@milkdown/crepe 7.5.7 → 7.5.9

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