Skip to content

Commit

Permalink
feat: add showToolbar props. #221
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Apr 21, 2024
1 parent 6fe4514 commit 01d5559
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,10 @@ export interface IMarkdownEditor extends ReactCodeMirrorProps {
toolbarsFilter?: (tool: Commands, idx: number) => boolean;
/** Toolbar on bottom */
toolbarBottom?: boolean;
/** Option to hide the tool bar. */
/** Option to hide the tool bar. @deprecated The next major version will be deprecated. Please use `showToolbar`. */
hideToolbar?: boolean;
/** Option to hide the tool bar. */
showToolbar?: boolean;
/** [@uiw/react-markdown-preview](https://github.com/uiwjs/react-markdown-preview#options-props) options */
previewProps?: MarkdownPreviewProps;
/** replace the default `extensions` */
Expand Down
10 changes: 7 additions & 3 deletions core/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ export interface IMarkdownEditor extends ReactCodeMirrorProps {
toolbarsFilter?: (tool: Commands, idx: number) => boolean;
/** Toolbar on bottom */
toolbarBottom?: boolean;
/** Option to hide the tool bar. */
/** Option to hide the tool bar. @deprecated The next major version will be deprecated. Please use `showToolbar`. */
hideToolbar?: boolean;
/** Option to hide the tool bar. */
showToolbar?: boolean;
/** [@uiw/react-markdown-preview](https://github.com/uiwjs/react-markdown-preview#options-props) options */
previewProps?: MarkdownPreviewProps;
/** replace the default `extensions` */
Expand Down Expand Up @@ -95,7 +97,8 @@ function MarkdownEditorInternal(
visible = true,
renderPreview,
visibleEditor = true,
hideToolbar = true,
hideToolbar,
showToolbar = true,
toolbarBottom = false,
enableScroll = true,
enablePreview = true,
Expand Down Expand Up @@ -222,7 +225,8 @@ function MarkdownEditorInternal(

const tools = toolbarsFilter ? toolbars.filter(toolbarsFilter) : toolbars;
const toolsMode = toolbarsFilter ? toolbarsMode.filter(toolbarsFilter) : toolbarsMode;
const toolbarView = hideToolbar && (
const isShowToolbar = hideToolbar ?? showToolbar;
const toolbarView = isShowToolbar && (
<div className={clsToolbar}>
<ToolBar {...toolBarProps} toolbars={tools} />
<ToolBar {...toolBarProps} toolbars={toolsMode} mode />
Expand Down
4 changes: 2 additions & 2 deletions www/src/Example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function ExampleDemo() {
height="500px"
value={mdstr}
enableScroll={enableScroll}
hideToolbar={hideToolbar}
showToolbar={hideToolbar}
toolbarBottom={toolbarBottom}
/>
<div style={{ marginTop: 10, display: 'flex', gap: '10px' }}>
Expand All @@ -37,7 +37,7 @@ export function ExampleDemo() {
</button>
<label>
<input type="checkbox" checked={hideToolbar} onChange={(evn) => setHideToolbar(evn.target.checked)} />
hideToolbar
showToolbar
</label>
<label>
<input type="checkbox" checked={enableScroll} onChange={(evn) => setEnableScroll(evn.target.checked)} />
Expand Down

0 comments on commit 01d5559

Please sign in to comment.