@uiw/react-md-editor 3.17.0 → 3.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +19 -1
  2. package/dist/mdeditor.css +22 -6
  3. package/dist/mdeditor.js +944 -698
  4. package/dist/mdeditor.min.css +1 -1
  5. package/dist/mdeditor.min.js +1 -1
  6. package/esm/Context.d.ts +1 -0
  7. package/esm/Editor.d.ts +5 -0
  8. package/esm/Editor.js +21 -13
  9. package/esm/Editor.js.map +4 -4
  10. package/esm/components/DragBar/index.css +1 -0
  11. package/esm/components/DragBar/index.less +1 -0
  12. package/esm/components/Toolbar/Child.js +0 -1
  13. package/esm/components/Toolbar/Child.js.map +2 -2
  14. package/esm/components/Toolbar/index.css +6 -1
  15. package/esm/components/Toolbar/index.d.ts +0 -2
  16. package/esm/components/Toolbar/index.js +0 -4
  17. package/esm/components/Toolbar/index.js.map +2 -3
  18. package/esm/components/Toolbar/index.less +6 -1
  19. package/esm/index.css +10 -3
  20. package/esm/index.less +9 -3
  21. package/lib/Context.d.ts +1 -0
  22. package/lib/Editor.d.ts +5 -0
  23. package/lib/Editor.js +24 -15
  24. package/lib/Editor.js.map +5 -5
  25. package/lib/components/DragBar/index.less +1 -0
  26. package/lib/components/Toolbar/Child.js +0 -1
  27. package/lib/components/Toolbar/Child.js.map +2 -2
  28. package/lib/components/Toolbar/index.d.ts +0 -2
  29. package/lib/components/Toolbar/index.js +0 -5
  30. package/lib/components/Toolbar/index.js.map +2 -3
  31. package/lib/components/Toolbar/index.less +6 -1
  32. package/lib/index.less +9 -3
  33. package/markdown-editor.css +17 -4
  34. package/package.json +2 -2
  35. package/src/Editor.tsx +30 -21
  36. package/src/components/DragBar/index.less +1 -0
  37. package/src/components/Toolbar/Child.tsx +1 -1
  38. package/src/components/Toolbar/index.less +6 -1
  39. package/src/components/Toolbar/index.tsx +2 -3
  40. package/src/index.less +9 -3
package/lib/Editor.js.map CHANGED
@@ -20,7 +20,6 @@
20
20
  "extraCommands",
21
21
  "getExtraCommands",
22
22
  "height",
23
- "toolbarHeight",
24
23
  "enableScroll",
25
24
  "visibleDragbar",
26
25
  "visiableDragbar",
@@ -80,19 +79,20 @@
80
79
  "type",
81
80
  "textareaDom",
82
81
  "previewDom",
83
- "mdp",
84
82
  "scale",
85
83
  "scrollHeight",
86
84
  "offsetHeight",
87
85
  "target",
86
+ "previewClassName",
88
87
  "mdPreview",
88
+ "React",
89
+ "isValidElement",
89
90
  "style",
90
91
  "test",
91
92
  "evn",
92
93
  "textarea",
93
94
  "newHeight",
94
95
  "mdEditor",
95
- "React",
96
96
  "forwardRef",
97
97
  "Markdown",
98
98
  "MarkdownPreview"
@@ -101,7 +101,7 @@
101
101
  "../src/Editor.tsx"
102
102
  ],
