@uiw/react-md-editor 3.20.1 → 3.20.2

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.
package/esm/Editor.d.ts CHANGED
@@ -31,7 +31,7 @@ export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>
31
31
  * The height of the editor.
32
32
  * ⚠️ `Dragbar` is invalid when **`height`** parameter percentage.
33
33
  */
34
- height?: CSSProperties['height'];
34
+ height?: number;
35
35
  /**
36
36
  * Custom toolbar heigth
37
37
  * @default 29px
package/esm/Editor.js.map CHANGED
@@ -110,7 +110,7 @@
110
110
  "../src/Editor.tsx"
111
111
  ],
112
112
  "sourcesContent": [
113
- "import React, { useEffect, useReducer, useMemo, useRef, useImperativeHandle, CSSProperties, PropsWithRef } 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 /** Theme configuration */\n 'data-color-mode'?: 'light' | 'dark';\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 * The **`direction`** property sets the direction of text, table columns, and horizontal overflow. Use `rtl` for languages written from right to left (like Hebrew or Arabic), and `ltr` for those written from left to right (like English and most other languages).\n *\n * https://github.com/uiwjs/react-md-editor/issues/462\n */\n direction?: CSSProperties['direction'];\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 direction,\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 direction ? `${prefixCls}-${direction}` : null,\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 const handlePreviewScroll = (e: React.UIEvent<HTMLDivElement, UIEvent>) => handleScroll(e, 'preview');\n let mdPreview = useMemo(\n () => (\n <div ref={previewRef} className={previewClassName}>\n <MarkdownPreview {...previewOptions} onScroll={handlePreviewScroll} source={state.markdown || ''} />\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={handlePreviewScroll}>\n {preview}\n </div>\n );\n }\n\n const containerStyle = { ...other.style, height: state.height || '100%' };\n const containerClick = () => dispatch({ barPopup: { ...setGroupPopFalse(state.barPopup) } });\n const dragBarChange = (newHeight: number) => dispatch({ height: newHeight });\n\n return (\n <EditorContext.Provider value={{ ...state, dispatch }}>\n <div ref={container} className={cls} {...other} onClick={containerClick} style={containerStyle}>\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={dragBarChange}\n />\n )}\n {!hideToolbar && toolbarBottom && (\n <Toolbar prefixCls={prefixCls} overflow={overflow} toolbarBottom={toolbarBottom} />\n )}\n </div>\n </EditorContext.Provider>\n );\n};\n\ntype Editor = React.FC<PropsWithRef<MDEditorProps>> & { Markdown: typeof MarkdownPreview };\n\nconst mdEditor: Editor = React.forwardRef(InternalMDEditor) as unknown as Editor;\n\nmdEditor.Markdown = MarkdownPreview;\n\nexport default mdEditor;\n"
113
+ "import React, { useEffect, useReducer, useMemo, useRef, useImperativeHandle, CSSProperties, PropsWithRef } 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?: number;\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 /** Theme configuration */\n 'data-color-mode'?: 'light' | 'dark';\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 * The **`direction`** property sets the direction of text, table columns, and horizontal overflow. Use `rtl` for languages written from right to left (like Hebrew or Arabic), and `ltr` for those written from left to right (like English and most other languages).\n *\n * https://github.com/uiwjs/react-md-editor/issues/462\n */\n direction?: CSSProperties['direction'];\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 direction,\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 direction ? `${prefixCls}-${direction}` : null,\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 const handlePreviewScroll = (e: React.UIEvent<HTMLDivElement, UIEvent>) => handleScroll(e, 'preview');\n let mdPreview = useMemo(\n () => (\n <div ref={previewRef} className={previewClassName}>\n <MarkdownPreview {...previewOptions} onScroll={handlePreviewScroll} source={state.markdown || ''} />\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={handlePreviewScroll}>\n {preview}\n </div>\n );\n }\n\n const containerStyle = { ...other.style, height: state.height || '100%' };\n const containerClick = () => dispatch({ barPopup: { ...setGroupPopFalse(state.barPopup) } });\n const dragBarChange = (newHeight: number) => dispatch({ height: newHeight });\n\n return (\n <EditorContext.Provider value={{ ...state, dispatch }}>\n <div ref={container} className={cls} {...other} onClick={containerClick} style={containerStyle}>\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={dragBarChange}\n />\n )}\n {!hideToolbar && toolbarBottom && (\n <Toolbar prefixCls={prefixCls} overflow={overflow} toolbarBottom={toolbarBottom} />\n )}\n </div>\n </EditorContext.Provider>\n );\n};\n\ntype Editor = React.FC<PropsWithRef<MDEditorProps>> & { Markdown: typeof MarkdownPreview };\n\nconst mdEditor: Editor = React.forwardRef(InternalMDEditor) as unknown as Editor;\n\nmdEditor.Markdown = MarkdownPreview;\n\nexport default mdEditor;\n"
114
114
  ],
