@@ -5,7 +5,7 @@ import { EditorView, ViewUpdate } from '@codemirror/view';
55import * as events from '@uiw/codemirror-extensions-events' ;
66import CodeMirror , { ReactCodeMirrorProps , ReactCodeMirrorRef } from '@uiw/react-codemirror' ;
77import MarkdownPreview , { MarkdownPreviewProps } from '@uiw/react-markdown-preview' ;
8- import ToolBar , { IToolBarProps } from './components/ToolBar' ;
8+ import ToolBar , { Commands } from './components/ToolBar' ;
99import { getCommands , getModeCommands } from './commands' ;
1010import { defaultTheme } from './theme' ;
1111import './index.less' ;
@@ -36,9 +36,11 @@ export interface IMarkdownEditor extends ReactCodeMirrorProps {
3636 /** Whether to enable scrolling */
3737 enableScroll ?: boolean ;
3838 /** Tool display settings. */
39- toolbars ?: IToolBarProps [ 'toolbars' ] ;
39+ toolbars ?: Commands [ ] ;
4040 /** The tool on the right shows the settings. */
41- toolbarsMode ?: IToolBarProps [ 'toolbars' ] ;
41+ toolbarsMode ?: Commands [ ] ;
42+ /** Tool display filter settings. */
43+ toolbarsFilter ?: ( tool : Commands , idx : number ) => boolean ;
4244 /** Toolbar on bottom */
4345 toolbarBottom ?: boolean ;
4446 /** Option to hide the tool bar. */
@@ -84,6 +86,7 @@ function MarkdownEditorInternal(
8486 onChange,
8587 toolbars = getCommands ( ) ,
8688 toolbarsMode = getModeCommands ( ) ,
89+ toolbarsFilter,
8790 visible = true ,
8891 renderPreview,
8992 visibleEditor = true ,
@@ -202,10 +205,13 @@ function MarkdownEditorInternal(
202205 ]
203206 . filter ( Boolean )
204207 . join ( ' ' ) ;
208+
209+ const tools = toolbarsFilter ? toolbars . filter ( toolbarsFilter ) : toolbars ;
210+ const toolsMode = toolbarsFilter ? toolbarsMode . filter ( toolbarsFilter ) : toolbarsMode ;
205211 const toolbarView = hideToolbar && (
206212 < div className = { clsToolbar } >
207- < ToolBar { ...toolBarProps } toolbars = { toolbars } />
208- < ToolBar { ...toolBarProps } toolbars = { toolbarsMode } mode />
213+ < ToolBar { ...toolBarProps } toolbars = { tools } />
214+ < ToolBar { ...toolBarProps } toolbars = { toolsMode } mode />
209215 </ div >
210216 ) ;
211217 const child = toolbarBottom ? (
0 commit comments