@caspeco/casper-ui-library 9.9.0 → 9.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/index.js +5 -0
- package/dist/_virtual/index2.js +4 -0
- package/dist/_virtual/use-sync-external-store-shim.development.js +4 -0
- package/dist/_virtual/use-sync-external-store-shim.production.js +4 -0
- package/dist/_virtual/with-selector.development.js +4 -0
- package/dist/_virtual/with-selector.js +5 -0
- package/dist/_virtual/with-selector.production.js +4 -0
- package/dist/_virtual/with-selector2.js +4 -0
- package/dist/components/button/button-recipe.d.ts.map +1 -1
- package/dist/components/button/button-recipe.js +80 -39
- package/dist/components/input/input.d.ts +1 -0
- package/dist/components/input/input.d.ts.map +1 -1
- package/dist/components/input/types.d.ts +1 -1
- package/dist/components/input/types.d.ts.map +1 -1
- package/dist/components/rich-text-editor/boolean-control.d.ts +3 -0
- package/dist/components/rich-text-editor/boolean-control.d.ts.map +1 -0
- package/dist/components/rich-text-editor/boolean-control.js +35 -0
- package/dist/components/rich-text-editor/extensions.d.ts +4 -0
- package/dist/components/rich-text-editor/extensions.d.ts.map +1 -0
- package/dist/components/rich-text-editor/extensions.js +37 -0
- package/dist/components/rich-text-editor/index.d.ts +26 -0
- package/dist/components/rich-text-editor/index.d.ts.map +1 -0
- package/dist/components/rich-text-editor/index.js +23 -0
- package/dist/components/rich-text-editor/rich-text-editor-context.d.ts +10 -0
- package/dist/components/rich-text-editor/rich-text-editor-context.d.ts.map +1 -0
- package/dist/components/rich-text-editor/rich-text-editor-context.js +13 -0
- package/dist/components/rich-text-editor/rich-text-editor-control.d.ts +11 -0
- package/dist/components/rich-text-editor/rich-text-editor-control.d.ts.map +1 -0
- package/dist/components/rich-text-editor/rich-text-editor-control.js +202 -0
- package/dist/components/rich-text-editor/rich-text-editor-recipe.d.ts +4 -0
- package/dist/components/rich-text-editor/rich-text-editor-recipe.d.ts.map +1 -0
- package/dist/components/rich-text-editor/rich-text-editor-recipe.js +58 -0
- package/dist/components/rich-text-editor/rich-text-editor.composition.d.ts +6 -0
- package/dist/components/rich-text-editor/rich-text-editor.composition.d.ts.map +1 -0
- package/dist/components/rich-text-editor/rich-text-editor.d.ts +11 -0
- package/dist/components/rich-text-editor/rich-text-editor.d.ts.map +1 -0
- package/dist/components/rich-text-editor/rich-text-editor.js +60 -0
- package/dist/components/rich-text-editor/rich-text-editor.test.d.ts +2 -0
- package/dist/components/rich-text-editor/rich-text-editor.test.d.ts.map +1 -0
- package/dist/components/rich-text-editor/rich-text-editor.visual.test.d.ts +2 -0
- package/dist/components/rich-text-editor/rich-text-editor.visual.test.d.ts.map +1 -0
- package/dist/components/rich-text-editor/rich-text-renderer.d.ts +3 -0
- package/dist/components/rich-text-editor/rich-text-renderer.d.ts.map +1 -0
- package/dist/components/rich-text-editor/rich-text-renderer.js +21 -0
- package/dist/components/rich-text-editor/translations.d.ts +23 -0
- package/dist/components/rich-text-editor/translations.d.ts.map +1 -0
- package/dist/components/rich-text-editor/translations.js +120 -0
- package/dist/components/rich-text-editor/types.d.ts +30 -0
- package/dist/components/rich-text-editor/types.d.ts.map +1 -0
- package/dist/components/rich-text-editor/use-rich-text-editor.d.ts +3 -0
- package/dist/components/rich-text-editor/use-rich-text-editor.d.ts.map +1 -0
- package/dist/components/rich-text-editor/use-rich-text-editor.js +17 -0
- package/dist/components/table/table-header-dropdown.d.ts.map +1 -1
- package/dist/components/table/table-header-dropdown.js +68 -66
- package/dist/components/toggle-button/toggle-button.d.ts.map +1 -1
- package/dist/components/toggle-button/toggle-button.js +11 -11
- package/dist/components/toggle-button/types.d.ts +2 -0
- package/dist/components/toggle-button/types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +774 -763
- package/dist/node_modules/@tanstack/react-virtual/dist/esm/index.js +83 -31
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/index.js +411 -226
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/lazy-measurements.js +33 -0
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/utils.js +29 -28
- package/dist/node_modules/@tiptap/core/dist/index.js +3953 -0
- package/dist/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js +19 -0
- package/dist/node_modules/@tiptap/extension-blockquote/dist/index.js +62 -0
- package/dist/node_modules/@tiptap/extension-bold/dist/index.js +85 -0
- package/dist/node_modules/@tiptap/extension-code/dist/index.js +54 -0
- package/dist/node_modules/@tiptap/extension-code-block/dist/index.js +219 -0
- package/dist/node_modules/@tiptap/extension-document/dist/index.js +12 -0
- package/dist/node_modules/@tiptap/extension-hard-break/dist/index.js +61 -0
- package/dist/node_modules/@tiptap/extension-heading/dist/index.js +67 -0
- package/dist/node_modules/@tiptap/extension-horizontal-rule/dist/index.js +56 -0
- package/dist/node_modules/@tiptap/extension-italic/dist/index.js +83 -0
- package/dist/node_modules/@tiptap/extension-link/dist/index.js +341 -0
- package/dist/node_modules/@tiptap/extension-list/dist/index.js +796 -0
- package/dist/node_modules/@tiptap/extension-paragraph/dist/index.js +49 -0
- package/dist/node_modules/@tiptap/extension-strike/dist/index.js +66 -0
- package/dist/node_modules/@tiptap/extension-text/dist/index.js +13 -0
- package/dist/node_modules/@tiptap/extension-underline/dist/index.js +65 -0
- package/dist/node_modules/@tiptap/extensions/dist/index.js +446 -0
- package/dist/node_modules/@tiptap/starter-kit/dist/index.js +28 -0
- package/dist/node_modules/fast-equals/dist/es/index.js +324 -0
- package/dist/node_modules/linkifyjs/dist/linkify.js +705 -0
- package/dist/node_modules/orderedmap/dist/index.js +103 -0
- package/dist/node_modules/prosemirror-commands/dist/index.js +388 -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/prosemirror-keymap/dist/index.js +62 -0
- package/dist/node_modules/prosemirror-model/dist/index.js +2736 -0
- package/dist/node_modules/prosemirror-schema-list/dist/index.js +88 -0
- package/dist/node_modules/prosemirror-state/dist/index.js +822 -0
- package/dist/node_modules/prosemirror-transform/dist/index.js +1552 -0
- package/dist/node_modules/prosemirror-view/dist/index.js +3802 -0
- package/dist/node_modules/rope-sequence/dist/index.js +100 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +58 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js +57 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +58 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +46 -0
- package/dist/node_modules/use-sync-external-store/shim/index.js +10 -0
- package/dist/node_modules/use-sync-external-store/shim/with-selector.js +10 -0
- package/dist/node_modules/w3c-keyname/index.js +93 -0
- package/dist/packages/casper-ui-library/node_modules/@tiptap/react/dist/index.js +506 -0
- package/package.json +14 -8
|
@@ -0,0 +1,3953 @@
|
|
|
1
|
+
import { findWrapping as ye, canJoin as bt, Transform as ke, RemoveMarkStep as we, liftTarget as xe, joinPoint as Lt, canSplit as X, ReplaceStep as Me, ReplaceAroundStep as Se } from "../../../prosemirror-transform/dist/index.js";
|
|
2
|
+
import { createParagraphNear as Ee, exitCode as Te, joinUp as Ae, joinDown as Ce, joinBackward as Pe, joinForward as $e, joinTextblockBackward as Ne, joinTextblockForward as Ie, lift as Oe, liftEmptyBlock as Re, newlineInCode as Be, selectNodeBackward as De, selectNodeForward as je, selectParentNode as _e, selectTextblockEnd as Le, selectTextblockStart as ze, setBlockType as Ct, wrapIn as Fe } from "../../../prosemirror-commands/dist/index.js";
|
|
3
|
+
import { NodeSelection as st, EditorState as Ve, Selection as F, TextSelection as O, Plugin as R, PluginKey as _, AllSelection as He } from "../../../prosemirror-state/dist/index.js";
|
|
4
|
+
import { Node as zt, DOMParser as tt, DOMSerializer as We, Schema as Ft, Fragment as j, Slice as Ue } from "../../../prosemirror-model/dist/index.js";
|
|
5
|
+
import { liftListItem as qe, sinkListItem as Je, wrapInList as Ke } from "../../../prosemirror-schema-list/dist/index.js";
|
|
6
|
+
import { EditorView as Qe } from "../../../prosemirror-view/dist/index.js";
|
|
7
|
+
import { keymap as Ze } from "../../../prosemirror-keymap/dist/index.js";
|
|
8
|
+
var Ge = Object.defineProperty, yt = (t, e) => {
|
|
9
|
+
for (var n in e)
|
|
10
|
+
Ge(t, n, { get: e[n], enumerable: !0 });
|
|
11
|
+
};
|
|
12
|
+
function it(t) {
|
|
13
|
+
const { state: e, transaction: n } = t;
|
|
14
|
+
let { selection: r } = n, { doc: o } = n, { storedMarks: s } = n;
|
|
15
|
+
return {
|
|
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
|
+
get storedMarks() {
|
|
24
|
+
return s;
|
|
25
|
+
},
|
|
26
|
+
get selection() {
|
|
27
|
+
return r;
|
|
28
|
+
},
|
|
29
|
+
get doc() {
|
|
30
|
+
return o;
|
|
31
|
+
},
|
|
32
|
+
get tr() {
|
|
33
|
+
return r = n.selection, o = n.doc, s = n.storedMarks, n;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
var at = class {
|
|
38
|
+
constructor(t) {
|
|
39
|
+
this.editor = t.editor, this.rawCommands = this.editor.extensionManager.commands, this.customState = t.state;
|
|
40
|
+
}
|
|
41
|
+
get hasCustomState() {
|
|
42
|
+
return !!this.customState;
|
|
43
|
+
}
|
|
44
|
+
get state() {
|
|
45
|
+
return this.customState || this.editor.state;
|
|
46
|
+
}
|
|
47
|
+
get commands() {
|
|
48
|
+
const { rawCommands: t, editor: e, state: n } = this, { view: r } = e, { tr: o } = n, s = this.buildProps(o);
|
|
49
|
+
return Object.fromEntries(
|
|
50
|
+
Object.entries(t).map(([i, c]) => [i, (...l) => {
|
|
51
|
+
const f = c(...l)(s);
|
|
52
|
+
return !o.getMeta("preventDispatch") && !this.hasCustomState && r.dispatch(o), f;
|
|
53
|
+
}])
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
get chain() {
|
|
57
|
+
return () => this.createChain();
|
|
58
|
+
}
|
|
59
|
+
get can() {
|
|
60
|
+
return () => this.createCan();
|
|
61
|
+
}
|
|
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((u) => u === !0)), f = {
|
|
64
|
+
...Object.fromEntries(
|
|
65
|
+
Object.entries(n).map(([u, p]) => [u, (...h) => {
|
|
66
|
+
const m = this.buildProps(a, e), g = p(...h)(m);
|
|
67
|
+
return i.push(g), f;
|
|
68
|
+
}])
|
|
69
|
+
),
|
|
70
|
+
run: l
|
|
71
|
+
};
|
|
72
|
+
return f;
|
|
73
|
+
}
|
|
74
|
+
createCan(t) {
|
|
75
|
+
const { rawCommands: e, state: n } = this, r = !1, o = t || n.tr, s = this.buildProps(o, r);
|
|
76
|
+
return {
|
|
77
|
+
...Object.fromEntries(
|
|
78
|
+
Object.entries(e).map(([c, a]) => [c, (...l) => a(...l)({ ...s, dispatch: void 0 })])
|
|
79
|
+
),
|
|
80
|
+
chain: () => this.createChain(o, r)
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
buildProps(t, e = !0) {
|
|
84
|
+
const { rawCommands: n, editor: r, state: o } = this, { view: s } = r, i = {
|
|
85
|
+
tr: t,
|
|
86
|
+
editor: r,
|
|
87
|
+
view: s,
|
|
88
|
+
state: it({
|
|
89
|
+
state: o,
|
|
90
|
+
transaction: t
|
|
91
|
+
}),
|
|
92
|
+
dispatch: e ? () => {
|
|
93
|
+
} : void 0,
|
|
94
|
+
chain: () => this.createChain(t, e),
|
|
95
|
+
can: () => this.createCan(t),
|
|
96
|
+
get commands() {
|
|
97
|
+
return Object.fromEntries(
|
|
98
|
+
Object.entries(n).map(([c, a]) => [c, (...l) => a(...l)(i)])
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
return i;
|
|
103
|
+
}
|
|
104
|
+
}, Vt = {};
|
|
105
|
+
yt(Vt, {
|
|
106
|
+
blur: () => Ye,
|
|
107
|
+
clearContent: () => Xe,
|
|
108
|
+
clearNodes: () => tn,
|
|
109
|
+
command: () => en,
|
|
110
|
+
createParagraphNear: () => nn,
|
|
111
|
+
cut: () => rn,
|
|
112
|
+
deleteCurrentNode: () => on,
|
|
113
|
+
deleteNode: () => sn,
|
|
114
|
+
deleteRange: () => an,
|
|
115
|
+
deleteSelection: () => un,
|
|
116
|
+
enter: () => dn,
|
|
117
|
+
exitCode: () => fn,
|
|
118
|
+
extendMarkRange: () => pn,
|
|
119
|
+
first: () => mn,
|
|
120
|
+
focus: () => gn,
|
|
121
|
+
forEach: () => vn,
|
|
122
|
+
insertContent: () => bn,
|
|
123
|
+
insertContentAt: () => wn,
|
|
124
|
+
joinBackward: () => Sn,
|
|
125
|
+
joinDown: () => Mn,
|
|
126
|
+
joinForward: () => En,
|
|
127
|
+
joinItemBackward: () => Tn,
|
|
128
|
+
joinItemForward: () => An,
|
|
129
|
+
joinTextblockBackward: () => Cn,
|
|
130
|
+
joinTextblockForward: () => Pn,
|
|
131
|
+
joinUp: () => xn,
|
|
132
|
+
keyboardShortcut: () => Nn,
|
|
133
|
+
lift: () => In,
|
|
134
|
+
liftEmptyBlock: () => On,
|
|
135
|
+
liftListItem: () => Rn,
|
|
136
|
+
newlineInCode: () => Bn,
|
|
137
|
+
resetAttributes: () => Dn,
|
|
138
|
+
scrollIntoView: () => jn,
|
|
139
|
+
selectAll: () => _n,
|
|
140
|
+
selectNodeBackward: () => Ln,
|
|
141
|
+
selectNodeForward: () => zn,
|
|
142
|
+
selectParentNode: () => Fn,
|
|
143
|
+
selectTextblockEnd: () => Vn,
|
|
144
|
+
selectTextblockStart: () => Hn,
|
|
145
|
+
setContent: () => Wn,
|
|
146
|
+
setMark: () => ur,
|
|
147
|
+
setMeta: () => dr,
|
|
148
|
+
setNode: () => fr,
|
|
149
|
+
setNodeSelection: () => pr,
|
|
150
|
+
setTextDirection: () => mr,
|
|
151
|
+
setTextSelection: () => hr,
|
|
152
|
+
sinkListItem: () => gr,
|
|
153
|
+
splitBlock: () => vr,
|
|
154
|
+
splitListItem: () => br,
|
|
155
|
+
toggleList: () => kr,
|
|
156
|
+
toggleMark: () => wr,
|
|
157
|
+
toggleNode: () => xr,
|
|
158
|
+
toggleWrap: () => Mr,
|
|
159
|
+
undoInputRule: () => Sr,
|
|
160
|
+
unsetAllMarks: () => Er,
|
|
161
|
+
unsetMark: () => Tr,
|
|
162
|
+
unsetTextDirection: () => Ar,
|
|
163
|
+
updateAttributes: () => Cr,
|
|
164
|
+
wrapIn: () => Pr,
|
|
165
|
+
wrapInList: () => $r
|
|
166
|
+
});
|
|
167
|
+
var Ye = () => ({ editor: t, view: e }) => (requestAnimationFrame(() => {
|
|
168
|
+
var n;
|
|
169
|
+
t.isDestroyed || (e.dom.blur(), (n = window?.getSelection()) == null || n.removeAllRanges());
|
|
170
|
+
}), !0), Xe = (t = !0) => ({ commands: e }) => e.setContent("", { emitUpdate: t }), tn = () => ({ state: t, tr: e, dispatch: n }) => {
|
|
171
|
+
const { selection: r } = e, { ranges: o } = r;
|
|
172
|
+
return n && o.forEach(({ $from: s, $to: i }) => {
|
|
173
|
+
t.doc.nodesBetween(s.pos, i.pos, (c, a) => {
|
|
174
|
+
if (c.type.isText)
|
|
175
|
+
return;
|
|
176
|
+
const { doc: l, mapping: f } = e, u = l.resolve(f.map(a)), p = l.resolve(f.map(a + c.nodeSize)), d = u.blockRange(p);
|
|
177
|
+
if (!d)
|
|
178
|
+
return;
|
|
179
|
+
const h = xe(d);
|
|
180
|
+
if (c.type.isTextblock) {
|
|
181
|
+
const { defaultType: m } = u.parent.contentMatchAt(u.index());
|
|
182
|
+
e.setNodeMarkup(d.start, m);
|
|
183
|
+
}
|
|
184
|
+
(h || h === 0) && e.lift(d, h);
|
|
185
|
+
});
|
|
186
|
+
}), !0;
|
|
187
|
+
}, en = (t) => (e) => t(e), nn = () => ({ state: t, dispatch: e }) => Ee(t, e), rn = (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
|
+
return r.insert(i, s.content), r.setSelection(new O(r.doc.resolve(Math.max(i - 1, 0)))), !0;
|
|
192
|
+
}, on = () => ({ tr: t, dispatch: e }) => {
|
|
193
|
+
const { selection: n } = t, r = n.$anchor.node();
|
|
194
|
+
if (r.content.size > 0)
|
|
195
|
+
return !1;
|
|
196
|
+
const o = t.selection.$anchor;
|
|
197
|
+
for (let s = o.depth; s > 0; s -= 1)
|
|
198
|
+
if (o.node(s).type === r.type) {
|
|
199
|
+
if (e) {
|
|
200
|
+
const c = o.before(s), a = o.after(s);
|
|
201
|
+
t.delete(c, a).scrollIntoView();
|
|
202
|
+
}
|
|
203
|
+
return !0;
|
|
204
|
+
}
|
|
205
|
+
return !1;
|
|
206
|
+
};
|
|
207
|
+
function T(t, e) {
|
|
208
|
+
if (typeof t == "string") {
|
|
209
|
+
if (!e.nodes[t])
|
|
210
|
+
throw Error(
|
|
211
|
+
`There is no node type named '${t}'. Maybe you forgot to add the extension?`
|
|
212
|
+
);
|
|
213
|
+
return e.nodes[t];
|
|
214
|
+
}
|
|
215
|
+
return t;
|
|
216
|
+
}
|
|
217
|
+
var sn = (t) => ({ tr: e, state: n, dispatch: r }) => {
|
|
218
|
+
const o = T(t, n.schema), s = e.selection.$anchor;
|
|
219
|
+
for (let i = s.depth; i > 0; i -= 1)
|
|
220
|
+
if (s.node(i).type === o) {
|
|
221
|
+
if (r) {
|
|
222
|
+
const a = s.before(i), l = s.after(i);
|
|
223
|
+
e.delete(a, l).scrollIntoView();
|
|
224
|
+
}
|
|
225
|
+
return !0;
|
|
226
|
+
}
|
|
227
|
+
return !1;
|
|
228
|
+
}, an = (t) => ({ tr: e, dispatch: n }) => {
|
|
229
|
+
const { from: r, to: o } = t;
|
|
230
|
+
return n && e.delete(r, o), !0;
|
|
231
|
+
}, cn = (t) => t.content ? /^text(\*|\+)/.test(t.content) : !1, Pt = (t, e, n) => {
|
|
232
|
+
if (!t.parent.isInline || n === "left" && t.pos > t.start() || n === "right" && t.pos < t.end())
|
|
233
|
+
return t.pos;
|
|
234
|
+
const r = e.nodes[t.parent.type.name].spec;
|
|
235
|
+
return cn(r) ? n === "left" ? t.start() - 1 : t.end() + 1 : t.pos;
|
|
236
|
+
}, ln = (t, e, n) => {
|
|
237
|
+
const r = Pt(t, n, "left"), o = Pt(e, n, "right");
|
|
238
|
+
return { from: r, to: o };
|
|
239
|
+
}, un = () => ({ state: t, dispatch: e }) => {
|
|
240
|
+
const { $from: n, $to: r } = t.selection;
|
|
241
|
+
if (t.selection.empty)
|
|
242
|
+
return !1;
|
|
243
|
+
const { from: o, to: s } = ln(n, r, t.schema);
|
|
244
|
+
return e && (t.tr.deleteRange(o, s).scrollIntoView(), e(t.tr)), !0;
|
|
245
|
+
}, dn = () => ({ commands: t }) => t.keyboardShortcut("Enter"), fn = () => ({ state: t, dispatch: e }) => Te(t, e);
|
|
246
|
+
function kt(t) {
|
|
247
|
+
return Object.prototype.toString.call(t) === "[object RegExp]";
|
|
248
|
+
}
|
|
249
|
+
function nt(t, e, n = { strict: !0 }) {
|
|
250
|
+
const r = Object.keys(e);
|
|
251
|
+
return r.length ? r.every((o) => n.strict ? e[o] === t[o] : kt(e[o]) ? e[o].test(t[o]) : e[o] === t[o]) : !0;
|
|
252
|
+
}
|
|
253
|
+
function Ht(t, e, n = {}) {
|
|
254
|
+
return t.find((r) => r.type === e && nt(
|
|
255
|
+
// Only check equality for the attributes that are provided
|
|
256
|
+
Object.fromEntries(Object.keys(n).map((o) => [o, r.attrs[o]])),
|
|
257
|
+
n
|
|
258
|
+
));
|
|
259
|
+
}
|
|
260
|
+
function $t(t, e, n = {}) {
|
|
261
|
+
return !!Ht(t, e, n);
|
|
262
|
+
}
|
|
263
|
+
function wt(t, e, n) {
|
|
264
|
+
if (!t || !e)
|
|
265
|
+
return;
|
|
266
|
+
let r = t.parent.childAfter(t.parentOffset);
|
|
267
|
+
if ((!r.node || !r.node.marks.some((l) => l.type === e)) && (r = t.parent.childBefore(t.parentOffset)), !r.node || !r.node.marks.some((l) => l.type === e))
|
|
268
|
+
return;
|
|
269
|
+
if (!n) {
|
|
270
|
+
const l = r.node.marks.find((f) => f.type === e);
|
|
271
|
+
l && (n = l.attrs);
|
|
272
|
+
}
|
|
273
|
+
if (!Ht([...r.node.marks], e, n))
|
|
274
|
+
return;
|
|
275
|
+
let s = r.index, i = t.start() + r.offset, c = s + 1, a = i + r.node.nodeSize;
|
|
276
|
+
for (; s > 0 && $t([...t.parent.child(s - 1).marks], e, n); )
|
|
277
|
+
s -= 1, i -= t.parent.child(s).nodeSize;
|
|
278
|
+
for (; c < t.parent.childCount && $t([...t.parent.child(c).marks], e, n); )
|
|
279
|
+
a += t.parent.child(c).nodeSize, c += 1;
|
|
280
|
+
return {
|
|
281
|
+
from: i,
|
|
282
|
+
to: a
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
function D(t, e) {
|
|
286
|
+
if (typeof t == "string") {
|
|
287
|
+
if (!e.marks[t])
|
|
288
|
+
throw Error(
|
|
289
|
+
`There is no mark type named '${t}'. Maybe you forgot to add the extension?`
|
|
290
|
+
);
|
|
291
|
+
return e.marks[t];
|
|
292
|
+
}
|
|
293
|
+
return t;
|
|
294
|
+
}
|
|
295
|
+
var pn = (t, e) => ({ tr: n, state: r, dispatch: o }) => {
|
|
296
|
+
const s = D(t, r.schema), { doc: i, selection: c } = n, { $from: a, from: l, to: f } = c;
|
|
297
|
+
if (o) {
|
|
298
|
+
const u = wt(a, s, e);
|
|
299
|
+
if (u && u.from <= l && u.to >= f) {
|
|
300
|
+
const p = O.create(i, u.from, u.to);
|
|
301
|
+
n.setSelection(p);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return !0;
|
|
305
|
+
}, mn = (t) => (e) => {
|
|
306
|
+
const n = typeof t == "function" ? t(e) : t;
|
|
307
|
+
for (let r = 0; r < n.length; r += 1)
|
|
308
|
+
if (n[r](e))
|
|
309
|
+
return !0;
|
|
310
|
+
return !1;
|
|
311
|
+
};
|
|
312
|
+
function Wt(t) {
|
|
313
|
+
return t instanceof O;
|
|
314
|
+
}
|
|
315
|
+
function z(t = 0, e = 0, n = 0) {
|
|
316
|
+
return Math.min(Math.max(t, e), n);
|
|
317
|
+
}
|
|
318
|
+
function Ut(t, e = null) {
|
|
319
|
+
if (!e)
|
|
320
|
+
return null;
|
|
321
|
+
const n = F.atStart(t), r = F.atEnd(t);
|
|
322
|
+
if (e === "start" || e === !0)
|
|
323
|
+
return n;
|
|
324
|
+
if (e === "end")
|
|
325
|
+
return r;
|
|
326
|
+
const o = n.from, s = r.to;
|
|
327
|
+
return e === "all" ? O.create(
|
|
328
|
+
t,
|
|
329
|
+
z(0, o, s),
|
|
330
|
+
z(t.content.size, o, s)
|
|
331
|
+
) : O.create(
|
|
332
|
+
t,
|
|
333
|
+
z(e, o, s),
|
|
334
|
+
z(e, o, s)
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
function Nt() {
|
|
338
|
+
return navigator.platform === "Android" || /android/i.test(navigator.userAgent);
|
|
339
|
+
}
|
|
340
|
+
function rt() {
|
|
341
|
+
return ["iPad Simulator", "iPhone Simulator", "iPod Simulator", "iPad", "iPhone", "iPod"].includes(
|
|
342
|
+
navigator.platform
|
|
343
|
+
) || // iPad on iOS 13 detection
|
|
344
|
+
navigator.userAgent.includes("Mac") && "ontouchend" in document;
|
|
345
|
+
}
|
|
346
|
+
function hn() {
|
|
347
|
+
return typeof navigator < "u" ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent) : !1;
|
|
348
|
+
}
|
|
349
|
+
var gn = (t = null, e = {}) => ({ editor: n, view: r, tr: o, dispatch: s }) => {
|
|
350
|
+
e = {
|
|
351
|
+
scrollIntoView: !0,
|
|
352
|
+
...e
|
|
353
|
+
};
|
|
354
|
+
const i = () => {
|
|
355
|
+
(rt() || Nt()) && r.dom.focus(), hn() && !rt() && !Nt() && r.dom.focus({ preventScroll: !0 }), requestAnimationFrame(() => {
|
|
356
|
+
n.isDestroyed || (r.focus(), e?.scrollIntoView && n.commands.scrollIntoView());
|
|
357
|
+
});
|
|
358
|
+
};
|
|
359
|
+
try {
|
|
360
|
+
if (r.hasFocus() && t === null || t === !1)
|
|
361
|
+
return !0;
|
|
362
|
+
} catch {
|
|
363
|
+
return !1;
|
|
364
|
+
}
|
|
365
|
+
if (s && t === null && !Wt(n.state.selection))
|
|
366
|
+
return i(), !0;
|
|
367
|
+
const c = Ut(o.doc, t) || n.state.selection, a = n.state.selection.eq(c);
|
|
368
|
+
return s && (a || o.setSelection(c), a && o.storedMarks && o.setStoredMarks(o.storedMarks), i()), !0;
|
|
369
|
+
}, vn = (t, e) => (n) => t.every((r, o) => e(r, { ...n, index: o })), bn = (t, e) => ({ tr: n, commands: r }) => r.insertContentAt(
|
|
370
|
+
{ from: n.selection.from, to: n.selection.to },
|
|
371
|
+
t,
|
|
372
|
+
e
|
|
373
|
+
), qt = (t) => {
|
|
374
|
+
const e = t.childNodes;
|
|
375
|
+
for (let n = e.length - 1; n >= 0; n -= 1) {
|
|
376
|
+
const r = e[n];
|
|
377
|
+
r.nodeType === 3 && r.nodeValue && /^(\n\s\s|\n)$/.test(r.nodeValue) ? t.removeChild(r) : r.nodeType === 1 && qt(r);
|
|
378
|
+
}
|
|
379
|
+
return t;
|
|
380
|
+
};
|
|
381
|
+
function U(t) {
|
|
382
|
+
if (typeof window > "u")
|
|
383
|
+
throw new Error(
|
|
384
|
+
"[tiptap error]: there is no window object available, so this function cannot be used"
|
|
385
|
+
);
|
|
386
|
+
const e = `<body>${t}</body>`, n = new window.DOMParser().parseFromString(e, "text/html").body;
|
|
387
|
+
return qt(n);
|
|
388
|
+
}
|
|
389
|
+
function K(t, e, n) {
|
|
390
|
+
if (t instanceof zt || t instanceof j)
|
|
391
|
+
return t;
|
|
392
|
+
n = {
|
|
393
|
+
slice: !0,
|
|
394
|
+
parseOptions: {},
|
|
395
|
+
...n
|
|
396
|
+
};
|
|
397
|
+
const r = typeof t == "object" && t !== null, o = typeof t == "string";
|
|
398
|
+
if (r)
|
|
399
|
+
try {
|
|
400
|
+
if (Array.isArray(t) && t.length > 0)
|
|
401
|
+
return j.fromArray(t.map((c) => e.nodeFromJSON(c)));
|
|
402
|
+
const i = e.nodeFromJSON(t);
|
|
403
|
+
return n.errorOnInvalidContent && i.check(), i;
|
|
404
|
+
} catch (s) {
|
|
405
|
+
if (n.errorOnInvalidContent)
|
|
406
|
+
throw new Error("[tiptap error]: Invalid JSON content", { cause: s });
|
|
407
|
+
return console.warn("[tiptap warn]: Invalid content.", "Passed value:", t, "Error:", s), K("", e, n);
|
|
408
|
+
}
|
|
409
|
+
if (o) {
|
|
410
|
+
if (n.errorOnInvalidContent) {
|
|
411
|
+
let i = !1, c = "";
|
|
412
|
+
const a = new Ft({
|
|
413
|
+
topNode: e.spec.topNode,
|
|
414
|
+
marks: e.spec.marks,
|
|
415
|
+
// Prosemirror's schemas are executed such that: the last to execute, matches last
|
|
416
|
+
// 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
|
|
417
|
+
nodes: e.spec.nodes.append({
|
|
418
|
+
__tiptap__private__unknown__catch__all__node: {
|
|
419
|
+
content: "inline*",
|
|
420
|
+
group: "block",
|
|
421
|
+
parseDOM: [
|
|
422
|
+
{
|
|
423
|
+
tag: "*",
|
|
424
|
+
getAttrs: (l) => (i = !0, c = typeof l == "string" ? l : l.outerHTML, null)
|
|
425
|
+
}
|
|
426
|
+
]
|
|
427
|
+
}
|
|
428
|
+
})
|
|
429
|
+
});
|
|
430
|
+
if (n.slice ? tt.fromSchema(a).parseSlice(
|
|
431
|
+
U(t),
|
|
432
|
+
n.parseOptions
|
|
433
|
+
) : tt.fromSchema(a).parse(
|
|
434
|
+
U(t),
|
|
435
|
+
n.parseOptions
|
|
436
|
+
), n.errorOnInvalidContent && i)
|
|
437
|
+
throw new Error("[tiptap error]: Invalid HTML content", {
|
|
438
|
+
cause: new Error(`Invalid element found: ${c}`)
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
const s = tt.fromSchema(e);
|
|
442
|
+
return n.slice ? s.parseSlice(U(t), n.parseOptions).content : s.parse(U(t), n.parseOptions);
|
|
443
|
+
}
|
|
444
|
+
return K("", e, n);
|
|
445
|
+
}
|
|
446
|
+
function yn(t, e, n) {
|
|
447
|
+
const r = t.steps.length - 1;
|
|
448
|
+
if (r < e)
|
|
449
|
+
return;
|
|
450
|
+
const o = t.steps[r];
|
|
451
|
+
if (!(o instanceof Me || o instanceof Se))
|
|
452
|
+
return;
|
|
453
|
+
const s = t.mapping.maps[r];
|
|
454
|
+
let i = 0;
|
|
455
|
+
s.forEach((c, a, l, f) => {
|
|
456
|
+
i === 0 && (i = f);
|
|
457
|
+
}), t.setSelection(F.near(t.doc.resolve(i), n));
|
|
458
|
+
}
|
|
459
|
+
var kn = (t) => !("type" in t), wn = (t, e, n) => ({ tr: r, dispatch: o, editor: s }) => {
|
|
460
|
+
var i;
|
|
461
|
+
if (o) {
|
|
462
|
+
n = {
|
|
463
|
+
parseOptions: s.options.parseOptions,
|
|
464
|
+
updateSelection: !0,
|
|
465
|
+
applyInputRules: !1,
|
|
466
|
+
applyPasteRules: !1,
|
|
467
|
+
...n
|
|
468
|
+
};
|
|
469
|
+
let c;
|
|
470
|
+
const a = (g) => {
|
|
471
|
+
s.emit("contentError", {
|
|
472
|
+
editor: s,
|
|
473
|
+
error: g,
|
|
474
|
+
disableCollaboration: () => {
|
|
475
|
+
"collaboration" in s.storage && typeof s.storage.collaboration == "object" && s.storage.collaboration && (s.storage.collaboration.isDisabled = !0);
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
}, l = {
|
|
479
|
+
preserveWhitespace: "full",
|
|
480
|
+
...n.parseOptions
|
|
481
|
+
};
|
|
482
|
+
if (!n.errorOnInvalidContent && !s.options.enableContentCheck && s.options.emitContentError)
|
|
483
|
+
try {
|
|
484
|
+
K(e, s.schema, {
|
|
485
|
+
parseOptions: l,
|
|
486
|
+
errorOnInvalidContent: !0
|
|
487
|
+
});
|
|
488
|
+
} catch (g) {
|
|
489
|
+
a(g);
|
|
490
|
+
}
|
|
491
|
+
try {
|
|
492
|
+
c = K(e, s.schema, {
|
|
493
|
+
parseOptions: l,
|
|
494
|
+
errorOnInvalidContent: (i = n.errorOnInvalidContent) != null ? i : s.options.enableContentCheck
|
|
495
|
+
});
|
|
496
|
+
} catch (g) {
|
|
497
|
+
return a(g), !1;
|
|
498
|
+
}
|
|
499
|
+
let { from: f, to: u } = typeof t == "number" ? { from: t, to: t } : { from: t.from, to: t.to }, p = !0, d = !0;
|
|
500
|
+
if ((kn(c) ? c : [c]).forEach((g) => {
|
|
501
|
+
g.check(), p = p ? g.isText && g.marks.length === 0 : !1, d = d ? g.isBlock : !1;
|
|
502
|
+
}), f === u && d) {
|
|
503
|
+
const { parent: g } = r.doc.resolve(f);
|
|
504
|
+
g.isTextblock && !g.type.spec.code && !g.childCount && (f -= 1, u += 1);
|
|
505
|
+
}
|
|
506
|
+
let m;
|
|
507
|
+
if (p) {
|
|
508
|
+
if (Array.isArray(e))
|
|
509
|
+
m = e.map((g) => g.text || "").join("");
|
|
510
|
+
else if (e instanceof j) {
|
|
511
|
+
let g = "";
|
|
512
|
+
e.forEach((v) => {
|
|
513
|
+
v.text && (g += v.text);
|
|
514
|
+
}), m = g;
|
|
515
|
+
} else typeof e == "object" && e && e.text ? m = e.text : m = e;
|
|
516
|
+
r.insertText(m, f, u);
|
|
517
|
+
} else {
|
|
518
|
+
m = c;
|
|
519
|
+
const g = r.doc.resolve(f), v = g.node(), y = g.parentOffset === 0, w = v.isText || v.isTextblock, x = v.content.size > 0;
|
|
520
|
+
y && w && x && d && (f = Math.max(0, f - 1)), r.replaceWith(f, u, m);
|
|
521
|
+
}
|
|
522
|
+
n.updateSelection && yn(r, r.steps.length - 1, -1), n.applyInputRules && r.setMeta("applyInputRules", { from: f, text: m }), n.applyPasteRules && r.setMeta("applyPasteRules", { from: f, text: m });
|
|
523
|
+
}
|
|
524
|
+
return !0;
|
|
525
|
+
}, xn = () => ({ state: t, dispatch: e }) => Ae(t, e), Mn = () => ({ state: t, dispatch: e }) => Ce(t, e), Sn = () => ({ state: t, dispatch: e }) => Pe(t, e), En = () => ({ state: t, dispatch: e }) => $e(t, e), Tn = () => ({ state: t, dispatch: e, tr: n }) => {
|
|
526
|
+
try {
|
|
527
|
+
const r = Lt(t.doc, t.selection.$from.pos, -1);
|
|
528
|
+
return r == null ? !1 : (n.join(r, 2), e && e(n), !0);
|
|
529
|
+
} catch {
|
|
530
|
+
return !1;
|
|
531
|
+
}
|
|
532
|
+
}, An = () => ({ state: t, dispatch: e, tr: n }) => {
|
|
533
|
+
try {
|
|
534
|
+
const r = Lt(t.doc, t.selection.$from.pos, 1);
|
|
535
|
+
return r == null ? !1 : (n.join(r, 2), e && e(n), !0);
|
|
536
|
+
} catch {
|
|
537
|
+
return !1;
|
|
538
|
+
}
|
|
539
|
+
}, Cn = () => ({ state: t, dispatch: e }) => Ne(t, e), Pn = () => ({ state: t, dispatch: e }) => Ie(t, e);
|
|
540
|
+
function Jt() {
|
|
541
|
+
return typeof navigator < "u" ? /Mac/.test(navigator.platform) : !1;
|
|
542
|
+
}
|
|
543
|
+
function $n(t) {
|
|
544
|
+
const e = t.split(/-(?!$)/);
|
|
545
|
+
let n = e[e.length - 1];
|
|
546
|
+
n === "Space" && (n = " ");
|
|
547
|
+
let r, o, s, i;
|
|
548
|
+
for (let c = 0; c < e.length - 1; c += 1) {
|
|
549
|
+
const a = e[c];
|
|
550
|
+
if (/^(cmd|meta|m)$/i.test(a))
|
|
551
|
+
i = !0;
|
|
552
|
+
else if (/^a(lt)?$/i.test(a))
|
|
553
|
+
r = !0;
|
|
554
|
+
else if (/^(c|ctrl|control)$/i.test(a))
|
|
555
|
+
o = !0;
|
|
556
|
+
else if (/^s(hift)?$/i.test(a))
|
|
557
|
+
s = !0;
|
|
558
|
+
else if (/^mod$/i.test(a))
|
|
559
|
+
rt() || Jt() ? i = !0 : o = !0;
|
|
560
|
+
else
|
|
561
|
+
throw new Error(`Unrecognized modifier name: ${a}`);
|
|
562
|
+
}
|
|
563
|
+
return r && (n = `Alt-${n}`), o && (n = `Ctrl-${n}`), i && (n = `Meta-${n}`), s && (n = `Shift-${n}`), n;
|
|
564
|
+
}
|
|
565
|
+
var Nn = (t) => ({ editor: e, view: n, tr: r, dispatch: o }) => {
|
|
566
|
+
const s = $n(t).split(/-(?!$)/), i = s.find((l) => !["Alt", "Ctrl", "Meta", "Shift"].includes(l)), c = new KeyboardEvent("keydown", {
|
|
567
|
+
key: i === "Space" ? " " : i,
|
|
568
|
+
altKey: s.includes("Alt"),
|
|
569
|
+
ctrlKey: s.includes("Ctrl"),
|
|
570
|
+
metaKey: s.includes("Meta"),
|
|
571
|
+
shiftKey: s.includes("Shift"),
|
|
572
|
+
bubbles: !0,
|
|
573
|
+
cancelable: !0
|
|
574
|
+
}), a = e.captureTransaction(() => {
|
|
575
|
+
n.someProp("handleKeyDown", (l) => l(n, c));
|
|
576
|
+
});
|
|
577
|
+
return a?.steps.forEach((l) => {
|
|
578
|
+
const f = l.map(r.mapping);
|
|
579
|
+
f && o && r.maybeStep(f);
|
|
580
|
+
}), !0;
|
|
581
|
+
};
|
|
582
|
+
function Q(t, e, n = {}) {
|
|
583
|
+
const { from: r, to: o, empty: s } = t.selection, i = e ? T(e, t.schema) : null, c = [];
|
|
584
|
+
t.doc.nodesBetween(r, o, (u, p) => {
|
|
585
|
+
if (u.isText)
|
|
586
|
+
return;
|
|
587
|
+
const d = Math.max(r, p), h = Math.min(o, p + u.nodeSize);
|
|
588
|
+
c.push({
|
|
589
|
+
node: u,
|
|
590
|
+
from: d,
|
|
591
|
+
to: h
|
|
592
|
+
});
|
|
593
|
+
});
|
|
594
|
+
const a = o - r, l = c.filter((u) => i ? i.name === u.node.type.name : !0).filter((u) => nt(u.node.attrs, n, { strict: !1 }));
|
|
595
|
+
return s ? !!l.length : l.reduce((u, p) => u + p.to - p.from, 0) >= a;
|
|
596
|
+
}
|
|
597
|
+
var In = (t, e = {}) => ({ state: n, dispatch: r }) => {
|
|
598
|
+
const o = T(t, n.schema);
|
|
599
|
+
return Q(n, o, e) ? Oe(n, r) : !1;
|
|
600
|
+
}, On = () => ({ state: t, dispatch: e }) => Re(t, e), Rn = (t) => ({ state: e, dispatch: n }) => {
|
|
601
|
+
const r = T(t, e.schema);
|
|
602
|
+
return qe(r)(e, n);
|
|
603
|
+
}, Bn = () => ({ state: t, dispatch: e }) => Be(t, e);
|
|
604
|
+
function ct(t, e) {
|
|
605
|
+
return e.nodes[t] ? "node" : e.marks[t] ? "mark" : null;
|
|
606
|
+
}
|
|
607
|
+
function It(t, e) {
|
|
608
|
+
const n = typeof e == "string" ? [e] : e;
|
|
609
|
+
return Object.keys(t).reduce((r, o) => (n.includes(o) || (r[o] = t[o]), r), {});
|
|
610
|
+
}
|
|
611
|
+
var Dn = (t, e) => ({ tr: n, state: r, dispatch: o }) => {
|
|
612
|
+
let s = null, i = null;
|
|
613
|
+
const c = ct(
|
|
614
|
+
typeof t == "string" ? t : t.name,
|
|
615
|
+
r.schema
|
|
616
|
+
);
|
|
617
|
+
if (!c)
|
|
618
|
+
return !1;
|
|
619
|
+
c === "node" && (s = T(t, r.schema)), c === "mark" && (i = D(t, r.schema));
|
|
620
|
+
let a = !1;
|
|
621
|
+
return n.selection.ranges.forEach((l) => {
|
|
622
|
+
r.doc.nodesBetween(l.$from.pos, l.$to.pos, (f, u) => {
|
|
623
|
+
s && s === f.type && (a = !0, o && n.setNodeMarkup(u, void 0, It(f.attrs, e))), i && f.marks.length && f.marks.forEach((p) => {
|
|
624
|
+
i === p.type && (a = !0, o && n.addMark(
|
|
625
|
+
u,
|
|
626
|
+
u + f.nodeSize,
|
|
627
|
+
i.create(It(p.attrs, e))
|
|
628
|
+
));
|
|
629
|
+
});
|
|
630
|
+
});
|
|
631
|
+
}), a;
|
|
632
|
+
}, jn = () => ({ tr: t, dispatch: e }) => (e && t.scrollIntoView(), !0), _n = () => ({ tr: t, dispatch: e }) => {
|
|
633
|
+
if (e) {
|
|
634
|
+
const n = new He(t.doc);
|
|
635
|
+
t.setSelection(n);
|
|
636
|
+
}
|
|
637
|
+
return !0;
|
|
638
|
+
}, Ln = () => ({ state: t, dispatch: e }) => De(t, e), zn = () => ({ state: t, dispatch: e }) => je(t, e), Fn = () => ({ state: t, dispatch: e }) => _e(t, e), Vn = () => ({ state: t, dispatch: e }) => Le(t, e), Hn = () => ({ state: t, dispatch: e }) => ze(t, e);
|
|
639
|
+
function gt(t, e, n = {}, r = {}) {
|
|
640
|
+
return K(t, e, {
|
|
641
|
+
slice: !1,
|
|
642
|
+
parseOptions: n,
|
|
643
|
+
errorOnInvalidContent: r.errorOnInvalidContent
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
var Wn = (t, { errorOnInvalidContent: e, emitUpdate: n = !0, parseOptions: r = {} } = {}) => ({ editor: o, tr: s, dispatch: i, commands: c }) => {
|
|
647
|
+
const { doc: a } = s;
|
|
648
|
+
if (r.preserveWhitespace !== "full") {
|
|
649
|
+
const l = gt(t, o.schema, r, {
|
|
650
|
+
errorOnInvalidContent: e ?? o.options.enableContentCheck
|
|
651
|
+
});
|
|
652
|
+
return i && s.replaceWith(0, a.content.size, l).setMeta("preventUpdate", !n), !0;
|
|
653
|
+
}
|
|
654
|
+
return i && s.setMeta("preventUpdate", !n), c.insertContentAt({ from: 0, to: a.content.size }, t, {
|
|
655
|
+
parseOptions: r,
|
|
656
|
+
errorOnInvalidContent: e ?? o.options.enableContentCheck
|
|
657
|
+
});
|
|
658
|
+
};
|
|
659
|
+
function Kt(t, e) {
|
|
660
|
+
const n = D(e, t.schema), { from: r, to: o, empty: s } = t.selection, i = [];
|
|
661
|
+
s ? (t.storedMarks && i.push(...t.storedMarks), i.push(...t.selection.$head.marks())) : t.doc.nodesBetween(r, o, (a) => {
|
|
662
|
+
i.push(...a.marks);
|
|
663
|
+
});
|
|
664
|
+
const c = i.find((a) => a.type.name === n.name);
|
|
665
|
+
return c ? { ...c.attrs } : {};
|
|
666
|
+
}
|
|
667
|
+
function Un(t, e) {
|
|
668
|
+
const n = new ke(t);
|
|
669
|
+
return e.forEach((r) => {
|
|
670
|
+
r.steps.forEach((o) => {
|
|
671
|
+
n.step(o);
|
|
672
|
+
});
|
|
673
|
+
}), n;
|
|
674
|
+
}
|
|
675
|
+
function qn(t) {
|
|
676
|
+
for (let e = 0; e < t.edgeCount; e += 1) {
|
|
677
|
+
const { type: n } = t.edge(e);
|
|
678
|
+
if (n.isTextblock && !n.hasRequiredAttrs())
|
|
679
|
+
return n;
|
|
680
|
+
}
|
|
681
|
+
return null;
|
|
682
|
+
}
|
|
683
|
+
function co(t, e, n) {
|
|
684
|
+
const r = [];
|
|
685
|
+
return t.nodesBetween(e.from, e.to, (o, s) => {
|
|
686
|
+
n(o) && r.push({
|
|
687
|
+
node: o,
|
|
688
|
+
pos: s
|
|
689
|
+
});
|
|
690
|
+
}), r;
|
|
691
|
+
}
|
|
692
|
+
function Jn(t, e) {
|
|
693
|
+
for (let n = t.depth; n > 0; n -= 1) {
|
|
694
|
+
const r = t.node(n);
|
|
695
|
+
if (e(r))
|
|
696
|
+
return {
|
|
697
|
+
pos: n > 0 ? t.before(n) : 0,
|
|
698
|
+
start: t.start(n),
|
|
699
|
+
depth: n,
|
|
700
|
+
node: r
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
function lt(t) {
|
|
705
|
+
return (e) => Jn(e.$from, t);
|
|
706
|
+
}
|
|
707
|
+
function b(t, e, n) {
|
|
708
|
+
return t.config[e] === void 0 && t.parent ? b(t.parent, e, n) : typeof t.config[e] == "function" ? t.config[e].bind({
|
|
709
|
+
...n,
|
|
710
|
+
parent: t.parent ? b(t.parent, e, n) : null
|
|
711
|
+
}) : t.config[e];
|
|
712
|
+
}
|
|
713
|
+
function xt(t) {
|
|
714
|
+
return t.map((e) => {
|
|
715
|
+
const n = {
|
|
716
|
+
name: e.name,
|
|
717
|
+
options: e.options,
|
|
718
|
+
storage: e.storage
|
|
719
|
+
}, r = b(
|
|
720
|
+
e,
|
|
721
|
+
"addExtensions",
|
|
722
|
+
n
|
|
723
|
+
);
|
|
724
|
+
return r ? [e, ...xt(r())] : e;
|
|
725
|
+
}).flat(10);
|
|
726
|
+
}
|
|
727
|
+
function ut(t, e) {
|
|
728
|
+
const n = We.fromSchema(e).serializeFragment(t), o = document.implementation.createHTMLDocument().createElement("div");
|
|
729
|
+
return o.appendChild(n), o.innerHTML;
|
|
730
|
+
}
|
|
731
|
+
function Qt(t) {
|
|
732
|
+
return typeof t == "function";
|
|
733
|
+
}
|
|
734
|
+
function M(t, e = void 0, ...n) {
|
|
735
|
+
return Qt(t) ? e ? t.bind(e)(...n) : t(...n) : t;
|
|
736
|
+
}
|
|
737
|
+
function Kn(t = {}) {
|
|
738
|
+
return Object.keys(t).length === 0 && t.constructor === Object;
|
|
739
|
+
}
|
|
740
|
+
function V(t) {
|
|
741
|
+
const e = t.filter(
|
|
742
|
+
(o) => o.type === "extension"
|
|
743
|
+
), n = t.filter((o) => o.type === "node"), r = t.filter((o) => o.type === "mark");
|
|
744
|
+
return {
|
|
745
|
+
baseExtensions: e,
|
|
746
|
+
nodeExtensions: n,
|
|
747
|
+
markExtensions: r
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
function Zt(t) {
|
|
751
|
+
const e = [], { nodeExtensions: n, markExtensions: r } = V(t), o = [...n, ...r], s = {
|
|
752
|
+
default: null,
|
|
753
|
+
validate: void 0,
|
|
754
|
+
rendered: !0,
|
|
755
|
+
renderHTML: null,
|
|
756
|
+
parseHTML: null,
|
|
757
|
+
keepOnSplit: !0,
|
|
758
|
+
isRequired: !1
|
|
759
|
+
}, i = n.filter((l) => l.name !== "text").map((l) => l.name), c = r.map((l) => l.name), a = [...i, ...c];
|
|
760
|
+
return t.forEach((l) => {
|
|
761
|
+
const f = {
|
|
762
|
+
name: l.name,
|
|
763
|
+
options: l.options,
|
|
764
|
+
storage: l.storage,
|
|
765
|
+
extensions: o
|
|
766
|
+
}, u = b(
|
|
767
|
+
l,
|
|
768
|
+
"addGlobalAttributes",
|
|
769
|
+
f
|
|
770
|
+
);
|
|
771
|
+
if (!u)
|
|
772
|
+
return;
|
|
773
|
+
u().forEach((d) => {
|
|
774
|
+
let h;
|
|
775
|
+
Array.isArray(d.types) ? h = d.types : d.types === "*" ? h = a : d.types === "nodes" ? h = i : d.types === "marks" ? h = c : h = [], h.forEach((m) => {
|
|
776
|
+
Object.entries(d.attributes).forEach(([g, v]) => {
|
|
777
|
+
e.push({
|
|
778
|
+
type: m,
|
|
779
|
+
name: g,
|
|
780
|
+
attribute: {
|
|
781
|
+
...s,
|
|
782
|
+
...v
|
|
783
|
+
}
|
|
784
|
+
});
|
|
785
|
+
});
|
|
786
|
+
});
|
|
787
|
+
});
|
|
788
|
+
}), o.forEach((l) => {
|
|
789
|
+
const f = {
|
|
790
|
+
name: l.name,
|
|
791
|
+
options: l.options,
|
|
792
|
+
storage: l.storage
|
|
793
|
+
}, u = b(l, "addAttributes", f);
|
|
794
|
+
if (!u)
|
|
795
|
+
return;
|
|
796
|
+
const p = u();
|
|
797
|
+
Object.entries(p).forEach(([d, h]) => {
|
|
798
|
+
const m = {
|
|
799
|
+
...s,
|
|
800
|
+
...h
|
|
801
|
+
};
|
|
802
|
+
typeof m?.default == "function" && (m.default = m.default()), m?.isRequired && m?.default === void 0 && delete m.default, e.push({
|
|
803
|
+
type: l.name,
|
|
804
|
+
name: d,
|
|
805
|
+
attribute: m
|
|
806
|
+
});
|
|
807
|
+
});
|
|
808
|
+
}), e;
|
|
809
|
+
}
|
|
810
|
+
function Qn(t) {
|
|
811
|
+
const e = [];
|
|
812
|
+
let n = "", r = !1, o = !1, s = 0;
|
|
813
|
+
const i = t.length;
|
|
814
|
+
for (let c = 0; c < i; c += 1) {
|
|
815
|
+
const a = t[c];
|
|
816
|
+
if (a === "'" && !o) {
|
|
817
|
+
r = !r, n += a;
|
|
818
|
+
continue;
|
|
819
|
+
}
|
|
820
|
+
if (a === '"' && !r) {
|
|
821
|
+
o = !o, n += a;
|
|
822
|
+
continue;
|
|
823
|
+
}
|
|
824
|
+
if (!r && !o) {
|
|
825
|
+
if (a === "(") {
|
|
826
|
+
s += 1, n += a;
|
|
827
|
+
continue;
|
|
828
|
+
}
|
|
829
|
+
if (a === ")" && s > 0) {
|
|
830
|
+
s -= 1, n += a;
|
|
831
|
+
continue;
|
|
832
|
+
}
|
|
833
|
+
if (a === ";" && s === 0) {
|
|
834
|
+
e.push(n), n = "";
|
|
835
|
+
continue;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
n += a;
|
|
839
|
+
}
|
|
840
|
+
return n && e.push(n), e;
|
|
841
|
+
}
|
|
842
|
+
function Ot(t) {
|
|
843
|
+
const e = [], n = Qn(t || ""), r = n.length;
|
|
844
|
+
for (let o = 0; o < r; o += 1) {
|
|
845
|
+
const s = n[o], i = s.indexOf(":");
|
|
846
|
+
if (i === -1)
|
|
847
|
+
continue;
|
|
848
|
+
const c = s.slice(0, i).trim(), a = s.slice(i + 1).trim();
|
|
849
|
+
c && a && e.push([c, a]);
|
|
850
|
+
}
|
|
851
|
+
return e;
|
|
852
|
+
}
|
|
853
|
+
function Zn(...t) {
|
|
854
|
+
return t.filter((e) => !!e).reduce((e, n) => {
|
|
855
|
+
const r = { ...e };
|
|
856
|
+
return Object.entries(n).forEach(([o, s]) => {
|
|
857
|
+
if (!r[o]) {
|
|
858
|
+
r[o] = s;
|
|
859
|
+
return;
|
|
860
|
+
}
|
|
861
|
+
if (o === "class") {
|
|
862
|
+
const c = s ? String(s).split(" ") : [], a = r[o] ? r[o].split(" ") : [], l = c.filter(
|
|
863
|
+
(f) => !a.includes(f)
|
|
864
|
+
);
|
|
865
|
+
r[o] = [...a, ...l].join(" ");
|
|
866
|
+
} else if (o === "style") {
|
|
867
|
+
const c = new Map([
|
|
868
|
+
...Ot(r[o]),
|
|
869
|
+
...Ot(s)
|
|
870
|
+
]);
|
|
871
|
+
r[o] = Array.from(c.entries()).map(([a, l]) => `${a}: ${l}`).join("; ");
|
|
872
|
+
} else
|
|
873
|
+
r[o] = s;
|
|
874
|
+
}), r;
|
|
875
|
+
}, {});
|
|
876
|
+
}
|
|
877
|
+
function ot(t, e) {
|
|
878
|
+
return e.filter((n) => n.type === t.type.name).filter((n) => n.attribute.rendered).map((n) => n.attribute.renderHTML ? n.attribute.renderHTML(t.attrs) || {} : {
|
|
879
|
+
[n.name]: t.attrs[n.name]
|
|
880
|
+
}).reduce((n, r) => Zn(n, r), {});
|
|
881
|
+
}
|
|
882
|
+
function Gn(t) {
|
|
883
|
+
return typeof t != "string" ? t : t.match(/^[+-]?(?:\d*\.)?\d+$/) ? Number(t) : t === "true" ? !0 : t === "false" ? !1 : t;
|
|
884
|
+
}
|
|
885
|
+
function Rt(t, e) {
|
|
886
|
+
return "style" in t ? t : {
|
|
887
|
+
...t,
|
|
888
|
+
getAttrs: (n) => {
|
|
889
|
+
const r = t.getAttrs ? t.getAttrs(n) : t.attrs;
|
|
890
|
+
if (r === !1)
|
|
891
|
+
return !1;
|
|
892
|
+
const o = e.reduce((s, i) => {
|
|
893
|
+
const c = i.attribute.parseHTML ? i.attribute.parseHTML(n) : Gn(n.getAttribute(i.name));
|
|
894
|
+
return c == null ? s : {
|
|
895
|
+
...s,
|
|
896
|
+
[i.name]: c
|
|
897
|
+
};
|
|
898
|
+
}, {});
|
|
899
|
+
return { ...r, ...o };
|
|
900
|
+
}
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
function Bt(t) {
|
|
904
|
+
return Object.fromEntries(
|
|
905
|
+
// @ts-ignore
|
|
906
|
+
Object.entries(t).filter(([e, n]) => e === "attrs" && Kn(n) ? !1 : n != null)
|
|
907
|
+
);
|
|
908
|
+
}
|
|
909
|
+
function Dt(t) {
|
|
910
|
+
var e, n;
|
|
911
|
+
const r = {};
|
|
912
|
+
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];
|
|
913
|
+
}
|
|
914
|
+
function Gt(t, e) {
|
|
915
|
+
var n;
|
|
916
|
+
const r = Zt(t), { nodeExtensions: o, markExtensions: s } = V(t), i = (n = o.find((l) => b(l, "topNode"))) == null ? void 0 : n.name, c = Object.fromEntries(
|
|
917
|
+
o.map((l) => {
|
|
918
|
+
const f = r.filter(
|
|
919
|
+
(v) => v.type === l.name
|
|
920
|
+
), u = {
|
|
921
|
+
name: l.name,
|
|
922
|
+
options: l.options,
|
|
923
|
+
storage: l.storage,
|
|
924
|
+
editor: e
|
|
925
|
+
}, p = t.reduce((v, y) => {
|
|
926
|
+
const w = b(
|
|
927
|
+
y,
|
|
928
|
+
"extendNodeSchema",
|
|
929
|
+
u
|
|
930
|
+
);
|
|
931
|
+
return {
|
|
932
|
+
...v,
|
|
933
|
+
...w ? w(l) : {}
|
|
934
|
+
};
|
|
935
|
+
}, {}), d = Bt({
|
|
936
|
+
...p,
|
|
937
|
+
content: M(
|
|
938
|
+
b(l, "content", u)
|
|
939
|
+
),
|
|
940
|
+
marks: M(b(l, "marks", u)),
|
|
941
|
+
group: M(b(l, "group", u)),
|
|
942
|
+
inline: M(b(l, "inline", u)),
|
|
943
|
+
atom: M(b(l, "atom", u)),
|
|
944
|
+
selectable: M(
|
|
945
|
+
b(l, "selectable", u)
|
|
946
|
+
),
|
|
947
|
+
draggable: M(
|
|
948
|
+
b(l, "draggable", u)
|
|
949
|
+
),
|
|
950
|
+
code: M(b(l, "code", u)),
|
|
951
|
+
whitespace: M(
|
|
952
|
+
b(l, "whitespace", u)
|
|
953
|
+
),
|
|
954
|
+
linebreakReplacement: M(
|
|
955
|
+
b(
|
|
956
|
+
l,
|
|
957
|
+
"linebreakReplacement",
|
|
958
|
+
u
|
|
959
|
+
)
|
|
960
|
+
),
|
|
961
|
+
defining: M(
|
|
962
|
+
b(l, "defining", u)
|
|
963
|
+
),
|
|
964
|
+
isolating: M(
|
|
965
|
+
b(l, "isolating", u)
|
|
966
|
+
),
|
|
967
|
+
attrs: Object.fromEntries(f.map(Dt))
|
|
968
|
+
}), h = M(
|
|
969
|
+
b(l, "parseHTML", u)
|
|
970
|
+
);
|
|
971
|
+
h && (d.parseDOM = h.map(
|
|
972
|
+
(v) => Rt(v, f)
|
|
973
|
+
));
|
|
974
|
+
const m = b(
|
|
975
|
+
l,
|
|
976
|
+
"renderHTML",
|
|
977
|
+
u
|
|
978
|
+
);
|
|
979
|
+
m && (d.toDOM = (v) => m({
|
|
980
|
+
node: v,
|
|
981
|
+
HTMLAttributes: ot(v, f)
|
|
982
|
+
}));
|
|
983
|
+
const g = b(
|
|
984
|
+
l,
|
|
985
|
+
"renderText",
|
|
986
|
+
u
|
|
987
|
+
);
|
|
988
|
+
return g && (d.toText = g), [l.name, d];
|
|
989
|
+
})
|
|
990
|
+
), a = Object.fromEntries(
|
|
991
|
+
s.map((l) => {
|
|
992
|
+
const f = r.filter(
|
|
993
|
+
(g) => g.type === l.name
|
|
994
|
+
), u = {
|
|
995
|
+
name: l.name,
|
|
996
|
+
options: l.options,
|
|
997
|
+
storage: l.storage,
|
|
998
|
+
editor: e
|
|
999
|
+
}, p = t.reduce((g, v) => {
|
|
1000
|
+
const y = b(
|
|
1001
|
+
v,
|
|
1002
|
+
"extendMarkSchema",
|
|
1003
|
+
u
|
|
1004
|
+
);
|
|
1005
|
+
return {
|
|
1006
|
+
...g,
|
|
1007
|
+
...y ? y(l) : {}
|
|
1008
|
+
};
|
|
1009
|
+
}, {}), d = Bt({
|
|
1010
|
+
...p,
|
|
1011
|
+
inclusive: M(
|
|
1012
|
+
b(l, "inclusive", u)
|
|
1013
|
+
),
|
|
1014
|
+
excludes: M(
|
|
1015
|
+
b(l, "excludes", u)
|
|
1016
|
+
),
|
|
1017
|
+
group: M(b(l, "group", u)),
|
|
1018
|
+
spanning: M(
|
|
1019
|
+
b(l, "spanning", u)
|
|
1020
|
+
),
|
|
1021
|
+
code: M(b(l, "code", u)),
|
|
1022
|
+
attrs: Object.fromEntries(f.map(Dt))
|
|
1023
|
+
}), h = M(
|
|
1024
|
+
b(l, "parseHTML", u)
|
|
1025
|
+
);
|
|
1026
|
+
h && (d.parseDOM = h.map(
|
|
1027
|
+
(g) => Rt(g, f)
|
|
1028
|
+
));
|
|
1029
|
+
const m = b(
|
|
1030
|
+
l,
|
|
1031
|
+
"renderHTML",
|
|
1032
|
+
u
|
|
1033
|
+
);
|
|
1034
|
+
return m && (d.toDOM = (g) => m({
|
|
1035
|
+
mark: g,
|
|
1036
|
+
HTMLAttributes: ot(g, f)
|
|
1037
|
+
})), [l.name, d];
|
|
1038
|
+
})
|
|
1039
|
+
);
|
|
1040
|
+
return new Ft({
|
|
1041
|
+
topNode: i,
|
|
1042
|
+
nodes: c,
|
|
1043
|
+
marks: a
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
function Yn(t) {
|
|
1047
|
+
const e = t.filter((n, r) => t.indexOf(n) !== r);
|
|
1048
|
+
return Array.from(new Set(e));
|
|
1049
|
+
}
|
|
1050
|
+
function J(t) {
|
|
1051
|
+
return t.sort((n, r) => {
|
|
1052
|
+
const o = b(n, "priority") || 100, s = b(r, "priority") || 100;
|
|
1053
|
+
return o > s ? -1 : o < s ? 1 : 0;
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
function Mt(t) {
|
|
1057
|
+
const e = J(xt(t)), n = Yn(e.map((r) => r.name));
|
|
1058
|
+
return n.length && console.warn(
|
|
1059
|
+
`[tiptap warn]: Duplicate extension names found: [${n.map((r) => `'${r}'`).join(", ")}]. This can lead to issues.`
|
|
1060
|
+
), e;
|
|
1061
|
+
}
|
|
1062
|
+
function Yt(t, e) {
|
|
1063
|
+
const n = Mt(t);
|
|
1064
|
+
return Gt(n, e);
|
|
1065
|
+
}
|
|
1066
|
+
function lo(t, e) {
|
|
1067
|
+
const n = Yt(e), r = zt.fromJSON(n, t);
|
|
1068
|
+
return ut(r.content, n);
|
|
1069
|
+
}
|
|
1070
|
+
function uo(t, e) {
|
|
1071
|
+
const n = Yt(e), r = U(t);
|
|
1072
|
+
return tt.fromSchema(n).parse(r).toJSON();
|
|
1073
|
+
}
|
|
1074
|
+
function Xt(t, e, n) {
|
|
1075
|
+
const { from: r, to: o } = e, { blockSeparator: s = `
|
|
1076
|
+
|
|
1077
|
+
`, textSerializers: i = {} } = n || {};
|
|
1078
|
+
let c = "";
|
|
1079
|
+
return t.nodesBetween(r, o, (a, l, f, u) => {
|
|
1080
|
+
var p;
|
|
1081
|
+
a.isBlock && l > r && (c += s);
|
|
1082
|
+
const d = i?.[a.type.name];
|
|
1083
|
+
if (d)
|
|
1084
|
+
return f && (c += d({
|
|
1085
|
+
node: a,
|
|
1086
|
+
pos: l,
|
|
1087
|
+
parent: f,
|
|
1088
|
+
index: u,
|
|
1089
|
+
range: e
|
|
1090
|
+
})), !1;
|
|
1091
|
+
a.isText && (c += (p = a?.text) == null ? void 0 : p.slice(Math.max(r, l) - l, o - l));
|
|
1092
|
+
}), c;
|
|
1093
|
+
}
|
|
1094
|
+
function Xn(t, e) {
|
|
1095
|
+
const n = {
|
|
1096
|
+
from: 0,
|
|
1097
|
+
to: t.content.size
|
|
1098
|
+
};
|
|
1099
|
+
return Xt(t, n, e);
|
|
1100
|
+
}
|
|
1101
|
+
function te(t) {
|
|
1102
|
+
return Object.fromEntries(
|
|
1103
|
+
Object.entries(t.nodes).filter(([, e]) => e.spec.toText).map(([e, n]) => [e, n.spec.toText])
|
|
1104
|
+
);
|
|
1105
|
+
}
|
|
1106
|
+
function tr(t, e) {
|
|
1107
|
+
const n = T(e, t.schema), { from: r, to: o } = t.selection, s = [];
|
|
1108
|
+
t.doc.nodesBetween(r, o, (c) => {
|
|
1109
|
+
s.push(c);
|
|
1110
|
+
});
|
|
1111
|
+
const i = s.reverse().find((c) => c.type.name === n.name);
|
|
1112
|
+
return i ? { ...i.attrs } : {};
|
|
1113
|
+
}
|
|
1114
|
+
function er(t, e) {
|
|
1115
|
+
const n = ct(
|
|
1116
|
+
typeof e == "string" ? e : e.name,
|
|
1117
|
+
t.schema
|
|
1118
|
+
);
|
|
1119
|
+
return n === "node" ? tr(t, e) : n === "mark" ? Kt(t, e) : {};
|
|
1120
|
+
}
|
|
1121
|
+
function nr(t, e = JSON.stringify) {
|
|
1122
|
+
const n = {};
|
|
1123
|
+
return t.filter((r) => {
|
|
1124
|
+
const o = e(r);
|
|
1125
|
+
return Object.prototype.hasOwnProperty.call(n, o) ? !1 : n[o] = !0;
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1128
|
+
function rr(t) {
|
|
1129
|
+
const e = nr(t);
|
|
1130
|
+
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));
|
|
1131
|
+
}
|
|
1132
|
+
function or(t) {
|
|
1133
|
+
const { mapping: e, steps: n } = t, r = [];
|
|
1134
|
+
return e.maps.forEach((o, s) => {
|
|
1135
|
+
const i = [];
|
|
1136
|
+
if (o.ranges.length)
|
|
1137
|
+
o.forEach((c, a) => {
|
|
1138
|
+
i.push({ from: c, to: a });
|
|
1139
|
+
});
|
|
1140
|
+
else {
|
|
1141
|
+
const { from: c, to: a } = n[s];
|
|
1142
|
+
if (c === void 0 || a === void 0)
|
|
1143
|
+
return;
|
|
1144
|
+
i.push({ from: c, to: a });
|
|
1145
|
+
}
|
|
1146
|
+
i.forEach(({ from: c, to: a }) => {
|
|
1147
|
+
const l = e.slice(s).map(c, -1), f = e.slice(s).map(a), u = e.invert().map(l, -1), p = e.invert().map(f);
|
|
1148
|
+
r.push({
|
|
1149
|
+
oldRange: {
|
|
1150
|
+
from: u,
|
|
1151
|
+
to: p
|
|
1152
|
+
},
|
|
1153
|
+
newRange: {
|
|
1154
|
+
from: l,
|
|
1155
|
+
to: f
|
|
1156
|
+
}
|
|
1157
|
+
});
|
|
1158
|
+
});
|
|
1159
|
+
}), rr(r);
|
|
1160
|
+
}
|
|
1161
|
+
function ee(t, e, n) {
|
|
1162
|
+
const r = [];
|
|
1163
|
+
return t === e ? n.resolve(t).marks().forEach((o) => {
|
|
1164
|
+
const s = n.resolve(t), i = wt(s, o.type);
|
|
1165
|
+
i && r.push({
|
|
1166
|
+
mark: o,
|
|
1167
|
+
...i
|
|
1168
|
+
});
|
|
1169
|
+
}) : n.nodesBetween(t, e, (o, s) => {
|
|
1170
|
+
!o || o?.nodeSize === void 0 || r.push(
|
|
1171
|
+
...o.marks.map((i) => ({
|
|
1172
|
+
from: s,
|
|
1173
|
+
to: s + o.nodeSize,
|
|
1174
|
+
mark: i
|
|
1175
|
+
}))
|
|
1176
|
+
);
|
|
1177
|
+
}), r;
|
|
1178
|
+
}
|
|
1179
|
+
var fo = (t, e, n, r = 20) => {
|
|
1180
|
+
const o = t.doc.resolve(n);
|
|
1181
|
+
let s = r, i = null;
|
|
1182
|
+
for (; s > 0 && i === null; ) {
|
|
1183
|
+
const c = o.node(s);
|
|
1184
|
+
c?.type.name === e ? i = c : s -= 1;
|
|
1185
|
+
}
|
|
1186
|
+
return [i, s];
|
|
1187
|
+
};
|
|
1188
|
+
function W(t, e) {
|
|
1189
|
+
return e.nodes[t] || e.marks[t] || null;
|
|
1190
|
+
}
|
|
1191
|
+
function et(t, e, n) {
|
|
1192
|
+
return Object.fromEntries(
|
|
1193
|
+
Object.entries(n).filter(([r]) => {
|
|
1194
|
+
const o = t.find((s) => s.type === e && s.name === r);
|
|
1195
|
+
return o ? o.attribute.keepOnSplit : !1;
|
|
1196
|
+
})
|
|
1197
|
+
);
|
|
1198
|
+
}
|
|
1199
|
+
var sr = (t, e = 500) => {
|
|
1200
|
+
let n = "";
|
|
1201
|
+
const r = t.parentOffset;
|
|
1202
|
+
return t.parent.nodesBetween(
|
|
1203
|
+
Math.max(0, r - e),
|
|
1204
|
+
r,
|
|
1205
|
+
(o, s, i, c) => {
|
|
1206
|
+
var a, l;
|
|
1207
|
+
const f = ((l = (a = o.type.spec).toText) == null ? void 0 : l.call(a, {
|
|
1208
|
+
node: o,
|
|
1209
|
+
pos: s,
|
|
1210
|
+
parent: i,
|
|
1211
|
+
index: c
|
|
1212
|
+
})) || o.textContent || "%leaf%";
|
|
1213
|
+
n += o.isAtom && !o.isText ? f : f.slice(0, Math.max(0, r - s));
|
|
1214
|
+
}
|
|
1215
|
+
), n;
|
|
1216
|
+
};
|
|
1217
|
+
function vt(t, e, n = {}) {
|
|
1218
|
+
const { empty: r, ranges: o } = t.selection, s = e ? D(e, t.schema) : null;
|
|
1219
|
+
if (r)
|
|
1220
|
+
return !!(t.storedMarks || t.selection.$from.marks()).filter((u) => s ? s.name === u.type.name : !0).find((u) => nt(u.attrs, n, { strict: !1 }));
|
|
1221
|
+
let i = 0;
|
|
1222
|
+
const c = [];
|
|
1223
|
+
if (o.forEach(({ $from: u, $to: p }) => {
|
|
1224
|
+
const d = u.pos, h = p.pos;
|
|
1225
|
+
t.doc.nodesBetween(d, h, (m, g) => {
|
|
1226
|
+
if (s && m.inlineContent && !m.type.allowsMarkType(s))
|
|
1227
|
+
return !1;
|
|
1228
|
+
if (!m.isText && !m.marks.length)
|
|
1229
|
+
return;
|
|
1230
|
+
const v = Math.max(d, g), y = Math.min(h, g + m.nodeSize), w = y - v;
|
|
1231
|
+
i += w, c.push(
|
|
1232
|
+
...m.marks.map((x) => ({
|
|
1233
|
+
mark: x,
|
|
1234
|
+
from: v,
|
|
1235
|
+
to: y
|
|
1236
|
+
}))
|
|
1237
|
+
);
|
|
1238
|
+
});
|
|
1239
|
+
}), i === 0)
|
|
1240
|
+
return !1;
|
|
1241
|
+
const a = c.filter((u) => s ? s.name === u.mark.type.name : !0).filter((u) => nt(u.mark.attrs, n, { strict: !1 })).reduce((u, p) => u + p.to - p.from, 0), l = c.filter((u) => s ? u.mark.type !== s && u.mark.type.excludes(s) : !0).reduce((u, p) => u + p.to - p.from, 0);
|
|
1242
|
+
return (a > 0 ? a + l : a) >= i;
|
|
1243
|
+
}
|
|
1244
|
+
function ir(t, e, n = {}) {
|
|
1245
|
+
if (!e)
|
|
1246
|
+
return Q(t, null, n) || vt(t, null, n);
|
|
1247
|
+
const r = ct(e, t.schema);
|
|
1248
|
+
return r === "node" ? Q(t, e, n) : r === "mark" ? vt(t, e, n) : !1;
|
|
1249
|
+
}
|
|
1250
|
+
var po = (t, e) => {
|
|
1251
|
+
const { $from: n, $to: r, $anchor: o } = t.selection;
|
|
1252
|
+
if (e) {
|
|
1253
|
+
const s = lt((c) => c.type.name === e)(t.selection);
|
|
1254
|
+
if (!s)
|
|
1255
|
+
return !1;
|
|
1256
|
+
const i = t.doc.resolve(s.pos + 1);
|
|
1257
|
+
return o.pos + 1 === i.end();
|
|
1258
|
+
}
|
|
1259
|
+
return !(r.parentOffset < r.parent.nodeSize - 2 || n.pos !== r.pos);
|
|
1260
|
+
}, mo = (t) => {
|
|
1261
|
+
const { $from: e, $to: n } = t.selection;
|
|
1262
|
+
return !(e.parentOffset > 0 || e.pos !== n.pos);
|
|
1263
|
+
};
|
|
1264
|
+
function jt(t, e) {
|
|
1265
|
+
return Array.isArray(e) ? e.some((n) => (typeof n == "string" ? n : n.name) === t.name) : e;
|
|
1266
|
+
}
|
|
1267
|
+
function pt(t, e) {
|
|
1268
|
+
const { nodeExtensions: n } = V(e), r = n.find((i) => i.name === t);
|
|
1269
|
+
if (!r)
|
|
1270
|
+
return !1;
|
|
1271
|
+
const o = {
|
|
1272
|
+
name: r.name,
|
|
1273
|
+
options: r.options,
|
|
1274
|
+
storage: r.storage
|
|
1275
|
+
}, s = M(b(r, "group", o));
|
|
1276
|
+
return typeof s != "string" ? !1 : s.split(" ").includes("list");
|
|
1277
|
+
}
|
|
1278
|
+
function St(t, {
|
|
1279
|
+
checkChildren: e = !0,
|
|
1280
|
+
ignoreWhitespace: n = !1
|
|
1281
|
+
} = {}) {
|
|
1282
|
+
var r;
|
|
1283
|
+
if (n) {
|
|
1284
|
+
if (t.type.name === "hardBreak")
|
|
1285
|
+
return !0;
|
|
1286
|
+
if (t.isText)
|
|
1287
|
+
return !/\S/.test((r = t.text) != null ? r : "");
|
|
1288
|
+
}
|
|
1289
|
+
if (t.isText)
|
|
1290
|
+
return !t.text;
|
|
1291
|
+
if (t.isAtom || t.isLeaf)
|
|
1292
|
+
return !1;
|
|
1293
|
+
if (t.content.childCount === 0)
|
|
1294
|
+
return !0;
|
|
1295
|
+
if (e) {
|
|
1296
|
+
let o = !0;
|
|
1297
|
+
return t.content.forEach((s) => {
|
|
1298
|
+
o !== !1 && (St(s, { ignoreWhitespace: n, checkChildren: e }) || (o = !1));
|
|
1299
|
+
}), o;
|
|
1300
|
+
}
|
|
1301
|
+
return !1;
|
|
1302
|
+
}
|
|
1303
|
+
function ho(t) {
|
|
1304
|
+
return t instanceof st;
|
|
1305
|
+
}
|
|
1306
|
+
var ne = class re {
|
|
1307
|
+
constructor(e) {
|
|
1308
|
+
this.position = e;
|
|
1309
|
+
}
|
|
1310
|
+
/**
|
|
1311
|
+
* Creates a MappablePosition from a JSON object.
|
|
1312
|
+
*/
|
|
1313
|
+
static fromJSON(e) {
|
|
1314
|
+
return new re(e.position);
|
|
1315
|
+
}
|
|
1316
|
+
/**
|
|
1317
|
+
* Converts the MappablePosition to a JSON object.
|
|
1318
|
+
*/
|
|
1319
|
+
toJSON() {
|
|
1320
|
+
return {
|
|
1321
|
+
position: this.position
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1324
|
+
};
|
|
1325
|
+
function ar(t, e) {
|
|
1326
|
+
const n = e.mapping.mapResult(t.position);
|
|
1327
|
+
return {
|
|
1328
|
+
position: new ne(n.pos),
|
|
1329
|
+
mapResult: n
|
|
1330
|
+
};
|
|
1331
|
+
}
|
|
1332
|
+
function cr(t) {
|
|
1333
|
+
return new ne(t);
|
|
1334
|
+
}
|
|
1335
|
+
function lr(t, e, n) {
|
|
1336
|
+
var r;
|
|
1337
|
+
const { selection: o } = e;
|
|
1338
|
+
let s = null;
|
|
1339
|
+
if (Wt(o) && (s = o.$cursor), s) {
|
|
1340
|
+
const c = (r = t.storedMarks) != null ? r : s.marks();
|
|
1341
|
+
return s.parent.type.allowsMarkType(n) && (!!n.isInSet(c) || !c.some((l) => l.type.excludes(n)));
|
|
1342
|
+
}
|
|
1343
|
+
const { ranges: i } = o;
|
|
1344
|
+
return i.some(({ $from: c, $to: a }) => {
|
|
1345
|
+
let l = c.depth === 0 ? t.doc.inlineContent && t.doc.type.allowsMarkType(n) : !1;
|
|
1346
|
+
return t.doc.nodesBetween(c.pos, a.pos, (f, u, p) => {
|
|
1347
|
+
if (l)
|
|
1348
|
+
return !1;
|
|
1349
|
+
if (f.isInline) {
|
|
1350
|
+
const d = !p || p.type.allowsMarkType(n), h = !!n.isInSet(f.marks) || !f.marks.some((m) => m.type.excludes(n));
|
|
1351
|
+
l = d && h;
|
|
1352
|
+
}
|
|
1353
|
+
return !l;
|
|
1354
|
+
}), l;
|
|
1355
|
+
});
|
|
1356
|
+
}
|
|
1357
|
+
var ur = (t, e = {}) => ({ tr: n, state: r, dispatch: o }) => {
|
|
1358
|
+
const { selection: s } = n, { empty: i, ranges: c } = s, a = D(t, r.schema);
|
|
1359
|
+
if (o)
|
|
1360
|
+
if (i) {
|
|
1361
|
+
const l = Kt(r, a);
|
|
1362
|
+
n.addStoredMark(
|
|
1363
|
+
a.create({
|
|
1364
|
+
...l,
|
|
1365
|
+
...e
|
|
1366
|
+
})
|
|
1367
|
+
);
|
|
1368
|
+
} else
|
|
1369
|
+
c.forEach((l) => {
|
|
1370
|
+
const f = l.$from.pos, u = l.$to.pos;
|
|
1371
|
+
r.doc.nodesBetween(f, u, (p, d) => {
|
|
1372
|
+
const h = Math.max(d, f), m = Math.min(d + p.nodeSize, u);
|
|
1373
|
+
p.marks.find((v) => v.type === a) ? p.marks.forEach((v) => {
|
|
1374
|
+
a === v.type && n.addMark(
|
|
1375
|
+
h,
|
|
1376
|
+
m,
|
|
1377
|
+
a.create({
|
|
1378
|
+
...v.attrs,
|
|
1379
|
+
...e
|
|
1380
|
+
})
|
|
1381
|
+
);
|
|
1382
|
+
}) : n.addMark(h, m, a.create(e));
|
|
1383
|
+
});
|
|
1384
|
+
});
|
|
1385
|
+
return lr(r, n, a);
|
|
1386
|
+
}, dr = (t, e) => ({ tr: n }) => (n.setMeta(t, e), !0), fr = (t, e = {}) => ({ state: n, dispatch: r, chain: o }) => {
|
|
1387
|
+
const s = T(t, n.schema);
|
|
1388
|
+
let i;
|
|
1389
|
+
return n.selection.$anchor.sameParent(n.selection.$head) && (i = n.selection.$anchor.parent.attrs), s.isTextblock ? o().command(({ commands: c }) => Ct(s, { ...i, ...e })(n) ? !0 : c.clearNodes()).command(({ state: c }) => Ct(s, { ...i, ...e })(c, r)).run() : (console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'), !1);
|
|
1390
|
+
}, pr = (t) => ({ tr: e, dispatch: n }) => {
|
|
1391
|
+
if (n) {
|
|
1392
|
+
const { doc: r } = e, o = z(t, 0, r.content.size), s = st.create(r, o);
|
|
1393
|
+
e.setSelection(s);
|
|
1394
|
+
}
|
|
1395
|
+
return !0;
|
|
1396
|
+
}, mr = (t, e) => ({ tr: n, state: r, dispatch: o }) => {
|
|
1397
|
+
const { selection: s } = r;
|
|
1398
|
+
let i, c;
|
|
1399
|
+
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) => {
|
|
1400
|
+
a.isText || n.setNodeMarkup(l, void 0, {
|
|
1401
|
+
...a.attrs,
|
|
1402
|
+
dir: t
|
|
1403
|
+
});
|
|
1404
|
+
}), !0;
|
|
1405
|
+
}, hr = (t) => ({ tr: e, dispatch: n }) => {
|
|
1406
|
+
if (n) {
|
|
1407
|
+
const { doc: r } = e, { from: o, to: s } = typeof t == "number" ? { from: t, to: t } : t, i = O.atStart(r).from, c = O.atEnd(r).to, a = z(o, i, c), l = z(s, i, c), f = O.create(r, a, l);
|
|
1408
|
+
e.setSelection(f);
|
|
1409
|
+
}
|
|
1410
|
+
return !0;
|
|
1411
|
+
}, gr = (t) => ({ state: e, dispatch: n }) => {
|
|
1412
|
+
const r = T(t, e.schema);
|
|
1413
|
+
return Je(r)(e, n);
|
|
1414
|
+
};
|
|
1415
|
+
function _t(t, e) {
|
|
1416
|
+
const n = t.storedMarks || t.selection.$to.parentOffset && t.selection.$from.marks();
|
|
1417
|
+
if (n) {
|
|
1418
|
+
const r = n.filter((o) => e?.includes(o.type.name));
|
|
1419
|
+
t.tr.ensureMarks(r);
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
var vr = ({ keepMarks: t = !0 } = {}) => ({ tr: e, state: n, dispatch: r, editor: o }) => {
|
|
1423
|
+
const { selection: s, doc: i } = e, { $from: c, $to: a } = s, l = o.extensionManager.attributes, f = et(
|
|
1424
|
+
l,
|
|
1425
|
+
c.node().type.name,
|
|
1426
|
+
c.node().attrs
|
|
1427
|
+
);
|
|
1428
|
+
if (s instanceof st && s.node.isBlock)
|
|
1429
|
+
return !c.parentOffset || !X(i, c.pos) ? !1 : (r && (t && _t(n, o.extensionManager.splittableMarks), e.split(c.pos).scrollIntoView()), !0);
|
|
1430
|
+
if (!c.parent.isBlock)
|
|
1431
|
+
return !1;
|
|
1432
|
+
const u = a.parentOffset === a.parent.content.size, p = c.depth === 0 ? void 0 : qn(c.node(-1).contentMatchAt(c.indexAfter(-1)));
|
|
1433
|
+
let d = u && p ? [
|
|
1434
|
+
{
|
|
1435
|
+
type: p,
|
|
1436
|
+
attrs: f
|
|
1437
|
+
}
|
|
1438
|
+
] : void 0, h = X(e.doc, e.mapping.map(c.pos), 1, d);
|
|
1439
|
+
if (!d && !h && X(e.doc, e.mapping.map(c.pos), 1, p ? [{ type: p }] : void 0) && (h = !0, d = p ? [
|
|
1440
|
+
{
|
|
1441
|
+
type: p,
|
|
1442
|
+
attrs: f
|
|
1443
|
+
}
|
|
1444
|
+
] : void 0), r) {
|
|
1445
|
+
if (h && (s instanceof O && e.deleteSelection(), e.split(e.mapping.map(c.pos), 1, d), p && !u && !c.parentOffset && c.parent.type !== p)) {
|
|
1446
|
+
const m = e.mapping.map(c.before()), g = e.doc.resolve(m);
|
|
1447
|
+
c.node(-1).canReplaceWith(g.index(), g.index() + 1, p) && e.setNodeMarkup(e.mapping.map(c.before()), p);
|
|
1448
|
+
}
|
|
1449
|
+
t && _t(n, o.extensionManager.splittableMarks), e.scrollIntoView();
|
|
1450
|
+
}
|
|
1451
|
+
return h;
|
|
1452
|
+
}, br = (t, e = {}) => ({ tr: n, state: r, dispatch: o, editor: s }) => {
|
|
1453
|
+
var i;
|
|
1454
|
+
const c = T(t, r.schema), { $from: a, $to: l } = r.selection, f = r.selection.node;
|
|
1455
|
+
if (f && f.isBlock || a.depth < 2 || !a.sameParent(l))
|
|
1456
|
+
return !1;
|
|
1457
|
+
const u = a.node(-1);
|
|
1458
|
+
if (u.type !== c)
|
|
1459
|
+
return !1;
|
|
1460
|
+
const p = s.extensionManager.attributes;
|
|
1461
|
+
if (a.parent.content.size === 0 && a.node(-1).childCount === a.indexAfter(-1)) {
|
|
1462
|
+
if (a.depth === 2 || a.node(-3).type !== c || a.index(-2) !== a.node(-2).childCount - 1)
|
|
1463
|
+
return !1;
|
|
1464
|
+
if (o) {
|
|
1465
|
+
let v = j.empty;
|
|
1466
|
+
const y = a.index(-1) ? 1 : a.index(-2) ? 2 : 3;
|
|
1467
|
+
for (let A = a.depth - y; A >= a.depth - 3; A -= 1)
|
|
1468
|
+
v = j.from(a.node(A).copy(v));
|
|
1469
|
+
const w = (
|
|
1470
|
+
// oxlint-disable-next-line no-nested-ternary
|
|
1471
|
+
a.indexAfter(-1) < a.node(-2).childCount ? 1 : a.indexAfter(-2) < a.node(-3).childCount ? 2 : 3
|
|
1472
|
+
), x = {
|
|
1473
|
+
...et(p, a.node().type.name, a.node().attrs),
|
|
1474
|
+
...e
|
|
1475
|
+
}, k = ((i = c.contentMatch.defaultType) == null ? void 0 : i.createAndFill(x)) || void 0;
|
|
1476
|
+
v = v.append(j.from(c.createAndFill(null, k) || void 0));
|
|
1477
|
+
const S = a.before(a.depth - (y - 1));
|
|
1478
|
+
n.replace(S, a.after(-w), new Ue(v, 4 - y, 0));
|
|
1479
|
+
let E = -1;
|
|
1480
|
+
n.doc.nodesBetween(S, n.doc.content.size, (A, C) => {
|
|
1481
|
+
if (E > -1)
|
|
1482
|
+
return !1;
|
|
1483
|
+
A.isTextblock && A.content.size === 0 && (E = C + 1);
|
|
1484
|
+
}), E > -1 && n.setSelection(O.near(n.doc.resolve(E))), n.scrollIntoView();
|
|
1485
|
+
}
|
|
1486
|
+
return !0;
|
|
1487
|
+
}
|
|
1488
|
+
const d = l.pos === a.end() ? u.contentMatchAt(0).defaultType : null, h = {
|
|
1489
|
+
...et(p, u.type.name, u.attrs),
|
|
1490
|
+
...e
|
|
1491
|
+
}, m = {
|
|
1492
|
+
...et(p, a.node().type.name, a.node().attrs),
|
|
1493
|
+
...e
|
|
1494
|
+
};
|
|
1495
|
+
n.delete(a.pos, l.pos);
|
|
1496
|
+
const g = d ? [
|
|
1497
|
+
{ type: c, attrs: h },
|
|
1498
|
+
{ type: d, attrs: m }
|
|
1499
|
+
] : [{ type: c, attrs: h }];
|
|
1500
|
+
if (!X(n.doc, a.pos, 2))
|
|
1501
|
+
return !1;
|
|
1502
|
+
if (o) {
|
|
1503
|
+
const { selection: v, storedMarks: y } = r, { splittableMarks: w } = s.extensionManager, x = y || v.$to.parentOffset && v.$from.marks();
|
|
1504
|
+
if (n.split(a.pos, 2, g).scrollIntoView(), !x || !o)
|
|
1505
|
+
return !0;
|
|
1506
|
+
const k = x.filter((S) => w.includes(S.type.name));
|
|
1507
|
+
n.ensureMarks(k);
|
|
1508
|
+
}
|
|
1509
|
+
return !0;
|
|
1510
|
+
}, mt = (t, e) => {
|
|
1511
|
+
const n = lt((i) => i.type === e)(t.selection);
|
|
1512
|
+
if (!n)
|
|
1513
|
+
return !0;
|
|
1514
|
+
const r = t.doc.resolve(Math.max(0, n.pos - 1)).before(n.depth);
|
|
1515
|
+
if (r === void 0)
|
|
1516
|
+
return !0;
|
|
1517
|
+
const o = t.doc.nodeAt(r);
|
|
1518
|
+
return n.node.type === o?.type && bt(t.doc, n.pos) && t.join(n.pos), !0;
|
|
1519
|
+
}, ht = (t, e) => {
|
|
1520
|
+
const n = lt((i) => i.type === e)(t.selection);
|
|
1521
|
+
if (!n)
|
|
1522
|
+
return !0;
|
|
1523
|
+
const r = t.doc.resolve(n.start).after(n.depth);
|
|
1524
|
+
if (r === void 0)
|
|
1525
|
+
return !0;
|
|
1526
|
+
const o = t.doc.nodeAt(r);
|
|
1527
|
+
return n.node.type === o?.type && bt(t.doc, r) && t.join(r), !0;
|
|
1528
|
+
};
|
|
1529
|
+
function yr(t) {
|
|
1530
|
+
const e = t.doc, n = e.firstChild;
|
|
1531
|
+
if (!n)
|
|
1532
|
+
return null;
|
|
1533
|
+
const r = e.resolve(1), o = e.resolve(n.nodeSize - 1);
|
|
1534
|
+
return O.between(r, o);
|
|
1535
|
+
}
|
|
1536
|
+
var kr = (t, e, n, r = {}) => ({ editor: o, tr: s, state: i, dispatch: c, chain: a, commands: l, can: f }) => {
|
|
1537
|
+
const { extensions: u, splittableMarks: p } = o.extensionManager, d = T(t, i.schema), h = T(e, i.schema), { selection: m, storedMarks: g } = i, { $from: v, $to: y } = m, w = v.blockRange(y), x = g || m.$to.parentOffset && m.$from.marks();
|
|
1538
|
+
if (!w)
|
|
1539
|
+
return !1;
|
|
1540
|
+
const k = lt((I) => pt(I.type.name, u))(m), S = m.from === 0 && m.to === i.doc.content.size, E = i.doc.content.content, A = E.length === 1 ? E[0] : null, C = S && A && pt(A.type.name, u) ? {
|
|
1541
|
+
node: A,
|
|
1542
|
+
pos: 0
|
|
1543
|
+
} : null, $ = k ?? C, H = !!k && w.depth >= 1 && w.depth - k.depth <= 1, L = !!C;
|
|
1544
|
+
if ((H || L) && $) {
|
|
1545
|
+
if ($.node.type === d)
|
|
1546
|
+
return S && L ? a().command(({ tr: I, dispatch: N }) => {
|
|
1547
|
+
const P = yr(I);
|
|
1548
|
+
return P ? (I.setSelection(P), N && N(I), !0) : !1;
|
|
1549
|
+
}).liftListItem(h).run() : l.liftListItem(h);
|
|
1550
|
+
if (pt($.node.type.name, u) && d.validContent($.node.content))
|
|
1551
|
+
return a().command(() => (s.setNodeMarkup($.pos, d), !0)).command(() => mt(s, d)).command(() => ht(s, d)).run();
|
|
1552
|
+
}
|
|
1553
|
+
return !n || !x || !c ? a().command(() => f().wrapInList(d, r) ? !0 : l.clearNodes()).wrapInList(d, r).command(() => mt(s, d)).command(() => ht(s, d)).run() : a().command(() => {
|
|
1554
|
+
const I = f().wrapInList(d, r), N = x.filter((P) => p.includes(P.type.name));
|
|
1555
|
+
return s.ensureMarks(N), I ? !0 : l.clearNodes();
|
|
1556
|
+
}).wrapInList(d, r).command(() => mt(s, d)).command(() => ht(s, d)).run();
|
|
1557
|
+
}, wr = (t, e = {}, n = {}) => ({ state: r, commands: o }) => {
|
|
1558
|
+
const { extendEmptyMarkRange: s = !1 } = n, i = D(t, r.schema);
|
|
1559
|
+
return vt(r, i, e) ? o.unsetMark(i, { extendEmptyMarkRange: s }) : o.setMark(i, e);
|
|
1560
|
+
}, xr = (t, e, n = {}) => ({ state: r, commands: o }) => {
|
|
1561
|
+
const s = T(t, r.schema), i = T(e, r.schema), c = Q(r, s, n);
|
|
1562
|
+
let a;
|
|
1563
|
+
return r.selection.$anchor.sameParent(r.selection.$head) && (a = r.selection.$anchor.parent.attrs), c ? o.setNode(i, a) : o.setNode(s, { ...a, ...n });
|
|
1564
|
+
}, Mr = (t, e = {}) => ({ state: n, commands: r }) => {
|
|
1565
|
+
const o = T(t, n.schema);
|
|
1566
|
+
return Q(n, o, e) ? r.lift(o) : r.wrapIn(o, e);
|
|
1567
|
+
}, Sr = () => ({ state: t, dispatch: e }) => {
|
|
1568
|
+
const n = t.plugins;
|
|
1569
|
+
for (let r = 0; r < n.length; r += 1) {
|
|
1570
|
+
const o = n[r];
|
|
1571
|
+
let s;
|
|
1572
|
+
if (o.spec.isInputRules && (s = o.getState(t))) {
|
|
1573
|
+
if (e) {
|
|
1574
|
+
const i = t.tr, c = s.transform;
|
|
1575
|
+
for (let a = c.steps.length - 1; a >= 0; a -= 1)
|
|
1576
|
+
i.step(c.steps[a].invert(c.docs[a]));
|
|
1577
|
+
if (s.text) {
|
|
1578
|
+
const a = i.doc.resolve(s.from).marks();
|
|
1579
|
+
i.replaceWith(s.from, s.to, t.schema.text(s.text, a));
|
|
1580
|
+
} else
|
|
1581
|
+
i.delete(s.from, s.to);
|
|
1582
|
+
}
|
|
1583
|
+
return !0;
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
return !1;
|
|
1587
|
+
}, Er = () => ({ tr: t, dispatch: e }) => {
|
|
1588
|
+
const { selection: n } = t, { empty: r, ranges: o } = n;
|
|
1589
|
+
return r || e && o.forEach((s) => {
|
|
1590
|
+
t.removeMark(s.$from.pos, s.$to.pos);
|
|
1591
|
+
}), !0;
|
|
1592
|
+
}, Tr = (t, e = {}) => ({ tr: n, state: r, dispatch: o }) => {
|
|
1593
|
+
var s;
|
|
1594
|
+
const { extendEmptyMarkRange: i = !1 } = e, { selection: c } = n, a = D(t, r.schema), { $from: l, empty: f, ranges: u } = c;
|
|
1595
|
+
if (!o)
|
|
1596
|
+
return !0;
|
|
1597
|
+
if (f && i) {
|
|
1598
|
+
let { from: p, to: d } = c;
|
|
1599
|
+
const h = (s = l.marks().find((g) => g.type === a)) == null ? void 0 : s.attrs, m = wt(l, a, h);
|
|
1600
|
+
m && (p = m.from, d = m.to), n.removeMark(p, d, a);
|
|
1601
|
+
} else
|
|
1602
|
+
u.forEach((p) => {
|
|
1603
|
+
n.removeMark(p.$from.pos, p.$to.pos, a);
|
|
1604
|
+
});
|
|
1605
|
+
return n.removeStoredMark(a), !0;
|
|
1606
|
+
}, Ar = (t) => ({ tr: e, state: n, dispatch: r }) => {
|
|
1607
|
+
const { selection: o } = n;
|
|
1608
|
+
let s, i;
|
|
1609
|
+
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) => {
|
|
1610
|
+
if (c.isText)
|
|
1611
|
+
return;
|
|
1612
|
+
const l = { ...c.attrs };
|
|
1613
|
+
delete l.dir, e.setNodeMarkup(a, void 0, l);
|
|
1614
|
+
}), !0;
|
|
1615
|
+
}, Cr = (t, e = {}) => ({ tr: n, state: r, dispatch: o }) => {
|
|
1616
|
+
let s = null, i = null;
|
|
1617
|
+
const c = ct(
|
|
1618
|
+
typeof t == "string" ? t : t.name,
|
|
1619
|
+
r.schema
|
|
1620
|
+
);
|
|
1621
|
+
if (!c)
|
|
1622
|
+
return !1;
|
|
1623
|
+
c === "node" && (s = T(t, r.schema)), c === "mark" && (i = D(t, r.schema));
|
|
1624
|
+
let a = !1;
|
|
1625
|
+
return n.selection.ranges.forEach((l) => {
|
|
1626
|
+
const f = l.$from.pos, u = l.$to.pos;
|
|
1627
|
+
let p, d, h, m;
|
|
1628
|
+
n.selection.empty ? r.doc.nodesBetween(f, u, (g, v) => {
|
|
1629
|
+
s && s === g.type && (a = !0, h = Math.max(v, f), m = Math.min(v + g.nodeSize, u), p = v, d = g);
|
|
1630
|
+
}) : r.doc.nodesBetween(f, u, (g, v) => {
|
|
1631
|
+
v < f && s && s === g.type && (a = !0, h = Math.max(v, f), m = Math.min(v + g.nodeSize, u), p = v, d = g), v >= f && v <= u && (s && s === g.type && (a = !0, o && n.setNodeMarkup(v, void 0, {
|
|
1632
|
+
...g.attrs,
|
|
1633
|
+
...e
|
|
1634
|
+
})), i && g.marks.length && g.marks.forEach((y) => {
|
|
1635
|
+
if (i === y.type && (a = !0, o)) {
|
|
1636
|
+
const w = Math.max(v, f), x = Math.min(v + g.nodeSize, u);
|
|
1637
|
+
n.addMark(
|
|
1638
|
+
w,
|
|
1639
|
+
x,
|
|
1640
|
+
i.create({
|
|
1641
|
+
...y.attrs,
|
|
1642
|
+
...e
|
|
1643
|
+
})
|
|
1644
|
+
);
|
|
1645
|
+
}
|
|
1646
|
+
}));
|
|
1647
|
+
}), d && (p !== void 0 && o && n.setNodeMarkup(p, void 0, {
|
|
1648
|
+
...d.attrs,
|
|
1649
|
+
...e
|
|
1650
|
+
}), i && d.marks.length && d.marks.forEach((g) => {
|
|
1651
|
+
i === g.type && o && n.addMark(
|
|
1652
|
+
h,
|
|
1653
|
+
m,
|
|
1654
|
+
i.create({
|
|
1655
|
+
...g.attrs,
|
|
1656
|
+
...e
|
|
1657
|
+
})
|
|
1658
|
+
);
|
|
1659
|
+
}));
|
|
1660
|
+
}), a;
|
|
1661
|
+
}, Pr = (t, e = {}) => ({ state: n, dispatch: r }) => {
|
|
1662
|
+
const o = T(t, n.schema);
|
|
1663
|
+
return Fe(o, e)(n, r);
|
|
1664
|
+
}, $r = (t, e = {}) => ({ state: n, dispatch: r }) => {
|
|
1665
|
+
const o = T(t, n.schema);
|
|
1666
|
+
return Ke(o, e)(n, r);
|
|
1667
|
+
}, Nr = class {
|
|
1668
|
+
constructor() {
|
|
1669
|
+
this.callbacks = {};
|
|
1670
|
+
}
|
|
1671
|
+
on(t, e) {
|
|
1672
|
+
return this.callbacks[t] || (this.callbacks[t] = []), this.callbacks[t].push(e), this;
|
|
1673
|
+
}
|
|
1674
|
+
emit(t, ...e) {
|
|
1675
|
+
const n = this.callbacks[t];
|
|
1676
|
+
return n && n.forEach((r) => r.apply(this, e)), this;
|
|
1677
|
+
}
|
|
1678
|
+
off(t, e) {
|
|
1679
|
+
const n = this.callbacks[t];
|
|
1680
|
+
return n && (e ? this.callbacks[t] = n.filter((r) => r !== e) : delete this.callbacks[t]), this;
|
|
1681
|
+
}
|
|
1682
|
+
once(t, e) {
|
|
1683
|
+
const n = (...r) => {
|
|
1684
|
+
this.off(t, n), e.apply(this, r);
|
|
1685
|
+
};
|
|
1686
|
+
return this.on(t, n);
|
|
1687
|
+
}
|
|
1688
|
+
removeAllListeners() {
|
|
1689
|
+
this.callbacks = {};
|
|
1690
|
+
}
|
|
1691
|
+
}, dt = class {
|
|
1692
|
+
constructor(t) {
|
|
1693
|
+
var e;
|
|
1694
|
+
this.find = t.find, this.handler = t.handler, this.undoable = (e = t.undoable) != null ? e : !0;
|
|
1695
|
+
}
|
|
1696
|
+
}, Ir = (t, e) => {
|
|
1697
|
+
if (kt(e))
|
|
1698
|
+
return e.exec(t);
|
|
1699
|
+
const n = e(t);
|
|
1700
|
+
if (!n)
|
|
1701
|
+
return null;
|
|
1702
|
+
const r = [n.text];
|
|
1703
|
+
return r.index = n.index, r.input = t, r.data = n.data, n.replaceWith && (n.text.includes(n.replaceWith) || console.warn(
|
|
1704
|
+
'[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'
|
|
1705
|
+
), r.push(n.replaceWith)), r;
|
|
1706
|
+
};
|
|
1707
|
+
function Z(t) {
|
|
1708
|
+
var e;
|
|
1709
|
+
const { editor: n, from: r, to: o, text: s, rules: i, plugin: c } = t, { view: a } = n;
|
|
1710
|
+
if (a.composing)
|
|
1711
|
+
return !1;
|
|
1712
|
+
const l = a.state.doc.resolve(r);
|
|
1713
|
+
if (
|
|
1714
|
+
// check for code node
|
|
1715
|
+
l.parent.type.spec.code || (e = l.nodeBefore || l.nodeAfter) != null && e.marks.find((p) => p.type.spec.code)
|
|
1716
|
+
)
|
|
1717
|
+
return !1;
|
|
1718
|
+
let f = !1;
|
|
1719
|
+
const u = sr(l) + s;
|
|
1720
|
+
return i.forEach((p) => {
|
|
1721
|
+
if (f)
|
|
1722
|
+
return;
|
|
1723
|
+
const d = Ir(u, p.find);
|
|
1724
|
+
if (!d)
|
|
1725
|
+
return;
|
|
1726
|
+
const h = a.state.tr, m = it({
|
|
1727
|
+
state: a.state,
|
|
1728
|
+
transaction: h
|
|
1729
|
+
}), g = {
|
|
1730
|
+
from: r - (d[0].length - s.length),
|
|
1731
|
+
to: o
|
|
1732
|
+
}, { commands: v, chain: y, can: w } = new at({
|
|
1733
|
+
editor: n,
|
|
1734
|
+
state: m
|
|
1735
|
+
});
|
|
1736
|
+
p.handler({
|
|
1737
|
+
state: m,
|
|
1738
|
+
range: g,
|
|
1739
|
+
match: d,
|
|
1740
|
+
commands: v,
|
|
1741
|
+
chain: y,
|
|
1742
|
+
can: w
|
|
1743
|
+
}) === null || !h.steps.length || (p.undoable && h.setMeta(c, {
|
|
1744
|
+
transform: h,
|
|
1745
|
+
from: r,
|
|
1746
|
+
to: o,
|
|
1747
|
+
text: s
|
|
1748
|
+
}), a.dispatch(h), f = !0);
|
|
1749
|
+
}), f;
|
|
1750
|
+
}
|
|
1751
|
+
function Or(t) {
|
|
1752
|
+
const { editor: e, rules: n } = t, r = new R({
|
|
1753
|
+
state: {
|
|
1754
|
+
init() {
|
|
1755
|
+
return null;
|
|
1756
|
+
},
|
|
1757
|
+
apply(o, s, i) {
|
|
1758
|
+
const c = o.getMeta(r);
|
|
1759
|
+
if (c)
|
|
1760
|
+
return c;
|
|
1761
|
+
const a = o.getMeta("applyInputRules");
|
|
1762
|
+
return a && setTimeout(() => {
|
|
1763
|
+
let { text: f } = a;
|
|
1764
|
+
typeof f == "string" ? f = f : f = ut(j.from(f), i.schema);
|
|
1765
|
+
const { from: u } = a, p = u + f.length;
|
|
1766
|
+
Z({
|
|
1767
|
+
editor: e,
|
|
1768
|
+
from: u,
|
|
1769
|
+
to: p,
|
|
1770
|
+
text: f,
|
|
1771
|
+
rules: n,
|
|
1772
|
+
plugin: r
|
|
1773
|
+
});
|
|
1774
|
+
}), o.selectionSet || o.docChanged ? null : s;
|
|
1775
|
+
}
|
|
1776
|
+
},
|
|
1777
|
+
props: {
|
|
1778
|
+
handleTextInput(o, s, i, c) {
|
|
1779
|
+
return Z({
|
|
1780
|
+
editor: e,
|
|
1781
|
+
from: s,
|
|
1782
|
+
to: i,
|
|
1783
|
+
text: c,
|
|
1784
|
+
rules: n,
|
|
1785
|
+
plugin: r
|
|
1786
|
+
});
|
|
1787
|
+
},
|
|
1788
|
+
handleDOMEvents: {
|
|
1789
|
+
compositionend: (o) => (setTimeout(() => {
|
|
1790
|
+
const { $cursor: s } = o.state.selection;
|
|
1791
|
+
s && Z({
|
|
1792
|
+
editor: e,
|
|
1793
|
+
from: s.pos,
|
|
1794
|
+
to: s.pos,
|
|
1795
|
+
text: "",
|
|
1796
|
+
rules: n,
|
|
1797
|
+
plugin: r
|
|
1798
|
+
});
|
|
1799
|
+
}), !1)
|
|
1800
|
+
},
|
|
1801
|
+
// add support for input rules to trigger on enter
|
|
1802
|
+
// this is useful for example for code blocks
|
|
1803
|
+
handleKeyDown(o, s) {
|
|
1804
|
+
if (s.key !== "Enter")
|
|
1805
|
+
return !1;
|
|
1806
|
+
const { $cursor: i } = o.state.selection;
|
|
1807
|
+
return i ? Z({
|
|
1808
|
+
editor: e,
|
|
1809
|
+
from: i.pos,
|
|
1810
|
+
to: i.pos,
|
|
1811
|
+
text: `
|
|
1812
|
+
`,
|
|
1813
|
+
rules: n,
|
|
1814
|
+
plugin: r
|
|
1815
|
+
}) : !1;
|
|
1816
|
+
}
|
|
1817
|
+
},
|
|
1818
|
+
// @ts-ignore
|
|
1819
|
+
isInputRules: !0
|
|
1820
|
+
});
|
|
1821
|
+
return r;
|
|
1822
|
+
}
|
|
1823
|
+
function Rr(t) {
|
|
1824
|
+
return Object.prototype.toString.call(t).slice(8, -1);
|
|
1825
|
+
}
|
|
1826
|
+
function G(t) {
|
|
1827
|
+
return Rr(t) !== "Object" ? !1 : t.constructor === Object && Object.getPrototypeOf(t) === Object.prototype;
|
|
1828
|
+
}
|
|
1829
|
+
function oe(t, e) {
|
|
1830
|
+
const n = { ...t };
|
|
1831
|
+
return G(t) && G(e) && Object.keys(e).forEach((r) => {
|
|
1832
|
+
G(e[r]) && G(t[r]) ? n[r] = oe(t[r], e[r]) : n[r] = e[r];
|
|
1833
|
+
}), n;
|
|
1834
|
+
}
|
|
1835
|
+
var Et = class {
|
|
1836
|
+
constructor(t = {}) {
|
|
1837
|
+
this.type = "extendable", this.parent = null, this.child = null, this.name = "", this.config = {
|
|
1838
|
+
name: this.name
|
|
1839
|
+
}, this.config = {
|
|
1840
|
+
...this.config,
|
|
1841
|
+
...t
|
|
1842
|
+
}, this.name = this.config.name;
|
|
1843
|
+
}
|
|
1844
|
+
get options() {
|
|
1845
|
+
return {
|
|
1846
|
+
...M(
|
|
1847
|
+
b(this, "addOptions", {
|
|
1848
|
+
name: this.name
|
|
1849
|
+
})
|
|
1850
|
+
)
|
|
1851
|
+
};
|
|
1852
|
+
}
|
|
1853
|
+
get storage() {
|
|
1854
|
+
return {
|
|
1855
|
+
...M(
|
|
1856
|
+
b(this, "addStorage", {
|
|
1857
|
+
name: this.name,
|
|
1858
|
+
options: this.options
|
|
1859
|
+
})
|
|
1860
|
+
)
|
|
1861
|
+
};
|
|
1862
|
+
}
|
|
1863
|
+
configure(t = {}) {
|
|
1864
|
+
const e = this.extend({
|
|
1865
|
+
...this.config,
|
|
1866
|
+
addOptions: () => oe(this.options, t)
|
|
1867
|
+
});
|
|
1868
|
+
return e.name = this.name, e.parent = this.parent, this.child = null, e;
|
|
1869
|
+
}
|
|
1870
|
+
extend(t = {}) {
|
|
1871
|
+
const e = new this.constructor({ ...this.config, ...t });
|
|
1872
|
+
return e.parent = this, this.child = e, e.name = "name" in t ? t.name : e.parent.name, e;
|
|
1873
|
+
}
|
|
1874
|
+
}, Br = class se extends Et {
|
|
1875
|
+
constructor() {
|
|
1876
|
+
super(...arguments), this.type = "mark";
|
|
1877
|
+
}
|
|
1878
|
+
/**
|
|
1879
|
+
* Create a new Mark instance
|
|
1880
|
+
* @param config - Mark configuration object or a function that returns a configuration object
|
|
1881
|
+
*/
|
|
1882
|
+
static create(e = {}) {
|
|
1883
|
+
const n = typeof e == "function" ? e() : e;
|
|
1884
|
+
return new se(n);
|
|
1885
|
+
}
|
|
1886
|
+
static handleExit({ editor: e, mark: n }) {
|
|
1887
|
+
const { tr: r } = e.state, o = e.state.selection.$from;
|
|
1888
|
+
if (o.pos === o.end()) {
|
|
1889
|
+
const i = o.marks();
|
|
1890
|
+
if (!!!i.find((l) => l?.type.name === n.name))
|
|
1891
|
+
return !1;
|
|
1892
|
+
const a = i.find((l) => l?.type.name === n.name);
|
|
1893
|
+
return a && r.removeStoredMark(a), r.insertText(" ", o.pos), e.view.dispatch(r), !0;
|
|
1894
|
+
}
|
|
1895
|
+
return !1;
|
|
1896
|
+
}
|
|
1897
|
+
configure(e) {
|
|
1898
|
+
return super.configure(e);
|
|
1899
|
+
}
|
|
1900
|
+
extend(e) {
|
|
1901
|
+
const n = typeof e == "function" ? e() : e;
|
|
1902
|
+
return super.extend(n);
|
|
1903
|
+
}
|
|
1904
|
+
};
|
|
1905
|
+
function Dr(t) {
|
|
1906
|
+
return typeof t == "number";
|
|
1907
|
+
}
|
|
1908
|
+
var jr = class {
|
|
1909
|
+
constructor(t) {
|
|
1910
|
+
this.find = t.find, this.handler = t.handler;
|
|
1911
|
+
}
|
|
1912
|
+
}, _r = (t, e, n) => {
|
|
1913
|
+
if (kt(e))
|
|
1914
|
+
return [...t.matchAll(e)];
|
|
1915
|
+
const r = e(t, n);
|
|
1916
|
+
return r ? r.map((o) => {
|
|
1917
|
+
const s = [o.text];
|
|
1918
|
+
return s.index = o.index, s.input = t, s.data = o.data, o.replaceWith && (o.text.includes(o.replaceWith) || console.warn(
|
|
1919
|
+
'[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'
|
|
1920
|
+
), s.push(o.replaceWith)), s;
|
|
1921
|
+
}) : [];
|
|
1922
|
+
};
|
|
1923
|
+
function Lr(t) {
|
|
1924
|
+
const { editor: e, state: n, from: r, to: o, rule: s, pasteEvent: i, dropEvent: c } = t, { commands: a, chain: l, can: f } = new at({
|
|
1925
|
+
editor: e,
|
|
1926
|
+
state: n
|
|
1927
|
+
}), u = [];
|
|
1928
|
+
return n.doc.nodesBetween(r, o, (d, h) => {
|
|
1929
|
+
var m, g, v, y, w;
|
|
1930
|
+
if ((g = (m = d.type) == null ? void 0 : m.spec) != null && g.code || !(d.isText || d.isTextblock || d.isInline))
|
|
1931
|
+
return;
|
|
1932
|
+
const x = (w = (y = (v = d.content) == null ? void 0 : v.size) != null ? y : d.nodeSize) != null ? w : 0, k = Math.max(r, h), S = Math.min(o, h + x);
|
|
1933
|
+
if (k >= S)
|
|
1934
|
+
return;
|
|
1935
|
+
const E = d.isText ? d.text || "" : d.textBetween(k - h, S - h, void 0, "");
|
|
1936
|
+
_r(E, s.find, i).forEach((C) => {
|
|
1937
|
+
if (C.index === void 0)
|
|
1938
|
+
return;
|
|
1939
|
+
const $ = k + C.index + 1, H = $ + C[0].length, L = {
|
|
1940
|
+
from: n.tr.mapping.map($),
|
|
1941
|
+
to: n.tr.mapping.map(H)
|
|
1942
|
+
}, I = s.handler({
|
|
1943
|
+
state: n,
|
|
1944
|
+
range: L,
|
|
1945
|
+
match: C,
|
|
1946
|
+
commands: a,
|
|
1947
|
+
chain: l,
|
|
1948
|
+
can: f,
|
|
1949
|
+
pasteEvent: i,
|
|
1950
|
+
dropEvent: c
|
|
1951
|
+
});
|
|
1952
|
+
u.push(I);
|
|
1953
|
+
});
|
|
1954
|
+
}), u.every((d) => d !== null);
|
|
1955
|
+
}
|
|
1956
|
+
var Y = null, zr = (t) => {
|
|
1957
|
+
var e;
|
|
1958
|
+
const n = new ClipboardEvent("paste", {
|
|
1959
|
+
clipboardData: new DataTransfer()
|
|
1960
|
+
});
|
|
1961
|
+
return (e = n.clipboardData) == null || e.setData("text/html", t), n;
|
|
1962
|
+
};
|
|
1963
|
+
function Fr(t) {
|
|
1964
|
+
const { editor: e, rules: n } = t;
|
|
1965
|
+
let r = null, o = !1, s = !1, i = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, c;
|
|
1966
|
+
try {
|
|
1967
|
+
c = typeof DragEvent < "u" ? new DragEvent("drop") : null;
|
|
1968
|
+
} catch {
|
|
1969
|
+
c = null;
|
|
1970
|
+
}
|
|
1971
|
+
const a = ({
|
|
1972
|
+
state: f,
|
|
1973
|
+
from: u,
|
|
1974
|
+
to: p,
|
|
1975
|
+
rule: d,
|
|
1976
|
+
pasteEvt: h
|
|
1977
|
+
}) => {
|
|
1978
|
+
const m = f.tr, g = it({
|
|
1979
|
+
state: f,
|
|
1980
|
+
transaction: m
|
|
1981
|
+
});
|
|
1982
|
+
if (!(!Lr({
|
|
1983
|
+
editor: e,
|
|
1984
|
+
state: g,
|
|
1985
|
+
from: Math.max(u - 1, 0),
|
|
1986
|
+
to: p.b - 1,
|
|
1987
|
+
rule: d,
|
|
1988
|
+
pasteEvent: h,
|
|
1989
|
+
dropEvent: c
|
|
1990
|
+
}) || !m.steps.length)) {
|
|
1991
|
+
try {
|
|
1992
|
+
c = typeof DragEvent < "u" ? new DragEvent("drop") : null;
|
|
1993
|
+
} catch {
|
|
1994
|
+
c = null;
|
|
1995
|
+
}
|
|
1996
|
+
return i = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, m;
|
|
1997
|
+
}
|
|
1998
|
+
};
|
|
1999
|
+
return n.map((f) => new R({
|
|
2000
|
+
// we register a global drag handler to track the current drag source element
|
|
2001
|
+
view(u) {
|
|
2002
|
+
const p = (h) => {
|
|
2003
|
+
var m;
|
|
2004
|
+
r = (m = u.dom.parentElement) != null && m.contains(h.target) ? u.dom.parentElement : null, r && (Y = e);
|
|
2005
|
+
}, d = () => {
|
|
2006
|
+
Y && (Y = null);
|
|
2007
|
+
};
|
|
2008
|
+
return window.addEventListener("dragstart", p), window.addEventListener("dragend", d), {
|
|
2009
|
+
destroy() {
|
|
2010
|
+
window.removeEventListener("dragstart", p), window.removeEventListener("dragend", d);
|
|
2011
|
+
}
|
|
2012
|
+
};
|
|
2013
|
+
},
|
|
2014
|
+
props: {
|
|
2015
|
+
handleDOMEvents: {
|
|
2016
|
+
drop: (u, p) => {
|
|
2017
|
+
if (s = r === u.dom.parentElement, c = p, !s) {
|
|
2018
|
+
const d = Y;
|
|
2019
|
+
d?.isEditable && setTimeout(() => {
|
|
2020
|
+
const h = d.state.selection;
|
|
2021
|
+
h && d.commands.deleteRange({
|
|
2022
|
+
from: h.from,
|
|
2023
|
+
to: h.to
|
|
2024
|
+
});
|
|
2025
|
+
}, 10);
|
|
2026
|
+
}
|
|
2027
|
+
return !1;
|
|
2028
|
+
},
|
|
2029
|
+
paste: (u, p) => {
|
|
2030
|
+
var d;
|
|
2031
|
+
const h = (d = p.clipboardData) == null ? void 0 : d.getData("text/html");
|
|
2032
|
+
return i = p, o = !!h?.includes("data-pm-slice"), !1;
|
|
2033
|
+
}
|
|
2034
|
+
}
|
|
2035
|
+
},
|
|
2036
|
+
appendTransaction: (u, p, d) => {
|
|
2037
|
+
const h = u[0], m = h.getMeta("uiEvent") === "paste" && !o, g = h.getMeta("uiEvent") === "drop" && !s, v = h.getMeta("applyPasteRules"), y = !!v;
|
|
2038
|
+
if (!m && !g && !y)
|
|
2039
|
+
return;
|
|
2040
|
+
if (y) {
|
|
2041
|
+
let { text: k } = v;
|
|
2042
|
+
typeof k == "string" ? k = k : k = ut(j.from(k), d.schema);
|
|
2043
|
+
const { from: S } = v, E = S + k.length, A = zr(k);
|
|
2044
|
+
return a({
|
|
2045
|
+
rule: f,
|
|
2046
|
+
state: d,
|
|
2047
|
+
from: S,
|
|
2048
|
+
to: { b: E },
|
|
2049
|
+
pasteEvt: A
|
|
2050
|
+
});
|
|
2051
|
+
}
|
|
2052
|
+
const w = p.doc.content.findDiffStart(d.doc.content), x = p.doc.content.findDiffEnd(d.doc.content);
|
|
2053
|
+
if (!(!Dr(w) || !x || w === x.b))
|
|
2054
|
+
return a({
|
|
2055
|
+
rule: f,
|
|
2056
|
+
state: d,
|
|
2057
|
+
from: w,
|
|
2058
|
+
to: x,
|
|
2059
|
+
pasteEvt: i
|
|
2060
|
+
});
|
|
2061
|
+
}
|
|
2062
|
+
}));
|
|
2063
|
+
}
|
|
2064
|
+
var ft = class {
|
|
2065
|
+
constructor(t, e) {
|
|
2066
|
+
this.splittableMarks = [], this.editor = e, this.baseExtensions = t, this.extensions = Mt(t), this.schema = Gt(this.extensions, e), this.setupExtensions();
|
|
2067
|
+
}
|
|
2068
|
+
/**
|
|
2069
|
+
* Get all commands from the extensions.
|
|
2070
|
+
* @returns An object with all commands where the key is the command name and the value is the command function
|
|
2071
|
+
*/
|
|
2072
|
+
get commands() {
|
|
2073
|
+
return this.extensions.reduce((t, e) => {
|
|
2074
|
+
const n = {
|
|
2075
|
+
name: e.name,
|
|
2076
|
+
options: e.options,
|
|
2077
|
+
storage: this.editor.extensionStorage[e.name],
|
|
2078
|
+
editor: this.editor,
|
|
2079
|
+
type: W(e.name, this.schema)
|
|
2080
|
+
}, r = b(
|
|
2081
|
+
e,
|
|
2082
|
+
"addCommands",
|
|
2083
|
+
n
|
|
2084
|
+
);
|
|
2085
|
+
return r ? {
|
|
2086
|
+
...t,
|
|
2087
|
+
...r()
|
|
2088
|
+
} : t;
|
|
2089
|
+
}, {});
|
|
2090
|
+
}
|
|
2091
|
+
/**
|
|
2092
|
+
* Get all registered Prosemirror plugins from the extensions.
|
|
2093
|
+
* @returns An array of Prosemirror plugins
|
|
2094
|
+
*/
|
|
2095
|
+
get plugins() {
|
|
2096
|
+
const { editor: t } = this;
|
|
2097
|
+
return J([...this.extensions].reverse()).flatMap((r) => {
|
|
2098
|
+
const o = {
|
|
2099
|
+
name: r.name,
|
|
2100
|
+
options: r.options,
|
|
2101
|
+
storage: this.editor.extensionStorage[r.name],
|
|
2102
|
+
editor: t,
|
|
2103
|
+
type: W(r.name, this.schema)
|
|
2104
|
+
}, s = [], i = b(
|
|
2105
|
+
r,
|
|
2106
|
+
"addKeyboardShortcuts",
|
|
2107
|
+
o
|
|
2108
|
+
);
|
|
2109
|
+
let c = {};
|
|
2110
|
+
if (r.type === "mark" && b(r, "exitable", o) && (c.ArrowRight = () => Br.handleExit({ editor: t, mark: r })), i) {
|
|
2111
|
+
const p = Object.fromEntries(
|
|
2112
|
+
Object.entries(i()).map(([d, h]) => [d, () => h({ editor: t })])
|
|
2113
|
+
);
|
|
2114
|
+
c = { ...c, ...p };
|
|
2115
|
+
}
|
|
2116
|
+
const a = Ze(c);
|
|
2117
|
+
s.push(a);
|
|
2118
|
+
const l = b(
|
|
2119
|
+
r,
|
|
2120
|
+
"addInputRules",
|
|
2121
|
+
o
|
|
2122
|
+
);
|
|
2123
|
+
if (jt(r, t.options.enableInputRules) && l) {
|
|
2124
|
+
const p = l();
|
|
2125
|
+
if (p && p.length) {
|
|
2126
|
+
const d = Or({
|
|
2127
|
+
editor: t,
|
|
2128
|
+
rules: p
|
|
2129
|
+
}), h = Array.isArray(d) ? d : [d];
|
|
2130
|
+
s.push(...h);
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
const f = b(
|
|
2134
|
+
r,
|
|
2135
|
+
"addPasteRules",
|
|
2136
|
+
o
|
|
2137
|
+
);
|
|
2138
|
+
if (jt(r, t.options.enablePasteRules) && f) {
|
|
2139
|
+
const p = f();
|
|
2140
|
+
if (p && p.length) {
|
|
2141
|
+
const d = Fr({ editor: t, rules: p });
|
|
2142
|
+
s.push(...d);
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
const u = b(
|
|
2146
|
+
r,
|
|
2147
|
+
"addProseMirrorPlugins",
|
|
2148
|
+
o
|
|
2149
|
+
);
|
|
2150
|
+
if (u) {
|
|
2151
|
+
const p = u();
|
|
2152
|
+
s.push(...p);
|
|
2153
|
+
}
|
|
2154
|
+
return s;
|
|
2155
|
+
});
|
|
2156
|
+
}
|
|
2157
|
+
/**
|
|
2158
|
+
* Get all attributes from the extensions.
|
|
2159
|
+
* @returns An array of attributes
|
|
2160
|
+
*/
|
|
2161
|
+
get attributes() {
|
|
2162
|
+
return Zt(this.extensions);
|
|
2163
|
+
}
|
|
2164
|
+
/**
|
|
2165
|
+
* Get all node views from the extensions.
|
|
2166
|
+
* @returns An object with all node views where the key is the node name and the value is the node view function
|
|
2167
|
+
*/
|
|
2168
|
+
get nodeViews() {
|
|
2169
|
+
const { editor: t } = this, { nodeExtensions: e } = V(this.extensions);
|
|
2170
|
+
return Object.fromEntries(
|
|
2171
|
+
e.filter((n) => !!b(n, "addNodeView")).map((n) => {
|
|
2172
|
+
const r = this.attributes.filter(
|
|
2173
|
+
(a) => a.type === n.name
|
|
2174
|
+
), o = {
|
|
2175
|
+
name: n.name,
|
|
2176
|
+
options: n.options,
|
|
2177
|
+
storage: this.editor.extensionStorage[n.name],
|
|
2178
|
+
editor: t,
|
|
2179
|
+
type: T(n.name, this.schema)
|
|
2180
|
+
}, s = b(
|
|
2181
|
+
n,
|
|
2182
|
+
"addNodeView",
|
|
2183
|
+
o
|
|
2184
|
+
);
|
|
2185
|
+
if (!s)
|
|
2186
|
+
return [];
|
|
2187
|
+
const i = s();
|
|
2188
|
+
if (!i)
|
|
2189
|
+
return [];
|
|
2190
|
+
const c = (a, l, f, u, p) => {
|
|
2191
|
+
const d = ot(a, r);
|
|
2192
|
+
return i({
|
|
2193
|
+
// pass-through
|
|
2194
|
+
node: a,
|
|
2195
|
+
view: l,
|
|
2196
|
+
getPos: f,
|
|
2197
|
+
decorations: u,
|
|
2198
|
+
innerDecorations: p,
|
|
2199
|
+
// tiptap-specific
|
|
2200
|
+
editor: t,
|
|
2201
|
+
extension: n,
|
|
2202
|
+
HTMLAttributes: d
|
|
2203
|
+
});
|
|
2204
|
+
};
|
|
2205
|
+
return [n.name, c];
|
|
2206
|
+
})
|
|
2207
|
+
);
|
|
2208
|
+
}
|
|
2209
|
+
/**
|
|
2210
|
+
* Get the composed dispatchTransaction function from all extensions.
|
|
2211
|
+
* @param baseDispatch The base dispatch function (e.g. from the editor or user props)
|
|
2212
|
+
* @returns A composed dispatch function
|
|
2213
|
+
*/
|
|
2214
|
+
dispatchTransaction(t) {
|
|
2215
|
+
const { editor: e } = this;
|
|
2216
|
+
return J([...this.extensions].reverse()).reduceRight((r, o) => {
|
|
2217
|
+
const s = {
|
|
2218
|
+
name: o.name,
|
|
2219
|
+
options: o.options,
|
|
2220
|
+
storage: this.editor.extensionStorage[o.name],
|
|
2221
|
+
editor: e,
|
|
2222
|
+
type: W(o.name, this.schema)
|
|
2223
|
+
}, i = b(
|
|
2224
|
+
o,
|
|
2225
|
+
"dispatchTransaction",
|
|
2226
|
+
s
|
|
2227
|
+
);
|
|
2228
|
+
return i ? (c) => {
|
|
2229
|
+
i.call(s, { transaction: c, next: r });
|
|
2230
|
+
} : r;
|
|
2231
|
+
}, t);
|
|
2232
|
+
}
|
|
2233
|
+
/**
|
|
2234
|
+
* Get the composed transformPastedHTML function from all extensions.
|
|
2235
|
+
* @param baseTransform The base transform function (e.g. from the editor props)
|
|
2236
|
+
* @returns A composed transform function that chains all extension transforms
|
|
2237
|
+
*/
|
|
2238
|
+
transformPastedHTML(t) {
|
|
2239
|
+
const { editor: e } = this;
|
|
2240
|
+
return J([...this.extensions]).reduce(
|
|
2241
|
+
(r, o) => {
|
|
2242
|
+
const s = {
|
|
2243
|
+
name: o.name,
|
|
2244
|
+
options: o.options,
|
|
2245
|
+
storage: this.editor.extensionStorage[o.name],
|
|
2246
|
+
editor: e,
|
|
2247
|
+
type: W(o.name, this.schema)
|
|
2248
|
+
}, i = b(
|
|
2249
|
+
o,
|
|
2250
|
+
"transformPastedHTML",
|
|
2251
|
+
s
|
|
2252
|
+
);
|
|
2253
|
+
return i ? (c, a) => {
|
|
2254
|
+
const l = r(c, a);
|
|
2255
|
+
return i.call(s, l);
|
|
2256
|
+
} : r;
|
|
2257
|
+
},
|
|
2258
|
+
t || ((r) => r)
|
|
2259
|
+
);
|
|
2260
|
+
}
|
|
2261
|
+
get markViews() {
|
|
2262
|
+
const { editor: t } = this, { markExtensions: e } = V(this.extensions);
|
|
2263
|
+
return Object.fromEntries(
|
|
2264
|
+
e.filter((n) => !!b(n, "addMarkView")).map((n) => {
|
|
2265
|
+
const r = this.attributes.filter(
|
|
2266
|
+
(c) => c.type === n.name
|
|
2267
|
+
), o = {
|
|
2268
|
+
name: n.name,
|
|
2269
|
+
options: n.options,
|
|
2270
|
+
storage: this.editor.extensionStorage[n.name],
|
|
2271
|
+
editor: t,
|
|
2272
|
+
type: D(n.name, this.schema)
|
|
2273
|
+
}, s = b(
|
|
2274
|
+
n,
|
|
2275
|
+
"addMarkView",
|
|
2276
|
+
o
|
|
2277
|
+
);
|
|
2278
|
+
if (!s)
|
|
2279
|
+
return [];
|
|
2280
|
+
const i = (c, a, l) => {
|
|
2281
|
+
const f = ot(c, r);
|
|
2282
|
+
return s()({
|
|
2283
|
+
// pass-through
|
|
2284
|
+
mark: c,
|
|
2285
|
+
view: a,
|
|
2286
|
+
inline: l,
|
|
2287
|
+
// tiptap-specific
|
|
2288
|
+
editor: t,
|
|
2289
|
+
extension: n,
|
|
2290
|
+
HTMLAttributes: f,
|
|
2291
|
+
updateAttributes: (u) => {
|
|
2292
|
+
to(c, t, u);
|
|
2293
|
+
}
|
|
2294
|
+
});
|
|
2295
|
+
};
|
|
2296
|
+
return [n.name, i];
|
|
2297
|
+
})
|
|
2298
|
+
);
|
|
2299
|
+
}
|
|
2300
|
+
/**
|
|
2301
|
+
* Destroy the extension manager and clean up all extension references
|
|
2302
|
+
* to prevent memory leaks through parent/child extension chains.
|
|
2303
|
+
*
|
|
2304
|
+
* Walks each extension's full parent chain and nulls every forward
|
|
2305
|
+
* `parent.child → current` link where the parent still points to the
|
|
2306
|
+
* current node. This breaks the retention path from module-scope
|
|
2307
|
+
* singleton roots through deep extend() chains.
|
|
2308
|
+
*
|
|
2309
|
+
* Only ancestor `.child` links matching the current chain are cleared.
|
|
2310
|
+
* The `.parent` pointer on ancestors is never touched — extensions
|
|
2311
|
+
* may be shared across live editors, so their own backward references
|
|
2312
|
+
* and non-matching forward links must remain intact.
|
|
2313
|
+
*/
|
|
2314
|
+
destroy() {
|
|
2315
|
+
this.extensions.forEach((t) => {
|
|
2316
|
+
let e = t;
|
|
2317
|
+
for (; e.parent; ) {
|
|
2318
|
+
const n = e.parent;
|
|
2319
|
+
n.child === e && (n.child = null), e = n;
|
|
2320
|
+
}
|
|
2321
|
+
}), this.extensions = [], this.baseExtensions = [], this.schema = null, this.editor = null;
|
|
2322
|
+
}
|
|
2323
|
+
/**
|
|
2324
|
+
* Go through all extensions, create extension storages & setup marks
|
|
2325
|
+
* & bind editor event listener.
|
|
2326
|
+
*/
|
|
2327
|
+
setupExtensions() {
|
|
2328
|
+
const t = this.extensions;
|
|
2329
|
+
this.editor.extensionStorage = Object.fromEntries(
|
|
2330
|
+
t.map((e) => [e.name, e.storage])
|
|
2331
|
+
), t.forEach((e) => {
|
|
2332
|
+
var n;
|
|
2333
|
+
const r = {
|
|
2334
|
+
name: e.name,
|
|
2335
|
+
options: e.options,
|
|
2336
|
+
storage: this.editor.extensionStorage[e.name],
|
|
2337
|
+
editor: this.editor,
|
|
2338
|
+
type: W(e.name, this.schema)
|
|
2339
|
+
};
|
|
2340
|
+
e.type === "mark" && ((n = M(b(e, "keepOnSplit", r))) == null || n) && this.splittableMarks.push(e.name);
|
|
2341
|
+
const o = b(
|
|
2342
|
+
e,
|
|
2343
|
+
"onBeforeCreate",
|
|
2344
|
+
r
|
|
2345
|
+
), s = b(e, "onCreate", r), i = b(e, "onUpdate", r), c = b(
|
|
2346
|
+
e,
|
|
2347
|
+
"onSelectionUpdate",
|
|
2348
|
+
r
|
|
2349
|
+
), a = b(
|
|
2350
|
+
e,
|
|
2351
|
+
"onTransaction",
|
|
2352
|
+
r
|
|
2353
|
+
), l = b(e, "onFocus", r), f = b(e, "onBlur", r), u = b(e, "onDestroy", r);
|
|
2354
|
+
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), f && this.editor.on("blur", f), u && this.editor.on("destroy", u);
|
|
2355
|
+
});
|
|
2356
|
+
}
|
|
2357
|
+
};
|
|
2358
|
+
ft.resolve = Mt;
|
|
2359
|
+
ft.sort = J;
|
|
2360
|
+
ft.flatten = xt;
|
|
2361
|
+
var Vr = {};
|
|
2362
|
+
yt(Vr, {
|
|
2363
|
+
ClipboardTextSerializer: () => ae,
|
|
2364
|
+
Commands: () => ce,
|
|
2365
|
+
Delete: () => le,
|
|
2366
|
+
Drop: () => ue,
|
|
2367
|
+
Editable: () => de,
|
|
2368
|
+
FocusEvents: () => pe,
|
|
2369
|
+
Keymap: () => me,
|
|
2370
|
+
Paste: () => he,
|
|
2371
|
+
Tabindex: () => ge,
|
|
2372
|
+
TextDirection: () => ve,
|
|
2373
|
+
focusEventsPluginKey: () => fe
|
|
2374
|
+
});
|
|
2375
|
+
var B = class ie extends Et {
|
|
2376
|
+
constructor() {
|
|
2377
|
+
super(...arguments), this.type = "extension";
|
|
2378
|
+
}
|
|
2379
|
+
/**
|
|
2380
|
+
* Create a new Extension instance
|
|
2381
|
+
* @param config - Extension configuration object or a function that returns a configuration object
|
|
2382
|
+
*/
|
|
2383
|
+
static create(e = {}) {
|
|
2384
|
+
const n = typeof e == "function" ? e() : e;
|
|
2385
|
+
return new ie(n);
|
|
2386
|
+
}
|
|
2387
|
+
configure(e) {
|
|
2388
|
+
return super.configure(e);
|
|
2389
|
+
}
|
|
2390
|
+
extend(e) {
|
|
2391
|
+
const n = typeof e == "function" ? e() : e;
|
|
2392
|
+
return super.extend(n);
|
|
2393
|
+
}
|
|
2394
|
+
}, ae = B.create({
|
|
2395
|
+
name: "clipboardTextSerializer",
|
|
2396
|
+
addOptions() {
|
|
2397
|
+
return {
|
|
2398
|
+
blockSeparator: void 0
|
|
2399
|
+
};
|
|
2400
|
+
},
|
|
2401
|
+
addProseMirrorPlugins() {
|
|
2402
|
+
return [
|
|
2403
|
+
new R({
|
|
2404
|
+
key: new _("clipboardTextSerializer"),
|
|
2405
|
+
props: {
|
|
2406
|
+
clipboardTextSerializer: () => {
|
|
2407
|
+
const { editor: t } = this, { state: e, schema: n } = t, { doc: r, selection: o } = e, { ranges: s } = o, i = Math.min(...s.map((f) => f.$from.pos)), c = Math.max(...s.map((f) => f.$to.pos)), a = te(n);
|
|
2408
|
+
return Xt(r, { from: i, to: c }, {
|
|
2409
|
+
...this.options.blockSeparator !== void 0 ? { blockSeparator: this.options.blockSeparator } : {},
|
|
2410
|
+
textSerializers: a
|
|
2411
|
+
});
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2414
|
+
})
|
|
2415
|
+
];
|
|
2416
|
+
}
|
|
2417
|
+
}), ce = B.create({
|
|
2418
|
+
name: "commands",
|
|
2419
|
+
addCommands() {
|
|
2420
|
+
return {
|
|
2421
|
+
...Vt
|
|
2422
|
+
};
|
|
2423
|
+
}
|
|
2424
|
+
}), le = B.create({
|
|
2425
|
+
name: "delete",
|
|
2426
|
+
onUpdate({ transaction: t, appendedTransactions: e }) {
|
|
2427
|
+
var n, r, o;
|
|
2428
|
+
const s = () => {
|
|
2429
|
+
var i, c, a, l;
|
|
2430
|
+
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$"))
|
|
2431
|
+
return;
|
|
2432
|
+
const f = Un(t.before, [
|
|
2433
|
+
t,
|
|
2434
|
+
...e
|
|
2435
|
+
]);
|
|
2436
|
+
or(f).forEach((d) => {
|
|
2437
|
+
f.mapping.mapResult(d.oldRange.from).deletedAfter && f.mapping.mapResult(d.oldRange.to).deletedBefore && f.before.nodesBetween(
|
|
2438
|
+
d.oldRange.from,
|
|
2439
|
+
d.oldRange.to,
|
|
2440
|
+
(h, m) => {
|
|
2441
|
+
const g = m + h.nodeSize - 2, v = d.oldRange.from <= m && g <= d.oldRange.to;
|
|
2442
|
+
this.editor.emit("delete", {
|
|
2443
|
+
type: "node",
|
|
2444
|
+
node: h,
|
|
2445
|
+
from: m,
|
|
2446
|
+
to: g,
|
|
2447
|
+
newFrom: f.mapping.map(m),
|
|
2448
|
+
newTo: f.mapping.map(g),
|
|
2449
|
+
deletedRange: d.oldRange,
|
|
2450
|
+
newRange: d.newRange,
|
|
2451
|
+
partial: !v,
|
|
2452
|
+
editor: this.editor,
|
|
2453
|
+
transaction: t,
|
|
2454
|
+
combinedTransform: f
|
|
2455
|
+
});
|
|
2456
|
+
}
|
|
2457
|
+
);
|
|
2458
|
+
});
|
|
2459
|
+
const p = f.mapping;
|
|
2460
|
+
f.steps.forEach((d, h) => {
|
|
2461
|
+
var m, g;
|
|
2462
|
+
if (d instanceof we) {
|
|
2463
|
+
const v = p.slice(h).map(d.from, -1), y = p.slice(h).map(d.to), w = p.invert().map(v, -1), x = p.invert().map(y), k = v > 0 ? (m = f.doc.nodeAt(v - 1)) == null ? void 0 : m.marks.some((E) => E.eq(d.mark)) : !1, S = (g = f.doc.nodeAt(y)) == null ? void 0 : g.marks.some((E) => E.eq(d.mark));
|
|
2464
|
+
this.editor.emit("delete", {
|
|
2465
|
+
type: "mark",
|
|
2466
|
+
mark: d.mark,
|
|
2467
|
+
from: d.from,
|
|
2468
|
+
to: d.to,
|
|
2469
|
+
deletedRange: {
|
|
2470
|
+
from: w,
|
|
2471
|
+
to: x
|
|
2472
|
+
},
|
|
2473
|
+
newRange: {
|
|
2474
|
+
from: v,
|
|
2475
|
+
to: y
|
|
2476
|
+
},
|
|
2477
|
+
partial: !!(S || k),
|
|
2478
|
+
editor: this.editor,
|
|
2479
|
+
transaction: t,
|
|
2480
|
+
combinedTransform: f
|
|
2481
|
+
});
|
|
2482
|
+
}
|
|
2483
|
+
});
|
|
2484
|
+
};
|
|
2485
|
+
(o = (r = (n = this.editor.options.coreExtensionOptions) == null ? void 0 : n.delete) == null ? void 0 : r.async) == null || o ? setTimeout(s, 0) : s();
|
|
2486
|
+
}
|
|
2487
|
+
}), ue = B.create({
|
|
2488
|
+
name: "drop",
|
|
2489
|
+
addProseMirrorPlugins() {
|
|
2490
|
+
return [
|
|
2491
|
+
new R({
|
|
2492
|
+
key: new _("tiptapDrop"),
|
|
2493
|
+
props: {
|
|
2494
|
+
handleDrop: (t, e, n, r) => {
|
|
2495
|
+
this.editor.emit("drop", {
|
|
2496
|
+
editor: this.editor,
|
|
2497
|
+
event: e,
|
|
2498
|
+
slice: n,
|
|
2499
|
+
moved: r
|
|
2500
|
+
});
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2503
|
+
})
|
|
2504
|
+
];
|
|
2505
|
+
}
|
|
2506
|
+
}), de = B.create({
|
|
2507
|
+
name: "editable",
|
|
2508
|
+
addProseMirrorPlugins() {
|
|
2509
|
+
return [
|
|
2510
|
+
new R({
|
|
2511
|
+
key: new _("editable"),
|
|
2512
|
+
props: {
|
|
2513
|
+
editable: () => this.editor.options.editable
|
|
2514
|
+
}
|
|
2515
|
+
})
|
|
2516
|
+
];
|
|
2517
|
+
}
|
|
2518
|
+
}), fe = new _("focusEvents"), pe = B.create({
|
|
2519
|
+
name: "focusEvents",
|
|
2520
|
+
addProseMirrorPlugins() {
|
|
2521
|
+
const { editor: t } = this;
|
|
2522
|
+
return [
|
|
2523
|
+
new R({
|
|
2524
|
+
key: fe,
|
|
2525
|
+
props: {
|
|
2526
|
+
handleDOMEvents: {
|
|
2527
|
+
focus: (e, n) => {
|
|
2528
|
+
t.isFocused = !0;
|
|
2529
|
+
const r = t.state.tr.setMeta("focus", { event: n }).setMeta("addToHistory", !1);
|
|
2530
|
+
return e.dispatch(r), !1;
|
|
2531
|
+
},
|
|
2532
|
+
blur: (e, n) => {
|
|
2533
|
+
t.isFocused = !1;
|
|
2534
|
+
const r = t.state.tr.setMeta("blur", { event: n }).setMeta("addToHistory", !1);
|
|
2535
|
+
return e.dispatch(r), !1;
|
|
2536
|
+
}
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
})
|
|
2540
|
+
];
|
|
2541
|
+
}
|
|
2542
|
+
}), me = B.create({
|
|
2543
|
+
name: "keymap",
|
|
2544
|
+
addKeyboardShortcuts() {
|
|
2545
|
+
const t = () => this.editor.commands.first(({ commands: i }) => [
|
|
2546
|
+
() => i.undoInputRule(),
|
|
2547
|
+
// maybe convert first text block node to default node
|
|
2548
|
+
() => i.command(({ tr: c }) => {
|
|
2549
|
+
const { selection: a, doc: l } = c, { empty: f, $anchor: u } = a, { pos: p, parent: d } = u, h = u.parent.isTextblock && p > 0 ? c.doc.resolve(p - 1) : u, m = h.parent.type.spec.isolating, g = u.pos - u.parentOffset, v = m && h.parent.childCount === 1 ? g === u.pos : F.atStart(l).from === p;
|
|
2550
|
+
return !f || !d.type.isTextblock || d.textContent.length || !v || v && u.parent.type.name === "paragraph" ? !1 : i.clearNodes();
|
|
2551
|
+
}),
|
|
2552
|
+
() => i.deleteSelection(),
|
|
2553
|
+
() => i.joinBackward(),
|
|
2554
|
+
() => i.selectNodeBackward()
|
|
2555
|
+
]), e = () => this.editor.commands.first(({ commands: i }) => [
|
|
2556
|
+
() => i.deleteSelection(),
|
|
2557
|
+
() => i.deleteCurrentNode(),
|
|
2558
|
+
() => i.joinForward(),
|
|
2559
|
+
() => i.selectNodeForward()
|
|
2560
|
+
]), r = {
|
|
2561
|
+
Enter: () => this.editor.commands.first(({ commands: i }) => [
|
|
2562
|
+
() => i.newlineInCode(),
|
|
2563
|
+
() => i.createParagraphNear(),
|
|
2564
|
+
() => i.liftEmptyBlock(),
|
|
2565
|
+
() => i.splitBlock()
|
|
2566
|
+
]),
|
|
2567
|
+
"Mod-Enter": () => this.editor.commands.exitCode(),
|
|
2568
|
+
Backspace: t,
|
|
2569
|
+
"Mod-Backspace": t,
|
|
2570
|
+
"Shift-Backspace": t,
|
|
2571
|
+
Delete: e,
|
|
2572
|
+
"Mod-Delete": e,
|
|
2573
|
+
"Mod-a": () => this.editor.commands.selectAll()
|
|
2574
|
+
}, o = {
|
|
2575
|
+
...r
|
|
2576
|
+
}, s = {
|
|
2577
|
+
...r,
|
|
2578
|
+
"Ctrl-h": t,
|
|
2579
|
+
"Alt-Backspace": t,
|
|
2580
|
+
"Ctrl-d": e,
|
|
2581
|
+
"Ctrl-Alt-Backspace": e,
|
|
2582
|
+
"Alt-Delete": e,
|
|
2583
|
+
"Alt-d": e,
|
|
2584
|
+
"Ctrl-a": () => this.editor.commands.selectTextblockStart(),
|
|
2585
|
+
"Ctrl-e": () => this.editor.commands.selectTextblockEnd()
|
|
2586
|
+
};
|
|
2587
|
+
return rt() || Jt() ? s : o;
|
|
2588
|
+
},
|
|
2589
|
+
addProseMirrorPlugins() {
|
|
2590
|
+
return [
|
|
2591
|
+
// With this plugin we check if the whole document was selected and deleted.
|
|
2592
|
+
// In this case we will additionally call `clearNodes()` to convert e.g. a heading
|
|
2593
|
+
// to a paragraph if necessary.
|
|
2594
|
+
// This is an alternative to ProseMirror's `AllSelection`, which doesn’t work well
|
|
2595
|
+
// with many other commands.
|
|
2596
|
+
new R({
|
|
2597
|
+
key: new _("clearDocument"),
|
|
2598
|
+
appendTransaction: (t, e, n) => {
|
|
2599
|
+
if (t.some((m) => m.getMeta("composition")))
|
|
2600
|
+
return;
|
|
2601
|
+
const r = t.some((m) => m.docChanged) && !e.doc.eq(n.doc), o = t.some(
|
|
2602
|
+
(m) => m.getMeta("preventClearDocument")
|
|
2603
|
+
);
|
|
2604
|
+
if (!r || o)
|
|
2605
|
+
return;
|
|
2606
|
+
const { empty: s, from: i, to: c } = e.selection, a = F.atStart(e.doc).from, l = F.atEnd(e.doc).to;
|
|
2607
|
+
if (s || !(i === a && c === l) || !St(n.doc))
|
|
2608
|
+
return;
|
|
2609
|
+
const p = n.tr, d = it({
|
|
2610
|
+
state: n,
|
|
2611
|
+
transaction: p
|
|
2612
|
+
}), { commands: h } = new at({
|
|
2613
|
+
editor: this.editor,
|
|
2614
|
+
state: d
|
|
2615
|
+
});
|
|
2616
|
+
if (h.clearNodes(), !!p.steps.length)
|
|
2617
|
+
return p;
|
|
2618
|
+
}
|
|
2619
|
+
})
|
|
2620
|
+
];
|
|
2621
|
+
}
|
|
2622
|
+
}), he = B.create({
|
|
2623
|
+
name: "paste",
|
|
2624
|
+
addProseMirrorPlugins() {
|
|
2625
|
+
return [
|
|
2626
|
+
new R({
|
|
2627
|
+
key: new _("tiptapPaste"),
|
|
2628
|
+
props: {
|
|
2629
|
+
handlePaste: (t, e, n) => {
|
|
2630
|
+
this.editor.emit("paste", {
|
|
2631
|
+
editor: this.editor,
|
|
2632
|
+
event: e,
|
|
2633
|
+
slice: n
|
|
2634
|
+
});
|
|
2635
|
+
}
|
|
2636
|
+
}
|
|
2637
|
+
})
|
|
2638
|
+
];
|
|
2639
|
+
}
|
|
2640
|
+
}), ge = B.create({
|
|
2641
|
+
name: "tabindex",
|
|
2642
|
+
addOptions() {
|
|
2643
|
+
return {
|
|
2644
|
+
value: void 0
|
|
2645
|
+
};
|
|
2646
|
+
},
|
|
2647
|
+
addProseMirrorPlugins() {
|
|
2648
|
+
return [
|
|
2649
|
+
new R({
|
|
2650
|
+
key: new _("tabindex"),
|
|
2651
|
+
props: {
|
|
2652
|
+
attributes: () => {
|
|
2653
|
+
var t;
|
|
2654
|
+
return !this.editor.isEditable && this.options.value === void 0 ? {} : { tabindex: (t = this.options.value) != null ? t : "0" };
|
|
2655
|
+
}
|
|
2656
|
+
}
|
|
2657
|
+
})
|
|
2658
|
+
];
|
|
2659
|
+
}
|
|
2660
|
+
}), ve = B.create({
|
|
2661
|
+
name: "textDirection",
|
|
2662
|
+
addOptions() {
|
|
2663
|
+
return {
|
|
2664
|
+
direction: void 0
|
|
2665
|
+
};
|
|
2666
|
+
},
|
|
2667
|
+
addGlobalAttributes() {
|
|
2668
|
+
if (!this.options.direction)
|
|
2669
|
+
return [];
|
|
2670
|
+
const { nodeExtensions: t } = V(this.extensions);
|
|
2671
|
+
return [
|
|
2672
|
+
{
|
|
2673
|
+
types: t.filter((e) => e.name !== "text").map((e) => e.name),
|
|
2674
|
+
attributes: {
|
|
2675
|
+
dir: {
|
|
2676
|
+
default: this.options.direction,
|
|
2677
|
+
parseHTML: (e) => {
|
|
2678
|
+
const n = e.getAttribute("dir");
|
|
2679
|
+
return n && (n === "ltr" || n === "rtl" || n === "auto") ? n : this.options.direction;
|
|
2680
|
+
},
|
|
2681
|
+
renderHTML: (e) => e.dir ? {
|
|
2682
|
+
dir: e.dir
|
|
2683
|
+
} : {}
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
];
|
|
2688
|
+
},
|
|
2689
|
+
addProseMirrorPlugins() {
|
|
2690
|
+
return [
|
|
2691
|
+
new R({
|
|
2692
|
+
key: new _("textDirection"),
|
|
2693
|
+
props: {
|
|
2694
|
+
attributes: () => {
|
|
2695
|
+
const t = this.options.direction;
|
|
2696
|
+
return t ? {
|
|
2697
|
+
dir: t
|
|
2698
|
+
} : {};
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
})
|
|
2702
|
+
];
|
|
2703
|
+
}
|
|
2704
|
+
}), Hr = class q {
|
|
2705
|
+
constructor(e, n, r = !1, o = null) {
|
|
2706
|
+
this.currentNode = null, this.actualDepth = null, this.isBlock = r, this.resolvedPos = e, this.editor = n, this.currentNode = o;
|
|
2707
|
+
}
|
|
2708
|
+
get name() {
|
|
2709
|
+
return this.node.type.name;
|
|
2710
|
+
}
|
|
2711
|
+
get node() {
|
|
2712
|
+
return this.currentNode || this.resolvedPos.node();
|
|
2713
|
+
}
|
|
2714
|
+
get element() {
|
|
2715
|
+
return this.editor.view.domAtPos(this.pos).node;
|
|
2716
|
+
}
|
|
2717
|
+
get depth() {
|
|
2718
|
+
var e;
|
|
2719
|
+
return (e = this.actualDepth) != null ? e : this.resolvedPos.depth;
|
|
2720
|
+
}
|
|
2721
|
+
get pos() {
|
|
2722
|
+
return this.resolvedPos.pos;
|
|
2723
|
+
}
|
|
2724
|
+
get content() {
|
|
2725
|
+
return this.node.content;
|
|
2726
|
+
}
|
|
2727
|
+
set content(e) {
|
|
2728
|
+
let n = this.from, r = this.to;
|
|
2729
|
+
if (this.isBlock) {
|
|
2730
|
+
if (this.content.size === 0) {
|
|
2731
|
+
console.error(
|
|
2732
|
+
`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`
|
|
2733
|
+
);
|
|
2734
|
+
return;
|
|
2735
|
+
}
|
|
2736
|
+
n = this.from + 1, r = this.to - 1;
|
|
2737
|
+
}
|
|
2738
|
+
this.editor.commands.insertContentAt({ from: n, to: r }, e);
|
|
2739
|
+
}
|
|
2740
|
+
get attributes() {
|
|
2741
|
+
return this.node.attrs;
|
|
2742
|
+
}
|
|
2743
|
+
get textContent() {
|
|
2744
|
+
return this.node.textContent;
|
|
2745
|
+
}
|
|
2746
|
+
get size() {
|
|
2747
|
+
return this.node.nodeSize;
|
|
2748
|
+
}
|
|
2749
|
+
get from() {
|
|
2750
|
+
return this.isBlock ? this.pos : this.resolvedPos.start(this.resolvedPos.depth);
|
|
2751
|
+
}
|
|
2752
|
+
get range() {
|
|
2753
|
+
return {
|
|
2754
|
+
from: this.from,
|
|
2755
|
+
to: this.to
|
|
2756
|
+
};
|
|
2757
|
+
}
|
|
2758
|
+
get to() {
|
|
2759
|
+
return this.isBlock ? this.pos + this.size : this.resolvedPos.end(this.resolvedPos.depth) + (this.node.isText ? 0 : 1);
|
|
2760
|
+
}
|
|
2761
|
+
get parent() {
|
|
2762
|
+
if (this.depth === 0)
|
|
2763
|
+
return null;
|
|
2764
|
+
const e = this.resolvedPos.start(this.resolvedPos.depth - 1), n = this.resolvedPos.doc.resolve(e);
|
|
2765
|
+
return new q(n, this.editor);
|
|
2766
|
+
}
|
|
2767
|
+
get before() {
|
|
2768
|
+
let e = this.resolvedPos.doc.resolve(this.from - (this.isBlock ? 1 : 2));
|
|
2769
|
+
return e.depth !== this.depth && (e = this.resolvedPos.doc.resolve(this.from - 3)), new q(e, this.editor);
|
|
2770
|
+
}
|
|
2771
|
+
get after() {
|
|
2772
|
+
let e = this.resolvedPos.doc.resolve(this.to + (this.isBlock ? 2 : 1));
|
|
2773
|
+
return e.depth !== this.depth && (e = this.resolvedPos.doc.resolve(this.to + 3)), new q(e, this.editor);
|
|
2774
|
+
}
|
|
2775
|
+
get children() {
|
|
2776
|
+
const e = [];
|
|
2777
|
+
return this.node.content.forEach((n, r) => {
|
|
2778
|
+
const o = n.isBlock && !n.isTextblock, s = n.isAtom && !n.isText, i = n.isInline, c = this.pos + r + (s ? 0 : 1);
|
|
2779
|
+
if (c < 0 || c > this.resolvedPos.doc.nodeSize - 2)
|
|
2780
|
+
return;
|
|
2781
|
+
const a = this.resolvedPos.doc.resolve(c);
|
|
2782
|
+
if (!o && !i && a.depth <= this.depth)
|
|
2783
|
+
return;
|
|
2784
|
+
const l = new q(
|
|
2785
|
+
a,
|
|
2786
|
+
this.editor,
|
|
2787
|
+
o,
|
|
2788
|
+
o || i ? n : null
|
|
2789
|
+
);
|
|
2790
|
+
o && (l.actualDepth = this.depth + 1), e.push(l);
|
|
2791
|
+
}), e;
|
|
2792
|
+
}
|
|
2793
|
+
get firstChild() {
|
|
2794
|
+
return this.children[0] || null;
|
|
2795
|
+
}
|
|
2796
|
+
get lastChild() {
|
|
2797
|
+
const e = this.children;
|
|
2798
|
+
return e[e.length - 1] || null;
|
|
2799
|
+
}
|
|
2800
|
+
closest(e, n = {}) {
|
|
2801
|
+
let r = null, o = this.parent;
|
|
2802
|
+
for (; o && !r; ) {
|
|
2803
|
+
if (o.node.type.name === e)
|
|
2804
|
+
if (Object.keys(n).length > 0) {
|
|
2805
|
+
const s = o.node.attrs, i = Object.keys(n);
|
|
2806
|
+
for (let c = 0; c < i.length; c += 1) {
|
|
2807
|
+
const a = i[c];
|
|
2808
|
+
if (s[a] !== n[a])
|
|
2809
|
+
break;
|
|
2810
|
+
}
|
|
2811
|
+
} else
|
|
2812
|
+
r = o;
|
|
2813
|
+
o = o.parent;
|
|
2814
|
+
}
|
|
2815
|
+
return r;
|
|
2816
|
+
}
|
|
2817
|
+
querySelector(e, n = {}) {
|
|
2818
|
+
return this.querySelectorAll(e, n, !0)[0] || null;
|
|
2819
|
+
}
|
|
2820
|
+
querySelectorAll(e, n = {}, r = !1) {
|
|
2821
|
+
let o = [];
|
|
2822
|
+
if (!this.children || this.children.length === 0)
|
|
2823
|
+
return o;
|
|
2824
|
+
const s = Object.keys(n);
|
|
2825
|
+
return this.children.forEach((i) => {
|
|
2826
|
+
r && o.length > 0 || (i.node.type.name === e && s.every(
|
|
2827
|
+
(a) => n[a] === i.node.attrs[a]
|
|
2828
|
+
) && o.push(i), !(r && o.length > 0) && (o = o.concat(i.querySelectorAll(e, n, r))));
|
|
2829
|
+
}), o;
|
|
2830
|
+
}
|
|
2831
|
+
setAttribute(e) {
|
|
2832
|
+
const { tr: n } = this.editor.state;
|
|
2833
|
+
n.setNodeMarkup(this.from, void 0, {
|
|
2834
|
+
...this.node.attrs,
|
|
2835
|
+
...e
|
|
2836
|
+
}), this.editor.view.dispatch(n);
|
|
2837
|
+
}
|
|
2838
|
+
}, Wr = `.ProseMirror {
|
|
2839
|
+
position: relative;
|
|
2840
|
+
}
|
|
2841
|
+
|
|
2842
|
+
.ProseMirror {
|
|
2843
|
+
word-wrap: break-word;
|
|
2844
|
+
white-space: pre-wrap;
|
|
2845
|
+
white-space: break-spaces;
|
|
2846
|
+
-webkit-font-variant-ligatures: none;
|
|
2847
|
+
font-variant-ligatures: none;
|
|
2848
|
+
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
|
|
2849
|
+
}
|
|
2850
|
+
|
|
2851
|
+
.ProseMirror [contenteditable="false"] {
|
|
2852
|
+
white-space: normal;
|
|
2853
|
+
}
|
|
2854
|
+
|
|
2855
|
+
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
|
|
2856
|
+
white-space: pre-wrap;
|
|
2857
|
+
}
|
|
2858
|
+
|
|
2859
|
+
.ProseMirror pre {
|
|
2860
|
+
white-space: pre-wrap;
|
|
2861
|
+
}
|
|
2862
|
+
|
|
2863
|
+
img.ProseMirror-separator {
|
|
2864
|
+
display: inline !important;
|
|
2865
|
+
border: none !important;
|
|
2866
|
+
margin: 0 !important;
|
|
2867
|
+
width: 0 !important;
|
|
2868
|
+
height: 0 !important;
|
|
2869
|
+
}
|
|
2870
|
+
|
|
2871
|
+
.ProseMirror-gapcursor {
|
|
2872
|
+
display: none;
|
|
2873
|
+
pointer-events: none;
|
|
2874
|
+
position: absolute;
|
|
2875
|
+
margin: 0;
|
|
2876
|
+
}
|
|
2877
|
+
|
|
2878
|
+
.ProseMirror-gapcursor:after {
|
|
2879
|
+
content: "";
|
|
2880
|
+
display: block;
|
|
2881
|
+
position: absolute;
|
|
2882
|
+
top: -2px;
|
|
2883
|
+
width: 20px;
|
|
2884
|
+
border-top: 1px solid black;
|
|
2885
|
+
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
|
|
2886
|
+
}
|
|
2887
|
+
|
|
2888
|
+
@keyframes ProseMirror-cursor-blink {
|
|
2889
|
+
to {
|
|
2890
|
+
visibility: hidden;
|
|
2891
|
+
}
|
|
2892
|
+
}
|
|
2893
|
+
|
|
2894
|
+
.ProseMirror-hideselection *::selection {
|
|
2895
|
+
background: transparent;
|
|
2896
|
+
}
|
|
2897
|
+
|
|
2898
|
+
.ProseMirror-hideselection *::-moz-selection {
|
|
2899
|
+
background: transparent;
|
|
2900
|
+
}
|
|
2901
|
+
|
|
2902
|
+
.ProseMirror-hideselection * {
|
|
2903
|
+
caret-color: transparent;
|
|
2904
|
+
}
|
|
2905
|
+
|
|
2906
|
+
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
2907
|
+
display: block;
|
|
2908
|
+
}`;
|
|
2909
|
+
function Ur(t, e, n) {
|
|
2910
|
+
const r = document.querySelector("style[data-tiptap-style]");
|
|
2911
|
+
if (r !== null)
|
|
2912
|
+
return r;
|
|
2913
|
+
const o = document.createElement("style");
|
|
2914
|
+
return e && o.setAttribute("nonce", e), o.setAttribute("data-tiptap-style", ""), o.innerHTML = t, document.getElementsByTagName("head")[0].appendChild(o), o;
|
|
2915
|
+
}
|
|
2916
|
+
var go = class extends Nr {
|
|
2917
|
+
constructor(t = {}) {
|
|
2918
|
+
super(), this.css = null, this.className = "tiptap", this.editorView = null, this.isFocused = !1, this.destroyed = !1, this.isInitialized = !1, this.extensionStorage = {}, this.instanceId = Math.random().toString(36).slice(2, 9), this.options = {
|
|
2919
|
+
element: typeof document < "u" ? document.createElement("div") : null,
|
|
2920
|
+
content: "",
|
|
2921
|
+
injectCSS: !0,
|
|
2922
|
+
injectNonce: void 0,
|
|
2923
|
+
extensions: [],
|
|
2924
|
+
autofocus: !1,
|
|
2925
|
+
editable: !0,
|
|
2926
|
+
textDirection: void 0,
|
|
2927
|
+
editorProps: {},
|
|
2928
|
+
parseOptions: {},
|
|
2929
|
+
coreExtensionOptions: {},
|
|
2930
|
+
enableInputRules: !0,
|
|
2931
|
+
enablePasteRules: !0,
|
|
2932
|
+
enableCoreExtensions: !0,
|
|
2933
|
+
enableContentCheck: !1,
|
|
2934
|
+
emitContentError: !1,
|
|
2935
|
+
onBeforeCreate: () => null,
|
|
2936
|
+
onCreate: () => null,
|
|
2937
|
+
onMount: () => null,
|
|
2938
|
+
onUnmount: () => null,
|
|
2939
|
+
onUpdate: () => null,
|
|
2940
|
+
onSelectionUpdate: () => null,
|
|
2941
|
+
onTransaction: () => null,
|
|
2942
|
+
onFocus: () => null,
|
|
2943
|
+
onBlur: () => null,
|
|
2944
|
+
onDestroy: () => null,
|
|
2945
|
+
onContentError: ({ error: r }) => {
|
|
2946
|
+
throw r;
|
|
2947
|
+
},
|
|
2948
|
+
onPaste: () => null,
|
|
2949
|
+
onDrop: () => null,
|
|
2950
|
+
onDelete: () => null,
|
|
2951
|
+
enableExtensionDispatchTransaction: !0
|
|
2952
|
+
}, this.isCapturingTransaction = !1, this.capturedTransaction = null, this.utils = {
|
|
2953
|
+
getUpdatedPosition: ar,
|
|
2954
|
+
createMappablePosition: cr
|
|
2955
|
+
}, 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);
|
|
2956
|
+
const e = this.createDoc(), n = Ut(e, this.options.autofocus);
|
|
2957
|
+
this.editorState = Ve.create({
|
|
2958
|
+
doc: e,
|
|
2959
|
+
schema: this.schema,
|
|
2960
|
+
selection: n || void 0
|
|
2961
|
+
}), this.options.element && this.mount(this.options.element);
|
|
2962
|
+
}
|
|
2963
|
+
/**
|
|
2964
|
+
* Attach the editor to the DOM, creating a new editor view.
|
|
2965
|
+
*/
|
|
2966
|
+
mount(t) {
|
|
2967
|
+
if (typeof document > "u")
|
|
2968
|
+
throw new Error(
|
|
2969
|
+
"[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment."
|
|
2970
|
+
);
|
|
2971
|
+
this.createView(t), this.emit("mount", { editor: this }), this.css && !document.head.contains(this.css) && document.head.appendChild(this.css), window.setTimeout(() => {
|
|
2972
|
+
this.isDestroyed || (this.options.autofocus !== !1 && this.options.autofocus !== null && this.commands.focus(this.options.autofocus), this.emit("create", { editor: this }), this.isInitialized = !0);
|
|
2973
|
+
}, 0);
|
|
2974
|
+
}
|
|
2975
|
+
/**
|
|
2976
|
+
* Remove the editor from the DOM, but still allow remounting at a different point in time
|
|
2977
|
+
*/
|
|
2978
|
+
unmount() {
|
|
2979
|
+
if (this.editorView) {
|
|
2980
|
+
const t = this.editorView.dom;
|
|
2981
|
+
t?.editor && delete t.editor, this.editorView.destroy();
|
|
2982
|
+
}
|
|
2983
|
+
if (this.editorView = null, this.isInitialized = !1, this.css && !document.querySelectorAll(`.${this.className}`).length)
|
|
2984
|
+
try {
|
|
2985
|
+
typeof this.css.remove == "function" ? this.css.remove() : this.css.parentNode && this.css.parentNode.removeChild(this.css);
|
|
2986
|
+
} catch (t) {
|
|
2987
|
+
console.warn("Failed to remove CSS element:", t);
|
|
2988
|
+
}
|
|
2989
|
+
this.css = null, this.emit("unmount", { editor: this });
|
|
2990
|
+
}
|
|
2991
|
+
/**
|
|
2992
|
+
* Returns the editor storage.
|
|
2993
|
+
*/
|
|
2994
|
+
get storage() {
|
|
2995
|
+
return this.extensionStorage;
|
|
2996
|
+
}
|
|
2997
|
+
/**
|
|
2998
|
+
* An object of all registered commands.
|
|
2999
|
+
*/
|
|
3000
|
+
get commands() {
|
|
3001
|
+
return this.commandManager.commands;
|
|
3002
|
+
}
|
|
3003
|
+
/**
|
|
3004
|
+
* Create a command chain to call multiple commands at once.
|
|
3005
|
+
*/
|
|
3006
|
+
chain() {
|
|
3007
|
+
return this.commandManager.chain();
|
|
3008
|
+
}
|
|
3009
|
+
/**
|
|
3010
|
+
* Check if a command or a command chain can be executed. Without executing it.
|
|
3011
|
+
*/
|
|
3012
|
+
can() {
|
|
3013
|
+
return this.commandManager.can();
|
|
3014
|
+
}
|
|
3015
|
+
/**
|
|
3016
|
+
* Inject CSS styles.
|
|
3017
|
+
*/
|
|
3018
|
+
injectCSS() {
|
|
3019
|
+
this.options.injectCSS && typeof document < "u" && (this.css = Ur(Wr, this.options.injectNonce));
|
|
3020
|
+
}
|
|
3021
|
+
/**
|
|
3022
|
+
* Update editor options.
|
|
3023
|
+
*
|
|
3024
|
+
* @param options A list of options
|
|
3025
|
+
*/
|
|
3026
|
+
setOptions(t = {}) {
|
|
3027
|
+
this.options = {
|
|
3028
|
+
...this.options,
|
|
3029
|
+
...t
|
|
3030
|
+
}, !(!this.editorView || !this.state || this.isDestroyed) && (this.options.editorProps && this.view.setProps(this.options.editorProps), this.view.updateState(this.state));
|
|
3031
|
+
}
|
|
3032
|
+
/**
|
|
3033
|
+
* Update editable state of the editor.
|
|
3034
|
+
*/
|
|
3035
|
+
setEditable(t, e = !0) {
|
|
3036
|
+
this.setOptions({ editable: t }), e && this.emit("update", { editor: this, transaction: this.state.tr, appendedTransactions: [] });
|
|
3037
|
+
}
|
|
3038
|
+
/**
|
|
3039
|
+
* Returns whether the editor is editable.
|
|
3040
|
+
*/
|
|
3041
|
+
get isEditable() {
|
|
3042
|
+
return this.options.editable && this.view && this.view.editable;
|
|
3043
|
+
}
|
|
3044
|
+
/**
|
|
3045
|
+
* Returns the editor view.
|
|
3046
|
+
*/
|
|
3047
|
+
get view() {
|
|
3048
|
+
return this.editorView ? this.editorView : new Proxy(
|
|
3049
|
+
{
|
|
3050
|
+
state: this.editorState,
|
|
3051
|
+
updateState: (t) => {
|
|
3052
|
+
this.editorState = t;
|
|
3053
|
+
},
|
|
3054
|
+
dispatch: (t) => {
|
|
3055
|
+
this.dispatchTransaction(t);
|
|
3056
|
+
},
|
|
3057
|
+
// Stub some commonly accessed properties to prevent errors
|
|
3058
|
+
composing: !1,
|
|
3059
|
+
dragging: null,
|
|
3060
|
+
editable: !0,
|
|
3061
|
+
isDestroyed: !1
|
|
3062
|
+
},
|
|
3063
|
+
{
|
|
3064
|
+
get: (t, e) => {
|
|
3065
|
+
if (this.editorView)
|
|
3066
|
+
return this.editorView[e];
|
|
3067
|
+
if (e === "state")
|
|
3068
|
+
return this.editorState;
|
|
3069
|
+
if (e in t)
|
|
3070
|
+
return Reflect.get(t, e);
|
|
3071
|
+
throw new Error(
|
|
3072
|
+
`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`
|
|
3073
|
+
);
|
|
3074
|
+
}
|
|
3075
|
+
}
|
|
3076
|
+
);
|
|
3077
|
+
}
|
|
3078
|
+
/**
|
|
3079
|
+
* Returns the editor state.
|
|
3080
|
+
*/
|
|
3081
|
+
get state() {
|
|
3082
|
+
return this.editorView && (this.editorState = this.view.state), this.editorState;
|
|
3083
|
+
}
|
|
3084
|
+
/**
|
|
3085
|
+
* Register a ProseMirror plugin.
|
|
3086
|
+
*
|
|
3087
|
+
* @param plugin A ProseMirror plugin
|
|
3088
|
+
* @param handlePlugins Control how to merge the plugin into the existing plugins.
|
|
3089
|
+
* @returns The new editor state
|
|
3090
|
+
*/
|
|
3091
|
+
registerPlugin(t, e) {
|
|
3092
|
+
const n = Qt(e) ? e(t, [...this.state.plugins]) : [...this.state.plugins, t], r = this.state.reconfigure({ plugins: n });
|
|
3093
|
+
return this.view.updateState(r), r;
|
|
3094
|
+
}
|
|
3095
|
+
/**
|
|
3096
|
+
* Unregister a ProseMirror plugin.
|
|
3097
|
+
*
|
|
3098
|
+
* @param nameOrPluginKeyToRemove The plugins name
|
|
3099
|
+
* @returns The new editor state or undefined if the editor is destroyed
|
|
3100
|
+
*/
|
|
3101
|
+
unregisterPlugin(t) {
|
|
3102
|
+
if (this.isDestroyed)
|
|
3103
|
+
return;
|
|
3104
|
+
const e = this.state.plugins;
|
|
3105
|
+
let n = e;
|
|
3106
|
+
if ([].concat(t).forEach((o) => {
|
|
3107
|
+
const s = typeof o == "string" ? `${o}$` : o.key;
|
|
3108
|
+
n = n.filter((i) => !i.key.startsWith(s));
|
|
3109
|
+
}), e.length === n.length)
|
|
3110
|
+
return;
|
|
3111
|
+
const r = this.state.reconfigure({
|
|
3112
|
+
plugins: n
|
|
3113
|
+
});
|
|
3114
|
+
return this.view.updateState(r), r;
|
|
3115
|
+
}
|
|
3116
|
+
/**
|
|
3117
|
+
* Creates an extension manager.
|
|
3118
|
+
*/
|
|
3119
|
+
createExtensionManager() {
|
|
3120
|
+
var t, e, n, r;
|
|
3121
|
+
const s = [...this.options.enableCoreExtensions ? [
|
|
3122
|
+
de,
|
|
3123
|
+
ae.configure({
|
|
3124
|
+
blockSeparator: (e = (t = this.options.coreExtensionOptions) == null ? void 0 : t.clipboardTextSerializer) == null ? void 0 : e.blockSeparator
|
|
3125
|
+
}),
|
|
3126
|
+
ce,
|
|
3127
|
+
pe,
|
|
3128
|
+
me,
|
|
3129
|
+
ge.configure({
|
|
3130
|
+
value: (r = (n = this.options.coreExtensionOptions) == null ? void 0 : n.tabindex) == null ? void 0 : r.value
|
|
3131
|
+
}),
|
|
3132
|
+
ue,
|
|
3133
|
+
he,
|
|
3134
|
+
le,
|
|
3135
|
+
ve.configure({
|
|
3136
|
+
direction: this.options.textDirection
|
|
3137
|
+
})
|
|
3138
|
+
].filter((i) => typeof this.options.enableCoreExtensions == "object" ? this.options.enableCoreExtensions[i.name] !== !1 : !0) : [], ...this.options.extensions].filter((i) => ["extension", "node", "mark"].includes(i?.type));
|
|
3139
|
+
this.extensionManager = new ft(s, this);
|
|
3140
|
+
}
|
|
3141
|
+
/**
|
|
3142
|
+
* Creates an command manager.
|
|
3143
|
+
*/
|
|
3144
|
+
createCommandManager() {
|
|
3145
|
+
this.commandManager = new at({
|
|
3146
|
+
editor: this
|
|
3147
|
+
});
|
|
3148
|
+
}
|
|
3149
|
+
/**
|
|
3150
|
+
* Creates a ProseMirror schema.
|
|
3151
|
+
*/
|
|
3152
|
+
createSchema() {
|
|
3153
|
+
this.schema = this.extensionManager.schema;
|
|
3154
|
+
}
|
|
3155
|
+
/**
|
|
3156
|
+
* Creates the initial document.
|
|
3157
|
+
*/
|
|
3158
|
+
createDoc() {
|
|
3159
|
+
let t;
|
|
3160
|
+
try {
|
|
3161
|
+
t = gt(this.options.content, this.schema, this.options.parseOptions, {
|
|
3162
|
+
errorOnInvalidContent: this.options.enableContentCheck
|
|
3163
|
+
});
|
|
3164
|
+
} catch (e) {
|
|
3165
|
+
if (!(e instanceof Error) || !["[tiptap error]: Invalid JSON content", "[tiptap error]: Invalid HTML content"].includes(
|
|
3166
|
+
e.message
|
|
3167
|
+
))
|
|
3168
|
+
throw e;
|
|
3169
|
+
this.emit("contentError", {
|
|
3170
|
+
editor: this,
|
|
3171
|
+
error: e,
|
|
3172
|
+
disableCollaboration: () => {
|
|
3173
|
+
"collaboration" in this.storage && typeof this.storage.collaboration == "object" && this.storage.collaboration && (this.storage.collaboration.isDisabled = !0), this.options.extensions = this.options.extensions.filter(
|
|
3174
|
+
(n) => n.name !== "collaboration"
|
|
3175
|
+
), this.createExtensionManager();
|
|
3176
|
+
}
|
|
3177
|
+
}), t = gt(this.options.content, this.schema, this.options.parseOptions, {
|
|
3178
|
+
errorOnInvalidContent: !1
|
|
3179
|
+
});
|
|
3180
|
+
}
|
|
3181
|
+
return t;
|
|
3182
|
+
}
|
|
3183
|
+
/**
|
|
3184
|
+
* Creates a ProseMirror view.
|
|
3185
|
+
*/
|
|
3186
|
+
createView(t) {
|
|
3187
|
+
const { editorProps: e, enableExtensionDispatchTransaction: n } = this.options, r = e.dispatchTransaction || this.dispatchTransaction.bind(this), o = n ? this.extensionManager.dispatchTransaction(r) : r, s = e.transformPastedHTML, i = this.extensionManager.transformPastedHTML(s);
|
|
3188
|
+
this.editorView = new Qe(t, {
|
|
3189
|
+
...e,
|
|
3190
|
+
attributes: {
|
|
3191
|
+
// add `role="textbox"` to the editor element
|
|
3192
|
+
role: "textbox",
|
|
3193
|
+
...e?.attributes
|
|
3194
|
+
},
|
|
3195
|
+
dispatchTransaction: o,
|
|
3196
|
+
transformPastedHTML: i,
|
|
3197
|
+
state: this.editorState,
|
|
3198
|
+
markViews: this.extensionManager.markViews,
|
|
3199
|
+
nodeViews: this.extensionManager.nodeViews
|
|
3200
|
+
});
|
|
3201
|
+
const c = this.state.reconfigure({
|
|
3202
|
+
plugins: this.extensionManager.plugins
|
|
3203
|
+
});
|
|
3204
|
+
this.view.updateState(c), this.prependClass(), this.injectCSS();
|
|
3205
|
+
const a = this.view.dom;
|
|
3206
|
+
a.editor = this;
|
|
3207
|
+
}
|
|
3208
|
+
/**
|
|
3209
|
+
* Creates all node and mark views.
|
|
3210
|
+
*/
|
|
3211
|
+
createNodeViews() {
|
|
3212
|
+
this.view.isDestroyed || this.view.setProps({
|
|
3213
|
+
markViews: this.extensionManager.markViews,
|
|
3214
|
+
nodeViews: this.extensionManager.nodeViews
|
|
3215
|
+
});
|
|
3216
|
+
}
|
|
3217
|
+
/**
|
|
3218
|
+
* Prepend class name to element.
|
|
3219
|
+
*/
|
|
3220
|
+
prependClass() {
|
|
3221
|
+
this.view.dom.className = `${this.className} ${this.view.dom.className}`;
|
|
3222
|
+
}
|
|
3223
|
+
captureTransaction(t) {
|
|
3224
|
+
this.isCapturingTransaction = !0, t(), this.isCapturingTransaction = !1;
|
|
3225
|
+
const e = this.capturedTransaction;
|
|
3226
|
+
return this.capturedTransaction = null, e;
|
|
3227
|
+
}
|
|
3228
|
+
/**
|
|
3229
|
+
* The callback over which to send transactions (state updates) produced by the view.
|
|
3230
|
+
*
|
|
3231
|
+
* @param transaction An editor state transaction
|
|
3232
|
+
*/
|
|
3233
|
+
dispatchTransaction(t) {
|
|
3234
|
+
if (this.view.isDestroyed)
|
|
3235
|
+
return;
|
|
3236
|
+
if (this.isCapturingTransaction) {
|
|
3237
|
+
if (!this.capturedTransaction) {
|
|
3238
|
+
this.capturedTransaction = t;
|
|
3239
|
+
return;
|
|
3240
|
+
}
|
|
3241
|
+
t.steps.forEach((l) => {
|
|
3242
|
+
var f;
|
|
3243
|
+
return (f = this.capturedTransaction) == null ? void 0 : f.step(l);
|
|
3244
|
+
});
|
|
3245
|
+
return;
|
|
3246
|
+
}
|
|
3247
|
+
const { state: e, transactions: n } = this.state.applyTransaction(t), r = !this.state.selection.eq(e.selection), o = n.includes(t), s = this.state;
|
|
3248
|
+
if (this.emit("beforeTransaction", {
|
|
3249
|
+
editor: this,
|
|
3250
|
+
transaction: t,
|
|
3251
|
+
nextState: e
|
|
3252
|
+
}), !o)
|
|
3253
|
+
return;
|
|
3254
|
+
this.view.updateState(e), this.emit("transaction", {
|
|
3255
|
+
editor: this,
|
|
3256
|
+
transaction: t,
|
|
3257
|
+
appendedTransactions: n.slice(1)
|
|
3258
|
+
}), r && this.emit("selectionUpdate", {
|
|
3259
|
+
editor: this,
|
|
3260
|
+
transaction: t
|
|
3261
|
+
});
|
|
3262
|
+
const i = n.findLast((l) => l.getMeta("focus") || l.getMeta("blur")), c = i?.getMeta("focus"), a = i?.getMeta("blur");
|
|
3263
|
+
c && this.emit("focus", {
|
|
3264
|
+
editor: this,
|
|
3265
|
+
event: c.event,
|
|
3266
|
+
// oxlint-disable-next-lineno-non-null-assertion
|
|
3267
|
+
transaction: i
|
|
3268
|
+
}), a && this.emit("blur", {
|
|
3269
|
+
editor: this,
|
|
3270
|
+
event: a.event,
|
|
3271
|
+
// oxlint-disable-next-lineno-non-null-assertion
|
|
3272
|
+
transaction: i
|
|
3273
|
+
}), !(t.getMeta("preventUpdate") || !n.some((l) => l.docChanged) || s.doc.eq(e.doc)) && this.emit("update", {
|
|
3274
|
+
editor: this,
|
|
3275
|
+
transaction: t,
|
|
3276
|
+
appendedTransactions: n.slice(1)
|
|
3277
|
+
});
|
|
3278
|
+
}
|
|
3279
|
+
/**
|
|
3280
|
+
* Get attributes of the currently selected node or mark.
|
|
3281
|
+
*/
|
|
3282
|
+
getAttributes(t) {
|
|
3283
|
+
return er(this.state, t);
|
|
3284
|
+
}
|
|
3285
|
+
isActive(t, e) {
|
|
3286
|
+
const n = typeof t == "string" ? t : null, r = typeof t == "string" ? e : t;
|
|
3287
|
+
return ir(this.state, n, r);
|
|
3288
|
+
}
|
|
3289
|
+
/**
|
|
3290
|
+
* Get the document as JSON.
|
|
3291
|
+
*/
|
|
3292
|
+
getJSON() {
|
|
3293
|
+
return this.state.doc.toJSON();
|
|
3294
|
+
}
|
|
3295
|
+
/**
|
|
3296
|
+
* Get the document as HTML.
|
|
3297
|
+
*/
|
|
3298
|
+
getHTML() {
|
|
3299
|
+
return ut(this.state.doc.content, this.schema);
|
|
3300
|
+
}
|
|
3301
|
+
/**
|
|
3302
|
+
* Get the document as text.
|
|
3303
|
+
*/
|
|
3304
|
+
getText(t) {
|
|
3305
|
+
const { blockSeparator: e = `
|
|
3306
|
+
|
|
3307
|
+
`, textSerializers: n = {} } = t || {};
|
|
3308
|
+
return Xn(this.state.doc, {
|
|
3309
|
+
blockSeparator: e,
|
|
3310
|
+
textSerializers: {
|
|
3311
|
+
...te(this.schema),
|
|
3312
|
+
...n
|
|
3313
|
+
}
|
|
3314
|
+
});
|
|
3315
|
+
}
|
|
3316
|
+
/**
|
|
3317
|
+
* Check if there is no content.
|
|
3318
|
+
*/
|
|
3319
|
+
get isEmpty() {
|
|
3320
|
+
return St(this.state.doc);
|
|
3321
|
+
}
|
|
3322
|
+
/**
|
|
3323
|
+
* Destroy the editor.
|
|
3324
|
+
*/
|
|
3325
|
+
destroy() {
|
|
3326
|
+
this.destroyed || (this.destroyed = !0, this.emit("destroy"), this.unmount(), this.removeAllListeners(), this.extensionManager.destroy(), this.extensionManager = null, this.schema = null, this.commandManager = null, this.extensionStorage = {});
|
|
3327
|
+
}
|
|
3328
|
+
/**
|
|
3329
|
+
* Check if the editor is already destroyed.
|
|
3330
|
+
*/
|
|
3331
|
+
get isDestroyed() {
|
|
3332
|
+
var t, e;
|
|
3333
|
+
return (e = (t = this.editorView) == null ? void 0 : t.isDestroyed) != null ? e : !0;
|
|
3334
|
+
}
|
|
3335
|
+
$node(t, e) {
|
|
3336
|
+
var n;
|
|
3337
|
+
return ((n = this.$doc) == null ? void 0 : n.querySelector(t, e)) || null;
|
|
3338
|
+
}
|
|
3339
|
+
$nodes(t, e) {
|
|
3340
|
+
var n;
|
|
3341
|
+
return ((n = this.$doc) == null ? void 0 : n.querySelectorAll(t, e)) || null;
|
|
3342
|
+
}
|
|
3343
|
+
$pos(t) {
|
|
3344
|
+
const e = this.state.doc.resolve(t), n = t > 0 && e.nodeAfter && !e.nodeAfter.isText ? e.nodeAfter : null;
|
|
3345
|
+
return new Hr(e, this, !1, n);
|
|
3346
|
+
}
|
|
3347
|
+
get $doc() {
|
|
3348
|
+
return this.$pos(0);
|
|
3349
|
+
}
|
|
3350
|
+
};
|
|
3351
|
+
function vo(t) {
|
|
3352
|
+
return new dt({
|
|
3353
|
+
find: t.find,
|
|
3354
|
+
handler: ({ state: e, range: n, match: r }) => {
|
|
3355
|
+
const o = M(t.getAttributes, void 0, r);
|
|
3356
|
+
if (o === !1 || o === null)
|
|
3357
|
+
return null;
|
|
3358
|
+
const { tr: s } = e, i = r[r.length - 1], c = r[0];
|
|
3359
|
+
if (i) {
|
|
3360
|
+
const a = c.search(/\S/), l = n.from + c.indexOf(i), f = l + i.length;
|
|
3361
|
+
if (ee(n.from, n.to, e.doc).filter((d) => d.mark.type.excluded.find((m) => m === t.type && m !== d.mark.type)).filter((d) => d.to > l).length)
|
|
3362
|
+
return null;
|
|
3363
|
+
f < n.to && s.delete(f, n.to), l > n.from && s.delete(n.from + a, l);
|
|
3364
|
+
const p = n.from + a + i.length;
|
|
3365
|
+
s.addMark(n.from + a, p, t.type.create(o || {})), s.removeStoredMark(t.type);
|
|
3366
|
+
}
|
|
3367
|
+
},
|
|
3368
|
+
undoable: t.undoable
|
|
3369
|
+
});
|
|
3370
|
+
}
|
|
3371
|
+
function bo(t) {
|
|
3372
|
+
return new dt({
|
|
3373
|
+
find: t.find,
|
|
3374
|
+
handler: ({ state: e, range: n, match: r }) => {
|
|
3375
|
+
const o = M(t.getAttributes, void 0, r) || {}, { tr: s } = e, i = n.from;
|
|
3376
|
+
let c = n.to;
|
|
3377
|
+
const a = t.type.create(o);
|
|
3378
|
+
if (r[1]) {
|
|
3379
|
+
const l = r[0].lastIndexOf(r[1]);
|
|
3380
|
+
let f = i + l;
|
|
3381
|
+
f > c ? f = c : c = f + r[1].length;
|
|
3382
|
+
const u = r[0][r[0].length - 1];
|
|
3383
|
+
s.insertText(u, i + r[0].length - 1), s.replaceWith(f, c, a);
|
|
3384
|
+
} else if (r[0]) {
|
|
3385
|
+
const l = t.type.isInline ? i : i - 1;
|
|
3386
|
+
s.insert(l, t.type.create(o)).delete(
|
|
3387
|
+
s.mapping.map(i),
|
|
3388
|
+
s.mapping.map(c)
|
|
3389
|
+
);
|
|
3390
|
+
}
|
|
3391
|
+
s.scrollIntoView();
|
|
3392
|
+
},
|
|
3393
|
+
undoable: t.undoable
|
|
3394
|
+
});
|
|
3395
|
+
}
|
|
3396
|
+
function yo(t) {
|
|
3397
|
+
return new dt({
|
|
3398
|
+
find: t.find,
|
|
3399
|
+
handler: ({ state: e, range: n, match: r }) => {
|
|
3400
|
+
const o = e.doc.resolve(n.from), s = M(t.getAttributes, void 0, r) || {};
|
|
3401
|
+
if (!o.node(-1).canReplaceWith(o.index(-1), o.indexAfter(-1), t.type))
|
|
3402
|
+
return null;
|
|
3403
|
+
e.tr.delete(n.from, n.to).setBlockType(n.from, n.from, t.type, s);
|
|
3404
|
+
},
|
|
3405
|
+
undoable: t.undoable
|
|
3406
|
+
});
|
|
3407
|
+
}
|
|
3408
|
+
function ko(t) {
|
|
3409
|
+
return new dt({
|
|
3410
|
+
find: t.find,
|
|
3411
|
+
handler: ({ state: e, range: n, match: r, chain: o }) => {
|
|
3412
|
+
const s = M(t.getAttributes, void 0, r) || {}, i = e.tr.delete(n.from, n.to), a = i.doc.resolve(n.from).blockRange(), l = a && ye(a, t.type, s);
|
|
3413
|
+
if (!l)
|
|
3414
|
+
return null;
|
|
3415
|
+
if (i.wrap(a, l), t.keepMarks && t.editor) {
|
|
3416
|
+
const { selection: u, storedMarks: p } = e, { splittableMarks: d } = t.editor.extensionManager, h = p || u.$to.parentOffset && u.$from.marks();
|
|
3417
|
+
if (h) {
|
|
3418
|
+
const m = h.filter((g) => d.includes(g.type.name));
|
|
3419
|
+
i.ensureMarks(m);
|
|
3420
|
+
}
|
|
3421
|
+
}
|
|
3422
|
+
if (t.keepAttributes) {
|
|
3423
|
+
const u = t.type.name === "bulletList" || t.type.name === "orderedList" ? "listItem" : "taskList";
|
|
3424
|
+
o().updateAttributes(u, s).run();
|
|
3425
|
+
}
|
|
3426
|
+
const f = i.doc.resolve(n.from - 1).nodeBefore;
|
|
3427
|
+
f && f.type === t.type && bt(i.doc, n.from - 1) && (!t.joinPredicate || t.joinPredicate(r, f)) && i.join(n.from - 1);
|
|
3428
|
+
},
|
|
3429
|
+
undoable: t.undoable
|
|
3430
|
+
});
|
|
3431
|
+
}
|
|
3432
|
+
function wo(t, e) {
|
|
3433
|
+
const { selection: n } = t, { $from: r } = n;
|
|
3434
|
+
if (n instanceof st) {
|
|
3435
|
+
const s = r.index();
|
|
3436
|
+
return r.parent.canReplaceWith(s, s + 1, e);
|
|
3437
|
+
}
|
|
3438
|
+
let o = r.depth;
|
|
3439
|
+
for (; o >= 0; ) {
|
|
3440
|
+
const s = r.index(o);
|
|
3441
|
+
if (r.node(o).contentMatchAt(s).matchType(e))
|
|
3442
|
+
return !0;
|
|
3443
|
+
o -= 1;
|
|
3444
|
+
}
|
|
3445
|
+
return !1;
|
|
3446
|
+
}
|
|
3447
|
+
var qr = {};
|
|
3448
|
+
yt(qr, {
|
|
3449
|
+
createAtomBlockMarkdownSpec: () => Jr,
|
|
3450
|
+
createBlockMarkdownSpec: () => Kr,
|
|
3451
|
+
createInlineMarkdownSpec: () => Gr,
|
|
3452
|
+
parseAttributes: () => Tt,
|
|
3453
|
+
parseIndentedBlocks: () => Yr,
|
|
3454
|
+
renderNestedMarkdownContent: () => Xr,
|
|
3455
|
+
serializeAttributes: () => At
|
|
3456
|
+
});
|
|
3457
|
+
function Tt(t) {
|
|
3458
|
+
if (!t?.trim())
|
|
3459
|
+
return {};
|
|
3460
|
+
const e = {}, n = [], r = t.replace(/["']([^"']*)["']/g, (l) => (n.push(l), `__QUOTED_${n.length - 1}__`)), o = r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);
|
|
3461
|
+
if (o) {
|
|
3462
|
+
const l = o.map((f) => f.trim().slice(1));
|
|
3463
|
+
e.class = l.join(" ");
|
|
3464
|
+
}
|
|
3465
|
+
const s = r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);
|
|
3466
|
+
s && (e.id = s[1]);
|
|
3467
|
+
const i = /([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;
|
|
3468
|
+
Array.from(r.matchAll(i)).forEach(([, l, f]) => {
|
|
3469
|
+
var u;
|
|
3470
|
+
const p = parseInt(((u = f.match(/__QUOTED_(\d+)__/)) == null ? void 0 : u[1]) || "0", 10), d = n[p];
|
|
3471
|
+
d && (e[l] = d.slice(1, -1));
|
|
3472
|
+
});
|
|
3473
|
+
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();
|
|
3474
|
+
return a && a.split(/\s+/).filter(Boolean).forEach((f) => {
|
|
3475
|
+
f.match(/^[a-zA-Z][\w-]*$/) && (e[f] = !0);
|
|
3476
|
+
}), e;
|
|
3477
|
+
}
|
|
3478
|
+
function At(t) {
|
|
3479
|
+
if (!t || Object.keys(t).length === 0)
|
|
3480
|
+
return "";
|
|
3481
|
+
const e = [];
|
|
3482
|
+
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]) => {
|
|
3483
|
+
n === "class" || n === "id" || (r === !0 ? e.push(n) : r !== !1 && r != null && e.push(`${n}="${String(r)}"`));
|
|
3484
|
+
}), e.join(" ");
|
|
3485
|
+
}
|
|
3486
|
+
function Jr(t) {
|
|
3487
|
+
const {
|
|
3488
|
+
nodeName: e,
|
|
3489
|
+
name: n,
|
|
3490
|
+
parseAttributes: r = Tt,
|
|
3491
|
+
serializeAttributes: o = At,
|
|
3492
|
+
defaultAttributes: s = {},
|
|
3493
|
+
requiredAttributes: i = [],
|
|
3494
|
+
allowedAttributes: c
|
|
3495
|
+
} = t, a = n || e, l = (f) => {
|
|
3496
|
+
if (!c)
|
|
3497
|
+
return f;
|
|
3498
|
+
const u = {};
|
|
3499
|
+
return c.forEach((p) => {
|
|
3500
|
+
p in f && (u[p] = f[p]);
|
|
3501
|
+
}), u;
|
|
3502
|
+
};
|
|
3503
|
+
return {
|
|
3504
|
+
parseMarkdown: (f, u) => {
|
|
3505
|
+
const p = { ...s, ...f.attributes };
|
|
3506
|
+
return u.createNode(e, p, []);
|
|
3507
|
+
},
|
|
3508
|
+
markdownTokenizer: {
|
|
3509
|
+
name: e,
|
|
3510
|
+
level: "block",
|
|
3511
|
+
start(f) {
|
|
3512
|
+
var u;
|
|
3513
|
+
const p = new RegExp(`^:::${a}(?:\\s|$)`, "m"), d = (u = f.match(p)) == null ? void 0 : u.index;
|
|
3514
|
+
return d !== void 0 ? d : -1;
|
|
3515
|
+
},
|
|
3516
|
+
tokenize(f, u, p) {
|
|
3517
|
+
const d = new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`), h = f.match(d);
|
|
3518
|
+
if (!h)
|
|
3519
|
+
return;
|
|
3520
|
+
const m = h[1] || "", g = r(m);
|
|
3521
|
+
if (!i.find((y) => !(y in g)))
|
|
3522
|
+
return {
|
|
3523
|
+
type: e,
|
|
3524
|
+
raw: h[0],
|
|
3525
|
+
attributes: g
|
|
3526
|
+
};
|
|
3527
|
+
}
|
|
3528
|
+
},
|
|
3529
|
+
renderMarkdown: (f) => {
|
|
3530
|
+
const u = l(f.attrs || {}), p = o(u), d = p ? ` {${p}}` : "";
|
|
3531
|
+
return `:::${a}${d} :::`;
|
|
3532
|
+
}
|
|
3533
|
+
};
|
|
3534
|
+
}
|
|
3535
|
+
function Kr(t) {
|
|
3536
|
+
const {
|
|
3537
|
+
nodeName: e,
|
|
3538
|
+
name: n,
|
|
3539
|
+
getContent: r,
|
|
3540
|
+
parseAttributes: o = Tt,
|
|
3541
|
+
serializeAttributes: s = At,
|
|
3542
|
+
defaultAttributes: i = {},
|
|
3543
|
+
content: c = "block",
|
|
3544
|
+
allowedAttributes: a
|
|
3545
|
+
} = t, l = n || e, f = (u) => {
|
|
3546
|
+
if (!a)
|
|
3547
|
+
return u;
|
|
3548
|
+
const p = {};
|
|
3549
|
+
return a.forEach((d) => {
|
|
3550
|
+
d in u && (p[d] = u[d]);
|
|
3551
|
+
}), p;
|
|
3552
|
+
};
|
|
3553
|
+
return {
|
|
3554
|
+
parseMarkdown: (u, p) => {
|
|
3555
|
+
let d;
|
|
3556
|
+
if (r) {
|
|
3557
|
+
const m = r(u);
|
|
3558
|
+
d = typeof m == "string" ? [{ type: "text", text: m }] : m;
|
|
3559
|
+
} else c === "block" ? d = p.parseChildren(u.tokens || []) : d = p.parseInline(u.tokens || []);
|
|
3560
|
+
const h = { ...i, ...u.attributes };
|
|
3561
|
+
return p.createNode(e, h, d);
|
|
3562
|
+
},
|
|
3563
|
+
markdownTokenizer: {
|
|
3564
|
+
name: e,
|
|
3565
|
+
level: "block",
|
|
3566
|
+
start(u) {
|
|
3567
|
+
var p;
|
|
3568
|
+
const d = new RegExp(`^:::${l}`, "m"), h = (p = u.match(d)) == null ? void 0 : p.index;
|
|
3569
|
+
return h !== void 0 ? h : -1;
|
|
3570
|
+
},
|
|
3571
|
+
tokenize(u, p, d) {
|
|
3572
|
+
var h;
|
|
3573
|
+
const m = new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*\\n`), g = u.match(m);
|
|
3574
|
+
if (!g)
|
|
3575
|
+
return;
|
|
3576
|
+
const [v, y = ""] = g, w = o(y);
|
|
3577
|
+
let x = 1;
|
|
3578
|
+
const k = v.length;
|
|
3579
|
+
let S = "";
|
|
3580
|
+
const E = /^:::([\w-]*)(\s.*)?/gm, A = u.slice(k);
|
|
3581
|
+
for (E.lastIndex = 0; ; ) {
|
|
3582
|
+
const C = E.exec(A);
|
|
3583
|
+
if (C === null)
|
|
3584
|
+
break;
|
|
3585
|
+
const $ = C.index, H = C[1];
|
|
3586
|
+
if (!((h = C[2]) != null && h.endsWith(":::"))) {
|
|
3587
|
+
if (H)
|
|
3588
|
+
x += 1;
|
|
3589
|
+
else if (x -= 1, x === 0) {
|
|
3590
|
+
const L = A.slice(0, $);
|
|
3591
|
+
S = L.trim();
|
|
3592
|
+
const I = u.slice(0, k + $ + C[0].length);
|
|
3593
|
+
let N = [];
|
|
3594
|
+
if (S)
|
|
3595
|
+
if (c === "block")
|
|
3596
|
+
for (N = d.blockTokens(L), N.forEach((P) => {
|
|
3597
|
+
P.text && (!P.tokens || P.tokens.length === 0) && (P.tokens = d.inlineTokens(P.text));
|
|
3598
|
+
}); N.length > 0; ) {
|
|
3599
|
+
const P = N[N.length - 1];
|
|
3600
|
+
if (P.type === "paragraph" && (!P.text || P.text.trim() === ""))
|
|
3601
|
+
N.pop();
|
|
3602
|
+
else
|
|
3603
|
+
break;
|
|
3604
|
+
}
|
|
3605
|
+
else
|
|
3606
|
+
N = d.inlineTokens(S);
|
|
3607
|
+
return {
|
|
3608
|
+
type: e,
|
|
3609
|
+
raw: I,
|
|
3610
|
+
attributes: w,
|
|
3611
|
+
content: S,
|
|
3612
|
+
tokens: N
|
|
3613
|
+
};
|
|
3614
|
+
}
|
|
3615
|
+
}
|
|
3616
|
+
}
|
|
3617
|
+
}
|
|
3618
|
+
},
|
|
3619
|
+
renderMarkdown: (u, p) => {
|
|
3620
|
+
const d = f(u.attrs || {}), h = s(d), m = h ? ` {${h}}` : "", g = p.renderChildren(u.content || [], `
|
|
3621
|
+
|
|
3622
|
+
`);
|
|
3623
|
+
return `:::${l}${m}
|
|
3624
|
+
|
|
3625
|
+
${g}
|
|
3626
|
+
|
|
3627
|
+
:::`;
|
|
3628
|
+
}
|
|
3629
|
+
};
|
|
3630
|
+
}
|
|
3631
|
+
function Qr(t) {
|
|
3632
|
+
if (!t.trim())
|
|
3633
|
+
return {};
|
|
3634
|
+
const e = {}, n = /(\w+)=(?:"([^"]*)"|'([^']*)')/g;
|
|
3635
|
+
let r = n.exec(t);
|
|
3636
|
+
for (; r !== null; ) {
|
|
3637
|
+
const [, o, s, i] = r;
|
|
3638
|
+
e[o] = s || i, r = n.exec(t);
|
|
3639
|
+
}
|
|
3640
|
+
return e;
|
|
3641
|
+
}
|
|
3642
|
+
function Zr(t) {
|
|
3643
|
+
return Object.entries(t).filter(([, e]) => e != null).map(([e, n]) => `${e}="${n}"`).join(" ");
|
|
3644
|
+
}
|
|
3645
|
+
function Gr(t) {
|
|
3646
|
+
const {
|
|
3647
|
+
nodeName: e,
|
|
3648
|
+
name: n,
|
|
3649
|
+
getContent: r,
|
|
3650
|
+
parseAttributes: o = Qr,
|
|
3651
|
+
serializeAttributes: s = Zr,
|
|
3652
|
+
defaultAttributes: i = {},
|
|
3653
|
+
selfClosing: c = !1,
|
|
3654
|
+
allowedAttributes: a
|
|
3655
|
+
} = t, l = n || e, f = (p) => {
|
|
3656
|
+
if (!a)
|
|
3657
|
+
return p;
|
|
3658
|
+
const d = {};
|
|
3659
|
+
return a.forEach((h) => {
|
|
3660
|
+
const m = typeof h == "string" ? h : h.name, g = typeof h == "string" ? void 0 : h.skipIfDefault;
|
|
3661
|
+
if (m in p) {
|
|
3662
|
+
const v = p[m];
|
|
3663
|
+
if (g !== void 0 && v === g)
|
|
3664
|
+
return;
|
|
3665
|
+
d[m] = v;
|
|
3666
|
+
}
|
|
3667
|
+
}), d;
|
|
3668
|
+
}, u = l.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3669
|
+
return {
|
|
3670
|
+
parseMarkdown: (p, d) => {
|
|
3671
|
+
const h = { ...i, ...p.attributes };
|
|
3672
|
+
if (c)
|
|
3673
|
+
return d.createNode(e, h);
|
|
3674
|
+
const m = r ? r(p) : p.content || "";
|
|
3675
|
+
return m ? d.createNode(e, h, [d.createTextNode(m)]) : d.createNode(e, h, []);
|
|
3676
|
+
},
|
|
3677
|
+
markdownTokenizer: {
|
|
3678
|
+
name: e,
|
|
3679
|
+
level: "inline",
|
|
3680
|
+
start(p) {
|
|
3681
|
+
const d = c ? new RegExp(`\\[${u}\\s*[^\\]]*\\]`) : new RegExp(`\\[${u}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${u}\\]`), h = p.match(d), m = h?.index;
|
|
3682
|
+
return m !== void 0 ? m : -1;
|
|
3683
|
+
},
|
|
3684
|
+
tokenize(p, d, h) {
|
|
3685
|
+
const m = c ? new RegExp(`^\\[${u}\\s*([^\\]]*)\\]`) : new RegExp(
|
|
3686
|
+
`^\\[${u}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${u}\\]`
|
|
3687
|
+
), g = p.match(m);
|
|
3688
|
+
if (!g)
|
|
3689
|
+
return;
|
|
3690
|
+
let v = "", y = "";
|
|
3691
|
+
if (c) {
|
|
3692
|
+
const [, x] = g;
|
|
3693
|
+
y = x;
|
|
3694
|
+
} else {
|
|
3695
|
+
const [, x, k] = g;
|
|
3696
|
+
y = x, v = k || "";
|
|
3697
|
+
}
|
|
3698
|
+
const w = o(y.trim());
|
|
3699
|
+
return {
|
|
3700
|
+
type: e,
|
|
3701
|
+
raw: g[0],
|
|
3702
|
+
content: v.trim(),
|
|
3703
|
+
attributes: w
|
|
3704
|
+
};
|
|
3705
|
+
}
|
|
3706
|
+
},
|
|
3707
|
+
renderMarkdown: (p) => {
|
|
3708
|
+
let d = "";
|
|
3709
|
+
r ? d = r(p) : p.content && p.content.length > 0 && (d = p.content.filter((v) => v.type === "text").map((v) => v.text).join(""));
|
|
3710
|
+
const h = f(p.attrs || {}), m = s(h), g = m ? ` ${m}` : "";
|
|
3711
|
+
return c ? `[${l}${g}]` : `[${l}${g}]${d}[/${l}]`;
|
|
3712
|
+
}
|
|
3713
|
+
};
|
|
3714
|
+
}
|
|
3715
|
+
function Yr(t, e, n) {
|
|
3716
|
+
var r, o, s, i;
|
|
3717
|
+
const c = t.split(`
|
|
3718
|
+
`), a = [];
|
|
3719
|
+
let l = "", f = 0;
|
|
3720
|
+
const u = e.baseIndentSize || 2;
|
|
3721
|
+
for (; f < c.length; ) {
|
|
3722
|
+
const p = c[f], d = p.match(e.itemPattern);
|
|
3723
|
+
if (!d) {
|
|
3724
|
+
if (a.length > 0)
|
|
3725
|
+
break;
|
|
3726
|
+
if (p.trim() === "") {
|
|
3727
|
+
f += 1, l = `${l}${p}
|
|
3728
|
+
`;
|
|
3729
|
+
continue;
|
|
3730
|
+
} else
|
|
3731
|
+
return;
|
|
3732
|
+
}
|
|
3733
|
+
const h = e.extractItemData(d), { indentLevel: m, mainContent: g } = h;
|
|
3734
|
+
l = `${l}${p}
|
|
3735
|
+
`;
|
|
3736
|
+
const v = [g];
|
|
3737
|
+
for (f += 1; f < c.length; ) {
|
|
3738
|
+
const k = c[f];
|
|
3739
|
+
if (k.trim() === "") {
|
|
3740
|
+
const E = c.slice(f + 1).findIndex(($) => $.trim() !== "");
|
|
3741
|
+
if (E === -1)
|
|
3742
|
+
break;
|
|
3743
|
+
if ((((o = (r = c[f + 1 + E].match(/^(\s*)/)) == null ? void 0 : r[1]) == null ? void 0 : o.length) || 0) > m) {
|
|
3744
|
+
v.push(k), l = `${l}${k}
|
|
3745
|
+
`, f += 1;
|
|
3746
|
+
continue;
|
|
3747
|
+
} else
|
|
3748
|
+
break;
|
|
3749
|
+
}
|
|
3750
|
+
if ((((i = (s = k.match(/^(\s*)/)) == null ? void 0 : s[1]) == null ? void 0 : i.length) || 0) > m)
|
|
3751
|
+
v.push(k), l = `${l}${k}
|
|
3752
|
+
`, f += 1;
|
|
3753
|
+
else
|
|
3754
|
+
break;
|
|
3755
|
+
}
|
|
3756
|
+
let y;
|
|
3757
|
+
const w = v.slice(1);
|
|
3758
|
+
if (w.length > 0) {
|
|
3759
|
+
const k = w.map((S) => S.slice(m + u)).join(`
|
|
3760
|
+
`);
|
|
3761
|
+
k.trim() && (e.customNestedParser ? y = e.customNestedParser(k) : y = n.blockTokens(k));
|
|
3762
|
+
}
|
|
3763
|
+
const x = e.createToken(h, y);
|
|
3764
|
+
a.push(x);
|
|
3765
|
+
}
|
|
3766
|
+
if (a.length !== 0)
|
|
3767
|
+
return {
|
|
3768
|
+
items: a,
|
|
3769
|
+
raw: l
|
|
3770
|
+
};
|
|
3771
|
+
}
|
|
3772
|
+
function Xr(t, e, n, r) {
|
|
3773
|
+
if (!t || !Array.isArray(t.content))
|
|
3774
|
+
return "";
|
|
3775
|
+
const o = typeof n == "function" ? n(r) : n, [s, ...i] = t.content, c = e.renderChildren([s]);
|
|
3776
|
+
let a = `${o}${c}`;
|
|
3777
|
+
return i && i.length > 0 && i.forEach((l, f) => {
|
|
3778
|
+
var u, p;
|
|
3779
|
+
const d = (p = (u = e.renderChild) == null ? void 0 : u.call(e, l, f + 1)) != null ? p : e.renderChildren([l]);
|
|
3780
|
+
if (d != null) {
|
|
3781
|
+
const h = d.split(`
|
|
3782
|
+
`).map((m) => m ? e.indent(m) : e.indent("")).join(`
|
|
3783
|
+
`);
|
|
3784
|
+
a += l.type === "paragraph" ? `
|
|
3785
|
+
|
|
3786
|
+
${h}` : `
|
|
3787
|
+
${h}`;
|
|
3788
|
+
}
|
|
3789
|
+
}), a;
|
|
3790
|
+
}
|
|
3791
|
+
function to(t, e, n = {}) {
|
|
3792
|
+
const { state: r } = e, { doc: o, tr: s } = r, i = t;
|
|
3793
|
+
o.descendants((c, a) => {
|
|
3794
|
+
const l = s.mapping.map(a), f = s.mapping.map(a) + c.nodeSize;
|
|
3795
|
+
let u = null;
|
|
3796
|
+
if (c.marks.forEach((d) => {
|
|
3797
|
+
if (d !== i)
|
|
3798
|
+
return !1;
|
|
3799
|
+
u = d;
|
|
3800
|
+
}), !u)
|
|
3801
|
+
return;
|
|
3802
|
+
let p = !1;
|
|
3803
|
+
if (Object.keys(n).forEach((d) => {
|
|
3804
|
+
n[d] !== u.attrs[d] && (p = !0);
|
|
3805
|
+
}), p) {
|
|
3806
|
+
const d = t.type.create({
|
|
3807
|
+
...t.attrs,
|
|
3808
|
+
...n
|
|
3809
|
+
});
|
|
3810
|
+
s.removeMark(l, f, t.type), s.addMark(l, f, d);
|
|
3811
|
+
}
|
|
3812
|
+
}), s.docChanged && e.view.dispatch(s);
|
|
3813
|
+
}
|
|
3814
|
+
var xo = class be extends Et {
|
|
3815
|
+
constructor() {
|
|
3816
|
+
super(...arguments), this.type = "node";
|
|
3817
|
+
}
|
|
3818
|
+
/**
|
|
3819
|
+
* Create a new Node instance
|
|
3820
|
+
* @param config - Node configuration object or a function that returns a configuration object
|
|
3821
|
+
*/
|
|
3822
|
+
static create(e = {}) {
|
|
3823
|
+
const n = typeof e == "function" ? e() : e;
|
|
3824
|
+
return new be(n);
|
|
3825
|
+
}
|
|
3826
|
+
configure(e) {
|
|
3827
|
+
return super.configure(e);
|
|
3828
|
+
}
|
|
3829
|
+
extend(e) {
|
|
3830
|
+
const n = typeof e == "function" ? e() : e;
|
|
3831
|
+
return super.extend(n);
|
|
3832
|
+
}
|
|
3833
|
+
};
|
|
3834
|
+
function Mo(t) {
|
|
3835
|
+
return new jr({
|
|
3836
|
+
find: t.find,
|
|
3837
|
+
handler: ({ state: e, range: n, match: r, pasteEvent: o }) => {
|
|
3838
|
+
const s = M(t.getAttributes, void 0, r, o);
|
|
3839
|
+
if (s === !1 || s === null)
|
|
3840
|
+
return null;
|
|
3841
|
+
const { tr: i } = e, c = r[r.length - 1], a = r[0];
|
|
3842
|
+
let l = n.to;
|
|
3843
|
+
if (c) {
|
|
3844
|
+
const f = a.search(/\S/), u = n.from + a.indexOf(c), p = u + c.length;
|
|
3845
|
+
if (ee(n.from, n.to, e.doc).filter((m) => m.mark.type.excluded.find((v) => v === t.type && v !== m.mark.type)).filter((m) => m.to > u).length)
|
|
3846
|
+
return null;
|
|
3847
|
+
p < n.to && i.delete(p, n.to), u > n.from && i.delete(n.from + f, u), l = n.from + f + c.length, i.addMark(n.from + f, l, t.type.create(s || {})), r.index !== void 0 && r.input !== void 0 && r.index + r[0].length >= r.input.length || i.removeStoredMark(t.type);
|
|
3848
|
+
}
|
|
3849
|
+
}
|
|
3850
|
+
});
|
|
3851
|
+
}
|
|
3852
|
+
export {
|
|
3853
|
+
at as CommandManager,
|
|
3854
|
+
go as Editor,
|
|
3855
|
+
Et as Extendable,
|
|
3856
|
+
B as Extension,
|
|
3857
|
+
dt as InputRule,
|
|
3858
|
+
ne as MappablePosition,
|
|
3859
|
+
Br as Mark,
|
|
3860
|
+
xo as Node,
|
|
3861
|
+
Hr as NodePos,
|
|
3862
|
+
jr as PasteRule,
|
|
3863
|
+
M as callOrReturn,
|
|
3864
|
+
wo as canInsertNode,
|
|
3865
|
+
Un as combineTransactionSteps,
|
|
3866
|
+
Vt as commands,
|
|
3867
|
+
Jr as createAtomBlockMarkdownSpec,
|
|
3868
|
+
Kr as createBlockMarkdownSpec,
|
|
3869
|
+
it as createChainableState,
|
|
3870
|
+
gt as createDocument,
|
|
3871
|
+
Gr as createInlineMarkdownSpec,
|
|
3872
|
+
cr as createMappablePosition,
|
|
3873
|
+
K as createNodeFromContent,
|
|
3874
|
+
Ur as createStyleTag,
|
|
3875
|
+
qn as defaultBlockAt,
|
|
3876
|
+
It as deleteProps,
|
|
3877
|
+
U as elementFromString,
|
|
3878
|
+
Vr as extensions,
|
|
3879
|
+
co as findChildrenInRange,
|
|
3880
|
+
Yn as findDuplicates,
|
|
3881
|
+
lt as findParentNode,
|
|
3882
|
+
Jn as findParentNodeClosestToPos,
|
|
3883
|
+
xt as flattenExtensions,
|
|
3884
|
+
Gn as fromString,
|
|
3885
|
+
lo as generateHTML,
|
|
3886
|
+
uo as generateJSON,
|
|
3887
|
+
er as getAttributes,
|
|
3888
|
+
Zt as getAttributesFromExtensions,
|
|
3889
|
+
or as getChangedRanges,
|
|
3890
|
+
b as getExtensionField,
|
|
3891
|
+
ut as getHTMLFromFragment,
|
|
3892
|
+
Kt as getMarkAttributes,
|
|
3893
|
+
wt as getMarkRange,
|
|
3894
|
+
D as getMarkType,
|
|
3895
|
+
ee as getMarksBetween,
|
|
3896
|
+
fo as getNodeAtPosition,
|
|
3897
|
+
tr as getNodeAttributes,
|
|
3898
|
+
T as getNodeType,
|
|
3899
|
+
ot as getRenderedAttributes,
|
|
3900
|
+
Yt as getSchema,
|
|
3901
|
+
Gt as getSchemaByResolvedExtensions,
|
|
3902
|
+
W as getSchemaTypeByName,
|
|
3903
|
+
ct as getSchemaTypeNameByName,
|
|
3904
|
+
et as getSplittedAttributes,
|
|
3905
|
+
Xn as getText,
|
|
3906
|
+
Xt as getTextBetween,
|
|
3907
|
+
sr as getTextContentFromNodes,
|
|
3908
|
+
te as getTextSerializersFromSchema,
|
|
3909
|
+
ar as getUpdatedPosition,
|
|
3910
|
+
Rt as injectExtensionAttributesToParseRule,
|
|
3911
|
+
Or as inputRulesPlugin,
|
|
3912
|
+
ir as isActive,
|
|
3913
|
+
Nt as isAndroid,
|
|
3914
|
+
po as isAtEndOfNode,
|
|
3915
|
+
mo as isAtStartOfNode,
|
|
3916
|
+
Kn as isEmptyObject,
|
|
3917
|
+
jt as isExtensionRulesEnabled,
|
|
3918
|
+
Qt as isFunction,
|
|
3919
|
+
pt as isList,
|
|
3920
|
+
Jt as isMacOS,
|
|
3921
|
+
vt as isMarkActive,
|
|
3922
|
+
Q as isNodeActive,
|
|
3923
|
+
St as isNodeEmpty,
|
|
3924
|
+
ho as isNodeSelection,
|
|
3925
|
+
Dr as isNumber,
|
|
3926
|
+
G as isPlainObject,
|
|
3927
|
+
kt as isRegExp,
|
|
3928
|
+
hn as isSafari,
|
|
3929
|
+
Wt as isTextSelection,
|
|
3930
|
+
rt as isiOS,
|
|
3931
|
+
vo as markInputRule,
|
|
3932
|
+
Mo as markPasteRule,
|
|
3933
|
+
qr as markdown,
|
|
3934
|
+
Zn as mergeAttributes,
|
|
3935
|
+
oe as mergeDeep,
|
|
3936
|
+
z as minMax,
|
|
3937
|
+
bo as nodeInputRule,
|
|
3938
|
+
nt as objectIncludes,
|
|
3939
|
+
Tt as parseAttributes,
|
|
3940
|
+
Yr as parseIndentedBlocks,
|
|
3941
|
+
Fr as pasteRulesPlugin,
|
|
3942
|
+
nr as removeDuplicates,
|
|
3943
|
+
Xr as renderNestedMarkdownContent,
|
|
3944
|
+
Mt as resolveExtensions,
|
|
3945
|
+
Ut as resolveFocusPosition,
|
|
3946
|
+
yn as selectionToInsertionEnd,
|
|
3947
|
+
At as serializeAttributes,
|
|
3948
|
+
J as sortExtensions,
|
|
3949
|
+
V as splitExtensions,
|
|
3950
|
+
yo as textblockTypeInputRule,
|
|
3951
|
+
to as updateMarkViewAttributes,
|
|
3952
|
+
ko as wrappingInputRule
|
|
3953
|
+
};
|