@clevertask/scribe 0.1.12 → 0.1.13

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 (29) hide show
  1. package/README.md +1 -1
  2. package/dist/{BarMenu-5M9g9Y1j.js → BarMenu-O2IVhHXx.js} +1 -1
  3. package/dist/assets/index.css +1 -1
  4. package/dist/components/Menu/BarMenu.js +1 -1
  5. package/dist/components/Menu/BubbleMenu.js +2 -2
  6. package/dist/components/Menu/CalloutBubbleMenu.js +2 -2
  7. package/dist/components/Menu/LinkBubbleMenu.js +2 -2
  8. package/dist/components/Menu/Mobile/ListOptionBar.js +1 -1
  9. package/dist/components/Menu/TableBubbleMenu.js +2 -2
  10. package/dist/components/Scribe/extension/callout.js +1 -1
  11. package/dist/components/Scribe/extension/emoji/suggest.js +1 -1
  12. package/dist/components/Scribe/extension/extension-link.js +1 -1
  13. package/dist/components/Scribe/extension/extension-markdown-paste.js +1 -1
  14. package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
  15. package/dist/components/Scribe/extension/index.js +1 -1
  16. package/dist/components/Scribe/extension/resizable-table.js +1 -1
  17. package/dist/components/Scribe/extension/slashCommand/index.js +1 -1
  18. package/dist/components/Scribe/extension/slashCommand/renderItems.js +1 -1
  19. package/dist/components/Scribe/extension/tableOfContents.js +1 -1
  20. package/dist/components/Scribe/index.js +3 -3
  21. package/dist/{dist-Dw4STOPE.js → dist-BoYfa2nz.js} +1 -1
  22. package/dist/{dist-DFua_Xbu.js → dist-W9E-K577.js} +980 -618
  23. package/dist/{extension-_8uh0Ik9.js → extension-D5WIAWhc.js} +2106 -2070
  24. package/dist/{extension-link-CjfUZ90W.js → extension-link-D8Zi7OSa.js} +36 -36
  25. package/dist/{menus-_EXlLMjz.js → menus-B1Zz0GjH.js} +17 -17
  26. package/dist/{resizable-table-Ddw3l6DJ.js → resizable-table-Bf-fb9iv.js} +36 -18
  27. package/dist/{slashCommand-CxX07Nbk.js → slashCommand-47omO4ob.js} +2 -2
  28. package/dist/utils/index.js +2 -2
  29. package/package.json +48 -48
@@ -1,18 +1,18 @@
1
1
  import { RemoveMarkStep as e, ReplaceAroundStep as t, ReplaceStep as n, Transform as r, canJoin as i, canSplit as a, findWrapping as o, joinPoint as s, liftTarget as c } from "@tiptap/pm/transform";
2
2
  import { createParagraphNear as l, exitCode as u, joinBackward as d, joinDown as f, joinForward as p, joinTextblockBackward as m, joinTextblockForward as h, joinUp as g, lift as ee, liftEmptyBlock as te, newlineInCode as _, selectNodeBackward as ne, selectNodeForward as v, selectParentNode as re, selectTextblockEnd as ie, selectTextblockStart as y, setBlockType as b, wrapIn as x } from "@tiptap/pm/commands";
