@clevertask/scribe 0.1.28 → 0.1.30
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 +30 -47
- package/dist/BarMenu-Bban-B3t.js +302 -0
- package/dist/assets/index.css +1 -1
- package/dist/components/Menu/BarMenu.d.ts.map +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.d.ts.map +1 -1
- package/dist/components/Menu/LinkBubbleMenu.js +107 -119
- package/dist/components/Menu/LinkEditor.d.ts +0 -7
- package/dist/components/Menu/LinkEditor.d.ts.map +1 -1
- package/dist/components/Menu/LinkEditor.js +152 -153
- package/dist/components/Menu/Mobile/ListOptionBar.js +1 -1
- package/dist/components/Menu/TableBubbleMenu.js +3 -3
- package/dist/components/Menu/TableHeightSettings.js +1 -1
- package/dist/components/Menu/linkBubbleMenuPlugin.d.ts.map +1 -1
- package/dist/components/Menu/linkBubbleMenuPlugin.js +9 -5
- package/dist/components/Scribe/extension/callout.js +5 -5
- 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/attributes.d.ts +0 -7
- package/dist/components/Scribe/extension/external-link-preview/attributes.d.ts.map +1 -1
- package/dist/components/Scribe/extension/external-link-preview/attributes.js +26 -51
- package/dist/components/Scribe/extension/external-link-preview/commands.d.ts +5 -12
- package/dist/components/Scribe/extension/external-link-preview/commands.d.ts.map +1 -1
- package/dist/components/Scribe/extension/external-link-preview/commands.js +56 -121
- package/dist/components/Scribe/extension/external-link-preview/index.d.ts +4 -6
- package/dist/components/Scribe/extension/external-link-preview/index.d.ts.map +1 -1
- package/dist/components/Scribe/extension/external-link-preview/index.js +5 -41
- package/dist/components/Scribe/extension/external-link-preview/render-html.d.ts +1 -0
- package/dist/components/Scribe/extension/external-link-preview/render-html.d.ts.map +1 -1
- package/dist/components/Scribe/extension/external-link-preview/render-html.js +17 -60
- package/dist/components/Scribe/extension/external-link-preview/schema.d.ts +2 -2
- package/dist/components/Scribe/extension/external-link-preview/schema.js +1 -1
- package/dist/components/Scribe/extension/external-link-preview/serialization.d.ts.map +1 -1
- package/dist/components/Scribe/extension/external-link-preview/serialization.js +29 -45
- package/dist/components/Scribe/extension/external-link-preview/types.d.ts +14 -17
- package/dist/components/Scribe/extension/external-link-preview/types.d.ts.map +1 -1
- package/dist/components/Scribe/extension/index.js +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/renderItems.js +1 -1
- package/dist/components/Scribe/extension/table-layout.js +1 -1
- package/dist/components/Scribe/extension/tableOfContents.js +1 -1
- package/dist/components/Scribe/index.d.ts +3 -9
- package/dist/components/Scribe/index.d.ts.map +1 -1
- package/dist/components/Scribe/index.js +3 -3
- package/dist/{dist-xjmWZ-oh.js → dist-DGEcUiqG.js} +650 -686
- package/dist/{dist-Dk0fXvrc.js → dist-TKt66Yz8.js} +2 -2
- package/dist/{dist-BiognBi4.js → dist-ZGDUiMX8.js} +189 -376
- package/dist/document-node-capabilities.js +1 -1
- package/dist/{extension-BU2USLV1.js → extension-I7Ocj_D_.js} +2 -2
- package/dist/extension-link-Cb1UO6hv.js +939 -0
- package/dist/main.css +0 -141
- package/dist/{menus-BDXjZsFU.js → menus-BrQTLTFL.js} +17 -17
- package/dist/{schema-extensions-DyCk1Goa.js → schema-extensions-CzDKrIf8.js} +1616 -1489
- package/dist/schema-extensions.js +1 -1
- package/dist/schema.js +1 -1
- package/dist/{table-layout-BoDS50DR.js → table-layout-Dt7KmVp_.js} +174 -123
- package/dist/utils/create-scribe-editor.d.ts +1 -1
- package/dist/utils/create-scribe-editor.d.ts.map +1 -1
- package/dist/utils/index.js +2 -2
- package/package.json +51 -51
- package/dist/BarMenu-BGWT4Oyk.js +0 -302
- package/dist/components/Menu/ExternalLinkDisplayOptions.d.ts +0 -13
- package/dist/components/Menu/ExternalLinkDisplayOptions.d.ts.map +0 -1
- package/dist/components/Menu/ExternalLinkDisplayOptions.js +0 -90
- package/dist/components/Scribe/extension/external-link-preview/node-view.d.ts +0 -3
- package/dist/components/Scribe/extension/external-link-preview/node-view.d.ts.map +0 -1
- package/dist/components/Scribe/extension/external-link-preview/node-view.js +0 -97
- package/dist/components/Scribe/extension/external-link-preview/normalization.d.ts +0 -7
- package/dist/components/Scribe/extension/external-link-preview/normalization.d.ts.map +0 -1
- package/dist/components/Scribe/extension/external-link-preview/normalization.js +0 -21
- package/dist/components/Scribe/extension/external-link-preview/paste.d.ts +0 -8
- package/dist/components/Scribe/extension/external-link-preview/paste.d.ts.map +0 -1
- package/dist/components/Scribe/extension/external-link-preview/paste.js +0 -53
- package/dist/components/Scribe/extension/external-link-preview/policy.d.ts +0 -7
- package/dist/components/Scribe/extension/external-link-preview/policy.d.ts.map +0 -1
- package/dist/components/Scribe/extension/external-link-preview/policy.js +0 -38
- package/dist/components/Scribe/extension/external-link-preview/resolver.d.ts +0 -23
- package/dist/components/Scribe/extension/external-link-preview/resolver.d.ts.map +0 -1
- package/dist/components/Scribe/extension/external-link-preview/resolver.js +0 -118
- package/dist/extension-link-DmM_EJTn.js +0 -909
|
@@ -1,22 +1,23 @@
|
|
|
1
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
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
|
|
4
|
-
import { DOMParser as
|
|
5
|
-
import { liftListItem as
|
|
6
|
-
import { DecorationSet as
|
|
7
|
-
import { keymap as
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
import { createParagraphNear as g, exitCode as _, joinBackward as v, joinDown as y, joinForward as b, joinTextblockBackward as x, joinTextblockForward as ee, joinUp as te, lift as S, liftEmptyBlock as ne, newlineInCode as C, selectNodeBackward as re, selectNodeForward as ie, selectParentNode as ae, selectTextblockEnd as oe, selectTextblockStart as se, setBlockType as ce, wrapIn as le } from "@tiptap/pm/commands";
|
|
4
|
+
import { DOMParser as ue, DOMSerializer as de, Fragment as w, Schema as fe, Slice as pe } from "@tiptap/pm/model";
|
|
5
|
+
import { liftListItem as me, sinkListItem as he, wrapInList as ge } from "@tiptap/pm/schema-list";
|
|
6
|
+
import { DecorationSet as T, EditorView as _e } from "@tiptap/pm/view";
|
|
7
|
+
import { keymap as ve } from "@tiptap/pm/keymap";
|
|
8
|
+
import { closeHistory as ye } from "@tiptap/pm/history";
|
|
9
|
+
//#region node_modules/.pnpm/@tiptap+core@3.31.4_@tiptap+pm@3.31.4/node_modules/@tiptap/core/dist/rolldown-runtime-D7D4PA-g.js
|
|
10
|
+
var be = Object.defineProperty, xe = (e, t) => {
|
|
10
11
|
let n = {};
|
|
11
|
-
for (var r in e)
|
|
12
|
+
for (var r in e) be(n, r, {
|
|
12
13
|
get: e[r],
|
|
13
14
|
enumerable: !0
|
|
14
15
|
});
|
|
15
|
-
return t ||
|
|
16
|
+
return t || be(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
16
17
|
};
|
|
17
18
|
//#endregion
|
|
18
|
-
//#region node_modules/.pnpm/@tiptap+core@3.31.
|
|
19
|
-
function
|
|
19
|
+
//#region node_modules/.pnpm/@tiptap+core@3.31.4_@tiptap+pm@3.31.4/node_modules/@tiptap/core/dist/index.js
|
|
20
|
+
function E(e) {
|
|
20
21
|
let { state: t, transaction: n } = e, { selection: r } = n, { doc: i } = n, { storedMarks: a } = n;
|
|
21
22
|
return {
|
|
22
23
|
...t,
|
|
@@ -40,7 +41,7 @@ function w(e) {
|
|
|
40
41
|
}
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
|
-
var
|
|
44
|
+
var D = class e {
|
|
44
45
|
constructor(e) {
|
|
45
46
|
this.editor = e.editor, this.rawCommands = this.editor.extensionManager.commands, this.customState = e.state;
|
|
46
47
|
}
|
|
@@ -100,7 +101,7 @@ var T = class e {
|
|
|
100
101
|
tr: e,
|
|
101
102
|
editor: r,
|
|
102
103
|
view: a,
|
|
103
|
-
state:
|
|
104
|
+
state: E({
|
|
104
105
|
state: i,
|
|
105
106
|
transaction: e
|
|
106
107
|
}),
|
|
@@ -113,12 +114,12 @@ var T = class e {
|
|
|
113
114
|
};
|
|
114
115
|
return o;
|
|
115
116
|
}
|
|
116
|
-
},
|
|
117
|
+
}, Se = () => ({ editor: e, view: t }) => (requestAnimationFrame(() => {
|
|
117
118
|
if (!e.isDestroyed) {
|
|
118
119
|
var n;
|
|
119
120
|
t.dom.blur(), (n = window) == null || (n = n.getSelection()) == null || n.removeAllRanges();
|
|
120
121
|
}
|
|
121
|
-
}), !0),
|
|
122
|
+
}), !0), Ce = (e = !0) => ({ commands: t }) => t.setContent("", { emitUpdate: e }), we = () => ({ state: e, tr: t, dispatch: n }) => {
|
|
122
123
|
let { selection: r } = t, { ranges: i } = r;
|
|
123
124
|
return n && i.forEach(({ $from: n, $to: r }) => {
|
|
124
125
|
e.doc.nodesBetween(n.pos, r.pos, (e, n) => {
|
|
@@ -133,12 +134,12 @@ var T = class e {
|
|
|
133
134
|
(c || c === 0) && t.lift(s, c);
|
|
134
135
|
});
|
|
135
136
|
}), !0;
|
|
136
|
-
},
|
|
137
|
+
}, Te = (e) => (t) => e(t), Ee = () => ({ state: e, dispatch: t }) => g(e, t), De = (e, t) => ({ editor: n, tr: r }) => {
|
|
137
138
|
let { state: i } = n, a = i.doc.slice(e.from, e.to);
|
|
138
139
|
r.deleteRange(e.from, e.to);
|
|
139
140
|
let s = r.mapping.map(t);
|
|
140
141
|
return r.insert(s, a.content), r.setSelection(new o(r.doc.resolve(Math.max(s - 1, 0)))), !0;
|
|
141
|
-
},
|
|
142
|
+
}, Oe = () => ({ tr: e, dispatch: t }) => {
|
|
142
143
|
let { selection: n } = e, r = n.$anchor.node();
|
|
143
144
|
if (r.content.size > 0) return !1;
|
|
144
145
|
let i = e.selection.$anchor;
|
|
@@ -151,15 +152,15 @@ var T = class e {
|
|
|
151
152
|
}
|
|
152
153
|
return !1;
|
|
153
154
|
};
|
|
154
|
-
function
|
|
155
|
+
function O(e, t) {
|
|
155
156
|
if (typeof e == "string") {
|
|
156
157
|
if (!t.nodes[e]) throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);
|
|
157
158
|
return t.nodes[e];
|
|
158
159
|
}
|
|
159
160
|
return e;
|
|
160
161
|
}
|
|
161
|
-
var
|
|
162
|
-
let i =
|
|
162
|
+
var ke = (e) => ({ tr: t, state: n, dispatch: r }) => {
|
|
163
|
+
let i = O(e, n.schema), a = t.selection.$anchor;
|
|
163
164
|
for (let e = a.depth; e > 0; --e) if (a.node(e).type === i) {
|
|
164
165
|
if (r) {
|
|
165
166
|
let n = a.before(e), r = a.after(e);
|
|
@@ -168,41 +169,41 @@ var Ae = (e) => ({ tr: t, state: n, dispatch: r }) => {
|
|
|
168
169
|
return !0;
|
|
169
170
|
}
|
|
170
171
|
return !1;
|
|
171
|
-
},
|
|
172
|
+
}, Ae = (e) => ({ tr: t, dispatch: n }) => {
|
|
172
173
|
let { from: r, to: i } = e;
|
|
173
174
|
return n && t.delete(r, i), !0;
|
|
174
|
-
},
|
|
175
|
+
}, je = (e) => e.content ? /^text(\*|\+)/.test(e.content) : !1, Me = (e, t, n) => {
|
|
175
176
|
if (!e.parent.isInline || n === "left" && e.pos > e.start() || n === "right" && e.pos < e.end()) return e.pos;
|
|
176
177
|
let r = t.nodes[e.parent.type.name].spec;
|
|
177
|
-
return
|
|
178
|
-
},
|
|
179
|
-
from:
|
|
180
|
-
to:
|
|
181
|
-
}),
|
|
178
|
+
return je(r) ? n === "left" ? e.start() - 1 : e.end() + 1 : e.pos;
|
|
179
|
+
}, Ne = (e, t, n) => ({
|
|
180
|
+
from: Me(e, n, "left"),
|
|
181
|
+
to: Me(t, n, "right")
|
|
182
|
+
}), Pe = () => ({ state: e, dispatch: t }) => {
|
|
182
183
|
if (e.selection.empty) return !1;
|
|
183
184
|
if (t) {
|
|
184
185
|
let n = e.tr, { ranges: r } = e.selection, i = n.steps.length;
|
|
185
186
|
r.forEach((t) => {
|
|
186
|
-
let r = n.mapping.slice(i), { from: a, to: o } =
|
|
187
|
+
let r = n.mapping.slice(i), { from: a, to: o } = Ne(n.doc.resolve(r.map(t.$from.pos)), n.doc.resolve(r.map(t.$to.pos)), e.schema);
|
|
187
188
|
n.deleteRange(a, o);
|
|
188
189
|
}), n.selection.empty || n.setSelection(o.near(n.doc.resolve(n.selection.from))), n.scrollIntoView(), t(n);
|
|
189
190
|
}
|
|
190
191
|
return !0;
|
|
191
|
-
},
|
|
192
|
-
function
|
|
192
|
+
}, Fe = () => ({ commands: e }) => e.keyboardShortcut("Enter"), Ie = () => ({ state: e, dispatch: t }) => _(e, t);
|
|
193
|
+
function Le(e) {
|
|
193
194
|
return Object.prototype.toString.call(e) === "[object RegExp]";
|
|
194
195
|
}
|
|
195
|
-
function
|
|
196
|
+
function Re(e, t, n = { strict: !0 }) {
|
|
196
197
|
let r = Object.keys(t);
|
|
197
|
-
return !r.length || r.every((r) => n.strict ? t[r] === e[r] :
|
|
198
|
+
return !r.length || r.every((r) => n.strict ? t[r] === e[r] : Le(t[r]) ? t[r].test(e[r]) : t[r] === e[r]);
|
|
198
199
|
}
|
|
199
200
|
function ze(e, t, n = {}) {
|
|
200
|
-
return e.find((e) => e.type === t &&
|
|
201
|
+
return e.find((e) => e.type === t && Re(Object.fromEntries(Object.keys(n).map((t) => [t, e.attrs[t]])), n));
|
|
201
202
|
}
|
|
202
203
|
function Be(e, t, n = {}) {
|
|
203
204
|
return !!ze(e, t, n);
|
|
204
205
|
}
|
|
205
|
-
function
|
|
206
|
+
function k(e, t, n) {
|
|
206
207
|
if (!e || !t) return;
|
|
207
208
|
let r = e.parent.childAfter(e.parentOffset);
|
|
208
209
|
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;
|
|
@@ -219,7 +220,7 @@ function O(e, t, n) {
|
|
|
219
220
|
to: s
|
|
220
221
|
};
|
|
221
222
|
}
|
|
222
|
-
function
|
|
223
|
+
function A(e, t) {
|
|
223
224
|
if (typeof e == "string") {
|
|
224
225
|
if (!t.marks[e]) throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);
|
|
225
226
|
return t.marks[e];
|
|
@@ -227,9 +228,9 @@ function k(e, t) {
|
|
|
227
228
|
return e;
|
|
228
229
|
}
|
|
229
230
|
var Ve = (e, t) => ({ tr: n, state: r, dispatch: i }) => {
|
|
230
|
-
let a =
|
|
231
|
+
let a = A(e, r.schema), { doc: s, selection: c } = n, { $from: l, from: u, to: d } = c;
|
|
231
232
|
if (i) {
|
|
232
|
-
let e =
|
|
233
|
+
let e = k(l, a, t);
|
|
233
234
|
if (e && e.from <= u && e.to >= d) {
|
|
234
235
|
let t = o.create(s, e.from, e.to);
|
|
235
236
|
n.setSelection(t);
|
|
@@ -244,7 +245,7 @@ var Ve = (e, t) => ({ tr: n, state: r, dispatch: i }) => {
|
|
|
244
245
|
function Ue(e) {
|
|
245
246
|
return e instanceof o;
|
|
246
247
|
}
|
|
247
|
-
function
|
|
248
|
+
function j(e = 0, t = 0, n = 0) {
|
|
248
249
|
return Math.min(Math.max(e, t), n);
|
|
249
250
|
}
|
|
250
251
|
function We(e, t = null) {
|
|
@@ -253,12 +254,12 @@ function We(e, t = null) {
|
|
|
253
254
|
if (t === "start" || t === !0) return n;
|
|
254
255
|
if (t === "end") return r;
|
|
255
256
|
let i = n.from, s = r.to;
|
|
256
|
-
return t === "all" ? o.create(e,
|
|
257
|
+
return t === "all" ? o.create(e, j(0, i, s), j(e.content.size, i, s)) : o.create(e, j(t, i, s), j(t, i, s));
|
|
257
258
|
}
|
|
258
259
|
function Ge() {
|
|
259
260
|
return ["Android"].includes(navigator.platform) || /android/i.test(navigator.userAgent);
|
|
260
261
|
}
|
|
261
|
-
function
|
|
262
|
+
function M() {
|
|
262
263
|
return [
|
|
263
264
|
"iPad Simulator",
|
|
264
265
|
"iPhone Simulator",
|
|
@@ -277,7 +278,7 @@ var qe = (e = null, t = {}) => ({ editor: n, view: r, tr: i, dispatch: a }) => {
|
|
|
277
278
|
...t
|
|
278
279
|
};
|
|
279
280
|
let o = () => {
|
|
280
|
-
(
|
|
281
|
+
(M() || Ge()) && r.dom.focus(), Ke() && !M() && !Ge() && r.dom.focus({ preventScroll: !0 }), requestAnimationFrame(() => {
|
|
281
282
|
n.isDestroyed || (r.focus(), t?.scrollIntoView && n.commands.scrollIntoView());
|
|
282
283
|
});
|
|
283
284
|
};
|
|
@@ -303,7 +304,7 @@ var qe = (e = null, t = {}) => ({ editor: n, view: r, tr: i, dispatch: a }) => {
|
|
|
303
304
|
}
|
|
304
305
|
return e;
|
|
305
306
|
};
|
|
306
|
-
function
|
|
307
|
+
function N(e) {
|
|
307
308
|
if (typeof window > "u") throw Error("[tiptap error]: there is no window object available, so this function cannot be used");
|
|
308
309
|
let t = `<body>${e}</body>`, n = new window.DOMParser().parseFromString(t, "text/html").body;
|
|
309
310
|
return Xe(n);
|
|
@@ -311,7 +312,7 @@ function M(e) {
|
|
|
311
312
|
function Ze(e) {
|
|
312
313
|
return typeof e?.nodesBetween == "function";
|
|
313
314
|
}
|
|
314
|
-
function
|
|
315
|
+
function P(e, t, n) {
|
|
315
316
|
if (Ze(e)) return e;
|
|
316
317
|
let r = typeof e == "object" && !!e;
|
|
317
318
|
n = {
|
|
@@ -321,16 +322,16 @@ function N(e, t, n) {
|
|
|
321
322
|
};
|
|
322
323
|
let i = typeof e == "string";
|
|
323
324
|
if (r) try {
|
|
324
|
-
if (Array.isArray(e) && e.length > 0) return
|
|
325
|
+
if (Array.isArray(e) && e.length > 0) return w.fromArray(e.map((e) => t.nodeFromJSON(e)));
|
|
325
326
|
let r = t.nodeFromJSON(e);
|
|
326
327
|
return n.errorOnInvalidContent && r.check(), r;
|
|
327
328
|
} catch (r) {
|
|
328
329
|
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),
|
|
330
|
+
return console.warn("[tiptap warn]: Invalid content.", "Passed value:", e, "Error:", r), P("", t, n);
|
|
330
331
|
}
|
|
331
332
|
if (i) {
|
|
332
333
|
if (n.errorOnInvalidContent) {
|
|
333
|
-
let r = !1, i = "", a = new
|
|
334
|
+
let r = !1, i = "", a = new fe({
|
|
334
335
|
topNode: t.spec.topNode,
|
|
335
336
|
marks: t.spec.marks,
|
|
336
337
|
nodes: t.spec.nodes.append({ __tiptap__private__unknown__catch__all__node: {
|
|
@@ -342,12 +343,12 @@ function N(e, t, n) {
|
|
|
342
343
|
}]
|
|
343
344
|
} })
|
|
344
345
|
});
|
|
345
|
-
if (n.slice ?
|
|
346
|
+
if (n.slice ? ue.fromSchema(a).parseSlice(N(e), n.parseOptions) : ue.fromSchema(a).parse(N(e), n.parseOptions), n.errorOnInvalidContent && r) throw Error("[tiptap error]: Invalid HTML content", { cause: /* @__PURE__ */ Error(`Invalid element found: ${i}`) });
|
|
346
347
|
}
|
|
347
|
-
let r =
|
|
348
|
-
return n.slice ? r.parseSlice(
|
|
348
|
+
let r = ue.fromSchema(t);
|
|
349
|
+
return n.slice ? r.parseSlice(N(e), n.parseOptions).content : r.parse(N(e), n.parseOptions);
|
|
349
350
|
}
|
|
350
|
-
return
|
|
351
|
+
return P("", t, n);
|
|
351
352
|
}
|
|
352
353
|
function Qe(e) {
|
|
353
354
|
return !("type" in e);
|
|
@@ -384,7 +385,7 @@ var et = (e, t, n) => ({ tr: r, dispatch: i, editor: a }) => {
|
|
|
384
385
|
...n.parseOptions
|
|
385
386
|
};
|
|
386
387
|
if (!n.errorOnInvalidContent && !a.options.enableContentCheck && a.options.emitContentError) try {
|
|
387
|
-
|
|
388
|
+
P(t, a.schema, {
|
|
388
389
|
parseOptions: s,
|
|
389
390
|
errorOnInvalidContent: !0
|
|
390
391
|
});
|
|
@@ -392,7 +393,7 @@ var et = (e, t, n) => ({ tr: r, dispatch: i, editor: a }) => {
|
|
|
392
393
|
o(e);
|
|
393
394
|
}
|
|
394
395
|
try {
|
|
395
|
-
i =
|
|
396
|
+
i = P(t, a.schema, {
|
|
396
397
|
parseOptions: s,
|
|
397
398
|
errorOnInvalidContent: n.errorOnInvalidContent ?? a.options.enableContentCheck
|
|
398
399
|
});
|
|
@@ -415,7 +416,7 @@ var et = (e, t, n) => ({ tr: r, dispatch: i, editor: a }) => {
|
|
|
415
416
|
let p;
|
|
416
417
|
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
418
|
else {
|
|
418
|
-
p =
|
|
419
|
+
p = w.from(f);
|
|
419
420
|
let e = r.doc.resolve(c), t = e.node(), n = e.parentOffset === 0, i = t.isText || t.isTextblock, a = t.content.size > 0;
|
|
420
421
|
n && i && a && d && (c = Math.max(0, c - 1)), r.replaceWith(c, l, f);
|
|
421
422
|
}
|
|
@@ -443,29 +444,32 @@ var nt = (e = {}) => ({ tr: t, dispatch: n, editor: r }) => {
|
|
|
443
444
|
if (!l) return !1;
|
|
444
445
|
let u = Object.keys(l.spec.attrs || {}), d = a ? Object.fromEntries(Object.entries(a).filter(([e]) => u.includes(e))) : {}, f;
|
|
445
446
|
if (o) {
|
|
446
|
-
let e =
|
|
447
|
+
let e = P(o, r.schema);
|
|
447
448
|
f = l.createAndFill(d, e);
|
|
448
449
|
} else f = l.createAndFill(d);
|
|
449
450
|
return f ? (n && (t.insert(c.pos, f), s && $e(t, t.steps.length - 1, -1)), !0) : !1;
|
|
450
|
-
}, rt = () => ({ state: e, dispatch: t }) =>
|
|
451
|
+
}, rt = () => ({ state: e, dispatch: t }) => te(e, t), it = () => ({ state: e, dispatch: t }) => y(e, t), at = () => ({ state: e, dispatch: t }) => v(e, t), ot = () => ({ state: e, dispatch: t }) => b(e, t), st = (e, t) => {
|
|
452
|
+
let n = e.resolve(t), r = n.nodeBefore, i = n.nodeAfter;
|
|
453
|
+
return !r || !i ? !1 : !r.type.spec.isolating && !i.type.spec.isolating;
|
|
454
|
+
}, ct = () => ({ state: e, dispatch: t, tr: n }) => {
|
|
451
455
|
try {
|
|
452
456
|
let r = m(e.doc, e.selection.$from.pos, -1);
|
|
453
|
-
return r
|
|
457
|
+
return r == null || !st(e.doc, r) ? !1 : (n.join(r, 2), t && t(n), !0);
|
|
454
458
|
} catch {
|
|
455
459
|
return !1;
|
|
456
460
|
}
|
|
457
|
-
},
|
|
461
|
+
}, lt = () => ({ state: e, dispatch: t, tr: n }) => {
|
|
458
462
|
try {
|
|
459
463
|
let r = m(e.doc, e.selection.$from.pos, 1);
|
|
460
|
-
return r
|
|
464
|
+
return r == null || !st(e.doc, r) ? !1 : (n.join(r, 2), t && t(n), !0);
|
|
461
465
|
} catch {
|
|
462
466
|
return !1;
|
|
463
467
|
}
|
|
464
|
-
},
|
|
465
|
-
function
|
|
468
|
+
}, ut = () => ({ state: e, dispatch: t }) => x(e, t), dt = () => ({ state: e, dispatch: t }) => ee(e, t);
|
|
469
|
+
function ft() {
|
|
466
470
|
return typeof navigator < "u" && /Mac/.test(navigator.platform);
|
|
467
471
|
}
|
|
468
|
-
function
|
|
472
|
+
function pt(e) {
|
|
469
473
|
let t = e.split(/-(?!$)/), n = t[t.length - 1];
|
|
470
474
|
n === "Space" && (n = " ");
|
|
471
475
|
let r, i, a, o;
|
|
@@ -475,13 +479,13 @@ function ft(e) {
|
|
|
475
479
|
else if (/^a(lt)?$/i.test(n)) r = !0;
|
|
476
480
|
else if (/^(c|ctrl|control)$/i.test(n)) i = !0;
|
|
477
481
|
else if (/^s(hift)?$/i.test(n)) a = !0;
|
|
478
|
-
else if (/^mod$/i.test(n))
|
|
482
|
+
else if (/^mod$/i.test(n)) M() || ft() ? o = !0 : i = !0;
|
|
479
483
|
else throw Error(`Unrecognized modifier name: ${n}`);
|
|
480
484
|
}
|
|
481
485
|
return r && (n = `Alt-${n}`), i && (n = `Ctrl-${n}`), o && (n = `Meta-${n}`), a && (n = `Shift-${n}`), n;
|
|
482
486
|
}
|
|
483
|
-
var
|
|
484
|
-
let a =
|
|
487
|
+
var mt = (e) => ({ editor: t, view: n, tr: r, dispatch: i }) => {
|
|
488
|
+
let a = pt(e).split(/-(?!$)/), o = a.find((e) => ![
|
|
485
489
|
"Alt",
|
|
486
490
|
"Ctrl",
|
|
487
491
|
"Meta",
|
|
@@ -502,8 +506,8 @@ var pt = (e) => ({ editor: t, view: n, tr: r, dispatch: i }) => {
|
|
|
502
506
|
t && i && r.maybeStep(t);
|
|
503
507
|
}), !0;
|
|
504
508
|
};
|
|
505
|
-
function
|
|
506
|
-
let { from: r, to: i, empty: a } = e.selection, o = t ?
|
|
509
|
+
function F(e, t, n = {}) {
|
|
510
|
+
let { from: r, to: i, empty: a } = e.selection, o = t ? O(t, e.schema) : null, s = [];
|
|
507
511
|
e.doc.nodesBetween(r, i, (e, t) => {
|
|
508
512
|
if (e.isText) return;
|
|
509
513
|
let n = Math.max(r, t), a = Math.min(i, t + e.nodeSize);
|
|
@@ -513,50 +517,50 @@ function P(e, t, n = {}) {
|
|
|
513
517
|
to: a
|
|
514
518
|
});
|
|
515
519
|
});
|
|
516
|
-
let c = i - r, l = s.filter((e) => !o || o.name === e.node.type.name).filter((e) =>
|
|
520
|
+
let c = i - r, l = s.filter((e) => !o || o.name === e.node.type.name).filter((e) => Re(e.node.attrs, n, { strict: !1 }));
|
|
517
521
|
return a ? !!l.length : l.reduce((e, t) => e + t.to - t.from, 0) >= c;
|
|
518
522
|
}
|
|
519
|
-
var
|
|
520
|
-
let r =
|
|
521
|
-
return
|
|
522
|
-
},
|
|
523
|
-
function
|
|
523
|
+
var ht = (e, t = {}) => ({ state: n, dispatch: r }) => F(n, O(e, n.schema), t) ? S(n, r) : !1, gt = () => ({ state: e, dispatch: t }) => ne(e, t), _t = (e) => ({ state: t, dispatch: n }) => {
|
|
524
|
+
let r = O(e, t.schema);
|
|
525
|
+
return me(r)(t, n);
|
|
526
|
+
}, vt = () => ({ state: e, dispatch: t }) => C(e, t);
|
|
527
|
+
function I(e, t) {
|
|
524
528
|
return t.nodes[e] ? "node" : t.marks[e] ? "mark" : null;
|
|
525
529
|
}
|
|
526
|
-
function
|
|
530
|
+
function yt(e, t) {
|
|
527
531
|
let n = typeof t == "string" ? [t] : t;
|
|
528
532
|
return Object.keys(e).reduce((t, r) => (n.includes(r) || (t[r] = e[r]), t), {});
|
|
529
533
|
}
|
|
530
|
-
var
|
|
531
|
-
let a = null, o = null, s =
|
|
534
|
+
var bt = (e, t) => ({ tr: n, state: r, dispatch: i }) => {
|
|
535
|
+
let a = null, o = null, s = I(typeof e == "string" ? e : e.name, r.schema);
|
|
532
536
|
if (!s) return !1;
|
|
533
|
-
s === "node" && (a =
|
|
537
|
+
s === "node" && (a = O(e, r.schema)), s === "mark" && (o = A(e, r.schema));
|
|
534
538
|
let c = !1;
|
|
535
539
|
return n.selection.ranges.forEach((e) => {
|
|
536
540
|
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(
|
|
541
|
+
a && a === e.type && (c = !0, i && n.setNodeMarkup(r, void 0, yt(e.attrs, t))), o && e.marks.length && e.marks.forEach((a) => {
|
|
542
|
+
o === a.type && (c = !0, i && n.addMark(r, r + e.nodeSize, o.create(yt(a.attrs, t))));
|
|
539
543
|
});
|
|
540
544
|
});
|
|
541
545
|
}), c;
|
|
542
|
-
},
|
|
546
|
+
}, xt = () => ({ tr: e, dispatch: t }) => (t && e.scrollIntoView(), !0), St = () => ({ tr: t, dispatch: n }) => {
|
|
543
547
|
if (n) {
|
|
544
548
|
let n = new e(t.doc);
|
|
545
549
|
t.setSelection(n);
|
|
546
550
|
}
|
|
547
551
|
return !0;
|
|
548
|
-
},
|
|
549
|
-
function
|
|
550
|
-
return
|
|
552
|
+
}, Ct = () => ({ state: e, dispatch: t }) => re(e, t), wt = () => ({ state: e, dispatch: t }) => ie(e, t), Tt = () => ({ state: e, dispatch: t }) => ae(e, t), Et = () => ({ state: e, dispatch: t }) => oe(e, t), Dt = () => ({ state: e, dispatch: t }) => se(e, t);
|
|
553
|
+
function Ot(e, t, n = {}, r = {}) {
|
|
554
|
+
return P(e, t, {
|
|
551
555
|
slice: !1,
|
|
552
556
|
parseOptions: n,
|
|
553
557
|
errorOnInvalidContent: r.errorOnInvalidContent
|
|
554
558
|
});
|
|
555
559
|
}
|
|
556
|
-
var
|
|
560
|
+
var kt = (e, { errorOnInvalidContent: t, emitUpdate: n = !0, parseOptions: r = {} } = {}) => ({ editor: i, tr: a, dispatch: o, commands: s }) => {
|
|
557
561
|
let { doc: c } = a;
|
|
558
562
|
if (r.preserveWhitespace !== "full") {
|
|
559
|
-
let s =
|
|
563
|
+
let s = Ot(e, i.schema, r, { errorOnInvalidContent: t ?? i.options.enableContentCheck });
|
|
560
564
|
if (o) {
|
|
561
565
|
let e = Qe(s) ? s.content : [s];
|
|
562
566
|
a.replaceWith(0, c.content.size, e).setMeta("preventUpdate", !n);
|
|
@@ -571,15 +575,15 @@ var Ot = (e, { errorOnInvalidContent: t, emitUpdate: n = !0, parseOptions: r = {
|
|
|
571
575
|
errorOnInvalidContent: t ?? i.options.enableContentCheck
|
|
572
576
|
});
|
|
573
577
|
};
|
|
574
|
-
function
|
|
575
|
-
let n =
|
|
578
|
+
function At(e, t) {
|
|
579
|
+
let n = A(t, e.schema), { from: r, to: i, empty: a } = e.selection, o = [];
|
|
576
580
|
a ? (e.storedMarks && o.push(...e.storedMarks), o.push(...e.selection.$head.marks())) : e.doc.nodesBetween(r, i, (e) => {
|
|
577
581
|
o.push(...e.marks);
|
|
578
582
|
});
|
|
579
583
|
let s = o.find((e) => e.type.name === n.name);
|
|
580
584
|
return s ? { ...s.attrs } : {};
|
|
581
585
|
}
|
|
582
|
-
function
|
|
586
|
+
function jt(e, t) {
|
|
583
587
|
let n = new u(e);
|
|
584
588
|
return t.forEach((e) => {
|
|
585
589
|
e.steps.forEach((e) => {
|
|
@@ -587,7 +591,7 @@ function At(e, t) {
|
|
|
587
591
|
});
|
|
588
592
|
}), n;
|
|
589
593
|
}
|
|
590
|
-
function
|
|
594
|
+
function Mt(e, t, n) {
|
|
591
595
|
let r = [];
|
|
592
596
|
return e.nodesBetween(t.from, t.to, (e, t) => {
|
|
593
597
|
n(e) && r.push({
|
|
@@ -596,7 +600,7 @@ function jt(e, t, n) {
|
|
|
596
600
|
});
|
|
597
601
|
}), r;
|
|
598
602
|
}
|
|
599
|
-
function
|
|
603
|
+
function Nt(e, t) {
|
|
600
604
|
for (let n = e.depth; n > 0; --n) {
|
|
601
605
|
let r = e.node(n);
|
|
602
606
|
if (t(r)) return {
|
|
@@ -607,47 +611,47 @@ function Mt(e, t) {
|
|
|
607
611
|
};
|
|
608
612
|
}
|
|
609
613
|
}
|
|
610
|
-
function
|
|
611
|
-
return (t) =>
|
|
614
|
+
function L(e) {
|
|
615
|
+
return (t) => Nt(t.$from, e);
|
|
612
616
|
}
|
|
613
|
-
function
|
|
614
|
-
return e.config[t] === void 0 && e.parent ?
|
|
617
|
+
function R(e, t, n) {
|
|
618
|
+
return e.config[t] === void 0 && e.parent ? R(e.parent, t, n) : typeof e.config[t] == "function" ? e.config[t].bind({
|
|
615
619
|
...n,
|
|
616
|
-
parent: e.parent ?
|
|
620
|
+
parent: e.parent ? R(e.parent, t, n) : null
|
|
617
621
|
}) : e.config[t];
|
|
618
622
|
}
|
|
619
|
-
function
|
|
623
|
+
function Pt(e) {
|
|
620
624
|
return e.map((e) => {
|
|
621
|
-
let t =
|
|
625
|
+
let t = R(e, "addExtensions", {
|
|
622
626
|
name: e.name,
|
|
623
627
|
options: e.options,
|
|
624
628
|
storage: e.storage
|
|
625
629
|
});
|
|
626
|
-
return t ? [e, ...
|
|
630
|
+
return t ? [e, ...Pt(t())] : e;
|
|
627
631
|
}).flat(10);
|
|
628
632
|
}
|
|
629
|
-
function
|
|
630
|
-
let n =
|
|
633
|
+
function Ft(e, t) {
|
|
634
|
+
let n = de.fromSchema(t).serializeFragment(e), r = document.implementation.createHTMLDocument().createElement("div");
|
|
631
635
|
return r.appendChild(n), r.innerHTML;
|
|
632
636
|
}
|
|
633
|
-
function
|
|
637
|
+
function It(e) {
|
|
634
638
|
return typeof e == "function";
|
|
635
639
|
}
|
|
636
|
-
function
|
|
637
|
-
return
|
|
640
|
+
function z(e, t = void 0, ...n) {
|
|
641
|
+
return It(e) ? t ? e.bind(t)(...n) : e(...n) : e;
|
|
638
642
|
}
|
|
639
|
-
function
|
|
643
|
+
function Lt(e = {}) {
|
|
640
644
|
return Object.keys(e).length === 0 && e.constructor === Object;
|
|
641
645
|
}
|
|
642
|
-
function
|
|
646
|
+
function B(e) {
|
|
643
647
|
return {
|
|
644
648
|
baseExtensions: e.filter((e) => e.type === "extension"),
|
|
645
649
|
nodeExtensions: e.filter((e) => e.type === "node"),
|
|
646
650
|
markExtensions: e.filter((e) => e.type === "mark")
|
|
647
651
|
};
|
|
648
652
|
}
|
|
649
|
-
function
|
|
650
|
-
let t = [], { nodeExtensions: n, markExtensions: r } =
|
|
653
|
+
function Rt(e) {
|
|
654
|
+
let t = [], { nodeExtensions: n, markExtensions: r } = B(e), i = [...n, ...r], a = {
|
|
651
655
|
default: null,
|
|
652
656
|
validate: void 0,
|
|
653
657
|
rendered: !0,
|
|
@@ -657,7 +661,7 @@ function Lt(e) {
|
|
|
657
661
|
isRequired: !1
|
|
658
662
|
}, o = n.filter((e) => e.name !== "text").map((e) => e.name), s = r.map((e) => e.name), c = [...o, ...s];
|
|
659
663
|
return e.forEach((e) => {
|
|
660
|
-
let n =
|
|
664
|
+
let n = R(e, "addGlobalAttributes", {
|
|
661
665
|
name: e.name,
|
|
662
666
|
options: e.options,
|
|
663
667
|
storage: e.storage,
|
|
@@ -679,7 +683,7 @@ function Lt(e) {
|
|
|
679
683
|
});
|
|
680
684
|
});
|
|
681
685
|
}), i.forEach((e) => {
|
|
682
|
-
let n =
|
|
686
|
+
let n = R(e, "addAttributes", {
|
|
683
687
|
name: e.name,
|
|
684
688
|
options: e.options,
|
|
685
689
|
storage: e.storage
|
|
@@ -699,7 +703,7 @@ function Lt(e) {
|
|
|
699
703
|
});
|
|
700
704
|
}), t;
|
|
701
705
|
}
|
|
702
|
-
function
|
|
706
|
+
function zt(e) {
|
|
703
707
|
let t = [], n = "", r = !1, i = !1, a = 0, o = e.length;
|
|
704
708
|
for (let s = 0; s < o; s += 1) {
|
|
705
709
|
let o = e[s];
|
|
@@ -729,8 +733,8 @@ function Rt(e) {
|
|
|
729
733
|
}
|
|
730
734
|
return n && t.push(n), t;
|
|
731
735
|
}
|
|
732
|
-
function
|
|
733
|
-
let t = [], n =
|
|
736
|
+
function Bt(e) {
|
|
737
|
+
let t = [], n = zt(e || ""), r = n.length;
|
|
734
738
|
for (let e = 0; e < r; e += 1) {
|
|
735
739
|
let r = n[e], i = r.indexOf(":");
|
|
736
740
|
if (i === -1) continue;
|
|
@@ -739,7 +743,7 @@ function zt(e) {
|
|
|
739
743
|
}
|
|
740
744
|
return t;
|
|
741
745
|
}
|
|
742
|
-
function
|
|
746
|
+
function Vt(...e) {
|
|
743
747
|
return e.filter((e) => !!e).reduce((e, t) => {
|
|
744
748
|
let n = { ...e };
|
|
745
749
|
return Object.entries(t).forEach(([e, t]) => {
|
|
@@ -760,26 +764,26 @@ function Bt(...e) {
|
|
|
760
764
|
let r = t ? String(t).split(" ") : [], i = n[e] ? n[e].split(" ") : [], a = r.filter((e) => !i.includes(e));
|
|
761
765
|
n[e] = [...i, ...a].join(" ");
|
|
762
766
|
} else if (e === "style") {
|
|
763
|
-
let r = new Map([...
|
|
767
|
+
let r = new Map([...Bt(n[e]), ...Bt(t)]);
|
|
764
768
|
n[e] = Array.from(r.entries()).map(([e, t]) => `${e}: ${t}`).join("; ");
|
|
765
769
|
} else n[e] = t;
|
|
766
770
|
}), n;
|
|
767
771
|
}, {});
|
|
768
772
|
}
|
|
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) =>
|
|
773
|
+
function V(e, t) {
|
|
774
|
+
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) => Vt(e, t), {});
|
|
771
775
|
}
|
|
772
|
-
function
|
|
776
|
+
function Ht(e) {
|
|
773
777
|
return typeof e == "string" ? e.match(/^[+-]?(?:\d*\.)?\d+$/) ? Number(e) : e === "true" || e !== "false" && e : e;
|
|
774
778
|
}
|
|
775
|
-
function
|
|
779
|
+
function Ut(e, t) {
|
|
776
780
|
return "style" in e ? e : {
|
|
777
781
|
...e,
|
|
778
782
|
getAttrs: (n) => {
|
|
779
783
|
let r = e.getAttrs ? e.getAttrs(n) : e.attrs;
|
|
780
784
|
if (r === !1) return !1;
|
|
781
785
|
let i = t.reduce((e, t) => {
|
|
782
|
-
let r = t.attribute.parseHTML ? t.attribute.parseHTML(n) :
|
|
786
|
+
let r = t.attribute.parseHTML ? t.attribute.parseHTML(n) : Ht(n.getAttribute(t.name));
|
|
783
787
|
return r == null ? e : {
|
|
784
788
|
...e,
|
|
785
789
|
[t.name]: r
|
|
@@ -792,50 +796,50 @@ function Ht(e, t) {
|
|
|
792
796
|
}
|
|
793
797
|
};
|
|
794
798
|
}
|
|
795
|
-
function Ut(e) {
|
|
796
|
-
return Object.fromEntries(Object.entries(e).filter(([e, t]) => e === "attrs" && It(t) ? !1 : t != null));
|
|
797
|
-
}
|
|
798
799
|
function Wt(e) {
|
|
800
|
+
return Object.fromEntries(Object.entries(e).filter(([e, t]) => e === "attrs" && Lt(t) ? !1 : t != null));
|
|
801
|
+
}
|
|
802
|
+
function Gt(e) {
|
|
799
803
|
var t, n;
|
|
800
804
|
let r = {};
|
|
801
805
|
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
806
|
}
|
|
803
|
-
function
|
|
804
|
-
let n =
|
|
807
|
+
function Kt(e, t) {
|
|
808
|
+
let n = Rt(e), { nodeExtensions: r, markExtensions: i } = B(e), a = r.find((e) => R(e, "topNode"))?.name, o = Object.fromEntries(r.map((r) => {
|
|
805
809
|
let i = n.filter((e) => e.type === r.name), a = {
|
|
806
810
|
name: r.name,
|
|
807
811
|
options: r.options,
|
|
808
812
|
storage: r.storage,
|
|
809
813
|
editor: t
|
|
810
|
-
}, o =
|
|
814
|
+
}, o = Wt({
|
|
811
815
|
...e.reduce((e, t) => {
|
|
812
|
-
let n =
|
|
816
|
+
let n = R(t, "extendNodeSchema", a);
|
|
813
817
|
return {
|
|
814
818
|
...e,
|
|
815
819
|
...n ? n(r) : {}
|
|
816
820
|
};
|
|
817
821
|
}, {}),
|
|
818
|
-
content: R(
|
|
819
|
-
marks: R(
|
|
820
|
-
group: R(
|
|
821
|
-
inline: R(
|
|
822
|
-
atom: R(
|
|
823
|
-
selectable: R(
|
|
824
|
-
draggable: R(
|
|
825
|
-
code: R(
|
|
826
|
-
whitespace: R(
|
|
827
|
-
linebreakReplacement: R(
|
|
828
|
-
defining: R(
|
|
829
|
-
isolating: R(
|
|
830
|
-
attrs: Object.fromEntries(i.map(
|
|
831
|
-
}), s = R(
|
|
832
|
-
s && (o.parseDOM = s.map((e) =>
|
|
833
|
-
let c =
|
|
822
|
+
content: z(R(r, "content", a)),
|
|
823
|
+
marks: z(R(r, "marks", a)),
|
|
824
|
+
group: z(R(r, "group", a)),
|
|
825
|
+
inline: z(R(r, "inline", a)),
|
|
826
|
+
atom: z(R(r, "atom", a)),
|
|
827
|
+
selectable: z(R(r, "selectable", a)),
|
|
828
|
+
draggable: z(R(r, "draggable", a)),
|
|
829
|
+
code: z(R(r, "code", a)),
|
|
830
|
+
whitespace: z(R(r, "whitespace", a)),
|
|
831
|
+
linebreakReplacement: z(R(r, "linebreakReplacement", a)),
|
|
832
|
+
defining: z(R(r, "defining", a)),
|
|
833
|
+
isolating: z(R(r, "isolating", a)),
|
|
834
|
+
attrs: Object.fromEntries(i.map(Gt))
|
|
835
|
+
}), s = z(R(r, "parseHTML", a));
|
|
836
|
+
s && (o.parseDOM = s.map((e) => Ut(e, i)));
|
|
837
|
+
let c = R(r, "renderHTML", a);
|
|
834
838
|
c && (o.toDOM = (e) => c({
|
|
835
839
|
node: e,
|
|
836
|
-
HTMLAttributes:
|
|
840
|
+
HTMLAttributes: V(e, i)
|
|
837
841
|
}));
|
|
838
|
-
let l =
|
|
842
|
+
let l = R(r, "renderText", a);
|
|
839
843
|
return l && (o.toText = l), [r.name, o];
|
|
840
844
|
})), s = Object.fromEntries(i.map((r) => {
|
|
841
845
|
let i = n.filter((e) => e.type === r.name), a = {
|
|
@@ -843,49 +847,49 @@ function Gt(e, t) {
|
|
|
843
847
|
options: r.options,
|
|
844
848
|
storage: r.storage,
|
|
845
849
|
editor: t
|
|
846
|
-
}, o =
|
|
850
|
+
}, o = Wt({
|
|
847
851
|
...e.reduce((e, t) => {
|
|
848
|
-
let n =
|
|
852
|
+
let n = R(t, "extendMarkSchema", a);
|
|
849
853
|
return {
|
|
850
854
|
...e,
|
|
851
855
|
...n ? n(r) : {}
|
|
852
856
|
};
|
|
853
857
|
}, {}),
|
|
854
|
-
inclusive: R(
|
|
855
|
-
excludes: R(
|
|
856
|
-
group: R(
|
|
857
|
-
spanning: R(
|
|
858
|
-
code: R(
|
|
859
|
-
attrs: Object.fromEntries(i.map(
|
|
860
|
-
}), s = R(
|
|
861
|
-
s && (o.parseDOM = s.map((e) =>
|
|
862
|
-
let c =
|
|
858
|
+
inclusive: z(R(r, "inclusive", a)),
|
|
859
|
+
excludes: z(R(r, "excludes", a)),
|
|
860
|
+
group: z(R(r, "group", a)),
|
|
861
|
+
spanning: z(R(r, "spanning", a)),
|
|
862
|
+
code: z(R(r, "code", a)),
|
|
863
|
+
attrs: Object.fromEntries(i.map(Gt))
|
|
864
|
+
}), s = z(R(r, "parseHTML", a));
|
|
865
|
+
s && (o.parseDOM = s.map((e) => Ut(e, i)));
|
|
866
|
+
let c = R(r, "renderHTML", a);
|
|
863
867
|
return c && (o.toDOM = (e) => c({
|
|
864
868
|
mark: e,
|
|
865
|
-
HTMLAttributes:
|
|
869
|
+
HTMLAttributes: V(e, i)
|
|
866
870
|
})), [r.name, o];
|
|
867
871
|
}));
|
|
868
|
-
return new
|
|
872
|
+
return new fe({
|
|
869
873
|
topNode: a,
|
|
870
874
|
nodes: o,
|
|
871
875
|
marks: s
|
|
872
876
|
});
|
|
873
877
|
}
|
|
874
|
-
function
|
|
878
|
+
function qt(e) {
|
|
875
879
|
let t = e.filter((t, n) => e.indexOf(t) !== n);
|
|
876
880
|
return Array.from(new Set(t));
|
|
877
881
|
}
|
|
878
|
-
function
|
|
882
|
+
function H(e) {
|
|
879
883
|
return e.sort((e, t) => {
|
|
880
|
-
let n =
|
|
884
|
+
let n = R(e, "priority") || 100, r = R(t, "priority") || 100;
|
|
881
885
|
return n > r ? -1 : +(n < r);
|
|
882
886
|
});
|
|
883
887
|
}
|
|
884
|
-
function
|
|
885
|
-
let t =
|
|
888
|
+
function Jt(e) {
|
|
889
|
+
let t = H(Pt(e)), n = qt(t.map((e) => e.name));
|
|
886
890
|
return n.length && console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map((e) => `'${e}'`).join(", ")}]. This can lead to issues.`), t;
|
|
887
891
|
}
|
|
888
|
-
function
|
|
892
|
+
function Yt(e, t, n) {
|
|
889
893
|
let { from: r, to: i } = t, { blockSeparator: a = "\n\n", textSerializers: o = {} } = n || {}, s = "";
|
|
890
894
|
return e.nodesBetween(r, i, (e, n, c, l) => {
|
|
891
895
|
e.isBlock && n > r && (s += a);
|
|
@@ -903,39 +907,39 @@ function Jt(e, t, n) {
|
|
|
903
907
|
}
|
|
904
908
|
}), s;
|
|
905
909
|
}
|
|
906
|
-
function
|
|
907
|
-
return
|
|
910
|
+
function Xt(e, t) {
|
|
911
|
+
return Yt(e, {
|
|
908
912
|
from: 0,
|
|
909
913
|
to: e.content.size
|
|
910
914
|
}, t);
|
|
911
915
|
}
|
|
912
|
-
function
|
|
916
|
+
function Zt(e) {
|
|
913
917
|
return Object.fromEntries(Object.entries(e.nodes).filter(([, e]) => e.spec.toText).map(([e, t]) => [e, t.spec.toText]));
|
|
914
918
|
}
|
|
915
|
-
function
|
|
916
|
-
let n =
|
|
919
|
+
function Qt(e, t) {
|
|
920
|
+
let n = O(t, e.schema), { from: r, to: i } = e.selection, a = [];
|
|
917
921
|
e.doc.nodesBetween(r, i, (e) => {
|
|
918
922
|
a.push(e);
|
|
919
923
|
});
|
|
920
924
|
let o = a.reverse().find((e) => e.type.name === n.name);
|
|
921
925
|
return o ? { ...o.attrs } : {};
|
|
922
926
|
}
|
|
923
|
-
function
|
|
924
|
-
let n =
|
|
925
|
-
return n === "node" ?
|
|
927
|
+
function $t(e, t) {
|
|
928
|
+
let n = I(typeof t == "string" ? t : t.name, e.schema);
|
|
929
|
+
return n === "node" ? Qt(e, t) : n === "mark" ? At(e, t) : {};
|
|
926
930
|
}
|
|
927
|
-
function
|
|
931
|
+
function en(e, t = JSON.stringify) {
|
|
928
932
|
let n = {};
|
|
929
933
|
return e.filter((e) => {
|
|
930
934
|
let r = t(e);
|
|
931
935
|
return Object.prototype.hasOwnProperty.call(n, r) ? !1 : n[r] = !0;
|
|
932
936
|
});
|
|
933
937
|
}
|
|
934
|
-
function
|
|
935
|
-
let t =
|
|
938
|
+
function tn(e) {
|
|
939
|
+
let t = en(e);
|
|
936
940
|
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
941
|
}
|
|
938
|
-
function
|
|
942
|
+
function nn(e) {
|
|
939
943
|
let { mapping: t, steps: n } = e, r = [];
|
|
940
944
|
return t.maps.forEach((e, i) => {
|
|
941
945
|
let a = [];
|
|
@@ -966,12 +970,12 @@ function tn(e) {
|
|
|
966
970
|
}
|
|
967
971
|
});
|
|
968
972
|
});
|
|
969
|
-
}),
|
|
973
|
+
}), tn(r);
|
|
970
974
|
}
|
|
971
|
-
function
|
|
975
|
+
function rn(e, t, n) {
|
|
972
976
|
let r = [];
|
|
973
977
|
return e === t ? n.resolve(e).marks().forEach((t) => {
|
|
974
|
-
let i =
|
|
978
|
+
let i = k(n.resolve(e), t.type);
|
|
975
979
|
i && r.push({
|
|
976
980
|
mark: t,
|
|
977
981
|
...i
|
|
@@ -984,14 +988,14 @@ function H(e, t, n) {
|
|
|
984
988
|
})));
|
|
985
989
|
}), r;
|
|
986
990
|
}
|
|
987
|
-
var
|
|
991
|
+
var an = (e, t, n, r = 20) => {
|
|
988
992
|
let i = e.doc.resolve(n), a = r, o = null;
|
|
989
993
|
for (; a > 0 && o === null;) {
|
|
990
994
|
let e = i.node(a);
|
|
991
995
|
e?.type.name === t ? o = e : --a;
|
|
992
996
|
}
|
|
993
997
|
return [o, a];
|
|
994
|
-
},
|
|
998
|
+
}, on = (e) => {
|
|
995
999
|
let t = e.depth - 1;
|
|
996
1000
|
if (t < 0) return null;
|
|
997
1001
|
let n = e.index(t);
|
|
@@ -1006,7 +1010,7 @@ function W(e, t, n) {
|
|
|
1006
1010
|
return r ? r.attribute.keepOnSplit : !1;
|
|
1007
1011
|
}));
|
|
1008
1012
|
}
|
|
1009
|
-
var
|
|
1013
|
+
var sn = (e, t = 500) => {
|
|
1010
1014
|
let n = "", r = e.parentOffset;
|
|
1011
1015
|
return e.parent.nodesBetween(Math.max(0, r - t), r, (e, t, i, a) => {
|
|
1012
1016
|
var o;
|
|
@@ -1019,9 +1023,9 @@ var an = (e, t = 500) => {
|
|
|
1019
1023
|
n += e.isAtom && !e.isText ? s : s.slice(0, Math.max(0, r - t));
|
|
1020
1024
|
}), n;
|
|
1021
1025
|
};
|
|
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) =>
|
|
1026
|
+
function cn(e, t, n = {}) {
|
|
1027
|
+
let { empty: r, ranges: i } = e.selection, a = t ? A(t, e.schema) : null;
|
|
1028
|
+
if (r) return !!(e.storedMarks || e.selection.$from.marks()).filter((e) => !a || a.name === e.type.name).find((e) => Re(e.attrs, n, { strict: !1 }));
|
|
1025
1029
|
let o = 0, s = [];
|
|
1026
1030
|
if (i.forEach(({ $from: t, $to: n }) => {
|
|
1027
1031
|
let r = t.pos, i = n.pos;
|
|
@@ -1036,34 +1040,34 @@ function on(e, t, n = {}) {
|
|
|
1036
1040
|
})));
|
|
1037
1041
|
});
|
|
1038
1042
|
}), o === 0) return !1;
|
|
1039
|
-
let c = s.filter((e) => !a || a.name === e.mark.type.name).filter((e) =>
|
|
1043
|
+
let c = s.filter((e) => !a || a.name === e.mark.type.name).filter((e) => Re(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
1044
|
return (c > 0 ? c + l : c) >= o;
|
|
1041
1045
|
}
|
|
1042
|
-
function
|
|
1043
|
-
if (!t) return
|
|
1044
|
-
let r =
|
|
1045
|
-
return r === "node" ?
|
|
1046
|
+
function ln(e, t, n = {}) {
|
|
1047
|
+
if (!t) return F(e, null, n) || cn(e, null, n);
|
|
1048
|
+
let r = I(t, e.schema);
|
|
1049
|
+
return r === "node" ? F(e, t, n) : r === "mark" && cn(e, t, n);
|
|
1046
1050
|
}
|
|
1047
|
-
var
|
|
1051
|
+
var un = (e, t) => {
|
|
1048
1052
|
let { $from: n, $to: r, $anchor: i } = e.selection;
|
|
1049
1053
|
if (t) {
|
|
1050
|
-
let n =
|
|
1054
|
+
let n = L((e) => e.type.name === t)(e.selection);
|
|
1051
1055
|
if (!n) return !1;
|
|
1052
1056
|
let r = e.doc.resolve(n.pos + 1);
|
|
1053
1057
|
return i.pos + 1 === r.end();
|
|
1054
1058
|
}
|
|
1055
1059
|
return !(r.parentOffset < r.parent.nodeSize - 2 || n.pos !== r.pos);
|
|
1056
|
-
},
|
|
1060
|
+
}, dn = (e) => {
|
|
1057
1061
|
let { $from: t, $to: n } = e.selection;
|
|
1058
1062
|
return !(t.parentOffset > 0 || t.pos !== n.pos);
|
|
1059
1063
|
};
|
|
1060
|
-
function
|
|
1064
|
+
function fn(e, t) {
|
|
1061
1065
|
return Array.isArray(t) ? t.some((t) => (typeof t == "string" ? t : t.name) === e.name) : t;
|
|
1062
1066
|
}
|
|
1063
|
-
function
|
|
1064
|
-
let { nodeExtensions: n } =
|
|
1067
|
+
function pn(e, t) {
|
|
1068
|
+
let { nodeExtensions: n } = B(t), r = n.find((t) => t.name === e);
|
|
1065
1069
|
if (!r) return !1;
|
|
1066
|
-
let i = R(
|
|
1070
|
+
let i = z(R(r, "group", {
|
|
1067
1071
|
name: r.name,
|
|
1068
1072
|
options: r.options,
|
|
1069
1073
|
storage: r.storage
|
|
@@ -1089,10 +1093,10 @@ function G(e, { checkChildren: t = !0, ignoreWhitespace: n = !1 } = {}) {
|
|
|
1089
1093
|
}
|
|
1090
1094
|
return !1;
|
|
1091
1095
|
}
|
|
1092
|
-
function
|
|
1096
|
+
function mn(e) {
|
|
1093
1097
|
return e instanceof n;
|
|
1094
1098
|
}
|
|
1095
|
-
var
|
|
1099
|
+
var hn = class e {
|
|
1096
1100
|
constructor(e) {
|
|
1097
1101
|
this.position = e;
|
|
1098
1102
|
}
|
|
@@ -1103,18 +1107,18 @@ var pn = class e {
|
|
|
1103
1107
|
return { position: this.position };
|
|
1104
1108
|
}
|
|
1105
1109
|
};
|
|
1106
|
-
function
|
|
1110
|
+
function gn(e, t) {
|
|
1107
1111
|
let n = t.mapping.mapResult(e.position);
|
|
1108
1112
|
return {
|
|
1109
|
-
position: new
|
|
1113
|
+
position: new hn(n.pos),
|
|
1110
1114
|
mapResult: n
|
|
1111
1115
|
};
|
|
1112
1116
|
}
|
|
1113
|
-
function
|
|
1114
|
-
return new
|
|
1117
|
+
function _n(e) {
|
|
1118
|
+
return new hn(e);
|
|
1115
1119
|
}
|
|
1116
|
-
function
|
|
1117
|
-
let r = e.state.doc.content.size, i =
|
|
1120
|
+
function vn(e, t, n) {
|
|
1121
|
+
let r = e.state.doc.content.size, i = j(t, 0, r), a = j(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
1122
|
top: c,
|
|
1119
1123
|
bottom: l,
|
|
1120
1124
|
left: u,
|
|
@@ -1129,7 +1133,7 @@ function gn(e, t, n) {
|
|
|
1129
1133
|
toJSON: () => f
|
|
1130
1134
|
};
|
|
1131
1135
|
}
|
|
1132
|
-
function
|
|
1136
|
+
function yn(e, t, n) {
|
|
1133
1137
|
let { selection: r } = t, i = null;
|
|
1134
1138
|
if (Ue(r) && (i = r.$cursor), i) {
|
|
1135
1139
|
let t = e.storedMarks ?? i.marks();
|
|
@@ -1148,11 +1152,11 @@ function _n(e, t, n) {
|
|
|
1148
1152
|
}), i;
|
|
1149
1153
|
});
|
|
1150
1154
|
}
|
|
1151
|
-
var
|
|
1152
|
-
let { selection: a } = n, { empty: o, ranges: s } = a, c =
|
|
1155
|
+
var bn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
|
|
1156
|
+
let { selection: a } = n, { empty: o, ranges: s } = a, c = A(e, r.schema);
|
|
1153
1157
|
if (i) {
|
|
1154
1158
|
if (o) {
|
|
1155
|
-
let e =
|
|
1159
|
+
let e = At(r, c);
|
|
1156
1160
|
n.addStoredMark(c.create({
|
|
1157
1161
|
...e,
|
|
1158
1162
|
...t
|
|
@@ -1170,23 +1174,23 @@ var vn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
|
|
|
1170
1174
|
});
|
|
1171
1175
|
});
|
|
1172
1176
|
}
|
|
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 }) =>
|
|
1177
|
+
return yn(r, n, c);
|
|
1178
|
+
}, xn = (e, t) => ({ tr: n }) => (n.setMeta(e, t), !0), Sn = (e, t = {}) => ({ state: n, dispatch: r, chain: i }) => {
|
|
1179
|
+
let a = O(e, n.schema), o;
|
|
1180
|
+
return n.selection.$anchor.sameParent(n.selection.$head) && (o = n.selection.$anchor.parent.attrs), a.isTextblock ? i().command(({ commands: e }) => ce(a, {
|
|
1177
1181
|
...o,
|
|
1178
1182
|
...t
|
|
1179
|
-
})(n) ? !0 : e.clearNodes()).command(({ state: e }) =>
|
|
1183
|
+
})(n) ? !0 : e.clearNodes()).command(({ state: e }) => ce(a, {
|
|
1180
1184
|
...o,
|
|
1181
1185
|
...t
|
|
1182
1186
|
})(e, r)).run() : (console.warn("[tiptap warn]: Currently \"setNode()\" only supports text block nodes."), !1);
|
|
1183
|
-
},
|
|
1187
|
+
}, Cn = (e) => ({ tr: t, dispatch: r }) => {
|
|
1184
1188
|
if (r) {
|
|
1185
|
-
let { doc: r } = t, i =
|
|
1189
|
+
let { doc: r } = t, i = j(e, 0, r.content.size), a = n.create(r, i);
|
|
1186
1190
|
t.setSelection(a);
|
|
1187
1191
|
}
|
|
1188
1192
|
return !0;
|
|
1189
|
-
},
|
|
1193
|
+
}, wn = (e, t) => ({ tr: n, state: r, dispatch: i }) => {
|
|
1190
1194
|
let { selection: a } = r, o, s;
|
|
1191
1195
|
return typeof t == "number" ? (o = t, s = t) : t && "from" in t && "to" in t ? (o = t.from, s = t.to) : (o = a.from, s = a.to), i && n.doc.nodesBetween(o, s, (t, r) => {
|
|
1192
1196
|
t.isText || n.setNodeMarkup(r, void 0, {
|
|
@@ -1194,47 +1198,53 @@ var vn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
|
|
|
1194
1198
|
dir: e
|
|
1195
1199
|
});
|
|
1196
1200
|
}), !0;
|
|
1197
|
-
},
|
|
1201
|
+
}, Tn = (e) => ({ tr: t, dispatch: n }) => {
|
|
1198
1202
|
if (n) {
|
|
1199
1203
|
let { doc: n } = t, { from: r, to: i } = typeof e == "number" ? {
|
|
1200
1204
|
from: e,
|
|
1201
1205
|
to: e
|
|
1202
|
-
} : e, a = o.atStart(n).from, s = o.atEnd(n).to, c =
|
|
1206
|
+
} : e, a = o.atStart(n).from, s = o.atEnd(n).to, c = j(r, a, s), l = j(i, a, s), u = o.create(n, c, l);
|
|
1203
1207
|
t.setSelection(u);
|
|
1204
1208
|
}
|
|
1205
1209
|
return !0;
|
|
1206
|
-
},
|
|
1207
|
-
let r =
|
|
1208
|
-
return
|
|
1210
|
+
}, En = (e) => ({ state: t, dispatch: n }) => {
|
|
1211
|
+
let r = O(e, t.schema);
|
|
1212
|
+
return he(r)(t, n);
|
|
1209
1213
|
};
|
|
1210
|
-
function
|
|
1214
|
+
function Dn(e, t) {
|
|
1211
1215
|
let n = e.storedMarks || e.selection.$to.parentOffset && e.selection.$from.marks();
|
|
1212
1216
|
if (n) {
|
|
1213
1217
|
let r = n.filter((e) => t?.includes(e.type.name));
|
|
1214
1218
|
e.tr.ensureMarks(r);
|
|
1215
1219
|
}
|
|
1216
1220
|
}
|
|
1217
|
-
var
|
|
1218
|
-
let { selection:
|
|
1219
|
-
if (
|
|
1220
|
-
if (!
|
|
1221
|
-
let
|
|
1222
|
-
type:
|
|
1223
|
-
attrs:
|
|
1224
|
-
}] : void 0,
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
}] : void 0),
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1221
|
+
var On = ({ keepMarks: e = !0 } = {}) => ({ tr: r, state: i, dispatch: a, editor: s }) => {
|
|
1222
|
+
let { selection: c, doc: l } = r, { $from: u, $to: d } = c, p = s.extensionManager.attributes, m = W(p, u.node().type.name, u.node().attrs);
|
|
1223
|
+
if (c instanceof n && c.node.isBlock) return !u.parentOffset || !f(l, u.pos) ? !1 : (a && (e && Dn(i, s.extensionManager.splittableMarks), r.split(u.pos).scrollIntoView()), !0);
|
|
1224
|
+
if (!u.parent.isBlock) return !1;
|
|
1225
|
+
let h = d.parentOffset === d.parent.content.size, g = u.depth === 0 ? void 0 : tt(u.node(-1).contentMatchAt(u.indexAfter(-1))), _ = h && g ? [{
|
|
1226
|
+
type: g,
|
|
1227
|
+
attrs: m
|
|
1228
|
+
}] : void 0, v = c instanceof o && !c.empty ? t.create({
|
|
1229
|
+
doc: r.doc,
|
|
1230
|
+
selection: c
|
|
1231
|
+
}).tr.deleteSelection() : null, y = v ? v.doc : r.doc, b = v ? v.mapping.map(u.pos) : u.pos, x = f(y, b, 1, _);
|
|
1232
|
+
if (!_ && !x && f(y, b, 1, g ? [{ type: g }] : void 0) && (x = !0, _ = g ? [{
|
|
1233
|
+
type: g,
|
|
1234
|
+
attrs: m
|
|
1235
|
+
}] : void 0), a) {
|
|
1236
|
+
if (x) {
|
|
1237
|
+
let e = r.steps.length;
|
|
1238
|
+
if (c instanceof o && r.deleteSelection(), r.split(r.mapping.slice(e).map(u.pos), 1, _), g && !h && !u.parentOffset && u.parent.type !== g) {
|
|
1239
|
+
let t = r.mapping.slice(e).map(u.before()), n = r.doc.resolve(t);
|
|
1240
|
+
u.node(-1).canReplaceWith(n.index(), n.index() + 1, g) && r.setNodeMarkup(r.mapping.slice(e).map(u.before()), g);
|
|
1241
|
+
}
|
|
1232
1242
|
}
|
|
1233
|
-
e &&
|
|
1243
|
+
e && Dn(i, s.extensionManager.splittableMarks), r.scrollIntoView();
|
|
1234
1244
|
}
|
|
1235
|
-
return
|
|
1236
|
-
},
|
|
1237
|
-
let s =
|
|
1245
|
+
return x;
|
|
1246
|
+
}, kn = (e, t = {}) => ({ tr: n, state: r, dispatch: i, editor: a }) => {
|
|
1247
|
+
let s = O(e, r.schema), { $from: c, $to: l } = r.selection, u = r.selection.node;
|
|
1238
1248
|
if (u && u.isBlock || c.depth < 2 || !c.sameParent(l)) return !1;
|
|
1239
1249
|
let d = c.node(-1);
|
|
1240
1250
|
if (d.type !== s) return !1;
|
|
@@ -1242,15 +1252,15 @@ var En = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: r, dispatch: i, editor
|
|
|
1242
1252
|
if (c.parent.content.size === 0 && c.node(-1).childCount === c.indexAfter(-1)) {
|
|
1243
1253
|
if (c.depth === 2 || c.node(-3).type !== s || c.index(-2) !== c.node(-2).childCount - 1) return !1;
|
|
1244
1254
|
if (i) {
|
|
1245
|
-
let e =
|
|
1246
|
-
for (let t = c.depth - r; t >= c.depth - 3; --t) e =
|
|
1255
|
+
let e = w.empty, r = c.index(-1) ? 1 : c.index(-2) ? 2 : 3;
|
|
1256
|
+
for (let t = c.depth - r; t >= c.depth - 3; --t) e = w.from(c.node(t).copy(e));
|
|
1247
1257
|
let i = c.indexAfter(-1) < c.node(-2).childCount ? 1 : c.indexAfter(-2) < c.node(-3).childCount ? 2 : 3, a = {
|
|
1248
1258
|
...W(p, c.node().type.name, c.node().attrs),
|
|
1249
1259
|
...t
|
|
1250
1260
|
}, l = s.contentMatch.defaultType?.createAndFill(a) || void 0;
|
|
1251
|
-
e = e.append(
|
|
1261
|
+
e = e.append(w.from(s.createAndFill(null, l) || void 0));
|
|
1252
1262
|
let u = c.before(c.depth - (r - 1));
|
|
1253
|
-
n.replace(u, c.after(-i), new
|
|
1263
|
+
n.replace(u, c.after(-i), new pe(e, 4 - r, 0));
|
|
1254
1264
|
let d = -1;
|
|
1255
1265
|
n.doc.nodesBetween(u, n.doc.content.size, (e, t) => {
|
|
1256
1266
|
if (d > -1) return !1;
|
|
@@ -1265,86 +1275,86 @@ var En = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: r, dispatch: i, editor
|
|
|
1265
1275
|
}, g = {
|
|
1266
1276
|
...W(p, c.node().type.name, c.node().attrs),
|
|
1267
1277
|
...t
|
|
1268
|
-
};
|
|
1278
|
+
}, _ = c.parentOffset === 0 && c.index(-1) === 0, v = c.before(-1);
|
|
1269
1279
|
n.delete(c.pos, l.pos);
|
|
1270
|
-
let _ = m ? [{
|
|
1280
|
+
let y = _ ? d.attrs : h, b = m ? [{
|
|
1271
1281
|
type: s,
|
|
1272
|
-
attrs:
|
|
1282
|
+
attrs: y
|
|
1273
1283
|
}, {
|
|
1274
1284
|
type: m,
|
|
1275
1285
|
attrs: g
|
|
1276
1286
|
}] : [{
|
|
1277
1287
|
type: s,
|
|
1278
|
-
attrs:
|
|
1288
|
+
attrs: y
|
|
1279
1289
|
}];
|
|
1280
1290
|
if (!f(n.doc, c.pos, 2)) return !1;
|
|
1281
1291
|
if (i) {
|
|
1282
1292
|
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,
|
|
1293
|
+
if (n.split(c.pos, 2, b).scrollIntoView(), _ && n.setNodeMarkup(v, void 0, h), !s || !i) return !0;
|
|
1284
1294
|
let l = s.filter((e) => o.includes(e.type.name));
|
|
1285
1295
|
n.ensureMarks(l);
|
|
1286
1296
|
}
|
|
1287
1297
|
return !0;
|
|
1288
1298
|
};
|
|
1289
|
-
function
|
|
1299
|
+
function An(e) {
|
|
1290
1300
|
return !e || e === "1" ? null : e;
|
|
1291
1301
|
}
|
|
1292
|
-
function
|
|
1293
|
-
return
|
|
1302
|
+
function jn(e, t) {
|
|
1303
|
+
return An(e) === An(t);
|
|
1294
1304
|
}
|
|
1295
|
-
var
|
|
1296
|
-
let n =
|
|
1305
|
+
var Mn = (e, t) => {
|
|
1306
|
+
let n = L((e) => e.type === t)(e.selection);
|
|
1297
1307
|
if (!n) return !0;
|
|
1298
1308
|
let r = e.doc.resolve(Math.max(0, n.pos - 1)).before(n.depth);
|
|
1299
1309
|
if (r === void 0) return !0;
|
|
1300
1310
|
let i = e.doc.nodeAt(r);
|
|
1301
|
-
return !(n.node.type === i?.type && d(e.doc, n.pos)) || !
|
|
1302
|
-
},
|
|
1303
|
-
let n =
|
|
1311
|
+
return !(n.node.type === i?.type && d(e.doc, n.pos)) || !jn(n.node.attrs.type, i?.attrs.type) || e.join(n.pos), !0;
|
|
1312
|
+
}, Nn = (e, t) => {
|
|
1313
|
+
let n = L((e) => e.type === t)(e.selection);
|
|
1304
1314
|
if (!n) return !0;
|
|
1305
1315
|
let r = e.doc.resolve(n.start).after(n.depth);
|
|
1306
1316
|
if (r === void 0) return !0;
|
|
1307
1317
|
let i = e.doc.nodeAt(r);
|
|
1308
|
-
return !(n.node.type === i?.type && d(e.doc, r)) || !
|
|
1318
|
+
return !(n.node.type === i?.type && d(e.doc, r)) || !jn(n.node.attrs.type, i?.attrs.type) || e.join(r), !0;
|
|
1309
1319
|
};
|
|
1310
|
-
function
|
|
1320
|
+
function Pn(e) {
|
|
1311
1321
|
let t = e.doc, n = t.firstChild;
|
|
1312
1322
|
if (!n) return null;
|
|
1313
1323
|
let r = t.resolve(1), i = t.resolve(n.nodeSize - 1);
|
|
1314
1324
|
return o.between(r, i);
|
|
1315
1325
|
}
|
|
1316
|
-
var
|
|
1317
|
-
let { extensions: d, splittableMarks: f } = i.extensionManager, p =
|
|
1318
|
-
if (!
|
|
1319
|
-
let
|
|
1320
|
-
node:
|
|
1326
|
+
var Fn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain: c, commands: l, can: u }) => {
|
|
1327
|
+
let { extensions: d, splittableMarks: f } = i.extensionManager, p = O(e, o.schema), m = O(t, o.schema), { selection: h, storedMarks: g } = o, { $from: _, $to: v } = h, y = _.blockRange(v), b = g || h.$to.parentOffset && h.$from.marks();
|
|
1328
|
+
if (!y) return !1;
|
|
1329
|
+
let x = L((e) => pn(e.type.name, d))(h), ee = h.from === 0 && h.to === o.doc.content.size, te = o.doc.content.content, S = te.length === 1 ? te[0] : null, ne = ee && S && pn(S.type.name, d) ? {
|
|
1330
|
+
node: S,
|
|
1321
1331
|
pos: 0,
|
|
1322
1332
|
depth: 0
|
|
1323
|
-
} : null,
|
|
1324
|
-
if ((
|
|
1325
|
-
if (
|
|
1326
|
-
let n =
|
|
1333
|
+
} : null, C = x ?? ne, re = !!x && y.depth >= 1 && y.depth - x.depth <= 1, ie = !!ne;
|
|
1334
|
+
if ((re || ie) && C) {
|
|
1335
|
+
if (C.node.type === p) return ee && ie ? c().command(({ tr: e, dispatch: t }) => {
|
|
1336
|
+
let n = Pn(e);
|
|
1327
1337
|
return n ? (e.setSelection(n), t && t(e), !0) : !1;
|
|
1328
1338
|
}).liftListItem(m).run() : l.liftListItem(m);
|
|
1329
|
-
if (
|
|
1339
|
+
if (pn(C.node.type.name, d) && p.validContent(C.node.content)) return c().command(() => (a.setNodeMarkup(C.pos, p), !0)).command(() => Mn(a, p)).command(() => Nn(a, p)).run();
|
|
1330
1340
|
}
|
|
1331
|
-
return !n || !
|
|
1332
|
-
let e = u().wrapInList(p, r), t =
|
|
1341
|
+
return !n || !b || !s ? c().command(() => u().wrapInList(p, r) ? !0 : l.clearNodes()).wrapInList(p, r).command(() => Mn(a, p)).command(() => Nn(a, p)).run() : c().command(() => {
|
|
1342
|
+
let e = u().wrapInList(p, r), t = b.filter((e) => f.includes(e.type.name));
|
|
1333
1343
|
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 =
|
|
1344
|
+
}).wrapInList(p, r).command(() => Mn(a, p)).command(() => Nn(a, p)).run();
|
|
1345
|
+
}, In = (e, t = {}, n = {}) => ({ state: r, commands: i }) => {
|
|
1346
|
+
let { extendEmptyMarkRange: a = !1 } = n, o = A(e, r.schema);
|
|
1347
|
+
return cn(r, o, t) ? i.unsetMark(o, { extendEmptyMarkRange: a }) : i.setMark(o, t);
|
|
1348
|
+
}, Ln = (e, t, n = {}) => ({ state: r, commands: i }) => {
|
|
1349
|
+
let a = O(e, r.schema), o = O(t, r.schema), s = F(r, a, n), c;
|
|
1340
1350
|
return r.selection.$anchor.sameParent(r.selection.$head) && (c = r.selection.$anchor.parent.attrs), s ? i.setNode(o, c) : i.setNode(a, {
|
|
1341
1351
|
...c,
|
|
1342
1352
|
...n
|
|
1343
1353
|
});
|
|
1344
|
-
},
|
|
1345
|
-
let i =
|
|
1346
|
-
return
|
|
1347
|
-
},
|
|
1354
|
+
}, Rn = (e, t = {}) => ({ state: n, commands: r }) => {
|
|
1355
|
+
let i = O(e, n.schema);
|
|
1356
|
+
return F(n, i, t) ? r.lift(i) : r.wrapIn(i, t);
|
|
1357
|
+
}, zn = () => ({ state: e, dispatch: t }) => {
|
|
1348
1358
|
let n = e.plugins;
|
|
1349
1359
|
for (let r = 0; r < n.length; r += 1) {
|
|
1350
1360
|
let i = n[r], a;
|
|
@@ -1361,7 +1371,7 @@ var Nn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain:
|
|
|
1361
1371
|
}
|
|
1362
1372
|
}
|
|
1363
1373
|
return !1;
|
|
1364
|
-
},
|
|
1374
|
+
}, Bn = (e = {}) => ({ tr: t, dispatch: n, editor: r }) => {
|
|
1365
1375
|
let { ignoreClearable: i = !1 } = e, { selection: a } = t, { empty: o, ranges: s } = a;
|
|
1366
1376
|
if (o) return !0;
|
|
1367
1377
|
let { nonClearableMarks: c } = r.extensionManager;
|
|
@@ -1372,27 +1382,27 @@ var Nn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain:
|
|
|
1372
1382
|
});
|
|
1373
1383
|
}
|
|
1374
1384
|
return !0;
|
|
1375
|
-
},
|
|
1376
|
-
let { extendEmptyMarkRange: a = !1 } = t, { selection: o } = n, s =
|
|
1385
|
+
}, Vn = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
|
|
1386
|
+
let { extendEmptyMarkRange: a = !1 } = t, { selection: o } = n, s = A(e, r.schema), { $from: c, empty: l, ranges: u } = o;
|
|
1377
1387
|
if (!i) return !0;
|
|
1378
1388
|
if (l && a) {
|
|
1379
|
-
let { from: e, to: t } = o, r =
|
|
1389
|
+
let { from: e, to: t } = o, r = k(c, s, c.marks().find((e) => e.type === s)?.attrs);
|
|
1380
1390
|
r && (e = r.from, t = r.to), n.removeMark(e, t, s);
|
|
1381
1391
|
} else u.forEach((e) => {
|
|
1382
1392
|
n.removeMark(e.$from.pos, e.$to.pos, s);
|
|
1383
1393
|
});
|
|
1384
1394
|
return n.removeStoredMark(s), !0;
|
|
1385
|
-
},
|
|
1395
|
+
}, Hn = (e) => ({ tr: t, state: n, dispatch: r }) => {
|
|
1386
1396
|
let { selection: i } = n, a, o;
|
|
1387
1397
|
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
1398
|
if (e.isText) return;
|
|
1389
1399
|
let r = { ...e.attrs };
|
|
1390
1400
|
delete r.dir, t.setNodeMarkup(n, void 0, r);
|
|
1391
1401
|
}), !0;
|
|
1392
|
-
},
|
|
1393
|
-
let a = null, o = null, s =
|
|
1402
|
+
}, Un = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => {
|
|
1403
|
+
let a = null, o = null, s = I(typeof e == "string" ? e : e.name, r.schema);
|
|
1394
1404
|
if (!s) return !1;
|
|
1395
|
-
s === "node" && (a =
|
|
1405
|
+
s === "node" && (a = O(e, r.schema)), s === "mark" && (o = A(e, r.schema));
|
|
1396
1406
|
let c = !1;
|
|
1397
1407
|
return n.selection.ranges.forEach((e) => {
|
|
1398
1408
|
let s = e.$from.pos, l = e.$to.pos, u, d, f, p;
|
|
@@ -1421,28 +1431,28 @@ var Nn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain:
|
|
|
1421
1431
|
}));
|
|
1422
1432
|
}));
|
|
1423
1433
|
}), c;
|
|
1424
|
-
}, K = new i("__tiptap_decorations__"),
|
|
1434
|
+
}, K = new i("__tiptap_decorations__"), Wn = (e) => ({ tr: t, dispatch: n }) => (n && t.setMeta(K, {
|
|
1425
1435
|
type: "force",
|
|
1426
1436
|
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: () =>
|
|
1437
|
+
}), !0), Gn = (e, t = {}) => ({ state: n, dispatch: r }) => {
|
|
1438
|
+
let i = O(e, n.schema);
|
|
1439
|
+
return le(i, t)(n, r);
|
|
1440
|
+
}, Kn = (e, t = {}) => ({ state: n, dispatch: r }) => {
|
|
1441
|
+
let i = O(e, n.schema);
|
|
1442
|
+
return ge(i, t)(n, r);
|
|
1443
|
+
}, qn = /* @__PURE__ */ xe({
|
|
1444
|
+
blur: () => Se,
|
|
1445
|
+
clearContent: () => Ce,
|
|
1446
|
+
clearNodes: () => we,
|
|
1447
|
+
command: () => Te,
|
|
1448
|
+
createParagraphNear: () => Ee,
|
|
1449
|
+
cut: () => De,
|
|
1450
|
+
deleteCurrentNode: () => Oe,
|
|
1451
|
+
deleteNode: () => ke,
|
|
1452
|
+
deleteRange: () => Ae,
|
|
1453
|
+
deleteSelection: () => Pe,
|
|
1454
|
+
enter: () => Fe,
|
|
1455
|
+
exitCode: () => Ie,
|
|
1446
1456
|
extendMarkRange: () => Ve,
|
|
1447
1457
|
first: () => He,
|
|
1448
1458
|
focus: () => qe,
|
|
@@ -1453,48 +1463,48 @@ var Nn = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain:
|
|
|
1453
1463
|
joinBackward: () => at,
|
|
1454
1464
|
joinDown: () => it,
|
|
1455
1465
|
joinForward: () => ot,
|
|
1456
|
-
joinItemBackward: () =>
|
|
1457
|
-
joinItemForward: () =>
|
|
1458
|
-
joinTextblockBackward: () =>
|
|
1459
|
-
joinTextblockForward: () =>
|
|
1466
|
+
joinItemBackward: () => ct,
|
|
1467
|
+
joinItemForward: () => lt,
|
|
1468
|
+
joinTextblockBackward: () => ut,
|
|
1469
|
+
joinTextblockForward: () => dt,
|
|
1460
1470
|
joinUp: () => rt,
|
|
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: () =>
|
|
1471
|
+
keyboardShortcut: () => mt,
|
|
1472
|
+
lift: () => ht,
|
|
1473
|
+
liftEmptyBlock: () => gt,
|
|
1474
|
+
liftListItem: () => _t,
|
|
1475
|
+
newlineInCode: () => vt,
|
|
1476
|
+
resetAttributes: () => bt,
|
|
1477
|
+
scrollIntoView: () => xt,
|
|
1478
|
+
selectAll: () => St,
|
|
1479
|
+
selectNodeBackward: () => Ct,
|
|
1480
|
+
selectNodeForward: () => wt,
|
|
1481
|
+
selectParentNode: () => Tt,
|
|
1482
|
+
selectTextblockEnd: () => Et,
|
|
1483
|
+
selectTextblockStart: () => Dt,
|
|
1484
|
+
setContent: () => kt,
|
|
1485
|
+
setMark: () => bn,
|
|
1486
|
+
setMeta: () => xn,
|
|
1487
|
+
setNode: () => Sn,
|
|
1488
|
+
setNodeSelection: () => Cn,
|
|
1489
|
+
setTextDirection: () => wn,
|
|
1490
|
+
setTextSelection: () => Tn,
|
|
1491
|
+
sinkListItem: () => En,
|
|
1492
|
+
splitBlock: () => On,
|
|
1493
|
+
splitListItem: () => kn,
|
|
1494
|
+
toggleList: () => Fn,
|
|
1495
|
+
toggleMark: () => In,
|
|
1496
|
+
toggleNode: () => Ln,
|
|
1497
|
+
toggleWrap: () => Rn,
|
|
1498
|
+
undoInputRule: () => zn,
|
|
1499
|
+
unsetAllMarks: () => Bn,
|
|
1500
|
+
unsetMark: () => Vn,
|
|
1501
|
+
unsetTextDirection: () => Hn,
|
|
1502
|
+
updateAttributes: () => Un,
|
|
1503
|
+
updateDecorations: () => Wn,
|
|
1504
|
+
wrapIn: () => Gn,
|
|
1505
|
+
wrapInList: () => Kn
|
|
1496
1506
|
}), q = /* @__PURE__ */ new WeakMap();
|
|
1497
|
-
function
|
|
1507
|
+
function Jn(e, t) {
|
|
1498
1508
|
q.set(e, (q.get(e) ?? 0) + 1);
|
|
1499
1509
|
try {
|
|
1500
1510
|
return t();
|
|
@@ -1503,10 +1513,10 @@ function Kn(e, t) {
|
|
|
1503
1513
|
t > 0 ? q.set(e, t) : q.delete(e);
|
|
1504
1514
|
}
|
|
1505
1515
|
}
|
|
1506
|
-
function
|
|
1516
|
+
function Yn(e) {
|
|
1507
1517
|
return q.has(e);
|
|
1508
1518
|
}
|
|
1509
|
-
var
|
|
1519
|
+
var Xn = class {
|
|
1510
1520
|
constructor() {
|
|
1511
1521
|
this.callbacks = {};
|
|
1512
1522
|
}
|
|
@@ -1530,44 +1540,44 @@ var Jn = class {
|
|
|
1530
1540
|
removeAllListeners() {
|
|
1531
1541
|
this.callbacks = {};
|
|
1532
1542
|
}
|
|
1533
|
-
},
|
|
1534
|
-
function
|
|
1543
|
+
}, Zn = typeof process < "u" && process.env.NODE_ENV !== "production";
|
|
1544
|
+
function Qn(e) {
|
|
1535
1545
|
return e.kind === "widget";
|
|
1536
1546
|
}
|
|
1537
|
-
function
|
|
1547
|
+
function $n(e, t) {
|
|
1538
1548
|
let n = [], r = /* @__PURE__ */ new Set();
|
|
1539
|
-
for (let i of e) i.kind === "widget" &&
|
|
1549
|
+
for (let i of e) i.kind === "widget" && Qn(i) && r.add(i.key), n.push(i.toPMDecoration(t));
|
|
1540
1550
|
return {
|
|
1541
1551
|
decorations: n,
|
|
1542
1552
|
widgetKeys: r
|
|
1543
1553
|
};
|
|
1544
1554
|
}
|
|
1545
|
-
function
|
|
1546
|
-
let { decorations: r, widgetKeys: i } =
|
|
1555
|
+
function er(e, t, n) {
|
|
1556
|
+
let { decorations: r, widgetKeys: i } = $n(t, n);
|
|
1547
1557
|
return {
|
|
1548
|
-
set:
|
|
1558
|
+
set: T.create(e, r),
|
|
1549
1559
|
widgetKeys: i
|
|
1550
1560
|
};
|
|
1551
1561
|
}
|
|
1552
|
-
function
|
|
1562
|
+
function tr({ position: e, from: t, to: n, docSize: r }) {
|
|
1553
1563
|
return e < t ? !1 : e < n || e === n && n === r;
|
|
1554
1564
|
}
|
|
1555
|
-
function
|
|
1556
|
-
return e.filter((e) =>
|
|
1565
|
+
function nr({ decorations: e, from: t, to: n, docSize: r, extensionName: i, warnedExtensions: a }) {
|
|
1566
|
+
return e.filter((e) => tr({
|
|
1557
1567
|
position: e.anchor,
|
|
1558
1568
|
from: t,
|
|
1559
1569
|
to: n,
|
|
1560
1570
|
docSize: r
|
|
1561
1571
|
}) ? !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
1572
|
}
|
|
1563
|
-
function
|
|
1573
|
+
function rr(e) {
|
|
1564
1574
|
let t = e.spec?.key;
|
|
1565
1575
|
return typeof t == "string" ? t : void 0;
|
|
1566
1576
|
}
|
|
1567
|
-
function
|
|
1577
|
+
function ir(e) {
|
|
1568
1578
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
1569
1579
|
for (let r of e.find()) {
|
|
1570
|
-
let e =
|
|
1580
|
+
let e = rr(r);
|
|
1571
1581
|
if (!e) continue;
|
|
1572
1582
|
let i = r.spec.extensionName ?? "unknown", a = t.get(e) ?? /* @__PURE__ */ new Set();
|
|
1573
1583
|
a.add(i), t.set(e, a), n.set(e, (n.get(e) ?? 0) + 1);
|
|
@@ -1577,18 +1587,18 @@ function nr(e) {
|
|
|
1577
1587
|
extensions: t
|
|
1578
1588
|
})).filter(({ key: e }) => (n.get(e) ?? 0) > 1);
|
|
1579
1589
|
}
|
|
1580
|
-
function
|
|
1590
|
+
function ar(e) {
|
|
1581
1591
|
return e.jsonID === "attr";
|
|
1582
1592
|
}
|
|
1583
|
-
function
|
|
1593
|
+
function or(e) {
|
|
1584
1594
|
let t = !1;
|
|
1585
1595
|
if (e.getMap().forEach(() => {
|
|
1586
1596
|
t = !0;
|
|
1587
|
-
}), t ||
|
|
1597
|
+
}), t || ar(e)) return !0;
|
|
1588
1598
|
let n = e;
|
|
1589
1599
|
return typeof n.from == "number" && typeof n.to == "number";
|
|
1590
1600
|
}
|
|
1591
|
-
function
|
|
1601
|
+
function sr(e, t) {
|
|
1592
1602
|
let n = null, r = 0, i = 0;
|
|
1593
1603
|
for (let a = 0; a < e.childCount && !(i > t.to); a += 1) {
|
|
1594
1604
|
let o = i + e.child(a).nodeSize;
|
|
@@ -1599,11 +1609,11 @@ function ar(e, t) {
|
|
|
1599
1609
|
to: r
|
|
1600
1610
|
};
|
|
1601
1611
|
}
|
|
1602
|
-
function
|
|
1603
|
-
if (e.steps.some((e) => !
|
|
1604
|
-
let n =
|
|
1612
|
+
function cr(e, t) {
|
|
1613
|
+
if (e.steps.some((e) => !or(e))) return { type: "full" };
|
|
1614
|
+
let n = nn(e).map(({ newRange: e }) => e);
|
|
1605
1615
|
e.steps.forEach((t, r) => {
|
|
1606
|
-
if (!
|
|
1616
|
+
if (!ar(t)) return;
|
|
1607
1617
|
let i = e.mapping.slice(r);
|
|
1608
1618
|
n.push({
|
|
1609
1619
|
from: i.map(t.pos, -1),
|
|
@@ -1612,7 +1622,7 @@ function or(e, t) {
|
|
|
1612
1622
|
});
|
|
1613
1623
|
let r = [];
|
|
1614
1624
|
for (let e of n) {
|
|
1615
|
-
let n =
|
|
1625
|
+
let n = sr(t, e);
|
|
1616
1626
|
n && r.push(n);
|
|
1617
1627
|
}
|
|
1618
1628
|
r.sort((e, t) => e.from - t.from);
|
|
@@ -1626,29 +1636,29 @@ function or(e, t) {
|
|
|
1626
1636
|
ranges: i
|
|
1627
1637
|
};
|
|
1628
1638
|
}
|
|
1629
|
-
function
|
|
1639
|
+
function lr(e, t, n, r) {
|
|
1630
1640
|
return e.map(t, n, { onRemove: (e) => {
|
|
1631
1641
|
let t = e?.key;
|
|
1632
1642
|
typeof t == "string" && r.delete(t);
|
|
1633
1643
|
} });
|
|
1634
1644
|
}
|
|
1635
|
-
function
|
|
1636
|
-
let r = t.decorationSetsByExtension[e] ??
|
|
1645
|
+
function ur(e, t, n) {
|
|
1646
|
+
let r = t.decorationSetsByExtension[e] ?? T.empty, i = new Set(t.widgetKeysByExtension[e] ?? []);
|
|
1637
1647
|
return {
|
|
1638
|
-
set:
|
|
1648
|
+
set: lr(r, n.mapping, n.doc, i),
|
|
1639
1649
|
widgetKeys: i
|
|
1640
1650
|
};
|
|
1641
1651
|
}
|
|
1642
|
-
function
|
|
1652
|
+
function dr(e, t) {
|
|
1643
1653
|
let n = Object.values(t).flatMap((e) => e.find());
|
|
1644
|
-
return
|
|
1654
|
+
return T.create(e, n);
|
|
1645
1655
|
}
|
|
1646
|
-
function
|
|
1656
|
+
function fr(e) {
|
|
1647
1657
|
let t = /* @__PURE__ */ new Set();
|
|
1648
1658
|
for (let n of Object.values(e)) for (let e of n) t.add(e);
|
|
1649
1659
|
return t;
|
|
1650
1660
|
}
|
|
1651
|
-
function
|
|
1661
|
+
function pr(e, t) {
|
|
1652
1662
|
switch (t.update ?? "document") {
|
|
1653
1663
|
case "document":
|
|
1654
1664
|
if (t.createInRange) throw Error(`[tiptap error]: Extension "${e}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);
|
|
@@ -1663,21 +1673,21 @@ function dr(e, t) {
|
|
|
1663
1673
|
default: throw Error(`[tiptap error]: Extension "${e}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`);
|
|
1664
1674
|
}
|
|
1665
1675
|
}
|
|
1666
|
-
function
|
|
1676
|
+
function mr(e, t, n) {
|
|
1667
1677
|
return n ? !0 : e.update === "manual" ? !1 : e.shouldUpdate ? e.shouldUpdate(t) : t.tr.docChanged;
|
|
1668
1678
|
}
|
|
1669
|
-
var
|
|
1679
|
+
var hr = /* @__PURE__ */ new Set(), gr = class {
|
|
1670
1680
|
constructor(e) {
|
|
1671
1681
|
this.warnedWidgetKeys = /* @__PURE__ */ new Set(), this.warnedOutOfRangeExtensions = /* @__PURE__ */ new Set(), this.handleBeforeTransaction = ({ nextState: e }) => {
|
|
1672
1682
|
let t = K.getState(e);
|
|
1673
1683
|
t && this.warnDuplicateWidgetKeys(t);
|
|
1674
|
-
}, this.editor = e.editor, this.entries = this.resolveEntries(e.entries), this.entries.forEach(({ name: e, spec: t }) =>
|
|
1684
|
+
}, this.editor = e.editor, this.entries = this.resolveEntries(e.entries), this.entries.forEach(({ name: e, spec: t }) => pr(e, t)), this.plugin = this.entries.length > 0 ? this.createPlugin() : null, this.editor.on("beforeTransaction", this.handleBeforeTransaction);
|
|
1675
1685
|
}
|
|
1676
1686
|
destroy() {
|
|
1677
1687
|
this.editor.off("beforeTransaction", this.handleBeforeTransaction);
|
|
1678
1688
|
}
|
|
1679
1689
|
liveWidgetKeys() {
|
|
1680
|
-
return K.getState(this.editor.state)?.widgetKeys ??
|
|
1690
|
+
return K.getState(this.editor.state)?.widgetKeys ?? hr;
|
|
1681
1691
|
}
|
|
1682
1692
|
get mountedView() {
|
|
1683
1693
|
return this.editor.isDestroyed ? null : this.editor.view;
|
|
@@ -1708,22 +1718,22 @@ var pr = /* @__PURE__ */ new Set(), mr = class {
|
|
|
1708
1718
|
decorationSetsByExtension: r,
|
|
1709
1719
|
widgetKeysByExtension: i,
|
|
1710
1720
|
mergedDecorationSet: this.buildMergedSet(n.doc, r),
|
|
1711
|
-
widgetKeys:
|
|
1721
|
+
widgetKeys: fr(i)
|
|
1712
1722
|
};
|
|
1713
1723
|
return this.warnDuplicateWidgetKeys(a), a;
|
|
1714
1724
|
},
|
|
1715
1725
|
apply: (n, r, i, a) => {
|
|
1716
1726
|
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
|
|
1727
|
+
return Jn(e, () => {
|
|
1718
1728
|
for (let { name: o, spec: f } of t) {
|
|
1719
1729
|
let t = s || c === o;
|
|
1720
|
-
if (!
|
|
1730
|
+
if (!mr(f, {
|
|
1721
1731
|
editor: e,
|
|
1722
1732
|
tr: n,
|
|
1723
1733
|
oldState: i,
|
|
1724
1734
|
newState: a
|
|
1725
1735
|
}, t)) {
|
|
1726
|
-
let e =
|
|
1736
|
+
let e = ur(o, r, n);
|
|
1727
1737
|
l[o] = e.set, u[o] = e.widgetKeys;
|
|
1728
1738
|
} else if (f.update === "changedRanges" && n.docChanged && !t) {
|
|
1729
1739
|
let e = this.applyChangedRangesRecompute(o, f, r, n, a);
|
|
@@ -1743,34 +1753,34 @@ var pr = /* @__PURE__ */ new Set(), mr = class {
|
|
|
1743
1753
|
decorationSetsByExtension: l,
|
|
1744
1754
|
recomputedNames: d
|
|
1745
1755
|
}),
|
|
1746
|
-
widgetKeys:
|
|
1756
|
+
widgetKeys: fr(u)
|
|
1747
1757
|
};
|
|
1748
1758
|
}
|
|
1749
1759
|
},
|
|
1750
1760
|
props: { decorations(e) {
|
|
1751
|
-
return K.getState(e)?.mergedDecorationSet ??
|
|
1761
|
+
return K.getState(e)?.mergedDecorationSet ?? T.empty;
|
|
1752
1762
|
} }
|
|
1753
1763
|
});
|
|
1754
1764
|
}
|
|
1755
1765
|
applyChangedRangesRecompute(e, t, n, r, i) {
|
|
1756
|
-
let a =
|
|
1766
|
+
let a = cr(r, i.doc);
|
|
1757
1767
|
return a.type === "full" ? this.buildFullSet(e, t, i) : this.rebuildRanges(e, t, n, r, i, a.ranges);
|
|
1758
1768
|
}
|
|
1759
1769
|
rebuildRanges(e, t, n, r, i, a) {
|
|
1760
|
-
let o = n.decorationSetsByExtension[e] ??
|
|
1770
|
+
let o = n.decorationSetsByExtension[e] ?? T.empty, s = new Set(n.widgetKeysByExtension[e] ?? []), c = lr(o, r.mapping, r.doc, s), l = i.doc.content.size;
|
|
1761
1771
|
for (let { from: n, to: r } of a) {
|
|
1762
|
-
let a = c.find(n, r).filter((e) =>
|
|
1772
|
+
let a = c.find(n, r).filter((e) => tr({
|
|
1763
1773
|
position: e.from,
|
|
1764
1774
|
from: n,
|
|
1765
1775
|
to: r,
|
|
1766
1776
|
docSize: l
|
|
1767
1777
|
}));
|
|
1768
1778
|
for (let e of a) {
|
|
1769
|
-
let t =
|
|
1779
|
+
let t = rr(e);
|
|
1770
1780
|
t && s.delete(t);
|
|
1771
1781
|
}
|
|
1772
1782
|
c = c.remove(a);
|
|
1773
|
-
let { decorations: o, widgetKeys: u } =
|
|
1783
|
+
let { decorations: o, widgetKeys: u } = $n(nr({
|
|
1774
1784
|
decorations: this.runCreate(e, "createInRange", () => t.createInRange({
|
|
1775
1785
|
editor: this.editor,
|
|
1776
1786
|
state: i,
|
|
@@ -1798,7 +1808,7 @@ var pr = /* @__PURE__ */ new Set(), mr = class {
|
|
|
1798
1808
|
state: n,
|
|
1799
1809
|
view: this.mountedView
|
|
1800
1810
|
}));
|
|
1801
|
-
return
|
|
1811
|
+
return er(n.doc, r, e);
|
|
1802
1812
|
}
|
|
1803
1813
|
runCreate(e, t, n) {
|
|
1804
1814
|
try {
|
|
@@ -1808,12 +1818,12 @@ var pr = /* @__PURE__ */ new Set(), mr = class {
|
|
|
1808
1818
|
}
|
|
1809
1819
|
}
|
|
1810
1820
|
warnDuplicateWidgetKeys(e) {
|
|
1811
|
-
if (!
|
|
1821
|
+
if (!Zn) return;
|
|
1812
1822
|
if (e.widgetKeys.size === 0) {
|
|
1813
1823
|
this.warnedWidgetKeys.clear();
|
|
1814
1824
|
return;
|
|
1815
1825
|
}
|
|
1816
|
-
let t =
|
|
1826
|
+
let t = ir(e.mergedDecorationSet), n = new Set(t.map(({ key: e }) => e));
|
|
1817
1827
|
for (let { key: e, extensions: n } of t) {
|
|
1818
1828
|
if (this.warnedWidgetKeys.has(e)) continue;
|
|
1819
1829
|
let t = Array.from(n).map((e) => `"${e}"`).join(", ");
|
|
@@ -1823,13 +1833,13 @@ var pr = /* @__PURE__ */ new Set(), mr = class {
|
|
|
1823
1833
|
}
|
|
1824
1834
|
buildMergedSet(e, t) {
|
|
1825
1835
|
let n = Object.keys(t);
|
|
1826
|
-
return n.length === 1 ? t[n[0]] :
|
|
1836
|
+
return n.length === 1 ? t[n[0]] : dr(e, t);
|
|
1827
1837
|
}
|
|
1828
1838
|
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) :
|
|
1839
|
+
return e.length === 1 ? r[e[0].name] : i.size === 0 ? t.mergedDecorationSet.map(n.mapping, n.doc) : dr(n.doc, r);
|
|
1830
1840
|
}
|
|
1831
1841
|
};
|
|
1832
|
-
function
|
|
1842
|
+
function _r(e, t) {
|
|
1833
1843
|
let { selection: r } = e, { $from: i } = r;
|
|
1834
1844
|
if (r instanceof n) {
|
|
1835
1845
|
let e = i.index();
|
|
@@ -1843,16 +1853,16 @@ function hr(e, t) {
|
|
|
1843
1853
|
}
|
|
1844
1854
|
return !1;
|
|
1845
1855
|
}
|
|
1846
|
-
function
|
|
1856
|
+
function vr(e, t, n) {
|
|
1847
1857
|
let r = document.querySelector(`style[data-tiptap-style${n ? `-${n}` : ""}]`);
|
|
1848
1858
|
if (r !== null) return r;
|
|
1849
1859
|
let i = document.createElement("style");
|
|
1850
1860
|
return t && i.setAttribute("nonce", t), i.setAttribute(`data-tiptap-style${n ? `-${n}` : ""}`, ""), i.innerHTML = e, document.getElementsByTagName("head")[0].appendChild(i), i;
|
|
1851
1861
|
}
|
|
1852
|
-
function
|
|
1862
|
+
function yr(e) {
|
|
1853
1863
|
return e.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
1854
1864
|
}
|
|
1855
|
-
function
|
|
1865
|
+
function br(e, t) {
|
|
1856
1866
|
let n = e.getAttribute("style");
|
|
1857
1867
|
if (!n) return null;
|
|
1858
1868
|
let r = n.split(";").map((e) => e.trim()).filter(Boolean), i = t.toLowerCase();
|
|
@@ -1862,19 +1872,22 @@ function vr(e, t) {
|
|
|
1862
1872
|
}
|
|
1863
1873
|
return null;
|
|
1864
1874
|
}
|
|
1865
|
-
function
|
|
1875
|
+
function xr() {
|
|
1866
1876
|
return typeof navigator < "u" && /Firefox/.test(navigator.userAgent);
|
|
1867
1877
|
}
|
|
1868
|
-
function
|
|
1878
|
+
function Sr(e) {
|
|
1869
1879
|
return typeof e == "number";
|
|
1870
1880
|
}
|
|
1871
|
-
function
|
|
1881
|
+
function Cr(e) {
|
|
1872
1882
|
return Object.prototype.toString.call(e).slice(8, -1);
|
|
1873
1883
|
}
|
|
1874
1884
|
function J(e) {
|
|
1875
|
-
return
|
|
1885
|
+
return Cr(e) === "Object" && e.constructor === Object && Object.getPrototypeOf(e) === Object.prototype;
|
|
1876
1886
|
}
|
|
1877
|
-
function
|
|
1887
|
+
function wr(e) {
|
|
1888
|
+
return typeof e == "string" && e.trim().length > 0 && !/[;{}]/.test(e);
|
|
1889
|
+
}
|
|
1890
|
+
function Tr(e, t, n) {
|
|
1878
1891
|
let r = e.split("\n"), i = [], a = "", o = 0, s = t.baseIndentSize || 2;
|
|
1879
1892
|
for (; o < r.length;) {
|
|
1880
1893
|
let e = r[o], u = e.match(t.itemPattern);
|
|
@@ -1918,13 +1931,13 @@ function Sr(e, t, n) {
|
|
|
1918
1931
|
raw: a
|
|
1919
1932
|
};
|
|
1920
1933
|
}
|
|
1921
|
-
var
|
|
1922
|
-
function
|
|
1934
|
+
var Er = 4;
|
|
1935
|
+
function Dr(e) {
|
|
1923
1936
|
let t = 0;
|
|
1924
|
-
for (let n of e) t = n === " " ? t +
|
|
1937
|
+
for (let n of e) t = n === " " ? t + Er - t % Er : t + 1;
|
|
1925
1938
|
return t;
|
|
1926
1939
|
}
|
|
1927
|
-
function
|
|
1940
|
+
function Or(e, t, n, r, i) {
|
|
1928
1941
|
if (!e || !Array.isArray(e.content)) return "";
|
|
1929
1942
|
let a = typeof n == "function" ? n(r) : n, [o, ...s] = e.content, c = `${a}${t.renderChildren([o])}`;
|
|
1930
1943
|
return s && s.length > 0 && s.forEach((e, n) => {
|
|
@@ -1932,20 +1945,20 @@ function Tr(e, t, n, r, i) {
|
|
|
1932
1945
|
if (r != null) {
|
|
1933
1946
|
let n = (e) => {
|
|
1934
1947
|
if (!i?.alignNestedToPrefix) return t.indent(e);
|
|
1935
|
-
let n = t.indent(""), r =
|
|
1936
|
-
return (
|
|
1948
|
+
let n = t.indent(""), r = Dr(a);
|
|
1949
|
+
return (Dr(n) >= r ? n : " ".repeat(r)) + e;
|
|
1937
1950
|
}, o = r.split("\n").map((e) => n(e || "")).join("\n");
|
|
1938
1951
|
c += e.type === "paragraph" ? `\n\n${o}` : `\n${o}`;
|
|
1939
1952
|
}
|
|
1940
1953
|
}), c;
|
|
1941
1954
|
}
|
|
1942
|
-
function
|
|
1955
|
+
function kr(e, t) {
|
|
1943
1956
|
let n = { ...e };
|
|
1944
1957
|
return J(e) && J(t) && Object.keys(t).forEach((r) => {
|
|
1945
|
-
J(t[r]) && J(e[r]) ? n[r] =
|
|
1958
|
+
J(t[r]) && J(e[r]) ? n[r] = kr(e[r], t[r]) : n[r] = t[r];
|
|
1946
1959
|
}), n;
|
|
1947
1960
|
}
|
|
1948
|
-
function
|
|
1961
|
+
function Ar(e, t, n = {}) {
|
|
1949
1962
|
let { state: r } = t, { doc: i, tr: a } = r, o = e;
|
|
1950
1963
|
i.descendants((t, r) => {
|
|
1951
1964
|
let i = a.mapping.map(r), s = a.mapping.map(r) + t.nodeSize, c = null;
|
|
@@ -1969,54 +1982,88 @@ var Y = class {
|
|
|
1969
1982
|
constructor(e) {
|
|
1970
1983
|
this.find = e.find, this.handler = e.handler, this.undoable = e.undoable ?? !0;
|
|
1971
1984
|
}
|
|
1972
|
-
},
|
|
1973
|
-
if (
|
|
1985
|
+
}, jr = (e, t) => {
|
|
1986
|
+
if (Le(t)) return t.exec(e);
|
|
1974
1987
|
let n = t(e);
|
|
1975
1988
|
if (!n) return null;
|
|
1976
1989
|
let r = [n.text];
|
|
1977
1990
|
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
1991
|
};
|
|
1992
|
+
function Mr(e) {
|
|
1993
|
+
let { editor: n, from: r, to: i, text: a, insertText: o } = e;
|
|
1994
|
+
if (!o) return {
|
|
1995
|
+
inputTransaction: null,
|
|
1996
|
+
tr: n.view.state.tr
|
|
1997
|
+
};
|
|
1998
|
+
let s = n.view.state.tr.insertText(a, r, i);
|
|
1999
|
+
return {
|
|
2000
|
+
inputTransaction: s,
|
|
2001
|
+
tr: t.create({
|
|
2002
|
+
doc: s.doc,
|
|
2003
|
+
selection: s.selection,
|
|
2004
|
+
storedMarks: s.storedMarks
|
|
2005
|
+
}).tr
|
|
2006
|
+
};
|
|
2007
|
+
}
|
|
2008
|
+
function Nr(e) {
|
|
2009
|
+
let { editor: t, from: n, to: r, text: i, rule: a, match: o, plugin: s, insertText: c } = e, { view: l } = t, { inputTransaction: u, tr: d } = Mr({
|
|
2010
|
+
editor: t,
|
|
2011
|
+
from: n,
|
|
2012
|
+
to: r,
|
|
2013
|
+
text: i,
|
|
2014
|
+
insertText: c
|
|
2015
|
+
}), f = u ? n + i.length : r, p = E({
|
|
2016
|
+
state: l.state,
|
|
2017
|
+
transaction: d
|
|
2018
|
+
}), m = {
|
|
2019
|
+
from: n - (o[0].length - i.length),
|
|
2020
|
+
to: f
|
|
2021
|
+
}, { commands: h, chain: g, can: _ } = new D({
|
|
2022
|
+
editor: t,
|
|
2023
|
+
state: p
|
|
2024
|
+
});
|
|
2025
|
+
return a.handler({
|
|
2026
|
+
state: p,
|
|
2027
|
+
range: m,
|
|
2028
|
+
match: o,
|
|
2029
|
+
commands: h,
|
|
2030
|
+
chain: g,
|
|
2031
|
+
can: _
|
|
2032
|
+
}) === null || !d.steps.length ? !1 : u && (l.dispatch(u), !l.state.doc.eq(u.doc)) ? !0 : (ye(d), d.setMeta("inputRule", !0), a.undoable && d.setMeta(s, {
|
|
2033
|
+
transform: d,
|
|
2034
|
+
from: n,
|
|
2035
|
+
to: f,
|
|
2036
|
+
text: i
|
|
2037
|
+
}), l.dispatch(d), !0);
|
|
2038
|
+
}
|
|
2039
|
+
function Pr(e, t, n) {
|
|
2040
|
+
let r = t[0].length - n.length;
|
|
2041
|
+
if (r <= 0) return !0;
|
|
2042
|
+
let i = e.parentOffset - r;
|
|
2043
|
+
return i >= 0 && e.parent.textBetween(i, e.parentOffset) === t[0].slice(0, r);
|
|
2044
|
+
}
|
|
1979
2045
|
function X(e) {
|
|
1980
|
-
let { editor: t, from: n, to: r, text: i, rules: a, plugin: o } = e, { view:
|
|
1981
|
-
if (
|
|
1982
|
-
let
|
|
1983
|
-
if (
|
|
1984
|
-
let
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
if (!a) return;
|
|
1989
|
-
let d = a[0].length - i.length;
|
|
1990
|
-
if (d > 0) {
|
|
1991
|
-
let e = c.parentOffset - d;
|
|
1992
|
-
if (e < 0 || c.parent.textBetween(e, c.parentOffset) !== a[0].slice(0, d)) return;
|
|
1993
|
-
}
|
|
1994
|
-
let f = s.state.tr, p = w({
|
|
1995
|
-
state: s.state,
|
|
1996
|
-
transaction: f
|
|
1997
|
-
}), m = {
|
|
1998
|
-
from: n - (a[0].length - i.length),
|
|
1999
|
-
to: r
|
|
2000
|
-
}, { commands: h, chain: g, can: _ } = new T({
|
|
2046
|
+
let { editor: t, from: n, to: r, text: i, rules: a, plugin: o, insertText: s } = e, { view: c } = t;
|
|
2047
|
+
if (c.composing) return !1;
|
|
2048
|
+
let l = c.state.doc.resolve(n);
|
|
2049
|
+
if (l.parent.type.spec.code || (l.nodeBefore || l.nodeAfter)?.marks.find((e) => e.type.spec.code)) return !1;
|
|
2050
|
+
let u = sn(l) + i;
|
|
2051
|
+
for (let e of a) {
|
|
2052
|
+
let a = jr(u, e.find);
|
|
2053
|
+
if (a && Pr(l, a, i) && Nr({
|
|
2001
2054
|
editor: t,
|
|
2002
|
-
state: p
|
|
2003
|
-
});
|
|
2004
|
-
e.handler({
|
|
2005
|
-
state: p,
|
|
2006
|
-
range: m,
|
|
2007
|
-
match: a,
|
|
2008
|
-
commands: h,
|
|
2009
|
-
chain: g,
|
|
2010
|
-
can: _
|
|
2011
|
-
}) !== null && f.steps.length && (e.undoable && f.setMeta(o, {
|
|
2012
|
-
transform: f,
|
|
2013
2055
|
from: n,
|
|
2014
2056
|
to: r,
|
|
2015
|
-
text: i
|
|
2016
|
-
|
|
2017
|
-
|
|
2057
|
+
text: i,
|
|
2058
|
+
rule: e,
|
|
2059
|
+
match: a,
|
|
2060
|
+
plugin: o,
|
|
2061
|
+
insertText: s
|
|
2062
|
+
})) return !0;
|
|
2063
|
+
}
|
|
2064
|
+
return !1;
|
|
2018
2065
|
}
|
|
2019
|
-
function
|
|
2066
|
+
function Fr(e) {
|
|
2020
2067
|
let { editor: t, rules: n } = e, i = new r({
|
|
2021
2068
|
state: {
|
|
2022
2069
|
init() {
|
|
@@ -2028,7 +2075,7 @@ function kr(e) {
|
|
|
2028
2075
|
let s = e.getMeta("applyInputRules");
|
|
2029
2076
|
return s && setTimeout(() => {
|
|
2030
2077
|
let { text: e } = s;
|
|
2031
|
-
e = typeof e == "string" ? e :
|
|
2078
|
+
e = typeof e == "string" ? e : Ft(w.from(e), a.schema);
|
|
2032
2079
|
let { from: r } = s, o = r + e.length;
|
|
2033
2080
|
X({
|
|
2034
2081
|
editor: t,
|
|
@@ -2049,7 +2096,8 @@ function kr(e) {
|
|
|
2049
2096
|
to: a,
|
|
2050
2097
|
text: o,
|
|
2051
2098
|
rules: n,
|
|
2052
|
-
plugin: i
|
|
2099
|
+
plugin: i,
|
|
2100
|
+
insertText: !0
|
|
2053
2101
|
});
|
|
2054
2102
|
},
|
|
2055
2103
|
handleDOMEvents: { compositionend: (e) => (setTimeout(() => {
|
|
@@ -2080,7 +2128,7 @@ function kr(e) {
|
|
|
2080
2128
|
});
|
|
2081
2129
|
return i;
|
|
2082
2130
|
}
|
|
2083
|
-
var
|
|
2131
|
+
var Ir = class {
|
|
2084
2132
|
constructor(e = {}) {
|
|
2085
2133
|
this.type = "extendable", this.parent = null, this.child = null, this.name = "", this.config = { name: this.name }, this.config = {
|
|
2086
2134
|
...this.config,
|
|
@@ -2088,10 +2136,10 @@ var Ar = class {
|
|
|
2088
2136
|
}, this.name = this.config.name;
|
|
2089
2137
|
}
|
|
2090
2138
|
get options() {
|
|
2091
|
-
return { ...R(
|
|
2139
|
+
return { ...z(R(this, "addOptions", { name: this.name })) };
|
|
2092
2140
|
}
|
|
2093
2141
|
get storage() {
|
|
2094
|
-
return { ...R(
|
|
2142
|
+
return { ...z(R(this, "addStorage", {
|
|
2095
2143
|
name: this.name,
|
|
2096
2144
|
options: this.options
|
|
2097
2145
|
})) };
|
|
@@ -2099,7 +2147,7 @@ var Ar = class {
|
|
|
2099
2147
|
configure(e = {}) {
|
|
2100
2148
|
let t = this.extend({
|
|
2101
2149
|
...this.config,
|
|
2102
|
-
addOptions: () =>
|
|
2150
|
+
addOptions: () => kr(this.options, e)
|
|
2103
2151
|
});
|
|
2104
2152
|
return t.name = this.name, t.parent = this.parent, this.child = null, t;
|
|
2105
2153
|
}
|
|
@@ -2110,7 +2158,7 @@ var Ar = class {
|
|
|
2110
2158
|
});
|
|
2111
2159
|
return t.parent = this, this.child = t, t.name = "name" in e ? e.name : t.parent.name, t;
|
|
2112
2160
|
}
|
|
2113
|
-
},
|
|
2161
|
+
}, Lr = class e extends Ir {
|
|
2114
2162
|
constructor(...e) {
|
|
2115
2163
|
super(...e), this.type = "mark";
|
|
2116
2164
|
}
|
|
@@ -2135,20 +2183,20 @@ var Ar = class {
|
|
|
2135
2183
|
let t = typeof e == "function" ? e() : e;
|
|
2136
2184
|
return super.extend(t);
|
|
2137
2185
|
}
|
|
2138
|
-
},
|
|
2186
|
+
}, Rr = class {
|
|
2139
2187
|
constructor(e) {
|
|
2140
2188
|
this.find = e.find, this.handler = e.handler;
|
|
2141
2189
|
}
|
|
2142
|
-
},
|
|
2143
|
-
if (
|
|
2190
|
+
}, zr = (e, t, n) => {
|
|
2191
|
+
if (Le(t)) return [...e.matchAll(t)];
|
|
2144
2192
|
let r = t(e, n);
|
|
2145
2193
|
return r ? r.map((t) => {
|
|
2146
2194
|
let n = [t.text];
|
|
2147
2195
|
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
2196
|
}) : [];
|
|
2149
2197
|
};
|
|
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
|
|
2198
|
+
function Br(e) {
|
|
2199
|
+
let { editor: t, state: n, from: r, to: i, rule: a, pasteEvent: o, dropEvent: s } = e, { commands: c, chain: l, can: u } = new D({
|
|
2152
2200
|
editor: t,
|
|
2153
2201
|
state: n
|
|
2154
2202
|
}), d = [];
|
|
@@ -2156,7 +2204,7 @@ function Pr(e) {
|
|
|
2156
2204
|
var f;
|
|
2157
2205
|
if ((f = e.type) != null && (f = f.spec) != null && f.code || !(e.isText || e.isTextblock || e.isInline)) return;
|
|
2158
2206
|
let p = e.content?.size ?? e.nodeSize ?? 0, m = Math.max(r, t), h = Math.min(i, t + p);
|
|
2159
|
-
m >= h ||
|
|
2207
|
+
m >= h || zr(e.isText ? e.text || "" : e.textBetween(m - t, h - t, void 0, ""), a.find, o).forEach((e) => {
|
|
2160
2208
|
if (e.index === void 0) return;
|
|
2161
2209
|
let t = m + e.index + 1, r = t + e[0].length, i = {
|
|
2162
2210
|
from: n.tr.mapping.map(t),
|
|
@@ -2175,12 +2223,12 @@ function Pr(e) {
|
|
|
2175
2223
|
});
|
|
2176
2224
|
}), d.every((e) => e !== null);
|
|
2177
2225
|
}
|
|
2178
|
-
var Z = null,
|
|
2226
|
+
var Z = null, Vr = (e) => {
|
|
2179
2227
|
var t;
|
|
2180
2228
|
let n = new ClipboardEvent("paste", { clipboardData: new DataTransfer() });
|
|
2181
2229
|
return (t = n.clipboardData) == null || t.setData("text/html", e), n;
|
|
2182
2230
|
};
|
|
2183
|
-
function
|
|
2231
|
+
function Hr(e) {
|
|
2184
2232
|
let { editor: t, rules: n } = e, i = null, a = !1, o = !1, s = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, c;
|
|
2185
2233
|
try {
|
|
2186
2234
|
c = typeof DragEvent < "u" ? new DragEvent("drop") : null;
|
|
@@ -2188,11 +2236,11 @@ function Ir(e) {
|
|
|
2188
2236
|
c = null;
|
|
2189
2237
|
}
|
|
2190
2238
|
let l = ({ state: e, from: n, to: r, rule: i, pasteEvt: a }) => {
|
|
2191
|
-
let o = e.tr, l =
|
|
2239
|
+
let o = e.tr, l = E({
|
|
2192
2240
|
state: e,
|
|
2193
2241
|
transaction: o
|
|
2194
2242
|
});
|
|
2195
|
-
if (
|
|
2243
|
+
if (Br({
|
|
2196
2244
|
editor: t,
|
|
2197
2245
|
state: l,
|
|
2198
2246
|
from: Math.max(n - 1, 0),
|
|
@@ -2209,7 +2257,9 @@ function Ir(e) {
|
|
|
2209
2257
|
return s = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, o;
|
|
2210
2258
|
}
|
|
2211
2259
|
};
|
|
2212
|
-
return
|
|
2260
|
+
return t.on("destroy", () => {
|
|
2261
|
+
Z === t && (Z = null);
|
|
2262
|
+
}), n.map((e) => new r({
|
|
2213
2263
|
view(e) {
|
|
2214
2264
|
let n = (n) => {
|
|
2215
2265
|
i = e.dom.parentElement?.contains(n.target) ? e.dom.parentElement : null, i && (Z = t);
|
|
@@ -2225,6 +2275,7 @@ function Ir(e) {
|
|
|
2225
2275
|
if (o = i === e.dom.parentElement, c = t, !o) {
|
|
2226
2276
|
let e = Z;
|
|
2227
2277
|
e?.isEditable && setTimeout(() => {
|
|
2278
|
+
if (e.isDestroyed) return;
|
|
2228
2279
|
let t = e.state.selection;
|
|
2229
2280
|
t && e.commands.deleteRange({
|
|
2230
2281
|
from: t.from,
|
|
@@ -2244,8 +2295,8 @@ function Ir(e) {
|
|
|
2244
2295
|
if (!c && !u && !f) return;
|
|
2245
2296
|
if (f) {
|
|
2246
2297
|
let { text: t } = d;
|
|
2247
|
-
t = typeof t == "string" ? t :
|
|
2248
|
-
let { from: n } = d, i = n + t.length, a =
|
|
2298
|
+
t = typeof t == "string" ? t : Ft(w.from(t), r.schema);
|
|
2299
|
+
let { from: n } = d, i = n + t.length, a = Vr(t);
|
|
2249
2300
|
return l({
|
|
2250
2301
|
rule: e,
|
|
2251
2302
|
state: r,
|
|
@@ -2255,7 +2306,7 @@ function Ir(e) {
|
|
|
2255
2306
|
});
|
|
2256
2307
|
}
|
|
2257
2308
|
let p = n.doc.content.findDiffStart(r.doc.content), m = n.doc.content.findDiffEnd(r.doc.content);
|
|
2258
|
-
if (
|
|
2309
|
+
if (Sr(p) && m && p !== m.b) return l({
|
|
2259
2310
|
rule: e,
|
|
2260
2311
|
state: r,
|
|
2261
2312
|
from: p,
|
|
@@ -2267,11 +2318,11 @@ function Ir(e) {
|
|
|
2267
2318
|
}
|
|
2268
2319
|
var Q = class {
|
|
2269
2320
|
constructor(e, t) {
|
|
2270
|
-
this.splittableMarks = [], this.nonClearableMarks = [], this.decorationManager = null, this.editor = t, this.baseExtensions = e, this.extensions =
|
|
2321
|
+
this.splittableMarks = [], this.nonClearableMarks = [], this.decorationManager = null, this.editor = t, this.baseExtensions = e, this.extensions = Jt(e), this.schema = Kt(this.extensions, t), this.setupExtensions();
|
|
2271
2322
|
}
|
|
2272
2323
|
get commands() {
|
|
2273
2324
|
return this.extensions.reduce((e, t) => {
|
|
2274
|
-
let n =
|
|
2325
|
+
let n = R(t, "addCommands", {
|
|
2275
2326
|
name: t.name,
|
|
2276
2327
|
options: t.options,
|
|
2277
2328
|
storage: this.editor.extensionStorage[t.name],
|
|
@@ -2285,15 +2336,15 @@ var Q = class {
|
|
|
2285
2336
|
}, {});
|
|
2286
2337
|
}
|
|
2287
2338
|
get plugins() {
|
|
2288
|
-
let { editor: e } = this, t =
|
|
2339
|
+
let { editor: e } = this, t = H([...this.extensions].reverse()).flatMap((t) => {
|
|
2289
2340
|
let n = {
|
|
2290
2341
|
name: t.name,
|
|
2291
2342
|
options: t.options,
|
|
2292
2343
|
storage: this.editor.extensionStorage[t.name],
|
|
2293
2344
|
editor: e,
|
|
2294
2345
|
type: U(t.name, this.schema)
|
|
2295
|
-
}, r = [], i =
|
|
2296
|
-
if (t.type === "mark" &&
|
|
2346
|
+
}, r = [], i = R(t, "addKeyboardShortcuts", n), a = {};
|
|
2347
|
+
if (t.type === "mark" && R(t, "exitable", n) && (a.ArrowRight = () => Lr.handleExit({
|
|
2297
2348
|
editor: e,
|
|
2298
2349
|
mark: t
|
|
2299
2350
|
})), i) {
|
|
@@ -2303,31 +2354,31 @@ var Q = class {
|
|
|
2303
2354
|
...t
|
|
2304
2355
|
};
|
|
2305
2356
|
}
|
|
2306
|
-
let o =
|
|
2357
|
+
let o = ve(a);
|
|
2307
2358
|
r.push(o);
|
|
2308
|
-
let s =
|
|
2309
|
-
if (
|
|
2359
|
+
let s = R(t, "addInputRules", n);
|
|
2360
|
+
if (fn(t, e.options.enableInputRules) && s) {
|
|
2310
2361
|
let t = s();
|
|
2311
2362
|
if (t && t.length) {
|
|
2312
|
-
let n =
|
|
2363
|
+
let n = Fr({
|
|
2313
2364
|
editor: e,
|
|
2314
2365
|
rules: t
|
|
2315
2366
|
}), i = Array.isArray(n) ? n : [n];
|
|
2316
2367
|
r.push(...i);
|
|
2317
2368
|
}
|
|
2318
2369
|
}
|
|
2319
|
-
let c =
|
|
2320
|
-
if (
|
|
2370
|
+
let c = R(t, "addPasteRules", n);
|
|
2371
|
+
if (fn(t, e.options.enablePasteRules) && c) {
|
|
2321
2372
|
let t = c();
|
|
2322
2373
|
if (t && t.length) {
|
|
2323
|
-
let n =
|
|
2374
|
+
let n = Hr({
|
|
2324
2375
|
editor: e,
|
|
2325
2376
|
rules: t
|
|
2326
2377
|
});
|
|
2327
2378
|
r.push(...n);
|
|
2328
2379
|
}
|
|
2329
2380
|
}
|
|
2330
|
-
let l =
|
|
2381
|
+
let l = R(t, "addProseMirrorPlugins", n);
|
|
2331
2382
|
if (l) {
|
|
2332
2383
|
let e = l();
|
|
2333
2384
|
r.push(...e);
|
|
@@ -2342,7 +2393,7 @@ var Q = class {
|
|
|
2342
2393
|
(e = this.decorationManager) == null || e.destroy();
|
|
2343
2394
|
let n = [];
|
|
2344
2395
|
return this.extensions.forEach((e) => {
|
|
2345
|
-
let r =
|
|
2396
|
+
let r = R(e, "addDecorations", {
|
|
2346
2397
|
name: e.name,
|
|
2347
2398
|
options: e.options,
|
|
2348
2399
|
storage: this.editor.extensionStorage[e.name],
|
|
@@ -2353,28 +2404,28 @@ var Q = class {
|
|
|
2353
2404
|
name: e.name,
|
|
2354
2405
|
addDecorations: r
|
|
2355
2406
|
});
|
|
2356
|
-
}), this.decorationManager = new
|
|
2407
|
+
}), this.decorationManager = new gr({
|
|
2357
2408
|
editor: t,
|
|
2358
2409
|
entries: n
|
|
2359
2410
|
}), this.decorationManager.plugin;
|
|
2360
2411
|
}
|
|
2361
2412
|
get attributes() {
|
|
2362
|
-
return
|
|
2413
|
+
return Rt(this.extensions);
|
|
2363
2414
|
}
|
|
2364
2415
|
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 =
|
|
2416
|
+
let { editor: e } = this, { nodeExtensions: t } = B(this.extensions);
|
|
2417
|
+
return Object.fromEntries(t.filter((e) => !!R(e, "addNodeView")).map((t) => {
|
|
2418
|
+
let n = this.attributes.filter((e) => e.type === t.name), r = R(t, "addNodeView", {
|
|
2368
2419
|
name: t.name,
|
|
2369
2420
|
options: t.options,
|
|
2370
2421
|
storage: this.editor.extensionStorage[t.name],
|
|
2371
2422
|
editor: e,
|
|
2372
|
-
type:
|
|
2423
|
+
type: O(t.name, this.schema)
|
|
2373
2424
|
});
|
|
2374
2425
|
if (!r) return [];
|
|
2375
2426
|
let i = r();
|
|
2376
2427
|
return i ? [t.name, (r, a, o, s, c) => {
|
|
2377
|
-
let l =
|
|
2428
|
+
let l = V(r, n);
|
|
2378
2429
|
return i({
|
|
2379
2430
|
node: r,
|
|
2380
2431
|
view: a,
|
|
@@ -2390,14 +2441,14 @@ var Q = class {
|
|
|
2390
2441
|
}
|
|
2391
2442
|
dispatchTransaction(e) {
|
|
2392
2443
|
let { editor: t } = this;
|
|
2393
|
-
return
|
|
2444
|
+
return H([...this.extensions].reverse()).reduceRight((e, n) => {
|
|
2394
2445
|
let r = {
|
|
2395
2446
|
name: n.name,
|
|
2396
2447
|
options: n.options,
|
|
2397
2448
|
storage: this.editor.extensionStorage[n.name],
|
|
2398
2449
|
editor: t,
|
|
2399
2450
|
type: U(n.name, this.schema)
|
|
2400
|
-
}, i =
|
|
2451
|
+
}, i = R(n, "dispatchTransaction", r);
|
|
2401
2452
|
return i ? (t) => {
|
|
2402
2453
|
i.call(r, {
|
|
2403
2454
|
transaction: t,
|
|
@@ -2408,14 +2459,14 @@ var Q = class {
|
|
|
2408
2459
|
}
|
|
2409
2460
|
transformPastedHTML(e) {
|
|
2410
2461
|
let { editor: t } = this;
|
|
2411
|
-
return
|
|
2462
|
+
return H([...this.extensions]).reduce((e, n) => {
|
|
2412
2463
|
let r = {
|
|
2413
2464
|
name: n.name,
|
|
2414
2465
|
options: n.options,
|
|
2415
2466
|
storage: this.editor.extensionStorage[n.name],
|
|
2416
2467
|
editor: t,
|
|
2417
2468
|
type: U(n.name, this.schema)
|
|
2418
|
-
}, i =
|
|
2469
|
+
}, i = R(n, "transformPastedHTML", r);
|
|
2419
2470
|
return i ? (t, n) => {
|
|
2420
2471
|
let a = e(t, n);
|
|
2421
2472
|
return i.call(r, a);
|
|
@@ -2423,17 +2474,17 @@ var Q = class {
|
|
|
2423
2474
|
}, e || ((e) => e));
|
|
2424
2475
|
}
|
|
2425
2476
|
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 =
|
|
2477
|
+
let { editor: e } = this, { markExtensions: t } = B(this.extensions);
|
|
2478
|
+
return Object.fromEntries(t.filter((e) => !!R(e, "addMarkView")).map((t) => {
|
|
2479
|
+
let n = this.attributes.filter((e) => e.type === t.name), r = R(t, "addMarkView", {
|
|
2429
2480
|
name: t.name,
|
|
2430
2481
|
options: t.options,
|
|
2431
2482
|
storage: this.editor.extensionStorage[t.name],
|
|
2432
2483
|
editor: e,
|
|
2433
|
-
type:
|
|
2484
|
+
type: A(t.name, this.schema)
|
|
2434
2485
|
});
|
|
2435
2486
|
return r ? [t.name, (i, a, o) => {
|
|
2436
|
-
let s =
|
|
2487
|
+
let s = V(i, n);
|
|
2437
2488
|
return r()({
|
|
2438
2489
|
mark: i,
|
|
2439
2490
|
view: a,
|
|
@@ -2442,7 +2493,7 @@ var Q = class {
|
|
|
2442
2493
|
extension: t,
|
|
2443
2494
|
HTMLAttributes: s,
|
|
2444
2495
|
updateAttributes: (t) => {
|
|
2445
|
-
|
|
2496
|
+
Ar(i, e, t);
|
|
2446
2497
|
}
|
|
2447
2498
|
});
|
|
2448
2499
|
}] : [];
|
|
@@ -2468,14 +2519,14 @@ var Q = class {
|
|
|
2468
2519
|
editor: this.editor,
|
|
2469
2520
|
type: U(e.name, this.schema)
|
|
2470
2521
|
};
|
|
2471
|
-
e.type === "mark" && ((R(
|
|
2472
|
-
let n =
|
|
2522
|
+
e.type === "mark" && ((z(R(e, "keepOnSplit", t)) ?? !0) && this.splittableMarks.push(e.name), (z(R(e, "clearable", t)) ?? !0) || this.nonClearableMarks.push(e.name));
|
|
2523
|
+
let n = R(e, "onBeforeCreate", t), r = R(e, "onCreate", t), i = R(e, "onUpdate", t), a = R(e, "onSelectionUpdate", t), o = R(e, "onTransaction", t), s = R(e, "onFocus", t), c = R(e, "onBlur", t), l = R(e, "onDestroy", t);
|
|
2473
2524
|
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
2525
|
});
|
|
2475
2526
|
}
|
|
2476
2527
|
};
|
|
2477
|
-
Q.resolve =
|
|
2478
|
-
var $ = class e extends
|
|
2528
|
+
Q.resolve = Jt, Q.sort = H, Q.flatten = Pt;
|
|
2529
|
+
var $ = class e extends Ir {
|
|
2479
2530
|
constructor(...e) {
|
|
2480
2531
|
super(...e), this.type = "extension";
|
|
2481
2532
|
}
|
|
@@ -2490,7 +2541,7 @@ var $ = class e extends Ar {
|
|
|
2490
2541
|
let t = typeof e == "function" ? e() : e;
|
|
2491
2542
|
return super.extend(t);
|
|
2492
2543
|
}
|
|
2493
|
-
},
|
|
2544
|
+
}, Ur = $.create({
|
|
2494
2545
|
name: "clipboardTextSerializer",
|
|
2495
2546
|
addOptions() {
|
|
2496
2547
|
return { blockSeparator: void 0 };
|
|
@@ -2499,31 +2550,31 @@ var $ = class e extends Ar {
|
|
|
2499
2550
|
return [new r({
|
|
2500
2551
|
key: new i("clipboardTextSerializer"),
|
|
2501
2552
|
props: { clipboardTextSerializer: () => {
|
|
2502
|
-
let { editor: e } = this, { state: t, schema: n } = e, { doc: r, selection: i } = t, a =
|
|
2553
|
+
let { editor: e } = this, { state: t, schema: n } = e, { doc: r, selection: i } = t, a = Zt(n), { blockSeparator: o } = this.options, s = {
|
|
2503
2554
|
...o === void 0 ? {} : { blockSeparator: o },
|
|
2504
2555
|
textSerializers: a
|
|
2505
2556
|
};
|
|
2506
|
-
return [...i.ranges].sort((e, t) => e.$from.pos - t.$from.pos).map(({ $from: e, $to: t }) =>
|
|
2557
|
+
return [...i.ranges].sort((e, t) => e.$from.pos - t.$from.pos).map(({ $from: e, $to: t }) => Yt(r, {
|
|
2507
2558
|
from: e.pos,
|
|
2508
2559
|
to: t.pos
|
|
2509
2560
|
}, s)).join(o ?? "\n\n");
|
|
2510
2561
|
} }
|
|
2511
2562
|
})];
|
|
2512
2563
|
}
|
|
2513
|
-
}),
|
|
2564
|
+
}), Wr = $.create({
|
|
2514
2565
|
name: "commands",
|
|
2515
2566
|
addCommands() {
|
|
2516
|
-
return { ...
|
|
2567
|
+
return { ...qn };
|
|
2517
2568
|
}
|
|
2518
|
-
}),
|
|
2569
|
+
}), Gr = $.create({
|
|
2519
2570
|
name: "delete",
|
|
2520
2571
|
onUpdate({ transaction: e, appendedTransactions: t }) {
|
|
2521
2572
|
var n;
|
|
2522
2573
|
let r = () => {
|
|
2523
2574
|
var n, r;
|
|
2524
2575
|
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 =
|
|
2526
|
-
|
|
2576
|
+
let i = jt(e.before, [e, ...t]);
|
|
2577
|
+
nn(i).forEach((t) => {
|
|
2527
2578
|
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
2579
|
let a = r + n.nodeSize - 2, o = t.oldRange.from <= r && a <= t.oldRange.to;
|
|
2529
2580
|
this.editor.emit("delete", {
|
|
@@ -2569,7 +2620,7 @@ var $ = class e extends Ar {
|
|
|
2569
2620
|
};
|
|
2570
2621
|
((n = this.editor.options.coreExtensionOptions) == null || (n = n.delete) == null ? void 0 : n.async) ?? !0 ? setTimeout(r, 0) : r();
|
|
2571
2622
|
}
|
|
2572
|
-
}),
|
|
2623
|
+
}), Kr = $.create({
|
|
2573
2624
|
name: "drop",
|
|
2574
2625
|
addProseMirrorPlugins() {
|
|
2575
2626
|
return [new r({
|
|
@@ -2584,7 +2635,7 @@ var $ = class e extends Ar {
|
|
|
2584
2635
|
} }
|
|
2585
2636
|
})];
|
|
2586
2637
|
}
|
|
2587
|
-
}),
|
|
2638
|
+
}), qr = $.create({
|
|
2588
2639
|
name: "editable",
|
|
2589
2640
|
addProseMirrorPlugins() {
|
|
2590
2641
|
return [new r({
|
|
@@ -2592,12 +2643,12 @@ var $ = class e extends Ar {
|
|
|
2592
2643
|
props: { editable: () => this.editor.options.editable }
|
|
2593
2644
|
})];
|
|
2594
2645
|
}
|
|
2595
|
-
}),
|
|
2646
|
+
}), Jr = new i("focusEvents"), Yr = $.create({
|
|
2596
2647
|
name: "focusEvents",
|
|
2597
2648
|
addProseMirrorPlugins() {
|
|
2598
2649
|
let { editor: e } = this;
|
|
2599
2650
|
return [new r({
|
|
2600
|
-
key:
|
|
2651
|
+
key: Jr,
|
|
2601
2652
|
props: { handleDOMEvents: {
|
|
2602
2653
|
focus: (t, n) => {
|
|
2603
2654
|
e.isFocused = !0;
|
|
@@ -2612,7 +2663,7 @@ var $ = class e extends Ar {
|
|
|
2612
2663
|
} }
|
|
2613
2664
|
})];
|
|
2614
2665
|
}
|
|
2615
|
-
}),
|
|
2666
|
+
}), Xr = $.create({
|
|
2616
2667
|
name: "keymap",
|
|
2617
2668
|
addKeyboardShortcuts() {
|
|
2618
2669
|
let e = () => this.editor.commands.first(({ commands: e }) => [
|
|
@@ -2654,7 +2705,7 @@ var $ = class e extends Ar {
|
|
|
2654
2705
|
"Ctrl-a": () => this.editor.commands.selectTextblockStart(),
|
|
2655
2706
|
"Ctrl-e": () => this.editor.commands.selectTextblockEnd()
|
|
2656
2707
|
};
|
|
2657
|
-
return
|
|
2708
|
+
return M() || ft() ? i : r;
|
|
2658
2709
|
},
|
|
2659
2710
|
addProseMirrorPlugins() {
|
|
2660
2711
|
return [new r({
|
|
@@ -2665,10 +2716,10 @@ var $ = class e extends Ar {
|
|
|
2665
2716
|
if (!r || i) return;
|
|
2666
2717
|
let { empty: o, from: s, to: c } = t.selection, l = a.atStart(t.doc).from, u = a.atEnd(t.doc).to;
|
|
2667
2718
|
if (o || s !== l || c !== u || !G(n.doc)) return;
|
|
2668
|
-
let d = n.tr, f =
|
|
2719
|
+
let d = n.tr, f = E({
|
|
2669
2720
|
state: n,
|
|
2670
2721
|
transaction: d
|
|
2671
|
-
}), { commands: p } = new
|
|
2722
|
+
}), { commands: p } = new D({
|
|
2672
2723
|
editor: this.editor,
|
|
2673
2724
|
state: f
|
|
2674
2725
|
});
|
|
@@ -2676,7 +2727,7 @@ var $ = class e extends Ar {
|
|
|
2676
2727
|
}
|
|
2677
2728
|
})];
|
|
2678
2729
|
}
|
|
2679
|
-
}),
|
|
2730
|
+
}), Zr = $.create({
|
|
2680
2731
|
name: "paste",
|
|
2681
2732
|
addProseMirrorPlugins() {
|
|
2682
2733
|
return [new r({
|
|
@@ -2690,7 +2741,7 @@ var $ = class e extends Ar {
|
|
|
2690
2741
|
} }
|
|
2691
2742
|
})];
|
|
2692
2743
|
}
|
|
2693
|
-
}),
|
|
2744
|
+
}), Qr = $.create({
|
|
2694
2745
|
name: "tabindex",
|
|
2695
2746
|
addOptions() {
|
|
2696
2747
|
return { value: void 0 };
|
|
@@ -2701,14 +2752,14 @@ var $ = class e extends Ar {
|
|
|
2701
2752
|
props: { attributes: () => !this.editor.isEditable && this.options.value === void 0 ? {} : { tabindex: this.options.value ?? "0" } }
|
|
2702
2753
|
})];
|
|
2703
2754
|
}
|
|
2704
|
-
}),
|
|
2755
|
+
}), $r = $.create({
|
|
2705
2756
|
name: "textDirection",
|
|
2706
2757
|
addOptions() {
|
|
2707
2758
|
return { direction: void 0 };
|
|
2708
2759
|
},
|
|
2709
2760
|
addGlobalAttributes() {
|
|
2710
2761
|
if (!this.options.direction) return [];
|
|
2711
|
-
let { nodeExtensions: e } =
|
|
2762
|
+
let { nodeExtensions: e } = B(this.extensions);
|
|
2712
2763
|
return [{
|
|
2713
2764
|
types: e.filter((e) => e.name !== "text").map((e) => e.name),
|
|
2714
2765
|
attributes: { dir: {
|
|
@@ -2730,10 +2781,10 @@ var $ = class e extends Ar {
|
|
|
2730
2781
|
} }
|
|
2731
2782
|
})];
|
|
2732
2783
|
}
|
|
2733
|
-
}),
|
|
2734
|
-
function
|
|
2735
|
-
if (
|
|
2736
|
-
|
|
2784
|
+
}), ei = !1;
|
|
2785
|
+
function ti(e) {
|
|
2786
|
+
if (ei) return;
|
|
2787
|
+
ei = !0;
|
|
2737
2788
|
let t;
|
|
2738
2789
|
try {
|
|
2739
2790
|
t = l.fromJSON(e, {
|
|
@@ -2743,9 +2794,9 @@ function Yr(e) {
|
|
|
2743
2794
|
} catch {
|
|
2744
2795
|
return;
|
|
2745
2796
|
}
|
|
2746
|
-
t instanceof
|
|
2797
|
+
t instanceof w || 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
2798
|
}
|
|
2748
|
-
var
|
|
2799
|
+
var ni = class e {
|
|
2749
2800
|
get name() {
|
|
2750
2801
|
return this.node.type.name;
|
|
2751
2802
|
}
|
|
@@ -2867,7 +2918,7 @@ var Xr = class e {
|
|
|
2867
2918
|
...e
|
|
2868
2919
|
}), this.editor.view.dispatch(t);
|
|
2869
2920
|
}
|
|
2870
|
-
},
|
|
2921
|
+
}, ri = ".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}", ii = class extends Xn {
|
|
2871
2922
|
constructor(e = {}) {
|
|
2872
2923
|
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
2924
|
element: typeof document < "u" ? document.createElement("div") : null,
|
|
@@ -2904,8 +2955,8 @@ var Xr = class e {
|
|
|
2904
2955
|
onDelete: () => null,
|
|
2905
2956
|
enableExtensionDispatchTransaction: !0
|
|
2906
2957
|
}, this.isCapturingTransaction = !1, this.capturedTransaction = null, this.utils = {
|
|
2907
|
-
getUpdatedPosition:
|
|
2908
|
-
createMappablePosition:
|
|
2958
|
+
getUpdatedPosition: gn,
|
|
2959
|
+
createMappablePosition: _n
|
|
2909
2960
|
}, 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
2961
|
let n = this.createDoc();
|
|
2911
2962
|
if (!this.editorState) {
|
|
@@ -2916,7 +2967,7 @@ var Xr = class e {
|
|
|
2916
2967
|
selection: e || void 0
|
|
2917
2968
|
});
|
|
2918
2969
|
}
|
|
2919
|
-
|
|
2970
|
+
ti(this.schema), this.options.element && this.mount(this.options.element);
|
|
2920
2971
|
}
|
|
2921
2972
|
mount(e) {
|
|
2922
2973
|
if (typeof document > "u") throw Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");
|
|
@@ -2944,19 +2995,22 @@ var Xr = class e {
|
|
|
2944
2995
|
return this.commandManager.commands;
|
|
2945
2996
|
}
|
|
2946
2997
|
chain() {
|
|
2947
|
-
return this.commandManager ? this.commandManager.chain() :
|
|
2998
|
+
return this.commandManager ? this.commandManager.chain() : D.createFakeChain();
|
|
2948
2999
|
}
|
|
2949
3000
|
can() {
|
|
2950
|
-
return this.commandManager ? this.commandManager.can() :
|
|
3001
|
+
return this.commandManager ? this.commandManager.can() : D.createFallbackCan();
|
|
2951
3002
|
}
|
|
2952
3003
|
injectCSS() {
|
|
2953
|
-
this.options.injectCSS && typeof document < "u" && (this.css =
|
|
3004
|
+
this.options.injectCSS && typeof document < "u" && (this.css = vr(ri, this.options.injectNonce));
|
|
2954
3005
|
}
|
|
2955
3006
|
setOptions(e = {}) {
|
|
2956
3007
|
this.options = {
|
|
2957
3008
|
...this.options,
|
|
2958
3009
|
...e
|
|
2959
|
-
}, this.editorView && this.state && !this.isDestroyed && (this.options.editorProps && this.view.setProps(
|
|
3010
|
+
}, this.editorView && this.state && !this.isDestroyed && (this.options.editorProps && this.view.setProps({
|
|
3011
|
+
...this.options.editorProps,
|
|
3012
|
+
attributes: this.getEditorViewAttributes()
|
|
3013
|
+
}), this.view.updateState(this.state));
|
|
2960
3014
|
}
|
|
2961
3015
|
setEditable(e, t = !0) {
|
|
2962
3016
|
this.setOptions({ editable: e }), t && this.emit("update", {
|
|
@@ -2989,10 +3043,10 @@ var Xr = class e {
|
|
|
2989
3043
|
} });
|
|
2990
3044
|
}
|
|
2991
3045
|
get state() {
|
|
2992
|
-
return
|
|
3046
|
+
return Zn && !this.hasWarnedStaleDecorationRead && Yn(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
3047
|
}
|
|
2994
3048
|
registerPlugin(e, t) {
|
|
2995
|
-
let n =
|
|
3049
|
+
let n = It(t) ? t(e, [...this.state.plugins]) : [...this.state.plugins, e], r = this.state.reconfigure({ plugins: n });
|
|
2996
3050
|
return this.view.updateState(r), r;
|
|
2997
3051
|
}
|
|
2998
3052
|
unregisterPlugin(e) {
|
|
@@ -3008,16 +3062,16 @@ var Xr = class e {
|
|
|
3008
3062
|
createExtensionManager() {
|
|
3009
3063
|
var e, t;
|
|
3010
3064
|
let n = [...this.options.enableCoreExtensions ? [
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
Rr,
|
|
3014
|
-
Ur,
|
|
3065
|
+
qr,
|
|
3066
|
+
Ur.configure({ blockSeparator: (e = this.options.coreExtensionOptions) == null || (e = e.clipboardTextSerializer) == null ? void 0 : e.blockSeparator }),
|
|
3015
3067
|
Wr,
|
|
3016
|
-
|
|
3017
|
-
|
|
3068
|
+
Yr,
|
|
3069
|
+
Xr,
|
|
3070
|
+
Qr.configure({ value: (t = this.options.coreExtensionOptions) == null || (t = t.tabindex) == null ? void 0 : t.value }),
|
|
3071
|
+
Kr,
|
|
3072
|
+
Zr,
|
|
3018
3073
|
Gr,
|
|
3019
|
-
|
|
3020
|
-
qr.configure({ direction: this.options.textDirection })
|
|
3074
|
+
$r.configure({ direction: this.options.textDirection })
|
|
3021
3075
|
].filter((e) => typeof this.options.enableCoreExtensions != "object" || this.options.enableCoreExtensions[e.name] !== !1) : [], ...this.options.extensions].filter((e) => [
|
|
3022
3076
|
"extension",
|
|
3023
3077
|
"node",
|
|
@@ -3026,7 +3080,7 @@ var Xr = class e {
|
|
|
3026
3080
|
this.extensionManager = new Q(n, this);
|
|
3027
3081
|
}
|
|
3028
3082
|
createCommandManager() {
|
|
3029
|
-
this.commandManager = new
|
|
3083
|
+
this.commandManager = new D({ editor: this });
|
|
3030
3084
|
}
|
|
3031
3085
|
createSchema() {
|
|
3032
3086
|
this.schema = this.extensionManager.schema;
|
|
@@ -3034,10 +3088,10 @@ var Xr = class e {
|
|
|
3034
3088
|
createDoc() {
|
|
3035
3089
|
let e;
|
|
3036
3090
|
try {
|
|
3037
|
-
e =
|
|
3091
|
+
e = Ot(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: this.options.enableContentCheck });
|
|
3038
3092
|
} catch (e) {
|
|
3039
3093
|
if (!(e instanceof Error) || !["[tiptap error]: Invalid JSON content", "[tiptap error]: Invalid HTML content"].includes(e.message)) throw e;
|
|
3040
|
-
let n =
|
|
3094
|
+
let n = Ot(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: !1 });
|
|
3041
3095
|
return this.editorState = t.create({
|
|
3042
3096
|
doc: n,
|
|
3043
3097
|
schema: this.schema,
|
|
@@ -3052,14 +3106,21 @@ var Xr = class e {
|
|
|
3052
3106
|
}
|
|
3053
3107
|
return e;
|
|
3054
3108
|
}
|
|
3109
|
+
getEditorViewAttributes() {
|
|
3110
|
+
let e = this.options.editorProps?.attributes;
|
|
3111
|
+
return It(e) ? (t) => ({
|
|
3112
|
+
role: "textbox",
|
|
3113
|
+
...e(t)
|
|
3114
|
+
}) : {
|
|
3115
|
+
role: "textbox",
|
|
3116
|
+
...e
|
|
3117
|
+
};
|
|
3118
|
+
}
|
|
3055
3119
|
createView(e) {
|
|
3056
3120
|
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
|
|
3121
|
+
this.editorView = new _e(e, {
|
|
3058
3122
|
...t,
|
|
3059
|
-
attributes:
|
|
3060
|
-
role: "textbox",
|
|
3061
|
-
...t?.attributes
|
|
3062
|
-
},
|
|
3123
|
+
attributes: this.getEditorViewAttributes(),
|
|
3063
3124
|
dispatchTransaction: i,
|
|
3064
3125
|
transformPastedHTML: o,
|
|
3065
3126
|
state: this.editorState,
|
|
@@ -3125,24 +3186,24 @@ var Xr = class e {
|
|
|
3125
3186
|
});
|
|
3126
3187
|
}
|
|
3127
3188
|
getAttributes(e) {
|
|
3128
|
-
return
|
|
3189
|
+
return $t(this.state, e);
|
|
3129
3190
|
}
|
|
3130
3191
|
isActive(e, t) {
|
|
3131
3192
|
let n = typeof e == "string" ? e : null, r = typeof e == "string" ? t : e;
|
|
3132
|
-
return
|
|
3193
|
+
return ln(this.state, n, r);
|
|
3133
3194
|
}
|
|
3134
3195
|
getJSON() {
|
|
3135
3196
|
return this.state.doc.toJSON();
|
|
3136
3197
|
}
|
|
3137
3198
|
getHTML() {
|
|
3138
|
-
return
|
|
3199
|
+
return Ft(this.state.doc.content, this.schema);
|
|
3139
3200
|
}
|
|
3140
3201
|
getText(e) {
|
|
3141
3202
|
let { blockSeparator: t = "\n\n", textSerializers: n = {} } = e || {};
|
|
3142
|
-
return
|
|
3203
|
+
return Xt(this.state.doc, {
|
|
3143
3204
|
blockSeparator: t,
|
|
3144
3205
|
textSerializers: {
|
|
3145
|
-
...
|
|
3206
|
+
...Zt(this.schema),
|
|
3146
3207
|
...n
|
|
3147
3208
|
}
|
|
3148
3209
|
});
|
|
@@ -3164,22 +3225,22 @@ var Xr = class e {
|
|
|
3164
3225
|
}
|
|
3165
3226
|
$pos(e) {
|
|
3166
3227
|
let t = this.state.doc.resolve(e), n = e > 0 && t.nodeAfter && !t.nodeAfter.isText && t.nodeAfter.isAtom ? t.nodeAfter : null;
|
|
3167
|
-
return new
|
|
3228
|
+
return new ni(t, this, !1, n);
|
|
3168
3229
|
}
|
|
3169
3230
|
get $doc() {
|
|
3170
3231
|
return this.$pos(0);
|
|
3171
3232
|
}
|
|
3172
3233
|
};
|
|
3173
|
-
function
|
|
3234
|
+
function ai(e) {
|
|
3174
3235
|
return new Y({
|
|
3175
3236
|
find: e.find,
|
|
3176
3237
|
handler: ({ state: t, range: n, match: r }) => {
|
|
3177
|
-
let i =
|
|
3238
|
+
let i = z(e.getAttributes, void 0, r);
|
|
3178
3239
|
if (i === !1 || i === null) return null;
|
|
3179
3240
|
let { tr: a } = t, o = r[r.length - 1], s = r[0];
|
|
3180
3241
|
if (o) {
|
|
3181
3242
|
let r = s.search(/\S/), c = n.from + s.indexOf(o), l = c + o.length;
|
|
3182
|
-
if (
|
|
3243
|
+
if (rn(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
3244
|
l < n.to && a.delete(l, n.to), c > n.from && a.delete(n.from + r, c);
|
|
3184
3245
|
let u = n.from + r + o.length;
|
|
3185
3246
|
a.addMark(n.from + r, u, e.type.create(i || {})), a.removeStoredMark(e.type);
|
|
@@ -3188,11 +3249,11 @@ function $r(e) {
|
|
|
3188
3249
|
undoable: e.undoable
|
|
3189
3250
|
});
|
|
3190
3251
|
}
|
|
3191
|
-
function
|
|
3252
|
+
function oi(e) {
|
|
3192
3253
|
return new Y({
|
|
3193
3254
|
find: e.find,
|
|
3194
3255
|
handler: ({ state: t, range: n, match: r }) => {
|
|
3195
|
-
let i =
|
|
3256
|
+
let i = z(e.getAttributes, void 0, r) || {}, { tr: a } = t, o = n.from, s = n.to, c = e.type.create(i);
|
|
3196
3257
|
if (r[1]) {
|
|
3197
3258
|
let e = o + r[0].lastIndexOf(r[1]);
|
|
3198
3259
|
e > s ? e = s : s = e + r[1].length;
|
|
@@ -3207,18 +3268,18 @@ function ei(e) {
|
|
|
3207
3268
|
undoable: e.undoable
|
|
3208
3269
|
});
|
|
3209
3270
|
}
|
|
3210
|
-
function
|
|
3271
|
+
function si(e) {
|
|
3211
3272
|
return new Y({
|
|
3212
3273
|
find: e.find,
|
|
3213
3274
|
handler: ({ state: t, range: n, match: r }) => {
|
|
3214
|
-
let i = t.doc.resolve(n.from), a =
|
|
3275
|
+
let i = t.doc.resolve(n.from), a = z(e.getAttributes, void 0, r) || {};
|
|
3215
3276
|
if (!i.node(-1).canReplaceWith(i.index(-1), i.indexAfter(-1), e.type)) return null;
|
|
3216
3277
|
t.tr.delete(n.from, n.to).setBlockType(n.from, n.from, e.type, a);
|
|
3217
3278
|
},
|
|
3218
3279
|
undoable: e.undoable
|
|
3219
3280
|
});
|
|
3220
3281
|
}
|
|
3221
|
-
function
|
|
3282
|
+
function ci(e) {
|
|
3222
3283
|
return new Y({
|
|
3223
3284
|
find: e.find,
|
|
3224
3285
|
handler: ({ state: t, range: n, match: r }) => {
|
|
@@ -3234,11 +3295,11 @@ function ni(e) {
|
|
|
3234
3295
|
undoable: e.undoable
|
|
3235
3296
|
});
|
|
3236
3297
|
}
|
|
3237
|
-
function
|
|
3298
|
+
function li(e) {
|
|
3238
3299
|
return new Y({
|
|
3239
3300
|
find: e.find,
|
|
3240
3301
|
handler: ({ state: t, range: n, match: r, chain: i }) => {
|
|
3241
|
-
let a =
|
|
3302
|
+
let a = z(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
3303
|
if (!c) return null;
|
|
3243
3304
|
if (o.wrap(s, c), e.keepMarks && e.editor) {
|
|
3244
3305
|
let { selection: n, storedMarks: r } = t, { splittableMarks: i } = e.editor.extensionManager, a = r || n.$to.parentOffset && n.$from.marks();
|
|
@@ -3257,7 +3318,7 @@ function ri(e) {
|
|
|
3257
3318
|
undoable: e.undoable
|
|
3258
3319
|
});
|
|
3259
3320
|
}
|
|
3260
|
-
var
|
|
3321
|
+
var ui = (e) => "touches" in e, di = class {
|
|
3261
3322
|
constructor(e) {
|
|
3262
3323
|
var t;
|
|
3263
3324
|
this.directions = [
|
|
@@ -3347,7 +3408,7 @@ var ii = (e) => "touches" in e, ai = class {
|
|
|
3347
3408
|
e ? (this.element.style.width = `${e}px`, this.initialWidth = e) : this.initialWidth = this.element.offsetWidth, t ? (this.element.style.height = `${t}px`, this.initialHeight = t) : this.initialHeight = this.element.offsetHeight, this.initialWidth > 0 && this.initialHeight > 0 && (this.aspectRatio = this.initialWidth / this.initialHeight);
|
|
3348
3409
|
}
|
|
3349
3410
|
handleResizeStart(e, t) {
|
|
3350
|
-
e.preventDefault(), e.stopPropagation(), this.isResizing = !0, this.activeHandle = t,
|
|
3411
|
+
e.preventDefault(), e.stopPropagation(), this.isResizing = !0, this.activeHandle = t, ui(e) ? (this.startX = e.touches[0].clientX, this.startY = e.touches[0].clientY) : (this.startX = e.clientX, this.startY = e.clientY), this.startWidth = this.element.offsetWidth, this.startHeight = this.element.offsetHeight, this.startWidth > 0 && this.startHeight > 0 && (this.aspectRatio = this.startWidth / this.startHeight), this.getPos(), this.container.dataset.resizeState = "true", this.classNames.resizing && this.container.classList.add(this.classNames.resizing), document.addEventListener("mousemove", this.handleMouseMove), document.addEventListener("touchmove", this.handleTouchMove), document.addEventListener("mouseup", this.handleMouseUp), document.addEventListener("keydown", this.handleKeyDown), document.addEventListener("keyup", this.handleKeyUp);
|
|
3351
3412
|
}
|
|
3352
3413
|
handleResize(e, t) {
|
|
3353
3414
|
if (!this.activeHandle) return;
|
|
@@ -3387,7 +3448,7 @@ var ii = (e) => "touches" in e, ai = class {
|
|
|
3387
3448
|
height: e / this.aspectRatio
|
|
3388
3449
|
};
|
|
3389
3450
|
}
|
|
3390
|
-
},
|
|
3451
|
+
}, fi = class e extends Ir {
|
|
3391
3452
|
constructor(...e) {
|
|
3392
3453
|
super(...e), this.type = "node";
|
|
3393
3454
|
}
|
|
@@ -3402,118 +3463,21 @@ var ii = (e) => "touches" in e, ai = class {
|
|
|
3402
3463
|
let t = typeof e == "function" ? e() : e;
|
|
3403
3464
|
return super.extend(t);
|
|
3404
3465
|
}
|
|
3405
|
-
}, si = class {
|
|
3406
|
-
constructor(e, t, n) {
|
|
3407
|
-
this.isDragging = !1, this.component = e, this.editor = t.editor, this.options = {
|
|
3408
|
-
stopEvent: null,
|
|
3409
|
-
ignoreMutation: null,
|
|
3410
|
-
...n
|
|
3411
|
-
}, this.extension = t.extension, this.node = t.node, this.decorations = t.decorations, this.innerDecorations = t.innerDecorations, this.view = t.view, this.HTMLAttributes = t.HTMLAttributes, this.getPos = () => {
|
|
3412
|
-
try {
|
|
3413
|
-
return t.getPos();
|
|
3414
|
-
} catch {
|
|
3415
|
-
return;
|
|
3416
|
-
}
|
|
3417
|
-
}, this.mount();
|
|
3418
|
-
}
|
|
3419
|
-
mount() {}
|
|
3420
|
-
get dom() {
|
|
3421
|
-
return this.editor.view.dom;
|
|
3422
|
-
}
|
|
3423
|
-
get contentDOM() {
|
|
3424
|
-
return null;
|
|
3425
|
-
}
|
|
3426
|
-
onDragStart(e) {
|
|
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
|
-
}
|
|
3434
|
-
let s = this.dom.cloneNode(!0);
|
|
3435
|
-
try {
|
|
3436
|
-
let e = this.dom.getBoundingClientRect();
|
|
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
|
-
} catch {}
|
|
3439
|
-
let c = null;
|
|
3440
|
-
try {
|
|
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
|
-
} finally {
|
|
3444
|
-
c && setTimeout(() => {
|
|
3445
|
-
try {
|
|
3446
|
-
c?.remove();
|
|
3447
|
-
} catch {}
|
|
3448
|
-
}, 0);
|
|
3449
|
-
}
|
|
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
|
-
}
|
|
3455
|
-
stopEvent(e) {
|
|
3456
|
-
if (!this.dom) return !1;
|
|
3457
|
-
if (typeof this.options.stopEvent == "function") return this.options.stopEvent({ event: e });
|
|
3458
|
-
let t = e.target;
|
|
3459
|
-
if (!this.dom.contains(t) || this.contentDOM?.contains(t)) return !1;
|
|
3460
|
-
let r = e.type.startsWith("drag"), i = e.type === "dragover" || e.type === "dragenter", a = e.type === "drop";
|
|
3461
|
-
if (([
|
|
3462
|
-
"INPUT",
|
|
3463
|
-
"BUTTON",
|
|
3464
|
-
"SELECT",
|
|
3465
|
-
"TEXTAREA"
|
|
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
|
-
let e = t.closest("[data-drag-handle]");
|
|
3471
|
-
e && (this.dom === e || this.dom.contains(e)) && (this.isDragging = !0, document.addEventListener("dragend", () => {
|
|
3472
|
-
this.isDragging = !1;
|
|
3473
|
-
}, { once: !0 }), document.addEventListener("drop", () => {
|
|
3474
|
-
this.isDragging = !1;
|
|
3475
|
-
}, { once: !0 }), document.addEventListener("mouseup", () => {
|
|
3476
|
-
this.isDragging = !1;
|
|
3477
|
-
}, { once: !0 }));
|
|
3478
|
-
}
|
|
3479
|
-
return !(s || i || a || u || d || f || p && l);
|
|
3480
|
-
}
|
|
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" && (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
|
-
}
|
|
3484
|
-
updateAttributes(e) {
|
|
3485
|
-
this.editor.commands.command(({ tr: t }) => {
|
|
3486
|
-
let n = this.getPos();
|
|
3487
|
-
return typeof n == "number" && (t.setNodeMarkup(n, void 0, {
|
|
3488
|
-
...this.node.attrs,
|
|
3489
|
-
...e
|
|
3490
|
-
}), !0);
|
|
3491
|
-
});
|
|
3492
|
-
}
|
|
3493
|
-
deleteNode() {
|
|
3494
|
-
let e = this.getPos();
|
|
3495
|
-
if (typeof e != "number") return;
|
|
3496
|
-
let t = e + this.node.nodeSize;
|
|
3497
|
-
this.editor.commands.deleteRange({
|
|
3498
|
-
from: e,
|
|
3499
|
-
to: t
|
|
3500
|
-
});
|
|
3501
|
-
}
|
|
3502
3466
|
};
|
|
3503
|
-
function
|
|
3504
|
-
return new
|
|
3467
|
+
function pi(e) {
|
|
3468
|
+
return new Rr({
|
|
3505
3469
|
find: e.find,
|
|
3506
3470
|
handler: ({ state: t, range: n, match: r, pasteEvent: i }) => {
|
|
3507
|
-
let a =
|
|
3471
|
+
let a = z(e.getAttributes, void 0, r, i);
|
|
3508
3472
|
if (a === !1 || a === null) return null;
|
|
3509
3473
|
let { tr: o } = t, s = r[r.length - 1], c = r[0], l = n.to;
|
|
3510
3474
|
if (s) {
|
|
3511
3475
|
let i = c.search(/\S/), u = n.from + c.indexOf(s), d = u + s.length;
|
|
3512
|
-
if (
|
|
3476
|
+
if (rn(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
3477
|
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
3478
|
}
|
|
3515
3479
|
}
|
|
3516
3480
|
});
|
|
3517
3481
|
}
|
|
3518
3482
|
//#endregion
|
|
3519
|
-
export {
|
|
3483
|
+
export { dn as A, Vt as B, on as C, Zt as D, Xt as E, Ue as F, ci as G, Tr as H, wr as I, si as K, M as L, F as M, G as N, Ge as O, mn as P, ai as R, O as S, br as T, vn as U, oi as V, Or as W, R as _, fi as a, rn as b, z as c, qn as d, yr as f, nn as g, $t as h, Lr as i, xr as j, un as k, _r as l, Nt as m, $ as n, Rr as o, Mt as p, li as q, Y as r, di as s, ii as t, jt as u, k as v, V as w, an as x, A as y, pi as z };
|