@clevertask/scribe 0.1.12 → 0.1.14

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 (91) hide show
  1. package/README.md +51 -1
  2. package/dist/{BarMenu-5M9g9Y1j.js → BarMenu-x4sf3ECS.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/ExternalLinkDisplayOptions.d.ts +13 -0
  8. package/dist/components/Menu/ExternalLinkDisplayOptions.d.ts.map +1 -0
  9. package/dist/components/Menu/ExternalLinkDisplayOptions.js +90 -0
  10. package/dist/components/Menu/LinkBubbleMenu.d.ts.map +1 -1
  11. package/dist/components/Menu/LinkBubbleMenu.js +161 -61
  12. package/dist/components/Menu/LinkEditor.d.ts +9 -0
  13. package/dist/components/Menu/LinkEditor.d.ts.map +1 -1
  14. package/dist/components/Menu/LinkEditor.js +117 -64
  15. package/dist/components/Menu/Mobile/ListOptionBar.js +1 -1
  16. package/dist/components/Menu/TableBubbleMenu.js +2 -2
  17. package/dist/components/Menu/contextualMenuOwner.d.ts +1 -1
  18. package/dist/components/Menu/contextualMenuOwner.d.ts.map +1 -1
  19. package/dist/components/Menu/contextualMenuOwner.js +9 -6
  20. package/dist/components/Menu/linkBubbleMenuPlugin.d.ts +24 -1
  21. package/dist/components/Menu/linkBubbleMenuPlugin.d.ts.map +1 -1
  22. package/dist/components/Menu/linkBubbleMenuPlugin.js +43 -6
  23. package/dist/components/Scribe/extension/callout.js +1 -1
  24. package/dist/components/Scribe/extension/emoji/suggest.js +1 -1
  25. package/dist/components/Scribe/extension/extension-link.js +1 -1
  26. package/dist/components/Scribe/extension/extension-markdown-paste.js +2 -2
  27. package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
  28. package/dist/components/Scribe/extension/external-link-preview/attributes.d.ts +18 -0
  29. package/dist/components/Scribe/extension/external-link-preview/attributes.d.ts.map +1 -0
  30. package/dist/components/Scribe/extension/external-link-preview/attributes.js +82 -0
  31. package/dist/components/Scribe/extension/external-link-preview/commands.d.ts +53 -0
  32. package/dist/components/Scribe/extension/external-link-preview/commands.d.ts.map +1 -0
  33. package/dist/components/Scribe/extension/external-link-preview/commands.js +134 -0
  34. package/dist/components/Scribe/extension/external-link-preview/index.d.ts +13 -0
  35. package/dist/components/Scribe/extension/external-link-preview/index.d.ts.map +1 -0
  36. package/dist/components/Scribe/extension/external-link-preview/index.js +138 -0
  37. package/dist/components/Scribe/extension/external-link-preview/node-view.d.ts +3 -0
  38. package/dist/components/Scribe/extension/external-link-preview/node-view.d.ts.map +1 -0
  39. package/dist/components/Scribe/extension/external-link-preview/node-view.js +97 -0
  40. package/dist/components/Scribe/extension/external-link-preview/normalization.d.ts +7 -0
  41. package/dist/components/Scribe/extension/external-link-preview/normalization.d.ts.map +1 -0
  42. package/dist/components/Scribe/extension/external-link-preview/normalization.js +21 -0
  43. package/dist/components/Scribe/extension/external-link-preview/paste.d.ts +8 -0
  44. package/dist/components/Scribe/extension/external-link-preview/paste.d.ts.map +1 -0
  45. package/dist/components/Scribe/extension/external-link-preview/paste.js +54 -0
  46. package/dist/components/Scribe/extension/external-link-preview/policy.d.ts +7 -0
  47. package/dist/components/Scribe/extension/external-link-preview/policy.d.ts.map +1 -0
  48. package/dist/components/Scribe/extension/external-link-preview/policy.js +38 -0
  49. package/dist/components/Scribe/extension/external-link-preview/render-html.d.ts +7 -0
  50. package/dist/components/Scribe/extension/external-link-preview/render-html.d.ts.map +1 -0
  51. package/dist/components/Scribe/extension/external-link-preview/render-html.js +62 -0
  52. package/dist/components/Scribe/extension/external-link-preview/resolver.d.ts +23 -0
  53. package/dist/components/Scribe/extension/external-link-preview/resolver.d.ts.map +1 -0
  54. package/dist/components/Scribe/extension/external-link-preview/resolver.js +118 -0
  55. package/dist/components/Scribe/extension/external-link-preview/serialization.d.ts +10 -0
  56. package/dist/components/Scribe/extension/external-link-preview/serialization.d.ts.map +1 -0
  57. package/dist/components/Scribe/extension/external-link-preview/serialization.js +69 -0
  58. package/dist/components/Scribe/extension/external-link-preview/types.d.ts +53 -0
  59. package/dist/components/Scribe/extension/external-link-preview/types.d.ts.map +1 -0
  60. package/dist/components/Scribe/extension/external-link-preview/types.js +4 -0
  61. package/dist/components/Scribe/extension/index.d.ts +1 -1
  62. package/dist/components/Scribe/extension/index.d.ts.map +1 -1
  63. package/dist/components/Scribe/extension/index.js +1 -1
  64. package/dist/components/Scribe/extension/resizable-table.js +1 -1
  65. package/dist/components/Scribe/extension/slashCommand/index.js +1 -1
  66. package/dist/components/Scribe/extension/slashCommand/renderItems.js +1 -1
  67. package/dist/components/Scribe/extension/tableOfContents.js +1 -1
  68. package/dist/components/Scribe/index.d.ts +14 -0
  69. package/dist/components/Scribe/index.d.ts.map +1 -1
  70. package/dist/components/Scribe/index.js +5 -5
  71. package/dist/{dist-Dw4STOPE.js → dist-DDjaA1Pn.js} +309 -150
  72. package/dist/{dist-DFua_Xbu.js → dist-tNcpTcFT.js} +893 -430
  73. package/dist/{extension-_8uh0Ik9.js → extension-dRUfQQo6.js} +2097 -2059
  74. package/dist/{extension-link-CjfUZ90W.js → extension-link-RYtPpHwt.js} +52 -51
  75. package/dist/{html-to-markdown-C920nQtn.js → html-to-markdown-nbQ6qHyO.js} +173 -162
  76. package/dist/main.css +148 -0
  77. package/dist/main.d.ts +1 -0
  78. package/dist/main.d.ts.map +1 -1
  79. package/dist/main.js +12 -9
  80. package/dist/{markdown-to-html-CW0Nb9Ye.js → markdown-to-html-B-KKCZRs.js} +115 -111
  81. package/dist/{menus-_EXlLMjz.js → menus-U2HdvQnu.js} +18 -18
  82. package/dist/{resizable-table-Ddw3l6DJ.js → resizable-table-m0AzovsZ.js} +42 -24
  83. package/dist/{slashCommand-CxX07Nbk.js → slashCommand-CtvgnL0Z.js} +2 -2
  84. package/dist/utils/create-scribe-editor.d.ts +4 -1
  85. package/dist/utils/create-scribe-editor.d.ts.map +1 -1
  86. package/dist/utils/html-to-markdown.d.ts.map +1 -1
  87. package/dist/utils/html-to-markdown.js +1 -1
  88. package/dist/utils/index.js +7 -7
  89. package/dist/utils/markdown-to-html.d.ts.map +1 -1
  90. package/dist/utils/markdown-to-html.js +1 -1
  91. package/package.json +48 -48
@@ -1,11 +1,11 @@
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";
3
+ import { AllSelection as ae, EditorState as oe, NodeSelection as S, Plugin as C, PluginKey as w, Selection as T, TextSelection as E } from "@tiptap/pm/state";
4
+ import { DOMParser as se, DOMSerializer as ce, Fragment as D, Schema as le, Slice as ue } from "@tiptap/pm/model";
5
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";
6
+ import { DecorationSet as O, EditorView as me } from "@tiptap/pm/view";
7
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
8
+ //#region node_modules/.pnpm/@tiptap+core@3.30.1_@tiptap+pm@3.30.1/node_modules/@tiptap/core/dist/index.js
9
9
  var ge = Object.defineProperty, _e = (e, t) => {
10
10
  for (var n in t) ge(e, n, {
11
11
  get: t[n],
@@ -111,11 +111,11 @@ _e(ve, {
111
111
  deleteSelection: () => je,
112
112
  enter: () => Me,
113
113
  exitCode: () => Ne,
114
- extendMarkRange: () => Re,
115
- first: () => ze,
116
- focus: () => We,
117
- forEach: () => Ge,
118
- insertContent: () => Ke,
114
+ extendMarkRange: () => Le,
115
+ first: () => Re,
116
+ focus: () => Ue,
117
+ forEach: () => We,
118
+ insertContent: () => Ge,
119
119
  insertContentAt: () => Xe,
120
120
  insertDefaultBlock: () => Qe,
121
121
  joinBackward: () => tt,
@@ -140,26 +140,27 @@ _e(ve, {
140
140
  selectTextblockEnd: () => xt,
141
141
  selectTextblockStart: () => St,
142
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
143
+ setMark: () => gn,
144
+ setMeta: () => _n,
145
+ setNode: () => vn,
146
+ setNodeSelection: () => yn,
147
+ setTextDirection: () => bn,
148
+ setTextSelection: () => xn,
149
+ sinkListItem: () => Sn,
150
+ splitBlock: () => wn,
151
+ splitListItem: () => Tn,
152
+ toggleList: () => jn,
153
+ toggleMark: () => Mn,
154
+ toggleNode: () => Nn,
155
+ toggleWrap: () => Pn,
156
+ undoInputRule: () => Fn,
157
+ unsetAllMarks: () => In,
158
+ unsetMark: () => Ln,
159
+ unsetTextDirection: () => Rn,
160
+ updateAttributes: () => zn,
161
+ updateDecorations: () => Bn,
162
+ wrapIn: () => Vn,
163
+ wrapInList: () => Hn
163
164
  });
164
165
  var ye = () => ({ editor: e, view: t }) => (requestAnimationFrame(() => {
165
166
  var n;
@@ -183,7 +184,7 @@ var ye = () => ({ editor: e, view: t }) => (requestAnimationFrame(() => {
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
+ return r.insert(o, a.content), r.setSelection(new E(r.doc.resolve(Math.max(o - 1, 0)))), !0;
187
188
  }, Te = () => ({ tr: e, dispatch: t }) => {
188
189
  let { selection: n } = e, r = n.$anchor.node();
189
190
  if (r.content.size > 0) return !1;
@@ -231,7 +232,7 @@ var Ee = (e) => ({ tr: t, state: n, dispatch: r }) => {
231
232
  r.forEach((t) => {
232
233
  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
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(E.near(n.doc.resolve(n.selection.from))), n.scrollIntoView(), t(n);
235
236
  }
236
237
  return !0;
237
238
  }, Me = () => ({ commands: e }) => e.keyboardShortcut("Enter"), Ne = () => ({ state: e, dispatch: t }) => u(e, t);
@@ -248,7 +249,7 @@ function Fe(e, t, n = {}) {
248
249
  function Ie(e, t, n = {}) {
249
250
  return !!Fe(e, t, n);
250
251
  }
251
- function Le(e, t, n) {
252
+ function N(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;
@@ -265,46 +266,46 @@ function Le(e, t, n) {
265
266
  to: s
266
267
  };
267
268
  }
268
- function N(e, t) {
269
+ function P(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 Le = (e, t) => ({ tr: n, state: r, dispatch: i }) => {
277
+ let a = P(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 = N(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 = E.create(o, e.from, e.to);
281
282
  n.setSelection(t);
282
283
  }
283
284
  }
284
285
  return !0;
285
- }, ze = (e) => (t) => {
286
+ }, Re = (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 ze(e) {
292
+ return e instanceof E;
292
293
  }
293
- function P(e = 0, t = 0, n = 0) {
294
+ function F(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 Be(e, t = null) {
297
298
  if (!t) return null;
298
- let n = E.atStart(e), r = E.atEnd(e);
299
+ let n = T.atStart(e), r = T.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" ? E.create(e, F(0, i, a), F(e.content.size, i, a)) : E.create(e, F(t, i, a), F(t, i, a));
303
304
  }
304
- function He() {
305
+ function Ve() {
305
306
  return ["Android"].includes(navigator.platform) || /android/i.test(navigator.userAgent);
306
307
  }
307
- function F() {
308
+ function I() {
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 He() {
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 Ue = (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
+ (I() || Ve()) && r.dom.focus(), He() && !I() && !Ve() && r.dom.focus({ preventScroll: !0 }), requestAnimationFrame(() => {
327
328
  n.isDestroyed || (r.focus(), t?.scrollIntoView && n.commands.scrollIntoView());
328
329
  });
329
330
  };
@@ -332,43 +333,47 @@ 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 && !ze(n.state.selection)) return o(), !0;
337
+ let s = Be(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
+ }, We = (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
+ })), Ge = (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), Ke = (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 && Ke(r);
349
350
  }
350
351
  return e;
351
352
  };
352
- function I(e) {
353
+ function L(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 Ke(n);
357
+ }
358
+ function qe(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 R(e, t, n) {
362
+ if (qe(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 D.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), R("", t, n);
372
377
  }
373
378
  if (i) {
374
379
  if (n.errorOnInvalidContent) {
@@ -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 ? se.fromSchema(a).parseSlice(L(e), n.parseOptions) : se.fromSchema(a).parse(L(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 = se.fromSchema(t);
395
+ return n.slice ? r.parseSlice(L(e), n.parseOptions).content : r.parse(L(e), n.parseOptions);
391
396
  }
392
- return L("", t, n);
397
+ return R("", t, n);
393
398
  }
394
- function Je(e, r, i) {
399
+ function Je(e) {
400
+ return !("type" in e);
401
+ }
402
+ function Ye(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(T.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 Xe = (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
+ R(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 = R(t, a.schema, {
435
443
  parseOptions: s,
436
444
  errorOnInvalidContent: n.errorOnInvalidContent ?? a.options.enableContentCheck
437
445
  });
@@ -444,34 +452,26 @@ 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 = Je(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("") : qe(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 = D.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 && Ye(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;
@@ -490,10 +490,10 @@ var Qe = (e = {}) => ({ tr: t, dispatch: n, editor: r }) => {
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 = R(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;
496
+ return f ? (n && (t.insert(c.pos, f), s && Ye(t, t.steps.length - 1, -1)), !0) : !1;
497
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 }) => {
498
498
  try {
499
499
  let r = s(e.doc, e.selection.$from.pos, -1);
@@ -522,7 +522,7 @@ 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)) I() || st() ? 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;
@@ -549,7 +549,7 @@ 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 = {}) {
552
+ function z(e, t, n = {}) {
553
553
  let { from: r, to: i, empty: a } = e.selection, o = t ? j(t, e.schema) : null, s = [];
554
554
  e.doc.nodesBetween(r, i, (e, t) => {
555
555
  if (e.isText) return;
@@ -563,11 +563,11 @@ function R(e, t, n = {}) {
563
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 }));
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 }) => {
566
+ var ut = (e, t = {}) => ({ state: n, dispatch: r }) => z(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
567
  let r = j(e, t.schema);
568
568
  return de(r)(t, n);
569
569
  }, pt = () => ({ state: e, dispatch: t }) => _(e, t);
570
- function z(e, t) {
570
+ function B(e, t) {
571
571
  return t.nodes[e] ? "node" : t.marks[e] ? "mark" : null;
572
572
  }
573
573
  function mt(e, t) {
@@ -575,9 +575,9 @@ function mt(e, t) {
575
575
  return Object.keys(e).reduce((t, r) => (n.includes(r) || (t[r] = e[r]), t), {});
576
576
  }
577
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);
578
+ let a = null, o = null, s = B(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 = j(e, r.schema)), s === "mark" && (o = P(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) => {
@@ -594,7 +594,7 @@ var ht = (e, t) => ({ tr: n, state: r, dispatch: i }) => {
594
594
  return !0;
595
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
596
  function Ct(e, t, n = {}, r = {}) {
597
- return L(e, t, {
597
+ return R(e, t, {
598
598
  slice: !1,
599
599
  parseOptions: n,
600
600
  errorOnInvalidContent: r.errorOnInvalidContent
@@ -604,7 +604,11 @@ var wt = (e, { errorOnInvalidContent: t, emitUpdate: n = !0, parseOptions: r = {
604
604
  let { doc: c } = a;
605
605
  if (r.preserveWhitespace !== "full") {
606
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;
607
+ if (o) {
608
+ let e = Je(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,
@@ -615,7 +619,7 @@ var wt = (e, { errorOnInvalidContent: t, emitUpdate: n = !0, parseOptions: r = {
615
619
  });
616
620
  };
617
621
  function Tt(e, t) {
618
- let n = N(t, e.schema), { from: r, to: i, empty: a } = e.selection, o = [];
622
+ let n = P(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
  });
@@ -650,18 +654,18 @@ function Ot(e, t) {
650
654
  };
651
655
  }
652
656
  }
653
- function B(e) {
657
+ function V(e) {
654
658
  return (t) => Ot(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 H(e, t, n) {
661
+ return e.config[t] === void 0 && e.parent ? H(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 ? H(e.parent, t, n) : null
660
664
  }) : e.config[t];
661
665
  }
662
666
  function kt(e) {
663
667
  return e.map((e) => {
664
- let t = V(e, "addExtensions", {
668
+ let t = H(e, "addExtensions", {
665
669
  name: e.name,
666
670
  options: e.options,
667
671
  storage: e.storage
@@ -670,19 +674,19 @@ function kt(e) {
670
674
  }).flat(10);
671
675
  }
672
676
  function At(e, t) {
673
- let n = se.fromSchema(t).serializeFragment(e), r = document.implementation.createHTMLDocument().createElement("div");
677
+ let n = ce.fromSchema(t).serializeFragment(e), r = document.implementation.createHTMLDocument().createElement("div");
674
678
  return r.appendChild(n), r.innerHTML;
675
679
  }
676
680
  function jt(e) {
677
681
  return typeof e == "function";
678
682
  }
679
- function H(e, t = void 0, ...n) {
683
+ function U(e, t = void 0, ...n) {
680
684
  return jt(e) ? t ? e.bind(t)(...n) : e(...n) : e;
681
685
  }
682
686
  function Mt(e = {}) {
683
687
  return Object.keys(e).length === 0 && e.constructor === Object;
684
688
  }
685
- function U(e) {
689
+ function W(e) {
686
690
  return {
687
691
  baseExtensions: e.filter((e) => e.type === "extension"),
688
692
  nodeExtensions: e.filter((e) => e.type === "node"),
@@ -690,7 +694,7 @@ function U(e) {
690
694
  };
691
695
  }
692
696
  function Nt(e) {
693
- let t = [], { nodeExtensions: n, markExtensions: r } = U(e), i = [...n, ...r], a = {
697
+ let t = [], { nodeExtensions: n, markExtensions: r } = W(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 = H(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 = H(e, "addAttributes", {
726
730
  name: e.name,
727
731
  options: e.options,
728
732
  storage: e.storage
@@ -800,7 +804,7 @@ function It(...e) {
800
804
  }), n;
801
805
  }, {});
802
806
  }
803
- function W(e, t) {
807
+ function G(e, t) {
804
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) => It(e, t), {});
805
809
  }
806
810
  function Lt(e) {
@@ -834,7 +838,7 @@ function Bt(e) {
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
840
  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) => {
841
+ let n = Nt(e), { nodeExtensions: r, markExtensions: i } = W(e), a = r.find((e) => H(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,
@@ -842,33 +846,33 @@ function Vt(e, t) {
842
846
  editor: t
843
847
  }, o = zt({
844
848
  ...e.reduce((e, t) => {
845
- let n = V(t, "extendNodeSchema", a);
849
+ let n = H(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)),
855
+ content: U(H(r, "content", a)),
856
+ marks: U(H(r, "marks", a)),
857
+ group: U(H(r, "group", a)),
858
+ inline: U(H(r, "inline", a)),
859
+ atom: U(H(r, "atom", a)),
860
+ selectable: U(H(r, "selectable", a)),
861
+ draggable: U(H(r, "draggable", a)),
862
+ code: U(H(r, "code", a)),
863
+ whitespace: U(H(r, "whitespace", a)),
864
+ linebreakReplacement: U(H(r, "linebreakReplacement", a)),
865
+ defining: U(H(r, "defining", a)),
866
+ isolating: U(H(r, "isolating", a)),
863
867
  attrs: Object.fromEntries(i.map(Bt))
864
- }), s = H(V(r, "parseHTML", a));
868
+ }), s = U(H(r, "parseHTML", a));
865
869
  s && (o.parseDOM = s.map((e) => Rt(e, i)));
866
- let c = V(r, "renderHTML", a);
870
+ let c = H(r, "renderHTML", a);
867
871
  c && (o.toDOM = (e) => c({
868
872
  node: e,
869
- HTMLAttributes: W(e, i)
873
+ HTMLAttributes: G(e, i)
870
874
  }));
871
- let l = V(r, "renderText", a);
875
+ let l = H(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 = {
@@ -878,24 +882,24 @@ function Vt(e, t) {
878
882
  editor: t
879
883
  }, o = zt({
880
884
  ...e.reduce((e, t) => {
881
- let n = V(t, "extendMarkSchema", a);
885
+ let n = H(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)),
891
+ inclusive: U(H(r, "inclusive", a)),
892
+ excludes: U(H(r, "excludes", a)),
893
+ group: U(H(r, "group", a)),
894
+ spanning: U(H(r, "spanning", a)),
895
+ code: U(H(r, "code", a)),
892
896
  attrs: Object.fromEntries(i.map(Bt))
893
- }), s = H(V(r, "parseHTML", a));
897
+ }), s = U(H(r, "parseHTML", a));
894
898
  s && (o.parseDOM = s.map((e) => Rt(e, i)));
895
- let c = V(r, "renderHTML", a);
899
+ let c = H(r, "renderHTML", a);
896
900
  return c && (o.toDOM = (e) => c({
897
901
  mark: e,
898
- HTMLAttributes: W(e, i)
902
+ HTMLAttributes: G(e, i)
899
903
  })), [r.name, o];
900
904
  }));
901
905
  return new le({
@@ -908,14 +912,14 @@ function Ht(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 K(e) {
912
916
  return e.sort((e, t) => {
913
- let n = V(e, "priority") || 100, r = V(t, "priority") || 100;
917
+ let n = H(e, "priority") || 100, r = H(t, "priority") || 100;
914
918
  return n > r ? -1 : +(n < r);
915
919
  });
916
920
  }
917
921
  function Ut(e) {
918
- let t = G(kt(e)), n = Ht(t.map((e) => e.name));
922
+ let t = K(kt(e)), n = Ht(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
925
  function Wt(e, t, n) {
@@ -951,7 +955,7 @@ function qt(e, t) {
951
955
  return o ? { ...o.attrs } : {};
952
956
  }
953
957
  function Jt(e, t) {
954
- let n = z(typeof t == "string" ? t : t.name, e.schema);
958
+ let n = B(typeof t == "string" ? t : t.name, e.schema);
955
959
  return n === "node" ? qt(e, t) : n === "mark" ? Tt(e, t) : {};
956
960
  }
957
961
  function Yt(e, t = JSON.stringify) {
@@ -1001,7 +1005,7 @@ function Zt(e) {
1001
1005
  function Qt(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 = N(n.resolve(e), t.type);
1005
1009
  i && r.push({
1006
1010
  mark: t,
1007
1011
  ...i
@@ -1021,17 +1025,22 @@ var $t = (e, t, n, r = 20) => {
1021
1025
  e?.type.name === t ? o = e : --a;
1022
1026
  }
1023
1027
  return [o, a];
1028
+ }, en = (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 q(e, t) {
1026
1035
  return t.nodes[e] || t.marks[e] || null;
1027
1036
  }
1028
- function q(e, t, n) {
1037
+ function J(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 tn = (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,8 +1053,8 @@ 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;
1056
+ function nn(e, t, n = {}) {
1057
+ let { empty: r, ranges: i } = e.selection, a = t ? P(t, e.schema) : null;
1049
1058
  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 }));
1050
1059
  let o = 0, s = [];
1051
1060
  if (i.forEach(({ $from: t, $to: n }) => {
@@ -1064,38 +1073,38 @@ function tn(e, t, n = {}) {
1064
1073
  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);
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 rn(e, t, n = {}) {
1077
+ if (!t) return z(e, null, n) || nn(e, null, n);
1078
+ let r = B(t, e.schema);
1079
+ return r === "node" ? z(e, t, n) : r === "mark" && nn(e, t, n);
1071
1080
  }
1072
- var rn = (e, t) => {
1081
+ var an = (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 = V((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
+ }, on = (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 sn(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 cn(e, t) {
1098
+ let { nodeExtensions: n } = W(t), r = n.find((t) => t.name === e);
1090
1099
  if (!r) return !1;
1091
- let i = H(V(r, "group", {
1100
+ let i = U(H(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 Y(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 && (Y(e, {
1110
1119
  ignoreWhitespace: n,
1111
1120
  checkChildren: t
1112
1121
  }) || (r = !1));
@@ -1114,10 +1123,14 @@ 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 ln(e) {
1127
+ return e instanceof S;
1128
+ }
1129
+ function un({ selection: e, pos: t, nodeSize: n, selectedOnTextSelection: r = !1 }) {
1130
+ let { from: i, to: a } = e;
1131
+ return !!(i <= t && a >= t + n || r && ze(e) && i > t && a < t + n);
1119
1132
  }
1120
- var ln = class e {
1133
+ var dn = class e {
1121
1134
  constructor(e) {
1122
1135
  this.position = e;
1123
1136
  }
@@ -1128,18 +1141,18 @@ var ln = class e {
1128
1141
  return { position: this.position };
1129
1142
  }
1130
1143
  };
1131
- function un(e, t) {
1144
+ function fn(e, t) {
1132
1145
  let n = t.mapping.mapResult(e.position);
1133
1146
  return {
1134
- position: new ln(n.pos),
1147
+ position: new dn(n.pos),
1135
1148
  mapResult: n
1136
1149
  };
1137
1150
  }
1138
- function dn(e) {
1139
- return new ln(e);
1151
+ function pn(e) {
1152
+ return new dn(e);
1140
1153
  }
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 = {
1154
+ function mn(e, t, n) {
1155
+ let r = e.state.doc.content.size, i = F(t, 0, r), a = F(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
1156
  top: c,
1144
1157
  bottom: l,
1145
1158
  left: u,
@@ -1154,9 +1167,9 @@ function fn(e, t, n) {
1154
1167
  toJSON: () => f
1155
1168
  };
1156
1169
  }
1157
- function pn(e, t, n) {
1170
+ function hn(e, t, n) {
1158
1171
  let { selection: r } = t, i = null;
1159
- if (Be(r) && (i = r.$cursor), i) {
1172
+ if (ze(r) && (i = r.$cursor), i) {
1160
1173
  let t = e.storedMarks ?? i.marks();
1161
1174
  return i.parent.type.allowsMarkType(n) && (!!n.isInSet(t) || !t.some((e) => e.type.excludes(n)));
1162
1175
  }
@@ -1173,8 +1186,8 @@ function pn(e, t, n) {
1173
1186
  }), i;
1174
1187
  });
1175
1188
  }
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);
1189
+ var gn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
1190
+ let { selection: a } = n, { empty: o, ranges: s } = a, c = P(e, r.schema);
1178
1191
  if (i) {
1179
1192
  if (o) {
1180
1193
  let e = Tt(r, c);
@@ -1195,8 +1208,8 @@ var mn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
1195
1208
  });
1196
1209
  });
1197
1210
  }
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 }) => {
1211
+ return hn(r, n, c);
1212
+ }, _n = (e, t) => ({ tr: n }) => (n.setMeta(e, t), !0), vn = (e, t = {}) => ({ state: n, dispatch: r, chain: i }) => {
1200
1213
  let a = j(e, n.schema), o;
1201
1214
  return n.selection.$anchor.sameParent(n.selection.$head) && (o = n.selection.$anchor.parent.attrs), a.isTextblock ? i().command(({ commands: e }) => b(a, {
1202
1215
  ...o,
@@ -1205,13 +1218,13 @@ var mn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
1205
1218
  ...o,
1206
1219
  ...t
1207
1220
  })(e, r)).run() : (console.warn("[tiptap warn]: Currently \"setNode()\" only supports text block nodes."), !1);
1208
- }, _n = (e) => ({ tr: t, dispatch: n }) => {
1221
+ }, yn = (e) => ({ tr: t, dispatch: n }) => {
1209
1222
  if (n) {
1210
- let { doc: n } = t, r = P(e, 0, n.content.size), i = C.create(n, r);
1223
+ let { doc: n } = t, r = F(e, 0, n.content.size), i = S.create(n, r);
1211
1224
  t.setSelection(i);
1212
1225
  }
1213
1226
  return !0;
1214
- }, vn = (e, t) => ({ tr: n, state: r, dispatch: i }) => {
1227
+ }, bn = (e, t) => ({ tr: n, state: r, dispatch: i }) => {
1215
1228
  let { selection: a } = r, o, s;
1216
1229
  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
1230
  t.isText || n.setNodeMarkup(r, void 0, {
@@ -1219,29 +1232,29 @@ var mn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
1219
1232
  dir: e
1220
1233
  });
1221
1234
  }), !0;
1222
- }, yn = (e) => ({ tr: t, dispatch: n }) => {
1235
+ }, xn = (e) => ({ tr: t, dispatch: n }) => {
1223
1236
  if (n) {
1224
1237
  let { doc: n } = t, { from: r, to: i } = typeof e == "number" ? {
1225
1238
  from: e,
1226
1239
  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);
1240
+ } : e, a = E.atStart(n).from, o = E.atEnd(n).to, s = F(r, a, o), c = F(i, a, o), l = E.create(n, s, c);
1228
1241
  t.setSelection(l);
1229
1242
  }
1230
1243
  return !0;
1231
- }, bn = (e) => ({ state: t, dispatch: n }) => {
1244
+ }, Sn = (e) => ({ state: t, dispatch: n }) => {
1232
1245
  let r = j(e, t.schema);
1233
1246
  return fe(r)(t, n);
1234
1247
  };
1235
- function xn(e, t) {
1248
+ function Cn(e, t) {
1236
1249
  let n = e.storedMarks || e.selection.$to.parentOffset && e.selection.$from.marks();
1237
1250
  if (n) {
1238
1251
  let r = n.filter((e) => t?.includes(e.type.name));
1239
1252
  e.tr.ensureMarks(r);
1240
1253
  }
1241
1254
  }
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);
1255
+ var wn = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor: i }) => {
1256
+ let { selection: o, doc: s } = t, { $from: c, $to: l } = o, u = i.extensionManager.attributes, d = J(u, c.node().type.name, c.node().attrs);
1257
+ if (o instanceof S && o.node.isBlock) return !c.parentOffset || !a(s, c.pos) ? !1 : (r && (e && Cn(n, i.extensionManager.splittableMarks), t.split(c.pos).scrollIntoView()), !0);
1245
1258
  if (!c.parent.isBlock) return !1;
1246
1259
  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 ? [{
1247
1260
  type: p,
@@ -1251,14 +1264,14 @@ var Sn = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
1251
1264
  type: p,
1252
1265
  attrs: d
1253
1266
  }] : 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)) {
1267
+ if (h && (o instanceof E && t.deleteSelection(), t.split(t.mapping.map(c.pos), 1, m), p && !f && !c.parentOffset && c.parent.type !== p)) {
1255
1268
  let e = t.mapping.map(c.before()), n = t.doc.resolve(e);
1256
1269
  c.node(-1).canReplaceWith(n.index(), n.index() + 1, p) && t.setNodeMarkup(t.mapping.map(c.before()), p);
1257
1270
  }
1258
- e && xn(n, i.extensionManager.splittableMarks), t.scrollIntoView();
1271
+ e && Cn(n, i.extensionManager.splittableMarks), t.scrollIntoView();
1259
1272
  }
1260
1273
  return h;
1261
- }, Cn = (e, t = {}) => ({ tr: n, state: r, dispatch: i, editor: o }) => {
1274
+ }, Tn = (e, t = {}) => ({ tr: n, state: r, dispatch: i, editor: o }) => {
1262
1275
  let s = j(e, r.schema), { $from: c, $to: l } = r.selection, u = r.selection.node;
1263
1276
  if (u && u.isBlock || c.depth < 2 || !c.sameParent(l)) return !1;
1264
1277
  let d = c.node(-1);
@@ -1267,28 +1280,28 @@ var Sn = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
1267
1280
  if (c.parent.content.size === 0 && c.node(-1).childCount === c.indexAfter(-1)) {
1268
1281
  if (c.depth === 2 || c.node(-3).type !== s || c.index(-2) !== c.node(-2).childCount - 1) return !1;
1269
1282
  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));
1283
+ let e = D.empty, r = c.index(-1) ? 1 : c.index(-2) ? 2 : 3;
1284
+ for (let t = c.depth - r; t >= c.depth - 3; --t) e = D.from(c.node(t).copy(e));
1272
1285
  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),
1286
+ ...J(f, c.node().type.name, c.node().attrs),
1274
1287
  ...t
1275
1288
  }, o = s.contentMatch.defaultType?.createAndFill(a) || void 0;
1276
- e = e.append(O.from(s.createAndFill(null, o) || void 0));
1289
+ e = e.append(D.from(s.createAndFill(null, o) || void 0));
1277
1290
  let l = c.before(c.depth - (r - 1));
1278
1291
  n.replace(l, c.after(-i), new ue(e, 4 - r, 0));
1279
1292
  let u = -1;
1280
1293
  n.doc.nodesBetween(l, n.doc.content.size, (e, t) => {
1281
1294
  if (u > -1) return !1;
1282
1295
  e.isTextblock && e.content.size === 0 && (u = t + 1);
1283
- }), u > -1 && n.setSelection(D.near(n.doc.resolve(u))), n.scrollIntoView();
1296
+ }), u > -1 && n.setSelection(E.near(n.doc.resolve(u))), n.scrollIntoView();
1284
1297
  }
1285
1298
  return !0;
1286
1299
  }
1287
1300
  let p = l.pos === c.end() ? d.contentMatchAt(0).defaultType : null, m = {
1288
- ...q(f, d.type.name, d.attrs),
1301
+ ...J(f, d.type.name, d.attrs),
1289
1302
  ...t
1290
1303
  }, h = {
1291
- ...q(f, c.node().type.name, c.node().attrs),
1304
+ ...J(f, c.node().type.name, c.node().attrs),
1292
1305
  ...t
1293
1306
  };
1294
1307
  n.delete(c.pos, l.pos);
@@ -1311,65 +1324,65 @@ var Sn = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
1311
1324
  }
1312
1325
  return !0;
1313
1326
  };
1314
- function wn(e) {
1327
+ function En(e) {
1315
1328
  return !e || e === "1" ? null : e;
1316
1329
  }
1317
- function Tn(e, t) {
1318
- return wn(e) === wn(t);
1330
+ function Dn(e, t) {
1331
+ return En(e) === En(t);
1319
1332
  }
1320
- var En = (e, t) => {
1321
- let n = B((e) => e.type === t)(e.selection);
1333
+ var On = (e, t) => {
1334
+ let n = V((e) => e.type === t)(e.selection);
1322
1335
  if (!n) return !0;
1323
1336
  let r = e.doc.resolve(Math.max(0, n.pos - 1)).before(n.depth);
1324
1337
  if (r === void 0) return !0;
1325
1338
  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);
1339
+ return !(n.node.type === a?.type && i(e.doc, n.pos)) || !Dn(n.node.attrs.type, a?.attrs.type) || e.join(n.pos), !0;
1340
+ }, kn = (e, t) => {
1341
+ let n = V((e) => e.type === t)(e.selection);
1329
1342
  if (!n) return !0;
1330
1343
  let r = e.doc.resolve(n.start).after(n.depth);
1331
1344
  if (r === void 0) return !0;
1332
1345
  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;
1346
+ return !(n.node.type === a?.type && i(e.doc, r)) || !Dn(n.node.attrs.type, a?.attrs.type) || e.join(r), !0;
1334
1347
  };
1335
- function On(e) {
1348
+ function An(e) {
1336
1349
  let t = e.doc, n = t.firstChild;
1337
1350
  if (!n) return null;
1338
1351
  let r = t.resolve(1), i = t.resolve(n.nodeSize - 1);
1339
- return D.between(r, i);
1352
+ return E.between(r, i);
1340
1353
  }
1341
- var kn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain: c, commands: l, can: u }) => {
1354
+ var jn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain: c, commands: l, can: u }) => {
1342
1355
  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();
1343
1356
  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) ? {
1357
+ let v = V((e) => cn(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 && cn(y.type.name, d) ? {
1345
1358
  node: y,
1346
1359
  pos: 0,
1347
1360
  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);
1361
+ } : null, x = v ?? b, ae = !!v && _.depth >= 1 && _.depth - v.depth <= 1, oe = !!b;
1362
+ if ((ae || oe) && x) {
1363
+ if (x.node.type === p) return re && oe ? c().command(({ tr: e, dispatch: t }) => {
1364
+ let n = An(e);
1352
1365
  return n ? (e.setSelection(n), t && t(e), !0) : !1;
1353
1366
  }).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();
1367
+ if (cn(x.node.type.name, d) && p.validContent(x.node.content)) return c().command(() => (a.setNodeMarkup(x.pos, p), !0)).command(() => On(a, p)).command(() => kn(a, p)).run();
1355
1368
  }
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(() => {
1369
+ return !n || !ne || !s ? c().command(() => u().wrapInList(p, r) ? !0 : l.clearNodes()).wrapInList(p, r).command(() => On(a, p)).command(() => kn(a, p)).run() : c().command(() => {
1357
1370
  let e = u().wrapInList(p, r), t = ne.filter((e) => f.includes(e.type.name));
1358
1371
  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;
1372
+ }).wrapInList(p, r).command(() => On(a, p)).command(() => kn(a, p)).run();
1373
+ }, Mn = (e, t = {}, n = {}) => ({ state: r, commands: i }) => {
1374
+ let { extendEmptyMarkRange: a = !1 } = n, o = P(e, r.schema);
1375
+ return nn(r, o, t) ? i.unsetMark(o, { extendEmptyMarkRange: a }) : i.setMark(o, t);
1376
+ }, Nn = (e, t, n = {}) => ({ state: r, commands: i }) => {
1377
+ let a = j(e, r.schema), o = j(t, r.schema), s = z(r, a, n), c;
1365
1378
  return r.selection.$anchor.sameParent(r.selection.$head) && (c = r.selection.$anchor.parent.attrs), s ? i.setNode(o, c) : i.setNode(a, {
1366
1379
  ...c,
1367
1380
  ...n
1368
1381
  });
1369
- }, Mn = (e, t = {}) => ({ state: n, commands: r }) => {
1382
+ }, Pn = (e, t = {}) => ({ state: n, commands: r }) => {
1370
1383
  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 }) => {
1384
+ return z(n, i, t) ? r.lift(i) : r.wrapIn(i, t);
1385
+ }, Fn = () => ({ state: e, dispatch: t }) => {
1373
1386
  let n = e.plugins;
1374
1387
  for (let r = 0; r < n.length; r += 1) {
1375
1388
  let i = n[r], a;
@@ -1386,7 +1399,7 @@ var kn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain:
1386
1399
  }
1387
1400
  }
1388
1401
  return !1;
1389
- }, Pn = (e = {}) => ({ tr: t, dispatch: n, editor: r }) => {
1402
+ }, In = (e = {}) => ({ tr: t, dispatch: n, editor: r }) => {
1390
1403
  let { ignoreClearable: i = !1 } = e, { selection: a } = t, { empty: o, ranges: s } = a;
1391
1404
  if (o) return !0;
1392
1405
  let { nonClearableMarks: c } = r.extensionManager;
@@ -1397,27 +1410,27 @@ var kn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain:
1397
1410
  });
1398
1411
  }
1399
1412
  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;
1413
+ }, Ln = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
1414
+ let { extendEmptyMarkRange: a = !1 } = t, { selection: o } = n, s = P(e, r.schema), { $from: c, empty: l, ranges: u } = o;
1402
1415
  if (!i) return !0;
1403
1416
  if (l && a) {
1404
- let { from: e, to: t } = o, r = Le(c, s, c.marks().find((e) => e.type === s)?.attrs);
1417
+ let { from: e, to: t } = o, r = N(c, s, c.marks().find((e) => e.type === s)?.attrs);
1405
1418
  r && (e = r.from, t = r.to), n.removeMark(e, t, s);
1406
1419
  } else u.forEach((e) => {
1407
1420
  n.removeMark(e.$from.pos, e.$to.pos, s);
1408
1421
  });
1409
1422
  return n.removeStoredMark(s), !0;
1410
- }, In = (e) => ({ tr: t, state: n, dispatch: r }) => {
1423
+ }, Rn = (e) => ({ tr: t, state: n, dispatch: r }) => {
1411
1424
  let { selection: i } = n, a, o;
1412
1425
  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
1426
  if (e.isText) return;
1414
1427
  let r = { ...e.attrs };
1415
1428
  delete r.dir, t.setNodeMarkup(n, void 0, r);
1416
1429
  }), !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);
1430
+ }, zn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
1431
+ let a = null, o = null, s = B(typeof e == "string" ? e : e.name, r.schema);
1419
1432
  if (!s) return !1;
1420
- s === "node" && (a = j(e, r.schema)), s === "mark" && (o = N(e, r.schema));
1433
+ s === "node" && (a = j(e, r.schema)), s === "mark" && (o = P(e, r.schema));
1421
1434
  let c = !1;
1422
1435
  return n.selection.ranges.forEach((e) => {
1423
1436
  let s = e.$from.pos, l = e.$to.pos, u, d, f, p;
@@ -1446,13 +1459,29 @@ var kn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain:
1446
1459
  }));
1447
1460
  }));
1448
1461
  }), c;
1449
- }, Rn = (e, t = {}) => ({ state: n, dispatch: r }) => {
1462
+ }, X = new w("__tiptap_decorations__"), Bn = (e) => ({ tr: t, dispatch: n }) => (n && t.setMeta(X, {
1463
+ type: "force",
1464
+ name: e
1465
+ }), !0), Vn = (e, t = {}) => ({ state: n, dispatch: r }) => {
1450
1466
  let i = j(e, n.schema);
1451
1467
  return x(i, t)(n, r);
1452
- }, zn = (e, t = {}) => ({ state: n, dispatch: r }) => {
1468
+ }, Hn = (e, t = {}) => ({ state: n, dispatch: r }) => {
1453
1469
  let i = j(e, n.schema);
1454
1470
  return pe(i, t)(n, r);
1455
- }, Bn = class {
1471
+ }, Z = /* @__PURE__ */ new WeakMap();
1472
+ function Un(e, t) {
1473
+ Z.set(e, (Z.get(e) ?? 0) + 1);
1474
+ try {
1475
+ return t();
1476
+ } finally {
1477
+ let t = (Z.get(e) ?? 1) - 1;
1478
+ t > 0 ? Z.set(e, t) : Z.delete(e);
1479
+ }
1480
+ }
1481
+ function Wn(e) {
1482
+ return Z.has(e);
1483
+ }
1484
+ var Gn = class {
1456
1485
  constructor() {
1457
1486
  this.callbacks = {};
1458
1487
  }
@@ -1476,10 +1505,308 @@ var kn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain:
1476
1505
  removeAllListeners() {
1477
1506
  this.callbacks = {};
1478
1507
  }
1508
+ }, Kn = typeof process < "u" && process.env.NODE_ENV !== "production";
1509
+ function qn(e) {
1510
+ return e.kind === "widget";
1511
+ }
1512
+ function Jn(e, t) {
1513
+ let n = [], r = /* @__PURE__ */ new Set();
1514
+ for (let i of e) i.kind === "widget" && qn(i) && r.add(i.key), n.push(i.toPMDecoration(t));
1515
+ return {
1516
+ decorations: n,
1517
+ widgetKeys: r
1518
+ };
1519
+ }
1520
+ function Yn(e, t, n) {
1521
+ let { decorations: r, widgetKeys: i } = Jn(t, n);
1522
+ return {
1523
+ set: O.create(e, r),
1524
+ widgetKeys: i
1525
+ };
1526
+ }
1527
+ function Xn({ position: e, from: t, to: n, docSize: r }) {
1528
+ return e < t ? !1 : e < n || e === n && n === r;
1529
+ }
1530
+ function Zn({ decorations: e, from: t, to: n, docSize: r, extensionName: i, warnedExtensions: a }) {
1531
+ return e.filter((e) => Xn({
1532
+ position: e.anchor,
1533
+ from: t,
1534
+ to: n,
1535
+ docSize: r
1536
+ }) ? !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));
1537
+ }
1538
+ function Qn(e) {
1539
+ let t = e.spec?.key;
1540
+ return typeof t == "string" ? t : void 0;
1541
+ }
1542
+ function $n(e) {
1543
+ let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
1544
+ for (let r of e.find()) {
1545
+ let e = Qn(r);
1546
+ if (!e) continue;
1547
+ let i = r.spec.extensionName ?? "unknown", a = t.get(e) ?? /* @__PURE__ */ new Set();
1548
+ a.add(i), t.set(e, a), n.set(e, (n.get(e) ?? 0) + 1);
1549
+ }
1550
+ return Array.from(t, ([e, t]) => ({
1551
+ key: e,
1552
+ extensions: t
1553
+ })).filter(({ key: e }) => (n.get(e) ?? 0) > 1);
1554
+ }
1555
+ function er(e) {
1556
+ return e.jsonID === "attr";
1557
+ }
1558
+ function tr(e) {
1559
+ let t = !1;
1560
+ if (e.getMap().forEach(() => {
1561
+ t = !0;
1562
+ }), t || er(e)) return !0;
1563
+ let n = e;
1564
+ return typeof n.from == "number" && typeof n.to == "number";
1565
+ }
1566
+ function nr(e, t) {
1567
+ let n = null, r = 0, i = 0;
1568
+ for (let a = 0; a < e.childCount && !(i > t.to); a += 1) {
1569
+ let o = i + e.child(a).nodeSize;
1570
+ o >= t.from && (n === null && (n = i), r = o), i = o;
1571
+ }
1572
+ return n === null ? null : {
1573
+ from: n,
1574
+ to: r
1575
+ };
1576
+ }
1577
+ function rr(e, t) {
1578
+ if (e.steps.some((e) => !tr(e))) return { type: "full" };
1579
+ let n = Zt(e).map(({ newRange: e }) => e);
1580
+ e.steps.forEach((t, r) => {
1581
+ if (!er(t)) return;
1582
+ let i = e.mapping.slice(r);
1583
+ n.push({
1584
+ from: i.map(t.pos, -1),
1585
+ to: i.map(t.pos + 1)
1586
+ });
1587
+ });
1588
+ let r = [];
1589
+ for (let e of n) {
1590
+ let n = nr(t, e);
1591
+ n && r.push(n);
1592
+ }
1593
+ r.sort((e, t) => e.from - t.from);
1594
+ let i = [];
1595
+ for (let e of r) {
1596
+ let t = i[i.length - 1];
1597
+ t && e.from <= t.to ? t.to = Math.max(t.to, e.to) : i.push({ ...e });
1598
+ }
1599
+ return {
1600
+ type: "ranges",
1601
+ ranges: i
1602
+ };
1603
+ }
1604
+ function ir(e, t, n, r) {
1605
+ return e.map(t, n, { onRemove: (e) => {
1606
+ let t = e?.key;
1607
+ typeof t == "string" && r.delete(t);
1608
+ } });
1609
+ }
1610
+ function ar(e, t, n) {
1611
+ let r = t.decorationSetsByExtension[e] ?? O.empty, i = new Set(t.widgetKeysByExtension[e] ?? []);
1612
+ return {
1613
+ set: ir(r, n.mapping, n.doc, i),
1614
+ widgetKeys: i
1615
+ };
1616
+ }
1617
+ function or(e, t) {
1618
+ let n = Object.values(t).flatMap((e) => e.find());
1619
+ return O.create(e, n);
1620
+ }
1621
+ function sr(e) {
1622
+ let t = /* @__PURE__ */ new Set();
1623
+ for (let n of Object.values(e)) for (let e of n) t.add(e);
1624
+ return t;
1625
+ }
1626
+ function cr(e, t) {
1627
+ switch (t.update ?? "document") {
1628
+ case "document":
1629
+ if (t.createInRange) throw Error(`[tiptap error]: Extension "${e}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);
1630
+ return;
1631
+ case "changedRanges":
1632
+ if (!t.createInRange) throw Error(`[tiptap error]: Extension "${e}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);
1633
+ return;
1634
+ case "manual":
1635
+ 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.`);
1636
+ if (t.shouldUpdate) throw Error(`[tiptap error]: Extension "${e}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);
1637
+ return;
1638
+ default: throw Error(`[tiptap error]: Extension "${e}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`);
1639
+ }
1640
+ }
1641
+ function lr(e, t, n) {
1642
+ return n ? !0 : e.update === "manual" ? !1 : e.shouldUpdate ? e.shouldUpdate(t) : t.tr.docChanged;
1643
+ }
1644
+ var ur = /* @__PURE__ */ new Set(), dr = class {
1645
+ constructor(e) {
1646
+ this.warnedWidgetKeys = /* @__PURE__ */ new Set(), this.warnedOutOfRangeExtensions = /* @__PURE__ */ new Set(), this.handleBeforeTransaction = ({ nextState: e }) => {
1647
+ let t = X.getState(e);
1648
+ t && this.warnDuplicateWidgetKeys(t);
1649
+ }, this.editor = e.editor, this.entries = this.resolveEntries(e.entries), this.entries.forEach(({ name: e, spec: t }) => cr(e, t)), this.plugin = this.entries.length > 0 ? this.createPlugin() : null, this.editor.on("beforeTransaction", this.handleBeforeTransaction);
1650
+ }
1651
+ destroy() {
1652
+ this.editor.off("beforeTransaction", this.handleBeforeTransaction);
1653
+ }
1654
+ liveWidgetKeys() {
1655
+ return X.getState(this.editor.state)?.widgetKeys ?? ur;
1656
+ }
1657
+ get mountedView() {
1658
+ return this.editor.isDestroyed ? null : this.editor.view;
1659
+ }
1660
+ resolveEntries(e) {
1661
+ let t = [];
1662
+ for (let { name: n, addDecorations: r } of e) {
1663
+ let e = r();
1664
+ e && t.push({
1665
+ name: n,
1666
+ spec: e
1667
+ });
1668
+ }
1669
+ return t;
1670
+ }
1671
+ createPlugin() {
1672
+ let { editor: e, entries: t } = this;
1673
+ return new C({
1674
+ key: X,
1675
+ state: {
1676
+ init: (e, n) => {
1677
+ let r = {}, i = {};
1678
+ for (let { name: e, spec: a } of t) {
1679
+ let { set: t, widgetKeys: o } = this.buildFullSet(e, a, n);
1680
+ r[e] = t, i[e] = o;
1681
+ }
1682
+ let a = {
1683
+ decorationSetsByExtension: r,
1684
+ widgetKeysByExtension: i,
1685
+ mergedDecorationSet: this.buildMergedSet(n.doc, r),
1686
+ widgetKeys: sr(i)
1687
+ };
1688
+ return this.warnDuplicateWidgetKeys(a), a;
1689
+ },
1690
+ apply: (n, r, i, a) => {
1691
+ let o = n.getMeta(X), s = o?.type === "force" && !o.name, c = o?.type === "force" ? o.name : void 0, l = {}, u = {}, d = /* @__PURE__ */ new Set();
1692
+ return Un(e, () => {
1693
+ for (let { name: o, spec: f } of t) {
1694
+ let t = s || c === o;
1695
+ if (!lr(f, {
1696
+ editor: e,
1697
+ tr: n,
1698
+ oldState: i,
1699
+ newState: a
1700
+ }, t)) {
1701
+ let e = ar(o, r, n);
1702
+ l[o] = e.set, u[o] = e.widgetKeys;
1703
+ } else if (f.update === "changedRanges" && n.docChanged && !t) {
1704
+ let e = this.applyChangedRangesRecompute(o, f, r, n, a);
1705
+ l[o] = e.set, u[o] = e.widgetKeys, d.add(o);
1706
+ } else {
1707
+ let { set: e, widgetKeys: t } = this.buildFullSet(o, f, a);
1708
+ l[o] = e, u[o] = t, d.add(o);
1709
+ }
1710
+ }
1711
+ }), d.size === 0 && !n.docChanged ? r : {
1712
+ decorationSetsByExtension: l,
1713
+ widgetKeysByExtension: u,
1714
+ mergedDecorationSet: this.mergeAfterApply({
1715
+ entries: t,
1716
+ previous: r,
1717
+ tr: n,
1718
+ decorationSetsByExtension: l,
1719
+ recomputedNames: d
1720
+ }),
1721
+ widgetKeys: sr(u)
1722
+ };
1723
+ }
1724
+ },
1725
+ props: { decorations(e) {
1726
+ return X.getState(e)?.mergedDecorationSet ?? O.empty;
1727
+ } }
1728
+ });
1729
+ }
1730
+ applyChangedRangesRecompute(e, t, n, r, i) {
1731
+ let a = rr(r, i.doc);
1732
+ return a.type === "full" ? this.buildFullSet(e, t, i) : this.rebuildRanges(e, t, n, r, i, a.ranges);
1733
+ }
1734
+ rebuildRanges(e, t, n, r, i, a) {
1735
+ let o = n.decorationSetsByExtension[e] ?? O.empty, s = new Set(n.widgetKeysByExtension[e] ?? []), c = ir(o, r.mapping, r.doc, s), l = i.doc.content.size;
1736
+ for (let { from: n, to: r } of a) {
1737
+ let a = c.find(n, r).filter((e) => Xn({
1738
+ position: e.from,
1739
+ from: n,
1740
+ to: r,
1741
+ docSize: l
1742
+ }));
1743
+ for (let e of a) {
1744
+ let t = Qn(e);
1745
+ t && s.delete(t);
1746
+ }
1747
+ c = c.remove(a);
1748
+ let { decorations: o, widgetKeys: u } = Jn(Zn({
1749
+ decorations: this.runCreate(e, "createInRange", () => t.createInRange({
1750
+ editor: this.editor,
1751
+ state: i,
1752
+ view: this.mountedView,
1753
+ from: n,
1754
+ to: r
1755
+ })),
1756
+ from: n,
1757
+ to: r,
1758
+ docSize: l,
1759
+ extensionName: e,
1760
+ warnedExtensions: this.warnedOutOfRangeExtensions
1761
+ }), e);
1762
+ c = c.add(i.doc, o);
1763
+ for (let e of u) s.add(e);
1764
+ }
1765
+ return {
1766
+ set: c,
1767
+ widgetKeys: s
1768
+ };
1769
+ }
1770
+ buildFullSet(e, t, n) {
1771
+ let r = this.runCreate(e, "create", () => t.create({
1772
+ editor: this.editor,
1773
+ state: n,
1774
+ view: this.mountedView
1775
+ }));
1776
+ return Yn(n.doc, r, e);
1777
+ }
1778
+ runCreate(e, t, n) {
1779
+ try {
1780
+ return n();
1781
+ } catch (n) {
1782
+ return console.error(`[tiptap error]: Extension "${e}" threw in \`addDecorations().${t}()\`. Its decorations were dropped for this update.`, n), [];
1783
+ }
1784
+ }
1785
+ warnDuplicateWidgetKeys(e) {
1786
+ if (!Kn) return;
1787
+ if (e.widgetKeys.size === 0) {
1788
+ this.warnedWidgetKeys.clear();
1789
+ return;
1790
+ }
1791
+ let t = $n(e.mergedDecorationSet), n = new Set(t.map(({ key: e }) => e));
1792
+ for (let { key: e, extensions: n } of t) {
1793
+ if (this.warnedWidgetKeys.has(e)) continue;
1794
+ let t = Array.from(n).map((e) => `"${e}"`).join(", ");
1795
+ 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}\`).`);
1796
+ }
1797
+ this.warnedWidgetKeys = n;
1798
+ }
1799
+ buildMergedSet(e, t) {
1800
+ let n = Object.keys(t);
1801
+ return n.length === 1 ? t[n[0]] : or(e, t);
1802
+ }
1803
+ mergeAfterApply({ entries: e, previous: t, tr: n, decorationSetsByExtension: r, recomputedNames: i }) {
1804
+ return e.length === 1 ? r[e[0].name] : i.size === 0 ? t.mergedDecorationSet.map(n.mapping, n.doc) : or(n.doc, r);
1805
+ }
1479
1806
  };
1480
- function Vn(e, t) {
1807
+ function fr(e, t) {
1481
1808
  let { selection: n } = e, { $from: r } = n;
1482
- if (n instanceof C) {
1809
+ if (n instanceof S) {
1483
1810
  let e = r.index();
1484
1811
  return r.parent.canReplaceWith(e, e + 1, t);
1485
1812
  }
@@ -1491,16 +1818,16 @@ function Vn(e, t) {
1491
1818
  }
1492
1819
  return !1;
1493
1820
  }
1494
- function Hn(e, t, n) {
1821
+ function pr(e, t, n) {
1495
1822
  let r = document.querySelector(`style[data-tiptap-style${n ? `-${n}` : ""}]`);
1496
1823
  if (r !== null) return r;
1497
1824
  let i = document.createElement("style");
1498
1825
  return t && i.setAttribute("nonce", t), i.setAttribute(`data-tiptap-style${n ? `-${n}` : ""}`, ""), i.innerHTML = e, document.getElementsByTagName("head")[0].appendChild(i), i;
1499
1826
  }
1500
- function Un(e) {
1827
+ function mr(e) {
1501
1828
  return e.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
1502
1829
  }
1503
- function Wn(e, t) {
1830
+ function hr(e, t) {
1504
1831
  let n = e.getAttribute("style");
1505
1832
  if (!n) return null;
1506
1833
  let r = n.split(";").map((e) => e.trim()).filter(Boolean), i = t.toLowerCase();
@@ -1510,28 +1837,28 @@ function Wn(e, t) {
1510
1837
  }
1511
1838
  return null;
1512
1839
  }
1513
- function Gn() {
1840
+ function gr() {
1514
1841
  return typeof navigator < "u" && /Firefox/.test(navigator.userAgent);
1515
1842
  }
1516
- function Kn(e) {
1843
+ function _r(e) {
1517
1844
  return typeof e == "number";
1518
1845
  }
1519
- function qn(e) {
1846
+ function vr(e) {
1520
1847
  return Object.prototype.toString.call(e).slice(8, -1);
1521
1848
  }
1522
- function Y(e) {
1523
- return qn(e) === "Object" && e.constructor === Object && Object.getPrototypeOf(e) === Object.prototype;
1849
+ function yr(e) {
1850
+ return vr(e) === "Object" && e.constructor === Object && Object.getPrototypeOf(e) === Object.prototype;
1524
1851
  }
1525
1852
  _e({}, {
1526
- createAtomBlockMarkdownSpec: () => Xn,
1527
- createBlockMarkdownSpec: () => Zn,
1528
- createInlineMarkdownSpec: () => er,
1529
- parseAttributes: () => Jn,
1530
- parseIndentedBlocks: () => tr,
1531
- renderNestedMarkdownContent: () => nr,
1532
- serializeAttributes: () => Yn
1853
+ createAtomBlockMarkdownSpec: () => Sr,
1854
+ createBlockMarkdownSpec: () => Cr,
1855
+ createInlineMarkdownSpec: () => Er,
1856
+ parseAttributes: () => br,
1857
+ parseIndentedBlocks: () => Dr,
1858
+ renderNestedMarkdownContent: () => Or,
1859
+ serializeAttributes: () => xr
1533
1860
  });
1534
- function Jn(e) {
1861
+ function br(e) {
1535
1862
  if (!e?.trim()) return {};
1536
1863
  let t = {}, n = [], r = e.replace(/["']([^"']*)["']/g, (e) => (n.push(e), `__QUOTED_${n.length - 1}__`)), i = r.match(/(?:^|\s)\.([\w-]+)/g);
1537
1864
  i && (t.class = i.map((e) => e.trim().slice(1)).join(" "));
@@ -1545,15 +1872,15 @@ function Jn(e) {
1545
1872
  e.match(/^[a-zA-Z][\w-]*$/) && (t[e] = !0);
1546
1873
  }), t;
1547
1874
  }
1548
- function Yn(e) {
1875
+ function xr(e) {
1549
1876
  if (!e || Object.keys(e).length === 0) return "";
1550
1877
  let t = [];
1551
1878
  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
1879
  e !== "class" && e !== "id" && (n === !0 ? t.push(e) : n !== !1 && n != null && t.push(`${e}="${String(n)}"`));
1553
1880
  }), t.join(" ");
1554
1881
  }
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) => {
1882
+ function Sr(e) {
1883
+ let { nodeName: t, name: n, parseAttributes: r = br, serializeAttributes: i = xr, defaultAttributes: a = {}, requiredAttributes: o = [], allowedAttributes: s } = e, c = n || t, l = (e) => {
1557
1884
  if (!s) return e;
1558
1885
  let t = {};
1559
1886
  return s.forEach((n) => {
@@ -1592,8 +1919,8 @@ function Xn(e) {
1592
1919
  }
1593
1920
  };
1594
1921
  }
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) => {
1922
+ function Cr(e) {
1923
+ 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
1924
  if (!c) return e;
1598
1925
  let t = {};
1599
1926
  return c.forEach((n) => {
@@ -1669,7 +1996,7 @@ ${o}
1669
1996
  }
1670
1997
  };
1671
1998
  }
1672
- function Qn(e) {
1999
+ function wr(e) {
1673
2000
  if (!e.trim()) return {};
1674
2001
  let t = {}, n = /(\w+)=(?:"([^"]*)"|'([^']*)')/g, r = n.exec(e);
1675
2002
  for (; r !== null;) {
@@ -1678,11 +2005,11 @@ function Qn(e) {
1678
2005
  }
1679
2006
  return t;
1680
2007
  }
1681
- function $n(e) {
2008
+ function Tr(e) {
1682
2009
  return Object.entries(e).filter(([, e]) => e != null).map(([e, t]) => `${e}="${t}"`).join(" ");
1683
2010
  }
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) => {
2011
+ function Er(e) {
2012
+ 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
2013
  if (!c) return e;
1687
2014
  let t = {};
1688
2015
  return c.forEach((n) => {
@@ -1739,7 +2066,7 @@ function er(e) {
1739
2066
  }
1740
2067
  };
1741
2068
  }
1742
- function tr(e, t, n) {
2069
+ function Dr(e, t, n) {
1743
2070
  let r = e.split("\n"), i = [], a = "", o = 0, s = t.baseIndentSize || 2;
1744
2071
  for (; o < r.length;) {
1745
2072
  let e = r[o], c = e.match(t.itemPattern);
@@ -1785,7 +2112,7 @@ function tr(e, t, n) {
1785
2112
  raw: a
1786
2113
  };
1787
2114
  }
1788
- function nr(e, t, n, r) {
2115
+ function Or(e, t, n, r) {
1789
2116
  if (!e || !Array.isArray(e.content)) return "";
1790
2117
  let i = typeof n == "function" ? n(r) : n, [a, ...o] = e.content, s = `${i}${t.renderChildren([a])}`;
1791
2118
  return o && o.length > 0 && o.forEach((e, n) => {
@@ -1799,13 +2126,13 @@ ${n}`;
1799
2126
  }
1800
2127
  }), s;
1801
2128
  }
1802
- function rr(e, t) {
2129
+ function kr(e, t) {
1803
2130
  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];
2131
+ return yr(e) && yr(t) && Object.keys(t).forEach((r) => {
2132
+ yr(t[r]) && yr(e[r]) ? n[r] = kr(e[r], t[r]) : n[r] = t[r];
1806
2133
  }), n;
1807
2134
  }
1808
- function ir(e, t, n = {}) {
2135
+ function Ar(e, t, n = {}) {
1809
2136
  let { state: r } = t, { doc: i, tr: a } = r, o = e;
1810
2137
  i.descendants((t, r) => {
1811
2138
  let i = a.mapping.map(r), s = a.mapping.map(r) + t.nodeSize, c = null;
@@ -1825,26 +2152,26 @@ function ir(e, t, n = {}) {
1825
2152
  }
1826
2153
  }), a.docChanged && t.view.dispatch(a);
1827
2154
  }
1828
- var X = class {
2155
+ var Q = class {
1829
2156
  constructor(e) {
1830
2157
  this.find = e.find, this.handler = e.handler, this.undoable = e.undoable ?? !0;
1831
2158
  }
1832
- }, ar = (e, t) => {
2159
+ }, jr = (e, t) => {
1833
2160
  if (Pe(t)) return t.exec(e);
1834
2161
  let n = t(e);
1835
2162
  if (!n) return null;
1836
2163
  let r = [n.text];
1837
2164
  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
2165
  };
1839
- function Z(e) {
2166
+ function Mr(e) {
1840
2167
  let { editor: t, from: n, to: r, text: i, rules: a, plugin: o } = e, { view: s } = t;
1841
2168
  if (s.composing) return !1;
1842
2169
  let c = s.state.doc.resolve(n);
1843
2170
  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;
2171
+ let l = !1, u = tn(c) + i;
1845
2172
  return a.forEach((e) => {
1846
2173
  if (l) return;
1847
- let a = ar(u, e.find);
2174
+ let a = jr(u, e.find);
1848
2175
  if (!a) return;
1849
2176
  let d = a[0].length - i.length;
1850
2177
  if (d > 0) {
@@ -1876,8 +2203,8 @@ function Z(e) {
1876
2203
  }), s.dispatch(f), l = !0);
1877
2204
  }), l;
1878
2205
  }
1879
- function or(e) {
1880
- let { editor: t, rules: n } = e, r = new w({
2206
+ function Nr(e) {
2207
+ let { editor: t, rules: n } = e, r = new C({
1881
2208
  state: {
1882
2209
  init() {
1883
2210
  return null;
@@ -1888,9 +2215,9 @@ function or(e) {
1888
2215
  let s = e.getMeta("applyInputRules");
1889
2216
  return s && setTimeout(() => {
1890
2217
  let { text: e } = s;
1891
- e = typeof e == "string" ? e : At(O.from(e), a.schema);
2218
+ e = typeof e == "string" ? e : At(D.from(e), a.schema);
1892
2219
  let { from: i } = s, o = i + e.length;
1893
- Z({
2220
+ Mr({
1894
2221
  editor: t,
1895
2222
  from: i,
1896
2223
  to: o,
@@ -1903,7 +2230,7 @@ function or(e) {
1903
2230
  },
1904
2231
  props: {
1905
2232
  handleTextInput(e, i, a, o) {
1906
- return Z({
2233
+ return Mr({
1907
2234
  editor: t,
1908
2235
  from: i,
1909
2236
  to: a,
@@ -1914,7 +2241,7 @@ function or(e) {
1914
2241
  },
1915
2242
  handleDOMEvents: { compositionend: (e) => (setTimeout(() => {
1916
2243
  let { $cursor: i } = e.state.selection;
1917
- i && Z({
2244
+ i && Mr({
1918
2245
  editor: t,
1919
2246
  from: i.pos,
1920
2247
  to: i.pos,
@@ -1926,7 +2253,7 @@ function or(e) {
1926
2253
  handleKeyDown(e, i) {
1927
2254
  if (i.key !== "Enter") return !1;
1928
2255
  let { $cursor: a } = e.state.selection;
1929
- return a ? Z({
2256
+ return a ? Mr({
1930
2257
  editor: t,
1931
2258
  from: a.pos,
1932
2259
  to: a.pos,
@@ -1940,7 +2267,7 @@ function or(e) {
1940
2267
  });
1941
2268
  return r;
1942
2269
  }
1943
- var sr = class {
2270
+ var Pr = class {
1944
2271
  constructor(e = {}) {
1945
2272
  this.type = "extendable", this.parent = null, this.child = null, this.name = "", this.config = { name: this.name }, this.config = {
1946
2273
  ...this.config,
@@ -1948,10 +2275,10 @@ var sr = class {
1948
2275
  }, this.name = this.config.name;
1949
2276
  }
1950
2277
  get options() {
1951
- return { ...H(V(this, "addOptions", { name: this.name })) };
2278
+ return { ...U(H(this, "addOptions", { name: this.name })) };
1952
2279
  }
1953
2280
  get storage() {
1954
- return { ...H(V(this, "addStorage", {
2281
+ return { ...U(H(this, "addStorage", {
1955
2282
  name: this.name,
1956
2283
  options: this.options
1957
2284
  })) };
@@ -1959,7 +2286,7 @@ var sr = class {
1959
2286
  configure(e = {}) {
1960
2287
  let t = this.extend({
1961
2288
  ...this.config,
1962
- addOptions: () => rr(this.options, e)
2289
+ addOptions: () => kr(this.options, e)
1963
2290
  });
1964
2291
  return t.name = this.name, t.parent = this.parent, this.child = null, t;
1965
2292
  }
@@ -1970,7 +2297,7 @@ var sr = class {
1970
2297
  });
1971
2298
  return t.parent = this, this.child = t, t.name = "name" in e ? e.name : t.parent.name, t;
1972
2299
  }
1973
- }, cr = class e extends sr {
2300
+ }, Fr = class e extends Pr {
1974
2301
  constructor() {
1975
2302
  super(...arguments), this.type = "mark";
1976
2303
  }
@@ -1995,11 +2322,11 @@ var sr = class {
1995
2322
  let t = typeof e == "function" ? e() : e;
1996
2323
  return super.extend(t);
1997
2324
  }
1998
- }, lr = class {
2325
+ }, Ir = class {
1999
2326
  constructor(e) {
2000
2327
  this.find = e.find, this.handler = e.handler;
2001
2328
  }
2002
- }, ur = (e, t, n) => {
2329
+ }, Lr = (e, t, n) => {
2003
2330
  if (Pe(t)) return [...e.matchAll(t)];
2004
2331
  let r = t(e, n);
2005
2332
  return r ? r.map((t) => {
@@ -2007,7 +2334,7 @@ var sr = class {
2007
2334
  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
2335
  }) : [];
2009
2336
  };
2010
- function dr(e) {
2337
+ function Rr(e) {
2011
2338
  let { editor: t, state: n, from: r, to: i, rule: a, pasteEvent: o, dropEvent: s } = e, { commands: c, chain: l, can: u } = new A({
2012
2339
  editor: t,
2013
2340
  state: n
@@ -2015,7 +2342,7 @@ function dr(e) {
2015
2342
  return n.doc.nodesBetween(r, i, (e, t) => {
2016
2343
  if (e.type?.spec?.code || !(e.isText || e.isTextblock || e.isInline)) return;
2017
2344
  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) => {
2345
+ p >= m || Lr(e.isText ? e.text || "" : e.textBetween(p - t, m - t, void 0, ""), a.find, o).forEach((e) => {
2019
2346
  if (e.index === void 0) return;
2020
2347
  let t = p + e.index + 1, r = t + e[0].length, i = {
2021
2348
  from: n.tr.mapping.map(t),
@@ -2034,12 +2361,12 @@ function dr(e) {
2034
2361
  });
2035
2362
  }), d.every((e) => e !== null);
2036
2363
  }
2037
- var fr = null, pr = (e) => {
2364
+ var zr = null, Br = (e) => {
2038
2365
  var t;
2039
2366
  let n = new ClipboardEvent("paste", { clipboardData: new DataTransfer() });
2040
2367
  return (t = n.clipboardData) == null || t.setData("text/html", e), n;
2041
2368
  };
2042
- function mr(e) {
2369
+ function Vr(e) {
2043
2370
  let { editor: t, rules: n } = e, r = null, i = !1, a = !1, o = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, s;
2044
2371
  try {
2045
2372
  s = typeof DragEvent < "u" ? new DragEvent("drop") : null;
@@ -2051,7 +2378,7 @@ function mr(e) {
2051
2378
  state: e,
2052
2379
  transaction: c
2053
2380
  });
2054
- if (!(!dr({
2381
+ if (!(!Rr({
2055
2382
  editor: t,
2056
2383
  state: l,
2057
2384
  from: Math.max(n - 1, 0),
@@ -2068,12 +2395,12 @@ function mr(e) {
2068
2395
  return o = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, c;
2069
2396
  }
2070
2397
  };
2071
- return n.map((e) => new w({
2398
+ return n.map((e) => new C({
2072
2399
  view(e) {
2073
2400
  let n = (n) => {
2074
- r = e.dom.parentElement?.contains(n.target) ? e.dom.parentElement : null, r && (fr = t);
2401
+ r = e.dom.parentElement?.contains(n.target) ? e.dom.parentElement : null, r && (zr = t);
2075
2402
  }, i = () => {
2076
- fr &&= null;
2403
+ zr &&= null;
2077
2404
  };
2078
2405
  return window.addEventListener("dragstart", n), window.addEventListener("dragend", i), { destroy() {
2079
2406
  window.removeEventListener("dragstart", n), window.removeEventListener("dragend", i);
@@ -2082,7 +2409,7 @@ function mr(e) {
2082
2409
  props: { handleDOMEvents: {
2083
2410
  drop: (e, t) => {
2084
2411
  if (a = r === e.dom.parentElement, s = t, !a) {
2085
- let e = fr;
2412
+ let e = zr;
2086
2413
  e?.isEditable && setTimeout(() => {
2087
2414
  let t = e.state.selection;
2088
2415
  t && e.commands.deleteRange({
@@ -2103,8 +2430,8 @@ function mr(e) {
2103
2430
  if (!l && !u && !f) return;
2104
2431
  if (f) {
2105
2432
  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);
2433
+ t = typeof t == "string" ? t : At(D.from(t), r.schema);
2434
+ let { from: n } = d, i = n + t.length, a = Br(t);
2108
2435
  return c({
2109
2436
  rule: e,
2110
2437
  state: r,
@@ -2114,7 +2441,7 @@ function mr(e) {
2114
2441
  });
2115
2442
  }
2116
2443
  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({
2444
+ if (!(!_r(p) || !m || p === m.b)) return c({
2118
2445
  rule: e,
2119
2446
  state: r,
2120
2447
  from: p,
@@ -2124,18 +2451,18 @@ function mr(e) {
2124
2451
  }
2125
2452
  }));
2126
2453
  }
2127
- var Q = class {
2454
+ var Hr = class {
2128
2455
  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();
2456
+ this.splittableMarks = [], this.nonClearableMarks = [], this.decorationManager = null, this.editor = t, this.baseExtensions = e, this.extensions = Ut(e), this.schema = Vt(this.extensions, t), this.setupExtensions();
2130
2457
  }
2131
2458
  get commands() {
2132
2459
  return this.extensions.reduce((e, t) => {
2133
- let n = V(t, "addCommands", {
2460
+ let n = H(t, "addCommands", {
2134
2461
  name: t.name,
2135
2462
  options: t.options,
2136
2463
  storage: this.editor.extensionStorage[t.name],
2137
2464
  editor: this.editor,
2138
- type: K(t.name, this.schema)
2465
+ type: q(t.name, this.schema)
2139
2466
  });
2140
2467
  return n ? {
2141
2468
  ...e,
@@ -2144,16 +2471,15 @@ var Q = class {
2144
2471
  }, {});
2145
2472
  }
2146
2473
  get plugins() {
2147
- let { editor: e } = this;
2148
- return G([...this.extensions].reverse()).flatMap((t) => {
2474
+ let { editor: e } = this, t = K([...this.extensions].reverse()).flatMap((t) => {
2149
2475
  let n = {
2150
2476
  name: t.name,
2151
2477
  options: t.options,
2152
2478
  storage: this.editor.extensionStorage[t.name],
2153
2479
  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({
2480
+ type: q(t.name, this.schema)
2481
+ }, r = [], i = H(t, "addKeyboardShortcuts", n), a = {};
2482
+ if (t.type === "mark" && H(t, "exitable", n) && (a.ArrowRight = () => Fr.handleExit({
2157
2483
  editor: e,
2158
2484
  mark: t
2159
2485
  })), i) {
@@ -2165,43 +2491,66 @@ var Q = class {
2165
2491
  }
2166
2492
  let o = he(a);
2167
2493
  r.push(o);
2168
- let s = V(t, "addInputRules", n);
2169
- if (on(t, e.options.enableInputRules) && s) {
2494
+ let s = H(t, "addInputRules", n);
2495
+ if (sn(t, e.options.enableInputRules) && s) {
2170
2496
  let t = s();
2171
2497
  if (t && t.length) {
2172
- let n = or({
2498
+ let n = Nr({
2173
2499
  editor: e,
2174
2500
  rules: t
2175
2501
  }), i = Array.isArray(n) ? n : [n];
2176
2502
  r.push(...i);
2177
2503
  }
2178
2504
  }
2179
- let c = V(t, "addPasteRules", n);
2180
- if (on(t, e.options.enablePasteRules) && c) {
2505
+ let c = H(t, "addPasteRules", n);
2506
+ if (sn(t, e.options.enablePasteRules) && c) {
2181
2507
  let t = c();
2182
2508
  if (t && t.length) {
2183
- let n = mr({
2509
+ let n = Vr({
2184
2510
  editor: e,
2185
2511
  rules: t
2186
2512
  });
2187
2513
  r.push(...n);
2188
2514
  }
2189
2515
  }
2190
- let l = V(t, "addProseMirrorPlugins", n);
2516
+ let l = H(t, "addProseMirrorPlugins", n);
2191
2517
  if (l) {
2192
2518
  let e = l();
2193
2519
  r.push(...e);
2194
2520
  }
2195
2521
  return r;
2196
- });
2522
+ }), n = this.createDecorationPlugin();
2523
+ return n && t.push(n), t;
2524
+ }
2525
+ createDecorationPlugin() {
2526
+ var e;
2527
+ let { editor: t } = this;
2528
+ (e = this.decorationManager) == null || e.destroy();
2529
+ let n = [];
2530
+ return this.extensions.forEach((e) => {
2531
+ let r = H(e, "addDecorations", {
2532
+ name: e.name,
2533
+ options: e.options,
2534
+ storage: this.editor.extensionStorage[e.name],
2535
+ editor: t,
2536
+ type: q(e.name, this.schema)
2537
+ });
2538
+ r && n.push({
2539
+ name: e.name,
2540
+ addDecorations: r
2541
+ });
2542
+ }), this.decorationManager = new dr({
2543
+ editor: t,
2544
+ entries: n
2545
+ }), this.decorationManager.plugin;
2197
2546
  }
2198
2547
  get attributes() {
2199
2548
  return Nt(this.extensions);
2200
2549
  }
2201
2550
  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", {
2551
+ let { editor: e } = this, { nodeExtensions: t } = W(this.extensions);
2552
+ return Object.fromEntries(t.filter((e) => !!H(e, "addNodeView")).map((t) => {
2553
+ let n = this.attributes.filter((e) => e.type === t.name), r = H(t, "addNodeView", {
2205
2554
  name: t.name,
2206
2555
  options: t.options,
2207
2556
  storage: this.editor.extensionStorage[t.name],
@@ -2211,7 +2560,7 @@ var Q = class {
2211
2560
  if (!r) return [];
2212
2561
  let i = r();
2213
2562
  return i ? [t.name, (r, a, o, s, c) => {
2214
- let l = W(r, n);
2563
+ let l = G(r, n);
2215
2564
  return i({
2216
2565
  node: r,
2217
2566
  view: a,
@@ -2227,14 +2576,14 @@ var Q = class {
2227
2576
  }
2228
2577
  dispatchTransaction(e) {
2229
2578
  let { editor: t } = this;
2230
- return G([...this.extensions].reverse()).reduceRight((e, n) => {
2579
+ return K([...this.extensions].reverse()).reduceRight((e, n) => {
2231
2580
  let r = {
2232
2581
  name: n.name,
2233
2582
  options: n.options,
2234
2583
  storage: this.editor.extensionStorage[n.name],
2235
2584
  editor: t,
2236
- type: K(n.name, this.schema)
2237
- }, i = V(n, "dispatchTransaction", r);
2585
+ type: q(n.name, this.schema)
2586
+ }, i = H(n, "dispatchTransaction", r);
2238
2587
  return i ? (t) => {
2239
2588
  i.call(r, {
2240
2589
  transaction: t,
@@ -2245,14 +2594,14 @@ var Q = class {
2245
2594
  }
2246
2595
  transformPastedHTML(e) {
2247
2596
  let { editor: t } = this;
2248
- return G([...this.extensions]).reduce((e, n) => {
2597
+ return K([...this.extensions]).reduce((e, n) => {
2249
2598
  let r = {
2250
2599
  name: n.name,
2251
2600
  options: n.options,
2252
2601
  storage: this.editor.extensionStorage[n.name],
2253
2602
  editor: t,
2254
- type: K(n.name, this.schema)
2255
- }, i = V(n, "transformPastedHTML", r);
2603
+ type: q(n.name, this.schema)
2604
+ }, i = H(n, "transformPastedHTML", r);
2256
2605
  return i ? (t, n) => {
2257
2606
  let a = e(t, n);
2258
2607
  return i.call(r, a);
@@ -2260,17 +2609,17 @@ var Q = class {
2260
2609
  }, e || ((e) => e));
2261
2610
  }
2262
2611
  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", {
2612
+ let { editor: e } = this, { markExtensions: t } = W(this.extensions);
2613
+ return Object.fromEntries(t.filter((e) => !!H(e, "addMarkView")).map((t) => {
2614
+ let n = this.attributes.filter((e) => e.type === t.name), r = H(t, "addMarkView", {
2266
2615
  name: t.name,
2267
2616
  options: t.options,
2268
2617
  storage: this.editor.extensionStorage[t.name],
2269
2618
  editor: e,
2270
- type: N(t.name, this.schema)
2619
+ type: P(t.name, this.schema)
2271
2620
  });
2272
2621
  return r ? [t.name, (i, a, o) => {
2273
- let s = W(i, n);
2622
+ let s = G(i, n);
2274
2623
  return r()({
2275
2624
  mark: i,
2276
2625
  view: a,
@@ -2279,20 +2628,21 @@ var Q = class {
2279
2628
  extension: t,
2280
2629
  HTMLAttributes: s,
2281
2630
  updateAttributes: (t) => {
2282
- ir(i, e, t);
2631
+ Ar(i, e, t);
2283
2632
  }
2284
2633
  });
2285
2634
  }] : [];
2286
2635
  }));
2287
2636
  }
2288
2637
  destroy() {
2289
- this.extensions.forEach((e) => {
2638
+ var e;
2639
+ (e = this.decorationManager) == null || e.destroy(), this.extensions.forEach((e) => {
2290
2640
  let t = e;
2291
2641
  for (; t.parent;) {
2292
2642
  let e = t.parent;
2293
2643
  e.child === t && (e.child = null), t = e;
2294
2644
  }
2295
- }), this.extensions = [], this.baseExtensions = [], this.schema = null, this.editor = null;
2645
+ }), this.extensions = [], this.baseExtensions = [], this.decorationManager = null, this.schema = null, this.editor = null;
2296
2646
  }
2297
2647
  setupExtensions() {
2298
2648
  let e = this.extensions;
@@ -2302,28 +2652,28 @@ var Q = class {
2302
2652
  options: e.options,
2303
2653
  storage: this.editor.extensionStorage[e.name],
2304
2654
  editor: this.editor,
2305
- type: K(e.name, this.schema)
2655
+ type: q(e.name, this.schema)
2306
2656
  };
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);
2657
+ e.type === "mark" && ((U(H(e, "keepOnSplit", t)) ?? !0) && this.splittableMarks.push(e.name), (U(H(e, "clearable", t)) ?? !0) || this.nonClearableMarks.push(e.name));
2658
+ let n = H(e, "onBeforeCreate", t), r = H(e, "onCreate", t), i = H(e, "onUpdate", t), a = H(e, "onSelectionUpdate", t), o = H(e, "onTransaction", t), s = H(e, "onFocus", t), c = H(e, "onBlur", t), l = H(e, "onDestroy", t);
2309
2659
  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
2660
  });
2311
2661
  }
2312
2662
  };
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
2663
+ Hr.resolve = Ut, Hr.sort = K, Hr.flatten = kt, _e({}, {
2664
+ ClipboardTextSerializer: () => Ur,
2665
+ Commands: () => Wr,
2666
+ Delete: () => Gr,
2667
+ Drop: () => Kr,
2668
+ Editable: () => qr,
2669
+ FocusEvents: () => Yr,
2670
+ Keymap: () => Xr,
2671
+ Paste: () => Zr,
2672
+ Tabindex: () => Qr,
2673
+ TextDirection: () => $r,
2674
+ focusEventsPluginKey: () => Jr
2325
2675
  });
2326
- var $ = class e extends sr {
2676
+ var $ = class e extends Pr {
2327
2677
  constructor() {
2328
2678
  super(...arguments), this.type = "extension";
2329
2679
  }
@@ -2338,14 +2688,14 @@ var $ = class e extends sr {
2338
2688
  let t = typeof e == "function" ? e() : e;
2339
2689
  return super.extend(t);
2340
2690
  }
2341
- }, hr = $.create({
2691
+ }, Ur = $.create({
2342
2692
  name: "clipboardTextSerializer",
2343
2693
  addOptions() {
2344
2694
  return { blockSeparator: void 0 };
2345
2695
  },
2346
2696
  addProseMirrorPlugins() {
2347
- return [new w({
2348
- key: new T("clipboardTextSerializer"),
2697
+ return [new C({
2698
+ key: new w("clipboardTextSerializer"),
2349
2699
  props: { clipboardTextSerializer: () => {
2350
2700
  let { editor: e } = this, { state: t, schema: n } = e, { doc: r, selection: i } = t, a = Kt(n), { blockSeparator: o } = this.options, s = {
2351
2701
  ...o === void 0 ? {} : { blockSeparator: o },
@@ -2358,12 +2708,12 @@ var $ = class e extends sr {
2358
2708
  } }
2359
2709
  })];
2360
2710
  }
2361
- }), gr = $.create({
2711
+ }), Wr = $.create({
2362
2712
  name: "commands",
2363
2713
  addCommands() {
2364
2714
  return { ...ve };
2365
2715
  }
2366
- }), _r = $.create({
2716
+ }), Gr = $.create({
2367
2717
  name: "delete",
2368
2718
  onUpdate({ transaction: t, appendedTransactions: n }) {
2369
2719
  let r = () => {
@@ -2416,11 +2766,11 @@ var $ = class e extends sr {
2416
2766
  };
2417
2767
  this.editor.options.coreExtensionOptions?.delete?.async ?? !0 ? setTimeout(r, 0) : r();
2418
2768
  }
2419
- }), vr = $.create({
2769
+ }), Kr = $.create({
2420
2770
  name: "drop",
2421
2771
  addProseMirrorPlugins() {
2422
- return [new w({
2423
- key: new T("tiptapDrop"),
2772
+ return [new C({
2773
+ key: new w("tiptapDrop"),
2424
2774
  props: { handleDrop: (e, t, n, r) => {
2425
2775
  this.editor.emit("drop", {
2426
2776
  editor: this.editor,
@@ -2431,20 +2781,20 @@ var $ = class e extends sr {
2431
2781
  } }
2432
2782
  })];
2433
2783
  }
2434
- }), yr = $.create({
2784
+ }), qr = $.create({
2435
2785
  name: "editable",
2436
2786
  addProseMirrorPlugins() {
2437
- return [new w({
2438
- key: new T("editable"),
2787
+ return [new C({
2788
+ key: new w("editable"),
2439
2789
  props: { editable: () => this.editor.options.editable }
2440
2790
  })];
2441
2791
  }
2442
- }), br = new T("focusEvents"), xr = $.create({
2792
+ }), Jr = new w("focusEvents"), Yr = $.create({
2443
2793
  name: "focusEvents",
2444
2794
  addProseMirrorPlugins() {
2445
2795
  let { editor: e } = this;
2446
- return [new w({
2447
- key: br,
2796
+ return [new C({
2797
+ key: Jr,
2448
2798
  props: { handleDOMEvents: {
2449
2799
  focus: (t, n) => {
2450
2800
  e.isFocused = !0;
@@ -2459,13 +2809,13 @@ var $ = class e extends sr {
2459
2809
  } }
2460
2810
  })];
2461
2811
  }
2462
- }), Sr = $.create({
2812
+ }), Xr = $.create({
2463
2813
  name: "keymap",
2464
2814
  addKeyboardShortcuts() {
2465
2815
  let e = () => this.editor.commands.first(({ commands: e }) => [
2466
2816
  () => e.undoInputRule(),
2467
2817
  () => 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;
2818
+ 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 : T.atStart(r).from === o;
2469
2819
  return !i || !s.type.isTextblock || s.textContent.length || !d || d && a.parent.type.name === "paragraph" ? !1 : e.clearNodes();
2470
2820
  }),
2471
2821
  () => e.deleteSelection(),
@@ -2501,17 +2851,17 @@ var $ = class e extends sr {
2501
2851
  "Ctrl-a": () => this.editor.commands.selectTextblockStart(),
2502
2852
  "Ctrl-e": () => this.editor.commands.selectTextblockEnd()
2503
2853
  };
2504
- return F() || st() ? i : r;
2854
+ return I() || st() ? i : r;
2505
2855
  },
2506
2856
  addProseMirrorPlugins() {
2507
- return [new w({
2508
- key: new T("clearDocument"),
2857
+ return [new C({
2858
+ key: new w("clearDocument"),
2509
2859
  appendTransaction: (e, t, n) => {
2510
2860
  if (e.some((e) => e.getMeta("composition"))) return;
2511
2861
  let r = e.some((e) => e.docChanged) && !t.doc.eq(n.doc), i = e.some((e) => e.getMeta("preventClearDocument"));
2512
2862
  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;
2863
+ let { empty: a, from: o, to: s } = t.selection, c = T.atStart(t.doc).from, l = T.atEnd(t.doc).to;
2864
+ if (a || o !== c || s !== l || !Y(n.doc)) return;
2515
2865
  let u = n.tr, d = k({
2516
2866
  state: n,
2517
2867
  transaction: u
@@ -2523,11 +2873,11 @@ var $ = class e extends sr {
2523
2873
  }
2524
2874
  })];
2525
2875
  }
2526
- }), Cr = $.create({
2876
+ }), Zr = $.create({
2527
2877
  name: "paste",
2528
2878
  addProseMirrorPlugins() {
2529
- return [new w({
2530
- key: new T("tiptapPaste"),
2879
+ return [new C({
2880
+ key: new w("tiptapPaste"),
2531
2881
  props: { handlePaste: (e, t, n) => {
2532
2882
  this.editor.emit("paste", {
2533
2883
  editor: this.editor,
@@ -2537,25 +2887,25 @@ var $ = class e extends sr {
2537
2887
  } }
2538
2888
  })];
2539
2889
  }
2540
- }), wr = $.create({
2890
+ }), Qr = $.create({
2541
2891
  name: "tabindex",
2542
2892
  addOptions() {
2543
2893
  return { value: void 0 };
2544
2894
  },
2545
2895
  addProseMirrorPlugins() {
2546
- return [new w({
2547
- key: new T("tabindex"),
2896
+ return [new C({
2897
+ key: new w("tabindex"),
2548
2898
  props: { attributes: () => !this.editor.isEditable && this.options.value === void 0 ? {} : { tabindex: this.options.value ?? "0" } }
2549
2899
  })];
2550
2900
  }
2551
- }), Tr = $.create({
2901
+ }), $r = $.create({
2552
2902
  name: "textDirection",
2553
2903
  addOptions() {
2554
2904
  return { direction: void 0 };
2555
2905
  },
2556
2906
  addGlobalAttributes() {
2557
2907
  if (!this.options.direction) return [];
2558
- let { nodeExtensions: e } = U(this.extensions);
2908
+ let { nodeExtensions: e } = W(this.extensions);
2559
2909
  return [{
2560
2910
  types: e.filter((e) => e.name !== "text").map((e) => e.name),
2561
2911
  attributes: { dir: {
@@ -2569,15 +2919,30 @@ var $ = class e extends sr {
2569
2919
  }];
2570
2920
  },
2571
2921
  addProseMirrorPlugins() {
2572
- return [new w({
2573
- key: new T("textDirection"),
2922
+ return [new C({
2923
+ key: new w("textDirection"),
2574
2924
  props: { attributes: () => {
2575
2925
  let e = this.options.direction;
2576
2926
  return e ? { dir: e } : {};
2577
2927
  } }
2578
2928
  })];
2579
2929
  }
2580
- }), Er = class e {
2930
+ }), ei = !1;
2931
+ function ti(e) {
2932
+ if (ei) return;
2933
+ ei = !0;
2934
+ let t;
2935
+ try {
2936
+ t = n.fromJSON(e, {
2937
+ from: 0,
2938
+ to: 0
2939
+ }).slice.content;
2940
+ } catch {
2941
+ return;
2942
+ }
2943
+ t instanceof D || 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.");
2944
+ }
2945
+ var ni = class e {
2581
2946
  constructor(e, t, n = !1, r = null) {
2582
2947
  this.currentNode = null, this.actualDepth = null, this.isBlock = n, this.resolvedPos = e, this.editor = t, this.currentNode = r;
2583
2948
  }
@@ -2699,9 +3064,9 @@ var $ = class e extends sr {
2699
3064
  ...e
2700
3065
  }), this.editor.view.dispatch(t);
2701
3066
  }
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 {
3067
+ }, ri = ".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}", ii = class extends Gn {
2703
3068
  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 = {
3069
+ 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
3070
  element: typeof document < "u" ? document.createElement("div") : null,
2706
3071
  content: "",
2707
3072
  injectCSS: !0,
@@ -2736,19 +3101,19 @@ var $ = class e extends sr {
2736
3101
  onDelete: () => null,
2737
3102
  enableExtensionDispatchTransaction: !0
2738
3103
  }, this.isCapturingTransaction = !1, this.capturedTransaction = null, this.utils = {
2739
- getUpdatedPosition: un,
2740
- createMappablePosition: dn
3104
+ getUpdatedPosition: fn,
3105
+ createMappablePosition: pn
2741
3106
  }, 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
3107
  let t = this.createDoc();
2743
3108
  if (!this.editorState) {
2744
- let e = Ve(t, this.options.autofocus);
2745
- this.editorState = S.create({
3109
+ let e = Be(t, this.options.autofocus);
3110
+ this.editorState = oe.create({
2746
3111
  doc: t,
2747
3112
  schema: this.schema,
2748
3113
  selection: e || void 0
2749
3114
  });
2750
3115
  }
2751
- this.options.element && this.mount(this.options.element);
3116
+ ti(this.schema), this.options.element && this.mount(this.options.element);
2752
3117
  }
2753
3118
  mount(e) {
2754
3119
  if (typeof document > "u") throw Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");
@@ -2758,6 +3123,7 @@ var $ = class e extends sr {
2758
3123
  }
2759
3124
  unmount() {
2760
3125
  if (this.editorView) {
3126
+ this.editorState = this.editorView.state;
2761
3127
  let e = this.editorView.dom;
2762
3128
  e?.editor && delete e.editor, this.editorView.destroy();
2763
3129
  }
@@ -2781,7 +3147,7 @@ var $ = class e extends sr {
2781
3147
  return this.commandManager.can();
2782
3148
  }
2783
3149
  injectCSS() {
2784
- this.options.injectCSS && typeof document < "u" && (this.css = Hn(Dr, this.options.injectNonce));
3150
+ this.options.injectCSS && typeof document < "u" && (this.css = pr(ri, this.options.injectNonce));
2785
3151
  }
2786
3152
  setOptions(e = {}) {
2787
3153
  this.options = {
@@ -2820,7 +3186,7 @@ var $ = class e extends sr {
2820
3186
  } });
2821
3187
  }
2822
3188
  get state() {
2823
- return this.editorView && (this.editorState = this.view.state), this.editorState;
3189
+ return Kn && !this.hasWarnedStaleDecorationRead && Wn(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
3190
  }
2825
3191
  registerPlugin(e, t) {
2826
3192
  let n = jt(t) ? t(e, [...this.state.plugins]) : [...this.state.plugins, e], r = this.state.reconfigure({ plugins: n });
@@ -2838,22 +3204,22 @@ var $ = class e extends sr {
2838
3204
  }
2839
3205
  createExtensionManager() {
2840
3206
  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 })
3207
+ qr,
3208
+ Ur.configure({ blockSeparator: this.options.coreExtensionOptions?.clipboardTextSerializer?.blockSeparator }),
3209
+ Wr,
3210
+ Yr,
3211
+ Xr,
3212
+ Qr.configure({ value: this.options.coreExtensionOptions?.tabindex?.value }),
3213
+ Kr,
3214
+ Zr,
3215
+ Gr,
3216
+ $r.configure({ direction: this.options.textDirection })
2851
3217
  ].filter((e) => typeof this.options.enableCoreExtensions != "object" || this.options.enableCoreExtensions[e.name] !== !1) : [], ...this.options.extensions].filter((e) => [
2852
3218
  "extension",
2853
3219
  "node",
2854
3220
  "mark"
2855
3221
  ].includes(e?.type));
2856
- this.extensionManager = new Q(e, this);
3222
+ this.extensionManager = new Hr(e, this);
2857
3223
  }
2858
3224
  createCommandManager() {
2859
3225
  this.commandManager = new A({ editor: this });
@@ -2868,10 +3234,10 @@ var $ = class e extends sr {
2868
3234
  } catch (e) {
2869
3235
  if (!(e instanceof Error) || !["[tiptap error]: Invalid JSON content", "[tiptap error]: Invalid HTML content"].includes(e.message)) throw e;
2870
3236
  let t = Ct(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: !1 });
2871
- return this.editorState = S.create({
3237
+ return this.editorState = oe.create({
2872
3238
  doc: t,
2873
3239
  schema: this.schema,
2874
- selection: Ve(t, this.options.autofocus) || void 0
3240
+ selection: Be(t, this.options.autofocus) || void 0
2875
3241
  }), this.emit("contentError", {
2876
3242
  editor: this,
2877
3243
  error: e,
@@ -2959,7 +3325,7 @@ var $ = class e extends sr {
2959
3325
  }
2960
3326
  isActive(e, t) {
2961
3327
  let n = typeof e == "string" ? e : null, r = typeof e == "string" ? t : e;
2962
- return nn(this.state, n, r);
3328
+ return rn(this.state, n, r);
2963
3329
  }
2964
3330
  getJSON() {
2965
3331
  return this.state.doc.toJSON();
@@ -2978,7 +3344,7 @@ var $ = class e extends sr {
2978
3344
  });
2979
3345
  }
2980
3346
  get isEmpty() {
2981
- return J(this.state.doc);
3347
+ return Y(this.state.doc);
2982
3348
  }
2983
3349
  destroy() {
2984
3350
  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,17 +3360,17 @@ var $ = class e extends sr {
2994
3360
  }
2995
3361
  $pos(e) {
2996
3362
  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);
3363
+ return new ni(t, this, !1, n);
2998
3364
  }
2999
3365
  get $doc() {
3000
3366
  return this.$pos(0);
3001
3367
  }
3002
3368
  };
3003
- function kr(e) {
3004
- return new X({
3369
+ function ai(e) {
3370
+ return new Q({
3005
3371
  find: e.find,
3006
3372
  handler: ({ state: t, range: n, match: r }) => {
3007
- let i = H(e.getAttributes, void 0, r);
3373
+ let i = U(e.getAttributes, void 0, r);
3008
3374
  if (i === !1 || i === null) return null;
3009
3375
  let { tr: a } = t, o = r[r.length - 1], s = r[0];
3010
3376
  if (o) {
@@ -3018,11 +3384,11 @@ function kr(e) {
3018
3384
  undoable: e.undoable
3019
3385
  });
3020
3386
  }
3021
- function Ar(e) {
3022
- return new X({
3387
+ function oi(e) {
3388
+ return new Q({
3023
3389
  find: e.find,
3024
3390
  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);
3391
+ let i = U(e.getAttributes, void 0, r) || {}, { tr: a } = t, o = n.from, s = n.to, c = e.type.create(i);
3026
3392
  if (r[1]) {
3027
3393
  let e = o + r[0].lastIndexOf(r[1]);
3028
3394
  e > s ? e = s : s = e + r[1].length;
@@ -3037,19 +3403,19 @@ function Ar(e) {
3037
3403
  undoable: e.undoable
3038
3404
  });
3039
3405
  }
3040
- function jr(e) {
3041
- return new X({
3406
+ function si(e) {
3407
+ return new Q({
3042
3408
  find: e.find,
3043
3409
  handler: ({ state: t, range: n, match: r }) => {
3044
- let i = t.doc.resolve(n.from), a = H(e.getAttributes, void 0, r) || {};
3410
+ let i = t.doc.resolve(n.from), a = U(e.getAttributes, void 0, r) || {};
3045
3411
  if (!i.node(-1).canReplaceWith(i.index(-1), i.indexAfter(-1), e.type)) return null;
3046
3412
  t.tr.delete(n.from, n.to).setBlockType(n.from, n.from, e.type, a);
3047
3413
  },
3048
3414
  undoable: e.undoable
3049
3415
  });
3050
3416
  }
3051
- function Mr(e) {
3052
- return new X({
3417
+ function ci(e) {
3418
+ return new Q({
3053
3419
  find: e.find,
3054
3420
  handler: ({ state: t, range: n, match: r }) => {
3055
3421
  let i = e.replace, a = n.from, o = n.to;
@@ -3064,11 +3430,11 @@ function Mr(e) {
3064
3430
  undoable: e.undoable
3065
3431
  });
3066
3432
  }
3067
- function Nr(e) {
3068
- return new X({
3433
+ function li(e) {
3434
+ return new Q({
3069
3435
  find: e.find,
3070
3436
  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);
3437
+ let s = U(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
3438
  if (!u) return null;
3073
3439
  if (c.wrap(l, u), e.keepMarks && e.editor) {
3074
3440
  let { selection: n, storedMarks: r } = t, { splittableMarks: i } = e.editor.extensionManager, a = r || n.$to.parentOffset && n.$from.marks();
@@ -3087,7 +3453,7 @@ function Nr(e) {
3087
3453
  undoable: e.undoable
3088
3454
  });
3089
3455
  }
3090
- var Pr = (e) => "touches" in e, Fr = class {
3456
+ var ui = (e) => "touches" in e, di = class {
3091
3457
  constructor(e) {
3092
3458
  this.directions = [
3093
3459
  "bottom-left",
@@ -3176,7 +3542,7 @@ var Pr = (e) => "touches" in e, Fr = class {
3176
3542
  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
3543
  }
3178
3544
  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);
3545
+ e.preventDefault(), e.stopPropagation(), this.isResizing = !0, this.activeHandle = t, ui(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
3546
  }
3181
3547
  handleResize(e, t) {
3182
3548
  if (!this.activeHandle) return;
@@ -3216,7 +3582,7 @@ var Pr = (e) => "touches" in e, Fr = class {
3216
3582
  height: e / this.aspectRatio
3217
3583
  };
3218
3584
  }
3219
- }, Ir = class e extends sr {
3585
+ }, fi = class e extends Pr {
3220
3586
  constructor() {
3221
3587
  super(...arguments), this.type = "node";
3222
3588
  }
@@ -3231,12 +3597,109 @@ var Pr = (e) => "touches" in e, Fr = class {
3231
3597
  let t = typeof e == "function" ? e() : e;
3232
3598
  return super.extend(t);
3233
3599
  }
3600
+ }, pi = class {
3601
+ constructor(e, t, n) {
3602
+ this.isDragging = !1, this.component = e, this.editor = t.editor, this.options = {
3603
+ stopEvent: null,
3604
+ ignoreMutation: null,
3605
+ ...n
3606
+ }, this.extension = t.extension, this.node = t.node, this.decorations = t.decorations, this.innerDecorations = t.innerDecorations, this.view = t.view, this.HTMLAttributes = t.HTMLAttributes, this.getPos = () => {
3607
+ try {
3608
+ return t.getPos();
3609
+ } catch {
3610
+ return;
3611
+ }
3612
+ }, this.mount();
3613
+ }
3614
+ mount() {}
3615
+ get dom() {
3616
+ return this.editor.view.dom;
3617
+ }
3618
+ get contentDOM() {
3619
+ return null;
3620
+ }
3621
+ onDragStart(e) {
3622
+ var t;
3623
+ let { view: n } = this.editor, r = e.target, i = r.nodeType === 3 ? r.parentElement?.closest("[data-drag-handle]") : r.closest("[data-drag-handle]");
3624
+ if (!this.dom || this.contentDOM?.contains(r) || !i) return;
3625
+ let a = 0, o = 0;
3626
+ if (this.dom !== i) {
3627
+ let t = this.dom.getBoundingClientRect(), n = i.getBoundingClientRect(), r = e.offsetX ?? e.nativeEvent?.offsetX, s = e.offsetY ?? e.nativeEvent?.offsetY;
3628
+ a = n.x - t.x + r, o = n.y - t.y + s;
3629
+ }
3630
+ let s = this.dom.cloneNode(!0);
3631
+ try {
3632
+ let e = this.dom.getBoundingClientRect();
3633
+ s.style.width = `${Math.round(e.width)}px`, s.style.height = `${Math.round(e.height)}px`, s.style.boxSizing = "border-box", s.style.pointerEvents = "none";
3634
+ } catch {}
3635
+ let c = null;
3636
+ try {
3637
+ c = document.createElement("div"), c.style.position = "absolute", c.style.top = "-9999px", c.style.left = "-9999px", c.style.pointerEvents = "none", c.appendChild(s), document.body.appendChild(c), (t = e.dataTransfer) == null || t.setDragImage(s, a, o);
3638
+ } finally {
3639
+ c && setTimeout(() => {
3640
+ try {
3641
+ c?.remove();
3642
+ } catch {}
3643
+ }, 0);
3644
+ }
3645
+ let l = this.getPos();
3646
+ if (typeof l != "number") return;
3647
+ let u = S.create(n.state.doc, l), d = n.state.tr.setSelection(u);
3648
+ n.dispatch(d);
3649
+ }
3650
+ stopEvent(e) {
3651
+ if (!this.dom) return !1;
3652
+ if (typeof this.options.stopEvent == "function") return this.options.stopEvent({ event: e });
3653
+ let t = e.target;
3654
+ if (!(this.dom.contains(t) && !this.contentDOM?.contains(t))) return !1;
3655
+ let n = e.type.startsWith("drag"), r = e.type === "dragover" || e.type === "dragenter", i = e.type === "drop";
3656
+ if (([
3657
+ "INPUT",
3658
+ "BUTTON",
3659
+ "SELECT",
3660
+ "TEXTAREA"
3661
+ ].includes(t.tagName) || t.isContentEditable) && !i && !n) return !0;
3662
+ let { isEditable: a } = this.editor, { isDragging: o } = this, s = !!this.node.type.spec.draggable, c = S.isSelectable(this.node), l = e.type === "copy", u = e.type === "paste", d = e.type === "cut", f = e.type === "mousedown";
3663
+ if (!s && c && n && e.target === this.dom && e.preventDefault(), s && n && !o && e.target === this.dom) return e.preventDefault(), !1;
3664
+ if (s && a && !o && f) {
3665
+ let e = t.closest("[data-drag-handle]");
3666
+ e && (this.dom === e || this.dom.contains(e)) && (this.isDragging = !0, document.addEventListener("dragend", () => {
3667
+ this.isDragging = !1;
3668
+ }, { once: !0 }), document.addEventListener("drop", () => {
3669
+ this.isDragging = !1;
3670
+ }, { once: !0 }), document.addEventListener("mouseup", () => {
3671
+ this.isDragging = !1;
3672
+ }, { once: !0 }));
3673
+ }
3674
+ return !(o || r || i || l || u || d || f && c);
3675
+ }
3676
+ ignoreMutation(e) {
3677
+ return !this.dom || !this.contentDOM ? !0 : typeof this.options.ignoreMutation == "function" ? this.options.ignoreMutation({ mutation: e }) : this.node.isLeaf || this.node.isAtom ? !0 : e.type === "selection" || this.dom.contains(e.target) && e.type === "childList" && (I() || Ve()) && this.editor.isFocused && [...Array.from(e.addedNodes), ...Array.from(e.removedNodes)].every((e) => e.isContentEditable) ? !1 : this.contentDOM === e.target && e.type === "attributes" || !this.contentDOM.contains(e.target);
3678
+ }
3679
+ updateAttributes(e) {
3680
+ this.editor.commands.command(({ tr: t }) => {
3681
+ let n = this.getPos();
3682
+ return typeof n == "number" && (t.setNodeMarkup(n, void 0, {
3683
+ ...this.node.attrs,
3684
+ ...e
3685
+ }), !0);
3686
+ });
3687
+ }
3688
+ deleteNode() {
3689
+ let e = this.getPos();
3690
+ if (typeof e != "number") return;
3691
+ let t = e + this.node.nodeSize;
3692
+ this.editor.commands.deleteRange({
3693
+ from: e,
3694
+ to: t
3695
+ });
3696
+ }
3234
3697
  };
3235
- function Lr(e) {
3236
- return new lr({
3698
+ function mi(e) {
3699
+ return new Ir({
3237
3700
  find: e.find,
3238
3701
  handler: ({ state: t, range: n, match: r, pasteEvent: i }) => {
3239
- let a = H(e.getAttributes, void 0, r, i);
3702
+ let a = U(e.getAttributes, void 0, r, i);
3240
3703
  if (a === !1 || a === null) return null;
3241
3704
  let { tr: o } = t, s = r[r.length - 1], c = r[0], l = n.to;
3242
3705
  if (s) {
@@ -3248,4 +3711,4 @@ function Lr(e) {
3248
3711
  });
3249
3712
  }
3250
3713
  //#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 };
3714
+ export { z as A, mn as B, G as C, an as D, Kt as E, ai as F, ci as H, mi as I, It as L, ln as M, un as N, on as O, ze as P, oi as R, en as S, Gt as T, si as U, Or as V, li as W, H as _, fi as a, $t as b, di as c, Et as d, mr as f, Zt as g, Jt as h, Fr as i, Y as j, gr as k, U as l, Ot as m, $ as n, pi as o, Dt as p, Q as r, Ir as s, ii as t, fr as u, N as v, hr as w, j as x, Qt as y, Dr as z };