@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
@@ -22,7 +22,7 @@
22
22
  "../../src/commands/fullscreen.tsx"
23
23
  ],
24
24
  "sourcesContent": [
25
- "import * as React from 'react';\nimport { ICommand, TextState, TextAreaTextApi } from './';\nimport { ContextStore, ExecuteCommandState } from '../Context';\n\nexport const fullscreen: ICommand = {\n name: 'fullscreen',\n keyCommand: 'fullscreen',\n shortcuts: 'ctrlcmd+0',\n value: 'fullscreen',\n buttonProps: { 'aria-label': 'Toggle fullscreen (ctrl + 0)', title: 'Toggle fullscreen (ctrl+ 0)' },\n icon: (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 520 520\">\n <path\n fill=\"currentColor\"\n d=\"M118 171.133334L118 342.200271C118 353.766938 126.675 365.333605 141.133333 365.333605L382.634614 365.333605C394.201281 365.333605 405.767948 356.658605 405.767948 342.200271L405.767948 171.133334C405.767948 159.566667 397.092948 148 382.634614 148L141.133333 148C126.674999 148 117.999999 156.675 118 171.133334zM465.353591 413.444444L370 413.444444 370 471.222222 474.0221 471.222222C500.027624 471.222222 520.254143 451 520.254143 425L520.254143 321 462.464089 321 462.464089 413.444444 465.353591 413.444444zM471.0221 43L367 43 367 100.777778 462.353591 100.777778 462.353591 196.111111 520.143647 196.111111 520.143647 89.2222219C517.254144 63.2222219 497.027624 43 471.0221 43zM57.7900547 100.777778L153.143646 100.777778 153.143646 43 46.2320439 43C20.2265191 43 0 63.2222219 0 89.2222219L0 193.222222 57.7900547 193.222222 57.7900547 100.777778zM57.7900547 321L0 321 0 425C0 451 20.2265191 471.222222 46.2320439 471.222223L150.254143 471.222223 150.254143 413.444445 57.7900547 413.444445 57.7900547 321z\"\n />\n </svg>\n ),\n execute: (\n state: TextState,\n api: TextAreaTextApi,\n dispatch?: React.Dispatch<ContextStore>,\n executeCommandState?: ExecuteCommandState,\n ) => {\n api.textArea.focus();\n if (dispatch && executeCommandState && executeCommandState.fullscreen) {\n dispatch({ fullscreen: false });\n }\n },\n};\n"
25
+ "import * as React from 'react';\nimport { ICommand, TextState, TextAreaTextApi } from './';\nimport { ContextStore, ExecuteCommandState } from '../Context';\n\nexport const fullscreen: ICommand = {\n name: 'fullscreen',\n keyCommand: 'fullscreen',\n shortcuts: 'ctrlcmd+0',\n value: 'fullscreen',\n buttonProps: { 'aria-label': 'Toggle fullscreen (ctrl + 0)', title: 'Toggle fullscreen (ctrl+ 0)' },\n icon: (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 520 520\">\n <path\n fill=\"currentColor\"\n d=\"M118 171.133334L118 342.200271C118 353.766938 126.675 365.333605 141.133333 365.333605L382.634614 365.333605C394.201281 365.333605 405.767948 356.658605 405.767948 342.200271L405.767948 171.133334C405.767948 159.566667 397.092948 148 382.634614 148L141.133333 148C126.674999 148 117.999999 156.675 118 171.133334zM465.353591 413.444444L370 413.444444 370 471.222222 474.0221 471.222222C500.027624 471.222222 520.254143 451 520.254143 425L520.254143 321 462.464089 321 462.464089 413.444444 465.353591 413.444444zM471.0221 43L367 43 367 100.777778 462.353591 100.777778 462.353591 196.111111 520.143647 196.111111 520.143647 89.2222219C517.254144 63.2222219 497.027624 43 471.0221 43zM57.7900547 100.777778L153.143646 100.777778 153.143646 43 46.2320439 43C20.2265191 43 0 63.2222219 0 89.2222219L0 193.222222 57.7900547 193.222222 57.7900547 100.777778zM57.7900547 321L0 321 0 425C0 451 20.2265191 471.222222 46.2320439 471.222223L150.254143 471.222223 150.254143 413.444445 57.7900547 413.444445 57.7900547 321z\"\n />\n </svg>\n ),\n execute: (\n state: TextState,\n api: TextAreaTextApi,\n dispatch?: React.Dispatch<ContextStore>,\n executeCommandState?: ExecuteCommandState,\n shortcuts?: string[],\n ) => {\n api.textArea.focus();\n if (shortcuts && dispatch && executeCommandState) {\n dispatch({ fullscreen: !executeCommandState.fullscreen });\n }\n },\n};\n"
26
26
  ],
27
- "mappings": "AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;;AAIA,OAAO,IAAMC,UAAoB,GAAG;EAClCC,IAAI,EAAE,YAD4B;EAElCC,UAAU,EAAE,YAFsB;EAGlCC,SAAS,EAAE,WAHuB;EAIlCC,KAAK,EAAE,YAJ2B;EAKlCC,WAAW,EAAE;IAAE,cAAc,8BAAhB;IAAgDC,KAAK,EAAE;EAAvD,CALqB;EAMlCC,IAAI,eACF;IAAK,KAAK,EAAC,IAAX;IAAgB,MAAM,EAAC,IAAvB;IAA4B,OAAO,EAAC,aAApC;IAAA,uBACE;MACE,IAAI,EAAC,cADP;MAEE,CAAC,EAAC;IAFJ;EADF,EAPgC;EAclCC,OAAO,EAAE,CACPC,KADO,EAEPC,GAFO,EAGPC,QAHO,EAIPC,mBAJO,KAKJ;IACHF,GAAG,CAACG,QAAJ,CAAaC,KAAb;;IACA,IAAIH,QAAQ,IAAIC,mBAAZ,IAAmCA,mBAAmB,CAACZ,UAA3D,EAAuE;MACrEW,QAAQ,CAAC;QAAEX,UAAU,EAAE;MAAd,CAAD,CAAR;IACD;EACF;AAxBiC,CAA7B"
27
+ "mappings": "AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAAC;AAI/B,OAAO,IAAMC,UAAoB,GAAG;EAClCC,IAAI,EAAE,YAAY;EAClBC,UAAU,EAAE,YAAY;EACxBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE,YAAY;EACnBC,WAAW,EAAE;IAAE,YAAY,EAAE,8BAA8B;IAAEC,KAAK,EAAE;EAA8B,CAAC;EACnGC,IAAI,eACF;IAAK,KAAK,EAAC,IAAI;IAAC,MAAM,EAAC,IAAI;IAAC,OAAO,EAAC,aAAa;IAAA,uBAC/C;MACE,IAAI,EAAC,cAAc;MACnB,CAAC,EAAC;IAAs/B;EACx/B,EAEL;EACDC,OAAO,EAAE,CACPC,KAAgB,EAChBC,GAAoB,EACpBC,QAAuC,EACvCC,mBAAyC,EACzCT,SAAoB,KACjB;IACHO,GAAG,CAACG,QAAQ,CAACC,KAAK,EAAE;IACpB,IAAIX,SAAS,IAAIQ,QAAQ,IAAIC,mBAAmB,EAAE;MAChDD,QAAQ,CAAC;QAAEX,UAAU,EAAE,CAACY,mBAAmB,CAACZ;MAAW,CAAC,CAAC;IAC3D;EACF;AACF,CAAC"
28
28
  }
@@ -1,3 +1,4 @@
1
+ import _objectDestructuringEmpty from "@babel/runtime/helpers/objectDestructuringEmpty";
1
2
  import _extends from "@babel/runtime/helpers/extends";
2
3
  import React from 'react';
3
4
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -17,16 +18,13 @@ export var group = (arr, options) => {
17
18
  }, options, {
18
19
  keyCommand: 'group'
19
20
  });
20
-
21
21
  if (Array.isArray(data.children)) {
22
22
  data.children = data.children.map(_ref => {
23
- var item = _extends({}, _ref);
24
-
23
+ var item = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
25
24
  item.parent = data;
26
25
  return _extends({}, item);
27
26
  });
28
27
  }
29
-
30
28
  return data;
31
29
  };
32
30
  //# sourceMappingURL=group.js.map
@@ -22,5 +22,5 @@
22
22
  "sourcesContent": [
23
23
  "import React from 'react';\nimport { ICommand, ICommandChildCommands, ICommandChildHandle } from './';\n\nexport type GroupOptions = Omit<ICommand<string>, 'children'> & {\n children?: ICommandChildHandle['children'];\n};\n\nexport const group = (arr: ICommandChildCommands['children'], options?: GroupOptions): ICommand<string> => {\n let data = {\n children: arr as any,\n icon: (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 520 520\">\n <path\n fill=\"currentColor\"\n d=\"M15.7083333,468 C7.03242448,468 0,462.030833 0,454.666667 L0,421.333333 C0,413.969167 7.03242448,408 15.7083333,408 L361.291667,408 C369.967576,408 377,413.969167 377,421.333333 L377,454.666667 C377,462.030833 369.967576,468 361.291667,468 L15.7083333,468 Z M21.6666667,366 C9.69989583,366 0,359.831861 0,352.222222 L0,317.777778 C0,310.168139 9.69989583,304 21.6666667,304 L498.333333,304 C510.300104,304 520,310.168139 520,317.777778 L520,352.222222 C520,359.831861 510.300104,366 498.333333,366 L21.6666667,366 Z M136.835938,64 L136.835937,126 L107.25,126 L107.25,251 L40.75,251 L40.75,126 L-5.68434189e-14,126 L-5.68434189e-14,64 L136.835938,64 Z M212,64 L212,251 L161.648438,251 L161.648438,64 L212,64 Z M378,64 L378,126 L343.25,126 L343.25,251 L281.75,251 L281.75,126 L238,126 L238,64 L378,64 Z M449.047619,189.550781 L520,189.550781 L520,251 L405,251 L405,64 L449.047619,64 L449.047619,189.550781 Z\"\n />\n </svg>\n ),\n execute: () => {},\n ...options,\n keyCommand: 'group',\n };\n if (Array.isArray(data.children)) {\n data.children = data.children.map(({ ...item }: ICommand) => {\n item.parent = data;\n return { ...item };\n });\n }\n return data;\n};\n"
24
24
  ],
