@uiw/react-md-editor 3.12.2 → 3.14.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 (58) hide show
  1. package/README.md +9 -7
  2. package/dist/mdeditor.css +16 -11
  3. package/dist/mdeditor.js +1320 -1718
  4. package/dist/mdeditor.min.css +1 -1
  5. package/dist/mdeditor.min.js +1 -1
  6. package/dist/mdeditor.min.js.LICENSE.txt +1 -15
  7. package/esm/Editor.d.ts +5 -3
  8. package/esm/Editor.js +12 -5
  9. package/esm/Editor.js.map +4 -3
  10. package/esm/components/TextArea/index.css +8 -1
  11. package/esm/components/TextArea/index.less +8 -1
  12. package/esm/components/Toolbar/index.css +5 -0
  13. package/esm/components/Toolbar/index.d.ts +1 -0
  14. package/esm/components/Toolbar/index.js +3 -1
  15. package/esm/components/Toolbar/index.js.map +5 -3
  16. package/esm/components/Toolbar/index.less +5 -0
  17. package/esm/index.css +3 -0
  18. package/esm/index.less +3 -0
  19. package/lib/Context.js.map +1 -1
  20. package/lib/Editor.d.ts +5 -3
  21. package/lib/Editor.js +14 -6
  22. package/lib/Editor.js.map +11 -3
  23. package/lib/commands/bold.js.map +2 -1
  24. package/lib/commands/code.js.map +4 -1
  25. package/lib/commands/comment.js.map +2 -1
  26. package/lib/commands/image.js.map +2 -1
  27. package/lib/commands/index.js.map +2 -1
  28. package/lib/commands/italic.js.map +2 -1
  29. package/lib/commands/link.js.map +2 -1
  30. package/lib/commands/list.js.map +4 -1
  31. package/lib/commands/quote.js.map +4 -1
  32. package/lib/commands/strikeThrough.js.map +2 -1
  33. package/lib/commands/title1.js.map +2 -1
  34. package/lib/commands/title2.js.map +2 -1
  35. package/lib/commands/title3.js.map +2 -1
  36. package/lib/commands/title4.js.map +2 -1
  37. package/lib/commands/title5.js.map +2 -1
  38. package/lib/commands/title6.js.map +2 -1
  39. package/lib/components/DragBar/index.js.map +5 -2
  40. package/lib/components/TextArea/Markdown.js.map +5 -1
  41. package/lib/components/TextArea/Textarea.js.map +5 -1
  42. package/lib/components/TextArea/handleKeyDown.js.map +3 -1
  43. package/lib/components/TextArea/index.js.map +3 -2
  44. package/lib/components/TextArea/index.less +8 -1
  45. package/lib/components/Toolbar/Child.js.map +3 -1
  46. package/lib/components/Toolbar/index.d.ts +1 -0
  47. package/lib/components/Toolbar/index.js +3 -1
  48. package/lib/components/Toolbar/index.js.map +8 -3
  49. package/lib/components/Toolbar/index.less +5 -0
  50. package/lib/index.less +3 -0
  51. package/markdown-editor.css +16 -1
  52. package/package.json +12 -12
  53. package/src/Editor.tsx +14 -6
  54. package/src/__test__/editor.test.tsx +1 -1
  55. package/src/components/TextArea/index.less +8 -1
  56. package/src/components/Toolbar/index.less +5 -0
  57. package/src/components/Toolbar/index.tsx +4 -2
  58. package/src/index.less +3 -0
@@ -1,9 +1,3 @@
1
- /*
2
- object-assign
3
- (c) Sindre Sorhus
4
- @license MIT
5
- */
6
-
7
1
  /*!
8
2
  * @uiw/copy-to-clipboard v1.0.12
9
3
  * Copy to clipboard.
@@ -32,15 +26,7 @@ object-assign
32
26
  */
33
27
 
34
28
  /**
35
- * Prism: Lightweight, robust, elegant syntax highlighting
36
- *
37
- * @license MIT <https://opensource.org/licenses/MIT>
38
- * @author Lea Verou <https://lea.verou.me>
39
- * @namespace
40
- * @public
41
- */
42
-
43
- /** @license React v17.0.2
29
+ * @license React
44
30
  * react-jsx-runtime.production.min.js
45
31
  *
46
32
  * Copyright (c) Facebook, Inc. and its affiliates.
package/esm/Editor.d.ts CHANGED
@@ -39,7 +39,7 @@ export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>
39
39
  /**
40
40
  * Show drag and drop tool. Set the height of the editor.
41
41
  */
