@lunejs/admin-ui 0.2.0 → 0.2.1
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/dist/lib/api/codegen/graphql.d.ts +1 -0
- package/dist/lib/api/codegen/graphql.js +8 -8
- package/dist/lib/custom-fields/components/details/is-list/custom-field-is-list.js +6 -4
- package/dist/lib/custom-fields/components/details/use-form/form-schema.d.ts +1 -0
- package/dist/lib/custom-fields/components/details/use-form/form-schema.js +4 -3
- package/dist/lib/custom-fields/components/fields/custom-field.js +44 -36
- package/dist/lib/custom-fields/components/fields/rich-text.d.ts +8 -0
- package/dist/lib/custom-fields/components/fields/rich-text.js +17 -0
- package/dist/lib/custom-fields/components/fields/shared/primitive.d.ts +2 -1
- package/dist/lib/custom-fields/components/fields/shared/primitive.js +67 -61
- package/dist/lib/custom-fields/utils/custom-field.utils.js +63 -51
- package/dist/lib/translate/components/form/translate-form-row-data.d.ts +2 -1
- package/dist/lib/translate/components/form/translate-form-row-data.js +51 -19
- package/dist/lib/translate/components/form/translate-rich-text.d.ts +8 -0
- package/dist/lib/translate/components/form/translate-rich-text.js +65 -0
- package/dist/lib/translate/components/product-form/custom-fields/translate-product-custom-fields.js +95 -63
- package/dist/lib/translate/components/product-form/translate-product-form.js +19 -18
- package/dist/node_modules/@tiptap/core/dist/index.js +876 -872
- package/dist/node_modules/@tiptap/extensions/dist/index.js +288 -0
- package/dist/node_modules/@tiptap/react/dist/index.js +35 -34
- package/dist/node_modules/es-toolkit/dist/compat/object/cloneDeep.js +1 -1
- package/dist/node_modules/es-toolkit/dist/object/cloneDeep.js +1 -1
- package/dist/node_modules/lucide-react/dist/esm/icons/layout-list.js +13 -0
- package/dist/node_modules/prosemirror-dropcursor/dist/index.js +86 -0
- package/dist/node_modules/prosemirror-gapcursor/dist/index.js +204 -0
- package/dist/node_modules/prosemirror-history/dist/index.js +248 -0
- package/dist/node_modules/rope-sequence/dist/index.js +100 -0
- package/dist/shared/components/rich-editor/rich-editor.d.ts +3 -1
- package/dist/shared/components/rich-editor/rich-editor.js +40 -36
- package/dist/shared/components/rich-editor/toolbar/bold/rich-editor-toolbar-bold.js +10 -9
- package/dist/shared/components/rich-editor/toolbar/color/rich-editor-toolbar-color.js +1 -0
- package/dist/shared/components/rich-editor/toolbar/heading/rich-editor-toolbar-heading.js +1 -0
- package/dist/shared/components/rich-editor/toolbar/italic/rich-editor-toolbar-italic.js +5 -4
- package/dist/shared/components/rich-editor/toolbar/link/rich-editor-toolbar-link.js +8 -7
- package/dist/shared/components/rich-editor/toolbar/ol-list/rich-editor-toolbar-ul-list.js +1 -0
- package/dist/shared/components/rich-editor/toolbar/table/rich-editor-toolbar-table.js +9 -8
- package/dist/shared/components/rich-editor/toolbar/ul-list/rich-editor-toolbar-ul-list.js +7 -6
- package/dist/shared/components/rich-editor/toolbar/underline/rich-editor-toolbar-underline.js +3 -2
- package/package.json +1 -1
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { Transform as pe, findWrapping as me, canJoin as ft, RemoveMarkStep as he, liftTarget as ge, joinPoint as
|
|
2
|
-
import { createParagraphNear as ke, deleteSelection as ye, exitCode as we, joinUp as Me, joinDown as xe, joinBackward as Se, joinForward as Ee, joinTextblockBackward as Te, joinTextblockForward as Ae, lift as Ce, liftEmptyBlock as Pe, newlineInCode as $e, selectNodeBackward as Ne, selectNodeForward as Ie, selectParentNode as Be, selectTextblockEnd as Re, selectTextblockStart as je, setBlockType as
|
|
3
|
-
import { EditorState as De, Selection as F, TextSelection as P, Plugin as $, PluginKey as O, AllSelection as _e
|
|
1
|
+
import { Transform as pe, findWrapping as me, canJoin as ft, RemoveMarkStep as he, liftTarget as ge, joinPoint as jt, canSplit as Z, ReplaceStep as ve, ReplaceAroundStep as be } from "../../../prosemirror-transform/dist/index.js";
|
|
2
|
+
import { createParagraphNear as ke, deleteSelection as ye, exitCode as we, joinUp as Me, joinDown as xe, joinBackward as Se, joinForward as Ee, joinTextblockBackward as Te, joinTextblockForward as Ae, lift as Ce, liftEmptyBlock as Pe, newlineInCode as $e, selectNodeBackward as Ne, selectNodeForward as Ie, selectParentNode as Be, selectTextblockEnd as Re, selectTextblockStart as je, setBlockType as Tt, wrapIn as Oe } from "../../../prosemirror-commands/dist/index.js";
|
|
3
|
+
import { NodeSelection as pt, EditorState as De, Selection as F, TextSelection as P, Plugin as $, PluginKey as O, AllSelection as _e } from "../../../prosemirror-state/dist/index.js";
|
|
4
4
|
import { DOMSerializer as ze, Schema as Ot, Fragment as j, Node as Fe, DOMParser as it, Slice as Le } from "../../../prosemirror-model/dist/index.js";
|
|
5
5
|
import { liftListItem as Ve, sinkListItem as He, wrapInList as Ue } from "../../../prosemirror-schema-list/dist/index.js";
|
|
6
6
|
import { EditorView as We } from "../../../prosemirror-view/dist/index.js";
|
|
7
7
|
import { keymap as qe } from "../../../prosemirror-keymap/dist/index.js";
|
|
8
|
-
var Ke = Object.defineProperty,
|
|
9
|
-
for (var n in
|
|
10
|
-
Ke(
|
|
8
|
+
var Ke = Object.defineProperty, mt = (t, e) => {
|
|
9
|
+
for (var n in e)
|
|
10
|
+
Ke(t, n, { get: e[n], enumerable: !0 });
|
|
11
11
|
};
|
|
12
|
-
function X(
|
|
13
|
-
const { state:
|
|
12
|
+
function X(t) {
|
|
13
|
+
const { state: e, transaction: n } = t;
|
|
14
14
|
let { selection: r } = n, { doc: o } = n, { storedMarks: s } = n;
|
|
15
15
|
return {
|
|
16
|
-
...
|
|
17
|
-
apply:
|
|
18
|
-
applyTransaction:
|
|
19
|
-
plugins:
|
|
20
|
-
schema:
|
|
21
|
-
reconfigure:
|
|
22
|
-
toJSON:
|
|
16
|
+
...e,
|
|
17
|
+
apply: e.apply.bind(e),
|
|
18
|
+
applyTransaction: e.applyTransaction.bind(e),
|
|
19
|
+
plugins: e.plugins,
|
|
20
|
+
schema: e.schema,
|
|
21
|
+
reconfigure: e.reconfigure.bind(e),
|
|
22
|
+
toJSON: e.toJSON.bind(e),
|
|
23
23
|
get storedMarks() {
|
|
24
24
|
return s;
|
|
25
25
|
},
|
|
@@ -35,8 +35,8 @@ function X(e) {
|
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
var tt = class {
|
|
38
|
-
constructor(
|
|
39
|
-
this.editor =
|
|
38
|
+
constructor(t) {
|
|
39
|
+
this.editor = t.editor, this.rawCommands = this.editor.extensionManager.commands, this.customState = t.state;
|
|
40
40
|
}
|
|
41
41
|
get hasCustomState() {
|
|
42
42
|
return !!this.customState;
|
|
@@ -45,9 +45,9 @@ var tt = class {
|
|
|
45
45
|
return this.customState || this.editor.state;
|
|
46
46
|
}
|
|
47
47
|
get commands() {
|
|
48
|
-
const { rawCommands:
|
|
48
|
+
const { rawCommands: t, editor: e, state: n } = this, { view: r } = e, { tr: o } = n, s = this.buildProps(o);
|
|
49
49
|
return Object.fromEntries(
|
|
50
|
-
Object.entries(
|
|
50
|
+
Object.entries(t).map(([i, c]) => [i, (...l) => {
|
|
51
51
|
const u = c(...l)(s);
|
|
52
52
|
return !o.getMeta("preventDispatch") && !this.hasCustomState && r.dispatch(o), u;
|
|
53
53
|
}])
|
|
@@ -59,11 +59,11 @@ var tt = class {
|
|
|
59
59
|
get can() {
|
|
60
60
|
return () => this.createCan();
|
|
61
61
|
}
|
|
62
|
-
createChain(
|
|
63
|
-
const { rawCommands: n, editor: r, state: o } = this, { view: s } = r, i = [], c = !!
|
|
62
|
+
createChain(t, e = !0) {
|
|
63
|
+
const { rawCommands: n, editor: r, state: o } = this, { view: s } = r, i = [], c = !!t, a = t || o.tr, l = () => (!c && e && !a.getMeta("preventDispatch") && !this.hasCustomState && s.dispatch(a), i.every((d) => d === !0)), u = {
|
|
64
64
|
...Object.fromEntries(
|
|
65
65
|
Object.entries(n).map(([d, f]) => [d, (...m) => {
|
|
66
|
-
const h = this.buildProps(a,
|
|
66
|
+
const h = this.buildProps(a, e), g = f(...m)(h);
|
|
67
67
|
return i.push(g), u;
|
|
68
68
|
}])
|
|
69
69
|
),
|
|
@@ -71,28 +71,28 @@ var tt = class {
|
|
|
71
71
|
};
|
|
72
72
|
return u;
|
|
73
73
|
}
|
|
74
|
-
createCan(
|
|
75
|
-
const { rawCommands:
|
|
74
|
+
createCan(t) {
|
|
75
|
+
const { rawCommands: e, state: n } = this, r = !1, o = t || n.tr, s = this.buildProps(o, r);
|
|
76
76
|
return {
|
|
77
77
|
...Object.fromEntries(
|
|
78
|
-
Object.entries(
|
|
78
|
+
Object.entries(e).map(([c, a]) => [c, (...l) => a(...l)({ ...s, dispatch: void 0 })])
|
|
79
79
|
),
|
|
80
80
|
chain: () => this.createChain(o, r)
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
buildProps(
|
|
83
|
+
buildProps(t, e = !0) {
|
|
84
84
|
const { rawCommands: n, editor: r, state: o } = this, { view: s } = r, i = {
|
|
85
|
-
tr:
|
|
85
|
+
tr: t,
|
|
86
86
|
editor: r,
|
|
87
87
|
view: s,
|
|
88
88
|
state: X({
|
|
89
89
|
state: o,
|
|
90
|
-
transaction:
|
|
90
|
+
transaction: t
|
|
91
91
|
}),
|
|
92
|
-
dispatch:
|
|
92
|
+
dispatch: e ? () => {
|
|
93
93
|
} : void 0,
|
|
94
|
-
chain: () => this.createChain(
|
|
95
|
-
can: () => this.createCan(
|
|
94
|
+
chain: () => this.createChain(t, e),
|
|
95
|
+
can: () => this.createCan(t),
|
|
96
96
|
get commands() {
|
|
97
97
|
return Object.fromEntries(
|
|
98
98
|
Object.entries(n).map(([c, a]) => [c, (...l) => a(...l)(i)])
|
|
@@ -102,7 +102,7 @@ var tt = class {
|
|
|
102
102
|
return i;
|
|
103
103
|
}
|
|
104
104
|
}, Dt = {};
|
|
105
|
-
|
|
105
|
+
mt(Dt, {
|
|
106
106
|
blur: () => Je,
|
|
107
107
|
clearContent: () => Ze,
|
|
108
108
|
clearNodes: () => Qe,
|
|
@@ -164,211 +164,211 @@ pt(Dt, {
|
|
|
164
164
|
wrapIn: () => Mr,
|
|
165
165
|
wrapInList: () => xr
|
|
166
166
|
});
|
|
167
|
-
var Je = () => ({ editor:
|
|
167
|
+
var Je = () => ({ editor: t, view: e }) => (requestAnimationFrame(() => {
|
|
168
168
|
var n;
|
|
169
|
-
|
|
170
|
-
}), !0), Ze = (
|
|
171
|
-
const { selection: r } =
|
|
169
|
+
t.isDestroyed || (e.dom.blur(), (n = window?.getSelection()) == null || n.removeAllRanges());
|
|
170
|
+
}), !0), Ze = (t = !0) => ({ commands: e }) => e.setContent("", { emitUpdate: t }), Qe = () => ({ state: t, tr: e, dispatch: n }) => {
|
|
171
|
+
const { selection: r } = e, { ranges: o } = r;
|
|
172
172
|
return n && o.forEach(({ $from: s, $to: i }) => {
|
|
173
|
-
|
|
173
|
+
t.doc.nodesBetween(s.pos, i.pos, (c, a) => {
|
|
174
174
|
if (c.type.isText)
|
|
175
175
|
return;
|
|
176
|
-
const { doc: l, mapping: u } =
|
|
176
|
+
const { doc: l, mapping: u } = e, d = l.resolve(u.map(a)), f = l.resolve(u.map(a + c.nodeSize)), p = d.blockRange(f);
|
|
177
177
|
if (!p)
|
|
178
178
|
return;
|
|
179
179
|
const m = ge(p);
|
|
180
180
|
if (c.type.isTextblock) {
|
|
181
181
|
const { defaultType: h } = d.parent.contentMatchAt(d.index());
|
|
182
|
-
|
|
182
|
+
e.setNodeMarkup(p.start, h);
|
|
183
183
|
}
|
|
184
|
-
(m || m === 0) &&
|
|
184
|
+
(m || m === 0) && e.lift(p, m);
|
|
185
185
|
});
|
|
186
186
|
}), !0;
|
|
187
|
-
}, Ge = (
|
|
188
|
-
const { state: o } = n, s = o.doc.slice(
|
|
189
|
-
r.deleteRange(
|
|
190
|
-
const i = r.mapping.map(
|
|
187
|
+
}, Ge = (t) => (e) => t(e), Ye = () => ({ state: t, dispatch: e }) => ke(t, e), Xe = (t, e) => ({ editor: n, tr: r }) => {
|
|
188
|
+
const { state: o } = n, s = o.doc.slice(t.from, t.to);
|
|
189
|
+
r.deleteRange(t.from, t.to);
|
|
190
|
+
const i = r.mapping.map(e);
|
|
191
191
|
return r.insert(i, s.content), r.setSelection(new P(r.doc.resolve(Math.max(i - 1, 0)))), !0;
|
|
192
|
-
}, tn = () => ({ tr:
|
|
193
|
-
const { selection: n } =
|
|
192
|
+
}, tn = () => ({ tr: t, dispatch: e }) => {
|
|
193
|
+
const { selection: n } = t, r = n.$anchor.node();
|
|
194
194
|
if (r.content.size > 0)
|
|
195
195
|
return !1;
|
|
196
|
-
const o =
|
|
196
|
+
const o = t.selection.$anchor;
|
|
197
197
|
for (let s = o.depth; s > 0; s -= 1)
|
|
198
198
|
if (o.node(s).type === r.type) {
|
|
199
|
-
if (
|
|
199
|
+
if (e) {
|
|
200
200
|
const c = o.before(s), a = o.after(s);
|
|
201
|
-
|
|
201
|
+
t.delete(c, a).scrollIntoView();
|
|
202
202
|
}
|
|
203
203
|
return !0;
|
|
204
204
|
}
|
|
205
205
|
return !1;
|
|
206
206
|
};
|
|
207
|
-
function T(
|
|
208
|
-
if (typeof
|
|
209
|
-
if (!
|
|
210
|
-
throw Error(`There is no node type named '${
|
|
211
|
-
return
|
|
207
|
+
function T(t, e) {
|
|
208
|
+
if (typeof t == "string") {
|
|
209
|
+
if (!e.nodes[t])
|
|
210
|
+
throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);
|
|
211
|
+
return e.nodes[t];
|
|
212
212
|
}
|
|
213
|
-
return
|
|
213
|
+
return t;
|
|
214
214
|
}
|
|
215
|
-
var en = (
|
|
216
|
-
const o = T(
|
|
215
|
+
var en = (t) => ({ tr: e, state: n, dispatch: r }) => {
|
|
216
|
+
const o = T(t, n.schema), s = e.selection.$anchor;
|
|
217
217
|
for (let i = s.depth; i > 0; i -= 1)
|
|
218
218
|
if (s.node(i).type === o) {
|
|
219
219
|
if (r) {
|
|
220
220
|
const a = s.before(i), l = s.after(i);
|
|
221
|
-
|
|
221
|
+
e.delete(a, l).scrollIntoView();
|
|
222
222
|
}
|
|
223
223
|
return !0;
|
|
224
224
|
}
|
|
225
225
|
return !1;
|
|
226
|
-
}, nn = (
|
|
227
|
-
const { from: r, to: o } =
|
|
228
|
-
return n &&
|
|
229
|
-
}, rn = () => ({ state:
|
|
230
|
-
function
|
|
231
|
-
return Object.prototype.toString.call(
|
|
232
|
-
}
|
|
233
|
-
function G(
|
|
234
|
-
const r = Object.keys(
|
|
235
|
-
return r.length ? r.every((o) => n.strict ?
|
|
236
|
-
}
|
|
237
|
-
function _t(
|
|
238
|
-
return
|
|
226
|
+
}, nn = (t) => ({ tr: e, dispatch: n }) => {
|
|
227
|
+
const { from: r, to: o } = t;
|
|
228
|
+
return n && e.delete(r, o), !0;
|
|
229
|
+
}, rn = () => ({ state: t, dispatch: e }) => ye(t, e), on = () => ({ commands: t }) => t.keyboardShortcut("Enter"), sn = () => ({ state: t, dispatch: e }) => we(t, e);
|
|
230
|
+
function ht(t) {
|
|
231
|
+
return Object.prototype.toString.call(t) === "[object RegExp]";
|
|
232
|
+
}
|
|
233
|
+
function G(t, e, n = { strict: !0 }) {
|
|
234
|
+
const r = Object.keys(e);
|
|
235
|
+
return r.length ? r.every((o) => n.strict ? e[o] === t[o] : ht(e[o]) ? e[o].test(t[o]) : e[o] === t[o]) : !0;
|
|
236
|
+
}
|
|
237
|
+
function _t(t, e, n = {}) {
|
|
238
|
+
return t.find((r) => r.type === e && G(
|
|
239
239
|
// Only check equality for the attributes that are provided
|
|
240
240
|
Object.fromEntries(Object.keys(n).map((o) => [o, r.attrs[o]])),
|
|
241
241
|
n
|
|
242
242
|
));
|
|
243
243
|
}
|
|
244
|
-
function
|
|
245
|
-
return !!_t(
|
|
244
|
+
function At(t, e, n = {}) {
|
|
245
|
+
return !!_t(t, e, n);
|
|
246
246
|
}
|
|
247
|
-
function
|
|
247
|
+
function gt(t, e, n) {
|
|
248
248
|
var r;
|
|
249
|
-
if (!
|
|
249
|
+
if (!t || !e)
|
|
250
250
|
return;
|
|
251
|
-
let o =
|
|
252
|
-
if ((!o.node || !o.node.marks.some((u) => u.type ===
|
|
251
|
+
let o = t.parent.childAfter(t.parentOffset);
|
|
252
|
+
if ((!o.node || !o.node.marks.some((u) => u.type === e)) && (o = t.parent.childBefore(t.parentOffset)), !o.node || !o.node.marks.some((u) => u.type === e) || (n = n || ((r = o.node.marks[0]) == null ? void 0 : r.attrs), !_t([...o.node.marks], e, n)))
|
|
253
253
|
return;
|
|
254
|
-
let i = o.index, c =
|
|
255
|
-
for (; i > 0 &&
|
|
256
|
-
i -= 1, c -=
|
|
257
|
-
for (; a <
|
|
258
|
-
l +=
|
|
254
|
+
let i = o.index, c = t.start() + o.offset, a = i + 1, l = c + o.node.nodeSize;
|
|
255
|
+
for (; i > 0 && At([...t.parent.child(i - 1).marks], e, n); )
|
|
256
|
+
i -= 1, c -= t.parent.child(i).nodeSize;
|
|
257
|
+
for (; a < t.parent.childCount && At([...t.parent.child(a).marks], e, n); )
|
|
258
|
+
l += t.parent.child(a).nodeSize, a += 1;
|
|
259
259
|
return {
|
|
260
260
|
from: c,
|
|
261
261
|
to: l
|
|
262
262
|
};
|
|
263
263
|
}
|
|
264
|
-
function B(
|
|
265
|
-
if (typeof
|
|
266
|
-
if (!
|
|
267
|
-
throw Error(`There is no mark type named '${
|
|
268
|
-
return
|
|
264
|
+
function B(t, e) {
|
|
265
|
+
if (typeof t == "string") {
|
|
266
|
+
if (!e.marks[t])
|
|
267
|
+
throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);
|
|
268
|
+
return e.marks[t];
|
|
269
269
|
}
|
|
270
|
-
return
|
|
270
|
+
return t;
|
|
271
271
|
}
|
|
272
|
-
var an = (
|
|
273
|
-
const s = B(
|
|
272
|
+
var an = (t, e = {}) => ({ tr: n, state: r, dispatch: o }) => {
|
|
273
|
+
const s = B(t, r.schema), { doc: i, selection: c } = n, { $from: a, from: l, to: u } = c;
|
|
274
274
|
if (o) {
|
|
275
|
-
const d =
|
|
275
|
+
const d = gt(a, s, e);
|
|
276
276
|
if (d && d.from <= l && d.to >= u) {
|
|
277
277
|
const f = P.create(i, d.from, d.to);
|
|
278
278
|
n.setSelection(f);
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
281
|
return !0;
|
|
282
|
-
}, cn = (
|
|
283
|
-
const n = typeof
|
|
282
|
+
}, cn = (t) => (e) => {
|
|
283
|
+
const n = typeof t == "function" ? t(e) : t;
|
|
284
284
|
for (let r = 0; r < n.length; r += 1)
|
|
285
|
-
if (n[r](
|
|
285
|
+
if (n[r](e))
|
|
286
286
|
return !0;
|
|
287
287
|
return !1;
|
|
288
288
|
};
|
|
289
|
-
function zt(
|
|
290
|
-
return
|
|
289
|
+
function zt(t) {
|
|
290
|
+
return t instanceof P;
|
|
291
291
|
}
|
|
292
|
-
function _(
|
|
293
|
-
return Math.min(Math.max(
|
|
292
|
+
function _(t = 0, e = 0, n = 0) {
|
|
293
|
+
return Math.min(Math.max(t, e), n);
|
|
294
294
|
}
|
|
295
|
-
function Ft(
|
|
296
|
-
if (!
|
|
295
|
+
function Ft(t, e = null) {
|
|
296
|
+
if (!e)
|
|
297
297
|
return null;
|
|
298
|
-
const n = F.atStart(
|
|
299
|
-
if (
|
|
298
|
+
const n = F.atStart(t), r = F.atEnd(t);
|
|
299
|
+
if (e === "start" || e === !0)
|
|
300
300
|
return n;
|
|
301
|
-
if (
|
|
301
|
+
if (e === "end")
|
|
302
302
|
return r;
|
|
303
303
|
const o = n.from, s = r.to;
|
|
304
|
-
return
|
|
304
|
+
return e === "all" ? P.create(t, _(0, o, s), _(t.content.size, o, s)) : P.create(t, _(e, o, s), _(e, o, s));
|
|
305
305
|
}
|
|
306
306
|
function ln() {
|
|
307
307
|
return navigator.platform === "Android" || /android/i.test(navigator.userAgent);
|
|
308
308
|
}
|
|
309
|
-
function
|
|
309
|
+
function vt() {
|
|
310
310
|
return ["iPad Simulator", "iPhone Simulator", "iPod Simulator", "iPad", "iPhone", "iPod"].includes(navigator.platform) || // iPad on iOS 13 detection
|
|
311
311
|
navigator.userAgent.includes("Mac") && "ontouchend" in document;
|
|
312
312
|
}
|
|
313
|
-
var dn = (
|
|
314
|
-
|
|
313
|
+
var dn = (t = null, e = {}) => ({ editor: n, view: r, tr: o, dispatch: s }) => {
|
|
314
|
+
e = {
|
|
315
315
|
scrollIntoView: !0,
|
|
316
|
-
...
|
|
316
|
+
...e
|
|
317
317
|
};
|
|
318
318
|
const i = () => {
|
|
319
|
-
(
|
|
320
|
-
n.isDestroyed || (r.focus(),
|
|
319
|
+
(vt() || ln()) && r.dom.focus(), requestAnimationFrame(() => {
|
|
320
|
+
n.isDestroyed || (r.focus(), e?.scrollIntoView && n.commands.scrollIntoView());
|
|
321
321
|
});
|
|
322
322
|
};
|
|
323
|
-
if (r.hasFocus() &&
|
|
323
|
+
if (r.hasFocus() && t === null || t === !1)
|
|
324
324
|
return !0;
|
|
325
|
-
if (s &&
|
|
325
|
+
if (s && t === null && !zt(n.state.selection))
|
|
326
326
|
return i(), !0;
|
|
327
|
-
const c = Ft(o.doc,
|
|
327
|
+
const c = Ft(o.doc, t) || n.state.selection, a = n.state.selection.eq(c);
|
|
328
328
|
return s && (a || o.setSelection(c), a && o.storedMarks && o.setStoredMarks(o.storedMarks), i()), !0;
|
|
329
|
-
}, un = (
|
|
330
|
-
const
|
|
331
|
-
for (let n =
|
|
332
|
-
const r =
|
|
333
|
-
r.nodeType === 3 && r.nodeValue && /^(\n\s\s|\n)$/.test(r.nodeValue) ?
|
|
329
|
+
}, un = (t, e) => (n) => t.every((r, o) => e(r, { ...n, index: o })), fn = (t, e) => ({ tr: n, commands: r }) => r.insertContentAt({ from: n.selection.from, to: n.selection.to }, t, e), Lt = (t) => {
|
|
330
|
+
const e = t.childNodes;
|
|
331
|
+
for (let n = e.length - 1; n >= 0; n -= 1) {
|
|
332
|
+
const r = e[n];
|
|
333
|
+
r.nodeType === 3 && r.nodeValue && /^(\n\s\s|\n)$/.test(r.nodeValue) ? t.removeChild(r) : r.nodeType === 1 && Lt(r);
|
|
334
334
|
}
|
|
335
|
-
return
|
|
335
|
+
return t;
|
|
336
336
|
};
|
|
337
|
-
function W(
|
|
337
|
+
function W(t) {
|
|
338
338
|
if (typeof window > "u")
|
|
339
339
|
throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");
|
|
340
|
-
const
|
|
340
|
+
const e = `<body>${t}</body>`, n = new window.DOMParser().parseFromString(e, "text/html").body;
|
|
341
341
|
return Lt(n);
|
|
342
342
|
}
|
|
343
|
-
function V(
|
|
344
|
-
if (
|
|
345
|
-
return
|
|
343
|
+
function V(t, e, n) {
|
|
344
|
+
if (t instanceof Fe || t instanceof j)
|
|
345
|
+
return t;
|
|
346
346
|
n = {
|
|
347
347
|
slice: !0,
|
|
348
348
|
parseOptions: {},
|
|
349
349
|
...n
|
|
350
350
|
};
|
|
351
|
-
const r = typeof
|
|
351
|
+
const r = typeof t == "object" && t !== null, o = typeof t == "string";
|
|
352
352
|
if (r)
|
|
353
353
|
try {
|
|
354
|
-
if (Array.isArray(
|
|
355
|
-
return j.fromArray(
|
|
356
|
-
const i =
|
|
354
|
+
if (Array.isArray(t) && t.length > 0)
|
|
355
|
+
return j.fromArray(t.map((c) => e.nodeFromJSON(c)));
|
|
356
|
+
const i = e.nodeFromJSON(t);
|
|
357
357
|
return n.errorOnInvalidContent && i.check(), i;
|
|
358
358
|
} catch (s) {
|
|
359
359
|
if (n.errorOnInvalidContent)
|
|
360
360
|
throw new Error("[tiptap error]: Invalid JSON content", { cause: s });
|
|
361
|
-
return console.warn("[tiptap warn]: Invalid content.", "Passed value:",
|
|
361
|
+
return console.warn("[tiptap warn]: Invalid content.", "Passed value:", t, "Error:", s), V("", e, n);
|
|
362
362
|
}
|
|
363
363
|
if (o) {
|
|
364
364
|
if (n.errorOnInvalidContent) {
|
|
365
365
|
let i = !1, c = "";
|
|
366
366
|
const a = new Ot({
|
|
367
|
-
topNode:
|
|
368
|
-
marks:
|
|
367
|
+
topNode: e.spec.topNode,
|
|
368
|
+
marks: e.spec.marks,
|
|
369
369
|
// Prosemirror's schemas are executed such that: the last to execute, matches last
|
|
370
370
|
// This means that we can add a catch-all node at the end of the schema to catch any content that we don't know how to handle
|
|
371
|
-
nodes:
|
|
371
|
+
nodes: e.spec.nodes.append({
|
|
372
372
|
__tiptap__private__unknown__catch__all__node: {
|
|
373
373
|
content: "inline*",
|
|
374
374
|
group: "block",
|
|
@@ -381,30 +381,30 @@ function V(e, t, n) {
|
|
|
381
381
|
}
|
|
382
382
|
})
|
|
383
383
|
});
|
|
384
|
-
if (n.slice ? it.fromSchema(a).parseSlice(W(
|
|
384
|
+
if (n.slice ? it.fromSchema(a).parseSlice(W(t), n.parseOptions) : it.fromSchema(a).parse(W(t), n.parseOptions), n.errorOnInvalidContent && i)
|
|
385
385
|
throw new Error("[tiptap error]: Invalid HTML content", {
|
|
386
386
|
cause: new Error(`Invalid element found: ${c}`)
|
|
387
387
|
});
|
|
388
388
|
}
|
|
389
|
-
const s = it.fromSchema(
|
|
390
|
-
return n.slice ? s.parseSlice(W(
|
|
389
|
+
const s = it.fromSchema(e);
|
|
390
|
+
return n.slice ? s.parseSlice(W(t), n.parseOptions).content : s.parse(W(t), n.parseOptions);
|
|
391
391
|
}
|
|
392
|
-
return V("",
|
|
392
|
+
return V("", e, n);
|
|
393
393
|
}
|
|
394
|
-
function pn(
|
|
395
|
-
const r =
|
|
396
|
-
if (r <
|
|
394
|
+
function pn(t, e, n) {
|
|
395
|
+
const r = t.steps.length - 1;
|
|
396
|
+
if (r < e)
|
|
397
397
|
return;
|
|
398
|
-
const o =
|
|
398
|
+
const o = t.steps[r];
|
|
399
399
|
if (!(o instanceof ve || o instanceof be))
|
|
400
400
|
return;
|
|
401
|
-
const s =
|
|
401
|
+
const s = t.mapping.maps[r];
|
|
402
402
|
let i = 0;
|
|
403
403
|
s.forEach((c, a, l, u) => {
|
|
404
404
|
i === 0 && (i = u);
|
|
405
|
-
}),
|
|
405
|
+
}), t.setSelection(F.near(t.doc.resolve(i), n));
|
|
406
406
|
}
|
|
407
|
-
var mn = (
|
|
407
|
+
var mn = (t) => !("type" in t), hn = (t, e, n) => ({ tr: r, dispatch: o, editor: s }) => {
|
|
408
408
|
var i;
|
|
409
409
|
if (o) {
|
|
410
410
|
n = {
|
|
@@ -429,7 +429,7 @@ var mn = (e) => !("type" in e), hn = (e, t, n) => ({ tr: r, dispatch: o, editor:
|
|
|
429
429
|
};
|
|
430
430
|
if (!n.errorOnInvalidContent && !s.options.enableContentCheck && s.options.emitContentError)
|
|
431
431
|
try {
|
|
432
|
-
V(
|
|
432
|
+
V(e, s.schema, {
|
|
433
433
|
parseOptions: l,
|
|
434
434
|
errorOnInvalidContent: !0
|
|
435
435
|
});
|
|
@@ -437,14 +437,14 @@ var mn = (e) => !("type" in e), hn = (e, t, n) => ({ tr: r, dispatch: o, editor:
|
|
|
437
437
|
a(g);
|
|
438
438
|
}
|
|
439
439
|
try {
|
|
440
|
-
c = V(
|
|
440
|
+
c = V(e, s.schema, {
|
|
441
441
|
parseOptions: l,
|
|
442
442
|
errorOnInvalidContent: (i = n.errorOnInvalidContent) != null ? i : s.options.enableContentCheck
|
|
443
443
|
});
|
|
444
444
|
} catch (g) {
|
|
445
445
|
return a(g), !1;
|
|
446
446
|
}
|
|
447
|
-
let { from: u, to: d } = typeof
|
|
447
|
+
let { from: u, to: d } = typeof t == "number" ? { from: t, to: t } : { from: t.from, to: t.to }, f = !0, p = !0;
|
|
448
448
|
if ((mn(c) ? c : [c]).forEach((g) => {
|
|
449
449
|
g.check(), f = f ? g.isText && g.marks.length === 0 : !1, p = p ? g.isBlock : !1;
|
|
450
450
|
}), u === d && p) {
|
|
@@ -453,14 +453,14 @@ var mn = (e) => !("type" in e), hn = (e, t, n) => ({ tr: r, dispatch: o, editor:
|
|
|
453
453
|
}
|
|
454
454
|
let h;
|
|
455
455
|
if (f) {
|
|
456
|
-
if (Array.isArray(
|
|
457
|
-
h =
|
|
458
|
-
else if (
|
|
456
|
+
if (Array.isArray(e))
|
|
457
|
+
h = e.map((g) => g.text || "").join("");
|
|
458
|
+
else if (e instanceof j) {
|
|
459
459
|
let g = "";
|
|
460
|
-
|
|
460
|
+
e.forEach((v) => {
|
|
461
461
|
v.text && (g += v.text);
|
|
462
462
|
}), h = g;
|
|
463
|
-
} else typeof
|
|
463
|
+
} else typeof e == "object" && e && e.text ? h = e.text : h = e;
|
|
464
464
|
r.insertText(h, u, d);
|
|
465
465
|
} else {
|
|
466
466
|
h = c;
|
|
@@ -470,31 +470,31 @@ var mn = (e) => !("type" in e), hn = (e, t, n) => ({ tr: r, dispatch: o, editor:
|
|
|
470
470
|
n.updateSelection && pn(r, r.steps.length - 1, -1), n.applyInputRules && r.setMeta("applyInputRules", { from: u, text: h }), n.applyPasteRules && r.setMeta("applyPasteRules", { from: u, text: h });
|
|
471
471
|
}
|
|
472
472
|
return !0;
|
|
473
|
-
}, gn = () => ({ state:
|
|
473
|
+
}, gn = () => ({ state: t, dispatch: e }) => Me(t, e), vn = () => ({ state: t, dispatch: e }) => xe(t, e), bn = () => ({ state: t, dispatch: e }) => Se(t, e), kn = () => ({ state: t, dispatch: e }) => Ee(t, e), yn = () => ({ state: t, dispatch: e, tr: n }) => {
|
|
474
474
|
try {
|
|
475
|
-
const r =
|
|
476
|
-
return r == null ? !1 : (n.join(r, 2),
|
|
475
|
+
const r = jt(t.doc, t.selection.$from.pos, -1);
|
|
476
|
+
return r == null ? !1 : (n.join(r, 2), e && e(n), !0);
|
|
477
477
|
} catch {
|
|
478
478
|
return !1;
|
|
479
479
|
}
|
|
480
|
-
}, wn = () => ({ state:
|
|
480
|
+
}, wn = () => ({ state: t, dispatch: e, tr: n }) => {
|
|
481
481
|
try {
|
|
482
|
-
const r =
|
|
483
|
-
return r == null ? !1 : (n.join(r, 2),
|
|
482
|
+
const r = jt(t.doc, t.selection.$from.pos, 1);
|
|
483
|
+
return r == null ? !1 : (n.join(r, 2), e && e(n), !0);
|
|
484
484
|
} catch {
|
|
485
485
|
return !1;
|
|
486
486
|
}
|
|
487
|
-
}, Mn = () => ({ state:
|
|
487
|
+
}, Mn = () => ({ state: t, dispatch: e }) => Te(t, e), xn = () => ({ state: t, dispatch: e }) => Ae(t, e);
|
|
488
488
|
function Vt() {
|
|
489
489
|
return typeof navigator < "u" ? /Mac/.test(navigator.platform) : !1;
|
|
490
490
|
}
|
|
491
|
-
function Sn(
|
|
492
|
-
const
|
|
493
|
-
let n =
|
|
491
|
+
function Sn(t) {
|
|
492
|
+
const e = t.split(/-(?!$)/);
|
|
493
|
+
let n = e[e.length - 1];
|
|
494
494
|
n === "Space" && (n = " ");
|
|
495
495
|
let r, o, s, i;
|
|
496
|
-
for (let c = 0; c <
|
|
497
|
-
const a =
|
|
496
|
+
for (let c = 0; c < e.length - 1; c += 1) {
|
|
497
|
+
const a = e[c];
|
|
498
498
|
if (/^(cmd|meta|m)$/i.test(a))
|
|
499
499
|
i = !0;
|
|
500
500
|
else if (/^a(lt)?$/i.test(a))
|
|
@@ -504,14 +504,14 @@ function Sn(e) {
|
|
|
504
504
|
else if (/^s(hift)?$/i.test(a))
|
|
505
505
|
s = !0;
|
|
506
506
|
else if (/^mod$/i.test(a))
|
|
507
|
-
|
|
507
|
+
vt() || Vt() ? i = !0 : o = !0;
|
|
508
508
|
else
|
|
509
509
|
throw new Error(`Unrecognized modifier name: ${a}`);
|
|
510
510
|
}
|
|
511
511
|
return r && (n = `Alt-${n}`), o && (n = `Ctrl-${n}`), i && (n = `Meta-${n}`), s && (n = `Shift-${n}`), n;
|
|
512
512
|
}
|
|
513
|
-
var En = (
|
|
514
|
-
const s = Sn(
|
|
513
|
+
var En = (t) => ({ editor: e, view: n, tr: r, dispatch: o }) => {
|
|
514
|
+
const s = Sn(t).split(/-(?!$)/), i = s.find((l) => !["Alt", "Ctrl", "Meta", "Shift"].includes(l)), c = new KeyboardEvent("keydown", {
|
|
515
515
|
key: i === "Space" ? " " : i,
|
|
516
516
|
altKey: s.includes("Alt"),
|
|
517
517
|
ctrlKey: s.includes("Ctrl"),
|
|
@@ -519,7 +519,7 @@ var En = (e) => ({ editor: t, view: n, tr: r, dispatch: o }) => {
|
|
|
519
519
|
shiftKey: s.includes("Shift"),
|
|
520
520
|
bubbles: !0,
|
|
521
521
|
cancelable: !0
|
|
522
|
-
}), a =
|
|
522
|
+
}), a = e.captureTransaction(() => {
|
|
523
523
|
n.someProp("handleKeyDown", (l) => l(n, c));
|
|
524
524
|
});
|
|
525
525
|
return a?.steps.forEach((l) => {
|
|
@@ -527,9 +527,9 @@ var En = (e) => ({ editor: t, view: n, tr: r, dispatch: o }) => {
|
|
|
527
527
|
u && o && r.maybeStep(u);
|
|
528
528
|
}), !0;
|
|
529
529
|
};
|
|
530
|
-
function H(
|
|
531
|
-
const { from: r, to: o, empty: s } =
|
|
532
|
-
|
|
530
|
+
function H(t, e, n = {}) {
|
|
531
|
+
const { from: r, to: o, empty: s } = t.selection, i = e ? T(e, t.schema) : null, c = [];
|
|
532
|
+
t.doc.nodesBetween(r, o, (d, f) => {
|
|
533
533
|
if (d.isText)
|
|
534
534
|
return;
|
|
535
535
|
const p = Math.max(r, f), m = Math.min(o, f + d.nodeSize);
|
|
@@ -542,151 +542,151 @@ function H(e, t, n = {}) {
|
|
|
542
542
|
const a = o - r, l = c.filter((d) => i ? i.name === d.node.type.name : !0).filter((d) => G(d.node.attrs, n, { strict: !1 }));
|
|
543
543
|
return s ? !!l.length : l.reduce((d, f) => d + f.to - f.from, 0) >= a;
|
|
544
544
|
}
|
|
545
|
-
var Tn = (
|
|
546
|
-
const o = T(
|
|
547
|
-
return H(n, o,
|
|
548
|
-
}, An = () => ({ state:
|
|
549
|
-
const r = T(
|
|
550
|
-
return Ve(r)(
|
|
551
|
-
}, Pn = () => ({ state:
|
|
552
|
-
function et(
|
|
553
|
-
return
|
|
554
|
-
}
|
|
555
|
-
function
|
|
556
|
-
const n = typeof
|
|
557
|
-
return Object.keys(
|
|
558
|
-
}
|
|
559
|
-
var $n = (
|
|
545
|
+
var Tn = (t, e = {}) => ({ state: n, dispatch: r }) => {
|
|
546
|
+
const o = T(t, n.schema);
|
|
547
|
+
return H(n, o, e) ? Ce(n, r) : !1;
|
|
548
|
+
}, An = () => ({ state: t, dispatch: e }) => Pe(t, e), Cn = (t) => ({ state: e, dispatch: n }) => {
|
|
549
|
+
const r = T(t, e.schema);
|
|
550
|
+
return Ve(r)(e, n);
|
|
551
|
+
}, Pn = () => ({ state: t, dispatch: e }) => $e(t, e);
|
|
552
|
+
function et(t, e) {
|
|
553
|
+
return e.nodes[t] ? "node" : e.marks[t] ? "mark" : null;
|
|
554
|
+
}
|
|
555
|
+
function Ct(t, e) {
|
|
556
|
+
const n = typeof e == "string" ? [e] : e;
|
|
557
|
+
return Object.keys(t).reduce((r, o) => (n.includes(o) || (r[o] = t[o]), r), {});
|
|
558
|
+
}
|
|
559
|
+
var $n = (t, e) => ({ tr: n, state: r, dispatch: o }) => {
|
|
560
560
|
let s = null, i = null;
|
|
561
561
|
const c = et(
|
|
562
|
-
typeof
|
|
562
|
+
typeof t == "string" ? t : t.name,
|
|
563
563
|
r.schema
|
|
564
564
|
);
|
|
565
565
|
if (!c)
|
|
566
566
|
return !1;
|
|
567
|
-
c === "node" && (s = T(
|
|
567
|
+
c === "node" && (s = T(t, r.schema)), c === "mark" && (i = B(t, r.schema));
|
|
568
568
|
let a = !1;
|
|
569
569
|
return n.selection.ranges.forEach((l) => {
|
|
570
570
|
r.doc.nodesBetween(l.$from.pos, l.$to.pos, (u, d) => {
|
|
571
|
-
s && s === u.type && (a = !0, o && n.setNodeMarkup(d, void 0,
|
|
572
|
-
i === f.type && (a = !0, o && n.addMark(d, d + u.nodeSize, i.create(
|
|
571
|
+
s && s === u.type && (a = !0, o && n.setNodeMarkup(d, void 0, Ct(u.attrs, e))), i && u.marks.length && u.marks.forEach((f) => {
|
|
572
|
+
i === f.type && (a = !0, o && n.addMark(d, d + u.nodeSize, i.create(Ct(f.attrs, e))));
|
|
573
573
|
});
|
|
574
574
|
});
|
|
575
575
|
}), a;
|
|
576
|
-
}, Nn = () => ({ tr:
|
|
577
|
-
if (
|
|
578
|
-
const n = new _e(
|
|
579
|
-
|
|
576
|
+
}, Nn = () => ({ tr: t, dispatch: e }) => (e && t.scrollIntoView(), !0), In = () => ({ tr: t, dispatch: e }) => {
|
|
577
|
+
if (e) {
|
|
578
|
+
const n = new _e(t.doc);
|
|
579
|
+
t.setSelection(n);
|
|
580
580
|
}
|
|
581
581
|
return !0;
|
|
582
|
-
}, Bn = () => ({ state:
|
|
583
|
-
function dt(
|
|
584
|
-
return V(
|
|
582
|
+
}, Bn = () => ({ state: t, dispatch: e }) => Ne(t, e), Rn = () => ({ state: t, dispatch: e }) => Ie(t, e), jn = () => ({ state: t, dispatch: e }) => Be(t, e), On = () => ({ state: t, dispatch: e }) => Re(t, e), Dn = () => ({ state: t, dispatch: e }) => je(t, e);
|
|
583
|
+
function dt(t, e, n = {}, r = {}) {
|
|
584
|
+
return V(t, e, {
|
|
585
585
|
slice: !1,
|
|
586
586
|
parseOptions: n,
|
|
587
587
|
errorOnInvalidContent: r.errorOnInvalidContent
|
|
588
588
|
});
|
|
589
589
|
}
|
|
590
|
-
var _n = (
|
|
590
|
+
var _n = (t, { errorOnInvalidContent: e, emitUpdate: n = !0, parseOptions: r = {} } = {}) => ({ editor: o, tr: s, dispatch: i, commands: c }) => {
|
|
591
591
|
const { doc: a } = s;
|
|
592
592
|
if (r.preserveWhitespace !== "full") {
|
|
593
|
-
const l = dt(
|
|
594
|
-
errorOnInvalidContent:
|
|
593
|
+
const l = dt(t, o.schema, r, {
|
|
594
|
+
errorOnInvalidContent: e ?? o.options.enableContentCheck
|
|
595
595
|
});
|
|
596
596
|
return i && s.replaceWith(0, a.content.size, l).setMeta("preventUpdate", !n), !0;
|
|
597
597
|
}
|
|
598
|
-
return i && s.setMeta("preventUpdate", !n), c.insertContentAt({ from: 0, to: a.content.size },
|
|
598
|
+
return i && s.setMeta("preventUpdate", !n), c.insertContentAt({ from: 0, to: a.content.size }, t, {
|
|
599
599
|
parseOptions: r,
|
|
600
|
-
errorOnInvalidContent:
|
|
600
|
+
errorOnInvalidContent: e ?? o.options.enableContentCheck
|
|
601
601
|
});
|
|
602
602
|
};
|
|
603
|
-
function Ht(
|
|
604
|
-
const n = B(
|
|
605
|
-
s ? (
|
|
603
|
+
function Ht(t, e) {
|
|
604
|
+
const n = B(e, t.schema), { from: r, to: o, empty: s } = t.selection, i = [];
|
|
605
|
+
s ? (t.storedMarks && i.push(...t.storedMarks), i.push(...t.selection.$head.marks())) : t.doc.nodesBetween(r, o, (a) => {
|
|
606
606
|
i.push(...a.marks);
|
|
607
607
|
});
|
|
608
608
|
const c = i.find((a) => a.type.name === n.name);
|
|
609
609
|
return c ? { ...c.attrs } : {};
|
|
610
610
|
}
|
|
611
|
-
function zn(
|
|
612
|
-
const n = new pe(
|
|
613
|
-
return
|
|
611
|
+
function zn(t, e) {
|
|
612
|
+
const n = new pe(t);
|
|
613
|
+
return e.forEach((r) => {
|
|
614
614
|
r.steps.forEach((o) => {
|
|
615
615
|
n.step(o);
|
|
616
616
|
});
|
|
617
617
|
}), n;
|
|
618
618
|
}
|
|
619
|
-
function Fn(
|
|
620
|
-
for (let
|
|
621
|
-
const { type: n } =
|
|
619
|
+
function Fn(t) {
|
|
620
|
+
for (let e = 0; e < t.edgeCount; e += 1) {
|
|
621
|
+
const { type: n } = t.edge(e);
|
|
622
622
|
if (n.isTextblock && !n.hasRequiredAttrs())
|
|
623
623
|
return n;
|
|
624
624
|
}
|
|
625
625
|
return null;
|
|
626
626
|
}
|
|
627
|
-
function eo(
|
|
627
|
+
function eo(t, e, n) {
|
|
628
628
|
const r = [];
|
|
629
|
-
return
|
|
629
|
+
return t.nodesBetween(e.from, e.to, (o, s) => {
|
|
630
630
|
n(o) && r.push({
|
|
631
631
|
node: o,
|
|
632
632
|
pos: s
|
|
633
633
|
});
|
|
634
634
|
}), r;
|
|
635
635
|
}
|
|
636
|
-
function Ln(
|
|
637
|
-
for (let n =
|
|
638
|
-
const r =
|
|
639
|
-
if (
|
|
636
|
+
function Ln(t, e) {
|
|
637
|
+
for (let n = t.depth; n > 0; n -= 1) {
|
|
638
|
+
const r = t.node(n);
|
|
639
|
+
if (e(r))
|
|
640
640
|
return {
|
|
641
|
-
pos: n > 0 ?
|
|
642
|
-
start:
|
|
641
|
+
pos: n > 0 ? t.before(n) : 0,
|
|
642
|
+
start: t.start(n),
|
|
643
643
|
depth: n,
|
|
644
644
|
node: r
|
|
645
645
|
};
|
|
646
646
|
}
|
|
647
647
|
}
|
|
648
|
-
function nt(
|
|
649
|
-
return (
|
|
648
|
+
function nt(t) {
|
|
649
|
+
return (e) => Ln(e.$from, t);
|
|
650
650
|
}
|
|
651
|
-
function b(
|
|
652
|
-
return
|
|
651
|
+
function b(t, e, n) {
|
|
652
|
+
return t.config[e] === void 0 && t.parent ? b(t.parent, e, n) : typeof t.config[e] == "function" ? t.config[e].bind({
|
|
653
653
|
...n,
|
|
654
|
-
parent:
|
|
655
|
-
}) :
|
|
654
|
+
parent: t.parent ? b(t.parent, e, n) : null
|
|
655
|
+
}) : t.config[e];
|
|
656
656
|
}
|
|
657
|
-
function
|
|
658
|
-
return
|
|
657
|
+
function bt(t) {
|
|
658
|
+
return t.map((e) => {
|
|
659
659
|
const n = {
|
|
660
|
-
name:
|
|
661
|
-
options:
|
|
662
|
-
storage:
|
|
663
|
-
}, r = b(
|
|
664
|
-
return r ? [
|
|
660
|
+
name: e.name,
|
|
661
|
+
options: e.options,
|
|
662
|
+
storage: e.storage
|
|
663
|
+
}, r = b(e, "addExtensions", n);
|
|
664
|
+
return r ? [e, ...bt(r())] : e;
|
|
665
665
|
}).flat(10);
|
|
666
666
|
}
|
|
667
|
-
function
|
|
668
|
-
const n = ze.fromSchema(
|
|
667
|
+
function kt(t, e) {
|
|
668
|
+
const n = ze.fromSchema(e).serializeFragment(t), o = document.implementation.createHTMLDocument().createElement("div");
|
|
669
669
|
return o.appendChild(n), o.innerHTML;
|
|
670
670
|
}
|
|
671
|
-
function Ut(
|
|
672
|
-
return typeof
|
|
671
|
+
function Ut(t) {
|
|
672
|
+
return typeof t == "function";
|
|
673
673
|
}
|
|
674
|
-
function x(
|
|
675
|
-
return Ut(
|
|
674
|
+
function x(t, e = void 0, ...n) {
|
|
675
|
+
return Ut(t) ? e ? t.bind(e)(...n) : t(...n) : t;
|
|
676
676
|
}
|
|
677
|
-
function Vn(
|
|
678
|
-
return Object.keys(
|
|
677
|
+
function Vn(t = {}) {
|
|
678
|
+
return Object.keys(t).length === 0 && t.constructor === Object;
|
|
679
679
|
}
|
|
680
|
-
function L(
|
|
681
|
-
const
|
|
680
|
+
function L(t) {
|
|
681
|
+
const e = t.filter((o) => o.type === "extension"), n = t.filter((o) => o.type === "node"), r = t.filter((o) => o.type === "mark");
|
|
682
682
|
return {
|
|
683
|
-
baseExtensions:
|
|
683
|
+
baseExtensions: e,
|
|
684
684
|
nodeExtensions: n,
|
|
685
685
|
markExtensions: r
|
|
686
686
|
};
|
|
687
687
|
}
|
|
688
|
-
function Wt(
|
|
689
|
-
const
|
|
688
|
+
function Wt(t) {
|
|
689
|
+
const e = [], { nodeExtensions: n, markExtensions: r } = L(t), o = [...n, ...r], s = {
|
|
690
690
|
default: null,
|
|
691
691
|
validate: void 0,
|
|
692
692
|
rendered: !0,
|
|
@@ -695,7 +695,7 @@ function Wt(e) {
|
|
|
695
695
|
keepOnSplit: !0,
|
|
696
696
|
isRequired: !1
|
|
697
697
|
};
|
|
698
|
-
return
|
|
698
|
+
return t.forEach((i) => {
|
|
699
699
|
const c = {
|
|
700
700
|
name: i.name,
|
|
701
701
|
options: i.options,
|
|
@@ -711,7 +711,7 @@ function Wt(e) {
|
|
|
711
711
|
a().forEach((u) => {
|
|
712
712
|
u.types.forEach((d) => {
|
|
713
713
|
Object.entries(u.attributes).forEach(([f, p]) => {
|
|
714
|
-
|
|
714
|
+
e.push({
|
|
715
715
|
type: d,
|
|
716
716
|
name: f,
|
|
717
717
|
attribute: {
|
|
@@ -740,17 +740,17 @@ function Wt(e) {
|
|
|
740
740
|
...s,
|
|
741
741
|
...d
|
|
742
742
|
};
|
|
743
|
-
typeof f?.default == "function" && (f.default = f.default()), f?.isRequired && f?.default === void 0 && delete f.default,
|
|
743
|
+
typeof f?.default == "function" && (f.default = f.default()), f?.isRequired && f?.default === void 0 && delete f.default, e.push({
|
|
744
744
|
type: i.name,
|
|
745
745
|
name: u,
|
|
746
746
|
attribute: f
|
|
747
747
|
});
|
|
748
748
|
});
|
|
749
|
-
}),
|
|
749
|
+
}), e;
|
|
750
750
|
}
|
|
751
|
-
function Hn(...
|
|
752
|
-
return
|
|
753
|
-
const r = { ...
|
|
751
|
+
function Hn(...t) {
|
|
752
|
+
return t.filter((e) => !!e).reduce((e, n) => {
|
|
753
|
+
const r = { ...e };
|
|
754
754
|
return Object.entries(n).forEach(([o, s]) => {
|
|
755
755
|
if (!r[o]) {
|
|
756
756
|
r[o] = s;
|
|
@@ -773,22 +773,22 @@ function Hn(...e) {
|
|
|
773
773
|
}), r;
|
|
774
774
|
}, {});
|
|
775
775
|
}
|
|
776
|
-
function Y(
|
|
777
|
-
return
|
|
778
|
-
[n.name]:
|
|
776
|
+
function Y(t, e) {
|
|
777
|
+
return e.filter((n) => n.type === t.type.name).filter((n) => n.attribute.rendered).map((n) => n.attribute.renderHTML ? n.attribute.renderHTML(t.attrs) || {} : {
|
|
778
|
+
[n.name]: t.attrs[n.name]
|
|
779
779
|
}).reduce((n, r) => Hn(n, r), {});
|
|
780
780
|
}
|
|
781
|
-
function Un(
|
|
782
|
-
return typeof
|
|
781
|
+
function Un(t) {
|
|
782
|
+
return typeof t != "string" ? t : t.match(/^[+-]?(?:\d*\.)?\d+$/) ? Number(t) : t === "true" ? !0 : t === "false" ? !1 : t;
|
|
783
783
|
}
|
|
784
|
-
function
|
|
785
|
-
return "style" in
|
|
786
|
-
...
|
|
784
|
+
function Pt(t, e) {
|
|
785
|
+
return "style" in t ? t : {
|
|
786
|
+
...t,
|
|
787
787
|
getAttrs: (n) => {
|
|
788
|
-
const r =
|
|
788
|
+
const r = t.getAttrs ? t.getAttrs(n) : t.attrs;
|
|
789
789
|
if (r === !1)
|
|
790
790
|
return !1;
|
|
791
|
-
const o =
|
|
791
|
+
const o = e.reduce((s, i) => {
|
|
792
792
|
const c = i.attribute.parseHTML ? i.attribute.parseHTML(n) : Un(n.getAttribute(i.name));
|
|
793
793
|
return c == null ? s : {
|
|
794
794
|
...s,
|
|
@@ -799,33 +799,33 @@ function Ct(e, t) {
|
|
|
799
799
|
}
|
|
800
800
|
};
|
|
801
801
|
}
|
|
802
|
-
function
|
|
802
|
+
function $t(t) {
|
|
803
803
|
return Object.fromEntries(
|
|
804
804
|
// @ts-ignore
|
|
805
|
-
Object.entries(
|
|
805
|
+
Object.entries(t).filter(([e, n]) => e === "attrs" && Vn(n) ? !1 : n != null)
|
|
806
806
|
);
|
|
807
807
|
}
|
|
808
|
-
function
|
|
809
|
-
var
|
|
808
|
+
function Nt(t) {
|
|
809
|
+
var e, n;
|
|
810
810
|
const r = {};
|
|
811
|
-
return !((
|
|
811
|
+
return !((e = t?.attribute) != null && e.isRequired) && "default" in (t?.attribute || {}) && (r.default = t.attribute.default), ((n = t?.attribute) == null ? void 0 : n.validate) !== void 0 && (r.validate = t.attribute.validate), [t.name, r];
|
|
812
812
|
}
|
|
813
|
-
function Wn(
|
|
813
|
+
function Wn(t, e) {
|
|
814
814
|
var n;
|
|
815
|
-
const r = Wt(
|
|
815
|
+
const r = Wt(t), { nodeExtensions: o, markExtensions: s } = L(t), i = (n = o.find((l) => b(l, "topNode"))) == null ? void 0 : n.name, c = Object.fromEntries(
|
|
816
816
|
o.map((l) => {
|
|
817
817
|
const u = r.filter((v) => v.type === l.name), d = {
|
|
818
818
|
name: l.name,
|
|
819
819
|
options: l.options,
|
|
820
820
|
storage: l.storage,
|
|
821
|
-
editor:
|
|
822
|
-
}, f =
|
|
821
|
+
editor: e
|
|
822
|
+
}, f = t.reduce((v, k) => {
|
|
823
823
|
const w = b(k, "extendNodeSchema", d);
|
|
824
824
|
return {
|
|
825
825
|
...v,
|
|
826
826
|
...w ? w(l) : {}
|
|
827
827
|
};
|
|
828
|
-
}, {}), p =
|
|
828
|
+
}, {}), p = $t({
|
|
829
829
|
...f,
|
|
830
830
|
content: x(b(l, "content", d)),
|
|
831
831
|
marks: x(b(l, "marks", d)),
|
|
@@ -841,10 +841,10 @@ function Wn(e, t) {
|
|
|
841
841
|
),
|
|
842
842
|
defining: x(b(l, "defining", d)),
|
|
843
843
|
isolating: x(b(l, "isolating", d)),
|
|
844
|
-
attrs: Object.fromEntries(u.map(
|
|
844
|
+
attrs: Object.fromEntries(u.map(Nt))
|
|
845
845
|
}), m = x(b(l, "parseHTML", d));
|
|
846
846
|
m && (p.parseDOM = m.map(
|
|
847
|
-
(v) =>
|
|
847
|
+
(v) => Pt(v, u)
|
|
848
848
|
));
|
|
849
849
|
const h = b(l, "renderHTML", d);
|
|
850
850
|
h && (p.toDOM = (v) => h({
|
|
@@ -860,24 +860,24 @@ function Wn(e, t) {
|
|
|
860
860
|
name: l.name,
|
|
861
861
|
options: l.options,
|
|
862
862
|
storage: l.storage,
|
|
863
|
-
editor:
|
|
864
|
-
}, f =
|
|
863
|
+
editor: e
|
|
864
|
+
}, f = t.reduce((g, v) => {
|
|
865
865
|
const k = b(v, "extendMarkSchema", d);
|
|
866
866
|
return {
|
|
867
867
|
...g,
|
|
868
868
|
...k ? k(l) : {}
|
|
869
869
|
};
|
|
870
|
-
}, {}), p =
|
|
870
|
+
}, {}), p = $t({
|
|
871
871
|
...f,
|
|
872
872
|
inclusive: x(b(l, "inclusive", d)),
|
|
873
873
|
excludes: x(b(l, "excludes", d)),
|
|
874
874
|
group: x(b(l, "group", d)),
|
|
875
875
|
spanning: x(b(l, "spanning", d)),
|
|
876
876
|
code: x(b(l, "code", d)),
|
|
877
|
-
attrs: Object.fromEntries(u.map(
|
|
877
|
+
attrs: Object.fromEntries(u.map(Nt))
|
|
878
878
|
}), m = x(b(l, "parseHTML", d));
|
|
879
879
|
m && (p.parseDOM = m.map(
|
|
880
|
-
(g) =>
|
|
880
|
+
(g) => Pt(g, u)
|
|
881
881
|
));
|
|
882
882
|
const h = b(l, "renderHTML", d);
|
|
883
883
|
return h && (p.toDOM = (g) => h({
|
|
@@ -892,28 +892,28 @@ function Wn(e, t) {
|
|
|
892
892
|
marks: a
|
|
893
893
|
});
|
|
894
894
|
}
|
|
895
|
-
function qn(
|
|
896
|
-
const
|
|
897
|
-
return Array.from(new Set(
|
|
895
|
+
function qn(t) {
|
|
896
|
+
const e = t.filter((n, r) => t.indexOf(n) !== r);
|
|
897
|
+
return Array.from(new Set(e));
|
|
898
898
|
}
|
|
899
|
-
function
|
|
900
|
-
return
|
|
899
|
+
function yt(t) {
|
|
900
|
+
return t.sort((n, r) => {
|
|
901
901
|
const o = b(n, "priority") || 100, s = b(r, "priority") || 100;
|
|
902
902
|
return o > s ? -1 : o < s ? 1 : 0;
|
|
903
903
|
});
|
|
904
904
|
}
|
|
905
|
-
function qt(
|
|
906
|
-
const
|
|
905
|
+
function qt(t) {
|
|
906
|
+
const e = yt(bt(t)), n = qn(e.map((r) => r.name));
|
|
907
907
|
return n.length && console.warn(
|
|
908
908
|
`[tiptap warn]: Duplicate extension names found: [${n.map((r) => `'${r}'`).join(", ")}]. This can lead to issues.`
|
|
909
|
-
),
|
|
909
|
+
), e;
|
|
910
910
|
}
|
|
911
|
-
function Kt(
|
|
912
|
-
const { from: r, to: o } =
|
|
911
|
+
function Kt(t, e, n) {
|
|
912
|
+
const { from: r, to: o } = e, { blockSeparator: s = `
|
|
913
913
|
|
|
914
914
|
`, textSerializers: i = {} } = n || {};
|
|
915
915
|
let c = "";
|
|
916
|
-
return
|
|
916
|
+
return t.nodesBetween(r, o, (a, l, u, d) => {
|
|
917
917
|
var f;
|
|
918
918
|
a.isBlock && l > r && (c += s);
|
|
919
919
|
const p = i?.[a.type.name];
|
|
@@ -923,52 +923,52 @@ function Kt(e, t, n) {
|
|
|
923
923
|
pos: l,
|
|
924
924
|
parent: u,
|
|
925
925
|
index: d,
|
|
926
|
-
range:
|
|
926
|
+
range: e
|
|
927
927
|
})), !1;
|
|
928
928
|
a.isText && (c += (f = a?.text) == null ? void 0 : f.slice(Math.max(r, l) - l, o - l));
|
|
929
929
|
}), c;
|
|
930
930
|
}
|
|
931
|
-
function Kn(
|
|
931
|
+
function Kn(t, e) {
|
|
932
932
|
const n = {
|
|
933
933
|
from: 0,
|
|
934
|
-
to:
|
|
934
|
+
to: t.content.size
|
|
935
935
|
};
|
|
936
|
-
return Kt(
|
|
936
|
+
return Kt(t, n, e);
|
|
937
937
|
}
|
|
938
|
-
function Jt(
|
|
938
|
+
function Jt(t) {
|
|
939
939
|
return Object.fromEntries(
|
|
940
|
-
Object.entries(
|
|
940
|
+
Object.entries(t.nodes).filter(([, e]) => e.spec.toText).map(([e, n]) => [e, n.spec.toText])
|
|
941
941
|
);
|
|
942
942
|
}
|
|
943
|
-
function Jn(
|
|
944
|
-
const n = T(
|
|
945
|
-
|
|
943
|
+
function Jn(t, e) {
|
|
944
|
+
const n = T(e, t.schema), { from: r, to: o } = t.selection, s = [];
|
|
945
|
+
t.doc.nodesBetween(r, o, (c) => {
|
|
946
946
|
s.push(c);
|
|
947
947
|
});
|
|
948
948
|
const i = s.reverse().find((c) => c.type.name === n.name);
|
|
949
949
|
return i ? { ...i.attrs } : {};
|
|
950
950
|
}
|
|
951
|
-
function Zn(
|
|
951
|
+
function Zn(t, e) {
|
|
952
952
|
const n = et(
|
|
953
|
-
typeof
|
|
954
|
-
|
|
953
|
+
typeof e == "string" ? e : e.name,
|
|
954
|
+
t.schema
|
|
955
955
|
);
|
|
956
|
-
return n === "node" ? Jn(
|
|
956
|
+
return n === "node" ? Jn(t, e) : n === "mark" ? Ht(t, e) : {};
|
|
957
957
|
}
|
|
958
|
-
function Qn(
|
|
958
|
+
function Qn(t, e = JSON.stringify) {
|
|
959
959
|
const n = {};
|
|
960
|
-
return
|
|
961
|
-
const o =
|
|
960
|
+
return t.filter((r) => {
|
|
961
|
+
const o = e(r);
|
|
962
962
|
return Object.prototype.hasOwnProperty.call(n, o) ? !1 : n[o] = !0;
|
|
963
963
|
});
|
|
964
964
|
}
|
|
965
|
-
function Gn(
|
|
966
|
-
const
|
|
967
|
-
return
|
|
965
|
+
function Gn(t) {
|
|
966
|
+
const e = Qn(t);
|
|
967
|
+
return e.length === 1 ? e : e.filter((n, r) => !e.filter((s, i) => i !== r).some((s) => n.oldRange.from >= s.oldRange.from && n.oldRange.to <= s.oldRange.to && n.newRange.from >= s.newRange.from && n.newRange.to <= s.newRange.to));
|
|
968
968
|
}
|
|
969
|
-
function Yn(
|
|
970
|
-
const { mapping:
|
|
971
|
-
return
|
|
969
|
+
function Yn(t) {
|
|
970
|
+
const { mapping: e, steps: n } = t, r = [];
|
|
971
|
+
return e.maps.forEach((o, s) => {
|
|
972
972
|
const i = [];
|
|
973
973
|
if (o.ranges.length)
|
|
974
974
|
o.forEach((c, a) => {
|
|
@@ -981,7 +981,7 @@ function Yn(e) {
|
|
|
981
981
|
i.push({ from: c, to: a });
|
|
982
982
|
}
|
|
983
983
|
i.forEach(({ from: c, to: a }) => {
|
|
984
|
-
const l =
|
|
984
|
+
const l = e.slice(s).map(c, -1), u = e.slice(s).map(a), d = e.invert().map(l, -1), f = e.invert().map(u);
|
|
985
985
|
r.push({
|
|
986
986
|
oldRange: {
|
|
987
987
|
from: d,
|
|
@@ -995,15 +995,15 @@ function Yn(e) {
|
|
|
995
995
|
});
|
|
996
996
|
}), Gn(r);
|
|
997
997
|
}
|
|
998
|
-
function Zt(
|
|
998
|
+
function Zt(t, e, n) {
|
|
999
999
|
const r = [];
|
|
1000
|
-
return
|
|
1001
|
-
const s = n.resolve(
|
|
1000
|
+
return t === e ? n.resolve(t).marks().forEach((o) => {
|
|
1001
|
+
const s = n.resolve(t), i = gt(s, o.type);
|
|
1002
1002
|
i && r.push({
|
|
1003
1003
|
mark: o,
|
|
1004
1004
|
...i
|
|
1005
1005
|
});
|
|
1006
|
-
}) : n.nodesBetween(
|
|
1006
|
+
}) : n.nodesBetween(t, e, (o, s) => {
|
|
1007
1007
|
!o || o?.nodeSize === void 0 || r.push(
|
|
1008
1008
|
...o.marks.map((i) => ({
|
|
1009
1009
|
from: s,
|
|
@@ -1013,30 +1013,30 @@ function Zt(e, t, n) {
|
|
|
1013
1013
|
);
|
|
1014
1014
|
}), r;
|
|
1015
1015
|
}
|
|
1016
|
-
var no = (
|
|
1017
|
-
const o =
|
|
1016
|
+
var no = (t, e, n, r = 20) => {
|
|
1017
|
+
const o = t.doc.resolve(n);
|
|
1018
1018
|
let s = r, i = null;
|
|
1019
1019
|
for (; s > 0 && i === null; ) {
|
|
1020
1020
|
const c = o.node(s);
|
|
1021
|
-
c?.type.name ===
|
|
1021
|
+
c?.type.name === e ? i = c : s -= 1;
|
|
1022
1022
|
}
|
|
1023
1023
|
return [i, s];
|
|
1024
1024
|
};
|
|
1025
|
-
function at(
|
|
1026
|
-
return
|
|
1025
|
+
function at(t, e) {
|
|
1026
|
+
return e.nodes[t] || e.marks[t] || null;
|
|
1027
1027
|
}
|
|
1028
|
-
function Q(
|
|
1028
|
+
function Q(t, e, n) {
|
|
1029
1029
|
return Object.fromEntries(
|
|
1030
1030
|
Object.entries(n).filter(([r]) => {
|
|
1031
|
-
const o =
|
|
1031
|
+
const o = t.find((s) => s.type === e && s.name === r);
|
|
1032
1032
|
return o ? o.attribute.keepOnSplit : !1;
|
|
1033
1033
|
})
|
|
1034
1034
|
);
|
|
1035
1035
|
}
|
|
1036
|
-
var Xn = (
|
|
1036
|
+
var Xn = (t, e = 500) => {
|
|
1037
1037
|
let n = "";
|
|
1038
|
-
const r =
|
|
1039
|
-
return
|
|
1038
|
+
const r = t.parentOffset;
|
|
1039
|
+
return t.parent.nodesBetween(Math.max(0, r - e), r, (o, s, i, c) => {
|
|
1040
1040
|
var a, l;
|
|
1041
1041
|
const u = ((l = (a = o.type.spec).toText) == null ? void 0 : l.call(a, {
|
|
1042
1042
|
node: o,
|
|
@@ -1047,15 +1047,15 @@ var Xn = (e, t = 500) => {
|
|
|
1047
1047
|
n += o.isAtom && !o.isText ? u : u.slice(0, Math.max(0, r - s));
|
|
1048
1048
|
}), n;
|
|
1049
1049
|
};
|
|
1050
|
-
function ut(
|
|
1051
|
-
const { empty: r, ranges: o } =
|
|
1050
|
+
function ut(t, e, n = {}) {
|
|
1051
|
+
const { empty: r, ranges: o } = t.selection, s = e ? B(e, t.schema) : null;
|
|
1052
1052
|
if (r)
|
|
1053
|
-
return !!(
|
|
1053
|
+
return !!(t.storedMarks || t.selection.$from.marks()).filter((d) => s ? s.name === d.type.name : !0).find((d) => G(d.attrs, n, { strict: !1 }));
|
|
1054
1054
|
let i = 0;
|
|
1055
1055
|
const c = [];
|
|
1056
1056
|
if (o.forEach(({ $from: d, $to: f }) => {
|
|
1057
1057
|
const p = d.pos, m = f.pos;
|
|
1058
|
-
|
|
1058
|
+
t.doc.nodesBetween(p, m, (h, g) => {
|
|
1059
1059
|
if (!h.isText && !h.marks.length)
|
|
1060
1060
|
return;
|
|
1061
1061
|
const v = Math.max(p, g), k = Math.min(m, g + h.nodeSize), w = k - v;
|
|
@@ -1072,31 +1072,31 @@ function ut(e, t, n = {}) {
|
|
|
1072
1072
|
const a = c.filter((d) => s ? s.name === d.mark.type.name : !0).filter((d) => G(d.mark.attrs, n, { strict: !1 })).reduce((d, f) => d + f.to - f.from, 0), l = c.filter((d) => s ? d.mark.type !== s && d.mark.type.excludes(s) : !0).reduce((d, f) => d + f.to - f.from, 0);
|
|
1073
1073
|
return (a > 0 ? a + l : a) >= i;
|
|
1074
1074
|
}
|
|
1075
|
-
function tr(
|
|
1076
|
-
if (!
|
|
1077
|
-
return H(
|
|
1078
|
-
const r = et(
|
|
1079
|
-
return r === "node" ? H(
|
|
1075
|
+
function tr(t, e, n = {}) {
|
|
1076
|
+
if (!e)
|
|
1077
|
+
return H(t, null, n) || ut(t, null, n);
|
|
1078
|
+
const r = et(e, t.schema);
|
|
1079
|
+
return r === "node" ? H(t, e, n) : r === "mark" ? ut(t, e, n) : !1;
|
|
1080
1080
|
}
|
|
1081
|
-
var ro = (
|
|
1082
|
-
const { $from: n, $to: r, $anchor: o } =
|
|
1083
|
-
if (
|
|
1084
|
-
const s = nt((c) => c.type.name ===
|
|
1081
|
+
var ro = (t, e) => {
|
|
1082
|
+
const { $from: n, $to: r, $anchor: o } = t.selection;
|
|
1083
|
+
if (e) {
|
|
1084
|
+
const s = nt((c) => c.type.name === e)(t.selection);
|
|
1085
1085
|
if (!s)
|
|
1086
1086
|
return !1;
|
|
1087
|
-
const i =
|
|
1087
|
+
const i = t.doc.resolve(s.pos + 1);
|
|
1088
1088
|
return o.pos + 1 === i.end();
|
|
1089
1089
|
}
|
|
1090
1090
|
return !(r.parentOffset < r.parent.nodeSize - 2 || n.pos !== r.pos);
|
|
1091
|
-
}, oo = (
|
|
1092
|
-
const { $from:
|
|
1093
|
-
return !(
|
|
1091
|
+
}, oo = (t) => {
|
|
1092
|
+
const { $from: e, $to: n } = t.selection;
|
|
1093
|
+
return !(e.parentOffset > 0 || e.pos !== n.pos);
|
|
1094
1094
|
};
|
|
1095
|
-
function
|
|
1096
|
-
return Array.isArray(
|
|
1095
|
+
function It(t, e) {
|
|
1096
|
+
return Array.isArray(e) ? e.some((n) => (typeof n == "string" ? n : n.name) === t.name) : e;
|
|
1097
1097
|
}
|
|
1098
|
-
function
|
|
1099
|
-
const { nodeExtensions: n } = L(
|
|
1098
|
+
function Bt(t, e) {
|
|
1099
|
+
const { nodeExtensions: n } = L(e), r = n.find((i) => i.name === t);
|
|
1100
1100
|
if (!r)
|
|
1101
1101
|
return !1;
|
|
1102
1102
|
const o = {
|
|
@@ -1106,40 +1106,43 @@ function It(e, t) {
|
|
|
1106
1106
|
}, s = x(b(r, "group", o));
|
|
1107
1107
|
return typeof s != "string" ? !1 : s.split(" ").includes("list");
|
|
1108
1108
|
}
|
|
1109
|
-
function
|
|
1110
|
-
checkChildren:
|
|
1109
|
+
function wt(t, {
|
|
1110
|
+
checkChildren: e = !0,
|
|
1111
1111
|
ignoreWhitespace: n = !1
|
|
1112
1112
|
} = {}) {
|
|
1113
1113
|
var r;
|
|
1114
1114
|
if (n) {
|
|
1115
|
-
if (
|
|
1115
|
+
if (t.type.name === "hardBreak")
|
|
1116
1116
|
return !0;
|
|
1117
|
-
if (
|
|
1118
|
-
return /^\s*$/m.test((r =
|
|
1117
|
+
if (t.isText)
|
|
1118
|
+
return /^\s*$/m.test((r = t.text) != null ? r : "");
|
|
1119
1119
|
}
|
|
1120
|
-
if (
|
|
1121
|
-
return !
|
|
1122
|
-
if (
|
|
1120
|
+
if (t.isText)
|
|
1121
|
+
return !t.text;
|
|
1122
|
+
if (t.isAtom || t.isLeaf)
|
|
1123
1123
|
return !1;
|
|
1124
|
-
if (
|
|
1124
|
+
if (t.content.childCount === 0)
|
|
1125
1125
|
return !0;
|
|
1126
|
-
if (
|
|
1126
|
+
if (e) {
|
|
1127
1127
|
let o = !0;
|
|
1128
|
-
return
|
|
1129
|
-
o !== !1 && (
|
|
1128
|
+
return t.content.forEach((s) => {
|
|
1129
|
+
o !== !1 && (wt(s, { ignoreWhitespace: n, checkChildren: e }) || (o = !1));
|
|
1130
1130
|
}), o;
|
|
1131
1131
|
}
|
|
1132
1132
|
return !1;
|
|
1133
1133
|
}
|
|
1134
|
+
function so(t) {
|
|
1135
|
+
return t instanceof pt;
|
|
1136
|
+
}
|
|
1134
1137
|
var Qt = class Gt {
|
|
1135
|
-
constructor(
|
|
1136
|
-
this.position =
|
|
1138
|
+
constructor(e) {
|
|
1139
|
+
this.position = e;
|
|
1137
1140
|
}
|
|
1138
1141
|
/**
|
|
1139
1142
|
* Creates a MappablePosition from a JSON object.
|
|
1140
1143
|
*/
|
|
1141
|
-
static fromJSON(
|
|
1142
|
-
return new Gt(
|
|
1144
|
+
static fromJSON(e) {
|
|
1145
|
+
return new Gt(e.position);
|
|
1143
1146
|
}
|
|
1144
1147
|
/**
|
|
1145
1148
|
* Converts the MappablePosition to a JSON object.
|
|
@@ -1150,28 +1153,28 @@ var Qt = class Gt {
|
|
|
1150
1153
|
};
|
|
1151
1154
|
}
|
|
1152
1155
|
};
|
|
1153
|
-
function er(
|
|
1154
|
-
const n =
|
|
1156
|
+
function er(t, e) {
|
|
1157
|
+
const n = e.mapping.mapResult(t.position);
|
|
1155
1158
|
return {
|
|
1156
1159
|
position: new Qt(n.pos),
|
|
1157
1160
|
mapResult: n
|
|
1158
1161
|
};
|
|
1159
1162
|
}
|
|
1160
|
-
function nr(
|
|
1161
|
-
return new Qt(
|
|
1163
|
+
function nr(t) {
|
|
1164
|
+
return new Qt(t);
|
|
1162
1165
|
}
|
|
1163
|
-
function rr(
|
|
1166
|
+
function rr(t, e, n) {
|
|
1164
1167
|
var r;
|
|
1165
|
-
const { selection: o } =
|
|
1168
|
+
const { selection: o } = e;
|
|
1166
1169
|
let s = null;
|
|
1167
1170
|
if (zt(o) && (s = o.$cursor), s) {
|
|
1168
|
-
const c = (r =
|
|
1171
|
+
const c = (r = t.storedMarks) != null ? r : s.marks();
|
|
1169
1172
|
return s.parent.type.allowsMarkType(n) && (!!n.isInSet(c) || !c.some((l) => l.type.excludes(n)));
|
|
1170
1173
|
}
|
|
1171
1174
|
const { ranges: i } = o;
|
|
1172
1175
|
return i.some(({ $from: c, $to: a }) => {
|
|
1173
|
-
let l = c.depth === 0 ?
|
|
1174
|
-
return
|
|
1176
|
+
let l = c.depth === 0 ? t.doc.inlineContent && t.doc.type.allowsMarkType(n) : !1;
|
|
1177
|
+
return t.doc.nodesBetween(c.pos, a.pos, (u, d, f) => {
|
|
1175
1178
|
if (l)
|
|
1176
1179
|
return !1;
|
|
1177
1180
|
if (u.isInline) {
|
|
@@ -1182,15 +1185,15 @@ function rr(e, t, n) {
|
|
|
1182
1185
|
}), l;
|
|
1183
1186
|
});
|
|
1184
1187
|
}
|
|
1185
|
-
var or = (
|
|
1186
|
-
const { selection: s } = n, { empty: i, ranges: c } = s, a = B(
|
|
1188
|
+
var or = (t, e = {}) => ({ tr: n, state: r, dispatch: o }) => {
|
|
1189
|
+
const { selection: s } = n, { empty: i, ranges: c } = s, a = B(t, r.schema);
|
|
1187
1190
|
if (o)
|
|
1188
1191
|
if (i) {
|
|
1189
1192
|
const l = Ht(r, a);
|
|
1190
1193
|
n.addStoredMark(
|
|
1191
1194
|
a.create({
|
|
1192
1195
|
...l,
|
|
1193
|
-
...
|
|
1196
|
+
...e
|
|
1194
1197
|
})
|
|
1195
1198
|
);
|
|
1196
1199
|
} else
|
|
@@ -1204,53 +1207,53 @@ var or = (e, t = {}) => ({ tr: n, state: r, dispatch: o }) => {
|
|
|
1204
1207
|
h,
|
|
1205
1208
|
a.create({
|
|
1206
1209
|
...v.attrs,
|
|
1207
|
-
...
|
|
1210
|
+
...e
|
|
1208
1211
|
})
|
|
1209
1212
|
);
|
|
1210
|
-
}) : n.addMark(m, h, a.create(
|
|
1213
|
+
}) : n.addMark(m, h, a.create(e));
|
|
1211
1214
|
});
|
|
1212
1215
|
});
|
|
1213
1216
|
return rr(r, n, a);
|
|
1214
|
-
}, sr = (
|
|
1215
|
-
const s = T(
|
|
1217
|
+
}, sr = (t, e) => ({ tr: n }) => (n.setMeta(t, e), !0), ir = (t, e = {}) => ({ state: n, dispatch: r, chain: o }) => {
|
|
1218
|
+
const s = T(t, n.schema);
|
|
1216
1219
|
let i;
|
|
1217
|
-
return n.selection.$anchor.sameParent(n.selection.$head) && (i = n.selection.$anchor.parent.attrs), s.isTextblock ? o().command(({ commands: c }) =>
|
|
1218
|
-
}, ar = (
|
|
1220
|
+
return n.selection.$anchor.sameParent(n.selection.$head) && (i = n.selection.$anchor.parent.attrs), s.isTextblock ? o().command(({ commands: c }) => Tt(s, { ...i, ...e })(n) ? !0 : c.clearNodes()).command(({ state: c }) => Tt(s, { ...i, ...e })(c, r)).run() : (console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'), !1);
|
|
1221
|
+
}, ar = (t) => ({ tr: e, dispatch: n }) => {
|
|
1219
1222
|
if (n) {
|
|
1220
|
-
const { doc: r } =
|
|
1221
|
-
|
|
1223
|
+
const { doc: r } = e, o = _(t, 0, r.content.size), s = pt.create(r, o);
|
|
1224
|
+
e.setSelection(s);
|
|
1222
1225
|
}
|
|
1223
1226
|
return !0;
|
|
1224
|
-
}, cr = (
|
|
1227
|
+
}, cr = (t, e) => ({ tr: n, state: r, dispatch: o }) => {
|
|
1225
1228
|
const { selection: s } = r;
|
|
1226
1229
|
let i, c;
|
|
1227
|
-
return typeof
|
|
1230
|
+
return typeof e == "number" ? (i = e, c = e) : e && "from" in e && "to" in e ? (i = e.from, c = e.to) : (i = s.from, c = s.to), o && n.doc.nodesBetween(i, c, (a, l) => {
|
|
1228
1231
|
a.isText || n.setNodeMarkup(l, void 0, {
|
|
1229
1232
|
...a.attrs,
|
|
1230
|
-
dir:
|
|
1233
|
+
dir: t
|
|
1231
1234
|
});
|
|
1232
1235
|
}), !0;
|
|
1233
|
-
}, lr = (
|
|
1236
|
+
}, lr = (t) => ({ tr: e, dispatch: n }) => {
|
|
1234
1237
|
if (n) {
|
|
1235
|
-
const { doc: r } =
|
|
1236
|
-
|
|
1238
|
+
const { doc: r } = e, { from: o, to: s } = typeof t == "number" ? { from: t, to: t } : t, i = P.atStart(r).from, c = P.atEnd(r).to, a = _(o, i, c), l = _(s, i, c), u = P.create(r, a, l);
|
|
1239
|
+
e.setSelection(u);
|
|
1237
1240
|
}
|
|
1238
1241
|
return !0;
|
|
1239
|
-
}, dr = (
|
|
1240
|
-
const r = T(
|
|
1241
|
-
return He(r)(
|
|
1242
|
+
}, dr = (t) => ({ state: e, dispatch: n }) => {
|
|
1243
|
+
const r = T(t, e.schema);
|
|
1244
|
+
return He(r)(e, n);
|
|
1242
1245
|
};
|
|
1243
|
-
function
|
|
1244
|
-
const n =
|
|
1246
|
+
function Rt(t, e) {
|
|
1247
|
+
const n = t.storedMarks || t.selection.$to.parentOffset && t.selection.$from.marks();
|
|
1245
1248
|
if (n) {
|
|
1246
|
-
const r = n.filter((o) =>
|
|
1247
|
-
|
|
1249
|
+
const r = n.filter((o) => e?.includes(o.type.name));
|
|
1250
|
+
t.tr.ensureMarks(r);
|
|
1248
1251
|
}
|
|
1249
1252
|
}
|
|
1250
|
-
var ur = ({ keepMarks:
|
|
1251
|
-
const { selection: s, doc: i } =
|
|
1252
|
-
if (s instanceof
|
|
1253
|
-
return !c.parentOffset || !Z(i, c.pos) ? !1 : (r && (
|
|
1253
|
+
var ur = ({ keepMarks: t = !0 } = {}) => ({ tr: e, state: n, dispatch: r, editor: o }) => {
|
|
1254
|
+
const { selection: s, doc: i } = e, { $from: c, $to: a } = s, l = o.extensionManager.attributes, u = Q(l, c.node().type.name, c.node().attrs);
|
|
1255
|
+
if (s instanceof pt && s.node.isBlock)
|
|
1256
|
+
return !c.parentOffset || !Z(i, c.pos) ? !1 : (r && (t && Rt(n, o.extensionManager.splittableMarks), e.split(c.pos).scrollIntoView()), !0);
|
|
1254
1257
|
if (!c.parent.isBlock)
|
|
1255
1258
|
return !1;
|
|
1256
1259
|
const d = a.parentOffset === a.parent.content.size, f = c.depth === 0 ? void 0 : Fn(c.node(-1).contentMatchAt(c.indexAfter(-1)));
|
|
@@ -1259,23 +1262,23 @@ var ur = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
|
|
|
1259
1262
|
type: f,
|
|
1260
1263
|
attrs: u
|
|
1261
1264
|
}
|
|
1262
|
-
] : void 0, m = Z(
|
|
1263
|
-
if (!p && !m && Z(
|
|
1265
|
+
] : void 0, m = Z(e.doc, e.mapping.map(c.pos), 1, p);
|
|
1266
|
+
if (!p && !m && Z(e.doc, e.mapping.map(c.pos), 1, f ? [{ type: f }] : void 0) && (m = !0, p = f ? [
|
|
1264
1267
|
{
|
|
1265
1268
|
type: f,
|
|
1266
1269
|
attrs: u
|
|
1267
1270
|
}
|
|
1268
1271
|
] : void 0), r) {
|
|
1269
|
-
if (m && (s instanceof P &&
|
|
1270
|
-
const h =
|
|
1271
|
-
c.node(-1).canReplaceWith(g.index(), g.index() + 1, f) &&
|
|
1272
|
+
if (m && (s instanceof P && e.deleteSelection(), e.split(e.mapping.map(c.pos), 1, p), f && !d && !c.parentOffset && c.parent.type !== f)) {
|
|
1273
|
+
const h = e.mapping.map(c.before()), g = e.doc.resolve(h);
|
|
1274
|
+
c.node(-1).canReplaceWith(g.index(), g.index() + 1, f) && e.setNodeMarkup(e.mapping.map(c.before()), f);
|
|
1272
1275
|
}
|
|
1273
|
-
|
|
1276
|
+
t && Rt(n, o.extensionManager.splittableMarks), e.scrollIntoView();
|
|
1274
1277
|
}
|
|
1275
1278
|
return m;
|
|
1276
|
-
}, fr = (
|
|
1279
|
+
}, fr = (t, e = {}) => ({ tr: n, state: r, dispatch: o, editor: s }) => {
|
|
1277
1280
|
var i;
|
|
1278
|
-
const c = T(
|
|
1281
|
+
const c = T(t, r.schema), { $from: a, $to: l } = r.selection, u = r.selection.node;
|
|
1279
1282
|
if (u && u.isBlock || a.depth < 2 || !a.sameParent(l))
|
|
1280
1283
|
return !1;
|
|
1281
1284
|
const d = a.node(-1);
|
|
@@ -1295,7 +1298,7 @@ var ur = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
|
|
|
1295
1298
|
a.indexAfter(-1) < a.node(-2).childCount ? 1 : a.indexAfter(-2) < a.node(-3).childCount ? 2 : 3
|
|
1296
1299
|
), M = {
|
|
1297
1300
|
...Q(f, a.node().type.name, a.node().attrs),
|
|
1298
|
-
...
|
|
1301
|
+
...e
|
|
1299
1302
|
}, y = ((i = c.contentMatch.defaultType) == null ? void 0 : i.createAndFill(M)) || void 0;
|
|
1300
1303
|
v = v.append(j.from(c.createAndFill(null, y) || void 0));
|
|
1301
1304
|
const S = a.before(a.depth - (k - 1));
|
|
@@ -1311,10 +1314,10 @@ var ur = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
|
|
|
1311
1314
|
}
|
|
1312
1315
|
const p = l.pos === a.end() ? d.contentMatchAt(0).defaultType : null, m = {
|
|
1313
1316
|
...Q(f, d.type.name, d.attrs),
|
|
1314
|
-
...
|
|
1317
|
+
...e
|
|
1315
1318
|
}, h = {
|
|
1316
1319
|
...Q(f, a.node().type.name, a.node().attrs),
|
|
1317
|
-
...
|
|
1320
|
+
...e
|
|
1318
1321
|
};
|
|
1319
1322
|
n.delete(a.pos, l.pos);
|
|
1320
1323
|
const g = p ? [
|
|
@@ -1331,62 +1334,62 @@ var ur = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
|
|
|
1331
1334
|
n.ensureMarks(y);
|
|
1332
1335
|
}
|
|
1333
1336
|
return !0;
|
|
1334
|
-
}, ct = (
|
|
1335
|
-
const n = nt((i) => i.type ===
|
|
1337
|
+
}, ct = (t, e) => {
|
|
1338
|
+
const n = nt((i) => i.type === e)(t.selection);
|
|
1336
1339
|
if (!n)
|
|
1337
1340
|
return !0;
|
|
1338
|
-
const r =
|
|
1341
|
+
const r = t.doc.resolve(Math.max(0, n.pos - 1)).before(n.depth);
|
|
1339
1342
|
if (r === void 0)
|
|
1340
1343
|
return !0;
|
|
1341
|
-
const o =
|
|
1342
|
-
return n.node.type === o?.type && ft(
|
|
1343
|
-
}, lt = (
|
|
1344
|
-
const n = nt((i) => i.type ===
|
|
1344
|
+
const o = t.doc.nodeAt(r);
|
|
1345
|
+
return n.node.type === o?.type && ft(t.doc, n.pos) && t.join(n.pos), !0;
|
|
1346
|
+
}, lt = (t, e) => {
|
|
1347
|
+
const n = nt((i) => i.type === e)(t.selection);
|
|
1345
1348
|
if (!n)
|
|
1346
1349
|
return !0;
|
|
1347
|
-
const r =
|
|
1350
|
+
const r = t.doc.resolve(n.start).after(n.depth);
|
|
1348
1351
|
if (r === void 0)
|
|
1349
1352
|
return !0;
|
|
1350
|
-
const o =
|
|
1351
|
-
return n.node.type === o?.type && ft(
|
|
1352
|
-
}, pr = (
|
|
1353
|
-
const { extensions: d, splittableMarks: f } = o.extensionManager, p = T(
|
|
1353
|
+
const o = t.doc.nodeAt(r);
|
|
1354
|
+
return n.node.type === o?.type && ft(t.doc, r) && t.join(r), !0;
|
|
1355
|
+
}, pr = (t, e, n, r = {}) => ({ editor: o, tr: s, state: i, dispatch: c, chain: a, commands: l, can: u }) => {
|
|
1356
|
+
const { extensions: d, splittableMarks: f } = o.extensionManager, p = T(t, i.schema), m = T(e, i.schema), { selection: h, storedMarks: g } = i, { $from: v, $to: k } = h, w = v.blockRange(k), M = g || h.$to.parentOffset && h.$from.marks();
|
|
1354
1357
|
if (!w)
|
|
1355
1358
|
return !1;
|
|
1356
|
-
const y = nt((S) =>
|
|
1359
|
+
const y = nt((S) => Bt(S.type.name, d))(h);
|
|
1357
1360
|
if (w.depth >= 1 && y && w.depth - y.depth <= 1) {
|
|
1358
1361
|
if (y.node.type === p)
|
|
1359
1362
|
return l.liftListItem(m);
|
|
1360
|
-
if (
|
|
1363
|
+
if (Bt(y.node.type.name, d) && p.validContent(y.node.content) && c)
|
|
1361
1364
|
return a().command(() => (s.setNodeMarkup(y.pos, p), !0)).command(() => ct(s, p)).command(() => lt(s, p)).run();
|
|
1362
1365
|
}
|
|
1363
1366
|
return !n || !M || !c ? a().command(() => u().wrapInList(p, r) ? !0 : l.clearNodes()).wrapInList(p, r).command(() => ct(s, p)).command(() => lt(s, p)).run() : a().command(() => {
|
|
1364
1367
|
const S = u().wrapInList(p, r), E = M.filter((A) => f.includes(A.type.name));
|
|
1365
1368
|
return s.ensureMarks(E), S ? !0 : l.clearNodes();
|
|
1366
1369
|
}).wrapInList(p, r).command(() => ct(s, p)).command(() => lt(s, p)).run();
|
|
1367
|
-
}, mr = (
|
|
1368
|
-
const { extendEmptyMarkRange: s = !1 } = n, i = B(
|
|
1369
|
-
return ut(r, i,
|
|
1370
|
-
}, hr = (
|
|
1371
|
-
const s = T(
|
|
1370
|
+
}, mr = (t, e = {}, n = {}) => ({ state: r, commands: o }) => {
|
|
1371
|
+
const { extendEmptyMarkRange: s = !1 } = n, i = B(t, r.schema);
|
|
1372
|
+
return ut(r, i, e) ? o.unsetMark(i, { extendEmptyMarkRange: s }) : o.setMark(i, e);
|
|
1373
|
+
}, hr = (t, e, n = {}) => ({ state: r, commands: o }) => {
|
|
1374
|
+
const s = T(t, r.schema), i = T(e, r.schema), c = H(r, s, n);
|
|
1372
1375
|
let a;
|
|
1373
1376
|
return r.selection.$anchor.sameParent(r.selection.$head) && (a = r.selection.$anchor.parent.attrs), c ? o.setNode(i, a) : o.setNode(s, { ...a, ...n });
|
|
1374
|
-
}, gr = (
|
|
1375
|
-
const o = T(
|
|
1376
|
-
return H(n, o,
|
|
1377
|
-
}, vr = () => ({ state:
|
|
1378
|
-
const n =
|
|
1377
|
+
}, gr = (t, e = {}) => ({ state: n, commands: r }) => {
|
|
1378
|
+
const o = T(t, n.schema);
|
|
1379
|
+
return H(n, o, e) ? r.lift(o) : r.wrapIn(o, e);
|
|
1380
|
+
}, vr = () => ({ state: t, dispatch: e }) => {
|
|
1381
|
+
const n = t.plugins;
|
|
1379
1382
|
for (let r = 0; r < n.length; r += 1) {
|
|
1380
1383
|
const o = n[r];
|
|
1381
1384
|
let s;
|
|
1382
|
-
if (o.spec.isInputRules && (s = o.getState(
|
|
1383
|
-
if (
|
|
1384
|
-
const i =
|
|
1385
|
+
if (o.spec.isInputRules && (s = o.getState(t))) {
|
|
1386
|
+
if (e) {
|
|
1387
|
+
const i = t.tr, c = s.transform;
|
|
1385
1388
|
for (let a = c.steps.length - 1; a >= 0; a -= 1)
|
|
1386
1389
|
i.step(c.steps[a].invert(c.docs[a]));
|
|
1387
1390
|
if (s.text) {
|
|
1388
1391
|
const a = i.doc.resolve(s.from).marks();
|
|
1389
|
-
i.replaceWith(s.from, s.to,
|
|
1392
|
+
i.replaceWith(s.from, s.to, t.schema.text(s.text, a));
|
|
1390
1393
|
} else
|
|
1391
1394
|
i.delete(s.from, s.to);
|
|
1392
1395
|
}
|
|
@@ -1394,43 +1397,43 @@ var ur = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
|
|
|
1394
1397
|
}
|
|
1395
1398
|
}
|
|
1396
1399
|
return !1;
|
|
1397
|
-
}, br = () => ({ tr:
|
|
1398
|
-
const { selection: n } =
|
|
1399
|
-
return r ||
|
|
1400
|
-
|
|
1400
|
+
}, br = () => ({ tr: t, dispatch: e }) => {
|
|
1401
|
+
const { selection: n } = t, { empty: r, ranges: o } = n;
|
|
1402
|
+
return r || e && o.forEach((s) => {
|
|
1403
|
+
t.removeMark(s.$from.pos, s.$to.pos);
|
|
1401
1404
|
}), !0;
|
|
1402
|
-
}, kr = (
|
|
1405
|
+
}, kr = (t, e = {}) => ({ tr: n, state: r, dispatch: o }) => {
|
|
1403
1406
|
var s;
|
|
1404
|
-
const { extendEmptyMarkRange: i = !1 } =
|
|
1407
|
+
const { extendEmptyMarkRange: i = !1 } = e, { selection: c } = n, a = B(t, r.schema), { $from: l, empty: u, ranges: d } = c;
|
|
1405
1408
|
if (!o)
|
|
1406
1409
|
return !0;
|
|
1407
1410
|
if (u && i) {
|
|
1408
1411
|
let { from: f, to: p } = c;
|
|
1409
|
-
const m = (s = l.marks().find((g) => g.type === a)) == null ? void 0 : s.attrs, h =
|
|
1412
|
+
const m = (s = l.marks().find((g) => g.type === a)) == null ? void 0 : s.attrs, h = gt(l, a, m);
|
|
1410
1413
|
h && (f = h.from, p = h.to), n.removeMark(f, p, a);
|
|
1411
1414
|
} else
|
|
1412
1415
|
d.forEach((f) => {
|
|
1413
1416
|
n.removeMark(f.$from.pos, f.$to.pos, a);
|
|
1414
1417
|
});
|
|
1415
1418
|
return n.removeStoredMark(a), !0;
|
|
1416
|
-
}, yr = (
|
|
1419
|
+
}, yr = (t) => ({ tr: e, state: n, dispatch: r }) => {
|
|
1417
1420
|
const { selection: o } = n;
|
|
1418
1421
|
let s, i;
|
|
1419
|
-
return typeof
|
|
1422
|
+
return typeof t == "number" ? (s = t, i = t) : t && "from" in t && "to" in t ? (s = t.from, i = t.to) : (s = o.from, i = o.to), r && e.doc.nodesBetween(s, i, (c, a) => {
|
|
1420
1423
|
if (c.isText)
|
|
1421
1424
|
return;
|
|
1422
1425
|
const l = { ...c.attrs };
|
|
1423
|
-
delete l.dir,
|
|
1426
|
+
delete l.dir, e.setNodeMarkup(a, void 0, l);
|
|
1424
1427
|
}), !0;
|
|
1425
|
-
}, wr = (
|
|
1428
|
+
}, wr = (t, e = {}) => ({ tr: n, state: r, dispatch: o }) => {
|
|
1426
1429
|
let s = null, i = null;
|
|
1427
1430
|
const c = et(
|
|
1428
|
-
typeof
|
|
1431
|
+
typeof t == "string" ? t : t.name,
|
|
1429
1432
|
r.schema
|
|
1430
1433
|
);
|
|
1431
1434
|
if (!c)
|
|
1432
1435
|
return !1;
|
|
1433
|
-
c === "node" && (s = T(
|
|
1436
|
+
c === "node" && (s = T(t, r.schema)), c === "mark" && (i = B(t, r.schema));
|
|
1434
1437
|
let a = !1;
|
|
1435
1438
|
return n.selection.ranges.forEach((l) => {
|
|
1436
1439
|
const u = l.$from.pos, d = l.$to.pos;
|
|
@@ -1440,7 +1443,7 @@ var ur = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
|
|
|
1440
1443
|
}) : r.doc.nodesBetween(u, d, (g, v) => {
|
|
1441
1444
|
v < u && s && s === g.type && (a = !0, m = Math.max(v, u), h = Math.min(v + g.nodeSize, d), f = v, p = g), v >= u && v <= d && (s && s === g.type && (a = !0, o && n.setNodeMarkup(v, void 0, {
|
|
1442
1445
|
...g.attrs,
|
|
1443
|
-
...
|
|
1446
|
+
...e
|
|
1444
1447
|
})), i && g.marks.length && g.marks.forEach((k) => {
|
|
1445
1448
|
if (i === k.type && (a = !0, o)) {
|
|
1446
1449
|
const w = Math.max(v, u), M = Math.min(v + g.nodeSize, d);
|
|
@@ -1449,78 +1452,78 @@ var ur = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor
|
|
|
1449
1452
|
M,
|
|
1450
1453
|
i.create({
|
|
1451
1454
|
...k.attrs,
|
|
1452
|
-
...
|
|
1455
|
+
...e
|
|
1453
1456
|
})
|
|
1454
1457
|
);
|
|
1455
1458
|
}
|
|
1456
1459
|
}));
|
|
1457
1460
|
}), p && (f !== void 0 && o && n.setNodeMarkup(f, void 0, {
|
|
1458
1461
|
...p.attrs,
|
|
1459
|
-
...
|
|
1462
|
+
...e
|
|
1460
1463
|
}), i && p.marks.length && p.marks.forEach((g) => {
|
|
1461
1464
|
i === g.type && o && n.addMark(
|
|
1462
1465
|
m,
|
|
1463
1466
|
h,
|
|
1464
1467
|
i.create({
|
|
1465
1468
|
...g.attrs,
|
|
1466
|
-
...
|
|
1469
|
+
...e
|
|
1467
1470
|
})
|
|
1468
1471
|
);
|
|
1469
1472
|
}));
|
|
1470
1473
|
}), a;
|
|
1471
|
-
}, Mr = (
|
|
1472
|
-
const o = T(
|
|
1473
|
-
return Oe(o,
|
|
1474
|
-
}, xr = (
|
|
1475
|
-
const o = T(
|
|
1476
|
-
return Ue(o,
|
|
1474
|
+
}, Mr = (t, e = {}) => ({ state: n, dispatch: r }) => {
|
|
1475
|
+
const o = T(t, n.schema);
|
|
1476
|
+
return Oe(o, e)(n, r);
|
|
1477
|
+
}, xr = (t, e = {}) => ({ state: n, dispatch: r }) => {
|
|
1478
|
+
const o = T(t, n.schema);
|
|
1479
|
+
return Ue(o, e)(n, r);
|
|
1477
1480
|
}, Sr = class {
|
|
1478
1481
|
constructor() {
|
|
1479
1482
|
this.callbacks = {};
|
|
1480
1483
|
}
|
|
1481
|
-
on(
|
|
1482
|
-
return this.callbacks[
|
|
1484
|
+
on(t, e) {
|
|
1485
|
+
return this.callbacks[t] || (this.callbacks[t] = []), this.callbacks[t].push(e), this;
|
|
1483
1486
|
}
|
|
1484
|
-
emit(
|
|
1485
|
-
const n = this.callbacks[
|
|
1486
|
-
return n && n.forEach((r) => r.apply(this,
|
|
1487
|
+
emit(t, ...e) {
|
|
1488
|
+
const n = this.callbacks[t];
|
|
1489
|
+
return n && n.forEach((r) => r.apply(this, e)), this;
|
|
1487
1490
|
}
|
|
1488
|
-
off(
|
|
1489
|
-
const n = this.callbacks[
|
|
1490
|
-
return n && (
|
|
1491
|
+
off(t, e) {
|
|
1492
|
+
const n = this.callbacks[t];
|
|
1493
|
+
return n && (e ? this.callbacks[t] = n.filter((r) => r !== e) : delete this.callbacks[t]), this;
|
|
1491
1494
|
}
|
|
1492
|
-
once(
|
|
1495
|
+
once(t, e) {
|
|
1493
1496
|
const n = (...r) => {
|
|
1494
|
-
this.off(
|
|
1497
|
+
this.off(t, n), e.apply(this, r);
|
|
1495
1498
|
};
|
|
1496
|
-
return this.on(
|
|
1499
|
+
return this.on(t, n);
|
|
1497
1500
|
}
|
|
1498
1501
|
removeAllListeners() {
|
|
1499
1502
|
this.callbacks = {};
|
|
1500
1503
|
}
|
|
1501
|
-
},
|
|
1502
|
-
constructor(
|
|
1503
|
-
var
|
|
1504
|
-
this.find =
|
|
1504
|
+
}, Mt = class {
|
|
1505
|
+
constructor(t) {
|
|
1506
|
+
var e;
|
|
1507
|
+
this.find = t.find, this.handler = t.handler, this.undoable = (e = t.undoable) != null ? e : !0;
|
|
1505
1508
|
}
|
|
1506
|
-
}, Er = (
|
|
1507
|
-
if (
|
|
1508
|
-
return
|
|
1509
|
-
const n = t
|
|
1509
|
+
}, Er = (t, e) => {
|
|
1510
|
+
if (ht(e))
|
|
1511
|
+
return e.exec(t);
|
|
1512
|
+
const n = e(t);
|
|
1510
1513
|
if (!n)
|
|
1511
1514
|
return null;
|
|
1512
1515
|
const r = [n.text];
|
|
1513
|
-
return r.index = n.index, r.input =
|
|
1516
|
+
return r.index = n.index, r.input = t, 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;
|
|
1514
1517
|
};
|
|
1515
|
-
function q(
|
|
1516
|
-
var
|
|
1517
|
-
const { editor: n, from: r, to: o, text: s, rules: i, plugin: c } =
|
|
1518
|
+
function q(t) {
|
|
1519
|
+
var e;
|
|
1520
|
+
const { editor: n, from: r, to: o, text: s, rules: i, plugin: c } = t, { view: a } = n;
|
|
1518
1521
|
if (a.composing)
|
|
1519
1522
|
return !1;
|
|
1520
1523
|
const l = a.state.doc.resolve(r);
|
|
1521
1524
|
if (
|
|
1522
1525
|
// check for code node
|
|
1523
|
-
l.parent.type.spec.code || (
|
|
1526
|
+
l.parent.type.spec.code || (e = l.nodeBefore || l.nodeAfter) != null && e.marks.find((f) => f.type.spec.code)
|
|
1524
1527
|
)
|
|
1525
1528
|
return !1;
|
|
1526
1529
|
let u = !1;
|
|
@@ -1556,8 +1559,8 @@ function q(e) {
|
|
|
1556
1559
|
}), a.dispatch(m), u = !0);
|
|
1557
1560
|
}), u;
|
|
1558
1561
|
}
|
|
1559
|
-
function Tr(
|
|
1560
|
-
const { editor:
|
|
1562
|
+
function Tr(t) {
|
|
1563
|
+
const { editor: e, rules: n } = t, r = new $({
|
|
1561
1564
|
state: {
|
|
1562
1565
|
init() {
|
|
1563
1566
|
return null;
|
|
@@ -1569,10 +1572,10 @@ function Tr(e) {
|
|
|
1569
1572
|
const a = o.getMeta("applyInputRules");
|
|
1570
1573
|
return a && setTimeout(() => {
|
|
1571
1574
|
let { text: u } = a;
|
|
1572
|
-
typeof u == "string" ? u = u : u =
|
|
1575
|
+
typeof u == "string" ? u = u : u = kt(j.from(u), i.schema);
|
|
1573
1576
|
const { from: d } = a, f = d + u.length;
|
|
1574
1577
|
q({
|
|
1575
|
-
editor:
|
|
1578
|
+
editor: e,
|
|
1576
1579
|
from: d,
|
|
1577
1580
|
to: f,
|
|
1578
1581
|
text: u,
|
|
@@ -1585,7 +1588,7 @@ function Tr(e) {
|
|
|
1585
1588
|
props: {
|
|
1586
1589
|
handleTextInput(o, s, i, c) {
|
|
1587
1590
|
return q({
|
|
1588
|
-
editor:
|
|
1591
|
+
editor: e,
|
|
1589
1592
|
from: s,
|
|
1590
1593
|
to: i,
|
|
1591
1594
|
text: c,
|
|
@@ -1597,7 +1600,7 @@ function Tr(e) {
|
|
|
1597
1600
|
compositionend: (o) => (setTimeout(() => {
|
|
1598
1601
|
const { $cursor: s } = o.state.selection;
|
|
1599
1602
|
s && q({
|
|
1600
|
-
editor:
|
|
1603
|
+
editor: e,
|
|
1601
1604
|
from: s.pos,
|
|
1602
1605
|
to: s.pos,
|
|
1603
1606
|
text: "",
|
|
@@ -1613,7 +1616,7 @@ function Tr(e) {
|
|
|
1613
1616
|
return !1;
|
|
1614
1617
|
const { $cursor: i } = o.state.selection;
|
|
1615
1618
|
return i ? q({
|
|
1616
|
-
editor:
|
|
1619
|
+
editor: e,
|
|
1617
1620
|
from: i.pos,
|
|
1618
1621
|
to: i.pos,
|
|
1619
1622
|
text: `
|
|
@@ -1628,25 +1631,25 @@ function Tr(e) {
|
|
|
1628
1631
|
});
|
|
1629
1632
|
return r;
|
|
1630
1633
|
}
|
|
1631
|
-
function Ar(
|
|
1632
|
-
return Object.prototype.toString.call(
|
|
1634
|
+
function Ar(t) {
|
|
1635
|
+
return Object.prototype.toString.call(t).slice(8, -1);
|
|
1633
1636
|
}
|
|
1634
|
-
function K(
|
|
1635
|
-
return Ar(
|
|
1637
|
+
function K(t) {
|
|
1638
|
+
return Ar(t) !== "Object" ? !1 : t.constructor === Object && Object.getPrototypeOf(t) === Object.prototype;
|
|
1636
1639
|
}
|
|
1637
|
-
function Yt(
|
|
1638
|
-
const n = { ...
|
|
1639
|
-
return K(
|
|
1640
|
-
K(
|
|
1640
|
+
function Yt(t, e) {
|
|
1641
|
+
const n = { ...t };
|
|
1642
|
+
return K(t) && K(e) && Object.keys(e).forEach((r) => {
|
|
1643
|
+
K(e[r]) && K(t[r]) ? n[r] = Yt(t[r], e[r]) : n[r] = e[r];
|
|
1641
1644
|
}), n;
|
|
1642
1645
|
}
|
|
1643
|
-
var
|
|
1644
|
-
constructor(
|
|
1646
|
+
var xt = class {
|
|
1647
|
+
constructor(t = {}) {
|
|
1645
1648
|
this.type = "extendable", this.parent = null, this.child = null, this.name = "", this.config = {
|
|
1646
1649
|
name: this.name
|
|
1647
1650
|
}, this.config = {
|
|
1648
1651
|
...this.config,
|
|
1649
|
-
...
|
|
1652
|
+
...t
|
|
1650
1653
|
}, this.name = this.config.name;
|
|
1651
1654
|
}
|
|
1652
1655
|
get options() {
|
|
@@ -1668,18 +1671,18 @@ var Mt = class {
|
|
|
1668
1671
|
) || {}
|
|
1669
1672
|
};
|
|
1670
1673
|
}
|
|
1671
|
-
configure(
|
|
1672
|
-
const
|
|
1674
|
+
configure(t = {}) {
|
|
1675
|
+
const e = this.extend({
|
|
1673
1676
|
...this.config,
|
|
1674
|
-
addOptions: () => Yt(this.options,
|
|
1677
|
+
addOptions: () => Yt(this.options, t)
|
|
1675
1678
|
});
|
|
1676
|
-
return
|
|
1679
|
+
return e.name = this.name, e.parent = this.parent, e;
|
|
1677
1680
|
}
|
|
1678
|
-
extend(
|
|
1679
|
-
const
|
|
1680
|
-
return
|
|
1681
|
+
extend(t = {}) {
|
|
1682
|
+
const e = new this.constructor({ ...this.config, ...t });
|
|
1683
|
+
return e.parent = this, this.child = e, e.name = "name" in t ? t.name : e.parent.name, e;
|
|
1681
1684
|
}
|
|
1682
|
-
}, Cr = class Xt extends
|
|
1685
|
+
}, Cr = class Xt extends xt {
|
|
1683
1686
|
constructor() {
|
|
1684
1687
|
super(...arguments), this.type = "mark";
|
|
1685
1688
|
}
|
|
@@ -1687,48 +1690,48 @@ var Mt = class {
|
|
|
1687
1690
|
* Create a new Mark instance
|
|
1688
1691
|
* @param config - Mark configuration object or a function that returns a configuration object
|
|
1689
1692
|
*/
|
|
1690
|
-
static create(
|
|
1691
|
-
const n = typeof
|
|
1693
|
+
static create(e = {}) {
|
|
1694
|
+
const n = typeof e == "function" ? e() : e;
|
|
1692
1695
|
return new Xt(n);
|
|
1693
1696
|
}
|
|
1694
|
-
static handleExit({ editor:
|
|
1695
|
-
const { tr: r } =
|
|
1697
|
+
static handleExit({ editor: e, mark: n }) {
|
|
1698
|
+
const { tr: r } = e.state, o = e.state.selection.$from;
|
|
1696
1699
|
if (o.pos === o.end()) {
|
|
1697
1700
|
const i = o.marks();
|
|
1698
1701
|
if (!!!i.find((l) => l?.type.name === n.name))
|
|
1699
1702
|
return !1;
|
|
1700
1703
|
const a = i.find((l) => l?.type.name === n.name);
|
|
1701
|
-
return a && r.removeStoredMark(a), r.insertText(" ", o.pos),
|
|
1704
|
+
return a && r.removeStoredMark(a), r.insertText(" ", o.pos), e.view.dispatch(r), !0;
|
|
1702
1705
|
}
|
|
1703
1706
|
return !1;
|
|
1704
1707
|
}
|
|
1705
|
-
configure(
|
|
1706
|
-
return super.configure(
|
|
1708
|
+
configure(e) {
|
|
1709
|
+
return super.configure(e);
|
|
1707
1710
|
}
|
|
1708
|
-
extend(
|
|
1709
|
-
const n = typeof
|
|
1711
|
+
extend(e) {
|
|
1712
|
+
const n = typeof e == "function" ? e() : e;
|
|
1710
1713
|
return super.extend(n);
|
|
1711
1714
|
}
|
|
1712
1715
|
};
|
|
1713
|
-
function Pr(
|
|
1714
|
-
return typeof
|
|
1716
|
+
function Pr(t) {
|
|
1717
|
+
return typeof t == "number";
|
|
1715
1718
|
}
|
|
1716
1719
|
var $r = class {
|
|
1717
|
-
constructor(
|
|
1718
|
-
this.find =
|
|
1720
|
+
constructor(t) {
|
|
1721
|
+
this.find = t.find, this.handler = t.handler;
|
|
1719
1722
|
}
|
|
1720
|
-
}, Nr = (
|
|
1721
|
-
if (
|
|
1722
|
-
return [...
|
|
1723
|
-
const r = t
|
|
1723
|
+
}, Nr = (t, e, n) => {
|
|
1724
|
+
if (ht(e))
|
|
1725
|
+
return [...t.matchAll(e)];
|
|
1726
|
+
const r = e(t, n);
|
|
1724
1727
|
return r ? r.map((o) => {
|
|
1725
1728
|
const s = [o.text];
|
|
1726
|
-
return s.index = o.index, s.input =
|
|
1729
|
+
return s.index = o.index, s.input = t, s.data = o.data, o.replaceWith && (o.text.includes(o.replaceWith) || console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'), s.push(o.replaceWith)), s;
|
|
1727
1730
|
}) : [];
|
|
1728
1731
|
};
|
|
1729
|
-
function Ir(
|
|
1730
|
-
const { editor:
|
|
1731
|
-
editor:
|
|
1732
|
+
function Ir(t) {
|
|
1733
|
+
const { editor: e, state: n, from: r, to: o, rule: s, pasteEvent: i, dropEvent: c } = t, { commands: a, chain: l, can: u } = new tt({
|
|
1734
|
+
editor: e,
|
|
1732
1735
|
state: n
|
|
1733
1736
|
}), d = [];
|
|
1734
1737
|
return n.doc.nodesBetween(r, o, (p, m) => {
|
|
@@ -1759,15 +1762,15 @@ function Ir(e) {
|
|
|
1759
1762
|
});
|
|
1760
1763
|
}), d.every((p) => p !== null);
|
|
1761
1764
|
}
|
|
1762
|
-
var J = null, Br = (
|
|
1763
|
-
var
|
|
1765
|
+
var J = null, Br = (t) => {
|
|
1766
|
+
var e;
|
|
1764
1767
|
const n = new ClipboardEvent("paste", {
|
|
1765
1768
|
clipboardData: new DataTransfer()
|
|
1766
1769
|
});
|
|
1767
|
-
return (
|
|
1770
|
+
return (e = n.clipboardData) == null || e.setData("text/html", t), n;
|
|
1768
1771
|
};
|
|
1769
|
-
function Rr(
|
|
1770
|
-
const { editor:
|
|
1772
|
+
function Rr(t) {
|
|
1773
|
+
const { editor: e, rules: n } = t;
|
|
1771
1774
|
let r = null, o = !1, s = !1, i = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, c;
|
|
1772
1775
|
try {
|
|
1773
1776
|
c = typeof DragEvent < "u" ? new DragEvent("drop") : null;
|
|
@@ -1786,7 +1789,7 @@ function Rr(e) {
|
|
|
1786
1789
|
transaction: h
|
|
1787
1790
|
});
|
|
1788
1791
|
if (!(!Ir({
|
|
1789
|
-
editor:
|
|
1792
|
+
editor: e,
|
|
1790
1793
|
state: g,
|
|
1791
1794
|
from: Math.max(d - 1, 0),
|
|
1792
1795
|
to: f.b - 1,
|
|
@@ -1807,7 +1810,7 @@ function Rr(e) {
|
|
|
1807
1810
|
view(d) {
|
|
1808
1811
|
const f = (m) => {
|
|
1809
1812
|
var h;
|
|
1810
|
-
r = (h = d.dom.parentElement) != null && h.contains(m.target) ? d.dom.parentElement : null, r && (J =
|
|
1813
|
+
r = (h = d.dom.parentElement) != null && h.contains(m.target) ? d.dom.parentElement : null, r && (J = e);
|
|
1811
1814
|
}, p = () => {
|
|
1812
1815
|
J && (J = null);
|
|
1813
1816
|
};
|
|
@@ -1842,7 +1845,7 @@ function Rr(e) {
|
|
|
1842
1845
|
return;
|
|
1843
1846
|
if (k) {
|
|
1844
1847
|
let { text: y } = v;
|
|
1845
|
-
typeof y == "string" ? y = y : y =
|
|
1848
|
+
typeof y == "string" ? y = y : y = kt(j.from(y), p.schema);
|
|
1846
1849
|
const { from: S } = v, E = S + y.length, A = Br(y);
|
|
1847
1850
|
return a({
|
|
1848
1851
|
rule: u,
|
|
@@ -1865,26 +1868,26 @@ function Rr(e) {
|
|
|
1865
1868
|
}));
|
|
1866
1869
|
}
|
|
1867
1870
|
var rt = class {
|
|
1868
|
-
constructor(
|
|
1869
|
-
this.splittableMarks = [], this.editor =
|
|
1871
|
+
constructor(t, e) {
|
|
1872
|
+
this.splittableMarks = [], this.editor = e, this.baseExtensions = t, this.extensions = qt(t), this.schema = Wn(this.extensions, e), this.setupExtensions();
|
|
1870
1873
|
}
|
|
1871
1874
|
/**
|
|
1872
1875
|
* Get all commands from the extensions.
|
|
1873
1876
|
* @returns An object with all commands where the key is the command name and the value is the command function
|
|
1874
1877
|
*/
|
|
1875
1878
|
get commands() {
|
|
1876
|
-
return this.extensions.reduce((
|
|
1879
|
+
return this.extensions.reduce((t, e) => {
|
|
1877
1880
|
const n = {
|
|
1878
|
-
name:
|
|
1879
|
-
options:
|
|
1880
|
-
storage: this.editor.extensionStorage[
|
|
1881
|
+
name: e.name,
|
|
1882
|
+
options: e.options,
|
|
1883
|
+
storage: this.editor.extensionStorage[e.name],
|
|
1881
1884
|
editor: this.editor,
|
|
1882
|
-
type: at(
|
|
1883
|
-
}, r = b(
|
|
1885
|
+
type: at(e.name, this.schema)
|
|
1886
|
+
}, r = b(e, "addCommands", n);
|
|
1884
1887
|
return r ? {
|
|
1885
|
-
...
|
|
1888
|
+
...t,
|
|
1886
1889
|
...r()
|
|
1887
|
-
} :
|
|
1890
|
+
} : t;
|
|
1888
1891
|
}, {});
|
|
1889
1892
|
}
|
|
1890
1893
|
/**
|
|
@@ -1892,13 +1895,13 @@ var rt = class {
|
|
|
1892
1895
|
* @returns An array of Prosemirror plugins
|
|
1893
1896
|
*/
|
|
1894
1897
|
get plugins() {
|
|
1895
|
-
const { editor:
|
|
1896
|
-
return
|
|
1898
|
+
const { editor: t } = this;
|
|
1899
|
+
return yt([...this.extensions].reverse()).flatMap((r) => {
|
|
1897
1900
|
const o = {
|
|
1898
1901
|
name: r.name,
|
|
1899
1902
|
options: r.options,
|
|
1900
1903
|
storage: this.editor.extensionStorage[r.name],
|
|
1901
|
-
editor:
|
|
1904
|
+
editor: t,
|
|
1902
1905
|
type: at(r.name, this.schema)
|
|
1903
1906
|
}, s = [], i = b(
|
|
1904
1907
|
r,
|
|
@@ -1906,30 +1909,30 @@ var rt = class {
|
|
|
1906
1909
|
o
|
|
1907
1910
|
);
|
|
1908
1911
|
let c = {};
|
|
1909
|
-
if (r.type === "mark" && b(r, "exitable", o) && (c.ArrowRight = () => Cr.handleExit({ editor:
|
|
1912
|
+
if (r.type === "mark" && b(r, "exitable", o) && (c.ArrowRight = () => Cr.handleExit({ editor: t, mark: r })), i) {
|
|
1910
1913
|
const f = Object.fromEntries(
|
|
1911
|
-
Object.entries(i()).map(([p, m]) => [p, () => m({ editor:
|
|
1914
|
+
Object.entries(i()).map(([p, m]) => [p, () => m({ editor: t })])
|
|
1912
1915
|
);
|
|
1913
1916
|
c = { ...c, ...f };
|
|
1914
1917
|
}
|
|
1915
1918
|
const a = qe(c);
|
|
1916
1919
|
s.push(a);
|
|
1917
1920
|
const l = b(r, "addInputRules", o);
|
|
1918
|
-
if (
|
|
1921
|
+
if (It(r, t.options.enableInputRules) && l) {
|
|
1919
1922
|
const f = l();
|
|
1920
1923
|
if (f && f.length) {
|
|
1921
1924
|
const p = Tr({
|
|
1922
|
-
editor:
|
|
1925
|
+
editor: t,
|
|
1923
1926
|
rules: f
|
|
1924
1927
|
}), m = Array.isArray(p) ? p : [p];
|
|
1925
1928
|
s.push(...m);
|
|
1926
1929
|
}
|
|
1927
1930
|
}
|
|
1928
1931
|
const u = b(r, "addPasteRules", o);
|
|
1929
|
-
if (
|
|
1932
|
+
if (It(r, t.options.enablePasteRules) && u) {
|
|
1930
1933
|
const f = u();
|
|
1931
1934
|
if (f && f.length) {
|
|
1932
|
-
const p = Rr({ editor:
|
|
1935
|
+
const p = Rr({ editor: t, rules: f });
|
|
1933
1936
|
s.push(...p);
|
|
1934
1937
|
}
|
|
1935
1938
|
}
|
|
@@ -1957,14 +1960,14 @@ var rt = class {
|
|
|
1957
1960
|
* @returns An object with all node views where the key is the node name and the value is the node view function
|
|
1958
1961
|
*/
|
|
1959
1962
|
get nodeViews() {
|
|
1960
|
-
const { editor:
|
|
1963
|
+
const { editor: t } = this, { nodeExtensions: e } = L(this.extensions);
|
|
1961
1964
|
return Object.fromEntries(
|
|
1962
|
-
|
|
1965
|
+
e.filter((n) => !!b(n, "addNodeView")).map((n) => {
|
|
1963
1966
|
const r = this.attributes.filter((a) => a.type === n.name), o = {
|
|
1964
1967
|
name: n.name,
|
|
1965
1968
|
options: n.options,
|
|
1966
1969
|
storage: this.editor.extensionStorage[n.name],
|
|
1967
|
-
editor:
|
|
1970
|
+
editor: t,
|
|
1968
1971
|
type: T(n.name, this.schema)
|
|
1969
1972
|
}, s = b(n, "addNodeView", o);
|
|
1970
1973
|
if (!s)
|
|
@@ -1982,7 +1985,7 @@ var rt = class {
|
|
|
1982
1985
|
decorations: d,
|
|
1983
1986
|
innerDecorations: f,
|
|
1984
1987
|
// tiptap-specific
|
|
1985
|
-
editor:
|
|
1988
|
+
editor: t,
|
|
1986
1989
|
extension: n,
|
|
1987
1990
|
HTMLAttributes: p
|
|
1988
1991
|
});
|
|
@@ -1992,14 +1995,14 @@ var rt = class {
|
|
|
1992
1995
|
);
|
|
1993
1996
|
}
|
|
1994
1997
|
get markViews() {
|
|
1995
|
-
const { editor:
|
|
1998
|
+
const { editor: t } = this, { markExtensions: e } = L(this.extensions);
|
|
1996
1999
|
return Object.fromEntries(
|
|
1997
|
-
|
|
2000
|
+
e.filter((n) => !!b(n, "addMarkView")).map((n) => {
|
|
1998
2001
|
const r = this.attributes.filter((c) => c.type === n.name), o = {
|
|
1999
2002
|
name: n.name,
|
|
2000
2003
|
options: n.options,
|
|
2001
2004
|
storage: this.editor.extensionStorage[n.name],
|
|
2002
|
-
editor:
|
|
2005
|
+
editor: t,
|
|
2003
2006
|
type: B(n.name, this.schema)
|
|
2004
2007
|
}, s = b(n, "addMarkView", o);
|
|
2005
2008
|
if (!s)
|
|
@@ -2012,11 +2015,11 @@ var rt = class {
|
|
|
2012
2015
|
view: a,
|
|
2013
2016
|
inline: l,
|
|
2014
2017
|
// tiptap-specific
|
|
2015
|
-
editor:
|
|
2018
|
+
editor: t,
|
|
2016
2019
|
extension: n,
|
|
2017
2020
|
HTMLAttributes: u,
|
|
2018
2021
|
updateAttributes: (d) => {
|
|
2019
|
-
Kr(c,
|
|
2022
|
+
Kr(c, t, d);
|
|
2020
2023
|
}
|
|
2021
2024
|
});
|
|
2022
2025
|
};
|
|
@@ -2029,33 +2032,33 @@ var rt = class {
|
|
|
2029
2032
|
* & bind editor event listener.
|
|
2030
2033
|
*/
|
|
2031
2034
|
setupExtensions() {
|
|
2032
|
-
const
|
|
2035
|
+
const t = this.extensions;
|
|
2033
2036
|
this.editor.extensionStorage = Object.fromEntries(
|
|
2034
|
-
|
|
2035
|
-
),
|
|
2037
|
+
t.map((e) => [e.name, e.storage])
|
|
2038
|
+
), t.forEach((e) => {
|
|
2036
2039
|
var n;
|
|
2037
2040
|
const r = {
|
|
2038
|
-
name:
|
|
2039
|
-
options:
|
|
2040
|
-
storage: this.editor.extensionStorage[
|
|
2041
|
+
name: e.name,
|
|
2042
|
+
options: e.options,
|
|
2043
|
+
storage: this.editor.extensionStorage[e.name],
|
|
2041
2044
|
editor: this.editor,
|
|
2042
|
-
type: at(
|
|
2045
|
+
type: at(e.name, this.schema)
|
|
2043
2046
|
};
|
|
2044
|
-
|
|
2045
|
-
const o = b(
|
|
2046
|
-
|
|
2047
|
+
e.type === "mark" && ((n = x(b(e, "keepOnSplit", r))) == null || n) && this.splittableMarks.push(e.name);
|
|
2048
|
+
const o = b(e, "onBeforeCreate", r), s = b(e, "onCreate", r), i = b(e, "onUpdate", r), c = b(
|
|
2049
|
+
e,
|
|
2047
2050
|
"onSelectionUpdate",
|
|
2048
2051
|
r
|
|
2049
|
-
), a = b(
|
|
2052
|
+
), a = b(e, "onTransaction", r), l = b(e, "onFocus", r), u = b(e, "onBlur", r), d = b(e, "onDestroy", r);
|
|
2050
2053
|
o && this.editor.on("beforeCreate", o), s && this.editor.on("create", s), i && this.editor.on("update", i), c && this.editor.on("selectionUpdate", c), a && this.editor.on("transaction", a), l && this.editor.on("focus", l), u && this.editor.on("blur", u), d && this.editor.on("destroy", d);
|
|
2051
2054
|
});
|
|
2052
2055
|
}
|
|
2053
2056
|
};
|
|
2054
2057
|
rt.resolve = qt;
|
|
2055
|
-
rt.sort =
|
|
2056
|
-
rt.flatten =
|
|
2058
|
+
rt.sort = yt;
|
|
2059
|
+
rt.flatten = bt;
|
|
2057
2060
|
var jr = {};
|
|
2058
|
-
|
|
2061
|
+
mt(jr, {
|
|
2059
2062
|
ClipboardTextSerializer: () => ee,
|
|
2060
2063
|
Commands: () => ne,
|
|
2061
2064
|
Delete: () => re,
|
|
@@ -2068,7 +2071,7 @@ pt(jr, {
|
|
|
2068
2071
|
TextDirection: () => ue,
|
|
2069
2072
|
focusEventsPluginKey: () => ie
|
|
2070
2073
|
});
|
|
2071
|
-
var N = class te extends
|
|
2074
|
+
var N = class te extends xt {
|
|
2072
2075
|
constructor() {
|
|
2073
2076
|
super(...arguments), this.type = "extension";
|
|
2074
2077
|
}
|
|
@@ -2076,15 +2079,15 @@ var N = class te extends Mt {
|
|
|
2076
2079
|
* Create a new Extension instance
|
|
2077
2080
|
* @param config - Extension configuration object or a function that returns a configuration object
|
|
2078
2081
|
*/
|
|
2079
|
-
static create(
|
|
2080
|
-
const n = typeof
|
|
2082
|
+
static create(e = {}) {
|
|
2083
|
+
const n = typeof e == "function" ? e() : e;
|
|
2081
2084
|
return new te(n);
|
|
2082
2085
|
}
|
|
2083
|
-
configure(
|
|
2084
|
-
return super.configure(
|
|
2086
|
+
configure(e) {
|
|
2087
|
+
return super.configure(e);
|
|
2085
2088
|
}
|
|
2086
|
-
extend(
|
|
2087
|
-
const n = typeof
|
|
2089
|
+
extend(e) {
|
|
2090
|
+
const n = typeof e == "function" ? e() : e;
|
|
2088
2091
|
return super.extend(n);
|
|
2089
2092
|
}
|
|
2090
2093
|
}, ee = N.create({
|
|
@@ -2100,7 +2103,7 @@ var N = class te extends Mt {
|
|
|
2100
2103
|
key: new O("clipboardTextSerializer"),
|
|
2101
2104
|
props: {
|
|
2102
2105
|
clipboardTextSerializer: () => {
|
|
2103
|
-
const { editor:
|
|
2106
|
+
const { editor: t } = this, { state: e, schema: n } = t, { doc: r, selection: o } = e, { ranges: s } = o, i = Math.min(...s.map((u) => u.$from.pos)), c = Math.max(...s.map((u) => u.$to.pos)), a = Jt(n);
|
|
2104
2107
|
return Kt(r, { from: i, to: c }, {
|
|
2105
2108
|
...this.options.blockSeparator !== void 0 ? { blockSeparator: this.options.blockSeparator } : {},
|
|
2106
2109
|
textSerializers: a
|
|
@@ -2119,13 +2122,13 @@ var N = class te extends Mt {
|
|
|
2119
2122
|
}
|
|
2120
2123
|
}), re = N.create({
|
|
2121
2124
|
name: "delete",
|
|
2122
|
-
onUpdate({ transaction:
|
|
2125
|
+
onUpdate({ transaction: t, appendedTransactions: e }) {
|
|
2123
2126
|
var n, r, o;
|
|
2124
2127
|
const s = () => {
|
|
2125
2128
|
var i, c, a, l;
|
|
2126
|
-
if ((l = (a = (c = (i = this.editor.options.coreExtensionOptions) == null ? void 0 : i.delete) == null ? void 0 : c.filterTransaction) == null ? void 0 : a.call(c,
|
|
2129
|
+
if ((l = (a = (c = (i = this.editor.options.coreExtensionOptions) == null ? void 0 : i.delete) == null ? void 0 : c.filterTransaction) == null ? void 0 : a.call(c, t)) != null ? l : t.getMeta("y-sync$"))
|
|
2127
2130
|
return;
|
|
2128
|
-
const u = zn(
|
|
2131
|
+
const u = zn(t.before, [t, ...e]);
|
|
2129
2132
|
Yn(u).forEach((p) => {
|
|
2130
2133
|
u.mapping.mapResult(p.oldRange.from).deletedAfter && u.mapping.mapResult(p.oldRange.to).deletedBefore && u.before.nodesBetween(p.oldRange.from, p.oldRange.to, (m, h) => {
|
|
2131
2134
|
const g = h + m.nodeSize - 2, v = p.oldRange.from <= h && g <= p.oldRange.to;
|
|
@@ -2140,7 +2143,7 @@ var N = class te extends Mt {
|
|
|
2140
2143
|
newRange: p.newRange,
|
|
2141
2144
|
partial: !v,
|
|
2142
2145
|
editor: this.editor,
|
|
2143
|
-
transaction:
|
|
2146
|
+
transaction: t,
|
|
2144
2147
|
combinedTransform: u
|
|
2145
2148
|
});
|
|
2146
2149
|
});
|
|
@@ -2165,7 +2168,7 @@ var N = class te extends Mt {
|
|
|
2165
2168
|
},
|
|
2166
2169
|
partial: !!(S || y),
|
|
2167
2170
|
editor: this.editor,
|
|
2168
|
-
transaction:
|
|
2171
|
+
transaction: t,
|
|
2169
2172
|
combinedTransform: u
|
|
2170
2173
|
});
|
|
2171
2174
|
}
|
|
@@ -2180,10 +2183,10 @@ var N = class te extends Mt {
|
|
|
2180
2183
|
new $({
|
|
2181
2184
|
key: new O("tiptapDrop"),
|
|
2182
2185
|
props: {
|
|
2183
|
-
handleDrop: (
|
|
2186
|
+
handleDrop: (t, e, n, r) => {
|
|
2184
2187
|
this.editor.emit("drop", {
|
|
2185
2188
|
editor: this.editor,
|
|
2186
|
-
event:
|
|
2189
|
+
event: e,
|
|
2187
2190
|
slice: n,
|
|
2188
2191
|
moved: r
|
|
2189
2192
|
});
|
|
@@ -2207,21 +2210,21 @@ var N = class te extends Mt {
|
|
|
2207
2210
|
}), ie = new O("focusEvents"), ae = N.create({
|
|
2208
2211
|
name: "focusEvents",
|
|
2209
2212
|
addProseMirrorPlugins() {
|
|
2210
|
-
const { editor:
|
|
2213
|
+
const { editor: t } = this;
|
|
2211
2214
|
return [
|
|
2212
2215
|
new $({
|
|
2213
2216
|
key: ie,
|
|
2214
2217
|
props: {
|
|
2215
2218
|
handleDOMEvents: {
|
|
2216
|
-
focus: (
|
|
2217
|
-
|
|
2218
|
-
const r =
|
|
2219
|
-
return
|
|
2219
|
+
focus: (e, n) => {
|
|
2220
|
+
t.isFocused = !0;
|
|
2221
|
+
const r = t.state.tr.setMeta("focus", { event: n }).setMeta("addToHistory", !1);
|
|
2222
|
+
return e.dispatch(r), !1;
|
|
2220
2223
|
},
|
|
2221
|
-
blur: (
|
|
2222
|
-
|
|
2223
|
-
const r =
|
|
2224
|
-
return
|
|
2224
|
+
blur: (e, n) => {
|
|
2225
|
+
t.isFocused = !1;
|
|
2226
|
+
const r = t.state.tr.setMeta("blur", { event: n }).setMeta("addToHistory", !1);
|
|
2227
|
+
return e.dispatch(r), !1;
|
|
2225
2228
|
}
|
|
2226
2229
|
}
|
|
2227
2230
|
}
|
|
@@ -2231,7 +2234,7 @@ var N = class te extends Mt {
|
|
|
2231
2234
|
}), ce = N.create({
|
|
2232
2235
|
name: "keymap",
|
|
2233
2236
|
addKeyboardShortcuts() {
|
|
2234
|
-
const
|
|
2237
|
+
const t = () => this.editor.commands.first(({ commands: i }) => [
|
|
2235
2238
|
() => i.undoInputRule(),
|
|
2236
2239
|
// maybe convert first text block node to default node
|
|
2237
2240
|
() => i.command(({ tr: c }) => {
|
|
@@ -2241,7 +2244,7 @@ var N = class te extends Mt {
|
|
|
2241
2244
|
() => i.deleteSelection(),
|
|
2242
2245
|
() => i.joinBackward(),
|
|
2243
2246
|
() => i.selectNodeBackward()
|
|
2244
|
-
]),
|
|
2247
|
+
]), e = () => this.editor.commands.first(({ commands: i }) => [
|
|
2245
2248
|
() => i.deleteSelection(),
|
|
2246
2249
|
() => i.deleteCurrentNode(),
|
|
2247
2250
|
() => i.joinForward(),
|
|
@@ -2254,26 +2257,26 @@ var N = class te extends Mt {
|
|
|
2254
2257
|
() => i.splitBlock()
|
|
2255
2258
|
]),
|
|
2256
2259
|
"Mod-Enter": () => this.editor.commands.exitCode(),
|
|
2257
|
-
Backspace:
|
|
2258
|
-
"Mod-Backspace":
|
|
2259
|
-
"Shift-Backspace":
|
|
2260
|
-
Delete:
|
|
2261
|
-
"Mod-Delete":
|
|
2260
|
+
Backspace: t,
|
|
2261
|
+
"Mod-Backspace": t,
|
|
2262
|
+
"Shift-Backspace": t,
|
|
2263
|
+
Delete: e,
|
|
2264
|
+
"Mod-Delete": e,
|
|
2262
2265
|
"Mod-a": () => this.editor.commands.selectAll()
|
|
2263
2266
|
}, o = {
|
|
2264
2267
|
...r
|
|
2265
2268
|
}, s = {
|
|
2266
2269
|
...r,
|
|
2267
|
-
"Ctrl-h":
|
|
2268
|
-
"Alt-Backspace":
|
|
2269
|
-
"Ctrl-d":
|
|
2270
|
-
"Ctrl-Alt-Backspace":
|
|
2271
|
-
"Alt-Delete":
|
|
2272
|
-
"Alt-d":
|
|
2270
|
+
"Ctrl-h": t,
|
|
2271
|
+
"Alt-Backspace": t,
|
|
2272
|
+
"Ctrl-d": e,
|
|
2273
|
+
"Ctrl-Alt-Backspace": e,
|
|
2274
|
+
"Alt-Delete": e,
|
|
2275
|
+
"Alt-d": e,
|
|
2273
2276
|
"Ctrl-a": () => this.editor.commands.selectTextblockStart(),
|
|
2274
2277
|
"Ctrl-e": () => this.editor.commands.selectTextblockEnd()
|
|
2275
2278
|
};
|
|
2276
|
-
return
|
|
2279
|
+
return vt() || Vt() ? s : o;
|
|
2277
2280
|
},
|
|
2278
2281
|
addProseMirrorPlugins() {
|
|
2279
2282
|
return [
|
|
@@ -2284,14 +2287,14 @@ var N = class te extends Mt {
|
|
|
2284
2287
|
// with many other commands.
|
|
2285
2288
|
new $({
|
|
2286
2289
|
key: new O("clearDocument"),
|
|
2287
|
-
appendTransaction: (
|
|
2288
|
-
if (
|
|
2290
|
+
appendTransaction: (t, e, n) => {
|
|
2291
|
+
if (t.some((h) => h.getMeta("composition")))
|
|
2289
2292
|
return;
|
|
2290
|
-
const r =
|
|
2293
|
+
const r = t.some((h) => h.docChanged) && !e.doc.eq(n.doc), o = t.some((h) => h.getMeta("preventClearDocument"));
|
|
2291
2294
|
if (!r || o)
|
|
2292
2295
|
return;
|
|
2293
|
-
const { empty: s, from: i, to: c } =
|
|
2294
|
-
if (s || !(i === a && c === l) || !
|
|
2296
|
+
const { empty: s, from: i, to: c } = e.selection, a = F.atStart(e.doc).from, l = F.atEnd(e.doc).to;
|
|
2297
|
+
if (s || !(i === a && c === l) || !wt(n.doc))
|
|
2295
2298
|
return;
|
|
2296
2299
|
const f = n.tr, p = X({
|
|
2297
2300
|
state: n,
|
|
@@ -2313,10 +2316,10 @@ var N = class te extends Mt {
|
|
|
2313
2316
|
new $({
|
|
2314
2317
|
key: new O("tiptapPaste"),
|
|
2315
2318
|
props: {
|
|
2316
|
-
handlePaste: (
|
|
2319
|
+
handlePaste: (t, e, n) => {
|
|
2317
2320
|
this.editor.emit("paste", {
|
|
2318
2321
|
editor: this.editor,
|
|
2319
|
-
event:
|
|
2322
|
+
event: e,
|
|
2320
2323
|
slice: n
|
|
2321
2324
|
});
|
|
2322
2325
|
}
|
|
@@ -2346,19 +2349,19 @@ var N = class te extends Mt {
|
|
|
2346
2349
|
addGlobalAttributes() {
|
|
2347
2350
|
if (!this.options.direction)
|
|
2348
2351
|
return [];
|
|
2349
|
-
const { nodeExtensions:
|
|
2352
|
+
const { nodeExtensions: t } = L(this.extensions);
|
|
2350
2353
|
return [
|
|
2351
2354
|
{
|
|
2352
|
-
types:
|
|
2355
|
+
types: t.filter((e) => e.name !== "text").map((e) => e.name),
|
|
2353
2356
|
attributes: {
|
|
2354
2357
|
dir: {
|
|
2355
2358
|
default: this.options.direction,
|
|
2356
|
-
parseHTML: (
|
|
2357
|
-
const n =
|
|
2359
|
+
parseHTML: (e) => {
|
|
2360
|
+
const n = e.getAttribute("dir");
|
|
2358
2361
|
return n && (n === "ltr" || n === "rtl" || n === "auto") ? n : this.options.direction;
|
|
2359
2362
|
},
|
|
2360
|
-
renderHTML: (
|
|
2361
|
-
dir:
|
|
2363
|
+
renderHTML: (e) => e.dir ? {
|
|
2364
|
+
dir: e.dir
|
|
2362
2365
|
} : {}
|
|
2363
2366
|
}
|
|
2364
2367
|
}
|
|
@@ -2371,9 +2374,9 @@ var N = class te extends Mt {
|
|
|
2371
2374
|
key: new O("textDirection"),
|
|
2372
2375
|
props: {
|
|
2373
2376
|
attributes: () => {
|
|
2374
|
-
const
|
|
2375
|
-
return
|
|
2376
|
-
dir:
|
|
2377
|
+
const t = this.options.direction;
|
|
2378
|
+
return t ? {
|
|
2379
|
+
dir: t
|
|
2377
2380
|
} : {};
|
|
2378
2381
|
}
|
|
2379
2382
|
}
|
|
@@ -2381,8 +2384,8 @@ var N = class te extends Mt {
|
|
|
2381
2384
|
];
|
|
2382
2385
|
}
|
|
2383
2386
|
}), Or = class z {
|
|
2384
|
-
constructor(
|
|
2385
|
-
this.currentNode = null, this.actualDepth = null, this.isBlock = r, this.resolvedPos =
|
|
2387
|
+
constructor(e, n, r = !1, o = null) {
|
|
2388
|
+
this.currentNode = null, this.actualDepth = null, this.isBlock = r, this.resolvedPos = e, this.editor = n, this.currentNode = o;
|
|
2386
2389
|
}
|
|
2387
2390
|
get name() {
|
|
2388
2391
|
return this.node.type.name;
|
|
@@ -2394,8 +2397,8 @@ var N = class te extends Mt {
|
|
|
2394
2397
|
return this.editor.view.domAtPos(this.pos).node;
|
|
2395
2398
|
}
|
|
2396
2399
|
get depth() {
|
|
2397
|
-
var
|
|
2398
|
-
return (
|
|
2400
|
+
var e;
|
|
2401
|
+
return (e = this.actualDepth) != null ? e : this.resolvedPos.depth;
|
|
2399
2402
|
}
|
|
2400
2403
|
get pos() {
|
|
2401
2404
|
return this.resolvedPos.pos;
|
|
@@ -2403,7 +2406,7 @@ var N = class te extends Mt {
|
|
|
2403
2406
|
get content() {
|
|
2404
2407
|
return this.node.content;
|
|
2405
2408
|
}
|
|
2406
|
-
set content(
|
|
2409
|
+
set content(e) {
|
|
2407
2410
|
let n = this.from, r = this.to;
|
|
2408
2411
|
if (this.isBlock) {
|
|
2409
2412
|
if (this.content.size === 0) {
|
|
@@ -2412,7 +2415,7 @@ var N = class te extends Mt {
|
|
|
2412
2415
|
}
|
|
2413
2416
|
n = this.from + 1, r = this.to - 1;
|
|
2414
2417
|
}
|
|
2415
|
-
this.editor.commands.insertContentAt({ from: n, to: r },
|
|
2418
|
+
this.editor.commands.insertContentAt({ from: n, to: r }, e);
|
|
2416
2419
|
}
|
|
2417
2420
|
get attributes() {
|
|
2418
2421
|
return this.node.attrs;
|
|
@@ -2438,19 +2441,19 @@ var N = class te extends Mt {
|
|
|
2438
2441
|
get parent() {
|
|
2439
2442
|
if (this.depth === 0)
|
|
2440
2443
|
return null;
|
|
2441
|
-
const
|
|
2444
|
+
const e = this.resolvedPos.start(this.resolvedPos.depth - 1), n = this.resolvedPos.doc.resolve(e);
|
|
2442
2445
|
return new z(n, this.editor);
|
|
2443
2446
|
}
|
|
2444
2447
|
get before() {
|
|
2445
|
-
let
|
|
2446
|
-
return
|
|
2448
|
+
let e = this.resolvedPos.doc.resolve(this.from - (this.isBlock ? 1 : 2));
|
|
2449
|
+
return e.depth !== this.depth && (e = this.resolvedPos.doc.resolve(this.from - 3)), new z(e, this.editor);
|
|
2447
2450
|
}
|
|
2448
2451
|
get after() {
|
|
2449
|
-
let
|
|
2450
|
-
return
|
|
2452
|
+
let e = this.resolvedPos.doc.resolve(this.to + (this.isBlock ? 2 : 1));
|
|
2453
|
+
return e.depth !== this.depth && (e = this.resolvedPos.doc.resolve(this.to + 3)), new z(e, this.editor);
|
|
2451
2454
|
}
|
|
2452
2455
|
get children() {
|
|
2453
|
-
const
|
|
2456
|
+
const e = [];
|
|
2454
2457
|
return this.node.content.forEach((n, r) => {
|
|
2455
2458
|
const o = n.isBlock && !n.isTextblock, s = n.isAtom && !n.isText, i = this.pos + r + (s ? 0 : 1);
|
|
2456
2459
|
if (i < 0 || i > this.resolvedPos.doc.nodeSize - 2)
|
|
@@ -2459,20 +2462,20 @@ var N = class te extends Mt {
|
|
|
2459
2462
|
if (!o && c.depth <= this.depth)
|
|
2460
2463
|
return;
|
|
2461
2464
|
const a = new z(c, this.editor, o, o ? n : null);
|
|
2462
|
-
o && (a.actualDepth = this.depth + 1),
|
|
2463
|
-
}),
|
|
2465
|
+
o && (a.actualDepth = this.depth + 1), e.push(new z(c, this.editor, o, o ? n : null));
|
|
2466
|
+
}), e;
|
|
2464
2467
|
}
|
|
2465
2468
|
get firstChild() {
|
|
2466
2469
|
return this.children[0] || null;
|
|
2467
2470
|
}
|
|
2468
2471
|
get lastChild() {
|
|
2469
|
-
const
|
|
2470
|
-
return
|
|
2472
|
+
const e = this.children;
|
|
2473
|
+
return e[e.length - 1] || null;
|
|
2471
2474
|
}
|
|
2472
|
-
closest(
|
|
2475
|
+
closest(e, n = {}) {
|
|
2473
2476
|
let r = null, o = this.parent;
|
|
2474
2477
|
for (; o && !r; ) {
|
|
2475
|
-
if (o.node.type.name ===
|
|
2478
|
+
if (o.node.type.name === e)
|
|
2476
2479
|
if (Object.keys(n).length > 0) {
|
|
2477
2480
|
const s = o.node.attrs, i = Object.keys(n);
|
|
2478
2481
|
for (let c = 0; c < i.length; c += 1) {
|
|
@@ -2486,23 +2489,23 @@ var N = class te extends Mt {
|
|
|
2486
2489
|
}
|
|
2487
2490
|
return r;
|
|
2488
2491
|
}
|
|
2489
|
-
querySelector(
|
|
2490
|
-
return this.querySelectorAll(
|
|
2492
|
+
querySelector(e, n = {}) {
|
|
2493
|
+
return this.querySelectorAll(e, n, !0)[0] || null;
|
|
2491
2494
|
}
|
|
2492
|
-
querySelectorAll(
|
|
2495
|
+
querySelectorAll(e, n = {}, r = !1) {
|
|
2493
2496
|
let o = [];
|
|
2494
2497
|
if (!this.children || this.children.length === 0)
|
|
2495
2498
|
return o;
|
|
2496
2499
|
const s = Object.keys(n);
|
|
2497
2500
|
return this.children.forEach((i) => {
|
|
2498
|
-
r && o.length > 0 || (i.node.type.name ===
|
|
2501
|
+
r && o.length > 0 || (i.node.type.name === e && s.every((a) => n[a] === i.node.attrs[a]) && o.push(i), !(r && o.length > 0) && (o = o.concat(i.querySelectorAll(e, n, r))));
|
|
2499
2502
|
}), o;
|
|
2500
2503
|
}
|
|
2501
|
-
setAttribute(
|
|
2504
|
+
setAttribute(e) {
|
|
2502
2505
|
const { tr: n } = this.editor.state;
|
|
2503
2506
|
n.setNodeMarkup(this.from, void 0, {
|
|
2504
2507
|
...this.node.attrs,
|
|
2505
|
-
...
|
|
2508
|
+
...e
|
|
2506
2509
|
}), this.editor.view.dispatch(n);
|
|
2507
2510
|
}
|
|
2508
2511
|
}, Dr = `.ProseMirror {
|
|
@@ -2576,15 +2579,15 @@ img.ProseMirror-separator {
|
|
|
2576
2579
|
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
2577
2580
|
display: block;
|
|
2578
2581
|
}`;
|
|
2579
|
-
function _r(
|
|
2582
|
+
function _r(t, e, n) {
|
|
2580
2583
|
const r = document.querySelector("style[data-tiptap-style]");
|
|
2581
2584
|
if (r !== null)
|
|
2582
2585
|
return r;
|
|
2583
2586
|
const o = document.createElement("style");
|
|
2584
|
-
return
|
|
2587
|
+
return e && o.setAttribute("nonce", e), o.setAttribute("data-tiptap-style", ""), o.innerHTML = t, document.getElementsByTagName("head")[0].appendChild(o), o;
|
|
2585
2588
|
}
|
|
2586
|
-
var
|
|
2587
|
-
constructor(
|
|
2589
|
+
var io = class extends Sr {
|
|
2590
|
+
constructor(t = {}) {
|
|
2588
2591
|
super(), this.css = null, this.className = "tiptap", this.editorView = null, this.isFocused = !1, this.isInitialized = !1, this.extensionStorage = {}, this.instanceId = Math.random().toString(36).slice(2, 9), this.options = {
|
|
2589
2592
|
element: typeof document < "u" ? document.createElement("div") : null,
|
|
2590
2593
|
content: "",
|
|
@@ -2621,10 +2624,10 @@ var so = class extends Sr {
|
|
|
2621
2624
|
}, this.isCapturingTransaction = !1, this.capturedTransaction = null, this.utils = {
|
|
2622
2625
|
getUpdatedPosition: er,
|
|
2623
2626
|
createMappablePosition: nr
|
|
2624
|
-
}, this.setOptions(
|
|
2625
|
-
const
|
|
2627
|
+
}, this.setOptions(t), 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: r, slice: o, moved: s }) => this.options.onDrop(r, o, s)), this.on("paste", ({ event: r, slice: o }) => this.options.onPaste(r, o)), this.on("delete", this.options.onDelete);
|
|
2628
|
+
const e = this.createDoc(), n = Ft(e, this.options.autofocus);
|
|
2626
2629
|
this.editorState = De.create({
|
|
2627
|
-
doc:
|
|
2630
|
+
doc: e,
|
|
2628
2631
|
schema: this.schema,
|
|
2629
2632
|
selection: n || void 0
|
|
2630
2633
|
}), this.options.element && this.mount(this.options.element);
|
|
@@ -2632,12 +2635,12 @@ var so = class extends Sr {
|
|
|
2632
2635
|
/**
|
|
2633
2636
|
* Attach the editor to the DOM, creating a new editor view.
|
|
2634
2637
|
*/
|
|
2635
|
-
mount(
|
|
2638
|
+
mount(t) {
|
|
2636
2639
|
if (typeof document > "u")
|
|
2637
2640
|
throw new Error(
|
|
2638
2641
|
"[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment."
|
|
2639
2642
|
);
|
|
2640
|
-
this.createView(
|
|
2643
|
+
this.createView(t), this.emit("mount", { editor: this }), this.css && !document.head.contains(this.css) && document.head.appendChild(this.css), window.setTimeout(() => {
|
|
2641
2644
|
this.isDestroyed || (this.options.autofocus !== !1 && this.options.autofocus !== null && this.commands.focus(this.options.autofocus), this.emit("create", { editor: this }), this.isInitialized = !0);
|
|
2642
2645
|
}, 0);
|
|
2643
2646
|
}
|
|
@@ -2646,14 +2649,14 @@ var so = class extends Sr {
|
|
|
2646
2649
|
*/
|
|
2647
2650
|
unmount() {
|
|
2648
2651
|
if (this.editorView) {
|
|
2649
|
-
const
|
|
2650
|
-
|
|
2652
|
+
const t = this.editorView.dom;
|
|
2653
|
+
t?.editor && delete t.editor, this.editorView.destroy();
|
|
2651
2654
|
}
|
|
2652
2655
|
if (this.editorView = null, this.isInitialized = !1, this.css && !document.querySelectorAll(`.${this.className}`).length)
|
|
2653
2656
|
try {
|
|
2654
2657
|
typeof this.css.remove == "function" ? this.css.remove() : this.css.parentNode && this.css.parentNode.removeChild(this.css);
|
|
2655
|
-
} catch (
|
|
2656
|
-
console.warn("Failed to remove CSS element:",
|
|
2658
|
+
} catch (t) {
|
|
2659
|
+
console.warn("Failed to remove CSS element:", t);
|
|
2657
2660
|
}
|
|
2658
2661
|
this.css = null, this.emit("unmount", { editor: this });
|
|
2659
2662
|
}
|
|
@@ -2692,17 +2695,17 @@ var so = class extends Sr {
|
|
|
2692
2695
|
*
|
|
2693
2696
|
* @param options A list of options
|
|
2694
2697
|
*/
|
|
2695
|
-
setOptions(
|
|
2698
|
+
setOptions(t = {}) {
|
|
2696
2699
|
this.options = {
|
|
2697
2700
|
...this.options,
|
|
2698
|
-
...
|
|
2701
|
+
...t
|
|
2699
2702
|
}, !(!this.editorView || !this.state || this.isDestroyed) && (this.options.editorProps && this.view.setProps(this.options.editorProps), this.view.updateState(this.state));
|
|
2700
2703
|
}
|
|
2701
2704
|
/**
|
|
2702
2705
|
* Update editable state of the editor.
|
|
2703
2706
|
*/
|
|
2704
|
-
setEditable(
|
|
2705
|
-
this.setOptions({ editable:
|
|
2707
|
+
setEditable(t, e = !0) {
|
|
2708
|
+
this.setOptions({ editable: t }), e && this.emit("update", { editor: this, transaction: this.state.tr, appendedTransactions: [] });
|
|
2706
2709
|
}
|
|
2707
2710
|
/**
|
|
2708
2711
|
* Returns whether the editor is editable.
|
|
@@ -2717,11 +2720,11 @@ var so = class extends Sr {
|
|
|
2717
2720
|
return this.editorView ? this.editorView : new Proxy(
|
|
2718
2721
|
{
|
|
2719
2722
|
state: this.editorState,
|
|
2720
|
-
updateState: (
|
|
2721
|
-
this.editorState =
|
|
2723
|
+
updateState: (t) => {
|
|
2724
|
+
this.editorState = t;
|
|
2722
2725
|
},
|
|
2723
|
-
dispatch: (
|
|
2724
|
-
this.dispatchTransaction(
|
|
2726
|
+
dispatch: (t) => {
|
|
2727
|
+
this.dispatchTransaction(t);
|
|
2725
2728
|
},
|
|
2726
2729
|
// Stub some commonly accessed properties to prevent errors
|
|
2727
2730
|
composing: !1,
|
|
@@ -2730,15 +2733,15 @@ var so = class extends Sr {
|
|
|
2730
2733
|
isDestroyed: !1
|
|
2731
2734
|
},
|
|
2732
2735
|
{
|
|
2733
|
-
get: (
|
|
2736
|
+
get: (t, e) => {
|
|
2734
2737
|
if (this.editorView)
|
|
2735
|
-
return this.editorView[
|
|
2736
|
-
if (
|
|
2738
|
+
return this.editorView[e];
|
|
2739
|
+
if (e === "state")
|
|
2737
2740
|
return this.editorState;
|
|
2738
|
-
if (
|
|
2739
|
-
return Reflect.get(
|
|
2741
|
+
if (e in t)
|
|
2742
|
+
return Reflect.get(t, e);
|
|
2740
2743
|
throw new Error(
|
|
2741
|
-
`[tiptap error]: The editor view is not available. Cannot access view['${
|
|
2744
|
+
`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`
|
|
2742
2745
|
);
|
|
2743
2746
|
}
|
|
2744
2747
|
}
|
|
@@ -2757,8 +2760,8 @@ var so = class extends Sr {
|
|
|
2757
2760
|
* @param handlePlugins Control how to merge the plugin into the existing plugins.
|
|
2758
2761
|
* @returns The new editor state
|
|
2759
2762
|
*/
|
|
2760
|
-
registerPlugin(
|
|
2761
|
-
const n = Ut(
|
|
2763
|
+
registerPlugin(t, e) {
|
|
2764
|
+
const n = Ut(e) ? e(t, [...this.state.plugins]) : [...this.state.plugins, t], r = this.state.reconfigure({ plugins: n });
|
|
2762
2765
|
return this.view.updateState(r), r;
|
|
2763
2766
|
}
|
|
2764
2767
|
/**
|
|
@@ -2767,15 +2770,15 @@ var so = class extends Sr {
|
|
|
2767
2770
|
* @param nameOrPluginKeyToRemove The plugins name
|
|
2768
2771
|
* @returns The new editor state or undefined if the editor is destroyed
|
|
2769
2772
|
*/
|
|
2770
|
-
unregisterPlugin(
|
|
2773
|
+
unregisterPlugin(t) {
|
|
2771
2774
|
if (this.isDestroyed)
|
|
2772
2775
|
return;
|
|
2773
|
-
const
|
|
2774
|
-
let n =
|
|
2775
|
-
if ([].concat(
|
|
2776
|
+
const e = this.state.plugins;
|
|
2777
|
+
let n = e;
|
|
2778
|
+
if ([].concat(t).forEach((o) => {
|
|
2776
2779
|
const s = typeof o == "string" ? `${o}$` : o.key;
|
|
2777
2780
|
n = n.filter((i) => !i.key.startsWith(s));
|
|
2778
|
-
}),
|
|
2781
|
+
}), e.length === n.length)
|
|
2779
2782
|
return;
|
|
2780
2783
|
const r = this.state.reconfigure({
|
|
2781
2784
|
plugins: n
|
|
@@ -2786,11 +2789,11 @@ var so = class extends Sr {
|
|
|
2786
2789
|
* Creates an extension manager.
|
|
2787
2790
|
*/
|
|
2788
2791
|
createExtensionManager() {
|
|
2789
|
-
var
|
|
2792
|
+
var t, e;
|
|
2790
2793
|
const r = [...this.options.enableCoreExtensions ? [
|
|
2791
2794
|
se,
|
|
2792
2795
|
ee.configure({
|
|
2793
|
-
blockSeparator: (
|
|
2796
|
+
blockSeparator: (e = (t = this.options.coreExtensionOptions) == null ? void 0 : t.clipboardTextSerializer) == null ? void 0 : e.blockSeparator
|
|
2794
2797
|
}),
|
|
2795
2798
|
ne,
|
|
2796
2799
|
ae,
|
|
@@ -2823,37 +2826,37 @@ var so = class extends Sr {
|
|
|
2823
2826
|
* Creates the initial document.
|
|
2824
2827
|
*/
|
|
2825
2828
|
createDoc() {
|
|
2826
|
-
let
|
|
2829
|
+
let t;
|
|
2827
2830
|
try {
|
|
2828
|
-
|
|
2831
|
+
t = dt(this.options.content, this.schema, this.options.parseOptions, {
|
|
2829
2832
|
errorOnInvalidContent: this.options.enableContentCheck
|
|
2830
2833
|
});
|
|
2831
|
-
} catch (
|
|
2832
|
-
if (!(
|
|
2833
|
-
throw
|
|
2834
|
+
} catch (e) {
|
|
2835
|
+
if (!(e instanceof Error) || !["[tiptap error]: Invalid JSON content", "[tiptap error]: Invalid HTML content"].includes(e.message))
|
|
2836
|
+
throw e;
|
|
2834
2837
|
this.emit("contentError", {
|
|
2835
2838
|
editor: this,
|
|
2836
|
-
error:
|
|
2839
|
+
error: e,
|
|
2837
2840
|
disableCollaboration: () => {
|
|
2838
2841
|
"collaboration" in this.storage && typeof this.storage.collaboration == "object" && this.storage.collaboration && (this.storage.collaboration.isDisabled = !0), this.options.extensions = this.options.extensions.filter((n) => n.name !== "collaboration"), this.createExtensionManager();
|
|
2839
2842
|
}
|
|
2840
|
-
}),
|
|
2843
|
+
}), t = dt(this.options.content, this.schema, this.options.parseOptions, {
|
|
2841
2844
|
errorOnInvalidContent: !1
|
|
2842
2845
|
});
|
|
2843
2846
|
}
|
|
2844
|
-
return
|
|
2847
|
+
return t;
|
|
2845
2848
|
}
|
|
2846
2849
|
/**
|
|
2847
2850
|
* Creates a ProseMirror view.
|
|
2848
2851
|
*/
|
|
2849
|
-
createView(
|
|
2850
|
-
var
|
|
2851
|
-
this.editorView = new We(
|
|
2852
|
+
createView(t) {
|
|
2853
|
+
var e;
|
|
2854
|
+
this.editorView = new We(t, {
|
|
2852
2855
|
...this.options.editorProps,
|
|
2853
2856
|
attributes: {
|
|
2854
2857
|
// add `role="textbox"` to the editor element
|
|
2855
2858
|
role: "textbox",
|
|
2856
|
-
...(
|
|
2859
|
+
...(e = this.options.editorProps) == null ? void 0 : e.attributes
|
|
2857
2860
|
},
|
|
2858
2861
|
dispatchTransaction: this.dispatchTransaction.bind(this),
|
|
2859
2862
|
state: this.editorState,
|
|
@@ -2882,44 +2885,44 @@ var so = class extends Sr {
|
|
|
2882
2885
|
prependClass() {
|
|
2883
2886
|
this.view.dom.className = `${this.className} ${this.view.dom.className}`;
|
|
2884
2887
|
}
|
|
2885
|
-
captureTransaction(
|
|
2886
|
-
this.isCapturingTransaction = !0,
|
|
2887
|
-
const
|
|
2888
|
-
return this.capturedTransaction = null,
|
|
2888
|
+
captureTransaction(t) {
|
|
2889
|
+
this.isCapturingTransaction = !0, t(), this.isCapturingTransaction = !1;
|
|
2890
|
+
const e = this.capturedTransaction;
|
|
2891
|
+
return this.capturedTransaction = null, e;
|
|
2889
2892
|
}
|
|
2890
2893
|
/**
|
|
2891
2894
|
* The callback over which to send transactions (state updates) produced by the view.
|
|
2892
2895
|
*
|
|
2893
2896
|
* @param transaction An editor state transaction
|
|
2894
2897
|
*/
|
|
2895
|
-
dispatchTransaction(
|
|
2898
|
+
dispatchTransaction(t) {
|
|
2896
2899
|
if (this.view.isDestroyed)
|
|
2897
2900
|
return;
|
|
2898
2901
|
if (this.isCapturingTransaction) {
|
|
2899
2902
|
if (!this.capturedTransaction) {
|
|
2900
|
-
this.capturedTransaction =
|
|
2903
|
+
this.capturedTransaction = t;
|
|
2901
2904
|
return;
|
|
2902
2905
|
}
|
|
2903
|
-
|
|
2906
|
+
t.steps.forEach((l) => {
|
|
2904
2907
|
var u;
|
|
2905
2908
|
return (u = this.capturedTransaction) == null ? void 0 : u.step(l);
|
|
2906
2909
|
});
|
|
2907
2910
|
return;
|
|
2908
2911
|
}
|
|
2909
|
-
const { state:
|
|
2912
|
+
const { state: e, transactions: n } = this.state.applyTransaction(t), r = !this.state.selection.eq(e.selection), o = n.includes(t), s = this.state;
|
|
2910
2913
|
if (this.emit("beforeTransaction", {
|
|
2911
2914
|
editor: this,
|
|
2912
|
-
transaction:
|
|
2913
|
-
nextState:
|
|
2915
|
+
transaction: t,
|
|
2916
|
+
nextState: e
|
|
2914
2917
|
}), !o)
|
|
2915
2918
|
return;
|
|
2916
|
-
this.view.updateState(
|
|
2919
|
+
this.view.updateState(e), this.emit("transaction", {
|
|
2917
2920
|
editor: this,
|
|
2918
|
-
transaction:
|
|
2921
|
+
transaction: t,
|
|
2919
2922
|
appendedTransactions: n.slice(1)
|
|
2920
2923
|
}), r && this.emit("selectionUpdate", {
|
|
2921
2924
|
editor: this,
|
|
2922
|
-
transaction:
|
|
2925
|
+
transaction: t
|
|
2923
2926
|
});
|
|
2924
2927
|
const i = n.findLast((l) => l.getMeta("focus") || l.getMeta("blur")), c = i?.getMeta("focus"), a = i?.getMeta("blur");
|
|
2925
2928
|
c && this.emit("focus", {
|
|
@@ -2932,20 +2935,20 @@ var so = class extends Sr {
|
|
|
2932
2935
|
event: a.event,
|
|
2933
2936
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
2934
2937
|
transaction: i
|
|
2935
|
-
}), !(
|
|
2938
|
+
}), !(t.getMeta("preventUpdate") || !n.some((l) => l.docChanged) || s.doc.eq(e.doc)) && this.emit("update", {
|
|
2936
2939
|
editor: this,
|
|
2937
|
-
transaction:
|
|
2940
|
+
transaction: t,
|
|
2938
2941
|
appendedTransactions: n.slice(1)
|
|
2939
2942
|
});
|
|
2940
2943
|
}
|
|
2941
2944
|
/**
|
|
2942
2945
|
* Get attributes of the currently selected node or mark.
|
|
2943
2946
|
*/
|
|
2944
|
-
getAttributes(
|
|
2945
|
-
return Zn(this.state,
|
|
2947
|
+
getAttributes(t) {
|
|
2948
|
+
return Zn(this.state, t);
|
|
2946
2949
|
}
|
|
2947
|
-
isActive(
|
|
2948
|
-
const n = typeof
|
|
2950
|
+
isActive(t, e) {
|
|
2951
|
+
const n = typeof t == "string" ? t : null, r = typeof t == "string" ? e : t;
|
|
2949
2952
|
return tr(this.state, n, r);
|
|
2950
2953
|
}
|
|
2951
2954
|
/**
|
|
@@ -2958,17 +2961,17 @@ var so = class extends Sr {
|
|
|
2958
2961
|
* Get the document as HTML.
|
|
2959
2962
|
*/
|
|
2960
2963
|
getHTML() {
|
|
2961
|
-
return
|
|
2964
|
+
return kt(this.state.doc.content, this.schema);
|
|
2962
2965
|
}
|
|
2963
2966
|
/**
|
|
2964
2967
|
* Get the document as text.
|
|
2965
2968
|
*/
|
|
2966
|
-
getText(
|
|
2967
|
-
const { blockSeparator:
|
|
2969
|
+
getText(t) {
|
|
2970
|
+
const { blockSeparator: e = `
|
|
2968
2971
|
|
|
2969
|
-
`, textSerializers: n = {} } =
|
|
2972
|
+
`, textSerializers: n = {} } = t || {};
|
|
2970
2973
|
return Kn(this.state.doc, {
|
|
2971
|
-
blockSeparator:
|
|
2974
|
+
blockSeparator: e,
|
|
2972
2975
|
textSerializers: {
|
|
2973
2976
|
...Jt(this.schema),
|
|
2974
2977
|
...n
|
|
@@ -2979,7 +2982,7 @@ var so = class extends Sr {
|
|
|
2979
2982
|
* Check if there is no content.
|
|
2980
2983
|
*/
|
|
2981
2984
|
get isEmpty() {
|
|
2982
|
-
return
|
|
2985
|
+
return wt(this.state.doc);
|
|
2983
2986
|
}
|
|
2984
2987
|
/**
|
|
2985
2988
|
* Destroy the editor.
|
|
@@ -2991,130 +2994,130 @@ var so = class extends Sr {
|
|
|
2991
2994
|
* Check if the editor is already destroyed.
|
|
2992
2995
|
*/
|
|
2993
2996
|
get isDestroyed() {
|
|
2994
|
-
var
|
|
2995
|
-
return (
|
|
2997
|
+
var t, e;
|
|
2998
|
+
return (e = (t = this.editorView) == null ? void 0 : t.isDestroyed) != null ? e : !0;
|
|
2996
2999
|
}
|
|
2997
|
-
$node(
|
|
3000
|
+
$node(t, e) {
|
|
2998
3001
|
var n;
|
|
2999
|
-
return ((n = this.$doc) == null ? void 0 : n.querySelector(
|
|
3002
|
+
return ((n = this.$doc) == null ? void 0 : n.querySelector(t, e)) || null;
|
|
3000
3003
|
}
|
|
3001
|
-
$nodes(
|
|
3004
|
+
$nodes(t, e) {
|
|
3002
3005
|
var n;
|
|
3003
|
-
return ((n = this.$doc) == null ? void 0 : n.querySelectorAll(
|
|
3006
|
+
return ((n = this.$doc) == null ? void 0 : n.querySelectorAll(t, e)) || null;
|
|
3004
3007
|
}
|
|
3005
|
-
$pos(
|
|
3006
|
-
const
|
|
3007
|
-
return new Or(
|
|
3008
|
+
$pos(t) {
|
|
3009
|
+
const e = this.state.doc.resolve(t);
|
|
3010
|
+
return new Or(e, this);
|
|
3008
3011
|
}
|
|
3009
3012
|
get $doc() {
|
|
3010
3013
|
return this.$pos(0);
|
|
3011
3014
|
}
|
|
3012
3015
|
};
|
|
3013
|
-
function
|
|
3014
|
-
return new
|
|
3015
|
-
find:
|
|
3016
|
-
handler: ({ state:
|
|
3017
|
-
const o = x(
|
|
3016
|
+
function ao(t) {
|
|
3017
|
+
return new Mt({
|
|
3018
|
+
find: t.find,
|
|
3019
|
+
handler: ({ state: e, range: n, match: r }) => {
|
|
3020
|
+
const o = x(t.getAttributes, void 0, r);
|
|
3018
3021
|
if (o === !1 || o === null)
|
|
3019
3022
|
return null;
|
|
3020
|
-
const { tr: s } =
|
|
3023
|
+
const { tr: s } = e, i = r[r.length - 1], c = r[0];
|
|
3021
3024
|
if (i) {
|
|
3022
3025
|
const a = c.search(/\S/), l = n.from + c.indexOf(i), u = l + i.length;
|
|
3023
|
-
if (Zt(n.from, n.to,
|
|
3026
|
+
if (Zt(n.from, n.to, e.doc).filter((p) => p.mark.type.excluded.find((h) => h === t.type && h !== p.mark.type)).filter((p) => p.to > l).length)
|
|
3024
3027
|
return null;
|
|
3025
3028
|
u < n.to && s.delete(u, n.to), l > n.from && s.delete(n.from + a, l);
|
|
3026
3029
|
const f = n.from + a + i.length;
|
|
3027
|
-
s.addMark(n.from + a, f,
|
|
3030
|
+
s.addMark(n.from + a, f, t.type.create(o || {})), s.removeStoredMark(t.type);
|
|
3028
3031
|
}
|
|
3029
3032
|
},
|
|
3030
|
-
undoable:
|
|
3033
|
+
undoable: t.undoable
|
|
3031
3034
|
});
|
|
3032
3035
|
}
|
|
3033
|
-
function
|
|
3034
|
-
return new
|
|
3035
|
-
find:
|
|
3036
|
-
handler: ({ state:
|
|
3037
|
-
const o =
|
|
3038
|
-
if (!o.node(-1).canReplaceWith(o.index(-1), o.indexAfter(-1),
|
|
3036
|
+
function co(t) {
|
|
3037
|
+
return new Mt({
|
|
3038
|
+
find: t.find,
|
|
3039
|
+
handler: ({ state: e, range: n, match: r }) => {
|
|
3040
|
+
const o = e.doc.resolve(n.from), s = x(t.getAttributes, void 0, r) || {};
|
|
3041
|
+
if (!o.node(-1).canReplaceWith(o.index(-1), o.indexAfter(-1), t.type))
|
|
3039
3042
|
return null;
|
|
3040
|
-
|
|
3043
|
+
e.tr.delete(n.from, n.to).setBlockType(n.from, n.from, t.type, s);
|
|
3041
3044
|
},
|
|
3042
|
-
undoable:
|
|
3045
|
+
undoable: t.undoable
|
|
3043
3046
|
});
|
|
3044
3047
|
}
|
|
3045
|
-
function
|
|
3046
|
-
return new
|
|
3047
|
-
find:
|
|
3048
|
-
handler: ({ state:
|
|
3049
|
-
const s = x(
|
|
3048
|
+
function lo(t) {
|
|
3049
|
+
return new Mt({
|
|
3050
|
+
find: t.find,
|
|
3051
|
+
handler: ({ state: e, range: n, match: r, chain: o }) => {
|
|
3052
|
+
const s = x(t.getAttributes, void 0, r) || {}, i = e.tr.delete(n.from, n.to), a = i.doc.resolve(n.from).blockRange(), l = a && me(a, t.type, s);
|
|
3050
3053
|
if (!l)
|
|
3051
3054
|
return null;
|
|
3052
|
-
if (i.wrap(a, l),
|
|
3053
|
-
const { selection: d, storedMarks: f } =
|
|
3055
|
+
if (i.wrap(a, l), t.keepMarks && t.editor) {
|
|
3056
|
+
const { selection: d, storedMarks: f } = e, { splittableMarks: p } = t.editor.extensionManager, m = f || d.$to.parentOffset && d.$from.marks();
|
|
3054
3057
|
if (m) {
|
|
3055
3058
|
const h = m.filter((g) => p.includes(g.type.name));
|
|
3056
3059
|
i.ensureMarks(h);
|
|
3057
3060
|
}
|
|
3058
3061
|
}
|
|
3059
|
-
if (
|
|
3060
|
-
const d =
|
|
3062
|
+
if (t.keepAttributes) {
|
|
3063
|
+
const d = t.type.name === "bulletList" || t.type.name === "orderedList" ? "listItem" : "taskList";
|
|
3061
3064
|
o().updateAttributes(d, s).run();
|
|
3062
3065
|
}
|
|
3063
3066
|
const u = i.doc.resolve(n.from - 1).nodeBefore;
|
|
3064
|
-
u && u.type ===
|
|
3067
|
+
u && u.type === t.type && ft(i.doc, n.from - 1) && (!t.joinPredicate || t.joinPredicate(r, u)) && i.join(n.from - 1);
|
|
3065
3068
|
},
|
|
3066
|
-
undoable:
|
|
3069
|
+
undoable: t.undoable
|
|
3067
3070
|
});
|
|
3068
3071
|
}
|
|
3069
3072
|
var zr = {};
|
|
3070
|
-
|
|
3073
|
+
mt(zr, {
|
|
3071
3074
|
createAtomBlockMarkdownSpec: () => Fr,
|
|
3072
3075
|
createBlockMarkdownSpec: () => Lr,
|
|
3073
3076
|
createInlineMarkdownSpec: () => Ur,
|
|
3074
|
-
parseAttributes: () =>
|
|
3077
|
+
parseAttributes: () => St,
|
|
3075
3078
|
parseIndentedBlocks: () => Wr,
|
|
3076
3079
|
renderNestedMarkdownContent: () => qr,
|
|
3077
|
-
serializeAttributes: () =>
|
|
3080
|
+
serializeAttributes: () => Et
|
|
3078
3081
|
});
|
|
3079
|
-
function
|
|
3080
|
-
if (!
|
|
3082
|
+
function St(t) {
|
|
3083
|
+
if (!t?.trim())
|
|
3081
3084
|
return {};
|
|
3082
|
-
const
|
|
3085
|
+
const e = {}, n = [], r = t.replace(/["']([^"']*)["']/g, (l) => (n.push(l), `__QUOTED_${n.length - 1}__`)), o = r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);
|
|
3083
3086
|
if (o) {
|
|
3084
3087
|
const l = o.map((u) => u.trim().slice(1));
|
|
3085
|
-
|
|
3088
|
+
e.class = l.join(" ");
|
|
3086
3089
|
}
|
|
3087
3090
|
const s = r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);
|
|
3088
|
-
s && (
|
|
3091
|
+
s && (e.id = s[1]);
|
|
3089
3092
|
const i = /([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;
|
|
3090
3093
|
Array.from(r.matchAll(i)).forEach(([, l, u]) => {
|
|
3091
3094
|
var d;
|
|
3092
3095
|
const f = parseInt(((d = u.match(/__QUOTED_(\d+)__/)) == null ? void 0 : d[1]) || "0", 10), p = n[f];
|
|
3093
|
-
p && (
|
|
3096
|
+
p && (e[l] = p.slice(1, -1));
|
|
3094
3097
|
});
|
|
3095
3098
|
const a = r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g, "").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g, "").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g, "").trim();
|
|
3096
3099
|
return a && a.split(/\s+/).filter(Boolean).forEach((u) => {
|
|
3097
|
-
u.match(/^[a-zA-Z][\w-]*$/) && (
|
|
3098
|
-
}),
|
|
3100
|
+
u.match(/^[a-zA-Z][\w-]*$/) && (e[u] = !0);
|
|
3101
|
+
}), e;
|
|
3099
3102
|
}
|
|
3100
|
-
function
|
|
3101
|
-
if (!
|
|
3103
|
+
function Et(t) {
|
|
3104
|
+
if (!t || Object.keys(t).length === 0)
|
|
3102
3105
|
return "";
|
|
3103
|
-
const
|
|
3104
|
-
return
|
|
3105
|
-
n === "class" || n === "id" || (r === !0 ?
|
|
3106
|
-
}),
|
|
3106
|
+
const e = [];
|
|
3107
|
+
return t.class && String(t.class).split(/\s+/).filter(Boolean).forEach((r) => e.push(`.${r}`)), t.id && e.push(`#${t.id}`), Object.entries(t).forEach(([n, r]) => {
|
|
3108
|
+
n === "class" || n === "id" || (r === !0 ? e.push(n) : r !== !1 && r != null && e.push(`${n}="${String(r)}"`));
|
|
3109
|
+
}), e.join(" ");
|
|
3107
3110
|
}
|
|
3108
|
-
function Fr(
|
|
3111
|
+
function Fr(t) {
|
|
3109
3112
|
const {
|
|
3110
|
-
nodeName:
|
|
3113
|
+
nodeName: e,
|
|
3111
3114
|
name: n,
|
|
3112
|
-
parseAttributes: r =
|
|
3113
|
-
serializeAttributes: o =
|
|
3115
|
+
parseAttributes: r = St,
|
|
3116
|
+
serializeAttributes: o = Et,
|
|
3114
3117
|
defaultAttributes: s = {},
|
|
3115
3118
|
requiredAttributes: i = [],
|
|
3116
3119
|
allowedAttributes: c
|
|
3117
|
-
} =
|
|
3120
|
+
} = t, a = n || e, l = (u) => {
|
|
3118
3121
|
if (!c)
|
|
3119
3122
|
return u;
|
|
3120
3123
|
const d = {};
|
|
@@ -3125,10 +3128,10 @@ function Fr(e) {
|
|
|
3125
3128
|
return {
|
|
3126
3129
|
parseMarkdown: (u, d) => {
|
|
3127
3130
|
const f = { ...s, ...u.attributes };
|
|
3128
|
-
return d.createNode(
|
|
3131
|
+
return d.createNode(e, f, []);
|
|
3129
3132
|
},
|
|
3130
3133
|
markdownTokenizer: {
|
|
3131
|
-
name:
|
|
3134
|
+
name: e,
|
|
3132
3135
|
level: "block",
|
|
3133
3136
|
start(u) {
|
|
3134
3137
|
var d;
|
|
@@ -3142,7 +3145,7 @@ function Fr(e) {
|
|
|
3142
3145
|
const h = m[1] || "", g = r(h);
|
|
3143
3146
|
if (!i.find((k) => !(k in g)))
|
|
3144
3147
|
return {
|
|
3145
|
-
type:
|
|
3148
|
+
type: e,
|
|
3146
3149
|
raw: m[0],
|
|
3147
3150
|
attributes: g
|
|
3148
3151
|
};
|
|
@@ -3154,17 +3157,17 @@ function Fr(e) {
|
|
|
3154
3157
|
}
|
|
3155
3158
|
};
|
|
3156
3159
|
}
|
|
3157
|
-
function Lr(
|
|
3160
|
+
function Lr(t) {
|
|
3158
3161
|
const {
|
|
3159
|
-
nodeName:
|
|
3162
|
+
nodeName: e,
|
|
3160
3163
|
name: n,
|
|
3161
3164
|
getContent: r,
|
|
3162
|
-
parseAttributes: o =
|
|
3163
|
-
serializeAttributes: s =
|
|
3165
|
+
parseAttributes: o = St,
|
|
3166
|
+
serializeAttributes: s = Et,
|
|
3164
3167
|
defaultAttributes: i = {},
|
|
3165
3168
|
content: c = "block",
|
|
3166
3169
|
allowedAttributes: a
|
|
3167
|
-
} =
|
|
3170
|
+
} = t, l = n || e, u = (d) => {
|
|
3168
3171
|
if (!a)
|
|
3169
3172
|
return d;
|
|
3170
3173
|
const f = {};
|
|
@@ -3180,10 +3183,10 @@ function Lr(e) {
|
|
|
3180
3183
|
p = typeof h == "string" ? [{ type: "text", text: h }] : h;
|
|
3181
3184
|
} else c === "block" ? p = f.parseChildren(d.tokens || []) : p = f.parseInline(d.tokens || []);
|
|
3182
3185
|
const m = { ...i, ...d.attributes };
|
|
3183
|
-
return f.createNode(
|
|
3186
|
+
return f.createNode(e, m, p);
|
|
3184
3187
|
},
|
|
3185
3188
|
markdownTokenizer: {
|
|
3186
|
-
name:
|
|
3189
|
+
name: e,
|
|
3187
3190
|
level: "block",
|
|
3188
3191
|
start(d) {
|
|
3189
3192
|
var f;
|
|
@@ -3227,7 +3230,7 @@ function Lr(e) {
|
|
|
3227
3230
|
else
|
|
3228
3231
|
R = p.inlineTokens(S);
|
|
3229
3232
|
return {
|
|
3230
|
-
type:
|
|
3233
|
+
type: e,
|
|
3231
3234
|
raw: st,
|
|
3232
3235
|
attributes: w,
|
|
3233
3236
|
content: S,
|
|
@@ -3250,23 +3253,23 @@ ${g}
|
|
|
3250
3253
|
}
|
|
3251
3254
|
};
|
|
3252
3255
|
}
|
|
3253
|
-
function Vr(
|
|
3254
|
-
if (!
|
|
3256
|
+
function Vr(t) {
|
|
3257
|
+
if (!t.trim())
|
|
3255
3258
|
return {};
|
|
3256
|
-
const
|
|
3257
|
-
let r = n.exec(
|
|
3259
|
+
const e = {}, n = /(\w+)=(?:"([^"]*)"|'([^']*)')/g;
|
|
3260
|
+
let r = n.exec(t);
|
|
3258
3261
|
for (; r !== null; ) {
|
|
3259
3262
|
const [, o, s, i] = r;
|
|
3260
|
-
|
|
3263
|
+
e[o] = s || i, r = n.exec(t);
|
|
3261
3264
|
}
|
|
3262
|
-
return
|
|
3265
|
+
return e;
|
|
3263
3266
|
}
|
|
3264
|
-
function Hr(
|
|
3265
|
-
return Object.entries(
|
|
3267
|
+
function Hr(t) {
|
|
3268
|
+
return Object.entries(t).filter(([, e]) => e != null).map(([e, n]) => `${e}="${n}"`).join(" ");
|
|
3266
3269
|
}
|
|
3267
|
-
function Ur(
|
|
3270
|
+
function Ur(t) {
|
|
3268
3271
|
const {
|
|
3269
|
-
nodeName:
|
|
3272
|
+
nodeName: e,
|
|
3270
3273
|
name: n,
|
|
3271
3274
|
getContent: r,
|
|
3272
3275
|
parseAttributes: o = Vr,
|
|
@@ -3274,7 +3277,7 @@ function Ur(e) {
|
|
|
3274
3277
|
defaultAttributes: i = {},
|
|
3275
3278
|
selfClosing: c = !1,
|
|
3276
3279
|
allowedAttributes: a
|
|
3277
|
-
} =
|
|
3280
|
+
} = t, l = n || e, u = (f) => {
|
|
3278
3281
|
if (!a)
|
|
3279
3282
|
return f;
|
|
3280
3283
|
const p = {};
|
|
@@ -3292,12 +3295,12 @@ function Ur(e) {
|
|
|
3292
3295
|
parseMarkdown: (f, p) => {
|
|
3293
3296
|
const m = { ...i, ...f.attributes };
|
|
3294
3297
|
if (c)
|
|
3295
|
-
return p.createNode(
|
|
3298
|
+
return p.createNode(e, m);
|
|
3296
3299
|
const h = r ? r(f) : f.content || "";
|
|
3297
|
-
return h ? p.createNode(
|
|
3300
|
+
return h ? p.createNode(e, m, [p.createTextNode(h)]) : p.createNode(e, m, []);
|
|
3298
3301
|
},
|
|
3299
3302
|
markdownTokenizer: {
|
|
3300
|
-
name:
|
|
3303
|
+
name: e,
|
|
3301
3304
|
level: "inline",
|
|
3302
3305
|
start(f) {
|
|
3303
3306
|
const p = c ? new RegExp(`\\[${d}\\s*[^\\]]*\\]`) : new RegExp(`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`), m = f.match(p), h = m?.index;
|
|
@@ -3317,7 +3320,7 @@ function Ur(e) {
|
|
|
3317
3320
|
}
|
|
3318
3321
|
const w = o(k.trim());
|
|
3319
3322
|
return {
|
|
3320
|
-
type:
|
|
3323
|
+
type: e,
|
|
3321
3324
|
raw: g[0],
|
|
3322
3325
|
content: v.trim(),
|
|
3323
3326
|
attributes: w
|
|
@@ -3332,14 +3335,14 @@ function Ur(e) {
|
|
|
3332
3335
|
}
|
|
3333
3336
|
};
|
|
3334
3337
|
}
|
|
3335
|
-
function Wr(
|
|
3338
|
+
function Wr(t, e, n) {
|
|
3336
3339
|
var r, o, s, i;
|
|
3337
|
-
const c =
|
|
3340
|
+
const c = t.split(`
|
|
3338
3341
|
`), a = [];
|
|
3339
3342
|
let l = "", u = 0;
|
|
3340
|
-
const d =
|
|
3343
|
+
const d = e.baseIndentSize || 2;
|
|
3341
3344
|
for (; u < c.length; ) {
|
|
3342
|
-
const f = c[u], p = f.match(
|
|
3345
|
+
const f = c[u], p = f.match(e.itemPattern);
|
|
3343
3346
|
if (!p) {
|
|
3344
3347
|
if (a.length > 0)
|
|
3345
3348
|
break;
|
|
@@ -3350,7 +3353,7 @@ function Wr(e, t, n) {
|
|
|
3350
3353
|
} else
|
|
3351
3354
|
return;
|
|
3352
3355
|
}
|
|
3353
|
-
const m =
|
|
3356
|
+
const m = e.extractItemData(p), { indentLevel: h, mainContent: g } = m;
|
|
3354
3357
|
l = `${l}${f}
|
|
3355
3358
|
`;
|
|
3356
3359
|
const v = [g];
|
|
@@ -3378,9 +3381,9 @@ function Wr(e, t, n) {
|
|
|
3378
3381
|
if (w.length > 0) {
|
|
3379
3382
|
const y = w.map((S) => S.slice(h + d)).join(`
|
|
3380
3383
|
`);
|
|
3381
|
-
y.trim() && (
|
|
3384
|
+
y.trim() && (e.customNestedParser ? k = e.customNestedParser(y) : k = n.blockTokens(y));
|
|
3382
3385
|
}
|
|
3383
|
-
const M =
|
|
3386
|
+
const M = e.createToken(m, k);
|
|
3384
3387
|
a.push(M);
|
|
3385
3388
|
}
|
|
3386
3389
|
if (a.length !== 0)
|
|
@@ -3389,23 +3392,23 @@ function Wr(e, t, n) {
|
|
|
3389
3392
|
raw: l
|
|
3390
3393
|
};
|
|
3391
3394
|
}
|
|
3392
|
-
function qr(
|
|
3393
|
-
if (!
|
|
3395
|
+
function qr(t, e, n, r) {
|
|
3396
|
+
if (!t || !Array.isArray(t.content))
|
|
3394
3397
|
return "";
|
|
3395
|
-
const o = typeof n == "function" ? n(r) : n, [s, ...i] =
|
|
3398
|
+
const o = typeof n == "function" ? n(r) : n, [s, ...i] = t.content, c = e.renderChildren([s]), a = [`${o}${c}`];
|
|
3396
3399
|
return i && i.length > 0 && i.forEach((l) => {
|
|
3397
|
-
const u =
|
|
3400
|
+
const u = e.renderChildren([l]);
|
|
3398
3401
|
if (u) {
|
|
3399
3402
|
const d = u.split(`
|
|
3400
|
-
`).map((f) => f ?
|
|
3403
|
+
`).map((f) => f ? e.indent(f) : "").join(`
|
|
3401
3404
|
`);
|
|
3402
3405
|
a.push(d);
|
|
3403
3406
|
}
|
|
3404
3407
|
}), a.join(`
|
|
3405
3408
|
`);
|
|
3406
3409
|
}
|
|
3407
|
-
function Kr(
|
|
3408
|
-
const { state: r } =
|
|
3410
|
+
function Kr(t, e, n = {}) {
|
|
3411
|
+
const { state: r } = e, { doc: o, tr: s } = r, i = t;
|
|
3409
3412
|
o.descendants((c, a) => {
|
|
3410
3413
|
const l = s.mapping.map(a), u = s.mapping.map(a) + c.nodeSize;
|
|
3411
3414
|
let d = null;
|
|
@@ -3419,15 +3422,15 @@ function Kr(e, t, n = {}) {
|
|
|
3419
3422
|
if (Object.keys(n).forEach((p) => {
|
|
3420
3423
|
n[p] !== d.attrs[p] && (f = !0);
|
|
3421
3424
|
}), f) {
|
|
3422
|
-
const p =
|
|
3423
|
-
...
|
|
3425
|
+
const p = t.type.create({
|
|
3426
|
+
...t.attrs,
|
|
3424
3427
|
...n
|
|
3425
3428
|
});
|
|
3426
|
-
s.removeMark(l, u,
|
|
3429
|
+
s.removeMark(l, u, t.type), s.addMark(l, u, p);
|
|
3427
3430
|
}
|
|
3428
|
-
}), s.docChanged &&
|
|
3431
|
+
}), s.docChanged && e.view.dispatch(s);
|
|
3429
3432
|
}
|
|
3430
|
-
var
|
|
3433
|
+
var uo = class fe extends xt {
|
|
3431
3434
|
constructor() {
|
|
3432
3435
|
super(...arguments), this.type = "node";
|
|
3433
3436
|
}
|
|
@@ -3435,45 +3438,45 @@ var lo = class fe extends Mt {
|
|
|
3435
3438
|
* Create a new Node instance
|
|
3436
3439
|
* @param config - Node configuration object or a function that returns a configuration object
|
|
3437
3440
|
*/
|
|
3438
|
-
static create(
|
|
3439
|
-
const n = typeof
|
|
3441
|
+
static create(e = {}) {
|
|
3442
|
+
const n = typeof e == "function" ? e() : e;
|
|
3440
3443
|
return new fe(n);
|
|
3441
3444
|
}
|
|
3442
|
-
configure(
|
|
3443
|
-
return super.configure(
|
|
3445
|
+
configure(e) {
|
|
3446
|
+
return super.configure(e);
|
|
3444
3447
|
}
|
|
3445
|
-
extend(
|
|
3446
|
-
const n = typeof
|
|
3448
|
+
extend(e) {
|
|
3449
|
+
const n = typeof e == "function" ? e() : e;
|
|
3447
3450
|
return super.extend(n);
|
|
3448
3451
|
}
|
|
3449
3452
|
};
|
|
3450
|
-
function
|
|
3453
|
+
function fo(t) {
|
|
3451
3454
|
return new $r({
|
|
3452
|
-
find:
|
|
3453
|
-
handler: ({ state:
|
|
3454
|
-
const s = x(
|
|
3455
|
+
find: t.find,
|
|
3456
|
+
handler: ({ state: e, range: n, match: r, pasteEvent: o }) => {
|
|
3457
|
+
const s = x(t.getAttributes, void 0, r, o);
|
|
3455
3458
|
if (s === !1 || s === null)
|
|
3456
3459
|
return null;
|
|
3457
|
-
const { tr: i } =
|
|
3460
|
+
const { tr: i } = e, c = r[r.length - 1], a = r[0];
|
|
3458
3461
|
let l = n.to;
|
|
3459
3462
|
if (c) {
|
|
3460
3463
|
const u = a.search(/\S/), d = n.from + a.indexOf(c), f = d + c.length;
|
|
3461
|
-
if (Zt(n.from, n.to,
|
|
3464
|
+
if (Zt(n.from, n.to, e.doc).filter((m) => m.mark.type.excluded.find((g) => g === t.type && g !== m.mark.type)).filter((m) => m.to > d).length)
|
|
3462
3465
|
return null;
|
|
3463
|
-
f < n.to && i.delete(f, n.to), d > n.from && i.delete(n.from + u, d), l = n.from + u + c.length, i.addMark(n.from + u, l,
|
|
3466
|
+
f < n.to && i.delete(f, n.to), d > n.from && i.delete(n.from + u, d), l = n.from + u + c.length, i.addMark(n.from + u, l, t.type.create(s || {})), i.removeStoredMark(t.type);
|
|
3464
3467
|
}
|
|
3465
3468
|
}
|
|
3466
3469
|
});
|
|
3467
3470
|
}
|
|
3468
3471
|
export {
|
|
3469
3472
|
tt as CommandManager,
|
|
3470
|
-
|
|
3471
|
-
|
|
3473
|
+
io as Editor,
|
|
3474
|
+
xt as Extendable,
|
|
3472
3475
|
N as Extension,
|
|
3473
|
-
|
|
3476
|
+
Mt as InputRule,
|
|
3474
3477
|
Qt as MappablePosition,
|
|
3475
3478
|
Cr as Mark,
|
|
3476
|
-
|
|
3479
|
+
uo as Node,
|
|
3477
3480
|
Or as NodePos,
|
|
3478
3481
|
$r as PasteRule,
|
|
3479
3482
|
x as callOrReturn,
|
|
@@ -3488,22 +3491,22 @@ export {
|
|
|
3488
3491
|
V as createNodeFromContent,
|
|
3489
3492
|
_r as createStyleTag,
|
|
3490
3493
|
Fn as defaultBlockAt,
|
|
3491
|
-
|
|
3494
|
+
Ct as deleteProps,
|
|
3492
3495
|
W as elementFromString,
|
|
3493
3496
|
jr as extensions,
|
|
3494
3497
|
eo as findChildrenInRange,
|
|
3495
3498
|
qn as findDuplicates,
|
|
3496
3499
|
nt as findParentNode,
|
|
3497
3500
|
Ln as findParentNodeClosestToPos,
|
|
3498
|
-
|
|
3501
|
+
bt as flattenExtensions,
|
|
3499
3502
|
Un as fromString,
|
|
3500
3503
|
Zn as getAttributes,
|
|
3501
3504
|
Wt as getAttributesFromExtensions,
|
|
3502
3505
|
Yn as getChangedRanges,
|
|
3503
3506
|
b as getExtensionField,
|
|
3504
|
-
|
|
3507
|
+
kt as getHTMLFromFragment,
|
|
3505
3508
|
Ht as getMarkAttributes,
|
|
3506
|
-
|
|
3509
|
+
gt as getMarkRange,
|
|
3507
3510
|
B as getMarkType,
|
|
3508
3511
|
Zt as getMarksBetween,
|
|
3509
3512
|
no as getNodeAtPosition,
|
|
@@ -3519,33 +3522,34 @@ export {
|
|
|
3519
3522
|
Xn as getTextContentFromNodes,
|
|
3520
3523
|
Jt as getTextSerializersFromSchema,
|
|
3521
3524
|
er as getUpdatedPosition,
|
|
3522
|
-
|
|
3525
|
+
Pt as injectExtensionAttributesToParseRule,
|
|
3523
3526
|
Tr as inputRulesPlugin,
|
|
3524
3527
|
tr as isActive,
|
|
3525
3528
|
ln as isAndroid,
|
|
3526
3529
|
ro as isAtEndOfNode,
|
|
3527
3530
|
oo as isAtStartOfNode,
|
|
3528
3531
|
Vn as isEmptyObject,
|
|
3529
|
-
|
|
3532
|
+
It as isExtensionRulesEnabled,
|
|
3530
3533
|
Ut as isFunction,
|
|
3531
|
-
|
|
3534
|
+
Bt as isList,
|
|
3532
3535
|
Vt as isMacOS,
|
|
3533
3536
|
ut as isMarkActive,
|
|
3534
3537
|
H as isNodeActive,
|
|
3535
|
-
|
|
3538
|
+
wt as isNodeEmpty,
|
|
3539
|
+
so as isNodeSelection,
|
|
3536
3540
|
Pr as isNumber,
|
|
3537
3541
|
K as isPlainObject,
|
|
3538
|
-
|
|
3542
|
+
ht as isRegExp,
|
|
3539
3543
|
zt as isTextSelection,
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3544
|
+
vt as isiOS,
|
|
3545
|
+
ao as markInputRule,
|
|
3546
|
+
fo as markPasteRule,
|
|
3543
3547
|
zr as markdown,
|
|
3544
3548
|
Hn as mergeAttributes,
|
|
3545
3549
|
Yt as mergeDeep,
|
|
3546
3550
|
_ as minMax,
|
|
3547
3551
|
G as objectIncludes,
|
|
3548
|
-
|
|
3552
|
+
St as parseAttributes,
|
|
3549
3553
|
Wr as parseIndentedBlocks,
|
|
3550
3554
|
Rr as pasteRulesPlugin,
|
|
3551
3555
|
Qn as removeDuplicates,
|
|
@@ -3553,10 +3557,10 @@ export {
|
|
|
3553
3557
|
qt as resolveExtensions,
|
|
3554
3558
|
Ft as resolveFocusPosition,
|
|
3555
3559
|
pn as selectionToInsertionEnd,
|
|
3556
|
-
|
|
3557
|
-
|
|
3560
|
+
Et as serializeAttributes,
|
|
3561
|
+
yt as sortExtensions,
|
|
3558
3562
|
L as splitExtensions,
|
|
3559
|
-
|
|
3563
|
+
co as textblockTypeInputRule,
|
|
3560
3564
|
Kr as updateMarkViewAttributes,
|
|
3561
|
-
|
|
3565
|
+
lo as wrappingInputRule
|
|
3562
3566
|
};
|