@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,97 +1,135 @@
|
|
|
1
|
-
import { $n as e,
|
|
2
|
-
import { r as me, t as he } from "./BlockNoteExtension-
|
|
3
|
-
import { A as ge,
|
|
4
|
-
import { r as
|
|
5
|
-
import { t as
|
|
6
|
-
import { DOMParser as
|
|
7
|
-
import { ReplaceAroundStep as
|
|
8
|
-
import { Editor as
|
|
9
|
-
import { NodeSelection as
|
|
10
|
-
import { Fragment as
|
|
11
|
-
import { CellSelection as
|
|
12
|
-
import { Plugin as
|
|
13
|
-
import { digestString as
|
|
14
|
-
import { InputRule as
|
|
15
|
-
import { keymap as
|
|
16
|
-
import { Text as
|
|
17
|
-
import { Gapcursor as
|
|
1
|
+
import { $n as e, Cn as t, Dn as n, En as r, Et as i, Fn as a, G as o, Hn as s, It as c, Lt as l, Mn as u, Mt as d, Nt as f, Pt as p, Rt as m, Sn as h, Tn as g, Un as _, Xt as ee, _n as te, an as ne, ar as re, er as v, f as ie, in as y, jt as ae, k as b, kn as oe, m as x, nr as S, on as se, or as C, rr as w, t as ce, tr as T, wn as le, wt as ue, xn as de, xt as fe } from "./blocks-CzQLehlc.js";
|
|
2
|
+
import { o as pe, r as me, t as he } from "./BlockNoteExtension-CbvDA0F7.js";
|
|
3
|
+
import { A as ge, C as _e, F as ve, M as ye, N as be, O as xe, P as Se, S as Ce, T as we, b as Te, c as Ee, g as De, h as Oe, k as ke, m as Ae, s as je, w as Me, x as Ne, y as Pe } from "./extensions-DGuhtOgB.js";
|
|
4
|
+
import { r as Fe } from "./UserStore-C4TzkGEn.js";
|
|
5
|
+
import { t as Ie } from "./en-uzHzj6eH.js";
|
|
6
|
+
import { DOMParser as Le, DOMSerializer as Re, Fragment as E, NodeRange as ze, Slice as D } from "prosemirror-model";
|
|
7
|
+
import { ReplaceAroundStep as O, ReplaceStep as Be, canJoin as Ve, liftTarget as He } from "prosemirror-transform";
|
|
8
|
+
import { Editor as Ue, Extension as k, Mark as We, Node as A, combineTransactionSteps as Ge, createDocument as Ke, extensions as j, findChildrenInRange as qe, findParentNodeClosestToPos as Je, getAttributes as Ye, getChangedRanges as Xe, getMarkRange as Ze, getMarksBetween as Qe, getSchema as $e, isNodeSelection as et, markPasteRule as tt, mergeAttributes as M, posToDOMRect as nt, selectionToInsertionEnd as rt } from "@tiptap/core";
|
|
9
|
+
import { NodeSelection as N, Plugin as P, TextSelection as F } from "prosemirror-state";
|
|
10
|
+
import { DOMParser as it, Fragment as I, Slice as L } from "@tiptap/pm/model";
|
|
11
|
+
import { CellSelection as at, TableMap as ot } from "prosemirror-tables";
|
|
12
|
+
import { Plugin as st, PluginKey as ct } from "@tiptap/pm/state";
|
|
13
|
+
import { digestString as lt } from "lib0/hash/fnv1a";
|
|
14
|
+
import { InputRule as ut, inputRules as dt } from "@handlewithcare/prosemirror-inputrules";
|
|
15
|
+
import { keymap as ft } from "@tiptap/pm/keymap";
|
|
16
|
+
import { Text as pt } from "@tiptap/extension-text";
|
|
17
|
+
import { Gapcursor as mt } from "@tiptap/extensions/gap-cursor";
|
|
18
|
+
//#region src/schema/blocks/types.ts
|
|
19
|
+
function ht(e) {
|
|
20
|
+
return typeof e == "string" ? e : e.map((e) => typeof e == "string" ? e : e.text).join("");
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
18
23
|
//#region src/schema/inlineContent/createSpec.ts
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
function gt(e) {
|
|
25
|
+
return e.matches("[data-editable]") ? e : e.querySelector("[data-editable]") || e;
|
|
26
|
+
}
|
|
27
|
+
function _t(e, t) {
|
|
28
|
+
return it.fromSchema(t).parse(e, {
|
|
29
|
+
topNode: t.nodes.paragraph.create(),
|
|
30
|
+
preserveWhitespace: !0
|
|
31
|
+
}).content;
|
|
32
|
+
}
|
|
33
|
+
function vt(e, t) {
|
|
34
|
+
let n = [];
|
|
35
|
+
return e.forEach((e) => {
|
|
36
|
+
if (e.isText) n.push(e);
|
|
37
|
+
else {
|
|
38
|
+
let r = e.type === t.linebreakReplacement ? "\n" : e.textContent;
|
|
39
|
+
r && n.push(t.text(r, e.marks));
|
|
25
40
|
}
|
|
41
|
+
}), I.fromArray(n);
|
|
42
|
+
}
|
|
43
|
+
function yt(e, t, n) {
|
|
44
|
+
let r = e.content === "plain" || n && e.content === "styled" ? (t) => (r, i) => {
|
|
45
|
+
let a = n?.({
|
|
46
|
+
el: r,
|
|
47
|
+
schema: i
|
|
48
|
+
});
|
|
49
|
+
if (a !== void 0) return e.content === "plain" ? vt(a, i) : a;
|
|
50
|
+
let o = _t(t(r), i);
|
|
51
|
+
return e.content === "plain" ? vt(o, i) : o;
|
|
52
|
+
} : void 0, i = [{
|
|
53
|
+
tag: `[data-inline-content-type="${e.type}"]`,
|
|
54
|
+
contentElement: (e) => gt(e),
|
|
55
|
+
getContent: r ? (e, t) => r(gt)(e, t) : void 0
|
|
26
56
|
}];
|
|
27
|
-
return t &&
|
|
57
|
+
return t && i.push({
|
|
28
58
|
tag: "*",
|
|
29
59
|
getAttrs(e) {
|
|
30
60
|
if (typeof e == "string") return !1;
|
|
31
61
|
let n = t?.(e);
|
|
32
|
-
return n
|
|
33
|
-
}
|
|
34
|
-
|
|
62
|
+
return n !== void 0 && n;
|
|
63
|
+
},
|
|
64
|
+
preserveWhitespace: r ? !0 : void 0,
|
|
65
|
+
getContent: r ? (e, t) => r((e) => e)(e, t) : void 0
|
|
66
|
+
}), i;
|
|
35
67
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
68
|
+
function bt(e, t) {
|
|
69
|
+
let n = A.create({
|
|
38
70
|
name: e.type,
|
|
39
71
|
inline: !0,
|
|
40
72
|
group: "inline",
|
|
41
|
-
draggable:
|
|
42
|
-
selectable: e.content
|
|
73
|
+
draggable: t.meta?.draggable,
|
|
74
|
+
selectable: e.content !== "none",
|
|
43
75
|
atom: e.content === "none",
|
|
44
|
-
|
|
76
|
+
code: t.meta?.code,
|
|
77
|
+
content: e.content === "styled" ? "inline*" : e.content === "plain" ? "text*" : "",
|
|
78
|
+
marks() {
|
|
79
|
+
return e.content === "plain" ? pe(this.editor) : void 0;
|
|
80
|
+
},
|
|
45
81
|
addAttributes() {
|
|
46
|
-
return
|
|
82
|
+
return te(e.propSchema);
|
|
47
83
|
},
|
|
48
84
|
addKeyboardShortcuts() {
|
|
49
|
-
return
|
|
85
|
+
return ne(e);
|
|
50
86
|
},
|
|
51
87
|
parseHTML() {
|
|
52
|
-
return
|
|
88
|
+
return yt(e, t.parse, t.parseContent);
|
|
53
89
|
},
|
|
54
|
-
renderHTML({ node:
|
|
55
|
-
let i = this.options.editor
|
|
56
|
-
return t(n.render.call({
|
|
90
|
+
renderHTML({ node: n }) {
|
|
91
|
+
let i = this.options.editor, a = t.render.call({
|
|
57
92
|
renderType: "dom",
|
|
58
93
|
props: void 0
|
|
59
|
-
},
|
|
94
|
+
}, r(n, i.schema.inlineContentSchema, i.schema.styleSchema), () => {}, i, n, () => void 0);
|
|
95
|
+
return y(a, e.type, n.attrs, e.propSchema);
|
|
60
96
|
},
|
|
61
97
|
addNodeView() {
|
|
62
|
-
return (
|
|
63
|
-
let { node: i, getPos:
|
|
64
|
-
return t(n.render.call({
|
|
98
|
+
return (n) => {
|
|
99
|
+
let { node: i, getPos: o } = n, s = this.options.editor, c = t.render.call({
|
|
65
100
|
renderType: "nodeView",
|
|
66
|
-
props:
|
|
67
|
-
},
|
|
68
|
-
let t =
|
|
69
|
-
n &&
|
|
70
|
-
}, o), e.type, i.attrs, e.propSchema);
|
|
101
|
+
props: n
|
|
102
|
+
}, r(i, s.schema.inlineContentSchema, s.schema.styleSchema), (e) => {
|
|
103
|
+
let t = l([e], s.pmSchema), n = o();
|
|
104
|
+
n && s.transact((e) => e.replaceWith(n, n + i.nodeSize, t));
|
|
105
|
+
}, s, i, o), u = y(c, e.type, i.attrs, e.propSchema);
|
|
106
|
+
return a(u), u;
|
|
71
107
|
};
|
|
72
108
|
}
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
109
|
+
});
|
|
110
|
+
return se(n, e.propSchema, {
|
|
111
|
+
...t,
|
|
112
|
+
toExternalHTML: t.toExternalHTML,
|
|
113
|
+
render(n, r, i) {
|
|
114
|
+
let a = l([n], i.pmSchema)[0], o = t.render(n, r, i, a, () => void 0);
|
|
115
|
+
return y(o, e.type, n.props, e.propSchema);
|
|
78
116
|
}
|
|
79
117
|
});
|
|
80
118
|
}
|
|
81
119
|
//#endregion
|
|
82
120
|
//#region src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts
|
|
83
|
-
function
|
|
84
|
-
let
|
|
85
|
-
let t =
|
|
121
|
+
function xt(e, t, n, r = "before") {
|
|
122
|
+
let i = typeof n == "string" ? n : n.id, a = u(e), o = t.map((e) => {
|
|
123
|
+
let t = c(e, a);
|
|
86
124
|
return t.check(), t;
|
|
87
|
-
}),
|
|
88
|
-
if (!
|
|
89
|
-
let l =
|
|
90
|
-
return r === "after" && (l +=
|
|
125
|
+
}), s = p(i, e.doc);
|
|
126
|
+
if (!s) throw Error(`Block with ID ${i} not found`);
|
|
127
|
+
let l = s.posBeforeNode;
|
|
128
|
+
return r === "after" && (l += s.node.nodeSize), e.step(new Be(l, l, new D(E.from(o), 0, 0))), o.map((t) => g(t, e.doc));
|
|
91
129
|
}
|
|
92
130
|
//#endregion
|
|
93
131
|
//#region src/api/blockManipulation/commands/replaceBlocks/util/fixColumnList.ts
|
|
94
|
-
function
|
|
132
|
+
function R(e) {
|
|
95
133
|
if (!e || e.type.name !== "column") throw Error("Invalid columnPos: does not point to column node.");
|
|
96
134
|
let t = e.firstChild;
|
|
97
135
|
if (!t) throw Error("Invalid column: does not have child node.");
|
|
@@ -99,89 +137,89 @@ function I(e) {
|
|
|
99
137
|
if (!n) throw Error("Invalid blockContainer: does not have child node.");
|
|
100
138
|
return e.childCount === 1 && t.childCount === 1 && n.type.name === "paragraph" && n.content.content.length === 0;
|
|
101
139
|
}
|
|
102
|
-
function
|
|
140
|
+
function St(e, t) {
|
|
103
141
|
let n = e.doc.resolve(t), r = n.nodeAfter;
|
|
104
142
|
if (!r || r.type.name !== "columnList") throw Error("Invalid columnListPos: does not point to columnList node.");
|
|
105
143
|
for (let t = r.childCount - 1; t >= 0; t--) {
|
|
106
144
|
let r = e.doc.resolve(n.pos + 1).posAtIndex(t), i = e.doc.resolve(r).nodeAfter;
|
|
107
145
|
if (!i || i.type.name !== "column") throw Error("Invalid columnPos: does not point to column node.");
|
|
108
|
-
|
|
146
|
+
R(i) && e.delete(r, r + i.nodeSize);
|
|
109
147
|
}
|
|
110
148
|
}
|
|
111
|
-
function
|
|
112
|
-
|
|
149
|
+
function z(e, t) {
|
|
150
|
+
St(e, t);
|
|
113
151
|
let n = e.doc.resolve(t).nodeAfter;
|
|
114
152
|
if (!n || n.type.name !== "columnList") throw Error("Invalid columnListPos: does not point to columnList node.");
|
|
115
153
|
if (n.childCount > 2) return;
|
|
116
154
|
if (n.childCount < 2) throw Error("Invalid columnList: contains fewer than two children.");
|
|
117
155
|
let r = t + 1, i = e.doc.resolve(r).nodeAfter, a = t + n.nodeSize - 1, o = e.doc.resolve(a).nodeBefore;
|
|
118
156
|
if (!i || !o) throw Error("Invalid columnList: does not contain children.");
|
|
119
|
-
let s =
|
|
157
|
+
let s = R(i), c = R(o);
|
|
120
158
|
if (s && c) {
|
|
121
159
|
e.delete(t, t + n.nodeSize);
|
|
122
160
|
return;
|
|
123
161
|
}
|
|
124
162
|
if (s) {
|
|
125
|
-
e.step(new
|
|
163
|
+
e.step(new O(t, t + n.nodeSize, a - o.nodeSize + 1, a - 1, D.empty, 0, !1));
|
|
126
164
|
return;
|
|
127
165
|
}
|
|
128
166
|
if (c) {
|
|
129
|
-
e.step(new
|
|
167
|
+
e.step(new O(t, t + n.nodeSize, r + 1, r + i.nodeSize - 1, D.empty, 0, !1));
|
|
130
168
|
return;
|
|
131
169
|
}
|
|
132
170
|
}
|
|
133
171
|
//#endregion
|
|
134
172
|
//#region src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts
|
|
135
|
-
function
|
|
136
|
-
let
|
|
137
|
-
let t =
|
|
173
|
+
function B(e, t, n, r = {}) {
|
|
174
|
+
let i = u(e), a = n.map((e) => {
|
|
175
|
+
let t = c(e, i);
|
|
138
176
|
return t.check(), t;
|
|
139
|
-
}),
|
|
140
|
-
if (
|
|
141
|
-
if (
|
|
142
|
-
if (!
|
|
143
|
-
let
|
|
144
|
-
if (!
|
|
145
|
-
if (
|
|
146
|
-
let
|
|
147
|
-
|
|
148
|
-
let n =
|
|
149
|
-
f +=
|
|
177
|
+
}), o = new Set(t.map((e) => typeof e == "string" ? e : e.id)), s = [], l = /* @__PURE__ */ new Set(), d = typeof t[0] == "string" ? t[0] : t[0].id, f = 0;
|
|
178
|
+
if (e.doc.descendants((t, r) => {
|
|
179
|
+
if (o.size === 0) return !1;
|
|
180
|
+
if (!t.type.isInGroup("bnBlock")) return !0;
|
|
181
|
+
let i = C(t, e.doc);
|
|
182
|
+
if (!o.has(i)) return !0;
|
|
183
|
+
if (s.push(g(t, e.doc)), o.delete(i), n.length > 0 && i === d) {
|
|
184
|
+
let t = e.doc.nodeSize;
|
|
185
|
+
e.insert(r, a);
|
|
186
|
+
let n = e.doc.nodeSize;
|
|
187
|
+
f += t - n;
|
|
150
188
|
}
|
|
151
|
-
let
|
|
152
|
-
|
|
153
|
-
let
|
|
154
|
-
return f +=
|
|
155
|
-
}),
|
|
156
|
-
let e = [...
|
|
189
|
+
let c = e.doc.nodeSize, u = e.doc.resolve(r - f);
|
|
190
|
+
u.node().type.name === "column" ? l.add(u.before(-1)) : u.node().type.name === "columnList" && l.add(u.before()), u.node().type.name === "blockGroup" && u.node(u.depth - 1).type.name !== "doc" && u.node().childCount === 1 ? e.delete(u.before(), u.after()) : e.delete(r - f, r - f + t.nodeSize);
|
|
191
|
+
let p = e.doc.nodeSize;
|
|
192
|
+
return f += c - p, !1;
|
|
193
|
+
}), o.size > 0) {
|
|
194
|
+
let e = [...o].join("\n");
|
|
157
195
|
throw Error("Blocks with the following IDs could not be found in the editor: " + e);
|
|
158
196
|
}
|
|
159
|
-
return
|
|
160
|
-
insertedBlocks:
|
|
161
|
-
removedBlocks:
|
|
197
|
+
return r.fixColumns !== !1 && l.forEach((t) => z(e, t)), {
|
|
198
|
+
insertedBlocks: a.map((t) => g(t, e.doc)),
|
|
199
|
+
removedBlocks: s
|
|
162
200
|
};
|
|
163
201
|
}
|
|
164
202
|
//#endregion
|
|
165
203
|
//#region src/api/exporters/html/util/serializeBlocksInternalHTML.ts
|
|
166
|
-
function
|
|
167
|
-
let
|
|
204
|
+
function Ct(e, t, n, i, a) {
|
|
205
|
+
let o;
|
|
168
206
|
if (!t) throw Error("blockContent is required");
|
|
169
|
-
if (typeof t == "string")
|
|
170
|
-
else if (Array.isArray(t))
|
|
171
|
-
else if (t.type === "tableContent")
|
|
172
|
-
else throw new
|
|
173
|
-
let
|
|
174
|
-
for (let t of
|
|
175
|
-
let
|
|
176
|
-
if (
|
|
177
|
-
let
|
|
207
|
+
if (typeof t == "string") o = l([t], e.pmSchema, i);
|
|
208
|
+
else if (Array.isArray(t)) o = l(t, e.pmSchema, i);
|
|
209
|
+
else if (t.type === "tableContent") o = m(t, e.pmSchema);
|
|
210
|
+
else throw new _(t.type);
|
|
211
|
+
let s = (a?.document ?? document).createDocumentFragment();
|
|
212
|
+
for (let t of o) if (t.type.name !== "text" && e.schema.inlineContentSchema[t.type.name]) {
|
|
213
|
+
let i = e.schema.inlineContentSpecs[t.type.name].implementation;
|
|
214
|
+
if (i) {
|
|
215
|
+
let o = r(t, e.schema.inlineContentSchema, e.schema.styleSchema), c = i.render.call({
|
|
178
216
|
renderType: "dom",
|
|
179
217
|
props: void 0
|
|
180
|
-
},
|
|
181
|
-
if (
|
|
182
|
-
if (
|
|
183
|
-
let e = n.serializeFragment(t.content,
|
|
184
|
-
|
|
218
|
+
}, o, () => {}, e);
|
|
219
|
+
if (c) {
|
|
220
|
+
if (s.appendChild(c.dom), c.contentDOM) {
|
|
221
|
+
let e = n.serializeFragment(t.content, a);
|
|
222
|
+
c.contentDOM.dataset.editable = "", c.contentDOM.appendChild(e);
|
|
185
223
|
}
|
|
186
224
|
continue;
|
|
187
225
|
}
|
|
@@ -192,17 +230,17 @@ function ht(e, t, n, r, i) {
|
|
|
192
230
|
let t = e.schema.styleSpecs[r.type.name].implementation.render(r.attrs.stringValue, e);
|
|
193
231
|
t.contentDOM.appendChild(n), n = t.dom;
|
|
194
232
|
} else {
|
|
195
|
-
let e = r.type.spec.toDOM(r, !0), t =
|
|
233
|
+
let e = r.type.spec.toDOM(r, !0), t = Re.renderSpec(document, e);
|
|
196
234
|
t.contentDOM.appendChild(n), n = t.dom;
|
|
197
235
|
}
|
|
198
|
-
|
|
236
|
+
s.appendChild(n);
|
|
199
237
|
} else {
|
|
200
|
-
let e = n.serializeFragment(
|
|
201
|
-
|
|
238
|
+
let e = n.serializeFragment(E.from([t]), a);
|
|
239
|
+
s.appendChild(e);
|
|
202
240
|
}
|
|
203
|
-
return
|
|
241
|
+
return s;
|
|
204
242
|
}
|
|
205
|
-
function
|
|
243
|
+
function wt(e, t, n, r) {
|
|
206
244
|
let i = e.pmSchema.nodes.blockContainer, a = t.props || {};
|
|
207
245
|
for (let [n, r] of Object.entries(e.schema.blockSchema[t.type].propSchema)) !(n in a) && r.default !== void 0 && (a[n] = r.default);
|
|
208
246
|
let o = t.children || [], s = e.blockImplementations[t.type].implementation.render.call({
|
|
@@ -214,12 +252,12 @@ function gt(e, t, n, r) {
|
|
|
214
252
|
children: o
|
|
215
253
|
}, e);
|
|
216
254
|
if (s.contentDOM && t.content) {
|
|
217
|
-
let i =
|
|
255
|
+
let i = Ct(e, t.content, n, t.type, r);
|
|
218
256
|
s.contentDOM.appendChild(i);
|
|
219
257
|
}
|
|
220
258
|
if (e.pmSchema.nodes[t.type].isInGroup("bnBlock")) {
|
|
221
259
|
if (t.children && t.children.length > 0) {
|
|
222
|
-
let i =
|
|
260
|
+
let i = Tt(e, t.children, n, r);
|
|
223
261
|
s.contentDOM?.append(i);
|
|
224
262
|
}
|
|
225
263
|
return s.dom;
|
|
@@ -228,59 +266,59 @@ function gt(e, t, n, r) {
|
|
|
228
266
|
id: t.id,
|
|
229
267
|
...a
|
|
230
268
|
}));
|
|
231
|
-
return c.contentDOM?.appendChild(s.dom), t.children && t.children.length > 0 && c.contentDOM?.appendChild(
|
|
269
|
+
return c.contentDOM?.appendChild(s.dom), t.children && t.children.length > 0 && c.contentDOM?.appendChild(Et(e, t.children, n, r)), c.dom;
|
|
232
270
|
}
|
|
233
|
-
function
|
|
271
|
+
function Tt(e, t, n, r) {
|
|
234
272
|
let i = (r?.document ?? document).createDocumentFragment();
|
|
235
273
|
for (let a of t) {
|
|
236
|
-
let t =
|
|
274
|
+
let t = wt(e, a, n, r);
|
|
237
275
|
i.appendChild(t);
|
|
238
276
|
}
|
|
239
277
|
return i;
|
|
240
278
|
}
|
|
241
|
-
var
|
|
242
|
-
let i = e.pmSchema.nodes.blockGroup, a = i.spec.toDOM(i.create({})), o =
|
|
279
|
+
var Et = (e, t, n, r) => {
|
|
280
|
+
let i = e.pmSchema.nodes.blockGroup, a = i.spec.toDOM(i.create({})), o = Tt(e, t, n, r);
|
|
243
281
|
return a.contentDOM?.appendChild(o), a.dom;
|
|
244
|
-
},
|
|
282
|
+
}, Dt = (e) => (e.querySelectorAll("[data-content-type=\"numberedListItem\"]").forEach((e) => {
|
|
245
283
|
let t = e.closest(".bn-block-outer")?.previousElementSibling?.querySelector("[data-content-type=\"numberedListItem\"]");
|
|
246
284
|
if (!t) e.setAttribute("data-index", e.getAttribute("data-start") || "1");
|
|
247
285
|
else {
|
|
248
286
|
let n = t.getAttribute("data-index");
|
|
249
287
|
e.setAttribute("data-index", (parseInt(n || "0") + 1).toString());
|
|
250
288
|
}
|
|
251
|
-
}), e),
|
|
289
|
+
}), e), Ot = (e) => (e.querySelectorAll("[data-content-type=\"checkListItem\"] input").forEach((e) => {
|
|
252
290
|
e.disabled = !0;
|
|
253
|
-
}), e),
|
|
291
|
+
}), e), kt = (e) => (e.querySelectorAll(".bn-toggle-wrapper[data-show-children=\"false\"]").forEach((e) => {
|
|
254
292
|
e.setAttribute("data-show-children", "true");
|
|
255
|
-
}), e),
|
|
293
|
+
}), e), At = (e) => (e.querySelectorAll("[data-content-type=\"table\"] table").forEach((e) => {
|
|
256
294
|
e.setAttribute("style", "--default-cell-min-width: 120px;"), e.setAttribute("data-show-children", "true");
|
|
257
|
-
}), e),
|
|
295
|
+
}), e), jt = (e) => (e.querySelectorAll("[data-content-type=\"table\"] table").forEach((e) => {
|
|
258
296
|
let t = document.createElement("div");
|
|
259
297
|
t.className = "tableWrapper";
|
|
260
298
|
let n = document.createElement("div");
|
|
261
299
|
n.className = "tableWrapper-inner", t.appendChild(n), e.parentElement?.appendChild(t), t.appendChild(e);
|
|
262
|
-
}), e),
|
|
300
|
+
}), e), Mt = (e) => (e.querySelectorAll(".bn-inline-content:empty").forEach((e) => {
|
|
263
301
|
let t = document.createElement("span");
|
|
264
302
|
t.className = "ProseMirror-trailingBreak", t.setAttribute("style", "display: inline-block;"), e.appendChild(t);
|
|
265
|
-
}), e),
|
|
266
|
-
let n =
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
303
|
+
}), e), Nt = (e, t) => {
|
|
304
|
+
let n = Re.fromSchema(e), r = [
|
|
305
|
+
Dt,
|
|
306
|
+
Ot,
|
|
307
|
+
kt,
|
|
308
|
+
At,
|
|
309
|
+
jt,
|
|
310
|
+
Mt
|
|
273
311
|
];
|
|
274
312
|
return { serializeBlocks: (e, i) => {
|
|
275
|
-
let a =
|
|
313
|
+
let a = Et(t, e, n, i);
|
|
276
314
|
for (let e of r) a = e(a);
|
|
277
315
|
return a.outerHTML;
|
|
278
316
|
} };
|
|
279
|
-
},
|
|
317
|
+
}, Pt = (e) => {
|
|
280
318
|
let t = 0;
|
|
281
319
|
for (let n = 0; n < e.length; n++) t = Math.imul(31, t) + e.charCodeAt(n);
|
|
282
320
|
return Math.abs(t);
|
|
283
|
-
},
|
|
321
|
+
}, V = [
|
|
284
322
|
{
|
|
285
323
|
light: "#fff0c2",
|
|
286
324
|
dark: "#8a6d1a"
|
|
@@ -301,20 +339,20 @@ var vt = (e, t, n, r) => {
|
|
|
301
339
|
light: "#bef3ff",
|
|
302
340
|
dark: "#0a7a8a"
|
|
303
341
|
}
|
|
304
|
-
],
|
|
305
|
-
if (!t || t.length === 0) return
|
|
342
|
+
], Ft = (e) => V[Pt(e) % V.length], It = (e, t) => {
|
|
343
|
+
if (!t || t.length === 0) return V[0];
|
|
306
344
|
let n = t[0], r = e.getUser(n);
|
|
307
345
|
return r?.color && r.colorLight ? {
|
|
308
346
|
light: r.colorLight,
|
|
309
347
|
dark: r.color
|
|
310
|
-
} :
|
|
311
|
-
},
|
|
312
|
-
let t =
|
|
348
|
+
} : Ft(n);
|
|
349
|
+
}, Lt = (e) => lt(e).toString(16).padStart(8, "0"), Rt = (e) => {
|
|
350
|
+
let t = Lt(e);
|
|
313
351
|
return {
|
|
314
352
|
light: `--user-color-${t}-light`,
|
|
315
353
|
dark: `--user-color-${t}-dark`
|
|
316
354
|
};
|
|
317
|
-
},
|
|
355
|
+
}, H = class {
|
|
318
356
|
callbacks = {};
|
|
319
357
|
on(e, t) {
|
|
320
358
|
return this.callbacks[e] || (this.callbacks[e] = []), this.callbacks[e].push(t), () => this.off(e, t);
|
|
@@ -333,90 +371,90 @@ var vt = (e, t, n, r) => {
|
|
|
333
371
|
};
|
|
334
372
|
//#endregion
|
|
335
373
|
//#region src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts
|
|
336
|
-
function
|
|
337
|
-
return
|
|
338
|
-
let
|
|
339
|
-
if (
|
|
374
|
+
function zt(e) {
|
|
375
|
+
return e.transact((e) => {
|
|
376
|
+
let t = T(e, e.selection.anchor), n = C(t.bnBlock.node, e.doc);
|
|
377
|
+
if (e.selection instanceof at) return {
|
|
340
378
|
type: "cell",
|
|
341
|
-
anchorBlockId:
|
|
342
|
-
anchorCellOffset:
|
|
343
|
-
headCellOffset:
|
|
379
|
+
anchorBlockId: n,
|
|
380
|
+
anchorCellOffset: e.selection.$anchorCell.pos - t.bnBlock.beforePos,
|
|
381
|
+
headCellOffset: e.selection.$headCell.pos - t.bnBlock.beforePos
|
|
344
382
|
};
|
|
345
|
-
if (
|
|
383
|
+
if (e.selection instanceof N) return {
|
|
346
384
|
type: "node",
|
|
347
|
-
anchorBlockId:
|
|
385
|
+
anchorBlockId: n
|
|
348
386
|
};
|
|
349
387
|
{
|
|
350
|
-
let
|
|
388
|
+
let r = T(e, e.selection.head);
|
|
351
389
|
return {
|
|
352
390
|
type: "text",
|
|
353
|
-
anchorBlockId:
|
|
354
|
-
headBlockId:
|
|
355
|
-
anchorOffset:
|
|
356
|
-
headOffset:
|
|
391
|
+
anchorBlockId: n,
|
|
392
|
+
headBlockId: C(r.bnBlock.node, e.doc),
|
|
393
|
+
anchorOffset: e.selection.anchor - t.bnBlock.beforePos,
|
|
394
|
+
headOffset: e.selection.head - r.bnBlock.beforePos
|
|
357
395
|
};
|
|
358
396
|
}
|
|
359
397
|
});
|
|
360
398
|
}
|
|
361
|
-
function
|
|
362
|
-
let n =
|
|
399
|
+
function Bt(e, t) {
|
|
400
|
+
let n = p(t.anchorBlockId, e.doc)?.posBeforeNode;
|
|
363
401
|
if (n === void 0) throw Error(`Could not find block with ID ${t.anchorBlockId} to update selection`);
|
|
364
402
|
let r;
|
|
365
|
-
if (t.type === "cell") r =
|
|
366
|
-
else if (t.type === "node") r =
|
|
403
|
+
if (t.type === "cell") r = at.create(e.doc, n + t.anchorCellOffset, n + t.headCellOffset);
|
|
404
|
+
else if (t.type === "node") r = N.create(e.doc, n + 1);
|
|
367
405
|
else {
|
|
368
|
-
let i =
|
|
406
|
+
let i = p(t.headBlockId, e.doc)?.posBeforeNode;
|
|
369
407
|
if (i === void 0) throw Error(`Could not find block with ID ${t.headBlockId} to update selection`);
|
|
370
|
-
r =
|
|
408
|
+
r = F.create(e.doc, n + t.anchorOffset, i + t.headOffset);
|
|
371
409
|
}
|
|
372
410
|
e.setSelection(r);
|
|
373
411
|
}
|
|
374
|
-
function
|
|
412
|
+
function Vt(e) {
|
|
375
413
|
return e.flatMap((e) => e.type === "column" ? e.children : [e]);
|
|
376
414
|
}
|
|
377
|
-
function
|
|
415
|
+
function U(e, t, n, r) {
|
|
378
416
|
e.transact((e) => {
|
|
379
|
-
|
|
417
|
+
B(e, t, [], { fixColumns: !1 }), xt(e, Vt(t), n, r);
|
|
380
418
|
});
|
|
381
419
|
}
|
|
382
|
-
function
|
|
420
|
+
function Ht(e, t, n) {
|
|
383
421
|
e.transact((r) => {
|
|
384
|
-
let i = e.getSelection()?.blocks || [e.getTextCursorPosition().block], a =
|
|
385
|
-
|
|
422
|
+
let i = e.getSelection()?.blocks || [e.getTextCursorPosition().block], a = zt(e);
|
|
423
|
+
U(e, i, t, n), Bt(r, a);
|
|
386
424
|
});
|
|
387
425
|
}
|
|
388
|
-
function
|
|
426
|
+
function Ut(e) {
|
|
389
427
|
return !e || e.type !== "columnList";
|
|
390
428
|
}
|
|
391
|
-
function
|
|
429
|
+
function Wt(e, t, n) {
|
|
392
430
|
let r, i;
|
|
393
431
|
if (t ? t.children.length > 0 ? (r = t.children[t.children.length - 1], i = "after") : (r = t, i = "before") : n && (r = n, i = "before"), !r || !i) return;
|
|
394
432
|
let a = e.getParentBlock(r);
|
|
395
|
-
return
|
|
433
|
+
return Ut(a) ? {
|
|
396
434
|
referenceBlock: r,
|
|
397
435
|
placement: i
|
|
398
|
-
} :
|
|
436
|
+
} : Wt(e, i === "after" ? r : e.getPrevBlock(r), a);
|
|
399
437
|
}
|
|
400
|
-
function
|
|
438
|
+
function Gt(e, t, n) {
|
|
401
439
|
let r, i;
|
|
402
440
|
if (t ? t.children.length > 0 ? (r = t.children[0], i = "before") : (r = t, i = "after") : n && (r = n, i = "after"), !r || !i) return;
|
|
403
441
|
let a = e.getParentBlock(r);
|
|
404
|
-
return
|
|
442
|
+
return Ut(a) ? {
|
|
405
443
|
referenceBlock: r,
|
|
406
444
|
placement: i
|
|
407
|
-
} :
|
|
445
|
+
} : Gt(e, i === "before" ? r : e.getNextBlock(r), a);
|
|
408
446
|
}
|
|
409
|
-
function
|
|
447
|
+
function Kt(e, t) {
|
|
410
448
|
e.transact(() => {
|
|
411
449
|
let n;
|
|
412
450
|
if (t) {
|
|
413
451
|
if (n = e.getBlock(t), !n) return;
|
|
414
452
|
} else n = e.getSelection()?.blocks[0] || e.getTextCursorPosition().block;
|
|
415
|
-
let r =
|
|
416
|
-
r && (t ?
|
|
453
|
+
let r = Wt(e, e.getPrevBlock(n), e.getParentBlock(n));
|
|
454
|
+
r && (t ? U(e, [n], r.referenceBlock, r.placement) : Ht(e, r.referenceBlock, r.placement));
|
|
417
455
|
});
|
|
418
456
|
}
|
|
419
|
-
function
|
|
457
|
+
function qt(e, t) {
|
|
420
458
|
e.transact(() => {
|
|
421
459
|
let n;
|
|
422
460
|
if (t) {
|
|
@@ -425,101 +463,101 @@ function zt(e, t) {
|
|
|
425
463
|
let t = e.getSelection();
|
|
426
464
|
n = t?.blocks[t?.blocks.length - 1] || e.getTextCursorPosition().block;
|
|
427
465
|
}
|
|
428
|
-
let r =
|
|
429
|
-
r && (t ?
|
|
466
|
+
let r = Gt(e, e.getNextBlock(n), e.getParentBlock(n));
|
|
467
|
+
r && (t ? U(e, [n], r.referenceBlock, r.placement) : Ht(e, r.referenceBlock, r.placement));
|
|
430
468
|
});
|
|
431
469
|
}
|
|
432
470
|
//#endregion
|
|
433
471
|
//#region src/api/blockManipulation/commands/nestBlock/nestBlock.ts
|
|
434
|
-
function
|
|
472
|
+
function Jt(e, t, n) {
|
|
435
473
|
let { $from: r, $to: i } = e.selection, a = r.blockRange(i, (e) => e.childCount > 0 && (e.type.name === "blockGroup" || e.type.name === "column"));
|
|
436
474
|
if (!a) return !1;
|
|
437
475
|
let o = a.startIndex;
|
|
438
476
|
if (o === 0) return !1;
|
|
439
477
|
let s = a.parent.child(o - 1);
|
|
440
478
|
if (s.type !== t) return !1;
|
|
441
|
-
let c = s.lastChild && s.lastChild.type === n, l =
|
|
442
|
-
return e.step(new
|
|
479
|
+
let c = s.lastChild && s.lastChild.type === n, l = E.from(c ? t.create() : null), u = new D(E.from(t.create(null, E.from(n.create(null, l)))), c ? 3 : 1, 0), d = a.start, f = a.end;
|
|
480
|
+
return e.step(new O(d - (c ? 3 : 1), f, d, f, u, 1, !0)).scrollIntoView(), !0;
|
|
443
481
|
}
|
|
444
|
-
function
|
|
445
|
-
return e.transact((t) =>
|
|
482
|
+
function Yt(e) {
|
|
483
|
+
return e.transact((t) => Jt(t, e.pmSchema.nodes.blockContainer, e.pmSchema.nodes.blockGroup));
|
|
446
484
|
}
|
|
447
|
-
function
|
|
485
|
+
function Xt(e, t, n, r) {
|
|
448
486
|
let i = r.end, a = r.$to.end(r.depth);
|
|
449
487
|
if (i < a) {
|
|
450
488
|
let o = r.parent.child(r.endIndex - 1), s = o.lastChild && o.lastChild.type === n;
|
|
451
|
-
e.step(new
|
|
489
|
+
e.step(new O(i - (s ? 2 : 1), a, i, a, new D(E.from(t.create(null, n.create())), s ? 2 : 1, 0), +!s, !0)), r = new ze(e.doc.resolve(r.$from.pos), e.doc.resolve(a), r.depth);
|
|
452
490
|
}
|
|
453
|
-
let o =
|
|
491
|
+
let o = He(r);
|
|
454
492
|
if (o == null) return !1;
|
|
455
493
|
e.lift(r, o);
|
|
456
494
|
let s = e.doc.resolve(e.mapping.map(i, -1) - 1);
|
|
457
|
-
return
|
|
495
|
+
return Ve(e.doc, s.pos) && s.nodeBefore.type === s.nodeAfter.type && e.join(s.pos), e.scrollIntoView(), !0;
|
|
458
496
|
}
|
|
459
|
-
function
|
|
497
|
+
function W(e, t, n) {
|
|
460
498
|
let { $from: r, $to: i } = e.selection, a = r.blockRange(i, (e) => e.childCount > 0 && (e.type.name === "blockGroup" || e.type.name === "column"));
|
|
461
|
-
return a
|
|
499
|
+
return a ? r.node(a.depth - 1).type === t && Xt(e, t, n, a) : !1;
|
|
462
500
|
}
|
|
463
|
-
function
|
|
464
|
-
return e.transact((t) =>
|
|
501
|
+
function Zt(e) {
|
|
502
|
+
return e.transact((t) => W(t, e.pmSchema.nodes.blockContainer, e.pmSchema.nodes.blockGroup));
|
|
465
503
|
}
|
|
466
|
-
function
|
|
504
|
+
function Qt(e) {
|
|
467
505
|
return e.transact((e) => {
|
|
468
|
-
let { bnBlock: t } =
|
|
506
|
+
let { bnBlock: t } = w(e);
|
|
469
507
|
return e.doc.resolve(t.beforePos).nodeBefore !== null;
|
|
470
508
|
});
|
|
471
509
|
}
|
|
472
|
-
function
|
|
510
|
+
function $t(e) {
|
|
473
511
|
return e.transact((e) => {
|
|
474
|
-
let { bnBlock: t } =
|
|
512
|
+
let { bnBlock: t } = w(e);
|
|
475
513
|
return e.doc.resolve(t.beforePos).depth > 1;
|
|
476
514
|
});
|
|
477
515
|
}
|
|
478
516
|
//#endregion
|
|
479
517
|
//#region src/api/blockManipulation/getBlock/getBlock.ts
|
|
480
|
-
function
|
|
481
|
-
let n =
|
|
482
|
-
if (
|
|
483
|
-
}
|
|
484
|
-
function
|
|
485
|
-
let n =
|
|
486
|
-
if (!
|
|
487
|
-
let
|
|
488
|
-
if (
|
|
489
|
-
}
|
|
490
|
-
function
|
|
491
|
-
let n =
|
|
492
|
-
if (!
|
|
493
|
-
let
|
|
494
|
-
if (
|
|
495
|
-
}
|
|
496
|
-
function
|
|
497
|
-
let n =
|
|
498
|
-
if (!
|
|
499
|
-
let
|
|
500
|
-
if (
|
|
518
|
+
function en(e, t) {
|
|
519
|
+
let n = typeof t == "string" ? t : t.id, r = p(n, e);
|
|
520
|
+
if (r) return g(r.node, e);
|
|
521
|
+
}
|
|
522
|
+
function tn(e, t) {
|
|
523
|
+
let n = typeof t == "string" ? t : t.id, r = p(n, e);
|
|
524
|
+
if (!r) return;
|
|
525
|
+
let i = e.resolve(r.posBeforeNode).nodeBefore;
|
|
526
|
+
if (i) return g(i, e);
|
|
527
|
+
}
|
|
528
|
+
function nn(e, t) {
|
|
529
|
+
let n = typeof t == "string" ? t : t.id, r = p(n, e);
|
|
530
|
+
if (!r) return;
|
|
531
|
+
let i = e.resolve(r.posBeforeNode + r.node.nodeSize).nodeAfter;
|
|
532
|
+
if (i) return g(i, e);
|
|
533
|
+
}
|
|
534
|
+
function rn(e, t) {
|
|
535
|
+
let n = typeof t == "string" ? t : t.id, r = p(n, e);
|
|
536
|
+
if (!r) return;
|
|
537
|
+
let i = e.resolve(r.posBeforeNode), a = i.node(), o = i.node(-1), s = o.type.name === "doc" ? void 0 : a.type.name === "blockGroup" ? o : a;
|
|
538
|
+
if (s) return g(s, e);
|
|
501
539
|
}
|
|
502
540
|
//#endregion
|
|
503
541
|
//#region src/editor/managers/BlockManager.ts
|
|
504
|
-
var
|
|
542
|
+
var an = class {
|
|
505
543
|
editor;
|
|
506
544
|
constructor(e) {
|
|
507
545
|
this.editor = e;
|
|
508
546
|
}
|
|
509
547
|
get document() {
|
|
510
|
-
return this.editor.transact((e) =>
|
|
548
|
+
return this.editor.transact((e) => le(e.doc));
|
|
511
549
|
}
|
|
512
550
|
getBlock(e) {
|
|
513
|
-
return this.editor.transact((t) =>
|
|
551
|
+
return this.editor.transact((t) => en(t.doc, e));
|
|
514
552
|
}
|
|
515
553
|
getPrevBlock(e) {
|
|
516
|
-
return this.editor.transact((t) =>
|
|
554
|
+
return this.editor.transact((t) => tn(t.doc, e));
|
|
517
555
|
}
|
|
518
556
|
getNextBlock(e) {
|
|
519
|
-
return this.editor.transact((t) =>
|
|
557
|
+
return this.editor.transact((t) => nn(t.doc, e));
|
|
520
558
|
}
|
|
521
559
|
getParentBlock(e) {
|
|
522
|
-
return this.editor.transact((t) =>
|
|
560
|
+
return this.editor.transact((t) => rn(t.doc, e));
|
|
523
561
|
}
|
|
524
562
|
forEachBlock(e, t = !1) {
|
|
525
563
|
let n = this.document.slice();
|
|
@@ -531,36 +569,36 @@ var Xt = class {
|
|
|
531
569
|
r(n);
|
|
532
570
|
}
|
|
533
571
|
insertBlocks(e, t, n = "before") {
|
|
534
|
-
return this.editor.transact((r) =>
|
|
572
|
+
return this.editor.transact((r) => xt(r, e, t, n));
|
|
535
573
|
}
|
|
536
574
|
updateBlock(e, t) {
|
|
537
|
-
return this.editor.transact((n) =>
|
|
575
|
+
return this.editor.transact((n) => ae(n, e, t));
|
|
538
576
|
}
|
|
539
577
|
removeBlocks(e) {
|
|
540
|
-
return this.editor.transact((t) =>
|
|
578
|
+
return this.editor.transact((t) => B(t, e, []).removedBlocks);
|
|
541
579
|
}
|
|
542
580
|
replaceBlocks(e, t) {
|
|
543
|
-
return this.editor.transact((n) =>
|
|
581
|
+
return this.editor.transact((n) => B(n, e, t));
|
|
544
582
|
}
|
|
545
583
|
canNestBlock() {
|
|
546
|
-
return
|
|
584
|
+
return Qt(this.editor);
|
|
547
585
|
}
|
|
548
586
|
nestBlock() {
|
|
549
|
-
|
|
587
|
+
Yt(this.editor);
|
|
550
588
|
}
|
|
551
589
|
canUnnestBlock() {
|
|
552
|
-
return
|
|
590
|
+
return $t(this.editor);
|
|
553
591
|
}
|
|
554
592
|
unnestBlock() {
|
|
555
|
-
|
|
593
|
+
Zt(this.editor);
|
|
556
594
|
}
|
|
557
595
|
moveBlocksUp(e) {
|
|
558
|
-
return
|
|
596
|
+
return Kt(this.editor, e);
|
|
559
597
|
}
|
|
560
598
|
moveBlocksDown(e) {
|
|
561
|
-
return
|
|
599
|
+
return qt(this.editor, e);
|
|
562
600
|
}
|
|
563
|
-
},
|
|
601
|
+
}, on = class extends H {
|
|
564
602
|
editor;
|
|
565
603
|
constructor(e) {
|
|
566
604
|
super(), this.editor = e, e.on("create", () => {
|
|
@@ -584,8 +622,8 @@ var Xt = class {
|
|
|
584
622
|
}
|
|
585
623
|
onChange(e, t = !0) {
|
|
586
624
|
let n = ({ transaction: n, appendedTransactions: r }) => {
|
|
587
|
-
!t &&
|
|
588
|
-
return
|
|
625
|
+
!t && sn(n) || e(this.editor, { getChanges() {
|
|
626
|
+
return Se(n, r);
|
|
589
627
|
} });
|
|
590
628
|
};
|
|
591
629
|
return this.on("onChange", n), () => {
|
|
@@ -594,7 +632,7 @@ var Xt = class {
|
|
|
594
632
|
}
|
|
595
633
|
onSelectionChange(e, t = !1) {
|
|
596
634
|
let n = (n) => {
|
|
597
|
-
!t &&
|
|
635
|
+
!t && sn(n.transaction) || e(this.editor);
|
|
598
636
|
};
|
|
599
637
|
return this.on("onSelectionChange", n), () => {
|
|
600
638
|
this.off("onSelectionChange", n);
|
|
@@ -611,30 +649,30 @@ var Xt = class {
|
|
|
611
649
|
};
|
|
612
650
|
}
|
|
613
651
|
};
|
|
614
|
-
function
|
|
652
|
+
function sn(e) {
|
|
615
653
|
return !!e.getMeta("y-sync$");
|
|
616
654
|
}
|
|
617
655
|
//#endregion
|
|
618
656
|
//#region src/api/parsers/html/util/nestedLists.ts
|
|
619
|
-
function
|
|
657
|
+
function cn(e) {
|
|
620
658
|
return Array.prototype.indexOf.call(e.parentElement.childNodes, e);
|
|
621
659
|
}
|
|
622
|
-
function
|
|
660
|
+
function ln(e) {
|
|
623
661
|
return e.nodeType === 3 && !/\S/.test(e.nodeValue || "");
|
|
624
662
|
}
|
|
625
|
-
function
|
|
663
|
+
function un(e) {
|
|
626
664
|
e.querySelectorAll("li > ul, li > ol").forEach((e) => {
|
|
627
|
-
let t =
|
|
665
|
+
let t = cn(e), n = e.parentElement, r = Array.from(n.childNodes).slice(t + 1);
|
|
628
666
|
e.remove(), r.forEach((e) => {
|
|
629
667
|
e.remove();
|
|
630
668
|
}), n.insertAdjacentElement("afterend", e), r.reverse().forEach((t) => {
|
|
631
|
-
if (
|
|
669
|
+
if (ln(t)) return;
|
|
632
670
|
let n = document.createElement("li");
|
|
633
671
|
n.append(t), e.insertAdjacentElement("afterend", n);
|
|
634
672
|
}), n.childNodes.length === 0 && n.remove();
|
|
635
673
|
});
|
|
636
674
|
}
|
|
637
|
-
function
|
|
675
|
+
function dn(e) {
|
|
638
676
|
e.querySelectorAll("li + ul, li + ol").forEach((e) => {
|
|
639
677
|
let t = e.previousElementSibling, n = document.createElement("div");
|
|
640
678
|
t.insertAdjacentElement("afterend", n), n.append(t);
|
|
@@ -642,26 +680,26 @@ function nn(e) {
|
|
|
642
680
|
for (r.setAttribute("data-node-type", "blockGroup"), n.append(r); n.nextElementSibling?.nodeName === "UL" || n.nextElementSibling?.nodeName === "OL";) r.append(n.nextElementSibling);
|
|
643
681
|
});
|
|
644
682
|
}
|
|
645
|
-
var
|
|
646
|
-
function
|
|
647
|
-
return
|
|
683
|
+
var fn = null;
|
|
684
|
+
function pn() {
|
|
685
|
+
return fn ||= document.implementation.createHTMLDocument("title");
|
|
648
686
|
}
|
|
649
|
-
function
|
|
687
|
+
function mn(e) {
|
|
650
688
|
if (typeof e == "string") {
|
|
651
|
-
let t =
|
|
689
|
+
let t = pn().createElement("div");
|
|
652
690
|
t.innerHTML = e, e = t;
|
|
653
691
|
}
|
|
654
|
-
return
|
|
692
|
+
return un(e), dn(e), e;
|
|
655
693
|
}
|
|
656
694
|
//#endregion
|
|
657
695
|
//#region src/api/parsers/html/util/normalizeWhitespace.ts
|
|
658
|
-
function
|
|
696
|
+
function hn(e) {
|
|
659
697
|
let t = e.ownerDocument.createTreeWalker(e, 128), n;
|
|
660
698
|
for (; n = t.nextNode();) if (/^\s*notionvc:/.test(n.nodeValue || "")) return !0;
|
|
661
699
|
return !1;
|
|
662
700
|
}
|
|
663
|
-
function
|
|
664
|
-
let t = new Set(["PRE", "CODE"]), n = e.ownerDocument.createTreeWalker(e, 4, { acceptNode(n) {
|
|
701
|
+
function gn(e) {
|
|
702
|
+
let t = /* @__PURE__ */ new Set(["PRE", "CODE"]), n = e.ownerDocument.createTreeWalker(e, 4, { acceptNode(n) {
|
|
665
703
|
let r = n.parentElement;
|
|
666
704
|
for (; r && r !== e;) {
|
|
667
705
|
if (t.has(r.tagName)) return 2;
|
|
@@ -672,78 +710,95 @@ function cn(e) {
|
|
|
672
710
|
for (; i = n.nextNode();) r.push(i);
|
|
673
711
|
for (let e of r) e.nodeValue && /[\r\n]/.test(e.nodeValue) && (e.nodeValue = e.nodeValue.replace(/[ \t\r\n\f]+/g, " "));
|
|
674
712
|
}
|
|
675
|
-
function
|
|
676
|
-
|
|
713
|
+
function _n(e) {
|
|
714
|
+
hn(e) || gn(e);
|
|
677
715
|
}
|
|
678
716
|
//#endregion
|
|
679
717
|
//#region src/api/parsers/html/parseHTML.ts
|
|
680
|
-
function
|
|
681
|
-
let
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
718
|
+
function vn(e) {
|
|
719
|
+
let t = [];
|
|
720
|
+
for (let n of e) if (n.type === "text") {
|
|
721
|
+
let e = n.text.split("").join("");
|
|
722
|
+
e.length > 0 && t.push({
|
|
723
|
+
...n,
|
|
724
|
+
text: e
|
|
725
|
+
});
|
|
726
|
+
} else Array.isArray(n.content) ? t.push({
|
|
727
|
+
...n,
|
|
728
|
+
content: vn(n.content)
|
|
729
|
+
}) : t.push(n);
|
|
730
|
+
return t;
|
|
731
|
+
}
|
|
732
|
+
function yn(e) {
|
|
733
|
+
for (let t of e) Array.isArray(t.content) && (t.content = vn(t.content)), t.children.length > 0 && yn(t.children);
|
|
734
|
+
}
|
|
735
|
+
function G(e, t) {
|
|
736
|
+
let n = mn(e);
|
|
737
|
+
_n(n);
|
|
738
|
+
let r = Le.fromSchema(t).parse(n, { topNode: t.nodes.blockGroup.create() }), i = [];
|
|
739
|
+
for (let e = 0; e < r.childCount; e++) i.push(g(r.child(e), r));
|
|
740
|
+
return yn(i), i;
|
|
686
741
|
}
|
|
687
742
|
//#endregion
|
|
688
743
|
//#region src/api/parsers/markdown/markdownToHtml.ts
|
|
689
|
-
function
|
|
744
|
+
function K(e) {
|
|
690
745
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
691
746
|
}
|
|
692
|
-
function
|
|
747
|
+
function bn(e) {
|
|
693
748
|
return e ? /\w/.test(e) : !1;
|
|
694
749
|
}
|
|
695
|
-
function
|
|
750
|
+
function q(e, t, n) {
|
|
696
751
|
let r = t > 0 ? e[t - 1] : void 0, i = t + n < e.length ? e[t + n] : void 0;
|
|
697
|
-
return
|
|
752
|
+
return bn(r) && bn(i);
|
|
698
753
|
}
|
|
699
|
-
function
|
|
754
|
+
function xn(e, t) {
|
|
700
755
|
if (e[t] !== "\\" || t + 1 >= e.length) return null;
|
|
701
756
|
let n = e[t + 1];
|
|
702
757
|
return n === "\n" ? {
|
|
703
758
|
html: "<br>\n",
|
|
704
759
|
end: t + 2
|
|
705
760
|
} : "\\`*_{}[]()#+-.!~|>".includes(n) ? {
|
|
706
|
-
html:
|
|
761
|
+
html: K(n),
|
|
707
762
|
end: t + 2
|
|
708
763
|
} : null;
|
|
709
764
|
}
|
|
710
|
-
function
|
|
711
|
-
return e[t] === "`" ?
|
|
765
|
+
function Sn(e, t) {
|
|
766
|
+
return e[t] === "`" ? Rn(e, t) : null;
|
|
712
767
|
}
|
|
713
|
-
function
|
|
714
|
-
return e[t] !== "!" || e[t + 1] !== "[" ? null :
|
|
768
|
+
function Cn(e, t) {
|
|
769
|
+
return e[t] !== "!" || e[t + 1] !== "[" ? null : zn(e, t);
|
|
715
770
|
}
|
|
716
|
-
function
|
|
717
|
-
return e[t] === "[" ?
|
|
771
|
+
function wn(e, t) {
|
|
772
|
+
return e[t] === "[" ? Bn(e, t) : null;
|
|
718
773
|
}
|
|
719
|
-
function
|
|
720
|
-
return e[t] !== "~" || e[t + 1] !== "~" ? null :
|
|
774
|
+
function Tn(e, t) {
|
|
775
|
+
return e[t] !== "~" || e[t + 1] !== "~" ? null : Y(e, t, "~~", "<del>", "</del>");
|
|
721
776
|
}
|
|
722
|
-
function
|
|
723
|
-
return e[t] === "*" && e[t + 1] === "*" && e[t + 2] === "*" || e[t] === "_" && e[t + 1] === "_" && e[t + 2] === "_" && !
|
|
777
|
+
function En(e, t) {
|
|
778
|
+
return e[t] === "*" && e[t + 1] === "*" && e[t + 2] === "*" || e[t] === "_" && e[t + 1] === "_" && e[t + 2] === "_" && !q(e, t, 3) ? Y(e, t, e.substring(t, t + 3), "<strong><em>", "</em></strong>") : null;
|
|
724
779
|
}
|
|
725
|
-
function
|
|
726
|
-
return e[t] === "*" && e[t + 1] === "*" || e[t] === "_" && e[t + 1] === "_" && !
|
|
780
|
+
function Dn(e, t) {
|
|
781
|
+
return e[t] === "*" && e[t + 1] === "*" || e[t] === "_" && e[t + 1] === "_" && !q(e, t, 2) ? Y(e, t, e.substring(t, t + 2), "<strong>", "</strong>") : null;
|
|
727
782
|
}
|
|
728
|
-
function
|
|
729
|
-
return e[t] === "*" || e[t] === "_" && !
|
|
783
|
+
function On(e, t) {
|
|
784
|
+
return e[t] === "*" || e[t] === "_" && !q(e, t, 1) ? Y(e, t, e[t], "<em>", "</em>") : null;
|
|
730
785
|
}
|
|
731
|
-
function
|
|
786
|
+
function kn(e, t) {
|
|
732
787
|
return e[t] === "\n" ? {
|
|
733
788
|
html: "<br>\n",
|
|
734
789
|
end: t + 1
|
|
735
790
|
} : null;
|
|
736
791
|
}
|
|
737
|
-
var
|
|
738
|
-
function
|
|
792
|
+
var An = /^<\/?[a-zA-Z][a-zA-Z0-9-]*(?:\s+[a-zA-Z_:][a-zA-Z0-9_.:-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*\s*\/?>/, jn = /^<!--[\s\S]*?-->/, Mn = /^<!\[CDATA\[[\s\S]*?\]\]>/, Nn = /^<\?[\s\S]*?\?>/, Pn = /^<![A-Za-z][\s\S]*?>/;
|
|
793
|
+
function Fn(e, t) {
|
|
739
794
|
if (e[t] !== "<") return null;
|
|
740
795
|
let n = e.substring(t);
|
|
741
796
|
for (let e of [
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
797
|
+
jn,
|
|
798
|
+
Mn,
|
|
799
|
+
Nn,
|
|
800
|
+
Pn,
|
|
801
|
+
An
|
|
747
802
|
]) {
|
|
748
803
|
let r = n.match(e);
|
|
749
804
|
if (r) return {
|
|
@@ -753,19 +808,19 @@ function Tn(e, t) {
|
|
|
753
808
|
}
|
|
754
809
|
return null;
|
|
755
810
|
}
|
|
756
|
-
var
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
hn,
|
|
762
|
-
gn,
|
|
763
|
-
_n,
|
|
764
|
-
vn,
|
|
811
|
+
var In = /* @__PURE__ */ new Set("\\`![~*_\n<"), Ln = [
|
|
812
|
+
xn,
|
|
813
|
+
Sn,
|
|
814
|
+
Cn,
|
|
815
|
+
wn,
|
|
765
816
|
Tn,
|
|
766
|
-
|
|
817
|
+
En,
|
|
818
|
+
Dn,
|
|
819
|
+
On,
|
|
820
|
+
Fn,
|
|
821
|
+
kn
|
|
767
822
|
];
|
|
768
|
-
function
|
|
823
|
+
function J(e) {
|
|
769
824
|
let t = "", n = 0;
|
|
770
825
|
for (; n < e.length;) {
|
|
771
826
|
if (e[n] === "\n" && n >= 2 && e[n - 1] === " " && e[n - 2] === " ") {
|
|
@@ -773,7 +828,7 @@ function K(e) {
|
|
|
773
828
|
continue;
|
|
774
829
|
}
|
|
775
830
|
let r = !1;
|
|
776
|
-
if (
|
|
831
|
+
if (In.has(e[n])) for (let i of Ln) {
|
|
777
832
|
let a = i(e, n);
|
|
778
833
|
if (a) {
|
|
779
834
|
t += a.html, n = a.end, r = !0;
|
|
@@ -782,13 +837,13 @@ function K(e) {
|
|
|
782
837
|
}
|
|
783
838
|
if (!r) {
|
|
784
839
|
let r = n;
|
|
785
|
-
for (n++; n < e.length && !
|
|
786
|
-
t +=
|
|
840
|
+
for (n++; n < e.length && !In.has(e[n]);) n++;
|
|
841
|
+
t += K(e.substring(r, n));
|
|
787
842
|
}
|
|
788
843
|
}
|
|
789
844
|
return t;
|
|
790
845
|
}
|
|
791
|
-
function
|
|
846
|
+
function Rn(e, t) {
|
|
792
847
|
let n = 0, r = t;
|
|
793
848
|
for (; r < e.length && e[r] === "`";) n++, r++;
|
|
794
849
|
let i = r;
|
|
@@ -798,46 +853,46 @@ function On(e, t) {
|
|
|
798
853
|
if (t === n) {
|
|
799
854
|
let t = e.substring(r, a);
|
|
800
855
|
return t = t.replace(/\n/g, " "), t.length >= 2 && t[0] === " " && t[t.length - 1] === " " && /[^ ]/.test(t) && (t = t.substring(1, t.length - 1)), {
|
|
801
|
-
html: `<code>${
|
|
856
|
+
html: `<code>${K(t)}</code>`,
|
|
802
857
|
end: i
|
|
803
858
|
};
|
|
804
859
|
}
|
|
805
860
|
} else i++;
|
|
806
861
|
return null;
|
|
807
862
|
}
|
|
808
|
-
function
|
|
809
|
-
let n =
|
|
863
|
+
function zn(e, t) {
|
|
864
|
+
let n = Vn(e, t + 1);
|
|
810
865
|
if (n === -1) return null;
|
|
811
866
|
let r = t + 2;
|
|
812
867
|
if (e[n + 1] !== "(") return null;
|
|
813
|
-
let i = n + 2, a =
|
|
868
|
+
let i = n + 2, a = Hn(e, i - 1);
|
|
814
869
|
if (a === -1) return null;
|
|
815
|
-
let o = e.substring(r, n), { url: s, title: c } =
|
|
816
|
-
if (
|
|
870
|
+
let o = e.substring(r, n), { url: s, title: c } = Un(e.substring(i, a));
|
|
871
|
+
if (de(s)) {
|
|
817
872
|
let e = o || c;
|
|
818
873
|
return {
|
|
819
|
-
html: `<video src="${
|
|
874
|
+
html: `<video src="${K(s)}"${e ? ` data-name="${K(e)}"` : ""} data-url="${K(s)}" controls></video>`,
|
|
820
875
|
end: a + 1
|
|
821
876
|
};
|
|
822
877
|
}
|
|
823
|
-
let l = c === void 0 ? "" : ` title="${
|
|
878
|
+
let l = c === void 0 ? "" : ` title="${K(c)}"`;
|
|
824
879
|
return {
|
|
825
|
-
html: `<img src="${
|
|
880
|
+
html: `<img src="${K(s)}" alt="${K(o)}"${l}>`,
|
|
826
881
|
end: a + 1
|
|
827
882
|
};
|
|
828
883
|
}
|
|
829
|
-
function
|
|
830
|
-
let n = t + 1, r =
|
|
884
|
+
function Bn(e, t) {
|
|
885
|
+
let n = t + 1, r = Vn(e, t);
|
|
831
886
|
if (r === -1 || e[r + 1] !== "(") return null;
|
|
832
|
-
let i = r + 2, a =
|
|
887
|
+
let i = r + 2, a = Hn(e, r + 1);
|
|
833
888
|
if (a === -1) return null;
|
|
834
|
-
let o = e.substring(n, r), { url: s, title: c } =
|
|
889
|
+
let o = e.substring(n, r), { url: s, title: c } = Un(e.substring(i, a)), l = c === void 0 ? "" : ` title="${K(c)}"`;
|
|
835
890
|
return {
|
|
836
|
-
html: `<a href="${
|
|
891
|
+
html: `<a href="${K(s)}"${l}>${J(o)}</a>`,
|
|
837
892
|
end: a + 1
|
|
838
893
|
};
|
|
839
894
|
}
|
|
840
|
-
function
|
|
895
|
+
function Vn(e, t) {
|
|
841
896
|
let n = 0;
|
|
842
897
|
for (let r = t; r < e.length; r++) {
|
|
843
898
|
if (e[r] === "\\" && r + 1 < e.length) {
|
|
@@ -848,7 +903,7 @@ function jn(e, t) {
|
|
|
848
903
|
}
|
|
849
904
|
return -1;
|
|
850
905
|
}
|
|
851
|
-
function
|
|
906
|
+
function Hn(e, t) {
|
|
852
907
|
let n = 0;
|
|
853
908
|
for (let r = t; r < e.length; r++) {
|
|
854
909
|
if (e[r] === "\\" && r + 1 < e.length) {
|
|
@@ -859,7 +914,7 @@ function Mn(e, t) {
|
|
|
859
914
|
}
|
|
860
915
|
return -1;
|
|
861
916
|
}
|
|
862
|
-
function
|
|
917
|
+
function Un(e) {
|
|
863
918
|
e = e.trim();
|
|
864
919
|
let t, n;
|
|
865
920
|
if (e.startsWith("<")) {
|
|
@@ -889,7 +944,7 @@ function Nn(e) {
|
|
|
889
944
|
title: r
|
|
890
945
|
};
|
|
891
946
|
}
|
|
892
|
-
function
|
|
947
|
+
function Y(e, t, n, r, i) {
|
|
893
948
|
let a = n.length, o = t + a;
|
|
894
949
|
if (o >= e.length || e[o] === " " || e[o] === " ") return null;
|
|
895
950
|
let s = o;
|
|
@@ -913,7 +968,7 @@ function q(e, t, n, r, i) {
|
|
|
913
968
|
continue;
|
|
914
969
|
}
|
|
915
970
|
return {
|
|
916
|
-
html: r +
|
|
971
|
+
html: r + J(t) + i,
|
|
917
972
|
end: s + a
|
|
918
973
|
};
|
|
919
974
|
}
|
|
@@ -921,13 +976,13 @@ function q(e, t, n, r, i) {
|
|
|
921
976
|
}
|
|
922
977
|
return null;
|
|
923
978
|
}
|
|
924
|
-
var
|
|
925
|
-
function
|
|
979
|
+
var Wn = /* @__PURE__ */ new Set(/* @__PURE__ */ "address.article.aside.audio.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.section.source.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul".split("."));
|
|
980
|
+
function Gn(e) {
|
|
926
981
|
if (/^ {0,3}<(!--|\?|![A-Za-z]|!\[CDATA\[)/.test(e)) return !0;
|
|
927
982
|
let t = e.match(/^ {0,3}<\/?([a-zA-Z][a-zA-Z0-9-]*)(?:\s|\/?>|$)/);
|
|
928
|
-
return t ?
|
|
983
|
+
return t ? Wn.has(t[1].toLowerCase()) : !1;
|
|
929
984
|
}
|
|
930
|
-
function
|
|
985
|
+
function Kn(e) {
|
|
931
986
|
let t = e.split("\n"), n = [], r = 0, i = !0;
|
|
932
987
|
for (; r < t.length;) {
|
|
933
988
|
let e = t[r];
|
|
@@ -986,7 +1041,7 @@ function J(e) {
|
|
|
986
1041
|
continue;
|
|
987
1042
|
}
|
|
988
1043
|
}
|
|
989
|
-
let s =
|
|
1044
|
+
let s = qn(t, r);
|
|
990
1045
|
if (s) {
|
|
991
1046
|
n.push(s.token), r = s.nextLine, i = !1;
|
|
992
1047
|
continue;
|
|
@@ -1042,7 +1097,7 @@ function J(e) {
|
|
|
1042
1097
|
}), i = !1;
|
|
1043
1098
|
continue;
|
|
1044
1099
|
}
|
|
1045
|
-
if (
|
|
1100
|
+
if (Gn(e)) {
|
|
1046
1101
|
let e = [];
|
|
1047
1102
|
for (; r < t.length && t[r].trim() !== "";) e.push(t[r]), r++;
|
|
1048
1103
|
n.push({
|
|
@@ -1054,7 +1109,7 @@ function J(e) {
|
|
|
1054
1109
|
let l = [e];
|
|
1055
1110
|
for (r++; r < t.length;) {
|
|
1056
1111
|
let e = t[r];
|
|
1057
|
-
if (e.trim() === "" || /^(#{1,6})\s/.test(e) || /^(`{3,}|~{3,})/.test(e) || /^\s{0,3}>/.test(e) || /^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(e) || /^\s*([-*+]|\d+[.)])\s+/.test(e) || /^\s*\|(.+\|)+\s*$/.test(e) ||
|
|
1112
|
+
if (e.trim() === "" || /^(#{1,6})\s/.test(e) || /^(`{3,}|~{3,})/.test(e) || /^\s{0,3}>/.test(e) || /^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(e) || /^\s*([-*+]|\d+[.)])\s+/.test(e) || /^\s*\|(.+\|)+\s*$/.test(e) || Gn(e) || r + 1 < t.length && /^[=-]+\s*$/.test(t[r + 1]) && e.trim().length > 0) break;
|
|
1058
1113
|
l.push(e), r++;
|
|
1059
1114
|
}
|
|
1060
1115
|
n.push({
|
|
@@ -1064,15 +1119,15 @@ function J(e) {
|
|
|
1064
1119
|
}
|
|
1065
1120
|
return n;
|
|
1066
1121
|
}
|
|
1067
|
-
function
|
|
1122
|
+
function qn(e, t) {
|
|
1068
1123
|
if (t + 1 >= e.length) return null;
|
|
1069
1124
|
let n = e[t], r = e[t + 1];
|
|
1070
1125
|
if (!r.includes("|") || !/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/.test(r) || !n.includes("|")) return null;
|
|
1071
|
-
let i =
|
|
1126
|
+
let i = Jn(n), a = Yn(r), o = [], s = t + 2;
|
|
1072
1127
|
for (; s < e.length;) {
|
|
1073
1128
|
let t = e[s];
|
|
1074
1129
|
if (!t.includes("|")) break;
|
|
1075
|
-
o.push(
|
|
1130
|
+
o.push(Jn(t)), s++;
|
|
1076
1131
|
}
|
|
1077
1132
|
return {
|
|
1078
1133
|
token: {
|
|
@@ -1084,37 +1139,37 @@ function In(e, t) {
|
|
|
1084
1139
|
nextLine: s
|
|
1085
1140
|
};
|
|
1086
1141
|
}
|
|
1087
|
-
function
|
|
1142
|
+
function Jn(e) {
|
|
1088
1143
|
let t = e.trim(), n = t.startsWith("|") ? t.substring(1) : t, r = n.endsWith("|") ? n.substring(0, n.length - 1) : n, i = [], a = "";
|
|
1089
1144
|
for (let e = 0; e < r.length; e++) r[e] === "\\" && e + 1 < r.length && r[e + 1] === "|" ? (a += "|", e++) : r[e] === "|" ? (i.push(a.trim()), a = "") : a += r[e];
|
|
1090
1145
|
return i.push(a.trim()), i;
|
|
1091
1146
|
}
|
|
1092
|
-
function
|
|
1093
|
-
return
|
|
1147
|
+
function Yn(e) {
|
|
1148
|
+
return Jn(e).map((e) => {
|
|
1094
1149
|
let t = e.trim(), n = t.startsWith(":"), r = t.endsWith(":");
|
|
1095
1150
|
return n && r ? "center" : r ? "right" : n ? "left" : null;
|
|
1096
1151
|
});
|
|
1097
1152
|
}
|
|
1098
|
-
function
|
|
1153
|
+
function Xn(e) {
|
|
1099
1154
|
let t = "", n = 0;
|
|
1100
1155
|
for (; n < e.length;) {
|
|
1101
1156
|
let r = e[n];
|
|
1102
1157
|
switch (r.type) {
|
|
1103
1158
|
case "heading": {
|
|
1104
1159
|
let e = r;
|
|
1105
|
-
t += `<h${e.level}>${
|
|
1160
|
+
t += `<h${e.level}>${J(e.content)}</h${e.level}>`, n++;
|
|
1106
1161
|
break;
|
|
1107
1162
|
}
|
|
1108
1163
|
case "paragraph":
|
|
1109
|
-
t += `<p>${
|
|
1164
|
+
t += `<p>${J(r.content)}</p>`, n++;
|
|
1110
1165
|
break;
|
|
1111
1166
|
case "codeBlock": {
|
|
1112
|
-
let e = r, i = e.language ? ` data-language="${
|
|
1113
|
-
t += `<pre><code${i}>${
|
|
1167
|
+
let e = r, i = e.language ? ` data-language="${K(e.language)}"` : "";
|
|
1168
|
+
t += `<pre><code${i}>${K(e.code)}</code></pre>`, n++;
|
|
1114
1169
|
break;
|
|
1115
1170
|
}
|
|
1116
1171
|
case "blockquote": {
|
|
1117
|
-
let e =
|
|
1172
|
+
let e = Xn(Kn(r.content));
|
|
1118
1173
|
t += `<blockquote>${e}</blockquote>`, n++;
|
|
1119
1174
|
break;
|
|
1120
1175
|
}
|
|
@@ -1122,12 +1177,12 @@ function Rn(e) {
|
|
|
1122
1177
|
t += "<hr>", n++;
|
|
1123
1178
|
break;
|
|
1124
1179
|
case "listItem": {
|
|
1125
|
-
let r =
|
|
1180
|
+
let r = Zn(e, n);
|
|
1126
1181
|
t += r.html, n = r.nextIndex;
|
|
1127
1182
|
break;
|
|
1128
1183
|
}
|
|
1129
1184
|
case "table":
|
|
1130
|
-
t +=
|
|
1185
|
+
t += $n(r), n++;
|
|
1131
1186
|
break;
|
|
1132
1187
|
case "rawHtml":
|
|
1133
1188
|
t += r.content, n++;
|
|
@@ -1137,10 +1192,10 @@ function Rn(e) {
|
|
|
1137
1192
|
}
|
|
1138
1193
|
return t;
|
|
1139
1194
|
}
|
|
1140
|
-
function
|
|
1195
|
+
function Zn(e, t) {
|
|
1141
1196
|
let n = "", r = t, i = null;
|
|
1142
1197
|
for (; r < e.length && e[r].type === "listItem";) {
|
|
1143
|
-
let t = e[r], a =
|
|
1198
|
+
let t = e[r], a = Qn(t.listType);
|
|
1144
1199
|
if (i !== null && i !== a && (n += `</${i === "ordered" ? "ol" : "ul"}>`, i = null), i === null) {
|
|
1145
1200
|
if (a === "ordered") {
|
|
1146
1201
|
let e = t.start !== void 0 && t.start !== 1 ? ` start="${t.start}"` : "";
|
|
@@ -1150,11 +1205,11 @@ function zn(e, t) {
|
|
|
1150
1205
|
}
|
|
1151
1206
|
if (t.listType === "task") {
|
|
1152
1207
|
let e = t.checked ? " checked" : "";
|
|
1153
|
-
n += `<li><input type="checkbox" disabled${e}><p>${
|
|
1154
|
-
} else n += `<li><p>${
|
|
1208
|
+
n += `<li><input type="checkbox" disabled${e}><p>${J(t.content)}</p>`;
|
|
1209
|
+
} else n += `<li><p>${J(t.content)}</p>`;
|
|
1155
1210
|
if (t.childContent) {
|
|
1156
|
-
let e =
|
|
1157
|
-
n +=
|
|
1211
|
+
let e = Kn(t.childContent);
|
|
1212
|
+
n += Xn(e);
|
|
1158
1213
|
}
|
|
1159
1214
|
n += "</li>", r++;
|
|
1160
1215
|
}
|
|
@@ -1163,16 +1218,16 @@ function zn(e, t) {
|
|
|
1163
1218
|
nextIndex: r
|
|
1164
1219
|
};
|
|
1165
1220
|
}
|
|
1166
|
-
function
|
|
1221
|
+
function Qn(e) {
|
|
1167
1222
|
return e === "ordered" ? "ordered" : "bullet";
|
|
1168
1223
|
}
|
|
1169
|
-
function
|
|
1224
|
+
function $n(e) {
|
|
1170
1225
|
let t = "<table>", n = e.headers.every((e) => e.trim() === ""), r = e.headers.length;
|
|
1171
1226
|
if (!n) {
|
|
1172
1227
|
t += "<thead><tr>";
|
|
1173
1228
|
for (let n = 0; n < r; n++) {
|
|
1174
1229
|
let r = e.alignments[n], i = r ? ` align="${r}"` : "";
|
|
1175
|
-
t += `<th${i}>${
|
|
1230
|
+
t += `<th${i}>${J(e.headers[n])}</th>`;
|
|
1176
1231
|
}
|
|
1177
1232
|
t += "</tr></thead>";
|
|
1178
1233
|
}
|
|
@@ -1182,7 +1237,7 @@ function Vn(e) {
|
|
|
1182
1237
|
t += "<tr>";
|
|
1183
1238
|
for (let i = 0; i < r; i++) {
|
|
1184
1239
|
let r = i < n.length ? n[i] : "", a = e.alignments[i], o = a ? ` align="${a}"` : "";
|
|
1185
|
-
t += `<td${o}>${
|
|
1240
|
+
t += `<td${o}>${J(r)}</td>`;
|
|
1186
1241
|
}
|
|
1187
1242
|
t += "</tr>";
|
|
1188
1243
|
}
|
|
@@ -1190,38 +1245,38 @@ function Vn(e) {
|
|
|
1190
1245
|
}
|
|
1191
1246
|
return t += "</table>", t;
|
|
1192
1247
|
}
|
|
1193
|
-
function
|
|
1194
|
-
return
|
|
1248
|
+
function er(e) {
|
|
1249
|
+
return Xn(Kn(e));
|
|
1195
1250
|
}
|
|
1196
1251
|
//#endregion
|
|
1197
1252
|
//#region src/api/parsers/markdown/parseMarkdown.ts
|
|
1198
|
-
function
|
|
1199
|
-
return
|
|
1253
|
+
function tr(e) {
|
|
1254
|
+
return er(e);
|
|
1200
1255
|
}
|
|
1201
|
-
function
|
|
1202
|
-
return
|
|
1256
|
+
function nr(e, t) {
|
|
1257
|
+
return G(tr(e), t);
|
|
1203
1258
|
}
|
|
1204
1259
|
//#endregion
|
|
1205
1260
|
//#region src/editor/managers/ExportManager.ts
|
|
1206
|
-
var
|
|
1261
|
+
var rr = class {
|
|
1207
1262
|
editor;
|
|
1208
1263
|
constructor(e) {
|
|
1209
1264
|
this.editor = e;
|
|
1210
1265
|
}
|
|
1211
1266
|
blocksToHTMLLossy(e = this.editor.document) {
|
|
1212
|
-
return
|
|
1267
|
+
return ve(this.editor.pmSchema, this.editor).exportBlocks(e, {});
|
|
1213
1268
|
}
|
|
1214
1269
|
blocksToFullHTML(e = this.editor.document) {
|
|
1215
|
-
return
|
|
1270
|
+
return Nt(this.editor.pmSchema, this.editor).serializeBlocks(e, {});
|
|
1216
1271
|
}
|
|
1217
1272
|
tryParseHTMLToBlocks(e) {
|
|
1218
|
-
return
|
|
1273
|
+
return G(e, this.editor.pmSchema);
|
|
1219
1274
|
}
|
|
1220
1275
|
blocksToMarkdownLossy(e = this.editor.document) {
|
|
1221
|
-
return
|
|
1276
|
+
return Te(e, this.editor.pmSchema, this.editor, {});
|
|
1222
1277
|
}
|
|
1223
1278
|
tryParseMarkdownToBlocks(e) {
|
|
1224
|
-
return
|
|
1279
|
+
return nr(e, this.editor.pmSchema);
|
|
1225
1280
|
}
|
|
1226
1281
|
pasteHTML(e, t = !1) {
|
|
1227
1282
|
let n = e;
|
|
@@ -1235,39 +1290,42 @@ var Gn = class {
|
|
|
1235
1290
|
return this.editor.prosemirrorView?.pasteText(e);
|
|
1236
1291
|
}
|
|
1237
1292
|
pasteMarkdown(e) {
|
|
1238
|
-
let t =
|
|
1293
|
+
let t = tr(e);
|
|
1239
1294
|
return this.pasteHTML(t);
|
|
1240
1295
|
}
|
|
1241
1296
|
};
|
|
1242
1297
|
//#endregion
|
|
1243
1298
|
//#region src/api/blockManipulation/selections/textCursorPosition.ts
|
|
1244
|
-
function
|
|
1245
|
-
let { bnBlock: t } =
|
|
1299
|
+
function ir(e) {
|
|
1300
|
+
let { bnBlock: t } = w(e), n = e.doc.resolve(t.beforePos), r = n.nodeBefore, i = e.doc.resolve(t.afterPos).nodeAfter, a;
|
|
1246
1301
|
return n.depth > 1 && (a = n.node(), a.type.isInGroup("bnBlock") || (a = n.node(n.depth - 1))), {
|
|
1247
|
-
block:
|
|
1248
|
-
prevBlock: r === null ? void 0 :
|
|
1249
|
-
nextBlock: i === null ? void 0 :
|
|
1250
|
-
parentBlock: a === void 0 ? void 0 :
|
|
1302
|
+
block: g(t.node, e.doc),
|
|
1303
|
+
prevBlock: r === null ? void 0 : g(r, e.doc),
|
|
1304
|
+
nextBlock: i === null ? void 0 : g(i, e.doc),
|
|
1305
|
+
parentBlock: a === void 0 ? void 0 : g(a, e.doc)
|
|
1251
1306
|
};
|
|
1252
1307
|
}
|
|
1253
|
-
function
|
|
1254
|
-
let
|
|
1255
|
-
if (!
|
|
1256
|
-
let
|
|
1257
|
-
if (
|
|
1258
|
-
let
|
|
1259
|
-
if (
|
|
1260
|
-
|
|
1308
|
+
function ar(e, t, n = "start") {
|
|
1309
|
+
let r = typeof t == "string" ? t : t.id, i = u(e.doc), a = oe(i), o = p(r, e.doc);
|
|
1310
|
+
if (!o) throw Error(`Block with ID ${r} not found`);
|
|
1311
|
+
let s = v(o), c = a.blockSchema[s.blockNoteType].content;
|
|
1312
|
+
if (s.isBlockContainer) {
|
|
1313
|
+
let t = s.blockContent;
|
|
1314
|
+
if (c === "none") {
|
|
1315
|
+
e.setSelection(N.create(e.doc, t.beforePos));
|
|
1261
1316
|
return;
|
|
1262
1317
|
}
|
|
1263
|
-
if (
|
|
1264
|
-
else if (
|
|
1265
|
-
else throw new c
|
|
1266
|
-
} else
|
|
1318
|
+
if (c === "inline" || c === "plain") n === "start" ? e.setSelection(F.create(e.doc, t.beforePos + 1)) : e.setSelection(F.create(e.doc, t.afterPos - 1));
|
|
1319
|
+
else if (c === "table") n === "start" ? e.setSelection(F.create(e.doc, t.beforePos + 4)) : e.setSelection(F.create(e.doc, t.afterPos - 4));
|
|
1320
|
+
else throw new _(c);
|
|
1321
|
+
} else {
|
|
1322
|
+
let t = n === "start" ? s.childContainer.node.firstChild : s.childContainer.node.lastChild;
|
|
1323
|
+
ar(e, C(t, e.doc), n);
|
|
1324
|
+
}
|
|
1267
1325
|
}
|
|
1268
1326
|
//#endregion
|
|
1269
1327
|
//#region src/api/clipboard/fromClipboard/acceptedMIMETypes.ts
|
|
1270
|
-
var
|
|
1328
|
+
var X = [
|
|
1271
1329
|
"vscode-editor-data",
|
|
1272
1330
|
"blocknote/html",
|
|
1273
1331
|
"text/markdown",
|
|
@@ -1277,90 +1335,91 @@ var Jn = [
|
|
|
1277
1335
|
];
|
|
1278
1336
|
//#endregion
|
|
1279
1337
|
//#region src/api/clipboard/fromClipboard/handleFileInsertion.ts
|
|
1280
|
-
function
|
|
1338
|
+
function or(e, t) {
|
|
1281
1339
|
if (!e.startsWith(".") || !t.startsWith(".")) throw Error("The strings provided are not valid file extensions.");
|
|
1282
1340
|
return e === t;
|
|
1283
1341
|
}
|
|
1284
|
-
function
|
|
1342
|
+
function sr(e, t) {
|
|
1285
1343
|
let n = e.split("/"), r = t.split("/");
|
|
1286
1344
|
if (n.length !== 2) throw Error(`The string ${e} is not a valid MIME type.`);
|
|
1287
1345
|
if (r.length !== 2) throw Error(`The string ${t} is not a valid MIME type.`);
|
|
1288
1346
|
return n[1] === "*" || r[1] === "*" ? n[0] === r[0] : (n[0] === "*" || r[0] === "*" || n[0] === r[0]) && n[1] === r[1];
|
|
1289
1347
|
}
|
|
1290
|
-
function
|
|
1348
|
+
function cr(e, t, n, r = "after") {
|
|
1291
1349
|
let i;
|
|
1292
1350
|
return i = Array.isArray(t.content) && t.content.length === 0 ? e.updateBlock(t, n).id : e.insertBlocks([n], t, r)[0].id, i;
|
|
1293
1351
|
}
|
|
1294
|
-
async function
|
|
1295
|
-
if (!
|
|
1352
|
+
async function lr(e, t) {
|
|
1353
|
+
if (!t.uploadFile) {
|
|
1296
1354
|
console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");
|
|
1297
1355
|
return;
|
|
1298
1356
|
}
|
|
1299
|
-
let
|
|
1300
|
-
if (
|
|
1301
|
-
let
|
|
1302
|
-
for (let e of
|
|
1303
|
-
|
|
1357
|
+
let n = "dataTransfer" in e ? e.dataTransfer : e.clipboardData;
|
|
1358
|
+
if (n === null) return;
|
|
1359
|
+
let r = null;
|
|
1360
|
+
for (let e of X) if (n.types.includes(e)) {
|
|
1361
|
+
r = e;
|
|
1304
1362
|
break;
|
|
1305
1363
|
}
|
|
1306
|
-
if (
|
|
1307
|
-
let
|
|
1308
|
-
if (
|
|
1309
|
-
|
|
1310
|
-
for (let
|
|
1311
|
-
let
|
|
1312
|
-
for (let e of Object.values(
|
|
1313
|
-
let
|
|
1314
|
-
if (o && (!
|
|
1315
|
-
|
|
1364
|
+
if (r !== "Files") return;
|
|
1365
|
+
let i = n.items;
|
|
1366
|
+
if (i) {
|
|
1367
|
+
e.preventDefault();
|
|
1368
|
+
for (let n = 0; n < i.length; n++) {
|
|
1369
|
+
let r = "file";
|
|
1370
|
+
for (let e of Object.values(t.schema.blockSpecs)) for (let t of e.implementation.meta?.fileBlockAccept || []) {
|
|
1371
|
+
let a = t.startsWith("."), o = i[n].getAsFile();
|
|
1372
|
+
if (o && (!a && o.type && sr(i[n].type, t) || a && or("." + o.name.split(".").pop(), t))) {
|
|
1373
|
+
r = e.config.type;
|
|
1316
1374
|
break;
|
|
1317
1375
|
}
|
|
1318
1376
|
}
|
|
1319
|
-
let
|
|
1320
|
-
if (
|
|
1321
|
-
let
|
|
1322
|
-
type:
|
|
1323
|
-
props: { name:
|
|
1324
|
-
},
|
|
1325
|
-
if (
|
|
1326
|
-
let e =
|
|
1327
|
-
|
|
1328
|
-
} else if (
|
|
1329
|
-
let
|
|
1330
|
-
left:
|
|
1331
|
-
top:
|
|
1332
|
-
},
|
|
1333
|
-
if (!
|
|
1334
|
-
|
|
1335
|
-
let
|
|
1336
|
-
return
|
|
1377
|
+
let a = i[n].getAsFile();
|
|
1378
|
+
if (a) {
|
|
1379
|
+
let n = {
|
|
1380
|
+
type: r,
|
|
1381
|
+
props: { name: a.name }
|
|
1382
|
+
}, i;
|
|
1383
|
+
if (e.type === "paste") {
|
|
1384
|
+
let e = t.getTextCursorPosition().block;
|
|
1385
|
+
i = cr(t, e, n);
|
|
1386
|
+
} else if (e.type === "drop") {
|
|
1387
|
+
let r = {
|
|
1388
|
+
left: e.clientX,
|
|
1389
|
+
top: e.clientY
|
|
1390
|
+
}, a = t.prosemirrorView.posAtCoords(r);
|
|
1391
|
+
if (!a) return;
|
|
1392
|
+
i = t.transact((e) => {
|
|
1393
|
+
let i = T(e, a.pos), o = C(i.bnBlock.node, e.doc), s = (t.domElement?.querySelector(`[data-id="${o}"]`))?.getBoundingClientRect(), c = t.getBlock(o);
|
|
1394
|
+
if (c) return cr(t, c, n, s && (s.top + s.bottom) / 2 > r.top ? "before" : "after");
|
|
1337
1395
|
});
|
|
1338
1396
|
} else return;
|
|
1339
|
-
|
|
1340
|
-
|
|
1397
|
+
if (!i) return;
|
|
1398
|
+
let o = await t.uploadFile(a, i), s = typeof o == "string" ? { props: { url: o } } : { ...o };
|
|
1399
|
+
t.updateBlock(i, s);
|
|
1341
1400
|
}
|
|
1342
1401
|
}
|
|
1343
1402
|
}
|
|
1344
1403
|
}
|
|
1345
1404
|
//#endregion
|
|
1346
1405
|
//#region src/api/clipboard/fromClipboard/fileDropExtension.ts
|
|
1347
|
-
var
|
|
1406
|
+
var ur = (e) => k.create({
|
|
1348
1407
|
name: "dropFile",
|
|
1349
1408
|
addProseMirrorPlugins() {
|
|
1350
|
-
return [new
|
|
1409
|
+
return [new P({ props: { handleDOMEvents: { drop(t, n) {
|
|
1351
1410
|
if (!e.isEditable) return;
|
|
1352
1411
|
let r = null;
|
|
1353
|
-
for (let e of
|
|
1412
|
+
for (let e of X) if (n.dataTransfer.types.includes(e)) {
|
|
1354
1413
|
r = e;
|
|
1355
1414
|
break;
|
|
1356
1415
|
}
|
|
1357
|
-
return r === null
|
|
1416
|
+
return r === null || r === "Files" && (lr(n, e), !0);
|
|
1358
1417
|
} } } })];
|
|
1359
1418
|
}
|
|
1360
|
-
}),
|
|
1419
|
+
}), dr = /(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/, fr = /(_|__|\*|\*\*|~~|==|\+\+)(?!\s)(?:[^\s](?:.{0,62}[^\s])?|\S)(?=\1)/, pr = /\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/, mr = /(?:\s|^)`(?!\s)(?:[^\s`](?:[^`]{0,46}[^\s`])?|[^\s`])`([^\w]|$)/, hr = /(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/, gr = /(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/, _r = /\n{2} {0,3}-{2,48}\n{2}/, vr = /(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/, yr = /(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/, br = /(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/, xr = /^\s*\|(.+\|)+\s*$/m, Sr = /^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m, Cr = /^\s*\|(.+\|)+\s*$/m, wr = (e) => dr.test(e) || fr.test(e) || pr.test(e) || mr.test(e) || hr.test(e) || gr.test(e) || _r.test(e) || vr.test(e) || yr.test(e) || br.test(e) || xr.test(e) || Sr.test(e) || Cr.test(e);
|
|
1361
1420
|
//#endregion
|
|
1362
1421
|
//#region src/api/clipboard/fromClipboard/handleVSCodePaste.ts
|
|
1363
|
-
function
|
|
1422
|
+
function Tr(e, t) {
|
|
1364
1423
|
let { schema: n } = t.state;
|
|
1365
1424
|
if (!e.clipboardData) return !1;
|
|
1366
1425
|
let r = e.clipboardData.getData("text/plain");
|
|
@@ -1370,39 +1429,39 @@ function mr(e, t) {
|
|
|
1370
1429
|
}
|
|
1371
1430
|
//#endregion
|
|
1372
1431
|
//#region src/api/clipboard/fromClipboard/pasteExtension.ts
|
|
1373
|
-
function
|
|
1432
|
+
function Er({ event: e, editor: t, prioritizeMarkdownOverHTML: n, plainTextAsMarkdown: r }) {
|
|
1374
1433
|
if (t.transact((e) => e.selection.$from.parent.type.spec.code && e.selection.$to.parent.type.spec.code)) {
|
|
1375
1434
|
let n = e.clipboardData?.getData("text/plain");
|
|
1376
1435
|
if (n) return t.pasteText(n), !0;
|
|
1377
1436
|
}
|
|
1378
1437
|
let i;
|
|
1379
|
-
for (let t of
|
|
1438
|
+
for (let t of X) if (e.clipboardData.types.includes(t)) {
|
|
1380
1439
|
i = t;
|
|
1381
1440
|
break;
|
|
1382
1441
|
}
|
|
1383
1442
|
if (!i) return !0;
|
|
1384
1443
|
if (i === "vscode-editor-data") {
|
|
1385
|
-
if (
|
|
1444
|
+
if (Tr(e, t.prosemirrorView)) return !0;
|
|
1386
1445
|
i = "text/plain";
|
|
1387
1446
|
}
|
|
1388
|
-
if (i === "Files") return
|
|
1447
|
+
if (i === "Files") return lr(e, t), !0;
|
|
1389
1448
|
let a = e.clipboardData.getData(i);
|
|
1390
1449
|
if (i === "blocknote/html") return t.pasteHTML(a, !0), !0;
|
|
1391
1450
|
if (i === "text/markdown") return t.pasteMarkdown(a), !0;
|
|
1392
1451
|
if (n) {
|
|
1393
1452
|
let n = e.clipboardData.getData("text/plain");
|
|
1394
|
-
if (
|
|
1453
|
+
if (wr(n)) return t.pasteMarkdown(n), !0;
|
|
1395
1454
|
}
|
|
1396
1455
|
return i === "text/html" ? (t.pasteHTML(a), !0) : r ? (t.pasteMarkdown(a), !0) : (t.pasteText(a), !0);
|
|
1397
1456
|
}
|
|
1398
|
-
var
|
|
1457
|
+
var Dr = (e, t) => k.create({
|
|
1399
1458
|
name: "pasteFromClipboard",
|
|
1400
1459
|
addProseMirrorPlugins() {
|
|
1401
|
-
return [new
|
|
1460
|
+
return [new P({ props: { handleDOMEvents: { paste(n, r) {
|
|
1402
1461
|
if (r.preventDefault(), e.isEditable) return t({
|
|
1403
1462
|
event: r,
|
|
1404
1463
|
editor: e,
|
|
1405
|
-
defaultPasteHandler: ({ prioritizeMarkdownOverHTML: t = !0, plainTextAsMarkdown: n = !0 } = {}) =>
|
|
1464
|
+
defaultPasteHandler: ({ prioritizeMarkdownOverHTML: t = !0, plainTextAsMarkdown: n = !0 } = {}) => Er({
|
|
1406
1465
|
event: r,
|
|
1407
1466
|
editor: e,
|
|
1408
1467
|
prioritizeMarkdownOverHTML: t,
|
|
@@ -1414,37 +1473,37 @@ var gr = (e, t) => D.create({
|
|
|
1414
1473
|
});
|
|
1415
1474
|
//#endregion
|
|
1416
1475
|
//#region src/api/clipboard/toClipboard/copyExtension.ts
|
|
1417
|
-
function
|
|
1418
|
-
let
|
|
1419
|
-
if (!
|
|
1420
|
-
let
|
|
1421
|
-
for (let e = 0; e <
|
|
1422
|
-
|
|
1423
|
-
}
|
|
1424
|
-
let
|
|
1425
|
-
if (
|
|
1426
|
-
|
|
1427
|
-
let e =
|
|
1428
|
-
|
|
1429
|
-
} else if (
|
|
1430
|
-
let e =
|
|
1431
|
-
|
|
1476
|
+
function Or(e, n, r) {
|
|
1477
|
+
let i = !1, a = e.state.selection instanceof at;
|
|
1478
|
+
if (!a) {
|
|
1479
|
+
let t = e.state.doc.slice(e.state.selection.from, e.state.selection.to, !1).content, r = [];
|
|
1480
|
+
for (let e = 0; e < t.childCount; e++) r.push(t.child(e));
|
|
1481
|
+
i = r.find((e) => e.type.isInGroup("bnBlock") || e.type.name === "blockGroup" || e.type.spec.group === "blockContent") === void 0, i && (n = t);
|
|
1482
|
+
}
|
|
1483
|
+
let o, s = ve(e.state.schema, r);
|
|
1484
|
+
if (a) {
|
|
1485
|
+
n.firstChild?.type.name === "table" && (n = n.firstChild.content);
|
|
1486
|
+
let e = t(n, r.schema.inlineContentSchema, r.schema.styleSchema);
|
|
1487
|
+
o = `<table>${s.exportInlineContent(e, {})}</table>`;
|
|
1488
|
+
} else if (i) {
|
|
1489
|
+
let e = h(n, r.schema.inlineContentSchema, r.schema.styleSchema);
|
|
1490
|
+
o = s.exportInlineContent(e, {});
|
|
1432
1491
|
} else {
|
|
1433
|
-
let e =
|
|
1434
|
-
|
|
1492
|
+
let e = Pe(n);
|
|
1493
|
+
o = s.exportBlocks(e, {});
|
|
1435
1494
|
}
|
|
1436
|
-
return
|
|
1495
|
+
return o;
|
|
1437
1496
|
}
|
|
1438
|
-
function
|
|
1439
|
-
"node" in e.state.selection && e.state.selection.node.type.spec.group === "blockContent" && t.transact((t) => t.setSelection(new
|
|
1440
|
-
let n = e.serializeForClipboard(e.state.selection.content()).dom.innerHTML, r = e.state.selection.content().content, i =
|
|
1497
|
+
function kr(e, t) {
|
|
1498
|
+
"node" in e.state.selection && e.state.selection.node.type.spec.group === "blockContent" && t.transact((t) => t.setSelection(new N(t.doc.resolve(e.state.selection.from - 1))));
|
|
1499
|
+
let n = e.serializeForClipboard(e.state.selection.content()).dom.innerHTML, r = e.state.selection.content().content, i = Or(e, r, t), { $from: a, $to: o } = e.state.selection, s = a.parent.type.name, c = t.blockImplementations[s];
|
|
1441
1500
|
return {
|
|
1442
1501
|
clipboardHTML: n,
|
|
1443
1502
|
externalHTML: i,
|
|
1444
|
-
markdown: a.sameParent(o) && c?.implementation.meta?.code === !0 ? e.state.doc.textBetween(a.pos, o.pos) :
|
|
1503
|
+
markdown: a.sameParent(o) && c?.implementation.meta?.code === !0 ? e.state.doc.textBetween(a.pos, o.pos) : Ne(i)
|
|
1445
1504
|
};
|
|
1446
1505
|
}
|
|
1447
|
-
var
|
|
1506
|
+
var Ar = (e) => {
|
|
1448
1507
|
if (e.state.selection.empty) return !0;
|
|
1449
1508
|
let t = window.getSelection();
|
|
1450
1509
|
if (t && !t.isCollapsed) {
|
|
@@ -1455,37 +1514,37 @@ var yr = (e) => {
|
|
|
1455
1514
|
}
|
|
1456
1515
|
}
|
|
1457
1516
|
return !1;
|
|
1458
|
-
},
|
|
1517
|
+
}, jr = (e, t, n) => {
|
|
1459
1518
|
n.preventDefault(), n.clipboardData.clearData();
|
|
1460
|
-
let { clipboardHTML: r, externalHTML: i, markdown: a } =
|
|
1519
|
+
let { clipboardHTML: r, externalHTML: i, markdown: a } = kr(t, e);
|
|
1461
1520
|
n.clipboardData.setData("blocknote/html", r), n.clipboardData.setData("text/html", i), n.clipboardData.setData("text/plain", a);
|
|
1462
|
-
},
|
|
1521
|
+
}, Mr = (e) => k.create({
|
|
1463
1522
|
name: "copyToClipboard",
|
|
1464
1523
|
addProseMirrorPlugins() {
|
|
1465
|
-
return [new
|
|
1524
|
+
return [new P({ props: { handleDOMEvents: {
|
|
1466
1525
|
copy(t, n) {
|
|
1467
|
-
return
|
|
1526
|
+
return Ar(t) || jr(e, t, n), !0;
|
|
1468
1527
|
},
|
|
1469
1528
|
cut(t, n) {
|
|
1470
|
-
return
|
|
1529
|
+
return Ar(t) ? !0 : (jr(e, t, n), t.editable && t.dispatch(t.state.tr.deleteSelection()), !0);
|
|
1471
1530
|
},
|
|
1472
1531
|
dragstart(t, n) {
|
|
1473
1532
|
if (!("node" in t.state.selection) || t.state.selection.node.type.spec.group !== "blockContent") return;
|
|
1474
|
-
e.transact((e) => e.setSelection(new
|
|
1475
|
-
let { clipboardHTML: r, externalHTML: i, markdown: a } =
|
|
1533
|
+
e.transact((e) => e.setSelection(new N(e.doc.resolve(t.state.selection.from - 1)))), n.preventDefault(), n.dataTransfer.clearData();
|
|
1534
|
+
let { clipboardHTML: r, externalHTML: i, markdown: a } = kr(t, e);
|
|
1476
1535
|
return n.dataTransfer.setData("blocknote/html", r), n.dataTransfer.setData("text/html", i), n.dataTransfer.setData("text/plain", a), !0;
|
|
1477
1536
|
}
|
|
1478
1537
|
} } })];
|
|
1479
1538
|
}
|
|
1480
|
-
}),
|
|
1539
|
+
}), Nr = k.create({
|
|
1481
1540
|
name: "blockBackgroundColor",
|
|
1482
1541
|
addGlobalAttributes() {
|
|
1483
1542
|
return [{
|
|
1484
1543
|
types: ["tableCell", "tableHeader"],
|
|
1485
|
-
attributes: { backgroundColor:
|
|
1544
|
+
attributes: { backgroundColor: ue() }
|
|
1486
1545
|
}];
|
|
1487
1546
|
}
|
|
1488
|
-
}),
|
|
1547
|
+
}), Pr = A.create({
|
|
1489
1548
|
name: "hardBreak",
|
|
1490
1549
|
inline: !0,
|
|
1491
1550
|
group: "inline",
|
|
@@ -1496,33 +1555,33 @@ var yr = (e) => {
|
|
|
1496
1555
|
return [{ tag: "br" }];
|
|
1497
1556
|
},
|
|
1498
1557
|
renderHTML({ HTMLAttributes: e }) {
|
|
1499
|
-
return ["br",
|
|
1558
|
+
return ["br", M(this.options.HTMLAttributes, e)];
|
|
1500
1559
|
},
|
|
1501
1560
|
renderText() {
|
|
1502
1561
|
return "\n";
|
|
1503
1562
|
}
|
|
1504
|
-
}),
|
|
1563
|
+
}), Fr = (e, t) => {
|
|
1505
1564
|
let n = e.resolve(t), r = n.depth - 1;
|
|
1506
1565
|
if (r < 1) return;
|
|
1507
1566
|
let i = n.before(r), a = e.resolve(i).nodeAfter;
|
|
1508
|
-
if (a) return a.type.spec.group?.includes("bnBlock") ?
|
|
1509
|
-
},
|
|
1567
|
+
if (a) return a.type.spec.group?.includes("bnBlock") ? S(e.resolve(i)) : Fr(e, i);
|
|
1568
|
+
}, Z = (e, t) => {
|
|
1510
1569
|
let n = e.resolve(t), r = n.index();
|
|
1511
1570
|
if (r === 0) return;
|
|
1512
1571
|
let i = n.posAtIndex(r - 1);
|
|
1513
|
-
return
|
|
1514
|
-
},
|
|
1572
|
+
return S(e.resolve(i));
|
|
1573
|
+
}, Q = (e, t) => {
|
|
1515
1574
|
let n = e.resolve(t), r = n.index();
|
|
1516
1575
|
if (r === n.node().childCount - 1) return;
|
|
1517
1576
|
let i = n.posAtIndex(r + 1);
|
|
1518
|
-
return
|
|
1519
|
-
},
|
|
1577
|
+
return S(e.resolve(i));
|
|
1578
|
+
}, Ir = (e, t) => {
|
|
1520
1579
|
for (; t.childContainer;) {
|
|
1521
1580
|
let n = t.childContainer.node, r = e.resolve(t.childContainer.beforePos + 1).posAtIndex(n.childCount - 1);
|
|
1522
|
-
t =
|
|
1581
|
+
t = S(e.resolve(r));
|
|
1523
1582
|
}
|
|
1524
1583
|
return t;
|
|
1525
|
-
},
|
|
1584
|
+
}, Lr = (e, t) => e.isBlockContainer && e.blockContent.node.type.spec.content === "inline*" && e.blockContent.node.childCount > 0 && t.isBlockContainer && t.blockContent.node.type.spec.content === "inline*", Rr = (e, t, n, r) => {
|
|
1526
1585
|
if (!r.isBlockContainer) throw Error(`Attempted to merge block at position ${r.bnBlock.beforePos} into previous block at position ${n.bnBlock.beforePos}, but next block is not a block container`);
|
|
1527
1586
|
if (r.childContainer) {
|
|
1528
1587
|
let n = e.doc.resolve(r.childContainer.beforePos + 1), i = e.doc.resolve(r.childContainer.afterPos - 1), a = n.blockRange(i);
|
|
@@ -1536,66 +1595,66 @@ var yr = (e) => {
|
|
|
1536
1595
|
t(e.tr.delete(n.blockContent.afterPos - 1, r.blockContent.beforePos + 1));
|
|
1537
1596
|
}
|
|
1538
1597
|
return !0;
|
|
1539
|
-
},
|
|
1540
|
-
let r =
|
|
1541
|
-
if (!
|
|
1542
|
-
let
|
|
1543
|
-
return
|
|
1544
|
-
},
|
|
1598
|
+
}, zr = (e) => ({ state: t, dispatch: n }) => {
|
|
1599
|
+
let r = t.doc.resolve(e), i = S(r), a = Z(t.doc, i.bnBlock.beforePos);
|
|
1600
|
+
if (!a) return !1;
|
|
1601
|
+
let o = Ir(t.doc, a);
|
|
1602
|
+
return Lr(o, i) ? Rr(t, n, o, i) : !1;
|
|
1603
|
+
}, Br = k.create({
|
|
1545
1604
|
priority: 50,
|
|
1546
1605
|
addKeyboardShortcuts() {
|
|
1547
1606
|
let e = () => this.editor.commands.first(({ chain: e, commands: t }) => [
|
|
1548
1607
|
() => t.deleteSelection(),
|
|
1549
1608
|
() => t.undoInputRule(),
|
|
1550
1609
|
() => t.command(({ state: e }) => {
|
|
1551
|
-
let n =
|
|
1610
|
+
let n = w(e);
|
|
1552
1611
|
if (!n.isBlockContainer) return !1;
|
|
1553
|
-
let
|
|
1554
|
-
return
|
|
1612
|
+
let r = e.selection.from === n.blockContent.beforePos + 1, i = n.blockContent.node.type.name === "paragraph";
|
|
1613
|
+
return r && !i ? t.command(d(n.bnBlock.beforePos, {
|
|
1555
1614
|
type: "paragraph",
|
|
1556
1615
|
props: {}
|
|
1557
1616
|
})) : !1;
|
|
1558
1617
|
}),
|
|
1559
1618
|
() => t.command(({ state: e, tr: t }) => {
|
|
1560
|
-
let n =
|
|
1619
|
+
let n = w(e);
|
|
1561
1620
|
if (!n.isBlockContainer) return !1;
|
|
1562
1621
|
let { blockContent: r } = n;
|
|
1563
|
-
return e.selection.from === r.beforePos + 1
|
|
1622
|
+
return e.selection.from === r.beforePos + 1 && W(t, t.doc.type.schema.nodes.blockContainer, t.doc.type.schema.nodes.blockGroup);
|
|
1564
1623
|
}),
|
|
1565
1624
|
() => t.command(({ state: t }) => {
|
|
1566
|
-
let n =
|
|
1625
|
+
let n = w(t);
|
|
1567
1626
|
if (!n.isBlockContainer) return !1;
|
|
1568
|
-
let { bnBlock: r, blockContent: i } = n, a =
|
|
1627
|
+
let { bnBlock: r, blockContent: i } = n, a = Z(t.doc, n.bnBlock.beforePos);
|
|
1569
1628
|
if (!a || !a.isBlockContainer || a.blockContent.node.type.spec.content !== "inline*") return !1;
|
|
1570
1629
|
let o = t.selection.from === i.beforePos + 1, s = t.selection.empty, c = r.beforePos;
|
|
1571
|
-
return o && s ? e().command(
|
|
1630
|
+
return o && s ? e().command(zr(c)).scrollIntoView().run() : !1;
|
|
1572
1631
|
}),
|
|
1573
1632
|
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1574
|
-
let r =
|
|
1633
|
+
let r = w(e);
|
|
1575
1634
|
if (!r.isBlockContainer || e.selection.from !== r.blockContent.beforePos + 1) return !1;
|
|
1576
|
-
let i =
|
|
1635
|
+
let i = Z(e.doc, r.bnBlock.beforePos);
|
|
1577
1636
|
if (!i || i.isBlockContainer) return !1;
|
|
1578
1637
|
if (n) {
|
|
1579
1638
|
let e = i.bnBlock.afterPos - 1, n = t.doc.resolve(e - 1);
|
|
1580
|
-
return t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), t.insert(n.pos, r.bnBlock.node), t.setSelection(
|
|
1639
|
+
return t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), t.insert(n.pos, r.bnBlock.node), t.setSelection(F.near(t.doc.resolve(n.pos + 1))), !0;
|
|
1581
1640
|
}
|
|
1582
1641
|
return !1;
|
|
1583
1642
|
}),
|
|
1584
1643
|
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1585
|
-
let r =
|
|
1644
|
+
let r = w(e);
|
|
1586
1645
|
if (!r.isBlockContainer || t.selection.from !== r.blockContent.beforePos + 1) return !1;
|
|
1587
1646
|
let i = t.doc.resolve(r.bnBlock.beforePos);
|
|
1588
1647
|
if (i.nodeBefore || i.node().type.name !== "column") return !1;
|
|
1589
1648
|
let a = t.doc.resolve(r.bnBlock.beforePos), o = t.doc.resolve(a.before()), s = o.before();
|
|
1590
|
-
return n && (t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos),
|
|
1649
|
+
return n && (t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), z(t, s), o.pos === s + 1 ? (t.insert(s, r.bnBlock.node), t.setSelection(F.near(t.doc.resolve(s)))) : (t.insert(o.pos - 1, r.bnBlock.node), t.setSelection(F.near(t.doc.resolve(o.pos))))), !0;
|
|
1591
1650
|
}),
|
|
1592
1651
|
() => t.command(({ state: t }) => {
|
|
1593
|
-
let n =
|
|
1652
|
+
let n = w(t);
|
|
1594
1653
|
if (!n.isBlockContainer) return !1;
|
|
1595
1654
|
if (n.blockContent.node.childCount === 0 && n.blockContent.node.type.spec.content === "inline*") {
|
|
1596
|
-
let r =
|
|
1655
|
+
let r = Z(t.doc, n.bnBlock.beforePos);
|
|
1597
1656
|
if (!r) return !1;
|
|
1598
|
-
let i =
|
|
1657
|
+
let i = Ir(t.doc, r);
|
|
1599
1658
|
if (!i.isBlockContainer || !i || !i.isBlockContainer) return !1;
|
|
1600
1659
|
let a = e();
|
|
1601
1660
|
if (n.childContainer && a.insertContentAt(n.bnBlock.afterPos, n.childContainer?.node.content), i.blockContent.node.type.spec.content === "tableRow+") {
|
|
@@ -1614,11 +1673,11 @@ var yr = (e) => {
|
|
|
1614
1673
|
return !1;
|
|
1615
1674
|
}),
|
|
1616
1675
|
() => t.command(({ state: t }) => {
|
|
1617
|
-
let n =
|
|
1676
|
+
let n = w(t);
|
|
1618
1677
|
if (!n.isBlockContainer) return !1;
|
|
1619
|
-
let r = t.selection.from === n.blockContent.beforePos + 1, i = t.selection.empty, a =
|
|
1678
|
+
let r = t.selection.from === n.blockContent.beforePos + 1, i = t.selection.empty, a = Z(t.doc, n.bnBlock.beforePos);
|
|
1620
1679
|
if (a && r && i) {
|
|
1621
|
-
let r =
|
|
1680
|
+
let r = Ir(t.doc, a);
|
|
1622
1681
|
if (!r.isBlockContainer) return !1;
|
|
1623
1682
|
if (r.blockContent.node.type.spec.content === "" || r.blockContent.node.type.spec.content === "inline*" && r.blockContent.node.childCount === 0) return e().cut({
|
|
1624
1683
|
from: n.bnBlock.beforePos,
|
|
@@ -1633,13 +1692,13 @@ var yr = (e) => {
|
|
|
1633
1692
|
]), t = () => this.editor.commands.first(({ chain: e, commands: t }) => [
|
|
1634
1693
|
() => t.deleteSelection(),
|
|
1635
1694
|
() => t.command(({ state: t }) => {
|
|
1636
|
-
let n =
|
|
1695
|
+
let n = w(t);
|
|
1637
1696
|
if (!n.isBlockContainer || !n.childContainer) return !1;
|
|
1638
|
-
let { blockContent: r, childContainer: i } = n, a = t.selection.from === r.afterPos - 1, o = t.selection.empty, s =
|
|
1697
|
+
let { blockContent: r, childContainer: i } = n, a = t.selection.from === r.afterPos - 1, o = t.selection.empty, s = S(t.doc.resolve(i.beforePos + 1));
|
|
1639
1698
|
if (!s.isBlockContainer) return !1;
|
|
1640
1699
|
if (a && o) {
|
|
1641
1700
|
let n = s.blockContent.node, a = n.type.spec.content === "inline*", o = r.node.type.spec.content === "inline*";
|
|
1642
|
-
return e().insertContentAt(s.bnBlock.afterPos, s.childContainer?.node.content ||
|
|
1701
|
+
return e().insertContentAt(s.bnBlock.afterPos, s.childContainer?.node.content || E.empty).deleteRange(i.node.childCount === 1 ? {
|
|
1643
1702
|
from: i.beforePos,
|
|
1644
1703
|
to: i.afterPos
|
|
1645
1704
|
} : {
|
|
@@ -1650,50 +1709,50 @@ var yr = (e) => {
|
|
|
1650
1709
|
return !1;
|
|
1651
1710
|
}),
|
|
1652
1711
|
() => t.command(({ state: t }) => {
|
|
1653
|
-
let n =
|
|
1712
|
+
let n = w(t);
|
|
1654
1713
|
if (!n.isBlockContainer) return !1;
|
|
1655
|
-
let { bnBlock: r, blockContent: i } = n, a =
|
|
1714
|
+
let { bnBlock: r, blockContent: i } = n, a = Q(t.doc, n.bnBlock.beforePos);
|
|
1656
1715
|
if (!a || !a.isBlockContainer) return !1;
|
|
1657
1716
|
let o = t.selection.from === i.afterPos - 1, s = t.selection.empty, c = r.afterPos;
|
|
1658
|
-
return o && s ? e().command(
|
|
1717
|
+
return o && s ? e().command(zr(c)).scrollIntoView().run() : !1;
|
|
1659
1718
|
}),
|
|
1660
1719
|
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1661
|
-
let r =
|
|
1720
|
+
let r = w(e);
|
|
1662
1721
|
if (!r.isBlockContainer || e.selection.from !== r.blockContent.afterPos - 1) return !1;
|
|
1663
|
-
let i =
|
|
1722
|
+
let i = Q(e.doc, r.bnBlock.beforePos);
|
|
1664
1723
|
if (!i || i.isBlockContainer) return !1;
|
|
1665
1724
|
if (n) {
|
|
1666
1725
|
let e = i.bnBlock.beforePos + 1, n = t.doc.resolve(e + 1);
|
|
1667
|
-
return t.delete(n.pos, n.pos + n.nodeAfter.nodeSize),
|
|
1726
|
+
return t.delete(n.pos, n.pos + n.nodeAfter.nodeSize), z(t, i.bnBlock.beforePos), t.insert(r.bnBlock.afterPos, n.nodeAfter), t.setSelection(F.near(t.doc.resolve(n.pos))), !0;
|
|
1668
1727
|
}
|
|
1669
1728
|
return !1;
|
|
1670
1729
|
}),
|
|
1671
1730
|
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1672
|
-
let r =
|
|
1731
|
+
let r = w(e);
|
|
1673
1732
|
if (!r.isBlockContainer || t.selection.from !== r.blockContent.afterPos - 1) return !1;
|
|
1674
1733
|
let i = t.doc.resolve(r.bnBlock.afterPos);
|
|
1675
1734
|
if (i.nodeAfter || i.node().type.name !== "column") return !1;
|
|
1676
1735
|
let a = t.doc.resolve(r.bnBlock.afterPos), o = t.doc.resolve(a.after()), s = o.after();
|
|
1677
1736
|
if (n) {
|
|
1678
|
-
let e = o.pos === s - 1 ? s : o.pos + 1, n =
|
|
1679
|
-
t.delete(n.bnBlock.beforePos, n.bnBlock.afterPos),
|
|
1737
|
+
let e = o.pos === s - 1 ? s : o.pos + 1, n = S(t.doc.resolve(e));
|
|
1738
|
+
t.delete(n.bnBlock.beforePos, n.bnBlock.afterPos), z(t, s - o.node().nodeSize), t.insert(a.pos, n.bnBlock.node), t.setSelection(F.near(t.doc.resolve(e)));
|
|
1680
1739
|
}
|
|
1681
1740
|
return !0;
|
|
1682
1741
|
}),
|
|
1683
1742
|
() => t.command(({ state: t }) => {
|
|
1684
|
-
let n =
|
|
1743
|
+
let n = w(t);
|
|
1685
1744
|
if (!n.isBlockContainer) return !1;
|
|
1686
1745
|
let { blockContent: r } = n, i = t.selection.from === r.afterPos - 1, a = t.selection.empty;
|
|
1687
1746
|
if (i && a) {
|
|
1688
1747
|
let i = (e, t) => {
|
|
1689
|
-
let n =
|
|
1748
|
+
let n = Q(e, t);
|
|
1690
1749
|
if (n) return n;
|
|
1691
|
-
let r =
|
|
1750
|
+
let r = Fr(e, t);
|
|
1692
1751
|
if (r) return i(e, r.bnBlock.beforePos);
|
|
1693
1752
|
}, a = i(t.doc, n.bnBlock.beforePos);
|
|
1694
1753
|
if (!a || !a.isBlockContainer) return !1;
|
|
1695
1754
|
let o = a.blockContent.node, s = o.type.spec.content === "inline*", c = r.node.type.spec.content === "inline*";
|
|
1696
|
-
return e().insertContentAt(a.bnBlock.afterPos, a.childContainer?.node.content ||
|
|
1755
|
+
return e().insertContentAt(a.bnBlock.afterPos, a.childContainer?.node.content || E.empty).deleteRange({
|
|
1697
1756
|
from: a.bnBlock.beforePos,
|
|
1698
1757
|
to: a.bnBlock.afterPos
|
|
1699
1758
|
}).insertContentAt(t.selection.from, s && c ? o.content : null).setTextSelection(t.selection.from).scrollIntoView().run();
|
|
@@ -1701,10 +1760,10 @@ var yr = (e) => {
|
|
|
1701
1760
|
return !1;
|
|
1702
1761
|
}),
|
|
1703
1762
|
() => t.command(({ state: t }) => {
|
|
1704
|
-
let n =
|
|
1763
|
+
let n = w(t);
|
|
1705
1764
|
if (!n.isBlockContainer) return !1;
|
|
1706
1765
|
if (n.blockContent.node.childCount === 0 && n.blockContent.node.type.spec.content === "inline*") {
|
|
1707
|
-
let r =
|
|
1766
|
+
let r = Q(t.doc, n.bnBlock.beforePos);
|
|
1708
1767
|
if (!r || !r.isBlockContainer) return !1;
|
|
1709
1768
|
let i = e();
|
|
1710
1769
|
if (r.blockContent.node.type.spec.content === "tableRow+") {
|
|
@@ -1719,9 +1778,9 @@ var yr = (e) => {
|
|
|
1719
1778
|
return !1;
|
|
1720
1779
|
}),
|
|
1721
1780
|
() => t.command(({ state: t }) => {
|
|
1722
|
-
let n =
|
|
1781
|
+
let n = w(t);
|
|
1723
1782
|
if (!n.isBlockContainer) return !1;
|
|
1724
|
-
let r = t.selection.from === n.blockContent.afterPos - 1, i = t.selection.empty, a =
|
|
1783
|
+
let r = t.selection.from === n.blockContent.afterPos - 1, i = t.selection.empty, a = Q(t.doc, n.bnBlock.beforePos);
|
|
1725
1784
|
if (!a || !a.isBlockContainer) return !1;
|
|
1726
1785
|
if (a && r && i && (a.blockContent.node.type.spec.content === "" || a.blockContent.node.type.spec.content === "inline*" && a.blockContent.node.childCount === 0)) {
|
|
1727
1786
|
let t = a.bnBlock.node.lastChild.content;
|
|
@@ -1734,39 +1793,40 @@ var yr = (e) => {
|
|
|
1734
1793
|
})
|
|
1735
1794
|
]), n = (e = !1) => this.editor.commands.first(({ commands: t, tr: n }) => [
|
|
1736
1795
|
() => t.command(({ state: e, tr: t }) => {
|
|
1737
|
-
let n =
|
|
1796
|
+
let n = w(e);
|
|
1738
1797
|
if (!n.isBlockContainer) return !1;
|
|
1739
1798
|
let { bnBlock: r, blockContent: i } = n, { depth: a } = e.doc.resolve(r.beforePos), o = e.selection.$anchor.parentOffset === 0, s = e.selection.anchor === e.selection.head, c = i.node.childCount === 0;
|
|
1740
|
-
return o && s && c && a > 1 ?
|
|
1799
|
+
return o && s && c && a > 1 ? W(t, t.doc.type.schema.nodes.blockContainer, t.doc.type.schema.nodes.blockGroup) : !1;
|
|
1741
1800
|
}),
|
|
1742
1801
|
() => t.command(({ state: t }) => {
|
|
1743
|
-
let r =
|
|
1744
|
-
if (
|
|
1745
|
-
if (
|
|
1802
|
+
let r = w(t), i = this.options.editor.schema.blockSpecs[r.blockNoteType], a = i?.implementation?.meta?.hardBreakShortcut ?? "shift+enter";
|
|
1803
|
+
if (a === "none") return !1;
|
|
1804
|
+
if (a === "shift+enter" && e || a === "enter") {
|
|
1805
|
+
if (i?.config?.content === "plain") return n.insertText("\n", n.selection.head), !0;
|
|
1746
1806
|
let e = n.storedMarks || n.selection.$head.marks().filter((e) => this.editor.extensionManager.splittableMarks.includes(e.type.name));
|
|
1747
1807
|
return n.insert(n.selection.head, n.doc.type.schema.nodes.hardBreak.create()).ensureMarks(e), !0;
|
|
1748
1808
|
}
|
|
1749
1809
|
return !1;
|
|
1750
1810
|
}),
|
|
1751
1811
|
() => t.command(({ state: e, dispatch: t, tr: n }) => {
|
|
1752
|
-
let r =
|
|
1812
|
+
let r = w(e);
|
|
1753
1813
|
if (!r.isBlockContainer) return !1;
|
|
1754
1814
|
let { bnBlock: i, blockContent: a } = r, o = e.selection.$anchor.parentOffset === 0, s = e.selection.anchor === e.selection.head, c = a.node.childCount === 0;
|
|
1755
1815
|
if (o && s && c) {
|
|
1756
1816
|
let a = i.afterPos, o = a + 2;
|
|
1757
1817
|
if (t) {
|
|
1758
1818
|
let t = e.schema.nodes.blockContainer.createAndFill(void 0, [e.schema.nodes.paragraph.createAndFill() || void 0, r.childContainer?.node].filter((e) => e !== void 0));
|
|
1759
|
-
n.insert(a, t).setSelection(new
|
|
1819
|
+
n.insert(a, t).setSelection(new F(n.doc.resolve(o))).scrollIntoView(), r.childContainer && n.delete(r.childContainer.beforePos, r.childContainer.afterPos);
|
|
1760
1820
|
}
|
|
1761
1821
|
return !0;
|
|
1762
1822
|
}
|
|
1763
1823
|
return !1;
|
|
1764
1824
|
}),
|
|
1765
1825
|
() => t.command(({ state: e, chain: t }) => {
|
|
1766
|
-
let n =
|
|
1826
|
+
let n = w(e);
|
|
1767
1827
|
if (!n.isBlockContainer) return !1;
|
|
1768
1828
|
let { blockContent: r } = n, i = e.selection.$anchor.parentOffset === 0;
|
|
1769
|
-
return r.node.childCount
|
|
1829
|
+
return r.node.childCount !== 0 && (t().deleteSelection().command(o(e.selection.from, i, i)).scrollIntoView().run(), !0);
|
|
1770
1830
|
})
|
|
1771
1831
|
]);
|
|
1772
1832
|
return {
|
|
@@ -1774,8 +1834,8 @@ var yr = (e) => {
|
|
|
1774
1834
|
Delete: t,
|
|
1775
1835
|
Enter: () => n(),
|
|
1776
1836
|
"Shift-Enter": () => n(!0),
|
|
1777
|
-
Tab: () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(
|
|
1778
|
-
"Shift-Tab": () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(
|
|
1837
|
+
Tab: () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(x)?.store.state || this.options.editor.getExtension(fe)?.store.state !== void 0) ? !1 : Yt(this.options.editor),
|
|
1838
|
+
"Shift-Tab": () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(x)?.store.state || this.options.editor.getExtension(fe)?.store.state !== void 0) ? !1 : Zt(this.options.editor),
|
|
1779
1839
|
"Shift-Mod-ArrowUp": () => (this.options.editor.moveBlocksUp(), !0),
|
|
1780
1840
|
"Shift-Mod-ArrowDown": () => (this.options.editor.moveBlocksDown(), !0),
|
|
1781
1841
|
"Mod-z": () => this.options.editor.undo(),
|
|
@@ -1783,7 +1843,7 @@ var yr = (e) => {
|
|
|
1783
1843
|
"Shift-Mod-z": () => this.options.editor.redo()
|
|
1784
1844
|
};
|
|
1785
1845
|
}
|
|
1786
|
-
}),
|
|
1846
|
+
}), Vr = k.create({
|
|
1787
1847
|
name: "textAlignment",
|
|
1788
1848
|
addGlobalAttributes() {
|
|
1789
1849
|
return [{
|
|
@@ -1795,7 +1855,7 @@ var yr = (e) => {
|
|
|
1795
1855
|
} }
|
|
1796
1856
|
}];
|
|
1797
1857
|
}
|
|
1798
|
-
}),
|
|
1858
|
+
}), Hr = k.create({
|
|
1799
1859
|
name: "blockTextColor",
|
|
1800
1860
|
addGlobalAttributes() {
|
|
1801
1861
|
return [{
|
|
@@ -1804,13 +1864,13 @@ var yr = (e) => {
|
|
|
1804
1864
|
"tableCell",
|
|
1805
1865
|
"tableHeader"
|
|
1806
1866
|
],
|
|
1807
|
-
attributes: { textColor:
|
|
1867
|
+
attributes: { textColor: i() }
|
|
1808
1868
|
}];
|
|
1809
1869
|
}
|
|
1810
|
-
}),
|
|
1870
|
+
}), Ur = "aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2";
|
|
1811
1871
|
//#endregion
|
|
1812
1872
|
//#region src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts
|
|
1813
|
-
function
|
|
1873
|
+
function Wr(e) {
|
|
1814
1874
|
let t = [], n = [], r = 0;
|
|
1815
1875
|
for (; r < e.length;) {
|
|
1816
1876
|
let i = 0;
|
|
@@ -1824,59 +1884,59 @@ function Nr(e) {
|
|
|
1824
1884
|
}
|
|
1825
1885
|
return t;
|
|
1826
1886
|
}
|
|
1827
|
-
var
|
|
1828
|
-
function
|
|
1887
|
+
var Gr = new Set(Wr(Ur)), Kr = /* @__PURE__ */ new Set(["localhost"]), qr = /[.,;:!?"']+$/, Jr = /(?:https?|ftp|ftps):\/\/[^\s]+/g, Yr = /mailto:[^\s]+/g, Xr = /[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}/g, Zr = /(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(?::\d{1,5})?(?:[/?#][^\s]*)?/g;
|
|
1888
|
+
function Qr(e) {
|
|
1829
1889
|
let t = e, n = !0;
|
|
1830
1890
|
for (; n;) {
|
|
1831
1891
|
n = !1;
|
|
1832
1892
|
let e = t;
|
|
1833
|
-
t = t.replace(
|
|
1893
|
+
t = t.replace(qr, ""), t !== e && (n = !0);
|
|
1834
1894
|
for (let [e, r] of [["(", ")"], ["[", "]"]]) for (; t.endsWith(r);) {
|
|
1835
|
-
let i =
|
|
1836
|
-
if (
|
|
1895
|
+
let i = $r(t, e);
|
|
1896
|
+
if ($r(t, r) > i) t = t.slice(0, -1), n = !0;
|
|
1837
1897
|
else break;
|
|
1838
1898
|
}
|
|
1839
1899
|
}
|
|
1840
1900
|
return t;
|
|
1841
1901
|
}
|
|
1842
|
-
function
|
|
1902
|
+
function $r(e, t) {
|
|
1843
1903
|
let n = 0;
|
|
1844
1904
|
for (let r = 0; r < e.length; r++) e[r] === t && n++;
|
|
1845
1905
|
return n;
|
|
1846
1906
|
}
|
|
1847
|
-
function
|
|
1907
|
+
function ei(e) {
|
|
1848
1908
|
let t = e.split(".");
|
|
1849
1909
|
return t[t.length - 1].toLowerCase();
|
|
1850
1910
|
}
|
|
1851
|
-
function
|
|
1852
|
-
let t =
|
|
1853
|
-
return
|
|
1911
|
+
function ti(e) {
|
|
1912
|
+
let t = ei(e);
|
|
1913
|
+
return Gr.has(t);
|
|
1854
1914
|
}
|
|
1855
|
-
function
|
|
1915
|
+
function ni(e, t, n) {
|
|
1856
1916
|
return t === "email" ? "mailto:" + e : /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(e) || /^mailto:/i.test(e) ? e : n + "://" + e;
|
|
1857
1917
|
}
|
|
1858
|
-
function
|
|
1918
|
+
function ri(e, t) {
|
|
1859
1919
|
if (!e) return [];
|
|
1860
1920
|
let n = t?.defaultProtocol || "http", r = [];
|
|
1861
|
-
for (let t of e.matchAll(
|
|
1921
|
+
for (let t of e.matchAll(Jr)) r.push({
|
|
1862
1922
|
type: "url",
|
|
1863
1923
|
value: t[0],
|
|
1864
1924
|
start: t.index,
|
|
1865
1925
|
end: t.index + t[0].length
|
|
1866
1926
|
});
|
|
1867
|
-
for (let t of e.matchAll(
|
|
1927
|
+
for (let t of e.matchAll(Yr)) r.push({
|
|
1868
1928
|
type: "url",
|
|
1869
1929
|
value: t[0],
|
|
1870
1930
|
start: t.index,
|
|
1871
1931
|
end: t.index + t[0].length
|
|
1872
1932
|
});
|
|
1873
|
-
for (let t of e.matchAll(
|
|
1933
|
+
for (let t of e.matchAll(Xr)) r.push({
|
|
1874
1934
|
type: "email",
|
|
1875
1935
|
value: t[0],
|
|
1876
1936
|
start: t.index,
|
|
1877
1937
|
end: t.index + t[0].length
|
|
1878
1938
|
});
|
|
1879
|
-
for (let t of e.matchAll(
|
|
1939
|
+
for (let t of e.matchAll(Zr)) r.push({
|
|
1880
1940
|
type: "url",
|
|
1881
1941
|
value: t[0],
|
|
1882
1942
|
start: t.index,
|
|
@@ -1887,18 +1947,18 @@ function Kr(e, t) {
|
|
|
1887
1947
|
for (let e of r) e.start >= a && (i.push(e), a = e.end);
|
|
1888
1948
|
let o = [];
|
|
1889
1949
|
for (let e of i) {
|
|
1890
|
-
let t =
|
|
1950
|
+
let t = Qr(e.value);
|
|
1891
1951
|
if (!t) continue;
|
|
1892
1952
|
let r = e.start, i = r + t.length;
|
|
1893
1953
|
if (e.type === "url" && !/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t)) {
|
|
1894
1954
|
let e = new URL("http://" + t).hostname;
|
|
1895
|
-
if (!
|
|
1955
|
+
if (!ti(e)) continue;
|
|
1896
1956
|
}
|
|
1897
1957
|
if (e.type === "email") {
|
|
1898
1958
|
let e = t.split("@")[1];
|
|
1899
|
-
if (!
|
|
1959
|
+
if (!ti(e)) continue;
|
|
1900
1960
|
}
|
|
1901
|
-
let a =
|
|
1961
|
+
let a = ni(t, e.type, n);
|
|
1902
1962
|
o.push({
|
|
1903
1963
|
type: e.type,
|
|
1904
1964
|
value: t,
|
|
@@ -1910,7 +1970,7 @@ function Kr(e, t) {
|
|
|
1910
1970
|
}
|
|
1911
1971
|
return o;
|
|
1912
1972
|
}
|
|
1913
|
-
function
|
|
1973
|
+
function ii(e, t = "http") {
|
|
1914
1974
|
if (!e) return [$(e, 0, 0)];
|
|
1915
1975
|
for (let [n, r] of [
|
|
1916
1976
|
["(", ")"],
|
|
@@ -1918,34 +1978,34 @@ function qr(e, t = "http") {
|
|
|
1918
1978
|
["{", "}"]
|
|
1919
1979
|
]) if (e.startsWith(n) && e.endsWith(r) && e.length > 2) {
|
|
1920
1980
|
let i = e.slice(1, -1);
|
|
1921
|
-
if (
|
|
1981
|
+
if (ai(i)) return [
|
|
1922
1982
|
$(n, 0, 1),
|
|
1923
|
-
|
|
1983
|
+
oi(i, 1, 1 + i.length, t),
|
|
1924
1984
|
$(r, 1 + i.length, e.length)
|
|
1925
1985
|
];
|
|
1926
1986
|
}
|
|
1927
1987
|
if (e.endsWith(".") && e.length > 1) {
|
|
1928
1988
|
let n = e.slice(0, -1);
|
|
1929
|
-
if (
|
|
1989
|
+
if (ai(n)) return [oi(n, 0, n.length, t), $(".", n.length, e.length)];
|
|
1930
1990
|
}
|
|
1931
|
-
return
|
|
1991
|
+
return ai(e) ? [oi(e, 0, e.length, t)] : [$(e, 0, e.length)];
|
|
1932
1992
|
}
|
|
1933
|
-
function
|
|
1934
|
-
if (/^(?:https?|ftp|ftps):\/\/[^\s]+$/.test(e) || /^mailto:[^\s]+$/.test(e) ||
|
|
1993
|
+
function ai(e) {
|
|
1994
|
+
if (/^(?:https?|ftp|ftps):\/\/[^\s]+$/.test(e) || /^mailto:[^\s]+$/.test(e) || Kr.has(e.toLowerCase())) return !0;
|
|
1935
1995
|
let t = e.match(/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+([a-zA-Z]{2,})(?::\d{1,5})?(?:[/?#][^\s]*)?$/);
|
|
1936
1996
|
if (t) {
|
|
1937
1997
|
let e = t[1].toLowerCase();
|
|
1938
|
-
if (
|
|
1998
|
+
if (Gr.has(e)) return !0;
|
|
1939
1999
|
}
|
|
1940
2000
|
return !1;
|
|
1941
2001
|
}
|
|
1942
|
-
function
|
|
2002
|
+
function oi(e, t, n, r) {
|
|
1943
2003
|
let i = e.includes("@") && !e.includes("://") && !e.startsWith("mailto:") ? "email" : "url";
|
|
1944
2004
|
return {
|
|
1945
2005
|
type: i,
|
|
1946
2006
|
value: e,
|
|
1947
2007
|
isLink: !0,
|
|
1948
|
-
href:
|
|
2008
|
+
href: ni(e, i, r),
|
|
1949
2009
|
start: t,
|
|
1950
2010
|
end: n
|
|
1951
2011
|
};
|
|
@@ -1962,40 +2022,40 @@ function $(e, t, n) {
|
|
|
1962
2022
|
}
|
|
1963
2023
|
//#endregion
|
|
1964
2024
|
//#region src/extensions/tiptap-extensions/Link/helpers/whitespace.ts
|
|
1965
|
-
var
|
|
2025
|
+
var si = "[\0- \xA0 -\u2029 ]", ci = new RegExp(si), li = RegExp(`${si}$`), ui = new RegExp(si, "g");
|
|
1966
2026
|
//#endregion
|
|
1967
2027
|
//#region src/extensions/tiptap-extensions/Link/helpers/autolink.ts
|
|
1968
|
-
function
|
|
2028
|
+
function di(e) {
|
|
1969
2029
|
return e.length === 1 ? e[0].isLink : e.length === 3 && e[1].isLink ? ["()", "[]"].includes(e[0].value + e[2].value) : !1;
|
|
1970
2030
|
}
|
|
1971
|
-
function
|
|
1972
|
-
return new
|
|
1973
|
-
key: new
|
|
2031
|
+
function fi(e) {
|
|
2032
|
+
return new st({
|
|
2033
|
+
key: new ct("autolink"),
|
|
1974
2034
|
appendTransaction: (t, n, r) => {
|
|
1975
2035
|
let i = t.some((e) => e.docChanged) && !n.doc.eq(r.doc), a = t.some((e) => e.getMeta("preventAutolink"));
|
|
1976
2036
|
if (!i || a) return;
|
|
1977
|
-
let { tr: o } = r;
|
|
1978
|
-
if (
|
|
1979
|
-
let n =
|
|
2037
|
+
let { tr: o } = r, s = Ge(n.doc, [...t]);
|
|
2038
|
+
if (Xe(s).forEach(({ newRange: t }) => {
|
|
2039
|
+
let n = qe(r.doc, t, (e) => e.isTextblock), i, a;
|
|
1980
2040
|
if (n.length > 1) i = n[0], a = r.doc.textBetween(i.pos, i.pos + i.node.nodeSize, void 0, " ");
|
|
1981
2041
|
else if (n.length) {
|
|
1982
2042
|
let e = r.doc.textBetween(t.from, t.to, " ", " ");
|
|
1983
|
-
if (!
|
|
2043
|
+
if (!li.test(e)) return;
|
|
1984
2044
|
i = n[0], a = r.doc.textBetween(i.pos, t.to, void 0, " ");
|
|
1985
2045
|
}
|
|
1986
2046
|
if (i && a) {
|
|
1987
|
-
let t = a.split(
|
|
2047
|
+
let t = a.split(ci).filter(Boolean);
|
|
1988
2048
|
if (t.length <= 0) return;
|
|
1989
2049
|
let n = t[t.length - 1], s = i.pos + a.lastIndexOf(n);
|
|
1990
2050
|
if (!n) return;
|
|
1991
|
-
let c =
|
|
1992
|
-
if (
|
|
2051
|
+
let c = ii(n, e.defaultProtocol);
|
|
2052
|
+
if (!di(c)) return;
|
|
1993
2053
|
c.filter((e) => e.isLink).map((e) => ({
|
|
1994
2054
|
...e,
|
|
1995
2055
|
from: s + e.start + 1,
|
|
1996
2056
|
to: s + e.end + 1
|
|
1997
|
-
})).filter((e) => r.schema.marks.code
|
|
1998
|
-
|
|
2057
|
+
})).filter((e) => !r.schema.marks.code || !r.doc.rangeHasMark(e.from, e.to, r.schema.marks.code)).filter((t) => e.validate(t.value)).filter((t) => e.shouldAutoLink(t.value)).forEach((t) => {
|
|
2058
|
+
Qe(t.from, t.to, r.doc).some((t) => t.mark.type === e.type) || o.addMark(t.from, t.to, e.type.create({ href: t.href }));
|
|
1999
2059
|
});
|
|
2000
2060
|
}
|
|
2001
2061
|
}), o.steps.length) return o;
|
|
@@ -2004,9 +2064,9 @@ function ei(e) {
|
|
|
2004
2064
|
}
|
|
2005
2065
|
//#endregion
|
|
2006
2066
|
//#region src/extensions/tiptap-extensions/Link/helpers/clickHandler.ts
|
|
2007
|
-
function
|
|
2008
|
-
return new
|
|
2009
|
-
key: new
|
|
2067
|
+
function pi(e) {
|
|
2068
|
+
return new st({
|
|
2069
|
+
key: new ct("handleClickLink"),
|
|
2010
2070
|
props: { handleClick: (t, n, r) => {
|
|
2011
2071
|
if (r.button !== 0 || !t.editable) return !1;
|
|
2012
2072
|
let i = null;
|
|
@@ -2022,16 +2082,16 @@ function ti(e) {
|
|
|
2022
2082
|
if (!e.editor) throw Error("BlockNoteEditor not found in Link click handler");
|
|
2023
2083
|
return e.onClick(r, e.editor) ?? !0;
|
|
2024
2084
|
}
|
|
2025
|
-
let a =
|
|
2085
|
+
let a = Ye(t.state, e.type.name), o = i.href ?? a.href, s = i.target ?? a.target;
|
|
2026
2086
|
return o ? (window.open(o, s), !0) : !1;
|
|
2027
2087
|
} }
|
|
2028
2088
|
});
|
|
2029
2089
|
}
|
|
2030
2090
|
//#endregion
|
|
2031
2091
|
//#region src/extensions/tiptap-extensions/Link/helpers/pasteHandler.ts
|
|
2032
|
-
function
|
|
2033
|
-
return new
|
|
2034
|
-
key: new
|
|
2092
|
+
function mi(e) {
|
|
2093
|
+
return new st({
|
|
2094
|
+
key: new ct("handlePasteLink"),
|
|
2035
2095
|
props: { handlePaste: (t, n, r) => {
|
|
2036
2096
|
let { shouldAutoLink: i, isValidLink: a } = e, { state: o } = t, { selection: s } = o, { empty: c } = s;
|
|
2037
2097
|
if (c) return !1;
|
|
@@ -2039,26 +2099,26 @@ function ni(e) {
|
|
|
2039
2099
|
r.content.forEach((e) => {
|
|
2040
2100
|
l += e.textContent;
|
|
2041
2101
|
});
|
|
2042
|
-
let u =
|
|
2102
|
+
let u = ri(l, { defaultProtocol: e.defaultProtocol }).find((e) => e.isLink && e.value === l);
|
|
2043
2103
|
return !l || !u || !a(u.value) || i !== void 0 && !i(u.value) ? !1 : e.editor.commands.setMark(e.type, { href: u.href });
|
|
2044
2104
|
} }
|
|
2045
2105
|
});
|
|
2046
2106
|
}
|
|
2047
2107
|
//#endregion
|
|
2048
2108
|
//#region src/extensions/tiptap-extensions/Link/link.ts
|
|
2049
|
-
var
|
|
2050
|
-
function
|
|
2109
|
+
var hi = "https", gi = /^(?:(?:http|https|ftp|ftps|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z0-9+.\-]+(?:[^a-z+.\-:]|$))/i;
|
|
2110
|
+
function _i(e) {
|
|
2051
2111
|
if (!e) return !0;
|
|
2052
|
-
let t = e.replace(
|
|
2053
|
-
return
|
|
2112
|
+
let t = e.replace(ui, "");
|
|
2113
|
+
return gi.test(t);
|
|
2054
2114
|
}
|
|
2055
|
-
function
|
|
2115
|
+
function vi(e) {
|
|
2056
2116
|
let t = /^[a-z][a-z0-9+.-]*:\/\//i.test(e), n = /^[a-z][a-z0-9+.-]*:/i.test(e);
|
|
2057
2117
|
if (t || n && !e.includes("@")) return !0;
|
|
2058
2118
|
let r = (e.includes("@") ? e.split("@").pop() : e).split(/[/?#:]/)[0];
|
|
2059
2119
|
return !(/^\d{1,3}(\.\d{1,3}){3}$/.test(r) || !/\./.test(r));
|
|
2060
2120
|
}
|
|
2061
|
-
var
|
|
2121
|
+
var yi = We.create({
|
|
2062
2122
|
name: "link",
|
|
2063
2123
|
keepOnSplit: !1,
|
|
2064
2124
|
exitable: !0,
|
|
@@ -2073,7 +2133,7 @@ var si = Ve.create({
|
|
|
2073
2133
|
},
|
|
2074
2134
|
editor: void 0,
|
|
2075
2135
|
onClick: void 0,
|
|
2076
|
-
isValidLink:
|
|
2136
|
+
isValidLink: _i
|
|
2077
2137
|
};
|
|
2078
2138
|
},
|
|
2079
2139
|
addAttributes() {
|
|
@@ -2097,11 +2157,11 @@ var si = Ve.create({
|
|
|
2097
2157
|
renderHTML({ HTMLAttributes: e }) {
|
|
2098
2158
|
return this.options.isValidLink(e.href) ? [
|
|
2099
2159
|
"a",
|
|
2100
|
-
|
|
2160
|
+
M(e, this.options.HTMLAttributes),
|
|
2101
2161
|
0
|
|
2102
2162
|
] : [
|
|
2103
2163
|
"a",
|
|
2104
|
-
|
|
2164
|
+
M({
|
|
2105
2165
|
...e,
|
|
2106
2166
|
href: ""
|
|
2107
2167
|
}, this.options.HTMLAttributes),
|
|
@@ -2110,12 +2170,12 @@ var si = Ve.create({
|
|
|
2110
2170
|
},
|
|
2111
2171
|
addPasteRules() {
|
|
2112
2172
|
let e = this.options.isValidLink;
|
|
2113
|
-
return [
|
|
2173
|
+
return [tt({
|
|
2114
2174
|
find: (t) => {
|
|
2115
2175
|
let n = [];
|
|
2116
2176
|
if (t) {
|
|
2117
|
-
let r =
|
|
2118
|
-
for (let e of r)
|
|
2177
|
+
let r = ri(t, { defaultProtocol: hi }).filter((t) => t.isLink && e(t.value));
|
|
2178
|
+
for (let e of r) vi(e.value) && n.push({
|
|
2119
2179
|
text: e.value,
|
|
2120
2180
|
data: { href: e.href },
|
|
2121
2181
|
index: e.start
|
|
@@ -2129,46 +2189,46 @@ var si = Ve.create({
|
|
|
2129
2189
|
},
|
|
2130
2190
|
addProseMirrorPlugins() {
|
|
2131
2191
|
let e = [];
|
|
2132
|
-
return e.push(
|
|
2192
|
+
return e.push(fi({
|
|
2133
2193
|
type: this.type,
|
|
2134
|
-
defaultProtocol:
|
|
2194
|
+
defaultProtocol: hi,
|
|
2135
2195
|
validate: this.options.isValidLink,
|
|
2136
|
-
shouldAutoLink:
|
|
2137
|
-
})), e.push(
|
|
2196
|
+
shouldAutoLink: vi
|
|
2197
|
+
})), e.push(pi({
|
|
2138
2198
|
type: this.type,
|
|
2139
2199
|
tiptapEditor: this.editor,
|
|
2140
2200
|
editor: this.options.editor,
|
|
2141
2201
|
onClick: this.options.onClick
|
|
2142
|
-
})), e.push(
|
|
2202
|
+
})), e.push(mi({
|
|
2143
2203
|
editor: this.editor,
|
|
2144
|
-
defaultProtocol:
|
|
2204
|
+
defaultProtocol: hi,
|
|
2145
2205
|
type: this.type,
|
|
2146
|
-
shouldAutoLink:
|
|
2206
|
+
shouldAutoLink: vi,
|
|
2147
2207
|
isValidLink: this.options.isValidLink
|
|
2148
2208
|
})), e;
|
|
2149
2209
|
}
|
|
2150
|
-
}),
|
|
2210
|
+
}), bi = he(({ editor: e, options: t }) => ({
|
|
2151
2211
|
key: "link",
|
|
2152
|
-
tiptapExtensions: [
|
|
2212
|
+
tiptapExtensions: [yi.configure({
|
|
2153
2213
|
HTMLAttributes: t.HTMLAttributes ?? {},
|
|
2154
2214
|
editor: e,
|
|
2155
2215
|
onClick: t.onClick,
|
|
2156
2216
|
...t.isValidLink ? { isValidLink: t.isValidLink } : {}
|
|
2157
2217
|
})]
|
|
2158
|
-
})),
|
|
2218
|
+
})), xi = {
|
|
2159
2219
|
blockColor: "data-block-color",
|
|
2160
2220
|
blockStyle: "data-block-style",
|
|
2161
2221
|
id: "data-id",
|
|
2162
2222
|
depth: "data-depth",
|
|
2163
2223
|
depthChange: "data-depth-change"
|
|
2164
|
-
},
|
|
2224
|
+
}, Si = A.create({
|
|
2165
2225
|
name: "blockContainer",
|
|
2166
2226
|
group: "blockGroupChild bnBlock",
|
|
2167
2227
|
content: "blockContent blockGroup?",
|
|
2168
2228
|
priority: 50,
|
|
2169
2229
|
defining: !0,
|
|
2170
2230
|
marks() {
|
|
2171
|
-
return
|
|
2231
|
+
return b(this.editor);
|
|
2172
2232
|
},
|
|
2173
2233
|
parseHTML() {
|
|
2174
2234
|
return [{
|
|
@@ -2176,7 +2236,7 @@ var si = Ve.create({
|
|
|
2176
2236
|
getAttrs: (e) => {
|
|
2177
2237
|
if (typeof e == "string") return !1;
|
|
2178
2238
|
let t = {};
|
|
2179
|
-
for (let [n, r] of Object.entries(
|
|
2239
|
+
for (let [n, r] of Object.entries(xi)) e.getAttribute(r) && (t[n] = e.getAttribute(r));
|
|
2180
2240
|
return t;
|
|
2181
2241
|
}
|
|
2182
2242
|
}, {
|
|
@@ -2192,24 +2252,24 @@ var si = Ve.create({
|
|
|
2192
2252
|
...this.options.domAttributes?.block || {},
|
|
2193
2253
|
...e
|
|
2194
2254
|
}, r = document.createElement("div");
|
|
2195
|
-
r.className =
|
|
2255
|
+
r.className = s("bn-block", n.class), r.setAttribute("data-node-type", this.name);
|
|
2196
2256
|
for (let [e, t] of Object.entries(n)) e !== "class" && r.setAttribute(e, t);
|
|
2197
2257
|
return t.appendChild(r), {
|
|
2198
2258
|
dom: t,
|
|
2199
2259
|
contentDOM: r
|
|
2200
2260
|
};
|
|
2201
2261
|
}
|
|
2202
|
-
}),
|
|
2262
|
+
}), Ci = A.create({
|
|
2203
2263
|
name: "blockGroup",
|
|
2204
2264
|
group: "childContainer",
|
|
2205
2265
|
content: "blockGroupChild+",
|
|
2206
2266
|
marks() {
|
|
2207
|
-
return
|
|
2267
|
+
return b(this.editor);
|
|
2208
2268
|
},
|
|
2209
2269
|
parseHTML() {
|
|
2210
2270
|
return [{
|
|
2211
2271
|
tag: "div",
|
|
2212
|
-
getAttrs: (e) => typeof e
|
|
2272
|
+
getAttrs: (e) => typeof e != "string" && e.getAttribute("data-node-type") === "blockGroup" && null
|
|
2213
2273
|
}];
|
|
2214
2274
|
},
|
|
2215
2275
|
renderHTML({ HTMLAttributes: e }) {
|
|
@@ -2217,96 +2277,99 @@ var si = Ve.create({
|
|
|
2217
2277
|
...this.options.domAttributes?.blockGroup || {},
|
|
2218
2278
|
...e
|
|
2219
2279
|
}, n = document.createElement("div");
|
|
2220
|
-
n.className =
|
|
2280
|
+
n.className = s("bn-block-group", t.class), n.setAttribute("data-node-type", "blockGroup");
|
|
2221
2281
|
for (let [e, r] of Object.entries(t)) e !== "class" && n.setAttribute(e, r);
|
|
2222
2282
|
return {
|
|
2223
2283
|
dom: n,
|
|
2224
2284
|
contentDOM: n
|
|
2225
2285
|
};
|
|
2226
2286
|
}
|
|
2227
|
-
}),
|
|
2287
|
+
}), wi = A.create({
|
|
2228
2288
|
name: "doc",
|
|
2229
2289
|
topNode: !0,
|
|
2230
2290
|
content: "blockGroup",
|
|
2231
2291
|
marks() {
|
|
2232
|
-
return
|
|
2292
|
+
return b(this.editor);
|
|
2233
2293
|
}
|
|
2234
2294
|
});
|
|
2235
2295
|
//#endregion
|
|
2236
2296
|
//#region src/editor/managers/ExtensionManager/extensions.ts
|
|
2237
|
-
function
|
|
2297
|
+
function Ti(t, n) {
|
|
2238
2298
|
return [
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2299
|
+
j.ClipboardTextSerializer,
|
|
2300
|
+
j.Commands,
|
|
2301
|
+
j.Editable,
|
|
2302
|
+
j.FocusEvents,
|
|
2303
|
+
j.Tabindex,
|
|
2304
|
+
mt,
|
|
2305
|
+
e.configure({
|
|
2246
2306
|
types: [
|
|
2247
2307
|
"blockContainer",
|
|
2248
2308
|
"columnList",
|
|
2249
2309
|
"column"
|
|
2250
2310
|
],
|
|
2251
|
-
setIdAttribute:
|
|
2252
|
-
isWithinEditor:
|
|
2311
|
+
setIdAttribute: n.setIdAttribute,
|
|
2312
|
+
isWithinEditor: t.isWithinEditor
|
|
2253
2313
|
}),
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
...Object.values(
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2314
|
+
Pr,
|
|
2315
|
+
pt,
|
|
2316
|
+
...Object.values(t.schema.styleSpecs).map((e) => e.implementation.mark.configure({ editor: t })),
|
|
2317
|
+
Hr,
|
|
2318
|
+
Nr,
|
|
2319
|
+
Vr,
|
|
2320
|
+
k.create({
|
|
2261
2321
|
name: "OverrideEscape",
|
|
2262
|
-
addKeyboardShortcuts: () => ({ Escape: () =>
|
|
2322
|
+
addKeyboardShortcuts: () => ({ Escape: () => !t.getExtension(ie)?.shown() && (t.blur(), !0) })
|
|
2263
2323
|
}),
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
editor:
|
|
2267
|
-
domAttributes:
|
|
2324
|
+
wi,
|
|
2325
|
+
Si.configure({
|
|
2326
|
+
editor: t,
|
|
2327
|
+
domAttributes: n.domAttributes
|
|
2268
2328
|
}),
|
|
2269
|
-
|
|
2270
|
-
editor:
|
|
2271
|
-
tabBehavior:
|
|
2329
|
+
Br.configure({
|
|
2330
|
+
editor: t,
|
|
2331
|
+
tabBehavior: n.tabBehavior
|
|
2272
2332
|
}),
|
|
2273
|
-
|
|
2274
|
-
...Object.values(
|
|
2275
|
-
...Object.values(
|
|
2276
|
-
editor:
|
|
2277
|
-
domAttributes:
|
|
2333
|
+
Ci.configure({ domAttributes: n.domAttributes }),
|
|
2334
|
+
...Object.values(t.schema.inlineContentSpecs).filter((e) => e.config !== "link" && e.config !== "text").map((e) => e.implementation.node.configure({ editor: t })),
|
|
2335
|
+
...Object.values(t.schema.blockSpecs).flatMap((e) => [..."node" in e.implementation ? [e.implementation.node.configure({
|
|
2336
|
+
editor: t,
|
|
2337
|
+
domAttributes: n.domAttributes
|
|
2278
2338
|
})] : []]),
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2339
|
+
Mr(t),
|
|
2340
|
+
Dr(t, n.pasteHandler || ((e) => e.defaultPasteHandler())),
|
|
2341
|
+
ur(t)
|
|
2282
2342
|
];
|
|
2283
2343
|
}
|
|
2284
|
-
function
|
|
2344
|
+
function Ei(e, t) {
|
|
2285
2345
|
let n = [
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2346
|
+
be(),
|
|
2347
|
+
ye(t),
|
|
2348
|
+
fe(t),
|
|
2349
|
+
x(t),
|
|
2350
|
+
bi({
|
|
2291
2351
|
HTMLAttributes: t.links?.HTMLAttributes ?? {},
|
|
2292
2352
|
onClick: t.links?.onClick,
|
|
2293
2353
|
...t.links?.isValidLink ? { isValidLink: t.links.isValidLink } : {}
|
|
2294
2354
|
}),
|
|
2295
|
-
ke(t),
|
|
2296
|
-
Ae(),
|
|
2297
2355
|
xe(t),
|
|
2356
|
+
we(),
|
|
2298
2357
|
Me(t),
|
|
2299
|
-
|
|
2358
|
+
Fe(t),
|
|
2359
|
+
De(t),
|
|
2360
|
+
Oe(),
|
|
2361
|
+
Ae(),
|
|
2300
2362
|
ie(t),
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2363
|
+
ge(),
|
|
2364
|
+
ke(),
|
|
2365
|
+
_e(),
|
|
2366
|
+
...t.trailingBlock === !1 ? [] : [je()]
|
|
2304
2367
|
];
|
|
2305
|
-
return "table" in e.schema.blockSpecs && n.push(
|
|
2368
|
+
return "table" in e.schema.blockSpecs && n.push(Ee(t)), t.animations !== !1 && n.push(Ce()), n;
|
|
2306
2369
|
}
|
|
2307
2370
|
//#endregion
|
|
2308
2371
|
//#region src/editor/managers/ExtensionManager/index.ts
|
|
2309
|
-
var
|
|
2372
|
+
var Di = class {
|
|
2310
2373
|
editor;
|
|
2311
2374
|
options;
|
|
2312
2375
|
disabledExtensions = /* @__PURE__ */ new Set();
|
|
@@ -2330,7 +2393,7 @@ var hi = class {
|
|
|
2330
2393
|
}), e.onUnmount(() => {
|
|
2331
2394
|
for (let [e, t] of this.abortMap.entries()) this.abortMap.delete(e), t.abort();
|
|
2332
2395
|
}), this.disabledExtensions = new Set(t.disableExtensions || []);
|
|
2333
|
-
for (let e of
|
|
2396
|
+
for (let e of Ei(this.editor, this.options)) this.addExtension(e);
|
|
2334
2397
|
for (let e of this.options.extensions ?? []) this.addExtension(e);
|
|
2335
2398
|
for (let e of Object.values(this.editor.schema.blockSpecs)) for (let t of e.extensions ?? []) this.addExtension(t);
|
|
2336
2399
|
}
|
|
@@ -2399,7 +2462,7 @@ var hi = class {
|
|
|
2399
2462
|
this.editor.prosemirrorView.updateState(n);
|
|
2400
2463
|
}
|
|
2401
2464
|
getTiptapExtensions() {
|
|
2402
|
-
let e =
|
|
2465
|
+
let e = Ti(this.editor, this.options).filter((e) => !this.disabledExtensions.has(e.name)), t = ee(this.extensions.map((e) => {
|
|
2403
2466
|
let t = this.blockNoteExtensionDependents.get(e.key);
|
|
2404
2467
|
return t?.size ? {
|
|
2405
2468
|
key: e.key,
|
|
@@ -2409,21 +2472,21 @@ var hi = class {
|
|
|
2409
2472
|
for (let r of this.extensions) {
|
|
2410
2473
|
r.tiptapExtensions && e.push(...r.tiptapExtensions);
|
|
2411
2474
|
let i = t(r.key), { plugins: a, inputRules: o } = this.getProsemirrorPluginsFromExtension(r);
|
|
2412
|
-
a.length && e.push(
|
|
2475
|
+
a.length && e.push(k.create({
|
|
2413
2476
|
name: r.key,
|
|
2414
2477
|
priority: i,
|
|
2415
2478
|
addProseMirrorPlugins: () => a
|
|
2416
2479
|
})), o.length && (n.has(i) || n.set(i, []), n.get(i).push(...o));
|
|
2417
2480
|
}
|
|
2418
|
-
e.push(
|
|
2481
|
+
e.push(k.create({
|
|
2419
2482
|
name: "blocknote-input-rules",
|
|
2420
2483
|
addProseMirrorPlugins() {
|
|
2421
2484
|
let e = [];
|
|
2422
2485
|
Array.from(n.keys()).sort((e, t) => e - t).reverse().forEach((t) => {
|
|
2423
2486
|
e.push(...n.get(t));
|
|
2424
2487
|
});
|
|
2425
|
-
let t =
|
|
2426
|
-
return [t, new
|
|
2488
|
+
let t = dt({ rules: e });
|
|
2489
|
+
return [t, new P({ props: { handleKeyDown(e, n) {
|
|
2427
2490
|
if (n.key !== "Enter" || n.shiftKey || n.ctrlKey || n.metaKey || n.altKey) return !1;
|
|
2428
2491
|
let { $cursor: r } = e.state.selection;
|
|
2429
2492
|
return r ? !!t.props.handleTextInput?.call(t, e, r.pos, r.pos, "\n", () => e.state.tr.insertText("\n", r.pos, r.pos)) : !1;
|
|
@@ -2433,28 +2496,28 @@ var hi = class {
|
|
|
2433
2496
|
for (let t of this.options._tiptapOptions?.extensions ?? []) e.push(t);
|
|
2434
2497
|
return e;
|
|
2435
2498
|
}
|
|
2436
|
-
getProsemirrorPluginsFromExtension(
|
|
2437
|
-
let
|
|
2438
|
-
return !
|
|
2439
|
-
plugins:
|
|
2440
|
-
inputRules:
|
|
2441
|
-
} : (this.extensionPlugins.set(
|
|
2442
|
-
let
|
|
2443
|
-
match:
|
|
2499
|
+
getProsemirrorPluginsFromExtension(e) {
|
|
2500
|
+
let t = [...e.prosemirrorPlugins ?? []], n = [];
|
|
2501
|
+
return !e.prosemirrorPlugins?.length && !Object.keys(e.keyboardShortcuts || {}).length && !e.inputRules?.length ? {
|
|
2502
|
+
plugins: t,
|
|
2503
|
+
inputRules: n
|
|
2504
|
+
} : (this.extensionPlugins.set(e, t), e.inputRules?.length && n.push(...e.inputRules.map((e) => new ut(e.find, (t, n, r, i) => {
|
|
2505
|
+
let a = e.replace({
|
|
2506
|
+
match: n,
|
|
2444
2507
|
range: {
|
|
2445
|
-
from:
|
|
2446
|
-
to:
|
|
2508
|
+
from: r,
|
|
2509
|
+
to: i
|
|
2447
2510
|
},
|
|
2448
2511
|
editor: this.editor
|
|
2449
2512
|
});
|
|
2450
|
-
if (
|
|
2451
|
-
let
|
|
2452
|
-
return !
|
|
2513
|
+
if (a) {
|
|
2514
|
+
let e = t.tr, n = w(e);
|
|
2515
|
+
return !n.isBlockContainer || this.editor.schema.blockSchema[n.blockNoteType]?.content !== "inline" ? null : (e.deleteRange(r, i), f(e, n.bnBlock.beforePos, a), ar(e, C(n.bnBlock.node, e.doc), "start"), e);
|
|
2453
2516
|
}
|
|
2454
2517
|
return null;
|
|
2455
|
-
}, { undoable: !0 }))), Object.keys(
|
|
2456
|
-
plugins:
|
|
2457
|
-
inputRules:
|
|
2518
|
+
}, { undoable: !0 }))), Object.keys(e.keyboardShortcuts || {}).length && t.push(ft(Object.fromEntries(Object.entries(e.keyboardShortcuts).map(([e, t]) => [e, () => t({ editor: this.editor })])))), {
|
|
2519
|
+
plugins: t,
|
|
2520
|
+
inputRules: n
|
|
2458
2521
|
});
|
|
2459
2522
|
}
|
|
2460
2523
|
getExtensions() {
|
|
@@ -2466,12 +2529,12 @@ var hi = class {
|
|
|
2466
2529
|
throw Error(`Invalid extension type: ${typeof e}`);
|
|
2467
2530
|
}
|
|
2468
2531
|
hasExtension(e) {
|
|
2469
|
-
return typeof e == "string" ? this.extensions.some((t) => t.key === e) : typeof e == "object" && "key" in e ? this.extensions.some((t) => t.key === e.key) : typeof e == "function"
|
|
2532
|
+
return typeof e == "string" ? this.extensions.some((t) => t.key === e) : typeof e == "object" && "key" in e ? this.extensions.some((t) => t.key === e.key) : typeof e == "function" && this.extensionFactories.has(e);
|
|
2470
2533
|
}
|
|
2471
2534
|
};
|
|
2472
2535
|
//#endregion
|
|
2473
2536
|
//#region src/util/expandToWords.ts
|
|
2474
|
-
function
|
|
2537
|
+
function Oi(e, t) {
|
|
2475
2538
|
let { $from: n, $to: r } = t;
|
|
2476
2539
|
if (n.pos > n.start() && n.pos < e.content.size) {
|
|
2477
2540
|
let t = e.textBetween(n.pos, n.pos + 1);
|
|
@@ -2496,15 +2559,15 @@ function gi(e, t) {
|
|
|
2496
2559
|
}
|
|
2497
2560
|
//#endregion
|
|
2498
2561
|
//#region src/api/blockManipulation/selections/selection.ts
|
|
2499
|
-
function
|
|
2562
|
+
function ki(e) {
|
|
2500
2563
|
if (e.selection.empty || "node" in e.selection) return;
|
|
2501
|
-
let t = e.doc.resolve(
|
|
2564
|
+
let t = e.doc.resolve(re(e.doc, e.selection.from).posBeforeNode), n = e.doc.resolve(re(e.doc, e.selection.to).posBeforeNode), r = (n, r) => {
|
|
2502
2565
|
let i = t.posAtIndex(n, r), a = e.doc.resolve(i).nodeAfter;
|
|
2503
2566
|
if (!a) throw Error(`Error getting selection - node not found at position ${i}`);
|
|
2504
|
-
return
|
|
2567
|
+
return g(a, e.doc);
|
|
2505
2568
|
}, i = [], a = t.sharedDepth(n.pos), o = t.index(a), s = n.index(a);
|
|
2506
2569
|
if (t.depth > a) {
|
|
2507
|
-
i.push(
|
|
2570
|
+
i.push(g(t.nodeAfter, e.doc));
|
|
2508
2571
|
for (let e = t.depth; e > a; e--) if (t.node(e).type.isInGroup("childContainer")) {
|
|
2509
2572
|
let n = t.index(e) + 1, a = t.node(e).childCount;
|
|
2510
2573
|
for (let t = n; t < a; t++) i.push(r(t, e));
|
|
@@ -2514,74 +2577,74 @@ function _i(e) {
|
|
|
2514
2577
|
if (i.length === 0) throw Error(`Error getting selection - selection doesn't span any blocks (${e.selection})`);
|
|
2515
2578
|
return { blocks: i };
|
|
2516
2579
|
}
|
|
2517
|
-
function
|
|
2518
|
-
let
|
|
2519
|
-
if (
|
|
2520
|
-
let
|
|
2521
|
-
if (!
|
|
2522
|
-
let
|
|
2523
|
-
if (!
|
|
2524
|
-
let
|
|
2525
|
-
if (!
|
|
2526
|
-
if (!d.isBlockContainer ||
|
|
2527
|
-
let
|
|
2580
|
+
function Ai(e, t, n) {
|
|
2581
|
+
let r = typeof t == "string" ? t : t.id, i = typeof n == "string" ? n : n.id, a = u(e), o = oe(a);
|
|
2582
|
+
if (r === i) throw Error(`Attempting to set selection with the same anchor and head blocks (id ${r})`);
|
|
2583
|
+
let s = p(r, e.doc);
|
|
2584
|
+
if (!s) throw Error(`Block with ID ${r} not found`);
|
|
2585
|
+
let c = p(i, e.doc);
|
|
2586
|
+
if (!c) throw Error(`Block with ID ${i} not found`);
|
|
2587
|
+
let l = v(s), d = v(c), f = o.blockSchema[l.blockNoteType], m = o.blockSchema[d.blockNoteType];
|
|
2588
|
+
if (!l.isBlockContainer || f.content === "none") throw Error(`Attempting to set selection anchor in block without content (id ${r})`);
|
|
2589
|
+
if (!d.isBlockContainer || m.content === "none") throw Error(`Attempting to set selection anchor in block without content (id ${i})`);
|
|
2590
|
+
let h, g;
|
|
2528
2591
|
if (f.content === "table") {
|
|
2529
|
-
let e =
|
|
2530
|
-
|
|
2531
|
-
} else
|
|
2532
|
-
if (
|
|
2533
|
-
let t =
|
|
2534
|
-
|
|
2535
|
-
} else
|
|
2536
|
-
e.setSelection(
|
|
2537
|
-
}
|
|
2538
|
-
function
|
|
2539
|
-
let
|
|
2540
|
-
for (;
|
|
2592
|
+
let e = ot.get(l.blockContent.node);
|
|
2593
|
+
h = l.blockContent.beforePos + e.positionAt(0, 0, l.blockContent.node) + 1 + 2;
|
|
2594
|
+
} else h = l.blockContent.beforePos + 1;
|
|
2595
|
+
if (m.content === "table") {
|
|
2596
|
+
let t = ot.get(d.blockContent.node), n = d.blockContent.beforePos + t.positionAt(t.height - 1, t.width - 1, d.blockContent.node) + 1;
|
|
2597
|
+
g = n + e.doc.resolve(n).nodeAfter.nodeSize - 2;
|
|
2598
|
+
} else g = d.blockContent.afterPos - 1;
|
|
2599
|
+
e.setSelection(F.create(e.doc, h, g));
|
|
2600
|
+
}
|
|
2601
|
+
function ji(e, t = !1) {
|
|
2602
|
+
let r = t ? Oi(e.doc, e.selection) : e.selection, i = r.$from, a = r.$to;
|
|
2603
|
+
for (; a.parentOffset >= a.parent.nodeSize - 2 && a.depth > 0;) a = e.doc.resolve(a.pos + 1);
|
|
2604
|
+
for (; a.parentOffset === 0 && a.depth > 0;) a = e.doc.resolve(a.pos - 1);
|
|
2541
2605
|
for (; i.parentOffset === 0 && i.depth > 0;) i = e.doc.resolve(i.pos - 1);
|
|
2542
|
-
for (;
|
|
2543
|
-
|
|
2544
|
-
let a = de(e.doc.slice(r.pos, i.pos, !0));
|
|
2606
|
+
for (; i.parentOffset >= i.parent.nodeSize - 2 && i.depth > 0;) i = e.doc.resolve(i.pos + 1);
|
|
2607
|
+
let o = n(e.doc.slice(i.pos, a.pos, !0));
|
|
2545
2608
|
return {
|
|
2546
2609
|
_meta: {
|
|
2547
|
-
startPos:
|
|
2548
|
-
endPos:
|
|
2610
|
+
startPos: i.pos,
|
|
2611
|
+
endPos: a.pos
|
|
2549
2612
|
},
|
|
2550
|
-
...
|
|
2613
|
+
...o
|
|
2551
2614
|
};
|
|
2552
2615
|
}
|
|
2553
2616
|
//#endregion
|
|
2554
2617
|
//#region src/editor/managers/SelectionManager.ts
|
|
2555
|
-
var
|
|
2618
|
+
var Mi = class {
|
|
2556
2619
|
editor;
|
|
2557
2620
|
constructor(e) {
|
|
2558
2621
|
this.editor = e;
|
|
2559
2622
|
}
|
|
2560
2623
|
getSelection() {
|
|
2561
|
-
return this.editor.transact((e) =>
|
|
2624
|
+
return this.editor.transact((e) => ki(e));
|
|
2562
2625
|
}
|
|
2563
2626
|
getSelectionCutBlocks(e = !1) {
|
|
2564
|
-
return this.editor.transact((t) =>
|
|
2627
|
+
return this.editor.transact((t) => ji(t, e));
|
|
2565
2628
|
}
|
|
2566
2629
|
setSelection(e, t) {
|
|
2567
|
-
return this.editor.transact((n) =>
|
|
2630
|
+
return this.editor.transact((n) => Ai(n, e, t));
|
|
2568
2631
|
}
|
|
2569
2632
|
getTextCursorPosition() {
|
|
2570
|
-
return this.editor.transact((e) =>
|
|
2633
|
+
return this.editor.transact((e) => ir(e));
|
|
2571
2634
|
}
|
|
2572
2635
|
setTextCursorPosition(e, t = "start") {
|
|
2573
|
-
return this.editor.transact((n) =>
|
|
2636
|
+
return this.editor.transact((n) => ar(n, e, t));
|
|
2574
2637
|
}
|
|
2575
2638
|
getSelectionBoundingBox() {
|
|
2576
2639
|
if (!this.editor.prosemirrorView) return;
|
|
2577
2640
|
let { selection: e } = this.editor.prosemirrorState, { ranges: t } = e, n = Math.min(...t.map((e) => e.$from.pos)), r = Math.max(...t.map((e) => e.$to.pos));
|
|
2578
|
-
if (
|
|
2641
|
+
if (et(e)) {
|
|
2579
2642
|
let e = this.editor.prosemirrorView.nodeDOM(n);
|
|
2580
2643
|
if (e) return e.getBoundingClientRect();
|
|
2581
2644
|
}
|
|
2582
|
-
return
|
|
2645
|
+
return nt(this.editor.prosemirrorView, n, r).toJSON();
|
|
2583
2646
|
}
|
|
2584
|
-
},
|
|
2647
|
+
}, Ni = class {
|
|
2585
2648
|
editor;
|
|
2586
2649
|
constructor(e) {
|
|
2587
2650
|
this.editor = e;
|
|
@@ -2634,7 +2697,7 @@ var bi = class {
|
|
|
2634
2697
|
if (!this.editor.headless) throw Error("no editor, but also not headless?");
|
|
2635
2698
|
return !1;
|
|
2636
2699
|
}
|
|
2637
|
-
return this.editor._tiptapEditor.isEditable === void 0
|
|
2700
|
+
return this.editor._tiptapEditor.isEditable === void 0 || this.editor._tiptapEditor.isEditable;
|
|
2638
2701
|
}
|
|
2639
2702
|
set isEditable(e) {
|
|
2640
2703
|
if (!this.editor._tiptapEditor) {
|
|
@@ -2660,7 +2723,7 @@ var bi = class {
|
|
|
2660
2723
|
};
|
|
2661
2724
|
//#endregion
|
|
2662
2725
|
//#region src/api/blockManipulation/insertContentAt.ts
|
|
2663
|
-
function
|
|
2726
|
+
function Pi(e, t, n, r = { updateSelection: !0 }) {
|
|
2664
2727
|
let { from: i, to: a } = typeof t == "number" ? {
|
|
2665
2728
|
from: t,
|
|
2666
2729
|
to: t
|
|
@@ -2674,19 +2737,19 @@ function Si(e, t, n, r = { updateSelection: !0 }) {
|
|
|
2674
2737
|
let { parent: t } = e.doc.resolve(i);
|
|
2675
2738
|
t.isTextblock && !t.type.spec.code && !t.childCount && (--i, a += 1);
|
|
2676
2739
|
}
|
|
2677
|
-
return o ? e.insertText(c, i, a) : e.replaceWith(i, a, n), r.updateSelection &&
|
|
2740
|
+
return o ? e.insertText(c, i, a) : e.replaceWith(i, a, n), r.updateSelection && rt(e, e.steps.length - 1, -1), !0;
|
|
2678
2741
|
}
|
|
2679
2742
|
//#endregion
|
|
2680
2743
|
//#region src/editor/managers/StyleManager.ts
|
|
2681
|
-
var
|
|
2744
|
+
var Fi = class {
|
|
2682
2745
|
editor;
|
|
2683
2746
|
constructor(e) {
|
|
2684
2747
|
this.editor = e;
|
|
2685
2748
|
}
|
|
2686
2749
|
insertInlineContent(e, { updateSelection: t = !1 } = {}) {
|
|
2687
|
-
let n =
|
|
2750
|
+
let n = l(e, this.editor.pmSchema);
|
|
2688
2751
|
this.editor.transact((e) => {
|
|
2689
|
-
|
|
2752
|
+
Pi(e, {
|
|
2690
2753
|
from: e.selection.from,
|
|
2691
2754
|
to: e.selection.to
|
|
2692
2755
|
}, n, { updateSelection: t });
|
|
@@ -2712,7 +2775,7 @@ var Ci = class {
|
|
|
2712
2775
|
if (!e) throw Error(`style ${t} not found in styleSchema`);
|
|
2713
2776
|
if (e.propSchema === "boolean") this.editor._tiptapEditor.commands.setMark(t);
|
|
2714
2777
|
else if (e.propSchema === "string") this.editor._tiptapEditor.commands.setMark(t, { stringValue: n });
|
|
2715
|
-
else throw new
|
|
2778
|
+
else throw new _(e.propSchema);
|
|
2716
2779
|
}
|
|
2717
2780
|
}
|
|
2718
2781
|
removeStyles(e) {
|
|
@@ -2724,7 +2787,7 @@ var Ci = class {
|
|
|
2724
2787
|
if (!e) throw Error(`style ${t} not found in styleSchema`);
|
|
2725
2788
|
if (e.propSchema === "boolean") this.editor._tiptapEditor.commands.toggleMark(t);
|
|
2726
2789
|
else if (e.propSchema === "string") this.editor._tiptapEditor.commands.toggleMark(t, { stringValue: n });
|
|
2727
|
-
else throw new
|
|
2790
|
+
else throw new _(e.propSchema);
|
|
2728
2791
|
}
|
|
2729
2792
|
}
|
|
2730
2793
|
getSelectedText() {
|
|
@@ -2734,7 +2797,7 @@ var Ci = class {
|
|
|
2734
2797
|
return this.editor.transact((t) => {
|
|
2735
2798
|
let n = t.doc.resolve(e), r = n.marks().find((e) => e.type.name === "link");
|
|
2736
2799
|
if (!r) return;
|
|
2737
|
-
let i =
|
|
2800
|
+
let i = Ze(n, r.type);
|
|
2738
2801
|
if (i) return {
|
|
2739
2802
|
href: r.attrs.href,
|
|
2740
2803
|
from: i.from,
|
|
@@ -2773,71 +2836,72 @@ var Ci = class {
|
|
|
2773
2836
|
};
|
|
2774
2837
|
//#endregion
|
|
2775
2838
|
//#region src/editor/transformPasted.ts
|
|
2776
|
-
function
|
|
2777
|
-
return
|
|
2839
|
+
function Ii(e) {
|
|
2840
|
+
return Je(e.state.selection.$from, (e) => e.type.name === "tableCell" || e.type.name === "tableHeader") !== void 0;
|
|
2778
2841
|
}
|
|
2779
|
-
function
|
|
2780
|
-
let n = t.nodes.hardBreak, r =
|
|
2842
|
+
function Li(e, t) {
|
|
2843
|
+
let n = t.nodes.hardBreak, r = I.empty;
|
|
2781
2844
|
return e.forEach((e) => {
|
|
2782
|
-
e.isTextblock && e.childCount > 0 ? (r = r.append(e.content), r = r.addToEnd(n.create())) : e.isText ? r = r.addToEnd(e) : e.isBlock && e.childCount > 0 && (r = r.append(
|
|
2845
|
+
e.isTextblock && e.childCount > 0 ? (r = r.append(e.content), r = r.addToEnd(n.create())) : e.isText ? r = r.addToEnd(e) : e.isBlock && e.childCount > 0 && (r = r.append(Li(e.content, t)), r = r.addToEnd(n.create()));
|
|
2783
2846
|
}), r.lastChild?.type === n && (r = r.cut(0, r.size - 1)), r;
|
|
2784
2847
|
}
|
|
2785
|
-
function
|
|
2848
|
+
function Ri(e, t) {
|
|
2786
2849
|
let n = [];
|
|
2787
2850
|
return e.forEach((e, r, i) => {
|
|
2788
2851
|
i !== t && n.push(e);
|
|
2789
|
-
}),
|
|
2852
|
+
}), I.from(n);
|
|
2790
2853
|
}
|
|
2791
|
-
function
|
|
2854
|
+
function zi(e, t) {
|
|
2792
2855
|
let n = [];
|
|
2793
|
-
for (let r = 0; r < e.childCount; r++) if (e.child(r).type.name === "tableRow")
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2856
|
+
for (let r = 0; r < e.childCount; r++) if (e.child(r).type.name === "tableRow") {
|
|
2857
|
+
if (n.length > 0 && n[n.length - 1].type.name === "table") {
|
|
2858
|
+
let t = n[n.length - 1], i = t.copy(t.content.addToEnd(e.child(r)));
|
|
2859
|
+
n[n.length - 1] = i;
|
|
2860
|
+
} else {
|
|
2861
|
+
let i = t.nodes.table.createChecked(void 0, e.child(r));
|
|
2862
|
+
n.push(i);
|
|
2863
|
+
}
|
|
2864
|
+
} else n.push(e.child(r));
|
|
2865
|
+
return e = I.from(n), e;
|
|
2802
2866
|
}
|
|
2803
|
-
function
|
|
2804
|
-
let n =
|
|
2805
|
-
n =
|
|
2806
|
-
let r =
|
|
2867
|
+
function Bi(e, t) {
|
|
2868
|
+
let n = I.from(e.content);
|
|
2869
|
+
n = zi(n, t.state.schema);
|
|
2870
|
+
let r = Vi(n, t, e);
|
|
2807
2871
|
if (r) return r;
|
|
2808
|
-
if (
|
|
2872
|
+
if (Ii(t)) {
|
|
2809
2873
|
let e = !1;
|
|
2810
2874
|
if (n.descendants((t) => {
|
|
2811
2875
|
t.type.isInGroup("tableContent") && (e = !0);
|
|
2812
|
-
}), !e && !t.state.schema.nodes.tableParagraph.validContent(n)) return new
|
|
2876
|
+
}), !e && !t.state.schema.nodes.tableParagraph.validContent(n)) return new L(Li(n, t.state.schema), 0, 0);
|
|
2813
2877
|
}
|
|
2814
|
-
if (!
|
|
2878
|
+
if (!Hi(n, t)) return new L(n, e.openStart, e.openEnd);
|
|
2815
2879
|
for (let e = 0; e < n.childCount; e++) if (n.child(e).type.spec.group === "blockContent") {
|
|
2816
2880
|
let r = [n.child(e)];
|
|
2817
2881
|
if (e + 1 < n.childCount && n.child(e + 1).type.name === "blockGroup") {
|
|
2818
2882
|
let t = n.child(e + 1).child(0).child(0);
|
|
2819
|
-
(t.type.name === "bulletListItem" || t.type.name === "numberedListItem" || t.type.name === "checkListItem") && (r.push(n.child(e + 1)), n =
|
|
2883
|
+
(t.type.name === "bulletListItem" || t.type.name === "numberedListItem" || t.type.name === "checkListItem") && (r.push(n.child(e + 1)), n = Ri(n, e + 1));
|
|
2820
2884
|
}
|
|
2821
2885
|
let i = t.state.schema.nodes.blockContainer.createChecked(void 0, r);
|
|
2822
2886
|
n = n.replaceChild(e, i);
|
|
2823
2887
|
}
|
|
2824
|
-
return new
|
|
2888
|
+
return new L(n, e.openStart, e.openEnd);
|
|
2825
2889
|
}
|
|
2826
|
-
function
|
|
2827
|
-
if (
|
|
2828
|
-
let r =
|
|
2890
|
+
function Vi(e, t, n) {
|
|
2891
|
+
if (Ii(t) || t.dragging) return null;
|
|
2892
|
+
let r = w(t.state), i = r.isBlockContainer ? r.blockContent.node : null;
|
|
2829
2893
|
if (!i || i.type.name === "paragraph" || i.type.spec.content !== "inline*" || i.childCount > 0) return null;
|
|
2830
2894
|
let a = e.firstChild, o = a?.firstChild, s = o?.firstChild;
|
|
2831
2895
|
if (a?.type.name !== "blockGroup" || o?.type.name !== "blockContainer" || s?.type.name !== "paragraph") return null;
|
|
2832
2896
|
let c = i.type.create(i.attrs, s.content), l = o.copy(o.content.replaceChild(0, c)), u = a.copy(a.content.replaceChild(0, l));
|
|
2833
|
-
return new
|
|
2897
|
+
return new L(e.replaceChild(0, u), n.openStart, n.openEnd);
|
|
2834
2898
|
}
|
|
2835
|
-
function
|
|
2899
|
+
function Hi(e, t) {
|
|
2836
2900
|
let n = e.childCount === 1, r = e.firstChild?.type.spec.content === "inline*", i = e.firstChild?.type.spec.content === "tableRow+";
|
|
2837
2901
|
if (n) {
|
|
2838
2902
|
if (r) return !1;
|
|
2839
2903
|
if (i) {
|
|
2840
|
-
let e =
|
|
2904
|
+
let e = w(t.state);
|
|
2841
2905
|
if (e.isBlockContainer) return e.blockContent.node.type.spec.content !== "tableRow+";
|
|
2842
2906
|
}
|
|
2843
2907
|
}
|
|
@@ -2845,11 +2909,11 @@ function Ai(e, t) {
|
|
|
2845
2909
|
}
|
|
2846
2910
|
//#endregion
|
|
2847
2911
|
//#region src/editor/BlockNoteEditor.ts
|
|
2848
|
-
var
|
|
2912
|
+
var Ui = {
|
|
2849
2913
|
enableInputRules: !0,
|
|
2850
2914
|
enablePasteRules: !0,
|
|
2851
2915
|
enableCoreExtensions: !1
|
|
2852
|
-
},
|
|
2916
|
+
}, Wi = class t extends H {
|
|
2853
2917
|
options;
|
|
2854
2918
|
pmSchema;
|
|
2855
2919
|
_tiptapEditor;
|
|
@@ -2865,27 +2929,27 @@ var ji = {
|
|
|
2865
2929
|
onUploadEndCallbacks = [];
|
|
2866
2930
|
resolveFileUrl;
|
|
2867
2931
|
settings;
|
|
2868
|
-
static create(
|
|
2869
|
-
return new e
|
|
2870
|
-
}
|
|
2871
|
-
constructor(
|
|
2872
|
-
super(), this.options =
|
|
2873
|
-
splitCells:
|
|
2874
|
-
cellBackgroundColor:
|
|
2875
|
-
cellTextColor:
|
|
2876
|
-
headers:
|
|
2932
|
+
static create(e) {
|
|
2933
|
+
return new t(e ?? {});
|
|
2934
|
+
}
|
|
2935
|
+
constructor(t) {
|
|
2936
|
+
super(), this.options = t, this.dictionary = t.dictionary || Ie, this.settings = { tables: {
|
|
2937
|
+
splitCells: t?.tables?.splitCells ?? !1,
|
|
2938
|
+
cellBackgroundColor: t?.tables?.cellBackgroundColor ?? !1,
|
|
2939
|
+
cellTextColor: t?.tables?.cellTextColor ?? !1,
|
|
2940
|
+
headers: t?.tables?.headers ?? !1
|
|
2877
2941
|
} };
|
|
2878
|
-
let
|
|
2942
|
+
let n = {
|
|
2879
2943
|
defaultStyles: !0,
|
|
2880
|
-
schema:
|
|
2881
|
-
...
|
|
2944
|
+
schema: t.schema || ce.create(),
|
|
2945
|
+
...t,
|
|
2882
2946
|
placeholders: {
|
|
2883
2947
|
...this.dictionary.placeholders,
|
|
2884
|
-
...
|
|
2948
|
+
...t.placeholders
|
|
2885
2949
|
}
|
|
2886
2950
|
};
|
|
2887
|
-
if (this.schema =
|
|
2888
|
-
let e =
|
|
2951
|
+
if (this.schema = n.schema, this.blockImplementations = n.schema.blockSpecs, this.inlineContentImplementations = n.schema.inlineContentSpecs, this.styleImplementations = n.schema.styleSpecs, n.uploadFile) {
|
|
2952
|
+
let e = n.uploadFile;
|
|
2889
2953
|
this.uploadFile = async (t, n) => {
|
|
2890
2954
|
this.onUploadStartCallbacks.forEach((e) => e.apply(this, [n]));
|
|
2891
2955
|
try {
|
|
@@ -2895,13 +2959,13 @@ var ji = {
|
|
|
2895
2959
|
}
|
|
2896
2960
|
};
|
|
2897
2961
|
}
|
|
2898
|
-
this.resolveFileUrl =
|
|
2899
|
-
let
|
|
2900
|
-
...
|
|
2901
|
-
...
|
|
2962
|
+
this.resolveFileUrl = n.resolveFileUrl, this._eventManager = new on(this), this._extensionManager = new Di(this, n);
|
|
2963
|
+
let r = this._extensionManager.getTiptapExtensions(), i = {
|
|
2964
|
+
...Ui,
|
|
2965
|
+
...n._tiptapOptions,
|
|
2902
2966
|
element: null,
|
|
2903
|
-
autofocus:
|
|
2904
|
-
extensions:
|
|
2967
|
+
autofocus: n.autofocus ?? !1,
|
|
2968
|
+
extensions: r,
|
|
2905
2969
|
editorProps: {
|
|
2906
2970
|
scrollMargin: {
|
|
2907
2971
|
top: 72,
|
|
@@ -2909,34 +2973,34 @@ var ji = {
|
|
|
2909
2973
|
left: 0,
|
|
2910
2974
|
right: 0
|
|
2911
2975
|
},
|
|
2912
|
-
...
|
|
2976
|
+
...n._tiptapOptions?.editorProps,
|
|
2913
2977
|
attributes: {
|
|
2914
2978
|
tabIndex: "0",
|
|
2915
|
-
...
|
|
2916
|
-
...
|
|
2917
|
-
class:
|
|
2979
|
+
...n._tiptapOptions?.editorProps?.attributes,
|
|
2980
|
+
...n.domAttributes?.editor,
|
|
2981
|
+
class: s("bn-editor", n.defaultStyles ? "bn-default-styles" : "", n.domAttributes?.editor?.class || "")
|
|
2918
2982
|
},
|
|
2919
|
-
transformPasted:
|
|
2983
|
+
transformPasted: Bi
|
|
2920
2984
|
}
|
|
2921
2985
|
};
|
|
2922
2986
|
try {
|
|
2923
|
-
let
|
|
2987
|
+
let t = n.initialContent || [{
|
|
2924
2988
|
type: "paragraph",
|
|
2925
|
-
id:
|
|
2989
|
+
id: e.options.generateID()
|
|
2926
2990
|
}];
|
|
2927
|
-
if (!Array.isArray(
|
|
2928
|
-
let
|
|
2929
|
-
|
|
2930
|
-
let
|
|
2991
|
+
if (!Array.isArray(t) || t.length === 0) throw Error("initialContent must be a non-empty array of blocks, received: " + JSON.stringify(t));
|
|
2992
|
+
let r = $e(i.extensions);
|
|
2993
|
+
r.cached.blockNoteEditor = this;
|
|
2994
|
+
let a = t.map((e) => c(e, r, this.schema.styleSchema).toJSON()), o = Ke({
|
|
2931
2995
|
type: "doc",
|
|
2932
2996
|
content: [{
|
|
2933
2997
|
type: "blockGroup",
|
|
2934
|
-
content:
|
|
2998
|
+
content: a
|
|
2935
2999
|
}]
|
|
2936
|
-
},
|
|
2937
|
-
this._tiptapEditor = new
|
|
2938
|
-
...
|
|
2939
|
-
content:
|
|
3000
|
+
}, r, i.parseOptions);
|
|
3001
|
+
this._tiptapEditor = new Ue({
|
|
3002
|
+
...i,
|
|
3003
|
+
content: o.toJSON()
|
|
2940
3004
|
}), this.pmSchema = this._tiptapEditor.schema;
|
|
2941
3005
|
} catch (e) {
|
|
2942
3006
|
throw Error("Error creating document from blocks passed as `initialContent`", { cause: e });
|
|
@@ -2945,7 +3009,7 @@ var ji = {
|
|
|
2945
3009
|
this.headless = !1;
|
|
2946
3010
|
}), this._tiptapEditor.on("unmount", () => {
|
|
2947
3011
|
this.headless = !0;
|
|
2948
|
-
}), this._blockManager = new
|
|
3012
|
+
}), this._blockManager = new an(this), this._exportManager = new rr(this), this._selectionManager = new Mi(this), this._stateManager = new Ni(this), this._styleManager = new Fi(this), this.emit("create");
|
|
2949
3013
|
}
|
|
2950
3014
|
_blockManager;
|
|
2951
3015
|
_eventManager;
|
|
@@ -2969,7 +3033,7 @@ var ji = {
|
|
|
2969
3033
|
unregisterExtension = (...e) => this._extensionManager.unregisterExtension(...e);
|
|
2970
3034
|
registerExtension = (...e) => this._extensionManager.registerExtension(...e);
|
|
2971
3035
|
replaceExtension = (...e) => this._extensionManager.replaceExtension(...e);
|
|
2972
|
-
getExtension = ((
|
|
3036
|
+
getExtension = ((e) => this._extensionManager.getExtension(e));
|
|
2973
3037
|
mount = (e, t) => {
|
|
2974
3038
|
let n = e.getRootNode(), r = typeof ShadowRoot < "u" && n instanceof ShadowRoot;
|
|
2975
3039
|
(t?.portalTarget ?? e.parentElement ?? (r ? n : document.body)).appendChild(this.portalElement), this._tiptapEditor.mount({ mount: e });
|
|
@@ -3042,7 +3106,7 @@ var ji = {
|
|
|
3042
3106
|
this._tiptapEditor.on("selectionUpdate", e);
|
|
3043
3107
|
}
|
|
3044
3108
|
onBeforeChange(e) {
|
|
3045
|
-
return this._extensionManager.getExtension(
|
|
3109
|
+
return this._extensionManager.getExtension(be).subscribe(e);
|
|
3046
3110
|
}
|
|
3047
3111
|
getTextCursorPosition() {
|
|
3048
3112
|
return this._selectionManager.getTextCursorPosition();
|
|
@@ -3177,33 +3241,55 @@ var ji = {
|
|
|
3177
3241
|
pasteMarkdown(e) {
|
|
3178
3242
|
return this._exportManager.pasteMarkdown(e);
|
|
3179
3243
|
}
|
|
3180
|
-
},
|
|
3244
|
+
}, Gi = class {
|
|
3181
3245
|
mappings;
|
|
3182
3246
|
options;
|
|
3183
3247
|
constructor(e, t, n) {
|
|
3184
3248
|
this.mappings = t, this.options = n;
|
|
3185
3249
|
}
|
|
3250
|
+
get dictionary() {
|
|
3251
|
+
return this.options.dictionary?.exporter ?? Ie.exporter;
|
|
3252
|
+
}
|
|
3186
3253
|
async resolveFile(e) {
|
|
3187
3254
|
if (!this.options?.resolveFileUrl) return (await fetch(e)).blob();
|
|
3188
3255
|
let t = await this.options.resolveFileUrl(e);
|
|
3189
3256
|
return t instanceof Blob ? t : (await fetch(t)).blob();
|
|
3190
3257
|
}
|
|
3191
3258
|
mapStyles(e) {
|
|
3192
|
-
return Object.entries(e).map(([e, t]) =>
|
|
3259
|
+
return Object.entries(e).map(([e, t]) => {
|
|
3260
|
+
let n = this.mappings.styleMapping[e];
|
|
3261
|
+
if (!n) throw Error(`Exporter is missing a style mapping for style "${e}". If this style comes from a separate package, spread that package's exporter mappings into your styleMapping.`);
|
|
3262
|
+
return n(t, this);
|
|
3263
|
+
});
|
|
3193
3264
|
}
|
|
3194
3265
|
mapInlineContent(e) {
|
|
3195
|
-
|
|
3266
|
+
let t = this.mappings.inlineContentMapping[e.type];
|
|
3267
|
+
if (!t) throw Error(`Exporter is missing an inline content mapping for inline content type "${e.type}". If this inline content comes from a separate package, spread that package's exporter mappings into your inlineContentMapping.`);
|
|
3268
|
+
return t(e, this);
|
|
3196
3269
|
}
|
|
3197
3270
|
transformInlineContent(e) {
|
|
3198
3271
|
return e.map((e) => this.mapInlineContent(e));
|
|
3199
3272
|
}
|
|
3200
3273
|
async mapBlock(e, t, n, r) {
|
|
3201
|
-
|
|
3274
|
+
let i = this.mappings.blockMapping[e.type];
|
|
3275
|
+
if (!i) throw Error(`Exporter is missing a block mapping for block type "${e.type}". If this block comes from a separate package, spread that package's exporter mappings into your blockMapping.`);
|
|
3276
|
+
return i(e, this, t, n, r);
|
|
3202
3277
|
}
|
|
3203
3278
|
};
|
|
3204
3279
|
//#endregion
|
|
3280
|
+
//#region src/exporter/ExportImage.ts
|
|
3281
|
+
function Ki(e) {
|
|
3282
|
+
if ("toBase64" in e && typeof e.toBase64 == "function") return e.toBase64();
|
|
3283
|
+
let t = "";
|
|
3284
|
+
for (let n of e) t += String.fromCharCode(n);
|
|
3285
|
+
return btoa(t);
|
|
3286
|
+
}
|
|
3287
|
+
function qi(e) {
|
|
3288
|
+
return `data:${e.mimeType};base64,${Ki(e.data)}`;
|
|
3289
|
+
}
|
|
3290
|
+
//#endregion
|
|
3205
3291
|
//#region src/exporter/mapping.ts
|
|
3206
|
-
function
|
|
3292
|
+
function Ji(e) {
|
|
3207
3293
|
return {
|
|
3208
3294
|
createBlockMapping: (e) => e,
|
|
3209
3295
|
createInlineContentMapping: (e) => e,
|
|
@@ -3212,7 +3298,7 @@ function Pi(e) {
|
|
|
3212
3298
|
}
|
|
3213
3299
|
//#endregion
|
|
3214
3300
|
//#region src/util/combineByGroup.ts
|
|
3215
|
-
function
|
|
3301
|
+
function Yi(e, ...t) {
|
|
3216
3302
|
let n = [...e];
|
|
3217
3303
|
for (let e of t) for (let t of e) {
|
|
3218
3304
|
let e = n.findLastIndex((e) => e.group === t.group);
|
|
@@ -3221,6 +3307,6 @@ function Fi(e, ...t) {
|
|
|
3221
3307
|
return n;
|
|
3222
3308
|
}
|
|
3223
3309
|
//#endregion
|
|
3224
|
-
export {
|
|
3310
|
+
export { ht as A, B as C, xt as D, St as E, bt as O, Nt as S, R as T, It as _, Gi as a, V as b, kr as c, G as d, en as f, H as g, tn as h, qi as i, yt as k, nr as l, rn as m, Ji as n, Wi as o, nn as p, Ki as r, Oi as s, Yi as t, tr as u, Lt as v, z as w, Rt as x, Ft as y };
|
|
3225
3311
|
|
|
3226
|
-
//# sourceMappingURL=src-
|
|
3312
|
+
//# sourceMappingURL=src-BkfZVfaO.js.map
|