@dooherceg/tiptap-controlled-editor-with-table 0.0.9 → 0.0.11

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 (125) hide show
  1. package/dist/Combination-CO0ZtURs.js +1333 -0
  2. package/dist/assets/{components/tiptap-ui-primitive/badge/badge-colors.css → badge.css} +1 -1
  3. package/dist/assets/{components/tiptap-ui-primitive/button/button-colors.css → button.css} +1 -1
  4. package/dist/assets/simple-editor.css +1 -0
  5. package/dist/components/tiptap-node/horizontal-rule-node/horizontal-rule-node-extension.js +58 -6
  6. package/dist/components/tiptap-node/image-upload-node/image-upload-node.js +4 -5
  7. package/dist/components/tiptap-templates/simple/simple-editor.d.ts +3 -1
  8. package/dist/components/tiptap-templates/simple/simple-editor.js +1970 -201
  9. package/dist/components/tiptap-templates/simple/theme-toggle.js +7 -7
  10. package/dist/components/tiptap-ui/blockquote-button/blockquote-button.js +10 -10
  11. package/dist/components/tiptap-ui/color-highlight-button/color-highlight-button.js +5 -6
  12. package/dist/components/tiptap-ui/color-highlight-button/use-color-highlight.js +1 -1
  13. package/dist/components/tiptap-ui/color-highlight-popover/color-highlight-popover.js +16 -16
  14. package/dist/components/tiptap-ui/heading-button/heading-button.js +9 -9
  15. package/dist/components/tiptap-ui/heading-dropdown-menu/heading-dropdown-menu.js +37 -29
  16. package/dist/components/tiptap-ui/heading-dropdown-menu/use-heading-dropdown-menu.js +14 -13
  17. package/dist/components/tiptap-ui/image-upload-button/use-image-upload.js +16 -16
  18. package/dist/components/tiptap-ui/insert-table-button/insert-table-button.js +9 -9
  19. package/dist/components/tiptap-ui/link-popover/link-popover.js +13 -13
  20. package/dist/components/tiptap-ui/list-button/list-button.js +7 -7
  21. package/dist/components/tiptap-ui/list-dropdown-menu/list-dropdown-menu.js +24 -20
  22. package/dist/components/tiptap-ui/list-dropdown-menu/use-list-dropdown-menu.js +6 -5
  23. package/dist/components/tiptap-ui/table-actions-toolbar/table-actions-toolbar.js +28 -28
  24. package/dist/components/tiptap-ui-primitive/badge/badge.js +16 -19
  25. package/dist/components/tiptap-ui-primitive/button/button.js +19 -22
  26. package/dist/components/tiptap-ui-primitive/card/card.js +12 -13
  27. package/dist/components/tiptap-ui-primitive/dropdown-menu/dropdown-menu.js +1012 -39
  28. package/dist/components/tiptap-ui-primitive/input/input.js +6 -7
  29. package/dist/components/tiptap-ui-primitive/popover/popover.js +233 -24
  30. package/dist/components/tiptap-ui-primitive/separator/separator.js +8 -9
  31. package/dist/components/tiptap-ui-primitive/toolbar/toolbar.js +7 -8
  32. package/dist/components/tiptap-ui-primitive/tooltip/tooltip.js +1330 -84
  33. package/dist/floating-ui.react-dom-DgOuULHo.js +1334 -0
  34. package/dist/hooks/use-throttled-callback.js +108 -13
  35. package/dist/{node_modules/react-hotkeys-hook/packages/react-hotkeys-hook/dist/index.js → index-Bqw9S4qP.js} +55 -57
  36. package/package.json +1 -1
  37. package/dist/_virtual/_commonjsHelpers.js +0 -8
  38. package/dist/_virtual/index.js +0 -7
  39. package/dist/assets/components/tiptap-node/blockquote-node/blockquote-node.css +0 -1
  40. package/dist/assets/components/tiptap-node/code-block-node/code-block-node.css +0 -1
  41. package/dist/assets/components/tiptap-node/heading-node/heading-node.css +0 -1
  42. package/dist/assets/components/tiptap-node/horizontal-rule-node/horizontal-rule-node.css +0 -1
  43. package/dist/assets/components/tiptap-node/image-node/image-node.css +0 -1
  44. package/dist/assets/components/tiptap-node/list-node/list-node.css +0 -1
  45. package/dist/assets/components/tiptap-node/paragraph-node/paragraph-node.css +0 -1
  46. package/dist/assets/components/tiptap-templates/simple/simple-editor.css +0 -1
  47. package/dist/assets/components/tiptap-ui-primitive/badge/badge-group.css +0 -1
  48. package/dist/assets/components/tiptap-ui-primitive/badge/badge.css +0 -1
  49. package/dist/assets/components/tiptap-ui-primitive/button/button-group.css +0 -1
  50. package/dist/assets/components/tiptap-ui-primitive/button/button.css +0 -1
  51. package/dist/assets/styles/_keyframe-animations.css +0 -1
  52. package/dist/assets/styles/_variables.css +0 -1
  53. package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +0 -527
  54. package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +0 -402
  55. package/dist/node_modules/@floating-ui/react/dist/floating-ui.react.js +0 -932
  56. package/dist/node_modules/@floating-ui/react/dist/floating-ui.react.utils.js +0 -185
  57. package/dist/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js +0 -208
  58. package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +0 -136
  59. package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +0 -130
  60. package/dist/node_modules/@radix-ui/primitive/dist/index.js +0 -9
  61. package/dist/node_modules/@radix-ui/react-arrow/dist/index.js +0 -24
  62. package/dist/node_modules/@radix-ui/react-collection/dist/index.js +0 -48
  63. package/dist/node_modules/@radix-ui/react-compose-refs/dist/index.js +0 -29
  64. package/dist/node_modules/@radix-ui/react-context/dist/index.js +0 -53
  65. package/dist/node_modules/@radix-ui/react-direction/dist/index.js +0 -10
  66. package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +0 -127
  67. package/dist/node_modules/@radix-ui/react-dropdown-menu/dist/index.js +0 -221
  68. package/dist/node_modules/@radix-ui/react-focus-guards/dist/index.js +0 -17
  69. package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.js +0 -136
  70. package/dist/node_modules/@radix-ui/react-id/dist/index.js +0 -13
  71. package/dist/node_modules/@radix-ui/react-menu/dist/index.js +0 -636
  72. package/dist/node_modules/@radix-ui/react-popover/dist/index.js +0 -239
  73. package/dist/node_modules/@radix-ui/react-popper/dist/index.js +0 -219
  74. package/dist/node_modules/@radix-ui/react-portal/dist/index.js +0 -15
  75. package/dist/node_modules/@radix-ui/react-presence/dist/index.js +0 -70
  76. package/dist/node_modules/@radix-ui/react-primitive/dist/index.js +0 -36
  77. package/dist/node_modules/@radix-ui/react-roving-focus/dist/index.js +0 -183
  78. package/dist/node_modules/@radix-ui/react-slot/dist/index.js +0 -49
  79. package/dist/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +0 -10
  80. package/dist/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +0 -52
  81. package/dist/node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +0 -14
  82. package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +0 -6
  83. package/dist/node_modules/@radix-ui/react-use-size/dist/index.js +0 -27
  84. package/dist/node_modules/@tiptap/extension-highlight/dist/index.js +0 -84
  85. package/dist/node_modules/@tiptap/extension-horizontal-rule/dist/index.js +0 -57
  86. package/dist/node_modules/@tiptap/extension-image/dist/index.js +0 -128
  87. package/dist/node_modules/@tiptap/extension-list/dist/index.js +0 -713
  88. package/dist/node_modules/@tiptap/extension-subscript/dist/index.js +0 -40
  89. package/dist/node_modules/@tiptap/extension-superscript/dist/index.js +0 -40
  90. package/dist/node_modules/@tiptap/extension-table/dist/index.js +0 -380
  91. package/dist/node_modules/@tiptap/extension-text-align/dist/index.js +0 -46
  92. package/dist/node_modules/@tiptap/extension-typography/dist/index.js +0 -125
  93. package/dist/node_modules/@tiptap/extensions/dist/index.js +0 -288
  94. package/dist/node_modules/aria-hidden/dist/es2015/index.js +0 -52
  95. package/dist/node_modules/get-nonce/dist/es2015/index.js +0 -7
  96. package/dist/node_modules/lodash.throttle/index.js +0 -95
  97. package/dist/node_modules/react-remove-scroll/dist/es2015/Combination.js +0 -11
  98. package/dist/node_modules/react-remove-scroll/dist/es2015/SideEffect.js +0 -112
  99. package/dist/node_modules/react-remove-scroll/dist/es2015/UI.js +0 -31
  100. package/dist/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +0 -16
  101. package/dist/node_modules/react-remove-scroll/dist/es2015/handleScroll.js +0 -68
  102. package/dist/node_modules/react-remove-scroll/dist/es2015/medium.js +0 -5
  103. package/dist/node_modules/react-remove-scroll/dist/es2015/sidecar.js +0 -7
  104. package/dist/node_modules/react-remove-scroll-bar/dist/es2015/component.js +0 -71
  105. package/dist/node_modules/react-remove-scroll-bar/dist/es2015/constants.js +0 -7
  106. package/dist/node_modules/react-remove-scroll-bar/dist/es2015/utils.js +0 -25
  107. package/dist/node_modules/react-style-singleton/dist/es2015/component.js +0 -11
  108. package/dist/node_modules/react-style-singleton/dist/es2015/hook.js +0 -15
  109. package/dist/node_modules/react-style-singleton/dist/es2015/singleton.js +0 -30
  110. package/dist/node_modules/tabbable/dist/index.esm.js +0 -197
  111. package/dist/node_modules/tslib/tslib.es6.js +0 -27
  112. package/dist/node_modules/use-callback-ref/dist/es2015/assignRef.js +0 -6
  113. package/dist/node_modules/use-callback-ref/dist/es2015/useMergeRef.js +0 -26
  114. package/dist/node_modules/use-callback-ref/dist/es2015/useRef.js +0 -25
  115. package/dist/node_modules/use-sidecar/dist/es2015/exports.js +0 -18
  116. package/dist/node_modules/use-sidecar/dist/es2015/medium.js +0 -67
  117. /package/dist/assets/{components/tiptap-ui-primitive/card/card.css → card.css} +0 -0
  118. /package/dist/assets/{components/tiptap-ui/color-highlight-button/color-highlight-button.css → color-highlight-button.css} +0 -0
  119. /package/dist/assets/{components/tiptap-ui-primitive/dropdown-menu/dropdown-menu.css → dropdown-menu.css} +0 -0
  120. /package/dist/assets/{components/tiptap-node/image-upload-node/image-upload-node.css → image-upload-node.css} +0 -0
  121. /package/dist/assets/{components/tiptap-ui-primitive/input/input.css → input.css} +0 -0
  122. /package/dist/assets/{components/tiptap-ui-primitive/popover/popover.css → popover.css} +0 -0
  123. /package/dist/assets/{components/tiptap-ui-primitive/separator/separator.css → separator.css} +0 -0
  124. /package/dist/assets/{components/tiptap-ui-primitive/toolbar/toolbar.css → toolbar.css} +0 -0
  125. /package/dist/assets/{components/tiptap-ui-primitive/tooltip/tooltip.css → tooltip.css} +0 -0
