@vc-shell/framework 1.1.91-alpha.4 → 1.1.91

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 (103) hide show
  1. package/CHANGELOG.md +2757 -1410
  2. package/core/api/platform.ts +9883 -9883
  3. package/core/composables/useNotifications/index.ts +1 -32
  4. package/core/composables/useSettings/index.ts +3 -8
  5. package/core/composables/useUser/index.ts +171 -74
  6. package/core/composables/useUserManagement/index.ts +25 -67
  7. package/core/interceptors/index.ts +56 -19
  8. package/core/plugins/signalR/index.ts +1 -27
  9. package/core/types/index.ts +0 -2
  10. package/dist/core/api/platform.d.ts +1 -1
  11. package/dist/core/api/platform.d.ts.map +1 -1
  12. package/dist/core/composables/useNotifications/index.d.ts.map +1 -1
  13. package/dist/core/composables/useSettings/index.d.ts.map +1 -1
  14. package/dist/core/composables/useUser/index.d.ts +9 -18
  15. package/dist/core/composables/useUser/index.d.ts.map +1 -1
  16. package/dist/core/composables/useUserManagement/index.d.ts +7 -7
  17. package/dist/core/composables/useUserManagement/index.d.ts.map +1 -1
  18. package/dist/core/interceptors/index.d.ts +1 -2
  19. package/dist/core/interceptors/index.d.ts.map +1 -1
  20. package/dist/core/plugins/signalR/index.d.ts +0 -2
  21. package/dist/core/plugins/signalR/index.d.ts.map +1 -1
  22. package/dist/core/types/index.d.ts +1 -1
  23. package/dist/core/types/index.d.ts.map +1 -1
  24. package/dist/framework.js +5682 -5832
  25. package/dist/index.css +1 -1
  26. package/dist/index.d.ts +0 -8
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/injection-keys.d.ts +1 -2
  29. package/dist/injection-keys.d.ts.map +1 -1
  30. package/dist/shared/components/app-switcher/composables/useAppSwitcher/index.d.ts.map +1 -1
  31. package/dist/shared/components/sign-in/useExternalProvider.d.ts +1 -1
  32. package/dist/shared/components/sign-in/useExternalProvider.d.ts.map +1 -1
  33. package/dist/shared/modules/dynamic/helpers/nodeBuilder.d.ts.map +1 -1
  34. package/dist/tsconfig.tsbuildinfo +1 -1
  35. package/dist/ui/components/organisms/vc-app/vc-app.vue.d.ts.map +1 -1
  36. package/dist/vendor-dompurify-BuxjWxA2.js +553 -0
  37. package/dist/{vendor-prosemirror-gapcursor-K-Pj0iVP.js → vendor-prosemirror-gapcursor-CoNzHXkd.js} +27 -24
  38. package/dist/{vendor-tiptap-core-B000Ay3n.js → vendor-tiptap-core-D6CfVeU0.js} +1838 -1502
  39. package/dist/{vendor-tiptap-extension-blockquote-CHW3QVCH.js → vendor-tiptap-extension-blockquote-C__lIvqD.js} +19 -6
  40. package/dist/{vendor-tiptap-extension-bold-DsNXR7l5.js → vendor-tiptap-extension-bold-DF2R0mPF.js} +13 -10
  41. package/dist/{vendor-tiptap-extension-code-block-DYMOFxJc.js → vendor-tiptap-extension-code-block-B52VzS4M.js} +34 -16
  42. package/dist/{vendor-tiptap-extension-code-BXPfZcyf.js → vendor-tiptap-extension-code-f7eg00IH.js} +11 -8
  43. package/dist/vendor-tiptap-extension-document-UgQIRckz.js +12 -0
  44. package/dist/{vendor-tiptap-extension-hard-break-DfxtqTYW.js → vendor-tiptap-extension-hard-break-CYVqzABZ.js} +11 -9
  45. package/dist/{vendor-tiptap-extension-heading-BqN9fEEm.js → vendor-tiptap-extension-heading-BWwbIXKs.js} +11 -5
  46. package/dist/{vendor-tiptap-extension-horizontal-rule-Dl1wmLAo.js → vendor-tiptap-extension-horizontal-rule-DjIwBCkJ.js} +14 -11
  47. package/dist/{vendor-tiptap-extension-image-Cv28QlbA.js → vendor-tiptap-extension-image-CSFiALl1.js} +18 -8
  48. package/dist/{vendor-tiptap-extension-italic-B3WETSCz.js → vendor-tiptap-extension-italic-S1BFBPoJ.js} +15 -12
  49. package/dist/{vendor-tiptap-extension-link-CTWD6W1U.js → vendor-tiptap-extension-link-BII63Ad6.js} +101 -90
  50. package/dist/vendor-tiptap-extension-list-BiUARt_K.js +707 -0
  51. package/dist/vendor-tiptap-extension-paragraph-C7nR_Mg3.js +41 -0
  52. package/dist/vendor-tiptap-extension-placeholder-BoHVyYJs.js +1 -0
  53. package/dist/vendor-tiptap-extension-strike-D13ERA3E.js +64 -0
  54. package/dist/vendor-tiptap-extension-table-DsqCGn0S.js +368 -0
  55. package/dist/vendor-tiptap-extension-table-cell-qeLCoF6c.js +1 -0
  56. package/dist/vendor-tiptap-extension-table-header-qeLCoF6c.js +1 -0
  57. package/dist/vendor-tiptap-extension-table-row-qeLCoF6c.js +1 -0
  58. package/dist/vendor-tiptap-extension-text-D2Ap05bS.js +13 -0
  59. package/dist/{vendor-tiptap-extension-text-style-BiLsi9B8.js → vendor-tiptap-extension-text-style-6WFGdn9L.js} +1 -1
  60. package/dist/{vendor-tiptap-extension-underline-Bz_pv2E0.js → vendor-tiptap-extension-underline-CiLvGtsw.js} +29 -4
  61. package/dist/{vendor-tiptap-extensions-Crh_nh74.js → vendor-tiptap-extensions-0qImmpYJ.js} +88 -87
  62. package/dist/{vendor-tiptap-markdown-bGlioql8.js → vendor-tiptap-markdown-Dh06r1Sk.js} +1 -1
  63. package/dist/{vendor-tiptap-starter-kit-B3fY431M.js → vendor-tiptap-starter-kit-CQMmSEis.js} +17 -17
  64. package/dist/{vendor-tiptap-vue-3-CqWn44-V.js → vendor-tiptap-vue-3-B0kPYa3w.js} +1 -1
  65. package/dist/{vendor-vueuse-components-sgKpNzof.js → vendor-vueuse-components-B0zqjNRW.js} +1 -1
  66. package/dist/{vendor-vueuse-core-D0cN7FqY.js → vendor-vueuse-core-CYgwn-B2.js} +10 -10
  67. package/dist/{vendor-vueuse-shared-Pt0UEStA.js → vendor-vueuse-shared-B_uDJJ6V.js} +19 -19
  68. package/package.json +5 -7
  69. package/shared/components/app-switcher/components/vc-app-switcher/vc-app-switcher.vue +2 -2
  70. package/shared/components/app-switcher/composables/useAppSwitcher/index.ts +1 -15
  71. package/shared/components/sign-in/useExternalProvider.ts +1 -11
  72. package/shared/modules/dynamic/helpers/nodeBuilder.ts +3 -11
  73. package/ui/components/organisms/vc-app/vc-app.vue +2 -20
  74. package/core/providers/README.md +0 -176
  75. package/core/providers/auth-provider-manager.ts +0 -74
  76. package/core/providers/auth-provider-utils.ts +0 -26
  77. package/core/providers/example-custom-auth-provider.ts +0 -162
  78. package/core/providers/index.ts +0 -3
  79. package/core/providers/platform-auth-provider.ts +0 -207
  80. package/core/types/auth-provider.ts +0 -40
  81. package/dist/core/providers/auth-provider-manager.d.ts +0 -34
  82. package/dist/core/providers/auth-provider-manager.d.ts.map +0 -1
  83. package/dist/core/providers/auth-provider-utils.d.ts +0 -17
  84. package/dist/core/providers/auth-provider-utils.d.ts.map +0 -1
  85. package/dist/core/providers/example-custom-auth-provider.d.ts +0 -45
  86. package/dist/core/providers/example-custom-auth-provider.d.ts.map +0 -1
  87. package/dist/core/providers/index.d.ts +0 -3
  88. package/dist/core/providers/index.d.ts.map +0 -1
  89. package/dist/core/providers/platform-auth-provider.d.ts +0 -34
  90. package/dist/core/providers/platform-auth-provider.d.ts.map +0 -1
  91. package/dist/core/types/auth-provider.d.ts +0 -27
  92. package/dist/core/types/auth-provider.d.ts.map +0 -1
  93. package/dist/vendor-dompurify-C-JbJ3KX.js +0 -536
  94. package/dist/vendor-tiptap-extension-document-Y-jQl_8Q.js +0 -9
  95. package/dist/vendor-tiptap-extension-list-Da9Xfgwa.js +0 -420
  96. package/dist/vendor-tiptap-extension-paragraph-CSda9k3a.js +0 -31
  97. package/dist/vendor-tiptap-extension-placeholder-MI_ltlp7.js +0 -1
  98. package/dist/vendor-tiptap-extension-strike-Di5VtsLj.js +0 -61
  99. package/dist/vendor-tiptap-extension-table-DYCEjlpp.js +0 -311
  100. package/dist/vendor-tiptap-extension-table-cell-D5DL87Xa.js +0 -1
  101. package/dist/vendor-tiptap-extension-table-header-D5DL87Xa.js +0 -1
  102. package/dist/vendor-tiptap-extension-table-row-D5DL87Xa.js +0 -1
  103. package/dist/vendor-tiptap-extension-text-8vtzSN60.js +0 -8
