@blocknote/core 0.54.0 → 0.54.1
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-CzkqclGj.cjs → blocks-CTB_5Vyj.cjs} +4 -4
- package/dist/blocks-CTB_5Vyj.cjs.map +1 -0
- package/dist/{blocks-CzQLehlc.js → blocks-Dol85hpH.js} +337 -330
- package/dist/blocks-Dol85hpH.js.map +1 -0
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +2 -2
- package/dist/extensions-B7Rsp_Ft.cjs +58 -0
- package/dist/extensions-B7Rsp_Ft.cjs.map +1 -0
- package/dist/{extensions-DGuhtOgB.js → extensions-D6JcJCwd.js} +389 -346
- package/dist/extensions-D6JcJCwd.js.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +3 -3
- package/dist/{src-BkfZVfaO.js → src-Buuo5l7X.js} +521 -516
- package/dist/{src-BkfZVfaO.js.map → src-Buuo5l7X.js.map} +1 -1
- package/dist/{src-DM3syMdf.cjs → src-C54Ok9E0.cjs} +10 -10
- package/dist/{src-DM3syMdf.cjs.map → src-C54Ok9E0.cjs.map} +1 -1
- package/dist/webpack-stats.json +1 -1
- package/dist/y.cjs +1 -1
- package/dist/y.cjs.map +1 -1
- package/dist/y.js +205 -205
- package/dist/y.js.map +1 -1
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.js +21 -21
- package/package.json +1 -1
- package/src/api/getBlocksChangedByTransaction.test.ts +211 -0
- package/src/api/getBlocksChangedByTransaction.ts +48 -12
- package/src/api/getChangedRange.ts +54 -0
- package/src/blocks/index.ts +0 -1
- package/src/editor/performance.test.ts +45 -0
- package/src/exporter/Exporter.test.ts +148 -10
- package/src/exporter/Exporter.ts +20 -2
- package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +21 -0
- package/src/extensions/PreviousBlockType/PreviousBlockType.ts +5 -3
- package/src/extensions/TableHandles/TableHandles.browser.test.ts +305 -0
- package/src/extensions/TableHandles/TableHandles.ts +82 -41
- package/src/fonts/inter.css +9 -9
- package/src/schema/blocks/createSpec.ts +4 -5
- package/src/schema/inlineContent/createSpec.ts +4 -5
- package/src/schema/nodeViewMutations.test.ts +81 -56
- package/src/schema/nodeViewMutations.ts +30 -27
- package/src/schema/schema.test.ts +110 -0
- package/src/schema/schema.ts +13 -4
- package/src/y/extensions/AttributionExtension.test.ts +8 -9
- package/src/y/versioning/__test__/yhub.test.ts +92 -59
- package/src/y/versioning/yhub.ts +35 -29
- package/types/src/api/getChangedRange.d.ts +14 -0
- package/types/src/blocks/index.d.ts +0 -1
- package/types/src/exporter/Exporter.d.ts +9 -0
- package/types/src/extensions/TableHandles/TableHandles.browser.test.d.ts +1 -0
- package/types/src/extensions/TableHandles/TableHandles.d.ts +3 -0
- package/types/src/schema/nodeViewMutations.d.ts +2 -2
- package/types/src/schema/schema.test.d.ts +1 -0
- package/types/src/y/versioning/yhub.d.ts +3 -2
- package/dist/blocks-CzQLehlc.js.map +0 -1
- package/dist/blocks-CzkqclGj.cjs.map +0 -1
- package/dist/extensions-CSB9ZvuL.cjs +0 -58
- package/dist/extensions-CSB9ZvuL.cjs.map +0 -1
- package/dist/extensions-DGuhtOgB.js.map +0 -1
- package/src/blocks/File/helpers/uploadToTmpFilesDotOrg_DEV_ONLY.ts +0 -20
- package/types/src/blocks/File/helpers/uploadToTmpFilesDotOrg_DEV_ONLY.d.ts +0 -6
|
@@ -108,28 +108,28 @@ function je(e) {
|
|
|
108
108
|
if (!e.nodeAfter) throw Error(`Attempted to get blockContainer node at position ${e.pos} but a node at this position does not exist`);
|
|
109
109
|
return y(e.nodeAfter, e.pos);
|
|
110
110
|
}
|
|
111
|
-
function
|
|
112
|
-
return
|
|
111
|
+
function x(e) {
|
|
112
|
+
return Me(e, e.selection.anchor);
|
|
113
113
|
}
|
|
114
|
-
function
|
|
114
|
+
function Me(e, t) {
|
|
115
115
|
return b(Ae(e.doc, t));
|
|
116
116
|
}
|
|
117
117
|
//#endregion
|
|
118
118
|
//#region src/extensions/tiptap-extensions/UniqueID/UniqueID.ts
|
|
119
|
-
function
|
|
119
|
+
function Ne(e, t = JSON.stringify) {
|
|
120
120
|
let n = {};
|
|
121
121
|
return e.filter((e) => {
|
|
122
122
|
let r = t(e);
|
|
123
123
|
return Object.prototype.hasOwnProperty.call(n, r) ? !1 : n[r] = !0;
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
|
-
function
|
|
127
|
-
return
|
|
126
|
+
function Pe(e) {
|
|
127
|
+
return Ne(e.filter((t, n) => e.indexOf(t) !== n));
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function Fe(e) {
|
|
130
130
|
return e.marks.some((e) => e.type.name === "y-attributed-delete");
|
|
131
131
|
}
|
|
132
|
-
var
|
|
132
|
+
var Ie = s.create({
|
|
133
133
|
name: "uniqueID",
|
|
134
134
|
priority: 1e4,
|
|
135
135
|
addOptions() {
|
|
@@ -170,9 +170,9 @@ var Le = s.create({
|
|
|
170
170
|
if (!(e.some((e) => e.docChanged) && !t.doc.eq(n.doc))) return;
|
|
171
171
|
let { tr: r } = n, { types: i, generateID: a } = this.options, o = f(t.doc, e), { mapping: s } = o;
|
|
172
172
|
if (h(o).forEach(({ newRange: e }) => {
|
|
173
|
-
let o = p(n.doc, e, (e) => i.includes(e.type.name)), c =
|
|
173
|
+
let o = p(n.doc, e, (e) => i.includes(e.type.name)), c = Pe(o.map(({ node: e }) => e.attrs.id).filter((e) => e !== null));
|
|
174
174
|
o.forEach(({ node: e, pos: i }) => {
|
|
175
|
-
if (
|
|
175
|
+
if (Fe(e)) return;
|
|
176
176
|
let o = r.doc.nodeAt(i)?.attrs.id;
|
|
177
177
|
if (o === null) {
|
|
178
178
|
let o = t.doc.type.createAndFill().content;
|
|
@@ -242,19 +242,19 @@ var Le = s.create({
|
|
|
242
242
|
});
|
|
243
243
|
//#endregion
|
|
244
244
|
//#region src/schema/inlineContent/types.ts
|
|
245
|
-
function
|
|
245
|
+
function Le(e) {
|
|
246
246
|
return e.type === "link";
|
|
247
247
|
}
|
|
248
|
-
function
|
|
248
|
+
function Re(e) {
|
|
249
249
|
return typeof e != "string" && e.type === "link";
|
|
250
250
|
}
|
|
251
|
-
function
|
|
251
|
+
function S(e) {
|
|
252
252
|
return typeof e != "string" && e.type === "text";
|
|
253
253
|
}
|
|
254
254
|
//#endregion
|
|
255
255
|
//#region src/util/table.ts
|
|
256
|
-
function
|
|
257
|
-
return
|
|
256
|
+
function C(e) {
|
|
257
|
+
return T(e) ? { ...e } : w(e) ? {
|
|
258
258
|
type: "tableCell",
|
|
259
259
|
content: [].concat(e.content),
|
|
260
260
|
props: {
|
|
@@ -276,55 +276,55 @@ function Be(e) {
|
|
|
276
276
|
}
|
|
277
277
|
};
|
|
278
278
|
}
|
|
279
|
-
function
|
|
279
|
+
function w(e) {
|
|
280
280
|
return e != null && typeof e != "string" && !Array.isArray(e) && e.type === "tableCell";
|
|
281
281
|
}
|
|
282
|
-
function
|
|
283
|
-
return
|
|
282
|
+
function T(e) {
|
|
283
|
+
return w(e) && e.props !== void 0 && e.content !== void 0;
|
|
284
284
|
}
|
|
285
|
-
function
|
|
286
|
-
return
|
|
285
|
+
function E(e) {
|
|
286
|
+
return T(e) ? e.props.colspan ?? 1 : 1;
|
|
287
287
|
}
|
|
288
|
-
function
|
|
289
|
-
return
|
|
288
|
+
function D(e) {
|
|
289
|
+
return T(e) ? e.props.rowspan ?? 1 : 1;
|
|
290
290
|
}
|
|
291
291
|
//#endregion
|
|
292
292
|
//#region src/util/typescript.ts
|
|
293
|
-
var
|
|
293
|
+
var O = class extends Error {
|
|
294
294
|
constructor(e) {
|
|
295
295
|
super(`Unreachable case: ${e}`);
|
|
296
296
|
}
|
|
297
297
|
};
|
|
298
|
-
function
|
|
298
|
+
function ze(e, t = !0) {
|
|
299
299
|
let { "data-test": n, ...r } = e;
|
|
300
300
|
if (Object.keys(r).length > 0 && t) throw Error("Object must be empty " + JSON.stringify(e));
|
|
301
301
|
}
|
|
302
302
|
//#endregion
|
|
303
303
|
//#region src/util/browser.ts
|
|
304
|
-
var
|
|
305
|
-
function
|
|
306
|
-
return
|
|
304
|
+
var Be = () => typeof navigator < "u" && (/Mac/.test(navigator.platform) || /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent));
|
|
305
|
+
function k(e, t = "Ctrl") {
|
|
306
|
+
return Be() ? e.replace("Mod", "⌘") : e.replace("Mod", t);
|
|
307
307
|
}
|
|
308
|
-
function
|
|
308
|
+
function A(...e) {
|
|
309
309
|
return [...new Set(e.filter((e) => e).join(" ").split(" "))].join(" ");
|
|
310
310
|
}
|
|
311
|
-
var
|
|
311
|
+
var Ve = () => /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
312
312
|
//#endregion
|
|
313
313
|
//#region src/blocks/defaultBlockHelpers.ts
|
|
314
|
-
function
|
|
314
|
+
function He(e, t, n, r) {
|
|
315
315
|
let i = document.createElement("div");
|
|
316
|
-
i.className =
|
|
316
|
+
i.className = A("bn-block-content", n.class), i.setAttribute("data-content-type", e);
|
|
317
317
|
for (let [e, t] of Object.entries(n)) e !== "class" && i.setAttribute(e, t);
|
|
318
318
|
let a = document.createElement(t);
|
|
319
|
-
a.className =
|
|
319
|
+
a.className = A("bn-inline-content", r.class);
|
|
320
320
|
for (let [e, t] of Object.entries(r)) e !== "class" && a.setAttribute(e, t);
|
|
321
321
|
return i.appendChild(a), {
|
|
322
322
|
dom: i,
|
|
323
323
|
contentDOM: a
|
|
324
324
|
};
|
|
325
325
|
}
|
|
326
|
-
var
|
|
327
|
-
let n =
|
|
326
|
+
var Ue = (e, t) => {
|
|
327
|
+
let n = U(e, t.pmSchema);
|
|
328
328
|
n.type.name === "blockContainer" && (n = n.firstChild);
|
|
329
329
|
let r = t.pmSchema.nodes[n.type.name].spec.toDOM;
|
|
330
330
|
if (r === void 0) throw Error("This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.");
|
|
@@ -332,7 +332,7 @@ var Ge = (e, t) => {
|
|
|
332
332
|
if (typeof i != "object" || !("dom" in i)) throw Error("Cannot use this block's default HTML serialization as its corresponding TipTap node's `renderHTML` function does not return an object with the `dom` property.");
|
|
333
333
|
return i;
|
|
334
334
|
};
|
|
335
|
-
function
|
|
335
|
+
function We(e, t = "<br>") {
|
|
336
336
|
let n = e.querySelectorAll("p");
|
|
337
337
|
if (n.length > 1) {
|
|
338
338
|
let e = n[0];
|
|
@@ -344,44 +344,44 @@ function Ke(e, t = "<br>") {
|
|
|
344
344
|
}
|
|
345
345
|
//#endregion
|
|
346
346
|
//#region src/schema/nodeViewMutations.ts
|
|
347
|
-
function
|
|
348
|
-
return e.type
|
|
347
|
+
function Ge(e) {
|
|
348
|
+
return e.type !== "attributes" || !e.attributeName ? !1 : e.attributeName.startsWith("data-darkreader") ? !0 : e.attributeName === "style" ? (e.target.getAttribute("style") ?? "").includes("--darkreader") || (e.oldValue ?? "").includes("--darkreader") : !1;
|
|
349
349
|
}
|
|
350
|
-
function
|
|
350
|
+
function Ke(e) {
|
|
351
351
|
let t = e.ignoreMutation?.bind(e), n = e.contentDOM;
|
|
352
|
-
e.ignoreMutation = (e) =>
|
|
352
|
+
e.ignoreMutation = (e) => Ge(e) ? !0 : t ? t(e) : !n && e.type !== "selection";
|
|
353
353
|
}
|
|
354
354
|
//#endregion
|
|
355
355
|
//#region src/api/pmUtil.ts
|
|
356
|
-
function
|
|
356
|
+
function j(e) {
|
|
357
357
|
return "doc" in e ? e.doc.type.schema : e.type.schema;
|
|
358
358
|
}
|
|
359
|
-
function
|
|
359
|
+
function qe(e) {
|
|
360
360
|
return e.cached.blockNoteEditor;
|
|
361
361
|
}
|
|
362
|
-
function
|
|
363
|
-
return
|
|
362
|
+
function Je(e) {
|
|
363
|
+
return qe(e).schema;
|
|
364
364
|
}
|
|
365
|
-
function
|
|
366
|
-
return
|
|
365
|
+
function Ye(e) {
|
|
366
|
+
return Je(e).blockSchema;
|
|
367
367
|
}
|
|
368
|
-
function
|
|
369
|
-
return
|
|
368
|
+
function Xe(e) {
|
|
369
|
+
return Je(e).inlineContentSchema;
|
|
370
370
|
}
|
|
371
|
-
function
|
|
372
|
-
return
|
|
371
|
+
function M(e) {
|
|
372
|
+
return Je(e).styleSchema;
|
|
373
373
|
}
|
|
374
|
-
function
|
|
375
|
-
return
|
|
374
|
+
function Ze(e) {
|
|
375
|
+
return qe(e).blockCache;
|
|
376
376
|
}
|
|
377
|
-
function
|
|
378
|
-
if (
|
|
379
|
-
let n =
|
|
377
|
+
function Qe(e, t) {
|
|
378
|
+
if (Ye(e)[t.name]?.content === "plain") return !0;
|
|
379
|
+
let n = Xe(e)[t.name];
|
|
380
380
|
return typeof n == "object" && n.content === "plain";
|
|
381
381
|
}
|
|
382
382
|
//#endregion
|
|
383
383
|
//#region src/api/nodeConversions/nodeToBlock.ts
|
|
384
|
-
function
|
|
384
|
+
function $e(e, t, n) {
|
|
385
385
|
let r = {
|
|
386
386
|
type: "tableContent",
|
|
387
387
|
columnWidths: [],
|
|
@@ -396,10 +396,10 @@ function tt(e, t, n) {
|
|
|
396
396
|
t ??= Array(e.attrs.colspan ?? 1).fill(void 0), r.columnWidths.push(...t);
|
|
397
397
|
}), s.cells = e.content.content.map((e, r) => (i[o] || (i[o] = []), i[o][r] = e.type.name === "tableHeader", {
|
|
398
398
|
type: "tableCell",
|
|
399
|
-
content: e.content.content.map((e) =>
|
|
399
|
+
content: e.content.content.map((e) => et(e, t, n)).reduce((e, t) => {
|
|
400
400
|
if (!e.length) return t;
|
|
401
401
|
let n = e[e.length - 1], r = t[0];
|
|
402
|
-
return r &&
|
|
402
|
+
return r && S(n) && S(r) && JSON.stringify(n.styles) === JSON.stringify(r.styles) ? (n.text += "\n" + r.text, e.push(...t.slice(1)), e) : (e.push(...t), e);
|
|
403
403
|
}, []),
|
|
404
404
|
props: {
|
|
405
405
|
colspan: e.attrs.colspan,
|
|
@@ -414,13 +414,13 @@ function tt(e, t, n) {
|
|
|
414
414
|
for (let e = 0; e < i[0]?.length; e++) i?.every((t) => t[e]) && (r.headerCols = (r.headerCols ?? 0) + 1);
|
|
415
415
|
return r;
|
|
416
416
|
}
|
|
417
|
-
function
|
|
417
|
+
function et(e, t, n) {
|
|
418
418
|
let r = [], i;
|
|
419
419
|
return e.content.forEach((e) => {
|
|
420
420
|
if (e.type.name === "hardBreak") {
|
|
421
421
|
if (i) {
|
|
422
|
-
if (
|
|
423
|
-
else if (
|
|
422
|
+
if (S(i)) i.text += "\n";
|
|
423
|
+
else if (Le(i)) i.content[i.content.length - 1].text += "\n";
|
|
424
424
|
else throw Error("unexpected");
|
|
425
425
|
} else i = {
|
|
426
426
|
type: "text",
|
|
@@ -434,7 +434,7 @@ function nt(e, t, n) {
|
|
|
434
434
|
console.warn("unrecognized inline content type", e.type.name);
|
|
435
435
|
return;
|
|
436
436
|
}
|
|
437
|
-
i &&= (r.push(i), void 0), r.push(
|
|
437
|
+
i &&= (r.push(i), void 0), r.push(tt(e, t, n));
|
|
438
438
|
return;
|
|
439
439
|
}
|
|
440
440
|
let a = {}, o;
|
|
@@ -447,9 +447,9 @@ function nt(e, t, n) {
|
|
|
447
447
|
}
|
|
448
448
|
if (e.propSchema === "boolean") a[e.type] = !0;
|
|
449
449
|
else if (e.propSchema === "string") a[e.type] = t.attrs.stringValue;
|
|
450
|
-
else throw new
|
|
450
|
+
else throw new O(e.propSchema);
|
|
451
451
|
}
|
|
452
|
-
i ?
|
|
452
|
+
i ? S(i) ? o ? (r.push(i), i = {
|
|
453
453
|
type: "link",
|
|
454
454
|
href: o.attrs.href,
|
|
455
455
|
content: [{
|
|
@@ -461,7 +461,7 @@ function nt(e, t, n) {
|
|
|
461
461
|
type: "text",
|
|
462
462
|
text: e.textContent,
|
|
463
463
|
styles: a
|
|
464
|
-
}) :
|
|
464
|
+
}) : Le(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({
|
|
465
465
|
type: "text",
|
|
466
466
|
text: e.textContent,
|
|
467
467
|
styles: a
|
|
@@ -492,7 +492,7 @@ function nt(e, t, n) {
|
|
|
492
492
|
};
|
|
493
493
|
}), i && r.push(i), r;
|
|
494
494
|
}
|
|
495
|
-
function
|
|
495
|
+
function tt(e, t, n) {
|
|
496
496
|
if (e.type.name === "text" || e.type.name === "link") throw Error("unexpected");
|
|
497
497
|
let r = {}, i = t[e.type.name];
|
|
498
498
|
for (let [t, n] of Object.entries(e.attrs)) {
|
|
@@ -500,14 +500,14 @@ function rt(e, t, n) {
|
|
|
500
500
|
t in i.propSchema && (r[t] = n);
|
|
501
501
|
}
|
|
502
502
|
let a;
|
|
503
|
-
return a = i.content === "styled" ?
|
|
503
|
+
return a = i.content === "styled" ? et(e, t, n) : i.content === "plain" ? e.textContent : void 0, {
|
|
504
504
|
type: e.type.name,
|
|
505
505
|
props: r,
|
|
506
506
|
content: a
|
|
507
507
|
};
|
|
508
508
|
}
|
|
509
|
-
function
|
|
510
|
-
let n = e.type.schema, r =
|
|
509
|
+
function N(e, t) {
|
|
510
|
+
let n = e.type.schema, r = Ye(n), i = Xe(n), a = M(n), o = Ze(n);
|
|
511
511
|
if (!e.type.isInGroup("bnBlock")) throw Error("Node should be a bnBlock, but is instead: " + e.type.name);
|
|
512
512
|
let s = o?.get(e);
|
|
513
513
|
if (s) return s;
|
|
@@ -515,7 +515,7 @@ function j(e, t) {
|
|
|
515
515
|
try {
|
|
516
516
|
l = ke(c.bnBlock.node, t);
|
|
517
517
|
} catch {
|
|
518
|
-
l =
|
|
518
|
+
l = Ie.options.generateID();
|
|
519
519
|
}
|
|
520
520
|
let u = r[c.blockNoteType];
|
|
521
521
|
if (!u) throw Error("Block is of an unrecognized type: " + c.blockNoteType);
|
|
@@ -529,15 +529,15 @@ function j(e, t) {
|
|
|
529
529
|
}
|
|
530
530
|
let f = r[c.blockNoteType], p = [];
|
|
531
531
|
c.childContainer?.node.forEach((e) => {
|
|
532
|
-
p.push(
|
|
532
|
+
p.push(N(e, t));
|
|
533
533
|
});
|
|
534
534
|
let m;
|
|
535
535
|
if (f.content === "inline") {
|
|
536
536
|
if (!c.isBlockContainer) throw Error("impossible");
|
|
537
|
-
m =
|
|
537
|
+
m = et(c.blockContent.node, i, a);
|
|
538
538
|
} else if (f.content === "table") {
|
|
539
539
|
if (!c.isBlockContainer) throw Error("impossible");
|
|
540
|
-
m =
|
|
540
|
+
m = $e(c.blockContent.node, i, a);
|
|
541
541
|
} else if (f.content === "plain") {
|
|
542
542
|
if (!c.isBlockContainer) throw Error("impossible");
|
|
543
543
|
let e = c.blockContent.node.textContent;
|
|
@@ -547,7 +547,7 @@ function j(e, t) {
|
|
|
547
547
|
styles: {}
|
|
548
548
|
}] : [];
|
|
549
549
|
} else if (f.content === "none") m = void 0;
|
|
550
|
-
else throw new
|
|
550
|
+
else throw new O(f.content);
|
|
551
551
|
let h = {
|
|
552
552
|
id: l,
|
|
553
553
|
type: f.type,
|
|
@@ -557,11 +557,11 @@ function j(e, t) {
|
|
|
557
557
|
};
|
|
558
558
|
return o?.set(e, h), h;
|
|
559
559
|
}
|
|
560
|
-
function
|
|
560
|
+
function nt(e) {
|
|
561
561
|
let t = [];
|
|
562
|
-
return e.firstChild && e.firstChild.descendants((n) => (t.push(
|
|
562
|
+
return e.firstChild && e.firstChild.descendants((n) => (t.push(N(n, e)), !1)), t;
|
|
563
563
|
}
|
|
564
|
-
function
|
|
564
|
+
function rt(e) {
|
|
565
565
|
function t(n, r, i) {
|
|
566
566
|
if (n.type.name !== "blockGroup") throw Error("unexpected");
|
|
567
567
|
let a = [], o, s;
|
|
@@ -576,7 +576,7 @@ function at(e) {
|
|
|
576
576
|
o = e.blockCutAtStart, f && (s = e.blockCutAtEnd), a.push(...e.blocks);
|
|
577
577
|
return;
|
|
578
578
|
}
|
|
579
|
-
let p =
|
|
579
|
+
let p = N(c, e.content.firstChild), m = c.childCount > 1 ? c.child(1) : void 0, h = [];
|
|
580
580
|
if (m) {
|
|
581
581
|
let e = t(m, 0, f ? Math.max(0, i - 1) : 0);
|
|
582
582
|
h = e.blocks, f && (s = e.blockCutAtEnd);
|
|
@@ -601,14 +601,14 @@ function at(e) {
|
|
|
601
601
|
}
|
|
602
602
|
//#endregion
|
|
603
603
|
//#region src/util/string.ts
|
|
604
|
-
function
|
|
604
|
+
function P(e) {
|
|
605
605
|
return "data-" + e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
606
606
|
}
|
|
607
|
-
function
|
|
607
|
+
function it(e) {
|
|
608
608
|
let t = e.split("/");
|
|
609
609
|
return !t.length || t[t.length - 1] === "" ? e : t[t.length - 1];
|
|
610
610
|
}
|
|
611
|
-
function
|
|
611
|
+
function at(e) {
|
|
612
612
|
let t = [
|
|
613
613
|
"mp4",
|
|
614
614
|
"webm",
|
|
@@ -629,14 +629,14 @@ function st(e) {
|
|
|
629
629
|
}
|
|
630
630
|
//#endregion
|
|
631
631
|
//#region src/schema/blocks/internal.ts
|
|
632
|
-
function
|
|
632
|
+
function ot(e) {
|
|
633
633
|
let t = {};
|
|
634
634
|
return Object.entries(e).forEach(([e, n]) => {
|
|
635
635
|
t[e] = {
|
|
636
636
|
default: n.default,
|
|
637
637
|
keepOnSplit: !0,
|
|
638
638
|
parseHTML: (t) => {
|
|
639
|
-
let r = t.getAttribute(
|
|
639
|
+
let r = t.getAttribute(P(e));
|
|
640
640
|
if (r === null) return null;
|
|
641
641
|
if (n.default === void 0 && n.type === "boolean" || n.default !== void 0 && typeof n.default == "boolean") return r === "true" || r !== "false" && null;
|
|
642
642
|
if (n.default === void 0 && n.type === "number" || n.default !== void 0 && typeof n.default == "number") {
|
|
@@ -645,37 +645,37 @@ function ct(e) {
|
|
|
645
645
|
}
|
|
646
646
|
return r;
|
|
647
647
|
},
|
|
648
|
-
renderHTML: (t) => t[e] === n.default ? {} : { [
|
|
648
|
+
renderHTML: (t) => t[e] === n.default ? {} : { [P(e)]: t[e] }
|
|
649
649
|
};
|
|
650
650
|
}), t;
|
|
651
651
|
}
|
|
652
|
-
function
|
|
652
|
+
function st(e, t) {
|
|
653
653
|
let n = e();
|
|
654
654
|
if (n === void 0) throw Error("Cannot find node position");
|
|
655
655
|
let r = t.resolve(n).node();
|
|
656
656
|
if (!r) throw Error("Cannot find block container");
|
|
657
|
-
return
|
|
657
|
+
return N(r, t);
|
|
658
658
|
}
|
|
659
|
-
function
|
|
659
|
+
function ct(e, t, n) {
|
|
660
660
|
try {
|
|
661
|
-
return
|
|
661
|
+
return st(e, n);
|
|
662
662
|
} catch (e) {
|
|
663
663
|
let r = n.type.schema.nodes.blockContainer?.createAndFill(null, t);
|
|
664
|
-
if (r) return
|
|
664
|
+
if (r) return N(r, n);
|
|
665
665
|
throw e;
|
|
666
666
|
}
|
|
667
667
|
}
|
|
668
|
-
function
|
|
668
|
+
function lt(e, t, n, r, i = !1, a) {
|
|
669
669
|
let o = document.createElement("div");
|
|
670
670
|
if (a !== void 0) for (let [e, t] of Object.entries(a)) e !== "class" && o.setAttribute(e, t);
|
|
671
|
-
o.className =
|
|
672
|
-
for (let [e, t] of Object.entries(n)) t !== r[e]?.default && o.setAttribute(
|
|
673
|
-
return i && o.setAttribute("data-file-block", ""), o.appendChild(e.dom), e.contentDOM && (e.contentDOM.className =
|
|
671
|
+
o.className = A("bn-block-content", a?.class || ""), o.setAttribute("data-content-type", t);
|
|
672
|
+
for (let [e, t] of Object.entries(n)) t !== r[e]?.default && o.setAttribute(P(e), t);
|
|
673
|
+
return i && o.setAttribute("data-file-block", ""), o.appendChild(e.dom), e.contentDOM && (e.contentDOM.className = A("bn-inline-content", e.contentDOM.className)), {
|
|
674
674
|
...e,
|
|
675
675
|
dom: o
|
|
676
676
|
};
|
|
677
677
|
}
|
|
678
|
-
function
|
|
678
|
+
function ut(e, t, n) {
|
|
679
679
|
return {
|
|
680
680
|
config: {
|
|
681
681
|
type: e.type,
|
|
@@ -684,20 +684,20 @@ function dt(e, t, n) {
|
|
|
684
684
|
},
|
|
685
685
|
implementation: {
|
|
686
686
|
node: e.node,
|
|
687
|
-
render:
|
|
688
|
-
toExternalHTML:
|
|
687
|
+
render: Ue,
|
|
688
|
+
toExternalHTML: Ue
|
|
689
689
|
},
|
|
690
690
|
extensions: n
|
|
691
691
|
};
|
|
692
692
|
}
|
|
693
693
|
//#endregion
|
|
694
694
|
//#region src/schema/blocks/createSpec.ts
|
|
695
|
-
function
|
|
695
|
+
function dt(e, t) {
|
|
696
696
|
e.stopEvent = (e) => (e.type === "mousedown" && setTimeout(() => {
|
|
697
697
|
t.view.dom.blur();
|
|
698
698
|
}, 10), !0);
|
|
699
699
|
}
|
|
700
|
-
function
|
|
700
|
+
function ft(e, t) {
|
|
701
701
|
let n = [{
|
|
702
702
|
tag: "[data-content-type=" + e.type + "]",
|
|
703
703
|
contentElement: ".bn-inline-content"
|
|
@@ -720,7 +720,7 @@ function pt(e, t) {
|
|
|
720
720
|
}
|
|
721
721
|
if (e.content === "inline" || e.content === "plain") {
|
|
722
722
|
let i = n.cloneNode(!0);
|
|
723
|
-
|
|
723
|
+
We(i, e.content === "plain" || t.meta?.code ? "\n" : "<br>");
|
|
724
724
|
let a = ie.fromSchema(r).parse(i, {
|
|
725
725
|
topNode: r.nodes.paragraph.create(),
|
|
726
726
|
preserveWhitespace: !0
|
|
@@ -741,7 +741,7 @@ function pt(e, t) {
|
|
|
741
741
|
} : void 0
|
|
742
742
|
}), n;
|
|
743
743
|
}
|
|
744
|
-
function
|
|
744
|
+
function pt(e, n, r, i) {
|
|
745
745
|
let a = n.node || u.create({
|
|
746
746
|
name: e.type,
|
|
747
747
|
content: e.content === "inline" ? "inline*" : e.content === "plain" ? "text*" : e.content === "none" ? "" : e.content,
|
|
@@ -755,27 +755,27 @@ function mt(e, n, r, i) {
|
|
|
755
755
|
defining: n.meta?.defining ?? !0,
|
|
756
756
|
priority: i,
|
|
757
757
|
addAttributes() {
|
|
758
|
-
return
|
|
758
|
+
return ot(e.propSchema);
|
|
759
759
|
},
|
|
760
760
|
parseHTML() {
|
|
761
|
-
return
|
|
761
|
+
return ft(e, n);
|
|
762
762
|
},
|
|
763
763
|
renderHTML({ HTMLAttributes: t }) {
|
|
764
764
|
let r = document.createElement("div");
|
|
765
|
-
return
|
|
765
|
+
return lt({
|
|
766
766
|
dom: r,
|
|
767
767
|
contentDOM: e.content === "inline" || e.content === "plain" ? r : void 0
|
|
768
768
|
}, e.type, {}, e.propSchema, n.meta?.fileBlockAccept !== void 0, t);
|
|
769
769
|
},
|
|
770
770
|
addNodeView() {
|
|
771
771
|
return (t) => {
|
|
772
|
-
let r = this.options.editor, i =
|
|
772
|
+
let r = this.options.editor, i = ct(t.getPos, t.node, t.view.state.doc), a = this.options.domAttributes?.blockContent || {}, o = n.render.call({
|
|
773
773
|
blockContentDOMAttributes: a,
|
|
774
774
|
props: t,
|
|
775
775
|
renderType: "nodeView",
|
|
776
776
|
propSchema: e.propSchema
|
|
777
777
|
}, i, r);
|
|
778
|
-
return n.meta?.selectable === !1 &&
|
|
778
|
+
return n.meta?.selectable === !1 && dt(o, this.editor), Ke(o), o;
|
|
779
779
|
};
|
|
780
780
|
}
|
|
781
781
|
});
|
|
@@ -810,10 +810,10 @@ function mt(e, n, r, i) {
|
|
|
810
810
|
extensions: r
|
|
811
811
|
};
|
|
812
812
|
}
|
|
813
|
-
function
|
|
813
|
+
function F(e) {
|
|
814
814
|
return e;
|
|
815
815
|
}
|
|
816
|
-
function
|
|
816
|
+
function I(e, t, n) {
|
|
817
817
|
return (r = {}) => {
|
|
818
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;
|
|
819
819
|
return {
|
|
@@ -822,10 +822,10 @@ function F(e, t, n) {
|
|
|
822
822
|
...a,
|
|
823
823
|
toExternalHTML(e, t, n) {
|
|
824
824
|
let r = a.toExternalHTML?.call({ blockContentDOMAttributes: this.blockContentDOMAttributes }, e, t, n);
|
|
825
|
-
if (r !== void 0) return
|
|
825
|
+
if (r !== void 0) return lt(r, e.type, e.props, this.propSchema ?? i.propSchema, a.meta?.fileBlockAccept !== void 0);
|
|
826
826
|
},
|
|
827
827
|
render(e, t) {
|
|
828
|
-
return
|
|
828
|
+
return lt(a.render.call({
|
|
829
829
|
blockContentDOMAttributes: this.blockContentDOMAttributes,
|
|
830
830
|
renderType: this.renderType,
|
|
831
831
|
props: this.props
|
|
@@ -838,24 +838,24 @@ function F(e, t, n) {
|
|
|
838
838
|
}
|
|
839
839
|
//#endregion
|
|
840
840
|
//#region src/schema/inlineContent/internal.ts
|
|
841
|
-
function
|
|
842
|
-
return e.dom.setAttribute("data-inline-content-type", t), Object.entries(n).filter(([e, t]) => t !== r[e]?.default).map(([e, t]) => [
|
|
841
|
+
function mt(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]) => [P(e), t]).forEach(([t, n]) => e.dom.setAttribute(t, n)), e.contentDOM && e.contentDOM.setAttribute("data-editable", ""), e;
|
|
843
843
|
}
|
|
844
|
-
function
|
|
844
|
+
function ht(e) {
|
|
845
845
|
return { Backspace: ({ editor: t }) => {
|
|
846
846
|
let n = t.state.selection.$from;
|
|
847
847
|
return t.state.selection.empty && n.node().type.name === e.type && n.parentOffset === 0;
|
|
848
848
|
} };
|
|
849
849
|
}
|
|
850
|
-
function
|
|
850
|
+
function gt(e, t, n) {
|
|
851
851
|
return {
|
|
852
852
|
config: e,
|
|
853
853
|
implementation: t,
|
|
854
854
|
extensions: n
|
|
855
855
|
};
|
|
856
856
|
}
|
|
857
|
-
function
|
|
858
|
-
return
|
|
857
|
+
function _t(e, t, n) {
|
|
858
|
+
return gt({
|
|
859
859
|
type: e.name,
|
|
860
860
|
propSchema: t,
|
|
861
861
|
content: e.config.content === "inline*" ? "styled" : e.config.content === "text*" ? "plain" : "none"
|
|
@@ -864,12 +864,12 @@ function vt(e, t, n) {
|
|
|
864
864
|
node: e
|
|
865
865
|
});
|
|
866
866
|
}
|
|
867
|
-
function
|
|
867
|
+
function vt(e) {
|
|
868
868
|
return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, t.config]));
|
|
869
869
|
}
|
|
870
870
|
//#endregion
|
|
871
871
|
//#region src/schema/styles/internal.ts
|
|
872
|
-
function
|
|
872
|
+
function yt(e) {
|
|
873
873
|
return e === "boolean" ? {} : { stringValue: {
|
|
874
874
|
default: void 0,
|
|
875
875
|
keepOnSplit: !0,
|
|
@@ -877,17 +877,17 @@ function bt(e) {
|
|
|
877
877
|
renderHTML: (e) => e.stringValue === void 0 ? {} : { "data-value": e.stringValue }
|
|
878
878
|
} };
|
|
879
879
|
}
|
|
880
|
-
function
|
|
880
|
+
function L(e, t, n, r) {
|
|
881
881
|
return e.dom.setAttribute("data-style-type", t), r === "string" && e.dom.setAttribute("data-value", n), e.contentDOM && e.contentDOM.setAttribute("data-editable", ""), e;
|
|
882
882
|
}
|
|
883
|
-
function
|
|
883
|
+
function bt(e, t) {
|
|
884
884
|
return {
|
|
885
885
|
config: e,
|
|
886
886
|
implementation: t
|
|
887
887
|
};
|
|
888
888
|
}
|
|
889
|
-
function
|
|
890
|
-
return
|
|
889
|
+
function R(e, t) {
|
|
890
|
+
return bt({
|
|
891
891
|
type: e.name,
|
|
892
892
|
propSchema: t
|
|
893
893
|
}, {
|
|
@@ -908,12 +908,12 @@ function L(e, t) {
|
|
|
908
908
|
}
|
|
909
909
|
});
|
|
910
910
|
}
|
|
911
|
-
function
|
|
911
|
+
function xt(e) {
|
|
912
912
|
return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, t.config]));
|
|
913
913
|
}
|
|
914
914
|
//#endregion
|
|
915
915
|
//#region src/schema/styles/createSpec.ts
|
|
916
|
-
function
|
|
916
|
+
function St(e, t) {
|
|
917
917
|
let n = [{
|
|
918
918
|
tag: `[data-style-type="${e.type}"]`,
|
|
919
919
|
contentElement: (e) => {
|
|
@@ -931,33 +931,33 @@ function Ct(e, t) {
|
|
|
931
931
|
}
|
|
932
932
|
}), n;
|
|
933
933
|
}
|
|
934
|
-
function
|
|
934
|
+
function Ct(e, t) {
|
|
935
935
|
let n = l.create({
|
|
936
936
|
name: e.type,
|
|
937
937
|
addAttributes() {
|
|
938
|
-
return
|
|
938
|
+
return yt(e.propSchema);
|
|
939
939
|
},
|
|
940
940
|
parseHTML() {
|
|
941
|
-
return
|
|
941
|
+
return St(e, t.parse);
|
|
942
942
|
},
|
|
943
943
|
renderHTML({ mark: n }) {
|
|
944
|
-
return
|
|
944
|
+
return L((t.toExternalHTML || t.render)(n.attrs.stringValue), e.type, n.attrs.stringValue, e.propSchema);
|
|
945
945
|
},
|
|
946
946
|
addMarkView() {
|
|
947
|
-
return ({ mark: n }) =>
|
|
947
|
+
return ({ mark: n }) => L(t.render(n.attrs.stringValue), e.type, n.attrs.stringValue, e.propSchema);
|
|
948
948
|
}
|
|
949
949
|
});
|
|
950
|
-
return
|
|
950
|
+
return bt(e, {
|
|
951
951
|
...t,
|
|
952
952
|
mark: n,
|
|
953
|
-
render: (n) =>
|
|
954
|
-
toExternalHTML: (n) =>
|
|
953
|
+
render: (n) => L(t.render(n), e.type, n, e.propSchema),
|
|
954
|
+
toExternalHTML: (n) => L((t.toExternalHTML || t.render)(n), e.type, n, e.propSchema)
|
|
955
955
|
});
|
|
956
956
|
}
|
|
957
957
|
//#endregion
|
|
958
958
|
//#region src/util/topo-sort.ts
|
|
959
|
-
function
|
|
960
|
-
let t =
|
|
959
|
+
function wt(e) {
|
|
960
|
+
let t = Et(e), { roots: n, nonRoots: r } = Dt(t), i = [];
|
|
961
961
|
for (; n.size;) {
|
|
962
962
|
i.push(n);
|
|
963
963
|
let r = /* @__PURE__ */ new Set();
|
|
@@ -972,13 +972,13 @@ function Tt(e) {
|
|
|
972
972
|
}
|
|
973
973
|
n = r;
|
|
974
974
|
}
|
|
975
|
-
if (r =
|
|
975
|
+
if (r = Dt(t).nonRoots, r.size) throw Error(`Cycle(s) detected; toposort only works on acyclic graphs. Cyclic nodes: ${Array.from(r).join(", ")}`);
|
|
976
976
|
return i;
|
|
977
977
|
}
|
|
978
|
-
function
|
|
979
|
-
return
|
|
978
|
+
function Tt(e) {
|
|
979
|
+
return wt(Ot(e));
|
|
980
980
|
}
|
|
981
|
-
function
|
|
981
|
+
function Et(e) {
|
|
982
982
|
let t = /* @__PURE__ */ new Map();
|
|
983
983
|
for (let [n, r] of e.entries()) {
|
|
984
984
|
t.has(n) || t.set(n, 0);
|
|
@@ -989,7 +989,7 @@ function Dt(e) {
|
|
|
989
989
|
}
|
|
990
990
|
return t;
|
|
991
991
|
}
|
|
992
|
-
function
|
|
992
|
+
function Dt(e) {
|
|
993
993
|
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
994
994
|
for (let [r, i] of e.entries()) i === 0 ? t.add(r) : n.add(r);
|
|
995
995
|
return {
|
|
@@ -997,7 +997,7 @@ function Ot(e) {
|
|
|
997
997
|
nonRoots: n
|
|
998
998
|
};
|
|
999
999
|
}
|
|
1000
|
-
function
|
|
1000
|
+
function Ot(e) {
|
|
1001
1001
|
let t = /* @__PURE__ */ new Map();
|
|
1002
1002
|
for (let [n, r] of e.entries()) {
|
|
1003
1003
|
t.has(n) || t.set(n, /* @__PURE__ */ new Set());
|
|
@@ -1005,26 +1005,26 @@ function kt(e) {
|
|
|
1005
1005
|
}
|
|
1006
1006
|
return t;
|
|
1007
1007
|
}
|
|
1008
|
-
function
|
|
1008
|
+
function kt() {
|
|
1009
1009
|
return /* @__PURE__ */ new Map();
|
|
1010
1010
|
}
|
|
1011
|
-
function
|
|
1011
|
+
function At(e, t, n) {
|
|
1012
1012
|
return e.has(t) || e.set(t, /* @__PURE__ */ new Set()), e.get(t).add(n), e;
|
|
1013
1013
|
}
|
|
1014
|
-
function
|
|
1015
|
-
let t =
|
|
1014
|
+
function jt(e) {
|
|
1015
|
+
let t = kt();
|
|
1016
1016
|
for (let n of e) Array.isArray(n.runsBefore) && n.runsBefore.length > 0 ? n.runsBefore.forEach((e) => {
|
|
1017
|
-
|
|
1018
|
-
}) :
|
|
1019
|
-
let n =
|
|
1017
|
+
At(t, n.key, e);
|
|
1018
|
+
}) : At(t, "default", n.key);
|
|
1019
|
+
let n = Tt(t), r = n.findIndex((e) => e.has("default"));
|
|
1020
1020
|
return (e) => 91 + (n.findIndex((t) => t.has(e)) + r) * 10;
|
|
1021
1021
|
}
|
|
1022
1022
|
//#endregion
|
|
1023
1023
|
//#region src/schema/schema.ts
|
|
1024
|
-
function
|
|
1024
|
+
function Mt(e) {
|
|
1025
1025
|
return e && Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0));
|
|
1026
1026
|
}
|
|
1027
|
-
var
|
|
1027
|
+
var Nt = class {
|
|
1028
1028
|
opts;
|
|
1029
1029
|
BlockNoteEditor = "only for types";
|
|
1030
1030
|
Block = "only for types";
|
|
@@ -1041,14 +1041,14 @@ var Pt = class {
|
|
|
1041
1041
|
this.blockSpecs = t, this.styleSpecs = r, this.styleSchema = o, this.inlineContentSpecs = n, this.blockSchema = i, this.inlineContentSchema = a;
|
|
1042
1042
|
}
|
|
1043
1043
|
init() {
|
|
1044
|
-
let e =
|
|
1044
|
+
let e = jt(Object.entries({
|
|
1045
1045
|
...this.opts.blockSpecs,
|
|
1046
1046
|
...this.opts.inlineContentSpecs,
|
|
1047
1047
|
...this.opts.styleSpecs
|
|
1048
1048
|
}).map(([e, t]) => ({
|
|
1049
1049
|
key: e,
|
|
1050
1050
|
runsBefore: t.implementation?.runsBefore ?? []
|
|
1051
|
-
}))), t = Object.fromEntries(Object.entries(this.opts.blockSpecs).map(([t, n]) => [t,
|
|
1051
|
+
}))), t = Object.fromEntries(Object.entries(this.opts.blockSpecs).map(([t, n]) => [t, pt(n.config, n.implementation, n.extensions, e(t))])), n = Object.fromEntries(Object.entries(this.opts.inlineContentSpecs).map(([t, n]) => typeof n.config == "object" ? [t, {
|
|
1052
1052
|
...n,
|
|
1053
1053
|
implementation: {
|
|
1054
1054
|
...n.implementation,
|
|
@@ -1064,22 +1064,35 @@ var Pt = class {
|
|
|
1064
1064
|
return {
|
|
1065
1065
|
blockSpecs: t,
|
|
1066
1066
|
blockSchema: Object.fromEntries(Object.entries(t).map(([e, t]) => [e, t.config])),
|
|
1067
|
-
inlineContentSpecs:
|
|
1068
|
-
styleSpecs:
|
|
1069
|
-
inlineContentSchema:
|
|
1070
|
-
styleSchema:
|
|
1067
|
+
inlineContentSpecs: Mt(n),
|
|
1068
|
+
styleSpecs: Mt(r),
|
|
1069
|
+
inlineContentSchema: vt(n),
|
|
1070
|
+
styleSchema: xt(r)
|
|
1071
1071
|
};
|
|
1072
1072
|
}
|
|
1073
1073
|
extend(e) {
|
|
1074
|
-
|
|
1074
|
+
this.opts = {
|
|
1075
|
+
blockSpecs: {
|
|
1076
|
+
...this.opts.blockSpecs,
|
|
1077
|
+
...e.blockSpecs
|
|
1078
|
+
},
|
|
1079
|
+
inlineContentSpecs: {
|
|
1080
|
+
...this.opts.inlineContentSpecs,
|
|
1081
|
+
...e.inlineContentSpecs
|
|
1082
|
+
},
|
|
1083
|
+
styleSpecs: {
|
|
1084
|
+
...this.opts.styleSpecs,
|
|
1085
|
+
...e.styleSpecs
|
|
1086
|
+
}
|
|
1087
|
+
};
|
|
1075
1088
|
let { blockSpecs: t, inlineContentSpecs: n, styleSpecs: r, blockSchema: i, inlineContentSchema: a, styleSchema: o } = this.init();
|
|
1076
1089
|
return this.blockSpecs = t, this.styleSpecs = r, this.styleSchema = o, this.inlineContentSpecs = n, this.blockSchema = i, this.inlineContentSchema = a, this;
|
|
1077
1090
|
}
|
|
1078
1091
|
};
|
|
1079
1092
|
//#endregion
|
|
1080
1093
|
//#region src/api/blockManipulation/tables/tables.ts
|
|
1081
|
-
function
|
|
1082
|
-
let { height: t, width: n } =
|
|
1094
|
+
function z(e) {
|
|
1095
|
+
let { height: t, width: n } = Pt(e), r = Array(t).fill(!1).map(() => Array(n).fill(null)), i = (e, i) => {
|
|
1083
1096
|
for (let a = e; a < t; a++) for (let e = i; e < n; e++) if (!r[a][e]) return {
|
|
1084
1097
|
row: a,
|
|
1085
1098
|
col: e
|
|
@@ -1087,7 +1100,7 @@ function R(e) {
|
|
|
1087
1100
|
throw Error("Unable to create occupancy grid for table, no more available cells");
|
|
1088
1101
|
};
|
|
1089
1102
|
for (let t = 0; t < e.content.rows.length; t++) for (let n = 0; n < e.content.rows[t].cells.length; n++) {
|
|
1090
|
-
let a =
|
|
1103
|
+
let a = C(e.content.rows[t].cells[n]), o = D(a), s = E(a), { row: c, col: l } = i(t, n);
|
|
1091
1104
|
for (let e = c; e < c + o; e++) for (let i = l; i < l + s; i++) {
|
|
1092
1105
|
if (r[e][i]) throw Error(`Unable to create occupancy grid for table, cell at ${e},${i} is already occupied`);
|
|
1093
1106
|
r[e][i] = {
|
|
@@ -1101,11 +1114,11 @@ function R(e) {
|
|
|
1101
1114
|
}
|
|
1102
1115
|
return r;
|
|
1103
1116
|
}
|
|
1104
|
-
function
|
|
1117
|
+
function B(e) {
|
|
1105
1118
|
let t = /* @__PURE__ */ new Set();
|
|
1106
1119
|
return e.map((e) => ({ cells: e.map((e) => !t.has(e.row + ":" + e.col) && (t.add(e.row + ":" + e.col), e.cell)).filter((e) => e !== !1) }));
|
|
1107
1120
|
}
|
|
1108
|
-
function
|
|
1121
|
+
function V(e, t, n = z(t)) {
|
|
1109
1122
|
for (let t = 0; t < n.length; t++) for (let r = 0; r < n[t].length; r++) {
|
|
1110
1123
|
let i = n[t][r];
|
|
1111
1124
|
if (i && i.row === e.row && i.col === e.col) return {
|
|
@@ -1116,19 +1129,19 @@ function B(e, t, n = R(t)) {
|
|
|
1116
1129
|
}
|
|
1117
1130
|
throw Error(`Unable to resolve relative table cell indices for table, cell at ${e.row},${e.col} is not occupied`);
|
|
1118
1131
|
}
|
|
1119
|
-
function
|
|
1132
|
+
function Pt(e) {
|
|
1120
1133
|
let t = e.content.rows.length, n = 0;
|
|
1121
1134
|
return e.content.rows.forEach((e) => {
|
|
1122
1135
|
let t = 0;
|
|
1123
1136
|
e.cells.forEach((e) => {
|
|
1124
|
-
t +=
|
|
1137
|
+
t += E(e);
|
|
1125
1138
|
}), n = Math.max(n, t);
|
|
1126
1139
|
}), {
|
|
1127
1140
|
height: t,
|
|
1128
1141
|
width: n
|
|
1129
1142
|
};
|
|
1130
1143
|
}
|
|
1131
|
-
function
|
|
1144
|
+
function Ft(e, t, n = z(t)) {
|
|
1132
1145
|
let r = n[e.row]?.[e.col];
|
|
1133
1146
|
if (r) return {
|
|
1134
1147
|
row: r.row,
|
|
@@ -1136,8 +1149,8 @@ function It(e, t, n = R(t)) {
|
|
|
1136
1149
|
cell: r.cell
|
|
1137
1150
|
};
|
|
1138
1151
|
}
|
|
1139
|
-
function
|
|
1140
|
-
let n =
|
|
1152
|
+
function It(e, t) {
|
|
1153
|
+
let n = z(e);
|
|
1141
1154
|
if (t < 0 || t >= n.length) return [];
|
|
1142
1155
|
let r = 0;
|
|
1143
1156
|
for (let e = 0; e < t; e++) {
|
|
@@ -1145,14 +1158,14 @@ function Lt(e, t) {
|
|
|
1145
1158
|
if (!e) return [];
|
|
1146
1159
|
r += e.rowspan;
|
|
1147
1160
|
}
|
|
1148
|
-
let i = Array(n[0].length).fill(!1).map((t, i) =>
|
|
1161
|
+
let i = Array(n[0].length).fill(!1).map((t, i) => Ft({
|
|
1149
1162
|
row: r,
|
|
1150
1163
|
col: i
|
|
1151
1164
|
}, e, n)).filter((e) => e !== void 0);
|
|
1152
1165
|
return i.filter((e, t) => i.findIndex((t) => t.row === e.row && t.col === e.col) === t);
|
|
1153
1166
|
}
|
|
1154
|
-
function
|
|
1155
|
-
let n =
|
|
1167
|
+
function Lt(e, t) {
|
|
1168
|
+
let n = z(e);
|
|
1156
1169
|
if (t < 0 || t >= n[0].length) return [];
|
|
1157
1170
|
let r = 0;
|
|
1158
1171
|
for (let e = 0; e < t; e++) {
|
|
@@ -1160,62 +1173,62 @@ function Rt(e, t) {
|
|
|
1160
1173
|
if (!e) return [];
|
|
1161
1174
|
r += e.colspan;
|
|
1162
1175
|
}
|
|
1163
|
-
let i = Array(n.length).fill(!1).map((t, i) =>
|
|
1176
|
+
let i = Array(n.length).fill(!1).map((t, i) => Ft({
|
|
1164
1177
|
row: i,
|
|
1165
1178
|
col: r
|
|
1166
1179
|
}, e, n)).filter((e) => e !== void 0);
|
|
1167
1180
|
return i.filter((e, t) => i.findIndex((t) => t.row === e.row && t.col === e.col) === t);
|
|
1168
1181
|
}
|
|
1169
|
-
function
|
|
1170
|
-
let { col: i } =
|
|
1182
|
+
function Rt(e, t, n, r = z(e)) {
|
|
1183
|
+
let { col: i } = V({
|
|
1171
1184
|
row: 0,
|
|
1172
1185
|
col: t
|
|
1173
|
-
}, e, r), { col: a } =
|
|
1186
|
+
}, e, r), { col: a } = V({
|
|
1174
1187
|
row: 0,
|
|
1175
1188
|
col: n
|
|
1176
1189
|
}, e, r);
|
|
1177
1190
|
return r.forEach((e) => {
|
|
1178
1191
|
let [t] = e.splice(i, 1);
|
|
1179
1192
|
e.splice(a, 0, t);
|
|
1180
|
-
}),
|
|
1193
|
+
}), B(r);
|
|
1181
1194
|
}
|
|
1182
|
-
function
|
|
1183
|
-
let { row: i } =
|
|
1195
|
+
function zt(e, t, n, r = z(e)) {
|
|
1196
|
+
let { row: i } = V({
|
|
1184
1197
|
row: t,
|
|
1185
1198
|
col: 0
|
|
1186
|
-
}, e, r), { row: a } =
|
|
1199
|
+
}, e, r), { row: a } = V({
|
|
1187
1200
|
row: n,
|
|
1188
1201
|
col: 0
|
|
1189
1202
|
}, e, r), [o] = r.splice(i, 1);
|
|
1190
|
-
return r.splice(a, 0, o),
|
|
1203
|
+
return r.splice(a, 0, o), B(r);
|
|
1191
1204
|
}
|
|
1192
|
-
function
|
|
1193
|
-
return e ?
|
|
1205
|
+
function Bt(e) {
|
|
1206
|
+
return e ? w(e) ? Bt(e.content) : typeof e == "string" ? e.length === 0 : Array.isArray(e) ? e.every((e) => typeof e == "string" ? e.length === 0 : S(e) ? e.text.length === 0 : Re(e) ? typeof e.content == "string" ? e.content.length === 0 : e.content.every((e) => e.text.length === 0) : !1) : !1 : !0;
|
|
1194
1207
|
}
|
|
1195
|
-
function
|
|
1208
|
+
function Vt(e, t, n = z(e)) {
|
|
1196
1209
|
if (t === "columns") {
|
|
1197
1210
|
let e = 0;
|
|
1198
|
-
for (let t = n[0].length - 1; t >= 0 && n.every((e) =>
|
|
1211
|
+
for (let t = n[0].length - 1; t >= 0 && n.every((e) => Bt(e[t].cell) && e[t].colspan === 1); t--) e++;
|
|
1199
1212
|
for (let t = n.length - 1; t >= 0; t--) {
|
|
1200
1213
|
let r = Math.max(n[t].length - e, 1);
|
|
1201
1214
|
n[t] = n[t].slice(0, r);
|
|
1202
1215
|
}
|
|
1203
|
-
return
|
|
1216
|
+
return B(n);
|
|
1204
1217
|
}
|
|
1205
1218
|
let r = 0;
|
|
1206
|
-
for (let e = n.length - 1; e >= 0 && n[e].every((e) =>
|
|
1219
|
+
for (let e = n.length - 1; e >= 0 && n[e].every((e) => Bt(e.cell) && e.rowspan === 1); e--) r++;
|
|
1207
1220
|
let i = Math.min(r, n.length - 1);
|
|
1208
|
-
return n.splice(n.length - i, i),
|
|
1221
|
+
return n.splice(n.length - i, i), B(n);
|
|
1209
1222
|
}
|
|
1210
|
-
function
|
|
1211
|
-
let { width: i, height: a } =
|
|
1223
|
+
function Ht(e, t, n, r = z(e)) {
|
|
1224
|
+
let { width: i, height: a } = Pt(e);
|
|
1212
1225
|
if (t === "columns") r.forEach((e, t) => {
|
|
1213
1226
|
if (n >= 0) for (let r = 0; r < n; r++) e.push({
|
|
1214
1227
|
row: t,
|
|
1215
1228
|
col: Math.max(...e.map((e) => e.col)) + 1,
|
|
1216
1229
|
rowspan: 1,
|
|
1217
1230
|
colspan: 1,
|
|
1218
|
-
cell:
|
|
1231
|
+
cell: C("")
|
|
1219
1232
|
});
|
|
1220
1233
|
else e.splice(i + n, -1 * n);
|
|
1221
1234
|
});
|
|
@@ -1225,78 +1238,78 @@ function Ut(e, t, n, r = R(e)) {
|
|
|
1225
1238
|
col: n,
|
|
1226
1239
|
rowspan: 1,
|
|
1227
1240
|
colspan: 1,
|
|
1228
|
-
cell:
|
|
1241
|
+
cell: C("")
|
|
1229
1242
|
}));
|
|
1230
1243
|
r.push(t);
|
|
1231
1244
|
}
|
|
1232
1245
|
else n < 0 && r.splice(a + n, -1 * n);
|
|
1233
|
-
return
|
|
1246
|
+
return B(r);
|
|
1234
1247
|
}
|
|
1235
|
-
function
|
|
1236
|
-
let r =
|
|
1237
|
-
if (!r.some((e) =>
|
|
1248
|
+
function Ut(e, t, n) {
|
|
1249
|
+
let r = It(e, n);
|
|
1250
|
+
if (!r.some((e) => D(e.cell) > 1)) return !0;
|
|
1238
1251
|
let i = n, a = n;
|
|
1239
1252
|
return r.forEach((e) => {
|
|
1240
|
-
let t =
|
|
1253
|
+
let t = D(e.cell);
|
|
1241
1254
|
i = Math.max(i, e.row + t - 1), a = Math.min(a, e.row);
|
|
1242
1255
|
}), t < n ? n === i : n === a;
|
|
1243
1256
|
}
|
|
1244
|
-
function
|
|
1245
|
-
let r =
|
|
1246
|
-
if (!r.some((e) =>
|
|
1257
|
+
function Wt(e, t, n) {
|
|
1258
|
+
let r = Lt(e, n);
|
|
1259
|
+
if (!r.some((e) => E(e.cell) > 1)) return !0;
|
|
1247
1260
|
let i = n, a = n;
|
|
1248
1261
|
return r.forEach((e) => {
|
|
1249
|
-
let t =
|
|
1262
|
+
let t = E(e.cell);
|
|
1250
1263
|
i = Math.max(i, e.col + t - 1), a = Math.min(a, e.col);
|
|
1251
1264
|
}), t < n ? n === i : n === a;
|
|
1252
1265
|
}
|
|
1253
|
-
function
|
|
1254
|
-
let r =
|
|
1266
|
+
function Gt(e, t, n) {
|
|
1267
|
+
let r = V(e, n), i = V(t, n);
|
|
1255
1268
|
return r.col === i.col;
|
|
1256
1269
|
}
|
|
1257
1270
|
//#endregion
|
|
1258
1271
|
//#region src/api/nodeConversions/blockToNode.ts
|
|
1259
|
-
function
|
|
1272
|
+
function Kt(e, t, n, r) {
|
|
1260
1273
|
let i = [];
|
|
1261
1274
|
for (let [r, a] of Object.entries(e.styles || {})) {
|
|
1262
1275
|
let e = n[r];
|
|
1263
1276
|
if (!e) throw Error(`style ${r} not found in styleSchema`);
|
|
1264
1277
|
if (e.propSchema === "boolean") a && i.push(t.mark(r));
|
|
1265
1278
|
else if (e.propSchema === "string") a && i.push(t.mark(r, { stringValue: a }));
|
|
1266
|
-
else throw new
|
|
1279
|
+
else throw new O(e.propSchema);
|
|
1267
1280
|
}
|
|
1268
|
-
let a = r && t.nodes[r] &&
|
|
1269
|
-
return !r || !
|
|
1281
|
+
let a = r && t.nodes[r] && Qe(t, t.nodes[r]) ? [...t.nodes[r].allowedMarks(i)] : i;
|
|
1282
|
+
return !r || !Qe(t, t.nodes[r]) ? 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)] : [];
|
|
1270
1283
|
}
|
|
1271
|
-
function
|
|
1284
|
+
function qt(e, t, n) {
|
|
1272
1285
|
let r = t.marks.link.create({ href: e.href });
|
|
1273
|
-
return
|
|
1286
|
+
return Jt(e.content, t, n).map((e) => {
|
|
1274
1287
|
if (e.type.name === "text") return e.mark([...e.marks, r]);
|
|
1275
1288
|
if (e.type.name === "hardBreak") return e;
|
|
1276
1289
|
throw Error("unexpected node type");
|
|
1277
1290
|
});
|
|
1278
1291
|
}
|
|
1279
|
-
function
|
|
1292
|
+
function Jt(e, t, n, r) {
|
|
1280
1293
|
let i = [];
|
|
1281
|
-
if (typeof e == "string") return i.push(...
|
|
1294
|
+
if (typeof e == "string") return i.push(...Kt({
|
|
1282
1295
|
type: "text",
|
|
1283
1296
|
text: e,
|
|
1284
1297
|
styles: {}
|
|
1285
1298
|
}, t, n, r)), i;
|
|
1286
|
-
for (let a of e) i.push(...
|
|
1299
|
+
for (let a of e) i.push(...Kt(a, t, n, r));
|
|
1287
1300
|
return i;
|
|
1288
1301
|
}
|
|
1289
|
-
function
|
|
1302
|
+
function H(e, t, n, r = M(t)) {
|
|
1290
1303
|
let i = [];
|
|
1291
|
-
for (let a of e) typeof a == "string" ? i.push(...
|
|
1304
|
+
for (let a of e) typeof a == "string" ? i.push(...Jt(a, t, r, n)) : Re(a) ? i.push(...qt(a, t, r)) : S(a) ? i.push(...Jt([a], t, r, n)) : i.push(Xt(a, t, r));
|
|
1292
1305
|
return i;
|
|
1293
1306
|
}
|
|
1294
|
-
function
|
|
1307
|
+
function Yt(e, t, n = M(t)) {
|
|
1295
1308
|
let r = [], i = Array(e.headerRows ?? 0).fill(!0), a = Array(e.headerCols ?? 0).fill(!0), o = e.columnWidths ?? [];
|
|
1296
1309
|
for (let s = 0; s < e.rows.length; s++) {
|
|
1297
1310
|
let c = e.rows[s], l = [], u = i[s];
|
|
1298
1311
|
for (let r = 0; r < c.cells.length; r++) {
|
|
1299
|
-
let i = c.cells[r], d = a[r], f = null, p =
|
|
1312
|
+
let i = c.cells[r], d = a[r], f = null, p = V({
|
|
1300
1313
|
row: s,
|
|
1301
1314
|
col: r
|
|
1302
1315
|
}, {
|
|
@@ -1305,14 +1318,14 @@ function Xt(e, t, n = A(t)) {
|
|
|
1305
1318
|
}), m = o[p.col] ? [o[p.col]] : null;
|
|
1306
1319
|
if (i) {
|
|
1307
1320
|
if (typeof i == "string") f = t.text(i);
|
|
1308
|
-
else if (
|
|
1309
|
-
i.content && (f =
|
|
1310
|
-
let e =
|
|
1321
|
+
else if (w(i)) {
|
|
1322
|
+
i.content && (f = H(i.content, t, "tableParagraph", n));
|
|
1323
|
+
let e = E(i);
|
|
1311
1324
|
e > 1 && (m = Array(e).fill(!1).map((e, t) => o[p.col + t] ?? void 0));
|
|
1312
|
-
} else f =
|
|
1325
|
+
} else f = H(i, t, "tableParagraph", n);
|
|
1313
1326
|
}
|
|
1314
1327
|
let h = t.nodes[d || u ? "tableHeader" : "tableCell"].createChecked({
|
|
1315
|
-
...
|
|
1328
|
+
...w(i) ? i.props : {},
|
|
1316
1329
|
colwidth: m
|
|
1317
1330
|
}, t.nodes.tableParagraph.createChecked(void 0, f));
|
|
1318
1331
|
l.push(h);
|
|
@@ -1322,29 +1335,29 @@ function Xt(e, t, n = A(t)) {
|
|
|
1322
1335
|
}
|
|
1323
1336
|
return r;
|
|
1324
1337
|
}
|
|
1325
|
-
function
|
|
1338
|
+
function Xt(e, t, n) {
|
|
1326
1339
|
let r, i = e.type;
|
|
1327
1340
|
if (i === void 0 && (i = "paragraph"), !t.nodes[i]) throw Error(`node type ${i} not found in schema`);
|
|
1328
1341
|
if (!e.content) r = t.nodes[i].createChecked(e.props);
|
|
1329
1342
|
else if (typeof e.content == "string") {
|
|
1330
|
-
let a =
|
|
1343
|
+
let a = H([e.content], t, i, n);
|
|
1331
1344
|
r = t.nodes[i].createChecked(e.props, a);
|
|
1332
1345
|
} else if (Array.isArray(e.content)) {
|
|
1333
|
-
let a =
|
|
1346
|
+
let a = H(e.content, t, i, n);
|
|
1334
1347
|
r = t.nodes[i].createChecked(e.props, a);
|
|
1335
1348
|
} else if (e.content.type === "tableContent") {
|
|
1336
|
-
let a =
|
|
1349
|
+
let a = Yt(e.content, t, n);
|
|
1337
1350
|
r = t.nodes[i].createChecked(e.props, a);
|
|
1338
|
-
} else throw new
|
|
1351
|
+
} else throw new O(e.content.type);
|
|
1339
1352
|
return r;
|
|
1340
1353
|
}
|
|
1341
|
-
function
|
|
1354
|
+
function U(e, t, n = M(t)) {
|
|
1342
1355
|
let r = e.id;
|
|
1343
|
-
r === void 0 && (r =
|
|
1356
|
+
r === void 0 && (r = Ie.options.generateID());
|
|
1344
1357
|
let i = [];
|
|
1345
|
-
if (e.children) for (let r of e.children) i.push(
|
|
1358
|
+
if (e.children) for (let r of e.children) i.push(U(r, t, n));
|
|
1346
1359
|
if (!e.type || t.nodes[e.type].isInGroup("blockContent")) {
|
|
1347
|
-
let a =
|
|
1360
|
+
let a = Xt(e, t, n), o = i.length > 0 ? t.nodes.blockGroup.createChecked({}, i) : void 0;
|
|
1348
1361
|
return t.nodes.blockContainer.createChecked({
|
|
1349
1362
|
id: r,
|
|
1350
1363
|
...e.props
|
|
@@ -1358,23 +1371,23 @@ function H(e, t, n = A(t)) {
|
|
|
1358
1371
|
}
|
|
1359
1372
|
//#endregion
|
|
1360
1373
|
//#region src/api/nodeUtil.ts
|
|
1361
|
-
function
|
|
1374
|
+
function Zt(e, t) {
|
|
1362
1375
|
let n, r;
|
|
1363
|
-
if (t.firstChild.descendants((i, a) => n ? !1 :
|
|
1376
|
+
if (t.firstChild.descendants((i, a) => n ? !1 : !Qt(i) || !i.attrs.id || ke(i, t) !== e || (n = i, r = a + 1, !1)), n !== void 0 && r !== void 0) return {
|
|
1364
1377
|
node: n,
|
|
1365
1378
|
posBeforeNode: r
|
|
1366
1379
|
};
|
|
1367
1380
|
}
|
|
1368
|
-
function
|
|
1381
|
+
function Qt(e) {
|
|
1369
1382
|
return e.type.isInGroup("bnBlock");
|
|
1370
1383
|
}
|
|
1371
1384
|
//#endregion
|
|
1372
1385
|
//#region src/api/blockManipulation/commands/updateBlock/updateBlock.ts
|
|
1373
|
-
var
|
|
1374
|
-
function
|
|
1386
|
+
var $t = (e, t) => ({ tr: n, dispatch: r }) => (r && en(n, e, t), !0);
|
|
1387
|
+
function en(e, t, n, r, i) {
|
|
1375
1388
|
let a = je(e.doc.resolve(t)), o = null;
|
|
1376
1389
|
a.blockNoteType === "table" && (o = cn(e));
|
|
1377
|
-
let s =
|
|
1390
|
+
let s = j(e);
|
|
1378
1391
|
if (r !== void 0 && i !== void 0 && r > i) throw Error("Invalid replaceFromPos or replaceToPos");
|
|
1379
1392
|
let c = s.nodes[a.blockNoteType], l = s.nodes[n.type || a.blockNoteType], u = l.isInGroup("bnBlock") ? l : s.nodes.blockContainer;
|
|
1380
1393
|
if (a.isBlockContainer && l.isInGroup("blockContent")) {
|
|
@@ -1382,8 +1395,8 @@ function U(e, t, n, r, i) {
|
|
|
1382
1395
|
on(n, e, a), tn(n, e, c, l, a, t, o);
|
|
1383
1396
|
} else if (!a.isBlockContainer && l.isInGroup("bnBlock")) on(n, e, a);
|
|
1384
1397
|
else {
|
|
1385
|
-
let t =
|
|
1386
|
-
children:
|
|
1398
|
+
let t = U({
|
|
1399
|
+
children: N(a.bnBlock.node, e.doc).children,
|
|
1387
1400
|
...n
|
|
1388
1401
|
}, s);
|
|
1389
1402
|
t.check(), e.replaceWith(a.bnBlock.beforePos, a.bnBlock.afterPos, t);
|
|
@@ -1392,12 +1405,12 @@ function U(e, t, n, r, i) {
|
|
|
1392
1405
|
rn(e, a.bnBlock.beforePos, u, { ...n.props }), o && ln(e, a, o);
|
|
1393
1406
|
}
|
|
1394
1407
|
function tn(e, t, n, r, o, s, c) {
|
|
1395
|
-
let l =
|
|
1408
|
+
let l = j(t), u = "keep";
|
|
1396
1409
|
if (e.content) {
|
|
1397
|
-
if (typeof e.content == "string") u =
|
|
1398
|
-
else if (Array.isArray(e.content)) u =
|
|
1399
|
-
else if (e.content.type === "tableContent") u =
|
|
1400
|
-
else throw new
|
|
1410
|
+
if (typeof e.content == "string") u = H([e.content], l, r.name);
|
|
1411
|
+
else if (Array.isArray(e.content)) u = H(e.content, l, r.name);
|
|
1412
|
+
else if (e.content.type === "tableContent") u = Yt(e.content, l);
|
|
1413
|
+
else throw new O(e.content.type);
|
|
1401
1414
|
} else {
|
|
1402
1415
|
let e = o.blockContent.node.content;
|
|
1403
1416
|
if (n.spec.content !== "" && r.spec.content !== n.spec.content && !r.validContent(e)) {
|
|
@@ -1460,10 +1473,10 @@ function an(e, t, n, r) {
|
|
|
1460
1473
|
return rn(e, t, n, r), e.mapping.slice(i).map(t, -1);
|
|
1461
1474
|
}
|
|
1462
1475
|
function on(e, t, n) {
|
|
1463
|
-
let r =
|
|
1476
|
+
let r = j(t);
|
|
1464
1477
|
if (e.children !== void 0 && e.children.length > 0) {
|
|
1465
1478
|
let a = e.children.map((e) => {
|
|
1466
|
-
let t =
|
|
1479
|
+
let t = U(e, r);
|
|
1467
1480
|
return t.check(), t;
|
|
1468
1481
|
});
|
|
1469
1482
|
if (n.childContainer) nn(t, n.childContainer.beforePos, i.from(a));
|
|
@@ -1474,9 +1487,9 @@ function on(e, t, n) {
|
|
|
1474
1487
|
}
|
|
1475
1488
|
}
|
|
1476
1489
|
function sn(e, t, n, r, i) {
|
|
1477
|
-
let a = typeof t == "string" ? t : t.id, o =
|
|
1490
|
+
let a = typeof t == "string" ? t : t.id, o = Zt(a, e.doc);
|
|
1478
1491
|
if (!o) throw Error(`Block with ID ${a} not found`);
|
|
1479
|
-
return
|
|
1492
|
+
return en(e, o.posBeforeNode, n, r, i), N(e.doc.resolve(o.posBeforeNode + 1).node(), e.doc);
|
|
1480
1493
|
}
|
|
1481
1494
|
function cn(e) {
|
|
1482
1495
|
let t = "selection" in e ? e.selection : null;
|
|
@@ -1708,7 +1721,7 @@ var W = {
|
|
|
1708
1721
|
}, bn = (e, t) => {
|
|
1709
1722
|
let n = document.createElement("div"), r = document.createElement("p");
|
|
1710
1723
|
return r.textContent = t, n.appendChild(e), n.appendChild(r), { dom: n };
|
|
1711
|
-
}, xn = (e) => ({ url: e.src || void 0 }), Sn = "<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>", Cn =
|
|
1724
|
+
}, xn = (e) => ({ url: e.src || void 0 }), Sn = "<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>", Cn = F((e) => ({
|
|
1712
1725
|
type: "audio",
|
|
1713
1726
|
propSchema: {
|
|
1714
1727
|
backgroundColor: G.backgroundColor,
|
|
@@ -1748,7 +1761,7 @@ var W = {
|
|
|
1748
1761
|
if (!e.props.url) return { dom: document.createElement("audio") };
|
|
1749
1762
|
let n;
|
|
1750
1763
|
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 ? yn(n, e.props.caption) : bn(n, e.props.caption) : { dom: n };
|
|
1751
|
-
}, Dn =
|
|
1764
|
+
}, Dn = I(Cn, (e) => ({
|
|
1752
1765
|
meta: { fileBlockAccept: ["audio/*"] },
|
|
1753
1766
|
parse: wn(e),
|
|
1754
1767
|
render: Tn(e),
|
|
@@ -1850,11 +1863,11 @@ var Mn = (e) => (t, r) => n({
|
|
|
1850
1863
|
o?.destroy();
|
|
1851
1864
|
}
|
|
1852
1865
|
};
|
|
1853
|
-
}, Fn = "code-block-keyboard-shortcuts", In =
|
|
1866
|
+
}, Fn = "code-block-keyboard-shortcuts", In = F(({ defaultLanguage: e = "text" }) => ({
|
|
1854
1867
|
type: "codeBlock",
|
|
1855
1868
|
propSchema: { language: { default: e } },
|
|
1856
1869
|
content: "plain"
|
|
1857
|
-
})), Ln =
|
|
1870
|
+
})), Ln = I(In, (e) => ({
|
|
1858
1871
|
meta: {
|
|
1859
1872
|
code: !0,
|
|
1860
1873
|
defining: !0,
|
|
@@ -1868,11 +1881,11 @@ var Mn = (e) => (t, r) => n({
|
|
|
1868
1881
|
supportedLanguages: e.supportedLanguages
|
|
1869
1882
|
}),
|
|
1870
1883
|
toExternalHTML: (e) => An(e)
|
|
1871
|
-
}), (e) => [Mn(e)(Fn, "codeBlock")]), Rn =
|
|
1884
|
+
}), (e) => [Mn(e)(Fn, "codeBlock")]), Rn = F(() => ({
|
|
1872
1885
|
type: "divider",
|
|
1873
1886
|
propSchema: {},
|
|
1874
1887
|
content: "none"
|
|
1875
|
-
})), zn =
|
|
1888
|
+
})), zn = I(Rn, {
|
|
1876
1889
|
meta: { isolating: !1 },
|
|
1877
1890
|
parse(e) {
|
|
1878
1891
|
if (e.tagName === "HR") return {};
|
|
@@ -1892,7 +1905,7 @@ var Mn = (e) => (t, r) => n({
|
|
|
1892
1905
|
};
|
|
1893
1906
|
}
|
|
1894
1907
|
}]
|
|
1895
|
-
})]), Bn = (e) => ({ url: e.src || void 0 }), Vn =
|
|
1908
|
+
})]), Bn = (e) => ({ url: e.src || void 0 }), Vn = F(() => ({
|
|
1896
1909
|
type: "file",
|
|
1897
1910
|
propSchema: {
|
|
1898
1911
|
backgroundColor: G.backgroundColor,
|
|
@@ -1920,7 +1933,7 @@ var Mn = (e) => (t, r) => n({
|
|
|
1920
1933
|
caption: r
|
|
1921
1934
|
};
|
|
1922
1935
|
}
|
|
1923
|
-
}, Un =
|
|
1936
|
+
}, Un = I(Vn, {
|
|
1924
1937
|
meta: { fileBlockAccept: ["*/*"] },
|
|
1925
1938
|
parse: Hn(),
|
|
1926
1939
|
render(e, t) {
|
|
@@ -1938,7 +1951,7 @@ function Wn(e, t, n) {
|
|
|
1938
1951
|
let a = r.fromSchema(t), o = e.querySelector(":scope > summary"), s;
|
|
1939
1952
|
if (o) {
|
|
1940
1953
|
let e = o.cloneNode(!0);
|
|
1941
|
-
|
|
1954
|
+
We(e), s = a.parse(e, {
|
|
1942
1955
|
topNode: t.nodes.paragraph.create(),
|
|
1943
1956
|
preserveWhitespace: !0
|
|
1944
1957
|
}).content;
|
|
@@ -2020,7 +2033,7 @@ var Gn = {
|
|
|
2020
2033
|
type: "heading",
|
|
2021
2034
|
props: { level: e }
|
|
2022
2035
|
}), !0);
|
|
2023
|
-
}, Yn =
|
|
2036
|
+
}, Yn = F(({ defaultLevel: e = 1, levels: t = qn, allowToggleHeadings: n = !0 } = {}) => ({
|
|
2024
2037
|
type: "heading",
|
|
2025
2038
|
propSchema: {
|
|
2026
2039
|
...G,
|
|
@@ -2034,7 +2047,7 @@ var Gn = {
|
|
|
2034
2047
|
} } : {}
|
|
2035
2048
|
},
|
|
2036
2049
|
content: "inline"
|
|
2037
|
-
})), Xn =
|
|
2050
|
+
})), Xn = I(Yn, ({ allowToggleHeadings: e = !0 } = {}) => ({
|
|
2038
2051
|
meta: { isolating: !1 },
|
|
2039
2052
|
parse(t) {
|
|
2040
2053
|
if (e && t.tagName === "DETAILS") {
|
|
@@ -2166,7 +2179,7 @@ var Gn = {
|
|
|
2166
2179
|
url: e.src || void 0,
|
|
2167
2180
|
previewWidth: e.width || void 0,
|
|
2168
2181
|
name: e.alt || void 0
|
|
2169
|
-
}), $n = "<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>", er =
|
|
2182
|
+
}), $n = "<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>", er = F((e = {}) => ({
|
|
2170
2183
|
type: "image",
|
|
2171
2184
|
propSchema: {
|
|
2172
2185
|
textAlignment: G.textAlignment,
|
|
@@ -2213,7 +2226,7 @@ var Gn = {
|
|
|
2213
2226
|
if (!e.props.url) return { dom: document.createElement("img") };
|
|
2214
2227
|
let n;
|
|
2215
2228
|
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 ? yn(n, e.props.caption) : bn(n, e.props.caption) : { dom: n };
|
|
2216
|
-
}, ir =
|
|
2229
|
+
}, ir = I(er, (e) => ({
|
|
2217
2230
|
meta: { fileBlockAccept: ["image/*"] },
|
|
2218
2231
|
parse: tr(e),
|
|
2219
2232
|
render: nr(e),
|
|
@@ -2222,7 +2235,7 @@ var Gn = {
|
|
|
2222
2235
|
})), ar = (e, t, n) => ({ state: r, dispatch: i }) => !i || or(r.tr, e, t, n), or = (e, t, n, r) => {
|
|
2223
2236
|
let i = b(Ae(e.doc, t));
|
|
2224
2237
|
if (!i.isBlockContainer) return !1;
|
|
2225
|
-
let a =
|
|
2238
|
+
let a = j(e), o = [{
|
|
2226
2239
|
type: i.bnBlock.node.type,
|
|
2227
2240
|
attrs: r ? {
|
|
2228
2241
|
...i.bnBlock.node.attrs,
|
|
@@ -2235,13 +2248,13 @@ var Gn = {
|
|
|
2235
2248
|
return e.split(t, 2, o), !0;
|
|
2236
2249
|
}, sr = (e, t) => {
|
|
2237
2250
|
let { blockInfo: n, selectionEmpty: r } = e.transact((e) => ({
|
|
2238
|
-
blockInfo:
|
|
2251
|
+
blockInfo: x(e),
|
|
2239
2252
|
selectionEmpty: e.selection.anchor === e.selection.head
|
|
2240
2253
|
}));
|
|
2241
2254
|
if (!n.isBlockContainer) return !1;
|
|
2242
2255
|
let { bnBlock: i, blockContent: a } = n;
|
|
2243
2256
|
return a.node.type.name !== t || !r ? !1 : a.node.childCount === 0 ? (e.transact((e) => {
|
|
2244
|
-
|
|
2257
|
+
en(e, i.beforePos, {
|
|
2245
2258
|
type: "paragraph",
|
|
2246
2259
|
props: {}
|
|
2247
2260
|
});
|
|
@@ -2266,11 +2279,11 @@ function cr(e, t, n) {
|
|
|
2266
2279
|
}
|
|
2267
2280
|
//#endregion
|
|
2268
2281
|
//#region src/blocks/ListItem/BulletListItem/block.ts
|
|
2269
|
-
var lr =
|
|
2282
|
+
var lr = F(() => ({
|
|
2270
2283
|
type: "bulletListItem",
|
|
2271
2284
|
propSchema: { ...G },
|
|
2272
2285
|
content: "inline"
|
|
2273
|
-
})), ur =
|
|
2286
|
+
})), ur = I(lr, {
|
|
2274
2287
|
meta: { isolating: !1 },
|
|
2275
2288
|
parse(e) {
|
|
2276
2289
|
if (e.tagName !== "LI") return;
|
|
@@ -2307,13 +2320,13 @@ var lr = P(() => ({
|
|
|
2307
2320
|
inputRules: [{
|
|
2308
2321
|
find: /^\s?[-+*]\s$/,
|
|
2309
2322
|
replace({ editor: e }) {
|
|
2310
|
-
if (
|
|
2323
|
+
if (x(e.prosemirrorState).blockNoteType !== "heading") return {
|
|
2311
2324
|
type: "bulletListItem",
|
|
2312
2325
|
props: {}
|
|
2313
2326
|
};
|
|
2314
2327
|
}
|
|
2315
2328
|
}]
|
|
2316
|
-
})]), dr =
|
|
2329
|
+
})]), dr = F(() => ({
|
|
2317
2330
|
type: "checkListItem",
|
|
2318
2331
|
propSchema: {
|
|
2319
2332
|
...G,
|
|
@@ -2323,7 +2336,7 @@ var lr = P(() => ({
|
|
|
2323
2336
|
}
|
|
2324
2337
|
},
|
|
2325
2338
|
content: "inline"
|
|
2326
|
-
})), fr =
|
|
2339
|
+
})), fr = I(dr, {
|
|
2327
2340
|
meta: { isolating: !1 },
|
|
2328
2341
|
parse(e) {
|
|
2329
2342
|
if (e.tagName === "input") return e.closest("[data-content-type]") || e.closest("li") ? void 0 : e.type === "checkbox" ? { checked: e.checked } : void 0;
|
|
@@ -2473,7 +2486,7 @@ var hr = () => new _e({
|
|
|
2473
2486
|
props: { decorations(e) {
|
|
2474
2487
|
return this.getState(e)?.decorations ?? be.empty;
|
|
2475
2488
|
} }
|
|
2476
|
-
}), gr =
|
|
2489
|
+
}), gr = F(() => ({
|
|
2477
2490
|
type: "numberedListItem",
|
|
2478
2491
|
propSchema: {
|
|
2479
2492
|
...G,
|
|
@@ -2483,7 +2496,7 @@ var hr = () => new _e({
|
|
|
2483
2496
|
}
|
|
2484
2497
|
},
|
|
2485
2498
|
content: "inline"
|
|
2486
|
-
})), _r =
|
|
2499
|
+
})), _r = I(gr, {
|
|
2487
2500
|
meta: { isolating: !1 },
|
|
2488
2501
|
parse(e) {
|
|
2489
2502
|
if (e.tagName !== "LI") return;
|
|
@@ -2516,7 +2529,7 @@ var hr = () => new _e({
|
|
|
2516
2529
|
inputRules: [{
|
|
2517
2530
|
find: /^\s?(\d+)\.\s$/,
|
|
2518
2531
|
replace({ match: e, editor: t }) {
|
|
2519
|
-
if (
|
|
2532
|
+
if (x(t.prosemirrorState).blockNoteType === "heading") return;
|
|
2520
2533
|
let n = parseInt(e[1]);
|
|
2521
2534
|
return {
|
|
2522
2535
|
type: "numberedListItem",
|
|
@@ -2535,11 +2548,11 @@ var hr = () => new _e({
|
|
|
2535
2548
|
}
|
|
2536
2549
|
},
|
|
2537
2550
|
prosemirrorPlugins: [hr()]
|
|
2538
|
-
})]), vr =
|
|
2551
|
+
})]), vr = F(() => ({
|
|
2539
2552
|
type: "toggleListItem",
|
|
2540
2553
|
propSchema: { ...G },
|
|
2541
2554
|
content: "inline"
|
|
2542
|
-
})), yr =
|
|
2555
|
+
})), yr = I(vr, {
|
|
2543
2556
|
meta: { isolating: !1 },
|
|
2544
2557
|
parse(e) {
|
|
2545
2558
|
if (e.tagName === "DETAILS") return K(e);
|
|
@@ -2583,11 +2596,11 @@ var hr = () => new _e({
|
|
|
2583
2596
|
}), !0);
|
|
2584
2597
|
}
|
|
2585
2598
|
}
|
|
2586
|
-
})]), br =
|
|
2599
|
+
})]), br = F(() => ({
|
|
2587
2600
|
type: "pageBreak",
|
|
2588
2601
|
propSchema: {},
|
|
2589
2602
|
content: "none"
|
|
2590
|
-
})), xr =
|
|
2603
|
+
})), xr = I(br, {
|
|
2591
2604
|
parse(e) {
|
|
2592
2605
|
if (e.tagName === "DIV" && e.hasAttribute("data-page-break")) return {};
|
|
2593
2606
|
},
|
|
@@ -2599,11 +2612,11 @@ var hr = () => new _e({
|
|
|
2599
2612
|
let e = document.createElement("div");
|
|
2600
2613
|
return e.setAttribute("data-page-break", ""), { dom: e };
|
|
2601
2614
|
}
|
|
2602
|
-
}), Sr = (e) => e.extend({ blockSpecs: { pageBreak: xr() } }), Cr =
|
|
2615
|
+
}), Sr = (e) => e.extend({ blockSpecs: { pageBreak: xr() } }), Cr = F(() => ({
|
|
2603
2616
|
type: "paragraph",
|
|
2604
2617
|
propSchema: G,
|
|
2605
2618
|
content: "inline"
|
|
2606
|
-
})), wr =
|
|
2619
|
+
})), wr = I(Cr, {
|
|
2607
2620
|
meta: { isolating: !1 },
|
|
2608
2621
|
parse: (e) => {
|
|
2609
2622
|
if (e.tagName === "P" && e.textContent?.trim()) return K(e);
|
|
@@ -2632,14 +2645,14 @@ var hr = () => new _e({
|
|
|
2632
2645
|
props: {}
|
|
2633
2646
|
}), !0);
|
|
2634
2647
|
} }
|
|
2635
|
-
})]), Tr =
|
|
2648
|
+
})]), Tr = F(() => ({
|
|
2636
2649
|
type: "quote",
|
|
2637
2650
|
propSchema: {
|
|
2638
2651
|
backgroundColor: G.backgroundColor,
|
|
2639
2652
|
textColor: G.textColor
|
|
2640
2653
|
},
|
|
2641
2654
|
content: "inline"
|
|
2642
|
-
})), Er =
|
|
2655
|
+
})), Er = I(Tr, {
|
|
2643
2656
|
meta: { isolating: !1 },
|
|
2644
2657
|
parse(e) {
|
|
2645
2658
|
if (e.tagName === "BLOCKQUOTE") {
|
|
@@ -2814,7 +2827,7 @@ var Or = 120, kr = 31, Ar = s.create({
|
|
|
2814
2827
|
return [{ tag: "table" }];
|
|
2815
2828
|
},
|
|
2816
2829
|
renderHTML({ node: e, HTMLAttributes: t }) {
|
|
2817
|
-
let n =
|
|
2830
|
+
let n = He(this.name, "table", {
|
|
2818
2831
|
...this.options.domAttributes?.blockContent || {},
|
|
2819
2832
|
...t
|
|
2820
2833
|
}, this.options.domAttributes?.inlineContent || {}), r = document.createElement("colgroup");
|
|
@@ -2834,7 +2847,7 @@ var Or = 120, kr = 31, Ar = s.create({
|
|
|
2834
2847
|
constructor(e, t, n) {
|
|
2835
2848
|
super(e, t), this.node = e, this.cellMinWidth = t, this.blockContentHTMLAttributes = n;
|
|
2836
2849
|
let r = document.createElement("div");
|
|
2837
|
-
r.className =
|
|
2850
|
+
r.className = A("bn-block-content", n.class), r.setAttribute("data-content-type", "table");
|
|
2838
2851
|
for (let [e, t] of Object.entries(n)) e !== "class" && r.setAttribute(e, t);
|
|
2839
2852
|
let i = this.dom, a = document.createElement("div");
|
|
2840
2853
|
a.className = "tableWrapper-inner", a.appendChild(i.firstChild), i.appendChild(a), r.appendChild(i);
|
|
@@ -2847,7 +2860,7 @@ var Or = 120, kr = 31, Ar = s.create({
|
|
|
2847
2860
|
update(e) {
|
|
2848
2861
|
if (!super.update(e)) return !1;
|
|
2849
2862
|
for (let [t, n] of Object.entries(jr)) {
|
|
2850
|
-
let r =
|
|
2863
|
+
let r = P(t), i = e.attrs[t];
|
|
2851
2864
|
i === n.default ? this.dom.removeAttribute(r) : this.dom.setAttribute(r, String(i));
|
|
2852
2865
|
}
|
|
2853
2866
|
return !0;
|
|
@@ -2908,7 +2921,7 @@ function Lr(e, t) {
|
|
|
2908
2921
|
if (e.isInline) return a.push(e), !1;
|
|
2909
2922
|
}), i.fromArray(a);
|
|
2910
2923
|
}
|
|
2911
|
-
var Rr = () =>
|
|
2924
|
+
var Rr = () => ut({
|
|
2912
2925
|
node: Pr,
|
|
2913
2926
|
type: "table",
|
|
2914
2927
|
content: "table"
|
|
@@ -2941,7 +2954,7 @@ var Rr = () => dt({
|
|
|
2941
2954
|
url: e.src || void 0,
|
|
2942
2955
|
previewWidth: e.width || void 0,
|
|
2943
2956
|
name: e.getAttribute("data-name") || void 0
|
|
2944
|
-
}), Br = "<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>", Vr =
|
|
2957
|
+
}), Br = "<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>", Vr = F((e) => ({
|
|
2945
2958
|
type: "video",
|
|
2946
2959
|
propSchema: {
|
|
2947
2960
|
textAlignment: G.textAlignment,
|
|
@@ -2975,7 +2988,7 @@ var Rr = () => dt({
|
|
|
2975
2988
|
caption: r
|
|
2976
2989
|
};
|
|
2977
2990
|
}
|
|
2978
|
-
}, Ur =
|
|
2991
|
+
}, Ur = I(Vr, (e) => ({
|
|
2979
2992
|
meta: { fileBlockAccept: ["video/*"] },
|
|
2980
2993
|
parse: Hr(e),
|
|
2981
2994
|
render(t, n) {
|
|
@@ -2994,13 +3007,7 @@ var Rr = () => dt({
|
|
|
2994
3007
|
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 ? yn(t, e.props.caption) : bn(t, e.props.caption) : { dom: t };
|
|
2995
3008
|
},
|
|
2996
3009
|
runsBefore: ["file"]
|
|
2997
|
-
}))
|
|
2998
|
-
let t = new FormData();
|
|
2999
|
-
return t.append("file", e), (await (await fetch("https://tmpfiles.org/api/v1/upload", {
|
|
3000
|
-
method: "POST",
|
|
3001
|
-
body: t
|
|
3002
|
-
})).json()).data.url.replace("tmpfiles.org/", "tmpfiles.org/dl/");
|
|
3003
|
-
};
|
|
3010
|
+
}));
|
|
3004
3011
|
//#endregion
|
|
3005
3012
|
//#region src/blocks/defaultBlockTypeGuards.ts
|
|
3006
3013
|
function X(e, t, n) {
|
|
@@ -3019,13 +3026,13 @@ function X(e, t, n) {
|
|
|
3019
3026
|
}
|
|
3020
3027
|
return !0;
|
|
3021
3028
|
}
|
|
3022
|
-
function
|
|
3029
|
+
function Wr(e, t, n, r) {
|
|
3023
3030
|
return X(t, n, r) && e.type === n;
|
|
3024
3031
|
}
|
|
3025
|
-
function
|
|
3032
|
+
function Gr(e) {
|
|
3026
3033
|
return e instanceof se;
|
|
3027
3034
|
}
|
|
3028
|
-
function
|
|
3035
|
+
function Kr(e) {
|
|
3029
3036
|
let t = e.type.spec.tableRole;
|
|
3030
3037
|
return t === "cell" || t === "header_cell";
|
|
3031
3038
|
}
|
|
@@ -3070,7 +3077,7 @@ var Z = n(({ editor: t }) => {
|
|
|
3070
3077
|
});
|
|
3071
3078
|
//#endregion
|
|
3072
3079
|
//#region src/api/positionMapping.ts
|
|
3073
|
-
function
|
|
3080
|
+
function qr(e, t, n = "left") {
|
|
3074
3081
|
let r = e.getExtension("yPositionMapping");
|
|
3075
3082
|
if (r) return r.mapPosition(t, n);
|
|
3076
3083
|
let i = e.getExtension("positionMapping");
|
|
@@ -3079,7 +3086,7 @@ function Jr(e, t, n = "left") {
|
|
|
3079
3086
|
}
|
|
3080
3087
|
//#endregion
|
|
3081
3088
|
//#region src/extensions/SuggestionMenu/SuggestionMenu.ts
|
|
3082
|
-
var
|
|
3089
|
+
var Jr = m((e) => e.type.name === "blockContainer"), Yr = class {
|
|
3083
3090
|
editor;
|
|
3084
3091
|
state;
|
|
3085
3092
|
emitUpdate;
|
|
@@ -3127,7 +3134,7 @@ var Yr = m((e) => e.type.name === "blockContainer"), Xr = class {
|
|
|
3127
3134
|
to: this.editor.transact((e) => e.selection.from)
|
|
3128
3135
|
}).run();
|
|
3129
3136
|
};
|
|
3130
|
-
}, Q = new ne("SuggestionMenuPlugin"),
|
|
3137
|
+
}, Q = new ne("SuggestionMenuPlugin"), Xr = n(({ editor: t }) => {
|
|
3131
3138
|
let n = /* @__PURE__ */ new Map(), r, i = e(void 0);
|
|
3132
3139
|
return {
|
|
3133
3140
|
key: "suggestionMenu",
|
|
@@ -3156,7 +3163,7 @@ var Yr = m((e) => e.type.name === "blockContainer"), Xr = class {
|
|
|
3156
3163
|
},
|
|
3157
3164
|
prosemirrorPlugins: [new te({
|
|
3158
3165
|
key: Q,
|
|
3159
|
-
view: (e) => (r = new
|
|
3166
|
+
view: (e) => (r = new Yr(t, (e, t) => {
|
|
3160
3167
|
i.setState({
|
|
3161
3168
|
...t,
|
|
3162
3169
|
triggerCharacter: e
|
|
@@ -3169,7 +3176,7 @@ var Yr = m((e) => e.type.name === "blockContainer"), Xr = class {
|
|
|
3169
3176
|
let o = e.getMeta(Q);
|
|
3170
3177
|
if (typeof o == "object" && o) {
|
|
3171
3178
|
n && r?.closeMenu();
|
|
3172
|
-
let e =
|
|
3179
|
+
let e = qr(t, a.selection.from - o.triggerCharacter.length);
|
|
3173
3180
|
return {
|
|
3174
3181
|
triggerCharacter: o.triggerCharacter,
|
|
3175
3182
|
deleteTriggerCharacter: o.deleteTriggerCharacter !== !1,
|
|
@@ -3201,7 +3208,7 @@ var Yr = m((e) => e.type.name === "blockContainer"), Xr = class {
|
|
|
3201
3208
|
let t = this.getState(e);
|
|
3202
3209
|
if (t === void 0) return null;
|
|
3203
3210
|
if (!t.deleteTriggerCharacter) {
|
|
3204
|
-
let n =
|
|
3211
|
+
let n = Jr(e.selection);
|
|
3205
3212
|
if (n) return Se.create(e.doc, [xe.node(n.pos, n.pos + n.node.nodeSize, {
|
|
3206
3213
|
nodeName: "span",
|
|
3207
3214
|
class: "bn-suggestion-decorator",
|
|
@@ -3220,7 +3227,7 @@ var Yr = m((e) => e.type.name === "blockContainer"), Xr = class {
|
|
|
3220
3227
|
});
|
|
3221
3228
|
//#endregion
|
|
3222
3229
|
//#region src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts
|
|
3223
|
-
function
|
|
3230
|
+
function Zr(e) {
|
|
3224
3231
|
let t = e.getTextCursorPosition().block, n = e.schema.blockSchema[t.type].content;
|
|
3225
3232
|
for (; n === "none";) {
|
|
3226
3233
|
if (t = e.getTextCursorPosition().nextBlock, t === void 0) {
|
|
@@ -3235,9 +3242,9 @@ function $(e, t) {
|
|
|
3235
3242
|
let n = e.getTextCursorPosition().block;
|
|
3236
3243
|
if (n.content === void 0) throw Error("Slash Menu open in a block that doesn't contain content.");
|
|
3237
3244
|
let r;
|
|
3238
|
-
return Array.isArray(n.content) && (n.content.length === 1 &&
|
|
3245
|
+
return Array.isArray(n.content) && (n.content.length === 1 && S(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)), Zr(e), r;
|
|
3239
3246
|
}
|
|
3240
|
-
function
|
|
3247
|
+
function Qr(e) {
|
|
3241
3248
|
let t = [];
|
|
3242
3249
|
return X(e, "heading", { level: "number" }) && (e.schema.blockSchema.heading.propSchema.level.values || []).filter((e) => e <= 3).forEach((n) => {
|
|
3243
3250
|
t.push({
|
|
@@ -3247,7 +3254,7 @@ function $r(e) {
|
|
|
3247
3254
|
props: { level: n }
|
|
3248
3255
|
});
|
|
3249
3256
|
},
|
|
3250
|
-
badge:
|
|
3257
|
+
badge: k(`Mod-Alt-${n}`),
|
|
3251
3258
|
key: n === 1 ? "heading" : `heading_${n}`,
|
|
3252
3259
|
...e.dictionary.slash_menu[n === 1 ? "heading" : `heading_${n}`]
|
|
3253
3260
|
});
|
|
@@ -3261,42 +3268,42 @@ function $r(e) {
|
|
|
3261
3268
|
onItemClick: () => {
|
|
3262
3269
|
$(e, { type: "toggleListItem" });
|
|
3263
3270
|
},
|
|
3264
|
-
badge:
|
|
3271
|
+
badge: k("Mod-Shift-6"),
|
|
3265
3272
|
key: "toggle_list",
|
|
3266
3273
|
...e.dictionary.slash_menu.toggle_list
|
|
3267
3274
|
}), X(e, "numberedListItem") && t.push({
|
|
3268
3275
|
onItemClick: () => {
|
|
3269
3276
|
$(e, { type: "numberedListItem" });
|
|
3270
3277
|
},
|
|
3271
|
-
badge:
|
|
3278
|
+
badge: k("Mod-Shift-7"),
|
|
3272
3279
|
key: "numbered_list",
|
|
3273
3280
|
...e.dictionary.slash_menu.numbered_list
|
|
3274
3281
|
}), X(e, "bulletListItem") && t.push({
|
|
3275
3282
|
onItemClick: () => {
|
|
3276
3283
|
$(e, { type: "bulletListItem" });
|
|
3277
3284
|
},
|
|
3278
|
-
badge:
|
|
3285
|
+
badge: k("Mod-Shift-8"),
|
|
3279
3286
|
key: "bullet_list",
|
|
3280
3287
|
...e.dictionary.slash_menu.bullet_list
|
|
3281
3288
|
}), X(e, "checkListItem") && t.push({
|
|
3282
3289
|
onItemClick: () => {
|
|
3283
3290
|
$(e, { type: "checkListItem" });
|
|
3284
3291
|
},
|
|
3285
|
-
badge:
|
|
3292
|
+
badge: k("Mod-Shift-9"),
|
|
3286
3293
|
key: "check_list",
|
|
3287
3294
|
...e.dictionary.slash_menu.check_list
|
|
3288
3295
|
}), X(e, "paragraph") && t.push({
|
|
3289
3296
|
onItemClick: () => {
|
|
3290
3297
|
$(e, { type: "paragraph" });
|
|
3291
3298
|
},
|
|
3292
|
-
badge:
|
|
3299
|
+
badge: k("Mod-Alt-0"),
|
|
3293
3300
|
key: "paragraph",
|
|
3294
3301
|
...e.dictionary.slash_menu.paragraph
|
|
3295
3302
|
}), X(e, "codeBlock") && t.push({
|
|
3296
3303
|
onItemClick: () => {
|
|
3297
3304
|
$(e, { type: "codeBlock" });
|
|
3298
3305
|
},
|
|
3299
|
-
badge:
|
|
3306
|
+
badge: k("Mod-Alt-c"),
|
|
3300
3307
|
key: "code_block",
|
|
3301
3308
|
...e.dictionary.slash_menu.code_block
|
|
3302
3309
|
}), X(e, "divider") && t.push({
|
|
@@ -3379,13 +3386,13 @@ function $r(e) {
|
|
|
3379
3386
|
props: { level: n }
|
|
3380
3387
|
});
|
|
3381
3388
|
},
|
|
3382
|
-
badge:
|
|
3389
|
+
badge: k(`Mod-Alt-${n}`),
|
|
3383
3390
|
key: `heading_${n}`,
|
|
3384
3391
|
...e.dictionary.slash_menu[`heading_${n}`]
|
|
3385
3392
|
});
|
|
3386
3393
|
}), t.push({
|
|
3387
3394
|
onItemClick: () => {
|
|
3388
|
-
e.getExtension(
|
|
3395
|
+
e.getExtension(Xr)?.openSuggestionMenu(":", {
|
|
3389
3396
|
deleteTriggerCharacter: !0,
|
|
3390
3397
|
ignoreQueryLength: !0
|
|
3391
3398
|
});
|
|
@@ -3394,17 +3401,17 @@ function $r(e) {
|
|
|
3394
3401
|
...e.dictionary.slash_menu.emoji
|
|
3395
3402
|
}), t;
|
|
3396
3403
|
}
|
|
3397
|
-
function
|
|
3404
|
+
function $r(e, t) {
|
|
3398
3405
|
return e.filter(({ title: e, aliases: n }) => e.toLowerCase().includes(t.toLowerCase()) || n && n.filter((e) => e.toLowerCase().includes(t.toLowerCase())).length !== 0);
|
|
3399
3406
|
}
|
|
3400
3407
|
//#endregion
|
|
3401
3408
|
//#region src/blocks/PageBreak/getPageBreakSlashMenuItems.ts
|
|
3402
|
-
function
|
|
3409
|
+
function ei(e) {
|
|
3403
3410
|
return "pageBreak" in e.schema.blockSchema;
|
|
3404
3411
|
}
|
|
3405
|
-
function
|
|
3412
|
+
function ti(e) {
|
|
3406
3413
|
let t = [];
|
|
3407
|
-
return
|
|
3414
|
+
return ei(e) && t.push({
|
|
3408
3415
|
...e.dictionary.slash_menu.page_break,
|
|
3409
3416
|
onItemClick: () => {
|
|
3410
3417
|
$(e, { type: "pageBreak" });
|
|
@@ -3414,7 +3421,7 @@ function ni(e) {
|
|
|
3414
3421
|
}
|
|
3415
3422
|
//#endregion
|
|
3416
3423
|
//#region src/blocks/defaultBlocks.ts
|
|
3417
|
-
var
|
|
3424
|
+
var ni = {
|
|
3418
3425
|
audio: Dn(),
|
|
3419
3426
|
bulletListItem: ur(),
|
|
3420
3427
|
checkListItem: fr(),
|
|
@@ -3429,7 +3436,7 @@ var ri = {
|
|
|
3429
3436
|
table: Rr(),
|
|
3430
3437
|
toggleListItem: yr(),
|
|
3431
3438
|
video: Ur()
|
|
3432
|
-
},
|
|
3439
|
+
}, ri = Ct({
|
|
3433
3440
|
type: "textColor",
|
|
3434
3441
|
propSchema: "string"
|
|
3435
3442
|
}, {
|
|
@@ -3450,7 +3457,7 @@ var ri = {
|
|
|
3450
3457
|
parse: (e) => {
|
|
3451
3458
|
if (e.tagName === "SPAN" && e.style.color) return e.style.color;
|
|
3452
3459
|
}
|
|
3453
|
-
}),
|
|
3460
|
+
}), ii = Ct({
|
|
3454
3461
|
type: "backgroundColor",
|
|
3455
3462
|
propSchema: "string"
|
|
3456
3463
|
}, {
|
|
@@ -3471,12 +3478,12 @@ var ri = {
|
|
|
3471
3478
|
parse: (e) => {
|
|
3472
3479
|
if (e.tagName === "SPAN" && e.style.backgroundColor) return e.style.backgroundColor;
|
|
3473
3480
|
}
|
|
3474
|
-
}),
|
|
3475
|
-
bold:
|
|
3476
|
-
italic:
|
|
3477
|
-
underline:
|
|
3478
|
-
strike:
|
|
3479
|
-
code:
|
|
3481
|
+
}), ai = {
|
|
3482
|
+
bold: R(Ce, "boolean"),
|
|
3483
|
+
italic: R(Te, "boolean"),
|
|
3484
|
+
underline: R(De, "boolean"),
|
|
3485
|
+
strike: R(Ee, "boolean"),
|
|
3486
|
+
code: R(we.extend({ addInputRules() {
|
|
3480
3487
|
return [_({
|
|
3481
3488
|
find: /(^|[^`])`([^`]+)`(?!`)$/,
|
|
3482
3489
|
type: this.type
|
|
@@ -3488,9 +3495,9 @@ var ri = {
|
|
|
3488
3495
|
}
|
|
3489
3496
|
})];
|
|
3490
3497
|
} }), "boolean"),
|
|
3491
|
-
textColor:
|
|
3492
|
-
backgroundColor:
|
|
3493
|
-
},
|
|
3498
|
+
textColor: ri,
|
|
3499
|
+
backgroundColor: ii
|
|
3500
|
+
}, oi = xt(ai), si = {
|
|
3494
3501
|
text: {
|
|
3495
3502
|
config: "text",
|
|
3496
3503
|
implementation: {}
|
|
@@ -3499,16 +3506,16 @@ var ri = {
|
|
|
3499
3506
|
config: "link",
|
|
3500
3507
|
implementation: {}
|
|
3501
3508
|
}
|
|
3502
|
-
},
|
|
3509
|
+
}, ci = vt(si), li = class e extends Nt {
|
|
3503
3510
|
static create(t) {
|
|
3504
3511
|
return new e({
|
|
3505
|
-
blockSpecs: t?.blockSpecs ??
|
|
3506
|
-
inlineContentSpecs: t?.inlineContentSpecs ??
|
|
3507
|
-
styleSpecs: t?.styleSpecs ??
|
|
3512
|
+
blockSpecs: t?.blockSpecs ?? ni,
|
|
3513
|
+
inlineContentSpecs: t?.inlineContentSpecs ?? si,
|
|
3514
|
+
styleSpecs: t?.styleSpecs ?? ai
|
|
3508
3515
|
});
|
|
3509
3516
|
}
|
|
3510
3517
|
};
|
|
3511
3518
|
//#endregion
|
|
3512
|
-
export {
|
|
3519
|
+
export { Kn as $, b as $n, bt as $t, Er as A, Xe as An, sn as At, fr as B, Ve as Bn, Wt as Bt, Rr as C, nt as Cn, dn as Ct, Dr as D, Ze as Dn, un as Dt, Or as E, rt as En, K as Et, Sr as F, He as Fn, U as Ft, $n as G, D as Gn, Pt as Gt, lr as H, O as Hn, Vt as Ht, vr as I, Ue as In, H as It, tr as J, C as Jn, Nt as Jt, er as K, w as Kn, Rt as Kt, yr as L, We as Ln, Yt as Lt, wr as M, M as Mn, en as Mt, br as N, Qe as Nn, Zt as Nt, Y as O, Je as On, W as Ot, xr as P, Ke as Pn, Qt as Pt, Xn as Q, Ie as Qn, L as Qt, gr as R, k as Rn, Ht as Rt, Hr as S, $e as Sn, G as St, kr as T, tt as Tn, fn as Tt, ur as U, ze as Un, Lt as Ut, dr as V, A as Vn, Ut as Vt, ar as W, E as Wn, It as Wt, rr as X, Re as Xn, Ct as Xt, nr as Y, Le as Yn, jt as Yt, Yn as Z, S as Zn, St as Zt, Kr as _, lt as _n, Cn as _t, oi as a, _t as an, ke as ar, zn as at, Vr as b, at as bn, J as bt, ti as c, pt as cn, Pn as ct, $ as d, I as dn, On as dt, R as en, Me as er, Gn as et, Xr as f, ft as fn, kn as ft, X as g, ot as gn, En as gt, Wr as h, st as hn, Tn as ht, si as i, ht as in, Ae as ir, Rn as it, Cr as j, j as jn, $t as jt, Tr as k, Ye as kn, cn as kt, $r as l, dt as ln, Nn as lt, Z as m, ct as mn, wn as mt, ni as n, yt as nn, x as nr, Un as nt, ai as o, gt as on, Oe as or, In as ot, qr as p, ut as pn, Sn as pt, ir as q, T as qn, zt as qt, ci as r, mt as rn, y as rr, Hn as rt, ei as s, vt as sn, Ln as st, li as t, xt as tn, je as tr, Vn as tt, Qr as u, F as un, An as ut, Gr as v, P as vn, Dn as vt, jr as w, N as wn, pn as wt, Ur as x, et as xn, q as xt, Br as y, it as yn, xn as yt, _r as z, Be as zn, Gt as zt };
|
|
3513
3520
|
|
|
3514
|
-
//# sourceMappingURL=blocks-
|
|
3521
|
+
//# sourceMappingURL=blocks-Dol85hpH.js.map
|