42
- visiableDragbar?: boolean;
42
+ visibleDragbar?: boolean;
43
43
  /**
44
44
  * Show markdown preview.
45
45
  */
@@ -53,11 +53,11 @@ export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>
53
53
  */
54
54
  overflow?: boolean;
55
55
  /**
56
- * Maximum drag height. `visiableDragbar=true`
56
+ * Maximum drag height. `visibleDragbar=true`
57
57
  */
58
58
  maxHeight?: number;
59
59
  /**
60
- * Minimum drag height. `visiableDragbar=true`
60
+ * Minimum drag height. `visibleDragbar=true`
61
61
  */
62
62
  minHeight?: number;
63
63
  /**
@@ -103,6 +103,8 @@ export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>
103
103
  hideToolbar?: boolean;
104
104
  /** Whether to enable scrolling */
105
105
  enableScroll?: boolean;
106
+ /** Toolbar on bottom */
107
+ toolbarBottom?: boolean;
106
108
  }
107
109
  declare const mdEditor: React.ForwardRefExoticComponent<MDEditorProps & React.RefAttributes<ContextStore>>;
108
110
  declare type MDEditor = typeof mdEditor & {
package/esm/Editor.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
- var _excluded = ["prefixCls", "className", "value", "commands", "commandsFilter", "extraCommands", "height", "toolbarHeight", "enableScroll", "visiableDragbar", "highlightEnable", "preview", "fullscreen", "overflow", "previewOptions", "textareaProps", "maxHeight", "minHeight", "autoFocus", "tabSize", "defaultTabEnable", "onChange", "onHeightChange", "hideToolbar", "renderTextarea"];
3
+ var _excluded = ["prefixCls", "className", "value", "commands", "commandsFilter", "extraCommands", "height", "toolbarHeight", "enableScroll", "visibleDragbar", "highlightEnable", "preview", "fullscreen", "overflow", "previewOptions", "textareaProps", "maxHeight", "minHeight", "autoFocus", "tabSize", "defaultTabEnable", "onChange", "onHeightChange", "hideToolbar", "toolbarBottom", "renderTextarea"];
4
4
  import React, { useEffect, useReducer, useMemo, useRef, useImperativeHandle } from 'react';
5
5
  import MarkdownPreview from '@uiw/react-markdown-preview';
6
6
  import TextArea from './components/TextArea';
@@ -35,7 +35,7 @@ var InternalMDEditor = (props, ref) => {
35
35
  height = 200,
36
36
  toolbarHeight = 29,
37
37
  enableScroll = true,
38
- visiableDragbar = true,
38
+ visibleDragbar = true,
39
39
  highlightEnable = true,
40
40
  preview: previewType = 'live',
41
41
  fullscreen = false,
@@ -50,6 +50,7 @@ var InternalMDEditor = (props, ref) => {
50
50
  onChange: _onChange,
51
51
  onHeightChange,
52
52
  hideToolbar,
53
+ toolbarBottom = false,
53
54
  renderTextarea
54
55
  } = _ref,
55
56
  other = _objectWithoutPropertiesLoose(_ref, _excluded);
@@ -192,10 +193,11 @@ var InternalMDEditor = (props, ref) => {
192
193
  style: _extends({}, other.style, {
193
194
  height: state.fullscreen ? '100%' : hideToolbar ? Number(state.height) - toolbarHeight : state.height
194
195
  }),
195
- children: [!hideToolbar && /*#__PURE__*/_jsx(Toolbar, {
196
+ children: [!hideToolbar && !toolbarBottom && /*#__PURE__*/_jsx(Toolbar, {
196
197
  prefixCls: prefixCls,
197
198
  height: toolbarHeight,
198
- overflow: overflow
199
+ overflow: overflow,
200
+ toolbarBottom: toolbarBottom
199
201
  }), /*#__PURE__*/_jsxs("div", {
200
202
  className: prefixCls + "-content",
201
203
  style: {
@@ -216,7 +218,7 @@ var InternalMDEditor = (props, ref) => {
216
218
  renderTextarea: renderTextarea,
217
219
  onScroll: e => handleScroll(e, 'text')
218
220
  })), /(live|preview)/.test(state.preview || '') && mdPreview]
219
- }), visiableDragbar && !state.fullscreen && /*#__PURE__*/_jsx(DragBar, {
221
+ }), visibleDragbar && !state.fullscreen && /*#__PURE__*/_jsx(DragBar, {
220
222
  prefixCls: prefixCls,
221
223
  height: state.height,
222
224
  maxHeight: maxHeight,
@@ -226,6 +228,11 @@ var InternalMDEditor = (props, ref) => {
226
228
  height: newHeight
227
229
  });
228
230
  }
231
+ }), !hideToolbar && toolbarBottom && /*#__PURE__*/_jsx(Toolbar, {
232
+ prefixCls: prefixCls,
233
+ height: toolbarHeight,
234
+ overflow: overflow,
235
+ toolbarBottom: toolbarBottom
229
236
  })]
230
237
  }))