25
- "mappings": ";AAAA,OAAOA,KAAP,MAAkB,OAAlB;;AAOA,OAAO,IAAMC,KAAK,GAAG,CAACC,GAAD,EAAyCC,OAAzC,KAAsF;EACzG,IAAIC,IAAI;IACNC,QAAQ,EAAEH,GADJ;IAENI,IAAI,eACF;MAAK,KAAK,EAAC,IAAX;MAAgB,MAAM,EAAC,IAAvB;MAA4B,OAAO,EAAC,aAApC;MAAA,uBACE;QACE,IAAI,EAAC,cADP;QAEE,CAAC,EAAC;MAFJ;IADF,EAHI;IAUNC,OAAO,EAAE,MAAM,CAAE;EAVX,GAWHJ,OAXG;IAYNK,UAAU,EAAE;EAZN,EAAR;;EAcA,IAAIC,KAAK,CAACC,OAAN,CAAcN,IAAI,CAACC,QAAnB,CAAJ,EAAkC;IAChCD,IAAI,CAACC,QAAL,GAAgBD,IAAI,CAACC,QAAL,CAAcM,GAAd,CAAkB,QAA2B;MAAA,IAArBC,IAAqB;;MAC3DA,IAAI,CAACC,MAAL,GAAcT,IAAd;MACA,oBAAYQ,IAAZ;IACD,CAHe,CAAhB;EAID;;EACD,OAAOR,IAAP;AACD,CAtBM"
25
+ "mappings": ";;AAAA,OAAOA,KAAK,MAAM,OAAO;AAAC;AAO1B,OAAO,IAAMC,KAAK,GAAG,CAACC,GAAsC,EAAEC,OAAsB,KAAuB;EACzG,IAAIC,IAAI;IACNC,QAAQ,EAAEH,GAAU;IACpBI,IAAI,eACF;MAAK,KAAK,EAAC,IAAI;MAAC,MAAM,EAAC,IAAI;MAAC,OAAO,EAAC,aAAa;MAAA,uBAC/C;QACE,IAAI,EAAC,cAAc;QACnB,CAAC,EAAC;MAA24B;IAC74B,EAEL;IACDC,OAAO,EAAE,MAAM,CAAC;EAAC,GACdJ,OAAO;IACVK,UAAU,EAAE;EAAO,EACpB;EACD,IAAIC,KAAK,CAACC,OAAO,CAACN,IAAI,CAACC,QAAQ,CAAC,EAAE;IAChCD,IAAI,CAACC,QAAQ,GAAGD,IAAI,CAACC,QAAQ,CAACM,GAAG,CAAC,QAA2B;MAAA,IAArBC,IAAI;MAC1CA,IAAI,CAACC,MAAM,GAAGT,IAAI;MAClB,oBAAYQ,IAAI;IAClB,CAAC,CAAC;EACJ;EACA,OAAOR,IAAI;AACb,CAAC"
26
26
  }
@@ -22,5 +22,5 @@
22
22
  "sourcesContent": [
23
23
  "import * as React from 'react';\nimport { ICommand, TextState, TextAreaTextApi } from './';\n\nexport const hr: ICommand = {\n name: 'hr',\n keyCommand: 'hr',\n shortcuts: 'ctrlcmd+h',\n value: '----------',\n buttonProps: { 'aria-label': 'Insert HR (ctrl + h)', title: 'Insert HR (ctrl + h)' },\n icon: (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 175 175\">\n <path\n fill=\"currentColor\"\n d=\"M0,129 L175,129 L175,154 L0,154 L0,129 Z M3,9 L28.2158203,9 L28.2158203,47.9824219 L55.7695313,47.9824219 L55.7695313,9 L81.0966797,9 L81.0966797,107.185547 L55.7695313,107.185547 L55.7695313,68.0214844 L28.2158203,68.0214844 L28.2158203,107.185547 L3,107.185547 L3,9 Z M93.1855469,100.603516 L93.1855469,19 L135.211914,19 C143.004922,19 148.960917,19.6679621 153.080078,21.0039063 C157.199239,22.3398504 160.520495,24.8168764 163.043945,28.4350586 C165.567395,32.0532407 166.829102,36.459935 166.829102,41.6552734 C166.829102,46.1826398 165.864267,50.0883625 163.93457,53.3725586 C162.004873,56.6567547 159.351579,59.3193257 155.974609,61.3603516 C153.822255,62.6591862 150.872089,63.7353473 147.124023,64.5888672 C150.129898,65.5908253 152.319329,66.5927684 153.692383,67.5947266 C154.620122,68.2626987 155.965323,69.6913953 157.728027,71.8808594 C159.490731,74.0703234 160.668942,75.7587831 161.262695,76.9462891 L173,100.603516 L144.953125,100.603516 L131.482422,75.6660156 C129.775382,72.4374839 128.253913,70.3408251 126.917969,69.3759766 C125.0996,68.1142515 123.040051,67.4833984 120.739258,67.4833984 L118.512695,67.4833984 L118.512695,100.603516 L93.1855469,100.603516 Z M118.512695,52.0644531 L129.144531,52.0644531 C130.294928,52.0644531 132.521468,51.6933631 135.824219,50.9511719 C137.494149,50.6171858 138.857905,49.7636787 139.915527,48.390625 C140.97315,47.0175713 141.501953,45.4404386 141.501953,43.6591797 C141.501953,41.0244009 140.667001,39.0019602 138.99707,37.5917969 C137.32714,36.1816336 134.191429,35.4765625 129.589844,35.4765625 L117.512695,35.4765625 L118.512695,52.0644531 Z\"\n transform=\"translate(0 9)\"\n />\n </svg>\n ),\n execute: (state: TextState, api: TextAreaTextApi) => {\n api.replaceSelection(`${state.selectedText}\\n\\n----------\\n\\n`);\n },\n};\n"
24
24
  ],
25
- "mappings": "AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;;AAGA,OAAO,IAAMC,EAAY,GAAG;EAC1BC,IAAI,EAAE,IADoB;EAE1BC,UAAU,EAAE,IAFc;EAG1BC,SAAS,EAAE,WAHe;EAI1BC,KAAK,EAAE,YAJmB;EAK1BC,WAAW,EAAE;IAAE,cAAc,sBAAhB;IAAwCC,KAAK,EAAE;EAA/C,CALa;EAM1BC,IAAI,eACF;IAAK,KAAK,EAAC,IAAX;IAAgB,MAAM,EAAC,IAAvB;IAA4B,OAAO,EAAC,aAApC;IAAA,uBACE;MACE,IAAI,EAAC,cADP;MAEE,CAAC,EAAC,ukDAFJ;MAGE,SAAS,EAAC;IAHZ;EADF,EAPwB;EAe1BC,OAAO,EAAE,CAACC,KAAD,EAAmBC,GAAnB,KAA4C;IACnDA,GAAG,CAACC,gBAAJ,CAAwBF,KAAK,CAACG,YAA9B;EACD;AAjByB,CAArB"
25
+ "mappings": "AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAAC;AAG/B,OAAO,IAAMC,EAAY,GAAG;EAC1BC,IAAI,EAAE,IAAI;EACVC,UAAU,EAAE,IAAI;EAChBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE,YAAY;EACnBC,WAAW,EAAE;IAAE,YAAY,EAAE,sBAAsB;IAAEC,KAAK,EAAE;EAAuB,CAAC;EACpFC,IAAI,eACF;IAAK,KAAK,EAAC,IAAI;IAAC,MAAM,EAAC,IAAI;IAAC,OAAO,EAAC,aAAa;IAAA,uBAC/C;MACE,IAAI,EAAC,cAAc;MACnB,CAAC,EAAC,ukDAAukD;MACzkD,SAAS,EAAC;IAAgB;EAC1B,EAEL;EACDC,OAAO,EAAE,CAACC,KAAgB,EAAEC,GAAoB,KAAK;IACnDA,GAAG,CAACC,gBAAgB,CAAIF,KAAK,CAACG,YAAY,wBAAqB;EACjE;AACF,CAAC"
26
26
  }
@@ -11,8 +11,8 @@ export var image = {
11
11
  title: 'Add image (ctrl + k)'
12
12
  },