115
115
  "mappings": ";;;AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,UAAU,EAAEC,OAAO,EAAEC,MAAM,EAAEC,mBAAmB,QAAqC,OAAO;AACvH,OAAOC,eAAe,MAAgC,6BAA6B;AACnF,OAAOC,QAAQ,MAA0B,uBAAuB;AAChE,OAAOC,OAAO,MAAM,sBAAsB;AAC1C,OAAOC,OAAO,MAAM,sBAAsB;AAC1C,SAASC,WAAW,EAAEC,gBAAgB,QAAkB,YAAY;AACpE,SAASC,OAAO,EAAEC,aAAa,QAAmC,WAAW;AAC7E;AAAsB;AAAA;AA2ItB,SAASC,gBAAgB,CAACC,IAA6B,EAAO;EAAA,IAApCA,IAA6B;IAA7BA,IAA6B,GAAG,CAAC,CAAC;EAAA;EAC1DC,MAAM,CAACC,IAAI,CAACF,IAAI,CAAC,CAACG,OAAO,CAAEC,OAAO,IAAK;IACrCJ,IAAI,CAACI,OAAO,CAAC,GAAG,KAAK;EACvB,CAAC,CAAC;EACF,OAAOJ,IAAI;AACb;AAEA,IAAMK,gBAAgB,GAAG,CACvBC,KAAoB,EACpBC,GAA+E,KAC5E;EACH,WA6BID,KAAK,IAAI,CAAC,CAAC;IA7BT;MACJE,SAAS,GAAG,aAAa;MACzBC,SAAS;MACTC,KAAK,EAAEC,UAAU;MACjBC,QAAQ,GAAGjB,WAAW,EAAE;MACxBkB,cAAc;MACdC,SAAS;MACTC,aAAa,GAAGnB,gBAAgB,EAAE;MAClCoB,MAAM,GAAG,GAAG;MACZC,YAAY,GAAG,IAAI;MACnBC,cAAc,GAAG,OAAOZ,KAAK,CAACa,eAAe,KAAK,SAAS,GAAGb,KAAK,CAACa,eAAe,GAAG,IAAI;MAC1FC,eAAe,GAAG,IAAI;MACtBC,OAAO,EAAEC,WAAW,GAAG,MAAM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I,CAACtC,KAAK,CAACxB,OAAO,IAAI,EAAE,CAAC,IAAIuD,SAAS;MAAA,EACpD,EACL1D,cAAc,IAAI,CAAC2B,KAAK,CAACtB,UAAU,iBAClC,KAAC,OAAO;QACN,SAAS,EAAEf,SAAU;QACrB,MAAM,EAAEqC,KAAK,CAAC7B,MAAiB;QAC/B,SAAS,EAAEW,SAAW;QACtB,SAAS,EAAEC,SAAW;QACtB,QAAQ,EAAEqD;MAAc,EAE3B,EACA,CAAC/C,WAAW,IAAIC,aAAa,iBAC5B,KAAC,OAAO;QAAC,SAAS,EAAE3B,SAAU;QAAC,QAAQ,EAAEgB,QAAS;QAAC,aAAa,EAAEW;MAAc,EACjF;IAAA;EACG,EACiB;AAE7B,CAAC;AAID,IAAMmD,QAAgB,gBAAGrG,KAAK,CAACsG,UAAU,CAAClF,gBAAgB,CAAsB;AAEhFiF,QAAQ,CAACE,QAAQ,GAAGjG,eAAe;AAEnC,eAAe+F,QAAQ"
116
116
  }
@@ -29,5 +29,5 @@
29
29
  "sourcesContent": [
30
30
  "import React from 'react';\nimport { insertAtLineStart } from '../utils/InsertTextAtPosition';\nimport { ICommand, TextState, TextAreaTextApi } from './';\n\nexport const title1: ICommand = {\n name: 'title1',\n keyCommand: 'title1',\n shortcuts: 'ctrlcmd+1',\n value: 'title1',\n buttonProps: { 'aria-label': 'Insert title1 (ctrl + 1)', title: 'Insert title1 (ctrl + 1)' },\n icon: <div style={{ fontSize: 18, textAlign: 'left' }}>Title 1</div>,\n execute: (state: TextState, api: TextAreaTextApi) => {\n if (state.selection.start === 0 || /\\n$/.test(state.text)) {\n api.replaceSelection('# ');\n } else {\n insertAtLineStart('# ', state.selection.start, api.textArea);\n }\n },\n};\n"
31
31
  ],
32
- "mappings": "AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,+BAA+B;AAAC;AAGlE,OAAO,IAAMC,MAAgB,GAAG;EAC9BC,IAAI,EAAE,QAAQ;EACdC,UAAU,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AAC,IAAI,CAAC;IAC5B,CAAC,MAAM;MACLlB,iBAAiB,CAAC,IAAI,EAAEY,KAAK,CAACE,SAAS,CAACC,KAAK,EAAEF,GAAG,CAACM,QAAQ,CAAC;IAC9D;EACF;AACF,CAAC"
33
33
  }
@@ -29,5 +29,5 @@
29
29
  "sourcesContent": [
30
30
  "import * as React from 'react';\nimport { insertAtLineStart } from '../utils/InsertTextAtPosition';\nimport { ICommand, TextState, TextAreaTextApi } from './';\n\nexport const title2: ICommand = {\n name: 'title2',\n keyCommand: 'title2',\n shortcuts: 'ctrlcmd+2',\n value: 'title2',\n buttonProps: { 'aria-label': 'Insert title2 (ctrl + 2)', title: 'Insert title2 (ctrl + 2)' },\n icon: <div style={{ fontSize: 16, textAlign: 'left' }}>Title 2</div>,\n execute: (state: TextState, api: TextAreaTextApi) => {\n if (state.selection.start === 0 || /\\n$/.test(state.text)) {\n api.replaceSelection('## ');\n } else {\n insertAtLineStart('## ', state.selection.start, api.textArea);\n }\n },\n};\n"
31
31
  ],
32
- "mappings": "AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,iBAAiB,QAAQ,+BAA+B;AAAC;AAGlE,OAAO,IAAMC,MAAgB,GAAG;EAC9BC,IAAI,EAAE,QAAQ;EACdC,UAAU,EAAE,QAAQ;EACpBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE,QAAQ;EACfC,WAAW,EAAE;IAAE,YAAY,EAAE,0BAA0B;IAAEC,KAAK,EAAE;EAA2B,CAAC;EAC5FC,IAAI,eAAE;IAAK,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAE;MAAEC,SAAS,EAAE;IAAO,CAAE;IAAA;EAAA,EAAc;EACpEC,OAAO,EAAE,CAACC,KAAgB,EAAEC,GAAoB,KAAK;IACnD,IAAID,KAAK,CAACE,SAAS,CAACC,KAAK,KAAK,CAAC,IAAI,KAAK,CAACC,IAAI,CAACJ,KAAK,CAACK,IAAI,CAAC,EAAE;MACzDJ,GAAG,CAACK,gBAAgB,CAAC,KAAK,CAAC;IAC7B,CAAC,MAAM;MACLlB,iBAAiB,CAAC,KAAK,EAAEY,KAAK,CAACE,SAAS,CAACC,KAAK,EAAEF,GAAG,CAACM,QAAQ,CAAC;IAC/D;EACF;AACF,CAAC"
32
+ "mappings": "AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,iBAAiB,QAAQ,+BAA+B;AAAC;AAGlE,OAAO,IAAMC,MAAgB,GAAG;EAC9BC,IAAI,EAAE,QAAQ;EACdC,UAAU,EAAE,QAAQ;EACpBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE,QAAQ;EACfC,WAAW,EAAE;IAAE,YAAY,EAAE,0BAA0B;IAAEC,KAAK,EAAE;EAA2B,CAAC;EAC5FC,IAAI,eAAE;IAAK,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAE;MAAEC,SAAS,EAAE;IAAO,CAAE;IAAA,UAAC;EAAO,EAAM;EACpEC,OAAO,EAAE,CAACC,KAAgB,EAAEC,GAAoB,KAAK;IACnD,IAAID,KAAK,CAACE,SAAS,CAACC,KAAK,KAAK,CAAC,IAAI,KAAK,CAACC,IAAI,CAACJ,KAAK,CAACK,IAAI,CAAC,EAAE;MACzDJ,GAAG,CAACK,gBAAgB,CAAC,KAAK,CAAC;IAC7B,CAAC,MAAM;MACLlB,iBAAiB,CAAC,KAAK,EAAEY,KAAK,CAACE,SAAS,CAACC,KAAK,EAAEF,GAAG,CAACM,QAAQ,CAAC;IAC/D;EACF;AACF,CAAC"
33
33
  }
