@blocknote/core 0.48.1 → 0.50.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-BEvIOzln.cjs → blocks-BFnTypT-.cjs} +3 -3
- package/dist/blocks-BFnTypT-.cjs.map +1 -0
- package/dist/{blocks-DYl7UTS4.js → blocks-UU7EM-QM.js} +601 -570
- package/dist/blocks-UU7EM-QM.js.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 +19 -16
- package/dist/comments.js.map +1 -1
- package/dist/{en-QsSI16s5.js → en-B9hMApn4.js} +4 -2
- package/dist/en-B9hMApn4.js.map +1 -0
- package/dist/{en-C4ykW581.cjs → en-Cj5r8sW_.cjs} +2 -2
- package/dist/en-Cj5r8sW_.cjs.map +1 -0
- package/dist/extensions-CYsFi5Is.cjs +2 -0
- package/dist/extensions-CYsFi5Is.cjs.map +1 -0
- package/dist/{extensions-3nf9PPhA.js → extensions-CkLT--Nc.js} +244 -250
- package/dist/extensions-CkLT--Nc.js.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +2 -2
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +67 -23
- package/dist/locales.js.map +1 -1
- package/dist/src-DsJ6yzs9.cjs +5 -0
- package/dist/src-DsJ6yzs9.cjs.map +1 -0
- package/dist/{src-Hjv1f5lc.js → src-SVFpMAWE.js} +754 -366
- package/dist/src-SVFpMAWE.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/api/clipboard/toClipboard/copyExtension.ts +21 -16
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.ts +14 -1
- package/src/blocks/Quote/block.ts +9 -0
- package/src/blocks/Table/TableExtension.ts +38 -9
- package/src/blocks/Table/block.ts +26 -0
- package/src/blocks/defaultBlocks.ts +34 -1
- package/src/comments/extension.ts +35 -11
- package/src/comments/threadstore/yjs/YjsThreadStore.test.ts +3 -2
- package/src/comments/threadstore/yjs/YjsThreadStore.ts +4 -4
- package/src/editor/Block.css +14 -18
- package/src/editor/BlockNoteEditor.ts +84 -5
- package/src/editor/editor.css +5 -0
- package/src/editor/managers/ExtensionManager/extensions.ts +8 -27
- 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/SideMenu/SideMenu.ts +2 -2
- package/src/extensions/TableHandles/TableHandles.ts +2 -0
- 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 +238 -0
- package/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts +3 -5
- package/src/i18n/locales/ar.ts +3 -1
- package/src/i18n/locales/de.ts +3 -1
- package/src/i18n/locales/en.ts +3 -1
- package/src/i18n/locales/es.ts +3 -1
- package/src/i18n/locales/fa.ts +3 -1
- package/src/i18n/locales/fr.ts +3 -1
- package/src/i18n/locales/he.ts +3 -1
- package/src/i18n/locales/hr.ts +3 -1
- package/src/i18n/locales/is.ts +3 -1
- package/src/i18n/locales/it.ts +3 -1
- package/src/i18n/locales/ja.ts +3 -1
- package/src/i18n/locales/ko.ts +3 -1
- package/src/i18n/locales/nl.ts +3 -1
- package/src/i18n/locales/no.ts +3 -1
- package/src/i18n/locales/pl.ts +3 -1
- package/src/i18n/locales/pt.ts +3 -1
- package/src/i18n/locales/ru.ts +3 -1
- package/src/i18n/locales/sk.ts +3 -1
- package/src/i18n/locales/uk.ts +3 -1
- package/src/i18n/locales/uz.ts +3 -1
- package/src/i18n/locales/vi.ts +3 -1
- package/src/i18n/locales/zh-tw.ts +3 -1
- package/src/i18n/locales/zh.ts +3 -1
- package/src/schema/inlineContent/types.ts +1 -1
- package/types/src/comments/extension.d.ts +2 -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 +25 -0
- package/types/src/extensions/tiptap-extensions/Link/link.test.d.ts +1 -0
- package/types/src/i18n/locales/en.d.ts +2 -0
- package/types/src/i18n/locales/fa.d.ts +2 -0
- package/types/src/i18n/locales/sk.d.ts +2 -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/en-C4ykW581.cjs.map +0 -1
- package/dist/en-QsSI16s5.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 S, pt as
|
|
2
|
-
import { C as
|
|
3
|
-
import { r as
|
|
4
|
-
import { t as
|
|
5
|
-
import { t as
|
|
6
|
-
import { t as
|
|
7
|
-
import { DOMParser as
|
|
8
|
-
import { ReplaceAroundStep as
|
|
9
|
-
import { Editor 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 S, pt as ae, rn as oe, t as se, tn as ce, vn as C, vt as le, wt as ue } from "./blocks-UU7EM-QM.js";
|
|
2
|
+
import { C as de, D as fe, E as pe, O as me, S as he, T as ge, _ as _e, d as ve, f as ye, k as be, l as xe, m as Se, n as Ce, o as we, p as Te, t as Ee, u as De, v as Oe, w as ke, x as Ae, y as w } from "./extensions-CkLT--Nc.js";
|
|
3
|
+
import { r as je, t as Me } from "./BlockNoteExtension-B6RhuQ3V.js";
|
|
4
|
+
import { t as Ne } from "./ShowSelection-BsHFfdMi.js";
|
|
5
|
+
import { t as Pe } from "./en-B9hMApn4.js";
|
|
6
|
+
import { t as Fe } from "./EventEmitter-CuPnGDYt.js";
|
|
7
|
+
import { DOMParser as Ie, DOMSerializer as Le, Fragment as T, Node as Re, NodeRange as ze, Slice as E } from "prosemirror-model";
|
|
8
|
+
import { ReplaceAroundStep as D, ReplaceStep as Be, canJoin as Ve, liftTarget as He } from "prosemirror-transform";
|
|
9
|
+
import { Editor as Ue, Extension as O, Mark as k, Node as A, combineTransactionSteps as We, createDocument as Ge, extensions as j, findChildrenInRange as Ke, findParentNodeClosestToPos as qe, getAttributes as Je, getChangedRanges as Ye, getMarkRange as Xe, getMarksBetween as Ze, getSchema as Qe, isNodeSelection as $e, markPasteRule as et, mergeAttributes as M, posToDOMRect as tt, selectionToInsertionEnd as nt } from "@tiptap/core";
|
|
10
10
|
import { NodeSelection as N, Plugin as P, TextSelection as F } from "prosemirror-state";
|
|
11
11
|
import { Fragment as I, Slice as L } from "@tiptap/pm/model";
|
|
12
|
-
import { CellSelection as R, TableMap 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";
|
|
12
|
+
import { CellSelection as R, TableMap as rt } from "prosemirror-tables";
|
|
13
|
+
import { Plugin as z, PluginKey as B } from "@tiptap/pm/state";
|
|
14
|
+
import it from "remark-gfm";
|
|
15
|
+
import { unified as at } from "unified";
|
|
16
|
+
import ot from "remark-parse";
|
|
17
|
+
import st, { defaultHandlers as ct } from "remark-rehype";
|
|
18
|
+
import lt from "rehype-stringify";
|
|
19
|
+
import { InputRule as ut, inputRules as dt } from "@handlewithcare/prosemirror-inputrules";
|
|
20
|
+
import { keymap as ft } from "@tiptap/pm/keymap";
|
|
21
|
+
import { Gapcursor as pt } from "@tiptap/extensions/gap-cursor";
|
|
22
|
+
import { Text as mt } from "@tiptap/extension-text";
|
|
24
23
|
//#region src/schema/inlineContent/createSpec.ts
|
|
25
|
-
function
|
|
24
|
+
function ht(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 gt(e, t) {
|
|
42
|
+
return l(A.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 ht(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 _t(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
|
|
92
|
+
return r === "after" && (u += l.node.nodeSize), e.step(new Be(u, u, new E(T.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 V(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 vt(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
|
+
V(i) && e.delete(r, r + i.nodeSize);
|
|
112
111
|
}
|
|
113
112
|
}
|
|
114
|
-
function
|
|
115
|
-
|
|
113
|
+
function H(e, t) {
|
|
114
|
+
vt(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 = V(i), c = V(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 D(t, t + n.nodeSize, a - o.nodeSize + 1, a - 1, E.empty, 0, !1));
|
|
129
128
|
return;
|
|
130
129
|
}
|
|
131
130
|
if (c) {
|
|
132
|
-
e.step(new
|
|
131
|
+
e.step(new D(t, t + n.nodeSize, r + 1, r + i.nodeSize - 1, E.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 U(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) => H(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 yt(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);
|
|
@@ -190,17 +189,17 @@ function gt(e, n, r, i, a) {
|
|
|
190
189
|
let t = e.schema.styleSpecs[r.type.name].implementation.render(r.attrs.stringValue, e);
|
|
191
190
|
t.contentDOM.appendChild(n), n = t.dom;
|
|
192
191
|
} else {
|
|
193
|
-
let e = r.type.spec.toDOM(r, !0), t =
|
|
192
|
+
let e = r.type.spec.toDOM(r, !0), t = Le.renderSpec(document, e);
|
|
194
193
|
t.contentDOM.appendChild(n), n = t.dom;
|
|
195
194
|
}
|
|
196
195
|
s.appendChild(n);
|
|
197
196
|
} else {
|
|
198
|
-
let e = r.serializeFragment(
|
|
197
|
+
let e = r.serializeFragment(T.from([t]), a);
|
|
199
198
|
s.appendChild(e);
|
|
200
199
|
}
|
|
201
200
|
return s;
|
|
202
201
|
}
|
|
203
|
-
function
|
|
202
|
+
function bt(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 = yt(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 = xt(e, t.children, n, r);
|
|
221
220
|
s.contentDOM?.append(i);
|
|
222
221
|
}
|
|
223
222
|
return s.dom;
|
|
@@ -226,60 +225,60 @@ 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(St(e, t.children, n, r)), c.dom;
|
|
230
229
|
}
|
|
231
|
-
function
|
|
230
|
+
function xt(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 = bt(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 St = (e, t, n, r) => {
|
|
239
|
+
let i = e.pmSchema.nodes.blockGroup, a = i.spec.toDOM(i.create({})), o = xt(e, t, n, r);
|
|
241
240
|
return a.contentDOM?.appendChild(o), a.dom;
|
|
242
|
-
},
|
|
241
|
+
}, Ct = (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), wt = (e) => (e.querySelectorAll("[data-content-type=\"checkListItem\"] input").forEach((e) => {
|
|
250
249
|
e.disabled = !0;
|
|
251
|
-
}), e),
|
|
250
|
+
}), e), Tt = (e) => (e.querySelectorAll(".bn-toggle-wrapper[data-show-children=\"false\"]").forEach((e) => {
|
|
252
251
|
e.setAttribute("data-show-children", "true");
|
|
253
|
-
}), e),
|
|
252
|
+
}), e), Et = (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), Dt = (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), Ot = (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),
|
|
264
|
-
let n =
|
|
265
|
-
yt,
|
|
266
|
-
bt,
|
|
267
|
-
xt,
|
|
268
|
-
St,
|
|
262
|
+
}), e), kt = (e, t) => {
|
|
263
|
+
let n = Le.fromSchema(e), r = [
|
|
269
264
|
Ct,
|
|
270
|
-
wt
|
|
265
|
+
wt,
|
|
266
|
+
Tt,
|
|
267
|
+
Et,
|
|
268
|
+
Dt,
|
|
269
|
+
Ot
|
|
271
270
|
];
|
|
272
271
|
return { serializeBlocks: (e, i) => {
|
|
273
|
-
let a =
|
|
272
|
+
let a = St(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 At(e) {
|
|
281
280
|
return e.transact((e) => {
|
|
282
|
-
let t =
|
|
281
|
+
let t = C(e.doc, e.selection.anchor);
|
|
283
282
|
if (e.selection instanceof R) return {
|
|
284
283
|
type: "cell",
|
|
285
284
|
anchorBlockId: t.node.attrs.id,
|
|
@@ -291,7 +290,7 @@ function Tt(e) {
|
|
|
291
290
|
anchorBlockId: t.node.attrs.id
|
|
292
291
|
};
|
|
293
292
|
{
|
|
294
|
-
let n =
|
|
293
|
+
let n = C(e.doc, e.selection.head);
|
|
295
294
|
return {
|
|
296
295
|
type: "text",
|
|
297
296
|
anchorBlockId: t.node.attrs.id,
|
|
@@ -302,7 +301,7 @@ function Tt(e) {
|
|
|
302
301
|
}
|
|
303
302
|
});
|
|
304
303
|
}
|
|
305
|
-
function
|
|
304
|
+
function jt(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;
|
|
@@ -321,86 +320,86 @@ function W(e) {
|
|
|
321
320
|
children: W(e.children)
|
|
322
321
|
}).flat();
|
|
323
322
|
}
|
|
324
|
-
function
|
|
323
|
+
function Mt(e, t, n) {
|
|
325
324
|
e.transact((r) => {
|
|
326
|
-
let i = e.getSelection()?.blocks || [e.getTextCursorPosition().block], a =
|
|
327
|
-
e.removeBlocks(i), e.insertBlocks(W(i), t, n),
|
|
325
|
+
let i = e.getSelection()?.blocks || [e.getTextCursorPosition().block], a = At(e);
|
|
326
|
+
e.removeBlocks(i), e.insertBlocks(W(i), t, n), jt(r, a);
|
|
328
327
|
});
|
|
329
328
|
}
|
|
330
|
-
function
|
|
329
|
+
function Nt(e) {
|
|
331
330
|
return !e || e.type !== "columnList";
|
|
332
331
|
}
|
|
333
|
-
function
|
|
332
|
+
function Pt(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 Nt(a) ? {
|
|
338
337
|
referenceBlock: r,
|
|
339
338
|
placement: i
|
|
340
|
-
} :
|
|
339
|
+
} : Pt(e, i === "after" ? r : e.getPrevBlock(r), a);
|
|
341
340
|
}
|
|
342
|
-
function
|
|
341
|
+
function Ft(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 Nt(a) ? {
|
|
347
346
|
referenceBlock: r,
|
|
348
347
|
placement: i
|
|
349
|
-
} :
|
|
348
|
+
} : Ft(e, i === "before" ? r : e.getNextBlock(r), a);
|
|
350
349
|
}
|
|
351
|
-
function
|
|
350
|
+
function It(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 = Pt(e, e.getPrevBlock(t), e.getParentBlock(t));
|
|
353
|
+
n && Mt(e, n.referenceBlock, n.placement);
|
|
355
354
|
});
|
|
356
355
|
}
|
|
357
|
-
function
|
|
356
|
+
function Lt(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 = Ft(e, e.getNextBlock(n), e.getParentBlock(n));
|
|
359
|
+
r && Mt(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 Rt(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 = T.from(c ? t.create() : null), u = new E(T.from(t.create(null, T.from(n.create(null, l)))), c ? 3 : 1, 0), d = a.start, f = a.end;
|
|
372
|
+
return e.step(new D(d - (c ? 3 : 1), f, d, f, u, 1, !0)).scrollIntoView(), !0;
|
|
374
373
|
}
|
|
375
|
-
function
|
|
376
|
-
return e.transact((t) =>
|
|
374
|
+
function zt(e) {
|
|
375
|
+
return e.transact((t) => Rt(t, e.pmSchema.nodes.blockContainer, e.pmSchema.nodes.blockGroup));
|
|
377
376
|
}
|
|
378
|
-
function
|
|
377
|
+
function Bt(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 D(i - (s ? 2 : 1), a, i, a, new E(T.from(t.create(null, n.create())), s ? 2 : 1, 0), +!s, !0)), r = new ze(e.doc.resolve(r.$from.pos), e.doc.resolve(a), r.depth);
|
|
383
382
|
}
|
|
384
|
-
let o =
|
|
383
|
+
let o = He(r);
|
|
385
384
|
if (o == null) return !1;
|
|
386
385
|
e.lift(r, o);
|
|
387
386
|
let s = e.doc.resolve(e.mapping.map(i, -1) - 1);
|
|
388
|
-
return
|
|
387
|
+
return Ve(e.doc, s.pos) && s.nodeBefore.type === s.nodeAfter.type && e.join(s.pos), e.scrollIntoView(), !0;
|
|
389
388
|
}
|
|
390
389
|
function G(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 ? Bt(e, t, n, a) : !1;
|
|
393
392
|
}
|
|
394
|
-
function
|
|
393
|
+
function Vt(e) {
|
|
395
394
|
return e.transact((t) => G(t, e.pmSchema.nodes.blockContainer, e.pmSchema.nodes.blockGroup));
|
|
396
395
|
}
|
|
397
|
-
function
|
|
396
|
+
function Ht(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 Ut(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 Wt(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 Gt(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 Kt(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 qt(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 Jt = 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) => oe(e.doc, this.editor.pmSchema));
|
|
441
440
|
}
|
|
442
441
|
getBlock(e) {
|
|
443
|
-
return this.editor.transact((t) =>
|
|
442
|
+
return this.editor.transact((t) => Wt(t.doc, e));
|
|
444
443
|
}
|
|
445
444
|
getPrevBlock(e) {
|
|
446
|
-
return this.editor.transact((t) =>
|
|
445
|
+
return this.editor.transact((t) => Gt(t.doc, e));
|
|
447
446
|
}
|
|
448
447
|
getNextBlock(e) {
|
|
449
|
-
return this.editor.transact((t) =>
|
|
448
|
+
return this.editor.transact((t) => Kt(t.doc, e));
|
|
450
449
|
}
|
|
451
450
|
getParentBlock(e) {
|
|
452
|
-
return this.editor.transact((t) =>
|
|
451
|
+
return this.editor.transact((t) => qt(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) => _t(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) => U(t, e, []).removedBlocks);
|
|
471
470
|
}
|
|
472
471
|
replaceBlocks(e, t) {
|
|
473
|
-
return this.editor.transact((n) =>
|
|
472
|
+
return this.editor.transact((n) => U(n, e, t));
|
|
474
473
|
}
|
|
475
474
|
canNestBlock() {
|
|
476
|
-
return
|
|
475
|
+
return Ht(this.editor);
|
|
477
476
|
}
|
|
478
477
|
nestBlock() {
|
|
479
|
-
|
|
478
|
+
zt(this.editor);
|
|
480
479
|
}
|
|
481
480
|
canUnnestBlock() {
|
|
482
|
-
return
|
|
481
|
+
return Ut(this.editor);
|
|
483
482
|
}
|
|
484
483
|
unnestBlock() {
|
|
485
|
-
|
|
484
|
+
Vt(this.editor);
|
|
486
485
|
}
|
|
487
486
|
moveBlocksUp() {
|
|
488
|
-
return
|
|
487
|
+
return It(this.editor);
|
|
489
488
|
}
|
|
490
489
|
moveBlocksDown() {
|
|
491
|
-
return
|
|
490
|
+
return Lt(this.editor);
|
|
492
491
|
}
|
|
493
|
-
},
|
|
492
|
+
}, Yt = class extends Fe {
|
|
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 && Xt(n) || e(this.editor, { getChanges() {
|
|
516
|
+
return me(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 && Xt(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 Xt(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 Zt(e) {
|
|
549
548
|
return Array.prototype.indexOf.call(e.parentElement.childNodes, e);
|
|
550
549
|
}
|
|
551
|
-
function
|
|
550
|
+
function Qt(e) {
|
|
552
551
|
return e.nodeType === 3 && !/\S/.test(e.nodeValue || "");
|
|
553
552
|
}
|
|
554
|
-
function
|
|
553
|
+
function $t(e) {
|
|
555
554
|
e.querySelectorAll("li > ul, li > ol").forEach((e) => {
|
|
556
|
-
let t =
|
|
555
|
+
let t = Zt(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 (Qt(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 en(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 tn = null;
|
|
574
|
+
function nn() {
|
|
575
|
+
return tn ||= document.implementation.createHTMLDocument("title");
|
|
577
576
|
}
|
|
578
|
-
function
|
|
577
|
+
function rn(e) {
|
|
579
578
|
if (typeof e == "string") {
|
|
580
|
-
let t =
|
|
579
|
+
let t = nn().createElement("div");
|
|
581
580
|
t.innerHTML = e, e = t;
|
|
582
581
|
}
|
|
583
|
-
return
|
|
582
|
+
return $t(e), en(e), e;
|
|
584
583
|
}
|
|
585
584
|
//#endregion
|
|
586
585
|
//#region src/api/parsers/html/util/normalizeWhitespace.ts
|
|
587
|
-
function
|
|
586
|
+
function an(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 on(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 sn(e) {
|
|
604
|
+
an(e) || on(e);
|
|
606
605
|
}
|
|
607
606
|
//#endregion
|
|
608
607
|
//#region src/api/parsers/html/parseHTML.ts
|
|
609
608
|
function K(e, t) {
|
|
610
|
-
let n =
|
|
611
|
-
|
|
612
|
-
let r =
|
|
609
|
+
let n = rn(e);
|
|
610
|
+
sn(n);
|
|
611
|
+
let r = Ie.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 cn(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 ln(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
650
|
function q(t) {
|
|
652
|
-
return
|
|
653
|
-
...
|
|
654
|
-
image: (t, n) => e(String(n?.url || "")) ?
|
|
655
|
-
code:
|
|
651
|
+
return at().use(ot).use(it).use(st, { handlers: {
|
|
652
|
+
...ct,
|
|
653
|
+
image: (t, n) => e(String(n?.url || "")) ? ln(t, n) : ct.image(t, n),
|
|
654
|
+
code: cn,
|
|
656
655
|
blockquote: (e, t) => {
|
|
657
656
|
let n = {
|
|
658
657
|
type: "element",
|
|
@@ -662,31 +661,31 @@ function q(t) {
|
|
|
662
661
|
};
|
|
663
662
|
return e.patch(t, n), e.applyData(t, n);
|
|
664
663
|
}
|
|
665
|
-
} }).use(
|
|
664
|
+
} }).use(lt).processSync(t).value;
|
|
666
665
|
}
|
|
667
|
-
function
|
|
666
|
+
function un(e, t) {
|
|
668
667
|
return K(q(e), t);
|
|
669
668
|
}
|
|
670
669
|
//#endregion
|
|
671
670
|
//#region src/editor/managers/ExportManager.ts
|
|
672
|
-
var
|
|
671
|
+
var dn = class {
|
|
673
672
|
constructor(e) {
|
|
674
673
|
this.editor = e;
|
|
675
674
|
}
|
|
676
675
|
blocksToHTMLLossy(e = this.editor.document) {
|
|
677
|
-
return
|
|
676
|
+
return be(this.editor.pmSchema, this.editor).exportBlocks(e, {});
|
|
678
677
|
}
|
|
679
678
|
blocksToFullHTML(e = this.editor.document) {
|
|
680
|
-
return
|
|
679
|
+
return kt(this.editor.pmSchema, this.editor).serializeBlocks(e, {});
|
|
681
680
|
}
|
|
682
681
|
tryParseHTMLToBlocks(e) {
|
|
683
682
|
return K(e, this.editor.pmSchema);
|
|
684
683
|
}
|
|
685
684
|
blocksToMarkdownLossy(e = this.editor.document) {
|
|
686
|
-
return
|
|
685
|
+
return De(e, this.editor.pmSchema, this.editor, {});
|
|
687
686
|
}
|
|
688
687
|
tryParseMarkdownToBlocks(e) {
|
|
689
|
-
return
|
|
688
|
+
return un(e, this.editor.pmSchema);
|
|
690
689
|
}
|
|
691
690
|
pasteHTML(e, t = !1) {
|
|
692
691
|
let n = e;
|
|
@@ -703,7 +702,355 @@ var on = class {
|
|
|
703
702
|
let t = q(e);
|
|
704
703
|
return this.pasteHTML(t);
|
|
705
704
|
}
|
|
706
|
-
},
|
|
705
|
+
}, fn = "aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2";
|
|
706
|
+
//#endregion
|
|
707
|
+
//#region src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts
|
|
708
|
+
function pn(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 mn = new Set(pn(fn)), hn = new Set(["localhost"]), gn = /[.,;:!?"']+$/, _n = /(?:https?|ftp|ftps):\/\/[^\s]+/g, vn = /mailto:[^\s]+/g, yn = /[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}/g, bn = /(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(?::\d{1,5})?(?:[/?#][^\s]*)?/g;
|
|
723
|
+
function xn(e) {
|
|
724
|
+
let t = e, n = !0;
|
|
725
|
+
for (; n;) {
|
|
726
|
+
n = !1;
|
|
727
|
+
let e = t;
|
|
728
|
+
t = t.replace(gn, ""), t !== e && (n = !0);
|
|
729
|
+
for (let [e, r] of [["(", ")"], ["[", "]"]]) for (; t.endsWith(r);) {
|
|
730
|
+
let i = Sn(t, e);
|
|
731
|
+
if (Sn(t, r) > i) t = t.slice(0, -1), n = !0;
|
|
732
|
+
else break;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
return t;
|
|
736
|
+
}
|
|
737
|
+
function Sn(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 Cn(e) {
|
|
743
|
+
let t = e.split(".");
|
|
744
|
+
return t[t.length - 1].toLowerCase();
|
|
745
|
+
}
|
|
746
|
+
function wn(e) {
|
|
747
|
+
let t = Cn(e);
|
|
748
|
+
return mn.has(t);
|
|
749
|
+
}
|
|
750
|
+
function Tn(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 En(e, t) {
|
|
754
|
+
if (!e) return [];
|
|
755
|
+
let n = t?.defaultProtocol || "http", r = [];
|
|
756
|
+
for (let t of e.matchAll(_n)) 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(vn)) 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(yn)) 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(bn)) 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 = xn(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 (!wn(e)) continue;
|
|
791
|
+
}
|
|
792
|
+
if (e.type === "email") {
|
|
793
|
+
let e = t.split("@")[1];
|
|
794
|
+
if (!wn(e)) continue;
|
|
795
|
+
}
|
|
796
|
+
let a = Tn(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 Dn(e, t = "http") {
|
|
809
|
+
if (!e) return [X(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 (J(i)) return [
|
|
817
|
+
X(n, 0, 1),
|
|
818
|
+
Y(i, 1, 1 + i.length, t),
|
|
819
|
+
X(r, 1 + i.length, e.length)
|
|
820
|
+
];
|
|
821
|
+
}
|
|
822
|
+
if (e.endsWith(".") && e.length > 1) {
|
|
823
|
+
let n = e.slice(0, -1);
|
|
824
|
+
if (J(n)) return [Y(n, 0, n.length, t), X(".", n.length, e.length)];
|
|
825
|
+
}
|
|
826
|
+
return J(e) ? [Y(e, 0, e.length, t)] : [X(e, 0, e.length)];
|
|
827
|
+
}
|
|
828
|
+
function J(e) {
|
|
829
|
+
if (/^(?:https?|ftp|ftps):\/\/[^\s]+$/.test(e) || /^mailto:[^\s]+$/.test(e) || hn.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 (mn.has(e)) return !0;
|
|
834
|
+
}
|
|
835
|
+
return !1;
|
|
836
|
+
}
|
|
837
|
+
function Y(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: Tn(e, i, r),
|
|
844
|
+
start: t,
|
|
845
|
+
end: n
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
function X(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 Z = "[\0- \xA0 -\u2029 ]", On = new RegExp(Z), kn = RegExp(`${Z}$`), An = new RegExp(Z, "g");
|
|
861
|
+
//#endregion
|
|
862
|
+
//#region src/extensions/tiptap-extensions/Link/helpers/autolink.ts
|
|
863
|
+
function jn(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 Mn(e) {
|
|
867
|
+
return new z({
|
|
868
|
+
key: new B("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 (Ye(We(n.doc, [...t])).forEach(({ newRange: t }) => {
|
|
874
|
+
let n = Ke(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 (!kn.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(On).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 = Dn(n, e.defaultProtocol);
|
|
887
|
+
if (!jn(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
|
+
Ze(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 Nn(e) {
|
|
903
|
+
return new z({
|
|
904
|
+
key: new B("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 = Je(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 Pn(e) {
|
|
928
|
+
return new z({
|
|
929
|
+
key: new B("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 = En(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 Fn = "https", In = /^(?:(?:http|https|ftp|ftps|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z0-9+.\-]+(?:[^a-z+.\-:]|$))/i;
|
|
945
|
+
function Ln(e) {
|
|
946
|
+
if (!e) return !0;
|
|
947
|
+
let t = e.replace(An, "");
|
|
948
|
+
return In.test(t);
|
|
949
|
+
}
|
|
950
|
+
function Rn(e) {
|
|
951
|
+
let t = /^[a-z][a-z0-9+.-]*:\/\//i.test(e), n = /^[a-z][a-z0-9+.-]*:/i.test(e);
|
|
952
|
+
if (t || n && !e.includes("@")) return !0;
|
|
953
|
+
let r = (e.includes("@") ? e.split("@").pop() : e).split(/[/?#:]/)[0];
|
|
954
|
+
return !(/^\d{1,3}(\.\d{1,3}){3}$/.test(r) || !/\./.test(r));
|
|
955
|
+
}
|
|
956
|
+
var zn = k.create({
|
|
957
|
+
name: "link",
|
|
958
|
+
keepOnSplit: !1,
|
|
959
|
+
exitable: !0,
|
|
960
|
+
inclusive: !1,
|
|
961
|
+
addOptions() {
|
|
962
|
+
return {
|
|
963
|
+
HTMLAttributes: {
|
|
964
|
+
target: "_blank",
|
|
965
|
+
rel: "noopener noreferrer nofollow",
|
|
966
|
+
className: "bn-inline-content-section",
|
|
967
|
+
"data-inline-content-type": "link"
|
|
968
|
+
},
|
|
969
|
+
editor: void 0,
|
|
970
|
+
onClick: void 0,
|
|
971
|
+
isValidLink: Ln
|
|
972
|
+
};
|
|
973
|
+
},
|
|
974
|
+
addAttributes() {
|
|
975
|
+
return { href: {
|
|
976
|
+
default: null,
|
|
977
|
+
parseHTML(e) {
|
|
978
|
+
return e.getAttribute("href");
|
|
979
|
+
}
|
|
980
|
+
} };
|
|
981
|
+
},
|
|
982
|
+
parseHTML() {
|
|
983
|
+
let e = this.options.isValidLink;
|
|
984
|
+
return [{
|
|
985
|
+
tag: "a[href]",
|
|
986
|
+
getAttrs: (t) => {
|
|
987
|
+
let n = t.getAttribute("href");
|
|
988
|
+
return !n || !e(n) ? !1 : null;
|
|
989
|
+
}
|
|
990
|
+
}];
|
|
991
|
+
},
|
|
992
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
993
|
+
return this.options.isValidLink(e.href) ? [
|
|
994
|
+
"a",
|
|
995
|
+
M(e, this.options.HTMLAttributes),
|
|
996
|
+
0
|
|
997
|
+
] : [
|
|
998
|
+
"a",
|
|
999
|
+
M({
|
|
1000
|
+
...e,
|
|
1001
|
+
href: ""
|
|
1002
|
+
}, this.options.HTMLAttributes),
|
|
1003
|
+
0
|
|
1004
|
+
];
|
|
1005
|
+
},
|
|
1006
|
+
addPasteRules() {
|
|
1007
|
+
let e = this.options.isValidLink;
|
|
1008
|
+
return [et({
|
|
1009
|
+
find: (t) => {
|
|
1010
|
+
let n = [];
|
|
1011
|
+
if (t) {
|
|
1012
|
+
let r = En(t, { defaultProtocol: Fn }).filter((t) => t.isLink && e(t.value));
|
|
1013
|
+
for (let e of r) Rn(e.value) && n.push({
|
|
1014
|
+
text: e.value,
|
|
1015
|
+
data: { href: e.href },
|
|
1016
|
+
index: e.start
|
|
1017
|
+
});
|
|
1018
|
+
}
|
|
1019
|
+
return n;
|
|
1020
|
+
},
|
|
1021
|
+
type: this.type,
|
|
1022
|
+
getAttributes: (e) => ({ href: e.data?.href })
|
|
1023
|
+
})];
|
|
1024
|
+
},
|
|
1025
|
+
addProseMirrorPlugins() {
|
|
1026
|
+
let e = [];
|
|
1027
|
+
return e.push(Mn({
|
|
1028
|
+
type: this.type,
|
|
1029
|
+
defaultProtocol: Fn,
|
|
1030
|
+
validate: this.options.isValidLink,
|
|
1031
|
+
shouldAutoLink: Rn
|
|
1032
|
+
})), e.push(Nn({
|
|
1033
|
+
type: this.type,
|
|
1034
|
+
tiptapEditor: this.editor,
|
|
1035
|
+
editor: this.options.editor,
|
|
1036
|
+
onClick: this.options.onClick
|
|
1037
|
+
})), e.push(Pn({
|
|
1038
|
+
editor: this.editor,
|
|
1039
|
+
defaultProtocol: Fn,
|
|
1040
|
+
type: this.type,
|
|
1041
|
+
shouldAutoLink: Rn,
|
|
1042
|
+
isValidLink: this.options.isValidLink
|
|
1043
|
+
})), e;
|
|
1044
|
+
}
|
|
1045
|
+
}), Bn = Me(({ editor: e, options: t }) => ({
|
|
1046
|
+
key: "link",
|
|
1047
|
+
tiptapExtensions: [zn.configure({
|
|
1048
|
+
HTMLAttributes: t.HTMLAttributes ?? {},
|
|
1049
|
+
editor: e,
|
|
1050
|
+
onClick: t.onClick,
|
|
1051
|
+
...t.isValidLink ? { isValidLink: t.isValidLink } : {}
|
|
1052
|
+
})]
|
|
1053
|
+
})), Vn = [
|
|
707
1054
|
"vscode-editor-data",
|
|
708
1055
|
"blocknote/html",
|
|
709
1056
|
"text/markdown",
|
|
@@ -713,21 +1060,21 @@ var on = class {
|
|
|
713
1060
|
];
|
|
714
1061
|
//#endregion
|
|
715
1062
|
//#region src/api/clipboard/fromClipboard/handleFileInsertion.ts
|
|
716
|
-
function
|
|
1063
|
+
function Hn(e, t) {
|
|
717
1064
|
if (!e.startsWith(".") || !t.startsWith(".")) throw Error("The strings provided are not valid file extensions.");
|
|
718
1065
|
return e === t;
|
|
719
1066
|
}
|
|
720
|
-
function
|
|
1067
|
+
function Un(e, t) {
|
|
721
1068
|
let n = e.split("/"), r = t.split("/");
|
|
722
1069
|
if (n.length !== 2) throw Error(`The string ${e} is not a valid MIME type.`);
|
|
723
1070
|
if (r.length !== 2) throw Error(`The string ${t} is not a valid MIME type.`);
|
|
724
1071
|
return n[1] === "*" || r[1] === "*" ? n[0] === r[0] : (n[0] === "*" || r[0] === "*" || n[0] === r[0]) && n[1] === r[1];
|
|
725
1072
|
}
|
|
726
|
-
function
|
|
1073
|
+
function Wn(e, t, n, r = "after") {
|
|
727
1074
|
let i;
|
|
728
1075
|
return i = Array.isArray(t.content) && t.content.length === 0 ? e.updateBlock(t, n).id : e.insertBlocks([n], t, r)[0].id, i;
|
|
729
1076
|
}
|
|
730
|
-
async function
|
|
1077
|
+
async function Gn(e, t) {
|
|
731
1078
|
if (!t.uploadFile) {
|
|
732
1079
|
console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");
|
|
733
1080
|
return;
|
|
@@ -735,7 +1082,7 @@ async function un(e, t) {
|
|
|
735
1082
|
let n = "dataTransfer" in e ? e.dataTransfer : e.clipboardData;
|
|
736
1083
|
if (n === null) return;
|
|
737
1084
|
let r = null;
|
|
738
|
-
for (let e of
|
|
1085
|
+
for (let e of Vn) if (n.types.includes(e)) {
|
|
739
1086
|
r = e;
|
|
740
1087
|
break;
|
|
741
1088
|
}
|
|
@@ -747,7 +1094,7 @@ async function un(e, t) {
|
|
|
747
1094
|
let r = "file";
|
|
748
1095
|
for (let e of Object.values(t.schema.blockSpecs)) for (let t of e.implementation.meta?.fileBlockAccept || []) {
|
|
749
1096
|
let a = t.startsWith("."), o = i[n].getAsFile();
|
|
750
|
-
if (o && (!a && o.type &&
|
|
1097
|
+
if (o && (!a && o.type && Un(i[n].type, t) || a && Hn("." + o.name.split(".").pop(), t))) {
|
|
751
1098
|
r = e.config.type;
|
|
752
1099
|
break;
|
|
753
1100
|
}
|
|
@@ -760,7 +1107,7 @@ async function un(e, t) {
|
|
|
760
1107
|
}, i;
|
|
761
1108
|
if (e.type === "paste") {
|
|
762
1109
|
let e = t.getTextCursorPosition().block;
|
|
763
|
-
i =
|
|
1110
|
+
i = Wn(t, e, n);
|
|
764
1111
|
} else if (e.type === "drop") {
|
|
765
1112
|
let r = {
|
|
766
1113
|
left: e.clientX,
|
|
@@ -768,8 +1115,8 @@ async function un(e, t) {
|
|
|
768
1115
|
}, a = t.prosemirrorView.posAtCoords(r);
|
|
769
1116
|
if (!a) return;
|
|
770
1117
|
i = t.transact((e) => {
|
|
771
|
-
let i =
|
|
772
|
-
return
|
|
1118
|
+
let i = C(e.doc, a.pos), o = (t.domElement?.querySelector(`[data-id="${i.node.attrs.id}"]`))?.getBoundingClientRect();
|
|
1119
|
+
return Wn(t, t.getBlock(i.node.attrs.id), n, o && (o.top + o.bottom) / 2 > r.top ? "before" : "after");
|
|
773
1120
|
});
|
|
774
1121
|
} else return;
|
|
775
1122
|
let o = await t.uploadFile(a, i), s = typeof o == "string" ? { props: { url: o } } : { ...o };
|
|
@@ -780,23 +1127,23 @@ async function un(e, t) {
|
|
|
780
1127
|
}
|
|
781
1128
|
//#endregion
|
|
782
1129
|
//#region src/api/clipboard/fromClipboard/fileDropExtension.ts
|
|
783
|
-
var
|
|
1130
|
+
var Kn = (e) => O.create({
|
|
784
1131
|
name: "dropFile",
|
|
785
1132
|
addProseMirrorPlugins() {
|
|
786
1133
|
return [new P({ props: { handleDOMEvents: { drop(t, n) {
|
|
787
1134
|
if (!e.isEditable) return;
|
|
788
1135
|
let r = null;
|
|
789
|
-
for (let e of
|
|
1136
|
+
for (let e of Vn) if (n.dataTransfer.types.includes(e)) {
|
|
790
1137
|
r = e;
|
|
791
1138
|
break;
|
|
792
1139
|
}
|
|
793
|
-
return r === null ? !0 : r === "Files" ? (
|
|
1140
|
+
return r === null ? !0 : r === "Files" ? (Gn(n, e), !0) : !1;
|
|
794
1141
|
} } } })];
|
|
795
1142
|
}
|
|
796
|
-
}),
|
|
1143
|
+
}), 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
1144
|
//#endregion
|
|
798
1145
|
//#region src/api/clipboard/fromClipboard/handleVSCodePaste.ts
|
|
799
|
-
async function
|
|
1146
|
+
async function sr(e, t) {
|
|
800
1147
|
let { schema: n } = t.state;
|
|
801
1148
|
if (!e.clipboardData) return !1;
|
|
802
1149
|
let r = e.clipboardData.getData("text/plain");
|
|
@@ -807,36 +1154,36 @@ async function En(e, t) {
|
|
|
807
1154
|
}
|
|
808
1155
|
//#endregion
|
|
809
1156
|
//#region src/api/clipboard/fromClipboard/pasteExtension.ts
|
|
810
|
-
function
|
|
1157
|
+
function cr({ event: e, editor: t, prioritizeMarkdownOverHTML: n, plainTextAsMarkdown: r }) {
|
|
811
1158
|
if (t.transact((e) => e.selection.$from.parent.type.spec.code && e.selection.$to.parent.type.spec.code)) {
|
|
812
1159
|
let n = e.clipboardData?.getData("text/plain");
|
|
813
1160
|
if (n) return t.pasteText(n), !0;
|
|
814
1161
|
}
|
|
815
1162
|
let i;
|
|
816
|
-
for (let t of
|
|
1163
|
+
for (let t of Vn) if (e.clipboardData.types.includes(t)) {
|
|
817
1164
|
i = t;
|
|
818
1165
|
break;
|
|
819
1166
|
}
|
|
820
1167
|
if (!i) return !0;
|
|
821
|
-
if (i === "vscode-editor-data") return
|
|
822
|
-
if (i === "Files") return
|
|
1168
|
+
if (i === "vscode-editor-data") return sr(e, t.prosemirrorView), !0;
|
|
1169
|
+
if (i === "Files") return Gn(e, t), !0;
|
|
823
1170
|
let a = e.clipboardData.getData(i);
|
|
824
1171
|
if (i === "blocknote/html") return t.pasteHTML(a, !0), !0;
|
|
825
1172
|
if (i === "text/markdown") return t.pasteMarkdown(a), !0;
|
|
826
1173
|
if (n) {
|
|
827
1174
|
let n = e.clipboardData.getData("text/plain");
|
|
828
|
-
if (
|
|
1175
|
+
if (or(n)) return t.pasteMarkdown(n), !0;
|
|
829
1176
|
}
|
|
830
1177
|
return i === "text/html" ? (t.pasteHTML(a), !0) : r ? (t.pasteMarkdown(a), !0) : (t.pasteText(a), !0);
|
|
831
1178
|
}
|
|
832
|
-
var
|
|
1179
|
+
var lr = (e, t) => O.create({
|
|
833
1180
|
name: "pasteFromClipboard",
|
|
834
1181
|
addProseMirrorPlugins() {
|
|
835
1182
|
return [new P({ props: { handleDOMEvents: { paste(n, r) {
|
|
836
1183
|
if (r.preventDefault(), e.isEditable) return t({
|
|
837
1184
|
event: r,
|
|
838
1185
|
editor: e,
|
|
839
|
-
defaultPasteHandler: ({ prioritizeMarkdownOverHTML: t = !0, plainTextAsMarkdown: n = !0 } = {}) =>
|
|
1186
|
+
defaultPasteHandler: ({ prioritizeMarkdownOverHTML: t = !0, plainTextAsMarkdown: n = !0 } = {}) => cr({
|
|
840
1187
|
event: r,
|
|
841
1188
|
editor: e,
|
|
842
1189
|
prioritizeMarkdownOverHTML: t,
|
|
@@ -848,68 +1195,70 @@ var On = (e, t) => k.create({
|
|
|
848
1195
|
});
|
|
849
1196
|
//#endregion
|
|
850
1197
|
//#region src/api/clipboard/toClipboard/copyExtension.ts
|
|
851
|
-
function
|
|
1198
|
+
function ur(e, t, n) {
|
|
852
1199
|
let r = !1, i = e.state.selection instanceof R;
|
|
853
1200
|
if (!i) {
|
|
854
1201
|
let n = e.state.doc.slice(e.state.selection.from, e.state.selection.to, !1).content, i = [];
|
|
855
1202
|
for (let e = 0; e < n.childCount; e++) i.push(n.child(e));
|
|
856
1203
|
r = i.find((e) => e.type.isInGroup("bnBlock") || e.type.name === "blockGroup" || e.type.spec.group === "blockContent") === void 0, r && (t = n);
|
|
857
1204
|
}
|
|
858
|
-
let a, o =
|
|
1205
|
+
let a, o = be(e.state.schema, n);
|
|
859
1206
|
if (i) {
|
|
860
1207
|
t.firstChild?.type.name === "table" && (t = t.firstChild.content);
|
|
861
1208
|
let e = re(t, n.schema.inlineContentSchema, n.schema.styleSchema);
|
|
862
1209
|
a = `<table>${o.exportInlineContent(e, {})}</table>`;
|
|
863
1210
|
} else if (r) {
|
|
864
|
-
let e =
|
|
1211
|
+
let e = ce(t, n.schema.inlineContentSchema, n.schema.styleSchema);
|
|
865
1212
|
a = o.exportInlineContent(e, {});
|
|
866
1213
|
} else {
|
|
867
|
-
let e =
|
|
1214
|
+
let e = xe(t);
|
|
868
1215
|
a = o.exportBlocks(e, {});
|
|
869
1216
|
}
|
|
870
1217
|
return a;
|
|
871
1218
|
}
|
|
872
|
-
function
|
|
1219
|
+
function dr(e, t) {
|
|
873
1220
|
"node" in e.state.selection && e.state.selection.node.type.spec.group === "blockContent" && t.transact((t) => t.setSelection(new N(t.doc.resolve(e.state.selection.from - 1))));
|
|
874
|
-
let n = e.serializeForClipboard(e.state.selection.content()).dom.innerHTML, r = e.state.selection.content().content, i =
|
|
1221
|
+
let n = e.serializeForClipboard(e.state.selection.content()).dom.innerHTML, r = e.state.selection.content().content, i = ur(e, r, t);
|
|
875
1222
|
return {
|
|
876
1223
|
clipboardHTML: n,
|
|
877
1224
|
externalHTML: i,
|
|
878
|
-
markdown:
|
|
1225
|
+
markdown: ve(i)
|
|
879
1226
|
};
|
|
880
1227
|
}
|
|
881
|
-
var
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
1228
|
+
var fr = (e) => {
|
|
1229
|
+
if (e.state.selection.empty) return !0;
|
|
1230
|
+
let t = window.getSelection();
|
|
1231
|
+
if (t && !t.isCollapsed) {
|
|
1232
|
+
let e = t.focusNode;
|
|
1233
|
+
for (; e;) {
|
|
1234
|
+
if (e instanceof HTMLElement && e.getAttribute("contenteditable") === "false") return !0;
|
|
1235
|
+
e = e.parentElement;
|
|
1236
|
+
}
|
|
888
1237
|
}
|
|
889
1238
|
return !1;
|
|
890
|
-
},
|
|
1239
|
+
}, pr = (e, t, n) => {
|
|
891
1240
|
n.preventDefault(), n.clipboardData.clearData();
|
|
892
|
-
let { clipboardHTML: r, externalHTML: i, markdown: a } =
|
|
1241
|
+
let { clipboardHTML: r, externalHTML: i, markdown: a } = dr(t, e);
|
|
893
1242
|
n.clipboardData.setData("blocknote/html", r), n.clipboardData.setData("text/html", i), n.clipboardData.setData("text/plain", a);
|
|
894
|
-
},
|
|
1243
|
+
}, mr = (e) => O.create({
|
|
895
1244
|
name: "copyToClipboard",
|
|
896
1245
|
addProseMirrorPlugins() {
|
|
897
1246
|
return [new P({ props: { handleDOMEvents: {
|
|
898
1247
|
copy(t, n) {
|
|
899
|
-
return
|
|
1248
|
+
return fr(t) || pr(e, t, n), !0;
|
|
900
1249
|
},
|
|
901
1250
|
cut(t, n) {
|
|
902
|
-
return
|
|
1251
|
+
return fr(t) ? !0 : (pr(e, t, n), t.editable && t.dispatch(t.state.tr.deleteSelection()), !0);
|
|
903
1252
|
},
|
|
904
1253
|
dragstart(t, n) {
|
|
905
1254
|
if (!("node" in t.state.selection) || t.state.selection.node.type.spec.group !== "blockContent") return;
|
|
906
1255
|
e.transact((e) => e.setSelection(new N(e.doc.resolve(t.state.selection.from - 1)))), n.preventDefault(), n.dataTransfer.clearData();
|
|
907
|
-
let { clipboardHTML: r, externalHTML: i, markdown: a } =
|
|
1256
|
+
let { clipboardHTML: r, externalHTML: i, markdown: a } = dr(t, e);
|
|
908
1257
|
return n.dataTransfer.setData("blocknote/html", r), n.dataTransfer.setData("text/html", i), n.dataTransfer.setData("text/plain", a), !0;
|
|
909
1258
|
}
|
|
910
1259
|
} } })];
|
|
911
1260
|
}
|
|
912
|
-
}),
|
|
1261
|
+
}), hr = O.create({
|
|
913
1262
|
name: "blockBackgroundColor",
|
|
914
1263
|
addGlobalAttributes() {
|
|
915
1264
|
return [{
|
|
@@ -917,7 +1266,7 @@ var An = () => {
|
|
|
917
1266
|
attributes: { backgroundColor: ne() }
|
|
918
1267
|
}];
|
|
919
1268
|
}
|
|
920
|
-
}),
|
|
1269
|
+
}), gr = A.create({
|
|
921
1270
|
name: "hardBreak",
|
|
922
1271
|
inline: !0,
|
|
923
1272
|
group: "inline",
|
|
@@ -928,33 +1277,33 @@ var An = () => {
|
|
|
928
1277
|
return [{ tag: "br" }];
|
|
929
1278
|
},
|
|
930
1279
|
renderHTML({ HTMLAttributes: e }) {
|
|
931
|
-
return ["br",
|
|
1280
|
+
return ["br", M(this.options.HTMLAttributes, e)];
|
|
932
1281
|
},
|
|
933
1282
|
renderText() {
|
|
934
1283
|
return "\n";
|
|
935
1284
|
}
|
|
936
|
-
}),
|
|
1285
|
+
}), _r = (e, t) => {
|
|
937
1286
|
let n = e.resolve(t), r = n.depth - 1;
|
|
938
1287
|
if (r < 1) return;
|
|
939
1288
|
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
|
-
},
|
|
1289
|
+
if (a) return a.type.spec.group?.includes("bnBlock") ? x(e.resolve(i)) : _r(e, i);
|
|
1290
|
+
}, Q = (e, t) => {
|
|
942
1291
|
let n = e.resolve(t), r = n.index();
|
|
943
1292
|
if (r === 0) return;
|
|
944
1293
|
let i = n.posAtIndex(r - 1);
|
|
945
1294
|
return x(e.resolve(i));
|
|
946
|
-
},
|
|
1295
|
+
}, $ = (e, t) => {
|
|
947
1296
|
let n = e.resolve(t), r = n.index();
|
|
948
1297
|
if (r === n.node().childCount - 1) return;
|
|
949
1298
|
let i = n.posAtIndex(r + 1);
|
|
950
1299
|
return x(e.resolve(i));
|
|
951
|
-
},
|
|
1300
|
+
}, vr = (e, t) => {
|
|
952
1301
|
for (; t.childContainer;) {
|
|
953
1302
|
let n = t.childContainer.node, r = e.resolve(t.childContainer.beforePos + 1).posAtIndex(n.childCount - 1);
|
|
954
1303
|
t = x(e.resolve(r));
|
|
955
1304
|
}
|
|
956
1305
|
return t;
|
|
957
|
-
},
|
|
1306
|
+
}, 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
1307
|
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
1308
|
if (r.childContainer) {
|
|
960
1309
|
let n = e.doc.resolve(r.childContainer.beforePos + 1), i = e.doc.resolve(r.childContainer.afterPos - 1), a = n.blockRange(i);
|
|
@@ -968,12 +1317,12 @@ var An = () => {
|
|
|
968
1317
|
t(e.tr.delete(n.blockContent.afterPos - 1, r.blockContent.beforePos + 1));
|
|
969
1318
|
}
|
|
970
1319
|
return !0;
|
|
971
|
-
},
|
|
972
|
-
let r = x(t.doc.resolve(e)), i =
|
|
1320
|
+
}, xr = (e) => ({ state: t, dispatch: n }) => {
|
|
1321
|
+
let r = x(t.doc.resolve(e)), i = Q(t.doc, r.bnBlock.beforePos);
|
|
973
1322
|
if (!i) return !1;
|
|
974
|
-
let a =
|
|
975
|
-
return
|
|
976
|
-
},
|
|
1323
|
+
let a = vr(t.doc, i);
|
|
1324
|
+
return yr(a, r) ? br(t, n, a, r) : !1;
|
|
1325
|
+
}, Sr = O.create({
|
|
977
1326
|
priority: 50,
|
|
978
1327
|
addKeyboardShortcuts() {
|
|
979
1328
|
let e = () => this.editor.commands.first(({ chain: e, commands: t }) => [
|
|
@@ -983,7 +1332,7 @@ var An = () => {
|
|
|
983
1332
|
let n = v(e);
|
|
984
1333
|
if (!n.isBlockContainer) return !1;
|
|
985
1334
|
let r = e.selection.from === n.blockContent.beforePos + 1, i = n.blockContent.node.type.name === "paragraph";
|
|
986
|
-
return r && !i ? t.command(
|
|
1335
|
+
return r && !i ? t.command(ue(n.bnBlock.beforePos, {
|
|
987
1336
|
type: "paragraph",
|
|
988
1337
|
props: {}
|
|
989
1338
|
})) : !1;
|
|
@@ -997,15 +1346,15 @@ var An = () => {
|
|
|
997
1346
|
() => t.command(({ state: t }) => {
|
|
998
1347
|
let n = v(t);
|
|
999
1348
|
if (!n.isBlockContainer) return !1;
|
|
1000
|
-
let { bnBlock: r, blockContent: i } = n, a =
|
|
1349
|
+
let { bnBlock: r, blockContent: i } = n, a = Q(t.doc, n.bnBlock.beforePos);
|
|
1001
1350
|
if (!a || !a.isBlockContainer || a.blockContent.node.type.spec.content !== "inline*") return !1;
|
|
1002
1351
|
let o = t.selection.from === i.beforePos + 1, s = t.selection.empty, c = r.beforePos;
|
|
1003
|
-
return o && s ? e().command(
|
|
1352
|
+
return o && s ? e().command(xr(c)).scrollIntoView().run() : !1;
|
|
1004
1353
|
}),
|
|
1005
1354
|
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1006
1355
|
let r = v(e);
|
|
1007
1356
|
if (!r.isBlockContainer || e.selection.from !== r.blockContent.beforePos + 1) return !1;
|
|
1008
|
-
let i =
|
|
1357
|
+
let i = Q(e.doc, r.bnBlock.beforePos);
|
|
1009
1358
|
if (!i || i.isBlockContainer) return !1;
|
|
1010
1359
|
if (n) {
|
|
1011
1360
|
let e = i.bnBlock.afterPos - 1, n = t.doc.resolve(e - 1);
|
|
@@ -1019,15 +1368,15 @@ var An = () => {
|
|
|
1019
1368
|
let i = t.doc.resolve(r.bnBlock.beforePos);
|
|
1020
1369
|
if (i.nodeBefore || i.node().type.name !== "column") return !1;
|
|
1021
1370
|
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),
|
|
1371
|
+
return n && (t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), H(t, s), o.pos === s + 1 ? (t.insert(s, r.bnBlock.node), t.setSelection(F.near(t.doc.resolve(s)))) : (t.insert(o.pos - 1, r.bnBlock.node), t.setSelection(F.near(t.doc.resolve(o.pos))))), !0;
|
|
1023
1372
|
}),
|
|
1024
1373
|
() => t.command(({ state: t }) => {
|
|
1025
1374
|
let n = v(t);
|
|
1026
1375
|
if (!n.isBlockContainer) return !1;
|
|
1027
1376
|
if (n.blockContent.node.childCount === 0 && n.blockContent.node.type.spec.content === "inline*") {
|
|
1028
|
-
let r =
|
|
1377
|
+
let r = Q(t.doc, n.bnBlock.beforePos);
|
|
1029
1378
|
if (!r) return !1;
|
|
1030
|
-
let i =
|
|
1379
|
+
let i = vr(t.doc, r);
|
|
1031
1380
|
if (!i.isBlockContainer || !i || !i.isBlockContainer) return !1;
|
|
1032
1381
|
let a = e();
|
|
1033
1382
|
if (n.childContainer && a.insertContentAt(n.bnBlock.afterPos, n.childContainer?.node.content), i.blockContent.node.type.spec.content === "tableRow+") {
|
|
@@ -1048,9 +1397,9 @@ var An = () => {
|
|
|
1048
1397
|
() => t.command(({ state: t }) => {
|
|
1049
1398
|
let n = v(t);
|
|
1050
1399
|
if (!n.isBlockContainer) return !1;
|
|
1051
|
-
let r = t.selection.from === n.blockContent.beforePos + 1, i = t.selection.empty, a =
|
|
1400
|
+
let r = t.selection.from === n.blockContent.beforePos + 1, i = t.selection.empty, a = Q(t.doc, n.bnBlock.beforePos);
|
|
1052
1401
|
if (a && r && i) {
|
|
1053
|
-
let r =
|
|
1402
|
+
let r = vr(t.doc, a);
|
|
1054
1403
|
if (!r.isBlockContainer) return !1;
|
|
1055
1404
|
if (r.blockContent.node.type.spec.content === "" || r.blockContent.node.type.spec.content === "inline*" && r.blockContent.node.childCount === 0) return e().cut({
|
|
1056
1405
|
from: n.bnBlock.beforePos,
|
|
@@ -1071,7 +1420,7 @@ var An = () => {
|
|
|
1071
1420
|
if (!s.isBlockContainer) return !1;
|
|
1072
1421
|
if (a && o) {
|
|
1073
1422
|
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 ||
|
|
1423
|
+
return e().insertContentAt(s.bnBlock.afterPos, s.childContainer?.node.content || T.empty).deleteRange(i.node.childCount === 1 ? {
|
|
1075
1424
|
from: i.beforePos,
|
|
1076
1425
|
to: i.afterPos
|
|
1077
1426
|
} : {
|
|
@@ -1084,19 +1433,19 @@ var An = () => {
|
|
|
1084
1433
|
() => t.command(({ state: t }) => {
|
|
1085
1434
|
let n = v(t);
|
|
1086
1435
|
if (!n.isBlockContainer) return !1;
|
|
1087
|
-
let { bnBlock: r, blockContent: i } = n, a =
|
|
1436
|
+
let { bnBlock: r, blockContent: i } = n, a = $(t.doc, n.bnBlock.beforePos);
|
|
1088
1437
|
if (!a || !a.isBlockContainer) return !1;
|
|
1089
1438
|
let o = t.selection.from === i.afterPos - 1, s = t.selection.empty, c = r.afterPos;
|
|
1090
|
-
return o && s ? e().command(
|
|
1439
|
+
return o && s ? e().command(xr(c)).scrollIntoView().run() : !1;
|
|
1091
1440
|
}),
|
|
1092
1441
|
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1093
1442
|
let r = v(e);
|
|
1094
1443
|
if (!r.isBlockContainer || e.selection.from !== r.blockContent.afterPos - 1) return !1;
|
|
1095
|
-
let i =
|
|
1444
|
+
let i = $(e.doc, r.bnBlock.beforePos);
|
|
1096
1445
|
if (!i || i.isBlockContainer) return !1;
|
|
1097
1446
|
if (n) {
|
|
1098
1447
|
let e = i.bnBlock.beforePos + 1, n = t.doc.resolve(e + 1);
|
|
1099
|
-
return t.delete(n.pos, n.pos + n.nodeAfter.nodeSize),
|
|
1448
|
+
return t.delete(n.pos, n.pos + n.nodeAfter.nodeSize), H(t, i.bnBlock.beforePos), t.insert(r.bnBlock.afterPos, n.nodeAfter), t.setSelection(F.near(t.doc.resolve(n.pos))), !0;
|
|
1100
1449
|
}
|
|
1101
1450
|
return !1;
|
|
1102
1451
|
}),
|
|
@@ -1108,7 +1457,7 @@ var An = () => {
|
|
|
1108
1457
|
let a = t.doc.resolve(r.bnBlock.afterPos), o = t.doc.resolve(a.after()), s = o.after();
|
|
1109
1458
|
if (n) {
|
|
1110
1459
|
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),
|
|
1460
|
+
t.delete(n.bnBlock.beforePos, n.bnBlock.afterPos), H(t, s - o.node().nodeSize), t.insert(a.pos, n.bnBlock.node), t.setSelection(F.near(t.doc.resolve(e)));
|
|
1112
1461
|
}
|
|
1113
1462
|
return !0;
|
|
1114
1463
|
}),
|
|
@@ -1118,14 +1467,14 @@ var An = () => {
|
|
|
1118
1467
|
let { blockContent: r } = n, i = t.selection.from === r.afterPos - 1, a = t.selection.empty;
|
|
1119
1468
|
if (i && a) {
|
|
1120
1469
|
let i = (e, t) => {
|
|
1121
|
-
let n =
|
|
1470
|
+
let n = $(e, t);
|
|
1122
1471
|
if (n) return n;
|
|
1123
|
-
let r =
|
|
1472
|
+
let r = _r(e, t);
|
|
1124
1473
|
if (r) return i(e, r.bnBlock.beforePos);
|
|
1125
1474
|
}, a = i(t.doc, n.bnBlock.beforePos);
|
|
1126
1475
|
if (!a || !a.isBlockContainer) return !1;
|
|
1127
1476
|
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 ||
|
|
1477
|
+
return e().insertContentAt(a.bnBlock.afterPos, a.childContainer?.node.content || T.empty).deleteRange({
|
|
1129
1478
|
from: a.bnBlock.beforePos,
|
|
1130
1479
|
to: a.bnBlock.afterPos
|
|
1131
1480
|
}).insertContentAt(t.selection.from, s && c ? o.content : null).setTextSelection(t.selection.from).scrollIntoView().run();
|
|
@@ -1136,7 +1485,7 @@ var An = () => {
|
|
|
1136
1485
|
let n = v(t);
|
|
1137
1486
|
if (!n.isBlockContainer) return !1;
|
|
1138
1487
|
if (n.blockContent.node.childCount === 0 && n.blockContent.node.type.spec.content === "inline*") {
|
|
1139
|
-
let r =
|
|
1488
|
+
let r = $(t.doc, n.bnBlock.beforePos);
|
|
1140
1489
|
if (!r || !r.isBlockContainer) return !1;
|
|
1141
1490
|
let i = e();
|
|
1142
1491
|
if (r.blockContent.node.type.spec.content === "tableRow+") {
|
|
@@ -1153,7 +1502,7 @@ var An = () => {
|
|
|
1153
1502
|
() => t.command(({ state: t }) => {
|
|
1154
1503
|
let n = v(t);
|
|
1155
1504
|
if (!n.isBlockContainer) return !1;
|
|
1156
|
-
let r = t.selection.from === n.blockContent.afterPos - 1, i = t.selection.empty, a =
|
|
1505
|
+
let r = t.selection.from === n.blockContent.afterPos - 1, i = t.selection.empty, a = $(t.doc, n.bnBlock.beforePos);
|
|
1157
1506
|
if (!a || !a.isBlockContainer) return !1;
|
|
1158
1507
|
if (a && r && i && (a.blockContent.node.type.spec.content === "" || a.blockContent.node.type.spec.content === "inline*" && a.blockContent.node.childCount === 0)) {
|
|
1159
1508
|
let t = a.bnBlock.node.lastChild.content;
|
|
@@ -1206,8 +1555,8 @@ var An = () => {
|
|
|
1206
1555
|
Delete: t,
|
|
1207
1556
|
Enter: () => n(),
|
|
1208
1557
|
"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(
|
|
1558
|
+
Tab: () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(w)?.store.state || this.options.editor.getExtension(ae)?.store.state !== void 0) ? !1 : zt(this.options.editor),
|
|
1559
|
+
"Shift-Tab": () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(w)?.store.state || this.options.editor.getExtension(ae)?.store.state !== void 0) ? !1 : Vt(this.options.editor),
|
|
1211
1560
|
"Shift-Mod-ArrowUp": () => (this.options.editor.moveBlocksUp(), !0),
|
|
1212
1561
|
"Shift-Mod-ArrowDown": () => (this.options.editor.moveBlocksDown(), !0),
|
|
1213
1562
|
"Mod-z": () => this.options.editor.undo(),
|
|
@@ -1215,7 +1564,7 @@ var An = () => {
|
|
|
1215
1564
|
"Shift-Mod-z": () => this.options.editor.redo()
|
|
1216
1565
|
};
|
|
1217
1566
|
}
|
|
1218
|
-
}),
|
|
1567
|
+
}), Cr = k.create({
|
|
1219
1568
|
name: "insertion",
|
|
1220
1569
|
inclusive: !1,
|
|
1221
1570
|
excludes: "deletion modification insertion",
|
|
@@ -1248,7 +1597,7 @@ var An = () => {
|
|
|
1248
1597
|
}]
|
|
1249
1598
|
} : {};
|
|
1250
1599
|
}
|
|
1251
|
-
}),
|
|
1600
|
+
}), wr = k.create({
|
|
1252
1601
|
name: "deletion",
|
|
1253
1602
|
inclusive: !1,
|
|
1254
1603
|
excludes: "insertion modification deletion",
|
|
@@ -1281,7 +1630,7 @@ var An = () => {
|
|
|
1281
1630
|
}]
|
|
1282
1631
|
} : {};
|
|
1283
1632
|
}
|
|
1284
|
-
}),
|
|
1633
|
+
}), Tr = k.create({
|
|
1285
1634
|
name: "modification",
|
|
1286
1635
|
inclusive: !1,
|
|
1287
1636
|
excludes: "deletion insertion",
|
|
@@ -1339,7 +1688,7 @@ var An = () => {
|
|
|
1339
1688
|
}]
|
|
1340
1689
|
} : {};
|
|
1341
1690
|
}
|
|
1342
|
-
}),
|
|
1691
|
+
}), Er = O.create({
|
|
1343
1692
|
name: "textAlignment",
|
|
1344
1693
|
addGlobalAttributes() {
|
|
1345
1694
|
return [{
|
|
@@ -1351,7 +1700,7 @@ var An = () => {
|
|
|
1351
1700
|
} }
|
|
1352
1701
|
}];
|
|
1353
1702
|
}
|
|
1354
|
-
}),
|
|
1703
|
+
}), Dr = O.create({
|
|
1355
1704
|
name: "blockTextColor",
|
|
1356
1705
|
addGlobalAttributes() {
|
|
1357
1706
|
return [{
|
|
@@ -1360,16 +1709,16 @@ var An = () => {
|
|
|
1360
1709
|
"tableCell",
|
|
1361
1710
|
"tableHeader"
|
|
1362
1711
|
],
|
|
1363
|
-
attributes: { textColor:
|
|
1712
|
+
attributes: { textColor: le() }
|
|
1364
1713
|
}];
|
|
1365
1714
|
}
|
|
1366
|
-
}),
|
|
1715
|
+
}), Or = {
|
|
1367
1716
|
blockColor: "data-block-color",
|
|
1368
1717
|
blockStyle: "data-block-style",
|
|
1369
1718
|
id: "data-id",
|
|
1370
1719
|
depth: "data-depth",
|
|
1371
1720
|
depthChange: "data-depth-change"
|
|
1372
|
-
},
|
|
1721
|
+
}, kr = A.create({
|
|
1373
1722
|
name: "blockContainer",
|
|
1374
1723
|
group: "blockGroupChild bnBlock",
|
|
1375
1724
|
content: "blockContent blockGroup?",
|
|
@@ -1382,7 +1731,7 @@ var An = () => {
|
|
|
1382
1731
|
getAttrs: (e) => {
|
|
1383
1732
|
if (typeof e == "string") return !1;
|
|
1384
1733
|
let t = {};
|
|
1385
|
-
for (let [n, r] of Object.entries(
|
|
1734
|
+
for (let [n, r] of Object.entries(Or)) e.getAttribute(r) && (t[n] = e.getAttribute(r));
|
|
1386
1735
|
return t;
|
|
1387
1736
|
}
|
|
1388
1737
|
}, {
|
|
@@ -1405,7 +1754,7 @@ var An = () => {
|
|
|
1405
1754
|
contentDOM: r
|
|
1406
1755
|
};
|
|
1407
1756
|
}
|
|
1408
|
-
}),
|
|
1757
|
+
}), Ar = A.create({
|
|
1409
1758
|
name: "blockGroup",
|
|
1410
1759
|
group: "childContainer",
|
|
1411
1760
|
content: "blockGroupChild+",
|
|
@@ -1428,29 +1777,31 @@ var An = () => {
|
|
|
1428
1777
|
contentDOM: n
|
|
1429
1778
|
};
|
|
1430
1779
|
}
|
|
1431
|
-
}),
|
|
1780
|
+
}), jr = A.create({
|
|
1432
1781
|
name: "doc",
|
|
1433
1782
|
topNode: !0,
|
|
1434
1783
|
content: "blockGroup",
|
|
1435
1784
|
marks: "insertion modification deletion"
|
|
1436
|
-
}),
|
|
1785
|
+
}), Mr = Me(({ options: e }) => ({
|
|
1437
1786
|
key: "collaboration",
|
|
1438
1787
|
blockNoteExtensions: [
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1788
|
+
de(e),
|
|
1789
|
+
pe(e),
|
|
1790
|
+
ge(e),
|
|
1791
|
+
ke(),
|
|
1792
|
+
he(e)
|
|
1444
1793
|
]
|
|
1445
|
-
}))
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1794
|
+
}));
|
|
1795
|
+
//#endregion
|
|
1796
|
+
//#region src/editor/managers/ExtensionManager/extensions.ts
|
|
1797
|
+
function Nr(e, t) {
|
|
1798
|
+
return [
|
|
1799
|
+
j.ClipboardTextSerializer,
|
|
1800
|
+
j.Commands,
|
|
1801
|
+
j.Editable,
|
|
1802
|
+
j.FocusEvents,
|
|
1803
|
+
j.Tabindex,
|
|
1804
|
+
pt,
|
|
1454
1805
|
o.configure({
|
|
1455
1806
|
types: [
|
|
1456
1807
|
"blockContainer",
|
|
@@ -1460,66 +1811,63 @@ function Xn(e, t) {
|
|
|
1460
1811
|
setIdAttribute: t.setIdAttribute,
|
|
1461
1812
|
isWithinEditor: e.isWithinEditor
|
|
1462
1813
|
}),
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
ut.extend({ inclusive: !1 }).extend({ addAttributes() {
|
|
1469
|
-
let e = this.parent?.() || {};
|
|
1470
|
-
return delete e.title, e;
|
|
1471
|
-
} }).configure({
|
|
1472
|
-
defaultProtocol: be,
|
|
1473
|
-
protocols: Yn ? [] : ye
|
|
1474
|
-
}),
|
|
1814
|
+
gr,
|
|
1815
|
+
mt,
|
|
1816
|
+
Cr,
|
|
1817
|
+
wr,
|
|
1818
|
+
Tr,
|
|
1475
1819
|
...Object.values(e.schema.styleSpecs).map((t) => t.implementation.mark.configure({ editor: e })),
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1820
|
+
Dr,
|
|
1821
|
+
hr,
|
|
1822
|
+
Er,
|
|
1823
|
+
O.create({
|
|
1480
1824
|
name: "OverrideEscape",
|
|
1481
1825
|
addKeyboardShortcuts: () => ({ Escape: () => e.getExtension(te)?.shown() ? !1 : (e.blur(), !0) })
|
|
1482
1826
|
}),
|
|
1483
|
-
|
|
1484
|
-
|
|
1827
|
+
jr,
|
|
1828
|
+
kr.configure({
|
|
1485
1829
|
editor: e,
|
|
1486
1830
|
domAttributes: t.domAttributes
|
|
1487
1831
|
}),
|
|
1488
|
-
|
|
1832
|
+
Sr.configure({
|
|
1489
1833
|
editor: e,
|
|
1490
1834
|
tabBehavior: t.tabBehavior
|
|
1491
1835
|
}),
|
|
1492
|
-
|
|
1836
|
+
Ar.configure({ domAttributes: t.domAttributes }),
|
|
1493
1837
|
...Object.values(e.schema.inlineContentSpecs).filter((e) => e.config !== "link" && e.config !== "text").map((t) => t.implementation.node.configure({ editor: e })),
|
|
1494
1838
|
...Object.values(e.schema.blockSpecs).flatMap((n) => [..."node" in n.implementation ? [n.implementation.node.configure({
|
|
1495
1839
|
editor: e,
|
|
1496
1840
|
domAttributes: t.domAttributes
|
|
1497
1841
|
})] : []]),
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1842
|
+
mr(e),
|
|
1843
|
+
lr(e, t.pasteHandler || ((e) => e.defaultPasteHandler())),
|
|
1844
|
+
Kn(e)
|
|
1501
1845
|
];
|
|
1502
|
-
return Yn = !0, n;
|
|
1503
1846
|
}
|
|
1504
|
-
function
|
|
1847
|
+
function Pr(e, t) {
|
|
1505
1848
|
let n = [
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1849
|
+
fe(),
|
|
1850
|
+
Ae(t),
|
|
1851
|
+
ae(t),
|
|
1852
|
+
w(t),
|
|
1853
|
+
Bn({
|
|
1854
|
+
HTMLAttributes: t.links?.HTMLAttributes ?? {},
|
|
1855
|
+
onClick: t.links?.onClick,
|
|
1856
|
+
...t.links?.isValidLink ? { isValidLink: t.links.isValidLink } : {}
|
|
1857
|
+
}),
|
|
1858
|
+
_e(t),
|
|
1859
|
+
Se(),
|
|
1514
1860
|
Te(t),
|
|
1861
|
+
Ne(t),
|
|
1862
|
+
we(t),
|
|
1515
1863
|
te(t),
|
|
1516
|
-
...t.trailingBlock === !1 ? [] : [
|
|
1864
|
+
...t.trailingBlock === !1 ? [] : [Ee()]
|
|
1517
1865
|
];
|
|
1518
|
-
return t.collaboration ? n.push(
|
|
1866
|
+
return t.collaboration ? n.push(Mr(t.collaboration)) : n.push(Oe()), "table" in e.schema.blockSpecs && n.push(Ce(t)), t.animations !== !1 && n.push(ye()), n;
|
|
1519
1867
|
}
|
|
1520
1868
|
//#endregion
|
|
1521
1869
|
//#region src/editor/managers/ExtensionManager/index.ts
|
|
1522
|
-
var
|
|
1870
|
+
var Fr = class {
|
|
1523
1871
|
disabledExtensions = /* @__PURE__ */ new Set();
|
|
1524
1872
|
extensions = [];
|
|
1525
1873
|
abortMap = /* @__PURE__ */ new Map();
|
|
@@ -1540,7 +1888,7 @@ var Qn = class {
|
|
|
1540
1888
|
}), e.onUnmount(() => {
|
|
1541
1889
|
for (let [e, t] of this.abortMap.entries()) this.abortMap.delete(e), t.abort();
|
|
1542
1890
|
}), this.disabledExtensions = new Set(t.disableExtensions || []);
|
|
1543
|
-
for (let e of
|
|
1891
|
+
for (let e of Pr(this.editor, this.options)) this.addExtension(e);
|
|
1544
1892
|
for (let e of this.options.extensions ?? []) this.addExtension(e);
|
|
1545
1893
|
for (let e of Object.values(this.editor.schema.blockSpecs)) for (let t of e.extensions ?? []) this.addExtension(t);
|
|
1546
1894
|
}
|
|
@@ -1560,7 +1908,7 @@ var Qn = class {
|
|
|
1560
1908
|
let t;
|
|
1561
1909
|
if (t = typeof e == "function" ? e({ editor: this.editor }) : e, !(!t || this.disabledExtensions.has(t.key))) {
|
|
1562
1910
|
if (typeof e == "function") {
|
|
1563
|
-
let e = t[
|
|
1911
|
+
let e = t[je];
|
|
1564
1912
|
typeof e == "function" && this.extensionFactories.set(e, t);
|
|
1565
1913
|
}
|
|
1566
1914
|
if (this.extensions.push(t), t.blockNoteExtensions) for (let e of t.blockNoteExtensions) this.addExtension(e);
|
|
@@ -1599,23 +1947,23 @@ var Qn = class {
|
|
|
1599
1947
|
this.editor.prosemirrorView.updateState(n);
|
|
1600
1948
|
}
|
|
1601
1949
|
getTiptapExtensions() {
|
|
1602
|
-
let e =
|
|
1950
|
+
let e = Nr(this.editor, this.options).filter((e) => !this.disabledExtensions.has(e.name)), t = a(this.extensions), n = /* @__PURE__ */ new Map();
|
|
1603
1951
|
for (let r of this.extensions) {
|
|
1604
1952
|
r.tiptapExtensions && e.push(...r.tiptapExtensions);
|
|
1605
1953
|
let i = t(r.key), { plugins: a, inputRules: o } = this.getProsemirrorPluginsFromExtension(r);
|
|
1606
|
-
a.length && e.push(
|
|
1954
|
+
a.length && e.push(O.create({
|
|
1607
1955
|
name: r.key,
|
|
1608
1956
|
priority: i,
|
|
1609
1957
|
addProseMirrorPlugins: () => a
|
|
1610
1958
|
})), o.length && (n.has(i) || n.set(i, []), n.get(i).push(...o));
|
|
1611
1959
|
}
|
|
1612
|
-
e.push(
|
|
1960
|
+
e.push(O.create({
|
|
1613
1961
|
name: "blocknote-input-rules",
|
|
1614
1962
|
addProseMirrorPlugins() {
|
|
1615
1963
|
let e = [];
|
|
1616
1964
|
return Array.from(n.keys()).sort().reverse().forEach((t) => {
|
|
1617
1965
|
e.push(...n.get(t));
|
|
1618
|
-
}), [
|
|
1966
|
+
}), [dt({ rules: e })];
|
|
1619
1967
|
}
|
|
1620
1968
|
}));
|
|
1621
1969
|
for (let t of this.options._tiptapOptions?.extensions ?? []) e.push(t);
|
|
@@ -1626,7 +1974,7 @@ var Qn = class {
|
|
|
1626
1974
|
return !e.prosemirrorPlugins?.length && !Object.keys(e.keyboardShortcuts || {}).length && !e.inputRules?.length ? {
|
|
1627
1975
|
plugins: t,
|
|
1628
1976
|
inputRules: n
|
|
1629
|
-
} : (this.extensionPlugins.set(e, t), e.inputRules?.length && n.push(...e.inputRules.map((e) => new
|
|
1977
|
+
} : (this.extensionPlugins.set(e, t), e.inputRules?.length && n.push(...e.inputRules.map((e) => new ut(e.find, (t, n, r, i) => {
|
|
1630
1978
|
let a = e.replace({
|
|
1631
1979
|
match: n,
|
|
1632
1980
|
range: {
|
|
@@ -1642,7 +1990,7 @@ var Qn = class {
|
|
|
1642
1990
|
return d(o, n.bnBlock.beforePos, a), o;
|
|
1643
1991
|
}
|
|
1644
1992
|
return null;
|
|
1645
|
-
}))), Object.keys(e.keyboardShortcuts || {}).length && t.push(
|
|
1993
|
+
}))), Object.keys(e.keyboardShortcuts || {}).length && t.push(ft(Object.fromEntries(Object.entries(e.keyboardShortcuts).map(([e, t]) => [e, () => t({ editor: this.editor })])))), {
|
|
1646
1994
|
plugins: t,
|
|
1647
1995
|
inputRules: n
|
|
1648
1996
|
});
|
|
@@ -1661,7 +2009,7 @@ var Qn = class {
|
|
|
1661
2009
|
};
|
|
1662
2010
|
//#endregion
|
|
1663
2011
|
//#region src/util/expandToWords.ts
|
|
1664
|
-
function
|
|
2012
|
+
function Ir(e, t) {
|
|
1665
2013
|
let { $from: n, $to: r } = t;
|
|
1666
2014
|
if (n.pos > n.start() && n.pos < e.content.size) {
|
|
1667
2015
|
let t = e.textBetween(n.pos, n.pos + 1);
|
|
@@ -1686,10 +2034,10 @@ function $n(e, t) {
|
|
|
1686
2034
|
}
|
|
1687
2035
|
//#endregion
|
|
1688
2036
|
//#region src/api/blockManipulation/selections/selection.ts
|
|
1689
|
-
function
|
|
2037
|
+
function Lr(e) {
|
|
1690
2038
|
let t = g(e);
|
|
1691
2039
|
if (e.selection.empty || "node" in e.selection) return;
|
|
1692
|
-
let n = e.doc.resolve(
|
|
2040
|
+
let n = e.doc.resolve(C(e.doc, e.selection.from).posBeforeNode), r = e.doc.resolve(C(e.doc, e.selection.to).posBeforeNode), i = (r, i) => {
|
|
1693
2041
|
let a = n.posAtIndex(r, i), o = e.doc.resolve(a).nodeAfter;
|
|
1694
2042
|
if (!o) throw Error(`Error getting selection - node not found at position ${a}`);
|
|
1695
2043
|
return y(o, t);
|
|
@@ -1705,7 +2053,7 @@ function er(e) {
|
|
|
1705
2053
|
if (a.length === 0) throw Error(`Error getting selection - selection doesn't span any blocks (${e.selection})`);
|
|
1706
2054
|
return { blocks: a };
|
|
1707
2055
|
}
|
|
1708
|
-
function
|
|
2056
|
+
function Rr(e, t, n) {
|
|
1709
2057
|
let r = typeof t == "string" ? t : t.id, a = typeof n == "string" ? n : n.id, o = ee(g(e));
|
|
1710
2058
|
if (r === a) throw Error(`Attempting to set selection with the same anchor and head blocks (id ${r})`);
|
|
1711
2059
|
let s = i(r, e.doc);
|
|
@@ -1717,17 +2065,17 @@ function tr(e, t, n) {
|
|
|
1717
2065
|
if (!u.isBlockContainer || f.content === "none") throw Error(`Attempting to set selection anchor in block without content (id ${a})`);
|
|
1718
2066
|
let p, m;
|
|
1719
2067
|
if (d.content === "table") {
|
|
1720
|
-
let e =
|
|
2068
|
+
let e = rt.get(l.blockContent.node);
|
|
1721
2069
|
p = l.blockContent.beforePos + e.positionAt(0, 0, l.blockContent.node) + 1 + 2;
|
|
1722
2070
|
} else p = l.blockContent.beforePos + 1;
|
|
1723
2071
|
if (f.content === "table") {
|
|
1724
|
-
let t =
|
|
2072
|
+
let t = rt.get(u.blockContent.node), n = u.blockContent.beforePos + t.positionAt(t.height - 1, t.width - 1, u.blockContent.node) + 1;
|
|
1725
2073
|
m = n + e.doc.resolve(n).nodeAfter.nodeSize - 2;
|
|
1726
2074
|
} else m = u.blockContent.afterPos - 1;
|
|
1727
2075
|
e.setSelection(F.create(e.doc, p, m));
|
|
1728
2076
|
}
|
|
1729
|
-
function
|
|
1730
|
-
let n = g(e), r = t ?
|
|
2077
|
+
function zr(e, t = !1) {
|
|
2078
|
+
let n = g(e), r = t ? Ir(e.doc, e.selection) : e.selection, i = r.$from, a = r.$to;
|
|
1731
2079
|
for (; a.parentOffset >= a.parent.nodeSize - 2 && a.depth > 0;) a = e.doc.resolve(a.pos + 1);
|
|
1732
2080
|
for (; a.parentOffset === 0 && a.depth > 0;) a = e.doc.resolve(a.pos - 1);
|
|
1733
2081
|
for (; i.parentOffset === 0 && i.depth > 0;) i = e.doc.resolve(i.pos - 1);
|
|
@@ -1743,7 +2091,7 @@ function nr(e, t = !1) {
|
|
|
1743
2091
|
}
|
|
1744
2092
|
//#endregion
|
|
1745
2093
|
//#region src/api/blockManipulation/selections/textCursorPosition.ts
|
|
1746
|
-
function
|
|
2094
|
+
function Br(e) {
|
|
1747
2095
|
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
2096
|
return r.depth > 1 && (o = r.node(), o.type.isInGroup("bnBlock") || (o = r.node(r.depth - 1))), {
|
|
1749
2097
|
block: y(t.node, n),
|
|
@@ -1752,7 +2100,7 @@ function rr(e) {
|
|
|
1752
2100
|
parentBlock: o === void 0 ? void 0 : y(o, n)
|
|
1753
2101
|
};
|
|
1754
2102
|
}
|
|
1755
|
-
function
|
|
2103
|
+
function Vr(e, t, n = "start") {
|
|
1756
2104
|
let r = typeof t == "string" ? t : t.id, a = ee(g(e.doc)), o = i(r, e.doc);
|
|
1757
2105
|
if (!o) throw Error(`Block with ID ${r} not found`);
|
|
1758
2106
|
let s = S(o), c = a.blockSchema[s.blockNoteType].content;
|
|
@@ -1765,39 +2113,39 @@ function ir(e, t, n = "start") {
|
|
|
1765
2113
|
if (c === "inline") n === "start" ? e.setSelection(F.create(e.doc, t.beforePos + 1)) : e.setSelection(F.create(e.doc, t.afterPos - 1));
|
|
1766
2114
|
else if (c === "table") n === "start" ? e.setSelection(F.create(e.doc, t.beforePos + 4)) : e.setSelection(F.create(e.doc, t.afterPos - 4));
|
|
1767
2115
|
else throw new u(c);
|
|
1768
|
-
} else
|
|
2116
|
+
} else Vr(e, (n === "start" ? s.childContainer.node.firstChild : s.childContainer.node.lastChild).attrs.id, n);
|
|
1769
2117
|
}
|
|
1770
2118
|
//#endregion
|
|
1771
2119
|
//#region src/editor/managers/SelectionManager.ts
|
|
1772
|
-
var
|
|
2120
|
+
var Hr = class {
|
|
1773
2121
|
constructor(e) {
|
|
1774
2122
|
this.editor = e;
|
|
1775
2123
|
}
|
|
1776
2124
|
getSelection() {
|
|
1777
|
-
return this.editor.transact((e) =>
|
|
2125
|
+
return this.editor.transact((e) => Lr(e));
|
|
1778
2126
|
}
|
|
1779
2127
|
getSelectionCutBlocks(e = !1) {
|
|
1780
|
-
return this.editor.transact((t) =>
|
|
2128
|
+
return this.editor.transact((t) => zr(t, e));
|
|
1781
2129
|
}
|
|
1782
2130
|
setSelection(e, t) {
|
|
1783
|
-
return this.editor.transact((n) =>
|
|
2131
|
+
return this.editor.transact((n) => Rr(n, e, t));
|
|
1784
2132
|
}
|
|
1785
2133
|
getTextCursorPosition() {
|
|
1786
|
-
return this.editor.transact((e) =>
|
|
2134
|
+
return this.editor.transact((e) => Br(e));
|
|
1787
2135
|
}
|
|
1788
2136
|
setTextCursorPosition(e, t = "start") {
|
|
1789
|
-
return this.editor.transact((n) =>
|
|
2137
|
+
return this.editor.transact((n) => Vr(n, e, t));
|
|
1790
2138
|
}
|
|
1791
2139
|
getSelectionBoundingBox() {
|
|
1792
2140
|
if (!this.editor.prosemirrorView) return;
|
|
1793
2141
|
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 (
|
|
2142
|
+
if ($e(e)) {
|
|
1795
2143
|
let e = this.editor.prosemirrorView.nodeDOM(n);
|
|
1796
2144
|
if (e) return e.getBoundingClientRect();
|
|
1797
2145
|
}
|
|
1798
|
-
return
|
|
2146
|
+
return tt(this.editor.prosemirrorView, n, r).toJSON();
|
|
1799
2147
|
}
|
|
1800
|
-
},
|
|
2148
|
+
}, Ur = class {
|
|
1801
2149
|
constructor(e) {
|
|
1802
2150
|
this.editor = e;
|
|
1803
2151
|
}
|
|
@@ -1875,7 +2223,7 @@ var ar = class {
|
|
|
1875
2223
|
};
|
|
1876
2224
|
//#endregion
|
|
1877
2225
|
//#region src/api/blockManipulation/insertContentAt.ts
|
|
1878
|
-
function
|
|
2226
|
+
function Wr(e, t, n, r = { updateSelection: !0 }) {
|
|
1879
2227
|
let { from: i, to: a } = typeof t == "number" ? {
|
|
1880
2228
|
from: t,
|
|
1881
2229
|
to: t
|
|
@@ -1889,18 +2237,18 @@ function sr(e, t, n, r = { updateSelection: !0 }) {
|
|
|
1889
2237
|
let { parent: t } = e.doc.resolve(i);
|
|
1890
2238
|
t.isTextblock && !t.type.spec.code && !t.childCount && (--i, a += 1);
|
|
1891
2239
|
}
|
|
1892
|
-
return o ? e.insertText(c, i, a) : e.replaceWith(i, a, n), r.updateSelection &&
|
|
2240
|
+
return o ? e.insertText(c, i, a) : e.replaceWith(i, a, n), r.updateSelection && nt(e, e.steps.length - 1, -1), !0;
|
|
1893
2241
|
}
|
|
1894
2242
|
//#endregion
|
|
1895
2243
|
//#region src/editor/managers/StyleManager.ts
|
|
1896
|
-
var
|
|
2244
|
+
var Gr = class {
|
|
1897
2245
|
constructor(e) {
|
|
1898
2246
|
this.editor = e;
|
|
1899
2247
|
}
|
|
1900
2248
|
insertInlineContent(e, { updateSelection: t = !1 } = {}) {
|
|
1901
2249
|
let n = b(e, this.editor.pmSchema);
|
|
1902
2250
|
this.editor.transact((e) => {
|
|
1903
|
-
|
|
2251
|
+
Wr(e, {
|
|
1904
2252
|
from: e.selection.from,
|
|
1905
2253
|
to: e.selection.to
|
|
1906
2254
|
}, n, { updateSelection: t });
|
|
@@ -1944,36 +2292,65 @@ var cr = class {
|
|
|
1944
2292
|
getSelectedText() {
|
|
1945
2293
|
return this.editor.transact((e) => e.doc.textBetween(e.selection.from, e.selection.to));
|
|
1946
2294
|
}
|
|
2295
|
+
getLinkMarkAtPos(e) {
|
|
2296
|
+
return this.editor.transact((t) => {
|
|
2297
|
+
let n = t.doc.resolve(e), r = n.marks().find((e) => e.type.name === "link");
|
|
2298
|
+
if (!r) return;
|
|
2299
|
+
let i = Xe(n, r.type);
|
|
2300
|
+
if (i) return {
|
|
2301
|
+
href: r.attrs.href,
|
|
2302
|
+
from: i.from,
|
|
2303
|
+
to: i.to,
|
|
2304
|
+
text: t.doc.textBetween(i.from, i.to)
|
|
2305
|
+
};
|
|
2306
|
+
});
|
|
2307
|
+
}
|
|
1947
2308
|
getSelectedLinkUrl() {
|
|
1948
|
-
return this.editor.
|
|
2309
|
+
return this.editor.transact((e) => this.getLinkMarkAtPos(e.selection.from)?.href);
|
|
1949
2310
|
}
|
|
1950
2311
|
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);
|
|
2312
|
+
e !== "" && this.editor.transact((n) => {
|
|
2313
|
+
let { from: r, to: i } = n.selection, a = this.editor.pmSchema.mark("link", { href: e });
|
|
2314
|
+
t ? n.insertText(t, r, i).addMark(r, r + t.length, a) : n.addMark(r, i, a);
|
|
1956
2315
|
});
|
|
1957
2316
|
}
|
|
2317
|
+
editLink(e, t, n = this.editor.transact((e) => e.selection.anchor)) {
|
|
2318
|
+
this.editor.transact((r) => {
|
|
2319
|
+
let { from: i, to: a } = this.getLinkMarkAtPos(n + 1) || {
|
|
2320
|
+
from: r.selection.from,
|
|
2321
|
+
to: r.selection.to
|
|
2322
|
+
}, o = this.editor.pmSchema.mark("link", { href: e });
|
|
2323
|
+
t !== r.doc.textBetween(i, a) && r.insertText(t, i, a), r.addMark(i, i + t.length, o);
|
|
2324
|
+
}), this.editor.prosemirrorView.focus();
|
|
2325
|
+
}
|
|
2326
|
+
deleteLink(e = this.editor.transact((e) => e.selection.anchor)) {
|
|
2327
|
+
this.editor.transact((t) => {
|
|
2328
|
+
let { from: n, to: r } = this.getLinkMarkAtPos(e + 1) || {
|
|
2329
|
+
from: t.selection.from,
|
|
2330
|
+
to: t.selection.to
|
|
2331
|
+
};
|
|
2332
|
+
t.removeMark(n, r, this.editor.pmSchema.marks.link).setMeta("preventAutolink", !0);
|
|
2333
|
+
}), this.editor.prosemirrorView.focus();
|
|
2334
|
+
}
|
|
1958
2335
|
};
|
|
1959
2336
|
//#endregion
|
|
1960
2337
|
//#region src/editor/transformPasted.ts
|
|
1961
|
-
function
|
|
1962
|
-
return
|
|
2338
|
+
function Kr(e) {
|
|
2339
|
+
return qe(e.state.selection.$from, (e) => e.type.name === "tableCell" || e.type.name === "tableHeader") !== void 0;
|
|
1963
2340
|
}
|
|
1964
|
-
function
|
|
2341
|
+
function qr(e, t) {
|
|
1965
2342
|
let n = t.nodes.hardBreak, r = I.empty;
|
|
1966
2343
|
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(
|
|
2344
|
+
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
2345
|
}), r.lastChild?.type === n && (r = r.cut(0, r.size - 1)), r;
|
|
1969
2346
|
}
|
|
1970
|
-
function
|
|
2347
|
+
function Jr(e, t) {
|
|
1971
2348
|
let n = [];
|
|
1972
2349
|
return e.forEach((e, r, i) => {
|
|
1973
2350
|
i !== t && n.push(e);
|
|
1974
2351
|
}), I.from(n);
|
|
1975
2352
|
}
|
|
1976
|
-
function
|
|
2353
|
+
function Yr(e, t) {
|
|
1977
2354
|
let n = [];
|
|
1978
2355
|
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
2356
|
let t = n[n.length - 1], i = t.copy(t.content.addToEnd(e.child(r)));
|
|
@@ -1985,27 +2362,27 @@ function fr(e, t) {
|
|
|
1985
2362
|
else n.push(e.child(r));
|
|
1986
2363
|
return e = I.from(n), e;
|
|
1987
2364
|
}
|
|
1988
|
-
function
|
|
2365
|
+
function Xr(e, t) {
|
|
1989
2366
|
let n = I.from(e.content);
|
|
1990
|
-
if (n =
|
|
2367
|
+
if (n = Yr(n, t.state.schema), Kr(t)) {
|
|
1991
2368
|
let e = !1;
|
|
1992
2369
|
if (n.descendants((t) => {
|
|
1993
2370
|
t.type.isInGroup("tableContent") && (e = !0);
|
|
1994
|
-
}), !e && !t.state.schema.nodes.tableParagraph.validContent(n)) return new L(
|
|
2371
|
+
}), !e && !t.state.schema.nodes.tableParagraph.validContent(n)) return new L(qr(n, t.state.schema), 0, 0);
|
|
1995
2372
|
}
|
|
1996
|
-
if (!
|
|
2373
|
+
if (!Zr(n, t)) return new L(n, e.openStart, e.openEnd);
|
|
1997
2374
|
for (let e = 0; e < n.childCount; e++) if (n.child(e).type.spec.group === "blockContent") {
|
|
1998
2375
|
let r = [n.child(e)];
|
|
1999
2376
|
if (e + 1 < n.childCount && n.child(e + 1).type.name === "blockGroup") {
|
|
2000
2377
|
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 =
|
|
2378
|
+
(t.type.name === "bulletListItem" || t.type.name === "numberedListItem" || t.type.name === "checkListItem") && (r.push(n.child(e + 1)), n = Jr(n, e + 1));
|
|
2002
2379
|
}
|
|
2003
2380
|
let i = t.state.schema.nodes.blockContainer.createChecked(void 0, r);
|
|
2004
2381
|
n = n.replaceChild(e, i);
|
|
2005
2382
|
}
|
|
2006
2383
|
return new L(n, e.openStart, e.openEnd);
|
|
2007
2384
|
}
|
|
2008
|
-
function
|
|
2385
|
+
function Zr(e, t) {
|
|
2009
2386
|
let n = e.childCount === 1, r = e.firstChild?.type.spec.content === "inline*", i = e.firstChild?.type.spec.content === "tableRow+";
|
|
2010
2387
|
if (n) {
|
|
2011
2388
|
if (r) return !1;
|
|
@@ -2018,11 +2395,11 @@ function mr(e, t) {
|
|
|
2018
2395
|
}
|
|
2019
2396
|
//#endregion
|
|
2020
2397
|
//#region src/editor/BlockNoteEditor.ts
|
|
2021
|
-
var
|
|
2398
|
+
var Qr = {
|
|
2022
2399
|
enableInputRules: !0,
|
|
2023
2400
|
enablePasteRules: !0,
|
|
2024
2401
|
enableCoreExtensions: !1
|
|
2025
|
-
},
|
|
2402
|
+
}, $r = class e extends Fe {
|
|
2026
2403
|
pmSchema;
|
|
2027
2404
|
_tiptapEditor;
|
|
2028
2405
|
elementRenderer = null;
|
|
@@ -2041,7 +2418,7 @@ var hr = {
|
|
|
2041
2418
|
return new e(t ?? {});
|
|
2042
2419
|
}
|
|
2043
2420
|
constructor(e) {
|
|
2044
|
-
super(), this.options = e, this.dictionary = e.dictionary ||
|
|
2421
|
+
super(), this.options = e, this.dictionary = e.dictionary || Pe, this.settings = { tables: {
|
|
2045
2422
|
splitCells: e?.tables?.splitCells ?? !1,
|
|
2046
2423
|
cellBackgroundColor: e?.tables?.cellBackgroundColor ?? !1,
|
|
2047
2424
|
cellTextColor: e?.tables?.cellTextColor ?? !1,
|
|
@@ -2049,7 +2426,7 @@ var hr = {
|
|
|
2049
2426
|
} };
|
|
2050
2427
|
let t = {
|
|
2051
2428
|
defaultStyles: !0,
|
|
2052
|
-
schema: e.schema ||
|
|
2429
|
+
schema: e.schema || se.create(),
|
|
2053
2430
|
...e,
|
|
2054
2431
|
placeholders: {
|
|
2055
2432
|
...this.dictionary.placeholders,
|
|
@@ -2067,11 +2444,11 @@ var hr = {
|
|
|
2067
2444
|
}
|
|
2068
2445
|
};
|
|
2069
2446
|
}
|
|
2070
|
-
this.resolveFileUrl = t.resolveFileUrl, this._eventManager = new
|
|
2447
|
+
this.resolveFileUrl = t.resolveFileUrl, this._eventManager = new Yt(this), this._extensionManager = new Fr(this, t);
|
|
2071
2448
|
let n = this._extensionManager.getTiptapExtensions(), r = this._extensionManager.hasExtension("ySync") || this._extensionManager.hasExtension("liveblocksExtension");
|
|
2072
2449
|
r && t.initialContent && console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider");
|
|
2073
2450
|
let i = {
|
|
2074
|
-
...
|
|
2451
|
+
...Qr,
|
|
2075
2452
|
...t._tiptapOptions,
|
|
2076
2453
|
element: null,
|
|
2077
2454
|
autofocus: t.autofocus ?? !1,
|
|
@@ -2084,7 +2461,7 @@ var hr = {
|
|
|
2084
2461
|
...t.domAttributes?.editor,
|
|
2085
2462
|
class: s("bn-editor", t.defaultStyles ? "bn-default-styles" : "", t.domAttributes?.editor?.class || "")
|
|
2086
2463
|
},
|
|
2087
|
-
transformPasted:
|
|
2464
|
+
transformPasted: Xr
|
|
2088
2465
|
}
|
|
2089
2466
|
};
|
|
2090
2467
|
try {
|
|
@@ -2096,14 +2473,14 @@ var hr = {
|
|
|
2096
2473
|
id: o.options.generateID()
|
|
2097
2474
|
}]);
|
|
2098
2475
|
if (!Array.isArray(e) || e.length === 0) throw Error("initialContent must be a non-empty array of blocks, received: " + e);
|
|
2099
|
-
let n =
|
|
2476
|
+
let n = Qe(i.extensions), a = Ge({
|
|
2100
2477
|
type: "doc",
|
|
2101
2478
|
content: [{
|
|
2102
2479
|
type: "blockGroup",
|
|
2103
2480
|
content: e.map((e) => c(e, n, this.schema.styleSchema).toJSON())
|
|
2104
2481
|
}]
|
|
2105
2482
|
}, n, i.parseOptions);
|
|
2106
|
-
this._tiptapEditor = new
|
|
2483
|
+
this._tiptapEditor = new Ue({
|
|
2107
2484
|
...i,
|
|
2108
2485
|
content: a.toJSON()
|
|
2109
2486
|
}), this.pmSchema = this._tiptapEditor.schema;
|
|
@@ -2114,8 +2491,12 @@ var hr = {
|
|
|
2114
2491
|
this.pmSchema.nodes.doc.createAndFill = (...e) => {
|
|
2115
2492
|
if (a) return a;
|
|
2116
2493
|
let t = l.apply(this.pmSchema.nodes.doc, e), n = JSON.parse(JSON.stringify(t.toJSON()));
|
|
2117
|
-
return n.content[0].content[0].attrs.id = "initialBlockId", a =
|
|
2118
|
-
}, this.pmSchema.cached.blockNoteEditor = this, this.
|
|
2494
|
+
return n.content[0].content[0].attrs.id = "initialBlockId", a = Re.fromJSON(this.pmSchema, n), a;
|
|
2495
|
+
}, this.pmSchema.cached.blockNoteEditor = this, this._tiptapEditor.on("mount", () => {
|
|
2496
|
+
this.headless = !1;
|
|
2497
|
+
}), this._tiptapEditor.on("unmount", () => {
|
|
2498
|
+
this.headless = !0;
|
|
2499
|
+
}), this._blockManager = new Jt(this), this._exportManager = new dn(this), this._selectionManager = new Hr(this), this._stateManager = new Ur(this), this._styleManager = new Gr(this), this.emit("create");
|
|
2119
2500
|
}
|
|
2120
2501
|
_blockManager;
|
|
2121
2502
|
_eventManager;
|
|
@@ -2164,9 +2545,7 @@ var hr = {
|
|
|
2164
2545
|
isFocused() {
|
|
2165
2546
|
return this.headless ? !1 : this.prosemirrorView?.hasFocus() || !1;
|
|
2166
2547
|
}
|
|
2167
|
-
|
|
2168
|
-
return !this._tiptapEditor.isInitialized;
|
|
2169
|
-
}
|
|
2548
|
+
headless = !0;
|
|
2170
2549
|
focus() {
|
|
2171
2550
|
this.headless || this.prosemirrorView.focus();
|
|
2172
2551
|
}
|
|
@@ -2213,7 +2592,7 @@ var hr = {
|
|
|
2213
2592
|
this._tiptapEditor.on("selectionUpdate", e);
|
|
2214
2593
|
}
|
|
2215
2594
|
onBeforeChange(e) {
|
|
2216
|
-
return this._extensionManager.getExtension(
|
|
2595
|
+
return this._extensionManager.getExtension(fe).subscribe(e);
|
|
2217
2596
|
}
|
|
2218
2597
|
getTextCursorPosition() {
|
|
2219
2598
|
return this._selectionManager.getTextCursorPosition();
|
|
@@ -2278,6 +2657,15 @@ var hr = {
|
|
|
2278
2657
|
createLink(e, t) {
|
|
2279
2658
|
this._styleManager.createLink(e, t);
|
|
2280
2659
|
}
|
|
2660
|
+
getLinkMarkAtPos(e) {
|
|
2661
|
+
return this._styleManager.getLinkMarkAtPos(e);
|
|
2662
|
+
}
|
|
2663
|
+
editLink(e, t, n) {
|
|
2664
|
+
this._styleManager.editLink(e, t, n);
|
|
2665
|
+
}
|
|
2666
|
+
deleteLink(e) {
|
|
2667
|
+
this._styleManager.deleteLink(e);
|
|
2668
|
+
}
|
|
2281
2669
|
canNestBlock() {
|
|
2282
2670
|
return this._blockManager.canNestBlock();
|
|
2283
2671
|
}
|
|
@@ -2318,10 +2706,10 @@ var hr = {
|
|
|
2318
2706
|
return this._eventManager.onSelectionChange(e, t);
|
|
2319
2707
|
}
|
|
2320
2708
|
onMount(e) {
|
|
2321
|
-
this._eventManager.onMount(e);
|
|
2709
|
+
return this._eventManager.onMount(e);
|
|
2322
2710
|
}
|
|
2323
2711
|
onUnmount(e) {
|
|
2324
|
-
this._eventManager.onUnmount(e);
|
|
2712
|
+
return this._eventManager.onUnmount(e);
|
|
2325
2713
|
}
|
|
2326
2714
|
getSelectionBoundingBox() {
|
|
2327
2715
|
return this._selectionManager.getSelectionBoundingBox();
|
|
@@ -2339,7 +2727,7 @@ var hr = {
|
|
|
2339
2727
|
pasteMarkdown(e) {
|
|
2340
2728
|
return this._exportManager.pasteMarkdown(e);
|
|
2341
2729
|
}
|
|
2342
|
-
},
|
|
2730
|
+
}, ei = class {
|
|
2343
2731
|
constructor(e, t, n) {
|
|
2344
2732
|
this.mappings = t, this.options = n;
|
|
2345
2733
|
}
|
|
@@ -2363,7 +2751,7 @@ var hr = {
|
|
|
2363
2751
|
};
|
|
2364
2752
|
//#endregion
|
|
2365
2753
|
//#region src/exporter/mapping.ts
|
|
2366
|
-
function
|
|
2754
|
+
function ti(e) {
|
|
2367
2755
|
return {
|
|
2368
2756
|
createBlockMapping: (e) => e,
|
|
2369
2757
|
createInlineContentMapping: (e) => e,
|
|
@@ -2372,7 +2760,7 @@ function vr(e) {
|
|
|
2372
2760
|
}
|
|
2373
2761
|
//#endregion
|
|
2374
2762
|
//#region src/util/combineByGroup.ts
|
|
2375
|
-
function
|
|
2763
|
+
function ni(e, ...t) {
|
|
2376
2764
|
let n = [...e];
|
|
2377
2765
|
for (let e of t) for (let t of e) {
|
|
2378
2766
|
let e = n.findLastIndex((e) => e.group === t.group);
|
|
@@ -2381,6 +2769,6 @@ function yr(e, ...t) {
|
|
|
2381
2769
|
return n;
|
|
2382
2770
|
}
|
|
2383
2771
|
//#endregion
|
|
2384
|
-
export {
|
|
2772
|
+
export { V as _, Ir as a, gt as b, q as c, Kt as d, qt as f, H as g, U as h, $r as i, K as l, kt as m, ti as n, dr as o, Gt as p, ei as r, un as s, ni as t, Wt as u, vt as v, ht as x, _t as y };
|
|
2385
2773
|
|
|
2386
|
-
//# sourceMappingURL=src-
|
|
2774
|
+
//# sourceMappingURL=src-SVFpMAWE.js.map
|