@vc-shell/framework 1.1.98-rc.4 → 1.1.99-alpha.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 (96) hide show
  1. package/core/api/platform.ts +9883 -9883
  2. package/core/composables/useNotifications/index.ts +32 -1
  3. package/core/composables/useSettings/index.ts +8 -3
  4. package/core/composables/useUser/index.ts +74 -171
  5. package/core/composables/useUserManagement/index.ts +67 -25
  6. package/core/interceptors/index.ts +19 -56
  7. package/core/plugins/signalR/index.ts +27 -1
  8. package/core/providers/README.md +176 -0
  9. package/core/providers/auth-provider-manager.ts +74 -0
  10. package/core/providers/auth-provider-utils.ts +26 -0
  11. package/core/providers/example-custom-auth-provider.ts +162 -0
  12. package/core/providers/index.ts +3 -0
  13. package/core/providers/platform-auth-provider.ts +207 -0
  14. package/core/types/auth-provider.ts +40 -0
  15. package/core/types/index.ts +2 -0
  16. package/dist/core/api/platform.d.ts +1 -1
  17. package/dist/core/api/platform.d.ts.map +1 -1
  18. package/dist/core/composables/useNotifications/index.d.ts.map +1 -1
  19. package/dist/core/composables/useSettings/index.d.ts.map +1 -1
  20. package/dist/core/composables/useUser/index.d.ts +18 -9
  21. package/dist/core/composables/useUser/index.d.ts.map +1 -1
  22. package/dist/core/composables/useUserManagement/index.d.ts +7 -7
  23. package/dist/core/composables/useUserManagement/index.d.ts.map +1 -1
  24. package/dist/core/interceptors/index.d.ts +2 -1
  25. package/dist/core/interceptors/index.d.ts.map +1 -1
  26. package/dist/core/plugins/signalR/index.d.ts +2 -0
  27. package/dist/core/plugins/signalR/index.d.ts.map +1 -1
  28. package/dist/core/providers/auth-provider-manager.d.ts +34 -0
  29. package/dist/core/providers/auth-provider-manager.d.ts.map +1 -0
  30. package/dist/core/providers/auth-provider-utils.d.ts +17 -0
  31. package/dist/core/providers/auth-provider-utils.d.ts.map +1 -0
  32. package/dist/core/providers/example-custom-auth-provider.d.ts +45 -0
  33. package/dist/core/providers/example-custom-auth-provider.d.ts.map +1 -0
  34. package/dist/core/providers/index.d.ts +3 -0
  35. package/dist/core/providers/index.d.ts.map +1 -0
  36. package/dist/core/providers/platform-auth-provider.d.ts +34 -0
  37. package/dist/core/providers/platform-auth-provider.d.ts.map +1 -0
  38. package/dist/core/types/auth-provider.d.ts +27 -0
  39. package/dist/core/types/auth-provider.d.ts.map +1 -0
  40. package/dist/core/types/index.d.ts +1 -1
  41. package/dist/core/types/index.d.ts.map +1 -1
  42. package/dist/framework.js +6348 -6198
  43. package/dist/index.css +1 -1
  44. package/dist/index.d.ts +8 -0
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/injection-keys.d.ts +2 -1
  47. package/dist/injection-keys.d.ts.map +1 -1
  48. package/dist/shared/components/app-switcher/composables/useAppSwitcher/index.d.ts.map +1 -1
  49. package/dist/shared/components/sign-in/useExternalProvider.d.ts +1 -1
  50. package/dist/shared/components/sign-in/useExternalProvider.d.ts.map +1 -1
  51. package/dist/shared/modules/dynamic/helpers/nodeBuilder.d.ts.map +1 -1
  52. package/dist/tsconfig.tsbuildinfo +1 -1
  53. package/dist/ui/components/organisms/vc-app/vc-app.vue.d.ts.map +1 -1
  54. package/dist/vendor-tiptap-core-ClsTgaMv.js +3699 -0
  55. package/dist/{vendor-tiptap-extension-blockquote-BVmAuV7o.js → vendor-tiptap-extension-blockquote-r1MBx4hD.js} +1 -1
  56. package/dist/{vendor-tiptap-extension-bold-BOh8AIRZ.js → vendor-tiptap-extension-bold-BjLI4i8b.js} +1 -1
  57. package/dist/{vendor-tiptap-extension-code-R4pc2wFE.js → vendor-tiptap-extension-code-D5-kDnMW.js} +1 -1
  58. package/dist/{vendor-tiptap-extension-code-block-DibKlZFG.js → vendor-tiptap-extension-code-block-RjEb0zPA.js} +1 -1
  59. package/dist/{vendor-tiptap-extension-document-BwORJR1k.js → vendor-tiptap-extension-document--PLOxIdq.js} +1 -1
  60. package/dist/{vendor-tiptap-extension-hard-break-DH36OfVk.js → vendor-tiptap-extension-hard-break-9cxC2YOS.js} +13 -9
  61. package/dist/{vendor-tiptap-extension-heading-oMLORiPI.js → vendor-tiptap-extension-heading-2w0TutHn.js} +1 -1
  62. package/dist/{vendor-tiptap-extension-horizontal-rule-BMHSoB_Y.js → vendor-tiptap-extension-horizontal-rule-CFowa_lc.js} +1 -1
  63. package/dist/vendor-tiptap-extension-image-aWn-na6j.js +127 -0
  64. package/dist/{vendor-tiptap-extension-italic-BzqrUuB0.js → vendor-tiptap-extension-italic-Bn-6saY0.js} +1 -1
  65. package/dist/{vendor-tiptap-extension-link-hMFZ0hfl.js → vendor-tiptap-extension-link-BmcG1_k-.js} +1 -1
  66. package/dist/{vendor-tiptap-extension-list-Bj5AK6Pq.js → vendor-tiptap-extension-list-BrNBJ45n.js} +1 -1
  67. package/dist/{vendor-tiptap-extension-paragraph-Bs1wl42E.js → vendor-tiptap-extension-paragraph-DAiYhwUB.js} +1 -1
  68. package/dist/vendor-tiptap-extension-placeholder-9tURDKy-.js +1 -0
  69. package/dist/{vendor-tiptap-extension-strike-C4YpGyzc.js → vendor-tiptap-extension-strike-DqbXPfos.js} +1 -1
  70. package/dist/vendor-tiptap-extension-table-DQwPaR7v.js +374 -0
  71. package/dist/vendor-tiptap-extension-table-cell-C0tEP_0i.js +1 -0
  72. package/dist/vendor-tiptap-extension-table-header-C0tEP_0i.js +1 -0
  73. package/dist/vendor-tiptap-extension-table-row-C0tEP_0i.js +1 -0
  74. package/dist/{vendor-tiptap-extension-text-C4dQW13r.js → vendor-tiptap-extension-text-BFnfj70b.js} +1 -1
  75. package/dist/{vendor-tiptap-extension-text-style-a_NYjXT6.js → vendor-tiptap-extension-text-style-Darua3qr.js} +1 -1
  76. package/dist/{vendor-tiptap-extension-underline-DthCaPX3.js → vendor-tiptap-extension-underline-QyVnBqQZ.js} +1 -1
  77. package/dist/{vendor-tiptap-extensions-C8rF1qdq.js → vendor-tiptap-extensions-CU-D7bfm.js} +1 -1
  78. package/dist/{vendor-tiptap-markdown-DRc3qhBU.js → vendor-tiptap-markdown-BwATYN5A.js} +1 -1
  79. package/dist/{vendor-tiptap-starter-kit-BfUUblkP.js → vendor-tiptap-starter-kit-5luf7zzS.js} +17 -17
  80. package/dist/{vendor-tiptap-vue-3-DYxT2sf6.js → vendor-tiptap-vue-3-CFBErZGb.js} +1 -1
  81. package/dist/{vendor-vueuse-components-B0zqjNRW.js → vendor-vueuse-components-sgKpNzof.js} +1 -1
  82. package/dist/{vendor-vueuse-core-CYgwn-B2.js → vendor-vueuse-core-D0cN7FqY.js} +10 -10
  83. package/dist/{vendor-vueuse-shared-B_uDJJ6V.js → vendor-vueuse-shared-Pt0UEStA.js} +19 -19
  84. package/package.json +7 -5
  85. package/shared/components/app-switcher/components/vc-app-switcher/vc-app-switcher.vue +2 -2
  86. package/shared/components/app-switcher/composables/useAppSwitcher/index.ts +15 -1
  87. package/shared/components/sign-in/useExternalProvider.ts +11 -1
  88. package/shared/modules/dynamic/helpers/nodeBuilder.ts +11 -3
  89. package/ui/components/organisms/vc-app/vc-app.vue +20 -2
  90. package/dist/vendor-tiptap-core-8RGSOCZs.js +0 -3442
  91. package/dist/vendor-tiptap-extension-image-DF1ZJ94q.js +0 -80
  92. package/dist/vendor-tiptap-extension-placeholder-CupUGaI_.js +0 -1
  93. package/dist/vendor-tiptap-extension-table-D8RFr_6X.js +0 -368
  94. package/dist/vendor-tiptap-extension-table-cell-k9uLwyL6.js +0 -1
  95. package/dist/vendor-tiptap-extension-table-header-k9uLwyL6.js +0 -1
  96. package/dist/vendor-tiptap-extension-table-row-k9uLwyL6.js +0 -1