@@ -29,5 +29,5 @@
29
29
  "sourcesContent": [
30
30
  "import * as React from 'react';\nimport { insertAtLineStart } from '../utils/InsertTextAtPosition';\nimport { ICommand, TextState, TextAreaTextApi } from './';\n\nexport const title3: ICommand = {\n name: 'title3',\n keyCommand: 'title3',\n shortcuts: 'ctrlcmd+3',\n value: 'title3',\n buttonProps: { 'aria-label': 'Insert title3 (ctrl + 3)', title: 'Insert title3 (ctrl + 3)' },\n icon: <div style={{ fontSize: 15, textAlign: 'left' }}>Title 3</div>,\n execute: (state: TextState, api: TextAreaTextApi) => {\n if (state.selection.start === 0 || /\\n$/.test(state.text)) {\n api.replaceSelection('### ');\n } else {\n insertAtLineStart('### ', state.selection.start, api.textArea);\n }\n },\n};\n"
31
31
  ],
32
- "mappings": "AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,iBAAiB,QAAQ,+BAA+B;AAAC;AAGlE,OAAO,IAAMC,MAAgB,GAAG;EAC9BC,IAAI,EAAE,QAAQ;EACdC,UAAU,EAAE,QAAQ;EACpBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE,QAAQ;EACfC,WAAW,EAAE;IAAE,YAAY,EAAE,0BAA0B;IAAEC,KAAK,EAAE;EAA2B,CAAC;EAC5FC,IAAI,eAAE;IAAK,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAE;MAAEC,SAAS,EAAE;IAAO,CAAE;IAAA;EAAA,EAAc;EACpEC,OAAO,EAAE,CAACC,KAAgB,EAAEC,GAAoB,KAAK;IACnD,IAAID,KAAK,CAACE,SAAS,CAACC,KAAK,KAAK,CAAC,IAAI,KAAK,CAACC,IAAI,CAACJ,KAAK,CAACK,IAAI,CAAC,EAAE;MACzDJ,GAAG,CAACK,gBAAgB,CAAC,MAAM,CAAC;IAC9B,CAAC,MAAM;MACLlB,iBAAiB,CAAC,MAAM,EAAEY,KAAK,CAACE,SAAS,CAACC,KAAK,EAAEF,GAAG,CAACM,QAAQ,CAAC;IAChE;EACF;AACF,CAAC"
32
+ "mappings": "AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,iBAAiB,QAAQ,+BAA+B;AAAC;AAGlE,OAAO,IAAMC,MAAgB,GAAG;EAC9BC,IAAI,EAAE,QAAQ;EACdC,UAAU,EAAE,QAAQ;EACpBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE,QAAQ;EACfC,WAAW,EAAE;IAAE,YAAY,EAAE,0BAA0B;IAAEC,KAAK,EAAE;EAA2B,CAAC;EAC5FC,IAAI,eAAE;IAAK,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAE;MAAEC,SAAS,EAAE;IAAO,CAAE;IAAA,UAAC;EAAO,EAAM;EACpEC,OAAO,EAAE,CAACC,KAAgB,EAAEC,GAAoB,KAAK;IACnD,IAAID,KAAK,CAACE,SAAS,CAACC,KAAK,KAAK,CAAC,IAAI,KAAK,CAACC,IAAI,CAACJ,KAAK,CAACK,IAAI,CAAC,EAAE;MACzDJ,GAAG,CAACK,gBAAgB,CAAC,MAAM,CAAC;IAC9B,CAAC,MAAM;MACLlB,iBAAiB,CAAC,MAAM,EAAEY,KAAK,CAACE,SAAS,CAACC,KAAK,EAAEF,GAAG,CAACM,QAAQ,CAAC;IAChE;EACF;AACF,CAAC"
33
33
  }
@@ -29,5 +29,5 @@
29
29
  "sourcesContent": [
30
30
  "import * as React from 'react';\nimport { insertAtLineStart } from '../utils/InsertTextAtPosition';\nimport { ICommand, TextState, TextAreaTextApi } from './';\n\nexport const title4: ICommand = {\n name: 'title4',\n keyCommand: 'title4',\n shortcuts: 'ctrlcmd+4',\n value: 'title4',\n buttonProps: { 'aria-label': 'Insert title4 (ctrl + 4)', title: 'Insert title4 (ctrl + 4)' },\n icon: <div style={{ fontSize: 14, textAlign: 'left' }}>Title 4</div>,\n execute: (state: TextState, api: TextAreaTextApi) => {\n if (state.selection.start === 0 || /\\n$/.test(state.text)) {\n api.replaceSelection('#### ');\n } else {\n insertAtLineStart('#### ', state.selection.start, api.textArea);\n }\n },\n};\n"
31
31
  ],
32
- "mappings": "AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,iBAAiB,QAAQ,+BAA+B;AAAC;AAGlE,OAAO,IAAMC,MAAgB,GAAG;EAC9BC,IAAI,EAAE,QAAQ;EACdC,UAAU,EAAE,QAAQ;EACpBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE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,CAAC,OAAO,EAAEY,KAAK,CAACE,SAAS,CAACC,KAAK,EAAEF,GAAG,CAACM,QAAQ,CAAC;IACjE;EACF;AACF,CAAC"
33
33
  }
@@ -29,5 +29,5 @@
29
29
  "sourcesContent": [
30
30
  "import * as React from 'react';\nimport { insertAtLineStart } from '../utils/InsertTextAtPosition';\nimport { ICommand, TextState, TextAreaTextApi } from './';\n\nexport const title5: ICommand = {\n name: 'title5',\n keyCommand: 'title5',\n shortcuts: 'ctrlcmd+5',\n value: 'title5',\n buttonProps: { 'aria-label': 'Insert title5 (ctrl + 5)', title: 'Insert title5 (ctrl + 5)' },\n icon: <div style={{ fontSize: 12, textAlign: 'left' }}>Title 5</div>,\n execute: (state: TextState, api: TextAreaTextApi) => {\n if (state.selection.start === 0 || /\\n$/.test(state.text)) {\n api.replaceSelection('##### ');\n } else {\n insertAtLineStart('##### ', state.selection.start, api.textArea);\n }\n },\n};\n"
31
31
  ],
