@uiw/react-md-editor 4.1.4 → 4.1.6
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 +16 -1
- package/dist/mdeditor.js +7 -5
- package/dist/mdeditor.min.js +1 -1
- package/esm/Editor.factory.js +26 -2
- package/esm/Types.d.ts +6 -0
- package/esm/commands/index.cn.d.ts +2 -1
- package/esm/commands/index.cn.js +2 -2
- package/esm/commands/index.d.ts +2 -2
- package/esm/commands/index.js +2 -2
- package/esm/commands/list.d.ts +1 -1
- package/esm/commands/list.js +9 -3
- package/esm/components/TextArea/Textarea.js +0 -1
- package/esm/components/TextArea/factory.js +6 -3
- package/lib/Editor.factory.js +26 -2
- package/lib/Types.d.ts +6 -0
- package/lib/commands/index.cn.d.ts +2 -1
- package/lib/commands/index.cn.js +8 -1
- package/lib/commands/index.d.ts +2 -2
- package/lib/commands/index.js +6 -0
- package/lib/commands/list.d.ts +1 -1
- package/lib/commands/list.js +5 -1
- package/lib/components/TextArea/Textarea.js +0 -1
- package/lib/components/TextArea/factory.js +6 -3
- package/package.json +1 -1
- package/src/Editor.factory.tsx +24 -0
- package/src/Types.ts +6 -0
- package/src/commands/index.cn.ts +2 -0
- package/src/commands/index.ts +2 -1
- package/src/commands/list.tsx +11 -2
- package/src/components/TextArea/Textarea.tsx +0 -1
- package/src/components/TextArea/factory.tsx +7 -5
package/README.md
CHANGED
|
@@ -330,6 +330,21 @@ export default function App() {
|
|
|
330
330
|
|
|
331
331
|
### Custom Toolbars
|
|
332
332
|
|
|
333
|
+
List commands select a word by default. Custom commands can pass 'line' to makeList to select the entire line instead
|
|
334
|
+
|
|
335
|
+
```tsx
|
|
336
|
+
import MDEditor, { commands } from '@uiw/react-md-editor';
|
|
337
|
+
|
|
338
|
+
const lineListCommand = {
|
|
339
|
+
...commands.unorderedListCommand,
|
|
340
|
+
execute: (state, api) => commands.makeList(state, api, '- ', 'line'),
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
// <MDEditor commands={[lineListCommand]} />
|
|
344
|
+
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
|
|
333
348
|
[](https://codesandbox.io/embed/react-md-editor-custom-toolbars-m2n10?fontsize=14&hidenavigation=1&theme=dark)
|
|
334
349
|
|
|
335
350
|
```jsx mdx:preview
|
|
@@ -1186,6 +1201,7 @@ As always, thanks to our amazing contributors!
|
|
|
1186
1201
|
<a href="https://github.com/jaywcjlove" title="小弟调调"><img src="https://avatars.githubusercontent.com/u/1680273?v=4" width="42;" alt="小弟调调"/></a>
|
|
1187
1202
|
<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>
|
|
1188
1203
|
<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>
|
|
1204
|
+
<a href="https://github.com/hiyouwhatsapp" title="hiyouwhatsapp"><img src="https://avatars.githubusercontent.com/u/89997383?v=4" width="42;" alt="hiyouwhatsapp"/></a>
|
|
1189
1205
|
<a href="https://github.com/RARgames" title="RAR"><img src="https://avatars.githubusercontent.com/u/13639766?v=4" width="42;" alt="RAR"/></a>
|
|
1190
1206
|
<a href="https://github.com/Stopa" title="Stepan Bolotnikov"><img src="https://avatars.githubusercontent.com/u/408256?v=4" width="42;" alt="Stepan Bolotnikov"/></a>
|
|
1191
1207
|
<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>
|
|
@@ -1208,7 +1224,6 @@ As always, thanks to our amazing contributors!
|
|
|
1208
1224
|
<a href="https://github.com/rami-maalouf" title="Rami Maalouf"><img src="https://avatars.githubusercontent.com/u/81759594?v=4" width="42;" alt="Rami Maalouf"/></a>
|
|
1209
1225
|
<a href="https://github.com/toresbe" title="Tore Sinding Bekkedal"><img src="https://avatars.githubusercontent.com/u/1761606?v=4" width="42;" alt="Tore Sinding Bekkedal"/></a>
|
|
1210
1226
|
<a href="https://github.com/valenfv" title="Valentin"><img src="https://avatars.githubusercontent.com/u/34139820?v=4" width="42;" alt="Valentin"/></a>
|
|
1211
|
-
<a href="https://github.com/hiyouwhatsapp" title="hiyouwhatsapp"><img src="https://avatars.githubusercontent.com/u/89997383?v=4" width="42;" alt="hiyouwhatsapp"/></a>
|
|
1212
1227
|
<a href="https://github.com/jmtes" title="juno tesoro"><img src="https://avatars.githubusercontent.com/u/38450133?v=4" width="42;" alt="juno tesoro"/></a>
|
|
1213
1228
|
<a href="https://github.com/juspky" title="juspky"><img src="https://avatars.githubusercontent.com/u/11074890?v=4" width="42;" alt="juspky"/></a>
|
|
1214
1229
|
<a href="https://github.com/ryicoh" title="ryicoh"><img src="https://avatars.githubusercontent.com/u/37844673?v=4" width="42;" alt="ryicoh"/></a>
|
package/dist/mdeditor.js
CHANGED
|
@@ -656,6 +656,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
656
656
|
issue: () => (/* reexport */ issue),
|
|
657
657
|
italic: () => (/* reexport */ italic),
|
|
658
658
|
link: () => (/* reexport */ commands_link_link),
|
|
659
|
+
makeList: () => (/* reexport */ makeList),
|
|
659
660
|
orderedListCommand: () => (/* reexport */ orderedListCommand),
|
|
660
661
|
quote: () => (/* reexport */ quote),
|
|
661
662
|
reducer: () => (/* reexport */ reducer),
|
|
@@ -941,6 +942,7 @@ __webpack_require__.d(commands_namespaceObject, {
|
|
|
941
942
|
issue: () => (issue),
|
|
942
943
|
italic: () => (italic),
|
|
943
944
|
link: () => (commands_link_link),
|
|
945
|
+
makeList: () => (makeList),
|
|
944
946
|
orderedListCommand: () => (orderedListCommand),
|
|
945
947
|
quote: () => (quote),
|
|
946
948
|
strikethrough: () => (strikeThrough_strikethrough),
|
|
@@ -77724,7 +77726,7 @@ var italic={name:'italic',keyCommand:'italic',shortcuts:'ctrlcmd+i',prefix:'*',b
|
|
|
77724
77726
|
;// ./src/commands/link.tsx
|
|
77725
77727
|
var commands_link_link={name:'link',keyCommand:'link',shortcuts:'ctrlcmd+l',prefix:'[',suffix:'](url)',buttonProps:{'aria-label':'Add a link (ctrl + l)',title:'Add a link (ctrl + l)'},icon:/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("svg",{"data-name":"italic",width:"12",height:"12",role:"img",viewBox:"0 0 520 520",children:/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("path",{fill:"currentColor",d:"M331.751196,182.121107 C392.438214,241.974735 391.605313,337.935283 332.11686,396.871226 C332.005129,396.991316 331.873084,397.121413 331.751196,397.241503 L263.493918,464.491645 C203.291404,523.80587 105.345257,523.797864 45.151885,464.491645 C-15.0506283,405.187427 -15.0506283,308.675467 45.151885,249.371249 L82.8416853,212.237562 C92.836501,202.39022 110.049118,208.9351 110.56511,222.851476 C111.223305,240.5867 114.451306,258.404985 120.407566,275.611815 C122.424812,281.438159 120.983487,287.882964 116.565047,292.23621 L103.272145,305.332975 C74.8052033,333.379887 73.9123737,379.047937 102.098973,407.369054 C130.563883,435.969378 177.350591,436.139505 206.033884,407.879434 L274.291163,340.6393 C302.9257,312.427264 302.805844,266.827265 274.291163,238.733318 C270.531934,235.036561 266.74528,232.16442 263.787465,230.157924 C259.544542,227.2873 256.928256,222.609848 256.731165,217.542518 C256.328935,206.967633 260.13184,196.070508 268.613213,187.714278 L289.998463,166.643567 C295.606326,161.118448 304.403592,160.439942 310.906317,164.911276 C318.353355,170.034591 325.328531,175.793397 331.751196,182.121107 Z M240.704978,55.4828366 L172.447607,122.733236 C172.325719,122.853326 172.193674,122.983423 172.081943,123.103513 C117.703294,179.334654 129.953294,261.569283 185.365841,328.828764 C191.044403,335.721376 198.762988,340.914712 206.209732,346.037661 C212.712465,350.509012 221.510759,349.829503 227.117615,344.305363 L248.502893,323.234572 C256.984277,314.87831 260.787188,303.981143 260.384957,293.406218 C260.187865,288.338869 257.571576,283.661398 253.328648,280.790763 C250.370829,278.78426 246.58417,275.912107 242.824936,272.215337 C214.310216,244.121282 206.209732,204.825874 229.906702,179.334654 L298.164073,112.094263 C326.847404,83.8340838 373.633159,84.0042113 402.099123,112.604645 C430.285761,140.92587 429.393946,186.594095 400.92595,214.641114 L387.63303,227.737929 C383.214584,232.091191 381.773257,238.536021 383.790506,244.362388 C389.746774,261.569283 392.974779,279.387637 393.632975,297.122928 C394.149984,311.039357 411.361608,317.584262 421.356437,307.736882 L459.046288,270.603053 C519.249898,211.29961 519.249898,114.787281 459.047304,55.4828366 C398.853851,-3.82360914 300.907572,-3.83161514 240.704978,55.4828366 Z"})}),execute:function execute(state,api){var newSelectionRange=selectWord({text:state.text,selection:state.selection,prefix:state.command.prefix,suffix:state.command.suffix});var state1=api.setSelectionRange(newSelectionRange);if(state1.selectedText.includes('http')||state1.selectedText.includes('www')){newSelectionRange=selectWord({text:state.text,selection:state.selection,prefix:'[](',suffix:')'});state1=api.setSelectionRange(newSelectionRange);executeCommand({api:api,selectedText:state1.selectedText,selection:state.selection,prefix:'[](',suffix:')'});}else{if(state1.selectedText.length===0){executeCommand({api:api,selectedText:state1.selectedText,selection:state.selection,prefix:'[title',suffix:'](url)'});}else{executeCommand({api:api,selectedText:state1.selectedText,selection:state.selection,prefix:state.command.prefix,suffix:state.command.suffix});}}}};
|
|
77726
77728
|
;// ./src/commands/list.tsx
|
|
77727
|
-
var makeList=function makeList(state,api,insertBefore){var newSelectionRange=selectWord({text:state.text,selection:state.selection,prefix:state.command.prefix});var state1=api.setSelectionRange(newSelectionRange);var breaksBeforeCount=getBreaksNeededForEmptyLineBefore(state1.text,state1.selection.start);var breaksBefore=Array(breaksBeforeCount+1).join('\n');var breaksAfterCount=getBreaksNeededForEmptyLineAfter(state1.text,state1.selection.end);var breaksAfter=Array(breaksAfterCount+1).join('\n');var _insertBeforeEachLine=insertBeforeEachLine(state1.selectedText,insertBefore),modifiedText=_insertBeforeEachLine.modifiedText,insertionLength=_insertBeforeEachLine.insertionLength;if(insertionLength<0){// Remove
|
|
77729
|
+
var makeList=function makeList(state,api,insertBefore){var selectionStrategy=arguments.length>3&&arguments[3]!==undefined?arguments[3]:'word';var newSelectionRange=selectionStrategy==='line'?selectLine({text:state.text,selection:state.selection}):selectWord({text:state.text,selection:state.selection,prefix:state.command.prefix});var state1=api.setSelectionRange(newSelectionRange);var breaksBeforeCount=getBreaksNeededForEmptyLineBefore(state1.text,state1.selection.start);var breaksBefore=Array(breaksBeforeCount+1).join('\n');var breaksAfterCount=getBreaksNeededForEmptyLineAfter(state1.text,state1.selection.end);var breaksAfter=Array(breaksAfterCount+1).join('\n');var _insertBeforeEachLine=insertBeforeEachLine(state1.selectedText,insertBefore),modifiedText=_insertBeforeEachLine.modifiedText,insertionLength=_insertBeforeEachLine.insertionLength;if(insertionLength<0){// Remove
|
|
77728
77730
|
var selectionStart=state1.selection.start;var selectionEnd=state1.selection.end;if(state1.selection.start>0&&state.text.slice(state1.selection.start-1,state1.selection.start)==='\n'){selectionStart-=1;}if(state1.selection.end<state.text.length-1&&state.text.slice(state1.selection.end,state1.selection.end+1)==='\n'){selectionEnd+=1;}api.setSelectionRange({start:selectionStart,end:selectionEnd});api.replaceSelection("".concat(modifiedText));api.setSelectionRange({start:selectionStart,end:selectionStart+modifiedText.length});}else{// Add
|
|
77729
77731
|
api.replaceSelection("".concat(breaksBefore).concat(modifiedText).concat(breaksAfter));var _selectionStart=state1.selection.start+breaksBeforeCount;var _selectionEnd=_selectionStart+modifiedText.length;api.setSelectionRange({start:_selectionStart,end:_selectionEnd});}};var unorderedListCommand={name:'unordered-list',keyCommand:'list',shortcuts:'ctrl+shift+u',prefix:'- ',buttonProps:{'aria-label':'Add unordered list (ctrl + shift + u)',title:'Add unordered list (ctrl + shift + u)'},icon:/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("svg",{"data-name":"unordered-list",width:"12",height:"12",viewBox:"0 0 512 512",children:/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("path",{fill:"currentColor",d:"M96 96c0 26.51-21.49 48-48 48S0 122.51 0 96s21.49-48 48-48 48 21.49 48 48zM48 208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm0 160c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm96-236h352c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H144c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h352c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H144c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h352c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H144c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"})}),execute:function execute(state,api){makeList(state,api,'- ');}};var orderedListCommand={name:'ordered-list',keyCommand:'list',shortcuts:'ctrl+shift+o',prefix:'1. ',buttonProps:{'aria-label':'Add ordered list (ctrl + shift + o)',title:'Add ordered list (ctrl + shift + o)'},icon:/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("svg",{"data-name":"ordered-list",width:"12",height:"12",role:"img",viewBox:"0 0 512 512",children:/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("path",{fill:"currentColor",d:"M3.263 139.527c0-7.477 3.917-11.572 11.573-11.572h15.131V88.078c0-5.163.534-10.503.534-10.503h-.356s-1.779 2.67-2.848 3.738c-4.451 4.273-10.504 4.451-15.666-1.068l-5.518-6.231c-5.342-5.341-4.984-11.216.534-16.379l21.72-19.938C32.815 33.602 36.732 32 42.785 32H54.89c7.656 0 11.749 3.916 11.749 11.572v84.384h15.488c7.655 0 11.572 4.094 11.572 11.572v8.901c0 7.477-3.917 11.572-11.572 11.572H14.836c-7.656 0-11.573-4.095-11.573-11.572v-8.902zM2.211 304.591c0-47.278 50.955-56.383 50.955-69.165 0-7.18-5.954-8.755-9.28-8.755-3.153 0-6.479 1.051-9.455 3.852-5.079 4.903-10.507 7.004-16.111 2.451l-8.579-6.829c-5.779-4.553-7.18-9.805-2.803-15.409C13.592 201.981 26.025 192 47.387 192c19.437 0 44.476 10.506 44.476 39.573 0 38.347-46.753 46.402-48.679 56.909h39.049c7.529 0 11.557 4.027 11.557 11.382v8.755c0 7.354-4.028 11.382-11.557 11.382h-67.94c-7.005 0-12.083-4.028-12.083-11.382v-4.028zM5.654 454.61l5.603-9.28c3.853-6.654 9.105-7.004 15.584-3.152 4.903 2.101 9.63 3.152 14.359 3.152 10.155 0 14.358-3.502 14.358-8.23 0-6.654-5.604-9.106-15.934-9.106h-4.728c-5.954 0-9.28-2.101-12.258-7.88l-1.05-1.926c-2.451-4.728-1.226-9.806 2.801-14.884l5.604-7.004c6.829-8.405 12.257-13.483 12.257-13.483v-.35s-4.203 1.051-12.608 1.051H16.685c-7.53 0-11.383-4.028-11.383-11.382v-8.755c0-7.53 3.853-11.382 11.383-11.382h58.484c7.529 0 11.382 4.027 11.382 11.382v3.327c0 5.778-1.401 9.806-5.079 14.183l-17.509 20.137c19.611 5.078 28.716 20.487 28.716 34.845 0 21.363-14.358 44.126-48.503 44.126-16.636 0-28.192-4.728-35.896-9.455-5.779-4.202-6.304-9.805-2.626-15.934zM144 132h352c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H144c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h352c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H144c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h352c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H144c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"})}),execute:function execute(state,api){makeList(state,api,function(item,index){return"".concat(index+1,". ");});}};var checkedListCommand={name:'checked-list',keyCommand:'list',shortcuts:'ctrl+shift+c',prefix:'- [ ] ',buttonProps:{'aria-label':'Add checked list (ctrl + shift + c)',title:'Add checked list (ctrl + shift + c)'},icon:/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("svg",{"data-name":"checked-list",width:"12",height:"12",role:"img",viewBox:"0 0 512 512",children:/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("path",{fill:"currentColor",d:"M208 132h288c8.8 0 16-7.2 16-16V76c0-8.8-7.2-16-16-16H208c-8.8 0-16 7.2-16 16v40c0 8.8 7.2 16 16 16zm0 160h288c8.8 0 16-7.2 16-16v-40c0-8.8-7.2-16-16-16H208c-8.8 0-16 7.2-16 16v40c0 8.8 7.2 16 16 16zm0 160h288c8.8 0 16-7.2 16-16v-40c0-8.8-7.2-16-16-16H208c-8.8 0-16 7.2-16 16v40c0 8.8 7.2 16 16 16zM64 368c-26.5 0-48.6 21.5-48.6 48s22.1 48 48.6 48 48-21.5 48-48-21.5-48-48-48zm92.5-299l-72.2 72.2-15.6 15.6c-4.7 4.7-12.9 4.7-17.6 0L3.5 109.4c-4.7-4.7-4.7-12.3 0-17l15.7-15.7c4.7-4.7 12.3-4.7 17 0l22.7 22.1 63.7-63.3c4.7-4.7 12.3-4.7 17 0l17 16.5c4.6 4.7 4.6 12.3-.1 17zm0 159.6l-72.2 72.2-15.7 15.7c-4.7 4.7-12.9 4.7-17.6 0L3.5 269c-4.7-4.7-4.7-12.3 0-17l15.7-15.7c4.7-4.7 12.3-4.7 17 0l22.7 22.1 63.7-63.7c4.7-4.7 12.3-4.7 17 0l17 17c4.6 4.6 4.6 12.2-.1 16.9z"})}),execute:function execute(state,api){makeList(state,api,function(item,index){return"- [ ] ";});}};
|
|
77730
77732
|
;// ./src/commands/preview.tsx
|
|
@@ -77811,11 +77813,11 @@ stopPropagation(e);var selection={start:target.selectionStart,end:target.selecti
|
|
|
77811
77813
|
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_namespaceFn().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_namespaceFn().useEffect)(function(){statesRef.current={fullscreen:fullscreen,preview:preview,highlightEnable:highlightEnable};},[fullscreen,preview,highlightEnable]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().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
|
|
77812
77814
|
},[]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().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_namespaceFn().useEffect)(function(){if(textRef.current){textRef.current.addEventListener('keydown',onKeyDown);}return function(){if(textRef.current){// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77813
77815
|
textRef.current.removeEventListener('keydown',onKeyDown);}};// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77814
|
-
},[]);return/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("textarea",_objectSpread2(_objectSpread2({autoComplete:"off",
|
|
77816
|
+
},[]);return/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("textarea",_objectSpread2(_objectSpread2({autoComplete:"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);}}));}
|
|
77815
77817
|
;// ./src/components/TextArea/factory.tsx
|
|
77816
77818
|
var factory_excluded=["prefixCls","className","onScroll","renderTextarea"];function createTextArea(options){var _options$useMinHeight;var MarkdownComponent=options===null||options===void 0?void 0:options.Markdown;var useMinHeight=(_options$useMinHeight=options===null||options===void 0?void 0:options.useMinHeight)!==null&&_options$useMinHeight!==void 0?_options$useMinHeight:false;return function TextArea(props){var _ref=props||{},prefixCls=_ref.prefixCls,className=_ref.className,onScroll=_ref.onScroll,renderTextarea=_ref.renderTextarea,otherProps=_objectWithoutProperties(_ref,factory_excluded);var _useContext=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useContext)(EditorContext),markdown=_useContext.markdown,scrollTop=_useContext.scrollTop,commands=_useContext.commands,minHeight=_useContext.minHeight,highlightEnable=_useContext.highlightEnable,extraCommands=_useContext.extraCommands,dispatch=_useContext.dispatch;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 warp=/*#__PURE__*/(external_root_React_commonjs2_react_commonjs_react_amd_react_default()().createRef)();(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useEffect)(function(){var state={};if(warp.current){state.textareaWarp=warp.current||undefined;warp.current.scrollTop=scrollTop||0;}if(dispatch){dispatch(_objectSpread2({},state));}// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77817
77819
|
},[]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().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
|
|
77818
|
-
},[]);var textStyle=MarkdownComponent&&highlightEnable?{}:{WebkitTextFillColor:'initial',overflow:'auto'};return/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("div",{ref:warp,className:"".concat(prefixCls,"-area ").concat(className||''),onScroll:onScroll,children:/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("div",{className:"".concat(prefixCls,"-text"),style:useMinHeight?{minHeight:minHeight}:undefined,children:renderTextarea?(/*#__PURE__*/(external_root_React_commonjs2_react_commonjs_react_amd_react_default()().cloneElement)(renderTextarea(_objectSpread2(_objectSpread2({},
|
|
77820
|
+
},[]);var textStyle=MarkdownComponent&&highlightEnable?{}:{WebkitTextFillColor:'initial',overflow:'auto'};var inputProps=_objectSpread2({},otherProps);if(!inputProps['aria-label']&&!inputProps['aria-labelledby']&&!inputProps.id&&!inputProps.title){inputProps['aria-label']='Markdown editor';}return/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("div",{ref:warp,className:"".concat(prefixCls,"-area ").concat(className||''),onScroll:onScroll,children:/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("div",{className:"".concat(prefixCls,"-text"),style:useMinHeight?{minHeight:minHeight}:undefined,children:renderTextarea?(/*#__PURE__*/(external_root_React_commonjs2_react_commonjs_react_amd_react_default()().cloneElement)(renderTextarea(_objectSpread2(_objectSpread2({},inputProps),{},{value:markdown,autoComplete:'off',spellCheck:'false',autoCapitalize:'off',className:"".concat(prefixCls,"-text-input"),style:{WebkitTextFillColor:'inherit',overflow:'auto'}}),{dispatch:dispatch,onChange:otherProps.onChange,shortcuts:shortcutsHandle,useContext:{commands:commands,extraCommands:extraCommands,commandOrchestrator:executeRef.current}}),{ref:textRef})):/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)((external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().Fragment),{children:[MarkdownComponent&&highlightEnable&&/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(MarkdownComponent,{prefixCls:prefixCls}),/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(Textarea,_objectSpread2(_objectSpread2({prefixCls:prefixCls},inputProps),{},{style:textStyle}))]})})});};}
|
|
77819
77821
|
;// ./src/components/TextArea/index.tsx
|
|
77820
77822
|
/* harmony default export */ const components_TextArea = (createTextArea({Markdown:Markdown_Markdown,useMinHeight:true}));
|
|
77821
77823
|
;// ../node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
|
|
@@ -77887,7 +77889,7 @@ document.body.style.overflow=originalOverflow.current;}}},[fullscreen,originalOv
|
|
|
77887
77889
|
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_namespaceFn().useRef)(null);var dragRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)();var heightRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)(props.height);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().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_namespaceFn().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
|
|
77888
77890
|
},[]);var svg=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("svg",{viewBox:"0 0 512 512",height:"100%",children:/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().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,react_jsx_runtime_production_min_namespaceFn().jsx)("div",{className:"".concat(prefixCls,"-bar"),ref:$dom,children:svg});};/* harmony default export */ const components_DragBar = (DragBar_DragBar);
|
|
77889
77891
|
;// ./src/Editor.factory.tsx
|
|
77890
|
-
var Editor_factory_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;}function createMDEditor(options){var MarkdownPreview=options.MarkdownPreview,TextArea=options.TextArea;var PreviewComponent=MarkdownPreview;var TextAreaComponent=TextArea;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_factory_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_namespaceFn().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_namespaceFn().useRef)(null);var previewRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)(null);var enableScrollRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)(enableScroll);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useImperativeHandle)(ref,function(){return _objectSpread2(_objectSpread2({},state),{},{container:container.current,dispatch:dispatch});});(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return enableScrollRef.current=enableScroll;},[enableScroll]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().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
|
|
77892
|
+
var Editor_factory_excluded=["prefixCls","className","value","commands","commandsFilter","direction","extraCommands","height","enableScroll","visibleDragbar","highlightEnable","preview","fullscreen","overflow","previewOptions","textareaProps","id","name","required","disabled","readOnly","placeholder","aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required","aria-errormessage","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;}function createMDEditor(options){var MarkdownPreview=options.MarkdownPreview,TextArea=options.TextArea;var PreviewComponent=MarkdownPreview;var TextAreaComponent=TextArea;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,id=_ref.id,name=_ref.name,required=_ref.required,disabled=_ref.disabled,readOnly=_ref.readOnly,placeholder=_ref.placeholder,ariaLabel=_ref['aria-label'],ariaLabelledBy=_ref['aria-labelledby'],ariaDescribedBy=_ref['aria-describedby'],ariaInvalid=_ref['aria-invalid'],ariaRequired=_ref['aria-required'],ariaErrorMessage=_ref['aria-errormessage'],_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_factory_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_namespaceFn().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_namespaceFn().useRef)(null);var previewRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)(null);var enableScrollRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)(enableScroll);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useImperativeHandle)(ref,function(){return _objectSpread2(_objectSpread2({},state),{},{container:container.current,dispatch:dispatch});});(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return enableScrollRef.current=enableScroll;},[enableScroll]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().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
|
|
77891
77893
|
},[]);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_namespaceFn().useMemo)(function(){return propsValue!==state.markdown&&dispatch({markdown:propsValue||''});},[propsValue,state.markdown]);// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77892
77894
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return previewType!==state.preview&&dispatch({preview:previewType});},[previewType]);// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77893
77895
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return tabSize!==state.tabSize&&dispatch({tabSize:tabSize});},[tabSize]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return highlightEnable!==state.highlightEnable&&dispatch({highlightEnable:highlightEnable});},// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -77896,7 +77898,7 @@ var Editor_factory_excluded=["prefixCls","className","value","commands","command
|
|
|
77896
77898
|
[fullscreen]);// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77897
77899
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return height!==state.height&&dispatch({height:height});},[height]);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return height!==state.height&&onHeightChange&&onHeightChange(state.height,height,state);},[height,onHeightChange,state]);// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77898
77900
|
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return commands!==state.commands&&dispatch({commands:cmds});},[props.commands]);// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77899
|
-
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return extraCommands!==state.extraCommands&&dispatch({extraCommands:extraCmds});},[props.extraCommands]);var textareaDomRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)();var active=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)('preview');var initScroll=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)(false);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){textareaDomRef.current=state.textareaWarp;if(state.textareaWarp){state.textareaWarp.addEventListener('mouseover',function(){active.current='text';});state.textareaWarp.addEventListener('mouseleave',function(){active.current='preview';});}},[state.textareaWarp]);var handleScroll=function handleScroll(e,type){if(!enableScrollRef.current)return;var textareaDom=textareaDomRef.current;var previewDom=previewRef.current?previewRef.current:undefined;if(!initScroll.current){active.current=type;initScroll.current=true;}if(textareaDom&&previewDom){var scale=(textareaDom.scrollHeight-textareaDom.offsetHeight)/(previewDom.scrollHeight-previewDom.offsetHeight);if(e.target===textareaDom&&active.current==='text'){previewDom.scrollTop=textareaDom.scrollTop/scale;}if(e.target===previewDom&&active.current==='preview'){textareaDom.scrollTop=previewDom.scrollTop*scale;}var scrollTop=0;if(active.current==='text'){scrollTop=textareaDom.scrollTop||0;}else if(active.current==='preview'){scrollTop=previewDom.scrollTop||0;}dispatch({scrollTop:scrollTop});}};var previewClassName="".concat(prefixCls,"-preview ").concat(previewOptions.className||'');var handlePreviewScroll=function handlePreviewScroll(e){return handleScroll(e,'preview');};var mdPreview=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("div",{ref:previewRef,className:previewClassName,children:/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(PreviewComponent,_objectSpread2(_objectSpread2({},previewOptions),{},{onScroll:handlePreviewScroll,source:state.markdown||''}))});},[previewClassName,previewOptions,state.markdown]);var preview=(components===null||components===void 0?void 0:components.preview)&&(components===null||components===void 0?void 0:components.preview(state.markdown||'',state,dispatch));if(preview&&/*#__PURE__*/(external_root_React_commonjs2_react_commonjs_react_amd_react_default()().isValidElement)(preview)){mdPreview=/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("div",{className:previewClassName,ref:previewRef,onScroll:handlePreviewScroll,children:preview});}var containerStyle=_objectSpread2(_objectSpread2({},other.style),{},{height:state.height||'100%'});var containerClick=function containerClick(){return dispatch({barPopup:_objectSpread2({},setGroupPopFalse(state.barPopup))});};var dragBarChange=function dragBarChange(newHeight){return dispatch({height:newHeight});};var changeHandle=function changeHandle(evn){onChange&&onChange(evn.target.value,evn,state);if(textareaProps&&textareaProps.onChange){textareaProps.onChange(evn);}if(state.textarea&&state.textarea instanceof HTMLTextAreaElement&&onStatistics){var obj=new TextAreaCommandOrchestrator(state.textarea);var objState=obj.getState()||{};onStatistics(_objectSpread2(_objectSpread2({},objState),{},{lineCount:evn.target.value.split('\n').length,length:evn.target.value.length}));}};return/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(EditorContext.Provider,{value:_objectSpread2(_objectSpread2({},state),{},{dispatch:dispatch}),children:/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)("div",_objectSpread2(_objectSpread2({ref:container,className:cls},other),{},{onClick:containerClick,style:containerStyle,children:[/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(ToolbarVisibility,{hideToolbar:hideToolbar,toolbarBottom:toolbarBottom,prefixCls:prefixCls,overflow:overflow,placement:"top"}),/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)("div",{className:"".concat(prefixCls,"-content"),children:[/(edit|live)/.test(state.preview||'')&&/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(TextAreaComponent,_objectSpread2(_objectSpread2({className:"".concat(prefixCls,"-input"),prefixCls:prefixCls,autoFocus:autoFocus},textareaProps),{},{onChange:changeHandle,renderTextarea:(components===null||components===void 0?void 0:components.textarea)||renderTextarea,onScroll:function onScroll(e){return handleScroll(e,'text');}})),/(live|preview)/.test(state.preview||'')&&mdPreview]}),visibleDragbar&&!state.fullscreen&&/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(components_DragBar,{prefixCls:prefixCls,height:state.height,maxHeight:maxHeight,minHeight:minHeight,onChange:dragBarChange}),/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(ToolbarVisibility,{hideToolbar:hideToolbar,toolbarBottom:toolbarBottom,prefixCls:prefixCls,overflow:overflow,placement:"bottom"})]}))});});var Editor=InternalMDEditor;Editor.Markdown=MarkdownPreview;Editor.displayName='MDEditor';return Editor;}
|
|
77901
|
+
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return extraCommands!==state.extraCommands&&dispatch({extraCommands:extraCmds});},[props.extraCommands]);var textareaDomRef=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)();var active=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)('preview');var initScroll=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useRef)(false);(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){textareaDomRef.current=state.textareaWarp;if(state.textareaWarp){state.textareaWarp.addEventListener('mouseover',function(){active.current='text';});state.textareaWarp.addEventListener('mouseleave',function(){active.current='preview';});}},[state.textareaWarp]);var handleScroll=function handleScroll(e,type){if(!enableScrollRef.current)return;var textareaDom=textareaDomRef.current;var previewDom=previewRef.current?previewRef.current:undefined;if(!initScroll.current){active.current=type;initScroll.current=true;}if(textareaDom&&previewDom){var scale=(textareaDom.scrollHeight-textareaDom.offsetHeight)/(previewDom.scrollHeight-previewDom.offsetHeight);if(e.target===textareaDom&&active.current==='text'){previewDom.scrollTop=textareaDom.scrollTop/scale;}if(e.target===previewDom&&active.current==='preview'){textareaDom.scrollTop=previewDom.scrollTop*scale;}var scrollTop=0;if(active.current==='text'){scrollTop=textareaDom.scrollTop||0;}else if(active.current==='preview'){scrollTop=previewDom.scrollTop||0;}dispatch({scrollTop:scrollTop});}};var previewClassName="".concat(prefixCls,"-preview ").concat(previewOptions.className||'');var handlePreviewScroll=function handlePreviewScroll(e){return handleScroll(e,'preview');};var mdPreview=(0,external_root_React_commonjs2_react_commonjs_react_amd_react_namespaceFn().useMemo)(function(){return/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("div",{ref:previewRef,className:previewClassName,children:/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(PreviewComponent,_objectSpread2(_objectSpread2({},previewOptions),{},{onScroll:handlePreviewScroll,source:state.markdown||''}))});},[previewClassName,previewOptions,state.markdown]);var preview=(components===null||components===void 0?void 0:components.preview)&&(components===null||components===void 0?void 0:components.preview(state.markdown||'',state,dispatch));if(preview&&/*#__PURE__*/(external_root_React_commonjs2_react_commonjs_react_amd_react_default()().isValidElement)(preview)){mdPreview=/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("div",{className:previewClassName,ref:previewRef,onScroll:handlePreviewScroll,children:preview});}var containerStyle=_objectSpread2(_objectSpread2({},other.style),{},{height:state.height||'100%'});var containerClick=function containerClick(){return dispatch({barPopup:_objectSpread2({},setGroupPopFalse(state.barPopup))});};var dragBarChange=function dragBarChange(newHeight){return dispatch({height:newHeight});};var changeHandle=function changeHandle(evn){onChange&&onChange(evn.target.value,evn,state);if(textareaProps&&textareaProps.onChange){textareaProps.onChange(evn);}if(state.textarea&&state.textarea instanceof HTMLTextAreaElement&&onStatistics){var obj=new TextAreaCommandOrchestrator(state.textarea);var objState=obj.getState()||{};onStatistics(_objectSpread2(_objectSpread2({},objState),{},{lineCount:evn.target.value.split('\n').length,length:evn.target.value.length}));}};return/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(EditorContext.Provider,{value:_objectSpread2(_objectSpread2({},state),{},{dispatch:dispatch}),children:/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)("div",_objectSpread2(_objectSpread2({ref:container,className:cls},other),{},{onClick:containerClick,style:containerStyle,children:[/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(ToolbarVisibility,{hideToolbar:hideToolbar,toolbarBottom:toolbarBottom,prefixCls:prefixCls,overflow:overflow,placement:"top"}),/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)("div",{className:"".concat(prefixCls,"-content"),children:[/(edit|live)/.test(state.preview||'')&&/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(TextAreaComponent,_objectSpread2(_objectSpread2({className:"".concat(prefixCls,"-input"),prefixCls:prefixCls,autoFocus:autoFocus,id:id,name:name,required:required,disabled:disabled,readOnly:readOnly,placeholder:placeholder,"aria-label":ariaLabel,"aria-labelledby":ariaLabelledBy,"aria-describedby":ariaDescribedBy,"aria-invalid":ariaInvalid,"aria-required":ariaRequired,"aria-errormessage":ariaErrorMessage},textareaProps),{},{onChange:changeHandle,renderTextarea:(components===null||components===void 0?void 0:components.textarea)||renderTextarea,onScroll:function onScroll(e){return handleScroll(e,'text');}})),/(live|preview)/.test(state.preview||'')&&mdPreview]}),visibleDragbar&&!state.fullscreen&&/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(components_DragBar,{prefixCls:prefixCls,height:state.height,maxHeight:maxHeight,minHeight:minHeight,onChange:dragBarChange}),/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(ToolbarVisibility,{hideToolbar:hideToolbar,toolbarBottom:toolbarBottom,prefixCls:prefixCls,overflow:overflow,placement:"bottom"})]}))});});var Editor=InternalMDEditor;Editor.Markdown=MarkdownPreview;Editor.displayName='MDEditor';return Editor;}
|
|
77900
77902
|
;// ./src/Editor.tsx
|
|
77901
77903
|
/* harmony default export */ const Editor = (createMDEditor({MarkdownPreview:react_markdown_preview_esm,TextArea:components_TextArea}));
|
|
77902
77904
|
;// ./src/index.less
|