@lunejs/admin-ui 0.1.5 → 0.2.1

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