@milkdown/crepe 7.5.6 → 7.5.8

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 (227) hide show
  1. package/lib/cjs/{index-_mXHbJMH.js → index-3mj4YaCA.js} +5 -8
  2. package/lib/cjs/index-3mj4YaCA.js.map +1 -0
  3. package/lib/cjs/{index-wORIFtqa.js → index-A8IrOmzS.js} +33 -12
  4. package/lib/cjs/index-A8IrOmzS.js.map +1 -0
  5. package/lib/cjs/{index-z6pe2alg.js → index-AlHHvSR_.js} +1 -1
  6. package/lib/cjs/index-AlHHvSR_.js.map +1 -0
  7. package/lib/cjs/{index-YoPS8A3_.js → index-BIXWL4Or.js} +2 -2
  8. package/lib/cjs/index-BIXWL4Or.js.map +1 -0
  9. package/lib/cjs/{index-MLK151KV.js → index-BrCpWPcp.js} +2 -2
  10. package/lib/cjs/index-BrCpWPcp.js.map +1 -0
  11. package/lib/cjs/{index-uleaJDBC.js → index-BuSAwj4j.js} +1 -1
  12. package/lib/cjs/index-BuSAwj4j.js.map +1 -0
  13. package/lib/cjs/{index-vNNxr8yy.js → index-By3ewOiO.js} +173 -139
  14. package/lib/cjs/index-By3ewOiO.js.map +1 -0
  15. package/lib/cjs/{index-KeJUBENN.js → index-DmOOfQPi.js} +2 -2
  16. package/lib/cjs/index-DmOOfQPi.js.map +1 -0
  17. package/lib/cjs/index-Dt55rF23.js +35 -0
  18. package/lib/cjs/index-Dt55rF23.js.map +1 -0
  19. package/lib/cjs/{index-rFFAL9YA.js → index-Dub20F3z.js} +15 -17
  20. package/lib/cjs/index-Dub20F3z.js.map +1 -0
  21. package/lib/cjs/index.js +11 -13
  22. package/lib/cjs/index.js.map +1 -1
  23. package/lib/cjs/todoList-V4JWO5-M.js +675 -0
  24. package/lib/cjs/todoList-V4JWO5-M.js.map +1 -0
  25. package/lib/esm/{index-HHuxH8Dm.js → index-6VoEpEnX.js} +2 -2
  26. package/lib/esm/index-6VoEpEnX.js.map +1 -0
  27. package/lib/esm/{index-RJV0C6Af.js → index-BB3Rq6BU.js} +5 -8
  28. package/lib/esm/index-BB3Rq6BU.js.map +1 -0
  29. package/lib/esm/{index-uThMsyF6.js → index-BDGHz9p-.js} +2 -2
  30. package/lib/esm/index-BDGHz9p-.js.map +1 -0
  31. package/lib/esm/{index-X2mjLDJS.js → index-BoTKwL_u.js} +2 -2
  32. package/lib/esm/index-BoTKwL_u.js.map +1 -0
  33. package/lib/esm/{index-6JoGWH2I.js → index-CxJ9fxJm.js} +1 -1
  34. package/lib/esm/index-CxJ9fxJm.js.map +1 -0
  35. package/lib/esm/{index-Jvxff1vU.js → index-D6fLMv29.js} +1 -1
  36. package/lib/esm/index-D6fLMv29.js.map +1 -0
  37. package/lib/esm/{index-CMGDOz11.js → index-DOrkOhki.js} +15 -17
  38. package/lib/esm/index-DOrkOhki.js.map +1 -0
  39. package/lib/esm/index-DlX33Dj0.js +33 -0
  40. package/lib/esm/index-DlX33Dj0.js.map +1 -0
  41. package/lib/esm/{index-eZXAY3yz.js → index-kGl7HgN2.js} +33 -12
  42. package/lib/esm/index-kGl7HgN2.js.map +1 -0
  43. package/lib/esm/{index-sE0tYrbc.js → index-zKiGjwHz.js} +173 -139
  44. package/lib/esm/index-zKiGjwHz.js.map +1 -0
  45. package/lib/esm/index.js +11 -13
  46. package/lib/esm/index.js.map +1 -1
  47. package/lib/esm/todoList-CAbx4396.js +638 -0
  48. package/lib/esm/todoList-CAbx4396.js.map +1 -0
  49. package/lib/theme/_internal/classic-common.css +44 -19
  50. package/lib/theme/common/block-edit.css +12 -3
  51. package/lib/theme/common/code-mirror.css +1 -1
  52. package/lib/theme/common/cursor.css +7 -3
  53. package/lib/theme/common/image-block.css +28 -7
  54. package/lib/theme/common/link-tooltip.css +1 -0
  55. package/lib/theme/common/placeholder.css +5 -1
  56. package/lib/theme/common/prosemirror.css +1 -1
  57. package/lib/theme/common/style.css +10 -10
  58. package/lib/theme/common/table.css +17 -15
  59. package/lib/theme/common/toolbar.css +7 -3
  60. package/lib/theme/crepe/style.css +22 -20
  61. package/lib/theme/crepe-dark/style.css +25 -23
  62. package/lib/theme/frame/style.css +23 -20
  63. package/lib/theme/frame-dark/style.css +23 -20
  64. package/lib/theme/nord/style.css +25 -22
  65. package/lib/theme/nord-dark/style.css +23 -20
  66. package/lib/types/core/crepe.d.ts.map +1 -1
  67. package/lib/types/core/slice.d.ts +1 -1
  68. package/lib/types/core/slice.d.ts.map +1 -1
  69. package/lib/types/feature/block-edit/handle/component.d.ts.map +1 -1
  70. package/lib/types/feature/block-edit/handle/index.d.ts.map +1 -1
  71. package/lib/types/feature/block-edit/index.d.ts.map +1 -1
  72. package/lib/types/feature/block-edit/menu/component.d.ts.map +1 -1
  73. package/lib/types/feature/block-edit/menu/config.d.ts +2 -7
  74. package/lib/types/feature/block-edit/menu/config.d.ts.map +1 -1
  75. package/lib/types/feature/block-edit/menu/group-builder.d.ts +2 -2
  76. package/lib/types/feature/block-edit/menu/group-builder.d.ts.map +1 -1
  77. package/lib/types/feature/block-edit/menu/index.d.ts +2 -2
  78. package/lib/types/feature/block-edit/menu/index.d.ts.map +1 -1
  79. package/lib/types/feature/block-edit/menu/utils.d.ts.map +1 -1
  80. package/lib/types/feature/code-mirror/index.d.ts.map +1 -1
  81. package/lib/types/feature/cursor/index.d.ts.map +1 -1
  82. package/lib/types/feature/image-block/index.d.ts.map +1 -1
  83. package/lib/types/feature/index.d.ts.map +1 -1
  84. package/lib/types/feature/link-tooltip/index.d.ts.map +1 -1
  85. package/lib/types/feature/list-item/index.d.ts.map +1 -1
  86. package/lib/types/feature/placeholder/index.d.ts +2 -2
  87. package/lib/types/feature/placeholder/index.d.ts.map +1 -1
  88. package/lib/types/feature/shared.d.ts.map +1 -1
  89. package/lib/types/feature/table/index.d.ts.map +1 -1
  90. package/lib/types/feature/toolbar/component.d.ts.map +1 -1
  91. package/lib/types/feature/toolbar/index.d.ts.map +1 -1
  92. package/lib/types/icons/alignCenter.d.ts.map +1 -1
  93. package/lib/types/icons/alignLeft.d.ts.map +1 -1
  94. package/lib/types/icons/alignRight.d.ts.map +1 -1
  95. package/lib/types/icons/bold.d.ts.map +1 -1
  96. package/lib/types/icons/bullet.d.ts.map +1 -1
  97. package/lib/types/icons/bulletList.d.ts.map +1 -1
  98. package/lib/types/icons/caption.d.ts.map +1 -1
  99. package/lib/types/icons/checkBoxChecked.d.ts.map +1 -1
  100. package/lib/types/icons/checkBoxUnchecked.d.ts.map +1 -1
  101. package/lib/types/icons/chevronDown.d.ts.map +1 -1
  102. package/lib/types/icons/clear.d.ts.map +1 -1
  103. package/lib/types/icons/code.d.ts.map +1 -1
  104. package/lib/types/icons/confirm.d.ts.map +1 -1
  105. package/lib/types/icons/divider.d.ts.map +1 -1
  106. package/lib/types/icons/dragHandle.d.ts.map +1 -1
  107. package/lib/types/icons/edit.d.ts.map +1 -1
  108. package/lib/types/icons/h1.d.ts.map +1 -1
  109. package/lib/types/icons/h2.d.ts.map +1 -1
  110. package/lib/types/icons/h3.d.ts.map +1 -1
  111. package/lib/types/icons/h4.d.ts.map +1 -1
  112. package/lib/types/icons/h5.d.ts.map +1 -1
  113. package/lib/types/icons/h6.d.ts.map +1 -1
  114. package/lib/types/icons/image.d.ts.map +1 -1
  115. package/lib/types/icons/italic.d.ts.map +1 -1
  116. package/lib/types/icons/link.d.ts.map +1 -1
  117. package/lib/types/icons/menu.d.ts.map +1 -1
  118. package/lib/types/icons/orderedList.d.ts.map +1 -1
  119. package/lib/types/icons/plus.d.ts.map +1 -1
  120. package/lib/types/icons/quote.d.ts.map +1 -1
  121. package/lib/types/icons/remove.d.ts.map +1 -1
  122. package/lib/types/icons/search.d.ts.map +1 -1
  123. package/lib/types/icons/strikethrough.d.ts.map +1 -1
  124. package/lib/types/icons/table.d.ts.map +1 -1
  125. package/lib/types/icons/text.d.ts.map +1 -1
  126. package/lib/types/icons/todoList.d.ts.map +1 -1
  127. package/lib/types/utils/index.d.ts.map +1 -1
  128. package/package.json +3 -3
  129. package/src/core/crepe.ts +18 -12
  130. package/src/feature/block-edit/handle/component.ts +7 -4
  131. package/src/feature/block-edit/handle/index.ts +14 -11
  132. package/src/feature/block-edit/index.ts +6 -3
  133. package/src/feature/block-edit/menu/component.ts +138 -117
  134. package/src/feature/block-edit/menu/config.ts +42 -23
  135. package/src/feature/block-edit/menu/group-builder.ts +2 -3
  136. package/src/feature/block-edit/menu/index.ts +25 -15
  137. package/src/feature/block-edit/menu/utils.ts +45 -25
  138. package/src/feature/code-mirror/index.ts +20 -12
  139. package/src/feature/cursor/index.ts +4 -1
  140. package/src/feature/image-block/index.ts +20 -8
  141. package/src/feature/index.ts +5 -1
  142. package/src/feature/link-tooltip/index.ts +10 -3
  143. package/src/feature/list-item/index.ts +25 -8
  144. package/src/feature/placeholder/index.ts +19 -18
  145. package/src/feature/shared.ts +4 -1
  146. package/src/feature/table/index.ts +37 -29
  147. package/src/feature/toolbar/component.ts +40 -10
  148. package/src/feature/toolbar/index.ts +15 -9
  149. package/src/icons/alignCenter.ts +9 -2
  150. package/src/icons/alignLeft.ts +9 -2
  151. package/src/icons/alignRight.ts +9 -2
  152. package/src/icons/bold.ts +9 -2
  153. package/src/icons/bullet.ts +8 -3
  154. package/src/icons/bulletList.ts +10 -3
  155. package/src/icons/caption.ts +10 -2
  156. package/src/icons/checkBoxChecked.ts +10 -3
  157. package/src/icons/checkBoxUnchecked.ts +10 -3
  158. package/src/icons/chevronDown.ts +13 -2
  159. package/src/icons/clear.ts +10 -3
  160. package/src/icons/code.ts +10 -3
  161. package/src/icons/confirm.ts +11 -2
  162. package/src/icons/divider.ts +12 -3
  163. package/src/icons/dragHandle.ts +9 -2
  164. package/src/icons/edit.ts +10 -3
  165. package/src/icons/h1.ts +10 -3
  166. package/src/icons/h2.ts +10 -3
  167. package/src/icons/h3.ts +10 -3
  168. package/src/icons/h4.ts +10 -3
  169. package/src/icons/h5.ts +10 -3
  170. package/src/icons/h6.ts +10 -3
  171. package/src/icons/image.ts +10 -3
  172. package/src/icons/italic.ts +9 -2
  173. package/src/icons/link.ts +9 -2
  174. package/src/icons/menu.ts +10 -3
  175. package/src/icons/orderedList.ts +10 -3
  176. package/src/icons/plus.ts +10 -3
  177. package/src/icons/quote.ts +10 -3
  178. package/src/icons/remove.ts +9 -2
  179. package/src/icons/search.ts +13 -2
  180. package/src/icons/strikethrough.ts +9 -2
  181. package/src/icons/table.ts +10 -3
  182. package/src/icons/text.ts +10 -3
  183. package/src/icons/todoList.ts +9 -2
  184. package/src/theme/_internal/classic-common.css +39 -14
  185. package/src/theme/common/block-edit.css +12 -3
  186. package/src/theme/common/code-mirror.css +1 -1
  187. package/src/theme/common/cursor.css +7 -3
  188. package/src/theme/common/image-block.css +28 -7
  189. package/src/theme/common/link-tooltip.css +1 -0
  190. package/src/theme/common/placeholder.css +5 -1
  191. package/src/theme/common/prosemirror.css +1 -1
  192. package/src/theme/common/style.css +10 -10
  193. package/src/theme/common/table.css +17 -14
  194. package/src/theme/common/toolbar.css +7 -3
  195. package/src/theme/crepe/style.css +22 -20
  196. package/src/theme/crepe-dark/style.css +25 -23
  197. package/src/theme/frame/style.css +23 -20
  198. package/src/theme/frame-dark/style.css +23 -20
  199. package/src/theme/nord/style.css +25 -22
  200. package/src/theme/nord-dark/style.css +23 -20
  201. package/src/utils/index.ts +4 -1
  202. package/lib/cjs/index-9Lsv_-NW.js +0 -28
  203. package/lib/cjs/index-9Lsv_-NW.js.map +0 -1
  204. package/lib/cjs/index-KeJUBENN.js.map +0 -1
  205. package/lib/cjs/index-MLK151KV.js.map +0 -1
  206. package/lib/cjs/index-YoPS8A3_.js.map +0 -1
  207. package/lib/cjs/index-_mXHbJMH.js.map +0 -1
  208. package/lib/cjs/index-rFFAL9YA.js.map +0 -1
  209. package/lib/cjs/index-uleaJDBC.js.map +0 -1
  210. package/lib/cjs/index-vNNxr8yy.js.map +0 -1
  211. package/lib/cjs/index-wORIFtqa.js.map +0 -1
  212. package/lib/cjs/index-z6pe2alg.js.map +0 -1
  213. package/lib/cjs/todoList-Qb2JsRGC.js +0 -419
  214. package/lib/cjs/todoList-Qb2JsRGC.js.map +0 -1
  215. package/lib/esm/index-6JoGWH2I.js.map +0 -1
  216. package/lib/esm/index-CMGDOz11.js.map +0 -1
  217. package/lib/esm/index-HHuxH8Dm.js.map +0 -1
  218. package/lib/esm/index-J3c6JQEf.js +0 -26
  219. package/lib/esm/index-J3c6JQEf.js.map +0 -1
  220. package/lib/esm/index-Jvxff1vU.js.map +0 -1
  221. package/lib/esm/index-RJV0C6Af.js.map +0 -1
  222. package/lib/esm/index-X2mjLDJS.js.map +0 -1
  223. package/lib/esm/index-eZXAY3yz.js.map +0 -1
  224. package/lib/esm/index-sE0tYrbc.js.map +0 -1
  225. package/lib/esm/index-uThMsyF6.js.map +0 -1
  226. package/lib/esm/todoList-eAxCDaQj.js +0 -382
  227. package/lib/esm/todoList-eAxCDaQj.js.map +0 -1
