@blocknote/core 0.53.0 → 0.54.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/BlockNoteExtension-BJCLnwrE.cjs +2 -0
- package/dist/BlockNoteExtension-BJCLnwrE.cjs.map +1 -0
- package/dist/BlockNoteExtension-CbvDA0F7.js +80 -0
- package/dist/BlockNoteExtension-CbvDA0F7.js.map +1 -0
- package/dist/{UserStore-QbbPFj0z.js → UserStore-C4TzkGEn.js} +3 -3
- package/dist/{UserStore-DCG6lsla.cjs.map → UserStore-C4TzkGEn.js.map} +1 -1
- package/dist/{UserStore-DCG6lsla.cjs → UserStore-mj3fXW4D.cjs} +2 -2
- package/dist/UserStore-mj3fXW4D.cjs.map +1 -0
- package/dist/blocknote.cjs +1 -1
- package/dist/blocknote.js +6 -6
- package/dist/{blocks-BEJW9OM_.js → blocks-CzQLehlc.js} +571 -568
- package/dist/blocks-CzQLehlc.js.map +1 -0
- package/dist/blocks-CzkqclGj.cjs +12 -0
- package/dist/blocks-CzkqclGj.cjs.map +1 -0
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +2 -2
- package/dist/comments.cjs +1 -1
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js +7 -7
- package/dist/comments.js.map +1 -1
- package/dist/en-BuzSuuTq.cjs +2 -0
- package/dist/en-BuzSuuTq.cjs.map +1 -0
- package/dist/{en-CGKXfWma.js → en-uzHzj6eH.js} +10 -1
- package/dist/en-uzHzj6eH.js.map +1 -0
- package/dist/extensions-CSB9ZvuL.cjs +58 -0
- package/dist/extensions-CSB9ZvuL.cjs.map +1 -0
- package/dist/{extensions-BR5hkAio.js → extensions-DGuhtOgB.js} +662 -427
- package/dist/extensions-DGuhtOgB.js.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +4 -4
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +199 -1
- package/dist/locales.js.map +1 -1
- package/dist/{src-BUXut68d.js → src-BkfZVfaO.js} +967 -899
- package/dist/src-BkfZVfaO.js.map +1 -0
- package/dist/src-DM3syMdf.cjs +23 -0
- package/dist/src-DM3syMdf.cjs.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.cjs.map +1 -1
- package/dist/y.js +59 -56
- package/dist/y.js.map +1 -1
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.cjs.map +1 -1
- package/dist/yjs.js +88 -76
- package/dist/yjs.js.map +1 -1
- package/package.json +17 -18
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +2505 -763
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +42 -0
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +16 -4
- package/src/api/exporters/markdown/htmlToMarkdown.ts +45 -10
- package/src/api/nodeConversions/blockToNode.ts +5 -1
- package/src/api/nodeConversions/nodeToBlock.ts +3 -0
- package/src/api/pmUtil.ts +16 -8
- package/src/blocks/Code/CodeBlockOptions.ts +83 -0
- package/src/blocks/Code/block.test.ts +1 -1
- package/src/blocks/Code/block.ts +29 -281
- package/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.ts +120 -0
- package/src/blocks/Code/helpers/parse/parsePreCode.ts +45 -0
- package/src/blocks/Code/helpers/render/createCodeBlock.ts +98 -0
- package/src/blocks/Code/helpers/toExternalHTML/createPreCode.ts +14 -0
- package/src/blocks/index.ts +3 -0
- package/src/comments/extension.ts +2 -4
- package/src/editor/Block.css +273 -2
- package/src/editor/BlockNoteEditor.ts +25 -4
- package/src/editor/BlockNoteExtension.ts +1 -1
- package/src/editor/managers/ExtensionManager/extensions.ts +6 -0
- package/src/exporter/ExportImage.ts +50 -0
- package/src/exporter/Exporter.test.ts +48 -0
- package/src/exporter/Exporter.ts +46 -12
- package/src/exporter/index.ts +1 -0
- package/src/exporter/mapping.ts +4 -1
- package/src/extensions/FormattingToolbar/FormattingToolbar.ts +10 -8
- package/src/extensions/InlineContentBoundaryEdit/InlineContentBoundaryEdit.ts +109 -0
- package/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.ts +192 -0
- package/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.ts +142 -0
- package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.ts +120 -0
- package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.ts +89 -0
- package/src/extensions/SyntaxHighlighting/inlineHighlight.test.ts +135 -0
- package/src/extensions/SyntaxHighlighting/shiki.ts +116 -0
- package/src/extensions/Versioning/inMemoryVersioning.ts +13 -3
- package/src/extensions/index.ts +4 -0
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts +51 -2
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +22 -2
- package/src/i18n/locales/ar.ts +9 -0
- package/src/i18n/locales/de.ts +9 -0
- package/src/i18n/locales/en.ts +9 -0
- package/src/i18n/locales/es.ts +9 -0
- package/src/i18n/locales/fa.ts +9 -0
- package/src/i18n/locales/fr.ts +9 -0
- package/src/i18n/locales/he.ts +9 -0
- package/src/i18n/locales/hr.ts +9 -0
- package/src/i18n/locales/is.ts +9 -0
- package/src/i18n/locales/it.ts +9 -0
- package/src/i18n/locales/ja.ts +9 -0
- package/src/i18n/locales/ko.ts +9 -0
- package/src/i18n/locales/nl.ts +9 -0
- package/src/i18n/locales/no.ts +9 -0
- package/src/i18n/locales/pl.ts +9 -0
- package/src/i18n/locales/pt.ts +9 -0
- package/src/i18n/locales/ru.ts +9 -0
- package/src/i18n/locales/sk.ts +9 -0
- package/src/i18n/locales/uk.ts +9 -0
- package/src/i18n/locales/uz.ts +9 -0
- package/src/i18n/locales/vi.ts +9 -0
- package/src/i18n/locales/zh-tw.ts +9 -0
- package/src/i18n/locales/zh.ts +9 -0
- package/src/index.ts +5 -1
- package/src/schema/blocks/createSpec.ts +2 -3
- package/src/schema/blocks/types.ts +53 -3
- package/src/schema/contentTypePropagation.test.ts +1 -1
- package/src/schema/inlineContent/createSpec.test.ts +161 -0
- package/src/schema/inlineContent/createSpec.ts +171 -12
- package/src/schema/inlineContent/internal.ts +21 -2
- package/src/schema/inlineContent/types.ts +35 -5
- package/src/user/UserStore.ts +1 -1
- package/src/util/Store.test.ts +132 -0
- package/src/util/Store.ts +135 -0
- package/src/y/extensions/AttributionExtension.test.ts +10 -0
- package/src/y/extensions/Versioning.test.ts +20 -7
- package/src/yjs/comments/RESTYjsThreadStore.test.ts +85 -0
- package/src/yjs/comments/RESTYjsThreadStore.ts +7 -1
- package/src/yjs/extensions/ForkYDoc.test.ts +37 -0
- package/src/yjs/extensions/ForkYDoc.ts +26 -1
- package/src/yjs/extensions/RelativePositionMapping.ts +8 -2
- package/src/yjs/extensions/Versioning.test.ts +17 -5
- package/types/src/api/pmUtil.d.ts +7 -7
- package/types/src/blocks/Code/CodeBlockOptions.d.ts +61 -0
- package/types/src/blocks/Code/block.d.ts +3 -53
- package/types/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.d.ts +35 -0
- package/types/src/blocks/Code/helpers/parse/parsePreCode.d.ts +8 -0
- package/types/src/blocks/Code/helpers/render/createCodeBlock.d.ts +18 -0
- package/types/src/blocks/Code/helpers/toExternalHTML/createPreCode.d.ts +5 -0
- package/types/src/blocks/index.d.ts +3 -0
- package/types/src/comments/extension.d.ts +1 -15
- package/types/src/editor/BlockNoteEditor.d.ts +3 -3
- package/types/src/editor/BlockNoteExtension.d.ts +1 -1
- package/types/src/exporter/ExportImage.d.ts +36 -0
- package/types/src/exporter/Exporter.d.ts +21 -0
- package/types/src/exporter/Exporter.test.d.ts +1 -0
- package/types/src/exporter/index.d.ts +1 -0
- package/types/src/exporter/mapping.d.ts +1 -1
- package/types/src/extensions/FilePanel/FilePanel.d.ts +1 -1
- package/types/src/extensions/FormattingToolbar/FormattingToolbar.d.ts +1 -1
- package/types/src/extensions/InlineContentBoundaryEdit/InlineContentBoundaryEdit.d.ts +5 -0
- package/types/src/extensions/ShowSelection/ShowSelection.d.ts +1 -5
- package/types/src/extensions/SideMenu/SideMenu.d.ts +1 -1
- package/types/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.d.ts +45 -0
- package/types/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.d.ts +49 -0
- package/types/src/extensions/SuggestionMenu/SuggestionMenu.d.ts +1 -11
- package/types/src/extensions/SyntaxHighlighting/SyntaxHighlighting.d.ts +44 -0
- package/types/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.d.ts +1 -0
- package/types/src/extensions/SyntaxHighlighting/inlineHighlight.test.d.ts +1 -0
- package/types/src/extensions/SyntaxHighlighting/shiki.d.ts +13 -0
- package/types/src/extensions/TableHandles/TableHandles.d.ts +1 -1
- package/types/src/extensions/Versioning/Versioning.d.ts +1 -35
- package/types/src/extensions/index.d.ts +4 -0
- package/types/src/i18n/locales/en.d.ts +9 -0
- package/types/src/i18n/locales/fa.d.ts +9 -0
- package/types/src/i18n/locales/sk.d.ts +9 -0
- package/types/src/index.d.ts +2 -1
- package/types/src/schema/blocks/types.d.ts +36 -3
- package/types/src/schema/inlineContent/createSpec.d.ts +35 -3
- package/types/src/schema/inlineContent/createSpec.test.d.ts +1 -0
- package/types/src/schema/inlineContent/internal.d.ts +3 -2
- package/types/src/schema/inlineContent/types.d.ts +22 -3
- package/types/src/user/UserStore.d.ts +1 -1
- package/types/src/util/Store.d.ts +45 -0
- package/types/src/util/Store.test.d.ts +1 -0
- package/types/src/y/extensions/AttributionExtension.d.ts +1 -1
- package/types/src/y/extensions/DiffVersioningExtension.d.ts +1 -1
- package/types/src/y/extensions/ForkYDoc.d.ts +1 -5
- package/types/src/y/extensions/index.d.ts +2 -10
- package/types/src/yjs/comments/RESTYjsThreadStore.test.d.ts +1 -0
- package/types/src/yjs/extensions/ForkYDoc.d.ts +1 -5
- package/types/src/yjs/extensions/index.d.ts +1 -5
- package/dist/BlockNoteExtension-B_IEJHS8.js +0 -38
- package/dist/BlockNoteExtension-B_IEJHS8.js.map +0 -1
- package/dist/BlockNoteExtension-M0znTzxP.cjs +0 -2
- package/dist/BlockNoteExtension-M0znTzxP.cjs.map +0 -1
- package/dist/UserStore-QbbPFj0z.js.map +0 -1
- package/dist/blocks-BEJW9OM_.js.map +0 -1
- package/dist/blocks-BPmJglFo.cjs +0 -12
- package/dist/blocks-BPmJglFo.cjs.map +0 -1
- package/dist/en-C5Z4Ag9_.cjs +0 -2
- package/dist/en-C5Z4Ag9_.cjs.map +0 -1
- package/dist/en-CGKXfWma.js.map +0 -1
- package/dist/extensions-AitWbYdJ.cjs +0 -52
- package/dist/extensions-AitWbYdJ.cjs.map +0 -1
- package/dist/extensions-BR5hkAio.js.map +0 -1
- package/dist/src-BHPuOo7W.cjs +0 -21
- package/dist/src-BHPuOo7W.cjs.map +0 -1
- package/dist/src-BUXut68d.js.map +0 -1
- package/src/blocks/Code/shiki.ts +0 -73
- package/types/src/blocks/Code/shiki.d.ts +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as e, o as t, t as n } from "./BlockNoteExtension-CbvDA0F7.js";
|
|
2
2
|
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";
|
|
@@ -6,24 +6,22 @@ import { uuidv4 as ee } from "lib0/random";
|
|
|
6
6
|
import { Plugin as te, PluginKey as ne, TextSelection as re } from "prosemirror-state";
|
|
7
7
|
import { DOMParser as ie, DOMSerializer as ae, Fragment as oe } from "@tiptap/pm/model";
|
|
8
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 {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import Te from "@tiptap/extension-
|
|
15
|
-
import Ee from "@tiptap/extension-
|
|
16
|
-
import De from "@tiptap/extension-
|
|
17
|
-
import Oe from "@tiptap/extension-strike";
|
|
18
|
-
import ke from "@tiptap/extension-underline";
|
|
9
|
+
import { Plugin as _e, PluginKey as ve } from "@tiptap/pm/state";
|
|
10
|
+
import { Decoration as ye, DecorationSet as be } from "@tiptap/pm/view";
|
|
11
|
+
import { Decoration as xe, DecorationSet as Se } from "prosemirror-view";
|
|
12
|
+
import Ce from "@tiptap/extension-bold";
|
|
13
|
+
import we from "@tiptap/extension-code";
|
|
14
|
+
import Te from "@tiptap/extension-italic";
|
|
15
|
+
import Ee from "@tiptap/extension-strike";
|
|
16
|
+
import De from "@tiptap/extension-underline";
|
|
19
17
|
//#region src/api/getBlockInfoFromPos.ts
|
|
20
|
-
function
|
|
18
|
+
function Oe(e) {
|
|
21
19
|
return e.marks.some((e) => ["y-attributed-delete"].includes(e.type.name));
|
|
22
20
|
}
|
|
23
|
-
function
|
|
21
|
+
function ke(e, t) {
|
|
24
22
|
let n = e.attrs.id;
|
|
25
23
|
if (!n) throw Error(`Node ${e.type.name} does not have an ID`);
|
|
26
|
-
if (
|
|
24
|
+
if (Oe(e)) {
|
|
27
25
|
let r = 0, i = !1;
|
|
28
26
|
if (t.descendants((t) => {
|
|
29
27
|
if (i) return !1;
|
|
@@ -37,7 +35,7 @@ function je(e, t) {
|
|
|
37
35
|
}
|
|
38
36
|
return n;
|
|
39
37
|
}
|
|
40
|
-
function
|
|
38
|
+
function Ae(e, t) {
|
|
41
39
|
let n = e.resolve(t);
|
|
42
40
|
if (n.nodeAfter && n.nodeAfter.type.isInGroup("bnBlock")) return {
|
|
43
41
|
posBeforeNode: n.pos,
|
|
@@ -94,45 +92,44 @@ function y(e, t) {
|
|
|
94
92
|
childContainer: t,
|
|
95
93
|
blockNoteType: e.node.type.name
|
|
96
94
|
};
|
|
97
|
-
} else {
|
|
98
|
-
if (!i.node.type.isInGroup("childContainer")) throw Error(`bnBlock node is not in the childContainer group: ${i.node}`);
|
|
99
|
-
return {
|
|
100
|
-
isBlockContainer: !1,
|
|
101
|
-
bnBlock: i,
|
|
102
|
-
childContainer: i,
|
|
103
|
-
blockNoteType: i.node.type.name
|
|
104
|
-
};
|
|
105
95
|
}
|
|
96
|
+
if (!i.node.type.isInGroup("childContainer")) throw Error(`bnBlock node is not in the childContainer group: ${i.node}`);
|
|
97
|
+
return {
|
|
98
|
+
isBlockContainer: !1,
|
|
99
|
+
bnBlock: i,
|
|
100
|
+
childContainer: i,
|
|
101
|
+
blockNoteType: i.node.type.name
|
|
102
|
+
};
|
|
106
103
|
}
|
|
107
104
|
function b(e) {
|
|
108
105
|
return y(e.node, e.posBeforeNode);
|
|
109
106
|
}
|
|
110
|
-
function
|
|
107
|
+
function je(e) {
|
|
111
108
|
if (!e.nodeAfter) throw Error(`Attempted to get blockContainer node at position ${e.pos} but a node at this position does not exist`);
|
|
112
109
|
return y(e.nodeAfter, e.pos);
|
|
113
110
|
}
|
|
114
|
-
function
|
|
115
|
-
return
|
|
111
|
+
function Me(e) {
|
|
112
|
+
return Ne(e, e.selection.anchor);
|
|
116
113
|
}
|
|
117
|
-
function
|
|
118
|
-
return b(
|
|
114
|
+
function Ne(e, t) {
|
|
115
|
+
return b(Ae(e.doc, t));
|
|
119
116
|
}
|
|
120
117
|
//#endregion
|
|
121
118
|
//#region src/extensions/tiptap-extensions/UniqueID/UniqueID.ts
|
|
122
|
-
function
|
|
119
|
+
function Pe(e, t = JSON.stringify) {
|
|
123
120
|
let n = {};
|
|
124
121
|
return e.filter((e) => {
|
|
125
122
|
let r = t(e);
|
|
126
123
|
return Object.prototype.hasOwnProperty.call(n, r) ? !1 : n[r] = !0;
|
|
127
124
|
});
|
|
128
125
|
}
|
|
129
|
-
function
|
|
130
|
-
return
|
|
126
|
+
function Fe(e) {
|
|
127
|
+
return Pe(e.filter((t, n) => e.indexOf(t) !== n));
|
|
131
128
|
}
|
|
132
|
-
function
|
|
129
|
+
function Ie(e) {
|
|
133
130
|
return e.marks.some((e) => e.type.name === "y-attributed-delete");
|
|
134
131
|
}
|
|
135
|
-
var
|
|
132
|
+
var Le = s.create({
|
|
136
133
|
name: "uniqueID",
|
|
137
134
|
priority: 1e4,
|
|
138
135
|
addOptions() {
|
|
@@ -173,9 +170,9 @@ var ze = s.create({
|
|
|
173
170
|
if (!(e.some((e) => e.docChanged) && !t.doc.eq(n.doc))) return;
|
|
174
171
|
let { tr: r } = n, { types: i, generateID: a } = this.options, o = f(t.doc, e), { mapping: s } = o;
|
|
175
172
|
if (h(o).forEach(({ newRange: e }) => {
|
|
176
|
-
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 = Fe(o.map(({ node: e }) => e.attrs.id).filter((e) => e !== null));
|
|
177
174
|
o.forEach(({ node: e, pos: i }) => {
|
|
178
|
-
if (
|
|
175
|
+
if (Ie(e)) return;
|
|
179
176
|
let o = r.doc.nodeAt(i)?.attrs.id;
|
|
180
177
|
if (o === null) {
|
|
181
178
|
let o = t.doc.type.createAndFill().content;
|
|
@@ -196,7 +193,7 @@ var ze = s.create({
|
|
|
196
193
|
return;
|
|
197
194
|
}
|
|
198
195
|
let { deleted: l } = s.invert().mapResult(i);
|
|
199
|
-
l && c.includes(o) && !
|
|
196
|
+
l && c.includes(o) && !Oe(e) && r.setNodeMarkup(i, void 0, {
|
|
200
197
|
...e.attrs,
|
|
201
198
|
id: a()
|
|
202
199
|
});
|
|
@@ -245,10 +242,10 @@ var ze = s.create({
|
|
|
245
242
|
});
|
|
246
243
|
//#endregion
|
|
247
244
|
//#region src/schema/inlineContent/types.ts
|
|
248
|
-
function
|
|
245
|
+
function Re(e) {
|
|
249
246
|
return e.type === "link";
|
|
250
247
|
}
|
|
251
|
-
function
|
|
248
|
+
function ze(e) {
|
|
252
249
|
return typeof e != "string" && e.type === "link";
|
|
253
250
|
}
|
|
254
251
|
function x(e) {
|
|
@@ -256,7 +253,7 @@ function x(e) {
|
|
|
256
253
|
}
|
|
257
254
|
//#endregion
|
|
258
255
|
//#region src/util/table.ts
|
|
259
|
-
function
|
|
256
|
+
function Be(e) {
|
|
260
257
|
return C(e) ? { ...e } : S(e) ? {
|
|
261
258
|
type: "tableCell",
|
|
262
259
|
content: [].concat(e.content),
|
|
@@ -298,23 +295,23 @@ var E = class extends Error {
|
|
|
298
295
|
super(`Unreachable case: ${e}`);
|
|
299
296
|
}
|
|
300
297
|
};
|
|
301
|
-
function
|
|
298
|
+
function Ve(e, t = !0) {
|
|
302
299
|
let { "data-test": n, ...r } = e;
|
|
303
300
|
if (Object.keys(r).length > 0 && t) throw Error("Object must be empty " + JSON.stringify(e));
|
|
304
301
|
}
|
|
305
302
|
//#endregion
|
|
306
303
|
//#region src/util/browser.ts
|
|
307
|
-
var
|
|
304
|
+
var He = () => typeof navigator < "u" && (/Mac/.test(navigator.platform) || /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent));
|
|
308
305
|
function D(e, t = "Ctrl") {
|
|
309
|
-
return
|
|
306
|
+
return He() ? e.replace("Mod", "⌘") : e.replace("Mod", t);
|
|
310
307
|
}
|
|
311
308
|
function O(...e) {
|
|
312
309
|
return [...new Set(e.filter((e) => e).join(" ").split(" "))].join(" ");
|
|
313
310
|
}
|
|
314
|
-
var
|
|
311
|
+
var Ue = () => /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
315
312
|
//#endregion
|
|
316
313
|
//#region src/blocks/defaultBlockHelpers.ts
|
|
317
|
-
function
|
|
314
|
+
function We(e, t, n, r) {
|
|
318
315
|
let i = document.createElement("div");
|
|
319
316
|
i.className = O("bn-block-content", n.class), i.setAttribute("data-content-type", e);
|
|
320
317
|
for (let [e, t] of Object.entries(n)) e !== "class" && i.setAttribute(e, t);
|
|
@@ -326,7 +323,7 @@ function Ke(e, t, n, r) {
|
|
|
326
323
|
contentDOM: a
|
|
327
324
|
};
|
|
328
325
|
}
|
|
329
|
-
var
|
|
326
|
+
var Ge = (e, t) => {
|
|
330
327
|
let n = H(e, t.pmSchema);
|
|
331
328
|
n.type.name === "blockContainer" && (n = n.firstChild);
|
|
332
329
|
let r = t.pmSchema.nodes[n.type.name].spec.toDOM;
|
|
@@ -335,7 +332,7 @@ var qe = (e, t) => {
|
|
|
335
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.");
|
|
336
333
|
return i;
|
|
337
334
|
};
|
|
338
|
-
function
|
|
335
|
+
function Ke(e, t = "<br>") {
|
|
339
336
|
let n = e.querySelectorAll("p");
|
|
340
337
|
if (n.length > 1) {
|
|
341
338
|
let e = n[0];
|
|
@@ -347,42 +344,44 @@ function Je(e, t = "<br>") {
|
|
|
347
344
|
}
|
|
348
345
|
//#endregion
|
|
349
346
|
//#region src/schema/nodeViewMutations.ts
|
|
350
|
-
function
|
|
351
|
-
return e.type === "selection" ? !1 : !t || e.type === "attributes"
|
|
347
|
+
function qe(e, t) {
|
|
348
|
+
return e.type === "selection" ? !1 : !t || e.type === "attributes" || !t.contains(e.target);
|
|
352
349
|
}
|
|
353
|
-
function
|
|
350
|
+
function Je(e) {
|
|
354
351
|
let t = e.ignoreMutation?.bind(e), n = e.contentDOM;
|
|
355
|
-
e.ignoreMutation = (e) =>
|
|
352
|
+
e.ignoreMutation = (e) => qe(e, n) ? !0 : t ? t(e) : !1;
|
|
356
353
|
}
|
|
357
354
|
//#endregion
|
|
358
355
|
//#region src/api/pmUtil.ts
|
|
359
356
|
function k(e) {
|
|
360
357
|
return "doc" in e ? e.doc.type.schema : e.type.schema;
|
|
361
358
|
}
|
|
362
|
-
function
|
|
359
|
+
function Ye(e) {
|
|
363
360
|
return e.cached.blockNoteEditor;
|
|
364
361
|
}
|
|
365
|
-
function
|
|
366
|
-
return
|
|
362
|
+
function Xe(e) {
|
|
363
|
+
return Ye(e).schema;
|
|
367
364
|
}
|
|
368
|
-
function
|
|
369
|
-
return
|
|
365
|
+
function Ze(e) {
|
|
366
|
+
return Xe(e).blockSchema;
|
|
370
367
|
}
|
|
371
|
-
function
|
|
372
|
-
return
|
|
368
|
+
function Qe(e) {
|
|
369
|
+
return Xe(e).inlineContentSchema;
|
|
373
370
|
}
|
|
374
371
|
function A(e) {
|
|
375
|
-
return
|
|
372
|
+
return Xe(e).styleSchema;
|
|
376
373
|
}
|
|
377
|
-
function
|
|
378
|
-
return
|
|
374
|
+
function $e(e) {
|
|
375
|
+
return Ye(e).blockCache;
|
|
379
376
|
}
|
|
380
|
-
function
|
|
381
|
-
|
|
377
|
+
function et(e, t) {
|
|
378
|
+
if (Ze(e)[t.name]?.content === "plain") return !0;
|
|
379
|
+
let n = Qe(e)[t.name];
|
|
380
|
+
return typeof n == "object" && n.content === "plain";
|
|
382
381
|
}
|
|
383
382
|
//#endregion
|
|
384
383
|
//#region src/api/nodeConversions/nodeToBlock.ts
|
|
385
|
-
function
|
|
384
|
+
function tt(e, t, n) {
|
|
386
385
|
let r = {
|
|
387
386
|
type: "tableContent",
|
|
388
387
|
columnWidths: [],
|
|
@@ -397,7 +396,7 @@ function rt(e, t, n) {
|
|
|
397
396
|
t ??= Array(e.attrs.colspan ?? 1).fill(void 0), r.columnWidths.push(...t);
|
|
398
397
|
}), s.cells = e.content.content.map((e, r) => (i[o] || (i[o] = []), i[o][r] = e.type.name === "tableHeader", {
|
|
399
398
|
type: "tableCell",
|
|
400
|
-
content: e.content.content.map((e) =>
|
|
399
|
+
content: e.content.content.map((e) => nt(e, t, n)).reduce((e, t) => {
|
|
401
400
|
if (!e.length) return t;
|
|
402
401
|
let n = e[e.length - 1], r = t[0];
|
|
403
402
|
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);
|
|
@@ -415,14 +414,15 @@ function rt(e, t, n) {
|
|
|
415
414
|
for (let e = 0; e < i[0]?.length; e++) i?.every((t) => t[e]) && (r.headerCols = (r.headerCols ?? 0) + 1);
|
|
416
415
|
return r;
|
|
417
416
|
}
|
|
418
|
-
function
|
|
417
|
+
function nt(e, t, n) {
|
|
419
418
|
let r = [], i;
|
|
420
419
|
return e.content.forEach((e) => {
|
|
421
420
|
if (e.type.name === "hardBreak") {
|
|
422
|
-
if (i)
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
421
|
+
if (i) {
|
|
422
|
+
if (x(i)) i.text += "\n";
|
|
423
|
+
else if (Re(i)) i.content[i.content.length - 1].text += "\n";
|
|
424
|
+
else throw Error("unexpected");
|
|
425
|
+
} else i = {
|
|
426
426
|
type: "text",
|
|
427
427
|
text: "\n",
|
|
428
428
|
styles: {}
|
|
@@ -434,7 +434,7 @@ function it(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(rt(e, t, n));
|
|
438
438
|
return;
|
|
439
439
|
}
|
|
440
440
|
let a = {}, o;
|
|
@@ -461,7 +461,7 @@ function it(e, t, n) {
|
|
|
461
461
|
type: "text",
|
|
462
462
|
text: e.textContent,
|
|
463
463
|
styles: a
|
|
464
|
-
}) :
|
|
464
|
+
}) : Re(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 it(e, t, n) {
|
|
|
492
492
|
};
|
|
493
493
|
}), i && r.push(i), r;
|
|
494
494
|
}
|
|
495
|
-
function
|
|
495
|
+
function rt(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,22 +500,22 @@ function at(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" ? nt(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
509
|
function j(e, t) {
|
|
510
|
-
let n = e.type.schema, r =
|
|
510
|
+
let n = e.type.schema, r = Ze(n), i = Qe(n), a = A(n), o = $e(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;
|
|
514
514
|
let c = y(e, 0), l;
|
|
515
515
|
try {
|
|
516
|
-
l =
|
|
516
|
+
l = ke(c.bnBlock.node, t);
|
|
517
517
|
} catch {
|
|
518
|
-
l =
|
|
518
|
+
l = Le.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);
|
|
@@ -525,7 +525,7 @@ function j(e, t) {
|
|
|
525
525
|
...c.isBlockContainer ? c.blockContent.node.attrs : {}
|
|
526
526
|
})) {
|
|
527
527
|
let e = u.propSchema;
|
|
528
|
-
t in e &&
|
|
528
|
+
t in e && (e[t].default !== void 0 || n !== void 0) && (d[t] = n);
|
|
529
529
|
}
|
|
530
530
|
let f = r[c.blockNoteType], p = [];
|
|
531
531
|
c.childContainer?.node.forEach((e) => {
|
|
@@ -534,10 +534,10 @@ function j(e, t) {
|
|
|
534
534
|
let m;
|
|
535
535
|
if (f.content === "inline") {
|
|
536
536
|
if (!c.isBlockContainer) throw Error("impossible");
|
|
537
|
-
m =
|
|
537
|
+
m = nt(c.blockContent.node, i, a);
|
|
538
538
|
} else if (f.content === "table") {
|
|
539
539
|
if (!c.isBlockContainer) throw Error("impossible");
|
|
540
|
-
m =
|
|
540
|
+
m = tt(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;
|
|
@@ -557,11 +557,11 @@ function j(e, t) {
|
|
|
557
557
|
};
|
|
558
558
|
return o?.set(e, h), h;
|
|
559
559
|
}
|
|
560
|
-
function
|
|
560
|
+
function it(e) {
|
|
561
561
|
let t = [];
|
|
562
562
|
return e.firstChild && e.firstChild.descendants((n) => (t.push(j(n, e)), !1)), t;
|
|
563
563
|
}
|
|
564
|
-
function
|
|
564
|
+
function at(e) {
|
|
565
565
|
function t(n, r, i) {
|
|
566
566
|
if (n.type.name !== "blockGroup") throw Error("unexpected");
|
|
567
567
|
let a = [], o, s;
|
|
@@ -604,11 +604,11 @@ function st(e) {
|
|
|
604
604
|
function M(e) {
|
|
605
605
|
return "data-" + e.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
606
606
|
}
|
|
607
|
-
function
|
|
607
|
+
function ot(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 st(e) {
|
|
612
612
|
let t = [
|
|
613
613
|
"mp4",
|
|
614
614
|
"webm",
|
|
@@ -629,7 +629,7 @@ function lt(e) {
|
|
|
629
629
|
}
|
|
630
630
|
//#endregion
|
|
631
631
|
//#region src/schema/blocks/internal.ts
|
|
632
|
-
function
|
|
632
|
+
function ct(e) {
|
|
633
633
|
let t = {};
|
|
634
634
|
return Object.entries(e).forEach(([e, n]) => {
|
|
635
635
|
t[e] = {
|
|
@@ -638,7 +638,7 @@ function ut(e) {
|
|
|
638
638
|
parseHTML: (t) => {
|
|
639
639
|
let r = t.getAttribute(M(e));
|
|
640
640
|
if (r === null) return null;
|
|
641
|
-
if (n.default === void 0 && n.type === "boolean" || n.default !== void 0 && typeof n.default == "boolean") return r === "true"
|
|
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") {
|
|
643
643
|
let e = parseFloat(r);
|
|
644
644
|
return !Number.isNaN(e) && Number.isFinite(e) ? e : null;
|
|
@@ -649,16 +649,16 @@ function ut(e) {
|
|
|
649
649
|
};
|
|
650
650
|
}), t;
|
|
651
651
|
}
|
|
652
|
-
function
|
|
652
|
+
function lt(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
657
|
return j(r, t);
|
|
658
658
|
}
|
|
659
|
-
function
|
|
659
|
+
function ut(e, t, n) {
|
|
660
660
|
try {
|
|
661
|
-
return
|
|
661
|
+
return lt(e, n);
|
|
662
662
|
} catch (e) {
|
|
663
663
|
let r = n.type.schema.nodes.blockContainer?.createAndFill(null, t);
|
|
664
664
|
if (r) return j(r, n);
|
|
@@ -675,7 +675,7 @@ function N(e, t, n, r, i = !1, a) {
|
|
|
675
675
|
dom: o
|
|
676
676
|
};
|
|
677
677
|
}
|
|
678
|
-
function
|
|
678
|
+
function dt(e, t, n) {
|
|
679
679
|
return {
|
|
680
680
|
config: {
|
|
681
681
|
type: e.type,
|
|
@@ -684,20 +684,20 @@ function pt(e, t, n) {
|
|
|
684
684
|
},
|
|
685
685
|
implementation: {
|
|
686
686
|
node: e.node,
|
|
687
|
-
render:
|
|
688
|
-
toExternalHTML:
|
|
687
|
+
render: Ge,
|
|
688
|
+
toExternalHTML: Ge
|
|
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 ft(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 pt(e, t) {
|
|
701
701
|
let n = [{
|
|
702
702
|
tag: "[data-content-type=" + e.type + "]",
|
|
703
703
|
contentElement: ".bn-inline-content"
|
|
@@ -707,7 +707,7 @@ function ht(e, t) {
|
|
|
707
707
|
getAttrs(e) {
|
|
708
708
|
if (typeof e == "string") return !1;
|
|
709
709
|
let n = t.parse?.(e);
|
|
710
|
-
return n
|
|
710
|
+
return n !== void 0 && n;
|
|
711
711
|
},
|
|
712
712
|
preserveWhitespace: !0,
|
|
713
713
|
getContent: e.content === "inline" || e.content === "none" || e.content === "plain" ? (n, r) => {
|
|
@@ -720,7 +720,7 @@ function ht(e, t) {
|
|
|
720
720
|
}
|
|
721
721
|
if (e.content === "inline" || e.content === "plain") {
|
|
722
722
|
let i = n.cloneNode(!0);
|
|
723
|
-
|
|
723
|
+
Ke(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,12 +741,12 @@ function ht(e, t) {
|
|
|
741
741
|
} : void 0
|
|
742
742
|
}), n;
|
|
743
743
|
}
|
|
744
|
-
function
|
|
744
|
+
function mt(e, n, r, i) {
|
|
745
745
|
let a = n.node || u.create({
|
|
746
|
-
name:
|
|
747
|
-
content:
|
|
746
|
+
name: e.type,
|
|
747
|
+
content: e.content === "inline" ? "inline*" : e.content === "plain" ? "text*" : e.content === "none" ? "" : e.content,
|
|
748
748
|
marks() {
|
|
749
|
-
return
|
|
749
|
+
return e.content === "plain" ? t(this.editor) : void 0;
|
|
750
750
|
},
|
|
751
751
|
group: "blockContent",
|
|
752
752
|
selectable: n.meta?.selectable ?? !0,
|
|
@@ -755,56 +755,56 @@ function gt(t, n, r, i) {
|
|
|
755
755
|
defining: n.meta?.defining ?? !0,
|
|
756
756
|
priority: i,
|
|
757
757
|
addAttributes() {
|
|
758
|
-
return
|
|
758
|
+
return ct(e.propSchema);
|
|
759
759
|
},
|
|
760
760
|
parseHTML() {
|
|
761
|
-
return
|
|
761
|
+
return pt(e, n);
|
|
762
762
|
},
|
|
763
|
-
renderHTML({ HTMLAttributes:
|
|
763
|
+
renderHTML({ HTMLAttributes: t }) {
|
|
764
764
|
let r = document.createElement("div");
|
|
765
765
|
return N({
|
|
766
766
|
dom: r,
|
|
767
|
-
contentDOM:
|
|
768
|
-
},
|
|
767
|
+
contentDOM: e.content === "inline" || e.content === "plain" ? r : void 0
|
|
768
|
+
}, e.type, {}, e.propSchema, n.meta?.fileBlockAccept !== void 0, t);
|
|
769
769
|
},
|
|
770
770
|
addNodeView() {
|
|
771
|
-
return (
|
|
772
|
-
let r = this.options.editor, i =
|
|
771
|
+
return (t) => {
|
|
772
|
+
let r = this.options.editor, i = ut(t.getPos, t.node, t.view.state.doc), a = this.options.domAttributes?.blockContent || {}, o = n.render.call({
|
|
773
773
|
blockContentDOMAttributes: a,
|
|
774
|
-
props:
|
|
774
|
+
props: t,
|
|
775
775
|
renderType: "nodeView",
|
|
776
|
-
propSchema:
|
|
776
|
+
propSchema: e.propSchema
|
|
777
777
|
}, i, r);
|
|
778
|
-
return n.meta?.selectable === !1 &&
|
|
778
|
+
return n.meta?.selectable === !1 && ft(o, this.editor), Je(o), o;
|
|
779
779
|
};
|
|
780
780
|
}
|
|
781
781
|
});
|
|
782
|
-
if (a.name !==
|
|
782
|
+
if (a.name !== e.type) throw Error("Node name does not match block type. This is a bug in BlockNote.");
|
|
783
783
|
return {
|
|
784
|
-
config:
|
|
784
|
+
config: e,
|
|
785
785
|
implementation: {
|
|
786
786
|
...n,
|
|
787
787
|
node: a,
|
|
788
|
-
render(
|
|
788
|
+
render(t, r) {
|
|
789
789
|
let i = a.options.domAttributes?.blockContent || {};
|
|
790
790
|
return n.render.call({
|
|
791
791
|
blockContentDOMAttributes: i,
|
|
792
792
|
props: void 0,
|
|
793
793
|
renderType: "dom",
|
|
794
|
-
propSchema:
|
|
795
|
-
},
|
|
794
|
+
propSchema: e.propSchema
|
|
795
|
+
}, t, r);
|
|
796
796
|
},
|
|
797
|
-
toExternalHTML: (
|
|
797
|
+
toExternalHTML: (t, r, i) => {
|
|
798
798
|
let o = a.options.domAttributes?.blockContent || {};
|
|
799
799
|
return n.toExternalHTML?.call({
|
|
800
800
|
blockContentDOMAttributes: o,
|
|
801
|
-
propSchema:
|
|
802
|
-
},
|
|
801
|
+
propSchema: e.propSchema
|
|
802
|
+
}, t, r, i) ?? n.render.call({
|
|
803
803
|
blockContentDOMAttributes: o,
|
|
804
804
|
renderType: "dom",
|
|
805
805
|
props: void 0,
|
|
806
|
-
propSchema:
|
|
807
|
-
},
|
|
806
|
+
propSchema: e.propSchema
|
|
807
|
+
}, t, r);
|
|
808
808
|
}
|
|
809
809
|
},
|
|
810
810
|
extensions: r
|
|
@@ -838,37 +838,38 @@ function F(e, t, n) {
|
|
|
838
838
|
}
|
|
839
839
|
//#endregion
|
|
840
840
|
//#region src/schema/inlineContent/internal.ts
|
|
841
|
-
function
|
|
841
|
+
function ht(e, t, n, r) {
|
|
842
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;
|
|
843
843
|
}
|
|
844
|
-
function
|
|
844
|
+
function gt(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 _t(e, t, n) {
|
|
851
851
|
return {
|
|
852
852
|
config: e,
|
|
853
|
-
implementation: t
|
|
853
|
+
implementation: t,
|
|
854
|
+
extensions: n
|
|
854
855
|
};
|
|
855
856
|
}
|
|
856
|
-
function
|
|
857
|
-
return
|
|
857
|
+
function vt(e, t, n) {
|
|
858
|
+
return _t({
|
|
858
859
|
type: e.name,
|
|
859
860
|
propSchema: t,
|
|
860
|
-
content: e.config.content === "inline*" ? "styled" : "none"
|
|
861
|
+
content: e.config.content === "inline*" ? "styled" : e.config.content === "text*" ? "plain" : "none"
|
|
861
862
|
}, {
|
|
862
863
|
...n,
|
|
863
864
|
node: e
|
|
864
865
|
});
|
|
865
866
|
}
|
|
866
|
-
function
|
|
867
|
+
function yt(e) {
|
|
867
868
|
return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, t.config]));
|
|
868
869
|
}
|
|
869
870
|
//#endregion
|
|
870
871
|
//#region src/schema/styles/internal.ts
|
|
871
|
-
function
|
|
872
|
+
function bt(e) {
|
|
872
873
|
return e === "boolean" ? {} : { stringValue: {
|
|
873
874
|
default: void 0,
|
|
874
875
|
keepOnSplit: !0,
|
|
@@ -879,14 +880,14 @@ function St(e) {
|
|
|
879
880
|
function I(e, t, n, r) {
|
|
880
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;
|
|
881
882
|
}
|
|
882
|
-
function
|
|
883
|
+
function xt(e, t) {
|
|
883
884
|
return {
|
|
884
885
|
config: e,
|
|
885
886
|
implementation: t
|
|
886
887
|
};
|
|
887
888
|
}
|
|
888
889
|
function L(e, t) {
|
|
889
|
-
return
|
|
890
|
+
return xt({
|
|
890
891
|
type: e.name,
|
|
891
892
|
propSchema: t
|
|
892
893
|
}, {
|
|
@@ -907,12 +908,12 @@ function L(e, t) {
|
|
|
907
908
|
}
|
|
908
909
|
});
|
|
909
910
|
}
|
|
910
|
-
function
|
|
911
|
+
function St(e) {
|
|
911
912
|
return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, t.config]));
|
|
912
913
|
}
|
|
913
914
|
//#endregion
|
|
914
915
|
//#region src/schema/styles/createSpec.ts
|
|
915
|
-
function
|
|
916
|
+
function Ct(e, t) {
|
|
916
917
|
let n = [{
|
|
917
918
|
tag: `[data-style-type="${e.type}"]`,
|
|
918
919
|
contentElement: (e) => {
|
|
@@ -926,18 +927,18 @@ function Tt(e, t) {
|
|
|
926
927
|
getAttrs(e) {
|
|
927
928
|
if (typeof e == "string") return !1;
|
|
928
929
|
let n = t?.(e);
|
|
929
|
-
return n
|
|
930
|
+
return n !== void 0 && { stringValue: n };
|
|
930
931
|
}
|
|
931
932
|
}), n;
|
|
932
933
|
}
|
|
933
|
-
function
|
|
934
|
+
function wt(e, t) {
|
|
934
935
|
let n = l.create({
|
|
935
936
|
name: e.type,
|
|
936
937
|
addAttributes() {
|
|
937
|
-
return
|
|
938
|
+
return bt(e.propSchema);
|
|
938
939
|
},
|
|
939
940
|
parseHTML() {
|
|
940
|
-
return
|
|
941
|
+
return Ct(e, t.parse);
|
|
941
942
|
},
|
|
942
943
|
renderHTML({ mark: n }) {
|
|
943
944
|
return I((t.toExternalHTML || t.render)(n.attrs.stringValue), e.type, n.attrs.stringValue, e.propSchema);
|
|
@@ -946,7 +947,7 @@ function Et(e, t) {
|
|
|
946
947
|
return ({ mark: n }) => I(t.render(n.attrs.stringValue), e.type, n.attrs.stringValue, e.propSchema);
|
|
947
948
|
}
|
|
948
949
|
});
|
|
949
|
-
return
|
|
950
|
+
return xt(e, {
|
|
950
951
|
...t,
|
|
951
952
|
mark: n,
|
|
952
953
|
render: (n) => I(t.render(n), e.type, n, e.propSchema),
|
|
@@ -955,8 +956,8 @@ function Et(e, t) {
|
|
|
955
956
|
}
|
|
956
957
|
//#endregion
|
|
957
958
|
//#region src/util/topo-sort.ts
|
|
958
|
-
function
|
|
959
|
-
let t =
|
|
959
|
+
function Tt(e) {
|
|
960
|
+
let t = Dt(e), { roots: n, nonRoots: r } = Ot(t), i = [];
|
|
960
961
|
for (; n.size;) {
|
|
961
962
|
i.push(n);
|
|
962
963
|
let r = /* @__PURE__ */ new Set();
|
|
@@ -971,13 +972,13 @@ function Dt(e) {
|
|
|
971
972
|
}
|
|
972
973
|
n = r;
|
|
973
974
|
}
|
|
974
|
-
if (r =
|
|
975
|
+
if (r = Ot(t).nonRoots, r.size) throw Error(`Cycle(s) detected; toposort only works on acyclic graphs. Cyclic nodes: ${Array.from(r).join(", ")}`);
|
|
975
976
|
return i;
|
|
976
977
|
}
|
|
977
|
-
function
|
|
978
|
-
return
|
|
978
|
+
function Et(e) {
|
|
979
|
+
return Tt(kt(e));
|
|
979
980
|
}
|
|
980
|
-
function
|
|
981
|
+
function Dt(e) {
|
|
981
982
|
let t = /* @__PURE__ */ new Map();
|
|
982
983
|
for (let [n, r] of e.entries()) {
|
|
983
984
|
t.has(n) || t.set(n, 0);
|
|
@@ -988,7 +989,7 @@ function kt(e) {
|
|
|
988
989
|
}
|
|
989
990
|
return t;
|
|
990
991
|
}
|
|
991
|
-
function
|
|
992
|
+
function Ot(e) {
|
|
992
993
|
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
993
994
|
for (let [r, i] of e.entries()) i === 0 ? t.add(r) : n.add(r);
|
|
994
995
|
return {
|
|
@@ -996,7 +997,7 @@ function At(e) {
|
|
|
996
997
|
nonRoots: n
|
|
997
998
|
};
|
|
998
999
|
}
|
|
999
|
-
function
|
|
1000
|
+
function kt(e) {
|
|
1000
1001
|
let t = /* @__PURE__ */ new Map();
|
|
1001
1002
|
for (let [n, r] of e.entries()) {
|
|
1002
1003
|
t.has(n) || t.set(n, /* @__PURE__ */ new Set());
|
|
@@ -1004,26 +1005,26 @@ function jt(e) {
|
|
|
1004
1005
|
}
|
|
1005
1006
|
return t;
|
|
1006
1007
|
}
|
|
1007
|
-
function
|
|
1008
|
+
function At() {
|
|
1008
1009
|
return /* @__PURE__ */ new Map();
|
|
1009
1010
|
}
|
|
1010
|
-
function
|
|
1011
|
+
function jt(e, t, n) {
|
|
1011
1012
|
return e.has(t) || e.set(t, /* @__PURE__ */ new Set()), e.get(t).add(n), e;
|
|
1012
1013
|
}
|
|
1013
|
-
function
|
|
1014
|
-
let t =
|
|
1014
|
+
function Mt(e) {
|
|
1015
|
+
let t = At();
|
|
1015
1016
|
for (let n of e) Array.isArray(n.runsBefore) && n.runsBefore.length > 0 ? n.runsBefore.forEach((e) => {
|
|
1016
|
-
|
|
1017
|
-
}) :
|
|
1018
|
-
let n =
|
|
1017
|
+
jt(t, n.key, e);
|
|
1018
|
+
}) : jt(t, "default", n.key);
|
|
1019
|
+
let n = Et(t), r = n.findIndex((e) => e.has("default"));
|
|
1019
1020
|
return (e) => 91 + (n.findIndex((t) => t.has(e)) + r) * 10;
|
|
1020
1021
|
}
|
|
1021
1022
|
//#endregion
|
|
1022
1023
|
//#region src/schema/schema.ts
|
|
1023
|
-
function
|
|
1024
|
+
function Nt(e) {
|
|
1024
1025
|
return e && Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0));
|
|
1025
1026
|
}
|
|
1026
|
-
var
|
|
1027
|
+
var Pt = class {
|
|
1027
1028
|
opts;
|
|
1028
1029
|
BlockNoteEditor = "only for types";
|
|
1029
1030
|
Block = "only for types";
|
|
@@ -1040,14 +1041,14 @@ var It = class {
|
|
|
1040
1041
|
this.blockSpecs = t, this.styleSpecs = r, this.styleSchema = o, this.inlineContentSpecs = n, this.blockSchema = i, this.inlineContentSchema = a;
|
|
1041
1042
|
}
|
|
1042
1043
|
init() {
|
|
1043
|
-
let e =
|
|
1044
|
+
let e = Mt(Object.entries({
|
|
1044
1045
|
...this.opts.blockSpecs,
|
|
1045
1046
|
...this.opts.inlineContentSpecs,
|
|
1046
1047
|
...this.opts.styleSpecs
|
|
1047
1048
|
}).map(([e, t]) => ({
|
|
1048
1049
|
key: e,
|
|
1049
1050
|
runsBefore: t.implementation?.runsBefore ?? []
|
|
1050
|
-
}))), 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, mt(n.config, n.implementation, n.extensions, e(t))])), n = Object.fromEntries(Object.entries(this.opts.inlineContentSpecs).map(([t, n]) => typeof n.config == "object" ? [t, {
|
|
1051
1052
|
...n,
|
|
1052
1053
|
implementation: {
|
|
1053
1054
|
...n.implementation,
|
|
@@ -1063,10 +1064,10 @@ var It = class {
|
|
|
1063
1064
|
return {
|
|
1064
1065
|
blockSpecs: t,
|
|
1065
1066
|
blockSchema: Object.fromEntries(Object.entries(t).map(([e, t]) => [e, t.config])),
|
|
1066
|
-
inlineContentSpecs:
|
|
1067
|
-
styleSpecs:
|
|
1068
|
-
inlineContentSchema:
|
|
1069
|
-
styleSchema:
|
|
1067
|
+
inlineContentSpecs: Nt(n),
|
|
1068
|
+
styleSpecs: Nt(r),
|
|
1069
|
+
inlineContentSchema: yt(n),
|
|
1070
|
+
styleSchema: St(r)
|
|
1070
1071
|
};
|
|
1071
1072
|
}
|
|
1072
1073
|
extend(e) {
|
|
@@ -1078,7 +1079,7 @@ var It = class {
|
|
|
1078
1079
|
//#endregion
|
|
1079
1080
|
//#region src/api/blockManipulation/tables/tables.ts
|
|
1080
1081
|
function R(e) {
|
|
1081
|
-
let { height: t, width: n } =
|
|
1082
|
+
let { height: t, width: n } = Ft(e), r = Array(t).fill(!1).map(() => Array(n).fill(null)), i = (e, i) => {
|
|
1082
1083
|
for (let a = e; a < t; a++) for (let e = i; e < n; e++) if (!r[a][e]) return {
|
|
1083
1084
|
row: a,
|
|
1084
1085
|
col: e
|
|
@@ -1086,7 +1087,7 @@ function R(e) {
|
|
|
1086
1087
|
throw Error("Unable to create occupancy grid for table, no more available cells");
|
|
1087
1088
|
};
|
|
1088
1089
|
for (let t = 0; t < e.content.rows.length; t++) for (let n = 0; n < e.content.rows[t].cells.length; n++) {
|
|
1089
|
-
let a =
|
|
1090
|
+
let a = Be(e.content.rows[t].cells[n]), o = T(a), s = w(a), { row: c, col: l } = i(t, n);
|
|
1090
1091
|
for (let e = c; e < c + o; e++) for (let i = l; i < l + s; i++) {
|
|
1091
1092
|
if (r[e][i]) throw Error(`Unable to create occupancy grid for table, cell at ${e},${i} is already occupied`);
|
|
1092
1093
|
r[e][i] = {
|
|
@@ -1102,7 +1103,7 @@ function R(e) {
|
|
|
1102
1103
|
}
|
|
1103
1104
|
function z(e) {
|
|
1104
1105
|
let t = /* @__PURE__ */ new Set();
|
|
1105
|
-
return e.map((e) => ({ cells: e.map((e) => t.has(e.row + ":" + e.col)
|
|
1106
|
+
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) }));
|
|
1106
1107
|
}
|
|
1107
1108
|
function B(e, t, n = R(t)) {
|
|
1108
1109
|
for (let t = 0; t < n.length; t++) for (let r = 0; r < n[t].length; r++) {
|
|
@@ -1115,7 +1116,7 @@ function B(e, t, n = R(t)) {
|
|
|
1115
1116
|
}
|
|
1116
1117
|
throw Error(`Unable to resolve relative table cell indices for table, cell at ${e.row},${e.col} is not occupied`);
|
|
1117
1118
|
}
|
|
1118
|
-
function
|
|
1119
|
+
function Ft(e) {
|
|
1119
1120
|
let t = e.content.rows.length, n = 0;
|
|
1120
1121
|
return e.content.rows.forEach((e) => {
|
|
1121
1122
|
let t = 0;
|
|
@@ -1127,7 +1128,7 @@ function Lt(e) {
|
|
|
1127
1128
|
width: n
|
|
1128
1129
|
};
|
|
1129
1130
|
}
|
|
1130
|
-
function
|
|
1131
|
+
function It(e, t, n = R(t)) {
|
|
1131
1132
|
let r = n[e.row]?.[e.col];
|
|
1132
1133
|
if (r) return {
|
|
1133
1134
|
row: r.row,
|
|
@@ -1135,7 +1136,7 @@ function Rt(e, t, n = R(t)) {
|
|
|
1135
1136
|
cell: r.cell
|
|
1136
1137
|
};
|
|
1137
1138
|
}
|
|
1138
|
-
function
|
|
1139
|
+
function Lt(e, t) {
|
|
1139
1140
|
let n = R(e);
|
|
1140
1141
|
if (t < 0 || t >= n.length) return [];
|
|
1141
1142
|
let r = 0;
|
|
@@ -1144,13 +1145,13 @@ function zt(e, t) {
|
|
|
1144
1145
|
if (!e) return [];
|
|
1145
1146
|
r += e.rowspan;
|
|
1146
1147
|
}
|
|
1147
|
-
let i = Array(n[0].length).fill(!1).map((t, i) =>
|
|
1148
|
+
let i = Array(n[0].length).fill(!1).map((t, i) => It({
|
|
1148
1149
|
row: r,
|
|
1149
1150
|
col: i
|
|
1150
1151
|
}, e, n)).filter((e) => e !== void 0);
|
|
1151
1152
|
return i.filter((e, t) => i.findIndex((t) => t.row === e.row && t.col === e.col) === t);
|
|
1152
1153
|
}
|
|
1153
|
-
function
|
|
1154
|
+
function Rt(e, t) {
|
|
1154
1155
|
let n = R(e);
|
|
1155
1156
|
if (t < 0 || t >= n[0].length) return [];
|
|
1156
1157
|
let r = 0;
|
|
@@ -1159,13 +1160,13 @@ function Bt(e, t) {
|
|
|
1159
1160
|
if (!e) return [];
|
|
1160
1161
|
r += e.colspan;
|
|
1161
1162
|
}
|
|
1162
|
-
let i = Array(n.length).fill(!1).map((t, i) =>
|
|
1163
|
+
let i = Array(n.length).fill(!1).map((t, i) => It({
|
|
1163
1164
|
row: i,
|
|
1164
1165
|
col: r
|
|
1165
1166
|
}, e, n)).filter((e) => e !== void 0);
|
|
1166
1167
|
return i.filter((e, t) => i.findIndex((t) => t.row === e.row && t.col === e.col) === t);
|
|
1167
1168
|
}
|
|
1168
|
-
function
|
|
1169
|
+
function zt(e, t, n, r = R(e)) {
|
|
1169
1170
|
let { col: i } = B({
|
|
1170
1171
|
row: 0,
|
|
1171
1172
|
col: t
|
|
@@ -1178,7 +1179,7 @@ function Vt(e, t, n, r = R(e)) {
|
|
|
1178
1179
|
e.splice(a, 0, t);
|
|
1179
1180
|
}), z(r);
|
|
1180
1181
|
}
|
|
1181
|
-
function
|
|
1182
|
+
function Bt(e, t, n, r = R(e)) {
|
|
1182
1183
|
let { row: i } = B({
|
|
1183
1184
|
row: t,
|
|
1184
1185
|
col: 0
|
|
@@ -1188,13 +1189,13 @@ function Ht(e, t, n, r = R(e)) {
|
|
|
1188
1189
|
}, e, r), [o] = r.splice(i, 1);
|
|
1189
1190
|
return r.splice(a, 0, o), z(r);
|
|
1190
1191
|
}
|
|
1191
|
-
function
|
|
1192
|
-
return e ? S(e) ?
|
|
1192
|
+
function Vt(e) {
|
|
1193
|
+
return e ? S(e) ? Vt(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 : ze(e) ? typeof e.content == "string" ? e.content.length === 0 : e.content.every((e) => e.text.length === 0) : !1) : !1 : !0;
|
|
1193
1194
|
}
|
|
1194
|
-
function
|
|
1195
|
+
function Ht(e, t, n = R(e)) {
|
|
1195
1196
|
if (t === "columns") {
|
|
1196
1197
|
let e = 0;
|
|
1197
|
-
for (let t = n[0].length - 1; t >= 0 && n.every((e) =>
|
|
1198
|
+
for (let t = n[0].length - 1; t >= 0 && n.every((e) => Vt(e[t].cell) && e[t].colspan === 1); t--) e++;
|
|
1198
1199
|
for (let t = n.length - 1; t >= 0; t--) {
|
|
1199
1200
|
let r = Math.max(n[t].length - e, 1);
|
|
1200
1201
|
n[t] = n[t].slice(0, r);
|
|
@@ -1202,19 +1203,19 @@ function Wt(e, t, n = R(e)) {
|
|
|
1202
1203
|
return z(n);
|
|
1203
1204
|
}
|
|
1204
1205
|
let r = 0;
|
|
1205
|
-
for (let e = n.length - 1; e >= 0 && n[e].every((e) =>
|
|
1206
|
+
for (let e = n.length - 1; e >= 0 && n[e].every((e) => Vt(e.cell) && e.rowspan === 1); e--) r++;
|
|
1206
1207
|
let i = Math.min(r, n.length - 1);
|
|
1207
1208
|
return n.splice(n.length - i, i), z(n);
|
|
1208
1209
|
}
|
|
1209
|
-
function
|
|
1210
|
-
let { width: i, height: a } =
|
|
1210
|
+
function Ut(e, t, n, r = R(e)) {
|
|
1211
|
+
let { width: i, height: a } = Ft(e);
|
|
1211
1212
|
if (t === "columns") r.forEach((e, t) => {
|
|
1212
1213
|
if (n >= 0) for (let r = 0; r < n; r++) e.push({
|
|
1213
1214
|
row: t,
|
|
1214
1215
|
col: Math.max(...e.map((e) => e.col)) + 1,
|
|
1215
1216
|
rowspan: 1,
|
|
1216
1217
|
colspan: 1,
|
|
1217
|
-
cell:
|
|
1218
|
+
cell: Be("")
|
|
1218
1219
|
});
|
|
1219
1220
|
else e.splice(i + n, -1 * n);
|
|
1220
1221
|
});
|
|
@@ -1224,15 +1225,15 @@ function Gt(e, t, n, r = R(e)) {
|
|
|
1224
1225
|
col: n,
|
|
1225
1226
|
rowspan: 1,
|
|
1226
1227
|
colspan: 1,
|
|
1227
|
-
cell:
|
|
1228
|
+
cell: Be("")
|
|
1228
1229
|
}));
|
|
1229
1230
|
r.push(t);
|
|
1230
1231
|
}
|
|
1231
1232
|
else n < 0 && r.splice(a + n, -1 * n);
|
|
1232
1233
|
return z(r);
|
|
1233
1234
|
}
|
|
1234
|
-
function
|
|
1235
|
-
let r =
|
|
1235
|
+
function Wt(e, t, n) {
|
|
1236
|
+
let r = Lt(e, n);
|
|
1236
1237
|
if (!r.some((e) => T(e.cell) > 1)) return !0;
|
|
1237
1238
|
let i = n, a = n;
|
|
1238
1239
|
return r.forEach((e) => {
|
|
@@ -1240,8 +1241,8 @@ function Kt(e, t, n) {
|
|
|
1240
1241
|
i = Math.max(i, e.row + t - 1), a = Math.min(a, e.row);
|
|
1241
1242
|
}), t < n ? n === i : n === a;
|
|
1242
1243
|
}
|
|
1243
|
-
function
|
|
1244
|
-
let r =
|
|
1244
|
+
function Gt(e, t, n) {
|
|
1245
|
+
let r = Rt(e, n);
|
|
1245
1246
|
if (!r.some((e) => w(e.cell) > 1)) return !0;
|
|
1246
1247
|
let i = n, a = n;
|
|
1247
1248
|
return r.forEach((e) => {
|
|
@@ -1249,13 +1250,13 @@ function qt(e, t, n) {
|
|
|
1249
1250
|
i = Math.max(i, e.col + t - 1), a = Math.min(a, e.col);
|
|
1250
1251
|
}), t < n ? n === i : n === a;
|
|
1251
1252
|
}
|
|
1252
|
-
function
|
|
1253
|
+
function Kt(e, t, n) {
|
|
1253
1254
|
let r = B(e, n), i = B(t, n);
|
|
1254
1255
|
return r.col === i.col;
|
|
1255
1256
|
}
|
|
1256
1257
|
//#endregion
|
|
1257
1258
|
//#region src/api/nodeConversions/blockToNode.ts
|
|
1258
|
-
function
|
|
1259
|
+
function qt(e, t, n, r) {
|
|
1259
1260
|
let i = [];
|
|
1260
1261
|
for (let [r, a] of Object.entries(e.styles || {})) {
|
|
1261
1262
|
let e = n[r];
|
|
@@ -1264,33 +1265,33 @@ function Yt(e, t, n, r) {
|
|
|
1264
1265
|
else if (e.propSchema === "string") a && i.push(t.mark(r, { stringValue: a }));
|
|
1265
1266
|
else throw new E(e.propSchema);
|
|
1266
1267
|
}
|
|
1267
|
-
let a = r && t.nodes[r] &&
|
|
1268
|
-
return !r || !t.nodes[r]
|
|
1268
|
+
let a = r && t.nodes[r] && et(t, t.nodes[r]) ? [...t.nodes[r].allowedMarks(i)] : i;
|
|
1269
|
+
return !r || !et(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)] : [];
|
|
1269
1270
|
}
|
|
1270
|
-
function
|
|
1271
|
+
function Jt(e, t, n) {
|
|
1271
1272
|
let r = t.marks.link.create({ href: e.href });
|
|
1272
|
-
return
|
|
1273
|
+
return Yt(e.content, t, n).map((e) => {
|
|
1273
1274
|
if (e.type.name === "text") return e.mark([...e.marks, r]);
|
|
1274
1275
|
if (e.type.name === "hardBreak") return e;
|
|
1275
1276
|
throw Error("unexpected node type");
|
|
1276
1277
|
});
|
|
1277
1278
|
}
|
|
1278
|
-
function
|
|
1279
|
+
function Yt(e, t, n, r) {
|
|
1279
1280
|
let i = [];
|
|
1280
|
-
if (typeof e == "string") return i.push(...
|
|
1281
|
+
if (typeof e == "string") return i.push(...qt({
|
|
1281
1282
|
type: "text",
|
|
1282
1283
|
text: e,
|
|
1283
1284
|
styles: {}
|
|
1284
1285
|
}, t, n, r)), i;
|
|
1285
|
-
for (let a of e) i.push(...
|
|
1286
|
+
for (let a of e) i.push(...qt(a, t, n, r));
|
|
1286
1287
|
return i;
|
|
1287
1288
|
}
|
|
1288
1289
|
function V(e, t, n, r = A(t)) {
|
|
1289
1290
|
let i = [];
|
|
1290
|
-
for (let a of e) typeof a == "string" ? i.push(...
|
|
1291
|
+
for (let a of e) typeof a == "string" ? i.push(...Yt(a, t, r, n)) : ze(a) ? i.push(...Jt(a, t, r)) : x(a) ? i.push(...Yt([a], t, r, n)) : i.push(Zt(a, t, r));
|
|
1291
1292
|
return i;
|
|
1292
1293
|
}
|
|
1293
|
-
function
|
|
1294
|
+
function Xt(e, t, n = A(t)) {
|
|
1294
1295
|
let r = [], i = Array(e.headerRows ?? 0).fill(!0), a = Array(e.headerCols ?? 0).fill(!0), o = e.columnWidths ?? [];
|
|
1295
1296
|
for (let s = 0; s < e.rows.length; s++) {
|
|
1296
1297
|
let c = e.rows[s], l = [], u = i[s];
|
|
@@ -1302,12 +1303,14 @@ function Qt(e, t, n = A(t)) {
|
|
|
1302
1303
|
type: "table",
|
|
1303
1304
|
content: e
|
|
1304
1305
|
}), m = o[p.col] ? [o[p.col]] : null;
|
|
1305
|
-
if (i)
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1306
|
+
if (i) {
|
|
1307
|
+
if (typeof i == "string") f = t.text(i);
|
|
1308
|
+
else if (S(i)) {
|
|
1309
|
+
i.content && (f = V(i.content, t, "tableParagraph", n));
|
|
1310
|
+
let e = w(i);
|
|
1311
|
+
e > 1 && (m = Array(e).fill(!1).map((e, t) => o[p.col + t] ?? void 0));
|
|
1312
|
+
} else f = V(i, t, "tableParagraph", n);
|
|
1313
|
+
}
|
|
1311
1314
|
let h = t.nodes[d || u ? "tableHeader" : "tableCell"].createChecked({
|
|
1312
1315
|
...S(i) ? i.props : {},
|
|
1313
1316
|
colwidth: m
|
|
@@ -1319,7 +1322,7 @@ function Qt(e, t, n = A(t)) {
|
|
|
1319
1322
|
}
|
|
1320
1323
|
return r;
|
|
1321
1324
|
}
|
|
1322
|
-
function
|
|
1325
|
+
function Zt(e, t, n) {
|
|
1323
1326
|
let r, i = e.type;
|
|
1324
1327
|
if (i === void 0 && (i = "paragraph"), !t.nodes[i]) throw Error(`node type ${i} not found in schema`);
|
|
1325
1328
|
if (!e.content) r = t.nodes[i].createChecked(e.props);
|
|
@@ -1330,53 +1333,54 @@ function $t(e, t, n) {
|
|
|
1330
1333
|
let a = V(e.content, t, i, n);
|
|
1331
1334
|
r = t.nodes[i].createChecked(e.props, a);
|
|
1332
1335
|
} else if (e.content.type === "tableContent") {
|
|
1333
|
-
let a =
|
|
1336
|
+
let a = Xt(e.content, t, n);
|
|
1334
1337
|
r = t.nodes[i].createChecked(e.props, a);
|
|
1335
1338
|
} else throw new E(e.content.type);
|
|
1336
1339
|
return r;
|
|
1337
1340
|
}
|
|
1338
1341
|
function H(e, t, n = A(t)) {
|
|
1339
1342
|
let r = e.id;
|
|
1340
|
-
r === void 0 && (r =
|
|
1343
|
+
r === void 0 && (r = Le.options.generateID());
|
|
1341
1344
|
let i = [];
|
|
1342
1345
|
if (e.children) for (let r of e.children) i.push(H(r, t, n));
|
|
1343
1346
|
if (!e.type || t.nodes[e.type].isInGroup("blockContent")) {
|
|
1344
|
-
let a =
|
|
1347
|
+
let a = Zt(e, t, n), o = i.length > 0 ? t.nodes.blockGroup.createChecked({}, i) : void 0;
|
|
1345
1348
|
return t.nodes.blockContainer.createChecked({
|
|
1346
1349
|
id: r,
|
|
1347
1350
|
...e.props
|
|
1348
1351
|
}, o ? [a, o] : a);
|
|
1349
|
-
}
|
|
1352
|
+
}
|
|
1353
|
+
if (t.nodes[e.type].isInGroup("bnBlock")) return t.nodes[e.type].create({
|
|
1350
1354
|
id: r,
|
|
1351
1355
|
...e.props
|
|
1352
1356
|
}, i);
|
|
1353
|
-
|
|
1357
|
+
throw Error(`block type ${e.type} doesn't match blockContent or bnBlock group`);
|
|
1354
1358
|
}
|
|
1355
1359
|
//#endregion
|
|
1356
1360
|
//#region src/api/nodeUtil.ts
|
|
1357
|
-
function
|
|
1361
|
+
function Qt(e, t) {
|
|
1358
1362
|
let n, r;
|
|
1359
|
-
if (t.firstChild.descendants((i, a) => n ? !1 :
|
|
1363
|
+
if (t.firstChild.descendants((i, a) => n ? !1 : !$t(i) || !i.attrs.id || ke(i, t) !== e || (n = i, r = a + 1, !1)), n !== void 0 && r !== void 0) return {
|
|
1360
1364
|
node: n,
|
|
1361
1365
|
posBeforeNode: r
|
|
1362
1366
|
};
|
|
1363
1367
|
}
|
|
1364
|
-
function
|
|
1368
|
+
function $t(e) {
|
|
1365
1369
|
return e.type.isInGroup("bnBlock");
|
|
1366
1370
|
}
|
|
1367
1371
|
//#endregion
|
|
1368
1372
|
//#region src/api/blockManipulation/commands/updateBlock/updateBlock.ts
|
|
1369
|
-
var
|
|
1373
|
+
var en = (e, t) => ({ tr: n, dispatch: r }) => (r && U(n, e, t), !0);
|
|
1370
1374
|
function U(e, t, n, r, i) {
|
|
1371
|
-
let a =
|
|
1372
|
-
a.blockNoteType === "table" && (o =
|
|
1375
|
+
let a = je(e.doc.resolve(t)), o = null;
|
|
1376
|
+
a.blockNoteType === "table" && (o = cn(e));
|
|
1373
1377
|
let s = k(e);
|
|
1374
1378
|
if (r !== void 0 && i !== void 0 && r > i) throw Error("Invalid replaceFromPos or replaceToPos");
|
|
1375
1379
|
let c = s.nodes[a.blockNoteType], l = s.nodes[n.type || a.blockNoteType], u = l.isInGroup("bnBlock") ? l : s.nodes.blockContainer;
|
|
1376
1380
|
if (a.isBlockContainer && l.isInGroup("blockContent")) {
|
|
1377
1381
|
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;
|
|
1378
|
-
|
|
1379
|
-
} else if (!a.isBlockContainer && l.isInGroup("bnBlock"))
|
|
1382
|
+
on(n, e, a), tn(n, e, c, l, a, t, o);
|
|
1383
|
+
} else if (!a.isBlockContainer && l.isInGroup("bnBlock")) on(n, e, a);
|
|
1380
1384
|
else {
|
|
1381
1385
|
let t = H({
|
|
1382
1386
|
children: j(a.bnBlock.node, e.doc).children,
|
|
@@ -1385,25 +1389,34 @@ function U(e, t, n, r, i) {
|
|
|
1385
1389
|
t.check(), e.replaceWith(a.bnBlock.beforePos, a.bnBlock.afterPos, t);
|
|
1386
1390
|
return;
|
|
1387
1391
|
}
|
|
1388
|
-
|
|
1392
|
+
rn(e, a.bnBlock.beforePos, u, { ...n.props }), o && ln(e, a, o);
|
|
1389
1393
|
}
|
|
1390
|
-
function
|
|
1394
|
+
function tn(e, t, n, r, o, s, c) {
|
|
1391
1395
|
let l = k(t), u = "keep";
|
|
1392
|
-
if (e.content)
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1396
|
+
if (e.content) {
|
|
1397
|
+
if (typeof e.content == "string") u = V([e.content], l, r.name);
|
|
1398
|
+
else if (Array.isArray(e.content)) u = V(e.content, l, r.name);
|
|
1399
|
+
else if (e.content.type === "tableContent") u = Xt(e.content, l);
|
|
1400
|
+
else throw new E(e.content.type);
|
|
1401
|
+
} else {
|
|
1402
|
+
let e = o.blockContent.node.content;
|
|
1403
|
+
if (n.spec.content !== "" && r.spec.content !== n.spec.content && !r.validContent(e)) {
|
|
1404
|
+
if (r.inlineContent && n.inlineContent) {
|
|
1405
|
+
let e = o.blockContent.node.textContent;
|
|
1406
|
+
u = e.length > 0 ? [l.text(e)] : [];
|
|
1407
|
+
} else u = [];
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
if (u === "keep") rn(t, o.blockContent.beforePos, r, { ...e.props });
|
|
1398
1411
|
else if (s !== void 0 || c !== void 0) {
|
|
1399
|
-
let n =
|
|
1412
|
+
let n = an(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;
|
|
1400
1413
|
t.replace(l, d, new a(i.from(u), p - f - 1, m - f - 1));
|
|
1401
|
-
} else r === n || r.validContent(o.blockContent.node.content) ?
|
|
1414
|
+
} else r === n || r.validContent(o.blockContent.node.content) ? nn(t, an(t, o.blockContent.beforePos, r, { ...e.props }), i.from(u)) : t.replaceWith(o.blockContent.beforePos, o.blockContent.afterPos, r.createChecked({
|
|
1402
1415
|
...o.blockContent.node.attrs,
|
|
1403
1416
|
...e.props
|
|
1404
1417
|
}, u));
|
|
1405
1418
|
}
|
|
1406
|
-
function
|
|
1419
|
+
function nn(e, t, n) {
|
|
1407
1420
|
let r = e.doc.nodeAt(t);
|
|
1408
1421
|
if (!r) throw RangeError("No node at given position");
|
|
1409
1422
|
let s = r.content, c = t + 1;
|
|
@@ -1427,7 +1440,7 @@ function an(e, t, n) {
|
|
|
1427
1440
|
for (let e = d; e < p; e++) g.push(n.child(e));
|
|
1428
1441
|
e.step(new o(m, h, new a(i.from(g), 0, 0)));
|
|
1429
1442
|
}
|
|
1430
|
-
function
|
|
1443
|
+
function rn(e, t, n, r) {
|
|
1431
1444
|
let i = e.doc.nodeAt(t);
|
|
1432
1445
|
if (!i) throw RangeError("No node at given position");
|
|
1433
1446
|
let a = n.spec.attrs ?? {}, o = {};
|
|
@@ -1442,30 +1455,30 @@ function on(e, t, n, r) {
|
|
|
1442
1455
|
}
|
|
1443
1456
|
e.setNodeMarkup(t, n, s);
|
|
1444
1457
|
}
|
|
1445
|
-
function
|
|
1458
|
+
function an(e, t, n, r) {
|
|
1446
1459
|
let i = e.mapping.maps.length;
|
|
1447
|
-
return
|
|
1460
|
+
return rn(e, t, n, r), e.mapping.slice(i).map(t, -1);
|
|
1448
1461
|
}
|
|
1449
|
-
function
|
|
1462
|
+
function on(e, t, n) {
|
|
1450
1463
|
let r = k(t);
|
|
1451
1464
|
if (e.children !== void 0 && e.children.length > 0) {
|
|
1452
1465
|
let a = e.children.map((e) => {
|
|
1453
1466
|
let t = H(e, r);
|
|
1454
1467
|
return t.check(), t;
|
|
1455
1468
|
});
|
|
1456
|
-
if (n.childContainer)
|
|
1469
|
+
if (n.childContainer) nn(t, n.childContainer.beforePos, i.from(a));
|
|
1457
1470
|
else {
|
|
1458
1471
|
if (!n.isBlockContainer) throw Error("impossible");
|
|
1459
1472
|
t.insert(n.blockContent.afterPos, r.nodes.blockGroup.createChecked({}, a));
|
|
1460
1473
|
}
|
|
1461
1474
|
}
|
|
1462
1475
|
}
|
|
1463
|
-
function
|
|
1464
|
-
let a = typeof t == "string" ? t : t.id, o =
|
|
1476
|
+
function sn(e, t, n, r, i) {
|
|
1477
|
+
let a = typeof t == "string" ? t : t.id, o = Qt(a, e.doc);
|
|
1465
1478
|
if (!o) throw Error(`Block with ID ${a} not found`);
|
|
1466
1479
|
return U(e, o.posBeforeNode, n, r, i), j(e.doc.resolve(o.posBeforeNode + 1).node(), e.doc);
|
|
1467
1480
|
}
|
|
1468
|
-
function
|
|
1481
|
+
function cn(e) {
|
|
1469
1482
|
let t = "selection" in e ? e.selection : null;
|
|
1470
1483
|
if (!(t instanceof re)) return null;
|
|
1471
1484
|
let n = e.doc.resolve(t.head), r = -1, i = -1;
|
|
@@ -1488,13 +1501,13 @@ function un(e) {
|
|
|
1488
1501
|
offset: Math.max(0, t.head - p)
|
|
1489
1502
|
};
|
|
1490
1503
|
}
|
|
1491
|
-
function
|
|
1504
|
+
function ln(e, t, n) {
|
|
1492
1505
|
if (t.blockNoteType !== "table") return !1;
|
|
1493
1506
|
let r = -1;
|
|
1494
1507
|
if (t.isBlockContainer) r = e.mapping.map(t.blockContent.beforePos);
|
|
1495
1508
|
else {
|
|
1496
1509
|
let n = e.mapping.map(t.bnBlock.beforePos), i = n + (e.doc.nodeAt(n)?.nodeSize || 0);
|
|
1497
|
-
e.doc.nodesBetween(n, i, (e, t) => e.type.name
|
|
1510
|
+
e.doc.nodesBetween(n, i, (e, t) => e.type.name !== "table" || (r = t, !1));
|
|
1498
1511
|
}
|
|
1499
1512
|
let i = r >= 0 ? e.doc.nodeAt(r) : null;
|
|
1500
1513
|
if (!i || i.type.name !== "table") return !1;
|
|
@@ -1542,7 +1555,7 @@ var W = {
|
|
|
1542
1555
|
text: "#ad1a72",
|
|
1543
1556
|
background: "#f4dfeb"
|
|
1544
1557
|
}
|
|
1545
|
-
},
|
|
1558
|
+
}, un = {
|
|
1546
1559
|
gray: {
|
|
1547
1560
|
text: "#bebdb8",
|
|
1548
1561
|
background: "#9b9a97"
|
|
@@ -1596,35 +1609,35 @@ var W = {
|
|
|
1596
1609
|
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;
|
|
1597
1610
|
}, q = (e, t) => {
|
|
1598
1611
|
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);
|
|
1599
|
-
},
|
|
1612
|
+
}, dn = (e = "backgroundColor") => ({
|
|
1600
1613
|
default: G.backgroundColor.default,
|
|
1601
1614
|
parseHTML: (e) => e.hasAttribute("data-background-color") ? e.getAttribute("data-background-color") : e.style.backgroundColor ? e.style.backgroundColor : G.backgroundColor.default,
|
|
1602
1615
|
renderHTML: (t) => t[e] === G.backgroundColor.default ? {} : { "data-background-color": t[e] }
|
|
1603
|
-
}),
|
|
1616
|
+
}), fn = (e = "textColor") => ({
|
|
1604
1617
|
default: G.textColor.default,
|
|
1605
1618
|
parseHTML: (e) => e.hasAttribute("data-text-color") ? e.getAttribute("data-text-color") : e.style.color ? e.style.color : G.textColor.default,
|
|
1606
1619
|
renderHTML: (t) => t[e] === G.textColor.default ? {} : { "data-text-color": t[e] }
|
|
1607
|
-
}),
|
|
1620
|
+
}), pn = (e = "textAlignment") => ({
|
|
1608
1621
|
default: G.textAlignment.default,
|
|
1609
1622
|
parseHTML: (e) => e.hasAttribute("data-text-alignment") ? e.getAttribute("data-text-alignment") : e.style.textAlign ? e.style.textAlign : G.textAlignment.default,
|
|
1610
1623
|
renderHTML: (t) => t[e] === G.textAlignment.default ? {} : { "data-text-alignment": t[e] }
|
|
1611
|
-
}),
|
|
1624
|
+
}), mn = (e, t) => {
|
|
1612
1625
|
let n = e.querySelector(t);
|
|
1613
1626
|
if (n) return {
|
|
1614
1627
|
targetElement: n,
|
|
1615
1628
|
caption: e.querySelector("figcaption")?.textContent ?? void 0
|
|
1616
1629
|
};
|
|
1617
|
-
}, J = n(({ editor:
|
|
1618
|
-
let n =
|
|
1630
|
+
}, J = n(({ editor: t }) => {
|
|
1631
|
+
let n = e(void 0);
|
|
1619
1632
|
function r() {
|
|
1620
1633
|
n.setState(void 0);
|
|
1621
1634
|
}
|
|
1622
1635
|
return {
|
|
1623
1636
|
key: "filePanel",
|
|
1624
1637
|
store: n,
|
|
1625
|
-
mount({ signal:
|
|
1626
|
-
let n =
|
|
1627
|
-
|
|
1638
|
+
mount({ signal: e }) {
|
|
1639
|
+
let n = t.onChange(r, !1), i = t.onSelectionChange(r, !1);
|
|
1640
|
+
e.addEventListener("abort", () => {
|
|
1628
1641
|
n(), i();
|
|
1629
1642
|
});
|
|
1630
1643
|
},
|
|
@@ -1633,7 +1646,7 @@ var W = {
|
|
|
1633
1646
|
n.setState(e);
|
|
1634
1647
|
}
|
|
1635
1648
|
};
|
|
1636
|
-
}),
|
|
1649
|
+
}), hn = (e, t, n) => {
|
|
1637
1650
|
let r = document.createElement("div");
|
|
1638
1651
|
r.className = "bn-add-file-button";
|
|
1639
1652
|
let i = document.createElement("div");
|
|
@@ -1651,17 +1664,17 @@ var W = {
|
|
|
1651
1664
|
r.removeEventListener("mousedown", o, !0), r.removeEventListener("click", s, !0);
|
|
1652
1665
|
}
|
|
1653
1666
|
};
|
|
1654
|
-
},
|
|
1667
|
+
}, gn = "<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>", _n = (e) => {
|
|
1655
1668
|
let t = document.createElement("div");
|
|
1656
1669
|
t.className = "bn-file-name-with-icon";
|
|
1657
1670
|
let n = document.createElement("div");
|
|
1658
|
-
n.className = "bn-file-icon", n.innerHTML =
|
|
1671
|
+
n.className = "bn-file-icon", n.innerHTML = gn, t.appendChild(n);
|
|
1659
1672
|
let r = document.createElement("p");
|
|
1660
1673
|
return r.className = "bn-file-name", r.textContent = e.props.name, t.appendChild(r), { dom: t };
|
|
1661
|
-
},
|
|
1674
|
+
}, vn = (e, t, n, r) => {
|
|
1662
1675
|
let i = e.props.url !== "" && !!e.props.caption, a = document.createElement(i ? "figure" : "div");
|
|
1663
1676
|
if (a.className = "bn-file-block-content-wrapper", e.props.url === "") {
|
|
1664
|
-
let n =
|
|
1677
|
+
let n = hn(e, t, r);
|
|
1665
1678
|
a.appendChild(n.dom);
|
|
1666
1679
|
let i = t.onUploadStart((t) => {
|
|
1667
1680
|
if (t === e.id) {
|
|
@@ -1679,7 +1692,7 @@ var W = {
|
|
|
1679
1692
|
}
|
|
1680
1693
|
let o = { dom: a };
|
|
1681
1694
|
if (e.props.showPreview === !1 || !n) {
|
|
1682
|
-
let t =
|
|
1695
|
+
let t = _n(e);
|
|
1683
1696
|
a.appendChild(t.dom), o.destroy = () => {
|
|
1684
1697
|
t.destroy?.();
|
|
1685
1698
|
};
|
|
@@ -1689,13 +1702,13 @@ var W = {
|
|
|
1689
1702
|
t.className = "bn-file-caption", t.textContent = e.props.caption, a.appendChild(t);
|
|
1690
1703
|
}
|
|
1691
1704
|
return o;
|
|
1692
|
-
},
|
|
1705
|
+
}, yn = (e, t) => {
|
|
1693
1706
|
let n = document.createElement("figure"), r = document.createElement("figcaption");
|
|
1694
1707
|
return r.textContent = t, n.appendChild(e), n.appendChild(r), { dom: n };
|
|
1695
|
-
},
|
|
1708
|
+
}, bn = (e, t) => {
|
|
1696
1709
|
let n = document.createElement("div"), r = document.createElement("p");
|
|
1697
1710
|
return r.textContent = t, n.appendChild(e), n.appendChild(r), { dom: n };
|
|
1698
|
-
},
|
|
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 = P((e) => ({
|
|
1699
1712
|
type: "audio",
|
|
1700
1713
|
propSchema: {
|
|
1701
1714
|
backgroundColor: G.backgroundColor,
|
|
@@ -1705,146 +1718,96 @@ var W = {
|
|
|
1705
1718
|
showPreview: { default: !0 }
|
|
1706
1719
|
},
|
|
1707
1720
|
content: "none"
|
|
1708
|
-
})),
|
|
1721
|
+
})), wn = (e = {}) => (e) => {
|
|
1709
1722
|
if (e.tagName === "AUDIO") {
|
|
1710
1723
|
if (e.closest("figure")) return;
|
|
1711
1724
|
let { backgroundColor: t } = K(e);
|
|
1712
1725
|
return {
|
|
1713
|
-
...
|
|
1726
|
+
...xn(e),
|
|
1714
1727
|
backgroundColor: t
|
|
1715
1728
|
};
|
|
1716
1729
|
}
|
|
1717
1730
|
if (e.tagName === "FIGURE") {
|
|
1718
|
-
let t =
|
|
1731
|
+
let t = mn(e, "audio");
|
|
1719
1732
|
if (!t) return;
|
|
1720
1733
|
let { targetElement: n, caption: r } = t, { backgroundColor: i } = K(e);
|
|
1721
1734
|
return {
|
|
1722
|
-
...
|
|
1735
|
+
...xn(n),
|
|
1723
1736
|
backgroundColor: i,
|
|
1724
1737
|
caption: r
|
|
1725
1738
|
};
|
|
1726
1739
|
}
|
|
1727
|
-
},
|
|
1740
|
+
}, Tn = (e = {}) => (t, n) => {
|
|
1728
1741
|
let r = document.createElement("div");
|
|
1729
1742
|
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>";
|
|
1730
1743
|
let i = document.createElement("audio");
|
|
1731
1744
|
return i.className = "bn-audio", n.resolveFileUrl ? n.resolveFileUrl(t.props.url).then((e) => {
|
|
1732
1745
|
i.src = e;
|
|
1733
|
-
}) : i.src = t.props.url, i.controls = !0, i.contentEditable = "false", i.draggable = !1,
|
|
1734
|
-
},
|
|
1746
|
+
}) : i.src = t.props.url, i.controls = !0, i.contentEditable = "false", i.draggable = !1, vn(t, n, { dom: i }, r.firstElementChild);
|
|
1747
|
+
}, En = (e = {}) => (e, t) => {
|
|
1735
1748
|
if (!e.props.url) return { dom: document.createElement("audio") };
|
|
1736
1749
|
let n;
|
|
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 ?
|
|
1738
|
-
},
|
|
1750
|
+
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 = F(Cn, (e) => ({
|
|
1739
1752
|
meta: { fileBlockAccept: ["audio/*"] },
|
|
1740
|
-
parse:
|
|
1741
|
-
render:
|
|
1742
|
-
toExternalHTML:
|
|
1753
|
+
parse: wn(e),
|
|
1754
|
+
render: Tn(e),
|
|
1755
|
+
toExternalHTML: En(e),
|
|
1743
1756
|
runsBefore: ["file"]
|
|
1744
|
-
})),
|
|
1745
|
-
|
|
1746
|
-
let t = globalThis, n, r, i = !1;
|
|
1747
|
-
return _e({
|
|
1748
|
-
parser: (a) => {
|
|
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), [];
|
|
1750
|
-
if (!n) return t[jn] = t[jn] || e.createHighlighter(), t[jn].then((e) => {
|
|
1751
|
-
n = e;
|
|
1752
|
-
});
|
|
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);
|
|
1755
|
-
},
|
|
1756
|
-
languageExtractor: (e) => e.attrs.language,
|
|
1757
|
-
nodeTypes: ["codeBlock"]
|
|
1758
|
-
});
|
|
1759
|
-
}
|
|
1760
|
-
//#endregion
|
|
1761
|
-
//#region src/blocks/Code/block.ts
|
|
1762
|
-
var Nn = P(({ defaultLanguage: e = "text" }) => ({
|
|
1763
|
-
type: "codeBlock",
|
|
1764
|
-
propSchema: { language: { default: e } },
|
|
1765
|
-
content: "plain"
|
|
1766
|
-
})), Pn = F(Nn, (e) => ({
|
|
1767
|
-
meta: {
|
|
1768
|
-
code: !0,
|
|
1769
|
-
defining: !0,
|
|
1770
|
-
isolating: !1
|
|
1771
|
-
},
|
|
1772
|
-
parse: (e) => {
|
|
1757
|
+
})), On = (e) => {
|
|
1758
|
+
{
|
|
1773
1759
|
if (e.tagName !== "PRE" || e.childElementCount !== 1 || e.firstElementChild?.tagName !== "CODE") return;
|
|
1774
1760
|
let t = e.firstElementChild;
|
|
1775
|
-
return { language: t.getAttribute("data-language") || t.className.split(" ").find((e) => e.
|
|
1776
|
-
}
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
let a = document.createElement("div");
|
|
1801
|
-
a.contentEditable = "false", a.appendChild(i), r.appendChild(a);
|
|
1802
|
-
}
|
|
1803
|
-
return r.appendChild(i), {
|
|
1804
|
-
dom: r,
|
|
1805
|
-
contentDOM: a,
|
|
1806
|
-
destroy: () => {
|
|
1807
|
-
o?.();
|
|
1808
|
-
}
|
|
1809
|
-
};
|
|
1810
|
-
},
|
|
1811
|
-
toExternalHTML(e) {
|
|
1812
|
-
let t = document.createElement("pre"), n = document.createElement("code");
|
|
1813
|
-
return n.className = `language-${e.props.language}`, n.dataset.language = e.props.language, t.appendChild(n), {
|
|
1814
|
-
dom: t,
|
|
1815
|
-
contentDOM: n
|
|
1816
|
-
};
|
|
1817
|
-
}
|
|
1818
|
-
}), (e) => [n({
|
|
1819
|
-
key: "code-block-highlighter",
|
|
1820
|
-
prosemirrorPlugins: [Mn(e)]
|
|
1821
|
-
}), n({
|
|
1822
|
-
key: "code-block-keyboard-shortcuts",
|
|
1761
|
+
return { language: t.getAttribute("data-language") || t.className.split(" ").find((e) => e.startsWith("language-"))?.replace("language-", "") };
|
|
1762
|
+
}
|
|
1763
|
+
}, kn = ({ el: e, schema: t }, n) => {
|
|
1764
|
+
let r = ie.fromSchema(t), i = e.firstElementChild;
|
|
1765
|
+
return r.parse(i, {
|
|
1766
|
+
preserveWhitespace: "full",
|
|
1767
|
+
topNode: t.nodes[n].create()
|
|
1768
|
+
}).content;
|
|
1769
|
+
}, An = (e) => {
|
|
1770
|
+
let t = document.createElement("pre"), n = document.createElement("code");
|
|
1771
|
+
return n.className = `language-${e.props.language}`, n.dataset.language = e.props.language, t.appendChild(n), {
|
|
1772
|
+
dom: t,
|
|
1773
|
+
contentDOM: n
|
|
1774
|
+
};
|
|
1775
|
+
};
|
|
1776
|
+
//#endregion
|
|
1777
|
+
//#region src/blocks/Code/CodeBlockOptions.ts
|
|
1778
|
+
function jn(e, t) {
|
|
1779
|
+
let n = t.trim().toLowerCase();
|
|
1780
|
+
return Object.entries(e.supportedLanguages ?? {}).find(([e, { aliases: t }]) => e.toLowerCase() === n || t?.some((e) => e.toLowerCase() === n))?.[0];
|
|
1781
|
+
}
|
|
1782
|
+
//#endregion
|
|
1783
|
+
//#region src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.ts
|
|
1784
|
+
var Mn = (e) => (t, r) => n({
|
|
1785
|
+
key: t,
|
|
1823
1786
|
keyboardShortcuts: {
|
|
1824
1787
|
Delete: ({ editor: e }) => e.transact((t) => {
|
|
1825
1788
|
let { block: n } = e.getTextCursorPosition();
|
|
1826
|
-
if (n.type !==
|
|
1827
|
-
let { $from:
|
|
1828
|
-
return
|
|
1789
|
+
if (n.type !== r) return !1;
|
|
1790
|
+
let { $from: i } = t.selection;
|
|
1791
|
+
return !i.parent.textContent && (e.removeBlocks([n]), !0);
|
|
1829
1792
|
}),
|
|
1830
|
-
Tab: ({ editor: t }) => e.indentLineWithTab
|
|
1793
|
+
Tab: ({ editor: t }) => e.indentLineWithTab !== !1 && t.transact((e) => {
|
|
1831
1794
|
let { block: n } = t.getTextCursorPosition();
|
|
1832
|
-
return n.type ===
|
|
1795
|
+
return n.type === r && (e.insertText(" "), !0);
|
|
1833
1796
|
}),
|
|
1834
1797
|
Enter: ({ editor: e }) => e.transact((t) => {
|
|
1835
|
-
let { block: n, nextBlock:
|
|
1836
|
-
if (n.type !==
|
|
1837
|
-
let { $from:
|
|
1838
|
-
if (
|
|
1839
|
-
if (t.delete(
|
|
1840
|
-
let [
|
|
1841
|
-
return e.setTextCursorPosition(
|
|
1798
|
+
let { block: n, nextBlock: i } = e.getTextCursorPosition();
|
|
1799
|
+
if (n.type !== r) return !1;
|
|
1800
|
+
let { $from: a } = t.selection, o = a.parentOffset === a.parent.nodeSize - 2, s = a.parent.textContent.endsWith("\n\n");
|
|
1801
|
+
if (o && s) {
|
|
1802
|
+
if (t.delete(a.pos - 2, a.pos), i) return e.setTextCursorPosition(i, "start"), !0;
|
|
1803
|
+
let [r] = e.insertBlocks([{ type: "paragraph" }], n, "after");
|
|
1804
|
+
return e.setTextCursorPosition(r, "start"), !0;
|
|
1842
1805
|
}
|
|
1843
1806
|
return t.insertText("\n"), !0;
|
|
1844
1807
|
}),
|
|
1845
1808
|
"Shift-Enter": ({ editor: e }) => e.transact(() => {
|
|
1846
1809
|
let { block: t } = e.getTextCursorPosition();
|
|
1847
|
-
if (t.type !==
|
|
1810
|
+
if (t.type !== r) return !1;
|
|
1848
1811
|
let [n] = e.insertBlocks([{ type: "paragraph" }], t, "after");
|
|
1849
1812
|
return e.setTextCursorPosition(n, "start"), !0;
|
|
1850
1813
|
})
|
|
@@ -1854,23 +1817,62 @@ var Nn = P(({ defaultLanguage: e = "text" }) => ({
|
|
|
1854
1817
|
replace: ({ match: t }) => {
|
|
1855
1818
|
let n = t[1].trim();
|
|
1856
1819
|
return {
|
|
1857
|
-
type:
|
|
1858
|
-
props: { language: { language:
|
|
1820
|
+
type: r,
|
|
1821
|
+
props: { language: { language: jn(e, n) ?? n }.language },
|
|
1859
1822
|
content: []
|
|
1860
1823
|
};
|
|
1861
1824
|
}
|
|
1862
1825
|
}]
|
|
1863
|
-
})
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
}
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1826
|
+
}), Nn = (e, t, n, r) => {
|
|
1827
|
+
if (!(n in r)) throw Error(`Language ${n} is not supported.`);
|
|
1828
|
+
let i = document.createElement("select");
|
|
1829
|
+
Object.entries(r).forEach(([e, { name: t }]) => {
|
|
1830
|
+
let n = document.createElement("option");
|
|
1831
|
+
n.value = e, n.text = t, i.appendChild(n);
|
|
1832
|
+
}), i.value = n;
|
|
1833
|
+
let a = (n) => {
|
|
1834
|
+
t.isEditable && t.updateBlock(e.id, { props: { language: n.target.value } });
|
|
1835
|
+
};
|
|
1836
|
+
t.isEditable ? i.addEventListener("change", a) : i.disabled = !0;
|
|
1837
|
+
let o = document.createElement("div");
|
|
1838
|
+
return o.contentEditable = "false", o.appendChild(i), {
|
|
1839
|
+
dom: o,
|
|
1840
|
+
destroy: () => i.removeEventListener("change", a)
|
|
1841
|
+
};
|
|
1842
|
+
}, Pn = (e, t, n) => {
|
|
1843
|
+
let r = document.createElement("pre"), i = document.createElement("code");
|
|
1844
|
+
r.appendChild(i);
|
|
1845
|
+
let a = document.createDocumentFragment(), o;
|
|
1846
|
+
return n && Object.keys(n.supportedLanguages).length > 1 && (o = Nn(e, t, n.selectedLanguage, n.supportedLanguages), a.appendChild(o.dom)), a.appendChild(r), {
|
|
1847
|
+
dom: a,
|
|
1848
|
+
contentDOM: i,
|
|
1849
|
+
destroy: () => {
|
|
1850
|
+
o?.destroy();
|
|
1851
|
+
}
|
|
1852
|
+
};
|
|
1853
|
+
}, Fn = "code-block-keyboard-shortcuts", In = P(({ defaultLanguage: e = "text" }) => ({
|
|
1854
|
+
type: "codeBlock",
|
|
1855
|
+
propSchema: { language: { default: e } },
|
|
1856
|
+
content: "plain"
|
|
1857
|
+
})), Ln = F(In, (e) => ({
|
|
1858
|
+
meta: {
|
|
1859
|
+
code: !0,
|
|
1860
|
+
defining: !0,
|
|
1861
|
+
isolating: !1,
|
|
1862
|
+
highlight: (e) => e.props.language
|
|
1863
|
+
},
|
|
1864
|
+
parse: (e) => On(e),
|
|
1865
|
+
parseContent: (e) => kn(e, "codeBlock"),
|
|
1866
|
+
render: (t, n) => Pn(t, n, e.supportedLanguages && {
|
|
1867
|
+
selectedLanguage: t.props.language,
|
|
1868
|
+
supportedLanguages: e.supportedLanguages
|
|
1869
|
+
}),
|
|
1870
|
+
toExternalHTML: (e) => An(e)
|
|
1871
|
+
}), (e) => [Mn(e)(Fn, "codeBlock")]), Rn = P(() => ({
|
|
1870
1872
|
type: "divider",
|
|
1871
1873
|
propSchema: {},
|
|
1872
1874
|
content: "none"
|
|
1873
|
-
})),
|
|
1875
|
+
})), zn = F(Rn, {
|
|
1874
1876
|
meta: { isolating: !1 },
|
|
1875
1877
|
parse(e) {
|
|
1876
1878
|
if (e.tagName === "HR") return {};
|
|
@@ -1890,7 +1892,7 @@ var In = P(() => ({
|
|
|
1890
1892
|
};
|
|
1891
1893
|
}
|
|
1892
1894
|
}]
|
|
1893
|
-
})]),
|
|
1895
|
+
})]), Bn = (e) => ({ url: e.src || void 0 }), Vn = P(() => ({
|
|
1894
1896
|
type: "file",
|
|
1895
1897
|
propSchema: {
|
|
1896
1898
|
backgroundColor: G.backgroundColor,
|
|
@@ -1899,44 +1901,44 @@ var In = P(() => ({
|
|
|
1899
1901
|
caption: { default: "" }
|
|
1900
1902
|
},
|
|
1901
1903
|
content: "none"
|
|
1902
|
-
})),
|
|
1904
|
+
})), Hn = () => (e) => {
|
|
1903
1905
|
if (e.tagName === "EMBED") {
|
|
1904
1906
|
if (e.closest("figure")) return;
|
|
1905
1907
|
let { backgroundColor: t } = K(e);
|
|
1906
1908
|
return {
|
|
1907
|
-
...
|
|
1909
|
+
...Bn(e),
|
|
1908
1910
|
backgroundColor: t
|
|
1909
1911
|
};
|
|
1910
1912
|
}
|
|
1911
1913
|
if (e.tagName === "FIGURE") {
|
|
1912
|
-
let t =
|
|
1914
|
+
let t = mn(e, "embed");
|
|
1913
1915
|
if (!t) return;
|
|
1914
1916
|
let { targetElement: n, caption: r } = t, { backgroundColor: i } = K(e);
|
|
1915
1917
|
return {
|
|
1916
|
-
...
|
|
1918
|
+
...Bn(n),
|
|
1917
1919
|
backgroundColor: i,
|
|
1918
1920
|
caption: r
|
|
1919
1921
|
};
|
|
1920
1922
|
}
|
|
1921
|
-
},
|
|
1923
|
+
}, Un = F(Vn, {
|
|
1922
1924
|
meta: { fileBlockAccept: ["*/*"] },
|
|
1923
|
-
parse:
|
|
1925
|
+
parse: Hn(),
|
|
1924
1926
|
render(e, t) {
|
|
1925
|
-
return
|
|
1927
|
+
return vn(e, t);
|
|
1926
1928
|
},
|
|
1927
1929
|
toExternalHTML(e) {
|
|
1928
1930
|
if (!e.props.url) return { dom: document.createElement("embed") };
|
|
1929
1931
|
let t = document.createElement("a");
|
|
1930
|
-
return t.href = e.props.url, t.textContent = e.props.name || e.props.url, e.props.caption ?
|
|
1932
|
+
return t.href = e.props.url, t.textContent = e.props.name || e.props.url, e.props.caption ? bn(t, e.props.caption) : { dom: t };
|
|
1931
1933
|
}
|
|
1932
1934
|
});
|
|
1933
1935
|
//#endregion
|
|
1934
1936
|
//#region src/blocks/getDetailsContent.ts
|
|
1935
|
-
function
|
|
1937
|
+
function Wn(e, t, n) {
|
|
1936
1938
|
let a = r.fromSchema(t), o = e.querySelector(":scope > summary"), s;
|
|
1937
1939
|
if (o) {
|
|
1938
1940
|
let e = o.cloneNode(!0);
|
|
1939
|
-
|
|
1941
|
+
Ke(e), s = a.parse(e, {
|
|
1940
1942
|
topNode: t.nodes.paragraph.create(),
|
|
1941
1943
|
preserveWhitespace: !0
|
|
1942
1944
|
}).content;
|
|
@@ -1952,10 +1954,10 @@ function Hn(e, t, n) {
|
|
|
1952
1954
|
}
|
|
1953
1955
|
//#endregion
|
|
1954
1956
|
//#region src/blocks/ToggleWrapper/createToggleWrapper.ts
|
|
1955
|
-
var
|
|
1957
|
+
var Gn = {
|
|
1956
1958
|
set: (e, t) => window.localStorage.setItem(`toggle-${e.id}`, t ? "true" : "false"),
|
|
1957
1959
|
get: (e) => window.localStorage.getItem(`toggle-${e.id}`) === "true"
|
|
1958
|
-
},
|
|
1960
|
+
}, Kn = (e, t, n, r = Gn) => {
|
|
1959
1961
|
if ("isToggleable" in e.props && !e.props.isToggleable) return { dom: n };
|
|
1960
1962
|
let i = document.createElement("div"), a = document.createElement("div");
|
|
1961
1963
|
a.className = "bn-toggle-wrapper";
|
|
@@ -2005,20 +2007,20 @@ var Un = {
|
|
|
2005
2007
|
o.removeEventListener("mousedown", s), o.removeEventListener("click", c), l.removeEventListener("mousedown", u), l.removeEventListener("click", d), p?.();
|
|
2006
2008
|
}
|
|
2007
2009
|
};
|
|
2008
|
-
},
|
|
2010
|
+
}, qn = [
|
|
2009
2011
|
1,
|
|
2010
2012
|
2,
|
|
2011
2013
|
3,
|
|
2012
2014
|
4,
|
|
2013
2015
|
5,
|
|
2014
2016
|
6
|
|
2015
|
-
],
|
|
2017
|
+
], Jn = (e) => ({ editor: t }) => {
|
|
2016
2018
|
let n = t.getTextCursorPosition();
|
|
2017
|
-
return t.schema.blockSchema[n.block.type].content === "inline"
|
|
2019
|
+
return t.schema.blockSchema[n.block.type].content === "inline" && (t.updateBlock(n.block, {
|
|
2018
2020
|
type: "heading",
|
|
2019
2021
|
props: { level: e }
|
|
2020
|
-
}), !0)
|
|
2021
|
-
},
|
|
2022
|
+
}), !0);
|
|
2023
|
+
}, Yn = P(({ defaultLevel: e = 1, levels: t = qn, allowToggleHeadings: n = !0 } = {}) => ({
|
|
2022
2024
|
type: "heading",
|
|
2023
2025
|
propSchema: {
|
|
2024
2026
|
...G,
|
|
@@ -2032,7 +2034,7 @@ var Un = {
|
|
|
2032
2034
|
} } : {}
|
|
2033
2035
|
},
|
|
2034
2036
|
content: "inline"
|
|
2035
|
-
})),
|
|
2037
|
+
})), Xn = F(Yn, ({ allowToggleHeadings: e = !0 } = {}) => ({
|
|
2036
2038
|
meta: { isolating: !1 },
|
|
2037
2039
|
parse(t) {
|
|
2038
2040
|
if (e && t.tagName === "DETAILS") {
|
|
@@ -2073,13 +2075,13 @@ var Un = {
|
|
|
2073
2075
|
};
|
|
2074
2076
|
},
|
|
2075
2077
|
...e ? { parseContent: ({ el: e, schema: t }) => {
|
|
2076
|
-
if (e.tagName === "DETAILS") return
|
|
2078
|
+
if (e.tagName === "DETAILS") return Wn(e, t, "heading");
|
|
2077
2079
|
} } : {},
|
|
2078
2080
|
runsBefore: ["toggleListItem"],
|
|
2079
2081
|
render(t, n) {
|
|
2080
2082
|
let r = document.createElement(`h${t.props.level}`);
|
|
2081
2083
|
return e ? {
|
|
2082
|
-
...
|
|
2084
|
+
...Kn(t, n, r),
|
|
2083
2085
|
contentDOM: r
|
|
2084
2086
|
} : {
|
|
2085
2087
|
dom: r,
|
|
@@ -2103,9 +2105,9 @@ var Un = {
|
|
|
2103
2105
|
contentDOM: n
|
|
2104
2106
|
};
|
|
2105
2107
|
}
|
|
2106
|
-
}), ({ levels: e =
|
|
2108
|
+
}), ({ levels: e = qn } = {}) => [n({
|
|
2107
2109
|
key: "heading-shortcuts",
|
|
2108
|
-
keyboardShortcuts: Object.fromEntries(e.map((e) => [`Mod-Alt-${e}`,
|
|
2110
|
+
keyboardShortcuts: Object.fromEntries(e.map((e) => [`Mod-Alt-${e}`, Jn(e)]) ?? []),
|
|
2109
2111
|
inputRules: e.map((e) => ({
|
|
2110
2112
|
find: RegExp(`^(#{${e}})\\s$`),
|
|
2111
2113
|
replace({ match: e }) {
|
|
@@ -2115,8 +2117,8 @@ var Un = {
|
|
|
2115
2117
|
};
|
|
2116
2118
|
}
|
|
2117
2119
|
}))
|
|
2118
|
-
})]),
|
|
2119
|
-
let { dom: a, destroy: o } =
|
|
2120
|
+
})]), Zn = (e, t, n, r, i) => {
|
|
2121
|
+
let { dom: a, destroy: o } = vn(e, t, n, i), s = a;
|
|
2120
2122
|
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");
|
|
2121
2123
|
let c = document.createElement("div");
|
|
2122
2124
|
c.className = "bn-resize-handle", c.style.left = "4px", c.style.display = "none", r.appendChild(c);
|
|
@@ -2136,7 +2138,7 @@ var Un = {
|
|
|
2136
2138
|
}, h = () => {
|
|
2137
2139
|
t.isEditable && (c.style.display = "", l.style.display = "");
|
|
2138
2140
|
}, g = (e) => {
|
|
2139
|
-
e.relatedTarget
|
|
2141
|
+
e.relatedTarget !== c && e.relatedTarget !== l && (d || t.isEditable && (c.style.display = "none", l.style.display = "none"));
|
|
2140
2142
|
}, _ = (e) => {
|
|
2141
2143
|
e.preventDefault(), s.contains(u) || s.appendChild(u);
|
|
2142
2144
|
let t = "touches" in e ? e.touches[0].clientX : e.clientX;
|
|
@@ -2160,11 +2162,11 @@ var Un = {
|
|
|
2160
2162
|
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);
|
|
2161
2163
|
}
|
|
2162
2164
|
};
|
|
2163
|
-
},
|
|
2165
|
+
}, Qn = (e) => ({
|
|
2164
2166
|
url: e.src || void 0,
|
|
2165
2167
|
previewWidth: e.width || void 0,
|
|
2166
2168
|
name: e.alt || void 0
|
|
2167
|
-
}),
|
|
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 = P((e = {}) => ({
|
|
2168
2170
|
type: "image",
|
|
2169
2171
|
propSchema: {
|
|
2170
2172
|
textAlignment: G.textAlignment,
|
|
@@ -2179,26 +2181,26 @@ var Un = {
|
|
|
2179
2181
|
}
|
|
2180
2182
|
},
|
|
2181
2183
|
content: "none"
|
|
2182
|
-
})),
|
|
2184
|
+
})), tr = (e = {}) => (e) => {
|
|
2183
2185
|
if (e.tagName === "IMG") {
|
|
2184
2186
|
if (e.closest("figure")) return;
|
|
2185
2187
|
let { backgroundColor: t } = K(e);
|
|
2186
2188
|
return {
|
|
2187
|
-
...
|
|
2189
|
+
...Qn(e),
|
|
2188
2190
|
backgroundColor: t
|
|
2189
2191
|
};
|
|
2190
2192
|
}
|
|
2191
2193
|
if (e.tagName === "FIGURE") {
|
|
2192
|
-
let t =
|
|
2194
|
+
let t = mn(e, "img");
|
|
2193
2195
|
if (!t) return;
|
|
2194
2196
|
let { targetElement: n, caption: r } = t, { backgroundColor: i } = K(e);
|
|
2195
2197
|
return {
|
|
2196
|
-
...
|
|
2198
|
+
...Qn(n),
|
|
2197
2199
|
backgroundColor: i,
|
|
2198
2200
|
caption: r
|
|
2199
2201
|
};
|
|
2200
2202
|
}
|
|
2201
|
-
},
|
|
2203
|
+
}, nr = (e = {}) => (t, n) => {
|
|
2202
2204
|
let r = document.createElement("div");
|
|
2203
2205
|
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>";
|
|
2204
2206
|
let i = document.createElement("div");
|
|
@@ -2206,19 +2208,19 @@ var Un = {
|
|
|
2206
2208
|
let a = document.createElement("img");
|
|
2207
2209
|
return a.className = "bn-visual-media", n.resolveFileUrl ? n.resolveFileUrl(t.props.url).then((e) => {
|
|
2208
2210
|
a.src = e;
|
|
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),
|
|
2210
|
-
},
|
|
2211
|
+
}) : 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), Zn(t, n, { dom: i }, i, r.firstElementChild);
|
|
2212
|
+
}, rr = (e = {}) => (e, t) => {
|
|
2211
2213
|
if (!e.props.url) return { dom: document.createElement("img") };
|
|
2212
2214
|
let n;
|
|
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 ?
|
|
2214
|
-
},
|
|
2215
|
+
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 = F(er, (e) => ({
|
|
2215
2217
|
meta: { fileBlockAccept: ["image/*"] },
|
|
2216
|
-
parse:
|
|
2217
|
-
render:
|
|
2218
|
-
toExternalHTML:
|
|
2218
|
+
parse: tr(e),
|
|
2219
|
+
render: nr(e),
|
|
2220
|
+
toExternalHTML: rr(e),
|
|
2219
2221
|
runsBefore: ["file"]
|
|
2220
|
-
})),
|
|
2221
|
-
let i = b(
|
|
2222
|
+
})), ar = (e, t, n) => ({ state: r, dispatch: i }) => !i || or(r.tr, e, t, n), or = (e, t, n, r) => {
|
|
2223
|
+
let i = b(Ae(e.doc, t));
|
|
2222
2224
|
if (!i.isBlockContainer) return !1;
|
|
2223
2225
|
let a = k(e), o = [{
|
|
2224
2226
|
type: i.bnBlock.node.type,
|
|
@@ -2231,9 +2233,9 @@ var Un = {
|
|
|
2231
2233
|
attrs: r ? { ...i.blockContent.node.attrs } : {}
|
|
2232
2234
|
}];
|
|
2233
2235
|
return e.split(t, 2, o), !0;
|
|
2234
|
-
},
|
|
2236
|
+
}, sr = (e, t) => {
|
|
2235
2237
|
let { blockInfo: n, selectionEmpty: r } = e.transact((e) => ({
|
|
2236
|
-
blockInfo:
|
|
2238
|
+
blockInfo: Me(e),
|
|
2237
2239
|
selectionEmpty: e.selection.anchor === e.selection.head
|
|
2238
2240
|
}));
|
|
2239
2241
|
if (!n.isBlockContainer) return !1;
|
|
@@ -2243,11 +2245,11 @@ var Un = {
|
|
|
2243
2245
|
type: "paragraph",
|
|
2244
2246
|
props: {}
|
|
2245
2247
|
});
|
|
2246
|
-
}), !0) : a.node.childCount > 0
|
|
2248
|
+
}), !0) : a.node.childCount > 0 && e.transact((e) => (e.deleteSelection(), e.scrollIntoView(), or(e, e.selection.from, !0)));
|
|
2247
2249
|
};
|
|
2248
2250
|
//#endregion
|
|
2249
2251
|
//#region src/blocks/ListItem/getListItemContent.ts
|
|
2250
|
-
function
|
|
2252
|
+
function cr(e, t, n) {
|
|
2251
2253
|
let a = r.fromSchema(t), o = e, s = document.createElement("div");
|
|
2252
2254
|
s.setAttribute("data-node-type", "blockGroup");
|
|
2253
2255
|
for (let e of Array.from(o.childNodes)) s.appendChild(e.cloneNode(!0));
|
|
@@ -2264,18 +2266,18 @@ function or(e, t, n) {
|
|
|
2264
2266
|
}
|
|
2265
2267
|
//#endregion
|
|
2266
2268
|
//#region src/blocks/ListItem/BulletListItem/block.ts
|
|
2267
|
-
var
|
|
2269
|
+
var lr = P(() => ({
|
|
2268
2270
|
type: "bulletListItem",
|
|
2269
2271
|
propSchema: { ...G },
|
|
2270
2272
|
content: "inline"
|
|
2271
|
-
})),
|
|
2273
|
+
})), ur = F(lr, {
|
|
2272
2274
|
meta: { isolating: !1 },
|
|
2273
2275
|
parse(e) {
|
|
2274
2276
|
if (e.tagName !== "LI") return;
|
|
2275
2277
|
let t = e.parentElement;
|
|
2276
2278
|
if (t === null || t.tagName === "UL" || t.tagName === "DIV" && t.parentElement?.tagName === "UL" || !e.closest("ul, ol")) return K(e);
|
|
2277
2279
|
},
|
|
2278
|
-
parseContent: ({ el: e, schema: t }) =>
|
|
2280
|
+
parseContent: ({ el: e, schema: t }) => cr(e, t, "bulletListItem"),
|
|
2279
2281
|
render() {
|
|
2280
2282
|
let e = document.createElement("p");
|
|
2281
2283
|
return {
|
|
@@ -2293,25 +2295,25 @@ var sr = P(() => ({
|
|
|
2293
2295
|
}, [n({
|
|
2294
2296
|
key: "bullet-list-item-shortcuts",
|
|
2295
2297
|
keyboardShortcuts: {
|
|
2296
|
-
Enter: ({ editor: e }) =>
|
|
2298
|
+
Enter: ({ editor: e }) => sr(e, "bulletListItem"),
|
|
2297
2299
|
"Mod-Shift-8": ({ editor: e }) => {
|
|
2298
2300
|
let t = e.getTextCursorPosition();
|
|
2299
|
-
return e.schema.blockSchema[t.block.type].content === "inline"
|
|
2301
|
+
return e.schema.blockSchema[t.block.type].content === "inline" && (e.updateBlock(t.block, {
|
|
2300
2302
|
type: "bulletListItem",
|
|
2301
2303
|
props: {}
|
|
2302
|
-
}), !0)
|
|
2304
|
+
}), !0);
|
|
2303
2305
|
}
|
|
2304
2306
|
},
|
|
2305
2307
|
inputRules: [{
|
|
2306
2308
|
find: /^\s?[-+*]\s$/,
|
|
2307
2309
|
replace({ editor: e }) {
|
|
2308
|
-
if (
|
|
2310
|
+
if (Me(e.prosemirrorState).blockNoteType !== "heading") return {
|
|
2309
2311
|
type: "bulletListItem",
|
|
2310
2312
|
props: {}
|
|
2311
2313
|
};
|
|
2312
2314
|
}
|
|
2313
2315
|
}]
|
|
2314
|
-
})]),
|
|
2316
|
+
})]), dr = P(() => ({
|
|
2315
2317
|
type: "checkListItem",
|
|
2316
2318
|
propSchema: {
|
|
2317
2319
|
...G,
|
|
@@ -2321,7 +2323,7 @@ var sr = P(() => ({
|
|
|
2321
2323
|
}
|
|
2322
2324
|
},
|
|
2323
2325
|
content: "inline"
|
|
2324
|
-
})),
|
|
2326
|
+
})), fr = F(dr, {
|
|
2325
2327
|
meta: { isolating: !1 },
|
|
2326
2328
|
parse(e) {
|
|
2327
2329
|
if (e.tagName === "input") return e.closest("[data-content-type]") || e.closest("li") ? void 0 : e.type === "checkbox" ? { checked: e.checked } : void 0;
|
|
@@ -2335,7 +2337,7 @@ var sr = P(() => ({
|
|
|
2335
2337
|
};
|
|
2336
2338
|
}
|
|
2337
2339
|
},
|
|
2338
|
-
parseContent: ({ el: e, schema: t }) =>
|
|
2340
|
+
parseContent: ({ el: e, schema: t }) => cr(e, t, "checkListItem"),
|
|
2339
2341
|
render(e, t) {
|
|
2340
2342
|
let n = document.createDocumentFragment(), r = document.createElement("input");
|
|
2341
2343
|
r.type = "checkbox", r.checked = e.props.checked, e.props.checked && r.setAttribute("checked", ""), r.disabled = !t.isEditable, r.addEventListener("change", () => {
|
|
@@ -2360,13 +2362,13 @@ var sr = P(() => ({
|
|
|
2360
2362
|
}, [n({
|
|
2361
2363
|
key: "check-list-item-shortcuts",
|
|
2362
2364
|
keyboardShortcuts: {
|
|
2363
|
-
Enter: ({ editor: e }) =>
|
|
2365
|
+
Enter: ({ editor: e }) => sr(e, "checkListItem"),
|
|
2364
2366
|
"Mod-Shift-9": ({ editor: e }) => {
|
|
2365
2367
|
let t = e.getTextCursorPosition();
|
|
2366
|
-
return e.schema.blockSchema[t.block.type].content === "inline"
|
|
2368
|
+
return e.schema.blockSchema[t.block.type].content === "inline" && (e.updateBlock(t.block, {
|
|
2367
2369
|
type: "checkListItem",
|
|
2368
2370
|
props: {}
|
|
2369
|
-
}), !0)
|
|
2371
|
+
}), !0);
|
|
2370
2372
|
}
|
|
2371
2373
|
},
|
|
2372
2374
|
inputRules: [{
|
|
@@ -2389,7 +2391,7 @@ var sr = P(() => ({
|
|
|
2389
2391
|
})]);
|
|
2390
2392
|
//#endregion
|
|
2391
2393
|
//#region src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts
|
|
2392
|
-
function
|
|
2394
|
+
function pr(e, t, n, r) {
|
|
2393
2395
|
let i = !!e.firstChild.attrs.start, a = b({
|
|
2394
2396
|
posBeforeNode: t,
|
|
2395
2397
|
node: e
|
|
@@ -2438,7 +2440,7 @@ function dr(e, t, n, r) {
|
|
|
2438
2440
|
hasStart: i
|
|
2439
2441
|
};
|
|
2440
2442
|
}
|
|
2441
|
-
function
|
|
2443
|
+
function mr(e, t) {
|
|
2442
2444
|
let n = /* @__PURE__ */ new Map(), r = t.decorations.map(e.mapping, e.doc), i = e.changedRange() ?? {
|
|
2443
2445
|
from: 0,
|
|
2444
2446
|
to: e.doc.nodeSize - 2
|
|
@@ -2446,8 +2448,8 @@ function fr(e, t) {
|
|
|
2446
2448
|
e.doc.nodesBetween(i.from, e.doc.nodeSize - 2, (t, s, c) => {
|
|
2447
2449
|
if (c && o.has(c)) return !1;
|
|
2448
2450
|
if (t.type.name === "blockContainer" && t.firstChild.type.name === "numberedListItem") {
|
|
2449
|
-
let { index: l, isFirst: u, hasStart: d } =
|
|
2450
|
-
if (r.find(s + 1, s + 1 + f.nodeSize, (e) => e.index === l && e.isFirst === u && e.hasStart === d).length === 0) a.push(
|
|
2451
|
+
let { index: l, isFirst: u, hasStart: d } = pr(t, s, e, n), f = e.doc.nodeAt(s + 1);
|
|
2452
|
+
if (r.find(s + 1, s + 1 + f.nodeSize, (e) => e.index === l && e.isFirst === u && e.hasStart === d).length === 0) a.push(ye.node(s + 1, s + 1 + f.nodeSize, { "data-index": l.toString() }, {
|
|
2451
2453
|
index: l,
|
|
2452
2454
|
isFirst: u,
|
|
2453
2455
|
hasStart: d
|
|
@@ -2458,20 +2460,20 @@ function fr(e, t) {
|
|
|
2458
2460
|
let s = a.flatMap((e) => r.find(e.from, e.to));
|
|
2459
2461
|
return { decorations: r.remove(s).add(e.doc, a) };
|
|
2460
2462
|
}
|
|
2461
|
-
var
|
|
2462
|
-
key: new
|
|
2463
|
+
var hr = () => new _e({
|
|
2464
|
+
key: new ve("numbered-list-indexing-decorations"),
|
|
2463
2465
|
state: {
|
|
2464
2466
|
init(e, t) {
|
|
2465
|
-
return
|
|
2467
|
+
return mr(t.tr, { decorations: be.empty });
|
|
2466
2468
|
},
|
|
2467
2469
|
apply(e, t) {
|
|
2468
|
-
return !e.docChanged && t.decorations ? t :
|
|
2470
|
+
return !e.docChanged && t.decorations ? t : mr(e, t);
|
|
2469
2471
|
}
|
|
2470
2472
|
},
|
|
2471
2473
|
props: { decorations(e) {
|
|
2472
|
-
return this.getState(e)?.decorations ??
|
|
2474
|
+
return this.getState(e)?.decorations ?? be.empty;
|
|
2473
2475
|
} }
|
|
2474
|
-
}),
|
|
2476
|
+
}), gr = P(() => ({
|
|
2475
2477
|
type: "numberedListItem",
|
|
2476
2478
|
propSchema: {
|
|
2477
2479
|
...G,
|
|
@@ -2481,7 +2483,7 @@ var pr = () => new ye({
|
|
|
2481
2483
|
}
|
|
2482
2484
|
},
|
|
2483
2485
|
content: "inline"
|
|
2484
|
-
})),
|
|
2486
|
+
})), _r = F(gr, {
|
|
2485
2487
|
meta: { isolating: !1 },
|
|
2486
2488
|
parse(e) {
|
|
2487
2489
|
if (e.tagName !== "LI") return;
|
|
@@ -2494,7 +2496,7 @@ var pr = () => new ye({
|
|
|
2494
2496
|
};
|
|
2495
2497
|
}
|
|
2496
2498
|
},
|
|
2497
|
-
parseContent: ({ el: e, schema: t }) =>
|
|
2499
|
+
parseContent: ({ el: e, schema: t }) => cr(e, t, "numberedListItem"),
|
|
2498
2500
|
render() {
|
|
2499
2501
|
let e = document.createElement("p");
|
|
2500
2502
|
return {
|
|
@@ -2514,7 +2516,7 @@ var pr = () => new ye({
|
|
|
2514
2516
|
inputRules: [{
|
|
2515
2517
|
find: /^\s?(\d+)\.\s$/,
|
|
2516
2518
|
replace({ match: e, editor: t }) {
|
|
2517
|
-
if (
|
|
2519
|
+
if (Me(t.prosemirrorState).blockNoteType === "heading") return;
|
|
2518
2520
|
let n = parseInt(e[1]);
|
|
2519
2521
|
return {
|
|
2520
2522
|
type: "numberedListItem",
|
|
@@ -2523,21 +2525,21 @@ var pr = () => new ye({
|
|
|
2523
2525
|
}
|
|
2524
2526
|
}],
|
|
2525
2527
|
keyboardShortcuts: {
|
|
2526
|
-
Enter: ({ editor: e }) =>
|
|
2528
|
+
Enter: ({ editor: e }) => sr(e, "numberedListItem"),
|
|
2527
2529
|
"Mod-Shift-7": ({ editor: e }) => {
|
|
2528
2530
|
let t = e.getTextCursorPosition();
|
|
2529
|
-
return e.schema.blockSchema[t.block.type].content === "inline"
|
|
2531
|
+
return e.schema.blockSchema[t.block.type].content === "inline" && (e.updateBlock(t.block, {
|
|
2530
2532
|
type: "numberedListItem",
|
|
2531
2533
|
props: {}
|
|
2532
|
-
}), !0)
|
|
2534
|
+
}), !0);
|
|
2533
2535
|
}
|
|
2534
2536
|
},
|
|
2535
|
-
prosemirrorPlugins: [
|
|
2536
|
-
})]),
|
|
2537
|
+
prosemirrorPlugins: [hr()]
|
|
2538
|
+
})]), vr = P(() => ({
|
|
2537
2539
|
type: "toggleListItem",
|
|
2538
2540
|
propSchema: { ...G },
|
|
2539
2541
|
content: "inline"
|
|
2540
|
-
})),
|
|
2542
|
+
})), yr = F(vr, {
|
|
2541
2543
|
meta: { isolating: !1 },
|
|
2542
2544
|
parse(e) {
|
|
2543
2545
|
if (e.tagName === "DETAILS") return K(e);
|
|
@@ -2549,13 +2551,13 @@ var pr = () => new ye({
|
|
|
2549
2551
|
parseContent: ({ el: e, schema: t }) => {
|
|
2550
2552
|
let n = e.tagName === "DETAILS" ? e : e.querySelector(":scope > details");
|
|
2551
2553
|
if (!n) throw Error("No details found in toggleListItem parseContent");
|
|
2552
|
-
return
|
|
2554
|
+
return Wn(n, t, "toggleListItem");
|
|
2553
2555
|
},
|
|
2554
2556
|
runsBefore: ["bulletListItem"],
|
|
2555
2557
|
render(e, t) {
|
|
2556
2558
|
let n = document.createElement("p");
|
|
2557
2559
|
return {
|
|
2558
|
-
...
|
|
2560
|
+
...Kn(e, t, n),
|
|
2559
2561
|
contentDOM: n
|
|
2560
2562
|
};
|
|
2561
2563
|
},
|
|
@@ -2572,20 +2574,20 @@ var pr = () => new ye({
|
|
|
2572
2574
|
}, [n({
|
|
2573
2575
|
key: "toggle-list-item-shortcuts",
|
|
2574
2576
|
keyboardShortcuts: {
|
|
2575
|
-
Enter: ({ editor: e }) =>
|
|
2577
|
+
Enter: ({ editor: e }) => sr(e, "toggleListItem"),
|
|
2576
2578
|
"Mod-Shift-6": ({ editor: e }) => {
|
|
2577
2579
|
let t = e.getTextCursorPosition();
|
|
2578
|
-
return e.schema.blockSchema[t.block.type].content === "inline"
|
|
2580
|
+
return e.schema.blockSchema[t.block.type].content === "inline" && (e.updateBlock(t.block, {
|
|
2579
2581
|
type: "toggleListItem",
|
|
2580
2582
|
props: {}
|
|
2581
|
-
}), !0)
|
|
2583
|
+
}), !0);
|
|
2582
2584
|
}
|
|
2583
2585
|
}
|
|
2584
|
-
})]),
|
|
2586
|
+
})]), br = P(() => ({
|
|
2585
2587
|
type: "pageBreak",
|
|
2586
2588
|
propSchema: {},
|
|
2587
2589
|
content: "none"
|
|
2588
|
-
})),
|
|
2590
|
+
})), xr = F(br, {
|
|
2589
2591
|
parse(e) {
|
|
2590
2592
|
if (e.tagName === "DIV" && e.hasAttribute("data-page-break")) return {};
|
|
2591
2593
|
},
|
|
@@ -2597,11 +2599,11 @@ var pr = () => new ye({
|
|
|
2597
2599
|
let e = document.createElement("div");
|
|
2598
2600
|
return e.setAttribute("data-page-break", ""), { dom: e };
|
|
2599
2601
|
}
|
|
2600
|
-
}),
|
|
2602
|
+
}), Sr = (e) => e.extend({ blockSpecs: { pageBreak: xr() } }), Cr = P(() => ({
|
|
2601
2603
|
type: "paragraph",
|
|
2602
2604
|
propSchema: G,
|
|
2603
2605
|
content: "inline"
|
|
2604
|
-
})),
|
|
2606
|
+
})), wr = F(Cr, {
|
|
2605
2607
|
meta: { isolating: !1 },
|
|
2606
2608
|
parse: (e) => {
|
|
2607
2609
|
if (e.tagName === "P" && e.textContent?.trim()) return K(e);
|
|
@@ -2625,19 +2627,19 @@ var pr = () => new ye({
|
|
|
2625
2627
|
key: "paragraph-shortcuts",
|
|
2626
2628
|
keyboardShortcuts: { "Mod-Alt-0": ({ editor: e }) => {
|
|
2627
2629
|
let t = e.getTextCursorPosition();
|
|
2628
|
-
return e.schema.blockSchema[t.block.type].content === "inline"
|
|
2630
|
+
return e.schema.blockSchema[t.block.type].content === "inline" && (e.updateBlock(t.block, {
|
|
2629
2631
|
type: "paragraph",
|
|
2630
2632
|
props: {}
|
|
2631
|
-
}), !0)
|
|
2633
|
+
}), !0);
|
|
2632
2634
|
} }
|
|
2633
|
-
})]),
|
|
2635
|
+
})]), Tr = P(() => ({
|
|
2634
2636
|
type: "quote",
|
|
2635
2637
|
propSchema: {
|
|
2636
2638
|
backgroundColor: G.backgroundColor,
|
|
2637
2639
|
textColor: G.textColor
|
|
2638
2640
|
},
|
|
2639
2641
|
content: "inline"
|
|
2640
|
-
})),
|
|
2642
|
+
})), Er = F(Tr, {
|
|
2641
2643
|
meta: { isolating: !1 },
|
|
2642
2644
|
parse(e) {
|
|
2643
2645
|
if (e.tagName === "BLOCKQUOTE") {
|
|
@@ -2666,10 +2668,10 @@ var pr = () => new ye({
|
|
|
2666
2668
|
key: "quote-block-shortcuts",
|
|
2667
2669
|
keyboardShortcuts: { "Mod-Alt-q": ({ editor: e }) => {
|
|
2668
2670
|
let t = e.getTextCursorPosition();
|
|
2669
|
-
return e.schema.blockSchema[t.block.type].content === "inline"
|
|
2671
|
+
return e.schema.blockSchema[t.block.type].content === "inline" && (e.updateBlock(t.block, {
|
|
2670
2672
|
type: "quote",
|
|
2671
2673
|
props: {}
|
|
2672
|
-
}), !0)
|
|
2674
|
+
}), !0);
|
|
2673
2675
|
} },
|
|
2674
2676
|
inputRules: [{
|
|
2675
2677
|
find: /* @__PURE__ */ RegExp("^>\\s$"),
|
|
@@ -2688,15 +2690,15 @@ var pr = () => new ye({
|
|
|
2688
2690
|
};
|
|
2689
2691
|
}
|
|
2690
2692
|
}]
|
|
2691
|
-
})]),
|
|
2693
|
+
})]), Dr = "blockLevelSuggestion";
|
|
2692
2694
|
function Y(e) {
|
|
2693
2695
|
return e && e.options.extensions.some((e) => {
|
|
2694
2696
|
if (e.type !== "mark") return !1;
|
|
2695
2697
|
let t = g(e, "group");
|
|
2696
2698
|
return typeof t == "string" && t.split(" ").includes("blockLevelSuggestion");
|
|
2697
|
-
}) ?
|
|
2699
|
+
}) ? Dr : "";
|
|
2698
2700
|
}
|
|
2699
|
-
var
|
|
2701
|
+
var Or = 120, kr = 31, Ar = s.create({
|
|
2700
2702
|
name: "BlockNoteTableExtension",
|
|
2701
2703
|
addProseMirrorPlugins: () => [ue({
|
|
2702
2704
|
cellMinWidth: 35,
|
|
@@ -2718,13 +2720,14 @@ var Er = 120, Dr = 31, Or = s.create({
|
|
|
2718
2720
|
};
|
|
2719
2721
|
},
|
|
2720
2722
|
extendNodeSchema(e) {
|
|
2721
|
-
|
|
2723
|
+
let t = {
|
|
2722
2724
|
name: e.name,
|
|
2723
2725
|
options: e.options,
|
|
2724
2726
|
storage: e.storage
|
|
2725
|
-
}
|
|
2727
|
+
};
|
|
2728
|
+
return { tableRole: d(g(e, "tableRole", t)) };
|
|
2726
2729
|
}
|
|
2727
|
-
}),
|
|
2730
|
+
}), jr = { textColor: G.textColor }, Mr = u.create({
|
|
2728
2731
|
name: "tableHeader",
|
|
2729
2732
|
addOptions() {
|
|
2730
2733
|
return { HTMLAttributes: {} };
|
|
@@ -2751,7 +2754,7 @@ var Er = 120, Dr = 31, Or = s.create({
|
|
|
2751
2754
|
parseHTML() {
|
|
2752
2755
|
return [{
|
|
2753
2756
|
tag: "th",
|
|
2754
|
-
getContent: (e, t) =>
|
|
2757
|
+
getContent: (e, t) => Lr(e, t)
|
|
2755
2758
|
}];
|
|
2756
2759
|
},
|
|
2757
2760
|
renderHTML({ HTMLAttributes: e }) {
|
|
@@ -2761,7 +2764,7 @@ var Er = 120, Dr = 31, Or = s.create({
|
|
|
2761
2764
|
0
|
|
2762
2765
|
];
|
|
2763
2766
|
}
|
|
2764
|
-
}),
|
|
2767
|
+
}), Nr = u.create({
|
|
2765
2768
|
name: "tableCell",
|
|
2766
2769
|
addOptions() {
|
|
2767
2770
|
return { HTMLAttributes: {} };
|
|
@@ -2788,7 +2791,7 @@ var Er = 120, Dr = 31, Or = s.create({
|
|
|
2788
2791
|
parseHTML() {
|
|
2789
2792
|
return [{
|
|
2790
2793
|
tag: "td",
|
|
2791
|
-
getContent: (e, t) =>
|
|
2794
|
+
getContent: (e, t) => Lr(e, t)
|
|
2792
2795
|
}];
|
|
2793
2796
|
},
|
|
2794
2797
|
renderHTML({ HTMLAttributes: e }) {
|
|
@@ -2798,7 +2801,7 @@ var Er = 120, Dr = 31, Or = s.create({
|
|
|
2798
2801
|
0
|
|
2799
2802
|
];
|
|
2800
2803
|
}
|
|
2801
|
-
}),
|
|
2804
|
+
}), Pr = u.create({
|
|
2802
2805
|
name: "table",
|
|
2803
2806
|
content: "tableRow+",
|
|
2804
2807
|
group: "blockContent",
|
|
@@ -2811,7 +2814,7 @@ var Er = 120, Dr = 31, Or = s.create({
|
|
|
2811
2814
|
return [{ tag: "table" }];
|
|
2812
2815
|
},
|
|
2813
2816
|
renderHTML({ node: e, HTMLAttributes: t }) {
|
|
2814
|
-
let n =
|
|
2817
|
+
let n = We(this.name, "table", {
|
|
2815
2818
|
...this.options.domAttributes?.blockContent || {},
|
|
2816
2819
|
...t
|
|
2817
2820
|
}, this.options.domAttributes?.inlineContent || {}), r = document.createElement("colgroup");
|
|
@@ -2843,7 +2846,7 @@ var Er = 120, Dr = 31, Or = s.create({
|
|
|
2843
2846
|
}
|
|
2844
2847
|
update(e) {
|
|
2845
2848
|
if (!super.update(e)) return !1;
|
|
2846
|
-
for (let [t, n] of Object.entries(
|
|
2849
|
+
for (let [t, n] of Object.entries(jr)) {
|
|
2847
2850
|
let r = M(t), i = e.attrs[t];
|
|
2848
2851
|
i === n.default ? this.dom.removeAttribute(r) : this.dom.setAttribute(r, String(i));
|
|
2849
2852
|
}
|
|
@@ -2856,7 +2859,7 @@ var Er = 120, Dr = 31, Or = s.create({
|
|
|
2856
2859
|
});
|
|
2857
2860
|
};
|
|
2858
2861
|
}
|
|
2859
|
-
}),
|
|
2862
|
+
}), Fr = u.create({
|
|
2860
2863
|
name: "tableParagraph",
|
|
2861
2864
|
group: "tableContent",
|
|
2862
2865
|
content: "inline*",
|
|
@@ -2878,7 +2881,7 @@ var Er = 120, Dr = 31, Or = s.create({
|
|
|
2878
2881
|
0
|
|
2879
2882
|
];
|
|
2880
2883
|
}
|
|
2881
|
-
}),
|
|
2884
|
+
}), Ir = u.create({
|
|
2882
2885
|
name: "tableRow",
|
|
2883
2886
|
addOptions() {
|
|
2884
2887
|
return { HTMLAttributes: {} };
|
|
@@ -2899,24 +2902,24 @@ var Er = 120, Dr = 31, Or = s.create({
|
|
|
2899
2902
|
];
|
|
2900
2903
|
}
|
|
2901
2904
|
});
|
|
2902
|
-
function
|
|
2905
|
+
function Lr(e, t) {
|
|
2903
2906
|
let n = r.fromSchema(t).parse(e, { topNode: t.nodes.blockGroup.create() }), a = [];
|
|
2904
2907
|
return n.content.descendants((e) => {
|
|
2905
2908
|
if (e.isInline) return a.push(e), !1;
|
|
2906
2909
|
}), i.fromArray(a);
|
|
2907
2910
|
}
|
|
2908
|
-
var
|
|
2909
|
-
node:
|
|
2911
|
+
var Rr = () => dt({
|
|
2912
|
+
node: Pr,
|
|
2910
2913
|
type: "table",
|
|
2911
2914
|
content: "table"
|
|
2912
|
-
},
|
|
2915
|
+
}, jr, [n({
|
|
2913
2916
|
key: "table-extensions",
|
|
2914
2917
|
tiptapExtensions: [
|
|
2915
|
-
Or,
|
|
2916
|
-
Nr,
|
|
2917
2918
|
Ar,
|
|
2918
|
-
|
|
2919
|
-
|
|
2919
|
+
Fr,
|
|
2920
|
+
Mr,
|
|
2921
|
+
Nr,
|
|
2922
|
+
Ir
|
|
2920
2923
|
]
|
|
2921
2924
|
}), n({
|
|
2922
2925
|
key: "table-keyboard-delete",
|
|
@@ -2934,11 +2937,11 @@ var Ir = () => pt({
|
|
|
2934
2937
|
(e.getPrevBlock(t) || e.getNextBlock(t)) && e.setTextCursorPosition(t), e.removeBlocks([t]);
|
|
2935
2938
|
}), !0);
|
|
2936
2939
|
} }
|
|
2937
|
-
})]),
|
|
2940
|
+
})]), zr = (e) => ({
|
|
2938
2941
|
url: e.src || void 0,
|
|
2939
2942
|
previewWidth: e.width || void 0,
|
|
2940
2943
|
name: e.getAttribute("data-name") || void 0
|
|
2941
|
-
}),
|
|
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 = P((e) => ({
|
|
2942
2945
|
type: "video",
|
|
2943
2946
|
propSchema: {
|
|
2944
2947
|
textAlignment: G.textAlignment,
|
|
@@ -2953,28 +2956,28 @@ var Ir = () => pt({
|
|
|
2953
2956
|
}
|
|
2954
2957
|
},
|
|
2955
2958
|
content: "none"
|
|
2956
|
-
})),
|
|
2959
|
+
})), Hr = (e) => (e) => {
|
|
2957
2960
|
if (e.tagName === "VIDEO") {
|
|
2958
2961
|
if (e.closest("figure")) return;
|
|
2959
2962
|
let { backgroundColor: t } = K(e);
|
|
2960
2963
|
return {
|
|
2961
|
-
...
|
|
2964
|
+
...zr(e),
|
|
2962
2965
|
backgroundColor: t
|
|
2963
2966
|
};
|
|
2964
2967
|
}
|
|
2965
2968
|
if (e.tagName === "FIGURE") {
|
|
2966
|
-
let t =
|
|
2969
|
+
let t = mn(e, "video");
|
|
2967
2970
|
if (!t) return;
|
|
2968
2971
|
let { targetElement: n, caption: r } = t, { backgroundColor: i } = K(e);
|
|
2969
2972
|
return {
|
|
2970
|
-
...
|
|
2973
|
+
...zr(n),
|
|
2971
2974
|
backgroundColor: i,
|
|
2972
2975
|
caption: r
|
|
2973
2976
|
};
|
|
2974
2977
|
}
|
|
2975
|
-
},
|
|
2978
|
+
}, Ur = F(Vr, (e) => ({
|
|
2976
2979
|
meta: { fileBlockAccept: ["video/*"] },
|
|
2977
|
-
parse:
|
|
2980
|
+
parse: Hr(e),
|
|
2978
2981
|
render(t, n) {
|
|
2979
2982
|
let r = document.createElement("div");
|
|
2980
2983
|
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>";
|
|
@@ -2983,15 +2986,15 @@ var Ir = () => pt({
|
|
|
2983
2986
|
let a = document.createElement("video");
|
|
2984
2987
|
return a.className = "bn-visual-media", n.resolveFileUrl ? n.resolveFileUrl(t.props.url).then((e) => {
|
|
2985
2988
|
a.src = e;
|
|
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),
|
|
2989
|
+
}) : 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), Zn(t, n, { dom: i }, i, r.firstElementChild);
|
|
2987
2990
|
},
|
|
2988
2991
|
toExternalHTML(e) {
|
|
2989
2992
|
if (!e.props.url) return { dom: document.createElement("video") };
|
|
2990
2993
|
let t;
|
|
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 ?
|
|
2994
|
+
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 };
|
|
2992
2995
|
},
|
|
2993
2996
|
runsBefore: ["file"]
|
|
2994
|
-
})),
|
|
2997
|
+
})), Wr = async (e) => {
|
|
2995
2998
|
let t = new FormData();
|
|
2996
2999
|
return t.append("file", e), (await (await fetch("https://tmpfiles.org/api/v1/upload", {
|
|
2997
3000
|
method: "POST",
|
|
@@ -3016,48 +3019,48 @@ function X(e, t, n) {
|
|
|
3016
3019
|
}
|
|
3017
3020
|
return !0;
|
|
3018
3021
|
}
|
|
3019
|
-
function
|
|
3022
|
+
function Gr(e, t, n, r) {
|
|
3020
3023
|
return X(t, n, r) && e.type === n;
|
|
3021
3024
|
}
|
|
3022
|
-
function
|
|
3025
|
+
function Kr(e) {
|
|
3023
3026
|
return e instanceof se;
|
|
3024
3027
|
}
|
|
3025
|
-
function
|
|
3028
|
+
function qr(e) {
|
|
3026
3029
|
let t = e.type.spec.tableRole;
|
|
3027
3030
|
return t === "cell" || t === "header_cell";
|
|
3028
3031
|
}
|
|
3029
3032
|
//#endregion
|
|
3030
3033
|
//#region src/extensions/FormattingToolbar/FormattingToolbar.ts
|
|
3031
|
-
var Z = n(({ editor:
|
|
3032
|
-
let n =
|
|
3034
|
+
var Z = n(({ editor: t }) => {
|
|
3035
|
+
let n = e(!1), r = () => t.transact((e) => {
|
|
3033
3036
|
if (e.selection.empty || e.selection instanceof re && e.doc.textBetween(e.selection.from, e.selection.to).length === 0) return !1;
|
|
3034
3037
|
let t = !1;
|
|
3035
|
-
return e.selection.content().content.descendants((e) => (e.type.spec.
|
|
3038
|
+
return e.selection.content().content.descendants((e) => (e.type.spec.content === "text*" && (t = !0), !t)), !t;
|
|
3036
3039
|
});
|
|
3037
3040
|
return {
|
|
3038
3041
|
key: "formattingToolbar",
|
|
3039
3042
|
store: n,
|
|
3040
|
-
mount({ dom:
|
|
3041
|
-
let a = !1, o = !1, s =
|
|
3043
|
+
mount({ dom: e, signal: i }) {
|
|
3044
|
+
let a = !1, o = !1, s = t.onChange(() => {
|
|
3042
3045
|
a || o || n.setState(r());
|
|
3043
|
-
}), c =
|
|
3046
|
+
}), c = t.onSelectionChange(() => {
|
|
3044
3047
|
a || o || n.setState(r());
|
|
3045
3048
|
});
|
|
3046
|
-
|
|
3049
|
+
e.addEventListener("pointerdown", () => {
|
|
3047
3050
|
a = !0, n.setState(!1);
|
|
3048
|
-
}, { signal: i }),
|
|
3049
|
-
a = !1,
|
|
3051
|
+
}, { signal: i }), t.prosemirrorView.root.addEventListener("pointerup", () => {
|
|
3052
|
+
a = !1, t.isFocused() && n.setState(r());
|
|
3050
3053
|
}, {
|
|
3051
3054
|
signal: i,
|
|
3052
3055
|
capture: !0
|
|
3053
|
-
}),
|
|
3056
|
+
}), e.addEventListener("pointercancel", () => {
|
|
3054
3057
|
a = !0;
|
|
3055
3058
|
}, {
|
|
3056
3059
|
signal: i,
|
|
3057
3060
|
capture: !0
|
|
3058
|
-
}),
|
|
3061
|
+
}), t.prosemirrorView.root.addEventListener("dragstart", () => {
|
|
3059
3062
|
o = !0, n.setState(!1);
|
|
3060
|
-
}, { signal: i }),
|
|
3063
|
+
}, { signal: i }), t.prosemirrorView.root.addEventListener("dragend", () => {
|
|
3061
3064
|
o = !1;
|
|
3062
3065
|
}, { signal: i }), i.addEventListener("abort", () => {
|
|
3063
3066
|
s(), c();
|
|
@@ -3067,7 +3070,7 @@ var Z = n(({ editor: e }) => {
|
|
|
3067
3070
|
});
|
|
3068
3071
|
//#endregion
|
|
3069
3072
|
//#region src/api/positionMapping.ts
|
|
3070
|
-
function
|
|
3073
|
+
function Jr(e, t, n = "left") {
|
|
3071
3074
|
let r = e.getExtension("yPositionMapping");
|
|
3072
3075
|
if (r) return r.mapPosition(t, n);
|
|
3073
3076
|
let i = e.getExtension("positionMapping");
|
|
@@ -3076,7 +3079,7 @@ function Kr(e, t, n = "left") {
|
|
|
3076
3079
|
}
|
|
3077
3080
|
//#endregion
|
|
3078
3081
|
//#region src/extensions/SuggestionMenu/SuggestionMenu.ts
|
|
3079
|
-
var
|
|
3082
|
+
var Yr = m((e) => e.type.name === "blockContainer"), Xr = class {
|
|
3080
3083
|
editor;
|
|
3081
3084
|
state;
|
|
3082
3085
|
emitUpdate;
|
|
@@ -3100,7 +3103,7 @@ var qr = m((e) => e.type.name === "blockContainer"), Jr = class {
|
|
|
3100
3103
|
};
|
|
3101
3104
|
update(e, t) {
|
|
3102
3105
|
let n = Q.getState(t), r = Q.getState(e.state), i = n === void 0 && r !== void 0, a = n !== void 0 && r === void 0;
|
|
3103
|
-
if (!i &&
|
|
3106
|
+
if (!i && (n === void 0 || r === void 0) && !a) return;
|
|
3104
3107
|
if (this.pluginState = a ? n : r, a || !this.editor.isEditable) {
|
|
3105
3108
|
this.state && (this.state.show = !1), this.emitUpdate(this.pluginState.triggerCharacter);
|
|
3106
3109
|
return;
|
|
@@ -3124,8 +3127,8 @@ var qr = m((e) => e.type.name === "blockContainer"), Jr = class {
|
|
|
3124
3127
|
to: this.editor.transact((e) => e.selection.from)
|
|
3125
3128
|
}).run();
|
|
3126
3129
|
};
|
|
3127
|
-
}, Q = new ne("SuggestionMenuPlugin"),
|
|
3128
|
-
let n = /* @__PURE__ */ new Map(), r, i =
|
|
3130
|
+
}, Q = new ne("SuggestionMenuPlugin"), Zr = n(({ editor: t }) => {
|
|
3131
|
+
let n = /* @__PURE__ */ new Map(), r, i = e(void 0);
|
|
3129
3132
|
return {
|
|
3130
3133
|
key: "suggestionMenu",
|
|
3131
3134
|
store: i,
|
|
@@ -3142,10 +3145,10 @@ var qr = m((e) => e.type.name === "blockContainer"), Jr = class {
|
|
|
3142
3145
|
r?.clearQuery();
|
|
3143
3146
|
},
|
|
3144
3147
|
shown: () => r?.state?.show || !1,
|
|
3145
|
-
openSuggestionMenu: (
|
|
3146
|
-
|
|
3147
|
-
n?.deleteTriggerCharacter &&
|
|
3148
|
-
triggerCharacter:
|
|
3148
|
+
openSuggestionMenu: (e, n) => {
|
|
3149
|
+
t.headless || (t.focus(), t.transact((t) => {
|
|
3150
|
+
n?.deleteTriggerCharacter && t.insertText(e), t.scrollIntoView().setMeta(Q, {
|
|
3151
|
+
triggerCharacter: e,
|
|
3149
3152
|
deleteTriggerCharacter: n?.deleteTriggerCharacter || !1,
|
|
3150
3153
|
ignoreQueryLength: n?.ignoreQueryLength || !1
|
|
3151
3154
|
});
|
|
@@ -3153,31 +3156,31 @@ var qr = m((e) => e.type.name === "blockContainer"), Jr = class {
|
|
|
3153
3156
|
},
|
|
3154
3157
|
prosemirrorPlugins: [new te({
|
|
3155
3158
|
key: Q,
|
|
3156
|
-
view: (
|
|
3159
|
+
view: (e) => (r = new Xr(t, (e, t) => {
|
|
3157
3160
|
i.setState({
|
|
3158
3161
|
...t,
|
|
3159
3162
|
triggerCharacter: e
|
|
3160
3163
|
});
|
|
3161
|
-
},
|
|
3164
|
+
}, e), r),
|
|
3162
3165
|
state: {
|
|
3163
3166
|
init() {},
|
|
3164
|
-
apply: (
|
|
3165
|
-
if (
|
|
3166
|
-
let o =
|
|
3167
|
+
apply: (e, n, i, a) => {
|
|
3168
|
+
if (e.selection.$from.parent.type.spec.code) return n;
|
|
3169
|
+
let o = e.getMeta(Q);
|
|
3167
3170
|
if (typeof o == "object" && o) {
|
|
3168
3171
|
n && r?.closeMenu();
|
|
3169
|
-
let
|
|
3172
|
+
let e = Jr(t, a.selection.from - o.triggerCharacter.length);
|
|
3170
3173
|
return {
|
|
3171
3174
|
triggerCharacter: o.triggerCharacter,
|
|
3172
3175
|
deleteTriggerCharacter: o.deleteTriggerCharacter !== !1,
|
|
3173
|
-
queryStartPos: () =>
|
|
3176
|
+
queryStartPos: () => e() + o.triggerCharacter.length,
|
|
3174
3177
|
query: "",
|
|
3175
3178
|
decorationId: `id_${Math.floor(Math.random() * 4294967295)}`,
|
|
3176
3179
|
ignoreQueryLength: o?.ignoreQueryLength
|
|
3177
3180
|
};
|
|
3178
3181
|
}
|
|
3179
3182
|
if (n === void 0) return n;
|
|
3180
|
-
if (a.selection.from !== a.selection.to || o === null ||
|
|
3183
|
+
if (a.selection.from !== a.selection.to || o === null || e.getMeta("focus") || e.getMeta("blur") || e.getMeta("pointer") || n.triggerCharacter !== void 0 && a.selection.from < n.queryStartPos() || !a.selection.$from.sameParent(a.doc.resolve(n.queryStartPos()))) return;
|
|
3181
3184
|
let s = { ...n };
|
|
3182
3185
|
return s.query = a.doc.textBetween(n.queryStartPos(), a.selection.from), s;
|
|
3183
3186
|
}
|
|
@@ -3198,14 +3201,14 @@ var qr = m((e) => e.type.name === "blockContainer"), Jr = class {
|
|
|
3198
3201
|
let t = this.getState(e);
|
|
3199
3202
|
if (t === void 0) return null;
|
|
3200
3203
|
if (!t.deleteTriggerCharacter) {
|
|
3201
|
-
let n =
|
|
3202
|
-
if (n) return
|
|
3204
|
+
let n = Yr(e.selection);
|
|
3205
|
+
if (n) return Se.create(e.doc, [xe.node(n.pos, n.pos + n.node.nodeSize, {
|
|
3203
3206
|
nodeName: "span",
|
|
3204
3207
|
class: "bn-suggestion-decorator",
|
|
3205
3208
|
"data-decoration-id": t.decorationId
|
|
3206
3209
|
})]);
|
|
3207
3210
|
}
|
|
3208
|
-
return
|
|
3211
|
+
return Se.create(e.doc, [xe.inline(t.queryStartPos() - t.triggerCharacter.length, t.queryStartPos(), {
|
|
3209
3212
|
nodeName: "span",
|
|
3210
3213
|
class: "bn-suggestion-decorator",
|
|
3211
3214
|
"data-decoration-id": t.decorationId
|
|
@@ -3217,7 +3220,7 @@ var qr = m((e) => e.type.name === "blockContainer"), Jr = class {
|
|
|
3217
3220
|
});
|
|
3218
3221
|
//#endregion
|
|
3219
3222
|
//#region src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts
|
|
3220
|
-
function
|
|
3223
|
+
function Qr(e) {
|
|
3221
3224
|
let t = e.getTextCursorPosition().block, n = e.schema.blockSchema[t.type].content;
|
|
3222
3225
|
for (; n === "none";) {
|
|
3223
3226
|
if (t = e.getTextCursorPosition().nextBlock, t === void 0) {
|
|
@@ -3232,9 +3235,9 @@ function $(e, t) {
|
|
|
3232
3235
|
let n = e.getTextCursorPosition().block;
|
|
3233
3236
|
if (n.content === void 0) throw Error("Slash Menu open in a block that doesn't contain content.");
|
|
3234
3237
|
let r;
|
|
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)),
|
|
3238
|
+
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)), Qr(e), r;
|
|
3236
3239
|
}
|
|
3237
|
-
function
|
|
3240
|
+
function $r(e) {
|
|
3238
3241
|
let t = [];
|
|
3239
3242
|
return X(e, "heading", { level: "number" }) && (e.schema.blockSchema.heading.propSchema.level.values || []).filter((e) => e <= 3).forEach((n) => {
|
|
3240
3243
|
t.push({
|
|
@@ -3382,7 +3385,7 @@ function Zr(e) {
|
|
|
3382
3385
|
});
|
|
3383
3386
|
}), t.push({
|
|
3384
3387
|
onItemClick: () => {
|
|
3385
|
-
e.getExtension(
|
|
3388
|
+
e.getExtension(Zr)?.openSuggestionMenu(":", {
|
|
3386
3389
|
deleteTriggerCharacter: !0,
|
|
3387
3390
|
ignoreQueryLength: !0
|
|
3388
3391
|
});
|
|
@@ -3391,17 +3394,17 @@ function Zr(e) {
|
|
|
3391
3394
|
...e.dictionary.slash_menu.emoji
|
|
3392
3395
|
}), t;
|
|
3393
3396
|
}
|
|
3394
|
-
function
|
|
3397
|
+
function ei(e, t) {
|
|
3395
3398
|
return e.filter(({ title: e, aliases: n }) => e.toLowerCase().includes(t.toLowerCase()) || n && n.filter((e) => e.toLowerCase().includes(t.toLowerCase())).length !== 0);
|
|
3396
3399
|
}
|
|
3397
3400
|
//#endregion
|
|
3398
3401
|
//#region src/blocks/PageBreak/getPageBreakSlashMenuItems.ts
|
|
3399
|
-
function
|
|
3402
|
+
function ti(e) {
|
|
3400
3403
|
return "pageBreak" in e.schema.blockSchema;
|
|
3401
3404
|
}
|
|
3402
|
-
function
|
|
3405
|
+
function ni(e) {
|
|
3403
3406
|
let t = [];
|
|
3404
|
-
return
|
|
3407
|
+
return ti(e) && t.push({
|
|
3405
3408
|
...e.dictionary.slash_menu.page_break,
|
|
3406
3409
|
onItemClick: () => {
|
|
3407
3410
|
$(e, { type: "pageBreak" });
|
|
@@ -3411,22 +3414,22 @@ function ei(e) {
|
|
|
3411
3414
|
}
|
|
3412
3415
|
//#endregion
|
|
3413
3416
|
//#region src/blocks/defaultBlocks.ts
|
|
3414
|
-
var
|
|
3415
|
-
audio:
|
|
3416
|
-
bulletListItem:
|
|
3417
|
-
checkListItem:
|
|
3418
|
-
codeBlock:
|
|
3419
|
-
divider:
|
|
3420
|
-
file:
|
|
3421
|
-
heading:
|
|
3422
|
-
image:
|
|
3423
|
-
numberedListItem:
|
|
3424
|
-
paragraph:
|
|
3425
|
-
quote:
|
|
3426
|
-
table:
|
|
3427
|
-
toggleListItem:
|
|
3428
|
-
video:
|
|
3429
|
-
},
|
|
3417
|
+
var ri = {
|
|
3418
|
+
audio: Dn(),
|
|
3419
|
+
bulletListItem: ur(),
|
|
3420
|
+
checkListItem: fr(),
|
|
3421
|
+
codeBlock: Ln(),
|
|
3422
|
+
divider: zn(),
|
|
3423
|
+
file: Un(),
|
|
3424
|
+
heading: Xn(),
|
|
3425
|
+
image: ir(),
|
|
3426
|
+
numberedListItem: _r(),
|
|
3427
|
+
paragraph: wr(),
|
|
3428
|
+
quote: Er(),
|
|
3429
|
+
table: Rr(),
|
|
3430
|
+
toggleListItem: yr(),
|
|
3431
|
+
video: Ur()
|
|
3432
|
+
}, ii = wt({
|
|
3430
3433
|
type: "textColor",
|
|
3431
3434
|
propSchema: "string"
|
|
3432
3435
|
}, {
|
|
@@ -3447,7 +3450,7 @@ var ti = {
|
|
|
3447
3450
|
parse: (e) => {
|
|
3448
3451
|
if (e.tagName === "SPAN" && e.style.color) return e.style.color;
|
|
3449
3452
|
}
|
|
3450
|
-
}),
|
|
3453
|
+
}), ai = wt({
|
|
3451
3454
|
type: "backgroundColor",
|
|
3452
3455
|
propSchema: "string"
|
|
3453
3456
|
}, {
|
|
@@ -3468,12 +3471,12 @@ var ti = {
|
|
|
3468
3471
|
parse: (e) => {
|
|
3469
3472
|
if (e.tagName === "SPAN" && e.style.backgroundColor) return e.style.backgroundColor;
|
|
3470
3473
|
}
|
|
3471
|
-
}),
|
|
3472
|
-
bold: L(
|
|
3473
|
-
italic: L(
|
|
3474
|
-
underline: L(
|
|
3475
|
-
strike: L(
|
|
3476
|
-
code: L(
|
|
3474
|
+
}), oi = {
|
|
3475
|
+
bold: L(Ce, "boolean"),
|
|
3476
|
+
italic: L(Te, "boolean"),
|
|
3477
|
+
underline: L(De, "boolean"),
|
|
3478
|
+
strike: L(Ee, "boolean"),
|
|
3479
|
+
code: L(we.extend({ addInputRules() {
|
|
3477
3480
|
return [_({
|
|
3478
3481
|
find: /(^|[^`])`([^`]+)`(?!`)$/,
|
|
3479
3482
|
type: this.type
|
|
@@ -3485,9 +3488,9 @@ var ti = {
|
|
|
3485
3488
|
}
|
|
3486
3489
|
})];
|
|
3487
3490
|
} }), "boolean"),
|
|
3488
|
-
textColor:
|
|
3489
|
-
backgroundColor:
|
|
3490
|
-
},
|
|
3491
|
+
textColor: ii,
|
|
3492
|
+
backgroundColor: ai
|
|
3493
|
+
}, si = St(oi), ci = {
|
|
3491
3494
|
text: {
|
|
3492
3495
|
config: "text",
|
|
3493
3496
|
implementation: {}
|
|
@@ -3496,16 +3499,16 @@ var ti = {
|
|
|
3496
3499
|
config: "link",
|
|
3497
3500
|
implementation: {}
|
|
3498
3501
|
}
|
|
3499
|
-
},
|
|
3502
|
+
}, li = yt(ci), ui = class e extends Pt {
|
|
3500
3503
|
static create(t) {
|
|
3501
3504
|
return new e({
|
|
3502
|
-
blockSpecs: t?.blockSpecs ??
|
|
3503
|
-
inlineContentSpecs: t?.inlineContentSpecs ??
|
|
3504
|
-
styleSpecs: t?.styleSpecs ??
|
|
3505
|
+
blockSpecs: t?.blockSpecs ?? ri,
|
|
3506
|
+
inlineContentSpecs: t?.inlineContentSpecs ?? ci,
|
|
3507
|
+
styleSpecs: t?.styleSpecs ?? oi
|
|
3505
3508
|
});
|
|
3506
3509
|
}
|
|
3507
3510
|
};
|
|
3508
3511
|
//#endregion
|
|
3509
|
-
export {
|
|
3512
|
+
export { Xn as $, Le as $n, I as $t, Tr as A, Ze as An, cn as At, _r as B, He as Bn, Kt as Bt, Hr as C, tt as Cn, G as Ct, Or as D, at as Dn, K as Dt, kr as E, rt as En, fn as Et, xr as F, Je as Fn, $t as Ft, ar as G, w as Gn, Lt as Gt, dr as H, O as Hn, Wt as Ht, Sr as I, We as In, H as It, ir as J, C as Jn, Bt as Jt, $n as K, T as Kn, Ft as Kt, vr as L, Ge as Ln, V as Lt, Cr as M, k as Mn, en as Mt, wr as N, A as Nn, U as Nt, Dr as O, $e as On, un as Ot, br as P, et as Pn, Qt as Pt, Yn as Q, x as Qn, Ct as Qt, yr as R, Ke as Rn, Xt as Rt, Ur as S, nt as Sn, q as St, jr as T, j as Tn, pn as Tt, lr as U, E as Un, Ht as Ut, fr as V, Ue as Vn, Gt as Vt, ur as W, Ve as Wn, Rt as Wt, nr as X, Re as Xn, Mt as Xt, tr as Y, Be as Yn, Pt as Yt, rr as Z, ze as Zn, wt as Zt, qr as _, ct as _n, En as _t, si as a, gt as an, Ae as ar, Rn as at, Br as b, ot as bn, xn as bt, ni as c, yt as cn, Ln as ct, $ as d, P as dn, An as dt, xt as en, b as er, Kn as et, Zr as f, F as fn, On as ft, X as g, lt as gn, Tn as gt, Gr as h, ut as hn, wn as ht, ci as i, ht as in, y as ir, Hn as it, Er as j, Qe as jn, sn as jt, Y as k, Xe as kn, W as kt, ei as l, mt as ln, Pn as lt, Z as m, dt as mn, Sn as mt, ri as n, St as nn, je as nr, Vn as nt, oi as o, vt as on, ke as or, zn as ot, Jr as p, pt as pn, kn as pt, er as q, S as qn, zt as qt, li as r, bt as rn, Me as rr, Un as rt, ti as s, _t as sn, Oe as sr, In as st, ui as t, L as tn, Ne as tr, Gn as tt, $r as u, ft as un, Nn as ut, Kr as v, N as vn, Cn as vt, Rr as w, it as wn, dn as wt, Vr as x, st as xn, J as xt, Wr as y, M as yn, Dn as yt, gr as z, D as zn, Ut as zt };
|
|
3510
3513
|
|
|
3511
|
-
//# sourceMappingURL=blocks-
|
|
3514
|
+
//# sourceMappingURL=blocks-CzQLehlc.js.map
|