@uiw/react-md-editor 3.18.3 → 3.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/dist/mdeditor.js +1564 -1583
  2. package/dist/mdeditor.min.js +1 -1
  3. package/esm/Context.js.map +1 -1
  4. package/esm/Editor.js +43 -67
  5. package/esm/Editor.js.map +1 -1
  6. package/esm/commands/bold.js +4 -4
  7. package/esm/commands/bold.js.map +1 -1
  8. package/esm/commands/code.js +8 -10
  9. package/esm/commands/code.js.map +2 -2
  10. package/esm/commands/comment.js +27 -16
  11. package/esm/commands/comment.js.map +2 -2
  12. package/esm/commands/divider.js.map +1 -1
  13. package/esm/commands/fullscreen.js +3 -4
  14. package/esm/commands/fullscreen.js.map +2 -2
  15. package/esm/commands/group.js +2 -4
  16. package/esm/commands/group.js.map +1 -1
  17. package/esm/commands/hr.js.map +1 -1
  18. package/esm/commands/image.js +6 -6
  19. package/esm/commands/image.js.map +2 -2
  20. package/esm/commands/index.d.ts +2 -2
  21. package/esm/commands/index.js +12 -23
  22. package/esm/commands/index.js.map +3 -2
  23. package/esm/commands/italic.js +4 -4
  24. package/esm/commands/italic.js.map +1 -1
  25. package/esm/commands/link.js +4 -4
  26. package/esm/commands/link.js.map +1 -1
  27. package/esm/commands/list.js +4 -4
  28. package/esm/commands/list.js.map +1 -1
  29. package/esm/commands/preview.js +21 -3
  30. package/esm/commands/preview.js.map +7 -2
  31. package/esm/commands/quote.js +2 -1
  32. package/esm/commands/quote.js.map +1 -1
  33. package/esm/commands/strikeThrough.js +4 -4
  34. package/esm/commands/strikeThrough.js.map +1 -1
  35. package/esm/commands/title.js.map +1 -1
  36. package/esm/commands/title1.js.map +1 -1
  37. package/esm/commands/title2.js.map +1 -1
  38. package/esm/commands/title3.js.map +1 -1
  39. package/esm/commands/title4.js.map +1 -1
  40. package/esm/commands/title5.js.map +1 -1
  41. package/esm/commands/title6.js.map +1 -1
  42. package/esm/components/DragBar/index.js +2 -9
  43. package/esm/components/DragBar/index.js.map +1 -1
  44. package/esm/components/TextArea/Markdown.js +2 -7
  45. package/esm/components/TextArea/Markdown.js.map +1 -1
  46. package/esm/components/TextArea/Textarea.js +8 -11
  47. package/esm/components/TextArea/Textarea.js.map +1 -1
  48. package/esm/components/TextArea/handleKeyDown.js +2 -16
  49. package/esm/components/TextArea/handleKeyDown.js.map +1 -1
  50. package/esm/components/TextArea/index.js +11 -15
  51. package/esm/components/TextArea/index.js.map +1 -1
  52. package/esm/components/TextArea/shortcuts.js +1 -17
  53. package/esm/components/TextArea/shortcuts.js.map +2 -2
  54. package/esm/components/Toolbar/Child.js +2 -1
  55. package/esm/components/Toolbar/Child.js.map +1 -1
  56. package/esm/components/Toolbar/index.js +2 -12
  57. package/esm/components/Toolbar/index.js.map +1 -1
  58. package/esm/index.js.map +1 -1
  59. package/esm/utils/InsertTextAtPosition.js +28 -34
  60. package/esm/utils/InsertTextAtPosition.js.map +1 -1
  61. package/esm/utils/markdownUtils.js +14 -23
  62. package/esm/utils/markdownUtils.js.map +1 -1
  63. package/lib/Context.js +0 -6
  64. package/lib/Context.js.map +1 -1
  65. package/lib/Editor.js +74 -114
  66. package/lib/Editor.js.map +1 -1
  67. package/lib/commands/bold.js +4 -9
  68. package/lib/commands/bold.js.map +1 -1
  69. package/lib/commands/code.js +8 -15
  70. package/lib/commands/code.js.map +2 -2
  71. package/lib/commands/comment.js +27 -19
  72. package/lib/commands/comment.js.map +2 -2
  73. package/lib/commands/divider.js.map +1 -1
  74. package/lib/commands/fullscreen.js +3 -8
  75. package/lib/commands/fullscreen.js.map +2 -2
  76. package/lib/commands/group.js +2 -10
  77. package/lib/commands/group.js.map +1 -1
  78. package/lib/commands/hr.js +0 -4
  79. package/lib/commands/hr.js.map +1 -1
  80. package/lib/commands/image.js +6 -11
  81. package/lib/commands/image.js.map +2 -2
  82. package/lib/commands/index.d.ts +2 -2
  83. package/lib/commands/index.js +10 -47
  84. package/lib/commands/index.js.map +4 -3
  85. package/lib/commands/italic.js +4 -9
  86. package/lib/commands/italic.js.map +1 -1
  87. package/lib/commands/link.js +4 -9
  88. package/lib/commands/link.js.map +1 -1
  89. package/lib/commands/list.js +4 -10
  90. package/lib/commands/list.js.map +1 -1
  91. package/lib/commands/preview.js +21 -7
  92. package/lib/commands/preview.js.map +7 -2
  93. package/lib/commands/quote.js +2 -6
  94. package/lib/commands/quote.js.map +1 -1
  95. package/lib/commands/strikeThrough.js +4 -9
  96. package/lib/commands/strikeThrough.js.map +1 -1
  97. package/lib/commands/title.js +0 -6
  98. package/lib/commands/title.js.map +1 -1
  99. package/lib/commands/title1.js +0 -5
  100. package/lib/commands/title1.js.map +1 -1
  101. package/lib/commands/title2.js +0 -5
  102. package/lib/commands/title2.js.map +1 -1
  103. package/lib/commands/title3.js +0 -5
  104. package/lib/commands/title3.js.map +1 -1
  105. package/lib/commands/title4.js +0 -5
  106. package/lib/commands/title4.js.map +1 -1
  107. package/lib/commands/title5.js +0 -5
  108. package/lib/commands/title5.js.map +1 -1
  109. package/lib/commands/title6.js +0 -5
  110. package/lib/commands/title6.js.map +1 -1
  111. package/lib/components/DragBar/index.js +4 -15
  112. package/lib/components/DragBar/index.js.map +1 -1
  113. package/lib/components/TextArea/Markdown.js +6 -22
  114. package/lib/components/TextArea/Markdown.js.map +1 -1
  115. package/lib/components/TextArea/Textarea.js +15 -36
  116. package/lib/components/TextArea/Textarea.js.map +1 -1
  117. package/lib/components/TextArea/handleKeyDown.js +1 -18
  118. package/lib/components/TextArea/handleKeyDown.js.map +1 -1
  119. package/lib/components/TextArea/index.js +15 -37
  120. package/lib/components/TextArea/index.js.map +1 -1
  121. package/lib/components/TextArea/shortcuts.js +1 -17
  122. package/lib/components/TextArea/shortcuts.js.map +2 -2
  123. package/lib/components/Toolbar/Child.js +8 -18
  124. package/lib/components/Toolbar/Child.js.map +1 -1
  125. package/lib/components/Toolbar/index.js +14 -36
  126. package/lib/components/Toolbar/index.js.map +1 -1
  127. package/lib/index.js +0 -9
  128. package/lib/index.js.map +1 -1
  129. package/lib/utils/InsertTextAtPosition.js +28 -37
  130. package/lib/utils/InsertTextAtPosition.js.map +1 -1
  131. package/lib/utils/markdownUtils.js +17 -28
  132. package/lib/utils/markdownUtils.js.map +1 -1
  133. package/package.json +1 -1
  134. package/src/commands/code.tsx +2 -2
  135. package/src/commands/comment.tsx +19 -4
  136. package/src/commands/fullscreen.tsx +3 -2
  137. package/src/commands/image.tsx +1 -1
  138. package/src/commands/index.ts +8 -7
  139. package/src/commands/preview.tsx +35 -4
  140. package/src/components/TextArea/shortcuts.ts +2 -2
