@blocknote/core 0.53.0 → 0.54.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BlockNoteExtension-BJCLnwrE.cjs +2 -0
- package/dist/BlockNoteExtension-BJCLnwrE.cjs.map +1 -0
- package/dist/BlockNoteExtension-CbvDA0F7.js +80 -0
- package/dist/BlockNoteExtension-CbvDA0F7.js.map +1 -0
- package/dist/{UserStore-QbbPFj0z.js → UserStore-C4TzkGEn.js} +3 -3
- package/dist/{UserStore-DCG6lsla.cjs.map → UserStore-C4TzkGEn.js.map} +1 -1
- package/dist/{UserStore-DCG6lsla.cjs → UserStore-mj3fXW4D.cjs} +2 -2
- package/dist/UserStore-mj3fXW4D.cjs.map +1 -0
- package/dist/blocknote.cjs +1 -1
- package/dist/blocknote.js +6 -6
- package/dist/blocks-CTB_5Vyj.cjs +12 -0
- package/dist/blocks-CTB_5Vyj.cjs.map +1 -0
- package/dist/{blocks-BEJW9OM_.js → blocks-Dol85hpH.js} +680 -670
- package/dist/blocks-Dol85hpH.js.map +1 -0
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +2 -2
- package/dist/comments.cjs +1 -1
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js +7 -7
- package/dist/comments.js.map +1 -1
- package/dist/en-BuzSuuTq.cjs +2 -0
- package/dist/en-BuzSuuTq.cjs.map +1 -0
- package/dist/{en-CGKXfWma.js → en-uzHzj6eH.js} +10 -1
- package/dist/en-uzHzj6eH.js.map +1 -0
- package/dist/extensions-B7Rsp_Ft.cjs +58 -0
- package/dist/extensions-B7Rsp_Ft.cjs.map +1 -0
- package/dist/{extensions-BR5hkAio.js → extensions-D6JcJCwd.js} +735 -457
- package/dist/extensions-D6JcJCwd.js.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +4 -4
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +199 -1
- package/dist/locales.js.map +1 -1
- package/dist/{src-BUXut68d.js → src-Buuo5l7X.js} +924 -851
- package/dist/src-Buuo5l7X.js.map +1 -0
- package/dist/src-C54Ok9E0.cjs +23 -0
- package/dist/src-C54Ok9E0.cjs.map +1 -0
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/dist/y.cjs +1 -1
- package/dist/y.cjs.map +1 -1
- package/dist/y.js +245 -242
- package/dist/y.js.map +1 -1
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.cjs.map +1 -1
- package/dist/yjs.js +79 -67
- package/dist/yjs.js.map +1 -1
- package/package.json +17 -18
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +2505 -763
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +42 -0
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +16 -4
- package/src/api/exporters/markdown/htmlToMarkdown.ts +45 -10
- package/src/api/getBlocksChangedByTransaction.test.ts +211 -0
- package/src/api/getBlocksChangedByTransaction.ts +48 -12
- package/src/api/getChangedRange.ts +54 -0
- package/src/api/nodeConversions/blockToNode.ts +5 -1
- package/src/api/nodeConversions/nodeToBlock.ts +3 -0
- package/src/api/pmUtil.ts +16 -8
- package/src/blocks/Code/CodeBlockOptions.ts +83 -0
- package/src/blocks/Code/block.test.ts +1 -1
- package/src/blocks/Code/block.ts +29 -281
- package/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.ts +120 -0
- package/src/blocks/Code/helpers/parse/parsePreCode.ts +45 -0
- package/src/blocks/Code/helpers/render/createCodeBlock.ts +98 -0
- package/src/blocks/Code/helpers/toExternalHTML/createPreCode.ts +14 -0
- package/src/blocks/index.ts +3 -1
- package/src/comments/extension.ts +2 -4
- package/src/editor/Block.css +273 -2
- package/src/editor/BlockNoteEditor.ts +25 -4
- package/src/editor/BlockNoteExtension.ts +1 -1
- package/src/editor/managers/ExtensionManager/extensions.ts +6 -0
- package/src/editor/performance.test.ts +45 -0
- package/src/exporter/ExportImage.ts +50 -0
- package/src/exporter/Exporter.test.ts +186 -0
- package/src/exporter/Exporter.ts +66 -14
- package/src/exporter/index.ts +1 -0
- package/src/exporter/mapping.ts +4 -1
- package/src/extensions/FormattingToolbar/FormattingToolbar.ts +10 -8
- package/src/extensions/InlineContentBoundaryEdit/InlineContentBoundaryEdit.ts +109 -0
- package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +21 -0
- package/src/extensions/PreviousBlockType/PreviousBlockType.ts +5 -3
- package/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.ts +192 -0
- package/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.ts +142 -0
- package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.ts +120 -0
- package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.ts +89 -0
- package/src/extensions/SyntaxHighlighting/inlineHighlight.test.ts +135 -0
- package/src/extensions/SyntaxHighlighting/shiki.ts +116 -0
- package/src/extensions/TableHandles/TableHandles.browser.test.ts +305 -0
- package/src/extensions/TableHandles/TableHandles.ts +82 -41
- package/src/extensions/Versioning/inMemoryVersioning.ts +13 -3
- package/src/extensions/index.ts +4 -0
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts +51 -2
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +22 -2
- package/src/fonts/inter.css +9 -9
- package/src/i18n/locales/ar.ts +9 -0
- package/src/i18n/locales/de.ts +9 -0
- package/src/i18n/locales/en.ts +9 -0
- package/src/i18n/locales/es.ts +9 -0
- package/src/i18n/locales/fa.ts +9 -0
- package/src/i18n/locales/fr.ts +9 -0
- package/src/i18n/locales/he.ts +9 -0
- package/src/i18n/locales/hr.ts +9 -0
- package/src/i18n/locales/is.ts +9 -0
- package/src/i18n/locales/it.ts +9 -0
- package/src/i18n/locales/ja.ts +9 -0
- package/src/i18n/locales/ko.ts +9 -0
- package/src/i18n/locales/nl.ts +9 -0
- package/src/i18n/locales/no.ts +9 -0
- package/src/i18n/locales/pl.ts +9 -0
- package/src/i18n/locales/pt.ts +9 -0
- package/src/i18n/locales/ru.ts +9 -0
- package/src/i18n/locales/sk.ts +9 -0
- package/src/i18n/locales/uk.ts +9 -0
- package/src/i18n/locales/uz.ts +9 -0
- package/src/i18n/locales/vi.ts +9 -0
- package/src/i18n/locales/zh-tw.ts +9 -0
- package/src/i18n/locales/zh.ts +9 -0
- package/src/index.ts +5 -1
- package/src/schema/blocks/createSpec.ts +5 -7
- package/src/schema/blocks/types.ts +53 -3
- package/src/schema/contentTypePropagation.test.ts +1 -1
- package/src/schema/inlineContent/createSpec.test.ts +161 -0
- package/src/schema/inlineContent/createSpec.ts +175 -17
- package/src/schema/inlineContent/internal.ts +21 -2
- package/src/schema/inlineContent/types.ts +35 -5
- package/src/schema/nodeViewMutations.test.ts +81 -56
- package/src/schema/nodeViewMutations.ts +30 -27
- package/src/schema/schema.test.ts +110 -0
- package/src/schema/schema.ts +13 -4
- package/src/user/UserStore.ts +1 -1
- package/src/util/Store.test.ts +132 -0
- package/src/util/Store.ts +135 -0
- package/src/y/extensions/AttributionExtension.test.ts +18 -9
- package/src/y/extensions/Versioning.test.ts +20 -7
- package/src/y/versioning/__test__/yhub.test.ts +92 -59
- package/src/y/versioning/yhub.ts +35 -29
- package/src/yjs/comments/RESTYjsThreadStore.test.ts +85 -0
- package/src/yjs/comments/RESTYjsThreadStore.ts +7 -1
- package/src/yjs/extensions/ForkYDoc.test.ts +37 -0
- package/src/yjs/extensions/ForkYDoc.ts +26 -1
- package/src/yjs/extensions/RelativePositionMapping.ts +8 -2
- package/src/yjs/extensions/Versioning.test.ts +17 -5
- package/types/src/api/getChangedRange.d.ts +14 -0
- package/types/src/api/pmUtil.d.ts +7 -7
- package/types/src/blocks/Code/CodeBlockOptions.d.ts +61 -0
- package/types/src/blocks/Code/block.d.ts +3 -53
- package/types/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.d.ts +35 -0
- package/types/src/blocks/Code/helpers/parse/parsePreCode.d.ts +8 -0
- package/types/src/blocks/Code/helpers/render/createCodeBlock.d.ts +18 -0
- package/types/src/blocks/Code/helpers/toExternalHTML/createPreCode.d.ts +5 -0
- package/types/src/blocks/index.d.ts +3 -1
- package/types/src/comments/extension.d.ts +1 -15
- package/types/src/editor/BlockNoteEditor.d.ts +3 -3
- package/types/src/editor/BlockNoteExtension.d.ts +1 -1
- package/types/src/exporter/ExportImage.d.ts +36 -0
- package/types/src/exporter/Exporter.d.ts +30 -0
- package/types/src/exporter/Exporter.test.d.ts +1 -0
- package/types/src/exporter/index.d.ts +1 -0
- package/types/src/exporter/mapping.d.ts +1 -1
- package/types/src/extensions/FilePanel/FilePanel.d.ts +1 -1
- package/types/src/extensions/FormattingToolbar/FormattingToolbar.d.ts +1 -1
- package/types/src/extensions/InlineContentBoundaryEdit/InlineContentBoundaryEdit.d.ts +5 -0
- package/types/src/extensions/ShowSelection/ShowSelection.d.ts +1 -5
- package/types/src/extensions/SideMenu/SideMenu.d.ts +1 -1
- package/types/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.d.ts +45 -0
- package/types/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.d.ts +49 -0
- package/types/src/extensions/SuggestionMenu/SuggestionMenu.d.ts +1 -11
- package/types/src/extensions/SyntaxHighlighting/SyntaxHighlighting.d.ts +44 -0
- package/types/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.d.ts +1 -0
- package/types/src/extensions/SyntaxHighlighting/inlineHighlight.test.d.ts +1 -0
- package/types/src/extensions/SyntaxHighlighting/shiki.d.ts +13 -0
- package/types/src/extensions/TableHandles/TableHandles.browser.test.d.ts +1 -0
- package/types/src/extensions/TableHandles/TableHandles.d.ts +4 -1
- package/types/src/extensions/Versioning/Versioning.d.ts +1 -35
- package/types/src/extensions/index.d.ts +4 -0
- package/types/src/i18n/locales/en.d.ts +9 -0
- package/types/src/i18n/locales/fa.d.ts +9 -0
- package/types/src/i18n/locales/sk.d.ts +9 -0
- package/types/src/index.d.ts +2 -1
- package/types/src/schema/blocks/types.d.ts +36 -3
- package/types/src/schema/inlineContent/createSpec.d.ts +35 -3
- package/types/src/schema/inlineContent/createSpec.test.d.ts +1 -0
- package/types/src/schema/inlineContent/internal.d.ts +3 -2
- package/types/src/schema/inlineContent/types.d.ts +22 -3
- package/types/src/schema/nodeViewMutations.d.ts +2 -2
- package/types/src/schema/schema.test.d.ts +1 -0
- package/types/src/user/UserStore.d.ts +1 -1
- package/types/src/util/Store.d.ts +45 -0
- package/types/src/util/Store.test.d.ts +1 -0
- package/types/src/y/extensions/AttributionExtension.d.ts +1 -1
- package/types/src/y/extensions/DiffVersioningExtension.d.ts +1 -1
- package/types/src/y/extensions/ForkYDoc.d.ts +1 -5
- package/types/src/y/extensions/index.d.ts +2 -10
- package/types/src/y/versioning/yhub.d.ts +3 -2
- package/types/src/yjs/comments/RESTYjsThreadStore.test.d.ts +1 -0
- package/types/src/yjs/extensions/ForkYDoc.d.ts +1 -5
- package/types/src/yjs/extensions/index.d.ts +1 -5
- package/dist/BlockNoteExtension-B_IEJHS8.js +0 -38
- package/dist/BlockNoteExtension-B_IEJHS8.js.map +0 -1
- package/dist/BlockNoteExtension-M0znTzxP.cjs +0 -2
- package/dist/BlockNoteExtension-M0znTzxP.cjs.map +0 -1
- package/dist/UserStore-QbbPFj0z.js.map +0 -1
- package/dist/blocks-BEJW9OM_.js.map +0 -1
- package/dist/blocks-BPmJglFo.cjs +0 -12
- package/dist/blocks-BPmJglFo.cjs.map +0 -1
- package/dist/en-C5Z4Ag9_.cjs +0 -2
- package/dist/en-C5Z4Ag9_.cjs.map +0 -1
- package/dist/en-CGKXfWma.js.map +0 -1
- package/dist/extensions-AitWbYdJ.cjs +0 -52
- package/dist/extensions-AitWbYdJ.cjs.map +0 -1
- package/dist/extensions-BR5hkAio.js.map +0 -1
- package/dist/src-BHPuOo7W.cjs +0 -21
- package/dist/src-BHPuOo7W.cjs.map +0 -1
- package/dist/src-BUXut68d.js.map +0 -1
- package/src/blocks/Code/shiki.ts +0 -73
- package/src/blocks/File/helpers/uploadToTmpFilesDotOrg_DEV_ONLY.ts +0 -20
- package/types/src/blocks/Code/shiki.d.ts +0 -4
- package/types/src/blocks/File/helpers/uploadToTmpFilesDotOrg_DEV_ONLY.d.ts +0 -6
package/dist/y.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { _ as o,
|
|
4
|
-
import { a as u, i as d, o as f } from "./extensions-
|
|
5
|
-
import { n as p } from "./UserStore-
|
|
1
|
+
import { Cn as e, D as t, Ft as n } from "./blocks-Dol85hpH.js";
|
|
2
|
+
import { a as r, n as i, t as a } from "./BlockNoteExtension-CbvDA0F7.js";
|
|
3
|
+
import { _ as o, b as s, x as c, y as l } from "./src-Buuo5l7X.js";
|
|
4
|
+
import { a as u, i as d, o as f } from "./extensions-D6JcJCwd.js";
|
|
5
|
+
import { n as p } from "./UserStore-C4TzkGEn.js";
|
|
6
6
|
import { t as m } from "./ThreadStore-et9wB5Xt.js";
|
|
7
|
-
import { Mark as h, getChangedRanges as
|
|
8
|
-
import { uint32 as
|
|
9
|
-
import { Plugin as
|
|
10
|
-
import { acceptAllChanges as
|
|
11
|
-
import * as
|
|
12
|
-
import * as
|
|
13
|
-
import { decodeAny as
|
|
7
|
+
import { Mark as h, getChangedRanges as ee, getMarkRange as te, posToDOMRect as ne } from "@tiptap/core";
|
|
8
|
+
import { uint32 as re, uuidv4 as g } from "lib0/random";
|
|
9
|
+
import { Plugin as ie, PluginKey as ae } from "prosemirror-state";
|
|
10
|
+
import { acceptAllChanges as oe, acceptChanges as se, configureYProsemirror as _, defaultSelectionBuilder as ce, deltaAttributionToFormat as le, deltaToPNode as ue, deltaToPSteps as de, docToDelta as v, nodeToDelta as y, pauseSync as fe, pmToFragment as pe, rejectAllChanges as me, rejectChanges as he, relativePositionStore as ge, syncPlugin as _e, yCursorPlugin as ve, ySyncPluginKey as b } from "@y/prosemirror";
|
|
11
|
+
import * as x from "lib0/delta";
|
|
12
|
+
import * as S from "@y/y";
|
|
13
|
+
import { decodeAny as C, encodeAny as w } from "lib0/buffer";
|
|
14
14
|
//#region src/y/extensions/YAttributionMarks.ts
|
|
15
|
-
var
|
|
16
|
-
let i = t?.editor, a = e === "insert" ? "ins" : e === "delete" ? "del" : r ? "span" : "div",
|
|
17
|
-
Object.assign(
|
|
15
|
+
var T = (e, t) => e === void 0 ? void 0 : typeof e == "string" ? e : e[t], E = (e, t) => ({ mark: n, inline: r }) => {
|
|
16
|
+
let i = t?.editor, a = e === "insert" ? "ins" : e === "delete" ? "del" : r ? "span" : "div", o = document.createElement(a);
|
|
17
|
+
Object.assign(o.dataset, {
|
|
18
18
|
userIds: JSON.stringify(n.attrs.userIds),
|
|
19
19
|
inline: String(r)
|
|
20
|
-
}), e === "modification" && (
|
|
21
|
-
let u =
|
|
20
|
+
}), e === "modification" && (o.dataset.type = "modification", o.dataset.format = JSON.stringify(n.attrs.format));
|
|
21
|
+
let u = T(t?.getAttributionMarkClassName?.({
|
|
22
22
|
contentType: r ? "inline-content" : "block",
|
|
23
23
|
modificationType: e === "modification" ? "format" : e
|
|
24
|
-
}), "content"), d = (n.attrs.userIds ?? [])[0], f = d ?
|
|
25
|
-
if (u)
|
|
24
|
+
}), "content"), d = (n.attrs.userIds ?? [])[0], f = d ? l(d) : s[0];
|
|
25
|
+
if (u) o.style.cssText = "display: contents";
|
|
26
26
|
else {
|
|
27
|
-
let e = d ? `var(${
|
|
28
|
-
|
|
27
|
+
let e = d ? `var(${c(d).light}, ${f.light})` : f.light, t = d ? `var(${c(d).dark}, ${f.dark})` : f.dark;
|
|
28
|
+
o.style.cssText = `display: contents; --user-color-light: ${e}; --user-color-dark: ${t}`;
|
|
29
29
|
}
|
|
30
30
|
let p = document.createElement("span");
|
|
31
31
|
if (r) p.className = u ?? (e === "delete" ? "bn-suggestion-mark bn-suggestion-mark--delete" : "bn-suggestion-mark");
|
|
@@ -33,11 +33,11 @@ var D = (e, t) => e === void 0 ? void 0 : typeof e == "string" ? e : e[t], O = (
|
|
|
33
33
|
let e = i?.dictionary.suggestion_changes.deleted;
|
|
34
34
|
e && p.style.setProperty("--deleted-label", JSON.stringify(e));
|
|
35
35
|
}
|
|
36
|
-
return
|
|
37
|
-
dom:
|
|
36
|
+
return o.appendChild(p), {
|
|
37
|
+
dom: o,
|
|
38
38
|
contentDOM: p
|
|
39
39
|
};
|
|
40
|
-
},
|
|
40
|
+
}, D = h.create({
|
|
41
41
|
name: "y-attributed-insert",
|
|
42
42
|
inclusive: !1,
|
|
43
43
|
excludes: "",
|
|
@@ -46,12 +46,12 @@ var D = (e, t) => e === void 0 ? void 0 : typeof e == "string" ? e : e[t], O = (
|
|
|
46
46
|
return { userIds: { default: null } };
|
|
47
47
|
},
|
|
48
48
|
addMarkView() {
|
|
49
|
-
return
|
|
49
|
+
return E("insert", { getAttributionMarkClassName: this.options.getAttributionMarkClassName });
|
|
50
50
|
},
|
|
51
51
|
extendMarkSchema(e) {
|
|
52
52
|
return e.name === this.name ? { blocknoteIgnore: !0 } : {};
|
|
53
53
|
}
|
|
54
|
-
}),
|
|
54
|
+
}), O = h.create({
|
|
55
55
|
name: "y-attributed-delete",
|
|
56
56
|
inclusive: !1,
|
|
57
57
|
excludes: "",
|
|
@@ -60,7 +60,7 @@ var D = (e, t) => e === void 0 ? void 0 : typeof e == "string" ? e : e[t], O = (
|
|
|
60
60
|
return { userIds: { default: null } };
|
|
61
61
|
},
|
|
62
62
|
addMarkView() {
|
|
63
|
-
return
|
|
63
|
+
return E("delete", {
|
|
64
64
|
editor: this.options.editor,
|
|
65
65
|
getAttributionMarkClassName: this.options.getAttributionMarkClassName
|
|
66
66
|
});
|
|
@@ -68,7 +68,7 @@ var D = (e, t) => e === void 0 ? void 0 : typeof e == "string" ? e : e[t], O = (
|
|
|
68
68
|
extendMarkSchema(e) {
|
|
69
69
|
return e.name === this.name ? { blocknoteIgnore: !0 } : {};
|
|
70
70
|
}
|
|
71
|
-
}),
|
|
71
|
+
}), k = h.create({
|
|
72
72
|
name: "y-attributed-format",
|
|
73
73
|
inclusive: !1,
|
|
74
74
|
excludes: "",
|
|
@@ -80,23 +80,23 @@ var D = (e, t) => e === void 0 ? void 0 : typeof e == "string" ? e : e[t], O = (
|
|
|
80
80
|
};
|
|
81
81
|
},
|
|
82
82
|
addMarkView() {
|
|
83
|
-
return
|
|
83
|
+
return E("modification", { getAttributionMarkClassName: this.options.getAttributionMarkClassName });
|
|
84
84
|
},
|
|
85
85
|
extendMarkSchema(e) {
|
|
86
86
|
return e.name === this.name ? { blocknoteIgnore: !0 } : {};
|
|
87
87
|
}
|
|
88
|
-
}),
|
|
88
|
+
}), A = a(({ options: e }) => ({
|
|
89
89
|
key: "yAttributionMarks",
|
|
90
90
|
tiptapExtensions: [
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
D.configure({ getAttributionMarkClassName: e?.getAttributionMarkClassName }),
|
|
92
|
+
O.configure({ getAttributionMarkClassName: e?.getAttributionMarkClassName }),
|
|
93
|
+
k.configure({ getAttributionMarkClassName: e?.getAttributionMarkClassName })
|
|
94
94
|
]
|
|
95
|
-
})),
|
|
95
|
+
})), ye = {
|
|
96
96
|
"y-attributed-insert": "insert",
|
|
97
97
|
"y-attributed-delete": "delete",
|
|
98
98
|
"y-attributed-format": "format"
|
|
99
|
-
},
|
|
99
|
+
}, be = new ae("attributionLoadUsers"), j = "[data-user-ids]", M = (e) => {
|
|
100
100
|
if (!e) return [];
|
|
101
101
|
let t;
|
|
102
102
|
try {
|
|
@@ -105,7 +105,7 @@ var D = (e, t) => e === void 0 ? void 0 : typeof e == "string" ? e : e[t], O = (
|
|
|
105
105
|
return [];
|
|
106
106
|
}
|
|
107
107
|
return Array.isArray(t) ? t.map(String) : [];
|
|
108
|
-
},
|
|
108
|
+
}, N = (e) => {
|
|
109
109
|
if (!e) return [];
|
|
110
110
|
let t;
|
|
111
111
|
try {
|
|
@@ -114,18 +114,18 @@ var D = (e, t) => e === void 0 ? void 0 : typeof e == "string" ? e : e[t], O = (
|
|
|
114
114
|
return [];
|
|
115
115
|
}
|
|
116
116
|
return typeof t != "object" || !t ? [] : Object.keys(t);
|
|
117
|
-
},
|
|
117
|
+
}, P = (e) => {
|
|
118
118
|
let t = e.firstElementChild ?? e, n = t.getBoundingClientRect();
|
|
119
119
|
return n.width || n.height ? t : t.firstElementChild ?? t;
|
|
120
|
-
},
|
|
120
|
+
}, xe = (e) => P(e).getBoundingClientRect(), Se = (e) => P(e).getClientRects(), F = a(({ options: e }) => {
|
|
121
121
|
let t = p(e?.resolveUsers), n = e?.getAttributionMarkClassName, r = i(void 0), a = (e) => {
|
|
122
|
-
let n =
|
|
122
|
+
let n = ee(e);
|
|
123
123
|
if (n.length === 0) return;
|
|
124
124
|
let r = Infinity, i = -Infinity;
|
|
125
125
|
for (let { newRange: e } of n) r = Math.min(r, e.from), i = Math.max(i, e.to);
|
|
126
126
|
let a = /* @__PURE__ */ new Set();
|
|
127
127
|
e.doc.nodesBetween(r, i, (e) => {
|
|
128
|
-
for (let t of e.marks)
|
|
128
|
+
for (let t of e.marks) ye[t.type.name] && t.attrs.userIds?.forEach((e) => a.add(e));
|
|
129
129
|
return !0;
|
|
130
130
|
}), a.size > 0 && t.loadUsers(Array.from(a));
|
|
131
131
|
};
|
|
@@ -133,104 +133,104 @@ var D = (e, t) => e === void 0 ? void 0 : typeof e == "string" ? e : e[t], O = (
|
|
|
133
133
|
key: "attribution",
|
|
134
134
|
userStore: t,
|
|
135
135
|
store: r,
|
|
136
|
-
prosemirrorPlugins: [new
|
|
137
|
-
key:
|
|
136
|
+
prosemirrorPlugins: [new ie({
|
|
137
|
+
key: be,
|
|
138
138
|
state: {
|
|
139
139
|
init: () => null,
|
|
140
140
|
apply: (e) => (e.docChanged && a(e), null)
|
|
141
141
|
}
|
|
142
142
|
})],
|
|
143
143
|
mount({ dom: e, root: i, signal: a }) {
|
|
144
|
-
let
|
|
144
|
+
let s = () => {
|
|
145
145
|
for (let [n, r] of t.store.state) {
|
|
146
|
-
let { light: t, dark: i } =
|
|
146
|
+
let { light: t, dark: i } = c(n);
|
|
147
147
|
r.color && r.colorLight ? (e.style.setProperty(t, r.colorLight), e.style.setProperty(i, r.color)) : (e.style.removeProperty(t), e.style.removeProperty(i));
|
|
148
148
|
}
|
|
149
|
-
},
|
|
150
|
-
let t =
|
|
151
|
-
return t.length === 0 ? "" : `${
|
|
149
|
+
}, l, u = (e) => M(e).map((e) => t.getUser(e)?.username ?? e), d = (e) => {
|
|
150
|
+
let t = M(e.dataset.userIds);
|
|
151
|
+
return t.length === 0 ? "" : `${N(e.dataset.format).join(",")}:${t.join(",")}`;
|
|
152
152
|
}, f = (e) => {
|
|
153
153
|
let r = e.dataset.format !== void 0, i = r ? "format" : e.tagName === "INS" ? "insert" : "delete", a = e.dataset.inline === "false" ? "block" : "inline-content";
|
|
154
154
|
return {
|
|
155
155
|
anchor: e,
|
|
156
|
-
color:
|
|
156
|
+
color: o(t, M(e.dataset.userIds)).dark,
|
|
157
157
|
modificationType: i,
|
|
158
158
|
contentType: a,
|
|
159
159
|
users: u(e.dataset.userIds),
|
|
160
|
-
format: r ?
|
|
161
|
-
className:
|
|
160
|
+
format: r ? N(e.dataset.format) : void 0,
|
|
161
|
+
className: T(n?.({
|
|
162
162
|
contentType: a,
|
|
163
163
|
modificationType: i
|
|
164
164
|
}), "tooltip")
|
|
165
165
|
};
|
|
166
166
|
}, p = () => {
|
|
167
|
-
|
|
167
|
+
l && (l = void 0, r.setState(void 0));
|
|
168
168
|
}, m = (e) => {
|
|
169
169
|
for (; e;) {
|
|
170
|
-
let t = e.closest(
|
|
170
|
+
let t = e.closest(j);
|
|
171
171
|
if (!t) return;
|
|
172
172
|
if (d(t)) return t;
|
|
173
173
|
e = t.parentElement;
|
|
174
174
|
}
|
|
175
175
|
};
|
|
176
176
|
i.addEventListener("mouseover", (e) => {
|
|
177
|
-
let n =
|
|
178
|
-
if (!
|
|
177
|
+
let n = e.target instanceof Element ? e.target : null, i = m(n);
|
|
178
|
+
if (!i) {
|
|
179
179
|
p();
|
|
180
180
|
return;
|
|
181
181
|
}
|
|
182
|
-
let
|
|
183
|
-
for (;
|
|
184
|
-
let e =
|
|
182
|
+
let a = d(i), o = i, s = i.parentElement;
|
|
183
|
+
for (; s;) {
|
|
184
|
+
let e = s.closest(j);
|
|
185
185
|
if (!e) break;
|
|
186
186
|
let t = d(e);
|
|
187
|
-
if (t ===
|
|
187
|
+
if (t === a) o = e;
|
|
188
188
|
else if (t) break;
|
|
189
|
-
|
|
189
|
+
s = e.parentElement;
|
|
190
190
|
}
|
|
191
|
-
if (
|
|
192
|
-
|
|
193
|
-
let
|
|
194
|
-
|
|
195
|
-
|
|
191
|
+
if (l === o) return;
|
|
192
|
+
l = o, r.setState(f(o));
|
|
193
|
+
let c = M(o.dataset.userIds);
|
|
194
|
+
c.length > 0 && t.loadUsers(c).then(() => {
|
|
195
|
+
l === o && r.setState(f(o));
|
|
196
196
|
});
|
|
197
|
-
}, { signal: a }), a.addEventListener("abort", p),
|
|
198
|
-
let h = t.store.subscribe(
|
|
197
|
+
}, { signal: a }), a.addEventListener("abort", p), s();
|
|
198
|
+
let h = t.store.subscribe(s);
|
|
199
199
|
a.addEventListener("abort", h);
|
|
200
200
|
},
|
|
201
|
-
blockNoteExtensions: [
|
|
201
|
+
blockNoteExtensions: [A({ getAttributionMarkClassName: e?.getAttributionMarkClassName })]
|
|
202
202
|
};
|
|
203
|
-
}),
|
|
203
|
+
}), I = a(({ editor: e }) => ({
|
|
204
204
|
key: "yPositionMapping",
|
|
205
205
|
mapPosition: (t, n = "left") => {
|
|
206
|
-
let r =
|
|
206
|
+
let r = b.getState(e.prosemirrorState);
|
|
207
207
|
if (!r?.ytype) throw Error("YSync plugin state not found");
|
|
208
208
|
if (t === 0) return () => 0;
|
|
209
|
-
let i =
|
|
209
|
+
let i = ge(e.prosemirrorState.doc.resolve(t + (n === "right" ? 1 : -1)), r.ytype, r.renderer);
|
|
210
210
|
return () => {
|
|
211
|
-
let t =
|
|
211
|
+
let t = b.getState(e.prosemirrorState), r = i(e.prosemirrorState.doc, t.ytype, t.renderer);
|
|
212
212
|
if (r === null) throw Error("Position not found, cannot track positions");
|
|
213
213
|
return r + (n === "right" ? -1 : 1);
|
|
214
214
|
};
|
|
215
215
|
}
|
|
216
|
-
})),
|
|
217
|
-
for (let t of e.children) if (
|
|
218
|
-
for (let e of t.insert) if (
|
|
216
|
+
})), L = (e) => {
|
|
217
|
+
for (let t of e.children) if (x.$insertOp.check(t)) {
|
|
218
|
+
for (let e of t.insert) if (x.$deltaAny.check(e)) return e;
|
|
219
219
|
}
|
|
220
220
|
return null;
|
|
221
|
-
},
|
|
222
|
-
for (let t of e.children) if (
|
|
223
|
-
for (let e of t.insert) if (
|
|
221
|
+
}, R = (e) => {
|
|
222
|
+
for (let t of e.children) if (x.$insertOp.check(t)) {
|
|
223
|
+
for (let e of t.insert) if (x.$deltaAny.check(e) && e.name === "blockGroup") return !0;
|
|
224
224
|
}
|
|
225
225
|
return !1;
|
|
226
226
|
};
|
|
227
|
-
function
|
|
227
|
+
function z(e) {
|
|
228
228
|
if (e.name !== "table") return null;
|
|
229
229
|
let t = [];
|
|
230
|
-
for (let n of e.children) if (
|
|
230
|
+
for (let n of e.children) if (x.$insertOp.check(n)) for (let e of n.insert) {
|
|
231
231
|
if (e.name !== "tableRow") return null;
|
|
232
232
|
let n = [];
|
|
233
|
-
for (let t of e.children) if (
|
|
233
|
+
for (let t of e.children) if (x.$insertOp.check(t)) for (let e of t.insert) {
|
|
234
234
|
if (e.name !== "tableCell" && e.name !== "tableHeader") return null;
|
|
235
235
|
n.push({
|
|
236
236
|
colspan: Number(e.attrs.colspan) || 1,
|
|
@@ -259,92 +259,95 @@ function B(e) {
|
|
|
259
259
|
cols: r
|
|
260
260
|
};
|
|
261
261
|
}
|
|
262
|
-
var
|
|
262
|
+
var B = (e, t) => {
|
|
263
263
|
if (e.name !== t.name) return !1;
|
|
264
264
|
if (e.name !== "blockContainer") return !0;
|
|
265
|
-
let n =
|
|
266
|
-
if (n?.name !== r?.name ||
|
|
265
|
+
let n = L(e), r = L(t);
|
|
266
|
+
if (n?.name !== r?.name || R(e) !== R(t)) return !1;
|
|
267
267
|
if (n?.name === "table" && r?.name === "table") {
|
|
268
|
-
let e =
|
|
268
|
+
let e = z(n), t = z(r);
|
|
269
269
|
if (e !== null && t !== null && e.rows !== t.rows && e.cols !== t.cols) return !1;
|
|
270
270
|
}
|
|
271
271
|
return !0;
|
|
272
|
-
},
|
|
272
|
+
}, V = (e, t) => {
|
|
273
273
|
let n = { ...e };
|
|
274
274
|
return t.insert && (n["y-attributed-insert"] = { userIds: t.insert }), t.delete && (n["y-attributed-delete"] = { userIds: t.delete }), t.format && (n["y-attributed-format"] = {
|
|
275
275
|
userIds: [...new Set(Object.values(t.format).flat())],
|
|
276
276
|
format: t.format
|
|
277
277
|
}), n;
|
|
278
|
-
},
|
|
278
|
+
}, H = a(({ options: e, editor: t }) => ({
|
|
279
279
|
key: "ySync",
|
|
280
280
|
fragment: e.fragment,
|
|
281
281
|
mount: () => {
|
|
282
282
|
let n = () => {
|
|
283
|
-
t.exec(
|
|
283
|
+
t.exec(_({ ytype: e.fragment }));
|
|
284
284
|
};
|
|
285
|
-
if (e.provider && "synced" in e.provider && typeof e.provider.synced == "boolean")
|
|
286
|
-
|
|
287
|
-
e &&
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
285
|
+
if (e.provider && "synced" in e.provider && typeof e.provider.synced == "boolean") {
|
|
286
|
+
if (e.provider.synced) n();
|
|
287
|
+
else if ("on" in e.provider && typeof e.provider.on == "function") e.provider.on("synced", (e) => {
|
|
288
|
+
e && n();
|
|
289
|
+
});
|
|
290
|
+
else throw Error("YSyncExtension: provider must have a 'synced' boolean or an 'on' method to listen for 'sync'");
|
|
291
|
+
} else n();
|
|
291
292
|
},
|
|
292
|
-
prosemirrorPlugins: [
|
|
293
|
+
prosemirrorPlugins: [_e({
|
|
293
294
|
suggestionDoc: e.suggestionDoc,
|
|
294
|
-
mapAttributionToMark:
|
|
295
|
-
customCompare:
|
|
295
|
+
mapAttributionToMark: V,
|
|
296
|
+
customCompare: B
|
|
296
297
|
})],
|
|
297
298
|
runsBefore: ["default"]
|
|
298
299
|
}));
|
|
299
300
|
//#endregion
|
|
300
301
|
//#region src/y/utils.ts
|
|
301
|
-
function
|
|
302
|
+
function U(e, t) {
|
|
302
303
|
let n = e.doc;
|
|
303
304
|
if (!n) throw Error("type does not have a ydoc");
|
|
304
305
|
if (e._item === null) {
|
|
305
306
|
let r = Array.from(n.share.keys()).find((t) => n.share.get(t) === e);
|
|
306
307
|
if (r == null) throw Error("type does not exist in other ydoc");
|
|
307
308
|
return t.get(r, e.constructor);
|
|
308
|
-
}
|
|
309
|
-
|
|
309
|
+
}
|
|
310
|
+
{
|
|
311
|
+
let n = e._item, r = t.store.clients.get(n.id.client) ?? [], i = r[S.findIndexSS(r, n.id.clock)];
|
|
310
312
|
if (!i) throw Error("type does not exist in other ydoc");
|
|
311
313
|
let a = i.content;
|
|
312
314
|
if (!a) throw Error("type does not exist in other ydoc");
|
|
313
315
|
return a.type;
|
|
314
316
|
}
|
|
315
317
|
}
|
|
316
|
-
function
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
function G(t, n) {
|
|
320
|
-
let r = n.map((n) => e(n, t.pmSchema));
|
|
321
|
-
return t.pmSchema.topNodeType.create(null, t.pmSchema.nodes.blockGroup.create(null, r));
|
|
318
|
+
function Ce(t, n) {
|
|
319
|
+
let r = t.pmSchema.nodeFromJSON(n);
|
|
320
|
+
return e(r);
|
|
322
321
|
}
|
|
323
|
-
function
|
|
324
|
-
let r =
|
|
325
|
-
return
|
|
322
|
+
function W(e, t) {
|
|
323
|
+
let r = t.map((t) => n(t, e.pmSchema));
|
|
324
|
+
return e.pmSchema.topNodeType.create(null, e.pmSchema.nodes.blockGroup.create(null, r));
|
|
326
325
|
}
|
|
327
|
-
function
|
|
328
|
-
|
|
326
|
+
function G(t, n) {
|
|
327
|
+
let r = ue(n.toDeltaDeep(), t.pmSchema, null);
|
|
328
|
+
return r === null ? [] : e(r);
|
|
329
329
|
}
|
|
330
|
-
function we(e, t, n
|
|
331
|
-
return
|
|
330
|
+
function we(e, t, n) {
|
|
331
|
+
return n ||= new S.Doc().get("prosemirror"), pe(W(e, t), n);
|
|
332
332
|
}
|
|
333
333
|
function Te(e, t, n = "prosemirror") {
|
|
334
|
-
|
|
334
|
+
return G(e, t.get(n));
|
|
335
|
+
}
|
|
336
|
+
function Ee(e, t, n = "prosemirror") {
|
|
337
|
+
let r = v(W(e, t)), i = new S.Doc();
|
|
335
338
|
return i.get(n).applyDelta(r), i;
|
|
336
339
|
}
|
|
337
|
-
function
|
|
338
|
-
let n =
|
|
339
|
-
return
|
|
340
|
+
function K(e, t) {
|
|
341
|
+
let n = y(e), r = y(t);
|
|
342
|
+
return x.diff(n.done(), r.done(), { compare: B });
|
|
340
343
|
}
|
|
341
|
-
function
|
|
342
|
-
let r =
|
|
343
|
-
return
|
|
344
|
+
function q({ tr: e, fragment: t, renderer: n }) {
|
|
345
|
+
let r = le(t.toDeltaDeep({ renderer: n }), V), i = y(e.doc, void 0, !0), a = x.diff(i.done(), r.done(), { compare: B });
|
|
346
|
+
return de(e, a, void 0, void 0);
|
|
344
347
|
}
|
|
345
348
|
//#endregion
|
|
346
349
|
//#region src/y/extensions/Suggestions.ts
|
|
347
|
-
var
|
|
350
|
+
var De = a(({ editor: e, options: t }) => {
|
|
348
351
|
let n = t.suggestionDoc;
|
|
349
352
|
if (!n) throw Error("Suggestion doc not found");
|
|
350
353
|
let r = p(t.resolveUsers);
|
|
@@ -360,7 +363,7 @@ var Ee = a(({ editor: e, options: t }) => {
|
|
|
360
363
|
return e.transact((r) => {
|
|
361
364
|
let i = r.doc.resolve(t), a = i.marks().find((e) => e.type.name === n);
|
|
362
365
|
if (!a) return;
|
|
363
|
-
let o =
|
|
366
|
+
let o = te(i, a.type);
|
|
364
367
|
if (o) return {
|
|
365
368
|
range: o,
|
|
366
369
|
mark: a,
|
|
@@ -368,7 +371,7 @@ var Ee = a(({ editor: e, options: t }) => {
|
|
|
368
371
|
return r.doc.textBetween(o.from, o.to);
|
|
369
372
|
},
|
|
370
373
|
get position() {
|
|
371
|
-
return
|
|
374
|
+
return ne(e.prosemirrorView, o.from, o.to).toJSON();
|
|
372
375
|
}
|
|
373
376
|
};
|
|
374
377
|
});
|
|
@@ -384,68 +387,68 @@ var Ee = a(({ editor: e, options: t }) => {
|
|
|
384
387
|
userStore: r,
|
|
385
388
|
runsBefore: ["ySync"],
|
|
386
389
|
viewSuggestions: () => {
|
|
387
|
-
t.renderer && (t.renderer.suggestionMode = !1), e.exec(
|
|
388
|
-
ytype:
|
|
390
|
+
t.renderer && (t.renderer.suggestionMode = !1), e.exec(_({
|
|
391
|
+
ytype: U(t.fragment, n),
|
|
389
392
|
renderer: t.renderer
|
|
390
393
|
}));
|
|
391
394
|
},
|
|
392
395
|
enableSuggestions: () => {
|
|
393
|
-
t.renderer && (t.renderer.suggestionMode = !0), e.exec(
|
|
394
|
-
ytype:
|
|
396
|
+
t.renderer && (t.renderer.suggestionMode = !0), e.exec(_({
|
|
397
|
+
ytype: U(t.fragment, n),
|
|
395
398
|
renderer: t.renderer
|
|
396
399
|
}));
|
|
397
400
|
},
|
|
398
401
|
disableSuggestions: () => {
|
|
399
|
-
e.exec(
|
|
402
|
+
e.exec(_({
|
|
400
403
|
ytype: t.fragment,
|
|
401
404
|
renderer: null
|
|
402
405
|
}));
|
|
403
406
|
},
|
|
404
|
-
applyAllSuggestions: () => e.exec(
|
|
405
|
-
applySuggestion: (t, n) => e.exec(
|
|
406
|
-
revertSuggestion: (t, n) => e.exec(
|
|
407
|
-
revertAllSuggestions: () => e.exec(
|
|
407
|
+
applyAllSuggestions: () => e.exec(oe()),
|
|
408
|
+
applySuggestion: (t, n) => e.exec(se(t, n)),
|
|
409
|
+
revertSuggestion: (t, n) => e.exec(he(t, n)),
|
|
410
|
+
revertAllSuggestions: () => e.exec(me()),
|
|
408
411
|
getSuggestionElementAtPos: i,
|
|
409
412
|
getMarkAtPos: a,
|
|
410
413
|
getSuggestionAtSelection: o,
|
|
411
414
|
getSuggestionAtCoords: (t) => e.transact(() => {
|
|
412
415
|
let n = e.prosemirrorView.posAtCoords(t);
|
|
413
|
-
if (
|
|
416
|
+
if (n !== null && n?.inside !== -1) return a(n.pos, "y-attributed-insert") || a(n.pos, "y-attributed-delete") || a(n.pos, "y-attributed-format");
|
|
414
417
|
}),
|
|
415
418
|
checkUnresolvedSuggestions: () => {
|
|
416
419
|
let t = !1;
|
|
417
|
-
return e.prosemirrorState.doc.descendants((e) => t
|
|
420
|
+
return e.prosemirrorState.doc.descendants((e) => !t && (t = e.marks.findIndex((e) => e.type.name === "y-attributed-insert" || e.type.name === "y-attributed-delete" || e.type.name === "y-attributed-format") !== -1, !0)), t;
|
|
418
421
|
}
|
|
419
422
|
};
|
|
420
423
|
});
|
|
421
424
|
//#endregion
|
|
422
425
|
//#region src/y/extensions/Versioning.ts
|
|
423
|
-
function
|
|
424
|
-
e.exec(
|
|
426
|
+
function Oe(e) {
|
|
427
|
+
e.exec(fe), e.removeBlocks(e.document);
|
|
425
428
|
}
|
|
426
|
-
function
|
|
429
|
+
function ke(e, t) {
|
|
427
430
|
return {
|
|
428
431
|
getCurrentDocument: () => t,
|
|
429
|
-
serializeCurrentContent: () =>
|
|
432
|
+
serializeCurrentContent: () => S.encodeStateAsUpdateV2(t.doc),
|
|
430
433
|
preview: {
|
|
431
434
|
enterPreview: (n, r, i) => {
|
|
432
435
|
let a;
|
|
433
436
|
if (r) {
|
|
434
|
-
let e = new
|
|
435
|
-
|
|
437
|
+
let e = new S.Doc({ isSuggestionDoc: !0 });
|
|
438
|
+
S.applyUpdateV2(e, r), a = { fragment: U(t, e) };
|
|
436
439
|
}
|
|
437
|
-
let o = new
|
|
438
|
-
|
|
439
|
-
let r =
|
|
440
|
+
let o = new S.Doc();
|
|
441
|
+
S.applyUpdateV2(o, n), Oe(e), e.exec((e, n) => {
|
|
442
|
+
let r = q({
|
|
440
443
|
tr: e.tr,
|
|
441
|
-
fragment:
|
|
442
|
-
renderer: a ?
|
|
444
|
+
fragment: U(t, o),
|
|
445
|
+
renderer: a ? S.createDiffRenderer(a.fragment.doc, o, i ? { attrs: i } : void 0) : void 0
|
|
443
446
|
});
|
|
444
447
|
return n && n(r), !0;
|
|
445
448
|
});
|
|
446
449
|
},
|
|
447
450
|
exitPreview: () => {
|
|
448
|
-
|
|
451
|
+
Oe(e), e.exec(_({ ytype: t }));
|
|
449
452
|
},
|
|
450
453
|
applyRestore: (e) => {}
|
|
451
454
|
}
|
|
@@ -453,7 +456,7 @@ function Oe(e, t) {
|
|
|
453
456
|
}
|
|
454
457
|
//#endregion
|
|
455
458
|
//#region src/y/extensions/YCursorPlugin.ts
|
|
456
|
-
function
|
|
459
|
+
function Ae(e) {
|
|
457
460
|
let t = e.charAt(0) === "#" ? e.substring(1, 7) : e, n = parseInt(t.substring(0, 2), 16), r = parseInt(t.substring(2, 4), 16), i = parseInt(t.substring(4, 6), 16), a = [
|
|
458
461
|
n / 255,
|
|
459
462
|
r / 255,
|
|
@@ -461,15 +464,15 @@ function ke(e) {
|
|
|
461
464
|
].map((e) => e <= .03928 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4);
|
|
462
465
|
return .2126 * a[0] + .7152 * a[1] + .0722 * a[2] <= .179;
|
|
463
466
|
}
|
|
464
|
-
function
|
|
467
|
+
function je(e) {
|
|
465
468
|
let t = document.createElement("span");
|
|
466
469
|
t.classList.add("bn-collaboration-cursor__base");
|
|
467
470
|
let n = document.createElement("span");
|
|
468
|
-
n.setAttribute("contentedEditable", "false"), n.classList.add("bn-collaboration-cursor__caret"), n.setAttribute("style", `background-color: ${e.color}; color: ${
|
|
471
|
+
n.setAttribute("contentedEditable", "false"), n.classList.add("bn-collaboration-cursor__caret"), n.setAttribute("style", `background-color: ${e.color}; color: ${Ae(e.color) ? "white" : "black"}`);
|
|
469
472
|
let r = document.createElement("span");
|
|
470
|
-
return r.classList.add("bn-collaboration-cursor__label"), r.setAttribute("style", `background-color: ${e.color}; color: ${
|
|
473
|
+
return r.classList.add("bn-collaboration-cursor__label"), r.setAttribute("style", `background-color: ${e.color}; color: ${Ae(e.color) ? "white" : "black"}`), r.insertBefore(document.createTextNode(e.name), null), n.insertBefore(r, null), t.insertBefore(document.createTextNode(""), null), t.insertBefore(n, null), t.insertBefore(document.createTextNode(""), null), t;
|
|
471
474
|
}
|
|
472
|
-
var
|
|
475
|
+
var Me = a(({ options: e }) => {
|
|
473
476
|
let t = /* @__PURE__ */ new Map(), n = e.provider && "awareness" in e.provider && typeof e.provider.awareness == "object" ? e.provider.awareness : void 0;
|
|
474
477
|
return n && ("setLocalStateField" in n && typeof n.setLocalStateField == "function" && n.setLocalStateField("user", e.user), "on" in n && typeof n.on == "function" && e.showCursorLabels !== "always" && n.on("change", ({ updated: e }) => {
|
|
475
478
|
for (let n of e) {
|
|
@@ -485,12 +488,12 @@ var je = a(({ options: e }) => {
|
|
|
485
488
|
}
|
|
486
489
|
})), {
|
|
487
490
|
key: "yCursor",
|
|
488
|
-
prosemirrorPlugins: [n ?
|
|
489
|
-
selectionBuilder:
|
|
491
|
+
prosemirrorPlugins: [n ? ve(n, {
|
|
492
|
+
selectionBuilder: ce,
|
|
490
493
|
cursorBuilder(n, r) {
|
|
491
494
|
let i = t.get(r);
|
|
492
495
|
if (!i) {
|
|
493
|
-
let a = (e.renderCursor ??
|
|
496
|
+
let a = (e.renderCursor ?? je)(n);
|
|
494
497
|
e.showCursorLabels !== "always" && (a.addEventListener("mouseenter", () => {
|
|
495
498
|
let e = t.get(r);
|
|
496
499
|
e.element.setAttribute("data-active", ""), e.hideTimeout && (clearTimeout(e.hideTimeout), t.set(r, {
|
|
@@ -522,19 +525,19 @@ var je = a(({ options: e }) => {
|
|
|
522
525
|
if (e) return e.user;
|
|
523
526
|
}
|
|
524
527
|
};
|
|
525
|
-
}),
|
|
526
|
-
function
|
|
527
|
-
let n = new
|
|
528
|
+
}), Ne = "version:", Pe = (e) => Ne + e, Fe = "This version", Ie = "#4363d8";
|
|
529
|
+
function Le(e, t) {
|
|
530
|
+
let n = new S.Attributions();
|
|
528
531
|
return e.on("beforeObserverCalls", (e) => {
|
|
529
|
-
e.insertSet.isEmpty() ||
|
|
532
|
+
e.insertSet.isEmpty() || S.insertIntoIdMap(n.inserts, S.createIdMapFromIdSet(e.insertSet, [S.createContentAttribute("insert", t)])), e.deleteSet.isEmpty() || S.insertIntoIdMap(n.deletes, S.createIdMapFromIdSet(e.deleteSet, [S.createContentAttribute("delete", t)]));
|
|
530
533
|
}), n;
|
|
531
534
|
}
|
|
532
|
-
var
|
|
533
|
-
let n = e?.color ??
|
|
535
|
+
var Re = a(({ options: e, editor: t }) => {
|
|
536
|
+
let n = e?.color ?? Ie;
|
|
534
537
|
return {
|
|
535
538
|
key: "diffVersioning",
|
|
536
|
-
blockNoteExtensions: [
|
|
537
|
-
resolveUsers: async (e) => e.filter((e) => e.startsWith(
|
|
539
|
+
blockNoteExtensions: [F({
|
|
540
|
+
resolveUsers: async (e) => e.filter((e) => e.startsWith(Ne)).map((e) => ({
|
|
538
541
|
id: e,
|
|
539
542
|
username: e.slice(8),
|
|
540
543
|
avatarUrl: "",
|
|
@@ -542,22 +545,22 @@ var Le = a(({ options: e, editor: t }) => {
|
|
|
542
545
|
})),
|
|
543
546
|
getAttributionMarkClassName: e?.getAttributionMarkClassName
|
|
544
547
|
})],
|
|
545
|
-
renderDiff: (e, n, r =
|
|
546
|
-
let i =
|
|
548
|
+
renderDiff: (e, n, r = Fe) => {
|
|
549
|
+
let i = Pe(r);
|
|
547
550
|
if (!t.pmSchema.marks["y-attributed-insert"]) throw Error("DiffVersioningExtension: the y-attributed-* marks are missing from the schema. This should not happen — the extension registers them via AttributionExtension.");
|
|
548
|
-
let a =
|
|
551
|
+
let a = W(t, n), o = W(t, e), s = new S.Doc({ gc: !1 }), c = s.get("prosemirror");
|
|
549
552
|
s.transact(() => {
|
|
550
|
-
c.applyDelta(
|
|
553
|
+
c.applyDelta(v(a));
|
|
551
554
|
});
|
|
552
|
-
let l = new
|
|
553
|
-
|
|
554
|
-
let u =
|
|
555
|
+
let l = new S.Doc({ gc: !1 });
|
|
556
|
+
S.applyUpdateV2(l, S.encodeStateAsUpdateV2(s));
|
|
557
|
+
let u = U(c, l), d = Le(l, i), f = K(a, o);
|
|
555
558
|
l.transact(() => {
|
|
556
559
|
u.applyDelta(f);
|
|
557
560
|
}, i);
|
|
558
|
-
let p =
|
|
561
|
+
let p = S.createDiffRenderer(s, l, { attrs: d });
|
|
559
562
|
t.replaceBlocks(t.document, []), t.exec((e, t) => {
|
|
560
|
-
let n =
|
|
563
|
+
let n = q({
|
|
561
564
|
tr: e.tr,
|
|
562
565
|
fragment: u,
|
|
563
566
|
renderer: p
|
|
@@ -569,7 +572,7 @@ var Le = a(({ options: e, editor: t }) => {
|
|
|
569
572
|
t.replaceBlocks(t.document, []), t.replaceBlocks(t.document, e);
|
|
570
573
|
}
|
|
571
574
|
};
|
|
572
|
-
}),
|
|
575
|
+
}), ze = a(({ editor: e, options: t }) => {
|
|
573
576
|
let n = p(t.resolveUsers), r = {
|
|
574
577
|
...t,
|
|
575
578
|
resolveUsers: n
|
|
@@ -578,26 +581,26 @@ var Le = a(({ options: e, editor: t }) => {
|
|
|
578
581
|
key: "collaboration",
|
|
579
582
|
userStore: n,
|
|
580
583
|
blockNoteExtensions: [
|
|
581
|
-
t.suggestionDoc ?
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
584
|
+
t.suggestionDoc ? De(r) : null,
|
|
585
|
+
I(),
|
|
586
|
+
H(r),
|
|
587
|
+
Me(t),
|
|
585
588
|
t.versioningEndpoints ? u({
|
|
586
|
-
...
|
|
589
|
+
...ke(e, t.fragment),
|
|
587
590
|
endpoints: t.versioningEndpoints,
|
|
588
591
|
resolveUsers: n
|
|
589
592
|
}) : null,
|
|
590
|
-
|
|
593
|
+
F({
|
|
591
594
|
resolveUsers: n,
|
|
592
595
|
getAttributionMarkClassName: t.getAttributionMarkClassName
|
|
593
596
|
})
|
|
594
597
|
].filter((e) => e !== null)
|
|
595
598
|
};
|
|
596
599
|
});
|
|
597
|
-
function
|
|
600
|
+
function Be(e) {
|
|
598
601
|
return e.initialContent && console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider"), {
|
|
599
602
|
...e,
|
|
600
|
-
extensions: [...e.extensions ?? [],
|
|
603
|
+
extensions: [...e.extensions ?? [], ze(e.collaboration)],
|
|
601
604
|
disableExtensions: ["history", ...e.disableExtensions ?? []],
|
|
602
605
|
initialContent: [{
|
|
603
606
|
type: "paragraph",
|
|
@@ -607,16 +610,16 @@ function ze(e) {
|
|
|
607
610
|
}
|
|
608
611
|
//#endregion
|
|
609
612
|
//#region src/y/comments/yjsHelpers.ts
|
|
610
|
-
function
|
|
611
|
-
let t = new
|
|
613
|
+
function J(e) {
|
|
614
|
+
let t = new S.Type();
|
|
612
615
|
if (t.setAttr("id", e.id), t.setAttr("userId", e.userId), t.setAttr("createdAt", e.createdAt.getTime()), t.setAttr("updatedAt", e.updatedAt.getTime()), e.deletedAt ? (t.setAttr("deletedAt", e.deletedAt.getTime()), t.setAttr("body", void 0)) : t.setAttr("body", e.body), e.reactions.length > 0) throw Error("Reactions should be empty in commentToYType");
|
|
613
|
-
return t.setAttr("reactionsByUser", new
|
|
616
|
+
return t.setAttr("reactionsByUser", new S.Type()), t.setAttr("metadata", e.metadata), t;
|
|
614
617
|
}
|
|
615
618
|
function Ve(e) {
|
|
616
|
-
let t = new
|
|
619
|
+
let t = new S.Type();
|
|
617
620
|
t.setAttr("id", e.id), t.setAttr("createdAt", e.createdAt.getTime()), t.setAttr("updatedAt", e.updatedAt.getTime());
|
|
618
|
-
let n = new
|
|
619
|
-
return n.push(e.comments.map((e) =>
|
|
621
|
+
let n = new S.Type();
|
|
622
|
+
return n.push(e.comments.map((e) => J(e))), t.setAttr("comments", n), t.setAttr("resolved", e.resolved), t.setAttr("resolvedUpdatedAt", e.resolvedUpdatedAt?.getTime()), t.setAttr("resolvedBy", e.resolvedBy), t.setAttr("metadata", e.metadata), t;
|
|
620
623
|
}
|
|
621
624
|
function He(e) {
|
|
622
625
|
return {
|
|
@@ -676,7 +679,7 @@ var Z = class extends m {
|
|
|
676
679
|
getThreads() {
|
|
677
680
|
let e = /* @__PURE__ */ new Map();
|
|
678
681
|
return this.threadsYType.forEachAttr((t, n) => {
|
|
679
|
-
t instanceof
|
|
682
|
+
t instanceof S.Type && e.set(String(n), X(t));
|
|
680
683
|
}), e;
|
|
681
684
|
}
|
|
682
685
|
subscribe(e) {
|
|
@@ -740,7 +743,7 @@ var Z = class extends m {
|
|
|
740
743
|
if (!this.auth.canCreateThread()) throw Error("Not authorized");
|
|
741
744
|
let t = /* @__PURE__ */ new Date(), n = {
|
|
742
745
|
type: "comment",
|
|
743
|
-
id:
|
|
746
|
+
id: g(),
|
|
744
747
|
userId: this.userId,
|
|
745
748
|
createdAt: t,
|
|
746
749
|
updatedAt: t,
|
|
@@ -749,7 +752,7 @@ var Z = class extends m {
|
|
|
749
752
|
body: e.initialComment.body
|
|
750
753
|
}, r = {
|
|
751
754
|
type: "thread",
|
|
752
|
-
id:
|
|
755
|
+
id: g(),
|
|
753
756
|
createdAt: t,
|
|
754
757
|
updatedAt: t,
|
|
755
758
|
comments: [n],
|
|
@@ -765,7 +768,7 @@ var Z = class extends m {
|
|
|
765
768
|
if (!this.auth.canAddComment(X(t))) throw Error("Not authorized");
|
|
766
769
|
let n = /* @__PURE__ */ new Date(), r = {
|
|
767
770
|
type: "comment",
|
|
768
|
-
id:
|
|
771
|
+
id: g(),
|
|
769
772
|
userId: this.userId,
|
|
770
773
|
createdAt: n,
|
|
771
774
|
updatedAt: n,
|
|
@@ -774,7 +777,7 @@ var Z = class extends m {
|
|
|
774
777
|
metadata: e.comment.metadata,
|
|
775
778
|
body: e.comment.body
|
|
776
779
|
};
|
|
777
|
-
return t.getAttr("comments").push([
|
|
780
|
+
return t.getAttr("comments").push([J(r)]), t.setAttr("updatedAt", (/* @__PURE__ */ new Date()).getTime()), r;
|
|
778
781
|
});
|
|
779
782
|
updateComment = this.transact((e) => {
|
|
780
783
|
let t = this.threadsYType.getAttr(e.threadId);
|
|
@@ -820,7 +823,7 @@ var Z = class extends m {
|
|
|
820
823
|
if (!this.auth.canAddReaction(Y(i), e.emoji)) throw Error("Not authorized");
|
|
821
824
|
let a = /* @__PURE__ */ new Date(), o = `${this.userId}-${e.emoji}`, s = i.getAttr("reactionsByUser");
|
|
822
825
|
if (!s.hasAttr(o)) {
|
|
823
|
-
let t = new
|
|
826
|
+
let t = new S.Type();
|
|
824
827
|
t.setAttr("emoji", e.emoji), t.setAttr("createdAt", a.getTime()), t.setAttr("userId", this.userId), s.setAttr(o, t);
|
|
825
828
|
}
|
|
826
829
|
});
|
|
@@ -876,9 +879,9 @@ async function $(e, t, n) {
|
|
|
876
879
|
return r.arrayBuffer();
|
|
877
880
|
}
|
|
878
881
|
function Ye(e) {
|
|
879
|
-
let { baseUrl: t, org: n, docId: r, headers: i = {}, activityLimit: a = 50, group: o } = e, s = `${t}/activity/${n}/${r}`, c = `${t}/changeset/${n}/${r}`, l = `${t}/rollback/${n}/${r}`;
|
|
880
|
-
return (
|
|
881
|
-
let
|
|
882
|
+
let { baseUrl: t, org: n, docId: r, headers: i = {}, activityLimit: a = 50, group: o } = e, s = `${t}/activity/v1/${n}/${r}`, c = `${t}/changeset/v1/${n}/${r}`, l = `${t}/rollback/v1/${n}/${r}`, u = `${t}/ydoc/v1/${n}/${r}`;
|
|
883
|
+
return (t) => {
|
|
884
|
+
let n = () => (t.getExtension("ySync")?.fragment.doc)?.get(Ke), r = async () => {
|
|
882
885
|
let e = new URLSearchParams({
|
|
883
886
|
order: "desc",
|
|
884
887
|
limit: "1",
|
|
@@ -888,7 +891,7 @@ function Ye(e) {
|
|
|
888
891
|
limit: "1",
|
|
889
892
|
customAttributions: "true",
|
|
890
893
|
withCustomAttributions: "type:version"
|
|
891
|
-
}), [n, r] = await Promise.all([$(`${s}?${e}`, i), $(`${s}?${t}`, i)]), a =
|
|
894
|
+
}), [n, r] = await Promise.all([$(`${s}?${e}`, i), $(`${s}?${t}`, i)]), a = C(new Uint8Array(n)).activity[0], o = C(new Uint8Array(r)).activity[0];
|
|
892
895
|
if (!a || a.to <= (o?.to ?? 0)) return;
|
|
893
896
|
let c = a.by?.split(",").map((e) => e.trim()).filter(Boolean) ?? [];
|
|
894
897
|
return {
|
|
@@ -897,93 +900,93 @@ function Ye(e) {
|
|
|
897
900
|
updatedAt: a.to,
|
|
898
901
|
by: c.length > 0 ? c : void 0
|
|
899
902
|
};
|
|
900
|
-
},
|
|
903
|
+
}, p = async (e, t, n) => {
|
|
901
904
|
if (!e.doc) throw Error("Cannot patch document: the Y.Type is not attached to a Y.Doc.");
|
|
902
|
-
let
|
|
903
|
-
|
|
904
|
-
let
|
|
905
|
-
update:
|
|
906
|
-
customAttributions:
|
|
905
|
+
let r = new S.Doc();
|
|
906
|
+
r.get("__bn_version_markers", "XmlFragment").insert(0, ["v"]);
|
|
907
|
+
let a = {
|
|
908
|
+
update: S.encodeStateAsUpdate(r),
|
|
909
|
+
customAttributions: t
|
|
907
910
|
};
|
|
908
|
-
|
|
911
|
+
n && (a.by = n), await $(u, i, {
|
|
909
912
|
method: "PATCH",
|
|
910
|
-
body:
|
|
913
|
+
body: w(a)
|
|
911
914
|
});
|
|
912
|
-
},
|
|
913
|
-
let
|
|
914
|
-
|
|
915
|
-
let
|
|
915
|
+
}, m = async (e, r) => {
|
|
916
|
+
let i = String(re()), a = Date.now();
|
|
917
|
+
r?.name && n()?.setAttr(i, r.name);
|
|
918
|
+
let o = [{
|
|
916
919
|
k: "type",
|
|
917
920
|
v: "version"
|
|
918
921
|
}, {
|
|
919
922
|
k: "id",
|
|
920
|
-
v:
|
|
923
|
+
v: i
|
|
921
924
|
}];
|
|
922
|
-
|
|
925
|
+
r?.name && o.push({
|
|
923
926
|
k: "name",
|
|
924
|
-
v:
|
|
927
|
+
v: r.name
|
|
925
928
|
});
|
|
926
|
-
let
|
|
927
|
-
return await
|
|
928
|
-
id:
|
|
929
|
-
name:
|
|
930
|
-
createdAt:
|
|
931
|
-
updatedAt:
|
|
932
|
-
by:
|
|
929
|
+
let s = t.getExtension("yCursor")?.getUser();
|
|
930
|
+
return await p(e, o, s?.id), {
|
|
931
|
+
id: i,
|
|
932
|
+
name: r?.name,
|
|
933
|
+
createdAt: a,
|
|
934
|
+
updatedAt: a,
|
|
935
|
+
by: s?.id
|
|
933
936
|
};
|
|
934
|
-
},
|
|
935
|
-
let t =
|
|
937
|
+
}, h = async (e) => {
|
|
938
|
+
let t = new URLSearchParams({
|
|
936
939
|
ydoc: "true",
|
|
937
940
|
to: String(e)
|
|
938
|
-
})}`, i),
|
|
939
|
-
if (!
|
|
940
|
-
return
|
|
941
|
+
}), n = await $(`${c}?${t}`, i), r = C(new Uint8Array(n));
|
|
942
|
+
if (!r.ydoc) throw Error(`YHub returned no document state at timestamp ${e}.`);
|
|
943
|
+
return S.convertUpdateFormatV1ToV2(r.ydoc);
|
|
941
944
|
};
|
|
942
945
|
return {
|
|
943
946
|
list: async () => {
|
|
944
|
-
let t = e.groupMaxGap ?? 1e4,
|
|
947
|
+
let t = e.groupMaxGap ?? 1e4, c = e.groupMaxDuration, l = e.mergeUsers, u = new URLSearchParams({
|
|
945
948
|
order: "desc",
|
|
946
949
|
limit: String(a),
|
|
947
950
|
customAttributions: "true"
|
|
948
951
|
});
|
|
949
|
-
|
|
950
|
-
let
|
|
951
|
-
let t = e.name,
|
|
952
|
+
u.set("groupMaxGap", String(t)), o !== void 0 && u.set("group", String(o)), c !== void 0 && u.set("groupMaxDuration", String(c)), l !== void 0 && u.set("mergeUsers", String(l));
|
|
953
|
+
let d = await $(`${s}?${u}`, i), { activity: p } = C(new Uint8Array(d)), m = f(p.map((e, t) => Je(e, t)).filter((e) => e !== void 0).map((e) => {
|
|
954
|
+
let t = e.name, r = (typeof e.id == "string" ? n()?.getAttr(e.id) : void 0) ?? t;
|
|
952
955
|
return {
|
|
953
956
|
...e,
|
|
954
|
-
name:
|
|
957
|
+
name: r
|
|
955
958
|
};
|
|
956
|
-
})),
|
|
957
|
-
return
|
|
959
|
+
})), h = await r();
|
|
960
|
+
return h ? [h, ...m] : m;
|
|
958
961
|
},
|
|
959
|
-
create:
|
|
960
|
-
getContent: async (e) =>
|
|
962
|
+
create: m,
|
|
963
|
+
getContent: async (e) => h(e.createdAt),
|
|
961
964
|
getAttributions: async (e, t) => {
|
|
962
|
-
let n = e.createdAt, r = t === void 0 ? 0 : t.createdAt, a =
|
|
965
|
+
let n = e.createdAt, r = t === void 0 ? 0 : t.createdAt, a = new URLSearchParams({
|
|
963
966
|
from: String(r),
|
|
964
967
|
to: String(n),
|
|
965
968
|
attributions: "true"
|
|
966
|
-
})}`, i),
|
|
967
|
-
if (!
|
|
968
|
-
return
|
|
969
|
+
}), o = await $(`${c}?${a}`, i), s = C(new Uint8Array(o));
|
|
970
|
+
if (!s.attributions) throw Error(`YHub returned no attributions for snapshot ${String(e.id)}.`);
|
|
971
|
+
return S.decodeContentMap(s.attributions);
|
|
969
972
|
},
|
|
970
973
|
restore: async (e, t) => {
|
|
971
|
-
let n = t.createdAt, r = await
|
|
972
|
-
return await $(
|
|
974
|
+
let n = t.createdAt, r = await h(n);
|
|
975
|
+
return await $(l, i, {
|
|
973
976
|
method: "POST",
|
|
974
|
-
body:
|
|
977
|
+
body: w({ from: n })
|
|
975
978
|
}), r;
|
|
976
979
|
},
|
|
977
980
|
rename: async (e, t) => {
|
|
978
981
|
if (typeof e.id != "string") return;
|
|
979
|
-
let
|
|
980
|
-
if (!
|
|
981
|
-
t === void 0 || t === "" ?
|
|
982
|
+
let r = n();
|
|
983
|
+
if (!r) throw Error("Cannot rename version: no live collaboration document is available.");
|
|
984
|
+
t === void 0 || t === "" ? r.deleteAttr(e.id) : r.setAttr(e.id, t);
|
|
982
985
|
}
|
|
983
986
|
};
|
|
984
987
|
};
|
|
985
988
|
}
|
|
986
989
|
//#endregion
|
|
987
|
-
export {
|
|
990
|
+
export { F as AttributionExtension, ze as CollaborationExtension, Re as DiffVersioningExtension, We as RESTYjsThreadStore, I as RelativePositionMappingExtension, De as SuggestionsExtension, O as YAttributedDeletion, k as YAttributedFormat, D as YAttributedInsertion, A as YAttributionMarksExtension, Me as YCursorExtension, H as YSyncExtension, Ge as YjsThreadStore, Z as YjsThreadStoreBase, W as _blocksToProsemirrorNode, Ce as _prosemirrorJSONToBlocks, Ee as blocksToYDoc, we as blocksToYType, Ye as createYHubVersioningEndpoints, ke as createYjsVersioningAdapter, K as docDiffToDelta, U as findTypeInOtherYdoc, q as getProseMirrorTrFromYFragment, Se as getReferenceClientRects, xe as getReferenceRect, V as mapAttributionToMark, T as resolveAttributionMarkClassName, Be as withCollaboration, Te as yDocToBlocks, G as yfragmentToBlocks };
|
|
988
991
|
|
|
989
992
|
//# sourceMappingURL=y.js.map
|