103
103
  "sourcesContent": [
104
- "import React, { useEffect, useReducer, useMemo, useRef, useImperativeHandle, CSSProperties } from 'react';\nimport MarkdownPreview, { MarkdownPreviewProps, MarkdownPreviewRef } from '@uiw/react-markdown-preview';\nimport TextArea, { ITextAreaProps } from './components/TextArea';\nimport Toolbar from './components/Toolbar';\nimport DragBar from './components/DragBar';\nimport { getCommands, getExtraCommands, ICommand } from './commands';\nimport { reducer, EditorContext, ContextStore, PreviewType } from './Context';\nimport './index.less';\n\nexport interface IProps {\n prefixCls?: string;\n className?: string;\n}\n\nexport interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'>, IProps {\n /**\n * The Markdown value.\n */\n value?: string;\n /**\n * Event handler for the `onChange` event.\n */\n onChange?: (value?: string, event?: React.ChangeEvent<HTMLTextAreaElement>, state?: ContextStore) => void;\n /**\n * editor height change listener\n */\n onHeightChange?: (value?: CSSProperties['height'], oldValue?: CSSProperties['height'], state?: ContextStore) => void;\n /**\n * Can be used to make `Markdown Editor` focus itself on initialization. Defaults to on.\n * it will be set to true when either the source `textarea` is focused,\n * or it has an `autofocus` attribute and no other element is focused.\n */\n autoFocus?: ITextAreaProps['autoFocus'];\n /**\n * The height of the editor.\n * ⚠️ `Dragbar` is invalid when **`height`** parameter percentage.\n */\n height?: CSSProperties['height'];\n /**\n * Custom toolbar heigth\n * @default 29px\n */\n toolbarHeight?: number;\n /**\n * Show drag and drop tool. Set the height of the editor.\n */\n visibleDragbar?: boolean;\n /**\n * @deprecated use `visibleDragbar`\n */\n visiableDragbar?: boolean;\n /**\n * Show markdown preview.\n */\n preview?: PreviewType;\n /**\n * Full screen display editor.\n */\n fullscreen?: boolean;\n /**\n * Disable `fullscreen` setting body styles\n */\n overflow?: boolean;\n /**\n * Maximum drag height. `visibleDragbar=true`\n */\n maxHeight?: number;\n /**\n * Minimum drag height. `visibleDragbar=true`\n */\n minHeight?: number;\n /**\n * This is reset [react-markdown](https://github.com/rexxars/react-markdown) settings.\n */\n previewOptions?: Omit<MarkdownPreviewProps, 'source'>;\n /**\n * Set the `textarea` related props.\n */\n textareaProps?: ITextAreaProps;\n /**\n * Use div to replace TextArea or re-render TextArea\n * @deprecated Please use ~~`renderTextarea`~~ -> `components`\n */\n renderTextarea?: ITextAreaProps['renderTextarea'];\n /**\n * re-render element\n */\n components?: {\n /** Use div to replace TextArea or re-render TextArea */\n textarea?: ITextAreaProps['renderTextarea'];\n /**\n * Override the default command element\n * _`toolbar`_ < _`command[].render`_\n */\n toolbar?: ICommand['render'];\n };\n /**\n * Disable editing area code highlighting. The value is `false`, which increases the editing speed.\n * @default true\n */\n highlightEnable?: boolean;\n /**\n * The number of characters to insert when pressing tab key.\n * Default `2` spaces.\n */\n tabSize?: number;\n /**\n * If `false`, the `tab` key inserts a tab character into the textarea. If `true`, the `tab` key executes default behavior e.g. focus shifts to next element.\n */\n defaultTabEnable?: boolean;\n /**\n * You can create your own commands or reuse existing commands.\n */\n commands?: ICommand[];\n /**\n * Filter or modify your commands.\n * https://github.com/uiwjs/react-md-editor/issues/296\n */\n commandsFilter?: (command: ICommand, isExtra: boolean) => false | ICommand;\n /**\n * You can create your own commands or reuse existing commands.\n */\n extraCommands?: ICommand[];\n /**\n * Hide the tool bar\n */\n hideToolbar?: boolean;\n /** Whether to enable scrolling */\n enableScroll?: boolean;\n /** Toolbar on bottom */\n toolbarBottom?: boolean;\n}\n\nfunction setGroupPopFalse(data: Record<string, boolean> = {}) {\n Object.keys(data).forEach((keyname) => {\n data[keyname] = false;\n });\n return data;\n}\n\nconst InternalMDEditor = (\n props: MDEditorProps,\n ref?: ((instance: ContextStore) => void) | React.RefObject<ContextStore> | null,\n) => {\n const {\n prefixCls = 'w-md-editor',\n className,\n value: propsValue,\n commands = getCommands(),\n commandsFilter,\n extraCommands = getExtraCommands(),\n height = 200,\n toolbarHeight = 29,\n enableScroll = true,\n visibleDragbar = typeof props.visiableDragbar === 'boolean' ? props.visiableDragbar : true,\n highlightEnable = true,\n preview: previewType = 'live',\n fullscreen = false,\n overflow = true,\n previewOptions = {},\n textareaProps,\n maxHeight = 1200,\n minHeight = 100,\n autoFocus,\n tabSize = 2,\n defaultTabEnable = false,\n onChange,\n onHeightChange,\n hideToolbar,\n toolbarBottom = false,\n components,\n renderTextarea,\n ...other\n } = props || {};\n const cmds = commands\n .map((item) => (commandsFilter ? commandsFilter(item, false) : item))\n .filter(Boolean) as ICommand[];\n const extraCmds = extraCommands\n .map((item) => (commandsFilter ? commandsFilter(item, true) : item))\n .filter(Boolean) as ICommand[];\n let [state, dispatch] = useReducer(reducer, {\n markdown: propsValue,\n preview: previewType,\n components,\n height,\n highlightEnable,\n tabSize,\n defaultTabEnable,\n scrollTop: 0,\n scrollTopPreview: 0,\n commands: cmds,\n extraCommands: extraCmds,\n fullscreen,\n barPopup: {},\n });\n const container = useRef<HTMLDivElement>(null);\n const previewRef = useRef<MarkdownPreviewRef>(null);\n const enableScrollRef = useRef(enableScroll);\n\n useImperativeHandle(ref, () => ({ ...state }));\n useMemo(() => (enableScrollRef.current = enableScroll), [enableScroll]);\n useEffect(() => {\n const stateInit: ContextStore = {};\n if (container.current) {\n stateInit.container = container.current || undefined;\n }\n stateInit.markdown = propsValue || '';\n stateInit.barPopup = {};\n if (dispatch) {\n dispatch({ ...state, ...stateInit });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const cls = [\n className,\n 'wmde-markdown-var',\n prefixCls,\n state.preview ? `${prefixCls}-show-${state.preview}` : null,\n state.fullscreen ? `${prefixCls}-fullscreen` : null,\n ]\n .filter(Boolean)\n .join(' ')\n .trim();\n\n useMemo(\n () => propsValue !== state.markdown && dispatch({ markdown: propsValue || '' }),\n [propsValue, state.markdown],\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useMemo(() => previewType !== state.preview && dispatch({ preview: previewType }), [previewType]);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useMemo(() => tabSize !== state.tabSize && dispatch({ tabSize }), [tabSize]);\n useMemo(\n () => highlightEnable !== state.highlightEnable && dispatch({ highlightEnable }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [highlightEnable],\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useMemo(() => autoFocus !== state.autoFocus && dispatch({ autoFocus: autoFocus }), [autoFocus]);\n useMemo(\n () => fullscreen !== state.fullscreen && dispatch({ fullscreen: fullscreen }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [fullscreen],\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useMemo(() => height !== state.height && dispatch({ height: height }), [height]);\n useMemo(\n () => height !== state.height && onHeightChange && onHeightChange(state.height, height, state),\n [height, onHeightChange, state],\n );\n\n const textareaDomRef = useRef<HTMLDivElement>();\n const active = useRef<'text' | 'preview'>('preview');\n const initScroll = useRef(false);\n\n useMemo(() => {\n textareaDomRef.current = state.textareaWarp;\n if (state.textareaWarp) {\n state.textareaWarp.addEventListener('mouseover', () => {\n active.current = 'text';\n });\n state.textareaWarp.addEventListener('mouseleave', () => {\n active.current = 'preview';\n });\n }\n }, [state.textareaWarp]);\n\n const handleScroll = (e: React.UIEvent<HTMLDivElement>, type: 'text' | 'preview') => {\n if (!enableScrollRef.current) return;\n const textareaDom = textareaDomRef.current;\n const previewDom = previewRef.current ? previewRef.current.mdp.current : undefined;\n if (!initScroll.current) {\n active.current = type;\n initScroll.current = true;\n }\n if (textareaDom && previewDom) {\n const scale =\n (textareaDom.scrollHeight - textareaDom.offsetHeight) / (previewDom.scrollHeight - previewDom.offsetHeight);\n if (e.target === textareaDom && active.current === 'text') {\n previewDom.scrollTop = textareaDom.scrollTop / scale;\n }\n if (e.target === previewDom && active.current === 'preview') {\n textareaDom.scrollTop = previewDom.scrollTop * scale;\n }\n let scrollTop = 0;\n if (active.current === 'text') {\n scrollTop = textareaDom.scrollTop || 0;\n } else if (active.current === 'preview') {\n scrollTop = previewDom.scrollTop || 0;\n }\n dispatch({ scrollTop });\n }\n };\n\n const mdPreview = useMemo(\n () => (\n <MarkdownPreview\n {...previewOptions}\n onScroll={(e) => handleScroll(e, 'preview')}\n ref={previewRef}\n source={state.markdown || ''}\n className={`${prefixCls}-preview ${previewOptions.className || ''}`}\n />\n ),\n [prefixCls, previewOptions, state.markdown],\n );\n return (\n <EditorContext.Provider value={{ ...state, dispatch }}>\n <div\n ref={container}\n className={cls}\n {...other}\n onClick={() => {\n dispatch({ barPopup: { ...setGroupPopFalse(state.barPopup) } });\n }}\n style={{\n ...other.style,\n height: state.height || '100%',\n }}\n >\n {!hideToolbar && !toolbarBottom && (\n <Toolbar prefixCls={prefixCls} height={toolbarHeight} overflow={overflow} toolbarBottom={toolbarBottom} />\n )}\n <div\n className={`${prefixCls}-content`}\n style={{\n height: `calc(100% - ${toolbarHeight}px)`,\n }}\n >\n {/(edit|live)/.test(state.preview || '') && (\n <TextArea\n className={`${prefixCls}-input`}\n prefixCls={prefixCls}\n autoFocus={autoFocus}\n {...textareaProps}\n onChange={(evn) => {\n onChange && onChange(evn.target.value, evn, state);\n if (textareaProps && textareaProps.onChange) {\n textareaProps.onChange(evn);\n }\n }}\n renderTextarea={components?.textarea || renderTextarea}\n onScroll={(e) => handleScroll(e, 'text')}\n />\n )}\n {/(live|preview)/.test(state.preview || '') && mdPreview}\n </div>\n {visibleDragbar && !state.fullscreen && (\n <DragBar\n prefixCls={prefixCls}\n height={state.height as number}\n maxHeight={maxHeight!}\n minHeight={minHeight!}\n onChange={(newHeight) => {\n dispatch({ height: newHeight });\n }}\n />\n )}\n {!hideToolbar && toolbarBottom && (\n <Toolbar prefixCls={prefixCls} height={toolbarHeight} overflow={overflow} toolbarBottom={toolbarBottom} />\n )}\n </div>\n </EditorContext.Provider>\n );\n};\n\nconst mdEditor = React.forwardRef<ContextStore, MDEditorProps>(InternalMDEditor);\n\ntype MDEditor = typeof mdEditor & {\n Markdown: typeof MarkdownPreview;\n};\n\n(mdEditor as MDEditor).Markdown = MarkdownPreview;\n\nexport default mdEditor as MDEditor;\n"
104
+ "import React, { useEffect, useReducer, useMemo, useRef, useImperativeHandle, CSSProperties } from 'react';\nimport MarkdownPreview, { MarkdownPreviewProps } from '@uiw/react-markdown-preview';\nimport TextArea, { ITextAreaProps } from './components/TextArea';\nimport Toolbar from './components/Toolbar';\nimport DragBar from './components/DragBar';\nimport { getCommands, getExtraCommands, ICommand } from './commands';\nimport { reducer, EditorContext, ContextStore, PreviewType } from './Context';\nimport './index.less';\n\nexport interface IProps {\n prefixCls?: string;\n className?: string;\n}\n\nexport interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'>, IProps {\n /**\n * The Markdown value.\n */\n value?: string;\n /**\n * Event handler for the `onChange` event.\n */\n onChange?: (value?: string, event?: React.ChangeEvent<HTMLTextAreaElement>, state?: ContextStore) => void;\n /**\n * editor height change listener\n */\n onHeightChange?: (value?: CSSProperties['height'], oldValue?: CSSProperties['height'], state?: ContextStore) => void;\n /**\n * Can be used to make `Markdown Editor` focus itself on initialization. Defaults to on.\n * it will be set to true when either the source `textarea` is focused,\n * or it has an `autofocus` attribute and no other element is focused.\n */\n autoFocus?: ITextAreaProps['autoFocus'];\n /**\n * The height of the editor.\n * ⚠️ `Dragbar` is invalid when **`height`** parameter percentage.\n */\n height?: CSSProperties['height'];\n /**\n * Custom toolbar heigth\n * @default 29px\n *\n * @deprecated toolbar height adaptive: https://github.com/uiwjs/react-md-editor/issues/427\n *\n */\n toolbarHeight?: number;\n /**\n * Show drag and drop tool. Set the height of the editor.\n */\n visibleDragbar?: boolean;\n /**\n * @deprecated use `visibleDragbar`\n */\n visiableDragbar?: boolean;\n /**\n * Show markdown preview.\n */\n preview?: PreviewType;\n /**\n * Full screen display editor.\n */\n fullscreen?: boolean;\n /**\n * Disable `fullscreen` setting body styles\n */\n overflow?: boolean;\n /**\n * Maximum drag height. `visibleDragbar=true`\n */\n maxHeight?: number;\n /**\n * Minimum drag height. `visibleDragbar=true`\n */\n minHeight?: number;\n /**\n * This is reset [react-markdown](https://github.com/rexxars/react-markdown) settings.\n */\n previewOptions?: Omit<MarkdownPreviewProps, 'source'>;\n /**\n * Set the `textarea` related props.\n */\n textareaProps?: ITextAreaProps;\n /**\n * Use div to replace TextArea or re-render TextArea\n * @deprecated Please use ~~`renderTextarea`~~ -> `components`\n */\n renderTextarea?: ITextAreaProps['renderTextarea'];\n /**\n * re-render element\n */\n components?: {\n /** Use div to replace TextArea or re-render TextArea */\n textarea?: ITextAreaProps['renderTextarea'];\n /**\n * Override the default command element\n * _`toolbar`_ < _`command[].render`_\n */\n toolbar?: ICommand['render'];\n /** Custom markdown preview */\n preview?: (source: string, state: ContextStore, dispath: React.Dispatch<ContextStore>) => JSX.Element;\n };\n /**\n * Disable editing area code highlighting. The value is `false`, which increases the editing speed.\n * @default true\n */\n highlightEnable?: boolean;\n /**\n * The number of characters to insert when pressing tab key.\n * Default `2` spaces.\n */\n tabSize?: number;\n /**\n * If `false`, the `tab` key inserts a tab character into the textarea. If `true`, the `tab` key executes default behavior e.g. focus shifts to next element.\n */\n defaultTabEnable?: boolean;\n /**\n * You can create your own commands or reuse existing commands.\n */\n commands?: ICommand[];\n /**\n * Filter or modify your commands.\n * https://github.com/uiwjs/react-md-editor/issues/296\n */\n commandsFilter?: (command: ICommand, isExtra: boolean) => false | ICommand;\n /**\n * You can create your own commands or reuse existing commands.\n */\n extraCommands?: ICommand[];\n /**\n * Hide the tool bar\n */\n hideToolbar?: boolean;\n /** Whether to enable scrolling */\n enableScroll?: boolean;\n /** Toolbar on bottom */\n toolbarBottom?: boolean;\n}\n\nfunction setGroupPopFalse(data: Record<string, boolean> = {}) {\n Object.keys(data).forEach((keyname) => {\n data[keyname] = false;\n });\n return data;\n}\n\nconst InternalMDEditor = (\n props: MDEditorProps,\n ref?: ((instance: ContextStore) => void) | React.RefObject<ContextStore> | null,\n) => {\n const {\n prefixCls = 'w-md-editor',\n className,\n value: propsValue,\n commands = getCommands(),\n commandsFilter,\n extraCommands = getExtraCommands(),\n height = 200,\n enableScroll = true,\n visibleDragbar = typeof props.visiableDragbar === 'boolean' ? props.visiableDragbar : true,\n highlightEnable = true,\n preview: previewType = 'live',\n fullscreen = false,\n overflow = true,\n previewOptions = {},\n textareaProps,\n maxHeight = 1200,\n minHeight = 100,\n autoFocus,\n tabSize = 2,\n defaultTabEnable = false,\n onChange,\n onHeightChange,\n hideToolbar,\n toolbarBottom = false,\n components,\n renderTextarea,\n ...other\n } = props || {};\n const cmds = commands\n .map((item) => (commandsFilter ? commandsFilter(item, false) : item))\n .filter(Boolean) as ICommand[];\n const extraCmds = extraCommands\n .map((item) => (commandsFilter ? commandsFilter(item, true) : item))\n .filter(Boolean) as ICommand[];\n let [state, dispatch] = useReducer(reducer, {\n markdown: propsValue,\n preview: previewType,\n components,\n height,\n highlightEnable,\n tabSize,\n defaultTabEnable,\n scrollTop: 0,\n scrollTopPreview: 0,\n commands: cmds,\n extraCommands: extraCmds,\n fullscreen,\n barPopup: {},\n });\n const container = useRef<HTMLDivElement>(null);\n const previewRef = useRef<HTMLDivElement>(null);\n const enableScrollRef = useRef(enableScroll);\n\n useImperativeHandle(ref, () => ({ ...state }));\n useMemo(() => (enableScrollRef.current = enableScroll), [enableScroll]);\n useEffect(() => {\n const stateInit: ContextStore = {};\n if (container.current) {\n stateInit.container = container.current || undefined;\n }\n stateInit.markdown = propsValue || '';\n stateInit.barPopup = {};\n if (dispatch) {\n dispatch({ ...state, ...stateInit });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const cls = [\n className,\n 'wmde-markdown-var',\n prefixCls,\n state.preview ? `${prefixCls}-show-${state.preview}` : null,\n state.fullscreen ? `${prefixCls}-fullscreen` : null,\n ]\n .filter(Boolean)\n .join(' ')\n .trim();\n\n useMemo(\n () => propsValue !== state.markdown && dispatch({ markdown: propsValue || '' }),\n [propsValue, state.markdown],\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useMemo(() => previewType !== state.preview && dispatch({ preview: previewType }), [previewType]);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useMemo(() => tabSize !== state.tabSize && dispatch({ tabSize }), [tabSize]);\n useMemo(\n () => highlightEnable !== state.highlightEnable && dispatch({ highlightEnable }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [highlightEnable],\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useMemo(() => autoFocus !== state.autoFocus && dispatch({ autoFocus: autoFocus }), [autoFocus]);\n useMemo(\n () => fullscreen !== state.fullscreen && dispatch({ fullscreen: fullscreen }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [fullscreen],\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useMemo(() => height !== state.height && dispatch({ height: height }), [height]);\n useMemo(\n () => height !== state.height && onHeightChange && onHeightChange(state.height, height, state),\n [height, onHeightChange, state],\n );\n\n const textareaDomRef = useRef<HTMLDivElement>();\n const active = useRef<'text' | 'preview'>('preview');\n const initScroll = useRef(false);\n\n useMemo(() => {\n textareaDomRef.current = state.textareaWarp;\n if (state.textareaWarp) {\n state.textareaWarp.addEventListener('mouseover', () => {\n active.current = 'text';\n });\n state.textareaWarp.addEventListener('mouseleave', () => {\n active.current = 'preview';\n });\n }\n }, [state.textareaWarp]);\n\n const handleScroll = (e: React.UIEvent<HTMLDivElement>, type: 'text' | 'preview') => {\n if (!enableScrollRef.current) return;\n const textareaDom = textareaDomRef.current;\n const previewDom = previewRef.current ? previewRef.current : undefined;\n if (!initScroll.current) {\n active.current = type;\n initScroll.current = true;\n }\n if (textareaDom && previewDom) {\n const scale =\n (textareaDom.scrollHeight - textareaDom.offsetHeight) / (previewDom.scrollHeight - previewDom.offsetHeight);\n if (e.target === textareaDom && active.current === 'text') {\n previewDom.scrollTop = textareaDom.scrollTop / scale;\n }\n if (e.target === previewDom && active.current === 'preview') {\n textareaDom.scrollTop = previewDom.scrollTop * scale;\n }\n let scrollTop = 0;\n if (active.current === 'text') {\n scrollTop = textareaDom.scrollTop || 0;\n } else if (active.current === 'preview') {\n scrollTop = previewDom.scrollTop || 0;\n }\n dispatch({ scrollTop });\n }\n };\n\n const previewClassName = `${prefixCls}-preview ${previewOptions.className || ''}`;\n let mdPreview = useMemo(\n () => (\n <div ref={previewRef} className={previewClassName}>\n <MarkdownPreview\n {...previewOptions}\n onScroll={(e) => handleScroll(e, 'preview')}\n source={state.markdown || ''}\n />\n </div>\n ),\n [previewClassName, previewOptions, state.markdown],\n );\n const preview = components?.preview && components?.preview(state.markdown || '', state, dispatch);\n if (preview && React.isValidElement(preview)) {\n mdPreview = (\n <div className={previewClassName} ref={previewRef} onScroll={(e) => handleScroll(e, 'preview')}>\n {preview}\n </div>\n );\n }\n\n return (\n <EditorContext.Provider value={{ ...state, dispatch }}>\n <div\n ref={container}\n className={cls}\n {...other}\n onClick={() => {\n dispatch({ barPopup: { ...setGroupPopFalse(state.barPopup) } });\n }}\n style={{\n ...other.style,\n height: state.height || '100%',\n }}\n >\n {!hideToolbar && !toolbarBottom && (\n <Toolbar prefixCls={prefixCls} overflow={overflow} toolbarBottom={toolbarBottom} />\n )}\n <div className={`${prefixCls}-content`}>\n {/(edit|live)/.test(state.preview || '') && (\n <TextArea\n className={`${prefixCls}-input`}\n prefixCls={prefixCls}\n autoFocus={autoFocus}\n {...textareaProps}\n onChange={(evn) => {\n onChange && onChange(evn.target.value, evn, state);\n if (textareaProps && textareaProps.onChange) {\n textareaProps.onChange(evn);\n }\n }}\n renderTextarea={components?.textarea || renderTextarea}\n onScroll={(e) => handleScroll(e, 'text')}\n />\n )}\n {/(live|preview)/.test(state.preview || '') && mdPreview}\n </div>\n {visibleDragbar && !state.fullscreen && (\n <DragBar\n prefixCls={prefixCls}\n height={state.height as number}\n maxHeight={maxHeight!}\n minHeight={minHeight!}\n onChange={(newHeight) => {\n dispatch({ height: newHeight });\n }}\n />\n )}\n {!hideToolbar && toolbarBottom && (\n <Toolbar prefixCls={prefixCls} overflow={overflow} toolbarBottom={toolbarBottom} />\n )}\n </div>\n </EditorContext.Provider>\n );\n};\n\nconst mdEditor = React.forwardRef<ContextStore, MDEditorProps>(InternalMDEditor);\n\ntype MDEditor = typeof mdEditor & {\n Markdown: typeof MarkdownPreview;\n};\n\n(mdEditor as MDEditor).Markdown = MarkdownPreview;\n\nexport default mdEditor as MDEditor;\n"
105
105
  ],