13
13
  icon: /*#__PURE__*/_jsx("svg", {
14
- width: "12",
15
- height: "12",
14
+ width: "13",
15
+ height: "13",
16
16
  viewBox: "0 0 20 20",
17
17
  children: /*#__PURE__*/_jsx("path", {
18
18
  fill: "currentColor",
@@ -25,11 +25,11 @@ export var image = {
25
25
  text: state.text,
26
26
  selection: state.selection
27
27
  });
28
- var state1 = api.setSelectionRange(newSelectionRange); // Replaces the current selection with the image
29
-
28
+ var state1 = api.setSelectionRange(newSelectionRange);
29
+ // Replaces the current selection with the image
30
30
  var imageTemplate = state1.selectedText || 'https://example.com/your-image.png';
31
- api.replaceSelection("![](" + imageTemplate + ")"); // Adjust the selection to not contain the **
32
-
31
+ api.replaceSelection("![](" + imageTemplate + ")");
32
+ // Adjust the selection to not contain the **
33
33
  api.setSelectionRange({
34
34
  start: 4 + state1.selection.start,
35
35
  end: 4 + state1.selection.start + imageTemplate.length
@@ -30,7 +30,7 @@
30
30
  "../../src/commands/image.tsx"
31
31
  ],
32
32
  "sourcesContent": [
33
- "import * as React from 'react';\nimport { ICommand, TextState, TextAreaTextApi } from './';\nimport { selectWord } from '../utils/markdownUtils';\n\nexport const image: ICommand = {\n name: 'image',\n keyCommand: 'image',\n shortcuts: 'ctrlcmd+k',\n value: '![image]()',\n buttonProps: { 'aria-label': 'Add image (ctrl + k)', title: 'Add image (ctrl + k)' },\n icon: (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 20 20\">\n <path\n fill=\"currentColor\"\n d=\"M15 9c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm4-7H1c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm-1 13l-6-5-2 2-4-5-4 8V4h16v11z\"\n />\n </svg>\n ),\n execute: (state: TextState, api: TextAreaTextApi) => {\n // Select everything\n const newSelectionRange = selectWord({ text: state.text, selection: state.selection });\n const state1 = api.setSelectionRange(newSelectionRange);\n // Replaces the current selection with the image\n const imageTemplate = state1.selectedText || 'https://example.com/your-image.png';\n api.replaceSelection(`![](${imageTemplate})`);\n // Adjust the selection to not contain the **\n api.setSelectionRange({\n start: 4 + state1.selection.start,\n end: 4 + state1.selection.start + imageTemplate.length,\n });\n },\n};\n"
33
+ "import * as React from 'react';\nimport { ICommand, TextState, TextAreaTextApi } from './';\nimport { selectWord } from '../utils/markdownUtils';\n\nexport const image: ICommand = {\n name: 'image',\n keyCommand: 'image',\n shortcuts: 'ctrlcmd+k',\n value: '![image]()',\n buttonProps: { 'aria-label': 'Add image (ctrl + k)', title: 'Add image (ctrl + k)' },\n icon: (\n <svg width=\"13\" height=\"13\" viewBox=\"0 0 20 20\">\n <path\n fill=\"currentColor\"\n d=\"M15 9c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm4-7H1c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm-1 13l-6-5-2 2-4-5-4 8V4h16v11z\"\n />\n </svg>\n ),\n execute: (state: TextState, api: TextAreaTextApi) => {\n // Select everything\n const newSelectionRange = selectWord({ text: state.text, selection: state.selection });\n const state1 = api.setSelectionRange(newSelectionRange);\n // Replaces the current selection with the image\n const imageTemplate = state1.selectedText || 'https://example.com/your-image.png';\n api.replaceSelection(`![](${imageTemplate})`);\n // Adjust the selection to not contain the **\n api.setSelectionRange({\n start: 4 + state1.selection.start,\n end: 4 + state1.selection.start + imageTemplate.length,\n });\n },\n};\n"
34
34
  ],
35
- "mappings": "AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,SAASC,UAAT,QAA2B,wBAA3B;;AAEA,OAAO,IAAMC,KAAe,GAAG;EAC7BC,IAAI,EAAE,OADuB;EAE7BC,UAAU,EAAE,OAFiB;EAG7BC,SAAS,EAAE,WAHkB;EAI7BC,KAAK,EAAE,YAJsB;EAK7BC,WAAW,EAAE;IAAE,cAAc,sBAAhB;IAAwCC,KAAK,EAAE;EAA/C,CALgB;EAM7BC,IAAI,eACF;IAAK,KAAK,EAAC,IA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EC,GAAoB,KAAK;IACnD;IACA,IAAMC,iBAAiB,GAAGZ,UAAU,CAAC;MAAEa,IAAI,EAAEH,KAAK,CAACG,IAAI;MAAEC,SAAS,EAAEJ,KAAK,CAACI;IAAU,CAAC,CAAC;IACtF,IAAMC,MAAM,GAAGJ,GAAG,CAACK,iBAAiB,CAACJ,iBAAiB,CAAC;IACvD;IACA,IAAMK,aAAa,GAAGF,MAAM,CAACG,YAAY,IAAI,oCAAoC;IACjFP,GAAG,CAACQ,gBAAgB,UAAQF,aAAa,OAAI;IAC7C;IACAN,GAAG,CAACK,iBAAiB,CAAC;MACpBI,KAAK,EAAE,CAAC,GAAGL,MAAM,CAACD,SAAS,CAACM,KAAK;MACjCC,GAAG,EAAE,CAAC,GAAGN,MAAM,CAACD,SAAS,CAACM,KAAK,GAAGH,aAAa,CAACK;IAClD,CAAC,CAAC;EACJ;AACF,CAAC"
36
36
  }
@@ -46,7 +46,7 @@ export interface ICommandBase<T> {
46
46
  liProps?: React.LiHTMLAttributes<HTMLLIElement>;
47
47
  buttonProps?: React.ButtonHTMLAttributes<HTMLButtonElement> | null;
48
48
  render?: (command: ICommand<T>, disabled: boolean, executeCommand: (command: ICommand<T>, name?: string) => void, index: number) => void | undefined | null | React.ReactElement;
49
- execute?: (state: TextState, api: TextAreaTextApi, dispatch?: React.Dispatch<ContextStore>, executeCommandState?: ExecuteCommandState) => void;
49
+ execute?: (state: TextState, api: TextAreaTextApi, dispatch?: React.Dispatch<ContextStore>, executeCommandState?: ExecuteCommandState, shortcuts?: string[]) => void;
50
50
  }
51
51
  export declare type ICommand<T = string> = ICommandChildCommands<T> | ICommandChildHandle<T>;
52
52
  export interface TextRange {
@@ -81,6 +81,6 @@ declare class TextAreaCommandOrchestrator implements CommandOrchestrator {
81
81
  textApi: TextAreaTextApi;
82
82
  constructor(textArea: HTMLTextAreaElement);
83
83
  getState(): false | TextState;
84
- executeCommand(command: ICommand<string>, dispatch?: React.Dispatch<ContextStore>, state?: ExecuteCommandState): void;
84
+ executeCommand(command: ICommand<string>, dispatch?: React.Dispatch<ContextStore>, state?: ExecuteCommandState, shortcuts?: string[]): void;
85
85
  }
86
86
  export { title, title1, title2, title3, title4, title5, title6, bold, codeBlock, italic, strikethrough, hr, group, divider, link, quote, code, image, unorderedListCommand, orderedListCommand, checkedListCommand, codeEdit, codeLive, codePreview, fullscreen, getCommands, getExtraCommands, getStateFromTextArea, TextAreaCommandOrchestrator, TextAreaTextApi, };
@@ -20,18 +20,15 @@ import { title3 } from './title3';
20
20
  import { title4 } from './title4';
21
21
  import { title5 } from './title5';
22
22
  import { title6 } from './title6';
23
-
24
- var getCommands = () => [comment, bold, italic, strikethrough, hr, group([title1, title2, title3, title4, title5, title6], {
25
- name: "title",
26
- groupName: "title",
23
+ var getCommands = () => [bold, italic, strikethrough, hr, group([title1, title2, title3, title4, title5, title6], {
24
+ name: 'title',
25
+ groupName: 'title',
27
26
  buttonProps: {
28
- "aria-label": "Insert title",
29
- title: "Insert title"
27
+ 'aria-label': 'Insert title',
28
+ title: 'Insert title'
30
29
  }
31
- }), divider, link, quote, code, codeBlock, image, divider, unorderedListCommand, orderedListCommand, checkedListCommand];
32
-
30
+ }), divider, link, quote, code, codeBlock, comment, image, divider, unorderedListCommand, orderedListCommand, checkedListCommand];
33
31
  var getExtraCommands = () => [codeEdit, codeLive, codePreview, divider, fullscreen];
34
-
35
32
  function getStateFromTextArea(textArea) {
36
33
  return {
37
34
  selection: {
@@ -42,38 +39,33 @@ function getStateFromTextArea(textArea) {
42
39
  selectedText: textArea.value.slice(textArea.selectionStart, textArea.selectionEnd)
43
40
  };
44
41
  }
45
-
46
42
  class TextAreaTextApi {
47
43
  constructor(textArea) {
48
44
  this.textArea = void 0;
49
45
  this.textArea = textArea;
50
46
  }
47
+
51
48
  /**
52
49
  * Replaces the current selection with the new text. This will make the new selectedText to be empty, the
53
50
  * selection start and selection end will be the same and will both point to the end
54
51
  * @param text Text that should replace the current selection
55
52
  */
56
-
57
-
58
53
  replaceSelection(text) {
59
54
  insertTextAtPosition(this.textArea, text);
60
55
  return getStateFromTextArea(this.textArea);
61
56
  }
57
+
62
58
  /**
63
59
  * Selects the specified text range
64
60
  * @param selection
65
61
  */
66
-
67
-
68
62
  setSelectionRange(selection) {
69
63
  this.textArea.focus();
70
64
  this.textArea.selectionStart = selection.start;
71
65
  this.textArea.selectionEnd = selection.end;
72
66
  return getStateFromTextArea(this.textArea);
73
67
  }
74
-
75
68
  }
76
-
77
69
  class TextAreaCommandOrchestrator {
78
70
  constructor(textArea) {
79
71
  this.textArea = void 0;
@@ -81,18 +73,15 @@ class TextAreaCommandOrchestrator {
81
73
  this.textArea = textArea;
82
74
  this.textApi = new TextAreaTextApi(textArea);
83
75
  }
84
-
85
76
  getState() {
86
77
  if (!this.textArea) return false;
87
78
  return getStateFromTextArea(this.textArea);
88
79
  }
89
-
90
- executeCommand(command, dispatch, state) {
91
- command.execute && command.execute(getStateFromTextArea(this.textArea), this.textApi, dispatch, state);
80
+ executeCommand(command, dispatch, state, shortcuts) {
81
+ command.execute && command.execute(getStateFromTextArea(this.textArea), this.textApi, dispatch, state, shortcuts);
92
82
  }
93
-
94
83
  }
95
-
96
- export { title, title1, title2, title3, title4, title5, title6, bold, codeBlock, italic, strikethrough, hr, group, divider, link, quote, code, image, unorderedListCommand, orderedListCommand, checkedListCommand, codeEdit, codeLive, codePreview, fullscreen, // Tool method.
84
+ export { title, title1, title2, title3, title4, title5, title6, bold, codeBlock, italic, strikethrough, hr, group, divider, link, quote, code, image, unorderedListCommand, orderedListCommand, checkedListCommand, codeEdit, codeLive, codePreview, fullscreen,
85
+ // Tool method.
97
86
  getCommands, getExtraCommands, getStateFromTextArea, TextAreaCommandOrchestrator, TextAreaTextApi };
98
87
  //# sourceMappingURL=index.js.map
@@ -56,13 +56,14 @@
56
56
  "command",
57
57
  "dispatch",
58
58
  "state",
59
+ "shortcuts",
59
60
  "execute"
60
61
  ],
61
62
  "sources": [
62
63
  "../../src/commands/index.ts"
63
64
  ],
64
65
  "sourcesContent": [
65
- "import React from 'react';\nimport { ContextStore, ExecuteCommandState } from '../Context';\nimport { insertTextAtPosition } from '../utils/InsertTextAtPosition';\nimport { bold } from './bold';\nimport { code, codeBlock } from './code';\nimport { comment } from './comment';\nimport { divider } from './divider';\nimport { fullscreen } from './fullscreen';\nimport { group } from './group';\nimport { hr } from './hr';\nimport { image } from './image';\nimport { italic } from './italic';\nimport { link } from './link';\nimport { checkedListCommand, orderedListCommand, unorderedListCommand } from './list';\nimport { codeEdit, codeLive, codePreview } from './preview';\nimport { quote } from './quote';\nimport { strikethrough } from './strikeThrough';\nimport { title } from './title';\nimport { title1 } from './title1';\nimport { title2 } from './title2';\nimport { title3 } from './title3';\nimport { title4 } from './title4';\nimport { title5 } from './title5';\nimport { title6 } from './title6';\n\nexport interface CommandOrchestrator {\n executeCommand(command: ICommand): void;\n}\n\nexport interface ICommandChildHandle<T = string> extends ICommandBase<T> {\n children?: (handle: {\n close: () => void;\n execute: () => void;\n getState?: TextAreaCommandOrchestrator['getState'];\n textApi?: TextAreaTextApi;\n }) => React.ReactElement;\n}\n\nexport interface ICommandChildCommands<T = string> extends ICommandBase<T> {\n children?: Array<ICommand<T>>;\n}\n\nexport interface ICommandBase<T> {\n parent?: ICommand<any>;\n keyCommand?: string;\n name?: string;\n shortcuts?: string;\n groupName?: string;\n icon?: React.ReactElement;\n value?: T;\n position?: 'right';\n liProps?: React.LiHTMLAttributes<HTMLLIElement>;\n buttonProps?: React.ButtonHTMLAttributes<HTMLButtonElement> | null;\n render?: (\n command: ICommand<T>,\n disabled: boolean,\n executeCommand: (command: ICommand<T>, name?: string) => void,\n index: number,\n ) => void | undefined | null | React.ReactElement;\n execute?: (\n state: TextState,\n api: TextAreaTextApi,\n dispatch?: React.Dispatch<ContextStore>,\n executeCommandState?: ExecuteCommandState,\n ) => void;\n}\n\nexport type ICommand<T = string> = ICommandChildCommands<T> | ICommandChildHandle<T>;\n\nexport interface TextRange {\n start: number;\n end: number;\n}\n\nexport interface TextState {\n text: string;\n selectedText: string;\n selection: TextRange;\n}\n\nconst getCommands: () => ICommand[] = () => [\n comment,\n bold,\n italic,\n strikethrough,\n hr,\n group([title1, title2, title3, title4, title5, title6], {\n\t\t\tname: \"title\",\n\t\t\tgroupName: \"title\",\n\t\t\tbuttonProps: { \"aria-label\": \"Insert title\", title: \"Insert title\" },\n\t\t}),\n divider,\n link,\n quote,\n code,\n codeBlock,\n image,\n divider,\n unorderedListCommand,\n orderedListCommand,\n checkedListCommand,\n];\n\nconst getExtraCommands: () => ICommand[] = () => [codeEdit, codeLive, codePreview, divider, fullscreen];\n\nfunction getStateFromTextArea(textArea: HTMLTextAreaElement): TextState {\n return {\n selection: {\n start: textArea.selectionStart,\n end: textArea.selectionEnd,\n },\n text: textArea.value,\n selectedText: textArea.value.slice(textArea.selectionStart, textArea.selectionEnd),\n };\n}\n\nclass TextAreaTextApi {\n textArea: HTMLTextAreaElement;\n\n constructor(textArea: HTMLTextAreaElement) {\n this.textArea = textArea;\n }\n\n /**\n * Replaces the current selection with the new text. This will make the new selectedText to be empty, the\n * selection start and selection end will be the same and will both point to the end\n * @param text Text that should replace the current selection\n */\n replaceSelection(text: string): TextState {\n insertTextAtPosition(this.textArea, text);\n return getStateFromTextArea(this.textArea);\n }\n\n /**\n * Selects the specified text range\n * @param selection\n */\n setSelectionRange(selection: TextRange): TextState {\n this.textArea.focus();\n this.textArea.selectionStart = selection.start;\n this.textArea.selectionEnd = selection.end;\n return getStateFromTextArea(this.textArea);\n }\n}\n\nclass TextAreaCommandOrchestrator implements CommandOrchestrator {\n textArea: HTMLTextAreaElement;\n textApi: TextAreaTextApi;\n\n constructor(textArea: HTMLTextAreaElement) {\n this.textArea = textArea;\n this.textApi = new TextAreaTextApi(textArea);\n }\n\n getState() {\n if (!this.textArea) return false;\n return getStateFromTextArea(this.textArea);\n }\n\n executeCommand(\n command: ICommand<string>,\n dispatch?: React.Dispatch<ContextStore>,\n state?: ExecuteCommandState,\n ): void {\n command.execute && command.execute(getStateFromTextArea(this.textArea), this.textApi, dispatch, state);\n }\n}\n\nexport {\n title,\n title1,\n title2,\n title3,\n title4,\n title5,\n title6,\n bold,\n codeBlock,\n italic,\n strikethrough,\n hr,\n group,\n divider,\n link,\n quote,\n code,\n image,\n unorderedListCommand,\n orderedListCommand,\n checkedListCommand,\n codeEdit,\n codeLive,\n codePreview,\n fullscreen,\n // Tool method.\n getCommands,\n getExtraCommands,\n getStateFromTextArea,\n TextAreaCommandOrchestrator,\n TextAreaTextApi,\n};\n\n"
66
+ "import React from 'react';\nimport { ContextStore, ExecuteCommandState } from '../Context';\nimport { insertTextAtPosition } from '../utils/InsertTextAtPosition';\nimport { bold } from './bold';\nimport { code, codeBlock } from './code';\nimport { comment } from './comment';\nimport { divider } from './divider';\nimport { fullscreen } from './fullscreen';\nimport { group } from './group';\nimport { hr } from './hr';\nimport { image } from './image';\nimport { italic } from './italic';\nimport { link } from './link';\nimport { checkedListCommand, orderedListCommand, unorderedListCommand } from './list';\nimport { codeEdit, codeLive, codePreview } from './preview';\nimport { quote } from './quote';\nimport { strikethrough } from './strikeThrough';\nimport { title } from './title';\nimport { title1 } from './title1';\nimport { title2 } from './title2';\nimport { title3 } from './title3';\nimport { title4 } from './title4';\nimport { title5 } from './title5';\nimport { title6 } from './title6';\n\nexport interface CommandOrchestrator {\n executeCommand(command: ICommand): void;\n}\n\nexport interface ICommandChildHandle<T = string> extends ICommandBase<T> {\n children?: (handle: {\n close: () => void;\n execute: () => void;\n getState?: TextAreaCommandOrchestrator['getState'];\n textApi?: TextAreaTextApi;\n }) => React.ReactElement;\n}\n\nexport interface ICommandChildCommands<T = string> extends ICommandBase<T> {\n children?: Array<ICommand<T>>;\n}\n\nexport interface ICommandBase<T> {\n parent?: ICommand<any>;\n keyCommand?: string;\n name?: string;\n shortcuts?: string;\n groupName?: string;\n icon?: React.ReactElement;\n value?: T;\n position?: 'right';\n liProps?: React.LiHTMLAttributes<HTMLLIElement>;\n buttonProps?: React.ButtonHTMLAttributes<HTMLButtonElement> | null;\n render?: (\n command: ICommand<T>,\n disabled: boolean,\n executeCommand: (command: ICommand<T>, name?: string) => void,\n index: number,\n ) => void | undefined | null | React.ReactElement;\n execute?: (\n state: TextState,\n api: TextAreaTextApi,\n dispatch?: React.Dispatch<ContextStore>,\n executeCommandState?: ExecuteCommandState,\n shortcuts?: string[],\n ) => void;\n}\n\nexport type ICommand<T = string> = ICommandChildCommands<T> | ICommandChildHandle<T>;\n\nexport interface TextRange {\n start: number;\n end: number;\n}\n\nexport interface TextState {\n text: string;\n selectedText: string;\n selection: TextRange;\n}\n\nconst getCommands: () => ICommand[] = () => [\n bold,\n italic,\n strikethrough,\n hr,\n group([title1, title2, title3, title4, title5, title6], {\n name: 'title',\n groupName: 'title',\n buttonProps: { 'aria-label': 'Insert title', title: 'Insert title' },\n }),\n divider,\n link,\n quote,\n code,\n codeBlock,\n comment,\n image,\n divider,\n unorderedListCommand,\n orderedListCommand,\n checkedListCommand,\n];\n\nconst getExtraCommands: () => ICommand[] = () => [codeEdit, codeLive, codePreview, divider, fullscreen];\n\nfunction getStateFromTextArea(textArea: HTMLTextAreaElement): TextState {\n return {\n selection: {\n start: textArea.selectionStart,\n end: textArea.selectionEnd,\n },\n text: textArea.value,\n selectedText: textArea.value.slice(textArea.selectionStart, textArea.selectionEnd),\n };\n}\n\nclass TextAreaTextApi {\n textArea: HTMLTextAreaElement;\n\n constructor(textArea: HTMLTextAreaElement) {\n this.textArea = textArea;\n }\n\n /**\n * Replaces the current selection with the new text. This will make the new selectedText to be empty, the\n * selection start and selection end will be the same and will both point to the end\n * @param text Text that should replace the current selection\n */\n replaceSelection(text: string): TextState {\n insertTextAtPosition(this.textArea, text);\n return getStateFromTextArea(this.textArea);\n }\n\n /**\n * Selects the specified text range\n * @param selection\n */\n setSelectionRange(selection: TextRange): TextState {\n this.textArea.focus();\n this.textArea.selectionStart = selection.start;\n this.textArea.selectionEnd = selection.end;\n return getStateFromTextArea(this.textArea);\n }\n}\n\nclass TextAreaCommandOrchestrator implements CommandOrchestrator {\n textArea: HTMLTextAreaElement;\n textApi: TextAreaTextApi;\n\n constructor(textArea: HTMLTextAreaElement) {\n this.textArea = textArea;\n this.textApi = new TextAreaTextApi(textArea);\n }\n\n getState() {\n if (!this.textArea) return false;\n return getStateFromTextArea(this.textArea);\n }\n\n executeCommand(\n command: ICommand<string>,\n dispatch?: React.Dispatch<ContextStore>,\n state?: ExecuteCommandState,\n shortcuts?: string[],\n ): void {\n command.execute && command.execute(getStateFromTextArea(this.textArea), this.textApi, dispatch, state, shortcuts);\n }\n}\n\nexport {\n title,\n title1,\n title2,\n title3,\n title4,\n title5,\n title6,\n bold,\n codeBlock,\n italic,\n strikethrough,\n hr,\n group,\n divider,\n link,\n quote,\n code,\n image,\n unorderedListCommand,\n orderedListCommand,\n checkedListCommand,\n codeEdit,\n codeLive,\n codePreview,\n fullscreen,\n // Tool method.\n getCommands,\n getExtraCommands,\n getStateFromTextArea,\n TextAreaCommandOrchestrator,\n TextAreaTextApi,\n};\n"
66
67
  ],
67
- "mappings": "AAEA,SAASA,oBAAT,QAAqC,+BAArC;AACA,SAASC,IAAT,QAAqB,QAArB;AACA,SAASC,IAAT,EAAeC,SAAf,QAAgC,QAAhC;AACA,SAASC,OAAT,QAAwB,WAAxB;AACA,SAASC,OAAT,QAAwB,WAAxB;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,KAAT,QAAsB,SAAtB;AACA,SAASC,EAAT,QAAmB,MAAnB;AACA,SAASC,KAAT,QAAsB,SAAtB;AACA,SAASC,MAAT,QAAuB,UAAvB;AACA,SAASC,IAAT,QAAqB,QAArB;AACA,SAASC,kBAAT,EAA6BC,kBAA7B,EAAiDC,oBAAjD,QAA6E,QAA7E;AACA,SAASC,QAAT,EAAmBC,QAAnB,EAA6BC,WAA7B,QAAgD,WAAhD;AACA,SAASC,KAAT,QAAsB,SAAtB;AACA,SAASC,aAAT,QAA8B,iBAA9B;AACA,SAAS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28
  selection: state.selection
29
29
  });
30
- var state1 = api.setSelectionRange(newSelectionRange); // Replaces the current selection with the italic mark up
31
-
32
- var state2 = api.replaceSelection("*" + state1.selectedText + "*"); // Adjust the selection to not contain the *
33
-
30
+ var state1 = api.setSelectionRange(newSelectionRange);
31
+ // Replaces the current selection with the italic mark up
32
+ var state2 = api.replaceSelection("*" + state1.selectedText + "*");
33
+ // Adjust the selection to not contain the *
34
34
  api.setSelectionRange({
35
35
  start: state2.selection.end - 1 - state1.selectedText.length,
36
36
  end: state2.selection.end - 1
@@ -32,5 +32,5 @@
32
32
  "sourcesContent": [
33
33
  "import * as React from 'react';\nimport { ICommand, TextState, TextAreaTextApi } from './';\nimport { selectWord } from '../utils/markdownUtils';\n\nexport const italic: ICommand = {\n name: 'italic',\n keyCommand: 'italic',\n shortcuts: 'ctrlcmd+i',\n value: '* *',\n buttonProps: { 'aria-label': 'Add italic text (ctrl + i)', title: 'Add italic text (ctrl + i)' },\n icon: (\n <svg data-name=\"italic\" width=\"12\" height=\"12\" role=\"img\" viewBox=\"0 0 320 512\">\n <path\n fill=\"currentColor\"\n d=\"M204.758 416h-33.849l62.092-320h40.725a16 16 0 0 0 15.704-12.937l6.242-32C297.599 41.184 290.034 32 279.968 32H120.235a16 16 0 0 0-15.704 12.937l-6.242 32C96.362 86.816 103.927 96 113.993 96h33.846l-62.09 320H46.278a16 16 0 0 0-15.704 12.935l-6.245 32C22.402 470.815 29.967 480 40.034 480h158.479a16 16 0 0 0 15.704-12.935l6.245-32c1.927-9.88-5.638-19.065-15.704-19.065z\"\n />\n </svg>\n ),\n execute: (state: TextState, api: TextAreaTextApi) => {\n // Adjust the selection to encompass the whole word if the caret is inside one\n const newSelectionRange = selectWord({ text: state.text, selection: state.selection });\n const state1 = api.setSelectionRange(newSelectionRange);\n // Replaces the current selection with the italic mark up\n const state2 = api.replaceSelection(`*${state1.selectedText}*`);\n // Adjust the selection to not contain the *\n api.setSelectionRange({\n start: state2.selection.end - 1 - state1.selectedText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,SAASC,UAAU,QAAQ,wBAAwB;AAAC;AAEpD,OAAO,IAAMC,MAAgB,GAAG;EAC9BC,IAAI,EAAE,QAAQ;EACdC,UAAU,EAAE,QAAQ;EACpBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE,KAAK;EACZC,WAAW,EAAE;IAAE,YAAY,EAAE,4BAA4B;IAAEC,KAAK,EAAE;EAA6B,CAAC;EAChGC,IAAI,eACF;IAAK,aAAU,QAAQ;IAAC,KAAK,EAAC,IAAI;IAAC,MAAM,EAAC,IAAI;IAAC,IAAI,EAAC,KAAK;IAAC,OAAO,EAAC,aAAa;IAAA,uBAC7E;MACE,IAAI,EAAC,cAAc;MACnB,CAAC,EAAC;IAAoX;EACtX,EAEL;EACDC,OAAO,EAAE,CAACC,KAAgB,EAAEC,GAAoB,KAAK;IACnD;IACA,IAAMC,iBAAiB,GAAGZ,UAAU,CAAC;MAAEa,IAAI,EAAEH,KAAK,CAACG,IAAI;MAAEC,SAAS,EAAEJ,KAAK,CAACI;IAAU,CAAC,CAAC;IACtF,IAAMC,MAAM,GAAGJ,GAAG,CAACK,iBAAiB,CAACJ,iBAAiB,CAAC;IACvD;IACA,IAAMK,MAAM,GAAGN,GAAG,CAACO,gBAAgB,OAAKH,MAAM,CAACI,YAAY,OAAI;IAC/D;IACAR,GAAG,CAACK,iBAAiB,CAAC;MACpBI,KAAK,EAAEH,MAAM,CAACH,SAAS,CAACO,GAAG,GAAG,CAAC,GAAGN,MAAM,CAACI,YAAY,CAACG,MAAM;MAC5DD,GAAG,EAAEJ,MAAM,CAACH,SAAS,CAACO,GAAG,GAAG;IAC9B,CAAC,CAAC;EACJ;AACF,CAAC"
36
36
  }
@@ -27,10 +27,10 @@ export var link = {
27
27
  text: state.text,
28
28
  selection: state.selection
29
29
  });
30
- var state1 = api.setSelectionRange(newSelectionRange); // Replaces the current selection with the bold mark up
31
-
32
- var state2 = api.replaceSelection("[" + state1.selectedText + "](url)"); // Adjust the selection to not contain the **
33
-
30
+ var state1 = api.setSelectionRange(newSelectionRange);
31
+ // Replaces the current selection with the bold mark up
32
+ var state2 = api.replaceSelection("[" + state1.selectedText + "](url)");
33
+ // Adjust the selection to not contain the **
34
34
  api.setSelectionRange({
35
35
  start: state2.selection.end - 6 - state1.selectedText.length,
36
36
  end: state2.selection.end - 6
@@ -32,5 +32,5 @@
32
32
  "sourcesContent": [
33
33
  "import * as React from 'react';\nimport { ICommand, TextState, TextAreaTextApi } from './';\nimport { selectWord } from '../utils/markdownUtils';\n\nexport const link: ICommand = {\n name: 'link',\n keyCommand: 'link',\n shortcuts: 'ctrlcmd+l',\n value: '[](url)',\n buttonProps: { 'aria-label': 'Add a link (ctrl + l)', title: 'Add a link (ctrl + l)' },\n icon: (\n <svg data-name=\"italic\" width=\"12\" height=\"12\" role=\"img\" viewBox=\"0 0 520 520\">\n <path\n fill=\"currentColor\"\n 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\"\n />\n </svg>\n ),\n execute: (state: TextState, api: TextAreaTextApi) => {\n // Adjust the selection to encompass the whole word if the caret is inside one\n const newSelectionRange = selectWord({ text: state.text, selection: state.selection });\n const state1 = api.setSelectionRange(newSelectionRange);\n // Replaces the current selection with the bold mark up\n const state2 = api.replaceSelection(`[${state1.selectedText}](url)`);\n // Adjust the selection to not contain the **\n api.setSelectionRange({\n start: state2.selection.end - 6 - state1.selectedText.length,\n end: state2.selection.end - 6,\n });\n },\n};\n"
34
34
  ],
35
- "mappings": "AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,SAASC,UAAT,QAA2B,wBAA3B;;AAEA,OAAO,IAAMC,IAAc,GAAG;EAC5BC,IAAI,EAAE,MADsB;EAE5BC,UAAU,EAAE,MAFgB;EAG5BC,SAAS,EAAE,WAHiB;EAI5BC,KAAK,EAAE,SAJqB;EAK5BC,WAAW,EAAE;IAAE,cAAc,uBAAhB;IAAyCC,KAAK,EAAE;EAAhD,CAL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AC,KAAK;IAAC,OAAO,EAAC,aAAa;IAAA,uBAC7E;MACE,IAAI,EAAC,cAAc;MACnB,CAAC,EAAC;IAA2tE;EAC7tE,EAEL;EACDC,OAAO,EAAE,CAACC,KAAgB,EAAEC,GAAoB,KAAK;IACnD;IACA,IAAMC,iBAAiB,GAAGZ,UAAU,CAAC;MAAEa,IAAI,EAAEH,KAAK,CAACG,IAAI;MAAEC,SAAS,EAAEJ,KAAK,CAACI;IAAU,CAAC,CAAC;IACtF,IAAMC,MAAM,GAAGJ,GAAG,CAACK,iBAAiB,CAACJ,iBAAiB,CAAC;IACvD;IACA,IAAMK,MAAM,GAAGN,GAAG,CAACO,gBAAgB,OAAKH,MAAM,CAACI,YAAY,YAAS;IACpE;IACAR,GAAG,CAACK,iBAAiB,CAAC;MACpBI,KAAK,EAAEH,MAAM,CAACH,SAAS,CAACO,GAAG,GAAG,CAAC,GAAGN,MAAM,CAACI,YAAY,CAACG,MAAM;MAC5DD,GAAG,EAAEJ,MAAM,CAACH,SAAS,CAACO,GAAG,GAAG;IAC9B,CAAC,CAAC;EACJ;AACF,CAAC"
36
36
  }
@@ -1,7 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { selectWord, getBreaksNeededForEmptyLineBefore, getBreaksNeededForEmptyLineAfter } from '../utils/markdownUtils';
3
3
  import { jsx as _jsx } from "react/jsx-runtime";
4
-
5
4
  /**
6
5
  * Inserts insertionString before each line
7
6
  */
@@ -17,7 +16,6 @@ export function insertBeforeEachLine(selectedText, insertBefore) {
17
16
  insertionLength += insertionResult.length;
18
17
  return insertBefore(item, index) + item;
19
18
  }
20
-
21
19
  throw Error('insertion is expected to be either a string or a function');
22
20
  }).join('\n');
23
21
  return {
@@ -37,12 +35,14 @@ export var makeList = (state, api, insertBefore) => {
37
35
  var breaksAfterCount = getBreaksNeededForEmptyLineAfter(state1.text, state1.selection.end);
38
36
  var breaksAfter = Array(breaksAfterCount + 1).join('\n');
39
37
  var modifiedText = insertBeforeEachLine(state1.selectedText, insertBefore);
40
- api.replaceSelection("" + breaksBefore + modifiedText.modifiedText + breaksAfter); // Specifically when the text has only one line, we can exclude the "- ", for example, from the selection
38
+ api.replaceSelection("" + breaksBefore + modifiedText.modifiedText + breaksAfter);
41
39
 
40
+ // Specifically when the text has only one line, we can exclude the "- ", for example, from the selection
42
41
  var oneLinerOffset = state1.selectedText.indexOf('\n') === -1 ? modifiedText.insertionLength : 0;
43
42
  var selectionStart = state1.selection.start + breaksBeforeCount + oneLinerOffset;
44
- var selectionEnd = selectionStart + modifiedText.modifiedText.length - oneLinerOffset; // Adjust the selection to not contain the **
43
+ var selectionEnd = selectionStart + modifiedText.modifiedText.length - oneLinerOffset;
45
44
 
45
+ // Adjust the selection to not contain the **
46
46
  api.setSelectionRange({
47
47
  start: selectionStart,
48
48
  end: selectionEnd
@@ -57,5 +57,5 @@
57
57
  "sourcesContent": [
58
58
  "import * as React from 'react';\nimport { ICommand, TextState, TextAreaTextApi } from './';\nimport {\n selectWord,\n getBreaksNeededForEmptyLineBefore,\n getBreaksNeededForEmptyLineAfter,\n} from '../utils/markdownUtils';\n\nexport type AlterLineFunction = (line: string, index: number) => string;\n\n/**\n * Inserts insertionString before each line\n */\nexport function insertBeforeEachLine(\n selectedText: string,\n insertBefore: string | AlterLineFunction,\n): { modifiedText: string; insertionLength: number } {\n const lines = selectedText.split(/\\n/);\n\n let insertionLength = 0;\n const modifiedText = lines\n .map((item, index) => {\n if (typeof insertBefore === 'string') {\n insertionLength += insertBefore.length;\n return insertBefore + item;\n } else if (typeof insertBefore === 'function') {\n const insertionResult = insertBefore(item, index);\n insertionLength += insertionResult.length;\n return insertBefore(item, index) + item;\n }\n throw Error('insertion is expected to be either a string or a function');\n })\n .join('\\n');\n\n return { modifiedText, insertionLength };\n}\n\nexport const makeList = (state: TextState, api: TextAreaTextApi, insertBefore: string | AlterLineFunction) => {\n // Adjust the selection to encompass the whole word if the caret is inside one\n const newSelectionRange = selectWord({ text: state.text, selection: state.selection });\n const state1 = api.setSelectionRange(newSelectionRange);\n\n const breaksBeforeCount = getBreaksNeededForEmptyLineBefore(state1.text, state1.selection.start);\n const breaksBefore = Array(breaksBeforeCount + 1).join('\\n');\n\n const breaksAfterCount = getBreaksNeededForEmptyLineAfter(state1.text, state1.selection.end);\n const breaksAfter = Array(breaksAfterCount + 1).join('\\n');\n\n const modifiedText = insertBeforeEachLine(state1.selectedText, insertBefore);\n\n api.replaceSelection(`${breaksBefore}${modifiedText.modifiedText}${breaksAfter}`);\n\n // Specifically when the text has only one line, we can exclude the \"- \", for example, from the selection\n const oneLinerOffset = state1.selectedText.indexOf('\\n') === -1 ? modifiedText.insertionLength : 0;\n\n const selectionStart = state1.selection.start + breaksBeforeCount + oneLinerOffset;\n const selectionEnd = selectionStart + modifiedText.modifiedText.length - oneLinerOffset;\n\n // Adjust the selection to not contain the **\n api.setSelectionRange({\n start: selectionStart,\n end: selectionEnd,\n });\n};\n\nexport const unorderedListCommand: ICommand = {\n name: 'unordered-list',\n keyCommand: 'list',\n shortcuts: 'ctrl+shift+u',\n value: '- ',\n buttonProps: {\n 'aria-label': 'Add unordered list (ctrl + shift + u)',\n title: 'Add unordered list (ctrl + shift + u)',\n },\n icon: (\n <svg data-name=\"unordered-list\" width=\"12\" height=\"12\" viewBox=\"0 0 512 512\">\n <path\n fill=\"currentColor\"\n 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\"\n />\n </svg>\n ),\n execute: (state: TextState, api: TextAreaTextApi) => {\n makeList(state, api, '- ');\n },\n};\n\nexport const orderedListCommand: ICommand = {\n name: 'ordered-list',\n keyCommand: 'list',\n shortcuts: 'ctrl+shift+o',\n value: '1. ',\n buttonProps: { 'aria-label': 'Add ordered list (ctrl + shift + o)', title: 'Add ordered list (ctrl + shift + o)' },\n icon: (\n <svg data-name=\"ordered-list\" width=\"12\" height=\"12\" role=\"img\" viewBox=\"0 0 512 512\">\n <path\n fill=\"currentColor\"\n 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\"\n />\n </svg>\n ),\n execute: (state: TextState, api: TextAreaTextApi) => {\n makeList(state, api, (item, index) => `${index + 1}. `);\n },\n};\n\nexport const checkedListCommand: ICommand = {\n name: 'checked-list',\n keyCommand: 'list',\n shortcuts: 'ctrl+shift+c',\n value: '- [x] ',\n buttonProps: { 'aria-label': 'Add checked list (ctrl + shift + c)', title: 'Add checked list (ctrl + shift + c)' },\n icon: (\n <svg data-name=\"checked-list\" width=\"12\" height=\"12\" role=\"img\" viewBox=\"0 0 512 512\">\n <path\n fill=\"currentColor\"\n 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\"\n />\n </svg>\n ),\n execute: (state: TextState, api: TextAreaTextApi) => {\n makeList(state, api, (item, index) => `- [ ] `);\n },\n};\n"
59
59
  ],
60
- "mappings": "AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,SACEC,UADF,EAEEC,iCAFF,EAGEC,gCAHF,QAIO,wBAJP;;;AAQA;AACA;AACA;AACA,OAAO,SAASC,oBAAT,CACLC,YADK,EAELC,YAFK,EAG8C;EACnD,IAAMC,KAAK,GAAGF,YAAY,CAACG,KAAb,CAAmB,IAAnB,CAAd;EAEA,IAAIC,eAAe,GAAG,CAAtB;EACA,IAAMC,YAAY,GAAGH,KAAK,CACvBI,GADkB,CACd,CAACC,IAAD,EAAOC,KAAP,KAAiB;IACpB,IAAI,OAAOP,YAAP,KAAwB,QAA5B,EAAsC;MACpCG,eAAe,IAAIH,YAAY,CAACQ,MAAhC;MACA,OAAOR,YAAY,GAAGM,IAAtB;IACD,CAHD,MAGO,IAAI,OAAON,YAAP,KAAwB,UAA5B,EAAwC;MAC7C,IAAMS,eAAe,GAAGT,YAAY,CAACM,IAAD,EAAOC,KAAP,CAApC;MACAJ,eAAe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,KAAK;EACZC,WAAW,EAAE;IAAE,YAAY,EAAE,qCAAqC;IAAEC,KAAK,EAAE;EAAsC,CAAC;EAClHC,IAAI,eACF;IAAK,aAAU,cAAc;IAAC,KAAK,EAAC,IAAI;IAAC,MAAM,EAAC,IAAI;IAAC,IAAI,EAAC,KAAK;IAAC,OAAO,EAAC,aAAa;IAAA,uBACnF;MACE,IAAI,EAAC,cAAc;MACnB,CAAC,EAAC;IAA62D;EAC/2D,EAEL;EACDC,OAAO,EAAE,CAAC3B,KAAgB,EAAEC,GAAoB,KAAK;IACnDF,QAAQ,CAACC,KAAK,EAAEC,GAAG,EAAE,CAACR,IAAI,EAAEC,KAAK,KAAQA,KAAK,GAAG,CAAC,OAAI,CAAC;EACzD;AACF,CAAC;AAED,OAAO,IAAMmC,kBAA4B,GAAG;EAC1CT,IAAI,EAAE,cAAc;EACpBC,UAAU,EAAE,MAAM;EAClBC,SAAS,EAAE,cAAc;EACzBC,KAAK,EAAE,QAAQ;EACfC,WAAW,EAAE;IAAE,YAAY,EAAE,qCAAqC;IAAEC,KAAK,EAAE;EAAsC,CAAC;EAClHC,IAAI,eACF;IAAK,aAAU,cAAc;IAAC,KAAK,EAAC,IAAI;IAAC,MAAM,EAAC,IAAI;IAAC,IAAI,EAAC,KAAK;IAAC,OAAO,EAAC,aAAa;IAAA,uBACnF;MACE,IAAI,EAAC,cAAc;MACnB,CAAC,EAAC;IAA2vB;EAC7vB,EAEL;EACDC,OAAO,EAAE,CAAC3B,KAAgB,EAAEC,GAAoB,KAAK;IACnDF,QAAQ,CAACC,KAAK,EAAEC,GAAG,EAAE,CAACR,IAAI,EAAEC,KAAK,aAAa,CAAC;EACjD;AACF,CAAC"
61
61
  }
@@ -22,7 +22,13 @@ export var codePreview = {
22
22
  points: "148.023 72.293 520 71.293 520 122 200.023 124 200.023 397 520 396 520 449.707 148.023 450.413"
23
23
  })]
24
24
  }),
25
- execute: () => {}
25
+ execute: (state, api, dispatch, executeCommandState, shortcuts) => {
26
+ if (shortcuts && dispatch && executeCommandState) {
27
+ dispatch({
28
+ preview: 'preview'
29
+ });
30
+ }
31
+ }
26
32
  };
27
33
  export var codeEdit = {
28
34
  name: 'edit',
@@ -45,7 +51,13 @@ export var codeEdit = {
45
51
  points: "429 71.293 520 71.293 520 122 481 123 481 396 520 396 520 449.707 429 449.413"
46
52
  })]
47
53
  }),
48
- execute: () => {}
54
+ execute: (state, api, dispatch, executeCommandState, shortcuts) => {
55
+ if (shortcuts && dispatch && executeCommandState) {
56
+ dispatch({
57
+ preview: 'edit'
58
+ });
59
+ }
60
+ }
49
61
  };