231
238
  });
package/esm/Editor.js.map CHANGED
@@ -34,7 +34,7 @@
34
34
  "height",
35
35
  "toolbarHeight",
36
36
  "enableScroll",
37
- "visiableDragbar",
37
+ "visibleDragbar",
38
38
  "highlightEnable",
39
39
  "preview",
40
40
  "previewType",
@@ -50,6 +50,7 @@
50
50
  "onChange",
51
51
  "onHeightChange",
52
52
  "hideToolbar",
53
+ "toolbarBottom",
53
54
  "renderTextarea",
54
55
  "other",
55
56
  "cmds",
@@ -102,7 +103,7 @@
102
103
  "../src/Editor.tsx"
103
104
  ],
104
105
  "sourcesContent": [
105
- "import React, { useEffect, useReducer, useMemo, useRef, useImperativeHandle } 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?: number, oldValue?: number, 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 */\n height?: number;\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 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. `visiableDragbar=true`\n */\n maxHeight?: number;\n /**\n * Minimum drag height. `visiableDragbar=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 /** Use div to replace TextArea or re-render TextArea */\n renderTextarea?: ITextAreaProps['renderTextarea'];\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}\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 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 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 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\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.fullscreen ? '100%' : hideToolbar ? Number(state.height) - toolbarHeight : state.height,\n }}\n >\n {!hideToolbar && <Toolbar prefixCls={prefixCls} height={toolbarHeight} overflow={overflow} />}\n <div\n className={`${prefixCls}-content`}\n style={{\n height: state.fullscreen ? `calc(100% - ${toolbarHeight}px)` : Number(state.height) - toolbarHeight,\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={renderTextarea}\n onScroll={(e) => handleScroll(e, 'text')}\n />\n )}\n {/(live|preview)/.test(state.preview || '') && mdPreview}\n </div>\n {visiableDragbar && !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 </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"
106
+ "import React, { useEffect, useReducer, useMemo, useRef, useImperativeHandle } 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?: number, oldValue?: number, 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 */\n height?: number;\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 * 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 /** Use div to replace TextArea or re-render TextArea */\n renderTextarea?: ITextAreaProps['renderTextarea'];\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 = 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 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 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\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.fullscreen ? '100%' : hideToolbar ? Number(state.height) - toolbarHeight : state.height,\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: state.fullscreen ? `calc(100% - ${toolbarHeight}px)` : Number(state.height) - toolbarHeight,\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={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"
106
107
  ],
