@clevertask/scribe 0.1.19 → 0.1.20
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 +2 -2
- package/dist/{BarMenu-C9tCdvyV.js → BarMenu-sZGqMjQr.js} +1 -1
- package/dist/components/Menu/BarMenu.js +1 -1
- package/dist/components/Menu/BubbleMenu.js +2 -2
- package/dist/components/Menu/CalloutBubbleMenu.js +2 -2
- package/dist/components/Menu/LinkBubbleMenu.js +2 -2
- package/dist/components/Menu/Mobile/ListOptionBar.js +1 -1
- package/dist/components/Menu/TableBubbleMenu.js +2 -2
- package/dist/components/Menu/linkBubbleMenuPlugin.js +1 -1
- package/dist/components/Scribe/extension/callout.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 +2 -2
- package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
- package/dist/components/Scribe/extension/external-link-preview/commands.js +1 -1
- package/dist/components/Scribe/extension/external-link-preview/index.js +1 -1
- package/dist/components/Scribe/extension/external-link-preview/node-view.js +1 -1
- package/dist/components/Scribe/extension/external-link-preview/render-html.js +1 -1
- package/dist/components/Scribe/extension/external-link-preview/schema.js +1 -1
- package/dist/components/Scribe/extension/index.js +1 -1
- package/dist/components/Scribe/extension/resizable-table.js +1 -1
- package/dist/components/Scribe/extension/slashCommand/index.js +2 -2
- package/dist/components/Scribe/extension/slashCommand/renderItems.js +1 -1
- package/dist/components/Scribe/extension/tableOfContents.js +1 -1
- package/dist/components/Scribe/index.js +3 -3
- package/dist/{dist-CzXFZHMF.js → dist-Bm6rBIf2.js} +55 -39
- package/dist/{dist-DRPH9MfF.js → dist-BrbZZTdj.js} +21 -9
- package/dist/{dist-CkWsQ5Lj.js → dist-jjH04EIX.js} +585 -798
- package/dist/{extension-CKcvyrIW.js → extension-BNjzWzJi.js} +2 -2
- package/dist/{extension-link-yMrg9JOz.js → extension-link-7ta0X4tP.js} +2 -2
- package/dist/main.js +1 -1
- package/dist/{markdown-to-html-COv0iaxr.js → markdown-to-html-BSuSwB4B.js} +37 -9
- package/dist/{menus-D1cst_3I.js → menus-i0cEakC3.js} +48 -46
- package/dist/{resizable-table-D0mls3aB.js → resizable-table-DFTyMlVu.js} +27 -30
- package/dist/{schema-extensions-ChhE6XCo.js → schema-extensions-B-U6SbYg.js} +206 -211
- package/dist/schema-extensions.js +1 -1
- package/dist/schema.js +1 -1
- package/dist/utils/index.js +3 -3
- package/dist/utils/markdown-to-html.js +1 -1
- package/package.json +51 -51
|
@@ -1,18 +1,22 @@
|
|
|
1
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
|
|
3
|
-
import { AllSelection as
|
|
4
|
-
import { DOMParser as
|
|
5
|
-
import { liftListItem as
|
|
6
|
-
import { DecorationSet as
|
|
7
|
-
import { keymap as
|
|
8
|
-
//#region node_modules/.pnpm/@tiptap+core@3.30.
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
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 _, liftEmptyBlock as ee, newlineInCode as te, 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, Schema as ce, Slice as le } from "@tiptap/pm/model";
|
|
5
|
+
import { liftListItem as ue, sinkListItem as de, wrapInList as fe } from "@tiptap/pm/schema-list";
|
|
6
|
+
import { DecorationSet as k, EditorView as pe } from "@tiptap/pm/view";
|
|
7
|
+
import { keymap as me } from "@tiptap/pm/keymap";
|
|
8
|
+
//#region node_modules/.pnpm/@tiptap+core@3.30.5_@tiptap+pm@3.30.5/node_modules/@tiptap/core/dist/rolldown-runtime-D7D4PA-g.js
|
|
9
|
+
var he = Object.defineProperty, ge = (e, t) => {
|
|
10
|
+
let n = {};
|
|
11
|
+
for (var r in e) he(n, r, {
|
|
12
|
+
get: e[r],
|
|
12
13
|
enumerable: !0
|
|
13
14
|
});
|
|
15
|
+
return t || he(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
14
16
|
};
|
|
15
|
-
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region node_modules/.pnpm/@tiptap+core@3.30.5_@tiptap+pm@3.30.5/node_modules/@tiptap/core/dist/index.js
|
|
19
|
+
function _e(e) {
|
|
16
20
|
let { state: t, transaction: n } = e, { selection: r } = n, { doc: i } = n, { storedMarks: a } = n;
|
|
17
21
|
return {
|
|
18
22
|
...t,
|
|
@@ -36,7 +40,7 @@ function O(e) {
|
|
|
36
40
|
}
|
|
37
41
|
};
|
|
38
42
|
}
|
|
39
|
-
var
|
|
43
|
+
var A = class e {
|
|
40
44
|
constructor(e) {
|
|
41
45
|
this.editor = e.editor, this.rawCommands = this.editor.extensionManager.commands, this.customState = e.state;
|
|
42
46
|
}
|
|
@@ -96,7 +100,7 @@ var k = class e {
|
|
|
96
100
|
tr: e,
|
|
97
101
|
editor: r,
|
|
98
102
|
view: a,
|
|
99
|
-
state:
|
|
103
|
+
state: _e({
|
|
100
104
|
state: i,
|
|
101
105
|
transaction: e
|
|
102
106
|
}),
|
|
@@ -109,75 +113,12 @@ var k = class e {
|
|
|
109
113
|
};
|
|
110
114
|
return o;
|
|
111
115
|
}
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
createParagraphNear: () => we,
|
|
119
|
-
cut: () => Te,
|
|
120
|
-
deleteCurrentNode: () => Ee,
|
|
121
|
-
deleteNode: () => De,
|
|
122
|
-
deleteRange: () => Oe,
|
|
123
|
-
deleteSelection: () => Me,
|
|
124
|
-
enter: () => Ne,
|
|
125
|
-
exitCode: () => Pe,
|
|
126
|
-
extendMarkRange: () => Re,
|
|
127
|
-
first: () => ze,
|
|
128
|
-
focus: () => Ue,
|
|
129
|
-
forEach: () => We,
|
|
130
|
-
insertContent: () => Ge,
|
|
131
|
-
insertContentAt: () => Xe,
|
|
132
|
-
insertDefaultBlock: () => Qe,
|
|
133
|
-
joinBackward: () => tt,
|
|
134
|
-
joinDown: () => et,
|
|
135
|
-
joinForward: () => nt,
|
|
136
|
-
joinItemBackward: () => rt,
|
|
137
|
-
joinItemForward: () => it,
|
|
138
|
-
joinTextblockBackward: () => at,
|
|
139
|
-
joinTextblockForward: () => ot,
|
|
140
|
-
joinUp: () => $e,
|
|
141
|
-
keyboardShortcut: () => lt,
|
|
142
|
-
lift: () => ut,
|
|
143
|
-
liftEmptyBlock: () => dt,
|
|
144
|
-
liftListItem: () => ft,
|
|
145
|
-
newlineInCode: () => pt,
|
|
146
|
-
resetAttributes: () => ht,
|
|
147
|
-
scrollIntoView: () => gt,
|
|
148
|
-
selectAll: () => _t,
|
|
149
|
-
selectNodeBackward: () => vt,
|
|
150
|
-
selectNodeForward: () => yt,
|
|
151
|
-
selectParentNode: () => bt,
|
|
152
|
-
selectTextblockEnd: () => xt,
|
|
153
|
-
selectTextblockStart: () => St,
|
|
154
|
-
setContent: () => wt,
|
|
155
|
-
setMark: () => gn,
|
|
156
|
-
setMeta: () => _n,
|
|
157
|
-
setNode: () => vn,
|
|
158
|
-
setNodeSelection: () => yn,
|
|
159
|
-
setTextDirection: () => bn,
|
|
160
|
-
setTextSelection: () => xn,
|
|
161
|
-
sinkListItem: () => Sn,
|
|
162
|
-
splitBlock: () => wn,
|
|
163
|
-
splitListItem: () => Tn,
|
|
164
|
-
toggleList: () => jn,
|
|
165
|
-
toggleMark: () => Mn,
|
|
166
|
-
toggleNode: () => Nn,
|
|
167
|
-
toggleWrap: () => Pn,
|
|
168
|
-
undoInputRule: () => Fn,
|
|
169
|
-
unsetAllMarks: () => In,
|
|
170
|
-
unsetMark: () => Ln,
|
|
171
|
-
unsetTextDirection: () => Rn,
|
|
172
|
-
updateAttributes: () => zn,
|
|
173
|
-
updateDecorations: () => Bn,
|
|
174
|
-
wrapIn: () => Vn,
|
|
175
|
-
wrapInList: () => Hn
|
|
176
|
-
});
|
|
177
|
-
var be = () => ({ editor: e, view: t }) => (requestAnimationFrame(() => {
|
|
178
|
-
var n;
|
|
179
|
-
e.isDestroyed || (t.dom.blur(), (n = window == null ? void 0 : window.getSelection()) == null || n.removeAllRanges());
|
|
180
|
-
}), !0), xe = (e = !0) => ({ commands: t }) => t.setContent("", { emitUpdate: e }), Se = () => ({ state: e, tr: t, dispatch: n }) => {
|
|
116
|
+
}, ve = () => ({ editor: e, view: t }) => (requestAnimationFrame(() => {
|
|
117
|
+
if (!e.isDestroyed) {
|
|
118
|
+
var n;
|
|
119
|
+
t.dom.blur(), (n = window) == null || (n = n.getSelection()) == null || n.removeAllRanges();
|
|
120
|
+
}
|
|
121
|
+
}), !0), ye = (e = !0) => ({ commands: t }) => t.setContent("", { emitUpdate: e }), be = () => ({ state: e, tr: t, dispatch: n }) => {
|
|
181
122
|
let { selection: r } = t, { ranges: i } = r;
|
|
182
123
|
return n && i.forEach(({ $from: n, $to: r }) => {
|
|
183
124
|
e.doc.nodesBetween(n.pos, r.pos, (e, n) => {
|
|
@@ -192,12 +133,12 @@ var be = () => ({ editor: e, view: t }) => (requestAnimationFrame(() => {
|
|
|
192
133
|
(l || l === 0) && t.lift(s, l);
|
|
193
134
|
});
|
|
194
135
|
}), !0;
|
|
195
|
-
},
|
|
136
|
+
}, xe = (e) => (t) => e(t), Se = () => ({ state: e, dispatch: t }) => l(e, t), Ce = (e, t) => ({ editor: n, tr: r }) => {
|
|
196
137
|
let { state: i } = n, a = i.doc.slice(e.from, e.to);
|
|
197
138
|
r.deleteRange(e.from, e.to);
|
|
198
139
|
let o = r.mapping.map(t);
|
|
199
|
-
return r.insert(o, a.content), r.setSelection(new
|
|
200
|
-
},
|
|
140
|
+
return r.insert(o, a.content), r.setSelection(new D(r.doc.resolve(Math.max(o - 1, 0)))), !0;
|
|
141
|
+
}, we = () => ({ tr: e, dispatch: t }) => {
|
|
201
142
|
let { selection: n } = e, r = n.$anchor.node();
|
|
202
143
|
if (r.content.size > 0) return !1;
|
|
203
144
|
let i = e.selection.$anchor;
|
|
@@ -210,15 +151,15 @@ var be = () => ({ editor: e, view: t }) => (requestAnimationFrame(() => {
|
|
|
210
151
|
}
|
|
211
152
|
return !1;
|
|
212
153
|
};
|
|
213
|
-
function
|
|
154
|
+
function j(e, t) {
|
|
214
155
|
if (typeof e == "string") {
|
|
215
156
|
if (!t.nodes[e]) throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);
|
|
216
157
|
return t.nodes[e];
|
|
217
158
|
}
|
|
218
159
|
return e;
|
|
219
160
|
}
|
|
220
|
-
var
|
|
221
|
-
let i =
|
|
161
|
+
var Te = (e) => ({ tr: t, state: n, dispatch: r }) => {
|
|
162
|
+
let i = j(e, n.schema), a = t.selection.$anchor;
|
|
222
163
|
for (let e = a.depth; e > 0; --e) if (a.node(e).type === i) {
|
|
223
164
|
if (r) {
|
|
224
165
|
let n = a.before(e), r = a.after(e);
|
|
@@ -227,41 +168,41 @@ var De = (e) => ({ tr: t, state: n, dispatch: r }) => {
|
|
|
227
168
|
return !0;
|
|
228
169
|
}
|
|
229
170
|
return !1;
|
|
230
|
-
},
|
|
171
|
+
}, Ee = (e) => ({ tr: t, dispatch: n }) => {
|
|
231
172
|
let { from: r, to: i } = e;
|
|
232
173
|
return n && t.delete(r, i), !0;
|
|
233
|
-
},
|
|
174
|
+
}, De = (e) => e.content ? /^text(\*|\+)/.test(e.content) : !1, Oe = (e, t, n) => {
|
|
234
175
|
if (!e.parent.isInline || n === "left" && e.pos > e.start() || n === "right" && e.pos < e.end()) return e.pos;
|
|
235
176
|
let r = t.nodes[e.parent.type.name].spec;
|
|
236
|
-
return
|
|
237
|
-
},
|
|
238
|
-
from:
|
|
239
|
-
to:
|
|
240
|
-
}),
|
|
177
|
+
return De(r) ? n === "left" ? e.start() - 1 : e.end() + 1 : e.pos;
|
|
178
|
+
}, ke = (e, t, n) => ({
|
|
179
|
+
from: Oe(e, n, "left"),
|
|
180
|
+
to: Oe(t, n, "right")
|
|
181
|
+
}), Ae = () => ({ state: e, dispatch: t }) => {
|
|
241
182
|
if (e.selection.empty) return !1;
|
|
242
183
|
if (t) {
|
|
243
184
|
let n = e.tr, { ranges: r } = e.selection, i = n.steps.length;
|
|
244
185
|
r.forEach((t) => {
|
|
245
|
-
let r = n.mapping.slice(i), { from: a, to: o } =
|
|
186
|
+
let r = n.mapping.slice(i), { from: a, to: o } = ke(n.doc.resolve(r.map(t.$from.pos)), n.doc.resolve(r.map(t.$to.pos)), e.schema);
|
|
246
187
|
n.deleteRange(a, o);
|
|
247
|
-
}), n.selection.empty || n.setSelection(
|
|
188
|
+
}), n.selection.empty || n.setSelection(D.near(n.doc.resolve(n.selection.from))), n.scrollIntoView(), t(n);
|
|
248
189
|
}
|
|
249
190
|
return !0;
|
|
250
|
-
},
|
|
251
|
-
function
|
|
191
|
+
}, je = () => ({ commands: e }) => e.keyboardShortcut("Enter"), Me = () => ({ state: e, dispatch: t }) => u(e, t);
|
|
192
|
+
function Ne(e) {
|
|
252
193
|
return Object.prototype.toString.call(e) === "[object RegExp]";
|
|
253
194
|
}
|
|
254
|
-
function
|
|
195
|
+
function M(e, t, n = { strict: !0 }) {
|
|
255
196
|
let r = Object.keys(t);
|
|
256
|
-
return !r.length || r.every((r) => n.strict ? t[r] === e[r] :
|
|
197
|
+
return !r.length || r.every((r) => n.strict ? t[r] === e[r] : Ne(t[r]) ? t[r].test(e[r]) : t[r] === e[r]);
|
|
257
198
|
}
|
|
258
|
-
function
|
|
259
|
-
return e.find((e) => e.type === t &&
|
|
199
|
+
function Pe(e, t, n = {}) {
|
|
200
|
+
return e.find((e) => e.type === t && M(Object.fromEntries(Object.keys(n).map((t) => [t, e.attrs[t]])), n));
|
|
260
201
|
}
|
|
261
|
-
function
|
|
262
|
-
return !!
|
|
202
|
+
function Fe(e, t, n = {}) {
|
|
203
|
+
return !!Pe(e, t, n);
|
|
263
204
|
}
|
|
264
|
-
function
|
|
205
|
+
function N(e, t, n) {
|
|
265
206
|
if (!e || !t) return;
|
|
266
207
|
let r = e.parent.childAfter(e.parentOffset);
|
|
267
208
|
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;
|
|
@@ -269,55 +210,55 @@ function M(e, t, n) {
|
|
|
269
210
|
let e = r.node.marks.find((e) => e.type === t);
|
|
270
211
|
e && (n = e.attrs);
|
|
271
212
|
}
|
|
272
|
-
if (!
|
|
213
|
+
if (!Pe([...r.node.marks], t, n)) return;
|
|
273
214
|
let i = r.index, a = e.start() + r.offset, o = i + 1, s = a + r.node.nodeSize;
|
|
274
|
-
for (; i > 0 &&
|
|
275
|
-
for (; o < e.parent.childCount &&
|
|
215
|
+
for (; i > 0 && Fe([...e.parent.child(i - 1).marks], t, n);) --i, a -= e.parent.child(i).nodeSize;
|
|
216
|
+
for (; o < e.parent.childCount && Fe([...e.parent.child(o).marks], t, n);) s += e.parent.child(o).nodeSize, o += 1;
|
|
276
217
|
return {
|
|
277
218
|
from: a,
|
|
278
219
|
to: s
|
|
279
220
|
};
|
|
280
221
|
}
|
|
281
|
-
function
|
|
222
|
+
function P(e, t) {
|
|
282
223
|
if (typeof e == "string") {
|
|
283
224
|
if (!t.marks[e]) throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);
|
|
284
225
|
return t.marks[e];
|
|
285
226
|
}
|
|
286
227
|
return e;
|
|
287
228
|
}
|
|
288
|
-
var
|
|
289
|
-
let a =
|
|
229
|
+
var Ie = (e, t) => ({ tr: n, state: r, dispatch: i }) => {
|
|
230
|
+
let a = P(e, r.schema), { doc: o, selection: s } = n, { $from: c, from: l, to: u } = s;
|
|
290
231
|
if (i) {
|
|
291
|
-
let e =
|
|
232
|
+
let e = N(c, a, t);
|
|
292
233
|
if (e && e.from <= l && e.to >= u) {
|
|
293
|
-
let t =
|
|
234
|
+
let t = D.create(o, e.from, e.to);
|
|
294
235
|
n.setSelection(t);
|
|
295
236
|
}
|
|
296
237
|
}
|
|
297
238
|
return !0;
|
|
298
|
-
},
|
|
239
|
+
}, Le = (e) => (t) => {
|
|
299
240
|
let n = typeof e == "function" ? e(t) : e;
|
|
300
241
|
for (let e = 0; e < n.length; e += 1) if (n[e](t)) return !0;
|
|
301
242
|
return !1;
|
|
302
243
|
};
|
|
303
|
-
function
|
|
304
|
-
return e instanceof
|
|
244
|
+
function F(e) {
|
|
245
|
+
return e instanceof D;
|
|
305
246
|
}
|
|
306
|
-
function
|
|
247
|
+
function I(e = 0, t = 0, n = 0) {
|
|
307
248
|
return Math.min(Math.max(e, t), n);
|
|
308
249
|
}
|
|
309
|
-
function
|
|
250
|
+
function Re(e, t = null) {
|
|
310
251
|
if (!t) return null;
|
|
311
|
-
let n =
|
|
252
|
+
let n = E.atStart(e), r = E.atEnd(e);
|
|
312
253
|
if (t === "start" || t === !0) return n;
|
|
313
254
|
if (t === "end") return r;
|
|
314
255
|
let i = n.from, a = r.to;
|
|
315
|
-
return t === "all" ?
|
|
256
|
+
return t === "all" ? D.create(e, I(0, i, a), I(e.content.size, i, a)) : D.create(e, I(t, i, a), I(t, i, a));
|
|
316
257
|
}
|
|
317
|
-
function
|
|
258
|
+
function ze() {
|
|
318
259
|
return ["Android"].includes(navigator.platform) || /android/i.test(navigator.userAgent);
|
|
319
260
|
}
|
|
320
|
-
function
|
|
261
|
+
function L() {
|
|
321
262
|
return [
|
|
322
263
|
"iPad Simulator",
|
|
323
264
|
"iPhone Simulator",
|
|
@@ -327,16 +268,16 @@ function I() {
|
|
|
327
268
|
"iPod"
|
|
328
269
|
].includes(navigator.platform) || navigator.userAgent.includes("Mac") && "ontouchend" in document;
|
|
329
270
|
}
|
|
330
|
-
function
|
|
271
|
+
function Be() {
|
|
331
272
|
return typeof navigator < "u" && /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
332
273
|
}
|
|
333
|
-
var
|
|
274
|
+
var Ve = (e = null, t = {}) => ({ editor: n, view: r, tr: i, dispatch: a }) => {
|
|
334
275
|
t = {
|
|
335
276
|
scrollIntoView: !0,
|
|
336
277
|
...t
|
|
337
278
|
};
|
|
338
279
|
let o = () => {
|
|
339
|
-
(
|
|
280
|
+
(L() || ze()) && r.dom.focus(), Be() && !L() && !ze() && r.dom.focus({ preventScroll: !0 }), requestAnimationFrame(() => {
|
|
340
281
|
n.isDestroyed || (r.focus(), t?.scrollIntoView && n.commands.scrollIntoView());
|
|
341
282
|
});
|
|
342
283
|
};
|
|
@@ -345,33 +286,33 @@ var Ue = (e = null, t = {}) => ({ editor: n, view: r, tr: i, dispatch: a }) => {
|
|
|
345
286
|
} catch {
|
|
346
287
|
return !1;
|
|
347
288
|
}
|
|
348
|
-
if (a && e === null && !
|
|
349
|
-
let s =
|
|
289
|
+
if (a && e === null && !F(n.state.selection)) return o(), !0;
|
|
290
|
+
let s = Re(i.doc, e) || n.state.selection, c = n.state.selection.eq(s);
|
|
350
291
|
return a && (c || i.setSelection(s), c && i.storedMarks && i.setStoredMarks(i.storedMarks), o()), !0;
|
|
351
|
-
},
|
|
292
|
+
}, He = (e, t) => (n) => e.every((e, r) => t(e, {
|
|
352
293
|
...n,
|
|
353
294
|
index: r
|
|
354
|
-
})),
|
|
295
|
+
})), Ue = (e, t) => ({ tr: n, commands: r }) => r.insertContentAt({
|
|
355
296
|
from: n.selection.from,
|
|
356
297
|
to: n.selection.to
|
|
357
|
-
}, e, t),
|
|
298
|
+
}, e, t), We = (e) => {
|
|
358
299
|
let t = e.childNodes;
|
|
359
300
|
for (let n = t.length - 1; n >= 0; --n) {
|
|
360
301
|
let r = t[n];
|
|
361
|
-
r.nodeType === 3 && r.nodeValue && /^(\n\s\s|\n)$/.test(r.nodeValue) ? e.removeChild(r) : r.nodeType === 1 &&
|
|
302
|
+
r.nodeType === 3 && r.nodeValue && /^(\n\s\s|\n)$/.test(r.nodeValue) ? e.removeChild(r) : r.nodeType === 1 && We(r);
|
|
362
303
|
}
|
|
363
304
|
return e;
|
|
364
305
|
};
|
|
365
|
-
function
|
|
306
|
+
function R(e) {
|
|
366
307
|
if (typeof window > "u") throw Error("[tiptap error]: there is no window object available, so this function cannot be used");
|
|
367
308
|
let t = `<body>${e}</body>`, n = new window.DOMParser().parseFromString(t, "text/html").body;
|
|
368
|
-
return
|
|
309
|
+
return We(n);
|
|
369
310
|
}
|
|
370
|
-
function
|
|
311
|
+
function Ge(e) {
|
|
371
312
|
return typeof e?.nodesBetween == "function";
|
|
372
313
|
}
|
|
373
|
-
function
|
|
374
|
-
if (
|
|
314
|
+
function z(e, t, n) {
|
|
315
|
+
if (Ge(e)) return e;
|
|
375
316
|
let r = typeof e == "object" && !!e;
|
|
376
317
|
n = {
|
|
377
318
|
slice: !0,
|
|
@@ -380,16 +321,16 @@ function R(e, t, n) {
|
|
|
380
321
|
};
|
|
381
322
|
let i = typeof e == "string";
|
|
382
323
|
if (r) try {
|
|
383
|
-
if (Array.isArray(e) && e.length > 0) return
|
|
324
|
+
if (Array.isArray(e) && e.length > 0) return O.fromArray(e.map((e) => t.nodeFromJSON(e)));
|
|
384
325
|
let r = t.nodeFromJSON(e);
|
|
385
326
|
return n.errorOnInvalidContent && r.check(), r;
|
|
386
327
|
} catch (r) {
|
|
387
328
|
if (n.errorOnInvalidContent) throw Error("[tiptap error]: Invalid JSON content", { cause: r });
|
|
388
|
-
return console.warn("[tiptap warn]: Invalid content.", "Passed value:", e, "Error:", r),
|
|
329
|
+
return console.warn("[tiptap warn]: Invalid content.", "Passed value:", e, "Error:", r), z("", t, n);
|
|
389
330
|
}
|
|
390
331
|
if (i) {
|
|
391
332
|
if (n.errorOnInvalidContent) {
|
|
392
|
-
let r = !1, i = "", a = new
|
|
333
|
+
let r = !1, i = "", a = new ce({
|
|
393
334
|
topNode: t.spec.topNode,
|
|
394
335
|
marks: t.spec.marks,
|
|
395
336
|
nodes: t.spec.nodes.append({ __tiptap__private__unknown__catch__all__node: {
|
|
@@ -401,17 +342,17 @@ function R(e, t, n) {
|
|
|
401
342
|
}]
|
|
402
343
|
} })
|
|
403
344
|
});
|
|
404
|
-
if (n.slice ?
|
|
345
|
+
if (n.slice ? oe.fromSchema(a).parseSlice(R(e), n.parseOptions) : oe.fromSchema(a).parse(R(e), n.parseOptions), n.errorOnInvalidContent && r) throw Error("[tiptap error]: Invalid HTML content", { cause: /* @__PURE__ */ Error(`Invalid element found: ${i}`) });
|
|
405
346
|
}
|
|
406
|
-
let r =
|
|
407
|
-
return n.slice ? r.parseSlice(
|
|
347
|
+
let r = oe.fromSchema(t);
|
|
348
|
+
return n.slice ? r.parseSlice(R(e), n.parseOptions).content : r.parse(R(e), n.parseOptions);
|
|
408
349
|
}
|
|
409
|
-
return
|
|
350
|
+
return z("", t, n);
|
|
410
351
|
}
|
|
411
|
-
function
|
|
352
|
+
function Ke(e) {
|
|
412
353
|
return !("type" in e);
|
|
413
354
|
}
|
|
414
|
-
function
|
|
355
|
+
function qe(e, r, i) {
|
|
415
356
|
let a = e.steps.length - 1;
|
|
416
357
|
if (a < r) return;
|
|
417
358
|
let o = e.steps[a];
|
|
@@ -419,9 +360,9 @@ function Ye(e, r, i) {
|
|
|
419
360
|
let s = e.mapping.maps[a], c = 0;
|
|
420
361
|
s.forEach((e, t, n, r) => {
|
|
421
362
|
c === 0 && (c = r);
|
|
422
|
-
}), e.setSelection(
|
|
363
|
+
}), e.setSelection(E.near(e.doc.resolve(c), i));
|
|
423
364
|
}
|
|
424
|
-
var
|
|
365
|
+
var Je = (e, t, n) => ({ tr: r, dispatch: i, editor: a }) => {
|
|
425
366
|
if (i) {
|
|
426
367
|
n = {
|
|
427
368
|
parseOptions: a.options.parseOptions,
|
|
@@ -443,7 +384,7 @@ var Xe = (e, t, n) => ({ tr: r, dispatch: i, editor: a }) => {
|
|
|
443
384
|
...n.parseOptions
|
|
444
385
|
};
|
|
445
386
|
if (!n.errorOnInvalidContent && !a.options.enableContentCheck && a.options.emitContentError) try {
|
|
446
|
-
|
|
387
|
+
z(t, a.schema, {
|
|
447
388
|
parseOptions: s,
|
|
448
389
|
errorOnInvalidContent: !0
|
|
449
390
|
});
|
|
@@ -451,7 +392,7 @@ var Xe = (e, t, n) => ({ tr: r, dispatch: i, editor: a }) => {
|
|
|
451
392
|
o(e);
|
|
452
393
|
}
|
|
453
394
|
try {
|
|
454
|
-
i =
|
|
395
|
+
i = z(t, a.schema, {
|
|
455
396
|
parseOptions: s,
|
|
456
397
|
errorOnInvalidContent: n.errorOnInvalidContent ?? a.options.enableContentCheck
|
|
457
398
|
});
|
|
@@ -464,7 +405,7 @@ var Xe = (e, t, n) => ({ tr: r, dispatch: i, editor: a }) => {
|
|
|
464
405
|
} : {
|
|
465
406
|
from: e.from,
|
|
466
407
|
to: e.to
|
|
467
|
-
}, u = !0, d = !0, f =
|
|
408
|
+
}, u = !0, d = !0, f = Ke(i) ? i.content : [i];
|
|
468
409
|
if (f.forEach((e) => {
|
|
469
410
|
e.check(), u = u ? e.isText && e.marks.length === 0 : !1, d = d ? e.isBlock : !1;
|
|
470
411
|
}), c === l && d) {
|
|
@@ -472,13 +413,13 @@ var Xe = (e, t, n) => ({ tr: r, dispatch: i, editor: a }) => {
|
|
|
472
413
|
e.isTextblock && !e.type.spec.code && !e.childCount && (--c, l += 1);
|
|
473
414
|
}
|
|
474
415
|
let p;
|
|
475
|
-
if (u) p = Array.isArray(t) ? t.map((e) => e.text || "").join("") :
|
|
416
|
+
if (u) p = Array.isArray(t) ? t.map((e) => e.text || "").join("") : Ge(t) ? f.map((e) => e.text ?? "").join("") : typeof t == "object" && t && t.text ? t.text : t, r.insertText(p, c, l);
|
|
476
417
|
else {
|
|
477
|
-
p =
|
|
418
|
+
p = O.from(f);
|
|
478
419
|
let e = r.doc.resolve(c), t = e.node(), n = e.parentOffset === 0, i = t.isText || t.isTextblock, a = t.content.size > 0;
|
|
479
420
|
n && i && a && d && (c = Math.max(0, c - 1)), r.replaceWith(c, l, f);
|
|
480
421
|
}
|
|
481
|
-
n.updateSelection &&
|
|
422
|
+
n.updateSelection && qe(r, r.steps.length - 1, -1), n.applyInputRules && r.setMeta("applyInputRules", {
|
|
482
423
|
from: c,
|
|
483
424
|
text: p
|
|
484
425
|
}), n.applyPasteRules && r.setMeta("applyPasteRules", {
|
|
@@ -488,43 +429,43 @@ var Xe = (e, t, n) => ({ tr: r, dispatch: i, editor: a }) => {
|
|
|
488
429
|
}
|
|
489
430
|
return !0;
|
|
490
431
|
};
|
|
491
|
-
function
|
|
432
|
+
function Ye(e) {
|
|
492
433
|
for (let t = 0; t < e.edgeCount; t += 1) {
|
|
493
434
|
let { type: n } = e.edge(t);
|
|
494
435
|
if (n.isTextblock && !n.hasRequiredAttrs()) return n;
|
|
495
436
|
}
|
|
496
437
|
return null;
|
|
497
438
|
}
|
|
498
|
-
var
|
|
439
|
+
var Xe = (e = {}) => ({ tr: t, dispatch: n, editor: r }) => {
|
|
499
440
|
let { pos: i, attrs: a, content: o, updateSelection: s = !0 } = e, c;
|
|
500
441
|
c = typeof i == "number" ? t.doc.resolve(i) : i || t.selection.$from;
|
|
501
|
-
let l =
|
|
442
|
+
let l = Ye(c.parent.contentMatchAt(c.index()));
|
|
502
443
|
if (!l) return !1;
|
|
503
444
|
let u = Object.keys(l.spec.attrs || {}), d = a ? Object.fromEntries(Object.entries(a).filter(([e]) => u.includes(e))) : {}, f;
|
|
504
445
|
if (o) {
|
|
505
|
-
let e =
|
|
446
|
+
let e = z(o, r.schema);
|
|
506
447
|
f = l.createAndFill(d, e);
|
|
507
448
|
} else f = l.createAndFill(d);
|
|
508
|
-
return f ? (n && (t.insert(c.pos, f), s &&
|
|
509
|
-
},
|
|
449
|
+
return f ? (n && (t.insert(c.pos, f), s && qe(t, t.steps.length - 1, -1)), !0) : !1;
|
|
450
|
+
}, Ze = () => ({ state: e, dispatch: t }) => g(e, t), Qe = () => ({ state: e, dispatch: t }) => f(e, t), $e = () => ({ state: e, dispatch: t }) => d(e, t), et = () => ({ state: e, dispatch: t }) => p(e, t), tt = () => ({ state: e, dispatch: t, tr: n }) => {
|
|
510
451
|
try {
|
|
511
452
|
let r = s(e.doc, e.selection.$from.pos, -1);
|
|
512
453
|
return r != null && (n.join(r, 2), t && t(n), !0);
|
|
513
454
|
} catch {
|
|
514
455
|
return !1;
|
|
515
456
|
}
|
|
516
|
-
},
|
|
457
|
+
}, nt = () => ({ state: e, dispatch: t, tr: n }) => {
|
|
517
458
|
try {
|
|
518
459
|
let r = s(e.doc, e.selection.$from.pos, 1);
|
|
519
460
|
return r != null && (n.join(r, 2), t && t(n), !0);
|
|
520
461
|
} catch {
|
|
521
462
|
return !1;
|
|
522
463
|
}
|
|
523
|
-
},
|
|
524
|
-
function
|
|
464
|
+
}, rt = () => ({ state: e, dispatch: t }) => m(e, t), it = () => ({ state: e, dispatch: t }) => h(e, t);
|
|
465
|
+
function at() {
|
|
525
466
|
return typeof navigator < "u" && /Mac/.test(navigator.platform);
|
|
526
467
|
}
|
|
527
|
-
function
|
|
468
|
+
function ot(e) {
|
|
528
469
|
let t = e.split(/-(?!$)/), n = t[t.length - 1];
|
|
529
470
|
n === "Space" && (n = " ");
|
|
530
471
|
let r, i, a, o;
|
|
@@ -534,13 +475,13 @@ function ct(e) {
|
|
|
534
475
|
else if (/^a(lt)?$/i.test(n)) r = !0;
|
|
535
476
|
else if (/^(c|ctrl|control)$/i.test(n)) i = !0;
|
|
536
477
|
else if (/^s(hift)?$/i.test(n)) a = !0;
|
|
537
|
-
else if (/^mod$/i.test(n))
|
|
478
|
+
else if (/^mod$/i.test(n)) L() || at() ? o = !0 : i = !0;
|
|
538
479
|
else throw Error(`Unrecognized modifier name: ${n}`);
|
|
539
480
|
}
|
|
540
481
|
return r && (n = `Alt-${n}`), i && (n = `Ctrl-${n}`), o && (n = `Meta-${n}`), a && (n = `Shift-${n}`), n;
|
|
541
482
|
}
|
|
542
|
-
var
|
|
543
|
-
let a =
|
|
483
|
+
var st = (e) => ({ editor: t, view: n, tr: r, dispatch: i }) => {
|
|
484
|
+
let a = ot(e).split(/-(?!$)/), o = a.find((e) => ![
|
|
544
485
|
"Alt",
|
|
545
486
|
"Ctrl",
|
|
546
487
|
"Meta",
|
|
@@ -561,8 +502,8 @@ var lt = (e) => ({ editor: t, view: n, tr: r, dispatch: i }) => {
|
|
|
561
502
|
t && i && r.maybeStep(t);
|
|
562
503
|
}), !0;
|
|
563
504
|
};
|
|
564
|
-
function
|
|
565
|
-
let { from: r, to: i, empty: a } = e.selection, o = t ?
|
|
505
|
+
function B(e, t, n = {}) {
|
|
506
|
+
let { from: r, to: i, empty: a } = e.selection, o = t ? j(t, e.schema) : null, s = [];
|
|
566
507
|
e.doc.nodesBetween(r, i, (e, t) => {
|
|
567
508
|
if (e.isText) return;
|
|
568
509
|
let n = Math.max(r, t), a = Math.min(i, t + e.nodeSize);
|
|
@@ -572,52 +513,52 @@ function z(e, t, n = {}) {
|
|
|
572
513
|
to: a
|
|
573
514
|
});
|
|
574
515
|
});
|
|
575
|
-
let c = i - r, l = s.filter((e) => !o || o.name === e.node.type.name).filter((e) =>
|
|
516
|
+
let c = i - r, l = s.filter((e) => !o || o.name === e.node.type.name).filter((e) => M(e.node.attrs, n, { strict: !1 }));
|
|
576
517
|
return a ? !!l.length : l.reduce((e, t) => e + t.to - t.from, 0) >= c;
|
|
577
518
|
}
|
|
578
|
-
var
|
|
579
|
-
let r =
|
|
580
|
-
return
|
|
581
|
-
},
|
|
582
|
-
function
|
|
519
|
+
var ct = (e, t = {}) => ({ state: n, dispatch: r }) => B(n, j(e, n.schema), t) ? _(n, r) : !1, lt = () => ({ state: e, dispatch: t }) => ee(e, t), ut = (e) => ({ state: t, dispatch: n }) => {
|
|
520
|
+
let r = j(e, t.schema);
|
|
521
|
+
return ue(r)(t, n);
|
|
522
|
+
}, dt = () => ({ state: e, dispatch: t }) => te(e, t);
|
|
523
|
+
function ft(e, t) {
|
|
583
524
|
return t.nodes[e] ? "node" : t.marks[e] ? "mark" : null;
|
|
584
525
|
}
|
|
585
|
-
function
|
|
526
|
+
function pt(e, t) {
|
|
586
527
|
let n = typeof t == "string" ? [t] : t;
|
|
587
528
|
return Object.keys(e).reduce((t, r) => (n.includes(r) || (t[r] = e[r]), t), {});
|
|
588
529
|
}
|
|
589
|
-
var
|
|
590
|
-
let a = null, o = null, s =
|
|
530
|
+
var mt = (e, t) => ({ tr: n, state: r, dispatch: i }) => {
|
|
531
|
+
let a = null, o = null, s = ft(typeof e == "string" ? e : e.name, r.schema);
|
|
591
532
|
if (!s) return !1;
|
|
592
|
-
s === "node" && (a =
|
|
533
|
+
s === "node" && (a = j(e, r.schema)), s === "mark" && (o = P(e, r.schema));
|
|
593
534
|
let c = !1;
|
|
594
535
|
return n.selection.ranges.forEach((e) => {
|
|
595
536
|
r.doc.nodesBetween(e.$from.pos, e.$to.pos, (e, r) => {
|
|
596
|
-
a && a === e.type && (c = !0, i && n.setNodeMarkup(r, void 0,
|
|
597
|
-
o === a.type && (c = !0, i && n.addMark(r, r + e.nodeSize, o.create(
|
|
537
|
+
a && a === e.type && (c = !0, i && n.setNodeMarkup(r, void 0, pt(e.attrs, t))), o && e.marks.length && e.marks.forEach((a) => {
|
|
538
|
+
o === a.type && (c = !0, i && n.addMark(r, r + e.nodeSize, o.create(pt(a.attrs, t))));
|
|
598
539
|
});
|
|
599
540
|
});
|
|
600
541
|
}), c;
|
|
601
|
-
},
|
|
542
|
+
}, ht = () => ({ tr: e, dispatch: t }) => (t && e.scrollIntoView(), !0), gt = () => ({ tr: e, dispatch: t }) => {
|
|
602
543
|
if (t) {
|
|
603
|
-
let t = new
|
|
544
|
+
let t = new ae(e.doc);
|
|
604
545
|
e.setSelection(t);
|
|
605
546
|
}
|
|
606
547
|
return !0;
|
|
607
|
-
},
|
|
608
|
-
function
|
|
609
|
-
return
|
|
548
|
+
}, _t = () => ({ state: e, dispatch: t }) => ne(e, t), vt = () => ({ state: e, dispatch: t }) => v(e, t), yt = () => ({ state: e, dispatch: t }) => re(e, t), bt = () => ({ state: e, dispatch: t }) => ie(e, t), xt = () => ({ state: e, dispatch: t }) => y(e, t);
|
|
549
|
+
function St(e, t, n = {}, r = {}) {
|
|
550
|
+
return z(e, t, {
|
|
610
551
|
slice: !1,
|
|
611
552
|
parseOptions: n,
|
|
612
553
|
errorOnInvalidContent: r.errorOnInvalidContent
|
|
613
554
|
});
|
|
614
555
|
}
|
|
615
|
-
var
|
|
556
|
+
var Ct = (e, { errorOnInvalidContent: t, emitUpdate: n = !0, parseOptions: r = {} } = {}) => ({ editor: i, tr: a, dispatch: o, commands: s }) => {
|
|
616
557
|
let { doc: c } = a;
|
|
617
558
|
if (r.preserveWhitespace !== "full") {
|
|
618
|
-
let s =
|
|
559
|
+
let s = St(e, i.schema, r, { errorOnInvalidContent: t ?? i.options.enableContentCheck });
|
|
619
560
|
if (o) {
|
|
620
|
-
let e =
|
|
561
|
+
let e = Ke(s) ? s.content : [s];
|
|
621
562
|
a.replaceWith(0, c.content.size, e).setMeta("preventUpdate", !n);
|
|
622
563
|
}
|
|
623
564
|
return !0;
|
|
@@ -630,15 +571,15 @@ var wt = (e, { errorOnInvalidContent: t, emitUpdate: n = !0, parseOptions: r = {
|
|
|
630
571
|
errorOnInvalidContent: t ?? i.options.enableContentCheck
|
|
631
572
|
});
|
|
632
573
|
};
|
|
633
|
-
function
|
|
634
|
-
let n =
|
|
574
|
+
function wt(e, t) {
|
|
575
|
+
let n = P(t, e.schema), { from: r, to: i, empty: a } = e.selection, o = [];
|
|
635
576
|
a ? (e.storedMarks && o.push(...e.storedMarks), o.push(...e.selection.$head.marks())) : e.doc.nodesBetween(r, i, (e) => {
|
|
636
577
|
o.push(...e.marks);
|
|
637
578
|
});
|
|
638
579
|
let s = o.find((e) => e.type.name === n.name);
|
|
639
580
|
return s ? { ...s.attrs } : {};
|
|
640
581
|
}
|
|
641
|
-
function
|
|
582
|
+
function Tt(e, t) {
|
|
642
583
|
let n = new r(e);
|
|
643
584
|
return t.forEach((e) => {
|
|
644
585
|
e.steps.forEach((e) => {
|
|
@@ -646,7 +587,7 @@ function Et(e, t) {
|
|
|
646
587
|
});
|
|
647
588
|
}), n;
|
|
648
589
|
}
|
|
649
|
-
function
|
|
590
|
+
function Et(e, t, n) {
|
|
650
591
|
let r = [];
|
|
651
592
|
return e.nodesBetween(t.from, t.to, (e, t) => {
|
|
652
593
|
n(e) && r.push({
|
|
@@ -655,7 +596,7 @@ function Dt(e, t, n) {
|
|
|
655
596
|
});
|
|
656
597
|
}), r;
|
|
657
598
|
}
|
|
658
|
-
function
|
|
599
|
+
function Dt(e, t) {
|
|
659
600
|
for (let n = e.depth; n > 0; --n) {
|
|
660
601
|
let r = e.node(n);
|
|
661
602
|
if (t(r)) return {
|
|
@@ -667,7 +608,7 @@ function Ot(e, t) {
|
|
|
667
608
|
}
|
|
668
609
|
}
|
|
669
610
|
function V(e) {
|
|
670
|
-
return (t) =>
|
|
611
|
+
return (t) => Dt(t.$from, e);
|
|
671
612
|
}
|
|
672
613
|
function H(e, t, n) {
|
|
673
614
|
return e.config[t] === void 0 && e.parent ? H(e.parent, t, n) : typeof e.config[t] == "function" ? e.config[t].bind({
|
|
@@ -675,27 +616,27 @@ function H(e, t, n) {
|
|
|
675
616
|
parent: e.parent ? H(e.parent, t, n) : null
|
|
676
617
|
}) : e.config[t];
|
|
677
618
|
}
|
|
678
|
-
function
|
|
619
|
+
function Ot(e) {
|
|
679
620
|
return e.map((e) => {
|
|
680
621
|
let t = H(e, "addExtensions", {
|
|
681
622
|
name: e.name,
|
|
682
623
|
options: e.options,
|
|
683
624
|
storage: e.storage
|
|
684
625
|
});
|
|
685
|
-
return t ? [e, ...
|
|
626
|
+
return t ? [e, ...Ot(t())] : e;
|
|
686
627
|
}).flat(10);
|
|
687
628
|
}
|
|
688
|
-
function
|
|
689
|
-
let n =
|
|
629
|
+
function kt(e, t) {
|
|
630
|
+
let n = se.fromSchema(t).serializeFragment(e), r = document.implementation.createHTMLDocument().createElement("div");
|
|
690
631
|
return r.appendChild(n), r.innerHTML;
|
|
691
632
|
}
|
|
692
|
-
function
|
|
633
|
+
function At(e) {
|
|
693
634
|
return typeof e == "function";
|
|
694
635
|
}
|
|
695
636
|
function U(e, t = void 0, ...n) {
|
|
696
|
-
return
|
|
637
|
+
return At(e) ? t ? e.bind(t)(...n) : e(...n) : e;
|
|
697
638
|
}
|
|
698
|
-
function
|
|
639
|
+
function jt(e = {}) {
|
|
699
640
|
return Object.keys(e).length === 0 && e.constructor === Object;
|
|
700
641
|
}
|
|
701
642
|
function W(e) {
|
|
@@ -705,7 +646,7 @@ function W(e) {
|
|
|
705
646
|
markExtensions: e.filter((e) => e.type === "mark")
|
|
706
647
|
};
|
|
707
648
|
}
|
|
708
|
-
function
|
|
649
|
+
function Mt(e) {
|
|
709
650
|
let t = [], { nodeExtensions: n, markExtensions: r } = W(e), i = [...n, ...r], a = {
|
|
710
651
|
default: null,
|
|
711
652
|
validate: void 0,
|
|
@@ -758,7 +699,7 @@ function Nt(e) {
|
|
|
758
699
|
});
|
|
759
700
|
}), t;
|
|
760
701
|
}
|
|
761
|
-
function
|
|
702
|
+
function Nt(e) {
|
|
762
703
|
let t = [], n = "", r = !1, i = !1, a = 0, o = e.length;
|
|
763
704
|
for (let s = 0; s < o; s += 1) {
|
|
764
705
|
let o = e[s];
|
|
@@ -788,8 +729,8 @@ function Pt(e) {
|
|
|
788
729
|
}
|
|
789
730
|
return n && t.push(n), t;
|
|
790
731
|
}
|
|
791
|
-
function
|
|
792
|
-
let t = [], n =
|
|
732
|
+
function Pt(e) {
|
|
733
|
+
let t = [], n = Nt(e || ""), r = n.length;
|
|
793
734
|
for (let e = 0; e < r; e += 1) {
|
|
794
735
|
let r = n[e], i = r.indexOf(":");
|
|
795
736
|
if (i === -1) continue;
|
|
@@ -798,10 +739,19 @@ function Ft(e) {
|
|
|
798
739
|
}
|
|
799
740
|
return t;
|
|
800
741
|
}
|
|
801
|
-
function
|
|
742
|
+
function Ft(...e) {
|
|
802
743
|
return e.filter((e) => !!e).reduce((e, t) => {
|
|
803
744
|
let n = { ...e };
|
|
804
745
|
return Object.entries(t).forEach(([e, t]) => {
|
|
746
|
+
if (e === "__proto__") {
|
|
747
|
+
Object.defineProperty(n, e, {
|
|
748
|
+
configurable: !0,
|
|
749
|
+
enumerable: !0,
|
|
750
|
+
value: t,
|
|
751
|
+
writable: !0
|
|
752
|
+
});
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
805
755
|
if (!n[e]) {
|
|
806
756
|
n[e] = t;
|
|
807
757
|
return;
|
|
@@ -810,26 +760,26 @@ function It(...e) {
|
|
|
810
760
|
let r = t ? String(t).split(" ") : [], i = n[e] ? n[e].split(" ") : [], a = r.filter((e) => !i.includes(e));
|
|
811
761
|
n[e] = [...i, ...a].join(" ");
|
|
812
762
|
} else if (e === "style") {
|
|
813
|
-
let r = new Map([...
|
|
763
|
+
let r = new Map([...Pt(n[e]), ...Pt(t)]);
|
|
814
764
|
n[e] = Array.from(r.entries()).map(([e, t]) => `${e}: ${t}`).join("; ");
|
|
815
765
|
} else n[e] = t;
|
|
816
766
|
}), n;
|
|
817
767
|
}, {});
|
|
818
768
|
}
|
|
819
769
|
function G(e, t) {
|
|
820
|
-
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) =>
|
|
770
|
+
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) => Ft(e, t), {});
|
|
821
771
|
}
|
|
822
|
-
function
|
|
772
|
+
function It(e) {
|
|
823
773
|
return typeof e == "string" ? e.match(/^[+-]?(?:\d*\.)?\d+$/) ? Number(e) : e === "true" || e !== "false" && e : e;
|
|
824
774
|
}
|
|
825
|
-
function
|
|
775
|
+
function Lt(e, t) {
|
|
826
776
|
return "style" in e ? e : {
|
|
827
777
|
...e,
|
|
828
778
|
getAttrs: (n) => {
|
|
829
779
|
let r = e.getAttrs ? e.getAttrs(n) : e.attrs;
|
|
830
780
|
if (r === !1) return !1;
|
|
831
781
|
let i = t.reduce((e, t) => {
|
|
832
|
-
let r = t.attribute.parseHTML ? t.attribute.parseHTML(n) :
|
|
782
|
+
let r = t.attribute.parseHTML ? t.attribute.parseHTML(n) : It(n.getAttribute(t.name));
|
|
833
783
|
return r == null ? e : {
|
|
834
784
|
...e,
|
|
835
785
|
[t.name]: r
|
|
@@ -842,21 +792,22 @@ function Rt(e, t) {
|
|
|
842
792
|
}
|
|
843
793
|
};
|
|
844
794
|
}
|
|
845
|
-
function
|
|
846
|
-
return Object.fromEntries(Object.entries(e).filter(([e, t]) => e === "attrs" &&
|
|
795
|
+
function Rt(e) {
|
|
796
|
+
return Object.fromEntries(Object.entries(e).filter(([e, t]) => e === "attrs" && jt(t) ? !1 : t != null));
|
|
847
797
|
}
|
|
848
|
-
function
|
|
849
|
-
|
|
850
|
-
|
|
798
|
+
function zt(e) {
|
|
799
|
+
var t, n;
|
|
800
|
+
let r = {};
|
|
801
|
+
return !(e != null && (t = e.attribute) != null && t.isRequired) && "default" in (e?.attribute || {}) && (r.default = e.attribute.default), (e == null || (n = e.attribute) == null ? void 0 : n.validate) !== void 0 && (r.validate = e.attribute.validate), [e.name, r];
|
|
851
802
|
}
|
|
852
|
-
function
|
|
853
|
-
let n =
|
|
803
|
+
function Bt(e, t) {
|
|
804
|
+
let n = Mt(e), { nodeExtensions: r, markExtensions: i } = W(e), a = r.find((e) => H(e, "topNode"))?.name, o = Object.fromEntries(r.map((r) => {
|
|
854
805
|
let i = n.filter((e) => e.type === r.name), a = {
|
|
855
806
|
name: r.name,
|
|
856
807
|
options: r.options,
|
|
857
808
|
storage: r.storage,
|
|
858
809
|
editor: t
|
|
859
|
-
}, o =
|
|
810
|
+
}, o = Rt({
|
|
860
811
|
...e.reduce((e, t) => {
|
|
861
812
|
let n = H(t, "extendNodeSchema", a);
|
|
862
813
|
return {
|
|
@@ -876,9 +827,9 @@ function Vt(e, t) {
|
|
|
876
827
|
linebreakReplacement: U(H(r, "linebreakReplacement", a)),
|
|
877
828
|
defining: U(H(r, "defining", a)),
|
|
878
829
|
isolating: U(H(r, "isolating", a)),
|
|
879
|
-
attrs: Object.fromEntries(i.map(
|
|
830
|
+
attrs: Object.fromEntries(i.map(zt))
|
|
880
831
|
}), s = U(H(r, "parseHTML", a));
|
|
881
|
-
s && (o.parseDOM = s.map((e) =>
|
|
832
|
+
s && (o.parseDOM = s.map((e) => Lt(e, i)));
|
|
882
833
|
let c = H(r, "renderHTML", a);
|
|
883
834
|
c && (o.toDOM = (e) => c({
|
|
884
835
|
node: e,
|
|
@@ -892,7 +843,7 @@ function Vt(e, t) {
|
|
|
892
843
|
options: r.options,
|
|
893
844
|
storage: r.storage,
|
|
894
845
|
editor: t
|
|
895
|
-
}, o =
|
|
846
|
+
}, o = Rt({
|
|
896
847
|
...e.reduce((e, t) => {
|
|
897
848
|
let n = H(t, "extendMarkSchema", a);
|
|
898
849
|
return {
|
|
@@ -905,22 +856,22 @@ function Vt(e, t) {
|
|
|
905
856
|
group: U(H(r, "group", a)),
|
|
906
857
|
spanning: U(H(r, "spanning", a)),
|
|
907
858
|
code: U(H(r, "code", a)),
|
|
908
|
-
attrs: Object.fromEntries(i.map(
|
|
859
|
+
attrs: Object.fromEntries(i.map(zt))
|
|
909
860
|
}), s = U(H(r, "parseHTML", a));
|
|
910
|
-
s && (o.parseDOM = s.map((e) =>
|
|
861
|
+
s && (o.parseDOM = s.map((e) => Lt(e, i)));
|
|
911
862
|
let c = H(r, "renderHTML", a);
|
|
912
863
|
return c && (o.toDOM = (e) => c({
|
|
913
864
|
mark: e,
|
|
914
865
|
HTMLAttributes: G(e, i)
|
|
915
866
|
})), [r.name, o];
|
|
916
867
|
}));
|
|
917
|
-
return new
|
|
868
|
+
return new ce({
|
|
918
869
|
topNode: a,
|
|
919
870
|
nodes: o,
|
|
920
871
|
marks: s
|
|
921
872
|
});
|
|
922
873
|
}
|
|
923
|
-
function
|
|
874
|
+
function Vt(e) {
|
|
924
875
|
let t = e.filter((t, n) => e.indexOf(t) !== n);
|
|
925
876
|
return Array.from(new Set(t));
|
|
926
877
|
}
|
|
@@ -930,11 +881,11 @@ function K(e) {
|
|
|
930
881
|
return n > r ? -1 : +(n < r);
|
|
931
882
|
});
|
|
932
883
|
}
|
|
933
|
-
function
|
|
934
|
-
let t = K(
|
|
884
|
+
function Ht(e) {
|
|
885
|
+
let t = K(Ot(e)), n = Vt(t.map((e) => e.name));
|
|
935
886
|
return n.length && console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map((e) => `'${e}'`).join(", ")}]. This can lead to issues.`), t;
|
|
936
887
|
}
|
|
937
|
-
function
|
|
888
|
+
function Ut(e, t, n) {
|
|
938
889
|
let { from: r, to: i } = t, { blockSeparator: a = "\n\n", textSerializers: o = {} } = n || {}, s = "";
|
|
939
890
|
return e.nodesBetween(r, i, (e, n, c, l) => {
|
|
940
891
|
e.isBlock && n > r && (s += a);
|
|
@@ -946,42 +897,45 @@ function Wt(e, t, n) {
|
|
|
946
897
|
index: l,
|
|
947
898
|
range: t
|
|
948
899
|
})), !1;
|
|
949
|
-
|
|
900
|
+
if (e.isText) {
|
|
901
|
+
var d;
|
|
902
|
+
s += e == null || (d = e.text) == null ? void 0 : d.slice(Math.max(r, n) - n, i - n);
|
|
903
|
+
}
|
|
950
904
|
}), s;
|
|
951
905
|
}
|
|
952
|
-
function
|
|
953
|
-
return
|
|
906
|
+
function Wt(e, t) {
|
|
907
|
+
return Ut(e, {
|
|
954
908
|
from: 0,
|
|
955
909
|
to: e.content.size
|
|
956
910
|
}, t);
|
|
957
911
|
}
|
|
958
|
-
function
|
|
912
|
+
function Gt(e) {
|
|
959
913
|
return Object.fromEntries(Object.entries(e.nodes).filter(([, e]) => e.spec.toText).map(([e, t]) => [e, t.spec.toText]));
|
|
960
914
|
}
|
|
961
|
-
function
|
|
962
|
-
let n =
|
|
915
|
+
function Kt(e, t) {
|
|
916
|
+
let n = j(t, e.schema), { from: r, to: i } = e.selection, a = [];
|
|
963
917
|
e.doc.nodesBetween(r, i, (e) => {
|
|
964
918
|
a.push(e);
|
|
965
919
|
});
|
|
966
920
|
let o = a.reverse().find((e) => e.type.name === n.name);
|
|
967
921
|
return o ? { ...o.attrs } : {};
|
|
968
922
|
}
|
|
969
|
-
function
|
|
970
|
-
let n =
|
|
971
|
-
return n === "node" ?
|
|
923
|
+
function qt(e, t) {
|
|
924
|
+
let n = ft(typeof t == "string" ? t : t.name, e.schema);
|
|
925
|
+
return n === "node" ? Kt(e, t) : n === "mark" ? wt(e, t) : {};
|
|
972
926
|
}
|
|
973
|
-
function
|
|
927
|
+
function Jt(e, t = JSON.stringify) {
|
|
974
928
|
let n = {};
|
|
975
929
|
return e.filter((e) => {
|
|
976
930
|
let r = t(e);
|
|
977
931
|
return Object.prototype.hasOwnProperty.call(n, r) ? !1 : n[r] = !0;
|
|
978
932
|
});
|
|
979
933
|
}
|
|
980
|
-
function
|
|
981
|
-
let t =
|
|
934
|
+
function Yt(e) {
|
|
935
|
+
let t = Jt(e);
|
|
982
936
|
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));
|
|
983
937
|
}
|
|
984
|
-
function
|
|
938
|
+
function Xt(e) {
|
|
985
939
|
let { mapping: t, steps: n } = e, r = [];
|
|
986
940
|
return t.maps.forEach((e, i) => {
|
|
987
941
|
let a = [];
|
|
@@ -1012,12 +966,12 @@ function Zt(e) {
|
|
|
1012
966
|
}
|
|
1013
967
|
});
|
|
1014
968
|
});
|
|
1015
|
-
}),
|
|
969
|
+
}), Yt(r);
|
|
1016
970
|
}
|
|
1017
|
-
function
|
|
971
|
+
function Zt(e, t, n) {
|
|
1018
972
|
let r = [];
|
|
1019
973
|
return e === t ? n.resolve(e).marks().forEach((t) => {
|
|
1020
|
-
let i =
|
|
974
|
+
let i = N(n.resolve(e), t.type);
|
|
1021
975
|
i && r.push({
|
|
1022
976
|
mark: t,
|
|
1023
977
|
...i
|
|
@@ -1030,14 +984,14 @@ function Qt(e, t, n) {
|
|
|
1030
984
|
})));
|
|
1031
985
|
}), r;
|
|
1032
986
|
}
|
|
1033
|
-
var
|
|
987
|
+
var Qt = (e, t, n, r = 20) => {
|
|
1034
988
|
let i = e.doc.resolve(n), a = r, o = null;
|
|
1035
989
|
for (; a > 0 && o === null;) {
|
|
1036
990
|
let e = i.node(a);
|
|
1037
991
|
e?.type.name === t ? o = e : --a;
|
|
1038
992
|
}
|
|
1039
993
|
return [o, a];
|
|
1040
|
-
},
|
|
994
|
+
}, $t = (e) => {
|
|
1041
995
|
let t = e.depth - 1;
|
|
1042
996
|
if (t < 0) return null;
|
|
1043
997
|
let n = e.index(t);
|
|
@@ -1052,7 +1006,7 @@ function J(e, t, n) {
|
|
|
1052
1006
|
return r ? r.attribute.keepOnSplit : !1;
|
|
1053
1007
|
}));
|
|
1054
1008
|
}
|
|
1055
|
-
var
|
|
1009
|
+
var en = (e, t = 500) => {
|
|
1056
1010
|
let n = "", r = e.parentOffset;
|
|
1057
1011
|
return e.parent.nodesBetween(Math.max(0, r - t), r, (e, t, i, a) => {
|
|
1058
1012
|
var o;
|
|
@@ -1065,9 +1019,9 @@ var tn = (e, t = 500) => {
|
|
|
1065
1019
|
n += e.isAtom && !e.isText ? s : s.slice(0, Math.max(0, r - t));
|
|
1066
1020
|
}), n;
|
|
1067
1021
|
};
|
|
1068
|
-
function
|
|
1069
|
-
let { empty: r, ranges: i } = e.selection, a = t ?
|
|
1070
|
-
if (r) return !!(e.storedMarks || e.selection.$from.marks()).filter((e) => !a || a.name === e.type.name).find((e) =>
|
|
1022
|
+
function tn(e, t, n = {}) {
|
|
1023
|
+
let { empty: r, ranges: i } = e.selection, a = t ? P(t, e.schema) : null;
|
|
1024
|
+
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 }));
|
|
1071
1025
|
let o = 0, s = [];
|
|
1072
1026
|
if (i.forEach(({ $from: t, $to: n }) => {
|
|
1073
1027
|
let r = t.pos, i = n.pos;
|
|
@@ -1082,15 +1036,15 @@ function nn(e, t, n = {}) {
|
|
|
1082
1036
|
})));
|
|
1083
1037
|
});
|
|
1084
1038
|
}), o === 0) return !1;
|
|
1085
|
-
let c = s.filter((e) => !a || a.name === e.mark.type.name).filter((e) =>
|
|
1039
|
+
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);
|
|
1086
1040
|
return (c > 0 ? c + l : c) >= o;
|
|
1087
1041
|
}
|
|
1088
|
-
function
|
|
1089
|
-
if (!t) return
|
|
1090
|
-
let r =
|
|
1091
|
-
return r === "node" ?
|
|
1042
|
+
function nn(e, t, n = {}) {
|
|
1043
|
+
if (!t) return B(e, null, n) || tn(e, null, n);
|
|
1044
|
+
let r = ft(t, e.schema);
|
|
1045
|
+
return r === "node" ? B(e, t, n) : r === "mark" && tn(e, t, n);
|
|
1092
1046
|
}
|
|
1093
|
-
var
|
|
1047
|
+
var rn = (e, t) => {
|
|
1094
1048
|
let { $from: n, $to: r, $anchor: i } = e.selection;
|
|
1095
1049
|
if (t) {
|
|
1096
1050
|
let n = V((e) => e.type.name === t)(e.selection);
|
|
@@ -1099,14 +1053,14 @@ var an = (e, t) => {
|
|
|
1099
1053
|
return i.pos + 1 === r.end();
|
|
1100
1054
|
}
|
|
1101
1055
|
return !(r.parentOffset < r.parent.nodeSize - 2 || n.pos !== r.pos);
|
|
1102
|
-
},
|
|
1056
|
+
}, an = (e) => {
|
|
1103
1057
|
let { $from: t, $to: n } = e.selection;
|
|
1104
1058
|
return !(t.parentOffset > 0 || t.pos !== n.pos);
|
|
1105
1059
|
};
|
|
1106
|
-
function
|
|
1060
|
+
function on(e, t) {
|
|
1107
1061
|
return Array.isArray(t) ? t.some((t) => (typeof t == "string" ? t : t.name) === e.name) : t;
|
|
1108
1062
|
}
|
|
1109
|
-
function
|
|
1063
|
+
function sn(e, t) {
|
|
1110
1064
|
let { nodeExtensions: n } = W(t), r = n.find((t) => t.name === e);
|
|
1111
1065
|
if (!r) return !1;
|
|
1112
1066
|
let i = U(H(r, "group", {
|
|
@@ -1135,14 +1089,14 @@ function Y(e, { checkChildren: t = !0, ignoreWhitespace: n = !1 } = {}) {
|
|
|
1135
1089
|
}
|
|
1136
1090
|
return !1;
|
|
1137
1091
|
}
|
|
1138
|
-
function
|
|
1139
|
-
return e instanceof
|
|
1092
|
+
function cn(e) {
|
|
1093
|
+
return e instanceof C;
|
|
1140
1094
|
}
|
|
1141
|
-
function
|
|
1095
|
+
function ln({ selection: e, pos: t, nodeSize: n, selectedOnTextSelection: r = !1 }) {
|
|
1142
1096
|
let { from: i, to: a } = e;
|
|
1143
|
-
return !!(i <= t && a >= t + n || r &&
|
|
1097
|
+
return !!(i <= t && a >= t + n || r && F(e) && i > t && a < t + n);
|
|
1144
1098
|
}
|
|
1145
|
-
var
|
|
1099
|
+
var un = class e {
|
|
1146
1100
|
constructor(e) {
|
|
1147
1101
|
this.position = e;
|
|
1148
1102
|
}
|
|
@@ -1153,18 +1107,18 @@ var dn = class e {
|
|
|
1153
1107
|
return { position: this.position };
|
|
1154
1108
|
}
|
|
1155
1109
|
};
|
|
1156
|
-
function
|
|
1110
|
+
function dn(e, t) {
|
|
1157
1111
|
let n = t.mapping.mapResult(e.position);
|
|
1158
1112
|
return {
|
|
1159
|
-
position: new
|
|
1113
|
+
position: new un(n.pos),
|
|
1160
1114
|
mapResult: n
|
|
1161
1115
|
};
|
|
1162
1116
|
}
|
|
1163
|
-
function
|
|
1164
|
-
return new
|
|
1117
|
+
function fn(e) {
|
|
1118
|
+
return new un(e);
|
|
1165
1119
|
}
|
|
1166
|
-
function
|
|
1167
|
-
let r = e.state.doc.content.size, i =
|
|
1120
|
+
function pn(e, t, n) {
|
|
1121
|
+
let r = e.state.doc.content.size, i = I(t, 0, r), a = I(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 = {
|
|
1168
1122
|
top: c,
|
|
1169
1123
|
bottom: l,
|
|
1170
1124
|
left: u,
|
|
@@ -1179,9 +1133,9 @@ function mn(e, t, n) {
|
|
|
1179
1133
|
toJSON: () => f
|
|
1180
1134
|
};
|
|
1181
1135
|
}
|
|
1182
|
-
function
|
|
1136
|
+
function mn(e, t, n) {
|
|
1183
1137
|
let { selection: r } = t, i = null;
|
|
1184
|
-
if (
|
|
1138
|
+
if (F(r) && (i = r.$cursor), i) {
|
|
1185
1139
|
let t = e.storedMarks ?? i.marks();
|
|
1186
1140
|
return i.parent.type.allowsMarkType(n) && (!!n.isInSet(t) || !t.some((e) => e.type.excludes(n)));
|
|
1187
1141
|
}
|
|
@@ -1198,11 +1152,11 @@ function hn(e, t, n) {
|
|
|
1198
1152
|
}), i;
|
|
1199
1153
|
});
|
|
1200
1154
|
}
|
|
1201
|
-
var
|
|
1202
|
-
let { selection: a } = n, { empty: o, ranges: s } = a, c =
|
|
1155
|
+
var hn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
|
|
1156
|
+
let { selection: a } = n, { empty: o, ranges: s } = a, c = P(e, r.schema);
|
|
1203
1157
|
if (i) {
|
|
1204
1158
|
if (o) {
|
|
1205
|
-
let e =
|
|
1159
|
+
let e = wt(r, c);
|
|
1206
1160
|
n.addStoredMark(c.create({
|
|
1207
1161
|
...e,
|
|
1208
1162
|
...t
|
|
@@ -1220,23 +1174,23 @@ var gn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
|
|
|
1220
1174
|
});
|
|
1221
1175
|
});
|
|
1222
1176
|
}
|
|
1223
|
-
return
|
|
1224
|
-
},
|
|
1225
|
-
let a =
|
|
1226
|
-
return n.selection.$anchor.sameParent(n.selection.$head) && (o = n.selection.$anchor.parent.attrs), a.isTextblock ? i().command(({ commands: e }) =>
|
|
1177
|
+
return mn(r, n, c);
|
|
1178
|
+
}, gn = (e, t) => ({ tr: n }) => (n.setMeta(e, t), !0), _n = (e, t = {}) => ({ state: n, dispatch: r, chain: i }) => {
|
|
1179
|
+
let a = j(e, n.schema), o;
|
|
1180
|
+
return n.selection.$anchor.sameParent(n.selection.$head) && (o = n.selection.$anchor.parent.attrs), a.isTextblock ? i().command(({ commands: e }) => b(a, {
|
|
1227
1181
|
...o,
|
|
1228
1182
|
...t
|
|
1229
|
-
})(n) ? !0 : e.clearNodes()).command(({ state: e }) =>
|
|
1183
|
+
})(n) ? !0 : e.clearNodes()).command(({ state: e }) => b(a, {
|
|
1230
1184
|
...o,
|
|
1231
1185
|
...t
|
|
1232
1186
|
})(e, r)).run() : (console.warn("[tiptap warn]: Currently \"setNode()\" only supports text block nodes."), !1);
|
|
1233
|
-
},
|
|
1187
|
+
}, vn = (e) => ({ tr: t, dispatch: n }) => {
|
|
1234
1188
|
if (n) {
|
|
1235
|
-
let { doc: n } = t, r =
|
|
1189
|
+
let { doc: n } = t, r = I(e, 0, n.content.size), i = C.create(n, r);
|
|
1236
1190
|
t.setSelection(i);
|
|
1237
1191
|
}
|
|
1238
1192
|
return !0;
|
|
1239
|
-
},
|
|
1193
|
+
}, yn = (e, t) => ({ tr: n, state: r, dispatch: i }) => {
|
|
1240
1194
|
let { selection: a } = r, o, s;
|
|
1241
1195
|
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) => {
|
|
1242
1196
|
t.isText || n.setNodeMarkup(r, void 0, {
|
|
@@ -1244,31 +1198,31 @@ var gn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
|
|
|
1244
1198
|
dir: e
|
|
1245
1199
|
});
|
|
1246
1200
|
}), !0;
|
|
1247
|
-
},
|
|
1201
|
+
}, bn = (e) => ({ tr: t, dispatch: n }) => {
|
|
1248
1202
|
if (n) {
|
|
1249
1203
|
let { doc: n } = t, { from: r, to: i } = typeof e == "number" ? {
|
|
1250
1204
|
from: e,
|
|
1251
1205
|
to: e
|
|
1252
|
-
} : e, a =
|
|
1206
|
+
} : e, a = D.atStart(n).from, o = D.atEnd(n).to, s = I(r, a, o), c = I(i, a, o), l = D.create(n, s, c);
|
|
1253
1207
|
t.setSelection(l);
|
|
1254
1208
|
}
|
|
1255
1209
|
return !0;
|
|
1256
|
-
},
|
|
1257
|
-
let r =
|
|
1258
|
-
return
|
|
1210
|
+
}, xn = (e) => ({ state: t, dispatch: n }) => {
|
|
1211
|
+
let r = j(e, t.schema);
|
|
1212
|
+
return de(r)(t, n);
|
|
1259
1213
|
};
|
|
1260
|
-
function
|
|
1214
|
+
function Sn(e, t) {
|
|
1261
1215
|
let n = e.storedMarks || e.selection.$to.parentOffset && e.selection.$from.marks();
|
|
1262
1216
|
if (n) {
|
|
1263
1217
|
let r = n.filter((e) => t?.includes(e.type.name));
|
|
1264
1218
|
e.tr.ensureMarks(r);
|
|
1265
1219
|
}
|
|
1266
1220
|
}
|
|
1267
|
-
var
|
|
1221
|
+
var Cn = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor: i }) => {
|
|
1268
1222
|
let { selection: o, doc: s } = t, { $from: c, $to: l } = o, u = i.extensionManager.attributes, d = J(u, c.node().type.name, c.node().attrs);
|
|
1269
|
-
if (o instanceof
|
|
1223
|
+
if (o instanceof C && o.node.isBlock) return !c.parentOffset || !a(s, c.pos) ? !1 : (r && (e && Sn(n, i.extensionManager.splittableMarks), t.split(c.pos).scrollIntoView()), !0);
|
|
1270
1224
|
if (!c.parent.isBlock) return !1;
|
|
1271
|
-
let f = l.parentOffset === l.parent.content.size, p = c.depth === 0 ? void 0 :
|
|
1225
|
+
let f = l.parentOffset === l.parent.content.size, p = c.depth === 0 ? void 0 : Ye(c.node(-1).contentMatchAt(c.indexAfter(-1))), m = f && p ? [{
|
|
1272
1226
|
type: p,
|
|
1273
1227
|
attrs: d
|
|
1274
1228
|
}] : void 0, h = a(t.doc, t.mapping.map(c.pos), 1, m);
|
|
@@ -1276,15 +1230,15 @@ var wn = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
|
|
|
1276
1230
|
type: p,
|
|
1277
1231
|
attrs: d
|
|
1278
1232
|
}] : void 0), r) {
|
|
1279
|
-
if (h && (o instanceof
|
|
1233
|
+
if (h && (o instanceof D && t.deleteSelection(), t.split(t.mapping.map(c.pos), 1, m), p && !f && !c.parentOffset && c.parent.type !== p)) {
|
|
1280
1234
|
let e = t.mapping.map(c.before()), n = t.doc.resolve(e);
|
|
1281
1235
|
c.node(-1).canReplaceWith(n.index(), n.index() + 1, p) && t.setNodeMarkup(t.mapping.map(c.before()), p);
|
|
1282
1236
|
}
|
|
1283
|
-
e &&
|
|
1237
|
+
e && Sn(n, i.extensionManager.splittableMarks), t.scrollIntoView();
|
|
1284
1238
|
}
|
|
1285
1239
|
return h;
|
|
1286
|
-
},
|
|
1287
|
-
let s =
|
|
1240
|
+
}, wn = (e, t = {}) => ({ tr: n, state: r, dispatch: i, editor: o }) => {
|
|
1241
|
+
let s = j(e, r.schema), { $from: c, $to: l } = r.selection, u = r.selection.node;
|
|
1288
1242
|
if (u && u.isBlock || c.depth < 2 || !c.sameParent(l)) return !1;
|
|
1289
1243
|
let d = c.node(-1);
|
|
1290
1244
|
if (d.type !== s) return !1;
|
|
@@ -1292,20 +1246,20 @@ var wn = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
|
|
|
1292
1246
|
if (c.parent.content.size === 0 && c.node(-1).childCount === c.indexAfter(-1)) {
|
|
1293
1247
|
if (c.depth === 2 || c.node(-3).type !== s || c.index(-2) !== c.node(-2).childCount - 1) return !1;
|
|
1294
1248
|
if (i) {
|
|
1295
|
-
let e =
|
|
1296
|
-
for (let t = c.depth - r; t >= c.depth - 3; --t) e =
|
|
1249
|
+
let e = O.empty, r = c.index(-1) ? 1 : c.index(-2) ? 2 : 3;
|
|
1250
|
+
for (let t = c.depth - r; t >= c.depth - 3; --t) e = O.from(c.node(t).copy(e));
|
|
1297
1251
|
let i = c.indexAfter(-1) < c.node(-2).childCount ? 1 : c.indexAfter(-2) < c.node(-3).childCount ? 2 : 3, a = {
|
|
1298
1252
|
...J(f, c.node().type.name, c.node().attrs),
|
|
1299
1253
|
...t
|
|
1300
1254
|
}, o = s.contentMatch.defaultType?.createAndFill(a) || void 0;
|
|
1301
|
-
e = e.append(
|
|
1255
|
+
e = e.append(O.from(s.createAndFill(null, o) || void 0));
|
|
1302
1256
|
let l = c.before(c.depth - (r - 1));
|
|
1303
|
-
n.replace(l, c.after(-i), new
|
|
1257
|
+
n.replace(l, c.after(-i), new le(e, 4 - r, 0));
|
|
1304
1258
|
let u = -1;
|
|
1305
1259
|
n.doc.nodesBetween(l, n.doc.content.size, (e, t) => {
|
|
1306
1260
|
if (u > -1) return !1;
|
|
1307
1261
|
e.isTextblock && e.content.size === 0 && (u = t + 1);
|
|
1308
|
-
}), u > -1 && n.setSelection(
|
|
1262
|
+
}), u > -1 && n.setSelection(D.near(n.doc.resolve(u))), n.scrollIntoView();
|
|
1309
1263
|
}
|
|
1310
1264
|
return !0;
|
|
1311
1265
|
}
|
|
@@ -1336,65 +1290,65 @@ var wn = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
|
|
|
1336
1290
|
}
|
|
1337
1291
|
return !0;
|
|
1338
1292
|
};
|
|
1339
|
-
function
|
|
1293
|
+
function Tn(e) {
|
|
1340
1294
|
return !e || e === "1" ? null : e;
|
|
1341
1295
|
}
|
|
1342
|
-
function
|
|
1343
|
-
return
|
|
1296
|
+
function En(e, t) {
|
|
1297
|
+
return Tn(e) === Tn(t);
|
|
1344
1298
|
}
|
|
1345
|
-
var
|
|
1299
|
+
var Dn = (e, t) => {
|
|
1346
1300
|
let n = V((e) => e.type === t)(e.selection);
|
|
1347
1301
|
if (!n) return !0;
|
|
1348
1302
|
let r = e.doc.resolve(Math.max(0, n.pos - 1)).before(n.depth);
|
|
1349
1303
|
if (r === void 0) return !0;
|
|
1350
1304
|
let a = e.doc.nodeAt(r);
|
|
1351
|
-
return !(n.node.type === a?.type && i(e.doc, n.pos)) || !
|
|
1352
|
-
},
|
|
1305
|
+
return !(n.node.type === a?.type && i(e.doc, n.pos)) || !En(n.node.attrs.type, a?.attrs.type) || e.join(n.pos), !0;
|
|
1306
|
+
}, On = (e, t) => {
|
|
1353
1307
|
let n = V((e) => e.type === t)(e.selection);
|
|
1354
1308
|
if (!n) return !0;
|
|
1355
1309
|
let r = e.doc.resolve(n.start).after(n.depth);
|
|
1356
1310
|
if (r === void 0) return !0;
|
|
1357
1311
|
let a = e.doc.nodeAt(r);
|
|
1358
|
-
return !(n.node.type === a?.type && i(e.doc, r)) || !
|
|
1312
|
+
return !(n.node.type === a?.type && i(e.doc, r)) || !En(n.node.attrs.type, a?.attrs.type) || e.join(r), !0;
|
|
1359
1313
|
};
|
|
1360
|
-
function
|
|
1314
|
+
function kn(e) {
|
|
1361
1315
|
let t = e.doc, n = t.firstChild;
|
|
1362
1316
|
if (!n) return null;
|
|
1363
1317
|
let r = t.resolve(1), i = t.resolve(n.nodeSize - 1);
|
|
1364
|
-
return
|
|
1318
|
+
return D.between(r, i);
|
|
1365
1319
|
}
|
|
1366
|
-
var
|
|
1367
|
-
let { extensions: d, splittableMarks: f } = i.extensionManager, p =
|
|
1368
|
-
if (!
|
|
1369
|
-
let
|
|
1370
|
-
node:
|
|
1320
|
+
var An = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain: c, commands: l, can: u }) => {
|
|
1321
|
+
let { extensions: d, splittableMarks: f } = i.extensionManager, p = j(e, o.schema), m = j(t, o.schema), { selection: h, storedMarks: g } = o, { $from: _, $to: ee } = h, te = _.blockRange(ee), ne = g || h.$to.parentOffset && h.$from.marks();
|
|
1322
|
+
if (!te) return !1;
|
|
1323
|
+
let v = V((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) ? {
|
|
1324
|
+
node: y,
|
|
1371
1325
|
pos: 0,
|
|
1372
1326
|
depth: 0
|
|
1373
|
-
} : null,
|
|
1374
|
-
if ((
|
|
1375
|
-
if (
|
|
1376
|
-
let n =
|
|
1327
|
+
} : null, x = v ?? b, ae = !!v && te.depth >= 1 && te.depth - v.depth <= 1, S = !!b;
|
|
1328
|
+
if ((ae || S) && x) {
|
|
1329
|
+
if (x.node.type === p) return re && S ? c().command(({ tr: e, dispatch: t }) => {
|
|
1330
|
+
let n = kn(e);
|
|
1377
1331
|
return n ? (e.setSelection(n), t && t(e), !0) : !1;
|
|
1378
1332
|
}).liftListItem(m).run() : l.liftListItem(m);
|
|
1379
|
-
if (
|
|
1333
|
+
if (sn(x.node.type.name, d) && p.validContent(x.node.content)) return c().command(() => (a.setNodeMarkup(x.pos, p), !0)).command(() => Dn(a, p)).command(() => On(a, p)).run();
|
|
1380
1334
|
}
|
|
1381
|
-
return !n || !
|
|
1382
|
-
let e = u().wrapInList(p, r), t =
|
|
1335
|
+
return !n || !ne || !s ? c().command(() => u().wrapInList(p, r) ? !0 : l.clearNodes()).wrapInList(p, r).command(() => Dn(a, p)).command(() => On(a, p)).run() : c().command(() => {
|
|
1336
|
+
let e = u().wrapInList(p, r), t = ne.filter((e) => f.includes(e.type.name));
|
|
1383
1337
|
return a.ensureMarks(t), e ? !0 : l.clearNodes();
|
|
1384
|
-
}).wrapInList(p, r).command(() =>
|
|
1385
|
-
},
|
|
1386
|
-
let { extendEmptyMarkRange: a = !1 } = n, o =
|
|
1387
|
-
return
|
|
1388
|
-
},
|
|
1389
|
-
let a =
|
|
1338
|
+
}).wrapInList(p, r).command(() => Dn(a, p)).command(() => On(a, p)).run();
|
|
1339
|
+
}, jn = (e, t = {}, n = {}) => ({ state: r, commands: i }) => {
|
|
1340
|
+
let { extendEmptyMarkRange: a = !1 } = n, o = P(e, r.schema);
|
|
1341
|
+
return tn(r, o, t) ? i.unsetMark(o, { extendEmptyMarkRange: a }) : i.setMark(o, t);
|
|
1342
|
+
}, Mn = (e, t, n = {}) => ({ state: r, commands: i }) => {
|
|
1343
|
+
let a = j(e, r.schema), o = j(t, r.schema), s = B(r, a, n), c;
|
|
1390
1344
|
return r.selection.$anchor.sameParent(r.selection.$head) && (c = r.selection.$anchor.parent.attrs), s ? i.setNode(o, c) : i.setNode(a, {
|
|
1391
1345
|
...c,
|
|
1392
1346
|
...n
|
|
1393
1347
|
});
|
|
1394
|
-
},
|
|
1395
|
-
let i =
|
|
1396
|
-
return
|
|
1397
|
-
},
|
|
1348
|
+
}, Nn = (e, t = {}) => ({ state: n, commands: r }) => {
|
|
1349
|
+
let i = j(e, n.schema);
|
|
1350
|
+
return B(n, i, t) ? r.lift(i) : r.wrapIn(i, t);
|
|
1351
|
+
}, Pn = () => ({ state: e, dispatch: t }) => {
|
|
1398
1352
|
let n = e.plugins;
|
|
1399
1353
|
for (let r = 0; r < n.length; r += 1) {
|
|
1400
1354
|
let i = n[r], a;
|
|
@@ -1411,7 +1365,7 @@ var jn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain:
|
|
|
1411
1365
|
}
|
|
1412
1366
|
}
|
|
1413
1367
|
return !1;
|
|
1414
|
-
},
|
|
1368
|
+
}, Fn = (e = {}) => ({ tr: t, dispatch: n, editor: r }) => {
|
|
1415
1369
|
let { ignoreClearable: i = !1 } = e, { selection: a } = t, { empty: o, ranges: s } = a;
|
|
1416
1370
|
if (o) return !0;
|
|
1417
1371
|
let { nonClearableMarks: c } = r.extensionManager;
|
|
@@ -1422,27 +1376,27 @@ var jn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain:
|
|
|
1422
1376
|
});
|
|
1423
1377
|
}
|
|
1424
1378
|
return !0;
|
|
1425
|
-
},
|
|
1426
|
-
let { extendEmptyMarkRange: a = !1 } = t, { selection: o } = n, s =
|
|
1379
|
+
}, In = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
|
|
1380
|
+
let { extendEmptyMarkRange: a = !1 } = t, { selection: o } = n, s = P(e, r.schema), { $from: c, empty: l, ranges: u } = o;
|
|
1427
1381
|
if (!i) return !0;
|
|
1428
1382
|
if (l && a) {
|
|
1429
|
-
let { from: e, to: t } = o, r =
|
|
1383
|
+
let { from: e, to: t } = o, r = N(c, s, c.marks().find((e) => e.type === s)?.attrs);
|
|
1430
1384
|
r && (e = r.from, t = r.to), n.removeMark(e, t, s);
|
|
1431
1385
|
} else u.forEach((e) => {
|
|
1432
1386
|
n.removeMark(e.$from.pos, e.$to.pos, s);
|
|
1433
1387
|
});
|
|
1434
1388
|
return n.removeStoredMark(s), !0;
|
|
1435
|
-
},
|
|
1389
|
+
}, Ln = (e) => ({ tr: t, state: n, dispatch: r }) => {
|
|
1436
1390
|
let { selection: i } = n, a, o;
|
|
1437
1391
|
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) => {
|
|
1438
1392
|
if (e.isText) return;
|
|
1439
1393
|
let r = { ...e.attrs };
|
|
1440
1394
|
delete r.dir, t.setNodeMarkup(n, void 0, r);
|
|
1441
1395
|
}), !0;
|
|
1442
|
-
},
|
|
1443
|
-
let a = null, o = null, s =
|
|
1396
|
+
}, Rn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
|
|
1397
|
+
let a = null, o = null, s = ft(typeof e == "string" ? e : e.name, r.schema);
|
|
1444
1398
|
if (!s) return !1;
|
|
1445
|
-
s === "node" && (a =
|
|
1399
|
+
s === "node" && (a = j(e, r.schema)), s === "mark" && (o = P(e, r.schema));
|
|
1446
1400
|
let c = !1;
|
|
1447
1401
|
return n.selection.ranges.forEach((e) => {
|
|
1448
1402
|
let s = e.$from.pos, l = e.$to.pos, u, d, f, p;
|
|
@@ -1471,16 +1425,79 @@ var jn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain:
|
|
|
1471
1425
|
}));
|
|
1472
1426
|
}));
|
|
1473
1427
|
}), c;
|
|
1474
|
-
}, X = new
|
|
1428
|
+
}, X = new T("__tiptap_decorations__"), zn = (e) => ({ tr: t, dispatch: n }) => (n && t.setMeta(X, {
|
|
1475
1429
|
type: "force",
|
|
1476
1430
|
name: e
|
|
1477
|
-
}), !0),
|
|
1478
|
-
let i =
|
|
1479
|
-
return
|
|
1480
|
-
},
|
|
1481
|
-
let i =
|
|
1482
|
-
return
|
|
1483
|
-
},
|
|
1431
|
+
}), !0), Bn = (e, t = {}) => ({ state: n, dispatch: r }) => {
|
|
1432
|
+
let i = j(e, n.schema);
|
|
1433
|
+
return x(i, t)(n, r);
|
|
1434
|
+
}, Vn = (e, t = {}) => ({ state: n, dispatch: r }) => {
|
|
1435
|
+
let i = j(e, n.schema);
|
|
1436
|
+
return fe(i, t)(n, r);
|
|
1437
|
+
}, Hn = /* @__PURE__ */ ge({
|
|
1438
|
+
blur: () => ve,
|
|
1439
|
+
clearContent: () => ye,
|
|
1440
|
+
clearNodes: () => be,
|
|
1441
|
+
command: () => xe,
|
|
1442
|
+
createParagraphNear: () => Se,
|
|
1443
|
+
cut: () => Ce,
|
|
1444
|
+
deleteCurrentNode: () => we,
|
|
1445
|
+
deleteNode: () => Te,
|
|
1446
|
+
deleteRange: () => Ee,
|
|
1447
|
+
deleteSelection: () => Ae,
|
|
1448
|
+
enter: () => je,
|
|
1449
|
+
exitCode: () => Me,
|
|
1450
|
+
extendMarkRange: () => Ie,
|
|
1451
|
+
first: () => Le,
|
|
1452
|
+
focus: () => Ve,
|
|
1453
|
+
forEach: () => He,
|
|
1454
|
+
insertContent: () => Ue,
|
|
1455
|
+
insertContentAt: () => Je,
|
|
1456
|
+
insertDefaultBlock: () => Xe,
|
|
1457
|
+
joinBackward: () => $e,
|
|
1458
|
+
joinDown: () => Qe,
|
|
1459
|
+
joinForward: () => et,
|
|
1460
|
+
joinItemBackward: () => tt,
|
|
1461
|
+
joinItemForward: () => nt,
|
|
1462
|
+
joinTextblockBackward: () => rt,
|
|
1463
|
+
joinTextblockForward: () => it,
|
|
1464
|
+
joinUp: () => Ze,
|
|
1465
|
+
keyboardShortcut: () => st,
|
|
1466
|
+
lift: () => ct,
|
|
1467
|
+
liftEmptyBlock: () => lt,
|
|
1468
|
+
liftListItem: () => ut,
|
|
1469
|
+
newlineInCode: () => dt,
|
|
1470
|
+
resetAttributes: () => mt,
|
|
1471
|
+
scrollIntoView: () => ht,
|
|
1472
|
+
selectAll: () => gt,
|
|
1473
|
+
selectNodeBackward: () => _t,
|
|
1474
|
+
selectNodeForward: () => vt,
|
|
1475
|
+
selectParentNode: () => yt,
|
|
1476
|
+
selectTextblockEnd: () => bt,
|
|
1477
|
+
selectTextblockStart: () => xt,
|
|
1478
|
+
setContent: () => Ct,
|
|
1479
|
+
setMark: () => hn,
|
|
1480
|
+
setMeta: () => gn,
|
|
1481
|
+
setNode: () => _n,
|
|
1482
|
+
setNodeSelection: () => vn,
|
|
1483
|
+
setTextDirection: () => yn,
|
|
1484
|
+
setTextSelection: () => bn,
|
|
1485
|
+
sinkListItem: () => xn,
|
|
1486
|
+
splitBlock: () => Cn,
|
|
1487
|
+
splitListItem: () => wn,
|
|
1488
|
+
toggleList: () => An,
|
|
1489
|
+
toggleMark: () => jn,
|
|
1490
|
+
toggleNode: () => Mn,
|
|
1491
|
+
toggleWrap: () => Nn,
|
|
1492
|
+
undoInputRule: () => Pn,
|
|
1493
|
+
unsetAllMarks: () => Fn,
|
|
1494
|
+
unsetMark: () => In,
|
|
1495
|
+
unsetTextDirection: () => Ln,
|
|
1496
|
+
updateAttributes: () => Rn,
|
|
1497
|
+
updateDecorations: () => zn,
|
|
1498
|
+
wrapIn: () => Bn,
|
|
1499
|
+
wrapInList: () => Vn
|
|
1500
|
+
}), Z = /* @__PURE__ */ new WeakMap();
|
|
1484
1501
|
function Un(e, t) {
|
|
1485
1502
|
Z.set(e, (Z.get(e) ?? 0) + 1);
|
|
1486
1503
|
try {
|
|
@@ -1532,7 +1549,7 @@ function Jn(e, t) {
|
|
|
1532
1549
|
function Yn(e, t, n) {
|
|
1533
1550
|
let { decorations: r, widgetKeys: i } = Jn(t, n);
|
|
1534
1551
|
return {
|
|
1535
|
-
set:
|
|
1552
|
+
set: k.create(e, r),
|
|
1536
1553
|
widgetKeys: i
|
|
1537
1554
|
};
|
|
1538
1555
|
}
|
|
@@ -1588,7 +1605,7 @@ function nr(e, t) {
|
|
|
1588
1605
|
}
|
|
1589
1606
|
function rr(e, t) {
|
|
1590
1607
|
if (e.steps.some((e) => !tr(e))) return { type: "full" };
|
|
1591
|
-
let n =
|
|
1608
|
+
let n = Xt(e).map(({ newRange: e }) => e);
|
|
1592
1609
|
e.steps.forEach((t, r) => {
|
|
1593
1610
|
if (!er(t)) return;
|
|
1594
1611
|
let i = e.mapping.slice(r);
|
|
@@ -1620,7 +1637,7 @@ function ir(e, t, n, r) {
|
|
|
1620
1637
|
} });
|
|
1621
1638
|
}
|
|
1622
1639
|
function ar(e, t, n) {
|
|
1623
|
-
let r = t.decorationSetsByExtension[e] ??
|
|
1640
|
+
let r = t.decorationSetsByExtension[e] ?? k.empty, i = new Set(t.widgetKeysByExtension[e] ?? []);
|
|
1624
1641
|
return {
|
|
1625
1642
|
set: ir(r, n.mapping, n.doc, i),
|
|
1626
1643
|
widgetKeys: i
|
|
@@ -1628,7 +1645,7 @@ function ar(e, t, n) {
|
|
|
1628
1645
|
}
|
|
1629
1646
|
function or(e, t) {
|
|
1630
1647
|
let n = Object.values(t).flatMap((e) => e.find());
|
|
1631
|
-
return
|
|
1648
|
+
return k.create(e, n);
|
|
1632
1649
|
}
|
|
1633
1650
|
function sr(e) {
|
|
1634
1651
|
let t = /* @__PURE__ */ new Set();
|
|
@@ -1682,7 +1699,7 @@ var ur = /* @__PURE__ */ new Set(), dr = class {
|
|
|
1682
1699
|
}
|
|
1683
1700
|
createPlugin() {
|
|
1684
1701
|
let { editor: e, entries: t } = this;
|
|
1685
|
-
return new
|
|
1702
|
+
return new w({
|
|
1686
1703
|
key: X,
|
|
1687
1704
|
state: {
|
|
1688
1705
|
init: (e, n) => {
|
|
@@ -1735,7 +1752,7 @@ var ur = /* @__PURE__ */ new Set(), dr = class {
|
|
|
1735
1752
|
}
|
|
1736
1753
|
},
|
|
1737
1754
|
props: { decorations(e) {
|
|
1738
|
-
return X.getState(e)?.mergedDecorationSet ??
|
|
1755
|
+
return X.getState(e)?.mergedDecorationSet ?? k.empty;
|
|
1739
1756
|
} }
|
|
1740
1757
|
});
|
|
1741
1758
|
}
|
|
@@ -1744,7 +1761,7 @@ var ur = /* @__PURE__ */ new Set(), dr = class {
|
|
|
1744
1761
|
return a.type === "full" ? this.buildFullSet(e, t, i) : this.rebuildRanges(e, t, n, r, i, a.ranges);
|
|
1745
1762
|
}
|
|
1746
1763
|
rebuildRanges(e, t, n, r, i, a) {
|
|
1747
|
-
let o = n.decorationSetsByExtension[e] ??
|
|
1764
|
+
let o = n.decorationSetsByExtension[e] ?? k.empty, s = new Set(n.widgetKeysByExtension[e] ?? []), c = ir(o, r.mapping, r.doc, s), l = i.doc.content.size;
|
|
1748
1765
|
for (let { from: n, to: r } of a) {
|
|
1749
1766
|
let a = c.find(n, r).filter((e) => Xn({
|
|
1750
1767
|
position: e.from,
|
|
@@ -1818,7 +1835,7 @@ var ur = /* @__PURE__ */ new Set(), dr = class {
|
|
|
1818
1835
|
};
|
|
1819
1836
|
function fr(e, t) {
|
|
1820
1837
|
let { selection: n } = e, { $from: r } = n;
|
|
1821
|
-
if (n instanceof
|
|
1838
|
+
if (n instanceof C) {
|
|
1822
1839
|
let e = r.index();
|
|
1823
1840
|
return r.parent.canReplaceWith(e, e + 1, t);
|
|
1824
1841
|
}
|
|
@@ -1861,290 +1878,68 @@ function vr(e) {
|
|
|
1861
1878
|
function yr(e) {
|
|
1862
1879
|
return vr(e) === "Object" && e.constructor === Object && Object.getPrototypeOf(e) === Object.prototype;
|
|
1863
1880
|
}
|
|
1864
|
-
|
|
1865
|
-
createAtomBlockMarkdownSpec: () => Sr,
|
|
1866
|
-
createBlockMarkdownSpec: () => Cr,
|
|
1867
|
-
createInlineMarkdownSpec: () => Er,
|
|
1868
|
-
parseAttributes: () => br,
|
|
1869
|
-
parseIndentedBlocks: () => Dr,
|
|
1870
|
-
renderNestedMarkdownContent: () => Or,
|
|
1871
|
-
serializeAttributes: () => xr
|
|
1872
|
-
});
|
|
1873
|
-
function br(e) {
|
|
1874
|
-
if (!e?.trim()) return {};
|
|
1875
|
-
let t = {}, n = [], r = e.replace(/["']([^"']*)["']/g, (e) => (n.push(e), `__QUOTED_${n.length - 1}__`)), i = r.match(/(?:^|\s)\.([\w-]+)/g);
|
|
1876
|
-
i && (t.class = i.map((e) => e.trim().slice(1)).join(" "));
|
|
1877
|
-
let a = r.match(/(?:^|\s)#([\w-]+)/);
|
|
1878
|
-
a && (t.id = a[1]), Array.from(r.matchAll(/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g)).forEach(([, e, r]) => {
|
|
1879
|
-
let i = parseInt(r.match(/__QUOTED_(\d+)__/)?.[1] || "0", 10), a = n[i];
|
|
1880
|
-
a && (t[e] = a.slice(1, -1));
|
|
1881
|
-
});
|
|
1882
|
-
let o = r.replace(/(?:^|\s)\.([\w-]+)/g, "").replace(/(?:^|\s)#([\w-]+)/g, "").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g, "").trim();
|
|
1883
|
-
return o && o.split(/\s+/).filter(Boolean).forEach((e) => {
|
|
1884
|
-
e.match(/^[a-zA-Z][\w-]*$/) && (t[e] = !0);
|
|
1885
|
-
}), t;
|
|
1886
|
-
}
|
|
1887
|
-
function xr(e) {
|
|
1888
|
-
if (!e || Object.keys(e).length === 0) return "";
|
|
1889
|
-
let t = [];
|
|
1890
|
-
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]) => {
|
|
1891
|
-
e !== "class" && e !== "id" && (n === !0 ? t.push(e) : n !== !1 && n != null && t.push(`${e}="${String(n)}"`));
|
|
1892
|
-
}), t.join(" ");
|
|
1893
|
-
}
|
|
1894
|
-
function Sr(e) {
|
|
1895
|
-
let { nodeName: t, name: n, parseAttributes: r = br, serializeAttributes: i = xr, defaultAttributes: a = {}, requiredAttributes: o = [], allowedAttributes: s } = e, c = n || t, l = (e) => {
|
|
1896
|
-
if (!s) return e;
|
|
1897
|
-
let t = {};
|
|
1898
|
-
return s.forEach((n) => {
|
|
1899
|
-
n in e && (t[n] = e[n]);
|
|
1900
|
-
}), t;
|
|
1901
|
-
};
|
|
1902
|
-
return {
|
|
1903
|
-
parseMarkdown: (e, n) => {
|
|
1904
|
-
let r = {
|
|
1905
|
-
...a,
|
|
1906
|
-
...e.attributes
|
|
1907
|
-
};
|
|
1908
|
-
return n.createNode(t, r, []);
|
|
1909
|
-
},
|
|
1910
|
-
markdownTokenizer: {
|
|
1911
|
-
name: t,
|
|
1912
|
-
level: "block",
|
|
1913
|
-
start(e) {
|
|
1914
|
-
let t = RegExp(`^:::${c}(?:\\s|$)`, "m"), n = e.match(t)?.index;
|
|
1915
|
-
return n === void 0 ? -1 : n;
|
|
1916
|
-
},
|
|
1917
|
-
tokenize(e, n, i) {
|
|
1918
|
-
let a = RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`), s = e.match(a);
|
|
1919
|
-
if (!s) return;
|
|
1920
|
-
let l = s[1] || "", u = r(l);
|
|
1921
|
-
if (!o.find((e) => !(e in u))) return {
|
|
1922
|
-
type: t,
|
|
1923
|
-
raw: s[0],
|
|
1924
|
-
attributes: u
|
|
1925
|
-
};
|
|
1926
|
-
}
|
|
1927
|
-
},
|
|
1928
|
-
renderMarkdown: (e) => {
|
|
1929
|
-
let t = l(e.attrs || {}), n = i(t), r = n ? ` {${n}}` : "";
|
|
1930
|
-
return `:::${c}${r} :::`;
|
|
1931
|
-
}
|
|
1932
|
-
};
|
|
1933
|
-
}
|
|
1934
|
-
function Cr(e) {
|
|
1935
|
-
let { nodeName: t, name: n, getContent: r, parseAttributes: i = br, serializeAttributes: a = xr, defaultAttributes: o = {}, content: s = "block", allowedAttributes: c } = e, l = n || t, u = (e) => {
|
|
1936
|
-
if (!c) return e;
|
|
1937
|
-
let t = {};
|
|
1938
|
-
return c.forEach((n) => {
|
|
1939
|
-
n in e && (t[n] = e[n]);
|
|
1940
|
-
}), t;
|
|
1941
|
-
};
|
|
1942
|
-
return {
|
|
1943
|
-
parseMarkdown: (e, n) => {
|
|
1944
|
-
let i;
|
|
1945
|
-
if (r) {
|
|
1946
|
-
let t = r(e);
|
|
1947
|
-
i = typeof t == "string" ? [{
|
|
1948
|
-
type: "text",
|
|
1949
|
-
text: t
|
|
1950
|
-
}] : t;
|
|
1951
|
-
} else i = s === "block" ? n.parseChildren(e.tokens || []) : n.parseInline(e.tokens || []);
|
|
1952
|
-
let a = {
|
|
1953
|
-
...o,
|
|
1954
|
-
...e.attributes
|
|
1955
|
-
};
|
|
1956
|
-
return n.createNode(t, a, i);
|
|
1957
|
-
},
|
|
1958
|
-
markdownTokenizer: {
|
|
1959
|
-
name: t,
|
|
1960
|
-
level: "block",
|
|
1961
|
-
start(e) {
|
|
1962
|
-
let t = RegExp(`^:::${l}`, "m"), n = e.match(t)?.index;
|
|
1963
|
-
return n === void 0 ? -1 : n;
|
|
1964
|
-
},
|
|
1965
|
-
tokenize(e, n, r) {
|
|
1966
|
-
let a = RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*\\n`), o = e.match(a);
|
|
1967
|
-
if (!o) return;
|
|
1968
|
-
let [c, u = ""] = o, d = i(u), f = 1, p = c.length, m = "", h = /^:::([\w-]*)(\s.*)?/gm, g = e.slice(p);
|
|
1969
|
-
for (h.lastIndex = 0;;) {
|
|
1970
|
-
let n = h.exec(g);
|
|
1971
|
-
if (n === null) break;
|
|
1972
|
-
let i = n.index, a = n[1];
|
|
1973
|
-
if (!n[2]?.endsWith(":::")) {
|
|
1974
|
-
if (a) f += 1;
|
|
1975
|
-
else if (--f, f === 0) {
|
|
1976
|
-
let a = g.slice(0, i);
|
|
1977
|
-
m = a.trim();
|
|
1978
|
-
let o = e.slice(0, p + i + n[0].length), c = [];
|
|
1979
|
-
if (m) {
|
|
1980
|
-
if (s === "block") for (c = r.blockTokens(a), c.forEach((e) => {
|
|
1981
|
-
e.text && (!e.tokens || e.tokens.length === 0) && (e.tokens = r.inlineTokens(e.text));
|
|
1982
|
-
}); c.length > 0;) {
|
|
1983
|
-
let e = c[c.length - 1];
|
|
1984
|
-
if (e.type === "paragraph" && (!e.text || e.text.trim() === "")) c.pop();
|
|
1985
|
-
else break;
|
|
1986
|
-
}
|
|
1987
|
-
else c = r.inlineTokens(m);
|
|
1988
|
-
}
|
|
1989
|
-
return {
|
|
1990
|
-
type: t,
|
|
1991
|
-
raw: o,
|
|
1992
|
-
attributes: d,
|
|
1993
|
-
content: m,
|
|
1994
|
-
tokens: c
|
|
1995
|
-
};
|
|
1996
|
-
}
|
|
1997
|
-
}
|
|
1998
|
-
}
|
|
1999
|
-
}
|
|
2000
|
-
},
|
|
2001
|
-
renderMarkdown: (e, t) => {
|
|
2002
|
-
let n = u(e.attrs || {}), r = a(n), i = r ? ` {${r}}` : "", o = t.renderChildren(e.content || [], "\n\n");
|
|
2003
|
-
return `:::${l}${i}
|
|
2004
|
-
|
|
2005
|
-
${o}
|
|
2006
|
-
|
|
2007
|
-
:::`;
|
|
2008
|
-
}
|
|
2009
|
-
};
|
|
2010
|
-
}
|
|
2011
|
-
function wr(e) {
|
|
2012
|
-
if (!e.trim()) return {};
|
|
2013
|
-
let t = {}, n = /(\w+)=(?:"([^"]*)"|'([^']*)')/g, r = n.exec(e);
|
|
2014
|
-
for (; r !== null;) {
|
|
2015
|
-
let [, i, a, o] = r;
|
|
2016
|
-
t[i] = a || o, r = n.exec(e);
|
|
2017
|
-
}
|
|
2018
|
-
return t;
|
|
2019
|
-
}
|
|
2020
|
-
function Tr(e) {
|
|
2021
|
-
return Object.entries(e).filter(([, e]) => e != null).map(([e, t]) => `${e}="${t}"`).join(" ");
|
|
2022
|
-
}
|
|
2023
|
-
function Er(e) {
|
|
2024
|
-
let { nodeName: t, name: n, getContent: r, parseAttributes: i = wr, serializeAttributes: a = Tr, defaultAttributes: o = {}, selfClosing: s = !1, allowedAttributes: c } = e, l = n || t, u = (e) => {
|
|
2025
|
-
if (!c) return e;
|
|
2026
|
-
let t = {};
|
|
2027
|
-
return c.forEach((n) => {
|
|
2028
|
-
let r = typeof n == "string" ? n : n.name, i = typeof n == "string" ? void 0 : n.skipIfDefault;
|
|
2029
|
-
if (r in e) {
|
|
2030
|
-
let n = e[r];
|
|
2031
|
-
if (i !== void 0 && n === i) return;
|
|
2032
|
-
t[r] = n;
|
|
2033
|
-
}
|
|
2034
|
-
}), t;
|
|
2035
|
-
}, d = l.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2036
|
-
return {
|
|
2037
|
-
parseMarkdown: (e, n) => {
|
|
2038
|
-
let i = {
|
|
2039
|
-
...o,
|
|
2040
|
-
...e.attributes
|
|
2041
|
-
};
|
|
2042
|
-
if (s) return n.createNode(t, i);
|
|
2043
|
-
let a = r ? r(e) : e.content || "";
|
|
2044
|
-
return a ? n.createNode(t, i, [n.createTextNode(a)]) : n.createNode(t, i, []);
|
|
2045
|
-
},
|
|
2046
|
-
markdownTokenizer: {
|
|
2047
|
-
name: t,
|
|
2048
|
-
level: "inline",
|
|
2049
|
-
start(e) {
|
|
2050
|
-
let t = RegExp(s ? `\\[${d}\\s*[^\\]]*\\]` : `\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`), n = e.match(t)?.index;
|
|
2051
|
-
return n === void 0 ? -1 : n;
|
|
2052
|
-
},
|
|
2053
|
-
tokenize(e, n, r) {
|
|
2054
|
-
let a = RegExp(s ? `^\\[${d}\\s*([^\\]]*)\\]` : `^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`), o = e.match(a);
|
|
2055
|
-
if (!o) return;
|
|
2056
|
-
let c = "", l = "";
|
|
2057
|
-
if (s) {
|
|
2058
|
-
let [, e] = o;
|
|
2059
|
-
l = e;
|
|
2060
|
-
} else {
|
|
2061
|
-
let [, e, t] = o;
|
|
2062
|
-
l = e, c = t || "";
|
|
2063
|
-
}
|
|
2064
|
-
let u = i(l.trim());
|
|
2065
|
-
return {
|
|
2066
|
-
type: t,
|
|
2067
|
-
raw: o[0],
|
|
2068
|
-
content: c.trim(),
|
|
2069
|
-
attributes: u
|
|
2070
|
-
};
|
|
2071
|
-
}
|
|
2072
|
-
},
|
|
2073
|
-
renderMarkdown: (e) => {
|
|
2074
|
-
let t = "";
|
|
2075
|
-
r ? t = r(e) : e.content && e.content.length > 0 && (t = e.content.filter((e) => e.type === "text").map((e) => e.text).join(""));
|
|
2076
|
-
let n = u(e.attrs || {}), i = a(n), o = i ? ` ${i}` : "";
|
|
2077
|
-
return s ? `[${l}${o}]` : `[${l}${o}]${t}[/${l}]`;
|
|
2078
|
-
}
|
|
2079
|
-
};
|
|
2080
|
-
}
|
|
2081
|
-
function Dr(e, t, n) {
|
|
1881
|
+
function br(e, t, n) {
|
|
2082
1882
|
let r = e.split("\n"), i = [], a = "", o = 0, s = t.baseIndentSize || 2;
|
|
2083
1883
|
for (; o < r.length;) {
|
|
2084
|
-
let e = r[o],
|
|
2085
|
-
if (!
|
|
1884
|
+
let e = r[o], u = e.match(t.itemPattern);
|
|
1885
|
+
if (!u) {
|
|
2086
1886
|
if (i.length > 0) break;
|
|
2087
1887
|
if (e.trim() === "") {
|
|
2088
|
-
o += 1, a = `${a}${e}
|
|
2089
|
-
`;
|
|
1888
|
+
o += 1, a = `${a}${e}\n`;
|
|
2090
1889
|
continue;
|
|
2091
1890
|
}
|
|
2092
1891
|
return;
|
|
2093
1892
|
}
|
|
2094
|
-
let
|
|
2095
|
-
a = `${a}${e}
|
|
2096
|
-
|
|
2097
|
-
let f = [d];
|
|
1893
|
+
let d = t.extractItemData(u), { indentLevel: f, mainContent: p } = d;
|
|
1894
|
+
a = `${a}${e}\n`;
|
|
1895
|
+
let m = [p];
|
|
2098
1896
|
for (o += 1; o < r.length;) {
|
|
1897
|
+
var c;
|
|
2099
1898
|
let e = r[o];
|
|
2100
1899
|
if (e.trim() === "") {
|
|
1900
|
+
var l;
|
|
2101
1901
|
let t = r.slice(o + 1).findIndex((e) => e.trim() !== "");
|
|
2102
1902
|
if (t === -1) break;
|
|
2103
|
-
if ((r[o + 1 + t].match(/^(\s*)/)
|
|
2104
|
-
|
|
2105
|
-
`, o += 1;
|
|
1903
|
+
if ((((l = r[o + 1 + t].match(/^(\s*)/)) == null || (l = l[1]) == null ? void 0 : l.length) || 0) > f) {
|
|
1904
|
+
m.push(e), a = `${a}${e}\n`, o += 1;
|
|
2106
1905
|
continue;
|
|
2107
1906
|
}
|
|
2108
1907
|
break;
|
|
2109
1908
|
}
|
|
2110
|
-
if ((e.match(/^(\s*)/)
|
|
2111
|
-
`, o += 1;
|
|
1909
|
+
if ((((c = e.match(/^(\s*)/)) == null || (c = c[1]) == null ? void 0 : c.length) || 0) > f) m.push(e), a = `${a}${e}\n`, o += 1;
|
|
2112
1910
|
else break;
|
|
2113
1911
|
}
|
|
2114
|
-
let
|
|
2115
|
-
if (
|
|
2116
|
-
let e =
|
|
2117
|
-
e.trim() && (
|
|
1912
|
+
let h, g = m.slice(1);
|
|
1913
|
+
if (g.length > 0) {
|
|
1914
|
+
let e = g.map((e) => e.slice(f + s)).join("\n");
|
|
1915
|
+
e.trim() && (h = t.customNestedParser ? t.customNestedParser(e) : n.blockTokens(e));
|
|
2118
1916
|
}
|
|
2119
|
-
let
|
|
2120
|
-
i.push(
|
|
1917
|
+
let _ = t.createToken(d, h);
|
|
1918
|
+
i.push(_);
|
|
2121
1919
|
}
|
|
2122
1920
|
if (i.length !== 0) return {
|
|
2123
1921
|
items: i,
|
|
2124
1922
|
raw: a
|
|
2125
1923
|
};
|
|
2126
1924
|
}
|
|
2127
|
-
function
|
|
1925
|
+
function xr(e, t, n, r) {
|
|
2128
1926
|
if (!e || !Array.isArray(e.content)) return "";
|
|
2129
1927
|
let i = typeof n == "function" ? n(r) : n, [a, ...o] = e.content, s = `${i}${t.renderChildren([a])}`;
|
|
2130
1928
|
return o && o.length > 0 && o.forEach((e, n) => {
|
|
2131
1929
|
let r = t.renderChild?.call(t, e, n + 1) ?? t.renderChildren([e]);
|
|
2132
1930
|
if (r != null) {
|
|
2133
1931
|
let n = r.split("\n").map((e) => e ? t.indent(e) : t.indent("")).join("\n");
|
|
2134
|
-
s += e.type === "paragraph" ? `
|
|
2135
|
-
|
|
2136
|
-
${n}` : `
|
|
2137
|
-
${n}`;
|
|
1932
|
+
s += e.type === "paragraph" ? `\n\n${n}` : `\n${n}`;
|
|
2138
1933
|
}
|
|
2139
1934
|
}), s;
|
|
2140
1935
|
}
|
|
2141
|
-
function
|
|
1936
|
+
function Sr(e, t) {
|
|
2142
1937
|
let n = { ...e };
|
|
2143
1938
|
return yr(e) && yr(t) && Object.keys(t).forEach((r) => {
|
|
2144
|
-
yr(t[r]) && yr(e[r]) ? n[r] =
|
|
1939
|
+
yr(t[r]) && yr(e[r]) ? n[r] = Sr(e[r], t[r]) : n[r] = t[r];
|
|
2145
1940
|
}), n;
|
|
2146
1941
|
}
|
|
2147
|
-
function
|
|
1942
|
+
function Cr(e, t, n = {}) {
|
|
2148
1943
|
let { state: r } = t, { doc: i, tr: a } = r, o = e;
|
|
2149
1944
|
i.descendants((t, r) => {
|
|
2150
1945
|
let i = a.mapping.map(r), s = a.mapping.map(r) + t.nodeSize, c = null;
|
|
@@ -2168,35 +1963,35 @@ var Q = class {
|
|
|
2168
1963
|
constructor(e) {
|
|
2169
1964
|
this.find = e.find, this.handler = e.handler, this.undoable = e.undoable ?? !0;
|
|
2170
1965
|
}
|
|
2171
|
-
},
|
|
2172
|
-
if (
|
|
1966
|
+
}, wr = (e, t) => {
|
|
1967
|
+
if (Ne(t)) return t.exec(e);
|
|
2173
1968
|
let n = t(e);
|
|
2174
1969
|
if (!n) return null;
|
|
2175
1970
|
let r = [n.text];
|
|
2176
1971
|
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;
|
|
2177
1972
|
};
|
|
2178
|
-
function
|
|
1973
|
+
function Tr(e) {
|
|
2179
1974
|
let { editor: t, from: n, to: r, text: i, rules: a, plugin: o } = e, { view: s } = t;
|
|
2180
1975
|
if (s.composing) return !1;
|
|
2181
1976
|
let c = s.state.doc.resolve(n);
|
|
2182
1977
|
if (c.parent.type.spec.code || (c.nodeBefore || c.nodeAfter)?.marks.find((e) => e.type.spec.code)) return !1;
|
|
2183
|
-
let l = !1, u =
|
|
1978
|
+
let l = !1, u = en(c) + i;
|
|
2184
1979
|
return a.forEach((e) => {
|
|
2185
1980
|
if (l) return;
|
|
2186
|
-
let a =
|
|
1981
|
+
let a = wr(u, e.find);
|
|
2187
1982
|
if (!a) return;
|
|
2188
1983
|
let d = a[0].length - i.length;
|
|
2189
1984
|
if (d > 0) {
|
|
2190
1985
|
let e = c.parentOffset - d;
|
|
2191
1986
|
if (e < 0 || c.parent.textBetween(e, c.parentOffset) !== a[0].slice(0, d)) return;
|
|
2192
1987
|
}
|
|
2193
|
-
let f = s.state.tr, p =
|
|
1988
|
+
let f = s.state.tr, p = _e({
|
|
2194
1989
|
state: s.state,
|
|
2195
1990
|
transaction: f
|
|
2196
1991
|
}), m = {
|
|
2197
1992
|
from: n - (a[0].length - i.length),
|
|
2198
1993
|
to: r
|
|
2199
|
-
}, { commands: h, chain: g, can:
|
|
1994
|
+
}, { commands: h, chain: g, can: _ } = new A({
|
|
2200
1995
|
editor: t,
|
|
2201
1996
|
state: p
|
|
2202
1997
|
});
|
|
@@ -2206,7 +2001,7 @@ function Mr(e) {
|
|
|
2206
2001
|
match: a,
|
|
2207
2002
|
commands: h,
|
|
2208
2003
|
chain: g,
|
|
2209
|
-
can:
|
|
2004
|
+
can: _
|
|
2210
2005
|
}) === null || !f.steps.length || (e.undoable && f.setMeta(o, {
|
|
2211
2006
|
transform: f,
|
|
2212
2007
|
from: n,
|
|
@@ -2215,8 +2010,8 @@ function Mr(e) {
|
|
|
2215
2010
|
}), s.dispatch(f), l = !0);
|
|
2216
2011
|
}), l;
|
|
2217
2012
|
}
|
|
2218
|
-
function
|
|
2219
|
-
let { editor: t, rules: n } = e, r = new
|
|
2013
|
+
function Er(e) {
|
|
2014
|
+
let { editor: t, rules: n } = e, r = new w({
|
|
2220
2015
|
state: {
|
|
2221
2016
|
init() {
|
|
2222
2017
|
return null;
|
|
@@ -2227,9 +2022,9 @@ function Nr(e) {
|
|
|
2227
2022
|
let s = e.getMeta("applyInputRules");
|
|
2228
2023
|
return s && setTimeout(() => {
|
|
2229
2024
|
let { text: e } = s;
|
|
2230
|
-
e = typeof e == "string" ? e :
|
|
2025
|
+
e = typeof e == "string" ? e : kt(O.from(e), a.schema);
|
|
2231
2026
|
let { from: i } = s, o = i + e.length;
|
|
2232
|
-
|
|
2027
|
+
Tr({
|
|
2233
2028
|
editor: t,
|
|
2234
2029
|
from: i,
|
|
2235
2030
|
to: o,
|
|
@@ -2242,7 +2037,7 @@ function Nr(e) {
|
|
|
2242
2037
|
},
|
|
2243
2038
|
props: {
|
|
2244
2039
|
handleTextInput(e, i, a, o) {
|
|
2245
|
-
return
|
|
2040
|
+
return Tr({
|
|
2246
2041
|
editor: t,
|
|
2247
2042
|
from: i,
|
|
2248
2043
|
to: a,
|
|
@@ -2253,7 +2048,7 @@ function Nr(e) {
|
|
|
2253
2048
|
},
|
|
2254
2049
|
handleDOMEvents: { compositionend: (e) => (setTimeout(() => {
|
|
2255
2050
|
let { $cursor: i } = e.state.selection;
|
|
2256
|
-
i &&
|
|
2051
|
+
i && Tr({
|
|
2257
2052
|
editor: t,
|
|
2258
2053
|
from: i.pos,
|
|
2259
2054
|
to: i.pos,
|
|
@@ -2265,7 +2060,7 @@ function Nr(e) {
|
|
|
2265
2060
|
handleKeyDown(e, i) {
|
|
2266
2061
|
if (i.key !== "Enter") return !1;
|
|
2267
2062
|
let { $cursor: a } = e.state.selection;
|
|
2268
|
-
return a ?
|
|
2063
|
+
return a ? Tr({
|
|
2269
2064
|
editor: t,
|
|
2270
2065
|
from: a.pos,
|
|
2271
2066
|
to: a.pos,
|
|
@@ -2279,7 +2074,7 @@ function Nr(e) {
|
|
|
2279
2074
|
});
|
|
2280
2075
|
return r;
|
|
2281
2076
|
}
|
|
2282
|
-
var
|
|
2077
|
+
var Dr = class {
|
|
2283
2078
|
constructor(e = {}) {
|
|
2284
2079
|
this.type = "extendable", this.parent = null, this.child = null, this.name = "", this.config = { name: this.name }, this.config = {
|
|
2285
2080
|
...this.config,
|
|
@@ -2298,7 +2093,7 @@ var Pr = class {
|
|
|
2298
2093
|
configure(e = {}) {
|
|
2299
2094
|
let t = this.extend({
|
|
2300
2095
|
...this.config,
|
|
2301
|
-
addOptions: () =>
|
|
2096
|
+
addOptions: () => Sr(this.options, e)
|
|
2302
2097
|
});
|
|
2303
2098
|
return t.name = this.name, t.parent = this.parent, this.child = null, t;
|
|
2304
2099
|
}
|
|
@@ -2309,9 +2104,9 @@ var Pr = class {
|
|
|
2309
2104
|
});
|
|
2310
2105
|
return t.parent = this, this.child = t, t.name = "name" in e ? e.name : t.parent.name, t;
|
|
2311
2106
|
}
|
|
2312
|
-
},
|
|
2313
|
-
constructor() {
|
|
2314
|
-
super(...
|
|
2107
|
+
}, Or = class e extends Dr {
|
|
2108
|
+
constructor(...e) {
|
|
2109
|
+
super(...e), this.type = "mark";
|
|
2315
2110
|
}
|
|
2316
2111
|
static create(t = {}) {
|
|
2317
2112
|
let n = typeof t == "function" ? t() : t;
|
|
@@ -2334,29 +2129,30 @@ var Pr = class {
|
|
|
2334
2129
|
let t = typeof e == "function" ? e() : e;
|
|
2335
2130
|
return super.extend(t);
|
|
2336
2131
|
}
|
|
2337
|
-
},
|
|
2132
|
+
}, kr = class {
|
|
2338
2133
|
constructor(e) {
|
|
2339
2134
|
this.find = e.find, this.handler = e.handler;
|
|
2340
2135
|
}
|
|
2341
|
-
},
|
|
2342
|
-
if (
|
|
2136
|
+
}, Ar = (e, t, n) => {
|
|
2137
|
+
if (Ne(t)) return [...e.matchAll(t)];
|
|
2343
2138
|
let r = t(e, n);
|
|
2344
2139
|
return r ? r.map((t) => {
|
|
2345
2140
|
let n = [t.text];
|
|
2346
2141
|
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;
|
|
2347
2142
|
}) : [];
|
|
2348
2143
|
};
|
|
2349
|
-
function
|
|
2350
|
-
let { editor: t, state: n, from: r, to: i, rule: a, pasteEvent: o, dropEvent: s } = e, { commands: c, chain: l, can: u } = new
|
|
2144
|
+
function jr(e) {
|
|
2145
|
+
let { editor: t, state: n, from: r, to: i, rule: a, pasteEvent: o, dropEvent: s } = e, { commands: c, chain: l, can: u } = new A({
|
|
2351
2146
|
editor: t,
|
|
2352
2147
|
state: n
|
|
2353
2148
|
}), d = [];
|
|
2354
2149
|
return n.doc.nodesBetween(r, i, (e, t) => {
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
p
|
|
2150
|
+
var f;
|
|
2151
|
+
if ((f = e.type) != null && (f = f.spec) != null && f.code || !(e.isText || e.isTextblock || e.isInline)) return;
|
|
2152
|
+
let p = e.content?.size ?? e.nodeSize ?? 0, m = Math.max(r, t), h = Math.min(i, t + p);
|
|
2153
|
+
m >= h || Ar(e.isText ? e.text || "" : e.textBetween(m - t, h - t, void 0, ""), a.find, o).forEach((e) => {
|
|
2358
2154
|
if (e.index === void 0) return;
|
|
2359
|
-
let t =
|
|
2155
|
+
let t = m + e.index + 1, r = t + e[0].length, i = {
|
|
2360
2156
|
from: n.tr.mapping.map(t),
|
|
2361
2157
|
to: n.tr.mapping.map(r)
|
|
2362
2158
|
}, f = a.handler({
|
|
@@ -2373,12 +2169,12 @@ function Rr(e) {
|
|
|
2373
2169
|
});
|
|
2374
2170
|
}), d.every((e) => e !== null);
|
|
2375
2171
|
}
|
|
2376
|
-
var
|
|
2172
|
+
var Mr = null, Nr = (e) => {
|
|
2377
2173
|
var t;
|
|
2378
2174
|
let n = new ClipboardEvent("paste", { clipboardData: new DataTransfer() });
|
|
2379
2175
|
return (t = n.clipboardData) == null || t.setData("text/html", e), n;
|
|
2380
2176
|
};
|
|
2381
|
-
function
|
|
2177
|
+
function Pr(e) {
|
|
2382
2178
|
let { editor: t, rules: n } = e, r = null, i = !1, a = !1, o = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, s;
|
|
2383
2179
|
try {
|
|
2384
2180
|
s = typeof DragEvent < "u" ? new DragEvent("drop") : null;
|
|
@@ -2386,11 +2182,11 @@ function Vr(e) {
|
|
|
2386
2182
|
s = null;
|
|
2387
2183
|
}
|
|
2388
2184
|
let c = ({ state: e, from: n, to: r, rule: i, pasteEvt: a }) => {
|
|
2389
|
-
let c = e.tr, l =
|
|
2185
|
+
let c = e.tr, l = _e({
|
|
2390
2186
|
state: e,
|
|
2391
2187
|
transaction: c
|
|
2392
2188
|
});
|
|
2393
|
-
if (!(!
|
|
2189
|
+
if (!(!jr({
|
|
2394
2190
|
editor: t,
|
|
2395
2191
|
state: l,
|
|
2396
2192
|
from: Math.max(n - 1, 0),
|
|
@@ -2407,12 +2203,12 @@ function Vr(e) {
|
|
|
2407
2203
|
return o = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, c;
|
|
2408
2204
|
}
|
|
2409
2205
|
};
|
|
2410
|
-
return n.map((e) => new
|
|
2206
|
+
return n.map((e) => new w({
|
|
2411
2207
|
view(e) {
|
|
2412
2208
|
let n = (n) => {
|
|
2413
|
-
r = e.dom.parentElement?.contains(n.target) ? e.dom.parentElement : null, r && (
|
|
2209
|
+
r = e.dom.parentElement?.contains(n.target) ? e.dom.parentElement : null, r && (Mr = t);
|
|
2414
2210
|
}, i = () => {
|
|
2415
|
-
|
|
2211
|
+
Mr &&= null;
|
|
2416
2212
|
};
|
|
2417
2213
|
return window.addEventListener("dragstart", n), window.addEventListener("dragend", i), { destroy() {
|
|
2418
2214
|
window.removeEventListener("dragstart", n), window.removeEventListener("dragend", i);
|
|
@@ -2421,7 +2217,7 @@ function Vr(e) {
|
|
|
2421
2217
|
props: { handleDOMEvents: {
|
|
2422
2218
|
drop: (e, t) => {
|
|
2423
2219
|
if (a = r === e.dom.parentElement, s = t, !a) {
|
|
2424
|
-
let e =
|
|
2220
|
+
let e = Mr;
|
|
2425
2221
|
e?.isEditable && setTimeout(() => {
|
|
2426
2222
|
let t = e.state.selection;
|
|
2427
2223
|
t && e.commands.deleteRange({
|
|
@@ -2442,8 +2238,8 @@ function Vr(e) {
|
|
|
2442
2238
|
if (!l && !u && !f) return;
|
|
2443
2239
|
if (f) {
|
|
2444
2240
|
let { text: t } = d;
|
|
2445
|
-
t = typeof t == "string" ? t :
|
|
2446
|
-
let { from: n } = d, i = n + t.length, a =
|
|
2241
|
+
t = typeof t == "string" ? t : kt(O.from(t), r.schema);
|
|
2242
|
+
let { from: n } = d, i = n + t.length, a = Nr(t);
|
|
2447
2243
|
return c({
|
|
2448
2244
|
rule: e,
|
|
2449
2245
|
state: r,
|
|
@@ -2463,9 +2259,9 @@ function Vr(e) {
|
|
|
2463
2259
|
}
|
|
2464
2260
|
}));
|
|
2465
2261
|
}
|
|
2466
|
-
var
|
|
2262
|
+
var Fr = class {
|
|
2467
2263
|
constructor(e, t) {
|
|
2468
|
-
this.splittableMarks = [], this.nonClearableMarks = [], this.decorationManager = null, this.editor = t, this.baseExtensions = e, this.extensions =
|
|
2264
|
+
this.splittableMarks = [], this.nonClearableMarks = [], this.decorationManager = null, this.editor = t, this.baseExtensions = e, this.extensions = Ht(e), this.schema = Bt(this.extensions, t), this.setupExtensions();
|
|
2469
2265
|
}
|
|
2470
2266
|
get commands() {
|
|
2471
2267
|
return this.extensions.reduce((e, t) => {
|
|
@@ -2491,7 +2287,7 @@ var Hr = class {
|
|
|
2491
2287
|
editor: e,
|
|
2492
2288
|
type: q(t.name, this.schema)
|
|
2493
2289
|
}, r = [], i = H(t, "addKeyboardShortcuts", n), a = {};
|
|
2494
|
-
if (t.type === "mark" && H(t, "exitable", n) && (a.ArrowRight = () =>
|
|
2290
|
+
if (t.type === "mark" && H(t, "exitable", n) && (a.ArrowRight = () => Or.handleExit({
|
|
2495
2291
|
editor: e,
|
|
2496
2292
|
mark: t
|
|
2497
2293
|
})), i) {
|
|
@@ -2501,13 +2297,13 @@ var Hr = class {
|
|
|
2501
2297
|
...t
|
|
2502
2298
|
};
|
|
2503
2299
|
}
|
|
2504
|
-
let o =
|
|
2300
|
+
let o = me(a);
|
|
2505
2301
|
r.push(o);
|
|
2506
2302
|
let s = H(t, "addInputRules", n);
|
|
2507
|
-
if (
|
|
2303
|
+
if (on(t, e.options.enableInputRules) && s) {
|
|
2508
2304
|
let t = s();
|
|
2509
2305
|
if (t && t.length) {
|
|
2510
|
-
let n =
|
|
2306
|
+
let n = Er({
|
|
2511
2307
|
editor: e,
|
|
2512
2308
|
rules: t
|
|
2513
2309
|
}), i = Array.isArray(n) ? n : [n];
|
|
@@ -2515,10 +2311,10 @@ var Hr = class {
|
|
|
2515
2311
|
}
|
|
2516
2312
|
}
|
|
2517
2313
|
let c = H(t, "addPasteRules", n);
|
|
2518
|
-
if (
|
|
2314
|
+
if (on(t, e.options.enablePasteRules) && c) {
|
|
2519
2315
|
let t = c();
|
|
2520
2316
|
if (t && t.length) {
|
|
2521
|
-
let n =
|
|
2317
|
+
let n = Pr({
|
|
2522
2318
|
editor: e,
|
|
2523
2319
|
rules: t
|
|
2524
2320
|
});
|
|
@@ -2557,7 +2353,7 @@ var Hr = class {
|
|
|
2557
2353
|
}), this.decorationManager.plugin;
|
|
2558
2354
|
}
|
|
2559
2355
|
get attributes() {
|
|
2560
|
-
return
|
|
2356
|
+
return Mt(this.extensions);
|
|
2561
2357
|
}
|
|
2562
2358
|
get nodeViews() {
|
|
2563
2359
|
let { editor: e } = this, { nodeExtensions: t } = W(this.extensions);
|
|
@@ -2567,7 +2363,7 @@ var Hr = class {
|
|
|
2567
2363
|
options: t.options,
|
|
2568
2364
|
storage: this.editor.extensionStorage[t.name],
|
|
2569
2365
|
editor: e,
|
|
2570
|
-
type:
|
|
2366
|
+
type: j(t.name, this.schema)
|
|
2571
2367
|
});
|
|
2572
2368
|
if (!r) return [];
|
|
2573
2369
|
let i = r();
|
|
@@ -2628,7 +2424,7 @@ var Hr = class {
|
|
|
2628
2424
|
options: t.options,
|
|
2629
2425
|
storage: this.editor.extensionStorage[t.name],
|
|
2630
2426
|
editor: e,
|
|
2631
|
-
type:
|
|
2427
|
+
type: P(t.name, this.schema)
|
|
2632
2428
|
});
|
|
2633
2429
|
return r ? [t.name, (i, a, o) => {
|
|
2634
2430
|
let s = G(i, n);
|
|
@@ -2640,7 +2436,7 @@ var Hr = class {
|
|
|
2640
2436
|
extension: t,
|
|
2641
2437
|
HTMLAttributes: s,
|
|
2642
2438
|
updateAttributes: (t) => {
|
|
2643
|
-
|
|
2439
|
+
Cr(i, e, t);
|
|
2644
2440
|
}
|
|
2645
2441
|
});
|
|
2646
2442
|
}] : [];
|
|
@@ -2672,22 +2468,10 @@ var Hr = class {
|
|
|
2672
2468
|
});
|
|
2673
2469
|
}
|
|
2674
2470
|
};
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
Drop: () => Kr,
|
|
2680
|
-
Editable: () => qr,
|
|
2681
|
-
FocusEvents: () => Yr,
|
|
2682
|
-
Keymap: () => Xr,
|
|
2683
|
-
Paste: () => Zr,
|
|
2684
|
-
Tabindex: () => Qr,
|
|
2685
|
-
TextDirection: () => $r,
|
|
2686
|
-
focusEventsPluginKey: () => Jr
|
|
2687
|
-
});
|
|
2688
|
-
var $ = class e extends Pr {
|
|
2689
|
-
constructor() {
|
|
2690
|
-
super(...arguments), this.type = "extension";
|
|
2471
|
+
Fr.resolve = Ht, Fr.sort = K, Fr.flatten = Ot;
|
|
2472
|
+
var $ = class e extends Dr {
|
|
2473
|
+
constructor(...e) {
|
|
2474
|
+
super(...e), this.type = "extension";
|
|
2691
2475
|
}
|
|
2692
2476
|
static create(t = {}) {
|
|
2693
2477
|
let n = typeof t == "function" ? t() : t;
|
|
@@ -2700,61 +2484,62 @@ var $ = class e extends Pr {
|
|
|
2700
2484
|
let t = typeof e == "function" ? e() : e;
|
|
2701
2485
|
return super.extend(t);
|
|
2702
2486
|
}
|
|
2703
|
-
},
|
|
2487
|
+
}, Ir = $.create({
|
|
2704
2488
|
name: "clipboardTextSerializer",
|
|
2705
2489
|
addOptions() {
|
|
2706
2490
|
return { blockSeparator: void 0 };
|
|
2707
2491
|
},
|
|
2708
2492
|
addProseMirrorPlugins() {
|
|
2709
|
-
return [new
|
|
2710
|
-
key: new
|
|
2493
|
+
return [new w({
|
|
2494
|
+
key: new T("clipboardTextSerializer"),
|
|
2711
2495
|
props: { clipboardTextSerializer: () => {
|
|
2712
|
-
let { editor: e } = this, { state: t, schema: n } = e, { doc: r, selection: i } = t, a =
|
|
2496
|
+
let { editor: e } = this, { state: t, schema: n } = e, { doc: r, selection: i } = t, a = Gt(n), { blockSeparator: o } = this.options, s = {
|
|
2713
2497
|
...o === void 0 ? {} : { blockSeparator: o },
|
|
2714
2498
|
textSerializers: a
|
|
2715
2499
|
};
|
|
2716
|
-
return [...i.ranges].sort((e, t) => e.$from.pos - t.$from.pos).map(({ $from: e, $to: t }) =>
|
|
2500
|
+
return [...i.ranges].sort((e, t) => e.$from.pos - t.$from.pos).map(({ $from: e, $to: t }) => Ut(r, {
|
|
2717
2501
|
from: e.pos,
|
|
2718
2502
|
to: t.pos
|
|
2719
2503
|
}, s)).join(o ?? "\n\n");
|
|
2720
2504
|
} }
|
|
2721
2505
|
})];
|
|
2722
2506
|
}
|
|
2723
|
-
}),
|
|
2507
|
+
}), Lr = $.create({
|
|
2724
2508
|
name: "commands",
|
|
2725
2509
|
addCommands() {
|
|
2726
|
-
return { ...
|
|
2510
|
+
return { ...Hn };
|
|
2727
2511
|
}
|
|
2728
|
-
}),
|
|
2512
|
+
}), Rr = $.create({
|
|
2729
2513
|
name: "delete",
|
|
2730
2514
|
onUpdate({ transaction: t, appendedTransactions: n }) {
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2515
|
+
var r;
|
|
2516
|
+
let i = () => {
|
|
2517
|
+
var r, i;
|
|
2518
|
+
if (((r = this.editor.options.coreExtensionOptions) == null || (r = r.delete) == null || (i = r.filterTransaction) == null ? void 0 : i.call(r, t)) ?? t.getMeta("y-sync$")) return;
|
|
2519
|
+
let a = Tt(t.before, [t, ...n]);
|
|
2520
|
+
Xt(a).forEach((e) => {
|
|
2521
|
+
a.mapping.mapResult(e.oldRange.from).deletedAfter && a.mapping.mapResult(e.oldRange.to).deletedBefore && a.before.nodesBetween(e.oldRange.from, e.oldRange.to, (n, r) => {
|
|
2522
|
+
let i = r + n.nodeSize - 2, o = e.oldRange.from <= r && i <= e.oldRange.to;
|
|
2738
2523
|
this.editor.emit("delete", {
|
|
2739
2524
|
type: "node",
|
|
2740
2525
|
node: n,
|
|
2741
2526
|
from: r,
|
|
2742
|
-
to:
|
|
2743
|
-
newFrom:
|
|
2744
|
-
newTo:
|
|
2527
|
+
to: i,
|
|
2528
|
+
newFrom: a.mapping.map(r),
|
|
2529
|
+
newTo: a.mapping.map(i),
|
|
2745
2530
|
deletedRange: e.oldRange,
|
|
2746
2531
|
newRange: e.newRange,
|
|
2747
2532
|
partial: !o,
|
|
2748
2533
|
editor: this.editor,
|
|
2749
2534
|
transaction: t,
|
|
2750
|
-
combinedTransform:
|
|
2535
|
+
combinedTransform: a
|
|
2751
2536
|
});
|
|
2752
2537
|
});
|
|
2753
2538
|
});
|
|
2754
|
-
let
|
|
2755
|
-
|
|
2539
|
+
let o = a.mapping;
|
|
2540
|
+
a.steps.forEach((n, r) => {
|
|
2756
2541
|
if (n instanceof e) {
|
|
2757
|
-
let e =
|
|
2542
|
+
let e = o.slice(r).map(n.from, -1), i = o.slice(r).map(n.to), s = o.invert().map(e, -1), c = o.invert().map(i), l = e > 0 && a.doc.nodeAt(e - 1)?.marks.some((e) => e.eq(n.mark)), u = a.doc.nodeAt(i)?.marks.some((e) => e.eq(n.mark));
|
|
2758
2543
|
this.editor.emit("delete", {
|
|
2759
2544
|
type: "mark",
|
|
2760
2545
|
mark: n.mark,
|
|
@@ -2766,23 +2551,23 @@ var $ = class e extends Pr {
|
|
|
2766
2551
|
},
|
|
2767
2552
|
newRange: {
|
|
2768
2553
|
from: e,
|
|
2769
|
-
to:
|
|
2554
|
+
to: i
|
|
2770
2555
|
},
|
|
2771
2556
|
partial: !!(u || l),
|
|
2772
2557
|
editor: this.editor,
|
|
2773
2558
|
transaction: t,
|
|
2774
|
-
combinedTransform:
|
|
2559
|
+
combinedTransform: a
|
|
2775
2560
|
});
|
|
2776
2561
|
}
|
|
2777
2562
|
});
|
|
2778
2563
|
};
|
|
2779
|
-
this.editor.options.coreExtensionOptions
|
|
2564
|
+
((r = this.editor.options.coreExtensionOptions) == null || (r = r.delete) == null ? void 0 : r.async) ?? !0 ? setTimeout(i, 0) : i();
|
|
2780
2565
|
}
|
|
2781
|
-
}),
|
|
2566
|
+
}), zr = $.create({
|
|
2782
2567
|
name: "drop",
|
|
2783
2568
|
addProseMirrorPlugins() {
|
|
2784
|
-
return [new
|
|
2785
|
-
key: new
|
|
2569
|
+
return [new w({
|
|
2570
|
+
key: new T("tiptapDrop"),
|
|
2786
2571
|
props: { handleDrop: (e, t, n, r) => {
|
|
2787
2572
|
this.editor.emit("drop", {
|
|
2788
2573
|
editor: this.editor,
|
|
@@ -2793,20 +2578,20 @@ var $ = class e extends Pr {
|
|
|
2793
2578
|
} }
|
|
2794
2579
|
})];
|
|
2795
2580
|
}
|
|
2796
|
-
}),
|
|
2581
|
+
}), Br = $.create({
|
|
2797
2582
|
name: "editable",
|
|
2798
2583
|
addProseMirrorPlugins() {
|
|
2799
|
-
return [new
|
|
2800
|
-
key: new
|
|
2584
|
+
return [new w({
|
|
2585
|
+
key: new T("editable"),
|
|
2801
2586
|
props: { editable: () => this.editor.options.editable }
|
|
2802
2587
|
})];
|
|
2803
2588
|
}
|
|
2804
|
-
}),
|
|
2589
|
+
}), Vr = new T("focusEvents"), Hr = $.create({
|
|
2805
2590
|
name: "focusEvents",
|
|
2806
2591
|
addProseMirrorPlugins() {
|
|
2807
2592
|
let { editor: e } = this;
|
|
2808
|
-
return [new
|
|
2809
|
-
key:
|
|
2593
|
+
return [new w({
|
|
2594
|
+
key: Vr,
|
|
2810
2595
|
props: { handleDOMEvents: {
|
|
2811
2596
|
focus: (t, n) => {
|
|
2812
2597
|
e.isFocused = !0;
|
|
@@ -2821,13 +2606,13 @@ var $ = class e extends Pr {
|
|
|
2821
2606
|
} }
|
|
2822
2607
|
})];
|
|
2823
2608
|
}
|
|
2824
|
-
}),
|
|
2609
|
+
}), Ur = $.create({
|
|
2825
2610
|
name: "keymap",
|
|
2826
2611
|
addKeyboardShortcuts() {
|
|
2827
2612
|
let e = () => this.editor.commands.first(({ commands: e }) => [
|
|
2828
2613
|
() => e.undoInputRule(),
|
|
2829
2614
|
() => e.command(({ tr: t }) => {
|
|
2830
|
-
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 :
|
|
2615
|
+
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;
|
|
2831
2616
|
return !i || !s.type.isTextblock || s.textContent.length || !d || d && a.parent.type.name === "paragraph" ? !1 : e.clearNodes();
|
|
2832
2617
|
}),
|
|
2833
2618
|
() => e.deleteSelection(),
|
|
@@ -2863,21 +2648,21 @@ var $ = class e extends Pr {
|
|
|
2863
2648
|
"Ctrl-a": () => this.editor.commands.selectTextblockStart(),
|
|
2864
2649
|
"Ctrl-e": () => this.editor.commands.selectTextblockEnd()
|
|
2865
2650
|
};
|
|
2866
|
-
return
|
|
2651
|
+
return L() || at() ? i : r;
|
|
2867
2652
|
},
|
|
2868
2653
|
addProseMirrorPlugins() {
|
|
2869
|
-
return [new
|
|
2870
|
-
key: new
|
|
2654
|
+
return [new w({
|
|
2655
|
+
key: new T("clearDocument"),
|
|
2871
2656
|
appendTransaction: (e, t, n) => {
|
|
2872
2657
|
if (e.some((e) => e.getMeta("composition"))) return;
|
|
2873
2658
|
let r = e.some((e) => e.docChanged) && !t.doc.eq(n.doc), i = e.some((e) => e.getMeta("preventClearDocument"));
|
|
2874
2659
|
if (!r || i) return;
|
|
2875
|
-
let { empty: a, from: o, to: s } = t.selection, c =
|
|
2660
|
+
let { empty: a, from: o, to: s } = t.selection, c = E.atStart(t.doc).from, l = E.atEnd(t.doc).to;
|
|
2876
2661
|
if (a || o !== c || s !== l || !Y(n.doc)) return;
|
|
2877
|
-
let u = n.tr, d =
|
|
2662
|
+
let u = n.tr, d = _e({
|
|
2878
2663
|
state: n,
|
|
2879
2664
|
transaction: u
|
|
2880
|
-
}), { commands: f } = new
|
|
2665
|
+
}), { commands: f } = new A({
|
|
2881
2666
|
editor: this.editor,
|
|
2882
2667
|
state: d
|
|
2883
2668
|
});
|
|
@@ -2885,11 +2670,11 @@ var $ = class e extends Pr {
|
|
|
2885
2670
|
}
|
|
2886
2671
|
})];
|
|
2887
2672
|
}
|
|
2888
|
-
}),
|
|
2673
|
+
}), Wr = $.create({
|
|
2889
2674
|
name: "paste",
|
|
2890
2675
|
addProseMirrorPlugins() {
|
|
2891
|
-
return [new
|
|
2892
|
-
key: new
|
|
2676
|
+
return [new w({
|
|
2677
|
+
key: new T("tiptapPaste"),
|
|
2893
2678
|
props: { handlePaste: (e, t, n) => {
|
|
2894
2679
|
this.editor.emit("paste", {
|
|
2895
2680
|
editor: this.editor,
|
|
@@ -2899,18 +2684,18 @@ var $ = class e extends Pr {
|
|
|
2899
2684
|
} }
|
|
2900
2685
|
})];
|
|
2901
2686
|
}
|
|
2902
|
-
}),
|
|
2687
|
+
}), Gr = $.create({
|
|
2903
2688
|
name: "tabindex",
|
|
2904
2689
|
addOptions() {
|
|
2905
2690
|
return { value: void 0 };
|
|
2906
2691
|
},
|
|
2907
2692
|
addProseMirrorPlugins() {
|
|
2908
|
-
return [new
|
|
2909
|
-
key: new
|
|
2693
|
+
return [new w({
|
|
2694
|
+
key: new T("tabindex"),
|
|
2910
2695
|
props: { attributes: () => !this.editor.isEditable && this.options.value === void 0 ? {} : { tabindex: this.options.value ?? "0" } }
|
|
2911
2696
|
})];
|
|
2912
2697
|
}
|
|
2913
|
-
}),
|
|
2698
|
+
}), Kr = $.create({
|
|
2914
2699
|
name: "textDirection",
|
|
2915
2700
|
addOptions() {
|
|
2916
2701
|
return { direction: void 0 };
|
|
@@ -2931,18 +2716,18 @@ var $ = class e extends Pr {
|
|
|
2931
2716
|
}];
|
|
2932
2717
|
},
|
|
2933
2718
|
addProseMirrorPlugins() {
|
|
2934
|
-
return [new
|
|
2935
|
-
key: new
|
|
2719
|
+
return [new w({
|
|
2720
|
+
key: new T("textDirection"),
|
|
2936
2721
|
props: { attributes: () => {
|
|
2937
2722
|
let e = this.options.direction;
|
|
2938
2723
|
return e ? { dir: e } : {};
|
|
2939
2724
|
} }
|
|
2940
2725
|
})];
|
|
2941
2726
|
}
|
|
2942
|
-
}),
|
|
2943
|
-
function
|
|
2944
|
-
if (
|
|
2945
|
-
|
|
2727
|
+
}), qr = !1;
|
|
2728
|
+
function Jr(e) {
|
|
2729
|
+
if (qr) return;
|
|
2730
|
+
qr = !0;
|
|
2946
2731
|
let t;
|
|
2947
2732
|
try {
|
|
2948
2733
|
t = n.fromJSON(e, {
|
|
@@ -2952,15 +2737,15 @@ function ti(e) {
|
|
|
2952
2737
|
} catch {
|
|
2953
2738
|
return;
|
|
2954
2739
|
}
|
|
2955
|
-
t instanceof
|
|
2740
|
+
t instanceof O || console.warn("[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.");
|
|
2956
2741
|
}
|
|
2957
|
-
var
|
|
2958
|
-
constructor(e, t, n = !1, r = null) {
|
|
2959
|
-
this.currentNode = null, this.actualDepth = null, this.isBlock = n, this.resolvedPos = e, this.editor = t, this.currentNode = r;
|
|
2960
|
-
}
|
|
2742
|
+
var Yr = class e {
|
|
2961
2743
|
get name() {
|
|
2962
2744
|
return this.node.type.name;
|
|
2963
2745
|
}
|
|
2746
|
+
constructor(e, t, n = !1, r = null) {
|
|
2747
|
+
this.currentNode = null, this.actualDepth = null, this.isBlock = n, this.resolvedPos = e, this.editor = t, this.currentNode = r;
|
|
2748
|
+
}
|
|
2964
2749
|
get node() {
|
|
2965
2750
|
return this.currentNode || this.resolvedPos.node();
|
|
2966
2751
|
}
|
|
@@ -2980,7 +2765,7 @@ var ni = class e {
|
|
|
2980
2765
|
let t = this.from, n = this.to;
|
|
2981
2766
|
if (this.isBlock) {
|
|
2982
2767
|
if (this.content.size === 0) {
|
|
2983
|
-
console.error(`You can
|
|
2768
|
+
console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);
|
|
2984
2769
|
return;
|
|
2985
2770
|
}
|
|
2986
2771
|
t = this.from + 1, n = this.to - 1;
|
|
@@ -3076,7 +2861,7 @@ var ni = class e {
|
|
|
3076
2861
|
...e
|
|
3077
2862
|
}), this.editor.view.dispatch(t);
|
|
3078
2863
|
}
|
|
3079
|
-
},
|
|
2864
|
+
}, Xr = ".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}", Zr = class extends Gn {
|
|
3080
2865
|
constructor(e = {}) {
|
|
3081
2866
|
super(), this.css = null, this.className = "tiptap", this.editorView = null, this.isFocused = !1, this.destroyed = !1, this.isInitialized = !1, this.extensionStorage = {}, this.instanceId = Math.random().toString(36).slice(2, 9), this.hasWarnedStaleDecorationRead = !1, this.options = {
|
|
3082
2867
|
element: typeof document < "u" ? document.createElement("div") : null,
|
|
@@ -3113,19 +2898,19 @@ var ni = class e {
|
|
|
3113
2898
|
onDelete: () => null,
|
|
3114
2899
|
enableExtensionDispatchTransaction: !0
|
|
3115
2900
|
}, this.isCapturingTransaction = !1, this.capturedTransaction = null, this.utils = {
|
|
3116
|
-
getUpdatedPosition:
|
|
3117
|
-
createMappablePosition:
|
|
2901
|
+
getUpdatedPosition: dn,
|
|
2902
|
+
createMappablePosition: fn
|
|
3118
2903
|
}, 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);
|
|
3119
2904
|
let t = this.createDoc();
|
|
3120
2905
|
if (!this.editorState) {
|
|
3121
|
-
let e =
|
|
3122
|
-
this.editorState =
|
|
2906
|
+
let e = Re(t, this.options.autofocus);
|
|
2907
|
+
this.editorState = S.create({
|
|
3123
2908
|
doc: t,
|
|
3124
2909
|
schema: this.schema,
|
|
3125
2910
|
selection: e || void 0
|
|
3126
2911
|
});
|
|
3127
2912
|
}
|
|
3128
|
-
|
|
2913
|
+
Jr(this.schema), this.options.element && this.mount(this.options.element);
|
|
3129
2914
|
}
|
|
3130
2915
|
mount(e) {
|
|
3131
2916
|
if (typeof document > "u") throw Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");
|
|
@@ -3153,13 +2938,13 @@ var ni = class e {
|
|
|
3153
2938
|
return this.commandManager.commands;
|
|
3154
2939
|
}
|
|
3155
2940
|
chain() {
|
|
3156
|
-
return this.commandManager ? this.commandManager.chain() :
|
|
2941
|
+
return this.commandManager ? this.commandManager.chain() : A.createFakeChain();
|
|
3157
2942
|
}
|
|
3158
2943
|
can() {
|
|
3159
|
-
return this.commandManager ? this.commandManager.can() :
|
|
2944
|
+
return this.commandManager ? this.commandManager.can() : A.createFallbackCan();
|
|
3160
2945
|
}
|
|
3161
2946
|
injectCSS() {
|
|
3162
|
-
this.options.injectCSS && typeof document < "u" && (this.css = pr(
|
|
2947
|
+
this.options.injectCSS && typeof document < "u" && (this.css = pr(Xr, this.options.injectNonce));
|
|
3163
2948
|
}
|
|
3164
2949
|
setOptions(e = {}) {
|
|
3165
2950
|
this.options = {
|
|
@@ -3201,7 +2986,7 @@ var ni = class e {
|
|
|
3201
2986
|
return Kn && !this.hasWarnedStaleDecorationRead && Wn(this) && (this.hasWarnedStaleDecorationRead = !0, console.warn("[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.")), this.editorView && (this.editorState = this.view.state), this.editorState;
|
|
3202
2987
|
}
|
|
3203
2988
|
registerPlugin(e, t) {
|
|
3204
|
-
let n =
|
|
2989
|
+
let n = At(t) ? t(e, [...this.state.plugins]) : [...this.state.plugins, e], r = this.state.reconfigure({ plugins: n });
|
|
3205
2990
|
return this.view.updateState(r), r;
|
|
3206
2991
|
}
|
|
3207
2992
|
unregisterPlugin(e) {
|
|
@@ -3215,26 +3000,27 @@ var ni = class e {
|
|
|
3215
3000
|
return this.view.updateState(r), r;
|
|
3216
3001
|
}
|
|
3217
3002
|
createExtensionManager() {
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3003
|
+
var e, t;
|
|
3004
|
+
let n = [...this.options.enableCoreExtensions ? [
|
|
3005
|
+
Br,
|
|
3006
|
+
Ir.configure({ blockSeparator: (e = this.options.coreExtensionOptions) == null || (e = e.clipboardTextSerializer) == null ? void 0 : e.blockSeparator }),
|
|
3007
|
+
Lr,
|
|
3008
|
+
Hr,
|
|
3009
|
+
Ur,
|
|
3010
|
+
Gr.configure({ value: (t = this.options.coreExtensionOptions) == null || (t = t.tabindex) == null ? void 0 : t.value }),
|
|
3011
|
+
zr,
|
|
3221
3012
|
Wr,
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
Qr.configure({ value: this.options.coreExtensionOptions?.tabindex?.value }),
|
|
3225
|
-
Kr,
|
|
3226
|
-
Zr,
|
|
3227
|
-
Gr,
|
|
3228
|
-
$r.configure({ direction: this.options.textDirection })
|
|
3013
|
+
Rr,
|
|
3014
|
+
Kr.configure({ direction: this.options.textDirection })
|
|
3229
3015
|
].filter((e) => typeof this.options.enableCoreExtensions != "object" || this.options.enableCoreExtensions[e.name] !== !1) : [], ...this.options.extensions].filter((e) => [
|
|
3230
3016
|
"extension",
|
|
3231
3017
|
"node",
|
|
3232
3018
|
"mark"
|
|
3233
3019
|
].includes(e?.type));
|
|
3234
|
-
this.extensionManager = new
|
|
3020
|
+
this.extensionManager = new Fr(n, this);
|
|
3235
3021
|
}
|
|
3236
3022
|
createCommandManager() {
|
|
3237
|
-
this.commandManager = new
|
|
3023
|
+
this.commandManager = new A({ editor: this });
|
|
3238
3024
|
}
|
|
3239
3025
|
createSchema() {
|
|
3240
3026
|
this.schema = this.extensionManager.schema;
|
|
@@ -3242,14 +3028,14 @@ var ni = class e {
|
|
|
3242
3028
|
createDoc() {
|
|
3243
3029
|
let e;
|
|
3244
3030
|
try {
|
|
3245
|
-
e =
|
|
3031
|
+
e = St(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: this.options.enableContentCheck });
|
|
3246
3032
|
} catch (e) {
|
|
3247
3033
|
if (!(e instanceof Error) || !["[tiptap error]: Invalid JSON content", "[tiptap error]: Invalid HTML content"].includes(e.message)) throw e;
|
|
3248
|
-
let t =
|
|
3249
|
-
return this.editorState =
|
|
3034
|
+
let t = St(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: !1 });
|
|
3035
|
+
return this.editorState = S.create({
|
|
3250
3036
|
doc: t,
|
|
3251
3037
|
schema: this.schema,
|
|
3252
|
-
selection:
|
|
3038
|
+
selection: Re(t, this.options.autofocus) || void 0
|
|
3253
3039
|
}), this.emit("contentError", {
|
|
3254
3040
|
editor: this,
|
|
3255
3041
|
error: e,
|
|
@@ -3262,7 +3048,7 @@ var ni = class e {
|
|
|
3262
3048
|
}
|
|
3263
3049
|
createView(e) {
|
|
3264
3050
|
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);
|
|
3265
|
-
this.editorView = new
|
|
3051
|
+
this.editorView = new pe(e, {
|
|
3266
3052
|
...t,
|
|
3267
3053
|
attributes: {
|
|
3268
3054
|
role: "textbox",
|
|
@@ -3333,24 +3119,24 @@ var ni = class e {
|
|
|
3333
3119
|
});
|
|
3334
3120
|
}
|
|
3335
3121
|
getAttributes(e) {
|
|
3336
|
-
return
|
|
3122
|
+
return qt(this.state, e);
|
|
3337
3123
|
}
|
|
3338
3124
|
isActive(e, t) {
|
|
3339
3125
|
let n = typeof e == "string" ? e : null, r = typeof e == "string" ? t : e;
|
|
3340
|
-
return
|
|
3126
|
+
return nn(this.state, n, r);
|
|
3341
3127
|
}
|
|
3342
3128
|
getJSON() {
|
|
3343
3129
|
return this.state.doc.toJSON();
|
|
3344
3130
|
}
|
|
3345
3131
|
getHTML() {
|
|
3346
|
-
return
|
|
3132
|
+
return kt(this.state.doc.content, this.schema);
|
|
3347
3133
|
}
|
|
3348
3134
|
getText(e) {
|
|
3349
3135
|
let { blockSeparator: t = "\n\n", textSerializers: n = {} } = e || {};
|
|
3350
|
-
return
|
|
3136
|
+
return Wt(this.state.doc, {
|
|
3351
3137
|
blockSeparator: t,
|
|
3352
3138
|
textSerializers: {
|
|
3353
|
-
...
|
|
3139
|
+
...Gt(this.schema),
|
|
3354
3140
|
...n
|
|
3355
3141
|
}
|
|
3356
3142
|
});
|
|
@@ -3372,13 +3158,13 @@ var ni = class e {
|
|
|
3372
3158
|
}
|
|
3373
3159
|
$pos(e) {
|
|
3374
3160
|
let t = this.state.doc.resolve(e), n = e > 0 && t.nodeAfter && !t.nodeAfter.isText && t.nodeAfter.isAtom ? t.nodeAfter : null;
|
|
3375
|
-
return new
|
|
3161
|
+
return new Yr(t, this, !1, n);
|
|
3376
3162
|
}
|
|
3377
3163
|
get $doc() {
|
|
3378
3164
|
return this.$pos(0);
|
|
3379
3165
|
}
|
|
3380
3166
|
};
|
|
3381
|
-
function
|
|
3167
|
+
function Qr(e) {
|
|
3382
3168
|
return new Q({
|
|
3383
3169
|
find: e.find,
|
|
3384
3170
|
handler: ({ state: t, range: n, match: r }) => {
|
|
@@ -3387,7 +3173,7 @@ function ai(e) {
|
|
|
3387
3173
|
let { tr: a } = t, o = r[r.length - 1], s = r[0];
|
|
3388
3174
|
if (o) {
|
|
3389
3175
|
let r = s.search(/\S/), c = n.from + s.indexOf(o), l = c + o.length;
|
|
3390
|
-
if (
|
|
3176
|
+
if (Zt(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;
|
|
3391
3177
|
l < n.to && a.delete(l, n.to), c > n.from && a.delete(n.from + r, c);
|
|
3392
3178
|
let u = n.from + r + o.length;
|
|
3393
3179
|
a.addMark(n.from + r, u, e.type.create(i || {})), a.removeStoredMark(e.type);
|
|
@@ -3396,7 +3182,7 @@ function ai(e) {
|
|
|
3396
3182
|
undoable: e.undoable
|
|
3397
3183
|
});
|
|
3398
3184
|
}
|
|
3399
|
-
function
|
|
3185
|
+
function $r(e) {
|
|
3400
3186
|
return new Q({
|
|
3401
3187
|
find: e.find,
|
|
3402
3188
|
handler: ({ state: t, range: n, match: r }) => {
|
|
@@ -3415,7 +3201,7 @@ function oi(e) {
|
|
|
3415
3201
|
undoable: e.undoable
|
|
3416
3202
|
});
|
|
3417
3203
|
}
|
|
3418
|
-
function
|
|
3204
|
+
function ei(e) {
|
|
3419
3205
|
return new Q({
|
|
3420
3206
|
find: e.find,
|
|
3421
3207
|
handler: ({ state: t, range: n, match: r }) => {
|
|
@@ -3426,7 +3212,7 @@ function si(e) {
|
|
|
3426
3212
|
undoable: e.undoable
|
|
3427
3213
|
});
|
|
3428
3214
|
}
|
|
3429
|
-
function
|
|
3215
|
+
function ti(e) {
|
|
3430
3216
|
return new Q({
|
|
3431
3217
|
find: e.find,
|
|
3432
3218
|
handler: ({ state: t, range: n, match: r }) => {
|
|
@@ -3442,7 +3228,7 @@ function ci(e) {
|
|
|
3442
3228
|
undoable: e.undoable
|
|
3443
3229
|
});
|
|
3444
3230
|
}
|
|
3445
|
-
function
|
|
3231
|
+
function ni(e) {
|
|
3446
3232
|
return new Q({
|
|
3447
3233
|
find: e.find,
|
|
3448
3234
|
handler: ({ state: t, range: n, match: r, chain: a }) => {
|
|
@@ -3465,8 +3251,9 @@ function li(e) {
|
|
|
3465
3251
|
undoable: e.undoable
|
|
3466
3252
|
});
|
|
3467
3253
|
}
|
|
3468
|
-
var
|
|
3254
|
+
var ri = (e) => "touches" in e, ii = class {
|
|
3469
3255
|
constructor(e) {
|
|
3256
|
+
var t;
|
|
3470
3257
|
this.directions = [
|
|
3471
3258
|
"bottom-left",
|
|
3472
3259
|
"bottom-right",
|
|
@@ -3501,7 +3288,7 @@ var ui = (e) => "touches" in e, di = class {
|
|
|
3501
3288
|
}, 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 = {
|
|
3502
3289
|
...this.minSize,
|
|
3503
3290
|
...e.options.min
|
|
3504
|
-
}), e.options?.max && (this.maxSize = e.options.max), e
|
|
3291
|
+
}), e.options?.max && (this.maxSize = e.options.max), e != null && (t = e.options) != null && t.directions && (this.directions = e.options.directions), e.options?.preserveAspectRatio && (this.preserveAspectRatio = e.options.preserveAspectRatio), e.options?.className && (this.classNames = {
|
|
3505
3292
|
container: e.options.className.container || "",
|
|
3506
3293
|
wrapper: e.options.className.wrapper || "",
|
|
3507
3294
|
handle: e.options.className.handle || "",
|
|
@@ -3554,7 +3341,7 @@ var ui = (e) => "touches" in e, di = class {
|
|
|
3554
3341
|
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);
|
|
3555
3342
|
}
|
|
3556
3343
|
handleResizeStart(e, t) {
|
|
3557
|
-
e.preventDefault(), e.stopPropagation(), this.isResizing = !0, this.activeHandle = t,
|
|
3344
|
+
e.preventDefault(), e.stopPropagation(), this.isResizing = !0, this.activeHandle = t, ri(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);
|
|
3558
3345
|
}
|
|
3559
3346
|
handleResize(e, t) {
|
|
3560
3347
|
if (!this.activeHandle) return;
|
|
@@ -3594,9 +3381,9 @@ var ui = (e) => "touches" in e, di = class {
|
|
|
3594
3381
|
height: e / this.aspectRatio
|
|
3595
3382
|
};
|
|
3596
3383
|
}
|
|
3597
|
-
},
|
|
3598
|
-
constructor() {
|
|
3599
|
-
super(...
|
|
3384
|
+
}, ai = class e extends Dr {
|
|
3385
|
+
constructor(...e) {
|
|
3386
|
+
super(...e), this.type = "node";
|
|
3600
3387
|
}
|
|
3601
3388
|
static create(t = {}) {
|
|
3602
3389
|
let n = typeof t == "function" ? t() : t;
|
|
@@ -3609,7 +3396,7 @@ var ui = (e) => "touches" in e, di = class {
|
|
|
3609
3396
|
let t = typeof e == "function" ? e() : e;
|
|
3610
3397
|
return super.extend(t);
|
|
3611
3398
|
}
|
|
3612
|
-
},
|
|
3399
|
+
}, oi = class {
|
|
3613
3400
|
constructor(e, t, n) {
|
|
3614
3401
|
this.isDragging = !1, this.component = e, this.editor = t.editor, this.options = {
|
|
3615
3402
|
stopEvent: null,
|
|
@@ -3631,33 +3418,33 @@ var ui = (e) => "touches" in e, di = class {
|
|
|
3631
3418
|
return null;
|
|
3632
3419
|
}
|
|
3633
3420
|
onDragStart(e) {
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
a = n.x - t.x + r, o = n.y - t.y + s;
|
|
3421
|
+
let { view: t } = this.editor, n = e.target, r = n.nodeType === 3 ? n.parentElement?.closest("[data-drag-handle]") : n.closest("[data-drag-handle]");
|
|
3422
|
+
if (!this.dom || this.contentDOM?.contains(n) || !r) return;
|
|
3423
|
+
let i = 0, a = 0;
|
|
3424
|
+
if (this.dom !== r) {
|
|
3425
|
+
let t = this.dom.getBoundingClientRect(), n = r.getBoundingClientRect(), o = e.offsetX ?? e.nativeEvent?.offsetX, s = e.offsetY ?? e.nativeEvent?.offsetY;
|
|
3426
|
+
i = n.x - t.x + o, a = n.y - t.y + s;
|
|
3641
3427
|
}
|
|
3642
|
-
let
|
|
3428
|
+
let o = this.dom.cloneNode(!0);
|
|
3643
3429
|
try {
|
|
3644
3430
|
let e = this.dom.getBoundingClientRect();
|
|
3645
|
-
|
|
3431
|
+
o.style.width = `${Math.round(e.width)}px`, o.style.height = `${Math.round(e.height)}px`, o.style.boxSizing = "border-box", o.style.pointerEvents = "none";
|
|
3646
3432
|
} catch {}
|
|
3647
|
-
let
|
|
3433
|
+
let s = null;
|
|
3648
3434
|
try {
|
|
3649
|
-
|
|
3435
|
+
var c;
|
|
3436
|
+
s = document.createElement("div"), s.style.position = "absolute", s.style.top = "-9999px", s.style.left = "-9999px", s.style.pointerEvents = "none", s.appendChild(o), document.body.appendChild(s), (c = e.dataTransfer) == null || c.setDragImage(o, i, a);
|
|
3650
3437
|
} finally {
|
|
3651
|
-
|
|
3438
|
+
s && setTimeout(() => {
|
|
3652
3439
|
try {
|
|
3653
|
-
|
|
3440
|
+
s?.remove();
|
|
3654
3441
|
} catch {}
|
|
3655
3442
|
}, 0);
|
|
3656
3443
|
}
|
|
3657
3444
|
let l = this.getPos();
|
|
3658
3445
|
if (typeof l != "number") return;
|
|
3659
|
-
let u =
|
|
3660
|
-
|
|
3446
|
+
let u = C.create(t.state.doc, l), d = t.state.tr.setSelection(u);
|
|
3447
|
+
t.dispatch(d);
|
|
3661
3448
|
}
|
|
3662
3449
|
stopEvent(e) {
|
|
3663
3450
|
if (!this.dom) return !1;
|
|
@@ -3671,7 +3458,7 @@ var ui = (e) => "touches" in e, di = class {
|
|
|
3671
3458
|
"SELECT",
|
|
3672
3459
|
"TEXTAREA"
|
|
3673
3460
|
].includes(t.tagName) || t.isContentEditable) && !i && !n) return !0;
|
|
3674
|
-
let { isEditable: a } = this.editor, { isDragging: o } = this, s = !!this.node.type.spec.draggable, c =
|
|
3461
|
+
let { isEditable: a } = this.editor, { isDragging: o } = this, s = !!this.node.type.spec.draggable, c = C.isSelectable(this.node), l = e.type === "copy", u = e.type === "paste", d = e.type === "cut", f = e.type === "mousedown";
|
|
3675
3462
|
if (!s && c && n && e.target === this.dom && e.preventDefault(), s && n && !o && e.target === this.dom) return e.preventDefault(), !1;
|
|
3676
3463
|
if (s && a && !o && f) {
|
|
3677
3464
|
let e = t.closest("[data-drag-handle]");
|
|
@@ -3686,7 +3473,7 @@ var ui = (e) => "touches" in e, di = class {
|
|
|
3686
3473
|
return !(o || r || i || l || u || d || f && c);
|
|
3687
3474
|
}
|
|
3688
3475
|
ignoreMutation(e) {
|
|
3689
|
-
return !this.dom || !this.contentDOM ? !0 : typeof this.options.ignoreMutation == "function" ? this.options.ignoreMutation({ mutation: e }) : this.node.isLeaf || this.node.isAtom ? !0 : e.type === "selection" || this.dom.contains(e.target) && e.type === "childList" && (
|
|
3476
|
+
return !this.dom || !this.contentDOM ? !0 : typeof this.options.ignoreMutation == "function" ? this.options.ignoreMutation({ mutation: e }) : this.node.isLeaf || this.node.isAtom ? !0 : e.type === "selection" || this.dom.contains(e.target) && e.type === "childList" && (L() || ze()) && this.editor.isFocused && [...Array.from(e.addedNodes), ...Array.from(e.removedNodes)].every((e) => e.isContentEditable) ? !1 : this.contentDOM === e.target && e.type === "attributes" || !this.contentDOM.contains(e.target);
|
|
3690
3477
|
}
|
|
3691
3478
|
updateAttributes(e) {
|
|
3692
3479
|
this.editor.commands.command(({ tr: t }) => {
|
|
@@ -3707,8 +3494,8 @@ var ui = (e) => "touches" in e, di = class {
|
|
|
3707
3494
|
});
|
|
3708
3495
|
}
|
|
3709
3496
|
};
|
|
3710
|
-
function
|
|
3711
|
-
return new
|
|
3497
|
+
function si(e) {
|
|
3498
|
+
return new kr({
|
|
3712
3499
|
find: e.find,
|
|
3713
3500
|
handler: ({ state: t, range: n, match: r, pasteEvent: i }) => {
|
|
3714
3501
|
let a = U(e.getAttributes, void 0, r, i);
|
|
@@ -3716,11 +3503,11 @@ function mi(e) {
|
|
|
3716
3503
|
let { tr: o } = t, s = r[r.length - 1], c = r[0], l = n.to;
|
|
3717
3504
|
if (s) {
|
|
3718
3505
|
let i = c.search(/\S/), u = n.from + c.indexOf(s), d = u + s.length;
|
|
3719
|
-
if (
|
|
3506
|
+
if (Zt(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;
|
|
3720
3507
|
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);
|
|
3721
3508
|
}
|
|
3722
3509
|
}
|
|
3723
3510
|
});
|
|
3724
3511
|
}
|
|
3725
3512
|
//#endregion
|
|
3726
|
-
export {
|
|
3513
|
+
export { B as A, pn as B, G as C, rn as D, Gt as E, Qr as F, ti as H, si as I, Ft as L, cn as M, ln as N, an as O, F as P, $r as R, $t as S, Wt as T, ei as U, xr as V, ni as W, H as _, ai as a, Qt as b, ii as c, Tt as d, mr as f, Xt as g, qt as h, Or as i, Y as j, gr as k, U as l, Dt as m, $ as n, oi as o, Et as p, Q as r, kr as s, Zr as t, fr as u, N as v, hr as w, j as x, Zt as y, br as z };
|