@@ -1,713 +0,0 @@
1
- import { Node as L, wrappingInputRule as k, mergeAttributes as m, renderNestedMarkdownContent as E, Extension as H, parseIndentedBlocks as M, isNodeActive as g, isAtStartOfNode as B, isAtEndOfNode as j, getNodeType as $, getNodeAtPosition as K } from "@tiptap/core";
2
- var V = Object.defineProperty, X = (t, e) => {
3
- for (var s in e)
4
- V(t, s, { get: e[s], enumerable: !0 });
5
- }, z = "listItem", x = "textStyle", w = /^\s*([-+*])\s$/, F = L.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", m(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(z, this.editor.getAttributes(x)).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 = k({
47
- find: w,
48
- type: this.type
49
- });
50
- return (this.options.keepMarks || this.options.keepAttributes) && (t = k({
51
- find: w,
52
- type: this.type,
53
- keepMarks: this.options.keepMarks,
54
- keepAttributes: this.options.keepAttributes,
55
- getAttributes: () => this.editor.getAttributes(x),
56
- editor: this.editor
57
- })), [t];
58
- }
59
- }), G = L.create({
60
- name: "listItem",
61
- addOptions() {
62
- return {
63
- HTMLAttributes: {},
64
- bulletListTypeName: "bulletList",
65
- orderedListTypeName: "orderedList"
66
- };
67
- },
68
- content: "paragraph block*",
69
- defining: !0,
70
- parseHTML() {
71
- return [
72
- {
73
- tag: "li"
74
- }
75
- ];
76
- },
77
- renderHTML({ HTMLAttributes: t }) {
78
- return ["li", m(this.options.HTMLAttributes, t), 0];
79
- },
80
- markdownTokenName: "list_item",
81
- parseMarkdown: (t, e) => {
82
- if (t.type !== "list_item")
83
- return [];
84
- let s = [];
85
- if (t.tokens && t.tokens.length > 0)
86
- if (t.tokens.some((r) => r.type === "paragraph"))
87
- s = e.parseChildren(t.tokens);
88
- else {
89
- const r = t.tokens[0];
90
- if (r && r.type === "text" && r.tokens && r.tokens.length > 0) {
91
- if (s = [
92
- {
93
- type: "paragraph",
94
- content: e.parseInline(r.tokens)
95
- }
96
- ], t.tokens.length > 1) {
97
- const l = t.tokens.slice(1), a = e.parseChildren(l);
98
- s.push(...a);
99
- }
100
- } else
101
- s = e.parseChildren(t.tokens);
102
- }
103
- return s.length === 0 && (s = [
104
- {
105
- type: "paragraph",
106
- content: []
107
- }
108
- ]), {
109
- type: "listItem",
110
- content: s
111
- };
112
- },
113
- renderMarkdown: (t, e, s) => E(
114
- t,
115
- e,
116
- (n) => n.parentType === "bulletList" ? "- " : n.parentType === "orderedList" ? `${n.index + 1}. ` : "- ",
117
- s
118
- ),
119
- addKeyboardShortcuts() {
120
- return {
121
- Enter: () => this.editor.commands.splitListItem(this.name),
122
- Tab: () => this.editor.commands.sinkListItem(this.name),
123
- "Shift-Tab": () => this.editor.commands.liftListItem(this.name)
124
- };
125
- }
126
- }), W = {};
127
- X(W, {
128
- findListItemPos: () => b,
129
- getNextListDepth: () => T,
130
- handleBackspace: () => v,
131
- handleDelete: () => I,
132
- hasListBefore: () => S,
133
- hasListItemAfter: () => q,
134
- hasListItemBefore: () => P,
135
- listItemHasSubList: () => _,
136
- nextListIsDeeper: () => O,
137
- nextListIsHigher: () => D
138
- });
139
- var b = (t, e) => {
140
- const { $from: s } = e.selection, n = $(t, e.schema);
141
- let r = null, i = s.depth, l = s.pos, a = null;
142
- for (; i > 0 && a === null; )
143
- r = s.node(i), r.type === n ? a = i : (i -= 1, l -= 1);
144
- return a === null ? null : { $pos: e.doc.resolve(l), depth: a };
145
- }, T = (t, e) => {
146
- const s = b(t, e);
147
- if (!s)
148
- return !1;
149
- const [, n] = K(e, t, s.$pos.pos + 4);
150
- return n;
151
- }, S = (t, e, s) => {
152
- const { $anchor: n } = t.selection, r = Math.max(0, n.pos - 2), i = t.doc.resolve(r).node();
153
- return !(!i || !s.includes(i.type.name));
154
- }, P = (t, e) => {
155
- var s;
156
- const { $anchor: n } = e.selection, r = e.doc.resolve(n.pos - 2);
157
- return !(r.index() === 0 || ((s = r.nodeBefore) == null ? void 0 : s.type.name) !== t);
158
- }, _ = (t, e, s) => {
159
- if (!s)
160
- return !1;
161
- const n = $(t, e.schema);
162
- let r = !1;
163
- return s.descendants((i) => {
164
- i.type === n && (r = !0);
165
- }), r;
166
- }, v = (t, e, s) => {
167
- if (t.commands.undoInputRule())
168
- return !0;
169
- if (t.state.selection.from !== t.state.selection.to)
170
- return !1;
171
- if (!g(t.state, e) && S(t.state, e, s)) {
172
- const { $anchor: a } = t.state.selection, p = t.state.doc.resolve(a.before() - 1), h = [];
173
- p.node().descendants((c, u) => {
174
- c.type.name === e && h.push({ node: c, pos: u });
175
- });
176
- const o = h.at(-1);
177
- if (!o)
178
- return !1;
179
- const d = t.state.doc.resolve(p.start() + o.pos + 1);
180
- return t.chain().cut({ from: a.start() - 1, to: a.end() + 1 }, d.end()).joinForward().run();
181
- }
182
- if (!g(t.state, e) || !B(t.state))
183
- return !1;
184
- const n = b(e, t.state);
185
- if (!n)
186
- return !1;
187
- const i = t.state.doc.resolve(n.$pos.pos - 2).node(n.depth), l = _(e, t.state, i);
188
- return P(e, t.state) && !l ? t.commands.joinItemBackward() : t.chain().liftListItem(e).run();
189
- }, O = (t, e) => {
190
- const s = T(t, e), n = b(t, e);
191
- return !n || !s ? !1 : s > n.depth;
192
- }, D = (t, e) => {
193
- const s = T(t, e), n = b(t, e);
194
- return !n || !s ? !1 : s < n.depth;
195
- }, I = (t, e) => {
196
- if (!g(t.state, e) || !j(t.state, e))
197
- return !1;
198
- const { selection: s } = t.state, { $from: n, $to: r } = s;
199
- return !s.empty && n.sameParent(r) ? !1 : O(e, t.state) ? t.chain().focus(t.state.selection.from + 4).lift(e).joinBackward().run() : D(e, t.state) ? t.chain().joinForward().joinBackward().run() : t.commands.joinItemForward();
200
- }, q = (t, e) => {
201
- var s;
202
- const { $anchor: n } = e.selection, r = e.doc.resolve(n.pos - n.parentOffset - 2);
203
- return !(r.index() === r.parent.childCount - 1 || ((s = r.nodeAfter) == null ? void 0 : s.type.name) !== t);
204
- }, Y = H.create({
205
- name: "listKeymap",
206
- addOptions() {
207
- return {
208
- listTypes: [
209
- {
210
- itemName: "listItem",
211
- wrapperNames: ["bulletList", "orderedList"]
212
- },
213
- {
214
- itemName: "taskItem",
215
- wrapperNames: ["taskList"]
216
- }
217
- ]
218
- };
219
- },
220
- addKeyboardShortcuts() {
221
- return {
222
- Delete: ({ editor: t }) => {
223
- let e = !1;
224
- return this.options.listTypes.forEach(({ itemName: s }) => {
225
- t.state.schema.nodes[s] !== void 0 && I(t, s) && (e = !0);
226
- }), e;
227
- },
228
- "Mod-Delete": ({ editor: t }) => {
229
- let e = !1;
230
- return this.options.listTypes.forEach(({ itemName: s }) => {
231
- t.state.schema.nodes[s] !== void 0 && I(t, s) && (e = !0);
232
- }), e;
233
- },
234
- Backspace: ({ editor: t }) => {
235
- let e = !1;
236
- return this.options.listTypes.forEach(({ itemName: s, wrapperNames: n }) => {
237
- t.state.schema.nodes[s] !== void 0 && v(t, s, n) && (e = !0);
238
- }), e;
239
- },
240
- "Mod-Backspace": ({ editor: t }) => {
241
- let e = !1;
242
- return this.options.listTypes.forEach(({ itemName: s, wrapperNames: n }) => {
243
- t.state.schema.nodes[s] !== void 0 && v(t, s, n) && (e = !0);
244
- }), e;
245
- }
246
- };
247
- }
248
- }), A = /^(\s*)(\d+)\.\s+(.*)$/, J = /^\s/;
249
- function Q(t) {
250
- const e = [];
251
- let s = 0, n = 0;
252
- for (; s < t.length; ) {
253
- const r = t[s], i = r.match(A);
254
- if (!i)
255
- break;
256
- const [, l, a, p] = i, h = l.length;
257
- let o = p, d = s + 1;
258
- const c = [r];
259
- for (; d < t.length; ) {
260
- const u = t[d];
261
- if (u.match(A))
262
- break;
263
- if (u.trim() === "")
264
- c.push(u), o += `
265
- `, d += 1;
266
- else if (u.match(J))
267
- c.push(u), o += `
268
- ${u.slice(h + 2)}`, d += 1;
269
- else
270
- break;
271
- }
272
- e.push({
273
- indent: h,
274
- number: parseInt(a, 10),
275
- content: o.trim(),
276
- raw: c.join(`
277
- `)
278
- }), n = d, s = d;
279
- }
280
- return [e, n];
281
- }
282
- function R(t, e, s) {
283
- var n;
284
- const r = [];
285
- let i = 0;
286
- for (; i < t.length; ) {
287
- const l = t[i];
288
- if (l.indent === e) {
289
- const a = l.content.split(`
290
- `), p = ((n = a[0]) == null ? void 0 : n.trim()) || "", h = [];
291
- p && h.push({
292
- type: "paragraph",
293
- raw: p,
294
- tokens: s.inlineTokens(p)
295
- });
296
- const o = a.slice(1).join(`
297
- `).trim();
298
- if (o) {
299
- const u = s.blockTokens(o);
300
- h.push(...u);
301
- }
302
- let d = i + 1;
303
- const c = [];
304
- for (; d < t.length && t[d].indent > e; )
305
- c.push(t[d]), d += 1;
306
- if (c.length > 0) {
307
- const u = Math.min(...c.map((y) => y.indent)), f = R(c, u, s);
308
- h.push({
309
- type: "list",
310
- ordered: !0,
311
- start: c[0].number,
312
- items: f,
313
- raw: c.map((y) => y.raw).join(`
314
- `)
315
- });
316
- }
317
- r.push({
318
- type: "list_item",
319
- raw: l.raw,
320
- tokens: h
321
- }), i = d;
322
- } else
323
- i += 1;
324
- }
325
- return r;
326
- }
327
- function U(t, e) {
328
- return t.map((s) => {
329
- if (s.type !== "list_item")
330
- return e.parseChildren([s])[0];
331
- const n = [];
332
- return s.tokens && s.tokens.length > 0 && s.tokens.forEach((r) => {
333
- if (r.type === "paragraph" || r.type === "list" || r.type === "blockquote" || r.type === "code")
334
- n.push(...e.parseChildren([r]));
335
- else if (r.type === "text" && r.tokens) {
336
- const i = e.parseChildren([r]);
337
- n.push({
338
- type: "paragraph",
339
- content: i
340
- });
341
- } else {
342
- const i = e.parseChildren([r]);
343
- i.length > 0 && n.push(...i);
344
- }
345
- }), {
346
- type: "listItem",
347
- content: n
348
- };
349
- });
350
- }
351
- var Z = "listItem", C = "textStyle", N = /^(\d+)\.\s$/, tt = L.create({
352
- name: "orderedList",
353
- addOptions() {
354
- return {
355
- itemTypeName: "listItem",
356
- HTMLAttributes: {},
357
- keepMarks: !1,
358
- keepAttributes: !1
359
- };
360
- },
361
- group: "block list",
362
- content() {
363
- return `${this.options.itemTypeName}+`;
364
- },
365
- addAttributes() {
366
- return {
367
- start: {
368
- default: 1,
369
- parseHTML: (t) => t.hasAttribute("start") ? parseInt(t.getAttribute("start") || "", 10) : 1
370
- },
371
- type: {
372
- default: null,
373
- parseHTML: (t) => t.getAttribute("type")
374
- }
375
- };
376
- },
377
- parseHTML() {
378
- return [
379
- {
380
- tag: "ol"
381
- }
382
- ];
383
- },
384
- renderHTML({ HTMLAttributes: t }) {
385
- const { start: e, ...s } = t;
386
- return e === 1 ? ["ol", m(this.options.HTMLAttributes, s), 0] : ["ol", m(this.options.HTMLAttributes, t), 0];
387
- },
388
- markdownTokenName: "list",
389
- parseMarkdown: (t, e) => {
390
- if (t.type !== "list" || !t.ordered)
391
- return [];
392
- const s = t.start || 1, n = t.items ? U(t.items, e) : [];
393
- return s !== 1 ? {
394
- type: "orderedList",
395
- attrs: { start: s },
396
- content: n
397
- } : {
398
- type: "orderedList",
399
- content: n
400
- };
401
- },
402
- renderMarkdown: (t, e) => t.content ? e.renderChildren(t.content, `
403
- `) : "",
404
- markdownTokenizer: {
405
- name: "orderedList",
406
- level: "block",
407
- start: (t) => {
408
- const e = t.match(/^(\s*)(\d+)\.\s+/), s = e?.index;
409
- return s !== void 0 ? s : -1;
410
- },
411
- tokenize: (t, e, s) => {
412
- var n;
413
- const r = t.split(`
414
- `), [i, l] = Q(r);
415
- if (i.length === 0)
416
- return;
417
- const a = R(i, 0, s);
418
- return a.length === 0 ? void 0 : {
419
- type: "list",
420
- ordered: !0,
421
- start: ((n = i[0]) == null ? void 0 : n.number) || 1,
422
- items: a,
423
- raw: r.slice(0, l).join(`
424
- `)
425
- };
426
- }
427
- },
428
- markdownOptions: {
429
- indentsContent: !0
430
- },
431
- addCommands() {
432
- return {
433
- toggleOrderedList: () => ({ commands: t, chain: e }) => this.options.keepAttributes ? e().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(Z, this.editor.getAttributes(C)).run() : t.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
434
- };
435
- },
436
- addKeyboardShortcuts() {
437
- return {
438
- "Mod-Shift-7": () => this.editor.commands.toggleOrderedList()
439
- };
440
- },
441
- addInputRules() {
442
- let t = k({
443
- find: N,
444
- type: this.type,
445
- getAttributes: (e) => ({ start: +e[1] }),
446
- joinPredicate: (e, s) => s.childCount + s.attrs.start === +e[1]
447
- });
448
- return (this.options.keepMarks || this.options.keepAttributes) && (t = k({
449
- find: N,
450
- type: this.type,
451
- keepMarks: this.options.keepMarks,
452
- keepAttributes: this.options.keepAttributes,
453
- getAttributes: (e) => ({ start: +e[1], ...this.editor.getAttributes(C) }),
454
- joinPredicate: (e, s) => s.childCount + s.attrs.start === +e[1],
455
- editor: this.editor
456
- })), [t];
457
- }
458
- }), et = /^\s*(\[([( |x])?\])\s$/, st = L.create({
459
- name: "taskItem",
460
- addOptions() {
461
- return {
462
- nested: !1,
463
- HTMLAttributes: {},
464
- taskListTypeName: "taskList",
465
- a11y: void 0
466
- };
467
- },
468
- content() {
469
- return this.options.nested ? "paragraph block*" : "paragraph+";
470
- },
471
- defining: !0,
472
- addAttributes() {
473
- return {
474
- checked: {
475
- default: !1,
476
- keepOnSplit: !1,
477
- parseHTML: (t) => {
478
- const e = t.getAttribute("data-checked");
479
- return e === "" || e === "true";
480
- },
481
- renderHTML: (t) => ({
482
- "data-checked": t.checked
483
- })
484
- }
485
- };
486
- },
487
- parseHTML() {
488
- return [
489
- {
490
- tag: `li[data-type="${this.name}"]`,
491
- priority: 51
492
- }
493
- ];
494
- },
495
- renderHTML({ node: t, HTMLAttributes: e }) {
496
- return [
497
- "li",
498
- m(this.options.HTMLAttributes, e, {
499
- "data-type": this.name
500
- }),
501
- [
502
- "label",
503
- [
504
- "input",
505
- {
506
- type: "checkbox",
507
- checked: t.attrs.checked ? "checked" : null
508
- }
509
- ],
510
- ["span"]
511
- ],
512
- ["div", 0]
513
- ];
514
- },
515
- parseMarkdown: (t, e) => {
516
- const s = [];
517
- 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) {
518
- const n = e.parseChildren(t.nestedTokens);
519
- s.push(...n);
520
- }
521
- return e.createNode("taskItem", { checked: t.checked || !1 }, s);
522
- },
523
- renderMarkdown: (t, e) => {
524
- var s;
525
- const r = `- [${(s = t.attrs) != null && s.checked ? "x" : " "}] `;
526
- return E(t, e, r);
527
- },
528
- addKeyboardShortcuts() {
529
- const t = {
530
- Enter: () => this.editor.commands.splitListItem(this.name),
531
- "Shift-Tab": () => this.editor.commands.liftListItem(this.name)
532
- };
533
- return this.options.nested ? {
534
- ...t,
535
- Tab: () => this.editor.commands.sinkListItem(this.name)
536
- } : t;
537
- },
538
- addNodeView() {
539
- return ({ node: t, HTMLAttributes: e, getPos: s, editor: n }) => {
540
- const r = document.createElement("li"), i = document.createElement("label"), l = document.createElement("span"), a = document.createElement("input"), p = document.createElement("div"), h = (o) => {
541
- var d, c;
542
- a.ariaLabel = ((c = (d = this.options.a11y) == null ? void 0 : d.checkboxLabel) == null ? void 0 : c.call(d, o, a.checked)) || `Task item checkbox for ${o.textContent || "empty task item"}`;
543
- };
544
- return h(t), i.contentEditable = "false", a.type = "checkbox", a.addEventListener("mousedown", (o) => o.preventDefault()), a.addEventListener("change", (o) => {
545
- if (!n.isEditable && !this.options.onReadOnlyChecked) {
546
- a.checked = !a.checked;
547
- return;
548
- }
549
- const { checked: d } = o.target;
550
- n.isEditable && typeof s == "function" && n.chain().focus(void 0, { scrollIntoView: !1 }).command(({ tr: c }) => {
551
- const u = s();
552
- if (typeof u != "number")
553
- return !1;
554
- const f = c.doc.nodeAt(u);
555
- return c.setNodeMarkup(u, void 0, {
556
- ...f?.attrs,
557
- checked: d
558
- }), !0;
559
- }).run(), !n.isEditable && this.options.onReadOnlyChecked && (this.options.onReadOnlyChecked(t, d) || (a.checked = !a.checked));
560
- }), Object.entries(this.options.HTMLAttributes).forEach(([o, d]) => {
561
- r.setAttribute(o, d);
562
- }), r.dataset.checked = t.attrs.checked, a.checked = t.attrs.checked, i.append(a, l), r.append(i, p), Object.entries(e).forEach(([o, d]) => {
563
- r.setAttribute(o, d);
564
- }), {
565
- dom: r,
566
- contentDOM: p,
567
- update: (o) => o.type !== this.type ? !1 : (r.dataset.checked = o.attrs.checked, a.checked = o.attrs.checked, h(o), !0)
568
- };
569
- };
570
- },
571
- addInputRules() {
572
- return [
573
- k({
574
- find: et,
575
- type: this.type,
576
- getAttributes: (t) => ({
577
- checked: t[t.length - 1] === "x"
578
- })
579
- })
580
- ];
581
- }
582
- }), nt = L.create({
583
- name: "taskList",
584
- addOptions() {
585
- return {
586
- itemTypeName: "taskItem",
587
- HTMLAttributes: {}
588
- };
589
- },
590
- group: "block list",
591
- content() {
592
- return `${this.options.itemTypeName}+`;
593
- },
594
- parseHTML() {
595
- return [
596
- {
597
- tag: `ul[data-type="${this.name}"]`,
598
- priority: 51
599
- }
600
- ];
601
- },
602
- renderHTML({ HTMLAttributes: t }) {
603
- return ["ul", m(this.options.HTMLAttributes, t, { "data-type": this.name }), 0];
604
- },
605
- parseMarkdown: (t, e) => e.createNode("taskList", {}, e.parseChildren(t.items || [])),
606
- renderMarkdown: (t, e) => t.content ? e.renderChildren(t.content, `
607
- `) : "",
608
- markdownTokenizer: {
609
- name: "taskList",
610
- level: "block",
611
- start(t) {
612
- var e;
613
- const s = (e = t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)) == null ? void 0 : e.index;
614
- return s !== void 0 ? s : -1;
615
- },
616
- tokenize(t, e, s) {
617
- const n = (i) => {
618
- const l = M(
619
- i,
620
- {
621
- itemPattern: /^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,
622
- extractItemData: (a) => ({
623
- indentLevel: a[1].length,
624
- mainContent: a[4],
625
- checked: a[3].toLowerCase() === "x"
626
- }),
627
- createToken: (a, p) => ({
628
- type: "taskItem",
629
- raw: "",
630
- mainContent: a.mainContent,
631
- indentLevel: a.indentLevel,
632
- checked: a.checked,
633
- text: a.mainContent,
634
- tokens: s.inlineTokens(a.mainContent),
635
- nestedTokens: p
636
- }),
637
- // Allow recursive nesting
638
- customNestedParser: n
639
- },
640
- s
641
- );
642
- return l ? [
643
- {
644
- type: "taskList",
645
- raw: l.raw,
646
- items: l.items
647
- }
648
- ] : s.blockTokens(i);
649
- }, r = M(
650
- t,
651
- {
652
- itemPattern: /^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,
653
- extractItemData: (i) => ({
654
- indentLevel: i[1].length,
655
- mainContent: i[4],
656
- checked: i[3].toLowerCase() === "x"
657
- }),
658
- createToken: (i, l) => ({
659
- type: "taskItem",
660
- raw: "",
661
- mainContent: i.mainContent,
662
- indentLevel: i.indentLevel,
663
- checked: i.checked,
664
- text: i.mainContent,
665
- tokens: s.inlineTokens(i.mainContent),
666
- nestedTokens: l
667
- }),
668
- // Use the recursive parser for nested content
669
- customNestedParser: n
670
- },
671
- s
672
- );
673
- if (r)
674
- return {
675
- type: "taskList",
676
- raw: r.raw,
677
- items: r.items
678
- };
679
- }
680
- },
681
- markdownOptions: {
682
- indentsContent: !0
683
- },
684
- addCommands() {
685
- return {
686
- toggleTaskList: () => ({ commands: t }) => t.toggleList(this.name, this.options.itemTypeName)
687
- };
688
- },
689
- addKeyboardShortcuts() {
690
- return {
691
- "Mod-Shift-9": () => this.editor.commands.toggleTaskList()
692
- };
693
- }
694
- });
695
- H.create({
696
- name: "listKit",
697
- addExtensions() {
698
- const t = [];
699
- return this.options.bulletList !== !1 && t.push(F.configure(this.options.bulletList)), this.options.listItem !== !1 && t.push(G.configure(this.options.listItem)), this.options.listKeymap !== !1 && t.push(Y.configure(this.options.listKeymap)), this.options.orderedList !== !1 && t.push(tt.configure(this.options.orderedList)), this.options.taskItem !== !1 && t.push(st.configure(this.options.taskItem)), this.options.taskList !== !1 && t.push(nt.configure(this.options.taskList)), t;
700
- }
701
- });
702
- export {
703
- F as BulletList,
704
- G as ListItem,
705
- Y as ListKeymap,
706
- tt as OrderedList,
707
- st as TaskItem,
708
- nt as TaskList,
709
- w as bulletListInputRegex,
710
- et as inputRegex,
711
- W as listHelpers,
712
- N as orderedListInputRegex
713
- };