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