@@ -1,14 +1,11 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
-
3
2
  function getCommands(data, resulte) {
4
3
  if (data === void 0) {
5
4
  data = [];
6
5
  }
7
-
8
6
  if (resulte === void 0) {
9
7
  resulte = {};
10
8
  }
11
-
12
9
  data.forEach(item => {
13
10
  if (item.children && Array.isArray(item.children)) {
14
11
  resulte = _extends({}, resulte, getCommands(item.children || []));
@@ -18,43 +15,33 @@ function getCommands(data, resulte) {
18
15
  });
19
16
  return resulte;
20
17
  }
21
-
22
18
  export default function shortcutsHandle(e, commands, commandOrchestrator, dispatch, state) {
23
19
  if (commands === void 0) {
24
20
  commands = [];
25
21
  }
26
-
27
22
  var data = getCommands(commands || []);
28
23
  var shortcuts = [];
29
-
30
24
  if (e.altKey) {
31
25
  shortcuts.push('alt');
32
26
  }
33
-
34
27
  if (e.shiftKey) {
35
28
  shortcuts.push('shift');
36
29
  }
37
-
38
30
  if (e.metaKey) {
39
31
  shortcuts.push('cmd');
40
32
  }
41
-
42
33
  if (e.ctrlKey) {
43
34
  shortcuts.push('ctrl');
44
35
  }
45
-
46
36
  if (shortcuts.length > 0 && !/(control|alt|meta|shift)/.test(e.key.toLocaleLowerCase())) {
47
37
  shortcuts.push(e.key.toLocaleLowerCase());
48
38
  }
49
-
50
39
  if (/escape/.test(e.key.toLocaleLowerCase())) {
51
40
  shortcuts.push('escape');
52
41
  }
53
-
54
42
  if (shortcuts.length < 1) {
55
43
  return;
56
44
  }
57
-
58
45
  var equal = !!data[shortcuts.join('+')];
59
46
  var command = equal ? data[shortcuts.join('+')] : undefined;
60
47
  Object.keys(data).forEach(item => {
@@ -62,19 +49,16 @@ export default function shortcutsHandle(e, commands, commandOrchestrator, dispat
62
49
  if (/ctrlcmd/.test(v)) {
63
50
  return shortcuts.includes('ctrl') || shortcuts.includes('cmd');
64
51
  }
65
-
66
52
  return shortcuts.includes(v);
67
53
  });
68
-
69
54
  if (isequal) {
70
55
  command = data[item];
71
56
  }
72
57
  });
73
-
74
58
  if (command && commandOrchestrator) {
75
59
  e.stopPropagation();
76
60
  e.preventDefault();
77
- commandOrchestrator.executeCommand(command, dispatch, state);
61
+ commandOrchestrator.executeCommand(command, dispatch, state, shortcuts);
78
62
  return;
79
63
  }
80
64
  }
@@ -46,7 +46,7 @@
46
46
  "../../../src/components/TextArea/shortcuts.ts"
47
47
  ],
48
48
  "sourcesContent": [
49
- "import { ICommand, TextAreaCommandOrchestrator } from '../../commands';\nimport { ContextStore, ExecuteCommandState } from '../../Context';\n\nfunction getCommands(data: ICommand[] = [], resulte: Record<string, ICommand> = {}): Record<string, ICommand> {\n data.forEach((item) => {\n if (item.children && Array.isArray(item.children)) {\n resulte = { ...resulte, ...getCommands(item.children || []) };\n } else if (item.keyCommand && item.shortcuts && item.execute) {\n resulte[item.shortcuts.toLocaleLowerCase()] = item;\n }\n });\n return resulte;\n}\n\nexport default function shortcutsHandle(\n e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>,\n commands: ICommand[] = [],\n commandOrchestrator?: TextAreaCommandOrchestrator,\n dispatch?: React.Dispatch<ContextStore>,\n state?: ExecuteCommandState,\n) {\n const data = getCommands(commands || []);\n const shortcuts: (string | number)[] = [];\n if (e.altKey) {\n shortcuts.push('alt');\n }\n if (e.shiftKey) {\n shortcuts.push('shift');\n }\n if (e.metaKey) {\n shortcuts.push('cmd');\n }\n if (e.ctrlKey) {\n shortcuts.push('ctrl');\n }\n if (shortcuts.length > 0 && !/(control|alt|meta|shift)/.test(e.key.toLocaleLowerCase())) {\n shortcuts.push(e.key.toLocaleLowerCase());\n }\n if (/escape/.test(e.key.toLocaleLowerCase())) {\n shortcuts.push('escape');\n }\n if (shortcuts.length < 1) {\n return;\n }\n\n let equal = !!data[shortcuts.join('+')];\n let command = equal ? data[shortcuts.join('+')] : undefined;\n\n Object.keys(data).forEach((item) => {\n const isequal = item.split('+').every((v) => {\n if (/ctrlcmd/.test(v)) {\n return shortcuts.includes('ctrl') || shortcuts.includes('cmd');\n }\n return shortcuts.includes(v);\n });\n if (isequal) {\n command = data[item];\n }\n });\n if (command && commandOrchestrator) {\n e.stopPropagation();\n e.preventDefault();\n commandOrchestrator.executeCommand(command, dispatch, state);\n return;\n }\n}\n"
49
+ "import { ICommand, TextAreaCommandOrchestrator } from '../../commands';\nimport { ContextStore, ExecuteCommandState } from '../../Context';\n\nfunction getCommands(data: ICommand[] = [], resulte: Record<string, ICommand> = {}): Record<string, ICommand> {\n data.forEach((item) => {\n if (item.children && Array.isArray(item.children)) {\n resulte = { ...resulte, ...getCommands(item.children || []) };\n } else if (item.keyCommand && item.shortcuts && item.execute) {\n resulte[item.shortcuts.toLocaleLowerCase()] = item;\n }\n });\n return resulte;\n}\n\nexport default function shortcutsHandle(\n e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>,\n commands: ICommand[] = [],\n commandOrchestrator?: TextAreaCommandOrchestrator,\n dispatch?: React.Dispatch<ContextStore>,\n state?: ExecuteCommandState,\n) {\n const data = getCommands(commands || []);\n const shortcuts: string[] = [];\n if (e.altKey) {\n shortcuts.push('alt');\n }\n if (e.shiftKey) {\n shortcuts.push('shift');\n }\n if (e.metaKey) {\n shortcuts.push('cmd');\n }\n if (e.ctrlKey) {\n shortcuts.push('ctrl');\n }\n if (shortcuts.length > 0 && !/(control|alt|meta|shift)/.test(e.key.toLocaleLowerCase())) {\n shortcuts.push(e.key.toLocaleLowerCase());\n }\n if (/escape/.test(e.key.toLocaleLowerCase())) {\n shortcuts.push('escape');\n }\n if (shortcuts.length < 1) {\n return;\n }\n\n let equal = !!data[shortcuts.join('+')];\n let command = equal ? data[shortcuts.join('+')] : undefined;\n\n Object.keys(data).forEach((item) => {\n const isequal = item.split('+').every((v) => {\n if (/ctrlcmd/.test(v)) {\n return shortcuts.includes('ctrl') || shortcuts.includes('cmd');\n }\n return shortcuts.includes(v);\n });\n if (isequal) {\n command = data[item];\n }\n });\n if (command && commandOrchestrator) {\n e.stopPropagation();\n e.preventDefault();\n commandOrchestrator.executeCommand(command, dispatch, state, shortcuts);\n return;\n }\n}\n"
50
50
  ],
