@blocknote/core 0.47.2 → 0.48.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/BlockNoteExtension-B6RhuQ3V.js +27 -0
- package/dist/BlockNoteExtension-B6RhuQ3V.js.map +1 -0
- package/dist/BlockNoteExtension-ab0REuob.cjs +2 -0
- package/dist/BlockNoteExtension-ab0REuob.cjs.map +1 -0
- package/dist/EventEmitter-CuPnGDYt.js +22 -0
- package/dist/EventEmitter-CuPnGDYt.js.map +1 -0
- package/dist/EventEmitter-DHdSnYCD.cjs +2 -0
- package/dist/EventEmitter-DHdSnYCD.cjs.map +1 -0
- package/dist/ShowSelection-BsHFfdMi.js +29 -0
- package/dist/ShowSelection-BsHFfdMi.js.map +1 -0
- package/dist/ShowSelection-DhXglbt8.cjs +2 -0
- package/dist/ShowSelection-DhXglbt8.cjs.map +1 -0
- package/dist/blocknote.cjs +1 -5
- package/dist/blocknote.js +7 -4216
- package/dist/blocks-BEvIOzln.cjs +11 -0
- package/dist/blocks-BEvIOzln.cjs.map +1 -0
- package/dist/blocks-DYl7UTS4.js +3313 -0
- package/dist/blocks-DYl7UTS4.js.map +1 -0
- package/dist/blocks.cjs +1 -2
- package/dist/blocks.js +2 -74
- package/dist/comments.cjs +2 -2
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js +604 -900
- package/dist/comments.js.map +1 -1
- package/dist/en-C4ykW581.cjs +2 -0
- package/dist/en-C4ykW581.cjs.map +1 -0
- package/dist/en-QsSI16s5.js +453 -0
- package/dist/en-QsSI16s5.js.map +1 -0
- package/dist/extensions-3nf9PPhA.js +1495 -0
- package/dist/extensions-3nf9PPhA.js.map +1 -0
- package/dist/extensions-D9y6evn6.cjs +2 -0
- package/dist/extensions-D9y6evn6.cjs.map +1 -0
- package/dist/extensions.cjs +1 -2
- package/dist/extensions.js +4 -36
- package/dist/locales.cjs +2 -2
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +10049 -9111
- package/dist/locales.js.map +1 -1
- package/dist/src-BKJH7Jla.cjs +5 -0
- package/dist/src-BKJH7Jla.cjs.map +1 -0
- package/dist/src-Hjv1f5lc.js +2386 -0
- package/dist/src-Hjv1f5lc.js.map +1 -0
- package/dist/style.css +2 -1
- package/dist/webpack-stats.json +1 -1
- package/dist/yjs.cjs +2 -2
- package/dist/yjs.cjs.map +1 -1
- package/dist/yjs.js +20 -38
- package/dist/yjs.js.map +1 -1
- package/package.json +8 -8
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +15 -1
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +5 -0
- package/src/api/blockManipulation/commands/nestBlock/__snapshots__/nestBlock.test.ts.snap +1095 -0
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.test.ts +661 -0
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +128 -11
- package/src/api/parsers/html/parseHTML.ts +2 -0
- package/src/api/parsers/html/util/normalizeWhitespace.ts +87 -0
- package/src/blocks/File/helpers/render/createResizableFileBlockWrapper.ts +17 -23
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.ts +346 -0
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +143 -71
- package/src/editor/Block.css +5 -8
- package/src/editor/BlockNoteEditor.ts +38 -1
- package/src/editor/editor.css +0 -20
- package/src/editor/managers/ExtensionManager/extensions.ts +12 -1
- package/src/editor/performance.test.ts +134 -0
- package/src/extensions/Collaboration/ForkYDoc.test.ts +115 -103
- package/src/extensions/Placeholder/Placeholder.ts +1 -1
- package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +86 -0
- package/src/extensions/PreviousBlockType/PreviousBlockType.ts +33 -49
- package/src/extensions/SideMenu/SideMenu.ts +14 -8
- package/src/extensions/TableHandles/TableHandles.ts +14 -0
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +57 -17
- package/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts +9 -8
- package/src/index.ts +1 -1
- package/src/schema/blocks/createSpec.ts +6 -2
- package/src/schema/inlineContent/types.ts +0 -1
- package/src/vite-env.d.ts +6 -0
- package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.d.ts +14 -1
- package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.test.d.ts +1 -0
- package/types/src/api/parsers/html/util/normalizeWhitespace.d.ts +6 -0
- package/types/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.d.ts +1 -0
- package/types/src/editor/BlockNoteEditor.d.ts +13 -0
- package/types/src/editor/performance.test.d.ts +1 -0
- package/types/src/extensions/PreviousBlockType/PreviousBlockType.test.d.ts +1 -0
- package/types/src/extensions/SideMenu/SideMenu.d.ts +6 -0
- package/types/src/extensions/TableHandles/TableHandles.d.ts +6 -0
- package/dist/BlockNoteExtension-BWw0r8Gy.cjs +0 -2
- package/dist/BlockNoteExtension-BWw0r8Gy.cjs.map +0 -1
- package/dist/BlockNoteExtension-C2X7LW-V.js +0 -25
- package/dist/BlockNoteExtension-C2X7LW-V.js.map +0 -1
- package/dist/BlockNoteSchema-CCs_V3lo.cjs +0 -2
- package/dist/BlockNoteSchema-CCs_V3lo.cjs.map +0 -1
- package/dist/BlockNoteSchema-ooiKsd5B.js +0 -270
- package/dist/BlockNoteSchema-ooiKsd5B.js.map +0 -1
- package/dist/EventEmitter-CLwfmbqG.cjs +0 -2
- package/dist/EventEmitter-CLwfmbqG.cjs.map +0 -1
- package/dist/EventEmitter-CjSwpTbz.js +0 -27
- package/dist/EventEmitter-CjSwpTbz.js.map +0 -1
- package/dist/ShowSelection-B0ch3unP.js +0 -51
- package/dist/ShowSelection-B0ch3unP.js.map +0 -1
- package/dist/ShowSelection-BxnbRvy4.cjs +0 -2
- package/dist/ShowSelection-BxnbRvy4.cjs.map +0 -1
- package/dist/TrailingNode-GzE59m_7.js +0 -2288
- package/dist/TrailingNode-GzE59m_7.js.map +0 -1
- package/dist/TrailingNode-n0WdMPUl.cjs +0 -2
- package/dist/TrailingNode-n0WdMPUl.cjs.map +0 -1
- package/dist/blockToNode-BNoNIXU7.js +0 -1140
- package/dist/blockToNode-BNoNIXU7.js.map +0 -1
- package/dist/blockToNode-CumVjgem.cjs +0 -7
- package/dist/blockToNode-CumVjgem.cjs.map +0 -1
- package/dist/blocknote.cjs.map +0 -1
- package/dist/blocknote.js.map +0 -1
- package/dist/blocks.cjs.map +0 -1
- package/dist/blocks.js.map +0 -1
- package/dist/defaultBlocks-Dg9kQWXm.cjs +0 -6
- package/dist/defaultBlocks-Dg9kQWXm.cjs.map +0 -1
- package/dist/defaultBlocks-ZzGbYgQn.js +0 -3284
- package/dist/defaultBlocks-ZzGbYgQn.js.map +0 -1
- package/dist/en-Cl87Uuyf.cjs +0 -2
- package/dist/en-Cl87Uuyf.cjs.map +0 -1
- package/dist/en-njEqD7AG.js +0 -408
- package/dist/en-njEqD7AG.js.map +0 -1
- package/dist/extensions.cjs.map +0 -1
- package/dist/extensions.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -1,2288 +0,0 @@
|
|
|
1
|
-
var Ae = Object.defineProperty;
|
|
2
|
-
var Le = (n, e, o) => e in n ? Ae(n, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : n[e] = o;
|
|
3
|
-
var k = (n, e, o) => Le(n, typeof e != "symbol" ? e + "" : e, o);
|
|
4
|
-
import { Plugin as L, PluginKey as N, NodeSelection as pe, TextSelection as fe, Selection as U } from "prosemirror-state";
|
|
5
|
-
import { combineTransactionSteps as Ne, getMarkRange as Re, posToDOMRect as Ve, findChildren as Q } from "@tiptap/core";
|
|
6
|
-
import He from "fast-deep-equal";
|
|
7
|
-
import { i as Z, t as $e, U as Fe, n as Ue, g as _, a as z, c as ge, m as _e, e as we, f as ze, h as Ye, j as je, k as Ke, l as Xe, o as ee, p as te } from "./blockToNode-BNoNIXU7.js";
|
|
8
|
-
import { ai as be, a2 as oe, aj as ye, _ as We, $ as qe, a1 as ne } from "./defaultBlocks-ZzGbYgQn.js";
|
|
9
|
-
import { c as E, a as j } from "./BlockNoteExtension-C2X7LW-V.js";
|
|
10
|
-
import { yCursorPlugin as Ge, defaultSelectionBuilder as Je, ySyncPlugin as Qe, redoCommand as Ze, undoCommand as et, yUndoPlugin as tt, yUndoPluginKey as re } from "y-prosemirror";
|
|
11
|
-
import * as P from "yjs";
|
|
12
|
-
import { PluginKey as ke, Plugin as ve, TextSelection as ot } from "@tiptap/pm/state";
|
|
13
|
-
import { dropPoint as nt } from "prosemirror-transform";
|
|
14
|
-
import { redo as rt, undo as st, history as it } from "@tiptap/pm/history";
|
|
15
|
-
import { Decoration as H, DecorationSet as Y } from "prosemirror-view";
|
|
16
|
-
import { v4 as at } from "uuid";
|
|
17
|
-
import { DOMParser as lt, Slice as ct } from "@tiptap/pm/model";
|
|
18
|
-
import { DOMSerializer as Ce, Fragment as Se, Slice as dt } from "prosemirror-model";
|
|
19
|
-
import ut from "rehype-parse";
|
|
20
|
-
import ht from "rehype-remark";
|
|
21
|
-
import mt from "remark-gfm";
|
|
22
|
-
import pt from "remark-stringify";
|
|
23
|
-
import { unified as ft } from "unified";
|
|
24
|
-
import { fromDom as gt } from "hast-util-from-dom";
|
|
25
|
-
import { visit as wt } from "unist-util-visit";
|
|
26
|
-
import { splitCell as bt, mergeCells as yt, deleteRow as kt, deleteColumn as vt, addRowBefore as Ct, addRowAfter as St, addColumnBefore as xt, addColumnAfter as Et, CellSelection as It } from "prosemirror-tables";
|
|
27
|
-
function xe(n) {
|
|
28
|
-
const e = Array.from(n.classList).filter(
|
|
29
|
-
(o) => !o.startsWith("bn-")
|
|
30
|
-
) || [];
|
|
31
|
-
e.length > 0 ? n.className = e.join(" ") : n.removeAttribute("class");
|
|
32
|
-
}
|
|
33
|
-
function Ee(n, e, o, t) {
|
|
34
|
-
var a;
|
|
35
|
-
let r;
|
|
36
|
-
if (e)
|
|
37
|
-
if (typeof e == "string")
|
|
38
|
-
r = Z([e], n.pmSchema);
|
|
39
|
-
else if (Array.isArray(e))
|
|
40
|
-
r = Z(e, n.pmSchema);
|
|
41
|
-
else if (e.type === "tableContent")
|
|
42
|
-
r = $e(e, n.pmSchema);
|
|
43
|
-
else
|
|
44
|
-
throw new Fe(e.type);
|
|
45
|
-
else throw new Error("blockContent is required");
|
|
46
|
-
const i = ((t == null ? void 0 : t.document) ?? document).createDocumentFragment();
|
|
47
|
-
for (const c of r)
|
|
48
|
-
if (c.type.name !== "text" && n.schema.inlineContentSchema[c.type.name]) {
|
|
49
|
-
const l = n.schema.inlineContentSpecs[c.type.name].implementation;
|
|
50
|
-
if (l) {
|
|
51
|
-
const u = Ue(
|
|
52
|
-
c,
|
|
53
|
-
n.schema.inlineContentSchema,
|
|
54
|
-
n.schema.styleSchema
|
|
55
|
-
), h = l.toExternalHTML ? l.toExternalHTML(
|
|
56
|
-
u,
|
|
57
|
-
n
|
|
58
|
-
) : l.render.call(
|
|
59
|
-
{
|
|
60
|
-
renderType: "dom",
|
|
61
|
-
props: void 0
|
|
62
|
-
},
|
|
63
|
-
u,
|
|
64
|
-
() => {
|
|
65
|
-
},
|
|
66
|
-
n
|
|
67
|
-
);
|
|
68
|
-
if (h) {
|
|
69
|
-
if (i.appendChild(h.dom), h.contentDOM) {
|
|
70
|
-
const f = o.serializeFragment(
|
|
71
|
-
c.content,
|
|
72
|
-
t
|
|
73
|
-
);
|
|
74
|
-
h.contentDOM.dataset.editable = "", h.contentDOM.appendChild(f);
|
|
75
|
-
}
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
} else if (c.type.name === "text") {
|
|
80
|
-
let l = document.createTextNode(
|
|
81
|
-
c.textContent
|
|
82
|
-
);
|
|
83
|
-
for (const u of c.marks.toReversed())
|
|
84
|
-
if (u.type.name in n.schema.styleSpecs) {
|
|
85
|
-
const h = (n.schema.styleSpecs[u.type.name].implementation.toExternalHTML ?? n.schema.styleSpecs[u.type.name].implementation.render)(u.attrs.stringValue, n);
|
|
86
|
-
h.contentDOM.appendChild(l), l = h.dom;
|
|
87
|
-
} else {
|
|
88
|
-
const h = u.type.spec.toDOM(u, !0), f = Ce.renderSpec(document, h);
|
|
89
|
-
f.contentDOM.appendChild(l), l = f.dom;
|
|
90
|
-
}
|
|
91
|
-
i.appendChild(l);
|
|
92
|
-
} else {
|
|
93
|
-
const l = o.serializeFragment(
|
|
94
|
-
Se.from([c]),
|
|
95
|
-
t
|
|
96
|
-
);
|
|
97
|
-
i.appendChild(l);
|
|
98
|
-
}
|
|
99
|
-
return i.childNodes.length === 1 && ((a = i.firstChild) == null ? void 0 : a.nodeType) === 1 && xe(i.firstChild), i;
|
|
100
|
-
}
|
|
101
|
-
function Bt(n, e, o, t, r, s, i, a) {
|
|
102
|
-
var b, y, w, v, x, I, O, M, T;
|
|
103
|
-
const c = (a == null ? void 0 : a.document) ?? document, l = e.pmSchema.nodes.blockContainer, u = o.props || {};
|
|
104
|
-
for (const [C, S] of Object.entries(
|
|
105
|
-
e.schema.blockSchema[o.type].propSchema
|
|
106
|
-
))
|
|
107
|
-
!(C in u) && S.default !== void 0 && (u[C] = S.default);
|
|
108
|
-
const h = (y = (b = l.spec) == null ? void 0 : b.toDOM) == null ? void 0 : y.call(
|
|
109
|
-
b,
|
|
110
|
-
l.create({
|
|
111
|
-
id: o.id,
|
|
112
|
-
...u
|
|
113
|
-
})
|
|
114
|
-
), f = Array.from(h.dom.attributes), m = e.blockImplementations[o.type].implementation, p = ((w = m.toExternalHTML) == null ? void 0 : w.call(
|
|
115
|
-
{},
|
|
116
|
-
{ ...o, props: u },
|
|
117
|
-
e,
|
|
118
|
-
{
|
|
119
|
-
nestingLevel: i
|
|
120
|
-
}
|
|
121
|
-
)) || m.render.call(
|
|
122
|
-
{},
|
|
123
|
-
{ ...o, props: u },
|
|
124
|
-
e
|
|
125
|
-
), d = c.createDocumentFragment();
|
|
126
|
-
if (p.dom.classList.contains("bn-block-content")) {
|
|
127
|
-
const C = [
|
|
128
|
-
...f,
|
|
129
|
-
...Array.from(p.dom.attributes)
|
|
130
|
-
].filter(
|
|
131
|
-
(S) => S.name.startsWith("data") && S.name !== "data-content-type" && S.name !== "data-file-block" && S.name !== "data-node-view-wrapper" && S.name !== "data-node-type" && S.name !== "data-id" && S.name !== "data-editable"
|
|
132
|
-
);
|
|
133
|
-
for (const S of C)
|
|
134
|
-
p.dom.firstChild.setAttribute(S.name, S.value);
|
|
135
|
-
xe(p.dom.firstChild), i > 0 && p.dom.firstChild.setAttribute(
|
|
136
|
-
"data-nesting-level",
|
|
137
|
-
i.toString()
|
|
138
|
-
), d.append(...Array.from(p.dom.childNodes));
|
|
139
|
-
} else
|
|
140
|
-
d.append(p.dom), i > 0 && p.dom.setAttribute(
|
|
141
|
-
"data-nesting-level",
|
|
142
|
-
i.toString()
|
|
143
|
-
);
|
|
144
|
-
if (p.contentDOM && o.content) {
|
|
145
|
-
const C = Ee(
|
|
146
|
-
e,
|
|
147
|
-
o.content,
|
|
148
|
-
// TODO
|
|
149
|
-
t,
|
|
150
|
-
a
|
|
151
|
-
);
|
|
152
|
-
p.contentDOM.appendChild(C);
|
|
153
|
-
}
|
|
154
|
-
let g;
|
|
155
|
-
if (r.has(o.type) ? g = "OL" : s.has(o.type) && (g = "UL"), g) {
|
|
156
|
-
if (((v = n.lastChild) == null ? void 0 : v.nodeName) !== g) {
|
|
157
|
-
const C = c.createElement(g);
|
|
158
|
-
g === "OL" && "start" in u && u.start && (u == null ? void 0 : u.start) !== 1 && C.setAttribute("start", u.start + ""), n.append(C);
|
|
159
|
-
}
|
|
160
|
-
n.lastChild.appendChild(d);
|
|
161
|
-
} else
|
|
162
|
-
n.append(d);
|
|
163
|
-
if (o.children && o.children.length > 0) {
|
|
164
|
-
const C = c.createDocumentFragment();
|
|
165
|
-
if (Ie(
|
|
166
|
-
C,
|
|
167
|
-
e,
|
|
168
|
-
o.children,
|
|
169
|
-
t,
|
|
170
|
-
r,
|
|
171
|
-
s,
|
|
172
|
-
i + 1,
|
|
173
|
-
a
|
|
174
|
-
), ((x = n.lastChild) == null ? void 0 : x.nodeName) === "UL" || ((I = n.lastChild) == null ? void 0 : I.nodeName) === "OL")
|
|
175
|
-
for (; ((O = C.firstChild) == null ? void 0 : O.nodeName) === "UL" || ((M = C.firstChild) == null ? void 0 : M.nodeName) === "OL"; )
|
|
176
|
-
n.lastChild.lastChild.appendChild(C.firstChild);
|
|
177
|
-
"childrenDOM" in p && p.childrenDOM ? p.childrenDOM.append(C) : e.pmSchema.nodes[o.type].isInGroup("blockContent") ? n.append(C) : (T = p.contentDOM) == null || T.append(C);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
const Ie = (n, e, o, t, r, s, i = 0, a) => {
|
|
181
|
-
for (const c of o)
|
|
182
|
-
Bt(
|
|
183
|
-
n,
|
|
184
|
-
e,
|
|
185
|
-
c,
|
|
186
|
-
t,
|
|
187
|
-
r,
|
|
188
|
-
s,
|
|
189
|
-
i,
|
|
190
|
-
a
|
|
191
|
-
);
|
|
192
|
-
}, Tt = (n, e, o, t, r, s) => {
|
|
193
|
-
const a = ((s == null ? void 0 : s.document) ?? document).createDocumentFragment();
|
|
194
|
-
return Ie(
|
|
195
|
-
a,
|
|
196
|
-
n,
|
|
197
|
-
e,
|
|
198
|
-
o,
|
|
199
|
-
t,
|
|
200
|
-
r,
|
|
201
|
-
0,
|
|
202
|
-
s
|
|
203
|
-
), a;
|
|
204
|
-
}, Be = (n, e) => {
|
|
205
|
-
const o = Ce.fromSchema(n);
|
|
206
|
-
return {
|
|
207
|
-
exportBlocks: (t, r) => {
|
|
208
|
-
const s = Tt(
|
|
209
|
-
e,
|
|
210
|
-
t,
|
|
211
|
-
o,
|
|
212
|
-
/* @__PURE__ */ new Set(["numberedListItem"]),
|
|
213
|
-
/* @__PURE__ */ new Set(["bulletListItem", "checkListItem", "toggleListItem"]),
|
|
214
|
-
r
|
|
215
|
-
), i = document.createElement("div");
|
|
216
|
-
return i.append(s), i.innerHTML;
|
|
217
|
-
},
|
|
218
|
-
exportInlineContent: (t, r) => {
|
|
219
|
-
const s = Ee(
|
|
220
|
-
e,
|
|
221
|
-
t,
|
|
222
|
-
o,
|
|
223
|
-
r
|
|
224
|
-
), i = document.createElement("div");
|
|
225
|
-
return i.append(s.cloneNode(!0)), i.innerHTML;
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
};
|
|
229
|
-
function Dt(n, e) {
|
|
230
|
-
if (e === 0)
|
|
231
|
-
return;
|
|
232
|
-
const o = n.resolve(e);
|
|
233
|
-
for (let t = o.depth; t > 0; t--) {
|
|
234
|
-
const r = o.node(t);
|
|
235
|
-
if (be(r))
|
|
236
|
-
return r.attrs.id;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
function Ot(n) {
|
|
240
|
-
return n.getMeta("paste") ? { type: "paste" } : n.getMeta("uiEvent") === "drop" ? { type: "drop" } : n.getMeta("history$") ? {
|
|
241
|
-
type: n.getMeta("history$").redo ? "redo" : "undo"
|
|
242
|
-
} : n.getMeta("y-sync$") ? n.getMeta("y-sync$").isUndoRedoOperation ? { type: "undo-redo" } : { type: "yjs-remote" } : { type: "local" };
|
|
243
|
-
}
|
|
244
|
-
function se(n) {
|
|
245
|
-
const e = "__root__", o = {}, t = {}, r = _(n);
|
|
246
|
-
return n.descendants((s, i) => {
|
|
247
|
-
if (!be(s))
|
|
248
|
-
return !0;
|
|
249
|
-
const a = Dt(n, i), c = a ?? e;
|
|
250
|
-
t[c] || (t[c] = []);
|
|
251
|
-
const l = z(s, r);
|
|
252
|
-
return o[s.attrs.id] = { block: l, parentId: a }, t[c].push(s.attrs.id), !0;
|
|
253
|
-
}), { byId: o, childrenByParent: t };
|
|
254
|
-
}
|
|
255
|
-
function Pt(n, e) {
|
|
256
|
-
const o = /* @__PURE__ */ new Set();
|
|
257
|
-
if (!n || !e)
|
|
258
|
-
return o;
|
|
259
|
-
const t = new Set(n), r = e.filter((d) => t.has(d)), s = n.filter(
|
|
260
|
-
(d) => r.includes(d)
|
|
261
|
-
);
|
|
262
|
-
if (s.length <= 1 || r.length <= 1)
|
|
263
|
-
return o;
|
|
264
|
-
const i = {};
|
|
265
|
-
for (let d = 0; d < s.length; d++)
|
|
266
|
-
i[s[d]] = d;
|
|
267
|
-
const a = r.map((d) => i[d]), c = a.length, l = [], u = [], h = new Array(c).fill(-1), f = (d, g) => {
|
|
268
|
-
let b = 0, y = d.length;
|
|
269
|
-
for (; b < y; ) {
|
|
270
|
-
const w = b + y >>> 1;
|
|
271
|
-
d[w] < g ? b = w + 1 : y = w;
|
|
272
|
-
}
|
|
273
|
-
return b;
|
|
274
|
-
};
|
|
275
|
-
for (let d = 0; d < c; d++) {
|
|
276
|
-
const g = a[d], b = f(l, g);
|
|
277
|
-
b > 0 && (h[d] = u[b - 1]), b === l.length ? (l.push(g), u.push(d)) : (l[b] = g, u[b] = d);
|
|
278
|
-
}
|
|
279
|
-
const m = /* @__PURE__ */ new Set();
|
|
280
|
-
let p = u[u.length - 1] ?? -1;
|
|
281
|
-
for (; p !== -1; )
|
|
282
|
-
m.add(p), p = h[p];
|
|
283
|
-
for (let d = 0; d < r.length; d++)
|
|
284
|
-
m.has(d) || o.add(r[d]);
|
|
285
|
-
return o;
|
|
286
|
-
}
|
|
287
|
-
function Mt(n, e = []) {
|
|
288
|
-
const o = Ot(n), t = Ne(n.before, [
|
|
289
|
-
n,
|
|
290
|
-
...e
|
|
291
|
-
]), r = se(
|
|
292
|
-
t.before
|
|
293
|
-
), s = se(
|
|
294
|
-
t.doc
|
|
295
|
-
), i = [], a = /* @__PURE__ */ new Set();
|
|
296
|
-
Object.keys(s.byId).filter((m) => !(m in r.byId)).forEach((m) => {
|
|
297
|
-
i.push({
|
|
298
|
-
type: "insert",
|
|
299
|
-
block: s.byId[m].block,
|
|
300
|
-
source: o,
|
|
301
|
-
prevBlock: void 0
|
|
302
|
-
}), a.add(m);
|
|
303
|
-
}), Object.keys(r.byId).filter((m) => !(m in s.byId)).forEach((m) => {
|
|
304
|
-
i.push({
|
|
305
|
-
type: "delete",
|
|
306
|
-
block: r.byId[m].block,
|
|
307
|
-
source: o,
|
|
308
|
-
prevBlock: void 0
|
|
309
|
-
}), a.add(m);
|
|
310
|
-
}), Object.keys(s.byId).filter((m) => m in r.byId).forEach((m) => {
|
|
311
|
-
var b, y;
|
|
312
|
-
const p = r.byId[m], d = s.byId[m];
|
|
313
|
-
p.parentId !== d.parentId ? (i.push({
|
|
314
|
-
type: "move",
|
|
315
|
-
block: d.block,
|
|
316
|
-
prevBlock: p.block,
|
|
317
|
-
source: o,
|
|
318
|
-
prevParent: p.parentId ? (b = r.byId[p.parentId]) == null ? void 0 : b.block : void 0,
|
|
319
|
-
currentParent: d.parentId ? (y = s.byId[d.parentId]) == null ? void 0 : y.block : void 0
|
|
320
|
-
}), a.add(m)) : He(
|
|
321
|
-
{ ...p.block, children: void 0 },
|
|
322
|
-
{ ...d.block, children: void 0 }
|
|
323
|
-
) || (i.push({
|
|
324
|
-
type: "update",
|
|
325
|
-
block: d.block,
|
|
326
|
-
prevBlock: p.block,
|
|
327
|
-
source: o
|
|
328
|
-
}), a.add(m));
|
|
329
|
-
});
|
|
330
|
-
const c = r.childrenByParent, l = s.childrenByParent, u = "__root__", h = /* @__PURE__ */ new Set([
|
|
331
|
-
...Object.keys(c),
|
|
332
|
-
...Object.keys(l)
|
|
333
|
-
]), f = /* @__PURE__ */ new Set();
|
|
334
|
-
return h.forEach((m) => {
|
|
335
|
-
const p = Pt(
|
|
336
|
-
c[m],
|
|
337
|
-
l[m]
|
|
338
|
-
);
|
|
339
|
-
p.size !== 0 && p.forEach((d) => {
|
|
340
|
-
var w, v;
|
|
341
|
-
const g = r.byId[d], b = s.byId[d];
|
|
342
|
-
!g || !b || g.parentId !== b.parentId || a.has(d) || (g.parentId ?? u) !== m || f.has(d) || (f.add(d), i.push({
|
|
343
|
-
type: "move",
|
|
344
|
-
block: b.block,
|
|
345
|
-
prevBlock: g.block,
|
|
346
|
-
source: o,
|
|
347
|
-
prevParent: g.parentId ? (w = r.byId[g.parentId]) == null ? void 0 : w.block : void 0,
|
|
348
|
-
currentParent: b.parentId ? (v = s.byId[b.parentId]) == null ? void 0 : v.block : void 0
|
|
349
|
-
}), a.add(d));
|
|
350
|
-
});
|
|
351
|
-
}), i;
|
|
352
|
-
}
|
|
353
|
-
const Do = E(() => {
|
|
354
|
-
const n = [];
|
|
355
|
-
return {
|
|
356
|
-
key: "blockChange",
|
|
357
|
-
prosemirrorPlugins: [
|
|
358
|
-
new L({
|
|
359
|
-
key: new N("blockChange"),
|
|
360
|
-
filterTransaction: (e) => {
|
|
361
|
-
let o;
|
|
362
|
-
return n.reduce((t, r) => t === !1 ? t : r({
|
|
363
|
-
getChanges() {
|
|
364
|
-
return o || (o = Mt(e), o);
|
|
365
|
-
},
|
|
366
|
-
tr: e
|
|
367
|
-
}) !== !1, !0);
|
|
368
|
-
}
|
|
369
|
-
})
|
|
370
|
-
],
|
|
371
|
-
/**
|
|
372
|
-
* Subscribe to the block change events.
|
|
373
|
-
*/
|
|
374
|
-
subscribe(e) {
|
|
375
|
-
return n.push(e), () => {
|
|
376
|
-
n.splice(
|
|
377
|
-
n.indexOf(e),
|
|
378
|
-
1
|
|
379
|
-
);
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
};
|
|
383
|
-
});
|
|
384
|
-
function ie(n) {
|
|
385
|
-
const e = n.charAt(0) === "#" ? n.substring(1, 7) : n, o = parseInt(e.substring(0, 2), 16), t = parseInt(e.substring(2, 4), 16), r = parseInt(e.substring(4, 6), 16), i = [o / 255, t / 255, r / 255].map((c) => c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4));
|
|
386
|
-
return 0.2126 * i[0] + 0.7152 * i[1] + 0.0722 * i[2] <= 0.179;
|
|
387
|
-
}
|
|
388
|
-
function At(n) {
|
|
389
|
-
const e = document.createElement("span");
|
|
390
|
-
e.classList.add("bn-collaboration-cursor__base");
|
|
391
|
-
const o = document.createElement("span");
|
|
392
|
-
o.setAttribute("contentedEditable", "false"), o.classList.add("bn-collaboration-cursor__caret"), o.setAttribute(
|
|
393
|
-
"style",
|
|
394
|
-
`background-color: ${n.color}; color: ${ie(n.color) ? "white" : "black"}`
|
|
395
|
-
);
|
|
396
|
-
const t = document.createElement("span");
|
|
397
|
-
return t.classList.add("bn-collaboration-cursor__label"), t.setAttribute(
|
|
398
|
-
"style",
|
|
399
|
-
`background-color: ${n.color}; color: ${ie(n.color) ? "white" : "black"}`
|
|
400
|
-
), t.insertBefore(document.createTextNode(n.name), null), o.insertBefore(t, null), e.insertBefore(document.createTextNode(""), null), e.insertBefore(o, null), e.insertBefore(document.createTextNode(""), null), e;
|
|
401
|
-
}
|
|
402
|
-
const ae = E(
|
|
403
|
-
({ options: n }) => {
|
|
404
|
-
const e = /* @__PURE__ */ new Map(), o = n.provider && "awareness" in n.provider && typeof n.provider.awareness == "object" ? n.provider.awareness : void 0;
|
|
405
|
-
return o && ("setLocalStateField" in o && typeof o.setLocalStateField == "function" && o.setLocalStateField("user", n.user), "on" in o && typeof o.on == "function" && n.showCursorLabels !== "always" && o.on(
|
|
406
|
-
"change",
|
|
407
|
-
({
|
|
408
|
-
updated: t
|
|
409
|
-
}) => {
|
|
410
|
-
for (const r of t) {
|
|
411
|
-
const s = e.get(r);
|
|
412
|
-
s && (setTimeout(() => {
|
|
413
|
-
s.element.setAttribute("data-active", "");
|
|
414
|
-
}, 10), s.hideTimeout && clearTimeout(s.hideTimeout), e.set(r, {
|
|
415
|
-
element: s.element,
|
|
416
|
-
hideTimeout: setTimeout(() => {
|
|
417
|
-
s.element.removeAttribute("data-active");
|
|
418
|
-
}, 2e3)
|
|
419
|
-
}));
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
)), {
|
|
423
|
-
key: "yCursor",
|
|
424
|
-
prosemirrorPlugins: [
|
|
425
|
-
o ? Ge(o, {
|
|
426
|
-
selectionBuilder: Je,
|
|
427
|
-
cursorBuilder(t, r) {
|
|
428
|
-
let s = e.get(r);
|
|
429
|
-
if (!s) {
|
|
430
|
-
const i = (n.renderCursor ?? At)(t);
|
|
431
|
-
n.showCursorLabels !== "always" && (i.addEventListener("mouseenter", () => {
|
|
432
|
-
const a = e.get(r);
|
|
433
|
-
a.element.setAttribute("data-active", ""), a.hideTimeout && (clearTimeout(a.hideTimeout), e.set(r, {
|
|
434
|
-
element: a.element,
|
|
435
|
-
hideTimeout: void 0
|
|
436
|
-
}));
|
|
437
|
-
}), i.addEventListener("mouseleave", () => {
|
|
438
|
-
const a = e.get(r);
|
|
439
|
-
e.set(r, {
|
|
440
|
-
element: a.element,
|
|
441
|
-
hideTimeout: setTimeout(() => {
|
|
442
|
-
a.element.removeAttribute("data-active");
|
|
443
|
-
}, 2e3)
|
|
444
|
-
});
|
|
445
|
-
})), s = {
|
|
446
|
-
element: i,
|
|
447
|
-
hideTimeout: void 0
|
|
448
|
-
}, e.set(r, s);
|
|
449
|
-
}
|
|
450
|
-
return s.element;
|
|
451
|
-
}
|
|
452
|
-
}) : void 0
|
|
453
|
-
].filter(Boolean),
|
|
454
|
-
dependsOn: ["ySync"],
|
|
455
|
-
updateUser(t) {
|
|
456
|
-
o == null || o.setLocalStateField("user", t);
|
|
457
|
-
}
|
|
458
|
-
};
|
|
459
|
-
}
|
|
460
|
-
), K = E(
|
|
461
|
-
({ options: n }) => ({
|
|
462
|
-
key: "ySync",
|
|
463
|
-
prosemirrorPlugins: [Qe(n.fragment)],
|
|
464
|
-
runsBefore: ["default"]
|
|
465
|
-
})
|
|
466
|
-
), X = E(() => ({
|
|
467
|
-
key: "yUndo",
|
|
468
|
-
prosemirrorPlugins: [tt()],
|
|
469
|
-
dependsOn: ["yCursor", "ySync"],
|
|
470
|
-
undoCommand: et,
|
|
471
|
-
redoCommand: Ze
|
|
472
|
-
}));
|
|
473
|
-
function Lt(n, e) {
|
|
474
|
-
const o = n.doc;
|
|
475
|
-
if (n._item === null) {
|
|
476
|
-
const t = Array.from(o.share.keys()).find(
|
|
477
|
-
(r) => o.share.get(r) === n
|
|
478
|
-
);
|
|
479
|
-
if (t == null)
|
|
480
|
-
throw new Error("type does not exist in other ydoc");
|
|
481
|
-
return e.get(t, n.constructor);
|
|
482
|
-
} else {
|
|
483
|
-
const t = n._item, r = e.store.clients.get(t.id.client) ?? [], s = P.findIndexSS(r, t.id.clock);
|
|
484
|
-
return r[s].content.type;
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
const Oo = E(
|
|
488
|
-
({ editor: n, options: e }) => {
|
|
489
|
-
let o;
|
|
490
|
-
const t = j({ isForked: !1 });
|
|
491
|
-
return {
|
|
492
|
-
key: "yForkDoc",
|
|
493
|
-
store: t,
|
|
494
|
-
/**
|
|
495
|
-
* Fork the Y.js document from syncing to the remote,
|
|
496
|
-
* allowing modifications to the document without affecting the remote.
|
|
497
|
-
* These changes can later be rolled back or applied to the remote.
|
|
498
|
-
*/
|
|
499
|
-
fork() {
|
|
500
|
-
if (o)
|
|
501
|
-
return;
|
|
502
|
-
const r = e.fragment;
|
|
503
|
-
if (!r)
|
|
504
|
-
throw new Error("No fragment to fork from");
|
|
505
|
-
const s = new P.Doc();
|
|
506
|
-
P.applyUpdate(s, P.encodeStateAsUpdate(r.doc));
|
|
507
|
-
const i = Lt(r, s);
|
|
508
|
-
o = {
|
|
509
|
-
undoStack: re.getState(n.prosemirrorState).undoManager.undoStack,
|
|
510
|
-
originalFragment: r,
|
|
511
|
-
forkedFragment: i
|
|
512
|
-
}, n.unregisterExtension([
|
|
513
|
-
X,
|
|
514
|
-
ae,
|
|
515
|
-
K
|
|
516
|
-
]);
|
|
517
|
-
const a = {
|
|
518
|
-
...e,
|
|
519
|
-
fragment: i
|
|
520
|
-
};
|
|
521
|
-
n.registerExtension([
|
|
522
|
-
K(a),
|
|
523
|
-
// No need to register the cursor plugin again, it's a local fork
|
|
524
|
-
X()
|
|
525
|
-
]), t.setState({ isForked: !0 });
|
|
526
|
-
},
|
|
527
|
-
/**
|
|
528
|
-
* Resume syncing the Y.js document to the remote
|
|
529
|
-
* If `keepChanges` is true, any changes that have been made to the forked document will be applied to the original document.
|
|
530
|
-
* Otherwise, the original document will be restored and the changes will be discarded.
|
|
531
|
-
*/
|
|
532
|
-
merge({ keepChanges: r }) {
|
|
533
|
-
if (!o)
|
|
534
|
-
return;
|
|
535
|
-
n.unregisterExtension(["ySync", "yCursor", "yUndo"]);
|
|
536
|
-
const { originalFragment: s, forkedFragment: i, undoStack: a } = o;
|
|
537
|
-
if (n.registerExtension([
|
|
538
|
-
K(e),
|
|
539
|
-
ae(e),
|
|
540
|
-
X()
|
|
541
|
-
]), re.getState(
|
|
542
|
-
n.prosemirrorState
|
|
543
|
-
).undoManager.undoStack = a, r) {
|
|
544
|
-
const c = P.encodeStateAsUpdate(
|
|
545
|
-
i.doc,
|
|
546
|
-
P.encodeStateVector(s.doc)
|
|
547
|
-
);
|
|
548
|
-
P.applyUpdate(s.doc, c, n);
|
|
549
|
-
}
|
|
550
|
-
o = void 0, t.setState({ isForked: !1 });
|
|
551
|
-
}
|
|
552
|
-
};
|
|
553
|
-
}
|
|
554
|
-
), Te = (n, e) => {
|
|
555
|
-
e(n), n.forEach((o) => {
|
|
556
|
-
o instanceof P.XmlElement && Te(o, e);
|
|
557
|
-
});
|
|
558
|
-
}, Nt = (n, e) => {
|
|
559
|
-
const o = /* @__PURE__ */ new Map();
|
|
560
|
-
return n.forEach((t) => {
|
|
561
|
-
t instanceof P.XmlElement && Te(t, (r) => {
|
|
562
|
-
if (r.nodeName === "blockContainer" && r.hasAttribute("id")) {
|
|
563
|
-
const s = r.getAttribute("textColor"), i = r.getAttribute("backgroundColor"), a = {
|
|
564
|
-
textColor: s === oe.textColor.default ? void 0 : s,
|
|
565
|
-
backgroundColor: i === oe.backgroundColor.default ? void 0 : i
|
|
566
|
-
};
|
|
567
|
-
(a.textColor || a.backgroundColor) && o.set(r.getAttribute("id"), a);
|
|
568
|
-
}
|
|
569
|
-
});
|
|
570
|
-
}), o.size === 0 ? !1 : (e.doc.descendants((t, r) => {
|
|
571
|
-
if (t.type.name === "blockContainer" && o.has(t.attrs.id)) {
|
|
572
|
-
const s = e.doc.nodeAt(r + 1);
|
|
573
|
-
if (!s)
|
|
574
|
-
throw new Error("No element found");
|
|
575
|
-
e.setNodeMarkup(r + 1, void 0, {
|
|
576
|
-
// preserve existing attributes
|
|
577
|
-
...s.attrs,
|
|
578
|
-
// add the textColor and backgroundColor attributes
|
|
579
|
-
...o.get(t.attrs.id)
|
|
580
|
-
});
|
|
581
|
-
}
|
|
582
|
-
}), !0);
|
|
583
|
-
}, Rt = [Nt], Po = E(
|
|
584
|
-
({ options: n }) => {
|
|
585
|
-
let e = !1;
|
|
586
|
-
const o = new ke("schemaMigration");
|
|
587
|
-
return {
|
|
588
|
-
key: "schemaMigration",
|
|
589
|
-
prosemirrorPlugins: [
|
|
590
|
-
new ve({
|
|
591
|
-
key: o,
|
|
592
|
-
appendTransaction: (t, r, s) => {
|
|
593
|
-
if (e || // If any of the transactions are not due to a yjs sync, we don't need to run the migration
|
|
594
|
-
!t.some((a) => a.getMeta("y-sync$")) || // If none of the transactions result in a document change, we don't need to run the migration
|
|
595
|
-
t.every((a) => !a.docChanged) || // If the fragment is still empty, we can't run the migration (since it has not yet been applied to the Y.Doc)
|
|
596
|
-
!n.fragment.firstChild)
|
|
597
|
-
return;
|
|
598
|
-
const i = s.tr;
|
|
599
|
-
for (const a of Rt)
|
|
600
|
-
a(n.fragment, i);
|
|
601
|
-
if (e = !0, !!i.docChanged)
|
|
602
|
-
return i;
|
|
603
|
-
}
|
|
604
|
-
})
|
|
605
|
-
]
|
|
606
|
-
};
|
|
607
|
-
}
|
|
608
|
-
);
|
|
609
|
-
function le(n, e) {
|
|
610
|
-
return !n || !e ? !1 : !!n.closest(`.${e}`);
|
|
611
|
-
}
|
|
612
|
-
function Vt(n, e, o, t, r) {
|
|
613
|
-
const s = n.state.doc.resolve(e.pos);
|
|
614
|
-
if (!!s.parent.inlineContent || e.orientation === "inline")
|
|
615
|
-
return null;
|
|
616
|
-
const a = s.nodeBefore, c = s.nodeAfter;
|
|
617
|
-
if (!a && !c)
|
|
618
|
-
return null;
|
|
619
|
-
const l = e.orientation === "block-vertical-left" || e.orientation === "block-vertical-right", u = l ? e.pos : e.pos - (a ? a.nodeSize : 0), h = n.nodeDOM(u);
|
|
620
|
-
if (!h)
|
|
621
|
-
return null;
|
|
622
|
-
const f = h.getBoundingClientRect();
|
|
623
|
-
if (l) {
|
|
624
|
-
const d = o / 2 * t, g = e.orientation === "block-vertical-left" ? f.left : f.right;
|
|
625
|
-
return {
|
|
626
|
-
left: g - d,
|
|
627
|
-
right: g + d,
|
|
628
|
-
top: f.top,
|
|
629
|
-
bottom: f.bottom
|
|
630
|
-
};
|
|
631
|
-
}
|
|
632
|
-
let m = a ? f.bottom : f.top;
|
|
633
|
-
a && c && (m = (m + n.nodeDOM(e.pos).getBoundingClientRect().top) / 2);
|
|
634
|
-
const p = o / 2 * r;
|
|
635
|
-
return {
|
|
636
|
-
left: f.left,
|
|
637
|
-
right: f.right,
|
|
638
|
-
top: m - p,
|
|
639
|
-
bottom: m + p
|
|
640
|
-
};
|
|
641
|
-
}
|
|
642
|
-
function Ht(n, e, o, t) {
|
|
643
|
-
const r = n.coordsAtPos(e.pos), s = o / 2 * t;
|
|
644
|
-
return {
|
|
645
|
-
left: r.left - s,
|
|
646
|
-
right: r.left + s,
|
|
647
|
-
top: r.top,
|
|
648
|
-
bottom: r.bottom
|
|
649
|
-
};
|
|
650
|
-
}
|
|
651
|
-
function $t(n, e) {
|
|
652
|
-
n.classList.toggle(
|
|
653
|
-
"prosemirror-dropcursor-inline",
|
|
654
|
-
e === "inline"
|
|
655
|
-
), n.classList.toggle(
|
|
656
|
-
"prosemirror-dropcursor-block-horizontal",
|
|
657
|
-
e === "block-horizontal"
|
|
658
|
-
), n.classList.toggle(
|
|
659
|
-
"prosemirror-dropcursor-block-vertical-left",
|
|
660
|
-
e === "block-vertical-left"
|
|
661
|
-
), n.classList.toggle(
|
|
662
|
-
"prosemirror-dropcursor-block-vertical-right",
|
|
663
|
-
e === "block-vertical-right"
|
|
664
|
-
), n.classList.toggle(
|
|
665
|
-
"prosemirror-dropcursor-block",
|
|
666
|
-
e === "block-horizontal"
|
|
667
|
-
), n.classList.toggle(
|
|
668
|
-
"prosemirror-dropcursor-vertical",
|
|
669
|
-
e === "block-vertical-left" || e === "block-vertical-right"
|
|
670
|
-
);
|
|
671
|
-
}
|
|
672
|
-
function Ft(n) {
|
|
673
|
-
if (!n || n === document.body && getComputedStyle(n).position === "static")
|
|
674
|
-
return {
|
|
675
|
-
parentLeft: -window.pageXOffset,
|
|
676
|
-
parentTop: -window.pageYOffset
|
|
677
|
-
};
|
|
678
|
-
const e = n.getBoundingClientRect(), o = e.width / n.offsetWidth, t = e.height / n.offsetHeight;
|
|
679
|
-
return {
|
|
680
|
-
parentLeft: e.left - n.scrollLeft * o,
|
|
681
|
-
parentTop: e.top - n.scrollTop * t
|
|
682
|
-
};
|
|
683
|
-
}
|
|
684
|
-
const Ut = "bn-drag-exclude", Mo = E(({ editor: n, options: e }) => {
|
|
685
|
-
var d, g, b, y;
|
|
686
|
-
let o = null, t = null, r = -1, s = null;
|
|
687
|
-
const i = {
|
|
688
|
-
width: ((d = e.dropCursor) == null ? void 0 : d.width) ?? 5,
|
|
689
|
-
color: ((g = e.dropCursor) == null ? void 0 : g.color) ?? "#ddeeff",
|
|
690
|
-
exclude: ((b = e.dropCursor) == null ? void 0 : b.exclude) ?? Ut,
|
|
691
|
-
hooks: (y = e.dropCursor) == null ? void 0 : y.hooks
|
|
692
|
-
}, a = (w) => {
|
|
693
|
-
(w == null ? void 0 : w.pos) === (o == null ? void 0 : o.pos) && (w == null ? void 0 : w.orientation) === (o == null ? void 0 : o.orientation) || (o = w, w == null ? (t && t.parentNode && t.parentNode.removeChild(t), t = null) : c());
|
|
694
|
-
}, c = () => {
|
|
695
|
-
if (!o)
|
|
696
|
-
return;
|
|
697
|
-
const w = n.prosemirrorView, v = w.dom, x = v.getBoundingClientRect(), I = x.width / v.offsetWidth, O = x.height / v.offsetHeight, T = Vt(
|
|
698
|
-
w,
|
|
699
|
-
o,
|
|
700
|
-
i.width,
|
|
701
|
-
I,
|
|
702
|
-
O
|
|
703
|
-
) ?? Ht(w, o, i.width, I), C = w.dom.offsetParent;
|
|
704
|
-
t || (t = C.appendChild(document.createElement("div")), t.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", i.color && (t.style.backgroundColor = i.color)), $t(t, o.orientation);
|
|
705
|
-
const { parentLeft: S, parentTop: q } = Ft(C);
|
|
706
|
-
t.style.left = (T.left - S) / I + "px", t.style.top = (T.top - q) / O + "px", t.style.width = (T.right - T.left) / I + "px", t.style.height = (T.bottom - T.top) / O + "px";
|
|
707
|
-
}, l = (w) => {
|
|
708
|
-
clearTimeout(r), r = window.setTimeout(() => a(null), w);
|
|
709
|
-
}, u = (w) => {
|
|
710
|
-
const v = w;
|
|
711
|
-
s = v.target instanceof Element ? v.target : null;
|
|
712
|
-
}, h = (w) => {
|
|
713
|
-
var C;
|
|
714
|
-
const v = w;
|
|
715
|
-
if (s && le(s, i.exclude) || v.target instanceof Element && le(v.target, i.exclude))
|
|
716
|
-
return;
|
|
717
|
-
const x = n.prosemirrorView;
|
|
718
|
-
if (!x.editable)
|
|
719
|
-
return;
|
|
720
|
-
const I = x.posAtCoords({
|
|
721
|
-
left: v.clientX,
|
|
722
|
-
top: v.clientY
|
|
723
|
-
}), O = I && I.inside >= 0 && x.state.doc.nodeAt(I.inside), M = O && O.type.spec.disableDropCursor, T = typeof M == "function" ? M(x, I, v) : M;
|
|
724
|
-
if (I && !T) {
|
|
725
|
-
let S = I.pos;
|
|
726
|
-
if (x.dragging && x.dragging.slice) {
|
|
727
|
-
const R = nt(x.state.doc, S, x.dragging.slice);
|
|
728
|
-
R != null && (S = R);
|
|
729
|
-
}
|
|
730
|
-
const Me = !x.state.doc.resolve(S).parent.inlineContent, G = {
|
|
731
|
-
pos: S,
|
|
732
|
-
orientation: Me ? "block-horizontal" : "inline"
|
|
733
|
-
};
|
|
734
|
-
let J = G;
|
|
735
|
-
if ((C = i.hooks) != null && C.computeDropPosition) {
|
|
736
|
-
const R = i.hooks.computeDropPosition({
|
|
737
|
-
editor: n,
|
|
738
|
-
event: v,
|
|
739
|
-
view: x,
|
|
740
|
-
defaultPosition: G
|
|
741
|
-
});
|
|
742
|
-
if (R === null) {
|
|
743
|
-
a(null);
|
|
744
|
-
return;
|
|
745
|
-
}
|
|
746
|
-
J = R;
|
|
747
|
-
}
|
|
748
|
-
a(J), l(5e3);
|
|
749
|
-
}
|
|
750
|
-
}, f = (w) => {
|
|
751
|
-
const v = w;
|
|
752
|
-
(!(v.relatedTarget instanceof Node) || !n.prosemirrorView.dom.contains(v.relatedTarget)) && a(null);
|
|
753
|
-
}, m = () => {
|
|
754
|
-
l(20);
|
|
755
|
-
}, p = () => {
|
|
756
|
-
l(20), s = null;
|
|
757
|
-
};
|
|
758
|
-
return {
|
|
759
|
-
key: "dropCursor",
|
|
760
|
-
mount({ signal: w, dom: v, root: x }) {
|
|
761
|
-
x.addEventListener("dragstart", u, {
|
|
762
|
-
capture: !0,
|
|
763
|
-
signal: w
|
|
764
|
-
}), v.addEventListener("dragover", h, { signal: w }), v.addEventListener("dragleave", f, { signal: w }), v.addEventListener("drop", m, { signal: w }), v.addEventListener("dragend", p, { signal: w }), w.addEventListener("abort", () => {
|
|
765
|
-
clearTimeout(r), a(null);
|
|
766
|
-
});
|
|
767
|
-
}
|
|
768
|
-
};
|
|
769
|
-
}), Ao = E(({ editor: n }) => {
|
|
770
|
-
const e = j(!1), o = () => n.transact((t) => {
|
|
771
|
-
var s;
|
|
772
|
-
if (t.selection.empty || t.selection instanceof pe && (t.selection.node.type.spec.content === "inline*" || ((s = t.selection.node.firstChild) == null ? void 0 : s.type.spec.content) === "inline*") || t.selection instanceof fe && t.doc.textBetween(t.selection.from, t.selection.to).length === 0)
|
|
773
|
-
return !1;
|
|
774
|
-
let r = !1;
|
|
775
|
-
return t.selection.content().content.descendants((i) => (i.type.spec.code && (r = !0), !r)), !r;
|
|
776
|
-
});
|
|
777
|
-
return {
|
|
778
|
-
key: "formattingToolbar",
|
|
779
|
-
store: e,
|
|
780
|
-
mount({ dom: t, signal: r }) {
|
|
781
|
-
let s = !1;
|
|
782
|
-
const i = n.onChange(() => {
|
|
783
|
-
s || e.setState(o());
|
|
784
|
-
}), a = n.onSelectionChange(() => {
|
|
785
|
-
s || e.setState(o());
|
|
786
|
-
});
|
|
787
|
-
t.addEventListener(
|
|
788
|
-
"pointerdown",
|
|
789
|
-
() => {
|
|
790
|
-
s = !0, e.setState(!1);
|
|
791
|
-
},
|
|
792
|
-
{ signal: r }
|
|
793
|
-
), n.prosemirrorView.root.addEventListener(
|
|
794
|
-
"pointerup",
|
|
795
|
-
() => {
|
|
796
|
-
s = !1, n.isFocused() && e.setState(o());
|
|
797
|
-
},
|
|
798
|
-
{ signal: r, capture: !0 }
|
|
799
|
-
), t.addEventListener(
|
|
800
|
-
"pointercancel",
|
|
801
|
-
() => {
|
|
802
|
-
s = !1;
|
|
803
|
-
},
|
|
804
|
-
{
|
|
805
|
-
signal: r,
|
|
806
|
-
capture: !0
|
|
807
|
-
}
|
|
808
|
-
), r.addEventListener("abort", () => {
|
|
809
|
-
i(), a();
|
|
810
|
-
});
|
|
811
|
-
}
|
|
812
|
-
};
|
|
813
|
-
}), Lo = E(() => ({
|
|
814
|
-
key: "history",
|
|
815
|
-
prosemirrorPlugins: [it()],
|
|
816
|
-
undoCommand: st,
|
|
817
|
-
redoCommand: rt
|
|
818
|
-
})), No = E(({ editor: n }) => {
|
|
819
|
-
function e(r) {
|
|
820
|
-
let s = n.prosemirrorView.nodeDOM(r);
|
|
821
|
-
for (; s && s.parentElement; ) {
|
|
822
|
-
if (s.nodeName === "A")
|
|
823
|
-
return s;
|
|
824
|
-
s = s.parentElement;
|
|
825
|
-
}
|
|
826
|
-
return null;
|
|
827
|
-
}
|
|
828
|
-
function o(r, s) {
|
|
829
|
-
return n.transact((i) => {
|
|
830
|
-
const a = i.doc.resolve(r), c = a.marks().find((u) => u.type.name === s);
|
|
831
|
-
if (!c)
|
|
832
|
-
return;
|
|
833
|
-
const l = Re(a, c.type);
|
|
834
|
-
if (l)
|
|
835
|
-
return {
|
|
836
|
-
range: l,
|
|
837
|
-
mark: c,
|
|
838
|
-
get text() {
|
|
839
|
-
return i.doc.textBetween(l.from, l.to);
|
|
840
|
-
},
|
|
841
|
-
get position() {
|
|
842
|
-
return Ve(
|
|
843
|
-
n.prosemirrorView,
|
|
844
|
-
l.from,
|
|
845
|
-
l.to
|
|
846
|
-
).toJSON();
|
|
847
|
-
}
|
|
848
|
-
};
|
|
849
|
-
});
|
|
850
|
-
}
|
|
851
|
-
function t() {
|
|
852
|
-
return n.transact((r) => {
|
|
853
|
-
const s = r.selection;
|
|
854
|
-
if (s.empty)
|
|
855
|
-
return o(s.anchor, "link");
|
|
856
|
-
});
|
|
857
|
-
}
|
|
858
|
-
return {
|
|
859
|
-
key: "linkToolbar",
|
|
860
|
-
getLinkAtSelection: t,
|
|
861
|
-
getLinkElementAtPos: e,
|
|
862
|
-
getMarkAtPos: o,
|
|
863
|
-
getLinkAtElement(r) {
|
|
864
|
-
return n.transact(() => {
|
|
865
|
-
const s = n.prosemirrorView.posAtDOM(r, 0) + 1;
|
|
866
|
-
return o(s, "link");
|
|
867
|
-
});
|
|
868
|
-
},
|
|
869
|
-
editLink(r, s, i = n.transact((a) => a.selection.anchor)) {
|
|
870
|
-
n.transact((a) => {
|
|
871
|
-
const c = _(a), { range: l } = o(i + 1, "link") || {
|
|
872
|
-
range: {
|
|
873
|
-
from: a.selection.from,
|
|
874
|
-
to: a.selection.to
|
|
875
|
-
}
|
|
876
|
-
};
|
|
877
|
-
l && (a.insertText(s, l.from, l.to), a.addMark(
|
|
878
|
-
l.from,
|
|
879
|
-
l.from + s.length,
|
|
880
|
-
c.mark("link", { href: r })
|
|
881
|
-
));
|
|
882
|
-
}), n.prosemirrorView.focus();
|
|
883
|
-
},
|
|
884
|
-
deleteLink(r = n.transact((s) => s.selection.anchor)) {
|
|
885
|
-
n.transact((s) => {
|
|
886
|
-
const i = _(s), { range: a } = o(r + 1, "link") || {
|
|
887
|
-
range: {
|
|
888
|
-
from: s.selection.from,
|
|
889
|
-
to: s.selection.to
|
|
890
|
-
}
|
|
891
|
-
};
|
|
892
|
-
a && s.removeMark(a.from, a.to, i.marks.link).setMeta(
|
|
893
|
-
"preventAutolink",
|
|
894
|
-
!0
|
|
895
|
-
);
|
|
896
|
-
}), n.prosemirrorView.focus();
|
|
897
|
-
}
|
|
898
|
-
};
|
|
899
|
-
}), Ro = [
|
|
900
|
-
"http",
|
|
901
|
-
"https",
|
|
902
|
-
"ftp",
|
|
903
|
-
"ftps",
|
|
904
|
-
"mailto",
|
|
905
|
-
"tel",
|
|
906
|
-
"callto",
|
|
907
|
-
"sms",
|
|
908
|
-
"cid",
|
|
909
|
-
"xmpp"
|
|
910
|
-
], Vo = "https", _t = new N("node-selection-keyboard"), Ho = E(
|
|
911
|
-
() => ({
|
|
912
|
-
key: "nodeSelectionKeyboard",
|
|
913
|
-
prosemirrorPlugins: [
|
|
914
|
-
new L({
|
|
915
|
-
key: _t,
|
|
916
|
-
props: {
|
|
917
|
-
handleKeyDown: (n, e) => {
|
|
918
|
-
if ("node" in n.state.selection) {
|
|
919
|
-
if (e.ctrlKey || e.metaKey)
|
|
920
|
-
return !1;
|
|
921
|
-
if (e.key.length === 1)
|
|
922
|
-
return e.preventDefault(), !0;
|
|
923
|
-
if (e.key === "Enter" && !e.isComposing && !e.shiftKey && !e.altKey && !e.ctrlKey && !e.metaKey) {
|
|
924
|
-
const o = n.state.tr;
|
|
925
|
-
return n.dispatch(
|
|
926
|
-
o.insert(
|
|
927
|
-
n.state.tr.selection.$to.after(),
|
|
928
|
-
n.state.schema.nodes.paragraph.createChecked()
|
|
929
|
-
).setSelection(
|
|
930
|
-
new fe(
|
|
931
|
-
o.doc.resolve(
|
|
932
|
-
n.state.tr.selection.$to.after() + 1
|
|
933
|
-
)
|
|
934
|
-
)
|
|
935
|
-
)
|
|
936
|
-
), !0;
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
return !1;
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
})
|
|
943
|
-
]
|
|
944
|
-
})
|
|
945
|
-
), zt = new N("blocknote-placeholder"), $o = E(
|
|
946
|
-
({
|
|
947
|
-
editor: n,
|
|
948
|
-
options: e
|
|
949
|
-
}) => {
|
|
950
|
-
const o = e.placeholders;
|
|
951
|
-
return {
|
|
952
|
-
key: "placeholder",
|
|
953
|
-
prosemirrorPlugins: [
|
|
954
|
-
new L({
|
|
955
|
-
key: zt,
|
|
956
|
-
view: (t) => {
|
|
957
|
-
const r = `placeholder-selector-${at()}`;
|
|
958
|
-
t.dom.classList.add(r);
|
|
959
|
-
const s = document.createElement("style"), i = n._tiptapEditor.options.injectNonce;
|
|
960
|
-
i && s.setAttribute("nonce", i), t.root instanceof window.ShadowRoot ? t.root.append(s) : t.root.head.appendChild(s);
|
|
961
|
-
const a = s.sheet, c = (l = "") => `.${r} .bn-block-content${l} .bn-inline-content:has(> .ProseMirror-trailingBreak:only-child):before`;
|
|
962
|
-
try {
|
|
963
|
-
const {
|
|
964
|
-
default: l,
|
|
965
|
-
emptyDocument: u,
|
|
966
|
-
...h
|
|
967
|
-
} = o || {};
|
|
968
|
-
for (const [p, d] of Object.entries(h)) {
|
|
969
|
-
const g = `[data-content-type="${p}"]`;
|
|
970
|
-
a.insertRule(
|
|
971
|
-
`${c(g)} { content: ${JSON.stringify(
|
|
972
|
-
d
|
|
973
|
-
)}; }`
|
|
974
|
-
);
|
|
975
|
-
}
|
|
976
|
-
const f = "[data-is-only-empty-block]", m = "[data-is-empty-and-focused]";
|
|
977
|
-
a.insertRule(
|
|
978
|
-
`${c(f)} { content: ${JSON.stringify(
|
|
979
|
-
u
|
|
980
|
-
)}; }`
|
|
981
|
-
), a.insertRule(
|
|
982
|
-
`${c(m)} { content: ${JSON.stringify(
|
|
983
|
-
l
|
|
984
|
-
)}; }`
|
|
985
|
-
);
|
|
986
|
-
} catch (l) {
|
|
987
|
-
console.warn(
|
|
988
|
-
"Failed to insert placeholder CSS rule - this is likely due to the browser not supporting certain CSS pseudo-element selectors (:has, :only-child:, or :before)",
|
|
989
|
-
l
|
|
990
|
-
);
|
|
991
|
-
}
|
|
992
|
-
return {
|
|
993
|
-
destroy: () => {
|
|
994
|
-
t.root instanceof window.ShadowRoot ? t.root.removeChild(s) : t.root.head.removeChild(s);
|
|
995
|
-
}
|
|
996
|
-
};
|
|
997
|
-
},
|
|
998
|
-
props: {
|
|
999
|
-
decorations: (t) => {
|
|
1000
|
-
const { doc: r, selection: s } = t;
|
|
1001
|
-
if (!n.isEditable || !s.empty || s.$from.parent.type.spec.code)
|
|
1002
|
-
return;
|
|
1003
|
-
const i = [];
|
|
1004
|
-
t.doc.content.size === 6 && i.push(
|
|
1005
|
-
H.node(2, 4, {
|
|
1006
|
-
"data-is-only-empty-block": "true"
|
|
1007
|
-
})
|
|
1008
|
-
);
|
|
1009
|
-
const a = s.$anchor, c = a.parent;
|
|
1010
|
-
if (c.content.size === 0) {
|
|
1011
|
-
const l = a.before();
|
|
1012
|
-
i.push(
|
|
1013
|
-
H.node(l, l + c.nodeSize, {
|
|
1014
|
-
"data-is-empty-and-focused": "true"
|
|
1015
|
-
})
|
|
1016
|
-
);
|
|
1017
|
-
}
|
|
1018
|
-
return Y.create(r, i);
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
})
|
|
1022
|
-
]
|
|
1023
|
-
};
|
|
1024
|
-
}
|
|
1025
|
-
), ce = new N("previous-blocks"), Yt = {
|
|
1026
|
-
// Numbered List Items
|
|
1027
|
-
index: "index",
|
|
1028
|
-
// Headings
|
|
1029
|
-
level: "level",
|
|
1030
|
-
// All Blocks
|
|
1031
|
-
type: "type",
|
|
1032
|
-
depth: "depth",
|
|
1033
|
-
"depth-change": "depth-change"
|
|
1034
|
-
}, Fo = E(() => {
|
|
1035
|
-
let n;
|
|
1036
|
-
return {
|
|
1037
|
-
key: "previousBlockType",
|
|
1038
|
-
prosemirrorPlugins: [
|
|
1039
|
-
new L({
|
|
1040
|
-
key: ce,
|
|
1041
|
-
view(e) {
|
|
1042
|
-
return {
|
|
1043
|
-
update: async (o, t) => {
|
|
1044
|
-
var r;
|
|
1045
|
-
((r = this.key) == null ? void 0 : r.getState(o.state).updatedBlocks.size) > 0 && (n = setTimeout(() => {
|
|
1046
|
-
o.dispatch(
|
|
1047
|
-
o.state.tr.setMeta(ce, { clearUpdate: !0 })
|
|
1048
|
-
);
|
|
1049
|
-
}, 0));
|
|
1050
|
-
},
|
|
1051
|
-
destroy: () => {
|
|
1052
|
-
n && clearTimeout(n);
|
|
1053
|
-
}
|
|
1054
|
-
};
|
|
1055
|
-
},
|
|
1056
|
-
state: {
|
|
1057
|
-
init() {
|
|
1058
|
-
return {
|
|
1059
|
-
// Block attributes, by block ID, from just before the previous transaction.
|
|
1060
|
-
prevTransactionOldBlockAttrs: {},
|
|
1061
|
-
// Block attributes, by block ID, from just before the current transaction.
|
|
1062
|
-
currentTransactionOldBlockAttrs: {},
|
|
1063
|
-
// Set of IDs of blocks whose attributes changed from the current transaction.
|
|
1064
|
-
updatedBlocks: /* @__PURE__ */ new Set()
|
|
1065
|
-
};
|
|
1066
|
-
},
|
|
1067
|
-
apply(e, o, t, r) {
|
|
1068
|
-
if (o.currentTransactionOldBlockAttrs = {}, o.updatedBlocks.clear(), !e.docChanged || t.doc.eq(r.doc))
|
|
1069
|
-
return o;
|
|
1070
|
-
const s = {}, i = Q(
|
|
1071
|
-
t.doc,
|
|
1072
|
-
(l) => l.attrs.id
|
|
1073
|
-
), a = new Map(
|
|
1074
|
-
i.map((l) => [l.node.attrs.id, l])
|
|
1075
|
-
), c = Q(
|
|
1076
|
-
r.doc,
|
|
1077
|
-
(l) => l.attrs.id
|
|
1078
|
-
);
|
|
1079
|
-
for (const l of c) {
|
|
1080
|
-
const u = a.get(l.node.attrs.id), h = u == null ? void 0 : u.node.firstChild, f = l.node.firstChild;
|
|
1081
|
-
if (u && h && f) {
|
|
1082
|
-
const m = {
|
|
1083
|
-
index: f.attrs.index,
|
|
1084
|
-
level: f.attrs.level,
|
|
1085
|
-
type: f.type.name,
|
|
1086
|
-
depth: r.doc.resolve(l.pos).depth
|
|
1087
|
-
}, p = {
|
|
1088
|
-
index: h.attrs.index,
|
|
1089
|
-
level: h.attrs.level,
|
|
1090
|
-
type: h.type.name,
|
|
1091
|
-
depth: t.doc.resolve(u.pos).depth
|
|
1092
|
-
};
|
|
1093
|
-
s[l.node.attrs.id] = p, o.currentTransactionOldBlockAttrs[l.node.attrs.id] = p, JSON.stringify(p) !== JSON.stringify(m) && (p["depth-change"] = p.depth - m.depth, o.updatedBlocks.add(l.node.attrs.id));
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
return o.prevTransactionOldBlockAttrs = s, o;
|
|
1097
|
-
}
|
|
1098
|
-
},
|
|
1099
|
-
props: {
|
|
1100
|
-
decorations(e) {
|
|
1101
|
-
const o = this.getState(e);
|
|
1102
|
-
if (o.updatedBlocks.size === 0)
|
|
1103
|
-
return;
|
|
1104
|
-
const t = [];
|
|
1105
|
-
return e.doc.descendants((r, s) => {
|
|
1106
|
-
if (!r.attrs.id || !o.updatedBlocks.has(r.attrs.id))
|
|
1107
|
-
return;
|
|
1108
|
-
const i = o.currentTransactionOldBlockAttrs[r.attrs.id], a = {};
|
|
1109
|
-
for (const [l, u] of Object.entries(i))
|
|
1110
|
-
a["data-prev-" + Yt[l]] = u || "none";
|
|
1111
|
-
const c = H.node(s, s + r.nodeSize, {
|
|
1112
|
-
...a
|
|
1113
|
-
});
|
|
1114
|
-
t.push(c);
|
|
1115
|
-
}), Y.create(e.doc, t);
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
})
|
|
1119
|
-
]
|
|
1120
|
-
};
|
|
1121
|
-
});
|
|
1122
|
-
function De(n, e) {
|
|
1123
|
-
var o, t;
|
|
1124
|
-
for (; n && n.parentElement && n.parentElement !== e.dom && ((o = n.getAttribute) == null ? void 0 : o.call(n, "data-node-type")) !== "blockContainer"; )
|
|
1125
|
-
n = n.parentElement;
|
|
1126
|
-
if (((t = n.getAttribute) == null ? void 0 : t.call(n, "data-node-type")) === "blockContainer")
|
|
1127
|
-
return { node: n, id: n.getAttribute("data-id") };
|
|
1128
|
-
}
|
|
1129
|
-
function jt() {
|
|
1130
|
-
const n = (e) => {
|
|
1131
|
-
let o = e.children.length;
|
|
1132
|
-
for (let t = 0; t < o; t++) {
|
|
1133
|
-
const r = e.children[t];
|
|
1134
|
-
if (r.type === "element" && (n(r), r.tagName === "u"))
|
|
1135
|
-
if (r.children.length > 0) {
|
|
1136
|
-
e.children.splice(t, 1, ...r.children);
|
|
1137
|
-
const s = r.children.length - 1;
|
|
1138
|
-
o += s, t += s;
|
|
1139
|
-
} else
|
|
1140
|
-
e.children.splice(t, 1), o--, t--;
|
|
1141
|
-
}
|
|
1142
|
-
};
|
|
1143
|
-
return n;
|
|
1144
|
-
}
|
|
1145
|
-
function Kt() {
|
|
1146
|
-
const n = (e) => {
|
|
1147
|
-
var o;
|
|
1148
|
-
if (e.children && "length" in e.children && e.children.length)
|
|
1149
|
-
for (let t = e.children.length - 1; t >= 0; t--) {
|
|
1150
|
-
const r = e.children[t], s = t + 1 < e.children.length ? e.children[t + 1] : void 0;
|
|
1151
|
-
r.type === "element" && r.tagName === "input" && ((o = r.properties) == null ? void 0 : o.type) === "checkbox" && (s == null ? void 0 : s.type) === "element" && s.tagName === "p" ? (s.tagName = "span", s.children.splice(
|
|
1152
|
-
0,
|
|
1153
|
-
0,
|
|
1154
|
-
gt(document.createTextNode(" "))
|
|
1155
|
-
)) : n(r);
|
|
1156
|
-
}
|
|
1157
|
-
};
|
|
1158
|
-
return n;
|
|
1159
|
-
}
|
|
1160
|
-
function Xt() {
|
|
1161
|
-
return (n) => {
|
|
1162
|
-
wt(n, "element", (e, o, t) => {
|
|
1163
|
-
var r, s, i, a;
|
|
1164
|
-
if (t && e.tagName === "video") {
|
|
1165
|
-
const c = ((r = e.properties) == null ? void 0 : r.src) || ((s = e.properties) == null ? void 0 : s["data-url"]) || "", l = ((i = e.properties) == null ? void 0 : i.title) || ((a = e.properties) == null ? void 0 : a["data-name"]) || "";
|
|
1166
|
-
t.children[o] = {
|
|
1167
|
-
type: "text",
|
|
1168
|
-
value: ``
|
|
1169
|
-
};
|
|
1170
|
-
}
|
|
1171
|
-
});
|
|
1172
|
-
};
|
|
1173
|
-
}
|
|
1174
|
-
function Oe(n) {
|
|
1175
|
-
return ft().use(ut, { fragment: !0 }).use(Xt).use(jt).use(Kt).use(ht).use(mt).use(pt, {
|
|
1176
|
-
handlers: { text: (o) => o.value }
|
|
1177
|
-
}).processSync(n).value;
|
|
1178
|
-
}
|
|
1179
|
-
function Uo(n, e, o, t) {
|
|
1180
|
-
const s = Be(e, o).exportBlocks(n, t);
|
|
1181
|
-
return Oe(s);
|
|
1182
|
-
}
|
|
1183
|
-
function Wt(n) {
|
|
1184
|
-
const e = [];
|
|
1185
|
-
return n.descendants((o) => {
|
|
1186
|
-
var r, s;
|
|
1187
|
-
const t = _(o);
|
|
1188
|
-
return o.type.name === "blockContainer" && ((r = o.firstChild) == null ? void 0 : r.type.name) === "blockGroup" ? !0 : o.type.name === "columnList" && o.childCount === 1 ? ((s = o.firstChild) == null || s.forEach((i) => {
|
|
1189
|
-
e.push(z(i, t));
|
|
1190
|
-
}), !1) : o.type.isInGroup("bnBlock") ? (e.push(z(o, t)), !1) : !0;
|
|
1191
|
-
}), e;
|
|
1192
|
-
}
|
|
1193
|
-
class A extends U {
|
|
1194
|
-
constructor(o, t) {
|
|
1195
|
-
super(o, t);
|
|
1196
|
-
k(this, "nodes");
|
|
1197
|
-
const r = o.node();
|
|
1198
|
-
this.nodes = [], o.doc.nodesBetween(o.pos, t.pos, (s, i, a) => {
|
|
1199
|
-
if (a !== null && a.eq(r))
|
|
1200
|
-
return this.nodes.push(s), !1;
|
|
1201
|
-
});
|
|
1202
|
-
}
|
|
1203
|
-
static create(o, t, r = t) {
|
|
1204
|
-
return new A(o.resolve(t), o.resolve(r));
|
|
1205
|
-
}
|
|
1206
|
-
content() {
|
|
1207
|
-
return new dt(Se.from(this.nodes), 0, 0);
|
|
1208
|
-
}
|
|
1209
|
-
eq(o) {
|
|
1210
|
-
if (!(o instanceof A) || this.nodes.length !== o.nodes.length || this.from !== o.from || this.to !== o.to)
|
|
1211
|
-
return !1;
|
|
1212
|
-
for (let t = 0; t < this.nodes.length; t++)
|
|
1213
|
-
if (!this.nodes[t].eq(o.nodes[t]))
|
|
1214
|
-
return !1;
|
|
1215
|
-
return !0;
|
|
1216
|
-
}
|
|
1217
|
-
map(o, t) {
|
|
1218
|
-
const r = t.mapResult(this.from), s = t.mapResult(this.to);
|
|
1219
|
-
return s.deleted ? U.near(o.resolve(r.pos)) : r.deleted ? U.near(o.resolve(s.pos)) : new A(
|
|
1220
|
-
o.resolve(r.pos),
|
|
1221
|
-
o.resolve(s.pos)
|
|
1222
|
-
);
|
|
1223
|
-
}
|
|
1224
|
-
toJSON() {
|
|
1225
|
-
return { type: "multiple-node", anchor: this.anchor, head: this.head };
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
1228
|
-
U.jsonID("multiple-node", A);
|
|
1229
|
-
let D;
|
|
1230
|
-
function qt(n, e) {
|
|
1231
|
-
let o, t;
|
|
1232
|
-
const r = e.resolve(n.from).node().type.spec.group === "blockContent", s = e.resolve(n.to).node().type.spec.group === "blockContent", i = Math.min(n.$anchor.depth, n.$head.depth);
|
|
1233
|
-
if (r && s) {
|
|
1234
|
-
const a = n.$from.start(i - 1), c = n.$to.end(i - 1);
|
|
1235
|
-
o = e.resolve(a - 1).pos, t = e.resolve(c + 1).pos;
|
|
1236
|
-
} else
|
|
1237
|
-
o = n.from, t = n.to;
|
|
1238
|
-
return { from: o, to: t };
|
|
1239
|
-
}
|
|
1240
|
-
function de(n, e, o = e) {
|
|
1241
|
-
e === o && (o += n.state.doc.resolve(e + 1).node().nodeSize);
|
|
1242
|
-
const t = n.domAtPos(e).node.cloneNode(!0), r = n.domAtPos(e).node, s = (h, f) => Array.prototype.indexOf.call(h.children, f), i = s(
|
|
1243
|
-
r,
|
|
1244
|
-
// Expects from position to be just before the first selected block.
|
|
1245
|
-
n.domAtPos(e + 1).node.parentElement
|
|
1246
|
-
), a = s(
|
|
1247
|
-
r,
|
|
1248
|
-
// Expects to position to be just after the last selected block.
|
|
1249
|
-
n.domAtPos(o - 1).node.parentElement
|
|
1250
|
-
);
|
|
1251
|
-
for (let h = r.childElementCount - 1; h >= 0; h--)
|
|
1252
|
-
(h > a || h < i) && t.removeChild(t.children[h]);
|
|
1253
|
-
Pe(n.root), D = t;
|
|
1254
|
-
const c = D.getElementsByTagName("iframe");
|
|
1255
|
-
for (let h = 0; h < c.length; h++) {
|
|
1256
|
-
const f = c[h], m = f.parentElement;
|
|
1257
|
-
m && m.removeChild(f);
|
|
1258
|
-
}
|
|
1259
|
-
const u = n.dom.className.split(" ").filter(
|
|
1260
|
-
(h) => h !== "ProseMirror" && h !== "bn-root" && h !== "bn-editor"
|
|
1261
|
-
).join(" ");
|
|
1262
|
-
D.className = D.className + " bn-drag-preview " + u, n.root instanceof ShadowRoot ? n.root.appendChild(D) : n.root.body.appendChild(D);
|
|
1263
|
-
}
|
|
1264
|
-
function Pe(n) {
|
|
1265
|
-
D !== void 0 && (n instanceof ShadowRoot ? n.removeChild(D) : n.body.removeChild(D), D = void 0);
|
|
1266
|
-
}
|
|
1267
|
-
function Gt(n, e, o) {
|
|
1268
|
-
if (!n.dataTransfer || o.headless)
|
|
1269
|
-
return;
|
|
1270
|
-
const t = o.prosemirrorView, r = ye(e.id, t.state.doc);
|
|
1271
|
-
if (!r)
|
|
1272
|
-
throw new Error(`Block with ID ${e.id} not found`);
|
|
1273
|
-
const s = r.posBeforeNode;
|
|
1274
|
-
if (s != null) {
|
|
1275
|
-
const i = t.state.selection, a = t.state.doc, { from: c, to: l } = qt(i, a), u = c <= s && s < l, h = i.$anchor.node() !== i.$head.node() || i instanceof A;
|
|
1276
|
-
u && h ? (t.dispatch(
|
|
1277
|
-
t.state.tr.setSelection(A.create(a, c, l))
|
|
1278
|
-
), de(t, c, l)) : (t.dispatch(
|
|
1279
|
-
t.state.tr.setSelection(pe.create(t.state.doc, s))
|
|
1280
|
-
), de(t, s));
|
|
1281
|
-
const f = t.state.selection.content(), m = o.pmSchema, p = t.serializeForClipboard(f).dom.innerHTML, d = Be(m, o), g = Wt(f.content), b = d.exportBlocks(g, {}), y = Oe(b);
|
|
1282
|
-
n.dataTransfer.clearData(), n.dataTransfer.setData("blocknote/html", p), n.dataTransfer.setData("text/html", b), n.dataTransfer.setData("text/plain", y), n.dataTransfer.effectAllowed = "move", n.dataTransfer.setDragImage(D, 0, 0);
|
|
1283
|
-
}
|
|
1284
|
-
}
|
|
1285
|
-
const ue = 250;
|
|
1286
|
-
function W(n, e, o = !0) {
|
|
1287
|
-
const t = n.root.elementsFromPoint(e.left, e.top);
|
|
1288
|
-
for (const r of t)
|
|
1289
|
-
if (n.dom.contains(r))
|
|
1290
|
-
return o && r.closest("[data-node-type=columnList]") ? W(
|
|
1291
|
-
n,
|
|
1292
|
-
{
|
|
1293
|
-
// TODO can we do better than this?
|
|
1294
|
-
left: e.left + 50,
|
|
1295
|
-
// bit hacky, but if we're inside a column, offset x position to right to account for the width of sidemenu itself
|
|
1296
|
-
top: e.top
|
|
1297
|
-
},
|
|
1298
|
-
!1
|
|
1299
|
-
) : De(r, n);
|
|
1300
|
-
}
|
|
1301
|
-
function Jt(n, e) {
|
|
1302
|
-
if (!e.dom.firstChild)
|
|
1303
|
-
return;
|
|
1304
|
-
const o = e.dom.firstChild.getBoundingClientRect(), t = {
|
|
1305
|
-
// Clamps the x position to the editor's bounding box.
|
|
1306
|
-
left: Math.min(
|
|
1307
|
-
Math.max(o.left + 10, n.x),
|
|
1308
|
-
o.right - 10
|
|
1309
|
-
),
|
|
1310
|
-
top: n.y
|
|
1311
|
-
}, r = W(e, t);
|
|
1312
|
-
if (!r)
|
|
1313
|
-
return;
|
|
1314
|
-
const s = r.node.getBoundingClientRect();
|
|
1315
|
-
return W(
|
|
1316
|
-
e,
|
|
1317
|
-
{
|
|
1318
|
-
left: s.right - 10,
|
|
1319
|
-
top: n.y
|
|
1320
|
-
},
|
|
1321
|
-
!1
|
|
1322
|
-
);
|
|
1323
|
-
}
|
|
1324
|
-
class Qt {
|
|
1325
|
-
constructor(e, o, t) {
|
|
1326
|
-
k(this, "state");
|
|
1327
|
-
k(this, "emitUpdate");
|
|
1328
|
-
k(this, "mousePos");
|
|
1329
|
-
k(this, "hoveredBlock");
|
|
1330
|
-
k(this, "menuFrozen", !1);
|
|
1331
|
-
k(this, "isDragOrigin", !1);
|
|
1332
|
-
k(this, "updateState", (e) => {
|
|
1333
|
-
this.state = e, this.emitUpdate(this.state);
|
|
1334
|
-
});
|
|
1335
|
-
k(this, "updateStateFromMousePos", () => {
|
|
1336
|
-
var t, r, s, i, a;
|
|
1337
|
-
if (this.menuFrozen || !this.mousePos)
|
|
1338
|
-
return;
|
|
1339
|
-
const e = this.findClosestEditorElement({
|
|
1340
|
-
clientX: this.mousePos.x,
|
|
1341
|
-
clientY: this.mousePos.y
|
|
1342
|
-
});
|
|
1343
|
-
if ((e == null ? void 0 : e.element) !== this.pmView.dom || e.distance > ue) {
|
|
1344
|
-
(t = this.state) != null && t.show && (this.state.show = !1, this.updateState(this.state));
|
|
1345
|
-
return;
|
|
1346
|
-
}
|
|
1347
|
-
const o = Jt(this.mousePos, this.pmView);
|
|
1348
|
-
if (!o || !this.editor.isEditable) {
|
|
1349
|
-
(r = this.state) != null && r.show && (this.state.show = !1, this.updateState(this.state));
|
|
1350
|
-
return;
|
|
1351
|
-
}
|
|
1352
|
-
if (!((s = this.state) != null && s.show && ((i = this.hoveredBlock) != null && i.hasAttribute("data-id")) && ((a = this.hoveredBlock) == null ? void 0 : a.getAttribute("data-id")) === o.id) && (this.hoveredBlock = o.node, this.editor.isEditable)) {
|
|
1353
|
-
const c = o.node.getBoundingClientRect(), l = o.node.closest("[data-node-type=column]");
|
|
1354
|
-
this.state = {
|
|
1355
|
-
show: !0,
|
|
1356
|
-
referencePos: new DOMRect(
|
|
1357
|
-
l ? (
|
|
1358
|
-
// We take the first child as column elements have some default
|
|
1359
|
-
// padding. This is a little weird since this child element will
|
|
1360
|
-
// be the first block, but since it's always non-nested and we
|
|
1361
|
-
// only take the x coordinate, it's ok.
|
|
1362
|
-
l.firstElementChild.getBoundingClientRect().x
|
|
1363
|
-
) : this.pmView.dom.firstChild.getBoundingClientRect().x,
|
|
1364
|
-
c.y,
|
|
1365
|
-
c.width,
|
|
1366
|
-
c.height
|
|
1367
|
-
),
|
|
1368
|
-
block: this.editor.getBlock(
|
|
1369
|
-
this.hoveredBlock.getAttribute("data-id")
|
|
1370
|
-
)
|
|
1371
|
-
}, this.updateState(this.state);
|
|
1372
|
-
}
|
|
1373
|
-
});
|
|
1374
|
-
/**
|
|
1375
|
-
* If a block is being dragged, ProseMirror usually gets the context of what's
|
|
1376
|
-
* being dragged from `view.dragging`, which is automatically set when a
|
|
1377
|
-
* `dragstart` event fires in the editor. However, if the user tries to drag
|
|
1378
|
-
* and drop blocks between multiple editors, only the one in which the drag
|
|
1379
|
-
* began has that context, so we need to set it on the others manually. This
|
|
1380
|
-
* ensures that PM always drops the blocks in between other blocks, and not
|
|
1381
|
-
* inside them.
|
|
1382
|
-
*
|
|
1383
|
-
* After the `dragstart` event fires on the drag handle, it sets
|
|
1384
|
-
* `blocknote/html` data on the clipboard. This handler fires right after,
|
|
1385
|
-
* parsing the `blocknote/html` data into nodes and setting them on
|
|
1386
|
-
* `view.dragging`.
|
|
1387
|
-
*
|
|
1388
|
-
* Note: Setting `view.dragging` on `dragover` would be better as the user
|
|
1389
|
-
* could then drag between editors in different windows, but you can only
|
|
1390
|
-
* access `dataTransfer` contents on `dragstart` and `drop` events.
|
|
1391
|
-
*/
|
|
1392
|
-
k(this, "onDragStart", (e) => {
|
|
1393
|
-
var i;
|
|
1394
|
-
const o = (i = e.dataTransfer) == null ? void 0 : i.getData("blocknote/html");
|
|
1395
|
-
if (!o || this.pmView.dragging)
|
|
1396
|
-
return;
|
|
1397
|
-
const t = document.createElement("div");
|
|
1398
|
-
t.innerHTML = o;
|
|
1399
|
-
const s = lt.fromSchema(this.pmView.state.schema).parse(t, {
|
|
1400
|
-
topNode: this.pmView.state.schema.nodes.blockGroup.create()
|
|
1401
|
-
});
|
|
1402
|
-
this.pmView.dragging = {
|
|
1403
|
-
slice: new ct(s.content, 0, 0),
|
|
1404
|
-
move: !0
|
|
1405
|
-
};
|
|
1406
|
-
});
|
|
1407
|
-
/**
|
|
1408
|
-
* Finds the closest editor visually to the given coordinates
|
|
1409
|
-
*/
|
|
1410
|
-
k(this, "findClosestEditorElement", (e) => {
|
|
1411
|
-
const o = Array.from(this.pmView.root.querySelectorAll(".bn-editor"));
|
|
1412
|
-
if (o.length === 0)
|
|
1413
|
-
return null;
|
|
1414
|
-
let t = o[0], r = Number.MAX_VALUE;
|
|
1415
|
-
return o.forEach((s) => {
|
|
1416
|
-
const i = s.querySelector(".bn-block-group").getBoundingClientRect(), a = e.clientX < i.left ? i.left - e.clientX : e.clientX > i.right ? e.clientX - i.right : 0, c = e.clientY < i.top ? i.top - e.clientY : e.clientY > i.bottom ? e.clientY - i.bottom : 0, l = Math.sqrt(
|
|
1417
|
-
Math.pow(a, 2) + Math.pow(c, 2)
|
|
1418
|
-
);
|
|
1419
|
-
l < r && (r = l, t = s);
|
|
1420
|
-
}), {
|
|
1421
|
-
element: t,
|
|
1422
|
-
distance: r
|
|
1423
|
-
};
|
|
1424
|
-
});
|
|
1425
|
-
/**
|
|
1426
|
-
* This dragover event handler listens at the document level,
|
|
1427
|
-
* and is trying to handle dragover events for all editors.
|
|
1428
|
-
*
|
|
1429
|
-
* It specifically is trying to handle the following cases:
|
|
1430
|
-
* - If the dragover event is within the bounds of any editor, then it does nothing
|
|
1431
|
-
* - If the dragover event is outside the bounds of any editor, but close enough (within DISTANCE_TO_CONSIDER_EDITOR_BOUNDS) to the closest editor,
|
|
1432
|
-
* then it dispatches a synthetic dragover event to the closest editor (which will trigger the drop-cursor to be shown on that editor)
|
|
1433
|
-
* - If the dragover event is outside the bounds of the current editor, then it will dispatch a synthetic dragleave event to the current editor
|
|
1434
|
-
* (which will trigger the drop-cursor to be removed from the current editor)
|
|
1435
|
-
*
|
|
1436
|
-
* The synthetic event is a necessary evil because we do not control prosemirror-dropcursor to be able to show the drop-cursor within the range we want
|
|
1437
|
-
*/
|
|
1438
|
-
k(this, "onDragOver", (e) => {
|
|
1439
|
-
var r;
|
|
1440
|
-
if (e.synthetic || !(this.pmView.dragging !== null || this.isDragOrigin || ((r = e.dataTransfer) == null ? void 0 : r.types.includes("blocknote/html")) || e.target instanceof Node && this.pmView.dom.contains(e.target)))
|
|
1441
|
-
return;
|
|
1442
|
-
const t = this.getDragEventContext(e);
|
|
1443
|
-
if (!t || !t.isDropPoint) {
|
|
1444
|
-
this.closeDropCursor();
|
|
1445
|
-
return;
|
|
1446
|
-
}
|
|
1447
|
-
t.isDropPoint && !t.isDropWithinEditorBounds && this.dispatchSyntheticEvent(e);
|
|
1448
|
-
});
|
|
1449
|
-
/**
|
|
1450
|
-
* Closes the drop-cursor for the current editor
|
|
1451
|
-
*/
|
|
1452
|
-
k(this, "closeDropCursor", () => {
|
|
1453
|
-
const e = new Event("dragleave", { bubbles: !1 });
|
|
1454
|
-
e.synthetic = !0, this.pmView.dom.dispatchEvent(e);
|
|
1455
|
-
});
|
|
1456
|
-
/**
|
|
1457
|
-
* It is surprisingly difficult to determine the information we need to know about a drag event
|
|
1458
|
-
*
|
|
1459
|
-
* This function is trying to determine the following:
|
|
1460
|
-
* - Whether the current editor instance is the drop point
|
|
1461
|
-
* - Whether the current editor instance is the drag origin
|
|
1462
|
-
* - Whether the drop event is within the bounds of the current editor instance
|
|
1463
|
-
*/
|
|
1464
|
-
k(this, "getDragEventContext", (e) => {
|
|
1465
|
-
var l, u;
|
|
1466
|
-
if (!(this.pmView.dragging !== null || this.isDragOrigin || ((l = e.dataTransfer) == null ? void 0 : l.types.includes("blocknote/html")) || e.target instanceof Node && this.pmView.dom.contains(e.target)))
|
|
1467
|
-
return;
|
|
1468
|
-
const t = !((u = e.dataTransfer) != null && u.types.includes("blocknote/html")) && !!this.pmView.dragging, r = !!this.isDragOrigin, s = t || r, i = this.findClosestEditorElement(e);
|
|
1469
|
-
if (!i || i.distance > ue)
|
|
1470
|
-
return;
|
|
1471
|
-
const a = i.element === this.pmView.dom, c = a && i.distance === 0;
|
|
1472
|
-
if (!(!a && !s))
|
|
1473
|
-
return {
|
|
1474
|
-
isDropPoint: a,
|
|
1475
|
-
isDropWithinEditorBounds: c,
|
|
1476
|
-
isDragOrigin: s
|
|
1477
|
-
};
|
|
1478
|
-
});
|
|
1479
|
-
/**
|
|
1480
|
-
* The drop event handler listens at the document level,
|
|
1481
|
-
* and handles drop events for all editors.
|
|
1482
|
-
*
|
|
1483
|
-
* It specifically handles the following cases:
|
|
1484
|
-
* - If we are both the drag origin and drop point:
|
|
1485
|
-
* - Let normal drop handling take over
|
|
1486
|
-
* - If we are the drop point but not the drag origin:
|
|
1487
|
-
* - Collapse selection to prevent PM from deleting unrelated content
|
|
1488
|
-
* - If drop event is outside our editor bounds, dispatch synthetic drop event to our editor
|
|
1489
|
-
* - If we are the drag origin but not the drop point:
|
|
1490
|
-
* - Delete the dragged content from our editor after a delay
|
|
1491
|
-
*/
|
|
1492
|
-
k(this, "onDrop", (e) => {
|
|
1493
|
-
var a;
|
|
1494
|
-
if (e.synthetic || !(this.pmView.dragging !== null || this.isDragOrigin || ((a = e.dataTransfer) == null ? void 0 : a.types.includes("blocknote/html")) || e.target instanceof Node && this.pmView.dom.contains(e.target)))
|
|
1495
|
-
return;
|
|
1496
|
-
const t = this.getDragEventContext(e);
|
|
1497
|
-
if (!t) {
|
|
1498
|
-
this.closeDropCursor();
|
|
1499
|
-
return;
|
|
1500
|
-
}
|
|
1501
|
-
const { isDropPoint: r, isDropWithinEditorBounds: s, isDragOrigin: i } = t;
|
|
1502
|
-
if (!s && r && this.dispatchSyntheticEvent(e), r) {
|
|
1503
|
-
if (this.pmView.dragging)
|
|
1504
|
-
return;
|
|
1505
|
-
this.pmView.dispatch(
|
|
1506
|
-
this.pmView.state.tr.setSelection(
|
|
1507
|
-
ot.create(
|
|
1508
|
-
this.pmView.state.tr.doc,
|
|
1509
|
-
this.pmView.state.tr.selection.anchor
|
|
1510
|
-
)
|
|
1511
|
-
)
|
|
1512
|
-
);
|
|
1513
|
-
return;
|
|
1514
|
-
} else if (i) {
|
|
1515
|
-
setTimeout(
|
|
1516
|
-
() => this.pmView.dispatch(this.pmView.state.tr.deleteSelection()),
|
|
1517
|
-
0
|
|
1518
|
-
);
|
|
1519
|
-
return;
|
|
1520
|
-
}
|
|
1521
|
-
});
|
|
1522
|
-
k(this, "onDragEnd", (e) => {
|
|
1523
|
-
e.synthetic || (this.pmView.dragging = null);
|
|
1524
|
-
});
|
|
1525
|
-
k(this, "onKeyDown", (e) => {
|
|
1526
|
-
var o;
|
|
1527
|
-
(o = this.state) != null && o.show && this.editor.isFocused() && (this.state.show = !1, this.emitUpdate(this.state));
|
|
1528
|
-
});
|
|
1529
|
-
k(this, "onMouseMove", (e) => {
|
|
1530
|
-
var s;
|
|
1531
|
-
if (this.menuFrozen)
|
|
1532
|
-
return;
|
|
1533
|
-
this.mousePos = { x: e.clientX, y: e.clientY };
|
|
1534
|
-
const o = this.pmView.dom.getBoundingClientRect(), t = this.mousePos.x > o.left && this.mousePos.x < o.right && this.mousePos.y > o.top && this.mousePos.y < o.bottom, r = this.pmView.dom.parentElement;
|
|
1535
|
-
if (
|
|
1536
|
-
// Cursor is within the editor area
|
|
1537
|
-
t && // An element is hovered
|
|
1538
|
-
e && e.target && // Element is outside the editor
|
|
1539
|
-
!(r === e.target || r.contains(e.target))
|
|
1540
|
-
) {
|
|
1541
|
-
(s = this.state) != null && s.show && (this.state.show = !1, this.emitUpdate(this.state));
|
|
1542
|
-
return;
|
|
1543
|
-
}
|
|
1544
|
-
this.updateStateFromMousePos();
|
|
1545
|
-
});
|
|
1546
|
-
this.editor = e, this.pmView = o, this.emitUpdate = () => {
|
|
1547
|
-
if (!this.state)
|
|
1548
|
-
throw new Error("Attempting to update uninitialized side menu");
|
|
1549
|
-
t(this.state);
|
|
1550
|
-
}, this.pmView.root.addEventListener(
|
|
1551
|
-
"dragstart",
|
|
1552
|
-
this.onDragStart
|
|
1553
|
-
), this.pmView.root.addEventListener(
|
|
1554
|
-
"dragover",
|
|
1555
|
-
this.onDragOver
|
|
1556
|
-
), this.pmView.root.addEventListener(
|
|
1557
|
-
"drop",
|
|
1558
|
-
this.onDrop,
|
|
1559
|
-
!0
|
|
1560
|
-
), this.pmView.root.addEventListener(
|
|
1561
|
-
"dragend",
|
|
1562
|
-
this.onDragEnd,
|
|
1563
|
-
!0
|
|
1564
|
-
), this.pmView.root.addEventListener(
|
|
1565
|
-
"mousemove",
|
|
1566
|
-
this.onMouseMove,
|
|
1567
|
-
!0
|
|
1568
|
-
), this.pmView.root.addEventListener(
|
|
1569
|
-
"keydown",
|
|
1570
|
-
this.onKeyDown,
|
|
1571
|
-
!0
|
|
1572
|
-
);
|
|
1573
|
-
}
|
|
1574
|
-
dispatchSyntheticEvent(e) {
|
|
1575
|
-
const o = new Event(e.type, e), t = this.pmView.dom.firstChild.getBoundingClientRect();
|
|
1576
|
-
o.clientX = e.clientX, o.clientY = e.clientY, o.clientX = Math.min(
|
|
1577
|
-
Math.max(e.clientX, t.left),
|
|
1578
|
-
t.left + t.width
|
|
1579
|
-
), o.clientY = Math.min(
|
|
1580
|
-
Math.max(e.clientY, t.top),
|
|
1581
|
-
t.top + t.height
|
|
1582
|
-
), o.dataTransfer = e.dataTransfer, o.preventDefault = () => e.preventDefault(), o.synthetic = !0, this.pmView.dom.dispatchEvent(o);
|
|
1583
|
-
}
|
|
1584
|
-
// Needed in cases where the editor state updates without the mouse cursor
|
|
1585
|
-
// moving, as some state updates can require a side menu update. For example,
|
|
1586
|
-
// adding a button to the side menu which removes the block can cause the
|
|
1587
|
-
// block below to jump up into the place of the removed block when clicked,
|
|
1588
|
-
// allowing the user to click the button again without moving the cursor. This
|
|
1589
|
-
// would otherwise not update the side menu, and so clicking the button again
|
|
1590
|
-
// would attempt to remove the same block again, causing an error.
|
|
1591
|
-
update(e, o) {
|
|
1592
|
-
var r;
|
|
1593
|
-
!o.doc.eq(this.pmView.state.doc) && ((r = this.state) != null && r.show) && this.updateStateFromMousePos();
|
|
1594
|
-
}
|
|
1595
|
-
destroy() {
|
|
1596
|
-
var e;
|
|
1597
|
-
(e = this.state) != null && e.show && (this.state.show = !1, this.emitUpdate(this.state)), this.pmView.root.removeEventListener(
|
|
1598
|
-
"mousemove",
|
|
1599
|
-
this.onMouseMove,
|
|
1600
|
-
!0
|
|
1601
|
-
), this.pmView.root.removeEventListener(
|
|
1602
|
-
"dragstart",
|
|
1603
|
-
this.onDragStart
|
|
1604
|
-
), this.pmView.root.removeEventListener(
|
|
1605
|
-
"dragover",
|
|
1606
|
-
this.onDragOver
|
|
1607
|
-
), this.pmView.root.removeEventListener(
|
|
1608
|
-
"drop",
|
|
1609
|
-
this.onDrop,
|
|
1610
|
-
!0
|
|
1611
|
-
), this.pmView.root.removeEventListener(
|
|
1612
|
-
"dragend",
|
|
1613
|
-
this.onDragEnd,
|
|
1614
|
-
!0
|
|
1615
|
-
), this.pmView.root.removeEventListener(
|
|
1616
|
-
"keydown",
|
|
1617
|
-
this.onKeyDown,
|
|
1618
|
-
!0
|
|
1619
|
-
);
|
|
1620
|
-
}
|
|
1621
|
-
}
|
|
1622
|
-
const Zt = new ke("SideMenuPlugin"), _o = E(({ editor: n }) => {
|
|
1623
|
-
let e;
|
|
1624
|
-
const o = j(
|
|
1625
|
-
void 0
|
|
1626
|
-
);
|
|
1627
|
-
return {
|
|
1628
|
-
key: "sideMenu",
|
|
1629
|
-
store: o,
|
|
1630
|
-
prosemirrorPlugins: [
|
|
1631
|
-
new ve({
|
|
1632
|
-
key: Zt,
|
|
1633
|
-
view: (t) => (e = new Qt(n, t, (r) => {
|
|
1634
|
-
o.setState({ ...r });
|
|
1635
|
-
}), e)
|
|
1636
|
-
})
|
|
1637
|
-
],
|
|
1638
|
-
/**
|
|
1639
|
-
* Handles drag & drop events for blocks.
|
|
1640
|
-
*/
|
|
1641
|
-
blockDragStart(t, r) {
|
|
1642
|
-
e && (e.isDragOrigin = !0), Gt(t, r, n);
|
|
1643
|
-
},
|
|
1644
|
-
/**
|
|
1645
|
-
* Handles drag & drop events for blocks.
|
|
1646
|
-
*/
|
|
1647
|
-
blockDragEnd() {
|
|
1648
|
-
Pe(n.prosemirrorView.root), e && (e.isDragOrigin = !1), n.blur();
|
|
1649
|
-
},
|
|
1650
|
-
/**
|
|
1651
|
-
* Freezes the side menu. When frozen, the side menu will stay
|
|
1652
|
-
* attached to the same block regardless of which block is hovered by the
|
|
1653
|
-
* mouse cursor.
|
|
1654
|
-
*/
|
|
1655
|
-
freezeMenu() {
|
|
1656
|
-
e.menuFrozen = !0, e.state.show = !0, e.emitUpdate(e.state);
|
|
1657
|
-
},
|
|
1658
|
-
/**
|
|
1659
|
-
* Unfreezes the side menu. When frozen, the side menu will stay
|
|
1660
|
-
* attached to the same block regardless of which block is hovered by the
|
|
1661
|
-
* mouse cursor.
|
|
1662
|
-
*/
|
|
1663
|
-
unfreezeMenu() {
|
|
1664
|
-
e.menuFrozen = !1, e.state.show = !1, e.emitUpdate(e.state);
|
|
1665
|
-
}
|
|
1666
|
-
};
|
|
1667
|
-
});
|
|
1668
|
-
let $;
|
|
1669
|
-
async function eo() {
|
|
1670
|
-
return $ || ($ = (async () => {
|
|
1671
|
-
const [n, e] = await Promise.all([
|
|
1672
|
-
import("emoji-mart"),
|
|
1673
|
-
// use a dynamic import to encourage bundle-splitting
|
|
1674
|
-
// and a smaller initial client bundle size
|
|
1675
|
-
import("@emoji-mart/data")
|
|
1676
|
-
]), o = "default" in n ? n.default : n, t = "default" in e ? e.default : e;
|
|
1677
|
-
return await o.init({ data: t }), { emojiMart: o, emojiData: t };
|
|
1678
|
-
})(), $);
|
|
1679
|
-
}
|
|
1680
|
-
async function zo(n, e) {
|
|
1681
|
-
if (!("text" in n.schema.inlineContentSchema) || n.schema.inlineContentSchema.text !== We.text)
|
|
1682
|
-
return [];
|
|
1683
|
-
const { emojiData: o, emojiMart: t } = await eo();
|
|
1684
|
-
return (e.trim() === "" ? Object.values(o.emojis) : await t.SearchIndex.search(e)).map((s) => ({
|
|
1685
|
-
id: s.skins[0].native,
|
|
1686
|
-
onItemClick: () => n.insertInlineContent(s.skins[0].native + " ")
|
|
1687
|
-
}));
|
|
1688
|
-
}
|
|
1689
|
-
let B;
|
|
1690
|
-
function he(n) {
|
|
1691
|
-
B || (B = document.createElement("div"), B.innerHTML = "_", B.style.opacity = "0", B.style.height = "1px", B.style.width = "1px", n instanceof Document ? n.body.appendChild(B) : n.appendChild(B));
|
|
1692
|
-
}
|
|
1693
|
-
function to(n) {
|
|
1694
|
-
B && (n instanceof Document ? n.body.removeChild(B) : n.removeChild(B), B = void 0);
|
|
1695
|
-
}
|
|
1696
|
-
function F(n) {
|
|
1697
|
-
return Array.prototype.indexOf.call(n.parentElement.childNodes, n);
|
|
1698
|
-
}
|
|
1699
|
-
function oo(n) {
|
|
1700
|
-
let e = n;
|
|
1701
|
-
for (; e && e.nodeName !== "TD" && e.nodeName !== "TH" && !e.classList.contains("tableWrapper"); ) {
|
|
1702
|
-
if (e.classList.contains("ProseMirror"))
|
|
1703
|
-
return;
|
|
1704
|
-
const o = e.parentNode;
|
|
1705
|
-
if (!o || !(o instanceof Element))
|
|
1706
|
-
return;
|
|
1707
|
-
e = o;
|
|
1708
|
-
}
|
|
1709
|
-
return e.nodeName === "TD" || e.nodeName === "TH" ? {
|
|
1710
|
-
type: "cell",
|
|
1711
|
-
domNode: e,
|
|
1712
|
-
tbodyNode: e.closest("tbody")
|
|
1713
|
-
} : {
|
|
1714
|
-
type: "wrapper",
|
|
1715
|
-
domNode: e,
|
|
1716
|
-
tbodyNode: e.querySelector("tbody")
|
|
1717
|
-
};
|
|
1718
|
-
}
|
|
1719
|
-
function no(n, e) {
|
|
1720
|
-
const o = e.querySelectorAll(n);
|
|
1721
|
-
for (let t = 0; t < o.length; t++)
|
|
1722
|
-
o[t].style.visibility = "hidden";
|
|
1723
|
-
}
|
|
1724
|
-
class ro {
|
|
1725
|
-
constructor(e, o, t) {
|
|
1726
|
-
k(this, "state");
|
|
1727
|
-
k(this, "emitUpdate");
|
|
1728
|
-
k(this, "tableId");
|
|
1729
|
-
k(this, "tablePos");
|
|
1730
|
-
k(this, "tableElement");
|
|
1731
|
-
k(this, "menuFrozen", !1);
|
|
1732
|
-
k(this, "mouseState", "up");
|
|
1733
|
-
k(this, "prevWasEditable", null);
|
|
1734
|
-
k(this, "viewMousedownHandler", () => {
|
|
1735
|
-
this.mouseState = "down";
|
|
1736
|
-
});
|
|
1737
|
-
k(this, "mouseUpHandler", (e) => {
|
|
1738
|
-
this.mouseState = "up", this.mouseMoveHandler(e);
|
|
1739
|
-
});
|
|
1740
|
-
k(this, "mouseMoveHandler", (e) => {
|
|
1741
|
-
var l, u, h, f, m, p, d, g;
|
|
1742
|
-
if (this.menuFrozen || this.mouseState === "selecting" || !(e.target instanceof Element) || !this.pmView.dom.contains(e.target))
|
|
1743
|
-
return;
|
|
1744
|
-
const o = oo(e.target);
|
|
1745
|
-
if ((o == null ? void 0 : o.type) === "cell" && this.mouseState === "down" && !((l = this.state) != null && l.draggingState)) {
|
|
1746
|
-
this.mouseState = "selecting", (u = this.state) != null && u.show && (this.state.show = !1, this.state.showAddOrRemoveRowsButton = !1, this.state.showAddOrRemoveColumnsButton = !1, this.emitUpdate());
|
|
1747
|
-
return;
|
|
1748
|
-
}
|
|
1749
|
-
if (!o || !this.editor.isEditable) {
|
|
1750
|
-
(h = this.state) != null && h.show && (this.state.show = !1, this.state.showAddOrRemoveRowsButton = !1, this.state.showAddOrRemoveColumnsButton = !1, this.emitUpdate());
|
|
1751
|
-
return;
|
|
1752
|
-
}
|
|
1753
|
-
if (!o.tbodyNode)
|
|
1754
|
-
return;
|
|
1755
|
-
const t = o.tbodyNode.getBoundingClientRect(), r = De(o.domNode, this.pmView);
|
|
1756
|
-
if (!r)
|
|
1757
|
-
return;
|
|
1758
|
-
this.tableElement = r.node;
|
|
1759
|
-
let s;
|
|
1760
|
-
const i = this.editor.transact(
|
|
1761
|
-
(b) => ye(r.id, b.doc)
|
|
1762
|
-
);
|
|
1763
|
-
if (!i)
|
|
1764
|
-
throw new Error(`Block with ID ${r.id} not found`);
|
|
1765
|
-
const a = z(
|
|
1766
|
-
i.node,
|
|
1767
|
-
this.editor.pmSchema,
|
|
1768
|
-
this.editor.schema.blockSchema,
|
|
1769
|
-
this.editor.schema.inlineContentSchema,
|
|
1770
|
-
this.editor.schema.styleSchema
|
|
1771
|
-
);
|
|
1772
|
-
if (qe(this.editor, "table") && (this.tablePos = i.posBeforeNode + 1, s = a), !s)
|
|
1773
|
-
return;
|
|
1774
|
-
this.tableId = r.id;
|
|
1775
|
-
const c = (f = o.domNode.closest(".tableWrapper")) == null ? void 0 : f.querySelector(".table-widgets-container");
|
|
1776
|
-
if ((o == null ? void 0 : o.type) === "wrapper") {
|
|
1777
|
-
const b = e.clientY >= t.bottom - 1 && // -1 to account for fractions of pixels in "bottom"
|
|
1778
|
-
e.clientY < t.bottom + 20, y = e.clientX >= t.right - 1 && e.clientX < t.right + 20, w = (
|
|
1779
|
-
// always hide handles when the actively hovered table changed
|
|
1780
|
-
((m = this.state) == null ? void 0 : m.block.id) !== s.id || // make sure we don't hide existing handles (keep col / row index) when
|
|
1781
|
-
// we're hovering just above or to the right of a table
|
|
1782
|
-
e.clientX > t.right || e.clientY > t.bottom
|
|
1783
|
-
);
|
|
1784
|
-
this.state = {
|
|
1785
|
-
...this.state,
|
|
1786
|
-
show: !0,
|
|
1787
|
-
showAddOrRemoveRowsButton: b,
|
|
1788
|
-
showAddOrRemoveColumnsButton: y,
|
|
1789
|
-
referencePosTable: t,
|
|
1790
|
-
block: s,
|
|
1791
|
-
widgetContainer: c,
|
|
1792
|
-
colIndex: w || (p = this.state) == null ? void 0 : p.colIndex,
|
|
1793
|
-
rowIndex: w || (d = this.state) == null ? void 0 : d.rowIndex,
|
|
1794
|
-
referencePosCell: w || (g = this.state) == null ? void 0 : g.referencePosCell
|
|
1795
|
-
};
|
|
1796
|
-
} else {
|
|
1797
|
-
const b = F(o.domNode), y = F(o.domNode.parentElement), w = o.domNode.getBoundingClientRect();
|
|
1798
|
-
if (this.state !== void 0 && this.state.show && this.tableId === r.id && this.state.rowIndex === y && this.state.colIndex === b)
|
|
1799
|
-
return;
|
|
1800
|
-
this.state = {
|
|
1801
|
-
show: !0,
|
|
1802
|
-
showAddOrRemoveColumnsButton: b === s.content.rows[0].cells.length - 1,
|
|
1803
|
-
showAddOrRemoveRowsButton: y === s.content.rows.length - 1,
|
|
1804
|
-
referencePosTable: t,
|
|
1805
|
-
block: s,
|
|
1806
|
-
draggingState: void 0,
|
|
1807
|
-
referencePosCell: w,
|
|
1808
|
-
colIndex: b,
|
|
1809
|
-
rowIndex: y,
|
|
1810
|
-
widgetContainer: c
|
|
1811
|
-
};
|
|
1812
|
-
}
|
|
1813
|
-
return this.emitUpdate(), !1;
|
|
1814
|
-
});
|
|
1815
|
-
k(this, "dragOverHandler", (e) => {
|
|
1816
|
-
var f;
|
|
1817
|
-
if (((f = this.state) == null ? void 0 : f.draggingState) === void 0)
|
|
1818
|
-
return;
|
|
1819
|
-
e.preventDefault(), e.dataTransfer.dropEffect = "move", no(
|
|
1820
|
-
".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline",
|
|
1821
|
-
this.pmView.root
|
|
1822
|
-
);
|
|
1823
|
-
const o = {
|
|
1824
|
-
left: Math.min(
|
|
1825
|
-
Math.max(e.clientX, this.state.referencePosTable.left + 1),
|
|
1826
|
-
this.state.referencePosTable.right - 1
|
|
1827
|
-
),
|
|
1828
|
-
top: Math.min(
|
|
1829
|
-
Math.max(e.clientY, this.state.referencePosTable.top + 1),
|
|
1830
|
-
this.state.referencePosTable.bottom - 1
|
|
1831
|
-
)
|
|
1832
|
-
}, t = this.pmView.root.elementsFromPoint(o.left, o.top).filter(
|
|
1833
|
-
(m) => m.tagName === "TD" || m.tagName === "TH"
|
|
1834
|
-
);
|
|
1835
|
-
if (t.length === 0)
|
|
1836
|
-
return;
|
|
1837
|
-
const r = t[0];
|
|
1838
|
-
let s = !1;
|
|
1839
|
-
const i = F(r.parentElement), a = F(r), c = this.state.draggingState.draggedCellOrientation === "row" ? this.state.rowIndex : this.state.colIndex, u = (this.state.draggingState.draggedCellOrientation === "row" ? i : a) !== c;
|
|
1840
|
-
(this.state.rowIndex !== i || this.state.colIndex !== a) && (this.state.rowIndex = i, this.state.colIndex = a, this.state.referencePosCell = r.getBoundingClientRect(), s = !0);
|
|
1841
|
-
const h = this.state.draggingState.draggedCellOrientation === "row" ? o.top : o.left;
|
|
1842
|
-
this.state.draggingState.mousePos !== h && (this.state.draggingState.mousePos = h, s = !0), s && this.emitUpdate(), u && this.editor.transact((m) => m.setMeta(V, !0));
|
|
1843
|
-
});
|
|
1844
|
-
k(this, "dropHandler", (e) => {
|
|
1845
|
-
if (this.mouseState = "up", this.state === void 0 || this.state.draggingState === void 0)
|
|
1846
|
-
return !1;
|
|
1847
|
-
if (this.state.rowIndex === void 0 || this.state.colIndex === void 0)
|
|
1848
|
-
throw new Error(
|
|
1849
|
-
"Attempted to drop table row or column, but no table block was hovered prior."
|
|
1850
|
-
);
|
|
1851
|
-
e.preventDefault();
|
|
1852
|
-
const { draggingState: o, colIndex: t, rowIndex: r } = this.state, s = this.state.block.content.columnWidths;
|
|
1853
|
-
if (o.draggedCellOrientation === "row") {
|
|
1854
|
-
if (!ge(
|
|
1855
|
-
this.state.block,
|
|
1856
|
-
o.originalIndex,
|
|
1857
|
-
r
|
|
1858
|
-
))
|
|
1859
|
-
return !1;
|
|
1860
|
-
const i = _e(
|
|
1861
|
-
this.state.block,
|
|
1862
|
-
o.originalIndex,
|
|
1863
|
-
r
|
|
1864
|
-
);
|
|
1865
|
-
this.editor.updateBlock(this.state.block, {
|
|
1866
|
-
type: "table",
|
|
1867
|
-
content: {
|
|
1868
|
-
...this.state.block.content,
|
|
1869
|
-
rows: i
|
|
1870
|
-
}
|
|
1871
|
-
});
|
|
1872
|
-
} else {
|
|
1873
|
-
if (!we(
|
|
1874
|
-
this.state.block,
|
|
1875
|
-
o.originalIndex,
|
|
1876
|
-
t
|
|
1877
|
-
))
|
|
1878
|
-
return !1;
|
|
1879
|
-
const i = ze(
|
|
1880
|
-
this.state.block,
|
|
1881
|
-
o.originalIndex,
|
|
1882
|
-
t
|
|
1883
|
-
), [a] = s.splice(o.originalIndex, 1);
|
|
1884
|
-
s.splice(t, 0, a), this.editor.updateBlock(this.state.block, {
|
|
1885
|
-
type: "table",
|
|
1886
|
-
content: {
|
|
1887
|
-
...this.state.block.content,
|
|
1888
|
-
columnWidths: s,
|
|
1889
|
-
rows: i
|
|
1890
|
-
}
|
|
1891
|
-
});
|
|
1892
|
-
}
|
|
1893
|
-
return this.editor.setTextCursorPosition(this.state.block.id), !0;
|
|
1894
|
-
});
|
|
1895
|
-
this.editor = e, this.pmView = o, this.emitUpdate = () => {
|
|
1896
|
-
if (!this.state)
|
|
1897
|
-
throw new Error("Attempting to update uninitialized image toolbar");
|
|
1898
|
-
t(this.state);
|
|
1899
|
-
}, o.dom.addEventListener("mousemove", this.mouseMoveHandler), o.dom.addEventListener("mousedown", this.viewMousedownHandler), window.addEventListener("mouseup", this.mouseUpHandler), o.root.addEventListener(
|
|
1900
|
-
"dragover",
|
|
1901
|
-
this.dragOverHandler
|
|
1902
|
-
), o.root.addEventListener(
|
|
1903
|
-
"drop",
|
|
1904
|
-
this.dropHandler
|
|
1905
|
-
);
|
|
1906
|
-
}
|
|
1907
|
-
// Updates drag handles when the table is modified or removed.
|
|
1908
|
-
update() {
|
|
1909
|
-
var r;
|
|
1910
|
-
if (!this.state || !this.state.show)
|
|
1911
|
-
return;
|
|
1912
|
-
if (this.state.block = this.editor.getBlock(this.state.block.id), !this.state.block || this.state.block.type !== "table" || // when collaborating, the table element might be replaced and out of date
|
|
1913
|
-
// because yjs replaces the element when for example you change the color via the side menu
|
|
1914
|
-
!((r = this.tableElement) != null && r.isConnected)) {
|
|
1915
|
-
this.state.show = !1, this.state.showAddOrRemoveRowsButton = !1, this.state.showAddOrRemoveColumnsButton = !1, this.emitUpdate();
|
|
1916
|
-
return;
|
|
1917
|
-
}
|
|
1918
|
-
const { height: e, width: o } = Ye(
|
|
1919
|
-
this.state.block
|
|
1920
|
-
);
|
|
1921
|
-
this.state.rowIndex !== void 0 && this.state.colIndex !== void 0 && (this.state.rowIndex >= e && (this.state.rowIndex = e - 1), this.state.colIndex >= o && (this.state.colIndex = o - 1));
|
|
1922
|
-
const t = this.tableElement.querySelector("tbody");
|
|
1923
|
-
if (!t)
|
|
1924
|
-
throw new Error(
|
|
1925
|
-
"Table block does not contain a 'tbody' HTML element. This should never happen."
|
|
1926
|
-
);
|
|
1927
|
-
if (this.state.rowIndex !== void 0 && this.state.colIndex !== void 0) {
|
|
1928
|
-
const i = t.children[this.state.rowIndex].children[this.state.colIndex];
|
|
1929
|
-
i ? this.state.referencePosCell = i.getBoundingClientRect() : (this.state.rowIndex = void 0, this.state.colIndex = void 0);
|
|
1930
|
-
}
|
|
1931
|
-
this.state.referencePosTable = t.getBoundingClientRect(), this.emitUpdate();
|
|
1932
|
-
}
|
|
1933
|
-
destroy() {
|
|
1934
|
-
this.pmView.dom.removeEventListener("mousemove", this.mouseMoveHandler), window.removeEventListener("mouseup", this.mouseUpHandler), this.pmView.dom.removeEventListener("mousedown", this.viewMousedownHandler), this.pmView.root.removeEventListener(
|
|
1935
|
-
"dragover",
|
|
1936
|
-
this.dragOverHandler
|
|
1937
|
-
), this.pmView.root.removeEventListener(
|
|
1938
|
-
"drop",
|
|
1939
|
-
this.dropHandler
|
|
1940
|
-
);
|
|
1941
|
-
}
|
|
1942
|
-
}
|
|
1943
|
-
const V = new N("TableHandlesPlugin"), Yo = E(({ editor: n }) => {
|
|
1944
|
-
let e;
|
|
1945
|
-
const o = j(void 0);
|
|
1946
|
-
return {
|
|
1947
|
-
key: "tableHandles",
|
|
1948
|
-
store: o,
|
|
1949
|
-
prosemirrorPlugins: [
|
|
1950
|
-
new L({
|
|
1951
|
-
key: V,
|
|
1952
|
-
view: (t) => (e = new ro(n, t, (r) => {
|
|
1953
|
-
o.setState(
|
|
1954
|
-
r.block ? {
|
|
1955
|
-
...r,
|
|
1956
|
-
draggingState: r.draggingState ? { ...r.draggingState } : void 0
|
|
1957
|
-
} : void 0
|
|
1958
|
-
);
|
|
1959
|
-
}), e),
|
|
1960
|
-
// We use decorations to render the drop cursor when dragging a table row
|
|
1961
|
-
// or column. The decorations are updated in the `dragOverHandler` method.
|
|
1962
|
-
props: {
|
|
1963
|
-
decorations: (t) => {
|
|
1964
|
-
if (e === void 0 || e.state === void 0 || e.state.draggingState === void 0 || e.tablePos === void 0)
|
|
1965
|
-
return;
|
|
1966
|
-
const r = e.state.draggingState.draggedCellOrientation === "row" ? e.state.rowIndex : e.state.colIndex;
|
|
1967
|
-
if (r === void 0)
|
|
1968
|
-
return;
|
|
1969
|
-
const s = [], { block: i, draggingState: a } = e.state, { originalIndex: c, draggedCellOrientation: l } = a;
|
|
1970
|
-
if (r === c || !i || l === "row" && !ge(i, c, r) || l === "col" && !we(i, c, r))
|
|
1971
|
-
return Y.create(t.doc, s);
|
|
1972
|
-
const u = t.doc.resolve(e.tablePos + 1);
|
|
1973
|
-
return e.state.draggingState.draggedCellOrientation === "row" ? te(
|
|
1974
|
-
e.state.block,
|
|
1975
|
-
r
|
|
1976
|
-
).forEach(({ row: f, col: m }) => {
|
|
1977
|
-
const p = t.doc.resolve(
|
|
1978
|
-
u.posAtIndex(f) + 1
|
|
1979
|
-
), d = t.doc.resolve(
|
|
1980
|
-
p.posAtIndex(m) + 1
|
|
1981
|
-
), g = d.node(), b = d.pos + (r > c ? g.nodeSize - 2 : 0);
|
|
1982
|
-
s.push(
|
|
1983
|
-
// The widget is a small bar which spans the width of the cell.
|
|
1984
|
-
H.widget(b, () => {
|
|
1985
|
-
const y = document.createElement("div");
|
|
1986
|
-
return y.className = "bn-table-drop-cursor", y.style.left = "0", y.style.right = "0", r > c ? y.style.bottom = "-2px" : y.style.top = "-3px", y.style.height = "4px", y;
|
|
1987
|
-
})
|
|
1988
|
-
);
|
|
1989
|
-
}) : ee(
|
|
1990
|
-
e.state.block,
|
|
1991
|
-
r
|
|
1992
|
-
).forEach(({ row: f, col: m }) => {
|
|
1993
|
-
const p = t.doc.resolve(
|
|
1994
|
-
u.posAtIndex(f) + 1
|
|
1995
|
-
), d = t.doc.resolve(
|
|
1996
|
-
p.posAtIndex(m) + 1
|
|
1997
|
-
), g = d.node(), b = d.pos + (r > c ? g.nodeSize - 2 : 0);
|
|
1998
|
-
s.push(
|
|
1999
|
-
// The widget is a small bar which spans the height of the cell.
|
|
2000
|
-
H.widget(b, () => {
|
|
2001
|
-
const y = document.createElement("div");
|
|
2002
|
-
return y.className = "bn-table-drop-cursor", y.style.top = "0", y.style.bottom = "0", r > c ? y.style.right = "-2px" : y.style.left = "-3px", y.style.width = "4px", y;
|
|
2003
|
-
})
|
|
2004
|
-
);
|
|
2005
|
-
}), Y.create(t.doc, s);
|
|
2006
|
-
}
|
|
2007
|
-
}
|
|
2008
|
-
})
|
|
2009
|
-
],
|
|
2010
|
-
/**
|
|
2011
|
-
* Callback that should be set on the `dragStart` event for whichever element
|
|
2012
|
-
* is used as the column drag handle.
|
|
2013
|
-
*/
|
|
2014
|
-
colDragStart(t) {
|
|
2015
|
-
if (e === void 0 || e.state === void 0 || e.state.colIndex === void 0)
|
|
2016
|
-
throw new Error(
|
|
2017
|
-
"Attempted to drag table column, but no table block was hovered prior."
|
|
2018
|
-
);
|
|
2019
|
-
e.state.draggingState = {
|
|
2020
|
-
draggedCellOrientation: "col",
|
|
2021
|
-
originalIndex: e.state.colIndex,
|
|
2022
|
-
mousePos: t.clientX
|
|
2023
|
-
}, e.emitUpdate(), n.transact(
|
|
2024
|
-
(r) => r.setMeta(V, {
|
|
2025
|
-
draggedCellOrientation: e.state.draggingState.draggedCellOrientation,
|
|
2026
|
-
originalIndex: e.state.colIndex,
|
|
2027
|
-
newIndex: e.state.colIndex,
|
|
2028
|
-
tablePos: e.tablePos
|
|
2029
|
-
})
|
|
2030
|
-
), !n.headless && (he(n.prosemirrorView.root), t.dataTransfer.setDragImage(B, 0, 0), t.dataTransfer.effectAllowed = "move");
|
|
2031
|
-
},
|
|
2032
|
-
/**
|
|
2033
|
-
* Callback that should be set on the `dragStart` event for whichever element
|
|
2034
|
-
* is used as the row drag handle.
|
|
2035
|
-
*/
|
|
2036
|
-
rowDragStart(t) {
|
|
2037
|
-
if (e.state === void 0 || e.state.rowIndex === void 0)
|
|
2038
|
-
throw new Error(
|
|
2039
|
-
"Attempted to drag table row, but no table block was hovered prior."
|
|
2040
|
-
);
|
|
2041
|
-
e.state.draggingState = {
|
|
2042
|
-
draggedCellOrientation: "row",
|
|
2043
|
-
originalIndex: e.state.rowIndex,
|
|
2044
|
-
mousePos: t.clientY
|
|
2045
|
-
}, e.emitUpdate(), n.transact(
|
|
2046
|
-
(r) => r.setMeta(V, {
|
|
2047
|
-
draggedCellOrientation: e.state.draggingState.draggedCellOrientation,
|
|
2048
|
-
originalIndex: e.state.rowIndex,
|
|
2049
|
-
newIndex: e.state.rowIndex,
|
|
2050
|
-
tablePos: e.tablePos
|
|
2051
|
-
})
|
|
2052
|
-
), !n.headless && (he(n.prosemirrorView.root), t.dataTransfer.setDragImage(B, 0, 0), t.dataTransfer.effectAllowed = "copyMove");
|
|
2053
|
-
},
|
|
2054
|
-
/**
|
|
2055
|
-
* Callback that should be set on the `dragEnd` event for both the element
|
|
2056
|
-
* used as the row drag handle, and the one used as the column drag handle.
|
|
2057
|
-
*/
|
|
2058
|
-
dragEnd() {
|
|
2059
|
-
if (e.state === void 0)
|
|
2060
|
-
throw new Error(
|
|
2061
|
-
"Attempted to drag table row, but no table block was hovered prior."
|
|
2062
|
-
);
|
|
2063
|
-
e.state.draggingState = void 0, e.emitUpdate(), n.transact((t) => t.setMeta(V, null)), !n.headless && to(n.prosemirrorView.root);
|
|
2064
|
-
},
|
|
2065
|
-
/**
|
|
2066
|
-
* Freezes the drag handles. When frozen, they will stay attached to the same
|
|
2067
|
-
* cell regardless of which cell is hovered by the mouse cursor.
|
|
2068
|
-
*/
|
|
2069
|
-
freezeHandles() {
|
|
2070
|
-
e.menuFrozen = !0;
|
|
2071
|
-
},
|
|
2072
|
-
/**
|
|
2073
|
-
* Unfreezes the drag handles. When frozen, they will stay attached to the
|
|
2074
|
-
* same cell regardless of which cell is hovered by the mouse cursor.
|
|
2075
|
-
*/
|
|
2076
|
-
unfreezeHandles() {
|
|
2077
|
-
e.menuFrozen = !1;
|
|
2078
|
-
},
|
|
2079
|
-
getCellsAtRowHandle(t, r) {
|
|
2080
|
-
return te(t, r);
|
|
2081
|
-
},
|
|
2082
|
-
/**
|
|
2083
|
-
* Get all the cells in a column of the table block.
|
|
2084
|
-
*/
|
|
2085
|
-
getCellsAtColumnHandle(t, r) {
|
|
2086
|
-
return ee(t, r);
|
|
2087
|
-
},
|
|
2088
|
-
/**
|
|
2089
|
-
* Sets the selection to the given cell or a range of cells.
|
|
2090
|
-
* @returns The new state after the selection has been set.
|
|
2091
|
-
*/
|
|
2092
|
-
setCellSelection(t, r, s = r) {
|
|
2093
|
-
if (!e)
|
|
2094
|
-
throw new Error("Table handles view not initialized");
|
|
2095
|
-
const i = t.doc.resolve(e.tablePos + 1), a = t.doc.resolve(
|
|
2096
|
-
i.posAtIndex(r.row) + 1
|
|
2097
|
-
), c = t.doc.resolve(
|
|
2098
|
-
// No need for +1, since CellSelection expects the position before the cell
|
|
2099
|
-
a.posAtIndex(r.col)
|
|
2100
|
-
), l = t.doc.resolve(
|
|
2101
|
-
i.posAtIndex(s.row) + 1
|
|
2102
|
-
), u = t.doc.resolve(
|
|
2103
|
-
// No need for +1, since CellSelection expects the position before the cell
|
|
2104
|
-
l.posAtIndex(s.col)
|
|
2105
|
-
), h = t.tr;
|
|
2106
|
-
return h.setSelection(
|
|
2107
|
-
new It(c, u)
|
|
2108
|
-
), t.apply(h);
|
|
2109
|
-
},
|
|
2110
|
-
/**
|
|
2111
|
-
* Adds a row or column to the table using prosemirror-table commands
|
|
2112
|
-
*/
|
|
2113
|
-
addRowOrColumn(t, r) {
|
|
2114
|
-
n.exec((s, i) => {
|
|
2115
|
-
const a = this.setCellSelection(
|
|
2116
|
-
s,
|
|
2117
|
-
r.orientation === "row" ? { row: t, col: 0 } : { row: 0, col: t }
|
|
2118
|
-
);
|
|
2119
|
-
return r.orientation === "row" ? r.side === "above" ? Ct(a, i) : St(a, i) : r.side === "left" ? xt(a, i) : Et(a, i);
|
|
2120
|
-
});
|
|
2121
|
-
},
|
|
2122
|
-
/**
|
|
2123
|
-
* Removes a row or column from the table using prosemirror-table commands
|
|
2124
|
-
*/
|
|
2125
|
-
removeRowOrColumn(t, r) {
|
|
2126
|
-
return r === "row" ? n.exec((s, i) => {
|
|
2127
|
-
const a = this.setCellSelection(s, {
|
|
2128
|
-
row: t,
|
|
2129
|
-
col: 0
|
|
2130
|
-
});
|
|
2131
|
-
return kt(a, i);
|
|
2132
|
-
}) : n.exec((s, i) => {
|
|
2133
|
-
const a = this.setCellSelection(s, {
|
|
2134
|
-
row: 0,
|
|
2135
|
-
col: t
|
|
2136
|
-
});
|
|
2137
|
-
return vt(a, i);
|
|
2138
|
-
});
|
|
2139
|
-
},
|
|
2140
|
-
/**
|
|
2141
|
-
* Merges the cells in the table block.
|
|
2142
|
-
*/
|
|
2143
|
-
mergeCells(t) {
|
|
2144
|
-
return n.exec((r, s) => {
|
|
2145
|
-
const i = t ? this.setCellSelection(
|
|
2146
|
-
r,
|
|
2147
|
-
t.relativeStartCell,
|
|
2148
|
-
t.relativeEndCell
|
|
2149
|
-
) : r;
|
|
2150
|
-
return yt(i, s);
|
|
2151
|
-
});
|
|
2152
|
-
},
|
|
2153
|
-
/**
|
|
2154
|
-
* Splits the cell in the table block.
|
|
2155
|
-
* If no cell is provided, the current cell selected will be split.
|
|
2156
|
-
*/
|
|
2157
|
-
splitCell(t) {
|
|
2158
|
-
return n.exec((r, s) => {
|
|
2159
|
-
const i = t ? this.setCellSelection(r, t) : r;
|
|
2160
|
-
return bt(i, s);
|
|
2161
|
-
});
|
|
2162
|
-
},
|
|
2163
|
-
/**
|
|
2164
|
-
* Gets the start and end cells of the current cell selection.
|
|
2165
|
-
* @returns The start and end cells of the current cell selection.
|
|
2166
|
-
*/
|
|
2167
|
-
getCellSelection() {
|
|
2168
|
-
return n.transact((t) => {
|
|
2169
|
-
const r = t.selection;
|
|
2170
|
-
let s = r.$from, i = r.$to;
|
|
2171
|
-
if (ne(r)) {
|
|
2172
|
-
const { ranges: d } = r;
|
|
2173
|
-
d.forEach((g) => {
|
|
2174
|
-
s = g.$from.min(s ?? g.$from), i = g.$to.max(i ?? g.$to);
|
|
2175
|
-
});
|
|
2176
|
-
} else if (s = t.doc.resolve(
|
|
2177
|
-
r.$from.pos - r.$from.parentOffset - 1
|
|
2178
|
-
), i = t.doc.resolve(
|
|
2179
|
-
r.$to.pos - r.$to.parentOffset - 1
|
|
2180
|
-
), s.pos === 0 || i.pos === 0)
|
|
2181
|
-
return;
|
|
2182
|
-
const a = t.doc.resolve(
|
|
2183
|
-
s.pos - s.parentOffset - 1
|
|
2184
|
-
), c = t.doc.resolve(i.pos - i.parentOffset - 1), l = t.doc.resolve(a.pos - a.parentOffset - 1), u = s.index(a.depth), h = a.index(l.depth), f = i.index(c.depth), m = c.index(l.depth), p = [];
|
|
2185
|
-
for (let d = h; d <= m; d++)
|
|
2186
|
-
for (let g = u; g <= f; g++)
|
|
2187
|
-
p.push({ row: d, col: g });
|
|
2188
|
-
return {
|
|
2189
|
-
from: {
|
|
2190
|
-
row: h,
|
|
2191
|
-
col: u
|
|
2192
|
-
},
|
|
2193
|
-
to: {
|
|
2194
|
-
row: m,
|
|
2195
|
-
col: f
|
|
2196
|
-
},
|
|
2197
|
-
cells: p
|
|
2198
|
-
};
|
|
2199
|
-
});
|
|
2200
|
-
},
|
|
2201
|
-
/**
|
|
2202
|
-
* Gets the direction of the merge based on the current cell selection.
|
|
2203
|
-
*
|
|
2204
|
-
* Returns undefined when there is no cell selection, or the selection is not within a table.
|
|
2205
|
-
*/
|
|
2206
|
-
getMergeDirection(t) {
|
|
2207
|
-
return n.transact((r) => {
|
|
2208
|
-
const s = ne(r.selection) ? r.selection : void 0;
|
|
2209
|
-
if (!s || !t || // Only offer the merge button if there is more than one cell selected.
|
|
2210
|
-
s.ranges.length <= 1)
|
|
2211
|
-
return;
|
|
2212
|
-
const i = this.getCellSelection();
|
|
2213
|
-
if (i)
|
|
2214
|
-
return Xe(i.from, i.to, t) ? "vertical" : "horizontal";
|
|
2215
|
-
});
|
|
2216
|
-
},
|
|
2217
|
-
cropEmptyRowsOrColumns(t, r) {
|
|
2218
|
-
return Ke(t, r);
|
|
2219
|
-
},
|
|
2220
|
-
addRowsOrColumns(t, r, s) {
|
|
2221
|
-
return je(t, r, s);
|
|
2222
|
-
}
|
|
2223
|
-
};
|
|
2224
|
-
}), me = new N("trailingNode"), jo = E(() => ({
|
|
2225
|
-
key: "trailingNode",
|
|
2226
|
-
prosemirrorPlugins: [
|
|
2227
|
-
new L({
|
|
2228
|
-
key: me,
|
|
2229
|
-
appendTransaction: (n, e, o) => {
|
|
2230
|
-
const { doc: t, tr: r, schema: s } = o, i = me.getState(o), a = t.content.size - 2, c = s.nodes.blockContainer, l = s.nodes.paragraph;
|
|
2231
|
-
if (i)
|
|
2232
|
-
return r.insert(
|
|
2233
|
-
a,
|
|
2234
|
-
c.create(void 0, l.create())
|
|
2235
|
-
);
|
|
2236
|
-
},
|
|
2237
|
-
state: {
|
|
2238
|
-
init: (n, e) => {
|
|
2239
|
-
},
|
|
2240
|
-
apply: (n, e) => {
|
|
2241
|
-
if (!n.docChanged)
|
|
2242
|
-
return e;
|
|
2243
|
-
let o = n.doc.lastChild;
|
|
2244
|
-
if (!o || o.type.name !== "blockGroup")
|
|
2245
|
-
throw new Error("Expected blockGroup");
|
|
2246
|
-
if (o = o.lastChild, !o || o.type.name !== "blockContainer")
|
|
2247
|
-
return !0;
|
|
2248
|
-
const t = o.firstChild;
|
|
2249
|
-
if (!t)
|
|
2250
|
-
throw new Error("Expected blockContent");
|
|
2251
|
-
return o.nodeSize > 4 || t.type.spec.content !== "inline*";
|
|
2252
|
-
}
|
|
2253
|
-
}
|
|
2254
|
-
})
|
|
2255
|
-
]
|
|
2256
|
-
}));
|
|
2257
|
-
export {
|
|
2258
|
-
Do as B,
|
|
2259
|
-
Ut as D,
|
|
2260
|
-
Oo as F,
|
|
2261
|
-
Lo as H,
|
|
2262
|
-
No as L,
|
|
2263
|
-
Ho as N,
|
|
2264
|
-
$o as P,
|
|
2265
|
-
Po as S,
|
|
2266
|
-
ro as T,
|
|
2267
|
-
Ro as V,
|
|
2268
|
-
ae as Y,
|
|
2269
|
-
K as a,
|
|
2270
|
-
X as b,
|
|
2271
|
-
Mo as c,
|
|
2272
|
-
Ao as d,
|
|
2273
|
-
Vo as e,
|
|
2274
|
-
Fo as f,
|
|
2275
|
-
Qt as g,
|
|
2276
|
-
_o as h,
|
|
2277
|
-
zo as i,
|
|
2278
|
-
Yo as j,
|
|
2279
|
-
jo as k,
|
|
2280
|
-
Mt as l,
|
|
2281
|
-
Be as m,
|
|
2282
|
-
Uo as n,
|
|
2283
|
-
Oe as o,
|
|
2284
|
-
Wt as p,
|
|
2285
|
-
Zt as s,
|
|
2286
|
-
V as t
|
|
2287
|
-
};
|
|
2288
|
-
//# sourceMappingURL=TrailingNode-GzE59m_7.js.map
|