@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,28 +1,27 @@
|
|
|
1
|
-
import { An as e, At as t, Ct as n, En as r, Et as i, Ht as a, Jn as o, Ln as s, Ot as c, Qt as l, Rn as u, Tt as d, V as f, Xt as p, Zt as m, an as h, cn as ee, dn as g, f as te, gn as _, gt as ne, hn as v, in as y, kt as b, mn as x, nn as re, on as ie, pn as
|
|
2
|
-
import { C as
|
|
1
|
+
import { An as e, At as t, Ct as n, En as r, Et as i, Ht as a, Jn as o, Ln as s, Ot as c, Qt as l, Rn as u, Tt as d, V as f, Xt as p, Zt as m, an as h, cn as ee, dn as g, f as te, gn as _, gt as ne, hn as v, in as y, kt as b, mn as x, nn as re, on as ie, pn as ae, pt as oe, rn as se, t as ce, tn as le, vn as S, vt as ue, wt as de } from "./blocks-CSfJen16.js";
|
|
2
|
+
import { C as fe, D as pe, E as me, O as he, S as ge, T as _e, _ as ve, d as ye, f as be, k as xe, l as Se, m as Ce, n as we, o as Te, p as Ee, t as De, u as Oe, v as ke, w as Ae, x as je, y as C } from "./extensions-C3nguvVr.js";
|
|
3
3
|
import { r as Me, t as Ne } from "./BlockNoteExtension-B6RhuQ3V.js";
|
|
4
4
|
import { t as Pe } from "./ShowSelection-BsHFfdMi.js";
|
|
5
5
|
import { t as Fe } from "./en-QsSI16s5.js";
|
|
6
6
|
import { t as Ie } from "./EventEmitter-CuPnGDYt.js";
|
|
7
|
-
import { DOMParser as Le, DOMSerializer as Re, Fragment as
|
|
8
|
-
import { ReplaceAroundStep as
|
|
9
|
-
import { Editor as We, Extension as
|
|
10
|
-
import { NodeSelection as
|
|
11
|
-
import { Fragment as
|
|
12
|
-
import { CellSelection as
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import { unified as
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import { InputRule as
|
|
20
|
-
import { keymap as
|
|
21
|
-
import { Gapcursor as
|
|
22
|
-
import {
|
|
23
|
-
import { Text as dt } from "@tiptap/extension-text";
|
|
7
|
+
import { DOMParser as Le, DOMSerializer as Re, Fragment as w, Node as ze, NodeRange as Be, Slice as T } from "prosemirror-model";
|
|
8
|
+
import { ReplaceAroundStep as E, ReplaceStep as Ve, canJoin as He, liftTarget as Ue } from "prosemirror-transform";
|
|
9
|
+
import { Editor as We, Extension as D, Mark as O, Node as k, combineTransactionSteps as Ge, createDocument as Ke, extensions as A, findChildrenInRange as qe, findParentNodeClosestToPos as Je, getAttributes as Ye, getChangedRanges as Xe, getMarkRange as Ze, getMarksBetween as Qe, getSchema as $e, isNodeSelection as et, markPasteRule as tt, mergeAttributes as j, posToDOMRect as nt, selectionToInsertionEnd as rt } from "@tiptap/core";
|
|
10
|
+
import { NodeSelection as M, Plugin as N, TextSelection as P } from "prosemirror-state";
|
|
11
|
+
import { Fragment as F, Slice as I } from "@tiptap/pm/model";
|
|
12
|
+
import { CellSelection as L, TableMap as it } from "prosemirror-tables";
|
|
13
|
+
import { Plugin as at, PluginKey as ot } from "@tiptap/pm/state";
|
|
14
|
+
import st from "remark-gfm";
|
|
15
|
+
import { unified as ct } from "unified";
|
|
16
|
+
import lt from "remark-parse";
|
|
17
|
+
import ut, { defaultHandlers as dt } from "remark-rehype";
|
|
18
|
+
import ft from "rehype-stringify";
|
|
19
|
+
import { InputRule as pt, inputRules as mt } from "@handlewithcare/prosemirror-inputrules";
|
|
20
|
+
import { keymap as ht } from "@tiptap/pm/keymap";
|
|
21
|
+
import { Gapcursor as gt } from "@tiptap/extensions/gap-cursor";
|
|
22
|
+
import { Text as _t } from "@tiptap/extension-text";
|
|
24
23
|
//#region src/schema/inlineContent/createSpec.ts
|
|
25
|
-
function
|
|
24
|
+
function vt(e, t) {
|
|
26
25
|
let n = [{
|
|
27
26
|
tag: `[data-inline-content-type="${e.type}"]`,
|
|
28
27
|
contentElement: (e) => {
|
|
@@ -39,8 +38,8 @@ function ft(e, t) {
|
|
|
39
38
|
}
|
|
40
39
|
}), n;
|
|
41
40
|
}
|
|
42
|
-
function
|
|
43
|
-
return l(
|
|
41
|
+
function yt(e, t) {
|
|
42
|
+
return l(k.create({
|
|
44
43
|
name: e.type,
|
|
45
44
|
inline: !0,
|
|
46
45
|
group: "inline",
|
|
@@ -55,7 +54,7 @@ function pt(e, t) {
|
|
|
55
54
|
return m(e);
|
|
56
55
|
},
|
|
57
56
|
parseHTML() {
|
|
58
|
-
return
|
|
57
|
+
return vt(e, t.parse);
|
|
59
58
|
},
|
|
60
59
|
renderHTML({ node: n }) {
|
|
61
60
|
let r = this.options.editor;
|
|
@@ -86,15 +85,15 @@ function pt(e, t) {
|
|
|
86
85
|
}
|
|
87
86
|
//#endregion
|
|
88
87
|
//#region src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts
|
|
89
|
-
function
|
|
88
|
+
function bt(e, t, n, r = "before") {
|
|
90
89
|
let a = typeof n == "string" ? n : n.id, o = g(e), s = t.map((e) => c(e, o)), l = i(a, e.doc);
|
|
91
90
|
if (!l) throw Error(`Block with ID ${a} not found`);
|
|
92
91
|
let u = l.posBeforeNode;
|
|
93
|
-
return r === "after" && (u += l.node.nodeSize), e.step(new Ve(u, u, new
|
|
92
|
+
return r === "after" && (u += l.node.nodeSize), e.step(new Ve(u, u, new T(w.from(s), 0, 0))), s.map((e) => y(e, o));
|
|
94
93
|
}
|
|
95
94
|
//#endregion
|
|
96
95
|
//#region src/api/blockManipulation/commands/replaceBlocks/util/fixColumnList.ts
|
|
97
|
-
function
|
|
96
|
+
function R(e) {
|
|
98
97
|
if (!e || e.type.name !== "column") throw Error("Invalid columnPos: does not point to column node.");
|
|
99
98
|
let t = e.firstChild;
|
|
100
99
|
if (!t) throw Error("Invalid column: does not have child node.");
|
|
@@ -102,40 +101,40 @@ function z(e) {
|
|
|
102
101
|
if (!n) throw Error("Invalid blockContainer: does not have child node.");
|
|
103
102
|
return e.childCount === 1 && t.childCount === 1 && n.type.name === "paragraph" && n.content.content.length === 0;
|
|
104
103
|
}
|
|
105
|
-
function
|
|
104
|
+
function xt(e, t) {
|
|
106
105
|
let n = e.doc.resolve(t), r = n.nodeAfter;
|
|
107
106
|
if (!r || r.type.name !== "columnList") throw Error("Invalid columnListPos: does not point to columnList node.");
|
|
108
107
|
for (let t = r.childCount - 1; t >= 0; t--) {
|
|
109
108
|
let r = e.doc.resolve(n.pos + 1).posAtIndex(t), i = e.doc.resolve(r).nodeAfter;
|
|
110
109
|
if (!i || i.type.name !== "column") throw Error("Invalid columnPos: does not point to column node.");
|
|
111
|
-
|
|
110
|
+
R(i) && e.delete(r, r + i.nodeSize);
|
|
112
111
|
}
|
|
113
112
|
}
|
|
114
|
-
function
|
|
115
|
-
|
|
113
|
+
function z(e, t) {
|
|
114
|
+
xt(e, t);
|
|
116
115
|
let n = e.doc.resolve(t).nodeAfter;
|
|
117
116
|
if (!n || n.type.name !== "columnList") throw Error("Invalid columnListPos: does not point to columnList node.");
|
|
118
117
|
if (n.childCount > 2) return;
|
|
119
118
|
if (n.childCount < 2) throw Error("Invalid columnList: contains fewer than two children.");
|
|
120
119
|
let r = t + 1, i = e.doc.resolve(r).nodeAfter, a = t + n.nodeSize - 1, o = e.doc.resolve(a).nodeBefore;
|
|
121
120
|
if (!i || !o) throw Error("Invalid columnList: does not contain children.");
|
|
122
|
-
let s =
|
|
121
|
+
let s = R(i), c = R(o);
|
|
123
122
|
if (s && c) {
|
|
124
123
|
e.delete(t, t + n.nodeSize);
|
|
125
124
|
return;
|
|
126
125
|
}
|
|
127
126
|
if (s) {
|
|
128
|
-
e.step(new
|
|
127
|
+
e.step(new E(t, t + n.nodeSize, a - o.nodeSize + 1, a - 1, T.empty, 0, !1));
|
|
129
128
|
return;
|
|
130
129
|
}
|
|
131
130
|
if (c) {
|
|
132
|
-
e.step(new
|
|
131
|
+
e.step(new E(t, t + n.nodeSize, r + 1, r + i.nodeSize - 1, T.empty, 0, !1));
|
|
133
132
|
return;
|
|
134
133
|
}
|
|
135
134
|
}
|
|
136
135
|
//#endregion
|
|
137
136
|
//#region src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts
|
|
138
|
-
function
|
|
137
|
+
function B(e, t, n) {
|
|
139
138
|
let r = g(e), i = n.map((e) => c(e, r)), a = new Set(t.map((e) => typeof e == "string" ? e : e.id)), o = [], s = /* @__PURE__ */ new Set(), l = typeof t[0] == "string" ? t[0] : t[0].id, u = 0;
|
|
140
139
|
if (e.doc.descendants((t, c) => {
|
|
141
140
|
if (a.size === 0) return !1;
|
|
@@ -154,14 +153,14 @@ function V(e, t, n) {
|
|
|
154
153
|
let e = [...a].join("\n");
|
|
155
154
|
throw Error("Blocks with the following IDs could not be found in the editor: " + e);
|
|
156
155
|
}
|
|
157
|
-
return s.forEach((t) =>
|
|
156
|
+
return s.forEach((t) => z(e, t)), {
|
|
158
157
|
insertedBlocks: i.map((e) => y(e, r)),
|
|
159
158
|
removedBlocks: o
|
|
160
159
|
};
|
|
161
160
|
}
|
|
162
161
|
//#endregion
|
|
163
162
|
//#region src/api/exporters/html/util/serializeBlocksInternalHTML.ts
|
|
164
|
-
function
|
|
163
|
+
function St(e, n, r, i, a) {
|
|
165
164
|
let o;
|
|
166
165
|
if (!n) throw Error("blockContent is required");
|
|
167
166
|
if (typeof n == "string") o = b([n], e.pmSchema, i);
|
|
@@ -195,12 +194,12 @@ function gt(e, n, r, i, a) {
|
|
|
195
194
|
}
|
|
196
195
|
s.appendChild(n);
|
|
197
196
|
} else {
|
|
198
|
-
let e = r.serializeFragment(
|
|
197
|
+
let e = r.serializeFragment(w.from([t]), a);
|
|
199
198
|
s.appendChild(e);
|
|
200
199
|
}
|
|
201
200
|
return s;
|
|
202
201
|
}
|
|
203
|
-
function
|
|
202
|
+
function Ct(e, t, n, r) {
|
|
204
203
|
let i = e.pmSchema.nodes.blockContainer, a = t.props || {};
|
|
205
204
|
for (let [n, r] of Object.entries(e.schema.blockSchema[t.type].propSchema)) !(n in a) && r.default !== void 0 && (a[n] = r.default);
|
|
206
205
|
let o = t.children || [], s = e.blockImplementations[t.type].implementation.render.call({
|
|
@@ -212,12 +211,12 @@ function _t(e, t, n, r) {
|
|
|
212
211
|
children: o
|
|
213
212
|
}, e);
|
|
214
213
|
if (s.contentDOM && t.content) {
|
|
215
|
-
let i =
|
|
214
|
+
let i = St(e, t.content, n, t.type, r);
|
|
216
215
|
s.contentDOM.appendChild(i);
|
|
217
216
|
}
|
|
218
217
|
if (e.pmSchema.nodes[t.type].isInGroup("bnBlock")) {
|
|
219
218
|
if (t.children && t.children.length > 0) {
|
|
220
|
-
let i =
|
|
219
|
+
let i = wt(e, t.children, n, r);
|
|
221
220
|
s.contentDOM?.append(i);
|
|
222
221
|
}
|
|
223
222
|
return s.dom;
|
|
@@ -226,72 +225,72 @@ function _t(e, t, n, r) {
|
|
|
226
225
|
id: t.id,
|
|
227
226
|
...a
|
|
228
227
|
}));
|
|
229
|
-
return c.contentDOM?.appendChild(s.dom), t.children && t.children.length > 0 && c.contentDOM?.appendChild(
|
|
228
|
+
return c.contentDOM?.appendChild(s.dom), t.children && t.children.length > 0 && c.contentDOM?.appendChild(Tt(e, t.children, n, r)), c.dom;
|
|
230
229
|
}
|
|
231
|
-
function
|
|
230
|
+
function wt(e, t, n, r) {
|
|
232
231
|
let i = (r?.document ?? document).createDocumentFragment();
|
|
233
232
|
for (let a of t) {
|
|
234
|
-
let t =
|
|
233
|
+
let t = Ct(e, a, n, r);
|
|
235
234
|
i.appendChild(t);
|
|
236
235
|
}
|
|
237
236
|
return i;
|
|
238
237
|
}
|
|
239
|
-
var
|
|
240
|
-
let i = e.pmSchema.nodes.blockGroup, a = i.spec.toDOM(i.create({})), o =
|
|
238
|
+
var Tt = (e, t, n, r) => {
|
|
239
|
+
let i = e.pmSchema.nodes.blockGroup, a = i.spec.toDOM(i.create({})), o = wt(e, t, n, r);
|
|
241
240
|
return a.contentDOM?.appendChild(o), a.dom;
|
|
242
|
-
},
|
|
241
|
+
}, Et = (e) => (e.querySelectorAll("[data-content-type=\"numberedListItem\"]").forEach((e) => {
|
|
243
242
|
let t = e.closest(".bn-block-outer")?.previousElementSibling?.querySelector("[data-content-type=\"numberedListItem\"]");
|
|
244
243
|
if (!t) e.setAttribute("data-index", e.getAttribute("data-start") || "1");
|
|
245
244
|
else {
|
|
246
245
|
let n = t.getAttribute("data-index");
|
|
247
246
|
e.setAttribute("data-index", (parseInt(n || "0") + 1).toString());
|
|
248
247
|
}
|
|
249
|
-
}), e),
|
|
248
|
+
}), e), Dt = (e) => (e.querySelectorAll("[data-content-type=\"checkListItem\"] input").forEach((e) => {
|
|
250
249
|
e.disabled = !0;
|
|
251
|
-
}), e),
|
|
250
|
+
}), e), Ot = (e) => (e.querySelectorAll(".bn-toggle-wrapper[data-show-children=\"false\"]").forEach((e) => {
|
|
252
251
|
e.setAttribute("data-show-children", "true");
|
|
253
|
-
}), e),
|
|
252
|
+
}), e), kt = (e) => (e.querySelectorAll("[data-content-type=\"table\"] table").forEach((e) => {
|
|
254
253
|
e.setAttribute("style", "--default-cell-min-width: 120px;"), e.setAttribute("data-show-children", "true");
|
|
255
|
-
}), e),
|
|
254
|
+
}), e), At = (e) => (e.querySelectorAll("[data-content-type=\"table\"] table").forEach((e) => {
|
|
256
255
|
let t = document.createElement("div");
|
|
257
256
|
t.className = "tableWrapper";
|
|
258
257
|
let n = document.createElement("div");
|
|
259
258
|
n.className = "tableWrapper-inner", t.appendChild(n), e.parentElement?.appendChild(t), t.appendChild(e);
|
|
260
|
-
}), e),
|
|
259
|
+
}), e), jt = (e) => (e.querySelectorAll(".bn-inline-content:empty").forEach((e) => {
|
|
261
260
|
let t = document.createElement("span");
|
|
262
261
|
t.className = "ProseMirror-trailingBreak", t.setAttribute("style", "display: inline-block;"), e.appendChild(t);
|
|
263
|
-
}), e),
|
|
262
|
+
}), e), Mt = (e, t) => {
|
|
264
263
|
let n = Re.fromSchema(e), r = [
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
264
|
+
Et,
|
|
265
|
+
Dt,
|
|
266
|
+
Ot,
|
|
267
|
+
kt,
|
|
268
|
+
At,
|
|
269
|
+
jt
|
|
271
270
|
];
|
|
272
271
|
return { serializeBlocks: (e, i) => {
|
|
273
|
-
let a =
|
|
272
|
+
let a = Tt(t, e, n, i);
|
|
274
273
|
for (let e of r) a = e(a);
|
|
275
274
|
return a.outerHTML;
|
|
276
275
|
} };
|
|
277
276
|
};
|
|
278
277
|
//#endregion
|
|
279
278
|
//#region src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts
|
|
280
|
-
function
|
|
279
|
+
function Nt(e) {
|
|
281
280
|
return e.transact((e) => {
|
|
282
|
-
let t =
|
|
283
|
-
if (e.selection instanceof
|
|
281
|
+
let t = S(e.doc, e.selection.anchor);
|
|
282
|
+
if (e.selection instanceof L) return {
|
|
284
283
|
type: "cell",
|
|
285
284
|
anchorBlockId: t.node.attrs.id,
|
|
286
285
|
anchorCellOffset: e.selection.$anchorCell.pos - t.posBeforeNode,
|
|
287
286
|
headCellOffset: e.selection.$headCell.pos - t.posBeforeNode
|
|
288
287
|
};
|
|
289
|
-
if (e.selection instanceof
|
|
288
|
+
if (e.selection instanceof M) return {
|
|
290
289
|
type: "node",
|
|
291
290
|
anchorBlockId: t.node.attrs.id
|
|
292
291
|
};
|
|
293
292
|
{
|
|
294
|
-
let n =
|
|
293
|
+
let n = S(e.doc, e.selection.head);
|
|
295
294
|
return {
|
|
296
295
|
type: "text",
|
|
297
296
|
anchorBlockId: t.node.attrs.id,
|
|
@@ -302,84 +301,84 @@ function Tt(e) {
|
|
|
302
301
|
}
|
|
303
302
|
});
|
|
304
303
|
}
|
|
305
|
-
function
|
|
304
|
+
function Pt(e, t) {
|
|
306
305
|
let n = i(t.anchorBlockId, e.doc)?.posBeforeNode;
|
|
307
306
|
if (n === void 0) throw Error(`Could not find block with ID ${t.anchorBlockId} to update selection`);
|
|
308
307
|
let r;
|
|
309
|
-
if (t.type === "cell") r =
|
|
310
|
-
else if (t.type === "node") r =
|
|
308
|
+
if (t.type === "cell") r = L.create(e.doc, n + t.anchorCellOffset, n + t.headCellOffset);
|
|
309
|
+
else if (t.type === "node") r = M.create(e.doc, n + 1);
|
|
311
310
|
else {
|
|
312
311
|
let a = i(t.headBlockId, e.doc)?.posBeforeNode;
|
|
313
312
|
if (a === void 0) throw Error(`Could not find block with ID ${t.headBlockId} to update selection`);
|
|
314
|
-
r =
|
|
313
|
+
r = P.create(e.doc, n + t.anchorOffset, a + t.headOffset);
|
|
315
314
|
}
|
|
316
315
|
e.setSelection(r);
|
|
317
316
|
}
|
|
318
|
-
function
|
|
319
|
-
return e.map((e) => e.type === "columnList" ? e.children.map((e) =>
|
|
317
|
+
function V(e) {
|
|
318
|
+
return e.map((e) => e.type === "columnList" ? e.children.map((e) => V(e.children)).flat() : {
|
|
320
319
|
...e,
|
|
321
|
-
children:
|
|
320
|
+
children: V(e.children)
|
|
322
321
|
}).flat();
|
|
323
322
|
}
|
|
324
|
-
function
|
|
323
|
+
function Ft(e, t, n) {
|
|
325
324
|
e.transact((r) => {
|
|
326
|
-
let i = e.getSelection()?.blocks || [e.getTextCursorPosition().block], a =
|
|
327
|
-
e.removeBlocks(i), e.insertBlocks(
|
|
325
|
+
let i = e.getSelection()?.blocks || [e.getTextCursorPosition().block], a = Nt(e);
|
|
326
|
+
e.removeBlocks(i), e.insertBlocks(V(i), t, n), Pt(r, a);
|
|
328
327
|
});
|
|
329
328
|
}
|
|
330
|
-
function
|
|
329
|
+
function It(e) {
|
|
331
330
|
return !e || e.type !== "columnList";
|
|
332
331
|
}
|
|
333
|
-
function
|
|
332
|
+
function Lt(e, t, n) {
|
|
334
333
|
let r, i;
|
|
335
334
|
if (t ? t.children.length > 0 ? (r = t.children[t.children.length - 1], i = "after") : (r = t, i = "before") : n && (r = n, i = "before"), !r || !i) return;
|
|
336
335
|
let a = e.getParentBlock(r);
|
|
337
|
-
return
|
|
336
|
+
return It(a) ? {
|
|
338
337
|
referenceBlock: r,
|
|
339
338
|
placement: i
|
|
340
|
-
} :
|
|
339
|
+
} : Lt(e, i === "after" ? r : e.getPrevBlock(r), a);
|
|
341
340
|
}
|
|
342
|
-
function
|
|
341
|
+
function Rt(e, t, n) {
|
|
343
342
|
let r, i;
|
|
344
343
|
if (t ? t.children.length > 0 ? (r = t.children[0], i = "before") : (r = t, i = "after") : n && (r = n, i = "after"), !r || !i) return;
|
|
345
344
|
let a = e.getParentBlock(r);
|
|
346
|
-
return
|
|
345
|
+
return It(a) ? {
|
|
347
346
|
referenceBlock: r,
|
|
348
347
|
placement: i
|
|
349
|
-
} :
|
|
348
|
+
} : Rt(e, i === "before" ? r : e.getNextBlock(r), a);
|
|
350
349
|
}
|
|
351
|
-
function
|
|
350
|
+
function zt(e) {
|
|
352
351
|
e.transact(() => {
|
|
353
|
-
let t = e.getSelection()?.blocks[0] || e.getTextCursorPosition().block, n =
|
|
354
|
-
n &&
|
|
352
|
+
let t = e.getSelection()?.blocks[0] || e.getTextCursorPosition().block, n = Lt(e, e.getPrevBlock(t), e.getParentBlock(t));
|
|
353
|
+
n && Ft(e, n.referenceBlock, n.placement);
|
|
355
354
|
});
|
|
356
355
|
}
|
|
357
|
-
function
|
|
356
|
+
function Bt(e) {
|
|
358
357
|
e.transact(() => {
|
|
359
|
-
let t = e.getSelection(), n = t?.blocks[t?.blocks.length - 1] || e.getTextCursorPosition().block, r =
|
|
360
|
-
r &&
|
|
358
|
+
let t = e.getSelection(), n = t?.blocks[t?.blocks.length - 1] || e.getTextCursorPosition().block, r = Rt(e, e.getNextBlock(n), e.getParentBlock(n));
|
|
359
|
+
r && Ft(e, r.referenceBlock, r.placement);
|
|
361
360
|
});
|
|
362
361
|
}
|
|
363
362
|
//#endregion
|
|
364
363
|
//#region src/api/blockManipulation/commands/nestBlock/nestBlock.ts
|
|
365
|
-
function
|
|
364
|
+
function Vt(e, t, n) {
|
|
366
365
|
let { $from: r, $to: i } = e.selection, a = r.blockRange(i, (e) => e.childCount > 0 && (e.type.name === "blockGroup" || e.type.name === "column"));
|
|
367
366
|
if (!a) return !1;
|
|
368
367
|
let o = a.startIndex;
|
|
369
368
|
if (o === 0) return !1;
|
|
370
369
|
let s = a.parent.child(o - 1);
|
|
371
370
|
if (s.type !== t) return !1;
|
|
372
|
-
let c = s.lastChild && s.lastChild.type === n, l =
|
|
373
|
-
return e.step(new
|
|
371
|
+
let c = s.lastChild && s.lastChild.type === n, l = w.from(c ? t.create() : null), u = new T(w.from(t.create(null, w.from(n.create(null, l)))), c ? 3 : 1, 0), d = a.start, f = a.end;
|
|
372
|
+
return e.step(new E(d - (c ? 3 : 1), f, d, f, u, 1, !0)).scrollIntoView(), !0;
|
|
374
373
|
}
|
|
375
|
-
function
|
|
376
|
-
return e.transact((t) =>
|
|
374
|
+
function Ht(e) {
|
|
375
|
+
return e.transact((t) => Vt(t, e.pmSchema.nodes.blockContainer, e.pmSchema.nodes.blockGroup));
|
|
377
376
|
}
|
|
378
|
-
function
|
|
377
|
+
function Ut(e, t, n, r) {
|
|
379
378
|
let i = r.end, a = r.$to.end(r.depth);
|
|
380
379
|
if (i < a) {
|
|
381
380
|
let o = r.parent.child(r.endIndex - 1), s = o.lastChild && o.lastChild.type === n;
|
|
382
|
-
e.step(new
|
|
381
|
+
e.step(new E(i - (s ? 2 : 1), a, i, a, new T(w.from(t.create(null, n.create())), s ? 2 : 1, 0), +!s, !0)), r = new Be(e.doc.resolve(r.$from.pos), e.doc.resolve(a), r.depth);
|
|
383
382
|
}
|
|
384
383
|
let o = Ue(r);
|
|
385
384
|
if (o == null) return !1;
|
|
@@ -387,20 +386,20 @@ function Ft(e, t, n, r) {
|
|
|
387
386
|
let s = e.doc.resolve(e.mapping.map(i, -1) - 1);
|
|
388
387
|
return He(e.doc, s.pos) && s.nodeBefore.type === s.nodeAfter.type && e.join(s.pos), e.scrollIntoView(), !0;
|
|
389
388
|
}
|
|
390
|
-
function
|
|
389
|
+
function H(e, t, n) {
|
|
391
390
|
let { $from: r, $to: i } = e.selection, a = r.blockRange(i, (e) => e.childCount > 0 && (e.type.name === "blockGroup" || e.type.name === "column"));
|
|
392
|
-
return a && r.node(a.depth - 1).type === t ?
|
|
391
|
+
return a && r.node(a.depth - 1).type === t ? Ut(e, t, n, a) : !1;
|
|
393
392
|
}
|
|
394
|
-
function
|
|
395
|
-
return e.transact((t) =>
|
|
393
|
+
function Wt(e) {
|
|
394
|
+
return e.transact((t) => H(t, e.pmSchema.nodes.blockContainer, e.pmSchema.nodes.blockGroup));
|
|
396
395
|
}
|
|
397
|
-
function
|
|
396
|
+
function Gt(e) {
|
|
398
397
|
return e.transact((e) => {
|
|
399
398
|
let { bnBlock: t } = _(e);
|
|
400
399
|
return e.doc.resolve(t.beforePos).nodeBefore !== null;
|
|
401
400
|
});
|
|
402
401
|
}
|
|
403
|
-
function
|
|
402
|
+
function Kt(e) {
|
|
404
403
|
return e.transact((e) => {
|
|
405
404
|
let { bnBlock: t } = _(e);
|
|
406
405
|
return e.doc.resolve(t.beforePos).depth > 1;
|
|
@@ -408,23 +407,23 @@ function Rt(e) {
|
|
|
408
407
|
}
|
|
409
408
|
//#endregion
|
|
410
409
|
//#region src/api/blockManipulation/getBlock/getBlock.ts
|
|
411
|
-
function
|
|
410
|
+
function qt(e, t) {
|
|
412
411
|
let n = typeof t == "string" ? t : t.id, r = g(e), a = i(n, e);
|
|
413
412
|
if (a) return y(a.node, r);
|
|
414
413
|
}
|
|
415
|
-
function
|
|
414
|
+
function Jt(e, t) {
|
|
416
415
|
let n = i(typeof t == "string" ? t : t.id, e), r = g(e);
|
|
417
416
|
if (!n) return;
|
|
418
417
|
let a = e.resolve(n.posBeforeNode).nodeBefore;
|
|
419
418
|
if (a) return y(a, r);
|
|
420
419
|
}
|
|
421
|
-
function
|
|
420
|
+
function Yt(e, t) {
|
|
422
421
|
let n = i(typeof t == "string" ? t : t.id, e), r = g(e);
|
|
423
422
|
if (!n) return;
|
|
424
423
|
let a = e.resolve(n.posBeforeNode + n.node.nodeSize).nodeAfter;
|
|
425
424
|
if (a) return y(a, r);
|
|
426
425
|
}
|
|
427
|
-
function
|
|
426
|
+
function Xt(e, t) {
|
|
428
427
|
let n = typeof t == "string" ? t : t.id, r = g(e), a = i(n, e);
|
|
429
428
|
if (!a) return;
|
|
430
429
|
let o = e.resolve(a.posBeforeNode), s = o.node(), c = o.node(-1), l = c.type.name === "doc" ? void 0 : s.type.name === "blockGroup" ? c : s;
|
|
@@ -432,24 +431,24 @@ function Ht(e, t) {
|
|
|
432
431
|
}
|
|
433
432
|
//#endregion
|
|
434
433
|
//#region src/editor/managers/BlockManager.ts
|
|
435
|
-
var
|
|
434
|
+
var Zt = class {
|
|
436
435
|
constructor(e) {
|
|
437
436
|
this.editor = e;
|
|
438
437
|
}
|
|
439
438
|
get document() {
|
|
440
|
-
return this.editor.transact((e) =>
|
|
439
|
+
return this.editor.transact((e) => se(e.doc, this.editor.pmSchema));
|
|
441
440
|
}
|
|
442
441
|
getBlock(e) {
|
|
443
|
-
return this.editor.transact((t) =>
|
|
442
|
+
return this.editor.transact((t) => qt(t.doc, e));
|
|
444
443
|
}
|
|
445
444
|
getPrevBlock(e) {
|
|
446
|
-
return this.editor.transact((t) =>
|
|
445
|
+
return this.editor.transact((t) => Jt(t.doc, e));
|
|
447
446
|
}
|
|
448
447
|
getNextBlock(e) {
|
|
449
|
-
return this.editor.transact((t) =>
|
|
448
|
+
return this.editor.transact((t) => Yt(t.doc, e));
|
|
450
449
|
}
|
|
451
450
|
getParentBlock(e) {
|
|
452
|
-
return this.editor.transact((t) =>
|
|
451
|
+
return this.editor.transact((t) => Xt(t.doc, e));
|
|
453
452
|
}
|
|
454
453
|
forEachBlock(e, t = !1) {
|
|
455
454
|
let n = this.document.slice();
|
|
@@ -461,36 +460,36 @@ var Ut = class {
|
|
|
461
460
|
r(n);
|
|
462
461
|
}
|
|
463
462
|
insertBlocks(e, t, n = "before") {
|
|
464
|
-
return this.editor.transact((r) =>
|
|
463
|
+
return this.editor.transact((r) => bt(r, e, t, n));
|
|
465
464
|
}
|
|
466
465
|
updateBlock(e, t) {
|
|
467
466
|
return this.editor.transact((r) => n(r, e, t));
|
|
468
467
|
}
|
|
469
468
|
removeBlocks(e) {
|
|
470
|
-
return this.editor.transact((t) =>
|
|
469
|
+
return this.editor.transact((t) => B(t, e, []).removedBlocks);
|
|
471
470
|
}
|
|
472
471
|
replaceBlocks(e, t) {
|
|
473
|
-
return this.editor.transact((n) =>
|
|
472
|
+
return this.editor.transact((n) => B(n, e, t));
|
|
474
473
|
}
|
|
475
474
|
canNestBlock() {
|
|
476
|
-
return
|
|
475
|
+
return Gt(this.editor);
|
|
477
476
|
}
|
|
478
477
|
nestBlock() {
|
|
479
|
-
|
|
478
|
+
Ht(this.editor);
|
|
480
479
|
}
|
|
481
480
|
canUnnestBlock() {
|
|
482
|
-
return
|
|
481
|
+
return Kt(this.editor);
|
|
483
482
|
}
|
|
484
483
|
unnestBlock() {
|
|
485
|
-
|
|
484
|
+
Wt(this.editor);
|
|
486
485
|
}
|
|
487
486
|
moveBlocksUp() {
|
|
488
|
-
return
|
|
487
|
+
return zt(this.editor);
|
|
489
488
|
}
|
|
490
489
|
moveBlocksDown() {
|
|
491
|
-
return
|
|
490
|
+
return Bt(this.editor);
|
|
492
491
|
}
|
|
493
|
-
},
|
|
492
|
+
}, Qt = class extends Ie {
|
|
494
493
|
constructor(e) {
|
|
495
494
|
super(), this.editor = e, e.on("create", () => {
|
|
496
495
|
e._tiptapEditor.on("update", ({ transaction: t, appendedTransactions: n }) => {
|
|
@@ -513,8 +512,8 @@ var Ut = class {
|
|
|
513
512
|
}
|
|
514
513
|
onChange(e, t = !0) {
|
|
515
514
|
let n = ({ transaction: n, appendedTransactions: r }) => {
|
|
516
|
-
!t &&
|
|
517
|
-
return
|
|
515
|
+
!t && $t(n) || e(this.editor, { getChanges() {
|
|
516
|
+
return he(n, r);
|
|
518
517
|
} });
|
|
519
518
|
};
|
|
520
519
|
return this.on("onChange", n), () => {
|
|
@@ -523,7 +522,7 @@ var Ut = class {
|
|
|
523
522
|
}
|
|
524
523
|
onSelectionChange(e, t = !1) {
|
|
525
524
|
let n = (n) => {
|
|
526
|
-
!t &&
|
|
525
|
+
!t && $t(n.transaction) || e(this.editor);
|
|
527
526
|
};
|
|
528
527
|
return this.on("onSelectionChange", n), () => {
|
|
529
528
|
this.off("onSelectionChange", n);
|
|
@@ -540,30 +539,30 @@ var Ut = class {
|
|
|
540
539
|
};
|
|
541
540
|
}
|
|
542
541
|
};
|
|
543
|
-
function
|
|
542
|
+
function $t(e) {
|
|
544
543
|
return !!e.getMeta("y-sync$");
|
|
545
544
|
}
|
|
546
545
|
//#endregion
|
|
547
546
|
//#region src/api/parsers/html/util/nestedLists.ts
|
|
548
|
-
function
|
|
547
|
+
function en(e) {
|
|
549
548
|
return Array.prototype.indexOf.call(e.parentElement.childNodes, e);
|
|
550
549
|
}
|
|
551
|
-
function
|
|
550
|
+
function tn(e) {
|
|
552
551
|
return e.nodeType === 3 && !/\S/.test(e.nodeValue || "");
|
|
553
552
|
}
|
|
554
|
-
function
|
|
553
|
+
function nn(e) {
|
|
555
554
|
e.querySelectorAll("li > ul, li > ol").forEach((e) => {
|
|
556
|
-
let t =
|
|
555
|
+
let t = en(e), n = e.parentElement, r = Array.from(n.childNodes).slice(t + 1);
|
|
557
556
|
e.remove(), r.forEach((e) => {
|
|
558
557
|
e.remove();
|
|
559
558
|
}), n.insertAdjacentElement("afterend", e), r.reverse().forEach((t) => {
|
|
560
|
-
if (
|
|
559
|
+
if (tn(t)) return;
|
|
561
560
|
let n = document.createElement("li");
|
|
562
561
|
n.append(t), e.insertAdjacentElement("afterend", n);
|
|
563
562
|
}), n.childNodes.length === 0 && n.remove();
|
|
564
563
|
});
|
|
565
564
|
}
|
|
566
|
-
function
|
|
565
|
+
function rn(e) {
|
|
567
566
|
e.querySelectorAll("li + ul, li + ol").forEach((e) => {
|
|
568
567
|
let t = e.previousElementSibling, n = document.createElement("div");
|
|
569
568
|
t.insertAdjacentElement("afterend", n), n.append(t);
|
|
@@ -571,25 +570,25 @@ function Yt(e) {
|
|
|
571
570
|
for (r.setAttribute("data-node-type", "blockGroup"), n.append(r); n.nextElementSibling?.nodeName === "UL" || n.nextElementSibling?.nodeName === "OL";) r.append(n.nextElementSibling);
|
|
572
571
|
});
|
|
573
572
|
}
|
|
574
|
-
var
|
|
575
|
-
function
|
|
576
|
-
return
|
|
573
|
+
var an = null;
|
|
574
|
+
function on() {
|
|
575
|
+
return an ||= document.implementation.createHTMLDocument("title");
|
|
577
576
|
}
|
|
578
|
-
function
|
|
577
|
+
function sn(e) {
|
|
579
578
|
if (typeof e == "string") {
|
|
580
|
-
let t =
|
|
579
|
+
let t = on().createElement("div");
|
|
581
580
|
t.innerHTML = e, e = t;
|
|
582
581
|
}
|
|
583
|
-
return
|
|
582
|
+
return nn(e), rn(e), e;
|
|
584
583
|
}
|
|
585
584
|
//#endregion
|
|
586
585
|
//#region src/api/parsers/html/util/normalizeWhitespace.ts
|
|
587
|
-
function
|
|
586
|
+
function cn(e) {
|
|
588
587
|
let t = e.ownerDocument.createTreeWalker(e, 128), n;
|
|
589
588
|
for (; n = t.nextNode();) if (/^\s*notionvc:/.test(n.nodeValue || "")) return !0;
|
|
590
589
|
return !1;
|
|
591
590
|
}
|
|
592
|
-
function
|
|
591
|
+
function ln(e) {
|
|
593
592
|
let t = new Set(["PRE", "CODE"]), n = e.ownerDocument.createTreeWalker(e, 4, { acceptNode(n) {
|
|
594
593
|
let r = n.parentElement;
|
|
595
594
|
for (; r && r !== e;) {
|
|
@@ -601,21 +600,21 @@ function en(e) {
|
|
|
601
600
|
for (; i = n.nextNode();) r.push(i);
|
|
602
601
|
for (let e of r) e.nodeValue && /[\r\n]/.test(e.nodeValue) && (e.nodeValue = e.nodeValue.replace(/[ \t\r\n\f]+/g, " "));
|
|
603
602
|
}
|
|
604
|
-
function
|
|
605
|
-
|
|
603
|
+
function un(e) {
|
|
604
|
+
cn(e) || ln(e);
|
|
606
605
|
}
|
|
607
606
|
//#endregion
|
|
608
607
|
//#region src/api/parsers/html/parseHTML.ts
|
|
609
|
-
function
|
|
610
|
-
let n =
|
|
611
|
-
|
|
608
|
+
function U(e, t) {
|
|
609
|
+
let n = sn(e);
|
|
610
|
+
un(n);
|
|
612
611
|
let r = Le.fromSchema(t).parse(n, { topNode: t.nodes.blockGroup.create() }), i = [];
|
|
613
612
|
for (let e = 0; e < r.childCount; e++) i.push(y(r.child(e), t));
|
|
614
613
|
return i;
|
|
615
614
|
}
|
|
616
615
|
//#endregion
|
|
617
616
|
//#region src/api/parsers/markdown/parseMarkdown.ts
|
|
618
|
-
function
|
|
617
|
+
function dn(e, t) {
|
|
619
618
|
let n = t.value ? t.value : "", r = {};
|
|
620
619
|
t.lang && (r["data-language"] = t.lang);
|
|
621
620
|
let i = {
|
|
@@ -634,25 +633,25 @@ function nn(e, t) {
|
|
|
634
633
|
children: [i]
|
|
635
634
|
}, e.patch(t, i), i;
|
|
636
635
|
}
|
|
637
|
-
function
|
|
638
|
-
let n = String(t?.url || ""), r =
|
|
636
|
+
function fn(e, t) {
|
|
637
|
+
let n = String(t?.url || ""), r = {
|
|
639
638
|
type: "element",
|
|
640
639
|
tagName: "video",
|
|
641
640
|
properties: {
|
|
642
641
|
src: n,
|
|
643
|
-
"data-name":
|
|
642
|
+
"data-name": t?.title ? String(t.title) : void 0,
|
|
644
643
|
"data-url": n,
|
|
645
644
|
controls: !0
|
|
646
645
|
},
|
|
647
646
|
children: []
|
|
648
647
|
};
|
|
649
|
-
return e.patch?.(t,
|
|
648
|
+
return e.patch?.(t, r), r = e.applyData ? e.applyData(t, r) : r, r;
|
|
650
649
|
}
|
|
651
|
-
function
|
|
652
|
-
return
|
|
653
|
-
...
|
|
654
|
-
image: (t, n) => e(String(n?.url || "")) ?
|
|
655
|
-
code:
|
|
650
|
+
function W(t) {
|
|
651
|
+
return ct().use(lt).use(st).use(ut, { handlers: {
|
|
652
|
+
...dt,
|
|
653
|
+
image: (t, n) => e(String(n?.url || "")) ? fn(t, n) : dt.image(t, n),
|
|
654
|
+
code: dn,
|
|
656
655
|
blockquote: (e, t) => {
|
|
657
656
|
let n = {
|
|
658
657
|
type: "element",
|
|
@@ -662,14 +661,14 @@ function q(t) {
|
|
|
662
661
|
};
|
|
663
662
|
return e.patch(t, n), e.applyData(t, n);
|
|
664
663
|
}
|
|
665
|
-
} }).use(
|
|
664
|
+
} }).use(ft).processSync(t).value;
|
|
666
665
|
}
|
|
667
|
-
function
|
|
668
|
-
return
|
|
666
|
+
function pn(e, t) {
|
|
667
|
+
return U(W(e), t);
|
|
669
668
|
}
|
|
670
669
|
//#endregion
|
|
671
670
|
//#region src/editor/managers/ExportManager.ts
|
|
672
|
-
var
|
|
671
|
+
var mn = class {
|
|
673
672
|
constructor(e) {
|
|
674
673
|
this.editor = e;
|
|
675
674
|
}
|
|
@@ -677,16 +676,16 @@ var on = class {
|
|
|
677
676
|
return xe(this.editor.pmSchema, this.editor).exportBlocks(e, {});
|
|
678
677
|
}
|
|
679
678
|
blocksToFullHTML(e = this.editor.document) {
|
|
680
|
-
return
|
|
679
|
+
return Mt(this.editor.pmSchema, this.editor).serializeBlocks(e, {});
|
|
681
680
|
}
|
|
682
681
|
tryParseHTMLToBlocks(e) {
|
|
683
|
-
return
|
|
682
|
+
return U(e, this.editor.pmSchema);
|
|
684
683
|
}
|
|
685
684
|
blocksToMarkdownLossy(e = this.editor.document) {
|
|
686
685
|
return Oe(e, this.editor.pmSchema, this.editor, {});
|
|
687
686
|
}
|
|
688
687
|
tryParseMarkdownToBlocks(e) {
|
|
689
|
-
return
|
|
688
|
+
return pn(e, this.editor.pmSchema);
|
|
690
689
|
}
|
|
691
690
|
pasteHTML(e, t = !1) {
|
|
692
691
|
let n = e;
|
|
@@ -700,10 +699,355 @@ var on = class {
|
|
|
700
699
|
return this.editor.prosemirrorView?.pasteText(e);
|
|
701
700
|
}
|
|
702
701
|
pasteMarkdown(e) {
|
|
703
|
-
let t =
|
|
702
|
+
let t = W(e);
|
|
704
703
|
return this.pasteHTML(t);
|
|
705
704
|
}
|
|
706
|
-
},
|
|
705
|
+
}, hn = "aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2";
|
|
706
|
+
//#endregion
|
|
707
|
+
//#region src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts
|
|
708
|
+
function gn(e) {
|
|
709
|
+
let t = [], n = [], r = 0;
|
|
710
|
+
for (; r < e.length;) {
|
|
711
|
+
let i = 0;
|
|
712
|
+
for (; r + i < e.length && e.charCodeAt(r + i) >= 48 && e.charCodeAt(r + i) <= 57;) i++;
|
|
713
|
+
if (i > 0) {
|
|
714
|
+
t.push(n.join(""));
|
|
715
|
+
let a = parseInt(e.substring(r, r + i), 10);
|
|
716
|
+
for (; a-- > 0;) n.pop();
|
|
717
|
+
r += i;
|
|
718
|
+
} else n.push(e[r]), r++;
|
|
719
|
+
}
|
|
720
|
+
return t;
|
|
721
|
+
}
|
|
722
|
+
var _n = new Set(gn(hn)), vn = new Set(["localhost"]), yn = /[.,;:!?"']+$/, bn = /(?:https?|ftp|ftps):\/\/[^\s]+/g, xn = /mailto:[^\s]+/g, Sn = /[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}/g, Cn = /(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(?::\d{1,5})?(?:[/?#][^\s]*)?/g;
|
|
723
|
+
function wn(e) {
|
|
724
|
+
let t = e, n = !0;
|
|
725
|
+
for (; n;) {
|
|
726
|
+
n = !1;
|
|
727
|
+
let e = t;
|
|
728
|
+
t = t.replace(yn, ""), t !== e && (n = !0);
|
|
729
|
+
for (let [e, r] of [["(", ")"], ["[", "]"]]) for (; t.endsWith(r);) {
|
|
730
|
+
let i = Tn(t, e);
|
|
731
|
+
if (Tn(t, r) > i) t = t.slice(0, -1), n = !0;
|
|
732
|
+
else break;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
return t;
|
|
736
|
+
}
|
|
737
|
+
function Tn(e, t) {
|
|
738
|
+
let n = 0;
|
|
739
|
+
for (let r = 0; r < e.length; r++) e[r] === t && n++;
|
|
740
|
+
return n;
|
|
741
|
+
}
|
|
742
|
+
function En(e) {
|
|
743
|
+
let t = e.split(".");
|
|
744
|
+
return t[t.length - 1].toLowerCase();
|
|
745
|
+
}
|
|
746
|
+
function Dn(e) {
|
|
747
|
+
let t = En(e);
|
|
748
|
+
return _n.has(t);
|
|
749
|
+
}
|
|
750
|
+
function On(e, t, n) {
|
|
751
|
+
return t === "email" ? "mailto:" + e : /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(e) || /^mailto:/i.test(e) ? e : n + "://" + e;
|
|
752
|
+
}
|
|
753
|
+
function kn(e, t) {
|
|
754
|
+
if (!e) return [];
|
|
755
|
+
let n = t?.defaultProtocol || "http", r = [];
|
|
756
|
+
for (let t of e.matchAll(bn)) r.push({
|
|
757
|
+
type: "url",
|
|
758
|
+
value: t[0],
|
|
759
|
+
start: t.index,
|
|
760
|
+
end: t.index + t[0].length
|
|
761
|
+
});
|
|
762
|
+
for (let t of e.matchAll(xn)) r.push({
|
|
763
|
+
type: "url",
|
|
764
|
+
value: t[0],
|
|
765
|
+
start: t.index,
|
|
766
|
+
end: t.index + t[0].length
|
|
767
|
+
});
|
|
768
|
+
for (let t of e.matchAll(Sn)) r.push({
|
|
769
|
+
type: "email",
|
|
770
|
+
value: t[0],
|
|
771
|
+
start: t.index,
|
|
772
|
+
end: t.index + t[0].length
|
|
773
|
+
});
|
|
774
|
+
for (let t of e.matchAll(Cn)) r.push({
|
|
775
|
+
type: "url",
|
|
776
|
+
value: t[0],
|
|
777
|
+
start: t.index,
|
|
778
|
+
end: t.index + t[0].length
|
|
779
|
+
});
|
|
780
|
+
r.sort((e, t) => e.start - t.start || t.end - e.end);
|
|
781
|
+
let i = [], a = -1;
|
|
782
|
+
for (let e of r) e.start >= a && (i.push(e), a = e.end);
|
|
783
|
+
let o = [];
|
|
784
|
+
for (let e of i) {
|
|
785
|
+
let t = wn(e.value);
|
|
786
|
+
if (!t) continue;
|
|
787
|
+
let r = e.start, i = r + t.length;
|
|
788
|
+
if (e.type === "url" && !/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t)) {
|
|
789
|
+
let e = new URL("http://" + t).hostname;
|
|
790
|
+
if (!Dn(e)) continue;
|
|
791
|
+
}
|
|
792
|
+
if (e.type === "email") {
|
|
793
|
+
let e = t.split("@")[1];
|
|
794
|
+
if (!Dn(e)) continue;
|
|
795
|
+
}
|
|
796
|
+
let a = On(t, e.type, n);
|
|
797
|
+
o.push({
|
|
798
|
+
type: e.type,
|
|
799
|
+
value: t,
|
|
800
|
+
isLink: !0,
|
|
801
|
+
href: a,
|
|
802
|
+
start: r,
|
|
803
|
+
end: i
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
return o;
|
|
807
|
+
}
|
|
808
|
+
function An(e, t = "http") {
|
|
809
|
+
if (!e) return [q(e, 0, 0)];
|
|
810
|
+
for (let [n, r] of [
|
|
811
|
+
["(", ")"],
|
|
812
|
+
["[", "]"],
|
|
813
|
+
["{", "}"]
|
|
814
|
+
]) if (e.startsWith(n) && e.endsWith(r) && e.length > 2) {
|
|
815
|
+
let i = e.slice(1, -1);
|
|
816
|
+
if (G(i)) return [
|
|
817
|
+
q(n, 0, 1),
|
|
818
|
+
K(i, 1, 1 + i.length, t),
|
|
819
|
+
q(r, 1 + i.length, e.length)
|
|
820
|
+
];
|
|
821
|
+
}
|
|
822
|
+
if (e.endsWith(".") && e.length > 1) {
|
|
823
|
+
let n = e.slice(0, -1);
|
|
824
|
+
if (G(n)) return [K(n, 0, n.length, t), q(".", n.length, e.length)];
|
|
825
|
+
}
|
|
826
|
+
return G(e) ? [K(e, 0, e.length, t)] : [q(e, 0, e.length)];
|
|
827
|
+
}
|
|
828
|
+
function G(e) {
|
|
829
|
+
if (/^(?:https?|ftp|ftps):\/\/[^\s]+$/.test(e) || /^mailto:[^\s]+$/.test(e) || vn.has(e.toLowerCase())) return !0;
|
|
830
|
+
let t = e.match(/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+([a-zA-Z]{2,})(?::\d{1,5})?(?:[/?#][^\s]*)?$/);
|
|
831
|
+
if (t) {
|
|
832
|
+
let e = t[1].toLowerCase();
|
|
833
|
+
if (_n.has(e)) return !0;
|
|
834
|
+
}
|
|
835
|
+
return !1;
|
|
836
|
+
}
|
|
837
|
+
function K(e, t, n, r) {
|
|
838
|
+
let i = e.includes("@") && !e.includes("://") && !e.startsWith("mailto:") ? "email" : "url";
|
|
839
|
+
return {
|
|
840
|
+
type: i,
|
|
841
|
+
value: e,
|
|
842
|
+
isLink: !0,
|
|
843
|
+
href: On(e, i, r),
|
|
844
|
+
start: t,
|
|
845
|
+
end: n
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
function q(e, t, n) {
|
|
849
|
+
return {
|
|
850
|
+
type: "text",
|
|
851
|
+
value: e,
|
|
852
|
+
isLink: !1,
|
|
853
|
+
href: e,
|
|
854
|
+
start: t,
|
|
855
|
+
end: n
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
//#endregion
|
|
859
|
+
//#region src/extensions/tiptap-extensions/Link/helpers/whitespace.ts
|
|
860
|
+
var J = "[\0- \xA0 -\u2029 ]", jn = new RegExp(J), Mn = RegExp(`${J}$`), Nn = new RegExp(J, "g");
|
|
861
|
+
//#endregion
|
|
862
|
+
//#region src/extensions/tiptap-extensions/Link/helpers/autolink.ts
|
|
863
|
+
function Pn(e) {
|
|
864
|
+
return e.length === 1 ? e[0].isLink : e.length === 3 && e[1].isLink ? ["()", "[]"].includes(e[0].value + e[2].value) : !1;
|
|
865
|
+
}
|
|
866
|
+
function Fn(e) {
|
|
867
|
+
return new at({
|
|
868
|
+
key: new ot("autolink"),
|
|
869
|
+
appendTransaction: (t, n, r) => {
|
|
870
|
+
let i = t.some((e) => e.docChanged) && !n.doc.eq(r.doc), a = t.some((e) => e.getMeta("preventAutolink"));
|
|
871
|
+
if (!i || a) return;
|
|
872
|
+
let { tr: o } = r;
|
|
873
|
+
if (Xe(Ge(n.doc, [...t])).forEach(({ newRange: t }) => {
|
|
874
|
+
let n = qe(r.doc, t, (e) => e.isTextblock), i, a;
|
|
875
|
+
if (n.length > 1) i = n[0], a = r.doc.textBetween(i.pos, i.pos + i.node.nodeSize, void 0, " ");
|
|
876
|
+
else if (n.length) {
|
|
877
|
+
let e = r.doc.textBetween(t.from, t.to, " ", " ");
|
|
878
|
+
if (!Mn.test(e)) return;
|
|
879
|
+
i = n[0], a = r.doc.textBetween(i.pos, t.to, void 0, " ");
|
|
880
|
+
}
|
|
881
|
+
if (i && a) {
|
|
882
|
+
let t = a.split(jn).filter(Boolean);
|
|
883
|
+
if (t.length <= 0) return;
|
|
884
|
+
let n = t[t.length - 1], s = i.pos + a.lastIndexOf(n);
|
|
885
|
+
if (!n) return;
|
|
886
|
+
let c = An(n, e.defaultProtocol);
|
|
887
|
+
if (!Pn(c)) return;
|
|
888
|
+
c.filter((e) => e.isLink).map((e) => ({
|
|
889
|
+
...e,
|
|
890
|
+
from: s + e.start + 1,
|
|
891
|
+
to: s + e.end + 1
|
|
892
|
+
})).filter((e) => r.schema.marks.code ? !r.doc.rangeHasMark(e.from, e.to, r.schema.marks.code) : !0).filter((t) => e.validate(t.value)).filter((t) => e.shouldAutoLink(t.value)).forEach((t) => {
|
|
893
|
+
Qe(t.from, t.to, r.doc).some((t) => t.mark.type === e.type) || o.addMark(t.from, t.to, e.type.create({ href: t.href }));
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
}), o.steps.length) return o;
|
|
897
|
+
}
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
//#endregion
|
|
901
|
+
//#region src/extensions/tiptap-extensions/Link/helpers/clickHandler.ts
|
|
902
|
+
function In(e) {
|
|
903
|
+
return new at({
|
|
904
|
+
key: new ot("handleClickLink"),
|
|
905
|
+
props: { handleClick: (t, n, r) => {
|
|
906
|
+
if (r.button !== 0 || !t.editable) return !1;
|
|
907
|
+
let i = null;
|
|
908
|
+
if (r.target instanceof HTMLAnchorElement && r.target.getAttribute("data-inline-content-type") === "link") i = r.target;
|
|
909
|
+
else {
|
|
910
|
+
let t = r.target;
|
|
911
|
+
if (!t) return !1;
|
|
912
|
+
let n = e.tiptapEditor.view.dom;
|
|
913
|
+
i = t.closest("a[data-inline-content-type=\"link\"]"), i && !n.contains(i) && (i = null);
|
|
914
|
+
}
|
|
915
|
+
if (!i) return !1;
|
|
916
|
+
if (e.onClick) {
|
|
917
|
+
if (!e.editor) throw Error("BlockNoteEditor not found in Link click handler");
|
|
918
|
+
return e.onClick(r, e.editor) ?? !0;
|
|
919
|
+
}
|
|
920
|
+
let a = Ye(t.state, e.type.name), o = i.href ?? a.href, s = i.target ?? a.target;
|
|
921
|
+
return o ? (window.open(o, s), !0) : !1;
|
|
922
|
+
} }
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
//#endregion
|
|
926
|
+
//#region src/extensions/tiptap-extensions/Link/helpers/pasteHandler.ts
|
|
927
|
+
function Ln(e) {
|
|
928
|
+
return new at({
|
|
929
|
+
key: new ot("handlePasteLink"),
|
|
930
|
+
props: { handlePaste: (t, n, r) => {
|
|
931
|
+
let { shouldAutoLink: i, isValidLink: a } = e, { state: o } = t, { selection: s } = o, { empty: c } = s;
|
|
932
|
+
if (c) return !1;
|
|
933
|
+
let l = "";
|
|
934
|
+
r.content.forEach((e) => {
|
|
935
|
+
l += e.textContent;
|
|
936
|
+
});
|
|
937
|
+
let u = kn(l, { defaultProtocol: e.defaultProtocol }).find((e) => e.isLink && e.value === l);
|
|
938
|
+
return !l || !u || !a(u.value) || i !== void 0 && !i(u.value) ? !1 : e.editor.commands.setMark(e.type, { href: u.href });
|
|
939
|
+
} }
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
//#endregion
|
|
943
|
+
//#region src/extensions/tiptap-extensions/Link/link.ts
|
|
944
|
+
var Y = "https", X = {
|
|
945
|
+
target: "_blank",
|
|
946
|
+
rel: "noopener noreferrer nofollow",
|
|
947
|
+
className: "bn-inline-content-section",
|
|
948
|
+
"data-inline-content-type": "link"
|
|
949
|
+
}, Rn = /^(?:(?:http|https|ftp|ftps|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z0-9+.\-]+(?:[^a-z+.\-:]|$))/i;
|
|
950
|
+
function zn(e) {
|
|
951
|
+
if (!e) return !0;
|
|
952
|
+
let t = e.replace(Nn, "");
|
|
953
|
+
return Rn.test(t);
|
|
954
|
+
}
|
|
955
|
+
function Z(e) {
|
|
956
|
+
let t = /^[a-z][a-z0-9+.-]*:\/\//i.test(e), n = /^[a-z][a-z0-9+.-]*:/i.test(e);
|
|
957
|
+
if (t || n && !e.includes("@")) return !0;
|
|
958
|
+
let r = (e.includes("@") ? e.split("@").pop() : e).split(/[/?#:]/)[0];
|
|
959
|
+
return !(/^\d{1,3}(\.\d{1,3}){3}$/.test(r) || !/\./.test(r));
|
|
960
|
+
}
|
|
961
|
+
var Bn = O.create({
|
|
962
|
+
name: "link",
|
|
963
|
+
priority: 1e3,
|
|
964
|
+
keepOnSplit: !1,
|
|
965
|
+
exitable: !0,
|
|
966
|
+
inclusive: !1,
|
|
967
|
+
addOptions() {
|
|
968
|
+
return {
|
|
969
|
+
HTMLAttributes: {},
|
|
970
|
+
editor: void 0,
|
|
971
|
+
onClick: void 0,
|
|
972
|
+
isValidLink: zn
|
|
973
|
+
};
|
|
974
|
+
},
|
|
975
|
+
addAttributes() {
|
|
976
|
+
return {
|
|
977
|
+
href: {
|
|
978
|
+
default: null,
|
|
979
|
+
parseHTML(e) {
|
|
980
|
+
return e.getAttribute("href");
|
|
981
|
+
}
|
|
982
|
+
},
|
|
983
|
+
target: { default: X.target },
|
|
984
|
+
rel: { default: X.rel }
|
|
985
|
+
};
|
|
986
|
+
},
|
|
987
|
+
parseHTML() {
|
|
988
|
+
let e = this.options.isValidLink;
|
|
989
|
+
return [{
|
|
990
|
+
tag: "a[href]",
|
|
991
|
+
getAttrs: (t) => {
|
|
992
|
+
let n = t.getAttribute("href");
|
|
993
|
+
return !n || !e(n) ? !1 : null;
|
|
994
|
+
}
|
|
995
|
+
}];
|
|
996
|
+
},
|
|
997
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
998
|
+
return this.options.isValidLink(e.href) ? [
|
|
999
|
+
"a",
|
|
1000
|
+
j(X, e),
|
|
1001
|
+
0
|
|
1002
|
+
] : [
|
|
1003
|
+
"a",
|
|
1004
|
+
j(X, {
|
|
1005
|
+
...e,
|
|
1006
|
+
href: ""
|
|
1007
|
+
}),
|
|
1008
|
+
0
|
|
1009
|
+
];
|
|
1010
|
+
},
|
|
1011
|
+
addPasteRules() {
|
|
1012
|
+
let e = this.options.isValidLink;
|
|
1013
|
+
return [tt({
|
|
1014
|
+
find: (t) => {
|
|
1015
|
+
let n = [];
|
|
1016
|
+
if (t) {
|
|
1017
|
+
let r = kn(t, { defaultProtocol: Y }).filter((t) => t.isLink && e(t.value));
|
|
1018
|
+
for (let e of r) Z(e.value) && n.push({
|
|
1019
|
+
text: e.value,
|
|
1020
|
+
data: { href: e.href },
|
|
1021
|
+
index: e.start
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
return n;
|
|
1025
|
+
},
|
|
1026
|
+
type: this.type,
|
|
1027
|
+
getAttributes: (e) => ({ href: e.data?.href })
|
|
1028
|
+
})];
|
|
1029
|
+
},
|
|
1030
|
+
addProseMirrorPlugins() {
|
|
1031
|
+
let e = [];
|
|
1032
|
+
return e.push(Fn({
|
|
1033
|
+
type: this.type,
|
|
1034
|
+
defaultProtocol: Y,
|
|
1035
|
+
validate: this.options.isValidLink,
|
|
1036
|
+
shouldAutoLink: Z
|
|
1037
|
+
})), e.push(In({
|
|
1038
|
+
type: this.type,
|
|
1039
|
+
tiptapEditor: this.editor,
|
|
1040
|
+
editor: this.options.editor,
|
|
1041
|
+
onClick: this.options.onClick
|
|
1042
|
+
})), e.push(Ln({
|
|
1043
|
+
editor: this.editor,
|
|
1044
|
+
defaultProtocol: Y,
|
|
1045
|
+
type: this.type,
|
|
1046
|
+
shouldAutoLink: Z,
|
|
1047
|
+
isValidLink: this.options.isValidLink
|
|
1048
|
+
})), e;
|
|
1049
|
+
}
|
|
1050
|
+
}), Vn = [
|
|
707
1051
|
"vscode-editor-data",
|
|
708
1052
|
"blocknote/html",
|
|
709
1053
|
"text/markdown",
|
|
@@ -713,21 +1057,21 @@ var on = class {
|
|
|
713
1057
|
];
|
|
714
1058
|
//#endregion
|
|
715
1059
|
//#region src/api/clipboard/fromClipboard/handleFileInsertion.ts
|
|
716
|
-
function
|
|
1060
|
+
function Hn(e, t) {
|
|
717
1061
|
if (!e.startsWith(".") || !t.startsWith(".")) throw Error("The strings provided are not valid file extensions.");
|
|
718
1062
|
return e === t;
|
|
719
1063
|
}
|
|
720
|
-
function
|
|
1064
|
+
function Un(e, t) {
|
|
721
1065
|
let n = e.split("/"), r = t.split("/");
|
|
722
1066
|
if (n.length !== 2) throw Error(`The string ${e} is not a valid MIME type.`);
|
|
723
1067
|
if (r.length !== 2) throw Error(`The string ${t} is not a valid MIME type.`);
|
|
724
1068
|
return n[1] === "*" || r[1] === "*" ? n[0] === r[0] : (n[0] === "*" || r[0] === "*" || n[0] === r[0]) && n[1] === r[1];
|
|
725
1069
|
}
|
|
726
|
-
function
|
|
1070
|
+
function Wn(e, t, n, r = "after") {
|
|
727
1071
|
let i;
|
|
728
1072
|
return i = Array.isArray(t.content) && t.content.length === 0 ? e.updateBlock(t, n).id : e.insertBlocks([n], t, r)[0].id, i;
|
|
729
1073
|
}
|
|
730
|
-
async function
|
|
1074
|
+
async function Gn(e, t) {
|
|
731
1075
|
if (!t.uploadFile) {
|
|
732
1076
|
console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");
|
|
733
1077
|
return;
|
|
@@ -735,7 +1079,7 @@ async function un(e, t) {
|
|
|
735
1079
|
let n = "dataTransfer" in e ? e.dataTransfer : e.clipboardData;
|
|
736
1080
|
if (n === null) return;
|
|
737
1081
|
let r = null;
|
|
738
|
-
for (let e of
|
|
1082
|
+
for (let e of Vn) if (n.types.includes(e)) {
|
|
739
1083
|
r = e;
|
|
740
1084
|
break;
|
|
741
1085
|
}
|
|
@@ -747,7 +1091,7 @@ async function un(e, t) {
|
|
|
747
1091
|
let r = "file";
|
|
748
1092
|
for (let e of Object.values(t.schema.blockSpecs)) for (let t of e.implementation.meta?.fileBlockAccept || []) {
|
|
749
1093
|
let a = t.startsWith("."), o = i[n].getAsFile();
|
|
750
|
-
if (o && (!a && o.type &&
|
|
1094
|
+
if (o && (!a && o.type && Un(i[n].type, t) || a && Hn("." + o.name.split(".").pop(), t))) {
|
|
751
1095
|
r = e.config.type;
|
|
752
1096
|
break;
|
|
753
1097
|
}
|
|
@@ -760,7 +1104,7 @@ async function un(e, t) {
|
|
|
760
1104
|
}, i;
|
|
761
1105
|
if (e.type === "paste") {
|
|
762
1106
|
let e = t.getTextCursorPosition().block;
|
|
763
|
-
i =
|
|
1107
|
+
i = Wn(t, e, n);
|
|
764
1108
|
} else if (e.type === "drop") {
|
|
765
1109
|
let r = {
|
|
766
1110
|
left: e.clientX,
|
|
@@ -768,8 +1112,8 @@ async function un(e, t) {
|
|
|
768
1112
|
}, a = t.prosemirrorView.posAtCoords(r);
|
|
769
1113
|
if (!a) return;
|
|
770
1114
|
i = t.transact((e) => {
|
|
771
|
-
let i =
|
|
772
|
-
return
|
|
1115
|
+
let i = S(e.doc, a.pos), o = (t.domElement?.querySelector(`[data-id="${i.node.attrs.id}"]`))?.getBoundingClientRect();
|
|
1116
|
+
return Wn(t, t.getBlock(i.node.attrs.id), n, o && (o.top + o.bottom) / 2 > r.top ? "before" : "after");
|
|
773
1117
|
});
|
|
774
1118
|
} else return;
|
|
775
1119
|
let o = await t.uploadFile(a, i), s = typeof o == "string" ? { props: { url: o } } : { ...o };
|
|
@@ -780,23 +1124,23 @@ async function un(e, t) {
|
|
|
780
1124
|
}
|
|
781
1125
|
//#endregion
|
|
782
1126
|
//#region src/api/clipboard/fromClipboard/fileDropExtension.ts
|
|
783
|
-
var
|
|
1127
|
+
var Kn = (e) => D.create({
|
|
784
1128
|
name: "dropFile",
|
|
785
1129
|
addProseMirrorPlugins() {
|
|
786
|
-
return [new
|
|
1130
|
+
return [new N({ props: { handleDOMEvents: { drop(t, n) {
|
|
787
1131
|
if (!e.isEditable) return;
|
|
788
1132
|
let r = null;
|
|
789
|
-
for (let e of
|
|
1133
|
+
for (let e of Vn) if (n.dataTransfer.types.includes(e)) {
|
|
790
1134
|
r = e;
|
|
791
1135
|
break;
|
|
792
1136
|
}
|
|
793
|
-
return r === null ? !0 : r === "Files" ? (
|
|
1137
|
+
return r === null ? !0 : r === "Files" ? (Gn(n, e), !0) : !1;
|
|
794
1138
|
} } } })];
|
|
795
1139
|
}
|
|
796
|
-
}),
|
|
1140
|
+
}), qn = /(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/, Jn = /(_|__|\*|\*\*|~~|==|\+\+)(?!\s)(?:[^\s](?:.{0,62}[^\s])?|\S)(?=\1)/, Yn = /\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/, Xn = /(?:\s|^)`(?!\s)(?:[^\s`](?:[^`]{0,46}[^\s`])?|[^\s`])`([^\w]|$)/, Zn = /(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/, Qn = /(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/, $n = /\n{2} {0,3}-{2,48}\n{2}/, er = /(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/, tr = /(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/, nr = /(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/, rr = /^\s*\|(.+\|)+\s*$/m, ir = /^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m, ar = /^\s*\|(.+\|)+\s*$/m, or = (e) => qn.test(e) || Jn.test(e) || Yn.test(e) || Xn.test(e) || Zn.test(e) || Qn.test(e) || $n.test(e) || er.test(e) || tr.test(e) || nr.test(e) || rr.test(e) || ir.test(e) || ar.test(e);
|
|
797
1141
|
//#endregion
|
|
798
1142
|
//#region src/api/clipboard/fromClipboard/handleVSCodePaste.ts
|
|
799
|
-
async function
|
|
1143
|
+
async function sr(e, t) {
|
|
800
1144
|
let { schema: n } = t.state;
|
|
801
1145
|
if (!e.clipboardData) return !1;
|
|
802
1146
|
let r = e.clipboardData.getData("text/plain");
|
|
@@ -807,36 +1151,36 @@ async function En(e, t) {
|
|
|
807
1151
|
}
|
|
808
1152
|
//#endregion
|
|
809
1153
|
//#region src/api/clipboard/fromClipboard/pasteExtension.ts
|
|
810
|
-
function
|
|
1154
|
+
function cr({ event: e, editor: t, prioritizeMarkdownOverHTML: n, plainTextAsMarkdown: r }) {
|
|
811
1155
|
if (t.transact((e) => e.selection.$from.parent.type.spec.code && e.selection.$to.parent.type.spec.code)) {
|
|
812
1156
|
let n = e.clipboardData?.getData("text/plain");
|
|
813
1157
|
if (n) return t.pasteText(n), !0;
|
|
814
1158
|
}
|
|
815
1159
|
let i;
|
|
816
|
-
for (let t of
|
|
1160
|
+
for (let t of Vn) if (e.clipboardData.types.includes(t)) {
|
|
817
1161
|
i = t;
|
|
818
1162
|
break;
|
|
819
1163
|
}
|
|
820
1164
|
if (!i) return !0;
|
|
821
|
-
if (i === "vscode-editor-data") return
|
|
822
|
-
if (i === "Files") return
|
|
1165
|
+
if (i === "vscode-editor-data") return sr(e, t.prosemirrorView), !0;
|
|
1166
|
+
if (i === "Files") return Gn(e, t), !0;
|
|
823
1167
|
let a = e.clipboardData.getData(i);
|
|
824
1168
|
if (i === "blocknote/html") return t.pasteHTML(a, !0), !0;
|
|
825
1169
|
if (i === "text/markdown") return t.pasteMarkdown(a), !0;
|
|
826
1170
|
if (n) {
|
|
827
1171
|
let n = e.clipboardData.getData("text/plain");
|
|
828
|
-
if (
|
|
1172
|
+
if (or(n)) return t.pasteMarkdown(n), !0;
|
|
829
1173
|
}
|
|
830
1174
|
return i === "text/html" ? (t.pasteHTML(a), !0) : r ? (t.pasteMarkdown(a), !0) : (t.pasteText(a), !0);
|
|
831
1175
|
}
|
|
832
|
-
var
|
|
1176
|
+
var lr = (e, t) => D.create({
|
|
833
1177
|
name: "pasteFromClipboard",
|
|
834
1178
|
addProseMirrorPlugins() {
|
|
835
|
-
return [new
|
|
1179
|
+
return [new N({ props: { handleDOMEvents: { paste(n, r) {
|
|
836
1180
|
if (r.preventDefault(), e.isEditable) return t({
|
|
837
1181
|
event: r,
|
|
838
1182
|
editor: e,
|
|
839
|
-
defaultPasteHandler: ({ prioritizeMarkdownOverHTML: t = !0, plainTextAsMarkdown: n = !0 } = {}) =>
|
|
1183
|
+
defaultPasteHandler: ({ prioritizeMarkdownOverHTML: t = !0, plainTextAsMarkdown: n = !0 } = {}) => cr({
|
|
840
1184
|
event: r,
|
|
841
1185
|
editor: e,
|
|
842
1186
|
prioritizeMarkdownOverHTML: t,
|
|
@@ -848,8 +1192,8 @@ var On = (e, t) => k.create({
|
|
|
848
1192
|
});
|
|
849
1193
|
//#endregion
|
|
850
1194
|
//#region src/api/clipboard/toClipboard/copyExtension.ts
|
|
851
|
-
function
|
|
852
|
-
let r = !1, i = e.state.selection instanceof
|
|
1195
|
+
function ur(e, t, n) {
|
|
1196
|
+
let r = !1, i = e.state.selection instanceof L;
|
|
853
1197
|
if (!i) {
|
|
854
1198
|
let n = e.state.doc.slice(e.state.selection.from, e.state.selection.to, !1).content, i = [];
|
|
855
1199
|
for (let e = 0; e < n.childCount; e++) i.push(n.child(e));
|
|
@@ -861,7 +1205,7 @@ function kn(e, t, n) {
|
|
|
861
1205
|
let e = re(t, n.schema.inlineContentSchema, n.schema.styleSchema);
|
|
862
1206
|
a = `<table>${o.exportInlineContent(e, {})}</table>`;
|
|
863
1207
|
} else if (r) {
|
|
864
|
-
let e =
|
|
1208
|
+
let e = le(t, n.schema.inlineContentSchema, n.schema.styleSchema);
|
|
865
1209
|
a = o.exportInlineContent(e, {});
|
|
866
1210
|
} else {
|
|
867
1211
|
let e = Se(t);
|
|
@@ -869,16 +1213,16 @@ function kn(e, t, n) {
|
|
|
869
1213
|
}
|
|
870
1214
|
return a;
|
|
871
1215
|
}
|
|
872
|
-
function
|
|
873
|
-
"node" in e.state.selection && e.state.selection.node.type.spec.group === "blockContent" && t.transact((t) => t.setSelection(new
|
|
874
|
-
let n = e.serializeForClipboard(e.state.selection.content()).dom.innerHTML, r = e.state.selection.content().content, i =
|
|
1216
|
+
function dr(e, t) {
|
|
1217
|
+
"node" in e.state.selection && e.state.selection.node.type.spec.group === "blockContent" && t.transact((t) => t.setSelection(new M(t.doc.resolve(e.state.selection.from - 1))));
|
|
1218
|
+
let n = e.serializeForClipboard(e.state.selection.content()).dom.innerHTML, r = e.state.selection.content().content, i = ur(e, r, t);
|
|
875
1219
|
return {
|
|
876
1220
|
clipboardHTML: n,
|
|
877
1221
|
externalHTML: i,
|
|
878
|
-
markdown:
|
|
1222
|
+
markdown: ye(i)
|
|
879
1223
|
};
|
|
880
1224
|
}
|
|
881
|
-
var
|
|
1225
|
+
var fr = () => {
|
|
882
1226
|
let e = window.getSelection();
|
|
883
1227
|
if (!e || e.isCollapsed) return !0;
|
|
884
1228
|
let t = e.focusNode;
|
|
@@ -887,29 +1231,29 @@ var An = () => {
|
|
|
887
1231
|
t = t.parentElement;
|
|
888
1232
|
}
|
|
889
1233
|
return !1;
|
|
890
|
-
},
|
|
1234
|
+
}, pr = (e, t, n) => {
|
|
891
1235
|
n.preventDefault(), n.clipboardData.clearData();
|
|
892
|
-
let { clipboardHTML: r, externalHTML: i, markdown: a } =
|
|
1236
|
+
let { clipboardHTML: r, externalHTML: i, markdown: a } = dr(t, e);
|
|
893
1237
|
n.clipboardData.setData("blocknote/html", r), n.clipboardData.setData("text/html", i), n.clipboardData.setData("text/plain", a);
|
|
894
|
-
},
|
|
1238
|
+
}, mr = (e) => D.create({
|
|
895
1239
|
name: "copyToClipboard",
|
|
896
1240
|
addProseMirrorPlugins() {
|
|
897
|
-
return [new
|
|
1241
|
+
return [new N({ props: { handleDOMEvents: {
|
|
898
1242
|
copy(t, n) {
|
|
899
|
-
return
|
|
1243
|
+
return fr() || pr(e, t, n), !0;
|
|
900
1244
|
},
|
|
901
1245
|
cut(t, n) {
|
|
902
|
-
return
|
|
1246
|
+
return fr() ? !0 : (pr(e, t, n), t.editable && t.dispatch(t.state.tr.deleteSelection()), !0);
|
|
903
1247
|
},
|
|
904
1248
|
dragstart(t, n) {
|
|
905
1249
|
if (!("node" in t.state.selection) || t.state.selection.node.type.spec.group !== "blockContent") return;
|
|
906
|
-
e.transact((e) => e.setSelection(new
|
|
907
|
-
let { clipboardHTML: r, externalHTML: i, markdown: a } =
|
|
1250
|
+
e.transact((e) => e.setSelection(new M(e.doc.resolve(t.state.selection.from - 1)))), n.preventDefault(), n.dataTransfer.clearData();
|
|
1251
|
+
let { clipboardHTML: r, externalHTML: i, markdown: a } = dr(t, e);
|
|
908
1252
|
return n.dataTransfer.setData("blocknote/html", r), n.dataTransfer.setData("text/html", i), n.dataTransfer.setData("text/plain", a), !0;
|
|
909
1253
|
}
|
|
910
1254
|
} } })];
|
|
911
1255
|
}
|
|
912
|
-
}),
|
|
1256
|
+
}), hr = D.create({
|
|
913
1257
|
name: "blockBackgroundColor",
|
|
914
1258
|
addGlobalAttributes() {
|
|
915
1259
|
return [{
|
|
@@ -917,7 +1261,7 @@ var An = () => {
|
|
|
917
1261
|
attributes: { backgroundColor: ne() }
|
|
918
1262
|
}];
|
|
919
1263
|
}
|
|
920
|
-
}),
|
|
1264
|
+
}), gr = k.create({
|
|
921
1265
|
name: "hardBreak",
|
|
922
1266
|
inline: !0,
|
|
923
1267
|
group: "inline",
|
|
@@ -928,33 +1272,33 @@ var An = () => {
|
|
|
928
1272
|
return [{ tag: "br" }];
|
|
929
1273
|
},
|
|
930
1274
|
renderHTML({ HTMLAttributes: e }) {
|
|
931
|
-
return ["br",
|
|
1275
|
+
return ["br", j(this.options.HTMLAttributes, e)];
|
|
932
1276
|
},
|
|
933
1277
|
renderText() {
|
|
934
1278
|
return "\n";
|
|
935
1279
|
}
|
|
936
|
-
}),
|
|
1280
|
+
}), _r = (e, t) => {
|
|
937
1281
|
let n = e.resolve(t), r = n.depth - 1;
|
|
938
1282
|
if (r < 1) return;
|
|
939
1283
|
let i = n.before(r), a = e.resolve(i).nodeAfter;
|
|
940
|
-
if (a) return a.type.spec.group?.includes("bnBlock") ? x(e.resolve(i)) :
|
|
941
|
-
},
|
|
1284
|
+
if (a) return a.type.spec.group?.includes("bnBlock") ? x(e.resolve(i)) : _r(e, i);
|
|
1285
|
+
}, Q = (e, t) => {
|
|
942
1286
|
let n = e.resolve(t), r = n.index();
|
|
943
1287
|
if (r === 0) return;
|
|
944
1288
|
let i = n.posAtIndex(r - 1);
|
|
945
1289
|
return x(e.resolve(i));
|
|
946
|
-
},
|
|
1290
|
+
}, $ = (e, t) => {
|
|
947
1291
|
let n = e.resolve(t), r = n.index();
|
|
948
1292
|
if (r === n.node().childCount - 1) return;
|
|
949
1293
|
let i = n.posAtIndex(r + 1);
|
|
950
1294
|
return x(e.resolve(i));
|
|
951
|
-
},
|
|
1295
|
+
}, vr = (e, t) => {
|
|
952
1296
|
for (; t.childContainer;) {
|
|
953
1297
|
let n = t.childContainer.node, r = e.resolve(t.childContainer.beforePos + 1).posAtIndex(n.childCount - 1);
|
|
954
1298
|
t = x(e.resolve(r));
|
|
955
1299
|
}
|
|
956
1300
|
return t;
|
|
957
|
-
},
|
|
1301
|
+
}, yr = (e, t) => e.isBlockContainer && e.blockContent.node.type.spec.content === "inline*" && e.blockContent.node.childCount > 0 && t.isBlockContainer && t.blockContent.node.type.spec.content === "inline*", br = (e, t, n, r) => {
|
|
958
1302
|
if (!r.isBlockContainer) throw Error(`Attempted to merge block at position ${r.bnBlock.beforePos} into previous block at position ${n.bnBlock.beforePos}, but next block is not a block container`);
|
|
959
1303
|
if (r.childContainer) {
|
|
960
1304
|
let n = e.doc.resolve(r.childContainer.beforePos + 1), i = e.doc.resolve(r.childContainer.afterPos - 1), a = n.blockRange(i);
|
|
@@ -968,12 +1312,12 @@ var An = () => {
|
|
|
968
1312
|
t(e.tr.delete(n.blockContent.afterPos - 1, r.blockContent.beforePos + 1));
|
|
969
1313
|
}
|
|
970
1314
|
return !0;
|
|
971
|
-
},
|
|
972
|
-
let r = x(t.doc.resolve(e)), i =
|
|
1315
|
+
}, xr = (e) => ({ state: t, dispatch: n }) => {
|
|
1316
|
+
let r = x(t.doc.resolve(e)), i = Q(t.doc, r.bnBlock.beforePos);
|
|
973
1317
|
if (!i) return !1;
|
|
974
|
-
let a =
|
|
975
|
-
return
|
|
976
|
-
},
|
|
1318
|
+
let a = vr(t.doc, i);
|
|
1319
|
+
return yr(a, r) ? br(t, n, a, r) : !1;
|
|
1320
|
+
}, Sr = D.create({
|
|
977
1321
|
priority: 50,
|
|
978
1322
|
addKeyboardShortcuts() {
|
|
979
1323
|
let e = () => this.editor.commands.first(({ chain: e, commands: t }) => [
|
|
@@ -983,7 +1327,7 @@ var An = () => {
|
|
|
983
1327
|
let n = v(e);
|
|
984
1328
|
if (!n.isBlockContainer) return !1;
|
|
985
1329
|
let r = e.selection.from === n.blockContent.beforePos + 1, i = n.blockContent.node.type.name === "paragraph";
|
|
986
|
-
return r && !i ? t.command(
|
|
1330
|
+
return r && !i ? t.command(de(n.bnBlock.beforePos, {
|
|
987
1331
|
type: "paragraph",
|
|
988
1332
|
props: {}
|
|
989
1333
|
})) : !1;
|
|
@@ -992,24 +1336,24 @@ var An = () => {
|
|
|
992
1336
|
let n = v(e);
|
|
993
1337
|
if (!n.isBlockContainer) return !1;
|
|
994
1338
|
let { blockContent: r } = n;
|
|
995
|
-
return e.selection.from === r.beforePos + 1 ?
|
|
1339
|
+
return e.selection.from === r.beforePos + 1 ? H(t, t.doc.type.schema.nodes.blockContainer, t.doc.type.schema.nodes.blockGroup) : !1;
|
|
996
1340
|
}),
|
|
997
1341
|
() => t.command(({ state: t }) => {
|
|
998
1342
|
let n = v(t);
|
|
999
1343
|
if (!n.isBlockContainer) return !1;
|
|
1000
|
-
let { bnBlock: r, blockContent: i } = n, a =
|
|
1344
|
+
let { bnBlock: r, blockContent: i } = n, a = Q(t.doc, n.bnBlock.beforePos);
|
|
1001
1345
|
if (!a || !a.isBlockContainer || a.blockContent.node.type.spec.content !== "inline*") return !1;
|
|
1002
1346
|
let o = t.selection.from === i.beforePos + 1, s = t.selection.empty, c = r.beforePos;
|
|
1003
|
-
return o && s ? e().command(
|
|
1347
|
+
return o && s ? e().command(xr(c)).scrollIntoView().run() : !1;
|
|
1004
1348
|
}),
|
|
1005
1349
|
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1006
1350
|
let r = v(e);
|
|
1007
1351
|
if (!r.isBlockContainer || e.selection.from !== r.blockContent.beforePos + 1) return !1;
|
|
1008
|
-
let i =
|
|
1352
|
+
let i = Q(e.doc, r.bnBlock.beforePos);
|
|
1009
1353
|
if (!i || i.isBlockContainer) return !1;
|
|
1010
1354
|
if (n) {
|
|
1011
1355
|
let e = i.bnBlock.afterPos - 1, n = t.doc.resolve(e - 1);
|
|
1012
|
-
return t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), t.insert(n.pos, r.bnBlock.node), t.setSelection(
|
|
1356
|
+
return t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), t.insert(n.pos, r.bnBlock.node), t.setSelection(P.near(t.doc.resolve(n.pos + 1))), !0;
|
|
1013
1357
|
}
|
|
1014
1358
|
return !1;
|
|
1015
1359
|
}),
|
|
@@ -1019,15 +1363,15 @@ var An = () => {
|
|
|
1019
1363
|
let i = t.doc.resolve(r.bnBlock.beforePos);
|
|
1020
1364
|
if (i.nodeBefore || i.node().type.name !== "column") return !1;
|
|
1021
1365
|
let a = t.doc.resolve(r.bnBlock.beforePos), o = t.doc.resolve(a.before()), s = o.before();
|
|
1022
|
-
return n && (t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos),
|
|
1366
|
+
return n && (t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), z(t, s), o.pos === s + 1 ? (t.insert(s, r.bnBlock.node), t.setSelection(P.near(t.doc.resolve(s)))) : (t.insert(o.pos - 1, r.bnBlock.node), t.setSelection(P.near(t.doc.resolve(o.pos))))), !0;
|
|
1023
1367
|
}),
|
|
1024
1368
|
() => t.command(({ state: t }) => {
|
|
1025
1369
|
let n = v(t);
|
|
1026
1370
|
if (!n.isBlockContainer) return !1;
|
|
1027
1371
|
if (n.blockContent.node.childCount === 0 && n.blockContent.node.type.spec.content === "inline*") {
|
|
1028
|
-
let r =
|
|
1372
|
+
let r = Q(t.doc, n.bnBlock.beforePos);
|
|
1029
1373
|
if (!r) return !1;
|
|
1030
|
-
let i =
|
|
1374
|
+
let i = vr(t.doc, r);
|
|
1031
1375
|
if (!i.isBlockContainer || !i || !i.isBlockContainer) return !1;
|
|
1032
1376
|
let a = e();
|
|
1033
1377
|
if (n.childContainer && a.insertContentAt(n.bnBlock.afterPos, n.childContainer?.node.content), i.blockContent.node.type.spec.content === "tableRow+") {
|
|
@@ -1048,9 +1392,9 @@ var An = () => {
|
|
|
1048
1392
|
() => t.command(({ state: t }) => {
|
|
1049
1393
|
let n = v(t);
|
|
1050
1394
|
if (!n.isBlockContainer) return !1;
|
|
1051
|
-
let r = t.selection.from === n.blockContent.beforePos + 1, i = t.selection.empty, a =
|
|
1395
|
+
let r = t.selection.from === n.blockContent.beforePos + 1, i = t.selection.empty, a = Q(t.doc, n.bnBlock.beforePos);
|
|
1052
1396
|
if (a && r && i) {
|
|
1053
|
-
let r =
|
|
1397
|
+
let r = vr(t.doc, a);
|
|
1054
1398
|
if (!r.isBlockContainer) return !1;
|
|
1055
1399
|
if (r.blockContent.node.type.spec.content === "" || r.blockContent.node.type.spec.content === "inline*" && r.blockContent.node.childCount === 0) return e().cut({
|
|
1056
1400
|
from: n.bnBlock.beforePos,
|
|
@@ -1071,7 +1415,7 @@ var An = () => {
|
|
|
1071
1415
|
if (!s.isBlockContainer) return !1;
|
|
1072
1416
|
if (a && o) {
|
|
1073
1417
|
let n = s.blockContent.node, a = n.type.spec.content === "inline*", o = r.node.type.spec.content === "inline*";
|
|
1074
|
-
return e().insertContentAt(s.bnBlock.afterPos, s.childContainer?.node.content ||
|
|
1418
|
+
return e().insertContentAt(s.bnBlock.afterPos, s.childContainer?.node.content || w.empty).deleteRange(i.node.childCount === 1 ? {
|
|
1075
1419
|
from: i.beforePos,
|
|
1076
1420
|
to: i.afterPos
|
|
1077
1421
|
} : {
|
|
@@ -1084,19 +1428,19 @@ var An = () => {
|
|
|
1084
1428
|
() => t.command(({ state: t }) => {
|
|
1085
1429
|
let n = v(t);
|
|
1086
1430
|
if (!n.isBlockContainer) return !1;
|
|
1087
|
-
let { bnBlock: r, blockContent: i } = n, a =
|
|
1431
|
+
let { bnBlock: r, blockContent: i } = n, a = $(t.doc, n.bnBlock.beforePos);
|
|
1088
1432
|
if (!a || !a.isBlockContainer) return !1;
|
|
1089
1433
|
let o = t.selection.from === i.afterPos - 1, s = t.selection.empty, c = r.afterPos;
|
|
1090
|
-
return o && s ? e().command(
|
|
1434
|
+
return o && s ? e().command(xr(c)).scrollIntoView().run() : !1;
|
|
1091
1435
|
}),
|
|
1092
1436
|
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1093
1437
|
let r = v(e);
|
|
1094
1438
|
if (!r.isBlockContainer || e.selection.from !== r.blockContent.afterPos - 1) return !1;
|
|
1095
|
-
let i =
|
|
1439
|
+
let i = $(e.doc, r.bnBlock.beforePos);
|
|
1096
1440
|
if (!i || i.isBlockContainer) return !1;
|
|
1097
1441
|
if (n) {
|
|
1098
1442
|
let e = i.bnBlock.beforePos + 1, n = t.doc.resolve(e + 1);
|
|
1099
|
-
return t.delete(n.pos, n.pos + n.nodeAfter.nodeSize),
|
|
1443
|
+
return t.delete(n.pos, n.pos + n.nodeAfter.nodeSize), z(t, i.bnBlock.beforePos), t.insert(r.bnBlock.afterPos, n.nodeAfter), t.setSelection(P.near(t.doc.resolve(n.pos))), !0;
|
|
1100
1444
|
}
|
|
1101
1445
|
return !1;
|
|
1102
1446
|
}),
|
|
@@ -1108,7 +1452,7 @@ var An = () => {
|
|
|
1108
1452
|
let a = t.doc.resolve(r.bnBlock.afterPos), o = t.doc.resolve(a.after()), s = o.after();
|
|
1109
1453
|
if (n) {
|
|
1110
1454
|
let e = o.pos === s - 1 ? s : o.pos + 1, n = x(t.doc.resolve(e));
|
|
1111
|
-
t.delete(n.bnBlock.beforePos, n.bnBlock.afterPos),
|
|
1455
|
+
t.delete(n.bnBlock.beforePos, n.bnBlock.afterPos), z(t, s - o.node().nodeSize), t.insert(a.pos, n.bnBlock.node), t.setSelection(P.near(t.doc.resolve(e)));
|
|
1112
1456
|
}
|
|
1113
1457
|
return !0;
|
|
1114
1458
|
}),
|
|
@@ -1118,14 +1462,14 @@ var An = () => {
|
|
|
1118
1462
|
let { blockContent: r } = n, i = t.selection.from === r.afterPos - 1, a = t.selection.empty;
|
|
1119
1463
|
if (i && a) {
|
|
1120
1464
|
let i = (e, t) => {
|
|
1121
|
-
let n =
|
|
1465
|
+
let n = $(e, t);
|
|
1122
1466
|
if (n) return n;
|
|
1123
|
-
let r =
|
|
1467
|
+
let r = _r(e, t);
|
|
1124
1468
|
if (r) return i(e, r.bnBlock.beforePos);
|
|
1125
1469
|
}, a = i(t.doc, n.bnBlock.beforePos);
|
|
1126
1470
|
if (!a || !a.isBlockContainer) return !1;
|
|
1127
1471
|
let o = a.blockContent.node, s = o.type.spec.content === "inline*", c = r.node.type.spec.content === "inline*";
|
|
1128
|
-
return e().insertContentAt(a.bnBlock.afterPos, a.childContainer?.node.content ||
|
|
1472
|
+
return e().insertContentAt(a.bnBlock.afterPos, a.childContainer?.node.content || w.empty).deleteRange({
|
|
1129
1473
|
from: a.bnBlock.beforePos,
|
|
1130
1474
|
to: a.bnBlock.afterPos
|
|
1131
1475
|
}).insertContentAt(t.selection.from, s && c ? o.content : null).setTextSelection(t.selection.from).scrollIntoView().run();
|
|
@@ -1136,7 +1480,7 @@ var An = () => {
|
|
|
1136
1480
|
let n = v(t);
|
|
1137
1481
|
if (!n.isBlockContainer) return !1;
|
|
1138
1482
|
if (n.blockContent.node.childCount === 0 && n.blockContent.node.type.spec.content === "inline*") {
|
|
1139
|
-
let r =
|
|
1483
|
+
let r = $(t.doc, n.bnBlock.beforePos);
|
|
1140
1484
|
if (!r || !r.isBlockContainer) return !1;
|
|
1141
1485
|
let i = e();
|
|
1142
1486
|
if (r.blockContent.node.type.spec.content === "tableRow+") {
|
|
@@ -1153,7 +1497,7 @@ var An = () => {
|
|
|
1153
1497
|
() => t.command(({ state: t }) => {
|
|
1154
1498
|
let n = v(t);
|
|
1155
1499
|
if (!n.isBlockContainer) return !1;
|
|
1156
|
-
let r = t.selection.from === n.blockContent.afterPos - 1, i = t.selection.empty, a =
|
|
1500
|
+
let r = t.selection.from === n.blockContent.afterPos - 1, i = t.selection.empty, a = $(t.doc, n.bnBlock.beforePos);
|
|
1157
1501
|
if (!a || !a.isBlockContainer) return !1;
|
|
1158
1502
|
if (a && r && i && (a.blockContent.node.type.spec.content === "" || a.blockContent.node.type.spec.content === "inline*" && a.blockContent.node.childCount === 0)) {
|
|
1159
1503
|
let t = a.bnBlock.node.lastChild.content;
|
|
@@ -1169,7 +1513,7 @@ var An = () => {
|
|
|
1169
1513
|
let n = v(e);
|
|
1170
1514
|
if (!n.isBlockContainer) return !1;
|
|
1171
1515
|
let { bnBlock: r, blockContent: i } = n, { depth: a } = e.doc.resolve(r.beforePos), o = e.selection.$anchor.parentOffset === 0, s = e.selection.anchor === e.selection.head, c = i.node.childCount === 0;
|
|
1172
|
-
return o && s && c && a > 1 ?
|
|
1516
|
+
return o && s && c && a > 1 ? H(t, t.doc.type.schema.nodes.blockContainer, t.doc.type.schema.nodes.blockGroup) : !1;
|
|
1173
1517
|
}),
|
|
1174
1518
|
() => t.command(({ state: t }) => {
|
|
1175
1519
|
let r = v(t), i = this.options.editor.schema.blockSchema[r.blockNoteType].meta?.hardBreakShortcut ?? "shift+enter";
|
|
@@ -1188,7 +1532,7 @@ var An = () => {
|
|
|
1188
1532
|
let a = i.afterPos, o = a + 2;
|
|
1189
1533
|
if (t) {
|
|
1190
1534
|
let t = e.schema.nodes.blockContainer.createAndFill(void 0, [e.schema.nodes.paragraph.createAndFill() || void 0, r.childContainer?.node].filter((e) => e !== void 0));
|
|
1191
|
-
n.insert(a, t).setSelection(new
|
|
1535
|
+
n.insert(a, t).setSelection(new P(n.doc.resolve(o))).scrollIntoView(), r.childContainer && n.delete(r.childContainer.beforePos, r.childContainer.afterPos);
|
|
1192
1536
|
}
|
|
1193
1537
|
return !0;
|
|
1194
1538
|
}
|
|
@@ -1206,8 +1550,8 @@ var An = () => {
|
|
|
1206
1550
|
Delete: t,
|
|
1207
1551
|
Enter: () => n(),
|
|
1208
1552
|
"Shift-Enter": () => n(!0),
|
|
1209
|
-
Tab: () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(
|
|
1210
|
-
"Shift-Tab": () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(
|
|
1553
|
+
Tab: () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(C)?.store.state || this.options.editor.getExtension(oe)?.store.state !== void 0) ? !1 : Ht(this.options.editor),
|
|
1554
|
+
"Shift-Tab": () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(C)?.store.state || this.options.editor.getExtension(oe)?.store.state !== void 0) ? !1 : Wt(this.options.editor),
|
|
1211
1555
|
"Shift-Mod-ArrowUp": () => (this.options.editor.moveBlocksUp(), !0),
|
|
1212
1556
|
"Shift-Mod-ArrowDown": () => (this.options.editor.moveBlocksDown(), !0),
|
|
1213
1557
|
"Mod-z": () => this.options.editor.undo(),
|
|
@@ -1215,7 +1559,7 @@ var An = () => {
|
|
|
1215
1559
|
"Shift-Mod-z": () => this.options.editor.redo()
|
|
1216
1560
|
};
|
|
1217
1561
|
}
|
|
1218
|
-
}),
|
|
1562
|
+
}), Cr = O.create({
|
|
1219
1563
|
name: "insertion",
|
|
1220
1564
|
inclusive: !1,
|
|
1221
1565
|
excludes: "deletion modification insertion",
|
|
@@ -1248,7 +1592,7 @@ var An = () => {
|
|
|
1248
1592
|
}]
|
|
1249
1593
|
} : {};
|
|
1250
1594
|
}
|
|
1251
|
-
}),
|
|
1595
|
+
}), wr = O.create({
|
|
1252
1596
|
name: "deletion",
|
|
1253
1597
|
inclusive: !1,
|
|
1254
1598
|
excludes: "insertion modification deletion",
|
|
@@ -1281,7 +1625,7 @@ var An = () => {
|
|
|
1281
1625
|
}]
|
|
1282
1626
|
} : {};
|
|
1283
1627
|
}
|
|
1284
|
-
}),
|
|
1628
|
+
}), Tr = O.create({
|
|
1285
1629
|
name: "modification",
|
|
1286
1630
|
inclusive: !1,
|
|
1287
1631
|
excludes: "deletion insertion",
|
|
@@ -1339,7 +1683,7 @@ var An = () => {
|
|
|
1339
1683
|
}]
|
|
1340
1684
|
} : {};
|
|
1341
1685
|
}
|
|
1342
|
-
}),
|
|
1686
|
+
}), Er = D.create({
|
|
1343
1687
|
name: "textAlignment",
|
|
1344
1688
|
addGlobalAttributes() {
|
|
1345
1689
|
return [{
|
|
@@ -1351,7 +1695,7 @@ var An = () => {
|
|
|
1351
1695
|
} }
|
|
1352
1696
|
}];
|
|
1353
1697
|
}
|
|
1354
|
-
}),
|
|
1698
|
+
}), Dr = D.create({
|
|
1355
1699
|
name: "blockTextColor",
|
|
1356
1700
|
addGlobalAttributes() {
|
|
1357
1701
|
return [{
|
|
@@ -1360,16 +1704,16 @@ var An = () => {
|
|
|
1360
1704
|
"tableCell",
|
|
1361
1705
|
"tableHeader"
|
|
1362
1706
|
],
|
|
1363
|
-
attributes: { textColor:
|
|
1707
|
+
attributes: { textColor: ue() }
|
|
1364
1708
|
}];
|
|
1365
1709
|
}
|
|
1366
|
-
}),
|
|
1710
|
+
}), Or = {
|
|
1367
1711
|
blockColor: "data-block-color",
|
|
1368
1712
|
blockStyle: "data-block-style",
|
|
1369
1713
|
id: "data-id",
|
|
1370
1714
|
depth: "data-depth",
|
|
1371
1715
|
depthChange: "data-depth-change"
|
|
1372
|
-
},
|
|
1716
|
+
}, kr = k.create({
|
|
1373
1717
|
name: "blockContainer",
|
|
1374
1718
|
group: "blockGroupChild bnBlock",
|
|
1375
1719
|
content: "blockContent blockGroup?",
|
|
@@ -1382,7 +1726,7 @@ var An = () => {
|
|
|
1382
1726
|
getAttrs: (e) => {
|
|
1383
1727
|
if (typeof e == "string") return !1;
|
|
1384
1728
|
let t = {};
|
|
1385
|
-
for (let [n, r] of Object.entries(
|
|
1729
|
+
for (let [n, r] of Object.entries(Or)) e.getAttribute(r) && (t[n] = e.getAttribute(r));
|
|
1386
1730
|
return t;
|
|
1387
1731
|
}
|
|
1388
1732
|
}, {
|
|
@@ -1405,7 +1749,7 @@ var An = () => {
|
|
|
1405
1749
|
contentDOM: r
|
|
1406
1750
|
};
|
|
1407
1751
|
}
|
|
1408
|
-
}),
|
|
1752
|
+
}), Ar = k.create({
|
|
1409
1753
|
name: "blockGroup",
|
|
1410
1754
|
group: "childContainer",
|
|
1411
1755
|
content: "blockGroupChild+",
|
|
@@ -1428,29 +1772,31 @@ var An = () => {
|
|
|
1428
1772
|
contentDOM: n
|
|
1429
1773
|
};
|
|
1430
1774
|
}
|
|
1431
|
-
}),
|
|
1775
|
+
}), jr = k.create({
|
|
1432
1776
|
name: "doc",
|
|
1433
1777
|
topNode: !0,
|
|
1434
1778
|
content: "blockGroup",
|
|
1435
1779
|
marks: "insertion modification deletion"
|
|
1436
|
-
}),
|
|
1780
|
+
}), Mr = Ne(({ options: e }) => ({
|
|
1437
1781
|
key: "collaboration",
|
|
1438
1782
|
blockNoteExtensions: [
|
|
1439
|
-
ue(e),
|
|
1440
1783
|
fe(e),
|
|
1441
|
-
|
|
1784
|
+
me(e),
|
|
1785
|
+
_e(e),
|
|
1442
1786
|
Ae(),
|
|
1443
|
-
|
|
1787
|
+
ge(e)
|
|
1444
1788
|
]
|
|
1445
|
-
}))
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1789
|
+
}));
|
|
1790
|
+
//#endregion
|
|
1791
|
+
//#region src/editor/managers/ExtensionManager/extensions.ts
|
|
1792
|
+
function Nr(e, t) {
|
|
1793
|
+
return [
|
|
1794
|
+
A.ClipboardTextSerializer,
|
|
1795
|
+
A.Commands,
|
|
1796
|
+
A.Editable,
|
|
1797
|
+
A.FocusEvents,
|
|
1798
|
+
A.Tabindex,
|
|
1799
|
+
gt,
|
|
1454
1800
|
o.configure({
|
|
1455
1801
|
types: [
|
|
1456
1802
|
"blockContainer",
|
|
@@ -1460,54 +1806,52 @@ function Xn(e, t) {
|
|
|
1460
1806
|
setIdAttribute: t.setIdAttribute,
|
|
1461
1807
|
isWithinEditor: e.isWithinEditor
|
|
1462
1808
|
}),
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
protocols: Yn ? [] : ye
|
|
1809
|
+
gr,
|
|
1810
|
+
_t,
|
|
1811
|
+
Cr,
|
|
1812
|
+
wr,
|
|
1813
|
+
Tr,
|
|
1814
|
+
Bn.configure({
|
|
1815
|
+
HTMLAttributes: t.links?.HTMLAttributes ?? {},
|
|
1816
|
+
editor: e,
|
|
1817
|
+
onClick: t.links?.onClick,
|
|
1818
|
+
...t.links?.isValidLink ? { isValidLink: t.links.isValidLink } : {}
|
|
1474
1819
|
}),
|
|
1475
1820
|
...Object.values(e.schema.styleSpecs).map((t) => t.implementation.mark.configure({ editor: e })),
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1821
|
+
Dr,
|
|
1822
|
+
hr,
|
|
1823
|
+
Er,
|
|
1824
|
+
D.create({
|
|
1480
1825
|
name: "OverrideEscape",
|
|
1481
1826
|
addKeyboardShortcuts: () => ({ Escape: () => e.getExtension(te)?.shown() ? !1 : (e.blur(), !0) })
|
|
1482
1827
|
}),
|
|
1483
|
-
|
|
1484
|
-
|
|
1828
|
+
jr,
|
|
1829
|
+
kr.configure({
|
|
1485
1830
|
editor: e,
|
|
1486
1831
|
domAttributes: t.domAttributes
|
|
1487
1832
|
}),
|
|
1488
|
-
|
|
1833
|
+
Sr.configure({
|
|
1489
1834
|
editor: e,
|
|
1490
1835
|
tabBehavior: t.tabBehavior
|
|
1491
1836
|
}),
|
|
1492
|
-
|
|
1837
|
+
Ar.configure({ domAttributes: t.domAttributes }),
|
|
1493
1838
|
...Object.values(e.schema.inlineContentSpecs).filter((e) => e.config !== "link" && e.config !== "text").map((t) => t.implementation.node.configure({ editor: e })),
|
|
1494
1839
|
...Object.values(e.schema.blockSpecs).flatMap((n) => [..."node" in n.implementation ? [n.implementation.node.configure({
|
|
1495
1840
|
editor: e,
|
|
1496
1841
|
domAttributes: t.domAttributes
|
|
1497
1842
|
})] : []]),
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1843
|
+
mr(e),
|
|
1844
|
+
lr(e, t.pasteHandler || ((e) => e.defaultPasteHandler())),
|
|
1845
|
+
Kn(e)
|
|
1501
1846
|
];
|
|
1502
|
-
return Yn = !0, n;
|
|
1503
1847
|
}
|
|
1504
|
-
function
|
|
1848
|
+
function Pr(e, t) {
|
|
1505
1849
|
let n = [
|
|
1506
|
-
|
|
1850
|
+
pe(),
|
|
1507
1851
|
je(t),
|
|
1852
|
+
oe(t),
|
|
1508
1853
|
C(t),
|
|
1509
|
-
|
|
1510
|
-
ge(t),
|
|
1854
|
+
ve(t),
|
|
1511
1855
|
Ce(),
|
|
1512
1856
|
Ee(t),
|
|
1513
1857
|
Pe(t),
|
|
@@ -1515,11 +1859,11 @@ function Zn(e, t) {
|
|
|
1515
1859
|
te(t),
|
|
1516
1860
|
...t.trailingBlock === !1 ? [] : [De()]
|
|
1517
1861
|
];
|
|
1518
|
-
return t.collaboration ? n.push(
|
|
1862
|
+
return t.collaboration ? n.push(Mr(t.collaboration)) : n.push(ke()), "table" in e.schema.blockSpecs && n.push(we(t)), t.animations !== !1 && n.push(be()), n;
|
|
1519
1863
|
}
|
|
1520
1864
|
//#endregion
|
|
1521
1865
|
//#region src/editor/managers/ExtensionManager/index.ts
|
|
1522
|
-
var
|
|
1866
|
+
var Fr = class {
|
|
1523
1867
|
disabledExtensions = /* @__PURE__ */ new Set();
|
|
1524
1868
|
extensions = [];
|
|
1525
1869
|
abortMap = /* @__PURE__ */ new Map();
|
|
@@ -1540,7 +1884,7 @@ var Qn = class {
|
|
|
1540
1884
|
}), e.onUnmount(() => {
|
|
1541
1885
|
for (let [e, t] of this.abortMap.entries()) this.abortMap.delete(e), t.abort();
|
|
1542
1886
|
}), this.disabledExtensions = new Set(t.disableExtensions || []);
|
|
1543
|
-
for (let e of
|
|
1887
|
+
for (let e of Pr(this.editor, this.options)) this.addExtension(e);
|
|
1544
1888
|
for (let e of this.options.extensions ?? []) this.addExtension(e);
|
|
1545
1889
|
for (let e of Object.values(this.editor.schema.blockSpecs)) for (let t of e.extensions ?? []) this.addExtension(t);
|
|
1546
1890
|
}
|
|
@@ -1599,23 +1943,23 @@ var Qn = class {
|
|
|
1599
1943
|
this.editor.prosemirrorView.updateState(n);
|
|
1600
1944
|
}
|
|
1601
1945
|
getTiptapExtensions() {
|
|
1602
|
-
let e =
|
|
1946
|
+
let e = Nr(this.editor, this.options).filter((e) => !this.disabledExtensions.has(e.name)), t = a(this.extensions), n = /* @__PURE__ */ new Map();
|
|
1603
1947
|
for (let r of this.extensions) {
|
|
1604
1948
|
r.tiptapExtensions && e.push(...r.tiptapExtensions);
|
|
1605
1949
|
let i = t(r.key), { plugins: a, inputRules: o } = this.getProsemirrorPluginsFromExtension(r);
|
|
1606
|
-
a.length && e.push(
|
|
1950
|
+
a.length && e.push(D.create({
|
|
1607
1951
|
name: r.key,
|
|
1608
1952
|
priority: i,
|
|
1609
1953
|
addProseMirrorPlugins: () => a
|
|
1610
1954
|
})), o.length && (n.has(i) || n.set(i, []), n.get(i).push(...o));
|
|
1611
1955
|
}
|
|
1612
|
-
e.push(
|
|
1956
|
+
e.push(D.create({
|
|
1613
1957
|
name: "blocknote-input-rules",
|
|
1614
1958
|
addProseMirrorPlugins() {
|
|
1615
1959
|
let e = [];
|
|
1616
1960
|
return Array.from(n.keys()).sort().reverse().forEach((t) => {
|
|
1617
1961
|
e.push(...n.get(t));
|
|
1618
|
-
}), [
|
|
1962
|
+
}), [mt({ rules: e })];
|
|
1619
1963
|
}
|
|
1620
1964
|
}));
|
|
1621
1965
|
for (let t of this.options._tiptapOptions?.extensions ?? []) e.push(t);
|
|
@@ -1626,7 +1970,7 @@ var Qn = class {
|
|
|
1626
1970
|
return !e.prosemirrorPlugins?.length && !Object.keys(e.keyboardShortcuts || {}).length && !e.inputRules?.length ? {
|
|
1627
1971
|
plugins: t,
|
|
1628
1972
|
inputRules: n
|
|
1629
|
-
} : (this.extensionPlugins.set(e, t), e.inputRules?.length && n.push(...e.inputRules.map((e) => new
|
|
1973
|
+
} : (this.extensionPlugins.set(e, t), e.inputRules?.length && n.push(...e.inputRules.map((e) => new pt(e.find, (t, n, r, i) => {
|
|
1630
1974
|
let a = e.replace({
|
|
1631
1975
|
match: n,
|
|
1632
1976
|
range: {
|
|
@@ -1642,7 +1986,7 @@ var Qn = class {
|
|
|
1642
1986
|
return d(o, n.bnBlock.beforePos, a), o;
|
|
1643
1987
|
}
|
|
1644
1988
|
return null;
|
|
1645
|
-
}))), Object.keys(e.keyboardShortcuts || {}).length && t.push(
|
|
1989
|
+
}))), Object.keys(e.keyboardShortcuts || {}).length && t.push(ht(Object.fromEntries(Object.entries(e.keyboardShortcuts).map(([e, t]) => [e, () => t({ editor: this.editor })])))), {
|
|
1646
1990
|
plugins: t,
|
|
1647
1991
|
inputRules: n
|
|
1648
1992
|
});
|
|
@@ -1661,7 +2005,7 @@ var Qn = class {
|
|
|
1661
2005
|
};
|
|
1662
2006
|
//#endregion
|
|
1663
2007
|
//#region src/util/expandToWords.ts
|
|
1664
|
-
function
|
|
2008
|
+
function Ir(e, t) {
|
|
1665
2009
|
let { $from: n, $to: r } = t;
|
|
1666
2010
|
if (n.pos > n.start() && n.pos < e.content.size) {
|
|
1667
2011
|
let t = e.textBetween(n.pos, n.pos + 1);
|
|
@@ -1686,10 +2030,10 @@ function $n(e, t) {
|
|
|
1686
2030
|
}
|
|
1687
2031
|
//#endregion
|
|
1688
2032
|
//#region src/api/blockManipulation/selections/selection.ts
|
|
1689
|
-
function
|
|
2033
|
+
function Lr(e) {
|
|
1690
2034
|
let t = g(e);
|
|
1691
2035
|
if (e.selection.empty || "node" in e.selection) return;
|
|
1692
|
-
let n = e.doc.resolve(
|
|
2036
|
+
let n = e.doc.resolve(S(e.doc, e.selection.from).posBeforeNode), r = e.doc.resolve(S(e.doc, e.selection.to).posBeforeNode), i = (r, i) => {
|
|
1693
2037
|
let a = n.posAtIndex(r, i), o = e.doc.resolve(a).nodeAfter;
|
|
1694
2038
|
if (!o) throw Error(`Error getting selection - node not found at position ${a}`);
|
|
1695
2039
|
return y(o, t);
|
|
@@ -1705,29 +2049,29 @@ function er(e) {
|
|
|
1705
2049
|
if (a.length === 0) throw Error(`Error getting selection - selection doesn't span any blocks (${e.selection})`);
|
|
1706
2050
|
return { blocks: a };
|
|
1707
2051
|
}
|
|
1708
|
-
function
|
|
2052
|
+
function Rr(e, t, n) {
|
|
1709
2053
|
let r = typeof t == "string" ? t : t.id, a = typeof n == "string" ? n : n.id, o = ee(g(e));
|
|
1710
2054
|
if (r === a) throw Error(`Attempting to set selection with the same anchor and head blocks (id ${r})`);
|
|
1711
2055
|
let s = i(r, e.doc);
|
|
1712
2056
|
if (!s) throw Error(`Block with ID ${r} not found`);
|
|
1713
2057
|
let c = i(a, e.doc);
|
|
1714
2058
|
if (!c) throw Error(`Block with ID ${a} not found`);
|
|
1715
|
-
let l =
|
|
2059
|
+
let l = ae(s), u = ae(c), d = o.blockSchema[l.blockNoteType], f = o.blockSchema[u.blockNoteType];
|
|
1716
2060
|
if (!l.isBlockContainer || d.content === "none") throw Error(`Attempting to set selection anchor in block without content (id ${r})`);
|
|
1717
2061
|
if (!u.isBlockContainer || f.content === "none") throw Error(`Attempting to set selection anchor in block without content (id ${a})`);
|
|
1718
2062
|
let p, m;
|
|
1719
2063
|
if (d.content === "table") {
|
|
1720
|
-
let e =
|
|
2064
|
+
let e = it.get(l.blockContent.node);
|
|
1721
2065
|
p = l.blockContent.beforePos + e.positionAt(0, 0, l.blockContent.node) + 1 + 2;
|
|
1722
2066
|
} else p = l.blockContent.beforePos + 1;
|
|
1723
2067
|
if (f.content === "table") {
|
|
1724
|
-
let t =
|
|
2068
|
+
let t = it.get(u.blockContent.node), n = u.blockContent.beforePos + t.positionAt(t.height - 1, t.width - 1, u.blockContent.node) + 1;
|
|
1725
2069
|
m = n + e.doc.resolve(n).nodeAfter.nodeSize - 2;
|
|
1726
2070
|
} else m = u.blockContent.afterPos - 1;
|
|
1727
|
-
e.setSelection(
|
|
2071
|
+
e.setSelection(P.create(e.doc, p, m));
|
|
1728
2072
|
}
|
|
1729
|
-
function
|
|
1730
|
-
let n = g(e), r = t ?
|
|
2073
|
+
function zr(e, t = !1) {
|
|
2074
|
+
let n = g(e), r = t ? Ir(e.doc, e.selection) : e.selection, i = r.$from, a = r.$to;
|
|
1731
2075
|
for (; a.parentOffset >= a.parent.nodeSize - 2 && a.depth > 0;) a = e.doc.resolve(a.pos + 1);
|
|
1732
2076
|
for (; a.parentOffset === 0 && a.depth > 0;) a = e.doc.resolve(a.pos - 1);
|
|
1733
2077
|
for (; i.parentOffset === 0 && i.depth > 0;) i = e.doc.resolve(i.pos - 1);
|
|
@@ -1743,7 +2087,7 @@ function nr(e, t = !1) {
|
|
|
1743
2087
|
}
|
|
1744
2088
|
//#endregion
|
|
1745
2089
|
//#region src/api/blockManipulation/selections/textCursorPosition.ts
|
|
1746
|
-
function
|
|
2090
|
+
function Br(e) {
|
|
1747
2091
|
let { bnBlock: t } = _(e), n = g(e.doc), r = e.doc.resolve(t.beforePos), i = r.nodeBefore, a = e.doc.resolve(t.afterPos).nodeAfter, o;
|
|
1748
2092
|
return r.depth > 1 && (o = r.node(), o.type.isInGroup("bnBlock") || (o = r.node(r.depth - 1))), {
|
|
1749
2093
|
block: y(t.node, n),
|
|
@@ -1752,52 +2096,52 @@ function rr(e) {
|
|
|
1752
2096
|
parentBlock: o === void 0 ? void 0 : y(o, n)
|
|
1753
2097
|
};
|
|
1754
2098
|
}
|
|
1755
|
-
function
|
|
2099
|
+
function Vr(e, t, n = "start") {
|
|
1756
2100
|
let r = typeof t == "string" ? t : t.id, a = ee(g(e.doc)), o = i(r, e.doc);
|
|
1757
2101
|
if (!o) throw Error(`Block with ID ${r} not found`);
|
|
1758
|
-
let s =
|
|
2102
|
+
let s = ae(o), c = a.blockSchema[s.blockNoteType].content;
|
|
1759
2103
|
if (s.isBlockContainer) {
|
|
1760
2104
|
let t = s.blockContent;
|
|
1761
2105
|
if (c === "none") {
|
|
1762
|
-
e.setSelection(
|
|
2106
|
+
e.setSelection(M.create(e.doc, t.beforePos));
|
|
1763
2107
|
return;
|
|
1764
2108
|
}
|
|
1765
|
-
if (c === "inline") n === "start" ? e.setSelection(
|
|
1766
|
-
else if (c === "table") n === "start" ? e.setSelection(
|
|
2109
|
+
if (c === "inline") n === "start" ? e.setSelection(P.create(e.doc, t.beforePos + 1)) : e.setSelection(P.create(e.doc, t.afterPos - 1));
|
|
2110
|
+
else if (c === "table") n === "start" ? e.setSelection(P.create(e.doc, t.beforePos + 4)) : e.setSelection(P.create(e.doc, t.afterPos - 4));
|
|
1767
2111
|
else throw new u(c);
|
|
1768
|
-
} else
|
|
2112
|
+
} else Vr(e, (n === "start" ? s.childContainer.node.firstChild : s.childContainer.node.lastChild).attrs.id, n);
|
|
1769
2113
|
}
|
|
1770
2114
|
//#endregion
|
|
1771
2115
|
//#region src/editor/managers/SelectionManager.ts
|
|
1772
|
-
var
|
|
2116
|
+
var Hr = class {
|
|
1773
2117
|
constructor(e) {
|
|
1774
2118
|
this.editor = e;
|
|
1775
2119
|
}
|
|
1776
2120
|
getSelection() {
|
|
1777
|
-
return this.editor.transact((e) =>
|
|
2121
|
+
return this.editor.transact((e) => Lr(e));
|
|
1778
2122
|
}
|
|
1779
2123
|
getSelectionCutBlocks(e = !1) {
|
|
1780
|
-
return this.editor.transact((t) =>
|
|
2124
|
+
return this.editor.transact((t) => zr(t, e));
|
|
1781
2125
|
}
|
|
1782
2126
|
setSelection(e, t) {
|
|
1783
|
-
return this.editor.transact((n) =>
|
|
2127
|
+
return this.editor.transact((n) => Rr(n, e, t));
|
|
1784
2128
|
}
|
|
1785
2129
|
getTextCursorPosition() {
|
|
1786
|
-
return this.editor.transact((e) =>
|
|
2130
|
+
return this.editor.transact((e) => Br(e));
|
|
1787
2131
|
}
|
|
1788
2132
|
setTextCursorPosition(e, t = "start") {
|
|
1789
|
-
return this.editor.transact((n) =>
|
|
2133
|
+
return this.editor.transact((n) => Vr(n, e, t));
|
|
1790
2134
|
}
|
|
1791
2135
|
getSelectionBoundingBox() {
|
|
1792
2136
|
if (!this.editor.prosemirrorView) return;
|
|
1793
2137
|
let { selection: e } = this.editor.prosemirrorState, { ranges: t } = e, n = Math.min(...t.map((e) => e.$from.pos)), r = Math.max(...t.map((e) => e.$to.pos));
|
|
1794
|
-
if (
|
|
2138
|
+
if (et(e)) {
|
|
1795
2139
|
let e = this.editor.prosemirrorView.nodeDOM(n);
|
|
1796
2140
|
if (e) return e.getBoundingClientRect();
|
|
1797
2141
|
}
|
|
1798
|
-
return
|
|
2142
|
+
return nt(this.editor.prosemirrorView, n, r).toJSON();
|
|
1799
2143
|
}
|
|
1800
|
-
},
|
|
2144
|
+
}, Ur = class {
|
|
1801
2145
|
constructor(e) {
|
|
1802
2146
|
this.editor = e;
|
|
1803
2147
|
}
|
|
@@ -1875,7 +2219,7 @@ var ar = class {
|
|
|
1875
2219
|
};
|
|
1876
2220
|
//#endregion
|
|
1877
2221
|
//#region src/api/blockManipulation/insertContentAt.ts
|
|
1878
|
-
function
|
|
2222
|
+
function Wr(e, t, n, r = { updateSelection: !0 }) {
|
|
1879
2223
|
let { from: i, to: a } = typeof t == "number" ? {
|
|
1880
2224
|
from: t,
|
|
1881
2225
|
to: t
|
|
@@ -1889,18 +2233,18 @@ function sr(e, t, n, r = { updateSelection: !0 }) {
|
|
|
1889
2233
|
let { parent: t } = e.doc.resolve(i);
|
|
1890
2234
|
t.isTextblock && !t.type.spec.code && !t.childCount && (--i, a += 1);
|
|
1891
2235
|
}
|
|
1892
|
-
return o ? e.insertText(c, i, a) : e.replaceWith(i, a, n), r.updateSelection &&
|
|
2236
|
+
return o ? e.insertText(c, i, a) : e.replaceWith(i, a, n), r.updateSelection && rt(e, e.steps.length - 1, -1), !0;
|
|
1893
2237
|
}
|
|
1894
2238
|
//#endregion
|
|
1895
2239
|
//#region src/editor/managers/StyleManager.ts
|
|
1896
|
-
var
|
|
2240
|
+
var Gr = class {
|
|
1897
2241
|
constructor(e) {
|
|
1898
2242
|
this.editor = e;
|
|
1899
2243
|
}
|
|
1900
2244
|
insertInlineContent(e, { updateSelection: t = !1 } = {}) {
|
|
1901
2245
|
let n = b(e, this.editor.pmSchema);
|
|
1902
2246
|
this.editor.transact((e) => {
|
|
1903
|
-
|
|
2247
|
+
Wr(e, {
|
|
1904
2248
|
from: e.selection.from,
|
|
1905
2249
|
to: e.selection.to
|
|
1906
2250
|
}, n, { updateSelection: t });
|
|
@@ -1944,36 +2288,65 @@ var cr = class {
|
|
|
1944
2288
|
getSelectedText() {
|
|
1945
2289
|
return this.editor.transact((e) => e.doc.textBetween(e.selection.from, e.selection.to));
|
|
1946
2290
|
}
|
|
2291
|
+
getLinkMarkAtPos(e) {
|
|
2292
|
+
return this.editor.transact((t) => {
|
|
2293
|
+
let n = t.doc.resolve(e), r = n.marks().find((e) => e.type.name === "link");
|
|
2294
|
+
if (!r) return;
|
|
2295
|
+
let i = Ze(n, r.type);
|
|
2296
|
+
if (i) return {
|
|
2297
|
+
href: r.attrs.href,
|
|
2298
|
+
from: i.from,
|
|
2299
|
+
to: i.to,
|
|
2300
|
+
text: t.doc.textBetween(i.from, i.to)
|
|
2301
|
+
};
|
|
2302
|
+
});
|
|
2303
|
+
}
|
|
1947
2304
|
getSelectedLinkUrl() {
|
|
1948
|
-
return this.editor.
|
|
2305
|
+
return this.editor.transact((e) => this.getLinkMarkAtPos(e.selection.from)?.href);
|
|
1949
2306
|
}
|
|
1950
2307
|
createLink(e, t) {
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
let { from: r, to: i } = e.selection;
|
|
1955
|
-
t ? e.insertText(t, r, i).addMark(r, r + t.length, n) : e.setSelection($e.create(e.doc, i)).addMark(r, i, n);
|
|
2308
|
+
e !== "" && this.editor.transact((n) => {
|
|
2309
|
+
let { from: r, to: i } = n.selection, a = this.editor.pmSchema.mark("link", { href: e });
|
|
2310
|
+
t ? n.insertText(t, r, i).addMark(r, r + t.length, a) : n.addMark(r, i, a);
|
|
1956
2311
|
});
|
|
1957
2312
|
}
|
|
2313
|
+
editLink(e, t, n = this.editor.transact((e) => e.selection.anchor)) {
|
|
2314
|
+
this.editor.transact((r) => {
|
|
2315
|
+
let { from: i, to: a } = this.getLinkMarkAtPos(n + 1) || {
|
|
2316
|
+
from: r.selection.from,
|
|
2317
|
+
to: r.selection.to
|
|
2318
|
+
}, o = this.editor.pmSchema.mark("link", { href: e });
|
|
2319
|
+
t !== r.doc.textBetween(i, a) && r.insertText(t, i, a), r.addMark(i, i + t.length, o);
|
|
2320
|
+
}), this.editor.prosemirrorView.focus();
|
|
2321
|
+
}
|
|
2322
|
+
deleteLink(e = this.editor.transact((e) => e.selection.anchor)) {
|
|
2323
|
+
this.editor.transact((t) => {
|
|
2324
|
+
let { from: n, to: r } = this.getLinkMarkAtPos(e + 1) || {
|
|
2325
|
+
from: t.selection.from,
|
|
2326
|
+
to: t.selection.to
|
|
2327
|
+
};
|
|
2328
|
+
t.removeMark(n, r, this.editor.pmSchema.marks.link).setMeta("preventAutolink", !0);
|
|
2329
|
+
}), this.editor.prosemirrorView.focus();
|
|
2330
|
+
}
|
|
1958
2331
|
};
|
|
1959
2332
|
//#endregion
|
|
1960
2333
|
//#region src/editor/transformPasted.ts
|
|
1961
|
-
function
|
|
1962
|
-
return
|
|
2334
|
+
function Kr(e) {
|
|
2335
|
+
return Je(e.state.selection.$from, (e) => e.type.name === "tableCell" || e.type.name === "tableHeader") !== void 0;
|
|
1963
2336
|
}
|
|
1964
|
-
function
|
|
1965
|
-
let n = t.nodes.hardBreak, r =
|
|
2337
|
+
function qr(e, t) {
|
|
2338
|
+
let n = t.nodes.hardBreak, r = F.empty;
|
|
1966
2339
|
return e.forEach((e) => {
|
|
1967
|
-
e.isTextblock && e.childCount > 0 ? (r = r.append(e.content), r = r.addToEnd(n.create())) : e.isText ? r = r.addToEnd(e) : e.isBlock && e.childCount > 0 && (r = r.append(
|
|
2340
|
+
e.isTextblock && e.childCount > 0 ? (r = r.append(e.content), r = r.addToEnd(n.create())) : e.isText ? r = r.addToEnd(e) : e.isBlock && e.childCount > 0 && (r = r.append(qr(e.content, t)), r = r.addToEnd(n.create()));
|
|
1968
2341
|
}), r.lastChild?.type === n && (r = r.cut(0, r.size - 1)), r;
|
|
1969
2342
|
}
|
|
1970
|
-
function
|
|
2343
|
+
function Jr(e, t) {
|
|
1971
2344
|
let n = [];
|
|
1972
2345
|
return e.forEach((e, r, i) => {
|
|
1973
2346
|
i !== t && n.push(e);
|
|
1974
|
-
}),
|
|
2347
|
+
}), F.from(n);
|
|
1975
2348
|
}
|
|
1976
|
-
function
|
|
2349
|
+
function Yr(e, t) {
|
|
1977
2350
|
let n = [];
|
|
1978
2351
|
for (let r = 0; r < e.childCount; r++) if (e.child(r).type.name === "tableRow") if (n.length > 0 && n[n.length - 1].type.name === "table") {
|
|
1979
2352
|
let t = n[n.length - 1], i = t.copy(t.content.addToEnd(e.child(r)));
|
|
@@ -1983,29 +2356,29 @@ function fr(e, t) {
|
|
|
1983
2356
|
n.push(i);
|
|
1984
2357
|
}
|
|
1985
2358
|
else n.push(e.child(r));
|
|
1986
|
-
return e =
|
|
2359
|
+
return e = F.from(n), e;
|
|
1987
2360
|
}
|
|
1988
|
-
function
|
|
1989
|
-
let n =
|
|
1990
|
-
if (n =
|
|
2361
|
+
function Xr(e, t) {
|
|
2362
|
+
let n = F.from(e.content);
|
|
2363
|
+
if (n = Yr(n, t.state.schema), Kr(t)) {
|
|
1991
2364
|
let e = !1;
|
|
1992
2365
|
if (n.descendants((t) => {
|
|
1993
2366
|
t.type.isInGroup("tableContent") && (e = !0);
|
|
1994
|
-
}), !e && !t.state.schema.nodes.tableParagraph.validContent(n)) return new
|
|
2367
|
+
}), !e && !t.state.schema.nodes.tableParagraph.validContent(n)) return new I(qr(n, t.state.schema), 0, 0);
|
|
1995
2368
|
}
|
|
1996
|
-
if (!
|
|
2369
|
+
if (!Zr(n, t)) return new I(n, e.openStart, e.openEnd);
|
|
1997
2370
|
for (let e = 0; e < n.childCount; e++) if (n.child(e).type.spec.group === "blockContent") {
|
|
1998
2371
|
let r = [n.child(e)];
|
|
1999
2372
|
if (e + 1 < n.childCount && n.child(e + 1).type.name === "blockGroup") {
|
|
2000
2373
|
let t = n.child(e + 1).child(0).child(0);
|
|
2001
|
-
(t.type.name === "bulletListItem" || t.type.name === "numberedListItem" || t.type.name === "checkListItem") && (r.push(n.child(e + 1)), n =
|
|
2374
|
+
(t.type.name === "bulletListItem" || t.type.name === "numberedListItem" || t.type.name === "checkListItem") && (r.push(n.child(e + 1)), n = Jr(n, e + 1));
|
|
2002
2375
|
}
|
|
2003
2376
|
let i = t.state.schema.nodes.blockContainer.createChecked(void 0, r);
|
|
2004
2377
|
n = n.replaceChild(e, i);
|
|
2005
2378
|
}
|
|
2006
|
-
return new
|
|
2379
|
+
return new I(n, e.openStart, e.openEnd);
|
|
2007
2380
|
}
|
|
2008
|
-
function
|
|
2381
|
+
function Zr(e, t) {
|
|
2009
2382
|
let n = e.childCount === 1, r = e.firstChild?.type.spec.content === "inline*", i = e.firstChild?.type.spec.content === "tableRow+";
|
|
2010
2383
|
if (n) {
|
|
2011
2384
|
if (r) return !1;
|
|
@@ -2018,11 +2391,11 @@ function mr(e, t) {
|
|
|
2018
2391
|
}
|
|
2019
2392
|
//#endregion
|
|
2020
2393
|
//#region src/editor/BlockNoteEditor.ts
|
|
2021
|
-
var
|
|
2394
|
+
var Qr = {
|
|
2022
2395
|
enableInputRules: !0,
|
|
2023
2396
|
enablePasteRules: !0,
|
|
2024
2397
|
enableCoreExtensions: !1
|
|
2025
|
-
},
|
|
2398
|
+
}, $r = class e extends Ie {
|
|
2026
2399
|
pmSchema;
|
|
2027
2400
|
_tiptapEditor;
|
|
2028
2401
|
elementRenderer = null;
|
|
@@ -2049,7 +2422,7 @@ var hr = {
|
|
|
2049
2422
|
} };
|
|
2050
2423
|
let t = {
|
|
2051
2424
|
defaultStyles: !0,
|
|
2052
|
-
schema: e.schema ||
|
|
2425
|
+
schema: e.schema || ce.create(),
|
|
2053
2426
|
...e,
|
|
2054
2427
|
placeholders: {
|
|
2055
2428
|
...this.dictionary.placeholders,
|
|
@@ -2067,11 +2440,11 @@ var hr = {
|
|
|
2067
2440
|
}
|
|
2068
2441
|
};
|
|
2069
2442
|
}
|
|
2070
|
-
this.resolveFileUrl = t.resolveFileUrl, this._eventManager = new
|
|
2443
|
+
this.resolveFileUrl = t.resolveFileUrl, this._eventManager = new Qt(this), this._extensionManager = new Fr(this, t);
|
|
2071
2444
|
let n = this._extensionManager.getTiptapExtensions(), r = this._extensionManager.hasExtension("ySync") || this._extensionManager.hasExtension("liveblocksExtension");
|
|
2072
2445
|
r && t.initialContent && console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider");
|
|
2073
2446
|
let i = {
|
|
2074
|
-
...
|
|
2447
|
+
...Qr,
|
|
2075
2448
|
...t._tiptapOptions,
|
|
2076
2449
|
element: null,
|
|
2077
2450
|
autofocus: t.autofocus ?? !1,
|
|
@@ -2084,7 +2457,7 @@ var hr = {
|
|
|
2084
2457
|
...t.domAttributes?.editor,
|
|
2085
2458
|
class: s("bn-editor", t.defaultStyles ? "bn-default-styles" : "", t.domAttributes?.editor?.class || "")
|
|
2086
2459
|
},
|
|
2087
|
-
transformPasted:
|
|
2460
|
+
transformPasted: Xr
|
|
2088
2461
|
}
|
|
2089
2462
|
};
|
|
2090
2463
|
try {
|
|
@@ -2096,7 +2469,7 @@ var hr = {
|
|
|
2096
2469
|
id: o.options.generateID()
|
|
2097
2470
|
}]);
|
|
2098
2471
|
if (!Array.isArray(e) || e.length === 0) throw Error("initialContent must be a non-empty array of blocks, received: " + e);
|
|
2099
|
-
let n =
|
|
2472
|
+
let n = $e(i.extensions), a = Ke({
|
|
2100
2473
|
type: "doc",
|
|
2101
2474
|
content: [{
|
|
2102
2475
|
type: "blockGroup",
|
|
@@ -2115,7 +2488,11 @@ var hr = {
|
|
|
2115
2488
|
if (a) return a;
|
|
2116
2489
|
let t = l.apply(this.pmSchema.nodes.doc, e), n = JSON.parse(JSON.stringify(t.toJSON()));
|
|
2117
2490
|
return n.content[0].content[0].attrs.id = "initialBlockId", a = ze.fromJSON(this.pmSchema, n), a;
|
|
2118
|
-
}, this.pmSchema.cached.blockNoteEditor = this, this.
|
|
2491
|
+
}, this.pmSchema.cached.blockNoteEditor = this, this._tiptapEditor.on("mount", () => {
|
|
2492
|
+
this.headless = !1;
|
|
2493
|
+
}), this._tiptapEditor.on("unmount", () => {
|
|
2494
|
+
this.headless = !0;
|
|
2495
|
+
}), this._blockManager = new Zt(this), this._exportManager = new mn(this), this._selectionManager = new Hr(this), this._stateManager = new Ur(this), this._styleManager = new Gr(this), this.emit("create");
|
|
2119
2496
|
}
|
|
2120
2497
|
_blockManager;
|
|
2121
2498
|
_eventManager;
|
|
@@ -2164,9 +2541,7 @@ var hr = {
|
|
|
2164
2541
|
isFocused() {
|
|
2165
2542
|
return this.headless ? !1 : this.prosemirrorView?.hasFocus() || !1;
|
|
2166
2543
|
}
|
|
2167
|
-
|
|
2168
|
-
return !this._tiptapEditor.isInitialized;
|
|
2169
|
-
}
|
|
2544
|
+
headless = !0;
|
|
2170
2545
|
focus() {
|
|
2171
2546
|
this.headless || this.prosemirrorView.focus();
|
|
2172
2547
|
}
|
|
@@ -2213,7 +2588,7 @@ var hr = {
|
|
|
2213
2588
|
this._tiptapEditor.on("selectionUpdate", e);
|
|
2214
2589
|
}
|
|
2215
2590
|
onBeforeChange(e) {
|
|
2216
|
-
return this._extensionManager.getExtension(
|
|
2591
|
+
return this._extensionManager.getExtension(pe).subscribe(e);
|
|
2217
2592
|
}
|
|
2218
2593
|
getTextCursorPosition() {
|
|
2219
2594
|
return this._selectionManager.getTextCursorPosition();
|
|
@@ -2278,6 +2653,15 @@ var hr = {
|
|
|
2278
2653
|
createLink(e, t) {
|
|
2279
2654
|
this._styleManager.createLink(e, t);
|
|
2280
2655
|
}
|
|
2656
|
+
getLinkMarkAtPos(e) {
|
|
2657
|
+
return this._styleManager.getLinkMarkAtPos(e);
|
|
2658
|
+
}
|
|
2659
|
+
editLink(e, t, n) {
|
|
2660
|
+
this._styleManager.editLink(e, t, n);
|
|
2661
|
+
}
|
|
2662
|
+
deleteLink(e) {
|
|
2663
|
+
this._styleManager.deleteLink(e);
|
|
2664
|
+
}
|
|
2281
2665
|
canNestBlock() {
|
|
2282
2666
|
return this._blockManager.canNestBlock();
|
|
2283
2667
|
}
|
|
@@ -2318,10 +2702,10 @@ var hr = {
|
|
|
2318
2702
|
return this._eventManager.onSelectionChange(e, t);
|
|
2319
2703
|
}
|
|
2320
2704
|
onMount(e) {
|
|
2321
|
-
this._eventManager.onMount(e);
|
|
2705
|
+
return this._eventManager.onMount(e);
|
|
2322
2706
|
}
|
|
2323
2707
|
onUnmount(e) {
|
|
2324
|
-
this._eventManager.onUnmount(e);
|
|
2708
|
+
return this._eventManager.onUnmount(e);
|
|
2325
2709
|
}
|
|
2326
2710
|
getSelectionBoundingBox() {
|
|
2327
2711
|
return this._selectionManager.getSelectionBoundingBox();
|
|
@@ -2339,7 +2723,7 @@ var hr = {
|
|
|
2339
2723
|
pasteMarkdown(e) {
|
|
2340
2724
|
return this._exportManager.pasteMarkdown(e);
|
|
2341
2725
|
}
|
|
2342
|
-
},
|
|
2726
|
+
}, ei = class {
|
|
2343
2727
|
constructor(e, t, n) {
|
|
2344
2728
|
this.mappings = t, this.options = n;
|
|
2345
2729
|
}
|
|
@@ -2363,7 +2747,7 @@ var hr = {
|
|
|
2363
2747
|
};
|
|
2364
2748
|
//#endregion
|
|
2365
2749
|
//#region src/exporter/mapping.ts
|
|
2366
|
-
function
|
|
2750
|
+
function ti(e) {
|
|
2367
2751
|
return {
|
|
2368
2752
|
createBlockMapping: (e) => e,
|
|
2369
2753
|
createInlineContentMapping: (e) => e,
|
|
@@ -2372,7 +2756,7 @@ function vr(e) {
|
|
|
2372
2756
|
}
|
|
2373
2757
|
//#endregion
|
|
2374
2758
|
//#region src/util/combineByGroup.ts
|
|
2375
|
-
function
|
|
2759
|
+
function ni(e, ...t) {
|
|
2376
2760
|
let n = [...e];
|
|
2377
2761
|
for (let e of t) for (let t of e) {
|
|
2378
2762
|
let e = n.findLastIndex((e) => e.group === t.group);
|
|
@@ -2381,6 +2765,6 @@ function yr(e, ...t) {
|
|
|
2381
2765
|
return n;
|
|
2382
2766
|
}
|
|
2383
2767
|
//#endregion
|
|
2384
|
-
export {
|
|
2768
|
+
export { R as _, Ir as a, yt as b, W as c, Yt as d, Xt as f, z as g, B as h, $r as i, U as l, Mt as m, ti as n, dr as o, Jt as p, ei as r, pn as s, ni as t, qt as u, xt as v, vt as x, bt as y };
|
|
2385
2769
|
|
|
2386
|
-
//# sourceMappingURL=src-
|
|
2770
|
+
//# sourceMappingURL=src-DQfz4zLM.js.map
|