51
- "mappings": ";;AAGA,SAASA,WAAT,CAAqBC,IAArB,EAA4CC,OAA5C,EAA8G;EAAA,IAAzFD,IAAyF;IAAzFA,IAAyF,GAAtE,EAAsE;EAAA;;EAAA,IAAlEC,OAAkE;IAAlEA,OAAkE,GAA9B,EAA8B;EAAA;;EAC5GD,IAAI,CAACE,OAAL,CAAcC,IAAD,IAAU;IACrB,IAAIA,IAAI,CAACC,QAAL,IAAiBC,KAAK,CAACC,OAAN,CAAcH,IAAI,CAACC,QAAnB,CAArB,EAAmD;MACjDH,OAAO,gBAAQA,OAAR,EAAoBF,WAAW,CAACI,IAAI,CAACC,QAAL,IAAiB,EAAlB,CAA/B,CAAP;IACD,CAFD,MAEO,IAAID,IAAI,CAACI,UAAL,IAAmBJ,IAAI,CAACK,SAAxB,IAAqCL,IAAI,CAACM,OAA9C,EAAuD;MAC5DR,OAAO,CAACE,IAAI,CAACK,SAAL,CAAeE,iBAAf,EAAD,CAAP,GAA8CP,IAA9C;IACD;EACF,CAND;EAOA,OAAOF,OAAP;AACD;;AAED,eAAe,SAASU,eAAT,CACbC,CADa,EAEbC,QAFa,EAGbC,mBAHa,EAIbC,QAJa,EAKbC,KALa,EAMb;EAAA,IAJAH,QAIA;IAJAA,QAIA,GAJuB,EAIvB;EA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AC,GAAG,CAAC,CAACC,KAAK,CAAEC,CAAC,IAAK;MAC3C,IAAI,SAAS,CAACX,IAAI,CAACW,CAAC,CAAC,EAAE;QACrB,OAAO1B,SAAS,CAAC2B,QAAQ,CAAC,MAAM,CAAC,IAAI3B,SAAS,CAAC2B,QAAQ,CAAC,KAAK,CAAC;MAChE;MACA,OAAO3B,SAAS,CAAC2B,QAAQ,CAACD,CAAC,CAAC;IAC9B,CAAC,CAAC;IACF,IAAIH,OAAO,EAAE;MACXJ,OAAO,GAAG3B,IAAI,CAACG,IAAI,CAAC;IACtB;EACF,CAAC,CAAC;EACF,IAAIwB,OAAO,IAAIb,mBAAmB,EAAE;IAClCF,CAAC,CAACwB,eAAe,EAAE;IACnBxB,CAAC,CAACyB,cAAc,EAAE;IAClBvB,mBAAmB,CAACwB,cAAc,CAACX,OAAO,EAAEZ,QAAQ,EAAEC,KAAK,EAAER,SAAS,CAAC;IACvE;EACF;AACF"
52
52
  }
@@ -22,7 +22,8 @@ export default function Child(props) {
22
22
  }, props, {
23
23
  isChild: true
24
24
  })) : children
25
- }), // eslint-disable-next-line react-hooks/exhaustive-deps
25
+ }),
26
+ // eslint-disable-next-line react-hooks/exhaustive-deps
26
27
  [commands, barPopup, groupName, prefixCls]);
27
28
  }
28
29
  //# sourceMappingURL=Child.js.map
@@ -24,5 +24,5 @@
24
24
  "sourcesContent": [
25
25
  "import React, { useContext, useMemo } from 'react';\nimport './Child.less';\nimport Toolbar, { IToolbarProps } from './';\nimport { EditorContext } from '../../Context';\n\nexport type ChildProps = IToolbarProps & {\n children?: JSX.Element;\n groupName?: string;\n};\n\nexport default function Child(props: ChildProps) {\n const { prefixCls, groupName, commands, children } = props || {};\n const { barPopup = {} } = useContext(EditorContext);\n return useMemo(\n () => (\n <div\n className={`${prefixCls}-toolbar-child ${groupName && barPopup[groupName] ? 'active' : ''}`}\n onClick={(e) => e.stopPropagation()}\n >\n {Array.isArray(commands) ? <Toolbar commands={commands} {...props} isChild /> : children}\n </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,GAAGV,UAAU,CAACG,aAAa,CAAC;EACnD,OAAOF,OAAO,CACZ,mBACE;IACE,SAAS,EAAKK,SAAS,wBAAkBC,SAAS,IAAIG,QAAQ,CAACH,SAAS,CAAC,GAAG,QAAQ,GAAG,EAAE,CAAG;IAC5F,OAAO,EAAGI,CAAC,IAAKA,CAAC,CAACC,eAAe,EAAG;IAAA,UAEnCC,KAAK,CAACC,OAAO,CAACN,QAAQ,CAAC,gBAAG,KAAC,OAAO;MAAC,QAAQ,EAAEA;IAAS,GAAKH,KAAK;MAAE,OAAO;IAAA,GAAG,GAAGI;EAAQ,EAE3F;EACD;EACA,CAACD,QAAQ,EAAEE,QAAQ,EAAEH,SAAS,EAAED,SAAS,CAAC,CAC3C;AACH"
28
28
  }