@@ -7,11 +7,11 @@ var commonmark = require('@milkdown/kit/preset/commonmark');
7
7
  var prose = require('@milkdown/kit/prose');
8
8
  var slash = require('@milkdown/kit/plugin/slash');
9
9
  var utils = require('@milkdown/kit/utils');
10
- var index = require('./index-z6pe2alg.js');
10
+ var index = require('./index-AlHHvSR_.js');
11
11
  var atomico = require('atomico');
12
12
  var imageBlock = require('@milkdown/kit/component/image-block');
13
13
  var gfm = require('@milkdown/kit/preset/gfm');
14
- var todoList = require('./todoList-Qb2JsRGC.js');
14
+ var todoList = require('./todoList-V4JWO5-M.js');
15
15
  var transform = require('@milkdown/kit/prose/transform');
16
16
 
17
17
  function clearRange(tr) {
@@ -29,14 +29,12 @@ function wrapInBlockType(tr, nodeType, attrs = null) {
29
29
  const { $from, $to } = tr.selection;
30
30
  const range = $from.blockRange($to);
31
31
  const wrapping = range && transform.findWrapping(range, nodeType, attrs);
32
- if (!wrapping)
33
- return null;
32
+ if (!wrapping) return null;
34
33
  return tr.wrap(range, wrapping);
35
34
  }
36
35
  function addBlockType(tr, nodeType, attrs = null) {
37
36
  const node = nodeType.createAndFill(attrs);
38
- if (!node)
39
- return null;
37
+ if (!node) return null;
40
38
  return tr.replaceSelectionWith(node);
41
39
  }
42
40
  function clearContentAndSetBlockType(nodeType, attrs = null) {
@@ -51,20 +49,16 @@ function clearContentAndSetBlockType(nodeType, attrs = null) {
51
49
  function clearContentAndWrapInBlockType(nodeType, attrs = null) {
52
50
  return (state, dispatch) => {
53
51
  const tr = wrapInBlockType(clearRange(state.tr), nodeType, attrs);
54
- if (!tr)
55
- return false;
56
- if (dispatch)
57
- dispatch(tr.scrollIntoView());
52
+ if (!tr) return false;
53
+ if (dispatch) dispatch(tr.scrollIntoView());
58
54
  return true;
59
55
  };
60
56
  }
61
57
  function clearContentAndAddBlockType(nodeType, attrs = null) {
62
58
  return (state, dispatch) => {
63
59
  const tr = addBlockType(clearRange(state.tr), nodeType, attrs);
64
- if (!tr)
65
- return false;
66
- if (dispatch)
67
- dispatch(tr.scrollIntoView());
60
+ if (!tr) return false;
61
+ if (dispatch) dispatch(tr.scrollIntoView());
68
62
  return true;
69
63
  };
70
64
  }
@@ -75,7 +69,7 @@ var __typeError$2 = (msg) => {
75
69
  var __accessCheck$2 = (obj, member, msg) => member.has(obj) || __typeError$2("Cannot " + msg);
76
70
  var __privateGet$2 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
77
71
  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);
78
- var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$2(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
72
+ var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$2(obj, member, "write to private field"), member.set(obj, value), value);
79
73
  var _groups, _getGroupInstance;
80
74
  class GroupBuilder {
81
75
  constructor() {
@@ -111,8 +105,7 @@ class GroupBuilder {
111
105
  };
112
106
  this.getGroup = (key) => {
113
107
  const group = __privateGet$2(this, _groups).find((group2) => group2.key === key);
114
- if (!group)
115
- throw new Error(`Group with key ${key} not found`);
108
+ if (!group) throw new Error(`Group with key ${key} not found`);
116
109
  return __privateGet$2(this, _getGroupInstance).call(this, group);
117
110
  };
118
111
  this.build = () => {
@@ -141,7 +134,9 @@ function getGroups(filter, config) {
141
134
  onRun: (ctx) => {
142
135
  const view = ctx.get(core.editorViewCtx);
143
136
  const { dispatch, state } = view;
144
- const command = clearContentAndSetBlockType(commonmark.headingSchema.type(ctx), { level: 1 });
137
+ const command = clearContentAndSetBlockType(commonmark.headingSchema.type(ctx), {
138
+ level: 1
139
+ });
145
140
  command(state, dispatch);
146
141
  }
147
142
  }).addItem("h2", {
@@ -150,7 +145,9 @@ function getGroups(filter, config) {
150
145
  onRun: (ctx) => {
151
146
  const view = ctx.get(core.editorViewCtx);
152
147
  const { dispatch, state } = view;
153
- const command = clearContentAndSetBlockType(commonmark.headingSchema.type(ctx), { level: 2 });
148
+ const command = clearContentAndSetBlockType(commonmark.headingSchema.type(ctx), {
149
+ level: 2
150
+ });
154
151
  command(state, dispatch);
155
152
  }
156
153
  }).addItem("h3", {
@@ -159,7 +156,9 @@ function getGroups(filter, config) {
159
156
  onRun: (ctx) => {
160
157
  const view = ctx.get(core.editorViewCtx);
161
158
  const { dispatch, state } = view;
162
- const command = clearContentAndSetBlockType(commonmark.headingSchema.type(ctx), { level: 3 });
159
+ const command = clearContentAndSetBlockType(commonmark.headingSchema.type(ctx), {
160
+ level: 3
161
+ });
163
162
  command(state, dispatch);
164
163
  }
165
164
  }).addItem("h4", {
@@ -168,7 +167,9 @@ function getGroups(filter, config) {
168
167
  onRun: (ctx) => {
169
168
  const view = ctx.get(core.editorViewCtx);
170
169
  const { dispatch, state } = view;
171
- const command = clearContentAndSetBlockType(commonmark.headingSchema.type(ctx), { level: 4 });
170
+ const command = clearContentAndSetBlockType(commonmark.headingSchema.type(ctx), {
171
+ level: 4
172
+ });
172
173
  command(state, dispatch);
173
174
  }
174
175
  }).addItem("h5", {
@@ -177,7 +178,9 @@ function getGroups(filter, config) {
177
178
  onRun: (ctx) => {
178
179
  const view = ctx.get(core.editorViewCtx);
179
180
  const { dispatch, state } = view;
180
- const command = clearContentAndSetBlockType(commonmark.headingSchema.type(ctx), { level: 5 });
181
+ const command = clearContentAndSetBlockType(commonmark.headingSchema.type(ctx), {
182
+ level: 5
183
+ });
181
184
  command(state, dispatch);
182
185
  }
183
186
  }).addItem("h6", {
@@ -186,7 +189,9 @@ function getGroups(filter, config) {
186
189
  onRun: (ctx) => {
187
190
  const view = ctx.get(core.editorViewCtx);
188
191
  const { dispatch, state } = view;
189
- const command = clearContentAndSetBlockType(commonmark.headingSchema.type(ctx), { level: 6 });
192
+ const command = clearContentAndSetBlockType(commonmark.headingSchema.type(ctx), {
193
+ level: 6
194
+ });
190
195
  command(state, dispatch);
191
196
  }
192
197
  }).addItem("quote", {
@@ -195,7 +200,9 @@ function getGroups(filter, config) {
195
200
  onRun: (ctx) => {
196
201
  const view = ctx.get(core.editorViewCtx);
197
202
  const { dispatch, state } = view;
198
- const command = clearContentAndWrapInBlockType(commonmark.blockquoteSchema.type(ctx));
203
+ const command = clearContentAndWrapInBlockType(
204
+ commonmark.blockquoteSchema.type(ctx)
205
+ );
199
206
  command(state, dispatch);
200
207
  }
201
208
  }).addItem("divider", {
@@ -214,7 +221,9 @@ function getGroups(filter, config) {
214
221
  onRun: (ctx) => {
215
222
  const view = ctx.get(core.editorViewCtx);
216
223
  const { dispatch, state } = view;
217
- const command = clearContentAndWrapInBlockType(commonmark.bulletListSchema.type(ctx));
224
+ const command = clearContentAndWrapInBlockType(
225
+ commonmark.bulletListSchema.type(ctx)
226
+ );
218
227
  command(state, dispatch);
219
228
  }
220
229
  }).addItem("ordered-list", {
@@ -223,7 +232,9 @@ function getGroups(filter, config) {
223
232
  onRun: (ctx) => {
224
233
  const view = ctx.get(core.editorViewCtx);
225
234
  const { dispatch, state } = view;
226
- const command = clearContentAndWrapInBlockType(commonmark.orderedListSchema.type(ctx));
235
+ const command = clearContentAndWrapInBlockType(
236
+ commonmark.orderedListSchema.type(ctx)
237
+ );
227
238
  command(state, dispatch);
228
239
  }
229
240
  }).addItem("todo-list", {
@@ -232,7 +243,10 @@ function getGroups(filter, config) {
232
243
  onRun: (ctx) => {
233
244
  const view = ctx.get(core.editorViewCtx);
234
245
  const { dispatch, state } = view;
235
- const command = clearContentAndWrapInBlockType(commonmark.listItemSchema.type(ctx), { checked: false });
246
+ const command = clearContentAndWrapInBlockType(
247
+ commonmark.listItemSchema.type(ctx),
248
+ { checked: false }
249
+ );
236
250
  command(state, dispatch);
237
251
  }
238
252
  });
@@ -276,7 +290,9 @@ function getGroups(filter, config) {
276
290
  let groups = groupBuilder.build();
277
291
  if (filter) {
278
292
  groups = groups.map((group) => {
279
- const items2 = group.items.filter((item) => item.label.toLowerCase().includes(filter.toLowerCase()));
293
+ const items2 = group.items.filter(
294
+ (item) => item.label.toLowerCase().includes(filter.toLowerCase())
295
+ );
280
296
  return {
281
297
  ...group,
282
298
  items: items2
@@ -314,93 +330,104 @@ const menuComponent = ({
314
330
  const prevMousePosition = atomico.useRef({ x: -999, y: -999 });
315
331
  const onMouseMove = atomico.useCallback((e) => {
316
332
  const prevPos = prevMousePosition.current;
317
- if (!prevPos)
318
- return;
333
+ if (!prevPos) return;
319
334
  const { x, y } = e;
320
335
  prevPos.x = x;
321
336
  prevPos.y = y;
322
337
  }, []);
323
338
  atomico.useEffect(() => {
324
- if (size === 0 && show)
325
- hide == null ? void 0 : hide();
339
+ if (size === 0 && show) hide == null ? void 0 : hide();
340
+ else if (hoverIndex >= size) setHoverIndex(0);
326
341
  }, [size, show]);
327
- const onHover = atomico.useCallback((index, after) => {
328
- setHoverIndex((prev) => {
329
- const next = typeof index === "function" ? index(prev) : index;
330
- after == null ? void 0 : after(next);
331
- return next;
332
- });
333
- }, []);
342
+ const onHover = atomico.useCallback(
343
+ (index, after) => {
344
+ setHoverIndex((prev) => {
345
+ const next = typeof index === "function" ? index(prev) : index;
346
+ after == null ? void 0 : after(next);
347
+ return next;
348
+ });
349
+ },
350
+ []
351
+ );
334
352
  const scrollToIndex = atomico.useCallback((index) => {
335
- const target = host.current.querySelector(`[data-index="${index}"]`);
353
+ const target = host.current.querySelector(
354
+ `[data-index="${index}"]`
355
+ );
336
356
  const scrollRoot = host.current.querySelector(".menu-groups");
337
- if (!target || !scrollRoot)
338
- return;
357
+ if (!target || !scrollRoot) return;
339
358
  scrollRoot.scrollTop = target.offsetTop - scrollRoot.offsetTop;
340
359
  }, []);
341
- const runByIndex = atomico.useCallback((index) => {
342
- const item = groups.flatMap((group) => group.items).at(index);
343
- if (item && ctx)
344
- item.onRun(ctx);
345
- hide == null ? void 0 : hide();
346
- }, [groups]);
347
- const onKeydown = atomico.useCallback((e) => {
348
- if (e.key === "Escape") {
349
- e.preventDefault();
360
+ const runByIndex = atomico.useCallback(
361
+ (index) => {
362
+ const item = groups.flatMap((group) => group.items).at(index);
363
+ if (item && ctx) item.onRun(ctx);
350
364
  hide == null ? void 0 : hide();
351
- return;
352
- }
353
- if (e.key === "ArrowDown") {
354
- e.preventDefault();
355
- return onHover((index) => index < size - 1 ? index + 1 : index, scrollToIndex);
356
- }
357
- if (e.key === "ArrowUp") {
358
- e.preventDefault();
359
- return onHover((index) => index <= 0 ? index : index - 1, scrollToIndex);
360
- }
361
- if (e.key === "ArrowLeft") {
362
- e.preventDefault();
363
- return onHover((index) => {
364
- const group = groups.find((group2) => group2.range[0] <= index && group2.range[1] > index);
365
- if (!group)
366
- return index;
367
- const prevGroup = groups[groups.indexOf(group) - 1];
368
- if (!prevGroup)
369
- return index;
370
- return prevGroup.range[1] - 1;
371
- }, scrollToIndex);
372
- }
373
- if (e.key === "ArrowRight") {
374
- e.preventDefault();
375
- return onHover((index) => {
376
- const group = groups.find((group2) => group2.range[0] <= index && group2.range[1] > index);
377
- if (!group)
378
- return index;
379
- const nextGroup = groups[groups.indexOf(group) + 1];
380
- if (!nextGroup)
381
- return index;
382
- return nextGroup.range[0];
383
- }, scrollToIndex);
384
- }
385
- if (e.key === "Enter") {
386
- e.preventDefault();
387
- runByIndex(hoverIndex);
388
- }
389
- }, [hide, groups, hoverIndex]);
365
+ },
366
+ [groups]
367
+ );
368
+ const onKeydown = atomico.useCallback(
369
+ (e) => {
370
+ if (e.key === "Escape") {
371
+ e.preventDefault();
372
+ hide == null ? void 0 : hide();
373
+ return;
374
+ }
375
+ if (e.key === "ArrowDown") {
376
+ e.preventDefault();
377
+ return onHover(
378
+ (index) => index < size - 1 ? index + 1 : index,
379
+ scrollToIndex
380
+ );
381
+ }
382
+ if (e.key === "ArrowUp") {
383
+ e.preventDefault();
384
+ return onHover(
385
+ (index) => index <= 0 ? index : index - 1,
386
+ scrollToIndex
387
+ );
388
+ }
389
+ if (e.key === "ArrowLeft") {
390
+ e.preventDefault();
391
+ return onHover((index) => {
392
+ const group = groups.find(
393
+ (group2) => group2.range[0] <= index && group2.range[1] > index
394
+ );
395
+ if (!group) return index;
396
+ const prevGroup = groups[groups.indexOf(group) - 1];
397
+ if (!prevGroup) return index;
398
+ return prevGroup.range[1] - 1;
399
+ }, scrollToIndex);
400
+ }
401
+ if (e.key === "ArrowRight") {
402
+ e.preventDefault();
403
+ return onHover((index) => {
404
+ const group = groups.find(
405
+ (group2) => group2.range[0] <= index && group2.range[1] > index
406
+ );
407
+ if (!group) return index;
408
+ const nextGroup = groups[groups.indexOf(group) + 1];
409
+ if (!nextGroup) return index;
410
+ return nextGroup.range[0];
411
+ }, scrollToIndex);
412
+ }
413
+ if (e.key === "Enter") {
414
+ e.preventDefault();
415
+ runByIndex(hoverIndex);
416
+ }
417
+ },
418
+ [hide, groups, hoverIndex]
419
+ );
390
420
  const onMouseEnter = atomico.useCallback((index) => {
391
421
  return (e) => {
392
422
  const prevPos = prevMousePosition.current;
393
- if (!prevPos)
394
- return;
423
+ if (!prevPos) return;
395
424
  const { x, y } = e;
396
- if (x === prevPos.x && y === prevPos.y)
397
- return;
425
+ if (x === prevPos.x && y === prevPos.y) return;
398
426
  onHover(index);
399
427
  };
400
428
  }, []);
401
429
  atomico.useEffect(() => {
402
- if (show)
403
- root.addEventListener("keydown", onKeydown, { capture: true });
430
+ if (show) root.addEventListener("keydown", onKeydown, { capture: true });
404
431
  else root.removeEventListener("keydown", onKeydown, { capture: true });
405
432
  return () => {
406
433
  root.removeEventListener("keydown", onKeydown, { capture: true });
@@ -410,13 +437,15 @@ const menuComponent = ({
410
437
  <host onmousedown=${(e) => e.preventDefault()}>
411
438
  <nav class="tab-group">
412
439
  <ul>
413
- ${groups.map((group) => atomico.html`<li
414
- key=${group.key}
415
- onmousedown=${() => onHover(group.range[0], scrollToIndex)}
416
- class=${hoverIndex >= group.range[0] && hoverIndex < group.range[1] ? "selected" : ""}
417
- >
418
- ${group.label}
419
- </li>`)}
440
+ ${groups.map(
441
+ (group) => atomico.html`<li
442
+ key=${group.key}
443
+ onmousedown=${() => onHover(group.range[0], scrollToIndex)}
444
+ class=${hoverIndex >= group.range[0] && hoverIndex < group.range[1] ? "selected" : ""}
445
+ >
446
+ ${group.label}
447
+ </li>`
448
+ )}
420
449
  </ul>
421
450
  </nav>
422
451
  <div class="menu-groups" onmousemove=${onMouseMove}>
@@ -427,23 +456,23 @@ const menuComponent = ({
427
456
  <ul>
428
457
  ${group.items.map(
429
458
  (item) => atomico.html`<li
430
- key=${item.key}
431
- data-index=${item.index}
432
- class=${hoverIndex === item.index ? "hover" : ""}
433
- onmouseenter=${onMouseEnter(item.index)}
434
- onmousedown=${() => {
459
+ key=${item.key}
460
+ data-index=${item.index}
461
+ class=${hoverIndex === item.index ? "hover" : ""}
462
+ onmouseenter=${onMouseEnter(item.index)}
463
+ onmousedown=${() => {
435
464
  var _a;
436
465
  (_a = host.current.querySelector(`[data-index="${item.index}"]`)) == null ? void 0 : _a.classList.add("active");
437
466
  }}
438
- onmouseup=${() => {
467
+ onmouseup=${() => {
439
468
  var _a;
440
469
  (_a = host.current.querySelector(`[data-index="${item.index}"]`)) == null ? void 0 : _a.classList.remove("active");
441
470
  runByIndex(item.index);
442
471
  }}
443
- >
444
- ${item.icon}
445
- <span>${item.label}</span>
446
- </li>`
472
+ >
473
+ ${item.icon}
474
+ <span>${item.label}</span>
475
+ </li>`
447
476
  )}
448
477
  </ul>
449
478
  </div>
@@ -468,15 +497,18 @@ var __typeError$1 = (msg) => {
468
497
  var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Cannot " + msg);
469
498
  var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
470
499
  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);
471
- var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
500
+ var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
472
501
  var _content$1, _slashProvider, _programmaticallyPos;
473
502
  const menu = slash.slashFactory("CREPE_MENU");
474
- const menuAPI = utils.$ctx({
475
- show: () => {
503
+ const menuAPI = utils.$ctx(
504
+ {
505
+ show: () => {
506
+ },
507
+ hide: () => {
508
+ }
476
509
  },
477
- hide: () => {
478
- }
479
- }, "menuAPICtx");
510
+ "menuAPICtx"
511
+ );
480
512
  index.defIfNotExists("milkdown-slash-menu", MenuElement);
481
513
  function configureMenu(ctx, config) {
482
514
  ctx.set(menu.key, {
@@ -515,9 +547,11 @@ class MenuView {
515
547
  shouldShow(view2) {
516
548
  if (index.isInCodeBlock(view2.state.selection) || index.isInList(view2.state.selection))
517
549
  return false;
518
- const currentText = this.getContent(view2, (node) => ["paragraph", "heading"].includes(node.type.name));
519
- if (currentText == null)
520
- return false;
550
+ const currentText = this.getContent(
551
+ view2,
552
+ (node) => ["paragraph", "heading"].includes(node.type.name)
553
+ );
554
+ if (currentText == null) return false;
521
555
  const pos = __privateGet$1(self, _programmaticallyPos);
522
556
  __privateGet$1(self, _content$1).filter = currentText.startsWith("/") ? currentText.slice(1) : currentText;
523
557
  if (typeof pos === "number") {
@@ -527,8 +561,7 @@ class MenuView {
527
561
  }
528
562
  return true;
529
563
  }
530
- if (!currentText.startsWith("/"))
531
- return false;
564
+ if (!currentText.startsWith("/")) return false;
532
565
  return true;
533
566
  },
534
567
  offset: 10
@@ -575,12 +608,15 @@ const blockHandleComponent = ({
575
608
  };
576
609
  return atomico.html`
577
610
  <host>
578
- <div ref=${ref} onmousedown=${onMouseDown} onmouseup=${onMouseUp} class="operation-item">
611
+ <div
612
+ ref=${ref}
613
+ onmousedown=${onMouseDown}
614
+ onmouseup=${onMouseUp}
615
+ class="operation-item"
616
+ >
579
617
  ${(addIcon == null ? void 0 : addIcon()) || todoList.plusIcon}
580
618
  </div>
581
- <div class="operation-item">
582
- ${(handleIcon == null ? void 0 : handleIcon()) || todoList.menuIcon}
583
- </div>
619
+ <div class="operation-item">${(handleIcon == null ? void 0 : handleIcon()) || todoList.menuIcon}</div>
584
620
  </host>
585
621
  `;
586
622
  };
@@ -598,7 +634,7 @@ var __typeError = (msg) => {
598
634
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
599
635
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
600
636
  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);
601
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
637
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
602
638
  var _content, _provider, _ctx;
603
639
  class BlockHandleView {
604
640
  constructor(ctx, config) {
@@ -615,12 +651,10 @@ class BlockHandleView {
615
651
  this.onAdd = () => {
616
652
  const ctx = __privateGet(this, _ctx);
617
653
  const view = ctx.get(core.editorViewCtx);
618
- if (!view.hasFocus())
619
- view.focus();
654
+ if (!view.hasFocus()) view.focus();
620
655
  const { state: state$1, dispatch } = view;
621
656
  const active = __privateGet(this, _provider).active;
622
- if (!active)
623
- return;
657
+ if (!active) return;
624
658
  const $pos = active.$pos;
625
659
  const pos = $pos.pos + active.node.nodeSize;
626
660
  let tr = state$1.tr.insert(pos, commonmark.paragraphSchema.type(ctx).create());
@@ -640,8 +674,7 @@ class BlockHandleView {
640
674
  content,
641
675
  getOffset: () => 16,
642
676
  getPlacement: ({ active, blockDom }) => {
643
- if (active.node.type.name === "heading")
644
- return "left";
677
+ if (active.node.type.name === "heading") return "left";
645
678
  let totalDescendant = 0;
646
679
  active.node.descendants((node) => {
647
680
  totalDescendant += node.childCount;
@@ -667,9 +700,10 @@ index.defIfNotExists("milkdown-block-handle", BlockHandleElement);
667
700
  function configureBlockHandle(ctx, config) {
668
701
  ctx.set(block.blockConfig.key, {
669
702
  filterNodes: (pos) => {
670
- const filter = prose.findParent((node) => ["table", "blockquote"].includes(node.type.name))(pos);
671
- if (filter)
672
- return false;
703
+ const filter = prose.findParent(
704
+ (node) => ["table", "blockquote"].includes(node.type.name)
705
+ )(pos);
706
+ if (filter) return false;
673
707
  return true;
674
708
  }
675
709
  });
@@ -683,4 +717,4 @@ const defineFeature = (editor, config) => {
683
717
  };
684
718
 
685
719
  exports.defineFeature = defineFeature;
686
- //# sourceMappingURL=index-vNNxr8yy.js.map
720
+ //# sourceMappingURL=index-By3ewOiO.js.map