From 0b320cd41d66d91b096f03122c2760bee3088832 Mon Sep 17 00:00:00 2001 From: Kevin Qualters <56408403+kqualters-elastic@users.noreply.github.com> Date: Wed, 14 Jun 2023 00:38:11 -0400 Subject: [PATCH] [EuiMarkdownEditor] Allow markdown plugins to disable toolbar button (#6840) * Allow markdown plugins to disable toolbar button * Add changelog * [PR feedback] changelog --------- Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> --- src/components/markdown_editor/markdown_editor_toolbar.tsx | 5 ++++- src/components/markdown_editor/markdown_types.ts | 1 + upcoming_changelogs/6840.md | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 upcoming_changelogs/6840.md diff --git a/src/components/markdown_editor/markdown_editor_toolbar.tsx b/src/components/markdown_editor/markdown_editor_toolbar.tsx index f179d092ecd..90459eefb62 100644 --- a/src/components/markdown_editor/markdown_editor_toolbar.tsx +++ b/src/components/markdown_editor/markdown_editor_toolbar.tsx @@ -93,6 +93,7 @@ interface EuiMarkdownEditorToolbarButtonProps { selectedNode: null | any; handleMdButtonClick: (mdButtonId: string) => void; isEditable: boolean; + isDisabled?: boolean; id: string; nodeId: string; label: string; @@ -102,6 +103,7 @@ const EuiMarkdownEditorToolbarButton = ({ selectedNode, handleMdButtonClick, isEditable, + isDisabled, id, nodeId, label, @@ -122,7 +124,7 @@ const EuiMarkdownEditorToolbarButton = ({ onClick={() => handleMdButtonClick(id)} iconType={icon} aria-label={label} - isDisabled={!isEditable} + isDisabled={!isEditable || isDisabled} /> ); }; @@ -205,6 +207,7 @@ export const EuiMarkdownEditorToolbar = forwardRef< selectedNode={selectedNode} handleMdButtonClick={handleMdButtonClick} isEditable={isEditable} + isDisabled={button.isDisabled} id={name} nodeId={name} label={button.label} diff --git a/src/components/markdown_editor/markdown_types.ts b/src/components/markdown_editor/markdown_types.ts index 307ee7cf206..ff6b94797e9 100644 --- a/src/components/markdown_editor/markdown_types.ts +++ b/src/components/markdown_editor/markdown_types.ts @@ -71,6 +71,7 @@ export type EuiMarkdownEditorUiPlugin = { button: { label: string; iconType: IconType; + isDisabled?: boolean; }; helpText?: ReactNode; } & (PluginWithImmediateFormatting | PluginWithDelayedFormatting); diff --git a/upcoming_changelogs/6840.md b/upcoming_changelogs/6840.md new file mode 100644 index 00000000000..451e5041f07 --- /dev/null +++ b/upcoming_changelogs/6840.md @@ -0,0 +1 @@ +- Added ability for `EuiMarkdownEditor` plugins to disable toolbar buttons