@milkdown/crepe 7.11.1 → 7.12.0

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 (191) hide show
  1. package/lib/cjs/builder/builder.js +107 -0
  2. package/lib/cjs/builder/builder.js.map +1 -0
  3. package/lib/cjs/{index-CtTpZYVe.js → feature/block-edit/index.js} +165 -61
  4. package/lib/cjs/feature/block-edit/index.js.map +1 -0
  5. package/lib/cjs/feature/code-mirror/index.js +161 -0
  6. package/lib/cjs/feature/code-mirror/index.js.map +1 -0
  7. package/lib/cjs/feature/cursor/index.js +57 -0
  8. package/lib/cjs/feature/cursor/index.js.map +1 -0
  9. package/lib/cjs/feature/image-block/index.js +123 -0
  10. package/lib/cjs/feature/image-block/index.js.map +1 -0
  11. package/lib/cjs/{index-2icTTGim.js → feature/latex/index.js} +111 -24
  12. package/lib/cjs/feature/latex/index.js.map +1 -0
  13. package/lib/cjs/feature/link-tooltip/index.js +124 -0
  14. package/lib/cjs/feature/link-tooltip/index.js.map +1 -0
  15. package/lib/cjs/{index-Dw6lXgs6.js → feature/list-item/index.js} +39 -8
  16. package/lib/cjs/feature/list-item/index.js.map +1 -0
  17. package/lib/cjs/{index-B91KhPew.js → feature/placeholder/index.js} +46 -6
  18. package/lib/cjs/feature/placeholder/index.js.map +1 -0
  19. package/lib/cjs/{index-DEs_IHHy.js → feature/table/index.js} +78 -16
  20. package/lib/cjs/feature/table/index.js.map +1 -0
  21. package/lib/cjs/{index-k3lGvKiX.js → feature/toolbar/index.js} +133 -31
  22. package/lib/cjs/feature/toolbar/index.js.map +1 -0
  23. package/lib/cjs/index/index.js +2464 -0
  24. package/lib/cjs/index/index.js.map +1 -0
  25. package/lib/esm/builder/builder.js +105 -0
  26. package/lib/esm/builder/builder.js.map +1 -0
  27. package/lib/esm/{index-BEe1TpeS.js → feature/block-edit/index.js} +161 -57
  28. package/lib/esm/feature/block-edit/index.js.map +1 -0
  29. package/lib/esm/feature/code-mirror/index.js +159 -0
  30. package/lib/esm/feature/code-mirror/index.js.map +1 -0
  31. package/lib/esm/feature/cursor/index.js +55 -0
  32. package/lib/esm/feature/cursor/index.js.map +1 -0
  33. package/lib/esm/feature/image-block/index.js +121 -0
  34. package/lib/esm/feature/image-block/index.js.map +1 -0
  35. package/lib/esm/{index-ZGfGszIQ.js → feature/latex/index.js} +107 -20
  36. package/lib/esm/feature/latex/index.js.map +1 -0
  37. package/lib/esm/feature/link-tooltip/index.js +122 -0
  38. package/lib/esm/feature/link-tooltip/index.js.map +1 -0
  39. package/lib/esm/{index-E8UgFLeN.js → feature/list-item/index.js} +39 -8
  40. package/lib/esm/feature/list-item/index.js.map +1 -0
  41. package/lib/esm/{index-BCvtgOeI.js → feature/placeholder/index.js} +45 -5
  42. package/lib/esm/feature/placeholder/index.js.map +1 -0
  43. package/lib/esm/{index-CwMVnVeI.js → feature/table/index.js} +78 -16
  44. package/lib/esm/feature/table/index.js.map +1 -0
  45. package/lib/esm/{index-CTBg0aec.js → feature/toolbar/index.js} +128 -26
  46. package/lib/esm/feature/toolbar/index.js.map +1 -0
  47. package/lib/esm/index/index.js +2458 -0
  48. package/lib/esm/index/index.js.map +1 -0
  49. package/lib/tsconfig.tsbuildinfo +1 -1
  50. package/lib/types/builder.d.ts +2 -0
  51. package/lib/types/builder.d.ts.map +1 -0
  52. package/lib/types/core/builder.d.ts +23 -0
  53. package/lib/types/core/builder.d.ts.map +1 -0
  54. package/lib/types/core/crepe.d.ts +4 -15
  55. package/lib/types/core/crepe.d.ts.map +1 -1
  56. package/lib/types/core/index.d.ts +2 -1
  57. package/lib/types/core/index.d.ts.map +1 -1
  58. package/lib/types/core/slice.d.ts +6 -4
  59. package/lib/types/core/slice.d.ts.map +1 -1
  60. package/lib/types/default-config/index.d.ts +3 -0
  61. package/lib/types/default-config/index.d.ts.map +1 -0
  62. package/lib/types/feature/block-edit/handle/component.d.ts +2 -3
  63. package/lib/types/feature/block-edit/handle/component.d.ts.map +1 -1
  64. package/lib/types/feature/block-edit/index.d.ts +20 -20
  65. package/lib/types/feature/block-edit/index.d.ts.map +1 -1
  66. package/lib/types/feature/code-mirror/index.d.ts +7 -7
  67. package/lib/types/feature/code-mirror/index.d.ts.map +1 -1
  68. package/lib/types/feature/cursor/index.d.ts +1 -1
  69. package/lib/types/feature/cursor/index.d.ts.map +1 -1
  70. package/lib/types/feature/image-block/index.d.ts +9 -9
  71. package/lib/types/feature/image-block/index.d.ts.map +1 -1
  72. package/lib/types/feature/index.d.ts +2 -4
  73. package/lib/types/feature/index.d.ts.map +1 -1
  74. package/lib/types/feature/latex/index.d.ts +3 -3
  75. package/lib/types/feature/latex/index.d.ts.map +1 -1
  76. package/lib/types/feature/link-tooltip/index.d.ts +6 -6
  77. package/lib/types/feature/link-tooltip/index.d.ts.map +1 -1
  78. package/lib/types/feature/list-item/index.d.ts +5 -5
  79. package/lib/types/feature/list-item/index.d.ts.map +1 -1
  80. package/lib/types/feature/loader.d.ts +4 -0
  81. package/lib/types/feature/loader.d.ts.map +1 -0
  82. package/lib/types/feature/placeholder/index.d.ts +2 -2
  83. package/lib/types/feature/placeholder/index.d.ts.map +1 -1
  84. package/lib/types/feature/shared.d.ts +1 -2
  85. package/lib/types/feature/shared.d.ts.map +1 -1
  86. package/lib/types/feature/table/index.d.ts +11 -11
  87. package/lib/types/feature/table/index.d.ts.map +1 -1
  88. package/lib/types/feature/toolbar/index.d.ts +8 -8
  89. package/lib/types/feature/toolbar/index.d.ts.map +1 -1
  90. package/lib/types/icons/index.d.ts +1 -0
  91. package/lib/types/icons/index.d.ts.map +1 -1
  92. package/lib/types/index.d.ts +1 -1
  93. package/lib/types/index.d.ts.map +1 -1
  94. package/lib/types/utils/index.d.ts +0 -1
  95. package/lib/types/utils/index.d.ts.map +1 -1
  96. package/package.json +60 -3
  97. package/src/builder.ts +1 -0
  98. package/src/core/builder.ts +143 -0
  99. package/src/core/crepe.ts +14 -130
  100. package/src/core/index.ts +2 -1
  101. package/src/core/slice.ts +37 -8
  102. package/src/default-config/index.ts +25 -0
  103. package/src/feature/block-edit/handle/component.tsx +6 -8
  104. package/src/feature/block-edit/handle/index.ts +2 -2
  105. package/src/feature/block-edit/index.ts +23 -20
  106. package/src/feature/block-edit/menu/config.ts +19 -19
  107. package/src/feature/code-mirror/index.ts +32 -28
  108. package/src/feature/cursor/index.ts +10 -6
  109. package/src/feature/image-block/index.ts +19 -16
  110. package/src/feature/index.ts +2 -53
  111. package/src/feature/latex/index.ts +8 -10
  112. package/src/feature/latex/inline-tooltip/component.tsx +1 -1
  113. package/src/feature/link-tooltip/index.ts +13 -10
  114. package/src/feature/list-item/index.ts +11 -8
  115. package/src/feature/loader.ts +52 -0
  116. package/src/feature/placeholder/index.ts +5 -2
  117. package/src/feature/shared.ts +1 -3
  118. package/src/feature/table/index.ts +23 -23
  119. package/src/feature/toolbar/component.tsx +9 -9
  120. package/src/feature/toolbar/index.ts +14 -11
  121. package/src/icons/index.ts +1 -0
  122. package/src/index.ts +1 -1
  123. package/src/utils/index.ts +0 -8
  124. package/lib/cjs/confirm-CNveM9QH.js +0 -26
  125. package/lib/cjs/confirm-CNveM9QH.js.map +0 -1
  126. package/lib/cjs/edit-BUtBJHpV.js +0 -24
  127. package/lib/cjs/edit-BUtBJHpV.js.map +0 -1
  128. package/lib/cjs/functions-BAY51plB.js +0 -39
  129. package/lib/cjs/functions-BAY51plB.js.map +0 -1
  130. package/lib/cjs/image-BXLkOVnO.js +0 -24
  131. package/lib/cjs/image-BXLkOVnO.js.map +0 -1
  132. package/lib/cjs/index-2icTTGim.js.map +0 -1
  133. package/lib/cjs/index-B91KhPew.js.map +0 -1
  134. package/lib/cjs/index-BsrJn8Jp.js +0 -41
  135. package/lib/cjs/index-BsrJn8Jp.js.map +0 -1
  136. package/lib/cjs/index-C2CAbC2F.js +0 -26
  137. package/lib/cjs/index-C2CAbC2F.js.map +0 -1
  138. package/lib/cjs/index-CtTpZYVe.js.map +0 -1
  139. package/lib/cjs/index-DEs_IHHy.js.map +0 -1
  140. package/lib/cjs/index-DLIudQKW.js +0 -126
  141. package/lib/cjs/index-DLIudQKW.js.map +0 -1
  142. package/lib/cjs/index-Dw6lXgs6.js.map +0 -1
  143. package/lib/cjs/index-k3lGvKiX.js.map +0 -1
  144. package/lib/cjs/index-urTgNBfI.js +0 -202
  145. package/lib/cjs/index-urTgNBfI.js.map +0 -1
  146. package/lib/cjs/index-xbwf60wt.js +0 -15
  147. package/lib/cjs/index-xbwf60wt.js.map +0 -1
  148. package/lib/cjs/index-xbxqAqH2.js +0 -52
  149. package/lib/cjs/index-xbxqAqH2.js.map +0 -1
  150. package/lib/cjs/index.js +0 -20
  151. package/lib/cjs/index.js.map +0 -1
  152. package/lib/cjs/inline-latex-D0G71cGk.js +0 -54
  153. package/lib/cjs/inline-latex-D0G71cGk.js.map +0 -1
  154. package/lib/cjs/plus-XLomtlXf.js +0 -24
  155. package/lib/cjs/plus-XLomtlXf.js.map +0 -1
  156. package/lib/cjs/remove-Ba-ypwBf.js +0 -17
  157. package/lib/cjs/remove-Ba-ypwBf.js.map +0 -1
  158. package/lib/esm/confirm-DtE-HkVd.js +0 -24
  159. package/lib/esm/confirm-DtE-HkVd.js.map +0 -1
  160. package/lib/esm/edit-D--t_JAb.js +0 -22
  161. package/lib/esm/edit-D--t_JAb.js.map +0 -1
  162. package/lib/esm/functions-DlJPkGmE.js +0 -36
  163. package/lib/esm/functions-DlJPkGmE.js.map +0 -1
  164. package/lib/esm/image-DoB1o1sl.js +0 -22
  165. package/lib/esm/image-DoB1o1sl.js.map +0 -1
  166. package/lib/esm/index-BCvtgOeI.js.map +0 -1
  167. package/lib/esm/index-BEe1TpeS.js.map +0 -1
  168. package/lib/esm/index-BPG8iO8t.js +0 -12
  169. package/lib/esm/index-BPG8iO8t.js.map +0 -1
  170. package/lib/esm/index-BUBXHhHG.js +0 -39
  171. package/lib/esm/index-BUBXHhHG.js.map +0 -1
  172. package/lib/esm/index-Bvz1Yyiz.js +0 -24
  173. package/lib/esm/index-Bvz1Yyiz.js.map +0 -1
  174. package/lib/esm/index-C1aVAv1l.js +0 -124
  175. package/lib/esm/index-C1aVAv1l.js.map +0 -1
  176. package/lib/esm/index-CTBg0aec.js.map +0 -1
  177. package/lib/esm/index-ChR5Qhyf.js +0 -50
  178. package/lib/esm/index-ChR5Qhyf.js.map +0 -1
  179. package/lib/esm/index-CshFzSt2.js +0 -197
  180. package/lib/esm/index-CshFzSt2.js.map +0 -1
  181. package/lib/esm/index-CwMVnVeI.js.map +0 -1
  182. package/lib/esm/index-E8UgFLeN.js.map +0 -1
  183. package/lib/esm/index-ZGfGszIQ.js.map +0 -1
  184. package/lib/esm/index.js +0 -12
  185. package/lib/esm/index.js.map +0 -1
  186. package/lib/esm/inline-latex-C9IGAXXQ.js +0 -51
  187. package/lib/esm/inline-latex-C9IGAXXQ.js.map +0 -1
  188. package/lib/esm/plus-lrX0Q75O.js +0 -22
  189. package/lib/esm/plus-lrX0Q75O.js.map +0 -1
  190. package/lib/esm/remove-D3g0Cd6_.js +0 -15
  191. package/lib/esm/remove-D3g0Cd6_.js.map +0 -1
