@uiw/react-md-editor 3.9.6 → 3.9.9
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/README.md +3 -2
- package/dist/mdeditor.css +8 -8
- package/dist/mdeditor.js +63235 -60976
- package/dist/mdeditor.min.js +1 -1
- package/esm/components/Toolbar/index.js +2 -1
- package/esm/components/Toolbar/index.js.map +3 -2
- package/lib/components/Toolbar/index.js +2 -1
- package/lib/components/Toolbar/index.js.map +3 -2
- package/package.json +29 -28
- package/src/components/Toolbar/index.tsx +2 -1
|
@@ -77,7 +77,7 @@ export function ToolbarItems(props) {
|
|
|
77
77
|
}), idx);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
if (!item.keyCommand) return /*#__PURE__*/_jsx(Fragment, {});
|
|
80
|
+
if (!item.keyCommand) return /*#__PURE__*/_jsx(Fragment, {}, idx);
|
|
81
81
|
var activeBtn = fullscreen && item.keyCommand === 'fullscreen' || item.keyCommand === 'preview' && preview === item.value;
|
|
82
82
|
var childNode = item.children && typeof item.children === 'function' ? item.children({
|
|
83
83
|
getState: () => commandOrchestrator.getState(),
|
|
@@ -92,6 +92,7 @@ export function ToolbarItems(props) {
|
|
|
92
92
|
className: activeBtn ? "active" : '',
|
|
93
93
|
children: [!item.buttonProps && item.icon, item.buttonProps && /*#__PURE__*/React.createElement('button', _extends({
|
|
94
94
|
type: 'button',
|
|
95
|
+
key: idx,
|
|
95
96
|
disabled,
|
|
96
97
|
'data-name': item.name
|
|
97
98
|
}, item.buttonProps, {
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"icon",
|
|
61
61
|
"createElement",
|
|
62
62
|
"type",
|
|
63
|
+
"key",
|
|
63
64
|
"onClick",
|
|
64
65
|
"evn",
|
|
65
66
|
"stopPropagation",
|
|
@@ -70,8 +71,8 @@
|
|
|
70
71
|
"isChild",
|
|
71
72
|
"extraCommands"
|
|
72
73
|
],
|
|
73
|
-
"mappings": ";AAAA,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4BACE,KAAC,YAAD,eAAkBvD,KAAlB;AAAyB,MAAA,QAAQ,EAAEA,KAAK,CAACc,QAAN,IAAkBA,QAAlB,IAA8B;AAAjE,OADF,EAEG,CAAC0C,OAAD,iBAAY,KAAC,YAAD,eAAkBxD,KAAlB;AAAyB,MAAA,QAAQ,EAAEyD,aAAa,IAAI;AAApD,OAFf;AAAA,IADF;AAMD",
|
|
74
75
|
"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 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 } = 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) {\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]);\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 />;\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 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 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"
|
|
76
|
+
"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 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 } = 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) {\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]);\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 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"
|
|
76
77
|
]
|
|
77
78
|
}
|
|
@@ -92,7 +92,7 @@ function ToolbarItems(props) {
|
|
|
92
92
|
}), idx);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
if (!item.keyCommand) return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {});
|
|
95
|
+
if (!item.keyCommand) return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {}, idx);
|
|
96
96
|
var activeBtn = fullscreen && item.keyCommand === 'fullscreen' || item.keyCommand === 'preview' && preview === item.value;
|
|
97
97
|
var childNode = item.children && typeof item.children === 'function' ? item.children({
|
|
98
98
|
getState: function getState() {
|
|
@@ -113,6 +113,7 @@ function ToolbarItems(props) {
|
|
|
113
113
|
className: activeBtn ? "active" : '',
|
|
114
114
|
children: [!item.buttonProps && item.icon, item.buttonProps && /*#__PURE__*/_react.default.createElement('button', (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
115
115
|
type: 'button',
|
|
116
|
+
key: idx,
|
|
116
117
|
disabled: disabled,
|
|
117
118
|
'data-name': item.name
|
|
118
119
|
}, item.buttonProps), {}, {
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"React",
|
|
56
56
|
"createElement",
|
|
57
57
|
"type",
|
|
58
|
+
"key",
|
|
58
59
|
"onClick",
|
|
59
60
|
"evn",
|
|
60
61
|
"stopPropagation",
|
|
@@ -65,8 +66,8 @@
|
|
|
65
66
|
"isChild",
|
|
66
67
|
"extraCommands"
|
|
67
68
|
],
|
|
68
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;;AAEA;;AAEA;;;;AAUO,SAASA,YAAT,CAAsBC,KAAtB,EAA4C;AACjD,MAAQC,SAAR,GAAsBD,KAAtB,CAAQC,SAAR;;AACA,oBAA8E,uBAAWC,sBAAX,CAA9E;AAAA,MAAQC,UAAR,eAAQA,UAAR;AAAA,MAAoBC,OAApB,eAAoBA,OAApB;AAAA,yCAA6BC,QAA7B;AAAA,MAA6BA,QAA7B,qCAAwC,EAAxC;AAAA,MAA4CC,mBAA5C,eAA4CA,mBAA5C;AAAA,MAAiEC,QAAjE,eAAiEA,QAAjE;;AACA,MAAMC,gBAAgB,GAAG,mBAAO,EAAP,CAAzB;;AAEA,WAASC,WAAT,CAAqBC,OAArB,EAAgDC,IAAhD,EAA+D;AAC7D,QAAI,CAACJ,QAAL,EAAe;AACf,QAAMK,KAAmB,GAAG;AAAEP,MAAAA,QAAQ,kCAAOA,QAAP;AAAV,KAA5B;;AACA,QAAIK,OAAO,CAACG,UAAR,KAAuB,SAA3B,EAAsC;AACpCD,MAAAA,KAAK,CAACR,OAAN,GAAgBM,OAAO,CAACI,KAAxB;AACD;;AACD,QAAIJ,OAAO,CAACG,UAAR,KAAuB,YAA3B,EAAyC;AACvCD,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AA,MAA3BxD,KAA2B,uEAAJ,EAAI;AACzD,MAAQC,SAAR,GAA4CD,KAA5C,CAAQC,SAAR;AAAA,sBAA4CD,KAA5C,CAAmByD,MAAnB;AAAA,MAAmBA,MAAnB,8BAA4B,EAA5B;AAAA,MAAgCC,OAAhC,GAA4C1D,KAA5C,CAAgC0D,OAAhC;;AACA,qBAAoC,uBAAWxD,sBAAX,CAApC;AAAA,MAAQa,QAAR,gBAAQA,QAAR;AAAA,MAAkB4C,aAAlB,gBAAkBA,aAAlB;;AACA,sBACE;AAAK,IAAA,SAAS,YAAK1D,SAAL,aAAd;AAAwC,IAAA,KAAK,EAAE;AAAEwD,MAAAA,MAAM,EAANA;AAAF,KAA/C;AAAA,4BACE,qBAAC,YAAD,8DAAkBzD,KAAlB;AAAyB,MAAA,QAAQ,EAAEA,KAAK,CAACe,QAAN,IAAkBA,QAAlB,IAA8B;AAAjE,OADF,EAEG,CAAC2C,OAAD,iBAAY,qBAAC,YAAD,8DAAkB1D,KAAlB;AAAyB,MAAA,QAAQ,EAAE2D,aAAa,IAAI;AAApD,OAFf;AAAA,IADF;AAMD",
|
|
69
70
|
"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 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 } = 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) {\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]);\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 />;\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 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 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"
|
|
71
|
+
"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 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 } = 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) {\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]);\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 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"
|
|
71
72
|
]
|
|
72
73
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uiw/react-md-editor",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.9",
|
|
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>",
|
|
@@ -9,13 +9,14 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"prepare": "husky install && npm run build",
|
|
11
11
|
"released": "npm run build && npm run doc",
|
|
12
|
-
"bundle": "kkt build --bundle",
|
|
13
|
-
"bundle:min": "kkt build --bundle --mini --no-emptyDir",
|
|
14
12
|
"doc": "kkt build --app-src ./website",
|
|
15
13
|
"start": "kkt start --app-src ./website",
|
|
16
14
|
"css:build": "compile-less -d src -o esm",
|
|
17
15
|
"css:watch": "compile-less -d src -o esm --watch",
|
|
18
16
|
"css:build:dist": "compile-less -d src --combine markdown-editor.css --rm-global",
|
|
17
|
+
"bundle": "ncc build src/index.tsx --target web --filename mdeditor",
|
|
18
|
+
"bundle:watch": "ncc watch src/index.tsx --target web --filename mdeditor",
|
|
19
|
+
"bundle:min": "ncc build src/index.tsx --target web --filename mdeditor --minify",
|
|
19
20
|
"watch": "tsbb watch & npm run css:watch",
|
|
20
21
|
"build": "tsbb build && npm run css:build && npm run css:build:dist",
|
|
21
22
|
"test": "tsbb test --env=jsdom",
|
|
@@ -40,34 +41,34 @@
|
|
|
40
41
|
"react-dom": ">=16.8.0"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
|
-
"@kkt/less-modules": "7.
|
|
44
|
-
"@kkt/
|
|
45
|
-
"@kkt/
|
|
46
|
-
"@kkt/scope-plugin-options": "7.
|
|
47
|
-
"@types/katex": "0.11.1",
|
|
48
|
-
"@types/react": "17.0.
|
|
49
|
-
"@types/react-dom": "17.0.11",
|
|
50
|
-
"@types/react-test-renderer": "17.0.1",
|
|
51
|
-
"@uiw/react-github-corners": "1.5.3",
|
|
52
|
-
"@uiw/react-codesandbox": "1.1.4",
|
|
53
|
-
"@uiw/react-shields": "1.1.2",
|
|
54
|
-
"compile-less-cli": "1.8.11",
|
|
55
|
-
"katex": "0.15.2",
|
|
56
|
-
"husky": "7.0.4",
|
|
57
|
-
"kkt": "7.
|
|
58
|
-
"lint-staged": "12.3.
|
|
59
|
-
"prettier": "2.5.1",
|
|
60
|
-
"react": "17.0.2",
|
|
61
|
-
"react-dom": "17.0.2",
|
|
62
|
-
"react-test-renderer": "17.0.2",
|
|
63
|
-
"source-map-explorer": "2.5.2",
|
|
64
|
-
"tsbb": "3.
|
|
44
|
+
"@kkt/less-modules": "~7.1.1",
|
|
45
|
+
"@kkt/ncc": "~1.0.9",
|
|
46
|
+
"@kkt/raw-modules": "~7.1.1",
|
|
47
|
+
"@kkt/scope-plugin-options": "~7.1.1",
|
|
48
|
+
"@types/katex": "~0.11.1",
|
|
49
|
+
"@types/react": "~17.0.39",
|
|
50
|
+
"@types/react-dom": "~17.0.11",
|
|
51
|
+
"@types/react-test-renderer": "~17.0.1",
|
|
52
|
+
"@uiw/react-github-corners": "~1.5.3",
|
|
53
|
+
"@uiw/react-codesandbox": "~1.1.4",
|
|
54
|
+
"@uiw/react-shields": "~1.1.2",
|
|
55
|
+
"compile-less-cli": "~1.8.11",
|
|
56
|
+
"katex": "~0.15.2",
|
|
57
|
+
"husky": "~7.0.4",
|
|
58
|
+
"kkt": "~7.1.5",
|
|
59
|
+
"lint-staged": "~12.3.4",
|
|
60
|
+
"prettier": "~2.5.1",
|
|
61
|
+
"react": "~17.0.2",
|
|
62
|
+
"react-dom": "~17.0.2",
|
|
63
|
+
"react-test-renderer": "~17.0.2",
|
|
64
|
+
"source-map-explorer": "~2.5.2",
|
|
65
|
+
"tsbb": "~3.7.0"
|
|
65
66
|
},
|
|
66
67
|
"dependencies": {
|
|
67
68
|
"@babel/runtime": "^7.14.6",
|
|
68
|
-
"@uiw/react-markdown-preview": "3.
|
|
69
|
-
"rehype-sanitize": "5.0.1",
|
|
70
|
-
"rehype": "12.0.
|
|
69
|
+
"@uiw/react-markdown-preview": "~3.5.0",
|
|
70
|
+
"rehype-sanitize": "~5.0.1",
|
|
71
|
+
"rehype": "~12.0.1"
|
|
71
72
|
},
|
|
72
73
|
"keywords": [
|
|
73
74
|
"react",
|
|
@@ -68,7 +68,7 @@ export function ToolbarItems(props: IToolbarProps) {
|
|
|
68
68
|
if (item.keyCommand === 'divider') {
|
|
69
69
|
return <li key={idx} {...item.liProps} className={`${prefixCls}-toolbar-divider`} />;
|
|
70
70
|
}
|
|
71
|
-
if (!item.keyCommand) return <Fragment />;
|
|
71
|
+
if (!item.keyCommand) return <Fragment key={idx} />;
|
|
72
72
|
const activeBtn =
|
|
73
73
|
(fullscreen && item.keyCommand === 'fullscreen') || (item.keyCommand === 'preview' && preview === item.value);
|
|
74
74
|
const childNode =
|
|
@@ -89,6 +89,7 @@ export function ToolbarItems(props: IToolbarProps) {
|
|
|
89
89
|
'button',
|
|
90
90
|
{
|
|
91
91
|
type: 'button',
|
|
92
|
+
key: idx,
|
|
92
93
|
disabled,
|
|
93
94
|
'data-name': item.name,
|
|
94
95
|
...item.buttonProps,
|