3
- import { AllSelection as ae, EditorState as S, NodeSelection as C, Plugin as w, PluginKey as T, Selection as E, TextSelection as D } from "@tiptap/pm/state";
4
- import { DOMParser as oe, DOMSerializer as se, Fragment as O, Node as ce, Schema as le, Slice as ue } from "@tiptap/pm/model";
5
- import { liftListItem as de, sinkListItem as fe, wrapInList as pe } from "@tiptap/pm/schema-list";
6
- import { EditorView as me } from "@tiptap/pm/view";
7
- import { keymap as he } from "@tiptap/pm/keymap";
8
- //#region node_modules/.pnpm/@tiptap+core@3.29.2_@tiptap+pm@3.29.2/node_modules/@tiptap/core/dist/index.js
9
- var ge = Object.defineProperty, _e = (e, t) => {
10
- for (var n in t) ge(e, n, {
3
+ import { AllSelection as ae, EditorState as oe, NodeSelection as se, Plugin as S, PluginKey as C, Selection as w, TextSelection as T } from "@tiptap/pm/state";
4
+ import { DOMParser as ce, DOMSerializer as le, Fragment as E, Schema as ue, Slice as de } from "@tiptap/pm/model";
5
+ import { liftListItem as fe, sinkListItem as pe, wrapInList as me } from "@tiptap/pm/schema-list";
6
+ import { DecorationSet as D, EditorView as he } from "@tiptap/pm/view";
7
+ import { keymap as ge } from "@tiptap/pm/keymap";
8
+ //#region node_modules/.pnpm/@tiptap+core@3.30.1_@tiptap+pm@3.30.1/node_modules/@tiptap/core/dist/index.js
9
+ var _e = Object.defineProperty, ve = (e, t) => {
10
+ for (var n in t) _e(e, n, {
11
11
  get: t[n],
12
12
  enumerable: !0
13
13
  });
14
14
  };
15
- function k(e) {
15
+ function O(e) {
16
16
  let { state: t, transaction: n } = e, { selection: r } = n, { doc: i } = n, { storedMarks: a } = n;
17
17
  return {
18
18
  ...t,
@@ -36,7 +36,7 @@ function k(e) {
36
36
  }
37
37
  };
38
38
  }
39
- var A = class {
39
+ var k = class {
40
40
  constructor(e) {
41
41
  this.editor = e.editor, this.rawCommands = this.editor.extensionManager.commands, this.customState = e.state;
42
42
  }
@@ -84,7 +84,7 @@ var A = class {
84
84
  tr: e,
85
85
  editor: r,
86
86
  view: a,
87
- state: k({
87
+ state: O({
88
88
  state: i,
89
89
  transaction: e
90
90
  }),
@@ -97,74 +97,75 @@ var A = class {
97
97
  };
98
98
  return o;
99
99
  }
100
- }, ve = {};
101
- _e(ve, {
102
- blur: () => ye,
103
- clearContent: () => be,
104
- clearNodes: () => xe,
105
- command: () => Se,
106
- createParagraphNear: () => Ce,
107
- cut: () => we,
108
- deleteCurrentNode: () => Te,
109
- deleteNode: () => Ee,
110
- deleteRange: () => De,
111
- deleteSelection: () => je,
112
- enter: () => Me,
113
- exitCode: () => Ne,
114
- extendMarkRange: () => Re,
115
- first: () => ze,
116
- focus: () => We,
117
- forEach: () => Ge,
118
- insertContent: () => Ke,
119
- insertContentAt: () => Xe,
120
- insertDefaultBlock: () => Qe,
121
- joinBackward: () => tt,
122
- joinDown: () => et,
123
- joinForward: () => nt,
124
- joinItemBackward: () => rt,
125
- joinItemForward: () => it,
126
- joinTextblockBackward: () => at,
127
- joinTextblockForward: () => ot,
128
- joinUp: () => $e,
129
- keyboardShortcut: () => lt,
130
- lift: () => ut,
131
- liftEmptyBlock: () => dt,
132
- liftListItem: () => ft,
133
- newlineInCode: () => pt,
134
- resetAttributes: () => ht,
135
- scrollIntoView: () => gt,
136
- selectAll: () => _t,
137
- selectNodeBackward: () => vt,
138
- selectNodeForward: () => yt,
139
- selectParentNode: () => bt,
140
- selectTextblockEnd: () => xt,
141
- selectTextblockStart: () => St,
142
- setContent: () => wt,
143
- setMark: () => mn,
144
- setMeta: () => hn,
145
- setNode: () => gn,
146
- setNodeSelection: () => _n,
147
- setTextDirection: () => vn,
148
- setTextSelection: () => yn,
149
- sinkListItem: () => bn,
150
- splitBlock: () => Sn,
151
- splitListItem: () => Cn,
152
- toggleList: () => kn,
153
- toggleMark: () => An,
154
- toggleNode: () => jn,
155
- toggleWrap: () => Mn,
156
- undoInputRule: () => Nn,
157
- unsetAllMarks: () => Pn,
158
- unsetMark: () => Fn,
159
- unsetTextDirection: () => In,
160
- updateAttributes: () => Ln,
161
- wrapIn: () => Rn,
162
- wrapInList: () => zn
100
+ }, ye = {};
101
+ ve(ye, {
102
+ blur: () => be,
103
+ clearContent: () => xe,
104
+ clearNodes: () => Se,
105
+ command: () => Ce,
106
+ createParagraphNear: () => we,
107
+ cut: () => Te,
108
+ deleteCurrentNode: () => Ee,
109
+ deleteNode: () => De,
110
+ deleteRange: () => Oe,
111
+ deleteSelection: () => Me,
112
+ enter: () => Ne,
113
+ exitCode: () => Pe,
114
+ extendMarkRange: () => ze,
115
+ first: () => Be,
116
+ focus: () => Ge,
117
+ forEach: () => Ke,
118
+ insertContent: () => qe,
119
+ insertContentAt: () => Qe,
120
+ insertDefaultBlock: () => et,
121
+ joinBackward: () => rt,
122
+ joinDown: () => nt,
123
+ joinForward: () => it,
124
+ joinItemBackward: () => at,
125
+ joinItemForward: () => ot,
126
+ joinTextblockBackward: () => st,
127
+ joinTextblockForward: () => ct,
128
+ joinUp: () => tt,
129
+ keyboardShortcut: () => dt,
130
+ lift: () => ft,
131
+ liftEmptyBlock: () => pt,
132
+ liftListItem: () => mt,
133
+ newlineInCode: () => ht,
134
+ resetAttributes: () => _t,
135
+ scrollIntoView: () => vt,
136
+ selectAll: () => yt,
137
+ selectNodeBackward: () => bt,
138
+ selectNodeForward: () => xt,
139
+ selectParentNode: () => St,
140
+ selectTextblockEnd: () => Ct,
141
+ selectTextblockStart: () => wt,
142
+ setContent: () => Et,
143
+ setMark: () => _n,
144
+ setMeta: () => vn,
145
+ setNode: () => yn,
146
+ setNodeSelection: () => bn,
147
+ setTextDirection: () => xn,
148
+ setTextSelection: () => Sn,
149
+ sinkListItem: () => Cn,
150
+ splitBlock: () => Tn,
151
+ splitListItem: () => En,
152
+ toggleList: () => Mn,
153
+ toggleMark: () => Nn,
154
+ toggleNode: () => Pn,
155
+ toggleWrap: () => Fn,
156
+ undoInputRule: () => In,
157
+ unsetAllMarks: () => Ln,
158
+ unsetMark: () => Rn,
159
+ unsetTextDirection: () => zn,
160
+ updateAttributes: () => Bn,
161
+ updateDecorations: () => Vn,
162
+ wrapIn: () => Hn,
163
+ wrapInList: () => Un
163
164
  });
164
- var ye = () => ({ editor: e, view: t }) => (requestAnimationFrame(() => {
165
+ var be = () => ({ editor: e, view: t }) => (requestAnimationFrame(() => {
165
166
  var n;
166
167
  e.isDestroyed || (t.dom.blur(), (n = window == null ? void 0 : window.getSelection()) == null || n.removeAllRanges());
167
- }), !0), be = (e = !0) => ({ commands: t }) => t.setContent("", { emitUpdate: e }), xe = () => ({ state: e, tr: t, dispatch: n }) => {
168
+ }), !0), xe = (e = !0) => ({ commands: t }) => t.setContent("", { emitUpdate: e }), Se = () => ({ state: e, tr: t, dispatch: n }) => {
168
169
  let { selection: r } = t, { ranges: i } = r;
169
170
  return n && i.forEach(({ $from: n, $to: r }) => {
170
171
  e.doc.nodesBetween(n.pos, r.pos, (e, n) => {
@@ -179,12 +180,12 @@ var ye = () => ({ editor: e, view: t }) => (requestAnimationFrame(() => {
179
180
  (l || l === 0) && t.lift(s, l);
180
181
  });
181
182
  }), !0;
182
- }, Se = (e) => (t) => e(t), Ce = () => ({ state: e, dispatch: t }) => l(e, t), we = (e, t) => ({ editor: n, tr: r }) => {
183
+ }, Ce = (e) => (t) => e(t), we = () => ({ state: e, dispatch: t }) => l(e, t), Te = (e, t) => ({ editor: n, tr: r }) => {
183
184
  let { state: i } = n, a = i.doc.slice(e.from, e.to);
184
185
  r.deleteRange(e.from, e.to);
185
186
  let o = r.mapping.map(t);
186
- return r.insert(o, a.content), r.setSelection(new D(r.doc.resolve(Math.max(o - 1, 0)))), !0;
187
- }, Te = () => ({ tr: e, dispatch: t }) => {
187
+ return r.insert(o, a.content), r.setSelection(new T(r.doc.resolve(Math.max(o - 1, 0)))), !0;
188
+ }, Ee = () => ({ tr: e, dispatch: t }) => {
188
189
  let { selection: n } = e, r = n.$anchor.node();
189
190
  if (r.content.size > 0) return !1;
190
191
  let i = e.selection.$anchor;
@@ -197,15 +198,15 @@ var ye = () => ({ editor: e, view: t }) => (requestAnimationFrame(() => {
197
198
  }
198
199
  return !1;
199
200
  };
200
- function j(e, t) {
201
+ function A(e, t) {
201
202
  if (typeof e == "string") {
202
203
  if (!t.nodes[e]) throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);
203
204
  return t.nodes[e];
204
205
  }
205
206
  return e;
206
207
  }
207
- var Ee = (e) => ({ tr: t, state: n, dispatch: r }) => {
208
- let i = j(e, n.schema), a = t.selection.$anchor;
208
+ var De = (e) => ({ tr: t, state: n, dispatch: r }) => {
209
+ let i = A(e, n.schema), a = t.selection.$anchor;
209
210
  for (let e = a.depth; e > 0; --e) if (a.node(e).type === i) {
210
211
  if (r) {
211
212
  let n = a.before(e), r = a.after(e);
@@ -214,41 +215,41 @@ var Ee = (e) => ({ tr: t, state: n, dispatch: r }) => {
214
215
  return !0;
215
216
  }
216
217
  return !1;
217
- }, De = (e) => ({ tr: t, dispatch: n }) => {
218
+ }, Oe = (e) => ({ tr: t, dispatch: n }) => {
218
219
  let { from: r, to: i } = e;
219
220
  return n && t.delete(r, i), !0;
220
- }, Oe = (e) => e.content ? /^text(\*|\+)/.test(e.content) : !1, ke = (e, t, n) => {
221
+ }, ke = (e) => e.content ? /^text(\*|\+)/.test(e.content) : !1, Ae = (e, t, n) => {
221
222
  if (!e.parent.isInline || n === "left" && e.pos > e.start() || n === "right" && e.pos < e.end()) return e.pos;
222
223
  let r = t.nodes[e.parent.type.name].spec;
223
- return Oe(r) ? n === "left" ? e.start() - 1 : e.end() + 1 : e.pos;
224
- }, Ae = (e, t, n) => ({
225
- from: ke(e, n, "left"),
226
- to: ke(t, n, "right")
227
- }), je = () => ({ state: e, dispatch: t }) => {
224
+ return ke(r) ? n === "left" ? e.start() - 1 : e.end() + 1 : e.pos;
225
+ }, je = (e, t, n) => ({
226
+ from: Ae(e, n, "left"),
227
+ to: Ae(t, n, "right")
228
+ }), Me = () => ({ state: e, dispatch: t }) => {
228
229
  if (e.selection.empty) return !1;
229
230
  if (t) {
230
231
  let n = e.tr, { ranges: r } = e.selection, i = n.steps.length;
231
232
  r.forEach((t) => {
232
- let r = n.mapping.slice(i), { from: a, to: o } = Ae(n.doc.resolve(r.map(t.$from.pos)), n.doc.resolve(r.map(t.$to.pos)), e.schema);
233
+ let r = n.mapping.slice(i), { from: a, to: o } = je(n.doc.resolve(r.map(t.$from.pos)), n.doc.resolve(r.map(t.$to.pos)), e.schema);
233
234
  n.deleteRange(a, o);
234
- }), n.selection.empty || n.setSelection(D.near(n.doc.resolve(n.selection.from))), n.scrollIntoView(), t(n);
235
+ }), n.selection.empty || n.setSelection(T.near(n.doc.resolve(n.selection.from))), n.scrollIntoView(), t(n);
235
236
  }
236
237
  return !0;
237
- }, Me = () => ({ commands: e }) => e.keyboardShortcut("Enter"), Ne = () => ({ state: e, dispatch: t }) => u(e, t);
238
- function Pe(e) {
238
+ }, Ne = () => ({ commands: e }) => e.keyboardShortcut("Enter"), Pe = () => ({ state: e, dispatch: t }) => u(e, t);
239
+ function Fe(e) {
239
240
  return Object.prototype.toString.call(e) === "[object RegExp]";
240
241
  }
241
- function M(e, t, n = { strict: !0 }) {
242
+ function j(e, t, n = { strict: !0 }) {
242
243
  let r = Object.keys(t);
243
- return !r.length || r.every((r) => n.strict ? t[r] === e[r] : Pe(t[r]) ? t[r].test(e[r]) : t[r] === e[r]);
244
- }
245
- function Fe(e, t, n = {}) {
246
- return e.find((e) => e.type === t && M(Object.fromEntries(Object.keys(n).map((t) => [t, e.attrs[t]])), n));
244
+ return !r.length || r.every((r) => n.strict ? t[r] === e[r] : Fe(t[r]) ? t[r].test(e[r]) : t[r] === e[r]);
247
245
  }
248
246
  function Ie(e, t, n = {}) {
249
- return !!Fe(e, t, n);
247
+ return e.find((e) => e.type === t && j(Object.fromEntries(Object.keys(n).map((t) => [t, e.attrs[t]])), n));
248
+ }
249
+ function Le(e, t, n = {}) {
250
+ return !!Ie(e, t, n);
250
251
  }
251
- function Le(e, t, n) {
252
+ function Re(e, t, n) {
252
253
  if (!e || !t) return;
253
254
  let r = e.parent.childAfter(e.parentOffset);
254
255
  if ((!r.node || !r.node.marks.some((e) => e.type === t)) && (r = e.parent.childBefore(e.parentOffset)), !r.node || !r.node.marks.some((e) => e.type === t)) return;
@@ -256,55 +257,55 @@ function Le(e, t, n) {
256
257
  let e = r.node.marks.find((e) => e.type === t);
257
258
  e && (n = e.attrs);
258
259
  }
259
- if (!Fe([...r.node.marks], t, n)) return;
260
+ if (!Ie([...r.node.marks], t, n)) return;
260
261
  let i = r.index, a = e.start() + r.offset, o = i + 1, s = a + r.node.nodeSize;
261
- for (; i > 0 && Ie([...e.parent.child(i - 1).marks], t, n);) --i, a -= e.parent.child(i).nodeSize;
262
- for (; o < e.parent.childCount && Ie([...e.parent.child(o).marks], t, n);) s += e.parent.child(o).nodeSize, o += 1;
262
+ for (; i > 0 && Le([...e.parent.child(i - 1).marks], t, n);) --i, a -= e.parent.child(i).nodeSize;
263
+ for (; o < e.parent.childCount && Le([...e.parent.child(o).marks], t, n);) s += e.parent.child(o).nodeSize, o += 1;
263
264
  return {
264
265
  from: a,
265
266
  to: s
266
267
  };
267
268
  }
268
- function N(e, t) {
269
+ function M(e, t) {
269
270
  if (typeof e == "string") {
270
271
  if (!t.marks[e]) throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);
271
272
  return t.marks[e];
272
273
  }
273
274
  return e;
274
275
  }
275
- var Re = (e, t) => ({ tr: n, state: r, dispatch: i }) => {
276
- let a = N(e, r.schema), { doc: o, selection: s } = n, { $from: c, from: l, to: u } = s;
276
+ var ze = (e, t) => ({ tr: n, state: r, dispatch: i }) => {
277
+ let a = M(e, r.schema), { doc: o, selection: s } = n, { $from: c, from: l, to: u } = s;
277
278
  if (i) {
278
- let e = Le(c, a, t);
279
+ let e = Re(c, a, t);
279
280
  if (e && e.from <= l && e.to >= u) {
280
- let t = D.create(o, e.from, e.to);
281
+ let t = T.create(o, e.from, e.to);
281
282
  n.setSelection(t);
282
283
  }
283
284
  }
284
285
  return !0;
285
- }, ze = (e) => (t) => {
286
+ }, Be = (e) => (t) => {
286
287
  let n = typeof e == "function" ? e(t) : e;
287
288
  for (let e = 0; e < n.length; e += 1) if (n[e](t)) return !0;
288
289
  return !1;
289
290
  };
290
- function Be(e) {
291
- return e instanceof D;
291
+ function Ve(e) {
292
+ return e instanceof T;
292
293
  }
293
- function P(e = 0, t = 0, n = 0) {
294
+ function N(e = 0, t = 0, n = 0) {
294
295
  return Math.min(Math.max(e, t), n);
295
296
  }
296
- function Ve(e, t = null) {
297
+ function He(e, t = null) {
297
298
  if (!t) return null;
298
- let n = E.atStart(e), r = E.atEnd(e);
299
+ let n = w.atStart(e), r = w.atEnd(e);
299
300
  if (t === "start" || t === !0) return n;
300
301
  if (t === "end") return r;
301
302
  let i = n.from, a = r.to;
302
- return t === "all" ? D.create(e, P(0, i, a), P(e.content.size, i, a)) : D.create(e, P(t, i, a), P(t, i, a));
303
+ return t === "all" ? T.create(e, N(0, i, a), N(e.content.size, i, a)) : T.create(e, N(t, i, a), N(t, i, a));
303
304
  }
304
- function He() {
305
+ function Ue() {
305
306
  return ["Android"].includes(navigator.platform) || /android/i.test(navigator.userAgent);
306
307
  }
307
- function F() {
308
+ function P() {
308
309
  return [
309
310
  "iPad Simulator",
310
311
  "iPhone Simulator",
@@ -314,16 +315,16 @@ function F() {
314
315
  "iPod"
315
316
  ].includes(navigator.platform) || navigator.userAgent.includes("Mac") && "ontouchend" in document;
316
317
  }
317
- function Ue() {
318
+ function We() {
318
319
  return typeof navigator < "u" && /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
319
320
  }
320
- var We = (e = null, t = {}) => ({ editor: n, view: r, tr: i, dispatch: a }) => {
321
+ var Ge = (e = null, t = {}) => ({ editor: n, view: r, tr: i, dispatch: a }) => {
321
322
  t = {
322
323
  scrollIntoView: !0,
323
324
  ...t
324
325
  };
325
326
  let o = () => {
326
- (F() || He()) && r.dom.focus(), Ue() && !F() && !He() && r.dom.focus({ preventScroll: !0 }), requestAnimationFrame(() => {
327
+ (P() || Ue()) && r.dom.focus(), We() && !P() && !Ue() && r.dom.focus({ preventScroll: !0 }), requestAnimationFrame(() => {
327
328
  n.isDestroyed || (r.focus(), t?.scrollIntoView && n.commands.scrollIntoView());
328
329
  });
329
330
  };
@@ -332,47 +333,51 @@ var We = (e = null, t = {}) => ({ editor: n, view: r, tr: i, dispatch: a }) => {
332
333
  } catch {
333
334
  return !1;
334
335
  }
335
- if (a && e === null && !Be(n.state.selection)) return o(), !0;
336
- let s = Ve(i.doc, e) || n.state.selection, c = n.state.selection.eq(s);
336
+ if (a && e === null && !Ve(n.state.selection)) return o(), !0;
337
+ let s = He(i.doc, e) || n.state.selection, c = n.state.selection.eq(s);
337
338
  return a && (c || i.setSelection(s), c && i.storedMarks && i.setStoredMarks(i.storedMarks), o()), !0;
338
- }, Ge = (e, t) => (n) => e.every((e, r) => t(e, {
339
+ }, Ke = (e, t) => (n) => e.every((e, r) => t(e, {
339
340
  ...n,
340
341
  index: r
341
- })), Ke = (e, t) => ({ tr: n, commands: r }) => r.insertContentAt({
342
+ })), qe = (e, t) => ({ tr: n, commands: r }) => r.insertContentAt({
342
343
  from: n.selection.from,
343
344
  to: n.selection.to
344
- }, e, t), qe = (e) => {
345
+ }, e, t), Je = (e) => {
345
346
  let t = e.childNodes;
346
347
  for (let n = t.length - 1; n >= 0; --n) {
347
348
  let r = t[n];
348
- r.nodeType === 3 && r.nodeValue && /^(\n\s\s|\n)$/.test(r.nodeValue) ? e.removeChild(r) : r.nodeType === 1 && qe(r);
349
+ r.nodeType === 3 && r.nodeValue && /^(\n\s\s|\n)$/.test(r.nodeValue) ? e.removeChild(r) : r.nodeType === 1 && Je(r);
349
350
  }
350
351
  return e;
351
352
  };
352
- function I(e) {
353
+ function F(e) {
353
354
  if (typeof window > "u") throw Error("[tiptap error]: there is no window object available, so this function cannot be used");
354
355
  let t = `<body>${e}</body>`, n = new window.DOMParser().parseFromString(t, "text/html").body;
355
- return qe(n);
356
+ return Je(n);
357
+ }
358
+ function Ye(e) {
359
+ return typeof e?.nodesBetween == "function";
356
360
  }
357
- function L(e, t, n) {
358
- if (e instanceof ce || e instanceof O) return e;
361
+ function I(e, t, n) {
362
+ if (Ye(e)) return e;
363
+ let r = typeof e == "object" && !!e;
359
364
  n = {
360
365
  slice: !0,
361
366
  parseOptions: {},
362
367
  ...n
363
368
  };
364
- let r = typeof e == "object" && !!e, i = typeof e == "string";
369
+ let i = typeof e == "string";
365
370
  if (r) try {
366
- if (Array.isArray(e) && e.length > 0) return O.fromArray(e.map((e) => t.nodeFromJSON(e)));
371
+ if (Array.isArray(e) && e.length > 0) return E.fromArray(e.map((e) => t.nodeFromJSON(e)));
367
372
  let r = t.nodeFromJSON(e);
368
373
  return n.errorOnInvalidContent && r.check(), r;
369
374
  } catch (r) {
370
375
  if (n.errorOnInvalidContent) throw Error("[tiptap error]: Invalid JSON content", { cause: r });
371
- return console.warn("[tiptap warn]: Invalid content.", "Passed value:", e, "Error:", r), L("", t, n);
376
+ return console.warn("[tiptap warn]: Invalid content.", "Passed value:", e, "Error:", r), I("", t, n);
372
377
  }
373
378
  if (i) {
374
379
  if (n.errorOnInvalidContent) {
375
- let r = !1, i = "", a = new le({
380
+ let r = !1, i = "", a = new ue({
376
381
  topNode: t.spec.topNode,
377
382
  marks: t.spec.marks,
378
383
  nodes: t.spec.nodes.append({ __tiptap__private__unknown__catch__all__node: {
@@ -384,14 +389,17 @@ function L(e, t, n) {
384
389
  }]
385
390
  } })
386
391
  });
387
- if (n.slice ? oe.fromSchema(a).parseSlice(I(e), n.parseOptions) : oe.fromSchema(a).parse(I(e), n.parseOptions), n.errorOnInvalidContent && r) throw Error("[tiptap error]: Invalid HTML content", { cause: /* @__PURE__ */ Error(`Invalid element found: ${i}`) });
392
+ if (n.slice ? ce.fromSchema(a).parseSlice(F(e), n.parseOptions) : ce.fromSchema(a).parse(F(e), n.parseOptions), n.errorOnInvalidContent && r) throw Error("[tiptap error]: Invalid HTML content", { cause: /* @__PURE__ */ Error(`Invalid element found: ${i}`) });
388
393
  }
389
- let r = oe.fromSchema(t);
390
- return n.slice ? r.parseSlice(I(e), n.parseOptions).content : r.parse(I(e), n.parseOptions);
394
+ let r = ce.fromSchema(t);
395
+ return n.slice ? r.parseSlice(F(e), n.parseOptions).content : r.parse(F(e), n.parseOptions);
391
396
  }
392
- return L("", t, n);
397
+ return I("", t, n);
393
398
  }
394
- function Je(e, r, i) {
399
+ function Xe(e) {
400
+ return !("type" in e);
401
+ }
402
+ function Ze(e, r, i) {
395
403
  let a = e.steps.length - 1;
396
404
  if (a < r) return;
397
405
  let o = e.steps[a];
@@ -399,9 +407,9 @@ function Je(e, r, i) {
399
407
  let s = e.mapping.maps[a], c = 0;
400
408
  s.forEach((e, t, n, r) => {
401
409
  c === 0 && (c = r);
402
- }), e.setSelection(E.near(e.doc.resolve(c), i));
410
+ }), e.setSelection(w.near(e.doc.resolve(c), i));
403
411
  }
404
- var Ye = (e) => !("type" in e), Xe = (e, t, n) => ({ tr: r, dispatch: i, editor: a }) => {
412
+ var Qe = (e, t, n) => ({ tr: r, dispatch: i, editor: a }) => {
405
413
  if (i) {
406
414
  n = {
407
415
  parseOptions: a.options.parseOptions,
@@ -423,7 +431,7 @@ var Ye = (e) => !("type" in e), Xe = (e, t, n) => ({ tr: r, dispatch: i, editor:
423
431
  ...n.parseOptions
424
432
  };
425
433
  if (!n.errorOnInvalidContent && !a.options.enableContentCheck && a.options.emitContentError) try {
426
- L(t, a.schema, {
434
+ I(t, a.schema, {
427
435
  parseOptions: s,
428
436
  errorOnInvalidContent: !0
429
437
  });
@@ -431,7 +439,7 @@ var Ye = (e) => !("type" in e), Xe = (e, t, n) => ({ tr: r, dispatch: i, editor:
431
439
  o(e);
432
440
  }
433
441
  try {
434
- i = L(t, a.schema, {
442
+ i = I(t, a.schema, {
435
443
  parseOptions: s,
436
444
  errorOnInvalidContent: n.errorOnInvalidContent ?? a.options.enableContentCheck
437
445
  });
@@ -444,75 +452,67 @@ var Ye = (e) => !("type" in e), Xe = (e, t, n) => ({ tr: r, dispatch: i, editor:
444
452
  } : {
445
453
  from: e.from,
446
454
  to: e.to
447
- }, u = !0, d = !0;
448
- if ((Ye(i) ? i : [i]).forEach((e) => {
455
+ }, u = !0, d = !0, f = Xe(i) ? i.content : [i];
456
+ if (f.forEach((e) => {
449
457
  e.check(), u = u ? e.isText && e.marks.length === 0 : !1, d = d ? e.isBlock : !1;
450
458
  }), c === l && d) {
451
459
  let { parent: e } = r.doc.resolve(c);
452
460
  e.isTextblock && !e.type.spec.code && !e.childCount && (--c, l += 1);
453
461
  }
454
- let f;
455
- if (u) {
456
- if (Array.isArray(t)) f = t.map((e) => e.text || "").join("");
457
- else if (t instanceof O) {
458
- let e = "";
459
- t.forEach((t) => {
460
- t.text && (e += t.text);
461
- }), f = e;
462
- } else f = typeof t == "object" && t && t.text ? t.text : t;
463
- r.insertText(f, c, l);
464
- } else {
465
- f = i;
466
- let e = r.doc.resolve(c), t = e.node(), n = e.parentOffset === 0, a = t.isText || t.isTextblock, o = t.content.size > 0;
467
- n && a && o && d && (c = Math.max(0, c - 1)), r.replaceWith(c, l, f);
462
+ let p;
463
+ if (u) p = Array.isArray(t) ? t.map((e) => e.text || "").join("") : Ye(t) ? f.map((e) => e.text ?? "").join("") : typeof t == "object" && t && t.text ? t.text : t, r.insertText(p, c, l);
464
+ else {
465
+ p = E.from(f);
466
+ let e = r.doc.resolve(c), t = e.node(), n = e.parentOffset === 0, i = t.isText || t.isTextblock, a = t.content.size > 0;
467
+ n && i && a && d && (c = Math.max(0, c - 1)), r.replaceWith(c, l, f);
468
468
  }
469
- n.updateSelection && Je(r, r.steps.length - 1, -1), n.applyInputRules && r.setMeta("applyInputRules", {
469
+ n.updateSelection && Ze(r, r.steps.length - 1, -1), n.applyInputRules && r.setMeta("applyInputRules", {
470
470
  from: c,
471
- text: f
471
+ text: p
472
472
  }), n.applyPasteRules && r.setMeta("applyPasteRules", {
473
473
  from: c,
474
- text: f
474
+ text: p
475
475
  });
476
476
  }
477
477
  return !0;
478
478
  };
479
- function Ze(e) {
479
+ function $e(e) {
480
480
  for (let t = 0; t < e.edgeCount; t += 1) {
481
481
  let { type: n } = e.edge(t);
482
482
  if (n.isTextblock && !n.hasRequiredAttrs()) return n;
483
483
  }
484
484
  return null;
485
485
  }
486
- var Qe = (e = {}) => ({ tr: t, dispatch: n, editor: r }) => {
486
+ var et = (e = {}) => ({ tr: t, dispatch: n, editor: r }) => {
487
487
  let { pos: i, attrs: a, content: o, updateSelection: s = !0 } = e, c;
488
488
  c = typeof i == "number" ? t.doc.resolve(i) : i || t.selection.$from;
489
- let l = Ze(c.parent.contentMatchAt(c.index()));
489
+ let l = $e(c.parent.contentMatchAt(c.index()));
490
490
  if (!l) return !1;
491
491
  let u = Object.keys(l.spec.attrs || {}), d = a ? Object.fromEntries(Object.entries(a).filter(([e]) => u.includes(e))) : {}, f;
492
492
  if (o) {
493
- let e = L(o, r.schema);
493
+ let e = I(o, r.schema);
494
494
  f = l.createAndFill(d, e);
495
495
  } else f = l.createAndFill(d);
496
- return f ? (n && (t.insert(c.pos, f), s && Je(t, t.steps.length - 1, -1)), !0) : !1;
497
- }, $e = () => ({ state: e, dispatch: t }) => g(e, t), et = () => ({ state: e, dispatch: t }) => f(e, t), tt = () => ({ state: e, dispatch: t }) => d(e, t), nt = () => ({ state: e, dispatch: t }) => p(e, t), rt = () => ({ state: e, dispatch: t, tr: n }) => {
496
+ return f ? (n && (t.insert(c.pos, f), s && Ze(t, t.steps.length - 1, -1)), !0) : !1;
497
+ }, tt = () => ({ state: e, dispatch: t }) => g(e, t), nt = () => ({ state: e, dispatch: t }) => f(e, t), rt = () => ({ state: e, dispatch: t }) => d(e, t), it = () => ({ state: e, dispatch: t }) => p(e, t), at = () => ({ state: e, dispatch: t, tr: n }) => {
498
498
  try {
499
499
  let r = s(e.doc, e.selection.$from.pos, -1);
500
500
  return r != null && (n.join(r, 2), t && t(n), !0);
501
501
  } catch {
502
502
  return !1;
503
503
  }
504
- }, it = () => ({ state: e, dispatch: t, tr: n }) => {
504
+ }, ot = () => ({ state: e, dispatch: t, tr: n }) => {
505
505
  try {
506
506
  let r = s(e.doc, e.selection.$from.pos, 1);
507
507
  return r != null && (n.join(r, 2), t && t(n), !0);
508
508
  } catch {
509
509
  return !1;
510
510
  }
511
- }, at = () => ({ state: e, dispatch: t }) => m(e, t), ot = () => ({ state: e, dispatch: t }) => h(e, t);
512
- function st() {
511
+ }, st = () => ({ state: e, dispatch: t }) => m(e, t), ct = () => ({ state: e, dispatch: t }) => h(e, t);
512
+ function lt() {
513
513
  return typeof navigator < "u" && /Mac/.test(navigator.platform);
514
514
  }
515
- function ct(e) {
515
+ function ut(e) {
516
516
  let t = e.split(/-(?!$)/), n = t[t.length - 1];
517
517
  n === "Space" && (n = " ");
518
518
  let r, i, a, o;
@@ -522,13 +522,13 @@ function ct(e) {
522
522
  else if (/^a(lt)?$/i.test(n)) r = !0;
523
523
  else if (/^(c|ctrl|control)$/i.test(n)) i = !0;
524
524
  else if (/^s(hift)?$/i.test(n)) a = !0;
525
- else if (/^mod$/i.test(n)) F() || st() ? o = !0 : i = !0;
525
+ else if (/^mod$/i.test(n)) P() || lt() ? o = !0 : i = !0;
526
526
  else throw Error(`Unrecognized modifier name: ${n}`);
527
527
  }
528
528
  return r && (n = `Alt-${n}`), i && (n = `Ctrl-${n}`), o && (n = `Meta-${n}`), a && (n = `Shift-${n}`), n;
529
529
  }
530
- var lt = (e) => ({ editor: t, view: n, tr: r, dispatch: i }) => {
531
- let a = ct(e).split(/-(?!$)/), o = a.find((e) => ![
530
+ var dt = (e) => ({ editor: t, view: n, tr: r, dispatch: i }) => {
531
+ let a = ut(e).split(/-(?!$)/), o = a.find((e) => ![
532
532
  "Alt",
533
533
  "Ctrl",
534
534
  "Meta",
@@ -549,8 +549,8 @@ var lt = (e) => ({ editor: t, view: n, tr: r, dispatch: i }) => {
549
549
  t && i && r.maybeStep(t);
550
550
  }), !0;
551
551
  };
552
- function R(e, t, n = {}) {
553
- let { from: r, to: i, empty: a } = e.selection, o = t ? j(t, e.schema) : null, s = [];
552
+ function L(e, t, n = {}) {
553
+ let { from: r, to: i, empty: a } = e.selection, o = t ? A(t, e.schema) : null, s = [];
554
554
  e.doc.nodesBetween(r, i, (e, t) => {
555
555
  if (e.isText) return;
556
556
  let n = Math.max(r, t), a = Math.min(i, t + e.nodeSize);
@@ -560,51 +560,55 @@ function R(e, t, n = {}) {
560
560
  to: a
561
561
  });
562
562
  });
563
- let c = i - r, l = s.filter((e) => !o || o.name === e.node.type.name).filter((e) => M(e.node.attrs, n, { strict: !1 }));
563
+ let c = i - r, l = s.filter((e) => !o || o.name === e.node.type.name).filter((e) => j(e.node.attrs, n, { strict: !1 }));
564
564
  return a ? !!l.length : l.reduce((e, t) => e + t.to - t.from, 0) >= c;
565
565
  }
566
- var ut = (e, t = {}) => ({ state: n, dispatch: r }) => R(n, j(e, n.schema), t) ? ee(n, r) : !1, dt = () => ({ state: e, dispatch: t }) => te(e, t), ft = (e) => ({ state: t, dispatch: n }) => {
567
- let r = j(e, t.schema);
568
- return de(r)(t, n);
569
- }, pt = () => ({ state: e, dispatch: t }) => _(e, t);
570
- function z(e, t) {
566
+ var ft = (e, t = {}) => ({ state: n, dispatch: r }) => L(n, A(e, n.schema), t) ? ee(n, r) : !1, pt = () => ({ state: e, dispatch: t }) => te(e, t), mt = (e) => ({ state: t, dispatch: n }) => {
567
+ let r = A(e, t.schema);
568
+ return fe(r)(t, n);
569
+ }, ht = () => ({ state: e, dispatch: t }) => _(e, t);
570
+ function R(e, t) {
571
571
  return t.nodes[e] ? "node" : t.marks[e] ? "mark" : null;
572
572
  }
573
- function mt(e, t) {
573
+ function gt(e, t) {
574
574
  let n = typeof t == "string" ? [t] : t;
575
575
  return Object.keys(e).reduce((t, r) => (n.includes(r) || (t[r] = e[r]), t), {});
576
576
  }
577
- var ht = (e, t) => ({ tr: n, state: r, dispatch: i }) => {
578
- let a = null, o = null, s = z(typeof e == "string" ? e : e.name, r.schema);
577
+ var _t = (e, t) => ({ tr: n, state: r, dispatch: i }) => {
578
+ let a = null, o = null, s = R(typeof e == "string" ? e : e.name, r.schema);
579
579
  if (!s) return !1;
580
- s === "node" && (a = j(e, r.schema)), s === "mark" && (o = N(e, r.schema));
580
+ s === "node" && (a = A(e, r.schema)), s === "mark" && (o = M(e, r.schema));
581
581
  let c = !1;
582
582
  return n.selection.ranges.forEach((e) => {
583
583
  r.doc.nodesBetween(e.$from.pos, e.$to.pos, (e, r) => {
584
- a && a === e.type && (c = !0, i && n.setNodeMarkup(r, void 0, mt(e.attrs, t))), o && e.marks.length && e.marks.forEach((a) => {
585
- o === a.type && (c = !0, i && n.addMark(r, r + e.nodeSize, o.create(mt(a.attrs, t))));
584
+ a && a === e.type && (c = !0, i && n.setNodeMarkup(r, void 0, gt(e.attrs, t))), o && e.marks.length && e.marks.forEach((a) => {
585
+ o === a.type && (c = !0, i && n.addMark(r, r + e.nodeSize, o.create(gt(a.attrs, t))));
586
586
  });
587
587
  });
588
588
  }), c;
589
- }, gt = () => ({ tr: e, dispatch: t }) => (t && e.scrollIntoView(), !0), _t = () => ({ tr: e, dispatch: t }) => {
589
+ }, vt = () => ({ tr: e, dispatch: t }) => (t && e.scrollIntoView(), !0), yt = () => ({ tr: e, dispatch: t }) => {
590
590
  if (t) {
591
591
  let t = new ae(e.doc);
592
592
  e.setSelection(t);
593
593
  }
594
594
  return !0;
595
- }, vt = () => ({ state: e, dispatch: t }) => ne(e, t), yt = () => ({ state: e, dispatch: t }) => v(e, t), bt = () => ({ state: e, dispatch: t }) => re(e, t), xt = () => ({ state: e, dispatch: t }) => ie(e, t), St = () => ({ state: e, dispatch: t }) => y(e, t);
596
- function Ct(e, t, n = {}, r = {}) {
597
- return L(e, t, {
595
+ }, bt = () => ({ state: e, dispatch: t }) => ne(e, t), xt = () => ({ state: e, dispatch: t }) => v(e, t), St = () => ({ state: e, dispatch: t }) => re(e, t), Ct = () => ({ state: e, dispatch: t }) => ie(e, t), wt = () => ({ state: e, dispatch: t }) => y(e, t);
596
+ function Tt(e, t, n = {}, r = {}) {
597
+ return I(e, t, {
598
598
  slice: !1,
599
599
  parseOptions: n,
600
600
  errorOnInvalidContent: r.errorOnInvalidContent
601
601
  });
602
602
  }
603
- var wt = (e, { errorOnInvalidContent: t, emitUpdate: n = !0, parseOptions: r = {} } = {}) => ({ editor: i, tr: a, dispatch: o, commands: s }) => {
603
+ var Et = (e, { errorOnInvalidContent: t, emitUpdate: n = !0, parseOptions: r = {} } = {}) => ({ editor: i, tr: a, dispatch: o, commands: s }) => {
604
604
  let { doc: c } = a;
605
605
  if (r.preserveWhitespace !== "full") {
606
- let s = Ct(e, i.schema, r, { errorOnInvalidContent: t ?? i.options.enableContentCheck });
607
- return o && a.replaceWith(0, c.content.size, s).setMeta("preventUpdate", !n), !0;
606
+ let s = Tt(e, i.schema, r, { errorOnInvalidContent: t ?? i.options.enableContentCheck });
607
+ if (o) {
608
+ let e = Xe(s) ? s.content : [s];
609
+ a.replaceWith(0, c.content.size, e).setMeta("preventUpdate", !n);
610
+ }
611
+ return !0;
608
612
  }
609
613
  return o && a.setMeta("preventUpdate", !n), s.insertContentAt({
610
614
  from: 0,
@@ -614,15 +618,15 @@ var wt = (e, { errorOnInvalidContent: t, emitUpdate: n = !0, parseOptions: r = {
614
618
  errorOnInvalidContent: t ?? i.options.enableContentCheck
615
619
  });
616
620
  };
617
- function Tt(e, t) {
618
- let n = N(t, e.schema), { from: r, to: i, empty: a } = e.selection, o = [];
621
+ function Dt(e, t) {
622
+ let n = M(t, e.schema), { from: r, to: i, empty: a } = e.selection, o = [];
619
623
  a ? (e.storedMarks && o.push(...e.storedMarks), o.push(...e.selection.$head.marks())) : e.doc.nodesBetween(r, i, (e) => {
620
624
  o.push(...e.marks);
621
625
  });
622
626
  let s = o.find((e) => e.type.name === n.name);
623
627
  return s ? { ...s.attrs } : {};
624
628
  }
625
- function Et(e, t) {
629
+ function Ot(e, t) {
626
630
  let n = new r(e);
627
631
  return t.forEach((e) => {
628
632
  e.steps.forEach((e) => {
@@ -630,7 +634,7 @@ function Et(e, t) {
630
634
  });
631
635
  }), n;
632
636
  }
633
- function Dt(e, t, n) {
637
+ function kt(e, t, n) {
634
638
  let r = [];
635
639
  return e.nodesBetween(t.from, t.to, (e, t) => {
636
640
  n(e) && r.push({
@@ -639,7 +643,7 @@ function Dt(e, t, n) {
639
643
  });
640
644
  }), r;
641
645
  }
642
- function Ot(e, t) {
646
+ function At(e, t) {
643
647
  for (let n = e.depth; n > 0; --n) {
644
648
  let r = e.node(n);
645
649
  if (t(r)) return {
@@ -650,47 +654,47 @@ function Ot(e, t) {
650
654
  };
651
655
  }
652
656
  }
653
- function B(e) {
654
- return (t) => Ot(t.$from, e);
657
+ function z(e) {
658
+ return (t) => At(t.$from, e);
655
659
  }
656
- function V(e, t, n) {
657
- return e.config[t] === void 0 && e.parent ? V(e.parent, t, n) : typeof e.config[t] == "function" ? e.config[t].bind({
660
+ function B(e, t, n) {
661
+ return e.config[t] === void 0 && e.parent ? B(e.parent, t, n) : typeof e.config[t] == "function" ? e.config[t].bind({
658
662
  ...n,
659
- parent: e.parent ? V(e.parent, t, n) : null
663
+ parent: e.parent ? B(e.parent, t, n) : null
660
664
  }) : e.config[t];
661
665
  }
662
- function kt(e) {
666
+ function jt(e) {
663
667
  return e.map((e) => {
664
- let t = V(e, "addExtensions", {
668
+ let t = B(e, "addExtensions", {
665
669
  name: e.name,
666
670
  options: e.options,
667
671
  storage: e.storage
668
672
  });
669
- return t ? [e, ...kt(t())] : e;
673
+ return t ? [e, ...jt(t())] : e;
670
674
  }).flat(10);
671
675
  }
672
- function At(e, t) {
673
- let n = se.fromSchema(t).serializeFragment(e), r = document.implementation.createHTMLDocument().createElement("div");
676
+ function Mt(e, t) {
677
+ let n = le.fromSchema(t).serializeFragment(e), r = document.implementation.createHTMLDocument().createElement("div");
674
678
  return r.appendChild(n), r.innerHTML;
675
679
  }
676
- function jt(e) {
680
+ function Nt(e) {
677
681
  return typeof e == "function";
678
682
  }
679
- function H(e, t = void 0, ...n) {
680
- return jt(e) ? t ? e.bind(t)(...n) : e(...n) : e;
683
+ function V(e, t = void 0, ...n) {
684
+ return Nt(e) ? t ? e.bind(t)(...n) : e(...n) : e;
681
685
  }
682
- function Mt(e = {}) {
686
+ function Pt(e = {}) {
683
687
  return Object.keys(e).length === 0 && e.constructor === Object;
684
688
  }
685
- function U(e) {
689
+ function H(e) {
686
690
  return {
687
691
  baseExtensions: e.filter((e) => e.type === "extension"),
688
692
  nodeExtensions: e.filter((e) => e.type === "node"),
689
693
  markExtensions: e.filter((e) => e.type === "mark")
690
694
  };
691
695
  }
692
- function Nt(e) {
693
- let t = [], { nodeExtensions: n, markExtensions: r } = U(e), i = [...n, ...r], a = {
696
+ function Ft(e) {
697
+ let t = [], { nodeExtensions: n, markExtensions: r } = H(e), i = [...n, ...r], a = {
694
698
  default: null,
695
699
  validate: void 0,
696
700
  rendered: !0,
@@ -700,7 +704,7 @@ function Nt(e) {
700
704
  isRequired: !1
701
705
  }, o = n.filter((e) => e.name !== "text").map((e) => e.name), s = r.map((e) => e.name), c = [...o, ...s];
702
706
  return e.forEach((e) => {
703
- let n = V(e, "addGlobalAttributes", {
707
+ let n = B(e, "addGlobalAttributes", {
704
708
  name: e.name,
705
709
  options: e.options,
706
710
  storage: e.storage,
@@ -722,7 +726,7 @@ function Nt(e) {
722
726
  });
723
727
  });
724
728
  }), i.forEach((e) => {
725
- let n = V(e, "addAttributes", {
729
+ let n = B(e, "addAttributes", {
726
730
  name: e.name,
727
731
  options: e.options,
728
732
  storage: e.storage
@@ -742,7 +746,7 @@ function Nt(e) {
742
746
  });
743
747
  }), t;
744
748
  }
745
- function Pt(e) {
749
+ function It(e) {
746
750
  let t = [], n = "", r = !1, i = !1, a = 0, o = e.length;
747
751
  for (let s = 0; s < o; s += 1) {
748
752
  let o = e[s];
@@ -772,8 +776,8 @@ function Pt(e) {
772
776
  }
773
777
  return n && t.push(n), t;
774
778
  }
775
- function Ft(e) {
776
- let t = [], n = Pt(e || ""), r = n.length;
779
+ function Lt(e) {
780
+ let t = [], n = It(e || ""), r = n.length;
777
781
  for (let e = 0; e < r; e += 1) {
778
782
  let r = n[e], i = r.indexOf(":");
779
783
  if (i === -1) continue;
@@ -782,7 +786,7 @@ function Ft(e) {
782
786
  }
783
787
  return t;
784
788
  }
785
- function It(...e) {
789
+ function Rt(...e) {
786
790
  return e.filter((e) => !!e).reduce((e, t) => {
787
791
  let n = { ...e };
788
792
  return Object.entries(t).forEach(([e, t]) => {
@@ -794,26 +798,26 @@ function It(...e) {
794
798
  let r = t ? String(t).split(" ") : [], i = n[e] ? n[e].split(" ") : [], a = r.filter((e) => !i.includes(e));
795
799
  n[e] = [...i, ...a].join(" ");
796
800
  } else if (e === "style") {
797
- let r = new Map([...Ft(n[e]), ...Ft(t)]);
801
+ let r = new Map([...Lt(n[e]), ...Lt(t)]);
798
802
  n[e] = Array.from(r.entries()).map(([e, t]) => `${e}: ${t}`).join("; ");
799
803
  } else n[e] = t;
800
804
  }), n;
801
805
  }, {});
802
806
  }
803
- function W(e, t) {
804
- return t.filter((t) => t.type === e.type.name).filter((e) => e.attribute.rendered).map((t) => t.attribute.renderHTML ? t.attribute.renderHTML(e.attrs) || {} : { [t.name]: e.attrs[t.name] }).reduce((e, t) => It(e, t), {});
807
+ function U(e, t) {
808
+ return t.filter((t) => t.type === e.type.name).filter((e) => e.attribute.rendered).map((t) => t.attribute.renderHTML ? t.attribute.renderHTML(e.attrs) || {} : { [t.name]: e.attrs[t.name] }).reduce((e, t) => Rt(e, t), {});
805
809
  }
806
- function Lt(e) {
810
+ function zt(e) {
807
811
  return typeof e == "string" ? e.match(/^[+-]?(?:\d*\.)?\d+$/) ? Number(e) : e === "true" || e !== "false" && e : e;
808
812
  }
809
- function Rt(e, t) {
813
+ function Bt(e, t) {
810
814
  return "style" in e ? e : {
811
815
  ...e,
812
816
  getAttrs: (n) => {
813
817
  let r = e.getAttrs ? e.getAttrs(n) : e.attrs;
814
818
  if (r === !1) return !1;
815
819
  let i = t.reduce((e, t) => {
816
- let r = t.attribute.parseHTML ? t.attribute.parseHTML(n) : Lt(n.getAttribute(t.name));
820
+ let r = t.attribute.parseHTML ? t.attribute.parseHTML(n) : zt(n.getAttribute(t.name));
817
821
  return r == null ? e : {
818
822
  ...e,
819
823
  [t.name]: r
@@ -826,49 +830,49 @@ function Rt(e, t) {
826
830
  }
827
831
  };
828
832
  }
829
- function zt(e) {
830
- return Object.fromEntries(Object.entries(e).filter(([e, t]) => e === "attrs" && Mt(t) ? !1 : t != null));
833
+ function Vt(e) {
834
+ return Object.fromEntries(Object.entries(e).filter(([e, t]) => e === "attrs" && Pt(t) ? !1 : t != null));
831
835
  }
832
- function Bt(e) {
836
+ function Ht(e) {
833
837
  let t = {};
834
838
  return !e?.attribute?.isRequired && "default" in (e?.attribute || {}) && (t.default = e.attribute.default), e?.attribute?.validate !== void 0 && (t.validate = e.attribute.validate), [e.name, t];
835
839
  }
836
- function Vt(e, t) {
837
- let n = Nt(e), { nodeExtensions: r, markExtensions: i } = U(e), a = r.find((e) => V(e, "topNode"))?.name, o = Object.fromEntries(r.map((r) => {
840
+ function Ut(e, t) {
841
+ let n = Ft(e), { nodeExtensions: r, markExtensions: i } = H(e), a = r.find((e) => B(e, "topNode"))?.name, o = Object.fromEntries(r.map((r) => {
838
842
  let i = n.filter((e) => e.type === r.name), a = {
839
843
  name: r.name,
840
844
  options: r.options,
841
845
  storage: r.storage,
842
846
  editor: t
843
- }, o = zt({
847
+ }, o = Vt({
844
848
  ...e.reduce((e, t) => {
845
- let n = V(t, "extendNodeSchema", a);
849
+ let n = B(t, "extendNodeSchema", a);
846
850
  return {
847
851
  ...e,
848
852
  ...n ? n(r) : {}
849
853
  };
850
854
  }, {}),
851
- content: H(V(r, "content", a)),
852
- marks: H(V(r, "marks", a)),
853
- group: H(V(r, "group", a)),
854
- inline: H(V(r, "inline", a)),
855
- atom: H(V(r, "atom", a)),
856
- selectable: H(V(r, "selectable", a)),
857
- draggable: H(V(r, "draggable", a)),
858
- code: H(V(r, "code", a)),
859
- whitespace: H(V(r, "whitespace", a)),
860
- linebreakReplacement: H(V(r, "linebreakReplacement", a)),
861
- defining: H(V(r, "defining", a)),
862
- isolating: H(V(r, "isolating", a)),
863
- attrs: Object.fromEntries(i.map(Bt))
864
- }), s = H(V(r, "parseHTML", a));
865
- s && (o.parseDOM = s.map((e) => Rt(e, i)));
866
- let c = V(r, "renderHTML", a);
855
+ content: V(B(r, "content", a)),
856
+ marks: V(B(r, "marks", a)),
857
+ group: V(B(r, "group", a)),
858
+ inline: V(B(r, "inline", a)),
859
+ atom: V(B(r, "atom", a)),
860
+ selectable: V(B(r, "selectable", a)),
861
+ draggable: V(B(r, "draggable", a)),
862
+ code: V(B(r, "code", a)),
863
+ whitespace: V(B(r, "whitespace", a)),
864
+ linebreakReplacement: V(B(r, "linebreakReplacement", a)),
865
+ defining: V(B(r, "defining", a)),
866
+ isolating: V(B(r, "isolating", a)),
867
+ attrs: Object.fromEntries(i.map(Ht))
868
+ }), s = V(B(r, "parseHTML", a));
869
+ s && (o.parseDOM = s.map((e) => Bt(e, i)));
870
+ let c = B(r, "renderHTML", a);
867
871
  c && (o.toDOM = (e) => c({
868
872
  node: e,
869
- HTMLAttributes: W(e, i)
873
+ HTMLAttributes: U(e, i)
870
874
  }));
871
- let l = V(r, "renderText", a);
875
+ let l = B(r, "renderText", a);
872
876
  return l && (o.toText = l), [r.name, o];
873
877
  })), s = Object.fromEntries(i.map((r) => {
874
878
  let i = n.filter((e) => e.type === r.name), a = {
@@ -876,49 +880,49 @@ function Vt(e, t) {
876
880
  options: r.options,
877
881
  storage: r.storage,
878
882
  editor: t
879
- }, o = zt({
883
+ }, o = Vt({
880
884
  ...e.reduce((e, t) => {
881
- let n = V(t, "extendMarkSchema", a);
885
+ let n = B(t, "extendMarkSchema", a);
882
886
  return {
883
887
  ...e,
884
888
  ...n ? n(r) : {}
885
889
  };
886
890
  }, {}),
887
- inclusive: H(V(r, "inclusive", a)),
888
- excludes: H(V(r, "excludes", a)),
889
- group: H(V(r, "group", a)),
890
- spanning: H(V(r, "spanning", a)),
891
- code: H(V(r, "code", a)),
892
- attrs: Object.fromEntries(i.map(Bt))
893
- }), s = H(V(r, "parseHTML", a));
894
- s && (o.parseDOM = s.map((e) => Rt(e, i)));
895
- let c = V(r, "renderHTML", a);
891
+ inclusive: V(B(r, "inclusive", a)),
892
+ excludes: V(B(r, "excludes", a)),
893
+ group: V(B(r, "group", a)),
894
+ spanning: V(B(r, "spanning", a)),
895
+ code: V(B(r, "code", a)),
896
+ attrs: Object.fromEntries(i.map(Ht))
897
+ }), s = V(B(r, "parseHTML", a));
898
+ s && (o.parseDOM = s.map((e) => Bt(e, i)));
899
+ let c = B(r, "renderHTML", a);
896
900
  return c && (o.toDOM = (e) => c({
897
901
  mark: e,
898
- HTMLAttributes: W(e, i)
902
+ HTMLAttributes: U(e, i)
899
903
  })), [r.name, o];
900
904
  }));
901
- return new le({
905
+ return new ue({
902
906
  topNode: a,
903
907
  nodes: o,
904
908
  marks: s
905
909
  });
906
910
  }
907
- function Ht(e) {
911
+ function Wt(e) {
908
912
  let t = e.filter((t, n) => e.indexOf(t) !== n);
909
913
  return Array.from(new Set(t));
910
914
  }
911
- function G(e) {
915
+ function W(e) {
912
916
  return e.sort((e, t) => {
913
- let n = V(e, "priority") || 100, r = V(t, "priority") || 100;
917
+ let n = B(e, "priority") || 100, r = B(t, "priority") || 100;
914
918
  return n > r ? -1 : +(n < r);
915
919
  });
916
920
  }
917
- function Ut(e) {
918
- let t = G(kt(e)), n = Ht(t.map((e) => e.name));
921
+ function Gt(e) {
922
+ let t = W(jt(e)), n = Wt(t.map((e) => e.name));
919
923
  return n.length && console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map((e) => `'${e}'`).join(", ")}]. This can lead to issues.`), t;
920
924
  }
921
- function Wt(e, t, n) {
925
+ function Kt(e, t, n) {
922
926
  let { from: r, to: i } = t, { blockSeparator: a = "\n\n", textSerializers: o = {} } = n || {}, s = "";
923
927
  return e.nodesBetween(r, i, (e, n, c, l) => {
924
928
  e.isBlock && n > r && (s += a);
@@ -933,39 +937,39 @@ function Wt(e, t, n) {
933
937
  e.isText && (s += (e?.text)?.slice(Math.max(r, n) - n, i - n));
934
938
  }), s;
935
939
  }
936
- function Gt(e, t) {
937
- return Wt(e, {
940
+ function qt(e, t) {
941
+ return Kt(e, {
938
942
  from: 0,
939
943
  to: e.content.size
940
944
  }, t);
941
945
  }
942
- function Kt(e) {
946
+ function Jt(e) {
943
947
  return Object.fromEntries(Object.entries(e.nodes).filter(([, e]) => e.spec.toText).map(([e, t]) => [e, t.spec.toText]));
944
948
  }
945
- function qt(e, t) {
946
- let n = j(t, e.schema), { from: r, to: i } = e.selection, a = [];
949
+ function Yt(e, t) {
950
+ let n = A(t, e.schema), { from: r, to: i } = e.selection, a = [];
947
951
  e.doc.nodesBetween(r, i, (e) => {
948
952
  a.push(e);
949
953
  });
950
954
  let o = a.reverse().find((e) => e.type.name === n.name);
951
955
  return o ? { ...o.attrs } : {};
952
956
  }
953
- function Jt(e, t) {
954
- let n = z(typeof t == "string" ? t : t.name, e.schema);
955
- return n === "node" ? qt(e, t) : n === "mark" ? Tt(e, t) : {};
957
+ function Xt(e, t) {
958
+ let n = R(typeof t == "string" ? t : t.name, e.schema);
959
+ return n === "node" ? Yt(e, t) : n === "mark" ? Dt(e, t) : {};
956
960
  }
957
- function Yt(e, t = JSON.stringify) {
961
+ function Zt(e, t = JSON.stringify) {
958
962
  let n = {};
959
963
  return e.filter((e) => {
960
964
  let r = t(e);
961
965
  return Object.prototype.hasOwnProperty.call(n, r) ? !1 : n[r] = !0;
962
966
  });
963
967
  }
964
- function Xt(e) {
965
- let t = Yt(e);
968
+ function Qt(e) {
969
+ let t = Zt(e);
966
970
  return t.length === 1 ? t : t.filter((e, n) => !t.filter((e, t) => t !== n).some((t) => e.oldRange.from >= t.oldRange.from && e.oldRange.to <= t.oldRange.to && e.newRange.from >= t.newRange.from && e.newRange.to <= t.newRange.to));
967
971
  }
968
- function Zt(e) {
972
+ function $t(e) {
969
973
  let { mapping: t, steps: n } = e, r = [];
970
974
  return t.maps.forEach((e, i) => {
971
975
  let a = [];
@@ -996,12 +1000,12 @@ function Zt(e) {
996
1000
  }
997
1001
  });
998
1002
  });
999
- }), Xt(r);
1003
+ }), Qt(r);
1000
1004
  }
1001
- function Qt(e, t, n) {
1005
+ function en(e, t, n) {
1002
1006
  let r = [];
1003
1007
  return e === t ? n.resolve(e).marks().forEach((t) => {
1004
- let i = Le(n.resolve(e), t.type);
1008
+ let i = Re(n.resolve(e), t.type);
1005
1009
  i && r.push({
1006
1010
  mark: t,
1007
1011
  ...i
@@ -1014,24 +1018,29 @@ function Qt(e, t, n) {
1014
1018
  })));
1015
1019
  }), r;
1016
1020
  }
1017
- var $t = (e, t, n, r = 20) => {
1021
+ var tn = (e, t, n, r = 20) => {
1018
1022
  let i = e.doc.resolve(n), a = r, o = null;
1019
1023
  for (; a > 0 && o === null;) {
1020
1024
  let e = i.node(a);
1021
1025
  e?.type.name === t ? o = e : --a;
1022
1026
  }
1023
1027
  return [o, a];
1028
+ }, nn = (e) => {
1029
+ let t = e.depth - 1;
1030
+ if (t < 0) return null;
1031
+ let n = e.index(t);
1032
+ return n === 0 ? null : e.node(t).child(n - 1);
1024
1033
  };
1025
- function K(e, t) {
1034
+ function G(e, t) {
1026
1035
  return t.nodes[e] || t.marks[e] || null;
1027
1036
  }
1028
- function q(e, t, n) {
1037
+ function K(e, t, n) {
1029
1038
  return Object.fromEntries(Object.entries(n).filter(([n]) => {
1030
1039
  let r = e.find((e) => e.type === t && e.name === n);
1031
1040
  return r ? r.attribute.keepOnSplit : !1;
1032
1041
  }));
1033
1042
  }
1034
- var en = (e, t = 500) => {
1043
+ var rn = (e, t = 500) => {
1035
1044
  let n = "", r = e.parentOffset;
1036
1045
  return e.parent.nodesBetween(Math.max(0, r - t), r, (e, t, i, a) => {
1037
1046
  var o;
@@ -1044,9 +1053,9 @@ var en = (e, t = 500) => {
1044
1053
  n += e.isAtom && !e.isText ? s : s.slice(0, Math.max(0, r - t));
1045
1054
  }), n;
1046
1055
  };
1047
- function tn(e, t, n = {}) {
1048
- let { empty: r, ranges: i } = e.selection, a = t ? N(t, e.schema) : null;
1049
- if (r) return !!(e.storedMarks || e.selection.$from.marks()).filter((e) => !a || a.name === e.type.name).find((e) => M(e.attrs, n, { strict: !1 }));
1056
+ function an(e, t, n = {}) {
1057
+ let { empty: r, ranges: i } = e.selection, a = t ? M(t, e.schema) : null;
1058
+ if (r) return !!(e.storedMarks || e.selection.$from.marks()).filter((e) => !a || a.name === e.type.name).find((e) => j(e.attrs, n, { strict: !1 }));
1050
1059
  let o = 0, s = [];
1051
1060
  if (i.forEach(({ $from: t, $to: n }) => {
1052
1061
  let r = t.pos, i = n.pos;
@@ -1061,41 +1070,41 @@ function tn(e, t, n = {}) {
1061
1070
  })));
1062
1071
  });
1063
1072
  }), o === 0) return !1;
1064
- let c = s.filter((e) => !a || a.name === e.mark.type.name).filter((e) => M(e.mark.attrs, n, { strict: !1 })).reduce((e, t) => e + t.to - t.from, 0), l = s.filter((e) => !a || e.mark.type !== a && e.mark.type.excludes(a)).reduce((e, t) => e + t.to - t.from, 0);
1073
+ let c = s.filter((e) => !a || a.name === e.mark.type.name).filter((e) => j(e.mark.attrs, n, { strict: !1 })).reduce((e, t) => e + t.to - t.from, 0), l = s.filter((e) => !a || e.mark.type !== a && e.mark.type.excludes(a)).reduce((e, t) => e + t.to - t.from, 0);
1065
1074
  return (c > 0 ? c + l : c) >= o;
1066
1075
  }
1067
- function nn(e, t, n = {}) {
1068
- if (!t) return R(e, null, n) || tn(e, null, n);
1069
- let r = z(t, e.schema);
1070
- return r === "node" ? R(e, t, n) : r === "mark" && tn(e, t, n);
1076
+ function on(e, t, n = {}) {
1077
+ if (!t) return L(e, null, n) || an(e, null, n);
1078
+ let r = R(t, e.schema);
1079
+ return r === "node" ? L(e, t, n) : r === "mark" && an(e, t, n);
1071
1080
  }
1072
- var rn = (e, t) => {
1081
+ var sn = (e, t) => {
1073
1082
  let { $from: n, $to: r, $anchor: i } = e.selection;
1074
1083
  if (t) {
1075
- let n = B((e) => e.type.name === t)(e.selection);
1084
+ let n = z((e) => e.type.name === t)(e.selection);
1076
1085
  if (!n) return !1;
1077
1086
  let r = e.doc.resolve(n.pos + 1);
1078
1087
  return i.pos + 1 === r.end();
1079
1088
  }
1080
1089
  return !(r.parentOffset < r.parent.nodeSize - 2 || n.pos !== r.pos);
1081
- }, an = (e) => {
1090
+ }, cn = (e) => {
1082
1091
  let { $from: t, $to: n } = e.selection;
1083
1092
  return !(t.parentOffset > 0 || t.pos !== n.pos);
1084
1093
  };
1085
- function on(e, t) {
1094
+ function ln(e, t) {
1086
1095
  return Array.isArray(t) ? t.some((t) => (typeof t == "string" ? t : t.name) === e.name) : t;
1087
1096
  }
1088
- function sn(e, t) {
1089
- let { nodeExtensions: n } = U(t), r = n.find((t) => t.name === e);
1097
+ function un(e, t) {
1098
+ let { nodeExtensions: n } = H(t), r = n.find((t) => t.name === e);
1090
1099
  if (!r) return !1;
1091
- let i = H(V(r, "group", {
1100
+ let i = V(B(r, "group", {
1092
1101
  name: r.name,
1093
1102
  options: r.options,
1094
1103
  storage: r.storage
1095
1104
  }));
1096
1105
  return typeof i == "string" && i.split(" ").includes("list");
1097
1106
  }
1098
- function J(e, { checkChildren: t = !0, ignoreWhitespace: n = !1 } = {}) {
1107
+ function q(e, { checkChildren: t = !0, ignoreWhitespace: n = !1 } = {}) {
1099
1108
  if (n) {
1100
1109
  if (e.type.name === "hardBreak") return !0;
1101
1110
  if (e.isText) return !/\S/.test(e.text ?? "");
@@ -1106,7 +1115,7 @@ function J(e, { checkChildren: t = !0, ignoreWhitespace: n = !1 } = {}) {
1106
1115
  if (t) {
1107
1116
  let r = !0;
1108
1117
  return e.content.forEach((e) => {
1109
- r !== !1 && (J(e, {
1118
+ r !== !1 && (q(e, {
1110
1119
  ignoreWhitespace: n,
1111
1120
  checkChildren: t
1112
1121
  }) || (r = !1));
@@ -1114,10 +1123,10 @@ function J(e, { checkChildren: t = !0, ignoreWhitespace: n = !1 } = {}) {
1114
1123
  }
1115
1124
  return !1;
1116
1125
  }
1117
- function cn(e) {
1118
- return e instanceof C;
1126
+ function dn(e) {
1127
+ return e instanceof se;
1119
1128
  }
1120
- var ln = class e {
1129
+ var fn = class e {
1121
1130
  constructor(e) {
1122
1131
  this.position = e;
1123
1132
  }
@@ -1128,18 +1137,18 @@ var ln = class e {
1128
1137
  return { position: this.position };
1129
1138
  }
1130
1139
  };
1131
- function un(e, t) {
1140
+ function pn(e, t) {
1132
1141
  let n = t.mapping.mapResult(e.position);
1133
1142
  return {
1134
- position: new ln(n.pos),
1143
+ position: new fn(n.pos),
1135
1144
  mapResult: n
1136
1145
  };
1137
1146
  }
1138
- function dn(e) {
1139
- return new ln(e);
1147
+ function mn(e) {
1148
+ return new fn(e);
1140
1149
  }
1141
- function fn(e, t, n) {
1142
- let r = e.state.doc.content.size, i = P(t, 0, r), a = P(n, 0, r), o = e.coordsAtPos(i), s = e.coordsAtPos(a, -1), c = Math.min(o.top, s.top), l = Math.max(o.bottom, s.bottom), u = Math.min(o.left, s.left), d = Math.max(o.right, s.right), f = {
1150
+ function hn(e, t, n) {
1151
+ let r = e.state.doc.content.size, i = N(t, 0, r), a = N(n, 0, r), o = e.coordsAtPos(i), s = e.coordsAtPos(a, -1), c = Math.min(o.top, s.top), l = Math.max(o.bottom, s.bottom), u = Math.min(o.left, s.left), d = Math.max(o.right, s.right), f = {
1143
1152
  top: c,
1144
1153
  bottom: l,
1145
1154
  left: u,
@@ -1154,9 +1163,9 @@ function fn(e, t, n) {
1154
1163
  toJSON: () => f
1155
1164
  };
1156
1165
  }
1157
- function pn(e, t, n) {
1166
+ function gn(e, t, n) {
1158
1167
  let { selection: r } = t, i = null;
1159
- if (Be(r) && (i = r.$cursor), i) {
1168
+ if (Ve(r) && (i = r.$cursor), i) {
1160
1169
  let t = e.storedMarks ?? i.marks();
1161
1170
  return i.parent.type.allowsMarkType(n) && (!!n.isInSet(t) || !t.some((e) => e.type.excludes(n)));
1162
1171
  }
@@ -1173,11 +1182,11 @@ function pn(e, t, n) {
1173
1182
  }), i;
1174
1183
  });
1175
1184
  }
1176
- var mn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
1177
- let { selection: a } = n, { empty: o, ranges: s } = a, c = N(e, r.schema);
1185
+ var _n = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
1186
+ let { selection: a } = n, { empty: o, ranges: s } = a, c = M(e, r.schema);
1178
1187
  if (i) {
1179
1188
  if (o) {
1180
- let e = Tt(r, c);
1189
+ let e = Dt(r, c);
1181
1190
  n.addStoredMark(c.create({
1182
1191
  ...e,
1183
1192
  ...t
@@ -1195,9 +1204,9 @@ var mn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
1195
1204
  });
1196
1205
  });
1197
1206
  }
1198
- return pn(r, n, c);
1199
- }, hn = (e, t) => ({ tr: n }) => (n.setMeta(e, t), !0), gn = (e, t = {}) => ({ state: n, dispatch: r, chain: i }) => {
1200
- let a = j(e, n.schema), o;
1207
+ return gn(r, n, c);
1208
+ }, vn = (e, t) => ({ tr: n }) => (n.setMeta(e, t), !0), yn = (e, t = {}) => ({ state: n, dispatch: r, chain: i }) => {
1209
+ let a = A(e, n.schema), o;
1201
1210
  return n.selection.$anchor.sameParent(n.selection.$head) && (o = n.selection.$anchor.parent.attrs), a.isTextblock ? i().command(({ commands: e }) => b(a, {
1202
1211
  ...o,
1203
1212
  ...t
@@ -1205,13 +1214,13 @@ var mn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
1205
1214
  ...o,
1206
1215
  ...t
1207
1216
  })(e, r)).run() : (console.warn("[tiptap warn]: Currently \"setNode()\" only supports text block nodes."), !1);
1208
- }, _n = (e) => ({ tr: t, dispatch: n }) => {
1217
+ }, bn = (e) => ({ tr: t, dispatch: n }) => {
1209
1218
  if (n) {
1210
- let { doc: n } = t, r = P(e, 0, n.content.size), i = C.create(n, r);
1219
+ let { doc: n } = t, r = N(e, 0, n.content.size), i = se.create(n, r);
1211
1220
  t.setSelection(i);
1212
1221
  }
1213
1222
  return !0;
1214
- }, vn = (e, t) => ({ tr: n, state: r, dispatch: i }) => {
1223
+ }, xn = (e, t) => ({ tr: n, state: r, dispatch: i }) => {
1215
1224
  let { selection: a } = r, o, s;
1216
1225
  return typeof t == "number" ? (o = t, s = t) : t && "from" in t && "to" in t ? (o = t.from, s = t.to) : (o = a.from, s = a.to), i && n.doc.nodesBetween(o, s, (t, r) => {
1217
1226
  t.isText || n.setNodeMarkup(r, void 0, {
@@ -1219,31 +1228,31 @@ var mn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
1219
1228
  dir: e
1220
1229
  });
1221
1230
  }), !0;
1222
- }, yn = (e) => ({ tr: t, dispatch: n }) => {
1231
+ }, Sn = (e) => ({ tr: t, dispatch: n }) => {
1223
1232
  if (n) {
1224
1233
  let { doc: n } = t, { from: r, to: i } = typeof e == "number" ? {
1225
1234
  from: e,
1226
1235
  to: e
1227
- } : e, a = D.atStart(n).from, o = D.atEnd(n).to, s = P(r, a, o), c = P(i, a, o), l = D.create(n, s, c);
1236
+ } : e, a = T.atStart(n).from, o = T.atEnd(n).to, s = N(r, a, o), c = N(i, a, o), l = T.create(n, s, c);
1228
1237
  t.setSelection(l);
1229
1238
  }
1230
1239
  return !0;
1231
- }, bn = (e) => ({ state: t, dispatch: n }) => {
1232
- let r = j(e, t.schema);
1233
- return fe(r)(t, n);
1240
+ }, Cn = (e) => ({ state: t, dispatch: n }) => {
1241
+ let r = A(e, t.schema);
1242
+ return pe(r)(t, n);
1234
1243
  };
1235
- function xn(e, t) {
1244
+ function wn(e, t) {
1236
1245
  let n = e.storedMarks || e.selection.$to.parentOffset && e.selection.$from.marks();
1237
1246
  if (n) {
1238
1247
  let r = n.filter((e) => t?.includes(e.type.name));
1239
1248
  e.tr.ensureMarks(r);
1240
1249
  }
1241
1250
  }
1242
- var Sn = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor: i }) => {
1243
- let { selection: o, doc: s } = t, { $from: c, $to: l } = o, u = i.extensionManager.attributes, d = q(u, c.node().type.name, c.node().attrs);
1244
- if (o instanceof C && o.node.isBlock) return !c.parentOffset || !a(s, c.pos) ? !1 : (r && (e && xn(n, i.extensionManager.splittableMarks), t.split(c.pos).scrollIntoView()), !0);
1251
+ var Tn = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor: i }) => {
1252
+ let { selection: o, doc: s } = t, { $from: c, $to: l } = o, u = i.extensionManager.attributes, d = K(u, c.node().type.name, c.node().attrs);
1253
+ if (o instanceof se && o.node.isBlock) return !c.parentOffset || !a(s, c.pos) ? !1 : (r && (e && wn(n, i.extensionManager.splittableMarks), t.split(c.pos).scrollIntoView()), !0);
1245
1254
  if (!c.parent.isBlock) return !1;
1246
- let f = l.parentOffset === l.parent.content.size, p = c.depth === 0 ? void 0 : Ze(c.node(-1).contentMatchAt(c.indexAfter(-1))), m = f && p ? [{
1255
+ let f = l.parentOffset === l.parent.content.size, p = c.depth === 0 ? void 0 : $e(c.node(-1).contentMatchAt(c.indexAfter(-1))), m = f && p ? [{
1247
1256
  type: p,
1248
1257
  attrs: d
1249
1258
  }] : void 0, h = a(t.doc, t.mapping.map(c.pos), 1, m);
@@ -1251,15 +1260,15 @@ var Sn = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
1251
1260
  type: p,
1252
1261
  attrs: d
1253
1262
  }] : void 0), r) {
1254
- if (h && (o instanceof D && t.deleteSelection(), t.split(t.mapping.map(c.pos), 1, m), p && !f && !c.parentOffset && c.parent.type !== p)) {
1263
+ if (h && (o instanceof T && t.deleteSelection(), t.split(t.mapping.map(c.pos), 1, m), p && !f && !c.parentOffset && c.parent.type !== p)) {
1255
1264
  let e = t.mapping.map(c.before()), n = t.doc.resolve(e);
1256
1265
  c.node(-1).canReplaceWith(n.index(), n.index() + 1, p) && t.setNodeMarkup(t.mapping.map(c.before()), p);
1257
1266
  }
1258
- e && xn(n, i.extensionManager.splittableMarks), t.scrollIntoView();
1267
+ e && wn(n, i.extensionManager.splittableMarks), t.scrollIntoView();
1259
1268
  }
1260
1269
  return h;
1261
- }, Cn = (e, t = {}) => ({ tr: n, state: r, dispatch: i, editor: o }) => {
1262
- let s = j(e, r.schema), { $from: c, $to: l } = r.selection, u = r.selection.node;
1270
+ }, En = (e, t = {}) => ({ tr: n, state: r, dispatch: i, editor: o }) => {
1271
+ let s = A(e, r.schema), { $from: c, $to: l } = r.selection, u = r.selection.node;
1263
1272
  if (u && u.isBlock || c.depth < 2 || !c.sameParent(l)) return !1;
1264
1273
  let d = c.node(-1);
1265
1274
  if (d.type !== s) return !1;
@@ -1267,28 +1276,28 @@ var Sn = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
1267
1276
  if (c.parent.content.size === 0 && c.node(-1).childCount === c.indexAfter(-1)) {
1268
1277
  if (c.depth === 2 || c.node(-3).type !== s || c.index(-2) !== c.node(-2).childCount - 1) return !1;
1269
1278
  if (i) {
1270
- let e = O.empty, r = c.index(-1) ? 1 : c.index(-2) ? 2 : 3;
1271
- for (let t = c.depth - r; t >= c.depth - 3; --t) e = O.from(c.node(t).copy(e));
1279
+ let e = E.empty, r = c.index(-1) ? 1 : c.index(-2) ? 2 : 3;
1280
+ for (let t = c.depth - r; t >= c.depth - 3; --t) e = E.from(c.node(t).copy(e));
1272
1281
  let i = c.indexAfter(-1) < c.node(-2).childCount ? 1 : c.indexAfter(-2) < c.node(-3).childCount ? 2 : 3, a = {
1273
- ...q(f, c.node().type.name, c.node().attrs),
1282
+ ...K(f, c.node().type.name, c.node().attrs),
1274
1283
  ...t
1275
1284
  }, o = s.contentMatch.defaultType?.createAndFill(a) || void 0;
1276
- e = e.append(O.from(s.createAndFill(null, o) || void 0));
1285
+ e = e.append(E.from(s.createAndFill(null, o) || void 0));
1277
1286
  let l = c.before(c.depth - (r - 1));
1278
- n.replace(l, c.after(-i), new ue(e, 4 - r, 0));
1287
+ n.replace(l, c.after(-i), new de(e, 4 - r, 0));
1279
1288
  let u = -1;
1280
1289
  n.doc.nodesBetween(l, n.doc.content.size, (e, t) => {
1281
1290
  if (u > -1) return !1;
1282
1291
  e.isTextblock && e.content.size === 0 && (u = t + 1);
1283
- }), u > -1 && n.setSelection(D.near(n.doc.resolve(u))), n.scrollIntoView();
1292
+ }), u > -1 && n.setSelection(T.near(n.doc.resolve(u))), n.scrollIntoView();
1284
1293
  }
1285
1294
  return !0;
1286
1295
  }
1287
1296
  let p = l.pos === c.end() ? d.contentMatchAt(0).defaultType : null, m = {
1288
- ...q(f, d.type.name, d.attrs),
1297
+ ...K(f, d.type.name, d.attrs),
1289
1298
  ...t
1290
1299
  }, h = {
1291
- ...q(f, c.node().type.name, c.node().attrs),
1300
+ ...K(f, c.node().type.name, c.node().attrs),
1292
1301
  ...t
1293
1302
  };
1294
1303
  n.delete(c.pos, l.pos);
@@ -1311,65 +1320,65 @@ var Sn = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
1311
1320
  }
1312
1321
  return !0;
1313
1322
  };
1314
- function wn(e) {
1323
+ function Dn(e) {
1315
1324
  return !e || e === "1" ? null : e;
1316
1325
  }
1317
- function Tn(e, t) {
1318
- return wn(e) === wn(t);
1326
+ function On(e, t) {
1327
+ return Dn(e) === Dn(t);
1319
1328
  }
1320
- var En = (e, t) => {
1321
- let n = B((e) => e.type === t)(e.selection);
1329
+ var kn = (e, t) => {
1330
+ let n = z((e) => e.type === t)(e.selection);
1322
1331
  if (!n) return !0;
1323
1332
  let r = e.doc.resolve(Math.max(0, n.pos - 1)).before(n.depth);
1324
1333
  if (r === void 0) return !0;
1325
1334
  let a = e.doc.nodeAt(r);
1326
- return !(n.node.type === a?.type && i(e.doc, n.pos)) || !Tn(n.node.attrs.type, a?.attrs.type) || e.join(n.pos), !0;
1327
- }, Dn = (e, t) => {
1328
- let n = B((e) => e.type === t)(e.selection);
1335
+ return !(n.node.type === a?.type && i(e.doc, n.pos)) || !On(n.node.attrs.type, a?.attrs.type) || e.join(n.pos), !0;
1336
+ }, An = (e, t) => {
1337
+ let n = z((e) => e.type === t)(e.selection);
1329
1338
  if (!n) return !0;
1330
1339
  let r = e.doc.resolve(n.start).after(n.depth);
1331
1340
  if (r === void 0) return !0;
1332
1341
  let a = e.doc.nodeAt(r);
1333
- return !(n.node.type === a?.type && i(e.doc, r)) || !Tn(n.node.attrs.type, a?.attrs.type) || e.join(r), !0;
1342
+ return !(n.node.type === a?.type && i(e.doc, r)) || !On(n.node.attrs.type, a?.attrs.type) || e.join(r), !0;
1334
1343
  };
1335
- function On(e) {
1344
+ function jn(e) {
1336
1345
  let t = e.doc, n = t.firstChild;
1337
1346
  if (!n) return null;
1338
1347
  let r = t.resolve(1), i = t.resolve(n.nodeSize - 1);
1339
- return D.between(r, i);
1348
+ return T.between(r, i);
1340
1349
  }
1341
- var kn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain: c, commands: l, can: u }) => {
1342
- let { extensions: d, splittableMarks: f } = i.extensionManager, p = j(e, o.schema), m = j(t, o.schema), { selection: h, storedMarks: g } = o, { $from: ee, $to: te } = h, _ = ee.blockRange(te), ne = g || h.$to.parentOffset && h.$from.marks();
1350
+ var Mn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain: c, commands: l, can: u }) => {
1351
+ let { extensions: d, splittableMarks: f } = i.extensionManager, p = A(e, o.schema), m = A(t, o.schema), { selection: h, storedMarks: g } = o, { $from: ee, $to: te } = h, _ = ee.blockRange(te), ne = g || h.$to.parentOffset && h.$from.marks();
1343
1352
  if (!_) return !1;
1344
- let v = B((e) => sn(e.type.name, d))(h), re = h.from === 0 && h.to === o.doc.content.size, ie = o.doc.content.content, y = ie.length === 1 ? ie[0] : null, b = re && y && sn(y.type.name, d) ? {
1353
+ let v = z((e) => un(e.type.name, d))(h), re = h.from === 0 && h.to === o.doc.content.size, ie = o.doc.content.content, y = ie.length === 1 ? ie[0] : null, b = re && y && un(y.type.name, d) ? {
1345
1354
  node: y,
1346
1355
  pos: 0,
1347
1356
  depth: 0
1348
- } : null, x = v ?? b, ae = !!v && _.depth >= 1 && _.depth - v.depth <= 1, S = !!b;
1349
- if ((ae || S) && x) {
1350
- if (x.node.type === p) return re && S ? c().command(({ tr: e, dispatch: t }) => {
1351
- let n = On(e);
1357
+ } : null, x = v ?? b, ae = !!v && _.depth >= 1 && _.depth - v.depth <= 1, oe = !!b;
1358
+ if ((ae || oe) && x) {
1359
+ if (x.node.type === p) return re && oe ? c().command(({ tr: e, dispatch: t }) => {
1360
+ let n = jn(e);
1352
1361
  return n ? (e.setSelection(n), t && t(e), !0) : !1;
1353
1362
  }).liftListItem(m).run() : l.liftListItem(m);
1354
- if (sn(x.node.type.name, d) && p.validContent(x.node.content)) return c().command(() => (a.setNodeMarkup(x.pos, p), !0)).command(() => En(a, p)).command(() => Dn(a, p)).run();
1363
+ if (un(x.node.type.name, d) && p.validContent(x.node.content)) return c().command(() => (a.setNodeMarkup(x.pos, p), !0)).command(() => kn(a, p)).command(() => An(a, p)).run();
1355
1364
  }
1356
- return !n || !ne || !s ? c().command(() => u().wrapInList(p, r) ? !0 : l.clearNodes()).wrapInList(p, r).command(() => En(a, p)).command(() => Dn(a, p)).run() : c().command(() => {
1365
+ return !n || !ne || !s ? c().command(() => u().wrapInList(p, r) ? !0 : l.clearNodes()).wrapInList(p, r).command(() => kn(a, p)).command(() => An(a, p)).run() : c().command(() => {
1357
1366
  let e = u().wrapInList(p, r), t = ne.filter((e) => f.includes(e.type.name));
1358
1367
  return a.ensureMarks(t), e ? !0 : l.clearNodes();
1359
- }).wrapInList(p, r).command(() => En(a, p)).command(() => Dn(a, p)).run();
1360
- }, An = (e, t = {}, n = {}) => ({ state: r, commands: i }) => {
1361
- let { extendEmptyMarkRange: a = !1 } = n, o = N(e, r.schema);
1362
- return tn(r, o, t) ? i.unsetMark(o, { extendEmptyMarkRange: a }) : i.setMark(o, t);
1363
- }, jn = (e, t, n = {}) => ({ state: r, commands: i }) => {
1364
- let a = j(e, r.schema), o = j(t, r.schema), s = R(r, a, n), c;
1368
+ }).wrapInList(p, r).command(() => kn(a, p)).command(() => An(a, p)).run();
1369
+ }, Nn = (e, t = {}, n = {}) => ({ state: r, commands: i }) => {
1370
+ let { extendEmptyMarkRange: a = !1 } = n, o = M(e, r.schema);
1371
+ return an(r, o, t) ? i.unsetMark(o, { extendEmptyMarkRange: a }) : i.setMark(o, t);
1372
+ }, Pn = (e, t, n = {}) => ({ state: r, commands: i }) => {
1373
+ let a = A(e, r.schema), o = A(t, r.schema), s = L(r, a, n), c;
1365
1374
  return r.selection.$anchor.sameParent(r.selection.$head) && (c = r.selection.$anchor.parent.attrs), s ? i.setNode(o, c) : i.setNode(a, {
1366
1375
  ...c,
1367
1376
  ...n
1368
1377
  });
1369
- }, Mn = (e, t = {}) => ({ state: n, commands: r }) => {
1370
- let i = j(e, n.schema);
1371
- return R(n, i, t) ? r.lift(i) : r.wrapIn(i, t);
1372
- }, Nn = () => ({ state: e, dispatch: t }) => {
1378
+ }, Fn = (e, t = {}) => ({ state: n, commands: r }) => {
1379
+ let i = A(e, n.schema);
1380
+ return L(n, i, t) ? r.lift(i) : r.wrapIn(i, t);
1381
+ }, In = () => ({ state: e, dispatch: t }) => {
1373
1382
  let n = e.plugins;
1374
1383
  for (let r = 0; r < n.length; r += 1) {
1375
1384
  let i = n[r], a;
@@ -1386,7 +1395,7 @@ var kn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain:
1386
1395
  }
1387
1396
  }
1388
1397
  return !1;
1389
- }, Pn = (e = {}) => ({ tr: t, dispatch: n, editor: r }) => {
1398
+ }, Ln = (e = {}) => ({ tr: t, dispatch: n, editor: r }) => {
1390
1399
  let { ignoreClearable: i = !1 } = e, { selection: a } = t, { empty: o, ranges: s } = a;
1391
1400
  if (o) return !0;
1392
1401
  let { nonClearableMarks: c } = r.extensionManager;
@@ -1397,27 +1406,27 @@ var kn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain:
1397
1406
  });
1398
1407
  }
1399
1408
  return !0;
1400
- }, Fn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
1401
- let { extendEmptyMarkRange: a = !1 } = t, { selection: o } = n, s = N(e, r.schema), { $from: c, empty: l, ranges: u } = o;
1409
+ }, Rn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
1410
+ let { extendEmptyMarkRange: a = !1 } = t, { selection: o } = n, s = M(e, r.schema), { $from: c, empty: l, ranges: u } = o;
1402
1411
  if (!i) return !0;
1403
1412
  if (l && a) {
1404
- let { from: e, to: t } = o, r = Le(c, s, c.marks().find((e) => e.type === s)?.attrs);
1413
+ let { from: e, to: t } = o, r = Re(c, s, c.marks().find((e) => e.type === s)?.attrs);
1405
1414
  r && (e = r.from, t = r.to), n.removeMark(e, t, s);
1406
1415
  } else u.forEach((e) => {
1407
1416
  n.removeMark(e.$from.pos, e.$to.pos, s);
1408
1417
  });
1409
1418
  return n.removeStoredMark(s), !0;
1410
- }, In = (e) => ({ tr: t, state: n, dispatch: r }) => {
1419
+ }, zn = (e) => ({ tr: t, state: n, dispatch: r }) => {
1411
1420
  let { selection: i } = n, a, o;
1412
1421
  return typeof e == "number" ? (a = e, o = e) : e && "from" in e && "to" in e ? (a = e.from, o = e.to) : (a = i.from, o = i.to), r && t.doc.nodesBetween(a, o, (e, n) => {
1413
1422
  if (e.isText) return;
1414
1423
  let r = { ...e.attrs };
1415
1424
  delete r.dir, t.setNodeMarkup(n, void 0, r);
1416
1425
  }), !0;
1417
- }, Ln = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
1418
- let a = null, o = null, s = z(typeof e == "string" ? e : e.name, r.schema);
1426
+ }, Bn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
1427
+ let a = null, o = null, s = R(typeof e == "string" ? e : e.name, r.schema);
1419
1428
  if (!s) return !1;
1420
- s === "node" && (a = j(e, r.schema)), s === "mark" && (o = N(e, r.schema));
1429
+ s === "node" && (a = A(e, r.schema)), s === "mark" && (o = M(e, r.schema));
1421
1430
  let c = !1;
1422
1431
  return n.selection.ranges.forEach((e) => {
1423
1432
  let s = e.$from.pos, l = e.$to.pos, u, d, f, p;
@@ -1446,13 +1455,29 @@ var kn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain:
1446
1455
  }));
1447
1456
  }));
1448
1457
  }), c;
1449
- }, Rn = (e, t = {}) => ({ state: n, dispatch: r }) => {
1450
- let i = j(e, n.schema);
1458
+ }, J = new C("__tiptap_decorations__"), Vn = (e) => ({ tr: t, dispatch: n }) => (n && t.setMeta(J, {
1459
+ type: "force",
1460
+ name: e
1461
+ }), !0), Hn = (e, t = {}) => ({ state: n, dispatch: r }) => {
1462
+ let i = A(e, n.schema);
1451
1463
  return x(i, t)(n, r);
1452
- }, zn = (e, t = {}) => ({ state: n, dispatch: r }) => {
1453
- let i = j(e, n.schema);
1454
- return pe(i, t)(n, r);
1455
- }, Bn = class {
1464
+ }, Un = (e, t = {}) => ({ state: n, dispatch: r }) => {
1465
+ let i = A(e, n.schema);
1466
+ return me(i, t)(n, r);
1467
+ }, Y = /* @__PURE__ */ new WeakMap();
1468
+ function Wn(e, t) {
1469
+ Y.set(e, (Y.get(e) ?? 0) + 1);
1470
+ try {
1471
+ return t();
1472
+ } finally {
1473
+ let t = (Y.get(e) ?? 1) - 1;
1474
+ t > 0 ? Y.set(e, t) : Y.delete(e);
1475
+ }
1476
+ }
1477
+ function Gn(e) {
1478
+ return Y.has(e);
1479
+ }
1480
+ var Kn = class {
1456
1481
  constructor() {
1457
1482
  this.callbacks = {};
1458
1483
  }
@@ -1476,10 +1501,308 @@ var kn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain:
1476
1501
  removeAllListeners() {
1477
1502
  this.callbacks = {};
1478
1503
  }
1504
+ }, qn = typeof process < "u" && process.env.NODE_ENV !== "production";
1505
+ function Jn(e) {
1506
+ return e.kind === "widget";
1507
+ }
1508
+ function Yn(e, t) {
1509
+ let n = [], r = /* @__PURE__ */ new Set();
1510
+ for (let i of e) i.kind === "widget" && Jn(i) && r.add(i.key), n.push(i.toPMDecoration(t));
1511
+ return {
1512
+ decorations: n,
1513
+ widgetKeys: r
1514
+ };
1515
+ }
1516
+ function Xn(e, t, n) {
1517
+ let { decorations: r, widgetKeys: i } = Yn(t, n);
1518
+ return {
1519
+ set: D.create(e, r),
1520
+ widgetKeys: i
1521
+ };
1522
+ }
1523
+ function Zn({ position: e, from: t, to: n, docSize: r }) {
1524
+ return e < t ? !1 : e < n || e === n && n === r;
1525
+ }
1526
+ function Qn({ decorations: e, from: t, to: n, docSize: r, extensionName: i, warnedExtensions: a }) {
1527
+ return e.filter((e) => Zn({
1528
+ position: e.anchor,
1529
+ from: t,
1530
+ to: n,
1531
+ docSize: r
1532
+ }) ? !0 : (e.anchor === n || a.has(i) || (a.add(i), console.warn(`[tiptap warn]: Extension "${i}" returned a decoration outside the requested range [${t}, ${n}). It was ignored.`)), !1));
1533
+ }
1534
+ function $n(e) {
1535
+ let t = e.spec?.key;
1536
+ return typeof t == "string" ? t : void 0;
1537
+ }
1538
+ function er(e) {
1539
+ let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
1540
+ for (let r of e.find()) {
1541
+ let e = $n(r);
1542
+ if (!e) continue;
1543
+ let i = r.spec.extensionName ?? "unknown", a = t.get(e) ?? /* @__PURE__ */ new Set();
1544
+ a.add(i), t.set(e, a), n.set(e, (n.get(e) ?? 0) + 1);
1545
+ }
1546
+ return Array.from(t, ([e, t]) => ({
1547
+ key: e,
1548
+ extensions: t
1549
+ })).filter(({ key: e }) => (n.get(e) ?? 0) > 1);
1550
+ }
1551
+ function tr(e) {
1552
+ return e.jsonID === "attr";
1553
+ }
1554
+ function nr(e) {
1555
+ let t = !1;
1556
+ if (e.getMap().forEach(() => {
1557
+ t = !0;
1558
+ }), t || tr(e)) return !0;
1559
+ let n = e;
1560
+ return typeof n.from == "number" && typeof n.to == "number";
1561
+ }
1562
+ function rr(e, t) {
1563
+ let n = null, r = 0, i = 0;
1564
+ for (let a = 0; a < e.childCount && !(i > t.to); a += 1) {
1565
+ let o = i + e.child(a).nodeSize;
1566
+ o >= t.from && (n === null && (n = i), r = o), i = o;
1567
+ }
1568
+ return n === null ? null : {
1569
+ from: n,
1570
+ to: r
1571
+ };
1572
+ }
1573
+ function ir(e, t) {
1574
+ if (e.steps.some((e) => !nr(e))) return { type: "full" };
1575
+ let n = $t(e).map(({ newRange: e }) => e);
1576
+ e.steps.forEach((t, r) => {
1577
+ if (!tr(t)) return;
1578
+ let i = e.mapping.slice(r);
1579
+ n.push({
1580
+ from: i.map(t.pos, -1),
1581
+ to: i.map(t.pos + 1)
1582
+ });
1583
+ });
1584
+ let r = [];
1585
+ for (let e of n) {
1586
+ let n = rr(t, e);
1587
+ n && r.push(n);
1588
+ }
1589
+ r.sort((e, t) => e.from - t.from);
1590
+ let i = [];
1591
+ for (let e of r) {
1592
+ let t = i[i.length - 1];
1593
+ t && e.from <= t.to ? t.to = Math.max(t.to, e.to) : i.push({ ...e });
1594
+ }
1595
+ return {
1596
+ type: "ranges",
1597
+ ranges: i
1598
+ };
1599
+ }
1600
+ function ar(e, t, n, r) {
1601
+ return e.map(t, n, { onRemove: (e) => {
1602
+ let t = e?.key;
1603
+ typeof t == "string" && r.delete(t);
1604
+ } });
1605
+ }
1606
+ function or(e, t, n) {
1607
+ let r = t.decorationSetsByExtension[e] ?? D.empty, i = new Set(t.widgetKeysByExtension[e] ?? []);
1608
+ return {
1609
+ set: ar(r, n.mapping, n.doc, i),
1610
+ widgetKeys: i
1611
+ };
1612
+ }
1613
+ function sr(e, t) {
1614
+ let n = Object.values(t).flatMap((e) => e.find());
1615
+ return D.create(e, n);
1616
+ }
1617
+ function cr(e) {
1618
+ let t = /* @__PURE__ */ new Set();
1619
+ for (let n of Object.values(e)) for (let e of n) t.add(e);
1620
+ return t;
1621
+ }
1622
+ function lr(e, t) {
1623
+ switch (t.update ?? "document") {
1624
+ case "document":
1625
+ if (t.createInRange) throw Error(`[tiptap error]: Extension "${e}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);
1626
+ return;
1627
+ case "changedRanges":
1628
+ if (!t.createInRange) throw Error(`[tiptap error]: Extension "${e}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);
1629
+ return;
1630
+ case "manual":
1631
+ if (t.createInRange) throw Error(`[tiptap error]: Extension "${e}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`);
1632
+ if (t.shouldUpdate) throw Error(`[tiptap error]: Extension "${e}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);
1633
+ return;
1634
+ default: throw Error(`[tiptap error]: Extension "${e}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`);
1635
+ }
1636
+ }
1637
+ function ur(e, t, n) {
1638
+ return n ? !0 : e.update === "manual" ? !1 : e.shouldUpdate ? e.shouldUpdate(t) : t.tr.docChanged;
1639
+ }
1640
+ var dr = /* @__PURE__ */ new Set(), fr = class {
1641
+ constructor(e) {
1642
+ this.warnedWidgetKeys = /* @__PURE__ */ new Set(), this.warnedOutOfRangeExtensions = /* @__PURE__ */ new Set(), this.handleBeforeTransaction = ({ nextState: e }) => {
1643
+ let t = J.getState(e);
1644
+ t && this.warnDuplicateWidgetKeys(t);
1645
+ }, this.editor = e.editor, this.entries = this.resolveEntries(e.entries), this.entries.forEach(({ name: e, spec: t }) => lr(e, t)), this.plugin = this.entries.length > 0 ? this.createPlugin() : null, this.editor.on("beforeTransaction", this.handleBeforeTransaction);
1646
+ }
1647
+ destroy() {
1648
+ this.editor.off("beforeTransaction", this.handleBeforeTransaction);
1649
+ }
1650
+ liveWidgetKeys() {
1651
+ return J.getState(this.editor.state)?.widgetKeys ?? dr;
1652
+ }
1653
+ get mountedView() {
1654
+ return this.editor.isDestroyed ? null : this.editor.view;
1655
+ }
1656
+ resolveEntries(e) {
1657
+ let t = [];
1658
+ for (let { name: n, addDecorations: r } of e) {
1659
+ let e = r();
1660
+ e && t.push({
1661
+ name: n,
1662
+ spec: e
1663
+ });
1664
+ }
1665
+ return t;
1666
+ }
1667
+ createPlugin() {
1668
+ let { editor: e, entries: t } = this;
1669
+ return new S({
1670
+ key: J,
1671
+ state: {
1672
+ init: (e, n) => {
1673
+ let r = {}, i = {};
1674
+ for (let { name: e, spec: a } of t) {
1675
+ let { set: t, widgetKeys: o } = this.buildFullSet(e, a, n);
1676
+ r[e] = t, i[e] = o;
1677
+ }
1678
+ let a = {
1679
+ decorationSetsByExtension: r,
1680
+ widgetKeysByExtension: i,
1681
+ mergedDecorationSet: this.buildMergedSet(n.doc, r),
1682
+ widgetKeys: cr(i)
1683
+ };
1684
+ return this.warnDuplicateWidgetKeys(a), a;
1685
+ },
1686
+ apply: (n, r, i, a) => {
1687
+ let o = n.getMeta(J), s = o?.type === "force" && !o.name, c = o?.type === "force" ? o.name : void 0, l = {}, u = {}, d = /* @__PURE__ */ new Set();
1688
+ return Wn(e, () => {
1689
+ for (let { name: o, spec: f } of t) {
1690
+ let t = s || c === o;
1691
+ if (!ur(f, {
1692
+ editor: e,
1693
+ tr: n,
1694
+ oldState: i,
1695
+ newState: a
1696
+ }, t)) {
1697
+ let e = or(o, r, n);
1698
+ l[o] = e.set, u[o] = e.widgetKeys;
1699
+ } else if (f.update === "changedRanges" && n.docChanged && !t) {
1700
+ let e = this.applyChangedRangesRecompute(o, f, r, n, a);
1701
+ l[o] = e.set, u[o] = e.widgetKeys, d.add(o);
1702
+ } else {
1703
+ let { set: e, widgetKeys: t } = this.buildFullSet(o, f, a);
1704
+ l[o] = e, u[o] = t, d.add(o);
1705
+ }
1706
+ }
1707
+ }), d.size === 0 && !n.docChanged ? r : {
1708
+ decorationSetsByExtension: l,
1709
+ widgetKeysByExtension: u,
1710
+ mergedDecorationSet: this.mergeAfterApply({
1711
+ entries: t,
1712
+ previous: r,
1713
+ tr: n,
1714
+ decorationSetsByExtension: l,
1715
+ recomputedNames: d
1716
+ }),
1717
+ widgetKeys: cr(u)
1718
+ };
1719
+ }
1720
+ },
1721
+ props: { decorations(e) {
1722
+ return J.getState(e)?.mergedDecorationSet ?? D.empty;
1723
+ } }
1724
+ });
1725
+ }
1726
+ applyChangedRangesRecompute(e, t, n, r, i) {
1727
+ let a = ir(r, i.doc);
1728
+ return a.type === "full" ? this.buildFullSet(e, t, i) : this.rebuildRanges(e, t, n, r, i, a.ranges);
1729
+ }
1730
+ rebuildRanges(e, t, n, r, i, a) {
1731
+ let o = n.decorationSetsByExtension[e] ?? D.empty, s = new Set(n.widgetKeysByExtension[e] ?? []), c = ar(o, r.mapping, r.doc, s), l = i.doc.content.size;
1732
+ for (let { from: n, to: r } of a) {
1733
+ let a = c.find(n, r).filter((e) => Zn({
1734
+ position: e.from,
1735
+ from: n,
1736
+ to: r,
1737
+ docSize: l
1738
+ }));
1739
+ for (let e of a) {
1740
+ let t = $n(e);
1741
+ t && s.delete(t);
1742
+ }
1743
+ c = c.remove(a);
1744
+ let { decorations: o, widgetKeys: u } = Yn(Qn({
1745
+ decorations: this.runCreate(e, "createInRange", () => t.createInRange({
1746
+ editor: this.editor,
1747
+ state: i,
1748
+ view: this.mountedView,
1749
+ from: n,
1750
+ to: r
1751
+ })),
1752
+ from: n,
1753
+ to: r,
1754
+ docSize: l,
1755
+ extensionName: e,
1756
+ warnedExtensions: this.warnedOutOfRangeExtensions
1757
+ }), e);
1758
+ c = c.add(i.doc, o);
1759
+ for (let e of u) s.add(e);
1760
+ }
1761
+ return {
1762
+ set: c,
1763
+ widgetKeys: s
1764
+ };
1765
+ }
1766
+ buildFullSet(e, t, n) {
1767
+ let r = this.runCreate(e, "create", () => t.create({
1768
+ editor: this.editor,
1769
+ state: n,
1770
+ view: this.mountedView
1771
+ }));
1772
+ return Xn(n.doc, r, e);
1773
+ }
1774
+ runCreate(e, t, n) {
1775
+ try {
1776
+ return n();
1777
+ } catch (n) {
1778
+ return console.error(`[tiptap error]: Extension "${e}" threw in \`addDecorations().${t}()\`. Its decorations were dropped for this update.`, n), [];
1779
+ }
1780
+ }
1781
+ warnDuplicateWidgetKeys(e) {
1782
+ if (!qn) return;
1783
+ if (e.widgetKeys.size === 0) {
1784
+ this.warnedWidgetKeys.clear();
1785
+ return;
1786
+ }
1787
+ let t = er(e.mergedDecorationSet), n = new Set(t.map(({ key: e }) => e));
1788
+ for (let { key: e, extensions: n } of t) {
1789
+ if (this.warnedWidgetKeys.has(e)) continue;
1790
+ let t = Array.from(n).map((e) => `"${e}"`).join(", ");
1791
+ console.warn(`[tiptap warn]: Duplicate widget decoration key "${e}" in extension${n.size === 1 ? "" : "s"} ${t}. Widget decoration keys must be globally unique, otherwise ProseMirror misplaces the widget DOM. Use a stable, unique key (e.g. \`comment-\${id}\`).`);
1792
+ }
1793
+ this.warnedWidgetKeys = n;
1794
+ }
1795
+ buildMergedSet(e, t) {
1796
+ let n = Object.keys(t);
1797
+ return n.length === 1 ? t[n[0]] : sr(e, t);
1798
+ }
1799
+ mergeAfterApply({ entries: e, previous: t, tr: n, decorationSetsByExtension: r, recomputedNames: i }) {
1800
+ return e.length === 1 ? r[e[0].name] : i.size === 0 ? t.mergedDecorationSet.map(n.mapping, n.doc) : sr(n.doc, r);
1801
+ }
1479
1802
  };
1480
- function Vn(e, t) {
1803
+ function pr(e, t) {
1481
1804
  let { selection: n } = e, { $from: r } = n;
1482
- if (n instanceof C) {
1805
+ if (n instanceof se) {
1483
1806
  let e = r.index();
1484
1807
  return r.parent.canReplaceWith(e, e + 1, t);
1485
1808
  }
@@ -1491,16 +1814,16 @@ function Vn(e, t) {
1491
1814
  }
1492
1815
  return !1;
1493
1816
  }
1494
- function Hn(e, t, n) {
1817
+ function mr(e, t, n) {
1495
1818
  let r = document.querySelector(`style[data-tiptap-style${n ? `-${n}` : ""}]`);
1496
1819
  if (r !== null) return r;
1497
1820
  let i = document.createElement("style");
1498
1821
  return t && i.setAttribute("nonce", t), i.setAttribute(`data-tiptap-style${n ? `-${n}` : ""}`, ""), i.innerHTML = e, document.getElementsByTagName("head")[0].appendChild(i), i;
1499
1822
  }
1500
- function Un(e) {
1823
+ function hr(e) {
1501
1824
  return e.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
1502
1825
  }
1503
- function Wn(e, t) {
1826
+ function gr(e, t) {
1504
1827
  let n = e.getAttribute("style");
1505
1828
  if (!n) return null;
1506
1829
  let r = n.split(";").map((e) => e.trim()).filter(Boolean), i = t.toLowerCase();
@@ -1510,28 +1833,28 @@ function Wn(e, t) {
1510
1833
  }
1511
1834
  return null;
1512
1835
  }
1513
- function Gn() {
1836
+ function _r() {
1514
1837
  return typeof navigator < "u" && /Firefox/.test(navigator.userAgent);
1515
1838
  }
1516
- function Kn(e) {
1839
+ function vr(e) {
1517
1840
  return typeof e == "number";
1518
1841
  }
1519
- function qn(e) {
1842
+ function yr(e) {
1520
1843
  return Object.prototype.toString.call(e).slice(8, -1);
1521
1844
  }
1522
- function Y(e) {
1523
- return qn(e) === "Object" && e.constructor === Object && Object.getPrototypeOf(e) === Object.prototype;
1524
- }
1525
- _e({}, {
1526
- createAtomBlockMarkdownSpec: () => Xn,
1527
- createBlockMarkdownSpec: () => Zn,
1528
- createInlineMarkdownSpec: () => er,
1529
- parseAttributes: () => Jn,
1530
- parseIndentedBlocks: () => tr,
1531
- renderNestedMarkdownContent: () => nr,
1532
- serializeAttributes: () => Yn
1845
+ function X(e) {
1846
+ return yr(e) === "Object" && e.constructor === Object && Object.getPrototypeOf(e) === Object.prototype;
1847
+ }
1848
+ ve({}, {
1849
+ createAtomBlockMarkdownSpec: () => Sr,
1850
+ createBlockMarkdownSpec: () => Cr,
1851
+ createInlineMarkdownSpec: () => Er,
1852
+ parseAttributes: () => br,
1853
+ parseIndentedBlocks: () => Dr,
1854
+ renderNestedMarkdownContent: () => Or,
1855
+ serializeAttributes: () => xr
1533
1856
  });
1534
- function Jn(e) {
1857
+ function br(e) {
1535
1858
  if (!e?.trim()) return {};
1536
1859
  let t = {}, n = [], r = e.replace(/["']([^"']*)["']/g, (e) => (n.push(e), `__QUOTED_${n.length - 1}__`)), i = r.match(/(?:^|\s)\.([\w-]+)/g);
1537
1860
  i && (t.class = i.map((e) => e.trim().slice(1)).join(" "));
@@ -1545,15 +1868,15 @@ function Jn(e) {
1545
1868
  e.match(/^[a-zA-Z][\w-]*$/) && (t[e] = !0);
1546
1869
  }), t;
1547
1870
  }
1548
- function Yn(e) {
1871
+ function xr(e) {
1549
1872
  if (!e || Object.keys(e).length === 0) return "";
1550
1873
  let t = [];
1551
1874
  return e.class && String(e.class).split(/\s+/).filter(Boolean).forEach((e) => t.push(`.${e}`)), e.id && t.push(`#${e.id}`), Object.entries(e).forEach(([e, n]) => {
1552
1875
  e !== "class" && e !== "id" && (n === !0 ? t.push(e) : n !== !1 && n != null && t.push(`${e}="${String(n)}"`));
1553
1876
  }), t.join(" ");
1554
1877
  }
1555
- function Xn(e) {
1556
- let { nodeName: t, name: n, parseAttributes: r = Jn, serializeAttributes: i = Yn, defaultAttributes: a = {}, requiredAttributes: o = [], allowedAttributes: s } = e, c = n || t, l = (e) => {
1878
+ function Sr(e) {
1879
+ let { nodeName: t, name: n, parseAttributes: r = br, serializeAttributes: i = xr, defaultAttributes: a = {}, requiredAttributes: o = [], allowedAttributes: s } = e, c = n || t, l = (e) => {
1557
1880
  if (!s) return e;
1558
1881
  let t = {};
1559
1882
  return s.forEach((n) => {
@@ -1592,8 +1915,8 @@ function Xn(e) {
1592
1915
  }
1593
1916
  };
1594
1917
  }
1595
- function Zn(e) {
1596
- let { nodeName: t, name: n, getContent: r, parseAttributes: i = Jn, serializeAttributes: a = Yn, defaultAttributes: o = {}, content: s = "block", allowedAttributes: c } = e, l = n || t, u = (e) => {
1918
+ function Cr(e) {
1919
+ let { nodeName: t, name: n, getContent: r, parseAttributes: i = br, serializeAttributes: a = xr, defaultAttributes: o = {}, content: s = "block", allowedAttributes: c } = e, l = n || t, u = (e) => {
1597
1920
  if (!c) return e;
1598
1921
  let t = {};
1599
1922
  return c.forEach((n) => {
@@ -1669,7 +1992,7 @@ ${o}
1669
1992
  }
1670
1993
  };
1671
1994
  }
1672
- function Qn(e) {
1995
+ function wr(e) {
1673
1996
  if (!e.trim()) return {};
1674
1997
  let t = {}, n = /(\w+)=(?:"([^"]*)"|'([^']*)')/g, r = n.exec(e);
1675
1998
  for (; r !== null;) {
@@ -1678,11 +2001,11 @@ function Qn(e) {
1678
2001
  }
1679
2002
  return t;
1680
2003
  }
1681
- function $n(e) {
2004
+ function Tr(e) {
1682
2005
  return Object.entries(e).filter(([, e]) => e != null).map(([e, t]) => `${e}="${t}"`).join(" ");
1683
2006
  }
1684
- function er(e) {
1685
- let { nodeName: t, name: n, getContent: r, parseAttributes: i = Qn, serializeAttributes: a = $n, defaultAttributes: o = {}, selfClosing: s = !1, allowedAttributes: c } = e, l = n || t, u = (e) => {
2007
+ function Er(e) {
2008
+ let { nodeName: t, name: n, getContent: r, parseAttributes: i = wr, serializeAttributes: a = Tr, defaultAttributes: o = {}, selfClosing: s = !1, allowedAttributes: c } = e, l = n || t, u = (e) => {
1686
2009
  if (!c) return e;
1687
2010
  let t = {};
1688
2011
  return c.forEach((n) => {
@@ -1739,7 +2062,7 @@ function er(e) {
1739
2062
  }
1740
2063
  };
1741
2064
  }
1742
- function tr(e, t, n) {
2065
+ function Dr(e, t, n) {
1743
2066
  let r = e.split("\n"), i = [], a = "", o = 0, s = t.baseIndentSize || 2;
1744
2067
  for (; o < r.length;) {
1745
2068
  let e = r[o], c = e.match(t.itemPattern);
@@ -1785,7 +2108,7 @@ function tr(e, t, n) {
1785
2108
  raw: a
1786
2109
  };
1787
2110
  }
1788
- function nr(e, t, n, r) {
2111
+ function Or(e, t, n, r) {
1789
2112
  if (!e || !Array.isArray(e.content)) return "";
1790
2113
  let i = typeof n == "function" ? n(r) : n, [a, ...o] = e.content, s = `${i}${t.renderChildren([a])}`;
1791
2114
  return o && o.length > 0 && o.forEach((e, n) => {
@@ -1799,13 +2122,13 @@ ${n}`;
1799
2122
  }
1800
2123
  }), s;
1801
2124
  }
1802
- function rr(e, t) {
2125
+ function kr(e, t) {
1803
2126
  let n = { ...e };
1804
- return Y(e) && Y(t) && Object.keys(t).forEach((r) => {
1805
- Y(t[r]) && Y(e[r]) ? n[r] = rr(e[r], t[r]) : n[r] = t[r];
2127
+ return X(e) && X(t) && Object.keys(t).forEach((r) => {
2128
+ X(t[r]) && X(e[r]) ? n[r] = kr(e[r], t[r]) : n[r] = t[r];
1806
2129
  }), n;
1807
2130
  }
1808
- function ir(e, t, n = {}) {
2131
+ function Ar(e, t, n = {}) {
1809
2132
  let { state: r } = t, { doc: i, tr: a } = r, o = e;
1810
2133
  i.descendants((t, r) => {
1811
2134
  let i = a.mapping.map(r), s = a.mapping.map(r) + t.nodeSize, c = null;
@@ -1825,39 +2148,39 @@ function ir(e, t, n = {}) {
1825
2148
  }
1826
2149
  }), a.docChanged && t.view.dispatch(a);
1827
2150
  }
1828
- var X = class {
2151
+ var Z = class {
1829
2152
  constructor(e) {
1830
2153
  this.find = e.find, this.handler = e.handler, this.undoable = e.undoable ?? !0;
1831
2154
  }
1832
- }, ar = (e, t) => {
1833
- if (Pe(t)) return t.exec(e);
2155
+ }, jr = (e, t) => {
2156
+ if (Fe(t)) return t.exec(e);
1834
2157
  let n = t(e);
1835
2158
  if (!n) return null;
1836
2159
  let r = [n.text];
1837
2160
  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;
1838
2161
  };
1839
- function Z(e) {
2162
+ function Q(e) {
1840
2163
  let { editor: t, from: n, to: r, text: i, rules: a, plugin: o } = e, { view: s } = t;
1841
2164
  if (s.composing) return !1;
1842
2165
  let c = s.state.doc.resolve(n);
1843
2166
  if (c.parent.type.spec.code || (c.nodeBefore || c.nodeAfter)?.marks.find((e) => e.type.spec.code)) return !1;
1844
- let l = !1, u = en(c) + i;
2167
+ let l = !1, u = rn(c) + i;
1845
2168
  return a.forEach((e) => {
1846
2169
  if (l) return;
1847
- let a = ar(u, e.find);
2170
+ let a = jr(u, e.find);
1848
2171
  if (!a) return;
1849
2172
  let d = a[0].length - i.length;
1850
2173
  if (d > 0) {
1851
2174
  let e = c.parentOffset - d;
1852
2175
  if (e < 0 || c.parent.textBetween(e, c.parentOffset) !== a[0].slice(0, d)) return;
1853
2176
  }
1854
- let f = s.state.tr, p = k({
2177
+ let f = s.state.tr, p = O({
1855
2178
  state: s.state,
1856
2179
  transaction: f
1857
2180
  }), m = {
1858
2181
  from: n - (a[0].length - i.length),
1859
2182
  to: r
1860
- }, { commands: h, chain: g, can: ee } = new A({
2183
+ }, { commands: h, chain: g, can: ee } = new k({
1861
2184
  editor: t,
1862
2185
  state: p
1863
2186
  });
@@ -1876,8 +2199,8 @@ function Z(e) {
1876
2199
  }), s.dispatch(f), l = !0);
1877
2200
  }), l;
1878
2201
  }
1879
- function or(e) {
1880
- let { editor: t, rules: n } = e, r = new w({
2202
+ function Mr(e) {
2203
+ let { editor: t, rules: n } = e, r = new S({
1881
2204
  state: {
1882
2205
  init() {
1883
2206
  return null;
@@ -1888,9 +2211,9 @@ function or(e) {
1888
2211
  let s = e.getMeta("applyInputRules");
1889
2212
  return s && setTimeout(() => {
1890
2213
  let { text: e } = s;
1891
- e = typeof e == "string" ? e : At(O.from(e), a.schema);
2214
+ e = typeof e == "string" ? e : Mt(E.from(e), a.schema);
1892
2215
  let { from: i } = s, o = i + e.length;
1893
- Z({
2216
+ Q({
1894
2217
  editor: t,
1895
2218
  from: i,
1896
2219
  to: o,
@@ -1903,7 +2226,7 @@ function or(e) {
1903
2226
  },
1904
2227
  props: {
1905
2228
  handleTextInput(e, i, a, o) {
1906
- return Z({
2229
+ return Q({
1907
2230
  editor: t,
1908
2231
  from: i,
1909
2232
  to: a,
@@ -1914,7 +2237,7 @@ function or(e) {
1914
2237
  },
1915
2238
  handleDOMEvents: { compositionend: (e) => (setTimeout(() => {
1916
2239
  let { $cursor: i } = e.state.selection;
1917
- i && Z({
2240
+ i && Q({
1918
2241
  editor: t,
1919
2242
  from: i.pos,
1920
2243
  to: i.pos,
@@ -1926,7 +2249,7 @@ function or(e) {
1926
2249
  handleKeyDown(e, i) {
1927
2250
  if (i.key !== "Enter") return !1;
1928
2251
  let { $cursor: a } = e.state.selection;
1929
- return a ? Z({
2252
+ return a ? Q({
1930
2253
  editor: t,
1931
2254
  from: a.pos,
1932
2255
  to: a.pos,
@@ -1940,7 +2263,7 @@ function or(e) {
1940
2263
  });
1941
2264
  return r;
1942
2265
  }
1943
- var sr = class {
2266
+ var Nr = class {
1944
2267
  constructor(e = {}) {
1945
2268
  this.type = "extendable", this.parent = null, this.child = null, this.name = "", this.config = { name: this.name }, this.config = {
1946
2269
  ...this.config,
@@ -1948,10 +2271,10 @@ var sr = class {
1948
2271
  }, this.name = this.config.name;
1949
2272
  }
1950
2273
  get options() {
1951
- return { ...H(V(this, "addOptions", { name: this.name })) };
2274
+ return { ...V(B(this, "addOptions", { name: this.name })) };
1952
2275
  }
1953
2276
  get storage() {
1954
- return { ...H(V(this, "addStorage", {
2277
+ return { ...V(B(this, "addStorage", {
1955
2278
  name: this.name,
1956
2279
  options: this.options
1957
2280
  })) };
@@ -1959,7 +2282,7 @@ var sr = class {
1959
2282
  configure(e = {}) {
1960
2283
  let t = this.extend({
1961
2284
  ...this.config,
1962
- addOptions: () => rr(this.options, e)
2285
+ addOptions: () => kr(this.options, e)
1963
2286
  });
1964
2287
  return t.name = this.name, t.parent = this.parent, this.child = null, t;
1965
2288
  }
@@ -1970,7 +2293,7 @@ var sr = class {
1970
2293
  });
1971
2294
  return t.parent = this, this.child = t, t.name = "name" in e ? e.name : t.parent.name, t;
1972
2295
  }
1973
- }, cr = class e extends sr {
2296
+ }, Pr = class e extends Nr {
1974
2297
  constructor() {
1975
2298
  super(...arguments), this.type = "mark";
1976
2299
  }
@@ -1995,27 +2318,27 @@ var sr = class {
1995
2318
  let t = typeof e == "function" ? e() : e;
1996
2319
  return super.extend(t);
1997
2320
  }
1998
- }, lr = class {
2321
+ }, Fr = class {
1999
2322
  constructor(e) {
2000
2323
  this.find = e.find, this.handler = e.handler;
2001
2324
  }
2002
- }, ur = (e, t, n) => {
2003
- if (Pe(t)) return [...e.matchAll(t)];
2325
+ }, Ir = (e, t, n) => {
2326
+ if (Fe(t)) return [...e.matchAll(t)];
2004
2327
  let r = t(e, n);
2005
2328
  return r ? r.map((t) => {
2006
2329
  let n = [t.text];
2007
2330
  return n.index = t.index, n.input = e, n.data = t.data, t.replaceWith && (t.text.includes(t.replaceWith) || console.warn("[tiptap warn]: \"pasteRuleMatch.replaceWith\" must be part of \"pasteRuleMatch.text\"."), n.push(t.replaceWith)), n;
2008
2331
  }) : [];
2009
2332
  };
2010
- function dr(e) {
2011
- let { editor: t, state: n, from: r, to: i, rule: a, pasteEvent: o, dropEvent: s } = e, { commands: c, chain: l, can: u } = new A({
2333
+ function Lr(e) {
2334
+ let { editor: t, state: n, from: r, to: i, rule: a, pasteEvent: o, dropEvent: s } = e, { commands: c, chain: l, can: u } = new k({
2012
2335
  editor: t,
2013
2336
  state: n
2014
2337
  }), d = [];
2015
2338
  return n.doc.nodesBetween(r, i, (e, t) => {
2016
2339
  if (e.type?.spec?.code || !(e.isText || e.isTextblock || e.isInline)) return;
2017
2340
  let f = e.content?.size ?? e.nodeSize ?? 0, p = Math.max(r, t), m = Math.min(i, t + f);
2018
- p >= m || ur(e.isText ? e.text || "" : e.textBetween(p - t, m - t, void 0, ""), a.find, o).forEach((e) => {
2341
+ p >= m || Ir(e.isText ? e.text || "" : e.textBetween(p - t, m - t, void 0, ""), a.find, o).forEach((e) => {
2019
2342
  if (e.index === void 0) return;
2020
2343
  let t = p + e.index + 1, r = t + e[0].length, i = {
2021
2344
  from: n.tr.mapping.map(t),
@@ -2034,12 +2357,12 @@ function dr(e) {
2034
2357
  });
2035
2358
  }), d.every((e) => e !== null);
2036
2359
  }
2037
- var fr = null, pr = (e) => {
2360
+ var Rr = null, zr = (e) => {
2038
2361
  var t;
2039
2362
  let n = new ClipboardEvent("paste", { clipboardData: new DataTransfer() });
2040
2363
  return (t = n.clipboardData) == null || t.setData("text/html", e), n;
2041
2364
  };
2042
- function mr(e) {
2365
+ function Br(e) {
2043
2366
  let { editor: t, rules: n } = e, r = null, i = !1, a = !1, o = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, s;
2044
2367
  try {
2045
2368
  s = typeof DragEvent < "u" ? new DragEvent("drop") : null;
@@ -2047,11 +2370,11 @@ function mr(e) {
2047
2370
  s = null;
2048
2371
  }
2049
2372
  let c = ({ state: e, from: n, to: r, rule: i, pasteEvt: a }) => {
2050
- let c = e.tr, l = k({
2373
+ let c = e.tr, l = O({
2051
2374
  state: e,
2052
2375
  transaction: c
2053
2376
  });
2054
- if (!(!dr({
2377
+ if (!(!Lr({
2055
2378
  editor: t,
2056
2379
  state: l,
2057
2380
  from: Math.max(n - 1, 0),
@@ -2068,12 +2391,12 @@ function mr(e) {
2068
2391
  return o = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, c;
2069
2392
  }
2070
2393
  };
2071
- return n.map((e) => new w({
2394
+ return n.map((e) => new S({
2072
2395
  view(e) {
2073
2396
  let n = (n) => {
2074
- r = e.dom.parentElement?.contains(n.target) ? e.dom.parentElement : null, r && (fr = t);
2397
+ r = e.dom.parentElement?.contains(n.target) ? e.dom.parentElement : null, r && (Rr = t);
2075
2398
  }, i = () => {
2076
- fr &&= null;
2399
+ Rr &&= null;
2077
2400
  };
2078
2401
  return window.addEventListener("dragstart", n), window.addEventListener("dragend", i), { destroy() {
2079
2402
  window.removeEventListener("dragstart", n), window.removeEventListener("dragend", i);
@@ -2082,7 +2405,7 @@ function mr(e) {
2082
2405
  props: { handleDOMEvents: {
2083
2406
  drop: (e, t) => {
2084
2407
  if (a = r === e.dom.parentElement, s = t, !a) {
2085
- let e = fr;
2408
+ let e = Rr;
2086
2409
  e?.isEditable && setTimeout(() => {
2087
2410
  let t = e.state.selection;
2088
2411
  t && e.commands.deleteRange({
@@ -2103,8 +2426,8 @@ function mr(e) {
2103
2426
  if (!l && !u && !f) return;
2104
2427
  if (f) {
2105
2428
  let { text: t } = d;
2106
- t = typeof t == "string" ? t : At(O.from(t), r.schema);
2107
- let { from: n } = d, i = n + t.length, a = pr(t);
2429
+ t = typeof t == "string" ? t : Mt(E.from(t), r.schema);
2430
+ let { from: n } = d, i = n + t.length, a = zr(t);
2108
2431
  return c({
2109
2432
  rule: e,
2110
2433
  state: r,
@@ -2114,7 +2437,7 @@ function mr(e) {
2114
2437
  });
2115
2438
  }
2116
2439
  let p = n.doc.content.findDiffStart(r.doc.content), m = n.doc.content.findDiffEnd(r.doc.content);
2117
- if (!(!Kn(p) || !m || p === m.b)) return c({
2440
+ if (!(!vr(p) || !m || p === m.b)) return c({
2118
2441
  rule: e,
2119
2442
  state: r,
2120
2443
  from: p,
@@ -2124,18 +2447,18 @@ function mr(e) {
2124
2447
  }
2125
2448
  }));
2126
2449
  }
2127
- var Q = class {
2450
+ var Vr = class {
2128
2451
  constructor(e, t) {
2129
- this.splittableMarks = [], this.nonClearableMarks = [], this.editor = t, this.baseExtensions = e, this.extensions = Ut(e), this.schema = Vt(this.extensions, t), this.setupExtensions();
2452
+ this.splittableMarks = [], this.nonClearableMarks = [], this.decorationManager = null, this.editor = t, this.baseExtensions = e, this.extensions = Gt(e), this.schema = Ut(this.extensions, t), this.setupExtensions();
2130
2453
  }
2131
2454
  get commands() {
2132
2455
  return this.extensions.reduce((e, t) => {
2133
- let n = V(t, "addCommands", {
2456
+ let n = B(t, "addCommands", {
2134
2457
  name: t.name,
2135
2458
  options: t.options,
2136
2459
  storage: this.editor.extensionStorage[t.name],
2137
2460
  editor: this.editor,
2138
- type: K(t.name, this.schema)
2461
+ type: G(t.name, this.schema)
2139
2462
  });
2140
2463
  return n ? {
2141
2464
  ...e,
@@ -2144,16 +2467,15 @@ var Q = class {
2144
2467
  }, {});
2145
2468
  }
2146
2469
  get plugins() {
2147
- let { editor: e } = this;
2148
- return G([...this.extensions].reverse()).flatMap((t) => {
2470
+ let { editor: e } = this, t = W([...this.extensions].reverse()).flatMap((t) => {
2149
2471
  let n = {
2150
2472
  name: t.name,
2151
2473
  options: t.options,
2152
2474
  storage: this.editor.extensionStorage[t.name],
2153
2475
  editor: e,
2154
- type: K(t.name, this.schema)
2155
- }, r = [], i = V(t, "addKeyboardShortcuts", n), a = {};
2156
- if (t.type === "mark" && V(t, "exitable", n) && (a.ArrowRight = () => cr.handleExit({
2476
+ type: G(t.name, this.schema)
2477
+ }, r = [], i = B(t, "addKeyboardShortcuts", n), a = {};
2478
+ if (t.type === "mark" && B(t, "exitable", n) && (a.ArrowRight = () => Pr.handleExit({
2157
2479
  editor: e,
2158
2480
  mark: t
2159
2481
  })), i) {
@@ -2163,55 +2485,78 @@ var Q = class {
2163
2485
  ...t
2164
2486
  };
2165
2487
  }
2166
- let o = he(a);
2488
+ let o = ge(a);
2167
2489
  r.push(o);
2168
- let s = V(t, "addInputRules", n);
2169
- if (on(t, e.options.enableInputRules) && s) {
2490
+ let s = B(t, "addInputRules", n);
2491
+ if (ln(t, e.options.enableInputRules) && s) {
2170
2492
  let t = s();
2171
2493
  if (t && t.length) {
2172
- let n = or({
2494
+ let n = Mr({
2173
2495
  editor: e,
2174
2496
  rules: t
2175
2497
  }), i = Array.isArray(n) ? n : [n];
2176
2498
  r.push(...i);
2177
2499
  }
2178
2500
  }
2179
- let c = V(t, "addPasteRules", n);
2180
- if (on(t, e.options.enablePasteRules) && c) {
2501
+ let c = B(t, "addPasteRules", n);
2502
+ if (ln(t, e.options.enablePasteRules) && c) {
2181
2503
  let t = c();
2182
2504
  if (t && t.length) {
2183
- let n = mr({
2505
+ let n = Br({
2184
2506
  editor: e,
2185
2507
  rules: t
2186
2508
  });
2187
2509
  r.push(...n);
2188
2510
  }
2189
2511
  }
2190
- let l = V(t, "addProseMirrorPlugins", n);
2512
+ let l = B(t, "addProseMirrorPlugins", n);
2191
2513
  if (l) {
2192
2514
  let e = l();
2193
2515
  r.push(...e);
2194
2516
  }
2195
2517
  return r;
2196
- });
2518
+ }), n = this.createDecorationPlugin();
2519
+ return n && t.push(n), t;
2520
+ }
2521
+ createDecorationPlugin() {
2522
+ var e;
2523
+ let { editor: t } = this;
2524
+ (e = this.decorationManager) == null || e.destroy();
2525
+ let n = [];
2526
+ return this.extensions.forEach((e) => {
2527
+ let r = B(e, "addDecorations", {
2528
+ name: e.name,
2529
+ options: e.options,
2530
+ storage: this.editor.extensionStorage[e.name],
2531
+ editor: t,
2532
+ type: G(e.name, this.schema)
2533
+ });
2534
+ r && n.push({
2535
+ name: e.name,
2536
+ addDecorations: r
2537
+ });
2538
+ }), this.decorationManager = new fr({
2539
+ editor: t,
2540
+ entries: n
2541
+ }), this.decorationManager.plugin;
2197
2542
  }
2198
2543
  get attributes() {
2199
- return Nt(this.extensions);
2544
+ return Ft(this.extensions);
2200
2545
  }
2201
2546
  get nodeViews() {
2202
- let { editor: e } = this, { nodeExtensions: t } = U(this.extensions);
2203
- return Object.fromEntries(t.filter((e) => !!V(e, "addNodeView")).map((t) => {
2204
- let n = this.attributes.filter((e) => e.type === t.name), r = V(t, "addNodeView", {
2547
+ let { editor: e } = this, { nodeExtensions: t } = H(this.extensions);
2548
+ return Object.fromEntries(t.filter((e) => !!B(e, "addNodeView")).map((t) => {
2549
+ let n = this.attributes.filter((e) => e.type === t.name), r = B(t, "addNodeView", {
2205
2550
  name: t.name,
2206
2551
  options: t.options,
2207
2552
  storage: this.editor.extensionStorage[t.name],
2208
2553
  editor: e,
2209
- type: j(t.name, this.schema)
2554
+ type: A(t.name, this.schema)
2210
2555
  });
2211
2556
  if (!r) return [];
2212
2557
  let i = r();
2213
2558
  return i ? [t.name, (r, a, o, s, c) => {
2214
- let l = W(r, n);
2559
+ let l = U(r, n);
2215
2560
  return i({
2216
2561
  node: r,
2217
2562
  view: a,
@@ -2227,14 +2572,14 @@ var Q = class {
2227
2572
  }
2228
2573
  dispatchTransaction(e) {
2229
2574
  let { editor: t } = this;
2230
- return G([...this.extensions].reverse()).reduceRight((e, n) => {
2575
+ return W([...this.extensions].reverse()).reduceRight((e, n) => {
2231
2576
  let r = {
2232
2577
  name: n.name,
2233
2578
  options: n.options,
2234
2579
  storage: this.editor.extensionStorage[n.name],
2235
2580
  editor: t,
2236
- type: K(n.name, this.schema)
2237
- }, i = V(n, "dispatchTransaction", r);
2581
+ type: G(n.name, this.schema)
2582
+ }, i = B(n, "dispatchTransaction", r);
2238
2583
  return i ? (t) => {
2239
2584
  i.call(r, {
2240
2585
  transaction: t,
@@ -2245,14 +2590,14 @@ var Q = class {
2245
2590
  }
2246
2591
  transformPastedHTML(e) {
2247
2592
  let { editor: t } = this;
2248
- return G([...this.extensions]).reduce((e, n) => {
2593
+ return W([...this.extensions]).reduce((e, n) => {
2249
2594
  let r = {
2250
2595
  name: n.name,
2251
2596
  options: n.options,
2252
2597
  storage: this.editor.extensionStorage[n.name],
2253
2598
  editor: t,
2254
- type: K(n.name, this.schema)
2255
- }, i = V(n, "transformPastedHTML", r);
2599
+ type: G(n.name, this.schema)
2600
+ }, i = B(n, "transformPastedHTML", r);
2256
2601
  return i ? (t, n) => {
2257
2602
  let a = e(t, n);
2258
2603
  return i.call(r, a);
@@ -2260,17 +2605,17 @@ var Q = class {
2260
2605
  }, e || ((e) => e));
2261
2606
  }
2262
2607
  get markViews() {
2263
- let { editor: e } = this, { markExtensions: t } = U(this.extensions);
2264
- return Object.fromEntries(t.filter((e) => !!V(e, "addMarkView")).map((t) => {
2265
- let n = this.attributes.filter((e) => e.type === t.name), r = V(t, "addMarkView", {
2608
+ let { editor: e } = this, { markExtensions: t } = H(this.extensions);
2609
+ return Object.fromEntries(t.filter((e) => !!B(e, "addMarkView")).map((t) => {
2610
+ let n = this.attributes.filter((e) => e.type === t.name), r = B(t, "addMarkView", {
2266
2611
  name: t.name,
2267
2612
  options: t.options,
2268
2613
  storage: this.editor.extensionStorage[t.name],
2269
2614
  editor: e,
2270
- type: N(t.name, this.schema)
2615
+ type: M(t.name, this.schema)
2271
2616
  });
2272
2617
  return r ? [t.name, (i, a, o) => {
2273
- let s = W(i, n);
2618
+ let s = U(i, n);
2274
2619
  return r()({
2275
2620
  mark: i,
2276
2621
  view: a,
@@ -2279,20 +2624,21 @@ var Q = class {
2279
2624
  extension: t,
2280
2625
  HTMLAttributes: s,
2281
2626
  updateAttributes: (t) => {
2282
- ir(i, e, t);
2627
+ Ar(i, e, t);
2283
2628
  }
2284
2629
  });
2285
2630
  }] : [];
2286
2631
  }));
2287
2632
  }
2288
2633
  destroy() {
2289
- this.extensions.forEach((e) => {
2634
+ var e;
2635
+ (e = this.decorationManager) == null || e.destroy(), this.extensions.forEach((e) => {
2290
2636
  let t = e;
2291
2637
  for (; t.parent;) {
2292
2638
  let e = t.parent;
2293
2639
  e.child === t && (e.child = null), t = e;
2294
2640
  }
2295
- }), this.extensions = [], this.baseExtensions = [], this.schema = null, this.editor = null;
2641
+ }), this.extensions = [], this.baseExtensions = [], this.decorationManager = null, this.schema = null, this.editor = null;
2296
2642
  }
2297
2643
  setupExtensions() {
2298
2644
  let e = this.extensions;
@@ -2302,28 +2648,28 @@ var Q = class {
2302
2648
  options: e.options,
2303
2649
  storage: this.editor.extensionStorage[e.name],
2304
2650
  editor: this.editor,
2305
- type: K(e.name, this.schema)
2651
+ type: G(e.name, this.schema)
2306
2652
  };
2307
- e.type === "mark" && ((H(V(e, "keepOnSplit", t)) ?? !0) && this.splittableMarks.push(e.name), (H(V(e, "clearable", t)) ?? !0) || this.nonClearableMarks.push(e.name));
2308
- let n = V(e, "onBeforeCreate", t), r = V(e, "onCreate", t), i = V(e, "onUpdate", t), a = V(e, "onSelectionUpdate", t), o = V(e, "onTransaction", t), s = V(e, "onFocus", t), c = V(e, "onBlur", t), l = V(e, "onDestroy", t);
2653
+ e.type === "mark" && ((V(B(e, "keepOnSplit", t)) ?? !0) && this.splittableMarks.push(e.name), (V(B(e, "clearable", t)) ?? !0) || this.nonClearableMarks.push(e.name));
2654
+ let n = B(e, "onBeforeCreate", t), r = B(e, "onCreate", t), i = B(e, "onUpdate", t), a = B(e, "onSelectionUpdate", t), o = B(e, "onTransaction", t), s = B(e, "onFocus", t), c = B(e, "onBlur", t), l = B(e, "onDestroy", t);
2309
2655
  n && this.editor.on("beforeCreate", n), r && this.editor.on("create", r), i && this.editor.on("update", i), a && this.editor.on("selectionUpdate", a), o && this.editor.on("transaction", o), s && this.editor.on("focus", s), c && this.editor.on("blur", c), l && this.editor.on("destroy", l);
2310
2656
  });
2311
2657
  }
2312
2658
  };
2313
- Q.resolve = Ut, Q.sort = G, Q.flatten = kt, _e({}, {
2314
- ClipboardTextSerializer: () => hr,
2315
- Commands: () => gr,
2316
- Delete: () => _r,
2317
- Drop: () => vr,
2318
- Editable: () => yr,
2319
- FocusEvents: () => xr,
2320
- Keymap: () => Sr,
2321
- Paste: () => Cr,
2322
- Tabindex: () => wr,
2323
- TextDirection: () => Tr,
2324
- focusEventsPluginKey: () => br
2659
+ Vr.resolve = Gt, Vr.sort = W, Vr.flatten = jt, ve({}, {
2660
+ ClipboardTextSerializer: () => Hr,
2661
+ Commands: () => Ur,
2662
+ Delete: () => Wr,
2663
+ Drop: () => Gr,
2664
+ Editable: () => Kr,
2665
+ FocusEvents: () => Jr,
2666
+ Keymap: () => Yr,
2667
+ Paste: () => Xr,
2668
+ Tabindex: () => Zr,
2669
+ TextDirection: () => Qr,
2670
+ focusEventsPluginKey: () => qr
2325
2671
  });
2326
- var $ = class e extends sr {
2672
+ var $ = class e extends Nr {
2327
2673
  constructor() {
2328
2674
  super(...arguments), this.type = "extension";
2329
2675
  }
@@ -2338,39 +2684,39 @@ var $ = class e extends sr {
2338
2684
  let t = typeof e == "function" ? e() : e;
2339
2685
  return super.extend(t);
2340
2686
  }
2341
- }, hr = $.create({
2687
+ }, Hr = $.create({
2342
2688
  name: "clipboardTextSerializer",
2343
2689
  addOptions() {
2344
2690
  return { blockSeparator: void 0 };
2345
2691
  },
2346
2692
  addProseMirrorPlugins() {
2347
- return [new w({
2348
- key: new T("clipboardTextSerializer"),
2693
+ return [new S({
2694
+ key: new C("clipboardTextSerializer"),
2349
2695
  props: { clipboardTextSerializer: () => {
2350
- let { editor: e } = this, { state: t, schema: n } = e, { doc: r, selection: i } = t, a = Kt(n), { blockSeparator: o } = this.options, s = {
2696
+ let { editor: e } = this, { state: t, schema: n } = e, { doc: r, selection: i } = t, a = Jt(n), { blockSeparator: o } = this.options, s = {
2351
2697
  ...o === void 0 ? {} : { blockSeparator: o },
2352
2698
  textSerializers: a
2353
2699
  };
2354
- return [...i.ranges].sort((e, t) => e.$from.pos - t.$from.pos).map(({ $from: e, $to: t }) => Wt(r, {
2700
+ return [...i.ranges].sort((e, t) => e.$from.pos - t.$from.pos).map(({ $from: e, $to: t }) => Kt(r, {
2355
2701
  from: e.pos,
2356
2702
  to: t.pos
2357
2703
  }, s)).join(o ?? "\n\n");
2358
2704
  } }
2359
2705
  })];
2360
2706
  }
2361
- }), gr = $.create({
2707
+ }), Ur = $.create({
2362
2708
  name: "commands",
2363
2709
  addCommands() {
2364
- return { ...ve };
2710
+ return { ...ye };
2365
2711
  }
2366
- }), _r = $.create({
2712
+ }), Wr = $.create({
2367
2713
  name: "delete",
2368
2714
  onUpdate({ transaction: t, appendedTransactions: n }) {
2369
2715
  let r = () => {
2370
2716
  var r;
2371
2717
  if (((r = this.editor.options.coreExtensionOptions?.delete)?.filterTransaction)?.call(r, t) ?? t.getMeta("y-sync$")) return;
2372
- let i = Et(t.before, [t, ...n]);
2373
- Zt(i).forEach((e) => {
2718
+ let i = Ot(t.before, [t, ...n]);
2719
+ $t(i).forEach((e) => {
2374
2720
  i.mapping.mapResult(e.oldRange.from).deletedAfter && i.mapping.mapResult(e.oldRange.to).deletedBefore && i.before.nodesBetween(e.oldRange.from, e.oldRange.to, (n, r) => {
2375
2721
  let a = r + n.nodeSize - 2, o = e.oldRange.from <= r && a <= e.oldRange.to;
2376
2722
  this.editor.emit("delete", {
@@ -2416,11 +2762,11 @@ var $ = class e extends sr {
2416
2762
  };
2417
2763
  this.editor.options.coreExtensionOptions?.delete?.async ?? !0 ? setTimeout(r, 0) : r();
2418
2764
  }
2419
- }), vr = $.create({
2765
+ }), Gr = $.create({
2420
2766
  name: "drop",
2421
2767
  addProseMirrorPlugins() {
2422
- return [new w({
2423
- key: new T("tiptapDrop"),
2768
+ return [new S({
2769
+ key: new C("tiptapDrop"),
2424
2770
  props: { handleDrop: (e, t, n, r) => {
2425
2771
  this.editor.emit("drop", {
2426
2772
  editor: this.editor,
@@ -2431,20 +2777,20 @@ var $ = class e extends sr {
2431
2777
  } }
2432
2778
  })];
2433
2779
  }
2434
- }), yr = $.create({
2780
+ }), Kr = $.create({
2435
2781
  name: "editable",
2436
2782
  addProseMirrorPlugins() {
2437
- return [new w({
2438
- key: new T("editable"),
2783
+ return [new S({
2784
+ key: new C("editable"),
2439
2785
  props: { editable: () => this.editor.options.editable }
2440
2786
  })];
2441
2787
  }
2442
- }), br = new T("focusEvents"), xr = $.create({
2788
+ }), qr = new C("focusEvents"), Jr = $.create({
2443
2789
  name: "focusEvents",
2444
2790
  addProseMirrorPlugins() {
2445
2791
  let { editor: e } = this;
2446
- return [new w({
2447
- key: br,
2792
+ return [new S({
2793
+ key: qr,
2448
2794
  props: { handleDOMEvents: {
2449
2795
  focus: (t, n) => {
2450
2796
  e.isFocused = !0;
@@ -2459,13 +2805,13 @@ var $ = class e extends sr {
2459
2805
  } }
2460
2806
  })];
2461
2807
  }
2462
- }), Sr = $.create({
2808
+ }), Yr = $.create({
2463
2809
  name: "keymap",
2464
2810
  addKeyboardShortcuts() {
2465
2811
  let e = () => this.editor.commands.first(({ commands: e }) => [
2466
2812
  () => e.undoInputRule(),
2467
2813
  () => e.command(({ tr: t }) => {
2468
- let { selection: n, doc: r } = t, { empty: i, $anchor: a } = n, { pos: o, parent: s } = a, c = a.parent.isTextblock && o > 0 ? t.doc.resolve(o - 1) : a, l = c.parent.type.spec.isolating, u = a.pos - a.parentOffset, d = l && c.parent.childCount === 1 ? u === a.pos : E.atStart(r).from === o;
2814
+ let { selection: n, doc: r } = t, { empty: i, $anchor: a } = n, { pos: o, parent: s } = a, c = a.parent.isTextblock && o > 0 ? t.doc.resolve(o - 1) : a, l = c.parent.type.spec.isolating, u = a.pos - a.parentOffset, d = l && c.parent.childCount === 1 ? u === a.pos : w.atStart(r).from === o;
2469
2815
  return !i || !s.type.isTextblock || s.textContent.length || !d || d && a.parent.type.name === "paragraph" ? !1 : e.clearNodes();
2470
2816
  }),
2471
2817
  () => e.deleteSelection(),
@@ -2501,21 +2847,21 @@ var $ = class e extends sr {
2501
2847
  "Ctrl-a": () => this.editor.commands.selectTextblockStart(),
2502
2848
  "Ctrl-e": () => this.editor.commands.selectTextblockEnd()
2503
2849
  };
2504
- return F() || st() ? i : r;
2850
+ return P() || lt() ? i : r;
2505
2851
  },
2506
2852
  addProseMirrorPlugins() {
2507
- return [new w({
2508
- key: new T("clearDocument"),
2853
+ return [new S({
2854
+ key: new C("clearDocument"),
2509
2855
  appendTransaction: (e, t, n) => {
2510
2856
  if (e.some((e) => e.getMeta("composition"))) return;
2511
2857
  let r = e.some((e) => e.docChanged) && !t.doc.eq(n.doc), i = e.some((e) => e.getMeta("preventClearDocument"));
2512
2858
  if (!r || i) return;
2513
- let { empty: a, from: o, to: s } = t.selection, c = E.atStart(t.doc).from, l = E.atEnd(t.doc).to;
2514
- if (a || o !== c || s !== l || !J(n.doc)) return;
2515
- let u = n.tr, d = k({
2859
+ let { empty: a, from: o, to: s } = t.selection, c = w.atStart(t.doc).from, l = w.atEnd(t.doc).to;
2860
+ if (a || o !== c || s !== l || !q(n.doc)) return;
2861
+ let u = n.tr, d = O({
2516
2862
  state: n,
2517
2863
  transaction: u
2518
- }), { commands: f } = new A({
2864
+ }), { commands: f } = new k({
2519
2865
  editor: this.editor,
2520
2866
  state: d
2521
2867
  });
@@ -2523,11 +2869,11 @@ var $ = class e extends sr {
2523
2869
  }
2524
2870
  })];
2525
2871
  }
2526
- }), Cr = $.create({
2872
+ }), Xr = $.create({
2527
2873
  name: "paste",
2528
2874
  addProseMirrorPlugins() {
2529
- return [new w({
2530
- key: new T("tiptapPaste"),
2875
+ return [new S({
2876
+ key: new C("tiptapPaste"),
2531
2877
  props: { handlePaste: (e, t, n) => {
2532
2878
  this.editor.emit("paste", {
2533
2879
  editor: this.editor,
@@ -2537,25 +2883,25 @@ var $ = class e extends sr {
2537
2883
  } }
2538
2884
  })];
2539
2885
  }
2540
- }), wr = $.create({
2886
+ }), Zr = $.create({
2541
2887
  name: "tabindex",
2542
2888
  addOptions() {
2543
2889
  return { value: void 0 };
2544
2890
  },
2545
2891
  addProseMirrorPlugins() {
2546
- return [new w({
2547
- key: new T("tabindex"),
2892
+ return [new S({
2893
+ key: new C("tabindex"),
2548
2894
  props: { attributes: () => !this.editor.isEditable && this.options.value === void 0 ? {} : { tabindex: this.options.value ?? "0" } }
2549
2895
  })];
2550
2896
  }
2551
- }), Tr = $.create({
2897
+ }), Qr = $.create({
2552
2898
  name: "textDirection",
2553
2899
  addOptions() {
2554
2900
  return { direction: void 0 };
2555
2901
  },
2556
2902
  addGlobalAttributes() {
2557
2903
  if (!this.options.direction) return [];
2558
- let { nodeExtensions: e } = U(this.extensions);
2904
+ let { nodeExtensions: e } = H(this.extensions);
2559
2905
  return [{
2560
2906
  types: e.filter((e) => e.name !== "text").map((e) => e.name),
2561
2907
  attributes: { dir: {
@@ -2569,15 +2915,30 @@ var $ = class e extends sr {
2569
2915
  }];
2570
2916
  },
2571
2917
  addProseMirrorPlugins() {
2572
- return [new w({
2573
- key: new T("textDirection"),
2918
+ return [new S({
2919
+ key: new C("textDirection"),
2574
2920
  props: { attributes: () => {
2575
2921
  let e = this.options.direction;
2576
2922
  return e ? { dir: e } : {};
2577
2923
  } }
2578
2924
  })];
2579
2925
  }
2580
- }), Er = class e {
2926
+ }), $r = !1;
2927
+ function ei(e) {
2928
+ if ($r) return;
2929
+ $r = !0;
2930
+ let t;
2931
+ try {
2932
+ t = n.fromJSON(e, {
2933
+ from: 0,
2934
+ to: 0
2935
+ }).slice.content;
2936
+ } catch {
2937
+ return;
2938
+ }
2939
+ t instanceof E || console.warn("[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.");
2940
+ }
2941
+ var ti = class e {
2581
2942
  constructor(e, t, n = !1, r = null) {
2582
2943
  this.currentNode = null, this.actualDepth = null, this.isBlock = n, this.resolvedPos = e, this.editor = t, this.currentNode = r;
2583
2944
  }
@@ -2699,9 +3060,9 @@ var $ = class e extends sr {
2699
3060
  ...e
2700
3061
  }), this.editor.view.dispatch(t);
2701
3062
  }
2702
- }, Dr = ".ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: \"liga\" 0; /* the above doesn't seem to work in Edge */\n}\n\n.ProseMirror [contenteditable=\"false\"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable=\"false\"] [contenteditable=\"true\"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 0 !important;\n height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: \"\";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}", Or = class extends Bn {
3063
+ }, ni = ".ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: \"liga\" 0; /* the above doesn't seem to work in Edge */\n}\n\n.ProseMirror [contenteditable=\"false\"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable=\"false\"] [contenteditable=\"true\"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 0 !important;\n height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: \"\";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}", ri = class extends Kn {
2703
3064
  constructor(e = {}) {
2704
- super(), this.css = null, this.className = "tiptap", this.editorView = null, this.isFocused = !1, this.destroyed = !1, this.isInitialized = !1, this.extensionStorage = {}, this.instanceId = Math.random().toString(36).slice(2, 9), this.options = {
3065
+ super(), this.css = null, this.className = "tiptap", this.editorView = null, this.isFocused = !1, this.destroyed = !1, this.isInitialized = !1, this.extensionStorage = {}, this.instanceId = Math.random().toString(36).slice(2, 9), this.hasWarnedStaleDecorationRead = !1, this.options = {
2705
3066
  element: typeof document < "u" ? document.createElement("div") : null,
2706
3067
  content: "",
2707
3068
  injectCSS: !0,
@@ -2736,19 +3097,19 @@ var $ = class e extends sr {
2736
3097
  onDelete: () => null,
2737
3098
  enableExtensionDispatchTransaction: !0
2738
3099
  }, this.isCapturingTransaction = !1, this.capturedTransaction = null, this.utils = {
2739
- getUpdatedPosition: un,
2740
- createMappablePosition: dn
3100
+ getUpdatedPosition: pn,
3101
+ createMappablePosition: mn
2741
3102
  }, this.setOptions(e), 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: e, slice: t, moved: n }) => this.options.onDrop(e, t, n)), this.on("paste", ({ event: e, slice: t }) => this.options.onPaste(e, t)), this.on("delete", this.options.onDelete);
2742
3103
  let t = this.createDoc();
2743
3104
  if (!this.editorState) {
2744
- let e = Ve(t, this.options.autofocus);
2745
- this.editorState = S.create({
3105
+ let e = He(t, this.options.autofocus);
3106
+ this.editorState = oe.create({
2746
3107
  doc: t,
2747
3108
  schema: this.schema,
2748
3109
  selection: e || void 0
2749
3110
  });
2750
3111
  }
2751
- this.options.element && this.mount(this.options.element);
3112
+ ei(this.schema), this.options.element && this.mount(this.options.element);
2752
3113
  }
2753
3114
  mount(e) {
2754
3115
  if (typeof document > "u") throw Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");
@@ -2758,6 +3119,7 @@ var $ = class e extends sr {
2758
3119
  }
2759
3120
  unmount() {
2760
3121
  if (this.editorView) {
3122
+ this.editorState = this.editorView.state;
2761
3123
  let e = this.editorView.dom;
2762
3124
  e?.editor && delete e.editor, this.editorView.destroy();
2763
3125
  }
@@ -2781,7 +3143,7 @@ var $ = class e extends sr {
2781
3143
  return this.commandManager.can();
2782
3144
  }
2783
3145
  injectCSS() {
2784
- this.options.injectCSS && typeof document < "u" && (this.css = Hn(Dr, this.options.injectNonce));
3146
+ this.options.injectCSS && typeof document < "u" && (this.css = mr(ni, this.options.injectNonce));
2785
3147
  }
2786
3148
  setOptions(e = {}) {
2787
3149
  this.options = {
@@ -2820,10 +3182,10 @@ var $ = class e extends sr {
2820
3182
  } });
2821
3183
  }
2822
3184
  get state() {
2823
- return this.editorView && (this.editorState = this.view.state), this.editorState;
3185
+ return qn && !this.hasWarnedStaleDecorationRead && Gn(this) && (this.hasWarnedStaleDecorationRead = !0, console.warn("[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.")), this.editorView && (this.editorState = this.view.state), this.editorState;
2824
3186
  }
2825
3187
  registerPlugin(e, t) {
2826
- let n = jt(t) ? t(e, [...this.state.plugins]) : [...this.state.plugins, e], r = this.state.reconfigure({ plugins: n });
3188
+ let n = Nt(t) ? t(e, [...this.state.plugins]) : [...this.state.plugins, e], r = this.state.reconfigure({ plugins: n });
2827
3189
  return this.view.updateState(r), r;
2828
3190
  }
2829
3191
  unregisterPlugin(e) {
@@ -2838,25 +3200,25 @@ var $ = class e extends sr {
2838
3200
  }
2839
3201
  createExtensionManager() {
2840
3202
  let e = [...this.options.enableCoreExtensions ? [
2841
- yr,
2842
- hr.configure({ blockSeparator: this.options.coreExtensionOptions?.clipboardTextSerializer?.blockSeparator }),
2843
- gr,
2844
- xr,
2845
- Sr,
2846
- wr.configure({ value: this.options.coreExtensionOptions?.tabindex?.value }),
2847
- vr,
2848
- Cr,
2849
- _r,
2850
- Tr.configure({ direction: this.options.textDirection })
3203
+ Kr,
3204
+ Hr.configure({ blockSeparator: this.options.coreExtensionOptions?.clipboardTextSerializer?.blockSeparator }),
3205
+ Ur,
3206
+ Jr,
3207
+ Yr,
3208
+ Zr.configure({ value: this.options.coreExtensionOptions?.tabindex?.value }),
3209
+ Gr,
3210
+ Xr,
3211
+ Wr,
3212
+ Qr.configure({ direction: this.options.textDirection })
2851
3213
  ].filter((e) => typeof this.options.enableCoreExtensions != "object" || this.options.enableCoreExtensions[e.name] !== !1) : [], ...this.options.extensions].filter((e) => [
2852
3214
  "extension",
2853
3215
  "node",
2854
3216
  "mark"
2855
3217
  ].includes(e?.type));
2856
- this.extensionManager = new Q(e, this);
3218
+ this.extensionManager = new Vr(e, this);
2857
3219
  }
2858
3220
  createCommandManager() {
2859
- this.commandManager = new A({ editor: this });
3221
+ this.commandManager = new k({ editor: this });
2860
3222
  }
2861
3223
  createSchema() {
2862
3224
  this.schema = this.extensionManager.schema;
@@ -2864,14 +3226,14 @@ var $ = class e extends sr {
2864
3226
  createDoc() {
2865
3227
  let e;
2866
3228
  try {
2867
- e = Ct(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: this.options.enableContentCheck });
3229
+ e = Tt(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: this.options.enableContentCheck });
2868
3230
  } catch (e) {
2869
3231
  if (!(e instanceof Error) || !["[tiptap error]: Invalid JSON content", "[tiptap error]: Invalid HTML content"].includes(e.message)) throw e;
2870
- let t = Ct(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: !1 });
2871
- return this.editorState = S.create({
3232
+ let t = Tt(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: !1 });
3233
+ return this.editorState = oe.create({
2872
3234
  doc: t,
2873
3235
  schema: this.schema,
2874
- selection: Ve(t, this.options.autofocus) || void 0
3236
+ selection: He(t, this.options.autofocus) || void 0
2875
3237
  }), this.emit("contentError", {
2876
3238
  editor: this,
2877
3239
  error: e,
@@ -2884,7 +3246,7 @@ var $ = class e extends sr {
2884
3246
  }
2885
3247
  createView(e) {
2886
3248
  let { editorProps: t, enableExtensionDispatchTransaction: n } = this.options, r = t.dispatchTransaction || this.dispatchTransaction.bind(this), i = n ? this.extensionManager.dispatchTransaction(r) : r, a = t.transformPastedHTML, o = this.extensionManager.transformPastedHTML(a);
2887
- this.editorView = new me(e, {
3249
+ this.editorView = new he(e, {
2888
3250
  ...t,
2889
3251
  attributes: {
2890
3252
  role: "textbox",
@@ -2955,30 +3317,30 @@ var $ = class e extends sr {
2955
3317
  });
2956
3318
  }
2957
3319
  getAttributes(e) {
2958
- return Jt(this.state, e);
3320
+ return Xt(this.state, e);
2959
3321
  }
2960
3322
  isActive(e, t) {
2961
3323
  let n = typeof e == "string" ? e : null, r = typeof e == "string" ? t : e;
2962
- return nn(this.state, n, r);
3324
+ return on(this.state, n, r);
2963
3325
  }
2964
3326
  getJSON() {
2965
3327
  return this.state.doc.toJSON();
2966
3328
  }
2967
3329
  getHTML() {
2968
- return At(this.state.doc.content, this.schema);
3330
+ return Mt(this.state.doc.content, this.schema);
2969
3331
  }
2970
3332
  getText(e) {
2971
3333
  let { blockSeparator: t = "\n\n", textSerializers: n = {} } = e || {};
2972
- return Gt(this.state.doc, {
3334
+ return qt(this.state.doc, {
2973
3335
  blockSeparator: t,
2974
3336
  textSerializers: {
2975
- ...Kt(this.schema),
3337
+ ...Jt(this.schema),
2976
3338
  ...n
2977
3339
  }
2978
3340
  });
2979
3341
  }
2980
3342
  get isEmpty() {
2981
- return J(this.state.doc);
3343
+ return q(this.state.doc);
2982
3344
  }
2983
3345
  destroy() {
2984
3346
  this.destroyed || (this.destroyed = !0, this.emit("destroy"), this.unmount(), this.removeAllListeners(), this.extensionManager.destroy(), this.extensionManager = null, this.schema = null, this.commandManager = null, this.extensionStorage = {});
@@ -2994,22 +3356,22 @@ var $ = class e extends sr {
2994
3356
  }
2995
3357
  $pos(e) {
2996
3358
  let t = this.state.doc.resolve(e), n = e > 0 && t.nodeAfter && !t.nodeAfter.isText && t.nodeAfter.isAtom ? t.nodeAfter : null;
2997
- return new Er(t, this, !1, n);
3359
+ return new ti(t, this, !1, n);
2998
3360
  }
2999
3361
  get $doc() {
3000
3362
  return this.$pos(0);
3001
3363
  }
3002
3364
  };
3003
- function kr(e) {
3004
- return new X({
3365
+ function ii(e) {
3366
+ return new Z({
3005
3367
  find: e.find,
3006
3368
  handler: ({ state: t, range: n, match: r }) => {
3007
- let i = H(e.getAttributes, void 0, r);
3369
+ let i = V(e.getAttributes, void 0, r);
3008
3370
  if (i === !1 || i === null) return null;
3009
3371
  let { tr: a } = t, o = r[r.length - 1], s = r[0];
3010
3372
  if (o) {
3011
3373
  let r = s.search(/\S/), c = n.from + s.indexOf(o), l = c + o.length;
3012
- if (Qt(n.from, n.to, t.doc).filter((t) => t.mark.type.excluded.find((n) => n === e.type && n !== t.mark.type)).filter((e) => e.to > c).length) return null;
3374
+ if (en(n.from, n.to, t.doc).filter((t) => t.mark.type.excluded.find((n) => n === e.type && n !== t.mark.type)).filter((e) => e.to > c).length) return null;
3013
3375
  l < n.to && a.delete(l, n.to), c > n.from && a.delete(n.from + r, c);
3014
3376
  let u = n.from + r + o.length;
3015
3377
  a.addMark(n.from + r, u, e.type.create(i || {})), a.removeStoredMark(e.type);
@@ -3018,11 +3380,11 @@ function kr(e) {
3018
3380
  undoable: e.undoable
3019
3381
  });
3020
3382
  }
3021
- function Ar(e) {
3022
- return new X({
3383
+ function ai(e) {
3384
+ return new Z({
3023
3385
  find: e.find,
3024
3386
  handler: ({ state: t, range: n, match: r }) => {
3025
- let i = H(e.getAttributes, void 0, r) || {}, { tr: a } = t, o = n.from, s = n.to, c = e.type.create(i);
3387
+ let i = V(e.getAttributes, void 0, r) || {}, { tr: a } = t, o = n.from, s = n.to, c = e.type.create(i);
3026
3388
  if (r[1]) {
3027
3389
  let e = o + r[0].lastIndexOf(r[1]);
3028
3390
  e > s ? e = s : s = e + r[1].length;
@@ -3037,19 +3399,19 @@ function Ar(e) {
3037
3399
  undoable: e.undoable
3038
3400
  });
3039
3401
  }
3040
- function jr(e) {
3041
- return new X({
3402
+ function oi(e) {
3403
+ return new Z({
3042
3404
  find: e.find,
3043
3405
  handler: ({ state: t, range: n, match: r }) => {
3044
- let i = t.doc.resolve(n.from), a = H(e.getAttributes, void 0, r) || {};
3406
+ let i = t.doc.resolve(n.from), a = V(e.getAttributes, void 0, r) || {};
3045
3407
  if (!i.node(-1).canReplaceWith(i.index(-1), i.indexAfter(-1), e.type)) return null;
3046
3408
  t.tr.delete(n.from, n.to).setBlockType(n.from, n.from, e.type, a);
3047
3409
  },
3048
3410
  undoable: e.undoable
3049
3411
  });
3050
3412
  }
3051
- function Mr(e) {
3052
- return new X({
3413
+ function si(e) {
3414
+ return new Z({
3053
3415
  find: e.find,
3054
3416
  handler: ({ state: t, range: n, match: r }) => {
3055
3417
  let i = e.replace, a = n.from, o = n.to;
@@ -3064,11 +3426,11 @@ function Mr(e) {
3064
3426
  undoable: e.undoable
3065
3427
  });
3066
3428
  }
3067
- function Nr(e) {
3068
- return new X({
3429
+ function ci(e) {
3430
+ return new Z({
3069
3431
  find: e.find,
3070
3432
  handler: ({ state: t, range: n, match: r, chain: a }) => {
3071
- let s = H(e.getAttributes, void 0, r) || {}, c = t.tr.delete(n.from, n.to), l = c.doc.resolve(n.from).blockRange(), u = l && o(l, e.type, s);
3433
+ let s = V(e.getAttributes, void 0, r) || {}, c = t.tr.delete(n.from, n.to), l = c.doc.resolve(n.from).blockRange(), u = l && o(l, e.type, s);
3072
3434
  if (!u) return null;
3073
3435
  if (c.wrap(l, u), e.keepMarks && e.editor) {
3074
3436
  let { selection: n, storedMarks: r } = t, { splittableMarks: i } = e.editor.extensionManager, a = r || n.$to.parentOffset && n.$from.marks();
@@ -3087,7 +3449,7 @@ function Nr(e) {
3087
3449
  undoable: e.undoable
3088
3450
  });
3089
3451
  }
3090
- var Pr = (e) => "touches" in e, Fr = class {
3452
+ var li = (e) => "touches" in e, ui = class {
3091
3453
  constructor(e) {
3092
3454
  this.directions = [
3093
3455
  "bottom-left",
@@ -3176,7 +3538,7 @@ var Pr = (e) => "touches" in e, Fr = class {
3176
3538
  e ? (this.element.style.width = `${e}px`, this.initialWidth = e) : this.initialWidth = this.element.offsetWidth, t ? (this.element.style.height = `${t}px`, this.initialHeight = t) : this.initialHeight = this.element.offsetHeight, this.initialWidth > 0 && this.initialHeight > 0 && (this.aspectRatio = this.initialWidth / this.initialHeight);
3177
3539
  }
3178
3540
  handleResizeStart(e, t) {
3179
- e.preventDefault(), e.stopPropagation(), this.isResizing = !0, this.activeHandle = t, Pr(e) ? (this.startX = e.touches[0].clientX, this.startY = e.touches[0].clientY) : (this.startX = e.clientX, this.startY = e.clientY), this.startWidth = this.element.offsetWidth, this.startHeight = this.element.offsetHeight, this.startWidth > 0 && this.startHeight > 0 && (this.aspectRatio = this.startWidth / this.startHeight), this.getPos(), this.container.dataset.resizeState = "true", this.classNames.resizing && this.container.classList.add(this.classNames.resizing), document.addEventListener("mousemove", this.handleMouseMove), document.addEventListener("touchmove", this.handleTouchMove), document.addEventListener("mouseup", this.handleMouseUp), document.addEventListener("keydown", this.handleKeyDown), document.addEventListener("keyup", this.handleKeyUp);
3541
+ e.preventDefault(), e.stopPropagation(), this.isResizing = !0, this.activeHandle = t, li(e) ? (this.startX = e.touches[0].clientX, this.startY = e.touches[0].clientY) : (this.startX = e.clientX, this.startY = e.clientY), this.startWidth = this.element.offsetWidth, this.startHeight = this.element.offsetHeight, this.startWidth > 0 && this.startHeight > 0 && (this.aspectRatio = this.startWidth / this.startHeight), this.getPos(), this.container.dataset.resizeState = "true", this.classNames.resizing && this.container.classList.add(this.classNames.resizing), document.addEventListener("mousemove", this.handleMouseMove), document.addEventListener("touchmove", this.handleTouchMove), document.addEventListener("mouseup", this.handleMouseUp), document.addEventListener("keydown", this.handleKeyDown), document.addEventListener("keyup", this.handleKeyUp);
3180
3542
  }
3181
3543
  handleResize(e, t) {
3182
3544
  if (!this.activeHandle) return;
@@ -3216,7 +3578,7 @@ var Pr = (e) => "touches" in e, Fr = class {
3216
3578
  height: e / this.aspectRatio
3217
3579
  };
3218
3580
  }
3219
- }, Ir = class e extends sr {
3581
+ }, di = class e extends Nr {
3220
3582
  constructor() {
3221
3583
  super(...arguments), this.type = "node";
3222
3584
  }
@@ -3232,20 +3594,20 @@ var Pr = (e) => "touches" in e, Fr = class {
3232
3594
  return super.extend(t);
3233
3595
  }
3234
3596
  };
3235
- function Lr(e) {
3236
- return new lr({
3597
+ function fi(e) {
3598
+ return new Fr({
3237
3599
  find: e.find,
3238
3600
  handler: ({ state: t, range: n, match: r, pasteEvent: i }) => {
3239
- let a = H(e.getAttributes, void 0, r, i);
3601
+ let a = V(e.getAttributes, void 0, r, i);
3240
3602
  if (a === !1 || a === null) return null;
3241
3603
  let { tr: o } = t, s = r[r.length - 1], c = r[0], l = n.to;
3242
3604
  if (s) {
3243
3605
  let i = c.search(/\S/), u = n.from + c.indexOf(s), d = u + s.length;
3244
- if (Qt(n.from, n.to, t.doc).filter((t) => t.mark.type.excluded.find((n) => n === e.type && n !== t.mark.type)).filter((e) => e.to > u).length) return null;
3606
+ if (en(n.from, n.to, t.doc).filter((t) => t.mark.type.excluded.find((n) => n === e.type && n !== t.mark.type)).filter((e) => e.to > u).length) return null;
3245
3607
  d < n.to && o.delete(d, n.to), u > n.from && o.delete(n.from + i, u), l = n.from + i + s.length, o.addMark(n.from + i, l, e.type.create(a || {})), r.index !== void 0 && r.input !== void 0 && r.index + r[0].length >= r.input.length || o.removeStoredMark(e.type);
3246
3608
  }
3247
3609
  }
3248
3610
  });
3249
3611
  }
3250
3612
  //#endregion
3251
- export { Be as A, Nr as B, Kt as C, R as D, Gn as E, tr as F, fn as I, nr as L, Lr as M, It as N, J as O, Ar as P, Mr as R, Gt as S, an as T, Qt as _, Ir as a, W as b, H as c, Un as d, Dt as f, V as g, Zt as h, cr as i, kr as j, cn as k, Vn as l, Jt as m, $ as n, lr as o, Ot as p, X as r, Fr as s, Or as t, Et as u, $t as v, rn as w, Wn as x, j as y, jr as z };
3613
+ export { dn as A, oi as B, qt as C, _r as D, cn as E, ai as F, Dr as I, hn as L, ii as M, fi as N, L as O, Rt as P, Or as R, gr as S, sn as T, ci as V, en as _, di as a, nn as b, V as c, hr as d, kt as f, B as g, $t as h, Pr as i, Ve as j, q as k, pr as l, Xt as m, $ as n, Fr as o, At as p, Z as r, ui as s, ri as t, Ot as u, tn as v, Jt as w, U as x, A as y, si as z };