@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,34 +1,34 @@
|
|
|
1
1
|
import { n as e, t } from "./BlockNoteExtension-B6RhuQ3V.js";
|
|
2
2
|
import { DOMParser as n, Fragment as r, Slice as i } from "prosemirror-model";
|
|
3
3
|
import { Mapping as a, ReplaceStep as o } from "prosemirror-transform";
|
|
4
|
-
import { Extension as s,
|
|
5
|
-
import { Plugin as
|
|
6
|
-
import {
|
|
7
|
-
import { DOMParser as
|
|
8
|
-
import { CellSelection as
|
|
9
|
-
import { createHighlightPlugin as
|
|
10
|
-
import { createParser as
|
|
11
|
-
import { Plugin as
|
|
12
|
-
import { Decoration as
|
|
13
|
-
import { Decoration as
|
|
14
|
-
import { absolutePositionToRelativePosition as
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
4
|
+
import { Extension as s, InputRule as c, Mark as l, Node as u, callOrReturn as d, combineTransactionSteps as f, findChildrenInRange as p, findParentNode as m, getChangedRanges as h, getExtensionField as g, markInputRule as _, mergeAttributes as v } from "@tiptap/core";
|
|
5
|
+
import { Plugin as y, PluginKey as ee, TextSelection as te } from "prosemirror-state";
|
|
6
|
+
import { uuidv4 as ne } from "lib0/random";
|
|
7
|
+
import { DOMParser as re, DOMSerializer as ie, Fragment as ae } from "@tiptap/pm/model";
|
|
8
|
+
import { CellSelection as oe, TableMap as se, TableView as ce, columnResizing as le, goToNextCell as ue, isInTable as de, moveCellForward as fe, nextCell as pe, selectionCell as me, tableEditing as he } from "prosemirror-tables";
|
|
9
|
+
import { createHighlightPlugin as ge } from "prosemirror-highlight";
|
|
10
|
+
import { createParser as _e } from "prosemirror-highlight/shiki";
|
|
11
|
+
import { Plugin as ve, PluginKey as ye } from "@tiptap/pm/state";
|
|
12
|
+
import { Decoration as be, DecorationSet as xe } from "@tiptap/pm/view";
|
|
13
|
+
import { Decoration as Se, DecorationSet as Ce } from "prosemirror-view";
|
|
14
|
+
import { absolutePositionToRelativePosition as we, relativePositionToAbsolutePosition as Te, ySyncPluginKey as Ee } from "y-prosemirror";
|
|
15
|
+
import De from "@tiptap/extension-bold";
|
|
16
|
+
import Oe from "@tiptap/extension-code";
|
|
17
|
+
import ke from "@tiptap/extension-italic";
|
|
18
|
+
import Ae from "@tiptap/extension-strike";
|
|
19
|
+
import je from "@tiptap/extension-underline";
|
|
20
20
|
//#region src/extensions/tiptap-extensions/UniqueID/UniqueID.ts
|
|
21
|
-
function
|
|
21
|
+
function Me(e, t = JSON.stringify) {
|
|
22
22
|
let n = {};
|
|
23
23
|
return e.filter((e) => {
|
|
24
24
|
let r = t(e);
|
|
25
25
|
return Object.prototype.hasOwnProperty.call(n, r) ? !1 : n[r] = !0;
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
return
|
|
28
|
+
function Ne(e) {
|
|
29
|
+
return Me(e.filter((t, n) => e.indexOf(t) !== n));
|
|
30
30
|
}
|
|
31
|
-
var
|
|
31
|
+
var Pe = s.create({
|
|
32
32
|
name: "uniqueID",
|
|
33
33
|
priority: 1e4,
|
|
34
34
|
addOptions() {
|
|
@@ -42,7 +42,7 @@ var ke = s.create({
|
|
|
42
42
|
let e = window.__TEST_OPTIONS;
|
|
43
43
|
return e.mockID === void 0 ? e.mockID = 0 : e.mockID++, e.mockID.toString();
|
|
44
44
|
}
|
|
45
|
-
return
|
|
45
|
+
return ne();
|
|
46
46
|
},
|
|
47
47
|
filterTransaction: null
|
|
48
48
|
};
|
|
@@ -65,14 +65,14 @@ var ke = s.create({
|
|
|
65
65
|
},
|
|
66
66
|
addProseMirrorPlugins() {
|
|
67
67
|
let { isWithinEditor: e } = this.options, t = null, n = !1;
|
|
68
|
-
return [new
|
|
69
|
-
key: new
|
|
68
|
+
return [new y({
|
|
69
|
+
key: new ee("uniqueID"),
|
|
70
70
|
appendTransaction: (e, t, n) => {
|
|
71
71
|
let r = e.some((e) => e.docChanged) && !t.doc.eq(n.doc), i = this.options.filterTransaction && e.some((e) => !this.options.filterTransaction?.(e));
|
|
72
72
|
if (!r || i) return;
|
|
73
|
-
let { tr: a } = n, { types: o, attributeName: s, generateID: c } = this.options, l =
|
|
74
|
-
if (
|
|
75
|
-
let r =
|
|
73
|
+
let { tr: a } = n, { types: o, attributeName: s, generateID: c } = this.options, l = f(t.doc, e), { mapping: u } = l;
|
|
74
|
+
if (h(l).forEach(({ newRange: e }) => {
|
|
75
|
+
let r = p(n.doc, e, (e) => o.includes(e.type.name)), i = Ne(r.map(({ node: e }) => e.attrs[s]).filter((e) => e !== null));
|
|
76
76
|
r.forEach(({ node: e, pos: r }) => {
|
|
77
77
|
let o = a.doc.nodeAt(r)?.attrs[s];
|
|
78
78
|
if (o === null) {
|
|
@@ -143,19 +143,19 @@ var ke = s.create({
|
|
|
143
143
|
});
|
|
144
144
|
//#endregion
|
|
145
145
|
//#region src/schema/inlineContent/types.ts
|
|
146
|
-
function
|
|
146
|
+
function Fe(e) {
|
|
147
147
|
return e.type === "link";
|
|
148
148
|
}
|
|
149
|
-
function
|
|
149
|
+
function Ie(e) {
|
|
150
150
|
return typeof e != "string" && e.type === "link";
|
|
151
151
|
}
|
|
152
|
-
function
|
|
152
|
+
function b(e) {
|
|
153
153
|
return typeof e != "string" && e.type === "text";
|
|
154
154
|
}
|
|
155
155
|
//#endregion
|
|
156
156
|
//#region src/util/table.ts
|
|
157
|
-
function
|
|
158
|
-
return
|
|
157
|
+
function x(e) {
|
|
158
|
+
return C(e) ? { ...e } : S(e) ? {
|
|
159
159
|
type: "tableCell",
|
|
160
160
|
content: [].concat(e.content),
|
|
161
161
|
props: {
|
|
@@ -177,55 +177,55 @@ function Me(e) {
|
|
|
177
177
|
}
|
|
178
178
|
};
|
|
179
179
|
}
|
|
180
|
-
function
|
|
180
|
+
function S(e) {
|
|
181
181
|
return e != null && typeof e != "string" && !Array.isArray(e) && e.type === "tableCell";
|
|
182
182
|
}
|
|
183
|
-
function
|
|
184
|
-
return
|
|
183
|
+
function C(e) {
|
|
184
|
+
return S(e) && e.props !== void 0 && e.content !== void 0;
|
|
185
185
|
}
|
|
186
|
-
function
|
|
187
|
-
return
|
|
186
|
+
function w(e) {
|
|
187
|
+
return C(e) ? e.props.colspan ?? 1 : 1;
|
|
188
188
|
}
|
|
189
|
-
function
|
|
190
|
-
return
|
|
189
|
+
function Le(e) {
|
|
190
|
+
return C(e) ? e.props.rowspan ?? 1 : 1;
|
|
191
191
|
}
|
|
192
192
|
//#endregion
|
|
193
193
|
//#region src/util/typescript.ts
|
|
194
|
-
var
|
|
194
|
+
var T = class extends Error {
|
|
195
195
|
constructor(e) {
|
|
196
196
|
super(`Unreachable case: ${e}`);
|
|
197
197
|
}
|
|
198
198
|
};
|
|
199
|
-
function
|
|
199
|
+
function Re(e, t = !0) {
|
|
200
200
|
let { "data-test": n, ...r } = e;
|
|
201
201
|
if (Object.keys(r).length > 0 && t) throw Error("Object must be empty " + JSON.stringify(e));
|
|
202
202
|
}
|
|
203
203
|
//#endregion
|
|
204
204
|
//#region src/util/browser.ts
|
|
205
|
-
var
|
|
206
|
-
function
|
|
207
|
-
return
|
|
205
|
+
var ze = () => typeof navigator < "u" && (/Mac/.test(navigator.platform) || /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent));
|
|
206
|
+
function E(e, t = "Ctrl") {
|
|
207
|
+
return ze() ? e.replace("Mod", "⌘") : e.replace("Mod", t);
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function D(...e) {
|
|
210
210
|
return [...new Set(e.filter((e) => e).join(" ").split(" "))].join(" ");
|
|
211
211
|
}
|
|
212
|
-
var
|
|
212
|
+
var Be = () => /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
213
213
|
//#endregion
|
|
214
214
|
//#region src/blocks/defaultBlockHelpers.ts
|
|
215
|
-
function
|
|
215
|
+
function Ve(e, t, n, r) {
|
|
216
216
|
let i = document.createElement("div");
|
|
217
|
-
i.className =
|
|
217
|
+
i.className = D("bn-block-content", n.class), i.setAttribute("data-content-type", e);
|
|
218
218
|
for (let [e, t] of Object.entries(n)) e !== "class" && i.setAttribute(e, t);
|
|
219
219
|
let a = document.createElement(t);
|
|
220
|
-
a.className =
|
|
220
|
+
a.className = D("bn-inline-content", r.class);
|
|
221
221
|
for (let [e, t] of Object.entries(r)) e !== "class" && a.setAttribute(e, t);
|
|
222
222
|
return i.appendChild(a), {
|
|
223
223
|
dom: i,
|
|
224
224
|
contentDOM: a
|
|
225
225
|
};
|
|
226
226
|
}
|
|
227
|
-
var
|
|
228
|
-
let n =
|
|
227
|
+
var He = (e, t) => {
|
|
228
|
+
let n = W(e, t.pmSchema);
|
|
229
229
|
n.type.name === "blockContainer" && (n = n.firstChild);
|
|
230
230
|
let r = t.pmSchema.nodes[n.type.name].spec.toDOM;
|
|
231
231
|
if (r === void 0) throw Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");
|
|
@@ -233,7 +233,7 @@ var ze = (e, t) => {
|
|
|
233
233
|
if (typeof i != "object" || !("dom" in i)) throw Error("Cannot use this block's default HTML serialization as its corresponding TipTap node's `renderHTML` function does not return an object with the `dom` property.");
|
|
234
234
|
return i;
|
|
235
235
|
};
|
|
236
|
-
function
|
|
236
|
+
function Ue(e, t = "<br>") {
|
|
237
237
|
let n = e.querySelectorAll("p");
|
|
238
238
|
if (n.length > 1) {
|
|
239
239
|
let e = n[0];
|
|
@@ -245,14 +245,14 @@ function Be(e, t = "<br>") {
|
|
|
245
245
|
}
|
|
246
246
|
//#endregion
|
|
247
247
|
//#region src/util/string.ts
|
|
248
|
-
function
|
|
248
|
+
function O(e) {
|
|
249
249
|
return "data-" + e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
250
250
|
}
|
|
251
|
-
function
|
|
251
|
+
function We(e) {
|
|
252
252
|
let t = e.split("/");
|
|
253
253
|
return !t.length || t[t.length - 1] === "" ? e : t[t.length - 1];
|
|
254
254
|
}
|
|
255
|
-
function
|
|
255
|
+
function Ge(e) {
|
|
256
256
|
let t = [
|
|
257
257
|
"mp4",
|
|
258
258
|
"webm",
|
|
@@ -273,14 +273,14 @@ function He(e) {
|
|
|
273
273
|
}
|
|
274
274
|
//#endregion
|
|
275
275
|
//#region src/schema/blocks/internal.ts
|
|
276
|
-
function
|
|
276
|
+
function Ke(e) {
|
|
277
277
|
let t = {};
|
|
278
278
|
return Object.entries(e).forEach(([e, n]) => {
|
|
279
279
|
t[e] = {
|
|
280
280
|
default: n.default,
|
|
281
281
|
keepOnSplit: !0,
|
|
282
282
|
parseHTML: (t) => {
|
|
283
|
-
let r = t.getAttribute(
|
|
283
|
+
let r = t.getAttribute(O(e));
|
|
284
284
|
if (r === null) return null;
|
|
285
285
|
if (n.default === void 0 && n.type === "boolean" || n.default !== void 0 && typeof n.default == "boolean") return r === "true" ? !0 : r === "false" ? !1 : null;
|
|
286
286
|
if (n.default === void 0 && n.type === "number" || n.default !== void 0 && typeof n.default == "number") {
|
|
@@ -289,11 +289,11 @@ function Ue(e) {
|
|
|
289
289
|
}
|
|
290
290
|
return r;
|
|
291
291
|
},
|
|
292
|
-
renderHTML: (t) => t[e] === n.default ? {} : { [
|
|
292
|
+
renderHTML: (t) => t[e] === n.default ? {} : { [O(e)]: t[e] }
|
|
293
293
|
};
|
|
294
294
|
}), t;
|
|
295
295
|
}
|
|
296
|
-
function
|
|
296
|
+
function qe(e, t, n, r) {
|
|
297
297
|
let i = e();
|
|
298
298
|
if (i === void 0) throw Error("Cannot find node position");
|
|
299
299
|
let a = n.state.doc.resolve(i).node().attrs.id;
|
|
@@ -302,17 +302,17 @@ function We(e, t, n, r) {
|
|
|
302
302
|
if (o.type !== r) throw Error("Block type does not match");
|
|
303
303
|
return o;
|
|
304
304
|
}
|
|
305
|
-
function
|
|
305
|
+
function k(e, t, n, r, i = !1, a) {
|
|
306
306
|
let o = document.createElement("div");
|
|
307
307
|
if (a !== void 0) for (let [e, t] of Object.entries(a)) e !== "class" && o.setAttribute(e, t);
|
|
308
|
-
o.className =
|
|
309
|
-
for (let [e, t] of Object.entries(n)) t !== r[e].default && o.setAttribute(
|
|
310
|
-
return i && o.setAttribute("data-file-block", ""), o.appendChild(e.dom), e.contentDOM && (e.contentDOM.className =
|
|
308
|
+
o.className = D("bn-block-content", a?.class || ""), o.setAttribute("data-content-type", t);
|
|
309
|
+
for (let [e, t] of Object.entries(n)) t !== r[e].default && o.setAttribute(O(e), t);
|
|
310
|
+
return i && o.setAttribute("data-file-block", ""), o.appendChild(e.dom), e.contentDOM && (e.contentDOM.className = D("bn-inline-content", e.contentDOM.className)), {
|
|
311
311
|
...e,
|
|
312
312
|
dom: o
|
|
313
313
|
};
|
|
314
314
|
}
|
|
315
|
-
function
|
|
315
|
+
function Je(e, t, n) {
|
|
316
316
|
return {
|
|
317
317
|
config: {
|
|
318
318
|
type: e.type,
|
|
@@ -321,20 +321,20 @@ function Ge(e, t, n) {
|
|
|
321
321
|
},
|
|
322
322
|
implementation: {
|
|
323
323
|
node: e.node,
|
|
324
|
-
render:
|
|
325
|
-
toExternalHTML:
|
|
324
|
+
render: He,
|
|
325
|
+
toExternalHTML: He
|
|
326
326
|
},
|
|
327
327
|
extensions: n
|
|
328
328
|
};
|
|
329
329
|
}
|
|
330
330
|
//#endregion
|
|
331
331
|
//#region src/schema/blocks/createSpec.ts
|
|
332
|
-
function
|
|
332
|
+
function Ye(e, t) {
|
|
333
333
|
e.stopEvent = (e) => (e.type === "mousedown" && setTimeout(() => {
|
|
334
334
|
t.view.dom.blur();
|
|
335
335
|
}, 10), !0);
|
|
336
336
|
}
|
|
337
|
-
function
|
|
337
|
+
function Xe(e, t) {
|
|
338
338
|
let n = [{
|
|
339
339
|
tag: "[data-content-type=" + e.type + "]",
|
|
340
340
|
contentElement: ".bn-inline-content"
|
|
@@ -357,17 +357,17 @@ function qe(e, t) {
|
|
|
357
357
|
}
|
|
358
358
|
if (e.content === "inline") {
|
|
359
359
|
let e = n.cloneNode(!0);
|
|
360
|
-
return
|
|
360
|
+
return Ue(e, t.meta?.code ? "\n" : "<br>"), re.fromSchema(r).parse(e, {
|
|
361
361
|
topNode: r.nodes.paragraph.create(),
|
|
362
362
|
preserveWhitespace: !0
|
|
363
363
|
}).content;
|
|
364
364
|
}
|
|
365
|
-
return
|
|
365
|
+
return ae.empty;
|
|
366
366
|
} : void 0
|
|
367
367
|
}), n;
|
|
368
368
|
}
|
|
369
|
-
function
|
|
370
|
-
let i = t.node ||
|
|
369
|
+
function Ze(e, t, n, r) {
|
|
370
|
+
let i = t.node || u.create({
|
|
371
371
|
name: e.type,
|
|
372
372
|
content: e.content === "inline" ? "inline*" : e.content === "none" ? "" : e.content,
|
|
373
373
|
group: "blockContent",
|
|
@@ -377,26 +377,26 @@ function Je(e, t, n, r) {
|
|
|
377
377
|
defining: t.meta?.defining ?? !0,
|
|
378
378
|
priority: r,
|
|
379
379
|
addAttributes() {
|
|
380
|
-
return
|
|
380
|
+
return Ke(e.propSchema);
|
|
381
381
|
},
|
|
382
382
|
parseHTML() {
|
|
383
|
-
return
|
|
383
|
+
return Xe(e, t);
|
|
384
384
|
},
|
|
385
385
|
renderHTML({ HTMLAttributes: n }) {
|
|
386
386
|
let r = document.createElement("div");
|
|
387
|
-
return
|
|
387
|
+
return k({
|
|
388
388
|
dom: r,
|
|
389
389
|
contentDOM: e.content === "inline" ? r : void 0
|
|
390
390
|
}, e.type, {}, e.propSchema, t.meta?.fileBlockAccept !== void 0, n);
|
|
391
391
|
},
|
|
392
392
|
addNodeView() {
|
|
393
393
|
return (n) => {
|
|
394
|
-
let r = this.options.editor, i =
|
|
394
|
+
let r = this.options.editor, i = qe(n.getPos, r, this.editor, e.type), a = this.options.domAttributes?.blockContent || {}, o = t.render.call({
|
|
395
395
|
blockContentDOMAttributes: a,
|
|
396
396
|
props: n,
|
|
397
397
|
renderType: "nodeView"
|
|
398
398
|
}, i, r);
|
|
399
|
-
return t.meta?.selectable === !1 &&
|
|
399
|
+
return t.meta?.selectable === !1 && Ye(o, this.editor), o;
|
|
400
400
|
};
|
|
401
401
|
}
|
|
402
402
|
});
|
|
@@ -426,10 +426,10 @@ function Je(e, t, n, r) {
|
|
|
426
426
|
extensions: n
|
|
427
427
|
};
|
|
428
428
|
}
|
|
429
|
-
function
|
|
429
|
+
function A(e) {
|
|
430
430
|
return e;
|
|
431
431
|
}
|
|
432
|
-
function
|
|
432
|
+
function j(e, t, n) {
|
|
433
433
|
return (r = {}) => {
|
|
434
434
|
let i = typeof e == "function" ? e(r) : e, a = typeof t == "function" ? t(r) : t, o = n ? typeof n == "function" ? n(r) : n : void 0;
|
|
435
435
|
return {
|
|
@@ -438,10 +438,10 @@ function O(e, t, n) {
|
|
|
438
438
|
...a,
|
|
439
439
|
toExternalHTML(e, t, n) {
|
|
440
440
|
let r = a.toExternalHTML?.call({ blockContentDOMAttributes: this.blockContentDOMAttributes }, e, t, n);
|
|
441
|
-
if (r !== void 0) return
|
|
441
|
+
if (r !== void 0) return k(r, e.type, e.props, i.propSchema, a.meta?.fileBlockAccept !== void 0);
|
|
442
442
|
},
|
|
443
443
|
render(e, t) {
|
|
444
|
-
return
|
|
444
|
+
return k(a.render.call({
|
|
445
445
|
blockContentDOMAttributes: this.blockContentDOMAttributes,
|
|
446
446
|
renderType: this.renderType,
|
|
447
447
|
props: this.props
|
|
@@ -454,7 +454,7 @@ function O(e, t, n) {
|
|
|
454
454
|
}
|
|
455
455
|
//#endregion
|
|
456
456
|
//#region src/api/getBlockInfoFromPos.ts
|
|
457
|
-
function
|
|
457
|
+
function M(e, t) {
|
|
458
458
|
let n = e.resolve(t);
|
|
459
459
|
if (n.nodeAfter && n.nodeAfter.type.isInGroup("bnBlock")) return {
|
|
460
460
|
posBeforeNode: n.pos,
|
|
@@ -478,7 +478,7 @@ function Ye(e, t) {
|
|
|
478
478
|
node: o.nodeAfter
|
|
479
479
|
};
|
|
480
480
|
}
|
|
481
|
-
function
|
|
481
|
+
function Qe(e, t) {
|
|
482
482
|
if (!e.type.isInGroup("bnBlock")) throw Error(`Attempted to get bnBlock node at position but found node of different type ${e.type.name}`);
|
|
483
483
|
let n = e, r = t, i = {
|
|
484
484
|
node: n,
|
|
@@ -521,45 +521,45 @@ function Xe(e, t) {
|
|
|
521
521
|
};
|
|
522
522
|
}
|
|
523
523
|
}
|
|
524
|
-
function
|
|
525
|
-
return
|
|
524
|
+
function N(e) {
|
|
525
|
+
return Qe(e.node, e.posBeforeNode);
|
|
526
526
|
}
|
|
527
|
-
function
|
|
527
|
+
function $e(e) {
|
|
528
528
|
if (!e.nodeAfter) throw Error(`Attempted to get blockContainer node at position ${e.pos} but a node at this position does not exist`);
|
|
529
|
-
return
|
|
529
|
+
return Qe(e.nodeAfter, e.pos);
|
|
530
530
|
}
|
|
531
|
-
function
|
|
532
|
-
return
|
|
531
|
+
function et(e) {
|
|
532
|
+
return N(M(e.doc, e.selection.anchor));
|
|
533
533
|
}
|
|
534
|
-
function
|
|
535
|
-
return
|
|
534
|
+
function tt(e) {
|
|
535
|
+
return N(M(e.doc, e.selection.anchor));
|
|
536
536
|
}
|
|
537
537
|
//#endregion
|
|
538
538
|
//#region src/api/pmUtil.ts
|
|
539
|
-
function
|
|
539
|
+
function P(e) {
|
|
540
540
|
return "doc" in e ? e.doc.type.schema : e.type.schema;
|
|
541
541
|
}
|
|
542
|
-
function
|
|
542
|
+
function nt(e) {
|
|
543
543
|
return e.cached.blockNoteEditor;
|
|
544
544
|
}
|
|
545
|
-
function
|
|
546
|
-
return
|
|
545
|
+
function rt(e) {
|
|
546
|
+
return nt(e).schema;
|
|
547
547
|
}
|
|
548
|
-
function
|
|
549
|
-
return
|
|
548
|
+
function it(e) {
|
|
549
|
+
return rt(e).blockSchema;
|
|
550
550
|
}
|
|
551
|
-
function
|
|
552
|
-
return
|
|
553
|
-
}
|
|
554
|
-
function P(e) {
|
|
555
|
-
return j(e).styleSchema;
|
|
551
|
+
function at(e) {
|
|
552
|
+
return rt(e).inlineContentSchema;
|
|
556
553
|
}
|
|
557
554
|
function F(e) {
|
|
558
|
-
return
|
|
555
|
+
return rt(e).styleSchema;
|
|
556
|
+
}
|
|
557
|
+
function ot(e) {
|
|
558
|
+
return nt(e).blockCache;
|
|
559
559
|
}
|
|
560
560
|
//#endregion
|
|
561
561
|
//#region src/api/nodeConversions/nodeToBlock.ts
|
|
562
|
-
function
|
|
562
|
+
function st(e, t, n) {
|
|
563
563
|
let r = {
|
|
564
564
|
type: "tableContent",
|
|
565
565
|
columnWidths: [],
|
|
@@ -574,10 +574,10 @@ function tt(e, t, n) {
|
|
|
574
574
|
t ??= Array(e.attrs.colspan ?? 1).fill(void 0), r.columnWidths.push(...t);
|
|
575
575
|
}), s.cells = e.content.content.map((e, r) => (i[o] || (i[o] = []), i[o][r] = e.type.name === "tableHeader", {
|
|
576
576
|
type: "tableCell",
|
|
577
|
-
content: e.content.content.map((e) =>
|
|
577
|
+
content: e.content.content.map((e) => I(e, t, n)).reduce((e, t) => {
|
|
578
578
|
if (!e.length) return t;
|
|
579
579
|
let n = e[e.length - 1], r = t[0];
|
|
580
|
-
return r &&
|
|
580
|
+
return r && b(n) && b(r) && JSON.stringify(n.styles) === JSON.stringify(r.styles) ? (n.text += "\n" + r.text, e.push(...t.slice(1)), e) : (e.push(...t), e);
|
|
581
581
|
}, []),
|
|
582
582
|
props: {
|
|
583
583
|
colspan: e.attrs.colspan,
|
|
@@ -592,12 +592,12 @@ function tt(e, t, n) {
|
|
|
592
592
|
for (let e = 0; e < i[0]?.length; e++) i?.every((t) => t[e]) && (r.headerCols = (r.headerCols ?? 0) + 1);
|
|
593
593
|
return r;
|
|
594
594
|
}
|
|
595
|
-
function
|
|
595
|
+
function I(e, t, n) {
|
|
596
596
|
let r = [], i;
|
|
597
597
|
return e.content.forEach((e) => {
|
|
598
598
|
if (e.type.name === "hardBreak") {
|
|
599
|
-
if (i) if (
|
|
600
|
-
else if (
|
|
599
|
+
if (i) if (b(i)) i.text += "\n";
|
|
600
|
+
else if (Fe(i)) i.content[i.content.length - 1].text += "\n";
|
|
601
601
|
else throw Error("unexpected");
|
|
602
602
|
else i = {
|
|
603
603
|
type: "text",
|
|
@@ -611,7 +611,7 @@ function nt(e, t, n) {
|
|
|
611
611
|
console.warn("unrecognized inline content type", e.type.name);
|
|
612
612
|
return;
|
|
613
613
|
}
|
|
614
|
-
i &&= (r.push(i), void 0), r.push(
|
|
614
|
+
i &&= (r.push(i), void 0), r.push(ct(e, t, n));
|
|
615
615
|
return;
|
|
616
616
|
}
|
|
617
617
|
let a = {}, o;
|
|
@@ -624,9 +624,9 @@ function nt(e, t, n) {
|
|
|
624
624
|
}
|
|
625
625
|
if (e.propSchema === "boolean") a[e.type] = !0;
|
|
626
626
|
else if (e.propSchema === "string") a[e.type] = t.attrs.stringValue;
|
|
627
|
-
else throw new
|
|
627
|
+
else throw new T(e.propSchema);
|
|
628
628
|
}
|
|
629
|
-
i ?
|
|
629
|
+
i ? b(i) ? o ? (r.push(i), i = {
|
|
630
630
|
type: "link",
|
|
631
631
|
href: o.attrs.href,
|
|
632
632
|
content: [{
|
|
@@ -638,7 +638,7 @@ function nt(e, t, n) {
|
|
|
638
638
|
type: "text",
|
|
639
639
|
text: e.textContent,
|
|
640
640
|
styles: a
|
|
641
|
-
}) :
|
|
641
|
+
}) : Fe(i) && (o ? i.href === o.attrs.href ? JSON.stringify(i.content[i.content.length - 1].styles) === JSON.stringify(a) ? i.content[i.content.length - 1].text += e.textContent : i.content.push({
|
|
642
642
|
type: "text",
|
|
643
643
|
text: e.textContent,
|
|
644
644
|
styles: a
|
|
@@ -669,7 +669,7 @@ function nt(e, t, n) {
|
|
|
669
669
|
};
|
|
670
670
|
}), i && r.push(i), r;
|
|
671
671
|
}
|
|
672
|
-
function
|
|
672
|
+
function ct(e, t, n) {
|
|
673
673
|
if (e.type.name === "text" || e.type.name === "link") throw Error("unexpected");
|
|
674
674
|
let r = {}, i = t[e.type.name];
|
|
675
675
|
for (let [t, n] of Object.entries(e.attrs)) {
|
|
@@ -677,18 +677,18 @@ function rt(e, t, n) {
|
|
|
677
677
|
t in i.propSchema && (r[t] = n);
|
|
678
678
|
}
|
|
679
679
|
let a;
|
|
680
|
-
return a = i.content === "styled" ?
|
|
680
|
+
return a = i.content === "styled" ? I(e, t, n) : void 0, {
|
|
681
681
|
type: e.type.name,
|
|
682
682
|
props: r,
|
|
683
683
|
content: a
|
|
684
684
|
};
|
|
685
685
|
}
|
|
686
|
-
function
|
|
686
|
+
function L(e, t, n = it(t), r = at(t), i = F(t), a = ot(t)) {
|
|
687
687
|
if (!e.type.isInGroup("bnBlock")) throw Error("Node should be a bnBlock, but is instead: " + e.type.name);
|
|
688
688
|
let o = a?.get(e);
|
|
689
689
|
if (o) return o;
|
|
690
|
-
let s =
|
|
691
|
-
c === null && (c =
|
|
690
|
+
let s = Qe(e, 0), c = s.bnBlock.node.attrs.id;
|
|
691
|
+
c === null && (c = Pe.options.generateID());
|
|
692
692
|
let l = n[s.blockNoteType];
|
|
693
693
|
if (!l) throw Error("Block is of an unrecognized type: " + s.blockNoteType);
|
|
694
694
|
let u = {};
|
|
@@ -701,17 +701,17 @@ function I(e, t, n = M(t), r = N(t), i = P(t), a = F(t)) {
|
|
|
701
701
|
}
|
|
702
702
|
let d = n[s.blockNoteType], f = [];
|
|
703
703
|
s.childContainer?.node.forEach((e) => {
|
|
704
|
-
f.push(
|
|
704
|
+
f.push(L(e, t, n, r, i, a));
|
|
705
705
|
});
|
|
706
706
|
let p;
|
|
707
707
|
if (d.content === "inline") {
|
|
708
708
|
if (!s.isBlockContainer) throw Error("impossible");
|
|
709
|
-
p =
|
|
709
|
+
p = I(s.blockContent.node, r, i);
|
|
710
710
|
} else if (d.content === "table") {
|
|
711
711
|
if (!s.isBlockContainer) throw Error("impossible");
|
|
712
|
-
p =
|
|
712
|
+
p = st(s.blockContent.node, r, i);
|
|
713
713
|
} else if (d.content === "none") p = void 0;
|
|
714
|
-
else throw new
|
|
714
|
+
else throw new T(d.content);
|
|
715
715
|
let m = {
|
|
716
716
|
id: c,
|
|
717
717
|
type: d.type,
|
|
@@ -721,11 +721,11 @@ function I(e, t, n = M(t), r = N(t), i = P(t), a = F(t)) {
|
|
|
721
721
|
};
|
|
722
722
|
return a?.set(e, m), m;
|
|
723
723
|
}
|
|
724
|
-
function
|
|
724
|
+
function lt(e, t = P(e), n = it(t), r = at(t), i = F(t), a = ot(t)) {
|
|
725
725
|
let o = [];
|
|
726
|
-
return e.firstChild && e.firstChild.descendants((e) => (o.push(
|
|
726
|
+
return e.firstChild && e.firstChild.descendants((e) => (o.push(L(e, t, n, r, i, a)), !1)), o;
|
|
727
727
|
}
|
|
728
|
-
function
|
|
728
|
+
function ut(e, t, n = it(t), r = at(t), i = F(t), a = ot(t)) {
|
|
729
729
|
function o(e, s, c) {
|
|
730
730
|
if (e.type.name !== "blockGroup") throw Error("unexpected");
|
|
731
731
|
let l = [], u, d;
|
|
@@ -740,14 +740,14 @@ function at(e, t, n = M(t), r = N(t), i = P(t), a = F(t)) {
|
|
|
740
740
|
u = e.blockCutAtStart, g && (d = e.blockCutAtEnd), l.push(...e.blocks);
|
|
741
741
|
return;
|
|
742
742
|
}
|
|
743
|
-
let _ =
|
|
743
|
+
let _ = L(f, t, n, r, i, a), v = f.childCount > 1 ? f.child(1) : void 0, y = [];
|
|
744
744
|
if (v) {
|
|
745
745
|
let e = o(v, 0, g ? Math.max(0, c - 1) : 0);
|
|
746
|
-
|
|
746
|
+
y = e.blocks, g && (d = e.blockCutAtEnd);
|
|
747
747
|
}
|
|
748
748
|
g && !v && c > 1 && (d = _.id), h && s > 1 && (u = _.id), l.push({
|
|
749
749
|
..._,
|
|
750
|
-
children:
|
|
750
|
+
children: y
|
|
751
751
|
});
|
|
752
752
|
}), {
|
|
753
753
|
blocks: l,
|
|
@@ -765,23 +765,23 @@ function at(e, t, n = M(t), r = N(t), i = P(t), a = F(t)) {
|
|
|
765
765
|
}
|
|
766
766
|
//#endregion
|
|
767
767
|
//#region src/schema/inlineContent/internal.ts
|
|
768
|
-
function
|
|
769
|
-
return e.dom.setAttribute("data-inline-content-type", t), Object.entries(n).filter(([e, t]) => t !== r[e].default).map(([e, t]) => [
|
|
768
|
+
function dt(e, t, n, r) {
|
|
769
|
+
return e.dom.setAttribute("data-inline-content-type", t), Object.entries(n).filter(([e, t]) => t !== r[e].default).map(([e, t]) => [O(e), t]).forEach(([t, n]) => e.dom.setAttribute(t, n)), e.contentDOM && e.contentDOM.setAttribute("data-editable", ""), e;
|
|
770
770
|
}
|
|
771
|
-
function
|
|
771
|
+
function ft(e) {
|
|
772
772
|
return { Backspace: ({ editor: t }) => {
|
|
773
773
|
let n = t.state.selection.$from;
|
|
774
774
|
return t.state.selection.empty && n.node().type.name === e.type && n.parentOffset === 0;
|
|
775
775
|
} };
|
|
776
776
|
}
|
|
777
|
-
function
|
|
777
|
+
function pt(e, t) {
|
|
778
778
|
return {
|
|
779
779
|
config: e,
|
|
780
780
|
implementation: t
|
|
781
781
|
};
|
|
782
782
|
}
|
|
783
|
-
function
|
|
784
|
-
return
|
|
783
|
+
function mt(e, t, n) {
|
|
784
|
+
return pt({
|
|
785
785
|
type: e.name,
|
|
786
786
|
propSchema: t,
|
|
787
787
|
content: e.config.content === "inline*" ? "styled" : "none"
|
|
@@ -790,12 +790,12 @@ function lt(e, t, n) {
|
|
|
790
790
|
node: e
|
|
791
791
|
});
|
|
792
792
|
}
|
|
793
|
-
function
|
|
793
|
+
function ht(e) {
|
|
794
794
|
return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, t.config]));
|
|
795
795
|
}
|
|
796
796
|
//#endregion
|
|
797
797
|
//#region src/schema/styles/internal.ts
|
|
798
|
-
function
|
|
798
|
+
function gt(e) {
|
|
799
799
|
return e === "boolean" ? {} : { stringValue: {
|
|
800
800
|
default: void 0,
|
|
801
801
|
keepOnSplit: !0,
|
|
@@ -803,17 +803,17 @@ function dt(e) {
|
|
|
803
803
|
renderHTML: (e) => e.stringValue === void 0 ? {} : { "data-value": e.stringValue }
|
|
804
804
|
} };
|
|
805
805
|
}
|
|
806
|
-
function
|
|
806
|
+
function R(e, t, n, r) {
|
|
807
807
|
return e.dom.setAttribute("data-style-type", t), r === "string" && e.dom.setAttribute("data-value", n), e.contentDOM && e.contentDOM.setAttribute("data-editable", ""), e;
|
|
808
808
|
}
|
|
809
|
-
function
|
|
809
|
+
function _t(e, t) {
|
|
810
810
|
return {
|
|
811
811
|
config: e,
|
|
812
812
|
implementation: t
|
|
813
813
|
};
|
|
814
814
|
}
|
|
815
|
-
function
|
|
816
|
-
return
|
|
815
|
+
function z(e, t) {
|
|
816
|
+
return _t({
|
|
817
817
|
type: e.name,
|
|
818
818
|
propSchema: t
|
|
819
819
|
}, {
|
|
@@ -821,25 +821,25 @@ function R(e, t) {
|
|
|
821
821
|
render(t, n) {
|
|
822
822
|
let r = n.pmSchema.marks[e.name].spec.toDOM;
|
|
823
823
|
if (r === void 0) throw Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");
|
|
824
|
-
let i = n.pmSchema.mark(e.name, { stringValue: t }), a =
|
|
824
|
+
let i = n.pmSchema.mark(e.name, { stringValue: t }), a = ie.renderSpec(document, r(i, !0));
|
|
825
825
|
if (typeof a != "object" || !("dom" in a)) throw Error("Cannot use this block's default HTML serialization as its corresponding TipTap mark's `renderHTML` function does not return an object with the `dom` property.");
|
|
826
826
|
return a;
|
|
827
827
|
},
|
|
828
828
|
toExternalHTML(t, n) {
|
|
829
829
|
let r = n.pmSchema.marks[e.name].spec.toDOM;
|
|
830
830
|
if (r === void 0) throw Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");
|
|
831
|
-
let i = n.pmSchema.mark(e.name, { stringValue: t }), a =
|
|
831
|
+
let i = n.pmSchema.mark(e.name, { stringValue: t }), a = ie.renderSpec(document, r(i, !0));
|
|
832
832
|
if (typeof a != "object" || !("dom" in a)) throw Error("Cannot use this block's default HTML serialization as its corresponding TipTap mark's `renderHTML` function does not return an object with the `dom` property.");
|
|
833
833
|
return a;
|
|
834
834
|
}
|
|
835
835
|
});
|
|
836
836
|
}
|
|
837
|
-
function
|
|
837
|
+
function vt(e) {
|
|
838
838
|
return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, t.config]));
|
|
839
839
|
}
|
|
840
840
|
//#endregion
|
|
841
841
|
//#region src/schema/styles/createSpec.ts
|
|
842
|
-
function
|
|
842
|
+
function yt(e, t) {
|
|
843
843
|
let n = [{
|
|
844
844
|
tag: `[data-style-type="${e.type}"]`,
|
|
845
845
|
contentElement: (e) => {
|
|
@@ -857,33 +857,33 @@ function mt(e, t) {
|
|
|
857
857
|
}
|
|
858
858
|
}), n;
|
|
859
859
|
}
|
|
860
|
-
function
|
|
861
|
-
let n =
|
|
860
|
+
function bt(e, t) {
|
|
861
|
+
let n = l.create({
|
|
862
862
|
name: e.type,
|
|
863
863
|
addAttributes() {
|
|
864
|
-
return
|
|
864
|
+
return gt(e.propSchema);
|
|
865
865
|
},
|
|
866
866
|
parseHTML() {
|
|
867
|
-
return
|
|
867
|
+
return yt(e, t.parse);
|
|
868
868
|
},
|
|
869
869
|
renderHTML({ mark: n }) {
|
|
870
|
-
return
|
|
870
|
+
return R((t.toExternalHTML || t.render)(n.attrs.stringValue), e.type, n.attrs.stringValue, e.propSchema);
|
|
871
871
|
},
|
|
872
872
|
addMarkView() {
|
|
873
|
-
return ({ mark: n }) =>
|
|
873
|
+
return ({ mark: n }) => R(t.render(n.attrs.stringValue), e.type, n.attrs.stringValue, e.propSchema);
|
|
874
874
|
}
|
|
875
875
|
});
|
|
876
|
-
return
|
|
876
|
+
return _t(e, {
|
|
877
877
|
...t,
|
|
878
878
|
mark: n,
|
|
879
|
-
render: (n) =>
|
|
880
|
-
toExternalHTML: (n) =>
|
|
879
|
+
render: (n) => R(t.render(n), e.type, n, e.propSchema),
|
|
880
|
+
toExternalHTML: (n) => R((t.toExternalHTML || t.render)(n), e.type, n, e.propSchema)
|
|
881
881
|
});
|
|
882
882
|
}
|
|
883
883
|
//#endregion
|
|
884
884
|
//#region src/util/topo-sort.ts
|
|
885
|
-
function
|
|
886
|
-
let t =
|
|
885
|
+
function xt(e) {
|
|
886
|
+
let t = Ct(e), { roots: n, nonRoots: r } = wt(t), i = [];
|
|
887
887
|
for (; n.size;) {
|
|
888
888
|
i.push(n);
|
|
889
889
|
let r = /* @__PURE__ */ new Set();
|
|
@@ -898,13 +898,13 @@ function gt(e) {
|
|
|
898
898
|
}
|
|
899
899
|
n = r;
|
|
900
900
|
}
|
|
901
|
-
if (r =
|
|
901
|
+
if (r = wt(t).nonRoots, r.size) throw Error(`Cycle(s) detected; toposort only works on acyclic graphs. Cyclic nodes: ${Array.from(r).join(", ")}`);
|
|
902
902
|
return i;
|
|
903
903
|
}
|
|
904
|
-
function
|
|
905
|
-
return
|
|
904
|
+
function St(e) {
|
|
905
|
+
return xt(Tt(e));
|
|
906
906
|
}
|
|
907
|
-
function
|
|
907
|
+
function Ct(e) {
|
|
908
908
|
let t = /* @__PURE__ */ new Map();
|
|
909
909
|
for (let [n, r] of e.entries()) {
|
|
910
910
|
t.has(n) || t.set(n, 0);
|
|
@@ -915,7 +915,7 @@ function vt(e) {
|
|
|
915
915
|
}
|
|
916
916
|
return t;
|
|
917
917
|
}
|
|
918
|
-
function
|
|
918
|
+
function wt(e) {
|
|
919
919
|
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
920
920
|
for (let [r, i] of e.entries()) i === 0 ? t.add(r) : n.add(r);
|
|
921
921
|
return {
|
|
@@ -923,7 +923,7 @@ function yt(e) {
|
|
|
923
923
|
nonRoots: n
|
|
924
924
|
};
|
|
925
925
|
}
|
|
926
|
-
function
|
|
926
|
+
function Tt(e) {
|
|
927
927
|
let t = /* @__PURE__ */ new Map();
|
|
928
928
|
for (let [n, r] of e.entries()) {
|
|
929
929
|
t.has(n) || t.set(n, /* @__PURE__ */ new Set());
|
|
@@ -931,26 +931,26 @@ function bt(e) {
|
|
|
931
931
|
}
|
|
932
932
|
return t;
|
|
933
933
|
}
|
|
934
|
-
function
|
|
934
|
+
function Et() {
|
|
935
935
|
return /* @__PURE__ */ new Map();
|
|
936
936
|
}
|
|
937
|
-
function
|
|
937
|
+
function Dt(e, t, n) {
|
|
938
938
|
return e.has(t) || e.set(t, /* @__PURE__ */ new Set()), e.get(t).add(n), e;
|
|
939
939
|
}
|
|
940
|
-
function
|
|
941
|
-
let t =
|
|
940
|
+
function Ot(e) {
|
|
941
|
+
let t = Et();
|
|
942
942
|
for (let n of e) Array.isArray(n.runsBefore) && n.runsBefore.length > 0 ? n.runsBefore.forEach((e) => {
|
|
943
|
-
|
|
944
|
-
}) :
|
|
945
|
-
let n =
|
|
943
|
+
Dt(t, n.key, e);
|
|
944
|
+
}) : Dt(t, "default", n.key);
|
|
945
|
+
let n = St(t), r = n.findIndex((e) => e.has("default"));
|
|
946
946
|
return (e) => 91 + (n.findIndex((t) => t.has(e)) + r) * 10;
|
|
947
947
|
}
|
|
948
948
|
//#endregion
|
|
949
949
|
//#region src/schema/schema.ts
|
|
950
|
-
function
|
|
950
|
+
function kt(e) {
|
|
951
951
|
return e && Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0));
|
|
952
952
|
}
|
|
953
|
-
var
|
|
953
|
+
var At = class {
|
|
954
954
|
BlockNoteEditor = "only for types";
|
|
955
955
|
Block = "only for types";
|
|
956
956
|
PartialBlock = "only for types";
|
|
@@ -966,14 +966,14 @@ var Tt = class {
|
|
|
966
966
|
this.blockSpecs = t, this.styleSpecs = r, this.styleSchema = o, this.inlineContentSpecs = n, this.blockSchema = i, this.inlineContentSchema = a;
|
|
967
967
|
}
|
|
968
968
|
init() {
|
|
969
|
-
let e =
|
|
969
|
+
let e = Ot(Object.entries({
|
|
970
970
|
...this.opts.blockSpecs,
|
|
971
971
|
...this.opts.inlineContentSpecs,
|
|
972
972
|
...this.opts.styleSpecs
|
|
973
973
|
}).map(([e, t]) => ({
|
|
974
974
|
key: e,
|
|
975
975
|
runsBefore: t.implementation?.runsBefore ?? []
|
|
976
|
-
}))), t = Object.fromEntries(Object.entries(this.opts.blockSpecs).map(([t, n]) => [t,
|
|
976
|
+
}))), t = Object.fromEntries(Object.entries(this.opts.blockSpecs).map(([t, n]) => [t, Ze(n.config, n.implementation, n.extensions, e(t))])), n = Object.fromEntries(Object.entries(this.opts.inlineContentSpecs).map(([t, n]) => typeof n.config == "object" ? [t, {
|
|
977
977
|
...n,
|
|
978
978
|
implementation: {
|
|
979
979
|
...n.implementation,
|
|
@@ -989,10 +989,10 @@ var Tt = class {
|
|
|
989
989
|
return {
|
|
990
990
|
blockSpecs: t,
|
|
991
991
|
blockSchema: Object.fromEntries(Object.entries(t).map(([e, t]) => [e, t.config])),
|
|
992
|
-
inlineContentSpecs:
|
|
993
|
-
styleSpecs:
|
|
994
|
-
inlineContentSchema:
|
|
995
|
-
styleSchema:
|
|
992
|
+
inlineContentSpecs: kt(n),
|
|
993
|
+
styleSpecs: kt(r),
|
|
994
|
+
inlineContentSchema: ht(n),
|
|
995
|
+
styleSchema: vt(r)
|
|
996
996
|
};
|
|
997
997
|
}
|
|
998
998
|
extend(e) {
|
|
@@ -1003,8 +1003,8 @@ var Tt = class {
|
|
|
1003
1003
|
};
|
|
1004
1004
|
//#endregion
|
|
1005
1005
|
//#region src/api/blockManipulation/tables/tables.ts
|
|
1006
|
-
function
|
|
1007
|
-
let { height: t, width: n } =
|
|
1006
|
+
function B(e) {
|
|
1007
|
+
let { height: t, width: n } = jt(e), r = Array(t).fill(!1).map(() => Array(n).fill(null)), i = (e, i) => {
|
|
1008
1008
|
for (let a = e; a < t; a++) for (let e = i; e < n; e++) if (!r[a][e]) return {
|
|
1009
1009
|
row: a,
|
|
1010
1010
|
col: e
|
|
@@ -1012,7 +1012,7 @@ function z(e) {
|
|
|
1012
1012
|
throw Error("Unable to create occupancy grid for table, no more available cells");
|
|
1013
1013
|
};
|
|
1014
1014
|
for (let t = 0; t < e.content.rows.length; t++) for (let n = 0; n < e.content.rows[t].cells.length; n++) {
|
|
1015
|
-
let a =
|
|
1015
|
+
let a = x(e.content.rows[t].cells[n]), o = Le(a), s = w(a), { row: c, col: l } = i(t, n);
|
|
1016
1016
|
for (let e = c; e < c + o; e++) for (let i = l; i < l + s; i++) {
|
|
1017
1017
|
if (r[e][i]) throw Error(`Unable to create occupancy grid for table, cell at ${e},${i} is already occupied`);
|
|
1018
1018
|
r[e][i] = {
|
|
@@ -1026,11 +1026,11 @@ function z(e) {
|
|
|
1026
1026
|
}
|
|
1027
1027
|
return r;
|
|
1028
1028
|
}
|
|
1029
|
-
function
|
|
1029
|
+
function V(e) {
|
|
1030
1030
|
let t = /* @__PURE__ */ new Set();
|
|
1031
1031
|
return e.map((e) => ({ cells: e.map((e) => t.has(e.row + ":" + e.col) ? !1 : (t.add(e.row + ":" + e.col), e.cell)).filter((e) => e !== !1) }));
|
|
1032
1032
|
}
|
|
1033
|
-
function
|
|
1033
|
+
function H(e, t, n = B(t)) {
|
|
1034
1034
|
for (let t = 0; t < n.length; t++) for (let r = 0; r < n[t].length; r++) {
|
|
1035
1035
|
let i = n[t][r];
|
|
1036
1036
|
if (i && i.row === e.row && i.col === e.col) return {
|
|
@@ -1041,19 +1041,19 @@ function V(e, t, n = z(t)) {
|
|
|
1041
1041
|
}
|
|
1042
1042
|
throw Error(`Unable to resolve relative table cell indices for table, cell at ${e.row},${e.col} is not occupied`);
|
|
1043
1043
|
}
|
|
1044
|
-
function
|
|
1044
|
+
function jt(e) {
|
|
1045
1045
|
let t = e.content.rows.length, n = 0;
|
|
1046
1046
|
return e.content.rows.forEach((e) => {
|
|
1047
1047
|
let t = 0;
|
|
1048
1048
|
e.cells.forEach((e) => {
|
|
1049
|
-
t +=
|
|
1049
|
+
t += w(e);
|
|
1050
1050
|
}), n = Math.max(n, t);
|
|
1051
1051
|
}), {
|
|
1052
1052
|
height: t,
|
|
1053
1053
|
width: n
|
|
1054
1054
|
};
|
|
1055
1055
|
}
|
|
1056
|
-
function
|
|
1056
|
+
function Mt(e, t, n = B(t)) {
|
|
1057
1057
|
let r = n[e.row]?.[e.col];
|
|
1058
1058
|
if (r) return {
|
|
1059
1059
|
row: r.row,
|
|
@@ -1061,8 +1061,8 @@ function Dt(e, t, n = z(t)) {
|
|
|
1061
1061
|
cell: r.cell
|
|
1062
1062
|
};
|
|
1063
1063
|
}
|
|
1064
|
-
function
|
|
1065
|
-
let n =
|
|
1064
|
+
function Nt(e, t) {
|
|
1065
|
+
let n = B(e);
|
|
1066
1066
|
if (t < 0 || t >= n.length) return [];
|
|
1067
1067
|
let r = 0;
|
|
1068
1068
|
for (let e = 0; e < t; e++) {
|
|
@@ -1070,14 +1070,14 @@ function Ot(e, t) {
|
|
|
1070
1070
|
if (!e) return [];
|
|
1071
1071
|
r += e.rowspan;
|
|
1072
1072
|
}
|
|
1073
|
-
let i = Array(n[0].length).fill(!1).map((t, i) =>
|
|
1073
|
+
let i = Array(n[0].length).fill(!1).map((t, i) => Mt({
|
|
1074
1074
|
row: r,
|
|
1075
1075
|
col: i
|
|
1076
1076
|
}, e, n)).filter((e) => e !== void 0);
|
|
1077
1077
|
return i.filter((e, t) => i.findIndex((t) => t.row === e.row && t.col === e.col) === t);
|
|
1078
1078
|
}
|
|
1079
|
-
function
|
|
1080
|
-
let n =
|
|
1079
|
+
function Pt(e, t) {
|
|
1080
|
+
let n = B(e);
|
|
1081
1081
|
if (t < 0 || t >= n[0].length) return [];
|
|
1082
1082
|
let r = 0;
|
|
1083
1083
|
for (let e = 0; e < t; e++) {
|
|
@@ -1085,62 +1085,62 @@ function kt(e, t) {
|
|
|
1085
1085
|
if (!e) return [];
|
|
1086
1086
|
r += e.colspan;
|
|
1087
1087
|
}
|
|
1088
|
-
let i = Array(n.length).fill(!1).map((t, i) =>
|
|
1088
|
+
let i = Array(n.length).fill(!1).map((t, i) => Mt({
|
|
1089
1089
|
row: i,
|
|
1090
1090
|
col: r
|
|
1091
1091
|
}, e, n)).filter((e) => e !== void 0);
|
|
1092
1092
|
return i.filter((e, t) => i.findIndex((t) => t.row === e.row && t.col === e.col) === t);
|
|
1093
1093
|
}
|
|
1094
|
-
function
|
|
1095
|
-
let { col: i } =
|
|
1094
|
+
function Ft(e, t, n, r = B(e)) {
|
|
1095
|
+
let { col: i } = H({
|
|
1096
1096
|
row: 0,
|
|
1097
1097
|
col: t
|
|
1098
|
-
}, e, r), { col: a } =
|
|
1098
|
+
}, e, r), { col: a } = H({
|
|
1099
1099
|
row: 0,
|
|
1100
1100
|
col: n
|
|
1101
1101
|
}, e, r);
|
|
1102
1102
|
return r.forEach((e) => {
|
|
1103
1103
|
let [t] = e.splice(i, 1);
|
|
1104
1104
|
e.splice(a, 0, t);
|
|
1105
|
-
}),
|
|
1105
|
+
}), V(r);
|
|
1106
1106
|
}
|
|
1107
|
-
function
|
|
1108
|
-
let { row: i } =
|
|
1107
|
+
function It(e, t, n, r = B(e)) {
|
|
1108
|
+
let { row: i } = H({
|
|
1109
1109
|
row: t,
|
|
1110
1110
|
col: 0
|
|
1111
|
-
}, e, r), { row: a } =
|
|
1111
|
+
}, e, r), { row: a } = H({
|
|
1112
1112
|
row: n,
|
|
1113
1113
|
col: 0
|
|
1114
1114
|
}, e, r), [o] = r.splice(i, 1);
|
|
1115
|
-
return r.splice(a, 0, o),
|
|
1115
|
+
return r.splice(a, 0, o), V(r);
|
|
1116
1116
|
}
|
|
1117
|
-
function
|
|
1118
|
-
return e ?
|
|
1117
|
+
function Lt(e) {
|
|
1118
|
+
return e ? S(e) ? Lt(e.content) : typeof e == "string" ? e.length === 0 : Array.isArray(e) ? e.every((e) => typeof e == "string" ? e.length === 0 : b(e) ? e.text.length === 0 : Ie(e) ? typeof e.content == "string" ? e.content.length === 0 : e.content.every((e) => e.text.length === 0) : !1) : !1 : !0;
|
|
1119
1119
|
}
|
|
1120
|
-
function
|
|
1120
|
+
function Rt(e, t, n = B(e)) {
|
|
1121
1121
|
if (t === "columns") {
|
|
1122
1122
|
let e = 0;
|
|
1123
|
-
for (let t = n[0].length - 1; t >= 0 && n.every((e) =>
|
|
1123
|
+
for (let t = n[0].length - 1; t >= 0 && n.every((e) => Lt(e[t].cell) && e[t].colspan === 1); t--) e++;
|
|
1124
1124
|
for (let t = n.length - 1; t >= 0; t--) {
|
|
1125
1125
|
let r = Math.max(n[t].length - e, 1);
|
|
1126
1126
|
n[t] = n[t].slice(0, r);
|
|
1127
1127
|
}
|
|
1128
|
-
return
|
|
1128
|
+
return V(n);
|
|
1129
1129
|
}
|
|
1130
1130
|
let r = 0;
|
|
1131
|
-
for (let e = n.length - 1; e >= 0 && n[e].every((e) =>
|
|
1131
|
+
for (let e = n.length - 1; e >= 0 && n[e].every((e) => Lt(e.cell) && e.rowspan === 1); e--) r++;
|
|
1132
1132
|
let i = Math.min(r, n.length - 1);
|
|
1133
|
-
return n.splice(n.length - i, i),
|
|
1133
|
+
return n.splice(n.length - i, i), V(n);
|
|
1134
1134
|
}
|
|
1135
|
-
function
|
|
1136
|
-
let { width: i, height: a } =
|
|
1135
|
+
function zt(e, t, n, r = B(e)) {
|
|
1136
|
+
let { width: i, height: a } = jt(e);
|
|
1137
1137
|
if (t === "columns") r.forEach((e, t) => {
|
|
1138
1138
|
if (n >= 0) for (let r = 0; r < n; r++) e.push({
|
|
1139
1139
|
row: t,
|
|
1140
1140
|
col: Math.max(...e.map((e) => e.col)) + 1,
|
|
1141
1141
|
rowspan: 1,
|
|
1142
1142
|
colspan: 1,
|
|
1143
|
-
cell:
|
|
1143
|
+
cell: x("")
|
|
1144
1144
|
});
|
|
1145
1145
|
else e.splice(i + n, -1 * n);
|
|
1146
1146
|
});
|
|
@@ -1150,77 +1150,77 @@ function Pt(e, t, n, r = z(e)) {
|
|
|
1150
1150
|
col: n,
|
|
1151
1151
|
rowspan: 1,
|
|
1152
1152
|
colspan: 1,
|
|
1153
|
-
cell:
|
|
1153
|
+
cell: x("")
|
|
1154
1154
|
}));
|
|
1155
1155
|
r.push(t);
|
|
1156
1156
|
}
|
|
1157
1157
|
else n < 0 && r.splice(a + n, -1 * n);
|
|
1158
|
-
return
|
|
1158
|
+
return V(r);
|
|
1159
1159
|
}
|
|
1160
|
-
function
|
|
1161
|
-
let r =
|
|
1162
|
-
if (!r.some((e) =>
|
|
1160
|
+
function Bt(e, t, n) {
|
|
1161
|
+
let r = Nt(e, n);
|
|
1162
|
+
if (!r.some((e) => Le(e.cell) > 1)) return !0;
|
|
1163
1163
|
let i = n, a = n;
|
|
1164
1164
|
return r.forEach((e) => {
|
|
1165
|
-
let t =
|
|
1165
|
+
let t = Le(e.cell);
|
|
1166
1166
|
i = Math.max(i, e.row + t - 1), a = Math.min(a, e.row);
|
|
1167
1167
|
}), t < n ? n === i : n === a;
|
|
1168
1168
|
}
|
|
1169
|
-
function
|
|
1170
|
-
let r =
|
|
1171
|
-
if (!r.some((e) =>
|
|
1169
|
+
function Vt(e, t, n) {
|
|
1170
|
+
let r = Pt(e, n);
|
|
1171
|
+
if (!r.some((e) => w(e.cell) > 1)) return !0;
|
|
1172
1172
|
let i = n, a = n;
|
|
1173
1173
|
return r.forEach((e) => {
|
|
1174
|
-
let t =
|
|
1174
|
+
let t = w(e.cell);
|
|
1175
1175
|
i = Math.max(i, e.col + t - 1), a = Math.min(a, e.col);
|
|
1176
1176
|
}), t < n ? n === i : n === a;
|
|
1177
1177
|
}
|
|
1178
|
-
function
|
|
1179
|
-
let r =
|
|
1178
|
+
function Ht(e, t, n) {
|
|
1179
|
+
let r = H(e, n), i = H(t, n);
|
|
1180
1180
|
return r.col === i.col;
|
|
1181
1181
|
}
|
|
1182
1182
|
//#endregion
|
|
1183
1183
|
//#region src/api/nodeConversions/blockToNode.ts
|
|
1184
|
-
function
|
|
1184
|
+
function Ut(e, t, n, r) {
|
|
1185
1185
|
let i = [];
|
|
1186
1186
|
for (let [r, a] of Object.entries(e.styles || {})) {
|
|
1187
1187
|
let e = n[r];
|
|
1188
1188
|
if (!e) throw Error(`style ${r} not found in styleSchema`);
|
|
1189
1189
|
if (e.propSchema === "boolean") a && i.push(t.mark(r));
|
|
1190
1190
|
else if (e.propSchema === "string") a && i.push(t.mark(r, { stringValue: a }));
|
|
1191
|
-
else throw new
|
|
1191
|
+
else throw new T(e.propSchema);
|
|
1192
1192
|
}
|
|
1193
1193
|
return !r || !t.nodes[r].spec.code ? e.text.split(/(\n)/g).filter((e) => e.length > 0).map((e) => e === "\n" ? t.nodes.hardBreak.createChecked() : t.text(e, i)) : e.text.length > 0 ? [t.text(e.text, i)] : [];
|
|
1194
1194
|
}
|
|
1195
|
-
function
|
|
1195
|
+
function Wt(e, t, n) {
|
|
1196
1196
|
let r = t.marks.link.create({ href: e.href });
|
|
1197
|
-
return
|
|
1197
|
+
return Gt(e.content, t, n).map((e) => {
|
|
1198
1198
|
if (e.type.name === "text") return e.mark([...e.marks, r]);
|
|
1199
1199
|
if (e.type.name === "hardBreak") return e;
|
|
1200
1200
|
throw Error("unexpected node type");
|
|
1201
1201
|
});
|
|
1202
1202
|
}
|
|
1203
|
-
function
|
|
1203
|
+
function Gt(e, t, n, r) {
|
|
1204
1204
|
let i = [];
|
|
1205
|
-
if (typeof e == "string") return i.push(...
|
|
1205
|
+
if (typeof e == "string") return i.push(...Ut({
|
|
1206
1206
|
type: "text",
|
|
1207
1207
|
text: e,
|
|
1208
1208
|
styles: {}
|
|
1209
1209
|
}, t, n, r)), i;
|
|
1210
|
-
for (let a of e) i.push(...
|
|
1210
|
+
for (let a of e) i.push(...Ut(a, t, n, r));
|
|
1211
1211
|
return i;
|
|
1212
1212
|
}
|
|
1213
|
-
function
|
|
1213
|
+
function U(e, t, n, r = F(t)) {
|
|
1214
1214
|
let i = [];
|
|
1215
|
-
for (let a of e) typeof a == "string" ? i.push(...
|
|
1215
|
+
for (let a of e) typeof a == "string" ? i.push(...Gt(a, t, r, n)) : Ie(a) ? i.push(...Wt(a, t, r)) : b(a) ? i.push(...Gt([a], t, r, n)) : i.push(qt(a, t, r));
|
|
1216
1216
|
return i;
|
|
1217
1217
|
}
|
|
1218
|
-
function
|
|
1218
|
+
function Kt(e, t, n = F(t)) {
|
|
1219
1219
|
let r = [], i = Array(e.headerRows ?? 0).fill(!0), a = Array(e.headerCols ?? 0).fill(!0), o = e.columnWidths ?? [];
|
|
1220
1220
|
for (let s = 0; s < e.rows.length; s++) {
|
|
1221
1221
|
let c = e.rows[s], l = [], u = i[s];
|
|
1222
1222
|
for (let r = 0; r < c.cells.length; r++) {
|
|
1223
|
-
let i = c.cells[r], d = a[r], f = null, p =
|
|
1223
|
+
let i = c.cells[r], d = a[r], f = null, p = H({
|
|
1224
1224
|
row: s,
|
|
1225
1225
|
col: r
|
|
1226
1226
|
}, {
|
|
@@ -1228,13 +1228,13 @@ function Vt(e, t, n = P(t)) {
|
|
|
1228
1228
|
content: e
|
|
1229
1229
|
}), m = o[p.col] ? [o[p.col]] : null;
|
|
1230
1230
|
if (i) if (typeof i == "string") f = t.text(i);
|
|
1231
|
-
else if (
|
|
1232
|
-
i.content && (f =
|
|
1233
|
-
let e =
|
|
1231
|
+
else if (S(i)) {
|
|
1232
|
+
i.content && (f = U(i.content, t, "tableParagraph", n));
|
|
1233
|
+
let e = w(i);
|
|
1234
1234
|
e > 1 && (m = Array(e).fill(!1).map((e, t) => o[p.col + t] ?? void 0));
|
|
1235
|
-
} else f =
|
|
1235
|
+
} else f = U(i, t, "tableParagraph", n);
|
|
1236
1236
|
let h = t.nodes[d || u ? "tableHeader" : "tableCell"].createChecked({
|
|
1237
|
-
...
|
|
1237
|
+
...S(i) ? i.props : {},
|
|
1238
1238
|
colwidth: m
|
|
1239
1239
|
}, t.nodes.tableParagraph.createChecked(void 0, f));
|
|
1240
1240
|
l.push(h);
|
|
@@ -1244,29 +1244,29 @@ function Vt(e, t, n = P(t)) {
|
|
|
1244
1244
|
}
|
|
1245
1245
|
return r;
|
|
1246
1246
|
}
|
|
1247
|
-
function
|
|
1247
|
+
function qt(e, t, n) {
|
|
1248
1248
|
let r, i = e.type;
|
|
1249
1249
|
if (i === void 0 && (i = "paragraph"), !t.nodes[i]) throw Error(`node type ${i} not found in schema`);
|
|
1250
1250
|
if (!e.content) r = t.nodes[i].createChecked(e.props);
|
|
1251
1251
|
else if (typeof e.content == "string") {
|
|
1252
|
-
let a =
|
|
1252
|
+
let a = U([e.content], t, i, n);
|
|
1253
1253
|
r = t.nodes[i].createChecked(e.props, a);
|
|
1254
1254
|
} else if (Array.isArray(e.content)) {
|
|
1255
|
-
let a =
|
|
1255
|
+
let a = U(e.content, t, i, n);
|
|
1256
1256
|
r = t.nodes[i].createChecked(e.props, a);
|
|
1257
1257
|
} else if (e.content.type === "tableContent") {
|
|
1258
|
-
let a =
|
|
1258
|
+
let a = Kt(e.content, t, n);
|
|
1259
1259
|
r = t.nodes[i].createChecked(e.props, a);
|
|
1260
|
-
} else throw new
|
|
1260
|
+
} else throw new T(e.content.type);
|
|
1261
1261
|
return r;
|
|
1262
1262
|
}
|
|
1263
|
-
function
|
|
1263
|
+
function W(e, t, n = F(t)) {
|
|
1264
1264
|
let r = e.id;
|
|
1265
|
-
r === void 0 && (r =
|
|
1265
|
+
r === void 0 && (r = Pe.options.generateID());
|
|
1266
1266
|
let i = [];
|
|
1267
|
-
if (e.children) for (let r of e.children) i.push(
|
|
1267
|
+
if (e.children) for (let r of e.children) i.push(W(r, t, n));
|
|
1268
1268
|
if (!e.type || t.nodes[e.type].isInGroup("blockContent")) {
|
|
1269
|
-
let a =
|
|
1269
|
+
let a = qt(e, t, n), o = i.length > 0 ? t.nodes.blockGroup.createChecked({}, i) : void 0;
|
|
1270
1270
|
return t.nodes.blockContainer.createChecked({
|
|
1271
1271
|
id: r,
|
|
1272
1272
|
...e.props
|
|
@@ -1279,32 +1279,32 @@ function U(e, t, n = P(t)) {
|
|
|
1279
1279
|
}
|
|
1280
1280
|
//#endregion
|
|
1281
1281
|
//#region src/api/nodeUtil.ts
|
|
1282
|
-
function
|
|
1282
|
+
function Jt(e, t) {
|
|
1283
1283
|
let n, r;
|
|
1284
|
-
if (t.firstChild.descendants((t, i) => n ? !1 : !
|
|
1284
|
+
if (t.firstChild.descendants((t, i) => n ? !1 : !Yt(t) || t.attrs.id !== e ? !0 : (n = t, r = i + 1, !1)), !(n === void 0 || r === void 0)) return {
|
|
1285
1285
|
node: n,
|
|
1286
1286
|
posBeforeNode: r
|
|
1287
1287
|
};
|
|
1288
1288
|
}
|
|
1289
|
-
function
|
|
1289
|
+
function Yt(e) {
|
|
1290
1290
|
return e.type.isInGroup("bnBlock");
|
|
1291
1291
|
}
|
|
1292
1292
|
//#endregion
|
|
1293
1293
|
//#region src/api/blockManipulation/commands/updateBlock/updateBlock.ts
|
|
1294
|
-
var
|
|
1295
|
-
function
|
|
1296
|
-
let a =
|
|
1297
|
-
a.blockNoteType === "table" && (o =
|
|
1298
|
-
let s =
|
|
1294
|
+
var Xt = (e, t) => ({ tr: n, dispatch: r }) => (r && G(n, e, t), !0);
|
|
1295
|
+
function G(e, t, n, r, i) {
|
|
1296
|
+
let a = $e(e.doc.resolve(t)), o = null;
|
|
1297
|
+
a.blockNoteType === "table" && (o = en(e));
|
|
1298
|
+
let s = P(e);
|
|
1299
1299
|
if (r !== void 0 && i !== void 0 && r > i) throw Error("Invalid replaceFromPos or replaceToPos");
|
|
1300
1300
|
let c = s.nodes[a.blockNoteType], l = s.nodes[n.type || a.blockNoteType], u = l.isInGroup("bnBlock") ? l : s.nodes.blockContainer;
|
|
1301
1301
|
if (a.isBlockContainer && l.isInGroup("blockContent")) {
|
|
1302
1302
|
let t = r !== void 0 && r > a.blockContent.beforePos && r < a.blockContent.afterPos ? r - a.blockContent.beforePos - 1 : void 0, o = i !== void 0 && i > a.blockContent.beforePos && i < a.blockContent.afterPos ? i - a.blockContent.beforePos - 1 : void 0;
|
|
1303
|
-
|
|
1304
|
-
} else if (!a.isBlockContainer && l.isInGroup("bnBlock"))
|
|
1303
|
+
Qt(n, e, a), Zt(n, e, c, l, a, t, o);
|
|
1304
|
+
} else if (!a.isBlockContainer && l.isInGroup("bnBlock")) Qt(n, e, a);
|
|
1305
1305
|
else {
|
|
1306
|
-
let t =
|
|
1307
|
-
e.replaceWith(a.bnBlock.beforePos, a.bnBlock.afterPos,
|
|
1306
|
+
let t = L(a.bnBlock.node, s);
|
|
1307
|
+
e.replaceWith(a.bnBlock.beforePos, a.bnBlock.afterPos, W({
|
|
1308
1308
|
children: t.children,
|
|
1309
1309
|
...n
|
|
1310
1310
|
}, s));
|
|
@@ -1313,14 +1313,14 @@ function W(e, t, n, r, i) {
|
|
|
1313
1313
|
e.setNodeMarkup(a.bnBlock.beforePos, u, {
|
|
1314
1314
|
...a.bnBlock.node.attrs,
|
|
1315
1315
|
...n.props
|
|
1316
|
-
}), o &&
|
|
1317
|
-
}
|
|
1318
|
-
function
|
|
1319
|
-
let l =
|
|
1320
|
-
if (e.content) if (typeof e.content == "string") u =
|
|
1321
|
-
else if (Array.isArray(e.content)) u =
|
|
1322
|
-
else if (e.content.type === "tableContent") u =
|
|
1323
|
-
else throw new
|
|
1316
|
+
}), o && tn(e, a, o);
|
|
1317
|
+
}
|
|
1318
|
+
function Zt(e, t, n, a, o, s, c) {
|
|
1319
|
+
let l = P(t), u = "keep";
|
|
1320
|
+
if (e.content) if (typeof e.content == "string") u = U([e.content], l, a.name);
|
|
1321
|
+
else if (Array.isArray(e.content)) u = U(e.content, l, a.name);
|
|
1322
|
+
else if (e.content.type === "tableContent") u = Kt(e.content, l);
|
|
1323
|
+
else throw new T(e.content.type);
|
|
1324
1324
|
else n.spec.content === "" || a.spec.content !== n.spec.content && (u = []);
|
|
1325
1325
|
if (u === "keep") t.setNodeMarkup(o.blockContent.beforePos, a, {
|
|
1326
1326
|
...o.blockContent.node.attrs,
|
|
@@ -1338,10 +1338,10 @@ function Kt(e, t, n, a, o, s, c) {
|
|
|
1338
1338
|
...e.props
|
|
1339
1339
|
}, u));
|
|
1340
1340
|
}
|
|
1341
|
-
function
|
|
1342
|
-
let a =
|
|
1341
|
+
function Qt(e, t, n) {
|
|
1342
|
+
let a = P(t);
|
|
1343
1343
|
if (e.children !== void 0 && e.children.length > 0) {
|
|
1344
|
-
let s = e.children.map((e) =>
|
|
1344
|
+
let s = e.children.map((e) => W(e, a));
|
|
1345
1345
|
if (n.childContainer) t.step(new o(n.childContainer.beforePos + 1, n.childContainer.afterPos - 1, new i(r.from(s), 0, 0)));
|
|
1346
1346
|
else {
|
|
1347
1347
|
if (!n.isBlockContainer) throw Error("impossible");
|
|
@@ -1349,14 +1349,14 @@ function qt(e, t, n) {
|
|
|
1349
1349
|
}
|
|
1350
1350
|
}
|
|
1351
1351
|
}
|
|
1352
|
-
function
|
|
1353
|
-
let a = typeof t == "string" ? t : t.id, o =
|
|
1352
|
+
function $t(e, t, n, r, i) {
|
|
1353
|
+
let a = typeof t == "string" ? t : t.id, o = Jt(a, e.doc);
|
|
1354
1354
|
if (!o) throw Error(`Block with ID ${a} not found`);
|
|
1355
|
-
return
|
|
1355
|
+
return G(e, o.posBeforeNode, n, r, i), L(e.doc.resolve(o.posBeforeNode + 1).node(), P(e));
|
|
1356
1356
|
}
|
|
1357
|
-
function
|
|
1357
|
+
function en(e) {
|
|
1358
1358
|
let t = "selection" in e ? e.selection : null;
|
|
1359
|
-
if (!(t instanceof
|
|
1359
|
+
if (!(t instanceof te)) return null;
|
|
1360
1360
|
let n = e.doc.resolve(t.head), r = -1, i = -1;
|
|
1361
1361
|
for (let e = n.depth; e >= 0; e--) {
|
|
1362
1362
|
let t = n.node(e).type.name;
|
|
@@ -1368,7 +1368,7 @@ function Yt(e) {
|
|
|
1368
1368
|
if (r < 0 || i < 0) return null;
|
|
1369
1369
|
let a = n.before(r), o = n.before(i), s = e.doc.nodeAt(o);
|
|
1370
1370
|
if (!s || s.type.name !== "table") return null;
|
|
1371
|
-
let c =
|
|
1371
|
+
let c = se.get(s), l = a - (o + 1), u = c.map.indexOf(l);
|
|
1372
1372
|
if (u < 0) return null;
|
|
1373
1373
|
let d = Math.floor(u / c.width), f = u % c.width, p = a + 1 + 1;
|
|
1374
1374
|
return {
|
|
@@ -1377,7 +1377,7 @@ function Yt(e) {
|
|
|
1377
1377
|
offset: Math.max(0, t.head - p)
|
|
1378
1378
|
};
|
|
1379
1379
|
}
|
|
1380
|
-
function
|
|
1380
|
+
function tn(e, t, n) {
|
|
1381
1381
|
if (t.blockNoteType !== "table") return !1;
|
|
1382
1382
|
let r = -1;
|
|
1383
1383
|
if (t.isBlockContainer) r = e.mapping.map(t.blockContent.beforePos);
|
|
@@ -1387,14 +1387,14 @@ function Xt(e, t, n) {
|
|
|
1387
1387
|
}
|
|
1388
1388
|
let i = r >= 0 ? e.doc.nodeAt(r) : null;
|
|
1389
1389
|
if (!i || i.type.name !== "table") return !1;
|
|
1390
|
-
let a =
|
|
1390
|
+
let a = se.get(i), o = Math.max(0, Math.min(n.row, a.height - 1)), s = Math.max(0, Math.min(n.col, a.width - 1)), c = o * a.width + s, l = a.map[c];
|
|
1391
1391
|
if (l == null) return !1;
|
|
1392
1392
|
let u = r + 1 + l + 1, d = e.doc.nodeAt(u), f = u + 1, p = d ? d.content.size : 0, m = f + Math.max(0, Math.min(n.offset, p));
|
|
1393
|
-
return "selection" in e && e.setSelection(
|
|
1393
|
+
return "selection" in e && e.setSelection(te.create(e.doc, m)), !0;
|
|
1394
1394
|
}
|
|
1395
1395
|
//#endregion
|
|
1396
1396
|
//#region src/editor/defaultColors.ts
|
|
1397
|
-
var
|
|
1397
|
+
var K = {
|
|
1398
1398
|
gray: {
|
|
1399
1399
|
text: "#9b9a97",
|
|
1400
1400
|
background: "#ebeced"
|
|
@@ -1431,7 +1431,7 @@ var G = {
|
|
|
1431
1431
|
text: "#ad1a72",
|
|
1432
1432
|
background: "#f4dfeb"
|
|
1433
1433
|
}
|
|
1434
|
-
},
|
|
1434
|
+
}, nn = {
|
|
1435
1435
|
gray: {
|
|
1436
1436
|
text: "#bebdb8",
|
|
1437
1437
|
background: "#9b9a97"
|
|
@@ -1468,7 +1468,7 @@ var G = {
|
|
|
1468
1468
|
text: "#da208f",
|
|
1469
1469
|
background: "#ad1a72"
|
|
1470
1470
|
}
|
|
1471
|
-
},
|
|
1471
|
+
}, q = {
|
|
1472
1472
|
backgroundColor: { default: "default" },
|
|
1473
1473
|
textColor: { default: "default" },
|
|
1474
1474
|
textAlignment: {
|
|
@@ -1480,30 +1480,30 @@ var G = {
|
|
|
1480
1480
|
"justify"
|
|
1481
1481
|
]
|
|
1482
1482
|
}
|
|
1483
|
-
},
|
|
1483
|
+
}, J = (e) => {
|
|
1484
1484
|
let t = {};
|
|
1485
|
-
return e.hasAttribute("data-background-color") ? t.backgroundColor = e.getAttribute("data-background-color") : e.style.backgroundColor && (t.backgroundColor = e.style.backgroundColor), e.hasAttribute("data-text-color") ? t.textColor = e.getAttribute("data-text-color") : e.style.color && (t.textColor = e.style.color), t.textAlignment =
|
|
1486
|
-
},
|
|
1487
|
-
e.backgroundColor && e.backgroundColor !==
|
|
1488
|
-
},
|
|
1489
|
-
default:
|
|
1490
|
-
parseHTML: (e) => e.hasAttribute("data-background-color") ? e.getAttribute("data-background-color") : e.style.backgroundColor ? e.style.backgroundColor :
|
|
1491
|
-
renderHTML: (t) => t[e] ===
|
|
1492
|
-
}),
|
|
1493
|
-
default:
|
|
1494
|
-
parseHTML: (e) => e.hasAttribute("data-text-color") ? e.getAttribute("data-text-color") : e.style.color ? e.style.color :
|
|
1495
|
-
renderHTML: (t) => t[e] ===
|
|
1496
|
-
}),
|
|
1497
|
-
default:
|
|
1498
|
-
parseHTML: (e) => e.hasAttribute("data-text-alignment") ? e.getAttribute("data-text-alignment") : e.style.textAlign ? e.style.textAlign :
|
|
1499
|
-
renderHTML: (t) => t[e] ===
|
|
1500
|
-
}),
|
|
1485
|
+
return e.hasAttribute("data-background-color") ? t.backgroundColor = e.getAttribute("data-background-color") : e.style.backgroundColor && (t.backgroundColor = e.style.backgroundColor), e.hasAttribute("data-text-color") ? t.textColor = e.getAttribute("data-text-color") : e.style.color && (t.textColor = e.style.color), t.textAlignment = q.textAlignment.values.includes(e.style.textAlign) ? e.style.textAlign : void 0, t;
|
|
1486
|
+
}, Y = (e, t) => {
|
|
1487
|
+
e.backgroundColor && e.backgroundColor !== q.backgroundColor.default && (t.style.backgroundColor = e.backgroundColor in K ? K[e.backgroundColor].background : e.backgroundColor), e.textColor && e.textColor !== q.textColor.default && (t.style.color = e.textColor in K ? K[e.textColor].text : e.textColor), e.textAlignment && e.textAlignment !== q.textAlignment.default && (t.style.textAlign = e.textAlignment);
|
|
1488
|
+
}, rn = (e = "backgroundColor") => ({
|
|
1489
|
+
default: q.backgroundColor.default,
|
|
1490
|
+
parseHTML: (e) => e.hasAttribute("data-background-color") ? e.getAttribute("data-background-color") : e.style.backgroundColor ? e.style.backgroundColor : q.backgroundColor.default,
|
|
1491
|
+
renderHTML: (t) => t[e] === q.backgroundColor.default ? {} : { "data-background-color": t[e] }
|
|
1492
|
+
}), an = (e = "textColor") => ({
|
|
1493
|
+
default: q.textColor.default,
|
|
1494
|
+
parseHTML: (e) => e.hasAttribute("data-text-color") ? e.getAttribute("data-text-color") : e.style.color ? e.style.color : q.textColor.default,
|
|
1495
|
+
renderHTML: (t) => t[e] === q.textColor.default ? {} : { "data-text-color": t[e] }
|
|
1496
|
+
}), on = (e = "textAlignment") => ({
|
|
1497
|
+
default: q.textAlignment.default,
|
|
1498
|
+
parseHTML: (e) => e.hasAttribute("data-text-alignment") ? e.getAttribute("data-text-alignment") : e.style.textAlign ? e.style.textAlign : q.textAlignment.default,
|
|
1499
|
+
renderHTML: (t) => t[e] === q.textAlignment.default ? {} : { "data-text-alignment": t[e] }
|
|
1500
|
+
}), sn = (e, t) => {
|
|
1501
1501
|
let n = e.querySelector(t);
|
|
1502
1502
|
if (n) return {
|
|
1503
1503
|
targetElement: n,
|
|
1504
1504
|
caption: e.querySelector("figcaption")?.textContent ?? void 0
|
|
1505
1505
|
};
|
|
1506
|
-
},
|
|
1506
|
+
}, X = t(({ editor: t }) => {
|
|
1507
1507
|
let n = e(void 0);
|
|
1508
1508
|
function r() {
|
|
1509
1509
|
n.setState(void 0);
|
|
@@ -1522,7 +1522,7 @@ var G = {
|
|
|
1522
1522
|
n.setState(e);
|
|
1523
1523
|
}
|
|
1524
1524
|
};
|
|
1525
|
-
}),
|
|
1525
|
+
}), cn = (e, t, n) => {
|
|
1526
1526
|
let r = document.createElement("div");
|
|
1527
1527
|
r.className = "bn-add-file-button";
|
|
1528
1528
|
let i = document.createElement("div");
|
|
@@ -1532,7 +1532,7 @@ var G = {
|
|
|
1532
1532
|
let o = (e) => {
|
|
1533
1533
|
e.preventDefault(), e.stopPropagation();
|
|
1534
1534
|
}, s = () => {
|
|
1535
|
-
t.isEditable && t.getExtension(
|
|
1535
|
+
t.isEditable && t.getExtension(X)?.showMenu(e.id);
|
|
1536
1536
|
};
|
|
1537
1537
|
return r.addEventListener("mousedown", o, !0), r.addEventListener("click", s, !0), {
|
|
1538
1538
|
dom: r,
|
|
@@ -1540,17 +1540,17 @@ var G = {
|
|
|
1540
1540
|
r.removeEventListener("mousedown", o, !0), r.removeEventListener("click", s, !0);
|
|
1541
1541
|
}
|
|
1542
1542
|
};
|
|
1543
|
-
},
|
|
1543
|
+
}, ln = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z\"></path></svg>", un = (e) => {
|
|
1544
1544
|
let t = document.createElement("div");
|
|
1545
1545
|
t.className = "bn-file-name-with-icon";
|
|
1546
1546
|
let n = document.createElement("div");
|
|
1547
|
-
n.className = "bn-file-icon", n.innerHTML =
|
|
1547
|
+
n.className = "bn-file-icon", n.innerHTML = ln, t.appendChild(n);
|
|
1548
1548
|
let r = document.createElement("p");
|
|
1549
1549
|
return r.className = "bn-file-name", r.textContent = e.props.name, t.appendChild(r), { dom: t };
|
|
1550
|
-
},
|
|
1550
|
+
}, dn = (e, t, n, r) => {
|
|
1551
1551
|
let i = document.createElement("div");
|
|
1552
1552
|
if (i.className = "bn-file-block-content-wrapper", e.props.url === "") {
|
|
1553
|
-
let n =
|
|
1553
|
+
let n = cn(e, t, r);
|
|
1554
1554
|
i.appendChild(n.dom);
|
|
1555
1555
|
let a = t.onUploadStart((t) => {
|
|
1556
1556
|
if (t === e.id) {
|
|
@@ -1568,7 +1568,7 @@ var G = {
|
|
|
1568
1568
|
}
|
|
1569
1569
|
let a = { dom: i };
|
|
1570
1570
|
if (e.props.showPreview === !1 || !n) {
|
|
1571
|
-
let t =
|
|
1571
|
+
let t = un(e);
|
|
1572
1572
|
i.appendChild(t.dom), a.destroy = () => {
|
|
1573
1573
|
t.destroy?.();
|
|
1574
1574
|
};
|
|
@@ -1578,72 +1578,72 @@ var G = {
|
|
|
1578
1578
|
t.className = "bn-file-caption", t.textContent = e.props.caption, i.appendChild(t);
|
|
1579
1579
|
}
|
|
1580
1580
|
return a;
|
|
1581
|
-
},
|
|
1581
|
+
}, fn = (e, t) => {
|
|
1582
1582
|
let n = document.createElement("figure"), r = document.createElement("figcaption");
|
|
1583
1583
|
return r.textContent = t, n.appendChild(e), n.appendChild(r), { dom: n };
|
|
1584
|
-
},
|
|
1584
|
+
}, pn = (e, t) => {
|
|
1585
1585
|
let n = document.createElement("div"), r = document.createElement("p");
|
|
1586
1586
|
return r.textContent = t, n.appendChild(e), n.appendChild(r), { dom: n };
|
|
1587
|
-
},
|
|
1587
|
+
}, mn = (e) => ({ url: e.src || void 0 }), hn = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z\"></path></svg>", gn = A((e) => ({
|
|
1588
1588
|
type: "audio",
|
|
1589
1589
|
propSchema: {
|
|
1590
|
-
backgroundColor:
|
|
1590
|
+
backgroundColor: q.backgroundColor,
|
|
1591
1591
|
name: { default: "" },
|
|
1592
1592
|
url: { default: "" },
|
|
1593
1593
|
caption: { default: "" },
|
|
1594
1594
|
showPreview: { default: !0 }
|
|
1595
1595
|
},
|
|
1596
1596
|
content: "none"
|
|
1597
|
-
})),
|
|
1597
|
+
})), _n = (e = {}) => (e) => {
|
|
1598
1598
|
if (e.tagName === "AUDIO") {
|
|
1599
1599
|
if (e.closest("figure")) return;
|
|
1600
|
-
let { backgroundColor: t } =
|
|
1600
|
+
let { backgroundColor: t } = J(e);
|
|
1601
1601
|
return {
|
|
1602
|
-
...
|
|
1602
|
+
...mn(e),
|
|
1603
1603
|
backgroundColor: t
|
|
1604
1604
|
};
|
|
1605
1605
|
}
|
|
1606
1606
|
if (e.tagName === "FIGURE") {
|
|
1607
|
-
let t =
|
|
1607
|
+
let t = sn(e, "audio");
|
|
1608
1608
|
if (!t) return;
|
|
1609
|
-
let { targetElement: n, caption: r } = t, { backgroundColor: i } =
|
|
1609
|
+
let { targetElement: n, caption: r } = t, { backgroundColor: i } = J(e);
|
|
1610
1610
|
return {
|
|
1611
|
-
...
|
|
1611
|
+
...mn(n),
|
|
1612
1612
|
backgroundColor: i,
|
|
1613
1613
|
caption: r
|
|
1614
1614
|
};
|
|
1615
1615
|
}
|
|
1616
|
-
},
|
|
1616
|
+
}, vn = (e = {}) => (t, n) => {
|
|
1617
1617
|
let r = document.createElement("div");
|
|
1618
1618
|
r.innerHTML = e.icon ?? "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z\"></path></svg>";
|
|
1619
1619
|
let i = document.createElement("audio");
|
|
1620
1620
|
return i.className = "bn-audio", n.resolveFileUrl ? n.resolveFileUrl(t.props.url).then((e) => {
|
|
1621
1621
|
i.src = e;
|
|
1622
|
-
}) : i.src = t.props.url, i.controls = !0, i.contentEditable = "false", i.draggable = !1,
|
|
1623
|
-
},
|
|
1622
|
+
}) : i.src = t.props.url, i.controls = !0, i.contentEditable = "false", i.draggable = !1, dn(t, n, { dom: i }, r.firstElementChild);
|
|
1623
|
+
}, yn = (e = {}) => (e, t) => {
|
|
1624
1624
|
if (!e.props.url) {
|
|
1625
1625
|
let e = document.createElement("p");
|
|
1626
1626
|
return e.textContent = "Add audio", { dom: e };
|
|
1627
1627
|
}
|
|
1628
1628
|
let n;
|
|
1629
|
-
return e.props.showPreview ? (n = document.createElement("audio"), n.src = e.props.url) : (n = document.createElement("a"), n.href = e.props.url, n.textContent = e.props.name || e.props.url), e.props.caption ? e.props.showPreview ?
|
|
1630
|
-
},
|
|
1629
|
+
return e.props.showPreview ? (n = document.createElement("audio"), n.src = e.props.url) : (n = document.createElement("a"), n.href = e.props.url, n.textContent = e.props.name || e.props.url), e.props.caption ? e.props.showPreview ? fn(n, e.props.caption) : pn(n, e.props.caption) : { dom: n };
|
|
1630
|
+
}, bn = j(gn, (e) => ({
|
|
1631
1631
|
meta: { fileBlockAccept: ["audio/*"] },
|
|
1632
|
-
parse:
|
|
1633
|
-
render:
|
|
1634
|
-
toExternalHTML:
|
|
1632
|
+
parse: _n(e),
|
|
1633
|
+
render: vn(e),
|
|
1634
|
+
toExternalHTML: yn(e),
|
|
1635
1635
|
runsBefore: ["file"]
|
|
1636
|
-
})),
|
|
1637
|
-
function
|
|
1636
|
+
})), xn = Symbol.for("blocknote.shikiParser"), Sn = Symbol.for("blocknote.shikiHighlighterPromise");
|
|
1637
|
+
function Cn(e) {
|
|
1638
1638
|
let t = globalThis, n, r, i = !1;
|
|
1639
|
-
return
|
|
1639
|
+
return ge({
|
|
1640
1640
|
parser: (a) => {
|
|
1641
1641
|
if (!e.createHighlighter) return process.env.NODE_ENV === "development" && !i && (console.log("For syntax highlighting of code blocks, you must provide a `createCodeBlockSpec({ createHighlighter: () => ... })` function"), i = !0), [];
|
|
1642
|
-
if (!n) return t[
|
|
1642
|
+
if (!n) return t[Sn] = t[Sn] || e.createHighlighter(), t[Sn].then((e) => {
|
|
1643
1643
|
n = e;
|
|
1644
1644
|
});
|
|
1645
|
-
let o =
|
|
1646
|
-
return !o || o === "text" || o === "none" || o === "plaintext" || o === "txt" ? [] : n.getLoadedLanguages().includes(o) ? (r || (r = t[
|
|
1645
|
+
let o = En(e, a.language);
|
|
1646
|
+
return !o || o === "text" || o === "none" || o === "plaintext" || o === "txt" ? [] : n.getLoadedLanguages().includes(o) ? (r || (r = t[xn] || _e(n), t[xn] = r), r(a)) : n.loadLanguage(o);
|
|
1647
1647
|
},
|
|
1648
1648
|
languageExtractor: (e) => e.attrs.language,
|
|
1649
1649
|
nodeTypes: ["codeBlock"]
|
|
@@ -1651,11 +1651,11 @@ function _n(e) {
|
|
|
1651
1651
|
}
|
|
1652
1652
|
//#endregion
|
|
1653
1653
|
//#region src/blocks/Code/block.ts
|
|
1654
|
-
var
|
|
1654
|
+
var wn = A(({ defaultLanguage: e = "text" }) => ({
|
|
1655
1655
|
type: "codeBlock",
|
|
1656
1656
|
propSchema: { language: { default: e } },
|
|
1657
1657
|
content: "inline"
|
|
1658
|
-
})),
|
|
1658
|
+
})), Tn = j(wn, (e) => ({
|
|
1659
1659
|
meta: {
|
|
1660
1660
|
code: !0,
|
|
1661
1661
|
defining: !0,
|
|
@@ -1667,7 +1667,7 @@ var vn = D(({ defaultLanguage: e = "text" }) => ({
|
|
|
1667
1667
|
return { language: t.getAttribute("data-language") || t.className.split(" ").find((e) => e.includes("language-"))?.replace("language-", "") };
|
|
1668
1668
|
},
|
|
1669
1669
|
parseContent: ({ el: e, schema: t }) => {
|
|
1670
|
-
let n =
|
|
1670
|
+
let n = re.fromSchema(t), r = e.firstElementChild;
|
|
1671
1671
|
return n.parse(r, {
|
|
1672
1672
|
preserveWhitespace: "full",
|
|
1673
1673
|
topNode: t.nodes.codeBlock.create()
|
|
@@ -1709,7 +1709,7 @@ var vn = D(({ defaultLanguage: e = "text" }) => ({
|
|
|
1709
1709
|
}
|
|
1710
1710
|
}), (e) => [t({
|
|
1711
1711
|
key: "code-block-highlighter",
|
|
1712
|
-
prosemirrorPlugins: [
|
|
1712
|
+
prosemirrorPlugins: [Cn(e)]
|
|
1713
1713
|
}), t({
|
|
1714
1714
|
key: "code-block-keyboard-shortcuts",
|
|
1715
1715
|
keyboardShortcuts: {
|
|
@@ -1747,22 +1747,22 @@ var vn = D(({ defaultLanguage: e = "text" }) => ({
|
|
|
1747
1747
|
let n = t[1].trim();
|
|
1748
1748
|
return {
|
|
1749
1749
|
type: "codeBlock",
|
|
1750
|
-
props: { language: { language:
|
|
1750
|
+
props: { language: { language: En(e, n) ?? n }.language },
|
|
1751
1751
|
content: []
|
|
1752
1752
|
};
|
|
1753
1753
|
}
|
|
1754
1754
|
}]
|
|
1755
1755
|
})]);
|
|
1756
|
-
function
|
|
1756
|
+
function En(e, t) {
|
|
1757
1757
|
return Object.entries(e.supportedLanguages ?? {}).find(([e, { aliases: n }]) => n?.includes(t) || e === t)?.[0];
|
|
1758
1758
|
}
|
|
1759
1759
|
//#endregion
|
|
1760
1760
|
//#region src/blocks/Divider/block.ts
|
|
1761
|
-
var
|
|
1761
|
+
var Dn = A(() => ({
|
|
1762
1762
|
type: "divider",
|
|
1763
1763
|
propSchema: {},
|
|
1764
1764
|
content: "none"
|
|
1765
|
-
})),
|
|
1765
|
+
})), On = j(Dn, {
|
|
1766
1766
|
meta: { isolating: !1 },
|
|
1767
1767
|
parse(e) {
|
|
1768
1768
|
if (e.tagName === "HR") return {};
|
|
@@ -1782,39 +1782,39 @@ var xn = D(() => ({
|
|
|
1782
1782
|
};
|
|
1783
1783
|
}
|
|
1784
1784
|
}]
|
|
1785
|
-
})]),
|
|
1785
|
+
})]), kn = (e) => ({ url: e.src || void 0 }), An = A(() => ({
|
|
1786
1786
|
type: "file",
|
|
1787
1787
|
propSchema: {
|
|
1788
|
-
backgroundColor:
|
|
1788
|
+
backgroundColor: q.backgroundColor,
|
|
1789
1789
|
name: { default: "" },
|
|
1790
1790
|
url: { default: "" },
|
|
1791
1791
|
caption: { default: "" }
|
|
1792
1792
|
},
|
|
1793
1793
|
content: "none"
|
|
1794
|
-
})),
|
|
1794
|
+
})), jn = () => (e) => {
|
|
1795
1795
|
if (e.tagName === "EMBED") {
|
|
1796
1796
|
if (e.closest("figure")) return;
|
|
1797
|
-
let { backgroundColor: t } =
|
|
1797
|
+
let { backgroundColor: t } = J(e);
|
|
1798
1798
|
return {
|
|
1799
|
-
...
|
|
1799
|
+
...kn(e),
|
|
1800
1800
|
backgroundColor: t
|
|
1801
1801
|
};
|
|
1802
1802
|
}
|
|
1803
1803
|
if (e.tagName === "FIGURE") {
|
|
1804
|
-
let t =
|
|
1804
|
+
let t = sn(e, "embed");
|
|
1805
1805
|
if (!t) return;
|
|
1806
|
-
let { targetElement: n, caption: r } = t, { backgroundColor: i } =
|
|
1806
|
+
let { targetElement: n, caption: r } = t, { backgroundColor: i } = J(e);
|
|
1807
1807
|
return {
|
|
1808
|
-
...
|
|
1808
|
+
...kn(n),
|
|
1809
1809
|
backgroundColor: i,
|
|
1810
1810
|
caption: r
|
|
1811
1811
|
};
|
|
1812
1812
|
}
|
|
1813
|
-
},
|
|
1813
|
+
}, Mn = j(An, {
|
|
1814
1814
|
meta: { fileBlockAccept: ["*/*"] },
|
|
1815
|
-
parse:
|
|
1815
|
+
parse: jn(),
|
|
1816
1816
|
render(e, t) {
|
|
1817
|
-
return
|
|
1817
|
+
return dn(e, t);
|
|
1818
1818
|
},
|
|
1819
1819
|
toExternalHTML(e) {
|
|
1820
1820
|
if (!e.props.url) {
|
|
@@ -1822,16 +1822,16 @@ var xn = D(() => ({
|
|
|
1822
1822
|
return e.textContent = "Add file", { dom: e };
|
|
1823
1823
|
}
|
|
1824
1824
|
let t = document.createElement("a");
|
|
1825
|
-
return t.href = e.props.url, t.textContent = e.props.name || e.props.url, e.props.caption ?
|
|
1825
|
+
return t.href = e.props.url, t.textContent = e.props.name || e.props.url, e.props.caption ? pn(t, e.props.caption) : { dom: t };
|
|
1826
1826
|
}
|
|
1827
1827
|
});
|
|
1828
1828
|
//#endregion
|
|
1829
1829
|
//#region src/blocks/getDetailsContent.ts
|
|
1830
|
-
function
|
|
1830
|
+
function Nn(e, t, i) {
|
|
1831
1831
|
let a = n.fromSchema(t), o = e.querySelector(":scope > summary"), s;
|
|
1832
1832
|
if (o) {
|
|
1833
1833
|
let e = o.cloneNode(!0);
|
|
1834
|
-
|
|
1834
|
+
Ue(e), s = a.parse(e, {
|
|
1835
1835
|
topNode: t.nodes.paragraph.create(),
|
|
1836
1836
|
preserveWhitespace: !0
|
|
1837
1837
|
}).content;
|
|
@@ -1847,10 +1847,10 @@ function Dn(e, t, i) {
|
|
|
1847
1847
|
}
|
|
1848
1848
|
//#endregion
|
|
1849
1849
|
//#region src/blocks/ToggleWrapper/createToggleWrapper.ts
|
|
1850
|
-
var
|
|
1850
|
+
var Pn = {
|
|
1851
1851
|
set: (e, t) => window.localStorage.setItem(`toggle-${e.id}`, t ? "true" : "false"),
|
|
1852
1852
|
get: (e) => window.localStorage.getItem(`toggle-${e.id}`) === "true"
|
|
1853
|
-
},
|
|
1853
|
+
}, Fn = (e, t, n, r = Pn) => {
|
|
1854
1854
|
if ("isToggleable" in e.props && !e.props.isToggleable) return { dom: n };
|
|
1855
1855
|
let i = document.createElement("div"), a = document.createElement("div");
|
|
1856
1856
|
a.className = "bn-toggle-wrapper";
|
|
@@ -1884,23 +1884,23 @@ var On = {
|
|
|
1884
1884
|
o.removeEventListener("mousedown", s), o.removeEventListener("click", c), l.removeEventListener("mousedown", u), l.removeEventListener("click", d), p?.();
|
|
1885
1885
|
}
|
|
1886
1886
|
};
|
|
1887
|
-
},
|
|
1887
|
+
}, In = [
|
|
1888
1888
|
1,
|
|
1889
1889
|
2,
|
|
1890
1890
|
3,
|
|
1891
1891
|
4,
|
|
1892
1892
|
5,
|
|
1893
1893
|
6
|
|
1894
|
-
],
|
|
1894
|
+
], Ln = (e) => ({ editor: t }) => {
|
|
1895
1895
|
let n = t.getTextCursorPosition();
|
|
1896
1896
|
return t.schema.blockSchema[n.block.type].content === "inline" ? (t.updateBlock(n.block, {
|
|
1897
1897
|
type: "heading",
|
|
1898
1898
|
props: { level: e }
|
|
1899
1899
|
}), !0) : !1;
|
|
1900
|
-
},
|
|
1900
|
+
}, Rn = A(({ defaultLevel: e = 1, levels: t = In, allowToggleHeadings: n = !0 } = {}) => ({
|
|
1901
1901
|
type: "heading",
|
|
1902
1902
|
propSchema: {
|
|
1903
|
-
...
|
|
1903
|
+
...q,
|
|
1904
1904
|
level: {
|
|
1905
1905
|
default: e,
|
|
1906
1906
|
values: t
|
|
@@ -1911,7 +1911,7 @@ var On = {
|
|
|
1911
1911
|
} } : {}
|
|
1912
1912
|
},
|
|
1913
1913
|
content: "inline"
|
|
1914
|
-
})),
|
|
1914
|
+
})), zn = j(Rn, ({ allowToggleHeadings: e = !0 } = {}) => ({
|
|
1915
1915
|
meta: { isolating: !1 },
|
|
1916
1916
|
parse(t) {
|
|
1917
1917
|
if (e && t.tagName === "DETAILS") {
|
|
@@ -1919,7 +1919,7 @@ var On = {
|
|
|
1919
1919
|
if (!e) return;
|
|
1920
1920
|
let n = e.querySelector("h1, h2, h3, h4, h5, h6");
|
|
1921
1921
|
return n ? {
|
|
1922
|
-
...
|
|
1922
|
+
...J(n),
|
|
1923
1923
|
level: parseInt(n.tagName[1]),
|
|
1924
1924
|
isToggleable: !0
|
|
1925
1925
|
} : void 0;
|
|
@@ -1947,18 +1947,18 @@ var On = {
|
|
|
1947
1947
|
default: return;
|
|
1948
1948
|
}
|
|
1949
1949
|
return {
|
|
1950
|
-
...
|
|
1950
|
+
...J(t),
|
|
1951
1951
|
level: n
|
|
1952
1952
|
};
|
|
1953
1953
|
},
|
|
1954
1954
|
...e ? { parseContent: ({ el: e, schema: t }) => {
|
|
1955
|
-
if (e.tagName === "DETAILS") return
|
|
1955
|
+
if (e.tagName === "DETAILS") return Nn(e, t, "heading");
|
|
1956
1956
|
} } : {},
|
|
1957
1957
|
runsBefore: ["toggleListItem"],
|
|
1958
1958
|
render(t, n) {
|
|
1959
1959
|
let r = document.createElement(`h${t.props.level}`);
|
|
1960
1960
|
return e ? {
|
|
1961
|
-
...
|
|
1961
|
+
...Fn(t, n, r),
|
|
1962
1962
|
contentDOM: r
|
|
1963
1963
|
} : {
|
|
1964
1964
|
dom: r,
|
|
@@ -1967,7 +1967,7 @@ var On = {
|
|
|
1967
1967
|
},
|
|
1968
1968
|
toExternalHTML(t) {
|
|
1969
1969
|
let n = document.createElement(`h${t.props.level}`);
|
|
1970
|
-
if (
|
|
1970
|
+
if (Y(t.props, n), e && t.props.isToggleable) {
|
|
1971
1971
|
let e = document.createElement("details");
|
|
1972
1972
|
e.setAttribute("open", "");
|
|
1973
1973
|
let t = document.createElement("summary");
|
|
@@ -1982,9 +1982,9 @@ var On = {
|
|
|
1982
1982
|
contentDOM: n
|
|
1983
1983
|
};
|
|
1984
1984
|
}
|
|
1985
|
-
}), ({ levels: e =
|
|
1985
|
+
}), ({ levels: e = In } = {}) => [t({
|
|
1986
1986
|
key: "heading-shortcuts",
|
|
1987
|
-
keyboardShortcuts: Object.fromEntries(e.map((e) => [`Mod-Alt-${e}`,
|
|
1987
|
+
keyboardShortcuts: Object.fromEntries(e.map((e) => [`Mod-Alt-${e}`, Ln(e)]) ?? []),
|
|
1988
1988
|
inputRules: e.map((e) => ({
|
|
1989
1989
|
find: RegExp(`^(#{${e}})\\s$`),
|
|
1990
1990
|
replace({ match: e }) {
|
|
@@ -1994,8 +1994,8 @@ var On = {
|
|
|
1994
1994
|
};
|
|
1995
1995
|
}
|
|
1996
1996
|
}))
|
|
1997
|
-
})]),
|
|
1998
|
-
let { dom: a, destroy: o } =
|
|
1997
|
+
})]), Bn = (e, t, n, r, i) => {
|
|
1998
|
+
let { dom: a, destroy: o } = dn(e, t, n, i), s = a;
|
|
1999
1999
|
s.style.position = "relative", e.props.url && e.props.showPreview && (e.props.previewWidth ? s.style.width = `${e.props.previewWidth}px` : s.style.width = "fit-content");
|
|
2000
2000
|
let c = document.createElement("div");
|
|
2001
2001
|
c.className = "bn-resize-handle", c.style.left = "4px", c.style.display = "none", r.appendChild(c);
|
|
@@ -2039,15 +2039,15 @@ var On = {
|
|
|
2039
2039
|
o?.(), window.removeEventListener("mousemove", p), window.removeEventListener("touchmove", p), window.removeEventListener("mouseup", m), window.removeEventListener("touchend", m), s.removeEventListener("mouseenter", h), s.removeEventListener("mouseleave", g), c.removeEventListener("mousedown", _), c.removeEventListener("touchstart", _), l.removeEventListener("mousedown", v), l.removeEventListener("touchstart", v);
|
|
2040
2040
|
}
|
|
2041
2041
|
};
|
|
2042
|
-
},
|
|
2042
|
+
}, Vn = (e) => ({
|
|
2043
2043
|
url: e.src || void 0,
|
|
2044
2044
|
previewWidth: e.width || void 0,
|
|
2045
2045
|
name: e.alt || void 0
|
|
2046
|
-
}),
|
|
2046
|
+
}), Hn = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z\"></path></svg>", Un = A((e = {}) => ({
|
|
2047
2047
|
type: "image",
|
|
2048
2048
|
propSchema: {
|
|
2049
|
-
textAlignment:
|
|
2050
|
-
backgroundColor:
|
|
2049
|
+
textAlignment: q.textAlignment,
|
|
2050
|
+
backgroundColor: q.backgroundColor,
|
|
2051
2051
|
name: { default: "" },
|
|
2052
2052
|
url: { default: "" },
|
|
2053
2053
|
caption: { default: "" },
|
|
@@ -2058,26 +2058,26 @@ var On = {
|
|
|
2058
2058
|
}
|
|
2059
2059
|
},
|
|
2060
2060
|
content: "none"
|
|
2061
|
-
})),
|
|
2061
|
+
})), Wn = (e = {}) => (e) => {
|
|
2062
2062
|
if (e.tagName === "IMG") {
|
|
2063
2063
|
if (e.closest("figure")) return;
|
|
2064
|
-
let { backgroundColor: t } =
|
|
2064
|
+
let { backgroundColor: t } = J(e);
|
|
2065
2065
|
return {
|
|
2066
|
-
...
|
|
2066
|
+
...Vn(e),
|
|
2067
2067
|
backgroundColor: t
|
|
2068
2068
|
};
|
|
2069
2069
|
}
|
|
2070
2070
|
if (e.tagName === "FIGURE") {
|
|
2071
|
-
let t =
|
|
2071
|
+
let t = sn(e, "img");
|
|
2072
2072
|
if (!t) return;
|
|
2073
|
-
let { targetElement: n, caption: r } = t, { backgroundColor: i } =
|
|
2073
|
+
let { targetElement: n, caption: r } = t, { backgroundColor: i } = J(e);
|
|
2074
2074
|
return {
|
|
2075
|
-
...
|
|
2075
|
+
...Vn(n),
|
|
2076
2076
|
backgroundColor: i,
|
|
2077
2077
|
caption: r
|
|
2078
2078
|
};
|
|
2079
2079
|
}
|
|
2080
|
-
},
|
|
2080
|
+
}, Gn = (e = {}) => (t, n) => {
|
|
2081
2081
|
let r = document.createElement("div");
|
|
2082
2082
|
r.innerHTML = e.icon ?? "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z\"></path></svg>";
|
|
2083
2083
|
let i = document.createElement("div");
|
|
@@ -2085,24 +2085,24 @@ var On = {
|
|
|
2085
2085
|
let a = document.createElement("img");
|
|
2086
2086
|
return a.className = "bn-visual-media", n.resolveFileUrl ? n.resolveFileUrl(t.props.url).then((e) => {
|
|
2087
2087
|
a.src = e;
|
|
2088
|
-
}) : a.src = t.props.url, a.alt = t.props.name || t.props.caption || "BlockNote image", a.contentEditable = "false", a.draggable = !1, i.appendChild(a),
|
|
2089
|
-
},
|
|
2088
|
+
}) : a.src = t.props.url, a.alt = t.props.name || t.props.caption || "BlockNote image", a.contentEditable = "false", a.draggable = !1, i.appendChild(a), Bn(t, n, { dom: i }, i, r.firstElementChild);
|
|
2089
|
+
}, Kn = (e = {}) => (e, t) => {
|
|
2090
2090
|
if (!e.props.url) {
|
|
2091
2091
|
let e = document.createElement("p");
|
|
2092
2092
|
return e.textContent = "Add image", { dom: e };
|
|
2093
2093
|
}
|
|
2094
2094
|
let n;
|
|
2095
|
-
return e.props.showPreview ? (n = document.createElement("img"), n.src = e.props.url, n.alt = e.props.name || e.props.caption || "BlockNote image", e.props.previewWidth && (n.width = e.props.previewWidth)) : (n = document.createElement("a"), n.href = e.props.url, n.textContent = e.props.name || e.props.url), e.props.caption ? e.props.showPreview ?
|
|
2096
|
-
},
|
|
2095
|
+
return e.props.showPreview ? (n = document.createElement("img"), n.src = e.props.url, n.alt = e.props.name || e.props.caption || "BlockNote image", e.props.previewWidth && (n.width = e.props.previewWidth)) : (n = document.createElement("a"), n.href = e.props.url, n.textContent = e.props.name || e.props.url), e.props.caption ? e.props.showPreview ? fn(n, e.props.caption) : pn(n, e.props.caption) : { dom: n };
|
|
2096
|
+
}, qn = j(Un, (e) => ({
|
|
2097
2097
|
meta: { fileBlockAccept: ["image/*"] },
|
|
2098
|
-
parse:
|
|
2099
|
-
render:
|
|
2100
|
-
toExternalHTML:
|
|
2098
|
+
parse: Wn(e),
|
|
2099
|
+
render: Gn(e),
|
|
2100
|
+
toExternalHTML: Kn(e),
|
|
2101
2101
|
runsBefore: ["file"]
|
|
2102
|
-
})),
|
|
2103
|
-
let i =
|
|
2102
|
+
})), Jn = (e, t, n) => ({ state: r, dispatch: i }) => i ? Yn(r.tr, e, t, n) : !0, Yn = (e, t, n, r) => {
|
|
2103
|
+
let i = N(M(e.doc, t));
|
|
2104
2104
|
if (!i.isBlockContainer) return !1;
|
|
2105
|
-
let a =
|
|
2105
|
+
let a = P(e), o = [{
|
|
2106
2106
|
type: i.bnBlock.node.type,
|
|
2107
2107
|
attrs: r ? {
|
|
2108
2108
|
...i.bnBlock.node.attrs,
|
|
@@ -2113,23 +2113,23 @@ var On = {
|
|
|
2113
2113
|
attrs: r ? { ...i.blockContent.node.attrs } : {}
|
|
2114
2114
|
}];
|
|
2115
2115
|
return e.split(t, 2, o), !0;
|
|
2116
|
-
},
|
|
2116
|
+
}, Xn = (e, t) => {
|
|
2117
2117
|
let { blockInfo: n, selectionEmpty: r } = e.transact((e) => ({
|
|
2118
|
-
blockInfo:
|
|
2118
|
+
blockInfo: tt(e),
|
|
2119
2119
|
selectionEmpty: e.selection.anchor === e.selection.head
|
|
2120
2120
|
}));
|
|
2121
2121
|
if (!n.isBlockContainer) return !1;
|
|
2122
2122
|
let { bnBlock: i, blockContent: a } = n;
|
|
2123
2123
|
return a.node.type.name !== t || !r ? !1 : a.node.childCount === 0 ? (e.transact((e) => {
|
|
2124
|
-
|
|
2124
|
+
G(e, i.beforePos, {
|
|
2125
2125
|
type: "paragraph",
|
|
2126
2126
|
props: {}
|
|
2127
2127
|
});
|
|
2128
|
-
}), !0) : a.node.childCount > 0 ? e.transact((e) => (e.deleteSelection(),
|
|
2128
|
+
}), !0) : a.node.childCount > 0 ? e.transact((e) => (e.deleteSelection(), Yn(e, e.selection.from, !0))) : !1;
|
|
2129
2129
|
};
|
|
2130
2130
|
//#endregion
|
|
2131
2131
|
//#region src/blocks/ListItem/getListItemContent.ts
|
|
2132
|
-
function
|
|
2132
|
+
function Zn(e, t, i) {
|
|
2133
2133
|
let a = n.fromSchema(t), o = e, s = document.createElement("div");
|
|
2134
2134
|
s.setAttribute("data-node-type", "blockGroup");
|
|
2135
2135
|
for (let e of Array.from(o.childNodes)) s.appendChild(e.cloneNode(!0));
|
|
@@ -2146,18 +2146,18 @@ function Gn(e, t, i) {
|
|
|
2146
2146
|
}
|
|
2147
2147
|
//#endregion
|
|
2148
2148
|
//#region src/blocks/ListItem/BulletListItem/block.ts
|
|
2149
|
-
var
|
|
2149
|
+
var Qn = A(() => ({
|
|
2150
2150
|
type: "bulletListItem",
|
|
2151
|
-
propSchema: { ...
|
|
2151
|
+
propSchema: { ...q },
|
|
2152
2152
|
content: "inline"
|
|
2153
|
-
})),
|
|
2153
|
+
})), $n = j(Qn, {
|
|
2154
2154
|
meta: { isolating: !1 },
|
|
2155
2155
|
parse(e) {
|
|
2156
2156
|
if (e.tagName !== "LI") return;
|
|
2157
2157
|
let t = e.parentElement;
|
|
2158
|
-
if (t !== null && (t.tagName === "UL" || t.tagName === "DIV" && t.parentElement?.tagName === "UL")) return
|
|
2158
|
+
if (t !== null && (t.tagName === "UL" || t.tagName === "DIV" && t.parentElement?.tagName === "UL")) return J(e);
|
|
2159
2159
|
},
|
|
2160
|
-
parseContent: ({ el: e, schema: t }) =>
|
|
2160
|
+
parseContent: ({ el: e, schema: t }) => Zn(e, t, "bulletListItem"),
|
|
2161
2161
|
render() {
|
|
2162
2162
|
let e = document.createElement("p");
|
|
2163
2163
|
return {
|
|
@@ -2167,7 +2167,7 @@ var Kn = D(() => ({
|
|
|
2167
2167
|
},
|
|
2168
2168
|
toExternalHTML(e) {
|
|
2169
2169
|
let t = document.createElement("li"), n = document.createElement("p");
|
|
2170
|
-
return
|
|
2170
|
+
return Y(e.props, t), t.appendChild(n), {
|
|
2171
2171
|
dom: t,
|
|
2172
2172
|
contentDOM: n
|
|
2173
2173
|
};
|
|
@@ -2175,7 +2175,7 @@ var Kn = D(() => ({
|
|
|
2175
2175
|
}, [t({
|
|
2176
2176
|
key: "bullet-list-item-shortcuts",
|
|
2177
2177
|
keyboardShortcuts: {
|
|
2178
|
-
Enter: ({ editor: e }) =>
|
|
2178
|
+
Enter: ({ editor: e }) => Xn(e, "bulletListItem"),
|
|
2179
2179
|
"Mod-Shift-8": ({ editor: e }) => {
|
|
2180
2180
|
let t = e.getTextCursorPosition();
|
|
2181
2181
|
return e.schema.blockSchema[t.block.type].content === "inline" ? (e.updateBlock(t.block, {
|
|
@@ -2187,23 +2187,23 @@ var Kn = D(() => ({
|
|
|
2187
2187
|
inputRules: [{
|
|
2188
2188
|
find: /^\s?[-+*]\s$/,
|
|
2189
2189
|
replace({ editor: e }) {
|
|
2190
|
-
if (
|
|
2190
|
+
if (et(e.prosemirrorState).blockNoteType !== "heading") return {
|
|
2191
2191
|
type: "bulletListItem",
|
|
2192
2192
|
props: {}
|
|
2193
2193
|
};
|
|
2194
2194
|
}
|
|
2195
2195
|
}]
|
|
2196
|
-
})]),
|
|
2196
|
+
})]), er = A(() => ({
|
|
2197
2197
|
type: "checkListItem",
|
|
2198
2198
|
propSchema: {
|
|
2199
|
-
...
|
|
2199
|
+
...q,
|
|
2200
2200
|
checked: {
|
|
2201
2201
|
default: !1,
|
|
2202
2202
|
type: "boolean"
|
|
2203
2203
|
}
|
|
2204
2204
|
},
|
|
2205
2205
|
content: "inline"
|
|
2206
|
-
})),
|
|
2206
|
+
})), tr = j(er, {
|
|
2207
2207
|
meta: { isolating: !1 },
|
|
2208
2208
|
parse(e) {
|
|
2209
2209
|
if (e.tagName === "input") return e.closest("[data-content-type]") || e.closest("li") ? void 0 : e.type === "checkbox" ? { checked: e.checked } : void 0;
|
|
@@ -2212,12 +2212,12 @@ var Kn = D(() => ({
|
|
|
2212
2212
|
if (t !== null && (t.tagName === "UL" || t.tagName === "DIV" && t.parentElement?.tagName === "UL")) {
|
|
2213
2213
|
let t = e.querySelector("input[type=checkbox]") || null;
|
|
2214
2214
|
return t === null ? void 0 : {
|
|
2215
|
-
...
|
|
2215
|
+
...J(e),
|
|
2216
2216
|
checked: t.checked
|
|
2217
2217
|
};
|
|
2218
2218
|
}
|
|
2219
2219
|
},
|
|
2220
|
-
parseContent: ({ el: e, schema: t }) =>
|
|
2220
|
+
parseContent: ({ el: e, schema: t }) => Zn(e, t, "checkListItem"),
|
|
2221
2221
|
render(e, t) {
|
|
2222
2222
|
let n = document.createDocumentFragment(), r = document.createElement("input");
|
|
2223
2223
|
r.type = "checkbox", r.checked = e.props.checked, e.props.checked && r.setAttribute("checked", ""), r.disabled = !t.isEditable, r.addEventListener("change", () => {
|
|
@@ -2233,7 +2233,7 @@ var Kn = D(() => ({
|
|
|
2233
2233
|
let t = document.createElement("li"), n = document.createElement("input");
|
|
2234
2234
|
n.type = "checkbox", n.checked = e.props.checked, e.props.checked && n.setAttribute("checked", "");
|
|
2235
2235
|
let r = document.createElement("p");
|
|
2236
|
-
return
|
|
2236
|
+
return Y(e.props, t), t.appendChild(n), t.appendChild(r), {
|
|
2237
2237
|
dom: t,
|
|
2238
2238
|
contentDOM: r
|
|
2239
2239
|
};
|
|
@@ -2242,7 +2242,7 @@ var Kn = D(() => ({
|
|
|
2242
2242
|
}, [t({
|
|
2243
2243
|
key: "check-list-item-shortcuts",
|
|
2244
2244
|
keyboardShortcuts: {
|
|
2245
|
-
Enter: ({ editor: e }) =>
|
|
2245
|
+
Enter: ({ editor: e }) => Xn(e, "checkListItem"),
|
|
2246
2246
|
"Mod-Shift-9": ({ editor: e }) => {
|
|
2247
2247
|
let t = e.getTextCursorPosition();
|
|
2248
2248
|
return e.schema.blockSchema[t.block.type].content === "inline" ? (e.updateBlock(t.block, {
|
|
@@ -2271,8 +2271,8 @@ var Kn = D(() => ({
|
|
|
2271
2271
|
})]);
|
|
2272
2272
|
//#endregion
|
|
2273
2273
|
//#region src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts
|
|
2274
|
-
function
|
|
2275
|
-
let i = !!e.firstChild.attrs.start, a =
|
|
2274
|
+
function nr(e, t, n, r) {
|
|
2275
|
+
let i = !!e.firstChild.attrs.start, a = N({
|
|
2276
2276
|
posBeforeNode: t,
|
|
2277
2277
|
node: e
|
|
2278
2278
|
});
|
|
@@ -2291,7 +2291,7 @@ function Xn(e, t, n, r) {
|
|
|
2291
2291
|
pos: t
|
|
2292
2292
|
}], l = o, u = a.bnBlock.beforePos;
|
|
2293
2293
|
for (; l && r.get(l) === void 0;) {
|
|
2294
|
-
let e =
|
|
2294
|
+
let e = N({
|
|
2295
2295
|
posBeforeNode: u - l.nodeSize,
|
|
2296
2296
|
node: l
|
|
2297
2297
|
});
|
|
@@ -2303,7 +2303,7 @@ function Xn(e, t, n, r) {
|
|
|
2303
2303
|
let t = n.doc.resolve(e.bnBlock.beforePos).nodeBefore;
|
|
2304
2304
|
u = e.bnBlock.beforePos, l = t;
|
|
2305
2305
|
}
|
|
2306
|
-
let d, f, p = c[c.length - 1], m =
|
|
2306
|
+
let d, f, p = c[c.length - 1], m = N({
|
|
2307
2307
|
posBeforeNode: p.pos,
|
|
2308
2308
|
node: p.node
|
|
2309
2309
|
});
|
|
@@ -2320,15 +2320,15 @@ function Xn(e, t, n, r) {
|
|
|
2320
2320
|
hasStart: i
|
|
2321
2321
|
};
|
|
2322
2322
|
}
|
|
2323
|
-
function
|
|
2323
|
+
function rr(e, t) {
|
|
2324
2324
|
let n = /* @__PURE__ */ new Map(), r = t.decorations.map(e.mapping, e.doc), i = e.changedRange();
|
|
2325
2325
|
if (!i) return { decorations: r };
|
|
2326
2326
|
let a = [], o = /* @__PURE__ */ new Set();
|
|
2327
2327
|
e.doc.nodesBetween(i.from, e.doc.nodeSize - 2, (t, s, c) => {
|
|
2328
2328
|
if (c && o.has(c)) return !1;
|
|
2329
2329
|
if (t.type.name === "blockContainer" && t.firstChild.type.name === "numberedListItem") {
|
|
2330
|
-
let { index: l, isFirst: u, hasStart: d } =
|
|
2331
|
-
if (r.find(s + 1, s + 1 + f.nodeSize, (e) => e.index === l && e.isFirst === u && e.hasStart === d).length === 0) a.push(
|
|
2330
|
+
let { index: l, isFirst: u, hasStart: d } = nr(t, s, e, n), f = e.doc.nodeAt(s + 1);
|
|
2331
|
+
if (r.find(s + 1, s + 1 + f.nodeSize, (e) => e.index === l && e.isFirst === u && e.hasStart === d).length === 0) a.push(be.node(s + 1, s + 1 + f.nodeSize, { "data-index": l.toString() }, {
|
|
2332
2332
|
index: l,
|
|
2333
2333
|
isFirst: u,
|
|
2334
2334
|
hasStart: d
|
|
@@ -2339,43 +2339,43 @@ function Zn(e, t) {
|
|
|
2339
2339
|
let s = a.flatMap((e) => r.find(e.from, e.to));
|
|
2340
2340
|
return { decorations: r.remove(s).add(e.doc, a) };
|
|
2341
2341
|
}
|
|
2342
|
-
var
|
|
2343
|
-
key: new
|
|
2342
|
+
var ir = () => new ve({
|
|
2343
|
+
key: new ye("numbered-list-indexing-decorations"),
|
|
2344
2344
|
state: {
|
|
2345
2345
|
init(e, t) {
|
|
2346
|
-
return
|
|
2346
|
+
return rr(t.tr, { decorations: xe.empty });
|
|
2347
2347
|
},
|
|
2348
2348
|
apply(e, t) {
|
|
2349
|
-
return !e.docChanged && t.decorations ? t :
|
|
2349
|
+
return !e.docChanged && t.decorations ? t : rr(e, t);
|
|
2350
2350
|
}
|
|
2351
2351
|
},
|
|
2352
2352
|
props: { decorations(e) {
|
|
2353
|
-
return this.getState(e)?.decorations ??
|
|
2353
|
+
return this.getState(e)?.decorations ?? xe.empty;
|
|
2354
2354
|
} }
|
|
2355
|
-
}),
|
|
2355
|
+
}), ar = A(() => ({
|
|
2356
2356
|
type: "numberedListItem",
|
|
2357
2357
|
propSchema: {
|
|
2358
|
-
...
|
|
2358
|
+
...q,
|
|
2359
2359
|
start: {
|
|
2360
2360
|
default: void 0,
|
|
2361
2361
|
type: "number"
|
|
2362
2362
|
}
|
|
2363
2363
|
},
|
|
2364
2364
|
content: "inline"
|
|
2365
|
-
})),
|
|
2365
|
+
})), or = j(ar, {
|
|
2366
2366
|
meta: { isolating: !1 },
|
|
2367
2367
|
parse(e) {
|
|
2368
2368
|
if (e.tagName !== "LI") return;
|
|
2369
2369
|
let t = e.parentElement;
|
|
2370
2370
|
if (t !== null && (t.tagName === "OL" || t.tagName === "DIV" && t.parentElement?.tagName === "OL")) {
|
|
2371
|
-
let n = parseInt(t.getAttribute("start") || "1"), r =
|
|
2371
|
+
let n = parseInt(t.getAttribute("start") || "1"), r = J(e);
|
|
2372
2372
|
return e.previousElementSibling || n === 1 ? r : {
|
|
2373
2373
|
...r,
|
|
2374
2374
|
start: n
|
|
2375
2375
|
};
|
|
2376
2376
|
}
|
|
2377
2377
|
},
|
|
2378
|
-
parseContent: ({ el: e, schema: t }) =>
|
|
2378
|
+
parseContent: ({ el: e, schema: t }) => Zn(e, t, "numberedListItem"),
|
|
2379
2379
|
render() {
|
|
2380
2380
|
let e = document.createElement("p");
|
|
2381
2381
|
return {
|
|
@@ -2385,7 +2385,7 @@ var Qn = () => new pe({
|
|
|
2385
2385
|
},
|
|
2386
2386
|
toExternalHTML(e) {
|
|
2387
2387
|
let t = document.createElement("li"), n = document.createElement("p");
|
|
2388
|
-
return
|
|
2388
|
+
return Y(e.props, t), t.appendChild(n), {
|
|
2389
2389
|
dom: t,
|
|
2390
2390
|
contentDOM: n
|
|
2391
2391
|
};
|
|
@@ -2395,7 +2395,7 @@ var Qn = () => new pe({
|
|
|
2395
2395
|
inputRules: [{
|
|
2396
2396
|
find: /^\s?(\d+)\.\s$/,
|
|
2397
2397
|
replace({ match: e, editor: t }) {
|
|
2398
|
-
if (
|
|
2398
|
+
if (et(t.prosemirrorState).blockNoteType === "heading") return;
|
|
2399
2399
|
let n = parseInt(e[1]);
|
|
2400
2400
|
return {
|
|
2401
2401
|
type: "numberedListItem",
|
|
@@ -2404,7 +2404,7 @@ var Qn = () => new pe({
|
|
|
2404
2404
|
}
|
|
2405
2405
|
}],
|
|
2406
2406
|
keyboardShortcuts: {
|
|
2407
|
-
Enter: ({ editor: e }) =>
|
|
2407
|
+
Enter: ({ editor: e }) => Xn(e, "numberedListItem"),
|
|
2408
2408
|
"Mod-Shift-7": ({ editor: e }) => {
|
|
2409
2409
|
let t = e.getTextCursorPosition();
|
|
2410
2410
|
return e.schema.blockSchema[t.block.type].content === "inline" ? (e.updateBlock(t.block, {
|
|
@@ -2413,30 +2413,30 @@ var Qn = () => new pe({
|
|
|
2413
2413
|
}), !0) : !1;
|
|
2414
2414
|
}
|
|
2415
2415
|
},
|
|
2416
|
-
prosemirrorPlugins: [
|
|
2417
|
-
})]),
|
|
2416
|
+
prosemirrorPlugins: [ir()]
|
|
2417
|
+
})]), sr = A(() => ({
|
|
2418
2418
|
type: "toggleListItem",
|
|
2419
|
-
propSchema: { ...
|
|
2419
|
+
propSchema: { ...q },
|
|
2420
2420
|
content: "inline"
|
|
2421
|
-
})),
|
|
2421
|
+
})), cr = j(sr, {
|
|
2422
2422
|
meta: { isolating: !1 },
|
|
2423
2423
|
parse(e) {
|
|
2424
|
-
if (e.tagName === "DETAILS") return
|
|
2424
|
+
if (e.tagName === "DETAILS") return J(e);
|
|
2425
2425
|
if (e.tagName === "LI") {
|
|
2426
2426
|
let t = e.parentElement;
|
|
2427
|
-
if (t && (t.tagName === "UL" || t.tagName === "DIV" && t.parentElement?.tagName === "UL") && e.querySelector(":scope > details")) return
|
|
2427
|
+
if (t && (t.tagName === "UL" || t.tagName === "DIV" && t.parentElement?.tagName === "UL") && e.querySelector(":scope > details")) return J(e);
|
|
2428
2428
|
}
|
|
2429
2429
|
},
|
|
2430
2430
|
parseContent: ({ el: e, schema: t }) => {
|
|
2431
2431
|
let n = e.tagName === "DETAILS" ? e : e.querySelector(":scope > details");
|
|
2432
2432
|
if (!n) throw Error("No details found in toggleListItem parseContent");
|
|
2433
|
-
return
|
|
2433
|
+
return Nn(n, t, "toggleListItem");
|
|
2434
2434
|
},
|
|
2435
2435
|
runsBefore: ["bulletListItem"],
|
|
2436
2436
|
render(e, t) {
|
|
2437
2437
|
let n = document.createElement("p");
|
|
2438
2438
|
return {
|
|
2439
|
-
...
|
|
2439
|
+
...Fn(e, t, n),
|
|
2440
2440
|
contentDOM: n
|
|
2441
2441
|
};
|
|
2442
2442
|
},
|
|
@@ -2444,7 +2444,7 @@ var Qn = () => new pe({
|
|
|
2444
2444
|
let t = document.createElement("li"), n = document.createElement("details");
|
|
2445
2445
|
n.setAttribute("open", "");
|
|
2446
2446
|
let r = document.createElement("summary"), i = document.createElement("p");
|
|
2447
|
-
return r.appendChild(i), n.appendChild(r),
|
|
2447
|
+
return r.appendChild(i), n.appendChild(r), Y(e.props, t), t.appendChild(n), {
|
|
2448
2448
|
dom: t,
|
|
2449
2449
|
contentDOM: i,
|
|
2450
2450
|
childrenDOM: n
|
|
@@ -2453,7 +2453,7 @@ var Qn = () => new pe({
|
|
|
2453
2453
|
}, [t({
|
|
2454
2454
|
key: "toggle-list-item-shortcuts",
|
|
2455
2455
|
keyboardShortcuts: {
|
|
2456
|
-
Enter: ({ editor: e }) =>
|
|
2456
|
+
Enter: ({ editor: e }) => Xn(e, "toggleListItem"),
|
|
2457
2457
|
"Mod-Shift-6": ({ editor: e }) => {
|
|
2458
2458
|
let t = e.getTextCursorPosition();
|
|
2459
2459
|
return e.schema.blockSchema[t.block.type].content === "inline" ? (e.updateBlock(t.block, {
|
|
@@ -2462,11 +2462,11 @@ var Qn = () => new pe({
|
|
|
2462
2462
|
}), !0) : !1;
|
|
2463
2463
|
}
|
|
2464
2464
|
}
|
|
2465
|
-
})]),
|
|
2465
|
+
})]), lr = A(() => ({
|
|
2466
2466
|
type: "pageBreak",
|
|
2467
2467
|
propSchema: {},
|
|
2468
2468
|
content: "none"
|
|
2469
|
-
})),
|
|
2469
|
+
})), ur = j(lr, {
|
|
2470
2470
|
parse(e) {
|
|
2471
2471
|
if (e.tagName === "DIV" && e.hasAttribute("data-page-break")) return {};
|
|
2472
2472
|
},
|
|
@@ -2478,14 +2478,14 @@ var Qn = () => new pe({
|
|
|
2478
2478
|
let e = document.createElement("div");
|
|
2479
2479
|
return e.setAttribute("data-page-break", ""), { dom: e };
|
|
2480
2480
|
}
|
|
2481
|
-
}),
|
|
2481
|
+
}), dr = (e) => e.extend({ blockSpecs: { pageBreak: ur() } }), fr = A(() => ({
|
|
2482
2482
|
type: "paragraph",
|
|
2483
|
-
propSchema:
|
|
2483
|
+
propSchema: q,
|
|
2484
2484
|
content: "inline"
|
|
2485
|
-
})),
|
|
2485
|
+
})), pr = j(fr, {
|
|
2486
2486
|
meta: { isolating: !1 },
|
|
2487
2487
|
parse: (e) => {
|
|
2488
|
-
if (e.tagName === "P" && e.textContent?.trim()) return
|
|
2488
|
+
if (e.tagName === "P" && e.textContent?.trim()) return J(e);
|
|
2489
2489
|
},
|
|
2490
2490
|
render: () => {
|
|
2491
2491
|
let e = document.createElement("p");
|
|
@@ -2496,7 +2496,7 @@ var Qn = () => new pe({
|
|
|
2496
2496
|
},
|
|
2497
2497
|
toExternalHTML: (e) => {
|
|
2498
2498
|
let t = document.createElement("p");
|
|
2499
|
-
return
|
|
2499
|
+
return Y(e.props, t), {
|
|
2500
2500
|
dom: t,
|
|
2501
2501
|
contentDOM: t
|
|
2502
2502
|
};
|
|
@@ -2511,18 +2511,18 @@ var Qn = () => new pe({
|
|
|
2511
2511
|
props: {}
|
|
2512
2512
|
}), !0) : !1;
|
|
2513
2513
|
} }
|
|
2514
|
-
})]),
|
|
2514
|
+
})]), mr = A(() => ({
|
|
2515
2515
|
type: "quote",
|
|
2516
2516
|
propSchema: {
|
|
2517
|
-
backgroundColor:
|
|
2518
|
-
textColor:
|
|
2517
|
+
backgroundColor: q.backgroundColor,
|
|
2518
|
+
textColor: q.textColor
|
|
2519
2519
|
},
|
|
2520
2520
|
content: "inline"
|
|
2521
|
-
})),
|
|
2521
|
+
})), hr = j(mr, {
|
|
2522
2522
|
meta: { isolating: !1 },
|
|
2523
2523
|
parse(e) {
|
|
2524
2524
|
if (e.tagName === "BLOCKQUOTE") {
|
|
2525
|
-
let { backgroundColor: t, textColor: n } =
|
|
2525
|
+
let { backgroundColor: t, textColor: n } = J(e);
|
|
2526
2526
|
return {
|
|
2527
2527
|
backgroundColor: t,
|
|
2528
2528
|
textColor: n
|
|
@@ -2538,7 +2538,7 @@ var Qn = () => new pe({
|
|
|
2538
2538
|
},
|
|
2539
2539
|
toExternalHTML(e) {
|
|
2540
2540
|
let t = document.createElement("blockquote");
|
|
2541
|
-
return
|
|
2541
|
+
return Y(e.props, t), {
|
|
2542
2542
|
dom: t,
|
|
2543
2543
|
contentDOM: t
|
|
2544
2544
|
};
|
|
@@ -2560,33 +2560,45 @@ var Qn = () => new pe({
|
|
|
2560
2560
|
props: {}
|
|
2561
2561
|
};
|
|
2562
2562
|
}
|
|
2563
|
+
}, {
|
|
2564
|
+
find: RegExp("^\\p{Quotation_Mark}\\s$", "u"),
|
|
2565
|
+
replace() {
|
|
2566
|
+
return {
|
|
2567
|
+
type: "quote",
|
|
2568
|
+
props: {}
|
|
2569
|
+
};
|
|
2570
|
+
}
|
|
2563
2571
|
}]
|
|
2564
|
-
})]),
|
|
2572
|
+
})]), gr = 120, _r = 31, vr = s.create({
|
|
2565
2573
|
name: "BlockNoteTableExtension",
|
|
2566
|
-
addProseMirrorPlugins: () => [
|
|
2574
|
+
addProseMirrorPlugins: () => [le({
|
|
2567
2575
|
cellMinWidth: 35,
|
|
2568
2576
|
defaultCellMinWidth: 120,
|
|
2569
2577
|
View: null
|
|
2570
|
-
}),
|
|
2578
|
+
}), he()],
|
|
2571
2579
|
addKeyboardShortcuts() {
|
|
2572
2580
|
return {
|
|
2573
|
-
Enter: () => this.editor.state.selection
|
|
2581
|
+
Enter: () => this.editor.state.selection.$head.parent.type.name === "tableParagraph" ? this.editor.commands.command(({ state: e, dispatch: t }) => {
|
|
2582
|
+
if (!de(e)) return !1;
|
|
2583
|
+
let n = pe(me(e), "vert", 1);
|
|
2584
|
+
return n ? (t && t(e.tr.setSelection(te.between(n, fe(n))).scrollIntoView()), !0) : !1;
|
|
2585
|
+
}) : !1,
|
|
2574
2586
|
Backspace: () => {
|
|
2575
2587
|
let e = this.editor.state.selection, t = e.empty, n = e.$head.parentOffset === 0, r = e.$head.node().type.name === "tableParagraph";
|
|
2576
2588
|
return t && n && r;
|
|
2577
2589
|
},
|
|
2578
|
-
Tab: () => this.editor.commands.command(({ state: e, dispatch: t, view: n }) =>
|
|
2579
|
-
"Shift-Tab": () => this.editor.commands.command(({ state: e, dispatch: t, view: n }) =>
|
|
2590
|
+
Tab: () => this.editor.commands.command(({ state: e, dispatch: t, view: n }) => ue(1)(e, t, n)),
|
|
2591
|
+
"Shift-Tab": () => this.editor.commands.command(({ state: e, dispatch: t, view: n }) => ue(-1)(e, t, n))
|
|
2580
2592
|
};
|
|
2581
2593
|
},
|
|
2582
2594
|
extendNodeSchema(e) {
|
|
2583
|
-
return { tableRole:
|
|
2595
|
+
return { tableRole: d(g(e, "tableRole", {
|
|
2584
2596
|
name: e.name,
|
|
2585
2597
|
options: e.options,
|
|
2586
2598
|
storage: e.storage
|
|
2587
2599
|
})) };
|
|
2588
2600
|
}
|
|
2589
|
-
}),
|
|
2601
|
+
}), yr = { textColor: q.textColor }, br = u.create({
|
|
2590
2602
|
name: "tableHeader",
|
|
2591
2603
|
addOptions() {
|
|
2592
2604
|
return { HTMLAttributes: {} };
|
|
@@ -2610,17 +2622,17 @@ var Qn = () => new pe({
|
|
|
2610
2622
|
parseHTML() {
|
|
2611
2623
|
return [{
|
|
2612
2624
|
tag: "th",
|
|
2613
|
-
getContent: (e, t) =>
|
|
2625
|
+
getContent: (e, t) => Tr(e, t)
|
|
2614
2626
|
}];
|
|
2615
2627
|
},
|
|
2616
2628
|
renderHTML({ HTMLAttributes: e }) {
|
|
2617
2629
|
return [
|
|
2618
2630
|
"th",
|
|
2619
|
-
|
|
2631
|
+
v(this.options.HTMLAttributes, e),
|
|
2620
2632
|
0
|
|
2621
2633
|
];
|
|
2622
2634
|
}
|
|
2623
|
-
}),
|
|
2635
|
+
}), xr = u.create({
|
|
2624
2636
|
name: "tableCell",
|
|
2625
2637
|
addOptions() {
|
|
2626
2638
|
return { HTMLAttributes: {} };
|
|
@@ -2644,17 +2656,17 @@ var Qn = () => new pe({
|
|
|
2644
2656
|
parseHTML() {
|
|
2645
2657
|
return [{
|
|
2646
2658
|
tag: "td",
|
|
2647
|
-
getContent: (e, t) =>
|
|
2659
|
+
getContent: (e, t) => Tr(e, t)
|
|
2648
2660
|
}];
|
|
2649
2661
|
},
|
|
2650
2662
|
renderHTML({ HTMLAttributes: e }) {
|
|
2651
2663
|
return [
|
|
2652
2664
|
"td",
|
|
2653
|
-
|
|
2665
|
+
v(this.options.HTMLAttributes, e),
|
|
2654
2666
|
0
|
|
2655
2667
|
];
|
|
2656
2668
|
}
|
|
2657
|
-
}),
|
|
2669
|
+
}), Sr = u.create({
|
|
2658
2670
|
name: "table",
|
|
2659
2671
|
content: "tableRow+",
|
|
2660
2672
|
group: "blockContent",
|
|
@@ -2665,7 +2677,7 @@ var Qn = () => new pe({
|
|
|
2665
2677
|
return [{ tag: "table" }];
|
|
2666
2678
|
},
|
|
2667
2679
|
renderHTML({ node: e, HTMLAttributes: t }) {
|
|
2668
|
-
let n =
|
|
2680
|
+
let n = Ve(this.name, "table", {
|
|
2669
2681
|
...this.options.domAttributes?.blockContent || {},
|
|
2670
2682
|
...t
|
|
2671
2683
|
}, this.options.domAttributes?.inlineContent || {}), r = document.createElement("colgroup");
|
|
@@ -2678,11 +2690,11 @@ var Qn = () => new pe({
|
|
|
2678
2690
|
},
|
|
2679
2691
|
addNodeView() {
|
|
2680
2692
|
return ({ node: e, HTMLAttributes: t }) => {
|
|
2681
|
-
class n extends
|
|
2693
|
+
class n extends ce {
|
|
2682
2694
|
constructor(e, t, n) {
|
|
2683
2695
|
super(e, t), this.node = e, this.cellMinWidth = t, this.blockContentHTMLAttributes = n;
|
|
2684
2696
|
let r = document.createElement("div");
|
|
2685
|
-
r.className =
|
|
2697
|
+
r.className = D("bn-block-content", n.class), r.setAttribute("data-content-type", "table");
|
|
2686
2698
|
for (let [e, t] of Object.entries(n)) e !== "class" && r.setAttribute(e, t);
|
|
2687
2699
|
let i = this.dom, a = document.createElement("div");
|
|
2688
2700
|
a.className = "tableWrapper-inner", a.appendChild(i.firstChild), i.appendChild(a), r.appendChild(i);
|
|
@@ -2692,6 +2704,14 @@ var Qn = () => new pe({
|
|
|
2692
2704
|
ignoreMutation(e) {
|
|
2693
2705
|
return !e.target.closest(".tableWrapper-inner") || super.ignoreMutation(e);
|
|
2694
2706
|
}
|
|
2707
|
+
update(e) {
|
|
2708
|
+
if (!super.update(e)) return !1;
|
|
2709
|
+
for (let [t, n] of Object.entries(yr)) {
|
|
2710
|
+
let r = O(t), i = e.attrs[t];
|
|
2711
|
+
i === n.default ? this.dom.removeAttribute(r) : this.dom.setAttribute(r, String(i));
|
|
2712
|
+
}
|
|
2713
|
+
return !0;
|
|
2714
|
+
}
|
|
2695
2715
|
}
|
|
2696
2716
|
return new n(e, 120, {
|
|
2697
2717
|
...this.options.domAttributes?.blockContent || {},
|
|
@@ -2699,7 +2719,7 @@ var Qn = () => new pe({
|
|
|
2699
2719
|
});
|
|
2700
2720
|
};
|
|
2701
2721
|
}
|
|
2702
|
-
}),
|
|
2722
|
+
}), Cr = u.create({
|
|
2703
2723
|
name: "tableParagraph",
|
|
2704
2724
|
group: "tableContent",
|
|
2705
2725
|
content: "inline*",
|
|
@@ -2721,7 +2741,7 @@ var Qn = () => new pe({
|
|
|
2721
2741
|
0
|
|
2722
2742
|
];
|
|
2723
2743
|
}
|
|
2724
|
-
}),
|
|
2744
|
+
}), wr = u.create({
|
|
2725
2745
|
name: "tableRow",
|
|
2726
2746
|
addOptions() {
|
|
2727
2747
|
return { HTMLAttributes: {} };
|
|
@@ -2735,34 +2755,34 @@ var Qn = () => new pe({
|
|
|
2735
2755
|
renderHTML({ HTMLAttributes: e }) {
|
|
2736
2756
|
return [
|
|
2737
2757
|
"tr",
|
|
2738
|
-
|
|
2758
|
+
v(this.options.HTMLAttributes, e),
|
|
2739
2759
|
0
|
|
2740
2760
|
];
|
|
2741
2761
|
}
|
|
2742
2762
|
});
|
|
2743
|
-
function
|
|
2763
|
+
function Tr(e, t) {
|
|
2744
2764
|
let i = n.fromSchema(t).parse(e, { topNode: t.nodes.blockGroup.create() }), a = [];
|
|
2745
2765
|
return i.content.descendants((e) => {
|
|
2746
2766
|
if (e.isInline) return a.push(e), !1;
|
|
2747
2767
|
}), r.fromArray(a);
|
|
2748
2768
|
}
|
|
2749
|
-
var
|
|
2750
|
-
node:
|
|
2769
|
+
var Er = () => Je({
|
|
2770
|
+
node: Sr,
|
|
2751
2771
|
type: "table",
|
|
2752
2772
|
content: "table"
|
|
2753
|
-
},
|
|
2773
|
+
}, yr, [t({
|
|
2754
2774
|
key: "table-extensions",
|
|
2755
2775
|
tiptapExtensions: [
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2776
|
+
vr,
|
|
2777
|
+
Cr,
|
|
2778
|
+
br,
|
|
2779
|
+
xr,
|
|
2780
|
+
wr
|
|
2761
2781
|
]
|
|
2762
2782
|
}), t({
|
|
2763
2783
|
key: "table-keyboard-delete",
|
|
2764
2784
|
keyboardShortcuts: { Backspace: ({ editor: e }) => {
|
|
2765
|
-
if (!(e.prosemirrorState.selection instanceof
|
|
2785
|
+
if (!(e.prosemirrorState.selection instanceof oe)) return !1;
|
|
2766
2786
|
let t = e.getTextCursorPosition().block, n = t.content, r = 0;
|
|
2767
2787
|
for (let e of n.rows) for (let t of e.cells) {
|
|
2768
2788
|
if ("type" in t && t.content.length > 0 || !("type" in t) && t.length > 0) return !1;
|
|
@@ -2775,14 +2795,14 @@ var br = () => Ge({
|
|
|
2775
2795
|
(e.getPrevBlock(t) || e.getNextBlock(t)) && e.setTextCursorPosition(t), e.removeBlocks([t]);
|
|
2776
2796
|
}), !0);
|
|
2777
2797
|
} }
|
|
2778
|
-
})]),
|
|
2798
|
+
})]), Dr = (e) => ({
|
|
2779
2799
|
url: e.src || void 0,
|
|
2780
2800
|
previewWidth: e.width || void 0
|
|
2781
|
-
}),
|
|
2801
|
+
}), Or = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z\"></path></svg>", kr = A((e) => ({
|
|
2782
2802
|
type: "video",
|
|
2783
2803
|
propSchema: {
|
|
2784
|
-
textAlignment:
|
|
2785
|
-
backgroundColor:
|
|
2804
|
+
textAlignment: q.textAlignment,
|
|
2805
|
+
backgroundColor: q.backgroundColor,
|
|
2786
2806
|
name: { default: "" },
|
|
2787
2807
|
url: { default: "" },
|
|
2788
2808
|
caption: { default: "" },
|
|
@@ -2793,28 +2813,28 @@ var br = () => Ge({
|
|
|
2793
2813
|
}
|
|
2794
2814
|
},
|
|
2795
2815
|
content: "none"
|
|
2796
|
-
})),
|
|
2816
|
+
})), Ar = (e) => (e) => {
|
|
2797
2817
|
if (e.tagName === "VIDEO") {
|
|
2798
2818
|
if (e.closest("figure")) return;
|
|
2799
|
-
let { backgroundColor: t } =
|
|
2819
|
+
let { backgroundColor: t } = J(e);
|
|
2800
2820
|
return {
|
|
2801
|
-
...
|
|
2821
|
+
...Dr(e),
|
|
2802
2822
|
backgroundColor: t
|
|
2803
2823
|
};
|
|
2804
2824
|
}
|
|
2805
2825
|
if (e.tagName === "FIGURE") {
|
|
2806
|
-
let t =
|
|
2826
|
+
let t = sn(e, "video");
|
|
2807
2827
|
if (!t) return;
|
|
2808
|
-
let { targetElement: n, caption: r } = t, { backgroundColor: i } =
|
|
2828
|
+
let { targetElement: n, caption: r } = t, { backgroundColor: i } = J(e);
|
|
2809
2829
|
return {
|
|
2810
|
-
...
|
|
2830
|
+
...Dr(n),
|
|
2811
2831
|
backgroundColor: i,
|
|
2812
2832
|
caption: r
|
|
2813
2833
|
};
|
|
2814
2834
|
}
|
|
2815
|
-
},
|
|
2835
|
+
}, jr = j(kr, (e) => ({
|
|
2816
2836
|
meta: { fileBlockAccept: ["video/*"] },
|
|
2817
|
-
parse:
|
|
2837
|
+
parse: Ar(e),
|
|
2818
2838
|
render(t, n) {
|
|
2819
2839
|
let r = document.createElement("div");
|
|
2820
2840
|
r.innerHTML = e.icon ?? "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z\"></path></svg>";
|
|
@@ -2823,7 +2843,7 @@ var br = () => Ge({
|
|
|
2823
2843
|
let a = document.createElement("video");
|
|
2824
2844
|
return a.className = "bn-visual-media", n.resolveFileUrl ? n.resolveFileUrl(t.props.url).then((e) => {
|
|
2825
2845
|
a.src = e;
|
|
2826
|
-
}) : a.src = t.props.url, a.controls = !0, a.contentEditable = "false", a.draggable = !1, a.width = t.props.previewWidth, i.appendChild(a),
|
|
2846
|
+
}) : a.src = t.props.url, a.controls = !0, a.contentEditable = "false", a.draggable = !1, a.width = t.props.previewWidth, i.appendChild(a), Bn(t, n, { dom: i }, i, r.firstElementChild);
|
|
2827
2847
|
},
|
|
2828
2848
|
toExternalHTML(e) {
|
|
2829
2849
|
if (!e.props.url) {
|
|
@@ -2831,10 +2851,10 @@ var br = () => Ge({
|
|
|
2831
2851
|
return e.textContent = "Add video", { dom: e };
|
|
2832
2852
|
}
|
|
2833
2853
|
let t;
|
|
2834
|
-
return e.props.showPreview ? (t = document.createElement("video"), t.src = e.props.url, e.props.previewWidth && (t.width = e.props.previewWidth)) : (t = document.createElement("a"), t.href = e.props.url, t.textContent = e.props.name || e.props.url), e.props.caption ? e.props.showPreview ?
|
|
2854
|
+
return e.props.showPreview ? (t = document.createElement("video"), t.src = e.props.url, e.props.previewWidth && (t.width = e.props.previewWidth)) : (t = document.createElement("a"), t.href = e.props.url, t.textContent = e.props.name || e.props.url), e.props.caption ? e.props.showPreview ? fn(t, e.props.caption) : pn(t, e.props.caption) : { dom: t };
|
|
2835
2855
|
},
|
|
2836
2856
|
runsBefore: ["file"]
|
|
2837
|
-
})),
|
|
2857
|
+
})), Mr = async (e) => {
|
|
2838
2858
|
let t = new FormData();
|
|
2839
2859
|
return t.append("file", e), (await (await fetch("https://tmpfiles.org/api/v1/upload", {
|
|
2840
2860
|
method: "POST",
|
|
@@ -2859,40 +2879,40 @@ function Z(e, t, n) {
|
|
|
2859
2879
|
}
|
|
2860
2880
|
return !0;
|
|
2861
2881
|
}
|
|
2862
|
-
function
|
|
2882
|
+
function Nr(e, t, n, r) {
|
|
2863
2883
|
return Z(t, n, r) && e.type === n;
|
|
2864
2884
|
}
|
|
2865
|
-
function
|
|
2866
|
-
return e instanceof
|
|
2885
|
+
function Pr(e) {
|
|
2886
|
+
return e instanceof oe;
|
|
2867
2887
|
}
|
|
2868
2888
|
//#endregion
|
|
2869
2889
|
//#region src/api/positionMapping.ts
|
|
2870
|
-
var
|
|
2871
|
-
function
|
|
2872
|
-
if (
|
|
2890
|
+
var Fr = /* @__PURE__ */ new Map();
|
|
2891
|
+
function Ir(e) {
|
|
2892
|
+
if (Fr.has(e)) return Fr.get(e);
|
|
2873
2893
|
let t = new a();
|
|
2874
2894
|
return e._tiptapEditor.on("transaction", ({ transaction: e }) => {
|
|
2875
2895
|
t.appendMapping(e.mapping);
|
|
2876
2896
|
}), e._tiptapEditor.on("destroy", () => {
|
|
2877
|
-
|
|
2878
|
-
}),
|
|
2897
|
+
Fr.delete(e);
|
|
2898
|
+
}), Fr.set(e, t), t;
|
|
2879
2899
|
}
|
|
2880
|
-
function
|
|
2881
|
-
let r =
|
|
2900
|
+
function Lr(e, t, n = "left") {
|
|
2901
|
+
let r = Ee.getState(e.prosemirrorState);
|
|
2882
2902
|
if (!r) {
|
|
2883
|
-
let r =
|
|
2903
|
+
let r = Ir(e), i = r.maps.length;
|
|
2884
2904
|
return () => r.slice(i).map(t, n === "left" ? -1 : 1);
|
|
2885
2905
|
}
|
|
2886
|
-
let i =
|
|
2906
|
+
let i = we(t + (n === "right" ? 1 : -1), r.binding.type, r.binding.mapping);
|
|
2887
2907
|
return () => {
|
|
2888
|
-
let t =
|
|
2908
|
+
let t = Ee.getState(e.prosemirrorState), r = Te(t.doc, t.binding.type, i, t.binding.mapping);
|
|
2889
2909
|
if (r === null) throw Error("Position not found, cannot track positions");
|
|
2890
2910
|
return r + (n === "right" ? -1 : 1);
|
|
2891
2911
|
};
|
|
2892
2912
|
}
|
|
2893
2913
|
//#endregion
|
|
2894
2914
|
//#region src/extensions/SuggestionMenu/SuggestionMenu.ts
|
|
2895
|
-
var
|
|
2915
|
+
var Rr = m((e) => e.type.name === "blockContainer"), zr = class {
|
|
2896
2916
|
state;
|
|
2897
2917
|
emitUpdate;
|
|
2898
2918
|
rootEl;
|
|
@@ -2939,7 +2959,7 @@ var Mr = p((e) => e.type.name === "blockContainer"), Nr = class {
|
|
|
2939
2959
|
to: this.editor.transact((e) => e.selection.from)
|
|
2940
2960
|
}).run();
|
|
2941
2961
|
};
|
|
2942
|
-
}, Q = new
|
|
2962
|
+
}, Q = new ee("SuggestionMenuPlugin"), Br = t(({ editor: t }) => {
|
|
2943
2963
|
let n = /* @__PURE__ */ new Map(), r, i = e(void 0);
|
|
2944
2964
|
return {
|
|
2945
2965
|
key: "suggestionMenu",
|
|
@@ -2966,9 +2986,9 @@ var Mr = p((e) => e.type.name === "blockContainer"), Nr = class {
|
|
|
2966
2986
|
});
|
|
2967
2987
|
}));
|
|
2968
2988
|
},
|
|
2969
|
-
prosemirrorPlugins: [new
|
|
2989
|
+
prosemirrorPlugins: [new y({
|
|
2970
2990
|
key: Q,
|
|
2971
|
-
view: (e) => (r = new
|
|
2991
|
+
view: (e) => (r = new zr(t, (e, t) => {
|
|
2972
2992
|
i.setState({
|
|
2973
2993
|
...t,
|
|
2974
2994
|
triggerCharacter: e
|
|
@@ -2981,7 +3001,7 @@ var Mr = p((e) => e.type.name === "blockContainer"), Nr = class {
|
|
|
2981
3001
|
let o = e.getMeta(Q);
|
|
2982
3002
|
if (typeof o == "object" && o) {
|
|
2983
3003
|
n && r?.closeMenu();
|
|
2984
|
-
let e =
|
|
3004
|
+
let e = Lr(t, a.selection.from - o.triggerCharacter.length);
|
|
2985
3005
|
return {
|
|
2986
3006
|
triggerCharacter: o.triggerCharacter,
|
|
2987
3007
|
deleteTriggerCharacter: o.deleteTriggerCharacter !== !1,
|
|
@@ -3015,14 +3035,14 @@ var Mr = p((e) => e.type.name === "blockContainer"), Nr = class {
|
|
|
3015
3035
|
let t = this.getState(e);
|
|
3016
3036
|
if (t === void 0) return null;
|
|
3017
3037
|
if (!t.deleteTriggerCharacter) {
|
|
3018
|
-
let n =
|
|
3019
|
-
if (n) return
|
|
3038
|
+
let n = Rr(e.selection);
|
|
3039
|
+
if (n) return Ce.create(e.doc, [Se.node(n.pos, n.pos + n.node.nodeSize, {
|
|
3020
3040
|
nodeName: "span",
|
|
3021
3041
|
class: "bn-suggestion-decorator",
|
|
3022
3042
|
"data-decoration-id": t.decorationId
|
|
3023
3043
|
})]);
|
|
3024
3044
|
}
|
|
3025
|
-
return
|
|
3045
|
+
return Ce.create(e.doc, [Se.inline(t.queryStartPos() - t.triggerCharacter.length, t.queryStartPos(), {
|
|
3026
3046
|
nodeName: "span",
|
|
3027
3047
|
class: "bn-suggestion-decorator",
|
|
3028
3048
|
"data-decoration-id": t.decorationId
|
|
@@ -3034,7 +3054,7 @@ var Mr = p((e) => e.type.name === "blockContainer"), Nr = class {
|
|
|
3034
3054
|
});
|
|
3035
3055
|
//#endregion
|
|
3036
3056
|
//#region src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts
|
|
3037
|
-
function
|
|
3057
|
+
function Vr(e) {
|
|
3038
3058
|
let t = e.getTextCursorPosition().block, n = e.schema.blockSchema[t.type].content;
|
|
3039
3059
|
for (; n === "none";) {
|
|
3040
3060
|
if (t = e.getTextCursorPosition().nextBlock, t === void 0) return;
|
|
@@ -3045,9 +3065,9 @@ function $(e, t) {
|
|
|
3045
3065
|
let n = e.getTextCursorPosition().block;
|
|
3046
3066
|
if (n.content === void 0) throw Error("Slash Menu open in a block that doesn't contain content.");
|
|
3047
3067
|
let r;
|
|
3048
|
-
return Array.isArray(n.content) && (n.content.length === 1 &&
|
|
3068
|
+
return Array.isArray(n.content) && (n.content.length === 1 && b(n.content[0]) && n.content[0].type === "text" && n.content[0].text === "/" || n.content.length === 0) ? (r = e.updateBlock(n, t), e.setTextCursorPosition(r)) : (r = e.insertBlocks([t], n, "after")[0], e.setTextCursorPosition(e.getTextCursorPosition().nextBlock)), Vr(e), r;
|
|
3049
3069
|
}
|
|
3050
|
-
function
|
|
3070
|
+
function Hr(e) {
|
|
3051
3071
|
let t = [];
|
|
3052
3072
|
return Z(e, "heading", { level: "number" }) && (e.schema.blockSchema.heading.propSchema.level.values || []).filter((e) => e <= 3).forEach((n) => {
|
|
3053
3073
|
t.push({
|
|
@@ -3057,7 +3077,7 @@ function Ir(e) {
|
|
|
3057
3077
|
props: { level: n }
|
|
3058
3078
|
});
|
|
3059
3079
|
},
|
|
3060
|
-
badge:
|
|
3080
|
+
badge: E(`Mod-Alt-${n}`),
|
|
3061
3081
|
key: n === 1 ? "heading" : `heading_${n}`,
|
|
3062
3082
|
...e.dictionary.slash_menu[n === 1 ? "heading" : `heading_${n}`]
|
|
3063
3083
|
});
|
|
@@ -3071,42 +3091,42 @@ function Ir(e) {
|
|
|
3071
3091
|
onItemClick: () => {
|
|
3072
3092
|
$(e, { type: "toggleListItem" });
|
|
3073
3093
|
},
|
|
3074
|
-
badge:
|
|
3094
|
+
badge: E("Mod-Shift-6"),
|
|
3075
3095
|
key: "toggle_list",
|
|
3076
3096
|
...e.dictionary.slash_menu.toggle_list
|
|
3077
3097
|
}), Z(e, "numberedListItem") && t.push({
|
|
3078
3098
|
onItemClick: () => {
|
|
3079
3099
|
$(e, { type: "numberedListItem" });
|
|
3080
3100
|
},
|
|
3081
|
-
badge:
|
|
3101
|
+
badge: E("Mod-Shift-7"),
|
|
3082
3102
|
key: "numbered_list",
|
|
3083
3103
|
...e.dictionary.slash_menu.numbered_list
|
|
3084
3104
|
}), Z(e, "bulletListItem") && t.push({
|
|
3085
3105
|
onItemClick: () => {
|
|
3086
3106
|
$(e, { type: "bulletListItem" });
|
|
3087
3107
|
},
|
|
3088
|
-
badge:
|
|
3108
|
+
badge: E("Mod-Shift-8"),
|
|
3089
3109
|
key: "bullet_list",
|
|
3090
3110
|
...e.dictionary.slash_menu.bullet_list
|
|
3091
3111
|
}), Z(e, "checkListItem") && t.push({
|
|
3092
3112
|
onItemClick: () => {
|
|
3093
3113
|
$(e, { type: "checkListItem" });
|
|
3094
3114
|
},
|
|
3095
|
-
badge:
|
|
3115
|
+
badge: E("Mod-Shift-9"),
|
|
3096
3116
|
key: "check_list",
|
|
3097
3117
|
...e.dictionary.slash_menu.check_list
|
|
3098
3118
|
}), Z(e, "paragraph") && t.push({
|
|
3099
3119
|
onItemClick: () => {
|
|
3100
3120
|
$(e, { type: "paragraph" });
|
|
3101
3121
|
},
|
|
3102
|
-
badge:
|
|
3122
|
+
badge: E("Mod-Alt-0"),
|
|
3103
3123
|
key: "paragraph",
|
|
3104
3124
|
...e.dictionary.slash_menu.paragraph
|
|
3105
3125
|
}), Z(e, "codeBlock") && t.push({
|
|
3106
3126
|
onItemClick: () => {
|
|
3107
3127
|
$(e, { type: "codeBlock" });
|
|
3108
3128
|
},
|
|
3109
|
-
badge:
|
|
3129
|
+
badge: E("Mod-Alt-c"),
|
|
3110
3130
|
key: "code_block",
|
|
3111
3131
|
...e.dictionary.slash_menu.code_block
|
|
3112
3132
|
}), Z(e, "divider") && t.push({
|
|
@@ -3139,28 +3159,28 @@ function Ir(e) {
|
|
|
3139
3159
|
}), Z(e, "image", { url: "string" }) && t.push({
|
|
3140
3160
|
onItemClick: () => {
|
|
3141
3161
|
let t = $(e, { type: "image" });
|
|
3142
|
-
e.getExtension(
|
|
3162
|
+
e.getExtension(X)?.showMenu(t.id);
|
|
3143
3163
|
},
|
|
3144
3164
|
key: "image",
|
|
3145
3165
|
...e.dictionary.slash_menu.image
|
|
3146
3166
|
}), Z(e, "video", { url: "string" }) && t.push({
|
|
3147
3167
|
onItemClick: () => {
|
|
3148
3168
|
let t = $(e, { type: "video" });
|
|
3149
|
-
e.getExtension(
|
|
3169
|
+
e.getExtension(X)?.showMenu(t.id);
|
|
3150
3170
|
},
|
|
3151
3171
|
key: "video",
|
|
3152
3172
|
...e.dictionary.slash_menu.video
|
|
3153
3173
|
}), Z(e, "audio", { url: "string" }) && t.push({
|
|
3154
3174
|
onItemClick: () => {
|
|
3155
3175
|
let t = $(e, { type: "audio" });
|
|
3156
|
-
e.getExtension(
|
|
3176
|
+
e.getExtension(X)?.showMenu(t.id);
|
|
3157
3177
|
},
|
|
3158
3178
|
key: "audio",
|
|
3159
3179
|
...e.dictionary.slash_menu.audio
|
|
3160
3180
|
}), Z(e, "file", { url: "string" }) && t.push({
|
|
3161
3181
|
onItemClick: () => {
|
|
3162
3182
|
let t = $(e, { type: "file" });
|
|
3163
|
-
e.getExtension(
|
|
3183
|
+
e.getExtension(X)?.showMenu(t.id);
|
|
3164
3184
|
},
|
|
3165
3185
|
key: "file",
|
|
3166
3186
|
...e.dictionary.slash_menu.file
|
|
@@ -3189,13 +3209,13 @@ function Ir(e) {
|
|
|
3189
3209
|
props: { level: n }
|
|
3190
3210
|
});
|
|
3191
3211
|
},
|
|
3192
|
-
badge:
|
|
3212
|
+
badge: E(`Mod-Alt-${n}`),
|
|
3193
3213
|
key: `heading_${n}`,
|
|
3194
3214
|
...e.dictionary.slash_menu[`heading_${n}`]
|
|
3195
3215
|
});
|
|
3196
3216
|
}), t.push({
|
|
3197
3217
|
onItemClick: () => {
|
|
3198
|
-
e.getExtension(
|
|
3218
|
+
e.getExtension(Br)?.openSuggestionMenu(":", {
|
|
3199
3219
|
deleteTriggerCharacter: !0,
|
|
3200
3220
|
ignoreQueryLength: !0
|
|
3201
3221
|
});
|
|
@@ -3204,17 +3224,17 @@ function Ir(e) {
|
|
|
3204
3224
|
...e.dictionary.slash_menu.emoji
|
|
3205
3225
|
}), t;
|
|
3206
3226
|
}
|
|
3207
|
-
function
|
|
3227
|
+
function Ur(e, t) {
|
|
3208
3228
|
return e.filter(({ title: e, aliases: n }) => e.toLowerCase().includes(t.toLowerCase()) || n && n.filter((e) => e.toLowerCase().includes(t.toLowerCase())).length !== 0);
|
|
3209
3229
|
}
|
|
3210
3230
|
//#endregion
|
|
3211
3231
|
//#region src/blocks/PageBreak/getPageBreakSlashMenuItems.ts
|
|
3212
|
-
function
|
|
3232
|
+
function Wr(e) {
|
|
3213
3233
|
return "pageBreak" in e.schema.blockSchema;
|
|
3214
3234
|
}
|
|
3215
|
-
function
|
|
3235
|
+
function Gr(e) {
|
|
3216
3236
|
let t = [];
|
|
3217
|
-
return
|
|
3237
|
+
return Wr(e) && t.push({
|
|
3218
3238
|
...e.dictionary.slash_menu.page_break,
|
|
3219
3239
|
onItemClick: () => {
|
|
3220
3240
|
$(e, { type: "pageBreak" });
|
|
@@ -3224,22 +3244,22 @@ function zr(e) {
|
|
|
3224
3244
|
}
|
|
3225
3245
|
//#endregion
|
|
3226
3246
|
//#region src/blocks/defaultBlocks.ts
|
|
3227
|
-
var
|
|
3228
|
-
audio:
|
|
3229
|
-
bulletListItem:
|
|
3230
|
-
checkListItem:
|
|
3231
|
-
codeBlock:
|
|
3232
|
-
divider:
|
|
3233
|
-
file:
|
|
3234
|
-
heading:
|
|
3235
|
-
image:
|
|
3236
|
-
numberedListItem:
|
|
3237
|
-
paragraph:
|
|
3238
|
-
quote:
|
|
3239
|
-
table:
|
|
3240
|
-
toggleListItem:
|
|
3241
|
-
video:
|
|
3242
|
-
},
|
|
3247
|
+
var Kr = {
|
|
3248
|
+
audio: bn(),
|
|
3249
|
+
bulletListItem: $n(),
|
|
3250
|
+
checkListItem: tr(),
|
|
3251
|
+
codeBlock: Tn(),
|
|
3252
|
+
divider: On(),
|
|
3253
|
+
file: Mn(),
|
|
3254
|
+
heading: zn(),
|
|
3255
|
+
image: qn(),
|
|
3256
|
+
numberedListItem: or(),
|
|
3257
|
+
paragraph: pr(),
|
|
3258
|
+
quote: hr(),
|
|
3259
|
+
table: Er(),
|
|
3260
|
+
toggleListItem: cr(),
|
|
3261
|
+
video: jr()
|
|
3262
|
+
}, qr = bt({
|
|
3243
3263
|
type: "textColor",
|
|
3244
3264
|
propSchema: "string"
|
|
3245
3265
|
}, {
|
|
@@ -3252,7 +3272,7 @@ var Br = {
|
|
|
3252
3272
|
},
|
|
3253
3273
|
toExternalHTML: (e) => {
|
|
3254
3274
|
let t = document.createElement("span");
|
|
3255
|
-
return e !==
|
|
3275
|
+
return e !== q.textColor.default && (t.style.color = e in K ? K[e].text : e), {
|
|
3256
3276
|
dom: t,
|
|
3257
3277
|
contentDOM: t
|
|
3258
3278
|
};
|
|
@@ -3260,7 +3280,7 @@ var Br = {
|
|
|
3260
3280
|
parse: (e) => {
|
|
3261
3281
|
if (e.tagName === "SPAN" && e.style.color) return e.style.color;
|
|
3262
3282
|
}
|
|
3263
|
-
}),
|
|
3283
|
+
}), Jr = bt({
|
|
3264
3284
|
type: "backgroundColor",
|
|
3265
3285
|
propSchema: "string"
|
|
3266
3286
|
}, {
|
|
@@ -3273,7 +3293,7 @@ var Br = {
|
|
|
3273
3293
|
},
|
|
3274
3294
|
toExternalHTML: (e) => {
|
|
3275
3295
|
let t = document.createElement("span");
|
|
3276
|
-
return e !==
|
|
3296
|
+
return e !== q.backgroundColor.default && (t.style.backgroundColor = e in K ? K[e].background : e), {
|
|
3277
3297
|
dom: t,
|
|
3278
3298
|
contentDOM: t
|
|
3279
3299
|
};
|
|
@@ -3281,15 +3301,26 @@ var Br = {
|
|
|
3281
3301
|
parse: (e) => {
|
|
3282
3302
|
if (e.tagName === "SPAN" && e.style.backgroundColor) return e.style.backgroundColor;
|
|
3283
3303
|
}
|
|
3284
|
-
}),
|
|
3285
|
-
bold:
|
|
3286
|
-
italic:
|
|
3287
|
-
underline:
|
|
3288
|
-
strike:
|
|
3289
|
-
code:
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3304
|
+
}), Yr = {
|
|
3305
|
+
bold: z(De, "boolean"),
|
|
3306
|
+
italic: z(ke, "boolean"),
|
|
3307
|
+
underline: z(je, "boolean"),
|
|
3308
|
+
strike: z(Ae, "boolean"),
|
|
3309
|
+
code: z(Oe.extend({ addInputRules() {
|
|
3310
|
+
return [_({
|
|
3311
|
+
find: /(^|[^`])`([^`]+)`(?!`)$/,
|
|
3312
|
+
type: this.type
|
|
3313
|
+
}), new c({
|
|
3314
|
+
find: /(^|[^`])`([^`]+)`(?!`) $/,
|
|
3315
|
+
handler: ({ state: e, range: t, match: n }) => {
|
|
3316
|
+
let { tr: r, schema: i } = e, a = n[1], o = n[2];
|
|
3317
|
+
r.replaceWith(t.from + a.length, t.to, [i.text(o, [this.type.create()]), i.text(" ")]);
|
|
3318
|
+
}
|
|
3319
|
+
})];
|
|
3320
|
+
} }), "boolean"),
|
|
3321
|
+
textColor: qr,
|
|
3322
|
+
backgroundColor: Jr
|
|
3323
|
+
}, Xr = vt(Yr), Zr = {
|
|
3293
3324
|
text: {
|
|
3294
3325
|
config: "text",
|
|
3295
3326
|
implementation: {}
|
|
@@ -3298,16 +3329,16 @@ var Br = {
|
|
|
3298
3329
|
config: "link",
|
|
3299
3330
|
implementation: {}
|
|
3300
3331
|
}
|
|
3301
|
-
},
|
|
3332
|
+
}, Qr = ht(Zr), $r = class e extends At {
|
|
3302
3333
|
static create(t) {
|
|
3303
3334
|
return new e({
|
|
3304
|
-
blockSpecs: t?.blockSpecs ??
|
|
3305
|
-
inlineContentSpecs: t?.inlineContentSpecs ??
|
|
3306
|
-
styleSpecs: t?.styleSpecs ??
|
|
3335
|
+
blockSpecs: t?.blockSpecs ?? Kr,
|
|
3336
|
+
inlineContentSpecs: t?.inlineContentSpecs ?? Zr,
|
|
3337
|
+
styleSpecs: t?.styleSpecs ?? Yr
|
|
3307
3338
|
});
|
|
3308
3339
|
}
|
|
3309
3340
|
};
|
|
3310
3341
|
//#endregion
|
|
3311
|
-
export {
|
|
3342
|
+
export { Mn as $, pt as $t, lr as A, Ge as An, Kt as At, $n as B, w as Bn, It as Bt, yr as C, Xe as Cn, $t as Ct, hr as D, k as Dn, Yt as Dt, mr as E, Ke as En, Jt as Et, ar as F, ze as Fn, Rt as Ft, Wn as G, Fe as Gn, R as Gt, Hn as H, S as Hn, Ot as Ht, or as I, Be as In, Pt as It, Rn as J, Pe as Jn, vt as Jt, Gn as K, Ie as Kn, _t as Kt, tr as L, D as Ln, Nt as Lt, dr as M, He as Mn, Ht as Mt, sr as N, Ue as Nn, Vt as Nt, fr as O, O as On, W as Ot, cr as P, E as Pn, Bt as Pt, An as Q, mt as Qt, er as R, T as Rn, jt as Rt, Er as S, j as Sn, en as St, gr as T, qe as Tn, G as Tt, Un as U, C as Un, bt as Ut, Jn as V, Le as Vn, At as Vt, qn as W, x as Wn, yt as Wt, Fn as X, dt as Xt, zn as Y, gt as Yt, Pn as Z, ft as Zt, Mr as _, Qe as _n, on as _t, Xr as a, ct as an, En as at, jr as b, Ye as bn, nn as bt, Gr as c, rt as cn, vn as ct, $ as d, P as dn, bn as dt, ht as en, jn as et, Br as f, F as fn, mn as ft, Pr as g, tt as gn, rn as gt, Z as h, et as hn, q as ht, Zr as i, L as in, Tn as it, ur as j, Ve as jn, zt as jt, pr as k, We as kn, U as kt, Ur as l, it as ln, yn as lt, Nr as m, $e as mn, Y as mt, Kr as n, st as nn, On as nt, Yr as o, ut as on, hn as ot, Lr as p, N as pn, X as pt, Kn as q, b as qn, z as qt, Qr as r, lt as rn, wn as rt, Wr as s, ot as sn, _n as st, $r as t, I as tn, Dn as tt, Hr as u, at as un, gn as ut, Or as v, M as vn, an as vt, _r as w, Je as wn, Xt as wt, Ar as x, A as xn, K as xt, kr as y, Ze as yn, J as yt, Qn as z, Re as zn, Ft as zt };
|
|
3312
3343
|
|
|
3313
|
-
//# sourceMappingURL=blocks-
|
|
3344
|
+
//# sourceMappingURL=blocks-UU7EM-QM.js.map
|