@@ -19,21 +19,17 @@ export function ToolbarItems(props) {
19
19
  dispatch
20
20
  } = useContext(EditorContext);
21
21
  var originalOverflow = useRef('');
22
-
23
22
  function handleClick(command, name) {
24
23
  if (!dispatch) return;
25
24
  var state = {
26
25
  barPopup: _extends({}, barPopup)
27
26
  };
28
-
29
27
  if (command.keyCommand === 'preview') {
30
28
  state.preview = command.value;
31
29
  }
32
-
33
30
  if (command.keyCommand === 'fullscreen') {
34
31
  state.fullscreen = !fullscreen;
35
32
  }
36
-
37
33
  if (props.commands && command.keyCommand === 'group') {
38
34
  props.commands.forEach(item => {
39
35
  if (name === item.groupName) {
@@ -47,14 +43,11 @@ export function ToolbarItems(props) {
47
43
  state.barPopup[keyName] = false;
48
44
  });
49
45
  }
50
-
51
46
  if (Object.keys(state).length) {
52
47
  dispatch(_extends({}, state));
53
48
  }
54
-
55
49
  commandOrchestrator && commandOrchestrator.executeCommand(command);
56
50
  }
57
-
58
51
  useEffect(() => {
59
52
  if (document && overflow) {
60
53
  if (fullscreen) {
@@ -64,9 +57,8 @@ export function ToolbarItems(props) {
64
57
  // get the original overflow only the first time
65
58
  if (!originalOverflow.current) {
66
59
  originalOverflow.current = window.getComputedStyle(document.body, null).overflow;
67
- } // reset to the original overflow
68
-
69
-
60
+ }
61
+ // reset to the original overflow
70
62
  document.body.style.overflow = originalOverflow.current;
71
63
  }
72
64
  }
@@ -78,7 +70,6 @@ export function ToolbarItems(props) {
78
70
  className: prefixCls + "-toolbar-divider"
79
71
  }), idx);
80
72
  }
81
-
82
73
  if (!item.keyCommand) return /*#__PURE__*/_jsx(Fragment, {}, idx);
83
74
  var activeBtn = fullscreen && item.keyCommand === 'fullscreen' || item.keyCommand === 'preview' && preview === item.value;
84
75
  var childNode = item.children && typeof item.children === 'function' ? item.children({
@@ -119,7 +110,6 @@ export default function Toolbar(props) {
119
110
  if (props === void 0) {
120
111
  props = {};
121
112
  }
122
-
123
113
  var {
124
114
  prefixCls,
125
115
  toolbarBottom,
@@ -80,5 +80,5 @@
80
80
  "sourcesContent": [
81
81
  "import React, { Fragment, useContext, useEffect, useRef } from 'react';\nimport { IProps } from '../../Editor';\nimport { EditorContext, PreviewType, ContextStore } from '../../Context';\nimport { ICommand } from '../../commands';\nimport Child from './Child';\nimport './index.less';\n\nexport interface IToolbarProps extends IProps {\n overflow?: boolean;\n toolbarBottom?: boolean;\n onCommand?: (command: ICommand<string>, groupName?: string) => void;\n commands?: ICommand<string>[];\n isChild?: boolean;\n}\n\nexport function ToolbarItems(props: IToolbarProps) {\n const { prefixCls, overflow } = props;\n const { fullscreen, preview, barPopup = {}, components, commandOrchestrator, dispatch } = useContext(EditorContext);\n const originalOverflow = useRef('');\n\n function handleClick(command: ICommand<string>, name?: string) {\n if (!dispatch) return;\n const state: ContextStore = { barPopup: { ...barPopup } };\n if (command.keyCommand === 'preview') {\n state.preview = command.value as PreviewType;\n }\n if (command.keyCommand === 'fullscreen') {\n state.fullscreen = !fullscreen;\n }\n if (props.commands && command.keyCommand === 'group') {\n props.commands.forEach((item) => {\n if (name === item.groupName) {\n state.barPopup![name!] = true;\n } else if (item.keyCommand) {\n state.barPopup![item.groupName!] = false;\n }\n });\n } else if (name || command.parent) {\n Object.keys(state.barPopup || {}).forEach((keyName) => {\n state.barPopup![keyName] = false;\n });\n }\n\n if (Object.keys(state).length) {\n dispatch({ ...state });\n }\n commandOrchestrator && commandOrchestrator.executeCommand(command);\n }\n\n useEffect(() => {\n if (document && overflow) {\n if (fullscreen) {\n // prevent scroll on fullscreen\n document.body.style.overflow = 'hidden';\n } else {\n // get the original overflow only the first time\n if (!originalOverflow.current) {\n originalOverflow.current = window.getComputedStyle(document.body, null).overflow;\n }\n // reset to the original overflow\n document.body.style.overflow = originalOverflow.current;\n }\n }\n }, [fullscreen, originalOverflow, overflow]);\n\n return (\n <ul>\n {(props.commands || []).map((item, idx) => {\n if (item.keyCommand === 'divider') {\n return <li key={idx} {...item.liProps} className={`${prefixCls}-toolbar-divider`} />;\n }\n if (!item.keyCommand) return <Fragment key={idx} />;\n const activeBtn =\n (fullscreen && item.keyCommand === 'fullscreen') || (item.keyCommand === 'preview' && preview === item.value);\n const childNode =\n item.children && typeof item.children === 'function'\n ? item.children({\n getState: () => commandOrchestrator!.getState(),\n textApi: commandOrchestrator ? commandOrchestrator!.textApi : undefined,\n close: () => handleClick({}, item.groupName),\n execute: () => handleClick({ execute: item.execute }),\n })\n : undefined;\n const disabled = barPopup && preview && preview === 'preview' && !/(preview|fullscreen)/.test(item.keyCommand);\n const render = components?.toolbar || item.render;\n const com = (\n render && typeof render === 'function' ? render(item, !!disabled, handleClick, idx) : null\n ) as React.ReactElement;\n return (\n <li key={idx} {...item.liProps} className={activeBtn ? `active` : ''}>\n {com && React.isValidElement(com) && com}\n {!com && !item.buttonProps && item.icon}\n {!com &&\n item.buttonProps &&\n React.createElement(\n 'button',\n {\n type: 'button',\n key: idx,\n disabled,\n 'data-name': item.name,\n ...item.buttonProps,\n onClick: (evn: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n evn.stopPropagation();\n handleClick(item, item.groupName);\n },\n },\n item.icon,\n )}\n {item.children && (\n <Child\n overflow={overflow}\n groupName={item.groupName}\n prefixCls={prefixCls}\n children={childNode}\n commands={Array.isArray(item.children) ? item.children : undefined}\n />\n )}\n </li>\n );\n })}\n </ul>\n );\n}\n\nexport default function Toolbar(props: IToolbarProps = {}) {\n const { prefixCls, toolbarBottom, isChild } = props;\n const { commands, extraCommands } = useContext(EditorContext);\n const bottomClassName = toolbarBottom ? 'bottom' : '';\n return (\n <div className={`${prefixCls}-toolbar ${bottomClassName}`}>\n <ToolbarItems {...props} commands={props.commands || commands || []} />\n {!isChild && <ToolbarItems {...props} commands={extraCommands || []} />}\n </div>\n );\n}\n"
82
82
  ],
83
- "mappings": ";AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,UAA1B,EAAsCC,SAAtC,EAAiDC,MAAjD,QAA+D,OAA/D;AAEA,SAASC,aAAT,QAAyD,eAAzD;AAEA,OAAOC,KAAP,MAAkB,SAAlB;AACA;;;AAUA,OAAO,SAASC,YAAT,CAAsBC,KAAtB,EAA4C;EACjD,IAAM;IAAEC,SAAF;IAAaC;EAAb,IAA0BF,KAAhC;EACA,IAAM;IAAEG,UAAF;IAAcC,OAAd;IAAuBC,QAAQ,GAAG,EAAlC;IAAsCC,UAAtC;IAAkDC,mBAAlD;IAAuEC;EAAvE,IAAoFd,UAAU,CAACG,aAAD,CAApG;EACA,IAAMY,gBAAgB,GAAGb,MAAM,CAAC,EAAD,CAA/B;;EAEA,SAASc,WAAT,CAAqBC,OAArB,EAAgDC,IAAhD,EAA+D;IAC7D,IAAI,CAACJ,QAAL,EAAe;IACf,IAAMK,KAAmB,GAAG;MAAER,QAAQ,eAAOA,QAAP;IAAV,CAA5B;;IACA,IAAIM,OAAO,CAACG,UAAR,KAAuB,SAA3B,EAAsC;MACpCD,KAAK,CAACT,OAAN,GAAgBO,OAAO,CAACI,KAAxB;IACD;;IACD,IAAIJ,OAAO,CAACG,UAAR,KAAuB,YAA3B,EAAyC;MACvCD,KAAK,CAACV,UAAN,GAAmB,CAACA,UAApB;IACD;;IACD,IAAIH,KAAK,CAACgB,QAAN,IAAkBL,OAAO,CA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AQ,EAAEqB,KAAK,CAACC,OAAO,CAACxC,IAAI,CAACmB,QAAQ,CAAC,GAAGnB,IAAI,CAACmB,QAAQ,GAAGG;QAAU,EAEtE;MAAA,IA5BMP,GAAG,CA6BP;IAET,CAAC;EAAC,EACC;AAET;AAEA,eAAe,SAAS0B,OAAO,CAAC3D,KAAoB,EAAO;EAAA,IAA3BA,KAAoB;IAApBA,KAAoB,GAAG,CAAC,CAAC;EAAA;EACvD,IAAM;IAAEC,SAAS;IAAE2D,aAAa;IAAEC;EAAQ,CAAC,GAAG7D,KAAK;EACnD,IAAM;IAAEgB,QAAQ;IAAE8C;EAAc,CAAC,GAAGpE,UAAU,CAACG,aAAa,CAAC;EAC7D,IAAMkE,eAAe,GAAGH,aAAa,GAAG,QAAQ,GAAG,EAAE;EACrD,oBACE;IAAK,SAAS,EAAK3D,SAAS,iBAAY8D,eAAkB;IAAA,wBACxD,KAAC,YAAY,eAAK/D,KAAK;MAAE,QAAQ,EAAEA,KAAK,CAACgB,QAAQ,IAAIA,QAAQ,IAAI;IAAG,GAAG,EACtE,CAAC6C,OAAO,iBAAI,KAAC,YAAY,eAAK7D,KAAK;MAAE,QAAQ,EAAE8D,aAAa,IAAI;IAAG,GAAG;EAAA,EACnE;AAEV"
84
84
  }
package/esm/index.js.map CHANGED
@@ -11,5 +11,5 @@
11
11
  "sourcesContent": [
12
12
  "import MDEditor from './Editor';\nimport * as commands from './commands';\nimport * as MarkdownUtil from './utils/markdownUtils';\n\nexport * from './commands';\nexport * from './utils/markdownUtils';\nexport * from './Editor';\nexport * from './Context';\n\nexport { MarkdownUtil, commands };\n\nexport default MDEditor;\n"
13
13
  ],
14
- "mappings": "AAAA,OAAOA,QAAP,MAAqB,UAArB;AACA,OAAO,KAAKC,QAAZ,MAA0B,YAA1B;AACA,OAAO,KAAKC,YAAZ,MAA8B,uBAA9B;AAEA,cAAc,YAAd;AACA,cAAc,uBAAd;AACA,cAAc,UAAd;AACA,cAAc,WAAd;AAEA,SAASA,YAAT,EAAuBD,QAAvB;AAEA,eAAeD,QAAf"
14
+ "mappings": "AAAA,OAAOA,QAAQ,MAAM,UAAU;AAC/B,OAAO,KAAKC,QAAQ,MAAM,YAAY;AACtC,OAAO,KAAKC,YAAY,MAAM,uBAAuB;AAErD,cAAc,YAAY;AAC1B,cAAc,uBAAuB;AACrC,cAAc,UAAU;AACxB,cAAc,WAAW;AAEzB,SAASA,YAAY,EAAED,QAAQ;AAE/B,eAAeD,QAAQ"
15
15
  }
@@ -3,90 +3,84 @@
3
3
  * Copyright (c) 2018 Dmitriy Kubyshkin
4
4
  * Copied from https://github.com/grassator/insert-text-at-cursor
5
5
  */
6
+
6
7
  var browserSupportsTextareaTextNodes;
8
+
7
9
  /**
8
10
  * @param {HTMLElement} input
9
11
  * @return {boolean}
10
12
  */
11
-
12
13
  function canManipulateViaTextNodes(input) {
13
14
  if (input.nodeName !== 'TEXTAREA') {
14
15
  return false;
15
16
  }
16
-
17
17
  if (typeof browserSupportsTextareaTextNodes === 'undefined') {
18
18
  var textarea = document.createElement('textarea');
19
19
  textarea.value = '1';
20
20
  browserSupportsTextareaTextNodes = !!textarea.firstChild;
21
21
  }
22
-
23
22
  return browserSupportsTextareaTextNodes;
24
23
  }
24
+
25
25
  /**
26
26
  * @param {string} val
27
27
  * @param {number} cursorIdx
28
28
  * @param {HTMLTextAreaElement|HTMLInputElement} input
29
29
  * @return {void}
30
30
  */
31
-
32
-
33
31
  export var insertAtLineStart = (val, cursorIdx, input) => {
34
32
  var content = input.value;
35
33
  var startIdx = 0;
36
-
37
34
  while (cursorIdx--) {
38
35
  var char = content[cursorIdx];
39
-
40
36
  if (char === '\n') {
41
37
  startIdx = cursorIdx + 1;
42
38
  break;
43
39
  }
44
40
  }
45
-
46
41
  input.focus();
47
42
  input.setRangeText(val, startIdx, startIdx);
48
43
  input.dispatchEvent(new Event('input', {
49
44
  bubbles: true
50
45
  }));
51
46
  };
47
+
52
48
  /**
53
49
  * @param {HTMLTextAreaElement|HTMLInputElement} input
54
50
  * @param {string} text
55
51
  * @returns {void}
56
52
  */
57
-
58
53
  export function insertTextAtPosition(input, text) {
59
54
  // Most of the used APIs only work with the field selected
60
- input.focus(); // IE 8-10
55
+ input.focus();
61
56
 
57
+ // IE 8-10
62
58
  if (document.selection) {
63
59
  var ieRange = document.selection.createRange();
64
- ieRange.text = text; // Move cursor after the inserted text
60
+ ieRange.text = text;
65
61
 
66
- ieRange.collapse(false
67
- /* to the end */
68
- );
62
+ // Move cursor after the inserted text
63
+ ieRange.collapse(false /* to the end */);
69
64
  ieRange.select();
70
65
  return;
71
- } // Webkit + Edge
72
-
66
+ }
73
67
 
68
+ // Webkit + Edge
74
69
  var isSuccess = document.execCommand && document.execCommand('insertText', false, text);
75
-
76
70
  if (!isSuccess) {
77
71
  var start = input.selectionStart;
78
- var end = input.selectionEnd; // Firefox (non-standard method)
79
-
72
+ var end = input.selectionEnd;
73
+ // Firefox (non-standard method)
80
74
  if (typeof input.setRangeText === 'function') {
81
75
  input.setRangeText(text);
82
76
  } else {
83
77
  // To make a change we just need a Range, not a Selection
84
78
  var range = document.createRange();
85
79
  var textNode = document.createTextNode(text);
86
-
87
80
  if (canManipulateViaTextNodes(input)) {
88
- var node = input.firstChild; // If textarea is empty, just insert the text
81
+ var node = input.firstChild;
89
82
 
83
+ // If textarea is empty, just insert the text
90
84
  if (!node) {
91
85
  input.appendChild(textNode);
92
86
  } else {
@@ -94,35 +88,34 @@ export function insertTextAtPosition(input, text) {
94
88
  var offset = 0;
95
89
  var startNode = null;
96
90
  var endNode = null;
97
-
98
91
  while (node && (startNode === null || endNode === null)) {
99
- var nodeLength = node.nodeValue.length; // if start of the selection falls into current node
92
+ var nodeLength = node.nodeValue.length;
100
93
 
94
+ // if start of the selection falls into current node
101
95
  if (start >= offset && start <= offset + nodeLength) {
102
96
  range.setStart(startNode = node, start - offset);
103
- } // if end of the selection falls into current node
104
-
97
+ }
105
98
 
99
+ // if end of the selection falls into current node
106
100
  if (end >= offset && end <= offset + nodeLength) {
107
101
  range.setEnd(endNode = node, end - offset);
108
102
  }
109
-
110
103
  offset += nodeLength;
111
104
  node = node.nextSibling;
112
- } // If there is some text selected, remove it as we should replace it
113
-
105
+ }
114
106
 
107
+ // If there is some text selected, remove it as we should replace it
115
108
  if (start !== end) {
116
109
  range.deleteContents();
117
110
  }
118
111
  }
119
- } // If the node is a textarea and the range doesn't span outside the element
112
+ }
113
+
114
+ // If the node is a textarea and the range doesn't span outside the element
120
115
  //
121
116
  // Get the commonAncestorContainer of the selected range and test its type
122
117
  // If the node is of type `#text` it means that we're still working with text nodes within our textarea element
123
118
  // otherwise, if it's of type `#document` for example it means our selection spans outside the textarea.
124
-
125
-
126
119
  if (canManipulateViaTextNodes(input) && range.commonAncestorContainer.nodeName === '#text') {
127
120
  // Finally insert a new node. The browser will automatically split start and end nodes into two if necessary
128
121
  range.insertNode(textNode);
@@ -131,11 +124,12 @@ export function insertTextAtPosition(input, text) {
131
124
  var value = input.value;
132
125
  input.value = value.slice(0, start) + text + value.slice(end);
133
126
  }
134
- } // Correct the cursor position to be at the end of the insertion
135
-
127
+ }
136
128
 
137
- input.setSelectionRange(start + text.length, start + text.length); // Notify any possible listeners of the change
129
+ // Correct the cursor position to be at the end of the insertion
130
+ input.setSelectionRange(start + text.length, start + text.length);
138
131
 
132
+ // Notify any possible listeners of the change
139
133
  var e = document.createEvent('UIEvent');
140
134
  e.initEvent('input', true, false);
141
135
  input.dispatchEvent(e);
@@ -63,5 +63,5 @@
63
63
  "sourcesContent": [
64
64
  "/**\n * The MIT License\n * Copyright (c) 2018 Dmitriy Kubyshkin\n * Copied from https://github.com/grassator/insert-text-at-cursor\n */\n\nlet browserSupportsTextareaTextNodes: any;\n\n/**\n * @param {HTMLElement} input\n * @return {boolean}\n */\nfunction canManipulateViaTextNodes(input: HTMLTextAreaElement | HTMLInputElement): boolean {\n if (input.nodeName !== 'TEXTAREA') {\n return false;\n }\n if (typeof browserSupportsTextareaTextNodes === 'undefined') {\n const textarea: HTMLTextAreaElement = document.createElement('textarea');\n textarea.value = '1';\n browserSupportsTextareaTextNodes = !!textarea.firstChild;\n }\n return browserSupportsTextareaTextNodes;\n}\n\n/**\n * @param {string} val\n * @param {number} cursorIdx\n * @param {HTMLTextAreaElement|HTMLInputElement} input\n * @return {void}\n */\nexport const insertAtLineStart = (\n val: string,\n cursorIdx: number,\n input: HTMLTextAreaElement | HTMLInputElement,\n): void => {\n const content = input.value;\n let startIdx = 0;\n\n while (cursorIdx--) {\n let char = content[cursorIdx];\n if (char === '\\n') {\n startIdx = cursorIdx + 1;\n break;\n }\n }\n\n input.focus();\n input.setRangeText(val, startIdx, startIdx);\n input.dispatchEvent(new Event('input', { bubbles: true }));\n};\n\n/**\n * @param {HTMLTextAreaElement|HTMLInputElement} input\n * @param {string} text\n * @returns {void}\n */\nexport function insertTextAtPosition(input: HTMLTextAreaElement | HTMLInputElement, text: string): void {\n // Most of the used APIs only work with the field selected\n input.focus();\n\n // IE 8-10\n if ((document as any).selection) {\n const ieRange = (document as any).selection.createRange();\n ieRange.text = text;\n\n // Move cursor after the inserted text\n ieRange.collapse(false /* to the end */);\n ieRange.select();\n\n return;\n }\n\n // Webkit + Edge\n const isSuccess = document.execCommand && document.execCommand('insertText', false, text);\n if (!isSuccess) {\n const start = input.selectionStart!;\n const end = input.selectionEnd!;\n // Firefox (non-standard method)\n if (typeof input.setRangeText === 'function') {\n input.setRangeText(text);\n } else {\n // To make a change we just need a Range, not a Selection\n const range = document.createRange();\n const textNode = document.createTextNode(text);\n\n if (canManipulateViaTextNodes(input)) {\n let node = input.firstChild;\n\n // If textarea is empty, just insert the text\n if (!node) {\n input.appendChild(textNode);\n } else {\n // Otherwise we need to find a nodes for start and end\n let offset = 0;\n let startNode = null;\n let endNode = null;\n\n while (node && (startNode === null || endNode === null)) {\n const nodeLength = node.nodeValue!.length;\n\n // if start of the selection falls into current node\n if (start >= offset && start <= offset + nodeLength) {\n range.setStart((startNode = node), start - offset);\n }\n\n // if end of the selection falls into current node\n if (end >= offset && end <= offset + nodeLength) {\n range.setEnd((endNode = node), end - offset);\n }\n\n offset += nodeLength;\n node = node.nextSibling;\n }\n\n // If there is some text selected, remove it as we should replace it\n if (start !== end) {\n range.deleteContents();\n }\n }\n }\n\n // If the node is a textarea and the range doesn't span outside the element\n //\n // Get the commonAncestorContainer of the selected range and test its type\n // If the node is of type `#text` it means that we're still working with text nodes within our textarea element\n // otherwise, if it's of type `#document` for example it means our selection spans outside the textarea.\n if (canManipulateViaTextNodes(input) && range.commonAncestorContainer.nodeName === '#text') {\n // Finally insert a new node. The browser will automatically split start and end nodes into two if necessary\n range.insertNode(textNode);\n } else {\n // If the node is not a textarea or the range spans outside a textarea the only way is to replace the whole value\n const value = input.value;\n input.value = value.slice(0, start) + text + value.slice(end);\n }\n }\n\n // Correct the cursor position to be at the end of the insertion\n input.setSelectionRange(start + text.length, start + text.length);\n\n // Notify any possible listeners of the change\n const e = document.createEvent('UIEvent');\n e.initEvent('input', true, false);\n input.dispatchEvent(e);\n }\n}\n"
65
65
  ],
66
- "mappings": "AAAA;AACA;AACA;AACA;AACA;AAEA,IAAIA,gCAAJ;AAEA;AACA;AACA;AACA;;AACA,SAASC,yBAAT,CAAmCC,KAAnC,EAA2F;EACzF,IAAIA,KAAK,CAACC,QAAN,KAAmB,UAAvB,EAAmC;IACjC,OAAO,KAAP;EACD;;EACD,IAAI,OAAOH,gCAAP,KAA4C,WAAhD,EAA6D;IAC3D,IAAMI,QAA6B,GAAGC,QAAQ,CAACC,aAAT,CAAuB,UAAvB,CAAtC;IACAF,QAAQ,CAACG,KAAT,GAAiB,GAAjB;IACAP,gCAAgC,GAAG,CAAC,CAACI,QAAQ,CAACI,UAA9C;EACD;;EACD,OAAOR,gCAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,IAAMS,iBAAiB,GAAG,CAC/BC,GAD+B,EAE/BC,SAF+B,EAG/BT,KAH+B,KAItB;EACT,IAAMU,OAAO,GAAGV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B,KAAK,GAAGL,KAAK,CAACK,KAAK;QACzBL,KAAK,CAACK,KAAK,GAAGA,KAAK,CAAC2C,KAAK,CAAC,CAAC,EAAErB,KAAK,CAAC,GAAGR,IAAI,GAAGd,KAAK,CAAC2C,KAAK,CAACnB,GAAG,CAAC;MAC/D;IACF;;IAEA;IACA7B,KAAK,CAACiD,iBAAiB,CAACtB,KAAK,GAAGR,IAAI,CAACsB,MAAM,EAAEd,KAAK,GAAGR,IAAI,CAACsB,MAAM,CAAC;;IAEjE;IACA,IAAMS,CAAC,GAAG/C,QAAQ,CAACgD,WAAW,CAAC,SAAS,CAAC;IACzCD,CAAC,CAACE,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC;IACjCpD,KAAK,CAACe,aAAa,CAACmC,CAAC,CAAC;EACxB;AACF"
67
67
  }
@@ -3,113 +3,104 @@ export function selectWord(_ref) {
3
3
  text,
4
4
  selection
5
5
  } = _ref;
6
-
7
6
  if (text && text.length && selection.start === selection.end) {
8
7
  // the user is pointing to a word
9
8
  return getSurroundingWord(text, selection.start);
10
9
  }
11
-
12
10
  return selection;
13
11
  }