@@ -0,0 +1,2464 @@
1
+ 'use strict';
2
+
3
+ var lodashEs = require('lodash-es');
4
+ var languageData = require('@codemirror/language-data');
5
+ var themeOneDark = require('@codemirror/theme-one-dark');
6
+ var block = require('@milkdown/kit/plugin/block');
7
+ var ctx = require('@milkdown/kit/ctx');
8
+ var core = require('@milkdown/kit/core');
9
+ var commonmark = require('@milkdown/kit/preset/commonmark');
10
+ var prose = require('@milkdown/kit/prose');
11
+ var state = require('@milkdown/kit/prose/state');
12
+ var vue = require('vue');
13
+ var slash = require('@milkdown/kit/plugin/slash');
14
+ var utils = require('@milkdown/kit/utils');
15
+ var component = require('@milkdown/kit/component');
16
+ var imageBlock$1 = require('@milkdown/kit/component/image-block');
17
+ var gfm = require('@milkdown/kit/preset/gfm');
18
+ var transform = require('@milkdown/kit/prose/transform');
19
+ var commands = require('@codemirror/commands');
20
+ var view = require('@codemirror/view');
21
+ var codeBlock = require('@milkdown/kit/component/code-block');
22
+ var codemirror = require('codemirror');
23
+ var cursor$1 = require('@milkdown/kit/plugin/cursor');
24
+ var prosemirrorVirtualCursor = require('prosemirror-virtual-cursor');
25
+ var imageInline = require('@milkdown/kit/component/image-inline');
26
+ var katex = require('katex');
27
+ var tooltip = require('@milkdown/kit/plugin/tooltip');
28
+ var history = require('@milkdown/kit/prose/history');
29
+ var keymap = require('@milkdown/kit/prose/keymap');
30
+ var model = require('@milkdown/kit/prose/model');
31
+ var view$1 = require('@milkdown/kit/prose/view');
32
+ var inputrules = require('@milkdown/kit/prose/inputrules');
33
+ var remarkMath = require('remark-math');
34
+ var unistUtilVisit = require('unist-util-visit');
35
+ var linkTooltip$1 = require('@milkdown/kit/component/link-tooltip');
36
+ var listItemBlock = require('@milkdown/kit/component/list-item-block');
37
+ var tableBlock = require('@milkdown/kit/component/table-block');
38
+ var clsx = require('clsx');
39
+ var clipboard = require('@milkdown/kit/plugin/clipboard');
40
+ var history$1 = require('@milkdown/kit/plugin/history');
41
+ var indent = require('@milkdown/kit/plugin/indent');
42
+ var listener = require('@milkdown/kit/plugin/listener');
43
+ var trailing = require('@milkdown/kit/plugin/trailing');
44
+
45
+ var CrepeFeature = /* @__PURE__ */ ((CrepeFeature2) => {
46
+ CrepeFeature2["CodeMirror"] = "code-mirror";
47
+ CrepeFeature2["ListItem"] = "list-item";
48
+ CrepeFeature2["LinkTooltip"] = "link-tooltip";
49
+ CrepeFeature2["Cursor"] = "cursor";
50
+ CrepeFeature2["ImageBlock"] = "image-block";
51
+ CrepeFeature2["BlockEdit"] = "block-edit";
52
+ CrepeFeature2["Toolbar"] = "toolbar";
53
+ CrepeFeature2["Placeholder"] = "placeholder";
54
+ CrepeFeature2["Table"] = "table";
55
+ CrepeFeature2["Latex"] = "latex";
56
+ return CrepeFeature2;
57
+ })(CrepeFeature || {});
58
+ const defaultFeatures = {
59
+ ["cursor" /* Cursor */]: true,
60
+ ["list-item" /* ListItem */]: true,
61
+ ["link-tooltip" /* LinkTooltip */]: true,
62
+ ["image-block" /* ImageBlock */]: true,
63
+ ["block-edit" /* BlockEdit */]: true,
64
+ ["placeholder" /* Placeholder */]: true,
65
+ ["toolbar" /* Toolbar */]: true,
66
+ ["code-mirror" /* CodeMirror */]: true,
67
+ ["table" /* Table */]: true,
68
+ ["latex" /* Latex */]: true
69
+ };
70
+
71
+ const alignCenterIcon = `
72
+ <svg
73
+ xmlns="http://www.w3.org/2000/svg"
74
+ width="24"
75
+ height="24"
76
+ viewBox="0 0 24 24"
77
+ >
78
+ <path
79
+ d="M4.25 20.5C4.0375 20.5 3.85942 20.4281 3.71575 20.2843C3.57192 20.1404 3.5 19.9622 3.5 19.7498C3.5 19.5371 3.57192 19.359 3.71575 19.2155C3.85942 19.0718 4.0375 19 4.25 19H19.75C19.9625 19 20.1406 19.0719 20.2843 19.2158C20.4281 19.3596 20.5 19.5378 20.5 19.7502C20.5 19.9629 20.4281 20.141 20.2843 20.2845C20.1406 20.4282 19.9625 20.5 19.75 20.5H4.25ZM8.25 16.625C8.0375 16.625 7.85942 16.5531 7.71575 16.4093C7.57192 16.2654 7.5 16.0872 7.5 15.8748C7.5 15.6621 7.57192 15.484 7.71575 15.3405C7.85942 15.1968 8.0375 15.125 8.25 15.125H15.75C15.9625 15.125 16.1406 15.1969 16.2843 15.3408C16.4281 15.4846 16.5 15.6628 16.5 15.8753C16.5 16.0879 16.4281 16.266 16.2843 16.4095C16.1406 16.5532 15.9625 16.625 15.75 16.625H8.25ZM4.25 12.75C4.0375 12.75 3.85942 12.6781 3.71575 12.5343C3.57192 12.3904 3.5 12.2122 3.5 11.9998C3.5 11.7871 3.57192 11.609 3.71575 11.4655C3.85942 11.3218 4.0375 11.25 4.25 11.25H19.75C19.9625 11.25 20.1406 11.3219 20.2843 11.4658C20.4281 11.6096 20.5 11.7878 20.5 12.0003C20.5 12.2129 20.4281 12.391 20.2843 12.5345C20.1406 12.6782 19.9625 12.75 19.75 12.75H4.25ZM8.25 8.875C8.0375 8.875 7.85942 8.80308 7.71575 8.65925C7.57192 8.51542 7.5 8.33725 7.5 8.12475C7.5 7.91208 7.57192 7.734 7.71575 7.5905C7.85942 7.44683 8.0375 7.375 8.25 7.375H15.75C15.9625 7.375 16.1406 7.44692 16.2843 7.59075C16.4281 7.73458 16.5 7.91275 16.5 8.12525C16.5 8.33792 16.4281 8.516 16.2843 8.6595C16.1406 8.80317 15.9625 8.875 15.75 8.875H8.25ZM4.25 5C4.0375 5 3.85942 4.92808 3.71575 4.78425C3.57192 4.64042 3.5 4.46225 3.5 4.24975C3.5 4.03708 3.57192 3.859 3.71575 3.7155C3.85942 3.57183 4.0375 3.5 4.25 3.5H19.75C19.9625 3.5 20.1406 3.57192 20.2843 3.71575C20.4281 3.85958 20.5 4.03775 20.5 4.25025C20.5 4.46292 20.4281 4.641 20.2843 4.7845C20.1406 4.92817 19.9625 5 19.75 5H4.25Z"
80
+ />
81
+ </svg>
82
+ `;
83
+
84
+ const alignLeftIcon = `
85
+ <svg
86
+ xmlns="http://www.w3.org/2000/svg"
87
+ width="24"
88
+ height="24"
89
+ viewBox="0 0 24 24"
90
+ >
91
+ <path
92
+ d="M4.25 20.5C4.0375 20.5 3.85942 20.4281 3.71575 20.2843C3.57192 20.1404 3.5 19.9622 3.5 19.7498C3.5 19.5371 3.57192 19.359 3.71575 19.2155C3.85942 19.0718 4.0375 19 4.25 19H19.75C19.9625 19 20.1406 19.0719 20.2843 19.2158C20.4281 19.3596 20.5 19.5378 20.5 19.7502C20.5 19.9629 20.4281 20.141 20.2843 20.2845C20.1406 20.4282 19.9625 20.5 19.75 20.5H4.25ZM4.25 16.625C4.0375 16.625 3.85942 16.5531 3.71575 16.4093C3.57192 16.2654 3.5 16.0872 3.5 15.8748C3.5 15.6621 3.57192 15.484 3.71575 15.3405C3.85942 15.1968 4.0375 15.125 4.25 15.125H13.75C13.9625 15.125 14.1406 15.1969 14.2843 15.3408C14.4281 15.4846 14.5 15.6628 14.5 15.8753C14.5 16.0879 14.4281 16.266 14.2843 16.4095C14.1406 16.5532 13.9625 16.625 13.75 16.625H4.25ZM4.25 12.75C4.0375 12.75 3.85942 12.6781 3.71575 12.5343C3.57192 12.3904 3.5 12.2122 3.5 11.9998C3.5 11.7871 3.57192 11.609 3.71575 11.4655C3.85942 11.3218 4.0375 11.25 4.25 11.25H19.75C19.9625 11.25 20.1406 11.3219 20.2843 11.4658C20.4281 11.6096 20.5 11.7878 20.5 12.0003C20.5 12.2129 20.4281 12.391 20.2843 12.5345C20.1406 12.6782 19.9625 12.75 19.75 12.75H4.25ZM4.25 8.875C4.0375 8.875 3.85942 8.80308 3.71575 8.65925C3.57192 8.51542 3.5 8.33725 3.5 8.12475C3.5 7.91208 3.57192 7.734 3.71575 7.5905C3.85942 7.44683 4.0375 7.375 4.25 7.375H13.75C13.9625 7.375 14.1406 7.44692 14.2843 7.59075C14.4281 7.73458 14.5 7.91275 14.5 8.12525C14.5 8.33792 14.4281 8.516 14.2843 8.6595C14.1406 8.80317 13.9625 8.875 13.75 8.875H4.25ZM4.25 5C4.0375 5 3.85942 4.92808 3.71575 4.78425C3.57192 4.64042 3.5 4.46225 3.5 4.24975C3.5 4.03708 3.57192 3.859 3.71575 3.7155C3.85942 3.57183 4.0375 3.5 4.25 3.5H19.75C19.9625 3.5 20.1406 3.57192 20.2843 3.71575C20.4281 3.85958 20.5 4.03775 20.5 4.25025C20.5 4.46292 20.4281 4.641 20.2843 4.7845C20.1406 4.92817 19.9625 5 19.75 5H4.25Z"
93
+ />
94
+ </svg>
95
+ `;
96
+
97
+ const alignRightIcon = `
98
+ <svg
99
+ xmlns="http://www.w3.org/2000/svg"
100
+ width="24"
101
+ height="24"
102
+ viewBox="0 0 24 24"
103
+ >
104
+ <path
105
+ d="M4.25 5C4.0375 5 3.85942 4.92808 3.71575 4.78425C3.57192 4.64042 3.5 4.46225 3.5 4.24975C3.5 4.03708 3.57192 3.859 3.71575 3.7155C3.85942 3.57183 4.0375 3.5 4.25 3.5H19.75C19.9625 3.5 20.1406 3.57192 20.2843 3.71575C20.4281 3.85958 20.5 4.03775 20.5 4.25025C20.5 4.46292 20.4281 4.641 20.2843 4.7845C20.1406 4.92817 19.9625 5 19.75 5H4.25ZM10.25 8.875C10.0375 8.875 9.85942 8.80308 9.71575 8.65925C9.57192 8.51542 9.5 8.33725 9.5 8.12475C9.5 7.91208 9.57192 7.734 9.71575 7.5905C9.85942 7.44683 10.0375 7.375 10.25 7.375H19.75C19.9625 7.375 20.1406 7.44692 20.2843 7.59075C20.4281 7.73458 20.5 7.91275 20.5 8.12525C20.5 8.33792 20.4281 8.516 20.2843 8.6595C20.1406 8.80317 19.9625 8.875 19.75 8.875H10.25ZM4.25 12.75C4.0375 12.75 3.85942 12.6781 3.71575 12.5343C3.57192 12.3904 3.5 12.2122 3.5 11.9998C3.5 11.7871 3.57192 11.609 3.71575 11.4655C3.85942 11.3218 4.0375 11.25 4.25 11.25H19.75C19.9625 11.25 20.1406 11.3219 20.2843 11.4658C20.4281 11.6096 20.5 11.7878 20.5 12.0003C20.5 12.2129 20.4281 12.391 20.2843 12.5345C20.1406 12.6782 19.9625 12.75 19.75 12.75H4.25ZM10.25 16.625C10.0375 16.625 9.85942 16.5531 9.71575 16.4093C9.57192 16.2654 9.5 16.0872 9.5 15.8748C9.5 15.6621 9.57192 15.484 9.71575 15.3405C9.85942 15.1968 10.0375 15.125 10.25 15.125H19.75C19.9625 15.125 20.1406 15.1969 20.2843 15.3408C20.4281 15.4846 20.5 15.6628 20.5 15.8753C20.5 16.0879 20.4281 16.266 20.2843 16.4095C20.1406 16.5532 19.9625 16.625 19.75 16.625H10.25ZM4.25 20.5C4.0375 20.5 3.85942 20.4281 3.71575 20.2843C3.57192 20.1404 3.5 19.9622 3.5 19.7498C3.5 19.5371 3.57192 19.359 3.71575 19.2155C3.85942 19.0718 4.0375 19 4.25 19H19.75C19.9625 19 20.1406 19.0719 20.2843 19.2158C20.4281 19.3596 20.5 19.5378 20.5 19.7502C20.5 19.9629 20.4281 20.141 20.2843 20.2845C20.1406 20.4282 19.9625 20.5 19.75 20.5H4.25Z"
106
+ />
107
+ </svg>
108
+ `;
109
+
110
+ const boldIcon = `
111
+ <svg
112
+ xmlns="http://www.w3.org/2000/svg"
113
+ width="24"
114
+ height="24"
115
+ viewBox="0 0 24 24"
116
+ >
117
+ <path
118
+ d="M8.85758 18.625C8.4358 18.625 8.07715 18.4772 7.78163 18.1817C7.48613 17.8862 7.33838 17.5275 7.33838 17.1058V6.8942C7.33838 6.47242 7.48613 6.11377 7.78163 5.81825C8.07715 5.52275 8.4358 5.375 8.85758 5.375H12.1999C13.2191 5.375 14.1406 5.69231 14.9643 6.32693C15.788 6.96154 16.1999 7.81603 16.1999 8.89038C16.1999 9.63779 16.0194 10.2471 15.6585 10.7183C15.2976 11.1894 14.9088 11.5314 14.4922 11.7442C15.005 11.9211 15.4947 12.2708 15.9614 12.7933C16.428 13.3157 16.6614 14.0192 16.6614 14.9038C16.6614 16.182 16.1902 17.1217 15.2479 17.723C14.3056 18.3243 13.3563 18.625 12.3999 18.625H8.85758ZM9.4883 16.6327H12.3191C13.1063 16.6327 13.6627 16.4141 13.9884 15.9769C14.314 15.5397 14.4768 15.1205 14.4768 14.7192C14.4768 14.3179 14.314 13.8987 13.9884 13.4615C13.6627 13.0243 13.0909 12.8057 12.273 12.8057H9.4883V16.6327ZM9.4883 10.875H12.0826C12.6903 10.875 13.172 10.7013 13.5278 10.3539C13.8836 10.0064 14.0615 9.59037 14.0615 9.10575C14.0615 8.59035 13.8733 8.16918 13.497 7.84225C13.1207 7.51533 12.6595 7.35188 12.1133 7.35188H9.4883V10.875Z"
119
+ />
120
+ </svg>
121
+ `;
122
+
123
+ const bulletIcon = `
124
+ <svg
125
+ xmlns="http://www.w3.org/2000/svg"
126
+ width="24"
127
+ height="24"
128
+ viewBox="0 0 24 24"
129
+ >
130
+ <g clip-path="url(#clip0_952_6527)">
131
+ <circle cx="12" cy="12" r="3" />
132
+ </g>
133
+ <defs>
134
+ <clipPath id="clip0_952_6527">
135
+ <rect width="24" height="24" />
136
+ </clipPath>
137
+ </defs>
138
+ </svg>
139
+ `;
140
+
141
+ const bulletListIcon = `
142
+ <svg
143
+ xmlns="http://www.w3.org/2000/svg"
144
+ width="24"
145
+ height="24"
146
+ viewBox="0 0 24 24"
147
+ >
148
+ <g clip-path="url(#clip0_977_8070)">
149
+ <path
150
+ d="M4 10.5C3.17 10.5 2.5 11.17 2.5 12C2.5 12.83 3.17 13.5 4 13.5C4.83 13.5 5.5 12.83 5.5 12C5.5 11.17 4.83 10.5 4 10.5ZM4 4.5C3.17 4.5 2.5 5.17 2.5 6C2.5 6.83 3.17 7.5 4 7.5C4.83 7.5 5.5 6.83 5.5 6C5.5 5.17 4.83 4.5 4 4.5ZM4 16.5C3.17 16.5 2.5 17.18 2.5 18C2.5 18.82 3.18 19.5 4 19.5C4.82 19.5 5.5 18.82 5.5 18C5.5 17.18 4.83 16.5 4 16.5ZM8 19H20C20.55 19 21 18.55 21 18C21 17.45 20.55 17 20 17H8C7.45 17 7 17.45 7 18C7 18.55 7.45 19 8 19ZM8 13H20C20.55 13 21 12.55 21 12C21 11.45 20.55 11 20 11H8C7.45 11 7 11.45 7 12C7 12.55 7.45 13 8 13ZM7 6C7 6.55 7.45 7 8 7H20C20.55 7 21 6.55 21 6C21 5.45 20.55 5 20 5H8C7.45 5 7 5.45 7 6Z"
151
+ />
152
+ </g>
153
+ <defs>
154
+ <clipPath id="clip0_977_8070">
155
+ <rect width="24" height="24" />
156
+ </clipPath>
157
+ </defs>
158
+ </svg>
159
+ `;
160
+
161
+ const captionIcon = `
162
+ <svg
163
+ xmlns="http://www.w3.org/2000/svg"
164
+ width="32"
165
+ height="32"
166
+ viewBox="0 0 24 24"
167
+ >
168
+ <path
169
+ fill="currentColor"
170
+ d="M9 22a1 1 0 0 1-1-1v-3H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6.1l-3.7 3.71c-.2.19-.45.29-.7.29zm1-6v3.08L13.08 16H20V4H4v12z"
171
+ />
172
+ </svg>
173
+ `;
174
+
175
+ const checkBoxCheckedIcon = `
176
+ <svg
177
+ xmlns="http://www.w3.org/2000/svg"
178
+ width="24"
179
+ height="24"
180
+ viewBox="0 0 24 24"
181
+ >
182
+ <g clip-path="url(#clip0_1803_1151)">
183
+ <path
184
+ d="M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM10.71 16.29C10.32 16.68 9.69 16.68 9.3 16.29L5.71 12.7C5.32 12.31 5.32 11.68 5.71 11.29C6.1 10.9 6.73 10.9 7.12 11.29L10 14.17L16.88 7.29C17.27 6.9 17.9 6.9 18.29 7.29C18.68 7.68 18.68 8.31 18.29 8.7L10.71 16.29Z"
185
+ />
186
+ </g>
187
+ <defs>
188
+ <clipPath id="clip0_1803_1151">
189
+ <rect width="24" height="24" />
190
+ </clipPath>
191
+ </defs>
192
+ </svg>
193
+ `;
194
+
195
+ const checkBoxUncheckedIcon = `
196
+ <svg
197
+ xmlns="http://www.w3.org/2000/svg"
198
+ width="24"
199
+ height="24"
200
+ viewBox="0 0 24 24"
201
+ >
202
+ <g clip-path="url(#clip0_1803_535)">
203
+ <path
204
+ d="M18 19H6C5.45 19 5 18.55 5 18V6C5 5.45 5.45 5 6 5H18C18.55 5 19 5.45 19 6V18C19 18.55 18.55 19 18 19ZM19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3Z"
205
+ />
206
+ </g>
207
+ <defs>
208
+ <clipPath id="clip0_1803_535">
209
+ <rect width="24" height="24" />
210
+ </clipPath>
211
+ </defs>
212
+ </svg>
213
+ `;
214
+
215
+ const chevronDownIcon = `
216
+ <svg
217
+ xmlns="http://www.w3.org/2000/svg"
218
+ fill="none"
219
+ viewBox="0 0 24 24"
220
+ stroke-width="1.5"
221
+ stroke="currentColor"
222
+ class="w-6 h-6"
223
+ >
224
+ <path
225
+ stroke-linecap="round"
226
+ stroke-linejoin="round"
227
+ d="M19.5 8.25l-7.5 7.5-7.5-7.5"
228
+ />
229
+ </svg>
230
+ `;
231
+
232
+ const clearIcon = `
233
+ <svg
234
+ xmlns="http://www.w3.org/2000/svg"
235
+ width="24"
236
+ height="24"
237
+ viewBox="0 0 24 24"
238
+ >
239
+ <g clip-path="url(#clip0_1098_15553)">
240
+ <path
241
+ d="M18.3007 5.70973C17.9107 5.31973 17.2807 5.31973 16.8907 5.70973L12.0007 10.5897L7.1107 5.69973C6.7207 5.30973 6.0907 5.30973 5.7007 5.69973C5.3107 6.08973 5.3107 6.71973 5.7007 7.10973L10.5907 11.9997L5.7007 16.8897C5.3107 17.2797 5.3107 17.9097 5.7007 18.2997C6.0907 18.6897 6.7207 18.6897 7.1107 18.2997L12.0007 13.4097L16.8907 18.2997C17.2807 18.6897 17.9107 18.6897 18.3007 18.2997C18.6907 17.9097 18.6907 17.2797 18.3007 16.8897L13.4107 11.9997L18.3007 7.10973C18.6807 6.72973 18.6807 6.08973 18.3007 5.70973Z"
242
+ />
243
+ </g>
244
+ <defs>
245
+ <clipPath id="clip0_1098_15553">
246
+ <rect width="24" height="24" />
247
+ </clipPath>
248
+ </defs>
249
+ </svg>
250
+ `;
251
+
252
+ const codeIcon = `
253
+ <svg
254
+ xmlns="http://www.w3.org/2000/svg"
255
+ width="24"
256
+ height="24"
257
+ viewBox="0 0 24 24"
258
+ >
259
+ <g clip-path="url(#clip0_977_8081)">
260
+ <path
261
+ d="M9.4 16.6L4.8 12L9.4 7.4L8 6L2 12L8 18L9.4 16.6ZM14.6 16.6L19.2 12L14.6 7.4L16 6L22 12L16 18L14.6 16.6Z"
262
+ />
263
+ </g>
264
+ <defs>
265
+ <clipPath id="clip0_977_8081">
266
+ <rect width="24" height="24" />
267
+ </clipPath>
268
+ </defs>
269
+ </svg>
270
+ `;
271
+
272
+ const confirmIcon = `
273
+ <svg
274
+ xmlns="http://www.w3.org/2000/svg"
275
+ width="24"
276
+ height="24"
277
+ viewBox="0 0 24 24"
278
+ fill="none"
279
+ >
280
+ <g clip-path="url(#clip0_1013_1606)">
281
+ <path
282
+ d="M9.00012 16.1998L5.50012 12.6998C5.11012 12.3098 4.49012 12.3098 4.10012 12.6998C3.71012 13.0898 3.71012 13.7098 4.10012 14.0998L8.29012 18.2898C8.68012 18.6798 9.31012 18.6798 9.70012 18.2898L20.3001 7.69982C20.6901 7.30982 20.6901 6.68982 20.3001 6.29982C19.9101 5.90982 19.2901 5.90982 18.9001 6.29982L9.00012 16.1998Z"
283
+ fill="#817567"
284
+ />
285
+ </g>
286
+ <defs>
287
+ <clipPath id="clip0_1013_1606">
288
+ <rect width="24" height="24" />
289
+ </clipPath>
290
+ </defs>
291
+ </svg>
292
+ `;
293
+
294
+ const copyIcon = `
295
+ <svg
296
+ xmlns="http://www.w3.org/2000/svg"
297
+ height="24px"
298
+ viewBox="0 -960 960 960"
299
+ width="24px"
300
+ fill="none"
301
+ >
302
+ <path
303
+ d="M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z"
304
+ />
305
+ </svg>
306
+ `;
307
+
308
+ const dividerIcon = `
309
+ <svg
310
+ xmlns="http://www.w3.org/2000/svg"
311
+ width="24"
312
+ height="24"
313
+ viewBox="0 0 24 24"
314
+ >
315
+ <g clip-path="url(#clip0_977_7900)">
316
+ <path
317
+ fill-rule="evenodd"
318
+ clip-rule="evenodd"
319
+ d="M19 13H5C4.45 13 4 12.55 4 12C4 11.45 4.45 11 5 11H19C19.55 11 20 11.45 20 12C20 12.55 19.55 13 19 13Z"
320
+ />
321
+ </g>
322
+ <defs>
323
+ <clipPath id="clip0_977_7900">
324
+ <rect width="24" height="24" />
325
+ </clipPath>
326
+ </defs>
327
+ </svg>
328
+ `;
329
+
330
+ const dragHandleIcon = `
331
+ <svg
332
+ xmlns="http://www.w3.org/2000/svg"
333
+ width="16"
334
+ height="16"
335
+ viewBox="0 0 16 16"
336
+ >
337
+ <path
338
+ d="M3.5 9.83366C3.35833 9.83366 3.23961 9.78571 3.14383 9.68983C3.04794 9.59394 3 9.47516 3 9.33349C3 9.19171 3.04794 9.07299 3.14383 8.97733C3.23961 8.88155 3.35833 8.83366 3.5 8.83366H12.5C12.6417 8.83366 12.7604 8.8816 12.8562 8.97749C12.9521 9.07338 13 9.19216 13 9.33383C13 9.4756 12.9521 9.59433 12.8562 9.68999C12.7604 9.78577 12.6417 9.83366 12.5 9.83366H3.5ZM3.5 7.16699C3.35833 7.16699 3.23961 7.11905 3.14383 7.02316C3.04794 6.92727 3 6.80849 3 6.66683C3 6.52505 3.04794 6.40633 3.14383 6.31066C3.23961 6.21488 3.35833 6.16699 3.5 6.16699H12.5C12.6417 6.16699 12.7604 6.21494 12.8562 6.31083C12.9521 6.40671 13 6.52549 13 6.66716C13 6.80894 12.9521 6.92766 12.8562 7.02333C12.7604 7.1191 12.6417 7.16699 12.5 7.16699H3.5Z"
339
+ />
340
+ </svg>
341
+ `;
342
+
343
+ const editIcon = `
344
+ <svg
345
+ xmlns="http://www.w3.org/2000/svg"
346
+ width="24"
347
+ height="24"
348
+ viewBox="0 0 24 24"
349
+ >
350
+ <g clip-path="url(#clip0_1013_1585)">
351
+ <path
352
+ d="M14.06 9.02L14.98 9.94L5.92 19H5V18.08L14.06 9.02ZM17.66 3C17.41 3 17.15 3.1 16.96 3.29L15.13 5.12L18.88 8.87L20.71 7.04C21.1 6.65 21.1 6.02 20.71 5.63L18.37 3.29C18.17 3.09 17.92 3 17.66 3ZM14.06 6.19L3 17.25V21H6.75L17.81 9.94L14.06 6.19Z"
353
+ />
354
+ </g>
355
+ <defs>
356
+ <clipPath id="clip0_1013_1585">
357
+ <rect width="24" height="24" />
358
+ </clipPath>
359
+ </defs>
360
+ </svg>
361
+ `;
362
+
363
+ const h1Icon = `
364
+ <svg
365
+ xmlns="http://www.w3.org/2000/svg"
366
+ width="24"
367
+ height="24"
368
+ viewBox="0 0 24 24"
369
+ >
370
+ <g clip-path="url(#clip0_992_5553)">
371
+ <path
372
+ d="M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM19 19H5V5H19V19ZM12 17H14V7H10V9H12V17Z"
373
+ />
374
+ </g>
375
+ <defs>
376
+ <clipPath id="clip0_992_5553">
377
+ <rect width="24" height="24" />
378
+ </clipPath>
379
+ </defs>
380
+ </svg>
381
+ `;
382
+
383
+ const h2Icon = `
384
+ <svg
385
+ xmlns="http://www.w3.org/2000/svg"
386
+ width="24"
387
+ height="24"
388
+ viewBox="0 0 24 24"
389
+ >
390
+ <g clip-path="url(#clip0_992_5559)">
391
+ <path
392
+ d="M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM19 19H5V5H19V19ZM15 15H11V13H13C14.1 13 15 12.11 15 11V9C15 7.89 14.1 7 13 7H9V9H13V11H11C9.9 11 9 11.89 9 13V17H15V15Z"
393
+ />
394
+ </g>
395
+ <defs>
396
+ <clipPath id="clip0_992_5559">
397
+ <rect width="24" height="24" />
398
+ </clipPath>
399
+ </defs>
400
+ </svg>
401
+ `;
402
+
403
+ const h3Icon = `
404
+ <svg
405
+ xmlns="http://www.w3.org/2000/svg"
406
+ width="24"
407
+ height="24"
408
+ viewBox="0 0 24 24"
409
+ >
410
+ <g clip-path="url(#clip0_992_5565)">
411
+ <path
412
+ d="M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM19 19H5V5H19V19ZM15 15V13.5C15 12.67 14.33 12 13.5 12C14.33 12 15 11.33 15 10.5V9C15 7.89 14.1 7 13 7H9V9H13V11H11V13H13V15H9V17H13C14.1 17 15 16.11 15 15Z"
413
+ />
414
+ </g>
415
+ <defs>
416
+ <clipPath id="clip0_992_5565">
417
+ <rect width="24" height="24" />
418
+ </clipPath>
419
+ </defs>
420
+ </svg>
421
+ `;
422
+
423
+ const h4Icon = `
424
+ <svg
425
+ xmlns="http://www.w3.org/2000/svg"
426
+ width="24"
427
+ height="24"
428
+ viewBox="0 0 24 24"
429
+ >
430
+ <g clip-path="url(#clip0_977_7757)">
431
+ <path
432
+ d="M19.04 3H5.04004C3.94004 3 3.04004 3.9 3.04004 5V19C3.04004 20.1 3.94004 21 5.04004 21H19.04C20.14 21 21.04 20.1 21.04 19V5C21.04 3.9 20.14 3 19.04 3ZM19.04 19H5.04004V5H19.04V19ZM13.04 17H15.04V7H13.04V11H11.04V7H9.04004V13H13.04V17Z"
433
+ />
434
+ </g>
435
+ <defs>
436
+ <clipPath id="clip0_977_7757">
437
+ <rect width="24" height="24" />
438
+ </clipPath>
439
+ </defs>
440
+ </svg>
441
+ `;
442
+
443
+ const h5Icon = `
444
+ <svg
445
+ xmlns="http://www.w3.org/2000/svg"
446
+ width="24"
447
+ height="24"
448
+ viewBox="0 0 24 24"
449
+ >
450
+ <g clip-path="url(#clip0_977_7760)">
451
+ <path
452
+ d="M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM19 19H5V5H19V19ZM15 15V13C15 11.89 14.1 11 13 11H11V9H15V7H9V13H13V15H9V17H13C14.1 17 15 16.11 15 15Z"
453
+ />
454
+ </g>
455
+ <defs>
456
+ <clipPath id="clip0_977_7760">
457
+ <rect width="24" height="24" />
458
+ </clipPath>
459
+ </defs>
460
+ </svg>
461
+ `;
462
+
463
+ const h6Icon = `
464
+ <svg
465
+ xmlns="http://www.w3.org/2000/svg"
466
+ width="24"
467
+ height="24"
468
+ viewBox="0 0 24 24"
469
+ >
470
+ <g clip-path="url(#clip0_977_7763)">
471
+ <path
472
+ d="M11 17H13C14.1 17 15 16.11 15 15V13C15 11.89 14.1 11 13 11H11V9H15V7H11C9.9 7 9 7.89 9 9V15C9 16.11 9.9 17 11 17ZM11 13H13V15H11V13ZM19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM19 19H5V5H19V19Z"
473
+ />
474
+ </g>
475
+ <defs>
476
+ <clipPath id="clip0_977_7763">
477
+ <rect width="24" height="24" />
478
+ </clipPath>
479
+ </defs>
480
+ </svg>
481
+ `;
482
+
483
+ const imageIcon = `
484
+ <svg
485
+ xmlns="http://www.w3.org/2000/svg"
486
+ width="24"
487
+ height="24"
488
+ viewBox="0 0 24 24"
489
+ >
490
+ <g clip-path="url(#clip0_977_8075)">
491
+ <path
492
+ d="M19 5V19H5V5H19ZM19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM14.14 11.86L11.14 15.73L9 13.14L6 17H18L14.14 11.86Z"
493
+ />
494
+ </g>
495
+ <defs>
496
+ <clipPath id="clip0_977_8075">
497
+ <rect width="24" height="24" />
498
+ </clipPath>
499
+ </defs>
500
+ </svg>
501
+ `;
502
+
503
+ const italicIcon = `
504
+ <svg
505
+ xmlns="http://www.w3.org/2000/svg"
506
+ width="24"
507
+ height="24"
508
+ viewBox="0 0 24 24"
509
+ >
510
+ <path
511
+ d="M6.29811 18.625C6.04505 18.625 5.83115 18.5375 5.65641 18.3626C5.48166 18.1877 5.39429 17.9736 5.39429 17.7203C5.39429 17.467 5.48166 17.2532 5.65641 17.0788C5.83115 16.9045 6.04505 16.8173 6.29811 16.8173H9.21159L12.452 7.18265H9.53851C9.28545 7.18265 9.07155 7.0952 8.89681 6.9203C8.72206 6.7454 8.63469 6.5313 8.63469 6.278C8.63469 6.02472 8.72206 5.81089 8.89681 5.63652C9.07155 5.46217 9.28545 5.375 9.53851 5.375H16.8847C17.1377 5.375 17.3516 5.46245 17.5264 5.63735C17.7011 5.81225 17.7885 6.02634 17.7885 6.27962C17.7885 6.53293 17.7011 6.74676 17.5264 6.92113C17.3516 7.09548 17.1377 7.18265 16.8847 7.18265H14.2789L11.0385 16.8173H13.6443C13.8973 16.8173 14.1112 16.9048 14.286 17.0797C14.4607 17.2546 14.5481 17.4687 14.5481 17.722C14.5481 17.9752 14.4607 18.1891 14.286 18.3634C14.1112 18.5378 13.8973 18.625 13.6443 18.625H6.29811Z"
512
+ />
513
+ </svg>
514
+ `;
515
+
516
+ const linkIcon = `
517
+ <svg
518
+ xmlns="http://www.w3.org/2000/svg"
519
+ width="24"
520
+ height="24"
521
+ viewBox="0 0 24 24"
522
+ >
523
+ <path
524
+ d="M17.0385 19.5003V16.5388H14.0769V15.0388H17.0385V12.0773H18.5384V15.0388H21.5V16.5388H18.5384V19.5003H17.0385ZM10.8077 16.5388H7.03845C5.78282 16.5388 4.7125 16.0963 3.8275 15.2114C2.9425 14.3266 2.5 13.2564 2.5 12.0009C2.5 10.7454 2.9425 9.67504 3.8275 8.78979C4.7125 7.90454 5.78282 7.46191 7.03845 7.46191H10.8077V8.96186H7.03845C6.1987 8.96186 5.48235 9.25834 4.8894 9.85129C4.29645 10.4442 3.99998 11.1606 3.99998 12.0003C3.99998 12.8401 4.29645 13.5564 4.8894 14.1494C5.48235 14.7423 6.1987 15.0388 7.03845 15.0388H10.8077V16.5388ZM8.25 12.7503V11.2504H15.75V12.7503H8.25ZM21.5 12.0003H20C20 11.1606 19.7035 10.4442 19.1106 9.85129C18.5176 9.25834 17.8013 8.96186 16.9615 8.96186H13.1923V7.46191H16.9615C18.2171 7.46191 19.2875 7.90441 20.1725 8.78939C21.0575 9.67439 21.5 10.7447 21.5 12.0003Z"
525
+ />
526
+ </svg>
527
+ `;
528
+
529
+ const menuIcon = `
530
+ <svg
531
+ xmlns="http://www.w3.org/2000/svg"
532
+ width="24"
533
+ height="24"
534
+ viewBox="0 0 24 24"
535
+ >
536
+ <g clip-path="url(#clip0_971_7680)">
537
+ <path
538
+ d="M11 18C11 19.1 10.1 20 9 20C7.9 20 7 19.1 7 18C7 16.9 7.9 16 9 16C10.1 16 11 16.9 11 18ZM9 10C7.9 10 7 10.9 7 12C7 13.1 7.9 14 9 14C10.1 14 11 13.1 11 12C11 10.9 10.1 10 9 10ZM9 4C7.9 4 7 4.9 7 6C7 7.1 7.9 8 9 8C10.1 8 11 7.1 11 6C11 4.9 10.1 4 9 4ZM15 8C16.1 8 17 7.1 17 6C17 4.9 16.1 4 15 4C13.9 4 13 4.9 13 6C13 7.1 13.9 8 15 8ZM15 10C13.9 10 13 10.9 13 12C13 13.1 13.9 14 15 14C16.1 14 17 13.1 17 12C17 10.9 16.1 10 15 10ZM15 16C13.9 16 13 16.9 13 18C13 19.1 13.9 20 15 20C16.1 20 17 19.1 17 18C17 16.9 16.1 16 15 16Z"
539
+ />
540
+ </g>
541
+ <defs>
542
+ <clipPath id="clip0_971_7680">
543
+ <rect width="24" height="24" />
544
+ </clipPath>
545
+ </defs>
546
+ </svg>
547
+ `;
548
+
549
+ const orderedListIcon = `
550
+ <svg
551
+ xmlns="http://www.w3.org/2000/svg"
552
+ width="24"
553
+ height="24"
554
+ viewBox="0 0 24 24"
555
+ >
556
+ <g clip-path="url(#clip0_977_8067)">
557
+ <path
558
+ d="M8 7H20C20.55 7 21 6.55 21 6C21 5.45 20.55 5 20 5H8C7.45 5 7 5.45 7 6C7 6.55 7.45 7 8 7ZM20 17H8C7.45 17 7 17.45 7 18C7 18.55 7.45 19 8 19H20C20.55 19 21 18.55 21 18C21 17.45 20.55 17 20 17ZM20 11H8C7.45 11 7 11.45 7 12C7 12.55 7.45 13 8 13H20C20.55 13 21 12.55 21 12C21 11.45 20.55 11 20 11ZM4.5 16H2.5C2.22 16 2 16.22 2 16.5C2 16.78 2.22 17 2.5 17H4V17.5H3.5C3.22 17.5 3 17.72 3 18C3 18.28 3.22 18.5 3.5 18.5H4V19H2.5C2.22 19 2 19.22 2 19.5C2 19.78 2.22 20 2.5 20H4.5C4.78 20 5 19.78 5 19.5V16.5C5 16.22 4.78 16 4.5 16ZM2.5 5H3V7.5C3 7.78 3.22 8 3.5 8C3.78 8 4 7.78 4 7.5V4.5C4 4.22 3.78 4 3.5 4H2.5C2.22 4 2 4.22 2 4.5C2 4.78 2.22 5 2.5 5ZM4.5 10H2.5C2.22 10 2 10.22 2 10.5C2 10.78 2.22 11 2.5 11H3.8L2.12 12.96C2.04 13.05 2 13.17 2 13.28V13.5C2 13.78 2.22 14 2.5 14H4.5C4.78 14 5 13.78 5 13.5C5 13.22 4.78 13 4.5 13H3.2L4.88 11.04C4.96 10.95 5 10.83 5 10.72V10.5C5 10.22 4.78 10 4.5 10Z"
559
+ />
560
+ </g>
561
+ <defs>
562
+ <clipPath id="clip0_977_8067">
563
+ <rect width="24" height="24" />
564
+ </clipPath>
565
+ </defs>
566
+ </svg>
567
+ `;
568
+
569
+ const plusIcon = `
570
+ <svg
571
+ xmlns="http://www.w3.org/2000/svg"
572
+ width="24"
573
+ height="24"
574
+ viewBox="0 0 24 24"
575
+ >
576
+ <g clip-path="url(#clip0_971_7676)">
577
+ <path
578
+ d="M18 13H13V18C13 18.55 12.55 19 12 19C11.45 19 11 18.55 11 18V13H6C5.45 13 5 12.55 5 12C5 11.45 5.45 11 6 11H11V6C11 5.45 11.45 5 12 5C12.55 5 13 5.45 13 6V11H18C18.55 11 19 11.45 19 12C19 12.55 18.55 13 18 13Z"
579
+ />
580
+ </g>
581
+ <defs>
582
+ <clipPath id="clip0_971_7676">
583
+ <rect width="24" height="24" />
584
+ </clipPath>
585
+ </defs>
586
+ </svg>
587
+ `;
588
+
589
+ const quoteIcon = `
590
+ <svg
591
+ xmlns="http://www.w3.org/2000/svg"
592
+ width="24"
593
+ height="24"
594
+ viewBox="0 0 24 24"
595
+ >
596
+ <g clip-path="url(#clip0_977_7897)">
597
+ <path
598
+ d="M7.17 17C7.68 17 8.15 16.71 8.37 16.26L9.79 13.42C9.93 13.14 10 12.84 10 12.53V8C10 7.45 9.55 7 9 7H5C4.45 7 4 7.45 4 8V12C4 12.55 4.45 13 5 13H7L5.97 15.06C5.52 15.95 6.17 17 7.17 17ZM17.17 17C17.68 17 18.15 16.71 18.37 16.26L19.79 13.42C19.93 13.14 20 12.84 20 12.53V8C20 7.45 19.55 7 19 7H15C14.45 7 14 7.45 14 8V12C14 12.55 14.45 13 15 13H17L15.97 15.06C15.52 15.95 16.17 17 17.17 17Z"
599
+ />
600
+ </g>
601
+ <defs>
602
+ <clipPath id="clip0_977_7897">
603
+ <rect width="24" height="24" />
604
+ </clipPath>
605
+ </defs>
606
+ </svg>
607
+ `;
608
+
609
+ const removeIcon = `
610
+ <svg
611
+ xmlns="http://www.w3.org/2000/svg"
612
+ width="24"
613
+ height="24"
614
+ viewBox="0 0 24 24"
615
+ >
616
+ <path
617
+ d="M7.30775 20.4997C6.81058 20.4997 6.385 20.3227 6.031 19.9687C5.677 19.6147 5.5 19.1892 5.5 18.692V5.99973H5.25C5.0375 5.99973 4.85942 5.92782 4.71575 5.78398C4.57192 5.64015 4.5 5.46198 4.5 5.24948C4.5 5.03682 4.57192 4.85873 4.71575 4.71523C4.85942 4.57157 5.0375 4.49973 5.25 4.49973H9C9 4.2549 9.08625 4.04624 9.25875 3.87374C9.43108 3.7014 9.63967 3.61523 9.8845 3.61523H14.1155C14.3603 3.61523 14.5689 3.7014 14.7413 3.87374C14.9138 4.04624 15 4.2549 15 4.49973H18.75C18.9625 4.49973 19.1406 4.57165 19.2843 4.71548C19.4281 4.85932 19.5 5.03748 19.5 5.24998C19.5 5.46265 19.4281 5.64073 19.2843 5.78423C19.1406 5.9279 18.9625 5.99973 18.75 5.99973H18.5V18.692C18.5 19.1892 18.323 19.6147 17.969 19.9687C17.615 20.3227 17.1894 20.4997 16.6923 20.4997H7.30775ZM17 5.99973H7V18.692C7 18.7818 7.02883 18.8556 7.0865 18.9132C7.14417 18.9709 7.21792 18.9997 7.30775 18.9997H16.6923C16.7821 18.9997 16.8558 18.9709 16.9135 18.9132C16.9712 18.8556 17 18.7818 17 18.692V5.99973ZM10.1543 16.9997C10.3668 16.9997 10.5448 16.9279 10.6885 16.7842C10.832 16.6404 10.9037 16.4622 10.9037 16.2497V8.74973C10.9037 8.53723 10.8318 8.35907 10.688 8.21523C10.5443 8.07157 10.3662 7.99973 10.1535 7.99973C9.941 7.99973 9.76292 8.07157 9.61925 8.21523C9.47575 8.35907 9.404 8.53723 9.404 8.74973V16.2497C9.404 16.4622 9.47583 16.6404 9.6195 16.7842C9.76333 16.9279 9.94158 16.9997 10.1543 16.9997ZM13.8465 16.9997C14.059 16.9997 14.2371 16.9279 14.3807 16.7842C14.5243 16.6404 14.596 16.4622 14.596 16.2497V8.74973C14.596 8.53723 14.5242 8.35907 14.3805 8.21523C14.2367 8.07157 14.0584 7.99973 13.8458 7.99973C13.6333 7.99973 13.4552 8.07157 13.3115 8.21523C13.168 8.35907 13.0962 8.53723 13.0962 8.74973V16.2497C13.0962 16.4622 13.1682 16.6404 13.312 16.7842C13.4557 16.9279 13.6338 16.9997 13.8465 16.9997Z"
618
+ />
619
+ </svg>
620
+ `;
621
+
622
+ const searchIcon = `
623
+ <svg
624
+ xmlns="http://www.w3.org/2000/svg"
625
+ fill="none"
626
+ viewBox="0 0 24 24"
627
+ stroke-width="1.5"
628
+ stroke="currentColor"
629
+ class="w-6 h-6"
630
+ >
631
+ <path
632
+ stroke-linecap="round"
633
+ stroke-linejoin="round"
634
+ d="M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"
635
+ />
636
+ </svg>
637
+ `;
638
+
639
+ const strikethroughIcon = `
640
+ <svg
641
+ xmlns="http://www.w3.org/2000/svg"
642
+ width="24"
643
+ height="24"
644
+ viewBox="0 0 24 24"
645
+ >
646
+ <path
647
+ d="M3.25 13.7404C3.0375 13.7404 2.85938 13.6684 2.71563 13.5246C2.57188 13.3808 2.5 13.2026 2.5 12.99C2.5 12.7774 2.57188 12.5993 2.71563 12.4558C2.85938 12.3122 3.0375 12.2404 3.25 12.2404H20.75C20.9625 12.2404 21.1406 12.3123 21.2843 12.4561C21.4281 12.5999 21.5 12.7781 21.5 12.9907C21.5 13.2033 21.4281 13.3814 21.2843 13.525C21.1406 13.6686 20.9625 13.7404 20.75 13.7404H3.25ZM10.9423 10.2596V6.62495H6.5673C6.2735 6.62495 6.02377 6.52201 5.8181 6.31613C5.61245 6.11026 5.50963 5.86027 5.50963 5.56615C5.50963 5.27205 5.61245 5.02083 5.8181 4.8125C6.02377 4.60417 6.2735 4.5 6.5673 4.5H17.4423C17.7361 4.5 17.9858 4.60294 18.1915 4.80883C18.3971 5.01471 18.5 5.2647 18.5 5.5588C18.5 5.85292 18.3971 6.10413 18.1915 6.31245C17.9858 6.52078 17.7361 6.62495 17.4423 6.62495H13.0673V10.2596H10.9423ZM10.9423 15.7211H13.0673V18.4423C13.0673 18.7361 12.9643 18.9858 12.7584 19.1915C12.5526 19.3971 12.3026 19.5 12.0085 19.5C11.7144 19.5 11.4631 19.3962 11.2548 19.1887C11.0465 18.9811 10.9423 18.7291 10.9423 18.4327V15.7211Z"
648
+ />
649
+ </svg>
650
+ `;
651
+
652
+ const tableIcon = `
653
+ <svg
654
+ xmlns="http://www.w3.org/2000/svg"
655
+ width="24"
656
+ height="24"
657
+ viewBox="0 0 24 24"
658
+ >
659
+ <g clip-path="url(#clip0_977_8078)">
660
+ <path
661
+ d="M20 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H20C21.1 21 22 20.1 22 19V5C22 3.9 21.1 3 20 3ZM20 5V8H5V5H20ZM15 19H10V10H15V19ZM5 10H8V19H5V10ZM17 19V10H20V19H17Z"
662
+ />
663
+ </g>
664
+ <defs>
665
+ <clipPath id="clip0_977_8078">
666
+ <rect width="24" height="24" />
667
+ </clipPath>
668
+ </defs>
669
+ </svg>
670
+ `;
671
+
672
+ const textIcon = `
673
+ <svg
674
+ xmlns="http://www.w3.org/2000/svg"
675
+ width="24"
676
+ height="24"
677
+ viewBox="0 0 24 24"
678
+ >
679
+ <g clip-path="url(#clip0_992_5547)">
680
+ <path
681
+ d="M5 5.5C5 6.33 5.67 7 6.5 7H10.5V17.5C10.5 18.33 11.17 19 12 19C12.83 19 13.5 18.33 13.5 17.5V7H17.5C18.33 7 19 6.33 19 5.5C19 4.67 18.33 4 17.5 4H6.5C5.67 4 5 4.67 5 5.5Z"
682
+ />
683
+ </g>
684
+ <defs>
685
+ <clipPath id="clip0_992_5547">
686
+ <rect width="24" height="24" />
687
+ </clipPath>
688
+ </defs>
689
+ </svg>
690
+ `;
691
+
692
+ const todoListIcon = `
693
+ <svg
694
+ xmlns="http://www.w3.org/2000/svg"
695
+ width="24"
696
+ height="24"
697
+ viewBox="0 0 24 24"
698
+ >
699
+ <path
700
+ d="M5.66936 16.3389L9.39244 12.6158C9.54115 12.4671 9.71679 12.3937 9.91936 12.3957C10.1219 12.3976 10.2975 12.4761 10.4463 12.6312C10.5847 12.7823 10.654 12.9585 10.654 13.1599C10.654 13.3613 10.5847 13.5363 10.4463 13.6851L6.32704 17.8197C6.14627 18.0004 5.93538 18.0908 5.69436 18.0908C5.45333 18.0908 5.24243 18.0004 5.06166 17.8197L3.01744 15.7754C2.87899 15.637 2.81136 15.4629 2.81456 15.2533C2.81776 15.0437 2.88859 14.8697 3.02706 14.7312C3.16551 14.5928 3.34008 14.5235 3.55076 14.5235C3.76144 14.5235 3.93494 14.5928 4.07126 14.7312L5.66936 16.3389ZM5.66936 8.72359L9.39244 5.00049C9.54115 4.85177 9.71679 4.77838 9.91936 4.78031C10.1219 4.78223 10.2975 4.86075 10.4463 5.01586C10.5847 5.16691 10.654 5.34314 10.654 5.54454C10.654 5.74592 10.5847 5.92097 10.4463 6.06969L6.32704 10.2043C6.14627 10.3851 5.93538 10.4755 5.69436 10.4755C5.45333 10.4755 5.24243 10.3851 5.06166 10.2043L3.01744 8.16009C2.87899 8.02162 2.81136 7.84759 2.81456 7.63799C2.81776 7.42837 2.88859 7.25433 3.02706 7.11586C3.16551 6.97741 3.34008 6.90819 3.55076 6.90819C3.76144 6.90819 3.93494 6.97741 4.07126 7.11586L5.66936 8.72359ZM13.7597 16.5581C13.5472 16.5581 13.3691 16.4862 13.2253 16.3424C13.0816 16.1986 13.0097 16.0204 13.0097 15.8078C13.0097 15.5952 13.0816 15.4171 13.2253 15.2735C13.3691 15.13 13.5472 15.0582 13.7597 15.0582H20.7597C20.9722 15.0582 21.1503 15.1301 21.2941 15.2739C21.4378 15.4177 21.5097 15.5959 21.5097 15.8085C21.5097 16.0211 21.4378 16.1992 21.2941 16.3427C21.1503 16.4863 20.9722 16.5581 20.7597 16.5581H13.7597ZM13.7597 8.94276C13.5472 8.94276 13.3691 8.87085 13.2253 8.72704C13.0816 8.58324 13.0097 8.40504 13.0097 8.19244C13.0097 7.97985 13.0816 7.80177 13.2253 7.65819C13.3691 7.5146 13.5472 7.44281 13.7597 7.44281H20.7597C20.9722 7.44281 21.1503 7.51471 21.2941 7.65851C21.4378 7.80233 21.5097 7.98053 21.5097 8.19311C21.5097 8.40571 21.4378 8.5838 21.2941 8.72739C21.1503 8.87097 20.9722 8.94276 20.7597 8.94276H13.7597Z"
701
+ />
702
+ </svg>
703
+ `;
704
+
705
+ const functionsIcon = `
706
+ <svg
707
+ xmlns="http://www.w3.org/2000/svg"
708
+ width="32"
709
+ height="32"
710
+ viewBox="0 0 24 24"
711
+ >
712
+ <path
713
+ fill="currentColor"
714
+ d="M7 19v-.808L13.096 12L7 5.808V5h10v1.25H9.102L14.727 12l-5.625 5.77H17V19z"
715
+ />
716
+ </svg>
717
+ `;
718
+
719
+ const visibilityOffIcon = `
720
+ <svg
721
+ xmlns="http://www.w3.org/2000/svg"
722
+ height="24px"
723
+ viewBox="0 -960 960 960"
724
+ width="24px"
725
+ >
726
+ <path
727
+ d="m644-428-58-58q9-47-27-88t-93-32l-58-58q17-8 34.5-12t37.5-4q75 0 127.5 52.5T660-500q0 20-4 37.5T644-428Zm128 126-58-56q38-29 67.5-63.5T832-500q-50-101-143.5-160.5T480-720q-29 0-57 4t-55 12l-62-62q41-17 84-25.5t90-8.5q151 0 269 83.5T920-500q-23 59-60.5 109.5T772-302Zm20 246L624-222q-35 11-70.5 16.5T480-200q-151 0-269-83.5T40-500q21-53 53-98.5t73-81.5L56-792l56-56 736 736-56 56ZM222-624q-29 26-53 57t-41 67q50 101 143.5 160.5T480-280q20 0 39-2.5t39-5.5l-36-38q-11 3-21 4.5t-21 1.5q-75 0-127.5-52.5T300-500q0-11 1.5-21t4.5-21l-84-82Zm319 93Zm-151 75Z"
728
+ />
729
+ </svg>
730
+ `;
731
+
732
+ const defaultConfig = {
733
+ [CrepeFeature.CodeMirror]: {
734
+ theme: themeOneDark.oneDark,
735
+ languages: languageData.languages,
736
+ expandIcon: chevronDownIcon,
737
+ searchIcon,
738
+ clearSearchIcon: clearIcon,
739
+ searchPlaceholder: "Search language",
740
+ noResultText: "No result",
741
+ previewToggleIcon: (previewOnlyMode) => previewOnlyMode ? editIcon : visibilityOffIcon
742
+ }
743
+ };
744
+
745
+ const FeaturesCtx = ctx.createSlice([], "FeaturesCtx");
746
+ const CrepeCtx = ctx.createSlice({}, "CrepeCtx");
747
+ function useCrepe(ctx) {
748
+ return ctx.get("CrepeCtx");
749
+ }
750
+ function useCrepeFeatures(ctx) {
751
+ return ctx.use("FeaturesCtx");
752
+ }
753
+ function crepeFeatureConfig(feature) {
754
+ return (ctx) => {
755
+ useCrepeFeatures(ctx).update((features) => {
756
+ if (features.includes(feature)) {
757
+ return features;
758
+ }
759
+ return [...features, feature];
760
+ });
761
+ };
762
+ }
763
+
764
+ function isInCodeBlock(selection) {
765
+ const type = selection.$from.parent.type;
766
+ return type.name === "code_block";
767
+ }
768
+ function isInList(selection) {
769
+ var _a;
770
+ const type = (_a = selection.$from.node(selection.$from.depth - 1)) == null ? void 0 : _a.type;
771
+ return (type == null ? void 0 : type.name) === "list_item";
772
+ }
773
+
774
+ var __typeError$5 = (msg) => {
775
+ throw TypeError(msg);
776
+ };
777
+ var __accessCheck$5 = (obj, member, msg) => member.has(obj) || __typeError$5("Cannot " + msg);
778
+ var __privateGet$5 = (obj, member, getter) => (__accessCheck$5(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
779
+ var __privateAdd$5 = (obj, member, value) => member.has(obj) ? __typeError$5("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
780
+ var __privateSet$5 = (obj, member, value, setter) => (__accessCheck$5(obj, member, "write to private field"), member.set(obj, value), value);
781
+ var _groups, _getGroupInstance;
782
+ class GroupBuilder {
783
+ constructor() {
784
+ __privateAdd$5(this, _groups, []);
785
+ this.clear = () => {
786
+ __privateSet$5(this, _groups, []);
787
+ return this;
788
+ };
789
+ __privateAdd$5(this, _getGroupInstance, (group) => {
790
+ const groupInstance = {
791
+ group,
792
+ addItem: (key, item) => {
793
+ const data = { key, ...item };
794
+ group.items.push(data);
795
+ return groupInstance;
796
+ },
797
+ clear: () => {
798
+ group.items = [];
799
+ return groupInstance;
800
+ }
801
+ };
802
+ return groupInstance;
803
+ });
804
+ this.addGroup = (key, label) => {
805
+ const items = [];
806
+ const group = {
807
+ key,
808
+ label,
809
+ items
810
+ };
811
+ __privateGet$5(this, _groups).push(group);
812
+ return __privateGet$5(this, _getGroupInstance).call(this, group);
813
+ };
814
+ this.getGroup = (key) => {
815
+ const group = __privateGet$5(this, _groups).find((group2) => group2.key === key);
816
+ if (!group) throw new Error(`Group with key ${key} not found`);
817
+ return __privateGet$5(this, _getGroupInstance).call(this, group);
818
+ };
819
+ this.build = () => {
820
+ return __privateGet$5(this, _groups);
821
+ };
822
+ }
823
+ }
824
+ _groups = new WeakMap();
825
+ _getGroupInstance = new WeakMap();
826
+
827
+ function clearRange(tr) {
828
+ const { $from, $to } = tr.selection;
829
+ const { pos: from } = $from;
830
+ const { pos: to } = $to;
831
+ tr = tr.deleteRange(from - $from.node().content.size, to);
832
+ return tr;
833
+ }
834
+ function setBlockType(tr, nodeType, attrs = null) {
835
+ const { from, to } = tr.selection;
836
+ return tr.setBlockType(from, to, nodeType, attrs);
837
+ }
838
+ function wrapInBlockType(tr, nodeType, attrs = null) {
839
+ const { $from, $to } = tr.selection;
840
+ const range = $from.blockRange($to);
841
+ const wrapping = range && transform.findWrapping(range, nodeType, attrs);
842
+ if (!wrapping) return null;
843
+ return tr.wrap(range, wrapping);
844
+ }
845
+ function addBlockType(tr, nodeType, attrs = null) {
846
+ const node = nodeType.createAndFill(attrs);
847
+ if (!node) return null;
848
+ return tr.replaceSelectionWith(node);
849
+ }
850
+ function clearContentAndSetBlockType(nodeType, attrs = null) {
851
+ return (state, dispatch) => {
852
+ if (dispatch) {
853
+ const tr = setBlockType(clearRange(state.tr), nodeType, attrs);
854
+ dispatch(tr.scrollIntoView());
855
+ }
856
+ return true;
857
+ };
858
+ }
859
+ function clearContentAndWrapInBlockType(nodeType, attrs = null) {
860
+ return (state, dispatch) => {
861
+ const tr = wrapInBlockType(clearRange(state.tr), nodeType, attrs);
862
+ if (!tr) return false;
863
+ if (dispatch) dispatch(tr.scrollIntoView());
864
+ return true;
865
+ };
866
+ }
867
+ function clearContentAndAddBlockType(nodeType, attrs = null) {
868
+ return (state, dispatch) => {
869
+ const tr = addBlockType(clearRange(state.tr), nodeType, attrs);
870
+ if (!tr) return false;
871
+ if (dispatch) dispatch(tr.scrollIntoView());
872
+ return true;
873
+ };
874
+ }
875
+
876
+ function getGroups(filter, config, ctx) {
877
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J;
878
+ const flags = ctx && useCrepeFeatures(ctx).get();
879
+ const isLatexEnabled = flags == null ? void 0 : flags.includes(CrepeFeature.Latex);
880
+ const isImageBlockEnabled = flags == null ? void 0 : flags.includes(CrepeFeature.ImageBlock);
881
+ const isTableEnabled = flags == null ? void 0 : flags.includes(CrepeFeature.Table);
882
+ const groupBuilder = new GroupBuilder();
883
+ groupBuilder.addGroup("text", (_a = config == null ? void 0 : config.slashMenuTextGroupLabel) != null ? _a : "Text").addItem("text", {
884
+ label: (_b = config == null ? void 0 : config.slashMenuTextLabel) != null ? _b : "Text",
885
+ icon: (_c = config == null ? void 0 : config.slashMenuTextIcon) != null ? _c : textIcon,
886
+ onRun: (ctx2) => {
887
+ const view = ctx2.get(core.editorViewCtx);
888
+ const { dispatch, state } = view;
889
+ const command = clearContentAndSetBlockType(commonmark.paragraphSchema.type(ctx2));
890
+ command(state, dispatch);
891
+ }
892
+ }).addItem("h1", {
893
+ label: (_d = config == null ? void 0 : config.slashMenuH1Label) != null ? _d : "Heading 1",
894
+ icon: (_e = config == null ? void 0 : config.slashMenuH1Icon) != null ? _e : h1Icon,
895
+ onRun: (ctx2) => {
896
+ const view = ctx2.get(core.editorViewCtx);
897
+ const { dispatch, state } = view;
898
+ const command = clearContentAndSetBlockType(commonmark.headingSchema.type(ctx2), {
899
+ level: 1
900
+ });
901
+ command(state, dispatch);
902
+ }
903
+ }).addItem("h2", {
904
+ label: (_f = config == null ? void 0 : config.slashMenuH2Label) != null ? _f : "Heading 2",
905
+ icon: (_g = config == null ? void 0 : config.slashMenuH2Icon) != null ? _g : h2Icon,
906
+ onRun: (ctx2) => {
907
+ const view = ctx2.get(core.editorViewCtx);
908
+ const { dispatch, state } = view;
909
+ const command = clearContentAndSetBlockType(commonmark.headingSchema.type(ctx2), {
910
+ level: 2
911
+ });
912
+ command(state, dispatch);
913
+ }
914
+ }).addItem("h3", {
915
+ label: (_h = config == null ? void 0 : config.slashMenuH3Label) != null ? _h : "Heading 3",
916
+ icon: (_i = config == null ? void 0 : config.slashMenuH3Icon) != null ? _i : h3Icon,
917
+ onRun: (ctx2) => {
918
+ const view = ctx2.get(core.editorViewCtx);
919
+ const { dispatch, state } = view;
920
+ const command = clearContentAndSetBlockType(commonmark.headingSchema.type(ctx2), {
921
+ level: 3
922
+ });
923
+ command(state, dispatch);
924
+ }
925
+ }).addItem("h4", {
926
+ label: (_j = config == null ? void 0 : config.slashMenuH4Label) != null ? _j : "Heading 4",
927
+ icon: (_k = config == null ? void 0 : config.slashMenuH4Icon) != null ? _k : h4Icon,
928
+ onRun: (ctx2) => {
929
+ const view = ctx2.get(core.editorViewCtx);
930
+ const { dispatch, state } = view;
931
+ const command = clearContentAndSetBlockType(commonmark.headingSchema.type(ctx2), {
932
+ level: 4
933
+ });
934
+ command(state, dispatch);
935
+ }
936
+ }).addItem("h5", {
937
+ label: (_l = config == null ? void 0 : config.slashMenuH5Label) != null ? _l : "Heading 5",
938
+ icon: (_m = config == null ? void 0 : config.slashMenuH5Icon) != null ? _m : h5Icon,
939
+ onRun: (ctx2) => {
940
+ const view = ctx2.get(core.editorViewCtx);
941
+ const { dispatch, state } = view;
942
+ const command = clearContentAndSetBlockType(commonmark.headingSchema.type(ctx2), {
943
+ level: 5
944
+ });
945
+ command(state, dispatch);
946
+ }
947
+ }).addItem("h6", {
948
+ label: (_n = config == null ? void 0 : config.slashMenuH6Label) != null ? _n : "Heading 6",
949
+ icon: (_o = config == null ? void 0 : config.slashMenuH6Icon) != null ? _o : h6Icon,
950
+ onRun: (ctx2) => {
951
+ const view = ctx2.get(core.editorViewCtx);
952
+ const { dispatch, state } = view;
953
+ const command = clearContentAndSetBlockType(commonmark.headingSchema.type(ctx2), {
954
+ level: 6
955
+ });
956
+ command(state, dispatch);
957
+ }
958
+ }).addItem("quote", {
959
+ label: (_p = config == null ? void 0 : config.slashMenuQuoteLabel) != null ? _p : "Quote",
960
+ icon: (_q = config == null ? void 0 : config.slashMenuQuoteIcon) != null ? _q : quoteIcon,
961
+ onRun: (ctx2) => {
962
+ const view = ctx2.get(core.editorViewCtx);
963
+ const { dispatch, state } = view;
964
+ const command = clearContentAndWrapInBlockType(
965
+ commonmark.blockquoteSchema.type(ctx2)
966
+ );
967
+ command(state, dispatch);
968
+ }
969
+ }).addItem("divider", {
970
+ label: (_r = config == null ? void 0 : config.slashMenuDividerLabel) != null ? _r : "Divider",
971
+ icon: (_s = config == null ? void 0 : config.slashMenuDividerIcon) != null ? _s : dividerIcon,
972
+ onRun: (ctx2) => {
973
+ const view = ctx2.get(core.editorViewCtx);
974
+ const { dispatch, state } = view;
975
+ const command = clearContentAndAddBlockType(commonmark.hrSchema.type(ctx2));
976
+ command(state, dispatch);
977
+ }
978
+ });
979
+ groupBuilder.addGroup("list", (_t = config == null ? void 0 : config.slashMenuListGroupLabel) != null ? _t : "List").addItem("bullet-list", {
980
+ label: (_u = config == null ? void 0 : config.slashMenuBulletListLabel) != null ? _u : "Bullet List",
981
+ icon: (_v = config == null ? void 0 : config.slashMenuBulletListIcon) != null ? _v : bulletListIcon,
982
+ onRun: (ctx2) => {
983
+ const view = ctx2.get(core.editorViewCtx);
984
+ const { dispatch, state } = view;
985
+ const command = clearContentAndWrapInBlockType(
986
+ commonmark.bulletListSchema.type(ctx2)
987
+ );
988
+ command(state, dispatch);
989
+ }
990
+ }).addItem("ordered-list", {
991
+ label: (_w = config == null ? void 0 : config.slashMenuOrderedListLabel) != null ? _w : "Ordered List",
992
+ icon: (_x = config == null ? void 0 : config.slashMenuOrderedListIcon) != null ? _x : orderedListIcon,
993
+ onRun: (ctx2) => {
994
+ const view = ctx2.get(core.editorViewCtx);
995
+ const { dispatch, state } = view;
996
+ const command = clearContentAndWrapInBlockType(
997
+ commonmark.orderedListSchema.type(ctx2)
998
+ );
999
+ command(state, dispatch);
1000
+ }
1001
+ }).addItem("todo-list", {
1002
+ label: (_y = config == null ? void 0 : config.slashMenuTaskListLabel) != null ? _y : "Todo List",
1003
+ icon: (_z = config == null ? void 0 : config.slashMenuTaskListIcon) != null ? _z : todoListIcon,
1004
+ onRun: (ctx2) => {
1005
+ const view = ctx2.get(core.editorViewCtx);
1006
+ const { dispatch, state } = view;
1007
+ const command = clearContentAndWrapInBlockType(
1008
+ commonmark.listItemSchema.type(ctx2),
1009
+ { checked: false }
1010
+ );
1011
+ command(state, dispatch);
1012
+ }
1013
+ });
1014
+ const advancedGroup = groupBuilder.addGroup(
1015
+ "advanced",
1016
+ (_A = config == null ? void 0 : config.slashMenuAdvancedGroupLabel) != null ? _A : "Advanced"
1017
+ );
1018
+ if (isImageBlockEnabled) {
1019
+ advancedGroup.addItem("image", {
1020
+ label: (_B = config == null ? void 0 : config.slashMenuImageLabel) != null ? _B : "Image",
1021
+ icon: (_C = config == null ? void 0 : config.slashMenuImageIcon) != null ? _C : imageIcon,
1022
+ onRun: (ctx2) => {
1023
+ const view = ctx2.get(core.editorViewCtx);
1024
+ const { dispatch, state } = view;
1025
+ const command = clearContentAndAddBlockType(imageBlock$1.imageBlockSchema.type(ctx2));
1026
+ command(state, dispatch);
1027
+ }
1028
+ });
1029
+ }
1030
+ advancedGroup.addItem("code", {
1031
+ label: (_D = config == null ? void 0 : config.slashMenuCodeBlockLabel) != null ? _D : "Code",
1032
+ icon: (_E = config == null ? void 0 : config.slashMenuCodeBlockIcon) != null ? _E : codeIcon,
1033
+ onRun: (ctx2) => {
1034
+ const view = ctx2.get(core.editorViewCtx);
1035
+ const { dispatch, state } = view;
1036
+ const command = clearContentAndAddBlockType(commonmark.codeBlockSchema.type(ctx2));
1037
+ command(state, dispatch);
1038
+ }
1039
+ });
1040
+ if (isTableEnabled) {
1041
+ advancedGroup.addItem("table", {
1042
+ label: (_F = config == null ? void 0 : config.slashMenuTableLabel) != null ? _F : "Table",
1043
+ icon: (_G = config == null ? void 0 : config.slashMenuTableIcon) != null ? _G : tableIcon,
1044
+ onRun: (ctx2) => {
1045
+ const view = ctx2.get(core.editorViewCtx);
1046
+ const { dispatch, state: state$1 } = view;
1047
+ let { tr } = state$1;
1048
+ tr = clearRange(tr);
1049
+ const from = tr.selection.from;
1050
+ const table = gfm.createTable(ctx2, 3, 3);
1051
+ tr = tr.replaceSelectionWith(table);
1052
+ dispatch(tr);
1053
+ requestAnimationFrame(() => {
1054
+ const docSize = view.state.doc.content.size;
1055
+ const $pos = view.state.doc.resolve(
1056
+ from > docSize ? docSize : from < 0 ? 0 : from
1057
+ );
1058
+ const selection = state.TextSelection.near($pos);
1059
+ const tr2 = view.state.tr;
1060
+ tr2.setSelection(selection);
1061
+ dispatch(tr2.scrollIntoView());
1062
+ });
1063
+ }
1064
+ });
1065
+ }
1066
+ if (isLatexEnabled) {
1067
+ advancedGroup.addItem("math", {
1068
+ label: (_H = config == null ? void 0 : config.slashMenuMathLabel) != null ? _H : "Math",
1069
+ icon: (_I = config == null ? void 0 : config.slashMenuMathIcon) != null ? _I : functionsIcon,
1070
+ onRun: (ctx2) => {
1071
+ const view = ctx2.get(core.editorViewCtx);
1072
+ const { dispatch, state } = view;
1073
+ const command = clearContentAndAddBlockType(commonmark.codeBlockSchema.type(ctx2), {
1074
+ language: "LaTex"
1075
+ });
1076
+ command(state, dispatch);
1077
+ }
1078
+ });
1079
+ }
1080
+ (_J = config == null ? void 0 : config.buildMenu) == null ? void 0 : _J.call(config, groupBuilder);
1081
+ let groups = groupBuilder.build();
1082
+ if (filter) {
1083
+ groups = groups.map((group) => {
1084
+ const items2 = group.items.filter(
1085
+ (item) => item.label.toLowerCase().includes(filter.toLowerCase())
1086
+ );
1087
+ return {
1088
+ ...group,
1089
+ items: items2
1090
+ };
1091
+ }).filter((group) => group.items.length > 0);
1092
+ }
1093
+ const items = groups.flatMap((groups2) => groups2.items);
1094
+ items.forEach((item, index) => {
1095
+ Object.assign(item, { index });
1096
+ });
1097
+ groups.reduce((acc, group) => {
1098
+ const end = acc + group.items.length;
1099
+ Object.assign(group, {
1100
+ range: [acc, end]
1101
+ });
1102
+ return end;
1103
+ }, 0);
1104
+ return {
1105
+ groups,
1106
+ size: items.length
1107
+ };
1108
+ }
1109
+
1110
+ const Menu = vue.defineComponent({
1111
+ props: {
1112
+ ctx: {
1113
+ type: Object,
1114
+ required: true
1115
+ },
1116
+ show: {
1117
+ type: Object,
1118
+ required: true
1119
+ },
1120
+ filter: {
1121
+ type: Object,
1122
+ required: true
1123
+ },
1124
+ hide: {
1125
+ type: Function,
1126
+ required: true
1127
+ },
1128
+ config: {
1129
+ type: Object,
1130
+ required: false
1131
+ }
1132
+ },
1133
+ setup({ ctx, show, filter, hide, config }) {
1134
+ const host = vue.ref();
1135
+ const groupInfo = vue.computed(() => getGroups(filter.value, config, ctx));
1136
+ const hoverIndex = vue.ref(0);
1137
+ const prevMousePosition = vue.ref({ x: -999, y: -999 });
1138
+ const onPointerMove = (e) => {
1139
+ const { x, y } = e;
1140
+ prevMousePosition.value = { x, y };
1141
+ };
1142
+ vue.watch([groupInfo, show], () => {
1143
+ const { size } = groupInfo.value;
1144
+ if (size === 0 && show.value) hide();
1145
+ else if (hoverIndex.value >= size) hoverIndex.value = 0;
1146
+ });
1147
+ const onHover = (index, after) => {
1148
+ const prevHoverIndex = hoverIndex.value;
1149
+ const next = typeof index === "function" ? index(prevHoverIndex) : index;
1150
+ after == null ? void 0 : after(next);
1151
+ hoverIndex.value = next;
1152
+ };
1153
+ const scrollToIndex = (index) => {
1154
+ var _a, _b;
1155
+ const target = (_a = host.value) == null ? void 0 : _a.querySelector(
1156
+ `[data-index="${index}"]`
1157
+ );
1158
+ const scrollRoot = (_b = host.value) == null ? void 0 : _b.querySelector(".menu-groups");
1159
+ if (!target || !scrollRoot) return;
1160
+ scrollRoot.scrollTop = target.offsetTop - scrollRoot.offsetTop;
1161
+ };
1162
+ const runByIndex = (index) => {
1163
+ const item = groupInfo.value.groups.flatMap((group) => group.items).at(index);
1164
+ if (item && ctx) item.onRun(ctx);
1165
+ hide();
1166
+ };
1167
+ const onKeydown = (e) => {
1168
+ const { size, groups } = groupInfo.value;
1169
+ if (e.key === "Escape") {
1170
+ e.preventDefault();
1171
+ hide == null ? void 0 : hide();
1172
+ return;
1173
+ }
1174
+ if (e.key === "ArrowDown") {
1175
+ e.preventDefault();
1176
+ return onHover(
1177
+ (index) => index < size - 1 ? index + 1 : index,
1178
+ scrollToIndex
1179
+ );
1180
+ }
1181
+ if (e.key === "ArrowUp") {
1182
+ e.preventDefault();
1183
+ return onHover(
1184
+ (index) => index <= 0 ? index : index - 1,
1185
+ scrollToIndex
1186
+ );
1187
+ }
1188
+ if (e.key === "ArrowLeft") {
1189
+ e.preventDefault();
1190
+ return onHover((index) => {
1191
+ const group = groups.find(
1192
+ (group2) => group2.range[0] <= index && group2.range[1] > index
1193
+ );
1194
+ if (!group) return index;
1195
+ const prevGroup = groups[groups.indexOf(group) - 1];
1196
+ if (!prevGroup) return index;
1197
+ return prevGroup.range[1] - 1;
1198
+ }, scrollToIndex);
1199
+ }
1200
+ if (e.key === "ArrowRight") {
1201
+ e.preventDefault();
1202
+ return onHover((index) => {
1203
+ const group = groups.find(
1204
+ (group2) => group2.range[0] <= index && group2.range[1] > index
1205
+ );
1206
+ if (!group) return index;
1207
+ const nextGroup = groups[groups.indexOf(group) + 1];
1208
+ if (!nextGroup) return index;
1209
+ return nextGroup.range[0];
1210
+ }, scrollToIndex);
1211
+ }
1212
+ if (e.key === "Enter") {
1213
+ e.preventDefault();
1214
+ runByIndex(hoverIndex.value);
1215
+ }
1216
+ };
1217
+ const getOnPointerEnter = (index) => (e) => {
1218
+ const prevPos = prevMousePosition.value;
1219
+ if (!prevPos) return;
1220
+ const { x, y } = e;
1221
+ if (x === prevPos.x && y === prevPos.y) return;
1222
+ onHover(index);
1223
+ };
1224
+ vue.watchEffect(() => {
1225
+ const isShown = show.value;
1226
+ if (isShown) {
1227
+ window.addEventListener("keydown", onKeydown, { capture: true });
1228
+ } else {
1229
+ window.removeEventListener("keydown", onKeydown, { capture: true });
1230
+ }
1231
+ });
1232
+ vue.onUnmounted(() => {
1233
+ window.removeEventListener("keydown", onKeydown, { capture: true });
1234
+ });
1235
+ return () => {
1236
+ return /* @__PURE__ */ vue.h("div", { ref: host, onPointerdown: (e) => e.preventDefault() }, /* @__PURE__ */ vue.h("nav", { class: "tab-group" }, /* @__PURE__ */ vue.h("ul", null, groupInfo.value.groups.map((group) => /* @__PURE__ */ vue.h(
1237
+ "li",
1238
+ {
1239
+ key: group.key,
1240
+ onPointerdown: () => onHover(group.range[0], scrollToIndex),
1241
+ class: hoverIndex.value >= group.range[0] && hoverIndex.value < group.range[1] ? "selected" : ""
1242
+ },
1243
+ group.label
1244
+ )))), /* @__PURE__ */ vue.h("div", { class: "menu-groups", onPointermove: onPointerMove }, groupInfo.value.groups.map((group) => /* @__PURE__ */ vue.h("div", { key: group.key, class: "menu-group" }, /* @__PURE__ */ vue.h("h6", null, group.label), /* @__PURE__ */ vue.h("ul", null, group.items.map((item) => /* @__PURE__ */ vue.h(
1245
+ "li",
1246
+ {
1247
+ key: item.key,
1248
+ "data-index": item.index,
1249
+ class: hoverIndex.value === item.index ? "hover" : "",
1250
+ onPointerenter: getOnPointerEnter(item.index),
1251
+ onPointerdown: () => {
1252
+ var _a, _b;
1253
+ (_b = (_a = host.value) == null ? void 0 : _a.querySelector(`[data-index="${item.index}"]`)) == null ? void 0 : _b.classList.add("active");
1254
+ },
1255
+ onPointerup: () => {
1256
+ var _a, _b;
1257
+ (_b = (_a = host.value) == null ? void 0 : _a.querySelector(`[data-index="${item.index}"]`)) == null ? void 0 : _b.classList.remove("active");
1258
+ runByIndex(item.index);
1259
+ }
1260
+ },
1261
+ /* @__PURE__ */ vue.h(component.Icon, { icon: item.icon }),
1262
+ /* @__PURE__ */ vue.h("span", null, item.label)
1263
+ )))))));
1264
+ };
1265
+ }
1266
+ });
1267
+
1268
+ var __typeError$4 = (msg) => {
1269
+ throw TypeError(msg);
1270
+ };
1271
+ var __accessCheck$4 = (obj, member, msg) => member.has(obj) || __typeError$4("Cannot " + msg);
1272
+ var __privateGet$4 = (obj, member, getter) => (__accessCheck$4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
1273
+ var __privateAdd$4 = (obj, member, value) => member.has(obj) ? __typeError$4("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1274
+ var __privateSet$4 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value);
1275
+ var _content$3, _app$3, _filter, _slashProvider, _programmaticallyPos;
1276
+ const menu = slash.slashFactory("CREPE_MENU");
1277
+ const menuAPI = utils.$ctx(
1278
+ {
1279
+ show: () => {
1280
+ },
1281
+ hide: () => {
1282
+ }
1283
+ },
1284
+ "menuAPICtx"
1285
+ );
1286
+ function configureMenu(ctx, config) {
1287
+ ctx.set(menu.key, {
1288
+ view: (view) => new MenuView(ctx, view, config)
1289
+ });
1290
+ }
1291
+ class MenuView {
1292
+ constructor(ctx, view, config) {
1293
+ __privateAdd$4(this, _content$3);
1294
+ __privateAdd$4(this, _app$3);
1295
+ __privateAdd$4(this, _filter);
1296
+ __privateAdd$4(this, _slashProvider);
1297
+ __privateAdd$4(this, _programmaticallyPos, null);
1298
+ this.update = (view) => {
1299
+ __privateGet$4(this, _slashProvider).update(view);
1300
+ };
1301
+ this.show = (pos) => {
1302
+ __privateSet$4(this, _programmaticallyPos, pos);
1303
+ __privateGet$4(this, _filter).value = "";
1304
+ __privateGet$4(this, _slashProvider).show();
1305
+ };
1306
+ this.hide = () => {
1307
+ __privateSet$4(this, _programmaticallyPos, null);
1308
+ __privateGet$4(this, _slashProvider).hide();
1309
+ };
1310
+ this.destroy = () => {
1311
+ __privateGet$4(this, _slashProvider).destroy();
1312
+ __privateGet$4(this, _app$3).unmount();
1313
+ __privateGet$4(this, _content$3).remove();
1314
+ };
1315
+ const content = document.createElement("div");
1316
+ content.classList.add("milkdown-slash-menu");
1317
+ const show = vue.ref(false);
1318
+ const filter = vue.ref("");
1319
+ __privateSet$4(this, _filter, filter);
1320
+ const hide = this.hide;
1321
+ const app = vue.createApp(Menu, {
1322
+ ctx,
1323
+ config,
1324
+ show,
1325
+ filter,
1326
+ hide
1327
+ });
1328
+ __privateSet$4(this, _app$3, app);
1329
+ app.mount(content);
1330
+ __privateSet$4(this, _content$3, content);
1331
+ const self = this;
1332
+ __privateSet$4(this, _slashProvider, new slash.SlashProvider({
1333
+ content: __privateGet$4(this, _content$3),
1334
+ debounce: 20,
1335
+ shouldShow(view2) {
1336
+ if (isInCodeBlock(view2.state.selection) || isInList(view2.state.selection))
1337
+ return false;
1338
+ const currentText = this.getContent(
1339
+ view2,
1340
+ (node) => ["paragraph", "heading"].includes(node.type.name)
1341
+ );
1342
+ if (currentText == null) return false;
1343
+ if (!isSelectionAtEndOfNode(view2.state.selection)) {
1344
+ return false;
1345
+ }
1346
+ const pos = __privateGet$4(self, _programmaticallyPos);
1347
+ filter.value = currentText.startsWith("/") ? currentText.slice(1) : currentText;
1348
+ if (typeof pos === "number") {
1349
+ const maxSize = view2.state.doc.nodeSize - 2;
1350
+ const validPos = Math.min(pos, maxSize);
1351
+ if (view2.state.doc.resolve(validPos).node() !== view2.state.doc.resolve(view2.state.selection.from).node()) {
1352
+ __privateSet$4(self, _programmaticallyPos, null);
1353
+ return false;
1354
+ }
1355
+ return true;
1356
+ }
1357
+ if (!currentText.startsWith("/")) return false;
1358
+ return true;
1359
+ },
1360
+ offset: 10
1361
+ }));
1362
+ __privateGet$4(this, _slashProvider).onShow = () => {
1363
+ show.value = true;
1364
+ };
1365
+ __privateGet$4(this, _slashProvider).onHide = () => {
1366
+ show.value = false;
1367
+ };
1368
+ this.update(view);
1369
+ ctx.set(menuAPI.key, {
1370
+ show: (pos) => this.show(pos),
1371
+ hide: () => this.hide()
1372
+ });
1373
+ }
1374
+ }
1375
+ _content$3 = new WeakMap();
1376
+ _app$3 = new WeakMap();
1377
+ _filter = new WeakMap();
1378
+ _slashProvider = new WeakMap();
1379
+ _programmaticallyPos = new WeakMap();
1380
+ function isSelectionAtEndOfNode(selection) {
1381
+ if (!(selection instanceof state.TextSelection)) return false;
1382
+ const { $head } = selection;
1383
+ const parent = $head.parent;
1384
+ const offset = $head.parentOffset;
1385
+ return offset === parent.content.size;
1386
+ }
1387
+
1388
+ const BlockHandle = vue.defineComponent({
1389
+ props: {
1390
+ onAdd: {
1391
+ type: Function,
1392
+ required: true
1393
+ },
1394
+ addIcon: {
1395
+ type: String,
1396
+ required: true
1397
+ },
1398
+ handleIcon: {
1399
+ type: String,
1400
+ required: true
1401
+ }
1402
+ },
1403
+ setup(props) {
1404
+ const addButton = vue.ref();
1405
+ return () => {
1406
+ return /* @__PURE__ */ vue.h(vue.Fragment, null, /* @__PURE__ */ vue.h(
1407
+ "div",
1408
+ {
1409
+ ref: addButton,
1410
+ class: "operation-item",
1411
+ onPointerdown: (e) => {
1412
+ var _a;
1413
+ e.preventDefault();
1414
+ e.stopPropagation();
1415
+ (_a = addButton.value) == null ? void 0 : _a.classList.add("active");
1416
+ },
1417
+ onPointerup: (e) => {
1418
+ var _a;
1419
+ e.preventDefault();
1420
+ e.stopPropagation();
1421
+ (_a = addButton.value) == null ? void 0 : _a.classList.remove("active");
1422
+ props.onAdd();
1423
+ }
1424
+ },
1425
+ /* @__PURE__ */ vue.h(component.Icon, { icon: props.addIcon })
1426
+ ), /* @__PURE__ */ vue.h("div", { class: "operation-item" }, /* @__PURE__ */ vue.h(component.Icon, { icon: props.handleIcon })));
1427
+ };
1428
+ }
1429
+ });
1430
+
1431
+ var __typeError$3 = (msg) => {
1432
+ throw TypeError(msg);
1433
+ };
1434
+ var __accessCheck$3 = (obj, member, msg) => member.has(obj) || __typeError$3("Cannot " + msg);
1435
+ var __privateGet$3 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
1436
+ var __privateAdd$3 = (obj, member, value) => member.has(obj) ? __typeError$3("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1437
+ var __privateSet$3 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value);
1438
+ var _content$2, _provider$1, _app$2, _ctx;
1439
+ class BlockHandleView {
1440
+ constructor(ctx, config) {
1441
+ __privateAdd$3(this, _content$2);
1442
+ __privateAdd$3(this, _provider$1);
1443
+ __privateAdd$3(this, _app$2);
1444
+ __privateAdd$3(this, _ctx);
1445
+ this.update = () => {
1446
+ __privateGet$3(this, _provider$1).update();
1447
+ };
1448
+ this.destroy = () => {
1449
+ __privateGet$3(this, _provider$1).destroy();
1450
+ __privateGet$3(this, _content$2).remove();
1451
+ __privateGet$3(this, _app$2).unmount();
1452
+ };
1453
+ this.onAdd = () => {
1454
+ const ctx = __privateGet$3(this, _ctx);
1455
+ const view = ctx.get(core.editorViewCtx);
1456
+ if (!view.hasFocus()) view.focus();
1457
+ const { state: state$1, dispatch } = view;
1458
+ const active = __privateGet$3(this, _provider$1).active;
1459
+ if (!active) return;
1460
+ const $pos = active.$pos;
1461
+ const pos = $pos.pos + active.node.nodeSize;
1462
+ let tr = state$1.tr.insert(pos, commonmark.paragraphSchema.type(ctx).create());
1463
+ tr = tr.setSelection(state.TextSelection.near(tr.doc.resolve(pos)));
1464
+ dispatch(tr.scrollIntoView());
1465
+ __privateGet$3(this, _provider$1).hide();
1466
+ ctx.get(menuAPI.key).show(tr.selection.from);
1467
+ };
1468
+ var _a, _b;
1469
+ __privateSet$3(this, _ctx, ctx);
1470
+ const content = document.createElement("div");
1471
+ content.classList.add("milkdown-block-handle");
1472
+ const app = vue.createApp(BlockHandle, {
1473
+ onAdd: this.onAdd,
1474
+ addIcon: (_a = config == null ? void 0 : config.handleAddIcon) != null ? _a : plusIcon,
1475
+ handleIcon: (_b = config == null ? void 0 : config.handleDragIcon) != null ? _b : menuIcon
1476
+ });
1477
+ app.mount(content);
1478
+ __privateSet$3(this, _app$2, app);
1479
+ __privateSet$3(this, _content$2, content);
1480
+ __privateSet$3(this, _provider$1, new block.BlockProvider({
1481
+ ctx,
1482
+ content,
1483
+ getOffset: () => 16,
1484
+ getPlacement: ({ active, blockDom }) => {
1485
+ if (active.node.type.name === "heading") return "left";
1486
+ let totalDescendant = 0;
1487
+ active.node.descendants((node) => {
1488
+ totalDescendant += node.childCount;
1489
+ });
1490
+ const dom = active.el;
1491
+ const domRect = dom.getBoundingClientRect();
1492
+ const handleRect = blockDom.getBoundingClientRect();
1493
+ const style = window.getComputedStyle(dom);
1494
+ const paddingTop = Number.parseInt(style.paddingTop, 10) || 0;
1495
+ const paddingBottom = Number.parseInt(style.paddingBottom, 10) || 0;
1496
+ const height = domRect.height - paddingTop - paddingBottom;
1497
+ const handleHeight = handleRect.height;
1498
+ return totalDescendant > 2 || handleHeight < height ? "left-start" : "left";
1499
+ }
1500
+ }));
1501
+ this.update();
1502
+ }
1503
+ }
1504
+ _content$2 = new WeakMap();
1505
+ _provider$1 = new WeakMap();
1506
+ _app$2 = new WeakMap();
1507
+ _ctx = new WeakMap();
1508
+ function configureBlockHandle(ctx, config) {
1509
+ ctx.set(block.blockConfig.key, {
1510
+ filterNodes: (pos) => {
1511
+ const filter = prose.findParent(
1512
+ (node) => ["table", "blockquote", "math_inline"].includes(node.type.name)
1513
+ )(pos);
1514
+ if (filter) return false;
1515
+ return true;
1516
+ }
1517
+ });
1518
+ ctx.set(block.block.key, {
1519
+ view: () => new BlockHandleView(ctx, config)
1520
+ });
1521
+ }
1522
+
1523
+ const blockEdit = (editor, config) => {
1524
+ editor.config(crepeFeatureConfig(CrepeFeature.BlockEdit)).config((ctx) => configureBlockHandle(ctx, config)).config((ctx) => configureMenu(ctx, config)).use(menuAPI).use(block.block).use(menu);
1525
+ };
1526
+
1527
+ const codeMirror = (editor, config = {}) => {
1528
+ editor.config(crepeFeatureConfig(CrepeFeature.CodeMirror)).config((ctx) => {
1529
+ const { languages = [], theme } = config;
1530
+ const extensions = [
1531
+ view.keymap.of(commands.defaultKeymap.concat(commands.indentWithTab)),
1532
+ codemirror.basicSetup
1533
+ ];
1534
+ if (theme) {
1535
+ extensions.push(theme);
1536
+ }
1537
+ if (config.extensions) {
1538
+ extensions.push(...config.extensions);
1539
+ }
1540
+ ctx.update(codeBlock.codeBlockConfig.key, (defaultConfig) => ({
1541
+ extensions,
1542
+ languages,
1543
+ expandIcon: config.expandIcon || chevronDownIcon,
1544
+ searchIcon: config.searchIcon || searchIcon,
1545
+ clearSearchIcon: config.clearSearchIcon || clearIcon,
1546
+ searchPlaceholder: config.searchPlaceholder || "Search language",
1547
+ noResultText: config.noResultText || "No result",
1548
+ renderLanguage: config.renderLanguage || defaultConfig.renderLanguage,
1549
+ renderPreview: config.renderPreview || defaultConfig.renderPreview,
1550
+ previewToggleButton: (previewOnlyMode) => {
1551
+ var _a, _b;
1552
+ const icon = ((_a = config.previewToggleIcon) == null ? void 0 : _a.call(config, previewOnlyMode)) || (previewOnlyMode ? editIcon : visibilityOffIcon);
1553
+ const text = ((_b = config.previewToggleText) == null ? void 0 : _b.call(config, previewOnlyMode)) || (previewOnlyMode ? "Edit" : "Hide");
1554
+ return [icon, text].map((v) => v.trim()).join(" ");
1555
+ },
1556
+ previewLabel: config.previewLabel || defaultConfig.previewLabel
1557
+ }));
1558
+ }).use(codeBlock.codeBlockComponent);
1559
+ };
1560
+
1561
+ const cursor = (editor, config) => {
1562
+ editor.config(crepeFeatureConfig(CrepeFeature.Cursor)).config((ctx) => {
1563
+ ctx.update(cursor$1.dropCursorConfig.key, () => {
1564
+ var _a, _b;
1565
+ return {
1566
+ class: "crepe-drop-cursor",
1567
+ width: (_a = config == null ? void 0 : config.width) != null ? _a : 4,
1568
+ color: (_b = config == null ? void 0 : config.color) != null ? _b : false
1569
+ };
1570
+ });
1571
+ }).use(cursor$1.cursor);
1572
+ if ((config == null ? void 0 : config.virtual) === false) {
1573
+ return;
1574
+ }
1575
+ const virtualCursor = prosemirrorVirtualCursor.createVirtualCursor();
1576
+ editor.use(utils.$prose(() => virtualCursor));
1577
+ };
1578
+
1579
+ const imageBlock = (editor, config) => {
1580
+ editor.config(crepeFeatureConfig(CrepeFeature.ImageBlock)).config((ctx) => {
1581
+ ctx.update(imageInline.inlineImageConfig.key, (value) => {
1582
+ var _a, _b, _c, _d, _e, _f;
1583
+ return {
1584
+ uploadButton: (_a = config == null ? void 0 : config.inlineUploadButton) != null ? _a : "Upload",
1585
+ imageIcon: (_b = config == null ? void 0 : config.inlineImageIcon) != null ? _b : imageIcon,
1586
+ confirmButton: (_c = config == null ? void 0 : config.inlineConfirmButton) != null ? _c : confirmIcon,
1587
+ uploadPlaceholderText: (_d = config == null ? void 0 : config.inlineUploadPlaceholderText) != null ? _d : "or paste link",
1588
+ onUpload: (_f = (_e = config == null ? void 0 : config.inlineOnUpload) != null ? _e : config == null ? void 0 : config.onUpload) != null ? _f : value.onUpload,
1589
+ proxyDomURL: config == null ? void 0 : config.proxyDomURL
1590
+ };
1591
+ });
1592
+ ctx.update(imageBlock$1.imageBlockConfig.key, (value) => {
1593
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1594
+ return {
1595
+ uploadButton: (_a = config == null ? void 0 : config.blockUploadButton) != null ? _a : "Upload file",
1596
+ imageIcon: (_b = config == null ? void 0 : config.blockImageIcon) != null ? _b : imageIcon,
1597
+ captionIcon: (_c = config == null ? void 0 : config.blockCaptionIcon) != null ? _c : captionIcon,
1598
+ confirmButton: (_d = config == null ? void 0 : config.blockConfirmButton) != null ? _d : "Confirm",
1599
+ captionPlaceholderText: (_e = config == null ? void 0 : config.blockCaptionPlaceholderText) != null ? _e : "Write Image Caption",
1600
+ uploadPlaceholderText: (_f = config == null ? void 0 : config.blockUploadPlaceholderText) != null ? _f : "or paste link",
1601
+ onUpload: (_h = (_g = config == null ? void 0 : config.blockOnUpload) != null ? _g : config == null ? void 0 : config.onUpload) != null ? _h : value.onUpload,
1602
+ proxyDomURL: config == null ? void 0 : config.proxyDomURL
1603
+ };
1604
+ });
1605
+ }).use(imageBlock$1.imageBlockComponent).use(imageInline.imageInlineComponent);
1606
+ };
1607
+
1608
+ const blockLatexSchema = commonmark.codeBlockSchema.extendSchema((prev) => {
1609
+ return (ctx) => {
1610
+ const baseSchema = prev(ctx);
1611
+ return {
1612
+ ...baseSchema,
1613
+ toMarkdown: {
1614
+ match: baseSchema.toMarkdown.match,
1615
+ runner: (state, node) => {
1616
+ var _a, _b;
1617
+ const language = (_a = node.attrs.language) != null ? _a : "";
1618
+ if (language.toLowerCase() === "latex") {
1619
+ state.addNode(
1620
+ "math",
1621
+ void 0,
1622
+ ((_b = node.content.firstChild) == null ? void 0 : _b.text) || ""
1623
+ );
1624
+ } else {
1625
+ return baseSchema.toMarkdown.runner(state, node);
1626
+ }
1627
+ }
1628
+ }
1629
+ };
1630
+ };
1631
+ });
1632
+
1633
+ const mathInlineId = "math_inline";
1634
+ const mathInlineSchema = utils.$nodeSchema(mathInlineId, () => ({
1635
+ group: "inline",
1636
+ inline: true,
1637
+ draggable: true,
1638
+ atom: true,
1639
+ attrs: {
1640
+ value: {
1641
+ default: ""
1642
+ }
1643
+ },
1644
+ parseDOM: [
1645
+ {
1646
+ tag: `span[data-type="${mathInlineId}"]`,
1647
+ getAttrs: (dom) => {
1648
+ var _a;
1649
+ return {
1650
+ value: (_a = dom.dataset.value) != null ? _a : ""
1651
+ };
1652
+ }
1653
+ }
1654
+ ],
1655
+ toDOM: (node) => {
1656
+ const code = node.attrs.value;
1657
+ const dom = document.createElement("span");
1658
+ dom.dataset.type = mathInlineId;
1659
+ dom.dataset.value = code;
1660
+ katex.render(code, dom, {
1661
+ throwOnError: false
1662
+ });
1663
+ return dom;
1664
+ },
1665
+ parseMarkdown: {
1666
+ match: (node) => node.type === "inlineMath",
1667
+ runner: (state, node, type) => {
1668
+ state.addNode(type, { value: node.value });
1669
+ }
1670
+ },
1671
+ toMarkdown: {
1672
+ match: (node) => node.type.name === mathInlineId,
1673
+ runner: (state, node) => {
1674
+ state.addNode("inlineMath", void 0, node.attrs.value);
1675
+ }
1676
+ }
1677
+ }));
1678
+
1679
+ const inlineLatexTooltip = tooltip.tooltipFactory("INLINE_LATEX");
1680
+
1681
+ const LatexTooltip = vue.defineComponent({
1682
+ props: {
1683
+ config: {
1684
+ type: Object,
1685
+ required: true
1686
+ },
1687
+ innerView: {
1688
+ type: Object,
1689
+ required: true
1690
+ },
1691
+ updateValue: {
1692
+ type: Object,
1693
+ required: true
1694
+ }
1695
+ },
1696
+ setup(props) {
1697
+ const innerViewRef = (el) => {
1698
+ if (!el || !(el instanceof HTMLElement)) return;
1699
+ while (el.firstChild) {
1700
+ el.removeChild(el.firstChild);
1701
+ }
1702
+ if (props.innerView.value) {
1703
+ el.appendChild(props.innerView.value.dom);
1704
+ }
1705
+ };
1706
+ const onUpdate = (e) => {
1707
+ e.preventDefault();
1708
+ props.updateValue.value();
1709
+ };
1710
+ return () => {
1711
+ return /* @__PURE__ */ vue.h("div", { class: "container" }, props.innerView && /* @__PURE__ */ vue.h("div", { ref: innerViewRef }), /* @__PURE__ */ vue.h("button", { onPointerdown: onUpdate }, /* @__PURE__ */ vue.h(component.Icon, { icon: props.config.inlineEditConfirm })));
1712
+ };
1713
+ }
1714
+ });
1715
+
1716
+ var __typeError$2 = (msg) => {
1717
+ throw TypeError(msg);
1718
+ };
1719
+ var __accessCheck$2 = (obj, member, msg) => member.has(obj) || __typeError$2("Cannot " + msg);
1720
+ var __privateGet$2 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
1721
+ var __privateAdd$2 = (obj, member, value) => member.has(obj) ? __typeError$2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1722
+ var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$2(obj, member, "write to private field"), member.set(obj, value), value);
1723
+ var _content$1, _provider, _dom, _innerView, _updateValue, _app$1, _onHide, _shouldShow;
1724
+ class LatexInlineTooltip {
1725
+ constructor(ctx, view, config) {
1726
+ this.ctx = ctx;
1727
+ __privateAdd$2(this, _content$1);
1728
+ __privateAdd$2(this, _provider);
1729
+ __privateAdd$2(this, _dom);
1730
+ __privateAdd$2(this, _innerView, vue.shallowRef(null));
1731
+ __privateAdd$2(this, _updateValue, vue.shallowRef(() => {
1732
+ }));
1733
+ __privateAdd$2(this, _app$1);
1734
+ __privateAdd$2(this, _onHide, () => {
1735
+ if (__privateGet$2(this, _innerView).value) {
1736
+ __privateGet$2(this, _innerView).value.destroy();
1737
+ __privateGet$2(this, _innerView).value = null;
1738
+ }
1739
+ });
1740
+ __privateAdd$2(this, _shouldShow, (view) => {
1741
+ const shouldShow = () => {
1742
+ const { selection, schema } = view.state;
1743
+ if (selection.empty) return false;
1744
+ if (!(selection instanceof state.NodeSelection)) return false;
1745
+ const node = selection.node;
1746
+ if (node.type.name !== mathInlineId) return false;
1747
+ const textFrom = selection.from;
1748
+ const paragraph = schema.nodes.paragraph.create(
1749
+ null,
1750
+ schema.text(node.attrs.value)
1751
+ );
1752
+ const innerView = new view$1.EditorView(__privateGet$2(this, _dom), {
1753
+ state: state.EditorState.create({
1754
+ doc: paragraph,
1755
+ schema: new model.Schema({
1756
+ nodes: {
1757
+ doc: {
1758
+ content: "block+"
1759
+ },
1760
+ paragraph: {
1761
+ content: "inline*",
1762
+ group: "block",
1763
+ parseDOM: [{ tag: "p" }],
1764
+ toDOM() {
1765
+ return ["p", 0];
1766
+ }
1767
+ },
1768
+ text: {
1769
+ group: "inline"
1770
+ }
1771
+ }
1772
+ }),
1773
+ plugins: [
1774
+ keymap.keymap({
1775
+ "Mod-z": history.undo,
1776
+ "Mod-Z": history.redo,
1777
+ "Mod-y": history.redo,
1778
+ Enter: () => {
1779
+ __privateGet$2(this, _updateValue).value();
1780
+ return true;
1781
+ }
1782
+ })
1783
+ ]
1784
+ })
1785
+ });
1786
+ __privateGet$2(this, _innerView).value = innerView;
1787
+ __privateGet$2(this, _updateValue).value = () => {
1788
+ const { tr } = view.state;
1789
+ tr.setNodeAttribute(textFrom, "value", innerView.state.doc.textContent);
1790
+ view.dispatch(tr);
1791
+ requestAnimationFrame(() => {
1792
+ view.focus();
1793
+ });
1794
+ };
1795
+ return true;
1796
+ };
1797
+ const show = shouldShow();
1798
+ if (!show) __privateGet$2(this, _onHide).call(this);
1799
+ return show;
1800
+ });
1801
+ this.update = (view, prevState) => {
1802
+ __privateGet$2(this, _provider).update(view, prevState);
1803
+ };
1804
+ this.destroy = () => {
1805
+ __privateGet$2(this, _app$1).unmount();
1806
+ __privateGet$2(this, _provider).destroy();
1807
+ __privateGet$2(this, _content$1).remove();
1808
+ };
1809
+ const content = document.createElement("div");
1810
+ content.className = "milkdown-latex-inline-edit";
1811
+ __privateSet$2(this, _content$1, content);
1812
+ __privateSet$2(this, _app$1, vue.createApp(LatexTooltip, {
1813
+ config,
1814
+ innerView: __privateGet$2(this, _innerView),
1815
+ updateValue: __privateGet$2(this, _updateValue)
1816
+ }));
1817
+ __privateGet$2(this, _app$1).mount(content);
1818
+ __privateSet$2(this, _provider, new tooltip.TooltipProvider({
1819
+ debounce: 0,
1820
+ content: __privateGet$2(this, _content$1),
1821
+ shouldShow: __privateGet$2(this, _shouldShow),
1822
+ offset: 10,
1823
+ floatingUIOptions: {
1824
+ placement: "bottom"
1825
+ }
1826
+ }));
1827
+ __privateGet$2(this, _provider).update(view);
1828
+ __privateSet$2(this, _dom, document.createElement("div"));
1829
+ }
1830
+ }
1831
+ _content$1 = new WeakMap();
1832
+ _provider = new WeakMap();
1833
+ _dom = new WeakMap();
1834
+ _innerView = new WeakMap();
1835
+ _updateValue = new WeakMap();
1836
+ _app$1 = new WeakMap();
1837
+ _onHide = new WeakMap();
1838
+ _shouldShow = new WeakMap();
1839
+
1840
+ const mathInlineInputRule = utils.$inputRule(
1841
+ (ctx) => prose.nodeRule(/(?:\$)([^$]+)(?:\$)$/, mathInlineSchema.type(ctx), {
1842
+ getAttr: (match) => {
1843
+ var _a;
1844
+ return {
1845
+ value: (_a = match[1]) != null ? _a : ""
1846
+ };
1847
+ }
1848
+ })
1849
+ );
1850
+ const mathBlockInputRule = utils.$inputRule(
1851
+ (ctx) => inputrules.textblockTypeInputRule(/^\$\$[\s\n]$/, commonmark.codeBlockSchema.type(ctx), () => ({
1852
+ language: "LaTeX"
1853
+ }))
1854
+ );
1855
+
1856
+ const remarkMathPlugin = utils.$remark(
1857
+ "remarkMath",
1858
+ () => remarkMath
1859
+ );
1860
+ function visitMathBlock(ast) {
1861
+ return unistUtilVisit.visit(
1862
+ ast,
1863
+ "math",
1864
+ (node, index, parent) => {
1865
+ const { value } = node;
1866
+ const newNode = {
1867
+ type: "code",
1868
+ lang: "LaTeX",
1869
+ value
1870
+ };
1871
+ parent.children.splice(index, 1, newNode);
1872
+ }
1873
+ );
1874
+ }
1875
+ const remarkMathBlockPlugin = utils.$remark(
1876
+ "remarkMathBlock",
1877
+ () => () => visitMathBlock
1878
+ );
1879
+
1880
+ const latex = (editor, config) => {
1881
+ editor.config(crepeFeatureConfig(CrepeFeature.Latex)).config((ctx) => {
1882
+ const flags = useCrepeFeatures(ctx).get();
1883
+ const isCodeMirrorEnabled = flags.includes(CrepeFeature.CodeMirror);
1884
+ if (!isCodeMirrorEnabled) {
1885
+ throw new Error("You need to enable CodeMirror to use LaTeX feature");
1886
+ }
1887
+ ctx.update(codeBlock.codeBlockConfig.key, (prev) => ({
1888
+ ...prev,
1889
+ renderPreview: (language, content) => {
1890
+ if (language.toLowerCase() === "latex" && content.length > 0) {
1891
+ return renderLatex(content, config == null ? void 0 : config.katexOptions);
1892
+ }
1893
+ const renderPreview = prev.renderPreview;
1894
+ return renderPreview(language, content);
1895
+ }
1896
+ }));
1897
+ ctx.set(inlineLatexTooltip.key, {
1898
+ view: (view) => {
1899
+ var _a;
1900
+ return new LatexInlineTooltip(ctx, view, {
1901
+ inlineEditConfirm: (_a = config == null ? void 0 : config.inlineEditConfirm) != null ? _a : confirmIcon,
1902
+ ...config
1903
+ });
1904
+ }
1905
+ });
1906
+ }).use(remarkMathPlugin).use(remarkMathBlockPlugin).use(mathInlineSchema).use(inlineLatexTooltip).use(mathInlineInputRule).use(mathBlockInputRule).use(blockLatexSchema);
1907
+ };
1908
+ function renderLatex(content, options) {
1909
+ const html = katex.renderToString(content, {
1910
+ ...options,
1911
+ throwOnError: false,
1912
+ displayMode: true
1913
+ });
1914
+ return html;
1915
+ }
1916
+
1917
+ const linkTooltip = (editor, config) => {
1918
+ editor.config(crepeFeatureConfig(CrepeFeature.LinkTooltip)).config(linkTooltip$1.configureLinkTooltip).config((ctx) => {
1919
+ ctx.update(linkTooltip$1.linkTooltipConfig.key, (prev) => {
1920
+ var _a, _b, _c, _d, _e, _f;
1921
+ return {
1922
+ ...prev,
1923
+ linkIcon: (_a = config == null ? void 0 : config.linkIcon) != null ? _a : copyIcon,
1924
+ editButton: (_b = config == null ? void 0 : config.editButton) != null ? _b : editIcon,
1925
+ removeButton: (_c = config == null ? void 0 : config.removeButton) != null ? _c : removeIcon,
1926
+ confirmButton: (_d = config == null ? void 0 : config.confirmButton) != null ? _d : confirmIcon,
1927
+ inputPlaceholder: (_e = config == null ? void 0 : config.inputPlaceholder) != null ? _e : "Paste link...",
1928
+ onCopyLink: (_f = config == null ? void 0 : config.onCopyLink) != null ? _f : () => {
1929
+ }
1930
+ };
1931
+ });
1932
+ }).use(linkTooltip$1.linkTooltipPlugin);
1933
+ };
1934
+
1935
+ function configureListItem(ctx, config) {
1936
+ ctx.set(listItemBlock.listItemBlockConfig.key, {
1937
+ renderLabel: ({ label, listType, checked }) => {
1938
+ var _a, _b, _c;
1939
+ if (checked == null) {
1940
+ if (listType === "bullet") return (_a = config == null ? void 0 : config.bulletIcon) != null ? _a : bulletIcon;
1941
+ return label;
1942
+ }
1943
+ if (checked) return (_b = config == null ? void 0 : config.checkBoxCheckedIcon) != null ? _b : checkBoxCheckedIcon;
1944
+ return (_c = config == null ? void 0 : config.checkBoxUncheckedIcon) != null ? _c : checkBoxUncheckedIcon;
1945
+ }
1946
+ });
1947
+ }
1948
+ const listItem = (editor, config) => {
1949
+ editor.config(crepeFeatureConfig(CrepeFeature.ListItem)).config((ctx) => configureListItem(ctx, config)).use(listItemBlock.listItemBlockComponent);
1950
+ };
1951
+
1952
+ function isDocEmpty(doc) {
1953
+ var _a;
1954
+ return doc.childCount <= 1 && !((_a = doc.firstChild) == null ? void 0 : _a.content.size);
1955
+ }
1956
+ function createPlaceholderDecoration(state, placeholderText) {
1957
+ const { selection } = state;
1958
+ if (!selection.empty) return null;
1959
+ const $pos = selection.$anchor;
1960
+ const node = $pos.parent;
1961
+ if (node.content.size > 0) return null;
1962
+ const inTable = prose.findParent((node2) => node2.type.name === "table")($pos);
1963
+ if (inTable) return null;
1964
+ const before = $pos.before();
1965
+ return view$1.Decoration.node(before, before + node.nodeSize, {
1966
+ class: "crepe-placeholder",
1967
+ "data-placeholder": placeholderText
1968
+ });
1969
+ }
1970
+ const placeholderConfig = utils.$ctx(
1971
+ {
1972
+ text: "Please enter...",
1973
+ mode: "block"
1974
+ },
1975
+ "placeholderConfigCtx"
1976
+ );
1977
+ const placeholderPlugin = utils.$prose((ctx) => {
1978
+ return new state.Plugin({
1979
+ key: new state.PluginKey("CREPE_PLACEHOLDER"),
1980
+ props: {
1981
+ decorations: (state) => {
1982
+ var _a;
1983
+ const config = ctx.get(placeholderConfig.key);
1984
+ if (config.mode === "doc" && !isDocEmpty(state.doc)) return null;
1985
+ if (isInCodeBlock(state.selection) || isInList(state.selection))
1986
+ return null;
1987
+ const placeholderText = (_a = config.text) != null ? _a : "Please enter...";
1988
+ const deco = createPlaceholderDecoration(state, placeholderText);
1989
+ if (!deco) return null;
1990
+ return view$1.DecorationSet.create(state.doc, [deco]);
1991
+ }
1992
+ }
1993
+ });
1994
+ });
1995
+ const placeholder = (editor, config) => {
1996
+ editor.config(crepeFeatureConfig(CrepeFeature.Placeholder)).config((ctx) => {
1997
+ if (config) {
1998
+ ctx.update(placeholderConfig.key, (prev) => {
1999
+ return {
2000
+ ...prev,
2001
+ ...config
2002
+ };
2003
+ });
2004
+ }
2005
+ }).use(placeholderPlugin).use(placeholderConfig);
2006
+ };
2007
+
2008
+ const table = (editor, config) => {
2009
+ editor.config(crepeFeatureConfig(CrepeFeature.Table)).config((ctx) => {
2010
+ ctx.update(tableBlock.tableBlockConfig.key, (defaultConfig) => ({
2011
+ ...defaultConfig,
2012
+ renderButton: (renderType) => {
2013
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2014
+ switch (renderType) {
2015
+ case "add_row":
2016
+ return (_a = config == null ? void 0 : config.addRowIcon) != null ? _a : plusIcon;
2017
+ case "add_col":
2018
+ return (_b = config == null ? void 0 : config.addColIcon) != null ? _b : plusIcon;
2019
+ case "delete_row":
2020
+ return (_c = config == null ? void 0 : config.deleteRowIcon) != null ? _c : removeIcon;
2021
+ case "delete_col":
2022
+ return (_d = config == null ? void 0 : config.deleteColIcon) != null ? _d : removeIcon;
2023
+ case "align_col_left":
2024
+ return (_e = config == null ? void 0 : config.alignLeftIcon) != null ? _e : alignLeftIcon;
2025
+ case "align_col_center":
2026
+ return (_f = config == null ? void 0 : config.alignCenterIcon) != null ? _f : alignCenterIcon;
2027
+ case "align_col_right":
2028
+ return (_g = config == null ? void 0 : config.alignRightIcon) != null ? _g : alignRightIcon;
2029
+ case "col_drag_handle":
2030
+ return (_h = config == null ? void 0 : config.colDragHandleIcon) != null ? _h : dragHandleIcon;
2031
+ case "row_drag_handle":
2032
+ return (_i = config == null ? void 0 : config.rowDragHandleIcon) != null ? _i : dragHandleIcon;
2033
+ }
2034
+ }
2035
+ }));
2036
+ }).use(tableBlock.tableBlock);
2037
+ };
2038
+
2039
+ const Toolbar = vue.defineComponent({
2040
+ props: {
2041
+ ctx: {
2042
+ type: Object,
2043
+ required: true
2044
+ },
2045
+ hide: {
2046
+ type: Function,
2047
+ required: true
2048
+ },
2049
+ show: {
2050
+ type: Object,
2051
+ required: true
2052
+ },
2053
+ selection: {
2054
+ type: Object,
2055
+ required: true
2056
+ },
2057
+ config: {
2058
+ type: Object,
2059
+ required: false
2060
+ }
2061
+ },
2062
+ setup(props) {
2063
+ const { ctx, hide, config } = props;
2064
+ const onClick = (fn) => (e) => {
2065
+ e.preventDefault();
2066
+ ctx && fn(ctx);
2067
+ };
2068
+ const isActive = (mark) => {
2069
+ const selection = props.selection.value;
2070
+ if (!ctx || !selection) return false;
2071
+ const { state } = ctx.get(core.editorViewCtx);
2072
+ if (!state) return false;
2073
+ const { doc } = state;
2074
+ return doc.rangeHasMark(selection.from, selection.to, mark);
2075
+ };
2076
+ const containsNode = (node) => {
2077
+ const selection = props.selection.value;
2078
+ if (!ctx || !selection) return false;
2079
+ const { state: state$1 } = ctx.get(core.editorViewCtx);
2080
+ if (!state$1) return false;
2081
+ const { doc } = state$1;
2082
+ if (selection instanceof state.NodeSelection) {
2083
+ return selection.node.type === node;
2084
+ }
2085
+ const { from, to } = selection;
2086
+ let hasNode = false;
2087
+ doc.nodesBetween(from, to, (n) => {
2088
+ if (n.type === node) {
2089
+ hasNode = true;
2090
+ return false;
2091
+ }
2092
+ return true;
2093
+ });
2094
+ return hasNode;
2095
+ };
2096
+ const flags = useCrepeFeatures(ctx).get();
2097
+ const isLatexEnabled = flags == null ? void 0 : flags.includes(CrepeFeature.Latex);
2098
+ const toggleLatex = (ctx2) => {
2099
+ const hasLatex = containsNode(mathInlineSchema.type(ctx2));
2100
+ const view = ctx2.get(core.editorViewCtx);
2101
+ const { selection, doc, tr } = view.state;
2102
+ if (!hasLatex) {
2103
+ const text = doc.textBetween(selection.from, selection.to);
2104
+ let _tr2 = tr.replaceSelectionWith(
2105
+ mathInlineSchema.type(ctx2).create({
2106
+ value: text
2107
+ })
2108
+ );
2109
+ view.dispatch(
2110
+ _tr2.setSelection(state.NodeSelection.create(_tr2.doc, selection.from))
2111
+ );
2112
+ return;
2113
+ }
2114
+ const { from, to } = selection;
2115
+ let pos = -1;
2116
+ let node = null;
2117
+ doc.nodesBetween(from, to, (n, p) => {
2118
+ if (node) return false;
2119
+ if (n.type === mathInlineSchema.type(ctx2)) {
2120
+ pos = p;
2121
+ node = n;
2122
+ return false;
2123
+ }
2124
+ return true;
2125
+ });
2126
+ if (!node || pos < 0) return;
2127
+ let _tr = tr.delete(pos, pos + 1);
2128
+ const content = node.attrs.value;
2129
+ _tr = _tr.insertText(content, pos);
2130
+ view.dispatch(
2131
+ _tr.setSelection(
2132
+ state.TextSelection.create(_tr.doc, from, to + content.length - 1)
2133
+ )
2134
+ );
2135
+ };
2136
+ return () => {
2137
+ var _a, _b, _c, _d, _e, _f;
2138
+ return /* @__PURE__ */ vue.h(vue.Fragment, null, /* @__PURE__ */ vue.h(
2139
+ "button",
2140
+ {
2141
+ type: "button",
2142
+ class: clsx(
2143
+ "toolbar-item",
2144
+ ctx && isActive(commonmark.strongSchema.type(ctx)) && "active"
2145
+ ),
2146
+ onPointerdown: onClick((ctx2) => {
2147
+ const commands = ctx2.get(core.commandsCtx);
2148
+ commands.call(commonmark.toggleStrongCommand.key);
2149
+ })
2150
+ },
2151
+ /* @__PURE__ */ vue.h(component.Icon, { icon: (_a = config == null ? void 0 : config.boldIcon) != null ? _a : boldIcon })
2152
+ ), /* @__PURE__ */ vue.h(
2153
+ "button",
2154
+ {
2155
+ type: "button",
2156
+ class: clsx(
2157
+ "toolbar-item",
2158
+ ctx && isActive(commonmark.emphasisSchema.type(ctx)) && "active"
2159
+ ),
2160
+ onPointerdown: onClick((ctx2) => {
2161
+ const commands = ctx2.get(core.commandsCtx);
2162
+ commands.call(commonmark.toggleEmphasisCommand.key);
2163
+ })
2164
+ },
2165
+ /* @__PURE__ */ vue.h(component.Icon, { icon: (_b = config == null ? void 0 : config.italicIcon) != null ? _b : italicIcon })
2166
+ ), /* @__PURE__ */ vue.h(
2167
+ "button",
2168
+ {
2169
+ type: "button",
2170
+ class: clsx(
2171
+ "toolbar-item",
2172
+ ctx && isActive(gfm.strikethroughSchema.type(ctx)) && "active"
2173
+ ),
2174
+ onPointerdown: onClick((ctx2) => {
2175
+ const commands = ctx2.get(core.commandsCtx);
2176
+ commands.call(gfm.toggleStrikethroughCommand.key);
2177
+ })
2178
+ },
2179
+ /* @__PURE__ */ vue.h(component.Icon, { icon: (_c = config == null ? void 0 : config.strikethroughIcon) != null ? _c : strikethroughIcon })
2180
+ ), /* @__PURE__ */ vue.h("div", { class: "divider" }), /* @__PURE__ */ vue.h(
2181
+ "button",
2182
+ {
2183
+ type: "button",
2184
+ class: clsx(
2185
+ "toolbar-item",
2186
+ ctx && isActive(commonmark.inlineCodeSchema.type(ctx)) && "active"
2187
+ ),
2188
+ onPointerdown: onClick((ctx2) => {
2189
+ const commands = ctx2.get(core.commandsCtx);
2190
+ commands.call(commonmark.toggleInlineCodeCommand.key);
2191
+ })
2192
+ },
2193
+ /* @__PURE__ */ vue.h(component.Icon, { icon: (_d = config == null ? void 0 : config.codeIcon) != null ? _d : codeIcon })
2194
+ ), isLatexEnabled && /* @__PURE__ */ vue.h(
2195
+ "button",
2196
+ {
2197
+ type: "button",
2198
+ class: clsx(
2199
+ "toolbar-item",
2200
+ ctx && containsNode(mathInlineSchema.type(ctx)) && "active"
2201
+ ),
2202
+ onPointerdown: onClick(toggleLatex)
2203
+ },
2204
+ /* @__PURE__ */ vue.h(component.Icon, { icon: (_e = config == null ? void 0 : config.latexIcon) != null ? _e : functionsIcon })
2205
+ ), /* @__PURE__ */ vue.h(
2206
+ "button",
2207
+ {
2208
+ type: "button",
2209
+ class: clsx(
2210
+ "toolbar-item",
2211
+ ctx && isActive(commonmark.linkSchema.type(ctx)) && "active"
2212
+ ),
2213
+ onPointerdown: onClick((ctx2) => {
2214
+ const view = ctx2.get(core.editorViewCtx);
2215
+ const { selection } = view.state;
2216
+ if (isActive(commonmark.linkSchema.type(ctx2))) {
2217
+ ctx2.get(linkTooltip$1.linkTooltipAPI.key).removeLink(selection.from, selection.to);
2218
+ return;
2219
+ }
2220
+ ctx2.get(linkTooltip$1.linkTooltipAPI.key).addLink(selection.from, selection.to);
2221
+ hide == null ? void 0 : hide();
2222
+ })
2223
+ },
2224
+ /* @__PURE__ */ vue.h(component.Icon, { icon: (_f = config == null ? void 0 : config.linkIcon) != null ? _f : linkIcon })
2225
+ ));
2226
+ };
2227
+ }
2228
+ });
2229
+
2230
+ var __typeError$1 = (msg) => {
2231
+ throw TypeError(msg);
2232
+ };
2233
+ var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Cannot " + msg);
2234
+ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
2235
+ var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2236
+ var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
2237
+ var _tooltipProvider, _content, _app, _selection, _show;
2238
+ const toolbarTooltip = tooltip.tooltipFactory("CREPE_TOOLBAR");
2239
+ class ToolbarView {
2240
+ constructor(ctx, view, config) {
2241
+ __privateAdd$1(this, _tooltipProvider);
2242
+ __privateAdd$1(this, _content);
2243
+ __privateAdd$1(this, _app);
2244
+ __privateAdd$1(this, _selection);
2245
+ __privateAdd$1(this, _show, vue.ref(false));
2246
+ this.update = (view, prevState) => {
2247
+ __privateGet$1(this, _tooltipProvider).update(view, prevState);
2248
+ __privateGet$1(this, _selection).value = view.state.selection;
2249
+ };
2250
+ this.destroy = () => {
2251
+ __privateGet$1(this, _tooltipProvider).destroy();
2252
+ __privateGet$1(this, _app).unmount();
2253
+ __privateGet$1(this, _content).remove();
2254
+ };
2255
+ this.hide = () => {
2256
+ __privateGet$1(this, _tooltipProvider).hide();
2257
+ };
2258
+ const content = document.createElement("div");
2259
+ content.className = "milkdown-toolbar";
2260
+ __privateSet$1(this, _selection, vue.shallowRef(view.state.selection));
2261
+ const app = vue.createApp(Toolbar, {
2262
+ ctx,
2263
+ hide: this.hide,
2264
+ config,
2265
+ selection: __privateGet$1(this, _selection),
2266
+ show: __privateGet$1(this, _show)
2267
+ });
2268
+ app.mount(content);
2269
+ __privateSet$1(this, _content, content);
2270
+ __privateSet$1(this, _app, app);
2271
+ __privateSet$1(this, _tooltipProvider, new tooltip.TooltipProvider({
2272
+ content: __privateGet$1(this, _content),
2273
+ debounce: 20,
2274
+ offset: 10,
2275
+ shouldShow(view2) {
2276
+ const { doc, selection } = view2.state;
2277
+ const { empty, from, to } = selection;
2278
+ const isEmptyTextBlock = !doc.textBetween(from, to).length && selection instanceof state.TextSelection;
2279
+ const isNotTextBlock = !(selection instanceof state.TextSelection);
2280
+ const activeElement = view2.dom.getRootNode().activeElement;
2281
+ const isTooltipChildren = content.contains(activeElement);
2282
+ const notHasFocus = !view2.hasFocus() && !isTooltipChildren;
2283
+ const isReadonly = !view2.editable;
2284
+ if (notHasFocus || isNotTextBlock || empty || isEmptyTextBlock || isReadonly)
2285
+ return false;
2286
+ return true;
2287
+ }
2288
+ }));
2289
+ __privateGet$1(this, _tooltipProvider).onShow = () => {
2290
+ __privateGet$1(this, _show).value = true;
2291
+ };
2292
+ __privateGet$1(this, _tooltipProvider).onHide = () => {
2293
+ __privateGet$1(this, _show).value = false;
2294
+ };
2295
+ this.update(view);
2296
+ }
2297
+ }
2298
+ _tooltipProvider = new WeakMap();
2299
+ _content = new WeakMap();
2300
+ _app = new WeakMap();
2301
+ _selection = new WeakMap();
2302
+ _show = new WeakMap();
2303
+ const toolbar = (editor, config) => {
2304
+ editor.config(crepeFeatureConfig(CrepeFeature.Toolbar)).config((ctx) => {
2305
+ ctx.set(toolbarTooltip.key, {
2306
+ view: (view) => new ToolbarView(ctx, view, config)
2307
+ });
2308
+ }).use(toolbarTooltip);
2309
+ };
2310
+
2311
+ function loadFeature(feature, editor, config) {
2312
+ switch (feature) {
2313
+ case CrepeFeature.CodeMirror: {
2314
+ return codeMirror(editor, config);
2315
+ }
2316
+ case CrepeFeature.ListItem: {
2317
+ return listItem(editor, config);
2318
+ }
2319
+ case CrepeFeature.LinkTooltip: {
2320
+ return linkTooltip(editor, config);
2321
+ }
2322
+ case CrepeFeature.ImageBlock: {
2323
+ return imageBlock(editor, config);
2324
+ }
2325
+ case CrepeFeature.Cursor: {
2326
+ return cursor(editor, config);
2327
+ }
2328
+ case CrepeFeature.BlockEdit: {
2329
+ return blockEdit(editor, config);
2330
+ }
2331
+ case CrepeFeature.Placeholder: {
2332
+ return placeholder(editor, config);
2333
+ }
2334
+ case CrepeFeature.Toolbar: {
2335
+ return toolbar(editor, config);
2336
+ }
2337
+ case CrepeFeature.Table: {
2338
+ return table(editor, config);
2339
+ }
2340
+ case CrepeFeature.Latex: {
2341
+ return latex(editor, config);
2342
+ }
2343
+ }
2344
+ }
2345
+
2346
+ var __typeError = (msg) => {
2347
+ throw TypeError(msg);
2348
+ };
2349
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
2350
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
2351
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2352
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
2353
+ var _editor, _rootElement, _editable;
2354
+ class CrepeBuilder {
2355
+ /// The constructor of the crepe builder.
2356
+ /// You can pass configs to the builder to configure the editor.
2357
+ constructor({ root, defaultValue = "" }) {
2358
+ /// @internal
2359
+ __privateAdd(this, _editor);
2360
+ /// @internal
2361
+ __privateAdd(this, _rootElement);
2362
+ /// @internal
2363
+ __privateAdd(this, _editable, true);
2364
+ /// Add a feature to the editor.
2365
+ this.addFeature = (feature, config) => {
2366
+ feature(__privateGet(this, _editor), config);
2367
+ return this;
2368
+ };
2369
+ /// Create the editor.
2370
+ this.create = () => {
2371
+ return __privateGet(this, _editor).create();
2372
+ };
2373
+ /// Destroy the editor.
2374
+ this.destroy = () => {
2375
+ return __privateGet(this, _editor).destroy();
2376
+ };
2377
+ /// Set the readonly mode of the editor.
2378
+ this.setReadonly = (value) => {
2379
+ __privateSet(this, _editable, !value);
2380
+ __privateGet(this, _editor).action((ctx) => {
2381
+ if (__privateGet(this, _editor).status === core.EditorStatus.Created) {
2382
+ const view = ctx.get(core.editorViewCtx);
2383
+ view.setProps({
2384
+ editable: () => !value
2385
+ });
2386
+ }
2387
+ });
2388
+ return this;
2389
+ };
2390
+ /// Get the markdown content of the editor.
2391
+ this.getMarkdown = () => {
2392
+ return __privateGet(this, _editor).action(utils.getMarkdown());
2393
+ };
2394
+ /// Register event listeners.
2395
+ this.on = (fn) => {
2396
+ if (__privateGet(this, _editor).status !== core.EditorStatus.Created) {
2397
+ __privateGet(this, _editor).config((ctx) => {
2398
+ const listener2 = ctx.get(listener.listenerCtx);
2399
+ fn(listener2);
2400
+ });
2401
+ return this;
2402
+ }
2403
+ __privateGet(this, _editor).action((ctx) => {
2404
+ const listener2 = ctx.get(listener.listenerCtx);
2405
+ fn(listener2);
2406
+ });
2407
+ return this;
2408
+ };
2409
+ var _a;
2410
+ __privateSet(this, _rootElement, (_a = typeof root === "string" ? document.querySelector(root) : root) != null ? _a : document.body);
2411
+ __privateSet(this, _editor, core.Editor.make().config((ctx) => {
2412
+ ctx.inject(CrepeCtx, this);
2413
+ ctx.inject(FeaturesCtx, []);
2414
+ }).config((ctx) => {
2415
+ ctx.set(core.rootCtx, __privateGet(this, _rootElement));
2416
+ ctx.set(core.defaultValueCtx, defaultValue);
2417
+ ctx.set(core.editorViewOptionsCtx, {
2418
+ editable: () => __privateGet(this, _editable)
2419
+ });
2420
+ ctx.update(indent.indentConfig.key, (value) => ({
2421
+ ...value,
2422
+ size: 4
2423
+ }));
2424
+ }).use(commonmark.commonmark).use(listener.listener).use(history$1.history).use(indent.indent).use(trailing.trailing).use(clipboard.clipboard).use(gfm.gfm));
2425
+ }
2426
+ /// Get the milkdown editor instance.
2427
+ get editor() {
2428
+ return __privateGet(this, _editor);
2429
+ }
2430
+ }
2431
+ _editor = new WeakMap();
2432
+ _rootElement = new WeakMap();
2433
+ _editable = new WeakMap();
2434
+
2435
+ class Crepe extends CrepeBuilder {
2436
+ /// The constructor of the crepe editor.
2437
+ /// You can pass configs to the editor to configure the editor.
2438
+ /// Calling the constructor will not create the editor, you need to call `create` to create the editor.
2439
+ constructor({
2440
+ features = {},
2441
+ featureConfigs = {},
2442
+ ...crepeBuilderConfig
2443
+ }) {
2444
+ super(crepeBuilderConfig);
2445
+ const finalConfigs = lodashEs.defaultsDeep(featureConfigs, defaultConfig);
2446
+ const enabledFeatures = Object.entries({
2447
+ ...defaultFeatures,
2448
+ ...features
2449
+ }).filter(([, enabled]) => enabled).map(([feature]) => feature);
2450
+ enabledFeatures.forEach((feature) => {
2451
+ const config = finalConfigs[feature];
2452
+ loadFeature(feature, this.editor, config);
2453
+ });
2454
+ }
2455
+ }
2456
+ /// This is an alias for the `CrepeFeature` enum.
2457
+ Crepe.Feature = CrepeFeature;
2458
+
2459
+ exports.Crepe = Crepe;
2460
+ exports.CrepeBuilder = CrepeBuilder;
2461
+ exports.CrepeFeature = CrepeFeature;
2462
+ exports.useCrepe = useCrepe;
2463
+ exports.useCrepeFeatures = useCrepeFeatures;
2464
+ //# sourceMappingURL=index.js.map