@blocknote/core 0.54.0 → 0.54.2
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/blocknote.cjs +1 -1
- package/dist/blocknote.js +6 -6
- package/dist/{blocks-CzkqclGj.cjs → blocks-CTB_5Vyj.cjs} +4 -4
- package/dist/blocks-CTB_5Vyj.cjs.map +1 -0
- package/dist/{blocks-CzQLehlc.js → blocks-Dol85hpH.js} +337 -330
- package/dist/blocks-Dol85hpH.js.map +1 -0
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +2 -2
- package/dist/extensions-B7Rsp_Ft.cjs +58 -0
- package/dist/extensions-B7Rsp_Ft.cjs.map +1 -0
- package/dist/{extensions-DGuhtOgB.js → extensions-D6JcJCwd.js} +389 -346
- package/dist/extensions-D6JcJCwd.js.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +3 -3
- package/dist/{src-BkfZVfaO.js → src-Buuo5l7X.js} +521 -516
- package/dist/{src-BkfZVfaO.js.map → src-Buuo5l7X.js.map} +1 -1
- package/dist/{src-DM3syMdf.cjs → src-C54Ok9E0.cjs} +10 -10
- package/dist/{src-DM3syMdf.cjs.map → src-C54Ok9E0.cjs.map} +1 -1
- package/dist/webpack-stats.json +1 -1
- package/dist/y.cjs +1 -1
- package/dist/y.cjs.map +1 -1
- package/dist/y.js +205 -205
- package/dist/y.js.map +1 -1
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.js +21 -21
- package/package.json +1 -1
- package/src/api/getBlocksChangedByTransaction.test.ts +211 -0
- package/src/api/getBlocksChangedByTransaction.ts +48 -12
- package/src/api/getChangedRange.ts +54 -0
- package/src/blocks/index.ts +0 -1
- package/src/editor/performance.test.ts +45 -0
- package/src/exporter/Exporter.test.ts +148 -10
- package/src/exporter/Exporter.ts +20 -2
- package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +21 -0
- package/src/extensions/PreviousBlockType/PreviousBlockType.ts +5 -3
- package/src/extensions/TableHandles/TableHandles.browser.test.ts +305 -0
- package/src/extensions/TableHandles/TableHandles.ts +82 -41
- package/src/fonts/inter.css +9 -9
- package/src/schema/blocks/createSpec.ts +4 -5
- package/src/schema/inlineContent/createSpec.ts +4 -5
- package/src/schema/nodeViewMutations.test.ts +81 -56
- package/src/schema/nodeViewMutations.ts +30 -27
- package/src/schema/schema.test.ts +110 -0
- package/src/schema/schema.ts +13 -4
- package/src/y/extensions/AttributionExtension.test.ts +8 -9
- package/src/y/versioning/__test__/yhub.test.ts +92 -59
- package/src/y/versioning/yhub.ts +35 -29
- package/types/src/api/getChangedRange.d.ts +14 -0
- package/types/src/blocks/index.d.ts +0 -1
- package/types/src/exporter/Exporter.d.ts +9 -0
- package/types/src/extensions/TableHandles/TableHandles.browser.test.d.ts +1 -0
- package/types/src/extensions/TableHandles/TableHandles.d.ts +3 -0
- package/types/src/schema/nodeViewMutations.d.ts +2 -2
- package/types/src/schema/schema.test.d.ts +1 -0
- package/types/src/y/versioning/yhub.d.ts +3 -2
- package/dist/blocks-CzQLehlc.js.map +0 -1
- package/dist/blocks-CzkqclGj.cjs.map +0 -1
- package/dist/extensions-CSB9ZvuL.cjs +0 -58
- package/dist/extensions-CSB9ZvuL.cjs.map +0 -1
- package/dist/extensions-DGuhtOgB.js.map +0 -1
- package/src/blocks/File/helpers/uploadToTmpFilesDotOrg_DEV_ONLY.ts +0 -20
- package/types/src/blocks/File/helpers/uploadToTmpFilesDotOrg_DEV_ONLY.d.ts +0 -6
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { $n as e,
|
|
1
|
+
import { $n as e, At as t, Cn as n, Ct as r, En as i, Ft as a, Hn as o, It as s, Lt as c, Mt as l, Nt as u, O as d, On as f, Pn as p, Qn as m, Sn as h, Tn as g, Tt as _, Vn as ee, W as te, Yt as ne, an as re, ar as v, bn as ie, bt as y, er as ae, f as oe, gn as se, in as ce, ir as le, jn as b, jt as ue, m as x, nr as S, rn as C, t as de, tr as w, wn as T, xn as fe } from "./blocks-Dol85hpH.js";
|
|
2
2
|
import { o as pe, r as me, t as he } from "./BlockNoteExtension-CbvDA0F7.js";
|
|
3
|
-
import { A as ge, C as _e, F as ve, M as ye, N as be, O as xe, P as Se, S as Ce, T as we, b as Te, c as Ee, g as De, h as Oe, k as ke, m as Ae, s as je, w as Me, x as Ne, y as Pe } from "./extensions-
|
|
3
|
+
import { A as ge, C as _e, F as ve, M as ye, N as be, O as xe, P as Se, S as Ce, T as we, b as Te, c as Ee, g as De, h as Oe, k as ke, m as Ae, s as je, w as Me, x as Ne, y as Pe } from "./extensions-D6JcJCwd.js";
|
|
4
4
|
import { r as Fe } from "./UserStore-C4TzkGEn.js";
|
|
5
5
|
import { t as Ie } from "./en-uzHzj6eH.js";
|
|
6
6
|
import { DOMParser as Le, DOMSerializer as Re, Fragment as E, NodeRange as ze, Slice as D } from "prosemirror-model";
|
|
7
7
|
import { ReplaceAroundStep as O, ReplaceStep as Be, canJoin as Ve, liftTarget as He } from "prosemirror-transform";
|
|
8
|
-
import { Editor as Ue, Extension as k, Mark as We, Node as A, combineTransactionSteps as Ge, createDocument as Ke, extensions as j, findChildrenInRange as qe, findParentNodeClosestToPos as Je, getAttributes as Ye, getChangedRanges as Xe, getMarkRange as Ze, getMarksBetween as Qe, getSchema as $e, isNodeSelection as et, markPasteRule as tt, mergeAttributes as
|
|
9
|
-
import { NodeSelection as
|
|
10
|
-
import { DOMParser as
|
|
11
|
-
import { CellSelection as
|
|
12
|
-
import { Plugin as
|
|
13
|
-
import { digestString as
|
|
14
|
-
import { InputRule as
|
|
15
|
-
import { keymap as
|
|
16
|
-
import { Text as
|
|
17
|
-
import { Gapcursor as
|
|
8
|
+
import { Editor as Ue, Extension as k, Mark as We, Node as A, combineTransactionSteps as Ge, createDocument as Ke, extensions as j, findChildrenInRange as qe, findParentNodeClosestToPos as Je, getAttributes as Ye, getChangedRanges as Xe, getMarkRange as Ze, getMarksBetween as Qe, getSchema as $e, isNodeSelection as et, markPasteRule as tt, mergeAttributes as nt, posToDOMRect as rt, selectionToInsertionEnd as it } from "@tiptap/core";
|
|
9
|
+
import { NodeSelection as M, Plugin as N, TextSelection as P } from "prosemirror-state";
|
|
10
|
+
import { DOMParser as at, Fragment as F, Slice as I } from "@tiptap/pm/model";
|
|
11
|
+
import { CellSelection as ot, TableMap as st } from "prosemirror-tables";
|
|
12
|
+
import { Plugin as L, PluginKey as R } from "@tiptap/pm/state";
|
|
13
|
+
import { digestString as ct } from "lib0/hash/fnv1a";
|
|
14
|
+
import { InputRule as lt, inputRules as ut } from "@handlewithcare/prosemirror-inputrules";
|
|
15
|
+
import { keymap as dt } from "@tiptap/pm/keymap";
|
|
16
|
+
import { Text as ft } from "@tiptap/extension-text";
|
|
17
|
+
import { Gapcursor as pt } from "@tiptap/extensions/gap-cursor";
|
|
18
18
|
//#region src/schema/blocks/types.ts
|
|
19
|
-
function
|
|
19
|
+
function mt(e) {
|
|
20
20
|
return typeof e == "string" ? e : e.map((e) => typeof e == "string" ? e : e.text).join("");
|
|
21
21
|
}
|
|
22
22
|
//#endregion
|
|
23
23
|
//#region src/schema/inlineContent/createSpec.ts
|
|
24
|
-
function
|
|
24
|
+
function ht(e) {
|
|
25
25
|
return e.matches("[data-editable]") ? e : e.querySelector("[data-editable]") || e;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
return
|
|
27
|
+
function gt(e, t) {
|
|
28
|
+
return at.fromSchema(t).parse(e, {
|
|
29
29
|
topNode: t.nodes.paragraph.create(),
|
|
30
30
|
preserveWhitespace: !0
|
|
31
31
|
}).content;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function _t(e, t) {
|
|
34
34
|
let n = [];
|
|
35
35
|
return e.forEach((e) => {
|
|
36
36
|
if (e.isText) n.push(e);
|
|
@@ -38,21 +38,21 @@ function vt(e, t) {
|
|
|
38
38
|
let r = e.type === t.linebreakReplacement ? "\n" : e.textContent;
|
|
39
39
|
r && n.push(t.text(r, e.marks));
|
|
40
40
|
}
|
|
41
|
-
}),
|
|
41
|
+
}), F.fromArray(n);
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function vt(e, t, n) {
|
|
44
44
|
let r = e.content === "plain" || n && e.content === "styled" ? (t) => (r, i) => {
|
|
45
45
|
let a = n?.({
|
|
46
46
|
el: r,
|
|
47
47
|
schema: i
|
|
48
48
|
});
|
|
49
|
-
if (a !== void 0) return e.content === "plain" ?
|
|
50
|
-
let o =
|
|
51
|
-
return e.content === "plain" ?
|
|
49
|
+
if (a !== void 0) return e.content === "plain" ? _t(a, i) : a;
|
|
50
|
+
let o = gt(t(r), i);
|
|
51
|
+
return e.content === "plain" ? _t(o, i) : o;
|
|
52
52
|
} : void 0, i = [{
|
|
53
53
|
tag: `[data-inline-content-type="${e.type}"]`,
|
|
54
|
-
contentElement: (e) =>
|
|
55
|
-
getContent: r ? (e, t) => r(
|
|
54
|
+
contentElement: (e) => ht(e),
|
|
55
|
+
getContent: r ? (e, t) => r(ht)(e, t) : void 0
|
|
56
56
|
}];
|
|
57
57
|
return t && i.push({
|
|
58
58
|
tag: "*",
|
|
@@ -65,7 +65,7 @@ function yt(e, t, n) {
|
|
|
65
65
|
getContent: r ? (e, t) => r((e) => e)(e, t) : void 0
|
|
66
66
|
}), i;
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function yt(e, t) {
|
|
69
69
|
let n = A.create({
|
|
70
70
|
name: e.type,
|
|
71
71
|
inline: !0,
|
|
@@ -79,57 +79,57 @@ function bt(e, t) {
|
|
|
79
79
|
return e.content === "plain" ? pe(this.editor) : void 0;
|
|
80
80
|
},
|
|
81
81
|
addAttributes() {
|
|
82
|
-
return
|
|
82
|
+
return se(e.propSchema);
|
|
83
83
|
},
|
|
84
84
|
addKeyboardShortcuts() {
|
|
85
|
-
return
|
|
85
|
+
return ce(e);
|
|
86
86
|
},
|
|
87
87
|
parseHTML() {
|
|
88
|
-
return
|
|
88
|
+
return vt(e, t.parse, t.parseContent);
|
|
89
89
|
},
|
|
90
90
|
renderHTML({ node: n }) {
|
|
91
|
-
let
|
|
91
|
+
let r = this.options.editor, i = t.render.call({
|
|
92
92
|
renderType: "dom",
|
|
93
93
|
props: void 0
|
|
94
|
-
},
|
|
95
|
-
return
|
|
94
|
+
}, g(n, r.schema.inlineContentSchema, r.schema.styleSchema), () => {}, r, n, () => void 0);
|
|
95
|
+
return C(i, e.type, n.attrs, e.propSchema);
|
|
96
96
|
},
|
|
97
97
|
addNodeView() {
|
|
98
98
|
return (n) => {
|
|
99
|
-
let { node:
|
|
99
|
+
let { node: r, getPos: i } = n, a = this.options.editor, o = t.render.call({
|
|
100
100
|
renderType: "nodeView",
|
|
101
101
|
props: n
|
|
102
|
-
}, r
|
|
103
|
-
let t =
|
|
104
|
-
n &&
|
|
105
|
-
},
|
|
106
|
-
return
|
|
102
|
+
}, g(r, a.schema.inlineContentSchema, a.schema.styleSchema), (e) => {
|
|
103
|
+
let t = s([e], a.pmSchema), n = i();
|
|
104
|
+
n && a.transact((e) => e.replaceWith(n, n + r.nodeSize, t));
|
|
105
|
+
}, a, r, i), c = C(o, e.type, r.attrs, e.propSchema);
|
|
106
|
+
return p(c), c;
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
|
-
return
|
|
110
|
+
return re(n, e.propSchema, {
|
|
111
111
|
...t,
|
|
112
112
|
toExternalHTML: t.toExternalHTML,
|
|
113
113
|
render(n, r, i) {
|
|
114
|
-
let a =
|
|
115
|
-
return
|
|
114
|
+
let a = s([n], i.pmSchema)[0], o = t.render(n, r, i, a, () => void 0);
|
|
115
|
+
return C(o, e.type, n.props, e.propSchema);
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
//#endregion
|
|
120
120
|
//#region src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts
|
|
121
|
-
function
|
|
122
|
-
let i = typeof n == "string" ? n : n.id,
|
|
123
|
-
let t =
|
|
121
|
+
function bt(e, t, n, r = "before") {
|
|
122
|
+
let i = typeof n == "string" ? n : n.id, o = b(e), s = t.map((e) => {
|
|
123
|
+
let t = a(e, o);
|
|
124
124
|
return t.check(), t;
|
|
125
|
-
}),
|
|
126
|
-
if (!
|
|
127
|
-
let l =
|
|
128
|
-
return r === "after" && (l +=
|
|
125
|
+
}), c = u(i, e.doc);
|
|
126
|
+
if (!c) throw Error(`Block with ID ${i} not found`);
|
|
127
|
+
let l = c.posBeforeNode;
|
|
128
|
+
return r === "after" && (l += c.node.nodeSize), e.step(new Be(l, l, new D(E.from(s), 0, 0))), s.map((t) => T(t, e.doc));
|
|
129
129
|
}
|
|
130
130
|
//#endregion
|
|
131
131
|
//#region src/api/blockManipulation/commands/replaceBlocks/util/fixColumnList.ts
|
|
132
|
-
function
|
|
132
|
+
function z(e) {
|
|
133
133
|
if (!e || e.type.name !== "column") throw Error("Invalid columnPos: does not point to column node.");
|
|
134
134
|
let t = e.firstChild;
|
|
135
135
|
if (!t) throw Error("Invalid column: does not have child node.");
|
|
@@ -137,24 +137,24 @@ function R(e) {
|
|
|
137
137
|
if (!n) throw Error("Invalid blockContainer: does not have child node.");
|
|
138
138
|
return e.childCount === 1 && t.childCount === 1 && n.type.name === "paragraph" && n.content.content.length === 0;
|
|
139
139
|
}
|
|
140
|
-
function
|
|
140
|
+
function xt(e, t) {
|
|
141
141
|
let n = e.doc.resolve(t), r = n.nodeAfter;
|
|
142
142
|
if (!r || r.type.name !== "columnList") throw Error("Invalid columnListPos: does not point to columnList node.");
|
|
143
143
|
for (let t = r.childCount - 1; t >= 0; t--) {
|
|
144
144
|
let r = e.doc.resolve(n.pos + 1).posAtIndex(t), i = e.doc.resolve(r).nodeAfter;
|
|
145
145
|
if (!i || i.type.name !== "column") throw Error("Invalid columnPos: does not point to column node.");
|
|
146
|
-
|
|
146
|
+
z(i) && e.delete(r, r + i.nodeSize);
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
-
function
|
|
150
|
-
|
|
149
|
+
function B(e, t) {
|
|
150
|
+
xt(e, t);
|
|
151
151
|
let n = e.doc.resolve(t).nodeAfter;
|
|
152
152
|
if (!n || n.type.name !== "columnList") throw Error("Invalid columnListPos: does not point to columnList node.");
|
|
153
153
|
if (n.childCount > 2) return;
|
|
154
154
|
if (n.childCount < 2) throw Error("Invalid columnList: contains fewer than two children.");
|
|
155
155
|
let r = t + 1, i = e.doc.resolve(r).nodeAfter, a = t + n.nodeSize - 1, o = e.doc.resolve(a).nodeBefore;
|
|
156
156
|
if (!i || !o) throw Error("Invalid columnList: does not contain children.");
|
|
157
|
-
let s =
|
|
157
|
+
let s = z(i), c = z(o);
|
|
158
158
|
if (s && c) {
|
|
159
159
|
e.delete(t, t + n.nodeSize);
|
|
160
160
|
return;
|
|
@@ -170,56 +170,56 @@ function z(e, t) {
|
|
|
170
170
|
}
|
|
171
171
|
//#endregion
|
|
172
172
|
//#region src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts
|
|
173
|
-
function
|
|
174
|
-
let i =
|
|
175
|
-
let t =
|
|
173
|
+
function V(e, t, n, r = {}) {
|
|
174
|
+
let i = b(e), o = n.map((e) => {
|
|
175
|
+
let t = a(e, i);
|
|
176
176
|
return t.check(), t;
|
|
177
|
-
}),
|
|
177
|
+
}), s = new Set(t.map((e) => typeof e == "string" ? e : e.id)), c = [], l = /* @__PURE__ */ new Set(), u = typeof t[0] == "string" ? t[0] : t[0].id, d = 0;
|
|
178
178
|
if (e.doc.descendants((t, r) => {
|
|
179
|
-
if (
|
|
179
|
+
if (s.size === 0) return !1;
|
|
180
180
|
if (!t.type.isInGroup("bnBlock")) return !0;
|
|
181
|
-
let i =
|
|
182
|
-
if (!
|
|
183
|
-
if (
|
|
181
|
+
let i = v(t, e.doc);
|
|
182
|
+
if (!s.has(i)) return !0;
|
|
183
|
+
if (c.push(T(t, e.doc)), s.delete(i), n.length > 0 && i === u) {
|
|
184
184
|
let t = e.doc.nodeSize;
|
|
185
|
-
e.insert(r,
|
|
185
|
+
e.insert(r, o);
|
|
186
186
|
let n = e.doc.nodeSize;
|
|
187
|
-
|
|
187
|
+
d += t - n;
|
|
188
188
|
}
|
|
189
|
-
let
|
|
190
|
-
|
|
189
|
+
let a = e.doc.nodeSize, f = e.doc.resolve(r - d);
|
|
190
|
+
f.node().type.name === "column" ? l.add(f.before(-1)) : f.node().type.name === "columnList" && l.add(f.before()), f.node().type.name === "blockGroup" && f.node(f.depth - 1).type.name !== "doc" && f.node().childCount === 1 ? e.delete(f.before(), f.after()) : e.delete(r - d, r - d + t.nodeSize);
|
|
191
191
|
let p = e.doc.nodeSize;
|
|
192
|
-
return
|
|
193
|
-
}),
|
|
194
|
-
let e = [...
|
|
192
|
+
return d += a - p, !1;
|
|
193
|
+
}), s.size > 0) {
|
|
194
|
+
let e = [...s].join("\n");
|
|
195
195
|
throw Error("Blocks with the following IDs could not be found in the editor: " + e);
|
|
196
196
|
}
|
|
197
|
-
return r.fixColumns !== !1 && l.forEach((t) =>
|
|
198
|
-
insertedBlocks:
|
|
199
|
-
removedBlocks:
|
|
197
|
+
return r.fixColumns !== !1 && l.forEach((t) => B(e, t)), {
|
|
198
|
+
insertedBlocks: o.map((t) => T(t, e.doc)),
|
|
199
|
+
removedBlocks: c
|
|
200
200
|
};
|
|
201
201
|
}
|
|
202
202
|
//#endregion
|
|
203
203
|
//#region src/api/exporters/html/util/serializeBlocksInternalHTML.ts
|
|
204
|
-
function
|
|
205
|
-
let
|
|
204
|
+
function St(e, t, n, r, i) {
|
|
205
|
+
let a;
|
|
206
206
|
if (!t) throw Error("blockContent is required");
|
|
207
|
-
if (typeof t == "string")
|
|
208
|
-
else if (Array.isArray(t))
|
|
209
|
-
else if (t.type === "tableContent")
|
|
210
|
-
else throw new
|
|
211
|
-
let
|
|
212
|
-
for (let t of
|
|
213
|
-
let
|
|
214
|
-
if (
|
|
215
|
-
let
|
|
207
|
+
if (typeof t == "string") a = s([t], e.pmSchema, r);
|
|
208
|
+
else if (Array.isArray(t)) a = s(t, e.pmSchema, r);
|
|
209
|
+
else if (t.type === "tableContent") a = c(t, e.pmSchema);
|
|
210
|
+
else throw new o(t.type);
|
|
211
|
+
let l = (i?.document ?? document).createDocumentFragment();
|
|
212
|
+
for (let t of a) if (t.type.name !== "text" && e.schema.inlineContentSchema[t.type.name]) {
|
|
213
|
+
let r = e.schema.inlineContentSpecs[t.type.name].implementation;
|
|
214
|
+
if (r) {
|
|
215
|
+
let a = g(t, e.schema.inlineContentSchema, e.schema.styleSchema), o = r.render.call({
|
|
216
216
|
renderType: "dom",
|
|
217
217
|
props: void 0
|
|
218
|
-
},
|
|
219
|
-
if (
|
|
220
|
-
if (
|
|
221
|
-
let e = n.serializeFragment(t.content,
|
|
222
|
-
|
|
218
|
+
}, a, () => {}, e);
|
|
219
|
+
if (o) {
|
|
220
|
+
if (l.appendChild(o.dom), o.contentDOM) {
|
|
221
|
+
let e = n.serializeFragment(t.content, i);
|
|
222
|
+
o.contentDOM.dataset.editable = "", o.contentDOM.appendChild(e);
|
|
223
223
|
}
|
|
224
224
|
continue;
|
|
225
225
|
}
|
|
@@ -233,14 +233,14 @@ function Ct(e, t, n, i, a) {
|
|
|
233
233
|
let e = r.type.spec.toDOM(r, !0), t = Re.renderSpec(document, e);
|
|
234
234
|
t.contentDOM.appendChild(n), n = t.dom;
|
|
235
235
|
}
|
|
236
|
-
|
|
236
|
+
l.appendChild(n);
|
|
237
237
|
} else {
|
|
238
|
-
let e = n.serializeFragment(E.from([t]),
|
|
239
|
-
|
|
238
|
+
let e = n.serializeFragment(E.from([t]), i);
|
|
239
|
+
l.appendChild(e);
|
|
240
240
|
}
|
|
241
|
-
return
|
|
241
|
+
return l;
|
|
242
242
|
}
|
|
243
|
-
function
|
|
243
|
+
function Ct(e, t, n, r) {
|
|
244
244
|
let i = e.pmSchema.nodes.blockContainer, a = t.props || {};
|
|
245
245
|
for (let [n, r] of Object.entries(e.schema.blockSchema[t.type].propSchema)) !(n in a) && r.default !== void 0 && (a[n] = r.default);
|
|
246
246
|
let o = t.children || [], s = e.blockImplementations[t.type].implementation.render.call({
|
|
@@ -252,12 +252,12 @@ function wt(e, t, n, r) {
|
|
|
252
252
|
children: o
|
|
253
253
|
}, e);
|
|
254
254
|
if (s.contentDOM && t.content) {
|
|
255
|
-
let i =
|
|
255
|
+
let i = St(e, t.content, n, t.type, r);
|
|
256
256
|
s.contentDOM.appendChild(i);
|
|
257
257
|
}
|
|
258
258
|
if (e.pmSchema.nodes[t.type].isInGroup("bnBlock")) {
|
|
259
259
|
if (t.children && t.children.length > 0) {
|
|
260
|
-
let i =
|
|
260
|
+
let i = wt(e, t.children, n, r);
|
|
261
261
|
s.contentDOM?.append(i);
|
|
262
262
|
}
|
|
263
263
|
return s.dom;
|
|
@@ -266,59 +266,59 @@ function wt(e, t, n, r) {
|
|
|
266
266
|
id: t.id,
|
|
267
267
|
...a
|
|
268
268
|
}));
|
|
269
|
-
return c.contentDOM?.appendChild(s.dom), t.children && t.children.length > 0 && c.contentDOM?.appendChild(
|
|
269
|
+
return c.contentDOM?.appendChild(s.dom), t.children && t.children.length > 0 && c.contentDOM?.appendChild(Tt(e, t.children, n, r)), c.dom;
|
|
270
270
|
}
|
|
271
|
-
function
|
|
271
|
+
function wt(e, t, n, r) {
|
|
272
272
|
let i = (r?.document ?? document).createDocumentFragment();
|
|
273
273
|
for (let a of t) {
|
|
274
|
-
let t =
|
|
274
|
+
let t = Ct(e, a, n, r);
|
|
275
275
|
i.appendChild(t);
|
|
276
276
|
}
|
|
277
277
|
return i;
|
|
278
278
|
}
|
|
279
|
-
var
|
|
280
|
-
let i = e.pmSchema.nodes.blockGroup, a = i.spec.toDOM(i.create({})), o =
|
|
279
|
+
var Tt = (e, t, n, r) => {
|
|
280
|
+
let i = e.pmSchema.nodes.blockGroup, a = i.spec.toDOM(i.create({})), o = wt(e, t, n, r);
|
|
281
281
|
return a.contentDOM?.appendChild(o), a.dom;
|
|
282
|
-
},
|
|
282
|
+
}, Et = (e) => (e.querySelectorAll("[data-content-type=\"numberedListItem\"]").forEach((e) => {
|
|
283
283
|
let t = e.closest(".bn-block-outer")?.previousElementSibling?.querySelector("[data-content-type=\"numberedListItem\"]");
|
|
284
284
|
if (!t) e.setAttribute("data-index", e.getAttribute("data-start") || "1");
|
|
285
285
|
else {
|
|
286
286
|
let n = t.getAttribute("data-index");
|
|
287
287
|
e.setAttribute("data-index", (parseInt(n || "0") + 1).toString());
|
|
288
288
|
}
|
|
289
|
-
}), e),
|
|
289
|
+
}), e), Dt = (e) => (e.querySelectorAll("[data-content-type=\"checkListItem\"] input").forEach((e) => {
|
|
290
290
|
e.disabled = !0;
|
|
291
|
-
}), e),
|
|
291
|
+
}), e), Ot = (e) => (e.querySelectorAll(".bn-toggle-wrapper[data-show-children=\"false\"]").forEach((e) => {
|
|
292
292
|
e.setAttribute("data-show-children", "true");
|
|
293
|
-
}), e),
|
|
293
|
+
}), e), kt = (e) => (e.querySelectorAll("[data-content-type=\"table\"] table").forEach((e) => {
|
|
294
294
|
e.setAttribute("style", "--default-cell-min-width: 120px;"), e.setAttribute("data-show-children", "true");
|
|
295
|
-
}), e),
|
|
295
|
+
}), e), At = (e) => (e.querySelectorAll("[data-content-type=\"table\"] table").forEach((e) => {
|
|
296
296
|
let t = document.createElement("div");
|
|
297
297
|
t.className = "tableWrapper";
|
|
298
298
|
let n = document.createElement("div");
|
|
299
299
|
n.className = "tableWrapper-inner", t.appendChild(n), e.parentElement?.appendChild(t), t.appendChild(e);
|
|
300
|
-
}), e),
|
|
300
|
+
}), e), jt = (e) => (e.querySelectorAll(".bn-inline-content:empty").forEach((e) => {
|
|
301
301
|
let t = document.createElement("span");
|
|
302
302
|
t.className = "ProseMirror-trailingBreak", t.setAttribute("style", "display: inline-block;"), e.appendChild(t);
|
|
303
|
-
}), e),
|
|
303
|
+
}), e), Mt = (e, t) => {
|
|
304
304
|
let n = Re.fromSchema(e), r = [
|
|
305
|
+
Et,
|
|
305
306
|
Dt,
|
|
306
307
|
Ot,
|
|
307
308
|
kt,
|
|
308
309
|
At,
|
|
309
|
-
jt
|
|
310
|
-
Mt
|
|
310
|
+
jt
|
|
311
311
|
];
|
|
312
312
|
return { serializeBlocks: (e, i) => {
|
|
313
|
-
let a =
|
|
313
|
+
let a = Tt(t, e, n, i);
|
|
314
314
|
for (let e of r) a = e(a);
|
|
315
315
|
return a.outerHTML;
|
|
316
316
|
} };
|
|
317
|
-
},
|
|
317
|
+
}, Nt = (e) => {
|
|
318
318
|
let t = 0;
|
|
319
319
|
for (let n = 0; n < e.length; n++) t = Math.imul(31, t) + e.charCodeAt(n);
|
|
320
320
|
return Math.abs(t);
|
|
321
|
-
},
|
|
321
|
+
}, H = [
|
|
322
322
|
{
|
|
323
323
|
light: "#fff0c2",
|
|
324
324
|
dark: "#8a6d1a"
|
|
@@ -339,20 +339,20 @@ var Et = (e, t, n, r) => {
|
|
|
339
339
|
light: "#bef3ff",
|
|
340
340
|
dark: "#0a7a8a"
|
|
341
341
|
}
|
|
342
|
-
],
|
|
343
|
-
if (!t || t.length === 0) return
|
|
342
|
+
], Pt = (e) => H[Nt(e) % H.length], Ft = (e, t) => {
|
|
343
|
+
if (!t || t.length === 0) return H[0];
|
|
344
344
|
let n = t[0], r = e.getUser(n);
|
|
345
345
|
return r?.color && r.colorLight ? {
|
|
346
346
|
light: r.colorLight,
|
|
347
347
|
dark: r.color
|
|
348
|
-
} :
|
|
349
|
-
},
|
|
350
|
-
let t =
|
|
348
|
+
} : Pt(n);
|
|
349
|
+
}, It = (e) => ct(e).toString(16).padStart(8, "0"), Lt = (e) => {
|
|
350
|
+
let t = It(e);
|
|
351
351
|
return {
|
|
352
352
|
light: `--user-color-${t}-light`,
|
|
353
353
|
dark: `--user-color-${t}-dark`
|
|
354
354
|
};
|
|
355
|
-
},
|
|
355
|
+
}, U = class {
|
|
356
356
|
callbacks = {};
|
|
357
357
|
on(e, t) {
|
|
358
358
|
return this.callbacks[e] || (this.callbacks[e] = []), this.callbacks[e].push(t), () => this.off(e, t);
|
|
@@ -371,90 +371,90 @@ var Et = (e, t, n, r) => {
|
|
|
371
371
|
};
|
|
372
372
|
//#endregion
|
|
373
373
|
//#region src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts
|
|
374
|
-
function
|
|
374
|
+
function Rt(e) {
|
|
375
375
|
return e.transact((e) => {
|
|
376
|
-
let t =
|
|
377
|
-
if (e.selection instanceof
|
|
376
|
+
let t = ae(e, e.selection.anchor), n = v(t.bnBlock.node, e.doc);
|
|
377
|
+
if (e.selection instanceof ot) return {
|
|
378
378
|
type: "cell",
|
|
379
379
|
anchorBlockId: n,
|
|
380
380
|
anchorCellOffset: e.selection.$anchorCell.pos - t.bnBlock.beforePos,
|
|
381
381
|
headCellOffset: e.selection.$headCell.pos - t.bnBlock.beforePos
|
|
382
382
|
};
|
|
383
|
-
if (e.selection instanceof
|
|
383
|
+
if (e.selection instanceof M) return {
|
|
384
384
|
type: "node",
|
|
385
385
|
anchorBlockId: n
|
|
386
386
|
};
|
|
387
387
|
{
|
|
388
|
-
let r =
|
|
388
|
+
let r = ae(e, e.selection.head);
|
|
389
389
|
return {
|
|
390
390
|
type: "text",
|
|
391
391
|
anchorBlockId: n,
|
|
392
|
-
headBlockId:
|
|
392
|
+
headBlockId: v(r.bnBlock.node, e.doc),
|
|
393
393
|
anchorOffset: e.selection.anchor - t.bnBlock.beforePos,
|
|
394
394
|
headOffset: e.selection.head - r.bnBlock.beforePos
|
|
395
395
|
};
|
|
396
396
|
}
|
|
397
397
|
});
|
|
398
398
|
}
|
|
399
|
-
function
|
|
400
|
-
let n =
|
|
399
|
+
function zt(e, t) {
|
|
400
|
+
let n = u(t.anchorBlockId, e.doc)?.posBeforeNode;
|
|
401
401
|
if (n === void 0) throw Error(`Could not find block with ID ${t.anchorBlockId} to update selection`);
|
|
402
402
|
let r;
|
|
403
|
-
if (t.type === "cell") r =
|
|
404
|
-
else if (t.type === "node") r =
|
|
403
|
+
if (t.type === "cell") r = ot.create(e.doc, n + t.anchorCellOffset, n + t.headCellOffset);
|
|
404
|
+
else if (t.type === "node") r = M.create(e.doc, n + 1);
|
|
405
405
|
else {
|
|
406
|
-
let i =
|
|
406
|
+
let i = u(t.headBlockId, e.doc)?.posBeforeNode;
|
|
407
407
|
if (i === void 0) throw Error(`Could not find block with ID ${t.headBlockId} to update selection`);
|
|
408
|
-
r =
|
|
408
|
+
r = P.create(e.doc, n + t.anchorOffset, i + t.headOffset);
|
|
409
409
|
}
|
|
410
410
|
e.setSelection(r);
|
|
411
411
|
}
|
|
412
|
-
function
|
|
412
|
+
function Bt(e) {
|
|
413
413
|
return e.flatMap((e) => e.type === "column" ? e.children : [e]);
|
|
414
414
|
}
|
|
415
|
-
function
|
|
415
|
+
function W(e, t, n, r) {
|
|
416
416
|
e.transact((e) => {
|
|
417
|
-
|
|
417
|
+
V(e, t, [], { fixColumns: !1 }), bt(e, Bt(t), n, r);
|
|
418
418
|
});
|
|
419
419
|
}
|
|
420
|
-
function
|
|
420
|
+
function Vt(e, t, n) {
|
|
421
421
|
e.transact((r) => {
|
|
422
|
-
let i = e.getSelection()?.blocks || [e.getTextCursorPosition().block], a =
|
|
423
|
-
|
|
422
|
+
let i = e.getSelection()?.blocks || [e.getTextCursorPosition().block], a = Rt(e);
|
|
423
|
+
W(e, i, t, n), zt(r, a);
|
|
424
424
|
});
|
|
425
425
|
}
|
|
426
|
-
function
|
|
426
|
+
function Ht(e) {
|
|
427
427
|
return !e || e.type !== "columnList";
|
|
428
428
|
}
|
|
429
|
-
function
|
|
429
|
+
function Ut(e, t, n) {
|
|
430
430
|
let r, i;
|
|
431
431
|
if (t ? t.children.length > 0 ? (r = t.children[t.children.length - 1], i = "after") : (r = t, i = "before") : n && (r = n, i = "before"), !r || !i) return;
|
|
432
432
|
let a = e.getParentBlock(r);
|
|
433
|
-
return
|
|
433
|
+
return Ht(a) ? {
|
|
434
434
|
referenceBlock: r,
|
|
435
435
|
placement: i
|
|
436
|
-
} :
|
|
436
|
+
} : Ut(e, i === "after" ? r : e.getPrevBlock(r), a);
|
|
437
437
|
}
|
|
438
|
-
function
|
|
438
|
+
function Wt(e, t, n) {
|
|
439
439
|
let r, i;
|
|
440
440
|
if (t ? t.children.length > 0 ? (r = t.children[0], i = "before") : (r = t, i = "after") : n && (r = n, i = "after"), !r || !i) return;
|
|
441
441
|
let a = e.getParentBlock(r);
|
|
442
|
-
return
|
|
442
|
+
return Ht(a) ? {
|
|
443
443
|
referenceBlock: r,
|
|
444
444
|
placement: i
|
|
445
|
-
} :
|
|
445
|
+
} : Wt(e, i === "before" ? r : e.getNextBlock(r), a);
|
|
446
446
|
}
|
|
447
|
-
function
|
|
447
|
+
function Gt(e, t) {
|
|
448
448
|
e.transact(() => {
|
|
449
449
|
let n;
|
|
450
450
|
if (t) {
|
|
451
451
|
if (n = e.getBlock(t), !n) return;
|
|
452
452
|
} else n = e.getSelection()?.blocks[0] || e.getTextCursorPosition().block;
|
|
453
|
-
let r =
|
|
454
|
-
r && (t ?
|
|
453
|
+
let r = Ut(e, e.getPrevBlock(n), e.getParentBlock(n));
|
|
454
|
+
r && (t ? W(e, [n], r.referenceBlock, r.placement) : Vt(e, r.referenceBlock, r.placement));
|
|
455
455
|
});
|
|
456
456
|
}
|
|
457
|
-
function
|
|
457
|
+
function Kt(e, t) {
|
|
458
458
|
e.transact(() => {
|
|
459
459
|
let n;
|
|
460
460
|
if (t) {
|
|
@@ -463,13 +463,13 @@ function qt(e, t) {
|
|
|
463
463
|
let t = e.getSelection();
|
|
464
464
|
n = t?.blocks[t?.blocks.length - 1] || e.getTextCursorPosition().block;
|
|
465
465
|
}
|
|
466
|
-
let r =
|
|
467
|
-
r && (t ?
|
|
466
|
+
let r = Wt(e, e.getNextBlock(n), e.getParentBlock(n));
|
|
467
|
+
r && (t ? W(e, [n], r.referenceBlock, r.placement) : Vt(e, r.referenceBlock, r.placement));
|
|
468
468
|
});
|
|
469
469
|
}
|
|
470
470
|
//#endregion
|
|
471
471
|
//#region src/api/blockManipulation/commands/nestBlock/nestBlock.ts
|
|
472
|
-
function
|
|
472
|
+
function qt(e, t, n) {
|
|
473
473
|
let { $from: r, $to: i } = e.selection, a = r.blockRange(i, (e) => e.childCount > 0 && (e.type.name === "blockGroup" || e.type.name === "column"));
|
|
474
474
|
if (!a) return !1;
|
|
475
475
|
let o = a.startIndex;
|
|
@@ -479,10 +479,10 @@ function Jt(e, t, n) {
|
|
|
479
479
|
let c = s.lastChild && s.lastChild.type === n, l = E.from(c ? t.create() : null), u = new D(E.from(t.create(null, E.from(n.create(null, l)))), c ? 3 : 1, 0), d = a.start, f = a.end;
|
|
480
480
|
return e.step(new O(d - (c ? 3 : 1), f, d, f, u, 1, !0)).scrollIntoView(), !0;
|
|
481
481
|
}
|
|
482
|
-
function
|
|
483
|
-
return e.transact((t) =>
|
|
482
|
+
function Jt(e) {
|
|
483
|
+
return e.transact((t) => qt(t, e.pmSchema.nodes.blockContainer, e.pmSchema.nodes.blockGroup));
|
|
484
484
|
}
|
|
485
|
-
function
|
|
485
|
+
function Yt(e, t, n, r) {
|
|
486
486
|
let i = r.end, a = r.$to.end(r.depth);
|
|
487
487
|
if (i < a) {
|
|
488
488
|
let o = r.parent.child(r.endIndex - 1), s = o.lastChild && o.lastChild.type === n;
|
|
@@ -494,70 +494,70 @@ function Xt(e, t, n, r) {
|
|
|
494
494
|
let s = e.doc.resolve(e.mapping.map(i, -1) - 1);
|
|
495
495
|
return Ve(e.doc, s.pos) && s.nodeBefore.type === s.nodeAfter.type && e.join(s.pos), e.scrollIntoView(), !0;
|
|
496
496
|
}
|
|
497
|
-
function
|
|
497
|
+
function G(e, t, n) {
|
|
498
498
|
let { $from: r, $to: i } = e.selection, a = r.blockRange(i, (e) => e.childCount > 0 && (e.type.name === "blockGroup" || e.type.name === "column"));
|
|
499
|
-
return a ? r.node(a.depth - 1).type === t &&
|
|
499
|
+
return a ? r.node(a.depth - 1).type === t && Yt(e, t, n, a) : !1;
|
|
500
500
|
}
|
|
501
|
-
function
|
|
502
|
-
return e.transact((t) =>
|
|
501
|
+
function Xt(e) {
|
|
502
|
+
return e.transact((t) => G(t, e.pmSchema.nodes.blockContainer, e.pmSchema.nodes.blockGroup));
|
|
503
503
|
}
|
|
504
|
-
function
|
|
504
|
+
function Zt(e) {
|
|
505
505
|
return e.transact((e) => {
|
|
506
|
-
let { bnBlock: t } =
|
|
506
|
+
let { bnBlock: t } = S(e);
|
|
507
507
|
return e.doc.resolve(t.beforePos).nodeBefore !== null;
|
|
508
508
|
});
|
|
509
509
|
}
|
|
510
|
-
function
|
|
510
|
+
function Qt(e) {
|
|
511
511
|
return e.transact((e) => {
|
|
512
|
-
let { bnBlock: t } =
|
|
512
|
+
let { bnBlock: t } = S(e);
|
|
513
513
|
return e.doc.resolve(t.beforePos).depth > 1;
|
|
514
514
|
});
|
|
515
515
|
}
|
|
516
516
|
//#endregion
|
|
517
517
|
//#region src/api/blockManipulation/getBlock/getBlock.ts
|
|
518
|
-
function
|
|
519
|
-
let n = typeof t == "string" ? t : t.id, r =
|
|
520
|
-
if (r) return
|
|
518
|
+
function $t(e, t) {
|
|
519
|
+
let n = typeof t == "string" ? t : t.id, r = u(n, e);
|
|
520
|
+
if (r) return T(r.node, e);
|
|
521
521
|
}
|
|
522
|
-
function
|
|
523
|
-
let n = typeof t == "string" ? t : t.id, r =
|
|
522
|
+
function en(e, t) {
|
|
523
|
+
let n = typeof t == "string" ? t : t.id, r = u(n, e);
|
|
524
524
|
if (!r) return;
|
|
525
525
|
let i = e.resolve(r.posBeforeNode).nodeBefore;
|
|
526
|
-
if (i) return
|
|
526
|
+
if (i) return T(i, e);
|
|
527
527
|
}
|
|
528
|
-
function
|
|
529
|
-
let n = typeof t == "string" ? t : t.id, r =
|
|
528
|
+
function tn(e, t) {
|
|
529
|
+
let n = typeof t == "string" ? t : t.id, r = u(n, e);
|
|
530
530
|
if (!r) return;
|
|
531
531
|
let i = e.resolve(r.posBeforeNode + r.node.nodeSize).nodeAfter;
|
|
532
|
-
if (i) return
|
|
532
|
+
if (i) return T(i, e);
|
|
533
533
|
}
|
|
534
|
-
function
|
|
535
|
-
let n = typeof t == "string" ? t : t.id, r =
|
|
534
|
+
function nn(e, t) {
|
|
535
|
+
let n = typeof t == "string" ? t : t.id, r = u(n, e);
|
|
536
536
|
if (!r) return;
|
|
537
537
|
let i = e.resolve(r.posBeforeNode), a = i.node(), o = i.node(-1), s = o.type.name === "doc" ? void 0 : a.type.name === "blockGroup" ? o : a;
|
|
538
|
-
if (s) return
|
|
538
|
+
if (s) return T(s, e);
|
|
539
539
|
}
|
|
540
540
|
//#endregion
|
|
541
541
|
//#region src/editor/managers/BlockManager.ts
|
|
542
|
-
var
|
|
542
|
+
var rn = class {
|
|
543
543
|
editor;
|
|
544
544
|
constructor(e) {
|
|
545
545
|
this.editor = e;
|
|
546
546
|
}
|
|
547
547
|
get document() {
|
|
548
|
-
return this.editor.transact((e) =>
|
|
548
|
+
return this.editor.transact((e) => n(e.doc));
|
|
549
549
|
}
|
|
550
550
|
getBlock(e) {
|
|
551
|
-
return this.editor.transact((t) =>
|
|
551
|
+
return this.editor.transact((t) => $t(t.doc, e));
|
|
552
552
|
}
|
|
553
553
|
getPrevBlock(e) {
|
|
554
|
-
return this.editor.transact((t) =>
|
|
554
|
+
return this.editor.transact((t) => en(t.doc, e));
|
|
555
555
|
}
|
|
556
556
|
getNextBlock(e) {
|
|
557
|
-
return this.editor.transact((t) =>
|
|
557
|
+
return this.editor.transact((t) => tn(t.doc, e));
|
|
558
558
|
}
|
|
559
559
|
getParentBlock(e) {
|
|
560
|
-
return this.editor.transact((t) =>
|
|
560
|
+
return this.editor.transact((t) => nn(t.doc, e));
|
|
561
561
|
}
|
|
562
562
|
forEachBlock(e, t = !1) {
|
|
563
563
|
let n = this.document.slice();
|
|
@@ -569,36 +569,36 @@ var an = class {
|
|
|
569
569
|
r(n);
|
|
570
570
|
}
|
|
571
571
|
insertBlocks(e, t, n = "before") {
|
|
572
|
-
return this.editor.transact((r) =>
|
|
572
|
+
return this.editor.transact((r) => bt(r, e, t, n));
|
|
573
573
|
}
|
|
574
|
-
updateBlock(e,
|
|
575
|
-
return this.editor.transact((
|
|
574
|
+
updateBlock(e, n) {
|
|
575
|
+
return this.editor.transact((r) => t(r, e, n));
|
|
576
576
|
}
|
|
577
577
|
removeBlocks(e) {
|
|
578
|
-
return this.editor.transact((t) =>
|
|
578
|
+
return this.editor.transact((t) => V(t, e, []).removedBlocks);
|
|
579
579
|
}
|
|
580
580
|
replaceBlocks(e, t) {
|
|
581
|
-
return this.editor.transact((n) =>
|
|
581
|
+
return this.editor.transact((n) => V(n, e, t));
|
|
582
582
|
}
|
|
583
583
|
canNestBlock() {
|
|
584
|
-
return
|
|
584
|
+
return Zt(this.editor);
|
|
585
585
|
}
|
|
586
586
|
nestBlock() {
|
|
587
|
-
|
|
587
|
+
Jt(this.editor);
|
|
588
588
|
}
|
|
589
589
|
canUnnestBlock() {
|
|
590
|
-
return
|
|
590
|
+
return Qt(this.editor);
|
|
591
591
|
}
|
|
592
592
|
unnestBlock() {
|
|
593
|
-
|
|
593
|
+
Xt(this.editor);
|
|
594
594
|
}
|
|
595
595
|
moveBlocksUp(e) {
|
|
596
|
-
return
|
|
596
|
+
return Gt(this.editor, e);
|
|
597
597
|
}
|
|
598
598
|
moveBlocksDown(e) {
|
|
599
|
-
return
|
|
599
|
+
return Kt(this.editor, e);
|
|
600
600
|
}
|
|
601
|
-
},
|
|
601
|
+
}, an = class extends U {
|
|
602
602
|
editor;
|
|
603
603
|
constructor(e) {
|
|
604
604
|
super(), this.editor = e, e.on("create", () => {
|
|
@@ -622,7 +622,7 @@ var an = class {
|
|
|
622
622
|
}
|
|
623
623
|
onChange(e, t = !0) {
|
|
624
624
|
let n = ({ transaction: n, appendedTransactions: r }) => {
|
|
625
|
-
!t &&
|
|
625
|
+
!t && on(n) || e(this.editor, { getChanges() {
|
|
626
626
|
return Se(n, r);
|
|
627
627
|
} });
|
|
628
628
|
};
|
|
@@ -632,7 +632,7 @@ var an = class {
|
|
|
632
632
|
}
|
|
633
633
|
onSelectionChange(e, t = !1) {
|
|
634
634
|
let n = (n) => {
|
|
635
|
-
!t &&
|
|
635
|
+
!t && on(n.transaction) || e(this.editor);
|
|
636
636
|
};
|
|
637
637
|
return this.on("onSelectionChange", n), () => {
|
|
638
638
|
this.off("onSelectionChange", n);
|
|
@@ -649,30 +649,30 @@ var an = class {
|
|
|
649
649
|
};
|
|
650
650
|
}
|
|
651
651
|
};
|
|
652
|
-
function
|
|
652
|
+
function on(e) {
|
|
653
653
|
return !!e.getMeta("y-sync$");
|
|
654
654
|
}
|
|
655
655
|
//#endregion
|
|
656
656
|
//#region src/api/parsers/html/util/nestedLists.ts
|
|
657
|
-
function
|
|
657
|
+
function sn(e) {
|
|
658
658
|
return Array.prototype.indexOf.call(e.parentElement.childNodes, e);
|
|
659
659
|
}
|
|
660
|
-
function
|
|
660
|
+
function cn(e) {
|
|
661
661
|
return e.nodeType === 3 && !/\S/.test(e.nodeValue || "");
|
|
662
662
|
}
|
|
663
|
-
function
|
|
663
|
+
function ln(e) {
|
|
664
664
|
e.querySelectorAll("li > ul, li > ol").forEach((e) => {
|
|
665
|
-
let t =
|
|
665
|
+
let t = sn(e), n = e.parentElement, r = Array.from(n.childNodes).slice(t + 1);
|
|
666
666
|
e.remove(), r.forEach((e) => {
|
|
667
667
|
e.remove();
|
|
668
668
|
}), n.insertAdjacentElement("afterend", e), r.reverse().forEach((t) => {
|
|
669
|
-
if (
|
|
669
|
+
if (cn(t)) return;
|
|
670
670
|
let n = document.createElement("li");
|
|
671
671
|
n.append(t), e.insertAdjacentElement("afterend", n);
|
|
672
672
|
}), n.childNodes.length === 0 && n.remove();
|
|
673
673
|
});
|
|
674
674
|
}
|
|
675
|
-
function
|
|
675
|
+
function un(e) {
|
|
676
676
|
e.querySelectorAll("li + ul, li + ol").forEach((e) => {
|
|
677
677
|
let t = e.previousElementSibling, n = document.createElement("div");
|
|
678
678
|
t.insertAdjacentElement("afterend", n), n.append(t);
|
|
@@ -680,25 +680,25 @@ function dn(e) {
|
|
|
680
680
|
for (r.setAttribute("data-node-type", "blockGroup"), n.append(r); n.nextElementSibling?.nodeName === "UL" || n.nextElementSibling?.nodeName === "OL";) r.append(n.nextElementSibling);
|
|
681
681
|
});
|
|
682
682
|
}
|
|
683
|
-
var
|
|
684
|
-
function
|
|
685
|
-
return
|
|
683
|
+
var dn = null;
|
|
684
|
+
function fn() {
|
|
685
|
+
return dn ||= document.implementation.createHTMLDocument("title");
|
|
686
686
|
}
|
|
687
|
-
function
|
|
687
|
+
function pn(e) {
|
|
688
688
|
if (typeof e == "string") {
|
|
689
|
-
let t =
|
|
689
|
+
let t = fn().createElement("div");
|
|
690
690
|
t.innerHTML = e, e = t;
|
|
691
691
|
}
|
|
692
|
-
return
|
|
692
|
+
return ln(e), un(e), e;
|
|
693
693
|
}
|
|
694
694
|
//#endregion
|
|
695
695
|
//#region src/api/parsers/html/util/normalizeWhitespace.ts
|
|
696
|
-
function
|
|
696
|
+
function mn(e) {
|
|
697
697
|
let t = e.ownerDocument.createTreeWalker(e, 128), n;
|
|
698
698
|
for (; n = t.nextNode();) if (/^\s*notionvc:/.test(n.nodeValue || "")) return !0;
|
|
699
699
|
return !1;
|
|
700
700
|
}
|
|
701
|
-
function
|
|
701
|
+
function hn(e) {
|
|
702
702
|
let t = /* @__PURE__ */ new Set(["PRE", "CODE"]), n = e.ownerDocument.createTreeWalker(e, 4, { acceptNode(n) {
|
|
703
703
|
let r = n.parentElement;
|
|
704
704
|
for (; r && r !== e;) {
|
|
@@ -710,12 +710,12 @@ function gn(e) {
|
|
|
710
710
|
for (; i = n.nextNode();) r.push(i);
|
|
711
711
|
for (let e of r) e.nodeValue && /[\r\n]/.test(e.nodeValue) && (e.nodeValue = e.nodeValue.replace(/[ \t\r\n\f]+/g, " "));
|
|
712
712
|
}
|
|
713
|
-
function
|
|
714
|
-
|
|
713
|
+
function gn(e) {
|
|
714
|
+
mn(e) || hn(e);
|
|
715
715
|
}
|
|
716
716
|
//#endregion
|
|
717
717
|
//#region src/api/parsers/html/parseHTML.ts
|
|
718
|
-
function
|
|
718
|
+
function _n(e) {
|
|
719
719
|
let t = [];
|
|
720
720
|
for (let n of e) if (n.type === "text") {
|
|
721
721
|
let e = n.text.split("").join("");
|
|
@@ -725,80 +725,80 @@ function vn(e) {
|
|
|
725
725
|
});
|
|
726
726
|
} else Array.isArray(n.content) ? t.push({
|
|
727
727
|
...n,
|
|
728
|
-
content:
|
|
728
|
+
content: _n(n.content)
|
|
729
729
|
}) : t.push(n);
|
|
730
730
|
return t;
|
|
731
731
|
}
|
|
732
|
-
function
|
|
733
|
-
for (let t of e) Array.isArray(t.content) && (t.content =
|
|
732
|
+
function vn(e) {
|
|
733
|
+
for (let t of e) Array.isArray(t.content) && (t.content = _n(t.content)), t.children.length > 0 && vn(t.children);
|
|
734
734
|
}
|
|
735
|
-
function
|
|
736
|
-
let n =
|
|
737
|
-
|
|
735
|
+
function K(e, t) {
|
|
736
|
+
let n = pn(e);
|
|
737
|
+
gn(n);
|
|
738
738
|
let r = Le.fromSchema(t).parse(n, { topNode: t.nodes.blockGroup.create() }), i = [];
|
|
739
|
-
for (let e = 0; e < r.childCount; e++) i.push(
|
|
740
|
-
return
|
|
739
|
+
for (let e = 0; e < r.childCount; e++) i.push(T(r.child(e), r));
|
|
740
|
+
return vn(i), i;
|
|
741
741
|
}
|
|
742
742
|
//#endregion
|
|
743
743
|
//#region src/api/parsers/markdown/markdownToHtml.ts
|
|
744
|
-
function
|
|
744
|
+
function q(e) {
|
|
745
745
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
746
746
|
}
|
|
747
|
-
function
|
|
747
|
+
function yn(e) {
|
|
748
748
|
return e ? /\w/.test(e) : !1;
|
|
749
749
|
}
|
|
750
|
-
function
|
|
750
|
+
function J(e, t, n) {
|
|
751
751
|
let r = t > 0 ? e[t - 1] : void 0, i = t + n < e.length ? e[t + n] : void 0;
|
|
752
|
-
return
|
|
752
|
+
return yn(r) && yn(i);
|
|
753
753
|
}
|
|
754
|
-
function
|
|
754
|
+
function bn(e, t) {
|
|
755
755
|
if (e[t] !== "\\" || t + 1 >= e.length) return null;
|
|
756
756
|
let n = e[t + 1];
|
|
757
757
|
return n === "\n" ? {
|
|
758
758
|
html: "<br>\n",
|
|
759
759
|
end: t + 2
|
|
760
760
|
} : "\\`*_{}[]()#+-.!~|>".includes(n) ? {
|
|
761
|
-
html:
|
|
761
|
+
html: q(n),
|
|
762
762
|
end: t + 2
|
|
763
763
|
} : null;
|
|
764
764
|
}
|
|
765
|
+
function xn(e, t) {
|
|
766
|
+
return e[t] === "`" ? Ln(e, t) : null;
|
|
767
|
+
}
|
|
765
768
|
function Sn(e, t) {
|
|
766
|
-
return e[t]
|
|
769
|
+
return e[t] !== "!" || e[t + 1] !== "[" ? null : Rn(e, t);
|
|
767
770
|
}
|
|
768
771
|
function Cn(e, t) {
|
|
769
|
-
return e[t]
|
|
772
|
+
return e[t] === "[" ? zn(e, t) : null;
|
|
770
773
|
}
|
|
771
774
|
function wn(e, t) {
|
|
772
|
-
return e[t]
|
|
775
|
+
return e[t] !== "~" || e[t + 1] !== "~" ? null : X(e, t, "~~", "<del>", "</del>");
|
|
773
776
|
}
|
|
774
777
|
function Tn(e, t) {
|
|
775
|
-
return e[t]
|
|
778
|
+
return e[t] === "*" && e[t + 1] === "*" && e[t + 2] === "*" || e[t] === "_" && e[t + 1] === "_" && e[t + 2] === "_" && !J(e, t, 3) ? X(e, t, e.substring(t, t + 3), "<strong><em>", "</em></strong>") : null;
|
|
776
779
|
}
|
|
777
780
|
function En(e, t) {
|
|
778
|
-
return e[t] === "*" && e[t + 1] === "*"
|
|
781
|
+
return e[t] === "*" && e[t + 1] === "*" || e[t] === "_" && e[t + 1] === "_" && !J(e, t, 2) ? X(e, t, e.substring(t, t + 2), "<strong>", "</strong>") : null;
|
|
779
782
|
}
|
|
780
783
|
function Dn(e, t) {
|
|
781
|
-
return e[t] === "*"
|
|
784
|
+
return e[t] === "*" || e[t] === "_" && !J(e, t, 1) ? X(e, t, e[t], "<em>", "</em>") : null;
|
|
782
785
|
}
|
|
783
786
|
function On(e, t) {
|
|
784
|
-
return e[t] === "*" || e[t] === "_" && !q(e, t, 1) ? Y(e, t, e[t], "<em>", "</em>") : null;
|
|
785
|
-
}
|
|
786
|
-
function kn(e, t) {
|
|
787
787
|
return e[t] === "\n" ? {
|
|
788
788
|
html: "<br>\n",
|
|
789
789
|
end: t + 1
|
|
790
790
|
} : null;
|
|
791
791
|
}
|
|
792
|
-
var
|
|
793
|
-
function
|
|
792
|
+
var kn = /^<\/?[a-zA-Z][a-zA-Z0-9-]*(?:\s+[a-zA-Z_:][a-zA-Z0-9_.:-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*\s*\/?>/, An = /^<!--[\s\S]*?-->/, jn = /^<!\[CDATA\[[\s\S]*?\]\]>/, Mn = /^<\?[\s\S]*?\?>/, Nn = /^<![A-Za-z][\s\S]*?>/;
|
|
793
|
+
function Pn(e, t) {
|
|
794
794
|
if (e[t] !== "<") return null;
|
|
795
795
|
let n = e.substring(t);
|
|
796
796
|
for (let e of [
|
|
797
|
+
An,
|
|
797
798
|
jn,
|
|
798
799
|
Mn,
|
|
799
800
|
Nn,
|
|
800
|
-
|
|
801
|
-
An
|
|
801
|
+
kn
|
|
802
802
|
]) {
|
|
803
803
|
let r = n.match(e);
|
|
804
804
|
if (r) return {
|
|
@@ -808,7 +808,8 @@ function Fn(e, t) {
|
|
|
808
808
|
}
|
|
809
809
|
return null;
|
|
810
810
|
}
|
|
811
|
-
var
|
|
811
|
+
var Fn = /* @__PURE__ */ new Set("\\`![~*_\n<"), In = [
|
|
812
|
+
bn,
|
|
812
813
|
xn,
|
|
813
814
|
Sn,
|
|
814
815
|
Cn,
|
|
@@ -816,11 +817,10 @@ var In = /* @__PURE__ */ new Set("\\`![~*_\n<"), Ln = [
|
|
|
816
817
|
Tn,
|
|
817
818
|
En,
|
|
818
819
|
Dn,
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
kn
|
|
820
|
+
Pn,
|
|
821
|
+
On
|
|
822
822
|
];
|
|
823
|
-
function
|
|
823
|
+
function Y(e) {
|
|
824
824
|
let t = "", n = 0;
|
|
825
825
|
for (; n < e.length;) {
|
|
826
826
|
if (e[n] === "\n" && n >= 2 && e[n - 1] === " " && e[n - 2] === " ") {
|
|
@@ -828,7 +828,7 @@ function J(e) {
|
|
|
828
828
|
continue;
|
|
829
829
|
}
|
|
830
830
|
let r = !1;
|
|
831
|
-
if (
|
|
831
|
+
if (Fn.has(e[n])) for (let i of In) {
|
|
832
832
|
let a = i(e, n);
|
|
833
833
|
if (a) {
|
|
834
834
|
t += a.html, n = a.end, r = !0;
|
|
@@ -837,13 +837,13 @@ function J(e) {
|
|
|
837
837
|
}
|
|
838
838
|
if (!r) {
|
|
839
839
|
let r = n;
|
|
840
|
-
for (n++; n < e.length && !
|
|
841
|
-
t +=
|
|
840
|
+
for (n++; n < e.length && !Fn.has(e[n]);) n++;
|
|
841
|
+
t += q(e.substring(r, n));
|
|
842
842
|
}
|
|
843
843
|
}
|
|
844
844
|
return t;
|
|
845
845
|
}
|
|
846
|
-
function
|
|
846
|
+
function Ln(e, t) {
|
|
847
847
|
let n = 0, r = t;
|
|
848
848
|
for (; r < e.length && e[r] === "`";) n++, r++;
|
|
849
849
|
let i = r;
|
|
@@ -853,46 +853,46 @@ function Rn(e, t) {
|
|
|
853
853
|
if (t === n) {
|
|
854
854
|
let t = e.substring(r, a);
|
|
855
855
|
return t = t.replace(/\n/g, " "), t.length >= 2 && t[0] === " " && t[t.length - 1] === " " && /[^ ]/.test(t) && (t = t.substring(1, t.length - 1)), {
|
|
856
|
-
html: `<code>${
|
|
856
|
+
html: `<code>${q(t)}</code>`,
|
|
857
857
|
end: i
|
|
858
858
|
};
|
|
859
859
|
}
|
|
860
860
|
} else i++;
|
|
861
861
|
return null;
|
|
862
862
|
}
|
|
863
|
-
function
|
|
864
|
-
let n =
|
|
863
|
+
function Rn(e, t) {
|
|
864
|
+
let n = Bn(e, t + 1);
|
|
865
865
|
if (n === -1) return null;
|
|
866
866
|
let r = t + 2;
|
|
867
867
|
if (e[n + 1] !== "(") return null;
|
|
868
|
-
let i = n + 2, a =
|
|
868
|
+
let i = n + 2, a = Vn(e, i - 1);
|
|
869
869
|
if (a === -1) return null;
|
|
870
|
-
let o = e.substring(r, n), { url: s, title: c } =
|
|
871
|
-
if (
|
|
870
|
+
let o = e.substring(r, n), { url: s, title: c } = Hn(e.substring(i, a));
|
|
871
|
+
if (ie(s)) {
|
|
872
872
|
let e = o || c;
|
|
873
873
|
return {
|
|
874
|
-
html: `<video src="${
|
|
874
|
+
html: `<video src="${q(s)}"${e ? ` data-name="${q(e)}"` : ""} data-url="${q(s)}" controls></video>`,
|
|
875
875
|
end: a + 1
|
|
876
876
|
};
|
|
877
877
|
}
|
|
878
|
-
let l = c === void 0 ? "" : ` title="${
|
|
878
|
+
let l = c === void 0 ? "" : ` title="${q(c)}"`;
|
|
879
879
|
return {
|
|
880
|
-
html: `<img src="${
|
|
880
|
+
html: `<img src="${q(s)}" alt="${q(o)}"${l}>`,
|
|
881
881
|
end: a + 1
|
|
882
882
|
};
|
|
883
883
|
}
|
|
884
|
-
function
|
|
885
|
-
let n = t + 1, r =
|
|
884
|
+
function zn(e, t) {
|
|
885
|
+
let n = t + 1, r = Bn(e, t);
|
|
886
886
|
if (r === -1 || e[r + 1] !== "(") return null;
|
|
887
|
-
let i = r + 2, a =
|
|
887
|
+
let i = r + 2, a = Vn(e, r + 1);
|
|
888
888
|
if (a === -1) return null;
|
|
889
|
-
let o = e.substring(n, r), { url: s, title: c } =
|
|
889
|
+
let o = e.substring(n, r), { url: s, title: c } = Hn(e.substring(i, a)), l = c === void 0 ? "" : ` title="${q(c)}"`;
|
|
890
890
|
return {
|
|
891
|
-
html: `<a href="${
|
|
891
|
+
html: `<a href="${q(s)}"${l}>${Y(o)}</a>`,
|
|
892
892
|
end: a + 1
|
|
893
893
|
};
|
|
894
894
|
}
|
|
895
|
-
function
|
|
895
|
+
function Bn(e, t) {
|
|
896
896
|
let n = 0;
|
|
897
897
|
for (let r = t; r < e.length; r++) {
|
|
898
898
|
if (e[r] === "\\" && r + 1 < e.length) {
|
|
@@ -903,7 +903,7 @@ function Vn(e, t) {
|
|
|
903
903
|
}
|
|
904
904
|
return -1;
|
|
905
905
|
}
|
|
906
|
-
function
|
|
906
|
+
function Vn(e, t) {
|
|
907
907
|
let n = 0;
|
|
908
908
|
for (let r = t; r < e.length; r++) {
|
|
909
909
|
if (e[r] === "\\" && r + 1 < e.length) {
|
|
@@ -914,7 +914,7 @@ function Hn(e, t) {
|
|
|
914
914
|
}
|
|
915
915
|
return -1;
|
|
916
916
|
}
|
|
917
|
-
function
|
|
917
|
+
function Hn(e) {
|
|
918
918
|
e = e.trim();
|
|
919
919
|
let t, n;
|
|
920
920
|
if (e.startsWith("<")) {
|
|
@@ -944,7 +944,7 @@ function Un(e) {
|
|
|
944
944
|
title: r
|
|
945
945
|
};
|
|
946
946
|
}
|
|
947
|
-
function
|
|
947
|
+
function X(e, t, n, r, i) {
|
|
948
948
|
let a = n.length, o = t + a;
|
|
949
949
|
if (o >= e.length || e[o] === " " || e[o] === " ") return null;
|
|
950
950
|
let s = o;
|
|
@@ -968,7 +968,7 @@ function Y(e, t, n, r, i) {
|
|
|
968
968
|
continue;
|
|
969
969
|
}
|
|
970
970
|
return {
|
|
971
|
-
html: r +
|
|
971
|
+
html: r + Y(t) + i,
|
|
972
972
|
end: s + a
|
|
973
973
|
};
|
|
974
974
|
}
|
|
@@ -976,13 +976,13 @@ function Y(e, t, n, r, i) {
|
|
|
976
976
|
}
|
|
977
977
|
return null;
|
|
978
978
|
}
|
|
979
|
-
var
|
|
980
|
-
function
|
|
979
|
+
var Un = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.article.aside.audio.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.section.source.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul".split("."));
|
|
980
|
+
function Wn(e) {
|
|
981
981
|
if (/^ {0,3}<(!--|\?|![A-Za-z]|!\[CDATA\[)/.test(e)) return !0;
|
|
982
982
|
let t = e.match(/^ {0,3}<\/?([a-zA-Z][a-zA-Z0-9-]*)(?:\s|\/?>|$)/);
|
|
983
|
-
return t ?
|
|
983
|
+
return t ? Un.has(t[1].toLowerCase()) : !1;
|
|
984
984
|
}
|
|
985
|
-
function
|
|
985
|
+
function Gn(e) {
|
|
986
986
|
let t = e.split("\n"), n = [], r = 0, i = !0;
|
|
987
987
|
for (; r < t.length;) {
|
|
988
988
|
let e = t[r];
|
|
@@ -1041,7 +1041,7 @@ function Kn(e) {
|
|
|
1041
1041
|
continue;
|
|
1042
1042
|
}
|
|
1043
1043
|
}
|
|
1044
|
-
let s =
|
|
1044
|
+
let s = Kn(t, r);
|
|
1045
1045
|
if (s) {
|
|
1046
1046
|
n.push(s.token), r = s.nextLine, i = !1;
|
|
1047
1047
|
continue;
|
|
@@ -1097,7 +1097,7 @@ function Kn(e) {
|
|
|
1097
1097
|
}), i = !1;
|
|
1098
1098
|
continue;
|
|
1099
1099
|
}
|
|
1100
|
-
if (
|
|
1100
|
+
if (Wn(e)) {
|
|
1101
1101
|
let e = [];
|
|
1102
1102
|
for (; r < t.length && t[r].trim() !== "";) e.push(t[r]), r++;
|
|
1103
1103
|
n.push({
|
|
@@ -1109,7 +1109,7 @@ function Kn(e) {
|
|
|
1109
1109
|
let l = [e];
|
|
1110
1110
|
for (r++; r < t.length;) {
|
|
1111
1111
|
let e = t[r];
|
|
1112
|
-
if (e.trim() === "" || /^(#{1,6})\s/.test(e) || /^(`{3,}|~{3,})/.test(e) || /^\s{0,3}>/.test(e) || /^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(e) || /^\s*([-*+]|\d+[.)])\s+/.test(e) || /^\s*\|(.+\|)+\s*$/.test(e) ||
|
|
1112
|
+
if (e.trim() === "" || /^(#{1,6})\s/.test(e) || /^(`{3,}|~{3,})/.test(e) || /^\s{0,3}>/.test(e) || /^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(e) || /^\s*([-*+]|\d+[.)])\s+/.test(e) || /^\s*\|(.+\|)+\s*$/.test(e) || Wn(e) || r + 1 < t.length && /^[=-]+\s*$/.test(t[r + 1]) && e.trim().length > 0) break;
|
|
1113
1113
|
l.push(e), r++;
|
|
1114
1114
|
}
|
|
1115
1115
|
n.push({
|
|
@@ -1119,15 +1119,15 @@ function Kn(e) {
|
|
|
1119
1119
|
}
|
|
1120
1120
|
return n;
|
|
1121
1121
|
}
|
|
1122
|
-
function
|
|
1122
|
+
function Kn(e, t) {
|
|
1123
1123
|
if (t + 1 >= e.length) return null;
|
|
1124
1124
|
let n = e[t], r = e[t + 1];
|
|
1125
1125
|
if (!r.includes("|") || !/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/.test(r) || !n.includes("|")) return null;
|
|
1126
|
-
let i =
|
|
1126
|
+
let i = qn(n), a = Jn(r), o = [], s = t + 2;
|
|
1127
1127
|
for (; s < e.length;) {
|
|
1128
1128
|
let t = e[s];
|
|
1129
1129
|
if (!t.includes("|")) break;
|
|
1130
|
-
o.push(
|
|
1130
|
+
o.push(qn(t)), s++;
|
|
1131
1131
|
}
|
|
1132
1132
|
return {
|
|
1133
1133
|
token: {
|
|
@@ -1139,37 +1139,37 @@ function qn(e, t) {
|
|
|
1139
1139
|
nextLine: s
|
|
1140
1140
|
};
|
|
1141
1141
|
}
|
|
1142
|
-
function
|
|
1142
|
+
function qn(e) {
|
|
1143
1143
|
let t = e.trim(), n = t.startsWith("|") ? t.substring(1) : t, r = n.endsWith("|") ? n.substring(0, n.length - 1) : n, i = [], a = "";
|
|
1144
1144
|
for (let e = 0; e < r.length; e++) r[e] === "\\" && e + 1 < r.length && r[e + 1] === "|" ? (a += "|", e++) : r[e] === "|" ? (i.push(a.trim()), a = "") : a += r[e];
|
|
1145
1145
|
return i.push(a.trim()), i;
|
|
1146
1146
|
}
|
|
1147
|
-
function
|
|
1148
|
-
return
|
|
1147
|
+
function Jn(e) {
|
|
1148
|
+
return qn(e).map((e) => {
|
|
1149
1149
|
let t = e.trim(), n = t.startsWith(":"), r = t.endsWith(":");
|
|
1150
1150
|
return n && r ? "center" : r ? "right" : n ? "left" : null;
|
|
1151
1151
|
});
|
|
1152
1152
|
}
|
|
1153
|
-
function
|
|
1153
|
+
function Yn(e) {
|
|
1154
1154
|
let t = "", n = 0;
|
|
1155
1155
|
for (; n < e.length;) {
|
|
1156
1156
|
let r = e[n];
|
|
1157
1157
|
switch (r.type) {
|
|
1158
1158
|
case "heading": {
|
|
1159
1159
|
let e = r;
|
|
1160
|
-
t += `<h${e.level}>${
|
|
1160
|
+
t += `<h${e.level}>${Y(e.content)}</h${e.level}>`, n++;
|
|
1161
1161
|
break;
|
|
1162
1162
|
}
|
|
1163
1163
|
case "paragraph":
|
|
1164
|
-
t += `<p>${
|
|
1164
|
+
t += `<p>${Y(r.content)}</p>`, n++;
|
|
1165
1165
|
break;
|
|
1166
1166
|
case "codeBlock": {
|
|
1167
|
-
let e = r, i = e.language ? ` data-language="${
|
|
1168
|
-
t += `<pre><code${i}>${
|
|
1167
|
+
let e = r, i = e.language ? ` data-language="${q(e.language)}"` : "";
|
|
1168
|
+
t += `<pre><code${i}>${q(e.code)}</code></pre>`, n++;
|
|
1169
1169
|
break;
|
|
1170
1170
|
}
|
|
1171
1171
|
case "blockquote": {
|
|
1172
|
-
let e =
|
|
1172
|
+
let e = Yn(Gn(r.content));
|
|
1173
1173
|
t += `<blockquote>${e}</blockquote>`, n++;
|
|
1174
1174
|
break;
|
|
1175
1175
|
}
|
|
@@ -1177,12 +1177,12 @@ function Xn(e) {
|
|
|
1177
1177
|
t += "<hr>", n++;
|
|
1178
1178
|
break;
|
|
1179
1179
|
case "listItem": {
|
|
1180
|
-
let r =
|
|
1180
|
+
let r = Xn(e, n);
|
|
1181
1181
|
t += r.html, n = r.nextIndex;
|
|
1182
1182
|
break;
|
|
1183
1183
|
}
|
|
1184
1184
|
case "table":
|
|
1185
|
-
t +=
|
|
1185
|
+
t += Qn(r), n++;
|
|
1186
1186
|
break;
|
|
1187
1187
|
case "rawHtml":
|
|
1188
1188
|
t += r.content, n++;
|
|
@@ -1192,10 +1192,10 @@ function Xn(e) {
|
|
|
1192
1192
|
}
|
|
1193
1193
|
return t;
|
|
1194
1194
|
}
|
|
1195
|
-
function
|
|
1195
|
+
function Xn(e, t) {
|
|
1196
1196
|
let n = "", r = t, i = null;
|
|
1197
1197
|
for (; r < e.length && e[r].type === "listItem";) {
|
|
1198
|
-
let t = e[r], a =
|
|
1198
|
+
let t = e[r], a = Zn(t.listType);
|
|
1199
1199
|
if (i !== null && i !== a && (n += `</${i === "ordered" ? "ol" : "ul"}>`, i = null), i === null) {
|
|
1200
1200
|
if (a === "ordered") {
|
|
1201
1201
|
let e = t.start !== void 0 && t.start !== 1 ? ` start="${t.start}"` : "";
|
|
@@ -1205,11 +1205,11 @@ function Zn(e, t) {
|
|
|
1205
1205
|
}
|
|
1206
1206
|
if (t.listType === "task") {
|
|
1207
1207
|
let e = t.checked ? " checked" : "";
|
|
1208
|
-
n += `<li><input type="checkbox" disabled${e}><p>${
|
|
1209
|
-
} else n += `<li><p>${
|
|
1208
|
+
n += `<li><input type="checkbox" disabled${e}><p>${Y(t.content)}</p>`;
|
|
1209
|
+
} else n += `<li><p>${Y(t.content)}</p>`;
|
|
1210
1210
|
if (t.childContent) {
|
|
1211
|
-
let e =
|
|
1212
|
-
n +=
|
|
1211
|
+
let e = Gn(t.childContent);
|
|
1212
|
+
n += Yn(e);
|
|
1213
1213
|
}
|
|
1214
1214
|
n += "</li>", r++;
|
|
1215
1215
|
}
|
|
@@ -1218,16 +1218,16 @@ function Zn(e, t) {
|
|
|
1218
1218
|
nextIndex: r
|
|
1219
1219
|
};
|
|
1220
1220
|
}
|
|
1221
|
-
function
|
|
1221
|
+
function Zn(e) {
|
|
1222
1222
|
return e === "ordered" ? "ordered" : "bullet";
|
|
1223
1223
|
}
|
|
1224
|
-
function
|
|
1224
|
+
function Qn(e) {
|
|
1225
1225
|
let t = "<table>", n = e.headers.every((e) => e.trim() === ""), r = e.headers.length;
|
|
1226
1226
|
if (!n) {
|
|
1227
1227
|
t += "<thead><tr>";
|
|
1228
1228
|
for (let n = 0; n < r; n++) {
|
|
1229
1229
|
let r = e.alignments[n], i = r ? ` align="${r}"` : "";
|
|
1230
|
-
t += `<th${i}>${
|
|
1230
|
+
t += `<th${i}>${Y(e.headers[n])}</th>`;
|
|
1231
1231
|
}
|
|
1232
1232
|
t += "</tr></thead>";
|
|
1233
1233
|
}
|
|
@@ -1237,7 +1237,7 @@ function $n(e) {
|
|
|
1237
1237
|
t += "<tr>";
|
|
1238
1238
|
for (let i = 0; i < r; i++) {
|
|
1239
1239
|
let r = i < n.length ? n[i] : "", a = e.alignments[i], o = a ? ` align="${a}"` : "";
|
|
1240
|
-
t += `<td${o}>${
|
|
1240
|
+
t += `<td${o}>${Y(r)}</td>`;
|
|
1241
1241
|
}
|
|
1242
1242
|
t += "</tr>";
|
|
1243
1243
|
}
|
|
@@ -1245,20 +1245,20 @@ function $n(e) {
|
|
|
1245
1245
|
}
|
|
1246
1246
|
return t += "</table>", t;
|
|
1247
1247
|
}
|
|
1248
|
-
function
|
|
1249
|
-
return
|
|
1248
|
+
function $n(e) {
|
|
1249
|
+
return Yn(Gn(e));
|
|
1250
1250
|
}
|
|
1251
1251
|
//#endregion
|
|
1252
1252
|
//#region src/api/parsers/markdown/parseMarkdown.ts
|
|
1253
|
-
function
|
|
1254
|
-
return
|
|
1253
|
+
function er(e) {
|
|
1254
|
+
return $n(e);
|
|
1255
1255
|
}
|
|
1256
|
-
function
|
|
1257
|
-
return
|
|
1256
|
+
function tr(e, t) {
|
|
1257
|
+
return K(er(e), t);
|
|
1258
1258
|
}
|
|
1259
1259
|
//#endregion
|
|
1260
1260
|
//#region src/editor/managers/ExportManager.ts
|
|
1261
|
-
var
|
|
1261
|
+
var nr = class {
|
|
1262
1262
|
editor;
|
|
1263
1263
|
constructor(e) {
|
|
1264
1264
|
this.editor = e;
|
|
@@ -1267,16 +1267,16 @@ var rr = class {
|
|
|
1267
1267
|
return ve(this.editor.pmSchema, this.editor).exportBlocks(e, {});
|
|
1268
1268
|
}
|
|
1269
1269
|
blocksToFullHTML(e = this.editor.document) {
|
|
1270
|
-
return
|
|
1270
|
+
return Mt(this.editor.pmSchema, this.editor).serializeBlocks(e, {});
|
|
1271
1271
|
}
|
|
1272
1272
|
tryParseHTMLToBlocks(e) {
|
|
1273
|
-
return
|
|
1273
|
+
return K(e, this.editor.pmSchema);
|
|
1274
1274
|
}
|
|
1275
1275
|
blocksToMarkdownLossy(e = this.editor.document) {
|
|
1276
1276
|
return Te(e, this.editor.pmSchema, this.editor, {});
|
|
1277
1277
|
}
|
|
1278
1278
|
tryParseMarkdownToBlocks(e) {
|
|
1279
|
-
return
|
|
1279
|
+
return tr(e, this.editor.pmSchema);
|
|
1280
1280
|
}
|
|
1281
1281
|
pasteHTML(e, t = !1) {
|
|
1282
1282
|
let n = e;
|
|
@@ -1290,42 +1290,42 @@ var rr = class {
|
|
|
1290
1290
|
return this.editor.prosemirrorView?.pasteText(e);
|
|
1291
1291
|
}
|
|
1292
1292
|
pasteMarkdown(e) {
|
|
1293
|
-
let t =
|
|
1293
|
+
let t = er(e);
|
|
1294
1294
|
return this.pasteHTML(t);
|
|
1295
1295
|
}
|
|
1296
1296
|
};
|
|
1297
1297
|
//#endregion
|
|
1298
1298
|
//#region src/api/blockManipulation/selections/textCursorPosition.ts
|
|
1299
|
-
function
|
|
1300
|
-
let { bnBlock: t } =
|
|
1299
|
+
function rr(e) {
|
|
1300
|
+
let { bnBlock: t } = S(e), n = e.doc.resolve(t.beforePos), r = n.nodeBefore, i = e.doc.resolve(t.afterPos).nodeAfter, a;
|
|
1301
1301
|
return n.depth > 1 && (a = n.node(), a.type.isInGroup("bnBlock") || (a = n.node(n.depth - 1))), {
|
|
1302
|
-
block:
|
|
1303
|
-
prevBlock: r === null ? void 0 :
|
|
1304
|
-
nextBlock: i === null ? void 0 :
|
|
1305
|
-
parentBlock: a === void 0 ? void 0 :
|
|
1302
|
+
block: T(t.node, e.doc),
|
|
1303
|
+
prevBlock: r === null ? void 0 : T(r, e.doc),
|
|
1304
|
+
nextBlock: i === null ? void 0 : T(i, e.doc),
|
|
1305
|
+
parentBlock: a === void 0 ? void 0 : T(a, e.doc)
|
|
1306
1306
|
};
|
|
1307
1307
|
}
|
|
1308
|
-
function
|
|
1309
|
-
let
|
|
1310
|
-
if (!
|
|
1311
|
-
let
|
|
1312
|
-
if (
|
|
1313
|
-
let
|
|
1314
|
-
if (
|
|
1315
|
-
|
|
1308
|
+
function ir(t, n, r = "start") {
|
|
1309
|
+
let i = typeof n == "string" ? n : n.id, a = b(t.doc), s = f(a), c = u(i, t.doc);
|
|
1310
|
+
if (!c) throw Error(`Block with ID ${i} not found`);
|
|
1311
|
+
let l = e(c), d = s.blockSchema[l.blockNoteType].content;
|
|
1312
|
+
if (l.isBlockContainer) {
|
|
1313
|
+
let e = l.blockContent;
|
|
1314
|
+
if (d === "none") {
|
|
1315
|
+
t.setSelection(M.create(t.doc, e.beforePos));
|
|
1316
1316
|
return;
|
|
1317
1317
|
}
|
|
1318
|
-
if (
|
|
1319
|
-
else if (
|
|
1320
|
-
else throw new
|
|
1318
|
+
if (d === "inline" || d === "plain") r === "start" ? t.setSelection(P.create(t.doc, e.beforePos + 1)) : t.setSelection(P.create(t.doc, e.afterPos - 1));
|
|
1319
|
+
else if (d === "table") r === "start" ? t.setSelection(P.create(t.doc, e.beforePos + 4)) : t.setSelection(P.create(t.doc, e.afterPos - 4));
|
|
1320
|
+
else throw new o(d);
|
|
1321
1321
|
} else {
|
|
1322
|
-
let
|
|
1323
|
-
|
|
1322
|
+
let e = r === "start" ? l.childContainer.node.firstChild : l.childContainer.node.lastChild;
|
|
1323
|
+
ir(t, v(e, t.doc), r);
|
|
1324
1324
|
}
|
|
1325
1325
|
}
|
|
1326
1326
|
//#endregion
|
|
1327
1327
|
//#region src/api/clipboard/fromClipboard/acceptedMIMETypes.ts
|
|
1328
|
-
var
|
|
1328
|
+
var ar = [
|
|
1329
1329
|
"vscode-editor-data",
|
|
1330
1330
|
"blocknote/html",
|
|
1331
1331
|
"text/markdown",
|
|
@@ -1357,7 +1357,7 @@ async function lr(e, t) {
|
|
|
1357
1357
|
let n = "dataTransfer" in e ? e.dataTransfer : e.clipboardData;
|
|
1358
1358
|
if (n === null) return;
|
|
1359
1359
|
let r = null;
|
|
1360
|
-
for (let e of
|
|
1360
|
+
for (let e of ar) if (n.types.includes(e)) {
|
|
1361
1361
|
r = e;
|
|
1362
1362
|
break;
|
|
1363
1363
|
}
|
|
@@ -1390,7 +1390,7 @@ async function lr(e, t) {
|
|
|
1390
1390
|
}, a = t.prosemirrorView.posAtCoords(r);
|
|
1391
1391
|
if (!a) return;
|
|
1392
1392
|
i = t.transact((e) => {
|
|
1393
|
-
let i =
|
|
1393
|
+
let i = ae(e, a.pos), o = v(i.bnBlock.node, e.doc), s = (t.domElement?.querySelector(`[data-id="${o}"]`))?.getBoundingClientRect(), c = t.getBlock(o);
|
|
1394
1394
|
if (c) return cr(t, c, n, s && (s.top + s.bottom) / 2 > r.top ? "before" : "after");
|
|
1395
1395
|
});
|
|
1396
1396
|
} else return;
|
|
@@ -1406,10 +1406,10 @@ async function lr(e, t) {
|
|
|
1406
1406
|
var ur = (e) => k.create({
|
|
1407
1407
|
name: "dropFile",
|
|
1408
1408
|
addProseMirrorPlugins() {
|
|
1409
|
-
return [new
|
|
1409
|
+
return [new N({ props: { handleDOMEvents: { drop(t, n) {
|
|
1410
1410
|
if (!e.isEditable) return;
|
|
1411
1411
|
let r = null;
|
|
1412
|
-
for (let e of
|
|
1412
|
+
for (let e of ar) if (n.dataTransfer.types.includes(e)) {
|
|
1413
1413
|
r = e;
|
|
1414
1414
|
break;
|
|
1415
1415
|
}
|
|
@@ -1435,7 +1435,7 @@ function Er({ event: e, editor: t, prioritizeMarkdownOverHTML: n, plainTextAsMar
|
|
|
1435
1435
|
if (n) return t.pasteText(n), !0;
|
|
1436
1436
|
}
|
|
1437
1437
|
let i;
|
|
1438
|
-
for (let t of
|
|
1438
|
+
for (let t of ar) if (e.clipboardData.types.includes(t)) {
|
|
1439
1439
|
i = t;
|
|
1440
1440
|
break;
|
|
1441
1441
|
}
|
|
@@ -1457,7 +1457,7 @@ function Er({ event: e, editor: t, prioritizeMarkdownOverHTML: n, plainTextAsMar
|
|
|
1457
1457
|
var Dr = (e, t) => k.create({
|
|
1458
1458
|
name: "pasteFromClipboard",
|
|
1459
1459
|
addProseMirrorPlugins() {
|
|
1460
|
-
return [new
|
|
1460
|
+
return [new N({ props: { handleDOMEvents: { paste(n, r) {
|
|
1461
1461
|
if (r.preventDefault(), e.isEditable) return t({
|
|
1462
1462
|
event: r,
|
|
1463
1463
|
editor: e,
|
|
@@ -1473,29 +1473,29 @@ var Dr = (e, t) => k.create({
|
|
|
1473
1473
|
});
|
|
1474
1474
|
//#endregion
|
|
1475
1475
|
//#region src/api/clipboard/toClipboard/copyExtension.ts
|
|
1476
|
-
function Or(e,
|
|
1477
|
-
let
|
|
1478
|
-
if (!
|
|
1479
|
-
let
|
|
1480
|
-
for (let e = 0; e <
|
|
1481
|
-
|
|
1482
|
-
}
|
|
1483
|
-
let
|
|
1484
|
-
if (
|
|
1485
|
-
|
|
1486
|
-
let e = t
|
|
1487
|
-
|
|
1488
|
-
} else if (
|
|
1489
|
-
let e =
|
|
1490
|
-
|
|
1476
|
+
function Or(e, t, n) {
|
|
1477
|
+
let r = !1, i = e.state.selection instanceof ot;
|
|
1478
|
+
if (!i) {
|
|
1479
|
+
let n = e.state.doc.slice(e.state.selection.from, e.state.selection.to, !1).content, i = [];
|
|
1480
|
+
for (let e = 0; e < n.childCount; e++) i.push(n.child(e));
|
|
1481
|
+
r = i.find((e) => e.type.isInGroup("bnBlock") || e.type.name === "blockGroup" || e.type.spec.group === "blockContent") === void 0, r && (t = n);
|
|
1482
|
+
}
|
|
1483
|
+
let a, o = ve(e.state.schema, n);
|
|
1484
|
+
if (i) {
|
|
1485
|
+
t.firstChild?.type.name === "table" && (t = t.firstChild.content);
|
|
1486
|
+
let e = h(t, n.schema.inlineContentSchema, n.schema.styleSchema);
|
|
1487
|
+
a = `<table>${o.exportInlineContent(e, {})}</table>`;
|
|
1488
|
+
} else if (r) {
|
|
1489
|
+
let e = fe(t, n.schema.inlineContentSchema, n.schema.styleSchema);
|
|
1490
|
+
a = o.exportInlineContent(e, {});
|
|
1491
1491
|
} else {
|
|
1492
|
-
let e = Pe(
|
|
1493
|
-
|
|
1492
|
+
let e = Pe(t);
|
|
1493
|
+
a = o.exportBlocks(e, {});
|
|
1494
1494
|
}
|
|
1495
|
-
return
|
|
1495
|
+
return a;
|
|
1496
1496
|
}
|
|
1497
1497
|
function kr(e, t) {
|
|
1498
|
-
"node" in e.state.selection && e.state.selection.node.type.spec.group === "blockContent" && t.transact((t) => t.setSelection(new
|
|
1498
|
+
"node" in e.state.selection && e.state.selection.node.type.spec.group === "blockContent" && t.transact((t) => t.setSelection(new M(t.doc.resolve(e.state.selection.from - 1))));
|
|
1499
1499
|
let n = e.serializeForClipboard(e.state.selection.content()).dom.innerHTML, r = e.state.selection.content().content, i = Or(e, r, t), { $from: a, $to: o } = e.state.selection, s = a.parent.type.name, c = t.blockImplementations[s];
|
|
1500
1500
|
return {
|
|
1501
1501
|
clipboardHTML: n,
|
|
@@ -1521,7 +1521,7 @@ var Ar = (e) => {
|
|
|
1521
1521
|
}, Mr = (e) => k.create({
|
|
1522
1522
|
name: "copyToClipboard",
|
|
1523
1523
|
addProseMirrorPlugins() {
|
|
1524
|
-
return [new
|
|
1524
|
+
return [new N({ props: { handleDOMEvents: {
|
|
1525
1525
|
copy(t, n) {
|
|
1526
1526
|
return Ar(t) || jr(e, t, n), !0;
|
|
1527
1527
|
},
|
|
@@ -1530,7 +1530,7 @@ var Ar = (e) => {
|
|
|
1530
1530
|
},
|
|
1531
1531
|
dragstart(t, n) {
|
|
1532
1532
|
if (!("node" in t.state.selection) || t.state.selection.node.type.spec.group !== "blockContent") return;
|
|
1533
|
-
e.transact((e) => e.setSelection(new
|
|
1533
|
+
e.transact((e) => e.setSelection(new M(e.doc.resolve(t.state.selection.from - 1)))), n.preventDefault(), n.dataTransfer.clearData();
|
|
1534
1534
|
let { clipboardHTML: r, externalHTML: i, markdown: a } = kr(t, e);
|
|
1535
1535
|
return n.dataTransfer.setData("blocknote/html", r), n.dataTransfer.setData("text/html", i), n.dataTransfer.setData("text/plain", a), !0;
|
|
1536
1536
|
}
|
|
@@ -1541,7 +1541,7 @@ var Ar = (e) => {
|
|
|
1541
1541
|
addGlobalAttributes() {
|
|
1542
1542
|
return [{
|
|
1543
1543
|
types: ["tableCell", "tableHeader"],
|
|
1544
|
-
attributes: { backgroundColor:
|
|
1544
|
+
attributes: { backgroundColor: r() }
|
|
1545
1545
|
}];
|
|
1546
1546
|
}
|
|
1547
1547
|
}), Pr = A.create({
|
|
@@ -1555,7 +1555,7 @@ var Ar = (e) => {
|
|
|
1555
1555
|
return [{ tag: "br" }];
|
|
1556
1556
|
},
|
|
1557
1557
|
renderHTML({ HTMLAttributes: e }) {
|
|
1558
|
-
return ["br",
|
|
1558
|
+
return ["br", nt(this.options.HTMLAttributes, e)];
|
|
1559
1559
|
},
|
|
1560
1560
|
renderText() {
|
|
1561
1561
|
return "\n";
|
|
@@ -1564,21 +1564,21 @@ var Ar = (e) => {
|
|
|
1564
1564
|
let n = e.resolve(t), r = n.depth - 1;
|
|
1565
1565
|
if (r < 1) return;
|
|
1566
1566
|
let i = n.before(r), a = e.resolve(i).nodeAfter;
|
|
1567
|
-
if (a) return a.type.spec.group?.includes("bnBlock") ?
|
|
1567
|
+
if (a) return a.type.spec.group?.includes("bnBlock") ? w(e.resolve(i)) : Fr(e, i);
|
|
1568
1568
|
}, Z = (e, t) => {
|
|
1569
1569
|
let n = e.resolve(t), r = n.index();
|
|
1570
1570
|
if (r === 0) return;
|
|
1571
1571
|
let i = n.posAtIndex(r - 1);
|
|
1572
|
-
return
|
|
1572
|
+
return w(e.resolve(i));
|
|
1573
1573
|
}, Q = (e, t) => {
|
|
1574
1574
|
let n = e.resolve(t), r = n.index();
|
|
1575
1575
|
if (r === n.node().childCount - 1) return;
|
|
1576
1576
|
let i = n.posAtIndex(r + 1);
|
|
1577
|
-
return
|
|
1577
|
+
return w(e.resolve(i));
|
|
1578
1578
|
}, Ir = (e, t) => {
|
|
1579
1579
|
for (; t.childContainer;) {
|
|
1580
1580
|
let n = t.childContainer.node, r = e.resolve(t.childContainer.beforePos + 1).posAtIndex(n.childCount - 1);
|
|
1581
|
-
t =
|
|
1581
|
+
t = w(e.resolve(r));
|
|
1582
1582
|
}
|
|
1583
1583
|
return t;
|
|
1584
1584
|
}, Lr = (e, t) => e.isBlockContainer && e.blockContent.node.type.spec.content === "inline*" && e.blockContent.node.childCount > 0 && t.isBlockContainer && t.blockContent.node.type.spec.content === "inline*", Rr = (e, t, n, r) => {
|
|
@@ -1596,7 +1596,7 @@ var Ar = (e) => {
|
|
|
1596
1596
|
}
|
|
1597
1597
|
return !0;
|
|
1598
1598
|
}, zr = (e) => ({ state: t, dispatch: n }) => {
|
|
1599
|
-
let r = t.doc.resolve(e), i =
|
|
1599
|
+
let r = t.doc.resolve(e), i = w(r), a = Z(t.doc, i.bnBlock.beforePos);
|
|
1600
1600
|
if (!a) return !1;
|
|
1601
1601
|
let o = Ir(t.doc, a);
|
|
1602
1602
|
return Lr(o, i) ? Rr(t, n, o, i) : !1;
|
|
@@ -1607,22 +1607,22 @@ var Ar = (e) => {
|
|
|
1607
1607
|
() => t.deleteSelection(),
|
|
1608
1608
|
() => t.undoInputRule(),
|
|
1609
1609
|
() => t.command(({ state: e }) => {
|
|
1610
|
-
let n =
|
|
1610
|
+
let n = S(e);
|
|
1611
1611
|
if (!n.isBlockContainer) return !1;
|
|
1612
1612
|
let r = e.selection.from === n.blockContent.beforePos + 1, i = n.blockContent.node.type.name === "paragraph";
|
|
1613
|
-
return r && !i ? t.command(
|
|
1613
|
+
return r && !i ? t.command(ue(n.bnBlock.beforePos, {
|
|
1614
1614
|
type: "paragraph",
|
|
1615
1615
|
props: {}
|
|
1616
1616
|
})) : !1;
|
|
1617
1617
|
}),
|
|
1618
1618
|
() => t.command(({ state: e, tr: t }) => {
|
|
1619
|
-
let n =
|
|
1619
|
+
let n = S(e);
|
|
1620
1620
|
if (!n.isBlockContainer) return !1;
|
|
1621
1621
|
let { blockContent: r } = n;
|
|
1622
|
-
return e.selection.from === r.beforePos + 1 &&
|
|
1622
|
+
return e.selection.from === r.beforePos + 1 && G(t, t.doc.type.schema.nodes.blockContainer, t.doc.type.schema.nodes.blockGroup);
|
|
1623
1623
|
}),
|
|
1624
1624
|
() => t.command(({ state: t }) => {
|
|
1625
|
-
let n =
|
|
1625
|
+
let n = S(t);
|
|
1626
1626
|
if (!n.isBlockContainer) return !1;
|
|
1627
1627
|
let { bnBlock: r, blockContent: i } = n, a = Z(t.doc, n.bnBlock.beforePos);
|
|
1628
1628
|
if (!a || !a.isBlockContainer || a.blockContent.node.type.spec.content !== "inline*") return !1;
|
|
@@ -1630,26 +1630,26 @@ var Ar = (e) => {
|
|
|
1630
1630
|
return o && s ? e().command(zr(c)).scrollIntoView().run() : !1;
|
|
1631
1631
|
}),
|
|
1632
1632
|
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1633
|
-
let r =
|
|
1633
|
+
let r = S(e);
|
|
1634
1634
|
if (!r.isBlockContainer || e.selection.from !== r.blockContent.beforePos + 1) return !1;
|
|
1635
1635
|
let i = Z(e.doc, r.bnBlock.beforePos);
|
|
1636
1636
|
if (!i || i.isBlockContainer) return !1;
|
|
1637
1637
|
if (n) {
|
|
1638
1638
|
let e = i.bnBlock.afterPos - 1, n = t.doc.resolve(e - 1);
|
|
1639
|
-
return t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), t.insert(n.pos, r.bnBlock.node), t.setSelection(
|
|
1639
|
+
return t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), t.insert(n.pos, r.bnBlock.node), t.setSelection(P.near(t.doc.resolve(n.pos + 1))), !0;
|
|
1640
1640
|
}
|
|
1641
1641
|
return !1;
|
|
1642
1642
|
}),
|
|
1643
1643
|
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1644
|
-
let r =
|
|
1644
|
+
let r = S(e);
|
|
1645
1645
|
if (!r.isBlockContainer || t.selection.from !== r.blockContent.beforePos + 1) return !1;
|
|
1646
1646
|
let i = t.doc.resolve(r.bnBlock.beforePos);
|
|
1647
1647
|
if (i.nodeBefore || i.node().type.name !== "column") return !1;
|
|
1648
1648
|
let a = t.doc.resolve(r.bnBlock.beforePos), o = t.doc.resolve(a.before()), s = o.before();
|
|
1649
|
-
return n && (t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos),
|
|
1649
|
+
return n && (t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), B(t, s), o.pos === s + 1 ? (t.insert(s, r.bnBlock.node), t.setSelection(P.near(t.doc.resolve(s)))) : (t.insert(o.pos - 1, r.bnBlock.node), t.setSelection(P.near(t.doc.resolve(o.pos))))), !0;
|
|
1650
1650
|
}),
|
|
1651
1651
|
() => t.command(({ state: t }) => {
|
|
1652
|
-
let n =
|
|
1652
|
+
let n = S(t);
|
|
1653
1653
|
if (!n.isBlockContainer) return !1;
|
|
1654
1654
|
if (n.blockContent.node.childCount === 0 && n.blockContent.node.type.spec.content === "inline*") {
|
|
1655
1655
|
let r = Z(t.doc, n.bnBlock.beforePos);
|
|
@@ -1673,7 +1673,7 @@ var Ar = (e) => {
|
|
|
1673
1673
|
return !1;
|
|
1674
1674
|
}),
|
|
1675
1675
|
() => t.command(({ state: t }) => {
|
|
1676
|
-
let n =
|
|
1676
|
+
let n = S(t);
|
|
1677
1677
|
if (!n.isBlockContainer) return !1;
|
|
1678
1678
|
let r = t.selection.from === n.blockContent.beforePos + 1, i = t.selection.empty, a = Z(t.doc, n.bnBlock.beforePos);
|
|
1679
1679
|
if (a && r && i) {
|
|
@@ -1692,9 +1692,9 @@ var Ar = (e) => {
|
|
|
1692
1692
|
]), t = () => this.editor.commands.first(({ chain: e, commands: t }) => [
|
|
1693
1693
|
() => t.deleteSelection(),
|
|
1694
1694
|
() => t.command(({ state: t }) => {
|
|
1695
|
-
let n =
|
|
1695
|
+
let n = S(t);
|
|
1696
1696
|
if (!n.isBlockContainer || !n.childContainer) return !1;
|
|
1697
|
-
let { blockContent: r, childContainer: i } = n, a = t.selection.from === r.afterPos - 1, o = t.selection.empty, s =
|
|
1697
|
+
let { blockContent: r, childContainer: i } = n, a = t.selection.from === r.afterPos - 1, o = t.selection.empty, s = w(t.doc.resolve(i.beforePos + 1));
|
|
1698
1698
|
if (!s.isBlockContainer) return !1;
|
|
1699
1699
|
if (a && o) {
|
|
1700
1700
|
let n = s.blockContent.node, a = n.type.spec.content === "inline*", o = r.node.type.spec.content === "inline*";
|
|
@@ -1709,7 +1709,7 @@ var Ar = (e) => {
|
|
|
1709
1709
|
return !1;
|
|
1710
1710
|
}),
|
|
1711
1711
|
() => t.command(({ state: t }) => {
|
|
1712
|
-
let n =
|
|
1712
|
+
let n = S(t);
|
|
1713
1713
|
if (!n.isBlockContainer) return !1;
|
|
1714
1714
|
let { bnBlock: r, blockContent: i } = n, a = Q(t.doc, n.bnBlock.beforePos);
|
|
1715
1715
|
if (!a || !a.isBlockContainer) return !1;
|
|
@@ -1717,30 +1717,30 @@ var Ar = (e) => {
|
|
|
1717
1717
|
return o && s ? e().command(zr(c)).scrollIntoView().run() : !1;
|
|
1718
1718
|
}),
|
|
1719
1719
|
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1720
|
-
let r =
|
|
1720
|
+
let r = S(e);
|
|
1721
1721
|
if (!r.isBlockContainer || e.selection.from !== r.blockContent.afterPos - 1) return !1;
|
|
1722
1722
|
let i = Q(e.doc, r.bnBlock.beforePos);
|
|
1723
1723
|
if (!i || i.isBlockContainer) return !1;
|
|
1724
1724
|
if (n) {
|
|
1725
1725
|
let e = i.bnBlock.beforePos + 1, n = t.doc.resolve(e + 1);
|
|
1726
|
-
return t.delete(n.pos, n.pos + n.nodeAfter.nodeSize),
|
|
1726
|
+
return t.delete(n.pos, n.pos + n.nodeAfter.nodeSize), B(t, i.bnBlock.beforePos), t.insert(r.bnBlock.afterPos, n.nodeAfter), t.setSelection(P.near(t.doc.resolve(n.pos))), !0;
|
|
1727
1727
|
}
|
|
1728
1728
|
return !1;
|
|
1729
1729
|
}),
|
|
1730
1730
|
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1731
|
-
let r =
|
|
1731
|
+
let r = S(e);
|
|
1732
1732
|
if (!r.isBlockContainer || t.selection.from !== r.blockContent.afterPos - 1) return !1;
|
|
1733
1733
|
let i = t.doc.resolve(r.bnBlock.afterPos);
|
|
1734
1734
|
if (i.nodeAfter || i.node().type.name !== "column") return !1;
|
|
1735
1735
|
let a = t.doc.resolve(r.bnBlock.afterPos), o = t.doc.resolve(a.after()), s = o.after();
|
|
1736
1736
|
if (n) {
|
|
1737
|
-
let e = o.pos === s - 1 ? s : o.pos + 1, n =
|
|
1738
|
-
t.delete(n.bnBlock.beforePos, n.bnBlock.afterPos),
|
|
1737
|
+
let e = o.pos === s - 1 ? s : o.pos + 1, n = w(t.doc.resolve(e));
|
|
1738
|
+
t.delete(n.bnBlock.beforePos, n.bnBlock.afterPos), B(t, s - o.node().nodeSize), t.insert(a.pos, n.bnBlock.node), t.setSelection(P.near(t.doc.resolve(e)));
|
|
1739
1739
|
}
|
|
1740
1740
|
return !0;
|
|
1741
1741
|
}),
|
|
1742
1742
|
() => t.command(({ state: t }) => {
|
|
1743
|
-
let n =
|
|
1743
|
+
let n = S(t);
|
|
1744
1744
|
if (!n.isBlockContainer) return !1;
|
|
1745
1745
|
let { blockContent: r } = n, i = t.selection.from === r.afterPos - 1, a = t.selection.empty;
|
|
1746
1746
|
if (i && a) {
|
|
@@ -1760,7 +1760,7 @@ var Ar = (e) => {
|
|
|
1760
1760
|
return !1;
|
|
1761
1761
|
}),
|
|
1762
1762
|
() => t.command(({ state: t }) => {
|
|
1763
|
-
let n =
|
|
1763
|
+
let n = S(t);
|
|
1764
1764
|
if (!n.isBlockContainer) return !1;
|
|
1765
1765
|
if (n.blockContent.node.childCount === 0 && n.blockContent.node.type.spec.content === "inline*") {
|
|
1766
1766
|
let r = Q(t.doc, n.bnBlock.beforePos);
|
|
@@ -1778,7 +1778,7 @@ var Ar = (e) => {
|
|
|
1778
1778
|
return !1;
|
|
1779
1779
|
}),
|
|
1780
1780
|
() => t.command(({ state: t }) => {
|
|
1781
|
-
let n =
|
|
1781
|
+
let n = S(t);
|
|
1782
1782
|
if (!n.isBlockContainer) return !1;
|
|
1783
1783
|
let r = t.selection.from === n.blockContent.afterPos - 1, i = t.selection.empty, a = Q(t.doc, n.bnBlock.beforePos);
|
|
1784
1784
|
if (!a || !a.isBlockContainer) return !1;
|
|
@@ -1793,13 +1793,13 @@ var Ar = (e) => {
|
|
|
1793
1793
|
})
|
|
1794
1794
|
]), n = (e = !1) => this.editor.commands.first(({ commands: t, tr: n }) => [
|
|
1795
1795
|
() => t.command(({ state: e, tr: t }) => {
|
|
1796
|
-
let n =
|
|
1796
|
+
let n = S(e);
|
|
1797
1797
|
if (!n.isBlockContainer) return !1;
|
|
1798
1798
|
let { bnBlock: r, blockContent: i } = n, { depth: a } = e.doc.resolve(r.beforePos), o = e.selection.$anchor.parentOffset === 0, s = e.selection.anchor === e.selection.head, c = i.node.childCount === 0;
|
|
1799
|
-
return o && s && c && a > 1 ?
|
|
1799
|
+
return o && s && c && a > 1 ? G(t, t.doc.type.schema.nodes.blockContainer, t.doc.type.schema.nodes.blockGroup) : !1;
|
|
1800
1800
|
}),
|
|
1801
1801
|
() => t.command(({ state: t }) => {
|
|
1802
|
-
let r =
|
|
1802
|
+
let r = S(t), i = this.options.editor.schema.blockSpecs[r.blockNoteType], a = i?.implementation?.meta?.hardBreakShortcut ?? "shift+enter";
|
|
1803
1803
|
if (a === "none") return !1;
|
|
1804
1804
|
if (a === "shift+enter" && e || a === "enter") {
|
|
1805
1805
|
if (i?.config?.content === "plain") return n.insertText("\n", n.selection.head), !0;
|
|
@@ -1809,24 +1809,24 @@ var Ar = (e) => {
|
|
|
1809
1809
|
return !1;
|
|
1810
1810
|
}),
|
|
1811
1811
|
() => t.command(({ state: e, dispatch: t, tr: n }) => {
|
|
1812
|
-
let r =
|
|
1812
|
+
let r = S(e);
|
|
1813
1813
|
if (!r.isBlockContainer) return !1;
|
|
1814
1814
|
let { bnBlock: i, blockContent: a } = r, o = e.selection.$anchor.parentOffset === 0, s = e.selection.anchor === e.selection.head, c = a.node.childCount === 0;
|
|
1815
1815
|
if (o && s && c) {
|
|
1816
1816
|
let a = i.afterPos, o = a + 2;
|
|
1817
1817
|
if (t) {
|
|
1818
1818
|
let t = e.schema.nodes.blockContainer.createAndFill(void 0, [e.schema.nodes.paragraph.createAndFill() || void 0, r.childContainer?.node].filter((e) => e !== void 0));
|
|
1819
|
-
n.insert(a, t).setSelection(new
|
|
1819
|
+
n.insert(a, t).setSelection(new P(n.doc.resolve(o))).scrollIntoView(), r.childContainer && n.delete(r.childContainer.beforePos, r.childContainer.afterPos);
|
|
1820
1820
|
}
|
|
1821
1821
|
return !0;
|
|
1822
1822
|
}
|
|
1823
1823
|
return !1;
|
|
1824
1824
|
}),
|
|
1825
1825
|
() => t.command(({ state: e, chain: t }) => {
|
|
1826
|
-
let n =
|
|
1826
|
+
let n = S(e);
|
|
1827
1827
|
if (!n.isBlockContainer) return !1;
|
|
1828
1828
|
let { blockContent: r } = n, i = e.selection.$anchor.parentOffset === 0;
|
|
1829
|
-
return r.node.childCount !== 0 && (t().deleteSelection().command(
|
|
1829
|
+
return r.node.childCount !== 0 && (t().deleteSelection().command(te(e.selection.from, i, i)).scrollIntoView().run(), !0);
|
|
1830
1830
|
})
|
|
1831
1831
|
]);
|
|
1832
1832
|
return {
|
|
@@ -1834,8 +1834,8 @@ var Ar = (e) => {
|
|
|
1834
1834
|
Delete: t,
|
|
1835
1835
|
Enter: () => n(),
|
|
1836
1836
|
"Shift-Enter": () => n(!0),
|
|
1837
|
-
Tab: () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(x)?.store.state || this.options.editor.getExtension(
|
|
1838
|
-
"Shift-Tab": () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(x)?.store.state || this.options.editor.getExtension(
|
|
1837
|
+
Tab: () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(x)?.store.state || this.options.editor.getExtension(y)?.store.state !== void 0) ? !1 : Jt(this.options.editor),
|
|
1838
|
+
"Shift-Tab": () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(x)?.store.state || this.options.editor.getExtension(y)?.store.state !== void 0) ? !1 : Xt(this.options.editor),
|
|
1839
1839
|
"Shift-Mod-ArrowUp": () => (this.options.editor.moveBlocksUp(), !0),
|
|
1840
1840
|
"Shift-Mod-ArrowDown": () => (this.options.editor.moveBlocksDown(), !0),
|
|
1841
1841
|
"Mod-z": () => this.options.editor.undo(),
|
|
@@ -1864,7 +1864,7 @@ var Ar = (e) => {
|
|
|
1864
1864
|
"tableCell",
|
|
1865
1865
|
"tableHeader"
|
|
1866
1866
|
],
|
|
1867
|
-
attributes: { textColor:
|
|
1867
|
+
attributes: { textColor: _() }
|
|
1868
1868
|
}];
|
|
1869
1869
|
}
|
|
1870
1870
|
}), Ur = "aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2";
|
|
@@ -2029,8 +2029,8 @@ function di(e) {
|
|
|
2029
2029
|
return e.length === 1 ? e[0].isLink : e.length === 3 && e[1].isLink ? ["()", "[]"].includes(e[0].value + e[2].value) : !1;
|
|
2030
2030
|
}
|
|
2031
2031
|
function fi(e) {
|
|
2032
|
-
return new
|
|
2033
|
-
key: new
|
|
2032
|
+
return new L({
|
|
2033
|
+
key: new R("autolink"),
|
|
2034
2034
|
appendTransaction: (t, n, r) => {
|
|
2035
2035
|
let i = t.some((e) => e.docChanged) && !n.doc.eq(r.doc), a = t.some((e) => e.getMeta("preventAutolink"));
|
|
2036
2036
|
if (!i || a) return;
|
|
@@ -2065,8 +2065,8 @@ function fi(e) {
|
|
|
2065
2065
|
//#endregion
|
|
2066
2066
|
//#region src/extensions/tiptap-extensions/Link/helpers/clickHandler.ts
|
|
2067
2067
|
function pi(e) {
|
|
2068
|
-
return new
|
|
2069
|
-
key: new
|
|
2068
|
+
return new L({
|
|
2069
|
+
key: new R("handleClickLink"),
|
|
2070
2070
|
props: { handleClick: (t, n, r) => {
|
|
2071
2071
|
if (r.button !== 0 || !t.editable) return !1;
|
|
2072
2072
|
let i = null;
|
|
@@ -2090,8 +2090,8 @@ function pi(e) {
|
|
|
2090
2090
|
//#endregion
|
|
2091
2091
|
//#region src/extensions/tiptap-extensions/Link/helpers/pasteHandler.ts
|
|
2092
2092
|
function mi(e) {
|
|
2093
|
-
return new
|
|
2094
|
-
key: new
|
|
2093
|
+
return new L({
|
|
2094
|
+
key: new R("handlePasteLink"),
|
|
2095
2095
|
props: { handlePaste: (t, n, r) => {
|
|
2096
2096
|
let { shouldAutoLink: i, isValidLink: a } = e, { state: o } = t, { selection: s } = o, { empty: c } = s;
|
|
2097
2097
|
if (c) return !1;
|
|
@@ -2157,11 +2157,11 @@ var yi = We.create({
|
|
|
2157
2157
|
renderHTML({ HTMLAttributes: e }) {
|
|
2158
2158
|
return this.options.isValidLink(e.href) ? [
|
|
2159
2159
|
"a",
|
|
2160
|
-
|
|
2160
|
+
nt(e, this.options.HTMLAttributes),
|
|
2161
2161
|
0
|
|
2162
2162
|
] : [
|
|
2163
2163
|
"a",
|
|
2164
|
-
|
|
2164
|
+
nt({
|
|
2165
2165
|
...e,
|
|
2166
2166
|
href: ""
|
|
2167
2167
|
}, this.options.HTMLAttributes),
|
|
@@ -2228,7 +2228,7 @@ var yi = We.create({
|
|
|
2228
2228
|
priority: 50,
|
|
2229
2229
|
defining: !0,
|
|
2230
2230
|
marks() {
|
|
2231
|
-
return
|
|
2231
|
+
return d(this.editor);
|
|
2232
2232
|
},
|
|
2233
2233
|
parseHTML() {
|
|
2234
2234
|
return [{
|
|
@@ -2252,7 +2252,7 @@ var yi = We.create({
|
|
|
2252
2252
|
...this.options.domAttributes?.block || {},
|
|
2253
2253
|
...e
|
|
2254
2254
|
}, r = document.createElement("div");
|
|
2255
|
-
r.className =
|
|
2255
|
+
r.className = ee("bn-block", n.class), r.setAttribute("data-node-type", this.name);
|
|
2256
2256
|
for (let [e, t] of Object.entries(n)) e !== "class" && r.setAttribute(e, t);
|
|
2257
2257
|
return t.appendChild(r), {
|
|
2258
2258
|
dom: t,
|
|
@@ -2264,7 +2264,7 @@ var yi = We.create({
|
|
|
2264
2264
|
group: "childContainer",
|
|
2265
2265
|
content: "blockGroupChild+",
|
|
2266
2266
|
marks() {
|
|
2267
|
-
return
|
|
2267
|
+
return d(this.editor);
|
|
2268
2268
|
},
|
|
2269
2269
|
parseHTML() {
|
|
2270
2270
|
return [{
|
|
@@ -2277,7 +2277,7 @@ var yi = We.create({
|
|
|
2277
2277
|
...this.options.domAttributes?.blockGroup || {},
|
|
2278
2278
|
...e
|
|
2279
2279
|
}, n = document.createElement("div");
|
|
2280
|
-
n.className =
|
|
2280
|
+
n.className = ee("bn-block-group", t.class), n.setAttribute("data-node-type", "blockGroup");
|
|
2281
2281
|
for (let [e, r] of Object.entries(t)) e !== "class" && n.setAttribute(e, r);
|
|
2282
2282
|
return {
|
|
2283
2283
|
dom: n,
|
|
@@ -2289,63 +2289,63 @@ var yi = We.create({
|
|
|
2289
2289
|
topNode: !0,
|
|
2290
2290
|
content: "blockGroup",
|
|
2291
2291
|
marks() {
|
|
2292
|
-
return
|
|
2292
|
+
return d(this.editor);
|
|
2293
2293
|
}
|
|
2294
2294
|
});
|
|
2295
2295
|
//#endregion
|
|
2296
2296
|
//#region src/editor/managers/ExtensionManager/extensions.ts
|
|
2297
|
-
function Ti(
|
|
2297
|
+
function Ti(e, t) {
|
|
2298
2298
|
return [
|
|
2299
2299
|
j.ClipboardTextSerializer,
|
|
2300
2300
|
j.Commands,
|
|
2301
2301
|
j.Editable,
|
|
2302
2302
|
j.FocusEvents,
|
|
2303
2303
|
j.Tabindex,
|
|
2304
|
-
|
|
2305
|
-
|
|
2304
|
+
pt,
|
|
2305
|
+
m.configure({
|
|
2306
2306
|
types: [
|
|
2307
2307
|
"blockContainer",
|
|
2308
2308
|
"columnList",
|
|
2309
2309
|
"column"
|
|
2310
2310
|
],
|
|
2311
|
-
setIdAttribute:
|
|
2312
|
-
isWithinEditor:
|
|
2311
|
+
setIdAttribute: t.setIdAttribute,
|
|
2312
|
+
isWithinEditor: e.isWithinEditor
|
|
2313
2313
|
}),
|
|
2314
2314
|
Pr,
|
|
2315
|
-
|
|
2316
|
-
...Object.values(
|
|
2315
|
+
ft,
|
|
2316
|
+
...Object.values(e.schema.styleSpecs).map((t) => t.implementation.mark.configure({ editor: e })),
|
|
2317
2317
|
Hr,
|
|
2318
2318
|
Nr,
|
|
2319
2319
|
Vr,
|
|
2320
2320
|
k.create({
|
|
2321
2321
|
name: "OverrideEscape",
|
|
2322
|
-
addKeyboardShortcuts: () => ({ Escape: () => !
|
|
2322
|
+
addKeyboardShortcuts: () => ({ Escape: () => !e.getExtension(oe)?.shown() && (e.blur(), !0) })
|
|
2323
2323
|
}),
|
|
2324
2324
|
wi,
|
|
2325
2325
|
Si.configure({
|
|
2326
|
-
editor:
|
|
2327
|
-
domAttributes:
|
|
2326
|
+
editor: e,
|
|
2327
|
+
domAttributes: t.domAttributes
|
|
2328
2328
|
}),
|
|
2329
2329
|
Br.configure({
|
|
2330
|
-
editor:
|
|
2331
|
-
tabBehavior:
|
|
2330
|
+
editor: e,
|
|
2331
|
+
tabBehavior: t.tabBehavior
|
|
2332
2332
|
}),
|
|
2333
|
-
Ci.configure({ domAttributes:
|
|
2334
|
-
...Object.values(
|
|
2335
|
-
...Object.values(
|
|
2336
|
-
editor:
|
|
2337
|
-
domAttributes:
|
|
2333
|
+
Ci.configure({ domAttributes: t.domAttributes }),
|
|
2334
|
+
...Object.values(e.schema.inlineContentSpecs).filter((e) => e.config !== "link" && e.config !== "text").map((t) => t.implementation.node.configure({ editor: e })),
|
|
2335
|
+
...Object.values(e.schema.blockSpecs).flatMap((n) => [..."node" in n.implementation ? [n.implementation.node.configure({
|
|
2336
|
+
editor: e,
|
|
2337
|
+
domAttributes: t.domAttributes
|
|
2338
2338
|
})] : []]),
|
|
2339
|
-
Mr(
|
|
2340
|
-
Dr(
|
|
2341
|
-
ur(
|
|
2339
|
+
Mr(e),
|
|
2340
|
+
Dr(e, t.pasteHandler || ((e) => e.defaultPasteHandler())),
|
|
2341
|
+
ur(e)
|
|
2342
2342
|
];
|
|
2343
2343
|
}
|
|
2344
2344
|
function Ei(e, t) {
|
|
2345
2345
|
let n = [
|
|
2346
2346
|
be(),
|
|
2347
2347
|
ye(t),
|
|
2348
|
-
|
|
2348
|
+
y(t),
|
|
2349
2349
|
x(t),
|
|
2350
2350
|
bi({
|
|
2351
2351
|
HTMLAttributes: t.links?.HTMLAttributes ?? {},
|
|
@@ -2359,7 +2359,7 @@ function Ei(e, t) {
|
|
|
2359
2359
|
De(t),
|
|
2360
2360
|
Oe(),
|
|
2361
2361
|
Ae(),
|
|
2362
|
-
|
|
2362
|
+
oe(t),
|
|
2363
2363
|
ge(),
|
|
2364
2364
|
ke(),
|
|
2365
2365
|
_e(),
|
|
@@ -2462,7 +2462,7 @@ var Di = class {
|
|
|
2462
2462
|
this.editor.prosemirrorView.updateState(n);
|
|
2463
2463
|
}
|
|
2464
2464
|
getTiptapExtensions() {
|
|
2465
|
-
let e = Ti(this.editor, this.options).filter((e) => !this.disabledExtensions.has(e.name)), t =
|
|
2465
|
+
let e = Ti(this.editor, this.options).filter((e) => !this.disabledExtensions.has(e.name)), t = ne(this.extensions.map((e) => {
|
|
2466
2466
|
let t = this.blockNoteExtensionDependents.get(e.key);
|
|
2467
2467
|
return t?.size ? {
|
|
2468
2468
|
key: e.key,
|
|
@@ -2485,8 +2485,8 @@ var Di = class {
|
|
|
2485
2485
|
Array.from(n.keys()).sort((e, t) => e - t).reverse().forEach((t) => {
|
|
2486
2486
|
e.push(...n.get(t));
|
|
2487
2487
|
});
|
|
2488
|
-
let t =
|
|
2489
|
-
return [t, new
|
|
2488
|
+
let t = ut({ rules: e });
|
|
2489
|
+
return [t, new N({ props: { handleKeyDown(e, n) {
|
|
2490
2490
|
if (n.key !== "Enter" || n.shiftKey || n.ctrlKey || n.metaKey || n.altKey) return !1;
|
|
2491
2491
|
let { $cursor: r } = e.state.selection;
|
|
2492
2492
|
return r ? !!t.props.handleTextInput?.call(t, e, r.pos, r.pos, "\n", () => e.state.tr.insertText("\n", r.pos, r.pos)) : !1;
|
|
@@ -2501,7 +2501,7 @@ var Di = class {
|
|
|
2501
2501
|
return !e.prosemirrorPlugins?.length && !Object.keys(e.keyboardShortcuts || {}).length && !e.inputRules?.length ? {
|
|
2502
2502
|
plugins: t,
|
|
2503
2503
|
inputRules: n
|
|
2504
|
-
} : (this.extensionPlugins.set(e, t), e.inputRules?.length && n.push(...e.inputRules.map((e) => new
|
|
2504
|
+
} : (this.extensionPlugins.set(e, t), e.inputRules?.length && n.push(...e.inputRules.map((e) => new lt(e.find, (t, n, r, i) => {
|
|
2505
2505
|
let a = e.replace({
|
|
2506
2506
|
match: n,
|
|
2507
2507
|
range: {
|
|
@@ -2511,11 +2511,11 @@ var Di = class {
|
|
|
2511
2511
|
editor: this.editor
|
|
2512
2512
|
});
|
|
2513
2513
|
if (a) {
|
|
2514
|
-
let e = t.tr, n =
|
|
2515
|
-
return !n.isBlockContainer || this.editor.schema.blockSchema[n.blockNoteType]?.content !== "inline" ? null : (e.deleteRange(r, i),
|
|
2514
|
+
let e = t.tr, n = S(e);
|
|
2515
|
+
return !n.isBlockContainer || this.editor.schema.blockSchema[n.blockNoteType]?.content !== "inline" ? null : (e.deleteRange(r, i), l(e, n.bnBlock.beforePos, a), ir(e, v(n.bnBlock.node, e.doc), "start"), e);
|
|
2516
2516
|
}
|
|
2517
2517
|
return null;
|
|
2518
|
-
}, { undoable: !0 }))), Object.keys(e.keyboardShortcuts || {}).length && t.push(
|
|
2518
|
+
}, { undoable: !0 }))), Object.keys(e.keyboardShortcuts || {}).length && t.push(dt(Object.fromEntries(Object.entries(e.keyboardShortcuts).map(([e, t]) => [e, () => t({ editor: this.editor })])))), {
|
|
2519
2519
|
plugins: t,
|
|
2520
2520
|
inputRules: n
|
|
2521
2521
|
});
|
|
@@ -2561,13 +2561,13 @@ function Oi(e, t) {
|
|
|
2561
2561
|
//#region src/api/blockManipulation/selections/selection.ts
|
|
2562
2562
|
function ki(e) {
|
|
2563
2563
|
if (e.selection.empty || "node" in e.selection) return;
|
|
2564
|
-
let t = e.doc.resolve(
|
|
2564
|
+
let t = e.doc.resolve(le(e.doc, e.selection.from).posBeforeNode), n = e.doc.resolve(le(e.doc, e.selection.to).posBeforeNode), r = (n, r) => {
|
|
2565
2565
|
let i = t.posAtIndex(n, r), a = e.doc.resolve(i).nodeAfter;
|
|
2566
2566
|
if (!a) throw Error(`Error getting selection - node not found at position ${i}`);
|
|
2567
|
-
return
|
|
2567
|
+
return T(a, e.doc);
|
|
2568
2568
|
}, i = [], a = t.sharedDepth(n.pos), o = t.index(a), s = n.index(a);
|
|
2569
2569
|
if (t.depth > a) {
|
|
2570
|
-
i.push(
|
|
2570
|
+
i.push(T(t.nodeAfter, e.doc));
|
|
2571
2571
|
for (let e = t.depth; e > a; e--) if (t.node(e).type.isInGroup("childContainer")) {
|
|
2572
2572
|
let n = t.index(e) + 1, a = t.node(e).childCount;
|
|
2573
2573
|
for (let t = n; t < a; t++) i.push(r(t, e));
|
|
@@ -2577,37 +2577,37 @@ function ki(e) {
|
|
|
2577
2577
|
if (i.length === 0) throw Error(`Error getting selection - selection doesn't span any blocks (${e.selection})`);
|
|
2578
2578
|
return { blocks: i };
|
|
2579
2579
|
}
|
|
2580
|
-
function Ai(
|
|
2581
|
-
let
|
|
2582
|
-
if (
|
|
2583
|
-
let
|
|
2584
|
-
if (!s) throw Error(`Block with ID ${r} not found`);
|
|
2585
|
-
let c = p(i, e.doc);
|
|
2580
|
+
function Ai(t, n, r) {
|
|
2581
|
+
let i = typeof n == "string" ? n : n.id, a = typeof r == "string" ? r : r.id, o = b(t), s = f(o);
|
|
2582
|
+
if (i === a) throw Error(`Attempting to set selection with the same anchor and head blocks (id ${i})`);
|
|
2583
|
+
let c = u(i, t.doc);
|
|
2586
2584
|
if (!c) throw Error(`Block with ID ${i} not found`);
|
|
2587
|
-
let l =
|
|
2588
|
-
if (!l
|
|
2585
|
+
let l = u(a, t.doc);
|
|
2586
|
+
if (!l) throw Error(`Block with ID ${a} not found`);
|
|
2587
|
+
let d = e(c), p = e(l), m = s.blockSchema[d.blockNoteType], h = s.blockSchema[p.blockNoteType];
|
|
2589
2588
|
if (!d.isBlockContainer || m.content === "none") throw Error(`Attempting to set selection anchor in block without content (id ${i})`);
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
let e = ot.get(l.blockContent.node);
|
|
2593
|
-
h = l.blockContent.beforePos + e.positionAt(0, 0, l.blockContent.node) + 1 + 2;
|
|
2594
|
-
} else h = l.blockContent.beforePos + 1;
|
|
2589
|
+
if (!p.isBlockContainer || h.content === "none") throw Error(`Attempting to set selection anchor in block without content (id ${a})`);
|
|
2590
|
+
let g, _;
|
|
2595
2591
|
if (m.content === "table") {
|
|
2596
|
-
let
|
|
2597
|
-
g =
|
|
2598
|
-
} else g = d.blockContent.
|
|
2599
|
-
|
|
2592
|
+
let e = st.get(d.blockContent.node);
|
|
2593
|
+
g = d.blockContent.beforePos + e.positionAt(0, 0, d.blockContent.node) + 1 + 2;
|
|
2594
|
+
} else g = d.blockContent.beforePos + 1;
|
|
2595
|
+
if (h.content === "table") {
|
|
2596
|
+
let e = st.get(p.blockContent.node), n = p.blockContent.beforePos + e.positionAt(e.height - 1, e.width - 1, p.blockContent.node) + 1;
|
|
2597
|
+
_ = n + t.doc.resolve(n).nodeAfter.nodeSize - 2;
|
|
2598
|
+
} else _ = p.blockContent.afterPos - 1;
|
|
2599
|
+
t.setSelection(P.create(t.doc, g, _));
|
|
2600
2600
|
}
|
|
2601
2601
|
function ji(e, t = !1) {
|
|
2602
|
-
let
|
|
2602
|
+
let n = t ? Oi(e.doc, e.selection) : e.selection, r = n.$from, a = n.$to;
|
|
2603
2603
|
for (; a.parentOffset >= a.parent.nodeSize - 2 && a.depth > 0;) a = e.doc.resolve(a.pos + 1);
|
|
2604
2604
|
for (; a.parentOffset === 0 && a.depth > 0;) a = e.doc.resolve(a.pos - 1);
|
|
2605
|
-
for (;
|
|
2606
|
-
for (;
|
|
2607
|
-
let o =
|
|
2605
|
+
for (; r.parentOffset === 0 && r.depth > 0;) r = e.doc.resolve(r.pos - 1);
|
|
2606
|
+
for (; r.parentOffset >= r.parent.nodeSize - 2 && r.depth > 0;) r = e.doc.resolve(r.pos + 1);
|
|
2607
|
+
let o = i(e.doc.slice(r.pos, a.pos, !0));
|
|
2608
2608
|
return {
|
|
2609
2609
|
_meta: {
|
|
2610
|
-
startPos:
|
|
2610
|
+
startPos: r.pos,
|
|
2611
2611
|
endPos: a.pos
|
|
2612
2612
|
},
|
|
2613
2613
|
...o
|
|
@@ -2630,10 +2630,10 @@ var Mi = class {
|
|
|
2630
2630
|
return this.editor.transact((n) => Ai(n, e, t));
|
|
2631
2631
|
}
|
|
2632
2632
|
getTextCursorPosition() {
|
|
2633
|
-
return this.editor.transact((e) =>
|
|
2633
|
+
return this.editor.transact((e) => rr(e));
|
|
2634
2634
|
}
|
|
2635
2635
|
setTextCursorPosition(e, t = "start") {
|
|
2636
|
-
return this.editor.transact((n) =>
|
|
2636
|
+
return this.editor.transact((n) => ir(n, e, t));
|
|
2637
2637
|
}
|
|
2638
2638
|
getSelectionBoundingBox() {
|
|
2639
2639
|
if (!this.editor.prosemirrorView) return;
|
|
@@ -2642,7 +2642,7 @@ var Mi = class {
|
|
|
2642
2642
|
let e = this.editor.prosemirrorView.nodeDOM(n);
|
|
2643
2643
|
if (e) return e.getBoundingClientRect();
|
|
2644
2644
|
}
|
|
2645
|
-
return
|
|
2645
|
+
return rt(this.editor.prosemirrorView, n, r).toJSON();
|
|
2646
2646
|
}
|
|
2647
2647
|
}, Ni = class {
|
|
2648
2648
|
editor;
|
|
@@ -2737,7 +2737,7 @@ function Pi(e, t, n, r = { updateSelection: !0 }) {
|
|
|
2737
2737
|
let { parent: t } = e.doc.resolve(i);
|
|
2738
2738
|
t.isTextblock && !t.type.spec.code && !t.childCount && (--i, a += 1);
|
|
2739
2739
|
}
|
|
2740
|
-
return o ? e.insertText(c, i, a) : e.replaceWith(i, a, n), r.updateSelection &&
|
|
2740
|
+
return o ? e.insertText(c, i, a) : e.replaceWith(i, a, n), r.updateSelection && it(e, e.steps.length - 1, -1), !0;
|
|
2741
2741
|
}
|
|
2742
2742
|
//#endregion
|
|
2743
2743
|
//#region src/editor/managers/StyleManager.ts
|
|
@@ -2747,7 +2747,7 @@ var Fi = class {
|
|
|
2747
2747
|
this.editor = e;
|
|
2748
2748
|
}
|
|
2749
2749
|
insertInlineContent(e, { updateSelection: t = !1 } = {}) {
|
|
2750
|
-
let n =
|
|
2750
|
+
let n = s(e, this.editor.pmSchema);
|
|
2751
2751
|
this.editor.transact((e) => {
|
|
2752
2752
|
Pi(e, {
|
|
2753
2753
|
from: e.selection.from,
|
|
@@ -2775,7 +2775,7 @@ var Fi = class {
|
|
|
2775
2775
|
if (!e) throw Error(`style ${t} not found in styleSchema`);
|
|
2776
2776
|
if (e.propSchema === "boolean") this.editor._tiptapEditor.commands.setMark(t);
|
|
2777
2777
|
else if (e.propSchema === "string") this.editor._tiptapEditor.commands.setMark(t, { stringValue: n });
|
|
2778
|
-
else throw new
|
|
2778
|
+
else throw new o(e.propSchema);
|
|
2779
2779
|
}
|
|
2780
2780
|
}
|
|
2781
2781
|
removeStyles(e) {
|
|
@@ -2787,7 +2787,7 @@ var Fi = class {
|
|
|
2787
2787
|
if (!e) throw Error(`style ${t} not found in styleSchema`);
|
|
2788
2788
|
if (e.propSchema === "boolean") this.editor._tiptapEditor.commands.toggleMark(t);
|
|
2789
2789
|
else if (e.propSchema === "string") this.editor._tiptapEditor.commands.toggleMark(t, { stringValue: n });
|
|
2790
|
-
else throw new
|
|
2790
|
+
else throw new o(e.propSchema);
|
|
2791
2791
|
}
|
|
2792
2792
|
}
|
|
2793
2793
|
getSelectedText() {
|
|
@@ -2840,7 +2840,7 @@ function Ii(e) {
|
|
|
2840
2840
|
return Je(e.state.selection.$from, (e) => e.type.name === "tableCell" || e.type.name === "tableHeader") !== void 0;
|
|
2841
2841
|
}
|
|
2842
2842
|
function Li(e, t) {
|
|
2843
|
-
let n = t.nodes.hardBreak, r =
|
|
2843
|
+
let n = t.nodes.hardBreak, r = F.empty;
|
|
2844
2844
|
return e.forEach((e) => {
|
|
2845
2845
|
e.isTextblock && e.childCount > 0 ? (r = r.append(e.content), r = r.addToEnd(n.create())) : e.isText ? r = r.addToEnd(e) : e.isBlock && e.childCount > 0 && (r = r.append(Li(e.content, t)), r = r.addToEnd(n.create()));
|
|
2846
2846
|
}), r.lastChild?.type === n && (r = r.cut(0, r.size - 1)), r;
|
|
@@ -2849,7 +2849,7 @@ function Ri(e, t) {
|
|
|
2849
2849
|
let n = [];
|
|
2850
2850
|
return e.forEach((e, r, i) => {
|
|
2851
2851
|
i !== t && n.push(e);
|
|
2852
|
-
}),
|
|
2852
|
+
}), F.from(n);
|
|
2853
2853
|
}
|
|
2854
2854
|
function zi(e, t) {
|
|
2855
2855
|
let n = [];
|
|
@@ -2862,10 +2862,10 @@ function zi(e, t) {
|
|
|
2862
2862
|
n.push(i);
|
|
2863
2863
|
}
|
|
2864
2864
|
} else n.push(e.child(r));
|
|
2865
|
-
return e =
|
|
2865
|
+
return e = F.from(n), e;
|
|
2866
2866
|
}
|
|
2867
2867
|
function Bi(e, t) {
|
|
2868
|
-
let n =
|
|
2868
|
+
let n = F.from(e.content);
|
|
2869
2869
|
n = zi(n, t.state.schema);
|
|
2870
2870
|
let r = Vi(n, t, e);
|
|
2871
2871
|
if (r) return r;
|
|
@@ -2873,9 +2873,9 @@ function Bi(e, t) {
|
|
|
2873
2873
|
let e = !1;
|
|
2874
2874
|
if (n.descendants((t) => {
|
|
2875
2875
|
t.type.isInGroup("tableContent") && (e = !0);
|
|
2876
|
-
}), !e && !t.state.schema.nodes.tableParagraph.validContent(n)) return new
|
|
2876
|
+
}), !e && !t.state.schema.nodes.tableParagraph.validContent(n)) return new I(Li(n, t.state.schema), 0, 0);
|
|
2877
2877
|
}
|
|
2878
|
-
if (!Hi(n, t)) return new
|
|
2878
|
+
if (!Hi(n, t)) return new I(n, e.openStart, e.openEnd);
|
|
2879
2879
|
for (let e = 0; e < n.childCount; e++) if (n.child(e).type.spec.group === "blockContent") {
|
|
2880
2880
|
let r = [n.child(e)];
|
|
2881
2881
|
if (e + 1 < n.childCount && n.child(e + 1).type.name === "blockGroup") {
|
|
@@ -2885,23 +2885,23 @@ function Bi(e, t) {
|
|
|
2885
2885
|
let i = t.state.schema.nodes.blockContainer.createChecked(void 0, r);
|
|
2886
2886
|
n = n.replaceChild(e, i);
|
|
2887
2887
|
}
|
|
2888
|
-
return new
|
|
2888
|
+
return new I(n, e.openStart, e.openEnd);
|
|
2889
2889
|
}
|
|
2890
2890
|
function Vi(e, t, n) {
|
|
2891
2891
|
if (Ii(t) || t.dragging) return null;
|
|
2892
|
-
let r =
|
|
2892
|
+
let r = S(t.state), i = r.isBlockContainer ? r.blockContent.node : null;
|
|
2893
2893
|
if (!i || i.type.name === "paragraph" || i.type.spec.content !== "inline*" || i.childCount > 0) return null;
|
|
2894
2894
|
let a = e.firstChild, o = a?.firstChild, s = o?.firstChild;
|
|
2895
2895
|
if (a?.type.name !== "blockGroup" || o?.type.name !== "blockContainer" || s?.type.name !== "paragraph") return null;
|
|
2896
2896
|
let c = i.type.create(i.attrs, s.content), l = o.copy(o.content.replaceChild(0, c)), u = a.copy(a.content.replaceChild(0, l));
|
|
2897
|
-
return new
|
|
2897
|
+
return new I(e.replaceChild(0, u), n.openStart, n.openEnd);
|
|
2898
2898
|
}
|
|
2899
2899
|
function Hi(e, t) {
|
|
2900
2900
|
let n = e.childCount === 1, r = e.firstChild?.type.spec.content === "inline*", i = e.firstChild?.type.spec.content === "tableRow+";
|
|
2901
2901
|
if (n) {
|
|
2902
2902
|
if (r) return !1;
|
|
2903
2903
|
if (i) {
|
|
2904
|
-
let e =
|
|
2904
|
+
let e = S(t.state);
|
|
2905
2905
|
if (e.isBlockContainer) return e.blockContent.node.type.spec.content !== "tableRow+";
|
|
2906
2906
|
}
|
|
2907
2907
|
}
|
|
@@ -2913,7 +2913,7 @@ var Ui = {
|
|
|
2913
2913
|
enableInputRules: !0,
|
|
2914
2914
|
enablePasteRules: !0,
|
|
2915
2915
|
enableCoreExtensions: !1
|
|
2916
|
-
}, Wi = class
|
|
2916
|
+
}, Wi = class e extends U {
|
|
2917
2917
|
options;
|
|
2918
2918
|
pmSchema;
|
|
2919
2919
|
_tiptapEditor;
|
|
@@ -2929,27 +2929,27 @@ var Ui = {
|
|
|
2929
2929
|
onUploadEndCallbacks = [];
|
|
2930
2930
|
resolveFileUrl;
|
|
2931
2931
|
settings;
|
|
2932
|
-
static create(
|
|
2933
|
-
return new t
|
|
2934
|
-
}
|
|
2935
|
-
constructor(
|
|
2936
|
-
super(), this.options =
|
|
2937
|
-
splitCells:
|
|
2938
|
-
cellBackgroundColor:
|
|
2939
|
-
cellTextColor:
|
|
2940
|
-
headers:
|
|
2932
|
+
static create(t) {
|
|
2933
|
+
return new e(t ?? {});
|
|
2934
|
+
}
|
|
2935
|
+
constructor(e) {
|
|
2936
|
+
super(), this.options = e, this.dictionary = e.dictionary || Ie, this.settings = { tables: {
|
|
2937
|
+
splitCells: e?.tables?.splitCells ?? !1,
|
|
2938
|
+
cellBackgroundColor: e?.tables?.cellBackgroundColor ?? !1,
|
|
2939
|
+
cellTextColor: e?.tables?.cellTextColor ?? !1,
|
|
2940
|
+
headers: e?.tables?.headers ?? !1
|
|
2941
2941
|
} };
|
|
2942
|
-
let
|
|
2942
|
+
let t = {
|
|
2943
2943
|
defaultStyles: !0,
|
|
2944
|
-
schema:
|
|
2945
|
-
...
|
|
2944
|
+
schema: e.schema || de.create(),
|
|
2945
|
+
...e,
|
|
2946
2946
|
placeholders: {
|
|
2947
2947
|
...this.dictionary.placeholders,
|
|
2948
|
-
...
|
|
2948
|
+
...e.placeholders
|
|
2949
2949
|
}
|
|
2950
2950
|
};
|
|
2951
|
-
if (this.schema =
|
|
2952
|
-
let e =
|
|
2951
|
+
if (this.schema = t.schema, this.blockImplementations = t.schema.blockSpecs, this.inlineContentImplementations = t.schema.inlineContentSpecs, this.styleImplementations = t.schema.styleSpecs, t.uploadFile) {
|
|
2952
|
+
let e = t.uploadFile;
|
|
2953
2953
|
this.uploadFile = async (t, n) => {
|
|
2954
2954
|
this.onUploadStartCallbacks.forEach((e) => e.apply(this, [n]));
|
|
2955
2955
|
try {
|
|
@@ -2959,13 +2959,13 @@ var Ui = {
|
|
|
2959
2959
|
}
|
|
2960
2960
|
};
|
|
2961
2961
|
}
|
|
2962
|
-
this.resolveFileUrl =
|
|
2963
|
-
let
|
|
2962
|
+
this.resolveFileUrl = t.resolveFileUrl, this._eventManager = new an(this), this._extensionManager = new Di(this, t);
|
|
2963
|
+
let n = this._extensionManager.getTiptapExtensions(), r = {
|
|
2964
2964
|
...Ui,
|
|
2965
|
-
...
|
|
2965
|
+
...t._tiptapOptions,
|
|
2966
2966
|
element: null,
|
|
2967
|
-
autofocus:
|
|
2968
|
-
extensions:
|
|
2967
|
+
autofocus: t.autofocus ?? !1,
|
|
2968
|
+
extensions: n,
|
|
2969
2969
|
editorProps: {
|
|
2970
2970
|
scrollMargin: {
|
|
2971
2971
|
top: 72,
|
|
@@ -2973,33 +2973,33 @@ var Ui = {
|
|
|
2973
2973
|
left: 0,
|
|
2974
2974
|
right: 0
|
|
2975
2975
|
},
|
|
2976
|
-
...
|
|
2976
|
+
...t._tiptapOptions?.editorProps,
|
|
2977
2977
|
attributes: {
|
|
2978
2978
|
tabIndex: "0",
|
|
2979
|
-
...
|
|
2980
|
-
...
|
|
2981
|
-
class:
|
|
2979
|
+
...t._tiptapOptions?.editorProps?.attributes,
|
|
2980
|
+
...t.domAttributes?.editor,
|
|
2981
|
+
class: ee("bn-editor", t.defaultStyles ? "bn-default-styles" : "", t.domAttributes?.editor?.class || "")
|
|
2982
2982
|
},
|
|
2983
2983
|
transformPasted: Bi
|
|
2984
2984
|
}
|
|
2985
2985
|
};
|
|
2986
2986
|
try {
|
|
2987
|
-
let
|
|
2987
|
+
let e = t.initialContent || [{
|
|
2988
2988
|
type: "paragraph",
|
|
2989
|
-
id:
|
|
2989
|
+
id: m.options.generateID()
|
|
2990
2990
|
}];
|
|
2991
|
-
if (!Array.isArray(
|
|
2992
|
-
let
|
|
2993
|
-
|
|
2994
|
-
let
|
|
2991
|
+
if (!Array.isArray(e) || e.length === 0) throw Error("initialContent must be a non-empty array of blocks, received: " + JSON.stringify(e));
|
|
2992
|
+
let n = $e(r.extensions);
|
|
2993
|
+
n.cached.blockNoteEditor = this;
|
|
2994
|
+
let i = e.map((e) => a(e, n, this.schema.styleSchema).toJSON()), o = Ke({
|
|
2995
2995
|
type: "doc",
|
|
2996
2996
|
content: [{
|
|
2997
2997
|
type: "blockGroup",
|
|
2998
|
-
content:
|
|
2998
|
+
content: i
|
|
2999
2999
|
}]
|
|
3000
|
-
},
|
|
3000
|
+
}, n, r.parseOptions);
|
|
3001
3001
|
this._tiptapEditor = new Ue({
|
|
3002
|
-
...
|
|
3002
|
+
...r,
|
|
3003
3003
|
content: o.toJSON()
|
|
3004
3004
|
}), this.pmSchema = this._tiptapEditor.schema;
|
|
3005
3005
|
} catch (e) {
|
|
@@ -3009,7 +3009,7 @@ var Ui = {
|
|
|
3009
3009
|
this.headless = !1;
|
|
3010
3010
|
}), this._tiptapEditor.on("unmount", () => {
|
|
3011
3011
|
this.headless = !0;
|
|
3012
|
-
}), this._blockManager = new
|
|
3012
|
+
}), this._blockManager = new rn(this), this._exportManager = new nr(this), this._selectionManager = new Mi(this), this._stateManager = new Ni(this), this._styleManager = new Fi(this), this.emit("create");
|
|
3013
3013
|
}
|
|
3014
3014
|
_blockManager;
|
|
3015
3015
|
_eventManager;
|
|
@@ -3251,9 +3251,14 @@ var Ui = {
|
|
|
3251
3251
|
return this.options.dictionary?.exporter ?? Ie.exporter;
|
|
3252
3252
|
}
|
|
3253
3253
|
async resolveFile(e) {
|
|
3254
|
-
if (!this.options?.resolveFileUrl) return (
|
|
3254
|
+
if (!this.options?.resolveFileUrl) return this.fetchBlob(e);
|
|
3255
3255
|
let t = await this.options.resolveFileUrl(e);
|
|
3256
|
-
return t instanceof Blob ? t : (
|
|
3256
|
+
return t instanceof Blob ? t : this.fetchBlob(t);
|
|
3257
|
+
}
|
|
3258
|
+
async fetchBlob(e) {
|
|
3259
|
+
let t = await fetch(e);
|
|
3260
|
+
if (!t.ok) throw Error(`Failed to fetch file "${e}": ${t.status} ${t.statusText}`);
|
|
3261
|
+
return t.blob();
|
|
3257
3262
|
}
|
|
3258
3263
|
mapStyles(e) {
|
|
3259
3264
|
return Object.entries(e).map(([e, t]) => {
|
|
@@ -3307,6 +3312,6 @@ function Yi(e, ...t) {
|
|
|
3307
3312
|
return n;
|
|
3308
3313
|
}
|
|
3309
3314
|
//#endregion
|
|
3310
|
-
export {
|
|
3315
|
+
export { mt as A, V as C, bt as D, xt as E, yt as O, Mt as S, z as T, Ft as _, Gi as a, H as b, kr as c, K as d, $t as f, U as g, en as h, qi as i, vt as k, tr as l, nn as m, Ji as n, Wi as o, tn as p, Ki as r, Oi as s, Yi as t, er as u, It as v, B as w, Lt as x, Pt as y };
|
|
3311
3316
|
|
|
3312
|
-
//# sourceMappingURL=src-
|
|
3317
|
+
//# sourceMappingURL=src-Buuo5l7X.js.map
|