Skip to content

Commit

Permalink
[EuiMarkdownEditor] Allow markdown plugins to disable toolbar button (#…
Browse files Browse the repository at this point in the history
…6840)

* Allow markdown plugins to disable toolbar button

* Add changelog

* [PR feedback] changelog

---------

Co-authored-by: Cee Chen <[email protected]>
  • Loading branch information
kqualters-elastic and cee-chen authored Jun 14, 2023
1 parent 6bc7ed1 commit 0b320cd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/markdown_editor/markdown_editor_toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ interface EuiMarkdownEditorToolbarButtonProps {
selectedNode: null | any;
handleMdButtonClick: (mdButtonId: string) => void;
isEditable: boolean;
isDisabled?: boolean;
id: string;
nodeId: string;
label: string;
Expand All @@ -102,6 +103,7 @@ const EuiMarkdownEditorToolbarButton = ({
selectedNode,
handleMdButtonClick,
isEditable,
isDisabled,
id,
nodeId,
label,
Expand All @@ -122,7 +124,7 @@ const EuiMarkdownEditorToolbarButton = ({
onClick={() => handleMdButtonClick(id)}
iconType={icon}
aria-label={label}
isDisabled={!isEditable}
isDisabled={!isEditable || isDisabled}
/>
);
};
Expand Down Expand Up @@ -205,6 +207,7 @@ export const EuiMarkdownEditorToolbar = forwardRef<
selectedNode={selectedNode}
handleMdButtonClick={handleMdButtonClick}
isEditable={isEditable}
isDisabled={button.isDisabled}
id={name}
nodeId={name}
label={button.label}
Expand Down
1 change: 1 addition & 0 deletions src/components/markdown_editor/markdown_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export type EuiMarkdownEditorUiPlugin<NodeShape = any> = {
button: {
label: string;
iconType: IconType;
isDisabled?: boolean;
};
helpText?: ReactNode;
} & (PluginWithImmediateFormatting | PluginWithDelayedFormatting<NodeShape>);
Expand Down
1 change: 1 addition & 0 deletions upcoming_changelogs/6840.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Added ability for `EuiMarkdownEditor` plugins to disable toolbar buttons

0 comments on commit 0b320cd

Please sign in to comment.