106
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AA+HA,SAASA,gBAAT,GAA8D;EAAA,IAApCC,IAAoC,uEAAJ,EAAI;EAC5DC,MAAM,CAACC,IAAP,CAAYF,IAAZ,EAAkBG,OAAlB,CAA0B,UAACC,OAAD,EAAa;IACrCJ,IAAI,CAACI,OAAD,CAAJ,GAAgB,KAAhB;EACD,CAFD;EAGA,OAAOJ,IAAP;AACD;;AAED,IAAMK,gBAAgB,GAAG,SAAnBA,gBAAmB,CACvBC,KADuB,EAEvBC,GAFuB,EAGpB;EACH,WA6BID,KAAK,IAAI,EA7Bb;EAAA,0BACEE,SADF;EAAA,IACEA,SADF,+BACc,aADd;EAAA,IAEEC,SAFF,QAEEA,SAFF;EAAA,IAGSC,UAHT,QAGEC,KAHF;EAAA,yBAIEC,QAJF;EAAA,IAIEA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,UAAU,CAAEmD,QAAZ,KAAwBlD,cAX1C;UAYE,QAAQ,EAAE,kBAACmC,CAAD;YAAA,OAAOD,YAAY,CAACC,CAAD,EAAI,MAAJ,CAAnB;UAAA;QAZZ,GAFJ,EAiBG,iBAAiBa,IAAjB,CAAsBlC,KAAK,CAAC9B,OAAN,IAAiB,EAAvC,KAA8C4D,SAjBjD;MAAA,EAfF,EAkCG/D,cAAc,IAAI,CAACiC,KAAK,CAAC5B,UAAzB,iBACC,qBAAC,mBAAD;QACE,SAAS,EAAEhB,SADb;QAEE,MAAM,EAAE4C,KAAK,CAACnC,MAFhB;QAGE,SAAS,EAAEW,SAHb;QAIE,SAAS,EAAEC,SAJb;QAKE,QAAQ,EAAE,kBAAC4D,SAAD,EAAe;UACvBpC,QAAQ,CAAC;YAAEpC,MAAM,EAAEwE;UAAV,CAAD,CAAR;QACD;MAPH,EAnCJ,EA6CG,CAACtD,WAAD,IAAgBC,aAAhB,iBACC,qBAAC,mBAAD;QAAS,SAAS,EAAE5B,SAApB;QAA+B,QAAQ,EAAEiB,QAAzC;QAAmD,aAAa,EAAEW;MAAlE,EA9CJ;IAAA;EADF,EADF;AAqDD,CArOD;;AAuOA,IAAMsD,QAAQ,gBAAGP,iBAAA,CAAMQ,UAAN,CAA8CtF,gBAA9C,CAAjB;;AAMCqF,QAAD,CAAuBE,QAAvB,GAAkCC,gCAAlC;eAEeH,Q"
107
107
  }