32
- "mappings": "AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,iBAAiB,QAAQ,+BAA+B;AAAC;AAGlE,OAAO,IAAMC,MAAgB,GAAG;EAC9BC,IAAI,EAAE,QAAQ;EACdC,UAAU,EAAE,QAAQ;EACpBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE,QAAQ;EACfC,WAAW,EAAE;IAAE,YAAY,EAAE,0BAA0B;IAAEC,KAAK,EAAE;EAA2B,CAAC;EAC5FC,IAAI,eAAE;IAAK,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAE;MAAEC,SAAS,EAAE;IAAO,CAAE;IAAA;EAAA,EAAc;EACpEC,OAAO,EAAE,CAACC,KAAgB,EAAEC,GAAoB,KAAK;IACnD,IAAID,KAAK,CAACE,SAAS,CAACC,KAAK,KAAK,CAAC,IAAI,KAAK,CAACC,IAAI,CAACJ,KAAK,CAACK,IAAI,CAAC,EAAE;MACzDJ,GAAG,CAACK,gBAAgB,CAAC,QAAQ,CAAC;IAChC,CAAC,MAAM;MACLlB,iBAAiB,CAAC,QAAQ,EAAEY,KAAK,CAACE,SAAS,CAACC,KAAK,EAAEF,GAAG,CAACM,QAAQ,CAAC;IAClE;EACF;AACF,CAAC"
32
+ "mappings": "AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,iBAAiB,QAAQ,+BAA+B;AAAC;AAGlE,OAAO,IAAMC,MAAgB,GAAG;EAC9BC,IAAI,EAAE,QAAQ;EACdC,UAAU,EAAE,QAAQ;EACpBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE,QAAQ;EACfC,WAAW,EAAE;IAAE,YAAY,EAAE,0BAA0B;IAAEC,KAAK,EAAE;EAA2B,CAAC;EAC5FC,IAAI,eAAE;IAAK,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAE;MAAEC,SAAS,EAAE;IAAO,CAAE;IAAA,UAAC;EAAO,EAAM;EACpEC,OAAO,EAAE,CAACC,KAAgB,EAAEC,GAAoB,KAAK;IACnD,IAAID,KAAK,CAACE,SAAS,CAACC,KAAK,KAAK,CAAC,IAAI,KAAK,CAACC,IAAI,CAACJ,KAAK,CAACK,IAAI,CAAC,EAAE;MACzDJ,GAAG,CAACK,gBAAgB,CAAC,QAAQ,CAAC;IAChC,CAAC,MAAM;MACLlB,iBAAiB,CAAC,QAAQ,EAAEY,KAAK,CAACE,SAAS,CAACC,KAAK,EAAEF,GAAG,CAACM,QAAQ,CAAC;IAClE;EACF;AACF,CAAC"
33
33
  }
@@ -29,5 +29,5 @@
29
29
  "sourcesContent": [
30
30
  "import * as React from 'react';\nimport { insertAtLineStart } from '../utils/InsertTextAtPosition';\nimport { ICommand, TextState, TextAreaTextApi } from './';\n\nexport const title6: ICommand = {\n name: 'title6',\n keyCommand: 'title6',\n shortcuts: 'ctrlcmd+6',\n value: 'title6',\n buttonProps: { 'aria-label': 'Insert title6 (ctrl + 6)', title: 'Insert title6 (ctrl + 6)' },\n icon: <div style={{ fontSize: 12, textAlign: 'left' }}>Title 6</div>,\n execute: (state: TextState, api: TextAreaTextApi) => {\n if (state.selection.start === 0 || /\\n$/.test(state.text)) {\n api.replaceSelection('###### ');\n } else {\n insertAtLineStart('###### ', state.selection.start, api.textArea);\n }\n },\n};\n"
31
31
  ],
32
- "mappings": "AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,iBAAiB,QAAQ,+BAA+B;AAAC;AAGlE,OAAO,IAAMC,MAAgB,GAAG;EAC9BC,IAAI,EAAE,QAAQ;EACdC,UAAU,EAAE,QAAQ;EACpBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE,QAAQ;EACfC,WAAW,EAAE;IAAE,YAAY,EAAE,0BAA0B;IAAEC,KAAK,EAAE;EAA2B,CAAC;EAC5FC,IAAI,eAAE;IAAK,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAE;MAAEC,SAAS,EAAE;IAAO,CAAE;IAAA;EAAA,EAAc;EACpEC,OAAO,EAAE,CAACC,KAAgB,EAAEC,GAAoB,KAAK;IACnD,IAAID,KAAK,CAACE,SAAS,CAACC,KAAK,KAAK,CAAC,IAAI,KAAK,CAACC,IAAI,CAACJ,KAAK,CAACK,IAAI,CAAC,EAAE;MACzDJ,GAAG,CAACK,gBAAgB,CAAC,SAAS,CAAC;IACjC,CAAC,MAAM;MACLlB,iBAAiB,CAAC,SAAS,EAAEY,KAAK,CAACE,SAAS,CAACC,KAAK,EAAEF,GAAG,CAACM,QAAQ,CAAC;IACnE;EACF;AACF,CAAC"
32
+ "mappings": "AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,iBAAiB,QAAQ,+BAA+B;AAAC;AAGlE,OAAO,IAAMC,MAAgB,GAAG;EAC9BC,IAAI,EAAE,QAAQ;EACdC,UAAU,EAAE,QAAQ;EACpBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE,QAAQ;EACfC,WAAW,EAAE;IAAE,YAAY,EAAE,0BAA0B;IAAEC,KAAK,EAAE;EAA2B,CAAC;EAC5FC,IAAI,eAAE;IAAK,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAE;MAAEC,SAAS,EAAE;IAAO,CAAE;IAAA,UAAC;EAAO,EAAM;EACpEC,OAAO,EAAE,CAACC,KAAgB,EAAEC,GAAoB,KAAK;IACnD,IAAID,KAAK,CAACE,SAAS,CAACC,KAAK,KAAK,CAAC,IAAI,KAAK,CAACC,IAAI,CAACJ,KAAK,CAACK,IAAI,CAAC,EAAE;MACzDJ,GAAG,CAACK,gBAAgB,CAAC,SAAS,CAAC;IACjC,CAAC,MAAM;MACLlB,iBAAiB,CAAC,SAAS,EAAEY,KAAK,CAACE,SAAS,CAACC,KAAK,EAAEF,GAAG,CAACM,QAAQ,CAAC;IACnE;EACF;AACF,CAAC"
33
33
  }
