@blocknote/core 0.48.1 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocknote.cjs +1 -1
- package/dist/blocknote.js +3 -3
- package/dist/{blocks-DYl7UTS4.js → blocks-CSfJen16.js} +18 -2
- package/dist/blocks-CSfJen16.js.map +1 -0
- package/dist/{blocks-BEvIOzln.cjs → blocks-_lpGWKOa.cjs} +3 -3
- package/dist/blocks-_lpGWKOa.cjs.map +1 -0
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +1 -1
- package/dist/comments.cjs +1 -1
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js +2 -2
- package/dist/comments.js.map +1 -1
- package/dist/extensions-BfYaEv6F.cjs +2 -0
- package/dist/extensions-BfYaEv6F.cjs.map +1 -0
- package/dist/{extensions-3nf9PPhA.js → extensions-C3nguvVr.js} +240 -248
- package/dist/extensions-C3nguvVr.js.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +2 -2
- package/dist/src-ChTwrMcE.cjs +5 -0
- package/dist/src-ChTwrMcE.cjs.map +1 -0
- package/dist/{src-Hjv1f5lc.js → src-DQfz4zLM.js} +757 -373
- package/dist/src-DQfz4zLM.js.map +1 -0
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.js +1 -1
- package/package.json +6 -8
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.ts +14 -1
- package/src/blocks/Quote/block.ts +9 -0
- package/src/blocks/Table/block.ts +26 -0
- package/src/comments/extension.ts +5 -0
- package/src/comments/threadstore/yjs/YjsThreadStore.test.ts +3 -2
- package/src/comments/threadstore/yjs/YjsThreadStore.ts +4 -4
- package/src/editor/BlockNoteEditor.ts +84 -5
- package/src/editor/editor.css +5 -0
- package/src/editor/managers/ExtensionManager/extensions.ts +8 -26
- package/src/editor/managers/StyleManager.ts +90 -10
- package/src/extensions/FormattingToolbar/FormattingToolbar.ts +23 -16
- package/src/extensions/LinkToolbar/LinkToolbar.ts +30 -75
- package/src/extensions/Placeholder/Placeholder.ts +2 -2
- package/src/extensions/tiptap-extensions/Link/helpers/autolink.ts +179 -0
- package/src/extensions/tiptap-extensions/Link/helpers/clickHandler.ts +82 -0
- package/src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts +414 -0
- package/src/extensions/tiptap-extensions/Link/helpers/pasteHandler.ts +53 -0
- package/src/extensions/tiptap-extensions/Link/helpers/tlds.ts +7 -0
- package/src/extensions/tiptap-extensions/Link/helpers/whitespace.ts +13 -0
- package/src/extensions/tiptap-extensions/Link/index.ts +2 -0
- package/src/extensions/tiptap-extensions/Link/link.test.ts +941 -0
- package/src/extensions/tiptap-extensions/Link/link.ts +207 -0
- package/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts +3 -5
- package/src/schema/inlineContent/types.ts +1 -1
- package/types/src/editor/BlockNoteEditor.d.ts +69 -3
- package/types/src/editor/managers/StyleManager.d.ts +22 -0
- package/types/src/extensions/LinkToolbar/LinkToolbar.d.ts +28 -7
- package/types/src/extensions/tiptap-extensions/Link/helpers/autolink.d.ts +13 -0
- package/types/src/extensions/tiptap-extensions/Link/helpers/clickHandler.d.ts +12 -0
- package/types/src/extensions/tiptap-extensions/Link/helpers/linkDetector.d.ts +32 -0
- package/types/src/extensions/tiptap-extensions/Link/helpers/pasteHandler.d.ts +12 -0
- package/types/src/extensions/tiptap-extensions/Link/helpers/tlds.d.ts +1 -0
- package/types/src/extensions/tiptap-extensions/Link/helpers/whitespace.d.ts +4 -0
- package/types/src/extensions/tiptap-extensions/Link/index.d.ts +2 -0
- package/types/src/extensions/tiptap-extensions/Link/link.d.ts +13 -0
- package/types/src/extensions/tiptap-extensions/Link/link.test.d.ts +1 -0
- package/types/src/schema/inlineContent/types.d.ts +1 -2
- package/dist/blocks-BEvIOzln.cjs.map +0 -1
- package/dist/blocks-DYl7UTS4.js.map +0 -1
- package/dist/extensions-3nf9PPhA.js.map +0 -1
- package/dist/extensions-D9y6evn6.cjs +0 -2
- package/dist/extensions-D9y6evn6.cjs.map +0 -1
- package/dist/src-BKJH7Jla.cjs +0 -5
- package/dist/src-BKJH7Jla.cjs.map +0 -1
- package/dist/src-Hjv1f5lc.js.map +0 -1
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { At as e, Bt as t, Dt as n, Et as r, Ft as i, It as a, Lt as o, Mt as s, Nt as c, Pt as l, Rn as u, Rt as d, an as f, dn as p, g as m, h, ht as g, in as _, jt as ee, kt as
|
|
2
|
-
import { n as
|
|
3
|
-
import { DOMSerializer as
|
|
4
|
-
import { dropPoint as
|
|
5
|
-
import { combineTransactionSteps as
|
|
6
|
-
import { NodeSelection as
|
|
7
|
-
import {
|
|
8
|
-
import { DOMParser as
|
|
9
|
-
import { CellSelection as
|
|
10
|
-
import { Plugin as D, PluginKey as O, TextSelection as
|
|
1
|
+
import { At as e, Bt as t, Dt as n, Et as r, Ft as i, It as a, Lt as o, Mt as s, Nt as c, Pt as l, Rn as u, Rt as d, an as f, dn as p, g as m, h, ht as g, in as _, jt as ee, kt as v, r as te, zt as ne } from "./blocks-CSfJen16.js";
|
|
2
|
+
import { n as y, t as b } from "./BlockNoteExtension-B6RhuQ3V.js";
|
|
3
|
+
import { DOMSerializer as x, Fragment as S, Slice as re } from "prosemirror-model";
|
|
4
|
+
import { dropPoint as ie } from "prosemirror-transform";
|
|
5
|
+
import { combineTransactionSteps as ae, findChildrenInRange as C, posToDOMRect as oe } from "@tiptap/core";
|
|
6
|
+
import { NodeSelection as se, Plugin as w, PluginKey as T, Selection as E, TextSelection as ce } from "prosemirror-state";
|
|
7
|
+
import { uuidv4 as le } from "lib0/random";
|
|
8
|
+
import { DOMParser as ue, Slice as de } from "@tiptap/pm/model";
|
|
9
|
+
import { CellSelection as fe, addColumnAfter as pe, addColumnBefore as me, addRowAfter as he, addRowBefore as ge, deleteColumn as _e, deleteRow as ve, mergeCells as ye, splitCell as be } from "prosemirror-tables";
|
|
10
|
+
import { Plugin as D, PluginKey as O, TextSelection as xe } from "@tiptap/pm/state";
|
|
11
11
|
import { Decoration as k, DecorationSet as A } from "prosemirror-view";
|
|
12
|
-
import { defaultSelectionBuilder as
|
|
13
|
-
import
|
|
14
|
-
import * as
|
|
15
|
-
import { history as
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import { unified as
|
|
21
|
-
import { fromDom as
|
|
22
|
-
import { visit as
|
|
12
|
+
import { defaultSelectionBuilder as Se, redoCommand as Ce, undoCommand as we, yCursorPlugin as Te, ySyncPlugin as Ee, yUndoPlugin as De, yUndoPluginKey as j } from "y-prosemirror";
|
|
13
|
+
import Oe from "fast-deep-equal";
|
|
14
|
+
import * as M from "yjs";
|
|
15
|
+
import { history as ke, redo as Ae, undo as je } from "@tiptap/pm/history";
|
|
16
|
+
import Me from "rehype-parse";
|
|
17
|
+
import Ne from "rehype-remark";
|
|
18
|
+
import Pe from "remark-gfm";
|
|
19
|
+
import Fe from "remark-stringify";
|
|
20
|
+
import { unified as Ie } from "unified";
|
|
21
|
+
import { fromDom as Le } from "hast-util-from-dom";
|
|
22
|
+
import { visit as Re } from "unist-util-visit";
|
|
23
23
|
//#region src/api/exporters/html/util/serializeBlocksExternalHTML.ts
|
|
24
|
-
function
|
|
24
|
+
function N(e) {
|
|
25
25
|
let t = Array.from(e.classList).filter((e) => !e.startsWith("bn-")) || [];
|
|
26
26
|
t.length > 0 ? e.className = t.join(" ") : e.removeAttribute("class");
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function P(t, n, r, i) {
|
|
29
29
|
let a;
|
|
30
30
|
if (!n) throw Error("blockContent is required");
|
|
31
|
-
if (typeof n == "string") a =
|
|
32
|
-
else if (Array.isArray(n)) a =
|
|
31
|
+
if (typeof n == "string") a = v([n], t.pmSchema);
|
|
32
|
+
else if (Array.isArray(n)) a = v(n, t.pmSchema);
|
|
33
33
|
else if (n.type === "tableContent") a = e(n, t.pmSchema);
|
|
34
34
|
else throw new u(n.type);
|
|
35
35
|
let o = (i?.document ?? document).createDocumentFragment();
|
|
@@ -54,17 +54,17 @@ function He(t, n, r, i) {
|
|
|
54
54
|
let e = (t.schema.styleSpecs[r.type.name].implementation.toExternalHTML ?? t.schema.styleSpecs[r.type.name].implementation.render)(r.attrs.stringValue, t);
|
|
55
55
|
e.contentDOM.appendChild(n), n = e.dom;
|
|
56
56
|
} else {
|
|
57
|
-
let e = r.type.spec.toDOM(r, !0), t =
|
|
57
|
+
let e = r.type.spec.toDOM(r, !0), t = x.renderSpec(document, e);
|
|
58
58
|
t.contentDOM.appendChild(n), n = t.dom;
|
|
59
59
|
}
|
|
60
60
|
o.appendChild(n);
|
|
61
61
|
} else {
|
|
62
|
-
let t = r.serializeFragment(
|
|
62
|
+
let t = r.serializeFragment(S.from([e]), i);
|
|
63
63
|
o.appendChild(t);
|
|
64
64
|
}
|
|
65
|
-
return o.childNodes.length === 1 && o.firstChild?.nodeType === 1 &&
|
|
65
|
+
return o.childNodes.length === 1 && o.firstChild?.nodeType === 1 && N(o.firstChild), o;
|
|
66
66
|
}
|
|
67
|
-
function
|
|
67
|
+
function ze(e, t, n, r, i, a, o, s) {
|
|
68
68
|
let c = s?.document ?? document, l = t.pmSchema.nodes.blockContainer, u = n.props || {};
|
|
69
69
|
for (let [e, r] of Object.entries(t.schema.blockSchema[n.type].propSchema)) !(e in u) && r.default !== void 0 && (u[e] = r.default);
|
|
70
70
|
let d = l.spec?.toDOM?.(l.create({
|
|
@@ -80,10 +80,10 @@ function Ue(e, t, n, r, i, a, o, s) {
|
|
|
80
80
|
if (m.dom.classList.contains("bn-block-content")) {
|
|
81
81
|
let e = [...f, ...Array.from(m.dom.attributes)].filter((e) => e.name.startsWith("data") && e.name !== "data-content-type" && e.name !== "data-file-block" && e.name !== "data-node-view-wrapper" && e.name !== "data-node-type" && e.name !== "data-id" && e.name !== "data-editable");
|
|
82
82
|
for (let t of e) m.dom.firstChild.setAttribute(t.name, t.value);
|
|
83
|
-
|
|
83
|
+
N(m.dom.firstChild), o > 0 && m.dom.firstChild.setAttribute("data-nesting-level", o.toString()), h.append(...Array.from(m.dom.childNodes));
|
|
84
84
|
} else h.append(m.dom), o > 0 && m.dom.setAttribute("data-nesting-level", o.toString());
|
|
85
85
|
if (m.contentDOM && n.content) {
|
|
86
|
-
let e =
|
|
86
|
+
let e = P(t, n.content, r, s);
|
|
87
87
|
m.contentDOM.appendChild(e);
|
|
88
88
|
}
|
|
89
89
|
let g;
|
|
@@ -96,20 +96,20 @@ function Ue(e, t, n, r, i, a, o, s) {
|
|
|
96
96
|
} else e.append(h);
|
|
97
97
|
if (n.children && n.children.length > 0) {
|
|
98
98
|
let l = c.createDocumentFragment();
|
|
99
|
-
if (
|
|
99
|
+
if (F(l, t, n.children, r, i, a, o + 1, s), e.lastChild?.nodeName === "UL" || e.lastChild?.nodeName === "OL") for (; l.firstChild?.nodeName === "UL" || l.firstChild?.nodeName === "OL";) e.lastChild.lastChild.appendChild(l.firstChild);
|
|
100
100
|
"childrenDOM" in m && m.childrenDOM ? m.childrenDOM.append(l) : t.pmSchema.nodes[n.type].isInGroup("blockContent") ? e.append(l) : m.contentDOM?.append(l);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
var
|
|
104
|
-
for (let c of n)
|
|
105
|
-
},
|
|
103
|
+
var F = (e, t, n, r, i, a, o = 0, s) => {
|
|
104
|
+
for (let c of n) ze(e, t, c, r, i, a, o, s);
|
|
105
|
+
}, Be = (e, t, n, r, i, a) => {
|
|
106
106
|
let o = (a?.document ?? document).createDocumentFragment();
|
|
107
|
-
return
|
|
108
|
-
},
|
|
109
|
-
let n =
|
|
107
|
+
return F(o, e, t, n, r, i, 0, a), o;
|
|
108
|
+
}, I = (e, t) => {
|
|
109
|
+
let n = x.fromSchema(e);
|
|
110
110
|
return {
|
|
111
111
|
exportBlocks: (e, r) => {
|
|
112
|
-
let i =
|
|
112
|
+
let i = Be(t, e, n, new Set(["numberedListItem"]), new Set([
|
|
113
113
|
"bulletListItem",
|
|
114
114
|
"checkListItem",
|
|
115
115
|
"toggleListItem"
|
|
@@ -117,14 +117,14 @@ var We = (e, t, n, r, i, a, o = 0, s) => {
|
|
|
117
117
|
return a.append(i), a.innerHTML;
|
|
118
118
|
},
|
|
119
119
|
exportInlineContent: (e, r) => {
|
|
120
|
-
let i =
|
|
120
|
+
let i = P(t, e, n, r), a = document.createElement("div");
|
|
121
121
|
return a.append(i.cloneNode(!0)), a.innerHTML;
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
124
|
};
|
|
125
125
|
//#endregion
|
|
126
126
|
//#region src/api/getBlocksChangedByTransaction.ts
|
|
127
|
-
function
|
|
127
|
+
function Ve(e, t) {
|
|
128
128
|
if (t === 0) return;
|
|
129
129
|
let r = e.resolve(t);
|
|
130
130
|
for (let e = r.depth; e > 0; e--) {
|
|
@@ -132,14 +132,14 @@ function Ke(e, t) {
|
|
|
132
132
|
if (n(t)) return t.attrs.id;
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function He(e) {
|
|
136
136
|
return e.getMeta("paste") ? { type: "paste" } : e.getMeta("uiEvent") === "drop" ? { type: "drop" } : e.getMeta("history$") ? { type: e.getMeta("history$").redo ? "redo" : "undo" } : e.getMeta("y-sync$") ? e.getMeta("y-sync$").isUndoRedoOperation ? { type: "undo-redo" } : { type: "yjs-remote" } : { type: "local" };
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function L(e) {
|
|
139
139
|
let t = {}, r = {}, i = p(e);
|
|
140
140
|
return e.descendants((a, o) => {
|
|
141
141
|
if (!n(a)) return !0;
|
|
142
|
-
let s =
|
|
142
|
+
let s = Ve(e, o), c = s ?? "__root__";
|
|
143
143
|
r[c] || (r[c] = []);
|
|
144
144
|
let l = _(a, i);
|
|
145
145
|
return t[a.attrs.id] = {
|
|
@@ -151,7 +151,7 @@ function Je(e) {
|
|
|
151
151
|
childrenByParent: r
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function Ue(e, t) {
|
|
155
155
|
let n = /* @__PURE__ */ new Set();
|
|
156
156
|
if (!e || !t) return n;
|
|
157
157
|
let r = new Set(e), i = t.filter((e) => r.has(e)), a = e.filter((e) => i.includes(e));
|
|
@@ -175,8 +175,8 @@ function Ye(e, t) {
|
|
|
175
175
|
for (let e = 0; e < i.length; e++) p.has(e) || n.add(i[e]);
|
|
176
176
|
return n;
|
|
177
177
|
}
|
|
178
|
-
function
|
|
179
|
-
let n =
|
|
178
|
+
function R(e, t = []) {
|
|
179
|
+
let n = He(e), r = ae(e.before, [e, ...t]), i = L(r.before), a = L(r.doc), o = [], s = /* @__PURE__ */ new Set();
|
|
180
180
|
Object.keys(a.byId).filter((e) => !(e in i.byId)).forEach((e) => {
|
|
181
181
|
o.push({
|
|
182
182
|
type: "insert",
|
|
@@ -193,7 +193,7 @@ function N(e, t = []) {
|
|
|
193
193
|
}), s.add(e);
|
|
194
194
|
}), Object.keys(a.byId).filter((e) => e in i.byId).forEach((e) => {
|
|
195
195
|
let t = i.byId[e], r = a.byId[e];
|
|
196
|
-
t.parentId === r.parentId ?
|
|
196
|
+
t.parentId === r.parentId ? Oe({
|
|
197
197
|
...t.block,
|
|
198
198
|
children: void 0
|
|
199
199
|
}, {
|
|
@@ -215,7 +215,7 @@ function N(e, t = []) {
|
|
|
215
215
|
});
|
|
216
216
|
let c = i.childrenByParent, l = a.childrenByParent, u = new Set([...Object.keys(c), ...Object.keys(l)]), d = /* @__PURE__ */ new Set();
|
|
217
217
|
return u.forEach((e) => {
|
|
218
|
-
let t =
|
|
218
|
+
let t = Ue(c[e], l[e]);
|
|
219
219
|
t.size !== 0 && t.forEach((t) => {
|
|
220
220
|
let r = i.byId[t], c = a.byId[t];
|
|
221
221
|
!r || !c || r.parentId === c.parentId && (s.has(t) || (r.parentId ?? "__root__") === e && (d.has(t) || (d.add(t), o.push({
|
|
@@ -231,17 +231,17 @@ function N(e, t = []) {
|
|
|
231
231
|
}
|
|
232
232
|
//#endregion
|
|
233
233
|
//#region src/extensions/BlockChange/BlockChange.ts
|
|
234
|
-
var
|
|
234
|
+
var We = b(() => {
|
|
235
235
|
let e = [];
|
|
236
236
|
return {
|
|
237
237
|
key: "blockChange",
|
|
238
|
-
prosemirrorPlugins: [new
|
|
239
|
-
key: new
|
|
238
|
+
prosemirrorPlugins: [new w({
|
|
239
|
+
key: new T("blockChange"),
|
|
240
240
|
filterTransaction: (t) => {
|
|
241
241
|
let n;
|
|
242
242
|
return e.reduce((e, r) => e === !1 ? e : r({
|
|
243
243
|
getChanges() {
|
|
244
|
-
return n || (n =
|
|
244
|
+
return n || (n = R(t), n);
|
|
245
245
|
},
|
|
246
246
|
tr: t
|
|
247
247
|
}) !== !1, !0);
|
|
@@ -256,7 +256,7 @@ var Xe = y(() => {
|
|
|
256
256
|
});
|
|
257
257
|
//#endregion
|
|
258
258
|
//#region src/extensions/Collaboration/YCursorPlugin.ts
|
|
259
|
-
function
|
|
259
|
+
function z(e) {
|
|
260
260
|
let t = e.charAt(0) === "#" ? e.substring(1, 7) : e, n = parseInt(t.substring(0, 2), 16), r = parseInt(t.substring(2, 4), 16), i = parseInt(t.substring(4, 6), 16), a = [
|
|
261
261
|
n / 255,
|
|
262
262
|
r / 255,
|
|
@@ -264,15 +264,15 @@ function P(e) {
|
|
|
264
264
|
].map((e) => e <= .03928 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4);
|
|
265
265
|
return .2126 * a[0] + .7152 * a[1] + .0722 * a[2] <= .179;
|
|
266
266
|
}
|
|
267
|
-
function
|
|
267
|
+
function Ge(e) {
|
|
268
268
|
let t = document.createElement("span");
|
|
269
269
|
t.classList.add("bn-collaboration-cursor__base");
|
|
270
270
|
let n = document.createElement("span");
|
|
271
|
-
n.setAttribute("contentedEditable", "false"), n.classList.add("bn-collaboration-cursor__caret"), n.setAttribute("style", `background-color: ${e.color}; color: ${
|
|
271
|
+
n.setAttribute("contentedEditable", "false"), n.classList.add("bn-collaboration-cursor__caret"), n.setAttribute("style", `background-color: ${e.color}; color: ${z(e.color) ? "white" : "black"}`);
|
|
272
272
|
let r = document.createElement("span");
|
|
273
|
-
return r.classList.add("bn-collaboration-cursor__label"), r.setAttribute("style", `background-color: ${e.color}; color: ${
|
|
273
|
+
return r.classList.add("bn-collaboration-cursor__label"), r.setAttribute("style", `background-color: ${e.color}; color: ${z(e.color) ? "white" : "black"}`), r.insertBefore(document.createTextNode(e.name), null), n.insertBefore(r, null), t.insertBefore(document.createTextNode(""), null), t.insertBefore(n, null), t.insertBefore(document.createTextNode(""), null), t;
|
|
274
274
|
}
|
|
275
|
-
var
|
|
275
|
+
var B = b(({ options: e }) => {
|
|
276
276
|
let t = /* @__PURE__ */ new Map(), n = e.provider && "awareness" in e.provider && typeof e.provider.awareness == "object" ? e.provider.awareness : void 0;
|
|
277
277
|
return n && ("setLocalStateField" in n && typeof n.setLocalStateField == "function" && n.setLocalStateField("user", e.user), "on" in n && typeof n.on == "function" && e.showCursorLabels !== "always" && n.on("change", ({ updated: e }) => {
|
|
278
278
|
for (let n of e) {
|
|
@@ -288,12 +288,12 @@ var F = y(({ options: e }) => {
|
|
|
288
288
|
}
|
|
289
289
|
})), {
|
|
290
290
|
key: "yCursor",
|
|
291
|
-
prosemirrorPlugins: [n ?
|
|
292
|
-
selectionBuilder:
|
|
291
|
+
prosemirrorPlugins: [n ? Te(n, {
|
|
292
|
+
selectionBuilder: Se,
|
|
293
293
|
cursorBuilder(n, r) {
|
|
294
294
|
let i = t.get(r);
|
|
295
295
|
if (!i) {
|
|
296
|
-
let a = (e.renderCursor ??
|
|
296
|
+
let a = (e.renderCursor ?? Ge)(n);
|
|
297
297
|
e.showCursorLabels !== "always" && (a.addEventListener("mouseenter", () => {
|
|
298
298
|
let e = t.get(r);
|
|
299
299
|
e.element.setAttribute("data-active", ""), e.hideTimeout && (clearTimeout(e.hideTimeout), t.set(r, {
|
|
@@ -321,20 +321,20 @@ var F = y(({ options: e }) => {
|
|
|
321
321
|
n?.setLocalStateField("user", e);
|
|
322
322
|
}
|
|
323
323
|
};
|
|
324
|
-
}),
|
|
324
|
+
}), V = b(({ options: e }) => ({
|
|
325
325
|
key: "ySync",
|
|
326
|
-
prosemirrorPlugins: [
|
|
326
|
+
prosemirrorPlugins: [Ee(e.fragment)],
|
|
327
327
|
runsBefore: ["default"]
|
|
328
|
-
})),
|
|
328
|
+
})), H = b(() => ({
|
|
329
329
|
key: "yUndo",
|
|
330
|
-
prosemirrorPlugins: [
|
|
330
|
+
prosemirrorPlugins: [De()],
|
|
331
331
|
dependsOn: ["yCursor", "ySync"],
|
|
332
|
-
undoCommand:
|
|
333
|
-
redoCommand:
|
|
332
|
+
undoCommand: we,
|
|
333
|
+
redoCommand: Ce
|
|
334
334
|
}));
|
|
335
335
|
//#endregion
|
|
336
336
|
//#region src/extensions/Collaboration/ForkYDoc.ts
|
|
337
|
-
function
|
|
337
|
+
function Ke(e, t) {
|
|
338
338
|
let n = e.doc;
|
|
339
339
|
if (e._item === null) {
|
|
340
340
|
let r = Array.from(n.share.keys()).find((t) => n.share.get(t) === e);
|
|
@@ -342,11 +342,11 @@ function Qe(e, t) {
|
|
|
342
342
|
return t.get(r, e.constructor);
|
|
343
343
|
} else {
|
|
344
344
|
let n = e._item, r = t.store.clients.get(n.id.client) ?? [];
|
|
345
|
-
return r[
|
|
345
|
+
return r[M.findIndexSS(r, n.id.clock)].content.type;
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
|
-
var
|
|
349
|
-
let n, r =
|
|
348
|
+
var qe = b(({ editor: e, options: t }) => {
|
|
349
|
+
let n, r = y({ isForked: !1 });
|
|
350
350
|
return {
|
|
351
351
|
key: "yForkDoc",
|
|
352
352
|
store: r,
|
|
@@ -354,23 +354,23 @@ var $e = y(({ editor: e, options: t }) => {
|
|
|
354
354
|
if (n) return;
|
|
355
355
|
let i = t.fragment;
|
|
356
356
|
if (!i) throw Error("No fragment to fork from");
|
|
357
|
-
let a = new
|
|
358
|
-
|
|
359
|
-
let o =
|
|
357
|
+
let a = new M.Doc();
|
|
358
|
+
M.applyUpdate(a, M.encodeStateAsUpdate(i.doc));
|
|
359
|
+
let o = Ke(i, a);
|
|
360
360
|
n = {
|
|
361
|
-
undoStack:
|
|
361
|
+
undoStack: j.getState(e.prosemirrorState).undoManager.undoStack,
|
|
362
362
|
originalFragment: i,
|
|
363
363
|
forkedFragment: o
|
|
364
364
|
}, e.unregisterExtension([
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
365
|
+
H,
|
|
366
|
+
B,
|
|
367
|
+
V
|
|
368
368
|
]);
|
|
369
369
|
let s = {
|
|
370
370
|
...t,
|
|
371
371
|
fragment: o
|
|
372
372
|
};
|
|
373
|
-
e.registerExtension([
|
|
373
|
+
e.registerExtension([V(s), H()]), r.setState({ isForked: !0 });
|
|
374
374
|
},
|
|
375
375
|
merge({ keepChanges: i }) {
|
|
376
376
|
if (!n) return;
|
|
@@ -381,24 +381,24 @@ var $e = y(({ editor: e, options: t }) => {
|
|
|
381
381
|
]);
|
|
382
382
|
let { originalFragment: a, forkedFragment: o, undoStack: s } = n;
|
|
383
383
|
if (e.registerExtension([
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
]),
|
|
388
|
-
let t =
|
|
389
|
-
|
|
384
|
+
V(t),
|
|
385
|
+
B(t),
|
|
386
|
+
H()
|
|
387
|
+
]), j.getState(e.prosemirrorState).undoManager.undoStack = s, i) {
|
|
388
|
+
let t = M.encodeStateAsUpdate(o.doc, M.encodeStateVector(a.doc));
|
|
389
|
+
M.applyUpdate(a.doc, t, e);
|
|
390
390
|
}
|
|
391
391
|
n = void 0, r.setState({ isForked: !1 });
|
|
392
392
|
}
|
|
393
393
|
};
|
|
394
|
-
}),
|
|
394
|
+
}), U = (e, t) => {
|
|
395
395
|
t(e), e.forEach((e) => {
|
|
396
|
-
e instanceof
|
|
396
|
+
e instanceof M.XmlElement && U(e, t);
|
|
397
397
|
});
|
|
398
|
-
},
|
|
398
|
+
}, Je = [(e, t) => {
|
|
399
399
|
let n = /* @__PURE__ */ new Map();
|
|
400
400
|
return e.forEach((e) => {
|
|
401
|
-
e instanceof
|
|
401
|
+
e instanceof M.XmlElement && U(e, (e) => {
|
|
402
402
|
if (e.nodeName === "blockContainer" && e.hasAttribute("id")) {
|
|
403
403
|
let t = e.getAttribute("textColor"), r = e.getAttribute("backgroundColor"), i = {
|
|
404
404
|
textColor: t === g.textColor.default ? void 0 : t,
|
|
@@ -417,7 +417,7 @@ var $e = y(({ editor: e, options: t }) => {
|
|
|
417
417
|
});
|
|
418
418
|
}
|
|
419
419
|
}), !0);
|
|
420
|
-
}],
|
|
420
|
+
}], Ye = b(({ options: e }) => {
|
|
421
421
|
let t = !1;
|
|
422
422
|
return {
|
|
423
423
|
key: "schemaMigration",
|
|
@@ -426,7 +426,7 @@ var $e = y(({ editor: e, options: t }) => {
|
|
|
426
426
|
appendTransaction: (n, r, i) => {
|
|
427
427
|
if (t || !n.some((e) => e.getMeta("y-sync$")) || n.every((e) => !e.docChanged) || !e.fragment.firstChild) return;
|
|
428
428
|
let a = i.tr;
|
|
429
|
-
for (let t of
|
|
429
|
+
for (let t of Je) t(e.fragment, a);
|
|
430
430
|
if (t = !0, a.docChanged) return a;
|
|
431
431
|
}
|
|
432
432
|
})]
|
|
@@ -434,10 +434,10 @@ var $e = y(({ editor: e, options: t }) => {
|
|
|
434
434
|
});
|
|
435
435
|
//#endregion
|
|
436
436
|
//#region src/extensions/DropCursor/utils.ts
|
|
437
|
-
function
|
|
437
|
+
function W(e, t) {
|
|
438
438
|
return !e || !t ? !1 : !!e.closest(`.${t}`);
|
|
439
439
|
}
|
|
440
|
-
function
|
|
440
|
+
function Xe(e, t, n, r, i) {
|
|
441
441
|
let a = e.state.doc.resolve(t.pos);
|
|
442
442
|
if (a.parent.inlineContent || t.orientation === "inline") return null;
|
|
443
443
|
let o = a.nodeBefore, s = a.nodeAfter;
|
|
@@ -464,7 +464,7 @@ function nt(e, t, n, r, i) {
|
|
|
464
464
|
bottom: f + p
|
|
465
465
|
};
|
|
466
466
|
}
|
|
467
|
-
function
|
|
467
|
+
function Ze(e, t, n, r) {
|
|
468
468
|
let i = e.coordsAtPos(t.pos), a = n / 2 * r;
|
|
469
469
|
return {
|
|
470
470
|
left: i.left - a,
|
|
@@ -473,10 +473,10 @@ function rt(e, t, n, r) {
|
|
|
473
473
|
bottom: i.bottom
|
|
474
474
|
};
|
|
475
475
|
}
|
|
476
|
-
function
|
|
476
|
+
function Qe(e, t) {
|
|
477
477
|
e.classList.toggle("prosemirror-dropcursor-inline", t === "inline"), e.classList.toggle("prosemirror-dropcursor-block-horizontal", t === "block-horizontal"), e.classList.toggle("prosemirror-dropcursor-block-vertical-left", t === "block-vertical-left"), e.classList.toggle("prosemirror-dropcursor-block-vertical-right", t === "block-vertical-right"), e.classList.toggle("prosemirror-dropcursor-block", t === "block-horizontal"), e.classList.toggle("prosemirror-dropcursor-vertical", t === "block-vertical-left" || t === "block-vertical-right");
|
|
478
478
|
}
|
|
479
|
-
function
|
|
479
|
+
function $e(e) {
|
|
480
480
|
if (!e || e === document.body && getComputedStyle(e).position === "static") return {
|
|
481
481
|
parentLeft: -window.pageXOffset,
|
|
482
482
|
parentTop: -window.pageYOffset
|
|
@@ -489,7 +489,7 @@ function at(e) {
|
|
|
489
489
|
}
|
|
490
490
|
//#endregion
|
|
491
491
|
//#region src/extensions/DropCursor/DropCursor.ts
|
|
492
|
-
var
|
|
492
|
+
var et = "bn-drag-exclude", tt = b(({ editor: e, options: t }) => {
|
|
493
493
|
let n = null, r = null, i = -1, a = null, o = {
|
|
494
494
|
width: t.dropCursor?.width ?? 5,
|
|
495
495
|
color: t.dropCursor?.color ?? "#ddeeff",
|
|
@@ -499,9 +499,9 @@ var ot = "bn-drag-exclude", st = y(({ editor: e, options: t }) => {
|
|
|
499
499
|
e?.pos === n?.pos && e?.orientation === n?.orientation || (n = e, e == null ? (r && r.parentNode && r.parentNode.removeChild(r), r = null) : c());
|
|
500
500
|
}, c = () => {
|
|
501
501
|
if (!n) return;
|
|
502
|
-
let t = e.prosemirrorView, i = t.dom, a = i.getBoundingClientRect(), s = a.width / i.offsetWidth, c = a.height / i.offsetHeight, l =
|
|
503
|
-
r || (r = u.appendChild(document.createElement("div")), r.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", o.color && (r.style.backgroundColor = o.color)),
|
|
504
|
-
let { parentLeft: d, parentTop: f } =
|
|
502
|
+
let t = e.prosemirrorView, i = t.dom, a = i.getBoundingClientRect(), s = a.width / i.offsetWidth, c = a.height / i.offsetHeight, l = Xe(t, n, o.width, s, c) ?? Ze(t, n, o.width, s), u = t.dom.offsetParent;
|
|
503
|
+
r || (r = u.appendChild(document.createElement("div")), r.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", o.color && (r.style.backgroundColor = o.color)), Qe(r, n.orientation);
|
|
504
|
+
let { parentLeft: d, parentTop: f } = $e(u);
|
|
505
505
|
r.style.left = (l.left - d) / s + "px", r.style.top = (l.top - f) / c + "px", r.style.width = (l.right - l.left) / s + "px", r.style.height = (l.bottom - l.top) / c + "px";
|
|
506
506
|
}, l = (e) => {
|
|
507
507
|
clearTimeout(i), i = window.setTimeout(() => s(null), e);
|
|
@@ -510,7 +510,7 @@ var ot = "bn-drag-exclude", st = y(({ editor: e, options: t }) => {
|
|
|
510
510
|
a = t.target instanceof Element ? t.target : null;
|
|
511
511
|
}, d = (t) => {
|
|
512
512
|
let n = t;
|
|
513
|
-
if (a &&
|
|
513
|
+
if (a && W(a, o.exclude) || n.target instanceof Element && W(n.target, o.exclude)) return;
|
|
514
514
|
let r = e.prosemirrorView;
|
|
515
515
|
if (!r.editable) return;
|
|
516
516
|
let i = r.posAtCoords({
|
|
@@ -520,7 +520,7 @@ var ot = "bn-drag-exclude", st = y(({ editor: e, options: t }) => {
|
|
|
520
520
|
if (i && !d) {
|
|
521
521
|
let t = i.pos;
|
|
522
522
|
if (r.dragging && r.dragging.slice) {
|
|
523
|
-
let e =
|
|
523
|
+
let e = ie(r.state.doc, t, r.dragging.slice);
|
|
524
524
|
e != null && (t = e);
|
|
525
525
|
}
|
|
526
526
|
let a = !r.state.doc.resolve(t).parent.inlineContent, c = {
|
|
@@ -561,9 +561,9 @@ var ot = "bn-drag-exclude", st = y(({ editor: e, options: t }) => {
|
|
|
561
561
|
});
|
|
562
562
|
}
|
|
563
563
|
};
|
|
564
|
-
}),
|
|
565
|
-
let t =
|
|
566
|
-
if (e.selection.empty || e.selection instanceof
|
|
564
|
+
}), nt = b(({ editor: e }) => {
|
|
565
|
+
let t = y(!1), n = () => e.transact((e) => {
|
|
566
|
+
if (e.selection.empty || e.selection instanceof ce && e.doc.textBetween(e.selection.from, e.selection.to).length === 0) return !1;
|
|
567
567
|
let t = !1;
|
|
568
568
|
return e.selection.content().content.descendants((e) => (e.type.spec.code && (t = !0), !t)), !t;
|
|
569
569
|
});
|
|
@@ -571,10 +571,10 @@ var ot = "bn-drag-exclude", st = y(({ editor: e, options: t }) => {
|
|
|
571
571
|
key: "formattingToolbar",
|
|
572
572
|
store: t,
|
|
573
573
|
mount({ dom: r, signal: i }) {
|
|
574
|
-
let a = !1, o = e.onChange(() => {
|
|
575
|
-
a || t.setState(n());
|
|
576
|
-
}),
|
|
577
|
-
a || t.setState(n());
|
|
574
|
+
let a = !1, o = !1, s = e.onChange(() => {
|
|
575
|
+
a || o || t.setState(n());
|
|
576
|
+
}), c = e.onSelectionChange(() => {
|
|
577
|
+
a || o || t.setState(n());
|
|
578
578
|
});
|
|
579
579
|
r.addEventListener("pointerdown", () => {
|
|
580
580
|
a = !0, t.setState(!1);
|
|
@@ -584,21 +584,25 @@ var ot = "bn-drag-exclude", st = y(({ editor: e, options: t }) => {
|
|
|
584
584
|
signal: i,
|
|
585
585
|
capture: !0
|
|
586
586
|
}), r.addEventListener("pointercancel", () => {
|
|
587
|
-
a = !
|
|
587
|
+
a = !0;
|
|
588
588
|
}, {
|
|
589
589
|
signal: i,
|
|
590
590
|
capture: !0
|
|
591
|
-
}),
|
|
592
|
-
o
|
|
591
|
+
}), e.prosemirrorView.root.addEventListener("dragstart", () => {
|
|
592
|
+
o = !0, t.setState(!1);
|
|
593
|
+
}, { signal: i }), e.prosemirrorView.root.addEventListener("dragend", () => {
|
|
594
|
+
o = !1;
|
|
595
|
+
}, { signal: i }), i.addEventListener("abort", () => {
|
|
596
|
+
s(), c();
|
|
593
597
|
});
|
|
594
598
|
}
|
|
595
599
|
};
|
|
596
|
-
}),
|
|
600
|
+
}), rt = b(() => ({
|
|
597
601
|
key: "history",
|
|
598
|
-
prosemirrorPlugins: [
|
|
599
|
-
undoCommand:
|
|
600
|
-
redoCommand:
|
|
601
|
-
})),
|
|
602
|
+
prosemirrorPlugins: [ke()],
|
|
603
|
+
undoCommand: je,
|
|
604
|
+
redoCommand: Ae
|
|
605
|
+
})), it = b(({ editor: e }) => {
|
|
602
606
|
function t(t) {
|
|
603
607
|
let n = e.prosemirrorView.nodeDOM(t);
|
|
604
608
|
for (; n && n.parentElement;) {
|
|
@@ -607,57 +611,45 @@ var ot = "bn-drag-exclude", st = y(({ editor: e, options: t }) => {
|
|
|
607
611
|
}
|
|
608
612
|
return null;
|
|
609
613
|
}
|
|
610
|
-
function n(t
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
});
|
|
614
|
+
function n(t) {
|
|
615
|
+
let n = e.getLinkMarkAtPos(t);
|
|
616
|
+
if (n) return {
|
|
617
|
+
range: {
|
|
618
|
+
from: n.from,
|
|
619
|
+
to: n.to
|
|
620
|
+
},
|
|
621
|
+
mark: { attrs: { href: n.href } },
|
|
622
|
+
get text() {
|
|
623
|
+
return n.text;
|
|
624
|
+
},
|
|
625
|
+
get position() {
|
|
626
|
+
return oe(e.prosemirrorView, n.from, n.to).toJSON();
|
|
627
|
+
}
|
|
628
|
+
};
|
|
626
629
|
}
|
|
627
630
|
function r() {
|
|
628
631
|
return e.transact((e) => {
|
|
629
|
-
|
|
630
|
-
if (t.empty) return n(t.anchor, "link");
|
|
632
|
+
if (e.selection.empty) return n(e.selection.anchor);
|
|
631
633
|
});
|
|
632
634
|
}
|
|
633
635
|
return {
|
|
634
636
|
key: "linkToolbar",
|
|
635
637
|
getLinkAtSelection: r,
|
|
636
638
|
getLinkElementAtPos: t,
|
|
637
|
-
getMarkAtPos
|
|
639
|
+
getMarkAtPos(e, t) {
|
|
640
|
+
return n(e);
|
|
641
|
+
},
|
|
638
642
|
getLinkAtElement(t) {
|
|
639
|
-
return e.transact(() => n(e.prosemirrorView.posAtDOM(t, 0) + 1
|
|
643
|
+
return e.transact(() => n(e.prosemirrorView.posAtDOM(t, 0) + 1));
|
|
640
644
|
},
|
|
641
|
-
editLink(t,
|
|
642
|
-
e.
|
|
643
|
-
let a = p(e), { range: o } = n(i + 1, "link") || { range: {
|
|
644
|
-
from: e.selection.from,
|
|
645
|
-
to: e.selection.to
|
|
646
|
-
} };
|
|
647
|
-
o && (e.insertText(r, o.from, o.to), e.addMark(o.from, o.from + r.length, a.mark("link", { href: t })));
|
|
648
|
-
}), e.prosemirrorView.focus();
|
|
645
|
+
editLink(t, n, r = e.transact((e) => e.selection.anchor)) {
|
|
646
|
+
e.editLink(t, n, r);
|
|
649
647
|
},
|
|
650
648
|
deleteLink(t = e.transact((e) => e.selection.anchor)) {
|
|
651
|
-
e.
|
|
652
|
-
let r = p(e), { range: i } = n(t + 1, "link") || { range: {
|
|
653
|
-
from: e.selection.from,
|
|
654
|
-
to: e.selection.to
|
|
655
|
-
} };
|
|
656
|
-
i && e.removeMark(i.from, i.to, r.marks.link).setMeta("preventAutolink", !0);
|
|
657
|
-
}), e.prosemirrorView.focus();
|
|
649
|
+
e.deleteLink(t);
|
|
658
650
|
}
|
|
659
651
|
};
|
|
660
|
-
}),
|
|
652
|
+
}), at = [
|
|
661
653
|
"http",
|
|
662
654
|
"https",
|
|
663
655
|
"ftp",
|
|
@@ -668,30 +660,30 @@ var ot = "bn-drag-exclude", st = y(({ editor: e, options: t }) => {
|
|
|
668
660
|
"sms",
|
|
669
661
|
"cid",
|
|
670
662
|
"xmpp"
|
|
671
|
-
],
|
|
663
|
+
], ot = "https", st = new T("node-selection-keyboard"), ct = b(() => ({
|
|
672
664
|
key: "nodeSelectionKeyboard",
|
|
673
|
-
prosemirrorPlugins: [new
|
|
674
|
-
key:
|
|
665
|
+
prosemirrorPlugins: [new w({
|
|
666
|
+
key: st,
|
|
675
667
|
props: { handleKeyDown: (e, t) => {
|
|
676
668
|
if ("node" in e.state.selection) {
|
|
677
669
|
if (t.ctrlKey || t.metaKey) return !1;
|
|
678
670
|
if (t.key.length === 1) return t.preventDefault(), !0;
|
|
679
671
|
if (t.key === "Enter" && !t.isComposing && !t.shiftKey && !t.altKey && !t.ctrlKey && !t.metaKey) {
|
|
680
672
|
let t = e.state.tr;
|
|
681
|
-
return e.dispatch(t.insert(e.state.tr.selection.$to.after(), e.state.schema.nodes.paragraph.createChecked()).setSelection(new
|
|
673
|
+
return e.dispatch(t.insert(e.state.tr.selection.$to.after(), e.state.schema.nodes.paragraph.createChecked()).setSelection(new ce(t.doc.resolve(e.state.tr.selection.$to.after() + 1)))), !0;
|
|
682
674
|
}
|
|
683
675
|
}
|
|
684
676
|
return !1;
|
|
685
677
|
} }
|
|
686
678
|
})]
|
|
687
|
-
})),
|
|
679
|
+
})), lt = new T("blocknote-placeholder"), ut = b(({ editor: e, options: t }) => {
|
|
688
680
|
let n = t.placeholders;
|
|
689
681
|
return {
|
|
690
682
|
key: "placeholder",
|
|
691
|
-
prosemirrorPlugins: [new
|
|
692
|
-
key:
|
|
683
|
+
prosemirrorPlugins: [new w({
|
|
684
|
+
key: lt,
|
|
693
685
|
view: (t) => {
|
|
694
|
-
let r = `placeholder-selector-${
|
|
686
|
+
let r = `placeholder-selector-${le()}`;
|
|
695
687
|
t.dom.classList.add(r);
|
|
696
688
|
let i = document.createElement("style"), a = e._tiptapEditor.options.injectNonce;
|
|
697
689
|
a && i.setAttribute("nonce", a), t.root instanceof window.ShadowRoot ? t.root.append(i) : t.root.head.appendChild(i);
|
|
@@ -724,23 +716,23 @@ var ot = "bn-drag-exclude", st = y(({ editor: e, options: t }) => {
|
|
|
724
716
|
} }
|
|
725
717
|
})]
|
|
726
718
|
};
|
|
727
|
-
}),
|
|
719
|
+
}), dt = new T("previous-blocks"), ft = {
|
|
728
720
|
index: "index",
|
|
729
721
|
level: "level",
|
|
730
722
|
type: "type",
|
|
731
723
|
depth: "depth",
|
|
732
724
|
"depth-change": "depth-change"
|
|
733
|
-
},
|
|
725
|
+
}, pt = b(() => {
|
|
734
726
|
let e;
|
|
735
727
|
return {
|
|
736
728
|
key: "previousBlockType",
|
|
737
|
-
prosemirrorPlugins: [new
|
|
738
|
-
key:
|
|
729
|
+
prosemirrorPlugins: [new w({
|
|
730
|
+
key: dt,
|
|
739
731
|
view(t) {
|
|
740
732
|
return {
|
|
741
733
|
update: async (t, n) => {
|
|
742
734
|
this.key?.getState(t.state).updatedBlocks.size > 0 && (e = setTimeout(() => {
|
|
743
|
-
t.dispatch(t.state.tr.setMeta(
|
|
735
|
+
t.dispatch(t.state.tr.setMeta(dt, { clearUpdate: !0 }));
|
|
744
736
|
}, 0));
|
|
745
737
|
},
|
|
746
738
|
destroy: () => {
|
|
@@ -763,7 +755,7 @@ var ot = "bn-drag-exclude", st = y(({ editor: e, options: t }) => {
|
|
|
763
755
|
let a = e.mapping.invert(), o = {
|
|
764
756
|
from: a.map(i.from, -1),
|
|
765
757
|
to: a.map(i.to, 1)
|
|
766
|
-
}, s = {}, c =
|
|
758
|
+
}, s = {}, c = C(n.doc, o, (e) => e.attrs.id), l = new Map(c.map((e) => [e.node.attrs.id, e])), u = C(r.doc, i, (e) => e.attrs.id);
|
|
767
759
|
for (let e of u) {
|
|
768
760
|
let i = l.get(e.node.attrs.id), a = i?.node.firstChild, o = e.node.firstChild;
|
|
769
761
|
if (i && a && o) {
|
|
@@ -791,7 +783,7 @@ var ot = "bn-drag-exclude", st = y(({ editor: e, options: t }) => {
|
|
|
791
783
|
return e.doc.descendants((e, r) => {
|
|
792
784
|
if (!e.attrs.id || !t.updatedBlocks.has(e.attrs.id)) return;
|
|
793
785
|
let i = t.currentTransactionOldBlockAttrs[e.attrs.id], a = {};
|
|
794
|
-
for (let [e, t] of Object.entries(i)) a["data-prev-" +
|
|
786
|
+
for (let [e, t] of Object.entries(i)) a["data-prev-" + ft[e]] = t || "none";
|
|
795
787
|
n.push(k.node(r, r + e.nodeSize, { ...a }));
|
|
796
788
|
}), A.create(e.doc, n);
|
|
797
789
|
} }
|
|
@@ -800,7 +792,7 @@ var ot = "bn-drag-exclude", st = y(({ editor: e, options: t }) => {
|
|
|
800
792
|
});
|
|
801
793
|
//#endregion
|
|
802
794
|
//#region src/extensions/getDraggableBlockFromElement.ts
|
|
803
|
-
function
|
|
795
|
+
function mt(e, t) {
|
|
804
796
|
for (; e && e.parentElement && e.parentElement !== t.dom && e.getAttribute?.("data-node-type") !== "blockContainer";) e = e.parentElement;
|
|
805
797
|
if (e.getAttribute?.("data-node-type") === "blockContainer") return {
|
|
806
798
|
node: e,
|
|
@@ -809,7 +801,7 @@ function V(e, t) {
|
|
|
809
801
|
}
|
|
810
802
|
//#endregion
|
|
811
803
|
//#region src/api/exporters/markdown/util/removeUnderlinesRehypePlugin.ts
|
|
812
|
-
function
|
|
804
|
+
function ht() {
|
|
813
805
|
let e = (t) => {
|
|
814
806
|
let n = t.children.length;
|
|
815
807
|
for (let r = 0; r < n; r++) {
|
|
@@ -825,20 +817,20 @@ function yt() {
|
|
|
825
817
|
}
|
|
826
818
|
//#endregion
|
|
827
819
|
//#region src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.ts
|
|
828
|
-
function
|
|
820
|
+
function gt() {
|
|
829
821
|
let e = (t) => {
|
|
830
822
|
if (t.children && "length" in t.children && t.children.length) for (let n = t.children.length - 1; n >= 0; n--) {
|
|
831
823
|
let r = t.children[n], i = n + 1 < t.children.length ? t.children[n + 1] : void 0;
|
|
832
|
-
r.type === "element" && r.tagName === "input" && r.properties?.type === "checkbox" && i?.type === "element" && i.tagName === "p" ? (i.tagName = "span", i.children.splice(0, 0,
|
|
824
|
+
r.type === "element" && r.tagName === "input" && r.properties?.type === "checkbox" && i?.type === "element" && i.tagName === "p" ? (i.tagName = "span", i.children.splice(0, 0, Le(document.createTextNode(" ")))) : e(r);
|
|
833
825
|
}
|
|
834
826
|
};
|
|
835
827
|
return e;
|
|
836
828
|
}
|
|
837
829
|
//#endregion
|
|
838
830
|
//#region src/api/exporters/markdown/util/convertVideoToMarkdownRehypePlugin.ts
|
|
839
|
-
function
|
|
831
|
+
function _t() {
|
|
840
832
|
return (e) => {
|
|
841
|
-
|
|
833
|
+
Re(e, "element", (e, t, n) => {
|
|
842
834
|
if (n && e.tagName === "video") {
|
|
843
835
|
let r = e.properties?.src || e.properties?.["data-url"] || "", i = e.properties?.title || e.properties?.["data-name"] || "";
|
|
844
836
|
n.children[t] = {
|
|
@@ -851,15 +843,15 @@ function xt() {
|
|
|
851
843
|
}
|
|
852
844
|
//#endregion
|
|
853
845
|
//#region src/api/exporters/markdown/markdownExporter.ts
|
|
854
|
-
function
|
|
855
|
-
return
|
|
846
|
+
function G(e) {
|
|
847
|
+
return Ie().use(Me, { fragment: !0 }).use(_t).use(ht).use(gt).use(Ne).use(Pe).use(Fe, { handlers: { text: (e) => e.value } }).processSync(e).value;
|
|
856
848
|
}
|
|
857
|
-
function
|
|
858
|
-
return
|
|
849
|
+
function vt(e, t, n, r) {
|
|
850
|
+
return G(I(t, n).exportBlocks(e, r));
|
|
859
851
|
}
|
|
860
852
|
//#endregion
|
|
861
853
|
//#region src/api/nodeConversions/fragmentToBlocks.ts
|
|
862
|
-
function
|
|
854
|
+
function yt(e) {
|
|
863
855
|
let t = [];
|
|
864
856
|
return e.descendants((e) => {
|
|
865
857
|
let n = p(e);
|
|
@@ -870,7 +862,7 @@ function U(e) {
|
|
|
870
862
|
}
|
|
871
863
|
//#endregion
|
|
872
864
|
//#region src/extensions/SideMenu/MultipleNodeSelection.ts
|
|
873
|
-
var
|
|
865
|
+
var K = class e extends E {
|
|
874
866
|
nodes;
|
|
875
867
|
constructor(e, t) {
|
|
876
868
|
super(e, t);
|
|
@@ -883,7 +875,7 @@ var W = class e extends T {
|
|
|
883
875
|
return new e(t.resolve(n), t.resolve(r));
|
|
884
876
|
}
|
|
885
877
|
content() {
|
|
886
|
-
return new
|
|
878
|
+
return new re(S.from(this.nodes), 0, 0);
|
|
887
879
|
}
|
|
888
880
|
eq(t) {
|
|
889
881
|
if (!(t instanceof e) || this.nodes.length !== t.nodes.length || this.from !== t.from || this.to !== t.to) return !1;
|
|
@@ -892,7 +884,7 @@ var W = class e extends T {
|
|
|
892
884
|
}
|
|
893
885
|
map(t, n) {
|
|
894
886
|
let r = n.mapResult(this.from), i = n.mapResult(this.to);
|
|
895
|
-
return i.deleted ?
|
|
887
|
+
return i.deleted ? E.near(t.resolve(r.pos)) : r.deleted ? E.near(t.resolve(i.pos)) : new e(t.resolve(r.pos), t.resolve(i.pos));
|
|
896
888
|
}
|
|
897
889
|
toJSON() {
|
|
898
890
|
return {
|
|
@@ -902,11 +894,11 @@ var W = class e extends T {
|
|
|
902
894
|
};
|
|
903
895
|
}
|
|
904
896
|
};
|
|
905
|
-
|
|
897
|
+
E.jsonID("multiple-node", K);
|
|
906
898
|
//#endregion
|
|
907
899
|
//#region src/extensions/SideMenu/dragging.ts
|
|
908
|
-
var
|
|
909
|
-
function
|
|
900
|
+
var q;
|
|
901
|
+
function bt(e, t) {
|
|
910
902
|
let n, r, i = t.resolve(e.from).node().type.spec.group === "blockContent", a = t.resolve(e.to).node().type.spec.group === "blockContent", o = Math.min(e.$anchor.depth, e.$head.depth);
|
|
911
903
|
if (i && a) {
|
|
912
904
|
let i = e.$from.start(o - 1), a = e.$to.end(o - 1);
|
|
@@ -917,45 +909,45 @@ function Ct(e, t) {
|
|
|
917
909
|
to: r
|
|
918
910
|
};
|
|
919
911
|
}
|
|
920
|
-
function
|
|
912
|
+
function xt(e, t, n = t) {
|
|
921
913
|
t === n && (n += e.state.doc.resolve(t + 1).node().nodeSize);
|
|
922
914
|
let r = e.domAtPos(t).node.cloneNode(!0), i = e.domAtPos(t).node, a = (e, t) => Array.prototype.indexOf.call(e.children, t), o = a(i, e.domAtPos(t + 1).node.parentElement), s = a(i, e.domAtPos(n - 1).node.parentElement);
|
|
923
915
|
for (let e = i.childElementCount - 1; e >= 0; e--) (e > s || e < o) && r.removeChild(r.children[e]);
|
|
924
|
-
|
|
925
|
-
let c =
|
|
916
|
+
St(e.root), q = r;
|
|
917
|
+
let c = q.getElementsByTagName("iframe");
|
|
926
918
|
for (let e = 0; e < c.length; e++) {
|
|
927
919
|
let t = c[e], n = t.parentElement;
|
|
928
920
|
n && n.removeChild(t);
|
|
929
921
|
}
|
|
930
922
|
let l = e.dom.className.split(" ").filter((e) => e !== "ProseMirror" && e !== "bn-root" && e !== "bn-editor").join(" ");
|
|
931
|
-
|
|
923
|
+
q.className = q.className + " bn-drag-preview " + l, e.root instanceof ShadowRoot ? e.root.appendChild(q) : e.root.body.appendChild(q);
|
|
932
924
|
}
|
|
933
|
-
function
|
|
934
|
-
|
|
925
|
+
function St(e) {
|
|
926
|
+
q !== void 0 && (e instanceof ShadowRoot ? e.removeChild(q) : e.body.removeChild(q), q = void 0);
|
|
935
927
|
}
|
|
936
|
-
function
|
|
928
|
+
function Ct(e, t, n) {
|
|
937
929
|
if (!e.dataTransfer || n.headless) return;
|
|
938
930
|
let i = n.prosemirrorView, a = r(t.id, i.state.doc);
|
|
939
931
|
if (!a) throw Error(`Block with ID ${t.id} not found`);
|
|
940
932
|
let o = a.posBeforeNode;
|
|
941
933
|
if (o != null) {
|
|
942
|
-
let t = i.state.selection, r = i.state.doc, { from: a, to: s } =
|
|
943
|
-
c && l ? (i.dispatch(i.state.tr.setSelection(
|
|
944
|
-
let u = i.state.selection.content(), d = n.pmSchema, f = i.serializeForClipboard(u).dom.innerHTML, p =
|
|
945
|
-
e.dataTransfer.clearData(), e.dataTransfer.setData("blocknote/html", f), e.dataTransfer.setData("text/html", h), e.dataTransfer.setData("text/plain", g), e.dataTransfer.effectAllowed = "move", e.dataTransfer.setDragImage(
|
|
934
|
+
let t = i.state.selection, r = i.state.doc, { from: a, to: s } = bt(t, r), c = a <= o && o < s, l = t.$anchor.node() !== t.$head.node() || t instanceof K;
|
|
935
|
+
c && l ? (i.dispatch(i.state.tr.setSelection(K.create(r, a, s))), xt(i, a, s)) : (i.dispatch(i.state.tr.setSelection(se.create(i.state.doc, o))), xt(i, o));
|
|
936
|
+
let u = i.state.selection.content(), d = n.pmSchema, f = i.serializeForClipboard(u).dom.innerHTML, p = I(d, n), m = yt(u.content), h = p.exportBlocks(m, {}), g = G(h);
|
|
937
|
+
e.dataTransfer.clearData(), e.dataTransfer.setData("blocknote/html", f), e.dataTransfer.setData("text/html", h), e.dataTransfer.setData("text/plain", g), e.dataTransfer.effectAllowed = "move", e.dataTransfer.setDragImage(q, 0, 0);
|
|
946
938
|
}
|
|
947
939
|
}
|
|
948
940
|
//#endregion
|
|
949
941
|
//#region src/extensions/SideMenu/SideMenu.ts
|
|
950
|
-
var
|
|
942
|
+
var wt = 250;
|
|
951
943
|
function J(e, t, n = !0) {
|
|
952
944
|
let r = e.root.elementsFromPoint(t.left, t.top);
|
|
953
945
|
for (let i of r) if (e.dom.contains(i)) return n && i.closest("[data-node-type=columnList]") ? J(e, {
|
|
954
946
|
left: t.left + 50,
|
|
955
947
|
top: t.top
|
|
956
|
-
}, !1) :
|
|
948
|
+
}, !1) : mt(i, e);
|
|
957
949
|
}
|
|
958
|
-
function
|
|
950
|
+
function Tt(e, t) {
|
|
959
951
|
if (!t.dom.firstChild) return;
|
|
960
952
|
let n = t.dom.firstChild.getBoundingClientRect(), r = J(t, {
|
|
961
953
|
left: Math.min(Math.max(n.left + 10, e.x), n.right - 10),
|
|
@@ -966,7 +958,7 @@ function Et(e, t) {
|
|
|
966
958
|
top: e.y
|
|
967
959
|
}, !1);
|
|
968
960
|
}
|
|
969
|
-
var
|
|
961
|
+
var Et = class {
|
|
970
962
|
state;
|
|
971
963
|
emitUpdate;
|
|
972
964
|
mousePos;
|
|
@@ -988,11 +980,11 @@ var Dt = class {
|
|
|
988
980
|
clientX: this.mousePos.x,
|
|
989
981
|
clientY: this.mousePos.y
|
|
990
982
|
});
|
|
991
|
-
if (e?.element !== this.pmView.dom || e.distance >
|
|
983
|
+
if (e?.element !== this.pmView.dom || e.distance > wt) {
|
|
992
984
|
this.state?.show && (this.state.show = !1, this.updateState(this.state));
|
|
993
985
|
return;
|
|
994
986
|
}
|
|
995
|
-
let t =
|
|
987
|
+
let t = Tt(this.mousePos, this.pmView);
|
|
996
988
|
if (!t || !this.editor.isEditable) {
|
|
997
989
|
this.state?.show && (this.state.show = !1, this.updateState(this.state));
|
|
998
990
|
return;
|
|
@@ -1011,9 +1003,9 @@ var Dt = class {
|
|
|
1011
1003
|
if (!t || this.pmView.dragging) return;
|
|
1012
1004
|
let n = document.createElement("div");
|
|
1013
1005
|
n.innerHTML = t;
|
|
1014
|
-
let r =
|
|
1006
|
+
let r = ue.fromSchema(this.pmView.state.schema).parse(n, { topNode: this.pmView.state.schema.nodes.blockGroup.create() });
|
|
1015
1007
|
this.pmView.dragging = {
|
|
1016
|
-
slice: new
|
|
1008
|
+
slice: new de(r.content, 0, 0),
|
|
1017
1009
|
move: !0
|
|
1018
1010
|
};
|
|
1019
1011
|
};
|
|
@@ -1045,7 +1037,7 @@ var Dt = class {
|
|
|
1045
1037
|
getDragEventContext = (e) => {
|
|
1046
1038
|
if (!(this.pmView.dragging !== null || this.isDragOrigin || e.dataTransfer?.types.includes("blocknote/html") || e.target instanceof Node && this.pmView.dom.contains(e.target))) return;
|
|
1047
1039
|
let t = !e.dataTransfer?.types.includes("blocknote/html") && !!this.pmView.dragging, n = !!this.isDragOrigin, r = t || n, i = this.findClosestEditorElement(e);
|
|
1048
|
-
if (!i || i.distance >
|
|
1040
|
+
if (!i || i.distance > wt) return;
|
|
1049
1041
|
let a = i.element === this.pmView.dom, o = a && i.distance === 0;
|
|
1050
1042
|
if (!(!a && !r)) return {
|
|
1051
1043
|
isDropPoint: a,
|
|
@@ -1063,7 +1055,7 @@ var Dt = class {
|
|
|
1063
1055
|
let { isDropPoint: n, isDropWithinEditorBounds: r, isDragOrigin: i } = t;
|
|
1064
1056
|
if (!r && n && this.dispatchSyntheticEvent(e), n) {
|
|
1065
1057
|
if (this.pmView.dragging) return;
|
|
1066
|
-
this.pmView.dispatch(this.pmView.state.tr.setSelection(
|
|
1058
|
+
this.pmView.dispatch(this.pmView.state.tr.setSelection(xe.create(this.pmView.state.tr.doc, this.pmView.state.tr.selection.anchor)));
|
|
1067
1059
|
return;
|
|
1068
1060
|
} else if (i) {
|
|
1069
1061
|
setTimeout(() => this.pmView.dispatch(this.pmView.state.tr.deleteSelection()), 0);
|
|
@@ -1099,22 +1091,22 @@ var Dt = class {
|
|
|
1099
1091
|
destroy() {
|
|
1100
1092
|
this.state?.show && (this.state.show = !1, this.emitUpdate(this.state)), this.pmView.root.removeEventListener("mousemove", this.onMouseMove, !0), this.pmView.root.removeEventListener("dragstart", this.onDragStart), this.pmView.root.removeEventListener("dragover", this.onDragOver), this.pmView.root.removeEventListener("drop", this.onDrop, !0), this.pmView.root.removeEventListener("dragend", this.onDragEnd, !0), this.pmView.root.removeEventListener("keydown", this.onKeyDown, !0);
|
|
1101
1093
|
}
|
|
1102
|
-
},
|
|
1103
|
-
let t, n =
|
|
1094
|
+
}, Dt = new O("SideMenuPlugin"), Ot = b(({ editor: e }) => {
|
|
1095
|
+
let t, n = y(void 0);
|
|
1104
1096
|
return {
|
|
1105
1097
|
key: "sideMenu",
|
|
1106
1098
|
store: n,
|
|
1107
1099
|
prosemirrorPlugins: [new D({
|
|
1108
|
-
key:
|
|
1109
|
-
view: (r) => (t = new
|
|
1100
|
+
key: Dt,
|
|
1101
|
+
view: (r) => (t = new Et(e, r, (e) => {
|
|
1110
1102
|
n.setState({ ...e });
|
|
1111
1103
|
}), t)
|
|
1112
1104
|
})],
|
|
1113
1105
|
blockDragStart(n, r) {
|
|
1114
|
-
t && (t.isDragOrigin = !0),
|
|
1106
|
+
t && (t.isDragOrigin = !0), Ct(n, r, e);
|
|
1115
1107
|
},
|
|
1116
1108
|
blockDragEnd() {
|
|
1117
|
-
|
|
1109
|
+
St(e.prosemirrorView.root), t && (t.isDragOrigin = !1), e.blur();
|
|
1118
1110
|
},
|
|
1119
1111
|
freezeMenu() {
|
|
1120
1112
|
t.menuFrozen = !0, t.state.show = !0, t.emitUpdate(t.state);
|
|
@@ -1127,7 +1119,7 @@ var Dt = class {
|
|
|
1127
1119
|
}
|
|
1128
1120
|
};
|
|
1129
1121
|
}), Y;
|
|
1130
|
-
async function
|
|
1122
|
+
async function kt() {
|
|
1131
1123
|
return Y || (Y = (async () => {
|
|
1132
1124
|
let [e, t] = await Promise.all([import("emoji-mart"), import("@emoji-mart/data")]), n = "default" in e ? e.default : e, r = "default" in t ? t.default : t;
|
|
1133
1125
|
return await n.init({ data: r }), {
|
|
@@ -1136,9 +1128,9 @@ async function At() {
|
|
|
1136
1128
|
};
|
|
1137
1129
|
})(), Y);
|
|
1138
1130
|
}
|
|
1139
|
-
async function
|
|
1140
|
-
if (!("text" in e.schema.inlineContentSchema) || e.schema.inlineContentSchema.text !==
|
|
1141
|
-
let { emojiData: n, emojiMart: r } = await
|
|
1131
|
+
async function At(e, t) {
|
|
1132
|
+
if (!("text" in e.schema.inlineContentSchema) || e.schema.inlineContentSchema.text !== te.text) return [];
|
|
1133
|
+
let { emojiData: n, emojiMart: r } = await kt();
|
|
1142
1134
|
return (t.trim() === "" ? Object.values(n.emojis) : await r.SearchIndex.search(t)).map((t) => ({
|
|
1143
1135
|
id: t.skins[0].native,
|
|
1144
1136
|
onItemClick: () => e.insertInlineContent(t.skins[0].native + " ")
|
|
@@ -1147,16 +1139,16 @@ async function jt(e, t) {
|
|
|
1147
1139
|
//#endregion
|
|
1148
1140
|
//#region src/extensions/TableHandles/TableHandles.ts
|
|
1149
1141
|
var X;
|
|
1150
|
-
function
|
|
1142
|
+
function jt(e) {
|
|
1151
1143
|
X || (X = document.createElement("div"), X.innerHTML = "_", X.style.opacity = "0", X.style.height = "1px", X.style.width = "1px", e instanceof Document ? e.body.appendChild(X) : e.appendChild(X));
|
|
1152
1144
|
}
|
|
1153
|
-
function
|
|
1145
|
+
function Mt(e) {
|
|
1154
1146
|
X &&= (e instanceof Document ? e.body.removeChild(X) : e.removeChild(X), void 0);
|
|
1155
1147
|
}
|
|
1156
1148
|
function Z(e) {
|
|
1157
1149
|
return Array.prototype.indexOf.call(e.parentElement.childNodes, e);
|
|
1158
1150
|
}
|
|
1159
|
-
function
|
|
1151
|
+
function Nt(e) {
|
|
1160
1152
|
let t = e;
|
|
1161
1153
|
for (; t && t.nodeName !== "TD" && t.nodeName !== "TH" && !t.classList.contains("tableWrapper");) {
|
|
1162
1154
|
if (t.classList.contains("ProseMirror")) return;
|
|
@@ -1174,11 +1166,11 @@ function Pt(e) {
|
|
|
1174
1166
|
tbodyNode: t.querySelector("tbody")
|
|
1175
1167
|
};
|
|
1176
1168
|
}
|
|
1177
|
-
function
|
|
1169
|
+
function Pt(e, t) {
|
|
1178
1170
|
let n = t.querySelectorAll(e);
|
|
1179
1171
|
for (let e = 0; e < n.length; e++) n[e].style.visibility = "hidden";
|
|
1180
1172
|
}
|
|
1181
|
-
var
|
|
1173
|
+
var Ft = class {
|
|
1182
1174
|
state;
|
|
1183
1175
|
emitUpdate;
|
|
1184
1176
|
tableId;
|
|
@@ -1201,7 +1193,7 @@ var Q = class {
|
|
|
1201
1193
|
};
|
|
1202
1194
|
mouseMoveHandler = (e) => {
|
|
1203
1195
|
if (this.menuFrozen || this.mouseState === "selecting" || !(e.target instanceof Element) || !this.pmView.dom.contains(e.target)) return;
|
|
1204
|
-
let t =
|
|
1196
|
+
let t = Nt(e.target);
|
|
1205
1197
|
if (t?.type === "cell" && this.mouseState === "down" && !this.state?.draggingState) {
|
|
1206
1198
|
this.mouseState = "selecting", this.state?.show && (this.state.show = !1, this.state.showAddOrRemoveRowsButton = !1, this.state.showAddOrRemoveColumnsButton = !1, this.emitUpdate());
|
|
1207
1199
|
return;
|
|
@@ -1211,7 +1203,7 @@ var Q = class {
|
|
|
1211
1203
|
return;
|
|
1212
1204
|
}
|
|
1213
1205
|
if (!t.tbodyNode) return;
|
|
1214
|
-
let n = t.tbodyNode.getBoundingClientRect(), i =
|
|
1206
|
+
let n = t.tbodyNode.getBoundingClientRect(), i = mt(t.domNode, this.pmView);
|
|
1215
1207
|
if (!i) return;
|
|
1216
1208
|
this.tableElement = i.node;
|
|
1217
1209
|
let a, o = this.editor.transact((e) => r(i.id, e.doc));
|
|
@@ -1254,7 +1246,7 @@ var Q = class {
|
|
|
1254
1246
|
};
|
|
1255
1247
|
dragOverHandler = (e) => {
|
|
1256
1248
|
if (this.state?.draggingState === void 0) return;
|
|
1257
|
-
e.preventDefault(), e.dataTransfer.dropEffect = "move",
|
|
1249
|
+
e.preventDefault(), e.dataTransfer.dropEffect = "move", Pt(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline", this.pmView.root);
|
|
1258
1250
|
let t = {
|
|
1259
1251
|
left: Math.min(Math.max(e.clientX, this.state.referencePosTable.left + 1), this.state.referencePosTable.right - 1),
|
|
1260
1252
|
top: Math.min(Math.max(e.clientY, this.state.referencePosTable.top + 1), this.state.referencePosTable.bottom - 1)
|
|
@@ -1263,7 +1255,7 @@ var Q = class {
|
|
|
1263
1255
|
let r = n[0], i = !1, a = Z(r.parentElement), o = Z(r), s = this.state.draggingState.draggedCellOrientation === "row" ? this.state.rowIndex : this.state.colIndex, c = (this.state.draggingState.draggedCellOrientation === "row" ? a : o) !== s;
|
|
1264
1256
|
(this.state.rowIndex !== a || this.state.colIndex !== o) && (this.state.rowIndex = a, this.state.colIndex = o, this.state.referencePosCell = r.getBoundingClientRect(), i = !0);
|
|
1265
1257
|
let l = this.state.draggingState.draggedCellOrientation === "row" ? t.top : t.left;
|
|
1266
|
-
this.state.draggingState.mousePos !== l && (this.state.draggingState.mousePos = l, i = !0), i && this.emitUpdate(), c && this.editor.transact((e) => e.setMeta(
|
|
1258
|
+
this.state.draggingState.mousePos !== l && (this.state.draggingState.mousePos = l, i = !0), i && this.emitUpdate(), c && this.editor.transact((e) => e.setMeta(Q, !0));
|
|
1267
1259
|
};
|
|
1268
1260
|
dropHandler = (e) => {
|
|
1269
1261
|
if (this.mouseState = "up", this.state === void 0 || this.state.draggingState === void 0) return !1;
|
|
@@ -1282,7 +1274,7 @@ var Q = class {
|
|
|
1282
1274
|
});
|
|
1283
1275
|
} else {
|
|
1284
1276
|
if (!c(this.state.block, n.originalIndex, r)) return !1;
|
|
1285
|
-
let e =
|
|
1277
|
+
let e = ne(this.state.block, n.originalIndex, r), [t] = a.splice(n.originalIndex, 1);
|
|
1286
1278
|
a.splice(r, 0, t), this.editor.updateBlock(this.state.block, {
|
|
1287
1279
|
type: "table",
|
|
1288
1280
|
content: {
|
|
@@ -1313,14 +1305,14 @@ var Q = class {
|
|
|
1313
1305
|
destroy() {
|
|
1314
1306
|
this.pmView.dom.removeEventListener("mousemove", this.mouseMoveHandler), window.removeEventListener("mouseup", this.mouseUpHandler), this.pmView.dom.removeEventListener("mousedown", this.viewMousedownHandler), this.pmView.root.removeEventListener("dragover", this.dragOverHandler), this.pmView.root.removeEventListener("drop", this.dropHandler);
|
|
1315
1307
|
}
|
|
1316
|
-
},
|
|
1317
|
-
let t, n =
|
|
1308
|
+
}, Q = new T("TableHandlesPlugin"), It = b(({ editor: e }) => {
|
|
1309
|
+
let t, n = y(void 0);
|
|
1318
1310
|
return {
|
|
1319
1311
|
key: "tableHandles",
|
|
1320
1312
|
store: n,
|
|
1321
|
-
prosemirrorPlugins: [new
|
|
1322
|
-
key:
|
|
1323
|
-
view: (r) => (t = new
|
|
1313
|
+
prosemirrorPlugins: [new w({
|
|
1314
|
+
key: Q,
|
|
1315
|
+
view: (r) => (t = new Ft(e, r, (e) => {
|
|
1324
1316
|
n.setState(e.block ? {
|
|
1325
1317
|
...e,
|
|
1326
1318
|
draggingState: e.draggingState ? { ...e.draggingState } : void 0
|
|
@@ -1354,12 +1346,12 @@ var Q = class {
|
|
|
1354
1346
|
draggedCellOrientation: "col",
|
|
1355
1347
|
originalIndex: t.state.colIndex,
|
|
1356
1348
|
mousePos: n.clientX
|
|
1357
|
-
}, t.emitUpdate(), e.transact((e) => e.setMeta(
|
|
1349
|
+
}, t.emitUpdate(), e.transact((e) => e.setMeta(Q, {
|
|
1358
1350
|
draggedCellOrientation: t.state.draggingState.draggedCellOrientation,
|
|
1359
1351
|
originalIndex: t.state.colIndex,
|
|
1360
1352
|
newIndex: t.state.colIndex,
|
|
1361
1353
|
tablePos: t.tablePos
|
|
1362
|
-
})), !e.headless && (
|
|
1354
|
+
})), !e.headless && (jt(e.prosemirrorView.root), n.dataTransfer.setDragImage(X, 0, 0), n.dataTransfer.effectAllowed = "move");
|
|
1363
1355
|
},
|
|
1364
1356
|
rowDragStart(n) {
|
|
1365
1357
|
if (t.state === void 0 || t.state.rowIndex === void 0) throw Error("Attempted to drag table row, but no table block was hovered prior.");
|
|
@@ -1367,16 +1359,16 @@ var Q = class {
|
|
|
1367
1359
|
draggedCellOrientation: "row",
|
|
1368
1360
|
originalIndex: t.state.rowIndex,
|
|
1369
1361
|
mousePos: n.clientY
|
|
1370
|
-
}, t.emitUpdate(), e.transact((e) => e.setMeta(
|
|
1362
|
+
}, t.emitUpdate(), e.transact((e) => e.setMeta(Q, {
|
|
1371
1363
|
draggedCellOrientation: t.state.draggingState.draggedCellOrientation,
|
|
1372
1364
|
originalIndex: t.state.rowIndex,
|
|
1373
1365
|
newIndex: t.state.rowIndex,
|
|
1374
1366
|
tablePos: t.tablePos
|
|
1375
|
-
})), !e.headless && (
|
|
1367
|
+
})), !e.headless && (jt(e.prosemirrorView.root), n.dataTransfer.setDragImage(X, 0, 0), n.dataTransfer.effectAllowed = "copyMove");
|
|
1376
1368
|
},
|
|
1377
1369
|
dragEnd() {
|
|
1378
1370
|
if (t.state === void 0) throw Error("Attempted to drag table row, but no table block was hovered prior.");
|
|
1379
|
-
t.state.draggingState = void 0, t.emitUpdate(), e.transact((e) => e.setMeta(
|
|
1371
|
+
t.state.draggingState = void 0, t.emitUpdate(), e.transact((e) => e.setMeta(Q, null)), !e.headless && Mt(e.prosemirrorView.root);
|
|
1380
1372
|
},
|
|
1381
1373
|
freezeHandles() {
|
|
1382
1374
|
t.menuFrozen = !0;
|
|
@@ -1396,7 +1388,7 @@ var Q = class {
|
|
|
1396
1388
|
setCellSelection(e, n, r = n) {
|
|
1397
1389
|
if (!t) throw Error("Table handles view not initialized");
|
|
1398
1390
|
let i = e.doc.resolve(t.tablePos + 1), a = e.doc.resolve(i.posAtIndex(n.row) + 1), o = e.doc.resolve(a.posAtIndex(n.col)), s = e.doc.resolve(i.posAtIndex(r.row) + 1), c = e.doc.resolve(s.posAtIndex(r.col)), l = e.tr;
|
|
1399
|
-
return l.setSelection(new
|
|
1391
|
+
return l.setSelection(new fe(o, c)), e.apply(l);
|
|
1400
1392
|
},
|
|
1401
1393
|
addRowOrColumn(t, n) {
|
|
1402
1394
|
e.exec((e, r) => {
|
|
@@ -1407,23 +1399,23 @@ var Q = class {
|
|
|
1407
1399
|
row: 0,
|
|
1408
1400
|
col: t
|
|
1409
1401
|
});
|
|
1410
|
-
return n.orientation === "row" ? n.side === "above" ?
|
|
1402
|
+
return n.orientation === "row" ? n.side === "above" ? ge(i, r) : he(i, r) : n.side === "left" ? me(i, r) : pe(i, r);
|
|
1411
1403
|
});
|
|
1412
1404
|
},
|
|
1413
1405
|
removeRowOrColumn(t, n) {
|
|
1414
|
-
return n === "row" ? e.exec((e, n) =>
|
|
1406
|
+
return n === "row" ? e.exec((e, n) => ve(this.setCellSelection(e, {
|
|
1415
1407
|
row: t,
|
|
1416
1408
|
col: 0
|
|
1417
|
-
}), n)) : e.exec((e, n) =>
|
|
1409
|
+
}), n)) : e.exec((e, n) => _e(this.setCellSelection(e, {
|
|
1418
1410
|
row: 0,
|
|
1419
1411
|
col: t
|
|
1420
1412
|
}), n));
|
|
1421
1413
|
},
|
|
1422
1414
|
mergeCells(t) {
|
|
1423
|
-
return e.exec((e, n) =>
|
|
1415
|
+
return e.exec((e, n) => ye(t ? this.setCellSelection(e, t.relativeStartCell, t.relativeEndCell) : e, n));
|
|
1424
1416
|
},
|
|
1425
1417
|
splitCell(t) {
|
|
1426
|
-
return e.exec((e, n) =>
|
|
1418
|
+
return e.exec((e, n) => be(t ? this.setCellSelection(e, t) : e, n));
|
|
1427
1419
|
},
|
|
1428
1420
|
getCellSelection() {
|
|
1429
1421
|
return e.transact((e) => {
|
|
@@ -1467,12 +1459,12 @@ var Q = class {
|
|
|
1467
1459
|
return ee(e, t, n);
|
|
1468
1460
|
}
|
|
1469
1461
|
};
|
|
1470
|
-
}),
|
|
1462
|
+
}), $ = new T("trailingNode"), Lt = b(() => ({
|
|
1471
1463
|
key: "trailingNode",
|
|
1472
|
-
prosemirrorPlugins: [new
|
|
1473
|
-
key:
|
|
1464
|
+
prosemirrorPlugins: [new w({
|
|
1465
|
+
key: $,
|
|
1474
1466
|
appendTransaction: (e, t, n) => {
|
|
1475
|
-
let { doc: r, tr: i, schema: a } = n, o =
|
|
1467
|
+
let { doc: r, tr: i, schema: a } = n, o = $.getState(n), s = r.content.size - 2, c = a.nodes.blockContainer, l = a.nodes.paragraph;
|
|
1476
1468
|
if (o) return i.insert(s, c.create(void 0, l.create()));
|
|
1477
1469
|
},
|
|
1478
1470
|
state: {
|
|
@@ -1490,6 +1482,6 @@ var Q = class {
|
|
|
1490
1482
|
})]
|
|
1491
1483
|
}));
|
|
1492
1484
|
//#endregion
|
|
1493
|
-
export {
|
|
1485
|
+
export { qe as C, We as D, B as E, R as O, Ye as S, V as T, it as _, At as a, et as b, Dt as c, G as d, pt as f, at as g, ot as h, Q as i, I as k, yt as l, ct as m, It as n, Ot as o, ut as p, Ft as r, Et as s, Lt as t, vt as u, rt as v, H as w, tt as x, nt as y };
|
|
1494
1486
|
|
|
1495
|
-
//# sourceMappingURL=extensions-
|
|
1487
|
+
//# sourceMappingURL=extensions-C3nguvVr.js.map
|