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