package/lib/Editor.d.ts CHANGED
@@ -31,7 +31,7 @@ export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>
31
31
  * The height of the editor.
32
32
  * ⚠️ `Dragbar` is invalid when **`height`** parameter percentage.
33
33
  */
34
- height?: CSSProperties['height'];
34
+ height?: number;
35
35
  /**
36
36
  * Custom toolbar heigth
37
37
  * @default 29px
package/lib/Editor.js.map CHANGED
@@ -106,7 +106,7 @@
106
106
  "../src/Editor.tsx"
107
107
  ],
108
108
  "sourcesContent": [
109
- "import React, { useEffect, useReducer, useMemo, useRef, useImperativeHandle, CSSProperties, PropsWithRef } 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 /** Theme configuration */\n 'data-color-mode'?: 'light' | 'dark';\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 * The **`direction`** property sets the direction of text, table columns, and horizontal overflow. Use `rtl` for languages written from right to left (like Hebrew or Arabic), and `ltr` for those written from left to right (like English and most other languages).\n *\n * https://github.com/uiwjs/react-md-editor/issues/462\n */\n direction?: CSSProperties['direction'];\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 direction,\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 direction ? `${prefixCls}-${direction}` : null,\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 const handlePreviewScroll = (e: React.UIEvent<HTMLDivElement, UIEvent>) => handleScroll(e, 'preview');\n let mdPreview = useMemo(\n () => (\n <div ref={previewRef} className={previewClassName}>\n <MarkdownPreview {...previewOptions} onScroll={handlePreviewScroll} source={state.markdown || ''} />\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={handlePreviewScroll}>\n {preview}\n </div>\n );\n }\n\n const containerStyle = { ...other.style, height: state.height || '100%' };\n const containerClick = () => dispatch({ barPopup: { ...setGroupPopFalse(state.barPopup) } });\n const dragBarChange = (newHeight: number) => dispatch({ height: newHeight });\n\n return (\n <EditorContext.Provider value={{ ...state, dispatch }}>\n <div ref={container} className={cls} {...other} onClick={containerClick} style={containerStyle}>\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={dragBarChange}\n />\n )}\n {!hideToolbar && toolbarBottom && (\n <Toolbar prefixCls={prefixCls} overflow={overflow} toolbarBottom={toolbarBottom} />\n )}\n </div>\n </EditorContext.Provider>\n );\n};\n\ntype Editor = React.FC<PropsWithRef<MDEditorProps>> & { Markdown: typeof MarkdownPreview };\n\nconst mdEditor: Editor = React.forwardRef(InternalMDEditor) as unknown as Editor;\n\nmdEditor.Markdown = MarkdownPreview;\n\nexport default mdEditor;\n"
109
+ "import React, { useEffect, useReducer, useMemo, useRef, useImperativeHandle, CSSProperties, PropsWithRef } 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?: number;\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 /** Theme configuration */\n 'data-color-mode'?: 'light' | 'dark';\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 * The **`direction`** property sets the direction of text, table columns, and horizontal overflow. Use `rtl` for languages written from right to left (like Hebrew or Arabic), and `ltr` for those written from left to right (like English and most other languages).\n *\n * https://github.com/uiwjs/react-md-editor/issues/462\n */\n direction?: CSSProperties['direction'];\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 direction,\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 direction ? `${prefixCls}-${direction}` : null,\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 const handlePreviewScroll = (e: React.UIEvent<HTMLDivElement, UIEvent>) => handleScroll(e, 'preview');\n let mdPreview = useMemo(\n () => (\n <div ref={previewRef} className={previewClassName}>\n <MarkdownPreview {...previewOptions} onScroll={handlePreviewScroll} source={state.markdown || ''} />\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={handlePreviewScroll}>\n {preview}\n </div>\n );\n }\n\n const containerStyle = { ...other.style, height: state.height || '100%' };\n const containerClick = () => dispatch({ barPopup: { ...setGroupPopFalse(state.barPopup) } });\n const dragBarChange = (newHeight: number) => dispatch({ height: newHeight });\n\n return (\n <EditorContext.Provider value={{ ...state, dispatch }}>\n <div ref={container} className={cls} {...other} onClick={containerClick} style={containerStyle}>\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={dragBarChange}\n />\n )}\n {!hideToolbar && toolbarBottom && (\n <Toolbar prefixCls={prefixCls} overflow={overflow} toolbarBottom={toolbarBottom} />\n )}\n </div>\n </EditorContext.Provider>\n );\n};\n\ntype Editor = React.FC<PropsWithRef<MDEditorProps>> & { Markdown: typeof MarkdownPreview };\n\nconst mdEditor: Editor = React.forwardRef(InternalMDEditor) as unknown as Editor;\n\nmdEditor.Markdown = MarkdownPreview;\n\nexport default mdEditor;\n"
110
110
  ],
111
111
  "mappings": ";;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAA8E;AAAA;AA4I9E,SAASA,gBAAgB,GAAqC;EAAA,IAApCC,IAA6B,uEAAG,CAAC,CAAC;EAC1DC,MAAM,CAACC,IAAI,CAACF,IAAI,CAAC,CAACG,OAAO,CAAC,UAACC,OAAO,EAAK;IACrCJ,IAAI,CAACI,OAAO,CAAC,GAAG,KAAK;EACvB,CAAC,CAAC;EACF,OAAOJ,IAAI;AACb;AAEA,IAAMK,gBAAgB,GAAG,SAAnBA,gBAAgB,CACpBC,KAAoB,EACpBC,GAA+E,EAC5E;EACH,WA6BID,KAAK,IAAI,CAAC,CAAC;IAAA,sBA5BbE,SAAS;IAATA,SAAS,+BAAG,aAAa;IACzBC,SAAS,QAATA,SAAS;IACFC,UAAU,QAAjBC,KAAK;IAAA,qBACLC,QAAQ;IAARA,QAAQ,8BAAG,IAAAC,qBAAW,GAAE;IACxBC,cAAc,QAAdA,cAAc;IACdC,SAAS,QAATA,SAAS;IAAA,0BACTC,aAAa;IAAbA,aAAa,mCAAG,IAAAC,0BAAgB,GAAE;IAAA,mBAClCC,MAAM;IAANA,MAAM,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ACLhE,cAAc,IAAI,CAACiC,KAAK,CAAC5B,UAAU,iBAClC,qBAAC,mBAAO;QACN,SAAS,EAAEjB,SAAU;QACrB,MAAM,EAAE6C,KAAK,CAACnC,MAAiB;QAC/B,SAAS,EAAEW,SAAW;QACtB,SAAS,EAAEC,SAAW;QACtB,QAAQ,EAAE4D;MAAc,EAE3B,EACA,CAACtD,WAAW,IAAIC,aAAa,iBAC5B,qBAAC,mBAAO;QAAC,SAAS,EAAE7B,SAAU;QAAC,QAAQ,EAAEkB,QAAS;QAAC,aAAa,EAAEW;MAAc,EACjF;IAAA;EACG,EACiB;AAE7B,CAAC;AAID,IAAM0D,QAAgB,gBAAGV,iBAAK,CAACW,UAAU,CAAC3F,gBAAgB,CAAsB;AAEhF0F,QAAQ,CAACE,QAAQ,GAAGC,gCAAe;AAAC,eAErBH,QAAQ;AAAA;AAAA"