12
+
14
13
  /**
15
14
  * Gets the number of line-breaks that would have to be inserted before the given 'startPosition'
16
15
  * to make sure there's an empty line between 'startPosition' and the previous text
17
16
  */
18
-
19
17
  export function getBreaksNeededForEmptyLineBefore(text, startPosition) {
20
18
  if (text === void 0) {
21
19
  text = '';
22
20
  }
21
+ if (startPosition === 0) return 0;
23
22
 
24
- if (startPosition === 0) return 0; // rules:
23
+ // rules:
25
24
  // - If we're in the first line, no breaks are needed
26
25
  // - Otherwise there must be 2 breaks before the previous character. Depending on how many breaks exist already, we
27
26
  // may need to insert 0, 1 or 2 breaks
28
27
 
29
28
  var neededBreaks = 2;
30
29
  var isInFirstLine = true;
31
-
32
30
  for (var i = startPosition - 1; i >= 0 && neededBreaks >= 0; i--) {
33
31
  switch (text.charCodeAt(i)) {
34
32
  case 32:
35
33
  // blank space
36
34
  continue;
37
-
38
35
  case 10:
39
36
  // line break
40
37
  neededBreaks--;
41
38
  isInFirstLine = false;
42
39
  break;
43
-
44
40
  default:
45
41
  return neededBreaks;
46
42
  }
47
43
  }
48
-
49
44
  return isInFirstLine ? 0 : neededBreaks;
50
45
  }
