@caspeco/casper-ui-library 9.9.0 → 9.11.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 (107) hide show
  1. package/dist/_virtual/index.js +5 -0
  2. package/dist/_virtual/index2.js +4 -0
  3. package/dist/_virtual/use-sync-external-store-shim.development.js +4 -0
  4. package/dist/_virtual/use-sync-external-store-shim.production.js +4 -0
  5. package/dist/_virtual/with-selector.development.js +4 -0
  6. package/dist/_virtual/with-selector.js +5 -0
  7. package/dist/_virtual/with-selector.production.js +4 -0
  8. package/dist/_virtual/with-selector2.js +4 -0
  9. package/dist/components/button/button-recipe.d.ts.map +1 -1
  10. package/dist/components/button/button-recipe.js +80 -39
  11. package/dist/components/input/input.d.ts +1 -0
  12. package/dist/components/input/input.d.ts.map +1 -1
  13. package/dist/components/input/types.d.ts +1 -1
  14. package/dist/components/input/types.d.ts.map +1 -1
  15. package/dist/components/rich-text-editor/boolean-control.d.ts +3 -0
  16. package/dist/components/rich-text-editor/boolean-control.d.ts.map +1 -0
  17. package/dist/components/rich-text-editor/boolean-control.js +35 -0
  18. package/dist/components/rich-text-editor/extensions.d.ts +4 -0
  19. package/dist/components/rich-text-editor/extensions.d.ts.map +1 -0
  20. package/dist/components/rich-text-editor/extensions.js +37 -0
  21. package/dist/components/rich-text-editor/index.d.ts +26 -0
  22. package/dist/components/rich-text-editor/index.d.ts.map +1 -0
  23. package/dist/components/rich-text-editor/index.js +23 -0
  24. package/dist/components/rich-text-editor/rich-text-editor-context.d.ts +10 -0
  25. package/dist/components/rich-text-editor/rich-text-editor-context.d.ts.map +1 -0
  26. package/dist/components/rich-text-editor/rich-text-editor-context.js +13 -0
  27. package/dist/components/rich-text-editor/rich-text-editor-control.d.ts +11 -0
  28. package/dist/components/rich-text-editor/rich-text-editor-control.d.ts.map +1 -0
  29. package/dist/components/rich-text-editor/rich-text-editor-control.js +202 -0
  30. package/dist/components/rich-text-editor/rich-text-editor-recipe.d.ts +4 -0
  31. package/dist/components/rich-text-editor/rich-text-editor-recipe.d.ts.map +1 -0
  32. package/dist/components/rich-text-editor/rich-text-editor-recipe.js +58 -0
  33. package/dist/components/rich-text-editor/rich-text-editor.composition.d.ts +6 -0
  34. package/dist/components/rich-text-editor/rich-text-editor.composition.d.ts.map +1 -0
  35. package/dist/components/rich-text-editor/rich-text-editor.d.ts +11 -0
  36. package/dist/components/rich-text-editor/rich-text-editor.d.ts.map +1 -0
  37. package/dist/components/rich-text-editor/rich-text-editor.js +60 -0
  38. package/dist/components/rich-text-editor/rich-text-editor.test.d.ts +2 -0
  39. package/dist/components/rich-text-editor/rich-text-editor.test.d.ts.map +1 -0
  40. package/dist/components/rich-text-editor/rich-text-editor.visual.test.d.ts +2 -0
  41. package/dist/components/rich-text-editor/rich-text-editor.visual.test.d.ts.map +1 -0
  42. package/dist/components/rich-text-editor/rich-text-renderer.d.ts +3 -0
  43. package/dist/components/rich-text-editor/rich-text-renderer.d.ts.map +1 -0
  44. package/dist/components/rich-text-editor/rich-text-renderer.js +21 -0
  45. package/dist/components/rich-text-editor/translations.d.ts +23 -0
  46. package/dist/components/rich-text-editor/translations.d.ts.map +1 -0
  47. package/dist/components/rich-text-editor/translations.js +120 -0
  48. package/dist/components/rich-text-editor/types.d.ts +30 -0
  49. package/dist/components/rich-text-editor/types.d.ts.map +1 -0
  50. package/dist/components/rich-text-editor/use-rich-text-editor.d.ts +3 -0
  51. package/dist/components/rich-text-editor/use-rich-text-editor.d.ts.map +1 -0
  52. package/dist/components/rich-text-editor/use-rich-text-editor.js +17 -0
  53. package/dist/components/table/table-header-dropdown.d.ts.map +1 -1
  54. package/dist/components/table/table-header-dropdown.js +68 -66
  55. package/dist/components/toggle-button/toggle-button.d.ts.map +1 -1
  56. package/dist/components/toggle-button/toggle-button.js +11 -11
  57. package/dist/components/toggle-button/types.d.ts +2 -0
  58. package/dist/components/toggle-button/types.d.ts.map +1 -1
  59. package/dist/index.d.ts +1 -0
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +774 -763
  62. package/dist/node_modules/@tanstack/react-virtual/dist/esm/index.js +83 -31
  63. package/dist/node_modules/@tanstack/virtual-core/dist/esm/index.js +411 -226
  64. package/dist/node_modules/@tanstack/virtual-core/dist/esm/lazy-measurements.js +33 -0
  65. package/dist/node_modules/@tanstack/virtual-core/dist/esm/utils.js +29 -28
  66. package/dist/node_modules/@tiptap/core/dist/index.js +3953 -0
  67. package/dist/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js +19 -0
  68. package/dist/node_modules/@tiptap/extension-blockquote/dist/index.js +62 -0
  69. package/dist/node_modules/@tiptap/extension-bold/dist/index.js +85 -0
  70. package/dist/node_modules/@tiptap/extension-code/dist/index.js +54 -0
  71. package/dist/node_modules/@tiptap/extension-code-block/dist/index.js +219 -0
  72. package/dist/node_modules/@tiptap/extension-document/dist/index.js +12 -0
  73. package/dist/node_modules/@tiptap/extension-hard-break/dist/index.js +61 -0
  74. package/dist/node_modules/@tiptap/extension-heading/dist/index.js +67 -0
  75. package/dist/node_modules/@tiptap/extension-horizontal-rule/dist/index.js +56 -0
  76. package/dist/node_modules/@tiptap/extension-italic/dist/index.js +83 -0
  77. package/dist/node_modules/@tiptap/extension-link/dist/index.js +341 -0
  78. package/dist/node_modules/@tiptap/extension-list/dist/index.js +796 -0
  79. package/dist/node_modules/@tiptap/extension-paragraph/dist/index.js +49 -0
  80. package/dist/node_modules/@tiptap/extension-strike/dist/index.js +66 -0
  81. package/dist/node_modules/@tiptap/extension-text/dist/index.js +13 -0
  82. package/dist/node_modules/@tiptap/extension-underline/dist/index.js +65 -0
  83. package/dist/node_modules/@tiptap/extensions/dist/index.js +446 -0
  84. package/dist/node_modules/@tiptap/starter-kit/dist/index.js +28 -0
  85. package/dist/node_modules/fast-equals/dist/es/index.js +324 -0
  86. package/dist/node_modules/linkifyjs/dist/linkify.js +705 -0
  87. package/dist/node_modules/orderedmap/dist/index.js +103 -0
  88. package/dist/node_modules/prosemirror-commands/dist/index.js +388 -0
  89. package/dist/node_modules/prosemirror-dropcursor/dist/index.js +86 -0
  90. package/dist/node_modules/prosemirror-gapcursor/dist/index.js +204 -0
  91. package/dist/node_modules/prosemirror-history/dist/index.js +248 -0
  92. package/dist/node_modules/prosemirror-keymap/dist/index.js +62 -0
  93. package/dist/node_modules/prosemirror-model/dist/index.js +2736 -0
  94. package/dist/node_modules/prosemirror-schema-list/dist/index.js +88 -0
  95. package/dist/node_modules/prosemirror-state/dist/index.js +822 -0
  96. package/dist/node_modules/prosemirror-transform/dist/index.js +1552 -0
  97. package/dist/node_modules/prosemirror-view/dist/index.js +3802 -0
  98. package/dist/node_modules/rope-sequence/dist/index.js +100 -0
  99. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +58 -0
  100. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js +57 -0
  101. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +58 -0
  102. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +46 -0
  103. package/dist/node_modules/use-sync-external-store/shim/index.js +10 -0
  104. package/dist/node_modules/use-sync-external-store/shim/with-selector.js +10 -0
  105. package/dist/node_modules/w3c-keyname/index.js +93 -0
  106. package/dist/packages/casper-ui-library/node_modules/@tiptap/react/dist/index.js +506 -0
  107. package/package.json +14 -8