112
112
  }
@@ -28,5 +28,5 @@
28
28
  "sourcesContent": [
29
29
  "import React from 'react';\nimport { insertAtLineStart } from '../utils/InsertTextAtPosition';\nimport { ICommand, TextState, TextAreaTextApi } from './';\n\nexport const title1: ICommand = {\n name: 'title1',\n keyCommand: 'title1',\n shortcuts: 'ctrlcmd+1',\n value: 'title1',\n buttonProps: { 'aria-label': 'Insert title1 (ctrl + 1)', title: 'Insert title1 (ctrl + 1)' },\n icon: <div style={{ fontSize: 18, textAlign: 'left' }}>Title 1</div>,\n execute: (state: TextState, api: TextAreaTextApi) => {\n if (state.selection.start === 0 || /\\n$/.test(state.text)) {\n api.replaceSelection('# ');\n } else {\n insertAtLineStart('# ', state.selection.start, api.textArea);\n }\n },\n};\n"
30
30
  ],
31
- "mappings": ";;;;;;;AAAA;AACA;AAAkE;AAG3D,IAAMA,MAAgB,GAAG;EAC9BC,IAAI,EAAE,QAAQ;EACdC,UAAU,EAAE,QAAQ;EACpBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE,QAAQ;EACfC,WAAW,EAAE;IAAE,YAAY,EAAE,0BAA0B;IAAE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,CAAC;AAAC"
32
32
  }
@@ -28,5 +28,5 @@
28
28
  "sourcesContent": [
29
29
  "import * as React from 'react';\nimport { insertAtLineStart } from '../utils/InsertTextAtPosition';\nimport { ICommand, TextState, TextAreaTextApi } from './';\n\nexport const title2: ICommand = {\n name: 'title2',\n keyCommand: 'title2',\n shortcuts: 'ctrlcmd+2',\n value: 'title2',\n buttonProps: { 'aria-label': 'Insert title2 (ctrl + 2)', title: 'Insert title2 (ctrl + 2)' },\n icon: <div style={{ fontSize: 16, textAlign: 'left' }}>Title 2</div>,\n execute: (state: TextState, api: TextAreaTextApi) => {\n if (state.selection.start === 0 || /\\n$/.test(state.text)) {\n api.replaceSelection('## ');\n } else {\n insertAtLineStart('## ', state.selection.start, api.textArea);\n }\n },\n};\n"
30
30
  ],
31
- "mappings": ";;;;;;;AAAA;AACA;AAAkE;AAG3D,IAAMA,MAAgB,GAAG;EAC9BC,IAAI,EAAE,QAAQ;EACdC,UAAU,EAAE,QAAQ;EACpBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE,QAAQ;EACfC,WAAW,EAAE;IAAE,YAAY,EAAE,0BAA0B;IAAEC,KAAK,EAAE;EAA2B,CAAC;EAC5FC,IAAI,eAAE;IAAK,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAE;MAAEC,SAAS,EAAE;IAAO,CAAE;IAAA;EAAA,EAAc;EACpEC,OAAO,EAAE,iBAACC,KAAgB,EAAEC,GAAoB,EAAK;IACnD,IAAID,KAAK,CAACE,SAAS,CAACC,KAAK,KAAK,CAAC,IAAI,KAAK,CAACC,IAAI,CAACJ,KAAK,CAACK,IAAI,CAAC,EAAE;MACzDJ,GAAG,CAACK,gBAAgB,CAAC,KAAK,CAAC;IAC7B,CAAC,MAAM;MACL,IAAAC,uCAAiB,EAAC,KAAK,EAAEP,KAAK,CAACE,SAAS,CAACC,KAAK,EAAEF,GAAG,CAACO,QAAQ,CAAC;IAC/D;EACF;AACF,CAAC;AAAC"
31
+ "mappings": ";;;;;;;AAAA;AACA;AAAkE;AAG3D,IAAMA,MAAgB,GAAG;EAC9BC,IAAI,EAAE,QAAQ;EACdC,UAAU,EAAE,QAAQ;EACpBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE,QAAQ;EACfC,WAAW,EAAE;IAAE,YAAY,EAAE,0BAA0B;IAAEC,KAAK,EAAE;EAA2B,CAAC;EAC5FC,IAAI,eAAE;IAAK,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAE;MAAEC,SAAS,EAAE;IAAO,CAAE;IAAA,UAAC;EAAO,EAAM;EACpEC,OAAO,EAAE,iBAACC,KAAgB,EAAEC,GAAoB,EAAK;IACnD,IAAID,KAAK,CAACE,SAAS,CAACC,KAAK,KAAK,CAAC,IAAI,KAAK,CAACC,IAAI,CAACJ,KAAK,CAACK,IAAI,CAAC,EAAE;MACzDJ,GAAG,CAACK,gBAAgB,CAAC,KAAK,CAAC;IAC7B,CAAC,MAAM;MACL,IAAAC,uCAAiB,EAAC,KAAK,EAAEP,KAAK,CAACE,SAAS,CAACC,KAAK,EAAEF,GAAG,CAACO,QAAQ,CAAC;IAC/D;EACF;AACF,CAAC;AAAC"
32
32
  }