@@ -0,0 +1,3699 @@
1
+ import { f as le, c as ht, T as de, e as ue, l as fe, j as It, a as X, b as pe, R as he } from "./vendor-prosemirror-transform-CAHmg-qG.js";
2
+ import { c as me, d as ge, e as ve, j as ye, a as be, b as we, f as ke, g as Me, h as Se, l as xe, i as Ee, n as Te, s as Ae, k as Ce, m as Pe, o as $e, p as Ne, q as Tt, w as Re } from "./vendor-prosemirror-commands-Cu1q5ZDk.js";
3
+ import { N as G, E as ze, S as L, T as P, P as N, a as O, A as Ie } from "./vendor-prosemirror-state-DHaVEu5h.js";
4
+ import { D as _e, a as _t, F as _, b as Be, d as ct, S as je } from "./vendor-prosemirror-model-DFp4ML7B.js";
5
+ import { l as Oe, s as De, w as Le } from "./vendor-prosemirror-schema-list-CwCUArvx.js";
6
+ import { E as Fe } from "./vendor-prosemirror-view-CspJa44O.js";
7
+ import { a as He } from "./vendor-prosemirror-keymap-KfbdOEJw.js";
8
+ var Ve = Object.defineProperty, mt = (e, t) => {
9
+ for (var n in t)
10
+ Ve(e, n, { get: t[n], enumerable: !0 });
11
+ };
12
+ function tt(e) {
13
+ const { state: t, transaction: n } = e;
14
+ let { selection: r } = n, { doc: s } = n, { storedMarks: o } = n;
15
+ return {
16
+ ...t,
17
+ apply: t.apply.bind(t),
18
+ applyTransaction: t.applyTransaction.bind(t),
19
+ plugins: t.plugins,
20
+ schema: t.schema,
21
+ reconfigure: t.reconfigure.bind(t),
22
+ toJSON: t.toJSON.bind(t),
23
+ get storedMarks() {
24
+ return o;
25
+ },
26
+ get selection() {
27
+ return r;
28
+ },
29
+ get doc() {
30
+ return s;
31
+ },
32
+ get tr() {
33
+ return r = n.selection, s = n.doc, o = n.storedMarks, n;
34
+ }
35
+ };
36
+ }
37
+ var et = class {
38
+ constructor(e) {
39
+ this.editor = e.editor, this.rawCommands = this.editor.extensionManager.commands, this.customState = e.state;
40
+ }
41
+ get hasCustomState() {
42
+ return !!this.customState;
43
+ }
44
+ get state() {
45
+ return this.customState || this.editor.state;
46
+ }
47
+ get commands() {
48
+ const { rawCommands: e, editor: t, state: n } = this, { view: r } = t, { tr: s } = n, o = this.buildProps(s);
49
+ return Object.fromEntries(
50
+ Object.entries(e).map(([i, a]) => [i, (...l) => {
51
+ const d = a(...l)(o);
52
+ return !s.getMeta("preventDispatch") && !this.hasCustomState && r.dispatch(s), d;
53
+ }])
54
+ );
55
+ }
56
+ get chain() {
57
+ return () => this.createChain();
58
+ }
59
+ get can() {
60
+ return () => this.createCan();
61
+ }
62
+ createChain(e, t = !0) {
63
+ const { rawCommands: n, editor: r, state: s } = this, { view: o } = r, i = [], a = !!e, c = e || s.tr, l = () => (!a && t && !c.getMeta("preventDispatch") && !this.hasCustomState && o.dispatch(c), i.every((u) => u === !0)), d = {
64
+ ...Object.fromEntries(
65
+ Object.entries(n).map(([u, f]) => [u, (...h) => {
66
+ const m = this.buildProps(c, t), g = f(...h)(m);
67
+ return i.push(g), d;
68
+ }])
69
+ ),
70
+ run: l
71
+ };
72
+ return d;
73
+ }
74
+ createCan(e) {
75
+ const { rawCommands: t, state: n } = this, r = !1, s = e || n.tr, o = this.buildProps(s, r);
76
+ return {
77
+ ...Object.fromEntries(
78
+ Object.entries(t).map(([a, c]) => [a, (...l) => c(...l)({ ...o, dispatch: void 0 })])
79
+ ),
80
+ chain: () => this.createChain(s, r)
81
+ };
82
+ }
83
+ buildProps(e, t = !0) {
84
+ const { rawCommands: n, editor: r, state: s } = this, { view: o } = r, i = {
85
+ tr: e,
86
+ editor: r,
87
+ view: o,
88
+ state: tt({
89
+ state: s,
90
+ transaction: e
91
+ }),
92
+ dispatch: t ? () => {
93
+ } : void 0,
94
+ chain: () => this.createChain(e, t),
95
+ can: () => this.createCan(e),
96
+ get commands() {
97
+ return Object.fromEntries(
98
+ Object.entries(n).map(([a, c]) => [a, (...l) => c(...l)(i)])
99
+ );
100
+ }
101
+ };
102
+ return i;
103
+ }
104
+ }, Bt = {};
105
+ mt(Bt, {
106
+ blur: () => We,
107
+ clearContent: () => Ue,
108
+ clearNodes: () => Ke,
109
+ command: () => qe,
110
+ createParagraphNear: () => Je,
111
+ cut: () => Xe,
112
+ deleteCurrentNode: () => Ye,
113
+ deleteNode: () => Ze,
114
+ deleteRange: () => Qe,
115
+ deleteSelection: () => Ge,
116
+ enter: () => tn,
117
+ exitCode: () => en,
118
+ extendMarkRange: () => nn,
119
+ first: () => rn,
120
+ focus: () => on,
121
+ forEach: () => an,
122
+ insertContent: () => cn,
123
+ insertContentAt: () => un,
124
+ joinBackward: () => hn,
125
+ joinDown: () => pn,
126
+ joinForward: () => mn,
127
+ joinItemBackward: () => gn,
128
+ joinItemForward: () => vn,
129
+ joinTextblockBackward: () => yn,
130
+ joinTextblockForward: () => bn,
131
+ joinUp: () => fn,
132
+ keyboardShortcut: () => kn,
133
+ lift: () => Mn,
134
+ liftEmptyBlock: () => Sn,
135
+ liftListItem: () => xn,
136
+ newlineInCode: () => En,
137
+ resetAttributes: () => Tn,
138
+ scrollIntoView: () => An,
139
+ selectAll: () => Cn,
140
+ selectNodeBackward: () => Pn,
141
+ selectNodeForward: () => $n,
142
+ selectParentNode: () => Nn,
143
+ selectTextblockEnd: () => Rn,
144
+ selectTextblockStart: () => zn,
145
+ setContent: () => In,
146
+ setMark: () => Qn,
147
+ setMeta: () => Gn,
148
+ setNode: () => tr,
149
+ setNodeSelection: () => er,
150
+ setTextSelection: () => nr,
151
+ sinkListItem: () => rr,
152
+ splitBlock: () => sr,
153
+ splitListItem: () => or,
154
+ toggleList: () => ir,
155
+ toggleMark: () => ar,
156
+ toggleNode: () => cr,
157
+ toggleWrap: () => lr,
158
+ undoInputRule: () => dr,
159
+ unsetAllMarks: () => ur,
160
+ unsetMark: () => fr,
161
+ updateAttributes: () => pr,
162
+ wrapIn: () => hr,
163
+ wrapInList: () => mr
164
+ });
165
+ var We = () => ({ editor: e, view: t }) => (requestAnimationFrame(() => {
166
+ var n;
167
+ e.isDestroyed || (t.dom.blur(), (n = window?.getSelection()) == null || n.removeAllRanges());
168
+ }), !0), Ue = (e = !0) => ({ commands: t }) => t.setContent("", { emitUpdate: e }), Ke = () => ({ state: e, tr: t, dispatch: n }) => {
169
+ const { selection: r } = t, { ranges: s } = r;
170
+ return n && s.forEach(({ $from: o, $to: i }) => {
171
+ e.doc.nodesBetween(o.pos, i.pos, (a, c) => {
172
+ if (a.type.isText)
173
+ return;
174
+ const { doc: l, mapping: d } = t, u = l.resolve(d.map(c)), f = l.resolve(d.map(c + a.nodeSize)), p = u.blockRange(f);
175
+ if (!p)
176
+ return;
177
+ const h = fe(p);
178
+ if (a.type.isTextblock) {
179
+ const { defaultType: m } = u.parent.contentMatchAt(u.index());
180
+ t.setNodeMarkup(p.start, m);
181
+ }
182
+ (h || h === 0) && t.lift(p, h);
183
+ });
184
+ }), !0;
185
+ }, qe = (e) => (t) => e(t), Je = () => ({ state: e, dispatch: t }) => me(e, t), Xe = (e, t) => ({ editor: n, tr: r }) => {
186
+ const { state: s } = n, o = s.doc.slice(e.from, e.to);
187
+ r.deleteRange(e.from, e.to);
188
+ const i = r.mapping.map(t);
189
+ return r.insert(i, o.content), r.setSelection(new P(r.doc.resolve(Math.max(i - 1, 0)))), !0;
190
+ }, Ye = () => ({ tr: e, dispatch: t }) => {
191
+ const { selection: n } = e, r = n.$anchor.node();
192
+ if (r.content.size > 0)
193
+ return !1;
194
+ const s = e.selection.$anchor;
195
+ for (let o = s.depth; o > 0; o -= 1)
196
+ if (s.node(o).type === r.type) {
197
+ if (t) {
198
+ const a = s.before(o), c = s.after(o);
199
+ e.delete(a, c).scrollIntoView();
200
+ }
201
+ return !0;
202
+ }
203
+ return !1;
204
+ };
205
+ function T(e, t) {
206
+ if (typeof e == "string") {
207
+ if (!t.nodes[e])
208
+ throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);
209
+ return t.nodes[e];
210
+ }
211
+ return e;
212
+ }
213
+ var Ze = (e) => ({ tr: t, state: n, dispatch: r }) => {
214
+ const s = T(e, n.schema), o = t.selection.$anchor;
215
+ for (let i = o.depth; i > 0; i -= 1)
216
+ if (o.node(i).type === s) {
217
+ if (r) {
218
+ const c = o.before(i), l = o.after(i);
219
+ t.delete(c, l).scrollIntoView();
220
+ }
221
+ return !0;
222
+ }
223
+ return !1;
224
+ }, Qe = (e) => ({ tr: t, dispatch: n }) => {
225
+ const { from: r, to: s } = e;
226
+ return n && t.delete(r, s), !0;
227
+ }, Ge = () => ({ state: e, dispatch: t }) => ge(e, t), tn = () => ({ commands: e }) => e.keyboardShortcut("Enter"), en = () => ({ state: e, dispatch: t }) => ve(e, t);
228
+ function gt(e) {
229
+ return Object.prototype.toString.call(e) === "[object RegExp]";
230
+ }
231
+ function Z(e, t, n = { strict: !0 }) {
232
+ const r = Object.keys(t);
233
+ return r.length ? r.every((s) => n.strict ? t[s] === e[s] : gt(t[s]) ? t[s].test(e[s]) : t[s] === e[s]) : !0;
234
+ }
235
+ function jt(e, t, n = {}) {
236
+ return e.find((r) => r.type === t && Z(
237
+ // Only check equality for the attributes that are provided
238
+ Object.fromEntries(Object.keys(n).map((s) => [s, r.attrs[s]])),
239
+ n
240
+ ));
241
+ }
242
+ function At(e, t, n = {}) {
243
+ return !!jt(e, t, n);
244
+ }
245
+ function vt(e, t, n) {
246
+ var r;
247
+ if (!e || !t)
248
+ return;
249
+ let s = e.parent.childAfter(e.parentOffset);
250
+ if ((!s.node || !s.node.marks.some((d) => d.type === t)) && (s = e.parent.childBefore(e.parentOffset)), !s.node || !s.node.marks.some((d) => d.type === t) || (n = n || ((r = s.node.marks[0]) == null ? void 0 : r.attrs), !jt([...s.node.marks], t, n)))
251
+ return;
252
+ let i = s.index, a = e.start() + s.offset, c = i + 1, l = a + s.node.nodeSize;
253
+ for (; i > 0 && At([...e.parent.child(i - 1).marks], t, n); )
254
+ i -= 1, a -= e.parent.child(i).nodeSize;
255
+ for (; c < e.parent.childCount && At([...e.parent.child(c).marks], t, n); )
256
+ l += e.parent.child(c).nodeSize, c += 1;
257
+ return {
258
+ from: a,
259
+ to: l
260
+ };
261
+ }
262
+ function R(e, t) {
263
+ if (typeof e == "string") {
264
+ if (!t.marks[e])
265
+ throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);
266
+ return t.marks[e];
267
+ }
268
+ return e;
269
+ }
270
+ var nn = (e, t = {}) => ({ tr: n, state: r, dispatch: s }) => {
271
+ const o = R(e, r.schema), { doc: i, selection: a } = n, { $from: c, from: l, to: d } = a;
272
+ if (s) {
273
+ const u = vt(c, o, t);
274
+ if (u && u.from <= l && u.to >= d) {
275
+ const f = P.create(i, u.from, u.to);
276
+ n.setSelection(f);
277
+ }
278
+ }
279
+ return !0;
280
+ }, rn = (e) => (t) => {
281
+ const n = typeof e == "function" ? e(t) : e;
282
+ for (let r = 0; r < n.length; r += 1)
283
+ if (n[r](t))
284
+ return !0;
285
+ return !1;
286
+ };
287
+ function Ot(e) {
288
+ return e instanceof P;
289
+ }
290
+ function j(e = 0, t = 0, n = 0) {
291
+ return Math.min(Math.max(e, t), n);
292
+ }
293
+ function Dt(e, t = null) {
294
+ if (!t)
295
+ return null;
296
+ const n = L.atStart(e), r = L.atEnd(e);
297
+ if (t === "start" || t === !0)
298
+ return n;
299
+ if (t === "end")
300
+ return r;
301
+ const s = n.from, o = r.to;
302
+ return t === "all" ? P.create(e, j(0, s, o), j(e.content.size, s, o)) : P.create(e, j(t, s, o), j(t, s, o));
303
+ }
304
+ function sn() {
305
+ return navigator.platform === "Android" || /android/i.test(navigator.userAgent);
306
+ }
307
+ function yt() {
308
+ return ["iPad Simulator", "iPhone Simulator", "iPod Simulator", "iPad", "iPhone", "iPod"].includes(navigator.platform) || // iPad on iOS 13 detection
309
+ navigator.userAgent.includes("Mac") && "ontouchend" in document;
310
+ }
311
+ var on = (e = null, t = {}) => ({ editor: n, view: r, tr: s, dispatch: o }) => {
312
+ t = {
313
+ scrollIntoView: !0,
314
+ ...t
315
+ };
316
+ const i = () => {
317
+ (yt() || sn()) && r.dom.focus(), requestAnimationFrame(() => {
318
+ n.isDestroyed || (r.focus(), t?.scrollIntoView && n.commands.scrollIntoView());
319
+ });
320
+ };
321
+ if (r.hasFocus() && e === null || e === !1)
322
+ return !0;
323
+ if (o && e === null && !Ot(n.state.selection))
324
+ return i(), !0;
325
+ const a = Dt(s.doc, e) || n.state.selection, c = n.state.selection.eq(a);
326
+ return o && (c || s.setSelection(a), c && s.storedMarks && s.setStoredMarks(s.storedMarks), i()), !0;
327
+ }, an = (e, t) => (n) => e.every((r, s) => t(r, { ...n, index: s })), cn = (e, t) => ({ tr: n, commands: r }) => r.insertContentAt({ from: n.selection.from, to: n.selection.to }, e, t), Lt = (e) => {
328
+ const t = e.childNodes;
329
+ for (let n = t.length - 1; n >= 0; n -= 1) {
330
+ const r = t[n];
331
+ r.nodeType === 3 && r.nodeValue && /^(\n\s\s|\n)$/.test(r.nodeValue) ? e.removeChild(r) : r.nodeType === 1 && Lt(r);
332
+ }
333
+ return e;
334
+ };
335
+ function U(e) {
336
+ if (typeof window > "u")
337
+ throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");
338
+ const t = `<body>${e}</body>`, n = new window.DOMParser().parseFromString(t, "text/html").body;
339
+ return Lt(n);
340
+ }
341
+ function F(e, t, n) {
342
+ if (e instanceof Be || e instanceof _)
343
+ return e;
344
+ n = {
345
+ slice: !0,
346
+ parseOptions: {},
347
+ ...n
348
+ };
349
+ const r = typeof e == "object" && e !== null, s = typeof e == "string";
350
+ if (r)
351
+ try {
352
+ if (Array.isArray(e) && e.length > 0)
353
+ return _.fromArray(e.map((a) => t.nodeFromJSON(a)));
354
+ const i = t.nodeFromJSON(e);
355
+ return n.errorOnInvalidContent && i.check(), i;
356
+ } catch (o) {
357
+ if (n.errorOnInvalidContent)
358
+ throw new Error("[tiptap error]: Invalid JSON content", { cause: o });
359
+ return console.warn("[tiptap warn]: Invalid content.", "Passed value:", e, "Error:", o), F("", t, n);
360
+ }
361
+ if (s) {
362
+ if (n.errorOnInvalidContent) {
363
+ let i = !1, a = "";
364
+ const c = new _t({
365
+ topNode: t.spec.topNode,
366
+ marks: t.spec.marks,
367
+ // Prosemirror's schemas are executed such that: the last to execute, matches last
368
+ // This means that we can add a catch-all node at the end of the schema to catch any content that we don't know how to handle
369
+ nodes: t.spec.nodes.append({
370
+ __tiptap__private__unknown__catch__all__node: {
371
+ content: "inline*",
372
+ group: "block",
373
+ parseDOM: [
374
+ {
375
+ tag: "*",
376
+ getAttrs: (l) => (i = !0, a = typeof l == "string" ? l : l.outerHTML, null)
377
+ }
378
+ ]
379
+ }
380
+ })
381
+ });
382
+ if (n.slice ? ct.fromSchema(c).parseSlice(U(e), n.parseOptions) : ct.fromSchema(c).parse(U(e), n.parseOptions), n.errorOnInvalidContent && i)
383
+ throw new Error("[tiptap error]: Invalid HTML content", {
384
+ cause: new Error(`Invalid element found: ${a}`)
385
+ });
386
+ }
387
+ const o = ct.fromSchema(t);
388
+ return n.slice ? o.parseSlice(U(e), n.parseOptions).content : o.parse(U(e), n.parseOptions);
389
+ }
390
+ return F("", t, n);
391
+ }
392
+ function ln(e, t, n) {
393
+ const r = e.steps.length - 1;
394
+ if (r < t)
395
+ return;
396
+ const s = e.steps[r];
397
+ if (!(s instanceof pe || s instanceof he))
398
+ return;
399
+ const o = e.mapping.maps[r];
400
+ let i = 0;
401
+ o.forEach((a, c, l, d) => {
402
+ i === 0 && (i = d);
403
+ }), e.setSelection(L.near(e.doc.resolve(i), n));
404
+ }
405
+ var dn = (e) => !("type" in e), un = (e, t, n) => ({ tr: r, dispatch: s, editor: o }) => {
406
+ var i;
407
+ if (s) {
408
+ n = {
409
+ parseOptions: o.options.parseOptions,
410
+ updateSelection: !0,
411
+ applyInputRules: !1,
412
+ applyPasteRules: !1,
413
+ ...n
414
+ };
415
+ let a;
416
+ const c = (g) => {
417
+ o.emit("contentError", {
418
+ editor: o,
419
+ error: g,
420
+ disableCollaboration: () => {
421
+ "collaboration" in o.storage && typeof o.storage.collaboration == "object" && o.storage.collaboration && (o.storage.collaboration.isDisabled = !0);
422
+ }
423
+ });
424
+ }, l = {
425
+ preserveWhitespace: "full",
426
+ ...n.parseOptions
427
+ };
428
+ if (!n.errorOnInvalidContent && !o.options.enableContentCheck && o.options.emitContentError)
429
+ try {
430
+ F(t, o.schema, {
431
+ parseOptions: l,
432
+ errorOnInvalidContent: !0
433
+ });
434
+ } catch (g) {
435
+ c(g);
436
+ }
437
+ try {
438
+ a = F(t, o.schema, {
439
+ parseOptions: l,
440
+ errorOnInvalidContent: (i = n.errorOnInvalidContent) != null ? i : o.options.enableContentCheck
441
+ });
442
+ } catch (g) {
443
+ return c(g), !1;
444
+ }
445
+ let { from: d, to: u } = typeof e == "number" ? { from: e, to: e } : { from: e.from, to: e.to }, f = !0, p = !0;
446
+ if ((dn(a) ? a : [a]).forEach((g) => {
447
+ g.check(), f = f ? g.isText && g.marks.length === 0 : !1, p = p ? g.isBlock : !1;
448
+ }), d === u && p) {
449
+ const { parent: g } = r.doc.resolve(d);
450
+ g.isTextblock && !g.type.spec.code && !g.childCount && (d -= 1, u += 1);
451
+ }
452
+ let m;
453
+ if (f) {
454
+ if (Array.isArray(t))
455
+ m = t.map((g) => g.text || "").join("");
456
+ else if (t instanceof _) {
457
+ let g = "";
458
+ t.forEach((v) => {
459
+ v.text && (g += v.text);
460
+ }), m = g;
461
+ } else typeof t == "object" && t && t.text ? m = t.text : m = t;
462
+ r.insertText(m, d, u);
463
+ } else {
464
+ m = a;
465
+ const g = r.doc.resolve(d), v = g.node(), b = g.parentOffset === 0, k = v.isText || v.isTextblock, M = v.content.size > 0;
466
+ b && k && M && (d = Math.max(0, d - 1)), r.replaceWith(d, u, m);
467
+ }
468
+ n.updateSelection && ln(r, r.steps.length - 1, -1), n.applyInputRules && r.setMeta("applyInputRules", { from: d, text: m }), n.applyPasteRules && r.setMeta("applyPasteRules", { from: d, text: m });
469
+ }
470
+ return !0;
471
+ }, fn = () => ({ state: e, dispatch: t }) => ye(e, t), pn = () => ({ state: e, dispatch: t }) => be(e, t), hn = () => ({ state: e, dispatch: t }) => we(e, t), mn = () => ({ state: e, dispatch: t }) => ke(e, t), gn = () => ({ state: e, dispatch: t, tr: n }) => {
472
+ try {
473
+ const r = It(e.doc, e.selection.$from.pos, -1);
474
+ return r == null ? !1 : (n.join(r, 2), t && t(n), !0);
475
+ } catch {
476
+ return !1;
477
+ }
478
+ }, vn = () => ({ state: e, dispatch: t, tr: n }) => {
479
+ try {
480
+ const r = It(e.doc, e.selection.$from.pos, 1);
481
+ return r == null ? !1 : (n.join(r, 2), t && t(n), !0);
482
+ } catch {
483
+ return !1;
484
+ }
485
+ }, yn = () => ({ state: e, dispatch: t }) => Me(e, t), bn = () => ({ state: e, dispatch: t }) => Se(e, t);
486
+ function Ft() {
487
+ return typeof navigator < "u" ? /Mac/.test(navigator.platform) : !1;
488
+ }
489
+ function wn(e) {
490
+ const t = e.split(/-(?!$)/);
491
+ let n = t[t.length - 1];
492
+ n === "Space" && (n = " ");
493
+ let r, s, o, i;
494
+ for (let a = 0; a < t.length - 1; a += 1) {
495
+ const c = t[a];
496
+ if (/^(cmd|meta|m)$/i.test(c))
497
+ i = !0;
498
+ else if (/^a(lt)?$/i.test(c))
499
+ r = !0;
500
+ else if (/^(c|ctrl|control)$/i.test(c))
501
+ s = !0;
502
+ else if (/^s(hift)?$/i.test(c))
503
+ o = !0;
504
+ else if (/^mod$/i.test(c))
505
+ yt() || Ft() ? i = !0 : s = !0;
506
+ else
507
+ throw new Error(`Unrecognized modifier name: ${c}`);
508
+ }
509
+ return r && (n = `Alt-${n}`), s && (n = `Ctrl-${n}`), i && (n = `Meta-${n}`), o && (n = `Shift-${n}`), n;
510
+ }
511
+ var kn = (e) => ({ editor: t, view: n, tr: r, dispatch: s }) => {
512
+ const o = wn(e).split(/-(?!$)/), i = o.find((l) => !["Alt", "Ctrl", "Meta", "Shift"].includes(l)), a = new KeyboardEvent("keydown", {
513
+ key: i === "Space" ? " " : i,
514
+ altKey: o.includes("Alt"),
515
+ ctrlKey: o.includes("Ctrl"),
516
+ metaKey: o.includes("Meta"),
517
+ shiftKey: o.includes("Shift"),
518
+ bubbles: !0,
519
+ cancelable: !0
520
+ }), c = t.captureTransaction(() => {
521
+ n.someProp("handleKeyDown", (l) => l(n, a));
522
+ });
523
+ return c?.steps.forEach((l) => {
524
+ const d = l.map(r.mapping);
525
+ d && s && r.maybeStep(d);
526
+ }), !0;
527
+ };
528
+ function H(e, t, n = {}) {
529
+ const { from: r, to: s, empty: o } = e.selection, i = t ? T(t, e.schema) : null, a = [];
530
+ e.doc.nodesBetween(r, s, (u, f) => {
531
+ if (u.isText)
532
+ return;
533
+ const p = Math.max(r, f), h = Math.min(s, f + u.nodeSize);
534
+ a.push({
535
+ node: u,
536
+ from: p,
537
+ to: h
538
+ });
539
+ });
540
+ const c = s - r, l = a.filter((u) => i ? i.name === u.node.type.name : !0).filter((u) => Z(u.node.attrs, n, { strict: !1 }));
541
+ return o ? !!l.length : l.reduce((u, f) => u + f.to - f.from, 0) >= c;
542
+ }
543
+ var Mn = (e, t = {}) => ({ state: n, dispatch: r }) => {
544
+ const s = T(e, n.schema);
545
+ return H(n, s, t) ? xe(n, r) : !1;
546
+ }, Sn = () => ({ state: e, dispatch: t }) => Ee(e, t), xn = (e) => ({ state: t, dispatch: n }) => {
547
+ const r = T(e, t.schema);
548
+ return Oe(r)(t, n);
549
+ }, En = () => ({ state: e, dispatch: t }) => Te(e, t);
550
+ function nt(e, t) {
551
+ return t.nodes[e] ? "node" : t.marks[e] ? "mark" : null;
552
+ }
553
+ function Ct(e, t) {
554
+ const n = typeof t == "string" ? [t] : t;
555
+ return Object.keys(e).reduce((r, s) => (n.includes(s) || (r[s] = e[s]), r), {});
556
+ }
557
+ var Tn = (e, t) => ({ tr: n, state: r, dispatch: s }) => {
558
+ let o = null, i = null;
559
+ const a = nt(
560
+ typeof e == "string" ? e : e.name,
561
+ r.schema
562
+ );
563
+ return a ? (a === "node" && (o = T(e, r.schema)), a === "mark" && (i = R(e, r.schema)), s && n.selection.ranges.forEach((c) => {
564
+ r.doc.nodesBetween(c.$from.pos, c.$to.pos, (l, d) => {
565
+ o && o === l.type && n.setNodeMarkup(d, void 0, Ct(l.attrs, t)), i && l.marks.length && l.marks.forEach((u) => {
566
+ i === u.type && n.addMark(d, d + l.nodeSize, i.create(Ct(u.attrs, t)));
567
+ });
568
+ });
569
+ }), !0) : !1;
570
+ }, An = () => ({ tr: e, dispatch: t }) => (t && e.scrollIntoView(), !0), Cn = () => ({ tr: e, dispatch: t }) => {
571
+ if (t) {
572
+ const n = new Ie(e.doc);
573
+ e.setSelection(n);
574
+ }
575
+ return !0;
576
+ }, Pn = () => ({ state: e, dispatch: t }) => Ae(e, t), $n = () => ({ state: e, dispatch: t }) => Ce(e, t), Nn = () => ({ state: e, dispatch: t }) => Pe(e, t), Rn = () => ({ state: e, dispatch: t }) => $e(e, t), zn = () => ({ state: e, dispatch: t }) => Ne(e, t);
577
+ function ft(e, t, n = {}, r = {}) {
578
+ return F(e, t, {
579
+ slice: !1,
580
+ parseOptions: n,
581
+ errorOnInvalidContent: r.errorOnInvalidContent
582
+ });
583
+ }
584
+ var In = (e, { errorOnInvalidContent: t, emitUpdate: n = !0, parseOptions: r = {} } = {}) => ({ editor: s, tr: o, dispatch: i, commands: a }) => {
585
+ const { doc: c } = o;
586
+ if (r.preserveWhitespace !== "full") {
587
+ const l = ft(e, s.schema, r, {
588
+ errorOnInvalidContent: t ?? s.options.enableContentCheck
589
+ });
590
+ return i && o.replaceWith(0, c.content.size, l).setMeta("preventUpdate", !n), !0;
591
+ }
592
+ return i && o.setMeta("preventUpdate", !n), a.insertContentAt({ from: 0, to: c.content.size }, e, {
593
+ parseOptions: r,
594
+ errorOnInvalidContent: t ?? s.options.enableContentCheck
595
+ });
596
+ };
597
+ function Ht(e, t) {
598
+ const n = R(t, e.schema), { from: r, to: s, empty: o } = e.selection, i = [];
599
+ o ? (e.storedMarks && i.push(...e.storedMarks), i.push(...e.selection.$head.marks())) : e.doc.nodesBetween(r, s, (c) => {
600
+ i.push(...c.marks);
601
+ });
602
+ const a = i.find((c) => c.type.name === n.name);
603
+ return a ? { ...a.attrs } : {};
604
+ }
605
+ function _n(e, t) {
606
+ const n = new de(e);
607
+ return t.forEach((r) => {
608
+ r.steps.forEach((s) => {
609
+ n.step(s);
610
+ });
611
+ }), n;
612
+ }
613
+ function Bn(e) {
614
+ for (let t = 0; t < e.edgeCount; t += 1) {
615
+ const { type: n } = e.edge(t);
616
+ if (n.isTextblock && !n.hasRequiredAttrs())
617
+ return n;
618
+ }
619
+ return null;
620
+ }
621
+ function Jr(e, t, n) {
622
+ const r = [];
623
+ return e.nodesBetween(t.from, t.to, (s, o) => {
624
+ n(s) && r.push({
625
+ node: s,
626
+ pos: o
627
+ });
628
+ }), r;
629
+ }
630
+ function jn(e, t) {
631
+ for (let n = e.depth; n > 0; n -= 1) {
632
+ const r = e.node(n);
633
+ if (t(r))
634
+ return {
635
+ pos: n > 0 ? e.before(n) : 0,
636
+ start: e.start(n),
637
+ depth: n,
638
+ node: r
639
+ };
640
+ }
641
+ }
642
+ function rt(e) {
643
+ return (t) => jn(t.$from, e);
644
+ }
645
+ function y(e, t, n) {
646
+ return e.config[t] === void 0 && e.parent ? y(e.parent, t, n) : typeof e.config[t] == "function" ? e.config[t].bind({
647
+ ...n,
648
+ parent: e.parent ? y(e.parent, t, n) : null
649
+ }) : e.config[t];
650
+ }
651
+ function bt(e) {
652
+ return e.map((t) => {
653
+ const n = {
654
+ name: t.name,
655
+ options: t.options,
656
+ storage: t.storage
657
+ }, r = y(t, "addExtensions", n);
658
+ return r ? [t, ...bt(r())] : t;
659
+ }).flat(10);
660
+ }
661
+ function wt(e, t) {
662
+ const n = _e.fromSchema(t).serializeFragment(e), s = document.implementation.createHTMLDocument().createElement("div");
663
+ return s.appendChild(n), s.innerHTML;
664
+ }
665
+ function Vt(e) {
666
+ return typeof e == "function";
667
+ }
668
+ function S(e, t = void 0, ...n) {
669
+ return Vt(e) ? t ? e.bind(t)(...n) : e(...n) : e;
670
+ }
671
+ function On(e = {}) {
672
+ return Object.keys(e).length === 0 && e.constructor === Object;
673
+ }
674
+ function V(e) {
675
+ const t = e.filter((s) => s.type === "extension"), n = e.filter((s) => s.type === "node"), r = e.filter((s) => s.type === "mark");
676
+ return {
677
+ baseExtensions: t,
678
+ nodeExtensions: n,
679
+ markExtensions: r
680
+ };
681
+ }
682
+ function Wt(e) {
683
+ const t = [], { nodeExtensions: n, markExtensions: r } = V(e), s = [...n, ...r], o = {
684
+ default: null,
685
+ validate: void 0,
686
+ rendered: !0,
687
+ renderHTML: null,
688
+ parseHTML: null,
689
+ keepOnSplit: !0,
690
+ isRequired: !1
691
+ };
692
+ return e.forEach((i) => {
693
+ const a = {
694
+ name: i.name,
695
+ options: i.options,
696
+ storage: i.storage,
697
+ extensions: s
698
+ }, c = y(
699
+ i,
700
+ "addGlobalAttributes",
701
+ a
702
+ );
703
+ if (!c)
704
+ return;
705
+ c().forEach((d) => {
706
+ d.types.forEach((u) => {
707
+ Object.entries(d.attributes).forEach(([f, p]) => {
708
+ t.push({
709
+ type: u,
710
+ name: f,
711
+ attribute: {
712
+ ...o,
713
+ ...p
714
+ }
715
+ });
716
+ });
717
+ });
718
+ });
719
+ }), s.forEach((i) => {
720
+ const a = {
721
+ name: i.name,
722
+ options: i.options,
723
+ storage: i.storage
724
+ }, c = y(
725
+ i,
726
+ "addAttributes",
727
+ a
728
+ );
729
+ if (!c)
730
+ return;
731
+ const l = c();
732
+ Object.entries(l).forEach(([d, u]) => {
733
+ const f = {
734
+ ...o,
735
+ ...u
736
+ };
737
+ typeof f?.default == "function" && (f.default = f.default()), f?.isRequired && f?.default === void 0 && delete f.default, t.push({
738
+ type: i.name,
739
+ name: d,
740
+ attribute: f
741
+ });
742
+ });
743
+ }), t;
744
+ }
745
+ function Dn(...e) {
746
+ return e.filter((t) => !!t).reduce((t, n) => {
747
+ const r = { ...t };
748
+ return Object.entries(n).forEach(([s, o]) => {
749
+ if (!r[s]) {
750
+ r[s] = o;
751
+ return;
752
+ }
753
+ if (s === "class") {
754
+ const a = o ? String(o).split(" ") : [], c = r[s] ? r[s].split(" ") : [], l = a.filter((d) => !c.includes(d));
755
+ r[s] = [...c, ...l].join(" ");
756
+ } else if (s === "style") {
757
+ const a = o ? o.split(";").map((d) => d.trim()).filter(Boolean) : [], c = r[s] ? r[s].split(";").map((d) => d.trim()).filter(Boolean) : [], l = /* @__PURE__ */ new Map();
758
+ c.forEach((d) => {
759
+ const [u, f] = d.split(":").map((p) => p.trim());
760
+ l.set(u, f);
761
+ }), a.forEach((d) => {
762
+ const [u, f] = d.split(":").map((p) => p.trim());
763
+ l.set(u, f);
764
+ }), r[s] = Array.from(l.entries()).map(([d, u]) => `${d}: ${u}`).join("; ");
765
+ } else
766
+ r[s] = o;
767
+ }), r;
768
+ }, {});
769
+ }
770
+ function Q(e, t) {
771
+ return t.filter((n) => n.type === e.type.name).filter((n) => n.attribute.rendered).map((n) => n.attribute.renderHTML ? n.attribute.renderHTML(e.attrs) || {} : {
772
+ [n.name]: e.attrs[n.name]
773
+ }).reduce((n, r) => Dn(n, r), {});
774
+ }
775
+ function Ln(e) {
776
+ return typeof e != "string" ? e : e.match(/^[+-]?(?:\d*\.)?\d+$/) ? Number(e) : e === "true" ? !0 : e === "false" ? !1 : e;
777
+ }
778
+ function Pt(e, t) {
779
+ return "style" in e ? e : {
780
+ ...e,
781
+ getAttrs: (n) => {
782
+ const r = e.getAttrs ? e.getAttrs(n) : e.attrs;
783
+ if (r === !1)
784
+ return !1;
785
+ const s = t.reduce((o, i) => {
786
+ const a = i.attribute.parseHTML ? i.attribute.parseHTML(n) : Ln(n.getAttribute(i.name));
787
+ return a == null ? o : {
788
+ ...o,
789
+ [i.name]: a
790
+ };
791
+ }, {});
792
+ return { ...r, ...s };
793
+ }
794
+ };
795
+ }
796
+ function $t(e) {
797
+ return Object.fromEntries(
798
+ // @ts-ignore
799
+ Object.entries(e).filter(([t, n]) => t === "attrs" && On(n) ? !1 : n != null)
800
+ );
801
+ }
802
+ function Fn(e, t) {
803
+ var n;
804
+ const r = Wt(e), { nodeExtensions: s, markExtensions: o } = V(e), i = (n = s.find((l) => y(l, "topNode"))) == null ? void 0 : n.name, a = Object.fromEntries(
805
+ s.map((l) => {
806
+ const d = r.filter((v) => v.type === l.name), u = {
807
+ name: l.name,
808
+ options: l.options,
809
+ storage: l.storage,
810
+ editor: t
811
+ }, f = e.reduce((v, b) => {
812
+ const k = y(b, "extendNodeSchema", u);
813
+ return {
814
+ ...v,
815
+ ...k ? k(l) : {}
816
+ };
817
+ }, {}), p = $t({
818
+ ...f,
819
+ content: S(y(l, "content", u)),
820
+ marks: S(y(l, "marks", u)),
821
+ group: S(y(l, "group", u)),
822
+ inline: S(y(l, "inline", u)),
823
+ atom: S(y(l, "atom", u)),
824
+ selectable: S(y(l, "selectable", u)),
825
+ draggable: S(y(l, "draggable", u)),
826
+ code: S(y(l, "code", u)),
827
+ whitespace: S(y(l, "whitespace", u)),
828
+ linebreakReplacement: S(
829
+ y(l, "linebreakReplacement", u)
830
+ ),
831
+ defining: S(y(l, "defining", u)),
832
+ isolating: S(y(l, "isolating", u)),
833
+ attrs: Object.fromEntries(
834
+ d.map((v) => {
835
+ var b, k;
836
+ return [
837
+ v.name,
838
+ { default: (b = v?.attribute) == null ? void 0 : b.default, validate: (k = v?.attribute) == null ? void 0 : k.validate }
839
+ ];
840
+ })
841
+ )
842
+ }), h = S(y(l, "parseHTML", u));
843
+ h && (p.parseDOM = h.map(
844
+ (v) => Pt(v, d)
845
+ ));
846
+ const m = y(l, "renderHTML", u);
847
+ m && (p.toDOM = (v) => m({
848
+ node: v,
849
+ HTMLAttributes: Q(v, d)
850
+ }));
851
+ const g = y(l, "renderText", u);
852
+ return g && (p.toText = g), [l.name, p];
853
+ })
854
+ ), c = Object.fromEntries(
855
+ o.map((l) => {
856
+ const d = r.filter((g) => g.type === l.name), u = {
857
+ name: l.name,
858
+ options: l.options,
859
+ storage: l.storage,
860
+ editor: t
861
+ }, f = e.reduce((g, v) => {
862
+ const b = y(v, "extendMarkSchema", u);
863
+ return {
864
+ ...g,
865
+ ...b ? b(l) : {}
866
+ };
867
+ }, {}), p = $t({
868
+ ...f,
869
+ inclusive: S(y(l, "inclusive", u)),
870
+ excludes: S(y(l, "excludes", u)),
871
+ group: S(y(l, "group", u)),
872
+ spanning: S(y(l, "spanning", u)),
873
+ code: S(y(l, "code", u)),
874
+ attrs: Object.fromEntries(
875
+ d.map((g) => {
876
+ var v, b;
877
+ return [
878
+ g.name,
879
+ { default: (v = g?.attribute) == null ? void 0 : v.default, validate: (b = g?.attribute) == null ? void 0 : b.validate }
880
+ ];
881
+ })
882
+ )
883
+ }), h = S(y(l, "parseHTML", u));
884
+ h && (p.parseDOM = h.map(
885
+ (g) => Pt(g, d)
886
+ ));
887
+ const m = y(l, "renderHTML", u);
888
+ return m && (p.toDOM = (g) => m({
889
+ mark: g,
890
+ HTMLAttributes: Q(g, d)
891
+ })), [l.name, p];
892
+ })
893
+ );
894
+ return new _t({
895
+ topNode: i,
896
+ nodes: a,
897
+ marks: c
898
+ });
899
+ }
900
+ function Hn(e) {
901
+ const t = e.filter((n, r) => e.indexOf(n) !== r);
902
+ return Array.from(new Set(t));
903
+ }
904
+ function kt(e) {
905
+ return e.sort((n, r) => {
906
+ const s = y(n, "priority") || 100, o = y(r, "priority") || 100;
907
+ return s > o ? -1 : s < o ? 1 : 0;
908
+ });
909
+ }
910
+ function Ut(e) {
911
+ const t = kt(bt(e)), n = Hn(t.map((r) => r.name));
912
+ return n.length && console.warn(
913
+ `[tiptap warn]: Duplicate extension names found: [${n.map((r) => `'${r}'`).join(", ")}]. This can lead to issues.`
914
+ ), t;
915
+ }
916
+ function Kt(e, t, n) {
917
+ const { from: r, to: s } = t, { blockSeparator: o = `
918
+
919
+ `, textSerializers: i = {} } = n || {};
920
+ let a = "";
921
+ return e.nodesBetween(r, s, (c, l, d, u) => {
922
+ var f;
923
+ c.isBlock && l > r && (a += o);
924
+ const p = i?.[c.type.name];
925
+ if (p)
926
+ return d && (a += p({
927
+ node: c,
928
+ pos: l,
929
+ parent: d,
930
+ index: u,
931
+ range: t
932
+ })), !1;
933
+ c.isText && (a += (f = c?.text) == null ? void 0 : f.slice(Math.max(r, l) - l, s - l));
934
+ }), a;
935
+ }
936
+ function Vn(e, t) {
937
+ const n = {
938
+ from: 0,
939
+ to: e.content.size
940
+ };
941
+ return Kt(e, n, t);
942
+ }
943
+ function qt(e) {
944
+ return Object.fromEntries(
945
+ Object.entries(e.nodes).filter(([, t]) => t.spec.toText).map(([t, n]) => [t, n.spec.toText])
946
+ );
947
+ }
948
+ function Wn(e, t) {
949
+ const n = T(t, e.schema), { from: r, to: s } = e.selection, o = [];
950
+ e.doc.nodesBetween(r, s, (a) => {
951
+ o.push(a);
952
+ });
953
+ const i = o.reverse().find((a) => a.type.name === n.name);
954
+ return i ? { ...i.attrs } : {};
955
+ }
956
+ function Un(e, t) {
957
+ const n = nt(
958
+ typeof t == "string" ? t : t.name,
959
+ e.schema
960
+ );
961
+ return n === "node" ? Wn(e, t) : n === "mark" ? Ht(e, t) : {};
962
+ }
963
+ function Kn(e, t = JSON.stringify) {
964
+ const n = {};
965
+ return e.filter((r) => {
966
+ const s = t(r);
967
+ return Object.prototype.hasOwnProperty.call(n, s) ? !1 : n[s] = !0;
968
+ });
969
+ }
970
+ function qn(e) {
971
+ const t = Kn(e);
972
+ return t.length === 1 ? t : t.filter((n, r) => !t.filter((o, i) => i !== r).some((o) => n.oldRange.from >= o.oldRange.from && n.oldRange.to <= o.oldRange.to && n.newRange.from >= o.newRange.from && n.newRange.to <= o.newRange.to));
973
+ }
974
+ function Jn(e) {
975
+ const { mapping: t, steps: n } = e, r = [];
976
+ return t.maps.forEach((s, o) => {
977
+ const i = [];
978
+ if (s.ranges.length)
979
+ s.forEach((a, c) => {
980
+ i.push({ from: a, to: c });
981
+ });
982
+ else {
983
+ const { from: a, to: c } = n[o];
984
+ if (a === void 0 || c === void 0)
985
+ return;
986
+ i.push({ from: a, to: c });
987
+ }
988
+ i.forEach(({ from: a, to: c }) => {
989
+ const l = t.slice(o).map(a, -1), d = t.slice(o).map(c), u = t.invert().map(l, -1), f = t.invert().map(d);
990
+ r.push({
991
+ oldRange: {
992
+ from: u,
993
+ to: f
994
+ },
995
+ newRange: {
996
+ from: l,
997
+ to: d
998
+ }
999
+ });
1000
+ });
1001
+ }), qn(r);
1002
+ }
1003
+ function Jt(e, t, n) {
1004
+ const r = [];
1005
+ return e === t ? n.resolve(e).marks().forEach((s) => {
1006
+ const o = n.resolve(e), i = vt(o, s.type);
1007
+ i && r.push({
1008
+ mark: s,
1009
+ ...i
1010
+ });
1011
+ }) : n.nodesBetween(e, t, (s, o) => {
1012
+ !s || s?.nodeSize === void 0 || r.push(
1013
+ ...s.marks.map((i) => ({
1014
+ from: o,
1015
+ to: o + s.nodeSize,
1016
+ mark: i
1017
+ }))
1018
+ );
1019
+ }), r;
1020
+ }
1021
+ var Xr = (e, t, n, r = 20) => {
1022
+ const s = e.doc.resolve(n);
1023
+ let o = r, i = null;
1024
+ for (; o > 0 && i === null; ) {
1025
+ const a = s.node(o);
1026
+ a?.type.name === t ? i = a : o -= 1;
1027
+ }
1028
+ return [i, o];
1029
+ };
1030
+ function lt(e, t) {
1031
+ return t.nodes[e] || t.marks[e] || null;
1032
+ }
1033
+ function Y(e, t, n) {
1034
+ return Object.fromEntries(
1035
+ Object.entries(n).filter(([r]) => {
1036
+ const s = e.find((o) => o.type === t && o.name === r);
1037
+ return s ? s.attribute.keepOnSplit : !1;
1038
+ })
1039
+ );
1040
+ }
1041
+ var Xn = (e, t = 500) => {
1042
+ let n = "";
1043
+ const r = e.parentOffset;
1044
+ return e.parent.nodesBetween(Math.max(0, r - t), r, (s, o, i, a) => {
1045
+ var c, l;
1046
+ const d = ((l = (c = s.type.spec).toText) == null ? void 0 : l.call(c, {
1047
+ node: s,
1048
+ pos: o,
1049
+ parent: i,
1050
+ index: a
1051
+ })) || s.textContent || "%leaf%";
1052
+ n += s.isAtom && !s.isText ? d : d.slice(0, Math.max(0, r - o));
1053
+ }), n;
1054
+ };
1055
+ function pt(e, t, n = {}) {
1056
+ const { empty: r, ranges: s } = e.selection, o = t ? R(t, e.schema) : null;
1057
+ if (r)
1058
+ return !!(e.storedMarks || e.selection.$from.marks()).filter((u) => o ? o.name === u.type.name : !0).find((u) => Z(u.attrs, n, { strict: !1 }));
1059
+ let i = 0;
1060
+ const a = [];
1061
+ if (s.forEach(({ $from: u, $to: f }) => {
1062
+ const p = u.pos, h = f.pos;
1063
+ e.doc.nodesBetween(p, h, (m, g) => {
1064
+ if (!m.isText && !m.marks.length)
1065
+ return;
1066
+ const v = Math.max(p, g), b = Math.min(h, g + m.nodeSize), k = b - v;
1067
+ i += k, a.push(
1068
+ ...m.marks.map((M) => ({
1069
+ mark: M,
1070
+ from: v,
1071
+ to: b
1072
+ }))
1073
+ );
1074
+ });
1075
+ }), i === 0)
1076
+ return !1;
1077
+ const c = a.filter((u) => o ? o.name === u.mark.type.name : !0).filter((u) => Z(u.mark.attrs, n, { strict: !1 })).reduce((u, f) => u + f.to - f.from, 0), l = a.filter((u) => o ? u.mark.type !== o && u.mark.type.excludes(o) : !0).reduce((u, f) => u + f.to - f.from, 0);
1078
+ return (c > 0 ? c + l : c) >= i;
1079
+ }
1080
+ function Yn(e, t, n = {}) {
1081
+ if (!t)
1082
+ return H(e, null, n) || pt(e, null, n);
1083
+ const r = nt(t, e.schema);
1084
+ return r === "node" ? H(e, t, n) : r === "mark" ? pt(e, t, n) : !1;
1085
+ }
1086
+ var Yr = (e, t) => {
1087
+ const { $from: n, $to: r, $anchor: s } = e.selection;
1088
+ if (t) {
1089
+ const o = rt((a) => a.type.name === t)(e.selection);
1090
+ if (!o)
1091
+ return !1;
1092
+ const i = e.doc.resolve(o.pos + 1);
1093
+ return s.pos + 1 === i.end();
1094
+ }
1095
+ return !(r.parentOffset < r.parent.nodeSize - 2 || n.pos !== r.pos);
1096
+ }, Zr = (e) => {
1097
+ const { $from: t, $to: n } = e.selection;
1098
+ return !(t.parentOffset > 0 || t.pos !== n.pos);
1099
+ };
1100
+ function Nt(e, t) {
1101
+ return Array.isArray(t) ? t.some((n) => (typeof n == "string" ? n : n.name) === e.name) : t;
1102
+ }
1103
+ function Rt(e, t) {
1104
+ const { nodeExtensions: n } = V(t), r = n.find((i) => i.name === e);
1105
+ if (!r)
1106
+ return !1;
1107
+ const s = {
1108
+ name: r.name,
1109
+ options: r.options,
1110
+ storage: r.storage
1111
+ }, o = S(y(r, "group", s));
1112
+ return typeof o != "string" ? !1 : o.split(" ").includes("list");
1113
+ }
1114
+ function Mt(e, {
1115
+ checkChildren: t = !0,
1116
+ ignoreWhitespace: n = !1
1117
+ } = {}) {
1118
+ var r;
1119
+ if (n) {
1120
+ if (e.type.name === "hardBreak")
1121
+ return !0;
1122
+ if (e.isText)
1123
+ return /^\s*$/m.test((r = e.text) != null ? r : "");
1124
+ }
1125
+ if (e.isText)
1126
+ return !e.text;
1127
+ if (e.isAtom || e.isLeaf)
1128
+ return !1;
1129
+ if (e.content.childCount === 0)
1130
+ return !0;
1131
+ if (t) {
1132
+ let s = !0;
1133
+ return e.content.forEach((o) => {
1134
+ s !== !1 && (Mt(o, { ignoreWhitespace: n, checkChildren: t }) || (s = !1));
1135
+ }), s;
1136
+ }
1137
+ return !1;
1138
+ }
1139
+ function Qr(e) {
1140
+ return e instanceof G;
1141
+ }
1142
+ function Zn(e, t, n) {
1143
+ var r;
1144
+ const { selection: s } = t;
1145
+ let o = null;
1146
+ if (Ot(s) && (o = s.$cursor), o) {
1147
+ const a = (r = e.storedMarks) != null ? r : o.marks();
1148
+ return o.parent.type.allowsMarkType(n) && (!!n.isInSet(a) || !a.some((l) => l.type.excludes(n)));
1149
+ }
1150
+ const { ranges: i } = s;
1151
+ return i.some(({ $from: a, $to: c }) => {
1152
+ let l = a.depth === 0 ? e.doc.inlineContent && e.doc.type.allowsMarkType(n) : !1;
1153
+ return e.doc.nodesBetween(a.pos, c.pos, (d, u, f) => {
1154
+ if (l)
1155
+ return !1;
1156
+ if (d.isInline) {
1157
+ const p = !f || f.type.allowsMarkType(n), h = !!n.isInSet(d.marks) || !d.marks.some((m) => m.type.excludes(n));
1158
+ l = p && h;
1159
+ }
1160
+ return !l;
1161
+ }), l;
1162
+ });
1163
+ }
1164
+ var Qn = (e, t = {}) => ({ tr: n, state: r, dispatch: s }) => {
1165
+ const { selection: o } = n, { empty: i, ranges: a } = o, c = R(e, r.schema);
1166
+ if (s)
1167
+ if (i) {
1168
+ const l = Ht(r, c);
1169
+ n.addStoredMark(
1170
+ c.create({
1171
+ ...l,
1172
+ ...t
1173
+ })
1174
+ );
1175
+ } else
1176
+ a.forEach((l) => {
1177
+ const d = l.$from.pos, u = l.$to.pos;
1178
+ r.doc.nodesBetween(d, u, (f, p) => {
1179
+ const h = Math.max(p, d), m = Math.min(p + f.nodeSize, u);
1180
+ f.marks.find((v) => v.type === c) ? f.marks.forEach((v) => {
1181
+ c === v.type && n.addMark(
1182
+ h,
1183
+ m,
1184
+ c.create({
1185
+ ...v.attrs,
1186
+ ...t
1187
+ })
1188
+ );
1189
+ }) : n.addMark(h, m, c.create(t));
1190
+ });
1191
+ });
1192
+ return Zn(r, n, c);
1193
+ }, Gn = (e, t) => ({ tr: n }) => (n.setMeta(e, t), !0), tr = (e, t = {}) => ({ state: n, dispatch: r, chain: s }) => {
1194
+ const o = T(e, n.schema);
1195
+ let i;
1196
+ return n.selection.$anchor.sameParent(n.selection.$head) && (i = n.selection.$anchor.parent.attrs), o.isTextblock ? s().command(({ commands: a }) => Tt(o, { ...i, ...t })(n) ? !0 : a.clearNodes()).command(({ state: a }) => Tt(o, { ...i, ...t })(a, r)).run() : (console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'), !1);
1197
+ }, er = (e) => ({ tr: t, dispatch: n }) => {
1198
+ if (n) {
1199
+ const { doc: r } = t, s = j(e, 0, r.content.size), o = G.create(r, s);
1200
+ t.setSelection(o);
1201
+ }
1202
+ return !0;
1203
+ }, nr = (e) => ({ tr: t, dispatch: n }) => {
1204
+ if (n) {
1205
+ const { doc: r } = t, { from: s, to: o } = typeof e == "number" ? { from: e, to: e } : e, i = P.atStart(r).from, a = P.atEnd(r).to, c = j(s, i, a), l = j(o, i, a), d = P.create(r, c, l);
1206
+ t.setSelection(d);
1207
+ }
1208
+ return !0;
1209
+ }, rr = (e) => ({ state: t, dispatch: n }) => {
1210
+ const r = T(e, t.schema);
1211
+ return De(r)(t, n);
1212
+ };
1213
+ function zt(e, t) {
1214
+ const n = e.storedMarks || e.selection.$to.parentOffset && e.selection.$from.marks();
1215
+ if (n) {
1216
+ const r = n.filter((s) => t?.includes(s.type.name));
1217
+ e.tr.ensureMarks(r);
1218
+ }
1219
+ }
1220
+ var sr = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor: s }) => {
1221
+ const { selection: o, doc: i } = t, { $from: a, $to: c } = o, l = s.extensionManager.attributes, d = Y(l, a.node().type.name, a.node().attrs);
1222
+ if (o instanceof G && o.node.isBlock)
1223
+ return !a.parentOffset || !X(i, a.pos) ? !1 : (r && (e && zt(n, s.extensionManager.splittableMarks), t.split(a.pos).scrollIntoView()), !0);
1224
+ if (!a.parent.isBlock)
1225
+ return !1;
1226
+ const u = c.parentOffset === c.parent.content.size, f = a.depth === 0 ? void 0 : Bn(a.node(-1).contentMatchAt(a.indexAfter(-1)));
1227
+ let p = u && f ? [
1228
+ {
1229
+ type: f,
1230
+ attrs: d
1231
+ }
1232
+ ] : void 0, h = X(t.doc, t.mapping.map(a.pos), 1, p);
1233
+ if (!p && !h && X(t.doc, t.mapping.map(a.pos), 1, f ? [{ type: f }] : void 0) && (h = !0, p = f ? [
1234
+ {
1235
+ type: f,
1236
+ attrs: d
1237
+ }
1238
+ ] : void 0), r) {
1239
+ if (h && (o instanceof P && t.deleteSelection(), t.split(t.mapping.map(a.pos), 1, p), f && !u && !a.parentOffset && a.parent.type !== f)) {
1240
+ const m = t.mapping.map(a.before()), g = t.doc.resolve(m);
1241
+ a.node(-1).canReplaceWith(g.index(), g.index() + 1, f) && t.setNodeMarkup(t.mapping.map(a.before()), f);
1242
+ }
1243
+ e && zt(n, s.extensionManager.splittableMarks), t.scrollIntoView();
1244
+ }
1245
+ return h;
1246
+ }, or = (e, t = {}) => ({ tr: n, state: r, dispatch: s, editor: o }) => {
1247
+ var i;
1248
+ const a = T(e, r.schema), { $from: c, $to: l } = r.selection, d = r.selection.node;
1249
+ if (d && d.isBlock || c.depth < 2 || !c.sameParent(l))
1250
+ return !1;
1251
+ const u = c.node(-1);
1252
+ if (u.type !== a)
1253
+ return !1;
1254
+ const f = o.extensionManager.attributes;
1255
+ if (c.parent.content.size === 0 && c.node(-1).childCount === c.indexAfter(-1)) {
1256
+ if (c.depth === 2 || c.node(-3).type !== a || c.index(-2) !== c.node(-2).childCount - 1)
1257
+ return !1;
1258
+ if (s) {
1259
+ let v = _.empty;
1260
+ const b = c.index(-1) ? 1 : c.index(-2) ? 2 : 3;
1261
+ for (let A = c.depth - b; A >= c.depth - 3; A -= 1)
1262
+ v = _.from(c.node(A).copy(v));
1263
+ const k = (
1264
+ // eslint-disable-next-line no-nested-ternary
1265
+ c.indexAfter(-1) < c.node(-2).childCount ? 1 : c.indexAfter(-2) < c.node(-3).childCount ? 2 : 3
1266
+ ), M = {
1267
+ ...Y(f, c.node().type.name, c.node().attrs),
1268
+ ...t
1269
+ }, w = ((i = a.contentMatch.defaultType) == null ? void 0 : i.createAndFill(M)) || void 0;
1270
+ v = v.append(_.from(a.createAndFill(null, w) || void 0));
1271
+ const x = c.before(c.depth - (b - 1));
1272
+ n.replace(x, c.after(-k), new je(v, 4 - b, 0));
1273
+ let E = -1;
1274
+ n.doc.nodesBetween(x, n.doc.content.size, (A, C) => {
1275
+ if (E > -1)
1276
+ return !1;
1277
+ A.isTextblock && A.content.size === 0 && (E = C + 1);
1278
+ }), E > -1 && n.setSelection(P.near(n.doc.resolve(E))), n.scrollIntoView();
1279
+ }
1280
+ return !0;
1281
+ }
1282
+ const p = l.pos === c.end() ? u.contentMatchAt(0).defaultType : null, h = {
1283
+ ...Y(f, u.type.name, u.attrs),
1284
+ ...t
1285
+ }, m = {
1286
+ ...Y(f, c.node().type.name, c.node().attrs),
1287
+ ...t
1288
+ };
1289
+ n.delete(c.pos, l.pos);
1290
+ const g = p ? [
1291
+ { type: a, attrs: h },
1292
+ { type: p, attrs: m }
1293
+ ] : [{ type: a, attrs: h }];
1294
+ if (!X(n.doc, c.pos, 2))
1295
+ return !1;
1296
+ if (s) {
1297
+ const { selection: v, storedMarks: b } = r, { splittableMarks: k } = o.extensionManager, M = b || v.$to.parentOffset && v.$from.marks();
1298
+ if (n.split(c.pos, 2, g).scrollIntoView(), !M || !s)
1299
+ return !0;
1300
+ const w = M.filter((x) => k.includes(x.type.name));
1301
+ n.ensureMarks(w);
1302
+ }
1303
+ return !0;
1304
+ }, dt = (e, t) => {
1305
+ const n = rt((i) => i.type === t)(e.selection);
1306
+ if (!n)
1307
+ return !0;
1308
+ const r = e.doc.resolve(Math.max(0, n.pos - 1)).before(n.depth);
1309
+ if (r === void 0)
1310
+ return !0;
1311
+ const s = e.doc.nodeAt(r);
1312
+ return n.node.type === s?.type && ht(e.doc, n.pos) && e.join(n.pos), !0;
1313
+ }, ut = (e, t) => {
1314
+ const n = rt((i) => i.type === t)(e.selection);
1315
+ if (!n)
1316
+ return !0;
1317
+ const r = e.doc.resolve(n.start).after(n.depth);
1318
+ if (r === void 0)
1319
+ return !0;
1320
+ const s = e.doc.nodeAt(r);
1321
+ return n.node.type === s?.type && ht(e.doc, r) && e.join(r), !0;
1322
+ }, ir = (e, t, n, r = {}) => ({ editor: s, tr: o, state: i, dispatch: a, chain: c, commands: l, can: d }) => {
1323
+ const { extensions: u, splittableMarks: f } = s.extensionManager, p = T(e, i.schema), h = T(t, i.schema), { selection: m, storedMarks: g } = i, { $from: v, $to: b } = m, k = v.blockRange(b), M = g || m.$to.parentOffset && m.$from.marks();
1324
+ if (!k)
1325
+ return !1;
1326
+ const w = rt((x) => Rt(x.type.name, u))(m);
1327
+ if (k.depth >= 1 && w && k.depth - w.depth <= 1) {
1328
+ if (w.node.type === p)
1329
+ return l.liftListItem(h);
1330
+ if (Rt(w.node.type.name, u) && p.validContent(w.node.content) && a)
1331
+ return c().command(() => (o.setNodeMarkup(w.pos, p), !0)).command(() => dt(o, p)).command(() => ut(o, p)).run();
1332
+ }
1333
+ return !n || !M || !a ? c().command(() => d().wrapInList(p, r) ? !0 : l.clearNodes()).wrapInList(p, r).command(() => dt(o, p)).command(() => ut(o, p)).run() : c().command(() => {
1334
+ const x = d().wrapInList(p, r), E = M.filter((A) => f.includes(A.type.name));
1335
+ return o.ensureMarks(E), x ? !0 : l.clearNodes();
1336
+ }).wrapInList(p, r).command(() => dt(o, p)).command(() => ut(o, p)).run();
1337
+ }, ar = (e, t = {}, n = {}) => ({ state: r, commands: s }) => {
1338
+ const { extendEmptyMarkRange: o = !1 } = n, i = R(e, r.schema);
1339
+ return pt(r, i, t) ? s.unsetMark(i, { extendEmptyMarkRange: o }) : s.setMark(i, t);
1340
+ }, cr = (e, t, n = {}) => ({ state: r, commands: s }) => {
1341
+ const o = T(e, r.schema), i = T(t, r.schema), a = H(r, o, n);
1342
+ let c;
1343
+ return r.selection.$anchor.sameParent(r.selection.$head) && (c = r.selection.$anchor.parent.attrs), a ? s.setNode(i, c) : s.setNode(o, { ...c, ...n });
1344
+ }, lr = (e, t = {}) => ({ state: n, commands: r }) => {
1345
+ const s = T(e, n.schema);
1346
+ return H(n, s, t) ? r.lift(s) : r.wrapIn(s, t);
1347
+ }, dr = () => ({ state: e, dispatch: t }) => {
1348
+ const n = e.plugins;
1349
+ for (let r = 0; r < n.length; r += 1) {
1350
+ const s = n[r];
1351
+ let o;
1352
+ if (s.spec.isInputRules && (o = s.getState(e))) {
1353
+ if (t) {
1354
+ const i = e.tr, a = o.transform;
1355
+ for (let c = a.steps.length - 1; c >= 0; c -= 1)
1356
+ i.step(a.steps[c].invert(a.docs[c]));
1357
+ if (o.text) {
1358
+ const c = i.doc.resolve(o.from).marks();
1359
+ i.replaceWith(o.from, o.to, e.schema.text(o.text, c));
1360
+ } else
1361
+ i.delete(o.from, o.to);
1362
+ }
1363
+ return !0;
1364
+ }
1365
+ }
1366
+ return !1;
1367
+ }, ur = () => ({ tr: e, dispatch: t }) => {
1368
+ const { selection: n } = e, { empty: r, ranges: s } = n;
1369
+ return r || t && s.forEach((o) => {
1370
+ e.removeMark(o.$from.pos, o.$to.pos);
1371
+ }), !0;
1372
+ }, fr = (e, t = {}) => ({ tr: n, state: r, dispatch: s }) => {
1373
+ var o;
1374
+ const { extendEmptyMarkRange: i = !1 } = t, { selection: a } = n, c = R(e, r.schema), { $from: l, empty: d, ranges: u } = a;
1375
+ if (!s)
1376
+ return !0;
1377
+ if (d && i) {
1378
+ let { from: f, to: p } = a;
1379
+ const h = (o = l.marks().find((g) => g.type === c)) == null ? void 0 : o.attrs, m = vt(l, c, h);
1380
+ m && (f = m.from, p = m.to), n.removeMark(f, p, c);
1381
+ } else
1382
+ u.forEach((f) => {
1383
+ n.removeMark(f.$from.pos, f.$to.pos, c);
1384
+ });
1385
+ return n.removeStoredMark(c), !0;
1386
+ }, pr = (e, t = {}) => ({ tr: n, state: r, dispatch: s }) => {
1387
+ let o = null, i = null;
1388
+ const a = nt(
1389
+ typeof e == "string" ? e : e.name,
1390
+ r.schema
1391
+ );
1392
+ return a ? (a === "node" && (o = T(e, r.schema)), a === "mark" && (i = R(e, r.schema)), s && n.selection.ranges.forEach((c) => {
1393
+ const l = c.$from.pos, d = c.$to.pos;
1394
+ let u, f, p, h;
1395
+ n.selection.empty ? r.doc.nodesBetween(l, d, (m, g) => {
1396
+ o && o === m.type && (p = Math.max(g, l), h = Math.min(g + m.nodeSize, d), u = g, f = m);
1397
+ }) : r.doc.nodesBetween(l, d, (m, g) => {
1398
+ g < l && o && o === m.type && (p = Math.max(g, l), h = Math.min(g + m.nodeSize, d), u = g, f = m), g >= l && g <= d && (o && o === m.type && n.setNodeMarkup(g, void 0, {
1399
+ ...m.attrs,
1400
+ ...t
1401
+ }), i && m.marks.length && m.marks.forEach((v) => {
1402
+ if (i === v.type) {
1403
+ const b = Math.max(g, l), k = Math.min(g + m.nodeSize, d);
1404
+ n.addMark(
1405
+ b,
1406
+ k,
1407
+ i.create({
1408
+ ...v.attrs,
1409
+ ...t
1410
+ })
1411
+ );
1412
+ }
1413
+ }));
1414
+ }), f && (u !== void 0 && n.setNodeMarkup(u, void 0, {
1415
+ ...f.attrs,
1416
+ ...t
1417
+ }), i && f.marks.length && f.marks.forEach((m) => {
1418
+ i === m.type && n.addMark(
1419
+ p,
1420
+ h,
1421
+ i.create({
1422
+ ...m.attrs,
1423
+ ...t
1424
+ })
1425
+ );
1426
+ }));
1427
+ }), !0) : !1;
1428
+ }, hr = (e, t = {}) => ({ state: n, dispatch: r }) => {
1429
+ const s = T(e, n.schema);
1430
+ return Re(s, t)(n, r);
1431
+ }, mr = (e, t = {}) => ({ state: n, dispatch: r }) => {
1432
+ const s = T(e, n.schema);
1433
+ return Le(s, t)(n, r);
1434
+ }, gr = class {
1435
+ constructor() {
1436
+ this.callbacks = {};
1437
+ }
1438
+ on(e, t) {
1439
+ return this.callbacks[e] || (this.callbacks[e] = []), this.callbacks[e].push(t), this;
1440
+ }
1441
+ emit(e, ...t) {
1442
+ const n = this.callbacks[e];
1443
+ return n && n.forEach((r) => r.apply(this, t)), this;
1444
+ }
1445
+ off(e, t) {
1446
+ const n = this.callbacks[e];
1447
+ return n && (t ? this.callbacks[e] = n.filter((r) => r !== t) : delete this.callbacks[e]), this;
1448
+ }
1449
+ once(e, t) {
1450
+ const n = (...r) => {
1451
+ this.off(e, n), t.apply(this, r);
1452
+ };
1453
+ return this.on(e, n);
1454
+ }
1455
+ removeAllListeners() {
1456
+ this.callbacks = {};
1457
+ }
1458
+ }, st = class {
1459
+ constructor(e) {
1460
+ var t;
1461
+ this.find = e.find, this.handler = e.handler, this.undoable = (t = e.undoable) != null ? t : !0;
1462
+ }
1463
+ }, vr = (e, t) => {
1464
+ if (gt(t))
1465
+ return t.exec(e);
1466
+ const n = t(e);
1467
+ if (!n)
1468
+ return null;
1469
+ const r = [n.text];
1470
+ return r.index = n.index, r.input = e, r.data = n.data, n.replaceWith && (n.text.includes(n.replaceWith) || console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'), r.push(n.replaceWith)), r;
1471
+ };
1472
+ function K(e) {
1473
+ var t;
1474
+ const { editor: n, from: r, to: s, text: o, rules: i, plugin: a } = e, { view: c } = n;
1475
+ if (c.composing)
1476
+ return !1;
1477
+ const l = c.state.doc.resolve(r);
1478
+ if (
1479
+ // check for code node
1480
+ l.parent.type.spec.code || (t = l.nodeBefore || l.nodeAfter) != null && t.marks.find((f) => f.type.spec.code)
1481
+ )
1482
+ return !1;
1483
+ let d = !1;
1484
+ const u = Xn(l) + o;
1485
+ return i.forEach((f) => {
1486
+ if (d)
1487
+ return;
1488
+ const p = vr(u, f.find);
1489
+ if (!p)
1490
+ return;
1491
+ const h = c.state.tr, m = tt({
1492
+ state: c.state,
1493
+ transaction: h
1494
+ }), g = {
1495
+ from: r - (p[0].length - o.length),
1496
+ to: s
1497
+ }, { commands: v, chain: b, can: k } = new et({
1498
+ editor: n,
1499
+ state: m
1500
+ });
1501
+ f.handler({
1502
+ state: m,
1503
+ range: g,
1504
+ match: p,
1505
+ commands: v,
1506
+ chain: b,
1507
+ can: k
1508
+ }) === null || !h.steps.length || (f.undoable && h.setMeta(a, {
1509
+ transform: h,
1510
+ from: r,
1511
+ to: s,
1512
+ text: o
1513
+ }), c.dispatch(h), d = !0);
1514
+ }), d;
1515
+ }
1516
+ function yr(e) {
1517
+ const { editor: t, rules: n } = e, r = new N({
1518
+ state: {
1519
+ init() {
1520
+ return null;
1521
+ },
1522
+ apply(s, o, i) {
1523
+ const a = s.getMeta(r);
1524
+ if (a)
1525
+ return a;
1526
+ const c = s.getMeta("applyInputRules");
1527
+ return !!c && setTimeout(() => {
1528
+ let { text: d } = c;
1529
+ typeof d == "string" ? d = d : d = wt(_.from(d), i.schema);
1530
+ const { from: u } = c, f = u + d.length;
1531
+ K({
1532
+ editor: t,
1533
+ from: u,
1534
+ to: f,
1535
+ text: d,
1536
+ rules: n,
1537
+ plugin: r
1538
+ });
1539
+ }), s.selectionSet || s.docChanged ? null : o;
1540
+ }
1541
+ },
1542
+ props: {
1543
+ handleTextInput(s, o, i, a) {
1544
+ return K({
1545
+ editor: t,
1546
+ from: o,
1547
+ to: i,
1548
+ text: a,
1549
+ rules: n,
1550
+ plugin: r
1551
+ });
1552
+ },
1553
+ handleDOMEvents: {
1554
+ compositionend: (s) => (setTimeout(() => {
1555
+ const { $cursor: o } = s.state.selection;
1556
+ o && K({
1557
+ editor: t,
1558
+ from: o.pos,
1559
+ to: o.pos,
1560
+ text: "",
1561
+ rules: n,
1562
+ plugin: r
1563
+ });
1564
+ }), !1)
1565
+ },
1566
+ // add support for input rules to trigger on enter
1567
+ // this is useful for example for code blocks
1568
+ handleKeyDown(s, o) {
1569
+ if (o.key !== "Enter")
1570
+ return !1;
1571
+ const { $cursor: i } = s.state.selection;
1572
+ return i ? K({
1573
+ editor: t,
1574
+ from: i.pos,
1575
+ to: i.pos,
1576
+ text: `
1577
+ `,
1578
+ rules: n,
1579
+ plugin: r
1580
+ }) : !1;
1581
+ }
1582
+ },
1583
+ // @ts-ignore
1584
+ isInputRules: !0
1585
+ });
1586
+ return r;
1587
+ }
1588
+ function br(e) {
1589
+ return Object.prototype.toString.call(e).slice(8, -1);
1590
+ }
1591
+ function q(e) {
1592
+ return br(e) !== "Object" ? !1 : e.constructor === Object && Object.getPrototypeOf(e) === Object.prototype;
1593
+ }
1594
+ function Xt(e, t) {
1595
+ const n = { ...e };
1596
+ return q(e) && q(t) && Object.keys(t).forEach((r) => {
1597
+ q(t[r]) && q(e[r]) ? n[r] = Xt(e[r], t[r]) : n[r] = t[r];
1598
+ }), n;
1599
+ }
1600
+ var St = class {
1601
+ constructor(e = {}) {
1602
+ this.type = "extendable", this.parent = null, this.child = null, this.name = "", this.config = {
1603
+ name: this.name
1604
+ }, this.config = {
1605
+ ...this.config,
1606
+ ...e
1607
+ }, this.name = this.config.name;
1608
+ }
1609
+ get options() {
1610
+ return {
1611
+ ...S(
1612
+ y(this, "addOptions", {
1613
+ name: this.name
1614
+ })
1615
+ ) || {}
1616
+ };
1617
+ }
1618
+ get storage() {
1619
+ return {
1620
+ ...S(
1621
+ y(this, "addStorage", {
1622
+ name: this.name,
1623
+ options: this.options
1624
+ })
1625
+ ) || {}
1626
+ };
1627
+ }
1628
+ configure(e = {}) {
1629
+ const t = this.extend({
1630
+ ...this.config,
1631
+ addOptions: () => Xt(this.options, e)
1632
+ });
1633
+ return t.name = this.name, t.parent = this.parent, t;
1634
+ }
1635
+ extend(e = {}) {
1636
+ const t = new this.constructor({ ...this.config, ...e });
1637
+ return t.parent = this, this.child = t, t.name = "name" in e ? e.name : t.parent.name, t;
1638
+ }
1639
+ }, wr = class Yt extends St {
1640
+ constructor() {
1641
+ super(...arguments), this.type = "mark";
1642
+ }
1643
+ /**
1644
+ * Create a new Mark instance
1645
+ * @param config - Mark configuration object or a function that returns a configuration object
1646
+ */
1647
+ static create(t = {}) {
1648
+ const n = typeof t == "function" ? t() : t;
1649
+ return new Yt(n);
1650
+ }
1651
+ static handleExit({ editor: t, mark: n }) {
1652
+ const { tr: r } = t.state, s = t.state.selection.$from;
1653
+ if (s.pos === s.end()) {
1654
+ const i = s.marks();
1655
+ if (!!!i.find((l) => l?.type.name === n.name))
1656
+ return !1;
1657
+ const c = i.find((l) => l?.type.name === n.name);
1658
+ return c && r.removeStoredMark(c), r.insertText(" ", s.pos), t.view.dispatch(r), !0;
1659
+ }
1660
+ return !1;
1661
+ }
1662
+ configure(t) {
1663
+ return super.configure(t);
1664
+ }
1665
+ extend(t) {
1666
+ const n = typeof t == "function" ? t() : t;
1667
+ return super.extend(n);
1668
+ }
1669
+ };
1670
+ function kr(e) {
1671
+ return typeof e == "number";
1672
+ }
1673
+ var Mr = class {
1674
+ constructor(e) {
1675
+ this.find = e.find, this.handler = e.handler;
1676
+ }
1677
+ }, Sr = (e, t, n) => {
1678
+ if (gt(t))
1679
+ return [...e.matchAll(t)];
1680
+ const r = t(e, n);
1681
+ return r ? r.map((s) => {
1682
+ const o = [s.text];
1683
+ return o.index = s.index, o.input = e, o.data = s.data, s.replaceWith && (s.text.includes(s.replaceWith) || console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'), o.push(s.replaceWith)), o;
1684
+ }) : [];
1685
+ };
1686
+ function xr(e) {
1687
+ const { editor: t, state: n, from: r, to: s, rule: o, pasteEvent: i, dropEvent: a } = e, { commands: c, chain: l, can: d } = new et({
1688
+ editor: t,
1689
+ state: n
1690
+ }), u = [];
1691
+ return n.doc.nodesBetween(r, s, (p, h) => {
1692
+ var m, g, v, b, k;
1693
+ if ((g = (m = p.type) == null ? void 0 : m.spec) != null && g.code || !(p.isText || p.isTextblock || p.isInline))
1694
+ return;
1695
+ const M = (k = (b = (v = p.content) == null ? void 0 : v.size) != null ? b : p.nodeSize) != null ? k : 0, w = Math.max(r, h), x = Math.min(s, h + M);
1696
+ if (w >= x)
1697
+ return;
1698
+ const E = p.isText ? p.text || "" : p.textBetween(w - h, x - h, void 0, "");
1699
+ Sr(E, o.find, i).forEach((C) => {
1700
+ if (C.index === void 0)
1701
+ return;
1702
+ const B = w + C.index + 1, it = B + C[0].length, W = {
1703
+ from: n.tr.mapping.map(B),
1704
+ to: n.tr.mapping.map(it)
1705
+ }, at = o.handler({
1706
+ state: n,
1707
+ range: W,
1708
+ match: C,
1709
+ commands: c,
1710
+ chain: l,
1711
+ can: d,
1712
+ pasteEvent: i,
1713
+ dropEvent: a
1714
+ });
1715
+ u.push(at);
1716
+ });
1717
+ }), u.every((p) => p !== null);
1718
+ }
1719
+ var J = null, Er = (e) => {
1720
+ var t;
1721
+ const n = new ClipboardEvent("paste", {
1722
+ clipboardData: new DataTransfer()
1723
+ });
1724
+ return (t = n.clipboardData) == null || t.setData("text/html", e), n;
1725
+ };
1726
+ function Tr(e) {
1727
+ const { editor: t, rules: n } = e;
1728
+ let r = null, s = !1, o = !1, i = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, a;
1729
+ try {
1730
+ a = typeof DragEvent < "u" ? new DragEvent("drop") : null;
1731
+ } catch {
1732
+ a = null;
1733
+ }
1734
+ const c = ({
1735
+ state: d,
1736
+ from: u,
1737
+ to: f,
1738
+ rule: p,
1739
+ pasteEvt: h
1740
+ }) => {
1741
+ const m = d.tr, g = tt({
1742
+ state: d,
1743
+ transaction: m
1744
+ });
1745
+ if (!(!xr({
1746
+ editor: t,
1747
+ state: g,
1748
+ from: Math.max(u - 1, 0),
1749
+ to: f.b - 1,
1750
+ rule: p,
1751
+ pasteEvent: h,
1752
+ dropEvent: a
1753
+ }) || !m.steps.length)) {
1754
+ try {
1755
+ a = typeof DragEvent < "u" ? new DragEvent("drop") : null;
1756
+ } catch {
1757
+ a = null;
1758
+ }
1759
+ return i = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, m;
1760
+ }
1761
+ };
1762
+ return n.map((d) => new N({
1763
+ // we register a global drag handler to track the current drag source element
1764
+ view(u) {
1765
+ const f = (h) => {
1766
+ var m;
1767
+ r = (m = u.dom.parentElement) != null && m.contains(h.target) ? u.dom.parentElement : null, r && (J = t);
1768
+ }, p = () => {
1769
+ J && (J = null);
1770
+ };
1771
+ return window.addEventListener("dragstart", f), window.addEventListener("dragend", p), {
1772
+ destroy() {
1773
+ window.removeEventListener("dragstart", f), window.removeEventListener("dragend", p);
1774
+ }
1775
+ };
1776
+ },
1777
+ props: {
1778
+ handleDOMEvents: {
1779
+ drop: (u, f) => {
1780
+ if (o = r === u.dom.parentElement, a = f, !o) {
1781
+ const p = J;
1782
+ p?.isEditable && setTimeout(() => {
1783
+ const h = p.state.selection;
1784
+ h && p.commands.deleteRange({ from: h.from, to: h.to });
1785
+ }, 10);
1786
+ }
1787
+ return !1;
1788
+ },
1789
+ paste: (u, f) => {
1790
+ var p;
1791
+ const h = (p = f.clipboardData) == null ? void 0 : p.getData("text/html");
1792
+ return i = f, s = !!h?.includes("data-pm-slice"), !1;
1793
+ }
1794
+ }
1795
+ },
1796
+ appendTransaction: (u, f, p) => {
1797
+ const h = u[0], m = h.getMeta("uiEvent") === "paste" && !s, g = h.getMeta("uiEvent") === "drop" && !o, v = h.getMeta("applyPasteRules"), b = !!v;
1798
+ if (!m && !g && !b)
1799
+ return;
1800
+ if (b) {
1801
+ let { text: w } = v;
1802
+ typeof w == "string" ? w = w : w = wt(_.from(w), p.schema);
1803
+ const { from: x } = v, E = x + w.length, A = Er(w);
1804
+ return c({
1805
+ rule: d,
1806
+ state: p,
1807
+ from: x,
1808
+ to: { b: E },
1809
+ pasteEvt: A
1810
+ });
1811
+ }
1812
+ const k = f.doc.content.findDiffStart(p.doc.content), M = f.doc.content.findDiffEnd(p.doc.content);
1813
+ if (!(!kr(k) || !M || k === M.b))
1814
+ return c({
1815
+ rule: d,
1816
+ state: p,
1817
+ from: k,
1818
+ to: M,
1819
+ pasteEvt: i
1820
+ });
1821
+ }
1822
+ }));
1823
+ }
1824
+ var ot = class {
1825
+ constructor(e, t) {
1826
+ this.splittableMarks = [], this.editor = t, this.baseExtensions = e, this.extensions = Ut(e), this.schema = Fn(this.extensions, t), this.setupExtensions();
1827
+ }
1828
+ /**
1829
+ * Get all commands from the extensions.
1830
+ * @returns An object with all commands where the key is the command name and the value is the command function
1831
+ */
1832
+ get commands() {
1833
+ return this.extensions.reduce((e, t) => {
1834
+ const n = {
1835
+ name: t.name,
1836
+ options: t.options,
1837
+ storage: this.editor.extensionStorage[t.name],
1838
+ editor: this.editor,
1839
+ type: lt(t.name, this.schema)
1840
+ }, r = y(t, "addCommands", n);
1841
+ return r ? {
1842
+ ...e,
1843
+ ...r()
1844
+ } : e;
1845
+ }, {});
1846
+ }
1847
+ /**
1848
+ * Get all registered Prosemirror plugins from the extensions.
1849
+ * @returns An array of Prosemirror plugins
1850
+ */
1851
+ get plugins() {
1852
+ const { editor: e } = this;
1853
+ return kt([...this.extensions].reverse()).flatMap((r) => {
1854
+ const s = {
1855
+ name: r.name,
1856
+ options: r.options,
1857
+ storage: this.editor.extensionStorage[r.name],
1858
+ editor: e,
1859
+ type: lt(r.name, this.schema)
1860
+ }, o = [], i = y(
1861
+ r,
1862
+ "addKeyboardShortcuts",
1863
+ s
1864
+ );
1865
+ let a = {};
1866
+ if (r.type === "mark" && y(r, "exitable", s) && (a.ArrowRight = () => wr.handleExit({ editor: e, mark: r })), i) {
1867
+ const f = Object.fromEntries(
1868
+ Object.entries(i()).map(([p, h]) => [p, () => h({ editor: e })])
1869
+ );
1870
+ a = { ...a, ...f };
1871
+ }
1872
+ const c = He(a);
1873
+ o.push(c);
1874
+ const l = y(r, "addInputRules", s);
1875
+ if (Nt(r, e.options.enableInputRules) && l) {
1876
+ const f = l();
1877
+ if (f && f.length) {
1878
+ const p = yr({
1879
+ editor: e,
1880
+ rules: f
1881
+ }), h = Array.isArray(p) ? p : [p];
1882
+ o.push(...h);
1883
+ }
1884
+ }
1885
+ const d = y(r, "addPasteRules", s);
1886
+ if (Nt(r, e.options.enablePasteRules) && d) {
1887
+ const f = d();
1888
+ if (f && f.length) {
1889
+ const p = Tr({ editor: e, rules: f });
1890
+ o.push(...p);
1891
+ }
1892
+ }
1893
+ const u = y(
1894
+ r,
1895
+ "addProseMirrorPlugins",
1896
+ s
1897
+ );
1898
+ if (u) {
1899
+ const f = u();
1900
+ o.push(...f);
1901
+ }
1902
+ return o;
1903
+ });
1904
+ }
1905
+ /**
1906
+ * Get all attributes from the extensions.
1907
+ * @returns An array of attributes
1908
+ */
1909
+ get attributes() {
1910
+ return Wt(this.extensions);
1911
+ }
1912
+ /**
1913
+ * Get all node views from the extensions.
1914
+ * @returns An object with all node views where the key is the node name and the value is the node view function
1915
+ */
1916
+ get nodeViews() {
1917
+ const { editor: e } = this, { nodeExtensions: t } = V(this.extensions);
1918
+ return Object.fromEntries(
1919
+ t.filter((n) => !!y(n, "addNodeView")).map((n) => {
1920
+ const r = this.attributes.filter((c) => c.type === n.name), s = {
1921
+ name: n.name,
1922
+ options: n.options,
1923
+ storage: this.editor.extensionStorage[n.name],
1924
+ editor: e,
1925
+ type: T(n.name, this.schema)
1926
+ }, o = y(n, "addNodeView", s);
1927
+ if (!o)
1928
+ return [];
1929
+ const i = o();
1930
+ if (!i)
1931
+ return [];
1932
+ const a = (c, l, d, u, f) => {
1933
+ const p = Q(c, r);
1934
+ return i({
1935
+ // pass-through
1936
+ node: c,
1937
+ view: l,
1938
+ getPos: d,
1939
+ decorations: u,
1940
+ innerDecorations: f,
1941
+ // tiptap-specific
1942
+ editor: e,
1943
+ extension: n,
1944
+ HTMLAttributes: p
1945
+ });
1946
+ };
1947
+ return [n.name, a];
1948
+ })
1949
+ );
1950
+ }
1951
+ get markViews() {
1952
+ const { editor: e } = this, { markExtensions: t } = V(this.extensions);
1953
+ return Object.fromEntries(
1954
+ t.filter((n) => !!y(n, "addMarkView")).map((n) => {
1955
+ const r = this.attributes.filter((a) => a.type === n.name), s = {
1956
+ name: n.name,
1957
+ options: n.options,
1958
+ storage: this.editor.extensionStorage[n.name],
1959
+ editor: e,
1960
+ type: R(n.name, this.schema)
1961
+ }, o = y(n, "addMarkView", s);
1962
+ if (!o)
1963
+ return [];
1964
+ const i = (a, c, l) => {
1965
+ const d = Q(a, r);
1966
+ return o()({
1967
+ // pass-through
1968
+ mark: a,
1969
+ view: c,
1970
+ inline: l,
1971
+ // tiptap-specific
1972
+ editor: e,
1973
+ extension: n,
1974
+ HTMLAttributes: d,
1975
+ updateAttributes: (u) => {
1976
+ Lr(a, e, u);
1977
+ }
1978
+ });
1979
+ };
1980
+ return [n.name, i];
1981
+ })
1982
+ );
1983
+ }
1984
+ /**
1985
+ * Go through all extensions, create extension storages & setup marks
1986
+ * & bind editor event listener.
1987
+ */
1988
+ setupExtensions() {
1989
+ const e = this.extensions;
1990
+ this.editor.extensionStorage = Object.fromEntries(
1991
+ e.map((t) => [t.name, t.storage])
1992
+ ), e.forEach((t) => {
1993
+ var n;
1994
+ const r = {
1995
+ name: t.name,
1996
+ options: t.options,
1997
+ storage: this.editor.extensionStorage[t.name],
1998
+ editor: this.editor,
1999
+ type: lt(t.name, this.schema)
2000
+ };
2001
+ t.type === "mark" && ((n = S(y(t, "keepOnSplit", r))) == null || n) && this.splittableMarks.push(t.name);
2002
+ const s = y(t, "onBeforeCreate", r), o = y(t, "onCreate", r), i = y(t, "onUpdate", r), a = y(
2003
+ t,
2004
+ "onSelectionUpdate",
2005
+ r
2006
+ ), c = y(t, "onTransaction", r), l = y(t, "onFocus", r), d = y(t, "onBlur", r), u = y(t, "onDestroy", r);
2007
+ s && this.editor.on("beforeCreate", s), o && this.editor.on("create", o), i && this.editor.on("update", i), a && this.editor.on("selectionUpdate", a), c && this.editor.on("transaction", c), l && this.editor.on("focus", l), d && this.editor.on("blur", d), u && this.editor.on("destroy", u);
2008
+ });
2009
+ }
2010
+ };
2011
+ ot.resolve = Ut;
2012
+ ot.sort = kt;
2013
+ ot.flatten = bt;
2014
+ var Ar = {};
2015
+ mt(Ar, {
2016
+ ClipboardTextSerializer: () => Qt,
2017
+ Commands: () => Gt,
2018
+ Delete: () => te,
2019
+ Drop: () => ee,
2020
+ Editable: () => ne,
2021
+ FocusEvents: () => se,
2022
+ Keymap: () => oe,
2023
+ Paste: () => ie,
2024
+ Tabindex: () => ae,
2025
+ focusEventsPluginKey: () => re
2026
+ });
2027
+ var z = class Zt extends St {
2028
+ constructor() {
2029
+ super(...arguments), this.type = "extension";
2030
+ }
2031
+ /**
2032
+ * Create a new Extension instance
2033
+ * @param config - Extension configuration object or a function that returns a configuration object
2034
+ */
2035
+ static create(t = {}) {
2036
+ const n = typeof t == "function" ? t() : t;
2037
+ return new Zt(n);
2038
+ }
2039
+ configure(t) {
2040
+ return super.configure(t);
2041
+ }
2042
+ extend(t) {
2043
+ const n = typeof t == "function" ? t() : t;
2044
+ return super.extend(n);
2045
+ }
2046
+ }, Qt = z.create({
2047
+ name: "clipboardTextSerializer",
2048
+ addOptions() {
2049
+ return {
2050
+ blockSeparator: void 0
2051
+ };
2052
+ },
2053
+ addProseMirrorPlugins() {
2054
+ return [
2055
+ new N({
2056
+ key: new O("clipboardTextSerializer"),
2057
+ props: {
2058
+ clipboardTextSerializer: () => {
2059
+ const { editor: e } = this, { state: t, schema: n } = e, { doc: r, selection: s } = t, { ranges: o } = s, i = Math.min(...o.map((d) => d.$from.pos)), a = Math.max(...o.map((d) => d.$to.pos)), c = qt(n);
2060
+ return Kt(r, { from: i, to: a }, {
2061
+ ...this.options.blockSeparator !== void 0 ? { blockSeparator: this.options.blockSeparator } : {},
2062
+ textSerializers: c
2063
+ });
2064
+ }
2065
+ }
2066
+ })
2067
+ ];
2068
+ }
2069
+ }), Gt = z.create({
2070
+ name: "commands",
2071
+ addCommands() {
2072
+ return {
2073
+ ...Bt
2074
+ };
2075
+ }
2076
+ }), te = z.create({
2077
+ name: "delete",
2078
+ onUpdate({ transaction: e, appendedTransactions: t }) {
2079
+ var n, r, s;
2080
+ const o = () => {
2081
+ var i, a, c, l;
2082
+ if ((l = (c = (a = (i = this.editor.options.coreExtensionOptions) == null ? void 0 : i.delete) == null ? void 0 : a.filterTransaction) == null ? void 0 : c.call(a, e)) != null ? l : e.getMeta("y-sync$"))
2083
+ return;
2084
+ const d = _n(e.before, [e, ...t]);
2085
+ Jn(d).forEach((p) => {
2086
+ d.mapping.mapResult(p.oldRange.from).deletedAfter && d.mapping.mapResult(p.oldRange.to).deletedBefore && d.before.nodesBetween(p.oldRange.from, p.oldRange.to, (h, m) => {
2087
+ const g = m + h.nodeSize - 2, v = p.oldRange.from <= m && g <= p.oldRange.to;
2088
+ this.editor.emit("delete", {
2089
+ type: "node",
2090
+ node: h,
2091
+ from: m,
2092
+ to: g,
2093
+ newFrom: d.mapping.map(m),
2094
+ newTo: d.mapping.map(g),
2095
+ deletedRange: p.oldRange,
2096
+ newRange: p.newRange,
2097
+ partial: !v,
2098
+ editor: this.editor,
2099
+ transaction: e,
2100
+ combinedTransform: d
2101
+ });
2102
+ });
2103
+ });
2104
+ const f = d.mapping;
2105
+ d.steps.forEach((p, h) => {
2106
+ var m, g;
2107
+ if (p instanceof ue) {
2108
+ const v = f.slice(h).map(p.from, -1), b = f.slice(h).map(p.to), k = f.invert().map(v, -1), M = f.invert().map(b), w = (m = d.doc.nodeAt(v - 1)) == null ? void 0 : m.marks.some((E) => E.eq(p.mark)), x = (g = d.doc.nodeAt(b)) == null ? void 0 : g.marks.some((E) => E.eq(p.mark));
2109
+ this.editor.emit("delete", {
2110
+ type: "mark",
2111
+ mark: p.mark,
2112
+ from: p.from,
2113
+ to: p.to,
2114
+ deletedRange: {
2115
+ from: k,
2116
+ to: M
2117
+ },
2118
+ newRange: {
2119
+ from: v,
2120
+ to: b
2121
+ },
2122
+ partial: !!(x || w),
2123
+ editor: this.editor,
2124
+ transaction: e,
2125
+ combinedTransform: d
2126
+ });
2127
+ }
2128
+ });
2129
+ };
2130
+ (s = (r = (n = this.editor.options.coreExtensionOptions) == null ? void 0 : n.delete) == null ? void 0 : r.async) == null || s ? setTimeout(o, 0) : o();
2131
+ }
2132
+ }), ee = z.create({
2133
+ name: "drop",
2134
+ addProseMirrorPlugins() {
2135
+ return [
2136
+ new N({
2137
+ key: new O("tiptapDrop"),
2138
+ props: {
2139
+ handleDrop: (e, t, n, r) => {
2140
+ this.editor.emit("drop", {
2141
+ editor: this.editor,
2142
+ event: t,
2143
+ slice: n,
2144
+ moved: r
2145
+ });
2146
+ }
2147
+ }
2148
+ })
2149
+ ];
2150
+ }
2151
+ }), ne = z.create({
2152
+ name: "editable",
2153
+ addProseMirrorPlugins() {
2154
+ return [
2155
+ new N({
2156
+ key: new O("editable"),
2157
+ props: {
2158
+ editable: () => this.editor.options.editable
2159
+ }
2160
+ })
2161
+ ];
2162
+ }
2163
+ }), re = new O("focusEvents"), se = z.create({
2164
+ name: "focusEvents",
2165
+ addProseMirrorPlugins() {
2166
+ const { editor: e } = this;
2167
+ return [
2168
+ new N({
2169
+ key: re,
2170
+ props: {
2171
+ handleDOMEvents: {
2172
+ focus: (t, n) => {
2173
+ e.isFocused = !0;
2174
+ const r = e.state.tr.setMeta("focus", { event: n }).setMeta("addToHistory", !1);
2175
+ return t.dispatch(r), !1;
2176
+ },
2177
+ blur: (t, n) => {
2178
+ e.isFocused = !1;
2179
+ const r = e.state.tr.setMeta("blur", { event: n }).setMeta("addToHistory", !1);
2180
+ return t.dispatch(r), !1;
2181
+ }
2182
+ }
2183
+ }
2184
+ })
2185
+ ];
2186
+ }
2187
+ }), oe = z.create({
2188
+ name: "keymap",
2189
+ addKeyboardShortcuts() {
2190
+ const e = () => this.editor.commands.first(({ commands: i }) => [
2191
+ () => i.undoInputRule(),
2192
+ // maybe convert first text block node to default node
2193
+ () => i.command(({ tr: a }) => {
2194
+ const { selection: c, doc: l } = a, { empty: d, $anchor: u } = c, { pos: f, parent: p } = u, h = u.parent.isTextblock && f > 0 ? a.doc.resolve(f - 1) : u, m = h.parent.type.spec.isolating, g = u.pos - u.parentOffset, v = m && h.parent.childCount === 1 ? g === u.pos : L.atStart(l).from === f;
2195
+ return !d || !p.type.isTextblock || p.textContent.length || !v || v && u.parent.type.name === "paragraph" ? !1 : i.clearNodes();
2196
+ }),
2197
+ () => i.deleteSelection(),
2198
+ () => i.joinBackward(),
2199
+ () => i.selectNodeBackward()
2200
+ ]), t = () => this.editor.commands.first(({ commands: i }) => [
2201
+ () => i.deleteSelection(),
2202
+ () => i.deleteCurrentNode(),
2203
+ () => i.joinForward(),
2204
+ () => i.selectNodeForward()
2205
+ ]), r = {
2206
+ Enter: () => this.editor.commands.first(({ commands: i }) => [
2207
+ () => i.newlineInCode(),
2208
+ () => i.createParagraphNear(),
2209
+ () => i.liftEmptyBlock(),
2210
+ () => i.splitBlock()
2211
+ ]),
2212
+ "Mod-Enter": () => this.editor.commands.exitCode(),
2213
+ Backspace: e,
2214
+ "Mod-Backspace": e,
2215
+ "Shift-Backspace": e,
2216
+ Delete: t,
2217
+ "Mod-Delete": t,
2218
+ "Mod-a": () => this.editor.commands.selectAll()
2219
+ }, s = {
2220
+ ...r
2221
+ }, o = {
2222
+ ...r,
2223
+ "Ctrl-h": e,
2224
+ "Alt-Backspace": e,
2225
+ "Ctrl-d": t,
2226
+ "Ctrl-Alt-Backspace": t,
2227
+ "Alt-Delete": t,
2228
+ "Alt-d": t,
2229
+ "Ctrl-a": () => this.editor.commands.selectTextblockStart(),
2230
+ "Ctrl-e": () => this.editor.commands.selectTextblockEnd()
2231
+ };
2232
+ return yt() || Ft() ? o : s;
2233
+ },
2234
+ addProseMirrorPlugins() {
2235
+ return [
2236
+ // With this plugin we check if the whole document was selected and deleted.
2237
+ // In this case we will additionally call `clearNodes()` to convert e.g. a heading
2238
+ // to a paragraph if necessary.
2239
+ // This is an alternative to ProseMirror's `AllSelection`, which doesn’t work well
2240
+ // with many other commands.
2241
+ new N({
2242
+ key: new O("clearDocument"),
2243
+ appendTransaction: (e, t, n) => {
2244
+ if (e.some((m) => m.getMeta("composition")))
2245
+ return;
2246
+ const r = e.some((m) => m.docChanged) && !t.doc.eq(n.doc), s = e.some((m) => m.getMeta("preventClearDocument"));
2247
+ if (!r || s)
2248
+ return;
2249
+ const { empty: o, from: i, to: a } = t.selection, c = L.atStart(t.doc).from, l = L.atEnd(t.doc).to;
2250
+ if (o || !(i === c && a === l) || !Mt(n.doc))
2251
+ return;
2252
+ const f = n.tr, p = tt({
2253
+ state: n,
2254
+ transaction: f
2255
+ }), { commands: h } = new et({
2256
+ editor: this.editor,
2257
+ state: p
2258
+ });
2259
+ if (h.clearNodes(), !!f.steps.length)
2260
+ return f;
2261
+ }
2262
+ })
2263
+ ];
2264
+ }
2265
+ }), ie = z.create({
2266
+ name: "paste",
2267
+ addProseMirrorPlugins() {
2268
+ return [
2269
+ new N({
2270
+ key: new O("tiptapPaste"),
2271
+ props: {
2272
+ handlePaste: (e, t, n) => {
2273
+ this.editor.emit("paste", {
2274
+ editor: this.editor,
2275
+ event: t,
2276
+ slice: n
2277
+ });
2278
+ }
2279
+ }
2280
+ })
2281
+ ];
2282
+ }
2283
+ }), ae = z.create({
2284
+ name: "tabindex",
2285
+ addProseMirrorPlugins() {
2286
+ return [
2287
+ new N({
2288
+ key: new O("tabindex"),
2289
+ props: {
2290
+ attributes: () => this.editor.isEditable ? { tabindex: "0" } : {}
2291
+ }
2292
+ })
2293
+ ];
2294
+ }
2295
+ }), Cr = class D {
2296
+ constructor(t, n, r = !1, s = null) {
2297
+ this.currentNode = null, this.actualDepth = null, this.isBlock = r, this.resolvedPos = t, this.editor = n, this.currentNode = s;
2298
+ }
2299
+ get name() {
2300
+ return this.node.type.name;
2301
+ }
2302
+ get node() {
2303
+ return this.currentNode || this.resolvedPos.node();
2304
+ }
2305
+ get element() {
2306
+ return this.editor.view.domAtPos(this.pos).node;
2307
+ }
2308
+ get depth() {
2309
+ var t;
2310
+ return (t = this.actualDepth) != null ? t : this.resolvedPos.depth;
2311
+ }
2312
+ get pos() {
2313
+ return this.resolvedPos.pos;
2314
+ }
2315
+ get content() {
2316
+ return this.node.content;
2317
+ }
2318
+ set content(t) {
2319
+ let n = this.from, r = this.to;
2320
+ if (this.isBlock) {
2321
+ if (this.content.size === 0) {
2322
+ console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);
2323
+ return;
2324
+ }
2325
+ n = this.from + 1, r = this.to - 1;
2326
+ }
2327
+ this.editor.commands.insertContentAt({ from: n, to: r }, t);
2328
+ }
2329
+ get attributes() {
2330
+ return this.node.attrs;
2331
+ }
2332
+ get textContent() {
2333
+ return this.node.textContent;
2334
+ }
2335
+ get size() {
2336
+ return this.node.nodeSize;
2337
+ }
2338
+ get from() {
2339
+ return this.isBlock ? this.pos : this.resolvedPos.start(this.resolvedPos.depth);
2340
+ }
2341
+ get range() {
2342
+ return {
2343
+ from: this.from,
2344
+ to: this.to
2345
+ };
2346
+ }
2347
+ get to() {
2348
+ return this.isBlock ? this.pos + this.size : this.resolvedPos.end(this.resolvedPos.depth) + (this.node.isText ? 0 : 1);
2349
+ }
2350
+ get parent() {
2351
+ if (this.depth === 0)
2352
+ return null;
2353
+ const t = this.resolvedPos.start(this.resolvedPos.depth - 1), n = this.resolvedPos.doc.resolve(t);
2354
+ return new D(n, this.editor);
2355
+ }
2356
+ get before() {
2357
+ let t = this.resolvedPos.doc.resolve(this.from - (this.isBlock ? 1 : 2));
2358
+ return t.depth !== this.depth && (t = this.resolvedPos.doc.resolve(this.from - 3)), new D(t, this.editor);
2359
+ }
2360
+ get after() {
2361
+ let t = this.resolvedPos.doc.resolve(this.to + (this.isBlock ? 2 : 1));
2362
+ return t.depth !== this.depth && (t = this.resolvedPos.doc.resolve(this.to + 3)), new D(t, this.editor);
2363
+ }
2364
+ get children() {
2365
+ const t = [];
2366
+ return this.node.content.forEach((n, r) => {
2367
+ const s = n.isBlock && !n.isTextblock, o = n.isAtom && !n.isText, i = this.pos + r + (o ? 0 : 1);
2368
+ if (i < 0 || i > this.resolvedPos.doc.nodeSize - 2)
2369
+ return;
2370
+ const a = this.resolvedPos.doc.resolve(i);
2371
+ if (!s && a.depth <= this.depth)
2372
+ return;
2373
+ const c = new D(a, this.editor, s, s ? n : null);
2374
+ s && (c.actualDepth = this.depth + 1), t.push(new D(a, this.editor, s, s ? n : null));
2375
+ }), t;
2376
+ }
2377
+ get firstChild() {
2378
+ return this.children[0] || null;
2379
+ }
2380
+ get lastChild() {
2381
+ const t = this.children;
2382
+ return t[t.length - 1] || null;
2383
+ }
2384
+ closest(t, n = {}) {
2385
+ let r = null, s = this.parent;
2386
+ for (; s && !r; ) {
2387
+ if (s.node.type.name === t)
2388
+ if (Object.keys(n).length > 0) {
2389
+ const o = s.node.attrs, i = Object.keys(n);
2390
+ for (let a = 0; a < i.length; a += 1) {
2391
+ const c = i[a];
2392
+ if (o[c] !== n[c])
2393
+ break;
2394
+ }
2395
+ } else
2396
+ r = s;
2397
+ s = s.parent;
2398
+ }
2399
+ return r;
2400
+ }
2401
+ querySelector(t, n = {}) {
2402
+ return this.querySelectorAll(t, n, !0)[0] || null;
2403
+ }
2404
+ querySelectorAll(t, n = {}, r = !1) {
2405
+ let s = [];
2406
+ if (!this.children || this.children.length === 0)
2407
+ return s;
2408
+ const o = Object.keys(n);
2409
+ return this.children.forEach((i) => {
2410
+ r && s.length > 0 || (i.node.type.name === t && o.every((c) => n[c] === i.node.attrs[c]) && s.push(i), !(r && s.length > 0) && (s = s.concat(i.querySelectorAll(t, n, r))));
2411
+ }), s;
2412
+ }
2413
+ setAttribute(t) {
2414
+ const { tr: n } = this.editor.state;
2415
+ n.setNodeMarkup(this.from, void 0, {
2416
+ ...this.node.attrs,
2417
+ ...t
2418
+ }), this.editor.view.dispatch(n);
2419
+ }
2420
+ }, Pr = `.ProseMirror {
2421
+ position: relative;
2422
+ }
2423
+
2424
+ .ProseMirror {
2425
+ word-wrap: break-word;
2426
+ white-space: pre-wrap;
2427
+ white-space: break-spaces;
2428
+ -webkit-font-variant-ligatures: none;
2429
+ font-variant-ligatures: none;
2430
+ font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
2431
+ }
2432
+
2433
+ .ProseMirror [contenteditable="false"] {
2434
+ white-space: normal;
2435
+ }
2436
+
2437
+ .ProseMirror [contenteditable="false"] [contenteditable="true"] {
2438
+ white-space: pre-wrap;
2439
+ }
2440
+
2441
+ .ProseMirror pre {
2442
+ white-space: pre-wrap;
2443
+ }
2444
+
2445
+ img.ProseMirror-separator {
2446
+ display: inline !important;
2447
+ border: none !important;
2448
+ margin: 0 !important;
2449
+ width: 0 !important;
2450
+ height: 0 !important;
2451
+ }
2452
+
2453
+ .ProseMirror-gapcursor {
2454
+ display: none;
2455
+ pointer-events: none;
2456
+ position: absolute;
2457
+ margin: 0;
2458
+ }
2459
+
2460
+ .ProseMirror-gapcursor:after {
2461
+ content: "";
2462
+ display: block;
2463
+ position: absolute;
2464
+ top: -2px;
2465
+ width: 20px;
2466
+ border-top: 1px solid black;
2467
+ animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
2468
+ }
2469
+
2470
+ @keyframes ProseMirror-cursor-blink {
2471
+ to {
2472
+ visibility: hidden;
2473
+ }
2474
+ }
2475
+
2476
+ .ProseMirror-hideselection *::selection {
2477
+ background: transparent;
2478
+ }
2479
+
2480
+ .ProseMirror-hideselection *::-moz-selection {
2481
+ background: transparent;
2482
+ }
2483
+
2484
+ .ProseMirror-hideselection * {
2485
+ caret-color: transparent;
2486
+ }
2487
+
2488
+ .ProseMirror-focused .ProseMirror-gapcursor {
2489
+ display: block;
2490
+ }`;
2491
+ function $r(e, t, n) {
2492
+ const r = document.querySelector("style[data-tiptap-style]");
2493
+ if (r !== null)
2494
+ return r;
2495
+ const s = document.createElement("style");
2496
+ return t && s.setAttribute("nonce", t), s.setAttribute("data-tiptap-style", ""), s.innerHTML = e, document.getElementsByTagName("head")[0].appendChild(s), s;
2497
+ }
2498
+ var Gr = class extends gr {
2499
+ constructor(t = {}) {
2500
+ super(), this.css = null, this.className = "tiptap", this.editorView = null, this.isFocused = !1, this.isInitialized = !1, this.extensionStorage = {}, this.instanceId = Math.random().toString(36).slice(2, 9), this.options = {
2501
+ element: typeof document < "u" ? document.createElement("div") : null,
2502
+ content: "",
2503
+ injectCSS: !0,
2504
+ injectNonce: void 0,
2505
+ extensions: [],
2506
+ autofocus: !1,
2507
+ editable: !0,
2508
+ editorProps: {},
2509
+ parseOptions: {},
2510
+ coreExtensionOptions: {},
2511
+ enableInputRules: !0,
2512
+ enablePasteRules: !0,
2513
+ enableCoreExtensions: !0,
2514
+ enableContentCheck: !1,
2515
+ emitContentError: !1,
2516
+ onBeforeCreate: () => null,
2517
+ onCreate: () => null,
2518
+ onMount: () => null,
2519
+ onUnmount: () => null,
2520
+ onUpdate: () => null,
2521
+ onSelectionUpdate: () => null,
2522
+ onTransaction: () => null,
2523
+ onFocus: () => null,
2524
+ onBlur: () => null,
2525
+ onDestroy: () => null,
2526
+ onContentError: ({ error: s }) => {
2527
+ throw s;
2528
+ },
2529
+ onPaste: () => null,
2530
+ onDrop: () => null,
2531
+ onDelete: () => null
2532
+ }, this.isCapturingTransaction = !1, this.capturedTransaction = null, this.setOptions(t), this.createExtensionManager(), this.createCommandManager(), this.createSchema(), this.on("beforeCreate", this.options.onBeforeCreate), this.emit("beforeCreate", { editor: this }), this.on("mount", this.options.onMount), this.on("unmount", this.options.onUnmount), this.on("contentError", this.options.onContentError), this.on("create", this.options.onCreate), this.on("update", this.options.onUpdate), this.on("selectionUpdate", this.options.onSelectionUpdate), this.on("transaction", this.options.onTransaction), this.on("focus", this.options.onFocus), this.on("blur", this.options.onBlur), this.on("destroy", this.options.onDestroy), this.on("drop", ({ event: s, slice: o, moved: i }) => this.options.onDrop(s, o, i)), this.on("paste", ({ event: s, slice: o }) => this.options.onPaste(s, o)), this.on("delete", this.options.onDelete);
2533
+ const n = this.createDoc(), r = Dt(n, this.options.autofocus);
2534
+ this.editorState = ze.create({
2535
+ doc: n,
2536
+ schema: this.schema,
2537
+ selection: r || void 0
2538
+ }), this.options.element && this.mount(this.options.element);
2539
+ }
2540
+ /**
2541
+ * Attach the editor to the DOM, creating a new editor view.
2542
+ */
2543
+ mount(t) {
2544
+ if (typeof document > "u")
2545
+ throw new Error(
2546
+ "[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment."
2547
+ );
2548
+ this.createView(t), this.emit("mount", { editor: this }), this.css && !document.head.contains(this.css) && document.head.appendChild(this.css), window.setTimeout(() => {
2549
+ this.isDestroyed || (this.commands.focus(this.options.autofocus), this.emit("create", { editor: this }), this.isInitialized = !0);
2550
+ }, 0);
2551
+ }
2552
+ /**
2553
+ * Remove the editor from the DOM, but still allow remounting at a different point in time
2554
+ */
2555
+ unmount() {
2556
+ if (this.editorView) {
2557
+ const t = this.editorView.dom;
2558
+ t?.editor && delete t.editor, this.editorView.destroy();
2559
+ }
2560
+ if (this.editorView = null, this.isInitialized = !1, this.css && !document.querySelectorAll(`.${this.className}`).length)
2561
+ try {
2562
+ typeof this.css.remove == "function" ? this.css.remove() : this.css.parentNode && this.css.parentNode.removeChild(this.css);
2563
+ } catch (t) {
2564
+ console.warn("Failed to remove CSS element:", t);
2565
+ }
2566
+ this.css = null, this.emit("unmount", { editor: this });
2567
+ }
2568
+ /**
2569
+ * Returns the editor storage.
2570
+ */
2571
+ get storage() {
2572
+ return this.extensionStorage;
2573
+ }
2574
+ /**
2575
+ * An object of all registered commands.
2576
+ */
2577
+ get commands() {
2578
+ return this.commandManager.commands;
2579
+ }
2580
+ /**
2581
+ * Create a command chain to call multiple commands at once.
2582
+ */
2583
+ chain() {
2584
+ return this.commandManager.chain();
2585
+ }
2586
+ /**
2587
+ * Check if a command or a command chain can be executed. Without executing it.
2588
+ */
2589
+ can() {
2590
+ return this.commandManager.can();
2591
+ }
2592
+ /**
2593
+ * Inject CSS styles.
2594
+ */
2595
+ injectCSS() {
2596
+ this.options.injectCSS && typeof document < "u" && (this.css = $r(Pr, this.options.injectNonce));
2597
+ }
2598
+ /**
2599
+ * Update editor options.
2600
+ *
2601
+ * @param options A list of options
2602
+ */
2603
+ setOptions(t = {}) {
2604
+ this.options = {
2605
+ ...this.options,
2606
+ ...t
2607
+ }, !(!this.editorView || !this.state || this.isDestroyed) && (this.options.editorProps && this.view.setProps(this.options.editorProps), this.view.updateState(this.state));
2608
+ }
2609
+ /**
2610
+ * Update editable state of the editor.
2611
+ */
2612
+ setEditable(t, n = !0) {
2613
+ this.setOptions({ editable: t }), n && this.emit("update", { editor: this, transaction: this.state.tr, appendedTransactions: [] });
2614
+ }
2615
+ /**
2616
+ * Returns whether the editor is editable.
2617
+ */
2618
+ get isEditable() {
2619
+ return this.options.editable && this.view && this.view.editable;
2620
+ }
2621
+ /**
2622
+ * Returns the editor state.
2623
+ */
2624
+ get view() {
2625
+ return this.editorView ? this.editorView : new Proxy(
2626
+ {
2627
+ state: this.editorState,
2628
+ updateState: (t) => {
2629
+ this.editorState = t;
2630
+ },
2631
+ dispatch: (t) => {
2632
+ this.dispatchTransaction(t);
2633
+ },
2634
+ // Stub some commonly accessed properties to prevent errors
2635
+ composing: !1,
2636
+ dragging: null,
2637
+ editable: !0,
2638
+ isDestroyed: !1
2639
+ },
2640
+ {
2641
+ get: (t, n) => {
2642
+ if (this.editorView)
2643
+ return this.editorView[n];
2644
+ if (n === "state")
2645
+ return this.editorState;
2646
+ if (n in t)
2647
+ return Reflect.get(t, n);
2648
+ throw new Error(
2649
+ `[tiptap error]: The editor view is not available. Cannot access view['${n}']. The editor may not be mounted yet.`
2650
+ );
2651
+ }
2652
+ }
2653
+ );
2654
+ }
2655
+ /**
2656
+ * Returns the editor state.
2657
+ */
2658
+ get state() {
2659
+ return this.editorView && (this.editorState = this.view.state), this.editorState;
2660
+ }
2661
+ /**
2662
+ * Register a ProseMirror plugin.
2663
+ *
2664
+ * @param plugin A ProseMirror plugin
2665
+ * @param handlePlugins Control how to merge the plugin into the existing plugins.
2666
+ * @returns The new editor state
2667
+ */
2668
+ registerPlugin(t, n) {
2669
+ const r = Vt(n) ? n(t, [...this.state.plugins]) : [...this.state.plugins, t], s = this.state.reconfigure({ plugins: r });
2670
+ return this.view.updateState(s), s;
2671
+ }
2672
+ /**
2673
+ * Unregister a ProseMirror plugin.
2674
+ *
2675
+ * @param nameOrPluginKeyToRemove The plugins name
2676
+ * @returns The new editor state or undefined if the editor is destroyed
2677
+ */
2678
+ unregisterPlugin(t) {
2679
+ if (this.isDestroyed)
2680
+ return;
2681
+ const n = this.state.plugins;
2682
+ let r = n;
2683
+ if ([].concat(t).forEach((o) => {
2684
+ const i = typeof o == "string" ? `${o}$` : o.key;
2685
+ r = r.filter((a) => !a.key.startsWith(i));
2686
+ }), n.length === r.length)
2687
+ return;
2688
+ const s = this.state.reconfigure({
2689
+ plugins: r
2690
+ });
2691
+ return this.view.updateState(s), s;
2692
+ }
2693
+ /**
2694
+ * Creates an extension manager.
2695
+ */
2696
+ createExtensionManager() {
2697
+ var t, n;
2698
+ const s = [...this.options.enableCoreExtensions ? [
2699
+ ne,
2700
+ Qt.configure({
2701
+ blockSeparator: (n = (t = this.options.coreExtensionOptions) == null ? void 0 : t.clipboardTextSerializer) == null ? void 0 : n.blockSeparator
2702
+ }),
2703
+ Gt,
2704
+ se,
2705
+ oe,
2706
+ ae,
2707
+ ee,
2708
+ ie,
2709
+ te
2710
+ ].filter((o) => typeof this.options.enableCoreExtensions == "object" ? this.options.enableCoreExtensions[o.name] !== !1 : !0) : [], ...this.options.extensions].filter((o) => ["extension", "node", "mark"].includes(o?.type));
2711
+ this.extensionManager = new ot(s, this);
2712
+ }
2713
+ /**
2714
+ * Creates an command manager.
2715
+ */
2716
+ createCommandManager() {
2717
+ this.commandManager = new et({
2718
+ editor: this
2719
+ });
2720
+ }
2721
+ /**
2722
+ * Creates a ProseMirror schema.
2723
+ */
2724
+ createSchema() {
2725
+ this.schema = this.extensionManager.schema;
2726
+ }
2727
+ /**
2728
+ * Creates the initial document.
2729
+ */
2730
+ createDoc() {
2731
+ let t;
2732
+ try {
2733
+ t = ft(this.options.content, this.schema, this.options.parseOptions, {
2734
+ errorOnInvalidContent: this.options.enableContentCheck
2735
+ });
2736
+ } catch (n) {
2737
+ if (!(n instanceof Error) || !["[tiptap error]: Invalid JSON content", "[tiptap error]: Invalid HTML content"].includes(n.message))
2738
+ throw n;
2739
+ this.emit("contentError", {
2740
+ editor: this,
2741
+ error: n,
2742
+ disableCollaboration: () => {
2743
+ "collaboration" in this.storage && typeof this.storage.collaboration == "object" && this.storage.collaboration && (this.storage.collaboration.isDisabled = !0), this.options.extensions = this.options.extensions.filter((r) => r.name !== "collaboration"), this.createExtensionManager();
2744
+ }
2745
+ }), t = ft(this.options.content, this.schema, this.options.parseOptions, {
2746
+ errorOnInvalidContent: !1
2747
+ });
2748
+ }
2749
+ return t;
2750
+ }
2751
+ /**
2752
+ * Creates a ProseMirror view.
2753
+ */
2754
+ createView(t) {
2755
+ var n;
2756
+ this.editorView = new Fe(t, {
2757
+ ...this.options.editorProps,
2758
+ attributes: {
2759
+ // add `role="textbox"` to the editor element
2760
+ role: "textbox",
2761
+ ...(n = this.options.editorProps) == null ? void 0 : n.attributes
2762
+ },
2763
+ dispatchTransaction: this.dispatchTransaction.bind(this),
2764
+ state: this.editorState,
2765
+ markViews: this.extensionManager.markViews,
2766
+ nodeViews: this.extensionManager.nodeViews
2767
+ });
2768
+ const r = this.state.reconfigure({
2769
+ plugins: this.extensionManager.plugins
2770
+ });
2771
+ this.view.updateState(r), this.prependClass(), this.injectCSS();
2772
+ const s = this.view.dom;
2773
+ s.editor = this;
2774
+ }
2775
+ /**
2776
+ * Creates all node and mark views.
2777
+ */
2778
+ createNodeViews() {
2779
+ this.view.isDestroyed || this.view.setProps({
2780
+ markViews: this.extensionManager.markViews,
2781
+ nodeViews: this.extensionManager.nodeViews
2782
+ });
2783
+ }
2784
+ /**
2785
+ * Prepend class name to element.
2786
+ */
2787
+ prependClass() {
2788
+ this.view.dom.className = `${this.className} ${this.view.dom.className}`;
2789
+ }
2790
+ captureTransaction(t) {
2791
+ this.isCapturingTransaction = !0, t(), this.isCapturingTransaction = !1;
2792
+ const n = this.capturedTransaction;
2793
+ return this.capturedTransaction = null, n;
2794
+ }
2795
+ /**
2796
+ * The callback over which to send transactions (state updates) produced by the view.
2797
+ *
2798
+ * @param transaction An editor state transaction
2799
+ */
2800
+ dispatchTransaction(t) {
2801
+ if (this.view.isDestroyed)
2802
+ return;
2803
+ if (this.isCapturingTransaction) {
2804
+ if (!this.capturedTransaction) {
2805
+ this.capturedTransaction = t;
2806
+ return;
2807
+ }
2808
+ t.steps.forEach((d) => {
2809
+ var u;
2810
+ return (u = this.capturedTransaction) == null ? void 0 : u.step(d);
2811
+ });
2812
+ return;
2813
+ }
2814
+ const { state: n, transactions: r } = this.state.applyTransaction(t), s = !this.state.selection.eq(n.selection), o = r.includes(t), i = this.state;
2815
+ if (this.emit("beforeTransaction", {
2816
+ editor: this,
2817
+ transaction: t,
2818
+ nextState: n
2819
+ }), !o)
2820
+ return;
2821
+ this.view.updateState(n), this.emit("transaction", {
2822
+ editor: this,
2823
+ transaction: t,
2824
+ appendedTransactions: r.slice(1)
2825
+ }), s && this.emit("selectionUpdate", {
2826
+ editor: this,
2827
+ transaction: t
2828
+ });
2829
+ const a = r.findLast((d) => d.getMeta("focus") || d.getMeta("blur")), c = a?.getMeta("focus"), l = a?.getMeta("blur");
2830
+ c && this.emit("focus", {
2831
+ editor: this,
2832
+ event: c.event,
2833
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
2834
+ transaction: a
2835
+ }), l && this.emit("blur", {
2836
+ editor: this,
2837
+ event: l.event,
2838
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
2839
+ transaction: a
2840
+ }), !(t.getMeta("preventUpdate") || !r.some((d) => d.docChanged) || i.doc.eq(n.doc)) && this.emit("update", {
2841
+ editor: this,
2842
+ transaction: t,
2843
+ appendedTransactions: r.slice(1)
2844
+ });
2845
+ }
2846
+ /**
2847
+ * Get attributes of the currently selected node or mark.
2848
+ */
2849
+ getAttributes(t) {
2850
+ return Un(this.state, t);
2851
+ }
2852
+ isActive(t, n) {
2853
+ const r = typeof t == "string" ? t : null, s = typeof t == "string" ? n : t;
2854
+ return Yn(this.state, r, s);
2855
+ }
2856
+ /**
2857
+ * Get the document as JSON.
2858
+ */
2859
+ getJSON() {
2860
+ return this.state.doc.toJSON();
2861
+ }
2862
+ /**
2863
+ * Get the document as HTML.
2864
+ */
2865
+ getHTML() {
2866
+ return wt(this.state.doc.content, this.schema);
2867
+ }
2868
+ /**
2869
+ * Get the document as text.
2870
+ */
2871
+ getText(t) {
2872
+ const { blockSeparator: n = `
2873
+
2874
+ `, textSerializers: r = {} } = t || {};
2875
+ return Vn(this.state.doc, {
2876
+ blockSeparator: n,
2877
+ textSerializers: {
2878
+ ...qt(this.schema),
2879
+ ...r
2880
+ }
2881
+ });
2882
+ }
2883
+ /**
2884
+ * Check if there is no content.
2885
+ */
2886
+ get isEmpty() {
2887
+ return Mt(this.state.doc);
2888
+ }
2889
+ /**
2890
+ * Destroy the editor.
2891
+ */
2892
+ destroy() {
2893
+ this.emit("destroy"), this.unmount(), this.removeAllListeners();
2894
+ }
2895
+ /**
2896
+ * Check if the editor is already destroyed.
2897
+ */
2898
+ get isDestroyed() {
2899
+ var t, n;
2900
+ return (n = (t = this.editorView) == null ? void 0 : t.isDestroyed) != null ? n : !0;
2901
+ }
2902
+ $node(t, n) {
2903
+ var r;
2904
+ return ((r = this.$doc) == null ? void 0 : r.querySelector(t, n)) || null;
2905
+ }
2906
+ $nodes(t, n) {
2907
+ var r;
2908
+ return ((r = this.$doc) == null ? void 0 : r.querySelectorAll(t, n)) || null;
2909
+ }
2910
+ $pos(t) {
2911
+ const n = this.state.doc.resolve(t);
2912
+ return new Cr(n, this);
2913
+ }
2914
+ get $doc() {
2915
+ return this.$pos(0);
2916
+ }
2917
+ };
2918
+ function es(e) {
2919
+ return new st({
2920
+ find: e.find,
2921
+ handler: ({ state: t, range: n, match: r }) => {
2922
+ const s = S(e.getAttributes, void 0, r);
2923
+ if (s === !1 || s === null)
2924
+ return null;
2925
+ const { tr: o } = t, i = r[r.length - 1], a = r[0];
2926
+ if (i) {
2927
+ const c = a.search(/\S/), l = n.from + a.indexOf(i), d = l + i.length;
2928
+ if (Jt(n.from, n.to, t.doc).filter((p) => p.mark.type.excluded.find((m) => m === e.type && m !== p.mark.type)).filter((p) => p.to > l).length)
2929
+ return null;
2930
+ d < n.to && o.delete(d, n.to), l > n.from && o.delete(n.from + c, l);
2931
+ const f = n.from + c + i.length;
2932
+ o.addMark(n.from + c, f, e.type.create(s || {})), o.removeStoredMark(e.type);
2933
+ }
2934
+ },
2935
+ undoable: e.undoable
2936
+ });
2937
+ }
2938
+ function ns(e) {
2939
+ return new st({
2940
+ find: e.find,
2941
+ handler: ({ state: t, range: n, match: r }) => {
2942
+ const s = S(e.getAttributes, void 0, r) || {}, { tr: o } = t, i = n.from;
2943
+ let a = n.to;
2944
+ const c = e.type.create(s);
2945
+ if (r[1]) {
2946
+ const l = r[0].lastIndexOf(r[1]);
2947
+ let d = i + l;
2948
+ d > a ? d = a : a = d + r[1].length;
2949
+ const u = r[0][r[0].length - 1];
2950
+ o.insertText(u, i + r[0].length - 1), o.replaceWith(d, a, c);
2951
+ } else if (r[0]) {
2952
+ const l = e.type.isInline ? i : i - 1;
2953
+ o.insert(l, e.type.create(s)).delete(o.mapping.map(i), o.mapping.map(a));
2954
+ }
2955
+ o.scrollIntoView();
2956
+ },
2957
+ undoable: e.undoable
2958
+ });
2959
+ }
2960
+ function rs(e) {
2961
+ return new st({
2962
+ find: e.find,
2963
+ handler: ({ state: t, range: n, match: r }) => {
2964
+ const s = t.doc.resolve(n.from), o = S(e.getAttributes, void 0, r) || {};
2965
+ if (!s.node(-1).canReplaceWith(s.index(-1), s.indexAfter(-1), e.type))
2966
+ return null;
2967
+ t.tr.delete(n.from, n.to).setBlockType(n.from, n.from, e.type, o);
2968
+ },
2969
+ undoable: e.undoable
2970
+ });
2971
+ }
2972
+ function ss(e) {
2973
+ return new st({
2974
+ find: e.find,
2975
+ handler: ({ state: t, range: n, match: r, chain: s }) => {
2976
+ const o = S(e.getAttributes, void 0, r) || {}, i = t.tr.delete(n.from, n.to), c = i.doc.resolve(n.from).blockRange(), l = c && le(c, e.type, o);
2977
+ if (!l)
2978
+ return null;
2979
+ if (i.wrap(c, l), e.keepMarks && e.editor) {
2980
+ const { selection: u, storedMarks: f } = t, { splittableMarks: p } = e.editor.extensionManager, h = f || u.$to.parentOffset && u.$from.marks();
2981
+ if (h) {
2982
+ const m = h.filter((g) => p.includes(g.type.name));
2983
+ i.ensureMarks(m);
2984
+ }
2985
+ }
2986
+ if (e.keepAttributes) {
2987
+ const u = e.type.name === "bulletList" || e.type.name === "orderedList" ? "listItem" : "taskList";
2988
+ s().updateAttributes(u, o).run();
2989
+ }
2990
+ const d = i.doc.resolve(n.from - 1).nodeBefore;
2991
+ d && d.type === e.type && ht(i.doc, n.from - 1) && (!e.joinPredicate || e.joinPredicate(r, d)) && i.join(n.from - 1);
2992
+ },
2993
+ undoable: e.undoable
2994
+ });
2995
+ }
2996
+ var Nr = (e) => "touches" in e, os = class {
2997
+ /**
2998
+ * Creates a new ResizableNodeView instance.
2999
+ *
3000
+ * The constructor sets up the resize handles, applies initial sizing from
3001
+ * node attributes, and configures all resize behavior options.
3002
+ *
3003
+ * @param options - Configuration options for the resizable node view
3004
+ */
3005
+ constructor(e) {
3006
+ this.directions = ["bottom-left", "bottom-right", "top-left", "top-right"], this.minSize = {
3007
+ height: 8,
3008
+ width: 8
3009
+ }, this.preserveAspectRatio = !1, this.classNames = {
3010
+ container: "",
3011
+ wrapper: "",
3012
+ handle: "",
3013
+ resizing: ""
3014
+ }, this.initialWidth = 0, this.initialHeight = 0, this.aspectRatio = 1, this.isResizing = !1, this.activeHandle = null, this.startX = 0, this.startY = 0, this.startWidth = 0, this.startHeight = 0, this.isShiftKeyPressed = !1, this.handleMouseMove = (i) => {
3015
+ if (!this.isResizing || !this.activeHandle)
3016
+ return;
3017
+ const a = i.clientX - this.startX, c = i.clientY - this.startY;
3018
+ this.handleResize(a, c);
3019
+ }, this.handleTouchMove = (i) => {
3020
+ if (!this.isResizing || !this.activeHandle)
3021
+ return;
3022
+ const a = i.touches[0];
3023
+ if (!a)
3024
+ return;
3025
+ const c = a.clientX - this.startX, l = a.clientY - this.startY;
3026
+ this.handleResize(c, l);
3027
+ }, this.handleMouseUp = () => {
3028
+ if (!this.isResizing)
3029
+ return;
3030
+ const i = this.element.offsetWidth, a = this.element.offsetHeight;
3031
+ this.onCommit(i, a), this.isResizing = !1, this.activeHandle = null, this.container.dataset.resizeState = "false", this.classNames.resizing && this.container.classList.remove(this.classNames.resizing), document.removeEventListener("mousemove", this.handleMouseMove), document.removeEventListener("mouseup", this.handleMouseUp), document.removeEventListener("keydown", this.handleKeyDown), document.removeEventListener("keyup", this.handleKeyUp);
3032
+ }, this.handleKeyDown = (i) => {
3033
+ i.key === "Shift" && (this.isShiftKeyPressed = !0);
3034
+ }, this.handleKeyUp = (i) => {
3035
+ i.key === "Shift" && (this.isShiftKeyPressed = !1);
3036
+ };
3037
+ var t, n, r, s, o;
3038
+ this.node = e.node, this.element = e.element, this.contentElement = e.contentElement, this.getPos = e.getPos, this.onResize = e.onResize, this.onCommit = e.onCommit, this.onUpdate = e.onUpdate, (t = e.options) != null && t.min && (this.minSize = {
3039
+ ...this.minSize,
3040
+ ...e.options.min
3041
+ }), (n = e.options) != null && n.max && (this.maxSize = e.options.max), (r = e?.options) != null && r.directions && (this.directions = e.options.directions), (s = e.options) != null && s.preserveAspectRatio && (this.preserveAspectRatio = e.options.preserveAspectRatio), (o = e.options) != null && o.className && (this.classNames = {
3042
+ container: e.options.className.container || "",
3043
+ wrapper: e.options.className.wrapper || "",
3044
+ handle: e.options.className.handle || "",
3045
+ resizing: e.options.className.resizing || ""
3046
+ }), this.wrapper = this.createWrapper(), this.container = this.createContainer(), this.applyInitialSize(), this.attachHandles();
3047
+ }
3048
+ /**
3049
+ * Returns the top-level DOM node that should be placed in the editor.
3050
+ *
3051
+ * This is required by the ProseMirror NodeView interface. The container
3052
+ * includes the wrapper, handles, and the actual content element.
3053
+ *
3054
+ * @returns The container element to be inserted into the editor
3055
+ */
3056
+ get dom() {
3057
+ return this.container;
3058
+ }
3059
+ get contentDOM() {
3060
+ return this.contentElement;
3061
+ }
3062
+ /**
3063
+ * Called when the node's content or attributes change.
3064
+ *
3065
+ * Updates the internal node reference. If a custom `onUpdate` callback
3066
+ * was provided, it will be called to handle additional update logic.
3067
+ *
3068
+ * @param node - The new/updated node
3069
+ * @param decorations - Node decorations
3070
+ * @param innerDecorations - Inner decorations
3071
+ * @returns `false` if the node type has changed (requires full rebuild), otherwise the result of `onUpdate` or `true`
3072
+ */
3073
+ update(e, t, n) {
3074
+ return e.type !== this.node.type ? !1 : (this.node = e, this.onUpdate ? this.onUpdate(e, t, n) : !0);
3075
+ }
3076
+ /**
3077
+ * Cleanup method called when the node view is being removed.
3078
+ *
3079
+ * Removes all event listeners to prevent memory leaks. This is required
3080
+ * by the ProseMirror NodeView interface. If a resize is active when
3081
+ * destroy is called, it will be properly cancelled.
3082
+ */
3083
+ destroy() {
3084
+ this.isResizing && (this.container.dataset.resizeState = "false", this.classNames.resizing && this.container.classList.remove(this.classNames.resizing), document.removeEventListener("mousemove", this.handleMouseMove), document.removeEventListener("mouseup", this.handleMouseUp), document.removeEventListener("keydown", this.handleKeyDown), document.removeEventListener("keyup", this.handleKeyUp), this.isResizing = !1, this.activeHandle = null), this.container.remove();
3085
+ }
3086
+ /**
3087
+ * Creates the outer container element.
3088
+ *
3089
+ * The container is the top-level element returned by the NodeView and
3090
+ * wraps the entire resizable node. It's set up with flexbox to handle
3091
+ * alignment and includes data attributes for styling and identification.
3092
+ *
3093
+ * @returns The container element
3094
+ */
3095
+ createContainer() {
3096
+ const e = document.createElement("div");
3097
+ return e.dataset.resizeContainer = "", e.dataset.node = this.node.type.name, e.style.display = "flex", e.style.justifyContent = "flex-start", e.style.alignItems = "flex-start", this.classNames.container && (e.className = this.classNames.container), e.appendChild(this.wrapper), e;
3098
+ }
3099
+ /**
3100
+ * Creates the wrapper element that contains the content and handles.
3101
+ *
3102
+ * The wrapper uses relative positioning so that resize handles can be
3103
+ * positioned absolutely within it. This is the direct parent of the
3104
+ * content element being made resizable.
3105
+ *
3106
+ * @returns The wrapper element
3107
+ */
3108
+ createWrapper() {
3109
+ const e = document.createElement("div");
3110
+ return e.style.position = "relative", e.style.display = "block", e.dataset.resizeWrapper = "", this.classNames.wrapper && (e.className = this.classNames.wrapper), e.appendChild(this.element), e;
3111
+ }
3112
+ /**
3113
+ * Creates a resize handle element for a specific direction.
3114
+ *
3115
+ * Each handle is absolutely positioned and includes a data attribute
3116
+ * identifying its direction for styling purposes.
3117
+ *
3118
+ * @param direction - The resize direction for this handle
3119
+ * @returns The handle element
3120
+ */
3121
+ createHandle(e) {
3122
+ const t = document.createElement("div");
3123
+ return t.dataset.resizeHandle = e, t.style.position = "absolute", this.classNames.handle && (t.className = this.classNames.handle), t;
3124
+ }
3125
+ /**
3126
+ * Positions a handle element according to its direction.
3127
+ *
3128
+ * Corner handles (e.g., 'top-left') are positioned at the intersection
3129
+ * of two edges. Edge handles (e.g., 'top') span the full width or height.
3130
+ *
3131
+ * @param handle - The handle element to position
3132
+ * @param direction - The direction determining the position
3133
+ */
3134
+ positionHandle(e, t) {
3135
+ const n = t.includes("top"), r = t.includes("bottom"), s = t.includes("left"), o = t.includes("right");
3136
+ n && (e.style.top = "0"), r && (e.style.bottom = "0"), s && (e.style.left = "0"), o && (e.style.right = "0"), (t === "top" || t === "bottom") && (e.style.left = "0", e.style.right = "0"), (t === "left" || t === "right") && (e.style.top = "0", e.style.bottom = "0");
3137
+ }
3138
+ /**
3139
+ * Creates and attaches all resize handles to the wrapper.
3140
+ *
3141
+ * Iterates through the configured directions, creates a handle for each,
3142
+ * positions it, attaches the mousedown listener, and appends it to the DOM.
3143
+ */
3144
+ attachHandles() {
3145
+ this.directions.forEach((e) => {
3146
+ const t = this.createHandle(e);
3147
+ this.positionHandle(t, e), t.addEventListener("mousedown", (n) => this.handleResizeStart(n, e)), t.addEventListener("touchstart", (n) => this.handleResizeStart(n, e)), this.wrapper.appendChild(t);
3148
+ });
3149
+ }
3150
+ /**
3151
+ * Applies initial sizing from node attributes to the element.
3152
+ *
3153
+ * If width/height attributes exist on the node, they're applied to the element.
3154
+ * Otherwise, the element's natural/current dimensions are measured. The aspect
3155
+ * ratio is calculated for later use in aspect-ratio-preserving resizes.
3156
+ */
3157
+ applyInitialSize() {
3158
+ const e = this.node.attrs.width, t = this.node.attrs.height;
3159
+ e ? (this.element.style.width = `${e}px`, this.initialWidth = e) : this.initialWidth = this.element.offsetWidth, t ? (this.element.style.height = `${t}px`, this.initialHeight = t) : this.initialHeight = this.element.offsetHeight, this.initialWidth > 0 && this.initialHeight > 0 && (this.aspectRatio = this.initialWidth / this.initialHeight);
3160
+ }
3161
+ /**
3162
+ * Initiates a resize operation when a handle is clicked.
3163
+ *
3164
+ * Captures the starting mouse position and element dimensions, sets up
3165
+ * the resize state, adds the resizing class and state attribute, and
3166
+ * attaches document-level listeners for mouse movement and keyboard input.
3167
+ *
3168
+ * @param event - The mouse down event
3169
+ * @param direction - The direction of the handle being dragged
3170
+ */
3171
+ handleResizeStart(e, t) {
3172
+ e.preventDefault(), e.stopPropagation(), this.isResizing = !0, this.activeHandle = t, Nr(e) ? (this.startX = e.touches[0].clientX, this.startY = e.touches[0].clientY) : (this.startX = e.clientX, this.startY = e.clientY), this.startWidth = this.element.offsetWidth, this.startHeight = this.element.offsetHeight, this.startWidth > 0 && this.startHeight > 0 && (this.aspectRatio = this.startWidth / this.startHeight), this.getPos(), this.container.dataset.resizeState = "true", this.classNames.resizing && this.container.classList.add(this.classNames.resizing), document.addEventListener("mousemove", this.handleMouseMove), document.addEventListener("touchmove", this.handleTouchMove), document.addEventListener("mouseup", this.handleMouseUp), document.addEventListener("keydown", this.handleKeyDown), document.addEventListener("keyup", this.handleKeyUp);
3173
+ }
3174
+ handleResize(e, t) {
3175
+ if (!this.activeHandle)
3176
+ return;
3177
+ const n = this.preserveAspectRatio || this.isShiftKeyPressed, { width: r, height: s } = this.calculateNewDimensions(this.activeHandle, e, t), o = this.applyConstraints(r, s, n);
3178
+ this.element.style.width = `${o.width}px`, this.element.style.height = `${o.height}px`, this.onResize && this.onResize(o.width, o.height);
3179
+ }
3180
+ /**
3181
+ * Calculates new dimensions based on mouse delta and resize direction.
3182
+ *
3183
+ * Takes the starting dimensions and applies the mouse movement delta
3184
+ * according to the handle direction. For corner handles, both dimensions
3185
+ * are affected. For edge handles, only one dimension changes. If aspect
3186
+ * ratio should be preserved, delegates to applyAspectRatio.
3187
+ *
3188
+ * @param direction - The active resize handle direction
3189
+ * @param deltaX - Horizontal mouse movement since resize start
3190
+ * @param deltaY - Vertical mouse movement since resize start
3191
+ * @returns The calculated width and height
3192
+ */
3193
+ calculateNewDimensions(e, t, n) {
3194
+ let r = this.startWidth, s = this.startHeight;
3195
+ const o = e.includes("right"), i = e.includes("left"), a = e.includes("bottom"), c = e.includes("top");
3196
+ return o ? r = this.startWidth + t : i && (r = this.startWidth - t), a ? s = this.startHeight + n : c && (s = this.startHeight - n), (e === "right" || e === "left") && (r = this.startWidth + (o ? t : -t)), (e === "top" || e === "bottom") && (s = this.startHeight + (a ? n : -n)), this.preserveAspectRatio || this.isShiftKeyPressed ? this.applyAspectRatio(r, s, e) : { width: r, height: s };
3197
+ }
3198
+ /**
3199
+ * Applies min/max constraints to dimensions.
3200
+ *
3201
+ * When aspect ratio is NOT preserved, constraints are applied independently
3202
+ * to width and height. When aspect ratio IS preserved, constraints are
3203
+ * applied while maintaining the aspect ratio—if one dimension hits a limit,
3204
+ * the other is recalculated proportionally.
3205
+ *
3206
+ * This ensures that aspect ratio is never broken when constrained.
3207
+ *
3208
+ * @param width - The unconstrained width
3209
+ * @param height - The unconstrained height
3210
+ * @param preserveAspectRatio - Whether to maintain aspect ratio while constraining
3211
+ * @returns The constrained dimensions
3212
+ */
3213
+ applyConstraints(e, t, n) {
3214
+ var r, s, o, i;
3215
+ if (!n) {
3216
+ let l = Math.max(this.minSize.width, e), d = Math.max(this.minSize.height, t);
3217
+ return (r = this.maxSize) != null && r.width && (l = Math.min(this.maxSize.width, l)), (s = this.maxSize) != null && s.height && (d = Math.min(this.maxSize.height, d)), { width: l, height: d };
3218
+ }
3219
+ let a = e, c = t;
3220
+ return a < this.minSize.width && (a = this.minSize.width, c = a / this.aspectRatio), c < this.minSize.height && (c = this.minSize.height, a = c * this.aspectRatio), (o = this.maxSize) != null && o.width && a > this.maxSize.width && (a = this.maxSize.width, c = a / this.aspectRatio), (i = this.maxSize) != null && i.height && c > this.maxSize.height && (c = this.maxSize.height, a = c * this.aspectRatio), { width: a, height: c };
3221
+ }
3222
+ /**
3223
+ * Adjusts dimensions to maintain the original aspect ratio.
3224
+ *
3225
+ * For horizontal handles (left/right), uses width as the primary dimension
3226
+ * and calculates height from it. For vertical handles (top/bottom), uses
3227
+ * height as primary and calculates width. For corner handles, uses width
3228
+ * as the primary dimension.
3229
+ *
3230
+ * @param width - The new width
3231
+ * @param height - The new height
3232
+ * @param direction - The active resize direction
3233
+ * @returns Dimensions adjusted to preserve aspect ratio
3234
+ */
3235
+ applyAspectRatio(e, t, n) {
3236
+ const r = n === "left" || n === "right", s = n === "top" || n === "bottom";
3237
+ return r ? {
3238
+ width: e,
3239
+ height: e / this.aspectRatio
3240
+ } : s ? {
3241
+ width: t * this.aspectRatio,
3242
+ height: t
3243
+ } : {
3244
+ width: e,
3245
+ height: e / this.aspectRatio
3246
+ };
3247
+ }
3248
+ };
3249
+ function is(e, t) {
3250
+ const { selection: n } = e, { $from: r } = n;
3251
+ if (n instanceof G) {
3252
+ const o = r.index();
3253
+ return r.parent.canReplaceWith(o, o + 1, t);
3254
+ }
3255
+ let s = r.depth;
3256
+ for (; s >= 0; ) {
3257
+ const o = r.index(s);
3258
+ if (r.node(s).contentMatchAt(o).matchType(t))
3259
+ return !0;
3260
+ s -= 1;
3261
+ }
3262
+ return !1;
3263
+ }
3264
+ var Rr = {};
3265
+ mt(Rr, {
3266
+ createAtomBlockMarkdownSpec: () => zr,
3267
+ createBlockMarkdownSpec: () => Ir,
3268
+ createInlineMarkdownSpec: () => jr,
3269
+ parseAttributes: () => xt,
3270
+ parseIndentedBlocks: () => Or,
3271
+ renderNestedMarkdownContent: () => Dr,
3272
+ serializeAttributes: () => Et
3273
+ });
3274
+ function xt(e) {
3275
+ if (!e?.trim())
3276
+ return {};
3277
+ const t = {}, n = [], r = e.replace(/["']([^"']*)["']/g, (l) => (n.push(l), `__QUOTED_${n.length - 1}__`)), s = r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);
3278
+ if (s) {
3279
+ const l = s.map((d) => d.trim().slice(1));
3280
+ t.class = l.join(" ");
3281
+ }
3282
+ const o = r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);
3283
+ o && (t.id = o[1]);
3284
+ const i = /([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;
3285
+ Array.from(r.matchAll(i)).forEach(([, l, d]) => {
3286
+ var u;
3287
+ const f = parseInt(((u = d.match(/__QUOTED_(\d+)__/)) == null ? void 0 : u[1]) || "0", 10), p = n[f];
3288
+ p && (t[l] = p.slice(1, -1));
3289
+ });
3290
+ const c = r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g, "").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g, "").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g, "").trim();
3291
+ return c && c.split(/\s+/).filter(Boolean).forEach((d) => {
3292
+ d.match(/^[a-zA-Z][\w-]*$/) && (t[d] = !0);
3293
+ }), t;
3294
+ }
3295
+ function Et(e) {
3296
+ if (!e || Object.keys(e).length === 0)
3297
+ return "";
3298
+ const t = [];
3299
+ return e.class && String(e.class).split(/\s+/).filter(Boolean).forEach((r) => t.push(`.${r}`)), e.id && t.push(`#${e.id}`), Object.entries(e).forEach(([n, r]) => {
3300
+ n === "class" || n === "id" || (r === !0 ? t.push(n) : r !== !1 && r != null && t.push(`${n}="${String(r)}"`));
3301
+ }), t.join(" ");
3302
+ }
3303
+ function zr(e) {
3304
+ const {
3305
+ nodeName: t,
3306
+ name: n,
3307
+ parseAttributes: r = xt,
3308
+ serializeAttributes: s = Et,
3309
+ defaultAttributes: o = {},
3310
+ requiredAttributes: i = [],
3311
+ allowedAttributes: a
3312
+ } = e, c = n || t, l = (d) => {
3313
+ if (!a)
3314
+ return d;
3315
+ const u = {};
3316
+ return a.forEach((f) => {
3317
+ f in d && (u[f] = d[f]);
3318
+ }), u;
3319
+ };
3320
+ return {
3321
+ parseMarkdown: (d, u) => {
3322
+ const f = { ...o, ...d.attributes };
3323
+ return u.createNode(t, f, []);
3324
+ },
3325
+ markdownTokenizer: {
3326
+ name: t,
3327
+ level: "block",
3328
+ start(d) {
3329
+ var u;
3330
+ const f = new RegExp(`^:::${c}(?:\\s|$)`, "m"), p = (u = d.match(f)) == null ? void 0 : u.index;
3331
+ return p !== void 0 ? p : -1;
3332
+ },
3333
+ tokenize(d, u, f) {
3334
+ const p = new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`), h = d.match(p);
3335
+ if (!h)
3336
+ return;
3337
+ const m = h[1] || "", g = r(m);
3338
+ if (!i.find((b) => !(b in g)))
3339
+ return {
3340
+ type: t,
3341
+ raw: h[0],
3342
+ attributes: g
3343
+ };
3344
+ }
3345
+ },
3346
+ renderMarkdown: (d) => {
3347
+ const u = l(d.attrs || {}), f = s(u), p = f ? ` {${f}}` : "";
3348
+ return `:::${c}${p} :::`;
3349
+ }
3350
+ };
3351
+ }
3352
+ function Ir(e) {
3353
+ const {
3354
+ nodeName: t,
3355
+ name: n,
3356
+ getContent: r,
3357
+ parseAttributes: s = xt,
3358
+ serializeAttributes: o = Et,
3359
+ defaultAttributes: i = {},
3360
+ content: a = "block",
3361
+ allowedAttributes: c
3362
+ } = e, l = n || t, d = (u) => {
3363
+ if (!c)
3364
+ return u;
3365
+ const f = {};
3366
+ return c.forEach((p) => {
3367
+ p in u && (f[p] = u[p]);
3368
+ }), f;
3369
+ };
3370
+ return {
3371
+ parseMarkdown: (u, f) => {
3372
+ let p;
3373
+ if (r) {
3374
+ const m = r(u);
3375
+ p = typeof m == "string" ? [{ type: "text", text: m }] : m;
3376
+ } else a === "block" ? p = f.parseChildren(u.tokens || []) : p = f.parseInline(u.tokens || []);
3377
+ const h = { ...i, ...u.attributes };
3378
+ return f.createNode(t, h, p);
3379
+ },
3380
+ markdownTokenizer: {
3381
+ name: t,
3382
+ level: "block",
3383
+ start(u) {
3384
+ var f;
3385
+ const p = new RegExp(`^:::${l}`, "m"), h = (f = u.match(p)) == null ? void 0 : f.index;
3386
+ return h !== void 0 ? h : -1;
3387
+ },
3388
+ tokenize(u, f, p) {
3389
+ var h;
3390
+ const m = new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*\\n`), g = u.match(m);
3391
+ if (!g)
3392
+ return;
3393
+ const [v, b = ""] = g, k = s(b);
3394
+ let M = 1;
3395
+ const w = v.length;
3396
+ let x = "";
3397
+ const E = /^:::([\w-]*)(\s.*)?/gm, A = u.slice(w);
3398
+ for (E.lastIndex = 0; ; ) {
3399
+ const C = E.exec(A);
3400
+ if (C === null)
3401
+ break;
3402
+ const B = C.index, it = C[1];
3403
+ if (!((h = C[2]) != null && h.endsWith(":::"))) {
3404
+ if (it)
3405
+ M += 1;
3406
+ else if (M -= 1, M === 0) {
3407
+ const W = A.slice(0, B);
3408
+ x = W.trim();
3409
+ const at = u.slice(0, w + B + C[0].length);
3410
+ let I = [];
3411
+ if (x)
3412
+ if (a === "block")
3413
+ for (I = p.blockTokens(W), I.forEach(($) => {
3414
+ $.text && (!$.tokens || $.tokens.length === 0) && ($.tokens = p.inlineTokens($.text));
3415
+ }); I.length > 0; ) {
3416
+ const $ = I[I.length - 1];
3417
+ if ($.type === "paragraph" && (!$.text || $.text.trim() === ""))
3418
+ I.pop();
3419
+ else
3420
+ break;
3421
+ }
3422
+ else
3423
+ I = p.inlineTokens(x);
3424
+ return {
3425
+ type: t,
3426
+ raw: at,
3427
+ attributes: k,
3428
+ content: x,
3429
+ tokens: I
3430
+ };
3431
+ }
3432
+ }
3433
+ }
3434
+ }
3435
+ },
3436
+ renderMarkdown: (u, f) => {
3437
+ const p = d(u.attrs || {}), h = o(p), m = h ? ` {${h}}` : "", g = f.renderChildren(u.content || [], `
3438
+
3439
+ `);
3440
+ return `:::${l}${m}
3441
+
3442
+ ${g}
3443
+
3444
+ :::`;
3445
+ }
3446
+ };
3447
+ }
3448
+ function _r(e) {
3449
+ if (!e.trim())
3450
+ return {};
3451
+ const t = {}, n = /(\w+)=(?:"([^"]*)"|'([^']*)')/g;
3452
+ let r = n.exec(e);
3453
+ for (; r !== null; ) {
3454
+ const [, s, o, i] = r;
3455
+ t[s] = o || i, r = n.exec(e);
3456
+ }
3457
+ return t;
3458
+ }
3459
+ function Br(e) {
3460
+ return Object.entries(e).filter(([, t]) => t != null).map(([t, n]) => `${t}="${n}"`).join(" ");
3461
+ }
3462
+ function jr(e) {
3463
+ const {
3464
+ nodeName: t,
3465
+ name: n,
3466
+ getContent: r,
3467
+ parseAttributes: s = _r,
3468
+ serializeAttributes: o = Br,
3469
+ defaultAttributes: i = {},
3470
+ selfClosing: a = !1,
3471
+ allowedAttributes: c
3472
+ } = e, l = n || t, d = (f) => {
3473
+ if (!c)
3474
+ return f;
3475
+ const p = {};
3476
+ return c.forEach((h) => {
3477
+ h in f && (p[h] = f[h]);
3478
+ }), p;
3479
+ }, u = l.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3480
+ return {
3481
+ parseMarkdown: (f, p) => {
3482
+ const h = { ...i, ...f.attributes };
3483
+ if (a)
3484
+ return p.createNode(t, h);
3485
+ const m = r ? r(f) : f.content || "";
3486
+ return m ? p.createNode(t, h, [p.createTextNode(m)]) : p.createNode(t, h, []);
3487
+ },
3488
+ markdownTokenizer: {
3489
+ name: t,
3490
+ level: "inline",
3491
+ start(f) {
3492
+ const p = a ? new RegExp(`\\[${u}\\s*[^\\]]*\\]`) : new RegExp(`\\[${u}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${u}\\]`), h = f.match(p), m = h?.index;
3493
+ return m !== void 0 ? m : -1;
3494
+ },
3495
+ tokenize(f, p, h) {
3496
+ const m = a ? new RegExp(`^\\[${u}\\s*([^\\]]*)\\]`) : new RegExp(`^\\[${u}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${u}\\]`), g = f.match(m);
3497
+ if (!g)
3498
+ return;
3499
+ let v = "", b = "";
3500
+ if (a) {
3501
+ const [, M] = g;
3502
+ b = M;
3503
+ } else {
3504
+ const [, M, w] = g;
3505
+ b = M, v = w || "";
3506
+ }
3507
+ const k = s(b.trim());
3508
+ return {
3509
+ type: t,
3510
+ raw: g[0],
3511
+ content: v.trim(),
3512
+ attributes: k
3513
+ };
3514
+ }
3515
+ },
3516
+ renderMarkdown: (f) => {
3517
+ let p = "";
3518
+ r ? p = r(f) : f.content && f.content.length > 0 && (p = f.content.filter((v) => v.type === "text").map((v) => v.text).join(""));
3519
+ const h = d(f.attrs || {}), m = o(h), g = m ? ` ${m}` : "";
3520
+ return a ? `[${l}${g}]` : `[${l}${g}]${p}[/${l}]`;
3521
+ }
3522
+ };
3523
+ }
3524
+ function Or(e, t, n) {
3525
+ var r, s, o, i;
3526
+ const a = e.split(`
3527
+ `), c = [];
3528
+ let l = "", d = 0;
3529
+ const u = t.baseIndentSize || 2;
3530
+ for (; d < a.length; ) {
3531
+ const f = a[d], p = f.match(t.itemPattern);
3532
+ if (!p) {
3533
+ if (c.length > 0)
3534
+ break;
3535
+ if (f.trim() === "") {
3536
+ d += 1;
3537
+ continue;
3538
+ } else
3539
+ return;
3540
+ }
3541
+ const h = t.extractItemData(p), { indentLevel: m, mainContent: g } = h;
3542
+ l = `${l}${f}
3543
+ `;
3544
+ const v = [g];
3545
+ for (d += 1; d < a.length; ) {
3546
+ const w = a[d];
3547
+ if (w.trim() === "") {
3548
+ const E = a.slice(d + 1).findIndex((B) => B.trim() !== "");
3549
+ if (E === -1)
3550
+ break;
3551
+ if ((((s = (r = a[d + 1 + E].match(/^(\s*)/)) == null ? void 0 : r[1]) == null ? void 0 : s.length) || 0) > m) {
3552
+ v.push(w), l = `${l}${w}
3553
+ `, d += 1;
3554
+ continue;
3555
+ } else
3556
+ break;
3557
+ }
3558
+ if ((((i = (o = w.match(/^(\s*)/)) == null ? void 0 : o[1]) == null ? void 0 : i.length) || 0) > m)
3559
+ v.push(w), l = `${l}${w}
3560
+ `, d += 1;
3561
+ else
3562
+ break;
3563
+ }
3564
+ let b;
3565
+ const k = v.slice(1);
3566
+ if (k.length > 0) {
3567
+ const w = k.map((x) => x.slice(m + u)).join(`
3568
+ `);
3569
+ w.trim() && (t.customNestedParser ? b = t.customNestedParser(w) : b = n.blockTokens(w));
3570
+ }
3571
+ const M = t.createToken(h, b);
3572
+ c.push(M);
3573
+ }
3574
+ if (c.length !== 0)
3575
+ return {
3576
+ items: c,
3577
+ raw: l.trim()
3578
+ };
3579
+ }
3580
+ function Dr(e, t, n, r) {
3581
+ if (!e || !Array.isArray(e.content))
3582
+ return "";
3583
+ const s = typeof n == "function" ? n(r) : n, [o, ...i] = e.content, a = t.renderChildren([o]), c = [`${s}${a}`];
3584
+ return i && i.length > 0 && i.forEach((l) => {
3585
+ const d = t.renderChildren([l]);
3586
+ if (d) {
3587
+ const u = d.split(`
3588
+ `).map((f) => f ? t.indent(f) : "").join(`
3589
+ `);
3590
+ c.push(u);
3591
+ }
3592
+ }), c.join(`
3593
+ `);
3594
+ }
3595
+ function Lr(e, t, n = {}) {
3596
+ const { state: r } = t, { doc: s, tr: o } = r, i = e;
3597
+ s.descendants((a, c) => {
3598
+ const l = o.mapping.map(c), d = o.mapping.map(c) + a.nodeSize;
3599
+ let u = null;
3600
+ if (a.marks.forEach((p) => {
3601
+ if (p !== i)
3602
+ return !1;
3603
+ u = p;
3604
+ }), !u)
3605
+ return;
3606
+ let f = !1;
3607
+ if (Object.keys(n).forEach((p) => {
3608
+ n[p] !== u.attrs[p] && (f = !0);
3609
+ }), f) {
3610
+ const p = e.type.create({
3611
+ ...e.attrs,
3612
+ ...n
3613
+ });
3614
+ o.removeMark(l, d, e.type), o.addMark(l, d, p);
3615
+ }
3616
+ }), o.docChanged && t.view.dispatch(o);
3617
+ }
3618
+ var as = class ce extends St {
3619
+ constructor() {
3620
+ super(...arguments), this.type = "node";
3621
+ }
3622
+ /**
3623
+ * Create a new Node instance
3624
+ * @param config - Node configuration object or a function that returns a configuration object
3625
+ */
3626
+ static create(t = {}) {
3627
+ const n = typeof t == "function" ? t() : t;
3628
+ return new ce(n);
3629
+ }
3630
+ configure(t) {
3631
+ return super.configure(t);
3632
+ }
3633
+ extend(t) {
3634
+ const n = typeof t == "function" ? t() : t;
3635
+ return super.extend(n);
3636
+ }
3637
+ };
3638
+ function cs(e) {
3639
+ return new Mr({
3640
+ find: e.find,
3641
+ handler: ({ state: t, range: n, match: r, pasteEvent: s }) => {
3642
+ const o = S(e.getAttributes, void 0, r, s);
3643
+ if (o === !1 || o === null)
3644
+ return null;
3645
+ const { tr: i } = t, a = r[r.length - 1], c = r[0];
3646
+ let l = n.to;
3647
+ if (a) {
3648
+ const d = c.search(/\S/), u = n.from + c.indexOf(a), f = u + a.length;
3649
+ if (Jt(n.from, n.to, t.doc).filter((h) => h.mark.type.excluded.find((g) => g === e.type && g !== h.mark.type)).filter((h) => h.to > u).length)
3650
+ return null;
3651
+ f < n.to && i.delete(f, n.to), u > n.from && i.delete(n.from + d, u), l = n.from + d + a.length, i.addMark(n.from + d, l, e.type.create(o || {})), i.removeStoredMark(e.type);
3652
+ }
3653
+ }
3654
+ });
3655
+ }
3656
+ var ls = (e, t) => {
3657
+ if (e === "slot")
3658
+ return 0;
3659
+ if (e instanceof Function)
3660
+ return e(t);
3661
+ const { children: n, ...r } = t ?? {};
3662
+ if (e === "svg")
3663
+ throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");
3664
+ return [e, r, n];
3665
+ };
3666
+ export {
3667
+ wt as A,
3668
+ Gr as B,
3669
+ z as E,
3670
+ wr as M,
3671
+ as as N,
3672
+ os as R,
3673
+ cs as a,
3674
+ es as b,
3675
+ is as c,
3676
+ _n as d,
3677
+ Jt as e,
3678
+ Jr as f,
3679
+ Jn as g,
3680
+ ls as h,
3681
+ Qr as i,
3682
+ Un as j,
3683
+ H as k,
3684
+ Zr as l,
3685
+ Dn as m,
3686
+ ns as n,
3687
+ Yr as o,
3688
+ T as p,
3689
+ Xr as q,
3690
+ Dr as r,
3691
+ Or as s,
3692
+ rs as t,
3693
+ S as u,
3694
+ y as v,
3695
+ ss as w,
3696
+ jn as x,
3697
+ Mt as y,
3698
+ Ar as z
3699
+ };