@blocknote/core 0.46.2 → 0.47.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/{BlockNoteSchema-BkXw8HJ6.js → BlockNoteSchema-1r-ln0Q0.js} +2 -2
- package/dist/{BlockNoteSchema-BkXw8HJ6.js.map → BlockNoteSchema-1r-ln0Q0.js.map} +1 -1
- package/dist/{BlockNoteSchema-DmFDeA0n.cjs → BlockNoteSchema-DT4bdXj5.cjs} +2 -2
- package/dist/{BlockNoteSchema-DmFDeA0n.cjs.map → BlockNoteSchema-DT4bdXj5.cjs.map} +1 -1
- package/dist/{TrailingNode-CxM966vN.js → TrailingNode-DZag-Nvu.js} +448 -444
- package/dist/TrailingNode-DZag-Nvu.js.map +1 -0
- package/dist/TrailingNode-tesI8f7N.cjs +2 -0
- package/dist/TrailingNode-tesI8f7N.cjs.map +1 -0
- package/dist/blocknote.cjs +4 -4
- package/dist/blocknote.cjs.map +1 -1
- package/dist/blocknote.js +1053 -1014
- package/dist/blocknote.js.map +1 -1
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +2 -2
- package/dist/{defaultBlocks-DE5GNdJH.js → defaultBlocks-BSOEW3GR.js} +3 -3
- package/dist/defaultBlocks-BSOEW3GR.js.map +1 -0
- package/dist/defaultBlocks-D049Pbme.cjs +6 -0
- package/dist/defaultBlocks-D049Pbme.cjs.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +3 -3
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +813 -28
- package/dist/locales.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +1 -1
- package/src/blocks/ListItem/CheckListItem/block.test.ts +61 -0
- package/src/blocks/ListItem/CheckListItem/block.ts +4 -0
- package/src/editor/Block.css +2 -2
- package/src/editor/transformPasted.ts +69 -0
- package/src/extensions/SideMenu/SideMenu.ts +44 -0
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +37 -11
- package/src/i18n/locales/fa.ts +390 -0
- package/src/i18n/locales/index.ts +2 -0
- package/src/i18n/locales/uz.ts +421 -0
- package/types/src/blocks/ListItem/CheckListItem/block.test.d.ts +1 -0
- package/types/src/i18n/locales/fa.d.ts +320 -0
- package/types/src/i18n/locales/index.d.ts +2 -0
- package/types/src/i18n/locales/uz.d.ts +2 -0
- package/dist/TrailingNode-CxM966vN.js.map +0 -1
- package/dist/TrailingNode-D-CZ76FS.cjs +0 -2
- package/dist/TrailingNode-D-CZ76FS.cjs.map +0 -1
- package/dist/defaultBlocks-DE5GNdJH.js.map +0 -1
- package/dist/defaultBlocks-DosClM5E.cjs +0 -6
- package/dist/defaultBlocks-DosClM5E.cjs.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
var Ie = Object.defineProperty;
|
|
2
|
-
var Be = (n, e,
|
|
3
|
-
var b = (n, e,
|
|
2
|
+
var Be = (n, e, o) => e in n ? Ie(n, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : n[e] = o;
|
|
3
|
+
var b = (n, e, o) => Be(n, typeof e != "symbol" ? e + "" : e, o);
|
|
4
4
|
import { Plugin as T, PluginKey as P, NodeSelection as le, TextSelection as ce, Selection as N } from "prosemirror-state";
|
|
5
|
-
import { combineTransactionSteps as Te, getMarkRange as Pe, posToDOMRect as
|
|
6
|
-
import
|
|
5
|
+
import { combineTransactionSteps as Te, getMarkRange as Pe, posToDOMRect as De, findChildren as j } from "@tiptap/core";
|
|
6
|
+
import Oe from "fast-deep-equal";
|
|
7
7
|
import { i as q, t as Ae, U as Me, n as Ne, g as R, a as L, c as de, m as Re, e as ue, f as Le, h as Ve, j as He, k as Fe, l as $e, o as W, p as G } from "./blockToNode-BNoNIXU7.js";
|
|
8
|
-
import { ai as he, a2 as J, aj as me, $ as Ue, a1 as Q } from "./defaultBlocks-
|
|
9
|
-
import { c as
|
|
8
|
+
import { ai as he, a2 as J, aj as me, $ as Ue, a1 as Q } from "./defaultBlocks-BSOEW3GR.js";
|
|
9
|
+
import { c as C, a as H } from "./BlockNoteExtension-C2X7LW-V.js";
|
|
10
10
|
import { yCursorPlugin as _e, defaultSelectionBuilder as ze, ySyncPlugin as Ke, redoCommand as Ye, undoCommand as Xe, yUndoPlugin as je, yUndoPluginKey as Z } from "y-prosemirror";
|
|
11
11
|
import * as I from "yjs";
|
|
12
12
|
import { PluginKey as pe, Plugin as fe, TextSelection as qe } from "@tiptap/pm/state";
|
|
@@ -26,11 +26,11 @@ import { visit as ct } from "unist-util-visit";
|
|
|
26
26
|
import { splitCell as dt, mergeCells as ut, deleteRow as ht, deleteColumn as mt, addRowBefore as pt, addRowAfter as ft, addColumnBefore as gt, addColumnAfter as wt, CellSelection as yt } from "prosemirror-tables";
|
|
27
27
|
function ye(n) {
|
|
28
28
|
const e = Array.from(n.classList).filter(
|
|
29
|
-
(
|
|
29
|
+
(o) => !o.startsWith("bn-")
|
|
30
30
|
) || [];
|
|
31
31
|
e.length > 0 ? n.className = e.join(" ") : n.removeAttribute("class");
|
|
32
32
|
}
|
|
33
|
-
function be(n, e,
|
|
33
|
+
function be(n, e, o, t) {
|
|
34
34
|
var a;
|
|
35
35
|
let r;
|
|
36
36
|
if (e)
|
|
@@ -43,7 +43,7 @@ function be(n, e, t, o) {
|
|
|
43
43
|
else
|
|
44
44
|
throw new Me(e.type);
|
|
45
45
|
else throw new Error("blockContent is required");
|
|
46
|
-
const i = ((
|
|
46
|
+
const i = ((t == null ? void 0 : t.document) ?? document).createDocumentFragment();
|
|
47
47
|
for (const c of r)
|
|
48
48
|
if (c.type.name !== "text" && n.schema.inlineContentSchema[c.type.name]) {
|
|
49
49
|
const l = n.schema.inlineContentSpecs[c.type.name].implementation;
|
|
@@ -67,9 +67,9 @@ function be(n, e, t, o) {
|
|
|
67
67
|
);
|
|
68
68
|
if (h) {
|
|
69
69
|
if (i.appendChild(h.dom), h.contentDOM) {
|
|
70
|
-
const g =
|
|
70
|
+
const g = o.serializeFragment(
|
|
71
71
|
c.content,
|
|
72
|
-
|
|
72
|
+
t
|
|
73
73
|
);
|
|
74
74
|
h.contentDOM.dataset.editable = "", h.contentDOM.appendChild(g);
|
|
75
75
|
}
|
|
@@ -90,47 +90,47 @@ function be(n, e, t, o) {
|
|
|
90
90
|
}
|
|
91
91
|
i.appendChild(l);
|
|
92
92
|
} else {
|
|
93
|
-
const l =
|
|
93
|
+
const l = o.serializeFragment(
|
|
94
94
|
we.from([c]),
|
|
95
|
-
|
|
95
|
+
t
|
|
96
96
|
);
|
|
97
97
|
i.appendChild(l);
|
|
98
98
|
}
|
|
99
99
|
return i.childNodes.length === 1 && ((a = i.firstChild) == null ? void 0 : a.nodeType) === 1 && ye(i.firstChild), i;
|
|
100
100
|
}
|
|
101
|
-
function bt(n, e,
|
|
102
|
-
var w, y,
|
|
103
|
-
const c = (a == null ? void 0 : a.document) ?? document, l = e.pmSchema.nodes.blockContainer, u =
|
|
104
|
-
for (const [
|
|
105
|
-
e.schema.blockSchema[
|
|
101
|
+
function bt(n, e, o, t, r, s, i, a) {
|
|
102
|
+
var w, y, v, D, _, z, K, Y, X;
|
|
103
|
+
const c = (a == null ? void 0 : a.document) ?? document, l = e.pmSchema.nodes.blockContainer, u = o.props || {};
|
|
104
|
+
for (const [k, x] of Object.entries(
|
|
105
|
+
e.schema.blockSchema[o.type].propSchema
|
|
106
106
|
))
|
|
107
|
-
!(
|
|
107
|
+
!(k in u) && x.default !== void 0 && (u[k] = x.default);
|
|
108
108
|
const h = (y = (w = l.spec) == null ? void 0 : w.toDOM) == null ? void 0 : y.call(
|
|
109
109
|
w,
|
|
110
110
|
l.create({
|
|
111
|
-
id:
|
|
111
|
+
id: o.id,
|
|
112
112
|
...u
|
|
113
113
|
})
|
|
114
|
-
), g = Array.from(h.dom.attributes), m = e.blockImplementations[
|
|
114
|
+
), g = Array.from(h.dom.attributes), m = e.blockImplementations[o.type].implementation, p = ((v = m.toExternalHTML) == null ? void 0 : v.call(
|
|
115
115
|
{},
|
|
116
|
-
{ ...
|
|
116
|
+
{ ...o, props: u },
|
|
117
117
|
e,
|
|
118
118
|
{
|
|
119
119
|
nestingLevel: i
|
|
120
120
|
}
|
|
121
121
|
)) || m.render.call(
|
|
122
122
|
{},
|
|
123
|
-
{ ...
|
|
123
|
+
{ ...o, props: u },
|
|
124
124
|
e
|
|
125
125
|
), d = c.createDocumentFragment();
|
|
126
126
|
if (p.dom.classList.contains("bn-block-content")) {
|
|
127
|
-
const
|
|
127
|
+
const k = [
|
|
128
128
|
...g,
|
|
129
129
|
...Array.from(p.dom.attributes)
|
|
130
130
|
].filter(
|
|
131
131
|
(x) => x.name.startsWith("data") && x.name !== "data-content-type" && x.name !== "data-file-block" && x.name !== "data-node-view-wrapper" && x.name !== "data-node-type" && x.name !== "data-id" && x.name !== "data-editable"
|
|
132
132
|
);
|
|
133
|
-
for (const x of
|
|
133
|
+
for (const x of k)
|
|
134
134
|
p.dom.firstChild.setAttribute(x.name, x.value);
|
|
135
135
|
ye(p.dom.firstChild), i > 0 && p.dom.firstChild.setAttribute(
|
|
136
136
|
"data-nesting-level",
|
|
@@ -141,134 +141,134 @@ function bt(n, e, t, o, r, s, i, a) {
|
|
|
141
141
|
"data-nesting-level",
|
|
142
142
|
i.toString()
|
|
143
143
|
);
|
|
144
|
-
if (p.contentDOM &&
|
|
145
|
-
const
|
|
144
|
+
if (p.contentDOM && o.content) {
|
|
145
|
+
const k = be(
|
|
146
146
|
e,
|
|
147
|
-
|
|
147
|
+
o.content,
|
|
148
148
|
// TODO
|
|
149
|
-
|
|
149
|
+
t,
|
|
150
150
|
a
|
|
151
151
|
);
|
|
152
|
-
p.contentDOM.appendChild(
|
|
152
|
+
p.contentDOM.appendChild(k);
|
|
153
153
|
}
|
|
154
154
|
let f;
|
|
155
|
-
if (r.has(
|
|
156
|
-
if (((
|
|
157
|
-
const
|
|
158
|
-
f === "OL" && "start" in u && u.start && (u == null ? void 0 : u.start) !== 1 &&
|
|
155
|
+
if (r.has(o.type) ? f = "OL" : s.has(o.type) && (f = "UL"), f) {
|
|
156
|
+
if (((D = n.lastChild) == null ? void 0 : D.nodeName) !== f) {
|
|
157
|
+
const k = c.createElement(f);
|
|
158
|
+
f === "OL" && "start" in u && u.start && (u == null ? void 0 : u.start) !== 1 && k.setAttribute("start", u.start + ""), n.append(k);
|
|
159
159
|
}
|
|
160
160
|
n.lastChild.appendChild(d);
|
|
161
161
|
} else
|
|
162
162
|
n.append(d);
|
|
163
|
-
if (
|
|
164
|
-
const
|
|
165
|
-
if (
|
|
166
|
-
|
|
163
|
+
if (o.children && o.children.length > 0) {
|
|
164
|
+
const k = c.createDocumentFragment();
|
|
165
|
+
if (ke(
|
|
166
|
+
k,
|
|
167
167
|
e,
|
|
168
|
-
|
|
169
|
-
|
|
168
|
+
o.children,
|
|
169
|
+
t,
|
|
170
170
|
r,
|
|
171
171
|
s,
|
|
172
172
|
i + 1,
|
|
173
173
|
a
|
|
174
174
|
), ((_ = n.lastChild) == null ? void 0 : _.nodeName) === "UL" || ((z = n.lastChild) == null ? void 0 : z.nodeName) === "OL")
|
|
175
|
-
for (; ((K =
|
|
176
|
-
n.lastChild.lastChild.appendChild(
|
|
177
|
-
e.pmSchema.nodes[
|
|
175
|
+
for (; ((K = k.firstChild) == null ? void 0 : K.nodeName) === "UL" || ((Y = k.firstChild) == null ? void 0 : Y.nodeName) === "OL"; )
|
|
176
|
+
n.lastChild.lastChild.appendChild(k.firstChild);
|
|
177
|
+
e.pmSchema.nodes[o.type].isInGroup("blockContent") ? n.append(k) : (X = p.contentDOM) == null || X.append(k);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
-
const
|
|
181
|
-
for (const c of
|
|
180
|
+
const ke = (n, e, o, t, r, s, i = 0, a) => {
|
|
181
|
+
for (const c of o)
|
|
182
182
|
bt(
|
|
183
183
|
n,
|
|
184
184
|
e,
|
|
185
185
|
c,
|
|
186
|
-
|
|
186
|
+
t,
|
|
187
187
|
r,
|
|
188
188
|
s,
|
|
189
189
|
i,
|
|
190
190
|
a
|
|
191
191
|
);
|
|
192
|
-
},
|
|
192
|
+
}, kt = (n, e, o, t, r, s) => {
|
|
193
193
|
const a = ((s == null ? void 0 : s.document) ?? document).createDocumentFragment();
|
|
194
|
-
return
|
|
194
|
+
return ke(
|
|
195
195
|
a,
|
|
196
196
|
n,
|
|
197
197
|
e,
|
|
198
|
-
t,
|
|
199
198
|
o,
|
|
199
|
+
t,
|
|
200
200
|
r,
|
|
201
201
|
0,
|
|
202
202
|
s
|
|
203
203
|
), a;
|
|
204
|
-
},
|
|
205
|
-
const
|
|
204
|
+
}, Ce = (n, e) => {
|
|
205
|
+
const o = ge.fromSchema(n);
|
|
206
206
|
return {
|
|
207
|
-
exportBlocks: (
|
|
208
|
-
const s =
|
|
207
|
+
exportBlocks: (t, r) => {
|
|
208
|
+
const s = kt(
|
|
209
209
|
e,
|
|
210
|
-
o,
|
|
211
210
|
t,
|
|
211
|
+
o,
|
|
212
212
|
/* @__PURE__ */ new Set(["numberedListItem"]),
|
|
213
213
|
/* @__PURE__ */ new Set(["bulletListItem", "checkListItem", "toggleListItem"]),
|
|
214
214
|
r
|
|
215
215
|
), i = document.createElement("div");
|
|
216
216
|
return i.append(s), i.innerHTML;
|
|
217
217
|
},
|
|
218
|
-
exportInlineContent: (
|
|
218
|
+
exportInlineContent: (t, r) => {
|
|
219
219
|
const s = be(
|
|
220
220
|
e,
|
|
221
|
-
o,
|
|
222
221
|
t,
|
|
222
|
+
o,
|
|
223
223
|
r
|
|
224
224
|
), i = document.createElement("div");
|
|
225
225
|
return i.append(s.cloneNode(!0)), i.innerHTML;
|
|
226
226
|
}
|
|
227
227
|
};
|
|
228
228
|
};
|
|
229
|
-
function
|
|
229
|
+
function Ct(n, e) {
|
|
230
230
|
if (e === 0)
|
|
231
231
|
return;
|
|
232
|
-
const
|
|
233
|
-
for (let
|
|
234
|
-
const r =
|
|
232
|
+
const o = n.resolve(e);
|
|
233
|
+
for (let t = o.depth; t > 0; t--) {
|
|
234
|
+
const r = o.node(t);
|
|
235
235
|
if (he(r))
|
|
236
236
|
return r.attrs.id;
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
-
function
|
|
239
|
+
function vt(n) {
|
|
240
240
|
return n.getMeta("paste") ? { type: "paste" } : n.getMeta("uiEvent") === "drop" ? { type: "drop" } : n.getMeta("history$") ? {
|
|
241
241
|
type: n.getMeta("history$").redo ? "redo" : "undo"
|
|
242
242
|
} : n.getMeta("y-sync$") ? n.getMeta("y-sync$").isUndoRedoOperation ? { type: "undo-redo" } : { type: "yjs-remote" } : { type: "local" };
|
|
243
243
|
}
|
|
244
244
|
function ee(n) {
|
|
245
|
-
const e = "__root__",
|
|
245
|
+
const e = "__root__", o = {}, t = {}, r = R(n);
|
|
246
246
|
return n.descendants((s, i) => {
|
|
247
247
|
if (!he(s))
|
|
248
248
|
return !0;
|
|
249
|
-
const a =
|
|
250
|
-
|
|
249
|
+
const a = Ct(n, i), c = a ?? e;
|
|
250
|
+
t[c] || (t[c] = []);
|
|
251
251
|
const l = L(s, r);
|
|
252
|
-
return
|
|
253
|
-
}), { byId:
|
|
252
|
+
return o[s.attrs.id] = { block: l, parentId: a }, t[c].push(s.attrs.id), !0;
|
|
253
|
+
}), { byId: o, childrenByParent: t };
|
|
254
254
|
}
|
|
255
255
|
function St(n, e) {
|
|
256
|
-
const
|
|
256
|
+
const o = /* @__PURE__ */ new Set();
|
|
257
257
|
if (!n || !e)
|
|
258
|
-
return
|
|
259
|
-
const
|
|
258
|
+
return o;
|
|
259
|
+
const t = new Set(n), r = e.filter((d) => t.has(d)), s = n.filter(
|
|
260
260
|
(d) => r.includes(d)
|
|
261
261
|
);
|
|
262
262
|
if (s.length <= 1 || r.length <= 1)
|
|
263
|
-
return
|
|
263
|
+
return o;
|
|
264
264
|
const i = {};
|
|
265
265
|
for (let d = 0; d < s.length; d++)
|
|
266
266
|
i[s[d]] = d;
|
|
267
267
|
const a = r.map((d) => i[d]), c = a.length, l = [], u = [], h = new Array(c).fill(-1), g = (d, f) => {
|
|
268
268
|
let w = 0, y = d.length;
|
|
269
269
|
for (; w < y; ) {
|
|
270
|
-
const
|
|
271
|
-
d[
|
|
270
|
+
const v = w + y >>> 1;
|
|
271
|
+
d[v] < f ? w = v + 1 : y = v;
|
|
272
272
|
}
|
|
273
273
|
return w;
|
|
274
274
|
};
|
|
@@ -281,30 +281,30 @@ function St(n, e) {
|
|
|
281
281
|
for (; p !== -1; )
|
|
282
282
|
m.add(p), p = h[p];
|
|
283
283
|
for (let d = 0; d < r.length; d++)
|
|
284
|
-
m.has(d) ||
|
|
285
|
-
return
|
|
284
|
+
m.has(d) || o.add(r[d]);
|
|
285
|
+
return o;
|
|
286
286
|
}
|
|
287
287
|
function xt(n, e = []) {
|
|
288
|
-
const
|
|
288
|
+
const o = vt(n), t = Te(n.before, [
|
|
289
289
|
n,
|
|
290
290
|
...e
|
|
291
291
|
]), r = ee(
|
|
292
|
-
|
|
292
|
+
t.before
|
|
293
293
|
), s = ee(
|
|
294
|
-
|
|
294
|
+
t.doc
|
|
295
295
|
), i = [], a = /* @__PURE__ */ new Set();
|
|
296
296
|
Object.keys(s.byId).filter((m) => !(m in r.byId)).forEach((m) => {
|
|
297
297
|
i.push({
|
|
298
298
|
type: "insert",
|
|
299
299
|
block: s.byId[m].block,
|
|
300
|
-
source:
|
|
300
|
+
source: o,
|
|
301
301
|
prevBlock: void 0
|
|
302
302
|
}), a.add(m);
|
|
303
303
|
}), Object.keys(r.byId).filter((m) => !(m in s.byId)).forEach((m) => {
|
|
304
304
|
i.push({
|
|
305
305
|
type: "delete",
|
|
306
306
|
block: r.byId[m].block,
|
|
307
|
-
source:
|
|
307
|
+
source: o,
|
|
308
308
|
prevBlock: void 0
|
|
309
309
|
}), a.add(m);
|
|
310
310
|
}), Object.keys(s.byId).filter((m) => m in r.byId).forEach((m) => {
|
|
@@ -314,17 +314,17 @@ function xt(n, e = []) {
|
|
|
314
314
|
type: "move",
|
|
315
315
|
block: d.block,
|
|
316
316
|
prevBlock: p.block,
|
|
317
|
-
source:
|
|
317
|
+
source: o,
|
|
318
318
|
prevParent: p.parentId ? (w = r.byId[p.parentId]) == null ? void 0 : w.block : void 0,
|
|
319
319
|
currentParent: d.parentId ? (y = s.byId[d.parentId]) == null ? void 0 : y.block : void 0
|
|
320
|
-
}), a.add(m)) :
|
|
320
|
+
}), a.add(m)) : Oe(
|
|
321
321
|
{ ...p.block, children: void 0 },
|
|
322
322
|
{ ...d.block, children: void 0 }
|
|
323
323
|
) || (i.push({
|
|
324
324
|
type: "update",
|
|
325
325
|
block: d.block,
|
|
326
326
|
prevBlock: p.block,
|
|
327
|
-
source:
|
|
327
|
+
source: o
|
|
328
328
|
}), a.add(m));
|
|
329
329
|
});
|
|
330
330
|
const c = r.childrenByParent, l = s.childrenByParent, u = "__root__", h = /* @__PURE__ */ new Set([
|
|
@@ -337,20 +337,20 @@ function xt(n, e = []) {
|
|
|
337
337
|
l[m]
|
|
338
338
|
);
|
|
339
339
|
p.size !== 0 && p.forEach((d) => {
|
|
340
|
-
var
|
|
340
|
+
var v, D;
|
|
341
341
|
const f = r.byId[d], w = s.byId[d];
|
|
342
342
|
!f || !w || f.parentId !== w.parentId || a.has(d) || (f.parentId ?? u) !== m || g.has(d) || (g.add(d), i.push({
|
|
343
343
|
type: "move",
|
|
344
344
|
block: w.block,
|
|
345
345
|
prevBlock: f.block,
|
|
346
|
-
source:
|
|
347
|
-
prevParent: f.parentId ? (
|
|
348
|
-
currentParent: w.parentId ? (
|
|
346
|
+
source: o,
|
|
347
|
+
prevParent: f.parentId ? (v = r.byId[f.parentId]) == null ? void 0 : v.block : void 0,
|
|
348
|
+
currentParent: w.parentId ? (D = s.byId[w.parentId]) == null ? void 0 : D.block : void 0
|
|
349
349
|
}), a.add(d));
|
|
350
350
|
});
|
|
351
351
|
}), i;
|
|
352
352
|
}
|
|
353
|
-
const fo =
|
|
353
|
+
const fo = C(() => {
|
|
354
354
|
const n = [];
|
|
355
355
|
return {
|
|
356
356
|
key: "blockChange",
|
|
@@ -358,10 +358,10 @@ const fo = k(() => {
|
|
|
358
358
|
new T({
|
|
359
359
|
key: new P("blockChange"),
|
|
360
360
|
filterTransaction: (e) => {
|
|
361
|
-
let
|
|
362
|
-
return n.reduce((
|
|
361
|
+
let o;
|
|
362
|
+
return n.reduce((t, r) => t === !1 ? t : r({
|
|
363
363
|
getChanges() {
|
|
364
|
-
return
|
|
364
|
+
return o || (o = xt(e), o);
|
|
365
365
|
},
|
|
366
366
|
tr: e
|
|
367
367
|
}) !== !1, !0);
|
|
@@ -382,32 +382,32 @@ const fo = k(() => {
|
|
|
382
382
|
};
|
|
383
383
|
});
|
|
384
384
|
function te(n) {
|
|
385
|
-
const e = n.charAt(0) === "#" ? n.substring(1, 7) : 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
386
|
return 0.2126 * i[0] + 0.7152 * i[1] + 0.0722 * i[2] <= 0.179;
|
|
387
387
|
}
|
|
388
388
|
function Et(n) {
|
|
389
389
|
const e = document.createElement("span");
|
|
390
390
|
e.classList.add("bn-collaboration-cursor__base");
|
|
391
|
-
const
|
|
392
|
-
|
|
391
|
+
const o = document.createElement("span");
|
|
392
|
+
o.setAttribute("contentedEditable", "false"), o.classList.add("bn-collaboration-cursor__caret"), o.setAttribute(
|
|
393
393
|
"style",
|
|
394
394
|
`background-color: ${n.color}; color: ${te(n.color) ? "white" : "black"}`
|
|
395
395
|
);
|
|
396
|
-
const
|
|
397
|
-
return
|
|
396
|
+
const t = document.createElement("span");
|
|
397
|
+
return t.classList.add("bn-collaboration-cursor__label"), t.setAttribute(
|
|
398
398
|
"style",
|
|
399
399
|
`background-color: ${n.color}; color: ${te(n.color) ? "white" : "black"}`
|
|
400
|
-
),
|
|
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
401
|
}
|
|
402
|
-
const oe =
|
|
402
|
+
const oe = C(
|
|
403
403
|
({ options: n }) => {
|
|
404
|
-
const e = /* @__PURE__ */ new Map(),
|
|
405
|
-
return
|
|
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
406
|
"change",
|
|
407
407
|
({
|
|
408
|
-
updated:
|
|
408
|
+
updated: t
|
|
409
409
|
}) => {
|
|
410
|
-
for (const r of
|
|
410
|
+
for (const r of t) {
|
|
411
411
|
const s = e.get(r);
|
|
412
412
|
s && (s.element.setAttribute("data-active", ""), s.hideTimeout && clearTimeout(s.hideTimeout), e.set(r, {
|
|
413
413
|
element: s.element,
|
|
@@ -420,12 +420,12 @@ const oe = k(
|
|
|
420
420
|
)), {
|
|
421
421
|
key: "yCursor",
|
|
422
422
|
prosemirrorPlugins: [
|
|
423
|
-
|
|
423
|
+
o ? _e(o, {
|
|
424
424
|
selectionBuilder: ze,
|
|
425
|
-
cursorBuilder(
|
|
425
|
+
cursorBuilder(t, r) {
|
|
426
426
|
let s = e.get(r);
|
|
427
427
|
if (!s) {
|
|
428
|
-
const i = (n.renderCursor ?? Et)(
|
|
428
|
+
const i = (n.renderCursor ?? Et)(t);
|
|
429
429
|
n.showCursorLabels !== "always" && (i.addEventListener("mouseenter", () => {
|
|
430
430
|
const a = e.get(r);
|
|
431
431
|
a.element.setAttribute("data-active", ""), a.hideTimeout && (clearTimeout(a.hideTimeout), e.set(r, {
|
|
@@ -450,18 +450,18 @@ const oe = k(
|
|
|
450
450
|
}) : void 0
|
|
451
451
|
].filter(Boolean),
|
|
452
452
|
dependsOn: ["ySync"],
|
|
453
|
-
updateUser(
|
|
454
|
-
|
|
453
|
+
updateUser(t) {
|
|
454
|
+
o == null || o.setLocalStateField("user", t);
|
|
455
455
|
}
|
|
456
456
|
};
|
|
457
457
|
}
|
|
458
|
-
), F =
|
|
458
|
+
), F = C(
|
|
459
459
|
({ options: n }) => ({
|
|
460
460
|
key: "ySync",
|
|
461
461
|
prosemirrorPlugins: [Ke(n.fragment)],
|
|
462
462
|
runsBefore: ["default"]
|
|
463
463
|
})
|
|
464
|
-
), $ =
|
|
464
|
+
), $ = C(() => ({
|
|
465
465
|
key: "yUndo",
|
|
466
466
|
prosemirrorPlugins: [je()],
|
|
467
467
|
dependsOn: ["yCursor", "ySync"],
|
|
@@ -469,33 +469,33 @@ const oe = k(
|
|
|
469
469
|
redoCommand: Ye
|
|
470
470
|
}));
|
|
471
471
|
function It(n, e) {
|
|
472
|
-
const
|
|
472
|
+
const o = n.doc;
|
|
473
473
|
if (n._item === null) {
|
|
474
|
-
const
|
|
475
|
-
(r) =>
|
|
474
|
+
const t = Array.from(o.share.keys()).find(
|
|
475
|
+
(r) => o.share.get(r) === n
|
|
476
476
|
);
|
|
477
|
-
if (
|
|
477
|
+
if (t == null)
|
|
478
478
|
throw new Error("type does not exist in other ydoc");
|
|
479
|
-
return e.get(
|
|
479
|
+
return e.get(t, n.constructor);
|
|
480
480
|
} else {
|
|
481
|
-
const
|
|
481
|
+
const t = n._item, r = e.store.clients.get(t.id.client) ?? [], s = I.findIndexSS(r, t.id.clock);
|
|
482
482
|
return r[s].content.type;
|
|
483
483
|
}
|
|
484
484
|
}
|
|
485
|
-
const go =
|
|
485
|
+
const go = C(
|
|
486
486
|
({ editor: n, options: e }) => {
|
|
487
|
-
let
|
|
488
|
-
const
|
|
487
|
+
let o;
|
|
488
|
+
const t = H({ isForked: !1 });
|
|
489
489
|
return {
|
|
490
490
|
key: "yForkDoc",
|
|
491
|
-
store:
|
|
491
|
+
store: t,
|
|
492
492
|
/**
|
|
493
493
|
* Fork the Y.js document from syncing to the remote,
|
|
494
494
|
* allowing modifications to the document without affecting the remote.
|
|
495
495
|
* These changes can later be rolled back or applied to the remote.
|
|
496
496
|
*/
|
|
497
497
|
fork() {
|
|
498
|
-
if (
|
|
498
|
+
if (o)
|
|
499
499
|
return;
|
|
500
500
|
const r = e.fragment;
|
|
501
501
|
if (!r)
|
|
@@ -503,7 +503,7 @@ const go = k(
|
|
|
503
503
|
const s = new I.Doc();
|
|
504
504
|
I.applyUpdate(s, I.encodeStateAsUpdate(r.doc));
|
|
505
505
|
const i = It(r, s);
|
|
506
|
-
|
|
506
|
+
o = {
|
|
507
507
|
undoStack: Z.getState(n.prosemirrorState).undoManager.undoStack,
|
|
508
508
|
originalFragment: r,
|
|
509
509
|
forkedFragment: i
|
|
@@ -520,7 +520,7 @@ const go = k(
|
|
|
520
520
|
F(a),
|
|
521
521
|
// No need to register the cursor plugin again, it's a local fork
|
|
522
522
|
$()
|
|
523
|
-
]),
|
|
523
|
+
]), t.setState({ isForked: !0 });
|
|
524
524
|
},
|
|
525
525
|
/**
|
|
526
526
|
* Resume syncing the Y.js document to the remote
|
|
@@ -528,10 +528,10 @@ const go = k(
|
|
|
528
528
|
* Otherwise, the original document will be restored and the changes will be discarded.
|
|
529
529
|
*/
|
|
530
530
|
merge({ keepChanges: r }) {
|
|
531
|
-
if (!
|
|
531
|
+
if (!o)
|
|
532
532
|
return;
|
|
533
533
|
n.unregisterExtension(["ySync", "yCursor", "yUndo"]);
|
|
534
|
-
const { originalFragment: s, forkedFragment: i, undoStack: a } =
|
|
534
|
+
const { originalFragment: s, forkedFragment: i, undoStack: a } = o;
|
|
535
535
|
if (n.registerExtension([
|
|
536
536
|
F(e),
|
|
537
537
|
oe(e),
|
|
@@ -545,28 +545,28 @@ const go = k(
|
|
|
545
545
|
);
|
|
546
546
|
I.applyUpdate(s.doc, c, n);
|
|
547
547
|
}
|
|
548
|
-
|
|
548
|
+
o = void 0, t.setState({ isForked: !1 });
|
|
549
549
|
}
|
|
550
550
|
};
|
|
551
551
|
}
|
|
552
|
-
),
|
|
553
|
-
e(n), n.forEach((
|
|
554
|
-
|
|
552
|
+
), ve = (n, e) => {
|
|
553
|
+
e(n), n.forEach((o) => {
|
|
554
|
+
o instanceof I.XmlElement && ve(o, e);
|
|
555
555
|
});
|
|
556
556
|
}, Bt = (n, e) => {
|
|
557
|
-
const
|
|
558
|
-
return n.forEach((
|
|
559
|
-
|
|
557
|
+
const o = /* @__PURE__ */ new Map();
|
|
558
|
+
return n.forEach((t) => {
|
|
559
|
+
t instanceof I.XmlElement && ve(t, (r) => {
|
|
560
560
|
if (r.nodeName === "blockContainer" && r.hasAttribute("id")) {
|
|
561
561
|
const s = r.getAttribute("textColor"), i = r.getAttribute("backgroundColor"), a = {
|
|
562
562
|
textColor: s === J.textColor.default ? void 0 : s,
|
|
563
563
|
backgroundColor: i === J.backgroundColor.default ? void 0 : i
|
|
564
564
|
};
|
|
565
|
-
(a.textColor || a.backgroundColor) &&
|
|
565
|
+
(a.textColor || a.backgroundColor) && o.set(r.getAttribute("id"), a);
|
|
566
566
|
}
|
|
567
567
|
});
|
|
568
|
-
}),
|
|
569
|
-
if (
|
|
568
|
+
}), o.size === 0 ? !1 : (e.doc.descendants((t, r) => {
|
|
569
|
+
if (t.type.name === "blockContainer" && o.has(t.attrs.id)) {
|
|
570
570
|
const s = e.doc.nodeAt(r + 1);
|
|
571
571
|
if (!s)
|
|
572
572
|
throw new Error("No element found");
|
|
@@ -574,23 +574,23 @@ const go = k(
|
|
|
574
574
|
// preserve existing attributes
|
|
575
575
|
...s.attrs,
|
|
576
576
|
// add the textColor and backgroundColor attributes
|
|
577
|
-
...
|
|
577
|
+
...o.get(t.attrs.id)
|
|
578
578
|
});
|
|
579
579
|
}
|
|
580
580
|
}), !0);
|
|
581
|
-
}, Tt = [Bt], wo =
|
|
581
|
+
}, Tt = [Bt], wo = C(
|
|
582
582
|
({ options: n }) => {
|
|
583
583
|
let e = !1;
|
|
584
|
-
const
|
|
584
|
+
const o = new pe("schemaMigration");
|
|
585
585
|
return {
|
|
586
586
|
key: "schemaMigration",
|
|
587
587
|
prosemirrorPlugins: [
|
|
588
588
|
new fe({
|
|
589
|
-
key:
|
|
590
|
-
appendTransaction: (
|
|
589
|
+
key: o,
|
|
590
|
+
appendTransaction: (t, r, s) => {
|
|
591
591
|
if (e || // If any of the transactions are not due to a yjs sync, we don't need to run the migration
|
|
592
|
-
!
|
|
593
|
-
|
|
592
|
+
!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
|
|
593
|
+
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)
|
|
594
594
|
!n.fragment.firstChild)
|
|
595
595
|
return;
|
|
596
596
|
const i = s.tr;
|
|
@@ -603,7 +603,7 @@ const go = k(
|
|
|
603
603
|
]
|
|
604
604
|
};
|
|
605
605
|
}
|
|
606
|
-
), yo =
|
|
606
|
+
), yo = C(
|
|
607
607
|
({
|
|
608
608
|
editor: n,
|
|
609
609
|
options: e
|
|
@@ -617,25 +617,25 @@ const go = k(
|
|
|
617
617
|
})
|
|
618
618
|
]
|
|
619
619
|
})
|
|
620
|
-
), bo =
|
|
621
|
-
const e = H(!1),
|
|
620
|
+
), bo = C(({ editor: n }) => {
|
|
621
|
+
const e = H(!1), o = () => n.transact((t) => {
|
|
622
622
|
var s;
|
|
623
|
-
if (
|
|
623
|
+
if (t.selection.empty || t.selection instanceof le && (t.selection.node.type.spec.content === "inline*" || ((s = t.selection.node.firstChild) == null ? void 0 : s.type.spec.content) === "inline*") || t.selection instanceof ce && t.doc.textBetween(t.selection.from, t.selection.to).length === 0)
|
|
624
624
|
return !1;
|
|
625
625
|
let r = !1;
|
|
626
|
-
return
|
|
626
|
+
return t.selection.content().content.descendants((i) => (i.type.spec.code && (r = !0), !r)), !r;
|
|
627
627
|
});
|
|
628
628
|
return {
|
|
629
629
|
key: "formattingToolbar",
|
|
630
630
|
store: e,
|
|
631
|
-
mount({ dom:
|
|
631
|
+
mount({ dom: t, signal: r }) {
|
|
632
632
|
let s = !1;
|
|
633
633
|
const i = n.onChange(() => {
|
|
634
|
-
s || e.setState(
|
|
634
|
+
s || e.setState(o());
|
|
635
635
|
}), a = n.onSelectionChange(() => {
|
|
636
|
-
s || e.setState(
|
|
636
|
+
s || e.setState(o());
|
|
637
637
|
});
|
|
638
|
-
|
|
638
|
+
t.addEventListener(
|
|
639
639
|
"pointerdown",
|
|
640
640
|
() => {
|
|
641
641
|
s = !0, e.setState(!1);
|
|
@@ -644,10 +644,10 @@ const go = k(
|
|
|
644
644
|
), n.prosemirrorView.root.addEventListener(
|
|
645
645
|
"pointerup",
|
|
646
646
|
() => {
|
|
647
|
-
s = !1, n.isFocused() && e.setState(
|
|
647
|
+
s = !1, n.isFocused() && e.setState(o());
|
|
648
648
|
},
|
|
649
649
|
{ signal: r, capture: !0 }
|
|
650
|
-
),
|
|
650
|
+
), t.addEventListener(
|
|
651
651
|
"pointercancel",
|
|
652
652
|
() => {
|
|
653
653
|
s = !1;
|
|
@@ -661,12 +661,12 @@ const go = k(
|
|
|
661
661
|
});
|
|
662
662
|
}
|
|
663
663
|
};
|
|
664
|
-
}),
|
|
664
|
+
}), ko = C(() => ({
|
|
665
665
|
key: "history",
|
|
666
666
|
prosemirrorPlugins: [Qe()],
|
|
667
667
|
undoCommand: Je,
|
|
668
668
|
redoCommand: Ge
|
|
669
|
-
})),
|
|
669
|
+
})), Co = C(({ editor: n }) => {
|
|
670
670
|
function e(r) {
|
|
671
671
|
let s = n.prosemirrorView.nodeDOM(r);
|
|
672
672
|
for (; s && s.parentElement; ) {
|
|
@@ -676,7 +676,7 @@ const go = k(
|
|
|
676
676
|
}
|
|
677
677
|
return null;
|
|
678
678
|
}
|
|
679
|
-
function
|
|
679
|
+
function o(r, s) {
|
|
680
680
|
return n.transact((i) => {
|
|
681
681
|
const a = i.doc.resolve(r), c = a.marks().find((u) => u.type.name === s);
|
|
682
682
|
if (!c)
|
|
@@ -690,7 +690,7 @@ const go = k(
|
|
|
690
690
|
return i.doc.textBetween(l.from, l.to);
|
|
691
691
|
},
|
|
692
692
|
get position() {
|
|
693
|
-
return
|
|
693
|
+
return De(
|
|
694
694
|
n.prosemirrorView,
|
|
695
695
|
l.from,
|
|
696
696
|
l.to
|
|
@@ -699,27 +699,27 @@ const go = k(
|
|
|
699
699
|
};
|
|
700
700
|
});
|
|
701
701
|
}
|
|
702
|
-
function
|
|
702
|
+
function t() {
|
|
703
703
|
return n.transact((r) => {
|
|
704
704
|
const s = r.selection;
|
|
705
705
|
if (s.empty)
|
|
706
|
-
return
|
|
706
|
+
return o(s.anchor, "link");
|
|
707
707
|
});
|
|
708
708
|
}
|
|
709
709
|
return {
|
|
710
710
|
key: "linkToolbar",
|
|
711
|
-
getLinkAtSelection:
|
|
711
|
+
getLinkAtSelection: t,
|
|
712
712
|
getLinkElementAtPos: e,
|
|
713
|
-
getMarkAtPos:
|
|
713
|
+
getMarkAtPos: o,
|
|
714
714
|
getLinkAtElement(r) {
|
|
715
715
|
return n.transact(() => {
|
|
716
716
|
const s = n.prosemirrorView.posAtDOM(r, 0) + 1;
|
|
717
|
-
return
|
|
717
|
+
return o(s, "link");
|
|
718
718
|
});
|
|
719
719
|
},
|
|
720
720
|
editLink(r, s, i = n.transact((a) => a.selection.anchor)) {
|
|
721
721
|
n.transact((a) => {
|
|
722
|
-
const c = R(a), { range: l } =
|
|
722
|
+
const c = R(a), { range: l } = o(i + 1, "link") || {
|
|
723
723
|
range: {
|
|
724
724
|
from: a.selection.from,
|
|
725
725
|
to: a.selection.to
|
|
@@ -734,7 +734,7 @@ const go = k(
|
|
|
734
734
|
},
|
|
735
735
|
deleteLink(r = n.transact((s) => s.selection.anchor)) {
|
|
736
736
|
n.transact((s) => {
|
|
737
|
-
const i = R(s), { range: a } =
|
|
737
|
+
const i = R(s), { range: a } = o(r + 1, "link") || {
|
|
738
738
|
range: {
|
|
739
739
|
from: s.selection.from,
|
|
740
740
|
to: s.selection.to
|
|
@@ -747,7 +747,7 @@ const go = k(
|
|
|
747
747
|
}), n.prosemirrorView.focus();
|
|
748
748
|
}
|
|
749
749
|
};
|
|
750
|
-
}),
|
|
750
|
+
}), vo = [
|
|
751
751
|
"http",
|
|
752
752
|
"https",
|
|
753
753
|
"ftp",
|
|
@@ -758,7 +758,7 @@ const go = k(
|
|
|
758
758
|
"sms",
|
|
759
759
|
"cid",
|
|
760
760
|
"xmpp"
|
|
761
|
-
], So = "https", Pt = new P("node-selection-keyboard"), xo =
|
|
761
|
+
], So = "https", Pt = new P("node-selection-keyboard"), xo = C(
|
|
762
762
|
() => ({
|
|
763
763
|
key: "nodeSelectionKeyboard",
|
|
764
764
|
prosemirrorPlugins: [
|
|
@@ -772,14 +772,14 @@ const go = k(
|
|
|
772
772
|
if (e.key.length === 1)
|
|
773
773
|
return e.preventDefault(), !0;
|
|
774
774
|
if (e.key === "Enter" && !e.isComposing && !e.shiftKey && !e.altKey && !e.ctrlKey && !e.metaKey) {
|
|
775
|
-
const
|
|
775
|
+
const o = n.state.tr;
|
|
776
776
|
return n.dispatch(
|
|
777
|
-
|
|
777
|
+
o.insert(
|
|
778
778
|
n.state.tr.selection.$to.after(),
|
|
779
779
|
n.state.schema.nodes.paragraph.createChecked()
|
|
780
780
|
).setSelection(
|
|
781
781
|
new ce(
|
|
782
|
-
|
|
782
|
+
o.doc.resolve(
|
|
783
783
|
n.state.tr.selection.$to.after() + 1
|
|
784
784
|
)
|
|
785
785
|
)
|
|
@@ -793,29 +793,29 @@ const go = k(
|
|
|
793
793
|
})
|
|
794
794
|
]
|
|
795
795
|
})
|
|
796
|
-
),
|
|
796
|
+
), Dt = new P("blocknote-placeholder"), Eo = C(
|
|
797
797
|
({
|
|
798
798
|
editor: n,
|
|
799
799
|
options: e
|
|
800
800
|
}) => {
|
|
801
|
-
const
|
|
801
|
+
const o = e.placeholders;
|
|
802
802
|
return {
|
|
803
803
|
key: "placeholder",
|
|
804
804
|
prosemirrorPlugins: [
|
|
805
805
|
new T({
|
|
806
|
-
key:
|
|
807
|
-
view: (
|
|
806
|
+
key: Dt,
|
|
807
|
+
view: (t) => {
|
|
808
808
|
const r = `placeholder-selector-${Ze()}`;
|
|
809
|
-
|
|
809
|
+
t.dom.classList.add(r);
|
|
810
810
|
const s = document.createElement("style"), i = n._tiptapEditor.options.injectNonce;
|
|
811
|
-
i && s.setAttribute("nonce", i),
|
|
811
|
+
i && s.setAttribute("nonce", i), t.root instanceof window.ShadowRoot ? t.root.append(s) : t.root.head.appendChild(s);
|
|
812
812
|
const a = s.sheet, c = (l = "") => `.${r} .bn-block-content${l} .bn-inline-content:has(> .ProseMirror-trailingBreak:only-child):before`;
|
|
813
813
|
try {
|
|
814
814
|
const {
|
|
815
815
|
default: l,
|
|
816
816
|
emptyDocument: u,
|
|
817
817
|
...h
|
|
818
|
-
} =
|
|
818
|
+
} = o || {};
|
|
819
819
|
for (const [p, d] of Object.entries(h)) {
|
|
820
820
|
const f = `[data-content-type="${p}"]`;
|
|
821
821
|
a.insertRule(
|
|
@@ -842,17 +842,17 @@ const go = k(
|
|
|
842
842
|
}
|
|
843
843
|
return {
|
|
844
844
|
destroy: () => {
|
|
845
|
-
|
|
845
|
+
t.root instanceof window.ShadowRoot ? t.root.removeChild(s) : t.root.head.removeChild(s);
|
|
846
846
|
}
|
|
847
847
|
};
|
|
848
848
|
},
|
|
849
849
|
props: {
|
|
850
|
-
decorations: (
|
|
851
|
-
const { doc: r, selection: s } =
|
|
850
|
+
decorations: (t) => {
|
|
851
|
+
const { doc: r, selection: s } = t;
|
|
852
852
|
if (!n.isEditable || !s.empty || s.$from.parent.type.spec.code)
|
|
853
853
|
return;
|
|
854
854
|
const i = [];
|
|
855
|
-
|
|
855
|
+
t.doc.content.size === 6 && i.push(
|
|
856
856
|
A.node(2, 4, {
|
|
857
857
|
"data-is-only-empty-block": "true"
|
|
858
858
|
})
|
|
@@ -873,7 +873,7 @@ const go = k(
|
|
|
873
873
|
]
|
|
874
874
|
};
|
|
875
875
|
}
|
|
876
|
-
), ne = new P("previous-blocks"),
|
|
876
|
+
), ne = new P("previous-blocks"), Ot = {
|
|
877
877
|
// Numbered List Items
|
|
878
878
|
index: "index",
|
|
879
879
|
// Headings
|
|
@@ -882,7 +882,7 @@ const go = k(
|
|
|
882
882
|
type: "type",
|
|
883
883
|
depth: "depth",
|
|
884
884
|
"depth-change": "depth-change"
|
|
885
|
-
}, Io =
|
|
885
|
+
}, Io = C(() => {
|
|
886
886
|
let n;
|
|
887
887
|
return {
|
|
888
888
|
key: "previousBlockType",
|
|
@@ -891,11 +891,11 @@ const go = k(
|
|
|
891
891
|
key: ne,
|
|
892
892
|
view(e) {
|
|
893
893
|
return {
|
|
894
|
-
update: async (
|
|
894
|
+
update: async (o, t) => {
|
|
895
895
|
var r;
|
|
896
|
-
((r = this.key) == null ? void 0 : r.getState(
|
|
897
|
-
|
|
898
|
-
|
|
896
|
+
((r = this.key) == null ? void 0 : r.getState(o.state).updatedBlocks.size) > 0 && (n = setTimeout(() => {
|
|
897
|
+
o.dispatch(
|
|
898
|
+
o.state.tr.setMeta(ne, { clearUpdate: !0 })
|
|
899
899
|
);
|
|
900
900
|
}, 0));
|
|
901
901
|
},
|
|
@@ -915,11 +915,11 @@ const go = k(
|
|
|
915
915
|
updatedBlocks: /* @__PURE__ */ new Set()
|
|
916
916
|
};
|
|
917
917
|
},
|
|
918
|
-
apply(e,
|
|
919
|
-
if (
|
|
920
|
-
return
|
|
918
|
+
apply(e, o, t, r) {
|
|
919
|
+
if (o.currentTransactionOldBlockAttrs = {}, o.updatedBlocks.clear(), !e.docChanged || t.doc.eq(r.doc))
|
|
920
|
+
return o;
|
|
921
921
|
const s = {}, i = j(
|
|
922
|
-
|
|
922
|
+
t.doc,
|
|
923
923
|
(l) => l.attrs.id
|
|
924
924
|
), a = new Map(
|
|
925
925
|
i.map((l) => [l.node.attrs.id, l])
|
|
@@ -939,31 +939,31 @@ const go = k(
|
|
|
939
939
|
index: h.attrs.index,
|
|
940
940
|
level: h.attrs.level,
|
|
941
941
|
type: h.type.name,
|
|
942
|
-
depth:
|
|
942
|
+
depth: t.doc.resolve(u.pos).depth
|
|
943
943
|
};
|
|
944
|
-
s[l.node.attrs.id] = p,
|
|
944
|
+
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));
|
|
945
945
|
}
|
|
946
946
|
}
|
|
947
|
-
return
|
|
947
|
+
return o.prevTransactionOldBlockAttrs = s, o;
|
|
948
948
|
}
|
|
949
949
|
},
|
|
950
950
|
props: {
|
|
951
951
|
decorations(e) {
|
|
952
|
-
const
|
|
953
|
-
if (
|
|
952
|
+
const o = this.getState(e);
|
|
953
|
+
if (o.updatedBlocks.size === 0)
|
|
954
954
|
return;
|
|
955
|
-
const
|
|
955
|
+
const t = [];
|
|
956
956
|
return e.doc.descendants((r, s) => {
|
|
957
|
-
if (!r.attrs.id || !
|
|
957
|
+
if (!r.attrs.id || !o.updatedBlocks.has(r.attrs.id))
|
|
958
958
|
return;
|
|
959
|
-
const i =
|
|
959
|
+
const i = o.currentTransactionOldBlockAttrs[r.attrs.id], a = {};
|
|
960
960
|
for (const [l, u] of Object.entries(i))
|
|
961
|
-
a["data-prev-" +
|
|
961
|
+
a["data-prev-" + Ot[l]] = u || "none";
|
|
962
962
|
const c = A.node(s, s + r.nodeSize, {
|
|
963
963
|
...a
|
|
964
964
|
});
|
|
965
|
-
|
|
966
|
-
}), V.create(e.doc,
|
|
965
|
+
t.push(c);
|
|
966
|
+
}), V.create(e.doc, t);
|
|
967
967
|
}
|
|
968
968
|
}
|
|
969
969
|
})
|
|
@@ -971,35 +971,35 @@ const go = k(
|
|
|
971
971
|
};
|
|
972
972
|
});
|
|
973
973
|
function Se(n, e) {
|
|
974
|
-
var
|
|
975
|
-
for (; n && n.parentElement && n.parentElement !== e.dom && ((
|
|
974
|
+
var o, t;
|
|
975
|
+
for (; n && n.parentElement && n.parentElement !== e.dom && ((o = n.getAttribute) == null ? void 0 : o.call(n, "data-node-type")) !== "blockContainer"; )
|
|
976
976
|
n = n.parentElement;
|
|
977
|
-
if (((
|
|
977
|
+
if (((t = n.getAttribute) == null ? void 0 : t.call(n, "data-node-type")) === "blockContainer")
|
|
978
978
|
return { node: n, id: n.getAttribute("data-id") };
|
|
979
979
|
}
|
|
980
980
|
function At() {
|
|
981
981
|
const n = (e) => {
|
|
982
|
-
let
|
|
983
|
-
for (let
|
|
984
|
-
const r = e.children[
|
|
982
|
+
let o = e.children.length;
|
|
983
|
+
for (let t = 0; t < o; t++) {
|
|
984
|
+
const r = e.children[t];
|
|
985
985
|
if (r.type === "element" && (n(r), r.tagName === "u"))
|
|
986
986
|
if (r.children.length > 0) {
|
|
987
|
-
e.children.splice(
|
|
987
|
+
e.children.splice(t, 1, ...r.children);
|
|
988
988
|
const s = r.children.length - 1;
|
|
989
|
-
|
|
989
|
+
o += s, t += s;
|
|
990
990
|
} else
|
|
991
|
-
e.children.splice(
|
|
991
|
+
e.children.splice(t, 1), o--, t--;
|
|
992
992
|
}
|
|
993
993
|
};
|
|
994
994
|
return n;
|
|
995
995
|
}
|
|
996
996
|
function Mt() {
|
|
997
997
|
const n = (e) => {
|
|
998
|
-
var
|
|
998
|
+
var o;
|
|
999
999
|
if (e.children && "length" in e.children && e.children.length)
|
|
1000
|
-
for (let
|
|
1001
|
-
const r = e.children[
|
|
1002
|
-
r.type === "element" && r.tagName === "input" && ((
|
|
1000
|
+
for (let t = e.children.length - 1; t >= 0; t--) {
|
|
1001
|
+
const r = e.children[t], s = t + 1 < e.children.length ? e.children[t + 1] : void 0;
|
|
1002
|
+
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(
|
|
1003
1003
|
0,
|
|
1004
1004
|
0,
|
|
1005
1005
|
lt(document.createTextNode(" "))
|
|
@@ -1010,11 +1010,11 @@ function Mt() {
|
|
|
1010
1010
|
}
|
|
1011
1011
|
function Nt() {
|
|
1012
1012
|
return (n) => {
|
|
1013
|
-
ct(n, "element", (e,
|
|
1013
|
+
ct(n, "element", (e, o, t) => {
|
|
1014
1014
|
var r, s, i, a;
|
|
1015
|
-
if (
|
|
1015
|
+
if (t && e.tagName === "video") {
|
|
1016
1016
|
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"]) || "";
|
|
1017
|
-
|
|
1017
|
+
t.children[o] = {
|
|
1018
1018
|
type: "text",
|
|
1019
1019
|
value: ``
|
|
1020
1020
|
};
|
|
@@ -1024,52 +1024,52 @@ function Nt() {
|
|
|
1024
1024
|
}
|
|
1025
1025
|
function xe(n) {
|
|
1026
1026
|
return at().use(nt, { fragment: !0 }).use(Nt).use(At).use(Mt).use(rt).use(st).use(it, {
|
|
1027
|
-
handlers: { text: (
|
|
1027
|
+
handlers: { text: (o) => o.value }
|
|
1028
1028
|
}).processSync(n).value;
|
|
1029
1029
|
}
|
|
1030
|
-
function Bo(n, e,
|
|
1031
|
-
const s =
|
|
1030
|
+
function Bo(n, e, o, t) {
|
|
1031
|
+
const s = Ce(e, o).exportBlocks(n, t);
|
|
1032
1032
|
return xe(s);
|
|
1033
1033
|
}
|
|
1034
1034
|
function Rt(n) {
|
|
1035
1035
|
const e = [];
|
|
1036
|
-
return n.descendants((
|
|
1036
|
+
return n.descendants((o) => {
|
|
1037
1037
|
var r, s;
|
|
1038
|
-
const
|
|
1039
|
-
return
|
|
1040
|
-
e.push(L(i,
|
|
1041
|
-
}), !1) :
|
|
1038
|
+
const t = R(o);
|
|
1039
|
+
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) => {
|
|
1040
|
+
e.push(L(i, t));
|
|
1041
|
+
}), !1) : o.type.isInGroup("bnBlock") ? (e.push(L(o, t)), !1) : !0;
|
|
1042
1042
|
}), e;
|
|
1043
1043
|
}
|
|
1044
1044
|
class B extends N {
|
|
1045
|
-
constructor(
|
|
1046
|
-
super(
|
|
1045
|
+
constructor(o, t) {
|
|
1046
|
+
super(o, t);
|
|
1047
1047
|
b(this, "nodes");
|
|
1048
|
-
const r =
|
|
1049
|
-
this.nodes = [],
|
|
1048
|
+
const r = o.node();
|
|
1049
|
+
this.nodes = [], o.doc.nodesBetween(o.pos, t.pos, (s, i, a) => {
|
|
1050
1050
|
if (a !== null && a.eq(r))
|
|
1051
1051
|
return this.nodes.push(s), !1;
|
|
1052
1052
|
});
|
|
1053
1053
|
}
|
|
1054
|
-
static create(
|
|
1055
|
-
return new B(
|
|
1054
|
+
static create(o, t, r = t) {
|
|
1055
|
+
return new B(o.resolve(t), o.resolve(r));
|
|
1056
1056
|
}
|
|
1057
1057
|
content() {
|
|
1058
1058
|
return new ot(we.from(this.nodes), 0, 0);
|
|
1059
1059
|
}
|
|
1060
|
-
eq(
|
|
1061
|
-
if (!(
|
|
1060
|
+
eq(o) {
|
|
1061
|
+
if (!(o instanceof B) || this.nodes.length !== o.nodes.length || this.from !== o.from || this.to !== o.to)
|
|
1062
1062
|
return !1;
|
|
1063
|
-
for (let
|
|
1064
|
-
if (!this.nodes[
|
|
1063
|
+
for (let t = 0; t < this.nodes.length; t++)
|
|
1064
|
+
if (!this.nodes[t].eq(o.nodes[t]))
|
|
1065
1065
|
return !1;
|
|
1066
1066
|
return !0;
|
|
1067
1067
|
}
|
|
1068
|
-
map(
|
|
1069
|
-
const r =
|
|
1070
|
-
return s.deleted ? N.near(
|
|
1071
|
-
|
|
1072
|
-
|
|
1068
|
+
map(o, t) {
|
|
1069
|
+
const r = t.mapResult(this.from), s = t.mapResult(this.to);
|
|
1070
|
+
return s.deleted ? N.near(o.resolve(r.pos)) : r.deleted ? N.near(o.resolve(s.pos)) : new B(
|
|
1071
|
+
o.resolve(r.pos),
|
|
1072
|
+
o.resolve(s.pos)
|
|
1073
1073
|
);
|
|
1074
1074
|
}
|
|
1075
1075
|
toJSON() {
|
|
@@ -1079,29 +1079,29 @@ class B extends N {
|
|
|
1079
1079
|
N.jsonID("multiple-node", B);
|
|
1080
1080
|
let E;
|
|
1081
1081
|
function Lt(n, e) {
|
|
1082
|
-
let
|
|
1082
|
+
let o, t;
|
|
1083
1083
|
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);
|
|
1084
1084
|
if (r && s) {
|
|
1085
1085
|
const a = n.$from.start(i - 1), c = n.$to.end(i - 1);
|
|
1086
|
-
|
|
1086
|
+
o = e.resolve(a - 1).pos, t = e.resolve(c + 1).pos;
|
|
1087
1087
|
} else
|
|
1088
|
-
|
|
1089
|
-
return { from:
|
|
1088
|
+
o = n.from, t = n.to;
|
|
1089
|
+
return { from: o, to: t };
|
|
1090
1090
|
}
|
|
1091
|
-
function re(n, e,
|
|
1092
|
-
e ===
|
|
1093
|
-
const
|
|
1091
|
+
function re(n, e, o = e) {
|
|
1092
|
+
e === o && (o += n.state.doc.resolve(e + 1).node().nodeSize);
|
|
1093
|
+
const t = n.domAtPos(e).node.cloneNode(!0), r = n.domAtPos(e).node, s = (h, g) => Array.prototype.indexOf.call(h.children, g), i = s(
|
|
1094
1094
|
r,
|
|
1095
1095
|
// Expects from position to be just before the first selected block.
|
|
1096
1096
|
n.domAtPos(e + 1).node.parentElement
|
|
1097
1097
|
), a = s(
|
|
1098
1098
|
r,
|
|
1099
1099
|
// Expects to position to be just after the last selected block.
|
|
1100
|
-
n.domAtPos(
|
|
1100
|
+
n.domAtPos(o - 1).node.parentElement
|
|
1101
1101
|
);
|
|
1102
1102
|
for (let h = r.childElementCount - 1; h >= 0; h--)
|
|
1103
|
-
(h > a || h < i) &&
|
|
1104
|
-
Ee(n.root), E =
|
|
1103
|
+
(h > a || h < i) && t.removeChild(t.children[h]);
|
|
1104
|
+
Ee(n.root), E = t;
|
|
1105
1105
|
const c = E.getElementsByTagName("iframe");
|
|
1106
1106
|
for (let h = 0; h < c.length; h++) {
|
|
1107
1107
|
const g = c[h], m = g.parentElement;
|
|
@@ -1115,30 +1115,30 @@ function re(n, e, t = e) {
|
|
|
1115
1115
|
function Ee(n) {
|
|
1116
1116
|
E !== void 0 && (n instanceof ShadowRoot ? n.removeChild(E) : n.body.removeChild(E), E = void 0);
|
|
1117
1117
|
}
|
|
1118
|
-
function Vt(n, e,
|
|
1119
|
-
if (!n.dataTransfer ||
|
|
1118
|
+
function Vt(n, e, o) {
|
|
1119
|
+
if (!n.dataTransfer || o.headless)
|
|
1120
1120
|
return;
|
|
1121
|
-
const
|
|
1121
|
+
const t = o.prosemirrorView, r = me(e.id, t.state.doc);
|
|
1122
1122
|
if (!r)
|
|
1123
1123
|
throw new Error(`Block with ID ${e.id} not found`);
|
|
1124
1124
|
const s = r.posBeforeNode;
|
|
1125
1125
|
if (s != null) {
|
|
1126
|
-
const i =
|
|
1127
|
-
u && h ? (
|
|
1128
|
-
|
|
1129
|
-
), re(
|
|
1130
|
-
|
|
1131
|
-
), re(
|
|
1132
|
-
const g =
|
|
1126
|
+
const i = t.state.selection, a = t.state.doc, { from: c, to: l } = Lt(i, a), u = c <= s && s < l, h = i.$anchor.node() !== i.$head.node() || i instanceof B;
|
|
1127
|
+
u && h ? (t.dispatch(
|
|
1128
|
+
t.state.tr.setSelection(B.create(a, c, l))
|
|
1129
|
+
), re(t, c, l)) : (t.dispatch(
|
|
1130
|
+
t.state.tr.setSelection(le.create(t.state.doc, s))
|
|
1131
|
+
), re(t, s));
|
|
1132
|
+
const g = t.state.selection.content(), m = o.pmSchema, p = t.serializeForClipboard(g).dom.innerHTML, d = Ce(m, o), f = Rt(g.content), w = d.exportBlocks(f, {}), y = xe(w);
|
|
1133
1133
|
n.dataTransfer.clearData(), n.dataTransfer.setData("blocknote/html", p), n.dataTransfer.setData("text/html", w), n.dataTransfer.setData("text/plain", y), n.dataTransfer.effectAllowed = "move", n.dataTransfer.setDragImage(E, 0, 0);
|
|
1134
1134
|
}
|
|
1135
1135
|
}
|
|
1136
1136
|
const se = 250;
|
|
1137
|
-
function U(n, e,
|
|
1138
|
-
const
|
|
1139
|
-
for (const r of
|
|
1137
|
+
function U(n, e, o = !0) {
|
|
1138
|
+
const t = n.root.elementsFromPoint(e.left, e.top);
|
|
1139
|
+
for (const r of t)
|
|
1140
1140
|
if (n.dom.contains(r))
|
|
1141
|
-
return
|
|
1141
|
+
return o && r.closest("[data-node-type=columnList]") ? U(
|
|
1142
1142
|
n,
|
|
1143
1143
|
{
|
|
1144
1144
|
// TODO can we do better than this?
|
|
@@ -1152,14 +1152,14 @@ function U(n, e, t = !0) {
|
|
|
1152
1152
|
function Ht(n, e) {
|
|
1153
1153
|
if (!e.dom.firstChild)
|
|
1154
1154
|
return;
|
|
1155
|
-
const
|
|
1155
|
+
const o = e.dom.firstChild.getBoundingClientRect(), t = {
|
|
1156
1156
|
// Clamps the x position to the editor's bounding box.
|
|
1157
1157
|
left: Math.min(
|
|
1158
|
-
Math.max(
|
|
1159
|
-
|
|
1158
|
+
Math.max(o.left + 10, n.x),
|
|
1159
|
+
o.right - 10
|
|
1160
1160
|
),
|
|
1161
1161
|
top: n.y
|
|
1162
|
-
}, r = U(e,
|
|
1162
|
+
}, r = U(e, t);
|
|
1163
1163
|
if (!r)
|
|
1164
1164
|
return;
|
|
1165
1165
|
const s = r.node.getBoundingClientRect();
|
|
@@ -1173,7 +1173,7 @@ function Ht(n, e) {
|
|
|
1173
1173
|
);
|
|
1174
1174
|
}
|
|
1175
1175
|
class Ft {
|
|
1176
|
-
constructor(e,
|
|
1176
|
+
constructor(e, o, t) {
|
|
1177
1177
|
b(this, "state");
|
|
1178
1178
|
b(this, "emitUpdate");
|
|
1179
1179
|
b(this, "mousePos");
|
|
@@ -1184,7 +1184,7 @@ class Ft {
|
|
|
1184
1184
|
this.state = e, this.emitUpdate(this.state);
|
|
1185
1185
|
});
|
|
1186
1186
|
b(this, "updateStateFromMousePos", () => {
|
|
1187
|
-
var
|
|
1187
|
+
var t, r, s, i, a;
|
|
1188
1188
|
if (this.menuFrozen || !this.mousePos)
|
|
1189
1189
|
return;
|
|
1190
1190
|
const e = this.findClosestEditorElement({
|
|
@@ -1192,16 +1192,16 @@ class Ft {
|
|
|
1192
1192
|
clientY: this.mousePos.y
|
|
1193
1193
|
});
|
|
1194
1194
|
if ((e == null ? void 0 : e.element) !== this.pmView.dom || e.distance > se) {
|
|
1195
|
-
(
|
|
1195
|
+
(t = this.state) != null && t.show && (this.state.show = !1, this.updateState(this.state));
|
|
1196
1196
|
return;
|
|
1197
1197
|
}
|
|
1198
|
-
const
|
|
1199
|
-
if (!
|
|
1198
|
+
const o = Ht(this.mousePos, this.pmView);
|
|
1199
|
+
if (!o || !this.editor.isEditable) {
|
|
1200
1200
|
(r = this.state) != null && r.show && (this.state.show = !1, this.updateState(this.state));
|
|
1201
1201
|
return;
|
|
1202
1202
|
}
|
|
1203
|
-
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")) ===
|
|
1204
|
-
const c =
|
|
1203
|
+
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)) {
|
|
1204
|
+
const c = o.node.getBoundingClientRect(), l = o.node.closest("[data-node-type=column]");
|
|
1205
1205
|
this.state = {
|
|
1206
1206
|
show: !0,
|
|
1207
1207
|
referencePos: new DOMRect(
|
|
@@ -1242,12 +1242,12 @@ class Ft {
|
|
|
1242
1242
|
*/
|
|
1243
1243
|
b(this, "onDragStart", (e) => {
|
|
1244
1244
|
var i;
|
|
1245
|
-
const
|
|
1246
|
-
if (!
|
|
1245
|
+
const o = (i = e.dataTransfer) == null ? void 0 : i.getData("blocknote/html");
|
|
1246
|
+
if (!o || this.pmView.dragging)
|
|
1247
1247
|
return;
|
|
1248
|
-
const
|
|
1249
|
-
|
|
1250
|
-
const s = et.fromSchema(this.pmView.state.schema).parse(
|
|
1248
|
+
const t = document.createElement("div");
|
|
1249
|
+
t.innerHTML = o;
|
|
1250
|
+
const s = et.fromSchema(this.pmView.state.schema).parse(t, {
|
|
1251
1251
|
topNode: this.pmView.state.schema.nodes.blockGroup.create()
|
|
1252
1252
|
});
|
|
1253
1253
|
this.pmView.dragging = {
|
|
@@ -1259,17 +1259,17 @@ class Ft {
|
|
|
1259
1259
|
* Finds the closest editor visually to the given coordinates
|
|
1260
1260
|
*/
|
|
1261
1261
|
b(this, "findClosestEditorElement", (e) => {
|
|
1262
|
-
const
|
|
1263
|
-
if (
|
|
1262
|
+
const o = Array.from(this.pmView.root.querySelectorAll(".bn-editor"));
|
|
1263
|
+
if (o.length === 0)
|
|
1264
1264
|
return null;
|
|
1265
|
-
let
|
|
1266
|
-
return
|
|
1265
|
+
let t = o[0], r = Number.MAX_VALUE;
|
|
1266
|
+
return o.forEach((s) => {
|
|
1267
1267
|
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(
|
|
1268
1268
|
Math.pow(a, 2) + Math.pow(c, 2)
|
|
1269
1269
|
);
|
|
1270
|
-
l < r && (r = l,
|
|
1270
|
+
l < r && (r = l, t = s);
|
|
1271
1271
|
}), {
|
|
1272
|
-
element:
|
|
1272
|
+
element: t,
|
|
1273
1273
|
distance: r
|
|
1274
1274
|
};
|
|
1275
1275
|
});
|
|
@@ -1287,7 +1287,8 @@ class Ft {
|
|
|
1287
1287
|
* 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
|
|
1288
1288
|
*/
|
|
1289
1289
|
b(this, "onDragOver", (e) => {
|
|
1290
|
-
|
|
1290
|
+
var r;
|
|
1291
|
+
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)))
|
|
1291
1292
|
return;
|
|
1292
1293
|
const t = this.getDragEventContext(e);
|
|
1293
1294
|
if (!t || !t.isDropPoint) {
|
|
@@ -1312,16 +1313,18 @@ class Ft {
|
|
|
1312
1313
|
* - Whether the drop event is within the bounds of the current editor instance
|
|
1313
1314
|
*/
|
|
1314
1315
|
b(this, "getDragEventContext", (e) => {
|
|
1315
|
-
var
|
|
1316
|
-
|
|
1317
|
-
if (!s || s.distance > se)
|
|
1316
|
+
var l, u;
|
|
1317
|
+
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)))
|
|
1318
1318
|
return;
|
|
1319
|
-
const
|
|
1320
|
-
if (!
|
|
1319
|
+
const t = !((u = e.dataTransfer) != null && u.types.includes("blocknote/html")) && !!this.pmView.dragging, r = !!this.isDragOrigin, s = t || r, i = this.findClosestEditorElement(e);
|
|
1320
|
+
if (!i || i.distance > se)
|
|
1321
|
+
return;
|
|
1322
|
+
const a = i.element === this.pmView.dom, c = a && i.distance === 0;
|
|
1323
|
+
if (!(!a && !s))
|
|
1321
1324
|
return {
|
|
1322
|
-
isDropPoint:
|
|
1323
|
-
isDropWithinEditorBounds:
|
|
1324
|
-
isDragOrigin:
|
|
1325
|
+
isDropPoint: a,
|
|
1326
|
+
isDropWithinEditorBounds: c,
|
|
1327
|
+
isDragOrigin: s
|
|
1325
1328
|
};
|
|
1326
1329
|
});
|
|
1327
1330
|
/**
|
|
@@ -1338,15 +1341,16 @@ class Ft {
|
|
|
1338
1341
|
* - Delete the dragged content from our editor after a delay
|
|
1339
1342
|
*/
|
|
1340
1343
|
b(this, "onDrop", (e) => {
|
|
1341
|
-
|
|
1344
|
+
var a;
|
|
1345
|
+
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)))
|
|
1342
1346
|
return;
|
|
1343
1347
|
const t = this.getDragEventContext(e);
|
|
1344
1348
|
if (!t) {
|
|
1345
1349
|
this.closeDropCursor();
|
|
1346
1350
|
return;
|
|
1347
1351
|
}
|
|
1348
|
-
const { isDropPoint:
|
|
1349
|
-
if (!
|
|
1352
|
+
const { isDropPoint: r, isDropWithinEditorBounds: s, isDragOrigin: i } = t;
|
|
1353
|
+
if (!s && r && this.dispatchSyntheticEvent(e), r) {
|
|
1350
1354
|
if (this.pmView.dragging)
|
|
1351
1355
|
return;
|
|
1352
1356
|
this.pmView.dispatch(
|
|
@@ -1358,7 +1362,7 @@ class Ft {
|
|
|
1358
1362
|
)
|
|
1359
1363
|
);
|
|
1360
1364
|
return;
|
|
1361
|
-
} else if (
|
|
1365
|
+
} else if (i) {
|
|
1362
1366
|
setTimeout(
|
|
1363
1367
|
() => this.pmView.dispatch(this.pmView.state.tr.deleteSelection()),
|
|
1364
1368
|
0
|
|
@@ -1370,18 +1374,18 @@ class Ft {
|
|
|
1370
1374
|
e.synthetic || (this.pmView.dragging = null);
|
|
1371
1375
|
});
|
|
1372
1376
|
b(this, "onKeyDown", (e) => {
|
|
1373
|
-
var
|
|
1374
|
-
(
|
|
1377
|
+
var o;
|
|
1378
|
+
(o = this.state) != null && o.show && this.editor.isFocused() && (this.state.show = !1, this.emitUpdate(this.state));
|
|
1375
1379
|
});
|
|
1376
1380
|
b(this, "onMouseMove", (e) => {
|
|
1377
1381
|
var s;
|
|
1378
1382
|
if (this.menuFrozen)
|
|
1379
1383
|
return;
|
|
1380
1384
|
this.mousePos = { x: e.clientX, y: e.clientY };
|
|
1381
|
-
const
|
|
1385
|
+
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;
|
|
1382
1386
|
if (
|
|
1383
1387
|
// Cursor is within the editor area
|
|
1384
|
-
|
|
1388
|
+
t && // An element is hovered
|
|
1385
1389
|
e && e.target && // Element is outside the editor
|
|
1386
1390
|
!(r === e.target || r.contains(e.target))
|
|
1387
1391
|
) {
|
|
@@ -1390,10 +1394,10 @@ class Ft {
|
|
|
1390
1394
|
}
|
|
1391
1395
|
this.updateStateFromMousePos();
|
|
1392
1396
|
});
|
|
1393
|
-
this.editor = e, this.pmView =
|
|
1397
|
+
this.editor = e, this.pmView = o, this.emitUpdate = () => {
|
|
1394
1398
|
if (!this.state)
|
|
1395
1399
|
throw new Error("Attempting to update uninitialized side menu");
|
|
1396
|
-
|
|
1400
|
+
t(this.state);
|
|
1397
1401
|
}, this.pmView.root.addEventListener(
|
|
1398
1402
|
"dragstart",
|
|
1399
1403
|
this.onDragStart
|
|
@@ -1419,14 +1423,14 @@ class Ft {
|
|
|
1419
1423
|
);
|
|
1420
1424
|
}
|
|
1421
1425
|
dispatchSyntheticEvent(e) {
|
|
1422
|
-
const
|
|
1423
|
-
|
|
1424
|
-
Math.max(e.clientX,
|
|
1425
|
-
|
|
1426
|
-
),
|
|
1427
|
-
Math.max(e.clientY,
|
|
1428
|
-
|
|
1429
|
-
),
|
|
1426
|
+
const o = new Event(e.type, e), t = this.pmView.dom.firstChild.getBoundingClientRect();
|
|
1427
|
+
o.clientX = e.clientX, o.clientY = e.clientY, o.clientX = Math.min(
|
|
1428
|
+
Math.max(e.clientX, t.left),
|
|
1429
|
+
t.left + t.width
|
|
1430
|
+
), o.clientY = Math.min(
|
|
1431
|
+
Math.max(e.clientY, t.top),
|
|
1432
|
+
t.top + t.height
|
|
1433
|
+
), o.dataTransfer = e.dataTransfer, o.preventDefault = () => e.preventDefault(), o.synthetic = !0, this.pmView.dom.dispatchEvent(o);
|
|
1430
1434
|
}
|
|
1431
1435
|
// Needed in cases where the editor state updates without the mouse cursor
|
|
1432
1436
|
// moving, as some state updates can require a side menu update. For example,
|
|
@@ -1435,9 +1439,9 @@ class Ft {
|
|
|
1435
1439
|
// allowing the user to click the button again without moving the cursor. This
|
|
1436
1440
|
// would otherwise not update the side menu, and so clicking the button again
|
|
1437
1441
|
// would attempt to remove the same block again, causing an error.
|
|
1438
|
-
update(e,
|
|
1442
|
+
update(e, o) {
|
|
1439
1443
|
var r;
|
|
1440
|
-
!
|
|
1444
|
+
!o.doc.eq(this.pmView.state.doc) && ((r = this.state) != null && r.show) && this.updateStateFromMousePos();
|
|
1441
1445
|
}
|
|
1442
1446
|
destroy() {
|
|
1443
1447
|
var e;
|
|
@@ -1466,27 +1470,27 @@ class Ft {
|
|
|
1466
1470
|
);
|
|
1467
1471
|
}
|
|
1468
1472
|
}
|
|
1469
|
-
const $t = new pe("SideMenuPlugin"), To =
|
|
1473
|
+
const $t = new pe("SideMenuPlugin"), To = C(({ editor: n }) => {
|
|
1470
1474
|
let e;
|
|
1471
|
-
const
|
|
1475
|
+
const o = H(
|
|
1472
1476
|
void 0
|
|
1473
1477
|
);
|
|
1474
1478
|
return {
|
|
1475
1479
|
key: "sideMenu",
|
|
1476
|
-
store:
|
|
1480
|
+
store: o,
|
|
1477
1481
|
prosemirrorPlugins: [
|
|
1478
1482
|
new fe({
|
|
1479
1483
|
key: $t,
|
|
1480
|
-
view: (
|
|
1481
|
-
|
|
1484
|
+
view: (t) => (e = new Ft(n, t, (r) => {
|
|
1485
|
+
o.setState({ ...r });
|
|
1482
1486
|
}), e)
|
|
1483
1487
|
})
|
|
1484
1488
|
],
|
|
1485
1489
|
/**
|
|
1486
1490
|
* Handles drag & drop events for blocks.
|
|
1487
1491
|
*/
|
|
1488
|
-
blockDragStart(
|
|
1489
|
-
e && (e.isDragOrigin = !0), Vt(
|
|
1492
|
+
blockDragStart(t, r) {
|
|
1493
|
+
e && (e.isDragOrigin = !0), Vt(t, r, n);
|
|
1490
1494
|
},
|
|
1491
1495
|
/**
|
|
1492
1496
|
* Handles drag & drop events for blocks.
|
|
@@ -1527,10 +1531,10 @@ function _t(n) {
|
|
|
1527
1531
|
for (; e && e.nodeName !== "TD" && e.nodeName !== "TH" && !e.classList.contains("tableWrapper"); ) {
|
|
1528
1532
|
if (e.classList.contains("ProseMirror"))
|
|
1529
1533
|
return;
|
|
1530
|
-
const
|
|
1531
|
-
if (!
|
|
1534
|
+
const o = e.parentNode;
|
|
1535
|
+
if (!o || !(o instanceof Element))
|
|
1532
1536
|
return;
|
|
1533
|
-
e =
|
|
1537
|
+
e = o;
|
|
1534
1538
|
}
|
|
1535
1539
|
return e.nodeName === "TD" || e.nodeName === "TH" ? {
|
|
1536
1540
|
type: "cell",
|
|
@@ -1543,12 +1547,12 @@ function _t(n) {
|
|
|
1543
1547
|
};
|
|
1544
1548
|
}
|
|
1545
1549
|
function zt(n, e) {
|
|
1546
|
-
const
|
|
1547
|
-
for (let
|
|
1548
|
-
t
|
|
1550
|
+
const o = e.querySelectorAll(n);
|
|
1551
|
+
for (let t = 0; t < o.length; t++)
|
|
1552
|
+
o[t].style.visibility = "hidden";
|
|
1549
1553
|
}
|
|
1550
1554
|
class Kt {
|
|
1551
|
-
constructor(e,
|
|
1555
|
+
constructor(e, o, t) {
|
|
1552
1556
|
b(this, "state");
|
|
1553
1557
|
b(this, "emitUpdate");
|
|
1554
1558
|
b(this, "tableId");
|
|
@@ -1567,18 +1571,18 @@ class Kt {
|
|
|
1567
1571
|
var l, u, h, g, m, p, d, f;
|
|
1568
1572
|
if (this.menuFrozen || this.mouseState === "selecting" || !(e.target instanceof Element) || !this.pmView.dom.contains(e.target))
|
|
1569
1573
|
return;
|
|
1570
|
-
const
|
|
1571
|
-
if ((
|
|
1574
|
+
const o = _t(e.target);
|
|
1575
|
+
if ((o == null ? void 0 : o.type) === "cell" && this.mouseState === "down" && !((l = this.state) != null && l.draggingState)) {
|
|
1572
1576
|
this.mouseState = "selecting", (u = this.state) != null && u.show && (this.state.show = !1, this.state.showAddOrRemoveRowsButton = !1, this.state.showAddOrRemoveColumnsButton = !1, this.emitUpdate());
|
|
1573
1577
|
return;
|
|
1574
1578
|
}
|
|
1575
|
-
if (!
|
|
1579
|
+
if (!o || !this.editor.isEditable) {
|
|
1576
1580
|
(h = this.state) != null && h.show && (this.state.show = !1, this.state.showAddOrRemoveRowsButton = !1, this.state.showAddOrRemoveColumnsButton = !1, this.emitUpdate());
|
|
1577
1581
|
return;
|
|
1578
1582
|
}
|
|
1579
|
-
if (!
|
|
1583
|
+
if (!o.tbodyNode)
|
|
1580
1584
|
return;
|
|
1581
|
-
const
|
|
1585
|
+
const t = o.tbodyNode.getBoundingClientRect(), r = Se(o.domNode, this.pmView);
|
|
1582
1586
|
if (!r)
|
|
1583
1587
|
return;
|
|
1584
1588
|
this.tableElement = r.node;
|
|
@@ -1598,39 +1602,39 @@ class Kt {
|
|
|
1598
1602
|
if (Ue(this.editor, "table") && (this.tablePos = i.posBeforeNode + 1, s = a), !s)
|
|
1599
1603
|
return;
|
|
1600
1604
|
this.tableId = r.id;
|
|
1601
|
-
const c = (g =
|
|
1602
|
-
if ((
|
|
1603
|
-
const w = e.clientY >=
|
|
1604
|
-
e.clientY <
|
|
1605
|
+
const c = (g = o.domNode.closest(".tableWrapper")) == null ? void 0 : g.querySelector(".table-widgets-container");
|
|
1606
|
+
if ((o == null ? void 0 : o.type) === "wrapper") {
|
|
1607
|
+
const w = e.clientY >= t.bottom - 1 && // -1 to account for fractions of pixels in "bottom"
|
|
1608
|
+
e.clientY < t.bottom + 20, y = e.clientX >= t.right - 1 && e.clientX < t.right + 20, v = (
|
|
1605
1609
|
// always hide handles when the actively hovered table changed
|
|
1606
1610
|
((m = this.state) == null ? void 0 : m.block.id) !== s.id || // make sure we don't hide existing handles (keep col / row index) when
|
|
1607
1611
|
// we're hovering just above or to the right of a table
|
|
1608
|
-
e.clientX >
|
|
1612
|
+
e.clientX > t.right || e.clientY > t.bottom
|
|
1609
1613
|
);
|
|
1610
1614
|
this.state = {
|
|
1611
1615
|
...this.state,
|
|
1612
1616
|
show: !0,
|
|
1613
1617
|
showAddOrRemoveRowsButton: w,
|
|
1614
1618
|
showAddOrRemoveColumnsButton: y,
|
|
1615
|
-
referencePosTable:
|
|
1619
|
+
referencePosTable: t,
|
|
1616
1620
|
block: s,
|
|
1617
1621
|
widgetContainer: c,
|
|
1618
|
-
colIndex:
|
|
1619
|
-
rowIndex:
|
|
1620
|
-
referencePosCell:
|
|
1622
|
+
colIndex: v || (p = this.state) == null ? void 0 : p.colIndex,
|
|
1623
|
+
rowIndex: v || (d = this.state) == null ? void 0 : d.rowIndex,
|
|
1624
|
+
referencePosCell: v || (f = this.state) == null ? void 0 : f.referencePosCell
|
|
1621
1625
|
};
|
|
1622
1626
|
} else {
|
|
1623
|
-
const w = M(
|
|
1627
|
+
const w = M(o.domNode), y = M(o.domNode.parentElement), v = o.domNode.getBoundingClientRect();
|
|
1624
1628
|
if (this.state !== void 0 && this.state.show && this.tableId === r.id && this.state.rowIndex === y && this.state.colIndex === w)
|
|
1625
1629
|
return;
|
|
1626
1630
|
this.state = {
|
|
1627
1631
|
show: !0,
|
|
1628
1632
|
showAddOrRemoveColumnsButton: w === s.content.rows[0].cells.length - 1,
|
|
1629
1633
|
showAddOrRemoveRowsButton: y === s.content.rows.length - 1,
|
|
1630
|
-
referencePosTable:
|
|
1634
|
+
referencePosTable: t,
|
|
1631
1635
|
block: s,
|
|
1632
1636
|
draggingState: void 0,
|
|
1633
|
-
referencePosCell:
|
|
1637
|
+
referencePosCell: v,
|
|
1634
1638
|
colIndex: w,
|
|
1635
1639
|
rowIndex: y,
|
|
1636
1640
|
widgetContainer: c
|
|
@@ -1646,7 +1650,7 @@ class Kt {
|
|
|
1646
1650
|
".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline",
|
|
1647
1651
|
this.pmView.root
|
|
1648
1652
|
);
|
|
1649
|
-
const
|
|
1653
|
+
const o = {
|
|
1650
1654
|
left: Math.min(
|
|
1651
1655
|
Math.max(e.clientX, this.state.referencePosTable.left + 1),
|
|
1652
1656
|
this.state.referencePosTable.right - 1
|
|
@@ -1655,17 +1659,17 @@ class Kt {
|
|
|
1655
1659
|
Math.max(e.clientY, this.state.referencePosTable.top + 1),
|
|
1656
1660
|
this.state.referencePosTable.bottom - 1
|
|
1657
1661
|
)
|
|
1658
|
-
},
|
|
1662
|
+
}, t = this.pmView.root.elementsFromPoint(o.left, o.top).filter(
|
|
1659
1663
|
(m) => m.tagName === "TD" || m.tagName === "TH"
|
|
1660
1664
|
);
|
|
1661
|
-
if (
|
|
1665
|
+
if (t.length === 0)
|
|
1662
1666
|
return;
|
|
1663
|
-
const r =
|
|
1667
|
+
const r = t[0];
|
|
1664
1668
|
let s = !1;
|
|
1665
1669
|
const i = M(r.parentElement), a = M(r), c = this.state.draggingState.draggedCellOrientation === "row" ? this.state.rowIndex : this.state.colIndex, u = (this.state.draggingState.draggedCellOrientation === "row" ? i : a) !== c;
|
|
1666
1670
|
(this.state.rowIndex !== i || this.state.colIndex !== a) && (this.state.rowIndex = i, this.state.colIndex = a, this.state.referencePosCell = r.getBoundingClientRect(), s = !0);
|
|
1667
|
-
const h = this.state.draggingState.draggedCellOrientation === "row" ?
|
|
1668
|
-
this.state.draggingState.mousePos !== h && (this.state.draggingState.mousePos = h, s = !0), s && this.emitUpdate(), u && this.editor.transact((m) => m.setMeta(
|
|
1671
|
+
const h = this.state.draggingState.draggedCellOrientation === "row" ? o.top : o.left;
|
|
1672
|
+
this.state.draggingState.mousePos !== h && (this.state.draggingState.mousePos = h, s = !0), s && this.emitUpdate(), u && this.editor.transact((m) => m.setMeta(O, !0));
|
|
1669
1673
|
});
|
|
1670
1674
|
b(this, "dropHandler", (e) => {
|
|
1671
1675
|
if (this.mouseState = "up", this.state === void 0 || this.state.draggingState === void 0)
|
|
@@ -1675,17 +1679,17 @@ class Kt {
|
|
|
1675
1679
|
"Attempted to drop table row or column, but no table block was hovered prior."
|
|
1676
1680
|
);
|
|
1677
1681
|
e.preventDefault();
|
|
1678
|
-
const { draggingState:
|
|
1679
|
-
if (
|
|
1682
|
+
const { draggingState: o, colIndex: t, rowIndex: r } = this.state, s = this.state.block.content.columnWidths;
|
|
1683
|
+
if (o.draggedCellOrientation === "row") {
|
|
1680
1684
|
if (!de(
|
|
1681
1685
|
this.state.block,
|
|
1682
|
-
|
|
1686
|
+
o.originalIndex,
|
|
1683
1687
|
r
|
|
1684
1688
|
))
|
|
1685
1689
|
return !1;
|
|
1686
1690
|
const i = Re(
|
|
1687
1691
|
this.state.block,
|
|
1688
|
-
|
|
1692
|
+
o.originalIndex,
|
|
1689
1693
|
r
|
|
1690
1694
|
);
|
|
1691
1695
|
this.editor.updateBlock(this.state.block, {
|
|
@@ -1698,16 +1702,16 @@ class Kt {
|
|
|
1698
1702
|
} else {
|
|
1699
1703
|
if (!ue(
|
|
1700
1704
|
this.state.block,
|
|
1701
|
-
|
|
1702
|
-
|
|
1705
|
+
o.originalIndex,
|
|
1706
|
+
t
|
|
1703
1707
|
))
|
|
1704
1708
|
return !1;
|
|
1705
1709
|
const i = Le(
|
|
1706
1710
|
this.state.block,
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
), [a] = s.splice(
|
|
1710
|
-
s.splice(
|
|
1711
|
+
o.originalIndex,
|
|
1712
|
+
t
|
|
1713
|
+
), [a] = s.splice(o.originalIndex, 1);
|
|
1714
|
+
s.splice(t, 0, a), this.editor.updateBlock(this.state.block, {
|
|
1711
1715
|
type: "table",
|
|
1712
1716
|
content: {
|
|
1713
1717
|
...this.state.block.content,
|
|
@@ -1718,14 +1722,14 @@ class Kt {
|
|
|
1718
1722
|
}
|
|
1719
1723
|
return this.editor.setTextCursorPosition(this.state.block.id), !0;
|
|
1720
1724
|
});
|
|
1721
|
-
this.editor = e, this.pmView =
|
|
1725
|
+
this.editor = e, this.pmView = o, this.emitUpdate = () => {
|
|
1722
1726
|
if (!this.state)
|
|
1723
1727
|
throw new Error("Attempting to update uninitialized image toolbar");
|
|
1724
|
-
|
|
1725
|
-
},
|
|
1728
|
+
t(this.state);
|
|
1729
|
+
}, o.dom.addEventListener("mousemove", this.mouseMoveHandler), o.dom.addEventListener("mousedown", this.viewMousedownHandler), window.addEventListener("mouseup", this.mouseUpHandler), o.root.addEventListener(
|
|
1726
1730
|
"dragover",
|
|
1727
1731
|
this.dragOverHandler
|
|
1728
|
-
),
|
|
1732
|
+
), o.root.addEventListener(
|
|
1729
1733
|
"drop",
|
|
1730
1734
|
this.dropHandler
|
|
1731
1735
|
);
|
|
@@ -1741,20 +1745,20 @@ class Kt {
|
|
|
1741
1745
|
this.state.show = !1, this.state.showAddOrRemoveRowsButton = !1, this.state.showAddOrRemoveColumnsButton = !1, this.emitUpdate();
|
|
1742
1746
|
return;
|
|
1743
1747
|
}
|
|
1744
|
-
const { height: e, width:
|
|
1748
|
+
const { height: e, width: o } = Ve(
|
|
1745
1749
|
this.state.block
|
|
1746
1750
|
);
|
|
1747
|
-
this.state.rowIndex !== void 0 && this.state.colIndex !== void 0 && (this.state.rowIndex >= e && (this.state.rowIndex = e - 1), this.state.colIndex >=
|
|
1748
|
-
const
|
|
1749
|
-
if (!
|
|
1751
|
+
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));
|
|
1752
|
+
const t = this.tableElement.querySelector("tbody");
|
|
1753
|
+
if (!t)
|
|
1750
1754
|
throw new Error(
|
|
1751
1755
|
"Table block does not contain a 'tbody' HTML element. This should never happen."
|
|
1752
1756
|
);
|
|
1753
1757
|
if (this.state.rowIndex !== void 0 && this.state.colIndex !== void 0) {
|
|
1754
|
-
const i =
|
|
1758
|
+
const i = t.children[this.state.rowIndex].children[this.state.colIndex];
|
|
1755
1759
|
i ? this.state.referencePosCell = i.getBoundingClientRect() : (this.state.rowIndex = void 0, this.state.colIndex = void 0);
|
|
1756
1760
|
}
|
|
1757
|
-
this.state.referencePosTable =
|
|
1761
|
+
this.state.referencePosTable = t.getBoundingClientRect(), this.emitUpdate();
|
|
1758
1762
|
}
|
|
1759
1763
|
destroy() {
|
|
1760
1764
|
this.pmView.dom.removeEventListener("mousemove", this.mouseMoveHandler), window.removeEventListener("mouseup", this.mouseUpHandler), this.pmView.dom.removeEventListener("mousedown", this.viewMousedownHandler), this.pmView.root.removeEventListener(
|
|
@@ -1766,17 +1770,17 @@ class Kt {
|
|
|
1766
1770
|
);
|
|
1767
1771
|
}
|
|
1768
1772
|
}
|
|
1769
|
-
const
|
|
1773
|
+
const O = new P("TableHandlesPlugin"), Po = C(({ editor: n }) => {
|
|
1770
1774
|
let e;
|
|
1771
|
-
const
|
|
1775
|
+
const o = H(void 0);
|
|
1772
1776
|
return {
|
|
1773
1777
|
key: "tableHandles",
|
|
1774
|
-
store:
|
|
1778
|
+
store: o,
|
|
1775
1779
|
prosemirrorPlugins: [
|
|
1776
1780
|
new T({
|
|
1777
|
-
key:
|
|
1778
|
-
view: (
|
|
1779
|
-
|
|
1781
|
+
key: O,
|
|
1782
|
+
view: (t) => (e = new Kt(n, t, (r) => {
|
|
1783
|
+
o.setState(
|
|
1780
1784
|
r.block ? {
|
|
1781
1785
|
...r,
|
|
1782
1786
|
draggingState: r.draggingState ? { ...r.draggingState } : void 0
|
|
@@ -1786,7 +1790,7 @@ const D = new P("TableHandlesPlugin"), Po = k(({ editor: n }) => {
|
|
|
1786
1790
|
// We use decorations to render the drop cursor when dragging a table row
|
|
1787
1791
|
// or column. The decorations are updated in the `dragOverHandler` method.
|
|
1788
1792
|
props: {
|
|
1789
|
-
decorations: (
|
|
1793
|
+
decorations: (t) => {
|
|
1790
1794
|
if (e === void 0 || e.state === void 0 || e.state.draggingState === void 0 || e.tablePos === void 0)
|
|
1791
1795
|
return;
|
|
1792
1796
|
const r = e.state.draggingState.draggedCellOrientation === "row" ? e.state.rowIndex : e.state.colIndex;
|
|
@@ -1794,15 +1798,15 @@ const D = new P("TableHandlesPlugin"), Po = k(({ editor: n }) => {
|
|
|
1794
1798
|
return;
|
|
1795
1799
|
const s = [], { block: i, draggingState: a } = e.state, { originalIndex: c, draggedCellOrientation: l } = a;
|
|
1796
1800
|
if (r === c || !i || l === "row" && !de(i, c, r) || l === "col" && !ue(i, c, r))
|
|
1797
|
-
return V.create(
|
|
1798
|
-
const u =
|
|
1801
|
+
return V.create(t.doc, s);
|
|
1802
|
+
const u = t.doc.resolve(e.tablePos + 1);
|
|
1799
1803
|
return e.state.draggingState.draggedCellOrientation === "row" ? G(
|
|
1800
1804
|
e.state.block,
|
|
1801
1805
|
r
|
|
1802
1806
|
).forEach(({ row: g, col: m }) => {
|
|
1803
|
-
const p =
|
|
1807
|
+
const p = t.doc.resolve(
|
|
1804
1808
|
u.posAtIndex(g) + 1
|
|
1805
|
-
), d =
|
|
1809
|
+
), d = t.doc.resolve(
|
|
1806
1810
|
p.posAtIndex(m) + 1
|
|
1807
1811
|
), f = d.node(), w = d.pos + (r > c ? f.nodeSize - 2 : 0);
|
|
1808
1812
|
s.push(
|
|
@@ -1816,9 +1820,9 @@ const D = new P("TableHandlesPlugin"), Po = k(({ editor: n }) => {
|
|
|
1816
1820
|
e.state.block,
|
|
1817
1821
|
r
|
|
1818
1822
|
).forEach(({ row: g, col: m }) => {
|
|
1819
|
-
const p =
|
|
1823
|
+
const p = t.doc.resolve(
|
|
1820
1824
|
u.posAtIndex(g) + 1
|
|
1821
|
-
), d =
|
|
1825
|
+
), d = t.doc.resolve(
|
|
1822
1826
|
p.posAtIndex(m) + 1
|
|
1823
1827
|
), f = d.node(), w = d.pos + (r > c ? f.nodeSize - 2 : 0);
|
|
1824
1828
|
s.push(
|
|
@@ -1828,7 +1832,7 @@ const D = new P("TableHandlesPlugin"), Po = k(({ editor: n }) => {
|
|
|
1828
1832
|
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;
|
|
1829
1833
|
})
|
|
1830
1834
|
);
|
|
1831
|
-
}), V.create(
|
|
1835
|
+
}), V.create(t.doc, s);
|
|
1832
1836
|
}
|
|
1833
1837
|
}
|
|
1834
1838
|
})
|
|
@@ -1837,7 +1841,7 @@ const D = new P("TableHandlesPlugin"), Po = k(({ editor: n }) => {
|
|
|
1837
1841
|
* Callback that should be set on the `dragStart` event for whichever element
|
|
1838
1842
|
* is used as the column drag handle.
|
|
1839
1843
|
*/
|
|
1840
|
-
colDragStart(
|
|
1844
|
+
colDragStart(t) {
|
|
1841
1845
|
if (e === void 0 || e.state === void 0 || e.state.colIndex === void 0)
|
|
1842
1846
|
throw new Error(
|
|
1843
1847
|
"Attempted to drag table column, but no table block was hovered prior."
|
|
@@ -1845,21 +1849,21 @@ const D = new P("TableHandlesPlugin"), Po = k(({ editor: n }) => {
|
|
|
1845
1849
|
e.state.draggingState = {
|
|
1846
1850
|
draggedCellOrientation: "col",
|
|
1847
1851
|
originalIndex: e.state.colIndex,
|
|
1848
|
-
mousePos:
|
|
1852
|
+
mousePos: t.clientX
|
|
1849
1853
|
}, e.emitUpdate(), n.transact(
|
|
1850
|
-
(r) => r.setMeta(
|
|
1854
|
+
(r) => r.setMeta(O, {
|
|
1851
1855
|
draggedCellOrientation: e.state.draggingState.draggedCellOrientation,
|
|
1852
1856
|
originalIndex: e.state.colIndex,
|
|
1853
1857
|
newIndex: e.state.colIndex,
|
|
1854
1858
|
tablePos: e.tablePos
|
|
1855
1859
|
})
|
|
1856
|
-
), !n.headless && (ie(n.prosemirrorView.root),
|
|
1860
|
+
), !n.headless && (ie(n.prosemirrorView.root), t.dataTransfer.setDragImage(S, 0, 0), t.dataTransfer.effectAllowed = "move");
|
|
1857
1861
|
},
|
|
1858
1862
|
/**
|
|
1859
1863
|
* Callback that should be set on the `dragStart` event for whichever element
|
|
1860
1864
|
* is used as the row drag handle.
|
|
1861
1865
|
*/
|
|
1862
|
-
rowDragStart(
|
|
1866
|
+
rowDragStart(t) {
|
|
1863
1867
|
if (e.state === void 0 || e.state.rowIndex === void 0)
|
|
1864
1868
|
throw new Error(
|
|
1865
1869
|
"Attempted to drag table row, but no table block was hovered prior."
|
|
@@ -1867,15 +1871,15 @@ const D = new P("TableHandlesPlugin"), Po = k(({ editor: n }) => {
|
|
|
1867
1871
|
e.state.draggingState = {
|
|
1868
1872
|
draggedCellOrientation: "row",
|
|
1869
1873
|
originalIndex: e.state.rowIndex,
|
|
1870
|
-
mousePos:
|
|
1874
|
+
mousePos: t.clientY
|
|
1871
1875
|
}, e.emitUpdate(), n.transact(
|
|
1872
|
-
(r) => r.setMeta(
|
|
1876
|
+
(r) => r.setMeta(O, {
|
|
1873
1877
|
draggedCellOrientation: e.state.draggingState.draggedCellOrientation,
|
|
1874
1878
|
originalIndex: e.state.rowIndex,
|
|
1875
1879
|
newIndex: e.state.rowIndex,
|
|
1876
1880
|
tablePos: e.tablePos
|
|
1877
1881
|
})
|
|
1878
|
-
), !n.headless && (ie(n.prosemirrorView.root),
|
|
1882
|
+
), !n.headless && (ie(n.prosemirrorView.root), t.dataTransfer.setDragImage(S, 0, 0), t.dataTransfer.effectAllowed = "copyMove");
|
|
1879
1883
|
},
|
|
1880
1884
|
/**
|
|
1881
1885
|
* Callback that should be set on the `dragEnd` event for both the element
|
|
@@ -1886,7 +1890,7 @@ const D = new P("TableHandlesPlugin"), Po = k(({ editor: n }) => {
|
|
|
1886
1890
|
throw new Error(
|
|
1887
1891
|
"Attempted to drag table row, but no table block was hovered prior."
|
|
1888
1892
|
);
|
|
1889
|
-
e.state.draggingState = void 0, e.emitUpdate(), n.transact((
|
|
1893
|
+
e.state.draggingState = void 0, e.emitUpdate(), n.transact((t) => t.setMeta(O, null)), !n.headless && Ut(n.prosemirrorView.root);
|
|
1890
1894
|
},
|
|
1891
1895
|
/**
|
|
1892
1896
|
* Freezes the drag handles. When frozen, they will stay attached to the same
|
|
@@ -1902,45 +1906,45 @@ const D = new P("TableHandlesPlugin"), Po = k(({ editor: n }) => {
|
|
|
1902
1906
|
unfreezeHandles() {
|
|
1903
1907
|
e.menuFrozen = !1;
|
|
1904
1908
|
},
|
|
1905
|
-
getCellsAtRowHandle(
|
|
1906
|
-
return G(
|
|
1909
|
+
getCellsAtRowHandle(t, r) {
|
|
1910
|
+
return G(t, r);
|
|
1907
1911
|
},
|
|
1908
1912
|
/**
|
|
1909
1913
|
* Get all the cells in a column of the table block.
|
|
1910
1914
|
*/
|
|
1911
|
-
getCellsAtColumnHandle(
|
|
1912
|
-
return W(
|
|
1915
|
+
getCellsAtColumnHandle(t, r) {
|
|
1916
|
+
return W(t, r);
|
|
1913
1917
|
},
|
|
1914
1918
|
/**
|
|
1915
1919
|
* Sets the selection to the given cell or a range of cells.
|
|
1916
1920
|
* @returns The new state after the selection has been set.
|
|
1917
1921
|
*/
|
|
1918
|
-
setCellSelection(
|
|
1922
|
+
setCellSelection(t, r, s = r) {
|
|
1919
1923
|
if (!e)
|
|
1920
1924
|
throw new Error("Table handles view not initialized");
|
|
1921
|
-
const i =
|
|
1925
|
+
const i = t.doc.resolve(e.tablePos + 1), a = t.doc.resolve(
|
|
1922
1926
|
i.posAtIndex(r.row) + 1
|
|
1923
|
-
), c =
|
|
1927
|
+
), c = t.doc.resolve(
|
|
1924
1928
|
// No need for +1, since CellSelection expects the position before the cell
|
|
1925
1929
|
a.posAtIndex(r.col)
|
|
1926
|
-
), l =
|
|
1930
|
+
), l = t.doc.resolve(
|
|
1927
1931
|
i.posAtIndex(s.row) + 1
|
|
1928
|
-
), u =
|
|
1932
|
+
), u = t.doc.resolve(
|
|
1929
1933
|
// No need for +1, since CellSelection expects the position before the cell
|
|
1930
1934
|
l.posAtIndex(s.col)
|
|
1931
|
-
), h =
|
|
1935
|
+
), h = t.tr;
|
|
1932
1936
|
return h.setSelection(
|
|
1933
1937
|
new yt(c, u)
|
|
1934
|
-
),
|
|
1938
|
+
), t.apply(h);
|
|
1935
1939
|
},
|
|
1936
1940
|
/**
|
|
1937
1941
|
* Adds a row or column to the table using prosemirror-table commands
|
|
1938
1942
|
*/
|
|
1939
|
-
addRowOrColumn(
|
|
1943
|
+
addRowOrColumn(t, r) {
|
|
1940
1944
|
n.exec((s, i) => {
|
|
1941
1945
|
const a = this.setCellSelection(
|
|
1942
1946
|
s,
|
|
1943
|
-
r.orientation === "row" ? { row:
|
|
1947
|
+
r.orientation === "row" ? { row: t, col: 0 } : { row: 0, col: t }
|
|
1944
1948
|
);
|
|
1945
1949
|
return r.orientation === "row" ? r.side === "above" ? pt(a, i) : ft(a, i) : r.side === "left" ? gt(a, i) : wt(a, i);
|
|
1946
1950
|
});
|
|
@@ -1948,17 +1952,17 @@ const D = new P("TableHandlesPlugin"), Po = k(({ editor: n }) => {
|
|
|
1948
1952
|
/**
|
|
1949
1953
|
* Removes a row or column from the table using prosemirror-table commands
|
|
1950
1954
|
*/
|
|
1951
|
-
removeRowOrColumn(
|
|
1955
|
+
removeRowOrColumn(t, r) {
|
|
1952
1956
|
return r === "row" ? n.exec((s, i) => {
|
|
1953
1957
|
const a = this.setCellSelection(s, {
|
|
1954
|
-
row:
|
|
1958
|
+
row: t,
|
|
1955
1959
|
col: 0
|
|
1956
1960
|
});
|
|
1957
1961
|
return ht(a, i);
|
|
1958
1962
|
}) : n.exec((s, i) => {
|
|
1959
1963
|
const a = this.setCellSelection(s, {
|
|
1960
1964
|
row: 0,
|
|
1961
|
-
col:
|
|
1965
|
+
col: t
|
|
1962
1966
|
});
|
|
1963
1967
|
return mt(a, i);
|
|
1964
1968
|
});
|
|
@@ -1966,12 +1970,12 @@ const D = new P("TableHandlesPlugin"), Po = k(({ editor: n }) => {
|
|
|
1966
1970
|
/**
|
|
1967
1971
|
* Merges the cells in the table block.
|
|
1968
1972
|
*/
|
|
1969
|
-
mergeCells(
|
|
1973
|
+
mergeCells(t) {
|
|
1970
1974
|
return n.exec((r, s) => {
|
|
1971
|
-
const i =
|
|
1975
|
+
const i = t ? this.setCellSelection(
|
|
1972
1976
|
r,
|
|
1973
|
-
|
|
1974
|
-
|
|
1977
|
+
t.relativeStartCell,
|
|
1978
|
+
t.relativeEndCell
|
|
1975
1979
|
) : r;
|
|
1976
1980
|
return ut(i, s);
|
|
1977
1981
|
});
|
|
@@ -1980,9 +1984,9 @@ const D = new P("TableHandlesPlugin"), Po = k(({ editor: n }) => {
|
|
|
1980
1984
|
* Splits the cell in the table block.
|
|
1981
1985
|
* If no cell is provided, the current cell selected will be split.
|
|
1982
1986
|
*/
|
|
1983
|
-
splitCell(
|
|
1987
|
+
splitCell(t) {
|
|
1984
1988
|
return n.exec((r, s) => {
|
|
1985
|
-
const i =
|
|
1989
|
+
const i = t ? this.setCellSelection(r, t) : r;
|
|
1986
1990
|
return dt(i, s);
|
|
1987
1991
|
});
|
|
1988
1992
|
},
|
|
@@ -1991,23 +1995,23 @@ const D = new P("TableHandlesPlugin"), Po = k(({ editor: n }) => {
|
|
|
1991
1995
|
* @returns The start and end cells of the current cell selection.
|
|
1992
1996
|
*/
|
|
1993
1997
|
getCellSelection() {
|
|
1994
|
-
return n.transact((
|
|
1995
|
-
const r =
|
|
1998
|
+
return n.transact((t) => {
|
|
1999
|
+
const r = t.selection;
|
|
1996
2000
|
let s = r.$from, i = r.$to;
|
|
1997
2001
|
if (Q(r)) {
|
|
1998
2002
|
const { ranges: d } = r;
|
|
1999
2003
|
d.forEach((f) => {
|
|
2000
2004
|
s = f.$from.min(s ?? f.$from), i = f.$to.max(i ?? f.$to);
|
|
2001
2005
|
});
|
|
2002
|
-
} else if (s =
|
|
2006
|
+
} else if (s = t.doc.resolve(
|
|
2003
2007
|
r.$from.pos - r.$from.parentOffset - 1
|
|
2004
|
-
), i =
|
|
2008
|
+
), i = t.doc.resolve(
|
|
2005
2009
|
r.$to.pos - r.$to.parentOffset - 1
|
|
2006
2010
|
), s.pos === 0 || i.pos === 0)
|
|
2007
2011
|
return;
|
|
2008
|
-
const a =
|
|
2012
|
+
const a = t.doc.resolve(
|
|
2009
2013
|
s.pos - s.parentOffset - 1
|
|
2010
|
-
), c =
|
|
2014
|
+
), 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), g = i.index(c.depth), m = c.index(l.depth), p = [];
|
|
2011
2015
|
for (let d = h; d <= m; d++)
|
|
2012
2016
|
for (let f = u; f <= g; f++)
|
|
2013
2017
|
p.push({ row: d, col: f });
|
|
@@ -2029,31 +2033,31 @@ const D = new P("TableHandlesPlugin"), Po = k(({ editor: n }) => {
|
|
|
2029
2033
|
*
|
|
2030
2034
|
* Returns undefined when there is no cell selection, or the selection is not within a table.
|
|
2031
2035
|
*/
|
|
2032
|
-
getMergeDirection(
|
|
2036
|
+
getMergeDirection(t) {
|
|
2033
2037
|
return n.transact((r) => {
|
|
2034
2038
|
const s = Q(r.selection) ? r.selection : void 0;
|
|
2035
|
-
if (!s || !
|
|
2039
|
+
if (!s || !t || // Only offer the merge button if there is more than one cell selected.
|
|
2036
2040
|
s.ranges.length <= 1)
|
|
2037
2041
|
return;
|
|
2038
2042
|
const i = this.getCellSelection();
|
|
2039
2043
|
if (i)
|
|
2040
|
-
return $e(i.from, i.to,
|
|
2044
|
+
return $e(i.from, i.to, t) ? "vertical" : "horizontal";
|
|
2041
2045
|
});
|
|
2042
2046
|
},
|
|
2043
|
-
cropEmptyRowsOrColumns(
|
|
2044
|
-
return Fe(
|
|
2047
|
+
cropEmptyRowsOrColumns(t, r) {
|
|
2048
|
+
return Fe(t, r);
|
|
2045
2049
|
},
|
|
2046
|
-
addRowsOrColumns(
|
|
2047
|
-
return He(
|
|
2050
|
+
addRowsOrColumns(t, r, s) {
|
|
2051
|
+
return He(t, r, s);
|
|
2048
2052
|
}
|
|
2049
2053
|
};
|
|
2050
|
-
}), ae = new P("trailingNode"),
|
|
2054
|
+
}), ae = new P("trailingNode"), Do = C(() => ({
|
|
2051
2055
|
key: "trailingNode",
|
|
2052
2056
|
prosemirrorPlugins: [
|
|
2053
2057
|
new T({
|
|
2054
2058
|
key: ae,
|
|
2055
|
-
appendTransaction: (n, e,
|
|
2056
|
-
const { doc:
|
|
2059
|
+
appendTransaction: (n, e, o) => {
|
|
2060
|
+
const { doc: t, tr: r, schema: s } = o, i = ae.getState(o), a = t.content.size - 2, c = s.nodes.blockContainer, l = s.nodes.paragraph;
|
|
2057
2061
|
if (i)
|
|
2058
2062
|
return r.insert(
|
|
2059
2063
|
a,
|
|
@@ -2066,15 +2070,15 @@ const D = new P("TableHandlesPlugin"), Po = k(({ editor: n }) => {
|
|
|
2066
2070
|
apply: (n, e) => {
|
|
2067
2071
|
if (!n.docChanged)
|
|
2068
2072
|
return e;
|
|
2069
|
-
let
|
|
2070
|
-
if (!
|
|
2073
|
+
let o = n.doc.lastChild;
|
|
2074
|
+
if (!o || o.type.name !== "blockGroup")
|
|
2071
2075
|
throw new Error("Expected blockGroup");
|
|
2072
|
-
if (
|
|
2076
|
+
if (o = o.lastChild, !o || o.type.name !== "blockContainer")
|
|
2073
2077
|
return !0;
|
|
2074
|
-
const
|
|
2075
|
-
if (!
|
|
2078
|
+
const t = o.firstChild;
|
|
2079
|
+
if (!t)
|
|
2076
2080
|
throw new Error("Expected blockContent");
|
|
2077
|
-
return
|
|
2081
|
+
return o.nodeSize > 4 || t.type.spec.content !== "inline*";
|
|
2078
2082
|
}
|
|
2079
2083
|
}
|
|
2080
2084
|
})
|
|
@@ -2084,13 +2088,13 @@ export {
|
|
|
2084
2088
|
fo as B,
|
|
2085
2089
|
yo as D,
|
|
2086
2090
|
go as F,
|
|
2087
|
-
|
|
2088
|
-
|
|
2091
|
+
ko as H,
|
|
2092
|
+
Co as L,
|
|
2089
2093
|
xo as N,
|
|
2090
2094
|
Eo as P,
|
|
2091
2095
|
wo as S,
|
|
2092
2096
|
Kt as T,
|
|
2093
|
-
|
|
2097
|
+
vo as V,
|
|
2094
2098
|
oe as Y,
|
|
2095
2099
|
F as a,
|
|
2096
2100
|
$ as b,
|
|
@@ -2100,13 +2104,13 @@ export {
|
|
|
2100
2104
|
Ft as f,
|
|
2101
2105
|
To as g,
|
|
2102
2106
|
Po as h,
|
|
2103
|
-
|
|
2107
|
+
Do as i,
|
|
2104
2108
|
xt as j,
|
|
2105
|
-
|
|
2109
|
+
Ce as k,
|
|
2106
2110
|
Bo as l,
|
|
2107
2111
|
xe as m,
|
|
2108
2112
|
Rt as n,
|
|
2109
2113
|
$t as s,
|
|
2110
|
-
|
|
2114
|
+
O as t
|
|
2111
2115
|
};
|
|
2112
|
-
//# sourceMappingURL=TrailingNode-
|
|
2116
|
+
//# sourceMappingURL=TrailingNode-DZag-Nvu.js.map
|