@burdenoff/microfe-support 2026.1115.1 → 2026.1118.1

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