Skip to content

Commit 01d5559

Browse files
committed
feat: add showToolbar props. #221
1 parent 6fe4514 commit 01d5559

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

core/README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,10 @@ export interface IMarkdownEditor extends ReactCodeMirrorProps {
288288
toolbarsFilter?: (tool: Commands, idx: number) => boolean;
289289
/** Toolbar on bottom */
290290
toolbarBottom?: boolean;
291-
/** Option to hide the tool bar. */
291+
/** Option to hide the tool bar. @deprecated The next major version will be deprecated. Please use `showToolbar`. */
292292
hideToolbar?: boolean;
293+
/** Option to hide the tool bar. */
294+
showToolbar?: boolean;
293295
/** [@uiw/react-markdown-preview](https://github.com/uiwjs/react-markdown-preview#options-props) options */
294296
previewProps?: MarkdownPreviewProps;
295297
/** replace the default `extensions` */

core/src/index.tsx

+7-3
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ export interface IMarkdownEditor extends ReactCodeMirrorProps {
4545
toolbarsFilter?: (tool: Commands, idx: number) => boolean;
4646
/** Toolbar on bottom */
4747
toolbarBottom?: boolean;
48-
/** Option to hide the tool bar. */
48+
/** Option to hide the tool bar. @deprecated The next major version will be deprecated. Please use `showToolbar`. */
4949
hideToolbar?: boolean;
50+
/** Option to hide the tool bar. */
51+
showToolbar?: boolean;
5052
/** [@uiw/react-markdown-preview](https://github.com/uiwjs/react-markdown-preview#options-props) options */
5153
previewProps?: MarkdownPreviewProps;
5254
/** replace the default `extensions` */
@@ -95,7 +97,8 @@ function MarkdownEditorInternal(
9597
visible = true,
9698
renderPreview,
9799
visibleEditor = true,
98-
hideToolbar = true,
100+
hideToolbar,
101+
showToolbar = true,
99102
toolbarBottom = false,
100103
enableScroll = true,
101104
enablePreview = true,
@@ -222,7 +225,8 @@ function MarkdownEditorInternal(
222225

223226
const tools = toolbarsFilter ? toolbars.filter(toolbarsFilter) : toolbars;
224227
const toolsMode = toolbarsFilter ? toolbarsMode.filter(toolbarsFilter) : toolbarsMode;
225-
const toolbarView = hideToolbar && (
228+
const isShowToolbar = hideToolbar ?? showToolbar;
229+
const toolbarView = isShowToolbar && (
226230
<div className={clsToolbar}>
227231
<ToolBar {...toolBarProps} toolbars={tools} />
228232
<ToolBar {...toolBarProps} toolbars={toolsMode} mode />

www/src/Example.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function ExampleDemo() {
2323
height="500px"
2424
value={mdstr}
2525
enableScroll={enableScroll}
26-
hideToolbar={hideToolbar}
26+
showToolbar={hideToolbar}
2727
toolbarBottom={toolbarBottom}
2828
/>
2929
<div style={{ marginTop: 10, display: 'flex', gap: '10px' }}>
@@ -37,7 +37,7 @@ export function ExampleDemo() {
3737
</button>
3838
<label>
3939
<input type="checkbox" checked={hideToolbar} onChange={(evn) => setHideToolbar(evn.target.checked)} />
40-
hideToolbar
40+
showToolbar
4141
</label>
4242
<label>
4343
<input type="checkbox" checked={enableScroll} onChange={(evn) => setEnableScroll(evn.target.checked)} />

0 commit comments

Comments
 (0)