107
- "mappings": ";;;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,UAA3B,EAAuCC,OAAvC,EAAgDC,MAAhD,EAAwDC,mBAAxD,QAAmF,OAAnF;AACA,OAAOC,eAAP,MAA0E,6BAA1E;AACA,OAAOC,QAAP,MAAyC,uBAAzC;AACA,OAAOC,OAAP,MAAoB,sBAApB;AACA,OAAOC,OAAP,MAAoB,sBAApB;AACA,SAASC,WAAT,EAAsBC,gBAAtB,QAAwD,YAAxD;AACA,SAASC,OAAT,EAAkBC,aAAlB,QAAkE,WAAlE;AACA;;;;AAwGA,SAASC,gBAAT,CAA0BC,IAA1B,EAA8D;EAAA,IAApCA,IAAoC;IAApCA,IAAoC,GAAJ,EAAI;EAAA;;EAC5DC,MAAM,CAACC,IAAP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,EAAwBlC,KAAxB,CAApB;;YACA,IAAIlB,aAAa,IAAIA,aAAa,CAACM,QAAnC,EAA6C;cAC3CN,aAAa,CAACM,QAAd,CAAuB8C,GAAvB;YACD;UACF,CAVH;UAWE,cAAc,EAAE1C,cAXlB;UAYE,QAAQ,EAAG6B,CAAD,IAAOD,YAAY,CAACC,CAAD,EAAI,MAAJ;QAZ/B,GAPJ,EAsBG,iBAAiBY,IAAjB,CAAsBjC,KAAK,CAACvB,OAAN,IAAiB,EAAvC,KAA8CqD,SAtBjD;MAAA,EAfF,EAuCGvD,cAAc,IAAI,CAACyB,KAAK,CAACrB,UAAzB,iBACC,KAAC,OAAD;QACE,SAAS,EAAEd,SADb;QAEE,MAAM,EAAEmC,KAAK,CAAC5B,MAFhB;QAGE,SAAS,EAAEW,SAHb;QAIE,SAAS,EAAEC,SAJb;QAKE,QAAQ,EAAGmD,SAAD,IAAe;UACvBlC,QAAQ,CAAC;YAAE7B,MAAM,EAAE+D;UAAV,CAAD,CAAR;QACD;MAPH,EAxCJ,EAkDG,CAAC7C,WAAD,IAAgBC,aAAhB,iBACC,KAAC,OAAD;QAAS,SAAS,EAAE1B,SAApB;QAA+B,MAAM,EAAEQ,aAAvC;QAAsD,QAAQ,EAAEO,QAAhE;QAA0E,aAAa,EAAEW;MAAzF,EAnDJ;IAAA;EADF,EADF;AA0DD,CAhOD;;AAkOA,IAAM6C,QAAQ,gBAAG9F,KAAK,CAAC+F,UAAN,CAA8C3E,gBAA9C,CAAjB;AAMC0E,QAAD,CAAuBE,QAAvB,GAAkC1F,eAAlC;AAEA,eAAewF,QAAf"
108
109
  }
@@ -50,8 +50,15 @@
50
50
  }
51
51
  .w-md-editor-text-pre {
52
52
  position: relative;
53
- margin: 0px;
53
+ margin: 0px !important;
54
54
  pointer-events: none;
55
+ background-color: transparent !important;
56
+ }
57
+ .w-md-editor-text-pre > code {
58
+ padding: 0 !important;
59
+ font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
60
+ font-size: 14px !important;
61
+ line-height: 18px !important;
55
62
  }
56
63
  .w-md-editor-text-input {
57
64
  position: absolute;
@@ -48,8 +48,15 @@
48
48
  }
49
49
  &-pre {
50
50
  position: relative;
51
- margin: 0px;
51
+ margin: 0px !important;
52
52
  pointer-events: none;
53
+ background-color: transparent !important;
54
+ > code {
55
+ padding: 0 !important;
56
+ font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
57
+ font-size: 14px !important;
58
+ line-height: 18px !important;
59
+ }
53
60
  }
54
61
  &-input {
55
62
  position: absolute;
@@ -9,6 +9,11 @@
9
9
  -webkit-user-select: none;
10
10
  user-select: none;
11
11
  }
12
+ .w-md-editor-toolbar.bottom {
13
+ border-bottom: 0px;
14
+ border-top: 1px solid var(--color-border-default);
15
+ border-radius: 0 0 3px 3px;
16
+ }
12
17
  .w-md-editor-toolbar ul,