50
62
  export var codeLive = {
51
63
  name: 'live',
@@ -68,6 +80,12 @@ export var codeLive = {
68
80
  points: "289 71.293 520 71.293 520 122 341 123 341 396 520 396 520 449.707 289 449.413"
69
81
  })]
70
82
  }),
71
- execute: () => {}
83
+ execute: (state, api, dispatch, executeCommandState, shortcuts) => {
84
+ if (shortcuts && dispatch && executeCommandState) {
85
+ dispatch({
86
+ preview: 'live'
87
+ });
88
+ }
89
+ }
72
90
  };
73
91
  //# sourceMappingURL=preview.js.map
@@ -11,6 +11,11 @@
11
11
  "title",
12
12
  "icon",
13
13
  "execute",
14
+ "state",
15
+ "api",
16
+ "dispatch",
17
+ "executeCommandState",
18
+ "preview",
14
19
  "codeEdit",
15
20
  "codeLive"
16
21
  ],
@@ -18,7 +23,7 @@
18
23
  "../../src/commands/preview.tsx"
19
24
  ],
20
25
  "sourcesContent": [
21
- "import * as React from 'react';\nimport { ICommand } from './';\n\nexport const codePreview: ICommand = {\n name: 'preview',\n keyCommand: 'preview',\n value: 'preview',\n shortcuts: 'ctrlcmd+9',\n buttonProps: { 'aria-label': 'Preview code (ctrl + 9)', title: 'Preview code (ctrl + 9)' },\n icon: (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 520 520\">\n <polygon\n fill=\"currentColor\"\n points=\"0 71.293 0 122 38.023 123 38.023 398 0 397 0 449.707 91.023 450.413 91.023 72.293\"\n />\n <polygon\n fill=\"currentColor\"\n points=\"148.023 72.293 520 71.293 520 122 200.023 124 200.023 397 520 396 520 449.707 148.023 450.413\"\n />\n </svg>\n ),\n execute: () => {},\n};\n\nexport const codeEdit: ICommand = {\n name: 'edit',\n keyCommand: 'preview',\n value: 'edit',\n shortcuts: 'ctrlcmd+7',\n buttonProps: { 'aria-label': 'Edit code (ctrl + 7)', title: 'Edit code (ctrl + 7)' },\n icon: (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 520 520\">\n <polygon fill=\"currentColor\" points=\"0 71.293 0 122 319 122 319 397 0 397 0 449.707 372 449.413 372 71.293\" />\n <polygon\n fill=\"currentColor\"\n points=\"429 71.293 520 71.293 520 122 481 123 481 396 520 396 520 449.707 429 449.413\"\n />\n </svg>\n ),\n execute: () => {},\n};\n\nexport const codeLive: ICommand = {\n name: 'live',\n keyCommand: 'preview',\n value: 'live',\n shortcuts: 'ctrlcmd+8',\n buttonProps: { 'aria-label': 'Live code (ctrl + 8)', title: 'Live code (ctrl + 8)' },\n icon: (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 520 520\">\n <polygon fill=\"currentColor\" points=\"0 71.293 0 122 179 122 179 397 0 397 0 449.707 232 449.413 232 71.293\" />\n <polygon\n fill=\"currentColor\"\n points=\"289 71.293 520 71.293 520 122 341 123 341 396 520 396 520 449.707 289 449.413\"\n />\n </svg>\n ),\n execute: () => {},\n};\n"
26
+ "import * as React from 'react';\nimport { ICommand, TextState, TextAreaTextApi } from './';\nimport { ContextStore, ExecuteCommandState } from '../Context';\n\nexport const codePreview: ICommand = {\n name: 'preview',\n keyCommand: 'preview',\n value: 'preview',\n shortcuts: 'ctrlcmd+9',\n buttonProps: { 'aria-label': 'Preview code (ctrl + 9)', title: 'Preview code (ctrl + 9)' },\n icon: (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 520 520\">\n <polygon\n fill=\"currentColor\"\n points=\"0 71.293 0 122 38.023 123 38.023 398 0 397 0 449.707 91.023 450.413 91.023 72.293\"\n />\n <polygon\n fill=\"currentColor\"\n points=\"148.023 72.293 520 71.293 520 122 200.023 124 200.023 397 520 396 520 449.707 148.023 450.413\"\n />\n </svg>\n ),\n execute: (\n state: TextState,\n api: TextAreaTextApi,\n dispatch?: React.Dispatch<ContextStore>,\n executeCommandState?: ExecuteCommandState,\n shortcuts?: string[],\n ) => {\n if (shortcuts && dispatch && executeCommandState) {\n dispatch({ preview: 'preview' });\n }\n },\n};\n\nexport const codeEdit: ICommand = {\n name: 'edit',\n keyCommand: 'preview',\n value: 'edit',\n shortcuts: 'ctrlcmd+7',\n buttonProps: { 'aria-label': 'Edit code (ctrl + 7)', title: 'Edit code (ctrl + 7)' },\n icon: (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 520 520\">\n <polygon fill=\"currentColor\" points=\"0 71.293 0 122 319 122 319 397 0 397 0 449.707 372 449.413 372 71.293\" />\n <polygon\n fill=\"currentColor\"\n points=\"429 71.293 520 71.293 520 122 481 123 481 396 520 396 520 449.707 429 449.413\"\n />\n </svg>\n ),\n execute: (\n state: TextState,\n api: TextAreaTextApi,\n dispatch?: React.Dispatch<ContextStore>,\n executeCommandState?: ExecuteCommandState,\n shortcuts?: string[],\n ) => {\n if (shortcuts && dispatch && executeCommandState) {\n dispatch({ preview: 'edit' });\n }\n },\n};\n\nexport const codeLive: ICommand = {\n name: 'live',\n keyCommand: 'preview',\n value: 'live',\n shortcuts: 'ctrlcmd+8',\n buttonProps: { 'aria-label': 'Live code (ctrl + 8)', title: 'Live code (ctrl + 8)' },\n icon: (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 520 520\">\n <polygon fill=\"currentColor\" points=\"0 71.293 0 122 179 122 179 397 0 397 0 449.707 232 449.413 232 71.293\" />\n <polygon\n fill=\"currentColor\"\n points=\"289 71.293 520 71.293 520 122 341 123 341 396 520 396 520 449.707 289 449.413\"\n />\n </svg>\n ),\n execute: (\n state: TextState,\n api: TextAreaTextApi,\n dispatch?: React.Dispatch<ContextStore>,\n executeCommandState?: ExecuteCommandState,\n shortcuts?: string[],\n ) => {\n if (shortcuts && dispatch && executeCommandState) {\n dispatch({ preview: 'live' });\n }\n },\n};\n"
22
27
  ],
