@clevertask/scribe 0.1.24 → 0.1.25
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 +48 -0
- package/dist/{BarMenu-DW95OBe1.js → BarMenu-CP5BJhc-.js} +1 -1
- package/dist/components/Menu/BarMenu.js +1 -1
- package/dist/components/Menu/BubbleMenu.js +2 -2
- package/dist/components/Menu/CalloutBubbleMenu.js +2 -2
- package/dist/components/Menu/LinkBubbleMenu.js +2 -2
- package/dist/components/Menu/Mobile/ListOptionBar.js +1 -1
- package/dist/components/Menu/TableBubbleMenu.js +2 -2
- package/dist/components/Menu/linkBubbleMenuPlugin.js +1 -1
- package/dist/components/Scribe/extension/callout.js +1 -1
- package/dist/components/Scribe/extension/emoji/suggest.js +1 -1
- package/dist/components/Scribe/extension/extension-link.js +1 -1
- package/dist/components/Scribe/extension/extension-markdown-paste.js +1 -1
- package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
- package/dist/components/Scribe/extension/external-link-preview/commands.js +1 -1
- package/dist/components/Scribe/extension/external-link-preview/index.js +1 -1
- package/dist/components/Scribe/extension/external-link-preview/node-view.js +1 -1
- package/dist/components/Scribe/extension/external-link-preview/render-html.js +1 -1
- package/dist/components/Scribe/extension/external-link-preview/schema.js +1 -1
- package/dist/components/Scribe/extension/index.js +1 -1
- package/dist/components/Scribe/extension/resizable-table.d.ts +2 -0
- package/dist/components/Scribe/extension/resizable-table.d.ts.map +1 -1
- package/dist/components/Scribe/extension/resizable-table.js +2 -2
- package/dist/components/Scribe/extension/slashCommand/index.js +2 -2
- package/dist/components/Scribe/extension/slashCommand/items.d.ts.map +1 -1
- package/dist/components/Scribe/extension/slashCommand/items.js +35 -33
- package/dist/components/Scribe/extension/slashCommand/renderItems.js +1 -1
- package/dist/components/Scribe/extension/tableOfContents.js +1 -1
- package/dist/components/Scribe/index.js +3 -3
- package/dist/{dist-_L8dTDsy.js → dist-Cwbl2Okw.js} +1 -1
- package/dist/{dist-Cer8ra_P.js → dist-Dk0fXvrc.js} +1 -1
- package/dist/{dist-ClNucvAM.js → dist-xjmWZ-oh.js} +785 -785
- package/dist/{extension-B7i7CZ1Y.js → extension-9Oc-QD39.js} +1 -1
- package/dist/{extension-link-BQrkQZHi.js → extension-link-DmM_EJTn.js} +1 -1
- package/dist/{menus-BhM4ctz2.js → menus-B0uyLVhs.js} +2 -2
- package/dist/{resizable-table-DgMCiXeO.js → resizable-table-JZOaj_L3.js} +88 -78
- package/dist/{schema-extensions-ggKYCkRf.js → schema-extensions-LzyMpyWW.js} +4 -4
- package/dist/schema-extensions.js +1 -1
- package/dist/schema.d.ts +1 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +5 -4
- package/dist/table-transforms.d.ts +58 -0
- package/dist/table-transforms.d.ts.map +1 -0
- package/dist/table-transforms.js +166 -0
- package/dist/utils/index.js +2 -2
- package/package.json +1 -1
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { DOMParser as
|
|
5
|
-
import { liftListItem as
|
|
6
|
-
import { DecorationSet as
|
|
7
|
-
import { keymap as
|
|
1
|
+
import { AllSelection as e, EditorState as t, NodeSelection as n, Plugin as r, PluginKey as i, Selection as a, TextSelection as o } from "@tiptap/pm/state";
|
|
2
|
+
import { RemoveMarkStep as s, ReplaceAroundStep as c, ReplaceStep as l, Transform as u, canJoin as d, canSplit as f, findWrapping as p, joinPoint as m, liftTarget as h } from "@tiptap/pm/transform";
|
|
3
|
+
import { createParagraphNear as g, exitCode as _, joinBackward as ee, joinDown as v, joinForward as te, joinTextblockBackward as y, joinTextblockForward as ne, joinUp as re, lift as b, liftEmptyBlock as ie, newlineInCode as x, selectNodeBackward as ae, selectNodeForward as oe, selectParentNode as se, selectTextblockEnd as ce, selectTextblockStart as le, setBlockType as ue, wrapIn as de } from "@tiptap/pm/commands";
|
|
4
|
+
import { DOMParser as fe, DOMSerializer as pe, Fragment as S, Schema as me, Slice as he } from "@tiptap/pm/model";
|
|
5
|
+
import { liftListItem as ge, sinkListItem as _e, wrapInList as ve } from "@tiptap/pm/schema-list";
|
|
6
|
+
import { DecorationSet as C, EditorView as ye } from "@tiptap/pm/view";
|
|
7
|
+
import { keymap as be } from "@tiptap/pm/keymap";
|
|
8
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
|
|
9
|
+
var xe = Object.defineProperty, Se = (e, t) => {
|
|
10
10
|
let n = {};
|
|
11
|
-
for (var r in e)
|
|
11
|
+
for (var r in e) xe(n, r, {
|
|
12
12
|
get: e[r],
|
|
13
13
|
enumerable: !0
|
|
14
14
|
});
|
|
15
|
-
return t ||
|
|
15
|
+
return t || xe(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
16
16
|
};
|
|
17
17
|
//#endregion
|
|
18
18
|
//#region node_modules/.pnpm/@tiptap+core@3.31.3_@tiptap+pm@3.31.3/node_modules/@tiptap/core/dist/index.js
|
|
19
|
-
function
|
|
19
|
+
function w(e) {
|
|
20
20
|
let { state: t, transaction: n } = e, { selection: r } = n, { doc: i } = n, { storedMarks: a } = n;
|
|
21
21
|
return {
|
|
22
22
|
...t,
|
|
@@ -40,7 +40,7 @@ function k(e) {
|
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
var
|
|
43
|
+
var T = class e {
|
|
44
44
|
constructor(e) {
|
|
45
45
|
this.editor = e.editor, this.rawCommands = this.editor.extensionManager.commands, this.customState = e.state;
|
|
46
46
|
}
|
|
@@ -100,7 +100,7 @@ var A = class e {
|
|
|
100
100
|
tr: e,
|
|
101
101
|
editor: r,
|
|
102
102
|
view: a,
|
|
103
|
-
state:
|
|
103
|
+
state: w({
|
|
104
104
|
state: i,
|
|
105
105
|
transaction: e
|
|
106
106
|
}),
|
|
@@ -113,32 +113,32 @@ var A = class e {
|
|
|
113
113
|
};
|
|
114
114
|
return o;
|
|
115
115
|
}
|
|
116
|
-
},
|
|
116
|
+
}, Ce = () => ({ editor: e, view: t }) => (requestAnimationFrame(() => {
|
|
117
117
|
if (!e.isDestroyed) {
|
|
118
118
|
var n;
|
|
119
119
|
t.dom.blur(), (n = window) == null || (n = n.getSelection()) == null || n.removeAllRanges();
|
|
120
120
|
}
|
|
121
|
-
}), !0),
|
|
121
|
+
}), !0), we = (e = !0) => ({ commands: t }) => t.setContent("", { emitUpdate: e }), Te = () => ({ state: e, tr: t, dispatch: n }) => {
|
|
122
122
|
let { selection: r } = t, { ranges: i } = r;
|
|
123
123
|
return n && i.forEach(({ $from: n, $to: r }) => {
|
|
124
124
|
e.doc.nodesBetween(n.pos, r.pos, (e, n) => {
|
|
125
125
|
if (e.type.isText) return;
|
|
126
126
|
let { doc: r, mapping: i } = t, a = r.resolve(i.map(n)), o = r.resolve(i.map(n + e.nodeSize)), s = a.blockRange(o);
|
|
127
127
|
if (!s) return;
|
|
128
|
-
let
|
|
128
|
+
let c = h(s);
|
|
129
129
|
if (e.type.isTextblock) {
|
|
130
130
|
let { defaultType: e } = a.parent.contentMatchAt(a.index());
|
|
131
131
|
t.setNodeMarkup(s.start, e);
|
|
132
132
|
}
|
|
133
|
-
(
|
|
133
|
+
(c || c === 0) && t.lift(s, c);
|
|
134
134
|
});
|
|
135
135
|
}), !0;
|
|
136
|
-
},
|
|
136
|
+
}, Ee = (e) => (t) => e(t), De = () => ({ state: e, dispatch: t }) => g(e, t), Oe = (e, t) => ({ editor: n, tr: r }) => {
|
|
137
137
|
let { state: i } = n, a = i.doc.slice(e.from, e.to);
|
|
138
138
|
r.deleteRange(e.from, e.to);
|
|
139
|
-
let
|
|
140
|
-
return r.insert(
|
|
141
|
-
},
|
|
139
|
+
let s = r.mapping.map(t);
|
|
140
|
+
return r.insert(s, a.content), r.setSelection(new o(r.doc.resolve(Math.max(s - 1, 0)))), !0;
|
|
141
|
+
}, ke = () => ({ tr: e, dispatch: t }) => {
|
|
142
142
|
let { selection: n } = e, r = n.$anchor.node();
|
|
143
143
|
if (r.content.size > 0) return !1;
|
|
144
144
|
let i = e.selection.$anchor;
|
|
@@ -151,15 +151,15 @@ var A = class e {
|
|
|
151
151
|
}
|
|
152
152
|
return !1;
|
|
153
153
|
};
|
|
154
|
-
function
|
|
154
|
+
function E(e, t) {
|
|
155
155
|
if (typeof e == "string") {
|
|
156
156
|
if (!t.nodes[e]) throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);
|
|
157
157
|
return t.nodes[e];
|
|
158
158
|
}
|
|
159
159
|
return e;
|
|
160
160
|
}
|
|
161
|
-
var
|
|
162
|
-
let i =
|
|
161
|
+
var Ae = (e) => ({ tr: t, state: n, dispatch: r }) => {
|
|
162
|
+
let i = E(e, n.schema), a = t.selection.$anchor;
|
|
163
163
|
for (let e = a.depth; e > 0; --e) if (a.node(e).type === i) {
|
|
164
164
|
if (r) {
|
|
165
165
|
let n = a.before(e), r = a.after(e);
|
|
@@ -168,41 +168,41 @@ var Te = (e) => ({ tr: t, state: n, dispatch: r }) => {
|
|
|
168
168
|
return !0;
|
|
169
169
|
}
|
|
170
170
|
return !1;
|
|
171
|
-
},
|
|
171
|
+
}, je = (e) => ({ tr: t, dispatch: n }) => {
|
|
172
172
|
let { from: r, to: i } = e;
|
|
173
173
|
return n && t.delete(r, i), !0;
|
|
174
|
-
},
|
|
174
|
+
}, Me = (e) => e.content ? /^text(\*|\+)/.test(e.content) : !1, Ne = (e, t, n) => {
|
|
175
175
|
if (!e.parent.isInline || n === "left" && e.pos > e.start() || n === "right" && e.pos < e.end()) return e.pos;
|
|
176
176
|
let r = t.nodes[e.parent.type.name].spec;
|
|
177
|
-
return
|
|
178
|
-
},
|
|
179
|
-
from:
|
|
180
|
-
to:
|
|
181
|
-
}),
|
|
177
|
+
return Me(r) ? n === "left" ? e.start() - 1 : e.end() + 1 : e.pos;
|
|
178
|
+
}, Pe = (e, t, n) => ({
|
|
179
|
+
from: Ne(e, n, "left"),
|
|
180
|
+
to: Ne(t, n, "right")
|
|
181
|
+
}), Fe = () => ({ state: e, dispatch: t }) => {
|
|
182
182
|
if (e.selection.empty) return !1;
|
|
183
183
|
if (t) {
|
|
184
184
|
let n = e.tr, { ranges: r } = e.selection, i = n.steps.length;
|
|
185
185
|
r.forEach((t) => {
|
|
186
|
-
let r = n.mapping.slice(i), { from: a, to: o } =
|
|
186
|
+
let r = n.mapping.slice(i), { from: a, to: o } = Pe(n.doc.resolve(r.map(t.$from.pos)), n.doc.resolve(r.map(t.$to.pos)), e.schema);
|
|
187
187
|
n.deleteRange(a, o);
|
|
188
|
-
}), n.selection.empty || n.setSelection(
|
|
188
|
+
}), n.selection.empty || n.setSelection(o.near(n.doc.resolve(n.selection.from))), n.scrollIntoView(), t(n);
|
|
189
189
|
}
|
|
190
190
|
return !0;
|
|
191
|
-
},
|
|
192
|
-
function
|
|
191
|
+
}, Ie = () => ({ commands: e }) => e.keyboardShortcut("Enter"), Le = () => ({ state: e, dispatch: t }) => _(e, t);
|
|
192
|
+
function Re(e) {
|
|
193
193
|
return Object.prototype.toString.call(e) === "[object RegExp]";
|
|
194
194
|
}
|
|
195
|
-
function
|
|
195
|
+
function D(e, t, n = { strict: !0 }) {
|
|
196
196
|
let r = Object.keys(t);
|
|
197
|
-
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] : Re(t[r]) ? t[r].test(e[r]) : t[r] === e[r]);
|
|
198
198
|
}
|
|
199
|
-
function
|
|
200
|
-
return e.find((e) => e.type === t &&
|
|
199
|
+
function ze(e, t, n = {}) {
|
|
200
|
+
return e.find((e) => e.type === t && D(Object.fromEntries(Object.keys(n).map((t) => [t, e.attrs[t]])), n));
|
|
201
201
|
}
|
|
202
|
-
function
|
|
203
|
-
return !!
|
|
202
|
+
function Be(e, t, n = {}) {
|
|
203
|
+
return !!ze(e, t, n);
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function O(e, t, n) {
|
|
206
206
|
if (!e || !t) return;
|
|
207
207
|
let r = e.parent.childAfter(e.parentOffset);
|
|
208
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;
|
|
@@ -210,55 +210,55 @@ function N(e, t, n) {
|
|
|
210
210
|
let e = r.node.marks.find((e) => e.type === t);
|
|
211
211
|
e && (n = e.attrs);
|
|
212
212
|
}
|
|
213
|
-
if (!
|
|
213
|
+
if (!ze([...r.node.marks], t, n)) return;
|
|
214
214
|
let i = r.index, a = e.start() + r.offset, o = i + 1, s = a + r.node.nodeSize;
|
|
215
|
-
for (; i > 0 &&
|
|
216
|
-
for (; o < e.parent.childCount &&
|
|
215
|
+
for (; i > 0 && Be([...e.parent.child(i - 1).marks], t, n);) --i, a -= e.parent.child(i).nodeSize;
|
|
216
|
+
for (; o < e.parent.childCount && Be([...e.parent.child(o).marks], t, n);) s += e.parent.child(o).nodeSize, o += 1;
|
|
217
217
|
return {
|
|
218
218
|
from: a,
|
|
219
219
|
to: s
|
|
220
220
|
};
|
|
221
221
|
}
|
|
222
|
-
function
|
|
222
|
+
function k(e, t) {
|
|
223
223
|
if (typeof e == "string") {
|
|
224
224
|
if (!t.marks[e]) throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);
|
|
225
225
|
return t.marks[e];
|
|
226
226
|
}
|
|
227
227
|
return e;
|
|
228
228
|
}
|
|
229
|
-
var
|
|
230
|
-
let a =
|
|
229
|
+
var Ve = (e, t) => ({ tr: n, state: r, dispatch: i }) => {
|
|
230
|
+
let a = k(e, r.schema), { doc: s, selection: c } = n, { $from: l, from: u, to: d } = c;
|
|
231
231
|
if (i) {
|
|
232
|
-
let e =
|
|
233
|
-
if (e && e.from <=
|
|
234
|
-
let t =
|
|
232
|
+
let e = O(l, a, t);
|
|
233
|
+
if (e && e.from <= u && e.to >= d) {
|
|
234
|
+
let t = o.create(s, e.from, e.to);
|
|
235
235
|
n.setSelection(t);
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
return !0;
|
|
239
|
-
},
|
|
239
|
+
}, He = (e) => (t) => {
|
|
240
240
|
let n = typeof e == "function" ? e(t) : e;
|
|
241
241
|
for (let e = 0; e < n.length; e += 1) if (n[e](t)) return !0;
|
|
242
242
|
return !1;
|
|
243
243
|
};
|
|
244
|
-
function
|
|
245
|
-
return e instanceof
|
|
244
|
+
function Ue(e) {
|
|
245
|
+
return e instanceof o;
|
|
246
246
|
}
|
|
247
|
-
function
|
|
247
|
+
function A(e = 0, t = 0, n = 0) {
|
|
248
248
|
return Math.min(Math.max(e, t), n);
|
|
249
249
|
}
|
|
250
|
-
function
|
|
250
|
+
function We(e, t = null) {
|
|
251
251
|
if (!t) return null;
|
|
252
|
-
let n =
|
|
252
|
+
let n = a.atStart(e), r = a.atEnd(e);
|
|
253
253
|
if (t === "start" || t === !0) return n;
|
|
254
254
|
if (t === "end") return r;
|
|
255
|
-
let i = n.from,
|
|
256
|
-
return t === "all" ?
|
|
255
|
+
let i = n.from, s = r.to;
|
|
256
|
+
return t === "all" ? o.create(e, A(0, i, s), A(e.content.size, i, s)) : o.create(e, A(t, i, s), A(t, i, s));
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function Ge() {
|
|
259
259
|
return ["Android"].includes(navigator.platform) || /android/i.test(navigator.userAgent);
|
|
260
260
|
}
|
|
261
|
-
function
|
|
261
|
+
function j() {
|
|
262
262
|
return [
|
|
263
263
|
"iPad Simulator",
|
|
264
264
|
"iPhone Simulator",
|
|
@@ -268,16 +268,16 @@ function I() {
|
|
|
268
268
|
"iPod"
|
|
269
269
|
].includes(navigator.platform) || navigator.userAgent.includes("Mac") && "ontouchend" in document;
|
|
270
270
|
}
|
|
271
|
-
function
|
|
271
|
+
function Ke() {
|
|
272
272
|
return typeof navigator < "u" && /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
273
273
|
}
|
|
274
|
-
var
|
|
274
|
+
var qe = (e = null, t = {}) => ({ editor: n, view: r, tr: i, dispatch: a }) => {
|
|
275
275
|
t = {
|
|
276
276
|
scrollIntoView: !0,
|
|
277
277
|
...t
|
|
278
278
|
};
|
|
279
279
|
let o = () => {
|
|
280
|
-
(
|
|
280
|
+
(j() || Ge()) && r.dom.focus(), Ke() && !j() && !Ge() && r.dom.focus({ preventScroll: !0 }), requestAnimationFrame(() => {
|
|
281
281
|
n.isDestroyed || (r.focus(), t?.scrollIntoView && n.commands.scrollIntoView());
|
|
282
282
|
});
|
|
283
283
|
};
|
|
@@ -286,33 +286,33 @@ var He = (e = null, t = {}) => ({ editor: n, view: r, tr: i, dispatch: a }) => {
|
|
|
286
286
|
} catch {
|
|
287
287
|
return !1;
|
|
288
288
|
}
|
|
289
|
-
if (a && e === null && !
|
|
290
|
-
let s =
|
|
289
|
+
if (a && e === null && !Ue(n.state.selection)) return o(), !0;
|
|
290
|
+
let s = We(i.doc, e) || n.state.selection, c = n.state.selection.eq(s);
|
|
291
291
|
return a && (c || i.setSelection(s), c && i.storedMarks && i.setStoredMarks(i.storedMarks), o()), !0;
|
|
292
|
-
},
|
|
292
|
+
}, Je = (e, t) => (n) => e.every((e, r) => t(e, {
|
|
293
293
|
...n,
|
|
294
294
|
index: r
|
|
295
|
-
})),
|
|
295
|
+
})), Ye = (e, t) => ({ tr: n, commands: r }) => r.insertContentAt({
|
|
296
296
|
from: n.selection.from,
|
|
297
297
|
to: n.selection.to
|
|
298
|
-
}, e, t),
|
|
298
|
+
}, e, t), Xe = (e) => {
|
|
299
299
|
let t = e.childNodes;
|
|
300
300
|
for (let n = t.length - 1; n >= 0; --n) {
|
|
301
301
|
let r = t[n];
|
|
302
|
-
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 && Xe(r);
|
|
303
303
|
}
|
|
304
304
|
return e;
|
|
305
305
|
};
|
|
306
|
-
function
|
|
306
|
+
function M(e) {
|
|
307
307
|
if (typeof window > "u") throw Error("[tiptap error]: there is no window object available, so this function cannot be used");
|
|
308
308
|
let t = `<body>${e}</body>`, n = new window.DOMParser().parseFromString(t, "text/html").body;
|
|
309
|
-
return
|
|
309
|
+
return Xe(n);
|
|
310
310
|
}
|
|
311
|
-
function
|
|
311
|
+
function Ze(e) {
|
|
312
312
|
return typeof e?.nodesBetween == "function";
|
|
313
313
|
}
|
|
314
|
-
function
|
|
315
|
-
if (
|
|
314
|
+
function N(e, t, n) {
|
|
315
|
+
if (Ze(e)) return e;
|
|
316
316
|
let r = typeof e == "object" && !!e;
|
|
317
317
|
n = {
|
|
318
318
|
slice: !0,
|
|
@@ -321,16 +321,16 @@ function R(e, t, n) {
|
|
|
321
321
|
};
|
|
322
322
|
let i = typeof e == "string";
|
|
323
323
|
if (r) try {
|
|
324
|
-
if (Array.isArray(e) && e.length > 0) return
|
|
324
|
+
if (Array.isArray(e) && e.length > 0) return S.fromArray(e.map((e) => t.nodeFromJSON(e)));
|
|
325
325
|
let r = t.nodeFromJSON(e);
|
|
326
326
|
return n.errorOnInvalidContent && r.check(), r;
|
|
327
327
|
} catch (r) {
|
|
328
328
|
if (n.errorOnInvalidContent) throw Error("[tiptap error]: Invalid JSON content", { cause: r });
|
|
329
|
-
return console.warn("[tiptap warn]: Invalid content.", "Passed value:", e, "Error:", r),
|
|
329
|
+
return console.warn("[tiptap warn]: Invalid content.", "Passed value:", e, "Error:", r), N("", t, n);
|
|
330
330
|
}
|
|
331
331
|
if (i) {
|
|
332
332
|
if (n.errorOnInvalidContent) {
|
|
333
|
-
let r = !1, i = "", a = new
|
|
333
|
+
let r = !1, i = "", a = new me({
|
|
334
334
|
topNode: t.spec.topNode,
|
|
335
335
|
marks: t.spec.marks,
|
|
336
336
|
nodes: t.spec.nodes.append({ __tiptap__private__unknown__catch__all__node: {
|
|
@@ -342,27 +342,27 @@ function R(e, t, n) {
|
|
|
342
342
|
}]
|
|
343
343
|
} })
|
|
344
344
|
});
|
|
345
|
-
if (n.slice ?
|
|
345
|
+
if (n.slice ? fe.fromSchema(a).parseSlice(M(e), n.parseOptions) : fe.fromSchema(a).parse(M(e), n.parseOptions), n.errorOnInvalidContent && r) throw Error("[tiptap error]: Invalid HTML content", { cause: /* @__PURE__ */ Error(`Invalid element found: ${i}`) });
|
|
346
346
|
}
|
|
347
|
-
let r =
|
|
348
|
-
return n.slice ? r.parseSlice(
|
|
347
|
+
let r = fe.fromSchema(t);
|
|
348
|
+
return n.slice ? r.parseSlice(M(e), n.parseOptions).content : r.parse(M(e), n.parseOptions);
|
|
349
349
|
}
|
|
350
|
-
return
|
|
350
|
+
return N("", t, n);
|
|
351
351
|
}
|
|
352
|
-
function
|
|
352
|
+
function Qe(e) {
|
|
353
353
|
return !("type" in e);
|
|
354
354
|
}
|
|
355
|
-
function
|
|
356
|
-
let
|
|
357
|
-
if (
|
|
358
|
-
let
|
|
359
|
-
if (!(
|
|
360
|
-
let
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
}), e.setSelection(
|
|
364
|
-
}
|
|
365
|
-
var
|
|
355
|
+
function $e(e, t, n) {
|
|
356
|
+
let r = e.steps.length - 1;
|
|
357
|
+
if (r < t) return;
|
|
358
|
+
let i = e.steps[r];
|
|
359
|
+
if (!(i instanceof l || i instanceof c)) return;
|
|
360
|
+
let o = e.mapping.maps[r], s = 0;
|
|
361
|
+
o.forEach((e, t, n, r) => {
|
|
362
|
+
s === 0 && (s = r);
|
|
363
|
+
}), e.setSelection(a.near(e.doc.resolve(s), n));
|
|
364
|
+
}
|
|
365
|
+
var et = (e, t, n) => ({ tr: r, dispatch: i, editor: a }) => {
|
|
366
366
|
if (i) {
|
|
367
367
|
n = {
|
|
368
368
|
parseOptions: a.options.parseOptions,
|
|
@@ -384,7 +384,7 @@ var Ye = (e, t, n) => ({ tr: r, dispatch: i, editor: a }) => {
|
|
|
384
384
|
...n.parseOptions
|
|
385
385
|
};
|
|
386
386
|
if (!n.errorOnInvalidContent && !a.options.enableContentCheck && a.options.emitContentError) try {
|
|
387
|
-
|
|
387
|
+
N(t, a.schema, {
|
|
388
388
|
parseOptions: s,
|
|
389
389
|
errorOnInvalidContent: !0
|
|
390
390
|
});
|
|
@@ -392,7 +392,7 @@ var Ye = (e, t, n) => ({ tr: r, dispatch: i, editor: a }) => {
|
|
|
392
392
|
o(e);
|
|
393
393
|
}
|
|
394
394
|
try {
|
|
395
|
-
i =
|
|
395
|
+
i = N(t, a.schema, {
|
|
396
396
|
parseOptions: s,
|
|
397
397
|
errorOnInvalidContent: n.errorOnInvalidContent ?? a.options.enableContentCheck
|
|
398
398
|
});
|
|
@@ -405,7 +405,7 @@ var Ye = (e, t, n) => ({ tr: r, dispatch: i, editor: a }) => {
|
|
|
405
405
|
} : {
|
|
406
406
|
from: e.from,
|
|
407
407
|
to: e.to
|
|
408
|
-
}, u = !0, d = !0, f =
|
|
408
|
+
}, u = !0, d = !0, f = Qe(i) ? i.content : [i];
|
|
409
409
|
if (f.forEach((e) => {
|
|
410
410
|
e.check(), u = u ? e.isText && e.marks.length === 0 : !1, d = d ? e.isBlock : !1;
|
|
411
411
|
}), c === l && d) {
|
|
@@ -413,13 +413,13 @@ var Ye = (e, t, n) => ({ tr: r, dispatch: i, editor: a }) => {
|
|
|
413
413
|
e.isTextblock && !e.type.spec.code && !e.childCount && (--c, l += 1);
|
|
414
414
|
}
|
|
415
415
|
let p;
|
|
416
|
-
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("") : Ze(t) ? f.map((e) => e.text ?? "").join("") : typeof t == "object" && t && t.text ? t.text : t, r.insertText(p, c, l);
|
|
417
417
|
else {
|
|
418
|
-
p =
|
|
418
|
+
p = S.from(f);
|
|
419
419
|
let e = r.doc.resolve(c), t = e.node(), n = e.parentOffset === 0, i = t.isText || t.isTextblock, a = t.content.size > 0;
|
|
420
420
|
n && i && a && d && (c = Math.max(0, c - 1)), r.replaceWith(c, l, f);
|
|
421
421
|
}
|
|
422
|
-
n.updateSelection &&
|
|
422
|
+
n.updateSelection && $e(r, r.steps.length - 1, -1), n.applyInputRules && r.setMeta("applyInputRules", {
|
|
423
423
|
from: c,
|
|
424
424
|
text: p
|
|
425
425
|
}), n.applyPasteRules && r.setMeta("applyPasteRules", {
|
|
@@ -429,43 +429,43 @@ var Ye = (e, t, n) => ({ tr: r, dispatch: i, editor: a }) => {
|
|
|
429
429
|
}
|
|
430
430
|
return !0;
|
|
431
431
|
};
|
|
432
|
-
function
|
|
432
|
+
function tt(e) {
|
|
433
433
|
for (let t = 0; t < e.edgeCount; t += 1) {
|
|
434
434
|
let { type: n } = e.edge(t);
|
|
435
435
|
if (n.isTextblock && !n.hasRequiredAttrs()) return n;
|
|
436
436
|
}
|
|
437
437
|
return null;
|
|
438
438
|
}
|
|
439
|
-
var
|
|
439
|
+
var nt = (e = {}) => ({ tr: t, dispatch: n, editor: r }) => {
|
|
440
440
|
let { pos: i, attrs: a, content: o, updateSelection: s = !0 } = e, c;
|
|
441
441
|
c = typeof i == "number" ? t.doc.resolve(i) : i || t.selection.$from;
|
|
442
|
-
let l =
|
|
442
|
+
let l = tt(c.parent.contentMatchAt(c.index()));
|
|
443
443
|
if (!l) return !1;
|
|
444
444
|
let u = Object.keys(l.spec.attrs || {}), d = a ? Object.fromEntries(Object.entries(a).filter(([e]) => u.includes(e))) : {}, f;
|
|
445
445
|
if (o) {
|
|
446
|
-
let e =
|
|
446
|
+
let e = N(o, r.schema);
|
|
447
447
|
f = l.createAndFill(d, e);
|
|
448
448
|
} else f = l.createAndFill(d);
|
|
449
|
-
return f ? (n && (t.insert(c.pos, f), s &&
|
|
450
|
-
},
|
|
449
|
+
return f ? (n && (t.insert(c.pos, f), s && $e(t, t.steps.length - 1, -1)), !0) : !1;
|
|
450
|
+
}, rt = () => ({ state: e, dispatch: t }) => re(e, t), it = () => ({ state: e, dispatch: t }) => v(e, t), at = () => ({ state: e, dispatch: t }) => ee(e, t), ot = () => ({ state: e, dispatch: t }) => te(e, t), st = () => ({ state: e, dispatch: t, tr: n }) => {
|
|
451
451
|
try {
|
|
452
|
-
let r =
|
|
452
|
+
let r = m(e.doc, e.selection.$from.pos, -1);
|
|
453
453
|
return r != null && (n.join(r, 2), t && t(n), !0);
|
|
454
454
|
} catch {
|
|
455
455
|
return !1;
|
|
456
456
|
}
|
|
457
|
-
},
|
|
457
|
+
}, ct = () => ({ state: e, dispatch: t, tr: n }) => {
|
|
458
458
|
try {
|
|
459
|
-
let r =
|
|
459
|
+
let r = m(e.doc, e.selection.$from.pos, 1);
|
|
460
460
|
return r != null && (n.join(r, 2), t && t(n), !0);
|
|
461
461
|
} catch {
|
|
462
462
|
return !1;
|
|
463
463
|
}
|
|
464
|
-
},
|
|
465
|
-
function
|
|
464
|
+
}, lt = () => ({ state: e, dispatch: t }) => y(e, t), ut = () => ({ state: e, dispatch: t }) => ne(e, t);
|
|
465
|
+
function dt() {
|
|
466
466
|
return typeof navigator < "u" && /Mac/.test(navigator.platform);
|
|
467
467
|
}
|
|
468
|
-
function
|
|
468
|
+
function ft(e) {
|
|
469
469
|
let t = e.split(/-(?!$)/), n = t[t.length - 1];
|
|
470
470
|
n === "Space" && (n = " ");
|
|
471
471
|
let r, i, a, o;
|
|
@@ -475,13 +475,13 @@ function st(e) {
|
|
|
475
475
|
else if (/^a(lt)?$/i.test(n)) r = !0;
|
|
476
476
|
else if (/^(c|ctrl|control)$/i.test(n)) i = !0;
|
|
477
477
|
else if (/^s(hift)?$/i.test(n)) a = !0;
|
|
478
|
-
else if (/^mod$/i.test(n))
|
|
478
|
+
else if (/^mod$/i.test(n)) j() || dt() ? o = !0 : i = !0;
|
|
479
479
|
else throw Error(`Unrecognized modifier name: ${n}`);
|
|
480
480
|
}
|
|
481
481
|
return r && (n = `Alt-${n}`), i && (n = `Ctrl-${n}`), o && (n = `Meta-${n}`), a && (n = `Shift-${n}`), n;
|
|
482
482
|
}
|
|
483
|
-
var
|
|
484
|
-
let a =
|
|
483
|
+
var pt = (e) => ({ editor: t, view: n, tr: r, dispatch: i }) => {
|
|
484
|
+
let a = ft(e).split(/-(?!$)/), o = a.find((e) => ![
|
|
485
485
|
"Alt",
|
|
486
486
|
"Ctrl",
|
|
487
487
|
"Meta",
|
|
@@ -502,8 +502,8 @@ var ct = (e) => ({ editor: t, view: n, tr: r, dispatch: i }) => {
|
|
|
502
502
|
t && i && r.maybeStep(t);
|
|
503
503
|
}), !0;
|
|
504
504
|
};
|
|
505
|
-
function
|
|
506
|
-
let { from: r, to: i, empty: a } = e.selection, o = t ?
|
|
505
|
+
function P(e, t, n = {}) {
|
|
506
|
+
let { from: r, to: i, empty: a } = e.selection, o = t ? E(t, e.schema) : null, s = [];
|
|
507
507
|
e.doc.nodesBetween(r, i, (e, t) => {
|
|
508
508
|
if (e.isText) return;
|
|
509
509
|
let n = Math.max(r, t), a = Math.min(i, t + e.nodeSize);
|
|
@@ -513,52 +513,52 @@ function z(e, t, n = {}) {
|
|
|
513
513
|
to: a
|
|
514
514
|
});
|
|
515
515
|
});
|
|
516
|
-
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) => D(e.node.attrs, n, { strict: !1 }));
|
|
517
517
|
return a ? !!l.length : l.reduce((e, t) => e + t.to - t.from, 0) >= c;
|
|
518
518
|
}
|
|
519
|
-
var
|
|
520
|
-
let r =
|
|
521
|
-
return
|
|
522
|
-
},
|
|
523
|
-
function
|
|
519
|
+
var mt = (e, t = {}) => ({ state: n, dispatch: r }) => P(n, E(e, n.schema), t) ? b(n, r) : !1, ht = () => ({ state: e, dispatch: t }) => ie(e, t), gt = (e) => ({ state: t, dispatch: n }) => {
|
|
520
|
+
let r = E(e, t.schema);
|
|
521
|
+
return ge(r)(t, n);
|
|
522
|
+
}, _t = () => ({ state: e, dispatch: t }) => x(e, t);
|
|
523
|
+
function F(e, t) {
|
|
524
524
|
return t.nodes[e] ? "node" : t.marks[e] ? "mark" : null;
|
|
525
525
|
}
|
|
526
|
-
function
|
|
526
|
+
function vt(e, t) {
|
|
527
527
|
let n = typeof t == "string" ? [t] : t;
|
|
528
528
|
return Object.keys(e).reduce((t, r) => (n.includes(r) || (t[r] = e[r]), t), {});
|
|
529
529
|
}
|
|
530
|
-
var
|
|
531
|
-
let a = null, o = null, s =
|
|
530
|
+
var yt = (e, t) => ({ tr: n, state: r, dispatch: i }) => {
|
|
531
|
+
let a = null, o = null, s = F(typeof e == "string" ? e : e.name, r.schema);
|
|
532
532
|
if (!s) return !1;
|
|
533
|
-
s === "node" && (a =
|
|
533
|
+
s === "node" && (a = E(e, r.schema)), s === "mark" && (o = k(e, r.schema));
|
|
534
534
|
let c = !1;
|
|
535
535
|
return n.selection.ranges.forEach((e) => {
|
|
536
536
|
r.doc.nodesBetween(e.$from.pos, e.$to.pos, (e, r) => {
|
|
537
|
-
a && a === e.type && (c = !0, i && n.setNodeMarkup(r, void 0,
|
|
538
|
-
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, vt(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(vt(a.attrs, t))));
|
|
539
539
|
});
|
|
540
540
|
});
|
|
541
541
|
}), c;
|
|
542
|
-
},
|
|
543
|
-
if (
|
|
544
|
-
let
|
|
545
|
-
|
|
542
|
+
}, bt = () => ({ tr: e, dispatch: t }) => (t && e.scrollIntoView(), !0), xt = () => ({ tr: t, dispatch: n }) => {
|
|
543
|
+
if (n) {
|
|
544
|
+
let n = new e(t.doc);
|
|
545
|
+
t.setSelection(n);
|
|
546
546
|
}
|
|
547
547
|
return !0;
|
|
548
|
-
},
|
|
549
|
-
function
|
|
550
|
-
return
|
|
548
|
+
}, St = () => ({ state: e, dispatch: t }) => ae(e, t), Ct = () => ({ state: e, dispatch: t }) => oe(e, t), wt = () => ({ state: e, dispatch: t }) => se(e, t), Tt = () => ({ state: e, dispatch: t }) => ce(e, t), Et = () => ({ state: e, dispatch: t }) => le(e, t);
|
|
549
|
+
function Dt(e, t, n = {}, r = {}) {
|
|
550
|
+
return N(e, t, {
|
|
551
551
|
slice: !1,
|
|
552
552
|
parseOptions: n,
|
|
553
553
|
errorOnInvalidContent: r.errorOnInvalidContent
|
|
554
554
|
});
|
|
555
555
|
}
|
|
556
|
-
var
|
|
556
|
+
var Ot = (e, { errorOnInvalidContent: t, emitUpdate: n = !0, parseOptions: r = {} } = {}) => ({ editor: i, tr: a, dispatch: o, commands: s }) => {
|
|
557
557
|
let { doc: c } = a;
|
|
558
558
|
if (r.preserveWhitespace !== "full") {
|
|
559
|
-
let s =
|
|
559
|
+
let s = Dt(e, i.schema, r, { errorOnInvalidContent: t ?? i.options.enableContentCheck });
|
|
560
560
|
if (o) {
|
|
561
|
-
let e =
|
|
561
|
+
let e = Qe(s) ? s.content : [s];
|
|
562
562
|
a.replaceWith(0, c.content.size, e).setMeta("preventUpdate", !n);
|
|
563
563
|
}
|
|
564
564
|
return !0;
|
|
@@ -571,23 +571,23 @@ var Ct = (e, { errorOnInvalidContent: t, emitUpdate: n = !0, parseOptions: r = {
|
|
|
571
571
|
errorOnInvalidContent: t ?? i.options.enableContentCheck
|
|
572
572
|
});
|
|
573
573
|
};
|
|
574
|
-
function
|
|
575
|
-
let n =
|
|
574
|
+
function kt(e, t) {
|
|
575
|
+
let n = k(t, e.schema), { from: r, to: i, empty: a } = e.selection, o = [];
|
|
576
576
|
a ? (e.storedMarks && o.push(...e.storedMarks), o.push(...e.selection.$head.marks())) : e.doc.nodesBetween(r, i, (e) => {
|
|
577
577
|
o.push(...e.marks);
|
|
578
578
|
});
|
|
579
579
|
let s = o.find((e) => e.type.name === n.name);
|
|
580
580
|
return s ? { ...s.attrs } : {};
|
|
581
581
|
}
|
|
582
|
-
function
|
|
583
|
-
let n = new
|
|
582
|
+
function At(e, t) {
|
|
583
|
+
let n = new u(e);
|
|
584
584
|
return t.forEach((e) => {
|
|
585
585
|
e.steps.forEach((e) => {
|
|
586
586
|
n.step(e);
|
|
587
587
|
});
|
|
588
588
|
}), n;
|
|
589
589
|
}
|
|
590
|
-
function
|
|
590
|
+
function jt(e, t, n) {
|
|
591
591
|
let r = [];
|
|
592
592
|
return e.nodesBetween(t.from, t.to, (e, t) => {
|
|
593
593
|
n(e) && r.push({
|
|
@@ -596,7 +596,7 @@ function Et(e, t, n) {
|
|
|
596
596
|
});
|
|
597
597
|
}), r;
|
|
598
598
|
}
|
|
599
|
-
function
|
|
599
|
+
function Mt(e, t) {
|
|
600
600
|
for (let n = e.depth; n > 0; --n) {
|
|
601
601
|
let r = e.node(n);
|
|
602
602
|
if (t(r)) return {
|
|
@@ -607,47 +607,47 @@ function Dt(e, t) {
|
|
|
607
607
|
};
|
|
608
608
|
}
|
|
609
609
|
}
|
|
610
|
-
function
|
|
611
|
-
return (t) =>
|
|
610
|
+
function I(e) {
|
|
611
|
+
return (t) => Mt(t.$from, e);
|
|
612
612
|
}
|
|
613
|
-
function
|
|
614
|
-
return e.config[t] === void 0 && e.parent ?
|
|
613
|
+
function L(e, t, n) {
|
|
614
|
+
return e.config[t] === void 0 && e.parent ? L(e.parent, t, n) : typeof e.config[t] == "function" ? e.config[t].bind({
|
|
615
615
|
...n,
|
|
616
|
-
parent: e.parent ?
|
|
616
|
+
parent: e.parent ? L(e.parent, t, n) : null
|
|
617
617
|
}) : e.config[t];
|
|
618
618
|
}
|
|
619
|
-
function
|
|
619
|
+
function Nt(e) {
|
|
620
620
|
return e.map((e) => {
|
|
621
|
-
let t =
|
|
621
|
+
let t = L(e, "addExtensions", {
|
|
622
622
|
name: e.name,
|
|
623
623
|
options: e.options,
|
|
624
624
|
storage: e.storage
|
|
625
625
|
});
|
|
626
|
-
return t ? [e, ...
|
|
626
|
+
return t ? [e, ...Nt(t())] : e;
|
|
627
627
|
}).flat(10);
|
|
628
628
|
}
|
|
629
|
-
function
|
|
630
|
-
let n =
|
|
629
|
+
function Pt(e, t) {
|
|
630
|
+
let n = pe.fromSchema(t).serializeFragment(e), r = document.implementation.createHTMLDocument().createElement("div");
|
|
631
631
|
return r.appendChild(n), r.innerHTML;
|
|
632
632
|
}
|
|
633
|
-
function
|
|
633
|
+
function Ft(e) {
|
|
634
634
|
return typeof e == "function";
|
|
635
635
|
}
|
|
636
|
-
function
|
|
637
|
-
return
|
|
636
|
+
function R(e, t = void 0, ...n) {
|
|
637
|
+
return Ft(e) ? t ? e.bind(t)(...n) : e(...n) : e;
|
|
638
638
|
}
|
|
639
|
-
function
|
|
639
|
+
function It(e = {}) {
|
|
640
640
|
return Object.keys(e).length === 0 && e.constructor === Object;
|
|
641
641
|
}
|
|
642
|
-
function
|
|
642
|
+
function z(e) {
|
|
643
643
|
return {
|
|
644
644
|
baseExtensions: e.filter((e) => e.type === "extension"),
|
|
645
645
|
nodeExtensions: e.filter((e) => e.type === "node"),
|
|
646
646
|
markExtensions: e.filter((e) => e.type === "mark")
|
|
647
647
|
};
|
|
648
648
|
}
|
|
649
|
-
function
|
|
650
|
-
let t = [], { nodeExtensions: n, markExtensions: r } =
|
|
649
|
+
function Lt(e) {
|
|
650
|
+
let t = [], { nodeExtensions: n, markExtensions: r } = z(e), i = [...n, ...r], a = {
|
|
651
651
|
default: null,
|
|
652
652
|
validate: void 0,
|
|
653
653
|
rendered: !0,
|
|
@@ -657,7 +657,7 @@ function Nt(e) {
|
|
|
657
657
|
isRequired: !1
|
|
658
658
|
}, o = n.filter((e) => e.name !== "text").map((e) => e.name), s = r.map((e) => e.name), c = [...o, ...s];
|
|
659
659
|
return e.forEach((e) => {
|
|
660
|
-
let n =
|
|
660
|
+
let n = L(e, "addGlobalAttributes", {
|
|
661
661
|
name: e.name,
|
|
662
662
|
options: e.options,
|
|
663
663
|
storage: e.storage,
|
|
@@ -679,7 +679,7 @@ function Nt(e) {
|
|
|
679
679
|
});
|
|
680
680
|
});
|
|
681
681
|
}), i.forEach((e) => {
|
|
682
|
-
let n =
|
|
682
|
+
let n = L(e, "addAttributes", {
|
|
683
683
|
name: e.name,
|
|
684
684
|
options: e.options,
|
|
685
685
|
storage: e.storage
|
|
@@ -699,7 +699,7 @@ function Nt(e) {
|
|
|
699
699
|
});
|
|
700
700
|
}), t;
|
|
701
701
|
}
|
|
702
|
-
function
|
|
702
|
+
function Rt(e) {
|
|
703
703
|
let t = [], n = "", r = !1, i = !1, a = 0, o = e.length;
|
|
704
704
|
for (let s = 0; s < o; s += 1) {
|
|
705
705
|
let o = e[s];
|
|
@@ -729,8 +729,8 @@ function Pt(e) {
|
|
|
729
729
|
}
|
|
730
730
|
return n && t.push(n), t;
|
|
731
731
|
}
|
|
732
|
-
function
|
|
733
|
-
let t = [], n =
|
|
732
|
+
function zt(e) {
|
|
733
|
+
let t = [], n = Rt(e || ""), r = n.length;
|
|
734
734
|
for (let e = 0; e < r; e += 1) {
|
|
735
735
|
let r = n[e], i = r.indexOf(":");
|
|
736
736
|
if (i === -1) continue;
|
|
@@ -739,7 +739,7 @@ function Ft(e) {
|
|
|
739
739
|
}
|
|
740
740
|
return t;
|
|
741
741
|
}
|
|
742
|
-
function
|
|
742
|
+
function Bt(...e) {
|
|
743
743
|
return e.filter((e) => !!e).reduce((e, t) => {
|
|
744
744
|
let n = { ...e };
|
|
745
745
|
return Object.entries(t).forEach(([e, t]) => {
|
|
@@ -760,26 +760,26 @@ function It(...e) {
|
|
|
760
760
|
let r = t ? String(t).split(" ") : [], i = n[e] ? n[e].split(" ") : [], a = r.filter((e) => !i.includes(e));
|
|
761
761
|
n[e] = [...i, ...a].join(" ");
|
|
762
762
|
} else if (e === "style") {
|
|
763
|
-
let r = new Map([...
|
|
763
|
+
let r = new Map([...zt(n[e]), ...zt(t)]);
|
|
764
764
|
n[e] = Array.from(r.entries()).map(([e, t]) => `${e}: ${t}`).join("; ");
|
|
765
765
|
} else n[e] = t;
|
|
766
766
|
}), n;
|
|
767
767
|
}, {});
|
|
768
768
|
}
|
|
769
|
-
function
|
|
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) =>
|
|
769
|
+
function B(e, t) {
|
|
770
|
+
return t.filter((t) => t.type === e.type.name).filter((e) => e.attribute.rendered).map((t) => t.attribute.renderHTML ? t.attribute.renderHTML(e.attrs) || {} : { [t.name]: e.attrs[t.name] }).reduce((e, t) => Bt(e, t), {});
|
|
771
771
|
}
|
|
772
|
-
function
|
|
772
|
+
function Vt(e) {
|
|
773
773
|
return typeof e == "string" ? e.match(/^[+-]?(?:\d*\.)?\d+$/) ? Number(e) : e === "true" || e !== "false" && e : e;
|
|
774
774
|
}
|
|
775
|
-
function
|
|
775
|
+
function Ht(e, t) {
|
|
776
776
|
return "style" in e ? e : {
|
|
777
777
|
...e,
|
|
778
778
|
getAttrs: (n) => {
|
|
779
779
|
let r = e.getAttrs ? e.getAttrs(n) : e.attrs;
|
|
780
780
|
if (r === !1) return !1;
|
|
781
781
|
let i = t.reduce((e, t) => {
|
|
782
|
-
let r = t.attribute.parseHTML ? t.attribute.parseHTML(n) :
|
|
782
|
+
let r = t.attribute.parseHTML ? t.attribute.parseHTML(n) : Vt(n.getAttribute(t.name));
|
|
783
783
|
return r == null ? e : {
|
|
784
784
|
...e,
|
|
785
785
|
[t.name]: r
|
|
@@ -792,50 +792,50 @@ function Rt(e, t) {
|
|
|
792
792
|
}
|
|
793
793
|
};
|
|
794
794
|
}
|
|
795
|
-
function
|
|
796
|
-
return Object.fromEntries(Object.entries(e).filter(([e, t]) => e === "attrs" &&
|
|
795
|
+
function Ut(e) {
|
|
796
|
+
return Object.fromEntries(Object.entries(e).filter(([e, t]) => e === "attrs" && It(t) ? !1 : t != null));
|
|
797
797
|
}
|
|
798
|
-
function
|
|
798
|
+
function Wt(e) {
|
|
799
799
|
var t, n;
|
|
800
800
|
let r = {};
|
|
801
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];
|
|
802
802
|
}
|
|
803
|
-
function
|
|
804
|
-
let n =
|
|
803
|
+
function Gt(e, t) {
|
|
804
|
+
let n = Lt(e), { nodeExtensions: r, markExtensions: i } = z(e), a = r.find((e) => L(e, "topNode"))?.name, o = Object.fromEntries(r.map((r) => {
|
|
805
805
|
let i = n.filter((e) => e.type === r.name), a = {
|
|
806
806
|
name: r.name,
|
|
807
807
|
options: r.options,
|
|
808
808
|
storage: r.storage,
|
|
809
809
|
editor: t
|
|
810
|
-
}, o =
|
|
810
|
+
}, o = Ut({
|
|
811
811
|
...e.reduce((e, t) => {
|
|
812
|
-
let n =
|
|
812
|
+
let n = L(t, "extendNodeSchema", a);
|
|
813
813
|
return {
|
|
814
814
|
...e,
|
|
815
815
|
...n ? n(r) : {}
|
|
816
816
|
};
|
|
817
817
|
}, {}),
|
|
818
|
-
content:
|
|
819
|
-
marks:
|
|
820
|
-
group:
|
|
821
|
-
inline:
|
|
822
|
-
atom:
|
|
823
|
-
selectable:
|
|
824
|
-
draggable:
|
|
825
|
-
code:
|
|
826
|
-
whitespace:
|
|
827
|
-
linebreakReplacement:
|
|
828
|
-
defining:
|
|
829
|
-
isolating:
|
|
830
|
-
attrs: Object.fromEntries(i.map(
|
|
831
|
-
}), s =
|
|
832
|
-
s && (o.parseDOM = s.map((e) =>
|
|
833
|
-
let c =
|
|
818
|
+
content: R(L(r, "content", a)),
|
|
819
|
+
marks: R(L(r, "marks", a)),
|
|
820
|
+
group: R(L(r, "group", a)),
|
|
821
|
+
inline: R(L(r, "inline", a)),
|
|
822
|
+
atom: R(L(r, "atom", a)),
|
|
823
|
+
selectable: R(L(r, "selectable", a)),
|
|
824
|
+
draggable: R(L(r, "draggable", a)),
|
|
825
|
+
code: R(L(r, "code", a)),
|
|
826
|
+
whitespace: R(L(r, "whitespace", a)),
|
|
827
|
+
linebreakReplacement: R(L(r, "linebreakReplacement", a)),
|
|
828
|
+
defining: R(L(r, "defining", a)),
|
|
829
|
+
isolating: R(L(r, "isolating", a)),
|
|
830
|
+
attrs: Object.fromEntries(i.map(Wt))
|
|
831
|
+
}), s = R(L(r, "parseHTML", a));
|
|
832
|
+
s && (o.parseDOM = s.map((e) => Ht(e, i)));
|
|
833
|
+
let c = L(r, "renderHTML", a);
|
|
834
834
|
c && (o.toDOM = (e) => c({
|
|
835
835
|
node: e,
|
|
836
|
-
HTMLAttributes:
|
|
836
|
+
HTMLAttributes: B(e, i)
|
|
837
837
|
}));
|
|
838
|
-
let l =
|
|
838
|
+
let l = L(r, "renderText", a);
|
|
839
839
|
return l && (o.toText = l), [r.name, o];
|
|
840
840
|
})), s = Object.fromEntries(i.map((r) => {
|
|
841
841
|
let i = n.filter((e) => e.type === r.name), a = {
|
|
@@ -843,49 +843,49 @@ function Vt(e, t) {
|
|
|
843
843
|
options: r.options,
|
|
844
844
|
storage: r.storage,
|
|
845
845
|
editor: t
|
|
846
|
-
}, o =
|
|
846
|
+
}, o = Ut({
|
|
847
847
|
...e.reduce((e, t) => {
|
|
848
|
-
let n =
|
|
848
|
+
let n = L(t, "extendMarkSchema", a);
|
|
849
849
|
return {
|
|
850
850
|
...e,
|
|
851
851
|
...n ? n(r) : {}
|
|
852
852
|
};
|
|
853
853
|
}, {}),
|
|
854
|
-
inclusive:
|
|
855
|
-
excludes:
|
|
856
|
-
group:
|
|
857
|
-
spanning:
|
|
858
|
-
code:
|
|
859
|
-
attrs: Object.fromEntries(i.map(
|
|
860
|
-
}), s =
|
|
861
|
-
s && (o.parseDOM = s.map((e) =>
|
|
862
|
-
let c =
|
|
854
|
+
inclusive: R(L(r, "inclusive", a)),
|
|
855
|
+
excludes: R(L(r, "excludes", a)),
|
|
856
|
+
group: R(L(r, "group", a)),
|
|
857
|
+
spanning: R(L(r, "spanning", a)),
|
|
858
|
+
code: R(L(r, "code", a)),
|
|
859
|
+
attrs: Object.fromEntries(i.map(Wt))
|
|
860
|
+
}), s = R(L(r, "parseHTML", a));
|
|
861
|
+
s && (o.parseDOM = s.map((e) => Ht(e, i)));
|
|
862
|
+
let c = L(r, "renderHTML", a);
|
|
863
863
|
return c && (o.toDOM = (e) => c({
|
|
864
864
|
mark: e,
|
|
865
|
-
HTMLAttributes:
|
|
865
|
+
HTMLAttributes: B(e, i)
|
|
866
866
|
})), [r.name, o];
|
|
867
867
|
}));
|
|
868
|
-
return new
|
|
868
|
+
return new me({
|
|
869
869
|
topNode: a,
|
|
870
870
|
nodes: o,
|
|
871
871
|
marks: s
|
|
872
872
|
});
|
|
873
873
|
}
|
|
874
|
-
function
|
|
874
|
+
function Kt(e) {
|
|
875
875
|
let t = e.filter((t, n) => e.indexOf(t) !== n);
|
|
876
876
|
return Array.from(new Set(t));
|
|
877
877
|
}
|
|
878
|
-
function
|
|
878
|
+
function V(e) {
|
|
879
879
|
return e.sort((e, t) => {
|
|
880
|
-
let n =
|
|
880
|
+
let n = L(e, "priority") || 100, r = L(t, "priority") || 100;
|
|
881
881
|
return n > r ? -1 : +(n < r);
|
|
882
882
|
});
|
|
883
883
|
}
|
|
884
|
-
function
|
|
885
|
-
let t =
|
|
884
|
+
function qt(e) {
|
|
885
|
+
let t = V(Nt(e)), n = Kt(t.map((e) => e.name));
|
|
886
886
|
return n.length && console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map((e) => `'${e}'`).join(", ")}]. This can lead to issues.`), t;
|
|
887
887
|
}
|
|
888
|
-
function
|
|
888
|
+
function Jt(e, t, n) {
|
|
889
889
|
let { from: r, to: i } = t, { blockSeparator: a = "\n\n", textSerializers: o = {} } = n || {}, s = "";
|
|
890
890
|
return e.nodesBetween(r, i, (e, n, c, l) => {
|
|
891
891
|
e.isBlock && n > r && (s += a);
|
|
@@ -903,39 +903,39 @@ function Wt(e, t, n) {
|
|
|
903
903
|
}
|
|
904
904
|
}), s;
|
|
905
905
|
}
|
|
906
|
-
function
|
|
907
|
-
return
|
|
906
|
+
function Yt(e, t) {
|
|
907
|
+
return Jt(e, {
|
|
908
908
|
from: 0,
|
|
909
909
|
to: e.content.size
|
|
910
910
|
}, t);
|
|
911
911
|
}
|
|
912
|
-
function
|
|
912
|
+
function Xt(e) {
|
|
913
913
|
return Object.fromEntries(Object.entries(e.nodes).filter(([, e]) => e.spec.toText).map(([e, t]) => [e, t.spec.toText]));
|
|
914
914
|
}
|
|
915
|
-
function
|
|
916
|
-
let n =
|
|
915
|
+
function Zt(e, t) {
|
|
916
|
+
let n = E(t, e.schema), { from: r, to: i } = e.selection, a = [];
|
|
917
917
|
e.doc.nodesBetween(r, i, (e) => {
|
|
918
918
|
a.push(e);
|
|
919
919
|
});
|
|
920
920
|
let o = a.reverse().find((e) => e.type.name === n.name);
|
|
921
921
|
return o ? { ...o.attrs } : {};
|
|
922
922
|
}
|
|
923
|
-
function
|
|
924
|
-
let n =
|
|
925
|
-
return n === "node" ?
|
|
923
|
+
function Qt(e, t) {
|
|
924
|
+
let n = F(typeof t == "string" ? t : t.name, e.schema);
|
|
925
|
+
return n === "node" ? Zt(e, t) : n === "mark" ? kt(e, t) : {};
|
|
926
926
|
}
|
|
927
|
-
function
|
|
927
|
+
function $t(e, t = JSON.stringify) {
|
|
928
928
|
let n = {};
|
|
929
929
|
return e.filter((e) => {
|
|
930
930
|
let r = t(e);
|
|
931
931
|
return Object.prototype.hasOwnProperty.call(n, r) ? !1 : n[r] = !0;
|
|
932
932
|
});
|
|
933
933
|
}
|
|
934
|
-
function
|
|
935
|
-
let t =
|
|
934
|
+
function en(e) {
|
|
935
|
+
let t = $t(e);
|
|
936
936
|
return t.length === 1 ? t : t.filter((e, n) => !t.filter((e, t) => t !== n).some((t) => e.oldRange.from >= t.oldRange.from && e.oldRange.to <= t.oldRange.to && e.newRange.from >= t.newRange.from && e.newRange.to <= t.newRange.to));
|
|
937
937
|
}
|
|
938
|
-
function
|
|
938
|
+
function tn(e) {
|
|
939
939
|
let { mapping: t, steps: n } = e, r = [];
|
|
940
940
|
return t.maps.forEach((e, i) => {
|
|
941
941
|
let a = [];
|
|
@@ -966,12 +966,12 @@ function Zt(e) {
|
|
|
966
966
|
}
|
|
967
967
|
});
|
|
968
968
|
});
|
|
969
|
-
}),
|
|
969
|
+
}), en(r);
|
|
970
970
|
}
|
|
971
|
-
function
|
|
971
|
+
function H(e, t, n) {
|
|
972
972
|
let r = [];
|
|
973
973
|
return e === t ? n.resolve(e).marks().forEach((t) => {
|
|
974
|
-
let i =
|
|
974
|
+
let i = O(n.resolve(e), t.type);
|
|
975
975
|
i && r.push({
|
|
976
976
|
mark: t,
|
|
977
977
|
...i
|
|
@@ -984,29 +984,29 @@ function Qt(e, t, n) {
|
|
|
984
984
|
})));
|
|
985
985
|
}), r;
|
|
986
986
|
}
|
|
987
|
-
var
|
|
987
|
+
var nn = (e, t, n, r = 20) => {
|
|
988
988
|
let i = e.doc.resolve(n), a = r, o = null;
|
|
989
989
|
for (; a > 0 && o === null;) {
|
|
990
990
|
let e = i.node(a);
|
|
991
991
|
e?.type.name === t ? o = e : --a;
|
|
992
992
|
}
|
|
993
993
|
return [o, a];
|
|
994
|
-
},
|
|
994
|
+
}, rn = (e) => {
|
|
995
995
|
let t = e.depth - 1;
|
|
996
996
|
if (t < 0) return null;
|
|
997
997
|
let n = e.index(t);
|
|
998
998
|
return n === 0 ? null : e.node(t).child(n - 1);
|
|
999
999
|
};
|
|
1000
|
-
function
|
|
1000
|
+
function U(e, t) {
|
|
1001
1001
|
return t.nodes[e] || t.marks[e] || null;
|
|
1002
1002
|
}
|
|
1003
|
-
function
|
|
1003
|
+
function W(e, t, n) {
|
|
1004
1004
|
return Object.fromEntries(Object.entries(n).filter(([n]) => {
|
|
1005
1005
|
let r = e.find((e) => e.type === t && e.name === n);
|
|
1006
1006
|
return r ? r.attribute.keepOnSplit : !1;
|
|
1007
1007
|
}));
|
|
1008
1008
|
}
|
|
1009
|
-
var
|
|
1009
|
+
var an = (e, t = 500) => {
|
|
1010
1010
|
let n = "", r = e.parentOffset;
|
|
1011
1011
|
return e.parent.nodesBetween(Math.max(0, r - t), r, (e, t, i, a) => {
|
|
1012
1012
|
var o;
|
|
@@ -1019,9 +1019,9 @@ var tn = (e, t = 500) => {
|
|
|
1019
1019
|
n += e.isAtom && !e.isText ? s : s.slice(0, Math.max(0, r - t));
|
|
1020
1020
|
}), n;
|
|
1021
1021
|
};
|
|
1022
|
-
function
|
|
1023
|
-
let { empty: r, ranges: i } = e.selection, a = t ?
|
|
1024
|
-
if (r) return !!(e.storedMarks || e.selection.$from.marks()).filter((e) => !a || a.name === e.type.name).find((e) =>
|
|
1022
|
+
function on(e, t, n = {}) {
|
|
1023
|
+
let { empty: r, ranges: i } = e.selection, a = t ? k(t, e.schema) : null;
|
|
1024
|
+
if (r) return !!(e.storedMarks || e.selection.$from.marks()).filter((e) => !a || a.name === e.type.name).find((e) => D(e.attrs, n, { strict: !1 }));
|
|
1025
1025
|
let o = 0, s = [];
|
|
1026
1026
|
if (i.forEach(({ $from: t, $to: n }) => {
|
|
1027
1027
|
let r = t.pos, i = n.pos;
|
|
@@ -1036,41 +1036,41 @@ function nn(e, t, n = {}) {
|
|
|
1036
1036
|
})));
|
|
1037
1037
|
});
|
|
1038
1038
|
}), o === 0) return !1;
|
|
1039
|
-
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) => D(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);
|
|
1040
1040
|
return (c > 0 ? c + l : c) >= o;
|
|
1041
1041
|
}
|
|
1042
|
-
function
|
|
1043
|
-
if (!t) return
|
|
1044
|
-
let r =
|
|
1045
|
-
return r === "node" ?
|
|
1042
|
+
function sn(e, t, n = {}) {
|
|
1043
|
+
if (!t) return P(e, null, n) || on(e, null, n);
|
|
1044
|
+
let r = F(t, e.schema);
|
|
1045
|
+
return r === "node" ? P(e, t, n) : r === "mark" && on(e, t, n);
|
|
1046
1046
|
}
|
|
1047
|
-
var
|
|
1047
|
+
var cn = (e, t) => {
|
|
1048
1048
|
let { $from: n, $to: r, $anchor: i } = e.selection;
|
|
1049
1049
|
if (t) {
|
|
1050
|
-
let n =
|
|
1050
|
+
let n = I((e) => e.type.name === t)(e.selection);
|
|
1051
1051
|
if (!n) return !1;
|
|
1052
1052
|
let r = e.doc.resolve(n.pos + 1);
|
|
1053
1053
|
return i.pos + 1 === r.end();
|
|
1054
1054
|
}
|
|
1055
1055
|
return !(r.parentOffset < r.parent.nodeSize - 2 || n.pos !== r.pos);
|
|
1056
|
-
},
|
|
1056
|
+
}, ln = (e) => {
|
|
1057
1057
|
let { $from: t, $to: n } = e.selection;
|
|
1058
1058
|
return !(t.parentOffset > 0 || t.pos !== n.pos);
|
|
1059
1059
|
};
|
|
1060
|
-
function
|
|
1060
|
+
function un(e, t) {
|
|
1061
1061
|
return Array.isArray(t) ? t.some((t) => (typeof t == "string" ? t : t.name) === e.name) : t;
|
|
1062
1062
|
}
|
|
1063
|
-
function
|
|
1064
|
-
let { nodeExtensions: n } =
|
|
1063
|
+
function dn(e, t) {
|
|
1064
|
+
let { nodeExtensions: n } = z(t), r = n.find((t) => t.name === e);
|
|
1065
1065
|
if (!r) return !1;
|
|
1066
|
-
let i =
|
|
1066
|
+
let i = R(L(r, "group", {
|
|
1067
1067
|
name: r.name,
|
|
1068
1068
|
options: r.options,
|
|
1069
1069
|
storage: r.storage
|
|
1070
1070
|
}));
|
|
1071
1071
|
return typeof i == "string" && i.split(" ").includes("list");
|
|
1072
1072
|
}
|
|
1073
|
-
function
|
|
1073
|
+
function G(e, { checkChildren: t = !0, ignoreWhitespace: n = !1 } = {}) {
|
|
1074
1074
|
if (n) {
|
|
1075
1075
|
if (e.type.name === "hardBreak") return !0;
|
|
1076
1076
|
if (e.isText) return !/\S/.test(e.text ?? "");
|
|
@@ -1081,7 +1081,7 @@ function J(e, { checkChildren: t = !0, ignoreWhitespace: n = !1 } = {}) {
|
|
|
1081
1081
|
if (t) {
|
|
1082
1082
|
let r = !0;
|
|
1083
1083
|
return e.content.forEach((e) => {
|
|
1084
|
-
r !== !1 && (
|
|
1084
|
+
r !== !1 && (G(e, {
|
|
1085
1085
|
ignoreWhitespace: n,
|
|
1086
1086
|
checkChildren: t
|
|
1087
1087
|
}) || (r = !1));
|
|
@@ -1089,10 +1089,10 @@ function J(e, { checkChildren: t = !0, ignoreWhitespace: n = !1 } = {}) {
|
|
|
1089
1089
|
}
|
|
1090
1090
|
return !1;
|
|
1091
1091
|
}
|
|
1092
|
-
function
|
|
1093
|
-
return e instanceof
|
|
1092
|
+
function fn(e) {
|
|
1093
|
+
return e instanceof n;
|
|
1094
1094
|
}
|
|
1095
|
-
var
|
|
1095
|
+
var pn = class e {
|
|
1096
1096
|
constructor(e) {
|
|
1097
1097
|
this.position = e;
|
|
1098
1098
|
}
|
|
@@ -1103,18 +1103,18 @@ var un = class e {
|
|
|
1103
1103
|
return { position: this.position };
|
|
1104
1104
|
}
|
|
1105
1105
|
};
|
|
1106
|
-
function
|
|
1106
|
+
function mn(e, t) {
|
|
1107
1107
|
let n = t.mapping.mapResult(e.position);
|
|
1108
1108
|
return {
|
|
1109
|
-
position: new
|
|
1109
|
+
position: new pn(n.pos),
|
|
1110
1110
|
mapResult: n
|
|
1111
1111
|
};
|
|
1112
1112
|
}
|
|
1113
|
-
function
|
|
1114
|
-
return new
|
|
1113
|
+
function hn(e) {
|
|
1114
|
+
return new pn(e);
|
|
1115
1115
|
}
|
|
1116
|
-
function
|
|
1117
|
-
let r = e.state.doc.content.size, i =
|
|
1116
|
+
function gn(e, t, n) {
|
|
1117
|
+
let r = e.state.doc.content.size, i = A(t, 0, r), a = A(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 = {
|
|
1118
1118
|
top: c,
|
|
1119
1119
|
bottom: l,
|
|
1120
1120
|
left: u,
|
|
@@ -1129,9 +1129,9 @@ function pn(e, t, n) {
|
|
|
1129
1129
|
toJSON: () => f
|
|
1130
1130
|
};
|
|
1131
1131
|
}
|
|
1132
|
-
function
|
|
1132
|
+
function _n(e, t, n) {
|
|
1133
1133
|
let { selection: r } = t, i = null;
|
|
1134
|
-
if (
|
|
1134
|
+
if (Ue(r) && (i = r.$cursor), i) {
|
|
1135
1135
|
let t = e.storedMarks ?? i.marks();
|
|
1136
1136
|
return i.parent.type.allowsMarkType(n) && (!!n.isInSet(t) || !t.some((e) => e.type.excludes(n)));
|
|
1137
1137
|
}
|
|
@@ -1148,11 +1148,11 @@ function mn(e, t, n) {
|
|
|
1148
1148
|
}), i;
|
|
1149
1149
|
});
|
|
1150
1150
|
}
|
|
1151
|
-
var
|
|
1152
|
-
let { selection: a } = n, { empty: o, ranges: s } = a, c =
|
|
1151
|
+
var vn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
|
|
1152
|
+
let { selection: a } = n, { empty: o, ranges: s } = a, c = k(e, r.schema);
|
|
1153
1153
|
if (i) {
|
|
1154
1154
|
if (o) {
|
|
1155
|
-
let e =
|
|
1155
|
+
let e = kt(r, c);
|
|
1156
1156
|
n.addStoredMark(c.create({
|
|
1157
1157
|
...e,
|
|
1158
1158
|
...t
|
|
@@ -1170,23 +1170,23 @@ var hn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
|
|
|
1170
1170
|
});
|
|
1171
1171
|
});
|
|
1172
1172
|
}
|
|
1173
|
-
return
|
|
1174
|
-
},
|
|
1175
|
-
let a =
|
|
1176
|
-
return n.selection.$anchor.sameParent(n.selection.$head) && (o = n.selection.$anchor.parent.attrs), a.isTextblock ? i().command(({ commands: e }) =>
|
|
1173
|
+
return _n(r, n, c);
|
|
1174
|
+
}, yn = (e, t) => ({ tr: n }) => (n.setMeta(e, t), !0), bn = (e, t = {}) => ({ state: n, dispatch: r, chain: i }) => {
|
|
1175
|
+
let a = E(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 }) => ue(a, {
|
|
1177
1177
|
...o,
|
|
1178
1178
|
...t
|
|
1179
|
-
})(n) ? !0 : e.clearNodes()).command(({ state: e }) =>
|
|
1179
|
+
})(n) ? !0 : e.clearNodes()).command(({ state: e }) => ue(a, {
|
|
1180
1180
|
...o,
|
|
1181
1181
|
...t
|
|
1182
1182
|
})(e, r)).run() : (console.warn("[tiptap warn]: Currently \"setNode()\" only supports text block nodes."), !1);
|
|
1183
|
-
},
|
|
1184
|
-
if (
|
|
1185
|
-
let { doc:
|
|
1186
|
-
t.setSelection(
|
|
1183
|
+
}, xn = (e) => ({ tr: t, dispatch: r }) => {
|
|
1184
|
+
if (r) {
|
|
1185
|
+
let { doc: r } = t, i = A(e, 0, r.content.size), a = n.create(r, i);
|
|
1186
|
+
t.setSelection(a);
|
|
1187
1187
|
}
|
|
1188
1188
|
return !0;
|
|
1189
|
-
},
|
|
1189
|
+
}, Sn = (e, t) => ({ tr: n, state: r, dispatch: i }) => {
|
|
1190
1190
|
let { selection: a } = r, o, s;
|
|
1191
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) => {
|
|
1192
1192
|
t.isText || n.setNodeMarkup(r, void 0, {
|
|
@@ -1194,157 +1194,157 @@ var hn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
|
|
|
1194
1194
|
dir: e
|
|
1195
1195
|
});
|
|
1196
1196
|
}), !0;
|
|
1197
|
-
},
|
|
1197
|
+
}, Cn = (e) => ({ tr: t, dispatch: n }) => {
|
|
1198
1198
|
if (n) {
|
|
1199
1199
|
let { doc: n } = t, { from: r, to: i } = typeof e == "number" ? {
|
|
1200
1200
|
from: e,
|
|
1201
1201
|
to: e
|
|
1202
|
-
} : e, a =
|
|
1203
|
-
t.setSelection(
|
|
1202
|
+
} : e, a = o.atStart(n).from, s = o.atEnd(n).to, c = A(r, a, s), l = A(i, a, s), u = o.create(n, c, l);
|
|
1203
|
+
t.setSelection(u);
|
|
1204
1204
|
}
|
|
1205
1205
|
return !0;
|
|
1206
|
-
},
|
|
1207
|
-
let r =
|
|
1208
|
-
return
|
|
1206
|
+
}, wn = (e) => ({ state: t, dispatch: n }) => {
|
|
1207
|
+
let r = E(e, t.schema);
|
|
1208
|
+
return _e(r)(t, n);
|
|
1209
1209
|
};
|
|
1210
|
-
function
|
|
1210
|
+
function Tn(e, t) {
|
|
1211
1211
|
let n = e.storedMarks || e.selection.$to.parentOffset && e.selection.$from.marks();
|
|
1212
1212
|
if (n) {
|
|
1213
1213
|
let r = n.filter((e) => t?.includes(e.type.name));
|
|
1214
1214
|
e.tr.ensureMarks(r);
|
|
1215
1215
|
}
|
|
1216
1216
|
}
|
|
1217
|
-
var
|
|
1218
|
-
let { selection:
|
|
1219
|
-
if (
|
|
1220
|
-
if (!
|
|
1221
|
-
let
|
|
1222
|
-
type:
|
|
1223
|
-
attrs:
|
|
1224
|
-
}] : void 0,
|
|
1225
|
-
if (!
|
|
1226
|
-
type:
|
|
1227
|
-
attrs:
|
|
1228
|
-
}] : void 0),
|
|
1229
|
-
if (
|
|
1230
|
-
let e = t.mapping.map(
|
|
1231
|
-
|
|
1217
|
+
var En = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: r, dispatch: i, editor: a }) => {
|
|
1218
|
+
let { selection: s, doc: c } = t, { $from: l, $to: u } = s, d = a.extensionManager.attributes, p = W(d, l.node().type.name, l.node().attrs);
|
|
1219
|
+
if (s instanceof n && s.node.isBlock) return !l.parentOffset || !f(c, l.pos) ? !1 : (i && (e && Tn(r, a.extensionManager.splittableMarks), t.split(l.pos).scrollIntoView()), !0);
|
|
1220
|
+
if (!l.parent.isBlock) return !1;
|
|
1221
|
+
let m = u.parentOffset === u.parent.content.size, h = l.depth === 0 ? void 0 : tt(l.node(-1).contentMatchAt(l.indexAfter(-1))), g = m && h ? [{
|
|
1222
|
+
type: h,
|
|
1223
|
+
attrs: p
|
|
1224
|
+
}] : void 0, _ = f(t.doc, t.mapping.map(l.pos), 1, g);
|
|
1225
|
+
if (!g && !_ && f(t.doc, t.mapping.map(l.pos), 1, h ? [{ type: h }] : void 0) && (_ = !0, g = h ? [{
|
|
1226
|
+
type: h,
|
|
1227
|
+
attrs: p
|
|
1228
|
+
}] : void 0), i) {
|
|
1229
|
+
if (_ && (s instanceof o && t.deleteSelection(), t.split(t.mapping.map(l.pos), 1, g), h && !m && !l.parentOffset && l.parent.type !== h)) {
|
|
1230
|
+
let e = t.mapping.map(l.before()), n = t.doc.resolve(e);
|
|
1231
|
+
l.node(-1).canReplaceWith(n.index(), n.index() + 1, h) && t.setNodeMarkup(t.mapping.map(l.before()), h);
|
|
1232
1232
|
}
|
|
1233
|
-
e &&
|
|
1233
|
+
e && Tn(r, a.extensionManager.splittableMarks), t.scrollIntoView();
|
|
1234
1234
|
}
|
|
1235
|
-
return
|
|
1236
|
-
},
|
|
1237
|
-
let s =
|
|
1235
|
+
return _;
|
|
1236
|
+
}, Dn = (e, t = {}) => ({ tr: n, state: r, dispatch: i, editor: a }) => {
|
|
1237
|
+
let s = E(e, r.schema), { $from: c, $to: l } = r.selection, u = r.selection.node;
|
|
1238
1238
|
if (u && u.isBlock || c.depth < 2 || !c.sameParent(l)) return !1;
|
|
1239
1239
|
let d = c.node(-1);
|
|
1240
1240
|
if (d.type !== s) return !1;
|
|
1241
|
-
let
|
|
1241
|
+
let p = a.extensionManager.attributes;
|
|
1242
1242
|
if (c.parent.content.size === 0 && c.node(-1).childCount === c.indexAfter(-1)) {
|
|
1243
1243
|
if (c.depth === 2 || c.node(-3).type !== s || c.index(-2) !== c.node(-2).childCount - 1) return !1;
|
|
1244
1244
|
if (i) {
|
|
1245
|
-
let e =
|
|
1246
|
-
for (let t = c.depth - r; t >= c.depth - 3; --t) e =
|
|
1245
|
+
let e = S.empty, r = c.index(-1) ? 1 : c.index(-2) ? 2 : 3;
|
|
1246
|
+
for (let t = c.depth - r; t >= c.depth - 3; --t) e = S.from(c.node(t).copy(e));
|
|
1247
1247
|
let i = c.indexAfter(-1) < c.node(-2).childCount ? 1 : c.indexAfter(-2) < c.node(-3).childCount ? 2 : 3, a = {
|
|
1248
|
-
...
|
|
1248
|
+
...W(p, c.node().type.name, c.node().attrs),
|
|
1249
1249
|
...t
|
|
1250
|
-
},
|
|
1251
|
-
e = e.append(
|
|
1252
|
-
let
|
|
1253
|
-
n.replace(
|
|
1254
|
-
let
|
|
1255
|
-
n.doc.nodesBetween(
|
|
1256
|
-
if (
|
|
1257
|
-
e.isTextblock && e.content.size === 0 && (
|
|
1258
|
-
}),
|
|
1250
|
+
}, l = s.contentMatch.defaultType?.createAndFill(a) || void 0;
|
|
1251
|
+
e = e.append(S.from(s.createAndFill(null, l) || void 0));
|
|
1252
|
+
let u = c.before(c.depth - (r - 1));
|
|
1253
|
+
n.replace(u, c.after(-i), new he(e, 4 - r, 0));
|
|
1254
|
+
let d = -1;
|
|
1255
|
+
n.doc.nodesBetween(u, n.doc.content.size, (e, t) => {
|
|
1256
|
+
if (d > -1) return !1;
|
|
1257
|
+
e.isTextblock && e.content.size === 0 && (d = t + 1);
|
|
1258
|
+
}), d > -1 && n.setSelection(o.near(n.doc.resolve(d))), n.scrollIntoView();
|
|
1259
1259
|
}
|
|
1260
1260
|
return !0;
|
|
1261
1261
|
}
|
|
1262
|
-
let
|
|
1263
|
-
...
|
|
1262
|
+
let m = l.pos === c.end() ? d.contentMatchAt(0).defaultType : null, h = {
|
|
1263
|
+
...W(p, d.type.name, d.attrs),
|
|
1264
1264
|
...t
|
|
1265
|
-
},
|
|
1266
|
-
...
|
|
1265
|
+
}, g = {
|
|
1266
|
+
...W(p, c.node().type.name, c.node().attrs),
|
|
1267
1267
|
...t
|
|
1268
1268
|
};
|
|
1269
1269
|
n.delete(c.pos, l.pos);
|
|
1270
|
-
let
|
|
1270
|
+
let _ = m ? [{
|
|
1271
1271
|
type: s,
|
|
1272
|
-
attrs: m
|
|
1273
|
-
}, {
|
|
1274
|
-
type: p,
|
|
1275
1272
|
attrs: h
|
|
1273
|
+
}, {
|
|
1274
|
+
type: m,
|
|
1275
|
+
attrs: g
|
|
1276
1276
|
}] : [{
|
|
1277
1277
|
type: s,
|
|
1278
|
-
attrs:
|
|
1278
|
+
attrs: h
|
|
1279
1279
|
}];
|
|
1280
|
-
if (!
|
|
1280
|
+
if (!f(n.doc, c.pos, 2)) return !1;
|
|
1281
1281
|
if (i) {
|
|
1282
|
-
let { selection: e, storedMarks: t } = r, { splittableMarks:
|
|
1283
|
-
if (n.split(c.pos, 2,
|
|
1284
|
-
let l = s.filter((e) =>
|
|
1282
|
+
let { selection: e, storedMarks: t } = r, { splittableMarks: o } = a.extensionManager, s = t || e.$to.parentOffset && e.$from.marks();
|
|
1283
|
+
if (n.split(c.pos, 2, _).scrollIntoView(), !s || !i) return !0;
|
|
1284
|
+
let l = s.filter((e) => o.includes(e.type.name));
|
|
1285
1285
|
n.ensureMarks(l);
|
|
1286
1286
|
}
|
|
1287
1287
|
return !0;
|
|
1288
1288
|
};
|
|
1289
|
-
function
|
|
1289
|
+
function On(e) {
|
|
1290
1290
|
return !e || e === "1" ? null : e;
|
|
1291
1291
|
}
|
|
1292
|
-
function
|
|
1293
|
-
return
|
|
1292
|
+
function kn(e, t) {
|
|
1293
|
+
return On(e) === On(t);
|
|
1294
1294
|
}
|
|
1295
|
-
var
|
|
1296
|
-
let n =
|
|
1295
|
+
var An = (e, t) => {
|
|
1296
|
+
let n = I((e) => e.type === t)(e.selection);
|
|
1297
1297
|
if (!n) return !0;
|
|
1298
1298
|
let r = e.doc.resolve(Math.max(0, n.pos - 1)).before(n.depth);
|
|
1299
1299
|
if (r === void 0) return !0;
|
|
1300
|
-
let
|
|
1301
|
-
return !(n.node.type ===
|
|
1302
|
-
},
|
|
1303
|
-
let n =
|
|
1300
|
+
let i = e.doc.nodeAt(r);
|
|
1301
|
+
return !(n.node.type === i?.type && d(e.doc, n.pos)) || !kn(n.node.attrs.type, i?.attrs.type) || e.join(n.pos), !0;
|
|
1302
|
+
}, jn = (e, t) => {
|
|
1303
|
+
let n = I((e) => e.type === t)(e.selection);
|
|
1304
1304
|
if (!n) return !0;
|
|
1305
1305
|
let r = e.doc.resolve(n.start).after(n.depth);
|
|
1306
1306
|
if (r === void 0) return !0;
|
|
1307
|
-
let
|
|
1308
|
-
return !(n.node.type ===
|
|
1307
|
+
let i = e.doc.nodeAt(r);
|
|
1308
|
+
return !(n.node.type === i?.type && d(e.doc, r)) || !kn(n.node.attrs.type, i?.attrs.type) || e.join(r), !0;
|
|
1309
1309
|
};
|
|
1310
|
-
function
|
|
1310
|
+
function Mn(e) {
|
|
1311
1311
|
let t = e.doc, n = t.firstChild;
|
|
1312
1312
|
if (!n) return null;
|
|
1313
1313
|
let r = t.resolve(1), i = t.resolve(n.nodeSize - 1);
|
|
1314
|
-
return
|
|
1314
|
+
return o.between(r, i);
|
|
1315
1315
|
}
|
|
1316
|
-
var
|
|
1317
|
-
let { extensions: d, splittableMarks: f } = i.extensionManager, p =
|
|
1318
|
-
if (!
|
|
1319
|
-
let
|
|
1320
|
-
node:
|
|
1316
|
+
var Nn = (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 = E(e, o.schema), m = E(t, o.schema), { selection: h, storedMarks: g } = o, { $from: _, $to: ee } = h, v = _.blockRange(ee), te = g || h.$to.parentOffset && h.$from.marks();
|
|
1318
|
+
if (!v) return !1;
|
|
1319
|
+
let y = I((e) => dn(e.type.name, d))(h), ne = h.from === 0 && h.to === o.doc.content.size, re = o.doc.content.content, b = re.length === 1 ? re[0] : null, ie = ne && b && dn(b.type.name, d) ? {
|
|
1320
|
+
node: b,
|
|
1321
1321
|
pos: 0,
|
|
1322
1322
|
depth: 0
|
|
1323
|
-
} : null, x =
|
|
1323
|
+
} : null, x = y ?? ie, ae = !!y && v.depth >= 1 && v.depth - y.depth <= 1, oe = !!ie;
|
|
1324
1324
|
if ((ae || oe) && x) {
|
|
1325
|
-
if (x.node.type === p) return
|
|
1326
|
-
let n =
|
|
1325
|
+
if (x.node.type === p) return ne && oe ? c().command(({ tr: e, dispatch: t }) => {
|
|
1326
|
+
let n = Mn(e);
|
|
1327
1327
|
return n ? (e.setSelection(n), t && t(e), !0) : !1;
|
|
1328
1328
|
}).liftListItem(m).run() : l.liftListItem(m);
|
|
1329
|
-
if (
|
|
1329
|
+
if (dn(x.node.type.name, d) && p.validContent(x.node.content)) return c().command(() => (a.setNodeMarkup(x.pos, p), !0)).command(() => An(a, p)).command(() => jn(a, p)).run();
|
|
1330
1330
|
}
|
|
1331
|
-
return !n || !
|
|
1332
|
-
let e = u().wrapInList(p, r), t =
|
|
1331
|
+
return !n || !te || !s ? c().command(() => u().wrapInList(p, r) ? !0 : l.clearNodes()).wrapInList(p, r).command(() => An(a, p)).command(() => jn(a, p)).run() : c().command(() => {
|
|
1332
|
+
let e = u().wrapInList(p, r), t = te.filter((e) => f.includes(e.type.name));
|
|
1333
1333
|
return a.ensureMarks(t), e ? !0 : l.clearNodes();
|
|
1334
|
-
}).wrapInList(p, r).command(() =>
|
|
1335
|
-
},
|
|
1336
|
-
let { extendEmptyMarkRange: a = !1 } = n, o =
|
|
1337
|
-
return
|
|
1338
|
-
},
|
|
1339
|
-
let a =
|
|
1334
|
+
}).wrapInList(p, r).command(() => An(a, p)).command(() => jn(a, p)).run();
|
|
1335
|
+
}, Pn = (e, t = {}, n = {}) => ({ state: r, commands: i }) => {
|
|
1336
|
+
let { extendEmptyMarkRange: a = !1 } = n, o = k(e, r.schema);
|
|
1337
|
+
return on(r, o, t) ? i.unsetMark(o, { extendEmptyMarkRange: a }) : i.setMark(o, t);
|
|
1338
|
+
}, Fn = (e, t, n = {}) => ({ state: r, commands: i }) => {
|
|
1339
|
+
let a = E(e, r.schema), o = E(t, r.schema), s = P(r, a, n), c;
|
|
1340
1340
|
return r.selection.$anchor.sameParent(r.selection.$head) && (c = r.selection.$anchor.parent.attrs), s ? i.setNode(o, c) : i.setNode(a, {
|
|
1341
1341
|
...c,
|
|
1342
1342
|
...n
|
|
1343
1343
|
});
|
|
1344
|
-
},
|
|
1345
|
-
let i =
|
|
1346
|
-
return
|
|
1347
|
-
},
|
|
1344
|
+
}, In = (e, t = {}) => ({ state: n, commands: r }) => {
|
|
1345
|
+
let i = E(e, n.schema);
|
|
1346
|
+
return P(n, i, t) ? r.lift(i) : r.wrapIn(i, t);
|
|
1347
|
+
}, Ln = () => ({ state: e, dispatch: t }) => {
|
|
1348
1348
|
let n = e.plugins;
|
|
1349
1349
|
for (let r = 0; r < n.length; r += 1) {
|
|
1350
1350
|
let i = n[r], a;
|
|
@@ -1361,7 +1361,7 @@ var An = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain:
|
|
|
1361
1361
|
}
|
|
1362
1362
|
}
|
|
1363
1363
|
return !1;
|
|
1364
|
-
},
|
|
1364
|
+
}, Rn = (e = {}) => ({ tr: t, dispatch: n, editor: r }) => {
|
|
1365
1365
|
let { ignoreClearable: i = !1 } = e, { selection: a } = t, { empty: o, ranges: s } = a;
|
|
1366
1366
|
if (o) return !0;
|
|
1367
1367
|
let { nonClearableMarks: c } = r.extensionManager;
|
|
@@ -1372,27 +1372,27 @@ var An = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain:
|
|
|
1372
1372
|
});
|
|
1373
1373
|
}
|
|
1374
1374
|
return !0;
|
|
1375
|
-
},
|
|
1376
|
-
let { extendEmptyMarkRange: a = !1 } = t, { selection: o } = n, s =
|
|
1375
|
+
}, zn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
|
|
1376
|
+
let { extendEmptyMarkRange: a = !1 } = t, { selection: o } = n, s = k(e, r.schema), { $from: c, empty: l, ranges: u } = o;
|
|
1377
1377
|
if (!i) return !0;
|
|
1378
1378
|
if (l && a) {
|
|
1379
|
-
let { from: e, to: t } = o, r =
|
|
1379
|
+
let { from: e, to: t } = o, r = O(c, s, c.marks().find((e) => e.type === s)?.attrs);
|
|
1380
1380
|
r && (e = r.from, t = r.to), n.removeMark(e, t, s);
|
|
1381
1381
|
} else u.forEach((e) => {
|
|
1382
1382
|
n.removeMark(e.$from.pos, e.$to.pos, s);
|
|
1383
1383
|
});
|
|
1384
1384
|
return n.removeStoredMark(s), !0;
|
|
1385
|
-
},
|
|
1385
|
+
}, Bn = (e) => ({ tr: t, state: n, dispatch: r }) => {
|
|
1386
1386
|
let { selection: i } = n, a, o;
|
|
1387
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) => {
|
|
1388
1388
|
if (e.isText) return;
|
|
1389
1389
|
let r = { ...e.attrs };
|
|
1390
1390
|
delete r.dir, t.setNodeMarkup(n, void 0, r);
|
|
1391
1391
|
}), !0;
|
|
1392
|
-
},
|
|
1393
|
-
let a = null, o = null, s =
|
|
1392
|
+
}, Vn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
|
|
1393
|
+
let a = null, o = null, s = F(typeof e == "string" ? e : e.name, r.schema);
|
|
1394
1394
|
if (!s) return !1;
|
|
1395
|
-
s === "node" && (a =
|
|
1395
|
+
s === "node" && (a = E(e, r.schema)), s === "mark" && (o = k(e, r.schema));
|
|
1396
1396
|
let c = !1;
|
|
1397
1397
|
return n.selection.ranges.forEach((e) => {
|
|
1398
1398
|
let s = e.$from.pos, l = e.$to.pos, u, d, f, p;
|
|
@@ -1421,92 +1421,92 @@ var An = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain:
|
|
|
1421
1421
|
}));
|
|
1422
1422
|
}));
|
|
1423
1423
|
}), c;
|
|
1424
|
-
},
|
|
1424
|
+
}, K = new i("__tiptap_decorations__"), Hn = (e) => ({ tr: t, dispatch: n }) => (n && t.setMeta(K, {
|
|
1425
1425
|
type: "force",
|
|
1426
1426
|
name: e
|
|
1427
|
-
}), !0),
|
|
1428
|
-
let i =
|
|
1429
|
-
return
|
|
1430
|
-
},
|
|
1431
|
-
let i =
|
|
1432
|
-
return
|
|
1433
|
-
},
|
|
1434
|
-
blur: () =>
|
|
1435
|
-
clearContent: () =>
|
|
1436
|
-
clearNodes: () =>
|
|
1437
|
-
command: () =>
|
|
1438
|
-
createParagraphNear: () =>
|
|
1439
|
-
cut: () =>
|
|
1440
|
-
deleteCurrentNode: () =>
|
|
1441
|
-
deleteNode: () =>
|
|
1442
|
-
deleteRange: () =>
|
|
1443
|
-
deleteSelection: () =>
|
|
1444
|
-
enter: () =>
|
|
1445
|
-
exitCode: () =>
|
|
1446
|
-
extendMarkRange: () =>
|
|
1447
|
-
first: () =>
|
|
1448
|
-
focus: () =>
|
|
1449
|
-
forEach: () =>
|
|
1450
|
-
insertContent: () =>
|
|
1451
|
-
insertContentAt: () =>
|
|
1452
|
-
insertDefaultBlock: () =>
|
|
1453
|
-
joinBackward: () =>
|
|
1454
|
-
joinDown: () =>
|
|
1455
|
-
joinForward: () =>
|
|
1456
|
-
joinItemBackward: () =>
|
|
1457
|
-
joinItemForward: () =>
|
|
1458
|
-
joinTextblockBackward: () =>
|
|
1459
|
-
joinTextblockForward: () =>
|
|
1460
|
-
joinUp: () =>
|
|
1461
|
-
keyboardShortcut: () =>
|
|
1462
|
-
lift: () =>
|
|
1463
|
-
liftEmptyBlock: () =>
|
|
1464
|
-
liftListItem: () =>
|
|
1465
|
-
newlineInCode: () =>
|
|
1466
|
-
resetAttributes: () =>
|
|
1467
|
-
scrollIntoView: () =>
|
|
1468
|
-
selectAll: () =>
|
|
1469
|
-
selectNodeBackward: () =>
|
|
1470
|
-
selectNodeForward: () =>
|
|
1471
|
-
selectParentNode: () =>
|
|
1472
|
-
selectTextblockEnd: () =>
|
|
1473
|
-
selectTextblockStart: () =>
|
|
1474
|
-
setContent: () =>
|
|
1475
|
-
setMark: () =>
|
|
1476
|
-
setMeta: () =>
|
|
1477
|
-
setNode: () =>
|
|
1478
|
-
setNodeSelection: () =>
|
|
1479
|
-
setTextDirection: () =>
|
|
1480
|
-
setTextSelection: () =>
|
|
1481
|
-
sinkListItem: () =>
|
|
1482
|
-
splitBlock: () =>
|
|
1483
|
-
splitListItem: () =>
|
|
1484
|
-
toggleList: () =>
|
|
1485
|
-
toggleMark: () =>
|
|
1486
|
-
toggleNode: () =>
|
|
1487
|
-
toggleWrap: () =>
|
|
1488
|
-
undoInputRule: () =>
|
|
1489
|
-
unsetAllMarks: () =>
|
|
1490
|
-
unsetMark: () =>
|
|
1491
|
-
unsetTextDirection: () =>
|
|
1492
|
-
updateAttributes: () =>
|
|
1493
|
-
updateDecorations: () =>
|
|
1494
|
-
wrapIn: () =>
|
|
1495
|
-
wrapInList: () =>
|
|
1496
|
-
}),
|
|
1497
|
-
function
|
|
1498
|
-
|
|
1427
|
+
}), !0), Un = (e, t = {}) => ({ state: n, dispatch: r }) => {
|
|
1428
|
+
let i = E(e, n.schema);
|
|
1429
|
+
return de(i, t)(n, r);
|
|
1430
|
+
}, Wn = (e, t = {}) => ({ state: n, dispatch: r }) => {
|
|
1431
|
+
let i = E(e, n.schema);
|
|
1432
|
+
return ve(i, t)(n, r);
|
|
1433
|
+
}, Gn = /* @__PURE__ */ Se({
|
|
1434
|
+
blur: () => Ce,
|
|
1435
|
+
clearContent: () => we,
|
|
1436
|
+
clearNodes: () => Te,
|
|
1437
|
+
command: () => Ee,
|
|
1438
|
+
createParagraphNear: () => De,
|
|
1439
|
+
cut: () => Oe,
|
|
1440
|
+
deleteCurrentNode: () => ke,
|
|
1441
|
+
deleteNode: () => Ae,
|
|
1442
|
+
deleteRange: () => je,
|
|
1443
|
+
deleteSelection: () => Fe,
|
|
1444
|
+
enter: () => Ie,
|
|
1445
|
+
exitCode: () => Le,
|
|
1446
|
+
extendMarkRange: () => Ve,
|
|
1447
|
+
first: () => He,
|
|
1448
|
+
focus: () => qe,
|
|
1449
|
+
forEach: () => Je,
|
|
1450
|
+
insertContent: () => Ye,
|
|
1451
|
+
insertContentAt: () => et,
|
|
1452
|
+
insertDefaultBlock: () => nt,
|
|
1453
|
+
joinBackward: () => at,
|
|
1454
|
+
joinDown: () => it,
|
|
1455
|
+
joinForward: () => ot,
|
|
1456
|
+
joinItemBackward: () => st,
|
|
1457
|
+
joinItemForward: () => ct,
|
|
1458
|
+
joinTextblockBackward: () => lt,
|
|
1459
|
+
joinTextblockForward: () => ut,
|
|
1460
|
+
joinUp: () => rt,
|
|
1461
|
+
keyboardShortcut: () => pt,
|
|
1462
|
+
lift: () => mt,
|
|
1463
|
+
liftEmptyBlock: () => ht,
|
|
1464
|
+
liftListItem: () => gt,
|
|
1465
|
+
newlineInCode: () => _t,
|
|
1466
|
+
resetAttributes: () => yt,
|
|
1467
|
+
scrollIntoView: () => bt,
|
|
1468
|
+
selectAll: () => xt,
|
|
1469
|
+
selectNodeBackward: () => St,
|
|
1470
|
+
selectNodeForward: () => Ct,
|
|
1471
|
+
selectParentNode: () => wt,
|
|
1472
|
+
selectTextblockEnd: () => Tt,
|
|
1473
|
+
selectTextblockStart: () => Et,
|
|
1474
|
+
setContent: () => Ot,
|
|
1475
|
+
setMark: () => vn,
|
|
1476
|
+
setMeta: () => yn,
|
|
1477
|
+
setNode: () => bn,
|
|
1478
|
+
setNodeSelection: () => xn,
|
|
1479
|
+
setTextDirection: () => Sn,
|
|
1480
|
+
setTextSelection: () => Cn,
|
|
1481
|
+
sinkListItem: () => wn,
|
|
1482
|
+
splitBlock: () => En,
|
|
1483
|
+
splitListItem: () => Dn,
|
|
1484
|
+
toggleList: () => Nn,
|
|
1485
|
+
toggleMark: () => Pn,
|
|
1486
|
+
toggleNode: () => Fn,
|
|
1487
|
+
toggleWrap: () => In,
|
|
1488
|
+
undoInputRule: () => Ln,
|
|
1489
|
+
unsetAllMarks: () => Rn,
|
|
1490
|
+
unsetMark: () => zn,
|
|
1491
|
+
unsetTextDirection: () => Bn,
|
|
1492
|
+
updateAttributes: () => Vn,
|
|
1493
|
+
updateDecorations: () => Hn,
|
|
1494
|
+
wrapIn: () => Un,
|
|
1495
|
+
wrapInList: () => Wn
|
|
1496
|
+
}), q = /* @__PURE__ */ new WeakMap();
|
|
1497
|
+
function Kn(e, t) {
|
|
1498
|
+
q.set(e, (q.get(e) ?? 0) + 1);
|
|
1499
1499
|
try {
|
|
1500
1500
|
return t();
|
|
1501
1501
|
} finally {
|
|
1502
|
-
let t = (
|
|
1503
|
-
t > 0 ?
|
|
1502
|
+
let t = (q.get(e) ?? 1) - 1;
|
|
1503
|
+
t > 0 ? q.set(e, t) : q.delete(e);
|
|
1504
1504
|
}
|
|
1505
1505
|
}
|
|
1506
|
-
function
|
|
1507
|
-
return
|
|
1506
|
+
function qn(e) {
|
|
1507
|
+
return q.has(e);
|
|
1508
1508
|
}
|
|
1509
|
-
var
|
|
1509
|
+
var Jn = class {
|
|
1510
1510
|
constructor() {
|
|
1511
1511
|
this.callbacks = {};
|
|
1512
1512
|
}
|
|
@@ -1530,44 +1530,44 @@ var Gn = class {
|
|
|
1530
1530
|
removeAllListeners() {
|
|
1531
1531
|
this.callbacks = {};
|
|
1532
1532
|
}
|
|
1533
|
-
},
|
|
1534
|
-
function
|
|
1533
|
+
}, Yn = typeof process < "u" && process.env.NODE_ENV !== "production";
|
|
1534
|
+
function Xn(e) {
|
|
1535
1535
|
return e.kind === "widget";
|
|
1536
1536
|
}
|
|
1537
|
-
function
|
|
1537
|
+
function Zn(e, t) {
|
|
1538
1538
|
let n = [], r = /* @__PURE__ */ new Set();
|
|
1539
|
-
for (let i of e) i.kind === "widget" &&
|
|
1539
|
+
for (let i of e) i.kind === "widget" && Xn(i) && r.add(i.key), n.push(i.toPMDecoration(t));
|
|
1540
1540
|
return {
|
|
1541
1541
|
decorations: n,
|
|
1542
1542
|
widgetKeys: r
|
|
1543
1543
|
};
|
|
1544
1544
|
}
|
|
1545
|
-
function
|
|
1546
|
-
let { decorations: r, widgetKeys: i } =
|
|
1545
|
+
function Qn(e, t, n) {
|
|
1546
|
+
let { decorations: r, widgetKeys: i } = Zn(t, n);
|
|
1547
1547
|
return {
|
|
1548
|
-
set:
|
|
1548
|
+
set: C.create(e, r),
|
|
1549
1549
|
widgetKeys: i
|
|
1550
1550
|
};
|
|
1551
1551
|
}
|
|
1552
|
-
function
|
|
1552
|
+
function $n({ position: e, from: t, to: n, docSize: r }) {
|
|
1553
1553
|
return e < t ? !1 : e < n || e === n && n === r;
|
|
1554
1554
|
}
|
|
1555
|
-
function
|
|
1556
|
-
return e.filter((e) =>
|
|
1555
|
+
function er({ decorations: e, from: t, to: n, docSize: r, extensionName: i, warnedExtensions: a }) {
|
|
1556
|
+
return e.filter((e) => $n({
|
|
1557
1557
|
position: e.anchor,
|
|
1558
1558
|
from: t,
|
|
1559
1559
|
to: n,
|
|
1560
1560
|
docSize: r
|
|
1561
1561
|
}) ? !0 : (e.anchor === n || a.has(i) || (a.add(i), console.warn(`[tiptap warn]: Extension "${i}" returned a decoration outside the requested range [${t}, ${n}). It was ignored.`)), !1));
|
|
1562
1562
|
}
|
|
1563
|
-
function
|
|
1563
|
+
function tr(e) {
|
|
1564
1564
|
let t = e.spec?.key;
|
|
1565
1565
|
return typeof t == "string" ? t : void 0;
|
|
1566
1566
|
}
|
|
1567
|
-
function
|
|
1567
|
+
function nr(e) {
|
|
1568
1568
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
1569
1569
|
for (let r of e.find()) {
|
|
1570
|
-
let e =
|
|
1570
|
+
let e = tr(r);
|
|
1571
1571
|
if (!e) continue;
|
|
1572
1572
|
let i = r.spec.extensionName ?? "unknown", a = t.get(e) ?? /* @__PURE__ */ new Set();
|
|
1573
1573
|
a.add(i), t.set(e, a), n.set(e, (n.get(e) ?? 0) + 1);
|
|
@@ -1577,18 +1577,18 @@ function $n(e) {
|
|
|
1577
1577
|
extensions: t
|
|
1578
1578
|
})).filter(({ key: e }) => (n.get(e) ?? 0) > 1);
|
|
1579
1579
|
}
|
|
1580
|
-
function
|
|
1580
|
+
function rr(e) {
|
|
1581
1581
|
return e.jsonID === "attr";
|
|
1582
1582
|
}
|
|
1583
|
-
function
|
|
1583
|
+
function ir(e) {
|
|
1584
1584
|
let t = !1;
|
|
1585
1585
|
if (e.getMap().forEach(() => {
|
|
1586
1586
|
t = !0;
|
|
1587
|
-
}), t ||
|
|
1587
|
+
}), t || rr(e)) return !0;
|
|
1588
1588
|
let n = e;
|
|
1589
1589
|
return typeof n.from == "number" && typeof n.to == "number";
|
|
1590
1590
|
}
|
|
1591
|
-
function
|
|
1591
|
+
function ar(e, t) {
|
|
1592
1592
|
let n = null, r = 0, i = 0;
|
|
1593
1593
|
for (let a = 0; a < e.childCount && !(i > t.to); a += 1) {
|
|
1594
1594
|
let o = i + e.child(a).nodeSize;
|
|
@@ -1599,11 +1599,11 @@ function nr(e, t) {
|
|
|
1599
1599
|
to: r
|
|
1600
1600
|
};
|
|
1601
1601
|
}
|
|
1602
|
-
function
|
|
1603
|
-
if (e.steps.some((e) => !
|
|
1604
|
-
let n =
|
|
1602
|
+
function or(e, t) {
|
|
1603
|
+
if (e.steps.some((e) => !ir(e))) return { type: "full" };
|
|
1604
|
+
let n = tn(e).map(({ newRange: e }) => e);
|
|
1605
1605
|
e.steps.forEach((t, r) => {
|
|
1606
|
-
if (!
|
|
1606
|
+
if (!rr(t)) return;
|
|
1607
1607
|
let i = e.mapping.slice(r);
|
|
1608
1608
|
n.push({
|
|
1609
1609
|
from: i.map(t.pos, -1),
|
|
@@ -1612,7 +1612,7 @@ function rr(e, t) {
|
|
|
1612
1612
|
});
|
|
1613
1613
|
let r = [];
|
|
1614
1614
|
for (let e of n) {
|
|
1615
|
-
let n =
|
|
1615
|
+
let n = ar(t, e);
|
|
1616
1616
|
n && r.push(n);
|
|
1617
1617
|
}
|
|
1618
1618
|
r.sort((e, t) => e.from - t.from);
|
|
@@ -1626,29 +1626,29 @@ function rr(e, t) {
|
|
|
1626
1626
|
ranges: i
|
|
1627
1627
|
};
|
|
1628
1628
|
}
|
|
1629
|
-
function
|
|
1629
|
+
function sr(e, t, n, r) {
|
|
1630
1630
|
return e.map(t, n, { onRemove: (e) => {
|
|
1631
1631
|
let t = e?.key;
|
|
1632
1632
|
typeof t == "string" && r.delete(t);
|
|
1633
1633
|
} });
|
|
1634
1634
|
}
|
|
1635
|
-
function
|
|
1636
|
-
let r = t.decorationSetsByExtension[e] ??
|
|
1635
|
+
function cr(e, t, n) {
|
|
1636
|
+
let r = t.decorationSetsByExtension[e] ?? C.empty, i = new Set(t.widgetKeysByExtension[e] ?? []);
|
|
1637
1637
|
return {
|
|
1638
|
-
set:
|
|
1638
|
+
set: sr(r, n.mapping, n.doc, i),
|
|
1639
1639
|
widgetKeys: i
|
|
1640
1640
|
};
|
|
1641
1641
|
}
|
|
1642
|
-
function
|
|
1642
|
+
function lr(e, t) {
|
|
1643
1643
|
let n = Object.values(t).flatMap((e) => e.find());
|
|
1644
|
-
return
|
|
1644
|
+
return C.create(e, n);
|
|
1645
1645
|
}
|
|
1646
|
-
function
|
|
1646
|
+
function ur(e) {
|
|
1647
1647
|
let t = /* @__PURE__ */ new Set();
|
|
1648
1648
|
for (let n of Object.values(e)) for (let e of n) t.add(e);
|
|
1649
1649
|
return t;
|
|
1650
1650
|
}
|
|
1651
|
-
function
|
|
1651
|
+
function dr(e, t) {
|
|
1652
1652
|
switch (t.update ?? "document") {
|
|
1653
1653
|
case "document":
|
|
1654
1654
|
if (t.createInRange) throw Error(`[tiptap error]: Extension "${e}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);
|
|
@@ -1663,21 +1663,21 @@ function cr(e, t) {
|
|
|
1663
1663
|
default: throw Error(`[tiptap error]: Extension "${e}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`);
|
|
1664
1664
|
}
|
|
1665
1665
|
}
|
|
1666
|
-
function
|
|
1666
|
+
function fr(e, t, n) {
|
|
1667
1667
|
return n ? !0 : e.update === "manual" ? !1 : e.shouldUpdate ? e.shouldUpdate(t) : t.tr.docChanged;
|
|
1668
1668
|
}
|
|
1669
|
-
var
|
|
1669
|
+
var pr = /* @__PURE__ */ new Set(), mr = class {
|
|
1670
1670
|
constructor(e) {
|
|
1671
1671
|
this.warnedWidgetKeys = /* @__PURE__ */ new Set(), this.warnedOutOfRangeExtensions = /* @__PURE__ */ new Set(), this.handleBeforeTransaction = ({ nextState: e }) => {
|
|
1672
|
-
let t =
|
|
1672
|
+
let t = K.getState(e);
|
|
1673
1673
|
t && this.warnDuplicateWidgetKeys(t);
|
|
1674
|
-
}, this.editor = e.editor, this.entries = this.resolveEntries(e.entries), this.entries.forEach(({ name: e, spec: t }) =>
|
|
1674
|
+
}, this.editor = e.editor, this.entries = this.resolveEntries(e.entries), this.entries.forEach(({ name: e, spec: t }) => dr(e, t)), this.plugin = this.entries.length > 0 ? this.createPlugin() : null, this.editor.on("beforeTransaction", this.handleBeforeTransaction);
|
|
1675
1675
|
}
|
|
1676
1676
|
destroy() {
|
|
1677
1677
|
this.editor.off("beforeTransaction", this.handleBeforeTransaction);
|
|
1678
1678
|
}
|
|
1679
1679
|
liveWidgetKeys() {
|
|
1680
|
-
return
|
|
1680
|
+
return K.getState(this.editor.state)?.widgetKeys ?? pr;
|
|
1681
1681
|
}
|
|
1682
1682
|
get mountedView() {
|
|
1683
1683
|
return this.editor.isDestroyed ? null : this.editor.view;
|
|
@@ -1695,8 +1695,8 @@ var ur = /* @__PURE__ */ new Set(), dr = class {
|
|
|
1695
1695
|
}
|
|
1696
1696
|
createPlugin() {
|
|
1697
1697
|
let { editor: e, entries: t } = this;
|
|
1698
|
-
return new
|
|
1699
|
-
key:
|
|
1698
|
+
return new r({
|
|
1699
|
+
key: K,
|
|
1700
1700
|
state: {
|
|
1701
1701
|
init: (e, n) => {
|
|
1702
1702
|
let r = {}, i = {};
|
|
@@ -1708,22 +1708,22 @@ var ur = /* @__PURE__ */ new Set(), dr = class {
|
|
|
1708
1708
|
decorationSetsByExtension: r,
|
|
1709
1709
|
widgetKeysByExtension: i,
|
|
1710
1710
|
mergedDecorationSet: this.buildMergedSet(n.doc, r),
|
|
1711
|
-
widgetKeys:
|
|
1711
|
+
widgetKeys: ur(i)
|
|
1712
1712
|
};
|
|
1713
1713
|
return this.warnDuplicateWidgetKeys(a), a;
|
|
1714
1714
|
},
|
|
1715
1715
|
apply: (n, r, i, a) => {
|
|
1716
|
-
let o = n.getMeta(
|
|
1717
|
-
return
|
|
1716
|
+
let o = n.getMeta(K), s = o?.type === "force" && !o.name, c = o?.type === "force" ? o.name : void 0, l = {}, u = {}, d = /* @__PURE__ */ new Set();
|
|
1717
|
+
return Kn(e, () => {
|
|
1718
1718
|
for (let { name: o, spec: f } of t) {
|
|
1719
1719
|
let t = s || c === o;
|
|
1720
|
-
if (!
|
|
1720
|
+
if (!fr(f, {
|
|
1721
1721
|
editor: e,
|
|
1722
1722
|
tr: n,
|
|
1723
1723
|
oldState: i,
|
|
1724
1724
|
newState: a
|
|
1725
1725
|
}, t)) {
|
|
1726
|
-
let e =
|
|
1726
|
+
let e = cr(o, r, n);
|
|
1727
1727
|
l[o] = e.set, u[o] = e.widgetKeys;
|
|
1728
1728
|
} else if (f.update === "changedRanges" && n.docChanged && !t) {
|
|
1729
1729
|
let e = this.applyChangedRangesRecompute(o, f, r, n, a);
|
|
@@ -1743,34 +1743,34 @@ var ur = /* @__PURE__ */ new Set(), dr = class {
|
|
|
1743
1743
|
decorationSetsByExtension: l,
|
|
1744
1744
|
recomputedNames: d
|
|
1745
1745
|
}),
|
|
1746
|
-
widgetKeys:
|
|
1746
|
+
widgetKeys: ur(u)
|
|
1747
1747
|
};
|
|
1748
1748
|
}
|
|
1749
1749
|
},
|
|
1750
1750
|
props: { decorations(e) {
|
|
1751
|
-
return
|
|
1751
|
+
return K.getState(e)?.mergedDecorationSet ?? C.empty;
|
|
1752
1752
|
} }
|
|
1753
1753
|
});
|
|
1754
1754
|
}
|
|
1755
1755
|
applyChangedRangesRecompute(e, t, n, r, i) {
|
|
1756
|
-
let a =
|
|
1756
|
+
let a = or(r, i.doc);
|
|
1757
1757
|
return a.type === "full" ? this.buildFullSet(e, t, i) : this.rebuildRanges(e, t, n, r, i, a.ranges);
|
|
1758
1758
|
}
|
|
1759
1759
|
rebuildRanges(e, t, n, r, i, a) {
|
|
1760
|
-
let o = n.decorationSetsByExtension[e] ??
|
|
1760
|
+
let o = n.decorationSetsByExtension[e] ?? C.empty, s = new Set(n.widgetKeysByExtension[e] ?? []), c = sr(o, r.mapping, r.doc, s), l = i.doc.content.size;
|
|
1761
1761
|
for (let { from: n, to: r } of a) {
|
|
1762
|
-
let a = c.find(n, r).filter((e) =>
|
|
1762
|
+
let a = c.find(n, r).filter((e) => $n({
|
|
1763
1763
|
position: e.from,
|
|
1764
1764
|
from: n,
|
|
1765
1765
|
to: r,
|
|
1766
1766
|
docSize: l
|
|
1767
1767
|
}));
|
|
1768
1768
|
for (let e of a) {
|
|
1769
|
-
let t =
|
|
1769
|
+
let t = tr(e);
|
|
1770
1770
|
t && s.delete(t);
|
|
1771
1771
|
}
|
|
1772
1772
|
c = c.remove(a);
|
|
1773
|
-
let { decorations: o, widgetKeys: u } =
|
|
1773
|
+
let { decorations: o, widgetKeys: u } = Zn(er({
|
|
1774
1774
|
decorations: this.runCreate(e, "createInRange", () => t.createInRange({
|
|
1775
1775
|
editor: this.editor,
|
|
1776
1776
|
state: i,
|
|
@@ -1798,7 +1798,7 @@ var ur = /* @__PURE__ */ new Set(), dr = class {
|
|
|
1798
1798
|
state: n,
|
|
1799
1799
|
view: this.mountedView
|
|
1800
1800
|
}));
|
|
1801
|
-
return
|
|
1801
|
+
return Qn(n.doc, r, e);
|
|
1802
1802
|
}
|
|
1803
1803
|
runCreate(e, t, n) {
|
|
1804
1804
|
try {
|
|
@@ -1808,12 +1808,12 @@ var ur = /* @__PURE__ */ new Set(), dr = class {
|
|
|
1808
1808
|
}
|
|
1809
1809
|
}
|
|
1810
1810
|
warnDuplicateWidgetKeys(e) {
|
|
1811
|
-
if (!
|
|
1811
|
+
if (!Yn) return;
|
|
1812
1812
|
if (e.widgetKeys.size === 0) {
|
|
1813
1813
|
this.warnedWidgetKeys.clear();
|
|
1814
1814
|
return;
|
|
1815
1815
|
}
|
|
1816
|
-
let t =
|
|
1816
|
+
let t = nr(e.mergedDecorationSet), n = new Set(t.map(({ key: e }) => e));
|
|
1817
1817
|
for (let { key: e, extensions: n } of t) {
|
|
1818
1818
|
if (this.warnedWidgetKeys.has(e)) continue;
|
|
1819
1819
|
let t = Array.from(n).map((e) => `"${e}"`).join(", ");
|
|
@@ -1823,36 +1823,36 @@ var ur = /* @__PURE__ */ new Set(), dr = class {
|
|
|
1823
1823
|
}
|
|
1824
1824
|
buildMergedSet(e, t) {
|
|
1825
1825
|
let n = Object.keys(t);
|
|
1826
|
-
return n.length === 1 ? t[n[0]] :
|
|
1826
|
+
return n.length === 1 ? t[n[0]] : lr(e, t);
|
|
1827
1827
|
}
|
|
1828
1828
|
mergeAfterApply({ entries: e, previous: t, tr: n, decorationSetsByExtension: r, recomputedNames: i }) {
|
|
1829
|
-
return e.length === 1 ? r[e[0].name] : i.size === 0 ? t.mergedDecorationSet.map(n.mapping, n.doc) :
|
|
1829
|
+
return e.length === 1 ? r[e[0].name] : i.size === 0 ? t.mergedDecorationSet.map(n.mapping, n.doc) : lr(n.doc, r);
|
|
1830
1830
|
}
|
|
1831
1831
|
};
|
|
1832
|
-
function
|
|
1833
|
-
let { selection:
|
|
1834
|
-
if (
|
|
1835
|
-
let e =
|
|
1836
|
-
return
|
|
1837
|
-
}
|
|
1838
|
-
let
|
|
1839
|
-
for (;
|
|
1840
|
-
let e =
|
|
1841
|
-
if (
|
|
1842
|
-
--
|
|
1832
|
+
function hr(e, t) {
|
|
1833
|
+
let { selection: r } = e, { $from: i } = r;
|
|
1834
|
+
if (r instanceof n) {
|
|
1835
|
+
let e = i.index();
|
|
1836
|
+
return i.parent.canReplaceWith(e, e + 1, t);
|
|
1837
|
+
}
|
|
1838
|
+
let a = i.depth;
|
|
1839
|
+
for (; a >= 0;) {
|
|
1840
|
+
let e = i.index(a);
|
|
1841
|
+
if (i.node(a).contentMatchAt(e).matchType(t)) return !0;
|
|
1842
|
+
--a;
|
|
1843
1843
|
}
|
|
1844
1844
|
return !1;
|
|
1845
1845
|
}
|
|
1846
|
-
function
|
|
1846
|
+
function gr(e, t, n) {
|
|
1847
1847
|
let r = document.querySelector(`style[data-tiptap-style${n ? `-${n}` : ""}]`);
|
|
1848
1848
|
if (r !== null) return r;
|
|
1849
1849
|
let i = document.createElement("style");
|
|
1850
1850
|
return t && i.setAttribute("nonce", t), i.setAttribute(`data-tiptap-style${n ? `-${n}` : ""}`, ""), i.innerHTML = e, document.getElementsByTagName("head")[0].appendChild(i), i;
|
|
1851
1851
|
}
|
|
1852
|
-
function
|
|
1852
|
+
function _r(e) {
|
|
1853
1853
|
return e.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
1854
1854
|
}
|
|
1855
|
-
function
|
|
1855
|
+
function vr(e, t) {
|
|
1856
1856
|
let n = e.getAttribute("style");
|
|
1857
1857
|
if (!n) return null;
|
|
1858
1858
|
let r = n.split(";").map((e) => e.trim()).filter(Boolean), i = t.toLowerCase();
|
|
@@ -1862,19 +1862,19 @@ function hr(e, t) {
|
|
|
1862
1862
|
}
|
|
1863
1863
|
return null;
|
|
1864
1864
|
}
|
|
1865
|
-
function
|
|
1865
|
+
function yr() {
|
|
1866
1866
|
return typeof navigator < "u" && /Firefox/.test(navigator.userAgent);
|
|
1867
1867
|
}
|
|
1868
|
-
function
|
|
1868
|
+
function br(e) {
|
|
1869
1869
|
return typeof e == "number";
|
|
1870
1870
|
}
|
|
1871
|
-
function
|
|
1871
|
+
function xr(e) {
|
|
1872
1872
|
return Object.prototype.toString.call(e).slice(8, -1);
|
|
1873
1873
|
}
|
|
1874
|
-
function
|
|
1875
|
-
return
|
|
1874
|
+
function J(e) {
|
|
1875
|
+
return xr(e) === "Object" && e.constructor === Object && Object.getPrototypeOf(e) === Object.prototype;
|
|
1876
1876
|
}
|
|
1877
|
-
function
|
|
1877
|
+
function Sr(e, t, n) {
|
|
1878
1878
|
let r = e.split("\n"), i = [], a = "", o = 0, s = t.baseIndentSize || 2;
|
|
1879
1879
|
for (; o < r.length;) {
|
|
1880
1880
|
let e = r[o], u = e.match(t.itemPattern);
|
|
@@ -1910,21 +1910,21 @@ function yr(e, t, n) {
|
|
|
1910
1910
|
let e = g.map((e) => e.slice(f + s)).join("\n");
|
|
1911
1911
|
e.trim() && (h = t.customNestedParser ? t.customNestedParser(e) : n.blockTokens(e));
|
|
1912
1912
|
}
|
|
1913
|
-
let
|
|
1914
|
-
i.push(
|
|
1913
|
+
let _ = t.createToken(d, h);
|
|
1914
|
+
i.push(_);
|
|
1915
1915
|
}
|
|
1916
1916
|
if (i.length !== 0) return {
|
|
1917
1917
|
items: i,
|
|
1918
1918
|
raw: a
|
|
1919
1919
|
};
|
|
1920
1920
|
}
|
|
1921
|
-
var
|
|
1922
|
-
function
|
|
1921
|
+
var Cr = 4;
|
|
1922
|
+
function wr(e) {
|
|
1923
1923
|
let t = 0;
|
|
1924
|
-
for (let n of e) t = n === " " ? t +
|
|
1924
|
+
for (let n of e) t = n === " " ? t + Cr - t % Cr : t + 1;
|
|
1925
1925
|
return t;
|
|
1926
1926
|
}
|
|
1927
|
-
function
|
|
1927
|
+
function Tr(e, t, n, r, i) {
|
|
1928
1928
|
if (!e || !Array.isArray(e.content)) return "";
|
|
1929
1929
|
let a = typeof n == "function" ? n(r) : n, [o, ...s] = e.content, c = `${a}${t.renderChildren([o])}`;
|
|
1930
1930
|
return s && s.length > 0 && s.forEach((e, n) => {
|
|
@@ -1932,20 +1932,20 @@ function Sr(e, t, n, r, i) {
|
|
|
1932
1932
|
if (r != null) {
|
|
1933
1933
|
let n = (e) => {
|
|
1934
1934
|
if (!i?.alignNestedToPrefix) return t.indent(e);
|
|
1935
|
-
let n = t.indent(""), r =
|
|
1936
|
-
return (
|
|
1935
|
+
let n = t.indent(""), r = wr(a);
|
|
1936
|
+
return (wr(n) >= r ? n : " ".repeat(r)) + e;
|
|
1937
1937
|
}, o = r.split("\n").map((e) => n(e || "")).join("\n");
|
|
1938
1938
|
c += e.type === "paragraph" ? `\n\n${o}` : `\n${o}`;
|
|
1939
1939
|
}
|
|
1940
1940
|
}), c;
|
|
1941
1941
|
}
|
|
1942
|
-
function
|
|
1942
|
+
function Er(e, t) {
|
|
1943
1943
|
let n = { ...e };
|
|
1944
|
-
return
|
|
1945
|
-
|
|
1944
|
+
return J(e) && J(t) && Object.keys(t).forEach((r) => {
|
|
1945
|
+
J(t[r]) && J(e[r]) ? n[r] = Er(e[r], t[r]) : n[r] = t[r];
|
|
1946
1946
|
}), n;
|
|
1947
1947
|
}
|
|
1948
|
-
function
|
|
1948
|
+
function Dr(e, t, n = {}) {
|
|
1949
1949
|
let { state: r } = t, { doc: i, tr: a } = r, o = e;
|
|
1950
1950
|
i.descendants((t, r) => {
|
|
1951
1951
|
let i = a.mapping.map(r), s = a.mapping.map(r) + t.nodeSize, c = null;
|
|
@@ -1965,39 +1965,39 @@ function wr(e, t, n = {}) {
|
|
|
1965
1965
|
}
|
|
1966
1966
|
}), a.docChanged && t.view.dispatch(a);
|
|
1967
1967
|
}
|
|
1968
|
-
var
|
|
1968
|
+
var Y = class {
|
|
1969
1969
|
constructor(e) {
|
|
1970
1970
|
this.find = e.find, this.handler = e.handler, this.undoable = e.undoable ?? !0;
|
|
1971
1971
|
}
|
|
1972
|
-
},
|
|
1973
|
-
if (
|
|
1972
|
+
}, Or = (e, t) => {
|
|
1973
|
+
if (Re(t)) return t.exec(e);
|
|
1974
1974
|
let n = t(e);
|
|
1975
1975
|
if (!n) return null;
|
|
1976
1976
|
let r = [n.text];
|
|
1977
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;
|
|
1978
1978
|
};
|
|
1979
|
-
function
|
|
1979
|
+
function X(e) {
|
|
1980
1980
|
let { editor: t, from: n, to: r, text: i, rules: a, plugin: o } = e, { view: s } = t;
|
|
1981
1981
|
if (s.composing) return !1;
|
|
1982
1982
|
let c = s.state.doc.resolve(n);
|
|
1983
1983
|
if (c.parent.type.spec.code || (c.nodeBefore || c.nodeAfter)?.marks.find((e) => e.type.spec.code)) return !1;
|
|
1984
|
-
let l = !1, u =
|
|
1984
|
+
let l = !1, u = an(c) + i;
|
|
1985
1985
|
return a.forEach((e) => {
|
|
1986
1986
|
if (l) return;
|
|
1987
|
-
let a =
|
|
1987
|
+
let a = Or(u, e.find);
|
|
1988
1988
|
if (!a) return;
|
|
1989
1989
|
let d = a[0].length - i.length;
|
|
1990
1990
|
if (d > 0) {
|
|
1991
1991
|
let e = c.parentOffset - d;
|
|
1992
1992
|
if (e < 0 || c.parent.textBetween(e, c.parentOffset) !== a[0].slice(0, d)) return;
|
|
1993
1993
|
}
|
|
1994
|
-
let f = s.state.tr, p =
|
|
1994
|
+
let f = s.state.tr, p = w({
|
|
1995
1995
|
state: s.state,
|
|
1996
1996
|
transaction: f
|
|
1997
1997
|
}), m = {
|
|
1998
1998
|
from: n - (a[0].length - i.length),
|
|
1999
1999
|
to: r
|
|
2000
|
-
}, { commands: h, chain: g, can:
|
|
2000
|
+
}, { commands: h, chain: g, can: _ } = new T({
|
|
2001
2001
|
editor: t,
|
|
2002
2002
|
state: p
|
|
2003
2003
|
});
|
|
@@ -2007,7 +2007,7 @@ function Er(e) {
|
|
|
2007
2007
|
match: a,
|
|
2008
2008
|
commands: h,
|
|
2009
2009
|
chain: g,
|
|
2010
|
-
can:
|
|
2010
|
+
can: _
|
|
2011
2011
|
}) !== null && f.steps.length && (e.undoable && f.setMeta(o, {
|
|
2012
2012
|
transform: f,
|
|
2013
2013
|
from: n,
|
|
@@ -2016,71 +2016,71 @@ function Er(e) {
|
|
|
2016
2016
|
}), s.dispatch(f), l = !0);
|
|
2017
2017
|
}), l;
|
|
2018
2018
|
}
|
|
2019
|
-
function
|
|
2020
|
-
let { editor: t, rules: n } = e,
|
|
2019
|
+
function kr(e) {
|
|
2020
|
+
let { editor: t, rules: n } = e, i = new r({
|
|
2021
2021
|
state: {
|
|
2022
2022
|
init() {
|
|
2023
2023
|
return null;
|
|
2024
2024
|
},
|
|
2025
|
-
apply(e,
|
|
2026
|
-
let o = e.getMeta(
|
|
2025
|
+
apply(e, r, a) {
|
|
2026
|
+
let o = e.getMeta(i);
|
|
2027
2027
|
if (o) return o;
|
|
2028
2028
|
let s = e.getMeta("applyInputRules");
|
|
2029
2029
|
return s && setTimeout(() => {
|
|
2030
2030
|
let { text: e } = s;
|
|
2031
|
-
e = typeof e == "string" ? e :
|
|
2032
|
-
let { from:
|
|
2033
|
-
|
|
2031
|
+
e = typeof e == "string" ? e : Pt(S.from(e), a.schema);
|
|
2032
|
+
let { from: r } = s, o = r + e.length;
|
|
2033
|
+
X({
|
|
2034
2034
|
editor: t,
|
|
2035
|
-
from:
|
|
2035
|
+
from: r,
|
|
2036
2036
|
to: o,
|
|
2037
2037
|
text: e,
|
|
2038
2038
|
rules: n,
|
|
2039
|
-
plugin:
|
|
2039
|
+
plugin: i
|
|
2040
2040
|
});
|
|
2041
|
-
}), e.selectionSet || e.docChanged ? null :
|
|
2041
|
+
}), e.selectionSet || e.docChanged ? null : r;
|
|
2042
2042
|
}
|
|
2043
2043
|
},
|
|
2044
2044
|
props: {
|
|
2045
|
-
handleTextInput(e,
|
|
2046
|
-
return
|
|
2045
|
+
handleTextInput(e, r, a, o) {
|
|
2046
|
+
return X({
|
|
2047
2047
|
editor: t,
|
|
2048
|
-
from:
|
|
2048
|
+
from: r,
|
|
2049
2049
|
to: a,
|
|
2050
2050
|
text: o,
|
|
2051
2051
|
rules: n,
|
|
2052
|
-
plugin:
|
|
2052
|
+
plugin: i
|
|
2053
2053
|
});
|
|
2054
2054
|
},
|
|
2055
2055
|
handleDOMEvents: { compositionend: (e) => (setTimeout(() => {
|
|
2056
|
-
let { $cursor:
|
|
2057
|
-
|
|
2056
|
+
let { $cursor: r } = e.state.selection;
|
|
2057
|
+
r && X({
|
|
2058
2058
|
editor: t,
|
|
2059
|
-
from:
|
|
2060
|
-
to:
|
|
2059
|
+
from: r.pos,
|
|
2060
|
+
to: r.pos,
|
|
2061
2061
|
text: "",
|
|
2062
2062
|
rules: n,
|
|
2063
|
-
plugin:
|
|
2063
|
+
plugin: i
|
|
2064
2064
|
});
|
|
2065
2065
|
}), !1) },
|
|
2066
|
-
handleKeyDown(e,
|
|
2067
|
-
if (
|
|
2066
|
+
handleKeyDown(e, r) {
|
|
2067
|
+
if (r.key !== "Enter") return !1;
|
|
2068
2068
|
let { $cursor: a } = e.state.selection;
|
|
2069
|
-
return a ?
|
|
2069
|
+
return a ? X({
|
|
2070
2070
|
editor: t,
|
|
2071
2071
|
from: a.pos,
|
|
2072
2072
|
to: a.pos,
|
|
2073
2073
|
text: "\n",
|
|
2074
2074
|
rules: n,
|
|
2075
|
-
plugin:
|
|
2075
|
+
plugin: i
|
|
2076
2076
|
}) : !1;
|
|
2077
2077
|
}
|
|
2078
2078
|
},
|
|
2079
2079
|
isInputRules: !0
|
|
2080
2080
|
});
|
|
2081
|
-
return
|
|
2081
|
+
return i;
|
|
2082
2082
|
}
|
|
2083
|
-
var
|
|
2083
|
+
var Ar = class {
|
|
2084
2084
|
constructor(e = {}) {
|
|
2085
2085
|
this.type = "extendable", this.parent = null, this.child = null, this.name = "", this.config = { name: this.name }, this.config = {
|
|
2086
2086
|
...this.config,
|
|
@@ -2088,10 +2088,10 @@ var Or = class {
|
|
|
2088
2088
|
}, this.name = this.config.name;
|
|
2089
2089
|
}
|
|
2090
2090
|
get options() {
|
|
2091
|
-
return { ...
|
|
2091
|
+
return { ...R(L(this, "addOptions", { name: this.name })) };
|
|
2092
2092
|
}
|
|
2093
2093
|
get storage() {
|
|
2094
|
-
return { ...
|
|
2094
|
+
return { ...R(L(this, "addStorage", {
|
|
2095
2095
|
name: this.name,
|
|
2096
2096
|
options: this.options
|
|
2097
2097
|
})) };
|
|
@@ -2099,7 +2099,7 @@ var Or = class {
|
|
|
2099
2099
|
configure(e = {}) {
|
|
2100
2100
|
let t = this.extend({
|
|
2101
2101
|
...this.config,
|
|
2102
|
-
addOptions: () =>
|
|
2102
|
+
addOptions: () => Er(this.options, e)
|
|
2103
2103
|
});
|
|
2104
2104
|
return t.name = this.name, t.parent = this.parent, this.child = null, t;
|
|
2105
2105
|
}
|
|
@@ -2110,7 +2110,7 @@ var Or = class {
|
|
|
2110
2110
|
});
|
|
2111
2111
|
return t.parent = this, this.child = t, t.name = "name" in e ? e.name : t.parent.name, t;
|
|
2112
2112
|
}
|
|
2113
|
-
},
|
|
2113
|
+
}, jr = class e extends Ar {
|
|
2114
2114
|
constructor(...e) {
|
|
2115
2115
|
super(...e), this.type = "mark";
|
|
2116
2116
|
}
|
|
@@ -2135,20 +2135,20 @@ var Or = class {
|
|
|
2135
2135
|
let t = typeof e == "function" ? e() : e;
|
|
2136
2136
|
return super.extend(t);
|
|
2137
2137
|
}
|
|
2138
|
-
},
|
|
2138
|
+
}, Mr = class {
|
|
2139
2139
|
constructor(e) {
|
|
2140
2140
|
this.find = e.find, this.handler = e.handler;
|
|
2141
2141
|
}
|
|
2142
|
-
},
|
|
2143
|
-
if (
|
|
2142
|
+
}, Nr = (e, t, n) => {
|
|
2143
|
+
if (Re(t)) return [...e.matchAll(t)];
|
|
2144
2144
|
let r = t(e, n);
|
|
2145
2145
|
return r ? r.map((t) => {
|
|
2146
2146
|
let n = [t.text];
|
|
2147
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;
|
|
2148
2148
|
}) : [];
|
|
2149
2149
|
};
|
|
2150
|
-
function
|
|
2151
|
-
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 Pr(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 T({
|
|
2152
2152
|
editor: t,
|
|
2153
2153
|
state: n
|
|
2154
2154
|
}), d = [];
|
|
@@ -2156,7 +2156,7 @@ function Mr(e) {
|
|
|
2156
2156
|
var f;
|
|
2157
2157
|
if ((f = e.type) != null && (f = f.spec) != null && f.code || !(e.isText || e.isTextblock || e.isInline)) return;
|
|
2158
2158
|
let p = e.content?.size ?? e.nodeSize ?? 0, m = Math.max(r, t), h = Math.min(i, t + p);
|
|
2159
|
-
m >= h ||
|
|
2159
|
+
m >= h || Nr(e.isText ? e.text || "" : e.textBetween(m - t, h - t, void 0, ""), a.find, o).forEach((e) => {
|
|
2160
2160
|
if (e.index === void 0) return;
|
|
2161
2161
|
let t = m + e.index + 1, r = t + e[0].length, i = {
|
|
2162
2162
|
from: n.tr.mapping.map(t),
|
|
@@ -2175,55 +2175,55 @@ function Mr(e) {
|
|
|
2175
2175
|
});
|
|
2176
2176
|
}), d.every((e) => e !== null);
|
|
2177
2177
|
}
|
|
2178
|
-
var
|
|
2178
|
+
var Z = null, Fr = (e) => {
|
|
2179
2179
|
var t;
|
|
2180
2180
|
let n = new ClipboardEvent("paste", { clipboardData: new DataTransfer() });
|
|
2181
2181
|
return (t = n.clipboardData) == null || t.setData("text/html", e), n;
|
|
2182
2182
|
};
|
|
2183
|
-
function
|
|
2184
|
-
let { editor: t, rules: n } = e,
|
|
2183
|
+
function Ir(e) {
|
|
2184
|
+
let { editor: t, rules: n } = e, i = null, a = !1, o = !1, s = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, c;
|
|
2185
2185
|
try {
|
|
2186
|
-
|
|
2186
|
+
c = typeof DragEvent < "u" ? new DragEvent("drop") : null;
|
|
2187
2187
|
} catch {
|
|
2188
|
-
|
|
2188
|
+
c = null;
|
|
2189
2189
|
}
|
|
2190
|
-
let
|
|
2191
|
-
let
|
|
2190
|
+
let l = ({ state: e, from: n, to: r, rule: i, pasteEvt: a }) => {
|
|
2191
|
+
let o = e.tr, l = w({
|
|
2192
2192
|
state: e,
|
|
2193
|
-
transaction:
|
|
2193
|
+
transaction: o
|
|
2194
2194
|
});
|
|
2195
|
-
if (
|
|
2195
|
+
if (Pr({
|
|
2196
2196
|
editor: t,
|
|
2197
2197
|
state: l,
|
|
2198
2198
|
from: Math.max(n - 1, 0),
|
|
2199
2199
|
to: r.b - 1,
|
|
2200
2200
|
rule: i,
|
|
2201
2201
|
pasteEvent: a,
|
|
2202
|
-
dropEvent:
|
|
2203
|
-
}) &&
|
|
2202
|
+
dropEvent: c
|
|
2203
|
+
}) && o.steps.length) {
|
|
2204
2204
|
try {
|
|
2205
|
-
|
|
2205
|
+
c = typeof DragEvent < "u" ? new DragEvent("drop") : null;
|
|
2206
2206
|
} catch {
|
|
2207
|
-
|
|
2207
|
+
c = null;
|
|
2208
2208
|
}
|
|
2209
|
-
return
|
|
2209
|
+
return s = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, o;
|
|
2210
2210
|
}
|
|
2211
2211
|
};
|
|
2212
|
-
return n.map((e) => new
|
|
2212
|
+
return n.map((e) => new r({
|
|
2213
2213
|
view(e) {
|
|
2214
2214
|
let n = (n) => {
|
|
2215
|
-
|
|
2216
|
-
},
|
|
2217
|
-
|
|
2215
|
+
i = e.dom.parentElement?.contains(n.target) ? e.dom.parentElement : null, i && (Z = t);
|
|
2216
|
+
}, r = () => {
|
|
2217
|
+
Z &&= null;
|
|
2218
2218
|
};
|
|
2219
|
-
return window.addEventListener("dragstart", n), window.addEventListener("dragend",
|
|
2220
|
-
window.removeEventListener("dragstart", n), window.removeEventListener("dragend",
|
|
2219
|
+
return window.addEventListener("dragstart", n), window.addEventListener("dragend", r), { destroy() {
|
|
2220
|
+
window.removeEventListener("dragstart", n), window.removeEventListener("dragend", r);
|
|
2221
2221
|
} };
|
|
2222
2222
|
},
|
|
2223
2223
|
props: { handleDOMEvents: {
|
|
2224
2224
|
drop: (e, t) => {
|
|
2225
|
-
if (
|
|
2226
|
-
let e =
|
|
2225
|
+
if (o = i === e.dom.parentElement, c = t, !o) {
|
|
2226
|
+
let e = Z;
|
|
2227
2227
|
e?.isEditable && setTimeout(() => {
|
|
2228
2228
|
let t = e.state.selection;
|
|
2229
2229
|
t && e.commands.deleteRange({
|
|
@@ -2236,17 +2236,17 @@ function Fr(e) {
|
|
|
2236
2236
|
},
|
|
2237
2237
|
paste: (e, t) => {
|
|
2238
2238
|
let n = t.clipboardData?.getData("text/html");
|
|
2239
|
-
return
|
|
2239
|
+
return s = t, a = !!n?.includes("data-pm-slice"), !1;
|
|
2240
2240
|
}
|
|
2241
2241
|
} },
|
|
2242
2242
|
appendTransaction: (t, n, r) => {
|
|
2243
|
-
let
|
|
2244
|
-
if (!
|
|
2243
|
+
let i = t[0], c = i.getMeta("uiEvent") === "paste" && !a, u = i.getMeta("uiEvent") === "drop" && !o, d = i.getMeta("applyPasteRules"), f = !!d;
|
|
2244
|
+
if (!c && !u && !f) return;
|
|
2245
2245
|
if (f) {
|
|
2246
2246
|
let { text: t } = d;
|
|
2247
|
-
t = typeof t == "string" ? t :
|
|
2248
|
-
let { from: n } = d, i = n + t.length, a =
|
|
2249
|
-
return
|
|
2247
|
+
t = typeof t == "string" ? t : Pt(S.from(t), r.schema);
|
|
2248
|
+
let { from: n } = d, i = n + t.length, a = Fr(t);
|
|
2249
|
+
return l({
|
|
2250
2250
|
rule: e,
|
|
2251
2251
|
state: r,
|
|
2252
2252
|
from: n,
|
|
@@ -2255,28 +2255,28 @@ function Fr(e) {
|
|
|
2255
2255
|
});
|
|
2256
2256
|
}
|
|
2257
2257
|
let p = n.doc.content.findDiffStart(r.doc.content), m = n.doc.content.findDiffEnd(r.doc.content);
|
|
2258
|
-
if (
|
|
2258
|
+
if (br(p) && m && p !== m.b) return l({
|
|
2259
2259
|
rule: e,
|
|
2260
2260
|
state: r,
|
|
2261
2261
|
from: p,
|
|
2262
2262
|
to: m,
|
|
2263
|
-
pasteEvt:
|
|
2263
|
+
pasteEvt: s
|
|
2264
2264
|
});
|
|
2265
2265
|
}
|
|
2266
2266
|
}));
|
|
2267
2267
|
}
|
|
2268
|
-
var
|
|
2268
|
+
var Q = class {
|
|
2269
2269
|
constructor(e, t) {
|
|
2270
|
-
this.splittableMarks = [], this.nonClearableMarks = [], this.decorationManager = null, this.editor = t, this.baseExtensions = e, this.extensions =
|
|
2270
|
+
this.splittableMarks = [], this.nonClearableMarks = [], this.decorationManager = null, this.editor = t, this.baseExtensions = e, this.extensions = qt(e), this.schema = Gt(this.extensions, t), this.setupExtensions();
|
|
2271
2271
|
}
|
|
2272
2272
|
get commands() {
|
|
2273
2273
|
return this.extensions.reduce((e, t) => {
|
|
2274
|
-
let n =
|
|
2274
|
+
let n = L(t, "addCommands", {
|
|
2275
2275
|
name: t.name,
|
|
2276
2276
|
options: t.options,
|
|
2277
2277
|
storage: this.editor.extensionStorage[t.name],
|
|
2278
2278
|
editor: this.editor,
|
|
2279
|
-
type:
|
|
2279
|
+
type: U(t.name, this.schema)
|
|
2280
2280
|
});
|
|
2281
2281
|
return n ? {
|
|
2282
2282
|
...e,
|
|
@@ -2285,15 +2285,15 @@ var Ir = class {
|
|
|
2285
2285
|
}, {});
|
|
2286
2286
|
}
|
|
2287
2287
|
get plugins() {
|
|
2288
|
-
let { editor: e } = this, t =
|
|
2288
|
+
let { editor: e } = this, t = V([...this.extensions].reverse()).flatMap((t) => {
|
|
2289
2289
|
let n = {
|
|
2290
2290
|
name: t.name,
|
|
2291
2291
|
options: t.options,
|
|
2292
2292
|
storage: this.editor.extensionStorage[t.name],
|
|
2293
2293
|
editor: e,
|
|
2294
|
-
type:
|
|
2295
|
-
}, r = [], i =
|
|
2296
|
-
if (t.type === "mark" &&
|
|
2294
|
+
type: U(t.name, this.schema)
|
|
2295
|
+
}, r = [], i = L(t, "addKeyboardShortcuts", n), a = {};
|
|
2296
|
+
if (t.type === "mark" && L(t, "exitable", n) && (a.ArrowRight = () => jr.handleExit({
|
|
2297
2297
|
editor: e,
|
|
2298
2298
|
mark: t
|
|
2299
2299
|
})), i) {
|
|
@@ -2303,31 +2303,31 @@ var Ir = class {
|
|
|
2303
2303
|
...t
|
|
2304
2304
|
};
|
|
2305
2305
|
}
|
|
2306
|
-
let o =
|
|
2306
|
+
let o = be(a);
|
|
2307
2307
|
r.push(o);
|
|
2308
|
-
let s =
|
|
2309
|
-
if (
|
|
2308
|
+
let s = L(t, "addInputRules", n);
|
|
2309
|
+
if (un(t, e.options.enableInputRules) && s) {
|
|
2310
2310
|
let t = s();
|
|
2311
2311
|
if (t && t.length) {
|
|
2312
|
-
let n =
|
|
2312
|
+
let n = kr({
|
|
2313
2313
|
editor: e,
|
|
2314
2314
|
rules: t
|
|
2315
2315
|
}), i = Array.isArray(n) ? n : [n];
|
|
2316
2316
|
r.push(...i);
|
|
2317
2317
|
}
|
|
2318
2318
|
}
|
|
2319
|
-
let c =
|
|
2320
|
-
if (
|
|
2319
|
+
let c = L(t, "addPasteRules", n);
|
|
2320
|
+
if (un(t, e.options.enablePasteRules) && c) {
|
|
2321
2321
|
let t = c();
|
|
2322
2322
|
if (t && t.length) {
|
|
2323
|
-
let n =
|
|
2323
|
+
let n = Ir({
|
|
2324
2324
|
editor: e,
|
|
2325
2325
|
rules: t
|
|
2326
2326
|
});
|
|
2327
2327
|
r.push(...n);
|
|
2328
2328
|
}
|
|
2329
2329
|
}
|
|
2330
|
-
let l =
|
|
2330
|
+
let l = L(t, "addProseMirrorPlugins", n);
|
|
2331
2331
|
if (l) {
|
|
2332
2332
|
let e = l();
|
|
2333
2333
|
r.push(...e);
|
|
@@ -2342,39 +2342,39 @@ var Ir = class {
|
|
|
2342
2342
|
(e = this.decorationManager) == null || e.destroy();
|
|
2343
2343
|
let n = [];
|
|
2344
2344
|
return this.extensions.forEach((e) => {
|
|
2345
|
-
let r =
|
|
2345
|
+
let r = L(e, "addDecorations", {
|
|
2346
2346
|
name: e.name,
|
|
2347
2347
|
options: e.options,
|
|
2348
2348
|
storage: this.editor.extensionStorage[e.name],
|
|
2349
2349
|
editor: t,
|
|
2350
|
-
type:
|
|
2350
|
+
type: U(e.name, this.schema)
|
|
2351
2351
|
});
|
|
2352
2352
|
r && n.push({
|
|
2353
2353
|
name: e.name,
|
|
2354
2354
|
addDecorations: r
|
|
2355
2355
|
});
|
|
2356
|
-
}), this.decorationManager = new
|
|
2356
|
+
}), this.decorationManager = new mr({
|
|
2357
2357
|
editor: t,
|
|
2358
2358
|
entries: n
|
|
2359
2359
|
}), this.decorationManager.plugin;
|
|
2360
2360
|
}
|
|
2361
2361
|
get attributes() {
|
|
2362
|
-
return
|
|
2362
|
+
return Lt(this.extensions);
|
|
2363
2363
|
}
|
|
2364
2364
|
get nodeViews() {
|
|
2365
|
-
let { editor: e } = this, { nodeExtensions: t } =
|
|
2366
|
-
return Object.fromEntries(t.filter((e) => !!
|
|
2367
|
-
let n = this.attributes.filter((e) => e.type === t.name), r =
|
|
2365
|
+
let { editor: e } = this, { nodeExtensions: t } = z(this.extensions);
|
|
2366
|
+
return Object.fromEntries(t.filter((e) => !!L(e, "addNodeView")).map((t) => {
|
|
2367
|
+
let n = this.attributes.filter((e) => e.type === t.name), r = L(t, "addNodeView", {
|
|
2368
2368
|
name: t.name,
|
|
2369
2369
|
options: t.options,
|
|
2370
2370
|
storage: this.editor.extensionStorage[t.name],
|
|
2371
2371
|
editor: e,
|
|
2372
|
-
type:
|
|
2372
|
+
type: E(t.name, this.schema)
|
|
2373
2373
|
});
|
|
2374
2374
|
if (!r) return [];
|
|
2375
2375
|
let i = r();
|
|
2376
2376
|
return i ? [t.name, (r, a, o, s, c) => {
|
|
2377
|
-
let l =
|
|
2377
|
+
let l = B(r, n);
|
|
2378
2378
|
return i({
|
|
2379
2379
|
node: r,
|
|
2380
2380
|
view: a,
|
|
@@ -2390,14 +2390,14 @@ var Ir = class {
|
|
|
2390
2390
|
}
|
|
2391
2391
|
dispatchTransaction(e) {
|
|
2392
2392
|
let { editor: t } = this;
|
|
2393
|
-
return
|
|
2393
|
+
return V([...this.extensions].reverse()).reduceRight((e, n) => {
|
|
2394
2394
|
let r = {
|
|
2395
2395
|
name: n.name,
|
|
2396
2396
|
options: n.options,
|
|
2397
2397
|
storage: this.editor.extensionStorage[n.name],
|
|
2398
2398
|
editor: t,
|
|
2399
|
-
type:
|
|
2400
|
-
}, i =
|
|
2399
|
+
type: U(n.name, this.schema)
|
|
2400
|
+
}, i = L(n, "dispatchTransaction", r);
|
|
2401
2401
|
return i ? (t) => {
|
|
2402
2402
|
i.call(r, {
|
|
2403
2403
|
transaction: t,
|
|
@@ -2408,14 +2408,14 @@ var Ir = class {
|
|
|
2408
2408
|
}
|
|
2409
2409
|
transformPastedHTML(e) {
|
|
2410
2410
|
let { editor: t } = this;
|
|
2411
|
-
return
|
|
2411
|
+
return V([...this.extensions]).reduce((e, n) => {
|
|
2412
2412
|
let r = {
|
|
2413
2413
|
name: n.name,
|
|
2414
2414
|
options: n.options,
|
|
2415
2415
|
storage: this.editor.extensionStorage[n.name],
|
|
2416
2416
|
editor: t,
|
|
2417
|
-
type:
|
|
2418
|
-
}, i =
|
|
2417
|
+
type: U(n.name, this.schema)
|
|
2418
|
+
}, i = L(n, "transformPastedHTML", r);
|
|
2419
2419
|
return i ? (t, n) => {
|
|
2420
2420
|
let a = e(t, n);
|
|
2421
2421
|
return i.call(r, a);
|
|
@@ -2423,17 +2423,17 @@ var Ir = class {
|
|
|
2423
2423
|
}, e || ((e) => e));
|
|
2424
2424
|
}
|
|
2425
2425
|
get markViews() {
|
|
2426
|
-
let { editor: e } = this, { markExtensions: t } =
|
|
2427
|
-
return Object.fromEntries(t.filter((e) => !!
|
|
2428
|
-
let n = this.attributes.filter((e) => e.type === t.name), r =
|
|
2426
|
+
let { editor: e } = this, { markExtensions: t } = z(this.extensions);
|
|
2427
|
+
return Object.fromEntries(t.filter((e) => !!L(e, "addMarkView")).map((t) => {
|
|
2428
|
+
let n = this.attributes.filter((e) => e.type === t.name), r = L(t, "addMarkView", {
|
|
2429
2429
|
name: t.name,
|
|
2430
2430
|
options: t.options,
|
|
2431
2431
|
storage: this.editor.extensionStorage[t.name],
|
|
2432
2432
|
editor: e,
|
|
2433
|
-
type:
|
|
2433
|
+
type: k(t.name, this.schema)
|
|
2434
2434
|
});
|
|
2435
2435
|
return r ? [t.name, (i, a, o) => {
|
|
2436
|
-
let s =
|
|
2436
|
+
let s = B(i, n);
|
|
2437
2437
|
return r()({
|
|
2438
2438
|
mark: i,
|
|
2439
2439
|
view: a,
|
|
@@ -2442,7 +2442,7 @@ var Ir = class {
|
|
|
2442
2442
|
extension: t,
|
|
2443
2443
|
HTMLAttributes: s,
|
|
2444
2444
|
updateAttributes: (t) => {
|
|
2445
|
-
|
|
2445
|
+
Dr(i, e, t);
|
|
2446
2446
|
}
|
|
2447
2447
|
});
|
|
2448
2448
|
}] : [];
|
|
@@ -2466,16 +2466,16 @@ var Ir = class {
|
|
|
2466
2466
|
options: e.options,
|
|
2467
2467
|
storage: this.editor.extensionStorage[e.name],
|
|
2468
2468
|
editor: this.editor,
|
|
2469
|
-
type:
|
|
2469
|
+
type: U(e.name, this.schema)
|
|
2470
2470
|
};
|
|
2471
|
-
e.type === "mark" && ((
|
|
2472
|
-
let n =
|
|
2471
|
+
e.type === "mark" && ((R(L(e, "keepOnSplit", t)) ?? !0) && this.splittableMarks.push(e.name), (R(L(e, "clearable", t)) ?? !0) || this.nonClearableMarks.push(e.name));
|
|
2472
|
+
let n = L(e, "onBeforeCreate", t), r = L(e, "onCreate", t), i = L(e, "onUpdate", t), a = L(e, "onSelectionUpdate", t), o = L(e, "onTransaction", t), s = L(e, "onFocus", t), c = L(e, "onBlur", t), l = L(e, "onDestroy", t);
|
|
2473
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);
|
|
2474
2474
|
});
|
|
2475
2475
|
}
|
|
2476
2476
|
};
|
|
2477
|
-
|
|
2478
|
-
var $ = class e extends
|
|
2477
|
+
Q.resolve = qt, Q.sort = V, Q.flatten = Nt;
|
|
2478
|
+
var $ = class e extends Ar {
|
|
2479
2479
|
constructor(...e) {
|
|
2480
2480
|
super(...e), this.type = "extension";
|
|
2481
2481
|
}
|
|
@@ -2496,14 +2496,14 @@ var $ = class e extends Or {
|
|
|
2496
2496
|
return { blockSeparator: void 0 };
|
|
2497
2497
|
},
|
|
2498
2498
|
addProseMirrorPlugins() {
|
|
2499
|
-
return [new
|
|
2500
|
-
key: new
|
|
2499
|
+
return [new r({
|
|
2500
|
+
key: new i("clipboardTextSerializer"),
|
|
2501
2501
|
props: { clipboardTextSerializer: () => {
|
|
2502
|
-
let { editor: e } = this, { state: t, schema: n } = e, { doc: r, selection: i } = t, a =
|
|
2502
|
+
let { editor: e } = this, { state: t, schema: n } = e, { doc: r, selection: i } = t, a = Xt(n), { blockSeparator: o } = this.options, s = {
|
|
2503
2503
|
...o === void 0 ? {} : { blockSeparator: o },
|
|
2504
2504
|
textSerializers: a
|
|
2505
2505
|
};
|
|
2506
|
-
return [...i.ranges].sort((e, t) => e.$from.pos - t.$from.pos).map(({ $from: e, $to: t }) =>
|
|
2506
|
+
return [...i.ranges].sort((e, t) => e.$from.pos - t.$from.pos).map(({ $from: e, $to: t }) => Jt(r, {
|
|
2507
2507
|
from: e.pos,
|
|
2508
2508
|
to: t.pos
|
|
2509
2509
|
}, s)).join(o ?? "\n\n");
|
|
@@ -2513,67 +2513,67 @@ var $ = class e extends Or {
|
|
|
2513
2513
|
}), Rr = $.create({
|
|
2514
2514
|
name: "commands",
|
|
2515
2515
|
addCommands() {
|
|
2516
|
-
return { ...
|
|
2516
|
+
return { ...Gn };
|
|
2517
2517
|
}
|
|
2518
2518
|
}), zr = $.create({
|
|
2519
2519
|
name: "delete",
|
|
2520
|
-
onUpdate({ transaction:
|
|
2521
|
-
var
|
|
2522
|
-
let
|
|
2523
|
-
var
|
|
2524
|
-
if (((
|
|
2525
|
-
let
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
let
|
|
2520
|
+
onUpdate({ transaction: e, appendedTransactions: t }) {
|
|
2521
|
+
var n;
|
|
2522
|
+
let r = () => {
|
|
2523
|
+
var n, r;
|
|
2524
|
+
if (((n = this.editor.options.coreExtensionOptions) == null || (n = n.delete) == null || (r = n.filterTransaction) == null ? void 0 : r.call(n, e)) ?? e.getMeta("y-sync$")) return;
|
|
2525
|
+
let i = At(e.before, [e, ...t]);
|
|
2526
|
+
tn(i).forEach((t) => {
|
|
2527
|
+
i.mapping.mapResult(t.oldRange.from).deletedAfter && i.mapping.mapResult(t.oldRange.to).deletedBefore && i.before.nodesBetween(t.oldRange.from, t.oldRange.to, (n, r) => {
|
|
2528
|
+
let a = r + n.nodeSize - 2, o = t.oldRange.from <= r && a <= t.oldRange.to;
|
|
2529
2529
|
this.editor.emit("delete", {
|
|
2530
2530
|
type: "node",
|
|
2531
2531
|
node: n,
|
|
2532
2532
|
from: r,
|
|
2533
|
-
to:
|
|
2534
|
-
newFrom:
|
|
2535
|
-
newTo:
|
|
2536
|
-
deletedRange:
|
|
2537
|
-
newRange:
|
|
2533
|
+
to: a,
|
|
2534
|
+
newFrom: i.mapping.map(r),
|
|
2535
|
+
newTo: i.mapping.map(a),
|
|
2536
|
+
deletedRange: t.oldRange,
|
|
2537
|
+
newRange: t.newRange,
|
|
2538
2538
|
partial: !o,
|
|
2539
2539
|
editor: this.editor,
|
|
2540
|
-
transaction:
|
|
2541
|
-
combinedTransform:
|
|
2540
|
+
transaction: e,
|
|
2541
|
+
combinedTransform: i
|
|
2542
2542
|
});
|
|
2543
2543
|
});
|
|
2544
2544
|
});
|
|
2545
|
-
let
|
|
2546
|
-
|
|
2547
|
-
if (
|
|
2548
|
-
let
|
|
2545
|
+
let a = i.mapping;
|
|
2546
|
+
i.steps.forEach((t, n) => {
|
|
2547
|
+
if (t instanceof s) {
|
|
2548
|
+
let r = a.slice(n).map(t.from, -1), o = a.slice(n).map(t.to), s = a.invert().map(r, -1), c = a.invert().map(o), l = r > 0 && i.doc.nodeAt(r - 1)?.marks.some((e) => e.eq(t.mark)), u = i.doc.nodeAt(o)?.marks.some((e) => e.eq(t.mark));
|
|
2549
2549
|
this.editor.emit("delete", {
|
|
2550
2550
|
type: "mark",
|
|
2551
|
-
mark:
|
|
2552
|
-
from:
|
|
2553
|
-
to:
|
|
2551
|
+
mark: t.mark,
|
|
2552
|
+
from: t.from,
|
|
2553
|
+
to: t.to,
|
|
2554
2554
|
deletedRange: {
|
|
2555
2555
|
from: s,
|
|
2556
2556
|
to: c
|
|
2557
2557
|
},
|
|
2558
2558
|
newRange: {
|
|
2559
|
-
from:
|
|
2560
|
-
to:
|
|
2559
|
+
from: r,
|
|
2560
|
+
to: o
|
|
2561
2561
|
},
|
|
2562
2562
|
partial: !!(u || l),
|
|
2563
2563
|
editor: this.editor,
|
|
2564
|
-
transaction:
|
|
2565
|
-
combinedTransform:
|
|
2564
|
+
transaction: e,
|
|
2565
|
+
combinedTransform: i
|
|
2566
2566
|
});
|
|
2567
2567
|
}
|
|
2568
2568
|
});
|
|
2569
2569
|
};
|
|
2570
|
-
((
|
|
2570
|
+
((n = this.editor.options.coreExtensionOptions) == null || (n = n.delete) == null ? void 0 : n.async) ?? !0 ? setTimeout(r, 0) : r();
|
|
2571
2571
|
}
|
|
2572
2572
|
}), Br = $.create({
|
|
2573
2573
|
name: "drop",
|
|
2574
2574
|
addProseMirrorPlugins() {
|
|
2575
|
-
return [new
|
|
2576
|
-
key: new
|
|
2575
|
+
return [new r({
|
|
2576
|
+
key: new i("tiptapDrop"),
|
|
2577
2577
|
props: { handleDrop: (e, t, n, r) => {
|
|
2578
2578
|
this.editor.emit("drop", {
|
|
2579
2579
|
editor: this.editor,
|
|
@@ -2587,16 +2587,16 @@ var $ = class e extends Or {
|
|
|
2587
2587
|
}), Vr = $.create({
|
|
2588
2588
|
name: "editable",
|
|
2589
2589
|
addProseMirrorPlugins() {
|
|
2590
|
-
return [new
|
|
2591
|
-
key: new
|
|
2590
|
+
return [new r({
|
|
2591
|
+
key: new i("editable"),
|
|
2592
2592
|
props: { editable: () => this.editor.options.editable }
|
|
2593
2593
|
})];
|
|
2594
2594
|
}
|
|
2595
|
-
}), Hr = new
|
|
2595
|
+
}), Hr = new i("focusEvents"), Ur = $.create({
|
|
2596
2596
|
name: "focusEvents",
|
|
2597
2597
|
addProseMirrorPlugins() {
|
|
2598
2598
|
let { editor: e } = this;
|
|
2599
|
-
return [new
|
|
2599
|
+
return [new r({
|
|
2600
2600
|
key: Hr,
|
|
2601
2601
|
props: { handleDOMEvents: {
|
|
2602
2602
|
focus: (t, n) => {
|
|
@@ -2618,8 +2618,8 @@ var $ = class e extends Or {
|
|
|
2618
2618
|
let e = () => this.editor.commands.first(({ commands: e }) => [
|
|
2619
2619
|
() => e.undoInputRule(),
|
|
2620
2620
|
() => e.command(({ tr: t }) => {
|
|
2621
|
-
let { selection: n, doc: r } = t, { empty: i, $anchor:
|
|
2622
|
-
return !i || !
|
|
2621
|
+
let { selection: n, doc: r } = t, { empty: i, $anchor: o } = n, { pos: s, parent: c } = o, l = o.parent.isTextblock && s > 0 ? t.doc.resolve(s - 1) : o, u = l.parent.type.spec.isolating, d = o.pos - o.parentOffset, f = u && l.parent.childCount === 1 ? d === o.pos : a.atStart(r).from === s;
|
|
2622
|
+
return !i || !c.type.isTextblock || c.textContent.length || !f || f && o.parent.type.name === "paragraph" ? !1 : e.clearNodes();
|
|
2623
2623
|
}),
|
|
2624
2624
|
() => e.deleteSelection(),
|
|
2625
2625
|
() => e.joinBackward(),
|
|
@@ -2654,33 +2654,33 @@ var $ = class e extends Or {
|
|
|
2654
2654
|
"Ctrl-a": () => this.editor.commands.selectTextblockStart(),
|
|
2655
2655
|
"Ctrl-e": () => this.editor.commands.selectTextblockEnd()
|
|
2656
2656
|
};
|
|
2657
|
-
return
|
|
2657
|
+
return j() || dt() ? i : r;
|
|
2658
2658
|
},
|
|
2659
2659
|
addProseMirrorPlugins() {
|
|
2660
|
-
return [new
|
|
2661
|
-
key: new
|
|
2660
|
+
return [new r({
|
|
2661
|
+
key: new i("clearDocument"),
|
|
2662
2662
|
appendTransaction: (e, t, n) => {
|
|
2663
2663
|
if (e.some((e) => e.getMeta("composition"))) return;
|
|
2664
2664
|
let r = e.some((e) => e.docChanged) && !t.doc.eq(n.doc), i = e.some((e) => e.getMeta("preventClearDocument"));
|
|
2665
2665
|
if (!r || i) return;
|
|
2666
|
-
let { empty:
|
|
2667
|
-
if (
|
|
2668
|
-
let
|
|
2666
|
+
let { empty: o, from: s, to: c } = t.selection, l = a.atStart(t.doc).from, u = a.atEnd(t.doc).to;
|
|
2667
|
+
if (o || s !== l || c !== u || !G(n.doc)) return;
|
|
2668
|
+
let d = n.tr, f = w({
|
|
2669
2669
|
state: n,
|
|
2670
|
-
transaction:
|
|
2671
|
-
}), { commands:
|
|
2670
|
+
transaction: d
|
|
2671
|
+
}), { commands: p } = new T({
|
|
2672
2672
|
editor: this.editor,
|
|
2673
|
-
state:
|
|
2673
|
+
state: f
|
|
2674
2674
|
});
|
|
2675
|
-
if (
|
|
2675
|
+
if (p.clearNodes(), d.steps.length) return d;
|
|
2676
2676
|
}
|
|
2677
2677
|
})];
|
|
2678
2678
|
}
|
|
2679
2679
|
}), Gr = $.create({
|
|
2680
2680
|
name: "paste",
|
|
2681
2681
|
addProseMirrorPlugins() {
|
|
2682
|
-
return [new
|
|
2683
|
-
key: new
|
|
2682
|
+
return [new r({
|
|
2683
|
+
key: new i("tiptapPaste"),
|
|
2684
2684
|
props: { handlePaste: (e, t, n) => {
|
|
2685
2685
|
this.editor.emit("paste", {
|
|
2686
2686
|
editor: this.editor,
|
|
@@ -2696,8 +2696,8 @@ var $ = class e extends Or {
|
|
|
2696
2696
|
return { value: void 0 };
|
|
2697
2697
|
},
|
|
2698
2698
|
addProseMirrorPlugins() {
|
|
2699
|
-
return [new
|
|
2700
|
-
key: new
|
|
2699
|
+
return [new r({
|
|
2700
|
+
key: new i("tabindex"),
|
|
2701
2701
|
props: { attributes: () => !this.editor.isEditable && this.options.value === void 0 ? {} : { tabindex: this.options.value ?? "0" } }
|
|
2702
2702
|
})];
|
|
2703
2703
|
}
|
|
@@ -2708,7 +2708,7 @@ var $ = class e extends Or {
|
|
|
2708
2708
|
},
|
|
2709
2709
|
addGlobalAttributes() {
|
|
2710
2710
|
if (!this.options.direction) return [];
|
|
2711
|
-
let { nodeExtensions: e } =
|
|
2711
|
+
let { nodeExtensions: e } = z(this.extensions);
|
|
2712
2712
|
return [{
|
|
2713
2713
|
types: e.filter((e) => e.name !== "text").map((e) => e.name),
|
|
2714
2714
|
attributes: { dir: {
|
|
@@ -2722,8 +2722,8 @@ var $ = class e extends Or {
|
|
|
2722
2722
|
}];
|
|
2723
2723
|
},
|
|
2724
2724
|
addProseMirrorPlugins() {
|
|
2725
|
-
return [new
|
|
2726
|
-
key: new
|
|
2725
|
+
return [new r({
|
|
2726
|
+
key: new i("textDirection"),
|
|
2727
2727
|
props: { attributes: () => {
|
|
2728
2728
|
let e = this.options.direction;
|
|
2729
2729
|
return e ? { dir: e } : {};
|
|
@@ -2736,14 +2736,14 @@ function Yr(e) {
|
|
|
2736
2736
|
Jr = !0;
|
|
2737
2737
|
let t;
|
|
2738
2738
|
try {
|
|
2739
|
-
t =
|
|
2739
|
+
t = l.fromJSON(e, {
|
|
2740
2740
|
from: 0,
|
|
2741
2741
|
to: 0
|
|
2742
2742
|
}).slice.content;
|
|
2743
2743
|
} catch {
|
|
2744
2744
|
return;
|
|
2745
2745
|
}
|
|
2746
|
-
t instanceof
|
|
2746
|
+
t instanceof S || 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.");
|
|
2747
2747
|
}
|
|
2748
2748
|
var Xr = class e {
|
|
2749
2749
|
get name() {
|
|
@@ -2867,7 +2867,7 @@ var Xr = class e {
|
|
|
2867
2867
|
...e
|
|
2868
2868
|
}), this.editor.view.dispatch(t);
|
|
2869
2869
|
}
|
|
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
|
|
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 Jn {
|
|
2871
2871
|
constructor(e = {}) {
|
|
2872
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 = {
|
|
2873
2873
|
element: typeof document < "u" ? document.createElement("div") : null,
|
|
@@ -2904,14 +2904,14 @@ var Xr = class e {
|
|
|
2904
2904
|
onDelete: () => null,
|
|
2905
2905
|
enableExtensionDispatchTransaction: !0
|
|
2906
2906
|
}, this.isCapturingTransaction = !1, this.capturedTransaction = null, this.utils = {
|
|
2907
|
-
getUpdatedPosition:
|
|
2908
|
-
createMappablePosition:
|
|
2907
|
+
getUpdatedPosition: mn,
|
|
2908
|
+
createMappablePosition: hn
|
|
2909
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);
|
|
2910
|
-
let
|
|
2910
|
+
let n = this.createDoc();
|
|
2911
2911
|
if (!this.editorState) {
|
|
2912
|
-
let e =
|
|
2913
|
-
this.editorState =
|
|
2914
|
-
doc:
|
|
2912
|
+
let e = We(n, this.options.autofocus);
|
|
2913
|
+
this.editorState = t.create({
|
|
2914
|
+
doc: n,
|
|
2915
2915
|
schema: this.schema,
|
|
2916
2916
|
selection: e || void 0
|
|
2917
2917
|
});
|
|
@@ -2944,13 +2944,13 @@ var Xr = class e {
|
|
|
2944
2944
|
return this.commandManager.commands;
|
|
2945
2945
|
}
|
|
2946
2946
|
chain() {
|
|
2947
|
-
return this.commandManager ? this.commandManager.chain() :
|
|
2947
|
+
return this.commandManager ? this.commandManager.chain() : T.createFakeChain();
|
|
2948
2948
|
}
|
|
2949
2949
|
can() {
|
|
2950
|
-
return this.commandManager ? this.commandManager.can() :
|
|
2950
|
+
return this.commandManager ? this.commandManager.can() : T.createFallbackCan();
|
|
2951
2951
|
}
|
|
2952
2952
|
injectCSS() {
|
|
2953
|
-
this.options.injectCSS && typeof document < "u" && (this.css =
|
|
2953
|
+
this.options.injectCSS && typeof document < "u" && (this.css = gr(Zr, this.options.injectNonce));
|
|
2954
2954
|
}
|
|
2955
2955
|
setOptions(e = {}) {
|
|
2956
2956
|
this.options = {
|
|
@@ -2989,10 +2989,10 @@ var Xr = class e {
|
|
|
2989
2989
|
} });
|
|
2990
2990
|
}
|
|
2991
2991
|
get state() {
|
|
2992
|
-
return
|
|
2992
|
+
return Yn && !this.hasWarnedStaleDecorationRead && qn(this) && (this.hasWarnedStaleDecorationRead = !0, console.warn("[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.")), this.editorView && (this.editorState = this.view.state), this.editorState;
|
|
2993
2993
|
}
|
|
2994
2994
|
registerPlugin(e, t) {
|
|
2995
|
-
let n =
|
|
2995
|
+
let n = Ft(t) ? t(e, [...this.state.plugins]) : [...this.state.plugins, e], r = this.state.reconfigure({ plugins: n });
|
|
2996
2996
|
return this.view.updateState(r), r;
|
|
2997
2997
|
}
|
|
2998
2998
|
unregisterPlugin(e) {
|
|
@@ -3023,10 +3023,10 @@ var Xr = class e {
|
|
|
3023
3023
|
"node",
|
|
3024
3024
|
"mark"
|
|
3025
3025
|
].includes(e?.type));
|
|
3026
|
-
this.extensionManager = new
|
|
3026
|
+
this.extensionManager = new Q(n, this);
|
|
3027
3027
|
}
|
|
3028
3028
|
createCommandManager() {
|
|
3029
|
-
this.commandManager = new
|
|
3029
|
+
this.commandManager = new T({ editor: this });
|
|
3030
3030
|
}
|
|
3031
3031
|
createSchema() {
|
|
3032
3032
|
this.schema = this.extensionManager.schema;
|
|
@@ -3034,14 +3034,14 @@ var Xr = class e {
|
|
|
3034
3034
|
createDoc() {
|
|
3035
3035
|
let e;
|
|
3036
3036
|
try {
|
|
3037
|
-
e =
|
|
3037
|
+
e = Dt(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: this.options.enableContentCheck });
|
|
3038
3038
|
} catch (e) {
|
|
3039
3039
|
if (!(e instanceof Error) || !["[tiptap error]: Invalid JSON content", "[tiptap error]: Invalid HTML content"].includes(e.message)) throw e;
|
|
3040
|
-
let
|
|
3041
|
-
return this.editorState =
|
|
3042
|
-
doc:
|
|
3040
|
+
let n = Dt(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: !1 });
|
|
3041
|
+
return this.editorState = t.create({
|
|
3042
|
+
doc: n,
|
|
3043
3043
|
schema: this.schema,
|
|
3044
|
-
selection:
|
|
3044
|
+
selection: We(n, this.options.autofocus) || void 0
|
|
3045
3045
|
}), this.emit("contentError", {
|
|
3046
3046
|
editor: this,
|
|
3047
3047
|
error: e,
|
|
@@ -3054,7 +3054,7 @@ var Xr = class e {
|
|
|
3054
3054
|
}
|
|
3055
3055
|
createView(e) {
|
|
3056
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);
|
|
3057
|
-
this.editorView = new
|
|
3057
|
+
this.editorView = new ye(e, {
|
|
3058
3058
|
...t,
|
|
3059
3059
|
attributes: {
|
|
3060
3060
|
role: "textbox",
|
|
@@ -3125,30 +3125,30 @@ var Xr = class e {
|
|
|
3125
3125
|
});
|
|
3126
3126
|
}
|
|
3127
3127
|
getAttributes(e) {
|
|
3128
|
-
return
|
|
3128
|
+
return Qt(this.state, e);
|
|
3129
3129
|
}
|
|
3130
3130
|
isActive(e, t) {
|
|
3131
3131
|
let n = typeof e == "string" ? e : null, r = typeof e == "string" ? t : e;
|
|
3132
|
-
return
|
|
3132
|
+
return sn(this.state, n, r);
|
|
3133
3133
|
}
|
|
3134
3134
|
getJSON() {
|
|
3135
3135
|
return this.state.doc.toJSON();
|
|
3136
3136
|
}
|
|
3137
3137
|
getHTML() {
|
|
3138
|
-
return
|
|
3138
|
+
return Pt(this.state.doc.content, this.schema);
|
|
3139
3139
|
}
|
|
3140
3140
|
getText(e) {
|
|
3141
3141
|
let { blockSeparator: t = "\n\n", textSerializers: n = {} } = e || {};
|
|
3142
|
-
return
|
|
3142
|
+
return Yt(this.state.doc, {
|
|
3143
3143
|
blockSeparator: t,
|
|
3144
3144
|
textSerializers: {
|
|
3145
|
-
...
|
|
3145
|
+
...Xt(this.schema),
|
|
3146
3146
|
...n
|
|
3147
3147
|
}
|
|
3148
3148
|
});
|
|
3149
3149
|
}
|
|
3150
3150
|
get isEmpty() {
|
|
3151
|
-
return
|
|
3151
|
+
return G(this.state.doc);
|
|
3152
3152
|
}
|
|
3153
3153
|
destroy() {
|
|
3154
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 = {});
|
|
@@ -3171,15 +3171,15 @@ var Xr = class e {
|
|
|
3171
3171
|
}
|
|
3172
3172
|
};
|
|
3173
3173
|
function $r(e) {
|
|
3174
|
-
return new
|
|
3174
|
+
return new Y({
|
|
3175
3175
|
find: e.find,
|
|
3176
3176
|
handler: ({ state: t, range: n, match: r }) => {
|
|
3177
|
-
let i =
|
|
3177
|
+
let i = R(e.getAttributes, void 0, r);
|
|
3178
3178
|
if (i === !1 || i === null) return null;
|
|
3179
3179
|
let { tr: a } = t, o = r[r.length - 1], s = r[0];
|
|
3180
3180
|
if (o) {
|
|
3181
3181
|
let r = s.search(/\S/), c = n.from + s.indexOf(o), l = c + o.length;
|
|
3182
|
-
if (
|
|
3182
|
+
if (H(n.from, n.to, t.doc).filter((t) => t.mark.type.excluded.find((n) => n === e.type && n !== t.mark.type)).filter((e) => e.to > c).length) return null;
|
|
3183
3183
|
l < n.to && a.delete(l, n.to), c > n.from && a.delete(n.from + r, c);
|
|
3184
3184
|
let u = n.from + r + o.length;
|
|
3185
3185
|
a.addMark(n.from + r, u, e.type.create(i || {})), a.removeStoredMark(e.type);
|
|
@@ -3189,10 +3189,10 @@ function $r(e) {
|
|
|
3189
3189
|
});
|
|
3190
3190
|
}
|
|
3191
3191
|
function ei(e) {
|
|
3192
|
-
return new
|
|
3192
|
+
return new Y({
|
|
3193
3193
|
find: e.find,
|
|
3194
3194
|
handler: ({ state: t, range: n, match: r }) => {
|
|
3195
|
-
let i =
|
|
3195
|
+
let i = R(e.getAttributes, void 0, r) || {}, { tr: a } = t, o = n.from, s = n.to, c = e.type.create(i);
|
|
3196
3196
|
if (r[1]) {
|
|
3197
3197
|
let e = o + r[0].lastIndexOf(r[1]);
|
|
3198
3198
|
e > s ? e = s : s = e + r[1].length;
|
|
@@ -3208,10 +3208,10 @@ function ei(e) {
|
|
|
3208
3208
|
});
|
|
3209
3209
|
}
|
|
3210
3210
|
function ti(e) {
|
|
3211
|
-
return new
|
|
3211
|
+
return new Y({
|
|
3212
3212
|
find: e.find,
|
|
3213
3213
|
handler: ({ state: t, range: n, match: r }) => {
|
|
3214
|
-
let i = t.doc.resolve(n.from), a =
|
|
3214
|
+
let i = t.doc.resolve(n.from), a = R(e.getAttributes, void 0, r) || {};
|
|
3215
3215
|
if (!i.node(-1).canReplaceWith(i.index(-1), i.indexAfter(-1), e.type)) return null;
|
|
3216
3216
|
t.tr.delete(n.from, n.to).setBlockType(n.from, n.from, e.type, a);
|
|
3217
3217
|
},
|
|
@@ -3219,7 +3219,7 @@ function ti(e) {
|
|
|
3219
3219
|
});
|
|
3220
3220
|
}
|
|
3221
3221
|
function ni(e) {
|
|
3222
|
-
return new
|
|
3222
|
+
return new Y({
|
|
3223
3223
|
find: e.find,
|
|
3224
3224
|
handler: ({ state: t, range: n, match: r }) => {
|
|
3225
3225
|
let i = e.replace, a = n.from, o = n.to;
|
|
@@ -3235,24 +3235,24 @@ function ni(e) {
|
|
|
3235
3235
|
});
|
|
3236
3236
|
}
|
|
3237
3237
|
function ri(e) {
|
|
3238
|
-
return new
|
|
3238
|
+
return new Y({
|
|
3239
3239
|
find: e.find,
|
|
3240
|
-
handler: ({ state: t, range: n, match: r, chain:
|
|
3241
|
-
let
|
|
3242
|
-
if (!
|
|
3243
|
-
if (
|
|
3240
|
+
handler: ({ state: t, range: n, match: r, chain: i }) => {
|
|
3241
|
+
let a = R(e.getAttributes, void 0, r) || {}, o = t.tr.delete(n.from, n.to), s = o.doc.resolve(n.from).blockRange(), c = s && p(s, e.type, a);
|
|
3242
|
+
if (!c) return null;
|
|
3243
|
+
if (o.wrap(s, c), e.keepMarks && e.editor) {
|
|
3244
3244
|
let { selection: n, storedMarks: r } = t, { splittableMarks: i } = e.editor.extensionManager, a = r || n.$to.parentOffset && n.$from.marks();
|
|
3245
3245
|
if (a) {
|
|
3246
3246
|
let e = a.filter((e) => i.includes(e.type.name));
|
|
3247
|
-
|
|
3247
|
+
o.ensureMarks(e);
|
|
3248
3248
|
}
|
|
3249
3249
|
}
|
|
3250
3250
|
if (e.keepAttributes) {
|
|
3251
3251
|
let t = e.type.name === "bulletList" || e.type.name === "orderedList" ? "listItem" : "taskList";
|
|
3252
|
-
|
|
3252
|
+
i().updateAttributes(t, a).run();
|
|
3253
3253
|
}
|
|
3254
|
-
let
|
|
3255
|
-
|
|
3254
|
+
let l = o.doc.resolve(n.from - 1).nodeBefore;
|
|
3255
|
+
l && l.type === e.type && d(o.doc, n.from - 1) && (!e.joinPredicate || e.joinPredicate(r, l)) && o.join(n.from - 1);
|
|
3256
3256
|
},
|
|
3257
3257
|
undoable: e.undoable
|
|
3258
3258
|
});
|
|
@@ -3387,7 +3387,7 @@ var ii = (e) => "touches" in e, ai = class {
|
|
|
3387
3387
|
height: e / this.aspectRatio
|
|
3388
3388
|
};
|
|
3389
3389
|
}
|
|
3390
|
-
}, oi = class e extends
|
|
3390
|
+
}, oi = class e extends Ar {
|
|
3391
3391
|
constructor(...e) {
|
|
3392
3392
|
super(...e), this.type = "node";
|
|
3393
3393
|
}
|
|
@@ -3424,49 +3424,49 @@ var ii = (e) => "touches" in e, ai = class {
|
|
|
3424
3424
|
return null;
|
|
3425
3425
|
}
|
|
3426
3426
|
onDragStart(e) {
|
|
3427
|
-
let { view: t } = this.editor,
|
|
3428
|
-
if (!this.dom || this.contentDOM?.contains(
|
|
3429
|
-
let
|
|
3430
|
-
if (this.dom !==
|
|
3431
|
-
let t = this.dom.getBoundingClientRect(), n =
|
|
3432
|
-
|
|
3427
|
+
let { view: t } = this.editor, r = e.target, i = r.nodeType === 3 ? r.parentElement?.closest("[data-drag-handle]") : r.closest("[data-drag-handle]");
|
|
3428
|
+
if (!this.dom || this.contentDOM?.contains(r) || !i) return;
|
|
3429
|
+
let a = 0, o = 0;
|
|
3430
|
+
if (this.dom !== i) {
|
|
3431
|
+
let t = this.dom.getBoundingClientRect(), n = i.getBoundingClientRect(), r = e.offsetX ?? e.nativeEvent?.offsetX, s = e.offsetY ?? e.nativeEvent?.offsetY;
|
|
3432
|
+
a = n.x - t.x + r, o = n.y - t.y + s;
|
|
3433
3433
|
}
|
|
3434
|
-
let
|
|
3434
|
+
let s = this.dom.cloneNode(!0);
|
|
3435
3435
|
try {
|
|
3436
3436
|
let e = this.dom.getBoundingClientRect();
|
|
3437
|
-
|
|
3437
|
+
s.style.width = `${Math.round(e.width)}px`, s.style.height = `${Math.round(e.height)}px`, s.style.boxSizing = "border-box", s.style.pointerEvents = "none";
|
|
3438
3438
|
} catch {}
|
|
3439
|
-
let
|
|
3439
|
+
let c = null;
|
|
3440
3440
|
try {
|
|
3441
|
-
var
|
|
3442
|
-
|
|
3441
|
+
var l;
|
|
3442
|
+
c = document.createElement("div"), c.style.position = "absolute", c.style.top = "-9999px", c.style.left = "-9999px", c.style.pointerEvents = "none", c.appendChild(s), document.body.appendChild(c), (l = e.dataTransfer) == null || l.setDragImage(s, a, o);
|
|
3443
3443
|
} finally {
|
|
3444
|
-
|
|
3444
|
+
c && setTimeout(() => {
|
|
3445
3445
|
try {
|
|
3446
|
-
|
|
3446
|
+
c?.remove();
|
|
3447
3447
|
} catch {}
|
|
3448
3448
|
}, 0);
|
|
3449
3449
|
}
|
|
3450
|
-
let
|
|
3451
|
-
if (typeof
|
|
3452
|
-
let
|
|
3453
|
-
t.dispatch(
|
|
3450
|
+
let u = this.getPos();
|
|
3451
|
+
if (typeof u != "number") return;
|
|
3452
|
+
let d = n.create(t.state.doc, u), f = t.state.tr.setSelection(d);
|
|
3453
|
+
t.dispatch(f);
|
|
3454
3454
|
}
|
|
3455
3455
|
stopEvent(e) {
|
|
3456
3456
|
if (!this.dom) return !1;
|
|
3457
3457
|
if (typeof this.options.stopEvent == "function") return this.options.stopEvent({ event: e });
|
|
3458
3458
|
let t = e.target;
|
|
3459
3459
|
if (!this.dom.contains(t) || this.contentDOM?.contains(t)) return !1;
|
|
3460
|
-
let
|
|
3460
|
+
let r = e.type.startsWith("drag"), i = e.type === "dragover" || e.type === "dragenter", a = e.type === "drop";
|
|
3461
3461
|
if (([
|
|
3462
3462
|
"INPUT",
|
|
3463
3463
|
"BUTTON",
|
|
3464
3464
|
"SELECT",
|
|
3465
3465
|
"TEXTAREA"
|
|
3466
|
-
].includes(t.tagName) || t.isContentEditable) && !
|
|
3467
|
-
let { isEditable:
|
|
3468
|
-
if (!
|
|
3469
|
-
if (
|
|
3466
|
+
].includes(t.tagName) || t.isContentEditable) && !a && !r) return !0;
|
|
3467
|
+
let { isEditable: o } = this.editor, { isDragging: s } = this, c = !!this.node.type.spec.draggable, l = n.isSelectable(this.node), u = e.type === "copy", d = e.type === "paste", f = e.type === "cut", p = e.type === "mousedown";
|
|
3468
|
+
if (!c && l && r && e.target === this.dom && e.preventDefault(), c && r && !s && e.target === this.dom) return e.preventDefault(), !1;
|
|
3469
|
+
if (c && o && !s && p) {
|
|
3470
3470
|
let e = t.closest("[data-drag-handle]");
|
|
3471
3471
|
e && (this.dom === e || this.dom.contains(e)) && (this.isDragging = !0, document.addEventListener("dragend", () => {
|
|
3472
3472
|
this.isDragging = !1;
|
|
@@ -3476,10 +3476,10 @@ var ii = (e) => "touches" in e, ai = class {
|
|
|
3476
3476
|
this.isDragging = !1;
|
|
3477
3477
|
}, { once: !0 }));
|
|
3478
3478
|
}
|
|
3479
|
-
return !(
|
|
3479
|
+
return !(s || i || a || u || d || f || p && l);
|
|
3480
3480
|
}
|
|
3481
3481
|
ignoreMutation(e) {
|
|
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" && (
|
|
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" && (j() || Ge()) && 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);
|
|
3483
3483
|
}
|
|
3484
3484
|
updateAttributes(e) {
|
|
3485
3485
|
this.editor.commands.command(({ tr: t }) => {
|
|
@@ -3501,19 +3501,19 @@ var ii = (e) => "touches" in e, ai = class {
|
|
|
3501
3501
|
}
|
|
3502
3502
|
};
|
|
3503
3503
|
function ci(e) {
|
|
3504
|
-
return new
|
|
3504
|
+
return new Mr({
|
|
3505
3505
|
find: e.find,
|
|
3506
3506
|
handler: ({ state: t, range: n, match: r, pasteEvent: i }) => {
|
|
3507
|
-
let a =
|
|
3507
|
+
let a = R(e.getAttributes, void 0, r, i);
|
|
3508
3508
|
if (a === !1 || a === null) return null;
|
|
3509
3509
|
let { tr: o } = t, s = r[r.length - 1], c = r[0], l = n.to;
|
|
3510
3510
|
if (s) {
|
|
3511
3511
|
let i = c.search(/\S/), u = n.from + c.indexOf(s), d = u + s.length;
|
|
3512
|
-
if (
|
|
3512
|
+
if (H(n.from, n.to, t.doc).filter((t) => t.mark.type.excluded.find((n) => n === e.type && n !== t.mark.type)).filter((e) => e.to > u).length) return null;
|
|
3513
3513
|
d < n.to && o.delete(d, n.to), u > n.from && o.delete(n.from + i, u), l = n.from + i + s.length, o.addMark(n.from + i, l, e.type.create(a || {})), r.index !== void 0 && r.input !== void 0 && r.index + r[0].length >= r.input.length || o.removeStoredMark(e.type);
|
|
3514
3514
|
}
|
|
3515
3515
|
}
|
|
3516
3516
|
});
|
|
3517
3517
|
}
|
|
3518
3518
|
//#endregion
|
|
3519
|
-
export {
|
|
3519
|
+
export { P as A, Tr as B, B as C, cn as D, Xt as E, ci as F, ti as H, Bt as I, ei as L, fn as M, Ue as N, ln as O, $r as P, Sr as R, rn as S, Yt as T, ri as U, ni as V, L as _, oi as a, nn as b, ai as c, At as d, _r as f, tn as g, Qt as h, jr as i, G as j, yr as k, R as l, Mt as m, $ as n, si as o, jt as p, Y as r, Mr as s, Qr as t, hr as u, O as v, vr as w, E as x, H as y, gn as z };
|