@@ -1,15 +1,15 @@
1
- import { N as G, E as se, S as D, T as A, P, a as B, A as ie } from "./vendor-prosemirror-state-DUZYoLys.js";
2
- import { E as ae } from "./vendor-prosemirror-view-CesDChJC.js";
3
- import { a as ce } from "./vendor-prosemirror-keymap-CN6Hkrq2.js";
4
- import { f as le, c as ct, T as de, e as ue, l as fe, j as Tt, a as U, b as pe, R as me } from "./vendor-prosemirror-transform-BOkRqJ32.js";
5
- import { D as he, a as Ct, F as N, b as ge, d as nt, S as ve } from "./vendor-prosemirror-model-CiCy9gkA.js";
6
- import { c as ye, d as be, e as ke, j as we, a as Me, b as Se, f as Ee, g as xe, h as Te, l as Ce, i as Ae, n as Pe, s as $e, k as Ie, m as Ne, o as Oe, p as Be, q as yt, w as je } from "./vendor-prosemirror-commands-DlSOsoOz.js";
7
- import { l as Re, s as De, w as Fe } from "./vendor-prosemirror-schema-list-asS28-n3.js";
8
- var _e = Object.defineProperty, At = (e, t) => {
1
+ import { f as le, c as mt, T as de, e as ue, l as fe, j as Bt, a as Z, b as pe, R as me } from "./vendor-prosemirror-transform-BOkRqJ32.js";
2
+ import { c as he, d as ge, e as ve, j as be, a as ye, b as ke, f as we, g as Me, h as xe, l as Se, i as Ee, n as Te, s as Ae, k as Ce, m as $e, o as Pe, p as Ne, q as Tt, w as Ie } from "./vendor-prosemirror-commands-DlSOsoOz.js";
3
+ import { N as Y, E as Re, S as F, T as $, P as N, a as D, A as Be } from "./vendor-prosemirror-state-DUZYoLys.js";
4
+ import { D as je, a as jt, F as j, b as Oe, d as ct, S as _e } from "./vendor-prosemirror-model-CiCy9gkA.js";
5
+ import { l as De, s as ze, w as Fe } from "./vendor-prosemirror-schema-list-asS28-n3.js";
6
+ import { E as Le } from "./vendor-prosemirror-view-CesDChJC.js";
7
+ import { a as Ve } from "./vendor-prosemirror-keymap-CN6Hkrq2.js";
8
+ var He = Object.defineProperty, ht = (e, t) => {
9
9
  for (var n in t)
10
- _e(e, n, { get: t[n], enumerable: !0 });
10
+ He(e, n, { get: t[n], enumerable: !0 });
11
11
  };
12
- function X(e) {
12
+ function tt(e) {
13
13
  const { state: t, transaction: n } = e;
14
14
  let { selection: r } = n, { doc: o } = n, { storedMarks: s } = n;
15
15
  return {
@@ -34,7 +34,7 @@ function X(e) {
34
34
  }
35
35
  };
36
36
  }
37
- var Y = class {
37
+ var et = class {
38
38
  constructor(e) {
39
39
  this.editor = e.editor, this.rawCommands = this.editor.extensionManager.commands, this.customState = e.state;
40
40
  }
@@ -48,8 +48,8 @@ var Y = class {
48
48
  const { rawCommands: e, editor: t, state: n } = this, { view: r } = t, { tr: o } = n, s = this.buildProps(o);
49
49
  return Object.fromEntries(
50
50
  Object.entries(e).map(([i, a]) => [i, (...l) => {
51
- const d = a(...l)(s);
52
- return !o.getMeta("preventDispatch") && !this.hasCustomState && r.dispatch(o), d;
51
+ const u = a(...l)(s);
52
+ return !o.getMeta("preventDispatch") && !this.hasCustomState && r.dispatch(o), u;
53
53
  }])
54
54
  );
55
55
  }
@@ -60,16 +60,16 @@ var Y = class {
60
60
  return () => this.createCan();
61
61
  }
62
62
  createChain(e, t = !0) {
63
- const { rawCommands: n, editor: r, state: o } = this, { view: s } = r, i = [], a = !!e, c = e || o.tr, l = () => (!a && t && !c.getMeta("preventDispatch") && !this.hasCustomState && s.dispatch(c), i.every((u) => u === !0)), d = {
63
+ const { rawCommands: n, editor: r, state: o } = this, { view: s } = r, i = [], a = !!e, c = e || o.tr, l = () => (!a && t && !c.getMeta("preventDispatch") && !this.hasCustomState && s.dispatch(c), i.every((d) => d === !0)), u = {
64
64
  ...Object.fromEntries(
65
- Object.entries(n).map(([u, p]) => [u, (...g) => {
66
- const m = this.buildProps(c, t), h = p(...g)(m);
67
- return i.push(h), d;
65
+ Object.entries(n).map(([d, f]) => [d, (...m) => {
66
+ const h = this.buildProps(c, t), g = f(...m)(h);
67
+ return i.push(g), u;
68
68
  }])
69
69
  ),
70
70
  run: l
71
71
  };
72
- return d;
72
+ return u;
73
73
  }
74
74
  createCan(e) {
75
75
  const { rawCommands: t, state: n } = this, r = !1, o = e || n.tr, s = this.buildProps(o, r);
@@ -85,7 +85,7 @@ var Y = class {
85
85
  tr: e,
86
86
  editor: r,
87
87
  view: s,
88
- state: X({
88
+ state: tt({
89
89
  state: o,
90
90
  transaction: e
91
91
  }),
@@ -101,55 +101,245 @@ var Y = class {
101
101
  };
102
102
  return i;
103
103
  }
104
- }, Le = class {
105
- constructor() {
106
- this.callbacks = {};
107
- }
108
- on(e, t) {
109
- return this.callbacks[e] || (this.callbacks[e] = []), this.callbacks[e].push(t), this;
110
- }
111
- emit(e, ...t) {
112
- const n = this.callbacks[e];
113
- return n && n.forEach((r) => r.apply(this, t)), this;
114
- }
115
- off(e, t) {
116
- const n = this.callbacks[e];
117
- return n && (t ? this.callbacks[e] = n.filter((r) => r !== t) : delete this.callbacks[e]), this;
104
+ }, Ot = {};
105
+ ht(Ot, {
106
+ blur: () => We,
107
+ clearContent: () => qe,
108
+ clearNodes: () => Ue,
109
+ command: () => Ke,
110
+ createParagraphNear: () => Je,
111
+ cut: () => Ze,
112
+ deleteCurrentNode: () => Qe,
113
+ deleteNode: () => Ge,
114
+ deleteRange: () => Xe,
115
+ deleteSelection: () => Ye,
116
+ enter: () => tn,
117
+ exitCode: () => en,
118
+ extendMarkRange: () => nn,
119
+ first: () => rn,
120
+ focus: () => sn,
121
+ forEach: () => an,
122
+ insertContent: () => cn,
123
+ insertContentAt: () => un,
124
+ joinBackward: () => mn,
125
+ joinDown: () => pn,
126
+ joinForward: () => hn,
127
+ joinItemBackward: () => gn,
128
+ joinItemForward: () => vn,
129
+ joinTextblockBackward: () => bn,
130
+ joinTextblockForward: () => yn,
131
+ joinUp: () => fn,
132
+ keyboardShortcut: () => wn,
133
+ lift: () => Mn,
134
+ liftEmptyBlock: () => xn,
135
+ liftListItem: () => Sn,
136
+ newlineInCode: () => En,
137
+ resetAttributes: () => Tn,
138
+ scrollIntoView: () => An,
139
+ selectAll: () => Cn,
140
+ selectNodeBackward: () => $n,
141
+ selectNodeForward: () => Pn,
142
+ selectParentNode: () => Nn,
143
+ selectTextblockEnd: () => In,
144
+ selectTextblockStart: () => Rn,
145
+ setContent: () => Bn,
146
+ setMark: () => Xn,
147
+ setMeta: () => Yn,
148
+ setNode: () => tr,
149
+ setNodeSelection: () => er,
150
+ setTextSelection: () => nr,
151
+ sinkListItem: () => rr,
152
+ splitBlock: () => or,
153
+ splitListItem: () => sr,
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: () => mr,
163
+ wrapInList: () => hr
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), qe = (e = !0) => ({ commands: t }) => t.setContent("", { emitUpdate: e }), Ue = () => ({ state: e, tr: t, dispatch: n }) => {
169
+ const { selection: r } = t, { ranges: o } = r;
170
+ return n && o.forEach(({ $from: s, $to: i }) => {
171
+ e.doc.nodesBetween(s.pos, i.pos, (a, c) => {
172
+ if (a.type.isText)
173
+ return;
174
+ const { doc: l, mapping: u } = t, d = l.resolve(u.map(c)), f = l.resolve(u.map(c + a.nodeSize)), p = d.blockRange(f);
175
+ if (!p)
176
+ return;
177
+ const m = fe(p);
178
+ if (a.type.isTextblock) {
179
+ const { defaultType: h } = d.parent.contentMatchAt(d.index());
180
+ t.setNodeMarkup(p.start, h);
181
+ }
182
+ (m || m === 0) && t.lift(p, m);
183
+ });
184
+ }), !0;
185
+ }, Ke = (e) => (t) => e(t), Je = () => ({ state: e, dispatch: t }) => he(e, t), Ze = (e, t) => ({ editor: n, tr: r }) => {
186
+ const { state: o } = n, s = o.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, s.content), r.setSelection(new $(r.doc.resolve(Math.max(i - 1, 0)))), !0;
190
+ }, Qe = () => ({ tr: e, dispatch: t }) => {
191
+ const { selection: n } = e, r = n.$anchor.node();
192
+ if (r.content.size > 0)
193
+ return !1;
194
+ const o = e.selection.$anchor;
195
+ for (let s = o.depth; s > 0; s -= 1)
196
+ if (o.node(s).type === r.type) {
197
+ if (t) {
198
+ const a = o.before(s), c = o.after(s);
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];
118
210
  }
119
- once(e, t) {
120
- const n = (...r) => {
121
- this.off(e, n), t.apply(this, r);
122
- };
123
- return this.on(e, n);
211
+ return e;
212
+ }
213
+ var Ge = (e) => ({ tr: t, state: n, dispatch: r }) => {
214
+ const o = T(e, n.schema), s = t.selection.$anchor;
215
+ for (let i = s.depth; i > 0; i -= 1)
216
+ if (s.node(i).type === o) {
217
+ if (r) {
218
+ const c = s.before(i), l = s.after(i);
219
+ t.delete(c, l).scrollIntoView();
220
+ }
221
+ return !0;
222
+ }
223
+ return !1;
224
+ }, Xe = (e) => ({ tr: t, dispatch: n }) => {
225
+ const { from: r, to: o } = e;
226
+ return n && t.delete(r, o), !0;
227
+ }, Ye = () => ({ 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 G(e, t, n = { strict: !0 }) {
232
+ const r = Object.keys(t);
233
+ return r.length ? r.every((o) => n.strict ? t[o] === e[o] : gt(t[o]) ? t[o].test(e[o]) : t[o] === e[o]) : !0;
234
+ }
235
+ function _t(e, t, n = {}) {
236
+ return e.find((r) => r.type === t && G(
237
+ // Only check equality for the attributes that are provided
238
+ Object.fromEntries(Object.keys(n).map((o) => [o, r.attrs[o]])),
239
+ n
240
+ ));
241
+ }
242
+ function At(e, t, n = {}) {
243
+ return !!_t(e, t, n);
244
+ }
245
+ function vt(e, t, n) {
246
+ var r;
247
+ if (!e || !t)
248
+ return;
249
+ let o = e.parent.childAfter(e.parentOffset);
250
+ if ((!o.node || !o.node.marks.some((u) => u.type === t)) && (o = e.parent.childBefore(e.parentOffset)), !o.node || !o.node.marks.some((u) => u.type === t) || (n = n || ((r = o.node.marks[0]) == null ? void 0 : r.attrs), !_t([...o.node.marks], t, n)))
251
+ return;
252
+ let i = o.index, a = e.start() + o.offset, c = i + 1, l = a + o.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 I(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];
124
267
  }
125
- removeAllListeners() {
126
- this.callbacks = {};
268
+ return e;
269
+ }
270
+ var nn = (e, t = {}) => ({ tr: n, state: r, dispatch: o }) => {
271
+ const s = I(e, r.schema), { doc: i, selection: a } = n, { $from: c, from: l, to: u } = a;
272
+ if (o) {
273
+ const d = vt(c, s, t);
274
+ if (d && d.from <= l && d.to >= u) {
275
+ const f = $.create(i, d.from, d.to);
276
+ n.setSelection(f);
277
+ }
127
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;
128
286
  };
129
- function ze(e, t) {
130
- const n = new de(e);
131
- return t.forEach((r) => {
132
- r.steps.forEach((o) => {
133
- n.step(o);
134
- });
135
- }), n;
287
+ function Dt(e) {
288
+ return e instanceof $;
289
+ }
290
+ function _(e = 0, t = 0, n = 0) {
291
+ return Math.min(Math.max(e, t), n);
292
+ }
293
+ function zt(e, t = null) {
294
+ if (!t)
295
+ return null;
296
+ const n = F.atStart(e), r = F.atEnd(e);
297
+ if (t === "start" || t === !0)
298
+ return n;
299
+ if (t === "end")
300
+ return r;
301
+ const o = n.from, s = r.to;
302
+ return t === "all" ? $.create(e, _(0, o, s), _(e.content.size, o, s)) : $.create(e, _(t, o, s), _(t, o, s));
303
+ }
304
+ function on() {
305
+ return navigator.platform === "Android" || /android/i.test(navigator.userAgent);
306
+ }
307
+ function bt() {
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;
136
310
  }
137
- var Pt = (e) => {
311
+ var sn = (e = null, t = {}) => ({ editor: n, view: r, tr: o, dispatch: s }) => {
312
+ t = {
313
+ scrollIntoView: !0,
314
+ ...t
315
+ };
316
+ const i = () => {
317
+ (bt() || on()) && 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 (s && e === null && !Dt(n.state.selection))
324
+ return i(), !0;
325
+ const a = zt(o.doc, e) || n.state.selection, c = n.state.selection.eq(a);
326
+ return s && (c || o.setSelection(a), c && o.storedMarks && o.setStoredMarks(o.storedMarks), i()), !0;
327
+ }, an = (e, t) => (n) => e.every((r, o) => t(r, { ...n, index: o })), cn = (e, t) => ({ tr: n, commands: r }) => r.insertContentAt({ from: n.selection.from, to: n.selection.to }, e, t), Ft = (e) => {
138
328
  const t = e.childNodes;
139
329
  for (let n = t.length - 1; n >= 0; n -= 1) {
140
330
  const r = t[n];
141
- r.nodeType === 3 && r.nodeValue && /^(\n\s\s|\n)$/.test(r.nodeValue) ? e.removeChild(r) : r.nodeType === 1 && Pt(r);
331
+ r.nodeType === 3 && r.nodeValue && /^(\n\s\s|\n)$/.test(r.nodeValue) ? e.removeChild(r) : r.nodeType === 1 && Ft(r);
142
332
  }
143
333
  return e;
144
334
  };
145
- function z(e) {
335
+ function q(e) {
146
336
  if (typeof window > "u")
147
337
  throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");
148
338
  const t = `<body>${e}</body>`, n = new window.DOMParser().parseFromString(t, "text/html").body;
149
- return Pt(n);
339
+ return Ft(n);
150
340
  }
151
- function F(e, t, n) {
152
- if (e instanceof ge || e instanceof N)
341
+ function L(e, t, n) {
342
+ if (e instanceof Oe || e instanceof j)
153
343
  return e;
154
344
  n = {
155
345
  slice: !0,
@@ -160,18 +350,18 @@ function F(e, t, n) {
160
350
  if (r)
161
351
  try {
162
352
  if (Array.isArray(e) && e.length > 0)
163
- return N.fromArray(e.map((a) => t.nodeFromJSON(a)));
353
+ return j.fromArray(e.map((a) => t.nodeFromJSON(a)));
164
354
  const i = t.nodeFromJSON(e);
165
355
  return n.errorOnInvalidContent && i.check(), i;
166
356
  } catch (s) {
167
357
  if (n.errorOnInvalidContent)
168
358
  throw new Error("[tiptap error]: Invalid JSON content", { cause: s });
169
- return console.warn("[tiptap warn]: Invalid content.", "Passed value:", e, "Error:", s), F("", t, n);
359
+ return console.warn("[tiptap warn]: Invalid content.", "Passed value:", e, "Error:", s), L("", t, n);
170
360
  }
171
361
  if (o) {
172
362
  if (n.errorOnInvalidContent) {
173
363
  let i = !1, a = "";
174
- const c = new Ct({
364
+ const c = new jt({
175
365
  topNode: t.spec.topNode,
176
366
  marks: t.spec.marks,
177
367
  // Prosemirror's schemas are executed such that: the last to execute, matches last
@@ -189,85 +379,299 @@ function F(e, t, n) {
189
379
  }
190
380
  })
191
381
  });
192
- if (n.slice ? nt.fromSchema(c).parseSlice(z(e), n.parseOptions) : nt.fromSchema(c).parse(z(e), n.parseOptions), n.errorOnInvalidContent && i)
382
+ if (n.slice ? ct.fromSchema(c).parseSlice(q(e), n.parseOptions) : ct.fromSchema(c).parse(q(e), n.parseOptions), n.errorOnInvalidContent && i)
193
383
  throw new Error("[tiptap error]: Invalid HTML content", {
194
384
  cause: new Error(`Invalid element found: ${a}`)
195
385
  });
196
386
  }
197
- const s = nt.fromSchema(t);
198
- return n.slice ? s.parseSlice(z(e), n.parseOptions).content : s.parse(z(e), n.parseOptions);
387
+ const s = ct.fromSchema(t);
388
+ return n.slice ? s.parseSlice(q(e), n.parseOptions).content : s.parse(q(e), n.parseOptions);
199
389
  }
200
- return F("", t, n);
390
+ return L("", t, n);
201
391
  }
202
- function it(e, t, n = {}, r = {}) {
203
- return F(e, t, {
204
- slice: !1,
205
- parseOptions: n,
206
- errorOnInvalidContent: r.errorOnInvalidContent
207
- });
392
+ function ln(e, t, n) {
393
+ const r = e.steps.length - 1;
394
+ if (r < t)
395
+ return;
396
+ const o = e.steps[r];
397
+ if (!(o instanceof pe || o instanceof me))
398
+ return;
399
+ const s = e.mapping.maps[r];
400
+ let i = 0;
401
+ s.forEach((a, c, l, u) => {
402
+ i === 0 && (i = u);
403
+ }), e.setSelection(F.near(e.doc.resolve(i), n));
208
404
  }
209
- function Ve(e) {
210
- for (let t = 0; t < e.edgeCount; t += 1) {
211
- const { type: n } = e.edge(t);
212
- if (n.isTextblock && !n.hasRequiredAttrs())
213
- return n;
405
+ var dn = (e) => !("type" in e), un = (e, t, n) => ({ tr: r, dispatch: o, editor: s }) => {
406
+ var i;
407
+ if (o) {
408
+ n = {
409
+ parseOptions: s.options.parseOptions,
410
+ updateSelection: !0,
411
+ applyInputRules: !1,
412
+ applyPasteRules: !1,
413
+ ...n
414
+ };
415
+ let a;
416
+ const c = (g) => {
417
+ s.emit("contentError", {
418
+ editor: s,
419
+ error: g,
420
+ disableCollaboration: () => {
421
+ "collaboration" in s.storage && typeof s.storage.collaboration == "object" && s.storage.collaboration && (s.storage.collaboration.isDisabled = !0);
422
+ }
423
+ });
424
+ }, l = {
425
+ preserveWhitespace: "full",
426
+ ...n.parseOptions
427
+ };
428
+ if (!n.errorOnInvalidContent && !s.options.enableContentCheck && s.options.emitContentError)
429
+ try {
430
+ L(t, s.schema, {
431
+ parseOptions: l,
432
+ errorOnInvalidContent: !0
433
+ });
434
+ } catch (g) {
435
+ c(g);
436
+ }
437
+ try {
438
+ a = L(t, s.schema, {
439
+ parseOptions: l,
440
+ errorOnInvalidContent: (i = n.errorOnInvalidContent) != null ? i : s.options.enableContentCheck
441
+ });
442
+ } catch (g) {
443
+ return c(g), !1;
444
+ }
445
+ let { from: u, to: d } = 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
+ }), u === d && p) {
449
+ const { parent: g } = r.doc.resolve(u);
450
+ g.isTextblock && !g.type.spec.code && !g.childCount && (u -= 1, d += 1);
451
+ }
452
+ let h;
453
+ if (f) {
454
+ if (Array.isArray(t))
455
+ h = t.map((g) => g.text || "").join("");
456
+ else if (t instanceof j) {
457
+ let g = "";
458
+ t.forEach((v) => {
459
+ v.text && (g += v.text);
460
+ }), h = g;
461
+ } else typeof t == "object" && t && t.text ? h = t.text : h = t;
462
+ r.insertText(h, u, d);
463
+ } else {
464
+ h = a;
465
+ const g = r.doc.resolve(u), v = g.node(), y = g.parentOffset === 0, w = v.isText || v.isTextblock, M = v.content.size > 0;
466
+ y && w && M && (u = Math.max(0, u - 1)), r.replaceWith(u, d, h);
467
+ }
468
+ n.updateSelection && ln(r, r.steps.length - 1, -1), n.applyInputRules && r.setMeta("applyInputRules", { from: u, text: h }), n.applyPasteRules && r.setMeta("applyPasteRules", { from: u, text: h });
214
469
  }
215
- return null;
216
- }
217
- function jr(e, t, n) {
218
- const r = [];
219
- return e.nodesBetween(t.from, t.to, (o, s) => {
220
- n(o) && r.push({
221
- node: o,
222
- pos: s
223
- });
224
- }), r;
225
- }
226
- function He(e, t) {
227
- for (let n = e.depth; n > 0; n -= 1) {
228
- const r = e.node(n);
229
- if (t(r))
230
- return {
231
- pos: n > 0 ? e.before(n) : 0,
232
- start: e.start(n),
233
- depth: n,
234
- node: r
235
- };
470
+ return !0;
471
+ }, fn = () => ({ state: e, dispatch: t }) => be(e, t), pn = () => ({ state: e, dispatch: t }) => ye(e, t), mn = () => ({ state: e, dispatch: t }) => ke(e, t), hn = () => ({ state: e, dispatch: t }) => we(e, t), gn = () => ({ state: e, dispatch: t, tr: n }) => {
472
+ try {
473
+ const r = Bt(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;
236
477
  }
478
+ }, vn = () => ({ state: e, dispatch: t, tr: n }) => {
479
+ try {
480
+ const r = Bt(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
+ }, bn = () => ({ state: e, dispatch: t }) => Me(e, t), yn = () => ({ state: e, dispatch: t }) => xe(e, t);
486
+ function Lt() {
487
+ return typeof navigator < "u" ? /Mac/.test(navigator.platform) : !1;
237
488
  }
238
- function Q(e) {
239
- return (t) => He(t.$from, e);
240
- }
241
- function y(e, t, n) {
242
- return e.config[t] === void 0 && e.parent ? y(e.parent, t, n) : typeof e.config[t] == "function" ? e.config[t].bind({
243
- ...n,
244
- parent: e.parent ? y(e.parent, t, n) : null
245
- }) : e.config[t];
246
- }
247
- function lt(e) {
248
- return e.map((t) => {
249
- const n = {
250
- name: t.name,
251
- options: t.options,
252
- storage: t.storage
253
- }, r = y(t, "addExtensions", n);
254
- return r ? [t, ...lt(r())] : t;
255
- }).flat(10);
256
- }
257
- function dt(e, t) {
258
- const n = he.fromSchema(t).serializeFragment(e), o = document.implementation.createHTMLDocument().createElement("div");
259
- return o.appendChild(n), o.innerHTML;
260
- }
261
- function $t(e) {
262
- return typeof e == "function";
263
- }
264
- function w(e, t = void 0, ...n) {
265
- return $t(e) ? t ? e.bind(t)(...n) : e(...n) : e;
266
- }
267
- function We(e = {}) {
268
- return Object.keys(e).length === 0 && e.constructor === Object;
489
+ function kn(e) {
490
+ const t = e.split(/-(?!$)/);
491
+ let n = t[t.length - 1];
492
+ n === "Space" && (n = " ");
493
+ let r, o, s, 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
+ o = !0;
502
+ else if (/^s(hift)?$/i.test(c))
503
+ s = !0;
504
+ else if (/^mod$/i.test(c))
505
+ bt() || Lt() ? i = !0 : o = !0;
506
+ else
507
+ throw new Error(`Unrecognized modifier name: ${c}`);
508
+ }
509
+ return r && (n = `Alt-${n}`), o && (n = `Ctrl-${n}`), i && (n = `Meta-${n}`), s && (n = `Shift-${n}`), n;
269
510
  }
270
- function _(e) {
511
+ var wn = (e) => ({ editor: t, view: n, tr: r, dispatch: o }) => {
512
+ const s = kn(e).split(/-(?!$)/), i = s.find((l) => !["Alt", "Ctrl", "Meta", "Shift"].includes(l)), a = new KeyboardEvent("keydown", {
513
+ key: i === "Space" ? " " : i,
514
+ altKey: s.includes("Alt"),
515
+ ctrlKey: s.includes("Ctrl"),
516
+ metaKey: s.includes("Meta"),
517
+ shiftKey: s.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 u = l.map(r.mapping);
525
+ u && o && r.maybeStep(u);
526
+ }), !0;
527
+ };
528
+ function V(e, t, n = {}) {
529
+ const { from: r, to: o, empty: s } = e.selection, i = t ? T(t, e.schema) : null, a = [];
530
+ e.doc.nodesBetween(r, o, (d, f) => {
531
+ if (d.isText)
532
+ return;
533
+ const p = Math.max(r, f), m = Math.min(o, f + d.nodeSize);
534
+ a.push({
535
+ node: d,
536
+ from: p,
537
+ to: m
538
+ });
539
+ });
540
+ const c = o - r, l = a.filter((d) => i ? i.name === d.node.type.name : !0).filter((d) => G(d.node.attrs, n, { strict: !1 }));
541
+ return s ? !!l.length : l.reduce((d, f) => d + f.to - f.from, 0) >= c;
542
+ }
543
+ var Mn = (e, t = {}) => ({ state: n, dispatch: r }) => {
544
+ const o = T(e, n.schema);
545
+ return V(n, o, t) ? Se(n, r) : !1;
546
+ }, xn = () => ({ state: e, dispatch: t }) => Ee(e, t), Sn = (e) => ({ state: t, dispatch: n }) => {
547
+ const r = T(e, t.schema);
548
+ return De(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, o) => (n.includes(o) || (r[o] = e[o]), r), {});
556
+ }
557
+ var Tn = (e, t) => ({ tr: n, state: r, dispatch: o }) => {
558
+ let s = null, i = null;
559
+ const a = nt(
560
+ typeof e == "string" ? e : e.name,
561
+ r.schema
562
+ );
563
+ return a ? (a === "node" && (s = T(e, r.schema)), a === "mark" && (i = I(e, r.schema)), o && n.selection.ranges.forEach((c) => {
564
+ r.doc.nodesBetween(c.$from.pos, c.$to.pos, (l, u) => {
565
+ s && s === l.type && n.setNodeMarkup(u, void 0, Ct(l.attrs, t)), i && l.marks.length && l.marks.forEach((d) => {
566
+ i === d.type && n.addMark(u, u + l.nodeSize, i.create(Ct(d.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 Be(e.doc);
573
+ e.setSelection(n);
574
+ }
575
+ return !0;
576
+ }, $n = () => ({ state: e, dispatch: t }) => Ae(e, t), Pn = () => ({ state: e, dispatch: t }) => Ce(e, t), Nn = () => ({ state: e, dispatch: t }) => $e(e, t), In = () => ({ state: e, dispatch: t }) => Pe(e, t), Rn = () => ({ state: e, dispatch: t }) => Ne(e, t);
577
+ function ft(e, t, n = {}, r = {}) {
578
+ return L(e, t, {
579
+ slice: !1,
580
+ parseOptions: n,
581
+ errorOnInvalidContent: r.errorOnInvalidContent
582
+ });
583
+ }
584
+ var Bn = (e, { errorOnInvalidContent: t, emitUpdate: n = !0, parseOptions: r = {} } = {}) => ({ editor: o, tr: s, dispatch: i, commands: a }) => {
585
+ const { doc: c } = s;
586
+ if (r.preserveWhitespace !== "full") {
587
+ const l = ft(e, o.schema, r, {
588
+ errorOnInvalidContent: t ?? o.options.enableContentCheck
589
+ });
590
+ return i && s.replaceWith(0, c.content.size, l).setMeta("preventUpdate", !n), !0;
591
+ }
592
+ return i && s.setMeta("preventUpdate", !n), a.insertContentAt({ from: 0, to: c.content.size }, e, {
593
+ parseOptions: r,
594
+ errorOnInvalidContent: t ?? o.options.enableContentCheck
595
+ });
596
+ };
597
+ function Vt(e, t) {
598
+ const n = I(t, e.schema), { from: r, to: o, empty: s } = e.selection, i = [];
599
+ s ? (e.storedMarks && i.push(...e.storedMarks), i.push(...e.selection.$head.marks())) : e.doc.nodesBetween(r, o, (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 jn(e, t) {
606
+ const n = new de(e);
607
+ return t.forEach((r) => {
608
+ r.steps.forEach((o) => {
609
+ n.step(o);
610
+ });
611
+ }), n;
612
+ }
613
+ function On(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 Kr(e, t, n) {
622
+ const r = [];
623
+ return e.nodesBetween(t.from, t.to, (o, s) => {
624
+ n(o) && r.push({
625
+ node: o,
626
+ pos: s
627
+ });
628
+ }), r;
629
+ }
630
+ function _n(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) => _n(t.$from, e);
644
+ }
645
+ function b(e, t, n) {
646
+ return e.config[t] === void 0 && e.parent ? b(e.parent, t, n) : typeof e.config[t] == "function" ? e.config[t].bind({
647
+ ...n,
648
+ parent: e.parent ? b(e.parent, t, n) : null
649
+ }) : e.config[t];
650
+ }
651
+ function yt(e) {
652
+ return e.map((t) => {
653
+ const n = {
654
+ name: t.name,
655
+ options: t.options,
656
+ storage: t.storage
657
+ }, r = b(t, "addExtensions", n);
658
+ return r ? [t, ...yt(r())] : t;
659
+ }).flat(10);
660
+ }
661
+ function kt(e, t) {
662
+ const n = je.fromSchema(t).serializeFragment(e), o = document.implementation.createHTMLDocument().createElement("div");
663
+ return o.appendChild(n), o.innerHTML;
664
+ }
665
+ function Ht(e) {
666
+ return typeof e == "function";
667
+ }
668
+ function x(e, t = void 0, ...n) {
669
+ return Ht(e) ? t ? e.bind(t)(...n) : e(...n) : e;
670
+ }
671
+ function Dn(e = {}) {
672
+ return Object.keys(e).length === 0 && e.constructor === Object;
673
+ }
674
+ function H(e) {
271
675
  const t = e.filter((o) => o.type === "extension"), n = e.filter((o) => o.type === "node"), r = e.filter((o) => o.type === "mark");
272
676
  return {
273
677
  baseExtensions: t,
@@ -275,8 +679,8 @@ function _(e) {
275
679
  markExtensions: r
276
680
  };
277
681
  }
278
- function It(e) {
279
- const t = [], { nodeExtensions: n, markExtensions: r } = _(e), o = [...n, ...r], s = {
682
+ function Wt(e) {
683
+ const t = [], { nodeExtensions: n, markExtensions: r } = H(e), o = [...n, ...r], s = {
280
684
  default: null,
281
685
  validate: void 0,
282
686
  rendered: !0,
@@ -291,22 +695,22 @@ function It(e) {
291
695
  options: i.options,
292
696
  storage: i.storage,
293
697
  extensions: o
294
- }, c = y(
698
+ }, c = b(
295
699
  i,
296
700
  "addGlobalAttributes",
297
701
  a
298
702
  );
299
703
  if (!c)
300
704
  return;
301
- c().forEach((d) => {
302
- d.types.forEach((u) => {
303
- Object.entries(d.attributes).forEach(([p, f]) => {
705
+ c().forEach((u) => {
706
+ u.types.forEach((d) => {
707
+ Object.entries(u.attributes).forEach(([f, p]) => {
304
708
  t.push({
305
- type: u,
306
- name: p,
709
+ type: d,
710
+ name: f,
307
711
  attribute: {
308
712
  ...s,
309
- ...f
713
+ ...p
310
714
  }
311
715
  });
312
716
  });
@@ -317,7 +721,7 @@ function It(e) {
317
721
  name: i.name,
318
722
  options: i.options,
319
723
  storage: i.storage
320
- }, c = y(
724
+ }, c = b(
321
725
  i,
322
726
  "addAttributes",
323
727
  a
@@ -325,20 +729,20 @@ function It(e) {
325
729
  if (!c)
326
730
  return;
327
731
  const l = c();
328
- Object.entries(l).forEach(([d, u]) => {
329
- const p = {
732
+ Object.entries(l).forEach(([u, d]) => {
733
+ const f = {
330
734
  ...s,
331
- ...u
735
+ ...d
332
736
  };
333
- typeof p?.default == "function" && (p.default = p.default()), p?.isRequired && p?.default === void 0 && delete p.default, t.push({
737
+ typeof f?.default == "function" && (f.default = f.default()), f?.isRequired && f?.default === void 0 && delete f.default, t.push({
334
738
  type: i.name,
335
- name: d,
336
- attribute: p
739
+ name: u,
740
+ attribute: f
337
741
  });
338
742
  });
339
743
  }), t;
340
744
  }
341
- function Ue(...e) {
745
+ function zn(...e) {
342
746
  return e.filter((t) => !!t).reduce((t, n) => {
343
747
  const r = { ...t };
344
748
  return Object.entries(n).forEach(([o, s]) => {
@@ -347,31 +751,31 @@ function Ue(...e) {
347
751
  return;
348
752
  }
349
753
  if (o === "class") {
350
- const a = s ? String(s).split(" ") : [], c = r[o] ? r[o].split(" ") : [], l = a.filter((d) => !c.includes(d));
754
+ const a = s ? String(s).split(" ") : [], c = r[o] ? r[o].split(" ") : [], l = a.filter((u) => !c.includes(u));
351
755
  r[o] = [...c, ...l].join(" ");
352
756
  } else if (o === "style") {
353
- const a = s ? s.split(";").map((d) => d.trim()).filter(Boolean) : [], c = r[o] ? r[o].split(";").map((d) => d.trim()).filter(Boolean) : [], l = /* @__PURE__ */ new Map();
354
- c.forEach((d) => {
355
- const [u, p] = d.split(":").map((f) => f.trim());
356
- l.set(u, p);
357
- }), a.forEach((d) => {
358
- const [u, p] = d.split(":").map((f) => f.trim());
359
- l.set(u, p);
360
- }), r[o] = Array.from(l.entries()).map(([d, u]) => `${d}: ${u}`).join("; ");
757
+ const a = s ? s.split(";").map((u) => u.trim()).filter(Boolean) : [], c = r[o] ? r[o].split(";").map((u) => u.trim()).filter(Boolean) : [], l = /* @__PURE__ */ new Map();
758
+ c.forEach((u) => {
759
+ const [d, f] = u.split(":").map((p) => p.trim());
760
+ l.set(d, f);
761
+ }), a.forEach((u) => {
762
+ const [d, f] = u.split(":").map((p) => p.trim());
763
+ l.set(d, f);
764
+ }), r[o] = Array.from(l.entries()).map(([u, d]) => `${u}: ${d}`).join("; ");
361
765
  } else
362
766
  r[o] = s;
363
767
  }), r;
364
768
  }, {});
365
769
  }
366
- function K(e, t) {
770
+ function X(e, t) {
367
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) || {} : {
368
772
  [n.name]: e.attrs[n.name]
369
- }).reduce((n, r) => Ue(n, r), {});
773
+ }).reduce((n, r) => zn(n, r), {});
370
774
  }
371
- function qe(e) {
775
+ function Fn(e) {
372
776
  return typeof e != "string" ? e : e.match(/^[+-]?(?:\d*\.)?\d+$/) ? Number(e) : e === "true" ? !0 : e === "false" ? !1 : e;
373
777
  }
374
- function bt(e, t) {
778
+ function $t(e, t) {
375
779
  return "style" in e ? e : {
376
780
  ...e,
377
781
  getAttrs: (n) => {
@@ -379,7 +783,7 @@ function bt(e, t) {
379
783
  if (r === !1)
380
784
  return !1;
381
785
  const o = t.reduce((s, i) => {
382
- const a = i.attribute.parseHTML ? i.attribute.parseHTML(n) : qe(n.getAttribute(i.name));
786
+ const a = i.attribute.parseHTML ? i.attribute.parseHTML(n) : Fn(n.getAttribute(i.name));
383
787
  return a == null ? s : {
384
788
  ...s,
385
789
  [i.name]: a
@@ -389,212 +793,185 @@ function bt(e, t) {
389
793
  }
390
794
  };
391
795
  }
392
- function kt(e) {
796
+ function Pt(e) {
393
797
  return Object.fromEntries(
394
798
  // @ts-ignore
395
- Object.entries(e).filter(([t, n]) => t === "attrs" && We(n) ? !1 : n != null)
799
+ Object.entries(e).filter(([t, n]) => t === "attrs" && Dn(n) ? !1 : n != null)
396
800
  );
397
801
  }
398
- function Ke(e, t) {
802
+ function Ln(e, t) {
399
803
  var n;
400
- const r = It(e), { nodeExtensions: o, markExtensions: s } = _(e), i = (n = o.find((l) => y(l, "topNode"))) == null ? void 0 : n.name, a = Object.fromEntries(
804
+ const r = Wt(e), { nodeExtensions: o, markExtensions: s } = H(e), i = (n = o.find((l) => b(l, "topNode"))) == null ? void 0 : n.name, a = Object.fromEntries(
401
805
  o.map((l) => {
402
- const d = r.filter((v) => v.type === l.name), u = {
806
+ const u = r.filter((v) => v.type === l.name), d = {
403
807
  name: l.name,
404
808
  options: l.options,
405
809
  storage: l.storage,
406
810
  editor: t
407
- }, p = e.reduce((v, b) => {
408
- const k = y(b, "extendNodeSchema", u);
811
+ }, f = e.reduce((v, y) => {
812
+ const w = b(y, "extendNodeSchema", d);
409
813
  return {
410
814
  ...v,
411
- ...k ? k(l) : {}
815
+ ...w ? w(l) : {}
412
816
  };
413
- }, {}), f = kt({
414
- ...p,
415
- content: w(y(l, "content", u)),
416
- marks: w(y(l, "marks", u)),
417
- group: w(y(l, "group", u)),
418
- inline: w(y(l, "inline", u)),
419
- atom: w(y(l, "atom", u)),
420
- selectable: w(y(l, "selectable", u)),
421
- draggable: w(y(l, "draggable", u)),
422
- code: w(y(l, "code", u)),
423
- whitespace: w(y(l, "whitespace", u)),
424
- linebreakReplacement: w(
425
- y(l, "linebreakReplacement", u)
817
+ }, {}), p = Pt({
818
+ ...f,
819
+ content: x(b(l, "content", d)),
820
+ marks: x(b(l, "marks", d)),
821
+ group: x(b(l, "group", d)),
822
+ inline: x(b(l, "inline", d)),
823
+ atom: x(b(l, "atom", d)),
824
+ selectable: x(b(l, "selectable", d)),
825
+ draggable: x(b(l, "draggable", d)),
826
+ code: x(b(l, "code", d)),
827
+ whitespace: x(b(l, "whitespace", d)),
828
+ linebreakReplacement: x(
829
+ b(l, "linebreakReplacement", d)
426
830
  ),
427
- defining: w(y(l, "defining", u)),
428
- isolating: w(y(l, "isolating", u)),
831
+ defining: x(b(l, "defining", d)),
832
+ isolating: x(b(l, "isolating", d)),
429
833
  attrs: Object.fromEntries(
430
- d.map((v) => {
431
- var b, k;
834
+ u.map((v) => {
835
+ var y, w;
432
836
  return [
433
837
  v.name,
434
- { default: (b = v?.attribute) == null ? void 0 : b.default, validate: (k = v?.attribute) == null ? void 0 : k.validate }
838
+ { default: (y = v?.attribute) == null ? void 0 : y.default, validate: (w = v?.attribute) == null ? void 0 : w.validate }
435
839
  ];
436
840
  })
437
841
  )
438
- }), g = w(y(l, "parseHTML", u));
439
- g && (f.parseDOM = g.map(
440
- (v) => bt(v, d)
842
+ }), m = x(b(l, "parseHTML", d));
843
+ m && (p.parseDOM = m.map(
844
+ (v) => $t(v, u)
441
845
  ));
442
- const m = y(l, "renderHTML", u);
443
- m && (f.toDOM = (v) => m({
846
+ const h = b(l, "renderHTML", d);
847
+ h && (p.toDOM = (v) => h({
444
848
  node: v,
445
- HTMLAttributes: K(v, d)
849
+ HTMLAttributes: X(v, u)
446
850
  }));
447
- const h = y(l, "renderText", u);
448
- return h && (f.toText = h), [l.name, f];
851
+ const g = b(l, "renderText", d);
852
+ return g && (p.toText = g), [l.name, p];
449
853
  })
450
854
  ), c = Object.fromEntries(
451
855
  s.map((l) => {
452
- const d = r.filter((h) => h.type === l.name), u = {
856
+ const u = r.filter((g) => g.type === l.name), d = {
453
857
  name: l.name,
454
858
  options: l.options,
455
859
  storage: l.storage,
456
860
  editor: t
457
- }, p = e.reduce((h, v) => {
458
- const b = y(v, "extendMarkSchema", u);
861
+ }, f = e.reduce((g, v) => {
862
+ const y = b(v, "extendMarkSchema", d);
459
863
  return {
460
- ...h,
461
- ...b ? b(l) : {}
864
+ ...g,
865
+ ...y ? y(l) : {}
462
866
  };
463
- }, {}), f = kt({
464
- ...p,
465
- inclusive: w(y(l, "inclusive", u)),
466
- excludes: w(y(l, "excludes", u)),
467
- group: w(y(l, "group", u)),
468
- spanning: w(y(l, "spanning", u)),
469
- code: w(y(l, "code", u)),
867
+ }, {}), p = Pt({
868
+ ...f,
869
+ inclusive: x(b(l, "inclusive", d)),
870
+ excludes: x(b(l, "excludes", d)),
871
+ group: x(b(l, "group", d)),
872
+ spanning: x(b(l, "spanning", d)),
873
+ code: x(b(l, "code", d)),
470
874
  attrs: Object.fromEntries(
471
- d.map((h) => {
472
- var v, b;
875
+ u.map((g) => {
876
+ var v, y;
473
877
  return [
474
- h.name,
475
- { default: (v = h?.attribute) == null ? void 0 : v.default, validate: (b = h?.attribute) == null ? void 0 : b.validate }
878
+ g.name,
879
+ { default: (v = g?.attribute) == null ? void 0 : v.default, validate: (y = g?.attribute) == null ? void 0 : y.validate }
476
880
  ];
477
881
  })
478
882
  )
479
- }), g = w(y(l, "parseHTML", u));
480
- g && (f.parseDOM = g.map(
481
- (h) => bt(h, d)
883
+ }), m = x(b(l, "parseHTML", d));
884
+ m && (p.parseDOM = m.map(
885
+ (g) => $t(g, u)
482
886
  ));
483
- const m = y(l, "renderHTML", u);
484
- return m && (f.toDOM = (h) => m({
485
- mark: h,
486
- HTMLAttributes: K(h, d)
487
- })), [l.name, f];
887
+ const h = b(l, "renderHTML", d);
888
+ return h && (p.toDOM = (g) => h({
889
+ mark: g,
890
+ HTMLAttributes: X(g, u)
891
+ })), [l.name, p];
488
892
  })
489
893
  );
490
- return new Ct({
894
+ return new jt({
491
895
  topNode: i,
492
896
  nodes: a,
493
897
  marks: c
494
898
  });
495
899
  }
496
- function Je(e) {
900
+ function Vn(e) {
497
901
  const t = e.filter((n, r) => e.indexOf(n) !== r);
498
902
  return Array.from(new Set(t));
499
903
  }
500
- function ut(e) {
904
+ function wt(e) {
501
905
  return e.sort((n, r) => {
502
- const o = y(n, "priority") || 100, s = y(r, "priority") || 100;
906
+ const o = b(n, "priority") || 100, s = b(r, "priority") || 100;
503
907
  return o > s ? -1 : o < s ? 1 : 0;
504
908
  });
505
909
  }
506
- function Nt(e) {
507
- const t = ut(lt(e)), n = Je(t.map((r) => r.name));
910
+ function qt(e) {
911
+ const t = wt(yt(e)), n = Vn(t.map((r) => r.name));
508
912
  return n.length && console.warn(
509
913
  `[tiptap warn]: Duplicate extension names found: [${n.map((r) => `'${r}'`).join(", ")}]. This can lead to issues.`
510
914
  ), t;
511
915
  }
512
- function Ot(e, t, n) {
916
+ function Ut(e, t, n) {
513
917
  const { from: r, to: o } = t, { blockSeparator: s = `
514
918
 
515
919
  `, textSerializers: i = {} } = n || {};
516
920
  let a = "";
517
- return e.nodesBetween(r, o, (c, l, d, u) => {
518
- var p;
921
+ return e.nodesBetween(r, o, (c, l, u, d) => {
922
+ var f;
519
923
  c.isBlock && l > r && (a += s);
520
- const f = i?.[c.type.name];
521
- if (f)
522
- return d && (a += f({
924
+ const p = i?.[c.type.name];
925
+ if (p)
926
+ return u && (a += p({
523
927
  node: c,
524
928
  pos: l,
525
- parent: d,
526
- index: u,
929
+ parent: u,
930
+ index: d,
527
931
  range: t
528
932
  })), !1;
529
- c.isText && (a += (p = c?.text) == null ? void 0 : p.slice(Math.max(r, l) - l, o - l));
933
+ c.isText && (a += (f = c?.text) == null ? void 0 : f.slice(Math.max(r, l) - l, o - l));
530
934
  }), a;
531
935
  }
532
- function Ge(e, t) {
936
+ function Hn(e, t) {
533
937
  const n = {
534
938
  from: 0,
535
939
  to: e.content.size
536
940
  };
537
- return Ot(e, n, t);
941
+ return Ut(e, n, t);
538
942
  }
539
- function Bt(e) {
943
+ function Kt(e) {
540
944
  return Object.fromEntries(
541
945
  Object.entries(e.nodes).filter(([, t]) => t.spec.toText).map(([t, n]) => [t, n.spec.toText])
542
946
  );
543
947
  }
544
- function $(e, t) {
545
- if (typeof e == "string") {
546
- if (!t.marks[e])
547
- throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);
548
- return t.marks[e];
549
- }
550
- return e;
551
- }
552
- function jt(e, t) {
553
- const n = $(t, e.schema), { from: r, to: o, empty: s } = e.selection, i = [];
554
- s ? (e.storedMarks && i.push(...e.storedMarks), i.push(...e.selection.$head.marks())) : e.doc.nodesBetween(r, o, (c) => {
555
- i.push(...c.marks);
556
- });
557
- const a = i.find((c) => c.type.name === n.name);
558
- return a ? { ...a.attrs } : {};
559
- }
560
- function E(e, t) {
561
- if (typeof e == "string") {
562
- if (!t.nodes[e])
563
- throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);
564
- return t.nodes[e];
565
- }
566
- return e;
567
- }
568
- function Xe(e, t) {
569
- const n = E(t, e.schema), { from: r, to: o } = e.selection, s = [];
948
+ function Wn(e, t) {
949
+ const n = T(t, e.schema), { from: r, to: o } = e.selection, s = [];
570
950
  e.doc.nodesBetween(r, o, (a) => {
571
951
  s.push(a);
572
952
  });
573
953
  const i = s.reverse().find((a) => a.type.name === n.name);
574
954
  return i ? { ...i.attrs } : {};
575
955
  }
576
- function Z(e, t) {
577
- return t.nodes[e] ? "node" : t.marks[e] ? "mark" : null;
578
- }
579
- function Ye(e, t) {
580
- const n = Z(
956
+ function qn(e, t) {
957
+ const n = nt(
581
958
  typeof t == "string" ? t : t.name,
582
959
  e.schema
583
960
  );
584
- return n === "node" ? Xe(e, t) : n === "mark" ? jt(e, t) : {};
961
+ return n === "node" ? Wn(e, t) : n === "mark" ? Vt(e, t) : {};
585
962
  }
586
- function Qe(e, t = JSON.stringify) {
963
+ function Un(e, t = JSON.stringify) {
587
964
  const n = {};
588
965
  return e.filter((r) => {
589
966
  const o = t(r);
590
967
  return Object.prototype.hasOwnProperty.call(n, o) ? !1 : n[o] = !0;
591
968
  });
592
969
  }
593
- function Ze(e) {
594
- const t = Qe(e);
970
+ function Kn(e) {
971
+ const t = Un(e);
595
972
  return t.length === 1 ? t : t.filter((n, r) => !t.filter((s, i) => i !== r).some((s) => n.oldRange.from >= s.oldRange.from && n.oldRange.to <= s.oldRange.to && n.newRange.from >= s.newRange.from && n.newRange.to <= s.newRange.to));
596
973
  }
597
- function tn(e) {
974
+ function Jn(e) {
598
975
  const { mapping: t, steps: n } = e, r = [];
599
976
  return t.maps.forEach((o, s) => {
600
977
  const i = [];
@@ -609,58 +986,24 @@ function tn(e) {
609
986
  i.push({ from: a, to: c });
610
987
  }
611
988
  i.forEach(({ from: a, to: c }) => {
612
- const l = t.slice(s).map(a, -1), d = t.slice(s).map(c), u = t.invert().map(l, -1), p = t.invert().map(d);
989
+ const l = t.slice(s).map(a, -1), u = t.slice(s).map(c), d = t.invert().map(l, -1), f = t.invert().map(u);
613
990
  r.push({
614
991
  oldRange: {
615
- from: u,
616
- to: p
992
+ from: d,
993
+ to: f
617
994
  },
618
995
  newRange: {
619
996
  from: l,
620
- to: d
997
+ to: u
621
998
  }
622
999
  });
623
1000
  });
624
- }), Ze(r);
625
- }
626
- function ft(e) {
627
- return Object.prototype.toString.call(e) === "[object RegExp]";
628
- }
629
- function J(e, t, n = { strict: !0 }) {
630
- const r = Object.keys(t);
631
- return r.length ? r.every((o) => n.strict ? t[o] === e[o] : ft(t[o]) ? t[o].test(e[o]) : t[o] === e[o]) : !0;
632
- }
633
- function Rt(e, t, n = {}) {
634
- return e.find((r) => r.type === t && J(
635
- // Only check equality for the attributes that are provided
636
- Object.fromEntries(Object.keys(n).map((o) => [o, r.attrs[o]])),
637
- n
638
- ));
639
- }
640
- function wt(e, t, n = {}) {
641
- return !!Rt(e, t, n);
642
- }
643
- function pt(e, t, n) {
644
- var r;
645
- if (!e || !t)
646
- return;
647
- let o = e.parent.childAfter(e.parentOffset);
648
- if ((!o.node || !o.node.marks.some((d) => d.type === t)) && (o = e.parent.childBefore(e.parentOffset)), !o.node || !o.node.marks.some((d) => d.type === t) || (n = n || ((r = o.node.marks[0]) == null ? void 0 : r.attrs), !Rt([...o.node.marks], t, n)))
649
- return;
650
- let i = o.index, a = e.start() + o.offset, c = i + 1, l = a + o.node.nodeSize;
651
- for (; i > 0 && wt([...e.parent.child(i - 1).marks], t, n); )
652
- i -= 1, a -= e.parent.child(i).nodeSize;
653
- for (; c < e.parent.childCount && wt([...e.parent.child(c).marks], t, n); )
654
- l += e.parent.child(c).nodeSize, c += 1;
655
- return {
656
- from: a,
657
- to: l
658
- };
1001
+ }), Kn(r);
659
1002
  }
660
- function Dt(e, t, n) {
1003
+ function Jt(e, t, n) {
661
1004
  const r = [];
662
1005
  return e === t ? n.resolve(e).marks().forEach((o) => {
663
- const s = n.resolve(e), i = pt(s, o.type);
1006
+ const s = n.resolve(e), i = vt(s, o.type);
664
1007
  i && r.push({
665
1008
  mark: o,
666
1009
  ...i
@@ -675,7 +1018,7 @@ function Dt(e, t, n) {
675
1018
  );
676
1019
  }), r;
677
1020
  }
678
- var Rr = (e, t, n, r = 20) => {
1021
+ var Jr = (e, t, n, r = 20) => {
679
1022
  const o = e.doc.resolve(n);
680
1023
  let s = r, i = null;
681
1024
  for (; s > 0 && i === null; ) {
@@ -684,10 +1027,10 @@ var Rr = (e, t, n, r = 20) => {
684
1027
  }
685
1028
  return [i, s];
686
1029
  };
687
- function rt(e, t) {
1030
+ function lt(e, t) {
688
1031
  return t.nodes[e] || t.marks[e] || null;
689
1032
  }
690
- function q(e, t, n) {
1033
+ function Q(e, t, n) {
691
1034
  return Object.fromEntries(
692
1035
  Object.entries(n).filter(([r]) => {
693
1036
  const o = e.find((s) => s.type === t && s.name === r);
@@ -695,95 +1038,80 @@ function q(e, t, n) {
695
1038
  })
696
1039
  );
697
1040
  }
698
- var en = (e, t = 500) => {
1041
+ var Zn = (e, t = 500) => {
699
1042
  let n = "";
700
1043
  const r = e.parentOffset;
701
1044
  return e.parent.nodesBetween(Math.max(0, r - t), r, (o, s, i, a) => {
702
1045
  var c, l;
703
- const d = ((l = (c = o.type.spec).toText) == null ? void 0 : l.call(c, {
1046
+ const u = ((l = (c = o.type.spec).toText) == null ? void 0 : l.call(c, {
704
1047
  node: o,
705
1048
  pos: s,
706
1049
  parent: i,
707
1050
  index: a
708
1051
  })) || o.textContent || "%leaf%";
709
- n += o.isAtom && !o.isText ? d : d.slice(0, Math.max(0, r - s));
1052
+ n += o.isAtom && !o.isText ? u : u.slice(0, Math.max(0, r - s));
710
1053
  }), n;
711
1054
  };
712
- function at(e, t, n = {}) {
713
- const { empty: r, ranges: o } = e.selection, s = t ? $(t, e.schema) : null;
1055
+ function pt(e, t, n = {}) {
1056
+ const { empty: r, ranges: o } = e.selection, s = t ? I(t, e.schema) : null;
714
1057
  if (r)
715
- return !!(e.storedMarks || e.selection.$from.marks()).filter((u) => s ? s.name === u.type.name : !0).find((u) => J(u.attrs, n, { strict: !1 }));
1058
+ return !!(e.storedMarks || e.selection.$from.marks()).filter((d) => s ? s.name === d.type.name : !0).find((d) => G(d.attrs, n, { strict: !1 }));
716
1059
  let i = 0;
717
1060
  const a = [];
718
- if (o.forEach(({ $from: u, $to: p }) => {
719
- const f = u.pos, g = p.pos;
720
- e.doc.nodesBetween(f, g, (m, h) => {
721
- if (!m.isText && !m.marks.length)
1061
+ if (o.forEach(({ $from: d, $to: f }) => {
1062
+ const p = d.pos, m = f.pos;
1063
+ e.doc.nodesBetween(p, m, (h, g) => {
1064
+ if (!h.isText && !h.marks.length)
722
1065
  return;
723
- const v = Math.max(f, h), b = Math.min(g, h + m.nodeSize), k = b - v;
724
- i += k, a.push(
725
- ...m.marks.map((S) => ({
726
- mark: S,
1066
+ const v = Math.max(p, g), y = Math.min(m, g + h.nodeSize), w = y - v;
1067
+ i += w, a.push(
1068
+ ...h.marks.map((M) => ({
1069
+ mark: M,
727
1070
  from: v,
728
- to: b
1071
+ to: y
729
1072
  }))
730
1073
  );
731
1074
  });
732
1075
  }), i === 0)
733
1076
  return !1;
734
- const c = a.filter((u) => s ? s.name === u.mark.type.name : !0).filter((u) => J(u.mark.attrs, n, { strict: !1 })).reduce((u, p) => u + p.to - p.from, 0), l = a.filter((u) => s ? u.mark.type !== s && u.mark.type.excludes(s) : !0).reduce((u, p) => u + p.to - p.from, 0);
1077
+ const c = a.filter((d) => s ? s.name === d.mark.type.name : !0).filter((d) => G(d.mark.attrs, n, { strict: !1 })).reduce((d, f) => d + f.to - f.from, 0), l = a.filter((d) => s ? d.mark.type !== s && d.mark.type.excludes(s) : !0).reduce((d, f) => d + f.to - f.from, 0);
735
1078
  return (c > 0 ? c + l : c) >= i;
736
1079
  }
737
- function L(e, t, n = {}) {
738
- const { from: r, to: o, empty: s } = e.selection, i = t ? E(t, e.schema) : null, a = [];
739
- e.doc.nodesBetween(r, o, (u, p) => {
740
- if (u.isText)
741
- return;
742
- const f = Math.max(r, p), g = Math.min(o, p + u.nodeSize);
743
- a.push({
744
- node: u,
745
- from: f,
746
- to: g
747
- });
748
- });
749
- const c = o - r, l = a.filter((u) => i ? i.name === u.node.type.name : !0).filter((u) => J(u.node.attrs, n, { strict: !1 }));
750
- return s ? !!l.length : l.reduce((u, p) => u + p.to - p.from, 0) >= c;
751
- }
752
- function nn(e, t, n = {}) {
1080
+ function Qn(e, t, n = {}) {
753
1081
  if (!t)
754
- return L(e, null, n) || at(e, null, n);
755
- const r = Z(t, e.schema);
756
- return r === "node" ? L(e, t, n) : r === "mark" ? at(e, t, n) : !1;
1082
+ return V(e, null, n) || pt(e, null, n);
1083
+ const r = nt(t, e.schema);
1084
+ return r === "node" ? V(e, t, n) : r === "mark" ? pt(e, t, n) : !1;
757
1085
  }
758
- var Dr = (e, t) => {
1086
+ var Zr = (e, t) => {
759
1087
  const { $from: n, $to: r, $anchor: o } = e.selection;
760
1088
  if (t) {
761
- const s = Q((a) => a.type.name === t)(e.selection);
1089
+ const s = rt((a) => a.type.name === t)(e.selection);
762
1090
  if (!s)
763
1091
  return !1;
764
1092
  const i = e.doc.resolve(s.pos + 1);
765
1093
  return o.pos + 1 === i.end();
766
1094
  }
767
1095
  return !(r.parentOffset < r.parent.nodeSize - 2 || n.pos !== r.pos);
768
- }, Fr = (e) => {
1096
+ }, Qr = (e) => {
769
1097
  const { $from: t, $to: n } = e.selection;
770
1098
  return !(t.parentOffset > 0 || t.pos !== n.pos);
771
1099
  };
772
- function Mt(e, t) {
1100
+ function Nt(e, t) {
773
1101
  return Array.isArray(t) ? t.some((n) => (typeof n == "string" ? n : n.name) === e.name) : t;
774
1102
  }
775
- function St(e, t) {
776
- const { nodeExtensions: n } = _(t), r = n.find((i) => i.name === e);
1103
+ function It(e, t) {
1104
+ const { nodeExtensions: n } = H(t), r = n.find((i) => i.name === e);
777
1105
  if (!r)
778
1106
  return !1;
779
1107
  const o = {
780
1108
  name: r.name,
781
1109
  options: r.options,
782
1110
  storage: r.storage
783
- }, s = w(y(r, "group", o));
1111
+ }, s = x(b(r, "group", o));
784
1112
  return typeof s != "string" ? !1 : s.split(" ").includes("list");
785
1113
  }
786
- function mt(e, {
1114
+ function Mt(e, {
787
1115
  checkChildren: t = !0,
788
1116
  ignoreWhitespace: n = !1
789
1117
  } = {}) {
@@ -803,104 +1131,390 @@ function mt(e, {
803
1131
  if (t) {
804
1132
  let o = !0;
805
1133
  return e.content.forEach((s) => {
806
- o !== !1 && (mt(s, { ignoreWhitespace: n, checkChildren: t }) || (o = !1));
1134
+ o !== !1 && (Mt(s, { ignoreWhitespace: n, checkChildren: t }) || (o = !1));
807
1135
  }), o;
808
1136
  }
809
1137
  return !1;
810
1138
  }
811
- function _r(e) {
812
- return e instanceof G;
813
- }
814
- function Ft(e) {
815
- return e instanceof A;
816
- }
817
- function O(e = 0, t = 0, n = 0) {
818
- return Math.min(Math.max(e, t), n);
819
- }
820
- function _t(e, t = null) {
821
- if (!t)
822
- return null;
823
- const n = D.atStart(e), r = D.atEnd(e);
824
- if (t === "start" || t === !0)
825
- return n;
826
- if (t === "end")
827
- return r;
828
- const o = n.from, s = r.to;
829
- return t === "all" ? A.create(e, O(0, o, s), O(e.content.size, o, s)) : A.create(e, O(t, o, s), O(t, o, s));
1139
+ function Gr(e) {
1140
+ return e instanceof Y;
830
1141
  }
831
- function rn(e, t, n) {
832
- const r = e.steps.length - 1;
833
- if (r < t)
834
- return;
835
- const o = e.steps[r];
836
- if (!(o instanceof pe || o instanceof me))
837
- return;
838
- const s = e.mapping.maps[r];
839
- let i = 0;
840
- s.forEach((a, c, l, d) => {
841
- i === 0 && (i = d);
842
- }), e.setSelection(D.near(e.doc.resolve(i), n));
1142
+ function Gn(e, t, n) {
1143
+ var r;
1144
+ const { selection: o } = t;
1145
+ let s = null;
1146
+ if (Dt(o) && (s = o.$cursor), s) {
1147
+ const a = (r = e.storedMarks) != null ? r : s.marks();
1148
+ return s.parent.type.allowsMarkType(n) && (!!n.isInSet(a) || !a.some((l) => l.type.excludes(n)));
1149
+ }
1150
+ const { ranges: i } = o;
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, (u, d, f) => {
1154
+ if (l)
1155
+ return !1;
1156
+ if (u.isInline) {
1157
+ const p = !f || f.type.allowsMarkType(n), m = !!n.isInSet(u.marks) || !u.marks.some((h) => h.type.excludes(n));
1158
+ l = p && m;
1159
+ }
1160
+ return !l;
1161
+ }), l;
1162
+ });
843
1163
  }
844
- var tt = class {
845
- constructor(e) {
846
- var t;
847
- this.find = e.find, this.handler = e.handler, this.undoable = (t = e.undoable) != null ? t : !0;
1164
+ var Xn = (e, t = {}) => ({ tr: n, state: r, dispatch: o }) => {
1165
+ const { selection: s } = n, { empty: i, ranges: a } = s, c = I(e, r.schema);
1166
+ if (o)
1167
+ if (i) {
1168
+ const l = Vt(r, c);
1169
+ n.addStoredMark(
1170
+ c.create({
1171
+ ...l,
1172
+ ...t
1173
+ })
1174
+ );
1175
+ } else
1176
+ a.forEach((l) => {
1177
+ const u = l.$from.pos, d = l.$to.pos;
1178
+ r.doc.nodesBetween(u, d, (f, p) => {
1179
+ const m = Math.max(p, u), h = Math.min(p + f.nodeSize, d);
1180
+ f.marks.find((v) => v.type === c) ? f.marks.forEach((v) => {
1181
+ c === v.type && n.addMark(
1182
+ m,
1183
+ h,
1184
+ c.create({
1185
+ ...v.attrs,
1186
+ ...t
1187
+ })
1188
+ );
1189
+ }) : n.addMark(m, h, c.create(t));
1190
+ });
1191
+ });
1192
+ return Gn(r, n, c);
1193
+ }, Yn = (e, t) => ({ tr: n }) => (n.setMeta(e, t), !0), tr = (e, t = {}) => ({ state: n, dispatch: r, chain: o }) => {
1194
+ const s = T(e, n.schema);
1195
+ let i;
1196
+ return n.selection.$anchor.sameParent(n.selection.$head) && (i = n.selection.$anchor.parent.attrs), s.isTextblock ? o().command(({ commands: a }) => Tt(s, { ...i, ...t })(n) ? !0 : a.clearNodes()).command(({ state: a }) => Tt(s, { ...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, o = _(e, 0, r.content.size), s = Y.create(r, o);
1200
+ t.setSelection(s);
848
1201
  }
849
- }, on = (e, t) => {
850
- if (ft(t))
851
- return t.exec(e);
852
- const n = t(e);
853
- if (!n)
854
- return null;
855
- const r = [n.text];
856
- 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;
1202
+ return !0;
1203
+ }, nr = (e) => ({ tr: t, dispatch: n }) => {
1204
+ if (n) {
1205
+ const { doc: r } = t, { from: o, to: s } = typeof e == "number" ? { from: e, to: e } : e, i = $.atStart(r).from, a = $.atEnd(r).to, c = _(o, i, a), l = _(s, i, a), u = $.create(r, c, l);
1206
+ t.setSelection(u);
1207
+ }
1208
+ return !0;
1209
+ }, rr = (e) => ({ state: t, dispatch: n }) => {
1210
+ const r = T(e, t.schema);
1211
+ return ze(r)(t, n);
857
1212
  };
858
- function V(e) {
859
- var t;
860
- const { editor: n, from: r, to: o, text: s, rules: i, plugin: a } = e, { view: c } = n;
861
- if (c.composing)
1213
+ function Rt(e, t) {
1214
+ const n = e.storedMarks || e.selection.$to.parentOffset && e.selection.$from.marks();
1215
+ if (n) {
1216
+ const r = n.filter((o) => t?.includes(o.type.name));
1217
+ e.tr.ensureMarks(r);
1218
+ }
1219
+ }
1220
+ var or = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor: o }) => {
1221
+ const { selection: s, doc: i } = t, { $from: a, $to: c } = s, l = o.extensionManager.attributes, u = Q(l, a.node().type.name, a.node().attrs);
1222
+ if (s instanceof Y && s.node.isBlock)
1223
+ return !a.parentOffset || !Z(i, a.pos) ? !1 : (r && (e && Rt(n, o.extensionManager.splittableMarks), t.split(a.pos).scrollIntoView()), !0);
1224
+ if (!a.parent.isBlock)
862
1225
  return !1;
863
- const l = c.state.doc.resolve(r);
864
- if (
865
- // check for code node
866
- l.parent.type.spec.code || (t = l.nodeBefore || l.nodeAfter) != null && t.marks.find((p) => p.type.spec.code)
867
- )
1226
+ const d = c.parentOffset === c.parent.content.size, f = a.depth === 0 ? void 0 : On(a.node(-1).contentMatchAt(a.indexAfter(-1)));
1227
+ let p = d && f ? [
1228
+ {
1229
+ type: f,
1230
+ attrs: u
1231
+ }
1232
+ ] : void 0, m = Z(t.doc, t.mapping.map(a.pos), 1, p);
1233
+ if (!p && !m && Z(t.doc, t.mapping.map(a.pos), 1, f ? [{ type: f }] : void 0) && (m = !0, p = f ? [
1234
+ {
1235
+ type: f,
1236
+ attrs: u
1237
+ }
1238
+ ] : void 0), r) {
1239
+ if (m && (s instanceof $ && t.deleteSelection(), t.split(t.mapping.map(a.pos), 1, p), f && !d && !a.parentOffset && a.parent.type !== f)) {
1240
+ const h = t.mapping.map(a.before()), g = t.doc.resolve(h);
1241
+ a.node(-1).canReplaceWith(g.index(), g.index() + 1, f) && t.setNodeMarkup(t.mapping.map(a.before()), f);
1242
+ }
1243
+ e && Rt(n, o.extensionManager.splittableMarks), t.scrollIntoView();
1244
+ }
1245
+ return m;
1246
+ }, sr = (e, t = {}) => ({ tr: n, state: r, dispatch: o, editor: s }) => {
1247
+ var i;
1248
+ const a = T(e, r.schema), { $from: c, $to: l } = r.selection, u = r.selection.node;
1249
+ if (u && u.isBlock || c.depth < 2 || !c.sameParent(l))
868
1250
  return !1;
869
- let d = !1;
870
- const u = en(l) + s;
871
- return i.forEach((p) => {
872
- if (d)
873
- return;
874
- const f = on(u, p.find);
875
- if (!f)
876
- return;
877
- const g = c.state.tr, m = X({
878
- state: c.state,
879
- transaction: g
880
- }), h = {
881
- from: r - (f[0].length - s.length),
882
- to: o
883
- }, { commands: v, chain: b, can: k } = new Y({
884
- editor: n,
885
- state: m
886
- });
887
- p.handler({
888
- state: m,
889
- range: h,
890
- match: f,
891
- commands: v,
892
- chain: b,
893
- can: k
894
- }) === null || !g.steps.length || (p.undoable && g.setMeta(a, {
895
- transform: g,
1251
+ const d = c.node(-1);
1252
+ if (d.type !== a)
1253
+ return !1;
1254
+ const f = s.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 (o) {
1259
+ let v = j.empty;
1260
+ const y = c.index(-1) ? 1 : c.index(-2) ? 2 : 3;
1261
+ for (let A = c.depth - y; A >= c.depth - 3; A -= 1)
1262
+ v = j.from(c.node(A).copy(v));
1263
+ const w = (
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
+ ...Q(f, c.node().type.name, c.node().attrs),
1268
+ ...t
1269
+ }, k = ((i = a.contentMatch.defaultType) == null ? void 0 : i.createAndFill(M)) || void 0;
1270
+ v = v.append(j.from(a.createAndFill(null, k) || void 0));
1271
+ const S = c.before(c.depth - (y - 1));
1272
+ n.replace(S, c.after(-w), new _e(v, 4 - y, 0));
1273
+ let E = -1;
1274
+ n.doc.nodesBetween(S, 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($.near(n.doc.resolve(E))), n.scrollIntoView();
1279
+ }
1280
+ return !0;
1281
+ }
1282
+ const p = l.pos === c.end() ? d.contentMatchAt(0).defaultType : null, m = {
1283
+ ...Q(f, d.type.name, d.attrs),
1284
+ ...t
1285
+ }, h = {
1286
+ ...Q(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: m },
1292
+ { type: p, attrs: h }
1293
+ ] : [{ type: a, attrs: m }];
1294
+ if (!Z(n.doc, c.pos, 2))
1295
+ return !1;
1296
+ if (o) {
1297
+ const { selection: v, storedMarks: y } = r, { splittableMarks: w } = s.extensionManager, M = y || v.$to.parentOffset && v.$from.marks();
1298
+ if (n.split(c.pos, 2, g).scrollIntoView(), !M || !o)
1299
+ return !0;
1300
+ const k = M.filter((S) => w.includes(S.type.name));
1301
+ n.ensureMarks(k);
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 o = e.doc.nodeAt(r);
1312
+ return n.node.type === o?.type && mt(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 o = e.doc.nodeAt(r);
1321
+ return n.node.type === o?.type && mt(e.doc, r) && e.join(r), !0;
1322
+ }, ir = (e, t, n, r = {}) => ({ editor: o, tr: s, state: i, dispatch: a, chain: c, commands: l, can: u }) => {
1323
+ const { extensions: d, splittableMarks: f } = o.extensionManager, p = T(e, i.schema), m = T(t, i.schema), { selection: h, storedMarks: g } = i, { $from: v, $to: y } = h, w = v.blockRange(y), M = g || h.$to.parentOffset && h.$from.marks();
1324
+ if (!w)
1325
+ return !1;
1326
+ const k = rt((S) => It(S.type.name, d))(h);
1327
+ if (w.depth >= 1 && k && w.depth - k.depth <= 1) {
1328
+ if (k.node.type === p)
1329
+ return l.liftListItem(m);
1330
+ if (It(k.node.type.name, d) && p.validContent(k.node.content) && a)
1331
+ return c().command(() => (s.setNodeMarkup(k.pos, p), !0)).command(() => dt(s, p)).command(() => ut(s, p)).run();
1332
+ }
1333
+ return !n || !M || !a ? c().command(() => u().wrapInList(p, r) ? !0 : l.clearNodes()).wrapInList(p, r).command(() => dt(s, p)).command(() => ut(s, p)).run() : c().command(() => {
1334
+ const S = u().wrapInList(p, r), E = M.filter((A) => f.includes(A.type.name));
1335
+ return s.ensureMarks(E), S ? !0 : l.clearNodes();
1336
+ }).wrapInList(p, r).command(() => dt(s, p)).command(() => ut(s, p)).run();
1337
+ }, ar = (e, t = {}, n = {}) => ({ state: r, commands: o }) => {
1338
+ const { extendEmptyMarkRange: s = !1 } = n, i = I(e, r.schema);
1339
+ return pt(r, i, t) ? o.unsetMark(i, { extendEmptyMarkRange: s }) : o.setMark(i, t);
1340
+ }, cr = (e, t, n = {}) => ({ state: r, commands: o }) => {
1341
+ const s = T(e, r.schema), i = T(t, r.schema), a = V(r, s, n);
1342
+ let c;
1343
+ return r.selection.$anchor.sameParent(r.selection.$head) && (c = r.selection.$anchor.parent.attrs), a ? o.setNode(i, c) : o.setNode(s, { ...c, ...n });
1344
+ }, lr = (e, t = {}) => ({ state: n, commands: r }) => {
1345
+ const o = T(e, n.schema);
1346
+ return V(n, o, t) ? r.lift(o) : r.wrapIn(o, t);
1347
+ }, dr = () => ({ state: e, dispatch: t }) => {
1348
+ const n = e.plugins;
1349
+ for (let r = 0; r < n.length; r += 1) {
1350
+ const o = n[r];
1351
+ let s;
1352
+ if (o.spec.isInputRules && (s = o.getState(e))) {
1353
+ if (t) {
1354
+ const i = e.tr, a = s.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 (s.text) {
1358
+ const c = i.doc.resolve(s.from).marks();
1359
+ i.replaceWith(s.from, s.to, e.schema.text(s.text, c));
1360
+ } else
1361
+ i.delete(s.from, s.to);
1362
+ }
1363
+ return !0;
1364
+ }
1365
+ }
1366
+ return !1;
1367
+ }, ur = () => ({ tr: e, dispatch: t }) => {
1368
+ const { selection: n } = e, { empty: r, ranges: o } = n;
1369
+ return r || t && o.forEach((s) => {
1370
+ e.removeMark(s.$from.pos, s.$to.pos);
1371
+ }), !0;
1372
+ }, fr = (e, t = {}) => ({ tr: n, state: r, dispatch: o }) => {
1373
+ var s;
1374
+ const { extendEmptyMarkRange: i = !1 } = t, { selection: a } = n, c = I(e, r.schema), { $from: l, empty: u, ranges: d } = a;
1375
+ if (!o)
1376
+ return !0;
1377
+ if (u && i) {
1378
+ let { from: f, to: p } = a;
1379
+ const m = (s = l.marks().find((g) => g.type === c)) == null ? void 0 : s.attrs, h = vt(l, c, m);
1380
+ h && (f = h.from, p = h.to), n.removeMark(f, p, c);
1381
+ } else
1382
+ d.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: o }) => {
1387
+ let s = null, i = null;
1388
+ const a = nt(
1389
+ typeof e == "string" ? e : e.name,
1390
+ r.schema
1391
+ );
1392
+ return a ? (a === "node" && (s = T(e, r.schema)), a === "mark" && (i = I(e, r.schema)), o && n.selection.ranges.forEach((c) => {
1393
+ const l = c.$from.pos, u = c.$to.pos;
1394
+ let d, f, p, m;
1395
+ n.selection.empty ? r.doc.nodesBetween(l, u, (h, g) => {
1396
+ s && s === h.type && (p = Math.max(g, l), m = Math.min(g + h.nodeSize, u), d = g, f = h);
1397
+ }) : r.doc.nodesBetween(l, u, (h, g) => {
1398
+ g < l && s && s === h.type && (p = Math.max(g, l), m = Math.min(g + h.nodeSize, u), d = g, f = h), g >= l && g <= u && (s && s === h.type && n.setNodeMarkup(g, void 0, {
1399
+ ...h.attrs,
1400
+ ...t
1401
+ }), i && h.marks.length && h.marks.forEach((v) => {
1402
+ if (i === v.type) {
1403
+ const y = Math.max(g, l), w = Math.min(g + h.nodeSize, u);
1404
+ n.addMark(
1405
+ y,
1406
+ w,
1407
+ i.create({
1408
+ ...v.attrs,
1409
+ ...t
1410
+ })
1411
+ );
1412
+ }
1413
+ }));
1414
+ }), f && (d !== void 0 && n.setNodeMarkup(d, void 0, {
1415
+ ...f.attrs,
1416
+ ...t
1417
+ }), i && f.marks.length && f.marks.forEach((h) => {
1418
+ i === h.type && n.addMark(
1419
+ p,
1420
+ m,
1421
+ i.create({
1422
+ ...h.attrs,
1423
+ ...t
1424
+ })
1425
+ );
1426
+ }));
1427
+ }), !0) : !1;
1428
+ }, mr = (e, t = {}) => ({ state: n, dispatch: r }) => {
1429
+ const o = T(e, n.schema);
1430
+ return Ie(o, t)(n, r);
1431
+ }, hr = (e, t = {}) => ({ state: n, dispatch: r }) => {
1432
+ const o = T(e, n.schema);
1433
+ return Fe(o, 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
+ }, ot = 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 U(e) {
1473
+ var t;
1474
+ const { editor: n, from: r, to: o, text: s, 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 u = !1;
1484
+ const d = Zn(l) + s;
1485
+ return i.forEach((f) => {
1486
+ if (u)
1487
+ return;
1488
+ const p = vr(d, f.find);
1489
+ if (!p)
1490
+ return;
1491
+ const m = c.state.tr, h = tt({
1492
+ state: c.state,
1493
+ transaction: m
1494
+ }), g = {
1495
+ from: r - (p[0].length - s.length),
1496
+ to: o
1497
+ }, { commands: v, chain: y, can: w } = new et({
1498
+ editor: n,
1499
+ state: h
1500
+ });
1501
+ f.handler({
1502
+ state: h,
1503
+ range: g,
1504
+ match: p,
1505
+ commands: v,
1506
+ chain: y,
1507
+ can: w
1508
+ }) === null || !m.steps.length || (f.undoable && m.setMeta(a, {
1509
+ transform: m,
896
1510
  from: r,
897
1511
  to: o,
898
1512
  text: s
899
- }), c.dispatch(g), d = !0);
900
- }), d;
1513
+ }), c.dispatch(m), u = !0);
1514
+ }), u;
901
1515
  }
902
- function sn(e) {
903
- const { editor: t, rules: n } = e, r = new P({
1516
+ function br(e) {
1517
+ const { editor: t, rules: n } = e, r = new N({
904
1518
  state: {
905
1519
  init() {
906
1520
  return null;
@@ -911,14 +1525,14 @@ function sn(e) {
911
1525
  return a;
912
1526
  const c = o.getMeta("applyInputRules");
913
1527
  return !!c && setTimeout(() => {
914
- let { text: d } = c;
915
- typeof d == "string" ? d = d : d = dt(N.from(d), i.schema);
916
- const { from: u } = c, p = u + d.length;
917
- V({
1528
+ let { text: u } = c;
1529
+ typeof u == "string" ? u = u : u = kt(j.from(u), i.schema);
1530
+ const { from: d } = c, f = d + u.length;
1531
+ U({
918
1532
  editor: t,
919
- from: u,
920
- to: p,
921
- text: d,
1533
+ from: d,
1534
+ to: f,
1535
+ text: u,
922
1536
  rules: n,
923
1537
  plugin: r
924
1538
  });
@@ -927,7 +1541,7 @@ function sn(e) {
927
1541
  },
928
1542
  props: {
929
1543
  handleTextInput(o, s, i, a) {
930
- return V({
1544
+ return U({
931
1545
  editor: t,
932
1546
  from: s,
933
1547
  to: i,
@@ -939,7 +1553,7 @@ function sn(e) {
939
1553
  handleDOMEvents: {
940
1554
  compositionend: (o) => (setTimeout(() => {
941
1555
  const { $cursor: s } = o.state.selection;
942
- s && V({
1556
+ s && U({
943
1557
  editor: t,
944
1558
  from: s.pos,
945
1559
  to: s.pos,
@@ -955,7 +1569,7 @@ function sn(e) {
955
1569
  if (s.key !== "Enter")
956
1570
  return !1;
957
1571
  const { $cursor: i } = o.state.selection;
958
- return i ? V({
1572
+ return i ? U({
959
1573
  editor: t,
960
1574
  from: i.pos,
961
1575
  to: i.pos,
@@ -971,19 +1585,19 @@ function sn(e) {
971
1585
  });
972
1586
  return r;
973
1587
  }
974
- function an(e) {
1588
+ function yr(e) {
975
1589
  return Object.prototype.toString.call(e).slice(8, -1);
976
1590
  }
977
- function H(e) {
978
- return an(e) !== "Object" ? !1 : e.constructor === Object && Object.getPrototypeOf(e) === Object.prototype;
1591
+ function K(e) {
1592
+ return yr(e) !== "Object" ? !1 : e.constructor === Object && Object.getPrototypeOf(e) === Object.prototype;
979
1593
  }
980
- function Lt(e, t) {
1594
+ function Zt(e, t) {
981
1595
  const n = { ...e };
982
- return H(e) && H(t) && Object.keys(t).forEach((r) => {
983
- H(t[r]) && H(e[r]) ? n[r] = Lt(e[r], t[r]) : n[r] = t[r];
1596
+ return K(e) && K(t) && Object.keys(t).forEach((r) => {
1597
+ K(t[r]) && K(e[r]) ? n[r] = Zt(e[r], t[r]) : n[r] = t[r];
984
1598
  }), n;
985
1599
  }
986
- var ht = class {
1600
+ var xt = class {
987
1601
  constructor(e = {}) {
988
1602
  this.type = "extendable", this.parent = null, this.child = null, this.name = "", this.config = {
989
1603
  name: this.name
@@ -994,8 +1608,8 @@ var ht = class {
994
1608
  }
995
1609
  get options() {
996
1610
  return {
997
- ...w(
998
- y(this, "addOptions", {
1611
+ ...x(
1612
+ b(this, "addOptions", {
999
1613
  name: this.name
1000
1614
  })
1001
1615
  ) || {}
@@ -1003,8 +1617,8 @@ var ht = class {
1003
1617
  }
1004
1618
  get storage() {
1005
1619
  return {
1006
- ...w(
1007
- y(this, "addStorage", {
1620
+ ...x(
1621
+ b(this, "addStorage", {
1008
1622
  name: this.name,
1009
1623
  options: this.options
1010
1624
  })
@@ -1014,7 +1628,7 @@ var ht = class {
1014
1628
  configure(e = {}) {
1015
1629
  const t = this.extend({
1016
1630
  ...this.config,
1017
- addOptions: () => Lt(this.options, e)
1631
+ addOptions: () => Zt(this.options, e)
1018
1632
  });
1019
1633
  return t.name = this.name, t.parent = this.parent, t;
1020
1634
  }
@@ -1022,7 +1636,7 @@ var ht = class {
1022
1636
  const t = new this.constructor({ ...this.config, ...e });
1023
1637
  return t.parent = this, this.child = t, t.name = "name" in e ? e.name : t.parent.name, t;
1024
1638
  }
1025
- }, cn = class zt extends ht {
1639
+ }, kr = class Qt extends xt {
1026
1640
  constructor() {
1027
1641
  super(...arguments), this.type = "mark";
1028
1642
  }
@@ -1032,7 +1646,7 @@ var ht = class {
1032
1646
  */
1033
1647
  static create(t = {}) {
1034
1648
  const n = typeof t == "function" ? t() : t;
1035
- return new zt(n);
1649
+ return new Qt(n);
1036
1650
  }
1037
1651
  static handleExit({ editor: t, mark: n }) {
1038
1652
  const { tr: r } = t.state, o = t.state.selection.$from;
@@ -1053,15 +1667,15 @@ var ht = class {
1053
1667
  return super.extend(n);
1054
1668
  }
1055
1669
  };
1056
- function ln(e) {
1670
+ function wr(e) {
1057
1671
  return typeof e == "number";
1058
1672
  }
1059
- var dn = class {
1673
+ var Mr = class {
1060
1674
  constructor(e) {
1061
1675
  this.find = e.find, this.handler = e.handler;
1062
1676
  }
1063
- }, un = (e, t, n) => {
1064
- if (ft(t))
1677
+ }, xr = (e, t, n) => {
1678
+ if (gt(t))
1065
1679
  return [...e.matchAll(t)];
1066
1680
  const r = t(e, n);
1067
1681
  return r ? r.map((o) => {
@@ -1069,47 +1683,47 @@ var dn = class {
1069
1683
  return s.index = o.index, s.input = e, s.data = o.data, o.replaceWith && (o.text.includes(o.replaceWith) || console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'), s.push(o.replaceWith)), s;
1070
1684
  }) : [];
1071
1685
  };
1072
- function fn(e) {
1073
- const { editor: t, state: n, from: r, to: o, rule: s, pasteEvent: i, dropEvent: a } = e, { commands: c, chain: l, can: d } = new Y({
1686
+ function Sr(e) {
1687
+ const { editor: t, state: n, from: r, to: o, rule: s, pasteEvent: i, dropEvent: a } = e, { commands: c, chain: l, can: u } = new et({
1074
1688
  editor: t,
1075
1689
  state: n
1076
- }), u = [];
1077
- return n.doc.nodesBetween(r, o, (f, g) => {
1078
- var m, h, v, b, k;
1079
- if ((h = (m = f.type) == null ? void 0 : m.spec) != null && h.code || !(f.isText || f.isTextblock || f.isInline))
1690
+ }), d = [];
1691
+ return n.doc.nodesBetween(r, o, (p, m) => {
1692
+ var h, g, v, y, w;
1693
+ if ((g = (h = p.type) == null ? void 0 : h.spec) != null && g.code || !(p.isText || p.isTextblock || p.isInline))
1080
1694
  return;
1081
- const S = (k = (b = (v = f.content) == null ? void 0 : v.size) != null ? b : f.nodeSize) != null ? k : 0, M = Math.max(r, g), x = Math.min(o, g + S);
1082
- if (M >= x)
1695
+ const M = (w = (y = (v = p.content) == null ? void 0 : v.size) != null ? y : p.nodeSize) != null ? w : 0, k = Math.max(r, m), S = Math.min(o, m + M);
1696
+ if (k >= S)
1083
1697
  return;
1084
- const T = f.isText ? f.text || "" : f.textBetween(M - g, x - g, void 0, "");
1085
- un(T, s.find, i).forEach((j) => {
1086
- if (j.index === void 0)
1698
+ const E = p.isText ? p.text || "" : p.textBetween(k - m, S - m, void 0, "");
1699
+ xr(E, s.find, i).forEach((C) => {
1700
+ if (C.index === void 0)
1087
1701
  return;
1088
- const vt = M + j.index + 1, ne = vt + j[0].length, re = {
1089
- from: n.tr.mapping.map(vt),
1090
- to: n.tr.mapping.map(ne)
1091
- }, oe = s.handler({
1702
+ const O = k + C.index + 1, it = O + C[0].length, W = {
1703
+ from: n.tr.mapping.map(O),
1704
+ to: n.tr.mapping.map(it)
1705
+ }, at = s.handler({
1092
1706
  state: n,
1093
- range: re,
1094
- match: j,
1707
+ range: W,
1708
+ match: C,
1095
1709
  commands: c,
1096
1710
  chain: l,
1097
- can: d,
1711
+ can: u,
1098
1712
  pasteEvent: i,
1099
1713
  dropEvent: a
1100
1714
  });
1101
- u.push(oe);
1715
+ d.push(at);
1102
1716
  });
1103
- }), u.every((f) => f !== null);
1717
+ }), d.every((p) => p !== null);
1104
1718
  }
1105
- var W = null, pn = (e) => {
1719
+ var J = null, Er = (e) => {
1106
1720
  var t;
1107
1721
  const n = new ClipboardEvent("paste", {
1108
1722
  clipboardData: new DataTransfer()
1109
1723
  });
1110
1724
  return (t = n.clipboardData) == null || t.setData("text/html", e), n;
1111
1725
  };
1112
- function mn(e) {
1726
+ function Tr(e) {
1113
1727
  const { editor: t, rules: n } = e;
1114
1728
  let r = null, o = !1, s = !1, i = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, a;
1115
1729
  try {
@@ -1118,98 +1732,98 @@ function mn(e) {
1118
1732
  a = null;
1119
1733
  }
1120
1734
  const c = ({
1121
- state: d,
1122
- from: u,
1123
- to: p,
1124
- rule: f,
1125
- pasteEvt: g
1735
+ state: u,
1736
+ from: d,
1737
+ to: f,
1738
+ rule: p,
1739
+ pasteEvt: m
1126
1740
  }) => {
1127
- const m = d.tr, h = X({
1128
- state: d,
1129
- transaction: m
1741
+ const h = u.tr, g = tt({
1742
+ state: u,
1743
+ transaction: h
1130
1744
  });
1131
- if (!(!fn({
1745
+ if (!(!Sr({
1132
1746
  editor: t,
1133
- state: h,
1134
- from: Math.max(u - 1, 0),
1135
- to: p.b - 1,
1136
- rule: f,
1137
- pasteEvent: g,
1747
+ state: g,
1748
+ from: Math.max(d - 1, 0),
1749
+ to: f.b - 1,
1750
+ rule: p,
1751
+ pasteEvent: m,
1138
1752
  dropEvent: a
1139
- }) || !m.steps.length)) {
1753
+ }) || !h.steps.length)) {
1140
1754
  try {
1141
1755
  a = typeof DragEvent < "u" ? new DragEvent("drop") : null;
1142
1756
  } catch {
1143
1757
  a = null;
1144
1758
  }
1145
- return i = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, m;
1759
+ return i = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, h;
1146
1760
  }
1147
1761
  };
1148
- return n.map((d) => new P({
1762
+ return n.map((u) => new N({
1149
1763
  // we register a global drag handler to track the current drag source element
1150
- view(u) {
1151
- const p = (g) => {
1152
- var m;
1153
- r = (m = u.dom.parentElement) != null && m.contains(g.target) ? u.dom.parentElement : null, r && (W = t);
1154
- }, f = () => {
1155
- W && (W = null);
1764
+ view(d) {
1765
+ const f = (m) => {
1766
+ var h;
1767
+ r = (h = d.dom.parentElement) != null && h.contains(m.target) ? d.dom.parentElement : null, r && (J = t);
1768
+ }, p = () => {
1769
+ J && (J = null);
1156
1770
  };
1157
- return window.addEventListener("dragstart", p), window.addEventListener("dragend", f), {
1771
+ return window.addEventListener("dragstart", f), window.addEventListener("dragend", p), {
1158
1772
  destroy() {
1159
- window.removeEventListener("dragstart", p), window.removeEventListener("dragend", f);
1773
+ window.removeEventListener("dragstart", f), window.removeEventListener("dragend", p);
1160
1774
  }
1161
1775
  };
1162
1776
  },
1163
1777
  props: {
1164
1778
  handleDOMEvents: {
1165
- drop: (u, p) => {
1166
- if (s = r === u.dom.parentElement, a = p, !s) {
1167
- const f = W;
1168
- f?.isEditable && setTimeout(() => {
1169
- const g = f.state.selection;
1170
- g && f.commands.deleteRange({ from: g.from, to: g.to });
1779
+ drop: (d, f) => {
1780
+ if (s = r === d.dom.parentElement, a = f, !s) {
1781
+ const p = J;
1782
+ p?.isEditable && setTimeout(() => {
1783
+ const m = p.state.selection;
1784
+ m && p.commands.deleteRange({ from: m.from, to: m.to });
1171
1785
  }, 10);
1172
1786
  }
1173
1787
  return !1;
1174
1788
  },
1175
- paste: (u, p) => {
1176
- var f;
1177
- const g = (f = p.clipboardData) == null ? void 0 : f.getData("text/html");
1178
- return i = p, o = !!g?.includes("data-pm-slice"), !1;
1789
+ paste: (d, f) => {
1790
+ var p;
1791
+ const m = (p = f.clipboardData) == null ? void 0 : p.getData("text/html");
1792
+ return i = f, o = !!m?.includes("data-pm-slice"), !1;
1179
1793
  }
1180
1794
  }
1181
1795
  },
1182
- appendTransaction: (u, p, f) => {
1183
- const g = u[0], m = g.getMeta("uiEvent") === "paste" && !o, h = g.getMeta("uiEvent") === "drop" && !s, v = g.getMeta("applyPasteRules"), b = !!v;
1184
- if (!m && !h && !b)
1796
+ appendTransaction: (d, f, p) => {
1797
+ const m = d[0], h = m.getMeta("uiEvent") === "paste" && !o, g = m.getMeta("uiEvent") === "drop" && !s, v = m.getMeta("applyPasteRules"), y = !!v;
1798
+ if (!h && !g && !y)
1185
1799
  return;
1186
- if (b) {
1187
- let { text: M } = v;
1188
- typeof M == "string" ? M = M : M = dt(N.from(M), f.schema);
1189
- const { from: x } = v, T = x + M.length, C = pn(M);
1800
+ if (y) {
1801
+ let { text: k } = v;
1802
+ typeof k == "string" ? k = k : k = kt(j.from(k), p.schema);
1803
+ const { from: S } = v, E = S + k.length, A = Er(k);
1190
1804
  return c({
1191
- rule: d,
1192
- state: f,
1193
- from: x,
1194
- to: { b: T },
1195
- pasteEvt: C
1805
+ rule: u,
1806
+ state: p,
1807
+ from: S,
1808
+ to: { b: E },
1809
+ pasteEvt: A
1196
1810
  });
1197
1811
  }
1198
- const k = p.doc.content.findDiffStart(f.doc.content), S = p.doc.content.findDiffEnd(f.doc.content);
1199
- if (!(!ln(k) || !S || k === S.b))
1812
+ const w = f.doc.content.findDiffStart(p.doc.content), M = f.doc.content.findDiffEnd(p.doc.content);
1813
+ if (!(!wr(w) || !M || w === M.b))
1200
1814
  return c({
1201
- rule: d,
1202
- state: f,
1203
- from: k,
1204
- to: S,
1815
+ rule: u,
1816
+ state: p,
1817
+ from: w,
1818
+ to: M,
1205
1819
  pasteEvt: i
1206
1820
  });
1207
1821
  }
1208
1822
  }));
1209
1823
  }
1210
- var et = class {
1824
+ var st = class {
1211
1825
  constructor(e, t) {
1212
- this.splittableMarks = [], this.editor = t, this.extensions = Nt(e), this.schema = Ke(this.extensions, t), this.setupExtensions();
1826
+ this.splittableMarks = [], this.editor = t, this.baseExtensions = e, this.extensions = qt(e), this.schema = Ln(this.extensions, t), this.setupExtensions();
1213
1827
  }
1214
1828
  /**
1215
1829
  * Get all commands from the extensions.
@@ -1222,8 +1836,8 @@ var et = class {
1222
1836
  options: t.options,
1223
1837
  storage: this.editor.extensionStorage[t.name],
1224
1838
  editor: this.editor,
1225
- type: rt(t.name, this.schema)
1226
- }, r = y(t, "addCommands", n);
1839
+ type: lt(t.name, this.schema)
1840
+ }, r = b(t, "addCommands", n);
1227
1841
  return r ? {
1228
1842
  ...e,
1229
1843
  ...r()
@@ -1236,54 +1850,54 @@ var et = class {
1236
1850
  */
1237
1851
  get plugins() {
1238
1852
  const { editor: e } = this;
1239
- return ut([...this.extensions].reverse()).flatMap((r) => {
1853
+ return wt([...this.extensions].reverse()).flatMap((r) => {
1240
1854
  const o = {
1241
1855
  name: r.name,
1242
1856
  options: r.options,
1243
1857
  storage: this.editor.extensionStorage[r.name],
1244
1858
  editor: e,
1245
- type: rt(r.name, this.schema)
1246
- }, s = [], i = y(
1859
+ type: lt(r.name, this.schema)
1860
+ }, s = [], i = b(
1247
1861
  r,
1248
1862
  "addKeyboardShortcuts",
1249
1863
  o
1250
1864
  );
1251
1865
  let a = {};
1252
- if (r.type === "mark" && y(r, "exitable", o) && (a.ArrowRight = () => cn.handleExit({ editor: e, mark: r })), i) {
1253
- const p = Object.fromEntries(
1254
- Object.entries(i()).map(([f, g]) => [f, () => g({ editor: e })])
1866
+ if (r.type === "mark" && b(r, "exitable", o) && (a.ArrowRight = () => kr.handleExit({ editor: e, mark: r })), i) {
1867
+ const f = Object.fromEntries(
1868
+ Object.entries(i()).map(([p, m]) => [p, () => m({ editor: e })])
1255
1869
  );
1256
- a = { ...a, ...p };
1870
+ a = { ...a, ...f };
1257
1871
  }
1258
- const c = ce(a);
1872
+ const c = Ve(a);
1259
1873
  s.push(c);
1260
- const l = y(r, "addInputRules", o);
1261
- if (Mt(r, e.options.enableInputRules) && l) {
1262
- const p = l();
1263
- if (p && p.length) {
1264
- const f = sn({
1874
+ const l = b(r, "addInputRules", o);
1875
+ if (Nt(r, e.options.enableInputRules) && l) {
1876
+ const f = l();
1877
+ if (f && f.length) {
1878
+ const p = br({
1265
1879
  editor: e,
1266
- rules: p
1267
- }), g = Array.isArray(f) ? f : [f];
1268
- s.push(...g);
1880
+ rules: f
1881
+ }), m = Array.isArray(p) ? p : [p];
1882
+ s.push(...m);
1269
1883
  }
1270
1884
  }
1271
- const d = y(r, "addPasteRules", o);
1272
- if (Mt(r, e.options.enablePasteRules) && d) {
1273
- const p = d();
1274
- if (p && p.length) {
1275
- const f = mn({ editor: e, rules: p });
1276
- s.push(...f);
1885
+ const u = b(r, "addPasteRules", o);
1886
+ if (Nt(r, e.options.enablePasteRules) && u) {
1887
+ const f = u();
1888
+ if (f && f.length) {
1889
+ const p = Tr({ editor: e, rules: f });
1890
+ s.push(...p);
1277
1891
  }
1278
1892
  }
1279
- const u = y(
1893
+ const d = b(
1280
1894
  r,
1281
1895
  "addProseMirrorPlugins",
1282
1896
  o
1283
1897
  );
1284
- if (u) {
1285
- const p = u();
1286
- s.push(...p);
1898
+ if (d) {
1899
+ const f = d();
1900
+ s.push(...f);
1287
1901
  }
1288
1902
  return s;
1289
1903
  });
@@ -1293,781 +1907,170 @@ var et = class {
1293
1907
  * @returns An array of attributes
1294
1908
  */
1295
1909
  get attributes() {
1296
- return It(this.extensions);
1910
+ return Wt(this.extensions);
1297
1911
  }
1298
1912
  /**
1299
1913
  * Get all node views from the extensions.
1300
1914
  * @returns An object with all node views where the key is the node name and the value is the node view function
1301
1915
  */
1302
1916
  get nodeViews() {
1303
- const { editor: e } = this, { nodeExtensions: t } = _(this.extensions);
1917
+ const { editor: e } = this, { nodeExtensions: t } = H(this.extensions);
1304
1918
  return Object.fromEntries(
1305
- t.filter((n) => !!y(n, "addNodeView")).map((n) => {
1306
- const r = this.attributes.filter((a) => a.type === n.name), o = {
1307
- name: n.name,
1308
- options: n.options,
1309
- storage: this.editor.extensionStorage[n.name],
1310
- editor: e,
1311
- type: E(n.name, this.schema)
1312
- }, s = y(n, "addNodeView", o);
1313
- if (!s)
1314
- return [];
1315
- const i = (a, c, l, d, u) => {
1316
- const p = K(a, r);
1317
- return s()({
1318
- // pass-through
1319
- node: a,
1320
- view: c,
1321
- getPos: l,
1322
- decorations: d,
1323
- innerDecorations: u,
1324
- // tiptap-specific
1325
- editor: e,
1326
- extension: n,
1327
- HTMLAttributes: p
1328
- });
1329
- };
1330
- return [n.name, i];
1331
- })
1332
- );
1333
- }
1334
- get markViews() {
1335
- const { editor: e } = this, { markExtensions: t } = _(this.extensions);
1336
- return Object.fromEntries(
1337
- t.filter((n) => !!y(n, "addMarkView")).map((n) => {
1338
- const r = this.attributes.filter((a) => a.type === n.name), o = {
1339
- name: n.name,
1340
- options: n.options,
1341
- storage: this.editor.extensionStorage[n.name],
1342
- editor: e,
1343
- type: $(n.name, this.schema)
1344
- }, s = y(n, "addMarkView", o);
1345
- if (!s)
1346
- return [];
1347
- const i = (a, c, l) => {
1348
- const d = K(a, r);
1349
- return s()({
1350
- // pass-through
1351
- mark: a,
1352
- view: c,
1353
- inline: l,
1354
- // tiptap-specific
1355
- editor: e,
1356
- extension: n,
1357
- HTMLAttributes: d,
1358
- updateAttributes: (u) => {
1359
- Cr(a, e, u);
1360
- }
1361
- });
1362
- };
1363
- return [n.name, i];
1364
- })
1365
- );
1366
- }
1367
- /**
1368
- * Go through all extensions, create extension storages & setup marks
1369
- * & bind editor event listener.
1370
- */
1371
- setupExtensions() {
1372
- const e = this.extensions;
1373
- this.editor.extensionStorage = Object.fromEntries(
1374
- e.map((t) => [t.name, t.storage])
1375
- ), e.forEach((t) => {
1376
- var n;
1377
- const r = {
1378
- name: t.name,
1379
- options: t.options,
1380
- storage: this.editor.extensionStorage[t.name],
1381
- editor: this.editor,
1382
- type: rt(t.name, this.schema)
1383
- };
1384
- t.type === "mark" && ((n = w(y(t, "keepOnSplit", r))) == null || n) && this.splittableMarks.push(t.name);
1385
- const o = y(t, "onBeforeCreate", r), s = y(t, "onCreate", r), i = y(t, "onUpdate", r), a = y(
1386
- t,
1387
- "onSelectionUpdate",
1388
- r
1389
- ), c = y(t, "onTransaction", r), l = y(t, "onFocus", r), d = y(t, "onBlur", r), u = y(t, "onDestroy", r);
1390
- o && this.editor.on("beforeCreate", o), s && this.editor.on("create", s), 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);
1391
- });
1392
- }
1393
- };
1394
- et.resolve = Nt;
1395
- et.sort = ut;
1396
- et.flatten = lt;
1397
- var hn = {};
1398
- At(hn, {
1399
- ClipboardTextSerializer: () => Ht,
1400
- Commands: () => qt,
1401
- Delete: () => Kt,
1402
- Drop: () => Jt,
1403
- Editable: () => Gt,
1404
- FocusEvents: () => Yt,
1405
- Keymap: () => Qt,
1406
- Paste: () => Zt,
1407
- Tabindex: () => te,
1408
- focusEventsPluginKey: () => Xt
1409
- });
1410
- var I = class Vt extends ht {
1411
- constructor() {
1412
- super(...arguments), this.type = "extension";
1413
- }
1414
- /**
1415
- * Create a new Extension instance
1416
- * @param config - Extension configuration object or a function that returns a configuration object
1417
- */
1418
- static create(t = {}) {
1419
- const n = typeof t == "function" ? t() : t;
1420
- return new Vt(n);
1421
- }
1422
- configure(t) {
1423
- return super.configure(t);
1424
- }
1425
- extend(t) {
1426
- const n = typeof t == "function" ? t() : t;
1427
- return super.extend(n);
1428
- }
1429
- }, Ht = I.create({
1430
- name: "clipboardTextSerializer",
1431
- addOptions() {
1432
- return {
1433
- blockSeparator: void 0
1434
- };
1435
- },
1436
- addProseMirrorPlugins() {
1437
- return [
1438
- new P({
1439
- key: new B("clipboardTextSerializer"),
1440
- props: {
1441
- clipboardTextSerializer: () => {
1442
- const { editor: e } = this, { state: t, schema: n } = e, { doc: r, selection: o } = t, { ranges: s } = o, i = Math.min(...s.map((d) => d.$from.pos)), a = Math.max(...s.map((d) => d.$to.pos)), c = Bt(n);
1443
- return Ot(r, { from: i, to: a }, {
1444
- ...this.options.blockSeparator !== void 0 ? { blockSeparator: this.options.blockSeparator } : {},
1445
- textSerializers: c
1446
- });
1447
- }
1448
- }
1449
- })
1450
- ];
1451
- }
1452
- }), Wt = {};
1453
- At(Wt, {
1454
- blur: () => gn,
1455
- clearContent: () => vn,
1456
- clearNodes: () => yn,
1457
- command: () => bn,
1458
- createParagraphNear: () => kn,
1459
- cut: () => wn,
1460
- deleteCurrentNode: () => Mn,
1461
- deleteNode: () => Sn,
1462
- deleteRange: () => En,
1463
- deleteSelection: () => xn,
1464
- enter: () => Tn,
1465
- exitCode: () => Cn,
1466
- extendMarkRange: () => An,
1467
- first: () => Pn,
1468
- focus: () => In,
1469
- forEach: () => Nn,
1470
- insertContent: () => On,
1471
- insertContentAt: () => jn,
1472
- joinBackward: () => Fn,
1473
- joinDown: () => Dn,
1474
- joinForward: () => _n,
1475
- joinItemBackward: () => Ln,
1476
- joinItemForward: () => zn,
1477
- joinTextblockBackward: () => Vn,
1478
- joinTextblockForward: () => Hn,
1479
- joinUp: () => Rn,
1480
- keyboardShortcut: () => Un,
1481
- lift: () => qn,
1482
- liftEmptyBlock: () => Kn,
1483
- liftListItem: () => Jn,
1484
- newlineInCode: () => Gn,
1485
- resetAttributes: () => Xn,
1486
- scrollIntoView: () => Yn,
1487
- selectAll: () => Qn,
1488
- selectNodeBackward: () => Zn,
1489
- selectNodeForward: () => tr,
1490
- selectParentNode: () => er,
1491
- selectTextblockEnd: () => nr,
1492
- selectTextblockStart: () => rr,
1493
- setContent: () => or,
1494
- setMark: () => ir,
1495
- setMeta: () => ar,
1496
- setNode: () => cr,
1497
- setNodeSelection: () => lr,
1498
- setTextSelection: () => dr,
1499
- sinkListItem: () => ur,
1500
- splitBlock: () => fr,
1501
- splitListItem: () => pr,
1502
- toggleList: () => mr,
1503
- toggleMark: () => hr,
1504
- toggleNode: () => gr,
1505
- toggleWrap: () => vr,
1506
- undoInputRule: () => yr,
1507
- unsetAllMarks: () => br,
1508
- unsetMark: () => kr,
1509
- updateAttributes: () => wr,
1510
- wrapIn: () => Mr,
1511
- wrapInList: () => Sr
1512
- });
1513
- var gn = () => ({ editor: e, view: t }) => (requestAnimationFrame(() => {
1514
- var n;
1515
- e.isDestroyed || (t.dom.blur(), (n = window?.getSelection()) == null || n.removeAllRanges());
1516
- }), !0), vn = (e = !0) => ({ commands: t }) => t.setContent("", { emitUpdate: e }), yn = () => ({ state: e, tr: t, dispatch: n }) => {
1517
- const { selection: r } = t, { ranges: o } = r;
1518
- return n && o.forEach(({ $from: s, $to: i }) => {
1519
- e.doc.nodesBetween(s.pos, i.pos, (a, c) => {
1520
- if (a.type.isText)
1521
- return;
1522
- const { doc: l, mapping: d } = t, u = l.resolve(d.map(c)), p = l.resolve(d.map(c + a.nodeSize)), f = u.blockRange(p);
1523
- if (!f)
1524
- return;
1525
- const g = fe(f);
1526
- if (a.type.isTextblock) {
1527
- const { defaultType: m } = u.parent.contentMatchAt(u.index());
1528
- t.setNodeMarkup(f.start, m);
1529
- }
1530
- (g || g === 0) && t.lift(f, g);
1531
- });
1532
- }), !0;
1533
- }, bn = (e) => (t) => e(t), kn = () => ({ state: e, dispatch: t }) => ye(e, t), wn = (e, t) => ({ editor: n, tr: r }) => {
1534
- const { state: o } = n, s = o.doc.slice(e.from, e.to);
1535
- r.deleteRange(e.from, e.to);
1536
- const i = r.mapping.map(t);
1537
- return r.insert(i, s.content), r.setSelection(new A(r.doc.resolve(Math.max(i - 1, 0)))), !0;
1538
- }, Mn = () => ({ tr: e, dispatch: t }) => {
1539
- const { selection: n } = e, r = n.$anchor.node();
1540
- if (r.content.size > 0)
1541
- return !1;
1542
- const o = e.selection.$anchor;
1543
- for (let s = o.depth; s > 0; s -= 1)
1544
- if (o.node(s).type === r.type) {
1545
- if (t) {
1546
- const a = o.before(s), c = o.after(s);
1547
- e.delete(a, c).scrollIntoView();
1548
- }
1549
- return !0;
1550
- }
1551
- return !1;
1552
- }, Sn = (e) => ({ tr: t, state: n, dispatch: r }) => {
1553
- const o = E(e, n.schema), s = t.selection.$anchor;
1554
- for (let i = s.depth; i > 0; i -= 1)
1555
- if (s.node(i).type === o) {
1556
- if (r) {
1557
- const c = s.before(i), l = s.after(i);
1558
- t.delete(c, l).scrollIntoView();
1559
- }
1560
- return !0;
1561
- }
1562
- return !1;
1563
- }, En = (e) => ({ tr: t, dispatch: n }) => {
1564
- const { from: r, to: o } = e;
1565
- return n && t.delete(r, o), !0;
1566
- }, xn = () => ({ state: e, dispatch: t }) => be(e, t), Tn = () => ({ commands: e }) => e.keyboardShortcut("Enter"), Cn = () => ({ state: e, dispatch: t }) => ke(e, t), An = (e, t = {}) => ({ tr: n, state: r, dispatch: o }) => {
1567
- const s = $(e, r.schema), { doc: i, selection: a } = n, { $from: c, from: l, to: d } = a;
1568
- if (o) {
1569
- const u = pt(c, s, t);
1570
- if (u && u.from <= l && u.to >= d) {
1571
- const p = A.create(i, u.from, u.to);
1572
- n.setSelection(p);
1573
- }
1574
- }
1575
- return !0;
1576
- }, Pn = (e) => (t) => {
1577
- const n = typeof e == "function" ? e(t) : e;
1578
- for (let r = 0; r < n.length; r += 1)
1579
- if (n[r](t))
1580
- return !0;
1581
- return !1;
1582
- };
1583
- function $n() {
1584
- return navigator.platform === "Android" || /android/i.test(navigator.userAgent);
1585
- }
1586
- function gt() {
1587
- return ["iPad Simulator", "iPhone Simulator", "iPod Simulator", "iPad", "iPhone", "iPod"].includes(navigator.platform) || // iPad on iOS 13 detection
1588
- navigator.userAgent.includes("Mac") && "ontouchend" in document;
1589
- }
1590
- var In = (e = null, t = {}) => ({ editor: n, view: r, tr: o, dispatch: s }) => {
1591
- t = {
1592
- scrollIntoView: !0,
1593
- ...t
1594
- };
1595
- const i = () => {
1596
- (gt() || $n()) && r.dom.focus(), requestAnimationFrame(() => {
1597
- n.isDestroyed || (r.focus(), t?.scrollIntoView && n.commands.scrollIntoView());
1598
- });
1599
- };
1600
- if (r.hasFocus() && e === null || e === !1)
1601
- return !0;
1602
- if (s && e === null && !Ft(n.state.selection))
1603
- return i(), !0;
1604
- const a = _t(o.doc, e) || n.state.selection, c = n.state.selection.eq(a);
1605
- return s && (c || o.setSelection(a), c && o.storedMarks && o.setStoredMarks(o.storedMarks), i()), !0;
1606
- }, Nn = (e, t) => (n) => e.every((r, o) => t(r, { ...n, index: o })), On = (e, t) => ({ tr: n, commands: r }) => r.insertContentAt({ from: n.selection.from, to: n.selection.to }, e, t), Bn = (e) => !("type" in e), jn = (e, t, n) => ({ tr: r, dispatch: o, editor: s }) => {
1607
- var i;
1608
- if (o) {
1609
- n = {
1610
- parseOptions: s.options.parseOptions,
1611
- updateSelection: !0,
1612
- applyInputRules: !1,
1613
- applyPasteRules: !1,
1614
- ...n
1615
- };
1616
- let a;
1617
- const c = (h) => {
1618
- s.emit("contentError", {
1619
- editor: s,
1620
- error: h,
1621
- disableCollaboration: () => {
1622
- "collaboration" in s.storage && typeof s.storage.collaboration == "object" && s.storage.collaboration && (s.storage.collaboration.isDisabled = !0);
1623
- }
1624
- });
1625
- }, l = {
1626
- preserveWhitespace: "full",
1627
- ...n.parseOptions
1628
- };
1629
- if (!n.errorOnInvalidContent && !s.options.enableContentCheck && s.options.emitContentError)
1630
- try {
1631
- F(t, s.schema, {
1632
- parseOptions: l,
1633
- errorOnInvalidContent: !0
1634
- });
1635
- } catch (h) {
1636
- c(h);
1637
- }
1638
- try {
1639
- a = F(t, s.schema, {
1640
- parseOptions: l,
1641
- errorOnInvalidContent: (i = n.errorOnInvalidContent) != null ? i : s.options.enableContentCheck
1642
- });
1643
- } catch (h) {
1644
- return c(h), !1;
1645
- }
1646
- let { from: d, to: u } = typeof e == "number" ? { from: e, to: e } : { from: e.from, to: e.to }, p = !0, f = !0;
1647
- if ((Bn(a) ? a : [a]).forEach((h) => {
1648
- h.check(), p = p ? h.isText && h.marks.length === 0 : !1, f = f ? h.isBlock : !1;
1649
- }), d === u && f) {
1650
- const { parent: h } = r.doc.resolve(d);
1651
- h.isTextblock && !h.type.spec.code && !h.childCount && (d -= 1, u += 1);
1652
- }
1653
- let m;
1654
- if (p) {
1655
- if (Array.isArray(t))
1656
- m = t.map((h) => h.text || "").join("");
1657
- else if (t instanceof N) {
1658
- let h = "";
1659
- t.forEach((v) => {
1660
- v.text && (h += v.text);
1661
- }), m = h;
1662
- } else typeof t == "object" && t && t.text ? m = t.text : m = t;
1663
- r.insertText(m, d, u);
1664
- } else {
1665
- m = a;
1666
- const h = r.doc.resolve(d), v = h.node(), b = h.parentOffset === 0, k = v.isText || v.isTextblock, S = v.content.size > 0;
1667
- b && k && S && (d = Math.max(0, d - 1)), r.replaceWith(d, u, m);
1668
- }
1669
- n.updateSelection && rn(r, r.steps.length - 1, -1), n.applyInputRules && r.setMeta("applyInputRules", { from: d, text: m }), n.applyPasteRules && r.setMeta("applyPasteRules", { from: d, text: m });
1670
- }
1671
- return !0;
1672
- }, Rn = () => ({ state: e, dispatch: t }) => we(e, t), Dn = () => ({ state: e, dispatch: t }) => Me(e, t), Fn = () => ({ state: e, dispatch: t }) => Se(e, t), _n = () => ({ state: e, dispatch: t }) => Ee(e, t), Ln = () => ({ state: e, dispatch: t, tr: n }) => {
1673
- try {
1674
- const r = Tt(e.doc, e.selection.$from.pos, -1);
1675
- return r == null ? !1 : (n.join(r, 2), t && t(n), !0);
1676
- } catch {
1677
- return !1;
1678
- }
1679
- }, zn = () => ({ state: e, dispatch: t, tr: n }) => {
1680
- try {
1681
- const r = Tt(e.doc, e.selection.$from.pos, 1);
1682
- return r == null ? !1 : (n.join(r, 2), t && t(n), !0);
1683
- } catch {
1684
- return !1;
1685
- }
1686
- }, Vn = () => ({ state: e, dispatch: t }) => xe(e, t), Hn = () => ({ state: e, dispatch: t }) => Te(e, t);
1687
- function Ut() {
1688
- return typeof navigator < "u" ? /Mac/.test(navigator.platform) : !1;
1689
- }
1690
- function Wn(e) {
1691
- const t = e.split(/-(?!$)/);
1692
- let n = t[t.length - 1];
1693
- n === "Space" && (n = " ");
1694
- let r, o, s, i;
1695
- for (let a = 0; a < t.length - 1; a += 1) {
1696
- const c = t[a];
1697
- if (/^(cmd|meta|m)$/i.test(c))
1698
- i = !0;
1699
- else if (/^a(lt)?$/i.test(c))
1700
- r = !0;
1701
- else if (/^(c|ctrl|control)$/i.test(c))
1702
- o = !0;
1703
- else if (/^s(hift)?$/i.test(c))
1704
- s = !0;
1705
- else if (/^mod$/i.test(c))
1706
- gt() || Ut() ? i = !0 : o = !0;
1707
- else
1708
- throw new Error(`Unrecognized modifier name: ${c}`);
1709
- }
1710
- return r && (n = `Alt-${n}`), o && (n = `Ctrl-${n}`), i && (n = `Meta-${n}`), s && (n = `Shift-${n}`), n;
1711
- }
1712
- var Un = (e) => ({ editor: t, view: n, tr: r, dispatch: o }) => {
1713
- const s = Wn(e).split(/-(?!$)/), i = s.find((l) => !["Alt", "Ctrl", "Meta", "Shift"].includes(l)), a = new KeyboardEvent("keydown", {
1714
- key: i === "Space" ? " " : i,
1715
- altKey: s.includes("Alt"),
1716
- ctrlKey: s.includes("Ctrl"),
1717
- metaKey: s.includes("Meta"),
1718
- shiftKey: s.includes("Shift"),
1719
- bubbles: !0,
1720
- cancelable: !0
1721
- }), c = t.captureTransaction(() => {
1722
- n.someProp("handleKeyDown", (l) => l(n, a));
1723
- });
1724
- return c?.steps.forEach((l) => {
1725
- const d = l.map(r.mapping);
1726
- d && o && r.maybeStep(d);
1727
- }), !0;
1728
- }, qn = (e, t = {}) => ({ state: n, dispatch: r }) => {
1729
- const o = E(e, n.schema);
1730
- return L(n, o, t) ? Ce(n, r) : !1;
1731
- }, Kn = () => ({ state: e, dispatch: t }) => Ae(e, t), Jn = (e) => ({ state: t, dispatch: n }) => {
1732
- const r = E(e, t.schema);
1733
- return Re(r)(t, n);
1734
- }, Gn = () => ({ state: e, dispatch: t }) => Pe(e, t);
1735
- function Et(e, t) {
1736
- const n = typeof t == "string" ? [t] : t;
1737
- return Object.keys(e).reduce((r, o) => (n.includes(o) || (r[o] = e[o]), r), {});
1738
- }
1739
- var Xn = (e, t) => ({ tr: n, state: r, dispatch: o }) => {
1740
- let s = null, i = null;
1741
- const a = Z(
1742
- typeof e == "string" ? e : e.name,
1743
- r.schema
1744
- );
1745
- return a ? (a === "node" && (s = E(e, r.schema)), a === "mark" && (i = $(e, r.schema)), o && n.selection.ranges.forEach((c) => {
1746
- r.doc.nodesBetween(c.$from.pos, c.$to.pos, (l, d) => {
1747
- s && s === l.type && n.setNodeMarkup(d, void 0, Et(l.attrs, t)), i && l.marks.length && l.marks.forEach((u) => {
1748
- i === u.type && n.addMark(d, d + l.nodeSize, i.create(Et(u.attrs, t)));
1749
- });
1750
- });
1751
- }), !0) : !1;
1752
- }, Yn = () => ({ tr: e, dispatch: t }) => (t && e.scrollIntoView(), !0), Qn = () => ({ tr: e, dispatch: t }) => {
1753
- if (t) {
1754
- const n = new ie(e.doc);
1755
- e.setSelection(n);
1756
- }
1757
- return !0;
1758
- }, Zn = () => ({ state: e, dispatch: t }) => $e(e, t), tr = () => ({ state: e, dispatch: t }) => Ie(e, t), er = () => ({ state: e, dispatch: t }) => Ne(e, t), nr = () => ({ state: e, dispatch: t }) => Oe(e, t), rr = () => ({ state: e, dispatch: t }) => Be(e, t), or = (e, { errorOnInvalidContent: t, emitUpdate: n = !0, parseOptions: r = {} } = {}) => ({ editor: o, tr: s, dispatch: i, commands: a }) => {
1759
- const { doc: c } = s;
1760
- if (r.preserveWhitespace !== "full") {
1761
- const l = it(e, o.schema, r, {
1762
- errorOnInvalidContent: t ?? o.options.enableContentCheck
1763
- });
1764
- return i && s.replaceWith(0, c.content.size, l).setMeta("preventUpdate", !n), !0;
1765
- }
1766
- return i && s.setMeta("preventUpdate", !n), a.insertContentAt({ from: 0, to: c.content.size }, e, {
1767
- parseOptions: r,
1768
- errorOnInvalidContent: t ?? o.options.enableContentCheck
1769
- });
1770
- };
1771
- function sr(e, t, n) {
1772
- var r;
1773
- const { selection: o } = t;
1774
- let s = null;
1775
- if (Ft(o) && (s = o.$cursor), s) {
1776
- const a = (r = e.storedMarks) != null ? r : s.marks();
1777
- return s.parent.type.allowsMarkType(n) && (!!n.isInSet(a) || !a.some((l) => l.type.excludes(n)));
1778
- }
1779
- const { ranges: i } = o;
1780
- return i.some(({ $from: a, $to: c }) => {
1781
- let l = a.depth === 0 ? e.doc.inlineContent && e.doc.type.allowsMarkType(n) : !1;
1782
- return e.doc.nodesBetween(a.pos, c.pos, (d, u, p) => {
1783
- if (l)
1784
- return !1;
1785
- if (d.isInline) {
1786
- const f = !p || p.type.allowsMarkType(n), g = !!n.isInSet(d.marks) || !d.marks.some((m) => m.type.excludes(n));
1787
- l = f && g;
1788
- }
1789
- return !l;
1790
- }), l;
1791
- });
1792
- }
1793
- var ir = (e, t = {}) => ({ tr: n, state: r, dispatch: o }) => {
1794
- const { selection: s } = n, { empty: i, ranges: a } = s, c = $(e, r.schema);
1795
- if (o)
1796
- if (i) {
1797
- const l = jt(r, c);
1798
- n.addStoredMark(
1799
- c.create({
1800
- ...l,
1801
- ...t
1802
- })
1803
- );
1804
- } else
1805
- a.forEach((l) => {
1806
- const d = l.$from.pos, u = l.$to.pos;
1807
- r.doc.nodesBetween(d, u, (p, f) => {
1808
- const g = Math.max(f, d), m = Math.min(f + p.nodeSize, u);
1809
- p.marks.find((v) => v.type === c) ? p.marks.forEach((v) => {
1810
- c === v.type && n.addMark(
1811
- g,
1812
- m,
1813
- c.create({
1814
- ...v.attrs,
1815
- ...t
1816
- })
1817
- );
1818
- }) : n.addMark(g, m, c.create(t));
1819
- });
1820
- });
1821
- return sr(r, n, c);
1822
- }, ar = (e, t) => ({ tr: n }) => (n.setMeta(e, t), !0), cr = (e, t = {}) => ({ state: n, dispatch: r, chain: o }) => {
1823
- const s = E(e, n.schema);
1824
- let i;
1825
- return n.selection.$anchor.sameParent(n.selection.$head) && (i = n.selection.$anchor.parent.attrs), s.isTextblock ? o().command(({ commands: a }) => yt(s, { ...i, ...t })(n) ? !0 : a.clearNodes()).command(({ state: a }) => yt(s, { ...i, ...t })(a, r)).run() : (console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'), !1);
1826
- }, lr = (e) => ({ tr: t, dispatch: n }) => {
1827
- if (n) {
1828
- const { doc: r } = t, o = O(e, 0, r.content.size), s = G.create(r, o);
1829
- t.setSelection(s);
1919
+ t.filter((n) => !!b(n, "addNodeView")).map((n) => {
1920
+ const r = this.attributes.filter((a) => a.type === n.name), o = {
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
+ }, s = b(n, "addNodeView", o);
1927
+ if (!s)
1928
+ return [];
1929
+ const i = (a, c, l, u, d) => {
1930
+ const f = X(a, r);
1931
+ return s()({
1932
+ // pass-through
1933
+ node: a,
1934
+ view: c,
1935
+ getPos: l,
1936
+ decorations: u,
1937
+ innerDecorations: d,
1938
+ // tiptap-specific
1939
+ editor: e,
1940
+ extension: n,
1941
+ HTMLAttributes: f
1942
+ });
1943
+ };
1944
+ return [n.name, i];
1945
+ })
1946
+ );
1830
1947
  }
1831
- return !0;
1832
- }, dr = (e) => ({ tr: t, dispatch: n }) => {
1833
- if (n) {
1834
- const { doc: r } = t, { from: o, to: s } = typeof e == "number" ? { from: e, to: e } : e, i = A.atStart(r).from, a = A.atEnd(r).to, c = O(o, i, a), l = O(s, i, a), d = A.create(r, c, l);
1835
- t.setSelection(d);
1948
+ get markViews() {
1949
+ const { editor: e } = this, { markExtensions: t } = H(this.extensions);
1950
+ return Object.fromEntries(
1951
+ t.filter((n) => !!b(n, "addMarkView")).map((n) => {
1952
+ const r = this.attributes.filter((a) => a.type === n.name), o = {
1953
+ name: n.name,
1954
+ options: n.options,
1955
+ storage: this.editor.extensionStorage[n.name],
1956
+ editor: e,
1957
+ type: I(n.name, this.schema)
1958
+ }, s = b(n, "addMarkView", o);
1959
+ if (!s)
1960
+ return [];
1961
+ const i = (a, c, l) => {
1962
+ const u = X(a, r);
1963
+ return s()({
1964
+ // pass-through
1965
+ mark: a,
1966
+ view: c,
1967
+ inline: l,
1968
+ // tiptap-specific
1969
+ editor: e,
1970
+ extension: n,
1971
+ HTMLAttributes: u,
1972
+ updateAttributes: (d) => {
1973
+ zr(a, e, d);
1974
+ }
1975
+ });
1976
+ };
1977
+ return [n.name, i];
1978
+ })
1979
+ );
1836
1980
  }
1837
- return !0;
1838
- }, ur = (e) => ({ state: t, dispatch: n }) => {
1839
- const r = E(e, t.schema);
1840
- return De(r)(t, n);
1841
- };
1842
- function xt(e, t) {
1843
- const n = e.storedMarks || e.selection.$to.parentOffset && e.selection.$from.marks();
1844
- if (n) {
1845
- const r = n.filter((o) => t?.includes(o.type.name));
1846
- e.tr.ensureMarks(r);
1981
+ /**
1982
+ * Go through all extensions, create extension storages & setup marks
1983
+ * & bind editor event listener.
1984
+ */
1985
+ setupExtensions() {
1986
+ const e = this.extensions;
1987
+ this.editor.extensionStorage = Object.fromEntries(
1988
+ e.map((t) => [t.name, t.storage])
1989
+ ), e.forEach((t) => {
1990
+ var n;
1991
+ const r = {
1992
+ name: t.name,
1993
+ options: t.options,
1994
+ storage: this.editor.extensionStorage[t.name],
1995
+ editor: this.editor,
1996
+ type: lt(t.name, this.schema)
1997
+ };
1998
+ t.type === "mark" && ((n = x(b(t, "keepOnSplit", r))) == null || n) && this.splittableMarks.push(t.name);
1999
+ const o = b(t, "onBeforeCreate", r), s = b(t, "onCreate", r), i = b(t, "onUpdate", r), a = b(
2000
+ t,
2001
+ "onSelectionUpdate",
2002
+ r
2003
+ ), c = b(t, "onTransaction", r), l = b(t, "onFocus", r), u = b(t, "onBlur", r), d = b(t, "onDestroy", r);
2004
+ o && this.editor.on("beforeCreate", o), s && this.editor.on("create", s), i && this.editor.on("update", i), a && this.editor.on("selectionUpdate", a), c && this.editor.on("transaction", c), l && this.editor.on("focus", l), u && this.editor.on("blur", u), d && this.editor.on("destroy", d);
2005
+ });
1847
2006
  }
1848
- }
1849
- var fr = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor: o }) => {
1850
- const { selection: s, doc: i } = t, { $from: a, $to: c } = s, l = o.extensionManager.attributes, d = q(l, a.node().type.name, a.node().attrs);
1851
- if (s instanceof G && s.node.isBlock)
1852
- return !a.parentOffset || !U(i, a.pos) ? !1 : (r && (e && xt(n, o.extensionManager.splittableMarks), t.split(a.pos).scrollIntoView()), !0);
1853
- if (!a.parent.isBlock)
1854
- return !1;
1855
- const u = c.parentOffset === c.parent.content.size, p = a.depth === 0 ? void 0 : Ve(a.node(-1).contentMatchAt(a.indexAfter(-1)));
1856
- let f = u && p ? [
1857
- {
1858
- type: p,
1859
- attrs: d
1860
- }
1861
- ] : void 0, g = U(t.doc, t.mapping.map(a.pos), 1, f);
1862
- if (!f && !g && U(t.doc, t.mapping.map(a.pos), 1, p ? [{ type: p }] : void 0) && (g = !0, f = p ? [
1863
- {
1864
- type: p,
1865
- attrs: d
1866
- }
1867
- ] : void 0), r) {
1868
- if (g && (s instanceof A && t.deleteSelection(), t.split(t.mapping.map(a.pos), 1, f), p && !u && !a.parentOffset && a.parent.type !== p)) {
1869
- const m = t.mapping.map(a.before()), h = t.doc.resolve(m);
1870
- a.node(-1).canReplaceWith(h.index(), h.index() + 1, p) && t.setNodeMarkup(t.mapping.map(a.before()), p);
1871
- }
1872
- e && xt(n, o.extensionManager.splittableMarks), t.scrollIntoView();
2007
+ };
2008
+ st.resolve = qt;
2009
+ st.sort = wt;
2010
+ st.flatten = yt;
2011
+ var Ar = {};
2012
+ ht(Ar, {
2013
+ ClipboardTextSerializer: () => Xt,
2014
+ Commands: () => Yt,
2015
+ Delete: () => te,
2016
+ Drop: () => ee,
2017
+ Editable: () => ne,
2018
+ FocusEvents: () => oe,
2019
+ Keymap: () => se,
2020
+ Paste: () => ie,
2021
+ Tabindex: () => ae,
2022
+ focusEventsPluginKey: () => re
2023
+ });
2024
+ var R = class Gt extends xt {
2025
+ constructor() {
2026
+ super(...arguments), this.type = "extension";
1873
2027
  }
1874
- return g;
1875
- }, pr = (e, t = {}) => ({ tr: n, state: r, dispatch: o, editor: s }) => {
1876
- var i;
1877
- const a = E(e, r.schema), { $from: c, $to: l } = r.selection, d = r.selection.node;
1878
- if (d && d.isBlock || c.depth < 2 || !c.sameParent(l))
1879
- return !1;
1880
- const u = c.node(-1);
1881
- if (u.type !== a)
1882
- return !1;
1883
- const p = s.extensionManager.attributes;
1884
- if (c.parent.content.size === 0 && c.node(-1).childCount === c.indexAfter(-1)) {
1885
- if (c.depth === 2 || c.node(-3).type !== a || c.index(-2) !== c.node(-2).childCount - 1)
1886
- return !1;
1887
- if (o) {
1888
- let v = N.empty;
1889
- const b = c.index(-1) ? 1 : c.index(-2) ? 2 : 3;
1890
- for (let C = c.depth - b; C >= c.depth - 3; C -= 1)
1891
- v = N.from(c.node(C).copy(v));
1892
- const k = (
1893
- // eslint-disable-next-line no-nested-ternary
1894
- c.indexAfter(-1) < c.node(-2).childCount ? 1 : c.indexAfter(-2) < c.node(-3).childCount ? 2 : 3
1895
- ), S = {
1896
- ...q(p, c.node().type.name, c.node().attrs),
1897
- ...t
1898
- }, M = ((i = a.contentMatch.defaultType) == null ? void 0 : i.createAndFill(S)) || void 0;
1899
- v = v.append(N.from(a.createAndFill(null, M) || void 0));
1900
- const x = c.before(c.depth - (b - 1));
1901
- n.replace(x, c.after(-k), new ve(v, 4 - b, 0));
1902
- let T = -1;
1903
- n.doc.nodesBetween(x, n.doc.content.size, (C, j) => {
1904
- if (T > -1)
1905
- return !1;
1906
- C.isTextblock && C.content.size === 0 && (T = j + 1);
1907
- }), T > -1 && n.setSelection(A.near(n.doc.resolve(T))), n.scrollIntoView();
1908
- }
1909
- return !0;
2028
+ /**
2029
+ * Create a new Extension instance
2030
+ * @param config - Extension configuration object or a function that returns a configuration object
2031
+ */
2032
+ static create(t = {}) {
2033
+ const n = typeof t == "function" ? t() : t;
2034
+ return new Gt(n);
1910
2035
  }
1911
- const f = l.pos === c.end() ? u.contentMatchAt(0).defaultType : null, g = {
1912
- ...q(p, u.type.name, u.attrs),
1913
- ...t
1914
- }, m = {
1915
- ...q(p, c.node().type.name, c.node().attrs),
1916
- ...t
1917
- };
1918
- n.delete(c.pos, l.pos);
1919
- const h = f ? [
1920
- { type: a, attrs: g },
1921
- { type: f, attrs: m }
1922
- ] : [{ type: a, attrs: g }];
1923
- if (!U(n.doc, c.pos, 2))
1924
- return !1;
1925
- if (o) {
1926
- const { selection: v, storedMarks: b } = r, { splittableMarks: k } = s.extensionManager, S = b || v.$to.parentOffset && v.$from.marks();
1927
- if (n.split(c.pos, 2, h).scrollIntoView(), !S || !o)
1928
- return !0;
1929
- const M = S.filter((x) => k.includes(x.type.name));
1930
- n.ensureMarks(M);
2036
+ configure(t) {
2037
+ return super.configure(t);
1931
2038
  }
1932
- return !0;
1933
- }, ot = (e, t) => {
1934
- const n = Q((i) => i.type === t)(e.selection);
1935
- if (!n)
1936
- return !0;
1937
- const r = e.doc.resolve(Math.max(0, n.pos - 1)).before(n.depth);
1938
- if (r === void 0)
1939
- return !0;
1940
- const o = e.doc.nodeAt(r);
1941
- return n.node.type === o?.type && ct(e.doc, n.pos) && e.join(n.pos), !0;
1942
- }, st = (e, t) => {
1943
- const n = Q((i) => i.type === t)(e.selection);
1944
- if (!n)
1945
- return !0;
1946
- const r = e.doc.resolve(n.start).after(n.depth);
1947
- if (r === void 0)
1948
- return !0;
1949
- const o = e.doc.nodeAt(r);
1950
- return n.node.type === o?.type && ct(e.doc, r) && e.join(r), !0;
1951
- }, mr = (e, t, n, r = {}) => ({ editor: o, tr: s, state: i, dispatch: a, chain: c, commands: l, can: d }) => {
1952
- const { extensions: u, splittableMarks: p } = o.extensionManager, f = E(e, i.schema), g = E(t, i.schema), { selection: m, storedMarks: h } = i, { $from: v, $to: b } = m, k = v.blockRange(b), S = h || m.$to.parentOffset && m.$from.marks();
1953
- if (!k)
1954
- return !1;
1955
- const M = Q((x) => St(x.type.name, u))(m);
1956
- if (k.depth >= 1 && M && k.depth - M.depth <= 1) {
1957
- if (M.node.type === f)
1958
- return l.liftListItem(g);
1959
- if (St(M.node.type.name, u) && f.validContent(M.node.content) && a)
1960
- return c().command(() => (s.setNodeMarkup(M.pos, f), !0)).command(() => ot(s, f)).command(() => st(s, f)).run();
1961
- }
1962
- return !n || !S || !a ? c().command(() => d().wrapInList(f, r) ? !0 : l.clearNodes()).wrapInList(f, r).command(() => ot(s, f)).command(() => st(s, f)).run() : c().command(() => {
1963
- const x = d().wrapInList(f, r), T = S.filter((C) => p.includes(C.type.name));
1964
- return s.ensureMarks(T), x ? !0 : l.clearNodes();
1965
- }).wrapInList(f, r).command(() => ot(s, f)).command(() => st(s, f)).run();
1966
- }, hr = (e, t = {}, n = {}) => ({ state: r, commands: o }) => {
1967
- const { extendEmptyMarkRange: s = !1 } = n, i = $(e, r.schema);
1968
- return at(r, i, t) ? o.unsetMark(i, { extendEmptyMarkRange: s }) : o.setMark(i, t);
1969
- }, gr = (e, t, n = {}) => ({ state: r, commands: o }) => {
1970
- const s = E(e, r.schema), i = E(t, r.schema), a = L(r, s, n);
1971
- let c;
1972
- return r.selection.$anchor.sameParent(r.selection.$head) && (c = r.selection.$anchor.parent.attrs), a ? o.setNode(i, c) : o.setNode(s, { ...c, ...n });
1973
- }, vr = (e, t = {}) => ({ state: n, commands: r }) => {
1974
- const o = E(e, n.schema);
1975
- return L(n, o, t) ? r.lift(o) : r.wrapIn(o, t);
1976
- }, yr = () => ({ state: e, dispatch: t }) => {
1977
- const n = e.plugins;
1978
- for (let r = 0; r < n.length; r += 1) {
1979
- const o = n[r];
1980
- let s;
1981
- if (o.spec.isInputRules && (s = o.getState(e))) {
1982
- if (t) {
1983
- const i = e.tr, a = s.transform;
1984
- for (let c = a.steps.length - 1; c >= 0; c -= 1)
1985
- i.step(a.steps[c].invert(a.docs[c]));
1986
- if (s.text) {
1987
- const c = i.doc.resolve(s.from).marks();
1988
- i.replaceWith(s.from, s.to, e.schema.text(s.text, c));
1989
- } else
1990
- i.delete(s.from, s.to);
1991
- }
1992
- return !0;
1993
- }
2039
+ extend(t) {
2040
+ const n = typeof t == "function" ? t() : t;
2041
+ return super.extend(n);
1994
2042
  }
1995
- return !1;
1996
- }, br = () => ({ tr: e, dispatch: t }) => {
1997
- const { selection: n } = e, { empty: r, ranges: o } = n;
1998
- return r || t && o.forEach((s) => {
1999
- e.removeMark(s.$from.pos, s.$to.pos);
2000
- }), !0;
2001
- }, kr = (e, t = {}) => ({ tr: n, state: r, dispatch: o }) => {
2002
- var s;
2003
- const { extendEmptyMarkRange: i = !1 } = t, { selection: a } = n, c = $(e, r.schema), { $from: l, empty: d, ranges: u } = a;
2004
- if (!o)
2005
- return !0;
2006
- if (d && i) {
2007
- let { from: p, to: f } = a;
2008
- const g = (s = l.marks().find((h) => h.type === c)) == null ? void 0 : s.attrs, m = pt(l, c, g);
2009
- m && (p = m.from, f = m.to), n.removeMark(p, f, c);
2010
- } else
2011
- u.forEach((p) => {
2012
- n.removeMark(p.$from.pos, p.$to.pos, c);
2013
- });
2014
- return n.removeStoredMark(c), !0;
2015
- }, wr = (e, t = {}) => ({ tr: n, state: r, dispatch: o }) => {
2016
- let s = null, i = null;
2017
- const a = Z(
2018
- typeof e == "string" ? e : e.name,
2019
- r.schema
2020
- );
2021
- return a ? (a === "node" && (s = E(e, r.schema)), a === "mark" && (i = $(e, r.schema)), o && n.selection.ranges.forEach((c) => {
2022
- const l = c.$from.pos, d = c.$to.pos;
2023
- let u, p, f, g;
2024
- n.selection.empty ? r.doc.nodesBetween(l, d, (m, h) => {
2025
- s && s === m.type && (f = Math.max(h, l), g = Math.min(h + m.nodeSize, d), u = h, p = m);
2026
- }) : r.doc.nodesBetween(l, d, (m, h) => {
2027
- h < l && s && s === m.type && (f = Math.max(h, l), g = Math.min(h + m.nodeSize, d), u = h, p = m), h >= l && h <= d && (s && s === m.type && n.setNodeMarkup(h, void 0, {
2028
- ...m.attrs,
2029
- ...t
2030
- }), i && m.marks.length && m.marks.forEach((v) => {
2031
- if (i === v.type) {
2032
- const b = Math.max(h, l), k = Math.min(h + m.nodeSize, d);
2033
- n.addMark(
2034
- b,
2035
- k,
2036
- i.create({
2037
- ...v.attrs,
2038
- ...t
2039
- })
2040
- );
2043
+ }, Xt = R.create({
2044
+ name: "clipboardTextSerializer",
2045
+ addOptions() {
2046
+ return {
2047
+ blockSeparator: void 0
2048
+ };
2049
+ },
2050
+ addProseMirrorPlugins() {
2051
+ return [
2052
+ new N({
2053
+ key: new D("clipboardTextSerializer"),
2054
+ props: {
2055
+ clipboardTextSerializer: () => {
2056
+ const { editor: e } = this, { state: t, schema: n } = e, { doc: r, selection: o } = t, { ranges: s } = o, i = Math.min(...s.map((u) => u.$from.pos)), a = Math.max(...s.map((u) => u.$to.pos)), c = Kt(n);
2057
+ return Ut(r, { from: i, to: a }, {
2058
+ ...this.options.blockSeparator !== void 0 ? { blockSeparator: this.options.blockSeparator } : {},
2059
+ textSerializers: c
2060
+ });
2061
+ }
2041
2062
  }
2042
- }));
2043
- }), p && (u !== void 0 && n.setNodeMarkup(u, void 0, {
2044
- ...p.attrs,
2045
- ...t
2046
- }), i && p.marks.length && p.marks.forEach((m) => {
2047
- i === m.type && n.addMark(
2048
- f,
2049
- g,
2050
- i.create({
2051
- ...m.attrs,
2052
- ...t
2053
- })
2054
- );
2055
- }));
2056
- }), !0) : !1;
2057
- }, Mr = (e, t = {}) => ({ state: n, dispatch: r }) => {
2058
- const o = E(e, n.schema);
2059
- return je(o, t)(n, r);
2060
- }, Sr = (e, t = {}) => ({ state: n, dispatch: r }) => {
2061
- const o = E(e, n.schema);
2062
- return Fe(o, t)(n, r);
2063
- }, qt = I.create({
2063
+ })
2064
+ ];
2065
+ }
2066
+ }), Yt = R.create({
2064
2067
  name: "commands",
2065
2068
  addCommands() {
2066
2069
  return {
2067
- ...Wt
2070
+ ...Ot
2068
2071
  };
2069
2072
  }
2070
- }), Kt = I.create({
2073
+ }), te = R.create({
2071
2074
  name: "delete",
2072
2075
  onUpdate({ transaction: e, appendedTransactions: t }) {
2073
2076
  var n, r, o;
@@ -2075,60 +2078,60 @@ var fr = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
2075
2078
  var i, a, c, l;
2076
2079
  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$"))
2077
2080
  return;
2078
- const d = ze(e.before, [e, ...t]);
2079
- tn(d).forEach((f) => {
2080
- d.mapping.mapResult(f.oldRange.from).deletedAfter && d.mapping.mapResult(f.oldRange.to).deletedBefore && d.before.nodesBetween(f.oldRange.from, f.oldRange.to, (g, m) => {
2081
- const h = m + g.nodeSize - 2, v = f.oldRange.from <= m && h <= f.oldRange.to;
2081
+ const u = jn(e.before, [e, ...t]);
2082
+ Jn(u).forEach((p) => {
2083
+ u.mapping.mapResult(p.oldRange.from).deletedAfter && u.mapping.mapResult(p.oldRange.to).deletedBefore && u.before.nodesBetween(p.oldRange.from, p.oldRange.to, (m, h) => {
2084
+ const g = h + m.nodeSize - 2, v = p.oldRange.from <= h && g <= p.oldRange.to;
2082
2085
  this.editor.emit("delete", {
2083
2086
  type: "node",
2084
- node: g,
2085
- from: m,
2086
- to: h,
2087
- newFrom: d.mapping.map(m),
2088
- newTo: d.mapping.map(h),
2089
- deletedRange: f.oldRange,
2090
- newRange: f.newRange,
2087
+ node: m,
2088
+ from: h,
2089
+ to: g,
2090
+ newFrom: u.mapping.map(h),
2091
+ newTo: u.mapping.map(g),
2092
+ deletedRange: p.oldRange,
2093
+ newRange: p.newRange,
2091
2094
  partial: !v,
2092
2095
  editor: this.editor,
2093
2096
  transaction: e,
2094
- combinedTransform: d
2097
+ combinedTransform: u
2095
2098
  });
2096
2099
  });
2097
2100
  });
2098
- const p = d.mapping;
2099
- d.steps.forEach((f, g) => {
2100
- var m, h;
2101
- if (f instanceof ue) {
2102
- const v = p.slice(g).map(f.from, -1), b = p.slice(g).map(f.to), k = p.invert().map(v, -1), S = p.invert().map(b), M = (m = d.doc.nodeAt(v - 1)) == null ? void 0 : m.marks.some((T) => T.eq(f.mark)), x = (h = d.doc.nodeAt(b)) == null ? void 0 : h.marks.some((T) => T.eq(f.mark));
2101
+ const f = u.mapping;
2102
+ u.steps.forEach((p, m) => {
2103
+ var h, g;
2104
+ if (p instanceof ue) {
2105
+ const v = f.slice(m).map(p.from, -1), y = f.slice(m).map(p.to), w = f.invert().map(v, -1), M = f.invert().map(y), k = (h = u.doc.nodeAt(v - 1)) == null ? void 0 : h.marks.some((E) => E.eq(p.mark)), S = (g = u.doc.nodeAt(y)) == null ? void 0 : g.marks.some((E) => E.eq(p.mark));
2103
2106
  this.editor.emit("delete", {
2104
2107
  type: "mark",
2105
- mark: f.mark,
2106
- from: f.from,
2107
- to: f.to,
2108
+ mark: p.mark,
2109
+ from: p.from,
2110
+ to: p.to,
2108
2111
  deletedRange: {
2109
- from: k,
2110
- to: S
2112
+ from: w,
2113
+ to: M
2111
2114
  },
2112
2115
  newRange: {
2113
2116
  from: v,
2114
- to: b
2117
+ to: y
2115
2118
  },
2116
- partial: !!(x || M),
2119
+ partial: !!(S || k),
2117
2120
  editor: this.editor,
2118
2121
  transaction: e,
2119
- combinedTransform: d
2122
+ combinedTransform: u
2120
2123
  });
2121
2124
  }
2122
2125
  });
2123
2126
  };
2124
2127
  (o = (r = (n = this.editor.options.coreExtensionOptions) == null ? void 0 : n.delete) == null ? void 0 : r.async) == null || o ? setTimeout(s, 0) : s();
2125
2128
  }
2126
- }), Jt = I.create({
2129
+ }), ee = R.create({
2127
2130
  name: "drop",
2128
2131
  addProseMirrorPlugins() {
2129
2132
  return [
2130
- new P({
2131
- key: new B("tiptapDrop"),
2133
+ new N({
2134
+ key: new D("tiptapDrop"),
2132
2135
  props: {
2133
2136
  handleDrop: (e, t, n, r) => {
2134
2137
  this.editor.emit("drop", {
@@ -2142,25 +2145,25 @@ var fr = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
2142
2145
  })
2143
2146
  ];
2144
2147
  }
2145
- }), Gt = I.create({
2148
+ }), ne = R.create({
2146
2149
  name: "editable",
2147
2150
  addProseMirrorPlugins() {
2148
2151
  return [
2149
- new P({
2150
- key: new B("editable"),
2152
+ new N({
2153
+ key: new D("editable"),
2151
2154
  props: {
2152
2155
  editable: () => this.editor.options.editable
2153
2156
  }
2154
2157
  })
2155
2158
  ];
2156
2159
  }
2157
- }), Xt = new B("focusEvents"), Yt = I.create({
2160
+ }), re = new D("focusEvents"), oe = R.create({
2158
2161
  name: "focusEvents",
2159
2162
  addProseMirrorPlugins() {
2160
2163
  const { editor: e } = this;
2161
2164
  return [
2162
- new P({
2163
- key: Xt,
2165
+ new N({
2166
+ key: re,
2164
2167
  props: {
2165
2168
  handleDOMEvents: {
2166
2169
  focus: (t, n) => {
@@ -2178,15 +2181,15 @@ var fr = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
2178
2181
  })
2179
2182
  ];
2180
2183
  }
2181
- }), Qt = I.create({
2184
+ }), se = R.create({
2182
2185
  name: "keymap",
2183
2186
  addKeyboardShortcuts() {
2184
2187
  const e = () => this.editor.commands.first(({ commands: i }) => [
2185
2188
  () => i.undoInputRule(),
2186
2189
  // maybe convert first text block node to default node
2187
2190
  () => i.command(({ tr: a }) => {
2188
- const { selection: c, doc: l } = a, { empty: d, $anchor: u } = c, { pos: p, parent: f } = u, g = u.parent.isTextblock && p > 0 ? a.doc.resolve(p - 1) : u, m = g.parent.type.spec.isolating, h = u.pos - u.parentOffset, v = m && g.parent.childCount === 1 ? h === u.pos : D.atStart(l).from === p;
2189
- return !d || !f.type.isTextblock || f.textContent.length || !v || v && u.parent.type.name === "paragraph" ? !1 : i.clearNodes();
2191
+ const { selection: c, doc: l } = a, { empty: u, $anchor: d } = c, { pos: f, parent: p } = d, m = d.parent.isTextblock && f > 0 ? a.doc.resolve(f - 1) : d, h = m.parent.type.spec.isolating, g = d.pos - d.parentOffset, v = h && m.parent.childCount === 1 ? g === d.pos : F.atStart(l).from === f;
2192
+ return !u || !p.type.isTextblock || p.textContent.length || !v || v && d.parent.type.name === "paragraph" ? !1 : i.clearNodes();
2190
2193
  }),
2191
2194
  () => i.deleteSelection(),
2192
2195
  () => i.joinBackward(),
@@ -2223,7 +2226,7 @@ var fr = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
2223
2226
  "Ctrl-a": () => this.editor.commands.selectTextblockStart(),
2224
2227
  "Ctrl-e": () => this.editor.commands.selectTextblockEnd()
2225
2228
  };
2226
- return gt() || Ut() ? s : o;
2229
+ return bt() || Lt() ? s : o;
2227
2230
  },
2228
2231
  addProseMirrorPlugins() {
2229
2232
  return [
@@ -2232,36 +2235,36 @@ var fr = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
2232
2235
  // to a paragraph if necessary.
2233
2236
  // This is an alternative to ProseMirror's `AllSelection`, which doesn’t work well
2234
2237
  // with many other commands.
2235
- new P({
2236
- key: new B("clearDocument"),
2238
+ new N({
2239
+ key: new D("clearDocument"),
2237
2240
  appendTransaction: (e, t, n) => {
2238
- if (e.some((m) => m.getMeta("composition")))
2241
+ if (e.some((h) => h.getMeta("composition")))
2239
2242
  return;
2240
- const r = e.some((m) => m.docChanged) && !t.doc.eq(n.doc), o = e.some((m) => m.getMeta("preventClearDocument"));
2243
+ const r = e.some((h) => h.docChanged) && !t.doc.eq(n.doc), o = e.some((h) => h.getMeta("preventClearDocument"));
2241
2244
  if (!r || o)
2242
2245
  return;
2243
- const { empty: s, from: i, to: a } = t.selection, c = D.atStart(t.doc).from, l = D.atEnd(t.doc).to;
2244
- if (s || !(i === c && a === l) || !mt(n.doc))
2246
+ const { empty: s, from: i, to: a } = t.selection, c = F.atStart(t.doc).from, l = F.atEnd(t.doc).to;
2247
+ if (s || !(i === c && a === l) || !Mt(n.doc))
2245
2248
  return;
2246
- const p = n.tr, f = X({
2249
+ const f = n.tr, p = tt({
2247
2250
  state: n,
2248
- transaction: p
2249
- }), { commands: g } = new Y({
2251
+ transaction: f
2252
+ }), { commands: m } = new et({
2250
2253
  editor: this.editor,
2251
- state: f
2254
+ state: p
2252
2255
  });
2253
- if (g.clearNodes(), !!p.steps.length)
2254
- return p;
2256
+ if (m.clearNodes(), !!f.steps.length)
2257
+ return f;
2255
2258
  }
2256
2259
  })
2257
2260
  ];
2258
2261
  }
2259
- }), Zt = I.create({
2262
+ }), ie = R.create({
2260
2263
  name: "paste",
2261
2264
  addProseMirrorPlugins() {
2262
2265
  return [
2263
- new P({
2264
- key: new B("tiptapPaste"),
2266
+ new N({
2267
+ key: new D("tiptapPaste"),
2265
2268
  props: {
2266
2269
  handlePaste: (e, t, n) => {
2267
2270
  this.editor.emit("paste", {
@@ -2274,19 +2277,19 @@ var fr = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
2274
2277
  })
2275
2278
  ];
2276
2279
  }
2277
- }), te = I.create({
2280
+ }), ae = R.create({
2278
2281
  name: "tabindex",
2279
2282
  addProseMirrorPlugins() {
2280
2283
  return [
2281
- new P({
2282
- key: new B("tabindex"),
2284
+ new N({
2285
+ key: new D("tabindex"),
2283
2286
  props: {
2284
2287
  attributes: () => this.editor.isEditable ? { tabindex: "0" } : {}
2285
2288
  }
2286
2289
  })
2287
2290
  ];
2288
2291
  }
2289
- }), Er = class R {
2292
+ }), Cr = class z {
2290
2293
  constructor(t, n, r = !1, o = null) {
2291
2294
  this.currentNode = null, this.actualDepth = null, this.isBlock = r, this.resolvedPos = t, this.editor = n, this.currentNode = o;
2292
2295
  }
@@ -2345,15 +2348,15 @@ var fr = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
2345
2348
  if (this.depth === 0)
2346
2349
  return null;
2347
2350
  const t = this.resolvedPos.start(this.resolvedPos.depth - 1), n = this.resolvedPos.doc.resolve(t);
2348
- return new R(n, this.editor);
2351
+ return new z(n, this.editor);
2349
2352
  }
2350
2353
  get before() {
2351
2354
  let t = this.resolvedPos.doc.resolve(this.from - (this.isBlock ? 1 : 2));
2352
- return t.depth !== this.depth && (t = this.resolvedPos.doc.resolve(this.from - 3)), new R(t, this.editor);
2355
+ return t.depth !== this.depth && (t = this.resolvedPos.doc.resolve(this.from - 3)), new z(t, this.editor);
2353
2356
  }
2354
2357
  get after() {
2355
2358
  let t = this.resolvedPos.doc.resolve(this.to + (this.isBlock ? 2 : 1));
2356
- return t.depth !== this.depth && (t = this.resolvedPos.doc.resolve(this.to + 3)), new R(t, this.editor);
2359
+ return t.depth !== this.depth && (t = this.resolvedPos.doc.resolve(this.to + 3)), new z(t, this.editor);
2357
2360
  }
2358
2361
  get children() {
2359
2362
  const t = [];
@@ -2364,8 +2367,8 @@ var fr = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
2364
2367
  const a = this.resolvedPos.doc.resolve(i);
2365
2368
  if (!o && a.depth <= this.depth)
2366
2369
  return;
2367
- const c = new R(a, this.editor, o, o ? n : null);
2368
- o && (c.actualDepth = this.depth + 1), t.push(new R(a, this.editor, o, o ? n : null));
2370
+ const c = new z(a, this.editor, o, o ? n : null);
2371
+ o && (c.actualDepth = this.depth + 1), t.push(new z(a, this.editor, o, o ? n : null));
2369
2372
  }), t;
2370
2373
  }
2371
2374
  get firstChild() {
@@ -2411,7 +2414,7 @@ var fr = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
2411
2414
  ...t
2412
2415
  }), this.editor.view.dispatch(n);
2413
2416
  }
2414
- }, xr = `.ProseMirror {
2417
+ }, $r = `.ProseMirror {
2415
2418
  position: relative;
2416
2419
  }
2417
2420
 
@@ -2482,14 +2485,14 @@ img.ProseMirror-separator {
2482
2485
  .ProseMirror-focused .ProseMirror-gapcursor {
2483
2486
  display: block;
2484
2487
  }`;
2485
- function Tr(e, t, n) {
2488
+ function Pr(e, t, n) {
2486
2489
  const r = document.querySelector("style[data-tiptap-style]");
2487
2490
  if (r !== null)
2488
2491
  return r;
2489
2492
  const o = document.createElement("style");
2490
2493
  return t && o.setAttribute("nonce", t), o.setAttribute("data-tiptap-style", ""), o.innerHTML = e, document.getElementsByTagName("head")[0].appendChild(o), o;
2491
2494
  }
2492
- var Lr = class extends Le {
2495
+ var Xr = class extends gr {
2493
2496
  constructor(t = {}) {
2494
2497
  super(), this.css = null, this.editorView = null, this.isFocused = !1, this.isInitialized = !1, this.extensionStorage = {}, this.instanceId = Math.random().toString(36).slice(2, 9), this.options = {
2495
2498
  element: typeof document < "u" ? document.createElement("div") : null,
@@ -2524,8 +2527,8 @@ var Lr = class extends Le {
2524
2527
  onDrop: () => null,
2525
2528
  onDelete: () => null
2526
2529
  }, 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: o, slice: s, moved: i }) => this.options.onDrop(o, s, i)), this.on("paste", ({ event: o, slice: s }) => this.options.onPaste(o, s)), this.on("delete", this.options.onDelete);
2527
- const n = this.createDoc(), r = _t(n, this.options.autofocus);
2528
- this.editorState = se.create({
2530
+ const n = this.createDoc(), r = zt(n, this.options.autofocus);
2531
+ this.editorState = Re.create({
2529
2532
  doc: n,
2530
2533
  schema: this.schema,
2531
2534
  selection: r || void 0
@@ -2587,7 +2590,7 @@ var Lr = class extends Le {
2587
2590
  * Inject CSS styles.
2588
2591
  */
2589
2592
  injectCSS() {
2590
- this.options.injectCSS && typeof document < "u" && (this.css = Tr(xr, this.options.injectNonce));
2593
+ this.options.injectCSS && typeof document < "u" && (this.css = Pr($r, this.options.injectNonce));
2591
2594
  }
2592
2595
  /**
2593
2596
  * Update editor options.
@@ -2660,7 +2663,7 @@ var Lr = class extends Le {
2660
2663
  * @returns The new editor state
2661
2664
  */
2662
2665
  registerPlugin(t, n) {
2663
- const r = $t(n) ? n(t, [...this.state.plugins]) : [...this.state.plugins, t], o = this.state.reconfigure({ plugins: r });
2666
+ const r = Ht(n) ? n(t, [...this.state.plugins]) : [...this.state.plugins, t], o = this.state.reconfigure({ plugins: r });
2664
2667
  return this.view.updateState(o), o;
2665
2668
  }
2666
2669
  /**
@@ -2690,25 +2693,25 @@ var Lr = class extends Le {
2690
2693
  createExtensionManager() {
2691
2694
  var t, n;
2692
2695
  const o = [...this.options.enableCoreExtensions ? [
2693
- Gt,
2694
- Ht.configure({
2696
+ ne,
2697
+ Xt.configure({
2695
2698
  blockSeparator: (n = (t = this.options.coreExtensionOptions) == null ? void 0 : t.clipboardTextSerializer) == null ? void 0 : n.blockSeparator
2696
2699
  }),
2697
- qt,
2698
2700
  Yt,
2699
- Qt,
2700
- te,
2701
- Jt,
2702
- Zt,
2703
- Kt
2701
+ oe,
2702
+ se,
2703
+ ae,
2704
+ ee,
2705
+ ie,
2706
+ te
2704
2707
  ].filter((s) => typeof this.options.enableCoreExtensions == "object" ? this.options.enableCoreExtensions[s.name] !== !1 : !0) : [], ...this.options.extensions].filter((s) => ["extension", "node", "mark"].includes(s?.type));
2705
- this.extensionManager = new et(o, this);
2708
+ this.extensionManager = new st(o, this);
2706
2709
  }
2707
2710
  /**
2708
2711
  * Creates an command manager.
2709
2712
  */
2710
2713
  createCommandManager() {
2711
- this.commandManager = new Y({
2714
+ this.commandManager = new et({
2712
2715
  editor: this
2713
2716
  });
2714
2717
  }
@@ -2724,7 +2727,7 @@ var Lr = class extends Le {
2724
2727
  createDoc() {
2725
2728
  let t;
2726
2729
  try {
2727
- t = it(this.options.content, this.schema, this.options.parseOptions, {
2730
+ t = ft(this.options.content, this.schema, this.options.parseOptions, {
2728
2731
  errorOnInvalidContent: this.options.enableContentCheck
2729
2732
  });
2730
2733
  } catch (n) {
@@ -2736,7 +2739,7 @@ var Lr = class extends Le {
2736
2739
  disableCollaboration: () => {
2737
2740
  "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();
2738
2741
  }
2739
- }), t = it(this.options.content, this.schema, this.options.parseOptions, {
2742
+ }), t = ft(this.options.content, this.schema, this.options.parseOptions, {
2740
2743
  errorOnInvalidContent: !1
2741
2744
  });
2742
2745
  }
@@ -2747,7 +2750,7 @@ var Lr = class extends Le {
2747
2750
  */
2748
2751
  createView(t) {
2749
2752
  var n;
2750
- this.editorView = new ae(t, {
2753
+ this.editorView = new Le(t, {
2751
2754
  ...this.options.editorProps,
2752
2755
  attributes: {
2753
2756
  // add `role="textbox"` to the editor element
@@ -2799,9 +2802,9 @@ var Lr = class extends Le {
2799
2802
  this.capturedTransaction = t;
2800
2803
  return;
2801
2804
  }
2802
- t.steps.forEach((d) => {
2803
- var u;
2804
- return (u = this.capturedTransaction) == null ? void 0 : u.step(d);
2805
+ t.steps.forEach((u) => {
2806
+ var d;
2807
+ return (d = this.capturedTransaction) == null ? void 0 : d.step(u);
2805
2808
  });
2806
2809
  return;
2807
2810
  }
@@ -2820,7 +2823,7 @@ var Lr = class extends Le {
2820
2823
  editor: this,
2821
2824
  transaction: t
2822
2825
  });
2823
- const a = r.findLast((d) => d.getMeta("focus") || d.getMeta("blur")), c = a?.getMeta("focus"), l = a?.getMeta("blur");
2826
+ const a = r.findLast((u) => u.getMeta("focus") || u.getMeta("blur")), c = a?.getMeta("focus"), l = a?.getMeta("blur");
2824
2827
  c && this.emit("focus", {
2825
2828
  editor: this,
2826
2829
  event: c.event,
@@ -2831,7 +2834,7 @@ var Lr = class extends Le {
2831
2834
  event: l.event,
2832
2835
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
2833
2836
  transaction: a
2834
- }), !(t.getMeta("preventUpdate") || !r.some((d) => d.docChanged) || i.doc.eq(n.doc)) && this.emit("update", {
2837
+ }), !(t.getMeta("preventUpdate") || !r.some((u) => u.docChanged) || i.doc.eq(n.doc)) && this.emit("update", {
2835
2838
  editor: this,
2836
2839
  transaction: t,
2837
2840
  appendedTransactions: r.slice(1)
@@ -2841,11 +2844,11 @@ var Lr = class extends Le {
2841
2844
  * Get attributes of the currently selected node or mark.
2842
2845
  */
2843
2846
  getAttributes(t) {
2844
- return Ye(this.state, t);
2847
+ return qn(this.state, t);
2845
2848
  }
2846
2849
  isActive(t, n) {
2847
2850
  const r = typeof t == "string" ? t : null, o = typeof t == "string" ? n : t;
2848
- return nn(this.state, r, o);
2851
+ return Qn(this.state, r, o);
2849
2852
  }
2850
2853
  /**
2851
2854
  * Get the document as JSON.
@@ -2857,7 +2860,7 @@ var Lr = class extends Le {
2857
2860
  * Get the document as HTML.
2858
2861
  */
2859
2862
  getHTML() {
2860
- return dt(this.state.doc.content, this.schema);
2863
+ return kt(this.state.doc.content, this.schema);
2861
2864
  }
2862
2865
  /**
2863
2866
  * Get the document as text.
@@ -2866,10 +2869,10 @@ var Lr = class extends Le {
2866
2869
  const { blockSeparator: n = `
2867
2870
 
2868
2871
  `, textSerializers: r = {} } = t || {};
2869
- return Ge(this.state.doc, {
2872
+ return Hn(this.state.doc, {
2870
2873
  blockSeparator: n,
2871
2874
  textSerializers: {
2872
- ...Bt(this.schema),
2875
+ ...Kt(this.schema),
2873
2876
  ...r
2874
2877
  }
2875
2878
  });
@@ -2878,7 +2881,7 @@ var Lr = class extends Le {
2878
2881
  * Check if there is no content.
2879
2882
  */
2880
2883
  get isEmpty() {
2881
- return mt(this.state.doc);
2884
+ return Mt(this.state.doc);
2882
2885
  }
2883
2886
  /**
2884
2887
  * Destroy the editor.
@@ -2903,45 +2906,45 @@ var Lr = class extends Le {
2903
2906
  }
2904
2907
  $pos(t) {
2905
2908
  const n = this.state.doc.resolve(t);
2906
- return new Er(n, this);
2909
+ return new Cr(n, this);
2907
2910
  }
2908
2911
  get $doc() {
2909
2912
  return this.$pos(0);
2910
2913
  }
2911
2914
  };
2912
- function Vr(e) {
2913
- return new tt({
2915
+ function to(e) {
2916
+ return new ot({
2914
2917
  find: e.find,
2915
2918
  handler: ({ state: t, range: n, match: r }) => {
2916
- const o = w(e.getAttributes, void 0, r);
2919
+ const o = x(e.getAttributes, void 0, r);
2917
2920
  if (o === !1 || o === null)
2918
2921
  return null;
2919
2922
  const { tr: s } = t, i = r[r.length - 1], a = r[0];
2920
2923
  if (i) {
2921
- const c = a.search(/\S/), l = n.from + a.indexOf(i), d = l + i.length;
2922
- if (Dt(n.from, n.to, t.doc).filter((f) => f.mark.type.excluded.find((m) => m === e.type && m !== f.mark.type)).filter((f) => f.to > l).length)
2924
+ const c = a.search(/\S/), l = n.from + a.indexOf(i), u = l + i.length;
2925
+ if (Jt(n.from, n.to, t.doc).filter((p) => p.mark.type.excluded.find((h) => h === e.type && h !== p.mark.type)).filter((p) => p.to > l).length)
2923
2926
  return null;
2924
- d < n.to && s.delete(d, n.to), l > n.from && s.delete(n.from + c, l);
2925
- const p = n.from + c + i.length;
2926
- s.addMark(n.from + c, p, e.type.create(o || {})), s.removeStoredMark(e.type);
2927
+ u < n.to && s.delete(u, n.to), l > n.from && s.delete(n.from + c, l);
2928
+ const f = n.from + c + i.length;
2929
+ s.addMark(n.from + c, f, e.type.create(o || {})), s.removeStoredMark(e.type);
2927
2930
  }
2928
2931
  },
2929
2932
  undoable: e.undoable
2930
2933
  });
2931
2934
  }
2932
- function Hr(e) {
2933
- return new tt({
2935
+ function eo(e) {
2936
+ return new ot({
2934
2937
  find: e.find,
2935
2938
  handler: ({ state: t, range: n, match: r }) => {
2936
- const o = w(e.getAttributes, void 0, r) || {}, { tr: s } = t, i = n.from;
2939
+ const o = x(e.getAttributes, void 0, r) || {}, { tr: s } = t, i = n.from;
2937
2940
  let a = n.to;
2938
2941
  const c = e.type.create(o);
2939
2942
  if (r[1]) {
2940
2943
  const l = r[0].lastIndexOf(r[1]);
2941
- let d = i + l;
2942
- d > a ? d = a : a = d + r[1].length;
2943
- const u = r[0][r[0].length - 1];
2944
- s.insertText(u, i + r[0].length - 1), s.replaceWith(d, a, c);
2944
+ let u = i + l;
2945
+ u > a ? u = a : a = u + r[1].length;
2946
+ const d = r[0][r[0].length - 1];
2947
+ s.insertText(d, i + r[0].length - 1), s.replaceWith(u, a, c);
2945
2948
  } else if (r[0]) {
2946
2949
  const l = e.type.isInline ? i : i - 1;
2947
2950
  s.insert(l, e.type.create(o)).delete(s.mapping.map(i), s.mapping.map(a));
@@ -2951,11 +2954,11 @@ function Hr(e) {
2951
2954
  undoable: e.undoable
2952
2955
  });
2953
2956
  }
2954
- function Wr(e) {
2955
- return new tt({
2957
+ function no(e) {
2958
+ return new ot({
2956
2959
  find: e.find,
2957
2960
  handler: ({ state: t, range: n, match: r }) => {
2958
- const o = t.doc.resolve(n.from), s = w(e.getAttributes, void 0, r) || {};
2961
+ const o = t.doc.resolve(n.from), s = x(e.getAttributes, void 0, r) || {};
2959
2962
  if (!o.node(-1).canReplaceWith(o.index(-1), o.indexAfter(-1), e.type))
2960
2963
  return null;
2961
2964
  t.tr.delete(n.from, n.to).setBlockType(n.from, n.from, e.type, s);
@@ -2963,33 +2966,33 @@ function Wr(e) {
2963
2966
  undoable: e.undoable
2964
2967
  });
2965
2968
  }
2966
- function Ur(e) {
2967
- return new tt({
2969
+ function ro(e) {
2970
+ return new ot({
2968
2971
  find: e.find,
2969
2972
  handler: ({ state: t, range: n, match: r, chain: o }) => {
2970
- const s = w(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, s);
2973
+ const s = x(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, s);
2971
2974
  if (!l)
2972
2975
  return null;
2973
2976
  if (i.wrap(c, l), e.keepMarks && e.editor) {
2974
- const { selection: u, storedMarks: p } = t, { splittableMarks: f } = e.editor.extensionManager, g = p || u.$to.parentOffset && u.$from.marks();
2975
- if (g) {
2976
- const m = g.filter((h) => f.includes(h.type.name));
2977
- i.ensureMarks(m);
2977
+ const { selection: d, storedMarks: f } = t, { splittableMarks: p } = e.editor.extensionManager, m = f || d.$to.parentOffset && d.$from.marks();
2978
+ if (m) {
2979
+ const h = m.filter((g) => p.includes(g.type.name));
2980
+ i.ensureMarks(h);
2978
2981
  }
2979
2982
  }
2980
2983
  if (e.keepAttributes) {
2981
- const u = e.type.name === "bulletList" || e.type.name === "orderedList" ? "listItem" : "taskList";
2982
- o().updateAttributes(u, s).run();
2984
+ const d = e.type.name === "bulletList" || e.type.name === "orderedList" ? "listItem" : "taskList";
2985
+ o().updateAttributes(d, s).run();
2983
2986
  }
2984
- const d = i.doc.resolve(n.from - 1).nodeBefore;
2985
- d && d.type === e.type && ct(i.doc, n.from - 1) && (!e.joinPredicate || e.joinPredicate(r, d)) && i.join(n.from - 1);
2987
+ const u = i.doc.resolve(n.from - 1).nodeBefore;
2988
+ u && u.type === e.type && mt(i.doc, n.from - 1) && (!e.joinPredicate || e.joinPredicate(r, u)) && i.join(n.from - 1);
2986
2989
  },
2987
2990
  undoable: e.undoable
2988
2991
  });
2989
2992
  }
2990
- function qr(e, t) {
2993
+ function oo(e, t) {
2991
2994
  const { selection: n } = e, { $from: r } = n;
2992
- if (n instanceof G) {
2995
+ if (n instanceof Y) {
2993
2996
  const s = r.index();
2994
2997
  return r.parent.canReplaceWith(s, s + 1, t);
2995
2998
  }
@@ -3002,30 +3005,361 @@ function qr(e, t) {
3002
3005
  }
3003
3006
  return !1;
3004
3007
  }
3005
- function Cr(e, t, n = {}) {
3008
+ var Nr = {};
3009
+ ht(Nr, {
3010
+ createAtomBlockMarkdownSpec: () => Ir,
3011
+ createBlockMarkdownSpec: () => Rr,
3012
+ createInlineMarkdownSpec: () => Or,
3013
+ parseAttributes: () => St,
3014
+ parseIndentedBlocks: () => _r,
3015
+ renderNestedMarkdownContent: () => Dr,
3016
+ serializeAttributes: () => Et
3017
+ });
3018
+ function St(e) {
3019
+ if (!e?.trim())
3020
+ return {};
3021
+ const t = {}, n = [], r = e.replace(/["']([^"']*)["']/g, (l) => (n.push(l), `__QUOTED_${n.length - 1}__`)), o = r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);
3022
+ if (o) {
3023
+ const l = o.map((u) => u.trim().slice(1));
3024
+ t.class = l.join(" ");
3025
+ }
3026
+ const s = r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);
3027
+ s && (t.id = s[1]);
3028
+ const i = /([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;
3029
+ Array.from(r.matchAll(i)).forEach(([, l, u]) => {
3030
+ var d;
3031
+ const f = parseInt(((d = u.match(/__QUOTED_(\d+)__/)) == null ? void 0 : d[1]) || "0", 10), p = n[f];
3032
+ p && (t[l] = p.slice(1, -1));
3033
+ });
3034
+ 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();
3035
+ return c && c.split(/\s+/).filter(Boolean).forEach((u) => {
3036
+ u.match(/^[a-zA-Z][\w-]*$/) && (t[u] = !0);
3037
+ }), t;
3038
+ }
3039
+ function Et(e) {
3040
+ if (!e || Object.keys(e).length === 0)
3041
+ return "";
3042
+ const t = [];
3043
+ 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]) => {
3044
+ n === "class" || n === "id" || (r === !0 ? t.push(n) : r !== !1 && r != null && t.push(`${n}="${String(r)}"`));
3045
+ }), t.join(" ");
3046
+ }
3047
+ function Ir(e) {
3048
+ const {
3049
+ nodeName: t,
3050
+ name: n,
3051
+ parseAttributes: r = St,
3052
+ serializeAttributes: o = Et,
3053
+ defaultAttributes: s = {},
3054
+ requiredAttributes: i = [],
3055
+ allowedAttributes: a
3056
+ } = e, c = n || t, l = (u) => {
3057
+ if (!a)
3058
+ return u;
3059
+ const d = {};
3060
+ return a.forEach((f) => {
3061
+ f in u && (d[f] = u[f]);
3062
+ }), d;
3063
+ };
3064
+ return {
3065
+ parseMarkdown: (u, d) => {
3066
+ const f = { ...s, ...u.attributes };
3067
+ return d.createNode(t, f, []);
3068
+ },
3069
+ markdownTokenizer: {
3070
+ name: t,
3071
+ level: "block",
3072
+ start(u) {
3073
+ var d;
3074
+ const f = new RegExp(`^:::${c}(?:\\s|$)`, "m"), p = (d = u.match(f)) == null ? void 0 : d.index;
3075
+ return p !== void 0 ? p : -1;
3076
+ },
3077
+ tokenize(u, d, f) {
3078
+ const p = new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`), m = u.match(p);
3079
+ if (!m)
3080
+ return;
3081
+ const h = m[1] || "", g = r(h);
3082
+ if (!i.find((y) => !(y in g)))
3083
+ return {
3084
+ type: t,
3085
+ raw: m[0],
3086
+ attributes: g
3087
+ };
3088
+ }
3089
+ },
3090
+ renderMarkdown: (u) => {
3091
+ const d = l(u.attrs || {}), f = o(d), p = f ? ` {${f}}` : "";
3092
+ return `:::${c}${p} :::`;
3093
+ }
3094
+ };
3095
+ }
3096
+ function Rr(e) {
3097
+ const {
3098
+ nodeName: t,
3099
+ name: n,
3100
+ getContent: r,
3101
+ parseAttributes: o = St,
3102
+ serializeAttributes: s = Et,
3103
+ defaultAttributes: i = {},
3104
+ content: a = "block",
3105
+ allowedAttributes: c
3106
+ } = e, l = n || t, u = (d) => {
3107
+ if (!c)
3108
+ return d;
3109
+ const f = {};
3110
+ return c.forEach((p) => {
3111
+ p in d && (f[p] = d[p]);
3112
+ }), f;
3113
+ };
3114
+ return {
3115
+ parseMarkdown: (d, f) => {
3116
+ let p;
3117
+ if (r) {
3118
+ const h = r(d);
3119
+ p = typeof h == "string" ? [{ type: "text", text: h }] : h;
3120
+ } else a === "block" ? p = f.parseChildren(d.tokens || []) : p = f.parseInline(d.tokens || []);
3121
+ const m = { ...i, ...d.attributes };
3122
+ return f.createNode(t, m, p);
3123
+ },
3124
+ markdownTokenizer: {
3125
+ name: t,
3126
+ level: "block",
3127
+ start(d) {
3128
+ var f;
3129
+ const p = new RegExp(`^:::${l}`, "m"), m = (f = d.match(p)) == null ? void 0 : f.index;
3130
+ return m !== void 0 ? m : -1;
3131
+ },
3132
+ tokenize(d, f, p) {
3133
+ var m;
3134
+ const h = new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*\\n`), g = d.match(h);
3135
+ if (!g)
3136
+ return;
3137
+ const [v, y = ""] = g, w = o(y);
3138
+ let M = 1;
3139
+ const k = v.length;
3140
+ let S = "";
3141
+ const E = /^:::([\w-]*)(\s.*)?/gm, A = d.slice(k);
3142
+ for (E.lastIndex = 0; ; ) {
3143
+ const C = E.exec(A);
3144
+ if (C === null)
3145
+ break;
3146
+ const O = C.index, it = C[1];
3147
+ if (!((m = C[2]) != null && m.endsWith(":::"))) {
3148
+ if (it)
3149
+ M += 1;
3150
+ else if (M -= 1, M === 0) {
3151
+ const W = A.slice(0, O);
3152
+ S = W.trim();
3153
+ const at = d.slice(0, k + O + C[0].length);
3154
+ let B = [];
3155
+ if (S)
3156
+ if (a === "block")
3157
+ for (B = p.blockTokens(W), B.forEach((P) => {
3158
+ P.text && (!P.tokens || P.tokens.length === 0) && (P.tokens = p.inlineTokens(P.text));
3159
+ }); B.length > 0; ) {
3160
+ const P = B[B.length - 1];
3161
+ if (P.type === "paragraph" && (!P.text || P.text.trim() === ""))
3162
+ B.pop();
3163
+ else
3164
+ break;
3165
+ }
3166
+ else
3167
+ B = p.inlineTokens(S);
3168
+ return {
3169
+ type: t,
3170
+ raw: at,
3171
+ attributes: w,
3172
+ content: S,
3173
+ tokens: B
3174
+ };
3175
+ }
3176
+ }
3177
+ }
3178
+ }
3179
+ },
3180
+ renderMarkdown: (d, f) => {
3181
+ const p = u(d.attrs || {}), m = s(p), h = m ? ` {${m}}` : "", g = f.renderChildren(d.content || [], `
3182
+
3183
+ `);
3184
+ return `:::${l}${h}
3185
+
3186
+ ${g}
3187
+
3188
+ :::`;
3189
+ }
3190
+ };
3191
+ }
3192
+ function Br(e) {
3193
+ if (!e.trim())
3194
+ return {};
3195
+ const t = {}, n = /(\w+)=(?:"([^"]*)"|'([^']*)')/g;
3196
+ let r = n.exec(e);
3197
+ for (; r !== null; ) {
3198
+ const [, o, s, i] = r;
3199
+ t[o] = s || i, r = n.exec(e);
3200
+ }
3201
+ return t;
3202
+ }
3203
+ function jr(e) {
3204
+ return Object.entries(e).filter(([, t]) => t != null).map(([t, n]) => `${t}="${n}"`).join(" ");
3205
+ }
3206
+ function Or(e) {
3207
+ const {
3208
+ nodeName: t,
3209
+ name: n,
3210
+ getContent: r,
3211
+ parseAttributes: o = Br,
3212
+ serializeAttributes: s = jr,
3213
+ defaultAttributes: i = {},
3214
+ selfClosing: a = !1,
3215
+ allowedAttributes: c
3216
+ } = e, l = n || t, u = (f) => {
3217
+ if (!c)
3218
+ return f;
3219
+ const p = {};
3220
+ return c.forEach((m) => {
3221
+ m in f && (p[m] = f[m]);
3222
+ }), p;
3223
+ }, d = l.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3224
+ return {
3225
+ parseMarkdown: (f, p) => {
3226
+ const m = { ...i, ...f.attributes };
3227
+ if (a)
3228
+ return p.createNode(t, m);
3229
+ const h = r ? r(f) : f.content || "";
3230
+ return h ? p.createNode(t, m, [p.createTextNode(h)]) : p.createNode(t, m, []);
3231
+ },
3232
+ markdownTokenizer: {
3233
+ name: t,
3234
+ level: "inline",
3235
+ start(f) {
3236
+ const p = a ? new RegExp(`\\[${d}\\s*[^\\]]*\\]`) : new RegExp(`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`), m = f.match(p), h = m?.index;
3237
+ return h !== void 0 ? h : -1;
3238
+ },
3239
+ tokenize(f, p, m) {
3240
+ const h = a ? new RegExp(`^\\[${d}\\s*([^\\]]*)\\]`) : new RegExp(`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`), g = f.match(h);
3241
+ if (!g)
3242
+ return;
3243
+ let v = "", y = "";
3244
+ if (a) {
3245
+ const [, M] = g;
3246
+ y = M;
3247
+ } else {
3248
+ const [, M, k] = g;
3249
+ y = M, v = k || "";
3250
+ }
3251
+ const w = o(y.trim());
3252
+ return {
3253
+ type: t,
3254
+ raw: g[0],
3255
+ content: v.trim(),
3256
+ attributes: w
3257
+ };
3258
+ }
3259
+ },
3260
+ renderMarkdown: (f) => {
3261
+ let p = "";
3262
+ r ? p = r(f) : f.content && f.content.length > 0 && (p = f.content.filter((v) => v.type === "text").map((v) => v.text).join(""));
3263
+ const m = u(f.attrs || {}), h = s(m), g = h ? ` ${h}` : "";
3264
+ return a ? `[${l}${g}]` : `[${l}${g}]${p}[/${l}]`;
3265
+ }
3266
+ };
3267
+ }
3268
+ function _r(e, t, n) {
3269
+ var r, o, s, i;
3270
+ const a = e.split(`
3271
+ `), c = [];
3272
+ let l = "", u = 0;
3273
+ const d = t.baseIndentSize || 2;
3274
+ for (; u < a.length; ) {
3275
+ const f = a[u], p = f.match(t.itemPattern);
3276
+ if (!p) {
3277
+ if (c.length > 0)
3278
+ break;
3279
+ if (f.trim() === "") {
3280
+ u += 1;
3281
+ continue;
3282
+ } else
3283
+ return;
3284
+ }
3285
+ const m = t.extractItemData(p), { indentLevel: h, mainContent: g } = m;
3286
+ l = `${l}${f}
3287
+ `;
3288
+ const v = [g];
3289
+ for (u += 1; u < a.length; ) {
3290
+ const k = a[u];
3291
+ if (k.trim() === "") {
3292
+ const E = a.slice(u + 1).findIndex((O) => O.trim() !== "");
3293
+ if (E === -1)
3294
+ break;
3295
+ if ((((o = (r = a[u + 1 + E].match(/^(\s*)/)) == null ? void 0 : r[1]) == null ? void 0 : o.length) || 0) > h) {
3296
+ v.push(k), l = `${l}${k}
3297
+ `, u += 1;
3298
+ continue;
3299
+ } else
3300
+ break;
3301
+ }
3302
+ if ((((i = (s = k.match(/^(\s*)/)) == null ? void 0 : s[1]) == null ? void 0 : i.length) || 0) > h)
3303
+ v.push(k), l = `${l}${k}
3304
+ `, u += 1;
3305
+ else
3306
+ break;
3307
+ }
3308
+ let y;
3309
+ const w = v.slice(1);
3310
+ if (w.length > 0) {
3311
+ const k = w.map((S) => S.slice(h + d)).join(`
3312
+ `);
3313
+ k.trim() && (t.customNestedParser ? y = t.customNestedParser(k) : y = n.blockTokens(k));
3314
+ }
3315
+ const M = t.createToken(m, y);
3316
+ c.push(M);
3317
+ }
3318
+ if (c.length !== 0)
3319
+ return {
3320
+ items: c,
3321
+ raw: l.trim()
3322
+ };
3323
+ }
3324
+ function Dr(e, t, n, r) {
3325
+ if (!e || !Array.isArray(e.content))
3326
+ return "";
3327
+ const o = typeof n == "function" ? n(r) : n, [s, ...i] = e.content, a = t.renderChildren([s]), c = [`${o}${a}`];
3328
+ return i && i.length > 0 && i.forEach((l) => {
3329
+ const u = t.renderChildren([l]);
3330
+ if (u) {
3331
+ const d = u.split(`
3332
+ `).map((f) => f ? t.indent(f) : "").join(`
3333
+ `);
3334
+ c.push(d);
3335
+ }
3336
+ }), c.join(`
3337
+ `);
3338
+ }
3339
+ function zr(e, t, n = {}) {
3006
3340
  const { state: r } = t, { doc: o, tr: s } = r, i = e;
3007
3341
  o.descendants((a, c) => {
3008
- const l = s.mapping.map(c), d = s.mapping.map(c) + a.nodeSize;
3009
- let u = null;
3010
- if (a.marks.forEach((f) => {
3011
- if (f !== i)
3342
+ const l = s.mapping.map(c), u = s.mapping.map(c) + a.nodeSize;
3343
+ let d = null;
3344
+ if (a.marks.forEach((p) => {
3345
+ if (p !== i)
3012
3346
  return !1;
3013
- u = f;
3014
- }), !u)
3347
+ d = p;
3348
+ }), !d)
3015
3349
  return;
3016
- let p = !1;
3017
- if (Object.keys(n).forEach((f) => {
3018
- n[f] !== u.attrs[f] && (p = !0);
3019
- }), p) {
3020
- const f = e.type.create({
3350
+ let f = !1;
3351
+ if (Object.keys(n).forEach((p) => {
3352
+ n[p] !== d.attrs[p] && (f = !0);
3353
+ }), f) {
3354
+ const p = e.type.create({
3021
3355
  ...e.attrs,
3022
3356
  ...n
3023
3357
  });
3024
- s.removeMark(l, d, e.type), s.addMark(l, d, f);
3358
+ s.removeMark(l, u, e.type), s.addMark(l, u, p);
3025
3359
  }
3026
3360
  }), s.docChanged && t.view.dispatch(s);
3027
3361
  }
3028
- var Kr = class ee extends ht {
3362
+ var so = class ce extends xt {
3029
3363
  constructor() {
3030
3364
  super(...arguments), this.type = "node";
3031
3365
  }
@@ -3035,7 +3369,7 @@ var Kr = class ee extends ht {
3035
3369
  */
3036
3370
  static create(t = {}) {
3037
3371
  const n = typeof t == "function" ? t() : t;
3038
- return new ee(n);
3372
+ return new ce(n);
3039
3373
  }
3040
3374
  configure(t) {
3041
3375
  return super.configure(t);
@@ -3045,25 +3379,25 @@ var Kr = class ee extends ht {
3045
3379
  return super.extend(n);
3046
3380
  }
3047
3381
  };
3048
- function Jr(e) {
3049
- return new dn({
3382
+ function io(e) {
3383
+ return new Mr({
3050
3384
  find: e.find,
3051
3385
  handler: ({ state: t, range: n, match: r, pasteEvent: o }) => {
3052
- const s = w(e.getAttributes, void 0, r, o);
3386
+ const s = x(e.getAttributes, void 0, r, o);
3053
3387
  if (s === !1 || s === null)
3054
3388
  return null;
3055
3389
  const { tr: i } = t, a = r[r.length - 1], c = r[0];
3056
3390
  let l = n.to;
3057
3391
  if (a) {
3058
- const d = c.search(/\S/), u = n.from + c.indexOf(a), p = u + a.length;
3059
- if (Dt(n.from, n.to, t.doc).filter((g) => g.mark.type.excluded.find((h) => h === e.type && h !== g.mark.type)).filter((g) => g.to > u).length)
3392
+ const u = c.search(/\S/), d = n.from + c.indexOf(a), f = d + a.length;
3393
+ if (Jt(n.from, n.to, t.doc).filter((m) => m.mark.type.excluded.find((g) => g === e.type && g !== m.mark.type)).filter((m) => m.to > d).length)
3060
3394
  return null;
3061
- p < n.to && i.delete(p, 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(s || {})), i.removeStoredMark(e.type);
3395
+ f < n.to && i.delete(f, n.to), d > n.from && i.delete(n.from + u, d), l = n.from + u + a.length, i.addMark(n.from + u, l, e.type.create(s || {})), i.removeStoredMark(e.type);
3062
3396
  }
3063
3397
  }
3064
3398
  });
3065
3399
  }
3066
- var Gr = (e, t) => {
3400
+ var ao = (e, t) => {
3067
3401
  if (e === "slot")
3068
3402
  return 0;
3069
3403
  if (e instanceof Function)
@@ -3074,33 +3408,35 @@ var Gr = (e, t) => {
3074
3408
  return [e, r, n];
3075
3409
  };
3076
3410
  export {
3077
- I as E,
3078
- cn as M,
3079
- Kr as N,
3080
- Jr as a,
3081
- Vr as b,
3082
- qr as c,
3083
- ze as d,
3084
- Dt as e,
3085
- jr as f,
3086
- tn as g,
3087
- Gr as h,
3088
- _r as i,
3089
- Ye as j,
3090
- L as k,
3091
- Fr as l,
3092
- Ue as m,
3093
- Hr as n,
3094
- Dr as o,
3095
- E as p,
3096
- Rr as q,
3097
- w as r,
3098
- y as s,
3099
- Wr as t,
3100
- He as u,
3101
- mt as v,
3102
- Ur as w,
3103
- hn as x,
3104
- dt as y,
3105
- Lr as z
3411
+ kt as A,
3412
+ Xr as B,
3413
+ R as E,
3414
+ kr as M,
3415
+ so as N,
3416
+ io as a,
3417
+ to as b,
3418
+ oo as c,
3419
+ jn as d,
3420
+ Jt as e,
3421
+ Kr as f,
3422
+ Jn as g,
3423
+ ao as h,
3424
+ Gr as i,
3425
+ qn as j,
3426
+ V as k,
3427
+ Qr as l,
3428
+ zn as m,
3429
+ eo as n,
3430
+ Zr as o,
3431
+ T as p,
3432
+ Jr as q,
3433
+ Dr as r,
3434
+ _r as s,
3435
+ no as t,
3436
+ x as u,
3437
+ b as v,
3438
+ ro as w,
3439
+ _n as x,
3440
+ Mt as y,
3441
+ Ar as z
3106
3442
  };