23
- "mappings": "AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;;;AAGA,OAAO,IAAMC,WAAqB,GAAG;EACnCC,IAAI,EAAE,SAD6B;EAEnCC,UAAU,EAAE,SAFuB;EAGnCC,KAAK,EAAE,SAH4B;EAInCC,SAAS,EAAE,WAJwB;EAKnCC,WAAW,EAAE;IAAE,cAAc,yBAAhB;IAA2CC,KAAK,EAAE;EAAlD,CALsB;EAMnCC,IAAI,eACF;IAAK,KAAK,EAAC,IAAX;IAAgB,MAAM,EAAC,IAAvB;IAA4B,OAAO,EAAC,aAApC;IAAA,wBACE;MACE,IAAI,EAAC,cADP;MAEE,MAAM,EAAC;IAFT,EADF,eAKE;MACE,IAAI,EAAC,cADP;MAEE,MAAM,EAAC;IAFT,EALF;EAAA,EAPiC;EAkBnCC,OAAO,EAAE,MAAM,CAAE;AAlBkB,CAA9B;AAqBP,OAAO,IAAMC,QAAkB,GAAG;EAChCR,IAAI,EAAE,MAD0B;EAEhCC,UAAU,EAAE,SAFoB;EAGhCC,KAAK,EAAE,MAHyB;EAIhCC,SAAS,EAAE,WAJqB;EAKhCC,WAAW,EAAE;IAAE,cAAc,sBAAhB;IAAwCC,KAAK,EAAE;EAA/C,CALmB;EAMhCC,IAAI,eACF;IAAK,KAAK,EAAC,IAAX;IAAgB,MAAM,EAAC,IAAvB;IAA4B,OAAO,EAAC,aAApC;IAAA,wBACE;MAAS,IAAI,EAAC,cAAd;MAA6B,MAAM,EAAC;IAApC,EADF,eAEE;MACE,IAAI,EAAC,cADP;MAEE,MAAM,EAAC;IAFT,EAFF;EAAA,EAP8B;EAehCC,OAAO,EAAE,MAAM,CAAE;AAfe,CAA3B;AAkBP,OAAO,IAAME,QAAkB,GAAG;EAChCT,IAAI,EAAE,MAD0B;EAEhCC,UAAU,EAA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AC,CAAC;IAC/B;EACF;AACF,CAAC"
24
29
  }
