@uiw/react-md-editor 4.0.6 → 4.0.7
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 +47 -1
- package/dist/mdeditor.js +8 -6
- package/dist/mdeditor.min.js +1 -1
- package/esm/Context.d.ts +2 -0
- package/esm/Editor.js +5 -1
- package/esm/Editor.nohighlight.js +5 -1
- package/esm/Types.d.ts +6 -2
- package/esm/components/TextArea/Textarea.js +18 -1
- package/esm/index.css +1 -0
- package/lib/Context.d.ts +2 -0
- package/lib/Editor.js +8 -1
- package/lib/Editor.nohighlight.js +8 -1
- package/lib/Types.d.ts +6 -2
- package/lib/components/TextArea/Textarea.js +18 -1
- package/markdown-editor.css +1 -0
- package/package.json +1 -1
- package/src/Context.tsx +1 -0
- package/src/Editor.nohighlight.tsx +2 -0
- package/src/Editor.tsx +2 -0
- package/src/Types.ts +6 -2
- package/src/components/TextArea/Textarea.tsx +18 -0
package/README.md
CHANGED
|
@@ -613,6 +613,51 @@ export default function App() {
|
|
|
613
613
|
}
|
|
614
614
|
```
|
|
615
615
|
|
|
616
|
+
### Place the cursor at the end of the text
|
|
617
|
+
|
|
618
|
+
```jsx mdx:preview
|
|
619
|
+
import React from "react";
|
|
620
|
+
import MDEditor from '@uiw/react-md-editor';
|
|
621
|
+
|
|
622
|
+
const textSample = `# Welcome to the Markdown Editor!
|
|
623
|
+
|
|
624
|
+
This is a sample of the **React Markdown Editor**.
|
|
625
|
+
|
|
626
|
+
## ✨ Features
|
|
627
|
+
- Real-time preview
|
|
628
|
+
- Custom styling support
|
|
629
|
+
- Code highlighting
|
|
630
|
+
- Auto focus at the end of the text
|
|
631
|
+
|
|
632
|
+
## 📦 Sample Code
|
|
633
|
+
|
|
634
|
+
\`\`\`javascript
|
|
635
|
+
function hello() {
|
|
636
|
+
console.log("Hello, world!");
|
|
637
|
+
}
|
|
638
|
+
\`\`\`
|
|
639
|
+
|
|
640
|
+
## 🔗 Links
|
|
641
|
+
|
|
642
|
+
Visit [uiwjs/react-md-editor](https://github.com/uiwjs/react-md-editor) for more information.
|
|
643
|
+
`;
|
|
644
|
+
|
|
645
|
+
export default function App() {
|
|
646
|
+
const [value, setValue] = React.useState(textSample);
|
|
647
|
+
return (
|
|
648
|
+
<div className="container">
|
|
649
|
+
<MDEditor
|
|
650
|
+
autoFocus={true}
|
|
651
|
+
value={value}
|
|
652
|
+
autoFocusEnd={true}
|
|
653
|
+
visibleDragbar={false}
|
|
654
|
+
onChange={setValue}
|
|
655
|
+
/>
|
|
656
|
+
</div>
|
|
657
|
+
);
|
|
658
|
+
}
|
|
659
|
+
```
|
|
660
|
+
|
|
616
661
|
### Preview Markdown
|
|
617
662
|
|
|
618
663
|
[](https://codesandbox.io/embed/react-md-editor-preview-markdown-vrucl?fontsize=14&hidenavigation=1&theme=dark)
|
|
@@ -924,6 +969,7 @@ Inherit custom color variables by adding [`.wmde-markdown-var`](https://github.c
|
|
|
924
969
|
- `commandsFilter?: (command: ICommand, isExtra: boolean) => false | ICommand`: Filter or modify your commands.
|
|
925
970
|
- `extraCommands?: ICommand[]`: Displayed on the right side of the toolbar.
|
|
926
971
|
- `autoFocus?: true`: Can be used to make `Markdown Editor` focus itself on initialization.
|
|
972
|
+
- `autoFocusEnd?: false`: Can be used to make `Markdown Editor` focus on the end of text on initialization.
|
|
927
973
|
- `previewOptions?: ReactMarkdown.ReactMarkdownProps`: This is reset [@uiw/react-markdown-preview](https://github.com/uiwjs/react-markdown-preview/tree/0036dd51a25c00d5be6dc83aa978905c64750038?tab=readme-ov-file#options-props) settings.
|
|
928
974
|
- `textareaProps?: TextareaHTMLAttributes`: Set the `textarea` related props.
|
|
929
975
|
- ~~`renderTextarea?: (props, opts) => JSX.Element;`~~: `@deprecated` Please use ~~`renderTextarea`~~ -> `components`. Use div to replace TextArea or re-render TextArea. [#193](https://github.com/uiwjs/react-md-editor/issues/193)
|
|
@@ -984,8 +1030,8 @@ As always, thanks to our amazing contributors!
|
|
|
984
1030
|
<!--AUTO_GENERATED_PLEASE_DONT_DELETE_IT--><a href="https://github.com/jaywcjlove" title="小弟调调"><img src="https://avatars.githubusercontent.com/u/1680273?v=4" width="42;" alt="小弟调调"/></a>
|
|
985
1031
|
<a href="https://github.com/renovate-bot" title="Mend Renovate"><img src="https://avatars.githubusercontent.com/u/25180681?v=4" width="42;" alt="Mend Renovate"/></a>
|
|
986
1032
|
<a href="https://github.com/stevemk14ebr" title="Stephen Eckels"><img src="https://avatars.githubusercontent.com/u/6619205?v=4" width="42;" alt="Stephen Eckels"/></a>
|
|
987
|
-
<a href="https://github.com/alpharomercoma" title="Alpha Romer Coma"><img src="https://avatars.githubusercontent.com/u/108984668?v=4" width="42;" alt="Alpha Romer Coma"/></a>
|
|
988
1033
|
<a href="https://github.com/RARgames" title="RAR"><img src="https://avatars.githubusercontent.com/u/13639766?v=4" width="42;" alt="RAR"/></a>
|
|
1034
|
+
<a href="https://github.com/alpharomercoma" title="Alpha Romer Coma"><img src="https://avatars.githubusercontent.com/u/108984668?v=4" width="42;" alt="Alpha Romer Coma"/></a>
|
|
989
1035
|
<a href="https://github.com/Exmirai" title="UniqueUlysees"><img src="https://avatars.githubusercontent.com/u/6436703?v=4" width="42;" alt="UniqueUlysees"/></a>
|
|
990
1036
|
<a href="https://github.com/sandiiarov" title="Alex Sandiiarov"><img src="https://avatars.githubusercontent.com/u/15861257?v=4" width="42;" alt="Alex Sandiiarov"/></a>
|
|
991
1037
|
<a href="https://github.com/nuragic" title="Andrea Puddu"><img src="https://avatars.githubusercontent.com/u/1586378?v=4" width="42;" alt="Andrea Puddu"/></a>
|
package/dist/mdeditor.js
CHANGED
|
@@ -78,7 +78,8 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__442__;
|
|
|
78
78
|
|
|
79
79
|
if (true) {
|
|
80
80
|
module.exports = __webpack_require__(192);
|
|
81
|
-
} else
|
|
81
|
+
} else // removed by dead control flow
|
|
82
|
+
{}
|
|
82
83
|
|
|
83
84
|
|
|
84
85
|
/***/ }),
|
|
@@ -32364,7 +32365,7 @@ const html_html = create_create({
|
|
|
32364
32365
|
formTarget: null,
|
|
32365
32366
|
headers: types_spaceSeparated,
|
|
32366
32367
|
height: types_number,
|
|
32367
|
-
hidden:
|
|
32368
|
+
hidden: types_overloadedBoolean,
|
|
32368
32369
|
high: types_number,
|
|
32369
32370
|
href: null,
|
|
32370
32371
|
hrefLang: null,
|
|
@@ -76208,6 +76209,7 @@ const remarkAlert = ({ legacyTitle = false, tagName = "div" } = {}) => {
|
|
|
76208
76209
|
});
|
|
76209
76210
|
};
|
|
76210
76211
|
};
|
|
76212
|
+
/* harmony default export */ const remark_github_blockquote_alert_lib = ((/* unused pure expression or super */ null && (remarkAlert)));
|
|
76211
76213
|
function getAlertIcon(type) {
|
|
76212
76214
|
let pathD = pathData[type] ?? '';
|
|
76213
76215
|
return {
|
|
@@ -80126,8 +80128,8 @@ stopPropagation(e);var selection={start:target.selectionStart,end:target.selecti
|
|
|
80126
80128
|
// extracted by mini-css-extract-plugin
|
|
80127
80129
|
/* harmony default export */ const TextArea = ({});
|
|
80128
80130
|
;// ./src/components/TextArea/Textarea.tsx
|
|
80129
|
-
var Textarea_excluded=["prefixCls","onChange"],_excluded2=["markdown","commands","fullscreen","preview","highlightEnable","extraCommands","tabSize","defaultTabEnable","dispatch"];function Textarea(props){var prefixCls=props.prefixCls,_onChange=props.onChange,other=_objectWithoutProperties(props,Textarea_excluded);var _useContext=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useContext)(EditorContext),markdown=_useContext.markdown,commands=_useContext.commands,fullscreen=_useContext.fullscreen,preview=_useContext.preview,highlightEnable=_useContext.highlightEnable,extraCommands=_useContext.extraCommands,tabSize=_useContext.tabSize,defaultTabEnable=_useContext.defaultTabEnable,dispatch=_useContext.dispatch,otherStore=_objectWithoutProperties(_useContext,_excluded2);var textRef=external_root_React_commonjs2_react_commonjs_react_amd_react_default().useRef(null);var executeRef=external_root_React_commonjs2_react_commonjs_react_amd_react_default().useRef();var statesRef=external_root_React_commonjs2_react_commonjs_react_amd_react_default().useRef({fullscreen:fullscreen,preview:preview});(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){statesRef.current={fullscreen:fullscreen,preview:preview,highlightEnable:highlightEnable};},[fullscreen,preview,highlightEnable]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(textRef.current&&dispatch){var commandOrchestrator=new TextAreaCommandOrchestrator(textRef.current);executeRef.current=commandOrchestrator;dispatch({textarea:textRef.current,commandOrchestrator:commandOrchestrator});}// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80130
|
-
},[]);var onKeyDown=function onKeyDown(e){handleKeyDown(e,tabSize,defaultTabEnable);shortcutsHandle(e,[].concat(_toConsumableArray(commands||[]),_toConsumableArray(extraCommands||[])),executeRef.current,dispatch,statesRef.current);};(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(textRef.current){textRef.current.addEventListener('keydown',onKeyDown);}return function(){if(textRef.current){// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80131
|
+
var Textarea_excluded=["prefixCls","onChange"],_excluded2=["markdown","commands","fullscreen","preview","highlightEnable","extraCommands","tabSize","defaultTabEnable","autoFocusEnd","textareaWarp","dispatch"];function Textarea(props){var prefixCls=props.prefixCls,_onChange=props.onChange,other=_objectWithoutProperties(props,Textarea_excluded);var _useContext=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useContext)(EditorContext),markdown=_useContext.markdown,commands=_useContext.commands,fullscreen=_useContext.fullscreen,preview=_useContext.preview,highlightEnable=_useContext.highlightEnable,extraCommands=_useContext.extraCommands,tabSize=_useContext.tabSize,defaultTabEnable=_useContext.defaultTabEnable,autoFocusEnd=_useContext.autoFocusEnd,textareaWarp=_useContext.textareaWarp,dispatch=_useContext.dispatch,otherStore=_objectWithoutProperties(_useContext,_excluded2);var textRef=external_root_React_commonjs2_react_commonjs_react_amd_react_default().useRef(null);var executeRef=external_root_React_commonjs2_react_commonjs_react_amd_react_default().useRef();var statesRef=external_root_React_commonjs2_react_commonjs_react_amd_react_default().useRef({fullscreen:fullscreen,preview:preview});(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){statesRef.current={fullscreen:fullscreen,preview:preview,highlightEnable:highlightEnable};},[fullscreen,preview,highlightEnable]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(textRef.current&&dispatch){var commandOrchestrator=new TextAreaCommandOrchestrator(textRef.current);executeRef.current=commandOrchestrator;dispatch({textarea:textRef.current,commandOrchestrator:commandOrchestrator});}// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80132
|
+
},[]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(autoFocusEnd&&textRef.current&&textareaWarp){textRef.current.focus();var length=textRef.current.value.length;textRef.current.setSelectionRange(length,length);setTimeout(function(){if(textareaWarp){textareaWarp.scrollTop=textareaWarp.scrollHeight;}if(textRef.current){textRef.current.scrollTop=textRef.current.scrollHeight;}},0);}},[textareaWarp]);var onKeyDown=function onKeyDown(e){handleKeyDown(e,tabSize,defaultTabEnable);shortcutsHandle(e,[].concat(_toConsumableArray(commands||[]),_toConsumableArray(extraCommands||[])),executeRef.current,dispatch,statesRef.current);};(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(textRef.current){textRef.current.addEventListener('keydown',onKeyDown);}return function(){if(textRef.current){// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80131
80133
|
textRef.current.removeEventListener('keydown',onKeyDown);}};// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80132
80134
|
},[]);return/*#__PURE__*/(0,jsx_runtime.jsx)("textarea",_objectSpread2(_objectSpread2({autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:false},other),{},{ref:textRef,className:"".concat(prefixCls,"-text-input ").concat(other.className?other.className:''),value:markdown,onChange:function onChange(e){dispatch&&dispatch({markdown:e.target.value});_onChange&&_onChange(e);}}));}
|
|
80133
80135
|
;// ./src/components/TextArea/index.tsx
|
|
@@ -80141,12 +80143,12 @@ var TextArea_excluded=["prefixCls","className","onScroll","renderTextarea"];func
|
|
|
80141
80143
|
var DragBar_DragBar=function DragBar(props){var _ref=props||{},prefixCls=_ref.prefixCls,onChange=_ref.onChange;var $dom=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);var dragRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)();var heightRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(props.height);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(heightRef.current!==props.height){heightRef.current=props.height;}},[props.height]);function handleMouseMove(event){if(dragRef.current){var _changedTouches$;var clientY=event.clientY||((_changedTouches$=event.changedTouches[0])===null||_changedTouches$===void 0?void 0:_changedTouches$.clientY);var newHeight=dragRef.current.height+clientY-dragRef.current.dragY;if(newHeight>=props.minHeight&&newHeight<=props.maxHeight){onChange&&onChange(dragRef.current.height+(clientY-dragRef.current.dragY));}}}function handleMouseUp(){var _$dom$current,_$dom$current2;dragRef.current=undefined;document.removeEventListener('mousemove',handleMouseMove);document.removeEventListener('mouseup',handleMouseUp);(_$dom$current=$dom.current)===null||_$dom$current===void 0?void 0:_$dom$current.removeEventListener('touchmove',handleMouseMove);(_$dom$current2=$dom.current)===null||_$dom$current2===void 0?void 0:_$dom$current2.removeEventListener('touchend',handleMouseUp);}function handleMouseDown(event){var _changedTouches$2,_$dom$current3,_$dom$current4;event.preventDefault();var clientY=event.clientY||((_changedTouches$2=event.changedTouches[0])===null||_changedTouches$2===void 0?void 0:_changedTouches$2.clientY);dragRef.current={height:heightRef.current,dragY:clientY};document.addEventListener('mousemove',handleMouseMove);document.addEventListener('mouseup',handleMouseUp);(_$dom$current3=$dom.current)===null||_$dom$current3===void 0?void 0:_$dom$current3.addEventListener('touchmove',handleMouseMove,{passive:false});(_$dom$current4=$dom.current)===null||_$dom$current4===void 0?void 0:_$dom$current4.addEventListener('touchend',handleMouseUp,{passive:false});}(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){if(document){var _$dom$current5,_$dom$current6;(_$dom$current5=$dom.current)===null||_$dom$current5===void 0?void 0:_$dom$current5.addEventListener('touchstart',handleMouseDown,{passive:false});(_$dom$current6=$dom.current)===null||_$dom$current6===void 0?void 0:_$dom$current6.addEventListener('mousedown',handleMouseDown);}return function(){if(document){var _$dom$current7;(_$dom$current7=$dom.current)===null||_$dom$current7===void 0?void 0:_$dom$current7.removeEventListener('touchstart',handleMouseDown);document.removeEventListener('mousemove',handleMouseMove);}};// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80142
80144
|
},[]);var svg=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return/*#__PURE__*/(0,jsx_runtime.jsx)("svg",{viewBox:"0 0 512 512",height:"100%",children:/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"currentColor",d:"M304 256c0 26.5-21.5 48-48 48s-48-21.5-48-48 21.5-48 48-48 48 21.5 48 48zm120-48c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48zm-336 0c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z"})});},[]);return/*#__PURE__*/(0,jsx_runtime.jsx)("div",{className:"".concat(prefixCls,"-bar"),ref:$dom,children:svg});};/* harmony default export */ const components_DragBar = (DragBar_DragBar);
|
|
80143
80145
|
;// ./src/Editor.tsx
|
|
80144
|
-
var Editor_excluded=["prefixCls","className","value","commands","commandsFilter","direction","extraCommands","height","enableScroll","visibleDragbar","highlightEnable","preview","fullscreen","overflow","previewOptions","textareaProps","maxHeight","minHeight","autoFocus","tabSize","defaultTabEnable","onChange","onStatistics","onHeightChange","hideToolbar","toolbarBottom","components","renderTextarea"];function setGroupPopFalse(){var data=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};Object.keys(data).forEach(function(keyname){data[keyname]=false;});return data;}var InternalMDEditor=/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().forwardRef(function(props,ref){var _ref=props||{},_ref$prefixCls=_ref.prefixCls,prefixCls=_ref$prefixCls===void 0?'w-md-editor':_ref$prefixCls,className=_ref.className,propsValue=_ref.value,_ref$commands=_ref.commands,commands=_ref$commands===void 0?commands_getCommands():_ref$commands,commandsFilter=_ref.commandsFilter,direction=_ref.direction,_ref$extraCommands=_ref.extraCommands,extraCommands=_ref$extraCommands===void 0?getExtraCommands():_ref$extraCommands,_ref$height=_ref.height,height=_ref$height===void 0?200:_ref$height,_ref$enableScroll=_ref.enableScroll,enableScroll=_ref$enableScroll===void 0?true:_ref$enableScroll,_ref$visibleDragbar=_ref.visibleDragbar,visibleDragbar=_ref$visibleDragbar===void 0?typeof props.visiableDragbar==='boolean'?props.visiableDragbar:true:_ref$visibleDragbar,_ref$highlightEnable=_ref.highlightEnable,highlightEnable=_ref$highlightEnable===void 0?true:_ref$highlightEnable,_ref$preview=_ref.preview,previewType=_ref$preview===void 0?'live':_ref$preview,_ref$fullscreen=_ref.fullscreen,fullscreen=_ref$fullscreen===void 0?false:_ref$fullscreen,_ref$overflow=_ref.overflow,overflow=_ref$overflow===void 0?true:_ref$overflow,_ref$previewOptions=_ref.previewOptions,previewOptions=_ref$previewOptions===void 0?{}:_ref$previewOptions,textareaProps=_ref.textareaProps,_ref$maxHeight=_ref.maxHeight,maxHeight=_ref$maxHeight===void 0?1200:_ref$maxHeight,_ref$minHeight=_ref.minHeight,minHeight=_ref$minHeight===void 0?100:_ref$minHeight,autoFocus=_ref.autoFocus,_ref$tabSize=_ref.tabSize,tabSize=_ref$tabSize===void 0?2:_ref$tabSize,_ref$defaultTabEnable=_ref.defaultTabEnable,defaultTabEnable=_ref$defaultTabEnable===void 0?false:_ref$defaultTabEnable,onChange=_ref.onChange,onStatistics=_ref.onStatistics,onHeightChange=_ref.onHeightChange,hideToolbar=_ref.hideToolbar,_ref$toolbarBottom=_ref.toolbarBottom,toolbarBottom=_ref$toolbarBottom===void 0?false:_ref$toolbarBottom,components=_ref.components,renderTextarea=_ref.renderTextarea,other=_objectWithoutProperties(_ref,Editor_excluded);var cmds=commands.map(function(item){return commandsFilter?commandsFilter(item,false):item;}).filter(Boolean);var extraCmds=extraCommands.map(function(item){return commandsFilter?commandsFilter(item,true):item;}).filter(Boolean);var _useReducer=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useReducer)(reducer,{markdown:propsValue,preview:previewType,components:components,height:height,minHeight:minHeight,highlightEnable:highlightEnable,tabSize:tabSize,defaultTabEnable:defaultTabEnable,scrollTop:0,scrollTopPreview:0,commands:cmds,extraCommands:extraCmds,fullscreen:fullscreen,barPopup:{}}),_useReducer2=_slicedToArray(_useReducer,2),state=_useReducer2[0],dispatch=_useReducer2[1];var container=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);var previewRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);var enableScrollRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(enableScroll);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useImperativeHandle)(ref,function(){return _objectSpread2(_objectSpread2({},state),{},{container:container.current,dispatch:dispatch});});(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return enableScrollRef.current=enableScroll;},[enableScroll]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){var stateInit={};if(container.current){stateInit.container=container.current||undefined;}stateInit.markdown=propsValue||'';stateInit.barPopup={};if(dispatch){dispatch(_objectSpread2(_objectSpread2({},state),stateInit));}// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80146
|
+
var Editor_excluded=["prefixCls","className","value","commands","commandsFilter","direction","extraCommands","height","enableScroll","visibleDragbar","highlightEnable","preview","fullscreen","overflow","previewOptions","textareaProps","maxHeight","minHeight","autoFocus","autoFocusEnd","tabSize","defaultTabEnable","onChange","onStatistics","onHeightChange","hideToolbar","toolbarBottom","components","renderTextarea"];function setGroupPopFalse(){var data=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};Object.keys(data).forEach(function(keyname){data[keyname]=false;});return data;}var InternalMDEditor=/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().forwardRef(function(props,ref){var _ref=props||{},_ref$prefixCls=_ref.prefixCls,prefixCls=_ref$prefixCls===void 0?'w-md-editor':_ref$prefixCls,className=_ref.className,propsValue=_ref.value,_ref$commands=_ref.commands,commands=_ref$commands===void 0?commands_getCommands():_ref$commands,commandsFilter=_ref.commandsFilter,direction=_ref.direction,_ref$extraCommands=_ref.extraCommands,extraCommands=_ref$extraCommands===void 0?getExtraCommands():_ref$extraCommands,_ref$height=_ref.height,height=_ref$height===void 0?200:_ref$height,_ref$enableScroll=_ref.enableScroll,enableScroll=_ref$enableScroll===void 0?true:_ref$enableScroll,_ref$visibleDragbar=_ref.visibleDragbar,visibleDragbar=_ref$visibleDragbar===void 0?typeof props.visiableDragbar==='boolean'?props.visiableDragbar:true:_ref$visibleDragbar,_ref$highlightEnable=_ref.highlightEnable,highlightEnable=_ref$highlightEnable===void 0?true:_ref$highlightEnable,_ref$preview=_ref.preview,previewType=_ref$preview===void 0?'live':_ref$preview,_ref$fullscreen=_ref.fullscreen,fullscreen=_ref$fullscreen===void 0?false:_ref$fullscreen,_ref$overflow=_ref.overflow,overflow=_ref$overflow===void 0?true:_ref$overflow,_ref$previewOptions=_ref.previewOptions,previewOptions=_ref$previewOptions===void 0?{}:_ref$previewOptions,textareaProps=_ref.textareaProps,_ref$maxHeight=_ref.maxHeight,maxHeight=_ref$maxHeight===void 0?1200:_ref$maxHeight,_ref$minHeight=_ref.minHeight,minHeight=_ref$minHeight===void 0?100:_ref$minHeight,autoFocus=_ref.autoFocus,_ref$autoFocusEnd=_ref.autoFocusEnd,autoFocusEnd=_ref$autoFocusEnd===void 0?false:_ref$autoFocusEnd,_ref$tabSize=_ref.tabSize,tabSize=_ref$tabSize===void 0?2:_ref$tabSize,_ref$defaultTabEnable=_ref.defaultTabEnable,defaultTabEnable=_ref$defaultTabEnable===void 0?false:_ref$defaultTabEnable,onChange=_ref.onChange,onStatistics=_ref.onStatistics,onHeightChange=_ref.onHeightChange,hideToolbar=_ref.hideToolbar,_ref$toolbarBottom=_ref.toolbarBottom,toolbarBottom=_ref$toolbarBottom===void 0?false:_ref$toolbarBottom,components=_ref.components,renderTextarea=_ref.renderTextarea,other=_objectWithoutProperties(_ref,Editor_excluded);var cmds=commands.map(function(item){return commandsFilter?commandsFilter(item,false):item;}).filter(Boolean);var extraCmds=extraCommands.map(function(item){return commandsFilter?commandsFilter(item,true):item;}).filter(Boolean);var _useReducer=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useReducer)(reducer,{markdown:propsValue,preview:previewType,components:components,height:height,minHeight:minHeight,highlightEnable:highlightEnable,tabSize:tabSize,defaultTabEnable:defaultTabEnable,scrollTop:0,scrollTopPreview:0,commands:cmds,extraCommands:extraCmds,fullscreen:fullscreen,barPopup:{}}),_useReducer2=_slicedToArray(_useReducer,2),state=_useReducer2[0],dispatch=_useReducer2[1];var container=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);var previewRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);var enableScrollRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(enableScroll);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useImperativeHandle)(ref,function(){return _objectSpread2(_objectSpread2({},state),{},{container:container.current,dispatch:dispatch});});(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return enableScrollRef.current=enableScroll;},[enableScroll]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function(){var stateInit={};if(container.current){stateInit.container=container.current||undefined;}stateInit.markdown=propsValue||'';stateInit.barPopup={};if(dispatch){dispatch(_objectSpread2(_objectSpread2({},state),stateInit));}// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80145
80147
|
},[]);var cls=[className,'wmde-markdown-var',direction?"".concat(prefixCls,"-").concat(direction):null,prefixCls,state.preview?"".concat(prefixCls,"-show-").concat(state.preview):null,state.fullscreen?"".concat(prefixCls,"-fullscreen"):null].filter(Boolean).join(' ').trim();(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return propsValue!==state.markdown&&dispatch({markdown:propsValue||''});},[propsValue,state.markdown]);// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80146
80148
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return previewType!==state.preview&&dispatch({preview:previewType});},[previewType]);// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80147
80149
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return tabSize!==state.tabSize&&dispatch({tabSize:tabSize});},[tabSize]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return highlightEnable!==state.highlightEnable&&dispatch({highlightEnable:highlightEnable});},// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80148
80150
|
[highlightEnable]);// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80149
|
-
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return autoFocus!==state.autoFocus&&dispatch({autoFocus:autoFocus});},[autoFocus]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return fullscreen!==state.fullscreen&&dispatch({fullscreen:fullscreen});},// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80151
|
+
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return autoFocus!==state.autoFocus&&dispatch({autoFocus:autoFocus});},[autoFocus]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return autoFocusEnd!==state.autoFocusEnd&&dispatch({autoFocusEnd:autoFocusEnd});},[autoFocusEnd]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return fullscreen!==state.fullscreen&&dispatch({fullscreen:fullscreen});},// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80150
80152
|
[fullscreen]);// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80151
80153
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return height!==state.height&&dispatch({height:height});},[height]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return height!==state.height&&onHeightChange&&onHeightChange(state.height,height,state);},[height,onHeightChange,state]);// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80152
80154
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useMemo)(function(){return commands!==state.commands&&dispatch({commands:cmds});},[props.commands]);// eslint-disable-next-line react-hooks/exhaustive-deps
|