@blocknote/core 0.52.0 → 0.53.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 +6 -6
- package/dist/{blocks-CiuUGa1E.js → blocks-BEJW9OM_.js} +516 -476
- package/dist/blocks-BEJW9OM_.js.map +1 -0
- package/dist/blocks-BPmJglFo.cjs +12 -0
- package/dist/blocks-BPmJglFo.cjs.map +1 -0
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +2 -2
- package/dist/extensions-AitWbYdJ.cjs +52 -0
- package/dist/extensions-AitWbYdJ.cjs.map +1 -0
- package/dist/{extensions-CrUGDOks.js → extensions-BR5hkAio.js} +421 -391
- package/dist/extensions-BR5hkAio.js.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +3 -3
- package/dist/src-BHPuOo7W.cjs +21 -0
- package/dist/src-BHPuOo7W.cjs.map +1 -0
- package/dist/{src-DTF83Cl9.js → src-BUXut68d.js} +797 -779
- package/dist/src-BUXut68d.js.map +1 -0
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/dist/y.cjs +1 -1
- package/dist/y.js +9 -9
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.js +1 -1
- package/package.json +14 -14
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +10 -1
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +42 -8
- package/src/api/exporters/markdown/markdownExporter.ts +10 -1
- package/src/api/parsers/html/parseHTML.ts +43 -0
- package/src/blocks/Table/TableExtension.test.ts +102 -0
- package/src/blocks/ToggleWrapper/createToggleWrapper.ts +16 -5
- package/src/blocks/defaultBlockTypeGuards.ts +6 -0
- package/src/editor/Block.css +51 -1
- package/src/extensions/SideMenu/SideMenu.ts +20 -3
- package/src/extensions/SuggestionMenu/SuggestionMenu.test.ts +118 -0
- package/src/extensions/SuggestionMenu/SuggestionMenu.ts +40 -27
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +13 -3
- package/src/extensions/TableHandles/TableHandles.ts +25 -12
- package/src/extensions/TrailingNode/TrailingNode.ts +98 -32
- package/src/index.ts +1 -0
- package/src/schema/blocks/createSpec.ts +16 -3
- package/src/schema/blocks/internal.test.ts +86 -0
- package/src/schema/blocks/internal.ts +64 -0
- package/src/schema/inlineContent/createSpec.ts +9 -1
- package/src/schema/nodeViewMutations.test.ts +121 -0
- package/src/schema/nodeViewMutations.ts +46 -0
- package/types/src/api/exporters/html/util/serializeBlocksExternalHTML.d.ts +13 -0
- package/types/src/blocks/defaultBlockTypeGuards.d.ts +2 -0
- package/types/src/extensions/SideMenu/SideMenu.d.ts +5 -0
- package/types/src/extensions/SuggestionMenu/SuggestionMenu.d.ts +6 -0
- package/types/src/extensions/TrailingNode/TrailingNode.d.ts +5 -4
- package/types/src/index.d.ts +1 -0
- package/types/src/schema/blocks/internal.d.ts +21 -0
- package/types/src/schema/blocks/internal.test.d.ts +1 -0
- package/types/src/schema/nodeViewMutations.d.ts +3 -0
- package/types/src/schema/nodeViewMutations.test.d.ts +1 -0
- package/dist/blocks-BqHv0xhc.cjs +0 -12
- package/dist/blocks-BqHv0xhc.cjs.map +0 -1
- package/dist/blocks-CiuUGa1E.js.map +0 -1
- package/dist/extensions-CrUGDOks.js.map +0 -1
- package/dist/extensions-Ghr9QqqR.cjs +0 -52
- package/dist/extensions-Ghr9QqqR.cjs.map +0 -1
- package/dist/src-DTF83Cl9.js.map +0 -1
- package/dist/src-OfbaVbMw.cjs +0 -21
- package/dist/src-OfbaVbMw.cjs.map +0 -1
|
@@ -3,27 +3,27 @@ import { DOMParser as r, Fragment as i, Slice as a } from "prosemirror-model";
|
|
|
3
3
|
import { ReplaceStep as o } from "prosemirror-transform";
|
|
4
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
5
|
import { uuidv4 as ee } from "lib0/random";
|
|
6
|
-
import { Plugin as te, PluginKey as ne, TextSelection as
|
|
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
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
6
|
+
import { Plugin as te, PluginKey as ne, TextSelection as re } from "prosemirror-state";
|
|
7
|
+
import { DOMParser as ie, DOMSerializer as ae, Fragment as oe } from "@tiptap/pm/model";
|
|
8
|
+
import { CellSelection as se, TableMap as ce, TableView as le, columnResizing as ue, goToNextCell as de, isInTable as fe, moveCellForward as pe, nextCell as me, selectionCell as he, tableEditing as ge } from "prosemirror-tables";
|
|
9
|
+
import { createHighlightPlugin as _e } from "prosemirror-highlight";
|
|
10
|
+
import { createParser as ve } from "prosemirror-highlight/shiki";
|
|
11
|
+
import { Plugin as ye, PluginKey as be } from "@tiptap/pm/state";
|
|
12
|
+
import { Decoration as xe, DecorationSet as Se } from "@tiptap/pm/view";
|
|
13
|
+
import { Decoration as Ce, DecorationSet as we } from "prosemirror-view";
|
|
14
|
+
import Te from "@tiptap/extension-bold";
|
|
15
|
+
import Ee from "@tiptap/extension-code";
|
|
16
|
+
import De from "@tiptap/extension-italic";
|
|
17
|
+
import Oe from "@tiptap/extension-strike";
|
|
18
|
+
import ke from "@tiptap/extension-underline";
|
|
19
19
|
//#region src/api/getBlockInfoFromPos.ts
|
|
20
|
-
function
|
|
20
|
+
function Ae(e) {
|
|
21
21
|
return e.marks.some((e) => ["y-attributed-delete"].includes(e.type.name));
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function je(e, t) {
|
|
24
24
|
let n = e.attrs.id;
|
|
25
25
|
if (!n) throw Error(`Node ${e.type.name} does not have an ID`);
|
|
26
|
-
if (
|
|
26
|
+
if (Ae(e)) {
|
|
27
27
|
let r = 0, i = !1;
|
|
28
28
|
if (t.descendants((t) => {
|
|
29
29
|
if (i) return !1;
|
|
@@ -37,7 +37,7 @@ function Ae(e, t) {
|
|
|
37
37
|
}
|
|
38
38
|
return n;
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function Me(e, t) {
|
|
41
41
|
let n = e.resolve(t);
|
|
42
42
|
if (n.nodeAfter && n.nodeAfter.type.isInGroup("bnBlock")) return {
|
|
43
43
|
posBeforeNode: n.pos,
|
|
@@ -61,7 +61,7 @@ function je(e, t) {
|
|
|
61
61
|
node: o.nodeAfter
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function y(e, t) {
|
|
65
65
|
if (!e.type.isInGroup("bnBlock")) throw Error(`Attempted to get bnBlock node at position but found node of different type ${e.type.name}`);
|
|
66
66
|
let n = e, r = t, i = {
|
|
67
67
|
node: n,
|
|
@@ -105,34 +105,34 @@ function Me(e, t) {
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
function b(e) {
|
|
108
|
-
return
|
|
108
|
+
return y(e.node, e.posBeforeNode);
|
|
109
109
|
}
|
|
110
110
|
function Ne(e) {
|
|
111
111
|
if (!e.nodeAfter) throw Error(`Attempted to get blockContainer node at position ${e.pos} but a node at this position does not exist`);
|
|
112
|
-
return
|
|
112
|
+
return y(e.nodeAfter, e.pos);
|
|
113
113
|
}
|
|
114
|
-
function
|
|
115
|
-
return
|
|
114
|
+
function Pe(e) {
|
|
115
|
+
return Fe(e, e.selection.anchor);
|
|
116
116
|
}
|
|
117
|
-
function
|
|
118
|
-
return b(
|
|
117
|
+
function Fe(e, t) {
|
|
118
|
+
return b(Me(e.doc, t));
|
|
119
119
|
}
|
|
120
120
|
//#endregion
|
|
121
121
|
//#region src/extensions/tiptap-extensions/UniqueID/UniqueID.ts
|
|
122
|
-
function
|
|
122
|
+
function Ie(e, t = JSON.stringify) {
|
|
123
123
|
let n = {};
|
|
124
124
|
return e.filter((e) => {
|
|
125
125
|
let r = t(e);
|
|
126
126
|
return Object.prototype.hasOwnProperty.call(n, r) ? !1 : n[r] = !0;
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
|
-
function Ie(e) {
|
|
130
|
-
return Fe(e.filter((t, n) => e.indexOf(t) !== n));
|
|
131
|
-
}
|
|
132
129
|
function Le(e) {
|
|
130
|
+
return Ie(e.filter((t, n) => e.indexOf(t) !== n));
|
|
131
|
+
}
|
|
132
|
+
function Re(e) {
|
|
133
133
|
return e.marks.some((e) => e.type.name === "y-attributed-delete");
|
|
134
134
|
}
|
|
135
|
-
var
|
|
135
|
+
var ze = s.create({
|
|
136
136
|
name: "uniqueID",
|
|
137
137
|
priority: 1e4,
|
|
138
138
|
addOptions() {
|
|
@@ -173,9 +173,9 @@ var Re = s.create({
|
|
|
173
173
|
if (!(e.some((e) => e.docChanged) && !t.doc.eq(n.doc))) return;
|
|
174
174
|
let { tr: r } = n, { types: i, generateID: a } = this.options, o = f(t.doc, e), { mapping: s } = o;
|
|
175
175
|
if (h(o).forEach(({ newRange: e }) => {
|
|
176
|
-
let o = p(n.doc, e, (e) => i.includes(e.type.name)), c =
|
|
176
|
+
let o = p(n.doc, e, (e) => i.includes(e.type.name)), c = Le(o.map(({ node: e }) => e.attrs.id).filter((e) => e !== null));
|
|
177
177
|
o.forEach(({ node: e, pos: i }) => {
|
|
178
|
-
if (
|
|
178
|
+
if (Re(e)) return;
|
|
179
179
|
let o = r.doc.nodeAt(i)?.attrs.id;
|
|
180
180
|
if (o === null) {
|
|
181
181
|
let o = t.doc.type.createAndFill().content;
|
|
@@ -196,7 +196,7 @@ var Re = s.create({
|
|
|
196
196
|
return;
|
|
197
197
|
}
|
|
198
198
|
let { deleted: l } = s.invert().mapResult(i);
|
|
199
|
-
l && c.includes(o) && !
|
|
199
|
+
l && c.includes(o) && !Ae(e) && r.setNodeMarkup(i, void 0, {
|
|
200
200
|
...e.attrs,
|
|
201
201
|
id: a()
|
|
202
202
|
});
|
|
@@ -245,19 +245,19 @@ var Re = s.create({
|
|
|
245
245
|
});
|
|
246
246
|
//#endregion
|
|
247
247
|
//#region src/schema/inlineContent/types.ts
|
|
248
|
-
function
|
|
248
|
+
function Be(e) {
|
|
249
249
|
return e.type === "link";
|
|
250
250
|
}
|
|
251
|
-
function
|
|
251
|
+
function Ve(e) {
|
|
252
252
|
return typeof e != "string" && e.type === "link";
|
|
253
253
|
}
|
|
254
|
-
function
|
|
254
|
+
function x(e) {
|
|
255
255
|
return typeof e != "string" && e.type === "text";
|
|
256
256
|
}
|
|
257
257
|
//#endregion
|
|
258
258
|
//#region src/util/table.ts
|
|
259
|
-
function
|
|
260
|
-
return
|
|
259
|
+
function He(e) {
|
|
260
|
+
return C(e) ? { ...e } : S(e) ? {
|
|
261
261
|
type: "tableCell",
|
|
262
262
|
content: [].concat(e.content),
|
|
263
263
|
props: {
|
|
@@ -279,17 +279,17 @@ function C(e) {
|
|
|
279
279
|
}
|
|
280
280
|
};
|
|
281
281
|
}
|
|
282
|
-
function
|
|
282
|
+
function S(e) {
|
|
283
283
|
return e != null && typeof e != "string" && !Array.isArray(e) && e.type === "tableCell";
|
|
284
284
|
}
|
|
285
|
-
function
|
|
286
|
-
return
|
|
285
|
+
function C(e) {
|
|
286
|
+
return S(e) && e.props !== void 0 && e.content !== void 0;
|
|
287
287
|
}
|
|
288
|
-
function
|
|
289
|
-
return
|
|
288
|
+
function w(e) {
|
|
289
|
+
return C(e) ? e.props.colspan ?? 1 : 1;
|
|
290
290
|
}
|
|
291
|
-
function
|
|
292
|
-
return
|
|
291
|
+
function T(e) {
|
|
292
|
+
return C(e) ? e.props.rowspan ?? 1 : 1;
|
|
293
293
|
}
|
|
294
294
|
//#endregion
|
|
295
295
|
//#region src/util/typescript.ts
|
|
@@ -327,7 +327,7 @@ function Ke(e, t, n, r) {
|
|
|
327
327
|
};
|
|
328
328
|
}
|
|
329
329
|
var qe = (e, t) => {
|
|
330
|
-
let n =
|
|
330
|
+
let n = H(e, t.pmSchema);
|
|
331
331
|
n.type.name === "blockContainer" && (n = n.firstChild);
|
|
332
332
|
let r = t.pmSchema.nodes[n.type.name].spec.toDOM;
|
|
333
333
|
if (r === void 0) throw Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");
|
|
@@ -346,34 +346,43 @@ function Je(e, t = "<br>") {
|
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
348
|
//#endregion
|
|
349
|
+
//#region src/schema/nodeViewMutations.ts
|
|
350
|
+
function Ye(e, t) {
|
|
351
|
+
return e.type === "selection" ? !1 : !t || e.type === "attributes" ? !0 : !t.contains(e.target);
|
|
352
|
+
}
|
|
353
|
+
function Xe(e) {
|
|
354
|
+
let t = e.ignoreMutation?.bind(e), n = e.contentDOM;
|
|
355
|
+
e.ignoreMutation = (e) => Ye(e, n) ? !0 : t ? t(e) : !1;
|
|
356
|
+
}
|
|
357
|
+
//#endregion
|
|
349
358
|
//#region src/api/pmUtil.ts
|
|
350
359
|
function k(e) {
|
|
351
360
|
return "doc" in e ? e.doc.type.schema : e.type.schema;
|
|
352
361
|
}
|
|
353
|
-
function
|
|
362
|
+
function Ze(e) {
|
|
354
363
|
return e.cached.blockNoteEditor;
|
|
355
364
|
}
|
|
356
|
-
function
|
|
357
|
-
return
|
|
365
|
+
function Qe(e) {
|
|
366
|
+
return Ze(e).schema;
|
|
358
367
|
}
|
|
359
|
-
function
|
|
360
|
-
return
|
|
368
|
+
function $e(e) {
|
|
369
|
+
return Qe(e).blockSchema;
|
|
361
370
|
}
|
|
362
|
-
function
|
|
363
|
-
return
|
|
371
|
+
function et(e) {
|
|
372
|
+
return Qe(e).inlineContentSchema;
|
|
364
373
|
}
|
|
365
374
|
function A(e) {
|
|
366
|
-
return
|
|
375
|
+
return Qe(e).styleSchema;
|
|
367
376
|
}
|
|
368
|
-
function
|
|
369
|
-
return
|
|
377
|
+
function tt(e) {
|
|
378
|
+
return Ze(e).blockCache;
|
|
370
379
|
}
|
|
371
|
-
function
|
|
372
|
-
return
|
|
380
|
+
function nt(e, t) {
|
|
381
|
+
return $e(e)[t.name]?.content === "plain";
|
|
373
382
|
}
|
|
374
383
|
//#endregion
|
|
375
384
|
//#region src/api/nodeConversions/nodeToBlock.ts
|
|
376
|
-
function
|
|
385
|
+
function rt(e, t, n) {
|
|
377
386
|
let r = {
|
|
378
387
|
type: "tableContent",
|
|
379
388
|
columnWidths: [],
|
|
@@ -388,10 +397,10 @@ function tt(e, t, n) {
|
|
|
388
397
|
t ??= Array(e.attrs.colspan ?? 1).fill(void 0), r.columnWidths.push(...t);
|
|
389
398
|
}), s.cells = e.content.content.map((e, r) => (i[o] || (i[o] = []), i[o][r] = e.type.name === "tableHeader", {
|
|
390
399
|
type: "tableCell",
|
|
391
|
-
content: e.content.content.map((e) =>
|
|
400
|
+
content: e.content.content.map((e) => it(e, t, n)).reduce((e, t) => {
|
|
392
401
|
if (!e.length) return t;
|
|
393
402
|
let n = e[e.length - 1], r = t[0];
|
|
394
|
-
return r &&
|
|
403
|
+
return r && x(n) && x(r) && JSON.stringify(n.styles) === JSON.stringify(r.styles) ? (n.text += "\n" + r.text, e.push(...t.slice(1)), e) : (e.push(...t), e);
|
|
395
404
|
}, []),
|
|
396
405
|
props: {
|
|
397
406
|
colspan: e.attrs.colspan,
|
|
@@ -406,12 +415,12 @@ function tt(e, t, n) {
|
|
|
406
415
|
for (let e = 0; e < i[0]?.length; e++) i?.every((t) => t[e]) && (r.headerCols = (r.headerCols ?? 0) + 1);
|
|
407
416
|
return r;
|
|
408
417
|
}
|
|
409
|
-
function
|
|
418
|
+
function it(e, t, n) {
|
|
410
419
|
let r = [], i;
|
|
411
420
|
return e.content.forEach((e) => {
|
|
412
421
|
if (e.type.name === "hardBreak") {
|
|
413
|
-
if (i) if (
|
|
414
|
-
else if (
|
|
422
|
+
if (i) if (x(i)) i.text += "\n";
|
|
423
|
+
else if (Be(i)) i.content[i.content.length - 1].text += "\n";
|
|
415
424
|
else throw Error("unexpected");
|
|
416
425
|
else i = {
|
|
417
426
|
type: "text",
|
|
@@ -425,7 +434,7 @@ function j(e, t, n) {
|
|
|
425
434
|
console.warn("unrecognized inline content type", e.type.name);
|
|
426
435
|
return;
|
|
427
436
|
}
|
|
428
|
-
i &&= (r.push(i), void 0), r.push(
|
|
437
|
+
i &&= (r.push(i), void 0), r.push(at(e, t, n));
|
|
429
438
|
return;
|
|
430
439
|
}
|
|
431
440
|
let a = {}, o;
|
|
@@ -440,7 +449,7 @@ function j(e, t, n) {
|
|
|
440
449
|
else if (e.propSchema === "string") a[e.type] = t.attrs.stringValue;
|
|
441
450
|
else throw new E(e.propSchema);
|
|
442
451
|
}
|
|
443
|
-
i ?
|
|
452
|
+
i ? x(i) ? o ? (r.push(i), i = {
|
|
444
453
|
type: "link",
|
|
445
454
|
href: o.attrs.href,
|
|
446
455
|
content: [{
|
|
@@ -452,7 +461,7 @@ function j(e, t, n) {
|
|
|
452
461
|
type: "text",
|
|
453
462
|
text: e.textContent,
|
|
454
463
|
styles: a
|
|
455
|
-
}) :
|
|
464
|
+
}) : Be(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({
|
|
456
465
|
type: "text",
|
|
457
466
|
text: e.textContent,
|
|
458
467
|
styles: a
|
|
@@ -483,7 +492,7 @@ function j(e, t, n) {
|
|
|
483
492
|
};
|
|
484
493
|
}), i && r.push(i), r;
|
|
485
494
|
}
|
|
486
|
-
function
|
|
495
|
+
function at(e, t, n) {
|
|
487
496
|
if (e.type.name === "text" || e.type.name === "link") throw Error("unexpected");
|
|
488
497
|
let r = {}, i = t[e.type.name];
|
|
489
498
|
for (let [t, n] of Object.entries(e.attrs)) {
|
|
@@ -491,22 +500,22 @@ function nt(e, t, n) {
|
|
|
491
500
|
t in i.propSchema && (r[t] = n);
|
|
492
501
|
}
|
|
493
502
|
let a;
|
|
494
|
-
return a = i.content === "styled" ?
|
|
503
|
+
return a = i.content === "styled" ? it(e, t, n) : void 0, {
|
|
495
504
|
type: e.type.name,
|
|
496
505
|
props: r,
|
|
497
506
|
content: a
|
|
498
507
|
};
|
|
499
508
|
}
|
|
500
|
-
function
|
|
501
|
-
let n = e.type.schema, r =
|
|
509
|
+
function j(e, t) {
|
|
510
|
+
let n = e.type.schema, r = $e(n), i = et(n), a = A(n), o = tt(n);
|
|
502
511
|
if (!e.type.isInGroup("bnBlock")) throw Error("Node should be a bnBlock, but is instead: " + e.type.name);
|
|
503
512
|
let s = o?.get(e);
|
|
504
513
|
if (s) return s;
|
|
505
|
-
let c =
|
|
514
|
+
let c = y(e, 0), l;
|
|
506
515
|
try {
|
|
507
|
-
l =
|
|
516
|
+
l = je(c.bnBlock.node, t);
|
|
508
517
|
} catch {
|
|
509
|
-
l =
|
|
518
|
+
l = ze.options.generateID();
|
|
510
519
|
}
|
|
511
520
|
let u = r[c.blockNoteType];
|
|
512
521
|
if (!u) throw Error("Block is of an unrecognized type: " + c.blockNoteType);
|
|
@@ -520,15 +529,15 @@ function M(e, t) {
|
|
|
520
529
|
}
|
|
521
530
|
let f = r[c.blockNoteType], p = [];
|
|
522
531
|
c.childContainer?.node.forEach((e) => {
|
|
523
|
-
p.push(
|
|
532
|
+
p.push(j(e, t));
|
|
524
533
|
});
|
|
525
534
|
let m;
|
|
526
535
|
if (f.content === "inline") {
|
|
527
536
|
if (!c.isBlockContainer) throw Error("impossible");
|
|
528
|
-
m =
|
|
537
|
+
m = it(c.blockContent.node, i, a);
|
|
529
538
|
} else if (f.content === "table") {
|
|
530
539
|
if (!c.isBlockContainer) throw Error("impossible");
|
|
531
|
-
m =
|
|
540
|
+
m = rt(c.blockContent.node, i, a);
|
|
532
541
|
} else if (f.content === "plain") {
|
|
533
542
|
if (!c.isBlockContainer) throw Error("impossible");
|
|
534
543
|
let e = c.blockContent.node.textContent;
|
|
@@ -548,11 +557,11 @@ function M(e, t) {
|
|
|
548
557
|
};
|
|
549
558
|
return o?.set(e, h), h;
|
|
550
559
|
}
|
|
551
|
-
function
|
|
560
|
+
function ot(e) {
|
|
552
561
|
let t = [];
|
|
553
|
-
return e.firstChild && e.firstChild.descendants((n) => (t.push(
|
|
562
|
+
return e.firstChild && e.firstChild.descendants((n) => (t.push(j(n, e)), !1)), t;
|
|
554
563
|
}
|
|
555
|
-
function
|
|
564
|
+
function st(e) {
|
|
556
565
|
function t(n, r, i) {
|
|
557
566
|
if (n.type.name !== "blockGroup") throw Error("unexpected");
|
|
558
567
|
let a = [], o, s;
|
|
@@ -567,7 +576,7 @@ function it(e) {
|
|
|
567
576
|
o = e.blockCutAtStart, f && (s = e.blockCutAtEnd), a.push(...e.blocks);
|
|
568
577
|
return;
|
|
569
578
|
}
|
|
570
|
-
let p =
|
|
579
|
+
let p = j(c, e.content.firstChild), m = c.childCount > 1 ? c.child(1) : void 0, h = [];
|
|
571
580
|
if (m) {
|
|
572
581
|
let e = t(m, 0, f ? Math.max(0, i - 1) : 0);
|
|
573
582
|
h = e.blocks, f && (s = e.blockCutAtEnd);
|
|
@@ -592,14 +601,14 @@ function it(e) {
|
|
|
592
601
|
}
|
|
593
602
|
//#endregion
|
|
594
603
|
//#region src/util/string.ts
|
|
595
|
-
function
|
|
604
|
+
function M(e) {
|
|
596
605
|
return "data-" + e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
597
606
|
}
|
|
598
|
-
function
|
|
607
|
+
function ct(e) {
|
|
599
608
|
let t = e.split("/");
|
|
600
609
|
return !t.length || t[t.length - 1] === "" ? e : t[t.length - 1];
|
|
601
610
|
}
|
|
602
|
-
function
|
|
611
|
+
function lt(e) {
|
|
603
612
|
let t = [
|
|
604
613
|
"mp4",
|
|
605
614
|
"webm",
|
|
@@ -620,14 +629,14 @@ function ot(e) {
|
|
|
620
629
|
}
|
|
621
630
|
//#endregion
|
|
622
631
|
//#region src/schema/blocks/internal.ts
|
|
623
|
-
function
|
|
632
|
+
function ut(e) {
|
|
624
633
|
let t = {};
|
|
625
634
|
return Object.entries(e).forEach(([e, n]) => {
|
|
626
635
|
t[e] = {
|
|
627
636
|
default: n.default,
|
|
628
637
|
keepOnSplit: !0,
|
|
629
638
|
parseHTML: (t) => {
|
|
630
|
-
let r = t.getAttribute(
|
|
639
|
+
let r = t.getAttribute(M(e));
|
|
631
640
|
if (r === null) return null;
|
|
632
641
|
if (n.default === void 0 && n.type === "boolean" || n.default !== void 0 && typeof n.default == "boolean") return r === "true" ? !0 : r === "false" ? !1 : null;
|
|
633
642
|
if (n.default === void 0 && n.type === "number" || n.default !== void 0 && typeof n.default == "number") {
|
|
@@ -636,28 +645,37 @@ function st(e) {
|
|
|
636
645
|
}
|
|
637
646
|
return r;
|
|
638
647
|
},
|
|
639
|
-
renderHTML: (t) => t[e] === n.default ? {} : { [
|
|
648
|
+
renderHTML: (t) => t[e] === n.default ? {} : { [M(e)]: t[e] }
|
|
640
649
|
};
|
|
641
650
|
}), t;
|
|
642
651
|
}
|
|
643
|
-
function
|
|
652
|
+
function dt(e, t) {
|
|
644
653
|
let n = e();
|
|
645
654
|
if (n === void 0) throw Error("Cannot find node position");
|
|
646
655
|
let r = t.resolve(n).node();
|
|
647
656
|
if (!r) throw Error("Cannot find block container");
|
|
648
|
-
return
|
|
657
|
+
return j(r, t);
|
|
649
658
|
}
|
|
650
|
-
function
|
|
659
|
+
function ft(e, t, n) {
|
|
660
|
+
try {
|
|
661
|
+
return dt(e, n);
|
|
662
|
+
} catch (e) {
|
|
663
|
+
let r = n.type.schema.nodes.blockContainer?.createAndFill(null, t);
|
|
664
|
+
if (r) return j(r, n);
|
|
665
|
+
throw e;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
function N(e, t, n, r, i = !1, a) {
|
|
651
669
|
let o = document.createElement("div");
|
|
652
670
|
if (a !== void 0) for (let [e, t] of Object.entries(a)) e !== "class" && o.setAttribute(e, t);
|
|
653
671
|
o.className = O("bn-block-content", a?.class || ""), o.setAttribute("data-content-type", t);
|
|
654
|
-
for (let [e, t] of Object.entries(n)) t !== r[e]?.default && o.setAttribute(
|
|
672
|
+
for (let [e, t] of Object.entries(n)) t !== r[e]?.default && o.setAttribute(M(e), t);
|
|
655
673
|
return i && o.setAttribute("data-file-block", ""), o.appendChild(e.dom), e.contentDOM && (e.contentDOM.className = O("bn-inline-content", e.contentDOM.className)), {
|
|
656
674
|
...e,
|
|
657
675
|
dom: o
|
|
658
676
|
};
|
|
659
677
|
}
|
|
660
|
-
function
|
|
678
|
+
function pt(e, t, n) {
|
|
661
679
|
return {
|
|
662
680
|
config: {
|
|
663
681
|
type: e.type,
|
|
@@ -674,12 +692,12 @@ function lt(e, t, n) {
|
|
|
674
692
|
}
|
|
675
693
|
//#endregion
|
|
676
694
|
//#region src/schema/blocks/createSpec.ts
|
|
677
|
-
function
|
|
695
|
+
function mt(e, t) {
|
|
678
696
|
e.stopEvent = (e) => (e.type === "mousedown" && setTimeout(() => {
|
|
679
697
|
t.view.dom.blur();
|
|
680
698
|
}, 10), !0);
|
|
681
699
|
}
|
|
682
|
-
function
|
|
700
|
+
function ht(e, t) {
|
|
683
701
|
let n = [{
|
|
684
702
|
tag: "[data-content-type=" + e.type + "]",
|
|
685
703
|
contentElement: ".bn-inline-content"
|
|
@@ -703,7 +721,7 @@ function dt(e, t) {
|
|
|
703
721
|
if (e.content === "inline" || e.content === "plain") {
|
|
704
722
|
let i = n.cloneNode(!0);
|
|
705
723
|
Je(i, e.content === "plain" || t.meta?.code ? "\n" : "<br>");
|
|
706
|
-
let a =
|
|
724
|
+
let a = ie.fromSchema(r).parse(i, {
|
|
707
725
|
topNode: r.nodes.paragraph.create(),
|
|
708
726
|
preserveWhitespace: !0
|
|
709
727
|
});
|
|
@@ -715,15 +733,15 @@ function dt(e, t) {
|
|
|
715
733
|
let n = t.type === r.linebreakReplacement ? "\n" : t.textContent;
|
|
716
734
|
n && e.push(r.text(n, t.marks));
|
|
717
735
|
}
|
|
718
|
-
}),
|
|
736
|
+
}), oe.fromArray(e);
|
|
719
737
|
}
|
|
720
738
|
return a.content;
|
|
721
739
|
}
|
|
722
|
-
return
|
|
740
|
+
return oe.empty;
|
|
723
741
|
} : void 0
|
|
724
742
|
}), n;
|
|
725
743
|
}
|
|
726
|
-
function
|
|
744
|
+
function gt(t, n, r, i) {
|
|
727
745
|
let a = n.node || u.create({
|
|
728
746
|
name: t.type,
|
|
729
747
|
content: t.content === "inline" ? "inline*" : t.content === "plain" ? "text*" : t.content === "none" ? "" : t.content,
|
|
@@ -737,27 +755,27 @@ function ft(t, n, r, i) {
|
|
|
737
755
|
defining: n.meta?.defining ?? !0,
|
|
738
756
|
priority: i,
|
|
739
757
|
addAttributes() {
|
|
740
|
-
return
|
|
758
|
+
return ut(t.propSchema);
|
|
741
759
|
},
|
|
742
760
|
parseHTML() {
|
|
743
|
-
return
|
|
761
|
+
return ht(t, n);
|
|
744
762
|
},
|
|
745
763
|
renderHTML({ HTMLAttributes: e }) {
|
|
746
764
|
let r = document.createElement("div");
|
|
747
|
-
return
|
|
765
|
+
return N({
|
|
748
766
|
dom: r,
|
|
749
767
|
contentDOM: t.content === "inline" || t.content === "plain" ? r : void 0
|
|
750
768
|
}, t.type, {}, t.propSchema, n.meta?.fileBlockAccept !== void 0, e);
|
|
751
769
|
},
|
|
752
770
|
addNodeView() {
|
|
753
771
|
return (e) => {
|
|
754
|
-
let r = this.options.editor, i =
|
|
772
|
+
let r = this.options.editor, i = ft(e.getPos, e.node, e.view.state.doc), a = this.options.domAttributes?.blockContent || {}, o = n.render.call({
|
|
755
773
|
blockContentDOMAttributes: a,
|
|
756
774
|
props: e,
|
|
757
775
|
renderType: "nodeView",
|
|
758
776
|
propSchema: t.propSchema
|
|
759
777
|
}, i, r);
|
|
760
|
-
return n.meta?.selectable === !1 &&
|
|
778
|
+
return n.meta?.selectable === !1 && mt(o, this.editor), Xe(o), o;
|
|
761
779
|
};
|
|
762
780
|
}
|
|
763
781
|
});
|
|
@@ -792,10 +810,10 @@ function ft(t, n, r, i) {
|
|
|
792
810
|
extensions: r
|
|
793
811
|
};
|
|
794
812
|
}
|
|
795
|
-
function
|
|
813
|
+
function P(e) {
|
|
796
814
|
return e;
|
|
797
815
|
}
|
|
798
|
-
function
|
|
816
|
+
function F(e, t, n) {
|
|
799
817
|
return (r = {}) => {
|
|
800
818
|
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;
|
|
801
819
|
return {
|
|
@@ -804,10 +822,10 @@ function I(e, t, n) {
|
|
|
804
822
|
...a,
|
|
805
823
|
toExternalHTML(e, t, n) {
|
|
806
824
|
let r = a.toExternalHTML?.call({ blockContentDOMAttributes: this.blockContentDOMAttributes }, e, t, n);
|
|
807
|
-
if (r !== void 0) return
|
|
825
|
+
if (r !== void 0) return N(r, e.type, e.props, this.propSchema ?? i.propSchema, a.meta?.fileBlockAccept !== void 0);
|
|
808
826
|
},
|
|
809
827
|
render(e, t) {
|
|
810
|
-
return
|
|
828
|
+
return N(a.render.call({
|
|
811
829
|
blockContentDOMAttributes: this.blockContentDOMAttributes,
|
|
812
830
|
renderType: this.renderType,
|
|
813
831
|
props: this.props
|
|
@@ -820,23 +838,23 @@ function I(e, t, n) {
|
|
|
820
838
|
}
|
|
821
839
|
//#endregion
|
|
822
840
|
//#region src/schema/inlineContent/internal.ts
|
|
823
|
-
function
|
|
824
|
-
return e.dom.setAttribute("data-inline-content-type", t), Object.entries(n).filter(([e, t]) => t !== r[e]?.default).map(([e, t]) => [
|
|
841
|
+
function _t(e, t, n, r) {
|
|
842
|
+
return e.dom.setAttribute("data-inline-content-type", t), Object.entries(n).filter(([e, t]) => t !== r[e]?.default).map(([e, t]) => [M(e), t]).forEach(([t, n]) => e.dom.setAttribute(t, n)), e.contentDOM && e.contentDOM.setAttribute("data-editable", ""), e;
|
|
825
843
|
}
|
|
826
|
-
function
|
|
844
|
+
function vt(e) {
|
|
827
845
|
return { Backspace: ({ editor: t }) => {
|
|
828
846
|
let n = t.state.selection.$from;
|
|
829
847
|
return t.state.selection.empty && n.node().type.name === e.type && n.parentOffset === 0;
|
|
830
848
|
} };
|
|
831
849
|
}
|
|
832
|
-
function
|
|
850
|
+
function yt(e, t) {
|
|
833
851
|
return {
|
|
834
852
|
config: e,
|
|
835
853
|
implementation: t
|
|
836
854
|
};
|
|
837
855
|
}
|
|
838
|
-
function
|
|
839
|
-
return
|
|
856
|
+
function bt(e, t, n) {
|
|
857
|
+
return yt({
|
|
840
858
|
type: e.name,
|
|
841
859
|
propSchema: t,
|
|
842
860
|
content: e.config.content === "inline*" ? "styled" : "none"
|
|
@@ -845,12 +863,12 @@ function gt(e, t, n) {
|
|
|
845
863
|
node: e
|
|
846
864
|
});
|
|
847
865
|
}
|
|
848
|
-
function
|
|
866
|
+
function xt(e) {
|
|
849
867
|
return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, t.config]));
|
|
850
868
|
}
|
|
851
869
|
//#endregion
|
|
852
870
|
//#region src/schema/styles/internal.ts
|
|
853
|
-
function
|
|
871
|
+
function St(e) {
|
|
854
872
|
return e === "boolean" ? {} : { stringValue: {
|
|
855
873
|
default: void 0,
|
|
856
874
|
keepOnSplit: !0,
|
|
@@ -858,17 +876,17 @@ function vt(e) {
|
|
|
858
876
|
renderHTML: (e) => e.stringValue === void 0 ? {} : { "data-value": e.stringValue }
|
|
859
877
|
} };
|
|
860
878
|
}
|
|
861
|
-
function
|
|
879
|
+
function I(e, t, n, r) {
|
|
862
880
|
return e.dom.setAttribute("data-style-type", t), r === "string" && e.dom.setAttribute("data-value", n), e.contentDOM && e.contentDOM.setAttribute("data-editable", ""), e;
|
|
863
881
|
}
|
|
864
|
-
function
|
|
882
|
+
function Ct(e, t) {
|
|
865
883
|
return {
|
|
866
884
|
config: e,
|
|
867
885
|
implementation: t
|
|
868
886
|
};
|
|
869
887
|
}
|
|
870
|
-
function
|
|
871
|
-
return
|
|
888
|
+
function L(e, t) {
|
|
889
|
+
return Ct({
|
|
872
890
|
type: e.name,
|
|
873
891
|
propSchema: t
|
|
874
892
|
}, {
|
|
@@ -876,25 +894,25 @@ function R(e, t) {
|
|
|
876
894
|
render(t, n) {
|
|
877
895
|
let r = n.pmSchema.marks[e.name].spec.toDOM;
|
|
878
896
|
if (r === void 0) throw Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");
|
|
879
|
-
let i = n.pmSchema.mark(e.name, { stringValue: t }), a =
|
|
897
|
+
let i = n.pmSchema.mark(e.name, { stringValue: t }), a = ae.renderSpec(document, r(i, !0));
|
|
880
898
|
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.");
|
|
881
899
|
return a;
|
|
882
900
|
},
|
|
883
901
|
toExternalHTML(t, n) {
|
|
884
902
|
let r = n.pmSchema.marks[e.name].spec.toDOM;
|
|
885
903
|
if (r === void 0) throw Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");
|
|
886
|
-
let i = n.pmSchema.mark(e.name, { stringValue: t }), a =
|
|
904
|
+
let i = n.pmSchema.mark(e.name, { stringValue: t }), a = ae.renderSpec(document, r(i, !0));
|
|
887
905
|
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.");
|
|
888
906
|
return a;
|
|
889
907
|
}
|
|
890
908
|
});
|
|
891
909
|
}
|
|
892
|
-
function
|
|
910
|
+
function wt(e) {
|
|
893
911
|
return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, t.config]));
|
|
894
912
|
}
|
|
895
913
|
//#endregion
|
|
896
914
|
//#region src/schema/styles/createSpec.ts
|
|
897
|
-
function
|
|
915
|
+
function Tt(e, t) {
|
|
898
916
|
let n = [{
|
|
899
917
|
tag: `[data-style-type="${e.type}"]`,
|
|
900
918
|
contentElement: (e) => {
|
|
@@ -912,33 +930,33 @@ function xt(e, t) {
|
|
|
912
930
|
}
|
|
913
931
|
}), n;
|
|
914
932
|
}
|
|
915
|
-
function
|
|
933
|
+
function Et(e, t) {
|
|
916
934
|
let n = l.create({
|
|
917
935
|
name: e.type,
|
|
918
936
|
addAttributes() {
|
|
919
|
-
return
|
|
937
|
+
return St(e.propSchema);
|
|
920
938
|
},
|
|
921
939
|
parseHTML() {
|
|
922
|
-
return
|
|
940
|
+
return Tt(e, t.parse);
|
|
923
941
|
},
|
|
924
942
|
renderHTML({ mark: n }) {
|
|
925
|
-
return
|
|
943
|
+
return I((t.toExternalHTML || t.render)(n.attrs.stringValue), e.type, n.attrs.stringValue, e.propSchema);
|
|
926
944
|
},
|
|
927
945
|
addMarkView() {
|
|
928
|
-
return ({ mark: n }) =>
|
|
946
|
+
return ({ mark: n }) => I(t.render(n.attrs.stringValue), e.type, n.attrs.stringValue, e.propSchema);
|
|
929
947
|
}
|
|
930
948
|
});
|
|
931
|
-
return
|
|
949
|
+
return Ct(e, {
|
|
932
950
|
...t,
|
|
933
951
|
mark: n,
|
|
934
|
-
render: (n) =>
|
|
935
|
-
toExternalHTML: (n) =>
|
|
952
|
+
render: (n) => I(t.render(n), e.type, n, e.propSchema),
|
|
953
|
+
toExternalHTML: (n) => I((t.toExternalHTML || t.render)(n), e.type, n, e.propSchema)
|
|
936
954
|
});
|
|
937
955
|
}
|
|
938
956
|
//#endregion
|
|
939
957
|
//#region src/util/topo-sort.ts
|
|
940
|
-
function
|
|
941
|
-
let t =
|
|
958
|
+
function Dt(e) {
|
|
959
|
+
let t = kt(e), { roots: n, nonRoots: r } = At(t), i = [];
|
|
942
960
|
for (; n.size;) {
|
|
943
961
|
i.push(n);
|
|
944
962
|
let r = /* @__PURE__ */ new Set();
|
|
@@ -953,13 +971,13 @@ function Ct(e) {
|
|
|
953
971
|
}
|
|
954
972
|
n = r;
|
|
955
973
|
}
|
|
956
|
-
if (r =
|
|
974
|
+
if (r = At(t).nonRoots, r.size) throw Error(`Cycle(s) detected; toposort only works on acyclic graphs. Cyclic nodes: ${Array.from(r).join(", ")}`);
|
|
957
975
|
return i;
|
|
958
976
|
}
|
|
959
|
-
function
|
|
960
|
-
return
|
|
977
|
+
function Ot(e) {
|
|
978
|
+
return Dt(jt(e));
|
|
961
979
|
}
|
|
962
|
-
function
|
|
980
|
+
function kt(e) {
|
|
963
981
|
let t = /* @__PURE__ */ new Map();
|
|
964
982
|
for (let [n, r] of e.entries()) {
|
|
965
983
|
t.has(n) || t.set(n, 0);
|
|
@@ -970,7 +988,7 @@ function Tt(e) {
|
|
|
970
988
|
}
|
|
971
989
|
return t;
|
|
972
990
|
}
|
|
973
|
-
function
|
|
991
|
+
function At(e) {
|
|
974
992
|
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
975
993
|
for (let [r, i] of e.entries()) i === 0 ? t.add(r) : n.add(r);
|
|
976
994
|
return {
|
|
@@ -978,7 +996,7 @@ function Et(e) {
|
|
|
978
996
|
nonRoots: n
|
|
979
997
|
};
|
|
980
998
|
}
|
|
981
|
-
function
|
|
999
|
+
function jt(e) {
|
|
982
1000
|
let t = /* @__PURE__ */ new Map();
|
|
983
1001
|
for (let [n, r] of e.entries()) {
|
|
984
1002
|
t.has(n) || t.set(n, /* @__PURE__ */ new Set());
|
|
@@ -986,26 +1004,26 @@ function Dt(e) {
|
|
|
986
1004
|
}
|
|
987
1005
|
return t;
|
|
988
1006
|
}
|
|
989
|
-
function
|
|
1007
|
+
function Mt() {
|
|
990
1008
|
return /* @__PURE__ */ new Map();
|
|
991
1009
|
}
|
|
992
|
-
function
|
|
1010
|
+
function Nt(e, t, n) {
|
|
993
1011
|
return e.has(t) || e.set(t, /* @__PURE__ */ new Set()), e.get(t).add(n), e;
|
|
994
1012
|
}
|
|
995
|
-
function
|
|
996
|
-
let t =
|
|
1013
|
+
function Pt(e) {
|
|
1014
|
+
let t = Mt();
|
|
997
1015
|
for (let n of e) Array.isArray(n.runsBefore) && n.runsBefore.length > 0 ? n.runsBefore.forEach((e) => {
|
|
998
|
-
|
|
999
|
-
}) :
|
|
1000
|
-
let n =
|
|
1016
|
+
Nt(t, n.key, e);
|
|
1017
|
+
}) : Nt(t, "default", n.key);
|
|
1018
|
+
let n = Ot(t), r = n.findIndex((e) => e.has("default"));
|
|
1001
1019
|
return (e) => 91 + (n.findIndex((t) => t.has(e)) + r) * 10;
|
|
1002
1020
|
}
|
|
1003
1021
|
//#endregion
|
|
1004
1022
|
//#region src/schema/schema.ts
|
|
1005
|
-
function
|
|
1023
|
+
function Ft(e) {
|
|
1006
1024
|
return e && Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0));
|
|
1007
1025
|
}
|
|
1008
|
-
var
|
|
1026
|
+
var It = class {
|
|
1009
1027
|
opts;
|
|
1010
1028
|
BlockNoteEditor = "only for types";
|
|
1011
1029
|
Block = "only for types";
|
|
@@ -1022,14 +1040,14 @@ var Mt = class {
|
|
|
1022
1040
|
this.blockSpecs = t, this.styleSpecs = r, this.styleSchema = o, this.inlineContentSpecs = n, this.blockSchema = i, this.inlineContentSchema = a;
|
|
1023
1041
|
}
|
|
1024
1042
|
init() {
|
|
1025
|
-
let e =
|
|
1043
|
+
let e = Pt(Object.entries({
|
|
1026
1044
|
...this.opts.blockSpecs,
|
|
1027
1045
|
...this.opts.inlineContentSpecs,
|
|
1028
1046
|
...this.opts.styleSpecs
|
|
1029
1047
|
}).map(([e, t]) => ({
|
|
1030
1048
|
key: e,
|
|
1031
1049
|
runsBefore: t.implementation?.runsBefore ?? []
|
|
1032
|
-
}))), t = Object.fromEntries(Object.entries(this.opts.blockSpecs).map(([t, n]) => [t,
|
|
1050
|
+
}))), t = Object.fromEntries(Object.entries(this.opts.blockSpecs).map(([t, n]) => [t, gt(n.config, n.implementation, n.extensions, e(t))])), n = Object.fromEntries(Object.entries(this.opts.inlineContentSpecs).map(([t, n]) => typeof n.config == "object" ? [t, {
|
|
1033
1051
|
...n,
|
|
1034
1052
|
implementation: {
|
|
1035
1053
|
...n.implementation,
|
|
@@ -1045,10 +1063,10 @@ var Mt = class {
|
|
|
1045
1063
|
return {
|
|
1046
1064
|
blockSpecs: t,
|
|
1047
1065
|
blockSchema: Object.fromEntries(Object.entries(t).map(([e, t]) => [e, t.config])),
|
|
1048
|
-
inlineContentSpecs:
|
|
1049
|
-
styleSpecs:
|
|
1050
|
-
inlineContentSchema:
|
|
1051
|
-
styleSchema:
|
|
1066
|
+
inlineContentSpecs: Ft(n),
|
|
1067
|
+
styleSpecs: Ft(r),
|
|
1068
|
+
inlineContentSchema: xt(n),
|
|
1069
|
+
styleSchema: wt(r)
|
|
1052
1070
|
};
|
|
1053
1071
|
}
|
|
1054
1072
|
extend(e) {
|
|
@@ -1059,8 +1077,8 @@ var Mt = class {
|
|
|
1059
1077
|
};
|
|
1060
1078
|
//#endregion
|
|
1061
1079
|
//#region src/api/blockManipulation/tables/tables.ts
|
|
1062
|
-
function
|
|
1063
|
-
let { height: t, width: n } =
|
|
1080
|
+
function R(e) {
|
|
1081
|
+
let { height: t, width: n } = Lt(e), r = Array(t).fill(!1).map(() => Array(n).fill(null)), i = (e, i) => {
|
|
1064
1082
|
for (let a = e; a < t; a++) for (let e = i; e < n; e++) if (!r[a][e]) return {
|
|
1065
1083
|
row: a,
|
|
1066
1084
|
col: e
|
|
@@ -1068,7 +1086,7 @@ function z(e) {
|
|
|
1068
1086
|
throw Error("Unable to create occupancy grid for table, no more available cells");
|
|
1069
1087
|
};
|
|
1070
1088
|
for (let t = 0; t < e.content.rows.length; t++) for (let n = 0; n < e.content.rows[t].cells.length; n++) {
|
|
1071
|
-
let a =
|
|
1089
|
+
let a = He(e.content.rows[t].cells[n]), o = T(a), s = w(a), { row: c, col: l } = i(t, n);
|
|
1072
1090
|
for (let e = c; e < c + o; e++) for (let i = l; i < l + s; i++) {
|
|
1073
1091
|
if (r[e][i]) throw Error(`Unable to create occupancy grid for table, cell at ${e},${i} is already occupied`);
|
|
1074
1092
|
r[e][i] = {
|
|
@@ -1082,11 +1100,11 @@ function z(e) {
|
|
|
1082
1100
|
}
|
|
1083
1101
|
return r;
|
|
1084
1102
|
}
|
|
1085
|
-
function
|
|
1103
|
+
function z(e) {
|
|
1086
1104
|
let t = /* @__PURE__ */ new Set();
|
|
1087
1105
|
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) }));
|
|
1088
1106
|
}
|
|
1089
|
-
function
|
|
1107
|
+
function B(e, t, n = R(t)) {
|
|
1090
1108
|
for (let t = 0; t < n.length; t++) for (let r = 0; r < n[t].length; r++) {
|
|
1091
1109
|
let i = n[t][r];
|
|
1092
1110
|
if (i && i.row === e.row && i.col === e.col) return {
|
|
@@ -1097,19 +1115,19 @@ function V(e, t, n = z(t)) {
|
|
|
1097
1115
|
}
|
|
1098
1116
|
throw Error(`Unable to resolve relative table cell indices for table, cell at ${e.row},${e.col} is not occupied`);
|
|
1099
1117
|
}
|
|
1100
|
-
function
|
|
1118
|
+
function Lt(e) {
|
|
1101
1119
|
let t = e.content.rows.length, n = 0;
|
|
1102
1120
|
return e.content.rows.forEach((e) => {
|
|
1103
1121
|
let t = 0;
|
|
1104
1122
|
e.cells.forEach((e) => {
|
|
1105
|
-
t +=
|
|
1123
|
+
t += w(e);
|
|
1106
1124
|
}), n = Math.max(n, t);
|
|
1107
1125
|
}), {
|
|
1108
1126
|
height: t,
|
|
1109
1127
|
width: n
|
|
1110
1128
|
};
|
|
1111
1129
|
}
|
|
1112
|
-
function
|
|
1130
|
+
function Rt(e, t, n = R(t)) {
|
|
1113
1131
|
let r = n[e.row]?.[e.col];
|
|
1114
1132
|
if (r) return {
|
|
1115
1133
|
row: r.row,
|
|
@@ -1117,8 +1135,8 @@ function Pt(e, t, n = z(t)) {
|
|
|
1117
1135
|
cell: r.cell
|
|
1118
1136
|
};
|
|
1119
1137
|
}
|
|
1120
|
-
function
|
|
1121
|
-
let n =
|
|
1138
|
+
function zt(e, t) {
|
|
1139
|
+
let n = R(e);
|
|
1122
1140
|
if (t < 0 || t >= n.length) return [];
|
|
1123
1141
|
let r = 0;
|
|
1124
1142
|
for (let e = 0; e < t; e++) {
|
|
@@ -1126,14 +1144,14 @@ function Ft(e, t) {
|
|
|
1126
1144
|
if (!e) return [];
|
|
1127
1145
|
r += e.rowspan;
|
|
1128
1146
|
}
|
|
1129
|
-
let i = Array(n[0].length).fill(!1).map((t, i) =>
|
|
1147
|
+
let i = Array(n[0].length).fill(!1).map((t, i) => Rt({
|
|
1130
1148
|
row: r,
|
|
1131
1149
|
col: i
|
|
1132
1150
|
}, e, n)).filter((e) => e !== void 0);
|
|
1133
1151
|
return i.filter((e, t) => i.findIndex((t) => t.row === e.row && t.col === e.col) === t);
|
|
1134
1152
|
}
|
|
1135
|
-
function
|
|
1136
|
-
let n =
|
|
1153
|
+
function Bt(e, t) {
|
|
1154
|
+
let n = R(e);
|
|
1137
1155
|
if (t < 0 || t >= n[0].length) return [];
|
|
1138
1156
|
let r = 0;
|
|
1139
1157
|
for (let e = 0; e < t; e++) {
|
|
@@ -1141,62 +1159,62 @@ function It(e, t) {
|
|
|
1141
1159
|
if (!e) return [];
|
|
1142
1160
|
r += e.colspan;
|
|
1143
1161
|
}
|
|
1144
|
-
let i = Array(n.length).fill(!1).map((t, i) =>
|
|
1162
|
+
let i = Array(n.length).fill(!1).map((t, i) => Rt({
|
|
1145
1163
|
row: i,
|
|
1146
1164
|
col: r
|
|
1147
1165
|
}, e, n)).filter((e) => e !== void 0);
|
|
1148
1166
|
return i.filter((e, t) => i.findIndex((t) => t.row === e.row && t.col === e.col) === t);
|
|
1149
1167
|
}
|
|
1150
|
-
function
|
|
1151
|
-
let { col: i } =
|
|
1168
|
+
function Vt(e, t, n, r = R(e)) {
|
|
1169
|
+
let { col: i } = B({
|
|
1152
1170
|
row: 0,
|
|
1153
1171
|
col: t
|
|
1154
|
-
}, e, r), { col: a } =
|
|
1172
|
+
}, e, r), { col: a } = B({
|
|
1155
1173
|
row: 0,
|
|
1156
1174
|
col: n
|
|
1157
1175
|
}, e, r);
|
|
1158
1176
|
return r.forEach((e) => {
|
|
1159
1177
|
let [t] = e.splice(i, 1);
|
|
1160
1178
|
e.splice(a, 0, t);
|
|
1161
|
-
}),
|
|
1179
|
+
}), z(r);
|
|
1162
1180
|
}
|
|
1163
|
-
function
|
|
1164
|
-
let { row: i } =
|
|
1181
|
+
function Ht(e, t, n, r = R(e)) {
|
|
1182
|
+
let { row: i } = B({
|
|
1165
1183
|
row: t,
|
|
1166
1184
|
col: 0
|
|
1167
|
-
}, e, r), { row: a } =
|
|
1185
|
+
}, e, r), { row: a } = B({
|
|
1168
1186
|
row: n,
|
|
1169
1187
|
col: 0
|
|
1170
1188
|
}, e, r), [o] = r.splice(i, 1);
|
|
1171
|
-
return r.splice(a, 0, o),
|
|
1189
|
+
return r.splice(a, 0, o), z(r);
|
|
1172
1190
|
}
|
|
1173
|
-
function
|
|
1174
|
-
return e ?
|
|
1191
|
+
function Ut(e) {
|
|
1192
|
+
return e ? S(e) ? Ut(e.content) : typeof e == "string" ? e.length === 0 : Array.isArray(e) ? e.every((e) => typeof e == "string" ? e.length === 0 : x(e) ? e.text.length === 0 : Ve(e) ? typeof e.content == "string" ? e.content.length === 0 : e.content.every((e) => e.text.length === 0) : !1) : !1 : !0;
|
|
1175
1193
|
}
|
|
1176
|
-
function
|
|
1194
|
+
function Wt(e, t, n = R(e)) {
|
|
1177
1195
|
if (t === "columns") {
|
|
1178
1196
|
let e = 0;
|
|
1179
|
-
for (let t = n[0].length - 1; t >= 0 && n.every((e) =>
|
|
1197
|
+
for (let t = n[0].length - 1; t >= 0 && n.every((e) => Ut(e[t].cell) && e[t].colspan === 1); t--) e++;
|
|
1180
1198
|
for (let t = n.length - 1; t >= 0; t--) {
|
|
1181
1199
|
let r = Math.max(n[t].length - e, 1);
|
|
1182
1200
|
n[t] = n[t].slice(0, r);
|
|
1183
1201
|
}
|
|
1184
|
-
return
|
|
1202
|
+
return z(n);
|
|
1185
1203
|
}
|
|
1186
1204
|
let r = 0;
|
|
1187
|
-
for (let e = n.length - 1; e >= 0 && n[e].every((e) =>
|
|
1205
|
+
for (let e = n.length - 1; e >= 0 && n[e].every((e) => Ut(e.cell) && e.rowspan === 1); e--) r++;
|
|
1188
1206
|
let i = Math.min(r, n.length - 1);
|
|
1189
|
-
return n.splice(n.length - i, i),
|
|
1207
|
+
return n.splice(n.length - i, i), z(n);
|
|
1190
1208
|
}
|
|
1191
|
-
function
|
|
1192
|
-
let { width: i, height: a } =
|
|
1209
|
+
function Gt(e, t, n, r = R(e)) {
|
|
1210
|
+
let { width: i, height: a } = Lt(e);
|
|
1193
1211
|
if (t === "columns") r.forEach((e, t) => {
|
|
1194
1212
|
if (n >= 0) for (let r = 0; r < n; r++) e.push({
|
|
1195
1213
|
row: t,
|
|
1196
1214
|
col: Math.max(...e.map((e) => e.col)) + 1,
|
|
1197
1215
|
rowspan: 1,
|
|
1198
1216
|
colspan: 1,
|
|
1199
|
-
cell:
|
|
1217
|
+
cell: He("")
|
|
1200
1218
|
});
|
|
1201
1219
|
else e.splice(i + n, -1 * n);
|
|
1202
1220
|
});
|
|
@@ -1206,38 +1224,38 @@ function Vt(e, t, n, r = z(e)) {
|
|
|
1206
1224
|
col: n,
|
|
1207
1225
|
rowspan: 1,
|
|
1208
1226
|
colspan: 1,
|
|
1209
|
-
cell:
|
|
1227
|
+
cell: He("")
|
|
1210
1228
|
}));
|
|
1211
1229
|
r.push(t);
|
|
1212
1230
|
}
|
|
1213
1231
|
else n < 0 && r.splice(a + n, -1 * n);
|
|
1214
|
-
return
|
|
1232
|
+
return z(r);
|
|
1215
1233
|
}
|
|
1216
|
-
function
|
|
1217
|
-
let r =
|
|
1218
|
-
if (!r.some((e) =>
|
|
1234
|
+
function Kt(e, t, n) {
|
|
1235
|
+
let r = zt(e, n);
|
|
1236
|
+
if (!r.some((e) => T(e.cell) > 1)) return !0;
|
|
1219
1237
|
let i = n, a = n;
|
|
1220
1238
|
return r.forEach((e) => {
|
|
1221
|
-
let t =
|
|
1239
|
+
let t = T(e.cell);
|
|
1222
1240
|
i = Math.max(i, e.row + t - 1), a = Math.min(a, e.row);
|
|
1223
1241
|
}), t < n ? n === i : n === a;
|
|
1224
1242
|
}
|
|
1225
|
-
function
|
|
1226
|
-
let r =
|
|
1227
|
-
if (!r.some((e) =>
|
|
1243
|
+
function qt(e, t, n) {
|
|
1244
|
+
let r = Bt(e, n);
|
|
1245
|
+
if (!r.some((e) => w(e.cell) > 1)) return !0;
|
|
1228
1246
|
let i = n, a = n;
|
|
1229
1247
|
return r.forEach((e) => {
|
|
1230
|
-
let t =
|
|
1248
|
+
let t = w(e.cell);
|
|
1231
1249
|
i = Math.max(i, e.col + t - 1), a = Math.min(a, e.col);
|
|
1232
1250
|
}), t < n ? n === i : n === a;
|
|
1233
1251
|
}
|
|
1234
|
-
function
|
|
1235
|
-
let r =
|
|
1252
|
+
function Jt(e, t, n) {
|
|
1253
|
+
let r = B(e, n), i = B(t, n);
|
|
1236
1254
|
return r.col === i.col;
|
|
1237
1255
|
}
|
|
1238
1256
|
//#endregion
|
|
1239
1257
|
//#region src/api/nodeConversions/blockToNode.ts
|
|
1240
|
-
function
|
|
1258
|
+
function Yt(e, t, n, r) {
|
|
1241
1259
|
let i = [];
|
|
1242
1260
|
for (let [r, a] of Object.entries(e.styles || {})) {
|
|
1243
1261
|
let e = n[r];
|
|
@@ -1246,38 +1264,38 @@ function Gt(e, t, n, r) {
|
|
|
1246
1264
|
else if (e.propSchema === "string") a && i.push(t.mark(r, { stringValue: a }));
|
|
1247
1265
|
else throw new E(e.propSchema);
|
|
1248
1266
|
}
|
|
1249
|
-
let a = r && t.nodes[r] &&
|
|
1267
|
+
let a = r && t.nodes[r] && nt(t, t.nodes[r]) ? [...t.nodes[r].allowedMarks(i)] : i;
|
|
1250
1268
|
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, a)) : e.text.length > 0 ? [t.text(e.text, a)] : [];
|
|
1251
1269
|
}
|
|
1252
|
-
function
|
|
1270
|
+
function Xt(e, t, n) {
|
|
1253
1271
|
let r = t.marks.link.create({ href: e.href });
|
|
1254
|
-
return
|
|
1272
|
+
return Zt(e.content, t, n).map((e) => {
|
|
1255
1273
|
if (e.type.name === "text") return e.mark([...e.marks, r]);
|
|
1256
1274
|
if (e.type.name === "hardBreak") return e;
|
|
1257
1275
|
throw Error("unexpected node type");
|
|
1258
1276
|
});
|
|
1259
1277
|
}
|
|
1260
|
-
function
|
|
1278
|
+
function Zt(e, t, n, r) {
|
|
1261
1279
|
let i = [];
|
|
1262
|
-
if (typeof e == "string") return i.push(...
|
|
1280
|
+
if (typeof e == "string") return i.push(...Yt({
|
|
1263
1281
|
type: "text",
|
|
1264
1282
|
text: e,
|
|
1265
1283
|
styles: {}
|
|
1266
1284
|
}, t, n, r)), i;
|
|
1267
|
-
for (let a of e) i.push(...
|
|
1285
|
+
for (let a of e) i.push(...Yt(a, t, n, r));
|
|
1268
1286
|
return i;
|
|
1269
1287
|
}
|
|
1270
|
-
function
|
|
1288
|
+
function V(e, t, n, r = A(t)) {
|
|
1271
1289
|
let i = [];
|
|
1272
|
-
for (let a of e) typeof a == "string" ? i.push(...
|
|
1290
|
+
for (let a of e) typeof a == "string" ? i.push(...Zt(a, t, r, n)) : Ve(a) ? i.push(...Xt(a, t, r)) : x(a) ? i.push(...Zt([a], t, r, n)) : i.push($t(a, t, r));
|
|
1273
1291
|
return i;
|
|
1274
1292
|
}
|
|
1275
|
-
function
|
|
1293
|
+
function Qt(e, t, n = A(t)) {
|
|
1276
1294
|
let r = [], i = Array(e.headerRows ?? 0).fill(!0), a = Array(e.headerCols ?? 0).fill(!0), o = e.columnWidths ?? [];
|
|
1277
1295
|
for (let s = 0; s < e.rows.length; s++) {
|
|
1278
1296
|
let c = e.rows[s], l = [], u = i[s];
|
|
1279
1297
|
for (let r = 0; r < c.cells.length; r++) {
|
|
1280
|
-
let i = c.cells[r], d = a[r], f = null, p =
|
|
1298
|
+
let i = c.cells[r], d = a[r], f = null, p = B({
|
|
1281
1299
|
row: s,
|
|
1282
1300
|
col: r
|
|
1283
1301
|
}, {
|
|
@@ -1285,13 +1303,13 @@ function Jt(e, t, n = A(t)) {
|
|
|
1285
1303
|
content: e
|
|
1286
1304
|
}), m = o[p.col] ? [o[p.col]] : null;
|
|
1287
1305
|
if (i) if (typeof i == "string") f = t.text(i);
|
|
1288
|
-
else if (
|
|
1289
|
-
i.content && (f =
|
|
1290
|
-
let e =
|
|
1306
|
+
else if (S(i)) {
|
|
1307
|
+
i.content && (f = V(i.content, t, "tableParagraph", n));
|
|
1308
|
+
let e = w(i);
|
|
1291
1309
|
e > 1 && (m = Array(e).fill(!1).map((e, t) => o[p.col + t] ?? void 0));
|
|
1292
|
-
} else f =
|
|
1310
|
+
} else f = V(i, t, "tableParagraph", n);
|
|
1293
1311
|
let h = t.nodes[d || u ? "tableHeader" : "tableCell"].createChecked({
|
|
1294
|
-
...
|
|
1312
|
+
...S(i) ? i.props : {},
|
|
1295
1313
|
colwidth: m
|
|
1296
1314
|
}, t.nodes.tableParagraph.createChecked(void 0, f));
|
|
1297
1315
|
l.push(h);
|
|
@@ -1301,29 +1319,29 @@ function Jt(e, t, n = A(t)) {
|
|
|
1301
1319
|
}
|
|
1302
1320
|
return r;
|
|
1303
1321
|
}
|
|
1304
|
-
function
|
|
1322
|
+
function $t(e, t, n) {
|
|
1305
1323
|
let r, i = e.type;
|
|
1306
1324
|
if (i === void 0 && (i = "paragraph"), !t.nodes[i]) throw Error(`node type ${i} not found in schema`);
|
|
1307
1325
|
if (!e.content) r = t.nodes[i].createChecked(e.props);
|
|
1308
1326
|
else if (typeof e.content == "string") {
|
|
1309
|
-
let a =
|
|
1327
|
+
let a = V([e.content], t, i, n);
|
|
1310
1328
|
r = t.nodes[i].createChecked(e.props, a);
|
|
1311
1329
|
} else if (Array.isArray(e.content)) {
|
|
1312
|
-
let a =
|
|
1330
|
+
let a = V(e.content, t, i, n);
|
|
1313
1331
|
r = t.nodes[i].createChecked(e.props, a);
|
|
1314
1332
|
} else if (e.content.type === "tableContent") {
|
|
1315
|
-
let a =
|
|
1333
|
+
let a = Qt(e.content, t, n);
|
|
1316
1334
|
r = t.nodes[i].createChecked(e.props, a);
|
|
1317
1335
|
} else throw new E(e.content.type);
|
|
1318
1336
|
return r;
|
|
1319
1337
|
}
|
|
1320
|
-
function
|
|
1338
|
+
function H(e, t, n = A(t)) {
|
|
1321
1339
|
let r = e.id;
|
|
1322
|
-
r === void 0 && (r =
|
|
1340
|
+
r === void 0 && (r = ze.options.generateID());
|
|
1323
1341
|
let i = [];
|
|
1324
|
-
if (e.children) for (let r of e.children) i.push(
|
|
1342
|
+
if (e.children) for (let r of e.children) i.push(H(r, t, n));
|
|
1325
1343
|
if (!e.type || t.nodes[e.type].isInGroup("blockContent")) {
|
|
1326
|
-
let a =
|
|
1344
|
+
let a = $t(e, t, n), o = i.length > 0 ? t.nodes.blockGroup.createChecked({}, i) : void 0;
|
|
1327
1345
|
return t.nodes.blockContainer.createChecked({
|
|
1328
1346
|
id: r,
|
|
1329
1347
|
...e.props
|
|
@@ -1336,56 +1354,56 @@ function U(e, t, n = A(t)) {
|
|
|
1336
1354
|
}
|
|
1337
1355
|
//#endregion
|
|
1338
1356
|
//#region src/api/nodeUtil.ts
|
|
1339
|
-
function
|
|
1357
|
+
function en(e, t) {
|
|
1340
1358
|
let n, r;
|
|
1341
|
-
if (t.firstChild.descendants((i, a) => n ? !1 : !
|
|
1359
|
+
if (t.firstChild.descendants((i, a) => n ? !1 : !tn(i) || !i.attrs.id || je(i, t) !== e ? !0 : (n = i, r = a + 1, !1)), !(n === void 0 || r === void 0)) return {
|
|
1342
1360
|
node: n,
|
|
1343
1361
|
posBeforeNode: r
|
|
1344
1362
|
};
|
|
1345
1363
|
}
|
|
1346
|
-
function
|
|
1364
|
+
function tn(e) {
|
|
1347
1365
|
return e.type.isInGroup("bnBlock");
|
|
1348
1366
|
}
|
|
1349
1367
|
//#endregion
|
|
1350
1368
|
//#region src/api/blockManipulation/commands/updateBlock/updateBlock.ts
|
|
1351
|
-
var
|
|
1352
|
-
function
|
|
1369
|
+
var nn = (e, t) => ({ tr: n, dispatch: r }) => (r && U(n, e, t), !0);
|
|
1370
|
+
function U(e, t, n, r, i) {
|
|
1353
1371
|
let a = Ne(e.doc.resolve(t)), o = null;
|
|
1354
|
-
a.blockNoteType === "table" && (o =
|
|
1372
|
+
a.blockNoteType === "table" && (o = un(e));
|
|
1355
1373
|
let s = k(e);
|
|
1356
1374
|
if (r !== void 0 && i !== void 0 && r > i) throw Error("Invalid replaceFromPos or replaceToPos");
|
|
1357
1375
|
let c = s.nodes[a.blockNoteType], l = s.nodes[n.type || a.blockNoteType], u = l.isInGroup("bnBlock") ? l : s.nodes.blockContainer;
|
|
1358
1376
|
if (a.isBlockContainer && l.isInGroup("blockContent")) {
|
|
1359
1377
|
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;
|
|
1360
|
-
|
|
1361
|
-
} else if (!a.isBlockContainer && l.isInGroup("bnBlock"))
|
|
1378
|
+
cn(n, e, a), rn(n, e, c, l, a, t, o);
|
|
1379
|
+
} else if (!a.isBlockContainer && l.isInGroup("bnBlock")) cn(n, e, a);
|
|
1362
1380
|
else {
|
|
1363
|
-
let t =
|
|
1364
|
-
children:
|
|
1381
|
+
let t = H({
|
|
1382
|
+
children: j(a.bnBlock.node, e.doc).children,
|
|
1365
1383
|
...n
|
|
1366
1384
|
}, s);
|
|
1367
1385
|
t.check(), e.replaceWith(a.bnBlock.beforePos, a.bnBlock.afterPos, t);
|
|
1368
1386
|
return;
|
|
1369
1387
|
}
|
|
1370
|
-
|
|
1388
|
+
on(e, a.bnBlock.beforePos, u, { ...n.props }), o && dn(e, a, o);
|
|
1371
1389
|
}
|
|
1372
|
-
function
|
|
1390
|
+
function rn(e, t, n, r, o, s, c) {
|
|
1373
1391
|
let l = k(t), u = "keep";
|
|
1374
|
-
if (e.content) if (typeof e.content == "string") u =
|
|
1375
|
-
else if (Array.isArray(e.content)) u =
|
|
1376
|
-
else if (e.content.type === "tableContent") u =
|
|
1392
|
+
if (e.content) if (typeof e.content == "string") u = V([e.content], l, r.name);
|
|
1393
|
+
else if (Array.isArray(e.content)) u = V(e.content, l, r.name);
|
|
1394
|
+
else if (e.content.type === "tableContent") u = Qt(e.content, l);
|
|
1377
1395
|
else throw new E(e.content.type);
|
|
1378
1396
|
else n.spec.content === "" || r.spec.content !== n.spec.content && (u = []);
|
|
1379
|
-
if (u === "keep")
|
|
1397
|
+
if (u === "keep") on(t, o.blockContent.beforePos, r, { ...e.props });
|
|
1380
1398
|
else if (s !== void 0 || c !== void 0) {
|
|
1381
|
-
let n =
|
|
1399
|
+
let n = sn(t, o.blockContent.beforePos, r, { ...e.props }), l = n + 1 + (s ?? 0), d = n + 1 + (c ?? o.blockContent.node.content.size), f = t.doc.resolve(n).depth, p = t.doc.resolve(l).depth, m = t.doc.resolve(d).depth;
|
|
1382
1400
|
t.replace(l, d, new a(i.from(u), p - f - 1, m - f - 1));
|
|
1383
|
-
} else r === n || r.validContent(o.blockContent.node.content) ?
|
|
1401
|
+
} else r === n || r.validContent(o.blockContent.node.content) ? an(t, sn(t, o.blockContent.beforePos, r, { ...e.props }), i.from(u)) : t.replaceWith(o.blockContent.beforePos, o.blockContent.afterPos, r.createChecked({
|
|
1384
1402
|
...o.blockContent.node.attrs,
|
|
1385
1403
|
...e.props
|
|
1386
1404
|
}, u));
|
|
1387
1405
|
}
|
|
1388
|
-
function
|
|
1406
|
+
function an(e, t, n) {
|
|
1389
1407
|
let r = e.doc.nodeAt(t);
|
|
1390
1408
|
if (!r) throw RangeError("No node at given position");
|
|
1391
1409
|
let s = r.content, c = t + 1;
|
|
@@ -1409,7 +1427,7 @@ function tn(e, t, n) {
|
|
|
1409
1427
|
for (let e = d; e < p; e++) g.push(n.child(e));
|
|
1410
1428
|
e.step(new o(m, h, new a(i.from(g), 0, 0)));
|
|
1411
1429
|
}
|
|
1412
|
-
function
|
|
1430
|
+
function on(e, t, n, r) {
|
|
1413
1431
|
let i = e.doc.nodeAt(t);
|
|
1414
1432
|
if (!i) throw RangeError("No node at given position");
|
|
1415
1433
|
let a = n.spec.attrs ?? {}, o = {};
|
|
@@ -1424,32 +1442,32 @@ function nn(e, t, n, r) {
|
|
|
1424
1442
|
}
|
|
1425
1443
|
e.setNodeMarkup(t, n, s);
|
|
1426
1444
|
}
|
|
1427
|
-
function
|
|
1445
|
+
function sn(e, t, n, r) {
|
|
1428
1446
|
let i = e.mapping.maps.length;
|
|
1429
|
-
return
|
|
1447
|
+
return on(e, t, n, r), e.mapping.slice(i).map(t, -1);
|
|
1430
1448
|
}
|
|
1431
|
-
function
|
|
1449
|
+
function cn(e, t, n) {
|
|
1432
1450
|
let r = k(t);
|
|
1433
1451
|
if (e.children !== void 0 && e.children.length > 0) {
|
|
1434
1452
|
let a = e.children.map((e) => {
|
|
1435
|
-
let t =
|
|
1453
|
+
let t = H(e, r);
|
|
1436
1454
|
return t.check(), t;
|
|
1437
1455
|
});
|
|
1438
|
-
if (n.childContainer)
|
|
1456
|
+
if (n.childContainer) an(t, n.childContainer.beforePos, i.from(a));
|
|
1439
1457
|
else {
|
|
1440
1458
|
if (!n.isBlockContainer) throw Error("impossible");
|
|
1441
1459
|
t.insert(n.blockContent.afterPos, r.nodes.blockGroup.createChecked({}, a));
|
|
1442
1460
|
}
|
|
1443
1461
|
}
|
|
1444
1462
|
}
|
|
1445
|
-
function
|
|
1446
|
-
let a = typeof t == "string" ? t : t.id, o =
|
|
1463
|
+
function ln(e, t, n, r, i) {
|
|
1464
|
+
let a = typeof t == "string" ? t : t.id, o = en(a, e.doc);
|
|
1447
1465
|
if (!o) throw Error(`Block with ID ${a} not found`);
|
|
1448
|
-
return
|
|
1466
|
+
return U(e, o.posBeforeNode, n, r, i), j(e.doc.resolve(o.posBeforeNode + 1).node(), e.doc);
|
|
1449
1467
|
}
|
|
1450
|
-
function
|
|
1468
|
+
function un(e) {
|
|
1451
1469
|
let t = "selection" in e ? e.selection : null;
|
|
1452
|
-
if (!(t instanceof
|
|
1470
|
+
if (!(t instanceof re)) return null;
|
|
1453
1471
|
let n = e.doc.resolve(t.head), r = -1, i = -1;
|
|
1454
1472
|
for (let e = n.depth; e >= 0; e--) {
|
|
1455
1473
|
let t = n.node(e).type.name;
|
|
@@ -1461,7 +1479,7 @@ function sn(e) {
|
|
|
1461
1479
|
if (r < 0 || i < 0) return null;
|
|
1462
1480
|
let a = n.before(r), o = n.before(i), s = e.doc.nodeAt(o);
|
|
1463
1481
|
if (!s || s.type.name !== "table") return null;
|
|
1464
|
-
let c =
|
|
1482
|
+
let c = ce.get(s), l = a - (o + 1), u = c.map.indexOf(l);
|
|
1465
1483
|
if (u < 0) return null;
|
|
1466
1484
|
let d = Math.floor(u / c.width), f = u % c.width, p = a + 1 + 1;
|
|
1467
1485
|
return {
|
|
@@ -1470,7 +1488,7 @@ function sn(e) {
|
|
|
1470
1488
|
offset: Math.max(0, t.head - p)
|
|
1471
1489
|
};
|
|
1472
1490
|
}
|
|
1473
|
-
function
|
|
1491
|
+
function dn(e, t, n) {
|
|
1474
1492
|
if (t.blockNoteType !== "table") return !1;
|
|
1475
1493
|
let r = -1;
|
|
1476
1494
|
if (t.isBlockContainer) r = e.mapping.map(t.blockContent.beforePos);
|
|
@@ -1480,10 +1498,10 @@ function cn(e, t, n) {
|
|
|
1480
1498
|
}
|
|
1481
1499
|
let i = r >= 0 ? e.doc.nodeAt(r) : null;
|
|
1482
1500
|
if (!i || i.type.name !== "table") return !1;
|
|
1483
|
-
let a =
|
|
1501
|
+
let a = ce.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];
|
|
1484
1502
|
if (l == null) return !1;
|
|
1485
1503
|
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));
|
|
1486
|
-
return "selection" in e && e.setSelection(
|
|
1504
|
+
return "selection" in e && e.setSelection(re.create(e.doc, m)), !0;
|
|
1487
1505
|
}
|
|
1488
1506
|
//#endregion
|
|
1489
1507
|
//#region src/editor/defaultColors.ts
|
|
@@ -1524,7 +1542,7 @@ var W = {
|
|
|
1524
1542
|
text: "#ad1a72",
|
|
1525
1543
|
background: "#f4dfeb"
|
|
1526
1544
|
}
|
|
1527
|
-
},
|
|
1545
|
+
}, fn = {
|
|
1528
1546
|
gray: {
|
|
1529
1547
|
text: "#bebdb8",
|
|
1530
1548
|
background: "#9b9a97"
|
|
@@ -1578,19 +1596,19 @@ var W = {
|
|
|
1578
1596
|
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 = G.textAlignment.values.includes(e.style.textAlign) ? e.style.textAlign : void 0, t;
|
|
1579
1597
|
}, q = (e, t) => {
|
|
1580
1598
|
e.backgroundColor && e.backgroundColor !== G.backgroundColor.default && (t.style.backgroundColor = e.backgroundColor in W ? W[e.backgroundColor].background : e.backgroundColor), e.textColor && e.textColor !== G.textColor.default && (t.style.color = e.textColor in W ? W[e.textColor].text : e.textColor), e.textAlignment && e.textAlignment !== G.textAlignment.default && (t.style.textAlign = e.textAlignment);
|
|
1581
|
-
},
|
|
1599
|
+
}, pn = (e = "backgroundColor") => ({
|
|
1582
1600
|
default: G.backgroundColor.default,
|
|
1583
1601
|
parseHTML: (e) => e.hasAttribute("data-background-color") ? e.getAttribute("data-background-color") : e.style.backgroundColor ? e.style.backgroundColor : G.backgroundColor.default,
|
|
1584
1602
|
renderHTML: (t) => t[e] === G.backgroundColor.default ? {} : { "data-background-color": t[e] }
|
|
1585
|
-
}),
|
|
1603
|
+
}), mn = (e = "textColor") => ({
|
|
1586
1604
|
default: G.textColor.default,
|
|
1587
1605
|
parseHTML: (e) => e.hasAttribute("data-text-color") ? e.getAttribute("data-text-color") : e.style.color ? e.style.color : G.textColor.default,
|
|
1588
1606
|
renderHTML: (t) => t[e] === G.textColor.default ? {} : { "data-text-color": t[e] }
|
|
1589
|
-
}),
|
|
1607
|
+
}), hn = (e = "textAlignment") => ({
|
|
1590
1608
|
default: G.textAlignment.default,
|
|
1591
1609
|
parseHTML: (e) => e.hasAttribute("data-text-alignment") ? e.getAttribute("data-text-alignment") : e.style.textAlign ? e.style.textAlign : G.textAlignment.default,
|
|
1592
1610
|
renderHTML: (t) => t[e] === G.textAlignment.default ? {} : { "data-text-alignment": t[e] }
|
|
1593
|
-
}),
|
|
1611
|
+
}), gn = (e, t) => {
|
|
1594
1612
|
let n = e.querySelector(t);
|
|
1595
1613
|
if (n) return {
|
|
1596
1614
|
targetElement: n,
|
|
@@ -1615,7 +1633,7 @@ var W = {
|
|
|
1615
1633
|
n.setState(e);
|
|
1616
1634
|
}
|
|
1617
1635
|
};
|
|
1618
|
-
}),
|
|
1636
|
+
}), _n = (e, t, n) => {
|
|
1619
1637
|
let r = document.createElement("div");
|
|
1620
1638
|
r.className = "bn-add-file-button";
|
|
1621
1639
|
let i = document.createElement("div");
|
|
@@ -1633,17 +1651,17 @@ var W = {
|
|
|
1633
1651
|
r.removeEventListener("mousedown", o, !0), r.removeEventListener("click", s, !0);
|
|
1634
1652
|
}
|
|
1635
1653
|
};
|
|
1636
|
-
},
|
|
1654
|
+
}, vn = "<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>", yn = (e) => {
|
|
1637
1655
|
let t = document.createElement("div");
|
|
1638
1656
|
t.className = "bn-file-name-with-icon";
|
|
1639
1657
|
let n = document.createElement("div");
|
|
1640
|
-
n.className = "bn-file-icon", n.innerHTML =
|
|
1658
|
+
n.className = "bn-file-icon", n.innerHTML = vn, t.appendChild(n);
|
|
1641
1659
|
let r = document.createElement("p");
|
|
1642
1660
|
return r.className = "bn-file-name", r.textContent = e.props.name, t.appendChild(r), { dom: t };
|
|
1643
|
-
},
|
|
1661
|
+
}, bn = (e, t, n, r) => {
|
|
1644
1662
|
let i = e.props.url !== "" && !!e.props.caption, a = document.createElement(i ? "figure" : "div");
|
|
1645
1663
|
if (a.className = "bn-file-block-content-wrapper", e.props.url === "") {
|
|
1646
|
-
let n =
|
|
1664
|
+
let n = _n(e, t, r);
|
|
1647
1665
|
a.appendChild(n.dom);
|
|
1648
1666
|
let i = t.onUploadStart((t) => {
|
|
1649
1667
|
if (t === e.id) {
|
|
@@ -1661,7 +1679,7 @@ var W = {
|
|
|
1661
1679
|
}
|
|
1662
1680
|
let o = { dom: a };
|
|
1663
1681
|
if (e.props.showPreview === !1 || !n) {
|
|
1664
|
-
let t =
|
|
1682
|
+
let t = yn(e);
|
|
1665
1683
|
a.appendChild(t.dom), o.destroy = () => {
|
|
1666
1684
|
t.destroy?.();
|
|
1667
1685
|
};
|
|
@@ -1671,13 +1689,13 @@ var W = {
|
|
|
1671
1689
|
t.className = "bn-file-caption", t.textContent = e.props.caption, a.appendChild(t);
|
|
1672
1690
|
}
|
|
1673
1691
|
return o;
|
|
1674
|
-
},
|
|
1692
|
+
}, xn = (e, t) => {
|
|
1675
1693
|
let n = document.createElement("figure"), r = document.createElement("figcaption");
|
|
1676
1694
|
return r.textContent = t, n.appendChild(e), n.appendChild(r), { dom: n };
|
|
1677
|
-
},
|
|
1695
|
+
}, Sn = (e, t) => {
|
|
1678
1696
|
let n = document.createElement("div"), r = document.createElement("p");
|
|
1679
1697
|
return r.textContent = t, n.appendChild(e), n.appendChild(r), { dom: n };
|
|
1680
|
-
},
|
|
1698
|
+
}, Cn = (e) => ({ url: e.src || void 0 }), wn = "<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>", Tn = P((e) => ({
|
|
1681
1699
|
type: "audio",
|
|
1682
1700
|
propSchema: {
|
|
1683
1701
|
backgroundColor: G.backgroundColor,
|
|
@@ -1687,53 +1705,53 @@ var W = {
|
|
|
1687
1705
|
showPreview: { default: !0 }
|
|
1688
1706
|
},
|
|
1689
1707
|
content: "none"
|
|
1690
|
-
})),
|
|
1708
|
+
})), En = (e = {}) => (e) => {
|
|
1691
1709
|
if (e.tagName === "AUDIO") {
|
|
1692
1710
|
if (e.closest("figure")) return;
|
|
1693
1711
|
let { backgroundColor: t } = K(e);
|
|
1694
1712
|
return {
|
|
1695
|
-
...
|
|
1713
|
+
...Cn(e),
|
|
1696
1714
|
backgroundColor: t
|
|
1697
1715
|
};
|
|
1698
1716
|
}
|
|
1699
1717
|
if (e.tagName === "FIGURE") {
|
|
1700
|
-
let t =
|
|
1718
|
+
let t = gn(e, "audio");
|
|
1701
1719
|
if (!t) return;
|
|
1702
1720
|
let { targetElement: n, caption: r } = t, { backgroundColor: i } = K(e);
|
|
1703
1721
|
return {
|
|
1704
|
-
...
|
|
1722
|
+
...Cn(n),
|
|
1705
1723
|
backgroundColor: i,
|
|
1706
1724
|
caption: r
|
|
1707
1725
|
};
|
|
1708
1726
|
}
|
|
1709
|
-
},
|
|
1727
|
+
}, Dn = (e = {}) => (t, n) => {
|
|
1710
1728
|
let r = document.createElement("div");
|
|
1711
1729
|
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>";
|
|
1712
1730
|
let i = document.createElement("audio");
|
|
1713
1731
|
return i.className = "bn-audio", n.resolveFileUrl ? n.resolveFileUrl(t.props.url).then((e) => {
|
|
1714
1732
|
i.src = e;
|
|
1715
|
-
}) : i.src = t.props.url, i.controls = !0, i.contentEditable = "false", i.draggable = !1,
|
|
1716
|
-
},
|
|
1733
|
+
}) : i.src = t.props.url, i.controls = !0, i.contentEditable = "false", i.draggable = !1, bn(t, n, { dom: i }, r.firstElementChild);
|
|
1734
|
+
}, On = (e = {}) => (e, t) => {
|
|
1717
1735
|
if (!e.props.url) return { dom: document.createElement("audio") };
|
|
1718
1736
|
let n;
|
|
1719
|
-
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 ?
|
|
1720
|
-
},
|
|
1737
|
+
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 ? xn(n, e.props.caption) : Sn(n, e.props.caption) : { dom: n };
|
|
1738
|
+
}, kn = F(Tn, (e) => ({
|
|
1721
1739
|
meta: { fileBlockAccept: ["audio/*"] },
|
|
1722
|
-
parse:
|
|
1723
|
-
render:
|
|
1724
|
-
toExternalHTML:
|
|
1740
|
+
parse: En(e),
|
|
1741
|
+
render: Dn(e),
|
|
1742
|
+
toExternalHTML: On(e),
|
|
1725
1743
|
runsBefore: ["file"]
|
|
1726
|
-
})),
|
|
1727
|
-
function
|
|
1744
|
+
})), An = Symbol.for("blocknote.shikiParser"), jn = Symbol.for("blocknote.shikiHighlighterPromise");
|
|
1745
|
+
function Mn(e) {
|
|
1728
1746
|
let t = globalThis, n, r, i = !1;
|
|
1729
|
-
return
|
|
1747
|
+
return _e({
|
|
1730
1748
|
parser: (a) => {
|
|
1731
1749
|
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), [];
|
|
1732
|
-
if (!n) return t[
|
|
1750
|
+
if (!n) return t[jn] = t[jn] || e.createHighlighter(), t[jn].then((e) => {
|
|
1733
1751
|
n = e;
|
|
1734
1752
|
});
|
|
1735
|
-
let o =
|
|
1736
|
-
return !o || o === "text" || o === "none" || o === "plaintext" || o === "txt" ? [] : n.getLoadedLanguages().includes(o) ? (r || (r = t[
|
|
1753
|
+
let o = Fn(e, a.language);
|
|
1754
|
+
return !o || o === "text" || o === "none" || o === "plaintext" || o === "txt" ? [] : n.getLoadedLanguages().includes(o) ? (r || (r = t[An] || ve(n), t[An] = r), r(a)) : n.loadLanguage(o);
|
|
1737
1755
|
},
|
|
1738
1756
|
languageExtractor: (e) => e.attrs.language,
|
|
1739
1757
|
nodeTypes: ["codeBlock"]
|
|
@@ -1741,11 +1759,11 @@ function kn(e) {
|
|
|
1741
1759
|
}
|
|
1742
1760
|
//#endregion
|
|
1743
1761
|
//#region src/blocks/Code/block.ts
|
|
1744
|
-
var
|
|
1762
|
+
var Nn = P(({ defaultLanguage: e = "text" }) => ({
|
|
1745
1763
|
type: "codeBlock",
|
|
1746
1764
|
propSchema: { language: { default: e } },
|
|
1747
1765
|
content: "plain"
|
|
1748
|
-
})),
|
|
1766
|
+
})), Pn = F(Nn, (e) => ({
|
|
1749
1767
|
meta: {
|
|
1750
1768
|
code: !0,
|
|
1751
1769
|
defining: !0,
|
|
@@ -1757,7 +1775,7 @@ var An = F(({ defaultLanguage: e = "text" }) => ({
|
|
|
1757
1775
|
return { language: t.getAttribute("data-language") || t.className.split(" ").find((e) => e.includes("language-"))?.replace("language-", "") };
|
|
1758
1776
|
},
|
|
1759
1777
|
parseContent: ({ el: e, schema: t }) => {
|
|
1760
|
-
let n =
|
|
1778
|
+
let n = ie.fromSchema(t), r = e.firstElementChild;
|
|
1761
1779
|
return n.parse(r, {
|
|
1762
1780
|
preserveWhitespace: "full",
|
|
1763
1781
|
topNode: t.nodes.codeBlock.create()
|
|
@@ -1799,7 +1817,7 @@ var An = F(({ defaultLanguage: e = "text" }) => ({
|
|
|
1799
1817
|
}
|
|
1800
1818
|
}), (e) => [n({
|
|
1801
1819
|
key: "code-block-highlighter",
|
|
1802
|
-
prosemirrorPlugins: [
|
|
1820
|
+
prosemirrorPlugins: [Mn(e)]
|
|
1803
1821
|
}), n({
|
|
1804
1822
|
key: "code-block-keyboard-shortcuts",
|
|
1805
1823
|
keyboardShortcuts: {
|
|
@@ -1837,22 +1855,22 @@ var An = F(({ defaultLanguage: e = "text" }) => ({
|
|
|
1837
1855
|
let n = t[1].trim();
|
|
1838
1856
|
return {
|
|
1839
1857
|
type: "codeBlock",
|
|
1840
|
-
props: { language: { language:
|
|
1858
|
+
props: { language: { language: Fn(e, n) ?? n }.language },
|
|
1841
1859
|
content: []
|
|
1842
1860
|
};
|
|
1843
1861
|
}
|
|
1844
1862
|
}]
|
|
1845
1863
|
})]);
|
|
1846
|
-
function
|
|
1864
|
+
function Fn(e, t) {
|
|
1847
1865
|
return Object.entries(e.supportedLanguages ?? {}).find(([e, { aliases: n }]) => n?.includes(t) || e === t)?.[0];
|
|
1848
1866
|
}
|
|
1849
1867
|
//#endregion
|
|
1850
1868
|
//#region src/blocks/Divider/block.ts
|
|
1851
|
-
var
|
|
1869
|
+
var In = P(() => ({
|
|
1852
1870
|
type: "divider",
|
|
1853
1871
|
propSchema: {},
|
|
1854
1872
|
content: "none"
|
|
1855
|
-
})),
|
|
1873
|
+
})), Ln = F(In, {
|
|
1856
1874
|
meta: { isolating: !1 },
|
|
1857
1875
|
parse(e) {
|
|
1858
1876
|
if (e.tagName === "HR") return {};
|
|
@@ -1872,7 +1890,7 @@ var Nn = F(() => ({
|
|
|
1872
1890
|
};
|
|
1873
1891
|
}
|
|
1874
1892
|
}]
|
|
1875
|
-
})]),
|
|
1893
|
+
})]), Rn = (e) => ({ url: e.src || void 0 }), zn = P(() => ({
|
|
1876
1894
|
type: "file",
|
|
1877
1895
|
propSchema: {
|
|
1878
1896
|
backgroundColor: G.backgroundColor,
|
|
@@ -1881,40 +1899,40 @@ var Nn = F(() => ({
|
|
|
1881
1899
|
caption: { default: "" }
|
|
1882
1900
|
},
|
|
1883
1901
|
content: "none"
|
|
1884
|
-
})),
|
|
1902
|
+
})), Bn = () => (e) => {
|
|
1885
1903
|
if (e.tagName === "EMBED") {
|
|
1886
1904
|
if (e.closest("figure")) return;
|
|
1887
1905
|
let { backgroundColor: t } = K(e);
|
|
1888
1906
|
return {
|
|
1889
|
-
...
|
|
1907
|
+
...Rn(e),
|
|
1890
1908
|
backgroundColor: t
|
|
1891
1909
|
};
|
|
1892
1910
|
}
|
|
1893
1911
|
if (e.tagName === "FIGURE") {
|
|
1894
|
-
let t =
|
|
1912
|
+
let t = gn(e, "embed");
|
|
1895
1913
|
if (!t) return;
|
|
1896
1914
|
let { targetElement: n, caption: r } = t, { backgroundColor: i } = K(e);
|
|
1897
1915
|
return {
|
|
1898
|
-
...
|
|
1916
|
+
...Rn(n),
|
|
1899
1917
|
backgroundColor: i,
|
|
1900
1918
|
caption: r
|
|
1901
1919
|
};
|
|
1902
1920
|
}
|
|
1903
|
-
},
|
|
1921
|
+
}, Vn = F(zn, {
|
|
1904
1922
|
meta: { fileBlockAccept: ["*/*"] },
|
|
1905
|
-
parse:
|
|
1923
|
+
parse: Bn(),
|
|
1906
1924
|
render(e, t) {
|
|
1907
|
-
return
|
|
1925
|
+
return bn(e, t);
|
|
1908
1926
|
},
|
|
1909
1927
|
toExternalHTML(e) {
|
|
1910
1928
|
if (!e.props.url) return { dom: document.createElement("embed") };
|
|
1911
1929
|
let t = document.createElement("a");
|
|
1912
|
-
return t.href = e.props.url, t.textContent = e.props.name || e.props.url, e.props.caption ?
|
|
1930
|
+
return t.href = e.props.url, t.textContent = e.props.name || e.props.url, e.props.caption ? Sn(t, e.props.caption) : { dom: t };
|
|
1913
1931
|
}
|
|
1914
1932
|
});
|
|
1915
1933
|
//#endregion
|
|
1916
1934
|
//#region src/blocks/getDetailsContent.ts
|
|
1917
|
-
function
|
|
1935
|
+
function Hn(e, t, n) {
|
|
1918
1936
|
let a = r.fromSchema(t), o = e.querySelector(":scope > summary"), s;
|
|
1919
1937
|
if (o) {
|
|
1920
1938
|
let e = o.cloneNode(!0);
|
|
@@ -1934,10 +1952,10 @@ function zn(e, t, n) {
|
|
|
1934
1952
|
}
|
|
1935
1953
|
//#endregion
|
|
1936
1954
|
//#region src/blocks/ToggleWrapper/createToggleWrapper.ts
|
|
1937
|
-
var
|
|
1955
|
+
var Un = {
|
|
1938
1956
|
set: (e, t) => window.localStorage.setItem(`toggle-${e.id}`, t ? "true" : "false"),
|
|
1939
1957
|
get: (e) => window.localStorage.getItem(`toggle-${e.id}`) === "true"
|
|
1940
|
-
},
|
|
1958
|
+
}, Wn = (e, t, n, r = Un) => {
|
|
1941
1959
|
if ("isToggleable" in e.props && !e.props.isToggleable) return { dom: n };
|
|
1942
1960
|
let i = document.createElement("div"), a = document.createElement("div");
|
|
1943
1961
|
a.className = "bn-toggle-wrapper";
|
|
@@ -1946,7 +1964,8 @@ var Bn = {
|
|
|
1946
1964
|
let s = (e) => e.preventDefault();
|
|
1947
1965
|
o.addEventListener("mousedown", s);
|
|
1948
1966
|
let c = () => {
|
|
1949
|
-
|
|
1967
|
+
let n = t.getBlock(e);
|
|
1968
|
+
n && (a.getAttribute("data-show-children") === "true" ? (a.setAttribute("data-show-children", "false"), r.set(n, !1), i.contains(l) && i.removeChild(l)) : (a.setAttribute("data-show-children", "true"), r.set(n, !0), t.isEditable && n.children.length === 0 && !i.contains(l) && i.appendChild(l)));
|
|
1950
1969
|
};
|
|
1951
1970
|
o.addEventListener("click", c), a.appendChild(o), a.appendChild(n);
|
|
1952
1971
|
let l = document.createElement("button");
|
|
@@ -1962,7 +1981,22 @@ var Bn = {
|
|
|
1962
1981
|
l.addEventListener("click", d), i.appendChild(a);
|
|
1963
1982
|
let f = e.children.length, p = t.onChange(() => {
|
|
1964
1983
|
let n = t.getBlock(e)?.children.length ?? 0;
|
|
1965
|
-
|
|
1984
|
+
if (n > f) {
|
|
1985
|
+
if (a.getAttribute("data-show-children") === "false") {
|
|
1986
|
+
a.setAttribute("data-show-children", "true");
|
|
1987
|
+
let n = t.getBlock(e);
|
|
1988
|
+
n && r.set(n, !0);
|
|
1989
|
+
}
|
|
1990
|
+
i.contains(l) && i.removeChild(l);
|
|
1991
|
+
} else if (n === 0 && n < f) {
|
|
1992
|
+
if (a.getAttribute("data-show-children") === "true") {
|
|
1993
|
+
a.setAttribute("data-show-children", "false");
|
|
1994
|
+
let n = t.getBlock(e);
|
|
1995
|
+
n && r.set(n, !1);
|
|
1996
|
+
}
|
|
1997
|
+
i.contains(l) && i.removeChild(l);
|
|
1998
|
+
}
|
|
1999
|
+
f = n;
|
|
1966
2000
|
});
|
|
1967
2001
|
return r.get(e) ? (a.setAttribute("data-show-children", "true"), t.isEditable && e.children.length === 0 && i.appendChild(l)) : a.setAttribute("data-show-children", "false"), {
|
|
1968
2002
|
dom: i,
|
|
@@ -1971,20 +2005,20 @@ var Bn = {
|
|
|
1971
2005
|
o.removeEventListener("mousedown", s), o.removeEventListener("click", c), l.removeEventListener("mousedown", u), l.removeEventListener("click", d), p?.();
|
|
1972
2006
|
}
|
|
1973
2007
|
};
|
|
1974
|
-
},
|
|
2008
|
+
}, Gn = [
|
|
1975
2009
|
1,
|
|
1976
2010
|
2,
|
|
1977
2011
|
3,
|
|
1978
2012
|
4,
|
|
1979
2013
|
5,
|
|
1980
2014
|
6
|
|
1981
|
-
],
|
|
2015
|
+
], Kn = (e) => ({ editor: t }) => {
|
|
1982
2016
|
let n = t.getTextCursorPosition();
|
|
1983
2017
|
return t.schema.blockSchema[n.block.type].content === "inline" ? (t.updateBlock(n.block, {
|
|
1984
2018
|
type: "heading",
|
|
1985
2019
|
props: { level: e }
|
|
1986
2020
|
}), !0) : !1;
|
|
1987
|
-
},
|
|
2021
|
+
}, qn = P(({ defaultLevel: e = 1, levels: t = Gn, allowToggleHeadings: n = !0 } = {}) => ({
|
|
1988
2022
|
type: "heading",
|
|
1989
2023
|
propSchema: {
|
|
1990
2024
|
...G,
|
|
@@ -1998,7 +2032,7 @@ var Bn = {
|
|
|
1998
2032
|
} } : {}
|
|
1999
2033
|
},
|
|
2000
2034
|
content: "inline"
|
|
2001
|
-
})),
|
|
2035
|
+
})), Jn = F(qn, ({ allowToggleHeadings: e = !0 } = {}) => ({
|
|
2002
2036
|
meta: { isolating: !1 },
|
|
2003
2037
|
parse(t) {
|
|
2004
2038
|
if (e && t.tagName === "DETAILS") {
|
|
@@ -2039,13 +2073,13 @@ var Bn = {
|
|
|
2039
2073
|
};
|
|
2040
2074
|
},
|
|
2041
2075
|
...e ? { parseContent: ({ el: e, schema: t }) => {
|
|
2042
|
-
if (e.tagName === "DETAILS") return
|
|
2076
|
+
if (e.tagName === "DETAILS") return Hn(e, t, "heading");
|
|
2043
2077
|
} } : {},
|
|
2044
2078
|
runsBefore: ["toggleListItem"],
|
|
2045
2079
|
render(t, n) {
|
|
2046
2080
|
let r = document.createElement(`h${t.props.level}`);
|
|
2047
2081
|
return e ? {
|
|
2048
|
-
...
|
|
2082
|
+
...Wn(t, n, r),
|
|
2049
2083
|
contentDOM: r
|
|
2050
2084
|
} : {
|
|
2051
2085
|
dom: r,
|
|
@@ -2069,9 +2103,9 @@ var Bn = {
|
|
|
2069
2103
|
contentDOM: n
|
|
2070
2104
|
};
|
|
2071
2105
|
}
|
|
2072
|
-
}), ({ levels: e =
|
|
2106
|
+
}), ({ levels: e = Gn } = {}) => [n({
|
|
2073
2107
|
key: "heading-shortcuts",
|
|
2074
|
-
keyboardShortcuts: Object.fromEntries(e.map((e) => [`Mod-Alt-${e}`,
|
|
2108
|
+
keyboardShortcuts: Object.fromEntries(e.map((e) => [`Mod-Alt-${e}`, Kn(e)]) ?? []),
|
|
2075
2109
|
inputRules: e.map((e) => ({
|
|
2076
2110
|
find: RegExp(`^(#{${e}})\\s$`),
|
|
2077
2111
|
replace({ match: e }) {
|
|
@@ -2081,8 +2115,8 @@ var Bn = {
|
|
|
2081
2115
|
};
|
|
2082
2116
|
}
|
|
2083
2117
|
}))
|
|
2084
|
-
})]),
|
|
2085
|
-
let { dom: a, destroy: o } =
|
|
2118
|
+
})]), Yn = (e, t, n, r, i) => {
|
|
2119
|
+
let { dom: a, destroy: o } = bn(e, t, n, i), s = a;
|
|
2086
2120
|
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");
|
|
2087
2121
|
let c = document.createElement("div");
|
|
2088
2122
|
c.className = "bn-resize-handle", c.style.left = "4px", c.style.display = "none", r.appendChild(c);
|
|
@@ -2126,11 +2160,11 @@ var Bn = {
|
|
|
2126
2160
|
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);
|
|
2127
2161
|
}
|
|
2128
2162
|
};
|
|
2129
|
-
},
|
|
2163
|
+
}, Xn = (e) => ({
|
|
2130
2164
|
url: e.src || void 0,
|
|
2131
2165
|
previewWidth: e.width || void 0,
|
|
2132
2166
|
name: e.alt || void 0
|
|
2133
|
-
}),
|
|
2167
|
+
}), Zn = "<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>", Qn = P((e = {}) => ({
|
|
2134
2168
|
type: "image",
|
|
2135
2169
|
propSchema: {
|
|
2136
2170
|
textAlignment: G.textAlignment,
|
|
@@ -2145,26 +2179,26 @@ var Bn = {
|
|
|
2145
2179
|
}
|
|
2146
2180
|
},
|
|
2147
2181
|
content: "none"
|
|
2148
|
-
})),
|
|
2182
|
+
})), $n = (e = {}) => (e) => {
|
|
2149
2183
|
if (e.tagName === "IMG") {
|
|
2150
2184
|
if (e.closest("figure")) return;
|
|
2151
2185
|
let { backgroundColor: t } = K(e);
|
|
2152
2186
|
return {
|
|
2153
|
-
...
|
|
2187
|
+
...Xn(e),
|
|
2154
2188
|
backgroundColor: t
|
|
2155
2189
|
};
|
|
2156
2190
|
}
|
|
2157
2191
|
if (e.tagName === "FIGURE") {
|
|
2158
|
-
let t =
|
|
2192
|
+
let t = gn(e, "img");
|
|
2159
2193
|
if (!t) return;
|
|
2160
2194
|
let { targetElement: n, caption: r } = t, { backgroundColor: i } = K(e);
|
|
2161
2195
|
return {
|
|
2162
|
-
...
|
|
2196
|
+
...Xn(n),
|
|
2163
2197
|
backgroundColor: i,
|
|
2164
2198
|
caption: r
|
|
2165
2199
|
};
|
|
2166
2200
|
}
|
|
2167
|
-
},
|
|
2201
|
+
}, er = (e = {}) => (t, n) => {
|
|
2168
2202
|
let r = document.createElement("div");
|
|
2169
2203
|
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>";
|
|
2170
2204
|
let i = document.createElement("div");
|
|
@@ -2172,19 +2206,19 @@ var Bn = {
|
|
|
2172
2206
|
let a = document.createElement("img");
|
|
2173
2207
|
return a.className = "bn-visual-media", n.resolveFileUrl ? n.resolveFileUrl(t.props.url).then((e) => {
|
|
2174
2208
|
a.src = e;
|
|
2175
|
-
}) : a.src = t.props.url, a.alt = t.props.name || "", a.contentEditable = "false", a.draggable = !1, t.props.previewWidth && (a.width = t.props.previewWidth), i.appendChild(a),
|
|
2176
|
-
},
|
|
2209
|
+
}) : a.src = t.props.url, a.alt = t.props.name || "", a.contentEditable = "false", a.draggable = !1, t.props.previewWidth && (a.width = t.props.previewWidth), i.appendChild(a), Yn(t, n, { dom: i }, i, r.firstElementChild);
|
|
2210
|
+
}, tr = (e = {}) => (e, t) => {
|
|
2177
2211
|
if (!e.props.url) return { dom: document.createElement("img") };
|
|
2178
2212
|
let n;
|
|
2179
|
-
return e.props.showPreview ? (n = document.createElement("img"), n.src = e.props.url, n.alt = e.props.name || "", 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 ?
|
|
2180
|
-
},
|
|
2213
|
+
return e.props.showPreview ? (n = document.createElement("img"), n.src = e.props.url, n.alt = e.props.name || "", 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 ? xn(n, e.props.caption) : Sn(n, e.props.caption) : { dom: n };
|
|
2214
|
+
}, nr = F(Qn, (e) => ({
|
|
2181
2215
|
meta: { fileBlockAccept: ["image/*"] },
|
|
2182
|
-
parse:
|
|
2183
|
-
render:
|
|
2184
|
-
toExternalHTML:
|
|
2216
|
+
parse: $n(e),
|
|
2217
|
+
render: er(e),
|
|
2218
|
+
toExternalHTML: tr(e),
|
|
2185
2219
|
runsBefore: ["file"]
|
|
2186
|
-
})),
|
|
2187
|
-
let i = b(
|
|
2220
|
+
})), rr = (e, t, n) => ({ state: r, dispatch: i }) => i ? ir(r.tr, e, t, n) : !0, ir = (e, t, n, r) => {
|
|
2221
|
+
let i = b(Me(e.doc, t));
|
|
2188
2222
|
if (!i.isBlockContainer) return !1;
|
|
2189
2223
|
let a = k(e), o = [{
|
|
2190
2224
|
type: i.bnBlock.node.type,
|
|
@@ -2197,23 +2231,23 @@ var Bn = {
|
|
|
2197
2231
|
attrs: r ? { ...i.blockContent.node.attrs } : {}
|
|
2198
2232
|
}];
|
|
2199
2233
|
return e.split(t, 2, o), !0;
|
|
2200
|
-
},
|
|
2234
|
+
}, ar = (e, t) => {
|
|
2201
2235
|
let { blockInfo: n, selectionEmpty: r } = e.transact((e) => ({
|
|
2202
|
-
blockInfo:
|
|
2236
|
+
blockInfo: Pe(e),
|
|
2203
2237
|
selectionEmpty: e.selection.anchor === e.selection.head
|
|
2204
2238
|
}));
|
|
2205
2239
|
if (!n.isBlockContainer) return !1;
|
|
2206
2240
|
let { bnBlock: i, blockContent: a } = n;
|
|
2207
2241
|
return a.node.type.name !== t || !r ? !1 : a.node.childCount === 0 ? (e.transact((e) => {
|
|
2208
|
-
|
|
2242
|
+
U(e, i.beforePos, {
|
|
2209
2243
|
type: "paragraph",
|
|
2210
2244
|
props: {}
|
|
2211
2245
|
});
|
|
2212
|
-
}), !0) : a.node.childCount > 0 ? e.transact((e) => (e.deleteSelection(), e.scrollIntoView(),
|
|
2246
|
+
}), !0) : a.node.childCount > 0 ? e.transact((e) => (e.deleteSelection(), e.scrollIntoView(), ir(e, e.selection.from, !0))) : !1;
|
|
2213
2247
|
};
|
|
2214
2248
|
//#endregion
|
|
2215
2249
|
//#region src/blocks/ListItem/getListItemContent.ts
|
|
2216
|
-
function
|
|
2250
|
+
function or(e, t, n) {
|
|
2217
2251
|
let a = r.fromSchema(t), o = e, s = document.createElement("div");
|
|
2218
2252
|
s.setAttribute("data-node-type", "blockGroup");
|
|
2219
2253
|
for (let e of Array.from(o.childNodes)) s.appendChild(e.cloneNode(!0));
|
|
@@ -2230,18 +2264,18 @@ function rr(e, t, n) {
|
|
|
2230
2264
|
}
|
|
2231
2265
|
//#endregion
|
|
2232
2266
|
//#region src/blocks/ListItem/BulletListItem/block.ts
|
|
2233
|
-
var
|
|
2267
|
+
var sr = P(() => ({
|
|
2234
2268
|
type: "bulletListItem",
|
|
2235
2269
|
propSchema: { ...G },
|
|
2236
2270
|
content: "inline"
|
|
2237
|
-
})),
|
|
2271
|
+
})), cr = F(sr, {
|
|
2238
2272
|
meta: { isolating: !1 },
|
|
2239
2273
|
parse(e) {
|
|
2240
2274
|
if (e.tagName !== "LI") return;
|
|
2241
2275
|
let t = e.parentElement;
|
|
2242
2276
|
if (t === null || t.tagName === "UL" || t.tagName === "DIV" && t.parentElement?.tagName === "UL" || !e.closest("ul, ol")) return K(e);
|
|
2243
2277
|
},
|
|
2244
|
-
parseContent: ({ el: e, schema: t }) =>
|
|
2278
|
+
parseContent: ({ el: e, schema: t }) => or(e, t, "bulletListItem"),
|
|
2245
2279
|
render() {
|
|
2246
2280
|
let e = document.createElement("p");
|
|
2247
2281
|
return {
|
|
@@ -2259,7 +2293,7 @@ var ir = F(() => ({
|
|
|
2259
2293
|
}, [n({
|
|
2260
2294
|
key: "bullet-list-item-shortcuts",
|
|
2261
2295
|
keyboardShortcuts: {
|
|
2262
|
-
Enter: ({ editor: e }) =>
|
|
2296
|
+
Enter: ({ editor: e }) => ar(e, "bulletListItem"),
|
|
2263
2297
|
"Mod-Shift-8": ({ editor: e }) => {
|
|
2264
2298
|
let t = e.getTextCursorPosition();
|
|
2265
2299
|
return e.schema.blockSchema[t.block.type].content === "inline" ? (e.updateBlock(t.block, {
|
|
@@ -2271,13 +2305,13 @@ var ir = F(() => ({
|
|
|
2271
2305
|
inputRules: [{
|
|
2272
2306
|
find: /^\s?[-+*]\s$/,
|
|
2273
2307
|
replace({ editor: e }) {
|
|
2274
|
-
if (
|
|
2308
|
+
if (Pe(e.prosemirrorState).blockNoteType !== "heading") return {
|
|
2275
2309
|
type: "bulletListItem",
|
|
2276
2310
|
props: {}
|
|
2277
2311
|
};
|
|
2278
2312
|
}
|
|
2279
2313
|
}]
|
|
2280
|
-
})]),
|
|
2314
|
+
})]), lr = P(() => ({
|
|
2281
2315
|
type: "checkListItem",
|
|
2282
2316
|
propSchema: {
|
|
2283
2317
|
...G,
|
|
@@ -2287,7 +2321,7 @@ var ir = F(() => ({
|
|
|
2287
2321
|
}
|
|
2288
2322
|
},
|
|
2289
2323
|
content: "inline"
|
|
2290
|
-
})),
|
|
2324
|
+
})), ur = F(lr, {
|
|
2291
2325
|
meta: { isolating: !1 },
|
|
2292
2326
|
parse(e) {
|
|
2293
2327
|
if (e.tagName === "input") return e.closest("[data-content-type]") || e.closest("li") ? void 0 : e.type === "checkbox" ? { checked: e.checked } : void 0;
|
|
@@ -2301,7 +2335,7 @@ var ir = F(() => ({
|
|
|
2301
2335
|
};
|
|
2302
2336
|
}
|
|
2303
2337
|
},
|
|
2304
|
-
parseContent: ({ el: e, schema: t }) =>
|
|
2338
|
+
parseContent: ({ el: e, schema: t }) => or(e, t, "checkListItem"),
|
|
2305
2339
|
render(e, t) {
|
|
2306
2340
|
let n = document.createDocumentFragment(), r = document.createElement("input");
|
|
2307
2341
|
r.type = "checkbox", r.checked = e.props.checked, e.props.checked && r.setAttribute("checked", ""), r.disabled = !t.isEditable, r.addEventListener("change", () => {
|
|
@@ -2326,7 +2360,7 @@ var ir = F(() => ({
|
|
|
2326
2360
|
}, [n({
|
|
2327
2361
|
key: "check-list-item-shortcuts",
|
|
2328
2362
|
keyboardShortcuts: {
|
|
2329
|
-
Enter: ({ editor: e }) =>
|
|
2363
|
+
Enter: ({ editor: e }) => ar(e, "checkListItem"),
|
|
2330
2364
|
"Mod-Shift-9": ({ editor: e }) => {
|
|
2331
2365
|
let t = e.getTextCursorPosition();
|
|
2332
2366
|
return e.schema.blockSchema[t.block.type].content === "inline" ? (e.updateBlock(t.block, {
|
|
@@ -2355,7 +2389,7 @@ var ir = F(() => ({
|
|
|
2355
2389
|
})]);
|
|
2356
2390
|
//#endregion
|
|
2357
2391
|
//#region src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts
|
|
2358
|
-
function
|
|
2392
|
+
function dr(e, t, n, r) {
|
|
2359
2393
|
let i = !!e.firstChild.attrs.start, a = b({
|
|
2360
2394
|
posBeforeNode: t,
|
|
2361
2395
|
node: e
|
|
@@ -2404,7 +2438,7 @@ function cr(e, t, n, r) {
|
|
|
2404
2438
|
hasStart: i
|
|
2405
2439
|
};
|
|
2406
2440
|
}
|
|
2407
|
-
function
|
|
2441
|
+
function fr(e, t) {
|
|
2408
2442
|
let n = /* @__PURE__ */ new Map(), r = t.decorations.map(e.mapping, e.doc), i = e.changedRange() ?? {
|
|
2409
2443
|
from: 0,
|
|
2410
2444
|
to: e.doc.nodeSize - 2
|
|
@@ -2412,8 +2446,8 @@ function lr(e, t) {
|
|
|
2412
2446
|
e.doc.nodesBetween(i.from, e.doc.nodeSize - 2, (t, s, c) => {
|
|
2413
2447
|
if (c && o.has(c)) return !1;
|
|
2414
2448
|
if (t.type.name === "blockContainer" && t.firstChild.type.name === "numberedListItem") {
|
|
2415
|
-
let { index: l, isFirst: u, hasStart: d } =
|
|
2416
|
-
if (r.find(s + 1, s + 1 + f.nodeSize, (e) => e.index === l && e.isFirst === u && e.hasStart === d).length === 0) a.push(
|
|
2449
|
+
let { index: l, isFirst: u, hasStart: d } = dr(t, s, e, n), f = e.doc.nodeAt(s + 1);
|
|
2450
|
+
if (r.find(s + 1, s + 1 + f.nodeSize, (e) => e.index === l && e.isFirst === u && e.hasStart === d).length === 0) a.push(xe.node(s + 1, s + 1 + f.nodeSize, { "data-index": l.toString() }, {
|
|
2417
2451
|
index: l,
|
|
2418
2452
|
isFirst: u,
|
|
2419
2453
|
hasStart: d
|
|
@@ -2424,20 +2458,20 @@ function lr(e, t) {
|
|
|
2424
2458
|
let s = a.flatMap((e) => r.find(e.from, e.to));
|
|
2425
2459
|
return { decorations: r.remove(s).add(e.doc, a) };
|
|
2426
2460
|
}
|
|
2427
|
-
var
|
|
2428
|
-
key: new
|
|
2461
|
+
var pr = () => new ye({
|
|
2462
|
+
key: new be("numbered-list-indexing-decorations"),
|
|
2429
2463
|
state: {
|
|
2430
2464
|
init(e, t) {
|
|
2431
|
-
return
|
|
2465
|
+
return fr(t.tr, { decorations: Se.empty });
|
|
2432
2466
|
},
|
|
2433
2467
|
apply(e, t) {
|
|
2434
|
-
return !e.docChanged && t.decorations ? t :
|
|
2468
|
+
return !e.docChanged && t.decorations ? t : fr(e, t);
|
|
2435
2469
|
}
|
|
2436
2470
|
},
|
|
2437
2471
|
props: { decorations(e) {
|
|
2438
|
-
return this.getState(e)?.decorations ??
|
|
2472
|
+
return this.getState(e)?.decorations ?? Se.empty;
|
|
2439
2473
|
} }
|
|
2440
|
-
}),
|
|
2474
|
+
}), mr = P(() => ({
|
|
2441
2475
|
type: "numberedListItem",
|
|
2442
2476
|
propSchema: {
|
|
2443
2477
|
...G,
|
|
@@ -2447,7 +2481,7 @@ var ur = () => new ve({
|
|
|
2447
2481
|
}
|
|
2448
2482
|
},
|
|
2449
2483
|
content: "inline"
|
|
2450
|
-
})),
|
|
2484
|
+
})), hr = F(mr, {
|
|
2451
2485
|
meta: { isolating: !1 },
|
|
2452
2486
|
parse(e) {
|
|
2453
2487
|
if (e.tagName !== "LI") return;
|
|
@@ -2460,7 +2494,7 @@ var ur = () => new ve({
|
|
|
2460
2494
|
};
|
|
2461
2495
|
}
|
|
2462
2496
|
},
|
|
2463
|
-
parseContent: ({ el: e, schema: t }) =>
|
|
2497
|
+
parseContent: ({ el: e, schema: t }) => or(e, t, "numberedListItem"),
|
|
2464
2498
|
render() {
|
|
2465
2499
|
let e = document.createElement("p");
|
|
2466
2500
|
return {
|
|
@@ -2480,7 +2514,7 @@ var ur = () => new ve({
|
|
|
2480
2514
|
inputRules: [{
|
|
2481
2515
|
find: /^\s?(\d+)\.\s$/,
|
|
2482
2516
|
replace({ match: e, editor: t }) {
|
|
2483
|
-
if (
|
|
2517
|
+
if (Pe(t.prosemirrorState).blockNoteType === "heading") return;
|
|
2484
2518
|
let n = parseInt(e[1]);
|
|
2485
2519
|
return {
|
|
2486
2520
|
type: "numberedListItem",
|
|
@@ -2489,7 +2523,7 @@ var ur = () => new ve({
|
|
|
2489
2523
|
}
|
|
2490
2524
|
}],
|
|
2491
2525
|
keyboardShortcuts: {
|
|
2492
|
-
Enter: ({ editor: e }) =>
|
|
2526
|
+
Enter: ({ editor: e }) => ar(e, "numberedListItem"),
|
|
2493
2527
|
"Mod-Shift-7": ({ editor: e }) => {
|
|
2494
2528
|
let t = e.getTextCursorPosition();
|
|
2495
2529
|
return e.schema.blockSchema[t.block.type].content === "inline" ? (e.updateBlock(t.block, {
|
|
@@ -2498,12 +2532,12 @@ var ur = () => new ve({
|
|
|
2498
2532
|
}), !0) : !1;
|
|
2499
2533
|
}
|
|
2500
2534
|
},
|
|
2501
|
-
prosemirrorPlugins: [
|
|
2502
|
-
})]),
|
|
2535
|
+
prosemirrorPlugins: [pr()]
|
|
2536
|
+
})]), gr = P(() => ({
|
|
2503
2537
|
type: "toggleListItem",
|
|
2504
2538
|
propSchema: { ...G },
|
|
2505
2539
|
content: "inline"
|
|
2506
|
-
})),
|
|
2540
|
+
})), _r = F(gr, {
|
|
2507
2541
|
meta: { isolating: !1 },
|
|
2508
2542
|
parse(e) {
|
|
2509
2543
|
if (e.tagName === "DETAILS") return K(e);
|
|
@@ -2515,13 +2549,13 @@ var ur = () => new ve({
|
|
|
2515
2549
|
parseContent: ({ el: e, schema: t }) => {
|
|
2516
2550
|
let n = e.tagName === "DETAILS" ? e : e.querySelector(":scope > details");
|
|
2517
2551
|
if (!n) throw Error("No details found in toggleListItem parseContent");
|
|
2518
|
-
return
|
|
2552
|
+
return Hn(n, t, "toggleListItem");
|
|
2519
2553
|
},
|
|
2520
2554
|
runsBefore: ["bulletListItem"],
|
|
2521
2555
|
render(e, t) {
|
|
2522
2556
|
let n = document.createElement("p");
|
|
2523
2557
|
return {
|
|
2524
|
-
...
|
|
2558
|
+
...Wn(e, t, n),
|
|
2525
2559
|
contentDOM: n
|
|
2526
2560
|
};
|
|
2527
2561
|
},
|
|
@@ -2538,7 +2572,7 @@ var ur = () => new ve({
|
|
|
2538
2572
|
}, [n({
|
|
2539
2573
|
key: "toggle-list-item-shortcuts",
|
|
2540
2574
|
keyboardShortcuts: {
|
|
2541
|
-
Enter: ({ editor: e }) =>
|
|
2575
|
+
Enter: ({ editor: e }) => ar(e, "toggleListItem"),
|
|
2542
2576
|
"Mod-Shift-6": ({ editor: e }) => {
|
|
2543
2577
|
let t = e.getTextCursorPosition();
|
|
2544
2578
|
return e.schema.blockSchema[t.block.type].content === "inline" ? (e.updateBlock(t.block, {
|
|
@@ -2547,11 +2581,11 @@ var ur = () => new ve({
|
|
|
2547
2581
|
}), !0) : !1;
|
|
2548
2582
|
}
|
|
2549
2583
|
}
|
|
2550
|
-
})]),
|
|
2584
|
+
})]), vr = P(() => ({
|
|
2551
2585
|
type: "pageBreak",
|
|
2552
2586
|
propSchema: {},
|
|
2553
2587
|
content: "none"
|
|
2554
|
-
})),
|
|
2588
|
+
})), yr = F(vr, {
|
|
2555
2589
|
parse(e) {
|
|
2556
2590
|
if (e.tagName === "DIV" && e.hasAttribute("data-page-break")) return {};
|
|
2557
2591
|
},
|
|
@@ -2563,11 +2597,11 @@ var ur = () => new ve({
|
|
|
2563
2597
|
let e = document.createElement("div");
|
|
2564
2598
|
return e.setAttribute("data-page-break", ""), { dom: e };
|
|
2565
2599
|
}
|
|
2566
|
-
}),
|
|
2600
|
+
}), br = (e) => e.extend({ blockSpecs: { pageBreak: yr() } }), xr = P(() => ({
|
|
2567
2601
|
type: "paragraph",
|
|
2568
2602
|
propSchema: G,
|
|
2569
2603
|
content: "inline"
|
|
2570
|
-
})),
|
|
2604
|
+
})), Sr = F(xr, {
|
|
2571
2605
|
meta: { isolating: !1 },
|
|
2572
2606
|
parse: (e) => {
|
|
2573
2607
|
if (e.tagName === "P" && e.textContent?.trim()) return K(e);
|
|
@@ -2596,14 +2630,14 @@ var ur = () => new ve({
|
|
|
2596
2630
|
props: {}
|
|
2597
2631
|
}), !0) : !1;
|
|
2598
2632
|
} }
|
|
2599
|
-
})]),
|
|
2633
|
+
})]), Cr = P(() => ({
|
|
2600
2634
|
type: "quote",
|
|
2601
2635
|
propSchema: {
|
|
2602
2636
|
backgroundColor: G.backgroundColor,
|
|
2603
2637
|
textColor: G.textColor
|
|
2604
2638
|
},
|
|
2605
2639
|
content: "inline"
|
|
2606
|
-
})),
|
|
2640
|
+
})), wr = F(Cr, {
|
|
2607
2641
|
meta: { isolating: !1 },
|
|
2608
2642
|
parse(e) {
|
|
2609
2643
|
if (e.tagName === "BLOCKQUOTE") {
|
|
@@ -2654,33 +2688,33 @@ var ur = () => new ve({
|
|
|
2654
2688
|
};
|
|
2655
2689
|
}
|
|
2656
2690
|
}]
|
|
2657
|
-
})]),
|
|
2691
|
+
})]), Tr = "blockLevelSuggestion";
|
|
2658
2692
|
function Y(e) {
|
|
2659
2693
|
return e && e.options.extensions.some((e) => {
|
|
2660
2694
|
if (e.type !== "mark") return !1;
|
|
2661
2695
|
let t = g(e, "group");
|
|
2662
2696
|
return typeof t == "string" && t.split(" ").includes("blockLevelSuggestion");
|
|
2663
|
-
}) ?
|
|
2697
|
+
}) ? Tr : "";
|
|
2664
2698
|
}
|
|
2665
|
-
var
|
|
2699
|
+
var Er = 120, Dr = 31, Or = s.create({
|
|
2666
2700
|
name: "BlockNoteTableExtension",
|
|
2667
|
-
addProseMirrorPlugins: () => [
|
|
2701
|
+
addProseMirrorPlugins: () => [ue({
|
|
2668
2702
|
cellMinWidth: 35,
|
|
2669
2703
|
defaultCellMinWidth: 120,
|
|
2670
2704
|
View: null
|
|
2671
|
-
}),
|
|
2705
|
+
}), ge()],
|
|
2672
2706
|
addKeyboardShortcuts() {
|
|
2673
2707
|
return {
|
|
2674
|
-
Enter: () =>
|
|
2675
|
-
let n =
|
|
2676
|
-
return r && t && t(e.tr.setSelection(
|
|
2708
|
+
Enter: () => fe(this.editor.state) ? this.editor.commands.command(({ state: e, dispatch: t }) => {
|
|
2709
|
+
let n = he(e), r = n ? me(n, "vert", 1) : null;
|
|
2710
|
+
return r && t && t(e.tr.setSelection(re.between(r, pe(r))).scrollIntoView()), !0;
|
|
2677
2711
|
}) : !1,
|
|
2678
2712
|
Backspace: () => {
|
|
2679
2713
|
let e = this.editor.state.selection, t = e.empty, n = e.$head.parentOffset === 0, r = e.$head.node().type.name === "tableParagraph";
|
|
2680
2714
|
return t && n && r;
|
|
2681
2715
|
},
|
|
2682
|
-
Tab: () => this.editor.commands.command(({ state: e, dispatch: t, view: n }) =>
|
|
2683
|
-
"Shift-Tab": () => this.editor.commands.command(({ state: e, dispatch: t, view: n }) =>
|
|
2716
|
+
Tab: () => this.editor.commands.command(({ state: e, dispatch: t, view: n }) => fe(e) ? (de(1)(e, t, n), !0) : !1),
|
|
2717
|
+
"Shift-Tab": () => this.editor.commands.command(({ state: e, dispatch: t, view: n }) => fe(e) ? (de(-1)(e, t, n), !0) : !1)
|
|
2684
2718
|
};
|
|
2685
2719
|
},
|
|
2686
2720
|
extendNodeSchema(e) {
|
|
@@ -2690,7 +2724,7 @@ var Cr = 120, wr = 31, Tr = s.create({
|
|
|
2690
2724
|
storage: e.storage
|
|
2691
2725
|
})) };
|
|
2692
2726
|
}
|
|
2693
|
-
}),
|
|
2727
|
+
}), kr = { textColor: G.textColor }, Ar = u.create({
|
|
2694
2728
|
name: "tableHeader",
|
|
2695
2729
|
addOptions() {
|
|
2696
2730
|
return { HTMLAttributes: {} };
|
|
@@ -2717,7 +2751,7 @@ var Cr = 120, wr = 31, Tr = s.create({
|
|
|
2717
2751
|
parseHTML() {
|
|
2718
2752
|
return [{
|
|
2719
2753
|
tag: "th",
|
|
2720
|
-
getContent: (e, t) =>
|
|
2754
|
+
getContent: (e, t) => Fr(e, t)
|
|
2721
2755
|
}];
|
|
2722
2756
|
},
|
|
2723
2757
|
renderHTML({ HTMLAttributes: e }) {
|
|
@@ -2727,7 +2761,7 @@ var Cr = 120, wr = 31, Tr = s.create({
|
|
|
2727
2761
|
0
|
|
2728
2762
|
];
|
|
2729
2763
|
}
|
|
2730
|
-
}),
|
|
2764
|
+
}), jr = u.create({
|
|
2731
2765
|
name: "tableCell",
|
|
2732
2766
|
addOptions() {
|
|
2733
2767
|
return { HTMLAttributes: {} };
|
|
@@ -2754,7 +2788,7 @@ var Cr = 120, wr = 31, Tr = s.create({
|
|
|
2754
2788
|
parseHTML() {
|
|
2755
2789
|
return [{
|
|
2756
2790
|
tag: "td",
|
|
2757
|
-
getContent: (e, t) =>
|
|
2791
|
+
getContent: (e, t) => Fr(e, t)
|
|
2758
2792
|
}];
|
|
2759
2793
|
},
|
|
2760
2794
|
renderHTML({ HTMLAttributes: e }) {
|
|
@@ -2764,7 +2798,7 @@ var Cr = 120, wr = 31, Tr = s.create({
|
|
|
2764
2798
|
0
|
|
2765
2799
|
];
|
|
2766
2800
|
}
|
|
2767
|
-
}),
|
|
2801
|
+
}), Mr = u.create({
|
|
2768
2802
|
name: "table",
|
|
2769
2803
|
content: "tableRow+",
|
|
2770
2804
|
group: "blockContent",
|
|
@@ -2790,7 +2824,7 @@ var Cr = 120, wr = 31, Tr = s.create({
|
|
|
2790
2824
|
},
|
|
2791
2825
|
addNodeView() {
|
|
2792
2826
|
return ({ node: e, HTMLAttributes: t }) => {
|
|
2793
|
-
class n extends
|
|
2827
|
+
class n extends le {
|
|
2794
2828
|
node;
|
|
2795
2829
|
cellMinWidth;
|
|
2796
2830
|
blockContentHTMLAttributes;
|
|
@@ -2809,8 +2843,8 @@ var Cr = 120, wr = 31, Tr = s.create({
|
|
|
2809
2843
|
}
|
|
2810
2844
|
update(e) {
|
|
2811
2845
|
if (!super.update(e)) return !1;
|
|
2812
|
-
for (let [t, n] of Object.entries(
|
|
2813
|
-
let r =
|
|
2846
|
+
for (let [t, n] of Object.entries(kr)) {
|
|
2847
|
+
let r = M(t), i = e.attrs[t];
|
|
2814
2848
|
i === n.default ? this.dom.removeAttribute(r) : this.dom.setAttribute(r, String(i));
|
|
2815
2849
|
}
|
|
2816
2850
|
return !0;
|
|
@@ -2822,7 +2856,7 @@ var Cr = 120, wr = 31, Tr = s.create({
|
|
|
2822
2856
|
});
|
|
2823
2857
|
};
|
|
2824
2858
|
}
|
|
2825
|
-
}),
|
|
2859
|
+
}), Nr = u.create({
|
|
2826
2860
|
name: "tableParagraph",
|
|
2827
2861
|
group: "tableContent",
|
|
2828
2862
|
content: "inline*",
|
|
@@ -2844,7 +2878,7 @@ var Cr = 120, wr = 31, Tr = s.create({
|
|
|
2844
2878
|
0
|
|
2845
2879
|
];
|
|
2846
2880
|
}
|
|
2847
|
-
}),
|
|
2881
|
+
}), Pr = u.create({
|
|
2848
2882
|
name: "tableRow",
|
|
2849
2883
|
addOptions() {
|
|
2850
2884
|
return { HTMLAttributes: {} };
|
|
@@ -2865,29 +2899,29 @@ var Cr = 120, wr = 31, Tr = s.create({
|
|
|
2865
2899
|
];
|
|
2866
2900
|
}
|
|
2867
2901
|
});
|
|
2868
|
-
function
|
|
2902
|
+
function Fr(e, t) {
|
|
2869
2903
|
let n = r.fromSchema(t).parse(e, { topNode: t.nodes.blockGroup.create() }), a = [];
|
|
2870
2904
|
return n.content.descendants((e) => {
|
|
2871
2905
|
if (e.isInline) return a.push(e), !1;
|
|
2872
2906
|
}), i.fromArray(a);
|
|
2873
2907
|
}
|
|
2874
|
-
var
|
|
2875
|
-
node:
|
|
2908
|
+
var Ir = () => pt({
|
|
2909
|
+
node: Mr,
|
|
2876
2910
|
type: "table",
|
|
2877
2911
|
content: "table"
|
|
2878
|
-
},
|
|
2912
|
+
}, kr, [n({
|
|
2879
2913
|
key: "table-extensions",
|
|
2880
2914
|
tiptapExtensions: [
|
|
2881
|
-
Tr,
|
|
2882
|
-
Ar,
|
|
2883
|
-
Dr,
|
|
2884
2915
|
Or,
|
|
2885
|
-
|
|
2916
|
+
Nr,
|
|
2917
|
+
Ar,
|
|
2918
|
+
jr,
|
|
2919
|
+
Pr
|
|
2886
2920
|
]
|
|
2887
2921
|
}), n({
|
|
2888
2922
|
key: "table-keyboard-delete",
|
|
2889
2923
|
keyboardShortcuts: { Backspace: ({ editor: e }) => {
|
|
2890
|
-
if (!(e.prosemirrorState.selection instanceof
|
|
2924
|
+
if (!(e.prosemirrorState.selection instanceof se)) return !1;
|
|
2891
2925
|
let t = e.getTextCursorPosition().block, n = t.content, r = 0;
|
|
2892
2926
|
for (let e of n.rows) for (let t of e.cells) {
|
|
2893
2927
|
if ("type" in t && t.content.length > 0 || !("type" in t) && t.length > 0) return !1;
|
|
@@ -2900,11 +2934,11 @@ var Nr = () => lt({
|
|
|
2900
2934
|
(e.getPrevBlock(t) || e.getNextBlock(t)) && e.setTextCursorPosition(t), e.removeBlocks([t]);
|
|
2901
2935
|
}), !0);
|
|
2902
2936
|
} }
|
|
2903
|
-
})]),
|
|
2937
|
+
})]), Lr = (e) => ({
|
|
2904
2938
|
url: e.src || void 0,
|
|
2905
2939
|
previewWidth: e.width || void 0,
|
|
2906
2940
|
name: e.getAttribute("data-name") || void 0
|
|
2907
|
-
}),
|
|
2941
|
+
}), Rr = "<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>", zr = P((e) => ({
|
|
2908
2942
|
type: "video",
|
|
2909
2943
|
propSchema: {
|
|
2910
2944
|
textAlignment: G.textAlignment,
|
|
@@ -2919,28 +2953,28 @@ var Nr = () => lt({
|
|
|
2919
2953
|
}
|
|
2920
2954
|
},
|
|
2921
2955
|
content: "none"
|
|
2922
|
-
})),
|
|
2956
|
+
})), Br = (e) => (e) => {
|
|
2923
2957
|
if (e.tagName === "VIDEO") {
|
|
2924
2958
|
if (e.closest("figure")) return;
|
|
2925
2959
|
let { backgroundColor: t } = K(e);
|
|
2926
2960
|
return {
|
|
2927
|
-
...
|
|
2961
|
+
...Lr(e),
|
|
2928
2962
|
backgroundColor: t
|
|
2929
2963
|
};
|
|
2930
2964
|
}
|
|
2931
2965
|
if (e.tagName === "FIGURE") {
|
|
2932
|
-
let t =
|
|
2966
|
+
let t = gn(e, "video");
|
|
2933
2967
|
if (!t) return;
|
|
2934
2968
|
let { targetElement: n, caption: r } = t, { backgroundColor: i } = K(e);
|
|
2935
2969
|
return {
|
|
2936
|
-
...
|
|
2970
|
+
...Lr(n),
|
|
2937
2971
|
backgroundColor: i,
|
|
2938
2972
|
caption: r
|
|
2939
2973
|
};
|
|
2940
2974
|
}
|
|
2941
|
-
},
|
|
2975
|
+
}, Vr = F(zr, (e) => ({
|
|
2942
2976
|
meta: { fileBlockAccept: ["video/*"] },
|
|
2943
|
-
parse:
|
|
2977
|
+
parse: Br(e),
|
|
2944
2978
|
render(t, n) {
|
|
2945
2979
|
let r = document.createElement("div");
|
|
2946
2980
|
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>";
|
|
@@ -2949,15 +2983,15 @@ var Nr = () => lt({
|
|
|
2949
2983
|
let a = document.createElement("video");
|
|
2950
2984
|
return a.className = "bn-visual-media", n.resolveFileUrl ? n.resolveFileUrl(t.props.url).then((e) => {
|
|
2951
2985
|
a.src = e;
|
|
2952
|
-
}) : a.src = t.props.url, a.controls = !0, a.contentEditable = "false", a.draggable = !1, t.props.previewWidth && (a.width = t.props.previewWidth), i.appendChild(a),
|
|
2986
|
+
}) : a.src = t.props.url, a.controls = !0, a.contentEditable = "false", a.draggable = !1, t.props.previewWidth && (a.width = t.props.previewWidth), i.appendChild(a), Yn(t, n, { dom: i }, i, r.firstElementChild);
|
|
2953
2987
|
},
|
|
2954
2988
|
toExternalHTML(e) {
|
|
2955
2989
|
if (!e.props.url) return { dom: document.createElement("video") };
|
|
2956
2990
|
let t;
|
|
2957
|
-
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 ?
|
|
2991
|
+
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 ? xn(t, e.props.caption) : Sn(t, e.props.caption) : { dom: t };
|
|
2958
2992
|
},
|
|
2959
2993
|
runsBefore: ["file"]
|
|
2960
|
-
})),
|
|
2994
|
+
})), Hr = async (e) => {
|
|
2961
2995
|
let t = new FormData();
|
|
2962
2996
|
return t.append("file", e), (await (await fetch("https://tmpfiles.org/api/v1/upload", {
|
|
2963
2997
|
method: "POST",
|
|
@@ -2982,17 +3016,21 @@ function X(e, t, n) {
|
|
|
2982
3016
|
}
|
|
2983
3017
|
return !0;
|
|
2984
3018
|
}
|
|
2985
|
-
function
|
|
3019
|
+
function Ur(e, t, n, r) {
|
|
2986
3020
|
return X(t, n, r) && e.type === n;
|
|
2987
3021
|
}
|
|
2988
|
-
function
|
|
2989
|
-
return e instanceof
|
|
3022
|
+
function Wr(e) {
|
|
3023
|
+
return e instanceof se;
|
|
3024
|
+
}
|
|
3025
|
+
function Gr(e) {
|
|
3026
|
+
let t = e.type.spec.tableRole;
|
|
3027
|
+
return t === "cell" || t === "header_cell";
|
|
2990
3028
|
}
|
|
2991
3029
|
//#endregion
|
|
2992
3030
|
//#region src/extensions/FormattingToolbar/FormattingToolbar.ts
|
|
2993
3031
|
var Z = n(({ editor: e }) => {
|
|
2994
3032
|
let n = t(!1), r = () => e.transact((e) => {
|
|
2995
|
-
if (e.selection.empty || e.selection instanceof
|
|
3033
|
+
if (e.selection.empty || e.selection instanceof re && e.doc.textBetween(e.selection.from, e.selection.to).length === 0) return !1;
|
|
2996
3034
|
let t = !1;
|
|
2997
3035
|
return e.selection.content().content.descendants((e) => (e.type.spec.code && (t = !0), !t)), !t;
|
|
2998
3036
|
});
|
|
@@ -3029,7 +3067,7 @@ var Z = n(({ editor: e }) => {
|
|
|
3029
3067
|
});
|
|
3030
3068
|
//#endregion
|
|
3031
3069
|
//#region src/api/positionMapping.ts
|
|
3032
|
-
function
|
|
3070
|
+
function Kr(e, t, n = "left") {
|
|
3033
3071
|
let r = e.getExtension("yPositionMapping");
|
|
3034
3072
|
if (r) return r.mapPosition(t, n);
|
|
3035
3073
|
let i = e.getExtension("positionMapping");
|
|
@@ -3038,7 +3076,7 @@ function Hr(e, t, n = "left") {
|
|
|
3038
3076
|
}
|
|
3039
3077
|
//#endregion
|
|
3040
3078
|
//#region src/extensions/SuggestionMenu/SuggestionMenu.ts
|
|
3041
|
-
var
|
|
3079
|
+
var qr = m((e) => e.type.name === "blockContainer"), Jr = class {
|
|
3042
3080
|
editor;
|
|
3043
3081
|
state;
|
|
3044
3082
|
emitUpdate;
|
|
@@ -3086,7 +3124,7 @@ var Ur = m((e) => e.type.name === "blockContainer"), Wr = class {
|
|
|
3086
3124
|
to: this.editor.transact((e) => e.selection.from)
|
|
3087
3125
|
}).run();
|
|
3088
3126
|
};
|
|
3089
|
-
}, Q = new ne("SuggestionMenuPlugin"),
|
|
3127
|
+
}, Q = new ne("SuggestionMenuPlugin"), Yr = n(({ editor: e }) => {
|
|
3090
3128
|
let n = /* @__PURE__ */ new Map(), r, i = t(void 0);
|
|
3091
3129
|
return {
|
|
3092
3130
|
key: "suggestionMenu",
|
|
@@ -3115,7 +3153,7 @@ var Ur = m((e) => e.type.name === "blockContainer"), Wr = class {
|
|
|
3115
3153
|
},
|
|
3116
3154
|
prosemirrorPlugins: [new te({
|
|
3117
3155
|
key: Q,
|
|
3118
|
-
view: (t) => (r = new
|
|
3156
|
+
view: (t) => (r = new Jr(e, (e, t) => {
|
|
3119
3157
|
i.setState({
|
|
3120
3158
|
...t,
|
|
3121
3159
|
triggerCharacter: e
|
|
@@ -3128,7 +3166,7 @@ var Ur = m((e) => e.type.name === "blockContainer"), Wr = class {
|
|
|
3128
3166
|
let o = t.getMeta(Q);
|
|
3129
3167
|
if (typeof o == "object" && o) {
|
|
3130
3168
|
n && r?.closeMenu();
|
|
3131
|
-
let t =
|
|
3169
|
+
let t = Kr(e, a.selection.from - o.triggerCharacter.length);
|
|
3132
3170
|
return {
|
|
3133
3171
|
triggerCharacter: o.triggerCharacter,
|
|
3134
3172
|
deleteTriggerCharacter: o.deleteTriggerCharacter !== !1,
|
|
@@ -3146,14 +3184,12 @@ var Ur = m((e) => e.type.name === "blockContainer"), Wr = class {
|
|
|
3146
3184
|
},
|
|
3147
3185
|
props: {
|
|
3148
3186
|
handleTextInput(e, t, r, i) {
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
if (
|
|
3154
|
-
|
|
3155
|
-
return e.dispatch(e.state.tr.insertText(i)), e.dispatch(e.state.tr.setMeta(Q, { triggerCharacter: n }).scrollIntoView()), !0;
|
|
3156
|
-
}
|
|
3187
|
+
let a = e.state.doc, o = [...n.entries()].sort(([e], [t]) => t.length - e.length);
|
|
3188
|
+
for (let [n, r] of o) {
|
|
3189
|
+
let o = a.textBetween(Math.max(0, t - (n.length - i.length)), t) + i;
|
|
3190
|
+
if (n === o) {
|
|
3191
|
+
if (r.shouldOpen && !r.shouldOpen(e.state.tr)) continue;
|
|
3192
|
+
return e.dispatch(e.state.tr.insertText(i)), e.dispatch(e.state.tr.setMeta(Q, { triggerCharacter: o }).scrollIntoView()), !0;
|
|
3157
3193
|
}
|
|
3158
3194
|
}
|
|
3159
3195
|
return !1;
|
|
@@ -3162,14 +3198,14 @@ var Ur = m((e) => e.type.name === "blockContainer"), Wr = class {
|
|
|
3162
3198
|
let t = this.getState(e);
|
|
3163
3199
|
if (t === void 0) return null;
|
|
3164
3200
|
if (!t.deleteTriggerCharacter) {
|
|
3165
|
-
let n =
|
|
3166
|
-
if (n) return
|
|
3201
|
+
let n = qr(e.selection);
|
|
3202
|
+
if (n) return we.create(e.doc, [Ce.node(n.pos, n.pos + n.node.nodeSize, {
|
|
3167
3203
|
nodeName: "span",
|
|
3168
3204
|
class: "bn-suggestion-decorator",
|
|
3169
3205
|
"data-decoration-id": t.decorationId
|
|
3170
3206
|
})]);
|
|
3171
3207
|
}
|
|
3172
|
-
return
|
|
3208
|
+
return we.create(e.doc, [Ce.inline(t.queryStartPos() - t.triggerCharacter.length, t.queryStartPos(), {
|
|
3173
3209
|
nodeName: "span",
|
|
3174
3210
|
class: "bn-suggestion-decorator",
|
|
3175
3211
|
"data-decoration-id": t.decorationId
|
|
@@ -3181,10 +3217,14 @@ var Ur = m((e) => e.type.name === "blockContainer"), Wr = class {
|
|
|
3181
3217
|
});
|
|
3182
3218
|
//#endregion
|
|
3183
3219
|
//#region src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts
|
|
3184
|
-
function
|
|
3220
|
+
function Xr(e) {
|
|
3185
3221
|
let t = e.getTextCursorPosition().block, n = e.schema.blockSchema[t.type].content;
|
|
3186
3222
|
for (; n === "none";) {
|
|
3187
|
-
if (t = e.getTextCursorPosition().nextBlock, t === void 0)
|
|
3223
|
+
if (t = e.getTextCursorPosition().nextBlock, t === void 0) {
|
|
3224
|
+
let t = e.document[e.document.length - 1], n = e.insertBlocks([{ type: "paragraph" }], t, "after")[0];
|
|
3225
|
+
e.setTextCursorPosition(n, "end");
|
|
3226
|
+
return;
|
|
3227
|
+
}
|
|
3188
3228
|
n = e.schema.blockSchema[t.type].content, e.setTextCursorPosition(t, "end");
|
|
3189
3229
|
}
|
|
3190
3230
|
}
|
|
@@ -3192,9 +3232,9 @@ function $(e, t) {
|
|
|
3192
3232
|
let n = e.getTextCursorPosition().block;
|
|
3193
3233
|
if (n.content === void 0) throw Error("Slash Menu open in a block that doesn't contain content.");
|
|
3194
3234
|
let r;
|
|
3195
|
-
return Array.isArray(n.content) && (n.content.length === 1 &&
|
|
3235
|
+
return Array.isArray(n.content) && (n.content.length === 1 && x(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)), Xr(e), r;
|
|
3196
3236
|
}
|
|
3197
|
-
function
|
|
3237
|
+
function Zr(e) {
|
|
3198
3238
|
let t = [];
|
|
3199
3239
|
return X(e, "heading", { level: "number" }) && (e.schema.blockSchema.heading.propSchema.level.values || []).filter((e) => e <= 3).forEach((n) => {
|
|
3200
3240
|
t.push({
|
|
@@ -3342,7 +3382,7 @@ function qr(e) {
|
|
|
3342
3382
|
});
|
|
3343
3383
|
}), t.push({
|
|
3344
3384
|
onItemClick: () => {
|
|
3345
|
-
e.getExtension(
|
|
3385
|
+
e.getExtension(Yr)?.openSuggestionMenu(":", {
|
|
3346
3386
|
deleteTriggerCharacter: !0,
|
|
3347
3387
|
ignoreQueryLength: !0
|
|
3348
3388
|
});
|
|
@@ -3351,17 +3391,17 @@ function qr(e) {
|
|
|
3351
3391
|
...e.dictionary.slash_menu.emoji
|
|
3352
3392
|
}), t;
|
|
3353
3393
|
}
|
|
3354
|
-
function
|
|
3394
|
+
function Qr(e, t) {
|
|
3355
3395
|
return e.filter(({ title: e, aliases: n }) => e.toLowerCase().includes(t.toLowerCase()) || n && n.filter((e) => e.toLowerCase().includes(t.toLowerCase())).length !== 0);
|
|
3356
3396
|
}
|
|
3357
3397
|
//#endregion
|
|
3358
3398
|
//#region src/blocks/PageBreak/getPageBreakSlashMenuItems.ts
|
|
3359
|
-
function
|
|
3399
|
+
function $r(e) {
|
|
3360
3400
|
return "pageBreak" in e.schema.blockSchema;
|
|
3361
3401
|
}
|
|
3362
|
-
function
|
|
3402
|
+
function ei(e) {
|
|
3363
3403
|
let t = [];
|
|
3364
|
-
return
|
|
3404
|
+
return $r(e) && t.push({
|
|
3365
3405
|
...e.dictionary.slash_menu.page_break,
|
|
3366
3406
|
onItemClick: () => {
|
|
3367
3407
|
$(e, { type: "pageBreak" });
|
|
@@ -3371,22 +3411,22 @@ function Xr(e) {
|
|
|
3371
3411
|
}
|
|
3372
3412
|
//#endregion
|
|
3373
3413
|
//#region src/blocks/defaultBlocks.ts
|
|
3374
|
-
var
|
|
3375
|
-
audio:
|
|
3376
|
-
bulletListItem:
|
|
3377
|
-
checkListItem:
|
|
3378
|
-
codeBlock:
|
|
3379
|
-
divider:
|
|
3380
|
-
file:
|
|
3381
|
-
heading:
|
|
3382
|
-
image:
|
|
3383
|
-
numberedListItem:
|
|
3384
|
-
paragraph:
|
|
3385
|
-
quote:
|
|
3386
|
-
table:
|
|
3387
|
-
toggleListItem:
|
|
3388
|
-
video:
|
|
3389
|
-
},
|
|
3414
|
+
var ti = {
|
|
3415
|
+
audio: kn(),
|
|
3416
|
+
bulletListItem: cr(),
|
|
3417
|
+
checkListItem: ur(),
|
|
3418
|
+
codeBlock: Pn(),
|
|
3419
|
+
divider: Ln(),
|
|
3420
|
+
file: Vn(),
|
|
3421
|
+
heading: Jn(),
|
|
3422
|
+
image: nr(),
|
|
3423
|
+
numberedListItem: hr(),
|
|
3424
|
+
paragraph: Sr(),
|
|
3425
|
+
quote: wr(),
|
|
3426
|
+
table: Ir(),
|
|
3427
|
+
toggleListItem: _r(),
|
|
3428
|
+
video: Vr()
|
|
3429
|
+
}, ni = Et({
|
|
3390
3430
|
type: "textColor",
|
|
3391
3431
|
propSchema: "string"
|
|
3392
3432
|
}, {
|
|
@@ -3407,7 +3447,7 @@ var Zr = {
|
|
|
3407
3447
|
parse: (e) => {
|
|
3408
3448
|
if (e.tagName === "SPAN" && e.style.color) return e.style.color;
|
|
3409
3449
|
}
|
|
3410
|
-
}),
|
|
3450
|
+
}), ri = Et({
|
|
3411
3451
|
type: "backgroundColor",
|
|
3412
3452
|
propSchema: "string"
|
|
3413
3453
|
}, {
|
|
@@ -3428,12 +3468,12 @@ var Zr = {
|
|
|
3428
3468
|
parse: (e) => {
|
|
3429
3469
|
if (e.tagName === "SPAN" && e.style.backgroundColor) return e.style.backgroundColor;
|
|
3430
3470
|
}
|
|
3431
|
-
}),
|
|
3432
|
-
bold:
|
|
3433
|
-
italic:
|
|
3434
|
-
underline:
|
|
3435
|
-
strike:
|
|
3436
|
-
code:
|
|
3471
|
+
}), ii = {
|
|
3472
|
+
bold: L(Te, "boolean"),
|
|
3473
|
+
italic: L(De, "boolean"),
|
|
3474
|
+
underline: L(ke, "boolean"),
|
|
3475
|
+
strike: L(Oe, "boolean"),
|
|
3476
|
+
code: L(Ee.extend({ addInputRules() {
|
|
3437
3477
|
return [_({
|
|
3438
3478
|
find: /(^|[^`])`([^`]+)`(?!`)$/,
|
|
3439
3479
|
type: this.type
|
|
@@ -3445,9 +3485,9 @@ var Zr = {
|
|
|
3445
3485
|
}
|
|
3446
3486
|
})];
|
|
3447
3487
|
} }), "boolean"),
|
|
3448
|
-
textColor:
|
|
3449
|
-
backgroundColor:
|
|
3450
|
-
},
|
|
3488
|
+
textColor: ni,
|
|
3489
|
+
backgroundColor: ri
|
|
3490
|
+
}, ai = wt(ii), oi = {
|
|
3451
3491
|
text: {
|
|
3452
3492
|
config: "text",
|
|
3453
3493
|
implementation: {}
|
|
@@ -3456,16 +3496,16 @@ var Zr = {
|
|
|
3456
3496
|
config: "link",
|
|
3457
3497
|
implementation: {}
|
|
3458
3498
|
}
|
|
3459
|
-
},
|
|
3499
|
+
}, si = xt(oi), ci = class e extends It {
|
|
3460
3500
|
static create(t) {
|
|
3461
3501
|
return new e({
|
|
3462
|
-
blockSpecs: t?.blockSpecs ??
|
|
3463
|
-
inlineContentSpecs: t?.inlineContentSpecs ??
|
|
3464
|
-
styleSpecs: t?.styleSpecs ??
|
|
3502
|
+
blockSpecs: t?.blockSpecs ?? ti,
|
|
3503
|
+
inlineContentSpecs: t?.inlineContentSpecs ?? oi,
|
|
3504
|
+
styleSpecs: t?.styleSpecs ?? ii
|
|
3465
3505
|
});
|
|
3466
3506
|
}
|
|
3467
3507
|
};
|
|
3468
3508
|
//#endregion
|
|
3469
|
-
export {
|
|
3509
|
+
export { Jn as $, Pe as $n, St as $t, Cr as A, nt as An, en as At, hr as B, Ue as Bn, Bt, Br as C, st as Cn, K as Ct, Er as D, et as Dn, ln as Dt, Dr as E, $e as En, un as Et, yr as F, D as Fn, Gt as Ft, rr as G, He as Gn, It as Gt, lr as H, T as Hn, Lt as Ht, br as I, We as In, Jt as It, nr as J, x as Jn, Tt as Jt, Zn as K, Be as Kn, Pt as Kt, gr as L, Ge as Ln, qt as Lt, xr as M, Ke as Mn, H as Mt, Sr as N, qe as Nn, V as Nt, Tr as O, k as On, nn as Ot, vr as P, Je as Pn, Qt as Pt, qn as Q, Ne as Qn, wt as Qt, _r as R, O as Rn, Kt as Rt, Vr as S, at as Sn, mn as St, kr as T, Qe as Tn, W as Tt, sr as U, S as Un, Vt as Ut, ur as V, w as Vn, zt as Vt, cr as W, C as Wn, Ht as Wt, er as X, b as Xn, Ct as Xt, $n as Y, ze as Yn, I as Yt, tr as Z, Fe as Zn, L as Zt, Gr as _, lt as _n, J as _t, ai as a, gt as an, In as at, Rr as b, ot as bn, pn as bt, ei as c, F as cn, Pn as ct, $ as d, ft as dn, En as dt, _t as en, y as er, Wn as et, Yr as f, dt as fn, Dn as ft, X as g, ct as gn, Cn as gt, Ur as h, M as hn, kn as ht, oi as i, xt as in, Bn as it, wr as j, Xe as jn, tn as jt, Y as k, A as kn, U as kt, Qr as l, ht as ln, Fn as lt, Z as m, N as mn, Tn as mt, ti as n, bt as nn, je as nr, zn as nt, ii as o, mt as on, Ln as ot, Kr as p, ut as pn, On as pt, Qn as q, Ve as qn, Et as qt, si as r, yt as rn, Ae as rr, Vn as rt, $r as s, P as sn, Nn as st, ci as t, vt as tn, Me as tr, Un as tt, Zr as u, pt as un, wn as ut, Wr as v, it as vn, q as vt, Ir as w, tt as wn, fn as wt, zr as x, j as xn, hn as xt, Hr as y, rt as yn, G as yt, mr as z, E as zn, Wt as zt };
|
|
3470
3510
|
|
|
3471
|
-
//# sourceMappingURL=blocks-
|
|
3511
|
+
//# sourceMappingURL=blocks-BEJW9OM_.js.map
|