@@ -28,8 +28,9 @@ export var quote = {
28
28
  var breaksBeforeCount = getBreaksNeededForEmptyLineBefore(state1.text, state1.selection.start);
29
29
  var breaksBefore = Array(breaksBeforeCount + 1).join('\n');
30
30
  var breaksAfterCount = getBreaksNeededForEmptyLineAfter(state1.text, state1.selection.end);
31
- var breaksAfter = Array(breaksAfterCount + 1).join('\n'); // Replaces the current selection with the quote mark up
31
+ var breaksAfter = Array(breaksAfterCount + 1).join('\n');
32
32
 
33
+ // Replaces the current selection with the quote mark up
33
34
  api.replaceSelection(breaksBefore + "> " + state1.selectedText + breaksAfter);
34
35
  var selectionStart = state1.selection.start + breaksBeforeCount + 2;
35
36
  var selectionEnd = selectionStart + state1.selectedText.length;
@@ -40,5 +40,5 @@
40
40
  "sourcesContent": [
41
41
  "import * as React from 'react';\nimport { ICommand, TextState, TextAreaTextApi } from './';\nimport {\n getBreaksNeededForEmptyLineBefore,\n getBreaksNeededForEmptyLineAfter,\n selectWord,\n} from '../utils/markdownUtils';\n\nexport const quote: ICommand = {\n name: 'quote',\n keyCommand: 'quote',\n shortcuts: 'ctrlcmd+q',\n buttonProps: { 'aria-label': 'Insert a quote (ctrl + q)', title: 'Insert a quote (ctrl + q)' },\n icon: (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 520 520\">\n <path\n fill=\"currentColor\"\n d=\"M520,95.75 L520,225.75 C520,364.908906 457.127578,437.050625 325.040469,472.443125 C309.577578,476.586875 294.396016,464.889922 294.396016,448.881641 L294.396016,414.457031 C294.396016,404.242891 300.721328,395.025078 310.328125,391.554687 C377.356328,367.342187 414.375,349.711094 414.375,274.5 L341.25,274.5 C314.325781,274.5 292.5,252.674219 292.5,225.75 L292.5,95.75 C292.5,68.8257812 314.325781,47 341.25,47 L471.25,47 C498.174219,47 520,68.8257812 520,95.75 Z M178.75,47 L48.75,47 C21.8257813,47 0,68.8257812 0,95.75 L0,225.75 C0,252.674219 21.8257813,274.5 48.75,274.5 L121.875,274.5 C121.875,349.711094 84.8563281,367.342187 17.828125,391.554687 C8.22132813,395.025078 1.89601563,404.242891 1.89601563,414.457031 L1.89601563,448.881641 C1.89601563,464.889922 17.0775781,476.586875 32.5404687,472.443125 C164.627578,437.050625 227.5,364.908906 227.5,225.75 L227.5,95.75 C227.5,68.8257812 205.674219,47 178.75,47 Z\"\n />\n </svg>\n ),\n execute: (state: TextState, api: TextAreaTextApi) => {\n // Adjust the selection to encompass the whole word if the caret is inside one\n const newSelectionRange = selectWord({ text: state.text, selection: state.selection });\n const state1 = api.setSelectionRange(newSelectionRange);\n const breaksBeforeCount = getBreaksNeededForEmptyLineBefore(state1.text, state1.selection.start);\n const breaksBefore = Array(breaksBeforeCount + 1).join('\\n');\n\n const breaksAfterCount = getBreaksNeededForEmptyLineAfter(state1.text, state1.selection.end);\n const breaksAfter = Array(breaksAfterCount + 1).join('\\n');\n\n // Replaces the current selection with the quote mark up\n api.replaceSelection(`${breaksBefore}> ${state1.selectedText}${breaksAfter}`);\n\n const selectionStart = state1.selection.start + breaksBeforeCount + 2;\n const selectionEnd = selectionStart + state1.selectedText.length;\n\n api.setSelectionRange({\n start: selectionStart,\n end: selectionEnd,\n });\n },\n};\n"
42
42
  ],
43
- "mappings": "AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAEA,SACEC,iCADF,EAEEC,gCAFF,EAGEC,UAHF,QAIO,wBAJP;;AAMA,OAAO,IAAMC,KAAe,GAAG;EAC7BC,IAAI,EAAE,OADuB;EAE7BC,UAAU,EAAE,OAFiB;EAG7BC,SAAS,EAAE,WAHkB;EAI7BC,WAAW,EAAE;IAAE,cAAc,2BAAhB;IAA6CC,KAAK,EAAE;EAApD,CAJgB;EAK7BC,IAAI,eACF;IAAK,KAAK,EAAC,IAAX;IAAgB,MAAM,EAAC,IAAvB;IAA4B,OAAO,EAAC,aAApC;IAAA,uBACE;MACE,IAAI,EAAC,cADP;MAEE,CAAC,EAAC;IAFJ;E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