46
+
51
47
  /**
52
48
  * Gets the number of line-breaks that would have to be inserted after the given 'startPosition'
53
49
  * to make sure there's an empty line between 'startPosition' and the next text
54
50
  */
55
-
56
51
  export function getBreaksNeededForEmptyLineAfter(text, startPosition) {
57
52
  if (text === void 0) {
58
53
  text = '';
59
54
  }
55
+ if (startPosition === text.length - 1) return 0;
60
56
 
61
- if (startPosition === text.length - 1) return 0; // rules:
57
+ // rules:
62
58
  // - If we're in the first line, no breaks are needed
63
59
  // - Otherwise there must be 2 breaks before the previous character. Depending on how many breaks exist already, we
64
60
  // may need to insert 0, 1 or 2 breaks
65
61
 
66
62
  var neededBreaks = 2;
67
63
  var isInLastLine = true;
68
-
69
64
  for (var i = startPosition; i < text.length && neededBreaks >= 0; i++) {
70
65
  switch (text.charCodeAt(i)) {
71
66
  case 32:
72
67
  continue;
73
-
74
68
  case 10:
75
69
  {
76
70
  neededBreaks--;
77
71
  isInLastLine = false;
78
72
  break;
79
73
  }
80
-
81
74
  default:
82
75
  return neededBreaks;
83
76
  }
84
77
  }
85
-
86
78
  return isInLastLine ? 0 : neededBreaks;
87
79
  }
