@blocknote/core 0.53.0 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BlockNoteExtension-BJCLnwrE.cjs +2 -0
- package/dist/BlockNoteExtension-BJCLnwrE.cjs.map +1 -0
- package/dist/BlockNoteExtension-CbvDA0F7.js +80 -0
- package/dist/BlockNoteExtension-CbvDA0F7.js.map +1 -0
- package/dist/{UserStore-QbbPFj0z.js → UserStore-C4TzkGEn.js} +3 -3
- package/dist/{UserStore-DCG6lsla.cjs.map → UserStore-C4TzkGEn.js.map} +1 -1
- package/dist/{UserStore-DCG6lsla.cjs → UserStore-mj3fXW4D.cjs} +2 -2
- package/dist/UserStore-mj3fXW4D.cjs.map +1 -0
- package/dist/blocknote.cjs +1 -1
- package/dist/blocknote.js +6 -6
- package/dist/{blocks-BEJW9OM_.js → blocks-CzQLehlc.js} +571 -568
- package/dist/blocks-CzQLehlc.js.map +1 -0
- package/dist/blocks-CzkqclGj.cjs +12 -0
- package/dist/blocks-CzkqclGj.cjs.map +1 -0
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +2 -2
- package/dist/comments.cjs +1 -1
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js +7 -7
- package/dist/comments.js.map +1 -1
- package/dist/en-BuzSuuTq.cjs +2 -0
- package/dist/en-BuzSuuTq.cjs.map +1 -0
- package/dist/{en-CGKXfWma.js → en-uzHzj6eH.js} +10 -1
- package/dist/en-uzHzj6eH.js.map +1 -0
- package/dist/extensions-CSB9ZvuL.cjs +58 -0
- package/dist/extensions-CSB9ZvuL.cjs.map +1 -0
- package/dist/{extensions-BR5hkAio.js → extensions-DGuhtOgB.js} +662 -427
- package/dist/extensions-DGuhtOgB.js.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +4 -4
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +199 -1
- package/dist/locales.js.map +1 -1
- package/dist/{src-BUXut68d.js → src-BkfZVfaO.js} +967 -899
- package/dist/src-BkfZVfaO.js.map +1 -0
- package/dist/src-DM3syMdf.cjs +23 -0
- package/dist/src-DM3syMdf.cjs.map +1 -0
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/dist/y.cjs +1 -1
- package/dist/y.cjs.map +1 -1
- package/dist/y.js +59 -56
- package/dist/y.js.map +1 -1
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.cjs.map +1 -1
- package/dist/yjs.js +88 -76
- package/dist/yjs.js.map +1 -1
- package/package.json +17 -18
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +2505 -763
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +42 -0
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +16 -4
- package/src/api/exporters/markdown/htmlToMarkdown.ts +45 -10
- package/src/api/nodeConversions/blockToNode.ts +5 -1
- package/src/api/nodeConversions/nodeToBlock.ts +3 -0
- package/src/api/pmUtil.ts +16 -8
- package/src/blocks/Code/CodeBlockOptions.ts +83 -0
- package/src/blocks/Code/block.test.ts +1 -1
- package/src/blocks/Code/block.ts +29 -281
- package/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.ts +120 -0
- package/src/blocks/Code/helpers/parse/parsePreCode.ts +45 -0
- package/src/blocks/Code/helpers/render/createCodeBlock.ts +98 -0
- package/src/blocks/Code/helpers/toExternalHTML/createPreCode.ts +14 -0
- package/src/blocks/index.ts +3 -0
- package/src/comments/extension.ts +2 -4
- package/src/editor/Block.css +273 -2
- package/src/editor/BlockNoteEditor.ts +25 -4
- package/src/editor/BlockNoteExtension.ts +1 -1
- package/src/editor/managers/ExtensionManager/extensions.ts +6 -0
- package/src/exporter/ExportImage.ts +50 -0
- package/src/exporter/Exporter.test.ts +48 -0
- package/src/exporter/Exporter.ts +46 -12
- package/src/exporter/index.ts +1 -0
- package/src/exporter/mapping.ts +4 -1
- package/src/extensions/FormattingToolbar/FormattingToolbar.ts +10 -8
- package/src/extensions/InlineContentBoundaryEdit/InlineContentBoundaryEdit.ts +109 -0
- package/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.ts +192 -0
- package/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.ts +142 -0
- package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.ts +120 -0
- package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.ts +89 -0
- package/src/extensions/SyntaxHighlighting/inlineHighlight.test.ts +135 -0
- package/src/extensions/SyntaxHighlighting/shiki.ts +116 -0
- package/src/extensions/Versioning/inMemoryVersioning.ts +13 -3
- package/src/extensions/index.ts +4 -0
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts +51 -2
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +22 -2
- package/src/i18n/locales/ar.ts +9 -0
- package/src/i18n/locales/de.ts +9 -0
- package/src/i18n/locales/en.ts +9 -0
- package/src/i18n/locales/es.ts +9 -0
- package/src/i18n/locales/fa.ts +9 -0
- package/src/i18n/locales/fr.ts +9 -0
- package/src/i18n/locales/he.ts +9 -0
- package/src/i18n/locales/hr.ts +9 -0
- package/src/i18n/locales/is.ts +9 -0
- package/src/i18n/locales/it.ts +9 -0
- package/src/i18n/locales/ja.ts +9 -0
- package/src/i18n/locales/ko.ts +9 -0
- package/src/i18n/locales/nl.ts +9 -0
- package/src/i18n/locales/no.ts +9 -0
- package/src/i18n/locales/pl.ts +9 -0
- package/src/i18n/locales/pt.ts +9 -0
- package/src/i18n/locales/ru.ts +9 -0
- package/src/i18n/locales/sk.ts +9 -0
- package/src/i18n/locales/uk.ts +9 -0
- package/src/i18n/locales/uz.ts +9 -0
- package/src/i18n/locales/vi.ts +9 -0
- package/src/i18n/locales/zh-tw.ts +9 -0
- package/src/i18n/locales/zh.ts +9 -0
- package/src/index.ts +5 -1
- package/src/schema/blocks/createSpec.ts +2 -3
- package/src/schema/blocks/types.ts +53 -3
- package/src/schema/contentTypePropagation.test.ts +1 -1
- package/src/schema/inlineContent/createSpec.test.ts +161 -0
- package/src/schema/inlineContent/createSpec.ts +171 -12
- package/src/schema/inlineContent/internal.ts +21 -2
- package/src/schema/inlineContent/types.ts +35 -5
- package/src/user/UserStore.ts +1 -1
- package/src/util/Store.test.ts +132 -0
- package/src/util/Store.ts +135 -0
- package/src/y/extensions/AttributionExtension.test.ts +10 -0
- package/src/y/extensions/Versioning.test.ts +20 -7
- package/src/yjs/comments/RESTYjsThreadStore.test.ts +85 -0
- package/src/yjs/comments/RESTYjsThreadStore.ts +7 -1
- package/src/yjs/extensions/ForkYDoc.test.ts +37 -0
- package/src/yjs/extensions/ForkYDoc.ts +26 -1
- package/src/yjs/extensions/RelativePositionMapping.ts +8 -2
- package/src/yjs/extensions/Versioning.test.ts +17 -5
- package/types/src/api/pmUtil.d.ts +7 -7
- package/types/src/blocks/Code/CodeBlockOptions.d.ts +61 -0
- package/types/src/blocks/Code/block.d.ts +3 -53
- package/types/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.d.ts +35 -0
- package/types/src/blocks/Code/helpers/parse/parsePreCode.d.ts +8 -0
- package/types/src/blocks/Code/helpers/render/createCodeBlock.d.ts +18 -0
- package/types/src/blocks/Code/helpers/toExternalHTML/createPreCode.d.ts +5 -0
- package/types/src/blocks/index.d.ts +3 -0
- package/types/src/comments/extension.d.ts +1 -15
- package/types/src/editor/BlockNoteEditor.d.ts +3 -3
- package/types/src/editor/BlockNoteExtension.d.ts +1 -1
- package/types/src/exporter/ExportImage.d.ts +36 -0
- package/types/src/exporter/Exporter.d.ts +21 -0
- package/types/src/exporter/Exporter.test.d.ts +1 -0
- package/types/src/exporter/index.d.ts +1 -0
- package/types/src/exporter/mapping.d.ts +1 -1
- package/types/src/extensions/FilePanel/FilePanel.d.ts +1 -1
- package/types/src/extensions/FormattingToolbar/FormattingToolbar.d.ts +1 -1
- package/types/src/extensions/InlineContentBoundaryEdit/InlineContentBoundaryEdit.d.ts +5 -0
- package/types/src/extensions/ShowSelection/ShowSelection.d.ts +1 -5
- package/types/src/extensions/SideMenu/SideMenu.d.ts +1 -1
- package/types/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.d.ts +45 -0
- package/types/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.d.ts +49 -0
- package/types/src/extensions/SuggestionMenu/SuggestionMenu.d.ts +1 -11
- package/types/src/extensions/SyntaxHighlighting/SyntaxHighlighting.d.ts +44 -0
- package/types/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.d.ts +1 -0
- package/types/src/extensions/SyntaxHighlighting/inlineHighlight.test.d.ts +1 -0
- package/types/src/extensions/SyntaxHighlighting/shiki.d.ts +13 -0
- package/types/src/extensions/TableHandles/TableHandles.d.ts +1 -1
- package/types/src/extensions/Versioning/Versioning.d.ts +1 -35
- package/types/src/extensions/index.d.ts +4 -0
- package/types/src/i18n/locales/en.d.ts +9 -0
- package/types/src/i18n/locales/fa.d.ts +9 -0
- package/types/src/i18n/locales/sk.d.ts +9 -0
- package/types/src/index.d.ts +2 -1
- package/types/src/schema/blocks/types.d.ts +36 -3
- package/types/src/schema/inlineContent/createSpec.d.ts +35 -3
- package/types/src/schema/inlineContent/createSpec.test.d.ts +1 -0
- package/types/src/schema/inlineContent/internal.d.ts +3 -2
- package/types/src/schema/inlineContent/types.d.ts +22 -3
- package/types/src/user/UserStore.d.ts +1 -1
- package/types/src/util/Store.d.ts +45 -0
- package/types/src/util/Store.test.d.ts +1 -0
- package/types/src/y/extensions/AttributionExtension.d.ts +1 -1
- package/types/src/y/extensions/DiffVersioningExtension.d.ts +1 -1
- package/types/src/y/extensions/ForkYDoc.d.ts +1 -5
- package/types/src/y/extensions/index.d.ts +2 -10
- package/types/src/yjs/comments/RESTYjsThreadStore.test.d.ts +1 -0
- package/types/src/yjs/extensions/ForkYDoc.d.ts +1 -5
- package/types/src/yjs/extensions/index.d.ts +1 -5
- package/dist/BlockNoteExtension-B_IEJHS8.js +0 -38
- package/dist/BlockNoteExtension-B_IEJHS8.js.map +0 -1
- package/dist/BlockNoteExtension-M0znTzxP.cjs +0 -2
- package/dist/BlockNoteExtension-M0znTzxP.cjs.map +0 -1
- package/dist/UserStore-QbbPFj0z.js.map +0 -1
- package/dist/blocks-BEJW9OM_.js.map +0 -1
- package/dist/blocks-BPmJglFo.cjs +0 -12
- package/dist/blocks-BPmJglFo.cjs.map +0 -1
- package/dist/en-C5Z4Ag9_.cjs +0 -2
- package/dist/en-C5Z4Ag9_.cjs.map +0 -1
- package/dist/en-CGKXfWma.js.map +0 -1
- package/dist/extensions-AitWbYdJ.cjs +0 -52
- package/dist/extensions-AitWbYdJ.cjs.map +0 -1
- package/dist/extensions-BR5hkAio.js.map +0 -1
- package/dist/src-BHPuOo7W.cjs +0 -21
- package/dist/src-BHPuOo7W.cjs.map +0 -1
- package/dist/src-BUXut68d.js.map +0 -1
- package/src/blocks/Code/shiki.ts +0 -73
- package/types/src/blocks/Code/shiki.d.ts +0 -4
|
@@ -1,97 +1,135 @@
|
|
|
1
|
-
import { $n as e,
|
|
2
|
-
import { r as
|
|
3
|
-
import { A as _e,
|
|
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
73
|
draggable: t.meta?.draggable,
|
|
42
|
-
selectable: e.content
|
|
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
90
|
renderHTML({ node: n }) {
|
|
55
|
-
let
|
|
56
|
-
return y(t.render.call({
|
|
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
98
|
return (n) => {
|
|
63
|
-
let { node:
|
|
99
|
+
let { node: i, getPos: o } = n, s = this.options.editor, c = t.render.call({
|
|
64
100
|
renderType: "nodeView",
|
|
65
101
|
props: n
|
|
66
|
-
},
|
|
67
|
-
let t =
|
|
68
|
-
n &&
|
|
69
|
-
},
|
|
70
|
-
return
|
|
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
|
-
})
|
|
109
|
+
});
|
|
110
|
+
return se(n, e.propSchema, {
|
|
74
111
|
...t,
|
|
75
112
|
toExternalHTML: t.toExternalHTML,
|
|
76
113
|
render(n, r, i) {
|
|
77
|
-
|
|
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
|
|
90
|
-
return
|
|
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 i =
|
|
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
|
-
}),
|
|
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;
|
|
140
178
|
if (e.doc.descendants((t, r) => {
|
|
141
|
-
if (
|
|
179
|
+
if (o.size === 0) return !1;
|
|
142
180
|
if (!t.type.isInGroup("bnBlock")) return !0;
|
|
143
|
-
let i =
|
|
144
|
-
if (!
|
|
145
|
-
if (
|
|
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) {
|
|
146
184
|
let t = e.doc.nodeSize;
|
|
147
185
|
e.insert(r, a);
|
|
148
186
|
let n = e.doc.nodeSize;
|
|
149
187
|
f += t - n;
|
|
150
188
|
}
|
|
151
|
-
let
|
|
152
|
-
|
|
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);
|
|
153
191
|
let p = e.doc.nodeSize;
|
|
154
|
-
return f +=
|
|
155
|
-
}),
|
|
156
|
-
let e = [...
|
|
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 r.fixColumns !== !1 &&
|
|
160
|
-
insertedBlocks: a.map((t) =>
|
|
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 gt(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 _t(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 _t(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 yt = (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 yt = (e, t, n, r) => {
|
|
|
333
371
|
};
|
|
334
372
|
//#endregion
|
|
335
373
|
//#region src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts
|
|
336
|
-
function
|
|
374
|
+
function zt(e) {
|
|
337
375
|
return e.transact((e) => {
|
|
338
|
-
let t =
|
|
339
|
-
if (e.selection instanceof
|
|
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
379
|
anchorBlockId: n,
|
|
342
380
|
anchorCellOffset: e.selection.$anchorCell.pos - t.bnBlock.beforePos,
|
|
343
381
|
headCellOffset: e.selection.$headCell.pos - t.bnBlock.beforePos
|
|
344
382
|
};
|
|
345
|
-
if (e.selection instanceof
|
|
383
|
+
if (e.selection instanceof N) return {
|
|
346
384
|
type: "node",
|
|
347
385
|
anchorBlockId: n
|
|
348
386
|
};
|
|
349
387
|
{
|
|
350
|
-
let r =
|
|
388
|
+
let r = T(e, e.selection.head);
|
|
351
389
|
return {
|
|
352
390
|
type: "text",
|
|
353
391
|
anchorBlockId: n,
|
|
354
|
-
headBlockId:
|
|
392
|
+
headBlockId: C(r.bnBlock.node, e.doc),
|
|
355
393
|
anchorOffset: e.selection.anchor - t.bnBlock.beforePos,
|
|
356
394
|
headOffset: e.selection.head - r.bnBlock.beforePos
|
|
357
395
|
};
|
|
358
396
|
}
|
|
359
397
|
});
|
|
360
398
|
}
|
|
361
|
-
function
|
|
362
|
-
let
|
|
363
|
-
if (
|
|
364
|
-
let
|
|
365
|
-
if (
|
|
366
|
-
else if (
|
|
399
|
+
function Bt(e, t) {
|
|
400
|
+
let n = p(t.anchorBlockId, e.doc)?.posBeforeNode;
|
|
401
|
+
if (n === void 0) throw Error(`Could not find block with ID ${t.anchorBlockId} to update selection`);
|
|
402
|
+
let 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
|
|
369
|
-
if (
|
|
370
|
-
|
|
406
|
+
let i = p(t.headBlockId, e.doc)?.posBeforeNode;
|
|
407
|
+
if (i === void 0) throw Error(`Could not find block with ID ${t.headBlockId} to update selection`);
|
|
408
|
+
r = F.create(e.doc, n + t.anchorOffset, i + t.headOffset);
|
|
371
409
|
}
|
|
372
|
-
e.setSelection(
|
|
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 Bt(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
|
|
467
|
-
return
|
|
468
|
-
let { bnBlock:
|
|
469
|
-
return
|
|
504
|
+
function Qt(e) {
|
|
505
|
+
return e.transact((e) => {
|
|
506
|
+
let { bnBlock: t } = w(e);
|
|
507
|
+
return e.doc.resolve(t.beforePos).nodeBefore !== null;
|
|
470
508
|
});
|
|
471
509
|
}
|
|
472
|
-
function
|
|
473
|
-
return
|
|
474
|
-
let { bnBlock:
|
|
475
|
-
return
|
|
510
|
+
function $t(e) {
|
|
511
|
+
return e.transact((e) => {
|
|
512
|
+
let { bnBlock: t } = w(e);
|
|
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
|
|
482
|
-
if (r) return
|
|
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);
|
|
483
521
|
}
|
|
484
|
-
function
|
|
485
|
-
let
|
|
522
|
+
function tn(e, t) {
|
|
523
|
+
let n = typeof t == "string" ? t : t.id, r = p(n, e);
|
|
486
524
|
if (!r) return;
|
|
487
525
|
let i = e.resolve(r.posBeforeNode).nodeBefore;
|
|
488
|
-
if (i) return
|
|
526
|
+
if (i) return g(i, e);
|
|
489
527
|
}
|
|
490
|
-
function
|
|
491
|
-
let
|
|
528
|
+
function nn(e, t) {
|
|
529
|
+
let n = typeof t == "string" ? t : t.id, r = p(n, e);
|
|
492
530
|
if (!r) return;
|
|
493
531
|
let i = e.resolve(r.posBeforeNode + r.node.nodeSize).nodeAfter;
|
|
494
|
-
if (i) return
|
|
532
|
+
if (i) return g(i, e);
|
|
495
533
|
}
|
|
496
|
-
function
|
|
497
|
-
let
|
|
534
|
+
function rn(e, t) {
|
|
535
|
+
let n = typeof t == "string" ? t : t.id, r = p(n, e);
|
|
498
536
|
if (!r) return;
|
|
499
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;
|
|
500
|
-
if (s) return
|
|
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 Zt = 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 Zt = 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 Zt = 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 Zt = 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 rn(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,12 +710,12 @@ function ln(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
|
|
718
|
+
function vn(e) {
|
|
681
719
|
let t = [];
|
|
682
720
|
for (let n of e) if (n.type === "text") {
|
|
683
721
|
let e = n.text.split("").join("");
|
|
@@ -687,80 +725,80 @@ function dn(e) {
|
|
|
687
725
|
});
|
|
688
726
|
} else Array.isArray(n.content) ? t.push({
|
|
689
727
|
...n,
|
|
690
|
-
content:
|
|
728
|
+
content: vn(n.content)
|
|
691
729
|
}) : t.push(n);
|
|
692
730
|
return t;
|
|
693
731
|
}
|
|
694
|
-
function
|
|
695
|
-
for (let t of e) Array.isArray(t.content) && (t.content =
|
|
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);
|
|
696
734
|
}
|
|
697
|
-
function
|
|
698
|
-
let n =
|
|
699
|
-
|
|
700
|
-
let r =
|
|
701
|
-
for (let e = 0; e < r.childCount; e++) i.push(
|
|
702
|
-
return
|
|
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;
|
|
703
741
|
}
|
|
704
742
|
//#endregion
|
|
705
743
|
//#region src/api/parsers/markdown/markdownToHtml.ts
|
|
706
|
-
function
|
|
744
|
+
function K(e) {
|
|
707
745
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
708
746
|
}
|
|
709
|
-
function
|
|
747
|
+
function bn(e) {
|
|
710
748
|
return e ? /\w/.test(e) : !1;
|
|
711
749
|
}
|
|
712
|
-
function
|
|
750
|
+
function q(e, t, n) {
|
|
713
751
|
let r = t > 0 ? e[t - 1] : void 0, i = t + n < e.length ? e[t + n] : void 0;
|
|
714
|
-
return
|
|
752
|
+
return bn(r) && bn(i);
|
|
715
753
|
}
|
|
716
|
-
function
|
|
754
|
+
function xn(e, t) {
|
|
717
755
|
if (e[t] !== "\\" || t + 1 >= e.length) return null;
|
|
718
756
|
let n = e[t + 1];
|
|
719
757
|
return n === "\n" ? {
|
|
720
758
|
html: "<br>\n",
|
|
721
759
|
end: t + 2
|
|
722
760
|
} : "\\`*_{}[]()#+-.!~|>".includes(n) ? {
|
|
723
|
-
html:
|
|
761
|
+
html: K(n),
|
|
724
762
|
end: t + 2
|
|
725
763
|
} : null;
|
|
726
764
|
}
|
|
727
|
-
function
|
|
728
|
-
return e[t] === "`" ?
|
|
765
|
+
function Sn(e, t) {
|
|
766
|
+
return e[t] === "`" ? Rn(e, t) : null;
|
|
729
767
|
}
|
|
730
|
-
function
|
|
731
|
-
return e[t] !== "!" || e[t + 1] !== "[" ? null :
|
|
768
|
+
function Cn(e, t) {
|
|
769
|
+
return e[t] !== "!" || e[t + 1] !== "[" ? null : zn(e, t);
|
|
732
770
|
}
|
|
733
|
-
function
|
|
734
|
-
return e[t] === "[" ?
|
|
771
|
+
function wn(e, t) {
|
|
772
|
+
return e[t] === "[" ? Bn(e, t) : null;
|
|
735
773
|
}
|
|
736
|
-
function
|
|
737
|
-
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>");
|
|
738
776
|
}
|
|
739
|
-
function
|
|
740
|
-
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;
|
|
741
779
|
}
|
|
742
|
-
function
|
|
743
|
-
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;
|
|
744
782
|
}
|
|
745
|
-
function
|
|
746
|
-
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;
|
|
747
785
|
}
|
|
748
|
-
function
|
|
786
|
+
function kn(e, t) {
|
|
749
787
|
return e[t] === "\n" ? {
|
|
750
788
|
html: "<br>\n",
|
|
751
789
|
end: t + 1
|
|
752
790
|
} : null;
|
|
753
791
|
}
|
|
754
|
-
var
|
|
755
|
-
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) {
|
|
756
794
|
if (e[t] !== "<") return null;
|
|
757
795
|
let n = e.substring(t);
|
|
758
796
|
for (let e of [
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
797
|
+
jn,
|
|
798
|
+
Mn,
|
|
799
|
+
Nn,
|
|
800
|
+
Pn,
|
|
801
|
+
An
|
|
764
802
|
]) {
|
|
765
803
|
let r = n.match(e);
|
|
766
804
|
if (r) return {
|
|
@@ -770,19 +808,19 @@ function On(e, t) {
|
|
|
770
808
|
}
|
|
771
809
|
return null;
|
|
772
810
|
}
|
|
773
|
-
var
|
|
774
|
-
mn,
|
|
775
|
-
hn,
|
|
776
|
-
gn,
|
|
777
|
-
_n,
|
|
778
|
-
vn,
|
|
779
|
-
yn,
|
|
780
|
-
bn,
|
|
811
|
+
var In = /* @__PURE__ */ new Set("\\`![~*_\n<"), Ln = [
|
|
781
812
|
xn,
|
|
813
|
+
Sn,
|
|
814
|
+
Cn,
|
|
815
|
+
wn,
|
|
816
|
+
Tn,
|
|
817
|
+
En,
|
|
818
|
+
Dn,
|
|
782
819
|
On,
|
|
783
|
-
|
|
820
|
+
Fn,
|
|
821
|
+
kn
|
|
784
822
|
];
|
|
785
|
-
function
|
|
823
|
+
function J(e) {
|
|
786
824
|
let t = "", n = 0;
|
|
787
825
|
for (; n < e.length;) {
|
|
788
826
|
if (e[n] === "\n" && n >= 2 && e[n - 1] === " " && e[n - 2] === " ") {
|
|
@@ -790,7 +828,7 @@ function K(e) {
|
|
|
790
828
|
continue;
|
|
791
829
|
}
|
|
792
830
|
let r = !1;
|
|
793
|
-
if (
|
|
831
|
+
if (In.has(e[n])) for (let i of Ln) {
|
|
794
832
|
let a = i(e, n);
|
|
795
833
|
if (a) {
|
|
796
834
|
t += a.html, n = a.end, r = !0;
|
|
@@ -799,13 +837,13 @@ function K(e) {
|
|
|
799
837
|
}
|
|
800
838
|
if (!r) {
|
|
801
839
|
let r = n;
|
|
802
|
-
for (n++; n < e.length && !
|
|
803
|
-
t +=
|
|
840
|
+
for (n++; n < e.length && !In.has(e[n]);) n++;
|
|
841
|
+
t += K(e.substring(r, n));
|
|
804
842
|
}
|
|
805
843
|
}
|
|
806
844
|
return t;
|
|
807
845
|
}
|
|
808
|
-
function
|
|
846
|
+
function Rn(e, t) {
|
|
809
847
|
let n = 0, r = t;
|
|
810
848
|
for (; r < e.length && e[r] === "`";) n++, r++;
|
|
811
849
|
let i = r;
|
|
@@ -815,46 +853,46 @@ function jn(e, t) {
|
|
|
815
853
|
if (t === n) {
|
|
816
854
|
let t = e.substring(r, a);
|
|
817
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)), {
|
|
818
|
-
html: `<code>${
|
|
856
|
+
html: `<code>${K(t)}</code>`,
|
|
819
857
|
end: i
|
|
820
858
|
};
|
|
821
859
|
}
|
|
822
860
|
} else i++;
|
|
823
861
|
return null;
|
|
824
862
|
}
|
|
825
|
-
function
|
|
826
|
-
let n =
|
|
863
|
+
function zn(e, t) {
|
|
864
|
+
let n = Vn(e, t + 1);
|
|
827
865
|
if (n === -1) return null;
|
|
828
866
|
let r = t + 2;
|
|
829
867
|
if (e[n + 1] !== "(") return null;
|
|
830
|
-
let i = n + 2, a =
|
|
868
|
+
let i = n + 2, a = Hn(e, i - 1);
|
|
831
869
|
if (a === -1) return null;
|
|
832
|
-
let o = e.substring(r, n), { url: s, title: c } =
|
|
833
|
-
if (
|
|
870
|
+
let o = e.substring(r, n), { url: s, title: c } = Un(e.substring(i, a));
|
|
871
|
+
if (de(s)) {
|
|
834
872
|
let e = o || c;
|
|
835
873
|
return {
|
|
836
|
-
html: `<video src="${
|
|
874
|
+
html: `<video src="${K(s)}"${e ? ` data-name="${K(e)}"` : ""} data-url="${K(s)}" controls></video>`,
|
|
837
875
|
end: a + 1
|
|
838
876
|
};
|
|
839
877
|
}
|
|
840
|
-
let l = c === void 0 ? "" : ` title="${
|
|
878
|
+
let l = c === void 0 ? "" : ` title="${K(c)}"`;
|
|
841
879
|
return {
|
|
842
|
-
html: `<img src="${
|
|
880
|
+
html: `<img src="${K(s)}" alt="${K(o)}"${l}>`,
|
|
843
881
|
end: a + 1
|
|
844
882
|
};
|
|
845
883
|
}
|
|
846
|
-
function
|
|
847
|
-
let n = t + 1, r =
|
|
884
|
+
function Bn(e, t) {
|
|
885
|
+
let n = t + 1, r = Vn(e, t);
|
|
848
886
|
if (r === -1 || e[r + 1] !== "(") return null;
|
|
849
|
-
let i = r + 2, a =
|
|
887
|
+
let i = r + 2, a = Hn(e, r + 1);
|
|
850
888
|
if (a === -1) return null;
|
|
851
|
-
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)}"`;
|
|
852
890
|
return {
|
|
853
|
-
html: `<a href="${
|
|
891
|
+
html: `<a href="${K(s)}"${l}>${J(o)}</a>`,
|
|
854
892
|
end: a + 1
|
|
855
893
|
};
|
|
856
894
|
}
|
|
857
|
-
function
|
|
895
|
+
function Vn(e, t) {
|
|
858
896
|
let n = 0;
|
|
859
897
|
for (let r = t; r < e.length; r++) {
|
|
860
898
|
if (e[r] === "\\" && r + 1 < e.length) {
|
|
@@ -865,7 +903,7 @@ function Pn(e, t) {
|
|
|
865
903
|
}
|
|
866
904
|
return -1;
|
|
867
905
|
}
|
|
868
|
-
function
|
|
906
|
+
function Hn(e, t) {
|
|
869
907
|
let n = 0;
|
|
870
908
|
for (let r = t; r < e.length; r++) {
|
|
871
909
|
if (e[r] === "\\" && r + 1 < e.length) {
|
|
@@ -876,7 +914,7 @@ function Fn(e, t) {
|
|
|
876
914
|
}
|
|
877
915
|
return -1;
|
|
878
916
|
}
|
|
879
|
-
function
|
|
917
|
+
function Un(e) {
|
|
880
918
|
e = e.trim();
|
|
881
919
|
let t, n;
|
|
882
920
|
if (e.startsWith("<")) {
|
|
@@ -906,7 +944,7 @@ function In(e) {
|
|
|
906
944
|
title: r
|
|
907
945
|
};
|
|
908
946
|
}
|
|
909
|
-
function
|
|
947
|
+
function Y(e, t, n, r, i) {
|
|
910
948
|
let a = n.length, o = t + a;
|
|
911
949
|
if (o >= e.length || e[o] === " " || e[o] === " ") return null;
|
|
912
950
|
let s = o;
|
|
@@ -930,7 +968,7 @@ function q(e, t, n, r, i) {
|
|
|
930
968
|
continue;
|
|
931
969
|
}
|
|
932
970
|
return {
|
|
933
|
-
html: r +
|
|
971
|
+
html: r + J(t) + i,
|
|
934
972
|
end: s + a
|
|
935
973
|
};
|
|
936
974
|
}
|
|
@@ -938,13 +976,13 @@ function q(e, t, n, r, i) {
|
|
|
938
976
|
}
|
|
939
977
|
return null;
|
|
940
978
|
}
|
|
941
|
-
var
|
|
942
|
-
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) {
|
|
943
981
|
if (/^ {0,3}<(!--|\?|![A-Za-z]|!\[CDATA\[)/.test(e)) return !0;
|
|
944
982
|
let t = e.match(/^ {0,3}<\/?([a-zA-Z][a-zA-Z0-9-]*)(?:\s|\/?>|$)/);
|
|
945
|
-
return t ?
|
|
983
|
+
return t ? Wn.has(t[1].toLowerCase()) : !1;
|
|
946
984
|
}
|
|
947
|
-
function
|
|
985
|
+
function Kn(e) {
|
|
948
986
|
let t = e.split("\n"), n = [], r = 0, i = !0;
|
|
949
987
|
for (; r < t.length;) {
|
|
950
988
|
let e = t[r];
|
|
@@ -1003,7 +1041,7 @@ function J(e) {
|
|
|
1003
1041
|
continue;
|
|
1004
1042
|
}
|
|
1005
1043
|
}
|
|
1006
|
-
let s =
|
|
1044
|
+
let s = qn(t, r);
|
|
1007
1045
|
if (s) {
|
|
1008
1046
|
n.push(s.token), r = s.nextLine, i = !1;
|
|
1009
1047
|
continue;
|
|
@@ -1059,7 +1097,7 @@ function J(e) {
|
|
|
1059
1097
|
}), i = !1;
|
|
1060
1098
|
continue;
|
|
1061
1099
|
}
|
|
1062
|
-
if (
|
|
1100
|
+
if (Gn(e)) {
|
|
1063
1101
|
let e = [];
|
|
1064
1102
|
for (; r < t.length && t[r].trim() !== "";) e.push(t[r]), r++;
|
|
1065
1103
|
n.push({
|
|
@@ -1071,7 +1109,7 @@ function J(e) {
|
|
|
1071
1109
|
let l = [e];
|
|
1072
1110
|
for (r++; r < t.length;) {
|
|
1073
1111
|
let e = t[r];
|
|
1074
|
-
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;
|
|
1075
1113
|
l.push(e), r++;
|
|
1076
1114
|
}
|
|
1077
1115
|
n.push({
|
|
@@ -1081,15 +1119,15 @@ function J(e) {
|
|
|
1081
1119
|
}
|
|
1082
1120
|
return n;
|
|
1083
1121
|
}
|
|
1084
|
-
function
|
|
1122
|
+
function qn(e, t) {
|
|
1085
1123
|
if (t + 1 >= e.length) return null;
|
|
1086
1124
|
let n = e[t], r = e[t + 1];
|
|
1087
1125
|
if (!r.includes("|") || !/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/.test(r) || !n.includes("|")) return null;
|
|
1088
|
-
let i =
|
|
1126
|
+
let i = Jn(n), a = Yn(r), o = [], s = t + 2;
|
|
1089
1127
|
for (; s < e.length;) {
|
|
1090
1128
|
let t = e[s];
|
|
1091
1129
|
if (!t.includes("|")) break;
|
|
1092
|
-
o.push(
|
|
1130
|
+
o.push(Jn(t)), s++;
|
|
1093
1131
|
}
|
|
1094
1132
|
return {
|
|
1095
1133
|
token: {
|
|
@@ -1101,37 +1139,37 @@ function zn(e, t) {
|
|
|
1101
1139
|
nextLine: s
|
|
1102
1140
|
};
|
|
1103
1141
|
}
|
|
1104
|
-
function
|
|
1142
|
+
function Jn(e) {
|
|
1105
1143
|
let t = e.trim(), n = t.startsWith("|") ? t.substring(1) : t, r = n.endsWith("|") ? n.substring(0, n.length - 1) : n, i = [], a = "";
|
|
1106
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];
|
|
1107
1145
|
return i.push(a.trim()), i;
|
|
1108
1146
|
}
|
|
1109
|
-
function
|
|
1110
|
-
return
|
|
1147
|
+
function Yn(e) {
|
|
1148
|
+
return Jn(e).map((e) => {
|
|
1111
1149
|
let t = e.trim(), n = t.startsWith(":"), r = t.endsWith(":");
|
|
1112
1150
|
return n && r ? "center" : r ? "right" : n ? "left" : null;
|
|
1113
1151
|
});
|
|
1114
1152
|
}
|
|
1115
|
-
function
|
|
1153
|
+
function Xn(e) {
|
|
1116
1154
|
let t = "", n = 0;
|
|
1117
1155
|
for (; n < e.length;) {
|
|
1118
1156
|
let r = e[n];
|
|
1119
1157
|
switch (r.type) {
|
|
1120
1158
|
case "heading": {
|
|
1121
1159
|
let e = r;
|
|
1122
|
-
t += `<h${e.level}>${
|
|
1160
|
+
t += `<h${e.level}>${J(e.content)}</h${e.level}>`, n++;
|
|
1123
1161
|
break;
|
|
1124
1162
|
}
|
|
1125
1163
|
case "paragraph":
|
|
1126
|
-
t += `<p>${
|
|
1164
|
+
t += `<p>${J(r.content)}</p>`, n++;
|
|
1127
1165
|
break;
|
|
1128
1166
|
case "codeBlock": {
|
|
1129
|
-
let e = r, i = e.language ? ` data-language="${
|
|
1130
|
-
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++;
|
|
1131
1169
|
break;
|
|
1132
1170
|
}
|
|
1133
1171
|
case "blockquote": {
|
|
1134
|
-
let e =
|
|
1172
|
+
let e = Xn(Kn(r.content));
|
|
1135
1173
|
t += `<blockquote>${e}</blockquote>`, n++;
|
|
1136
1174
|
break;
|
|
1137
1175
|
}
|
|
@@ -1139,12 +1177,12 @@ function Vn(e) {
|
|
|
1139
1177
|
t += "<hr>", n++;
|
|
1140
1178
|
break;
|
|
1141
1179
|
case "listItem": {
|
|
1142
|
-
let r =
|
|
1180
|
+
let r = Zn(e, n);
|
|
1143
1181
|
t += r.html, n = r.nextIndex;
|
|
1144
1182
|
break;
|
|
1145
1183
|
}
|
|
1146
1184
|
case "table":
|
|
1147
|
-
t +=
|
|
1185
|
+
t += $n(r), n++;
|
|
1148
1186
|
break;
|
|
1149
1187
|
case "rawHtml":
|
|
1150
1188
|
t += r.content, n++;
|
|
@@ -1154,10 +1192,10 @@ function Vn(e) {
|
|
|
1154
1192
|
}
|
|
1155
1193
|
return t;
|
|
1156
1194
|
}
|
|
1157
|
-
function
|
|
1195
|
+
function Zn(e, t) {
|
|
1158
1196
|
let n = "", r = t, i = null;
|
|
1159
1197
|
for (; r < e.length && e[r].type === "listItem";) {
|
|
1160
|
-
let t = e[r], a =
|
|
1198
|
+
let t = e[r], a = Qn(t.listType);
|
|
1161
1199
|
if (i !== null && i !== a && (n += `</${i === "ordered" ? "ol" : "ul"}>`, i = null), i === null) {
|
|
1162
1200
|
if (a === "ordered") {
|
|
1163
1201
|
let e = t.start !== void 0 && t.start !== 1 ? ` start="${t.start}"` : "";
|
|
@@ -1167,11 +1205,11 @@ function Hn(e, t) {
|
|
|
1167
1205
|
}
|
|
1168
1206
|
if (t.listType === "task") {
|
|
1169
1207
|
let e = t.checked ? " checked" : "";
|
|
1170
|
-
n += `<li><input type="checkbox" disabled${e}><p>${
|
|
1171
|
-
} 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>`;
|
|
1172
1210
|
if (t.childContent) {
|
|
1173
|
-
let e =
|
|
1174
|
-
n +=
|
|
1211
|
+
let e = Kn(t.childContent);
|
|
1212
|
+
n += Xn(e);
|
|
1175
1213
|
}
|
|
1176
1214
|
n += "</li>", r++;
|
|
1177
1215
|
}
|
|
@@ -1180,16 +1218,16 @@ function Hn(e, t) {
|
|
|
1180
1218
|
nextIndex: r
|
|
1181
1219
|
};
|
|
1182
1220
|
}
|
|
1183
|
-
function
|
|
1221
|
+
function Qn(e) {
|
|
1184
1222
|
return e === "ordered" ? "ordered" : "bullet";
|
|
1185
1223
|
}
|
|
1186
|
-
function
|
|
1224
|
+
function $n(e) {
|
|
1187
1225
|
let t = "<table>", n = e.headers.every((e) => e.trim() === ""), r = e.headers.length;
|
|
1188
1226
|
if (!n) {
|
|
1189
1227
|
t += "<thead><tr>";
|
|
1190
1228
|
for (let n = 0; n < r; n++) {
|
|
1191
1229
|
let r = e.alignments[n], i = r ? ` align="${r}"` : "";
|
|
1192
|
-
t += `<th${i}>${
|
|
1230
|
+
t += `<th${i}>${J(e.headers[n])}</th>`;
|
|
1193
1231
|
}
|
|
1194
1232
|
t += "</tr></thead>";
|
|
1195
1233
|
}
|
|
@@ -1199,7 +1237,7 @@ function Wn(e) {
|
|
|
1199
1237
|
t += "<tr>";
|
|
1200
1238
|
for (let i = 0; i < r; i++) {
|
|
1201
1239
|
let r = i < n.length ? n[i] : "", a = e.alignments[i], o = a ? ` align="${a}"` : "";
|
|
1202
|
-
t += `<td${o}>${
|
|
1240
|
+
t += `<td${o}>${J(r)}</td>`;
|
|
1203
1241
|
}
|
|
1204
1242
|
t += "</tr>";
|
|
1205
1243
|
}
|
|
@@ -1207,38 +1245,38 @@ function Wn(e) {
|
|
|
1207
1245
|
}
|
|
1208
1246
|
return t += "</table>", t;
|
|
1209
1247
|
}
|
|
1210
|
-
function
|
|
1211
|
-
return
|
|
1248
|
+
function er(e) {
|
|
1249
|
+
return Xn(Kn(e));
|
|
1212
1250
|
}
|
|
1213
1251
|
//#endregion
|
|
1214
1252
|
//#region src/api/parsers/markdown/parseMarkdown.ts
|
|
1215
|
-
function
|
|
1216
|
-
return
|
|
1253
|
+
function tr(e) {
|
|
1254
|
+
return er(e);
|
|
1217
1255
|
}
|
|
1218
|
-
function
|
|
1219
|
-
return
|
|
1256
|
+
function nr(e, t) {
|
|
1257
|
+
return G(tr(e), t);
|
|
1220
1258
|
}
|
|
1221
1259
|
//#endregion
|
|
1222
1260
|
//#region src/editor/managers/ExportManager.ts
|
|
1223
|
-
var
|
|
1261
|
+
var rr = class {
|
|
1224
1262
|
editor;
|
|
1225
1263
|
constructor(e) {
|
|
1226
1264
|
this.editor = e;
|
|
1227
1265
|
}
|
|
1228
1266
|
blocksToHTMLLossy(e = this.editor.document) {
|
|
1229
|
-
return
|
|
1267
|
+
return ve(this.editor.pmSchema, this.editor).exportBlocks(e, {});
|
|
1230
1268
|
}
|
|
1231
1269
|
blocksToFullHTML(e = this.editor.document) {
|
|
1232
|
-
return
|
|
1270
|
+
return Nt(this.editor.pmSchema, this.editor).serializeBlocks(e, {});
|
|
1233
1271
|
}
|
|
1234
1272
|
tryParseHTMLToBlocks(e) {
|
|
1235
|
-
return
|
|
1273
|
+
return G(e, this.editor.pmSchema);
|
|
1236
1274
|
}
|
|
1237
1275
|
blocksToMarkdownLossy(e = this.editor.document) {
|
|
1238
1276
|
return Te(e, this.editor.pmSchema, this.editor, {});
|
|
1239
1277
|
}
|
|
1240
1278
|
tryParseMarkdownToBlocks(e) {
|
|
1241
|
-
return
|
|
1279
|
+
return nr(e, this.editor.pmSchema);
|
|
1242
1280
|
}
|
|
1243
1281
|
pasteHTML(e, t = !1) {
|
|
1244
1282
|
let n = e;
|
|
@@ -1252,39 +1290,42 @@ var Jn = class {
|
|
|
1252
1290
|
return this.editor.prosemirrorView?.pasteText(e);
|
|
1253
1291
|
}
|
|
1254
1292
|
pasteMarkdown(e) {
|
|
1255
|
-
let t =
|
|
1293
|
+
let t = tr(e);
|
|
1256
1294
|
return this.pasteHTML(t);
|
|
1257
1295
|
}
|
|
1258
1296
|
};
|
|
1259
1297
|
//#endregion
|
|
1260
1298
|
//#region src/api/blockManipulation/selections/textCursorPosition.ts
|
|
1261
|
-
function
|
|
1262
|
-
let { bnBlock:
|
|
1263
|
-
return
|
|
1264
|
-
block:
|
|
1265
|
-
prevBlock:
|
|
1266
|
-
nextBlock:
|
|
1267
|
-
parentBlock:
|
|
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;
|
|
1301
|
+
return n.depth > 1 && (a = n.node(), a.type.isInGroup("bnBlock") || (a = n.node(n.depth - 1))), {
|
|
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)
|
|
1268
1306
|
};
|
|
1269
1307
|
}
|
|
1270
|
-
function
|
|
1271
|
-
let
|
|
1272
|
-
if (!o) throw Error(`Block with ID ${
|
|
1273
|
-
let s =
|
|
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;
|
|
1274
1312
|
if (s.isBlockContainer) {
|
|
1275
1313
|
let t = s.blockContent;
|
|
1276
|
-
if (
|
|
1277
|
-
e.setSelection(
|
|
1314
|
+
if (c === "none") {
|
|
1315
|
+
e.setSelection(N.create(e.doc, t.beforePos));
|
|
1278
1316
|
return;
|
|
1279
1317
|
}
|
|
1280
|
-
if (
|
|
1281
|
-
else if (
|
|
1282
|
-
else throw new
|
|
1283
|
-
} 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
|
+
}
|
|
1284
1325
|
}
|
|
1285
1326
|
//#endregion
|
|
1286
1327
|
//#region src/api/clipboard/fromClipboard/acceptedMIMETypes.ts
|
|
1287
|
-
var
|
|
1328
|
+
var X = [
|
|
1288
1329
|
"vscode-editor-data",
|
|
1289
1330
|
"blocknote/html",
|
|
1290
1331
|
"text/markdown",
|
|
@@ -1294,21 +1335,21 @@ var Zn = [
|
|
|
1294
1335
|
];
|
|
1295
1336
|
//#endregion
|
|
1296
1337
|
//#region src/api/clipboard/fromClipboard/handleFileInsertion.ts
|
|
1297
|
-
function
|
|
1338
|
+
function or(e, t) {
|
|
1298
1339
|
if (!e.startsWith(".") || !t.startsWith(".")) throw Error("The strings provided are not valid file extensions.");
|
|
1299
1340
|
return e === t;
|
|
1300
1341
|
}
|
|
1301
|
-
function
|
|
1342
|
+
function sr(e, t) {
|
|
1302
1343
|
let n = e.split("/"), r = t.split("/");
|
|
1303
1344
|
if (n.length !== 2) throw Error(`The string ${e} is not a valid MIME type.`);
|
|
1304
1345
|
if (r.length !== 2) throw Error(`The string ${t} is not a valid MIME type.`);
|
|
1305
1346
|
return n[1] === "*" || r[1] === "*" ? n[0] === r[0] : (n[0] === "*" || r[0] === "*" || n[0] === r[0]) && n[1] === r[1];
|
|
1306
1347
|
}
|
|
1307
|
-
function
|
|
1348
|
+
function cr(e, t, n, r = "after") {
|
|
1308
1349
|
let i;
|
|
1309
1350
|
return i = Array.isArray(t.content) && t.content.length === 0 ? e.updateBlock(t, n).id : e.insertBlocks([n], t, r)[0].id, i;
|
|
1310
1351
|
}
|
|
1311
|
-
async function
|
|
1352
|
+
async function lr(e, t) {
|
|
1312
1353
|
if (!t.uploadFile) {
|
|
1313
1354
|
console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");
|
|
1314
1355
|
return;
|
|
@@ -1316,7 +1357,7 @@ async function tr(e, t) {
|
|
|
1316
1357
|
let n = "dataTransfer" in e ? e.dataTransfer : e.clipboardData;
|
|
1317
1358
|
if (n === null) return;
|
|
1318
1359
|
let r = null;
|
|
1319
|
-
for (let e of
|
|
1360
|
+
for (let e of X) if (n.types.includes(e)) {
|
|
1320
1361
|
r = e;
|
|
1321
1362
|
break;
|
|
1322
1363
|
}
|
|
@@ -1328,7 +1369,7 @@ async function tr(e, t) {
|
|
|
1328
1369
|
let r = "file";
|
|
1329
1370
|
for (let e of Object.values(t.schema.blockSpecs)) for (let t of e.implementation.meta?.fileBlockAccept || []) {
|
|
1330
1371
|
let a = t.startsWith("."), o = i[n].getAsFile();
|
|
1331
|
-
if (o && (!a && o.type &&
|
|
1372
|
+
if (o && (!a && o.type && sr(i[n].type, t) || a && or("." + o.name.split(".").pop(), t))) {
|
|
1332
1373
|
r = e.config.type;
|
|
1333
1374
|
break;
|
|
1334
1375
|
}
|
|
@@ -1341,7 +1382,7 @@ async function tr(e, t) {
|
|
|
1341
1382
|
}, i;
|
|
1342
1383
|
if (e.type === "paste") {
|
|
1343
1384
|
let e = t.getTextCursorPosition().block;
|
|
1344
|
-
i =
|
|
1385
|
+
i = cr(t, e, n);
|
|
1345
1386
|
} else if (e.type === "drop") {
|
|
1346
1387
|
let r = {
|
|
1347
1388
|
left: e.clientX,
|
|
@@ -1349,8 +1390,8 @@ async function tr(e, t) {
|
|
|
1349
1390
|
}, a = t.prosemirrorView.posAtCoords(r);
|
|
1350
1391
|
if (!a) return;
|
|
1351
1392
|
i = t.transact((e) => {
|
|
1352
|
-
let i =
|
|
1353
|
-
if (
|
|
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");
|
|
1354
1395
|
});
|
|
1355
1396
|
} else return;
|
|
1356
1397
|
if (!i) return;
|
|
@@ -1362,23 +1403,23 @@ async function tr(e, t) {
|
|
|
1362
1403
|
}
|
|
1363
1404
|
//#endregion
|
|
1364
1405
|
//#region src/api/clipboard/fromClipboard/fileDropExtension.ts
|
|
1365
|
-
var
|
|
1406
|
+
var ur = (e) => k.create({
|
|
1366
1407
|
name: "dropFile",
|
|
1367
1408
|
addProseMirrorPlugins() {
|
|
1368
|
-
return [new
|
|
1409
|
+
return [new P({ props: { handleDOMEvents: { drop(t, n) {
|
|
1369
1410
|
if (!e.isEditable) return;
|
|
1370
1411
|
let r = null;
|
|
1371
|
-
for (let e of
|
|
1412
|
+
for (let e of X) if (n.dataTransfer.types.includes(e)) {
|
|
1372
1413
|
r = e;
|
|
1373
1414
|
break;
|
|
1374
1415
|
}
|
|
1375
|
-
return r === null
|
|
1416
|
+
return r === null || r === "Files" && (lr(n, e), !0);
|
|
1376
1417
|
} } } })];
|
|
1377
1418
|
}
|
|
1378
|
-
}),
|
|
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);
|
|
1379
1420
|
//#endregion
|
|
1380
1421
|
//#region src/api/clipboard/fromClipboard/handleVSCodePaste.ts
|
|
1381
|
-
function
|
|
1422
|
+
function Tr(e, t) {
|
|
1382
1423
|
let { schema: n } = t.state;
|
|
1383
1424
|
if (!e.clipboardData) return !1;
|
|
1384
1425
|
let r = e.clipboardData.getData("text/plain");
|
|
@@ -1388,39 +1429,39 @@ function _r(e, t) {
|
|
|
1388
1429
|
}
|
|
1389
1430
|
//#endregion
|
|
1390
1431
|
//#region src/api/clipboard/fromClipboard/pasteExtension.ts
|
|
1391
|
-
function
|
|
1432
|
+
function Er({ event: e, editor: t, prioritizeMarkdownOverHTML: n, plainTextAsMarkdown: r }) {
|
|
1392
1433
|
if (t.transact((e) => e.selection.$from.parent.type.spec.code && e.selection.$to.parent.type.spec.code)) {
|
|
1393
1434
|
let n = e.clipboardData?.getData("text/plain");
|
|
1394
1435
|
if (n) return t.pasteText(n), !0;
|
|
1395
1436
|
}
|
|
1396
1437
|
let i;
|
|
1397
|
-
for (let t of
|
|
1438
|
+
for (let t of X) if (e.clipboardData.types.includes(t)) {
|
|
1398
1439
|
i = t;
|
|
1399
1440
|
break;
|
|
1400
1441
|
}
|
|
1401
1442
|
if (!i) return !0;
|
|
1402
1443
|
if (i === "vscode-editor-data") {
|
|
1403
|
-
if (
|
|
1444
|
+
if (Tr(e, t.prosemirrorView)) return !0;
|
|
1404
1445
|
i = "text/plain";
|
|
1405
1446
|
}
|
|
1406
|
-
if (i === "Files") return
|
|
1447
|
+
if (i === "Files") return lr(e, t), !0;
|
|
1407
1448
|
let a = e.clipboardData.getData(i);
|
|
1408
1449
|
if (i === "blocknote/html") return t.pasteHTML(a, !0), !0;
|
|
1409
1450
|
if (i === "text/markdown") return t.pasteMarkdown(a), !0;
|
|
1410
1451
|
if (n) {
|
|
1411
1452
|
let n = e.clipboardData.getData("text/plain");
|
|
1412
|
-
if (
|
|
1453
|
+
if (wr(n)) return t.pasteMarkdown(n), !0;
|
|
1413
1454
|
}
|
|
1414
1455
|
return i === "text/html" ? (t.pasteHTML(a), !0) : r ? (t.pasteMarkdown(a), !0) : (t.pasteText(a), !0);
|
|
1415
1456
|
}
|
|
1416
|
-
var
|
|
1457
|
+
var Dr = (e, t) => k.create({
|
|
1417
1458
|
name: "pasteFromClipboard",
|
|
1418
1459
|
addProseMirrorPlugins() {
|
|
1419
|
-
return [new
|
|
1460
|
+
return [new P({ props: { handleDOMEvents: { paste(n, r) {
|
|
1420
1461
|
if (r.preventDefault(), e.isEditable) return t({
|
|
1421
1462
|
event: r,
|
|
1422
1463
|
editor: e,
|
|
1423
|
-
defaultPasteHandler: ({ prioritizeMarkdownOverHTML: t = !0, plainTextAsMarkdown: n = !0 } = {}) =>
|
|
1464
|
+
defaultPasteHandler: ({ prioritizeMarkdownOverHTML: t = !0, plainTextAsMarkdown: n = !0 } = {}) => Er({
|
|
1424
1465
|
event: r,
|
|
1425
1466
|
editor: e,
|
|
1426
1467
|
prioritizeMarkdownOverHTML: t,
|
|
@@ -1432,37 +1473,37 @@ var yr = (e, t) => D.create({
|
|
|
1432
1473
|
});
|
|
1433
1474
|
//#endregion
|
|
1434
1475
|
//#region src/api/clipboard/toClipboard/copyExtension.ts
|
|
1435
|
-
function
|
|
1436
|
-
let
|
|
1437
|
-
if (!
|
|
1438
|
-
let
|
|
1439
|
-
for (let e = 0; e <
|
|
1440
|
-
|
|
1441
|
-
}
|
|
1442
|
-
let
|
|
1443
|
-
if (
|
|
1444
|
-
|
|
1445
|
-
let e =
|
|
1446
|
-
|
|
1447
|
-
} else if (
|
|
1448
|
-
let e =
|
|
1449
|
-
|
|
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, {});
|
|
1450
1491
|
} else {
|
|
1451
|
-
let e =
|
|
1452
|
-
|
|
1492
|
+
let e = Pe(n);
|
|
1493
|
+
o = s.exportBlocks(e, {});
|
|
1453
1494
|
}
|
|
1454
|
-
return
|
|
1495
|
+
return o;
|
|
1455
1496
|
}
|
|
1456
|
-
function
|
|
1457
|
-
"node" in e.state.selection && e.state.selection.node.type.spec.group === "blockContent" && t.transact((t) => t.setSelection(new
|
|
1458
|
-
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];
|
|
1459
1500
|
return {
|
|
1460
1501
|
clipboardHTML: n,
|
|
1461
1502
|
externalHTML: i,
|
|
1462
|
-
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)
|
|
1463
1504
|
};
|
|
1464
1505
|
}
|
|
1465
|
-
var
|
|
1506
|
+
var Ar = (e) => {
|
|
1466
1507
|
if (e.state.selection.empty) return !0;
|
|
1467
1508
|
let t = window.getSelection();
|
|
1468
1509
|
if (t && !t.isCollapsed) {
|
|
@@ -1473,37 +1514,37 @@ var Sr = (e) => {
|
|
|
1473
1514
|
}
|
|
1474
1515
|
}
|
|
1475
1516
|
return !1;
|
|
1476
|
-
},
|
|
1517
|
+
}, jr = (e, t, n) => {
|
|
1477
1518
|
n.preventDefault(), n.clipboardData.clearData();
|
|
1478
|
-
let { clipboardHTML: r, externalHTML: i, markdown: a } =
|
|
1519
|
+
let { clipboardHTML: r, externalHTML: i, markdown: a } = kr(t, e);
|
|
1479
1520
|
n.clipboardData.setData("blocknote/html", r), n.clipboardData.setData("text/html", i), n.clipboardData.setData("text/plain", a);
|
|
1480
|
-
},
|
|
1521
|
+
}, Mr = (e) => k.create({
|
|
1481
1522
|
name: "copyToClipboard",
|
|
1482
1523
|
addProseMirrorPlugins() {
|
|
1483
|
-
return [new
|
|
1524
|
+
return [new P({ props: { handleDOMEvents: {
|
|
1484
1525
|
copy(t, n) {
|
|
1485
|
-
return
|
|
1526
|
+
return Ar(t) || jr(e, t, n), !0;
|
|
1486
1527
|
},
|
|
1487
1528
|
cut(t, n) {
|
|
1488
|
-
return
|
|
1529
|
+
return Ar(t) ? !0 : (jr(e, t, n), t.editable && t.dispatch(t.state.tr.deleteSelection()), !0);
|
|
1489
1530
|
},
|
|
1490
1531
|
dragstart(t, n) {
|
|
1491
1532
|
if (!("node" in t.state.selection) || t.state.selection.node.type.spec.group !== "blockContent") return;
|
|
1492
|
-
e.transact((e) => e.setSelection(new
|
|
1493
|
-
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);
|
|
1494
1535
|
return n.dataTransfer.setData("blocknote/html", r), n.dataTransfer.setData("text/html", i), n.dataTransfer.setData("text/plain", a), !0;
|
|
1495
1536
|
}
|
|
1496
1537
|
} } })];
|
|
1497
1538
|
}
|
|
1498
|
-
}),
|
|
1539
|
+
}), Nr = k.create({
|
|
1499
1540
|
name: "blockBackgroundColor",
|
|
1500
1541
|
addGlobalAttributes() {
|
|
1501
1542
|
return [{
|
|
1502
1543
|
types: ["tableCell", "tableHeader"],
|
|
1503
|
-
attributes: { backgroundColor:
|
|
1544
|
+
attributes: { backgroundColor: ue() }
|
|
1504
1545
|
}];
|
|
1505
1546
|
}
|
|
1506
|
-
}),
|
|
1547
|
+
}), Pr = A.create({
|
|
1507
1548
|
name: "hardBreak",
|
|
1508
1549
|
inline: !0,
|
|
1509
1550
|
group: "inline",
|
|
@@ -1514,33 +1555,33 @@ var Sr = (e) => {
|
|
|
1514
1555
|
return [{ tag: "br" }];
|
|
1515
1556
|
},
|
|
1516
1557
|
renderHTML({ HTMLAttributes: e }) {
|
|
1517
|
-
return ["br",
|
|
1558
|
+
return ["br", M(this.options.HTMLAttributes, e)];
|
|
1518
1559
|
},
|
|
1519
1560
|
renderText() {
|
|
1520
1561
|
return "\n";
|
|
1521
1562
|
}
|
|
1522
|
-
}),
|
|
1563
|
+
}), Fr = (e, t) => {
|
|
1523
1564
|
let n = e.resolve(t), r = n.depth - 1;
|
|
1524
1565
|
if (r < 1) return;
|
|
1525
1566
|
let i = n.before(r), a = e.resolve(i).nodeAfter;
|
|
1526
|
-
if (a) return a.type.spec.group?.includes("bnBlock") ?
|
|
1527
|
-
},
|
|
1567
|
+
if (a) return a.type.spec.group?.includes("bnBlock") ? S(e.resolve(i)) : Fr(e, i);
|
|
1568
|
+
}, Z = (e, t) => {
|
|
1528
1569
|
let n = e.resolve(t), r = n.index();
|
|
1529
1570
|
if (r === 0) return;
|
|
1530
1571
|
let i = n.posAtIndex(r - 1);
|
|
1531
|
-
return
|
|
1532
|
-
},
|
|
1572
|
+
return S(e.resolve(i));
|
|
1573
|
+
}, Q = (e, t) => {
|
|
1533
1574
|
let n = e.resolve(t), r = n.index();
|
|
1534
1575
|
if (r === n.node().childCount - 1) return;
|
|
1535
1576
|
let i = n.posAtIndex(r + 1);
|
|
1536
|
-
return
|
|
1537
|
-
},
|
|
1577
|
+
return S(e.resolve(i));
|
|
1578
|
+
}, Ir = (e, t) => {
|
|
1538
1579
|
for (; t.childContainer;) {
|
|
1539
1580
|
let n = t.childContainer.node, r = e.resolve(t.childContainer.beforePos + 1).posAtIndex(n.childCount - 1);
|
|
1540
|
-
t =
|
|
1581
|
+
t = S(e.resolve(r));
|
|
1541
1582
|
}
|
|
1542
1583
|
return t;
|
|
1543
|
-
},
|
|
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) => {
|
|
1544
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`);
|
|
1545
1586
|
if (r.childContainer) {
|
|
1546
1587
|
let n = e.doc.resolve(r.childContainer.beforePos + 1), i = e.doc.resolve(r.childContainer.afterPos - 1), a = n.blockRange(i);
|
|
@@ -1554,70 +1595,70 @@ var Sr = (e) => {
|
|
|
1554
1595
|
t(e.tr.delete(n.blockContent.afterPos - 1, r.blockContent.beforePos + 1));
|
|
1555
1596
|
}
|
|
1556
1597
|
return !0;
|
|
1557
|
-
},
|
|
1558
|
-
let r =
|
|
1559
|
-
if (!
|
|
1560
|
-
let
|
|
1561
|
-
return
|
|
1562
|
-
},
|
|
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({
|
|
1563
1604
|
priority: 50,
|
|
1564
1605
|
addKeyboardShortcuts() {
|
|
1565
|
-
let
|
|
1566
|
-
() =>
|
|
1567
|
-
() =>
|
|
1568
|
-
() =>
|
|
1569
|
-
let
|
|
1570
|
-
if (!
|
|
1571
|
-
let
|
|
1572
|
-
return
|
|
1606
|
+
let e = () => this.editor.commands.first(({ chain: e, commands: t }) => [
|
|
1607
|
+
() => t.deleteSelection(),
|
|
1608
|
+
() => t.undoInputRule(),
|
|
1609
|
+
() => t.command(({ state: e }) => {
|
|
1610
|
+
let n = w(e);
|
|
1611
|
+
if (!n.isBlockContainer) return !1;
|
|
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, {
|
|
1573
1614
|
type: "paragraph",
|
|
1574
1615
|
props: {}
|
|
1575
1616
|
})) : !1;
|
|
1576
1617
|
}),
|
|
1577
|
-
() =>
|
|
1578
|
-
let
|
|
1579
|
-
if (!
|
|
1580
|
-
let { blockContent:
|
|
1581
|
-
return
|
|
1618
|
+
() => t.command(({ state: e, tr: t }) => {
|
|
1619
|
+
let n = w(e);
|
|
1620
|
+
if (!n.isBlockContainer) return !1;
|
|
1621
|
+
let { blockContent: r } = n;
|
|
1622
|
+
return e.selection.from === r.beforePos + 1 && W(t, t.doc.type.schema.nodes.blockContainer, t.doc.type.schema.nodes.blockGroup);
|
|
1582
1623
|
}),
|
|
1583
|
-
() =>
|
|
1584
|
-
let
|
|
1585
|
-
if (!
|
|
1586
|
-
let { bnBlock:
|
|
1587
|
-
if (!
|
|
1588
|
-
let
|
|
1589
|
-
return
|
|
1624
|
+
() => t.command(({ state: t }) => {
|
|
1625
|
+
let n = w(t);
|
|
1626
|
+
if (!n.isBlockContainer) return !1;
|
|
1627
|
+
let { bnBlock: r, blockContent: i } = n, a = Z(t.doc, n.bnBlock.beforePos);
|
|
1628
|
+
if (!a || !a.isBlockContainer || a.blockContent.node.type.spec.content !== "inline*") return !1;
|
|
1629
|
+
let o = t.selection.from === i.beforePos + 1, s = t.selection.empty, c = r.beforePos;
|
|
1630
|
+
return o && s ? e().command(zr(c)).scrollIntoView().run() : !1;
|
|
1590
1631
|
}),
|
|
1591
|
-
() =>
|
|
1592
|
-
let
|
|
1593
|
-
if (!
|
|
1594
|
-
let
|
|
1595
|
-
if (!
|
|
1596
|
-
if (
|
|
1597
|
-
let e =
|
|
1598
|
-
return
|
|
1632
|
+
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1633
|
+
let r = w(e);
|
|
1634
|
+
if (!r.isBlockContainer || e.selection.from !== r.blockContent.beforePos + 1) return !1;
|
|
1635
|
+
let i = Z(e.doc, r.bnBlock.beforePos);
|
|
1636
|
+
if (!i || i.isBlockContainer) return !1;
|
|
1637
|
+
if (n) {
|
|
1638
|
+
let e = i.bnBlock.afterPos - 1, n = t.doc.resolve(e - 1);
|
|
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;
|
|
1599
1640
|
}
|
|
1600
1641
|
return !1;
|
|
1601
1642
|
}),
|
|
1602
|
-
() =>
|
|
1603
|
-
let
|
|
1604
|
-
if (!
|
|
1605
|
-
let
|
|
1606
|
-
if (
|
|
1607
|
-
let
|
|
1608
|
-
return
|
|
1643
|
+
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1644
|
+
let r = w(e);
|
|
1645
|
+
if (!r.isBlockContainer || t.selection.from !== r.blockContent.beforePos + 1) return !1;
|
|
1646
|
+
let i = t.doc.resolve(r.bnBlock.beforePos);
|
|
1647
|
+
if (i.nodeBefore || i.node().type.name !== "column") return !1;
|
|
1648
|
+
let a = t.doc.resolve(r.bnBlock.beforePos), o = t.doc.resolve(a.before()), s = o.before();
|
|
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;
|
|
1609
1650
|
}),
|
|
1610
|
-
() =>
|
|
1611
|
-
let
|
|
1612
|
-
if (!
|
|
1613
|
-
if (
|
|
1614
|
-
let
|
|
1615
|
-
if (!
|
|
1616
|
-
let i =
|
|
1651
|
+
() => t.command(({ state: t }) => {
|
|
1652
|
+
let n = w(t);
|
|
1653
|
+
if (!n.isBlockContainer) return !1;
|
|
1654
|
+
if (n.blockContent.node.childCount === 0 && n.blockContent.node.type.spec.content === "inline*") {
|
|
1655
|
+
let r = Z(t.doc, n.bnBlock.beforePos);
|
|
1656
|
+
if (!r) return !1;
|
|
1657
|
+
let i = Ir(t.doc, r);
|
|
1617
1658
|
if (!i.isBlockContainer || !i || !i.isBlockContainer) return !1;
|
|
1618
|
-
let a =
|
|
1619
|
-
if (
|
|
1620
|
-
let e =
|
|
1659
|
+
let a = e();
|
|
1660
|
+
if (n.childContainer && a.insertContentAt(n.bnBlock.afterPos, n.childContainer?.node.content), i.blockContent.node.type.spec.content === "tableRow+") {
|
|
1661
|
+
let e = n.bnBlock.beforePos - 1 - 1 - 1 - 1 - 1;
|
|
1621
1662
|
a = a.setTextSelection(e);
|
|
1622
1663
|
} else if (i.blockContent.node.type.spec.content === "") a = a.setNodeSelection(i.blockContent.beforePos);
|
|
1623
1664
|
else {
|
|
@@ -1625,175 +1666,176 @@ var Sr = (e) => {
|
|
|
1625
1666
|
a = a.setTextSelection(e);
|
|
1626
1667
|
}
|
|
1627
1668
|
return a.deleteRange({
|
|
1628
|
-
from:
|
|
1629
|
-
to:
|
|
1669
|
+
from: n.bnBlock.beforePos,
|
|
1670
|
+
to: n.bnBlock.afterPos
|
|
1630
1671
|
}).scrollIntoView().run();
|
|
1631
1672
|
}
|
|
1632
1673
|
return !1;
|
|
1633
1674
|
}),
|
|
1634
|
-
() =>
|
|
1635
|
-
let
|
|
1636
|
-
if (!
|
|
1637
|
-
let
|
|
1638
|
-
if (
|
|
1639
|
-
let
|
|
1640
|
-
if (!
|
|
1641
|
-
if (
|
|
1675
|
+
() => t.command(({ state: t }) => {
|
|
1676
|
+
let n = w(t);
|
|
1677
|
+
if (!n.isBlockContainer) return !1;
|
|
1678
|
+
let r = t.selection.from === n.blockContent.beforePos + 1, i = t.selection.empty, a = Z(t.doc, n.bnBlock.beforePos);
|
|
1679
|
+
if (a && r && i) {
|
|
1680
|
+
let r = Ir(t.doc, a);
|
|
1681
|
+
if (!r.isBlockContainer) return !1;
|
|
1682
|
+
if (r.blockContent.node.type.spec.content === "" || r.blockContent.node.type.spec.content === "inline*" && r.blockContent.node.childCount === 0) return e().cut({
|
|
1683
|
+
from: n.bnBlock.beforePos,
|
|
1684
|
+
to: n.bnBlock.afterPos
|
|
1685
|
+
}, r.bnBlock.afterPos).deleteRange({
|
|
1642
1686
|
from: r.bnBlock.beforePos,
|
|
1643
1687
|
to: r.bnBlock.afterPos
|
|
1644
|
-
}, e.bnBlock.afterPos).deleteRange({
|
|
1645
|
-
from: e.bnBlock.beforePos,
|
|
1646
|
-
to: e.bnBlock.afterPos
|
|
1647
1688
|
}).run();
|
|
1648
1689
|
}
|
|
1649
1690
|
return !1;
|
|
1650
1691
|
})
|
|
1651
|
-
]),
|
|
1652
|
-
() =>
|
|
1653
|
-
() =>
|
|
1654
|
-
let
|
|
1655
|
-
if (!
|
|
1656
|
-
let { blockContent:
|
|
1657
|
-
if (!
|
|
1658
|
-
if (
|
|
1659
|
-
let
|
|
1660
|
-
return
|
|
1661
|
-
from:
|
|
1662
|
-
to:
|
|
1692
|
+
]), t = () => this.editor.commands.first(({ chain: e, commands: t }) => [
|
|
1693
|
+
() => t.deleteSelection(),
|
|
1694
|
+
() => t.command(({ state: t }) => {
|
|
1695
|
+
let n = w(t);
|
|
1696
|
+
if (!n.isBlockContainer || !n.childContainer) return !1;
|
|
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));
|
|
1698
|
+
if (!s.isBlockContainer) return !1;
|
|
1699
|
+
if (a && o) {
|
|
1700
|
+
let n = s.blockContent.node, a = n.type.spec.content === "inline*", o = r.node.type.spec.content === "inline*";
|
|
1701
|
+
return e().insertContentAt(s.bnBlock.afterPos, s.childContainer?.node.content || E.empty).deleteRange(i.node.childCount === 1 ? {
|
|
1702
|
+
from: i.beforePos,
|
|
1703
|
+
to: i.afterPos
|
|
1663
1704
|
} : {
|
|
1664
|
-
from:
|
|
1665
|
-
to:
|
|
1666
|
-
}).insertContentAt(
|
|
1705
|
+
from: s.bnBlock.beforePos,
|
|
1706
|
+
to: s.bnBlock.afterPos
|
|
1707
|
+
}).insertContentAt(t.selection.from, a && o ? n.content : null).setTextSelection(t.selection.from).scrollIntoView().run();
|
|
1667
1708
|
}
|
|
1668
1709
|
return !1;
|
|
1669
1710
|
}),
|
|
1670
|
-
() =>
|
|
1671
|
-
let
|
|
1672
|
-
if (!
|
|
1673
|
-
let { bnBlock:
|
|
1674
|
-
if (!
|
|
1675
|
-
let
|
|
1676
|
-
return
|
|
1711
|
+
() => t.command(({ state: t }) => {
|
|
1712
|
+
let n = w(t);
|
|
1713
|
+
if (!n.isBlockContainer) return !1;
|
|
1714
|
+
let { bnBlock: r, blockContent: i } = n, a = Q(t.doc, n.bnBlock.beforePos);
|
|
1715
|
+
if (!a || !a.isBlockContainer) return !1;
|
|
1716
|
+
let o = t.selection.from === i.afterPos - 1, s = t.selection.empty, c = r.afterPos;
|
|
1717
|
+
return o && s ? e().command(zr(c)).scrollIntoView().run() : !1;
|
|
1677
1718
|
}),
|
|
1678
|
-
() =>
|
|
1679
|
-
let
|
|
1680
|
-
if (!
|
|
1681
|
-
let
|
|
1682
|
-
if (!
|
|
1683
|
-
if (
|
|
1684
|
-
let e =
|
|
1685
|
-
return
|
|
1719
|
+
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1720
|
+
let r = w(e);
|
|
1721
|
+
if (!r.isBlockContainer || e.selection.from !== r.blockContent.afterPos - 1) return !1;
|
|
1722
|
+
let i = Q(e.doc, r.bnBlock.beforePos);
|
|
1723
|
+
if (!i || i.isBlockContainer) return !1;
|
|
1724
|
+
if (n) {
|
|
1725
|
+
let e = i.bnBlock.beforePos + 1, n = t.doc.resolve(e + 1);
|
|
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;
|
|
1686
1727
|
}
|
|
1687
1728
|
return !1;
|
|
1688
1729
|
}),
|
|
1689
|
-
() =>
|
|
1690
|
-
let
|
|
1691
|
-
if (!
|
|
1692
|
-
let
|
|
1693
|
-
if (
|
|
1694
|
-
let
|
|
1695
|
-
if (
|
|
1696
|
-
let e =
|
|
1697
|
-
|
|
1730
|
+
() => t.command(({ state: e, tr: t, dispatch: n }) => {
|
|
1731
|
+
let r = w(e);
|
|
1732
|
+
if (!r.isBlockContainer || t.selection.from !== r.blockContent.afterPos - 1) return !1;
|
|
1733
|
+
let i = t.doc.resolve(r.bnBlock.afterPos);
|
|
1734
|
+
if (i.nodeAfter || i.node().type.name !== "column") return !1;
|
|
1735
|
+
let a = t.doc.resolve(r.bnBlock.afterPos), o = t.doc.resolve(a.after()), s = o.after();
|
|
1736
|
+
if (n) {
|
|
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)));
|
|
1698
1739
|
}
|
|
1699
1740
|
return !0;
|
|
1700
1741
|
}),
|
|
1701
|
-
() =>
|
|
1702
|
-
let
|
|
1703
|
-
if (!
|
|
1704
|
-
let { blockContent:
|
|
1705
|
-
if (
|
|
1706
|
-
let
|
|
1707
|
-
let
|
|
1708
|
-
if (
|
|
1709
|
-
let
|
|
1710
|
-
if (
|
|
1711
|
-
}, a =
|
|
1742
|
+
() => t.command(({ state: t }) => {
|
|
1743
|
+
let n = w(t);
|
|
1744
|
+
if (!n.isBlockContainer) return !1;
|
|
1745
|
+
let { blockContent: r } = n, i = t.selection.from === r.afterPos - 1, a = t.selection.empty;
|
|
1746
|
+
if (i && a) {
|
|
1747
|
+
let i = (e, t) => {
|
|
1748
|
+
let n = Q(e, t);
|
|
1749
|
+
if (n) return n;
|
|
1750
|
+
let r = Fr(e, t);
|
|
1751
|
+
if (r) return i(e, r.bnBlock.beforePos);
|
|
1752
|
+
}, a = i(t.doc, n.bnBlock.beforePos);
|
|
1712
1753
|
if (!a || !a.isBlockContainer) return !1;
|
|
1713
|
-
let o = a.blockContent.node, s = o.type.spec.content === "inline*", c =
|
|
1714
|
-
return
|
|
1754
|
+
let o = a.blockContent.node, s = o.type.spec.content === "inline*", c = r.node.type.spec.content === "inline*";
|
|
1755
|
+
return e().insertContentAt(a.bnBlock.afterPos, a.childContainer?.node.content || E.empty).deleteRange({
|
|
1715
1756
|
from: a.bnBlock.beforePos,
|
|
1716
1757
|
to: a.bnBlock.afterPos
|
|
1717
|
-
}).insertContentAt(
|
|
1758
|
+
}).insertContentAt(t.selection.from, s && c ? o.content : null).setTextSelection(t.selection.from).scrollIntoView().run();
|
|
1718
1759
|
}
|
|
1719
1760
|
return !1;
|
|
1720
1761
|
}),
|
|
1721
|
-
() =>
|
|
1722
|
-
let
|
|
1723
|
-
if (!
|
|
1724
|
-
if (
|
|
1725
|
-
let
|
|
1726
|
-
if (!
|
|
1727
|
-
let i =
|
|
1728
|
-
if (
|
|
1729
|
-
let e =
|
|
1762
|
+
() => t.command(({ state: t }) => {
|
|
1763
|
+
let n = w(t);
|
|
1764
|
+
if (!n.isBlockContainer) return !1;
|
|
1765
|
+
if (n.blockContent.node.childCount === 0 && n.blockContent.node.type.spec.content === "inline*") {
|
|
1766
|
+
let r = Q(t.doc, n.bnBlock.beforePos);
|
|
1767
|
+
if (!r || !r.isBlockContainer) return !1;
|
|
1768
|
+
let i = e();
|
|
1769
|
+
if (r.blockContent.node.type.spec.content === "tableRow+") {
|
|
1770
|
+
let e = n.bnBlock.afterPos + 1 + 1 + 1 + 1 + 1;
|
|
1730
1771
|
i = i.setTextSelection(e);
|
|
1731
|
-
} else i =
|
|
1772
|
+
} else i = r.blockContent.node.type.spec.content === "" ? i.setNodeSelection(r.blockContent.beforePos) : i.setTextSelection(r.blockContent.beforePos + 1);
|
|
1732
1773
|
return i.deleteRange({
|
|
1733
|
-
from:
|
|
1734
|
-
to:
|
|
1774
|
+
from: n.bnBlock.beforePos,
|
|
1775
|
+
to: n.bnBlock.afterPos
|
|
1735
1776
|
}).scrollIntoView().run();
|
|
1736
1777
|
}
|
|
1737
1778
|
return !1;
|
|
1738
1779
|
}),
|
|
1739
|
-
() =>
|
|
1740
|
-
let
|
|
1741
|
-
if (!
|
|
1742
|
-
let
|
|
1743
|
-
if (!
|
|
1744
|
-
if (
|
|
1745
|
-
let
|
|
1746
|
-
return
|
|
1747
|
-
from:
|
|
1748
|
-
to:
|
|
1749
|
-
}).insertContentAt(
|
|
1780
|
+
() => t.command(({ state: t }) => {
|
|
1781
|
+
let n = w(t);
|
|
1782
|
+
if (!n.isBlockContainer) return !1;
|
|
1783
|
+
let r = t.selection.from === n.blockContent.afterPos - 1, i = t.selection.empty, a = Q(t.doc, n.bnBlock.beforePos);
|
|
1784
|
+
if (!a || !a.isBlockContainer) return !1;
|
|
1785
|
+
if (a && r && i && (a.blockContent.node.type.spec.content === "" || a.blockContent.node.type.spec.content === "inline*" && a.blockContent.node.childCount === 0)) {
|
|
1786
|
+
let t = a.bnBlock.node.lastChild.content;
|
|
1787
|
+
return e().deleteRange({
|
|
1788
|
+
from: a.bnBlock.beforePos,
|
|
1789
|
+
to: a.bnBlock.afterPos
|
|
1790
|
+
}).insertContentAt(n.bnBlock.afterPos, a.bnBlock.node.childCount === 2 ? t : null).run();
|
|
1750
1791
|
}
|
|
1751
1792
|
return !1;
|
|
1752
1793
|
})
|
|
1753
|
-
]),
|
|
1754
|
-
() =>
|
|
1755
|
-
let
|
|
1756
|
-
if (!
|
|
1757
|
-
let { bnBlock:
|
|
1758
|
-
return
|
|
1794
|
+
]), n = (e = !1) => this.editor.commands.first(({ commands: t, tr: n }) => [
|
|
1795
|
+
() => t.command(({ state: e, tr: t }) => {
|
|
1796
|
+
let n = w(e);
|
|
1797
|
+
if (!n.isBlockContainer) return !1;
|
|
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;
|
|
1799
|
+
return o && s && c && a > 1 ? W(t, t.doc.type.schema.nodes.blockContainer, t.doc.type.schema.nodes.blockGroup) : !1;
|
|
1759
1800
|
}),
|
|
1760
|
-
() =>
|
|
1761
|
-
let
|
|
1801
|
+
() => t.command(({ state: t }) => {
|
|
1802
|
+
let r = w(t), i = this.options.editor.schema.blockSpecs[r.blockNoteType], a = i?.implementation?.meta?.hardBreakShortcut ?? "shift+enter";
|
|
1762
1803
|
if (a === "none") return !1;
|
|
1763
|
-
if (a === "shift+enter" &&
|
|
1764
|
-
|
|
1765
|
-
|
|
1804
|
+
if (a === "shift+enter" && e || a === "enter") {
|
|
1805
|
+
if (i?.config?.content === "plain") return n.insertText("\n", n.selection.head), !0;
|
|
1806
|
+
let e = n.storedMarks || n.selection.$head.marks().filter((e) => this.editor.extensionManager.splittableMarks.includes(e.type.name));
|
|
1807
|
+
return n.insert(n.selection.head, n.doc.type.schema.nodes.hardBreak.create()).ensureMarks(e), !0;
|
|
1766
1808
|
}
|
|
1767
1809
|
return !1;
|
|
1768
1810
|
}),
|
|
1769
|
-
() =>
|
|
1770
|
-
let
|
|
1771
|
-
if (!
|
|
1772
|
-
let { bnBlock:
|
|
1773
|
-
if (
|
|
1774
|
-
let
|
|
1775
|
-
if (
|
|
1776
|
-
let
|
|
1777
|
-
|
|
1811
|
+
() => t.command(({ state: e, dispatch: t, tr: n }) => {
|
|
1812
|
+
let r = w(e);
|
|
1813
|
+
if (!r.isBlockContainer) return !1;
|
|
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;
|
|
1815
|
+
if (o && s && c) {
|
|
1816
|
+
let a = i.afterPos, o = a + 2;
|
|
1817
|
+
if (t) {
|
|
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));
|
|
1819
|
+
n.insert(a, t).setSelection(new F(n.doc.resolve(o))).scrollIntoView(), r.childContainer && n.delete(r.childContainer.beforePos, r.childContainer.afterPos);
|
|
1778
1820
|
}
|
|
1779
1821
|
return !0;
|
|
1780
1822
|
}
|
|
1781
1823
|
return !1;
|
|
1782
1824
|
}),
|
|
1783
|
-
() =>
|
|
1784
|
-
let
|
|
1785
|
-
if (!
|
|
1786
|
-
let { blockContent:
|
|
1787
|
-
return
|
|
1825
|
+
() => t.command(({ state: e, chain: t }) => {
|
|
1826
|
+
let n = w(e);
|
|
1827
|
+
if (!n.isBlockContainer) return !1;
|
|
1828
|
+
let { blockContent: r } = n, i = e.selection.$anchor.parentOffset === 0;
|
|
1829
|
+
return r.node.childCount !== 0 && (t().deleteSelection().command(o(e.selection.from, i, i)).scrollIntoView().run(), !0);
|
|
1788
1830
|
})
|
|
1789
1831
|
]);
|
|
1790
1832
|
return {
|
|
1791
|
-
Backspace:
|
|
1792
|
-
Delete:
|
|
1793
|
-
Enter: () =>
|
|
1794
|
-
"Shift-Enter": () =>
|
|
1795
|
-
Tab: () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(
|
|
1796
|
-
"Shift-Tab": () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(
|
|
1833
|
+
Backspace: e,
|
|
1834
|
+
Delete: t,
|
|
1835
|
+
Enter: () => n(),
|
|
1836
|
+
"Shift-Enter": () => n(!0),
|
|
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),
|
|
1797
1839
|
"Shift-Mod-ArrowUp": () => (this.options.editor.moveBlocksUp(), !0),
|
|
1798
1840
|
"Shift-Mod-ArrowDown": () => (this.options.editor.moveBlocksDown(), !0),
|
|
1799
1841
|
"Mod-z": () => this.options.editor.undo(),
|
|
@@ -1801,7 +1843,7 @@ var Sr = (e) => {
|
|
|
1801
1843
|
"Shift-Mod-z": () => this.options.editor.redo()
|
|
1802
1844
|
};
|
|
1803
1845
|
}
|
|
1804
|
-
}),
|
|
1846
|
+
}), Vr = k.create({
|
|
1805
1847
|
name: "textAlignment",
|
|
1806
1848
|
addGlobalAttributes() {
|
|
1807
1849
|
return [{
|
|
@@ -1813,7 +1855,7 @@ var Sr = (e) => {
|
|
|
1813
1855
|
} }
|
|
1814
1856
|
}];
|
|
1815
1857
|
}
|
|
1816
|
-
}),
|
|
1858
|
+
}), Hr = k.create({
|
|
1817
1859
|
name: "blockTextColor",
|
|
1818
1860
|
addGlobalAttributes() {
|
|
1819
1861
|
return [{
|
|
@@ -1822,13 +1864,13 @@ var Sr = (e) => {
|
|
|
1822
1864
|
"tableCell",
|
|
1823
1865
|
"tableHeader"
|
|
1824
1866
|
],
|
|
1825
|
-
attributes: { textColor:
|
|
1867
|
+
attributes: { textColor: i() }
|
|
1826
1868
|
}];
|
|
1827
1869
|
}
|
|
1828
|
-
}),
|
|
1870
|
+
}), Ur = "aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2";
|
|
1829
1871
|
//#endregion
|
|
1830
1872
|
//#region src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts
|
|
1831
|
-
function
|
|
1873
|
+
function Wr(e) {
|
|
1832
1874
|
let t = [], n = [], r = 0;
|
|
1833
1875
|
for (; r < e.length;) {
|
|
1834
1876
|
let i = 0;
|
|
@@ -1842,59 +1884,59 @@ function Ir(e) {
|
|
|
1842
1884
|
}
|
|
1843
1885
|
return t;
|
|
1844
1886
|
}
|
|
1845
|
-
var
|
|
1846
|
-
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) {
|
|
1847
1889
|
let t = e, n = !0;
|
|
1848
1890
|
for (; n;) {
|
|
1849
1891
|
n = !1;
|
|
1850
1892
|
let e = t;
|
|
1851
|
-
t = t.replace(
|
|
1893
|
+
t = t.replace(qr, ""), t !== e && (n = !0);
|
|
1852
1894
|
for (let [e, r] of [["(", ")"], ["[", "]"]]) for (; t.endsWith(r);) {
|
|
1853
|
-
let i =
|
|
1854
|
-
if (
|
|
1895
|
+
let i = $r(t, e);
|
|
1896
|
+
if ($r(t, r) > i) t = t.slice(0, -1), n = !0;
|
|
1855
1897
|
else break;
|
|
1856
1898
|
}
|
|
1857
1899
|
}
|
|
1858
1900
|
return t;
|
|
1859
1901
|
}
|
|
1860
|
-
function
|
|
1902
|
+
function $r(e, t) {
|
|
1861
1903
|
let n = 0;
|
|
1862
1904
|
for (let r = 0; r < e.length; r++) e[r] === t && n++;
|
|
1863
1905
|
return n;
|
|
1864
1906
|
}
|
|
1865
|
-
function
|
|
1907
|
+
function ei(e) {
|
|
1866
1908
|
let t = e.split(".");
|
|
1867
1909
|
return t[t.length - 1].toLowerCase();
|
|
1868
1910
|
}
|
|
1869
|
-
function
|
|
1870
|
-
let t =
|
|
1871
|
-
return
|
|
1911
|
+
function ti(e) {
|
|
1912
|
+
let t = ei(e);
|
|
1913
|
+
return Gr.has(t);
|
|
1872
1914
|
}
|
|
1873
|
-
function
|
|
1915
|
+
function ni(e, t, n) {
|
|
1874
1916
|
return t === "email" ? "mailto:" + e : /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(e) || /^mailto:/i.test(e) ? e : n + "://" + e;
|
|
1875
1917
|
}
|
|
1876
|
-
function
|
|
1918
|
+
function ri(e, t) {
|
|
1877
1919
|
if (!e) return [];
|
|
1878
1920
|
let n = t?.defaultProtocol || "http", r = [];
|
|
1879
|
-
for (let t of e.matchAll(
|
|
1921
|
+
for (let t of e.matchAll(Jr)) r.push({
|
|
1880
1922
|
type: "url",
|
|
1881
1923
|
value: t[0],
|
|
1882
1924
|
start: t.index,
|
|
1883
1925
|
end: t.index + t[0].length
|
|
1884
1926
|
});
|
|
1885
|
-
for (let t of e.matchAll(
|
|
1927
|
+
for (let t of e.matchAll(Yr)) r.push({
|
|
1886
1928
|
type: "url",
|
|
1887
1929
|
value: t[0],
|
|
1888
1930
|
start: t.index,
|
|
1889
1931
|
end: t.index + t[0].length
|
|
1890
1932
|
});
|
|
1891
|
-
for (let t of e.matchAll(
|
|
1933
|
+
for (let t of e.matchAll(Xr)) r.push({
|
|
1892
1934
|
type: "email",
|
|
1893
1935
|
value: t[0],
|
|
1894
1936
|
start: t.index,
|
|
1895
1937
|
end: t.index + t[0].length
|
|
1896
1938
|
});
|
|
1897
|
-
for (let t of e.matchAll(
|
|
1939
|
+
for (let t of e.matchAll(Zr)) r.push({
|
|
1898
1940
|
type: "url",
|
|
1899
1941
|
value: t[0],
|
|
1900
1942
|
start: t.index,
|
|
@@ -1905,18 +1947,18 @@ function Yr(e, t) {
|
|
|
1905
1947
|
for (let e of r) e.start >= a && (i.push(e), a = e.end);
|
|
1906
1948
|
let o = [];
|
|
1907
1949
|
for (let e of i) {
|
|
1908
|
-
let t =
|
|
1950
|
+
let t = Qr(e.value);
|
|
1909
1951
|
if (!t) continue;
|
|
1910
1952
|
let r = e.start, i = r + t.length;
|
|
1911
1953
|
if (e.type === "url" && !/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t)) {
|
|
1912
1954
|
let e = new URL("http://" + t).hostname;
|
|
1913
|
-
if (!
|
|
1955
|
+
if (!ti(e)) continue;
|
|
1914
1956
|
}
|
|
1915
1957
|
if (e.type === "email") {
|
|
1916
1958
|
let e = t.split("@")[1];
|
|
1917
|
-
if (!
|
|
1959
|
+
if (!ti(e)) continue;
|
|
1918
1960
|
}
|
|
1919
|
-
let a =
|
|
1961
|
+
let a = ni(t, e.type, n);
|
|
1920
1962
|
o.push({
|
|
1921
1963
|
type: e.type,
|
|
1922
1964
|
value: t,
|
|
@@ -1928,7 +1970,7 @@ function Yr(e, t) {
|
|
|
1928
1970
|
}
|
|
1929
1971
|
return o;
|
|
1930
1972
|
}
|
|
1931
|
-
function
|
|
1973
|
+
function ii(e, t = "http") {
|
|
1932
1974
|
if (!e) return [$(e, 0, 0)];
|
|
1933
1975
|
for (let [n, r] of [
|
|
1934
1976
|
["(", ")"],
|
|
@@ -1936,34 +1978,34 @@ function Xr(e, t = "http") {
|
|
|
1936
1978
|
["{", "}"]
|
|
1937
1979
|
]) if (e.startsWith(n) && e.endsWith(r) && e.length > 2) {
|
|
1938
1980
|
let i = e.slice(1, -1);
|
|
1939
|
-
if (
|
|
1981
|
+
if (ai(i)) return [
|
|
1940
1982
|
$(n, 0, 1),
|
|
1941
|
-
|
|
1983
|
+
oi(i, 1, 1 + i.length, t),
|
|
1942
1984
|
$(r, 1 + i.length, e.length)
|
|
1943
1985
|
];
|
|
1944
1986
|
}
|
|
1945
1987
|
if (e.endsWith(".") && e.length > 1) {
|
|
1946
1988
|
let n = e.slice(0, -1);
|
|
1947
|
-
if (
|
|
1989
|
+
if (ai(n)) return [oi(n, 0, n.length, t), $(".", n.length, e.length)];
|
|
1948
1990
|
}
|
|
1949
|
-
return
|
|
1991
|
+
return ai(e) ? [oi(e, 0, e.length, t)] : [$(e, 0, e.length)];
|
|
1950
1992
|
}
|
|
1951
|
-
function
|
|
1952
|
-
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;
|
|
1953
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]*)?$/);
|
|
1954
1996
|
if (t) {
|
|
1955
1997
|
let e = t[1].toLowerCase();
|
|
1956
|
-
if (
|
|
1998
|
+
if (Gr.has(e)) return !0;
|
|
1957
1999
|
}
|
|
1958
2000
|
return !1;
|
|
1959
2001
|
}
|
|
1960
|
-
function
|
|
2002
|
+
function oi(e, t, n, r) {
|
|
1961
2003
|
let i = e.includes("@") && !e.includes("://") && !e.startsWith("mailto:") ? "email" : "url";
|
|
1962
2004
|
return {
|
|
1963
2005
|
type: i,
|
|
1964
2006
|
value: e,
|
|
1965
2007
|
isLink: !0,
|
|
1966
|
-
href:
|
|
2008
|
+
href: ni(e, i, r),
|
|
1967
2009
|
start: t,
|
|
1968
2010
|
end: n
|
|
1969
2011
|
};
|
|
@@ -1980,40 +2022,40 @@ function $(e, t, n) {
|
|
|
1980
2022
|
}
|
|
1981
2023
|
//#endregion
|
|
1982
2024
|
//#region src/extensions/tiptap-extensions/Link/helpers/whitespace.ts
|
|
1983
|
-
var
|
|
2025
|
+
var si = "[\0- \xA0 -\u2029 ]", ci = new RegExp(si), li = RegExp(`${si}$`), ui = new RegExp(si, "g");
|
|
1984
2026
|
//#endregion
|
|
1985
2027
|
//#region src/extensions/tiptap-extensions/Link/helpers/autolink.ts
|
|
1986
|
-
function
|
|
2028
|
+
function di(e) {
|
|
1987
2029
|
return e.length === 1 ? e[0].isLink : e.length === 3 && e[1].isLink ? ["()", "[]"].includes(e[0].value + e[2].value) : !1;
|
|
1988
2030
|
}
|
|
1989
|
-
function
|
|
1990
|
-
return new
|
|
1991
|
-
key: new
|
|
2031
|
+
function fi(e) {
|
|
2032
|
+
return new st({
|
|
2033
|
+
key: new ct("autolink"),
|
|
1992
2034
|
appendTransaction: (t, n, r) => {
|
|
1993
2035
|
let i = t.some((e) => e.docChanged) && !n.doc.eq(r.doc), a = t.some((e) => e.getMeta("preventAutolink"));
|
|
1994
2036
|
if (!i || a) return;
|
|
1995
|
-
let { tr: o } = r;
|
|
1996
|
-
if (
|
|
1997
|
-
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;
|
|
1998
2040
|
if (n.length > 1) i = n[0], a = r.doc.textBetween(i.pos, i.pos + i.node.nodeSize, void 0, " ");
|
|
1999
2041
|
else if (n.length) {
|
|
2000
2042
|
let e = r.doc.textBetween(t.from, t.to, " ", " ");
|
|
2001
|
-
if (!
|
|
2043
|
+
if (!li.test(e)) return;
|
|
2002
2044
|
i = n[0], a = r.doc.textBetween(i.pos, t.to, void 0, " ");
|
|
2003
2045
|
}
|
|
2004
2046
|
if (i && a) {
|
|
2005
|
-
let t = a.split(
|
|
2047
|
+
let t = a.split(ci).filter(Boolean);
|
|
2006
2048
|
if (t.length <= 0) return;
|
|
2007
2049
|
let n = t[t.length - 1], s = i.pos + a.lastIndexOf(n);
|
|
2008
2050
|
if (!n) return;
|
|
2009
|
-
let c =
|
|
2010
|
-
if (!
|
|
2051
|
+
let c = ii(n, e.defaultProtocol);
|
|
2052
|
+
if (!di(c)) return;
|
|
2011
2053
|
c.filter((e) => e.isLink).map((e) => ({
|
|
2012
2054
|
...e,
|
|
2013
2055
|
from: s + e.start + 1,
|
|
2014
2056
|
to: s + e.end + 1
|
|
2015
|
-
})).filter((e) => r.schema.marks.code
|
|
2016
|
-
|
|
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 }));
|
|
2017
2059
|
});
|
|
2018
2060
|
}
|
|
2019
2061
|
}), o.steps.length) return o;
|
|
@@ -2022,9 +2064,9 @@ function ri(e) {
|
|
|
2022
2064
|
}
|
|
2023
2065
|
//#endregion
|
|
2024
2066
|
//#region src/extensions/tiptap-extensions/Link/helpers/clickHandler.ts
|
|
2025
|
-
function
|
|
2026
|
-
return new
|
|
2027
|
-
key: new
|
|
2067
|
+
function pi(e) {
|
|
2068
|
+
return new st({
|
|
2069
|
+
key: new ct("handleClickLink"),
|
|
2028
2070
|
props: { handleClick: (t, n, r) => {
|
|
2029
2071
|
if (r.button !== 0 || !t.editable) return !1;
|
|
2030
2072
|
let i = null;
|
|
@@ -2040,16 +2082,16 @@ function ii(e) {
|
|
|
2040
2082
|
if (!e.editor) throw Error("BlockNoteEditor not found in Link click handler");
|
|
2041
2083
|
return e.onClick(r, e.editor) ?? !0;
|
|
2042
2084
|
}
|
|
2043
|
-
let a =
|
|
2085
|
+
let a = Ye(t.state, e.type.name), o = i.href ?? a.href, s = i.target ?? a.target;
|
|
2044
2086
|
return o ? (window.open(o, s), !0) : !1;
|
|
2045
2087
|
} }
|
|
2046
2088
|
});
|
|
2047
2089
|
}
|
|
2048
2090
|
//#endregion
|
|
2049
2091
|
//#region src/extensions/tiptap-extensions/Link/helpers/pasteHandler.ts
|
|
2050
|
-
function
|
|
2051
|
-
return new
|
|
2052
|
-
key: new
|
|
2092
|
+
function mi(e) {
|
|
2093
|
+
return new st({
|
|
2094
|
+
key: new ct("handlePasteLink"),
|
|
2053
2095
|
props: { handlePaste: (t, n, r) => {
|
|
2054
2096
|
let { shouldAutoLink: i, isValidLink: a } = e, { state: o } = t, { selection: s } = o, { empty: c } = s;
|
|
2055
2097
|
if (c) return !1;
|
|
@@ -2057,26 +2099,26 @@ function ai(e) {
|
|
|
2057
2099
|
r.content.forEach((e) => {
|
|
2058
2100
|
l += e.textContent;
|
|
2059
2101
|
});
|
|
2060
|
-
let u =
|
|
2102
|
+
let u = ri(l, { defaultProtocol: e.defaultProtocol }).find((e) => e.isLink && e.value === l);
|
|
2061
2103
|
return !l || !u || !a(u.value) || i !== void 0 && !i(u.value) ? !1 : e.editor.commands.setMark(e.type, { href: u.href });
|
|
2062
2104
|
} }
|
|
2063
2105
|
});
|
|
2064
2106
|
}
|
|
2065
2107
|
//#endregion
|
|
2066
2108
|
//#region src/extensions/tiptap-extensions/Link/link.ts
|
|
2067
|
-
var
|
|
2068
|
-
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) {
|
|
2069
2111
|
if (!e) return !0;
|
|
2070
|
-
let t = e.replace(
|
|
2071
|
-
return
|
|
2112
|
+
let t = e.replace(ui, "");
|
|
2113
|
+
return gi.test(t);
|
|
2072
2114
|
}
|
|
2073
|
-
function
|
|
2115
|
+
function vi(e) {
|
|
2074
2116
|
let t = /^[a-z][a-z0-9+.-]*:\/\//i.test(e), n = /^[a-z][a-z0-9+.-]*:/i.test(e);
|
|
2075
2117
|
if (t || n && !e.includes("@")) return !0;
|
|
2076
2118
|
let r = (e.includes("@") ? e.split("@").pop() : e).split(/[/?#:]/)[0];
|
|
2077
2119
|
return !(/^\d{1,3}(\.\d{1,3}){3}$/.test(r) || !/\./.test(r));
|
|
2078
2120
|
}
|
|
2079
|
-
var
|
|
2121
|
+
var yi = We.create({
|
|
2080
2122
|
name: "link",
|
|
2081
2123
|
keepOnSplit: !1,
|
|
2082
2124
|
exitable: !0,
|
|
@@ -2091,7 +2133,7 @@ var ui = He.create({
|
|
|
2091
2133
|
},
|
|
2092
2134
|
editor: void 0,
|
|
2093
2135
|
onClick: void 0,
|
|
2094
|
-
isValidLink:
|
|
2136
|
+
isValidLink: _i
|
|
2095
2137
|
};
|
|
2096
2138
|
},
|
|
2097
2139
|
addAttributes() {
|
|
@@ -2115,11 +2157,11 @@ var ui = He.create({
|
|
|
2115
2157
|
renderHTML({ HTMLAttributes: e }) {
|
|
2116
2158
|
return this.options.isValidLink(e.href) ? [
|
|
2117
2159
|
"a",
|
|
2118
|
-
|
|
2160
|
+
M(e, this.options.HTMLAttributes),
|
|
2119
2161
|
0
|
|
2120
2162
|
] : [
|
|
2121
2163
|
"a",
|
|
2122
|
-
|
|
2164
|
+
M({
|
|
2123
2165
|
...e,
|
|
2124
2166
|
href: ""
|
|
2125
2167
|
}, this.options.HTMLAttributes),
|
|
@@ -2128,12 +2170,12 @@ var ui = He.create({
|
|
|
2128
2170
|
},
|
|
2129
2171
|
addPasteRules() {
|
|
2130
2172
|
let e = this.options.isValidLink;
|
|
2131
|
-
return [
|
|
2173
|
+
return [tt({
|
|
2132
2174
|
find: (t) => {
|
|
2133
2175
|
let n = [];
|
|
2134
2176
|
if (t) {
|
|
2135
|
-
let r =
|
|
2136
|
-
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({
|
|
2137
2179
|
text: e.value,
|
|
2138
2180
|
data: { href: e.href },
|
|
2139
2181
|
index: e.start
|
|
@@ -2147,39 +2189,39 @@ var ui = He.create({
|
|
|
2147
2189
|
},
|
|
2148
2190
|
addProseMirrorPlugins() {
|
|
2149
2191
|
let e = [];
|
|
2150
|
-
return e.push(
|
|
2192
|
+
return e.push(fi({
|
|
2151
2193
|
type: this.type,
|
|
2152
|
-
defaultProtocol:
|
|
2194
|
+
defaultProtocol: hi,
|
|
2153
2195
|
validate: this.options.isValidLink,
|
|
2154
|
-
shouldAutoLink:
|
|
2155
|
-
})), e.push(
|
|
2196
|
+
shouldAutoLink: vi
|
|
2197
|
+
})), e.push(pi({
|
|
2156
2198
|
type: this.type,
|
|
2157
2199
|
tiptapEditor: this.editor,
|
|
2158
2200
|
editor: this.options.editor,
|
|
2159
2201
|
onClick: this.options.onClick
|
|
2160
|
-
})), e.push(
|
|
2202
|
+
})), e.push(mi({
|
|
2161
2203
|
editor: this.editor,
|
|
2162
|
-
defaultProtocol:
|
|
2204
|
+
defaultProtocol: hi,
|
|
2163
2205
|
type: this.type,
|
|
2164
|
-
shouldAutoLink:
|
|
2206
|
+
shouldAutoLink: vi,
|
|
2165
2207
|
isValidLink: this.options.isValidLink
|
|
2166
2208
|
})), e;
|
|
2167
2209
|
}
|
|
2168
|
-
}),
|
|
2210
|
+
}), bi = he(({ editor: e, options: t }) => ({
|
|
2169
2211
|
key: "link",
|
|
2170
|
-
tiptapExtensions: [
|
|
2212
|
+
tiptapExtensions: [yi.configure({
|
|
2171
2213
|
HTMLAttributes: t.HTMLAttributes ?? {},
|
|
2172
2214
|
editor: e,
|
|
2173
2215
|
onClick: t.onClick,
|
|
2174
2216
|
...t.isValidLink ? { isValidLink: t.isValidLink } : {}
|
|
2175
2217
|
})]
|
|
2176
|
-
})),
|
|
2218
|
+
})), xi = {
|
|
2177
2219
|
blockColor: "data-block-color",
|
|
2178
2220
|
blockStyle: "data-block-style",
|
|
2179
2221
|
id: "data-id",
|
|
2180
2222
|
depth: "data-depth",
|
|
2181
2223
|
depthChange: "data-depth-change"
|
|
2182
|
-
},
|
|
2224
|
+
}, Si = A.create({
|
|
2183
2225
|
name: "blockContainer",
|
|
2184
2226
|
group: "blockGroupChild bnBlock",
|
|
2185
2227
|
content: "blockContent blockGroup?",
|
|
@@ -2194,7 +2236,7 @@ var ui = He.create({
|
|
|
2194
2236
|
getAttrs: (e) => {
|
|
2195
2237
|
if (typeof e == "string") return !1;
|
|
2196
2238
|
let t = {};
|
|
2197
|
-
for (let [n, r] of Object.entries(
|
|
2239
|
+
for (let [n, r] of Object.entries(xi)) e.getAttribute(r) && (t[n] = e.getAttribute(r));
|
|
2198
2240
|
return t;
|
|
2199
2241
|
}
|
|
2200
2242
|
}, {
|
|
@@ -2210,14 +2252,14 @@ var ui = He.create({
|
|
|
2210
2252
|
...this.options.domAttributes?.block || {},
|
|
2211
2253
|
...e
|
|
2212
2254
|
}, r = document.createElement("div");
|
|
2213
|
-
r.className =
|
|
2255
|
+
r.className = s("bn-block", n.class), r.setAttribute("data-node-type", this.name);
|
|
2214
2256
|
for (let [e, t] of Object.entries(n)) e !== "class" && r.setAttribute(e, t);
|
|
2215
2257
|
return t.appendChild(r), {
|
|
2216
2258
|
dom: t,
|
|
2217
2259
|
contentDOM: r
|
|
2218
2260
|
};
|
|
2219
2261
|
}
|
|
2220
|
-
}),
|
|
2262
|
+
}), Ci = A.create({
|
|
2221
2263
|
name: "blockGroup",
|
|
2222
2264
|
group: "childContainer",
|
|
2223
2265
|
content: "blockGroupChild+",
|
|
@@ -2227,7 +2269,7 @@ var ui = He.create({
|
|
|
2227
2269
|
parseHTML() {
|
|
2228
2270
|
return [{
|
|
2229
2271
|
tag: "div",
|
|
2230
|
-
getAttrs: (e) => typeof e
|
|
2272
|
+
getAttrs: (e) => typeof e != "string" && e.getAttribute("data-node-type") === "blockGroup" && null
|
|
2231
2273
|
}];
|
|
2232
2274
|
},
|
|
2233
2275
|
renderHTML({ HTMLAttributes: e }) {
|
|
@@ -2235,14 +2277,14 @@ var ui = He.create({
|
|
|
2235
2277
|
...this.options.domAttributes?.blockGroup || {},
|
|
2236
2278
|
...e
|
|
2237
2279
|
}, n = document.createElement("div");
|
|
2238
|
-
n.className =
|
|
2280
|
+
n.className = s("bn-block-group", t.class), n.setAttribute("data-node-type", "blockGroup");
|
|
2239
2281
|
for (let [e, r] of Object.entries(t)) e !== "class" && n.setAttribute(e, r);
|
|
2240
2282
|
return {
|
|
2241
2283
|
dom: n,
|
|
2242
2284
|
contentDOM: n
|
|
2243
2285
|
};
|
|
2244
2286
|
}
|
|
2245
|
-
}),
|
|
2287
|
+
}), wi = A.create({
|
|
2246
2288
|
name: "doc",
|
|
2247
2289
|
topNode: !0,
|
|
2248
2290
|
content: "blockGroup",
|
|
@@ -2252,79 +2294,82 @@ var ui = He.create({
|
|
|
2252
2294
|
});
|
|
2253
2295
|
//#endregion
|
|
2254
2296
|
//#region src/editor/managers/ExtensionManager/extensions.ts
|
|
2255
|
-
function
|
|
2297
|
+
function Ti(t, n) {
|
|
2256
2298
|
return [
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2299
|
+
j.ClipboardTextSerializer,
|
|
2300
|
+
j.Commands,
|
|
2301
|
+
j.Editable,
|
|
2302
|
+
j.FocusEvents,
|
|
2303
|
+
j.Tabindex,
|
|
2304
|
+
mt,
|
|
2305
|
+
e.configure({
|
|
2264
2306
|
types: [
|
|
2265
2307
|
"blockContainer",
|
|
2266
2308
|
"columnList",
|
|
2267
2309
|
"column"
|
|
2268
2310
|
],
|
|
2269
|
-
setIdAttribute:
|
|
2270
|
-
isWithinEditor:
|
|
2311
|
+
setIdAttribute: n.setIdAttribute,
|
|
2312
|
+
isWithinEditor: t.isWithinEditor
|
|
2271
2313
|
}),
|
|
2272
|
-
Er,
|
|
2273
|
-
ut,
|
|
2274
|
-
...Object.values(e.schema.styleSpecs).map((t) => t.implementation.mark.configure({ editor: e })),
|
|
2275
2314
|
Pr,
|
|
2276
|
-
|
|
2315
|
+
pt,
|
|
2316
|
+
...Object.values(t.schema.styleSpecs).map((e) => e.implementation.mark.configure({ editor: t })),
|
|
2317
|
+
Hr,
|
|
2277
2318
|
Nr,
|
|
2278
|
-
|
|
2319
|
+
Vr,
|
|
2320
|
+
k.create({
|
|
2279
2321
|
name: "OverrideEscape",
|
|
2280
|
-
addKeyboardShortcuts: () => ({ Escape: () =>
|
|
2322
|
+
addKeyboardShortcuts: () => ({ Escape: () => !t.getExtension(ie)?.shown() && (t.blur(), !0) })
|
|
2281
2323
|
}),
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
editor:
|
|
2285
|
-
domAttributes:
|
|
2324
|
+
wi,
|
|
2325
|
+
Si.configure({
|
|
2326
|
+
editor: t,
|
|
2327
|
+
domAttributes: n.domAttributes
|
|
2286
2328
|
}),
|
|
2287
|
-
|
|
2288
|
-
editor:
|
|
2289
|
-
tabBehavior:
|
|
2329
|
+
Br.configure({
|
|
2330
|
+
editor: t,
|
|
2331
|
+
tabBehavior: n.tabBehavior
|
|
2290
2332
|
}),
|
|
2291
|
-
|
|
2292
|
-
...Object.values(
|
|
2293
|
-
...Object.values(
|
|
2294
|
-
editor:
|
|
2295
|
-
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
|
|
2296
2338
|
})] : []]),
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2339
|
+
Mr(t),
|
|
2340
|
+
Dr(t, n.pasteHandler || ((e) => e.defaultPasteHandler())),
|
|
2341
|
+
ur(t)
|
|
2300
2342
|
];
|
|
2301
2343
|
}
|
|
2302
|
-
function
|
|
2344
|
+
function Ei(e, t) {
|
|
2303
2345
|
let n = [
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2346
|
+
be(),
|
|
2347
|
+
ye(t),
|
|
2348
|
+
fe(t),
|
|
2349
|
+
x(t),
|
|
2350
|
+
bi({
|
|
2309
2351
|
HTMLAttributes: t.links?.HTMLAttributes ?? {},
|
|
2310
2352
|
onClick: t.links?.onClick,
|
|
2311
2353
|
...t.links?.isValidLink ? { isValidLink: t.links.isValidLink } : {}
|
|
2312
2354
|
}),
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2355
|
+
xe(t),
|
|
2356
|
+
we(),
|
|
2357
|
+
Me(t),
|
|
2358
|
+
Fe(t),
|
|
2359
|
+
De(t),
|
|
2360
|
+
Oe(),
|
|
2361
|
+
Ae(),
|
|
2318
2362
|
ie(t),
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2363
|
+
ge(),
|
|
2364
|
+
ke(),
|
|
2365
|
+
_e(),
|
|
2366
|
+
...t.trailingBlock === !1 ? [] : [je()]
|
|
2322
2367
|
];
|
|
2323
|
-
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;
|
|
2324
2369
|
}
|
|
2325
2370
|
//#endregion
|
|
2326
2371
|
//#region src/editor/managers/ExtensionManager/index.ts
|
|
2327
|
-
var
|
|
2372
|
+
var Di = class {
|
|
2328
2373
|
editor;
|
|
2329
2374
|
options;
|
|
2330
2375
|
disabledExtensions = /* @__PURE__ */ new Set();
|
|
@@ -2348,7 +2393,7 @@ var vi = class {
|
|
|
2348
2393
|
}), e.onUnmount(() => {
|
|
2349
2394
|
for (let [e, t] of this.abortMap.entries()) this.abortMap.delete(e), t.abort();
|
|
2350
2395
|
}), this.disabledExtensions = new Set(t.disableExtensions || []);
|
|
2351
|
-
for (let e of
|
|
2396
|
+
for (let e of Ei(this.editor, this.options)) this.addExtension(e);
|
|
2352
2397
|
for (let e of this.options.extensions ?? []) this.addExtension(e);
|
|
2353
2398
|
for (let e of Object.values(this.editor.schema.blockSpecs)) for (let t of e.extensions ?? []) this.addExtension(t);
|
|
2354
2399
|
}
|
|
@@ -2364,7 +2409,7 @@ var vi = class {
|
|
|
2364
2409
|
}
|
|
2365
2410
|
if (!this.extensions.some((e) => e.key === n.key)) {
|
|
2366
2411
|
if (typeof e == "function") {
|
|
2367
|
-
let e = n[
|
|
2412
|
+
let e = n[me];
|
|
2368
2413
|
typeof e == "function" && this.extensionFactories.set(e, n);
|
|
2369
2414
|
}
|
|
2370
2415
|
if (this.extensions.push(n), n.blockNoteExtensions) for (let e of n.blockNoteExtensions) this.addExtension(e, n.key);
|
|
@@ -2417,7 +2462,7 @@ var vi = class {
|
|
|
2417
2462
|
this.editor.prosemirrorView.updateState(n);
|
|
2418
2463
|
}
|
|
2419
2464
|
getTiptapExtensions() {
|
|
2420
|
-
let e =
|
|
2465
|
+
let e = Ti(this.editor, this.options).filter((e) => !this.disabledExtensions.has(e.name)), t = ee(this.extensions.map((e) => {
|
|
2421
2466
|
let t = this.blockNoteExtensionDependents.get(e.key);
|
|
2422
2467
|
return t?.size ? {
|
|
2423
2468
|
key: e.key,
|
|
@@ -2427,21 +2472,21 @@ var vi = class {
|
|
|
2427
2472
|
for (let r of this.extensions) {
|
|
2428
2473
|
r.tiptapExtensions && e.push(...r.tiptapExtensions);
|
|
2429
2474
|
let i = t(r.key), { plugins: a, inputRules: o } = this.getProsemirrorPluginsFromExtension(r);
|
|
2430
|
-
a.length && e.push(
|
|
2475
|
+
a.length && e.push(k.create({
|
|
2431
2476
|
name: r.key,
|
|
2432
2477
|
priority: i,
|
|
2433
2478
|
addProseMirrorPlugins: () => a
|
|
2434
2479
|
})), o.length && (n.has(i) || n.set(i, []), n.get(i).push(...o));
|
|
2435
2480
|
}
|
|
2436
|
-
e.push(
|
|
2481
|
+
e.push(k.create({
|
|
2437
2482
|
name: "blocknote-input-rules",
|
|
2438
2483
|
addProseMirrorPlugins() {
|
|
2439
2484
|
let e = [];
|
|
2440
2485
|
Array.from(n.keys()).sort((e, t) => e - t).reverse().forEach((t) => {
|
|
2441
2486
|
e.push(...n.get(t));
|
|
2442
2487
|
});
|
|
2443
|
-
let t =
|
|
2444
|
-
return [t, new
|
|
2488
|
+
let t = dt({ rules: e });
|
|
2489
|
+
return [t, new P({ props: { handleKeyDown(e, n) {
|
|
2445
2490
|
if (n.key !== "Enter" || n.shiftKey || n.ctrlKey || n.metaKey || n.altKey) return !1;
|
|
2446
2491
|
let { $cursor: r } = e.state.selection;
|
|
2447
2492
|
return r ? !!t.props.handleTextInput?.call(t, e, r.pos, r.pos, "\n", () => e.state.tr.insertText("\n", r.pos, r.pos)) : !1;
|
|
@@ -2451,28 +2496,28 @@ var vi = class {
|
|
|
2451
2496
|
for (let t of this.options._tiptapOptions?.extensions ?? []) e.push(t);
|
|
2452
2497
|
return e;
|
|
2453
2498
|
}
|
|
2454
|
-
getProsemirrorPluginsFromExtension(
|
|
2455
|
-
let
|
|
2456
|
-
return !
|
|
2457
|
-
plugins:
|
|
2458
|
-
inputRules:
|
|
2459
|
-
} : (this.extensionPlugins.set(
|
|
2460
|
-
let
|
|
2461
|
-
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,
|
|
2462
2507
|
range: {
|
|
2463
|
-
from:
|
|
2464
|
-
to:
|
|
2508
|
+
from: r,
|
|
2509
|
+
to: i
|
|
2465
2510
|
},
|
|
2466
2511
|
editor: this.editor
|
|
2467
2512
|
});
|
|
2468
|
-
if (
|
|
2469
|
-
let
|
|
2470
|
-
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);
|
|
2471
2516
|
}
|
|
2472
2517
|
return null;
|
|
2473
|
-
}, { undoable: !0 }))), Object.keys(
|
|
2474
|
-
plugins:
|
|
2475
|
-
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
|
|
2476
2521
|
});
|
|
2477
2522
|
}
|
|
2478
2523
|
getExtensions() {
|
|
@@ -2484,12 +2529,12 @@ var vi = class {
|
|
|
2484
2529
|
throw Error(`Invalid extension type: ${typeof e}`);
|
|
2485
2530
|
}
|
|
2486
2531
|
hasExtension(e) {
|
|
2487
|
-
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);
|
|
2488
2533
|
}
|
|
2489
2534
|
};
|
|
2490
2535
|
//#endregion
|
|
2491
2536
|
//#region src/util/expandToWords.ts
|
|
2492
|
-
function
|
|
2537
|
+
function Oi(e, t) {
|
|
2493
2538
|
let { $from: n, $to: r } = t;
|
|
2494
2539
|
if (n.pos > n.start() && n.pos < e.content.size) {
|
|
2495
2540
|
let t = e.textBetween(n.pos, n.pos + 1);
|
|
@@ -2514,15 +2559,15 @@ function yi(e, t) {
|
|
|
2514
2559
|
}
|
|
2515
2560
|
//#endregion
|
|
2516
2561
|
//#region src/api/blockManipulation/selections/selection.ts
|
|
2517
|
-
function
|
|
2562
|
+
function ki(e) {
|
|
2518
2563
|
if (e.selection.empty || "node" in e.selection) return;
|
|
2519
|
-
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) => {
|
|
2520
2565
|
let i = t.posAtIndex(n, r), a = e.doc.resolve(i).nodeAfter;
|
|
2521
2566
|
if (!a) throw Error(`Error getting selection - node not found at position ${i}`);
|
|
2522
|
-
return
|
|
2567
|
+
return g(a, e.doc);
|
|
2523
2568
|
}, i = [], a = t.sharedDepth(n.pos), o = t.index(a), s = n.index(a);
|
|
2524
2569
|
if (t.depth > a) {
|
|
2525
|
-
i.push(
|
|
2570
|
+
i.push(g(t.nodeAfter, e.doc));
|
|
2526
2571
|
for (let e = t.depth; e > a; e--) if (t.node(e).type.isInGroup("childContainer")) {
|
|
2527
2572
|
let n = t.index(e) + 1, a = t.node(e).childCount;
|
|
2528
2573
|
for (let t = n; t < a; t++) i.push(r(t, e));
|
|
@@ -2532,29 +2577,29 @@ function bi(e) {
|
|
|
2532
2577
|
if (i.length === 0) throw Error(`Error getting selection - selection doesn't span any blocks (${e.selection})`);
|
|
2533
2578
|
return { blocks: i };
|
|
2534
2579
|
}
|
|
2535
|
-
function
|
|
2536
|
-
let
|
|
2537
|
-
if (
|
|
2538
|
-
let s =
|
|
2539
|
-
if (!s) throw Error(`Block with ID ${
|
|
2540
|
-
let
|
|
2541
|
-
if (!
|
|
2542
|
-
let
|
|
2543
|
-
if (!
|
|
2544
|
-
if (!d.isBlockContainer ||
|
|
2545
|
-
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;
|
|
2546
2591
|
if (f.content === "table") {
|
|
2547
|
-
let e =
|
|
2548
|
-
|
|
2549
|
-
} else
|
|
2550
|
-
if (
|
|
2551
|
-
let t =
|
|
2552
|
-
|
|
2553
|
-
} else
|
|
2554
|
-
e.setSelection(
|
|
2555
|
-
}
|
|
2556
|
-
function
|
|
2557
|
-
let r = t ?
|
|
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;
|
|
2558
2603
|
for (; a.parentOffset >= a.parent.nodeSize - 2 && a.depth > 0;) a = e.doc.resolve(a.pos + 1);
|
|
2559
2604
|
for (; a.parentOffset === 0 && a.depth > 0;) a = e.doc.resolve(a.pos - 1);
|
|
2560
2605
|
for (; i.parentOffset === 0 && i.depth > 0;) i = e.doc.resolve(i.pos - 1);
|
|
@@ -2570,36 +2615,36 @@ function Si(e, t = !1) {
|
|
|
2570
2615
|
}
|
|
2571
2616
|
//#endregion
|
|
2572
2617
|
//#region src/editor/managers/SelectionManager.ts
|
|
2573
|
-
var
|
|
2618
|
+
var Mi = class {
|
|
2574
2619
|
editor;
|
|
2575
2620
|
constructor(e) {
|
|
2576
2621
|
this.editor = e;
|
|
2577
2622
|
}
|
|
2578
2623
|
getSelection() {
|
|
2579
|
-
return this.editor.transact((e) =>
|
|
2624
|
+
return this.editor.transact((e) => ki(e));
|
|
2580
2625
|
}
|
|
2581
2626
|
getSelectionCutBlocks(e = !1) {
|
|
2582
|
-
return this.editor.transact((t) =>
|
|
2627
|
+
return this.editor.transact((t) => ji(t, e));
|
|
2583
2628
|
}
|
|
2584
2629
|
setSelection(e, t) {
|
|
2585
|
-
return this.editor.transact((n) =>
|
|
2630
|
+
return this.editor.transact((n) => Ai(n, e, t));
|
|
2586
2631
|
}
|
|
2587
2632
|
getTextCursorPosition() {
|
|
2588
|
-
return this.editor.transact((e) =>
|
|
2633
|
+
return this.editor.transact((e) => ir(e));
|
|
2589
2634
|
}
|
|
2590
2635
|
setTextCursorPosition(e, t = "start") {
|
|
2591
|
-
return this.editor.transact((n) =>
|
|
2636
|
+
return this.editor.transact((n) => ar(n, e, t));
|
|
2592
2637
|
}
|
|
2593
2638
|
getSelectionBoundingBox() {
|
|
2594
2639
|
if (!this.editor.prosemirrorView) return;
|
|
2595
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));
|
|
2596
|
-
if (
|
|
2641
|
+
if (et(e)) {
|
|
2597
2642
|
let e = this.editor.prosemirrorView.nodeDOM(n);
|
|
2598
2643
|
if (e) return e.getBoundingClientRect();
|
|
2599
2644
|
}
|
|
2600
|
-
return
|
|
2645
|
+
return nt(this.editor.prosemirrorView, n, r).toJSON();
|
|
2601
2646
|
}
|
|
2602
|
-
},
|
|
2647
|
+
}, Ni = class {
|
|
2603
2648
|
editor;
|
|
2604
2649
|
constructor(e) {
|
|
2605
2650
|
this.editor = e;
|
|
@@ -2652,7 +2697,7 @@ var Ci = class {
|
|
|
2652
2697
|
if (!this.editor.headless) throw Error("no editor, but also not headless?");
|
|
2653
2698
|
return !1;
|
|
2654
2699
|
}
|
|
2655
|
-
return this.editor._tiptapEditor.isEditable === void 0
|
|
2700
|
+
return this.editor._tiptapEditor.isEditable === void 0 || this.editor._tiptapEditor.isEditable;
|
|
2656
2701
|
}
|
|
2657
2702
|
set isEditable(e) {
|
|
2658
2703
|
if (!this.editor._tiptapEditor) {
|
|
@@ -2678,7 +2723,7 @@ var Ci = class {
|
|
|
2678
2723
|
};
|
|
2679
2724
|
//#endregion
|
|
2680
2725
|
//#region src/api/blockManipulation/insertContentAt.ts
|
|
2681
|
-
function
|
|
2726
|
+
function Pi(e, t, n, r = { updateSelection: !0 }) {
|
|
2682
2727
|
let { from: i, to: a } = typeof t == "number" ? {
|
|
2683
2728
|
from: t,
|
|
2684
2729
|
to: t
|
|
@@ -2692,19 +2737,19 @@ function Ti(e, t, n, r = { updateSelection: !0 }) {
|
|
|
2692
2737
|
let { parent: t } = e.doc.resolve(i);
|
|
2693
2738
|
t.isTextblock && !t.type.spec.code && !t.childCount && (--i, a += 1);
|
|
2694
2739
|
}
|
|
2695
|
-
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;
|
|
2696
2741
|
}
|
|
2697
2742
|
//#endregion
|
|
2698
2743
|
//#region src/editor/managers/StyleManager.ts
|
|
2699
|
-
var
|
|
2744
|
+
var Fi = class {
|
|
2700
2745
|
editor;
|
|
2701
2746
|
constructor(e) {
|
|
2702
2747
|
this.editor = e;
|
|
2703
2748
|
}
|
|
2704
2749
|
insertInlineContent(e, { updateSelection: t = !1 } = {}) {
|
|
2705
|
-
let n =
|
|
2750
|
+
let n = l(e, this.editor.pmSchema);
|
|
2706
2751
|
this.editor.transact((e) => {
|
|
2707
|
-
|
|
2752
|
+
Pi(e, {
|
|
2708
2753
|
from: e.selection.from,
|
|
2709
2754
|
to: e.selection.to
|
|
2710
2755
|
}, n, { updateSelection: t });
|
|
@@ -2730,7 +2775,7 @@ var Ei = class {
|
|
|
2730
2775
|
if (!e) throw Error(`style ${t} not found in styleSchema`);
|
|
2731
2776
|
if (e.propSchema === "boolean") this.editor._tiptapEditor.commands.setMark(t);
|
|
2732
2777
|
else if (e.propSchema === "string") this.editor._tiptapEditor.commands.setMark(t, { stringValue: n });
|
|
2733
|
-
else throw new
|
|
2778
|
+
else throw new _(e.propSchema);
|
|
2734
2779
|
}
|
|
2735
2780
|
}
|
|
2736
2781
|
removeStyles(e) {
|
|
@@ -2742,7 +2787,7 @@ var Ei = class {
|
|
|
2742
2787
|
if (!e) throw Error(`style ${t} not found in styleSchema`);
|
|
2743
2788
|
if (e.propSchema === "boolean") this.editor._tiptapEditor.commands.toggleMark(t);
|
|
2744
2789
|
else if (e.propSchema === "string") this.editor._tiptapEditor.commands.toggleMark(t, { stringValue: n });
|
|
2745
|
-
else throw new
|
|
2790
|
+
else throw new _(e.propSchema);
|
|
2746
2791
|
}
|
|
2747
2792
|
}
|
|
2748
2793
|
getSelectedText() {
|
|
@@ -2752,7 +2797,7 @@ var Ei = class {
|
|
|
2752
2797
|
return this.editor.transact((t) => {
|
|
2753
2798
|
let n = t.doc.resolve(e), r = n.marks().find((e) => e.type.name === "link");
|
|
2754
2799
|
if (!r) return;
|
|
2755
|
-
let i =
|
|
2800
|
+
let i = Ze(n, r.type);
|
|
2756
2801
|
if (i) return {
|
|
2757
2802
|
href: r.attrs.href,
|
|
2758
2803
|
from: i.from,
|
|
@@ -2791,83 +2836,84 @@ var Ei = class {
|
|
|
2791
2836
|
};
|
|
2792
2837
|
//#endregion
|
|
2793
2838
|
//#region src/editor/transformPasted.ts
|
|
2794
|
-
function
|
|
2795
|
-
return
|
|
2839
|
+
function Ii(e) {
|
|
2840
|
+
return Je(e.state.selection.$from, (e) => e.type.name === "tableCell" || e.type.name === "tableHeader") !== void 0;
|
|
2796
2841
|
}
|
|
2797
|
-
function
|
|
2798
|
-
let n = t.nodes.hardBreak, r =
|
|
2842
|
+
function Li(e, t) {
|
|
2843
|
+
let n = t.nodes.hardBreak, r = I.empty;
|
|
2799
2844
|
return e.forEach((e) => {
|
|
2800
|
-
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()));
|
|
2801
2846
|
}), r.lastChild?.type === n && (r = r.cut(0, r.size - 1)), r;
|
|
2802
2847
|
}
|
|
2803
|
-
function
|
|
2848
|
+
function Ri(e, t) {
|
|
2804
2849
|
let n = [];
|
|
2805
2850
|
return e.forEach((e, r, i) => {
|
|
2806
2851
|
i !== t && n.push(e);
|
|
2807
|
-
}),
|
|
2852
|
+
}), I.from(n);
|
|
2808
2853
|
}
|
|
2809
|
-
function
|
|
2854
|
+
function zi(e, t) {
|
|
2810
2855
|
let n = [];
|
|
2811
|
-
for (let r = 0; r < e.childCount; r++) if (e.child(r).type.name === "tableRow")
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
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;
|
|
2820
2866
|
}
|
|
2821
|
-
function
|
|
2822
|
-
let n =
|
|
2823
|
-
n =
|
|
2824
|
-
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);
|
|
2825
2871
|
if (r) return r;
|
|
2826
|
-
if (
|
|
2872
|
+
if (Ii(t)) {
|
|
2827
2873
|
let e = !1;
|
|
2828
2874
|
if (n.descendants((t) => {
|
|
2829
2875
|
t.type.isInGroup("tableContent") && (e = !0);
|
|
2830
|
-
}), !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);
|
|
2831
2877
|
}
|
|
2832
|
-
if (!
|
|
2878
|
+
if (!Hi(n, t)) return new L(n, e.openStart, e.openEnd);
|
|
2833
2879
|
for (let e = 0; e < n.childCount; e++) if (n.child(e).type.spec.group === "blockContent") {
|
|
2834
2880
|
let r = [n.child(e)];
|
|
2835
2881
|
if (e + 1 < n.childCount && n.child(e + 1).type.name === "blockGroup") {
|
|
2836
2882
|
let t = n.child(e + 1).child(0).child(0);
|
|
2837
|
-
(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));
|
|
2838
2884
|
}
|
|
2839
2885
|
let i = t.state.schema.nodes.blockContainer.createChecked(void 0, r);
|
|
2840
2886
|
n = n.replaceChild(e, i);
|
|
2841
2887
|
}
|
|
2842
|
-
return new
|
|
2843
|
-
}
|
|
2844
|
-
function
|
|
2845
|
-
if (
|
|
2846
|
-
let
|
|
2847
|
-
if (!
|
|
2848
|
-
let
|
|
2849
|
-
if (
|
|
2850
|
-
let
|
|
2851
|
-
return new
|
|
2852
|
-
}
|
|
2853
|
-
function
|
|
2854
|
-
let
|
|
2855
|
-
if (
|
|
2856
|
-
if (
|
|
2857
|
-
if (
|
|
2858
|
-
let
|
|
2859
|
-
if (
|
|
2888
|
+
return new L(n, e.openStart, e.openEnd);
|
|
2889
|
+
}
|
|
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;
|
|
2893
|
+
if (!i || i.type.name === "paragraph" || i.type.spec.content !== "inline*" || i.childCount > 0) return null;
|
|
2894
|
+
let a = e.firstChild, o = a?.firstChild, s = o?.firstChild;
|
|
2895
|
+
if (a?.type.name !== "blockGroup" || o?.type.name !== "blockContainer" || s?.type.name !== "paragraph") return null;
|
|
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));
|
|
2897
|
+
return new L(e.replaceChild(0, u), n.openStart, n.openEnd);
|
|
2898
|
+
}
|
|
2899
|
+
function Hi(e, t) {
|
|
2900
|
+
let n = e.childCount === 1, r = e.firstChild?.type.spec.content === "inline*", i = e.firstChild?.type.spec.content === "tableRow+";
|
|
2901
|
+
if (n) {
|
|
2902
|
+
if (r) return !1;
|
|
2903
|
+
if (i) {
|
|
2904
|
+
let e = w(t.state);
|
|
2905
|
+
if (e.isBlockContainer) return e.blockContent.node.type.spec.content !== "tableRow+";
|
|
2860
2906
|
}
|
|
2861
2907
|
}
|
|
2862
2908
|
return !0;
|
|
2863
2909
|
}
|
|
2864
2910
|
//#endregion
|
|
2865
2911
|
//#region src/editor/BlockNoteEditor.ts
|
|
2866
|
-
var
|
|
2912
|
+
var Ui = {
|
|
2867
2913
|
enableInputRules: !0,
|
|
2868
2914
|
enablePasteRules: !0,
|
|
2869
2915
|
enableCoreExtensions: !1
|
|
2870
|
-
},
|
|
2916
|
+
}, Wi = class t extends H {
|
|
2871
2917
|
options;
|
|
2872
2918
|
pmSchema;
|
|
2873
2919
|
_tiptapEditor;
|
|
@@ -2883,27 +2929,27 @@ var Pi = {
|
|
|
2883
2929
|
onUploadEndCallbacks = [];
|
|
2884
2930
|
resolveFileUrl;
|
|
2885
2931
|
settings;
|
|
2886
|
-
static create(
|
|
2887
|
-
return new e
|
|
2888
|
-
}
|
|
2889
|
-
constructor(
|
|
2890
|
-
super(), this.options =
|
|
2891
|
-
splitCells:
|
|
2892
|
-
cellBackgroundColor:
|
|
2893
|
-
cellTextColor:
|
|
2894
|
-
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
|
|
2895
2941
|
} };
|
|
2896
|
-
let
|
|
2942
|
+
let n = {
|
|
2897
2943
|
defaultStyles: !0,
|
|
2898
|
-
schema:
|
|
2899
|
-
...
|
|
2944
|
+
schema: t.schema || ce.create(),
|
|
2945
|
+
...t,
|
|
2900
2946
|
placeholders: {
|
|
2901
2947
|
...this.dictionary.placeholders,
|
|
2902
|
-
...
|
|
2948
|
+
...t.placeholders
|
|
2903
2949
|
}
|
|
2904
2950
|
};
|
|
2905
|
-
if (this.schema =
|
|
2906
|
-
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;
|
|
2907
2953
|
this.uploadFile = async (t, n) => {
|
|
2908
2954
|
this.onUploadStartCallbacks.forEach((e) => e.apply(this, [n]));
|
|
2909
2955
|
try {
|
|
@@ -2913,13 +2959,13 @@ var Pi = {
|
|
|
2913
2959
|
}
|
|
2914
2960
|
};
|
|
2915
2961
|
}
|
|
2916
|
-
this.resolveFileUrl =
|
|
2917
|
-
let
|
|
2918
|
-
...
|
|
2919
|
-
...
|
|
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,
|
|
2920
2966
|
element: null,
|
|
2921
|
-
autofocus:
|
|
2922
|
-
extensions:
|
|
2967
|
+
autofocus: n.autofocus ?? !1,
|
|
2968
|
+
extensions: r,
|
|
2923
2969
|
editorProps: {
|
|
2924
2970
|
scrollMargin: {
|
|
2925
2971
|
top: 72,
|
|
@@ -2927,34 +2973,34 @@ var Pi = {
|
|
|
2927
2973
|
left: 0,
|
|
2928
2974
|
right: 0
|
|
2929
2975
|
},
|
|
2930
|
-
...
|
|
2976
|
+
...n._tiptapOptions?.editorProps,
|
|
2931
2977
|
attributes: {
|
|
2932
2978
|
tabIndex: "0",
|
|
2933
|
-
...
|
|
2934
|
-
...
|
|
2935
|
-
class:
|
|
2979
|
+
...n._tiptapOptions?.editorProps?.attributes,
|
|
2980
|
+
...n.domAttributes?.editor,
|
|
2981
|
+
class: s("bn-editor", n.defaultStyles ? "bn-default-styles" : "", n.domAttributes?.editor?.class || "")
|
|
2936
2982
|
},
|
|
2937
|
-
transformPasted:
|
|
2983
|
+
transformPasted: Bi
|
|
2938
2984
|
}
|
|
2939
2985
|
};
|
|
2940
2986
|
try {
|
|
2941
|
-
let
|
|
2987
|
+
let t = n.initialContent || [{
|
|
2942
2988
|
type: "paragraph",
|
|
2943
|
-
id:
|
|
2989
|
+
id: e.options.generateID()
|
|
2944
2990
|
}];
|
|
2945
|
-
if (!Array.isArray(
|
|
2946
|
-
let
|
|
2947
|
-
|
|
2948
|
-
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({
|
|
2949
2995
|
type: "doc",
|
|
2950
2996
|
content: [{
|
|
2951
2997
|
type: "blockGroup",
|
|
2952
|
-
content:
|
|
2998
|
+
content: a
|
|
2953
2999
|
}]
|
|
2954
|
-
},
|
|
2955
|
-
this._tiptapEditor = new
|
|
2956
|
-
...
|
|
2957
|
-
content:
|
|
3000
|
+
}, r, i.parseOptions);
|
|
3001
|
+
this._tiptapEditor = new Ue({
|
|
3002
|
+
...i,
|
|
3003
|
+
content: o.toJSON()
|
|
2958
3004
|
}), this.pmSchema = this._tiptapEditor.schema;
|
|
2959
3005
|
} catch (e) {
|
|
2960
3006
|
throw Error("Error creating document from blocks passed as `initialContent`", { cause: e });
|
|
@@ -2963,7 +3009,7 @@ var Pi = {
|
|
|
2963
3009
|
this.headless = !1;
|
|
2964
3010
|
}), this._tiptapEditor.on("unmount", () => {
|
|
2965
3011
|
this.headless = !0;
|
|
2966
|
-
}), 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");
|
|
2967
3013
|
}
|
|
2968
3014
|
_blockManager;
|
|
2969
3015
|
_eventManager;
|
|
@@ -2987,7 +3033,7 @@ var Pi = {
|
|
|
2987
3033
|
unregisterExtension = (...e) => this._extensionManager.unregisterExtension(...e);
|
|
2988
3034
|
registerExtension = (...e) => this._extensionManager.registerExtension(...e);
|
|
2989
3035
|
replaceExtension = (...e) => this._extensionManager.replaceExtension(...e);
|
|
2990
|
-
getExtension = ((
|
|
3036
|
+
getExtension = ((e) => this._extensionManager.getExtension(e));
|
|
2991
3037
|
mount = (e, t) => {
|
|
2992
3038
|
let n = e.getRootNode(), r = typeof ShadowRoot < "u" && n instanceof ShadowRoot;
|
|
2993
3039
|
(t?.portalTarget ?? e.parentElement ?? (r ? n : document.body)).appendChild(this.portalElement), this._tiptapEditor.mount({ mount: e });
|
|
@@ -3060,7 +3106,7 @@ var Pi = {
|
|
|
3060
3106
|
this._tiptapEditor.on("selectionUpdate", e);
|
|
3061
3107
|
}
|
|
3062
3108
|
onBeforeChange(e) {
|
|
3063
|
-
return this._extensionManager.getExtension(
|
|
3109
|
+
return this._extensionManager.getExtension(be).subscribe(e);
|
|
3064
3110
|
}
|
|
3065
3111
|
getTextCursorPosition() {
|
|
3066
3112
|
return this._selectionManager.getTextCursorPosition();
|
|
@@ -3195,33 +3241,55 @@ var Pi = {
|
|
|
3195
3241
|
pasteMarkdown(e) {
|
|
3196
3242
|
return this._exportManager.pasteMarkdown(e);
|
|
3197
3243
|
}
|
|
3198
|
-
},
|
|
3244
|
+
}, Gi = class {
|
|
3199
3245
|
mappings;
|
|
3200
3246
|
options;
|
|
3201
3247
|
constructor(e, t, n) {
|
|
3202
3248
|
this.mappings = t, this.options = n;
|
|
3203
3249
|
}
|
|
3250
|
+
get dictionary() {
|
|
3251
|
+
return this.options.dictionary?.exporter ?? Ie.exporter;
|
|
3252
|
+
}
|
|
3204
3253
|
async resolveFile(e) {
|
|
3205
3254
|
if (!this.options?.resolveFileUrl) return (await fetch(e)).blob();
|
|
3206
3255
|
let t = await this.options.resolveFileUrl(e);
|
|
3207
3256
|
return t instanceof Blob ? t : (await fetch(t)).blob();
|
|
3208
3257
|
}
|
|
3209
3258
|
mapStyles(e) {
|
|
3210
|
-
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
|
+
});
|
|
3211
3264
|
}
|
|
3212
3265
|
mapInlineContent(e) {
|
|
3213
|
-
|
|
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);
|
|
3214
3269
|
}
|
|
3215
3270
|
transformInlineContent(e) {
|
|
3216
3271
|
return e.map((e) => this.mapInlineContent(e));
|
|
3217
3272
|
}
|
|
3218
3273
|
async mapBlock(e, t, n, r) {
|
|
3219
|
-
|
|
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);
|
|
3220
3277
|
}
|
|
3221
3278
|
};
|
|
3222
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
|
|
3223
3291
|
//#region src/exporter/mapping.ts
|
|
3224
|
-
function
|
|
3292
|
+
function Ji(e) {
|
|
3225
3293
|
return {
|
|
3226
3294
|
createBlockMapping: (e) => e,
|
|
3227
3295
|
createInlineContentMapping: (e) => e,
|
|
@@ -3230,7 +3298,7 @@ function Li(e) {
|
|
|
3230
3298
|
}
|
|
3231
3299
|
//#endregion
|
|
3232
3300
|
//#region src/util/combineByGroup.ts
|
|
3233
|
-
function
|
|
3301
|
+
function Yi(e, ...t) {
|
|
3234
3302
|
let n = [...e];
|
|
3235
3303
|
for (let e of t) for (let t of e) {
|
|
3236
3304
|
let e = n.findLastIndex((e) => e.group === t.group);
|
|
@@ -3239,6 +3307,6 @@ function Ri(e, ...t) {
|
|
|
3239
3307
|
return n;
|
|
3240
3308
|
}
|
|
3241
3309
|
//#endregion
|
|
3242
|
-
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 };
|
|
3243
3311
|
|
|
3244
|
-
//# sourceMappingURL=src-
|
|
3312
|
+
//# sourceMappingURL=src-BkfZVfaO.js.map
|