@quoreadmin/ui 1.7.16 → 1.7.18

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