88
80
  export function getSurroundingWord(text, position) {
89
81
  if (!text) throw Error("Argument 'text' should be truthy");
82
+ var isWordDelimiter = c => c === ' ' || c.charCodeAt(0) === 10;
90
83
 
91
- var isWordDelimiter = c => c === ' ' || c.charCodeAt(0) === 10; // leftIndex is initialized to 0 because if selection is 0, it won't even enter the iteration
92
-
93
-
94
- var start = 0; // rightIndex is initialized to text.length because if selection is equal to text.length it won't even enter the interation
95
-
96
- var end = text.length; // iterate to the left
84
+ // leftIndex is initialized to 0 because if selection is 0, it won't even enter the iteration
85
+ var start = 0;
86
+ // rightIndex is initialized to text.length because if selection is equal to text.length it won't even enter the interation
87
+ var end = text.length;
97
88
 
89
+ // iterate to the left
98
90
  for (var i = position; i - 1 > -1; i--) {
99
91
  if (isWordDelimiter(text[i - 1])) {
100
92
  start = i;
101
93
  break;
102
94
  }
103
- } // iterate to the right
104
-
95
+ }
105
96
 
97
+ // iterate to the right
106
98
  for (var _i = position; _i < text.length; _i++) {
107
99
  if (isWordDelimiter(text[_i])) {
108
100
  end = _i;
109
101
  break;
110
102
  }
111
103
  }
