@uiw/react-md-editor 3.12.3 → 3.13.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.
- package/dist/mdeditor.css +5 -0
- package/dist/mdeditor.js +846 -1376
- package/dist/mdeditor.min.css +1 -1
- package/dist/mdeditor.min.js +1 -1
- package/dist/mdeditor.min.js.LICENSE.txt +0 -9
- package/esm/Editor.d.ts +2 -0
- package/esm/Editor.js +10 -3
- package/esm/Editor.js.map +3 -2
- package/esm/components/Toolbar/index.css +5 -0
- package/esm/components/Toolbar/index.d.ts +1 -0
- package/esm/components/Toolbar/index.js +3 -1
- package/esm/components/Toolbar/index.js.map +5 -3
- package/esm/components/Toolbar/index.less +5 -0
- package/lib/Context.js.map +1 -1
- package/lib/Editor.d.ts +2 -0
- package/lib/Editor.js +11 -3
- package/lib/Editor.js.map +10 -2
- package/lib/commands/bold.js.map +2 -1
- package/lib/commands/code.js.map +4 -1
- package/lib/commands/comment.js.map +2 -1
- package/lib/commands/image.js.map +2 -1
- package/lib/commands/index.js.map +2 -1
- package/lib/commands/italic.js.map +2 -1
- package/lib/commands/link.js.map +2 -1
- package/lib/commands/list.js.map +4 -1
- package/lib/commands/quote.js.map +4 -1
- package/lib/commands/strikeThrough.js.map +2 -1
- package/lib/commands/title1.js.map +2 -1
- package/lib/commands/title2.js.map +2 -1
- package/lib/commands/title3.js.map +2 -1
- package/lib/commands/title4.js.map +2 -1
- package/lib/commands/title5.js.map +2 -1
- package/lib/commands/title6.js.map +2 -1
- package/lib/components/DragBar/index.js.map +5 -2
- package/lib/components/TextArea/Markdown.js.map +5 -1
- package/lib/components/TextArea/Textarea.js.map +5 -1
- package/lib/components/TextArea/handleKeyDown.js.map +3 -1
- package/lib/components/TextArea/index.js.map +3 -2
- package/lib/components/Toolbar/Child.js.map +3 -1
- package/lib/components/Toolbar/index.d.ts +1 -0
- package/lib/components/Toolbar/index.js +3 -1
- package/lib/components/Toolbar/index.js.map +8 -3
- package/lib/components/Toolbar/index.less +5 -0
- package/markdown-editor.css +5 -0
- package/package.json +1 -1
- package/src/Editor.tsx +9 -1
- package/src/components/Toolbar/index.less +5 -0
- package/src/components/Toolbar/index.tsx +4 -2
|
@@ -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;
|
|
@@ -139,14 +139,16 @@ function Toolbar() {
|
|
|
139
139
|
var prefixCls = props.prefixCls,
|
|
140
140
|
_props$height = props.height,
|
|
141
141
|
height = _props$height === void 0 ? 29 : _props$height,
|
|
142
|
+
toolbarBottom = props.toolbarBottom,
|
|
142
143
|
isChild = props.isChild;
|
|
143
144
|
|
|
144
145
|
var _useContext2 = (0, _react.useContext)(_Context.EditorContext),
|
|
145
146
|
commands = _useContext2.commands,
|
|
146
147
|
extraCommands = _useContext2.extraCommands;
|
|
147
148
|
|
|
149
|
+
var bottomClassName = toolbarBottom ? 'bottom' : '';
|
|
148
150
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
149
|
-
className: "".concat(prefixCls, "-toolbar"),
|
|
151
|
+
className: "".concat(prefixCls, "-toolbar ").concat(bottomClassName),
|
|
150
152
|
style: {
|
|
151
153
|
height: height
|
|
152
154
|
},
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"props",
|
|
6
6
|
"prefixCls",
|
|
7
7
|
"overflow",
|
|
8
|
+
"useContext",
|
|
8
9
|
"EditorContext",
|
|
9
10
|
"fullscreen",
|
|
10
11
|
"preview",
|
|
@@ -12,6 +13,7 @@
|
|
|
12
13
|
"commandOrchestrator",
|
|
13
14
|
"dispatch",
|
|
14
15
|
"originalOverflow",
|
|
16
|
+
"useRef",
|
|
15
17
|
"handleClick",
|
|
16
18
|
"command",
|
|
17
19
|
"name",
|
|
@@ -28,6 +30,7 @@
|
|
|
28
30
|
"keyName",
|
|
29
31
|
"length",
|
|
30
32
|
"executeCommand",
|
|
33
|
+
"useEffect",
|
|
31
34
|
"document",
|
|
32
35
|
"body",
|
|
33
36
|
"style",
|
|
@@ -60,14 +63,16 @@
|
|
|
60
63
|
"isArray",
|
|
61
64
|
"Toolbar",
|
|
62
65
|
"height",
|
|
66
|
+
"toolbarBottom",
|
|
63
67
|
"isChild",
|
|
64
|
-
"extraCommands"
|
|
68
|
+
"extraCommands",
|
|
69
|
+
"bottomClassName"
|
|
65
70
|
],
|
|
66
71
|
"sources": [
|
|
67
72
|
"../../../src/components/Toolbar/index.tsx"
|
|
68
73
|
],
|
|
69
74
|
"sourcesContent": [
|
|
70
|
-
"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"
|
|
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 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"
|
|
71
76
|
],
|
|
72
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;;AAEA;;AAEA;;;;
|
|
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B;MAAyB,QAAQ,EAAEA,KAAK,CAACkB,QAAN,IAAkBA,QAAlB,IAA8B;IAAjE,GADF,EAEG,CAAC4C,OAAD,iBAAY,qBAAC,YAAD,8DAAkB9D,KAAlB;MAAyB,QAAQ,EAAE+D,aAAa,IAAI;IAApD,GAFf;EAAA,EADF;AAMD"
|
|
73
78
|
}
|
package/markdown-editor.css
CHANGED
|
@@ -182,6 +182,11 @@
|
|
|
182
182
|
-webkit-user-select: none;
|
|
183
183
|
user-select: none;
|
|
184
184
|
}
|
|
185
|
+
.w-md-editor-toolbar.bottom {
|
|
186
|
+
border-bottom: 0px;
|
|
187
|
+
border-top: 1px solid var(--color-border-default);
|
|
188
|
+
border-radius: 0 0 3px 3px;
|
|
189
|
+
}
|
|
185
190
|
.w-md-editor-toolbar ul,
|
|
186
191
|
.w-md-editor-toolbar li {
|
|
187
192
|
margin: 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uiw/react-md-editor",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.13.0",
|
|
4
4
|
"description": "A markdown editor with preview, implemented with React.js and TypeScript.",
|
|
5
5
|
"homepage": "https://uiwjs.github.io/react-md-editor/",
|
|
6
6
|
"author": "kenny wang <wowohoo@qq.com>",
|
package/src/Editor.tsx
CHANGED
|
@@ -107,6 +107,8 @@ export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>
|
|
|
107
107
|
hideToolbar?: boolean;
|
|
108
108
|
/** Whether to enable scrolling */
|
|
109
109
|
enableScroll?: boolean;
|
|
110
|
+
/** Toolbar on bottom */
|
|
111
|
+
toolbarBottom?: boolean;
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
function setGroupPopFalse(data: Record<string, boolean> = {}) {
|
|
@@ -145,6 +147,7 @@ const InternalMDEditor = (
|
|
|
145
147
|
onChange,
|
|
146
148
|
onHeightChange,
|
|
147
149
|
hideToolbar,
|
|
150
|
+
toolbarBottom = false,
|
|
148
151
|
renderTextarea,
|
|
149
152
|
...other
|
|
150
153
|
} = props || {};
|
|
@@ -295,7 +298,9 @@ const InternalMDEditor = (
|
|
|
295
298
|
height: state.fullscreen ? '100%' : hideToolbar ? Number(state.height) - toolbarHeight : state.height,
|
|
296
299
|
}}
|
|
297
300
|
>
|
|
298
|
-
{!hideToolbar &&
|
|
301
|
+
{!hideToolbar && !toolbarBottom && (
|
|
302
|
+
<Toolbar prefixCls={prefixCls} height={toolbarHeight} overflow={overflow} toolbarBottom={toolbarBottom} />
|
|
303
|
+
)}
|
|
299
304
|
<div
|
|
300
305
|
className={`${prefixCls}-content`}
|
|
301
306
|
style={{
|
|
@@ -331,6 +336,9 @@ const InternalMDEditor = (
|
|
|
331
336
|
}}
|
|
332
337
|
/>
|
|
333
338
|
)}
|
|
339
|
+
{!hideToolbar && toolbarBottom && (
|
|
340
|
+
<Toolbar prefixCls={prefixCls} height={toolbarHeight} overflow={overflow} toolbarBottom={toolbarBottom} />
|
|
341
|
+
)}
|
|
334
342
|
</div>
|
|
335
343
|
</EditorContext.Provider>
|
|
336
344
|
);
|
|
@@ -8,6 +8,7 @@ import './index.less';
|
|
|
8
8
|
export interface IToolbarProps extends IProps {
|
|
9
9
|
overflow?: boolean;
|
|
10
10
|
height?: React.CSSProperties['height'];
|
|
11
|
+
toolbarBottom?: boolean;
|
|
11
12
|
onCommand?: (command: ICommand<string>, groupName?: string) => void;
|
|
12
13
|
commands?: ICommand<string>[];
|
|
13
14
|
isChild?: boolean;
|
|
@@ -118,10 +119,11 @@ export function ToolbarItems(props: IToolbarProps) {
|
|
|
118
119
|
}
|
|
119
120
|
|
|
120
121
|
export default function Toolbar(props: IToolbarProps = {}) {
|
|
121
|
-
const { prefixCls, height = 29, isChild } = props;
|
|
122
|
+
const { prefixCls, height = 29, toolbarBottom, isChild } = props;
|
|
122
123
|
const { commands, extraCommands } = useContext(EditorContext);
|
|
124
|
+
const bottomClassName = toolbarBottom ? 'bottom' : '';
|
|
123
125
|
return (
|
|
124
|
-
<div className={`${prefixCls}-toolbar`} style={{ height }}>
|
|
126
|
+
<div className={`${prefixCls}-toolbar ${bottomClassName}`} style={{ height }}>
|
|
125
127
|
<ToolbarItems {...props} commands={props.commands || commands || []} />
|
|
126
128
|
{!isChild && <ToolbarItems {...props} commands={extraCommands || []} />}
|
|
127
129
|
</div>
|