@blocknote/core 0.50.0 → 0.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocknote.cjs +1 -1
- package/dist/blocknote.js +4 -4
- package/dist/{blocks-UU7EM-QM.js → blocks-D0lMxErU.js} +397 -368
- package/dist/blocks-D0lMxErU.js.map +1 -0
- package/dist/blocks-KyMOxPT3.cjs +11 -0
- package/dist/blocks-KyMOxPT3.cjs.map +1 -0
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +2 -2
- package/dist/{extensions-CkLT--Nc.js → extensions-CQFfm5f5.js} +619 -353
- package/dist/extensions-CQFfm5f5.js.map +1 -0
- package/dist/extensions-Cuw3zOdC.cjs +52 -0
- package/dist/extensions-Cuw3zOdC.cjs.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +3 -3
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +1 -1
- package/dist/locales.js.map +1 -1
- package/dist/{src-SVFpMAWE.js → src-DK_8q1j5.js} +1070 -564
- package/dist/src-DK_8q1j5.js.map +1 -0
- package/dist/src-_83jmA7A.cjs +21 -0
- package/dist/src-_83jmA7A.cjs.map +1 -0
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.js +8 -8
- package/package.json +1 -13
- package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +7 -7
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +5 -3
- package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +5 -5
- package/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap +2550 -291
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +83 -2
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +103 -42
- package/src/api/blockManipulation/commands/nestBlock/__snapshots__/nestBlock.test.ts.snap +0 -143
- package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +12 -12
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +5 -3
- package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +6 -6
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +22 -22
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +12 -8
- package/src/api/blockManipulation/setupTestEnv.ts +1 -1
- package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +2 -6
- package/src/api/clipboard/fromClipboard/pasteExtension.ts +7 -2
- package/src/api/exporters/markdown/htmlToMarkdown.ts +813 -0
- package/src/api/exporters/markdown/markdownExporter.ts +2 -21
- package/src/api/nodeConversions/blockToNode.ts +3 -2
- package/src/api/parsers/html/util/__snapshots__/nestedLists.test.ts.snap +122 -107
- package/src/api/parsers/html/util/nestedLists.test.ts +1 -12
- package/src/api/parsers/markdown/markdownToHtml.ts +1194 -0
- package/src/api/parsers/markdown/parseMarkdown.ts +2 -101
- package/src/blocks/Audio/block.ts +1 -4
- package/src/blocks/Code/block.test.ts +258 -0
- package/src/blocks/File/block.ts +1 -4
- package/src/blocks/File/helpers/render/createFileBlockWrapper.ts +7 -2
- package/src/blocks/Image/block.ts +9 -6
- package/src/blocks/ListItem/BulletListItem/block.ts +7 -4
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +3 -4
- package/src/blocks/Video/block.ts +4 -5
- package/src/blocks/Video/parseVideoElement.ts +2 -1
- package/src/editor/Block.css +8 -0
- package/src/editor/BlockNoteEditor.test.ts +10 -4
- package/src/editor/BlockNoteEditor.ts +30 -13
- package/src/editor/managers/BlockManager.ts +10 -6
- package/src/editor/managers/ExtensionManager/index.ts +80 -25
- package/src/editor/performance.test.ts +2 -2
- package/src/editor/transformPasted.test.ts +295 -0
- package/src/editor/transformPasted.ts +77 -0
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor-forked.json +1 -12
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor.json +0 -11
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-forked.html +1 -1
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap.html +1 -1
- package/src/extensions/SideMenu/dragging.ts +7 -10
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +21 -0
- package/src/extensions/TrailingNode/TrailingNode.ts +124 -65
- package/src/i18n/locales/fr.ts +1 -1
- package/types/src/api/blockManipulation/commands/moveBlocks/moveBlocks.d.ts +13 -2
- package/types/src/api/clipboard/fromClipboard/handleVSCodePaste.d.ts +1 -1
- package/types/src/api/exporters/markdown/htmlToMarkdown.d.ts +11 -0
- package/types/src/api/parsers/markdown/markdownToHtml.d.ts +5 -0
- package/types/src/blocks/Code/block.test.d.ts +1 -0
- package/types/src/blocks/Video/block.d.ts +2 -0
- package/types/src/blocks/Video/parseVideoElement.d.ts +1 -0
- package/types/src/editor/BlockNoteEditor.d.ts +20 -6
- package/types/src/editor/managers/BlockManager.d.ts +8 -4
- package/types/src/editor/transformPasted.test.d.ts +1 -0
- package/types/src/extensions/TrailingNode/TrailingNode.d.ts +8 -3
- package/dist/blocks-BFnTypT-.cjs +0 -11
- package/dist/blocks-BFnTypT-.cjs.map +0 -1
- package/dist/blocks-UU7EM-QM.js.map +0 -1
- package/dist/extensions-CYsFi5Is.cjs +0 -2
- package/dist/extensions-CYsFi5Is.cjs.map +0 -1
- package/dist/extensions-CkLT--Nc.js.map +0 -1
- package/dist/src-DsJ6yzs9.cjs +0 -5
- package/dist/src-DsJ6yzs9.cjs.map +0 -1
- package/dist/src-SVFpMAWE.js.map +0 -1
- package/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.ts +0 -42
- package/src/api/exporters/markdown/util/convertVideoToMarkdownRehypePlugin.ts +0 -19
- package/src/api/exporters/markdown/util/removeUnderlinesRehypePlugin.ts +0 -39
- package/types/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.d.ts +0 -7
- package/types/src/api/exporters/markdown/util/convertVideoToMarkdownRehypePlugin.d.ts +0 -2
- package/types/src/api/exporters/markdown/util/removeUnderlinesRehypePlugin.d.ts +0 -6
|
@@ -1,42 +1,35 @@
|
|
|
1
|
-
import { At as e, Bt as t, Dt as n,
|
|
2
|
-
import { n as
|
|
3
|
-
import { DOMSerializer as
|
|
4
|
-
import { dropPoint as
|
|
5
|
-
import { combineTransactionSteps as
|
|
6
|
-
import { NodeSelection as
|
|
7
|
-
import { uuidv4 as
|
|
8
|
-
import { DOMParser as
|
|
9
|
-
import { CellSelection as
|
|
10
|
-
import { Plugin as
|
|
11
|
-
import { Decoration as
|
|
12
|
-
import { defaultSelectionBuilder as
|
|
13
|
-
import
|
|
14
|
-
import * as
|
|
15
|
-
import { history as
|
|
16
|
-
import Me from "rehype-parse";
|
|
17
|
-
import Ne from "rehype-remark";
|
|
18
|
-
import Pe from "remark-gfm";
|
|
19
|
-
import Fe from "remark-stringify";
|
|
20
|
-
import { unified as Ie } from "unified";
|
|
21
|
-
import { fromDom as Le } from "hast-util-from-dom";
|
|
22
|
-
import { visit as Re } from "unist-util-visit";
|
|
1
|
+
import { At as e, Bt as t, Dt as n, Ft as r, It as i, Lt as a, Mt as o, Nt as s, Ot as c, Pt as l, Rt as u, Vt as d, _ as f, an as p, fn as m, g as h, gt as g, jt as ee, on as te, r as ne, zn as re, zt as ie } from "./blocks-D0lMxErU.js";
|
|
2
|
+
import { n as _, t as v } from "./BlockNoteExtension-B6RhuQ3V.js";
|
|
3
|
+
import { DOMSerializer as ae, Fragment as y, Slice as oe } from "prosemirror-model";
|
|
4
|
+
import { dropPoint as se } from "prosemirror-transform";
|
|
5
|
+
import { combineTransactionSteps as ce, findChildrenInRange as le, posToDOMRect as ue } from "@tiptap/core";
|
|
6
|
+
import { NodeSelection as de, Plugin as b, PluginKey as x, Selection as S, TextSelection as fe } from "prosemirror-state";
|
|
7
|
+
import { uuidv4 as pe } from "lib0/random";
|
|
8
|
+
import { DOMParser as me, Slice as he } from "@tiptap/pm/model";
|
|
9
|
+
import { CellSelection as ge, addColumnAfter as _e, addColumnBefore as ve, addRowAfter as ye, addRowBefore as be, deleteColumn as xe, deleteRow as Se, mergeCells as Ce, splitCell as we } from "prosemirror-tables";
|
|
10
|
+
import { Plugin as C, PluginKey as Te, TextSelection as Ee } from "@tiptap/pm/state";
|
|
11
|
+
import { Decoration as w, DecorationSet as T } from "prosemirror-view";
|
|
12
|
+
import { defaultSelectionBuilder as De, redoCommand as Oe, undoCommand as ke, yCursorPlugin as Ae, ySyncPlugin as je, yUndoPlugin as Me, yUndoPluginKey as E } from "y-prosemirror";
|
|
13
|
+
import Ne from "fast-deep-equal";
|
|
14
|
+
import * as D from "yjs";
|
|
15
|
+
import { history as Pe, redo as Fe, undo as Ie } from "@tiptap/pm/history";
|
|
23
16
|
//#region src/api/exporters/html/util/serializeBlocksExternalHTML.ts
|
|
24
|
-
function
|
|
17
|
+
function Le(e) {
|
|
25
18
|
let t = Array.from(e.classList).filter((e) => !e.startsWith("bn-")) || [];
|
|
26
19
|
t.length > 0 ? e.className = t.join(" ") : e.removeAttribute("class");
|
|
27
20
|
}
|
|
28
|
-
function
|
|
21
|
+
function Re(t, n, r, i) {
|
|
29
22
|
let a;
|
|
30
23
|
if (!n) throw Error("blockContent is required");
|
|
31
|
-
if (typeof n == "string") a =
|
|
32
|
-
else if (Array.isArray(n)) a =
|
|
33
|
-
else if (n.type === "tableContent") a =
|
|
34
|
-
else throw new
|
|
24
|
+
if (typeof n == "string") a = e([n], t.pmSchema);
|
|
25
|
+
else if (Array.isArray(n)) a = e(n, t.pmSchema);
|
|
26
|
+
else if (n.type === "tableContent") a = ee(n, t.pmSchema);
|
|
27
|
+
else throw new re(n.type);
|
|
35
28
|
let o = (i?.document ?? document).createDocumentFragment();
|
|
36
29
|
for (let e of a) if (e.type.name !== "text" && t.schema.inlineContentSchema[e.type.name]) {
|
|
37
30
|
let n = t.schema.inlineContentSpecs[e.type.name].implementation;
|
|
38
31
|
if (n) {
|
|
39
|
-
let a =
|
|
32
|
+
let a = te(e, t.schema.inlineContentSchema, t.schema.styleSchema), s = n.toExternalHTML ? n.toExternalHTML(a, t) : n.render.call({
|
|
40
33
|
renderType: "dom",
|
|
41
34
|
props: void 0
|
|
42
35
|
}, a, () => {}, t);
|
|
@@ -54,15 +47,15 @@ function P(t, n, r, i) {
|
|
|
54
47
|
let e = (t.schema.styleSpecs[r.type.name].implementation.toExternalHTML ?? t.schema.styleSpecs[r.type.name].implementation.render)(r.attrs.stringValue, t);
|
|
55
48
|
e.contentDOM.appendChild(n), n = e.dom;
|
|
56
49
|
} else {
|
|
57
|
-
let e = r.type.spec.toDOM(r, !0), t =
|
|
50
|
+
let e = r.type.spec.toDOM(r, !0), t = ae.renderSpec(document, e);
|
|
58
51
|
t.contentDOM.appendChild(n), n = t.dom;
|
|
59
52
|
}
|
|
60
53
|
o.appendChild(n);
|
|
61
54
|
} else {
|
|
62
|
-
let t = r.serializeFragment(
|
|
55
|
+
let t = r.serializeFragment(y.from([e]), i);
|
|
63
56
|
o.appendChild(t);
|
|
64
57
|
}
|
|
65
|
-
return o.childNodes.length === 1 && o.firstChild?.nodeType === 1 &&
|
|
58
|
+
return o.childNodes.length === 1 && o.firstChild?.nodeType === 1 && Le(o.firstChild), o;
|
|
66
59
|
}
|
|
67
60
|
function ze(e, t, n, r, i, a, o, s) {
|
|
68
61
|
let c = s?.document ?? document, l = t.pmSchema.nodes.blockContainer, u = n.props || {};
|
|
@@ -80,10 +73,10 @@ function ze(e, t, n, r, i, a, o, s) {
|
|
|
80
73
|
if (m.dom.classList.contains("bn-block-content")) {
|
|
81
74
|
let e = [...f, ...Array.from(m.dom.attributes)].filter((e) => e.name.startsWith("data") && e.name !== "data-content-type" && e.name !== "data-file-block" && e.name !== "data-node-view-wrapper" && e.name !== "data-node-type" && e.name !== "data-id" && e.name !== "data-editable");
|
|
82
75
|
for (let t of e) m.dom.firstChild.setAttribute(t.name, t.value);
|
|
83
|
-
|
|
76
|
+
Le(m.dom.firstChild), o > 0 && m.dom.firstChild.setAttribute("data-nesting-level", o.toString()), h.append(...Array.from(m.dom.childNodes));
|
|
84
77
|
} else h.append(m.dom), o > 0 && m.dom.setAttribute("data-nesting-level", o.toString());
|
|
85
78
|
if (m.contentDOM && n.content) {
|
|
86
|
-
let e =
|
|
79
|
+
let e = Re(t, n.content, r, s);
|
|
87
80
|
m.contentDOM.appendChild(e);
|
|
88
81
|
}
|
|
89
82
|
let g;
|
|
@@ -96,20 +89,20 @@ function ze(e, t, n, r, i, a, o, s) {
|
|
|
96
89
|
} else e.append(h);
|
|
97
90
|
if (n.children && n.children.length > 0) {
|
|
98
91
|
let l = c.createDocumentFragment();
|
|
99
|
-
if (
|
|
92
|
+
if (Be(l, t, n.children, r, i, a, o + 1, s), e.lastChild?.nodeName === "UL" || e.lastChild?.nodeName === "OL") for (; l.firstChild?.nodeName === "UL" || l.firstChild?.nodeName === "OL";) e.lastChild.lastChild.appendChild(l.firstChild);
|
|
100
93
|
"childrenDOM" in m && m.childrenDOM ? m.childrenDOM.append(l) : t.pmSchema.nodes[n.type].isInGroup("blockContent") ? e.append(l) : m.contentDOM?.append(l);
|
|
101
94
|
}
|
|
102
95
|
}
|
|
103
|
-
var
|
|
96
|
+
var Be = (e, t, n, r, i, a, o = 0, s) => {
|
|
104
97
|
for (let c of n) ze(e, t, c, r, i, a, o, s);
|
|
105
|
-
},
|
|
98
|
+
}, Ve = (e, t, n, r, i, a) => {
|
|
106
99
|
let o = (a?.document ?? document).createDocumentFragment();
|
|
107
|
-
return
|
|
108
|
-
},
|
|
109
|
-
let n =
|
|
100
|
+
return Be(o, e, t, n, r, i, 0, a), o;
|
|
101
|
+
}, O = (e, t) => {
|
|
102
|
+
let n = ae.fromSchema(e);
|
|
110
103
|
return {
|
|
111
104
|
exportBlocks: (e, r) => {
|
|
112
|
-
let i =
|
|
105
|
+
let i = Ve(t, e, n, new Set(["numberedListItem"]), new Set([
|
|
113
106
|
"bulletListItem",
|
|
114
107
|
"checkListItem",
|
|
115
108
|
"toggleListItem"
|
|
@@ -117,41 +110,41 @@ var F = (e, t, n, r, i, a, o = 0, s) => {
|
|
|
117
110
|
return a.append(i), a.innerHTML;
|
|
118
111
|
},
|
|
119
112
|
exportInlineContent: (e, r) => {
|
|
120
|
-
let i =
|
|
113
|
+
let i = Re(t, e, n, r), a = document.createElement("div");
|
|
121
114
|
return a.append(i.cloneNode(!0)), a.innerHTML;
|
|
122
115
|
}
|
|
123
116
|
};
|
|
124
117
|
};
|
|
125
118
|
//#endregion
|
|
126
119
|
//#region src/api/getBlocksChangedByTransaction.ts
|
|
127
|
-
function
|
|
120
|
+
function He(e, t) {
|
|
128
121
|
if (t === 0) return;
|
|
129
|
-
let
|
|
130
|
-
for (let e =
|
|
131
|
-
let t =
|
|
132
|
-
if (
|
|
122
|
+
let n = e.resolve(t);
|
|
123
|
+
for (let e = n.depth; e > 0; e--) {
|
|
124
|
+
let t = n.node(e);
|
|
125
|
+
if (c(t)) return t.attrs.id;
|
|
133
126
|
}
|
|
134
127
|
}
|
|
135
|
-
function
|
|
128
|
+
function Ue(e) {
|
|
136
129
|
return e.getMeta("paste") ? { type: "paste" } : e.getMeta("uiEvent") === "drop" ? { type: "drop" } : e.getMeta("history$") ? { type: e.getMeta("history$").redo ? "redo" : "undo" } : e.getMeta("y-sync$") ? e.getMeta("y-sync$").isUndoRedoOperation ? { type: "undo-redo" } : { type: "yjs-remote" } : { type: "local" };
|
|
137
130
|
}
|
|
138
|
-
function
|
|
139
|
-
let t = {},
|
|
140
|
-
return e.descendants((
|
|
141
|
-
if (!
|
|
142
|
-
let
|
|
143
|
-
|
|
144
|
-
let l =
|
|
145
|
-
return t[
|
|
131
|
+
function We(e) {
|
|
132
|
+
let t = {}, n = {}, r = m(e);
|
|
133
|
+
return e.descendants((i, a) => {
|
|
134
|
+
if (!c(i)) return !0;
|
|
135
|
+
let o = He(e, a), s = o ?? "__root__";
|
|
136
|
+
n[s] || (n[s] = []);
|
|
137
|
+
let l = p(i, r);
|
|
138
|
+
return t[i.attrs.id] = {
|
|
146
139
|
block: l,
|
|
147
|
-
parentId:
|
|
148
|
-
},
|
|
140
|
+
parentId: o
|
|
141
|
+
}, n[s].push(i.attrs.id), !0;
|
|
149
142
|
}), {
|
|
150
143
|
byId: t,
|
|
151
|
-
childrenByParent:
|
|
144
|
+
childrenByParent: n
|
|
152
145
|
};
|
|
153
146
|
}
|
|
154
|
-
function
|
|
147
|
+
function Ge(e, t) {
|
|
155
148
|
let n = /* @__PURE__ */ new Set();
|
|
156
149
|
if (!e || !t) return n;
|
|
157
150
|
let r = new Set(e), i = t.filter((e) => r.has(e)), a = e.filter((e) => i.includes(e));
|
|
@@ -175,8 +168,8 @@ function Ue(e, t) {
|
|
|
175
168
|
for (let e = 0; e < i.length; e++) p.has(e) || n.add(i[e]);
|
|
176
169
|
return n;
|
|
177
170
|
}
|
|
178
|
-
function
|
|
179
|
-
let n =
|
|
171
|
+
function Ke(e, t = []) {
|
|
172
|
+
let n = Ue(e), r = ce(e.before, [e, ...t]), i = We(r.before), a = We(r.doc), o = [], s = /* @__PURE__ */ new Set();
|
|
180
173
|
Object.keys(a.byId).filter((e) => !(e in i.byId)).forEach((e) => {
|
|
181
174
|
o.push({
|
|
182
175
|
type: "insert",
|
|
@@ -193,7 +186,7 @@ function R(e, t = []) {
|
|
|
193
186
|
}), s.add(e);
|
|
194
187
|
}), Object.keys(a.byId).filter((e) => e in i.byId).forEach((e) => {
|
|
195
188
|
let t = i.byId[e], r = a.byId[e];
|
|
196
|
-
t.parentId === r.parentId ?
|
|
189
|
+
t.parentId === r.parentId ? Ne({
|
|
197
190
|
...t.block,
|
|
198
191
|
children: void 0
|
|
199
192
|
}, {
|
|
@@ -215,7 +208,7 @@ function R(e, t = []) {
|
|
|
215
208
|
});
|
|
216
209
|
let c = i.childrenByParent, l = a.childrenByParent, u = new Set([...Object.keys(c), ...Object.keys(l)]), d = /* @__PURE__ */ new Set();
|
|
217
210
|
return u.forEach((e) => {
|
|
218
|
-
let t =
|
|
211
|
+
let t = Ge(c[e], l[e]);
|
|
219
212
|
t.size !== 0 && t.forEach((t) => {
|
|
220
213
|
let r = i.byId[t], c = a.byId[t];
|
|
221
214
|
!r || !c || r.parentId === c.parentId && (s.has(t) || (r.parentId ?? "__root__") === e && (d.has(t) || (d.add(t), o.push({
|
|
@@ -231,17 +224,17 @@ function R(e, t = []) {
|
|
|
231
224
|
}
|
|
232
225
|
//#endregion
|
|
233
226
|
//#region src/extensions/BlockChange/BlockChange.ts
|
|
234
|
-
var
|
|
227
|
+
var qe = v(() => {
|
|
235
228
|
let e = [];
|
|
236
229
|
return {
|
|
237
230
|
key: "blockChange",
|
|
238
|
-
prosemirrorPlugins: [new
|
|
239
|
-
key: new
|
|
231
|
+
prosemirrorPlugins: [new b({
|
|
232
|
+
key: new x("blockChange"),
|
|
240
233
|
filterTransaction: (t) => {
|
|
241
234
|
let n;
|
|
242
235
|
return e.reduce((e, r) => e === !1 ? e : r({
|
|
243
236
|
getChanges() {
|
|
244
|
-
return n || (n =
|
|
237
|
+
return n || (n = Ke(t), n);
|
|
245
238
|
},
|
|
246
239
|
tr: t
|
|
247
240
|
}) !== !1, !0);
|
|
@@ -256,7 +249,7 @@ var We = b(() => {
|
|
|
256
249
|
});
|
|
257
250
|
//#endregion
|
|
258
251
|
//#region src/extensions/Collaboration/YCursorPlugin.ts
|
|
259
|
-
function
|
|
252
|
+
function Je(e) {
|
|
260
253
|
let t = e.charAt(0) === "#" ? e.substring(1, 7) : e, n = parseInt(t.substring(0, 2), 16), r = parseInt(t.substring(2, 4), 16), i = parseInt(t.substring(4, 6), 16), a = [
|
|
261
254
|
n / 255,
|
|
262
255
|
r / 255,
|
|
@@ -264,15 +257,15 @@ function z(e) {
|
|
|
264
257
|
].map((e) => e <= .03928 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4);
|
|
265
258
|
return .2126 * a[0] + .7152 * a[1] + .0722 * a[2] <= .179;
|
|
266
259
|
}
|
|
267
|
-
function
|
|
260
|
+
function Ye(e) {
|
|
268
261
|
let t = document.createElement("span");
|
|
269
262
|
t.classList.add("bn-collaboration-cursor__base");
|
|
270
263
|
let n = document.createElement("span");
|
|
271
|
-
n.setAttribute("contentedEditable", "false"), n.classList.add("bn-collaboration-cursor__caret"), n.setAttribute("style", `background-color: ${e.color}; color: ${
|
|
264
|
+
n.setAttribute("contentedEditable", "false"), n.classList.add("bn-collaboration-cursor__caret"), n.setAttribute("style", `background-color: ${e.color}; color: ${Je(e.color) ? "white" : "black"}`);
|
|
272
265
|
let r = document.createElement("span");
|
|
273
|
-
return r.classList.add("bn-collaboration-cursor__label"), r.setAttribute("style", `background-color: ${e.color}; color: ${
|
|
266
|
+
return r.classList.add("bn-collaboration-cursor__label"), r.setAttribute("style", `background-color: ${e.color}; color: ${Je(e.color) ? "white" : "black"}`), r.insertBefore(document.createTextNode(e.name), null), n.insertBefore(r, null), t.insertBefore(document.createTextNode(""), null), t.insertBefore(n, null), t.insertBefore(document.createTextNode(""), null), t;
|
|
274
267
|
}
|
|
275
|
-
var
|
|
268
|
+
var k = v(({ options: e }) => {
|
|
276
269
|
let t = /* @__PURE__ */ new Map(), n = e.provider && "awareness" in e.provider && typeof e.provider.awareness == "object" ? e.provider.awareness : void 0;
|
|
277
270
|
return n && ("setLocalStateField" in n && typeof n.setLocalStateField == "function" && n.setLocalStateField("user", e.user), "on" in n && typeof n.on == "function" && e.showCursorLabels !== "always" && n.on("change", ({ updated: e }) => {
|
|
278
271
|
for (let n of e) {
|
|
@@ -288,12 +281,12 @@ var B = b(({ options: e }) => {
|
|
|
288
281
|
}
|
|
289
282
|
})), {
|
|
290
283
|
key: "yCursor",
|
|
291
|
-
prosemirrorPlugins: [n ?
|
|
292
|
-
selectionBuilder:
|
|
284
|
+
prosemirrorPlugins: [n ? Ae(n, {
|
|
285
|
+
selectionBuilder: De,
|
|
293
286
|
cursorBuilder(n, r) {
|
|
294
287
|
let i = t.get(r);
|
|
295
288
|
if (!i) {
|
|
296
|
-
let a = (e.renderCursor ??
|
|
289
|
+
let a = (e.renderCursor ?? Ye)(n);
|
|
297
290
|
e.showCursorLabels !== "always" && (a.addEventListener("mouseenter", () => {
|
|
298
291
|
let e = t.get(r);
|
|
299
292
|
e.element.setAttribute("data-active", ""), e.hideTimeout && (clearTimeout(e.hideTimeout), t.set(r, {
|
|
@@ -321,20 +314,20 @@ var B = b(({ options: e }) => {
|
|
|
321
314
|
n?.setLocalStateField("user", e);
|
|
322
315
|
}
|
|
323
316
|
};
|
|
324
|
-
}),
|
|
317
|
+
}), A = v(({ options: e }) => ({
|
|
325
318
|
key: "ySync",
|
|
326
|
-
prosemirrorPlugins: [
|
|
319
|
+
prosemirrorPlugins: [je(e.fragment)],
|
|
327
320
|
runsBefore: ["default"]
|
|
328
|
-
})),
|
|
321
|
+
})), j = v(() => ({
|
|
329
322
|
key: "yUndo",
|
|
330
|
-
prosemirrorPlugins: [
|
|
323
|
+
prosemirrorPlugins: [Me()],
|
|
331
324
|
dependsOn: ["yCursor", "ySync"],
|
|
332
|
-
undoCommand:
|
|
333
|
-
redoCommand:
|
|
325
|
+
undoCommand: ke,
|
|
326
|
+
redoCommand: Oe
|
|
334
327
|
}));
|
|
335
328
|
//#endregion
|
|
336
329
|
//#region src/extensions/Collaboration/ForkYDoc.ts
|
|
337
|
-
function
|
|
330
|
+
function Xe(e, t) {
|
|
338
331
|
let n = e.doc;
|
|
339
332
|
if (e._item === null) {
|
|
340
333
|
let r = Array.from(n.share.keys()).find((t) => n.share.get(t) === e);
|
|
@@ -342,11 +335,11 @@ function Ke(e, t) {
|
|
|
342
335
|
return t.get(r, e.constructor);
|
|
343
336
|
} else {
|
|
344
337
|
let n = e._item, r = t.store.clients.get(n.id.client) ?? [];
|
|
345
|
-
return r[
|
|
338
|
+
return r[D.findIndexSS(r, n.id.clock)].content.type;
|
|
346
339
|
}
|
|
347
340
|
}
|
|
348
|
-
var
|
|
349
|
-
let n, r =
|
|
341
|
+
var Ze = v(({ editor: e, options: t }) => {
|
|
342
|
+
let n, r = _({ isForked: !1 });
|
|
350
343
|
return {
|
|
351
344
|
key: "yForkDoc",
|
|
352
345
|
store: r,
|
|
@@ -354,23 +347,23 @@ var qe = b(({ editor: e, options: t }) => {
|
|
|
354
347
|
if (n) return;
|
|
355
348
|
let i = t.fragment;
|
|
356
349
|
if (!i) throw Error("No fragment to fork from");
|
|
357
|
-
let a = new
|
|
358
|
-
|
|
359
|
-
let o =
|
|
350
|
+
let a = new D.Doc();
|
|
351
|
+
D.applyUpdate(a, D.encodeStateAsUpdate(i.doc));
|
|
352
|
+
let o = Xe(i, a);
|
|
360
353
|
n = {
|
|
361
|
-
undoStack:
|
|
354
|
+
undoStack: E.getState(e.prosemirrorState).undoManager.undoStack,
|
|
362
355
|
originalFragment: i,
|
|
363
356
|
forkedFragment: o
|
|
364
357
|
}, e.unregisterExtension([
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
358
|
+
j,
|
|
359
|
+
k,
|
|
360
|
+
A
|
|
368
361
|
]);
|
|
369
362
|
let s = {
|
|
370
363
|
...t,
|
|
371
364
|
fragment: o
|
|
372
365
|
};
|
|
373
|
-
e.registerExtension([
|
|
366
|
+
e.registerExtension([A(s), j()]), r.setState({ isForked: !0 });
|
|
374
367
|
},
|
|
375
368
|
merge({ keepChanges: i }) {
|
|
376
369
|
if (!n) return;
|
|
@@ -381,24 +374,24 @@ var qe = b(({ editor: e, options: t }) => {
|
|
|
381
374
|
]);
|
|
382
375
|
let { originalFragment: a, forkedFragment: o, undoStack: s } = n;
|
|
383
376
|
if (e.registerExtension([
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
]),
|
|
388
|
-
let t =
|
|
389
|
-
|
|
377
|
+
A(t),
|
|
378
|
+
k(t),
|
|
379
|
+
j()
|
|
380
|
+
]), E.getState(e.prosemirrorState).undoManager.undoStack = s, i) {
|
|
381
|
+
let t = D.encodeStateAsUpdate(o.doc, D.encodeStateVector(a.doc));
|
|
382
|
+
D.applyUpdate(a.doc, t, e);
|
|
390
383
|
}
|
|
391
384
|
n = void 0, r.setState({ isForked: !1 });
|
|
392
385
|
}
|
|
393
386
|
};
|
|
394
|
-
}),
|
|
387
|
+
}), M = (e, t) => {
|
|
395
388
|
t(e), e.forEach((e) => {
|
|
396
|
-
e instanceof
|
|
389
|
+
e instanceof D.XmlElement && M(e, t);
|
|
397
390
|
});
|
|
398
|
-
},
|
|
391
|
+
}, Qe = [(e, t) => {
|
|
399
392
|
let n = /* @__PURE__ */ new Map();
|
|
400
393
|
return e.forEach((e) => {
|
|
401
|
-
e instanceof
|
|
394
|
+
e instanceof D.XmlElement && M(e, (e) => {
|
|
402
395
|
if (e.nodeName === "blockContainer" && e.hasAttribute("id")) {
|
|
403
396
|
let t = e.getAttribute("textColor"), r = e.getAttribute("backgroundColor"), i = {
|
|
404
397
|
textColor: t === g.textColor.default ? void 0 : t,
|
|
@@ -417,16 +410,16 @@ var qe = b(({ editor: e, options: t }) => {
|
|
|
417
410
|
});
|
|
418
411
|
}
|
|
419
412
|
}), !0);
|
|
420
|
-
}],
|
|
413
|
+
}], $e = v(({ options: e }) => {
|
|
421
414
|
let t = !1;
|
|
422
415
|
return {
|
|
423
416
|
key: "schemaMigration",
|
|
424
|
-
prosemirrorPlugins: [new
|
|
425
|
-
key: new
|
|
417
|
+
prosemirrorPlugins: [new C({
|
|
418
|
+
key: new Te("schemaMigration"),
|
|
426
419
|
appendTransaction: (n, r, i) => {
|
|
427
420
|
if (t || !n.some((e) => e.getMeta("y-sync$")) || n.every((e) => !e.docChanged) || !e.fragment.firstChild) return;
|
|
428
421
|
let a = i.tr;
|
|
429
|
-
for (let t of
|
|
422
|
+
for (let t of Qe) t(e.fragment, a);
|
|
430
423
|
if (t = !0, a.docChanged) return a;
|
|
431
424
|
}
|
|
432
425
|
})]
|
|
@@ -434,10 +427,10 @@ var qe = b(({ editor: e, options: t }) => {
|
|
|
434
427
|
});
|
|
435
428
|
//#endregion
|
|
436
429
|
//#region src/extensions/DropCursor/utils.ts
|
|
437
|
-
function
|
|
430
|
+
function et(e, t) {
|
|
438
431
|
return !e || !t ? !1 : !!e.closest(`.${t}`);
|
|
439
432
|
}
|
|
440
|
-
function
|
|
433
|
+
function tt(e, t, n, r, i) {
|
|
441
434
|
let a = e.state.doc.resolve(t.pos);
|
|
442
435
|
if (a.parent.inlineContent || t.orientation === "inline") return null;
|
|
443
436
|
let o = a.nodeBefore, s = a.nodeAfter;
|
|
@@ -464,7 +457,7 @@ function Xe(e, t, n, r, i) {
|
|
|
464
457
|
bottom: f + p
|
|
465
458
|
};
|
|
466
459
|
}
|
|
467
|
-
function
|
|
460
|
+
function nt(e, t, n, r) {
|
|
468
461
|
let i = e.coordsAtPos(t.pos), a = n / 2 * r;
|
|
469
462
|
return {
|
|
470
463
|
left: i.left - a,
|
|
@@ -473,10 +466,10 @@ function Ze(e, t, n, r) {
|
|
|
473
466
|
bottom: i.bottom
|
|
474
467
|
};
|
|
475
468
|
}
|
|
476
|
-
function
|
|
469
|
+
function rt(e, t) {
|
|
477
470
|
e.classList.toggle("prosemirror-dropcursor-inline", t === "inline"), e.classList.toggle("prosemirror-dropcursor-block-horizontal", t === "block-horizontal"), e.classList.toggle("prosemirror-dropcursor-block-vertical-left", t === "block-vertical-left"), e.classList.toggle("prosemirror-dropcursor-block-vertical-right", t === "block-vertical-right"), e.classList.toggle("prosemirror-dropcursor-block", t === "block-horizontal"), e.classList.toggle("prosemirror-dropcursor-vertical", t === "block-vertical-left" || t === "block-vertical-right");
|
|
478
471
|
}
|
|
479
|
-
function
|
|
472
|
+
function it(e) {
|
|
480
473
|
if (!e || e === document.body && getComputedStyle(e).position === "static") return {
|
|
481
474
|
parentLeft: -window.pageXOffset,
|
|
482
475
|
parentTop: -window.pageYOffset
|
|
@@ -489,7 +482,7 @@ function $e(e) {
|
|
|
489
482
|
}
|
|
490
483
|
//#endregion
|
|
491
484
|
//#region src/extensions/DropCursor/DropCursor.ts
|
|
492
|
-
var
|
|
485
|
+
var at = "bn-drag-exclude", ot = v(({ editor: e, options: t }) => {
|
|
493
486
|
let n = null, r = null, i = -1, a = null, o = {
|
|
494
487
|
width: t.dropCursor?.width ?? 5,
|
|
495
488
|
color: t.dropCursor?.color ?? "#ddeeff",
|
|
@@ -499,9 +492,9 @@ var et = "bn-drag-exclude", tt = b(({ editor: e, options: t }) => {
|
|
|
499
492
|
e?.pos === n?.pos && e?.orientation === n?.orientation || (n = e, e == null ? (r && r.parentNode && r.parentNode.removeChild(r), r = null) : c());
|
|
500
493
|
}, c = () => {
|
|
501
494
|
if (!n) return;
|
|
502
|
-
let t = e.prosemirrorView, i = t.dom, a = i.getBoundingClientRect(), s = a.width / i.offsetWidth, c = a.height / i.offsetHeight, l =
|
|
503
|
-
r || (r = u.appendChild(document.createElement("div")), r.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", o.color && (r.style.backgroundColor = o.color)),
|
|
504
|
-
let { parentLeft: d, parentTop: f } =
|
|
495
|
+
let t = e.prosemirrorView, i = t.dom, a = i.getBoundingClientRect(), s = a.width / i.offsetWidth, c = a.height / i.offsetHeight, l = tt(t, n, o.width, s, c) ?? nt(t, n, o.width, s), u = t.dom.offsetParent;
|
|
496
|
+
r || (r = u.appendChild(document.createElement("div")), r.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", o.color && (r.style.backgroundColor = o.color)), rt(r, n.orientation);
|
|
497
|
+
let { parentLeft: d, parentTop: f } = it(u);
|
|
505
498
|
r.style.left = (l.left - d) / s + "px", r.style.top = (l.top - f) / c + "px", r.style.width = (l.right - l.left) / s + "px", r.style.height = (l.bottom - l.top) / c + "px";
|
|
506
499
|
}, l = (e) => {
|
|
507
500
|
clearTimeout(i), i = window.setTimeout(() => s(null), e);
|
|
@@ -510,7 +503,7 @@ var et = "bn-drag-exclude", tt = b(({ editor: e, options: t }) => {
|
|
|
510
503
|
a = t.target instanceof Element ? t.target : null;
|
|
511
504
|
}, d = (t) => {
|
|
512
505
|
let n = t;
|
|
513
|
-
if (a &&
|
|
506
|
+
if (a && et(a, o.exclude) || n.target instanceof Element && et(n.target, o.exclude)) return;
|
|
514
507
|
let r = e.prosemirrorView;
|
|
515
508
|
if (!r.editable) return;
|
|
516
509
|
let i = r.posAtCoords({
|
|
@@ -520,7 +513,7 @@ var et = "bn-drag-exclude", tt = b(({ editor: e, options: t }) => {
|
|
|
520
513
|
if (i && !d) {
|
|
521
514
|
let t = i.pos;
|
|
522
515
|
if (r.dragging && r.dragging.slice) {
|
|
523
|
-
let e =
|
|
516
|
+
let e = se(r.state.doc, t, r.dragging.slice);
|
|
524
517
|
e != null && (t = e);
|
|
525
518
|
}
|
|
526
519
|
let a = !r.state.doc.resolve(t).parent.inlineContent, c = {
|
|
@@ -561,48 +554,12 @@ var et = "bn-drag-exclude", tt = b(({ editor: e, options: t }) => {
|
|
|
561
554
|
});
|
|
562
555
|
}
|
|
563
556
|
};
|
|
564
|
-
}),
|
|
565
|
-
let t = y(!1), n = () => e.transact((e) => {
|
|
566
|
-
if (e.selection.empty || e.selection instanceof ce && e.doc.textBetween(e.selection.from, e.selection.to).length === 0) return !1;
|
|
567
|
-
let t = !1;
|
|
568
|
-
return e.selection.content().content.descendants((e) => (e.type.spec.code && (t = !0), !t)), !t;
|
|
569
|
-
});
|
|
570
|
-
return {
|
|
571
|
-
key: "formattingToolbar",
|
|
572
|
-
store: t,
|
|
573
|
-
mount({ dom: r, signal: i }) {
|
|
574
|
-
let a = !1, o = !1, s = e.onChange(() => {
|
|
575
|
-
a || o || t.setState(n());
|
|
576
|
-
}), c = e.onSelectionChange(() => {
|
|
577
|
-
a || o || t.setState(n());
|
|
578
|
-
});
|
|
579
|
-
r.addEventListener("pointerdown", () => {
|
|
580
|
-
a = !0, t.setState(!1);
|
|
581
|
-
}, { signal: i }), e.prosemirrorView.root.addEventListener("pointerup", () => {
|
|
582
|
-
a = !1, e.isFocused() && t.setState(n());
|
|
583
|
-
}, {
|
|
584
|
-
signal: i,
|
|
585
|
-
capture: !0
|
|
586
|
-
}), r.addEventListener("pointercancel", () => {
|
|
587
|
-
a = !0;
|
|
588
|
-
}, {
|
|
589
|
-
signal: i,
|
|
590
|
-
capture: !0
|
|
591
|
-
}), e.prosemirrorView.root.addEventListener("dragstart", () => {
|
|
592
|
-
o = !0, t.setState(!1);
|
|
593
|
-
}, { signal: i }), e.prosemirrorView.root.addEventListener("dragend", () => {
|
|
594
|
-
o = !1;
|
|
595
|
-
}, { signal: i }), i.addEventListener("abort", () => {
|
|
596
|
-
s(), c();
|
|
597
|
-
});
|
|
598
|
-
}
|
|
599
|
-
};
|
|
600
|
-
}), rt = b(() => ({
|
|
557
|
+
}), st = v(() => ({
|
|
601
558
|
key: "history",
|
|
602
|
-
prosemirrorPlugins: [
|
|
603
|
-
undoCommand:
|
|
604
|
-
redoCommand:
|
|
605
|
-
})),
|
|
559
|
+
prosemirrorPlugins: [Pe()],
|
|
560
|
+
undoCommand: Ie,
|
|
561
|
+
redoCommand: Fe
|
|
562
|
+
})), ct = v(({ editor: e }) => {
|
|
606
563
|
function t(t) {
|
|
607
564
|
let n = e.prosemirrorView.nodeDOM(t);
|
|
608
565
|
for (; n && n.parentElement;) {
|
|
@@ -623,7 +580,7 @@ var et = "bn-drag-exclude", tt = b(({ editor: e, options: t }) => {
|
|
|
623
580
|
return n.text;
|
|
624
581
|
},
|
|
625
582
|
get position() {
|
|
626
|
-
return
|
|
583
|
+
return ue(e.prosemirrorView, n.from, n.to).toJSON();
|
|
627
584
|
}
|
|
628
585
|
};
|
|
629
586
|
}
|
|
@@ -649,7 +606,7 @@ var et = "bn-drag-exclude", tt = b(({ editor: e, options: t }) => {
|
|
|
649
606
|
e.deleteLink(t);
|
|
650
607
|
}
|
|
651
608
|
};
|
|
652
|
-
}),
|
|
609
|
+
}), lt = [
|
|
653
610
|
"http",
|
|
654
611
|
"https",
|
|
655
612
|
"ftp",
|
|
@@ -660,30 +617,30 @@ var et = "bn-drag-exclude", tt = b(({ editor: e, options: t }) => {
|
|
|
660
617
|
"sms",
|
|
661
618
|
"cid",
|
|
662
619
|
"xmpp"
|
|
663
|
-
],
|
|
620
|
+
], ut = "https", dt = new x("node-selection-keyboard"), ft = v(() => ({
|
|
664
621
|
key: "nodeSelectionKeyboard",
|
|
665
|
-
prosemirrorPlugins: [new
|
|
666
|
-
key:
|
|
622
|
+
prosemirrorPlugins: [new b({
|
|
623
|
+
key: dt,
|
|
667
624
|
props: { handleKeyDown: (e, t) => {
|
|
668
625
|
if ("node" in e.state.selection) {
|
|
669
626
|
if (t.ctrlKey || t.metaKey) return !1;
|
|
670
627
|
if (t.key.length === 1) return t.preventDefault(), !0;
|
|
671
628
|
if (t.key === "Enter" && !t.isComposing && !t.shiftKey && !t.altKey && !t.ctrlKey && !t.metaKey) {
|
|
672
629
|
let t = e.state.tr;
|
|
673
|
-
return e.dispatch(t.insert(e.state.tr.selection.$to.after(), e.state.schema.nodes.paragraph.createChecked()).setSelection(new
|
|
630
|
+
return e.dispatch(t.insert(e.state.tr.selection.$to.after(), e.state.schema.nodes.paragraph.createChecked()).setSelection(new fe(t.doc.resolve(e.state.tr.selection.$to.after() + 1)))), !0;
|
|
674
631
|
}
|
|
675
632
|
}
|
|
676
633
|
return !1;
|
|
677
634
|
} }
|
|
678
635
|
})]
|
|
679
|
-
})),
|
|
636
|
+
})), pt = new x("blocknote-placeholder"), mt = v(({ editor: e, options: t }) => {
|
|
680
637
|
let n = t.placeholders;
|
|
681
638
|
return {
|
|
682
639
|
key: "placeholder",
|
|
683
|
-
prosemirrorPlugins: [new
|
|
684
|
-
key:
|
|
640
|
+
prosemirrorPlugins: [new b({
|
|
641
|
+
key: pt,
|
|
685
642
|
view: (t) => {
|
|
686
|
-
let r = `placeholder-selector-${
|
|
643
|
+
let r = `placeholder-selector-${pe()}`;
|
|
687
644
|
t.dom.classList.add(r);
|
|
688
645
|
let i = document.createElement("style"), a = e._tiptapEditor.options.injectNonce;
|
|
689
646
|
a && i.setAttribute("nonce", a), t.root instanceof window.ShadowRoot ? t.root.append(i) : t.root.head.appendChild(i);
|
|
@@ -706,33 +663,33 @@ var et = "bn-drag-exclude", tt = b(({ editor: e, options: t }) => {
|
|
|
706
663
|
let { doc: n, selection: r } = t;
|
|
707
664
|
if (!e.isEditable || !r.empty || r.$from.parent.type.spec.code) return;
|
|
708
665
|
let i = [];
|
|
709
|
-
t.doc.content.size === 6 && i.push(
|
|
666
|
+
t.doc.content.size === 6 && i.push(w.node(2, 4, { "data-is-only-empty-block": "true" }));
|
|
710
667
|
let a = r.$anchor, o = a.parent;
|
|
711
668
|
if (o.content.size === 0) {
|
|
712
669
|
let e = a.before();
|
|
713
|
-
i.push(
|
|
670
|
+
i.push(w.node(e, e + o.nodeSize, { "data-is-empty-and-focused": "true" }));
|
|
714
671
|
}
|
|
715
|
-
return
|
|
672
|
+
return T.create(n, i);
|
|
716
673
|
} }
|
|
717
674
|
})]
|
|
718
675
|
};
|
|
719
|
-
}),
|
|
676
|
+
}), ht = new x("previous-blocks"), gt = {
|
|
720
677
|
index: "index",
|
|
721
678
|
level: "level",
|
|
722
679
|
type: "type",
|
|
723
680
|
depth: "depth",
|
|
724
681
|
"depth-change": "depth-change"
|
|
725
|
-
},
|
|
682
|
+
}, _t = v(() => {
|
|
726
683
|
let e;
|
|
727
684
|
return {
|
|
728
685
|
key: "previousBlockType",
|
|
729
|
-
prosemirrorPlugins: [new
|
|
730
|
-
key:
|
|
686
|
+
prosemirrorPlugins: [new b({
|
|
687
|
+
key: ht,
|
|
731
688
|
view(t) {
|
|
732
689
|
return {
|
|
733
690
|
update: async (t, n) => {
|
|
734
691
|
this.key?.getState(t.state).updatedBlocks.size > 0 && (e = setTimeout(() => {
|
|
735
|
-
t.dispatch(t.state.tr.setMeta(
|
|
692
|
+
t.dispatch(t.state.tr.setMeta(ht, { clearUpdate: !0 }));
|
|
736
693
|
}, 0));
|
|
737
694
|
},
|
|
738
695
|
destroy: () => {
|
|
@@ -755,7 +712,7 @@ var et = "bn-drag-exclude", tt = b(({ editor: e, options: t }) => {
|
|
|
755
712
|
let a = e.mapping.invert(), o = {
|
|
756
713
|
from: a.map(i.from, -1),
|
|
757
714
|
to: a.map(i.to, 1)
|
|
758
|
-
}, s = {}, c =
|
|
715
|
+
}, s = {}, c = le(n.doc, o, (e) => e.attrs.id), l = new Map(c.map((e) => [e.node.attrs.id, e])), u = le(r.doc, i, (e) => e.attrs.id);
|
|
759
716
|
for (let e of u) {
|
|
760
717
|
let i = l.get(e.node.attrs.id), a = i?.node.firstChild, o = e.node.firstChild;
|
|
761
718
|
if (i && a && o) {
|
|
@@ -783,16 +740,16 @@ var et = "bn-drag-exclude", tt = b(({ editor: e, options: t }) => {
|
|
|
783
740
|
return e.doc.descendants((e, r) => {
|
|
784
741
|
if (!e.attrs.id || !t.updatedBlocks.has(e.attrs.id)) return;
|
|
785
742
|
let i = t.currentTransactionOldBlockAttrs[e.attrs.id], a = {};
|
|
786
|
-
for (let [e, t] of Object.entries(i)) a["data-prev-" +
|
|
787
|
-
n.push(
|
|
788
|
-
}),
|
|
743
|
+
for (let [e, t] of Object.entries(i)) a["data-prev-" + gt[e]] = t || "none";
|
|
744
|
+
n.push(w.node(r, r + e.nodeSize, { ...a }));
|
|
745
|
+
}), T.create(e.doc, n);
|
|
789
746
|
} }
|
|
790
747
|
})]
|
|
791
748
|
};
|
|
792
749
|
});
|
|
793
750
|
//#endregion
|
|
794
751
|
//#region src/extensions/getDraggableBlockFromElement.ts
|
|
795
|
-
function
|
|
752
|
+
function vt(e, t) {
|
|
796
753
|
for (; e && e.parentElement && e.parentElement !== t.dom && e.getAttribute?.("data-node-type") !== "blockContainer";) e = e.parentElement;
|
|
797
754
|
if (e.getAttribute?.("data-node-type") === "blockContainer") return {
|
|
798
755
|
node: e,
|
|
@@ -800,69 +757,365 @@ function mt(e, t) {
|
|
|
800
757
|
};
|
|
801
758
|
}
|
|
802
759
|
//#endregion
|
|
803
|
-
//#region src/api/exporters/markdown/
|
|
804
|
-
function
|
|
805
|
-
let
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
760
|
+
//#region src/api/exporters/markdown/htmlToMarkdown.ts
|
|
761
|
+
function yt(e) {
|
|
762
|
+
let t = document.createElement("div");
|
|
763
|
+
return t.innerHTML = e, N(t, {
|
|
764
|
+
indent: "",
|
|
765
|
+
inListItem: !1
|
|
766
|
+
}).trim() + "\n";
|
|
767
|
+
}
|
|
768
|
+
function N(e, t) {
|
|
769
|
+
let n = "", r = Array.from(e.childNodes);
|
|
770
|
+
for (let e = 0; e < r.length; e++) {
|
|
771
|
+
let i = r[e];
|
|
772
|
+
n += P(i, t);
|
|
773
|
+
}
|
|
774
|
+
return n;
|
|
775
|
+
}
|
|
776
|
+
function P(e, t) {
|
|
777
|
+
if (e.nodeType === 3) return e.textContent || "";
|
|
778
|
+
if (e.nodeType !== 1) return "";
|
|
779
|
+
let n = e;
|
|
780
|
+
switch (n.tagName.toLowerCase()) {
|
|
781
|
+
case "p": return bt(n, t);
|
|
782
|
+
case "h1":
|
|
783
|
+
case "h2":
|
|
784
|
+
case "h3":
|
|
785
|
+
case "h4":
|
|
786
|
+
case "h5":
|
|
787
|
+
case "h6": return F(n, t);
|
|
788
|
+
case "blockquote": return xt(n, t);
|
|
789
|
+
case "pre": return St(n, t);
|
|
790
|
+
case "ul": return wt(n, t);
|
|
791
|
+
case "ol": return Tt(n, t);
|
|
792
|
+
case "table": return Dt(n, t);
|
|
793
|
+
case "hr": return t.indent + "***\n\n";
|
|
794
|
+
case "img": return kt(n, t);
|
|
795
|
+
case "video": return At(n, t);
|
|
796
|
+
case "audio": return jt(n, t);
|
|
797
|
+
case "embed": return Mt(n, t);
|
|
798
|
+
case "figure": return Nt(n, t);
|
|
799
|
+
case "a": return H(n, t);
|
|
800
|
+
case "details": return Lt(n, t);
|
|
801
|
+
case "div": return N(n, t);
|
|
802
|
+
case "br": return "";
|
|
803
|
+
default: return N(n, t);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
function bt(e, t) {
|
|
807
|
+
let n = zt(U(e));
|
|
808
|
+
return t.inListItem ? n : t.indent + n + "\n\n";
|
|
809
|
+
}
|
|
810
|
+
function F(e, t) {
|
|
811
|
+
let n = parseInt(e.tagName[1], 10), r = "#".repeat(n) + " ", i = U(e);
|
|
812
|
+
return t.indent + r + i + "\n\n";
|
|
813
|
+
}
|
|
814
|
+
function xt(e, t) {
|
|
815
|
+
let n = Array.from(e.children).filter((e) => {
|
|
816
|
+
let t = e.tagName.toLowerCase();
|
|
817
|
+
return [
|
|
818
|
+
"p",
|
|
819
|
+
"ul",
|
|
820
|
+
"ol",
|
|
821
|
+
"pre",
|
|
822
|
+
"blockquote",
|
|
823
|
+
"table",
|
|
824
|
+
"hr"
|
|
825
|
+
].includes(t);
|
|
826
|
+
}), r;
|
|
827
|
+
if (n.length > 0) {
|
|
828
|
+
let e = [];
|
|
829
|
+
for (let t of n) t.tagName.toLowerCase() === "p" ? e.push(U(t)) : e.push(P(t, {
|
|
830
|
+
indent: "",
|
|
831
|
+
inListItem: !1
|
|
832
|
+
}).trim());
|
|
833
|
+
r = e.join("\n\n");
|
|
834
|
+
} else r = U(e);
|
|
835
|
+
return r.split("\n").map((e) => t.indent + "> " + e).join("\n") + "\n\n";
|
|
836
|
+
}
|
|
837
|
+
function St(e, t) {
|
|
838
|
+
let n = e.querySelector("code");
|
|
839
|
+
if (!n) return "";
|
|
840
|
+
let r = n.getAttribute("data-language") || Ct(n.className) || "", i = I(n), a = Math.max(0, ...(i.match(/`+/g) ?? []).map((e) => e.length)), o = "`".repeat(Math.max(3, a + 1));
|
|
841
|
+
return i ? t.indent + o + r + "\n" + i + (i.endsWith("\n") ? "" : "\n") + o + "\n\n" : t.indent + o + r + "\n" + o + "\n\n";
|
|
842
|
+
}
|
|
843
|
+
function I(e) {
|
|
844
|
+
let t = "";
|
|
845
|
+
for (let n of Array.from(e.childNodes)) n.nodeType === 3 ? t += n.textContent || "" : n.nodeType === 1 && (n.tagName.toLowerCase() === "br" ? t += "\n" : t += I(n));
|
|
846
|
+
return t;
|
|
847
|
+
}
|
|
848
|
+
function Ct(e) {
|
|
849
|
+
let t = e.match(/language-(\S+)/);
|
|
850
|
+
return t ? t[1] : "";
|
|
851
|
+
}
|
|
852
|
+
function wt(e, t) {
|
|
853
|
+
let n = "", r = Array.from(e.children).filter((e) => e.tagName.toLowerCase() === "li");
|
|
854
|
+
for (let e of r) n += L(e, "bullet", t);
|
|
855
|
+
return t.inListItem || (n += "\n"), n;
|
|
856
|
+
}
|
|
857
|
+
function Tt(e, t) {
|
|
858
|
+
let n = "", r = Array.from(e.children).filter((e) => e.tagName.toLowerCase() === "li"), i = parseInt(e.getAttribute("start") || "1", 10);
|
|
859
|
+
for (let e = 0; e < r.length; e++) {
|
|
860
|
+
let a = i + e;
|
|
861
|
+
n += L(r[e], "ordered", t, a);
|
|
862
|
+
}
|
|
863
|
+
return t.inListItem || (n += "\n"), n;
|
|
864
|
+
}
|
|
865
|
+
function L(e, t, n, r) {
|
|
866
|
+
let i = null, a = null;
|
|
867
|
+
for (let t of Array.from(e.children)) {
|
|
868
|
+
let e = t.tagName.toLowerCase();
|
|
869
|
+
e === "input" && t.type === "checkbox" && (i = t), e === "details" && (a = t);
|
|
870
|
+
}
|
|
871
|
+
let o, s;
|
|
872
|
+
i ? (o = `* ${i.checked ? "[x]" : "[ ]"} `, s = 2) : t === "ordered" ? (o = `${r}. `, s = o.length) : (o = "* ", s = 2);
|
|
873
|
+
let c, l;
|
|
874
|
+
if (a) {
|
|
875
|
+
let e = a.querySelector("summary")?.querySelector("p");
|
|
876
|
+
l = a, c = e ? U(e) : "";
|
|
877
|
+
} else l = Et(e, i), c = l ? U(l) : "";
|
|
878
|
+
let u = n.indent + o + c + "\n", d = n.indent + " ".repeat(s), f = {
|
|
879
|
+
indent: d,
|
|
880
|
+
inListItem: !0
|
|
815
881
|
};
|
|
816
|
-
|
|
882
|
+
if (a) {
|
|
883
|
+
let e = a.querySelector("summary");
|
|
884
|
+
for (let t of Array.from(a.children)) if (t !== e) if (t.tagName.toLowerCase() === "p") {
|
|
885
|
+
let e = U(t);
|
|
886
|
+
u += "\n" + d + e + "\n";
|
|
887
|
+
} else u += P(t, f);
|
|
888
|
+
}
|
|
889
|
+
let p = Array.from(e.children);
|
|
890
|
+
for (let e of p) {
|
|
891
|
+
let t = e.tagName.toLowerCase();
|
|
892
|
+
if (!(e === l || e === i) && t !== "input") if (t === "ul" || t === "ol") u += P(e, f);
|
|
893
|
+
else if (t === "p") {
|
|
894
|
+
let t = U(e);
|
|
895
|
+
u += "\n" + d + t + "\n";
|
|
896
|
+
} else u += "\n" + P(e, f);
|
|
897
|
+
}
|
|
898
|
+
return u;
|
|
817
899
|
}
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
if (
|
|
823
|
-
|
|
824
|
-
|
|
900
|
+
function Et(e, t) {
|
|
901
|
+
for (let n of Array.from(e.children)) {
|
|
902
|
+
if (n === t || n.tagName.toLowerCase() === "input") continue;
|
|
903
|
+
let e = n.tagName.toLowerCase();
|
|
904
|
+
if (e === "p" || e === "span") return n;
|
|
905
|
+
}
|
|
906
|
+
return null;
|
|
907
|
+
}
|
|
908
|
+
function Dt(e, t) {
|
|
909
|
+
let n = e.querySelector("colgroup"), r = 0;
|
|
910
|
+
n && (r = n.querySelectorAll("col").length);
|
|
911
|
+
let i = [], a = !1, o = e.querySelectorAll("tr"), s = [];
|
|
912
|
+
o.forEach((e, t) => {
|
|
913
|
+
s[t] || (s[t] = []);
|
|
914
|
+
let n = e.querySelectorAll("th, td"), i = 0;
|
|
915
|
+
n.forEach((e) => {
|
|
916
|
+
for (; s[t][i] !== void 0;) i++;
|
|
917
|
+
t === 0 && e.tagName.toLowerCase() === "th" && (a = !0);
|
|
918
|
+
let n = Ot(U(e).trim()), r = parseInt(e.getAttribute("colspan") || "1", 10), o = parseInt(e.getAttribute("rowspan") || "1", 10);
|
|
919
|
+
for (let e = 0; e < o; e++) for (let a = 0; a < r; a++) {
|
|
920
|
+
let r = t + e;
|
|
921
|
+
s[r] || (s[r] = []), s[r][i + a] = e === 0 && a === 0 ? n : "";
|
|
922
|
+
}
|
|
923
|
+
i += r;
|
|
924
|
+
}), s[t] && (r = Math.max(r, s[t].length));
|
|
925
|
+
});
|
|
926
|
+
for (let e of s) {
|
|
927
|
+
let t = [];
|
|
928
|
+
for (let n = 0; n < r; n++) t.push(e && e[n] !== void 0 ? e[n] ?? "" : "");
|
|
929
|
+
i.push(t);
|
|
930
|
+
}
|
|
931
|
+
if (i.length === 0) return "";
|
|
932
|
+
let c = [];
|
|
933
|
+
for (let e = 0; e < r; e++) {
|
|
934
|
+
let t = 3;
|
|
935
|
+
for (let n of i) {
|
|
936
|
+
let r = e < n.length ? n[e].length : 0;
|
|
937
|
+
t = Math.max(t, r);
|
|
825
938
|
}
|
|
826
|
-
|
|
827
|
-
|
|
939
|
+
c.push(Math.max(t, 10));
|
|
940
|
+
}
|
|
941
|
+
let l = "";
|
|
942
|
+
if (a) {
|
|
943
|
+
l += t.indent + R(i[0], c, r) + "\n", l += t.indent + z(c, r) + "\n";
|
|
944
|
+
for (let e = 1; e < i.length; e++) l += t.indent + R(i[e], c, r) + "\n";
|
|
945
|
+
} else {
|
|
946
|
+
let e = Array(r).fill("");
|
|
947
|
+
l += t.indent + R(e, c, r) + "\n", l += t.indent + z(c, r) + "\n";
|
|
948
|
+
for (let e of i) l += t.indent + R(e, c, r) + "\n";
|
|
949
|
+
}
|
|
950
|
+
return l += "\n", l;
|
|
828
951
|
}
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
952
|
+
function Ot(e) {
|
|
953
|
+
return e.replace(/\|/g, "\\|");
|
|
954
|
+
}
|
|
955
|
+
function R(e, t, n) {
|
|
956
|
+
let r = [];
|
|
957
|
+
for (let i = 0; i < n; i++) {
|
|
958
|
+
let n = i < e.length ? e[i] : "";
|
|
959
|
+
r.push(" " + n.padEnd(t[i]) + " ");
|
|
960
|
+
}
|
|
961
|
+
return "|" + r.join("|") + "|";
|
|
962
|
+
}
|
|
963
|
+
function z(e, t) {
|
|
964
|
+
let n = [];
|
|
965
|
+
for (let r = 0; r < t; r++) n.push(" " + "-".repeat(e[r]) + " ");
|
|
966
|
+
return "|" + n.join("|") + "|";
|
|
967
|
+
}
|
|
968
|
+
function kt(e, t) {
|
|
969
|
+
let n = e.getAttribute("src") || "", r = e.getAttribute("alt") || "";
|
|
970
|
+
return n ? t.indent + `\n\n` : "\n\n";
|
|
971
|
+
}
|
|
972
|
+
function At(e, t) {
|
|
973
|
+
let n = e.getAttribute("src") || e.getAttribute("data-url") || "", r = e.getAttribute("data-name") || e.getAttribute("title") || "";
|
|
974
|
+
return n ? t.indent + `\n\n` : "\n\n";
|
|
975
|
+
}
|
|
976
|
+
function jt(e, t) {
|
|
977
|
+
let n = e.getAttribute("src") || "";
|
|
978
|
+
return n ? t.indent + `<audio src="${V(n)}" controls></audio>\n\n` : "\n\n";
|
|
979
|
+
}
|
|
980
|
+
function Mt(e, t) {
|
|
981
|
+
let n = e.getAttribute("src") || "";
|
|
982
|
+
return n ? t.indent + `[](${n})\n\n` : "\n\n";
|
|
983
|
+
}
|
|
984
|
+
function Nt(e, t) {
|
|
985
|
+
let n = e.querySelector("img"), r = e.querySelector("video"), i = e.querySelector("audio"), a = e.querySelector("a"), o = e.querySelector("figcaption")?.textContent?.trim() || "";
|
|
986
|
+
return n ? B("img", n.getAttribute("src") || "", n.getAttribute("alt") || "", o, t) : r ? B("video", r.getAttribute("src") || r.getAttribute("data-url") || "", r.getAttribute("data-name") || r.getAttribute("title") || "", o, t) : i ? B("audio", i.getAttribute("src") || "", "", o, t) : a ? H(a, t) : "";
|
|
987
|
+
}
|
|
988
|
+
function B(e, t, n, r, i) {
|
|
989
|
+
if (!t) return "";
|
|
990
|
+
if (!r && e !== "audio") return i.indent + `\n\n`;
|
|
991
|
+
let a = n && n !== r ? e === "img" ? ` alt="${V(n)}"` : e === "video" ? ` data-name="${V(n)}"` : "" : "", o = e === "img" ? `<img${a} src="${V(t)}">` : `<${e} src="${V(t)}"${a} controls></${e}>`, s = r ? `<figcaption>${Pt(r)}</figcaption>` : "";
|
|
992
|
+
return i.indent + `<figure>${o}${s}</figure>\n\n`;
|
|
993
|
+
}
|
|
994
|
+
function V(e) {
|
|
995
|
+
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
996
|
+
}
|
|
997
|
+
function Pt(e) {
|
|
998
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
999
|
+
}
|
|
1000
|
+
function H(e, t) {
|
|
1001
|
+
let n = e.getAttribute("href") || "", r = e.textContent?.trim() || "";
|
|
1002
|
+
return n ? t.indent + Ft(r, n) + "\n\n" : t.indent + r + "\n\n";
|
|
1003
|
+
}
|
|
1004
|
+
function Ft(e, t) {
|
|
1005
|
+
return !e || e === t ? t : `[${e}](${It(t)})`;
|
|
1006
|
+
}
|
|
1007
|
+
function It(e) {
|
|
1008
|
+
return e.replace(/[\\()]/g, "\\$&");
|
|
1009
|
+
}
|
|
1010
|
+
function Lt(e, t) {
|
|
1011
|
+
let n = e.querySelector("summary");
|
|
1012
|
+
if (!n) return N(e, t);
|
|
1013
|
+
let r = n.querySelector("h1, h2, h3, h4, h5, h6");
|
|
1014
|
+
if (r) {
|
|
1015
|
+
let i = F(r, t);
|
|
1016
|
+
for (let r of Array.from(e.children)) r !== n && (i += P(r, t));
|
|
1017
|
+
return i;
|
|
1018
|
+
}
|
|
1019
|
+
return N(n, t);
|
|
1020
|
+
}
|
|
1021
|
+
function U(e) {
|
|
1022
|
+
let t = "";
|
|
1023
|
+
for (let n of Array.from(e.childNodes)) if (n.nodeType === 3) t += n.textContent || "";
|
|
1024
|
+
else if (n.nodeType === 1) {
|
|
1025
|
+
let e = n;
|
|
1026
|
+
switch (e.tagName.toLowerCase()) {
|
|
1027
|
+
case "strong":
|
|
1028
|
+
case "b": {
|
|
1029
|
+
let { content: n, trailing: r } = Rt(U(e));
|
|
1030
|
+
n ? t += `**${n}**${r}` : t += r;
|
|
1031
|
+
break;
|
|
840
1032
|
}
|
|
841
|
-
|
|
1033
|
+
case "em":
|
|
1034
|
+
case "i": {
|
|
1035
|
+
let { content: n, trailing: r } = Rt(U(e));
|
|
1036
|
+
n ? t += `*${n}*${r}` : t += r;
|
|
1037
|
+
break;
|
|
1038
|
+
}
|
|
1039
|
+
case "s":
|
|
1040
|
+
case "del":
|
|
1041
|
+
t += `~~${U(e)}~~`;
|
|
1042
|
+
break;
|
|
1043
|
+
case "code": {
|
|
1044
|
+
let n = e.textContent || "", r = Math.max(0, ...(n.match(/`+/g) ?? []).map((e) => e.length)), i = "`".repeat(r + 1), a = n.startsWith("`") || n.endsWith("`");
|
|
1045
|
+
t += i + (a ? ` ${n} ` : n) + i;
|
|
1046
|
+
break;
|
|
1047
|
+
}
|
|
1048
|
+
case "u":
|
|
1049
|
+
t += U(e);
|
|
1050
|
+
break;
|
|
1051
|
+
case "a": {
|
|
1052
|
+
let n = e.getAttribute("href") || "", r = U(e);
|
|
1053
|
+
t += Ft(r, n);
|
|
1054
|
+
break;
|
|
1055
|
+
}
|
|
1056
|
+
case "br":
|
|
1057
|
+
t += "\\\n";
|
|
1058
|
+
break;
|
|
1059
|
+
case "span":
|
|
1060
|
+
t += U(e);
|
|
1061
|
+
break;
|
|
1062
|
+
case "img": {
|
|
1063
|
+
let n = e.getAttribute("src") || "", r = e.getAttribute("alt") || "";
|
|
1064
|
+
t += ``;
|
|
1065
|
+
break;
|
|
1066
|
+
}
|
|
1067
|
+
case "video": {
|
|
1068
|
+
let n = e.getAttribute("src") || e.getAttribute("data-url") || "", r = e.getAttribute("data-name") || e.getAttribute("title") || "";
|
|
1069
|
+
t += ``;
|
|
1070
|
+
break;
|
|
1071
|
+
}
|
|
1072
|
+
case "p":
|
|
1073
|
+
t += U(e);
|
|
1074
|
+
break;
|
|
1075
|
+
case "input": break;
|
|
1076
|
+
default:
|
|
1077
|
+
t += U(e);
|
|
1078
|
+
break;
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
return t;
|
|
1082
|
+
}
|
|
1083
|
+
function Rt(e) {
|
|
1084
|
+
let t = e.match(/^(.*?)(\s*)$/);
|
|
1085
|
+
return t ? {
|
|
1086
|
+
content: t[1],
|
|
1087
|
+
trailing: t[2]
|
|
1088
|
+
} : {
|
|
1089
|
+
content: e,
|
|
1090
|
+
trailing: ""
|
|
842
1091
|
};
|
|
843
1092
|
}
|
|
1093
|
+
function zt(e) {
|
|
1094
|
+
let t = e.replace(/^(\\\n)+/, "");
|
|
1095
|
+
return t = t.replace(/(\\\n)+$/, ""), t;
|
|
1096
|
+
}
|
|
844
1097
|
//#endregion
|
|
845
1098
|
//#region src/api/exporters/markdown/markdownExporter.ts
|
|
846
|
-
function
|
|
847
|
-
return
|
|
1099
|
+
function W(e) {
|
|
1100
|
+
return yt(e);
|
|
848
1101
|
}
|
|
849
|
-
function
|
|
850
|
-
return
|
|
1102
|
+
function Bt(e, t, n, r) {
|
|
1103
|
+
return W(O(t, n).exportBlocks(e, r));
|
|
851
1104
|
}
|
|
852
1105
|
//#endregion
|
|
853
1106
|
//#region src/api/nodeConversions/fragmentToBlocks.ts
|
|
854
|
-
function
|
|
1107
|
+
function Vt(e) {
|
|
855
1108
|
let t = [];
|
|
856
1109
|
return e.descendants((e) => {
|
|
857
|
-
let n =
|
|
1110
|
+
let n = m(e);
|
|
858
1111
|
return e.type.name === "blockContainer" && e.firstChild?.type.name === "blockGroup" ? !0 : e.type.name === "columnList" && e.childCount === 1 ? (e.firstChild?.forEach((e) => {
|
|
859
|
-
t.push(
|
|
860
|
-
}), !1) : e.type.isInGroup("bnBlock") ? (t.push(
|
|
1112
|
+
t.push(p(e, n));
|
|
1113
|
+
}), !1) : e.type.isInGroup("bnBlock") ? (t.push(p(e, n)), !1) : !0;
|
|
861
1114
|
}), t;
|
|
862
1115
|
}
|
|
863
1116
|
//#endregion
|
|
864
1117
|
//#region src/extensions/SideMenu/MultipleNodeSelection.ts
|
|
865
|
-
var
|
|
1118
|
+
var G = class e extends S {
|
|
866
1119
|
nodes;
|
|
867
1120
|
constructor(e, t) {
|
|
868
1121
|
super(e, t);
|
|
@@ -875,7 +1128,7 @@ var K = class e extends E {
|
|
|
875
1128
|
return new e(t.resolve(n), t.resolve(r));
|
|
876
1129
|
}
|
|
877
1130
|
content() {
|
|
878
|
-
return new
|
|
1131
|
+
return new oe(y.from(this.nodes), 0, 0);
|
|
879
1132
|
}
|
|
880
1133
|
eq(t) {
|
|
881
1134
|
if (!(t instanceof e) || this.nodes.length !== t.nodes.length || this.from !== t.from || this.to !== t.to) return !1;
|
|
@@ -884,7 +1137,7 @@ var K = class e extends E {
|
|
|
884
1137
|
}
|
|
885
1138
|
map(t, n) {
|
|
886
1139
|
let r = n.mapResult(this.from), i = n.mapResult(this.to);
|
|
887
|
-
return i.deleted ?
|
|
1140
|
+
return i.deleted ? S.near(t.resolve(r.pos)) : r.deleted ? S.near(t.resolve(i.pos)) : new e(t.resolve(r.pos), t.resolve(i.pos));
|
|
888
1141
|
}
|
|
889
1142
|
toJSON() {
|
|
890
1143
|
return {
|
|
@@ -894,11 +1147,11 @@ var K = class e extends E {
|
|
|
894
1147
|
};
|
|
895
1148
|
}
|
|
896
1149
|
};
|
|
897
|
-
|
|
1150
|
+
S.jsonID("multiple-node", G);
|
|
898
1151
|
//#endregion
|
|
899
1152
|
//#region src/extensions/SideMenu/dragging.ts
|
|
900
|
-
var
|
|
901
|
-
function
|
|
1153
|
+
var K;
|
|
1154
|
+
function Ht(e, t) {
|
|
902
1155
|
let n, r, i = t.resolve(e.from).node().type.spec.group === "blockContent", a = t.resolve(e.to).node().type.spec.group === "blockContent", o = Math.min(e.$anchor.depth, e.$head.depth);
|
|
903
1156
|
if (i && a) {
|
|
904
1157
|
let i = e.$from.start(o - 1), a = e.$to.end(o - 1);
|
|
@@ -909,56 +1162,51 @@ function bt(e, t) {
|
|
|
909
1162
|
to: r
|
|
910
1163
|
};
|
|
911
1164
|
}
|
|
912
|
-
function
|
|
1165
|
+
function Ut(e, t, n = t) {
|
|
913
1166
|
t === n && (n += e.state.doc.resolve(t + 1).node().nodeSize);
|
|
914
1167
|
let r = e.domAtPos(t).node.cloneNode(!0), i = e.domAtPos(t).node, a = (e, t) => Array.prototype.indexOf.call(e.children, t), o = a(i, e.domAtPos(t + 1).node.parentElement), s = a(i, e.domAtPos(n - 1).node.parentElement);
|
|
915
1168
|
for (let e = i.childElementCount - 1; e >= 0; e--) (e > s || e < o) && r.removeChild(r.children[e]);
|
|
916
|
-
|
|
917
|
-
let c =
|
|
918
|
-
|
|
919
|
-
let t = c[e], n = t.parentElement;
|
|
920
|
-
n && n.removeChild(t);
|
|
921
|
-
}
|
|
922
|
-
let l = e.dom.className.split(" ").filter((e) => e !== "ProseMirror" && e !== "bn-root" && e !== "bn-editor").join(" ");
|
|
923
|
-
q.className = q.className + " bn-drag-preview " + l, e.root instanceof ShadowRoot ? e.root.appendChild(q) : e.root.body.appendChild(q);
|
|
1169
|
+
Wt(e.root), K = r, K.querySelectorAll("iframe, embed, object").forEach((e) => e.parentElement?.removeChild(e));
|
|
1170
|
+
let c = e.dom.className.split(" ").filter((e) => e !== "ProseMirror" && e !== "bn-root" && e !== "bn-editor").join(" ");
|
|
1171
|
+
K.className = K.className + " bn-drag-preview " + c, e.root instanceof ShadowRoot ? e.root.appendChild(K) : e.root.body.appendChild(K);
|
|
924
1172
|
}
|
|
925
|
-
function
|
|
926
|
-
|
|
1173
|
+
function Wt(e) {
|
|
1174
|
+
K !== void 0 && (e instanceof ShadowRoot ? e.removeChild(K) : e.body.removeChild(K), K = void 0);
|
|
927
1175
|
}
|
|
928
|
-
function
|
|
929
|
-
if (!e.dataTransfer ||
|
|
930
|
-
let i =
|
|
1176
|
+
function Gt(e, t, r) {
|
|
1177
|
+
if (!e.dataTransfer || r.headless) return;
|
|
1178
|
+
let i = r.prosemirrorView, a = n(t.id, i.state.doc);
|
|
931
1179
|
if (!a) throw Error(`Block with ID ${t.id} not found`);
|
|
932
1180
|
let o = a.posBeforeNode;
|
|
933
1181
|
if (o != null) {
|
|
934
|
-
let t = i.state.selection,
|
|
935
|
-
c && l ? (i.dispatch(i.state.tr.setSelection(
|
|
936
|
-
let u = i.state.selection.content(), d =
|
|
937
|
-
e.dataTransfer.clearData(), e.dataTransfer.setData("blocknote/html", f), e.dataTransfer.setData("text/html", h), e.dataTransfer.setData("text/plain", g), e.dataTransfer.effectAllowed = "move", e.dataTransfer.setDragImage(
|
|
1182
|
+
let t = i.state.selection, n = i.state.doc, { from: a, to: s } = Ht(t, n), c = a <= o && o < s, l = t.$anchor.node() !== t.$head.node() || t instanceof G;
|
|
1183
|
+
c && l ? (i.dispatch(i.state.tr.setSelection(G.create(n, a, s))), Ut(i, a, s)) : (i.dispatch(i.state.tr.setSelection(de.create(i.state.doc, o))), Ut(i, o));
|
|
1184
|
+
let u = i.state.selection.content(), d = r.pmSchema, f = i.serializeForClipboard(u).dom.innerHTML, p = O(d, r), m = Vt(u.content), h = p.exportBlocks(m, {}), g = W(h);
|
|
1185
|
+
e.dataTransfer.clearData(), e.dataTransfer.setData("blocknote/html", f), e.dataTransfer.setData("text/html", h), e.dataTransfer.setData("text/plain", g), e.dataTransfer.effectAllowed = "move", e.dataTransfer.setDragImage(K, 0, 0);
|
|
938
1186
|
}
|
|
939
1187
|
}
|
|
940
1188
|
//#endregion
|
|
941
1189
|
//#region src/extensions/SideMenu/SideMenu.ts
|
|
942
|
-
var
|
|
943
|
-
function
|
|
1190
|
+
var Kt = 250;
|
|
1191
|
+
function q(e, t, n = !0) {
|
|
944
1192
|
let r = e.root.elementsFromPoint(t.left, t.top);
|
|
945
|
-
for (let i of r) if (e.dom.contains(i)) return n && i.closest("[data-node-type=columnList]") ?
|
|
1193
|
+
for (let i of r) if (e.dom.contains(i)) return n && i.closest("[data-node-type=columnList]") ? q(e, {
|
|
946
1194
|
left: t.left + 50,
|
|
947
1195
|
top: t.top
|
|
948
|
-
}, !1) :
|
|
1196
|
+
}, !1) : vt(i, e);
|
|
949
1197
|
}
|
|
950
|
-
function
|
|
1198
|
+
function qt(e, t) {
|
|
951
1199
|
if (!t.dom.firstChild) return;
|
|
952
|
-
let n = t.dom.firstChild.getBoundingClientRect(), r =
|
|
1200
|
+
let n = t.dom.firstChild.getBoundingClientRect(), r = q(t, {
|
|
953
1201
|
left: Math.min(Math.max(n.left + 10, e.x), n.right - 10),
|
|
954
1202
|
top: e.y
|
|
955
1203
|
});
|
|
956
|
-
if (r) return
|
|
1204
|
+
if (r) return q(t, {
|
|
957
1205
|
left: r.node.getBoundingClientRect().right - 10,
|
|
958
1206
|
top: e.y
|
|
959
1207
|
}, !1);
|
|
960
1208
|
}
|
|
961
|
-
var
|
|
1209
|
+
var J = class {
|
|
962
1210
|
state;
|
|
963
1211
|
emitUpdate;
|
|
964
1212
|
mousePos;
|
|
@@ -980,11 +1228,11 @@ var Et = class {
|
|
|
980
1228
|
clientX: this.mousePos.x,
|
|
981
1229
|
clientY: this.mousePos.y
|
|
982
1230
|
});
|
|
983
|
-
if (e?.element !== this.pmView.dom || e.distance >
|
|
1231
|
+
if (e?.element !== this.pmView.dom || e.distance > Kt) {
|
|
984
1232
|
this.state?.show && (this.state.show = !1, this.updateState(this.state));
|
|
985
1233
|
return;
|
|
986
1234
|
}
|
|
987
|
-
let t =
|
|
1235
|
+
let t = qt(this.mousePos, this.pmView);
|
|
988
1236
|
if (!t || !this.editor.isEditable) {
|
|
989
1237
|
this.state?.show && (this.state.show = !1, this.updateState(this.state));
|
|
990
1238
|
return;
|
|
@@ -1003,9 +1251,9 @@ var Et = class {
|
|
|
1003
1251
|
if (!t || this.pmView.dragging) return;
|
|
1004
1252
|
let n = document.createElement("div");
|
|
1005
1253
|
n.innerHTML = t;
|
|
1006
|
-
let r =
|
|
1254
|
+
let r = me.fromSchema(this.pmView.state.schema).parse(n, { topNode: this.pmView.state.schema.nodes.blockGroup.create() });
|
|
1007
1255
|
this.pmView.dragging = {
|
|
1008
|
-
slice: new
|
|
1256
|
+
slice: new he(r.content, 0, 0),
|
|
1009
1257
|
move: !0
|
|
1010
1258
|
};
|
|
1011
1259
|
};
|
|
@@ -1037,7 +1285,7 @@ var Et = class {
|
|
|
1037
1285
|
getDragEventContext = (e) => {
|
|
1038
1286
|
if (!(this.pmView.dragging !== null || this.isDragOrigin || e.dataTransfer?.types.includes("blocknote/html") || e.target instanceof Node && this.pmView.dom.contains(e.target))) return;
|
|
1039
1287
|
let t = !e.dataTransfer?.types.includes("blocknote/html") && !!this.pmView.dragging, n = !!this.isDragOrigin, r = t || n, i = this.findClosestEditorElement(e);
|
|
1040
|
-
if (!i || i.distance >
|
|
1288
|
+
if (!i || i.distance > Kt) return;
|
|
1041
1289
|
let a = i.element === this.pmView.dom, o = a && i.distance === 0;
|
|
1042
1290
|
if (!(!a && !r)) return {
|
|
1043
1291
|
isDropPoint: a,
|
|
@@ -1055,7 +1303,7 @@ var Et = class {
|
|
|
1055
1303
|
let { isDropPoint: n, isDropWithinEditorBounds: r, isDragOrigin: i } = t;
|
|
1056
1304
|
if (!r && n && this.dispatchSyntheticEvent(e), n) {
|
|
1057
1305
|
if (this.pmView.dragging) return;
|
|
1058
|
-
this.pmView.dispatch(this.pmView.state.tr.setSelection(
|
|
1306
|
+
this.pmView.dispatch(this.pmView.state.tr.setSelection(Ee.create(this.pmView.state.tr.doc, this.pmView.state.tr.selection.anchor)));
|
|
1059
1307
|
return;
|
|
1060
1308
|
} else if (i) {
|
|
1061
1309
|
setTimeout(() => this.pmView.dispatch(this.pmView.state.tr.deleteSelection()), 0);
|
|
@@ -1091,22 +1339,22 @@ var Et = class {
|
|
|
1091
1339
|
destroy() {
|
|
1092
1340
|
this.state?.show && (this.state.show = !1, this.emitUpdate(this.state)), this.pmView.root.removeEventListener("mousemove", this.onMouseMove, !0), this.pmView.root.removeEventListener("dragstart", this.onDragStart), this.pmView.root.removeEventListener("dragover", this.onDragOver), this.pmView.root.removeEventListener("drop", this.onDrop, !0), this.pmView.root.removeEventListener("dragend", this.onDragEnd, !0), this.pmView.root.removeEventListener("keydown", this.onKeyDown, !0);
|
|
1093
1341
|
}
|
|
1094
|
-
},
|
|
1095
|
-
let t, n =
|
|
1342
|
+
}, Jt = new Te("SideMenuPlugin"), Yt = v(({ editor: e }) => {
|
|
1343
|
+
let t, n = _(void 0);
|
|
1096
1344
|
return {
|
|
1097
1345
|
key: "sideMenu",
|
|
1098
1346
|
store: n,
|
|
1099
|
-
prosemirrorPlugins: [new
|
|
1100
|
-
key:
|
|
1101
|
-
view: (r) => (t = new
|
|
1347
|
+
prosemirrorPlugins: [new C({
|
|
1348
|
+
key: Jt,
|
|
1349
|
+
view: (r) => (t = new J(e, r, (e) => {
|
|
1102
1350
|
n.setState({ ...e });
|
|
1103
1351
|
}), t)
|
|
1104
1352
|
})],
|
|
1105
1353
|
blockDragStart(n, r) {
|
|
1106
|
-
t && (t.isDragOrigin = !0),
|
|
1354
|
+
t && (t.isDragOrigin = !0), Gt(n, r, e);
|
|
1107
1355
|
},
|
|
1108
1356
|
blockDragEnd() {
|
|
1109
|
-
|
|
1357
|
+
Wt(e.prosemirrorView.root), t && (t.isDragOrigin = !1), e.blur();
|
|
1110
1358
|
},
|
|
1111
1359
|
freezeMenu() {
|
|
1112
1360
|
t.menuFrozen = !0, t.state.show = !0, t.emitUpdate(t.state);
|
|
@@ -1119,7 +1367,7 @@ var Et = class {
|
|
|
1119
1367
|
}
|
|
1120
1368
|
};
|
|
1121
1369
|
}), Y;
|
|
1122
|
-
async function
|
|
1370
|
+
async function Xt() {
|
|
1123
1371
|
return Y || (Y = (async () => {
|
|
1124
1372
|
let [e, t] = await Promise.all([import("emoji-mart"), import("@emoji-mart/data")]), n = "default" in e ? e.default : e, r = "default" in t ? t.default : t;
|
|
1125
1373
|
return await n.init({ data: r }), {
|
|
@@ -1128,9 +1376,9 @@ async function kt() {
|
|
|
1128
1376
|
};
|
|
1129
1377
|
})(), Y);
|
|
1130
1378
|
}
|
|
1131
|
-
async function
|
|
1132
|
-
if (!("text" in e.schema.inlineContentSchema) || e.schema.inlineContentSchema.text !==
|
|
1133
|
-
let { emojiData: n, emojiMart: r } = await
|
|
1379
|
+
async function Zt(e, t) {
|
|
1380
|
+
if (!("text" in e.schema.inlineContentSchema) || e.schema.inlineContentSchema.text !== ne.text) return [];
|
|
1381
|
+
let { emojiData: n, emojiMart: r } = await Xt();
|
|
1134
1382
|
return (t.trim() === "" ? Object.values(n.emojis) : await r.SearchIndex.search(t)).map((t) => ({
|
|
1135
1383
|
id: t.skins[0].native,
|
|
1136
1384
|
onItemClick: () => e.insertInlineContent(t.skins[0].native + " ")
|
|
@@ -1139,16 +1387,16 @@ async function At(e, t) {
|
|
|
1139
1387
|
//#endregion
|
|
1140
1388
|
//#region src/extensions/TableHandles/TableHandles.ts
|
|
1141
1389
|
var X;
|
|
1142
|
-
function
|
|
1390
|
+
function Qt(e) {
|
|
1143
1391
|
X || (X = document.createElement("div"), X.innerHTML = "_", X.style.opacity = "0", X.style.height = "1px", X.style.width = "1px", e instanceof Document ? e.body.appendChild(X) : e.appendChild(X));
|
|
1144
1392
|
}
|
|
1145
|
-
function
|
|
1393
|
+
function $t(e) {
|
|
1146
1394
|
X &&= (e instanceof Document ? e.body.removeChild(X) : e.removeChild(X), void 0);
|
|
1147
1395
|
}
|
|
1148
1396
|
function Z(e) {
|
|
1149
1397
|
return Array.prototype.indexOf.call(e.parentElement.childNodes, e);
|
|
1150
1398
|
}
|
|
1151
|
-
function
|
|
1399
|
+
function en(e) {
|
|
1152
1400
|
let t = e;
|
|
1153
1401
|
for (; t && t.nodeName !== "TD" && t.nodeName !== "TH" && !t.classList.contains("tableWrapper");) {
|
|
1154
1402
|
if (t.classList.contains("ProseMirror")) return;
|
|
@@ -1166,11 +1414,11 @@ function Nt(e) {
|
|
|
1166
1414
|
tbodyNode: t.querySelector("tbody")
|
|
1167
1415
|
};
|
|
1168
1416
|
}
|
|
1169
|
-
function
|
|
1417
|
+
function tn(e, t) {
|
|
1170
1418
|
let n = t.querySelectorAll(e);
|
|
1171
1419
|
for (let e = 0; e < n.length; e++) n[e].style.visibility = "hidden";
|
|
1172
1420
|
}
|
|
1173
|
-
var
|
|
1421
|
+
var nn = class {
|
|
1174
1422
|
state;
|
|
1175
1423
|
emitUpdate;
|
|
1176
1424
|
tableId;
|
|
@@ -1193,7 +1441,7 @@ var Ft = class {
|
|
|
1193
1441
|
};
|
|
1194
1442
|
mouseMoveHandler = (e) => {
|
|
1195
1443
|
if (this.menuFrozen || this.mouseState === "selecting" || !(e.target instanceof Element) || !this.pmView.dom.contains(e.target)) return;
|
|
1196
|
-
let t =
|
|
1444
|
+
let t = en(e.target);
|
|
1197
1445
|
if (t?.type === "cell" && this.mouseState === "down" && !this.state?.draggingState) {
|
|
1198
1446
|
this.mouseState = "selecting", this.state?.show && (this.state.show = !1, this.state.showAddOrRemoveRowsButton = !1, this.state.showAddOrRemoveColumnsButton = !1, this.emitUpdate());
|
|
1199
1447
|
return;
|
|
@@ -1203,23 +1451,23 @@ var Ft = class {
|
|
|
1203
1451
|
return;
|
|
1204
1452
|
}
|
|
1205
1453
|
if (!t.tbodyNode) return;
|
|
1206
|
-
let
|
|
1454
|
+
let r = t.tbodyNode.getBoundingClientRect(), i = vt(t.domNode, this.pmView);
|
|
1207
1455
|
if (!i) return;
|
|
1208
1456
|
this.tableElement = i.node;
|
|
1209
|
-
let a, o = this.editor.transact((e) =>
|
|
1457
|
+
let a, o = this.editor.transact((e) => n(i.id, e.doc));
|
|
1210
1458
|
if (!o) throw Error(`Block with ID ${i.id} not found`);
|
|
1211
|
-
let s =
|
|
1459
|
+
let s = p(o.node, this.editor.pmSchema, this.editor.schema.blockSchema, this.editor.schema.inlineContentSchema, this.editor.schema.styleSchema);
|
|
1212
1460
|
if (h(this.editor, "table") && (this.tablePos = o.posBeforeNode + 1, a = s), !a) return;
|
|
1213
1461
|
this.tableId = i.id;
|
|
1214
1462
|
let c = t.domNode.closest(".tableWrapper")?.querySelector(".table-widgets-container");
|
|
1215
1463
|
if (t?.type === "wrapper") {
|
|
1216
|
-
let t = e.clientY >=
|
|
1464
|
+
let t = e.clientY >= r.bottom - 1 && e.clientY < r.bottom + 20, n = e.clientX >= r.right - 1 && e.clientX < r.right + 20, i = this.state?.block.id !== a.id || e.clientX > r.right || e.clientY > r.bottom;
|
|
1217
1465
|
this.state = {
|
|
1218
1466
|
...this.state,
|
|
1219
1467
|
show: !0,
|
|
1220
1468
|
showAddOrRemoveRowsButton: t,
|
|
1221
|
-
showAddOrRemoveColumnsButton:
|
|
1222
|
-
referencePosTable:
|
|
1469
|
+
showAddOrRemoveColumnsButton: n,
|
|
1470
|
+
referencePosTable: r,
|
|
1223
1471
|
block: a,
|
|
1224
1472
|
widgetContainer: c,
|
|
1225
1473
|
colIndex: i ? void 0 : this.state?.colIndex,
|
|
@@ -1227,18 +1475,18 @@ var Ft = class {
|
|
|
1227
1475
|
referencePosCell: i ? void 0 : this.state?.referencePosCell
|
|
1228
1476
|
};
|
|
1229
1477
|
} else {
|
|
1230
|
-
let e = Z(t.domNode),
|
|
1231
|
-
if (this.state !== void 0 && this.state.show && this.tableId === i.id && this.state.rowIndex ===
|
|
1478
|
+
let e = Z(t.domNode), n = Z(t.domNode.parentElement), o = t.domNode.getBoundingClientRect();
|
|
1479
|
+
if (this.state !== void 0 && this.state.show && this.tableId === i.id && this.state.rowIndex === n && this.state.colIndex === e) return;
|
|
1232
1480
|
this.state = {
|
|
1233
1481
|
show: !0,
|
|
1234
1482
|
showAddOrRemoveColumnsButton: e === a.content.rows[0].cells.length - 1,
|
|
1235
|
-
showAddOrRemoveRowsButton:
|
|
1236
|
-
referencePosTable:
|
|
1483
|
+
showAddOrRemoveRowsButton: n === a.content.rows.length - 1,
|
|
1484
|
+
referencePosTable: r,
|
|
1237
1485
|
block: a,
|
|
1238
1486
|
draggingState: void 0,
|
|
1239
1487
|
referencePosCell: o,
|
|
1240
1488
|
colIndex: e,
|
|
1241
|
-
rowIndex:
|
|
1489
|
+
rowIndex: n,
|
|
1242
1490
|
widgetContainer: c
|
|
1243
1491
|
};
|
|
1244
1492
|
}
|
|
@@ -1246,7 +1494,7 @@ var Ft = class {
|
|
|
1246
1494
|
};
|
|
1247
1495
|
dragOverHandler = (e) => {
|
|
1248
1496
|
if (this.state?.draggingState === void 0) return;
|
|
1249
|
-
e.preventDefault(), e.dataTransfer.dropEffect = "move",
|
|
1497
|
+
e.preventDefault(), e.dataTransfer.dropEffect = "move", tn(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline", this.pmView.root);
|
|
1250
1498
|
let t = {
|
|
1251
1499
|
left: Math.min(Math.max(e.clientX, this.state.referencePosTable.left + 1), this.state.referencePosTable.right - 1),
|
|
1252
1500
|
top: Math.min(Math.max(e.clientY, this.state.referencePosTable.top + 1), this.state.referencePosTable.bottom - 1)
|
|
@@ -1261,12 +1509,12 @@ var Ft = class {
|
|
|
1261
1509
|
if (this.mouseState = "up", this.state === void 0 || this.state.draggingState === void 0) return !1;
|
|
1262
1510
|
if (this.state.rowIndex === void 0 || this.state.colIndex === void 0) throw Error("Attempted to drop table row or column, but no table block was hovered prior.");
|
|
1263
1511
|
e.preventDefault();
|
|
1264
|
-
let { draggingState: n, colIndex:
|
|
1512
|
+
let { draggingState: n, colIndex: i, rowIndex: a } = this.state;
|
|
1265
1513
|
this.state.draggingState = void 0;
|
|
1266
|
-
let
|
|
1514
|
+
let o = this.state.block.content.columnWidths;
|
|
1267
1515
|
if (n.draggedCellOrientation === "row") {
|
|
1268
|
-
if (!
|
|
1269
|
-
let e =
|
|
1516
|
+
if (!r(this.state.block, n.originalIndex, a)) return !1;
|
|
1517
|
+
let e = d(this.state.block, n.originalIndex, a);
|
|
1270
1518
|
this.editor.updateBlock(this.state.block, {
|
|
1271
1519
|
type: "table",
|
|
1272
1520
|
content: {
|
|
@@ -1275,13 +1523,13 @@ var Ft = class {
|
|
|
1275
1523
|
}
|
|
1276
1524
|
});
|
|
1277
1525
|
} else {
|
|
1278
|
-
if (!
|
|
1279
|
-
let e =
|
|
1280
|
-
|
|
1526
|
+
if (!l(this.state.block, n.originalIndex, i)) return !1;
|
|
1527
|
+
let e = t(this.state.block, n.originalIndex, i), [r] = o.splice(n.originalIndex, 1);
|
|
1528
|
+
o.splice(i, 0, r), this.editor.updateBlock(this.state.block, {
|
|
1281
1529
|
type: "table",
|
|
1282
1530
|
content: {
|
|
1283
1531
|
...this.state.block.content,
|
|
1284
|
-
columnWidths:
|
|
1532
|
+
columnWidths: o,
|
|
1285
1533
|
rows: e
|
|
1286
1534
|
}
|
|
1287
1535
|
});
|
|
@@ -1294,7 +1542,7 @@ var Ft = class {
|
|
|
1294
1542
|
this.state.show = !1, this.state.showAddOrRemoveRowsButton = !1, this.state.showAddOrRemoveColumnsButton = !1, this.emitUpdate();
|
|
1295
1543
|
return;
|
|
1296
1544
|
}
|
|
1297
|
-
let { height: e, width: t } =
|
|
1545
|
+
let { height: e, width: t } = ie(this.state.block);
|
|
1298
1546
|
this.state.rowIndex !== void 0 && this.state.colIndex !== void 0 && (this.state.rowIndex >= e && (this.state.rowIndex = e - 1), this.state.colIndex >= t && (this.state.colIndex = t - 1));
|
|
1299
1547
|
let n = this.tableElement.querySelector("tbody");
|
|
1300
1548
|
if (!n) throw Error("Table block does not contain a 'tbody' HTML element. This should never happen.");
|
|
@@ -1307,14 +1555,14 @@ var Ft = class {
|
|
|
1307
1555
|
destroy() {
|
|
1308
1556
|
this.pmView.dom.removeEventListener("mousemove", this.mouseMoveHandler), window.removeEventListener("mouseup", this.mouseUpHandler), this.pmView.dom.removeEventListener("mousedown", this.viewMousedownHandler), this.pmView.root.removeEventListener("dragover", this.dragOverHandler), this.pmView.root.removeEventListener("drop", this.dropHandler);
|
|
1309
1557
|
}
|
|
1310
|
-
}, Q = new
|
|
1311
|
-
let t, n =
|
|
1558
|
+
}, Q = new x("TableHandlesPlugin"), rn = v(({ editor: e }) => {
|
|
1559
|
+
let t, n = _(void 0);
|
|
1312
1560
|
return {
|
|
1313
1561
|
key: "tableHandles",
|
|
1314
1562
|
store: n,
|
|
1315
|
-
prosemirrorPlugins: [new
|
|
1563
|
+
prosemirrorPlugins: [new b({
|
|
1316
1564
|
key: Q,
|
|
1317
|
-
view: (r) => (t = new
|
|
1565
|
+
view: (r) => (t = new nn(e, r, (e) => {
|
|
1318
1566
|
n.setState(e.block ? {
|
|
1319
1567
|
...e,
|
|
1320
1568
|
draggingState: e.draggingState ? { ...e.draggingState } : void 0
|
|
@@ -1324,22 +1572,22 @@ var Ft = class {
|
|
|
1324
1572
|
if (t === void 0 || t.state === void 0 || t.state.draggingState === void 0 || t.tablePos === void 0) return;
|
|
1325
1573
|
let n = t.state.draggingState.draggedCellOrientation === "row" ? t.state.rowIndex : t.state.colIndex;
|
|
1326
1574
|
if (n === void 0) return;
|
|
1327
|
-
let
|
|
1328
|
-
if (n ===
|
|
1575
|
+
let i = [], { block: o, draggingState: s } = t.state, { originalIndex: c, draggedCellOrientation: d } = s;
|
|
1576
|
+
if (n === c || !o || d === "row" && !r(o, c, n) || d === "col" && !l(o, c, n)) return T.create(e.doc, i);
|
|
1329
1577
|
let f = e.doc.resolve(t.tablePos + 1);
|
|
1330
|
-
return t.state.draggingState.draggedCellOrientation === "row" ?
|
|
1331
|
-
let a = e.doc.resolve(f.posAtIndex(t) + 1), o = e.doc.resolve(a.posAtIndex(
|
|
1332
|
-
|
|
1578
|
+
return t.state.draggingState.draggedCellOrientation === "row" ? u(t.state.block, n).forEach(({ row: t, col: r }) => {
|
|
1579
|
+
let a = e.doc.resolve(f.posAtIndex(t) + 1), o = e.doc.resolve(a.posAtIndex(r) + 1), s = o.node(), l = o.pos + (n > c ? s.nodeSize - 2 : 0);
|
|
1580
|
+
i.push(w.widget(l, () => {
|
|
1333
1581
|
let e = document.createElement("div");
|
|
1334
|
-
return e.className = "bn-table-drop-cursor", e.style.left = "0", e.style.right = "0", n >
|
|
1582
|
+
return e.className = "bn-table-drop-cursor", e.style.left = "0", e.style.right = "0", n > c ? e.style.bottom = "-2px" : e.style.top = "-3px", e.style.height = "4px", e;
|
|
1335
1583
|
}));
|
|
1336
|
-
}) : a(t.state.block, n).forEach(({ row: t, col:
|
|
1337
|
-
let a = e.doc.resolve(f.posAtIndex(t) + 1), o = e.doc.resolve(a.posAtIndex(
|
|
1338
|
-
|
|
1584
|
+
}) : a(t.state.block, n).forEach(({ row: t, col: r }) => {
|
|
1585
|
+
let a = e.doc.resolve(f.posAtIndex(t) + 1), o = e.doc.resolve(a.posAtIndex(r) + 1), s = o.node(), l = o.pos + (n > c ? s.nodeSize - 2 : 0);
|
|
1586
|
+
i.push(w.widget(l, () => {
|
|
1339
1587
|
let e = document.createElement("div");
|
|
1340
|
-
return e.className = "bn-table-drop-cursor", e.style.top = "0", e.style.bottom = "0", n >
|
|
1588
|
+
return e.className = "bn-table-drop-cursor", e.style.top = "0", e.style.bottom = "0", n > c ? e.style.right = "-2px" : e.style.left = "-3px", e.style.width = "4px", e;
|
|
1341
1589
|
}));
|
|
1342
|
-
}),
|
|
1590
|
+
}), T.create(e.doc, i);
|
|
1343
1591
|
} }
|
|
1344
1592
|
})],
|
|
1345
1593
|
colDragStart(n) {
|
|
@@ -1353,7 +1601,7 @@ var Ft = class {
|
|
|
1353
1601
|
originalIndex: t.state.colIndex,
|
|
1354
1602
|
newIndex: t.state.colIndex,
|
|
1355
1603
|
tablePos: t.tablePos
|
|
1356
|
-
})), !e.headless && (
|
|
1604
|
+
})), !e.headless && (Qt(e.prosemirrorView.root), n.dataTransfer.setDragImage(X, 0, 0), n.dataTransfer.effectAllowed = "move");
|
|
1357
1605
|
},
|
|
1358
1606
|
rowDragStart(n) {
|
|
1359
1607
|
if (t.state === void 0 || t.state.rowIndex === void 0) throw Error("Attempted to drag table row, but no table block was hovered prior.");
|
|
@@ -1366,11 +1614,11 @@ var Ft = class {
|
|
|
1366
1614
|
originalIndex: t.state.rowIndex,
|
|
1367
1615
|
newIndex: t.state.rowIndex,
|
|
1368
1616
|
tablePos: t.tablePos
|
|
1369
|
-
})), !e.headless && (
|
|
1617
|
+
})), !e.headless && (Qt(e.prosemirrorView.root), n.dataTransfer.setDragImage(X, 0, 0), n.dataTransfer.effectAllowed = "copyMove");
|
|
1370
1618
|
},
|
|
1371
1619
|
dragEnd() {
|
|
1372
1620
|
if (t.state === void 0) throw Error("Attempted to drag table row, but no table block was hovered prior.");
|
|
1373
|
-
t.state.draggingState = void 0, t.emitUpdate(), e.transact((e) => e.setMeta(Q, null)), !e.headless &&
|
|
1621
|
+
t.state.draggingState = void 0, t.emitUpdate(), e.transact((e) => e.setMeta(Q, null)), !e.headless && $t(e.prosemirrorView.root);
|
|
1374
1622
|
},
|
|
1375
1623
|
freezeHandles() {
|
|
1376
1624
|
t.menuFrozen = !0;
|
|
@@ -1382,7 +1630,7 @@ var Ft = class {
|
|
|
1382
1630
|
!t.menuFrozen && t.state?.show && (t.state.show = !1, t.state.showAddOrRemoveRowsButton = !1, t.state.showAddOrRemoveColumnsButton = !1, t.emitUpdate());
|
|
1383
1631
|
},
|
|
1384
1632
|
getCellsAtRowHandle(e, t) {
|
|
1385
|
-
return
|
|
1633
|
+
return u(e, t);
|
|
1386
1634
|
},
|
|
1387
1635
|
getCellsAtColumnHandle(e, t) {
|
|
1388
1636
|
return a(e, t);
|
|
@@ -1390,7 +1638,7 @@ var Ft = class {
|
|
|
1390
1638
|
setCellSelection(e, n, r = n) {
|
|
1391
1639
|
if (!t) throw Error("Table handles view not initialized");
|
|
1392
1640
|
let i = e.doc.resolve(t.tablePos + 1), a = e.doc.resolve(i.posAtIndex(n.row) + 1), o = e.doc.resolve(a.posAtIndex(n.col)), s = e.doc.resolve(i.posAtIndex(r.row) + 1), c = e.doc.resolve(s.posAtIndex(r.col)), l = e.tr;
|
|
1393
|
-
return l.setSelection(new
|
|
1641
|
+
return l.setSelection(new ge(o, c)), e.apply(l);
|
|
1394
1642
|
},
|
|
1395
1643
|
addRowOrColumn(t, n) {
|
|
1396
1644
|
e.exec((e, r) => {
|
|
@@ -1401,28 +1649,28 @@ var Ft = class {
|
|
|
1401
1649
|
row: 0,
|
|
1402
1650
|
col: t
|
|
1403
1651
|
});
|
|
1404
|
-
return n.orientation === "row" ? n.side === "above" ?
|
|
1652
|
+
return n.orientation === "row" ? n.side === "above" ? be(i, r) : ye(i, r) : n.side === "left" ? ve(i, r) : _e(i, r);
|
|
1405
1653
|
});
|
|
1406
1654
|
},
|
|
1407
1655
|
removeRowOrColumn(t, n) {
|
|
1408
|
-
return n === "row" ? e.exec((e, n) =>
|
|
1656
|
+
return n === "row" ? e.exec((e, n) => Se(this.setCellSelection(e, {
|
|
1409
1657
|
row: t,
|
|
1410
1658
|
col: 0
|
|
1411
|
-
}), n)) : e.exec((e, n) =>
|
|
1659
|
+
}), n)) : e.exec((e, n) => xe(this.setCellSelection(e, {
|
|
1412
1660
|
row: 0,
|
|
1413
1661
|
col: t
|
|
1414
1662
|
}), n));
|
|
1415
1663
|
},
|
|
1416
1664
|
mergeCells(t) {
|
|
1417
|
-
return e.exec((e, n) =>
|
|
1665
|
+
return e.exec((e, n) => Ce(t ? this.setCellSelection(e, t.relativeStartCell, t.relativeEndCell) : e, n));
|
|
1418
1666
|
},
|
|
1419
1667
|
splitCell(t) {
|
|
1420
|
-
return e.exec((e, n) =>
|
|
1668
|
+
return e.exec((e, n) => we(t ? this.setCellSelection(e, t) : e, n));
|
|
1421
1669
|
},
|
|
1422
1670
|
getCellSelection() {
|
|
1423
1671
|
return e.transact((e) => {
|
|
1424
1672
|
let t = e.selection, n = t.$from, r = t.$to;
|
|
1425
|
-
if (
|
|
1673
|
+
if (f(t)) {
|
|
1426
1674
|
let { ranges: e } = t;
|
|
1427
1675
|
e.forEach((e) => {
|
|
1428
1676
|
n = e.$from.min(n ?? e.$from), r = e.$to.max(r ?? e.$to);
|
|
@@ -1448,7 +1696,7 @@ var Ft = class {
|
|
|
1448
1696
|
},
|
|
1449
1697
|
getMergeDirection(t) {
|
|
1450
1698
|
return e.transact((e) => {
|
|
1451
|
-
let n =
|
|
1699
|
+
let n = f(e.selection) ? e.selection : void 0;
|
|
1452
1700
|
if (!n || !t || n.ranges.length <= 1) return;
|
|
1453
1701
|
let r = this.getCellSelection();
|
|
1454
1702
|
if (r) return s(r.from, r.to, t) ? "vertical" : "horizontal";
|
|
@@ -1458,32 +1706,50 @@ var Ft = class {
|
|
|
1458
1706
|
return i(e, t);
|
|
1459
1707
|
},
|
|
1460
1708
|
addRowsOrColumns(e, t, n) {
|
|
1461
|
-
return
|
|
1709
|
+
return o(e, t, n);
|
|
1462
1710
|
}
|
|
1463
1711
|
};
|
|
1464
|
-
}), $ = new
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
}
|
|
1712
|
+
}), $ = new x("trailingNode");
|
|
1713
|
+
function an(e, t) {
|
|
1714
|
+
if (!t) return !1;
|
|
1715
|
+
let n = e.lastChild?.lastChild, r = n?.firstChild;
|
|
1716
|
+
return !(n?.type.name === "blockContainer" && r?.type.name === "paragraph" && r.content.size === 0);
|
|
1717
|
+
}
|
|
1718
|
+
var on = v(({ editor: e }) => {
|
|
1719
|
+
function t(t) {
|
|
1720
|
+
return w.widget(t, () => {
|
|
1721
|
+
let t = document.createElement("div");
|
|
1722
|
+
return t.className = "bn-trailing-block", t.contentEditable = "false", t.addEventListener("mousedown", (t) => {
|
|
1723
|
+
t.preventDefault(), e.transact((t) => {
|
|
1724
|
+
let [n] = e.insertBlocks([{ type: "paragraph" }], e.document[e.document.length - 1], "after");
|
|
1725
|
+
e.setTextCursorPosition(n, "start"), t.scrollIntoView();
|
|
1726
|
+
}), e.prosemirrorView?.focus();
|
|
1727
|
+
}), t;
|
|
1728
|
+
}, { side: 1 });
|
|
1729
|
+
}
|
|
1730
|
+
function n(e, n, r) {
|
|
1731
|
+
let i = n.map(e.mapping, e.doc), a = i.find(), o = a.length > 0;
|
|
1732
|
+
return o === an(e.doc, r) ? i : o ? i.remove(a) : i.add(e.doc, [t(e.doc.content.size - 1)]);
|
|
1733
|
+
}
|
|
1734
|
+
return {
|
|
1735
|
+
key: "trailingNode",
|
|
1736
|
+
prosemirrorPlugins: [new b({
|
|
1737
|
+
key: $,
|
|
1738
|
+
state: {
|
|
1739
|
+
init: (t, r) => n(r.tr, T.empty, e.isEditable),
|
|
1740
|
+
apply: (t, r) => !t.docChanged && !t.getMeta($) ? r : n(t, r, e.isEditable)
|
|
1741
|
+
},
|
|
1742
|
+
view(e) {
|
|
1743
|
+
let t = e.editable;
|
|
1744
|
+
return { update(e) {
|
|
1745
|
+
e.editable !== t && (t = e.editable, e.dispatch(e.state.tr.setMeta($, !0)));
|
|
1746
|
+
} };
|
|
1747
|
+
},
|
|
1748
|
+
props: { decorations: (e) => $.getState(e) }
|
|
1749
|
+
})]
|
|
1750
|
+
};
|
|
1751
|
+
});
|
|
1486
1752
|
//#endregion
|
|
1487
|
-
export {
|
|
1753
|
+
export { j as C, Ke as D, qe as E, O, Ze as S, k as T, ct as _, Zt as a, ot as b, Jt as c, W as d, _t as f, lt as g, ut as h, Q as i, Vt as l, ft as m, rn as n, Yt as o, mt as p, nn as r, J as s, on as t, Bt as u, st as v, A as w, $e as x, at as y };
|
|
1488
1754
|
|
|
1489
|
-
//# sourceMappingURL=extensions-
|
|
1755
|
+
//# sourceMappingURL=extensions-CQFfm5f5.js.map
|