@lunejs/admin-ui 0.1.4 → 0.2.0

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