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