@@ -5,6 +5,7 @@
5
5
  position: absolute;
6
6
  cursor: s-resize;
7
7
  right: 0;
8
+ bottom: 0;
8
9
  margin-top: -11px;
9
10
  margin-right: 0;
10
11
  width: 14px;
@@ -39,7 +39,6 @@ function Child(props) {
39
39
  children: Array.isArray(commands) ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_["default"], (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
40
40
  commands: commands
41
41
  }, props), {}, {
42
- height: "",
43
42
  isChild: true
44
43
  })) : children
45
44
  });
@@ -20,7 +20,7 @@
20
20
  "../../../src/components/Toolbar/Child.tsx"
21
21
  ],
22
22
  "sourcesContent": [
23
- "import React, { useContext, useMemo } from 'react';\nimport './Child.less';\nimport Toolbar, { IToolbarProps } from './';\nimport { EditorContext } from '../../Context';\n\nexport type ChildProps = IToolbarProps & {\n children?: JSX.Element;\n groupName?: string;\n};\n\nexport default function Child(props: ChildProps) {\n const { prefixCls, groupName, commands, children } = props || {};\n const { barPopup = {} } = useContext(EditorContext);\n return useMemo(\n () => (\n <div\n className={`${prefixCls}-toolbar-child ${groupName && barPopup[groupName] ? 'active' : ''}`}\n onClick={(e) => e.stopPropagation()}\n >\n {Array.isArray(commands) ? <Toolbar commands={commands} {...props} height=\"\" isChild /> : children}\n </div>\n ),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [commands, barPopup, groupName, prefixCls],\n );\n}\n"
23
+ "import React, { useContext, useMemo } from 'react';\nimport './Child.less';\nimport Toolbar, { IToolbarProps } from './';\nimport { EditorContext } from '../../Context';\n\nexport type ChildProps = IToolbarProps & {\n children?: JSX.Element;\n groupName?: string;\n};\n\nexport default function Child(props: ChildProps) {\n const { prefixCls, groupName, commands, children } = props || {};\n const { barPopup = {} } = useContext(EditorContext);\n return useMemo(\n () => (\n <div\n className={`${prefixCls}-toolbar-child ${groupName && barPopup[groupName] ? 'active' : ''}`}\n onClick={(e) => e.stopPropagation()}\n >\n {Array.isArray(commands) ? <Toolbar commands={commands} {...props} isChild /> : children}\n </div>\n ),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [commands, barPopup, groupName, prefixCls],\n );\n}\n"
24
24
  ],