@@ -28,5 +28,5 @@
28
28
  "sourcesContent": [
29
29
  "import * as React from 'react';\nimport { insertAtLineStart } from '../utils/InsertTextAtPosition';\nimport { ICommand, TextState, TextAreaTextApi } from './';\n\nexport const title3: ICommand = {\n name: 'title3',\n keyCommand: 'title3',\n shortcuts: 'ctrlcmd+3',\n value: 'title3',\n buttonProps: { 'aria-label': 'Insert title3 (ctrl + 3)', title: 'Insert title3 (ctrl + 3)' },\n icon: <div style={{ fontSize: 15, textAlign: 'left' }}>Title 3</div>,\n execute: (state: TextState, api: TextAreaTextApi) => {\n if (state.selection.start === 0 || /\\n$/.test(state.text)) {\n api.replaceSelection('### ');\n } else {\n insertAtLineStart('### ', state.selection.start, api.textArea);\n }\n },\n};\n"
30
30
  ],
31
- "mappings": ";;;;;;;AAAA;AACA;AAA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MACzDJ,GAAG,CAACK,gBAAgB,CAAC,MAAM,CAAC;IAC9B,CAAC,MAAM;MACL,IAAAC,uCAAiB,EAAC,MAAM,EAAEP,KAAK,CAACE,SAAS,CAACC,KAAK,EAAEF,GAAG,CAACO,QAAQ,CAAC;IAChE;EACF;AACF,CAAC;AAAC"
32
32
  }
@@ -28,5 +28,5 @@
28
28
  "sourcesContent": [
29
29
  "import * as React from 'react';\nimport { insertAtLineStart } from '../utils/InsertTextAtPosition';\nimport { ICommand, TextState, TextAreaTextApi } from './';\n\nexport const title4: ICommand = {\n name: 'title4',\n keyCommand: 'title4',\n shortcuts: 'ctrlcmd+4',\n value: 'title4',\n buttonProps: { 'aria-label': 'Insert title4 (ctrl + 4)', title: 'Insert title4 (ctrl + 4)' },\n icon: <div style={{ fontSize: 14, textAlign: 'left' }}>Title 4</div>,\n execute: (state: TextState, api: TextAreaTextApi) => {\n if (state.selection.start === 0 || /\\n$/.test(state.text)) {\n api.replaceSelection('#### ');\n } else {\n insertAtLineStart('#### ', state.selection.start, api.textArea);\n }\n },\n};\n"
30
30
  ],
31
- "mappings": ";;;;;;;AAAA;AACA;AAAkE;AAG3D,IAAMA,MAAgB,GAAG;EAC9BC,IAAI,EAAE,QAAQ;EACdC,UAAU,EAAE,QAAQ;EACpBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE,QAAQ;EACfC,WAAW,EAAE;IAAE,YAAY,EAAE,0BAA0B;IAAEC,KAAK,EAAE;EAA2B,CAAC;EAC5FC,IAAI,eAAE;IAAK,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAE;MAAEC,SAAS,EAAE;IAAO,CAAE;IAAA;EAAA,EAAc;EACpEC,OAAO,EAAE,iBAACC,KAAgB,EAAEC,GAAoB,EAAK;IACnD,IAAID,KAAK,CAACE,SAAS,CAACC,KAAK,KAAK,CAAC,IAAI,KAAK,CAACC,IAAI,CAACJ,KAAK,CAACK,IAAI,CAAC,EAAE;MACzDJ,GAAG,CAACK,gBAAgB,CAAC,OAAO,CAAC;IAC/B,CAAC,MAAM;MACL,IAAAC,uCAAiB,EAAC,OAAO,EAAEP,KAAK,CAACE,SAAS,CAACC,KAAK,EAAEF,GAAG,CAACO,QAAQ,CAAC;IACjE;EACF;AACF,CAAC;AAAC"
31
+ "mappings": ";;;;;;;AAAA;AACA;AAAkE;AAG3D,IAAMA,MAAgB,GAAG;EAC9BC,IAAI,EAAE,QAAQ;EACdC,UAAU,EAAE,QAAQ;EACpBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE,QAAQ;EACfC,WAAW,EAAE;IAAE,YAAY,EAAE,0BAA0B;IAAEC,KAAK,EAAE;EAA2B,CAAC;EAC5FC,IAAI,eAAE;IAAK,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAE;MAAEC,SAAS,EAAE;IAAO,CAAE;IAAA,UAAC;EAAO,EAAM;EACpEC,OAAO,EAAE,iBAACC,KAAgB,EAAEC,GAAoB,EAAK;IACnD,IAAID,KAAK,CAACE,SAAS,CAACC,KAAK,KAAK,CAAC,IAAI,KAAK,CAACC,IAAI,CAACJ,KAAK,CAACK,IAAI,CAAC,EAAE;MACzDJ,GAAG,CAACK,gBAAgB,CAAC,OAAO,CAAC;IAC/B,CAAC,MAAM;MACL,IAAAC,uCAAiB,EAAC,OAAO,EAAEP,KAAK,CAACE,SAAS,CAACC,KAAK,EAAEF,GAAG,CAACO,QAAQ,CAAC;IACjE;EACF;AACF,CAAC;AAAC"
32
32
  }
@@ -28,5 +28,5 @@
28
28
  "sourcesContent": [
29
29
  "import * as React from 'react';\nimport { insertAtLineStart } from '../utils/InsertTextAtPosition';\nimport { ICommand, TextState, TextAreaTextApi } from './';\n\nexport const title5: ICommand = {\n name: 'title5',\n keyCommand: 'title5',\n shortcuts: 'ctrlcmd+5',\n value: 'title5',\n buttonProps: { 'aria-label': 'Insert title5 (ctrl + 5)', title: 'Insert title5 (ctrl + 5)' },\n icon: <div style={{ fontSize: 12, textAlign: 'left' }}>Title 5</div>,\n execute: (state: TextState, api: TextAreaTextApi) => {\n if (state.selection.start === 0 || /\\n$/.test(state.text)) {\n api.replaceSelection('##### ');\n } else {\n insertAtLineStart('##### ', state.selection.start, api.textArea);\n }\n },\n};\n"
30
30
  ],