@@ -0,0 +1,796 @@
1
+ import { Node as g, wrappingInputRule as b, mergeAttributes as L, renderNestedMarkdownContent as $, Extension as S, isNodeActive as I, isAtStartOfNode as K, isAtEndOfNode as z, getNodeType as O, getNodeAtPosition as V, getRenderedAttributes as X, parseIndentedBlocks as x } from "../../core/dist/index.js";
2
+ var F = Object.defineProperty, G = (t, e) => {
3
+ for (var s in e)
4
+ F(t, s, { get: e[s], enumerable: !0 });
5
+ }, W = "listItem", w = "textStyle", C = /^\s*([-+*])\s$/, q = g.create({
6
+ name: "bulletList",
7
+ addOptions() {
8
+ return {
9
+ itemTypeName: "listItem",
10
+ HTMLAttributes: {},
11
+ keepMarks: !1,
12
+ keepAttributes: !1
13
+ };
14
+ },
15
+ group: "block list",
16
+ content() {
17
+ return `${this.options.itemTypeName}+`;
18
+ },
19
+ parseHTML() {
20
+ return [{ tag: "ul" }];
21
+ },
22
+ renderHTML({ HTMLAttributes: t }) {
23
+ return ["ul", L(this.options.HTMLAttributes, t), 0];
24
+ },
25
+ markdownTokenName: "list",
26
+ parseMarkdown: (t, e) => t.type !== "list" || t.ordered ? [] : {
27
+ type: "bulletList",
28
+ content: t.items ? e.parseChildren(t.items) : []
29
+ },
30
+ renderMarkdown: (t, e) => t.content ? e.renderChildren(t.content, `
31
+ `) : "",
32
+ markdownOptions: {
33
+ indentsContent: !0
34
+ },
35
+ addCommands() {
36
+ return {
37
+ toggleBulletList: () => ({ commands: t, chain: e }) => this.options.keepAttributes ? e().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(W, this.editor.getAttributes(w)).run() : t.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
38
+ };
39
+ },
40
+ addKeyboardShortcuts() {
41
+ return {
42
+ "Mod-Shift-8": () => this.editor.commands.toggleBulletList()
43
+ };
44
+ },
45
+ addInputRules() {
46
+ let t = b({
47
+ find: C,
48
+ type: this.type
49
+ });
50
+ return (this.options.keepMarks || this.options.keepAttributes) && (t = b({
51
+ find: C,
52
+ type: this.type,
53
+ keepMarks: this.options.keepMarks,
54
+ keepAttributes: this.options.keepAttributes,
55
+ getAttributes: () => this.editor.getAttributes(w),
56
+ editor: this.editor
57
+ })), [t];
58
+ }
59
+ });
60
+ function Y(t) {
61
+ var e, s;
62
+ const n = (e = t.tokens) == null ? void 0 : e[0];
63
+ return !!(t.text && ((s = t.tokens) == null ? void 0 : s.length) === 1 && n?.type === "list" && n.ordered && n.raw === t.text);
64
+ }
65
+ function J(t, e) {
66
+ return e.tokenizeInline ? e.parseInline(e.tokenizeInline(t)) : e.parseInline([
67
+ {
68
+ type: "text",
69
+ raw: t,
70
+ text: t
71
+ }
72
+ ]);
73
+ }
74
+ var Q = g.create({
75
+ name: "listItem",
76
+ addOptions() {
77
+ return {
78
+ HTMLAttributes: {},
79
+ bulletListTypeName: "bulletList",
80
+ orderedListTypeName: "orderedList"
81
+ };
82
+ },
83
+ content: "paragraph block*",
84
+ defining: !0,
85
+ parseHTML() {
86
+ return [
87
+ {
88
+ tag: "li"
89
+ }
90
+ ];
91
+ },
92
+ renderHTML({ HTMLAttributes: t }) {
93
+ return ["li", L(this.options.HTMLAttributes, t), 0];
94
+ },
95
+ markdownTokenName: "list_item",
96
+ parseMarkdown: (t, e) => {
97
+ var s;
98
+ if (t.type !== "list_item")
99
+ return [];
100
+ const n = (s = e.parseBlockChildren) != null ? s : e.parseChildren;
101
+ let r = [];
102
+ if (t.tokens && t.tokens.length > 0) {
103
+ if (Y(t))
104
+ return {
105
+ type: "listItem",
106
+ content: [
107
+ {
108
+ type: "paragraph",
109
+ content: J(t.text || "", e)
110
+ }
111
+ ]
112
+ };
113
+ if (t.tokens.some((u) => u.type === "paragraph"))
114
+ r = n(t.tokens);
115
+ else {
116
+ const u = t.tokens[0];
117
+ if (u && u.type === "text" && u.tokens && u.tokens.length > 0) {
118
+ if (r = [
119
+ {
120
+ type: "paragraph",
121
+ content: e.parseInline(u.tokens)
122
+ }
123
+ ], t.tokens.length > 1) {
124
+ const p = t.tokens.slice(1), h = n(p);
125
+ r.push(...h);
126
+ }
127
+ } else
128
+ r = n(t.tokens);
129
+ }
130
+ }
131
+ return r.length === 0 && (r = [
132
+ {
133
+ type: "paragraph",
134
+ content: []
135
+ }
136
+ ]), {
137
+ type: "listItem",
138
+ content: r
139
+ };
140
+ },
141
+ renderMarkdown: (t, e, s) => $(
142
+ t,
143
+ e,
144
+ (n) => {
145
+ var r, i;
146
+ return n.parentType === "bulletList" ? "- " : n.parentType === "orderedList" ? `${(((i = (r = n.meta) == null ? void 0 : r.parentAttrs) == null ? void 0 : i.start) || 1) + n.index}. ` : "- ";
147
+ },
148
+ s
149
+ ),
150
+ addKeyboardShortcuts() {
151
+ return {
152
+ Enter: () => this.editor.commands.splitListItem(this.name),
153
+ Tab: () => this.editor.commands.sinkListItem(this.name),
154
+ "Shift-Tab": () => this.editor.commands.liftListItem(this.name)
155
+ };
156
+ }
157
+ }), U = {};
158
+ G(U, {
159
+ findListItemPos: () => y,
160
+ getNextListDepth: () => A,
161
+ handleBackspace: () => T,
162
+ handleDelete: () => M,
163
+ hasListBefore: () => _,
164
+ hasListItemAfter: () => Z,
165
+ hasListItemBefore: () => B,
166
+ listItemHasSubList: () => P,
167
+ nextListIsDeeper: () => D,
168
+ nextListIsHigher: () => j
169
+ });
170
+ var y = (t, e) => {
171
+ const { $from: s } = e.selection, n = O(t, e.schema);
172
+ let r = null, i = s.depth, u = s.pos, a = null;
173
+ for (; i > 0 && a === null; )
174
+ r = s.node(i), r.type === n ? a = i : (i -= 1, u -= 1);
175
+ return a === null ? null : { $pos: e.doc.resolve(u), depth: a };
176
+ }, A = (t, e) => {
177
+ const s = y(t, e);
178
+ if (!s)
179
+ return !1;
180
+ const [, n] = V(e, t, s.$pos.pos + 4);
181
+ return n;
182
+ }, _ = (t, e, s) => {
183
+ const { $anchor: n } = t.selection, r = Math.max(0, n.pos - 2), i = t.doc.resolve(r).node();
184
+ return !(!i || !s.includes(i.type.name));
185
+ }, B = (t, e) => {
186
+ var s;
187
+ const { $anchor: n } = e.selection, r = e.doc.resolve(n.pos - 2);
188
+ return !(r.index() === 0 || ((s = r.nodeBefore) == null ? void 0 : s.type.name) !== t);
189
+ }, P = (t, e, s) => {
190
+ if (!s)
191
+ return !1;
192
+ const n = O(t, e.schema);
193
+ let r = !1;
194
+ return s.descendants((i) => {
195
+ i.type === n && (r = !0);
196
+ }), r;
197
+ }, T = (t, e, s) => {
198
+ if (t.commands.undoInputRule())
199
+ return !0;
200
+ if (t.state.selection.from !== t.state.selection.to)
201
+ return !1;
202
+ if (!I(t.state, e) && _(t.state, e, s)) {
203
+ const { $anchor: a } = t.state.selection, p = t.state.doc.resolve(a.before() - 1), h = [];
204
+ p.node().descendants((c, l) => {
205
+ c.type.name === e && h.push({ node: c, pos: l });
206
+ });
207
+ const m = h.at(-1);
208
+ if (!m)
209
+ return !1;
210
+ const o = t.state.doc.resolve(p.start() + m.pos + 1);
211
+ return t.chain().cut({ from: a.start() - 1, to: a.end() + 1 }, o.end()).joinForward().run();
212
+ }
213
+ if (!I(t.state, e) || !K(t.state))
214
+ return !1;
215
+ const n = y(e, t.state);
216
+ if (!n)
217
+ return !1;
218
+ const i = t.state.doc.resolve(n.$pos.pos - 2).node(n.depth), u = P(e, t.state, i);
219
+ return B(e, t.state) && !u ? t.commands.joinItemBackward() : t.chain().liftListItem(e).run();
220
+ }, D = (t, e) => {
221
+ const s = A(t, e), n = y(t, e);
222
+ return !n || !s ? !1 : s > n.depth;
223
+ }, j = (t, e) => {
224
+ const s = A(t, e), n = y(t, e);
225
+ return !n || !s ? !1 : s < n.depth;
226
+ }, M = (t, e) => {
227
+ if (!I(t.state, e) || !z(t.state, e))
228
+ return !1;
229
+ const { selection: s } = t.state, { $from: n, $to: r } = s;
230
+ return !s.empty && n.sameParent(r) ? !1 : D(e, t.state) ? t.chain().focus(t.state.selection.from + 4).lift(e).joinBackward().run() : j(e, t.state) ? t.chain().joinForward().joinBackward().run() : t.commands.joinItemForward();
231
+ }, Z = (t, e) => {
232
+ var s;
233
+ const { $anchor: n } = e.selection, r = e.doc.resolve(n.pos - n.parentOffset - 2);
234
+ return !(r.index() === r.parent.childCount - 1 || ((s = r.nodeAfter) == null ? void 0 : s.type.name) !== t);
235
+ }, tt = S.create({
236
+ name: "listKeymap",
237
+ addOptions() {
238
+ return {
239
+ listTypes: [
240
+ {
241
+ itemName: "listItem",
242
+ wrapperNames: ["bulletList", "orderedList"]
243
+ },
244
+ {
245
+ itemName: "taskItem",
246
+ wrapperNames: ["taskList"]
247
+ }
248
+ ]
249
+ };
250
+ },
251
+ addKeyboardShortcuts() {
252
+ return {
253
+ Delete: ({ editor: t }) => {
254
+ let e = !1;
255
+ return this.options.listTypes.forEach(({ itemName: s }) => {
256
+ t.state.schema.nodes[s] !== void 0 && M(t, s) && (e = !0);
257
+ }), e;
258
+ },
259
+ "Mod-Delete": ({ editor: t }) => {
260
+ let e = !1;
261
+ return this.options.listTypes.forEach(({ itemName: s }) => {
262
+ t.state.schema.nodes[s] !== void 0 && M(t, s) && (e = !0);
263
+ }), e;
264
+ },
265
+ Backspace: ({ editor: t }) => {
266
+ let e = !1;
267
+ return this.options.listTypes.forEach(({ itemName: s, wrapperNames: n }) => {
268
+ t.state.schema.nodes[s] !== void 0 && T(t, s, n) && (e = !0);
269
+ }), e;
270
+ },
271
+ "Mod-Backspace": ({ editor: t }) => {
272
+ let e = !1;
273
+ return this.options.listTypes.forEach(({ itemName: s, wrapperNames: n }) => {
274
+ t.state.schema.nodes[s] !== void 0 && T(t, s, n) && (e = !0);
275
+ }), e;
276
+ }
277
+ };
278
+ }
279
+ }), N = /^(\s*)(\d+)\.\s+(.*)$/, et = /^\s/;
280
+ function st(t) {
281
+ const e = t.trimStart();
282
+ return (
283
+ // oxlint-disable-next-line prefer-string-starts-ends-with
284
+ /^[-+*]\s+/.test(e) || // oxlint-disable-next-line prefer-string-starts-ends-with
285
+ /^\d+\.\s+/.test(e) || // oxlint-disable-next-line prefer-string-starts-ends-with
286
+ /^>\s?/.test(e) || // oxlint-disable-next-line prefer-string-starts-ends-with
287
+ /^```/.test(e) || // oxlint-disable-next-line prefer-string-starts-ends-with
288
+ /^~~~/.test(e)
289
+ );
290
+ }
291
+ function nt(t) {
292
+ const e = [], s = [];
293
+ let n = !1;
294
+ return t.forEach((r) => {
295
+ if (n) {
296
+ s.push(r);
297
+ return;
298
+ }
299
+ if (r.trim() === "") {
300
+ n = !0, s.push(r);
301
+ return;
302
+ }
303
+ if (e.length > 0 && st(r)) {
304
+ n = !0, s.push(r);
305
+ return;
306
+ }
307
+ e.push(r);
308
+ }), {
309
+ paragraphLines: e,
310
+ blockLines: s
311
+ };
312
+ }
313
+ function rt(t) {
314
+ const e = [];
315
+ let s = 0, n = 0;
316
+ for (; s < t.length; ) {
317
+ const r = t[s], i = r.match(N);
318
+ if (!i)
319
+ break;
320
+ const [, u, a, p] = i, h = u.length, m = [p];
321
+ let o = s + 1;
322
+ const c = [r];
323
+ let l = !1;
324
+ for (; o < t.length; ) {
325
+ const d = t[o];
326
+ if (d.match(N))
327
+ break;
328
+ if (d.trim() === "")
329
+ c.push(d), m.push(""), l = !0, o += 1;
330
+ else if (d.match(et))
331
+ c.push(d), m.push(d.slice(h + 2)), o += 1;
332
+ else {
333
+ if (l)
334
+ break;
335
+ c.push(d), m.push(d), o += 1;
336
+ }
337
+ }
338
+ e.push({
339
+ indent: h,
340
+ number: parseInt(a, 10),
341
+ content: m.join(`
342
+ `).trim(),
343
+ contentLines: m,
344
+ raw: c.join(`
345
+ `)
346
+ }), n = o, s = o;
347
+ }
348
+ return [e, n];
349
+ }
350
+ function R(t, e, s) {
351
+ const n = [];
352
+ let r = 0;
353
+ for (; r < t.length; ) {
354
+ const i = t[r];
355
+ if (i.indent === e) {
356
+ const { paragraphLines: u, blockLines: a } = nt(i.contentLines), p = u.join(`
357
+ `).trim(), h = [];
358
+ p && h.push({
359
+ type: "paragraph",
360
+ raw: p,
361
+ tokens: s.inlineTokens(p)
362
+ });
363
+ const m = a.join(`
364
+ `).trim();
365
+ if (m) {
366
+ const l = s.blockTokens(m);
367
+ h.push(...l);
368
+ }
369
+ let o = r + 1;
370
+ const c = [];
371
+ for (; o < t.length && t[o].indent > e; )
372
+ c.push(t[o]), o += 1;
373
+ if (c.length > 0) {
374
+ const l = Math.min(...c.map((f) => f.indent)), d = R(c, l, s);
375
+ h.push({
376
+ type: "list",
377
+ ordered: !0,
378
+ start: c[0].number,
379
+ items: d,
380
+ raw: c.map((f) => f.raw).join(`
381
+ `)
382
+ });
383
+ }
384
+ n.push({
385
+ type: "list_item",
386
+ raw: i.raw,
387
+ tokens: h
388
+ }), r = o;
389
+ } else
390
+ r += 1;
391
+ }
392
+ return n;
393
+ }
394
+ function it(t, e) {
395
+ return t.map((s) => {
396
+ if (s.type !== "list_item")
397
+ return e.parseChildren([s])[0];
398
+ const n = [];
399
+ return s.tokens && s.tokens.length > 0 && s.tokens.forEach((r) => {
400
+ if (r.type === "paragraph" || r.type === "list" || r.type === "blockquote" || r.type === "code")
401
+ n.push(...e.parseChildren([r]));
402
+ else if (r.type === "text" && r.tokens) {
403
+ const i = e.parseChildren([r]);
404
+ n.push({
405
+ type: "paragraph",
406
+ content: i
407
+ });
408
+ } else {
409
+ const i = e.parseChildren([r]);
410
+ i.length > 0 && n.push(...i);
411
+ }
412
+ }), {
413
+ type: "listItem",
414
+ content: n
415
+ };
416
+ });
417
+ }
418
+ var at = "listItem", E = "textStyle", H = /^(\d+)\.\s$/, ot = g.create({
419
+ name: "orderedList",
420
+ addOptions() {
421
+ return {
422
+ itemTypeName: "listItem",
423
+ HTMLAttributes: {},
424
+ keepMarks: !1,
425
+ keepAttributes: !1
426
+ };
427
+ },
428
+ group: "block list",
429
+ content() {
430
+ return `${this.options.itemTypeName}+`;
431
+ },
432
+ addAttributes() {
433
+ return {
434
+ start: {
435
+ default: 1,
436
+ parseHTML: (t) => t.hasAttribute("start") ? parseInt(t.getAttribute("start") || "", 10) : 1
437
+ },
438
+ type: {
439
+ default: null,
440
+ parseHTML: (t) => t.getAttribute("type")
441
+ }
442
+ };
443
+ },
444
+ parseHTML() {
445
+ return [
446
+ {
447
+ tag: "ol"
448
+ }
449
+ ];
450
+ },
451
+ renderHTML({ HTMLAttributes: t }) {
452
+ const { start: e, ...s } = t;
453
+ return e === 1 ? ["ol", L(this.options.HTMLAttributes, s), 0] : ["ol", L(this.options.HTMLAttributes, t), 0];
454
+ },
455
+ markdownTokenName: "list",
456
+ parseMarkdown: (t, e) => {
457
+ if (t.type !== "list" || !t.ordered)
458
+ return [];
459
+ const s = t.start || 1, n = t.items ? it(t.items, e) : [];
460
+ return s !== 1 ? {
461
+ type: "orderedList",
462
+ attrs: { start: s },
463
+ content: n
464
+ } : {
465
+ type: "orderedList",
466
+ content: n
467
+ };
468
+ },
469
+ renderMarkdown: (t, e) => t.content ? e.renderChildren(t.content, `
470
+ `) : "",
471
+ markdownTokenizer: {
472
+ name: "orderedList",
473
+ level: "block",
474
+ start: (t) => {
475
+ const e = t.match(/^(\s*)(\d+)\.\s+/), s = e?.index;
476
+ return s !== void 0 ? s : -1;
477
+ },
478
+ tokenize: (t, e, s) => {
479
+ var n;
480
+ const r = t.split(`
481
+ `), [i, u] = rt(r);
482
+ if (i.length === 0)
483
+ return;
484
+ const a = R(i, 0, s);
485
+ return a.length === 0 ? void 0 : {
486
+ type: "list",
487
+ ordered: !0,
488
+ start: ((n = i[0]) == null ? void 0 : n.number) || 1,
489
+ items: a,
490
+ raw: r.slice(0, u).join(`
491
+ `)
492
+ };
493
+ }
494
+ },
495
+ markdownOptions: {
496
+ indentsContent: !0
497
+ },
498
+ addCommands() {
499
+ return {
500
+ toggleOrderedList: () => ({ commands: t, chain: e }) => this.options.keepAttributes ? e().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(at, this.editor.getAttributes(E)).run() : t.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
501
+ };
502
+ },
503
+ addKeyboardShortcuts() {
504
+ return {
505
+ "Mod-Shift-7": () => this.editor.commands.toggleOrderedList()
506
+ };
507
+ },
508
+ addInputRules() {
509
+ let t = b({
510
+ find: H,
511
+ type: this.type,
512
+ getAttributes: (e) => ({ start: +e[1] }),
513
+ joinPredicate: (e, s) => s.childCount + s.attrs.start === +e[1]
514
+ });
515
+ return (this.options.keepMarks || this.options.keepAttributes) && (t = b({
516
+ find: H,
517
+ type: this.type,
518
+ keepMarks: this.options.keepMarks,
519
+ keepAttributes: this.options.keepAttributes,
520
+ getAttributes: (e) => ({ start: +e[1], ...this.editor.getAttributes(E) }),
521
+ joinPredicate: (e, s) => s.childCount + s.attrs.start === +e[1],
522
+ editor: this.editor
523
+ })), [t];
524
+ }
525
+ }), ut = /^\s*(\[([( |x])?\])\s$/, ct = g.create({
526
+ name: "taskItem",
527
+ addOptions() {
528
+ return {
529
+ nested: !1,
530
+ HTMLAttributes: {},
531
+ taskListTypeName: "taskList",
532
+ a11y: void 0
533
+ };
534
+ },
535
+ content() {
536
+ return this.options.nested ? "paragraph block*" : "paragraph+";
537
+ },
538
+ defining: !0,
539
+ addAttributes() {
540
+ return {
541
+ checked: {
542
+ default: !1,
543
+ keepOnSplit: !1,
544
+ parseHTML: (t) => {
545
+ const e = t.getAttribute("data-checked");
546
+ return e === "" || e === "true";
547
+ },
548
+ renderHTML: (t) => ({
549
+ "data-checked": t.checked
550
+ })
551
+ }
552
+ };
553
+ },
554
+ parseHTML() {
555
+ return [
556
+ {
557
+ tag: `li[data-type="${this.name}"]`,
558
+ priority: 51
559
+ }
560
+ ];
561
+ },
562
+ renderHTML({ node: t, HTMLAttributes: e }) {
563
+ return [
564
+ "li",
565
+ L(this.options.HTMLAttributes, e, {
566
+ "data-type": this.name
567
+ }),
568
+ [
569
+ "label",
570
+ [
571
+ "input",
572
+ {
573
+ type: "checkbox",
574
+ checked: t.attrs.checked ? "checked" : null
575
+ }
576
+ ],
577
+ ["span"]
578
+ ],
579
+ ["div", 0]
580
+ ];
581
+ },
582
+ parseMarkdown: (t, e) => {
583
+ const s = [];
584
+ if (t.tokens && t.tokens.length > 0 ? s.push(e.createNode("paragraph", {}, e.parseInline(t.tokens))) : t.text ? s.push(e.createNode("paragraph", {}, [e.createNode("text", { text: t.text })])) : s.push(e.createNode("paragraph", {}, [])), t.nestedTokens && t.nestedTokens.length > 0) {
585
+ const n = e.parseChildren(t.nestedTokens);
586
+ s.push(...n);
587
+ }
588
+ return e.createNode("taskItem", { checked: t.checked || !1 }, s);
589
+ },
590
+ renderMarkdown: (t, e) => {
591
+ var s;
592
+ const r = `- [${(s = t.attrs) != null && s.checked ? "x" : " "}] `;
593
+ return $(t, e, r);
594
+ },
595
+ addKeyboardShortcuts() {
596
+ const t = {
597
+ Enter: () => this.editor.commands.splitListItem(this.name),
598
+ "Shift-Tab": () => this.editor.commands.liftListItem(this.name)
599
+ };
600
+ return this.options.nested ? {
601
+ ...t,
602
+ Tab: () => this.editor.commands.sinkListItem(this.name)
603
+ } : t;
604
+ },
605
+ addNodeView() {
606
+ return ({ node: t, HTMLAttributes: e, getPos: s, editor: n }) => {
607
+ const r = document.createElement("li"), i = document.createElement("label"), u = document.createElement("span"), a = document.createElement("input"), p = document.createElement("div"), h = (o) => {
608
+ var c, l;
609
+ a.ariaLabel = ((l = (c = this.options.a11y) == null ? void 0 : c.checkboxLabel) == null ? void 0 : l.call(c, o, a.checked)) || `Task item checkbox for ${o.textContent || "empty task item"}`;
610
+ };
611
+ h(t), i.contentEditable = "false", a.type = "checkbox", a.addEventListener("mousedown", (o) => o.preventDefault()), a.addEventListener("change", (o) => {
612
+ if (!n.isEditable && !this.options.onReadOnlyChecked) {
613
+ a.checked = !a.checked;
614
+ return;
615
+ }
616
+ const { checked: c } = o.target;
617
+ n.isEditable && typeof s == "function" && n.chain().focus(void 0, { scrollIntoView: !1 }).command(({ tr: l }) => {
618
+ const d = s();
619
+ if (typeof d != "number")
620
+ return !1;
621
+ const f = l.doc.nodeAt(d);
622
+ return l.setNodeMarkup(d, void 0, {
623
+ ...f?.attrs,
624
+ checked: c
625
+ }), !0;
626
+ }).run(), !n.isEditable && this.options.onReadOnlyChecked && (this.options.onReadOnlyChecked(t, c) || (a.checked = !a.checked));
627
+ }), Object.entries(this.options.HTMLAttributes).forEach(([o, c]) => {
628
+ r.setAttribute(o, c);
629
+ }), r.dataset.checked = t.attrs.checked, a.checked = t.attrs.checked, i.append(a, u), r.append(i, p), Object.entries(e).forEach(([o, c]) => {
630
+ r.setAttribute(o, c);
631
+ });
632
+ let m = new Set(Object.keys(e));
633
+ return {
634
+ dom: r,
635
+ contentDOM: p,
636
+ update: (o) => {
637
+ if (o.type !== this.type)
638
+ return !1;
639
+ r.dataset.checked = o.attrs.checked, a.checked = o.attrs.checked, h(o);
640
+ const c = n.extensionManager.attributes, l = X(o, c), d = new Set(Object.keys(l)), f = this.options.HTMLAttributes;
641
+ return m.forEach((k) => {
642
+ d.has(k) || (k in f ? r.setAttribute(k, f[k]) : r.removeAttribute(k));
643
+ }), Object.entries(l).forEach(([k, v]) => {
644
+ v == null ? k in f ? r.setAttribute(k, f[k]) : r.removeAttribute(k) : r.setAttribute(k, v);
645
+ }), m = d, !0;
646
+ }
647
+ };
648
+ };
649
+ },
650
+ addInputRules() {
651
+ return [
652
+ b({
653
+ find: ut,
654
+ type: this.type,
655
+ getAttributes: (t) => ({
656
+ checked: t[t.length - 1] === "x"
657
+ })
658
+ })
659
+ ];
660
+ }
661
+ }), lt = g.create({
662
+ name: "taskList",
663
+ addOptions() {
664
+ return {
665
+ itemTypeName: "taskItem",
666
+ HTMLAttributes: {}
667
+ };
668
+ },
669
+ group: "block list",
670
+ content() {
671
+ return `${this.options.itemTypeName}+`;
672
+ },
673
+ parseHTML() {
674
+ return [
675
+ {
676
+ tag: `ul[data-type="${this.name}"]`,
677
+ priority: 51
678
+ }
679
+ ];
680
+ },
681
+ renderHTML({ HTMLAttributes: t }) {
682
+ return [
683
+ "ul",
684
+ L(this.options.HTMLAttributes, t, { "data-type": this.name }),
685
+ 0
686
+ ];
687
+ },
688
+ parseMarkdown: (t, e) => e.createNode("taskList", {}, e.parseChildren(t.items || [])),
689
+ renderMarkdown: (t, e) => t.content ? e.renderChildren(t.content, `
690
+ `) : "",
691
+ markdownTokenizer: {
692
+ name: "taskList",
693
+ level: "block",
694
+ start(t) {
695
+ var e;
696
+ const s = (e = t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)) == null ? void 0 : e.index;
697
+ return s !== void 0 ? s : -1;
698
+ },
699
+ tokenize(t, e, s) {
700
+ const n = (i) => {
701
+ const u = x(
702
+ i,
703
+ {
704
+ itemPattern: /^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,
705
+ extractItemData: (a) => ({
706
+ indentLevel: a[1].length,
707
+ mainContent: a[4],
708
+ checked: a[3].toLowerCase() === "x"
709
+ }),
710
+ createToken: (a, p) => ({
711
+ type: "taskItem",
712
+ raw: "",
713
+ mainContent: a.mainContent,
714
+ indentLevel: a.indentLevel,
715
+ checked: a.checked,
716
+ text: a.mainContent,
717
+ tokens: s.inlineTokens(a.mainContent),
718
+ nestedTokens: p
719
+ }),
720
+ // Allow recursive nesting
721
+ customNestedParser: n
722
+ },
723
+ s
724
+ );
725
+ return u ? [
726
+ {
727
+ type: "taskList",
728
+ raw: u.raw,
729
+ items: u.items
730
+ }
731
+ ] : s.blockTokens(i);
732
+ }, r = x(
733
+ t,
734
+ {
735
+ itemPattern: /^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,
736
+ extractItemData: (i) => ({
737
+ indentLevel: i[1].length,
738
+ mainContent: i[4],
739
+ checked: i[3].toLowerCase() === "x"
740
+ }),
741
+ createToken: (i, u) => ({
742
+ type: "taskItem",
743
+ raw: "",
744
+ mainContent: i.mainContent,
745
+ indentLevel: i.indentLevel,
746
+ checked: i.checked,
747
+ text: i.mainContent,
748
+ tokens: s.inlineTokens(i.mainContent),
749
+ nestedTokens: u
750
+ }),
751
+ // Use the recursive parser for nested content
752
+ customNestedParser: n
753
+ },
754
+ s
755
+ );
756
+ if (r)
757
+ return {
758
+ type: "taskList",
759
+ raw: r.raw,
760
+ items: r.items
761
+ };
762
+ }
763
+ },
764
+ markdownOptions: {
765
+ indentsContent: !0
766
+ },
767
+ addCommands() {
768
+ return {
769
+ toggleTaskList: () => ({ commands: t }) => t.toggleList(this.name, this.options.itemTypeName)
770
+ };
771
+ },
772
+ addKeyboardShortcuts() {
773
+ return {
774
+ "Mod-Shift-9": () => this.editor.commands.toggleTaskList()
775
+ };
776
+ }
777
+ });
778
+ S.create({
779
+ name: "listKit",
780
+ addExtensions() {
781
+ const t = [];
782
+ return this.options.bulletList !== !1 && t.push(q.configure(this.options.bulletList)), this.options.listItem !== !1 && t.push(Q.configure(this.options.listItem)), this.options.listKeymap !== !1 && t.push(tt.configure(this.options.listKeymap)), this.options.orderedList !== !1 && t.push(ot.configure(this.options.orderedList)), this.options.taskItem !== !1 && t.push(ct.configure(this.options.taskItem)), this.options.taskList !== !1 && t.push(lt.configure(this.options.taskList)), t;
783
+ }
784
+ });
785
+ export {
786
+ q as BulletList,
787
+ Q as ListItem,
788
+ tt as ListKeymap,
789
+ ot as OrderedList,
790
+ ct as TaskItem,
791
+ lt as TaskList,
792
+ C as bulletListInputRegex,
793
+ ut as inputRegex,
794
+ U as listHelpers,
795
+ H as orderedListInputRegex
796
+ };