@clevertask/scribe 0.1.19 → 0.1.21
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-tPZoiOba.js} +1 -1
- package/dist/assets/index.css +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 +6 -6
- 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 +3 -3
- 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/resolver.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/SlashCommandList.js +2 -2
- package/dist/components/Scribe/extension/slashCommand/index.js +2 -2
- package/dist/components/Scribe/extension/slashCommand/renderItems.js +2 -2
- package/dist/components/Scribe/extension/tableOfContents.js +3 -3
- package/dist/components/Scribe/index.js +4 -4
- package/dist/{dist-CzXFZHMF.js → dist-Cer8ra_P.js} +55 -39
- package/dist/{dist-CkWsQ5Lj.js → dist-ClNucvAM.js} +612 -819
- package/dist/{dist-DRPH9MfF.js → dist-D31OwZrM.js} +231 -168
- package/dist/{extension-CKcvyrIW.js → extension-B-7qHi2u.js} +2 -2
- package/dist/{extension-link-yMrg9JOz.js → extension-link-BQrkQZHi.js} +23 -23
- package/dist/{html-to-markdown-pY8ngCXa.js → html-to-markdown-D7PT8MhP.js} +1 -1
- package/dist/main.js +2 -2
- package/dist/{markdown-to-html-COv0iaxr.js → markdown-to-html-ChfR7P_Y.js} +39 -11
- package/dist/{menus-D1cst_3I.js → menus-DLKcWlVX.js} +56 -54
- package/dist/{resizable-table-D0mls3aB.js → resizable-table-DgMCiXeO.js} +28 -31
- package/dist/{schema-extensions-ChhE6XCo.js → schema-extensions-BMJIwh-u.js} +309 -314
- package/dist/schema-extensions.js +1 -1
- package/dist/schema.js +1 -1
- package/dist/{tippy.esm-DOXqN1Qm.js → tippy.esm-8vSV0zL7.js} +6 -6
- package/dist/utils/html-to-markdown.js +1 -1
- package/dist/utils/index.js +4 -4
- package/dist/utils/markdown-to-html.js +1 -1
- package/package.json +59 -56
|
@@ -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 ee, liftEmptyBlock as te, newlineInCode 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.
|
|
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 ee, liftEmptyBlock as te, newlineInCode as _, selectNodeBackward as ne, selectNodeForward as v, selectParentNode as re, selectTextblockEnd as ie, selectTextblockStart as y, setBlockType as b, wrapIn as x } from "@tiptap/pm/commands";
|
|
3
|
+
import { AllSelection as ae, EditorState as oe, NodeSelection as S, Plugin as C, PluginKey as w, Selection as T, TextSelection as E } from "@tiptap/pm/state";
|
|
4
|
+
import { DOMParser as se, DOMSerializer as ce, Fragment as D, Schema as le, Slice as ue } from "@tiptap/pm/model";
|
|
5
|
+
import { liftListItem as de, sinkListItem as fe, wrapInList as pe } from "@tiptap/pm/schema-list";
|
|
6
|
+
import { DecorationSet as O, EditorView as me } from "@tiptap/pm/view";
|
|
7
|
+
import { keymap as he } from "@tiptap/pm/keymap";
|
|
8
|
+
//#region node_modules/.pnpm/@tiptap+core@3.31.3_@tiptap+pm@3.31.3/node_modules/@tiptap/core/dist/rolldown-runtime-D7D4PA-g.js
|
|
9
|
+
var ge = Object.defineProperty, _e = (e, t) => {
|
|
10
|
+
let n = {};
|
|
11
|
+
for (var r in e) ge(n, r, {
|
|
12
|
+
get: e[r],
|
|
12
13
|
enumerable: !0
|
|
13
14
|
});
|
|
15
|
+
return t || ge(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
14
16
|
};
|
|
15
|
-
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region node_modules/.pnpm/@tiptap+core@3.31.3_@tiptap+pm@3.31.3/node_modules/@tiptap/core/dist/index.js
|
|
19
|
+
function k(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: k({
|
|
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 E(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(E.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,52 +210,52 @@ 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 = E.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 Re(e) {
|
|
245
|
+
return e instanceof E;
|
|
305
246
|
}
|
|
306
247
|
function F(e = 0, t = 0, n = 0) {
|
|
307
248
|
return Math.min(Math.max(e, t), n);
|
|
308
249
|
}
|
|
309
|
-
function
|
|
250
|
+
function ze(e, t = null) {
|
|
310
251
|
if (!t) return null;
|
|
311
|
-
let n =
|
|
252
|
+
let n = T.atStart(e), r = T.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" ? E.create(e, F(0, i, a), F(e.content.size, i, a)) : E.create(e, F(t, i, a), F(t, i, a));
|
|
316
257
|
}
|
|
317
|
-
function
|
|
258
|
+
function Be() {
|
|
318
259
|
return ["Android"].includes(navigator.platform) || /android/i.test(navigator.userAgent);
|
|
319
260
|
}
|
|
320
261
|
function I() {
|
|
@@ -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 Ve() {
|
|
331
272
|
return typeof navigator < "u" && /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
332
273
|
}
|
|
333
|
-
var
|
|
274
|
+
var He = (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
|
-
(I() ||
|
|
280
|
+
(I() || Be()) && r.dom.focus(), Ve() && !I() && !Be() && 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 && !Re(n.state.selection)) return o(), !0;
|
|
290
|
+
let s = ze(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
|
+
}, Ue = (e, t) => (n) => e.every((e, r) => t(e, {
|
|
352
293
|
...n,
|
|
353
294
|
index: r
|
|
354
|
-
})),
|
|
295
|
+
})), We = (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), Ge = (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 && Ge(r);
|
|
362
303
|
}
|
|
363
304
|
return e;
|
|
364
305
|
};
|
|
365
306
|
function L(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 Ge(n);
|
|
369
310
|
}
|
|
370
|
-
function
|
|
311
|
+
function Ke(e) {
|
|
371
312
|
return typeof e?.nodesBetween == "function";
|
|
372
313
|
}
|
|
373
314
|
function R(e, t, n) {
|
|
374
|
-
if (
|
|
315
|
+
if (Ke(e)) return e;
|
|
375
316
|
let r = typeof e == "object" && !!e;
|
|
376
317
|
n = {
|
|
377
318
|
slice: !0,
|
|
@@ -380,7 +321,7 @@ 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 D.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) {
|
|
@@ -389,7 +330,7 @@ function R(e, 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 le({
|
|
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 ? se.fromSchema(a).parseSlice(L(e), n.parseOptions) : se.fromSchema(a).parse(L(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 =
|
|
347
|
+
let r = se.fromSchema(t);
|
|
407
348
|
return n.slice ? r.parseSlice(L(e), n.parseOptions).content : r.parse(L(e), n.parseOptions);
|
|
408
349
|
}
|
|
409
350
|
return R("", t, n);
|
|
410
351
|
}
|
|
411
|
-
function
|
|
352
|
+
function qe(e) {
|
|
412
353
|
return !("type" in e);
|
|
413
354
|
}
|
|
414
|
-
function
|
|
355
|
+
function Je(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(T.near(e.doc.resolve(c), i));
|
|
423
364
|
}
|
|
424
|
-
var
|
|
365
|
+
var Ye = (e, t, n) => ({ tr: r, dispatch: i, editor: a }) => {
|
|
425
366
|
if (i) {
|
|
426
367
|
n = {
|
|
427
368
|
parseOptions: a.options.parseOptions,
|
|
@@ -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 = qe(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("") : Ke(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 = D.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 && Je(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 Xe(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 Ze = (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 = Xe(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
446
|
let e = R(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 && Je(t, t.steps.length - 1, -1)), !0) : !1;
|
|
450
|
+
}, Qe = () => ({ state: e, dispatch: t }) => g(e, t), $e = () => ({ state: e, dispatch: t }) => f(e, t), et = () => ({ state: e, dispatch: t }) => d(e, t), tt = () => ({ state: e, dispatch: t }) => p(e, t), nt = () => ({ 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
|
+
}, rt = () => ({ 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
|
+
}, it = () => ({ state: e, dispatch: t }) => m(e, t), at = () => ({ state: e, dispatch: t }) => h(e, t);
|
|
465
|
+
function ot() {
|
|
525
466
|
return typeof navigator < "u" && /Mac/.test(navigator.platform);
|
|
526
467
|
}
|
|
527
|
-
function
|
|
468
|
+
function st(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)) I() ||
|
|
478
|
+
else if (/^mod$/i.test(n)) I() || ot() ? 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 ct = (e) => ({ editor: t, view: n, tr: r, dispatch: i }) => {
|
|
484
|
+
let a = st(e).split(/-(?!$)/), o = a.find((e) => ![
|
|
544
485
|
"Alt",
|
|
545
486
|
"Ctrl",
|
|
546
487
|
"Meta",
|
|
@@ -562,7 +503,7 @@ var lt = (e) => ({ editor: t, view: n, tr: r, dispatch: i }) => {
|
|
|
562
503
|
}), !0;
|
|
563
504
|
};
|
|
564
505
|
function z(e, t, n = {}) {
|
|
565
|
-
let { from: r, to: i, empty: a } = e.selection, o = t ?
|
|
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
|
-
},
|
|
519
|
+
var lt = (e, t = {}) => ({ state: n, dispatch: r }) => z(n, j(e, n.schema), t) ? ee(n, r) : !1, ut = () => ({ state: e, dispatch: t }) => te(e, t), dt = (e) => ({ state: t, dispatch: n }) => {
|
|
520
|
+
let r = j(e, t.schema);
|
|
521
|
+
return de(r)(t, n);
|
|
522
|
+
}, ft = () => ({ state: e, dispatch: t }) => _(e, t);
|
|
582
523
|
function B(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
|
|
530
|
+
var mt = (e, t) => ({ tr: n, state: r, dispatch: i }) => {
|
|
590
531
|
let a = null, o = null, s = B(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
|
|
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 = {}) {
|
|
609
550
|
return R(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 = qe(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 {
|
|
@@ -666,18 +607,18 @@ function Ot(e, t) {
|
|
|
666
607
|
};
|
|
667
608
|
}
|
|
668
609
|
}
|
|
669
|
-
function
|
|
670
|
-
return (t) =>
|
|
610
|
+
function Ot(e) {
|
|
611
|
+
return (t) => Dt(t.$from, e);
|
|
671
612
|
}
|
|
672
|
-
function
|
|
673
|
-
return e.config[t] === void 0 && e.parent ?
|
|
613
|
+
function V(e, t, n) {
|
|
614
|
+
return e.config[t] === void 0 && e.parent ? V(e.parent, t, n) : typeof e.config[t] == "function" ? e.config[t].bind({
|
|
674
615
|
...n,
|
|
675
|
-
parent: e.parent ?
|
|
616
|
+
parent: e.parent ? V(e.parent, t, n) : null
|
|
676
617
|
}) : e.config[t];
|
|
677
618
|
}
|
|
678
619
|
function kt(e) {
|
|
679
620
|
return e.map((e) => {
|
|
680
|
-
let t =
|
|
621
|
+
let t = V(e, "addExtensions", {
|
|
681
622
|
name: e.name,
|
|
682
623
|
options: e.options,
|
|
683
624
|
storage: e.storage
|
|
@@ -686,19 +627,19 @@ function kt(e) {
|
|
|
686
627
|
}).flat(10);
|
|
687
628
|
}
|
|
688
629
|
function At(e, t) {
|
|
689
|
-
let n =
|
|
630
|
+
let n = ce.fromSchema(t).serializeFragment(e), r = document.implementation.createHTMLDocument().createElement("div");
|
|
690
631
|
return r.appendChild(n), r.innerHTML;
|
|
691
632
|
}
|
|
692
633
|
function jt(e) {
|
|
693
634
|
return typeof e == "function";
|
|
694
635
|
}
|
|
695
|
-
function
|
|
636
|
+
function H(e, t = void 0, ...n) {
|
|
696
637
|
return jt(e) ? t ? e.bind(t)(...n) : e(...n) : e;
|
|
697
638
|
}
|
|
698
639
|
function Mt(e = {}) {
|
|
699
640
|
return Object.keys(e).length === 0 && e.constructor === Object;
|
|
700
641
|
}
|
|
701
|
-
function
|
|
642
|
+
function U(e) {
|
|
702
643
|
return {
|
|
703
644
|
baseExtensions: e.filter((e) => e.type === "extension"),
|
|
704
645
|
nodeExtensions: e.filter((e) => e.type === "node"),
|
|
@@ -706,7 +647,7 @@ function W(e) {
|
|
|
706
647
|
};
|
|
707
648
|
}
|
|
708
649
|
function Nt(e) {
|
|
709
|
-
let t = [], { nodeExtensions: n, markExtensions: r } =
|
|
650
|
+
let t = [], { nodeExtensions: n, markExtensions: r } = U(e), i = [...n, ...r], a = {
|
|
710
651
|
default: null,
|
|
711
652
|
validate: void 0,
|
|
712
653
|
rendered: !0,
|
|
@@ -716,7 +657,7 @@ function Nt(e) {
|
|
|
716
657
|
isRequired: !1
|
|
717
658
|
}, o = n.filter((e) => e.name !== "text").map((e) => e.name), s = r.map((e) => e.name), c = [...o, ...s];
|
|
718
659
|
return e.forEach((e) => {
|
|
719
|
-
let n =
|
|
660
|
+
let n = V(e, "addGlobalAttributes", {
|
|
720
661
|
name: e.name,
|
|
721
662
|
options: e.options,
|
|
722
663
|
storage: e.storage,
|
|
@@ -738,7 +679,7 @@ function Nt(e) {
|
|
|
738
679
|
});
|
|
739
680
|
});
|
|
740
681
|
}), i.forEach((e) => {
|
|
741
|
-
let n =
|
|
682
|
+
let n = V(e, "addAttributes", {
|
|
742
683
|
name: e.name,
|
|
743
684
|
options: e.options,
|
|
744
685
|
storage: e.storage
|
|
@@ -802,6 +743,15 @@ function It(...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;
|
|
@@ -816,7 +766,7 @@ function It(...e) {
|
|
|
816
766
|
}), n;
|
|
817
767
|
}, {});
|
|
818
768
|
}
|
|
819
|
-
function
|
|
769
|
+
function W(e, t) {
|
|
820
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) => It(e, t), {});
|
|
821
771
|
}
|
|
822
772
|
function Lt(e) {
|
|
@@ -846,11 +796,12 @@ function zt(e) {
|
|
|
846
796
|
return Object.fromEntries(Object.entries(e).filter(([e, t]) => e === "attrs" && Mt(t) ? !1 : t != null));
|
|
847
797
|
}
|
|
848
798
|
function Bt(e) {
|
|
849
|
-
|
|
850
|
-
|
|
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
803
|
function Vt(e, t) {
|
|
853
|
-
let n = Nt(e), { nodeExtensions: r, markExtensions: i } =
|
|
804
|
+
let n = Nt(e), { nodeExtensions: r, markExtensions: i } = U(e), a = r.find((e) => V(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,
|
|
@@ -858,33 +809,33 @@ function Vt(e, t) {
|
|
|
858
809
|
editor: t
|
|
859
810
|
}, o = zt({
|
|
860
811
|
...e.reduce((e, t) => {
|
|
861
|
-
let n =
|
|
812
|
+
let n = V(t, "extendNodeSchema", a);
|
|
862
813
|
return {
|
|
863
814
|
...e,
|
|
864
815
|
...n ? n(r) : {}
|
|
865
816
|
};
|
|
866
817
|
}, {}),
|
|
867
|
-
content:
|
|
868
|
-
marks:
|
|
869
|
-
group:
|
|
870
|
-
inline:
|
|
871
|
-
atom:
|
|
872
|
-
selectable:
|
|
873
|
-
draggable:
|
|
874
|
-
code:
|
|
875
|
-
whitespace:
|
|
876
|
-
linebreakReplacement:
|
|
877
|
-
defining:
|
|
878
|
-
isolating:
|
|
818
|
+
content: H(V(r, "content", a)),
|
|
819
|
+
marks: H(V(r, "marks", a)),
|
|
820
|
+
group: H(V(r, "group", a)),
|
|
821
|
+
inline: H(V(r, "inline", a)),
|
|
822
|
+
atom: H(V(r, "atom", a)),
|
|
823
|
+
selectable: H(V(r, "selectable", a)),
|
|
824
|
+
draggable: H(V(r, "draggable", a)),
|
|
825
|
+
code: H(V(r, "code", a)),
|
|
826
|
+
whitespace: H(V(r, "whitespace", a)),
|
|
827
|
+
linebreakReplacement: H(V(r, "linebreakReplacement", a)),
|
|
828
|
+
defining: H(V(r, "defining", a)),
|
|
829
|
+
isolating: H(V(r, "isolating", a)),
|
|
879
830
|
attrs: Object.fromEntries(i.map(Bt))
|
|
880
|
-
}), s =
|
|
831
|
+
}), s = H(V(r, "parseHTML", a));
|
|
881
832
|
s && (o.parseDOM = s.map((e) => Rt(e, i)));
|
|
882
|
-
let c =
|
|
833
|
+
let c = V(r, "renderHTML", a);
|
|
883
834
|
c && (o.toDOM = (e) => c({
|
|
884
835
|
node: e,
|
|
885
|
-
HTMLAttributes:
|
|
836
|
+
HTMLAttributes: W(e, i)
|
|
886
837
|
}));
|
|
887
|
-
let l =
|
|
838
|
+
let l = V(r, "renderText", a);
|
|
888
839
|
return l && (o.toText = l), [r.name, o];
|
|
889
840
|
})), s = Object.fromEntries(i.map((r) => {
|
|
890
841
|
let i = n.filter((e) => e.type === r.name), a = {
|
|
@@ -894,27 +845,27 @@ function Vt(e, t) {
|
|
|
894
845
|
editor: t
|
|
895
846
|
}, o = zt({
|
|
896
847
|
...e.reduce((e, t) => {
|
|
897
|
-
let n =
|
|
848
|
+
let n = V(t, "extendMarkSchema", a);
|
|
898
849
|
return {
|
|
899
850
|
...e,
|
|
900
851
|
...n ? n(r) : {}
|
|
901
852
|
};
|
|
902
853
|
}, {}),
|
|
903
|
-
inclusive:
|
|
904
|
-
excludes:
|
|
905
|
-
group:
|
|
906
|
-
spanning:
|
|
907
|
-
code:
|
|
854
|
+
inclusive: H(V(r, "inclusive", a)),
|
|
855
|
+
excludes: H(V(r, "excludes", a)),
|
|
856
|
+
group: H(V(r, "group", a)),
|
|
857
|
+
spanning: H(V(r, "spanning", a)),
|
|
858
|
+
code: H(V(r, "code", a)),
|
|
908
859
|
attrs: Object.fromEntries(i.map(Bt))
|
|
909
|
-
}), s =
|
|
860
|
+
}), s = H(V(r, "parseHTML", a));
|
|
910
861
|
s && (o.parseDOM = s.map((e) => Rt(e, i)));
|
|
911
|
-
let c =
|
|
862
|
+
let c = V(r, "renderHTML", a);
|
|
912
863
|
return c && (o.toDOM = (e) => c({
|
|
913
864
|
mark: e,
|
|
914
|
-
HTMLAttributes:
|
|
865
|
+
HTMLAttributes: W(e, i)
|
|
915
866
|
})), [r.name, o];
|
|
916
867
|
}));
|
|
917
|
-
return new
|
|
868
|
+
return new le({
|
|
918
869
|
topNode: a,
|
|
919
870
|
nodes: o,
|
|
920
871
|
marks: s
|
|
@@ -924,14 +875,14 @@ function Ht(e) {
|
|
|
924
875
|
let t = e.filter((t, n) => e.indexOf(t) !== n);
|
|
925
876
|
return Array.from(new Set(t));
|
|
926
877
|
}
|
|
927
|
-
function
|
|
878
|
+
function G(e) {
|
|
928
879
|
return e.sort((e, t) => {
|
|
929
|
-
let n =
|
|
880
|
+
let n = V(e, "priority") || 100, r = V(t, "priority") || 100;
|
|
930
881
|
return n > r ? -1 : +(n < r);
|
|
931
882
|
});
|
|
932
883
|
}
|
|
933
884
|
function Ut(e) {
|
|
934
|
-
let t =
|
|
885
|
+
let t = G(kt(e)), n = Ht(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
888
|
function Wt(e, t, n) {
|
|
@@ -946,7 +897,10 @@ 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
906
|
function Gt(e, t) {
|
|
@@ -959,7 +913,7 @@ function Kt(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
915
|
function qt(e, t) {
|
|
962
|
-
let n =
|
|
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
|
});
|
|
@@ -968,7 +922,7 @@ function qt(e, t) {
|
|
|
968
922
|
}
|
|
969
923
|
function Jt(e, t) {
|
|
970
924
|
let n = B(typeof t == "string" ? t : t.name, e.schema);
|
|
971
|
-
return n === "node" ? qt(e, t) : n === "mark" ?
|
|
925
|
+
return n === "node" ? qt(e, t) : n === "mark" ? wt(e, t) : {};
|
|
972
926
|
}
|
|
973
927
|
function Yt(e, t = JSON.stringify) {
|
|
974
928
|
let n = {};
|
|
@@ -1017,13 +971,13 @@ function Zt(e) {
|
|
|
1017
971
|
function Qt(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
|
|
1024
978
|
});
|
|
1025
979
|
}) : n.nodesBetween(e, t, (e, t) => {
|
|
1026
|
-
|
|
980
|
+
e && e?.nodeSize !== void 0 && r.push(...e.marks.map((n) => ({
|
|
1027
981
|
from: t,
|
|
1028
982
|
to: t + e.nodeSize,
|
|
1029
983
|
mark: n
|
|
@@ -1043,10 +997,10 @@ var $t = (e, t, n, r = 20) => {
|
|
|
1043
997
|
let n = e.index(t);
|
|
1044
998
|
return n === 0 ? null : e.node(t).child(n - 1);
|
|
1045
999
|
};
|
|
1046
|
-
function
|
|
1000
|
+
function K(e, t) {
|
|
1047
1001
|
return t.nodes[e] || t.marks[e] || null;
|
|
1048
1002
|
}
|
|
1049
|
-
function
|
|
1003
|
+
function q(e, t, n) {
|
|
1050
1004
|
return Object.fromEntries(Object.entries(n).filter(([n]) => {
|
|
1051
1005
|
let r = e.find((e) => e.type === t && e.name === n);
|
|
1052
1006
|
return r ? r.attribute.keepOnSplit : !1;
|
|
@@ -1066,8 +1020,8 @@ var tn = (e, t = 500) => {
|
|
|
1066
1020
|
}), n;
|
|
1067
1021
|
};
|
|
1068
1022
|
function nn(e, t, n = {}) {
|
|
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) =>
|
|
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,7 +1036,7 @@ 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
1042
|
function rn(e, t, n = {}) {
|
|
@@ -1093,7 +1047,7 @@ function rn(e, t, n = {}) {
|
|
|
1093
1047
|
var an = (e, t) => {
|
|
1094
1048
|
let { $from: n, $to: r, $anchor: i } = e.selection;
|
|
1095
1049
|
if (t) {
|
|
1096
|
-
let n =
|
|
1050
|
+
let n = Ot((e) => e.type.name === t)(e.selection);
|
|
1097
1051
|
if (!n) return !1;
|
|
1098
1052
|
let r = e.doc.resolve(n.pos + 1);
|
|
1099
1053
|
return i.pos + 1 === r.end();
|
|
@@ -1107,16 +1061,16 @@ function sn(e, t) {
|
|
|
1107
1061
|
return Array.isArray(t) ? t.some((t) => (typeof t == "string" ? t : t.name) === e.name) : t;
|
|
1108
1062
|
}
|
|
1109
1063
|
function cn(e, t) {
|
|
1110
|
-
let { nodeExtensions: n } =
|
|
1064
|
+
let { nodeExtensions: n } = U(t), r = n.find((t) => t.name === e);
|
|
1111
1065
|
if (!r) return !1;
|
|
1112
|
-
let i =
|
|
1066
|
+
let i = H(V(r, "group", {
|
|
1113
1067
|
name: r.name,
|
|
1114
1068
|
options: r.options,
|
|
1115
1069
|
storage: r.storage
|
|
1116
1070
|
}));
|
|
1117
1071
|
return typeof i == "string" && i.split(" ").includes("list");
|
|
1118
1072
|
}
|
|
1119
|
-
function
|
|
1073
|
+
function J(e, { checkChildren: t = !0, ignoreWhitespace: n = !1 } = {}) {
|
|
1120
1074
|
if (n) {
|
|
1121
1075
|
if (e.type.name === "hardBreak") return !0;
|
|
1122
1076
|
if (e.isText) return !/\S/.test(e.text ?? "");
|
|
@@ -1127,7 +1081,7 @@ function Y(e, { checkChildren: t = !0, ignoreWhitespace: n = !1 } = {}) {
|
|
|
1127
1081
|
if (t) {
|
|
1128
1082
|
let r = !0;
|
|
1129
1083
|
return e.content.forEach((e) => {
|
|
1130
|
-
r !== !1 && (
|
|
1084
|
+
r !== !1 && (J(e, {
|
|
1131
1085
|
ignoreWhitespace: n,
|
|
1132
1086
|
checkChildren: t
|
|
1133
1087
|
}) || (r = !1));
|
|
@@ -1136,13 +1090,9 @@ function Y(e, { checkChildren: t = !0, ignoreWhitespace: n = !1 } = {}) {
|
|
|
1136
1090
|
return !1;
|
|
1137
1091
|
}
|
|
1138
1092
|
function ln(e) {
|
|
1139
|
-
return e instanceof
|
|
1140
|
-
}
|
|
1141
|
-
function un({ selection: e, pos: t, nodeSize: n, selectedOnTextSelection: r = !1 }) {
|
|
1142
|
-
let { from: i, to: a } = e;
|
|
1143
|
-
return !!(i <= t && a >= t + n || r && P(e) && i > t && a < t + n);
|
|
1093
|
+
return e instanceof S;
|
|
1144
1094
|
}
|
|
1145
|
-
var
|
|
1095
|
+
var un = class e {
|
|
1146
1096
|
constructor(e) {
|
|
1147
1097
|
this.position = e;
|
|
1148
1098
|
}
|
|
@@ -1153,17 +1103,17 @@ var dn = class e {
|
|
|
1153
1103
|
return { position: this.position };
|
|
1154
1104
|
}
|
|
1155
1105
|
};
|
|
1156
|
-
function
|
|
1106
|
+
function dn(e, t) {
|
|
1157
1107
|
let n = t.mapping.mapResult(e.position);
|
|
1158
1108
|
return {
|
|
1159
|
-
position: new
|
|
1109
|
+
position: new un(n.pos),
|
|
1160
1110
|
mapResult: n
|
|
1161
1111
|
};
|
|
1162
1112
|
}
|
|
1163
|
-
function
|
|
1164
|
-
return new
|
|
1113
|
+
function fn(e) {
|
|
1114
|
+
return new un(e);
|
|
1165
1115
|
}
|
|
1166
|
-
function
|
|
1116
|
+
function pn(e, t, n) {
|
|
1167
1117
|
let r = e.state.doc.content.size, i = F(t, 0, r), a = F(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
1118
|
top: c,
|
|
1169
1119
|
bottom: l,
|
|
@@ -1179,9 +1129,9 @@ function mn(e, t, n) {
|
|
|
1179
1129
|
toJSON: () => f
|
|
1180
1130
|
};
|
|
1181
1131
|
}
|
|
1182
|
-
function
|
|
1132
|
+
function mn(e, t, n) {
|
|
1183
1133
|
let { selection: r } = t, i = null;
|
|
1184
|
-
if (
|
|
1134
|
+
if (Re(r) && (i = r.$cursor), i) {
|
|
1185
1135
|
let t = e.storedMarks ?? i.marks();
|
|
1186
1136
|
return i.parent.type.allowsMarkType(n) && (!!n.isInSet(t) || !t.some((e) => e.type.excludes(n)));
|
|
1187
1137
|
}
|
|
@@ -1198,11 +1148,11 @@ function hn(e, t, n) {
|
|
|
1198
1148
|
}), i;
|
|
1199
1149
|
});
|
|
1200
1150
|
}
|
|
1201
|
-
var
|
|
1202
|
-
let { selection: a } = n, { empty: o, ranges: s } = a, c =
|
|
1151
|
+
var hn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
|
|
1152
|
+
let { selection: a } = n, { empty: o, ranges: s } = a, c = P(e, r.schema);
|
|
1203
1153
|
if (i) {
|
|
1204
1154
|
if (o) {
|
|
1205
|
-
let e =
|
|
1155
|
+
let e = wt(r, c);
|
|
1206
1156
|
n.addStoredMark(c.create({
|
|
1207
1157
|
...e,
|
|
1208
1158
|
...t
|
|
@@ -1220,23 +1170,23 @@ var gn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
|
|
|
1220
1170
|
});
|
|
1221
1171
|
});
|
|
1222
1172
|
}
|
|
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 }) =>
|
|
1173
|
+
return mn(r, n, c);
|
|
1174
|
+
}, gn = (e, t) => ({ tr: n }) => (n.setMeta(e, t), !0), _n = (e, t = {}) => ({ state: n, dispatch: r, chain: i }) => {
|
|
1175
|
+
let a = j(e, n.schema), o;
|
|
1176
|
+
return n.selection.$anchor.sameParent(n.selection.$head) && (o = n.selection.$anchor.parent.attrs), a.isTextblock ? i().command(({ commands: e }) => b(a, {
|
|
1227
1177
|
...o,
|
|
1228
1178
|
...t
|
|
1229
|
-
})(n) ? !0 : e.clearNodes()).command(({ state: e }) =>
|
|
1179
|
+
})(n) ? !0 : e.clearNodes()).command(({ state: e }) => b(a, {
|
|
1230
1180
|
...o,
|
|
1231
1181
|
...t
|
|
1232
1182
|
})(e, r)).run() : (console.warn("[tiptap warn]: Currently \"setNode()\" only supports text block nodes."), !1);
|
|
1233
|
-
},
|
|
1183
|
+
}, vn = (e) => ({ tr: t, dispatch: n }) => {
|
|
1234
1184
|
if (n) {
|
|
1235
|
-
let { doc: n } = t, r = F(e, 0, n.content.size), i =
|
|
1185
|
+
let { doc: n } = t, r = F(e, 0, n.content.size), i = S.create(n, r);
|
|
1236
1186
|
t.setSelection(i);
|
|
1237
1187
|
}
|
|
1238
1188
|
return !0;
|
|
1239
|
-
},
|
|
1189
|
+
}, yn = (e, t) => ({ tr: n, state: r, dispatch: i }) => {
|
|
1240
1190
|
let { selection: a } = r, o, s;
|
|
1241
1191
|
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
1192
|
t.isText || n.setNodeMarkup(r, void 0, {
|
|
@@ -1244,31 +1194,31 @@ var gn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
|
|
|
1244
1194
|
dir: e
|
|
1245
1195
|
});
|
|
1246
1196
|
}), !0;
|
|
1247
|
-
},
|
|
1197
|
+
}, bn = (e) => ({ tr: t, dispatch: n }) => {
|
|
1248
1198
|
if (n) {
|
|
1249
1199
|
let { doc: n } = t, { from: r, to: i } = typeof e == "number" ? {
|
|
1250
1200
|
from: e,
|
|
1251
1201
|
to: e
|
|
1252
|
-
} : e, a =
|
|
1202
|
+
} : e, a = E.atStart(n).from, o = E.atEnd(n).to, s = F(r, a, o), c = F(i, a, o), l = E.create(n, s, c);
|
|
1253
1203
|
t.setSelection(l);
|
|
1254
1204
|
}
|
|
1255
1205
|
return !0;
|
|
1256
|
-
},
|
|
1257
|
-
let r =
|
|
1258
|
-
return
|
|
1206
|
+
}, xn = (e) => ({ state: t, dispatch: n }) => {
|
|
1207
|
+
let r = j(e, t.schema);
|
|
1208
|
+
return fe(r)(t, n);
|
|
1259
1209
|
};
|
|
1260
|
-
function
|
|
1210
|
+
function Sn(e, t) {
|
|
1261
1211
|
let n = e.storedMarks || e.selection.$to.parentOffset && e.selection.$from.marks();
|
|
1262
1212
|
if (n) {
|
|
1263
1213
|
let r = n.filter((e) => t?.includes(e.type.name));
|
|
1264
1214
|
e.tr.ensureMarks(r);
|
|
1265
1215
|
}
|
|
1266
1216
|
}
|
|
1267
|
-
var
|
|
1268
|
-
let { selection: o, doc: s } = t, { $from: c, $to: l } = o, u = i.extensionManager.attributes, d =
|
|
1269
|
-
if (o instanceof
|
|
1217
|
+
var Cn = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor: i }) => {
|
|
1218
|
+
let { selection: o, doc: s } = t, { $from: c, $to: l } = o, u = i.extensionManager.attributes, d = q(u, c.node().type.name, c.node().attrs);
|
|
1219
|
+
if (o instanceof S && 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
1220
|
if (!c.parent.isBlock) return !1;
|
|
1271
|
-
let f = l.parentOffset === l.parent.content.size, p = c.depth === 0 ? void 0 :
|
|
1221
|
+
let f = l.parentOffset === l.parent.content.size, p = c.depth === 0 ? void 0 : Xe(c.node(-1).contentMatchAt(c.indexAfter(-1))), m = f && p ? [{
|
|
1272
1222
|
type: p,
|
|
1273
1223
|
attrs: d
|
|
1274
1224
|
}] : void 0, h = a(t.doc, t.mapping.map(c.pos), 1, m);
|
|
@@ -1276,15 +1226,15 @@ var wn = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
|
|
|
1276
1226
|
type: p,
|
|
1277
1227
|
attrs: d
|
|
1278
1228
|
}] : void 0), r) {
|
|
1279
|
-
if (h && (o instanceof
|
|
1229
|
+
if (h && (o instanceof E && t.deleteSelection(), t.split(t.mapping.map(c.pos), 1, m), p && !f && !c.parentOffset && c.parent.type !== p)) {
|
|
1280
1230
|
let e = t.mapping.map(c.before()), n = t.doc.resolve(e);
|
|
1281
1231
|
c.node(-1).canReplaceWith(n.index(), n.index() + 1, p) && t.setNodeMarkup(t.mapping.map(c.before()), p);
|
|
1282
1232
|
}
|
|
1283
|
-
e &&
|
|
1233
|
+
e && Sn(n, i.extensionManager.splittableMarks), t.scrollIntoView();
|
|
1284
1234
|
}
|
|
1285
1235
|
return h;
|
|
1286
|
-
},
|
|
1287
|
-
let s =
|
|
1236
|
+
}, wn = (e, t = {}) => ({ tr: n, state: r, dispatch: i, editor: o }) => {
|
|
1237
|
+
let s = j(e, r.schema), { $from: c, $to: l } = r.selection, u = r.selection.node;
|
|
1288
1238
|
if (u && u.isBlock || c.depth < 2 || !c.sameParent(l)) return !1;
|
|
1289
1239
|
let d = c.node(-1);
|
|
1290
1240
|
if (d.type !== s) return !1;
|
|
@@ -1292,28 +1242,28 @@ var wn = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
|
|
|
1292
1242
|
if (c.parent.content.size === 0 && c.node(-1).childCount === c.indexAfter(-1)) {
|
|
1293
1243
|
if (c.depth === 2 || c.node(-3).type !== s || c.index(-2) !== c.node(-2).childCount - 1) return !1;
|
|
1294
1244
|
if (i) {
|
|
1295
|
-
let e =
|
|
1296
|
-
for (let t = c.depth - r; t >= c.depth - 3; --t) e =
|
|
1245
|
+
let e = D.empty, r = c.index(-1) ? 1 : c.index(-2) ? 2 : 3;
|
|
1246
|
+
for (let t = c.depth - r; t >= c.depth - 3; --t) e = D.from(c.node(t).copy(e));
|
|
1297
1247
|
let i = c.indexAfter(-1) < c.node(-2).childCount ? 1 : c.indexAfter(-2) < c.node(-3).childCount ? 2 : 3, a = {
|
|
1298
|
-
...
|
|
1248
|
+
...q(f, c.node().type.name, c.node().attrs),
|
|
1299
1249
|
...t
|
|
1300
1250
|
}, o = s.contentMatch.defaultType?.createAndFill(a) || void 0;
|
|
1301
|
-
e = e.append(
|
|
1251
|
+
e = e.append(D.from(s.createAndFill(null, o) || void 0));
|
|
1302
1252
|
let l = c.before(c.depth - (r - 1));
|
|
1303
|
-
n.replace(l, c.after(-i), new
|
|
1253
|
+
n.replace(l, c.after(-i), new ue(e, 4 - r, 0));
|
|
1304
1254
|
let u = -1;
|
|
1305
1255
|
n.doc.nodesBetween(l, n.doc.content.size, (e, t) => {
|
|
1306
1256
|
if (u > -1) return !1;
|
|
1307
1257
|
e.isTextblock && e.content.size === 0 && (u = t + 1);
|
|
1308
|
-
}), u > -1 && n.setSelection(
|
|
1258
|
+
}), u > -1 && n.setSelection(E.near(n.doc.resolve(u))), n.scrollIntoView();
|
|
1309
1259
|
}
|
|
1310
1260
|
return !0;
|
|
1311
1261
|
}
|
|
1312
1262
|
let p = l.pos === c.end() ? d.contentMatchAt(0).defaultType : null, m = {
|
|
1313
|
-
...
|
|
1263
|
+
...q(f, d.type.name, d.attrs),
|
|
1314
1264
|
...t
|
|
1315
1265
|
}, h = {
|
|
1316
|
-
...
|
|
1266
|
+
...q(f, c.node().type.name, c.node().attrs),
|
|
1317
1267
|
...t
|
|
1318
1268
|
};
|
|
1319
1269
|
n.delete(c.pos, l.pos);
|
|
@@ -1336,65 +1286,65 @@ var wn = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
|
|
|
1336
1286
|
}
|
|
1337
1287
|
return !0;
|
|
1338
1288
|
};
|
|
1339
|
-
function
|
|
1289
|
+
function Tn(e) {
|
|
1340
1290
|
return !e || e === "1" ? null : e;
|
|
1341
1291
|
}
|
|
1342
|
-
function
|
|
1343
|
-
return
|
|
1292
|
+
function En(e, t) {
|
|
1293
|
+
return Tn(e) === Tn(t);
|
|
1344
1294
|
}
|
|
1345
|
-
var
|
|
1346
|
-
let n =
|
|
1295
|
+
var Dn = (e, t) => {
|
|
1296
|
+
let n = Ot((e) => e.type === t)(e.selection);
|
|
1347
1297
|
if (!n) return !0;
|
|
1348
1298
|
let r = e.doc.resolve(Math.max(0, n.pos - 1)).before(n.depth);
|
|
1349
1299
|
if (r === void 0) return !0;
|
|
1350
1300
|
let a = e.doc.nodeAt(r);
|
|
1351
|
-
return !(n.node.type === a?.type && i(e.doc, n.pos)) || !
|
|
1352
|
-
},
|
|
1353
|
-
let n =
|
|
1301
|
+
return !(n.node.type === a?.type && i(e.doc, n.pos)) || !En(n.node.attrs.type, a?.attrs.type) || e.join(n.pos), !0;
|
|
1302
|
+
}, On = (e, t) => {
|
|
1303
|
+
let n = Ot((e) => e.type === t)(e.selection);
|
|
1354
1304
|
if (!n) return !0;
|
|
1355
1305
|
let r = e.doc.resolve(n.start).after(n.depth);
|
|
1356
1306
|
if (r === void 0) return !0;
|
|
1357
1307
|
let a = e.doc.nodeAt(r);
|
|
1358
|
-
return !(n.node.type === a?.type && i(e.doc, r)) || !
|
|
1308
|
+
return !(n.node.type === a?.type && i(e.doc, r)) || !En(n.node.attrs.type, a?.attrs.type) || e.join(r), !0;
|
|
1359
1309
|
};
|
|
1360
|
-
function
|
|
1310
|
+
function kn(e) {
|
|
1361
1311
|
let t = e.doc, n = t.firstChild;
|
|
1362
1312
|
if (!n) return null;
|
|
1363
1313
|
let r = t.resolve(1), i = t.resolve(n.nodeSize - 1);
|
|
1364
|
-
return
|
|
1314
|
+
return E.between(r, i);
|
|
1365
1315
|
}
|
|
1366
|
-
var
|
|
1367
|
-
let { extensions: d, splittableMarks: f } = i.extensionManager, p =
|
|
1368
|
-
if (!
|
|
1369
|
-
let
|
|
1370
|
-
node:
|
|
1316
|
+
var An = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain: c, commands: l, can: u }) => {
|
|
1317
|
+
let { extensions: d, splittableMarks: f } = i.extensionManager, p = j(e, o.schema), m = j(t, o.schema), { selection: h, storedMarks: g } = o, { $from: ee, $to: te } = h, _ = ee.blockRange(te), ne = g || h.$to.parentOffset && h.$from.marks();
|
|
1318
|
+
if (!_) return !1;
|
|
1319
|
+
let v = Ot((e) => cn(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 && cn(y.type.name, d) ? {
|
|
1320
|
+
node: y,
|
|
1371
1321
|
pos: 0,
|
|
1372
1322
|
depth: 0
|
|
1373
|
-
} : null,
|
|
1374
|
-
if ((
|
|
1375
|
-
if (
|
|
1376
|
-
let n =
|
|
1323
|
+
} : null, x = v ?? b, ae = !!v && _.depth >= 1 && _.depth - v.depth <= 1, oe = !!b;
|
|
1324
|
+
if ((ae || oe) && x) {
|
|
1325
|
+
if (x.node.type === p) return re && oe ? c().command(({ tr: e, dispatch: t }) => {
|
|
1326
|
+
let n = kn(e);
|
|
1377
1327
|
return n ? (e.setSelection(n), t && t(e), !0) : !1;
|
|
1378
1328
|
}).liftListItem(m).run() : l.liftListItem(m);
|
|
1379
|
-
if (cn(
|
|
1329
|
+
if (cn(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
1330
|
}
|
|
1381
|
-
return !n || !
|
|
1382
|
-
let e = u().wrapInList(p, r), t =
|
|
1331
|
+
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(() => {
|
|
1332
|
+
let e = u().wrapInList(p, r), t = ne.filter((e) => f.includes(e.type.name));
|
|
1383
1333
|
return a.ensureMarks(t), e ? !0 : l.clearNodes();
|
|
1384
|
-
}).wrapInList(p, r).command(() =>
|
|
1385
|
-
},
|
|
1386
|
-
let { extendEmptyMarkRange: a = !1 } = n, o =
|
|
1334
|
+
}).wrapInList(p, r).command(() => Dn(a, p)).command(() => On(a, p)).run();
|
|
1335
|
+
}, jn = (e, t = {}, n = {}) => ({ state: r, commands: i }) => {
|
|
1336
|
+
let { extendEmptyMarkRange: a = !1 } = n, o = P(e, r.schema);
|
|
1387
1337
|
return nn(r, o, t) ? i.unsetMark(o, { extendEmptyMarkRange: a }) : i.setMark(o, t);
|
|
1388
|
-
},
|
|
1389
|
-
let a =
|
|
1338
|
+
}, Mn = (e, t, n = {}) => ({ state: r, commands: i }) => {
|
|
1339
|
+
let a = j(e, r.schema), o = j(t, r.schema), s = z(r, a, n), c;
|
|
1390
1340
|
return r.selection.$anchor.sameParent(r.selection.$head) && (c = r.selection.$anchor.parent.attrs), s ? i.setNode(o, c) : i.setNode(a, {
|
|
1391
1341
|
...c,
|
|
1392
1342
|
...n
|
|
1393
1343
|
});
|
|
1394
|
-
},
|
|
1395
|
-
let i =
|
|
1344
|
+
}, Nn = (e, t = {}) => ({ state: n, commands: r }) => {
|
|
1345
|
+
let i = j(e, n.schema);
|
|
1396
1346
|
return z(n, i, t) ? r.lift(i) : r.wrapIn(i, t);
|
|
1397
|
-
},
|
|
1347
|
+
}, Pn = () => ({ state: e, dispatch: t }) => {
|
|
1398
1348
|
let n = e.plugins;
|
|
1399
1349
|
for (let r = 0; r < n.length; r += 1) {
|
|
1400
1350
|
let i = n[r], a;
|
|
@@ -1411,7 +1361,7 @@ var jn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain:
|
|
|
1411
1361
|
}
|
|
1412
1362
|
}
|
|
1413
1363
|
return !1;
|
|
1414
|
-
},
|
|
1364
|
+
}, Fn = (e = {}) => ({ tr: t, dispatch: n, editor: r }) => {
|
|
1415
1365
|
let { ignoreClearable: i = !1 } = e, { selection: a } = t, { empty: o, ranges: s } = a;
|
|
1416
1366
|
if (o) return !0;
|
|
1417
1367
|
let { nonClearableMarks: c } = r.extensionManager;
|
|
@@ -1422,27 +1372,27 @@ var jn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain:
|
|
|
1422
1372
|
});
|
|
1423
1373
|
}
|
|
1424
1374
|
return !0;
|
|
1425
|
-
},
|
|
1426
|
-
let { extendEmptyMarkRange: a = !1 } = t, { selection: o } = n, s =
|
|
1375
|
+
}, In = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
|
|
1376
|
+
let { extendEmptyMarkRange: a = !1 } = t, { selection: o } = n, s = P(e, r.schema), { $from: c, empty: l, ranges: u } = o;
|
|
1427
1377
|
if (!i) return !0;
|
|
1428
1378
|
if (l && a) {
|
|
1429
|
-
let { from: e, to: t } = o, r =
|
|
1379
|
+
let { from: e, to: t } = o, r = N(c, s, c.marks().find((e) => e.type === s)?.attrs);
|
|
1430
1380
|
r && (e = r.from, t = r.to), n.removeMark(e, t, s);
|
|
1431
1381
|
} else u.forEach((e) => {
|
|
1432
1382
|
n.removeMark(e.$from.pos, e.$to.pos, s);
|
|
1433
1383
|
});
|
|
1434
1384
|
return n.removeStoredMark(s), !0;
|
|
1435
|
-
},
|
|
1385
|
+
}, Ln = (e) => ({ tr: t, state: n, dispatch: r }) => {
|
|
1436
1386
|
let { selection: i } = n, a, o;
|
|
1437
1387
|
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
1388
|
if (e.isText) return;
|
|
1439
1389
|
let r = { ...e.attrs };
|
|
1440
1390
|
delete r.dir, t.setNodeMarkup(n, void 0, r);
|
|
1441
1391
|
}), !0;
|
|
1442
|
-
},
|
|
1392
|
+
}, Rn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
|
|
1443
1393
|
let a = null, o = null, s = B(typeof e == "string" ? e : e.name, r.schema);
|
|
1444
1394
|
if (!s) return !1;
|
|
1445
|
-
s === "node" && (a =
|
|
1395
|
+
s === "node" && (a = j(e, r.schema)), s === "mark" && (o = P(e, r.schema));
|
|
1446
1396
|
let c = !1;
|
|
1447
1397
|
return n.selection.ranges.forEach((e) => {
|
|
1448
1398
|
let s = e.$from.pos, l = e.$to.pos, u, d, f, p;
|
|
@@ -1471,27 +1421,90 @@ var jn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain:
|
|
|
1471
1421
|
}));
|
|
1472
1422
|
}));
|
|
1473
1423
|
}), c;
|
|
1474
|
-
},
|
|
1424
|
+
}, Y = new w("__tiptap_decorations__"), zn = (e) => ({ tr: t, dispatch: n }) => (n && t.setMeta(Y, {
|
|
1475
1425
|
type: "force",
|
|
1476
1426
|
name: e
|
|
1477
|
-
}), !0),
|
|
1478
|
-
let i =
|
|
1479
|
-
return
|
|
1480
|
-
},
|
|
1481
|
-
let i =
|
|
1482
|
-
return
|
|
1483
|
-
},
|
|
1427
|
+
}), !0), Bn = (e, t = {}) => ({ state: n, dispatch: r }) => {
|
|
1428
|
+
let i = j(e, n.schema);
|
|
1429
|
+
return x(i, t)(n, r);
|
|
1430
|
+
}, Vn = (e, t = {}) => ({ state: n, dispatch: r }) => {
|
|
1431
|
+
let i = j(e, n.schema);
|
|
1432
|
+
return pe(i, t)(n, r);
|
|
1433
|
+
}, Hn = /* @__PURE__ */ _e({
|
|
1434
|
+
blur: () => ve,
|
|
1435
|
+
clearContent: () => ye,
|
|
1436
|
+
clearNodes: () => be,
|
|
1437
|
+
command: () => xe,
|
|
1438
|
+
createParagraphNear: () => Se,
|
|
1439
|
+
cut: () => Ce,
|
|
1440
|
+
deleteCurrentNode: () => we,
|
|
1441
|
+
deleteNode: () => Te,
|
|
1442
|
+
deleteRange: () => Ee,
|
|
1443
|
+
deleteSelection: () => Ae,
|
|
1444
|
+
enter: () => je,
|
|
1445
|
+
exitCode: () => Me,
|
|
1446
|
+
extendMarkRange: () => Ie,
|
|
1447
|
+
first: () => Le,
|
|
1448
|
+
focus: () => He,
|
|
1449
|
+
forEach: () => Ue,
|
|
1450
|
+
insertContent: () => We,
|
|
1451
|
+
insertContentAt: () => Ye,
|
|
1452
|
+
insertDefaultBlock: () => Ze,
|
|
1453
|
+
joinBackward: () => et,
|
|
1454
|
+
joinDown: () => $e,
|
|
1455
|
+
joinForward: () => tt,
|
|
1456
|
+
joinItemBackward: () => nt,
|
|
1457
|
+
joinItemForward: () => rt,
|
|
1458
|
+
joinTextblockBackward: () => it,
|
|
1459
|
+
joinTextblockForward: () => at,
|
|
1460
|
+
joinUp: () => Qe,
|
|
1461
|
+
keyboardShortcut: () => ct,
|
|
1462
|
+
lift: () => lt,
|
|
1463
|
+
liftEmptyBlock: () => ut,
|
|
1464
|
+
liftListItem: () => dt,
|
|
1465
|
+
newlineInCode: () => ft,
|
|
1466
|
+
resetAttributes: () => mt,
|
|
1467
|
+
scrollIntoView: () => ht,
|
|
1468
|
+
selectAll: () => gt,
|
|
1469
|
+
selectNodeBackward: () => _t,
|
|
1470
|
+
selectNodeForward: () => vt,
|
|
1471
|
+
selectParentNode: () => yt,
|
|
1472
|
+
selectTextblockEnd: () => bt,
|
|
1473
|
+
selectTextblockStart: () => xt,
|
|
1474
|
+
setContent: () => Ct,
|
|
1475
|
+
setMark: () => hn,
|
|
1476
|
+
setMeta: () => gn,
|
|
1477
|
+
setNode: () => _n,
|
|
1478
|
+
setNodeSelection: () => vn,
|
|
1479
|
+
setTextDirection: () => yn,
|
|
1480
|
+
setTextSelection: () => bn,
|
|
1481
|
+
sinkListItem: () => xn,
|
|
1482
|
+
splitBlock: () => Cn,
|
|
1483
|
+
splitListItem: () => wn,
|
|
1484
|
+
toggleList: () => An,
|
|
1485
|
+
toggleMark: () => jn,
|
|
1486
|
+
toggleNode: () => Mn,
|
|
1487
|
+
toggleWrap: () => Nn,
|
|
1488
|
+
undoInputRule: () => Pn,
|
|
1489
|
+
unsetAllMarks: () => Fn,
|
|
1490
|
+
unsetMark: () => In,
|
|
1491
|
+
unsetTextDirection: () => Ln,
|
|
1492
|
+
updateAttributes: () => Rn,
|
|
1493
|
+
updateDecorations: () => zn,
|
|
1494
|
+
wrapIn: () => Bn,
|
|
1495
|
+
wrapInList: () => Vn
|
|
1496
|
+
}), X = /* @__PURE__ */ new WeakMap();
|
|
1484
1497
|
function Un(e, t) {
|
|
1485
|
-
|
|
1498
|
+
X.set(e, (X.get(e) ?? 0) + 1);
|
|
1486
1499
|
try {
|
|
1487
1500
|
return t();
|
|
1488
1501
|
} finally {
|
|
1489
|
-
let t = (
|
|
1490
|
-
t > 0 ?
|
|
1502
|
+
let t = (X.get(e) ?? 1) - 1;
|
|
1503
|
+
t > 0 ? X.set(e, t) : X.delete(e);
|
|
1491
1504
|
}
|
|
1492
1505
|
}
|
|
1493
1506
|
function Wn(e) {
|
|
1494
|
-
return
|
|
1507
|
+
return X.has(e);
|
|
1495
1508
|
}
|
|
1496
1509
|
var Gn = class {
|
|
1497
1510
|
constructor() {
|
|
@@ -1532,7 +1545,7 @@ function Jn(e, t) {
|
|
|
1532
1545
|
function Yn(e, t, n) {
|
|
1533
1546
|
let { decorations: r, widgetKeys: i } = Jn(t, n);
|
|
1534
1547
|
return {
|
|
1535
|
-
set:
|
|
1548
|
+
set: O.create(e, r),
|
|
1536
1549
|
widgetKeys: i
|
|
1537
1550
|
};
|
|
1538
1551
|
}
|
|
@@ -1620,7 +1633,7 @@ function ir(e, t, n, r) {
|
|
|
1620
1633
|
} });
|
|
1621
1634
|
}
|
|
1622
1635
|
function ar(e, t, n) {
|
|
1623
|
-
let r = t.decorationSetsByExtension[e] ??
|
|
1636
|
+
let r = t.decorationSetsByExtension[e] ?? O.empty, i = new Set(t.widgetKeysByExtension[e] ?? []);
|
|
1624
1637
|
return {
|
|
1625
1638
|
set: ir(r, n.mapping, n.doc, i),
|
|
1626
1639
|
widgetKeys: i
|
|
@@ -1628,7 +1641,7 @@ function ar(e, t, n) {
|
|
|
1628
1641
|
}
|
|
1629
1642
|
function or(e, t) {
|
|
1630
1643
|
let n = Object.values(t).flatMap((e) => e.find());
|
|
1631
|
-
return
|
|
1644
|
+
return O.create(e, n);
|
|
1632
1645
|
}
|
|
1633
1646
|
function sr(e) {
|
|
1634
1647
|
let t = /* @__PURE__ */ new Set();
|
|
@@ -1656,7 +1669,7 @@ function lr(e, t, n) {
|
|
|
1656
1669
|
var ur = /* @__PURE__ */ new Set(), dr = class {
|
|
1657
1670
|
constructor(e) {
|
|
1658
1671
|
this.warnedWidgetKeys = /* @__PURE__ */ new Set(), this.warnedOutOfRangeExtensions = /* @__PURE__ */ new Set(), this.handleBeforeTransaction = ({ nextState: e }) => {
|
|
1659
|
-
let t =
|
|
1672
|
+
let t = Y.getState(e);
|
|
1660
1673
|
t && this.warnDuplicateWidgetKeys(t);
|
|
1661
1674
|
}, this.editor = e.editor, this.entries = this.resolveEntries(e.entries), this.entries.forEach(({ name: e, spec: t }) => cr(e, t)), this.plugin = this.entries.length > 0 ? this.createPlugin() : null, this.editor.on("beforeTransaction", this.handleBeforeTransaction);
|
|
1662
1675
|
}
|
|
@@ -1664,7 +1677,7 @@ var ur = /* @__PURE__ */ new Set(), dr = class {
|
|
|
1664
1677
|
this.editor.off("beforeTransaction", this.handleBeforeTransaction);
|
|
1665
1678
|
}
|
|
1666
1679
|
liveWidgetKeys() {
|
|
1667
|
-
return
|
|
1680
|
+
return Y.getState(this.editor.state)?.widgetKeys ?? ur;
|
|
1668
1681
|
}
|
|
1669
1682
|
get mountedView() {
|
|
1670
1683
|
return this.editor.isDestroyed ? null : this.editor.view;
|
|
@@ -1682,8 +1695,8 @@ var ur = /* @__PURE__ */ new Set(), dr = class {
|
|
|
1682
1695
|
}
|
|
1683
1696
|
createPlugin() {
|
|
1684
1697
|
let { editor: e, entries: t } = this;
|
|
1685
|
-
return new
|
|
1686
|
-
key:
|
|
1698
|
+
return new C({
|
|
1699
|
+
key: Y,
|
|
1687
1700
|
state: {
|
|
1688
1701
|
init: (e, n) => {
|
|
1689
1702
|
let r = {}, i = {};
|
|
@@ -1700,7 +1713,7 @@ var ur = /* @__PURE__ */ new Set(), dr = class {
|
|
|
1700
1713
|
return this.warnDuplicateWidgetKeys(a), a;
|
|
1701
1714
|
},
|
|
1702
1715
|
apply: (n, r, i, a) => {
|
|
1703
|
-
let o = n.getMeta(
|
|
1716
|
+
let o = n.getMeta(Y), s = o?.type === "force" && !o.name, c = o?.type === "force" ? o.name : void 0, l = {}, u = {}, d = /* @__PURE__ */ new Set();
|
|
1704
1717
|
return Un(e, () => {
|
|
1705
1718
|
for (let { name: o, spec: f } of t) {
|
|
1706
1719
|
let t = s || c === o;
|
|
@@ -1735,7 +1748,7 @@ var ur = /* @__PURE__ */ new Set(), dr = class {
|
|
|
1735
1748
|
}
|
|
1736
1749
|
},
|
|
1737
1750
|
props: { decorations(e) {
|
|
1738
|
-
return
|
|
1751
|
+
return Y.getState(e)?.mergedDecorationSet ?? O.empty;
|
|
1739
1752
|
} }
|
|
1740
1753
|
});
|
|
1741
1754
|
}
|
|
@@ -1744,7 +1757,7 @@ var ur = /* @__PURE__ */ new Set(), dr = class {
|
|
|
1744
1757
|
return a.type === "full" ? this.buildFullSet(e, t, i) : this.rebuildRanges(e, t, n, r, i, a.ranges);
|
|
1745
1758
|
}
|
|
1746
1759
|
rebuildRanges(e, t, n, r, i, a) {
|
|
1747
|
-
let o = n.decorationSetsByExtension[e] ??
|
|
1760
|
+
let o = n.decorationSetsByExtension[e] ?? O.empty, s = new Set(n.widgetKeysByExtension[e] ?? []), c = ir(o, r.mapping, r.doc, s), l = i.doc.content.size;
|
|
1748
1761
|
for (let { from: n, to: r } of a) {
|
|
1749
1762
|
let a = c.find(n, r).filter((e) => Xn({
|
|
1750
1763
|
position: e.from,
|
|
@@ -1818,7 +1831,7 @@ var ur = /* @__PURE__ */ new Set(), dr = class {
|
|
|
1818
1831
|
};
|
|
1819
1832
|
function fr(e, t) {
|
|
1820
1833
|
let { selection: n } = e, { $from: r } = n;
|
|
1821
|
-
if (n instanceof
|
|
1834
|
+
if (n instanceof S) {
|
|
1822
1835
|
let e = r.index();
|
|
1823
1836
|
return r.parent.canReplaceWith(e, e + 1, t);
|
|
1824
1837
|
}
|
|
@@ -1858,293 +1871,81 @@ function _r(e) {
|
|
|
1858
1871
|
function vr(e) {
|
|
1859
1872
|
return Object.prototype.toString.call(e).slice(8, -1);
|
|
1860
1873
|
}
|
|
1861
|
-
function
|
|
1874
|
+
function Z(e) {
|
|
1862
1875
|
return vr(e) === "Object" && e.constructor === Object && Object.getPrototypeOf(e) === Object.prototype;
|
|
1863
1876
|
}
|
|
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) {
|
|
1877
|
+
function yr(e, t, n) {
|
|
2082
1878
|
let r = e.split("\n"), i = [], a = "", o = 0, s = t.baseIndentSize || 2;
|
|
2083
1879
|
for (; o < r.length;) {
|
|
2084
|
-
let e = r[o],
|
|
2085
|
-
if (!
|
|
1880
|
+
let e = r[o], u = e.match(t.itemPattern);
|
|
1881
|
+
if (!u) {
|
|
2086
1882
|
if (i.length > 0) break;
|
|
2087
1883
|
if (e.trim() === "") {
|
|
2088
|
-
o += 1, a = `${a}${e}
|
|
2089
|
-
`;
|
|
1884
|
+
o += 1, a = `${a}${e}\n`;
|
|
2090
1885
|
continue;
|
|
2091
1886
|
}
|
|
2092
1887
|
return;
|
|
2093
1888
|
}
|
|
2094
|
-
let
|
|
2095
|
-
a = `${a}${e}
|
|
2096
|
-
|
|
2097
|
-
let f = [d];
|
|
1889
|
+
let d = t.extractItemData(u), { indentLevel: f, mainContent: p } = d;
|
|
1890
|
+
a = `${a}${e}\n`;
|
|
1891
|
+
let m = [p];
|
|
2098
1892
|
for (o += 1; o < r.length;) {
|
|
1893
|
+
var c;
|
|
2099
1894
|
let e = r[o];
|
|
2100
1895
|
if (e.trim() === "") {
|
|
1896
|
+
var l;
|
|
2101
1897
|
let t = r.slice(o + 1).findIndex((e) => e.trim() !== "");
|
|
2102
1898
|
if (t === -1) break;
|
|
2103
|
-
if ((r[o + 1 + t].match(/^(\s*)/)
|
|
2104
|
-
|
|
2105
|
-
`, o += 1;
|
|
1899
|
+
if ((((l = r[o + 1 + t].match(/^(\s*)/)) == null || (l = l[1]) == null ? void 0 : l.length) || 0) > f) {
|
|
1900
|
+
m.push(e), a = `${a}${e}\n`, o += 1;
|
|
2106
1901
|
continue;
|
|
2107
1902
|
}
|
|
2108
1903
|
break;
|
|
2109
1904
|
}
|
|
2110
|
-
if ((e.match(/^(\s*)/)
|
|
2111
|
-
`, o += 1;
|
|
1905
|
+
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
1906
|
else break;
|
|
2113
1907
|
}
|
|
2114
|
-
let
|
|
2115
|
-
if (
|
|
2116
|
-
let e =
|
|
2117
|
-
e.trim() && (
|
|
1908
|
+
let h, g = m.slice(1);
|
|
1909
|
+
if (g.length > 0) {
|
|
1910
|
+
let e = g.map((e) => e.slice(f + s)).join("\n");
|
|
1911
|
+
e.trim() && (h = t.customNestedParser ? t.customNestedParser(e) : n.blockTokens(e));
|
|
2118
1912
|
}
|
|
2119
|
-
let
|
|
2120
|
-
i.push(
|
|
1913
|
+
let ee = t.createToken(d, h);
|
|
1914
|
+
i.push(ee);
|
|
2121
1915
|
}
|
|
2122
1916
|
if (i.length !== 0) return {
|
|
2123
1917
|
items: i,
|
|
2124
1918
|
raw: a
|
|
2125
1919
|
};
|
|
2126
1920
|
}
|
|
2127
|
-
|
|
1921
|
+
var br = 4;
|
|
1922
|
+
function xr(e) {
|
|
1923
|
+
let t = 0;
|
|
1924
|
+
for (let n of e) t = n === " " ? t + br - t % br : t + 1;
|
|
1925
|
+
return t;
|
|
1926
|
+
}
|
|
1927
|
+
function Sr(e, t, n, r, i) {
|
|
2128
1928
|
if (!e || !Array.isArray(e.content)) return "";
|
|
2129
|
-
let
|
|
2130
|
-
return
|
|
1929
|
+
let a = typeof n == "function" ? n(r) : n, [o, ...s] = e.content, c = `${a}${t.renderChildren([o])}`;
|
|
1930
|
+
return s && s.length > 0 && s.forEach((e, n) => {
|
|
2131
1931
|
let r = t.renderChild?.call(t, e, n + 1) ?? t.renderChildren([e]);
|
|
2132
1932
|
if (r != null) {
|
|
2133
|
-
let n =
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
1933
|
+
let n = (e) => {
|
|
1934
|
+
if (!i?.alignNestedToPrefix) return t.indent(e);
|
|
1935
|
+
let n = t.indent(""), r = xr(a);
|
|
1936
|
+
return (xr(n) >= r ? n : " ".repeat(r)) + e;
|
|
1937
|
+
}, o = r.split("\n").map((e) => n(e || "")).join("\n");
|
|
1938
|
+
c += e.type === "paragraph" ? `\n\n${o}` : `\n${o}`;
|
|
2138
1939
|
}
|
|
2139
|
-
}),
|
|
1940
|
+
}), c;
|
|
2140
1941
|
}
|
|
2141
|
-
function
|
|
1942
|
+
function Cr(e, t) {
|
|
2142
1943
|
let n = { ...e };
|
|
2143
|
-
return
|
|
2144
|
-
|
|
1944
|
+
return Z(e) && Z(t) && Object.keys(t).forEach((r) => {
|
|
1945
|
+
Z(t[r]) && Z(e[r]) ? n[r] = Cr(e[r], t[r]) : n[r] = t[r];
|
|
2145
1946
|
}), n;
|
|
2146
1947
|
}
|
|
2147
|
-
function
|
|
1948
|
+
function wr(e, t, n = {}) {
|
|
2148
1949
|
let { state: r } = t, { doc: i, tr: a } = r, o = e;
|
|
2149
1950
|
i.descendants((t, r) => {
|
|
2150
1951
|
let i = a.mapping.map(r), s = a.mapping.map(r) + t.nodeSize, c = null;
|
|
@@ -2168,14 +1969,14 @@ var Q = class {
|
|
|
2168
1969
|
constructor(e) {
|
|
2169
1970
|
this.find = e.find, this.handler = e.handler, this.undoable = e.undoable ?? !0;
|
|
2170
1971
|
}
|
|
2171
|
-
},
|
|
2172
|
-
if (
|
|
1972
|
+
}, Tr = (e, t) => {
|
|
1973
|
+
if (Ne(t)) return t.exec(e);
|
|
2173
1974
|
let n = t(e);
|
|
2174
1975
|
if (!n) return null;
|
|
2175
1976
|
let r = [n.text];
|
|
2176
1977
|
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
1978
|
};
|
|
2178
|
-
function
|
|
1979
|
+
function Er(e) {
|
|
2179
1980
|
let { editor: t, from: n, to: r, text: i, rules: a, plugin: o } = e, { view: s } = t;
|
|
2180
1981
|
if (s.composing) return !1;
|
|
2181
1982
|
let c = s.state.doc.resolve(n);
|
|
@@ -2183,20 +1984,20 @@ function Mr(e) {
|
|
|
2183
1984
|
let l = !1, u = tn(c) + i;
|
|
2184
1985
|
return a.forEach((e) => {
|
|
2185
1986
|
if (l) return;
|
|
2186
|
-
let a =
|
|
1987
|
+
let a = Tr(u, e.find);
|
|
2187
1988
|
if (!a) return;
|
|
2188
1989
|
let d = a[0].length - i.length;
|
|
2189
1990
|
if (d > 0) {
|
|
2190
1991
|
let e = c.parentOffset - d;
|
|
2191
1992
|
if (e < 0 || c.parent.textBetween(e, c.parentOffset) !== a[0].slice(0, d)) return;
|
|
2192
1993
|
}
|
|
2193
|
-
let f = s.state.tr, p =
|
|
1994
|
+
let f = s.state.tr, p = k({
|
|
2194
1995
|
state: s.state,
|
|
2195
1996
|
transaction: f
|
|
2196
1997
|
}), m = {
|
|
2197
1998
|
from: n - (a[0].length - i.length),
|
|
2198
1999
|
to: r
|
|
2199
|
-
}, { commands: h, chain: g, can: ee } = new
|
|
2000
|
+
}, { commands: h, chain: g, can: ee } = new A({
|
|
2200
2001
|
editor: t,
|
|
2201
2002
|
state: p
|
|
2202
2003
|
});
|
|
@@ -2207,7 +2008,7 @@ function Mr(e) {
|
|
|
2207
2008
|
commands: h,
|
|
2208
2009
|
chain: g,
|
|
2209
2010
|
can: ee
|
|
2210
|
-
})
|
|
2011
|
+
}) !== null && f.steps.length && (e.undoable && f.setMeta(o, {
|
|
2211
2012
|
transform: f,
|
|
2212
2013
|
from: n,
|
|
2213
2014
|
to: r,
|
|
@@ -2215,8 +2016,8 @@ function Mr(e) {
|
|
|
2215
2016
|
}), s.dispatch(f), l = !0);
|
|
2216
2017
|
}), l;
|
|
2217
2018
|
}
|
|
2218
|
-
function
|
|
2219
|
-
let { editor: t, rules: n } = e, r = new
|
|
2019
|
+
function Dr(e) {
|
|
2020
|
+
let { editor: t, rules: n } = e, r = new C({
|
|
2220
2021
|
state: {
|
|
2221
2022
|
init() {
|
|
2222
2023
|
return null;
|
|
@@ -2227,9 +2028,9 @@ function Nr(e) {
|
|
|
2227
2028
|
let s = e.getMeta("applyInputRules");
|
|
2228
2029
|
return s && setTimeout(() => {
|
|
2229
2030
|
let { text: e } = s;
|
|
2230
|
-
e = typeof e == "string" ? e : At(
|
|
2031
|
+
e = typeof e == "string" ? e : At(D.from(e), a.schema);
|
|
2231
2032
|
let { from: i } = s, o = i + e.length;
|
|
2232
|
-
|
|
2033
|
+
Er({
|
|
2233
2034
|
editor: t,
|
|
2234
2035
|
from: i,
|
|
2235
2036
|
to: o,
|
|
@@ -2242,7 +2043,7 @@ function Nr(e) {
|
|
|
2242
2043
|
},
|
|
2243
2044
|
props: {
|
|
2244
2045
|
handleTextInput(e, i, a, o) {
|
|
2245
|
-
return
|
|
2046
|
+
return Er({
|
|
2246
2047
|
editor: t,
|
|
2247
2048
|
from: i,
|
|
2248
2049
|
to: a,
|
|
@@ -2253,7 +2054,7 @@ function Nr(e) {
|
|
|
2253
2054
|
},
|
|
2254
2055
|
handleDOMEvents: { compositionend: (e) => (setTimeout(() => {
|
|
2255
2056
|
let { $cursor: i } = e.state.selection;
|
|
2256
|
-
i &&
|
|
2057
|
+
i && Er({
|
|
2257
2058
|
editor: t,
|
|
2258
2059
|
from: i.pos,
|
|
2259
2060
|
to: i.pos,
|
|
@@ -2265,7 +2066,7 @@ function Nr(e) {
|
|
|
2265
2066
|
handleKeyDown(e, i) {
|
|
2266
2067
|
if (i.key !== "Enter") return !1;
|
|
2267
2068
|
let { $cursor: a } = e.state.selection;
|
|
2268
|
-
return a ?
|
|
2069
|
+
return a ? Er({
|
|
2269
2070
|
editor: t,
|
|
2270
2071
|
from: a.pos,
|
|
2271
2072
|
to: a.pos,
|
|
@@ -2279,7 +2080,7 @@ function Nr(e) {
|
|
|
2279
2080
|
});
|
|
2280
2081
|
return r;
|
|
2281
2082
|
}
|
|
2282
|
-
var
|
|
2083
|
+
var Or = class {
|
|
2283
2084
|
constructor(e = {}) {
|
|
2284
2085
|
this.type = "extendable", this.parent = null, this.child = null, this.name = "", this.config = { name: this.name }, this.config = {
|
|
2285
2086
|
...this.config,
|
|
@@ -2287,10 +2088,10 @@ var Pr = class {
|
|
|
2287
2088
|
}, this.name = this.config.name;
|
|
2288
2089
|
}
|
|
2289
2090
|
get options() {
|
|
2290
|
-
return { ...
|
|
2091
|
+
return { ...H(V(this, "addOptions", { name: this.name })) };
|
|
2291
2092
|
}
|
|
2292
2093
|
get storage() {
|
|
2293
|
-
return { ...
|
|
2094
|
+
return { ...H(V(this, "addStorage", {
|
|
2294
2095
|
name: this.name,
|
|
2295
2096
|
options: this.options
|
|
2296
2097
|
})) };
|
|
@@ -2298,7 +2099,7 @@ var Pr = class {
|
|
|
2298
2099
|
configure(e = {}) {
|
|
2299
2100
|
let t = this.extend({
|
|
2300
2101
|
...this.config,
|
|
2301
|
-
addOptions: () =>
|
|
2102
|
+
addOptions: () => Cr(this.options, e)
|
|
2302
2103
|
});
|
|
2303
2104
|
return t.name = this.name, t.parent = this.parent, this.child = null, t;
|
|
2304
2105
|
}
|
|
@@ -2309,9 +2110,9 @@ var Pr = class {
|
|
|
2309
2110
|
});
|
|
2310
2111
|
return t.parent = this, this.child = t, t.name = "name" in e ? e.name : t.parent.name, t;
|
|
2311
2112
|
}
|
|
2312
|
-
},
|
|
2313
|
-
constructor() {
|
|
2314
|
-
super(...
|
|
2113
|
+
}, kr = class e extends Or {
|
|
2114
|
+
constructor(...e) {
|
|
2115
|
+
super(...e), this.type = "mark";
|
|
2315
2116
|
}
|
|
2316
2117
|
static create(t = {}) {
|
|
2317
2118
|
let n = typeof t == "function" ? t() : t;
|
|
@@ -2334,29 +2135,30 @@ var Pr = class {
|
|
|
2334
2135
|
let t = typeof e == "function" ? e() : e;
|
|
2335
2136
|
return super.extend(t);
|
|
2336
2137
|
}
|
|
2337
|
-
},
|
|
2138
|
+
}, Ar = class {
|
|
2338
2139
|
constructor(e) {
|
|
2339
2140
|
this.find = e.find, this.handler = e.handler;
|
|
2340
2141
|
}
|
|
2341
|
-
},
|
|
2342
|
-
if (
|
|
2142
|
+
}, jr = (e, t, n) => {
|
|
2143
|
+
if (Ne(t)) return [...e.matchAll(t)];
|
|
2343
2144
|
let r = t(e, n);
|
|
2344
2145
|
return r ? r.map((t) => {
|
|
2345
2146
|
let n = [t.text];
|
|
2346
2147
|
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
2148
|
}) : [];
|
|
2348
2149
|
};
|
|
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
|
|
2150
|
+
function Mr(e) {
|
|
2151
|
+
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
2152
|
editor: t,
|
|
2352
2153
|
state: n
|
|
2353
2154
|
}), d = [];
|
|
2354
2155
|
return n.doc.nodesBetween(r, i, (e, t) => {
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
p
|
|
2156
|
+
var f;
|
|
2157
|
+
if ((f = e.type) != null && (f = f.spec) != null && f.code || !(e.isText || e.isTextblock || e.isInline)) return;
|
|
2158
|
+
let p = e.content?.size ?? e.nodeSize ?? 0, m = Math.max(r, t), h = Math.min(i, t + p);
|
|
2159
|
+
m >= h || jr(e.isText ? e.text || "" : e.textBetween(m - t, h - t, void 0, ""), a.find, o).forEach((e) => {
|
|
2358
2160
|
if (e.index === void 0) return;
|
|
2359
|
-
let t =
|
|
2161
|
+
let t = m + e.index + 1, r = t + e[0].length, i = {
|
|
2360
2162
|
from: n.tr.mapping.map(t),
|
|
2361
2163
|
to: n.tr.mapping.map(r)
|
|
2362
2164
|
}, f = a.handler({
|
|
@@ -2373,12 +2175,12 @@ function Rr(e) {
|
|
|
2373
2175
|
});
|
|
2374
2176
|
}), d.every((e) => e !== null);
|
|
2375
2177
|
}
|
|
2376
|
-
var
|
|
2178
|
+
var Nr = null, Pr = (e) => {
|
|
2377
2179
|
var t;
|
|
2378
2180
|
let n = new ClipboardEvent("paste", { clipboardData: new DataTransfer() });
|
|
2379
2181
|
return (t = n.clipboardData) == null || t.setData("text/html", e), n;
|
|
2380
2182
|
};
|
|
2381
|
-
function
|
|
2183
|
+
function Fr(e) {
|
|
2382
2184
|
let { editor: t, rules: n } = e, r = null, i = !1, a = !1, o = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, s;
|
|
2383
2185
|
try {
|
|
2384
2186
|
s = typeof DragEvent < "u" ? new DragEvent("drop") : null;
|
|
@@ -2386,11 +2188,11 @@ function Vr(e) {
|
|
|
2386
2188
|
s = null;
|
|
2387
2189
|
}
|
|
2388
2190
|
let c = ({ state: e, from: n, to: r, rule: i, pasteEvt: a }) => {
|
|
2389
|
-
let c = e.tr, l =
|
|
2191
|
+
let c = e.tr, l = k({
|
|
2390
2192
|
state: e,
|
|
2391
2193
|
transaction: c
|
|
2392
2194
|
});
|
|
2393
|
-
if (
|
|
2195
|
+
if (Mr({
|
|
2394
2196
|
editor: t,
|
|
2395
2197
|
state: l,
|
|
2396
2198
|
from: Math.max(n - 1, 0),
|
|
@@ -2398,7 +2200,7 @@ function Vr(e) {
|
|
|
2398
2200
|
rule: i,
|
|
2399
2201
|
pasteEvent: a,
|
|
2400
2202
|
dropEvent: s
|
|
2401
|
-
})
|
|
2203
|
+
}) && c.steps.length) {
|
|
2402
2204
|
try {
|
|
2403
2205
|
s = typeof DragEvent < "u" ? new DragEvent("drop") : null;
|
|
2404
2206
|
} catch {
|
|
@@ -2407,12 +2209,12 @@ function Vr(e) {
|
|
|
2407
2209
|
return o = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, c;
|
|
2408
2210
|
}
|
|
2409
2211
|
};
|
|
2410
|
-
return n.map((e) => new
|
|
2212
|
+
return n.map((e) => new C({
|
|
2411
2213
|
view(e) {
|
|
2412
2214
|
let n = (n) => {
|
|
2413
|
-
r = e.dom.parentElement?.contains(n.target) ? e.dom.parentElement : null, r && (
|
|
2215
|
+
r = e.dom.parentElement?.contains(n.target) ? e.dom.parentElement : null, r && (Nr = t);
|
|
2414
2216
|
}, i = () => {
|
|
2415
|
-
|
|
2217
|
+
Nr &&= null;
|
|
2416
2218
|
};
|
|
2417
2219
|
return window.addEventListener("dragstart", n), window.addEventListener("dragend", i), { destroy() {
|
|
2418
2220
|
window.removeEventListener("dragstart", n), window.removeEventListener("dragend", i);
|
|
@@ -2421,7 +2223,7 @@ function Vr(e) {
|
|
|
2421
2223
|
props: { handleDOMEvents: {
|
|
2422
2224
|
drop: (e, t) => {
|
|
2423
2225
|
if (a = r === e.dom.parentElement, s = t, !a) {
|
|
2424
|
-
let e =
|
|
2226
|
+
let e = Nr;
|
|
2425
2227
|
e?.isEditable && setTimeout(() => {
|
|
2426
2228
|
let t = e.state.selection;
|
|
2427
2229
|
t && e.commands.deleteRange({
|
|
@@ -2442,8 +2244,8 @@ function Vr(e) {
|
|
|
2442
2244
|
if (!l && !u && !f) return;
|
|
2443
2245
|
if (f) {
|
|
2444
2246
|
let { text: t } = d;
|
|
2445
|
-
t = typeof t == "string" ? t : At(
|
|
2446
|
-
let { from: n } = d, i = n + t.length, a =
|
|
2247
|
+
t = typeof t == "string" ? t : At(D.from(t), r.schema);
|
|
2248
|
+
let { from: n } = d, i = n + t.length, a = Pr(t);
|
|
2447
2249
|
return c({
|
|
2448
2250
|
rule: e,
|
|
2449
2251
|
state: r,
|
|
@@ -2453,7 +2255,7 @@ function Vr(e) {
|
|
|
2453
2255
|
});
|
|
2454
2256
|
}
|
|
2455
2257
|
let p = n.doc.content.findDiffStart(r.doc.content), m = n.doc.content.findDiffEnd(r.doc.content);
|
|
2456
|
-
if (
|
|
2258
|
+
if (_r(p) && m && p !== m.b) return c({
|
|
2457
2259
|
rule: e,
|
|
2458
2260
|
state: r,
|
|
2459
2261
|
from: p,
|
|
@@ -2463,18 +2265,18 @@ function Vr(e) {
|
|
|
2463
2265
|
}
|
|
2464
2266
|
}));
|
|
2465
2267
|
}
|
|
2466
|
-
var
|
|
2268
|
+
var Ir = class {
|
|
2467
2269
|
constructor(e, t) {
|
|
2468
2270
|
this.splittableMarks = [], this.nonClearableMarks = [], this.decorationManager = null, this.editor = t, this.baseExtensions = e, this.extensions = Ut(e), this.schema = Vt(this.extensions, t), this.setupExtensions();
|
|
2469
2271
|
}
|
|
2470
2272
|
get commands() {
|
|
2471
2273
|
return this.extensions.reduce((e, t) => {
|
|
2472
|
-
let n =
|
|
2274
|
+
let n = V(t, "addCommands", {
|
|
2473
2275
|
name: t.name,
|
|
2474
2276
|
options: t.options,
|
|
2475
2277
|
storage: this.editor.extensionStorage[t.name],
|
|
2476
2278
|
editor: this.editor,
|
|
2477
|
-
type:
|
|
2279
|
+
type: K(t.name, this.schema)
|
|
2478
2280
|
});
|
|
2479
2281
|
return n ? {
|
|
2480
2282
|
...e,
|
|
@@ -2483,15 +2285,15 @@ var Hr = class {
|
|
|
2483
2285
|
}, {});
|
|
2484
2286
|
}
|
|
2485
2287
|
get plugins() {
|
|
2486
|
-
let { editor: e } = this, t =
|
|
2288
|
+
let { editor: e } = this, t = G([...this.extensions].reverse()).flatMap((t) => {
|
|
2487
2289
|
let n = {
|
|
2488
2290
|
name: t.name,
|
|
2489
2291
|
options: t.options,
|
|
2490
2292
|
storage: this.editor.extensionStorage[t.name],
|
|
2491
2293
|
editor: e,
|
|
2492
|
-
type:
|
|
2493
|
-
}, r = [], i =
|
|
2494
|
-
if (t.type === "mark" &&
|
|
2294
|
+
type: K(t.name, this.schema)
|
|
2295
|
+
}, r = [], i = V(t, "addKeyboardShortcuts", n), a = {};
|
|
2296
|
+
if (t.type === "mark" && V(t, "exitable", n) && (a.ArrowRight = () => kr.handleExit({
|
|
2495
2297
|
editor: e,
|
|
2496
2298
|
mark: t
|
|
2497
2299
|
})), i) {
|
|
@@ -2501,31 +2303,31 @@ var Hr = class {
|
|
|
2501
2303
|
...t
|
|
2502
2304
|
};
|
|
2503
2305
|
}
|
|
2504
|
-
let o =
|
|
2306
|
+
let o = he(a);
|
|
2505
2307
|
r.push(o);
|
|
2506
|
-
let s =
|
|
2308
|
+
let s = V(t, "addInputRules", n);
|
|
2507
2309
|
if (sn(t, e.options.enableInputRules) && s) {
|
|
2508
2310
|
let t = s();
|
|
2509
2311
|
if (t && t.length) {
|
|
2510
|
-
let n =
|
|
2312
|
+
let n = Dr({
|
|
2511
2313
|
editor: e,
|
|
2512
2314
|
rules: t
|
|
2513
2315
|
}), i = Array.isArray(n) ? n : [n];
|
|
2514
2316
|
r.push(...i);
|
|
2515
2317
|
}
|
|
2516
2318
|
}
|
|
2517
|
-
let c =
|
|
2319
|
+
let c = V(t, "addPasteRules", n);
|
|
2518
2320
|
if (sn(t, e.options.enablePasteRules) && c) {
|
|
2519
2321
|
let t = c();
|
|
2520
2322
|
if (t && t.length) {
|
|
2521
|
-
let n =
|
|
2323
|
+
let n = Fr({
|
|
2522
2324
|
editor: e,
|
|
2523
2325
|
rules: t
|
|
2524
2326
|
});
|
|
2525
2327
|
r.push(...n);
|
|
2526
2328
|
}
|
|
2527
2329
|
}
|
|
2528
|
-
let l =
|
|
2330
|
+
let l = V(t, "addProseMirrorPlugins", n);
|
|
2529
2331
|
if (l) {
|
|
2530
2332
|
let e = l();
|
|
2531
2333
|
r.push(...e);
|
|
@@ -2540,12 +2342,12 @@ var Hr = class {
|
|
|
2540
2342
|
(e = this.decorationManager) == null || e.destroy();
|
|
2541
2343
|
let n = [];
|
|
2542
2344
|
return this.extensions.forEach((e) => {
|
|
2543
|
-
let r =
|
|
2345
|
+
let r = V(e, "addDecorations", {
|
|
2544
2346
|
name: e.name,
|
|
2545
2347
|
options: e.options,
|
|
2546
2348
|
storage: this.editor.extensionStorage[e.name],
|
|
2547
2349
|
editor: t,
|
|
2548
|
-
type:
|
|
2350
|
+
type: K(e.name, this.schema)
|
|
2549
2351
|
});
|
|
2550
2352
|
r && n.push({
|
|
2551
2353
|
name: e.name,
|
|
@@ -2560,19 +2362,19 @@ var Hr = class {
|
|
|
2560
2362
|
return Nt(this.extensions);
|
|
2561
2363
|
}
|
|
2562
2364
|
get nodeViews() {
|
|
2563
|
-
let { editor: e } = this, { nodeExtensions: t } =
|
|
2564
|
-
return Object.fromEntries(t.filter((e) => !!
|
|
2565
|
-
let n = this.attributes.filter((e) => e.type === t.name), r =
|
|
2365
|
+
let { editor: e } = this, { nodeExtensions: t } = U(this.extensions);
|
|
2366
|
+
return Object.fromEntries(t.filter((e) => !!V(e, "addNodeView")).map((t) => {
|
|
2367
|
+
let n = this.attributes.filter((e) => e.type === t.name), r = V(t, "addNodeView", {
|
|
2566
2368
|
name: t.name,
|
|
2567
2369
|
options: t.options,
|
|
2568
2370
|
storage: this.editor.extensionStorage[t.name],
|
|
2569
2371
|
editor: e,
|
|
2570
|
-
type:
|
|
2372
|
+
type: j(t.name, this.schema)
|
|
2571
2373
|
});
|
|
2572
2374
|
if (!r) return [];
|
|
2573
2375
|
let i = r();
|
|
2574
2376
|
return i ? [t.name, (r, a, o, s, c) => {
|
|
2575
|
-
let l =
|
|
2377
|
+
let l = W(r, n);
|
|
2576
2378
|
return i({
|
|
2577
2379
|
node: r,
|
|
2578
2380
|
view: a,
|
|
@@ -2588,14 +2390,14 @@ var Hr = class {
|
|
|
2588
2390
|
}
|
|
2589
2391
|
dispatchTransaction(e) {
|
|
2590
2392
|
let { editor: t } = this;
|
|
2591
|
-
return
|
|
2393
|
+
return G([...this.extensions].reverse()).reduceRight((e, n) => {
|
|
2592
2394
|
let r = {
|
|
2593
2395
|
name: n.name,
|
|
2594
2396
|
options: n.options,
|
|
2595
2397
|
storage: this.editor.extensionStorage[n.name],
|
|
2596
2398
|
editor: t,
|
|
2597
|
-
type:
|
|
2598
|
-
}, i =
|
|
2399
|
+
type: K(n.name, this.schema)
|
|
2400
|
+
}, i = V(n, "dispatchTransaction", r);
|
|
2599
2401
|
return i ? (t) => {
|
|
2600
2402
|
i.call(r, {
|
|
2601
2403
|
transaction: t,
|
|
@@ -2606,14 +2408,14 @@ var Hr = class {
|
|
|
2606
2408
|
}
|
|
2607
2409
|
transformPastedHTML(e) {
|
|
2608
2410
|
let { editor: t } = this;
|
|
2609
|
-
return
|
|
2411
|
+
return G([...this.extensions]).reduce((e, n) => {
|
|
2610
2412
|
let r = {
|
|
2611
2413
|
name: n.name,
|
|
2612
2414
|
options: n.options,
|
|
2613
2415
|
storage: this.editor.extensionStorage[n.name],
|
|
2614
2416
|
editor: t,
|
|
2615
|
-
type:
|
|
2616
|
-
}, i =
|
|
2417
|
+
type: K(n.name, this.schema)
|
|
2418
|
+
}, i = V(n, "transformPastedHTML", r);
|
|
2617
2419
|
return i ? (t, n) => {
|
|
2618
2420
|
let a = e(t, n);
|
|
2619
2421
|
return i.call(r, a);
|
|
@@ -2621,17 +2423,17 @@ var Hr = class {
|
|
|
2621
2423
|
}, e || ((e) => e));
|
|
2622
2424
|
}
|
|
2623
2425
|
get markViews() {
|
|
2624
|
-
let { editor: e } = this, { markExtensions: t } =
|
|
2625
|
-
return Object.fromEntries(t.filter((e) => !!
|
|
2626
|
-
let n = this.attributes.filter((e) => e.type === t.name), r =
|
|
2426
|
+
let { editor: e } = this, { markExtensions: t } = U(this.extensions);
|
|
2427
|
+
return Object.fromEntries(t.filter((e) => !!V(e, "addMarkView")).map((t) => {
|
|
2428
|
+
let n = this.attributes.filter((e) => e.type === t.name), r = V(t, "addMarkView", {
|
|
2627
2429
|
name: t.name,
|
|
2628
2430
|
options: t.options,
|
|
2629
2431
|
storage: this.editor.extensionStorage[t.name],
|
|
2630
2432
|
editor: e,
|
|
2631
|
-
type:
|
|
2433
|
+
type: P(t.name, this.schema)
|
|
2632
2434
|
});
|
|
2633
2435
|
return r ? [t.name, (i, a, o) => {
|
|
2634
|
-
let s =
|
|
2436
|
+
let s = W(i, n);
|
|
2635
2437
|
return r()({
|
|
2636
2438
|
mark: i,
|
|
2637
2439
|
view: a,
|
|
@@ -2640,7 +2442,7 @@ var Hr = class {
|
|
|
2640
2442
|
extension: t,
|
|
2641
2443
|
HTMLAttributes: s,
|
|
2642
2444
|
updateAttributes: (t) => {
|
|
2643
|
-
|
|
2445
|
+
wr(i, e, t);
|
|
2644
2446
|
}
|
|
2645
2447
|
});
|
|
2646
2448
|
}] : [];
|
|
@@ -2664,30 +2466,18 @@ var Hr = class {
|
|
|
2664
2466
|
options: e.options,
|
|
2665
2467
|
storage: this.editor.extensionStorage[e.name],
|
|
2666
2468
|
editor: this.editor,
|
|
2667
|
-
type:
|
|
2469
|
+
type: K(e.name, this.schema)
|
|
2668
2470
|
};
|
|
2669
|
-
e.type === "mark" && ((
|
|
2670
|
-
let n =
|
|
2471
|
+
e.type === "mark" && ((H(V(e, "keepOnSplit", t)) ?? !0) && this.splittableMarks.push(e.name), (H(V(e, "clearable", t)) ?? !0) || this.nonClearableMarks.push(e.name));
|
|
2472
|
+
let n = V(e, "onBeforeCreate", t), r = V(e, "onCreate", t), i = V(e, "onUpdate", t), a = V(e, "onSelectionUpdate", t), o = V(e, "onTransaction", t), s = V(e, "onFocus", t), c = V(e, "onBlur", t), l = V(e, "onDestroy", t);
|
|
2671
2473
|
n && this.editor.on("beforeCreate", n), r && this.editor.on("create", r), i && this.editor.on("update", i), a && this.editor.on("selectionUpdate", a), o && this.editor.on("transaction", o), s && this.editor.on("focus", s), c && this.editor.on("blur", c), l && this.editor.on("destroy", l);
|
|
2672
2474
|
});
|
|
2673
2475
|
}
|
|
2674
2476
|
};
|
|
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";
|
|
2477
|
+
Ir.resolve = Ut, Ir.sort = G, Ir.flatten = kt;
|
|
2478
|
+
var $ = class e extends Or {
|
|
2479
|
+
constructor(...e) {
|
|
2480
|
+
super(...e), this.type = "extension";
|
|
2691
2481
|
}
|
|
2692
2482
|
static create(t = {}) {
|
|
2693
2483
|
let n = typeof t == "function" ? t() : t;
|
|
@@ -2700,14 +2490,14 @@ var $ = class e extends Pr {
|
|
|
2700
2490
|
let t = typeof e == "function" ? e() : e;
|
|
2701
2491
|
return super.extend(t);
|
|
2702
2492
|
}
|
|
2703
|
-
},
|
|
2493
|
+
}, Lr = $.create({
|
|
2704
2494
|
name: "clipboardTextSerializer",
|
|
2705
2495
|
addOptions() {
|
|
2706
2496
|
return { blockSeparator: void 0 };
|
|
2707
2497
|
},
|
|
2708
2498
|
addProseMirrorPlugins() {
|
|
2709
|
-
return [new
|
|
2710
|
-
key: new
|
|
2499
|
+
return [new C({
|
|
2500
|
+
key: new w("clipboardTextSerializer"),
|
|
2711
2501
|
props: { clipboardTextSerializer: () => {
|
|
2712
2502
|
let { editor: e } = this, { state: t, schema: n } = e, { doc: r, selection: i } = t, a = Kt(n), { blockSeparator: o } = this.options, s = {
|
|
2713
2503
|
...o === void 0 ? {} : { blockSeparator: o },
|
|
@@ -2720,41 +2510,42 @@ var $ = class e extends Pr {
|
|
|
2720
2510
|
} }
|
|
2721
2511
|
})];
|
|
2722
2512
|
}
|
|
2723
|
-
}),
|
|
2513
|
+
}), Rr = $.create({
|
|
2724
2514
|
name: "commands",
|
|
2725
2515
|
addCommands() {
|
|
2726
|
-
return { ...
|
|
2516
|
+
return { ...Hn };
|
|
2727
2517
|
}
|
|
2728
|
-
}),
|
|
2518
|
+
}), zr = $.create({
|
|
2729
2519
|
name: "delete",
|
|
2730
2520
|
onUpdate({ transaction: t, appendedTransactions: n }) {
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2521
|
+
var r;
|
|
2522
|
+
let i = () => {
|
|
2523
|
+
var r, i;
|
|
2524
|
+
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;
|
|
2525
|
+
let a = Tt(t.before, [t, ...n]);
|
|
2526
|
+
Zt(a).forEach((e) => {
|
|
2527
|
+
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) => {
|
|
2528
|
+
let i = r + n.nodeSize - 2, o = e.oldRange.from <= r && i <= e.oldRange.to;
|
|
2738
2529
|
this.editor.emit("delete", {
|
|
2739
2530
|
type: "node",
|
|
2740
2531
|
node: n,
|
|
2741
2532
|
from: r,
|
|
2742
|
-
to:
|
|
2743
|
-
newFrom:
|
|
2744
|
-
newTo:
|
|
2533
|
+
to: i,
|
|
2534
|
+
newFrom: a.mapping.map(r),
|
|
2535
|
+
newTo: a.mapping.map(i),
|
|
2745
2536
|
deletedRange: e.oldRange,
|
|
2746
2537
|
newRange: e.newRange,
|
|
2747
2538
|
partial: !o,
|
|
2748
2539
|
editor: this.editor,
|
|
2749
2540
|
transaction: t,
|
|
2750
|
-
combinedTransform:
|
|
2541
|
+
combinedTransform: a
|
|
2751
2542
|
});
|
|
2752
2543
|
});
|
|
2753
2544
|
});
|
|
2754
|
-
let
|
|
2755
|
-
|
|
2545
|
+
let o = a.mapping;
|
|
2546
|
+
a.steps.forEach((n, r) => {
|
|
2756
2547
|
if (n instanceof e) {
|
|
2757
|
-
let e =
|
|
2548
|
+
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
2549
|
this.editor.emit("delete", {
|
|
2759
2550
|
type: "mark",
|
|
2760
2551
|
mark: n.mark,
|
|
@@ -2766,23 +2557,23 @@ var $ = class e extends Pr {
|
|
|
2766
2557
|
},
|
|
2767
2558
|
newRange: {
|
|
2768
2559
|
from: e,
|
|
2769
|
-
to:
|
|
2560
|
+
to: i
|
|
2770
2561
|
},
|
|
2771
2562
|
partial: !!(u || l),
|
|
2772
2563
|
editor: this.editor,
|
|
2773
2564
|
transaction: t,
|
|
2774
|
-
combinedTransform:
|
|
2565
|
+
combinedTransform: a
|
|
2775
2566
|
});
|
|
2776
2567
|
}
|
|
2777
2568
|
});
|
|
2778
2569
|
};
|
|
2779
|
-
this.editor.options.coreExtensionOptions
|
|
2570
|
+
((r = this.editor.options.coreExtensionOptions) == null || (r = r.delete) == null ? void 0 : r.async) ?? !0 ? setTimeout(i, 0) : i();
|
|
2780
2571
|
}
|
|
2781
|
-
}),
|
|
2572
|
+
}), Br = $.create({
|
|
2782
2573
|
name: "drop",
|
|
2783
2574
|
addProseMirrorPlugins() {
|
|
2784
|
-
return [new
|
|
2785
|
-
key: new
|
|
2575
|
+
return [new C({
|
|
2576
|
+
key: new w("tiptapDrop"),
|
|
2786
2577
|
props: { handleDrop: (e, t, n, r) => {
|
|
2787
2578
|
this.editor.emit("drop", {
|
|
2788
2579
|
editor: this.editor,
|
|
@@ -2793,20 +2584,20 @@ var $ = class e extends Pr {
|
|
|
2793
2584
|
} }
|
|
2794
2585
|
})];
|
|
2795
2586
|
}
|
|
2796
|
-
}),
|
|
2587
|
+
}), Vr = $.create({
|
|
2797
2588
|
name: "editable",
|
|
2798
2589
|
addProseMirrorPlugins() {
|
|
2799
|
-
return [new
|
|
2800
|
-
key: new
|
|
2590
|
+
return [new C({
|
|
2591
|
+
key: new w("editable"),
|
|
2801
2592
|
props: { editable: () => this.editor.options.editable }
|
|
2802
2593
|
})];
|
|
2803
2594
|
}
|
|
2804
|
-
}),
|
|
2595
|
+
}), Hr = new w("focusEvents"), Ur = $.create({
|
|
2805
2596
|
name: "focusEvents",
|
|
2806
2597
|
addProseMirrorPlugins() {
|
|
2807
2598
|
let { editor: e } = this;
|
|
2808
|
-
return [new
|
|
2809
|
-
key:
|
|
2599
|
+
return [new C({
|
|
2600
|
+
key: Hr,
|
|
2810
2601
|
props: { handleDOMEvents: {
|
|
2811
2602
|
focus: (t, n) => {
|
|
2812
2603
|
e.isFocused = !0;
|
|
@@ -2821,13 +2612,13 @@ var $ = class e extends Pr {
|
|
|
2821
2612
|
} }
|
|
2822
2613
|
})];
|
|
2823
2614
|
}
|
|
2824
|
-
}),
|
|
2615
|
+
}), Wr = $.create({
|
|
2825
2616
|
name: "keymap",
|
|
2826
2617
|
addKeyboardShortcuts() {
|
|
2827
2618
|
let e = () => this.editor.commands.first(({ commands: e }) => [
|
|
2828
2619
|
() => e.undoInputRule(),
|
|
2829
2620
|
() => 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 :
|
|
2621
|
+
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 : T.atStart(r).from === o;
|
|
2831
2622
|
return !i || !s.type.isTextblock || s.textContent.length || !d || d && a.parent.type.name === "paragraph" ? !1 : e.clearNodes();
|
|
2832
2623
|
}),
|
|
2833
2624
|
() => e.deleteSelection(),
|
|
@@ -2863,21 +2654,21 @@ var $ = class e extends Pr {
|
|
|
2863
2654
|
"Ctrl-a": () => this.editor.commands.selectTextblockStart(),
|
|
2864
2655
|
"Ctrl-e": () => this.editor.commands.selectTextblockEnd()
|
|
2865
2656
|
};
|
|
2866
|
-
return I() ||
|
|
2657
|
+
return I() || ot() ? i : r;
|
|
2867
2658
|
},
|
|
2868
2659
|
addProseMirrorPlugins() {
|
|
2869
|
-
return [new
|
|
2870
|
-
key: new
|
|
2660
|
+
return [new C({
|
|
2661
|
+
key: new w("clearDocument"),
|
|
2871
2662
|
appendTransaction: (e, t, n) => {
|
|
2872
2663
|
if (e.some((e) => e.getMeta("composition"))) return;
|
|
2873
2664
|
let r = e.some((e) => e.docChanged) && !t.doc.eq(n.doc), i = e.some((e) => e.getMeta("preventClearDocument"));
|
|
2874
2665
|
if (!r || i) return;
|
|
2875
|
-
let { empty: a, from: o, to: s } = t.selection, c =
|
|
2876
|
-
if (a || o !== c || s !== l || !
|
|
2877
|
-
let u = n.tr, d =
|
|
2666
|
+
let { empty: a, from: o, to: s } = t.selection, c = T.atStart(t.doc).from, l = T.atEnd(t.doc).to;
|
|
2667
|
+
if (a || o !== c || s !== l || !J(n.doc)) return;
|
|
2668
|
+
let u = n.tr, d = k({
|
|
2878
2669
|
state: n,
|
|
2879
2670
|
transaction: u
|
|
2880
|
-
}), { commands: f } = new
|
|
2671
|
+
}), { commands: f } = new A({
|
|
2881
2672
|
editor: this.editor,
|
|
2882
2673
|
state: d
|
|
2883
2674
|
});
|
|
@@ -2885,11 +2676,11 @@ var $ = class e extends Pr {
|
|
|
2885
2676
|
}
|
|
2886
2677
|
})];
|
|
2887
2678
|
}
|
|
2888
|
-
}),
|
|
2679
|
+
}), Gr = $.create({
|
|
2889
2680
|
name: "paste",
|
|
2890
2681
|
addProseMirrorPlugins() {
|
|
2891
|
-
return [new
|
|
2892
|
-
key: new
|
|
2682
|
+
return [new C({
|
|
2683
|
+
key: new w("tiptapPaste"),
|
|
2893
2684
|
props: { handlePaste: (e, t, n) => {
|
|
2894
2685
|
this.editor.emit("paste", {
|
|
2895
2686
|
editor: this.editor,
|
|
@@ -2899,25 +2690,25 @@ var $ = class e extends Pr {
|
|
|
2899
2690
|
} }
|
|
2900
2691
|
})];
|
|
2901
2692
|
}
|
|
2902
|
-
}),
|
|
2693
|
+
}), Kr = $.create({
|
|
2903
2694
|
name: "tabindex",
|
|
2904
2695
|
addOptions() {
|
|
2905
2696
|
return { value: void 0 };
|
|
2906
2697
|
},
|
|
2907
2698
|
addProseMirrorPlugins() {
|
|
2908
|
-
return [new
|
|
2909
|
-
key: new
|
|
2699
|
+
return [new C({
|
|
2700
|
+
key: new w("tabindex"),
|
|
2910
2701
|
props: { attributes: () => !this.editor.isEditable && this.options.value === void 0 ? {} : { tabindex: this.options.value ?? "0" } }
|
|
2911
2702
|
})];
|
|
2912
2703
|
}
|
|
2913
|
-
}),
|
|
2704
|
+
}), qr = $.create({
|
|
2914
2705
|
name: "textDirection",
|
|
2915
2706
|
addOptions() {
|
|
2916
2707
|
return { direction: void 0 };
|
|
2917
2708
|
},
|
|
2918
2709
|
addGlobalAttributes() {
|
|
2919
2710
|
if (!this.options.direction) return [];
|
|
2920
|
-
let { nodeExtensions: e } =
|
|
2711
|
+
let { nodeExtensions: e } = U(this.extensions);
|
|
2921
2712
|
return [{
|
|
2922
2713
|
types: e.filter((e) => e.name !== "text").map((e) => e.name),
|
|
2923
2714
|
attributes: { dir: {
|
|
@@ -2931,18 +2722,18 @@ var $ = class e extends Pr {
|
|
|
2931
2722
|
}];
|
|
2932
2723
|
},
|
|
2933
2724
|
addProseMirrorPlugins() {
|
|
2934
|
-
return [new
|
|
2935
|
-
key: new
|
|
2725
|
+
return [new C({
|
|
2726
|
+
key: new w("textDirection"),
|
|
2936
2727
|
props: { attributes: () => {
|
|
2937
2728
|
let e = this.options.direction;
|
|
2938
2729
|
return e ? { dir: e } : {};
|
|
2939
2730
|
} }
|
|
2940
2731
|
})];
|
|
2941
2732
|
}
|
|
2942
|
-
}),
|
|
2943
|
-
function
|
|
2944
|
-
if (
|
|
2945
|
-
|
|
2733
|
+
}), Jr = !1;
|
|
2734
|
+
function Yr(e) {
|
|
2735
|
+
if (Jr) return;
|
|
2736
|
+
Jr = !0;
|
|
2946
2737
|
let t;
|
|
2947
2738
|
try {
|
|
2948
2739
|
t = n.fromJSON(e, {
|
|
@@ -2952,15 +2743,15 @@ function ti(e) {
|
|
|
2952
2743
|
} catch {
|
|
2953
2744
|
return;
|
|
2954
2745
|
}
|
|
2955
|
-
t instanceof
|
|
2746
|
+
t instanceof D || 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
2747
|
}
|
|
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
|
-
}
|
|
2748
|
+
var Xr = class e {
|
|
2961
2749
|
get name() {
|
|
2962
2750
|
return this.node.type.name;
|
|
2963
2751
|
}
|
|
2752
|
+
constructor(e, t, n = !1, r = null) {
|
|
2753
|
+
this.currentNode = null, this.actualDepth = null, this.isBlock = n, this.resolvedPos = e, this.editor = t, this.currentNode = r;
|
|
2754
|
+
}
|
|
2964
2755
|
get node() {
|
|
2965
2756
|
return this.currentNode || this.resolvedPos.node();
|
|
2966
2757
|
}
|
|
@@ -2980,7 +2771,7 @@ var ni = class e {
|
|
|
2980
2771
|
let t = this.from, n = this.to;
|
|
2981
2772
|
if (this.isBlock) {
|
|
2982
2773
|
if (this.content.size === 0) {
|
|
2983
|
-
console.error(`You can
|
|
2774
|
+
console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);
|
|
2984
2775
|
return;
|
|
2985
2776
|
}
|
|
2986
2777
|
t = this.from + 1, n = this.to - 1;
|
|
@@ -3076,7 +2867,7 @@ var ni = class e {
|
|
|
3076
2867
|
...e
|
|
3077
2868
|
}), this.editor.view.dispatch(t);
|
|
3078
2869
|
}
|
|
3079
|
-
},
|
|
2870
|
+
}, Zr = ".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}", Qr = class extends Gn {
|
|
3080
2871
|
constructor(e = {}) {
|
|
3081
2872
|
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
2873
|
element: typeof document < "u" ? document.createElement("div") : null,
|
|
@@ -3113,19 +2904,19 @@ var ni = class e {
|
|
|
3113
2904
|
onDelete: () => null,
|
|
3114
2905
|
enableExtensionDispatchTransaction: !0
|
|
3115
2906
|
}, this.isCapturingTransaction = !1, this.capturedTransaction = null, this.utils = {
|
|
3116
|
-
getUpdatedPosition:
|
|
3117
|
-
createMappablePosition:
|
|
2907
|
+
getUpdatedPosition: dn,
|
|
2908
|
+
createMappablePosition: fn
|
|
3118
2909
|
}, 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
2910
|
let t = this.createDoc();
|
|
3120
2911
|
if (!this.editorState) {
|
|
3121
|
-
let e =
|
|
3122
|
-
this.editorState =
|
|
2912
|
+
let e = ze(t, this.options.autofocus);
|
|
2913
|
+
this.editorState = oe.create({
|
|
3123
2914
|
doc: t,
|
|
3124
2915
|
schema: this.schema,
|
|
3125
2916
|
selection: e || void 0
|
|
3126
2917
|
});
|
|
3127
2918
|
}
|
|
3128
|
-
|
|
2919
|
+
Yr(this.schema), this.options.element && this.mount(this.options.element);
|
|
3129
2920
|
}
|
|
3130
2921
|
mount(e) {
|
|
3131
2922
|
if (typeof document > "u") throw Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");
|
|
@@ -3153,19 +2944,19 @@ var ni = class e {
|
|
|
3153
2944
|
return this.commandManager.commands;
|
|
3154
2945
|
}
|
|
3155
2946
|
chain() {
|
|
3156
|
-
return this.commandManager ? this.commandManager.chain() :
|
|
2947
|
+
return this.commandManager ? this.commandManager.chain() : A.createFakeChain();
|
|
3157
2948
|
}
|
|
3158
2949
|
can() {
|
|
3159
|
-
return this.commandManager ? this.commandManager.can() :
|
|
2950
|
+
return this.commandManager ? this.commandManager.can() : A.createFallbackCan();
|
|
3160
2951
|
}
|
|
3161
2952
|
injectCSS() {
|
|
3162
|
-
this.options.injectCSS && typeof document < "u" && (this.css = pr(
|
|
2953
|
+
this.options.injectCSS && typeof document < "u" && (this.css = pr(Zr, this.options.injectNonce));
|
|
3163
2954
|
}
|
|
3164
2955
|
setOptions(e = {}) {
|
|
3165
2956
|
this.options = {
|
|
3166
2957
|
...this.options,
|
|
3167
2958
|
...e
|
|
3168
|
-
},
|
|
2959
|
+
}, this.editorView && this.state && !this.isDestroyed && (this.options.editorProps && this.view.setProps(this.options.editorProps), this.view.updateState(this.state));
|
|
3169
2960
|
}
|
|
3170
2961
|
setEditable(e, t = !0) {
|
|
3171
2962
|
this.setOptions({ editable: e }), t && this.emit("update", {
|
|
@@ -3215,26 +3006,27 @@ var ni = class e {
|
|
|
3215
3006
|
return this.view.updateState(r), r;
|
|
3216
3007
|
}
|
|
3217
3008
|
createExtensionManager() {
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3009
|
+
var e, t;
|
|
3010
|
+
let n = [...this.options.enableCoreExtensions ? [
|
|
3011
|
+
Vr,
|
|
3012
|
+
Lr.configure({ blockSeparator: (e = this.options.coreExtensionOptions) == null || (e = e.clipboardTextSerializer) == null ? void 0 : e.blockSeparator }),
|
|
3013
|
+
Rr,
|
|
3014
|
+
Ur,
|
|
3221
3015
|
Wr,
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
Qr.configure({ value: this.options.coreExtensionOptions?.tabindex?.value }),
|
|
3225
|
-
Kr,
|
|
3226
|
-
Zr,
|
|
3016
|
+
Kr.configure({ value: (t = this.options.coreExtensionOptions) == null || (t = t.tabindex) == null ? void 0 : t.value }),
|
|
3017
|
+
Br,
|
|
3227
3018
|
Gr,
|
|
3228
|
-
|
|
3019
|
+
zr,
|
|
3020
|
+
qr.configure({ direction: this.options.textDirection })
|
|
3229
3021
|
].filter((e) => typeof this.options.enableCoreExtensions != "object" || this.options.enableCoreExtensions[e.name] !== !1) : [], ...this.options.extensions].filter((e) => [
|
|
3230
3022
|
"extension",
|
|
3231
3023
|
"node",
|
|
3232
3024
|
"mark"
|
|
3233
3025
|
].includes(e?.type));
|
|
3234
|
-
this.extensionManager = new
|
|
3026
|
+
this.extensionManager = new Ir(n, this);
|
|
3235
3027
|
}
|
|
3236
3028
|
createCommandManager() {
|
|
3237
|
-
this.commandManager = new
|
|
3029
|
+
this.commandManager = new A({ editor: this });
|
|
3238
3030
|
}
|
|
3239
3031
|
createSchema() {
|
|
3240
3032
|
this.schema = this.extensionManager.schema;
|
|
@@ -3242,14 +3034,14 @@ var ni = class e {
|
|
|
3242
3034
|
createDoc() {
|
|
3243
3035
|
let e;
|
|
3244
3036
|
try {
|
|
3245
|
-
e =
|
|
3037
|
+
e = St(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: this.options.enableContentCheck });
|
|
3246
3038
|
} catch (e) {
|
|
3247
3039
|
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 =
|
|
3040
|
+
let t = St(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: !1 });
|
|
3041
|
+
return this.editorState = oe.create({
|
|
3250
3042
|
doc: t,
|
|
3251
3043
|
schema: this.schema,
|
|
3252
|
-
selection:
|
|
3044
|
+
selection: ze(t, this.options.autofocus) || void 0
|
|
3253
3045
|
}), this.emit("contentError", {
|
|
3254
3046
|
editor: this,
|
|
3255
3047
|
error: e,
|
|
@@ -3262,7 +3054,7 @@ var ni = class e {
|
|
|
3262
3054
|
}
|
|
3263
3055
|
createView(e) {
|
|
3264
3056
|
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
|
|
3057
|
+
this.editorView = new me(e, {
|
|
3266
3058
|
...t,
|
|
3267
3059
|
attributes: {
|
|
3268
3060
|
role: "textbox",
|
|
@@ -3356,7 +3148,7 @@ var ni = class e {
|
|
|
3356
3148
|
});
|
|
3357
3149
|
}
|
|
3358
3150
|
get isEmpty() {
|
|
3359
|
-
return
|
|
3151
|
+
return J(this.state.doc);
|
|
3360
3152
|
}
|
|
3361
3153
|
destroy() {
|
|
3362
3154
|
this.destroyed || (this.destroyed = !0, this.emit("destroy"), this.unmount(), this.removeAllListeners(), this.extensionManager.destroy(), this.extensionManager = null, this.schema = null, this.commandManager = null, this.extensionStorage = {});
|
|
@@ -3372,17 +3164,17 @@ var ni = class e {
|
|
|
3372
3164
|
}
|
|
3373
3165
|
$pos(e) {
|
|
3374
3166
|
let t = this.state.doc.resolve(e), n = e > 0 && t.nodeAfter && !t.nodeAfter.isText && t.nodeAfter.isAtom ? t.nodeAfter : null;
|
|
3375
|
-
return new
|
|
3167
|
+
return new Xr(t, this, !1, n);
|
|
3376
3168
|
}
|
|
3377
3169
|
get $doc() {
|
|
3378
3170
|
return this.$pos(0);
|
|
3379
3171
|
}
|
|
3380
3172
|
};
|
|
3381
|
-
function
|
|
3173
|
+
function $r(e) {
|
|
3382
3174
|
return new Q({
|
|
3383
3175
|
find: e.find,
|
|
3384
3176
|
handler: ({ state: t, range: n, match: r }) => {
|
|
3385
|
-
let i =
|
|
3177
|
+
let i = H(e.getAttributes, void 0, r);
|
|
3386
3178
|
if (i === !1 || i === null) return null;
|
|
3387
3179
|
let { tr: a } = t, o = r[r.length - 1], s = r[0];
|
|
3388
3180
|
if (o) {
|
|
@@ -3396,11 +3188,11 @@ function ai(e) {
|
|
|
3396
3188
|
undoable: e.undoable
|
|
3397
3189
|
});
|
|
3398
3190
|
}
|
|
3399
|
-
function
|
|
3191
|
+
function ei(e) {
|
|
3400
3192
|
return new Q({
|
|
3401
3193
|
find: e.find,
|
|
3402
3194
|
handler: ({ state: t, range: n, match: r }) => {
|
|
3403
|
-
let i =
|
|
3195
|
+
let i = H(e.getAttributes, void 0, r) || {}, { tr: a } = t, o = n.from, s = n.to, c = e.type.create(i);
|
|
3404
3196
|
if (r[1]) {
|
|
3405
3197
|
let e = o + r[0].lastIndexOf(r[1]);
|
|
3406
3198
|
e > s ? e = s : s = e + r[1].length;
|
|
@@ -3415,18 +3207,18 @@ function oi(e) {
|
|
|
3415
3207
|
undoable: e.undoable
|
|
3416
3208
|
});
|
|
3417
3209
|
}
|
|
3418
|
-
function
|
|
3210
|
+
function ti(e) {
|
|
3419
3211
|
return new Q({
|
|
3420
3212
|
find: e.find,
|
|
3421
3213
|
handler: ({ state: t, range: n, match: r }) => {
|
|
3422
|
-
let i = t.doc.resolve(n.from), a =
|
|
3214
|
+
let i = t.doc.resolve(n.from), a = H(e.getAttributes, void 0, r) || {};
|
|
3423
3215
|
if (!i.node(-1).canReplaceWith(i.index(-1), i.indexAfter(-1), e.type)) return null;
|
|
3424
3216
|
t.tr.delete(n.from, n.to).setBlockType(n.from, n.from, e.type, a);
|
|
3425
3217
|
},
|
|
3426
3218
|
undoable: e.undoable
|
|
3427
3219
|
});
|
|
3428
3220
|
}
|
|
3429
|
-
function
|
|
3221
|
+
function ni(e) {
|
|
3430
3222
|
return new Q({
|
|
3431
3223
|
find: e.find,
|
|
3432
3224
|
handler: ({ state: t, range: n, match: r }) => {
|
|
@@ -3442,11 +3234,11 @@ function ci(e) {
|
|
|
3442
3234
|
undoable: e.undoable
|
|
3443
3235
|
});
|
|
3444
3236
|
}
|
|
3445
|
-
function
|
|
3237
|
+
function ri(e) {
|
|
3446
3238
|
return new Q({
|
|
3447
3239
|
find: e.find,
|
|
3448
3240
|
handler: ({ state: t, range: n, match: r, chain: a }) => {
|
|
3449
|
-
let s =
|
|
3241
|
+
let s = H(e.getAttributes, void 0, r) || {}, c = t.tr.delete(n.from, n.to), l = c.doc.resolve(n.from).blockRange(), u = l && o(l, e.type, s);
|
|
3450
3242
|
if (!u) return null;
|
|
3451
3243
|
if (c.wrap(l, u), e.keepMarks && e.editor) {
|
|
3452
3244
|
let { selection: n, storedMarks: r } = t, { splittableMarks: i } = e.editor.extensionManager, a = r || n.$to.parentOffset && n.$from.marks();
|
|
@@ -3465,8 +3257,9 @@ function li(e) {
|
|
|
3465
3257
|
undoable: e.undoable
|
|
3466
3258
|
});
|
|
3467
3259
|
}
|
|
3468
|
-
var
|
|
3260
|
+
var ii = (e) => "touches" in e, ai = class {
|
|
3469
3261
|
constructor(e) {
|
|
3262
|
+
var t;
|
|
3470
3263
|
this.directions = [
|
|
3471
3264
|
"bottom-left",
|
|
3472
3265
|
"bottom-right",
|
|
@@ -3501,7 +3294,7 @@ var ui = (e) => "touches" in e, di = class {
|
|
|
3501
3294
|
}, 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
3295
|
...this.minSize,
|
|
3503
3296
|
...e.options.min
|
|
3504
|
-
}), e.options?.max && (this.maxSize = e.options.max), e
|
|
3297
|
+
}), 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
3298
|
container: e.options.className.container || "",
|
|
3506
3299
|
wrapper: e.options.className.wrapper || "",
|
|
3507
3300
|
handle: e.options.className.handle || "",
|
|
@@ -3554,7 +3347,7 @@ var ui = (e) => "touches" in e, di = class {
|
|
|
3554
3347
|
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
3348
|
}
|
|
3556
3349
|
handleResizeStart(e, t) {
|
|
3557
|
-
e.preventDefault(), e.stopPropagation(), this.isResizing = !0, this.activeHandle = t,
|
|
3350
|
+
e.preventDefault(), e.stopPropagation(), this.isResizing = !0, this.activeHandle = t, ii(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
3351
|
}
|
|
3559
3352
|
handleResize(e, t) {
|
|
3560
3353
|
if (!this.activeHandle) return;
|
|
@@ -3594,9 +3387,9 @@ var ui = (e) => "touches" in e, di = class {
|
|
|
3594
3387
|
height: e / this.aspectRatio
|
|
3595
3388
|
};
|
|
3596
3389
|
}
|
|
3597
|
-
},
|
|
3598
|
-
constructor() {
|
|
3599
|
-
super(...
|
|
3390
|
+
}, oi = class e extends Or {
|
|
3391
|
+
constructor(...e) {
|
|
3392
|
+
super(...e), this.type = "node";
|
|
3600
3393
|
}
|
|
3601
3394
|
static create(t = {}) {
|
|
3602
3395
|
let n = typeof t == "function" ? t() : t;
|
|
@@ -3609,7 +3402,7 @@ var ui = (e) => "touches" in e, di = class {
|
|
|
3609
3402
|
let t = typeof e == "function" ? e() : e;
|
|
3610
3403
|
return super.extend(t);
|
|
3611
3404
|
}
|
|
3612
|
-
},
|
|
3405
|
+
}, si = class {
|
|
3613
3406
|
constructor(e, t, n) {
|
|
3614
3407
|
this.isDragging = !1, this.component = e, this.editor = t.editor, this.options = {
|
|
3615
3408
|
stopEvent: null,
|
|
@@ -3631,39 +3424,39 @@ var ui = (e) => "touches" in e, di = class {
|
|
|
3631
3424
|
return null;
|
|
3632
3425
|
}
|
|
3633
3426
|
onDragStart(e) {
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
a = n.x - t.x + r, o = n.y - t.y + s;
|
|
3427
|
+
let { view: t } = this.editor, n = e.target, r = n.nodeType === 3 ? n.parentElement?.closest("[data-drag-handle]") : n.closest("[data-drag-handle]");
|
|
3428
|
+
if (!this.dom || this.contentDOM?.contains(n) || !r) return;
|
|
3429
|
+
let i = 0, a = 0;
|
|
3430
|
+
if (this.dom !== r) {
|
|
3431
|
+
let t = this.dom.getBoundingClientRect(), n = r.getBoundingClientRect(), o = e.offsetX ?? e.nativeEvent?.offsetX, s = e.offsetY ?? e.nativeEvent?.offsetY;
|
|
3432
|
+
i = n.x - t.x + o, a = n.y - t.y + s;
|
|
3641
3433
|
}
|
|
3642
|
-
let
|
|
3434
|
+
let o = this.dom.cloneNode(!0);
|
|
3643
3435
|
try {
|
|
3644
3436
|
let e = this.dom.getBoundingClientRect();
|
|
3645
|
-
|
|
3437
|
+
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
3438
|
} catch {}
|
|
3647
|
-
let
|
|
3439
|
+
let s = null;
|
|
3648
3440
|
try {
|
|
3649
|
-
|
|
3441
|
+
var c;
|
|
3442
|
+
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
3443
|
} finally {
|
|
3651
|
-
|
|
3444
|
+
s && setTimeout(() => {
|
|
3652
3445
|
try {
|
|
3653
|
-
|
|
3446
|
+
s?.remove();
|
|
3654
3447
|
} catch {}
|
|
3655
3448
|
}, 0);
|
|
3656
3449
|
}
|
|
3657
3450
|
let l = this.getPos();
|
|
3658
3451
|
if (typeof l != "number") return;
|
|
3659
|
-
let u =
|
|
3660
|
-
|
|
3452
|
+
let u = S.create(t.state.doc, l), d = t.state.tr.setSelection(u);
|
|
3453
|
+
t.dispatch(d);
|
|
3661
3454
|
}
|
|
3662
3455
|
stopEvent(e) {
|
|
3663
3456
|
if (!this.dom) return !1;
|
|
3664
3457
|
if (typeof this.options.stopEvent == "function") return this.options.stopEvent({ event: e });
|
|
3665
3458
|
let t = e.target;
|
|
3666
|
-
if (!
|
|
3459
|
+
if (!this.dom.contains(t) || this.contentDOM?.contains(t)) return !1;
|
|
3667
3460
|
let n = e.type.startsWith("drag"), r = e.type === "dragover" || e.type === "dragenter", i = e.type === "drop";
|
|
3668
3461
|
if (([
|
|
3669
3462
|
"INPUT",
|
|
@@ -3671,7 +3464,7 @@ var ui = (e) => "touches" in e, di = class {
|
|
|
3671
3464
|
"SELECT",
|
|
3672
3465
|
"TEXTAREA"
|
|
3673
3466
|
].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 =
|
|
3467
|
+
let { isEditable: a } = this.editor, { isDragging: o } = this, s = !!this.node.type.spec.draggable, c = S.isSelectable(this.node), l = e.type === "copy", u = e.type === "paste", d = e.type === "cut", f = e.type === "mousedown";
|
|
3675
3468
|
if (!s && c && n && e.target === this.dom && e.preventDefault(), s && n && !o && e.target === this.dom) return e.preventDefault(), !1;
|
|
3676
3469
|
if (s && a && !o && f) {
|
|
3677
3470
|
let e = t.closest("[data-drag-handle]");
|
|
@@ -3686,7 +3479,7 @@ var ui = (e) => "touches" in e, di = class {
|
|
|
3686
3479
|
return !(o || r || i || l || u || d || f && c);
|
|
3687
3480
|
}
|
|
3688
3481
|
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.
|
|
3482
|
+
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.contentDOM.contains(e.target) && e.type === "childList" && (I() || Be()) && 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
3483
|
}
|
|
3691
3484
|
updateAttributes(e) {
|
|
3692
3485
|
this.editor.commands.command(({ tr: t }) => {
|
|
@@ -3707,11 +3500,11 @@ var ui = (e) => "touches" in e, di = class {
|
|
|
3707
3500
|
});
|
|
3708
3501
|
}
|
|
3709
3502
|
};
|
|
3710
|
-
function
|
|
3711
|
-
return new
|
|
3503
|
+
function ci(e) {
|
|
3504
|
+
return new Ar({
|
|
3712
3505
|
find: e.find,
|
|
3713
3506
|
handler: ({ state: t, range: n, match: r, pasteEvent: i }) => {
|
|
3714
|
-
let a =
|
|
3507
|
+
let a = H(e.getAttributes, void 0, r, i);
|
|
3715
3508
|
if (a === !1 || a === null) return null;
|
|
3716
3509
|
let { tr: o } = t, s = r[r.length - 1], c = r[0], l = n.to;
|
|
3717
3510
|
if (s) {
|
|
@@ -3723,4 +3516,4 @@ function mi(e) {
|
|
|
3723
3516
|
});
|
|
3724
3517
|
}
|
|
3725
3518
|
//#endregion
|
|
3726
|
-
export { z as A,
|
|
3519
|
+
export { z as A, Sr as B, W as C, an as D, Kt as E, ci as F, ti as H, It as I, ei as L, ln as M, Re as N, on as O, $r as P, yr as R, en as S, Gt as T, ri as U, ni as V, V as _, oi as a, $t as b, ai as c, Tt as d, mr as f, Zt as g, Jt as h, kr as i, J as j, gr as k, H as l, Dt as m, $ as n, si as o, Et as p, Q as r, Ar as s, Qr as t, fr as u, N as v, hr as w, j as x, Qt as y, pn as z };
|