@blocknote/core 0.53.0 → 0.54.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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-CTB_5Vyj.cjs +12 -0
- package/dist/blocks-CTB_5Vyj.cjs.map +1 -0
- package/dist/{blocks-BEJW9OM_.js → blocks-Dol85hpH.js} +680 -670
- package/dist/blocks-Dol85hpH.js.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-B7Rsp_Ft.cjs +58 -0
- package/dist/extensions-B7Rsp_Ft.cjs.map +1 -0
- package/dist/{extensions-BR5hkAio.js → extensions-D6JcJCwd.js} +735 -457
- package/dist/extensions-D6JcJCwd.js.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +4 -4
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +199 -1
- package/dist/locales.js.map +1 -1
- package/dist/{src-BUXut68d.js → src-Buuo5l7X.js} +924 -851
- package/dist/src-Buuo5l7X.js.map +1 -0
- package/dist/src-C54Ok9E0.cjs +23 -0
- package/dist/src-C54Ok9E0.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 +245 -242
- package/dist/y.js.map +1 -1
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.cjs.map +1 -1
- package/dist/yjs.js +79 -67
- package/dist/yjs.js.map +1 -1
- package/package.json +17 -18
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +2505 -763
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +42 -0
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +16 -4
- package/src/api/exporters/markdown/htmlToMarkdown.ts +45 -10
- package/src/api/getBlocksChangedByTransaction.test.ts +211 -0
- package/src/api/getBlocksChangedByTransaction.ts +48 -12
- package/src/api/getChangedRange.ts +54 -0
- package/src/api/nodeConversions/blockToNode.ts +5 -1
- package/src/api/nodeConversions/nodeToBlock.ts +3 -0
- package/src/api/pmUtil.ts +16 -8
- package/src/blocks/Code/CodeBlockOptions.ts +83 -0
- package/src/blocks/Code/block.test.ts +1 -1
- package/src/blocks/Code/block.ts +29 -281
- package/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.ts +120 -0
- package/src/blocks/Code/helpers/parse/parsePreCode.ts +45 -0
- package/src/blocks/Code/helpers/render/createCodeBlock.ts +98 -0
- package/src/blocks/Code/helpers/toExternalHTML/createPreCode.ts +14 -0
- package/src/blocks/index.ts +3 -1
- package/src/comments/extension.ts +2 -4
- package/src/editor/Block.css +273 -2
- package/src/editor/BlockNoteEditor.ts +25 -4
- package/src/editor/BlockNoteExtension.ts +1 -1
- package/src/editor/managers/ExtensionManager/extensions.ts +6 -0
- package/src/editor/performance.test.ts +45 -0
- package/src/exporter/ExportImage.ts +50 -0
- package/src/exporter/Exporter.test.ts +186 -0
- package/src/exporter/Exporter.ts +66 -14
- 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/PreviousBlockType/PreviousBlockType.test.ts +21 -0
- package/src/extensions/PreviousBlockType/PreviousBlockType.ts +5 -3
- package/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.ts +192 -0
- package/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.ts +142 -0
- package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.ts +120 -0
- package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.ts +89 -0
- package/src/extensions/SyntaxHighlighting/inlineHighlight.test.ts +135 -0
- package/src/extensions/SyntaxHighlighting/shiki.ts +116 -0
- package/src/extensions/TableHandles/TableHandles.browser.test.ts +305 -0
- package/src/extensions/TableHandles/TableHandles.ts +82 -41
- 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/fonts/inter.css +9 -9
- package/src/i18n/locales/ar.ts +9 -0
- package/src/i18n/locales/de.ts +9 -0
- package/src/i18n/locales/en.ts +9 -0
- package/src/i18n/locales/es.ts +9 -0
- package/src/i18n/locales/fa.ts +9 -0
- package/src/i18n/locales/fr.ts +9 -0
- package/src/i18n/locales/he.ts +9 -0
- package/src/i18n/locales/hr.ts +9 -0
- package/src/i18n/locales/is.ts +9 -0
- package/src/i18n/locales/it.ts +9 -0
- package/src/i18n/locales/ja.ts +9 -0
- package/src/i18n/locales/ko.ts +9 -0
- package/src/i18n/locales/nl.ts +9 -0
- package/src/i18n/locales/no.ts +9 -0
- package/src/i18n/locales/pl.ts +9 -0
- package/src/i18n/locales/pt.ts +9 -0
- package/src/i18n/locales/ru.ts +9 -0
- package/src/i18n/locales/sk.ts +9 -0
- package/src/i18n/locales/uk.ts +9 -0
- package/src/i18n/locales/uz.ts +9 -0
- package/src/i18n/locales/vi.ts +9 -0
- package/src/i18n/locales/zh-tw.ts +9 -0
- package/src/i18n/locales/zh.ts +9 -0
- package/src/index.ts +5 -1
- package/src/schema/blocks/createSpec.ts +5 -7
- 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 +175 -17
- package/src/schema/inlineContent/internal.ts +21 -2
- package/src/schema/inlineContent/types.ts +35 -5
- package/src/schema/nodeViewMutations.test.ts +81 -56
- package/src/schema/nodeViewMutations.ts +30 -27
- package/src/schema/schema.test.ts +110 -0
- package/src/schema/schema.ts +13 -4
- package/src/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 +18 -9
- package/src/y/extensions/Versioning.test.ts +20 -7
- package/src/y/versioning/__test__/yhub.test.ts +92 -59
- package/src/y/versioning/yhub.ts +35 -29
- 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/getChangedRange.d.ts +14 -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/index.d.ts +3 -1
- 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 +30 -0
- package/types/src/exporter/Exporter.test.d.ts +1 -0
- package/types/src/exporter/index.d.ts +1 -0
- package/types/src/exporter/mapping.d.ts +1 -1
- package/types/src/extensions/FilePanel/FilePanel.d.ts +1 -1
- package/types/src/extensions/FormattingToolbar/FormattingToolbar.d.ts +1 -1
- package/types/src/extensions/InlineContentBoundaryEdit/InlineContentBoundaryEdit.d.ts +5 -0
- package/types/src/extensions/ShowSelection/ShowSelection.d.ts +1 -5
- package/types/src/extensions/SideMenu/SideMenu.d.ts +1 -1
- package/types/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.d.ts +45 -0
- package/types/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.d.ts +49 -0
- package/types/src/extensions/SuggestionMenu/SuggestionMenu.d.ts +1 -11
- package/types/src/extensions/SyntaxHighlighting/SyntaxHighlighting.d.ts +44 -0
- package/types/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.d.ts +1 -0
- package/types/src/extensions/SyntaxHighlighting/inlineHighlight.test.d.ts +1 -0
- package/types/src/extensions/SyntaxHighlighting/shiki.d.ts +13 -0
- package/types/src/extensions/TableHandles/TableHandles.browser.test.d.ts +1 -0
- package/types/src/extensions/TableHandles/TableHandles.d.ts +4 -1
- package/types/src/extensions/Versioning/Versioning.d.ts +1 -35
- package/types/src/extensions/index.d.ts +4 -0
- package/types/src/i18n/locales/en.d.ts +9 -0
- package/types/src/i18n/locales/fa.d.ts +9 -0
- package/types/src/i18n/locales/sk.d.ts +9 -0
- package/types/src/index.d.ts +2 -1
- package/types/src/schema/blocks/types.d.ts +36 -3
- package/types/src/schema/inlineContent/createSpec.d.ts +35 -3
- package/types/src/schema/inlineContent/createSpec.test.d.ts +1 -0
- package/types/src/schema/inlineContent/internal.d.ts +3 -2
- package/types/src/schema/inlineContent/types.d.ts +22 -3
- package/types/src/schema/nodeViewMutations.d.ts +2 -2
- package/types/src/schema/schema.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/y/versioning/yhub.d.ts +3 -2
- package/types/src/yjs/comments/RESTYjsThreadStore.test.d.ts +1 -0
- package/types/src/yjs/extensions/ForkYDoc.d.ts +1 -5
- package/types/src/yjs/extensions/index.d.ts +1 -5
- package/dist/BlockNoteExtension-B_IEJHS8.js +0 -38
- package/dist/BlockNoteExtension-B_IEJHS8.js.map +0 -1
- package/dist/BlockNoteExtension-M0znTzxP.cjs +0 -2
- package/dist/BlockNoteExtension-M0znTzxP.cjs.map +0 -1
- package/dist/UserStore-QbbPFj0z.js.map +0 -1
- package/dist/blocks-BEJW9OM_.js.map +0 -1
- package/dist/blocks-BPmJglFo.cjs +0 -12
- package/dist/blocks-BPmJglFo.cjs.map +0 -1
- package/dist/en-C5Z4Ag9_.cjs +0 -2
- package/dist/en-C5Z4Ag9_.cjs.map +0 -1
- package/dist/en-CGKXfWma.js.map +0 -1
- package/dist/extensions-AitWbYdJ.cjs +0 -52
- package/dist/extensions-AitWbYdJ.cjs.map +0 -1
- package/dist/extensions-BR5hkAio.js.map +0 -1
- package/dist/src-BHPuOo7W.cjs +0 -21
- package/dist/src-BHPuOo7W.cjs.map +0 -1
- package/dist/src-BUXut68d.js.map +0 -1
- package/src/blocks/Code/shiki.ts +0 -73
- package/src/blocks/File/helpers/uploadToTmpFilesDotOrg_DEV_ONLY.ts +0 -20
- package/types/src/blocks/Code/shiki.d.ts +0 -4
- package/types/src/blocks/File/helpers/uploadToTmpFilesDotOrg_DEV_ONLY.d.ts +0 -6
|
@@ -1,40 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as y, t as b } from "./BlockNoteExtension-
|
|
3
|
-
import { n as re } from "./UserStore-
|
|
4
|
-
import { DOMSerializer as
|
|
5
|
-
import { Mapping as
|
|
6
|
-
import { combineTransactionSteps as
|
|
1
|
+
import { Bt as e, Gt as t, Hn as n, Ht as r, It as i, Kt as a, Lt as o, Nt as s, Pt as c, Rt as l, Tn as u, Ut as d, Vt as f, Wt as p, _ as m, ar as h, h as g, qt as ee, r as te, v as _, wn as v, zt as ne } from "./blocks-Dol85hpH.js";
|
|
2
|
+
import { n as y, t as b } from "./BlockNoteExtension-CbvDA0F7.js";
|
|
3
|
+
import { n as re } from "./UserStore-C4TzkGEn.js";
|
|
4
|
+
import { DOMSerializer as x, Fragment as S, Slice as ie } from "prosemirror-model";
|
|
5
|
+
import { Mapping as ae, dropPoint as oe } from "prosemirror-transform";
|
|
6
|
+
import { combineTransactionSteps as se, findChildrenInRange as ce, posToDOMRect as le } from "@tiptap/core";
|
|
7
7
|
import { uuidv4 as ue } from "lib0/random";
|
|
8
|
-
import { NodeSelection as de, Plugin as C, PluginKey as w, Selection as T, TextSelection as
|
|
9
|
-
import { DOMParser as
|
|
10
|
-
import { CellSelection as
|
|
11
|
-
import { Plugin as
|
|
12
|
-
import { Decoration as
|
|
13
|
-
import
|
|
14
|
-
import { history as
|
|
15
|
-
|
|
8
|
+
import { NodeSelection as de, Plugin as C, PluginKey as w, Selection as T, TextSelection as E } from "prosemirror-state";
|
|
9
|
+
import { DOMParser as fe, Slice as pe } from "@tiptap/pm/model";
|
|
10
|
+
import { CellSelection as me, addColumnAfter as he, addColumnBefore as ge, addRowAfter as _e, addRowBefore as ve, deleteColumn as ye, deleteRow as be, mergeCells as xe, splitCell as Se } from "prosemirror-tables";
|
|
11
|
+
import { Plugin as Ce, PluginKey as we, TextSelection as Te } from "@tiptap/pm/state";
|
|
12
|
+
import { Decoration as D, DecorationSet as O } from "prosemirror-view";
|
|
13
|
+
import Ee from "fast-deep-equal";
|
|
14
|
+
import { history as De, redo as Oe, undo as ke } from "@tiptap/pm/history";
|
|
15
|
+
import { createHighlightPlugin as Ae } from "prosemirror-highlight";
|
|
16
|
+
import { createParser as je } from "prosemirror-highlight/shiki";
|
|
17
|
+
function Me(e) {
|
|
16
18
|
let t = Array.from(e.classList).filter((e) => !e.startsWith("bn-")) || [];
|
|
17
19
|
t.length > 0 ? e.className = t.join(" ") : e.removeAttribute("class");
|
|
18
20
|
}
|
|
19
|
-
function
|
|
20
|
-
let
|
|
21
|
+
function Ne(e, t, r, a) {
|
|
22
|
+
let s;
|
|
21
23
|
if (!t) throw Error("blockContent is required");
|
|
22
|
-
if (typeof t == "string")
|
|
23
|
-
else if (Array.isArray(t))
|
|
24
|
-
else if (t.type === "tableContent")
|
|
25
|
-
else throw new
|
|
26
|
-
let
|
|
27
|
-
for (let t of
|
|
28
|
-
let
|
|
29
|
-
if (
|
|
30
|
-
let
|
|
24
|
+
if (typeof t == "string") s = i([t], e.pmSchema, a?.blockType);
|
|
25
|
+
else if (Array.isArray(t)) s = i(t, e.pmSchema, a?.blockType);
|
|
26
|
+
else if (t.type === "tableContent") s = o(t, e.pmSchema);
|
|
27
|
+
else throw new n(t.type);
|
|
28
|
+
let c = (a?.document ?? document).createDocumentFragment();
|
|
29
|
+
for (let t of s) if (t.type.name !== "text" && e.schema.inlineContentSchema[t.type.name]) {
|
|
30
|
+
let n = e.schema.inlineContentSpecs[t.type.name].implementation;
|
|
31
|
+
if (n) {
|
|
32
|
+
let i = u(t, e.schema.inlineContentSchema, e.schema.styleSchema), o = n.toExternalHTML ? n.toExternalHTML(i, e) : n.render.call({
|
|
31
33
|
renderType: "dom",
|
|
32
34
|
props: void 0
|
|
33
|
-
},
|
|
34
|
-
if (
|
|
35
|
-
if (
|
|
36
|
-
let e =
|
|
37
|
-
|
|
35
|
+
}, i, () => {}, e);
|
|
36
|
+
if (o) {
|
|
37
|
+
if (c.appendChild(o.dom), o.contentDOM) {
|
|
38
|
+
let e = r.serializeFragment(t.content, a);
|
|
39
|
+
o.contentDOM.dataset.editable = "", o.contentDOM.appendChild(e);
|
|
38
40
|
}
|
|
39
41
|
continue;
|
|
40
42
|
}
|
|
@@ -45,17 +47,17 @@ function Me(e, t, n, r) {
|
|
|
45
47
|
let t = (e.schema.styleSpecs[r.type.name].implementation.toExternalHTML ?? e.schema.styleSpecs[r.type.name].implementation.render)(r.attrs.stringValue, e);
|
|
46
48
|
t.contentDOM.appendChild(n), n = t.dom;
|
|
47
49
|
} else {
|
|
48
|
-
let e = r.type.spec.toDOM(r, !0), t =
|
|
50
|
+
let e = r.type.spec.toDOM(r, !0), t = x.renderSpec(document, e);
|
|
49
51
|
t.contentDOM.appendChild(n), n = t.dom;
|
|
50
52
|
}
|
|
51
|
-
|
|
53
|
+
c.appendChild(n);
|
|
52
54
|
} else {
|
|
53
|
-
let e =
|
|
54
|
-
|
|
55
|
+
let e = r.serializeFragment(S.from([t]), a);
|
|
56
|
+
c.appendChild(e);
|
|
55
57
|
}
|
|
56
|
-
return
|
|
58
|
+
return c.childNodes.length === 1 && c.firstChild?.nodeType === 1 && Me(c.firstChild), c;
|
|
57
59
|
}
|
|
58
|
-
function
|
|
60
|
+
function Pe(e, t, n, r, i, a, o, s) {
|
|
59
61
|
let c = s?.document ?? document, l = t.pmSchema.nodes.blockContainer, u = n.props || {};
|
|
60
62
|
for (let [e, r] of Object.entries(t.schema.blockSchema[n.type].propSchema)) !(e in u) && r.default !== void 0 && (u[e] = r.default);
|
|
61
63
|
let d = l.spec?.toDOM?.(l.create({
|
|
@@ -71,11 +73,11 @@ function Ne(e, t, n, r, i, a, o, s) {
|
|
|
71
73
|
if (m.dom.classList.contains("bn-block-content")) {
|
|
72
74
|
let e = [...f, ...Array.from(m.dom.attributes)].filter((e) => e.name.startsWith("data") && e.name !== "data-content-type" && e.name !== "data-file-block" && e.name !== "data-node-view-wrapper" && e.name !== "data-node-type" && e.name !== "data-id" && e.name !== "data-editable");
|
|
73
75
|
for (let t of e) m.dom.firstChild.setAttribute(t.name, t.value);
|
|
74
|
-
|
|
76
|
+
Me(m.dom.firstChild), o > 0 && m.dom.firstChild.setAttribute("data-nesting-level", o.toString()), h.append(...Array.from(m.dom.childNodes));
|
|
75
77
|
} else h.append(m.dom), o > 0 && m.dom.setAttribute("data-nesting-level", o.toString());
|
|
76
78
|
if (m.contentDOM) {
|
|
77
79
|
if (n.content) {
|
|
78
|
-
let e =
|
|
80
|
+
let e = Ne(t, n.content, r, {
|
|
79
81
|
...s,
|
|
80
82
|
blockType: n.type
|
|
81
83
|
});
|
|
@@ -94,20 +96,20 @@ function Ne(e, t, n, r, i, a, o, s) {
|
|
|
94
96
|
} else e.append(h);
|
|
95
97
|
if (n.children && n.children.length > 0) {
|
|
96
98
|
let l = c.createDocumentFragment();
|
|
97
|
-
if (
|
|
99
|
+
if (Fe(l, t, n.children, r, i, a, o + 1, s), e.lastChild?.nodeName === "UL" || e.lastChild?.nodeName === "OL") for (; l.firstChild?.nodeName === "UL" || l.firstChild?.nodeName === "OL";) e.lastChild.lastChild.appendChild(l.firstChild);
|
|
98
100
|
"childrenDOM" in m && m.childrenDOM ? m.childrenDOM.append(l) : t.pmSchema.nodes[n.type].isInGroup("blockContent") ? e.append(l) : m.contentDOM?.append(l);
|
|
99
101
|
}
|
|
100
102
|
}
|
|
101
|
-
var
|
|
102
|
-
for (let c of n)
|
|
103
|
-
},
|
|
103
|
+
var Fe = (e, t, n, r, i, a, o = 0, s) => {
|
|
104
|
+
for (let c of n) Pe(e, t, c, r, i, a, o, s);
|
|
105
|
+
}, Ie = (e, t, n, r, i, a) => {
|
|
104
106
|
let o = (a?.document ?? document).createDocumentFragment();
|
|
105
|
-
return
|
|
107
|
+
return Fe(o, e, t, n, r, i, 0, a), o;
|
|
106
108
|
}, k = (e, t) => {
|
|
107
|
-
let n =
|
|
109
|
+
let n = x.fromSchema(e);
|
|
108
110
|
return {
|
|
109
111
|
exportBlocks: (e, r) => {
|
|
110
|
-
let i =
|
|
112
|
+
let i = Ie(t, e, n, /* @__PURE__ */ new Set(["numberedListItem"]), /* @__PURE__ */ new Set([
|
|
111
113
|
"bulletListItem",
|
|
112
114
|
"checkListItem",
|
|
113
115
|
"toggleListItem"
|
|
@@ -115,41 +117,61 @@ var O = (e, t, n, r, i, a, o = 0, s) => {
|
|
|
115
117
|
return a.append(i), a.innerHTML;
|
|
116
118
|
},
|
|
117
119
|
exportInlineContent: (e, r) => {
|
|
118
|
-
let i =
|
|
120
|
+
let i = Ne(t, e, n, r), a = document.createElement("div");
|
|
119
121
|
return a.append(i.cloneNode(!0)), a.innerHTML;
|
|
120
122
|
}
|
|
121
123
|
};
|
|
122
124
|
};
|
|
123
125
|
//#endregion
|
|
126
|
+
//#region src/api/getChangedRange.ts
|
|
127
|
+
function Le(e) {
|
|
128
|
+
let { mapping: t, steps: n } = e, r = Infinity, i = -Infinity;
|
|
129
|
+
for (let e = 0; e < t.maps.length; e++) {
|
|
130
|
+
let a = t.maps[e];
|
|
131
|
+
e && (r = a.map(r, 1), i = a.map(i, -1));
|
|
132
|
+
let o = !1;
|
|
133
|
+
if (a.forEach((e, t, n, a) => {
|
|
134
|
+
o = !0, r = Math.min(r, n), i = Math.max(i, a);
|
|
135
|
+
}), !o) {
|
|
136
|
+
let t = n[e];
|
|
137
|
+
typeof t.pos == "number" ? (r = Math.min(r, t.pos), i = Math.max(i, t.pos + 1)) : typeof t.from == "number" && typeof t.to == "number" && (r = Math.min(r, t.from), i = Math.max(i, t.to));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return r === Infinity ? null : {
|
|
141
|
+
from: r,
|
|
142
|
+
to: i
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
//#endregion
|
|
124
146
|
//#region src/api/getBlocksChangedByTransaction.ts
|
|
125
|
-
function
|
|
147
|
+
function Re(e, t) {
|
|
126
148
|
if (t === 0) return;
|
|
127
149
|
let n = e.resolve(t);
|
|
128
150
|
for (let t = n.depth; t > 0; t--) {
|
|
129
151
|
let r = n.node(t);
|
|
130
|
-
if (
|
|
152
|
+
if (c(r)) return h(r, e);
|
|
131
153
|
}
|
|
132
154
|
}
|
|
133
|
-
function
|
|
155
|
+
function ze(e) {
|
|
134
156
|
return e.getMeta("paste") ? { type: "paste" } : e.getMeta("uiEvent") === "drop" ? { type: "drop" } : e.getMeta("history$") ? { type: e.getMeta("history$").redo ? "redo" : "undo" } : e.getMeta("y-sync$") ? e.getMeta("y-sync$").isUndoRedoOperation ? { type: "undo-redo" } : { type: "yjs-remote" } : { type: "local" };
|
|
135
157
|
}
|
|
136
|
-
function
|
|
137
|
-
let
|
|
138
|
-
return e.
|
|
139
|
-
if (!
|
|
140
|
-
let a =
|
|
141
|
-
|
|
142
|
-
let s = v(
|
|
143
|
-
return
|
|
158
|
+
function Be(e, t) {
|
|
159
|
+
let n = {}, r = {}, i = Math.max(0, Math.min(t.from, e.content.size)), a = Math.max(i, Math.min(t.to, e.content.size));
|
|
160
|
+
return e.nodesBetween(i, a, (t, i) => {
|
|
161
|
+
if (!c(t)) return !0;
|
|
162
|
+
let a = Re(e, i), o = a ?? "__root__";
|
|
163
|
+
r[o] || (r[o] = []);
|
|
164
|
+
let s = v(t, e), l = h(t, e);
|
|
165
|
+
return n[l] = {
|
|
144
166
|
block: s,
|
|
145
167
|
parentId: a
|
|
146
|
-
},
|
|
168
|
+
}, r[o].push(l), !0;
|
|
147
169
|
}), {
|
|
148
|
-
byId:
|
|
149
|
-
childrenByParent:
|
|
170
|
+
byId: n,
|
|
171
|
+
childrenByParent: r
|
|
150
172
|
};
|
|
151
173
|
}
|
|
152
|
-
function
|
|
174
|
+
function Ve(e, t) {
|
|
153
175
|
let n = /* @__PURE__ */ new Set();
|
|
154
176
|
if (!e || !t) return n;
|
|
155
177
|
let r = new Set(e), i = t.filter((e) => r.has(e)), a = e.filter((e) => i.includes(e));
|
|
@@ -173,63 +195,68 @@ function Le(e, t) {
|
|
|
173
195
|
for (let e = 0; e < i.length; e++) p.has(e) || n.add(i[e]);
|
|
174
196
|
return n;
|
|
175
197
|
}
|
|
176
|
-
function
|
|
177
|
-
let n =
|
|
178
|
-
|
|
179
|
-
|
|
198
|
+
function He(e, t = []) {
|
|
199
|
+
let n = ze(e), r = se(e.before, [e, ...t]), i = Le(r);
|
|
200
|
+
if (!i) return [];
|
|
201
|
+
let a = r.mapping.invert(), o = {
|
|
202
|
+
from: a.map(i.from, -1),
|
|
203
|
+
to: a.map(i.to, 1)
|
|
204
|
+
}, s = Be(r.before, o), c = Be(r.doc, i), l = [], u = /* @__PURE__ */ new Set();
|
|
205
|
+
Object.keys(c.byId).filter((e) => !(e in s.byId)).forEach((e) => {
|
|
206
|
+
l.push({
|
|
180
207
|
type: "insert",
|
|
181
|
-
block:
|
|
208
|
+
block: c.byId[e].block,
|
|
182
209
|
source: n,
|
|
183
210
|
prevBlock: void 0
|
|
184
|
-
}),
|
|
185
|
-
}), Object.keys(
|
|
186
|
-
|
|
211
|
+
}), u.add(e);
|
|
212
|
+
}), Object.keys(s.byId).filter((e) => !(e in c.byId)).forEach((e) => {
|
|
213
|
+
l.push({
|
|
187
214
|
type: "delete",
|
|
188
|
-
block:
|
|
215
|
+
block: s.byId[e].block,
|
|
189
216
|
source: n,
|
|
190
217
|
prevBlock: void 0
|
|
191
|
-
}),
|
|
192
|
-
}), Object.keys(
|
|
193
|
-
let t =
|
|
194
|
-
t.parentId === r.parentId ?
|
|
218
|
+
}), u.add(e);
|
|
219
|
+
}), Object.keys(c.byId).filter((e) => e in s.byId).forEach((e) => {
|
|
220
|
+
let t = s.byId[e], r = c.byId[e];
|
|
221
|
+
t.parentId === r.parentId ? Ee({
|
|
195
222
|
...t.block,
|
|
196
223
|
children: void 0
|
|
197
224
|
}, {
|
|
198
225
|
...r.block,
|
|
199
226
|
children: void 0
|
|
200
|
-
}) || (
|
|
227
|
+
}) || (l.push({
|
|
201
228
|
type: "update",
|
|
202
229
|
block: r.block,
|
|
203
230
|
prevBlock: t.block,
|
|
204
231
|
source: n
|
|
205
|
-
}),
|
|
232
|
+
}), u.add(e)) : (l.push({
|
|
206
233
|
type: "move",
|
|
207
234
|
block: r.block,
|
|
208
235
|
prevBlock: t.block,
|
|
209
236
|
source: n,
|
|
210
|
-
prevParent: t.parentId ?
|
|
211
|
-
currentParent: r.parentId ?
|
|
212
|
-
}),
|
|
237
|
+
prevParent: t.parentId ? s.byId[t.parentId]?.block : void 0,
|
|
238
|
+
currentParent: r.parentId ? c.byId[r.parentId]?.block : void 0
|
|
239
|
+
}), u.add(e));
|
|
213
240
|
});
|
|
214
|
-
let
|
|
215
|
-
return
|
|
216
|
-
let t =
|
|
241
|
+
let d = s.childrenByParent, f = c.childrenByParent, p = /* @__PURE__ */ new Set([...Object.keys(d), ...Object.keys(f)]), m = /* @__PURE__ */ new Set();
|
|
242
|
+
return p.forEach((e) => {
|
|
243
|
+
let t = Ve(d[e], f[e]);
|
|
217
244
|
t.size !== 0 && t.forEach((t) => {
|
|
218
|
-
let r =
|
|
219
|
-
!r || !
|
|
245
|
+
let r = s.byId[t], i = c.byId[t];
|
|
246
|
+
!r || !i || r.parentId === i.parentId && (u.has(t) || (r.parentId ?? "__root__") === e && (m.has(t) || (m.add(t), l.push({
|
|
220
247
|
type: "move",
|
|
221
|
-
block:
|
|
248
|
+
block: i.block,
|
|
222
249
|
prevBlock: r.block,
|
|
223
250
|
source: n,
|
|
224
|
-
prevParent: r.parentId ?
|
|
225
|
-
currentParent:
|
|
226
|
-
}),
|
|
251
|
+
prevParent: r.parentId ? s.byId[r.parentId]?.block : void 0,
|
|
252
|
+
currentParent: i.parentId ? c.byId[i.parentId]?.block : void 0
|
|
253
|
+
}), u.add(t))));
|
|
227
254
|
});
|
|
228
|
-
}),
|
|
255
|
+
}), l;
|
|
229
256
|
}
|
|
230
257
|
//#endregion
|
|
231
258
|
//#region src/extensions/BlockChange/BlockChange.ts
|
|
232
|
-
var
|
|
259
|
+
var Ue = b(() => {
|
|
233
260
|
let e = [];
|
|
234
261
|
return {
|
|
235
262
|
key: "blockChange",
|
|
@@ -239,7 +266,7 @@ var ze = b(() => {
|
|
|
239
266
|
let n;
|
|
240
267
|
return e.reduce((e, r) => e === !1 ? e : r({
|
|
241
268
|
getChanges() {
|
|
242
|
-
return n || (n =
|
|
269
|
+
return n || (n = He(t), n);
|
|
243
270
|
},
|
|
244
271
|
tr: t
|
|
245
272
|
}) !== !1, !0);
|
|
@@ -254,10 +281,10 @@ var ze = b(() => {
|
|
|
254
281
|
});
|
|
255
282
|
//#endregion
|
|
256
283
|
//#region src/extensions/DropCursor/utils.ts
|
|
257
|
-
function
|
|
284
|
+
function We(e, t) {
|
|
258
285
|
return !e || !t ? !1 : !!e.closest(`.${t}`);
|
|
259
286
|
}
|
|
260
|
-
function
|
|
287
|
+
function Ge(e, t, n, r, i) {
|
|
261
288
|
let a = e.state.doc.resolve(t.pos);
|
|
262
289
|
if (a.parent.inlineContent || t.orientation === "inline") return null;
|
|
263
290
|
let o = a.nodeBefore, s = a.nodeAfter;
|
|
@@ -284,7 +311,7 @@ function Ve(e, t, n, r, i) {
|
|
|
284
311
|
bottom: f + p
|
|
285
312
|
};
|
|
286
313
|
}
|
|
287
|
-
function
|
|
314
|
+
function Ke(e, t, n, r) {
|
|
288
315
|
let i = e.coordsAtPos(t.pos), a = n / 2 * r;
|
|
289
316
|
return {
|
|
290
317
|
left: i.left - a,
|
|
@@ -293,10 +320,10 @@ function He(e, t, n, r) {
|
|
|
293
320
|
bottom: i.bottom
|
|
294
321
|
};
|
|
295
322
|
}
|
|
296
|
-
function
|
|
323
|
+
function qe(e, t) {
|
|
297
324
|
e.classList.toggle("prosemirror-dropcursor-inline", t === "inline"), e.classList.toggle("prosemirror-dropcursor-block-horizontal", t === "block-horizontal"), e.classList.toggle("prosemirror-dropcursor-block-vertical-left", t === "block-vertical-left"), e.classList.toggle("prosemirror-dropcursor-block-vertical-right", t === "block-vertical-right"), e.classList.toggle("prosemirror-dropcursor-block", t === "block-horizontal"), e.classList.toggle("prosemirror-dropcursor-vertical", t === "block-vertical-left" || t === "block-vertical-right");
|
|
298
325
|
}
|
|
299
|
-
function
|
|
326
|
+
function Je(e) {
|
|
300
327
|
if (!e || e === document.body && getComputedStyle(e).position === "static") return {
|
|
301
328
|
parentLeft: -window.pageXOffset,
|
|
302
329
|
parentTop: -window.pageYOffset
|
|
@@ -309,19 +336,19 @@ function We(e) {
|
|
|
309
336
|
}
|
|
310
337
|
//#endregion
|
|
311
338
|
//#region src/extensions/DropCursor/DropCursor.ts
|
|
312
|
-
var
|
|
339
|
+
var Ye = "bn-drag-exclude", Xe = b(({ editor: e, options: t }) => {
|
|
313
340
|
let n = null, r = null, i = -1, a = null, o = {
|
|
314
341
|
width: t.dropCursor?.width ?? 5,
|
|
315
342
|
color: t.dropCursor?.color ?? "#ddeeff",
|
|
316
343
|
exclude: t.dropCursor?.exclude ?? "bn-drag-exclude",
|
|
317
344
|
hooks: t.dropCursor?.hooks
|
|
318
345
|
}, s = (e) => {
|
|
319
|
-
e?.pos
|
|
346
|
+
(e?.pos !== n?.pos || e?.orientation !== n?.orientation) && (n = e, e == null ? (r && r.parentNode && r.parentNode.removeChild(r), r = null) : c());
|
|
320
347
|
}, c = () => {
|
|
321
348
|
if (!n) return;
|
|
322
|
-
let t = e.prosemirrorView, i = t.dom, a = i.getBoundingClientRect(), s = a.width / i.offsetWidth, c = a.height / i.offsetHeight, l =
|
|
323
|
-
r || (r = u.appendChild(document.createElement("div")), r.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", o.color && (r.style.backgroundColor = o.color)),
|
|
324
|
-
let { parentLeft: d, parentTop: f } =
|
|
349
|
+
let t = e.prosemirrorView, i = t.dom, a = i.getBoundingClientRect(), s = a.width / i.offsetWidth, c = a.height / i.offsetHeight, l = Ge(t, n, o.width, s, c) ?? Ke(t, n, o.width, s), u = t.dom.offsetParent;
|
|
350
|
+
r || (r = u.appendChild(document.createElement("div")), r.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", o.color && (r.style.backgroundColor = o.color)), qe(r, n.orientation);
|
|
351
|
+
let { parentLeft: d, parentTop: f } = Je(u);
|
|
325
352
|
r.style.left = (l.left - d) / s + "px", r.style.top = (l.top - f) / c + "px", r.style.width = (l.right - l.left) / s + "px", r.style.height = (l.bottom - l.top) / c + "px";
|
|
326
353
|
}, l = (e) => {
|
|
327
354
|
clearTimeout(i), i = window.setTimeout(() => s(null), e);
|
|
@@ -330,7 +357,7 @@ var Ge = "bn-drag-exclude", Ke = b(({ editor: e, options: t }) => {
|
|
|
330
357
|
a = t.target instanceof Element ? t.target : null;
|
|
331
358
|
}, d = (t) => {
|
|
332
359
|
let n = t;
|
|
333
|
-
if (a &&
|
|
360
|
+
if (a && We(a, o.exclude) || n.target instanceof Element && We(n.target, o.exclude)) return;
|
|
334
361
|
let r = e.prosemirrorView;
|
|
335
362
|
if (!r.editable) return;
|
|
336
363
|
let i = r.posAtCoords({
|
|
@@ -340,7 +367,7 @@ var Ge = "bn-drag-exclude", Ke = b(({ editor: e, options: t }) => {
|
|
|
340
367
|
if (i && !d) {
|
|
341
368
|
let t = i.pos;
|
|
342
369
|
if (r.dragging && r.dragging.slice) {
|
|
343
|
-
let e =
|
|
370
|
+
let e = oe(r.state.doc, t, r.dragging.slice);
|
|
344
371
|
e != null && (t = e);
|
|
345
372
|
}
|
|
346
373
|
let a = !r.state.doc.resolve(t).parent.inlineContent, c = {
|
|
@@ -381,12 +408,43 @@ var Ge = "bn-drag-exclude", Ke = b(({ editor: e, options: t }) => {
|
|
|
381
408
|
});
|
|
382
409
|
}
|
|
383
410
|
};
|
|
384
|
-
}),
|
|
411
|
+
}), Ze = b(() => ({
|
|
385
412
|
key: "history",
|
|
386
|
-
prosemirrorPlugins: [
|
|
387
|
-
undoCommand:
|
|
388
|
-
redoCommand:
|
|
389
|
-
})),
|
|
413
|
+
prosemirrorPlugins: [De()],
|
|
414
|
+
undoCommand: ke,
|
|
415
|
+
redoCommand: Oe
|
|
416
|
+
})), Qe = new w("inline-content-boundary-edit");
|
|
417
|
+
function $e(e, t, n) {
|
|
418
|
+
if (!e.empty) return e.from <= n.from && e.to >= n.to;
|
|
419
|
+
let r = n.to - n.from === 1;
|
|
420
|
+
return t === "Backspace" ? r && e.from === n.to : r && e.from === n.from;
|
|
421
|
+
}
|
|
422
|
+
var et = b(() => ({
|
|
423
|
+
key: "inlineContentBoundaryEdit",
|
|
424
|
+
prosemirrorPlugins: [new C({
|
|
425
|
+
key: Qe,
|
|
426
|
+
props: { handleKeyDown: (e, t) => {
|
|
427
|
+
if (!e.editable) return !1;
|
|
428
|
+
let n = t.key.length === 1 && !t.ctrlKey && !t.metaKey;
|
|
429
|
+
if (!n && t.key !== "Backspace" && t.key !== "Delete") return !1;
|
|
430
|
+
let { selection: r } = e.state, i = r.$from.node();
|
|
431
|
+
if (!i.type.spec.inline) return !1;
|
|
432
|
+
let a = r.$from.before(), o = a + 1, s = a + 1 + i.content.size;
|
|
433
|
+
if (n && i.content.size === 0) {
|
|
434
|
+
let n = e.state.tr.insert(o, e.state.schema.text(t.key));
|
|
435
|
+
return n.setSelection(E.create(n.doc, o + t.key.length)), e.dispatch(n), !0;
|
|
436
|
+
}
|
|
437
|
+
if (i.content.size > 0 && $e(r, t.key, {
|
|
438
|
+
from: o,
|
|
439
|
+
to: s
|
|
440
|
+
})) {
|
|
441
|
+
let t = e.state.tr.delete(o, s);
|
|
442
|
+
return t.setSelection(E.create(t.doc, o)), e.dispatch(t), !0;
|
|
443
|
+
}
|
|
444
|
+
return !1;
|
|
445
|
+
} }
|
|
446
|
+
})]
|
|
447
|
+
})), tt = b(({ editor: e }) => {
|
|
390
448
|
function t(t) {
|
|
391
449
|
let n = e.prosemirrorView.nodeDOM(t);
|
|
392
450
|
for (; n && n.parentElement;) {
|
|
@@ -433,7 +491,7 @@ var Ge = "bn-drag-exclude", Ke = b(({ editor: e, options: t }) => {
|
|
|
433
491
|
e.deleteLink(t);
|
|
434
492
|
}
|
|
435
493
|
};
|
|
436
|
-
}),
|
|
494
|
+
}), nt = [
|
|
437
495
|
"http",
|
|
438
496
|
"https",
|
|
439
497
|
"ftp",
|
|
@@ -444,28 +502,28 @@ var Ge = "bn-drag-exclude", Ke = b(({ editor: e, options: t }) => {
|
|
|
444
502
|
"sms",
|
|
445
503
|
"cid",
|
|
446
504
|
"xmpp"
|
|
447
|
-
],
|
|
505
|
+
], rt = "https", it = new w("node-selection-keyboard"), at = b(() => ({
|
|
448
506
|
key: "nodeSelectionKeyboard",
|
|
449
507
|
prosemirrorPlugins: [new C({
|
|
450
|
-
key:
|
|
508
|
+
key: it,
|
|
451
509
|
props: { handleKeyDown: (e, t) => {
|
|
452
510
|
if ("node" in e.state.selection) {
|
|
453
511
|
if (t.ctrlKey || t.metaKey) return !1;
|
|
454
512
|
if (t.key.length === 1) return t.preventDefault(), !0;
|
|
455
513
|
if (t.key === "Enter" && !t.isComposing && !t.shiftKey && !t.altKey && !t.ctrlKey && !t.metaKey) {
|
|
456
514
|
let t = e.state.tr;
|
|
457
|
-
return e.dispatch(t.insert(e.state.tr.selection.$to.after(), e.state.schema.nodes.paragraph.createChecked()).setSelection(new
|
|
515
|
+
return e.dispatch(t.insert(e.state.tr.selection.$to.after(), e.state.schema.nodes.paragraph.createChecked()).setSelection(new E(t.doc.resolve(e.state.tr.selection.$to.after() + 1)))), !0;
|
|
458
516
|
}
|
|
459
517
|
}
|
|
460
518
|
return !1;
|
|
461
519
|
} }
|
|
462
520
|
})]
|
|
463
|
-
})),
|
|
521
|
+
})), ot = new w("blocknote-placeholder"), st = b(({ editor: e, options: t }) => {
|
|
464
522
|
let n = t.placeholders;
|
|
465
523
|
return {
|
|
466
524
|
key: "placeholder",
|
|
467
525
|
prosemirrorPlugins: [new C({
|
|
468
|
-
key:
|
|
526
|
+
key: ot,
|
|
469
527
|
view: (t) => {
|
|
470
528
|
let r = `placeholder-selector-${ue()}`;
|
|
471
529
|
t.dom.classList.add(r);
|
|
@@ -490,20 +548,20 @@ var Ge = "bn-drag-exclude", Ke = b(({ editor: e, options: t }) => {
|
|
|
490
548
|
let { doc: n, selection: r } = t;
|
|
491
549
|
if (!e.isEditable || !r.empty || r.$from.parent.type.spec.code) return;
|
|
492
550
|
let i = [];
|
|
493
|
-
t.doc.content.size === 6 && i.push(
|
|
551
|
+
t.doc.content.size === 6 && i.push(D.node(2, 4, { "data-is-only-empty-block": "true" }));
|
|
494
552
|
let a = r.$anchor, o = a.parent;
|
|
495
553
|
if (o.content.size === 0) {
|
|
496
554
|
let e = a.before();
|
|
497
|
-
i.push(
|
|
555
|
+
i.push(D.node(e, e + o.nodeSize, { "data-is-empty-and-focused": "true" }));
|
|
498
556
|
}
|
|
499
|
-
return
|
|
557
|
+
return O.create(n, i);
|
|
500
558
|
} }
|
|
501
559
|
})]
|
|
502
560
|
};
|
|
503
|
-
}),
|
|
504
|
-
let t = new
|
|
561
|
+
}), ct = b(({ editor: e }) => {
|
|
562
|
+
let t = new ae(), n = 0;
|
|
505
563
|
function r() {
|
|
506
|
-
t = new
|
|
564
|
+
t = new ae(), n = 0;
|
|
507
565
|
}
|
|
508
566
|
let i = typeof FinalizationRegistry < "u" ? new FinalizationRegistry(() => {
|
|
509
567
|
n--, n === 0 && r();
|
|
@@ -522,23 +580,23 @@ var Ge = "bn-drag-exclude", Ke = b(({ editor: e, options: t }) => {
|
|
|
522
580
|
return i && i.register(o, void 0), o;
|
|
523
581
|
}
|
|
524
582
|
};
|
|
525
|
-
}),
|
|
583
|
+
}), lt = new w("previous-blocks"), ut = {
|
|
526
584
|
index: "index",
|
|
527
585
|
level: "level",
|
|
528
586
|
type: "type",
|
|
529
587
|
depth: "depth",
|
|
530
588
|
"depth-change": "depth-change"
|
|
531
|
-
},
|
|
589
|
+
}, dt = b(() => {
|
|
532
590
|
let e;
|
|
533
591
|
return {
|
|
534
592
|
key: "previousBlockType",
|
|
535
593
|
prosemirrorPlugins: [new C({
|
|
536
|
-
key:
|
|
594
|
+
key: lt,
|
|
537
595
|
view(t) {
|
|
538
596
|
return {
|
|
539
597
|
update: async (t, n) => {
|
|
540
598
|
this.key?.getState(t.state).updatedBlocks.size > 0 && (e = setTimeout(() => {
|
|
541
|
-
t.dispatch(t.state.tr.setMeta(
|
|
599
|
+
t.dispatch(t.state.tr.setMeta(lt, { clearUpdate: !0 }));
|
|
542
600
|
}, 0));
|
|
543
601
|
},
|
|
544
602
|
destroy: () => {
|
|
@@ -556,14 +614,14 @@ var Ge = "bn-drag-exclude", Ke = b(({ editor: e, options: t }) => {
|
|
|
556
614
|
},
|
|
557
615
|
apply(e, t, n, r) {
|
|
558
616
|
if (t.currentTransactionOldBlockAttrs = {}, t.updatedBlocks.clear(), !e.docChanged) return t;
|
|
559
|
-
let i = e
|
|
617
|
+
let i = Le(e);
|
|
560
618
|
if (!i) return t;
|
|
561
619
|
let a = e.mapping.invert(), o = {
|
|
562
620
|
from: a.map(i.from, -1),
|
|
563
621
|
to: a.map(i.to, 1)
|
|
564
|
-
}, s = {}, c =
|
|
622
|
+
}, s = {}, c = ce(n.doc, o, (e) => e.attrs.id), l = new Map(c.map((e) => [h(e.node, n.doc), e])), u = ce(r.doc, i, (e) => e.attrs.id);
|
|
565
623
|
for (let e of u) {
|
|
566
|
-
let i =
|
|
624
|
+
let i = h(e.node, r.doc), a = l.get(i), o = a?.node.firstChild, c = e.node.firstChild;
|
|
567
625
|
if (a && o && c) {
|
|
568
626
|
let l = {
|
|
569
627
|
index: c.attrs.index,
|
|
@@ -588,19 +646,19 @@ var Ge = "bn-drag-exclude", Ke = b(({ editor: e, options: t }) => {
|
|
|
588
646
|
let n = [];
|
|
589
647
|
return e.doc.descendants((r, i) => {
|
|
590
648
|
if (!r.attrs.id) return;
|
|
591
|
-
let a =
|
|
649
|
+
let a = h(r, e.doc);
|
|
592
650
|
if (!t.updatedBlocks.has(a)) return;
|
|
593
651
|
let o = t.currentTransactionOldBlockAttrs[a], s = {};
|
|
594
|
-
for (let [e, t] of Object.entries(o)) s["data-prev-" +
|
|
595
|
-
n.push(
|
|
596
|
-
}),
|
|
652
|
+
for (let [e, t] of Object.entries(o)) s["data-prev-" + ut[e]] = t || "none";
|
|
653
|
+
n.push(D.node(i, i + r.nodeSize, { ...s }));
|
|
654
|
+
}), O.create(e.doc, n);
|
|
597
655
|
} }
|
|
598
656
|
})]
|
|
599
657
|
};
|
|
600
658
|
});
|
|
601
659
|
//#endregion
|
|
602
660
|
//#region src/extensions/getDraggableBlockFromElement.ts
|
|
603
|
-
function
|
|
661
|
+
function ft(e, t) {
|
|
604
662
|
for (; e && e.parentElement && e.parentElement !== t.dom && e.getAttribute?.("data-node-type") !== "blockContainer";) e = e.parentElement;
|
|
605
663
|
if (e.getAttribute?.("data-node-type") === "blockContainer") return {
|
|
606
664
|
node: e,
|
|
@@ -609,60 +667,61 @@ function at(e, t) {
|
|
|
609
667
|
}
|
|
610
668
|
//#endregion
|
|
611
669
|
//#region src/api/exporters/markdown/htmlToMarkdown.ts
|
|
612
|
-
function
|
|
670
|
+
function pt(e) {
|
|
613
671
|
let t = document.createElement("div");
|
|
614
|
-
return t.innerHTML = e,
|
|
672
|
+
return t.innerHTML = e, A(t, {
|
|
615
673
|
indent: "",
|
|
616
674
|
inListItem: !1
|
|
617
675
|
}).trim() + "\n";
|
|
618
676
|
}
|
|
619
|
-
function
|
|
677
|
+
function A(e, t) {
|
|
620
678
|
let n = "", r = Array.from(e.childNodes);
|
|
621
679
|
for (let e = 0; e < r.length; e++) {
|
|
622
680
|
let i = r[e];
|
|
623
|
-
n +=
|
|
681
|
+
n += j(i, t);
|
|
624
682
|
}
|
|
625
683
|
return n;
|
|
626
684
|
}
|
|
627
|
-
function
|
|
685
|
+
function j(e, t) {
|
|
628
686
|
if (e.nodeType === 3) return e.textContent || "";
|
|
629
687
|
if (e.nodeType !== 1) return "";
|
|
630
688
|
let n = e;
|
|
631
689
|
switch (n.tagName.toLowerCase()) {
|
|
632
|
-
case "p": return
|
|
690
|
+
case "p": return mt(n, t);
|
|
633
691
|
case "h1":
|
|
634
692
|
case "h2":
|
|
635
693
|
case "h3":
|
|
636
694
|
case "h4":
|
|
637
695
|
case "h5":
|
|
638
|
-
case "h6": return
|
|
639
|
-
case "blockquote": return
|
|
640
|
-
case "pre": return
|
|
641
|
-
case "ul": return
|
|
642
|
-
case "ol": return
|
|
643
|
-
case "table": return
|
|
696
|
+
case "h6": return ht(n, t);
|
|
697
|
+
case "blockquote": return gt(n, t);
|
|
698
|
+
case "pre": return _t(n, t);
|
|
699
|
+
case "ul": return St(n, t);
|
|
700
|
+
case "ol": return Ct(n, t);
|
|
701
|
+
case "table": return Et(n, t);
|
|
644
702
|
case "hr": return t.indent + "***\n\n";
|
|
645
|
-
case "
|
|
646
|
-
case "
|
|
647
|
-
case "
|
|
648
|
-
case "
|
|
649
|
-
case "
|
|
650
|
-
case "
|
|
651
|
-
case "
|
|
652
|
-
case "
|
|
703
|
+
case "math": return yt(n, t);
|
|
704
|
+
case "img": return kt(n, t);
|
|
705
|
+
case "video": return At(n, t);
|
|
706
|
+
case "audio": return jt(n, t);
|
|
707
|
+
case "embed": return Mt(n, t);
|
|
708
|
+
case "figure": return Nt(n, t);
|
|
709
|
+
case "a": return F(n, t);
|
|
710
|
+
case "details": return It(n, t);
|
|
711
|
+
case "div": return A(n, t);
|
|
653
712
|
case "br": return "";
|
|
654
|
-
default: return
|
|
713
|
+
default: return A(n, t);
|
|
655
714
|
}
|
|
656
715
|
}
|
|
657
|
-
function
|
|
658
|
-
let n =
|
|
716
|
+
function mt(e, t) {
|
|
717
|
+
let n = Lt(L(e));
|
|
659
718
|
return t.inListItem ? n : t.indent + n + "\n\n";
|
|
660
719
|
}
|
|
661
|
-
function
|
|
662
|
-
let n = parseInt(e.tagName[1], 10), r = "#".repeat(n) + " ", i =
|
|
720
|
+
function ht(e, t) {
|
|
721
|
+
let n = parseInt(e.tagName[1], 10), r = "#".repeat(n) + " ", i = L(e);
|
|
663
722
|
return t.indent + r + i + "\n\n";
|
|
664
723
|
}
|
|
665
|
-
function
|
|
724
|
+
function gt(e, t) {
|
|
666
725
|
let n = Array.from(e.children).filter((e) => {
|
|
667
726
|
let t = e.tagName.toLowerCase();
|
|
668
727
|
return [
|
|
@@ -677,43 +736,57 @@ function lt(e, t) {
|
|
|
677
736
|
}), r;
|
|
678
737
|
if (n.length > 0) {
|
|
679
738
|
let e = [];
|
|
680
|
-
for (let t of n) t.tagName.toLowerCase() === "p" ? e.push(
|
|
739
|
+
for (let t of n) t.tagName.toLowerCase() === "p" ? e.push(L(t)) : e.push(j(t, {
|
|
681
740
|
indent: "",
|
|
682
741
|
inListItem: !1
|
|
683
742
|
}).trim());
|
|
684
743
|
r = e.join("\n\n");
|
|
685
|
-
} else r =
|
|
744
|
+
} else r = L(e);
|
|
686
745
|
return r.split("\n").map((e) => t.indent + "> " + e).join("\n") + "\n\n";
|
|
687
746
|
}
|
|
688
|
-
function
|
|
747
|
+
function _t(e, t) {
|
|
689
748
|
let n = e.querySelector("code");
|
|
690
749
|
if (!n) return "";
|
|
691
|
-
let r = n.getAttribute("data-language") ||
|
|
692
|
-
return i ?
|
|
750
|
+
let r = n.getAttribute("data-language") || xt(n.className) || "", i = bt(n), a = Math.max(0, ...(i.match(/`+/g) ?? []).map((e) => e.length)), o = "`".repeat(Math.max(3, a + 1));
|
|
751
|
+
return i ? [
|
|
752
|
+
o + r,
|
|
753
|
+
...(i.endsWith("\n") ? i.slice(0, -1) : i).split("\n"),
|
|
754
|
+
o
|
|
755
|
+
].map((e) => e && t.indent + e).join("\n") + "\n\n" : t.indent + o + r + "\n" + t.indent + o + "\n\n";
|
|
756
|
+
}
|
|
757
|
+
function vt(e) {
|
|
758
|
+
return (e.querySelector("annotation[encoding=\"application/x-tex\"]")?.textContent ?? e.textContent ?? "").trim();
|
|
759
|
+
}
|
|
760
|
+
function yt(e, t) {
|
|
761
|
+
return [
|
|
762
|
+
"$$",
|
|
763
|
+
...vt(e).split("\n"),
|
|
764
|
+
"$$"
|
|
765
|
+
].map((e) => e && t.indent + e).join("\n") + "\n\n";
|
|
693
766
|
}
|
|
694
|
-
function
|
|
767
|
+
function bt(e) {
|
|
695
768
|
let t = "";
|
|
696
|
-
for (let n of Array.from(e.childNodes)) n.nodeType === 3 ? t += n.textContent || "" : n.nodeType === 1 && (n.tagName.toLowerCase() === "br" ? t += "\n" : t +=
|
|
769
|
+
for (let n of Array.from(e.childNodes)) n.nodeType === 3 ? t += n.textContent || "" : n.nodeType === 1 && (n.tagName.toLowerCase() === "br" ? t += "\n" : t += bt(n));
|
|
697
770
|
return t;
|
|
698
771
|
}
|
|
699
|
-
function
|
|
772
|
+
function xt(e) {
|
|
700
773
|
let t = e.match(/language-(\S+)/);
|
|
701
774
|
return t ? t[1] : "";
|
|
702
775
|
}
|
|
703
|
-
function
|
|
776
|
+
function St(e, t) {
|
|
704
777
|
let n = "", r = Array.from(e.children).filter((e) => e.tagName.toLowerCase() === "li");
|
|
705
|
-
for (let e of r) n +=
|
|
778
|
+
for (let e of r) n += wt(e, "bullet", t);
|
|
706
779
|
return t.inListItem || (n += "\n"), n;
|
|
707
780
|
}
|
|
708
|
-
function
|
|
781
|
+
function Ct(e, t) {
|
|
709
782
|
let n = "", r = Array.from(e.children).filter((e) => e.tagName.toLowerCase() === "li"), i = parseInt(e.getAttribute("start") || "1", 10);
|
|
710
783
|
for (let e = 0; e < r.length; e++) {
|
|
711
784
|
let a = i + e;
|
|
712
|
-
n +=
|
|
785
|
+
n += wt(r[e], "ordered", t, a);
|
|
713
786
|
}
|
|
714
787
|
return t.inListItem || (n += "\n"), n;
|
|
715
788
|
}
|
|
716
|
-
function
|
|
789
|
+
function wt(e, t, n, r) {
|
|
717
790
|
let i = null, a = null;
|
|
718
791
|
for (let t of Array.from(e.children)) {
|
|
719
792
|
let e = t.tagName.toLowerCase();
|
|
@@ -724,31 +797,35 @@ function ht(e, t, n, r) {
|
|
|
724
797
|
let c, l;
|
|
725
798
|
if (a) {
|
|
726
799
|
let e = a.querySelector("summary")?.querySelector("p");
|
|
727
|
-
l = a, c = e ?
|
|
728
|
-
} else l =
|
|
800
|
+
l = a, c = e ? L(e) : "";
|
|
801
|
+
} else l = Tt(e, i), c = l ? L(l) : "";
|
|
729
802
|
let u = n.indent + o + c + "\n", d = n.indent + " ".repeat(s), f = {
|
|
730
803
|
indent: d,
|
|
731
804
|
inListItem: !0
|
|
732
805
|
};
|
|
733
806
|
if (a) {
|
|
734
807
|
let e = a.querySelector("summary");
|
|
735
|
-
for (let t of Array.from(a.children)) if (t !== e)
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
808
|
+
for (let t of Array.from(a.children)) if (t !== e) {
|
|
809
|
+
if (t.tagName.toLowerCase() === "p") {
|
|
810
|
+
let e = L(t);
|
|
811
|
+
u += "\n" + d + e + "\n";
|
|
812
|
+
} else u += j(t, f);
|
|
813
|
+
}
|
|
739
814
|
}
|
|
740
815
|
let p = Array.from(e.children);
|
|
741
816
|
for (let e of p) {
|
|
742
817
|
let t = e.tagName.toLowerCase();
|
|
743
|
-
if (
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
818
|
+
if (e !== l && e !== i && t !== "input") {
|
|
819
|
+
if (t === "ul" || t === "ol") u += j(e, f);
|
|
820
|
+
else if (t === "p") {
|
|
821
|
+
let t = L(e);
|
|
822
|
+
u += "\n" + d + t + "\n";
|
|
823
|
+
} else u += "\n" + j(e, f);
|
|
824
|
+
}
|
|
748
825
|
}
|
|
749
826
|
return u;
|
|
750
827
|
}
|
|
751
|
-
function
|
|
828
|
+
function Tt(e, t) {
|
|
752
829
|
for (let n of Array.from(e.children)) {
|
|
753
830
|
if (n === t || n.tagName.toLowerCase() === "input") continue;
|
|
754
831
|
let e = n.tagName.toLowerCase();
|
|
@@ -756,7 +833,7 @@ function gt(e, t) {
|
|
|
756
833
|
}
|
|
757
834
|
return null;
|
|
758
835
|
}
|
|
759
|
-
function
|
|
836
|
+
function Et(e, t) {
|
|
760
837
|
let n = e.querySelector("colgroup"), r = 0;
|
|
761
838
|
n && (r = n.querySelectorAll("col").length);
|
|
762
839
|
let i = [], a = !1, o = e.querySelectorAll("tr"), s = [];
|
|
@@ -766,7 +843,7 @@ function _t(e, t) {
|
|
|
766
843
|
n.forEach((e) => {
|
|
767
844
|
for (; s[t][i] !== void 0;) i++;
|
|
768
845
|
t === 0 && e.tagName.toLowerCase() === "th" && (a = !0);
|
|
769
|
-
let n =
|
|
846
|
+
let n = Dt(L(e).trim()), r = parseInt(e.getAttribute("colspan") || "1", 10), o = parseInt(e.getAttribute("rowspan") || "1", 10);
|
|
770
847
|
for (let e = 0; e < o; e++) for (let a = 0; a < r; a++) {
|
|
771
848
|
let r = t + e;
|
|
772
849
|
s[r] || (s[r] = []), s[r][i + a] = e === 0 && a === 0 ? n : "";
|
|
@@ -791,19 +868,19 @@ function _t(e, t) {
|
|
|
791
868
|
}
|
|
792
869
|
let l = "";
|
|
793
870
|
if (a) {
|
|
794
|
-
l += t.indent +
|
|
795
|
-
for (let e = 1; e < i.length; e++) l += t.indent +
|
|
871
|
+
l += t.indent + M(i[0], c, r) + "\n", l += t.indent + Ot(c, r) + "\n";
|
|
872
|
+
for (let e = 1; e < i.length; e++) l += t.indent + M(i[e], c, r) + "\n";
|
|
796
873
|
} else {
|
|
797
874
|
let e = Array(r).fill("");
|
|
798
|
-
l += t.indent +
|
|
799
|
-
for (let e of i) l += t.indent +
|
|
875
|
+
l += t.indent + M(e, c, r) + "\n", l += t.indent + Ot(c, r) + "\n";
|
|
876
|
+
for (let e of i) l += t.indent + M(e, c, r) + "\n";
|
|
800
877
|
}
|
|
801
878
|
return l += "\n", l;
|
|
802
879
|
}
|
|
803
|
-
function
|
|
880
|
+
function Dt(e) {
|
|
804
881
|
return e.replace(/\|/g, "\\|");
|
|
805
882
|
}
|
|
806
|
-
function
|
|
883
|
+
function M(e, t, n) {
|
|
807
884
|
let r = [];
|
|
808
885
|
for (let i = 0; i < n; i++) {
|
|
809
886
|
let n = i < e.length ? e[i] : "";
|
|
@@ -811,65 +888,65 @@ function N(e, t, n) {
|
|
|
811
888
|
}
|
|
812
889
|
return "|" + r.join("|") + "|";
|
|
813
890
|
}
|
|
814
|
-
function
|
|
891
|
+
function Ot(e, t) {
|
|
815
892
|
let n = [];
|
|
816
893
|
for (let r = 0; r < t; r++) n.push(" " + "-".repeat(e[r]) + " ");
|
|
817
894
|
return "|" + n.join("|") + "|";
|
|
818
895
|
}
|
|
819
|
-
function
|
|
896
|
+
function kt(e, t) {
|
|
820
897
|
let n = e.getAttribute("src") || "", r = e.getAttribute("alt") || "";
|
|
821
898
|
return n ? t.indent + `\n\n` : "\n\n";
|
|
822
899
|
}
|
|
823
|
-
function
|
|
900
|
+
function At(e, t) {
|
|
824
901
|
let n = e.getAttribute("src") || e.getAttribute("data-url") || "", r = e.getAttribute("data-name") || e.getAttribute("title") || "";
|
|
825
902
|
return n ? t.indent + `\n\n` : "\n\n";
|
|
826
903
|
}
|
|
827
|
-
function
|
|
904
|
+
function jt(e, t) {
|
|
828
905
|
let n = e.getAttribute("src") || "";
|
|
829
|
-
return n ? t.indent + `<audio src="${
|
|
906
|
+
return n ? t.indent + `<audio src="${P(n)}" controls></audio>\n\n` : "\n\n";
|
|
830
907
|
}
|
|
831
|
-
function
|
|
908
|
+
function Mt(e, t) {
|
|
832
909
|
let n = e.getAttribute("src") || "";
|
|
833
910
|
return n ? t.indent + `[](${n})\n\n` : "\n\n";
|
|
834
911
|
}
|
|
835
|
-
function
|
|
912
|
+
function Nt(e, t) {
|
|
836
913
|
let n = e.querySelector("img"), r = e.querySelector("video"), i = e.querySelector("audio"), a = e.querySelector("a"), o = e.querySelector("figcaption")?.textContent?.trim() || "";
|
|
837
|
-
return n ?
|
|
914
|
+
return n ? N("img", n.getAttribute("src") || "", n.getAttribute("alt") || "", o, t) : r ? N("video", r.getAttribute("src") || r.getAttribute("data-url") || "", r.getAttribute("data-name") || r.getAttribute("title") || "", o, t) : i ? N("audio", i.getAttribute("src") || "", "", o, t) : a ? F(a, t) : "";
|
|
838
915
|
}
|
|
839
|
-
function
|
|
916
|
+
function N(e, t, n, r, i) {
|
|
840
917
|
if (!t) return "";
|
|
841
918
|
if (!r && e !== "audio") return i.indent + `\n\n`;
|
|
842
|
-
let a = n && n !== r ? e === "img" ? ` alt="${
|
|
919
|
+
let a = n && n !== r ? e === "img" ? ` alt="${P(n)}"` : e === "video" ? ` data-name="${P(n)}"` : "" : "", o = e === "img" ? `<img${a} src="${P(t)}">` : `<${e} src="${P(t)}"${a} controls></${e}>`, s = r ? `<figcaption>${Pt(r)}</figcaption>` : "";
|
|
843
920
|
return i.indent + `<figure>${o}${s}</figure>\n\n`;
|
|
844
921
|
}
|
|
845
|
-
function
|
|
922
|
+
function P(e) {
|
|
846
923
|
return e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
847
924
|
}
|
|
848
|
-
function
|
|
925
|
+
function Pt(e) {
|
|
849
926
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
850
927
|
}
|
|
851
|
-
function
|
|
928
|
+
function F(e, t) {
|
|
852
929
|
let n = e.getAttribute("href") || "", r = e.textContent?.trim() || "";
|
|
853
|
-
return n ? t.indent +
|
|
930
|
+
return n ? t.indent + I(r, n) + "\n\n" : t.indent + r + "\n\n";
|
|
854
931
|
}
|
|
855
|
-
function
|
|
856
|
-
return !e || e === t ? t : `[${e}](${
|
|
932
|
+
function I(e, t) {
|
|
933
|
+
return !e || e === t ? t : `[${e}](${Ft(t)})`;
|
|
857
934
|
}
|
|
858
|
-
function
|
|
935
|
+
function Ft(e) {
|
|
859
936
|
return e.replace(/[\\()]/g, "\\$&");
|
|
860
937
|
}
|
|
861
|
-
function
|
|
938
|
+
function It(e, t) {
|
|
862
939
|
let n = e.querySelector("summary");
|
|
863
|
-
if (!n) return
|
|
940
|
+
if (!n) return A(e, t);
|
|
864
941
|
let r = n.querySelector("h1, h2, h3, h4, h5, h6");
|
|
865
942
|
if (r) {
|
|
866
|
-
let i =
|
|
867
|
-
for (let r of Array.from(e.children)) r !== n && (i +=
|
|
943
|
+
let i = ht(r, t);
|
|
944
|
+
for (let r of Array.from(e.children)) r !== n && (i += j(r, t));
|
|
868
945
|
return i;
|
|
869
946
|
}
|
|
870
|
-
return
|
|
947
|
+
return A(n, t);
|
|
871
948
|
}
|
|
872
|
-
function
|
|
949
|
+
function L(e) {
|
|
873
950
|
let t = "";
|
|
874
951
|
for (let n of Array.from(e.childNodes)) if (n.nodeType === 3) t += n.textContent || "";
|
|
875
952
|
else if (n.nodeType === 1) {
|
|
@@ -877,19 +954,19 @@ function z(e) {
|
|
|
877
954
|
switch (e.tagName.toLowerCase()) {
|
|
878
955
|
case "strong":
|
|
879
956
|
case "b": {
|
|
880
|
-
let { content: n, trailing: r } =
|
|
881
|
-
n ?
|
|
957
|
+
let { content: n, trailing: r } = R(L(e));
|
|
958
|
+
t += n ? `**${n}**${r}` : r;
|
|
882
959
|
break;
|
|
883
960
|
}
|
|
884
961
|
case "em":
|
|
885
962
|
case "i": {
|
|
886
|
-
let { content: n, trailing: r } =
|
|
887
|
-
n ?
|
|
963
|
+
let { content: n, trailing: r } = R(L(e));
|
|
964
|
+
t += n ? `*${n}*${r}` : r;
|
|
888
965
|
break;
|
|
889
966
|
}
|
|
890
967
|
case "s":
|
|
891
968
|
case "del":
|
|
892
|
-
t += `~~${
|
|
969
|
+
t += `~~${L(e)}~~`;
|
|
893
970
|
break;
|
|
894
971
|
case "code": {
|
|
895
972
|
let n = e.textContent || "", r = Math.max(0, ...(n.match(/`+/g) ?? []).map((e) => e.length)), i = "`".repeat(r + 1), a = n.startsWith("`") || n.endsWith("`");
|
|
@@ -897,18 +974,23 @@ function z(e) {
|
|
|
897
974
|
break;
|
|
898
975
|
}
|
|
899
976
|
case "u":
|
|
900
|
-
t +=
|
|
977
|
+
t += L(e);
|
|
901
978
|
break;
|
|
902
979
|
case "a": {
|
|
903
|
-
let n = e.getAttribute("href") || "", r =
|
|
904
|
-
t +=
|
|
980
|
+
let n = e.getAttribute("href") || "", r = L(e);
|
|
981
|
+
t += I(r, n);
|
|
905
982
|
break;
|
|
906
983
|
}
|
|
907
984
|
case "br":
|
|
908
985
|
t += "\\\n";
|
|
909
986
|
break;
|
|
987
|
+
case "math": {
|
|
988
|
+
let n = vt(e).split("\n").map((e) => e.trim()).join(" ");
|
|
989
|
+
t += `$${n}$`;
|
|
990
|
+
break;
|
|
991
|
+
}
|
|
910
992
|
case "span":
|
|
911
|
-
t +=
|
|
993
|
+
t += L(e);
|
|
912
994
|
break;
|
|
913
995
|
case "img": {
|
|
914
996
|
let n = e.getAttribute("src") || "", r = e.getAttribute("alt") || "";
|
|
@@ -921,17 +1003,15 @@ function z(e) {
|
|
|
921
1003
|
break;
|
|
922
1004
|
}
|
|
923
1005
|
case "p":
|
|
924
|
-
t +=
|
|
1006
|
+
t += L(e);
|
|
925
1007
|
break;
|
|
926
1008
|
case "input": break;
|
|
927
|
-
default:
|
|
928
|
-
t += z(e);
|
|
929
|
-
break;
|
|
1009
|
+
default: t += L(e);
|
|
930
1010
|
}
|
|
931
1011
|
}
|
|
932
1012
|
return t;
|
|
933
1013
|
}
|
|
934
|
-
function
|
|
1014
|
+
function R(e) {
|
|
935
1015
|
let t = e.match(/^(.*?)(\s*)$/);
|
|
936
1016
|
return t ? {
|
|
937
1017
|
content: t[1],
|
|
@@ -941,29 +1021,29 @@ function B(e) {
|
|
|
941
1021
|
trailing: ""
|
|
942
1022
|
};
|
|
943
1023
|
}
|
|
944
|
-
function
|
|
1024
|
+
function Lt(e) {
|
|
945
1025
|
let t = e.replace(/^(\\\n)+/, "");
|
|
946
1026
|
return t = t.replace(/(\\\n)+$/, ""), t;
|
|
947
1027
|
}
|
|
948
1028
|
//#endregion
|
|
949
1029
|
//#region src/api/exporters/markdown/markdownExporter.ts
|
|
950
|
-
function
|
|
951
|
-
return
|
|
1030
|
+
function z(e) {
|
|
1031
|
+
return pt(e.split("").join(""));
|
|
952
1032
|
}
|
|
953
|
-
function
|
|
954
|
-
return
|
|
1033
|
+
function Rt(e, t, n, r) {
|
|
1034
|
+
return z(k(t, n).exportBlocks(e, r));
|
|
955
1035
|
}
|
|
956
1036
|
//#endregion
|
|
957
1037
|
//#region src/api/nodeConversions/fragmentToBlocks.ts
|
|
958
|
-
function
|
|
1038
|
+
function B(e) {
|
|
959
1039
|
let t = [];
|
|
960
1040
|
return e.descendants((e) => e.type.name === "blockContainer" && e.firstChild?.type.name === "blockGroup" ? !0 : e.type.name === "columnList" && e.childCount === 1 ? (e.firstChild?.forEach((n) => {
|
|
961
1041
|
t.push(v(n, e));
|
|
962
|
-
}), !1) : e.type.isInGroup("bnBlock")
|
|
1042
|
+
}), !1) : !e.type.isInGroup("bnBlock") || (t.push(v(e, e)), !1)), t;
|
|
963
1043
|
}
|
|
964
1044
|
//#endregion
|
|
965
1045
|
//#region src/extensions/SideMenu/MultipleNodeSelection.ts
|
|
966
|
-
var
|
|
1046
|
+
var V = class e extends T {
|
|
967
1047
|
nodes;
|
|
968
1048
|
constructor(e, t) {
|
|
969
1049
|
super(e, t);
|
|
@@ -976,7 +1056,7 @@ var H = class e extends T {
|
|
|
976
1056
|
return new e(t.resolve(n), t.resolve(r));
|
|
977
1057
|
}
|
|
978
1058
|
content() {
|
|
979
|
-
return new
|
|
1059
|
+
return new ie(S.from(this.nodes), 0, 0);
|
|
980
1060
|
}
|
|
981
1061
|
eq(t) {
|
|
982
1062
|
if (!(t instanceof e) || this.nodes.length !== t.nodes.length || this.from !== t.from || this.to !== t.to) return !1;
|
|
@@ -995,11 +1075,11 @@ var H = class e extends T {
|
|
|
995
1075
|
};
|
|
996
1076
|
}
|
|
997
1077
|
};
|
|
998
|
-
T.jsonID("multiple-node",
|
|
1078
|
+
T.jsonID("multiple-node", V);
|
|
999
1079
|
//#endregion
|
|
1000
1080
|
//#region src/extensions/SideMenu/dragging.ts
|
|
1001
|
-
var
|
|
1002
|
-
function
|
|
1081
|
+
var H;
|
|
1082
|
+
function zt(e, t) {
|
|
1003
1083
|
let n, r, i = t.resolve(e.from).node().type.spec.group === "blockContent", a = t.resolve(e.to).node().type.spec.group === "blockContent", o = Math.min(e.$anchor.depth, e.$head.depth);
|
|
1004
1084
|
if (i && a) {
|
|
1005
1085
|
let i = e.$from.start(o - 1), a = e.$to.end(o - 1);
|
|
@@ -1010,51 +1090,51 @@ function At(e, t) {
|
|
|
1010
1090
|
to: r
|
|
1011
1091
|
};
|
|
1012
1092
|
}
|
|
1013
|
-
function
|
|
1093
|
+
function Bt(e, t, n = t) {
|
|
1014
1094
|
t === n && (n += e.state.doc.resolve(t + 1).node().nodeSize);
|
|
1015
1095
|
let r = e.domAtPos(t).node.cloneNode(!0), i = e.domAtPos(t).node, a = (e, t) => Array.prototype.indexOf.call(e.children, t), o = a(i, e.domAtPos(t + 1).node.parentElement), s = a(i, e.domAtPos(n - 1).node.parentElement);
|
|
1016
1096
|
for (let e = i.childElementCount - 1; e >= 0; e--) (e > s || e < o) && r.removeChild(r.children[e]);
|
|
1017
|
-
|
|
1097
|
+
Vt(e.root), H = r, H.querySelectorAll("iframe, embed, object").forEach((e) => e.parentElement?.removeChild(e));
|
|
1018
1098
|
let c = e.dom.className.split(" ").filter((e) => e !== "ProseMirror" && e !== "bn-root" && e !== "bn-editor").join(" ");
|
|
1019
|
-
|
|
1020
|
-
}
|
|
1021
|
-
function
|
|
1022
|
-
|
|
1023
|
-
}
|
|
1024
|
-
function
|
|
1025
|
-
if (!
|
|
1026
|
-
let
|
|
1027
|
-
if (!
|
|
1028
|
-
let
|
|
1029
|
-
if (
|
|
1030
|
-
let
|
|
1031
|
-
c && l ? (
|
|
1032
|
-
let u =
|
|
1033
|
-
|
|
1099
|
+
H.className = H.className + " bn-drag-preview " + c, e.root instanceof ShadowRoot ? e.root.appendChild(H) : e.root.body.appendChild(H);
|
|
1100
|
+
}
|
|
1101
|
+
function Vt(e) {
|
|
1102
|
+
H !== void 0 && (e instanceof ShadowRoot ? e.removeChild(H) : e.body.removeChild(H), H = void 0);
|
|
1103
|
+
}
|
|
1104
|
+
function Ht(e, t, n) {
|
|
1105
|
+
if (!e.dataTransfer || n.headless) return;
|
|
1106
|
+
let r = n.prosemirrorView, i = s(t.id, r.state.doc);
|
|
1107
|
+
if (!i) throw Error(`Block with ID ${t.id} not found`);
|
|
1108
|
+
let a = i.posBeforeNode;
|
|
1109
|
+
if (a != null) {
|
|
1110
|
+
let t = r.state.selection, i = r.state.doc, { from: o, to: s } = zt(t, i), c = o <= a && a < s, l = t.$anchor.node() !== t.$head.node() || t instanceof V;
|
|
1111
|
+
c && l ? (r.dispatch(r.state.tr.setSelection(V.create(i, o, s))), Bt(r, o, s)) : (r.dispatch(r.state.tr.setSelection(de.create(r.state.doc, a))), Bt(r, a));
|
|
1112
|
+
let u = r.state.selection.content(), d = n.pmSchema, f = r.serializeForClipboard(u).dom.innerHTML, p = k(d, n), m = B(u.content), h = p.exportBlocks(m, {}), g = z(h);
|
|
1113
|
+
e.dataTransfer.clearData(), e.dataTransfer.setData("blocknote/html", f), e.dataTransfer.setData("text/html", h), e.dataTransfer.setData("text/plain", g), e.dataTransfer.effectAllowed = "move", e.dataTransfer.setDragImage(H, 0, 0);
|
|
1034
1114
|
}
|
|
1035
1115
|
}
|
|
1036
1116
|
//#endregion
|
|
1037
1117
|
//#region src/extensions/SideMenu/SideMenu.ts
|
|
1038
|
-
var
|
|
1039
|
-
function
|
|
1118
|
+
var Ut = 250;
|
|
1119
|
+
function U(e, t, n = !0) {
|
|
1040
1120
|
let r = e.root.elementsFromPoint(t.left, t.top);
|
|
1041
|
-
for (let i of r) if (e.dom.contains(i)) return n && i.closest("[data-node-type=columnList]") ?
|
|
1121
|
+
for (let i of r) if (e.dom.contains(i)) return n && i.closest("[data-node-type=columnList]") ? U(e, {
|
|
1042
1122
|
left: t.left + 50,
|
|
1043
1123
|
top: t.top
|
|
1044
|
-
}, !1) :
|
|
1124
|
+
}, !1) : ft(i, e);
|
|
1045
1125
|
}
|
|
1046
|
-
function
|
|
1126
|
+
function Wt(e, t) {
|
|
1047
1127
|
if (!t.dom.firstChild) return;
|
|
1048
|
-
let n = t.dom.firstChild.getBoundingClientRect(), r =
|
|
1128
|
+
let n = t.dom.firstChild.getBoundingClientRect(), r = U(t, {
|
|
1049
1129
|
left: Math.min(Math.max(n.left + 10, e.x), n.right - 10),
|
|
1050
1130
|
top: e.y
|
|
1051
1131
|
});
|
|
1052
|
-
if (r) return
|
|
1132
|
+
if (r) return U(t, {
|
|
1053
1133
|
left: r.node.getBoundingClientRect().right - 10,
|
|
1054
1134
|
top: e.y
|
|
1055
1135
|
}, !1);
|
|
1056
1136
|
}
|
|
1057
|
-
var
|
|
1137
|
+
var Gt = class {
|
|
1058
1138
|
editor;
|
|
1059
1139
|
pmView;
|
|
1060
1140
|
state;
|
|
@@ -1078,11 +1158,11 @@ var It = class {
|
|
|
1078
1158
|
clientX: this.mousePos.x,
|
|
1079
1159
|
clientY: this.mousePos.y
|
|
1080
1160
|
});
|
|
1081
|
-
if (e?.element !== this.pmView.dom || e.distance >
|
|
1161
|
+
if (e?.element !== this.pmView.dom || e.distance > Ut) {
|
|
1082
1162
|
this.state?.show && (this.state.show = !1, this.updateState(this.state));
|
|
1083
1163
|
return;
|
|
1084
1164
|
}
|
|
1085
|
-
let t =
|
|
1165
|
+
let t = Wt(this.mousePos, this.pmView);
|
|
1086
1166
|
if (!t || !this.editor.isEditable) {
|
|
1087
1167
|
this.state?.show && (this.state.show = !1, this.updateState(this.state));
|
|
1088
1168
|
return;
|
|
@@ -1105,9 +1185,9 @@ var It = class {
|
|
|
1105
1185
|
if (!t || this.pmView.dragging) return;
|
|
1106
1186
|
let n = document.createElement("div");
|
|
1107
1187
|
n.innerHTML = t;
|
|
1108
|
-
let r =
|
|
1188
|
+
let r = fe.fromSchema(this.pmView.state.schema).parse(n, { topNode: this.pmView.state.schema.nodes.blockGroup.create() });
|
|
1109
1189
|
this.pmView.dragging = {
|
|
1110
|
-
slice: new
|
|
1190
|
+
slice: new pe(r.content, 0, 0),
|
|
1111
1191
|
move: !0
|
|
1112
1192
|
};
|
|
1113
1193
|
};
|
|
@@ -1139,7 +1219,7 @@ var It = class {
|
|
|
1139
1219
|
getDragEventContext = (e) => {
|
|
1140
1220
|
if (!(this.pmView.dragging !== null || this.isDragOrigin || e.dataTransfer?.types.includes("blocknote/html") || e.target instanceof Node && this.pmView.dom.contains(e.target))) return;
|
|
1141
1221
|
let t = !e.dataTransfer?.types.includes("blocknote/html") && !!this.pmView.dragging, n = !!this.isDragOrigin, r = t || n, i = this.findClosestEditorElement(e);
|
|
1142
|
-
if (!i || i.distance >
|
|
1222
|
+
if (!i || i.distance > Ut) return;
|
|
1143
1223
|
let a = i.element === this.pmView.dom, o = a && i.distance === 0;
|
|
1144
1224
|
if (!(!a && !r)) return {
|
|
1145
1225
|
isDropPoint: a,
|
|
@@ -1157,9 +1237,10 @@ var It = class {
|
|
|
1157
1237
|
let { isDropPoint: n, isDropWithinEditorBounds: r, isDragOrigin: i } = t;
|
|
1158
1238
|
if (!r && n && this.dispatchSyntheticEvent(e), n) {
|
|
1159
1239
|
if (this.pmView.dragging) return;
|
|
1160
|
-
this.pmView.dispatch(this.pmView.state.tr.setSelection(
|
|
1240
|
+
this.pmView.dispatch(this.pmView.state.tr.setSelection(Te.create(this.pmView.state.tr.doc, this.pmView.state.tr.selection.anchor)));
|
|
1161
1241
|
return;
|
|
1162
|
-
}
|
|
1242
|
+
}
|
|
1243
|
+
if (i) {
|
|
1163
1244
|
setTimeout(() => this.pmView.dispatch(this.pmView.state.tr.deleteSelection()), 0);
|
|
1164
1245
|
return;
|
|
1165
1246
|
}
|
|
@@ -1193,22 +1274,22 @@ var It = class {
|
|
|
1193
1274
|
destroy() {
|
|
1194
1275
|
this.state?.show && (this.state.show = !1, this.emitUpdate(this.state)), this.pmView.root.removeEventListener("mousemove", this.onMouseMove, !0), this.pmView.root.removeEventListener("dragstart", this.onDragStart), this.pmView.root.removeEventListener("dragover", this.onDragOver), this.pmView.root.removeEventListener("drop", this.onDrop, !0), this.pmView.root.removeEventListener("dragend", this.onDragEnd, !0), this.pmView.root.removeEventListener("keydown", this.onKeyDown, !0);
|
|
1195
1276
|
}
|
|
1196
|
-
},
|
|
1277
|
+
}, Kt = new we("SideMenuPlugin"), qt = b(({ editor: e }) => {
|
|
1197
1278
|
let t, n = y(void 0);
|
|
1198
1279
|
return {
|
|
1199
1280
|
key: "sideMenu",
|
|
1200
1281
|
store: n,
|
|
1201
|
-
prosemirrorPlugins: [new
|
|
1202
|
-
key:
|
|
1203
|
-
view: (r) => (t = new
|
|
1282
|
+
prosemirrorPlugins: [new Ce({
|
|
1283
|
+
key: Kt,
|
|
1284
|
+
view: (r) => (t = new Gt(e, r, (e) => {
|
|
1204
1285
|
n.setState({ ...e });
|
|
1205
1286
|
}), t)
|
|
1206
1287
|
})],
|
|
1207
1288
|
blockDragStart(n, r) {
|
|
1208
|
-
t && (t.isDragOrigin = !0),
|
|
1289
|
+
t && (t.isDragOrigin = !0), Ht(n, r, e);
|
|
1209
1290
|
},
|
|
1210
1291
|
blockDragEnd() {
|
|
1211
|
-
|
|
1292
|
+
Vt(e.prosemirrorView.root), t && (t.isDragOrigin = !1), e.blur();
|
|
1212
1293
|
},
|
|
1213
1294
|
get menuFrozen() {
|
|
1214
1295
|
return t.menuFrozen;
|
|
@@ -1223,8 +1304,172 @@ var It = class {
|
|
|
1223
1304
|
!t.menuFrozen && t.state?.show && (t.state.show = !1, t.emitUpdate(t.state));
|
|
1224
1305
|
}
|
|
1225
1306
|
};
|
|
1226
|
-
}),
|
|
1227
|
-
|
|
1307
|
+
}), Jt = b(({ editor: e }) => {
|
|
1308
|
+
let t = y({
|
|
1309
|
+
popupOpen: void 0,
|
|
1310
|
+
selected: void 0
|
|
1311
|
+
}), n = (t) => !!e.schema.blockSpecs[t.type]?.implementation?.meta?.hasPreview, r = (e) => ({ editor: r }) => {
|
|
1312
|
+
let { block: i, prevBlock: a, nextBlock: o } = r.getTextCursorPosition();
|
|
1313
|
+
if (!n(i) || t.state.popupOpen === i.id) return !1;
|
|
1314
|
+
let s = e === "prev" ? a : o;
|
|
1315
|
+
return s ? (r.setTextCursorPosition(s.id, e === "prev" ? "end" : "start"), !0) : !1;
|
|
1316
|
+
};
|
|
1317
|
+
return {
|
|
1318
|
+
key: "sourceBlockWithPreview",
|
|
1319
|
+
store: t,
|
|
1320
|
+
keyboardShortcuts: {
|
|
1321
|
+
Enter: ({ editor: e }) => {
|
|
1322
|
+
let { block: r } = e.getTextCursorPosition();
|
|
1323
|
+
if (!n(r)) return !1;
|
|
1324
|
+
if (t.state.popupOpen === r.id && e.schema.blockSpecs[r.type]?.implementation?.meta?.hardBreakShortcut === "enter") {
|
|
1325
|
+
let t = e.prosemirrorView;
|
|
1326
|
+
return t.dispatch(t.state.tr.insertText("\n")), !0;
|
|
1327
|
+
}
|
|
1328
|
+
return e.setTextCursorPosition(r.id, "end"), t.setState((e) => ({
|
|
1329
|
+
...e,
|
|
1330
|
+
popupOpen: t.state.popupOpen === r.id ? void 0 : r.id
|
|
1331
|
+
})), !0;
|
|
1332
|
+
},
|
|
1333
|
+
Escape: ({ editor: e }) => {
|
|
1334
|
+
let { block: r } = e.getTextCursorPosition();
|
|
1335
|
+
return !n(r) || t.state.popupOpen !== r.id ? !1 : (e.setTextCursorPosition(r.id, "end"), t.setState((e) => ({
|
|
1336
|
+
...e,
|
|
1337
|
+
popupOpen: void 0
|
|
1338
|
+
})), !0);
|
|
1339
|
+
},
|
|
1340
|
+
"Mod-a": ({ editor: e }) => {
|
|
1341
|
+
let { block: r } = e.getTextCursorPosition();
|
|
1342
|
+
if (!n(r) || t.state.popupOpen !== r.id) return !1;
|
|
1343
|
+
let i = e.prosemirrorView, { $from: a } = i.state.selection;
|
|
1344
|
+
return a.parent.type.name === r.type && (i.dispatch(i.state.tr.setSelection(E.create(i.state.doc, a.start(), a.end()))), !0);
|
|
1345
|
+
},
|
|
1346
|
+
ArrowUp: r("prev"),
|
|
1347
|
+
ArrowLeft: r("prev"),
|
|
1348
|
+
ArrowDown: r("next"),
|
|
1349
|
+
ArrowRight: r("next")
|
|
1350
|
+
},
|
|
1351
|
+
mount: ({ dom: r, signal: i }) => {
|
|
1352
|
+
let a = e.onSelectionChange(() => {
|
|
1353
|
+
let { block: r } = e.getTextCursorPosition(), i = n(r) ? r.id : void 0, a = t.state.popupOpen && t.state.popupOpen !== r.id ? void 0 : t.state.popupOpen;
|
|
1354
|
+
(i !== t.state.selected || a !== t.state.popupOpen) && t.setState((e) => ({
|
|
1355
|
+
...e,
|
|
1356
|
+
selected: i,
|
|
1357
|
+
popupOpen: a
|
|
1358
|
+
}));
|
|
1359
|
+
});
|
|
1360
|
+
i.addEventListener("abort", a), r.addEventListener("keydown", (r) => {
|
|
1361
|
+
if (!e.isEditable) return;
|
|
1362
|
+
let { block: i } = e.getTextCursorPosition();
|
|
1363
|
+
if (!(!n(i) || t.state.popupOpen === i.id)) {
|
|
1364
|
+
if (r.key === "Backspace" || r.key === "Delete") {
|
|
1365
|
+
r.preventDefault(), r.stopImmediatePropagation(), e.removeBlocks([i.id]);
|
|
1366
|
+
return;
|
|
1367
|
+
}
|
|
1368
|
+
(r.key.length === 1 && !r.ctrlKey && !r.metaKey || r.key === "Tab") && (r.preventDefault(), r.stopImmediatePropagation());
|
|
1369
|
+
}
|
|
1370
|
+
}, {
|
|
1371
|
+
capture: !0,
|
|
1372
|
+
signal: i
|
|
1373
|
+
}), r.addEventListener("blur", () => t.setState((e) => ({
|
|
1374
|
+
...e,
|
|
1375
|
+
popupOpen: void 0
|
|
1376
|
+
})), {
|
|
1377
|
+
capture: !0,
|
|
1378
|
+
signal: i
|
|
1379
|
+
});
|
|
1380
|
+
}
|
|
1381
|
+
};
|
|
1382
|
+
}), Yt = b(({ editor: e }) => {
|
|
1383
|
+
let t = y({ selected: void 0 }), n = (t) => !!e.schema.inlineContentSpecs[t]?.implementation?.meta?.hasPreview, r = (e) => ({ editor: t }) => {
|
|
1384
|
+
let { $from: r } = t.prosemirrorState.selection, i = r.node();
|
|
1385
|
+
if (!n(i.type.name)) return !1;
|
|
1386
|
+
let a = t.prosemirrorView, o = T.near(a.state.doc.resolve(e === "before" ? r.before() : r.after()), e === "before" ? -1 : 1);
|
|
1387
|
+
return a.dispatch(a.state.tr.setSelection(o)), !0;
|
|
1388
|
+
};
|
|
1389
|
+
return {
|
|
1390
|
+
key: "sourceInlineContentWithPreview",
|
|
1391
|
+
store: t,
|
|
1392
|
+
keyboardShortcuts: {
|
|
1393
|
+
Enter: r("after"),
|
|
1394
|
+
"Shift-Enter": r("after"),
|
|
1395
|
+
Escape: r("after"),
|
|
1396
|
+
ArrowUp: r("before"),
|
|
1397
|
+
ArrowDown: r("after"),
|
|
1398
|
+
"Mod-a": ({ editor: e }) => {
|
|
1399
|
+
let { $from: t } = e.prosemirrorState.selection;
|
|
1400
|
+
if (!n(t.node().type.name)) return !1;
|
|
1401
|
+
let r = e.prosemirrorView;
|
|
1402
|
+
return r.dispatch(r.state.tr.setSelection(E.create(r.state.doc, t.start(), t.end()))), !0;
|
|
1403
|
+
}
|
|
1404
|
+
},
|
|
1405
|
+
mount: ({ dom: r, signal: i }) => {
|
|
1406
|
+
let a = e.onSelectionChange(() => {
|
|
1407
|
+
let { $from: r } = e.prosemirrorState.selection, i = r.node();
|
|
1408
|
+
t.setState({ selected: n(i.type.name) ? r.before() : void 0 });
|
|
1409
|
+
});
|
|
1410
|
+
i.addEventListener("abort", a), r.addEventListener("keydown", (t) => {
|
|
1411
|
+
if (t.key !== "ArrowUp" && t.key !== "ArrowDown") return;
|
|
1412
|
+
let { $from: i } = e.prosemirrorState.selection;
|
|
1413
|
+
n(i.node().type.name) || (r.classList.add("bn-suppress-source-popup-caret"), requestAnimationFrame(() => r.classList.remove("bn-suppress-source-popup-caret")));
|
|
1414
|
+
}, {
|
|
1415
|
+
capture: !0,
|
|
1416
|
+
signal: i
|
|
1417
|
+
}), r.addEventListener("blur", () => t.setState({ selected: void 0 }), {
|
|
1418
|
+
capture: !0,
|
|
1419
|
+
signal: i
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1422
|
+
};
|
|
1423
|
+
}), Xt = Symbol.for("blocknote.shikiParser"), W = Symbol.for("blocknote.shikiHighlighterPromise"), Zt = [
|
|
1424
|
+
"text",
|
|
1425
|
+
"none",
|
|
1426
|
+
"plaintext",
|
|
1427
|
+
"txt"
|
|
1428
|
+
];
|
|
1429
|
+
function Qt(e, t, n) {
|
|
1430
|
+
let r = globalThis, i, a, o = /* @__PURE__ */ new Set();
|
|
1431
|
+
return Ae({
|
|
1432
|
+
parser: (t) => {
|
|
1433
|
+
if (!e.createHighlighter) return [];
|
|
1434
|
+
if (!i) return r[W] = r[W] || e.createHighlighter(), r[W].then((e) => {
|
|
1435
|
+
i = e;
|
|
1436
|
+
});
|
|
1437
|
+
let n = t.language;
|
|
1438
|
+
return !n || Zt.includes(n) || o.has(n) ? [] : i.getLoadedLanguages().includes(n) ? (a || (a = r[Xt] || je(i, $t(i)), r[Xt] = a), a(t)) : i.loadLanguage(n).catch(() => {
|
|
1439
|
+
o.add(n);
|
|
1440
|
+
});
|
|
1441
|
+
},
|
|
1442
|
+
languageExtractor: (e) => {
|
|
1443
|
+
let t = {
|
|
1444
|
+
type: e.type.name,
|
|
1445
|
+
props: e.attrs
|
|
1446
|
+
};
|
|
1447
|
+
return (n.blockSpecs[t.type] || n.inlineContentSpecs[t.type])?.implementation?.meta?.highlight?.(t) ?? void 0;
|
|
1448
|
+
},
|
|
1449
|
+
nodeTypes: t
|
|
1450
|
+
});
|
|
1451
|
+
}
|
|
1452
|
+
function $t(e) {
|
|
1453
|
+
let t = e.getLoadedThemes(), n = t.find((e) => /light/i.test(e)), r = t.find((e) => /dark/i.test(e));
|
|
1454
|
+
if (n && r) return {
|
|
1455
|
+
themes: {
|
|
1456
|
+
light: n,
|
|
1457
|
+
dark: r
|
|
1458
|
+
},
|
|
1459
|
+
defaultColor: !1
|
|
1460
|
+
};
|
|
1461
|
+
}
|
|
1462
|
+
//#endregion
|
|
1463
|
+
//#region src/extensions/SyntaxHighlighting/SyntaxHighlighting.ts
|
|
1464
|
+
function en(e) {
|
|
1465
|
+
let t = Object.values(e.blockSpecs).filter((e) => typeof e?.config == "object" && e.config.content === "plain" && !!e.implementation?.meta?.highlight).map((e) => e.config.type), n = Object.values(e.inlineContentSpecs).filter((e) => typeof e?.config == "object" && e.config.content === "plain" && !!e.implementation?.meta?.highlight).map((e) => e.config.type);
|
|
1466
|
+
return [...t, ...n];
|
|
1467
|
+
}
|
|
1468
|
+
var tn = b(({ editor: e, options: t }) => ({
|
|
1469
|
+
key: "syntaxHighlighting",
|
|
1470
|
+
prosemirrorPlugins: [Qt(t, en(e.schema), e.schema)]
|
|
1471
|
+
})), G;
|
|
1472
|
+
async function nn() {
|
|
1228
1473
|
return G || (G = (async () => {
|
|
1229
1474
|
let [e, t] = await Promise.all([import("emoji-mart"), import("@emoji-mart/data")]), n = "default" in e ? e.default : e, r = "default" in t ? t.default : t;
|
|
1230
1475
|
return await n.init({ data: r }), {
|
|
@@ -1233,9 +1478,9 @@ async function zt() {
|
|
|
1233
1478
|
};
|
|
1234
1479
|
})(), G);
|
|
1235
1480
|
}
|
|
1236
|
-
async function
|
|
1237
|
-
if (!("text" in e.schema.inlineContentSchema) || e.schema.inlineContentSchema.text !==
|
|
1238
|
-
let { emojiData: n, emojiMart: r } = await
|
|
1481
|
+
async function rn(e, t) {
|
|
1482
|
+
if (!("text" in e.schema.inlineContentSchema) || e.schema.inlineContentSchema.text !== te.text) return [];
|
|
1483
|
+
let { emojiData: n, emojiMart: r } = await nn();
|
|
1239
1484
|
return (t.trim() === "" ? Object.values(n.emojis) : await r.SearchIndex.search(t)).map((t) => ({
|
|
1240
1485
|
id: t.skins[0].native,
|
|
1241
1486
|
onItemClick: () => e.insertInlineContent(t.skins[0].native + " ")
|
|
@@ -1244,16 +1489,16 @@ async function Bt(e, t) {
|
|
|
1244
1489
|
//#endregion
|
|
1245
1490
|
//#region src/extensions/TableHandles/TableHandles.ts
|
|
1246
1491
|
var K;
|
|
1247
|
-
function
|
|
1492
|
+
function an(e) {
|
|
1248
1493
|
K || (K = document.createElement("div"), K.innerHTML = "_", K.style.opacity = "0", K.style.height = "1px", K.style.width = "1px", e instanceof Document ? e.body.appendChild(K) : e.appendChild(K));
|
|
1249
1494
|
}
|
|
1250
|
-
function
|
|
1495
|
+
function on(e) {
|
|
1251
1496
|
K &&= (e instanceof Document ? e.body.removeChild(K) : e.removeChild(K), void 0);
|
|
1252
1497
|
}
|
|
1253
1498
|
function q(e) {
|
|
1254
1499
|
return Array.prototype.indexOf.call(e.parentElement.childNodes, e);
|
|
1255
1500
|
}
|
|
1256
|
-
function
|
|
1501
|
+
function sn(e) {
|
|
1257
1502
|
let t = e;
|
|
1258
1503
|
for (; t && t.nodeName !== "TD" && t.nodeName !== "TH" && !t.classList.contains("tableWrapper");) {
|
|
1259
1504
|
if (t.classList.contains("ProseMirror")) return;
|
|
@@ -1271,11 +1516,11 @@ function Ut(e) {
|
|
|
1271
1516
|
tbodyNode: t.querySelector("tbody")
|
|
1272
1517
|
};
|
|
1273
1518
|
}
|
|
1274
|
-
function
|
|
1519
|
+
function cn(e, t) {
|
|
1275
1520
|
let n = t.querySelectorAll(e);
|
|
1276
1521
|
for (let e = 0; e < n.length; e++) n[e].style.visibility = "hidden";
|
|
1277
1522
|
}
|
|
1278
|
-
var
|
|
1523
|
+
var ln = class {
|
|
1279
1524
|
editor;
|
|
1280
1525
|
pmView;
|
|
1281
1526
|
state;
|
|
@@ -1294,60 +1539,69 @@ var Gt = class {
|
|
|
1294
1539
|
viewMousedownHandler = () => {
|
|
1295
1540
|
this.mouseState = "down";
|
|
1296
1541
|
};
|
|
1542
|
+
hideHandles = () => {
|
|
1543
|
+
this.state?.show && (this.state.show = !1, this.state.showAddOrRemoveRowsButton = !1, this.state.showAddOrRemoveColumnsButton = !1, this.emitUpdate());
|
|
1544
|
+
};
|
|
1297
1545
|
mouseUpHandler = (e) => {
|
|
1298
1546
|
this.mouseState = "up", this.mouseMoveHandler(e);
|
|
1299
1547
|
};
|
|
1300
|
-
mouseMoveHandler = (
|
|
1301
|
-
if (this.menuFrozen || this.mouseState === "selecting" || !(
|
|
1302
|
-
let
|
|
1303
|
-
if (
|
|
1304
|
-
this.mouseState = "selecting", this.
|
|
1548
|
+
mouseMoveHandler = (e) => {
|
|
1549
|
+
if (this.menuFrozen || this.mouseState === "selecting" || !(e.target instanceof Element) || !this.pmView.dom.contains(e.target)) return;
|
|
1550
|
+
let t = sn(e.target);
|
|
1551
|
+
if (t?.type === "cell" && this.mouseState === "down" && !this.state?.draggingState) {
|
|
1552
|
+
this.mouseState = "selecting", this.hideHandles();
|
|
1305
1553
|
return;
|
|
1306
1554
|
}
|
|
1307
|
-
if (!
|
|
1308
|
-
this.
|
|
1555
|
+
if (!t || !this.editor.isEditable) {
|
|
1556
|
+
this.hideHandles();
|
|
1309
1557
|
return;
|
|
1310
1558
|
}
|
|
1311
|
-
if (!
|
|
1312
|
-
let
|
|
1313
|
-
if (!
|
|
1314
|
-
this.
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
doc: t.doc
|
|
1559
|
+
if (!t.tbodyNode) return;
|
|
1560
|
+
let n = t.tbodyNode.getBoundingClientRect(), r = ft(t.domNode, this.pmView);
|
|
1561
|
+
if (!r) return;
|
|
1562
|
+
let { pmNodeInfo: i, doc: a } = this.editor.transact((e) => ({
|
|
1563
|
+
pmNodeInfo: s(r.id, e.doc),
|
|
1564
|
+
doc: e.doc
|
|
1318
1565
|
}));
|
|
1319
|
-
if (!
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
let
|
|
1324
|
-
if (
|
|
1325
|
-
|
|
1566
|
+
if (!i) {
|
|
1567
|
+
this.hideHandles();
|
|
1568
|
+
return;
|
|
1569
|
+
}
|
|
1570
|
+
let o = v(i.node, a);
|
|
1571
|
+
if (!g(o, this.editor, "table")) {
|
|
1572
|
+
this.hideHandles();
|
|
1573
|
+
return;
|
|
1574
|
+
}
|
|
1575
|
+
let c = o;
|
|
1576
|
+
this.tablePos = i.posBeforeNode + 1, this.tableElement = r.node, this.tableId = r.id;
|
|
1577
|
+
let l = t.domNode.closest(".tableWrapper")?.querySelector(".table-widgets-container");
|
|
1578
|
+
if (t?.type === "wrapper") {
|
|
1579
|
+
let t = e.clientY >= n.bottom - 1 && e.clientY < n.bottom + 20, r = e.clientX >= n.right - 1 && e.clientX < n.right + 20, i = this.state?.block?.id !== c.id || e.clientX > n.right || e.clientY > n.bottom;
|
|
1326
1580
|
this.state = {
|
|
1327
1581
|
...this.state,
|
|
1328
1582
|
show: !0,
|
|
1329
|
-
showAddOrRemoveRowsButton:
|
|
1330
|
-
showAddOrRemoveColumnsButton:
|
|
1331
|
-
referencePosTable:
|
|
1332
|
-
block:
|
|
1583
|
+
showAddOrRemoveRowsButton: t,
|
|
1584
|
+
showAddOrRemoveColumnsButton: r,
|
|
1585
|
+
referencePosTable: n,
|
|
1586
|
+
block: c,
|
|
1333
1587
|
widgetContainer: l,
|
|
1334
1588
|
colIndex: i ? void 0 : this.state?.colIndex,
|
|
1335
1589
|
rowIndex: i ? void 0 : this.state?.rowIndex,
|
|
1336
1590
|
referencePosCell: i ? void 0 : this.state?.referencePosCell
|
|
1337
1591
|
};
|
|
1338
1592
|
} else {
|
|
1339
|
-
let e = q(
|
|
1340
|
-
if (this.state !== void 0 && this.state.show && this.tableId ===
|
|
1593
|
+
let e = q(t.domNode), i = q(t.domNode.parentElement), a = t.domNode.getBoundingClientRect();
|
|
1594
|
+
if (this.state !== void 0 && this.state.show && this.tableId === r.id && this.state.rowIndex === i && this.state.colIndex === e) return;
|
|
1341
1595
|
this.state = {
|
|
1342
1596
|
show: !0,
|
|
1343
|
-
showAddOrRemoveColumnsButton: e ===
|
|
1344
|
-
showAddOrRemoveRowsButton:
|
|
1345
|
-
referencePosTable:
|
|
1346
|
-
block:
|
|
1597
|
+
showAddOrRemoveColumnsButton: e === c.content.rows[0].cells.length - 1,
|
|
1598
|
+
showAddOrRemoveRowsButton: i === c.content.rows.length - 1,
|
|
1599
|
+
referencePosTable: n,
|
|
1600
|
+
block: c,
|
|
1347
1601
|
draggingState: void 0,
|
|
1348
|
-
referencePosCell:
|
|
1602
|
+
referencePosCell: a,
|
|
1349
1603
|
colIndex: e,
|
|
1350
|
-
rowIndex:
|
|
1604
|
+
rowIndex: i,
|
|
1351
1605
|
widgetContainer: l
|
|
1352
1606
|
};
|
|
1353
1607
|
}
|
|
@@ -1355,7 +1609,7 @@ var Gt = class {
|
|
|
1355
1609
|
};
|
|
1356
1610
|
dragOverHandler = (e) => {
|
|
1357
1611
|
if (this.state?.draggingState === void 0) return;
|
|
1358
|
-
e.preventDefault(), e.dataTransfer.dropEffect = "move",
|
|
1612
|
+
e.preventDefault(), e.dataTransfer.dropEffect = "move", cn(".prosemirror-dropcursor-block, .prosemirror-dropcursor-inline", this.pmView.root);
|
|
1359
1613
|
let t = {
|
|
1360
1614
|
left: Math.min(Math.max(e.clientX, this.state.referencePosTable.left + 1), this.state.referencePosTable.right - 1),
|
|
1361
1615
|
top: Math.min(Math.max(e.clientY, this.state.referencePosTable.top + 1), this.state.referencePosTable.bottom - 1)
|
|
@@ -1366,16 +1620,16 @@ var Gt = class {
|
|
|
1366
1620
|
let l = this.state.draggingState.draggedCellOrientation === "row" ? t.top : t.left;
|
|
1367
1621
|
this.state.draggingState.mousePos !== l && (this.state.draggingState.mousePos = l, i = !0), i && this.emitUpdate(), c && this.editor.transact((e) => e.setMeta(J, !0));
|
|
1368
1622
|
};
|
|
1369
|
-
dropHandler = (
|
|
1623
|
+
dropHandler = (t) => {
|
|
1370
1624
|
if (this.mouseState = "up", this.state === void 0 || this.state.draggingState === void 0) return !1;
|
|
1371
1625
|
if (this.state.rowIndex === void 0 || this.state.colIndex === void 0) throw Error("Attempted to drop table row or column, but no table block was hovered prior.");
|
|
1372
|
-
|
|
1373
|
-
let { draggingState:
|
|
1626
|
+
t.preventDefault();
|
|
1627
|
+
let { draggingState: n, colIndex: r, rowIndex: i } = this.state;
|
|
1374
1628
|
this.state.draggingState = void 0;
|
|
1375
|
-
let
|
|
1376
|
-
if (
|
|
1377
|
-
if (!
|
|
1378
|
-
let e =
|
|
1629
|
+
let o = this.state.block.content.columnWidths;
|
|
1630
|
+
if (n.draggedCellOrientation === "row") {
|
|
1631
|
+
if (!f(this.state.block, n.originalIndex, i)) return !1;
|
|
1632
|
+
let e = ee(this.state.block, n.originalIndex, i);
|
|
1379
1633
|
this.editor.updateBlock(this.state.block, {
|
|
1380
1634
|
type: "table",
|
|
1381
1635
|
content: {
|
|
@@ -1384,29 +1638,34 @@ var Gt = class {
|
|
|
1384
1638
|
}
|
|
1385
1639
|
});
|
|
1386
1640
|
} else {
|
|
1387
|
-
if (!
|
|
1388
|
-
let
|
|
1389
|
-
|
|
1641
|
+
if (!e(this.state.block, n.originalIndex, r)) return !1;
|
|
1642
|
+
let t = a(this.state.block, n.originalIndex, r), [i] = o.splice(n.originalIndex, 1);
|
|
1643
|
+
o.splice(r, 0, i), this.editor.updateBlock(this.state.block, {
|
|
1390
1644
|
type: "table",
|
|
1391
1645
|
content: {
|
|
1392
1646
|
...this.state.block.content,
|
|
1393
|
-
columnWidths:
|
|
1394
|
-
rows:
|
|
1647
|
+
columnWidths: o,
|
|
1648
|
+
rows: t
|
|
1395
1649
|
}
|
|
1396
1650
|
});
|
|
1397
1651
|
}
|
|
1398
1652
|
return this.editor.setTextCursorPosition(this.state.block.id), !0;
|
|
1399
1653
|
};
|
|
1654
|
+
getTablePos(e) {
|
|
1655
|
+
if (this.tableId === void 0) return;
|
|
1656
|
+
let t = s(this.tableId, e);
|
|
1657
|
+
return t && t.posBeforeNode + 1;
|
|
1658
|
+
}
|
|
1400
1659
|
update() {
|
|
1401
1660
|
if (!this.state || !this.state.show) return;
|
|
1402
1661
|
let e = this.editor.getBlock(this.state.block.id);
|
|
1403
1662
|
if (!e || e.type !== "table" || !this.tableElement?.isConnected) {
|
|
1404
|
-
this.state = void 0, this.tableId = void 0, this.tableElement = void 0, this.emitUpdate();
|
|
1663
|
+
this.state = void 0, this.tableId = void 0, this.tablePos = void 0, this.tableElement = void 0, this.emitUpdate();
|
|
1405
1664
|
return;
|
|
1406
1665
|
}
|
|
1407
|
-
this.state.block = e;
|
|
1408
|
-
let { height:
|
|
1409
|
-
this.state.rowIndex !== void 0 && this.state.colIndex !== void 0 && (this.state.rowIndex >=
|
|
1666
|
+
this.state.block = e, this.tablePos = this.getTablePos(this.pmView.state.doc);
|
|
1667
|
+
let { height: n, width: r } = t(this.state.block);
|
|
1668
|
+
this.state.rowIndex !== void 0 && this.state.colIndex !== void 0 && (this.state.rowIndex >= n && (this.state.rowIndex = n - 1), this.state.colIndex >= r && (this.state.colIndex = r - 1));
|
|
1410
1669
|
let i = this.tableElement.querySelector("tbody");
|
|
1411
1670
|
if (!i) throw Error("Table block does not contain a 'tbody' HTML element. This should never happen.");
|
|
1412
1671
|
if (this.state.rowIndex !== void 0 && this.state.colIndex !== void 0) {
|
|
@@ -1418,120 +1677,136 @@ var Gt = class {
|
|
|
1418
1677
|
destroy() {
|
|
1419
1678
|
this.pmView.dom.removeEventListener("mousemove", this.mouseMoveHandler), window.removeEventListener("mouseup", this.mouseUpHandler), this.pmView.dom.removeEventListener("mousedown", this.viewMousedownHandler), this.pmView.root.removeEventListener("dragover", this.dragOverHandler), this.pmView.root.removeEventListener("drop", this.dropHandler);
|
|
1420
1679
|
}
|
|
1421
|
-
}, J = new w("TableHandlesPlugin"),
|
|
1422
|
-
let
|
|
1680
|
+
}, J = new w("TableHandlesPlugin"), un = b(({ editor: t }) => {
|
|
1681
|
+
let n, i = y(void 0);
|
|
1423
1682
|
return {
|
|
1424
1683
|
key: "tableHandles",
|
|
1425
|
-
store:
|
|
1684
|
+
store: i,
|
|
1426
1685
|
prosemirrorPlugins: [new C({
|
|
1427
1686
|
key: J,
|
|
1428
|
-
view: (
|
|
1429
|
-
|
|
1687
|
+
view: (e) => (n = new ln(t, e, (e) => {
|
|
1688
|
+
i.setState(e?.block ? {
|
|
1430
1689
|
...e,
|
|
1431
1690
|
draggingState: e.draggingState ? { ...e.draggingState } : void 0
|
|
1432
1691
|
} : void 0);
|
|
1433
|
-
}),
|
|
1434
|
-
props: { decorations: (
|
|
1435
|
-
if (
|
|
1436
|
-
let
|
|
1437
|
-
if (
|
|
1438
|
-
let i =
|
|
1439
|
-
if (
|
|
1440
|
-
let
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1692
|
+
}), n),
|
|
1693
|
+
props: { decorations: (t) => {
|
|
1694
|
+
if (n === void 0 || n.state === void 0 || n.state.draggingState === void 0) return;
|
|
1695
|
+
let r = n.getTablePos(t.doc);
|
|
1696
|
+
if (r === void 0) return;
|
|
1697
|
+
let i = n.state.draggingState.draggedCellOrientation === "row" ? n.state.rowIndex : n.state.colIndex;
|
|
1698
|
+
if (i === void 0) return;
|
|
1699
|
+
let a = [], { block: o, draggingState: s } = n.state, { originalIndex: c, draggedCellOrientation: l } = s;
|
|
1700
|
+
if (i === c || !o || l === "row" && !f(o, c, i) || l === "col" && !e(o, c, i)) return O.create(t.doc, a);
|
|
1701
|
+
let u = t.doc.resolve(r + 1);
|
|
1702
|
+
return n.state.draggingState.draggedCellOrientation === "row" ? p(n.state.block, i).forEach(({ row: e, col: n }) => {
|
|
1703
|
+
let r = t.doc.resolve(u.posAtIndex(e) + 1), o = t.doc.resolve(r.posAtIndex(n) + 1), s = o.node(), l = o.pos + (i > c ? s.nodeSize - 2 : 0);
|
|
1704
|
+
a.push(D.widget(l, () => {
|
|
1444
1705
|
let e = document.createElement("div");
|
|
1445
|
-
return e.className = "bn-table-drop-cursor", e.style.left = "0", e.style.right = "0",
|
|
1706
|
+
return e.className = "bn-table-drop-cursor", e.style.left = "0", e.style.right = "0", i > c ? e.style.bottom = "-2px" : e.style.top = "-3px", e.style.height = "4px", e;
|
|
1446
1707
|
}));
|
|
1447
|
-
}) :
|
|
1448
|
-
let
|
|
1449
|
-
|
|
1708
|
+
}) : d(n.state.block, i).forEach(({ row: e, col: n }) => {
|
|
1709
|
+
let r = t.doc.resolve(u.posAtIndex(e) + 1), o = t.doc.resolve(r.posAtIndex(n) + 1), s = o.node(), l = o.pos + (i > c ? s.nodeSize - 2 : 0);
|
|
1710
|
+
a.push(D.widget(l, () => {
|
|
1450
1711
|
let e = document.createElement("div");
|
|
1451
|
-
return e.className = "bn-table-drop-cursor", e.style.top = "0", e.style.bottom = "0",
|
|
1712
|
+
return e.className = "bn-table-drop-cursor", e.style.top = "0", e.style.bottom = "0", i > c ? e.style.right = "-2px" : e.style.left = "-3px", e.style.width = "4px", e;
|
|
1452
1713
|
}));
|
|
1453
|
-
}),
|
|
1714
|
+
}), O.create(t.doc, a);
|
|
1454
1715
|
} }
|
|
1455
1716
|
})],
|
|
1456
|
-
colDragStart(
|
|
1457
|
-
if (
|
|
1458
|
-
|
|
1717
|
+
colDragStart(e) {
|
|
1718
|
+
if (n === void 0 || n.state === void 0 || n.state.colIndex === void 0) throw Error("Attempted to drag table column, but no table block was hovered prior.");
|
|
1719
|
+
n.state.draggingState = {
|
|
1459
1720
|
draggedCellOrientation: "col",
|
|
1460
|
-
originalIndex:
|
|
1461
|
-
mousePos:
|
|
1462
|
-
},
|
|
1463
|
-
draggedCellOrientation:
|
|
1464
|
-
originalIndex:
|
|
1465
|
-
newIndex:
|
|
1466
|
-
tablePos:
|
|
1467
|
-
})), !
|
|
1721
|
+
originalIndex: n.state.colIndex,
|
|
1722
|
+
mousePos: e.clientX
|
|
1723
|
+
}, n.emitUpdate(), t.transact((e) => e.setMeta(J, {
|
|
1724
|
+
draggedCellOrientation: n.state.draggingState.draggedCellOrientation,
|
|
1725
|
+
originalIndex: n.state.colIndex,
|
|
1726
|
+
newIndex: n.state.colIndex,
|
|
1727
|
+
tablePos: n.tablePos
|
|
1728
|
+
})), !t.headless && (an(t.prosemirrorView.root), e.dataTransfer.setDragImage(K, 0, 0), e.dataTransfer.effectAllowed = "move");
|
|
1468
1729
|
},
|
|
1469
|
-
rowDragStart(
|
|
1470
|
-
if (
|
|
1471
|
-
|
|
1730
|
+
rowDragStart(e) {
|
|
1731
|
+
if (n.state === void 0 || n.state.rowIndex === void 0) throw Error("Attempted to drag table row, but no table block was hovered prior.");
|
|
1732
|
+
n.state.draggingState = {
|
|
1472
1733
|
draggedCellOrientation: "row",
|
|
1473
|
-
originalIndex:
|
|
1474
|
-
mousePos:
|
|
1475
|
-
},
|
|
1476
|
-
draggedCellOrientation:
|
|
1477
|
-
originalIndex:
|
|
1478
|
-
newIndex:
|
|
1479
|
-
tablePos:
|
|
1480
|
-
})), !
|
|
1734
|
+
originalIndex: n.state.rowIndex,
|
|
1735
|
+
mousePos: e.clientY
|
|
1736
|
+
}, n.emitUpdate(), t.transact((e) => e.setMeta(J, {
|
|
1737
|
+
draggedCellOrientation: n.state.draggingState.draggedCellOrientation,
|
|
1738
|
+
originalIndex: n.state.rowIndex,
|
|
1739
|
+
newIndex: n.state.rowIndex,
|
|
1740
|
+
tablePos: n.tablePos
|
|
1741
|
+
})), !t.headless && (an(t.prosemirrorView.root), e.dataTransfer.setDragImage(K, 0, 0), e.dataTransfer.effectAllowed = "copyMove");
|
|
1481
1742
|
},
|
|
1482
1743
|
dragEnd() {
|
|
1483
|
-
if (
|
|
1484
|
-
|
|
1744
|
+
if (n.state === void 0) throw Error("Attempted to drag table row, but no table block was hovered prior.");
|
|
1745
|
+
n.state.draggingState = void 0, n.emitUpdate(), t.transact((e) => e.setMeta(J, null)), !t.headless && on(t.prosemirrorView.root);
|
|
1485
1746
|
},
|
|
1486
1747
|
freezeHandles() {
|
|
1487
|
-
|
|
1748
|
+
n.menuFrozen = !0;
|
|
1488
1749
|
},
|
|
1489
1750
|
unfreezeHandles() {
|
|
1490
|
-
|
|
1751
|
+
n.menuFrozen = !1;
|
|
1491
1752
|
},
|
|
1492
1753
|
hideHandlesIfNotFrozen() {
|
|
1493
|
-
|
|
1754
|
+
n.menuFrozen || n.hideHandles();
|
|
1494
1755
|
},
|
|
1495
1756
|
getCellsAtRowHandle(e, t) {
|
|
1496
|
-
return
|
|
1757
|
+
return p(e, t);
|
|
1497
1758
|
},
|
|
1498
|
-
getCellsAtColumnHandle(e,
|
|
1499
|
-
return
|
|
1759
|
+
getCellsAtColumnHandle(e, t) {
|
|
1760
|
+
return d(e, t);
|
|
1500
1761
|
},
|
|
1501
|
-
setCellSelection(e, t,
|
|
1502
|
-
if (!
|
|
1503
|
-
let i =
|
|
1504
|
-
|
|
1762
|
+
setCellSelection(e, t, r = t) {
|
|
1763
|
+
if (!n) throw Error("Table handles view not initialized");
|
|
1764
|
+
let i = n.getTablePos(e.doc);
|
|
1765
|
+
if (i === void 0) throw Error("Attempted to select table cells, but the hovered table is no longer in the document.");
|
|
1766
|
+
let a = e.doc.resolve(i + 1), o = e.doc.resolve(a.posAtIndex(t.row) + 1), s = e.doc.resolve(o.posAtIndex(t.col)), c = e.doc.resolve(a.posAtIndex(r.row) + 1), l = e.doc.resolve(c.posAtIndex(r.col)), u = e.tr;
|
|
1767
|
+
return u.setSelection(new me(s, l)), e.apply(u);
|
|
1505
1768
|
},
|
|
1506
|
-
addRowOrColumn(
|
|
1507
|
-
|
|
1508
|
-
let i = this.setCellSelection(
|
|
1509
|
-
row:
|
|
1769
|
+
addRowOrColumn(e, n) {
|
|
1770
|
+
t.exec((t, r) => {
|
|
1771
|
+
let i = this.setCellSelection(t, n.orientation === "row" ? {
|
|
1772
|
+
row: e,
|
|
1510
1773
|
col: 0
|
|
1511
1774
|
} : {
|
|
1512
1775
|
row: 0,
|
|
1513
|
-
col:
|
|
1776
|
+
col: e
|
|
1514
1777
|
});
|
|
1515
|
-
return n.orientation === "row" ? n.side === "above" ?
|
|
1778
|
+
return n.orientation === "row" ? n.side === "above" ? ve(i, r) : _e(i, r) : n.side === "left" ? ge(i, r) : he(i, r);
|
|
1516
1779
|
});
|
|
1517
1780
|
},
|
|
1518
|
-
removeRowOrColumn(
|
|
1519
|
-
return n === "row" ?
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
}), n)
|
|
1781
|
+
removeRowOrColumn(e, n) {
|
|
1782
|
+
return n === "row" ? t.exec((t, n) => {
|
|
1783
|
+
let r = this.setCellSelection(t, {
|
|
1784
|
+
row: e,
|
|
1785
|
+
col: 0
|
|
1786
|
+
});
|
|
1787
|
+
return be(r, n);
|
|
1788
|
+
}) : t.exec((t, n) => {
|
|
1789
|
+
let r = this.setCellSelection(t, {
|
|
1790
|
+
row: 0,
|
|
1791
|
+
col: e
|
|
1792
|
+
});
|
|
1793
|
+
return ye(r, n);
|
|
1794
|
+
});
|
|
1526
1795
|
},
|
|
1527
|
-
mergeCells(
|
|
1528
|
-
return
|
|
1796
|
+
mergeCells(e) {
|
|
1797
|
+
return t.exec((t, n) => {
|
|
1798
|
+
let r = e ? this.setCellSelection(t, e.relativeStartCell, e.relativeEndCell) : t;
|
|
1799
|
+
return xe(r, n);
|
|
1800
|
+
});
|
|
1529
1801
|
},
|
|
1530
|
-
splitCell(
|
|
1531
|
-
return
|
|
1802
|
+
splitCell(e) {
|
|
1803
|
+
return t.exec((t, n) => {
|
|
1804
|
+
let r = e ? this.setCellSelection(t, e) : t;
|
|
1805
|
+
return Se(r, n);
|
|
1806
|
+
});
|
|
1532
1807
|
},
|
|
1533
1808
|
getCellSelection() {
|
|
1534
|
-
return
|
|
1809
|
+
return t.transact((e) => {
|
|
1535
1810
|
let t = e.selection, n = t.$from, r = t.$to;
|
|
1536
1811
|
if (_(t)) {
|
|
1537
1812
|
let { ranges: e } = t;
|
|
@@ -1540,7 +1815,7 @@ var Gt = class {
|
|
|
1540
1815
|
});
|
|
1541
1816
|
} else {
|
|
1542
1817
|
let i = t.$from.pos - t.$from.parentOffset - 1, a = t.$to.pos - t.$to.parentOffset - 1;
|
|
1543
|
-
if (i < 0 || a < 0 || (n = e.doc.resolve(i), r = e.doc.resolve(a), !
|
|
1818
|
+
if (i < 0 || a < 0 || (n = e.doc.resolve(i), r = e.doc.resolve(a), !m(n.parent) || !m(r.parent))) return;
|
|
1544
1819
|
}
|
|
1545
1820
|
let i = e.doc.resolve(n.pos - n.parentOffset - 1), a = e.doc.resolve(r.pos - r.parentOffset - 1), o = e.doc.resolve(i.pos - i.parentOffset - 1), s = n.index(i.depth), c = i.index(o.depth), l = r.index(a.depth), u = a.index(o.depth), d = [];
|
|
1546
1821
|
for (let e = c; e <= u; e++) for (let t = s; t <= l; t++) d.push({
|
|
@@ -1560,37 +1835,37 @@ var Gt = class {
|
|
|
1560
1835
|
};
|
|
1561
1836
|
});
|
|
1562
1837
|
},
|
|
1563
|
-
getMergeDirection(
|
|
1564
|
-
return
|
|
1565
|
-
let n = _(
|
|
1566
|
-
if (!n || !
|
|
1838
|
+
getMergeDirection(e) {
|
|
1839
|
+
return t.transact((t) => {
|
|
1840
|
+
let n = _(t.selection) ? t.selection : void 0;
|
|
1841
|
+
if (!n || !e || n.ranges.length <= 1) return;
|
|
1567
1842
|
let r = this.getCellSelection();
|
|
1568
|
-
if (r) return
|
|
1843
|
+
if (r) return ne(r.from, r.to, e) ? "vertical" : "horizontal";
|
|
1569
1844
|
});
|
|
1570
1845
|
},
|
|
1571
1846
|
cropEmptyRowsOrColumns(e, t) {
|
|
1572
|
-
return
|
|
1847
|
+
return r(e, t);
|
|
1573
1848
|
},
|
|
1574
|
-
addRowsOrColumns(e, t,
|
|
1575
|
-
return
|
|
1849
|
+
addRowsOrColumns(e, t, n) {
|
|
1850
|
+
return l(e, t, n);
|
|
1576
1851
|
}
|
|
1577
1852
|
};
|
|
1578
1853
|
}), Y = new w("trailingNode");
|
|
1579
1854
|
function X(e) {
|
|
1580
1855
|
let t = e.lastChild, n = t?.firstChild;
|
|
1581
|
-
return
|
|
1856
|
+
return t?.type.name !== "blockContainer" || n?.type.name !== "paragraph" || n.content.size !== 0;
|
|
1582
1857
|
}
|
|
1583
|
-
function
|
|
1858
|
+
function dn(e) {
|
|
1584
1859
|
if (!e.type.schema.nodes.column) {
|
|
1585
1860
|
let t = e.lastChild;
|
|
1586
1861
|
return t && X(t) ? [e.content.size - 1] : [];
|
|
1587
1862
|
}
|
|
1588
1863
|
let t = [];
|
|
1589
|
-
return e.descendants((e, n, r) => e.isTextblock
|
|
1864
|
+
return e.descendants((e, n, r) => !e.isTextblock && ((e.type.name === "column" || e.type.name === "blockGroup" && r?.type.name === "doc") && X(e) && t.push(n + e.nodeSize - 1), !0)), t;
|
|
1590
1865
|
}
|
|
1591
|
-
var
|
|
1866
|
+
var fn = b(({ editor: e }) => {
|
|
1592
1867
|
function t(t) {
|
|
1593
|
-
return
|
|
1868
|
+
return D.widget(t, () => {
|
|
1594
1869
|
let t = document.createElement("div");
|
|
1595
1870
|
return t.className = "bn-trailing-block", t.contentEditable = "false", t.addEventListener("mousedown", (n) => {
|
|
1596
1871
|
n.preventDefault();
|
|
@@ -1605,7 +1880,7 @@ var Jt = b(({ editor: e }) => {
|
|
|
1605
1880
|
}, { side: 1 });
|
|
1606
1881
|
}
|
|
1607
1882
|
function n(e, n, r) {
|
|
1608
|
-
let i = n.map(e.mapping, e.doc), a = new Set(r ?
|
|
1883
|
+
let i = n.map(e.mapping, e.doc), a = new Set(r ? dn(e.doc) : []), o = /* @__PURE__ */ new Set(), s = [];
|
|
1609
1884
|
for (let e of i.find()) a.has(e.from) && !o.has(e.from) ? o.add(e.from) : s.push(e);
|
|
1610
1885
|
let c = [...a].filter((e) => !o.has(e)), l = i;
|
|
1611
1886
|
return s.length > 0 && (l = l.remove(s)), c.length > 0 && (l = l.add(e.doc, c.map(t))), l;
|
|
@@ -1615,7 +1890,7 @@ var Jt = b(({ editor: e }) => {
|
|
|
1615
1890
|
prosemirrorPlugins: [new C({
|
|
1616
1891
|
key: Y,
|
|
1617
1892
|
state: {
|
|
1618
|
-
init: (t, r) => n(r.tr,
|
|
1893
|
+
init: (t, r) => n(r.tr, O.empty, e.isEditable),
|
|
1619
1894
|
apply: (t, r) => !t.docChanged && !t.getMeta(Y) ? r : n(t, r, e.isEditable)
|
|
1620
1895
|
},
|
|
1621
1896
|
view(e) {
|
|
@@ -1646,7 +1921,7 @@ function $(e) {
|
|
|
1646
1921
|
let t = typeof e == "object" ? e.id : e;
|
|
1647
1922
|
throw Error(`Snapshot not found: ${String(t)}`);
|
|
1648
1923
|
}
|
|
1649
|
-
var
|
|
1924
|
+
var pn = b(({ options: e, editor: t }) => {
|
|
1650
1925
|
let { endpoints: n, preview: r, getCurrentDocument: i, serializeCurrentContent: a, resolveUsers: o } = typeof e == "function" ? e(t) : e, s = typeof n == "function" ? n(t) : n, c = re(o), l = y({
|
|
1651
1926
|
snapshots: [],
|
|
1652
1927
|
previewedSnapshotId: void 0,
|
|
@@ -1762,10 +2037,10 @@ var Yt = b(({ options: e, editor: t }) => {
|
|
|
1762
2037
|
});
|
|
1763
2038
|
//#endregion
|
|
1764
2039
|
//#region src/extensions/Versioning/inMemoryVersioning.ts
|
|
1765
|
-
function
|
|
2040
|
+
function mn(e) {
|
|
1766
2041
|
return e.id === Z ? "Current version" : e.name ?? "Unnamed version";
|
|
1767
2042
|
}
|
|
1768
|
-
function
|
|
2043
|
+
function hn(e) {
|
|
1769
2044
|
let t, n = !1, r = (t) => {
|
|
1770
2045
|
e.replaceBlocks(e.document, t);
|
|
1771
2046
|
}, i = () => e.getExtension("diffVersioning");
|
|
@@ -1777,7 +2052,7 @@ function Zt(e) {
|
|
|
1777
2052
|
t === void 0 && (t = e.document);
|
|
1778
2053
|
let l = i();
|
|
1779
2054
|
if (o && l) {
|
|
1780
|
-
l.renderDiff(a, o, c &&
|
|
2055
|
+
l.renderDiff(a, o, c && mn(c.snapshot)), n = !0;
|
|
1781
2056
|
return;
|
|
1782
2057
|
}
|
|
1783
2058
|
n = !1, r(a);
|
|
@@ -1794,32 +2069,35 @@ function Zt(e) {
|
|
|
1794
2069
|
}
|
|
1795
2070
|
};
|
|
1796
2071
|
}
|
|
1797
|
-
function
|
|
1798
|
-
let e = [], t = /* @__PURE__ */ new Map(), n = 1;
|
|
2072
|
+
function gn() {
|
|
2073
|
+
let e = [], t = /* @__PURE__ */ new Map(), n = 1, r = 0;
|
|
2074
|
+
function i() {
|
|
2075
|
+
return r = Math.max(Date.now(), r + 1), r;
|
|
2076
|
+
}
|
|
1799
2077
|
return {
|
|
1800
2078
|
async list() {
|
|
1801
2079
|
return Q([...e]);
|
|
1802
2080
|
},
|
|
1803
|
-
async create(r,
|
|
1804
|
-
let
|
|
1805
|
-
id:
|
|
1806
|
-
name:
|
|
1807
|
-
createdAt:
|
|
1808
|
-
updatedAt:
|
|
2081
|
+
async create(r, a) {
|
|
2082
|
+
let o = i(), s = String(n++), c = {
|
|
2083
|
+
id: s,
|
|
2084
|
+
name: a?.name,
|
|
2085
|
+
createdAt: o,
|
|
2086
|
+
updatedAt: o
|
|
1809
2087
|
};
|
|
1810
|
-
return e.push(
|
|
2088
|
+
return e.push(c), t.set(s, structuredClone(r)), c;
|
|
1811
2089
|
},
|
|
1812
|
-
async restore(r,
|
|
1813
|
-
let
|
|
1814
|
-
if (!
|
|
1815
|
-
let
|
|
1816
|
-
id:
|
|
2090
|
+
async restore(r, a) {
|
|
2091
|
+
let o = String(a.id), s = t.get(o);
|
|
2092
|
+
if (!s) throw Error(`Snapshot ${o} not found`);
|
|
2093
|
+
let c = i(), l = String(n++), u = {
|
|
2094
|
+
id: l,
|
|
1817
2095
|
name: "Before restore",
|
|
1818
|
-
createdAt:
|
|
1819
|
-
updatedAt:
|
|
1820
|
-
restoredFromSnapshotId:
|
|
2096
|
+
createdAt: c,
|
|
2097
|
+
updatedAt: c,
|
|
2098
|
+
restoredFromSnapshotId: o
|
|
1821
2099
|
};
|
|
1822
|
-
return e.push(
|
|
2100
|
+
return e.push(u), t.set(l, structuredClone(r)), structuredClone(s);
|
|
1823
2101
|
},
|
|
1824
2102
|
async getContent(e) {
|
|
1825
2103
|
let n = String(e.id), r = t.get(n);
|
|
@@ -1829,7 +2107,7 @@ function Qt() {
|
|
|
1829
2107
|
async rename(t, n) {
|
|
1830
2108
|
let r = e.find((e) => e.id === t.id);
|
|
1831
2109
|
if (!r) throw Error(`Snapshot ${String(t.id)} not found`);
|
|
1832
|
-
r.name = n, r.updatedAt =
|
|
2110
|
+
r.name = n, r.updatedAt = i();
|
|
1833
2111
|
},
|
|
1834
2112
|
async remove(n) {
|
|
1835
2113
|
let r = e.findIndex((e) => e.id === n.id);
|
|
@@ -1838,8 +2116,8 @@ function Qt() {
|
|
|
1838
2116
|
}
|
|
1839
2117
|
};
|
|
1840
2118
|
}
|
|
1841
|
-
function
|
|
1842
|
-
let t =
|
|
2119
|
+
function _n(e) {
|
|
2120
|
+
let t = gn();
|
|
1843
2121
|
return {
|
|
1844
2122
|
endpoints: {
|
|
1845
2123
|
...t,
|
|
@@ -1849,12 +2127,12 @@ function $t(e) {
|
|
|
1849
2127
|
updatedAt: Date.now()
|
|
1850
2128
|
}, ...await t.list()]
|
|
1851
2129
|
},
|
|
1852
|
-
preview:
|
|
2130
|
+
preview: hn(e),
|
|
1853
2131
|
getCurrentDocument: () => e.document,
|
|
1854
2132
|
serializeCurrentContent: () => e.document
|
|
1855
2133
|
};
|
|
1856
2134
|
}
|
|
1857
2135
|
//#endregion
|
|
1858
|
-
export {
|
|
2136
|
+
export { Ze as A, ct as C, nt as D, rt as E, k as F, Xe as M, Ue as N, tt as O, He as P, dt as S, at as T, Gt as _, pn as a, Rt as b, un as c, rn as d, tn as f, qt as g, Jt as h, Z as i, Ye as j, et as k, ln as l, Yt as m, _n as n, Q as o, en as p, gn as r, fn as s, hn as t, J as u, Kt as v, st as w, z as x, B as y };
|
|
1859
2137
|
|
|
1860
|
-
//# sourceMappingURL=extensions-
|
|
2138
|
+
//# sourceMappingURL=extensions-D6JcJCwd.js.map
|