31
- "mappings": ";;;;;;;AAAA;AACA;AAAkE;AAG3D,IAAMA,MAAgB,GAAG;EAC9BC,IAAI,EAAE,QAAQ;EACdC,UAAU,EAAE,QAAQ;EACpBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE,QAAQ;EACfC,WAAW,EAAE;IAAE,YAAY,EAAE,0BAA0B;IAAEC,KAAK,EAAE;EAA2B,CAAC;EAC5FC,IAAI,eAAE;IAAK,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAE;MAAEC,SAAS,EAAE;IAAO,CAAE;IAAA;EAAA,EAAc;EACpEC,OAAO,EAAE,iBAACC,KAAgB,EAAEC,GAAoB,EAAK;IACnD,IAAID,KAAK,CAACE,SAAS,CAACC,KAAK,KAAK,CAAC,IAAI,KAAK,CAACC,IAAI,CAACJ,KAAK,CAACK,IAAI,CAAC,EAAE;MACzDJ,GAAG,CAACK,gBAAgB,CAAC,QAAQ,CAAC;IAChC,CAAC,MAAM;MACL,IAAAC,uCAAiB,EAAC,QAAQ,EAAEP,KAAK,CAACE,SAAS,CAACC,KAAK,EAAEF,GAAG,CAACO,QAAQ,CAAC;IAClE;EACF;AACF,CAAC;AAAC"
31
+ "mappings": ";;;;;;;AAAA;AACA;AAAkE;AAG3D,IAAMA,MAAgB,GAAG;EAC9BC,IAAI,EAAE,QAAQ;EACdC,UAAU,EAAE,QAAQ;EACpBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE,QAAQ;EACfC,WAAW,EAAE;IAAE,YAAY,EAAE,0BAA0B;IAAEC,KAAK,EAAE;EAA2B,CAAC;EAC5FC,IAAI,eAAE;IAAK,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAE;MAAEC,SAAS,EAAE;IAAO,CAAE;IAAA,UAAC;EAAO,EAAM;EACpEC,OAAO,EAAE,iBAACC,KAAgB,EAAEC,GAAoB,EAAK;IACnD,IAAID,KAAK,CAACE,SAAS,CAACC,KAAK,KAAK,CAAC,IAAI,KAAK,CAACC,IAAI,CAACJ,KAAK,CAACK,IAAI,CAAC,EAAE;MACzDJ,GAAG,CAACK,gBAAgB,CAAC,QAAQ,CAAC;IAChC,CAAC,MAAM;MACL,IAAAC,uCAAiB,EAAC,QAAQ,EAAEP,KAAK,CAACE,SAAS,CAACC,KAAK,EAAEF,GAAG,CAACO,QAAQ,CAAC;IAClE;EACF;AACF,CAAC;AAAC"
32
32
  }
@@ -28,5 +28,5 @@
28
28
  "sourcesContent": [
29
29
  "import * as React from 'react';\nimport { insertAtLineStart } from '../utils/InsertTextAtPosition';\nimport { ICommand, TextState, TextAreaTextApi } from './';\n\nexport const title6: ICommand = {\n name: 'title6',\n keyCommand: 'title6',\n shortcuts: 'ctrlcmd+6',\n value: 'title6',\n buttonProps: { 'aria-label': 'Insert title6 (ctrl + 6)', title: 'Insert title6 (ctrl + 6)' },\n icon: <div style={{ fontSize: 12, textAlign: 'left' }}>Title 6</div>,\n execute: (state: TextState, api: TextAreaTextApi) => {\n if (state.selection.start === 0 || /\\n$/.test(state.text)) {\n api.replaceSelection('###### ');\n } else {\n insertAtLineStart('###### ', state.selection.start, api.textArea);\n }\n },\n};\n"
30
30
  ],
31
- "mappings": ";;;;;;;AAAA;AACA;AAAkE;AAG3D,IAAMA,MAAgB,GAAG;EAC9BC,IAAI,EAAE,QAAQ;EACdC,UAAU,EAAE,QAAQ;EACpBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE,QAAQ;EACfC,WAAW,EAAE;IAAE,YAAY,EAAE,0BAA0B;IAAEC,KAAK,EAAE;EAA2B,CAAC;EAC5FC,IAAI,eAAE;IAAK,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAE;MAAEC,SAAS,EAAE;IAAO,CAAE;IAAA;EAAA,EAAc;EACpEC,OAAO,EAAE,iBAACC,KAAgB,EAAEC,GAAoB,EAAK;IACnD,IAAID,KAAK,CAACE,SAAS,CAACC,KAAK,KAAK,CAAC,IAAI,KAAK,CAACC,IAAI,CAACJ,KAAK,CAACK,IAAI,CAAC,EAAE;MACzDJ,GAAG,CAACK,gBAAgB,CAAC,SAAS,CAAC;IACjC,CAAC,MAAM;MACL,IAAAC,uCAAiB,EAAC,SAAS,EAAEP,KAAK,CAACE,SAAS,CAACC,KAAK,EAAEF,GAAG,CAACO,QAAQ,CAAC;IACnE;EACF;AACF,CAAC;AAAC"
31
+ "mappings": ";;;;;;;AAAA;AACA;AAAkE;AAG3D,IAAMA,MAAgB,GAAG;EAC9BC,IAAI,EAAE,QAAQ;EACdC,UAAU,EAAE,QAAQ;EACpBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE,QAAQ;EACfC,WAAW,EAAE;IAAE,YAAY,EAAE,0BAA0B;IAAEC,KAAK,EAAE;EAA2B,CAAC;EAC5FC,IAAI,eAAE;IAAK,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAE;MAAEC,SAAS,EAAE;IAAO,CAAE;IAAA,UAAC;EAAO,EAAM;EACpEC,OAAO,EAAE,iBAACC,KAAgB,EAAEC,GAAoB,EAAK;IACnD,IAAID,KAAK,CAACE,SAAS,CAACC,KAAK,KAAK,CAAC,IAAI,KAAK,CAACC,IAAI,CAACJ,KAAK,CAACK,IAAI,CAAC,EAAE;MACzDJ,GAAG,CAACK,gBAAgB,CAAC,SAAS,CAAC;IACjC,CAAC,MAAM;MACL,IAAAC,uCAAiB,EAAC,SAAS,EAAEP,KAAK,CAACE,SAAS,CAACC,KAAK,EAAEF,GAAG,CAACO,QAAQ,CAAC;IACnE;EACF;AACF,CAAC;AAAC"
32
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uiw/react-md-editor",
3
- "version": "3.20.1",
3
+ "version": "3.20.2",
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>",
package/src/Editor.tsx CHANGED
@@ -35,7 +35,7 @@ export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>
35
35
  * The height of the editor.
36
36
  * ⚠️ `Dragbar` is invalid when **`height`** parameter percentage.
37
37
  */
38
- height?: CSSProperties['height'];
38
+ height?: number;
39
39
  /**
40
40
  * Custom toolbar heigth
41
41
  * @default 29px