112
-
113
104
  return {
114
105
  start,
115
106
  end
@@ -27,5 +27,5 @@
27
27
  "sourcesContent": [
28
28
  "import { TextRange } from '../commands';\n\nexport interface TextSection {\n text: string;\n selection: TextRange;\n}\n\nexport function selectWord({ text, selection }: TextSection): TextRange {\n if (text && text.length && selection.start === selection.end) {\n // the user is pointing to a word\n return getSurroundingWord(text, selection.start);\n }\n return selection;\n}\n\n/**\n * Gets the number of line-breaks that would have to be inserted before the given 'startPosition'\n * to make sure there's an empty line between 'startPosition' and the previous text\n */\nexport function getBreaksNeededForEmptyLineBefore(text = '', startPosition: number): number {\n if (startPosition === 0) return 0;\n\n // rules:\n // - If we're in the first line, no breaks are needed\n // - Otherwise there must be 2 breaks before the previous character. Depending on how many breaks exist already, we\n // may need to insert 0, 1 or 2 breaks\n\n let neededBreaks = 2;\n let isInFirstLine = true;\n for (let i = startPosition - 1; i >= 0 && neededBreaks >= 0; i--) {\n switch (text.charCodeAt(i)) {\n case 32: // blank space\n continue;\n case 10: // line break\n neededBreaks--;\n isInFirstLine = false;\n break;\n default:\n return neededBreaks;\n }\n }\n return isInFirstLine ? 0 : neededBreaks;\n}\n\n/**\n * Gets the number of line-breaks that would have to be inserted after the given 'startPosition'\n * to make sure there's an empty line between 'startPosition' and the next text\n */\nexport function getBreaksNeededForEmptyLineAfter(text = '', startPosition: number): number {\n if (startPosition === text.length - 1) return 0;\n\n // rules:\n // - If we're in the first line, no breaks are needed\n // - Otherwise there must be 2 breaks before the previous character. Depending on how many breaks exist already, we\n // may need to insert 0, 1 or 2 breaks\n\n let neededBreaks = 2;\n let isInLastLine = true;\n for (let i = startPosition; i < text.length && neededBreaks >= 0; i++) {\n switch (text.charCodeAt(i)) {\n case 32:\n continue;\n case 10: {\n neededBreaks--;\n isInLastLine = false;\n break;\n }\n default:\n return neededBreaks;\n }\n }\n return isInLastLine ? 0 : neededBreaks;\n}\n\nexport function getSurroundingWord(text: string, position: number): TextRange {\n if (!text) throw Error(\"Argument 'text' should be truthy\");\n\n const isWordDelimiter = (c: string) => c === ' ' || c.charCodeAt(0) === 10;\n\n // leftIndex is initialized to 0 because if selection is 0, it won't even enter the iteration\n let start = 0;\n // rightIndex is initialized to text.length because if selection is equal to text.length it won't even enter the interation\n let end = text.length;\n\n // iterate to the left\n for (let i = position; i - 1 > -1; i--) {\n if (isWordDelimiter(text[i - 1])) {\n start = i;\n break;\n }\n }\n\n // iterate to the right\n for (let i = position; i < text.length; i++) {\n if (isWordDelimiter(text[i])) {\n end = i;\n break;\n }\n }\n\n return { start, end };\n}\n"
29
29
  ],
30
- "mappings": "AAOA,OAAO,SAASA,UAAT,OAAiE;EAAA,IAA7C;IAAEC,IAAF;IAAQC;EAAR,CAA6C;;EACtE,IAAID,IAAI,IAAIA,IAAI,CAACE,MAAb,IAAuBD,SAAS,CAACE,KAAV,KAAoBF,SAAS,CAACG,GAAzD,EAA8D;IAC5D;IACA,OAAOC,kBAAkB,CAACL,IAAD,EAAOC,SAAS,CAACE,KAAjB,CAAzB;EACD;;EACD,OAAOF,SAAP;AACD;AAED;AACA;AACA;AACA;;AACA,OAAO,SAASK,iCAAT,CAA2CN,IAA3C,EAAsDO,aAAtD,EAAqF;EAAA,IAA1CP,IAA0C;IAA1CA,IAA0C,GAAnC,EAAmC;EAAA;;EAC1F,IAAIO,aAAa,KAAK,CAAtB,EAAyB,OAAO,CAAP,CADiE,CAG1F;EACA;EACA;EACA;;EAEA,IAAIC,YAAY,GAAG,CAAnB;EACA,IAAIC,aAAa,GAAG,IAApB;;EACA,KA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