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