25
- "mappings": ";;;;;;;;;;;;;AAAA;;AAEA;;AACA;;;;AAOe,SAASA,KAAT,CAAeC,KAAf,EAAkC;EAC/C,WAAqDA,KAAK,IAAI,EAA9D;EAAA,IAAQC,SAAR,QAAQA,SAAR;EAAA,IAAmBC,SAAnB,QAAmBA,SAAnB;EAAA,IAA8BC,QAA9B,QAA8BA,QAA9B;EAAA,IAAwCC,QAAxC,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;MAAA,UAIGC,KAAK,CAACC,OAAN,CAAcT,QAAd,iBAA0B,qBAAC,YAAD;QAAS,QAAQ,EAAEA;MAAnB,GAAiCH,KAAjC;QAAwC,OAAO;MAA/C,GAA1B,GAA+EI;IAJlF,EADF;EAAA,CADK,EASL;EACA,CAACD,QAAD,EAAWI,QAAX,EAAqBL,SAArB,EAAgCD,SAAhC,CAVK,CAAP;AAYD"
26
26
  }
@@ -1,10 +1,8 @@
1
- import React from 'react';
2
1
  import { IProps } from '../../Editor';
3
2
  import { ICommand } from '../../commands';
4
3
  import './index.less';
5
4
  export interface IToolbarProps extends IProps {
6
5
  overflow?: boolean;
7
- height?: React.CSSProperties['height'];
8
6
  toolbarBottom?: boolean;
9
7
  onCommand?: (command: ICommand<string>, groupName?: string) => void;
10
8
  commands?: ICommand<string>[];
@@ -140,8 +140,6 @@ function ToolbarItems(props) {
140
140
  function Toolbar() {
141
141
  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
142
142
  var prefixCls = props.prefixCls,
143
- _props$height = props.height,
144
- height = _props$height === void 0 ? 29 : _props$height,
145
143
  toolbarBottom = props.toolbarBottom,
146
144
  isChild = props.isChild;
147
145
 
@@ -152,9 +150,6 @@ function Toolbar() {
152
150
  var bottomClassName = toolbarBottom ? 'bottom' : '';
153
151
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
154
152
  className: "".concat(prefixCls, "-toolbar ").concat(bottomClassName),
155
- style: {
156
- height: height
157
- },
158
153
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(ToolbarItems, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, props), {}, {
159
154
  commands: props.commands || commands || []
160
155
  })), !isChild && /*#__PURE__*/(0, _jsxRuntime.jsx)(ToolbarItems, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, props), {}, {
@@ -67,7 +67,6 @@
67
67
  "Array",
68
68
  "isArray",
69
69
  "Toolbar",
70
- "height",
71
70
  "toolbarBottom",
72
71
  "isChild",
73
72
  "extraCommands",
@@ -77,7 +76,7 @@
77
76
  "../../../src/components/Toolbar/index.tsx"
78
77
  ],
79
78
  "sourcesContent": [
80
- "import React, { Fragment, useContext, useEffect, useRef } from 'react';\nimport { IProps } from '../../Editor';\nimport { EditorContext, PreviewType, ContextStore } from '../../Context';\nimport { ICommand } from '../../commands';\nimport Child from './Child';\nimport './index.less';\n\nexport interface IToolbarProps extends IProps {\n overflow?: boolean;\n height?: React.CSSProperties['height'];\n toolbarBottom?: boolean;\n onCommand?: (command: ICommand<string>, groupName?: string) => void;\n commands?: ICommand<string>[];\n isChild?: boolean;\n}\n\nexport function ToolbarItems(props: IToolbarProps) {\n const { prefixCls, overflow } = props;\n const { fullscreen, preview, barPopup = {}, components, commandOrchestrator, dispatch } = useContext(EditorContext);\n const originalOverflow = useRef('');\n\n function handleClick(command: ICommand<string>, name?: string) {\n if (!dispatch) return;\n const state: ContextStore = { barPopup: { ...barPopup } };\n if (command.keyCommand === 'preview') {\n state.preview = command.value as PreviewType;\n }\n if (command.keyCommand === 'fullscreen') {\n state.fullscreen = !fullscreen;\n }\n if (props.commands && command.keyCommand === 'group') {\n props.commands.forEach((item) => {\n if (name === item.groupName) {\n state.barPopup![name!] = true;\n } else if (item.keyCommand) {\n state.barPopup![item.groupName!] = false;\n }\n });\n } else if (name || command.parent) {\n Object.keys(state.barPopup || {}).forEach((keyName) => {\n state.barPopup![keyName] = false;\n });\n }\n\n if (Object.keys(state).length) {\n dispatch({ ...state });\n }\n commandOrchestrator && commandOrchestrator.executeCommand(command);\n }\n\n useEffect(() => {\n if (document && overflow) {\n if (fullscreen) {\n // prevent scroll on fullscreen\n document.body.style.overflow = 'hidden';\n } else {\n // get the original overflow only the first time\n if (!originalOverflow.current) {\n originalOverflow.current = window.getComputedStyle(document.body, null).overflow;\n }\n // reset to the original overflow\n document.body.style.overflow = originalOverflow.current;\n }\n }\n }, [fullscreen, originalOverflow, overflow]);\n\n return (\n <ul>\n {(props.commands || []).map((item, idx) => {\n if (item.keyCommand === 'divider') {\n return <li key={idx} {...item.liProps} className={`${prefixCls}-toolbar-divider`} />;\n }\n if (!item.keyCommand) return <Fragment key={idx} />;\n const activeBtn =\n (fullscreen && item.keyCommand === 'fullscreen') || (item.keyCommand === 'preview' && preview === item.value);\n const childNode =\n item.children && typeof item.children === 'function'\n ? item.children({\n getState: () => commandOrchestrator!.getState(),\n textApi: commandOrchestrator ? commandOrchestrator!.textApi : undefined,\n close: () => handleClick({}, item.groupName),\n execute: () => handleClick({ execute: item.execute }),\n })\n : undefined;\n const disabled = barPopup && preview && preview === 'preview' && !/(preview|fullscreen)/.test(item.keyCommand);\n const render = components?.toolbar || item.render;\n const com = (\n render && typeof render === 'function' ? render(item, !!disabled, handleClick, idx) : null\n ) as React.ReactElement;\n return (\n <li key={idx} {...item.liProps} className={activeBtn ? `active` : ''}>\n {com && React.isValidElement(com) && com}\n {!com && !item.buttonProps && item.icon}\n {!com &&\n item.buttonProps &&\n React.createElement(\n 'button',\n {\n type: 'button',\n key: idx,\n disabled,\n 'data-name': item.name,\n ...item.buttonProps,\n onClick: (evn: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n evn.stopPropagation();\n handleClick(item, item.groupName);\n },\n },\n item.icon,\n )}\n {item.children && (\n <Child\n overflow={overflow}\n groupName={item.groupName}\n prefixCls={prefixCls}\n children={childNode}\n commands={Array.isArray(item.children) ? item.children : undefined}\n />\n )}\n </li>\n );\n })}\n </ul>\n );\n}\n\nexport default function Toolbar(props: IToolbarProps = {}) {\n const { prefixCls, height = 29, toolbarBottom, isChild } = props;\n const { commands, extraCommands } = useContext(EditorContext);\n const bottomClassName = toolbarBottom ? 'bottom' : '';\n return (\n <div className={`${prefixCls}-toolbar ${bottomClassName}`} style={{ height }}>\n <ToolbarItems {...props} commands={props.commands || commands || []} />\n {!isChild && <ToolbarItems {...props} commands={extraCommands || []} />}\n </div>\n );\n}\n"
79
+ "import React, { Fragment, useContext, useEffect, useRef } from 'react';\nimport { IProps } from '../../Editor';\nimport { EditorContext, PreviewType, ContextStore } from '../../Context';\nimport { ICommand } from '../../commands';\nimport Child from './Child';\nimport './index.less';\n\nexport interface IToolbarProps extends IProps {\n overflow?: boolean;\n toolbarBottom?: boolean;\n onCommand?: (command: ICommand<string>, groupName?: string) => void;\n commands?: ICommand<string>[];\n isChild?: boolean;\n}\n\nexport function ToolbarItems(props: IToolbarProps) {\n const { prefixCls, overflow } = props;\n const { fullscreen, preview, barPopup = {}, components, commandOrchestrator, dispatch } = useContext(EditorContext);\n const originalOverflow = useRef('');\n\n function handleClick(command: ICommand<string>, name?: string) {\n if (!dispatch) return;\n const state: ContextStore = { barPopup: { ...barPopup } };\n if (command.keyCommand === 'preview') {\n state.preview = command.value as PreviewType;\n }\n if (command.keyCommand === 'fullscreen') {\n state.fullscreen = !fullscreen;\n }\n if (props.commands && command.keyCommand === 'group') {\n props.commands.forEach((item) => {\n if (name === item.groupName) {\n state.barPopup![name!] = true;\n } else if (item.keyCommand) {\n state.barPopup![item.groupName!] = false;\n }\n });\n } else if (name || command.parent) {\n Object.keys(state.barPopup || {}).forEach((keyName) => {\n state.barPopup![keyName] = false;\n });\n }\n\n if (Object.keys(state).length) {\n dispatch({ ...state });\n }\n commandOrchestrator && commandOrchestrator.executeCommand(command);\n }\n\n useEffect(() => {\n if (document && overflow) {\n if (fullscreen) {\n // prevent scroll on fullscreen\n document.body.style.overflow = 'hidden';\n } else {\n // get the original overflow only the first time\n if (!originalOverflow.current) {\n originalOverflow.current = window.getComputedStyle(document.body, null).overflow;\n }\n // reset to the original overflow\n document.body.style.overflow = originalOverflow.current;\n }\n }\n }, [fullscreen, originalOverflow, overflow]);\n\n return (\n <ul>\n {(props.commands || []).map((item, idx) => {\n if (item.keyCommand === 'divider') {\n return <li key={idx} {...item.liProps} className={`${prefixCls}-toolbar-divider`} />;\n }\n if (!item.keyCommand) return <Fragment key={idx} />;\n const activeBtn =\n (fullscreen && item.keyCommand === 'fullscreen') || (item.keyCommand === 'preview' && preview === item.value);\n const childNode =\n item.children && typeof item.children === 'function'\n ? item.children({\n getState: () => commandOrchestrator!.getState(),\n textApi: commandOrchestrator ? commandOrchestrator!.textApi : undefined,\n close: () => handleClick({}, item.groupName),\n execute: () => handleClick({ execute: item.execute }),\n })\n : undefined;\n const disabled = barPopup && preview && preview === 'preview' && !/(preview|fullscreen)/.test(item.keyCommand);\n const render = components?.toolbar || item.render;\n const com = (\n render && typeof render === 'function' ? render(item, !!disabled, handleClick, idx) : null\n ) as React.ReactElement;\n return (\n <li key={idx} {...item.liProps} className={activeBtn ? `active` : ''}>\n {com && React.isValidElement(com) && com}\n {!com && !item.buttonProps && item.icon}\n {!com &&\n item.buttonProps &&\n React.createElement(\n 'button',\n {\n type: 'button',\n key: idx,\n disabled,\n 'data-name': item.name,\n ...item.buttonProps,\n onClick: (evn: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n evn.stopPropagation();\n handleClick(item, item.groupName);\n },\n },\n item.icon,\n )}\n {item.children && (\n <Child\n overflow={overflow}\n groupName={item.groupName}\n prefixCls={prefixCls}\n children={childNode}\n commands={Array.isArray(item.children) ? item.children : undefined}\n />\n )}\n </li>\n );\n })}\n </ul>\n );\n}\n\nexport default function Toolbar(props: IToolbarProps = {}) {\n const { prefixCls, toolbarBottom, isChild } = props;\n const { commands, extraCommands } = useContext(EditorContext);\n const bottomClassName = toolbarBottom ? 'bottom' : '';\n return (\n <div className={`${prefixCls}-toolbar ${bottomClassName}`}>\n <ToolbarItems {...props} commands={props.commands || commands || []} />\n {!isChild && <ToolbarItems {...props} commands={extraCommands || []} />}\n </div>\n );\n}\n"
81
80
  ],
82
- "mappings": ";;;;;;;;;;;;;;AAAA;;AAEA;;AAEA;;;;AAYO,SAASA,YAAT,CAAsBC,KAAtB,EAA4C;EACjD,IAAQC,SAAR,GAAgCD,KAAhC,CAAQC,SAAR;EAAA,IAAmBC,QAAnB,GAAgCF,KAAhC,CAAmBE,QAAnB;;EACA,kBAA0F,IAA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AACC,SAFlB;UAGE,SAAS,EAAErB,SAHb;UAIE,QAAQ,EAAEuC,SAJZ;UAKE,QAAQ,EAAEsB,KAAK,CAACC,OAAN,CAAc1C,IAAI,CAACoB,QAAnB,IAA+BpB,IAAI,CAACoB,QAApC,GAA+CG;QAL3D,EArBJ;MAAA,IAASP,GAAT,CADF;IAgCD,CArDA;EADH,EADF;AA0DD;;AAEc,SAAS2B,OAAT,GAA4C;EAAA,IAA3BhE,KAA2B,uEAAJ,EAAI;EACzD,IAAQC,SAAR,GAA8CD,KAA9C,CAAQC,SAAR;EAAA,IAAmBgE,aAAnB,GAA8CjE,KAA9C,CAAmBiE,aAAnB;EAAA,IAAkCC,OAAlC,GAA8ClE,KAA9C,CAAkCkE,OAAlC;;EACA,mBAAoC,IAAA/D,iBAAA,EAAWC,sBAAX,CAApC;EAAA,IAAQe,QAAR,gBAAQA,QAAR;EAAA,IAAkBgD,aAAlB,gBAAkBA,aAAlB;;EACA,IAAMC,eAAe,GAAGH,aAAa,GAAG,QAAH,GAAc,EAAnD;EACA,oBACE;IAAK,SAAS,YAAKhE,SAAL,sBAA0BmE,eAA1B,CAAd;IAAA,wBACE,qBAAC,YAAD,oEAAkBpE,KAAlB;MAAyB,QAAQ,EAAEA,KAAK,CAACmB,QAAN,IAAkBA,QAAlB,IAA8B;IAAjE,GADF,EAEG,CAAC+C,OAAD,iBAAY,qBAAC,YAAD,oEAAkBlE,KAAlB;MAAyB,QAAQ,EAAEmE,aAAa,IAAI;IAApD,GAFf;EAAA,EADF;AAMD"
83
82
  }
@@ -4,12 +4,13 @@
4
4
  &-toolbar {
5
5
  border-bottom: 1px solid var(--color-border-default);
6
6
  background-color: var(--color-canvas-default);
7
- padding: 0 5px 0 5px;
7
+ padding: 5px 5px;
8
8
  display: flex;
9
9
  justify-content: space-between;
10
10
  align-items: center;
11
11
  border-radius: 3px 3px 0 0;
12
12
  user-select: none;
13
+ flex-wrap: wrap;
13
14
  &.bottom {
14
15
  border-bottom: 0px;
15
16
  border-top: 1px solid var(--color-border-default);
@@ -20,10 +21,14 @@
20
21
  margin: 0;
21
22
  padding: 0;
22
23
  list-style: none;
24
+ line-height: initial;
23
25
  }
24
26
  li {
25
27
  display: inline-block;
26
28
  font-size: 14px;
29
+ & + li {
30
+ margin: 0;
31
+ }
27
32
  > button {
28
33
  border: none;
29
34
  height: 20px;
package/lib/index.less CHANGED
@@ -10,13 +10,19 @@
10
10
  0 1px 1px var(--color-border-default);
11
11
  background-color: var(--color-canvas-default);
12
12
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
13
- .copied {
14
- display: none !important;
13
+ display: flex;
14
+ flex-direction: column;
15
+ &-toolbar {
16
+ height: fit-content;
15
17
  }
16
18
  &-content {
19
+ height: 100%;
20
+ overflow: auto;
17
21
  position: relative;
18
22
  border-radius: 0 0 3px 0;
19
- height: calc(100% - 39.1px);
23
+ }
24
+ .copied {
25
+ display: none !important;
20
26
  }
21
27
  &-input {
22
28
  width: 50%;
@@ -2,6 +2,7 @@
2
2
  position: absolute;
3
3
  cursor: s-resize;
4
4
  right: 0;
5
+ bottom: 0;
5
6
  margin-top: -11px;
6
7
  margin-right: 0;
7
8
  width: 14px;
@@ -174,13 +175,14 @@
174
175
  .w-md-editor-toolbar {
175
176
  border-bottom: 1px solid var(--color-border-default);
176
177
  background-color: var(--color-canvas-default);
177
- padding: 0 5px 0 5px;
178
+ padding: 5px 5px;
178
179
  display: flex;
179
180
  justify-content: space-between;
180
181
  align-items: center;
181
182
  border-radius: 3px 3px 0 0;
182
183
  -webkit-user-select: none;
183
184
  user-select: none;
185
+ flex-wrap: wrap;
184
186
  }
185
187
  .w-md-editor-toolbar.bottom {
186
188
  border-bottom: 0px;
@@ -192,11 +194,15 @@
192
194
  margin: 0;
193
195
  padding: 0;
194
196
  list-style: none;
197
+ line-height: initial;
195
198
  }
196
199
  .w-md-editor-toolbar li {
197
200
  display: inline-block;
198
201
  font-size: 14px;
199
202
  }
203
+ .w-md-editor-toolbar li + li {
204
+ margin: 0;
205
+ }
200
206
  .w-md-editor-toolbar li > button {
201
207
  border: none;
202
208
  height: 20px;
@@ -251,14 +257,21 @@
251
257
  box-shadow: 0 0 0 1px var(--color-border-default), 0 0 0 var(--color-border-default), 0 1px 1px var(--color-border-default);
252
258
  background-color: var(--color-canvas-default);
253
259
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
260
+ display: flex;
261
+ flex-direction: column;
254
262
  }
255
- .w-md-editor .copied {
256
- display: none !important;
263
+ .w-md-editor-toolbar {
264
+ height: -webkit-fit-content;
265
+ height: fit-content;
257
266
  }
258
267
  .w-md-editor-content {
268
+ height: 100%;
269
+ overflow: auto;
259
270
  position: relative;
260
271
  border-radius: 0 0 3px 0;
261
- height: calc(100% - 39.1px);
272
+ }
273
+ .w-md-editor .copied {
274
+ display: none !important;
262
275
  }
263
276
  .w-md-editor-input {
264
277
  width: 50%;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uiw/react-md-editor",
3
- "version": "3.17.0",
3
+ "version": "3.18.0",
4
4
  "description": "A markdown editor with preview, implemented with React.js and TypeScript.",
5
5
  "homepage": "https://uiwjs.github.io/react-md-editor/",
6
6
  "author": "kenny wang <wowohoo@qq.com>",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@babel/runtime": "^7.14.6",
39
- "@uiw/react-markdown-preview": "^4.0.22",
39
+ "@uiw/react-markdown-preview": "^4.0.24",
40
40
  "rehype": "~12.0.1"
41
41
  },
42
42
  "keywords": [
package/src/Editor.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useReducer, useMemo, useRef, useImperativeHandle, CSSProperties } from 'react';
2
- import MarkdownPreview, { MarkdownPreviewProps, MarkdownPreviewRef } from '@uiw/react-markdown-preview';
2
+ import MarkdownPreview, { MarkdownPreviewProps } from '@uiw/react-markdown-preview';
3
3
  import TextArea, { ITextAreaProps } from './components/TextArea';
4
4
  import Toolbar from './components/Toolbar';
5
5
  import DragBar from './components/DragBar';
@@ -39,6 +39,9 @@ export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>
39
39
  /**
40
40
  * Custom toolbar heigth
41
41
  * @default 29px
42
+ *
43
+ * @deprecated toolbar height adaptive: https://github.com/uiwjs/react-md-editor/issues/427
44
+ *
42
45
  */
43
46
  toolbarHeight?: number;
44
47
  /**
@@ -93,6 +96,8 @@ export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>
93
96
  * _`toolbar`_ < _`command[].render`_
94
97
  */
95
98
  toolbar?: ICommand['render'];
99
+ /** Custom markdown preview */
100
+ preview?: (source: string, state: ContextStore, dispath: React.Dispatch<ContextStore>) => JSX.Element;
96
101
  };
97
102
  /**
98
103
  * Disable editing area code highlighting. The value is `false`, which increases the editing speed.
@@ -150,7 +155,6 @@ const InternalMDEditor = (
150
155
  commandsFilter,
151
156
  extraCommands = getExtraCommands(),
152
157
  height = 200,
153
- toolbarHeight = 29,
154
158
  enableScroll = true,
155
159
  visibleDragbar = typeof props.visiableDragbar === 'boolean' ? props.visiableDragbar : true,
156
160
  highlightEnable = true,
@@ -194,7 +198,7 @@ const InternalMDEditor = (
194
198
  barPopup: {},
195
199
  });
196
200
  const container = useRef<HTMLDivElement>(null);
197
- const previewRef = useRef<MarkdownPreviewRef>(null);
201
+ const previewRef = useRef<HTMLDivElement>(null);
198
202
  const enableScrollRef = useRef(enableScroll);
199
203
 
200
204
  useImperativeHandle(ref, () => ({ ...state }));
@@ -269,7 +273,7 @@ const InternalMDEditor = (
269
273
  const handleScroll = (e: React.UIEvent<HTMLDivElement>, type: 'text' | 'preview') => {
270
274
  if (!enableScrollRef.current) return;
271
275
  const textareaDom = textareaDomRef.current;
272
- const previewDom = previewRef.current ? previewRef.current.mdp.current : undefined;
276
+ const previewDom = previewRef.current ? previewRef.current : undefined;
273
277
  if (!initScroll.current) {
274
278
  active.current = type;
275
279
  initScroll.current = true;
@@ -293,18 +297,28 @@ const InternalMDEditor = (
293
297
  }
294
298
  };
295
299
 
296
- const mdPreview = useMemo(
300
+ const previewClassName = `${prefixCls}-preview ${previewOptions.className || ''}`;
301
+ let mdPreview = useMemo(
297
302
  () => (
298
- <MarkdownPreview
299
- {...previewOptions}
300
- onScroll={(e) => handleScroll(e, 'preview')}
301
- ref={previewRef}
302
- source={state.markdown || ''}
303
- className={`${prefixCls}-preview ${previewOptions.className || ''}`}
304
- />
303
+ <div ref={previewRef} className={previewClassName}>
304
+ <MarkdownPreview
305
+ {...previewOptions}
306
+ onScroll={(e) => handleScroll(e, 'preview')}
307
+ source={state.markdown || ''}
308
+ />
309
+ </div>
305
310
  ),
306
- [prefixCls, previewOptions, state.markdown],
311
+ [previewClassName, previewOptions, state.markdown],
307
312
  );
313
+ const preview = components?.preview && components?.preview(state.markdown || '', state, dispatch);
314
+ if (preview && React.isValidElement(preview)) {
315
+ mdPreview = (
316
+ <div className={previewClassName} ref={previewRef} onScroll={(e) => handleScroll(e, 'preview')}>
317
+ {preview}
318
+ </div>
319
+ );
320
+ }
321
+
308
322
  return (
309
323
  <EditorContext.Provider value={{ ...state, dispatch }}>
310
324
  <div
@@ -320,14 +334,9 @@ const InternalMDEditor = (
320
334
  }}
321
335
  >
322
336
  {!hideToolbar && !toolbarBottom && (
323
- <Toolbar prefixCls={prefixCls} height={toolbarHeight} overflow={overflow} toolbarBottom={toolbarBottom} />
337
+ <Toolbar prefixCls={prefixCls} overflow={overflow} toolbarBottom={toolbarBottom} />
324
338
  )}
325
- <div
326
- className={`${prefixCls}-content`}
327
- style={{
328
- height: `calc(100% - ${toolbarHeight}px)`,
329
- }}
330
- >
339
+ <div className={`${prefixCls}-content`}>
331
340
  {/(edit|live)/.test(state.preview || '') && (
332
341
  <TextArea
333
342
  className={`${prefixCls}-input`}
@@ -358,7 +367,7 @@ const InternalMDEditor = (
358
367
  />
359
368
  )}
360
369
  {!hideToolbar && toolbarBottom && (
361
- <Toolbar prefixCls={prefixCls} height={toolbarHeight} overflow={overflow} toolbarBottom={toolbarBottom} />
370
+ <Toolbar prefixCls={prefixCls} overflow={overflow} toolbarBottom={toolbarBottom} />
362
371
  )}
363
372
  </div>
364
373
  </EditorContext.Provider>
@@ -5,6 +5,7 @@
5
5
  position: absolute;
6
6
  cursor: s-resize;
7
7
  right: 0;
8
+ bottom: 0;
8
9
  margin-top: -11px;
9
10
  margin-right: 0;
10
11
  width: 14px;
@@ -17,7 +17,7 @@ export default function Child(props: ChildProps) {
17
17
  className={`${prefixCls}-toolbar-child ${groupName && barPopup[groupName] ? 'active' : ''}`}
18
18
  onClick={(e) => e.stopPropagation()}
19
19
  >
20
- {Array.isArray(commands) ? <Toolbar commands={commands} {...props} height="" isChild /> : children}
20
+ {Array.isArray(commands) ? <Toolbar commands={commands} {...props} isChild /> : children}
21
21
  </div>
22
22
  ),
23
23
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -4,12 +4,13 @@
4
4
  &-toolbar {
5
5
  border-bottom: 1px solid var(--color-border-default);
6
6
  background-color: var(--color-canvas-default);
7
- padding: 0 5px 0 5px;
7
+ padding: 5px 5px;
8
8
  display: flex;
9
9
  justify-content: space-between;
10
10
  align-items: center;
11
11
  border-radius: 3px 3px 0 0;
12
12
  user-select: none;
13
+ flex-wrap: wrap;
13
14
  &.bottom {
14
15
  border-bottom: 0px;
15
16
  border-top: 1px solid var(--color-border-default);
@@ -20,10 +21,14 @@
20
21
  margin: 0;
21
22
  padding: 0;
22
23
  list-style: none;
24
+ line-height: initial;
23
25
  }
24
26
  li {
25
27
  display: inline-block;
26
28
  font-size: 14px;
29
+ & + li {
30
+ margin: 0;
31
+ }
27
32
  > button {
28
33
  border: none;
29
34
  height: 20px;
@@ -7,7 +7,6 @@ import './index.less';
7
7
 
8
8
  export interface IToolbarProps extends IProps {
9
9
  overflow?: boolean;
10
- height?: React.CSSProperties['height'];
11
10
  toolbarBottom?: boolean;
12
11
  onCommand?: (command: ICommand<string>, groupName?: string) => void;
13
12
  commands?: ICommand<string>[];
@@ -125,11 +124,11 @@ export function ToolbarItems(props: IToolbarProps) {
125
124
  }
126
125
 
127
126
  export default function Toolbar(props: IToolbarProps = {}) {
128
- const { prefixCls, height = 29, toolbarBottom, isChild } = props;
127
+ const { prefixCls, toolbarBottom, isChild } = props;
129
128
  const { commands, extraCommands } = useContext(EditorContext);
130
129
  const bottomClassName = toolbarBottom ? 'bottom' : '';
131
130
  return (
132
- <div className={`${prefixCls}-toolbar ${bottomClassName}`} style={{ height }}>
131
+ <div className={`${prefixCls}-toolbar ${bottomClassName}`}>
133
132
  <ToolbarItems {...props} commands={props.commands || commands || []} />
134
133
  {!isChild && <ToolbarItems {...props} commands={extraCommands || []} />}
135
134
  </div>
package/src/index.less CHANGED
@@ -10,13 +10,19 @@
10
10
  0 1px 1px var(--color-border-default);
11
11
  background-color: var(--color-canvas-default);
12
12
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
13
- .copied {
14
- display: none !important;
13
+ display: flex;
14
+ flex-direction: column;
15
+ &-toolbar {
16
+ height: fit-content;
15
17
  }
16
18
  &-content {
19
+ height: 100%;
20
+ overflow: auto;
17
21
  position: relative;
18
22
  border-radius: 0 0 3px 0;
19
- height: calc(100% - 39.1px);
23
+ }
24
+ .copied {
25
+ display: none !important;
20
26
  }
21
27
  &-input {
22
28
  width: 50%;