13
18
  .w-md-editor-toolbar li {
14
19
  margin: 0;
@@ -5,6 +5,7 @@ import './index.less';
5
5
  export interface IToolbarProps extends IProps {
6
6
  overflow?: boolean;
7
7
  height?: React.CSSProperties['height'];
8
+ toolbarBottom?: boolean;
8
9
  onCommand?: (command: ICommand<string>, groupName?: string) => void;
9
10
  commands?: ICommand<string>[];
10
11
  isChild?: boolean;
@@ -120,14 +120,16 @@ export default function Toolbar(props) {
120
120
  var {
121
121
  prefixCls,
122
122
  height = 29,
123
+ toolbarBottom,
123
124
  isChild
124
125
  } = props;
125
126
  var {
126
127
  commands,
127
128
  extraCommands
128
129
  } = useContext(EditorContext);
130
+ var bottomClassName = toolbarBottom ? 'bottom' : '';
129
131
  return /*#__PURE__*/_jsxs("div", {
130
- className: prefixCls + "-toolbar",
132
+ className: prefixCls + "-toolbar " + bottomClassName,
131
133
  style: {
132
134
  height
133
135
  },
@@ -65,14 +65,16 @@
65
65
  "isArray",
66
66
  "Toolbar",
67
67
  "height",
68
+ "toolbarBottom",
68
69
  "isChild",
69
- "extraCommands"
70
+ "extraCommands",
71
+ "bottomClassName"
70
72
  ],
71
73
  "sources": [
72
74
  "../../../src/components/Toolbar/index.tsx"
73
75
  ],
74
76
  "sourcesContent": [
75
- "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 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 = {}, 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 return (\n <li key={idx} {...item.liProps} className={activeBtn ? `active` : ''}>\n {!item.buttonProps && item.icon}\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, isChild } = props;\n const { commands, extraCommands } = useContext(EditorContext);\n return (\n <div className={`${prefixCls}-toolbar`} style={{ height }}>\n <ToolbarItems {...props} commands={props.commands || commands || []} />\n {!isChild && <ToolbarItems {...props} commands={extraCommands || []} />}\n </div>\n );\n}\n"
77
+ "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 = {}, 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 return (\n <li key={idx} {...item.liProps} className={activeBtn ? `active` : ''}>\n {!item.buttonProps && item.icon}\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"
76
78
  ],
77
- "mappings": ";AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,UAA1B,EAAsCC,SAAtC,EAAiDC,MAAjD,QAA+D,OAA/D;AAEA,SAASC,aAAT,QAAyD,eAAzD;AAEA,OAAOC,KAAP,MAAkB,SAAlB;AACA;;;AAUA,OAAO,SAASC,YAAT,CAAsBC,KAAtB,EAA4C;EACjD,IAAM;IAAEC,SAAF;IAAaC;EAAb,IAA0BF,KAAhC;EACA,IAAM;IAAEG,UAAF;IAAcC,OAAd;IAAuBC,QAAQ,GAAG,EAAlC;IAAsCC,mBAAtC;IAA2DC;EAA3D,IAAwEb,UAAU,CAACG,aAAD,CAAxF;EACA,IAAMW,gBAAgB,GAAGZ,MAAM,CAAC,EAAD,CAA/B;;EAEA,SAASa,WAAT,CAAqBC,OAArB,EAAgDC,IAAhD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E,UAAU,CAACG,aAAD,CAA9C;EACA,IAAM8D,eAAe,GAAGH,aAAa,GAAG,QAAH,GAAc,EAAnD;EACA,oBACE;IAAK,SAAS,EAAKvD,SAAL,iBAA0B0D,eAAxC;IAA2D,KAAK,EAAE;MAAEJ;IAAF,CAAlE;IAAA,wBACE,KAAC,YAAD,eAAkBvD,KAAlB;MAAyB,QAAQ,EAAEA,KAAK,CAACe,QAAN,IAAkBA,QAAlB,IAA8B;IAAjE,GADF,EAEG,CAAC0C,OAAD,iBAAY,KAAC,YAAD,eAAkBzD,KAAlB;MAAyB,QAAQ,EAAE0D,aAAa,IAAI;IAApD,GAFf;EAAA,EADF;AAMD"
78
80
  }
@@ -10,6 +10,11 @@
10
10
  align-items: center;
11
11
  border-radius: 3px 3px 0 0;
12
12
  user-select: none;
13
+ &.bottom {
14
+ border-bottom: 0px;
15
+ border-top: 1px solid var(--color-border-default);
16
+ border-radius: 0 0 3px 3px;
17
+ }
13
18
  ul,
14
19
  li {
15
20
  margin: 0;
package/esm/index.css CHANGED
@@ -30,6 +30,9 @@
30
30
  top: 0;
31
31
  right: 0;
32
32
  bottom: 0;
33
+ border-radius: 0 0 5px 0;
34
+ display: flex;
35
+ flex-direction: column;
33
36
  }
34
37
  .w-md-editor-preview .anchor {
35
38
  display: none;
package/esm/index.less CHANGED
@@ -32,6 +32,9 @@
32
32
  top: 0;
33
33
  right: 0;
34
34
  bottom: 0;
35
+ border-radius: 0 0 5px 0;
36
+ display: flex;
37
+ flex-direction: column;
35
38
  .anchor {
36
39
  display: none;
37
40
  }
@@ -15,5 +15,5 @@
15
15
  "sourcesContent": [
16
16
  "import React from 'react';\nimport { ICommand, TextAreaCommandOrchestrator } from './commands';\n\nexport type PreviewType = 'live' | 'edit' | 'preview';\n\nexport type ContextStore = {\n commands?: ICommand<string>[];\n extraCommands?: ICommand<string>[];\n markdown?: string;\n preview?: PreviewType;\n height?: number;\n fullscreen?: boolean;\n highlightEnable?: boolean;\n autoFocus?: boolean;\n textarea?: HTMLTextAreaElement;\n commandOrchestrator?: TextAreaCommandOrchestrator;\n textareaWarp?: HTMLDivElement;\n textareaPre?: HTMLPreElement;\n container?: HTMLDivElement | null;\n dispatch?: React.Dispatch<ContextStore>;\n barPopup?: Record<string, boolean>;\n scrollTop?: number;\n scrollTopPreview?: number;\n tabSize?: number;\n defaultTabEnable?: boolean;\n};\n\nexport type ExecuteCommandState = Pick<ContextStore, 'fullscreen' | 'preview' | 'highlightEnable'>;\n\nexport function reducer(state: ContextStore, action: ContextStore) {\n return { ...state, ...action };\n}\n\nexport const EditorContext = React.createContext<ContextStore>({ markdown: '' });\n"
17
17
  ],
18
- "mappings": ";;;;;;;;;;;;AAAA;;AA6BO,SAASA,OAAT,CAAiBC,KAAjB,EAAsCC,MAAtC,EAA4D;EACjE,mEAAYD,KAAZ,GAAsBC,MAAtB;AACD;;AAEM,IAAMC,aAAa,gBAAGC,eAAMC,aAAN,CAAkC;EAAEC,QAAQ,EAAE;AAAZ,CAAlC,CAAtB"
18
+ "mappings": ";;;;;;;;;;;;AAAA;;AA6BO,SAASA,OAAT,CAAiBC,KAAjB,EAAsCC,MAAtC,EAA4D;EACjE,mEAAYD,KAAZ,GAAsBC,MAAtB;AACD;;AAEM,IAAMC,aAAa,gBAAGC,cAAA,CAAMC,aAAN,CAAkC;EAAEC,QAAQ,EAAE;AAAZ,CAAlC,CAAtB"
19
19
  }
package/lib/Editor.d.ts CHANGED
@@ -39,7 +39,7 @@ export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>
39
39
  /**
40
40
  * Show drag and drop tool. Set the height of the editor.
41
41
  */
42
- visiableDragbar?: boolean;
42
+ visibleDragbar?: boolean;
43
43
  /**
44
44
  * Show markdown preview.
45
45
  */
@@ -53,11 +53,11 @@ export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>
53
53
  */
54
54
  overflow?: boolean;
55
55
  /**
56
- * Maximum drag height. `visiableDragbar=true`
56
+ * Maximum drag height. `visibleDragbar=true`
57
57
  */
58
58
  maxHeight?: number;
59
59
  /**
60
- * Minimum drag height. `visiableDragbar=true`
60
+ * Minimum drag height. `visibleDragbar=true`
61
61
  */
62
62
  minHeight?: number;
63
63
  /**
@@ -103,6 +103,8 @@ export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>
103
103
  hideToolbar?: boolean;
104
104
  /** Whether to enable scrolling */
105
105
  enableScroll?: boolean;
106
+ /** Toolbar on bottom */
107
+ toolbarBottom?: boolean;
106
108
  }
107
109
  declare const mdEditor: React.ForwardRefExoticComponent<MDEditorProps & React.RefAttributes<ContextStore>>;
108
110
  declare type MDEditor = typeof mdEditor & {
package/lib/Editor.js CHANGED
@@ -31,7 +31,7 @@ var _Context = require("./Context");
31
31
 
32
32
  var _jsxRuntime = require("react/jsx-runtime");
33
33
 
34
- var _excluded = ["prefixCls", "className", "value", "commands", "commandsFilter", "extraCommands", "height", "toolbarHeight", "enableScroll", "visiableDragbar", "highlightEnable", "preview", "fullscreen", "overflow", "previewOptions", "textareaProps", "maxHeight", "minHeight", "autoFocus", "tabSize", "defaultTabEnable", "onChange", "onHeightChange", "hideToolbar", "renderTextarea"];
34
+ var _excluded = ["prefixCls", "className", "value", "commands", "commandsFilter", "extraCommands", "height", "toolbarHeight", "enableScroll", "visibleDragbar", "highlightEnable", "preview", "fullscreen", "overflow", "previewOptions", "textareaProps", "maxHeight", "minHeight", "autoFocus", "tabSize", "defaultTabEnable", "onChange", "onHeightChange", "hideToolbar", "toolbarBottom", "renderTextarea"];
35
35
 
36
36
  function setGroupPopFalse() {
37
37
  var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -58,8 +58,8 @@ var InternalMDEditor = function InternalMDEditor(props, ref) {
58
58
  toolbarHeight = _ref$toolbarHeight === void 0 ? 29 : _ref$toolbarHeight,
59
59
  _ref$enableScroll = _ref.enableScroll,
60
60
  enableScroll = _ref$enableScroll === void 0 ? true : _ref$enableScroll,
61
- _ref$visiableDragbar = _ref.visiableDragbar,
62
- visiableDragbar = _ref$visiableDragbar === void 0 ? true : _ref$visiableDragbar,
61
+ _ref$visibleDragbar = _ref.visibleDragbar,
62
+ visibleDragbar = _ref$visibleDragbar === void 0 ? true : _ref$visibleDragbar,
63
63
  _ref$highlightEnable = _ref.highlightEnable,
64
64
  highlightEnable = _ref$highlightEnable === void 0 ? true : _ref$highlightEnable,
65
65
  _ref$preview = _ref.preview,
@@ -83,6 +83,8 @@ var InternalMDEditor = function InternalMDEditor(props, ref) {
83
83
  _onChange = _ref.onChange,
84
84
  onHeightChange = _ref.onHeightChange,
85
85
  hideToolbar = _ref.hideToolbar,
86
+ _ref$toolbarBottom = _ref.toolbarBottom,
87
+ toolbarBottom = _ref$toolbarBottom === void 0 ? false : _ref$toolbarBottom,
86
88
  renderTextarea = _ref.renderTextarea,
87
89
  other = (0, _objectWithoutProperties2.default)(_ref, _excluded);
88
90
 
@@ -257,10 +259,11 @@ var InternalMDEditor = function InternalMDEditor(props, ref) {
257
259
  style: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, other.style), {}, {
258
260
  height: state.fullscreen ? '100%' : hideToolbar ? Number(state.height) - toolbarHeight : state.height
259
261
  }),
260
- children: [!hideToolbar && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Toolbar.default, {
262
+ children: [!hideToolbar && !toolbarBottom && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Toolbar.default, {
261
263
  prefixCls: prefixCls,
262
264
  height: toolbarHeight,
263
- overflow: overflow
265
+ overflow: overflow,
266
+ toolbarBottom: toolbarBottom
264
267
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
265
268
  className: "".concat(prefixCls, "-content"),
266
269
  style: {
@@ -283,7 +286,7 @@ var InternalMDEditor = function InternalMDEditor(props, ref) {
283
286
  return handleScroll(e, 'text');
284
287
  }
285
288
  })), /(live|preview)/.test(state.preview || '') && mdPreview]
286
- }), visiableDragbar && !state.fullscreen && /*#__PURE__*/(0, _jsxRuntime.jsx)(_DragBar.default, {
289
+ }), visibleDragbar && !state.fullscreen && /*#__PURE__*/(0, _jsxRuntime.jsx)(_DragBar.default, {
287
290
  prefixCls: prefixCls,
288
291
  height: state.height,
289
292
  maxHeight: maxHeight,
@@ -293,6 +296,11 @@ var InternalMDEditor = function InternalMDEditor(props, ref) {
293
296
  height: newHeight
294
297
  });
295
298
  }
299
+ }), !hideToolbar && toolbarBottom && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Toolbar.default, {
300
+ prefixCls: prefixCls,
301
+ height: toolbarHeight,
302
+ overflow: overflow,
303
+ toolbarBottom: toolbarBottom
296
304
  })]
297
305
  }))
298
306
  });