@blocknote/core 0.52.1 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BlockNoteExtension-BJCLnwrE.cjs +2 -0
- package/dist/BlockNoteExtension-BJCLnwrE.cjs.map +1 -0
- package/dist/BlockNoteExtension-CbvDA0F7.js +80 -0
- package/dist/BlockNoteExtension-CbvDA0F7.js.map +1 -0
- package/dist/{UserStore-QbbPFj0z.js → UserStore-C4TzkGEn.js} +3 -3
- package/dist/{UserStore-DCG6lsla.cjs.map → UserStore-C4TzkGEn.js.map} +1 -1
- package/dist/{UserStore-DCG6lsla.cjs → UserStore-mj3fXW4D.cjs} +2 -2
- package/dist/UserStore-mj3fXW4D.cjs.map +1 -0
- package/dist/blocknote.cjs +1 -1
- package/dist/blocknote.js +6 -6
- package/dist/{blocks-CiuUGa1E.js → blocks-CzQLehlc.js} +695 -652
- package/dist/blocks-CzQLehlc.js.map +1 -0
- package/dist/blocks-CzkqclGj.cjs +12 -0
- package/dist/blocks-CzkqclGj.cjs.map +1 -0
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +2 -2
- package/dist/comments.cjs +1 -1
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js +7 -7
- package/dist/comments.js.map +1 -1
- package/dist/en-BuzSuuTq.cjs +2 -0
- package/dist/en-BuzSuuTq.cjs.map +1 -0
- package/dist/{en-CGKXfWma.js → en-uzHzj6eH.js} +10 -1
- package/dist/en-uzHzj6eH.js.map +1 -0
- package/dist/extensions-CSB9ZvuL.cjs +58 -0
- package/dist/extensions-CSB9ZvuL.cjs.map +1 -0
- package/dist/{extensions-CrUGDOks.js → extensions-DGuhtOgB.js} +717 -452
- package/dist/extensions-DGuhtOgB.js.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +4 -4
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +199 -1
- package/dist/locales.js.map +1 -1
- package/dist/{src-DTF83Cl9.js → src-BkfZVfaO.js} +921 -835
- package/dist/src-BkfZVfaO.js.map +1 -0
- package/dist/src-DM3syMdf.cjs +23 -0
- package/dist/src-DM3syMdf.cjs.map +1 -0
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/dist/y.cjs +1 -1
- package/dist/y.cjs.map +1 -1
- package/dist/y.js +65 -62
- package/dist/y.js.map +1 -1
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.cjs.map +1 -1
- package/dist/yjs.js +88 -76
- package/dist/yjs.js.map +1 -1
- package/package.json +29 -30
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +2505 -763
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +42 -0
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +16 -4
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +10 -1
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +42 -8
- package/src/api/exporters/markdown/htmlToMarkdown.ts +45 -10
- package/src/api/exporters/markdown/markdownExporter.ts +10 -1
- package/src/api/nodeConversions/blockToNode.ts +5 -1
- package/src/api/nodeConversions/nodeToBlock.ts +3 -0
- package/src/api/parsers/html/parseHTML.ts +43 -0
- package/src/api/pmUtil.ts +16 -8
- package/src/blocks/Code/CodeBlockOptions.ts +83 -0
- package/src/blocks/Code/block.test.ts +1 -1
- package/src/blocks/Code/block.ts +29 -281
- package/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.ts +120 -0
- package/src/blocks/Code/helpers/parse/parsePreCode.ts +45 -0
- package/src/blocks/Code/helpers/render/createCodeBlock.ts +98 -0
- package/src/blocks/Code/helpers/toExternalHTML/createPreCode.ts +14 -0
- package/src/blocks/Table/TableExtension.test.ts +102 -0
- package/src/blocks/ToggleWrapper/createToggleWrapper.ts +16 -5
- package/src/blocks/defaultBlockTypeGuards.ts +6 -0
- package/src/blocks/index.ts +3 -0
- package/src/comments/extension.ts +2 -4
- package/src/editor/Block.css +324 -3
- package/src/editor/BlockNoteEditor.ts +25 -4
- package/src/editor/BlockNoteExtension.ts +1 -1
- package/src/editor/managers/ExtensionManager/extensions.ts +6 -0
- package/src/exporter/ExportImage.ts +50 -0
- package/src/exporter/Exporter.test.ts +48 -0
- package/src/exporter/Exporter.ts +46 -12
- package/src/exporter/index.ts +1 -0
- package/src/exporter/mapping.ts +4 -1
- package/src/extensions/FormattingToolbar/FormattingToolbar.ts +10 -8
- package/src/extensions/InlineContentBoundaryEdit/InlineContentBoundaryEdit.ts +109 -0
- package/src/extensions/SideMenu/SideMenu.ts +20 -3
- package/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.ts +192 -0
- package/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.ts +142 -0
- package/src/extensions/SuggestionMenu/SuggestionMenu.test.ts +118 -0
- package/src/extensions/SuggestionMenu/SuggestionMenu.ts +40 -27
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +13 -3
- package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.ts +120 -0
- package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.ts +89 -0
- package/src/extensions/SyntaxHighlighting/inlineHighlight.test.ts +135 -0
- package/src/extensions/SyntaxHighlighting/shiki.ts +116 -0
- package/src/extensions/TableHandles/TableHandles.ts +25 -12
- package/src/extensions/TrailingNode/TrailingNode.ts +98 -32
- package/src/extensions/Versioning/inMemoryVersioning.ts +13 -3
- package/src/extensions/index.ts +4 -0
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts +51 -2
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +22 -2
- package/src/i18n/locales/ar.ts +9 -0
- package/src/i18n/locales/de.ts +9 -0
- package/src/i18n/locales/en.ts +9 -0
- package/src/i18n/locales/es.ts +9 -0
- package/src/i18n/locales/fa.ts +9 -0
- package/src/i18n/locales/fr.ts +9 -0
- package/src/i18n/locales/he.ts +9 -0
- package/src/i18n/locales/hr.ts +9 -0
- package/src/i18n/locales/is.ts +9 -0
- package/src/i18n/locales/it.ts +9 -0
- package/src/i18n/locales/ja.ts +9 -0
- package/src/i18n/locales/ko.ts +9 -0
- package/src/i18n/locales/nl.ts +9 -0
- package/src/i18n/locales/no.ts +9 -0
- package/src/i18n/locales/pl.ts +9 -0
- package/src/i18n/locales/pt.ts +9 -0
- package/src/i18n/locales/ru.ts +9 -0
- package/src/i18n/locales/sk.ts +9 -0
- package/src/i18n/locales/uk.ts +9 -0
- package/src/i18n/locales/uz.ts +9 -0
- package/src/i18n/locales/vi.ts +9 -0
- package/src/i18n/locales/zh-tw.ts +9 -0
- package/src/i18n/locales/zh.ts +9 -0
- package/src/index.ts +6 -1
- package/src/schema/blocks/createSpec.ts +17 -5
- package/src/schema/blocks/internal.test.ts +86 -0
- package/src/schema/blocks/internal.ts +64 -0
- package/src/schema/blocks/types.ts +53 -3
- package/src/schema/contentTypePropagation.test.ts +1 -1
- package/src/schema/inlineContent/createSpec.test.ts +161 -0
- package/src/schema/inlineContent/createSpec.ts +180 -13
- package/src/schema/inlineContent/internal.ts +21 -2
- package/src/schema/inlineContent/types.ts +35 -5
- package/src/schema/nodeViewMutations.test.ts +121 -0
- package/src/schema/nodeViewMutations.ts +46 -0
- package/src/user/UserStore.ts +1 -1
- package/src/util/Store.test.ts +132 -0
- package/src/util/Store.ts +135 -0
- package/src/y/extensions/AttributionExtension.test.ts +10 -0
- package/src/y/extensions/Versioning.test.ts +20 -7
- package/src/yjs/comments/RESTYjsThreadStore.test.ts +85 -0
- package/src/yjs/comments/RESTYjsThreadStore.ts +7 -1
- package/src/yjs/extensions/ForkYDoc.test.ts +37 -0
- package/src/yjs/extensions/ForkYDoc.ts +26 -1
- package/src/yjs/extensions/RelativePositionMapping.ts +8 -2
- package/src/yjs/extensions/Versioning.test.ts +17 -5
- package/types/src/api/exporters/html/util/serializeBlocksExternalHTML.d.ts +13 -0
- package/types/src/api/pmUtil.d.ts +7 -7
- package/types/src/blocks/Code/CodeBlockOptions.d.ts +61 -0
- package/types/src/blocks/Code/block.d.ts +3 -53
- package/types/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.d.ts +35 -0
- package/types/src/blocks/Code/helpers/parse/parsePreCode.d.ts +8 -0
- package/types/src/blocks/Code/helpers/render/createCodeBlock.d.ts +18 -0
- package/types/src/blocks/Code/helpers/toExternalHTML/createPreCode.d.ts +5 -0
- package/types/src/blocks/defaultBlockTypeGuards.d.ts +2 -0
- package/types/src/blocks/index.d.ts +3 -0
- package/types/src/comments/extension.d.ts +1 -15
- package/types/src/editor/BlockNoteEditor.d.ts +3 -3
- package/types/src/editor/BlockNoteExtension.d.ts +1 -1
- package/types/src/exporter/ExportImage.d.ts +36 -0
- package/types/src/exporter/Exporter.d.ts +21 -0
- package/types/src/exporter/Exporter.test.d.ts +1 -0
- package/types/src/exporter/index.d.ts +1 -0
- package/types/src/exporter/mapping.d.ts +1 -1
- package/types/src/extensions/FilePanel/FilePanel.d.ts +1 -1
- package/types/src/extensions/FormattingToolbar/FormattingToolbar.d.ts +1 -1
- package/types/src/extensions/InlineContentBoundaryEdit/InlineContentBoundaryEdit.d.ts +5 -0
- package/types/src/extensions/ShowSelection/ShowSelection.d.ts +1 -5
- package/types/src/extensions/SideMenu/SideMenu.d.ts +6 -1
- package/types/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.d.ts +45 -0
- package/types/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.d.ts +49 -0
- package/types/src/extensions/SuggestionMenu/SuggestionMenu.d.ts +7 -11
- package/types/src/extensions/SyntaxHighlighting/SyntaxHighlighting.d.ts +44 -0
- package/types/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.d.ts +1 -0
- package/types/src/extensions/SyntaxHighlighting/inlineHighlight.test.d.ts +1 -0
- package/types/src/extensions/SyntaxHighlighting/shiki.d.ts +13 -0
- package/types/src/extensions/TableHandles/TableHandles.d.ts +1 -1
- package/types/src/extensions/TrailingNode/TrailingNode.d.ts +5 -4
- package/types/src/extensions/Versioning/Versioning.d.ts +1 -35
- package/types/src/extensions/index.d.ts +4 -0
- package/types/src/i18n/locales/en.d.ts +9 -0
- package/types/src/i18n/locales/fa.d.ts +9 -0
- package/types/src/i18n/locales/sk.d.ts +9 -0
- package/types/src/index.d.ts +3 -1
- package/types/src/schema/blocks/internal.d.ts +21 -0
- package/types/src/schema/blocks/internal.test.d.ts +1 -0
- package/types/src/schema/blocks/types.d.ts +36 -3
- package/types/src/schema/inlineContent/createSpec.d.ts +35 -3
- package/types/src/schema/inlineContent/createSpec.test.d.ts +1 -0
- package/types/src/schema/inlineContent/internal.d.ts +3 -2
- package/types/src/schema/inlineContent/types.d.ts +22 -3
- package/types/src/schema/nodeViewMutations.d.ts +3 -0
- package/types/src/schema/nodeViewMutations.test.d.ts +1 -0
- package/types/src/user/UserStore.d.ts +1 -1
- package/types/src/util/Store.d.ts +45 -0
- package/types/src/util/Store.test.d.ts +1 -0
- package/types/src/y/extensions/AttributionExtension.d.ts +1 -1
- package/types/src/y/extensions/DiffVersioningExtension.d.ts +1 -1
- package/types/src/y/extensions/ForkYDoc.d.ts +1 -5
- package/types/src/y/extensions/index.d.ts +2 -10
- package/types/src/yjs/comments/RESTYjsThreadStore.test.d.ts +1 -0
- package/types/src/yjs/extensions/ForkYDoc.d.ts +1 -5
- package/types/src/yjs/extensions/index.d.ts +1 -5
- package/dist/BlockNoteExtension-B_IEJHS8.js +0 -38
- package/dist/BlockNoteExtension-B_IEJHS8.js.map +0 -1
- package/dist/BlockNoteExtension-M0znTzxP.cjs +0 -2
- package/dist/BlockNoteExtension-M0znTzxP.cjs.map +0 -1
- package/dist/UserStore-QbbPFj0z.js.map +0 -1
- package/dist/blocks-BqHv0xhc.cjs +0 -12
- package/dist/blocks-BqHv0xhc.cjs.map +0 -1
- package/dist/blocks-CiuUGa1E.js.map +0 -1
- package/dist/en-C5Z4Ag9_.cjs +0 -2
- package/dist/en-C5Z4Ag9_.cjs.map +0 -1
- package/dist/en-CGKXfWma.js.map +0 -1
- package/dist/extensions-CrUGDOks.js.map +0 -1
- package/dist/extensions-Ghr9QqqR.cjs +0 -52
- package/dist/extensions-Ghr9QqqR.cjs.map +0 -1
- package/dist/src-DTF83Cl9.js.map +0 -1
- package/dist/src-OfbaVbMw.cjs +0 -21
- package/dist/src-OfbaVbMw.cjs.map +0 -1
- package/src/blocks/Code/shiki.ts +0 -73
- package/types/src/blocks/Code/shiki.d.ts +0 -4
package/dist/yjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as i, t as a } from "./BlockNoteExtension-
|
|
1
|
+
import { Ct as e, It as t, Pn as n, wn as r } from "./blocks-CzQLehlc.js";
|
|
2
|
+
import { n as i, t as a } from "./BlockNoteExtension-CbvDA0F7.js";
|
|
3
3
|
import { t as o } from "./ThreadStore-et9wB5Xt.js";
|
|
4
4
|
import { Node as s } from "prosemirror-model";
|
|
5
5
|
import { uuidv4 as c } from "lib0/random";
|
|
@@ -14,7 +14,8 @@ function w(e, t) {
|
|
|
14
14
|
let r = Array.from(n.share.keys()).find((t) => n.share.get(t) === e);
|
|
15
15
|
if (r == null) throw Error("type does not exist in other ydoc");
|
|
16
16
|
return t.get(r, e.constructor);
|
|
17
|
-
}
|
|
17
|
+
}
|
|
18
|
+
{
|
|
18
19
|
let n = e._item, r = t.store.clients.get(n.id.client) ?? [], i = r[C.findIndexSS(r, n.id.clock)];
|
|
19
20
|
if (!i) throw Error("type does not exist in other ydoc");
|
|
20
21
|
let a = i.content;
|
|
@@ -23,14 +24,16 @@ function w(e, t) {
|
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
function T(e, t) {
|
|
26
|
-
|
|
27
|
+
let n = e.pmSchema.nodeFromJSON(t);
|
|
28
|
+
return r(n);
|
|
27
29
|
}
|
|
28
30
|
function E(e, n) {
|
|
29
31
|
let r = n.map((n) => t(n, e.pmSchema));
|
|
30
32
|
return e.pmSchema.topNodeType.create(null, e.pmSchema.nodes.blockGroup.create(null, r));
|
|
31
33
|
}
|
|
32
34
|
function D(e, t) {
|
|
33
|
-
|
|
35
|
+
let n = S(t, e.pmSchema);
|
|
36
|
+
return r(n);
|
|
34
37
|
}
|
|
35
38
|
function O(e, t, n) {
|
|
36
39
|
return m(E(e, t), n);
|
|
@@ -43,17 +46,17 @@ function A(e, t, n = "prosemirror") {
|
|
|
43
46
|
}
|
|
44
47
|
//#endregion
|
|
45
48
|
//#region src/yjs/extensions/FixUpSchema.ts
|
|
46
|
-
var j = a(({ editor:
|
|
47
|
-
let
|
|
48
|
-
|
|
49
|
+
var j = a(({ editor: e }) => (e.on("create", () => {
|
|
50
|
+
let t = e.pmSchema, r, i = t.nodes.doc.createAndFill;
|
|
51
|
+
t.nodes.doc.createAndFill = ((...e) => {
|
|
49
52
|
if (r) return r;
|
|
50
|
-
let
|
|
51
|
-
return a.content[0].content[0].attrs.id = "initialBlockId", r = s.fromJSON(
|
|
53
|
+
let n = i.apply(t.nodes.doc, e), a = JSON.parse(JSON.stringify(n.toJSON()));
|
|
54
|
+
return a.content[0].content[0].attrs.id = "initialBlockId", r = s.fromJSON(t, a), r;
|
|
52
55
|
});
|
|
53
|
-
let a =
|
|
54
|
-
|
|
55
|
-
let o = typeof
|
|
56
|
-
return o &&
|
|
56
|
+
let a = t.node;
|
|
57
|
+
t.node = function(e, t, r, i) {
|
|
58
|
+
let o = typeof e == "string" ? this.nodes[e] : e;
|
|
59
|
+
return o && n(this, o) && Array.isArray(r) && (r = r.map((e) => e?.isText && e.marks.length ? e.mark(o.allowedMarks(e.marks)) : e)), a.call(this, e, t, r, i);
|
|
57
60
|
};
|
|
58
61
|
}), { key: "fixUpSchema" }));
|
|
59
62
|
//#endregion
|
|
@@ -144,7 +147,16 @@ var P = a(({ options: e }) => {
|
|
|
144
147
|
dependsOn: ["yCursor", "ySync"],
|
|
145
148
|
undoCommand: _,
|
|
146
149
|
redoCommand: h
|
|
147
|
-
}))
|
|
150
|
+
}));
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/yjs/extensions/ForkYDoc.ts
|
|
153
|
+
function L(e, t) {
|
|
154
|
+
e.transact((e) => e.setMeta(b, {
|
|
155
|
+
type: t,
|
|
156
|
+
doc: t.doc
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
159
|
+
var R = a(({ editor: e, options: t }) => {
|
|
148
160
|
let n, r = i({ isForked: !1 });
|
|
149
161
|
return {
|
|
150
162
|
key: "yForkDoc",
|
|
@@ -169,7 +181,7 @@ var P = a(({ options: e }) => {
|
|
|
169
181
|
"ySync",
|
|
170
182
|
"yCursor",
|
|
171
183
|
"yUndo"
|
|
172
|
-
], [F(c), I()]), r.setState({ isForked: !0 });
|
|
184
|
+
], [F(c), I()]), L(e, s), r.setState({ isForked: !0 });
|
|
173
185
|
},
|
|
174
186
|
merge({ keepChanges: i }) {
|
|
175
187
|
if (!n) return;
|
|
@@ -182,14 +194,14 @@ var P = a(({ options: e }) => {
|
|
|
182
194
|
F(t),
|
|
183
195
|
P(t),
|
|
184
196
|
I()
|
|
185
|
-
]), x.getState(e.prosemirrorState).undoManager.undoStack = s, i) {
|
|
197
|
+
]), L(e, a), x.getState(e.prosemirrorState).undoManager.undoStack = s, i) {
|
|
186
198
|
let t = C.encodeStateAsUpdate(o.doc, C.encodeStateVector(a.doc));
|
|
187
199
|
C.applyUpdate(a.doc, t, e);
|
|
188
200
|
}
|
|
189
201
|
n = void 0, r.setState({ isForked: !1 });
|
|
190
202
|
}
|
|
191
203
|
};
|
|
192
|
-
}),
|
|
204
|
+
}), z = a(({ editor: e }) => ({
|
|
193
205
|
key: "yPositionMapping",
|
|
194
206
|
mapPosition: (t, n = "left") => {
|
|
195
207
|
let r = b.getState(e.prosemirrorState);
|
|
@@ -202,47 +214,47 @@ var P = a(({ options: e }) => {
|
|
|
202
214
|
}
|
|
203
215
|
let i = d(t + (n === "right" ? 1 : -1), r.binding.type, r.binding.mapping);
|
|
204
216
|
return () => {
|
|
205
|
-
let t = b.getState(e.prosemirrorState), r = g(
|
|
206
|
-
if (
|
|
207
|
-
return
|
|
217
|
+
let t = b.getState(e.prosemirrorState), r = t.binding.type, a = g(r.doc, r, i, t.binding.mapping);
|
|
218
|
+
if (a === null) throw Error("Position not found, cannot track positions");
|
|
219
|
+
return a + (n === "right" ? -1 : 1);
|
|
208
220
|
};
|
|
209
221
|
}
|
|
210
|
-
})),
|
|
222
|
+
})), B = (e, t) => {
|
|
211
223
|
t(e), e.forEach((e) => {
|
|
212
|
-
e instanceof C.XmlElement &&
|
|
224
|
+
e instanceof C.XmlElement && B(e, t);
|
|
213
225
|
});
|
|
214
|
-
},
|
|
215
|
-
let
|
|
216
|
-
return
|
|
217
|
-
|
|
218
|
-
if (
|
|
219
|
-
let
|
|
220
|
-
textColor:
|
|
221
|
-
backgroundColor: i ===
|
|
226
|
+
}, V = [(t, n) => {
|
|
227
|
+
let r = /* @__PURE__ */ new Map();
|
|
228
|
+
return t.forEach((t) => {
|
|
229
|
+
t instanceof C.XmlElement && B(t, (t) => {
|
|
230
|
+
if (t.nodeName === "blockContainer" && t.hasAttribute("id")) {
|
|
231
|
+
let n = t.getAttribute("textColor"), i = t.getAttribute("backgroundColor"), a = {
|
|
232
|
+
textColor: n === e.textColor.default ? void 0 : n,
|
|
233
|
+
backgroundColor: i === e.backgroundColor.default ? void 0 : i
|
|
222
234
|
};
|
|
223
|
-
(a.textColor || a.backgroundColor) &&
|
|
235
|
+
(a.textColor || a.backgroundColor) && r.set(t.getAttribute("id"), a);
|
|
224
236
|
}
|
|
225
237
|
});
|
|
226
|
-
}),
|
|
227
|
-
if (e.type.name === "blockContainer" &&
|
|
228
|
-
let i =
|
|
238
|
+
}), r.size !== 0 && (n.doc.descendants((e, t) => {
|
|
239
|
+
if (e.type.name === "blockContainer" && r.has(e.attrs.id)) {
|
|
240
|
+
let i = n.doc.nodeAt(t + 1);
|
|
229
241
|
if (!i) throw Error("No element found");
|
|
230
|
-
|
|
242
|
+
n.setNodeMarkup(t + 1, void 0, {
|
|
231
243
|
...i.attrs,
|
|
232
|
-
...
|
|
244
|
+
...r.get(e.attrs.id)
|
|
233
245
|
});
|
|
234
246
|
}
|
|
235
247
|
}), !0);
|
|
236
|
-
}],
|
|
237
|
-
let t = !1;
|
|
248
|
+
}], H = a(({ options: e }) => {
|
|
249
|
+
let t = !1, n = new u("schemaMigration");
|
|
238
250
|
return {
|
|
239
251
|
key: "schemaMigration",
|
|
240
252
|
prosemirrorPlugins: [new l({
|
|
241
|
-
key:
|
|
253
|
+
key: n,
|
|
242
254
|
appendTransaction: (n, r, i) => {
|
|
243
255
|
if (t || !n.some((e) => e.getMeta("y-sync$")) || n.every((e) => !e.docChanged) || !e.fragment.firstChild) return;
|
|
244
256
|
let a = i.tr;
|
|
245
|
-
for (let t of
|
|
257
|
+
for (let t of V) t(e.fragment, a);
|
|
246
258
|
if (t = !0, a.docChanged) return a;
|
|
247
259
|
}
|
|
248
260
|
})]
|
|
@@ -250,10 +262,10 @@ var P = a(({ options: e }) => {
|
|
|
250
262
|
});
|
|
251
263
|
//#endregion
|
|
252
264
|
//#region src/yjs/extensions/Versioning.ts
|
|
253
|
-
function
|
|
265
|
+
function U(e, t) {
|
|
254
266
|
let { fragment: n } = t;
|
|
255
267
|
function r() {
|
|
256
|
-
let t = e.getExtension(
|
|
268
|
+
let t = e.getExtension(R);
|
|
257
269
|
if (!t) throw Error("ForkYDocExtension is required for the Yjs versioning adapter. Make sure it is registered before the VersioningExtension.");
|
|
258
270
|
return t;
|
|
259
271
|
}
|
|
@@ -278,22 +290,22 @@ function H(e, t) {
|
|
|
278
290
|
}
|
|
279
291
|
//#endregion
|
|
280
292
|
//#region src/yjs/extensions/index.ts
|
|
281
|
-
var
|
|
293
|
+
var W = a(({ options: e }) => ({
|
|
282
294
|
key: "collaboration",
|
|
283
295
|
blockNoteExtensions: [
|
|
284
296
|
j(),
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
297
|
+
R(e),
|
|
298
|
+
z(),
|
|
299
|
+
H(e),
|
|
288
300
|
P(e),
|
|
289
301
|
F(e),
|
|
290
302
|
I()
|
|
291
303
|
]
|
|
292
304
|
}));
|
|
293
|
-
function
|
|
305
|
+
function G(e) {
|
|
294
306
|
return {
|
|
295
307
|
...e,
|
|
296
|
-
extensions: [...e.extensions ?? [],
|
|
308
|
+
extensions: [...e.extensions ?? [], W(e.collaboration)],
|
|
297
309
|
disableExtensions: ["history", ...e.disableExtensions ?? []],
|
|
298
310
|
initialContent: [{
|
|
299
311
|
type: "paragraph",
|
|
@@ -303,26 +315,26 @@ function W(e) {
|
|
|
303
315
|
}
|
|
304
316
|
//#endregion
|
|
305
317
|
//#region src/yjs/comments/yjsHelpers.ts
|
|
306
|
-
function
|
|
318
|
+
function K(e) {
|
|
307
319
|
let t = new C.Map();
|
|
308
320
|
if (t.set("id", e.id), t.set("userId", e.userId), t.set("createdAt", e.createdAt.getTime()), t.set("updatedAt", e.updatedAt.getTime()), e.deletedAt ? (t.set("deletedAt", e.deletedAt.getTime()), t.set("body", void 0)) : t.set("body", e.body), e.reactions.length > 0) throw Error("Reactions should be empty in commentToYMap");
|
|
309
321
|
return t.set("reactionsByUser", new C.Map()), t.set("metadata", e.metadata), t;
|
|
310
322
|
}
|
|
311
|
-
function
|
|
323
|
+
function q(e) {
|
|
312
324
|
let t = new C.Map();
|
|
313
325
|
t.set("id", e.id), t.set("createdAt", e.createdAt.getTime()), t.set("updatedAt", e.updatedAt.getTime());
|
|
314
326
|
let n = new C.Array();
|
|
315
|
-
return n.push(e.comments.map((e) =>
|
|
327
|
+
return n.push(e.comments.map((e) => K(e))), t.set("comments", n), t.set("resolved", e.resolved), t.set("resolvedUpdatedAt", e.resolvedUpdatedAt?.getTime()), t.set("resolvedBy", e.resolvedBy), t.set("metadata", e.metadata), t;
|
|
316
328
|
}
|
|
317
|
-
function
|
|
329
|
+
function J(e) {
|
|
318
330
|
return {
|
|
319
331
|
emoji: e.get("emoji"),
|
|
320
332
|
createdAt: new Date(e.get("createdAt")),
|
|
321
333
|
userId: e.get("userId")
|
|
322
334
|
};
|
|
323
335
|
}
|
|
324
|
-
function
|
|
325
|
-
return [...e.values()].map((e) =>
|
|
336
|
+
function Y(e) {
|
|
337
|
+
return [...e.values()].map((e) => J(e)).reduce((e, t) => {
|
|
326
338
|
let n = e.find((e) => e.emoji === t.emoji);
|
|
327
339
|
return n ? (n.userIds.push(t.userId), n.createdAt = new Date(Math.min(n.createdAt.getTime(), t.createdAt.getTime()))) : e.push({
|
|
328
340
|
emoji: t.emoji,
|
|
@@ -331,7 +343,7 @@ function J(e) {
|
|
|
331
343
|
}), e;
|
|
332
344
|
}, []);
|
|
333
345
|
}
|
|
334
|
-
function
|
|
346
|
+
function X(e) {
|
|
335
347
|
return {
|
|
336
348
|
type: "comment",
|
|
337
349
|
id: e.get("id"),
|
|
@@ -339,18 +351,18 @@ function Y(e) {
|
|
|
339
351
|
createdAt: new Date(e.get("createdAt")),
|
|
340
352
|
updatedAt: new Date(e.get("updatedAt")),
|
|
341
353
|
deletedAt: e.get("deletedAt") ? new Date(e.get("deletedAt")) : void 0,
|
|
342
|
-
reactions:
|
|
354
|
+
reactions: Y(e.get("reactionsByUser")),
|
|
343
355
|
metadata: e.get("metadata"),
|
|
344
356
|
body: e.get("body")
|
|
345
357
|
};
|
|
346
358
|
}
|
|
347
|
-
function
|
|
359
|
+
function Z(e) {
|
|
348
360
|
return {
|
|
349
361
|
type: "thread",
|
|
350
362
|
id: e.get("id"),
|
|
351
363
|
createdAt: new Date(e.get("createdAt")),
|
|
352
364
|
updatedAt: new Date(e.get("updatedAt")),
|
|
353
|
-
comments: (e.get("comments") || []).map((e) =>
|
|
365
|
+
comments: (e.get("comments") || []).map((e) => X(e)),
|
|
354
366
|
resolved: e.get("resolved"),
|
|
355
367
|
resolvedUpdatedAt: new Date(e.get("resolvedUpdatedAt")),
|
|
356
368
|
resolvedBy: e.get("resolvedBy"),
|
|
@@ -359,7 +371,7 @@ function X(e) {
|
|
|
359
371
|
}
|
|
360
372
|
//#endregion
|
|
361
373
|
//#region src/yjs/comments/YjsThreadStoreBase.ts
|
|
362
|
-
var
|
|
374
|
+
var Q = class extends o {
|
|
363
375
|
threadsYMap;
|
|
364
376
|
constructor(e, t) {
|
|
365
377
|
super(t), this.threadsYMap = e;
|
|
@@ -367,12 +379,12 @@ var Z = class extends o {
|
|
|
367
379
|
getThread(e) {
|
|
368
380
|
let t = this.threadsYMap.get(e);
|
|
369
381
|
if (!t) throw Error("Thread not found");
|
|
370
|
-
return
|
|
382
|
+
return Z(t);
|
|
371
383
|
}
|
|
372
384
|
getThreads() {
|
|
373
385
|
let e = /* @__PURE__ */ new Map();
|
|
374
386
|
return this.threadsYMap.forEach((t, n) => {
|
|
375
|
-
t instanceof C.Map && e.set(n,
|
|
387
|
+
t instanceof C.Map && e.set(n, Z(t));
|
|
376
388
|
}), e;
|
|
377
389
|
}
|
|
378
390
|
subscribe(e) {
|
|
@@ -383,7 +395,7 @@ var Z = class extends o {
|
|
|
383
395
|
this.threadsYMap.unobserveDeep(t);
|
|
384
396
|
};
|
|
385
397
|
}
|
|
386
|
-
},
|
|
398
|
+
}, te = class extends Q {
|
|
387
399
|
BASE_URL;
|
|
388
400
|
headers;
|
|
389
401
|
constructor(e, t, n, r) {
|
|
@@ -402,7 +414,7 @@ var Z = class extends o {
|
|
|
402
414
|
return r.json();
|
|
403
415
|
};
|
|
404
416
|
addThreadToDocument = async (e) => {
|
|
405
|
-
let { threadId: t, selection: n } = e, r = b.getState(e.editor.prosemirrorState), i = r ? {
|
|
417
|
+
let { threadId: t, selection: n } = e, r = b.getState(e.editor.prosemirrorState)?.binding, i = r ? {
|
|
406
418
|
head: d(n.head, r.type, r.mapping),
|
|
407
419
|
anchor: d(n.anchor, r.type, r.mapping)
|
|
408
420
|
} : void 0;
|
|
@@ -432,7 +444,7 @@ var Z = class extends o {
|
|
|
432
444
|
return this.doRequest(`/${t}/comments/${n}/reactions`, "POST", r);
|
|
433
445
|
};
|
|
434
446
|
deleteReaction = (e) => this.doRequest(`/${e.threadId}/comments/${e.commentId}/reactions/${e.emoji}`, "DELETE");
|
|
435
|
-
},
|
|
447
|
+
}, ne = class extends Q {
|
|
436
448
|
userId;
|
|
437
449
|
constructor(e, t, n) {
|
|
438
450
|
super(t, n), this.userId = e;
|
|
@@ -458,13 +470,13 @@ var Z = class extends o {
|
|
|
458
470
|
resolved: !1,
|
|
459
471
|
metadata: e.metadata
|
|
460
472
|
};
|
|
461
|
-
return this.threadsYMap.set(r.id,
|
|
473
|
+
return this.threadsYMap.set(r.id, q(r)), r;
|
|
462
474
|
});
|
|
463
475
|
addThreadToDocument = void 0;
|
|
464
476
|
addComment = this.transact((e) => {
|
|
465
477
|
let t = this.threadsYMap.get(e.threadId);
|
|
466
478
|
if (!t) throw Error("Thread not found");
|
|
467
|
-
if (!this.auth.canAddComment(
|
|
479
|
+
if (!this.auth.canAddComment(Z(t))) throw Error("Not authorized");
|
|
468
480
|
let n = /* @__PURE__ */ new Date(), r = {
|
|
469
481
|
type: "comment",
|
|
470
482
|
id: c(),
|
|
@@ -476,7 +488,7 @@ var Z = class extends o {
|
|
|
476
488
|
metadata: e.comment.metadata,
|
|
477
489
|
body: e.comment.body
|
|
478
490
|
};
|
|
479
|
-
return t.get("comments").push([
|
|
491
|
+
return t.get("comments").push([K(r)]), t.set("updatedAt", (/* @__PURE__ */ new Date()).getTime()), r;
|
|
480
492
|
});
|
|
481
493
|
updateComment = this.transact((e) => {
|
|
482
494
|
let t = this.threadsYMap.get(e.threadId);
|
|
@@ -484,7 +496,7 @@ var Z = class extends o {
|
|
|
484
496
|
let n = $(t.get("comments"), (t) => t.get("id") === e.commentId);
|
|
485
497
|
if (n === -1) throw Error("Comment not found");
|
|
486
498
|
let r = t.get("comments").get(n);
|
|
487
|
-
if (!this.auth.canUpdateComment(
|
|
499
|
+
if (!this.auth.canUpdateComment(X(r))) throw Error("Not authorized");
|
|
488
500
|
r.set("body", e.comment.body), r.set("updatedAt", (/* @__PURE__ */ new Date()).getTime()), r.set("metadata", e.comment.metadata);
|
|
489
501
|
});
|
|
490
502
|
deleteComment = this.transact((e) => {
|
|
@@ -493,24 +505,24 @@ var Z = class extends o {
|
|
|
493
505
|
let n = $(t.get("comments"), (t) => t.get("id") === e.commentId);
|
|
494
506
|
if (n === -1) throw Error("Comment not found");
|
|
495
507
|
let r = t.get("comments").get(n);
|
|
496
|
-
if (!this.auth.canDeleteComment(
|
|
508
|
+
if (!this.auth.canDeleteComment(X(r))) throw Error("Not authorized");
|
|
497
509
|
if (r.get("deletedAt")) throw Error("Comment already deleted");
|
|
498
510
|
e.softDelete ? (r.set("deletedAt", (/* @__PURE__ */ new Date()).getTime()), r.set("body", void 0)) : t.get("comments").delete(n), t.get("comments").toArray().every((e) => e.get("deletedAt")) && (e.softDelete ? t.set("deletedAt", (/* @__PURE__ */ new Date()).getTime()) : this.threadsYMap.delete(e.threadId)), t.set("updatedAt", (/* @__PURE__ */ new Date()).getTime());
|
|
499
511
|
});
|
|
500
512
|
deleteThread = this.transact((e) => {
|
|
501
|
-
if (!this.auth.canDeleteThread(
|
|
513
|
+
if (!this.auth.canDeleteThread(Z(this.threadsYMap.get(e.threadId)))) throw Error("Not authorized");
|
|
502
514
|
this.threadsYMap.delete(e.threadId);
|
|
503
515
|
});
|
|
504
516
|
resolveThread = this.transact((e) => {
|
|
505
517
|
let t = this.threadsYMap.get(e.threadId);
|
|
506
518
|
if (!t) throw Error("Thread not found");
|
|
507
|
-
if (!this.auth.canResolveThread(
|
|
519
|
+
if (!this.auth.canResolveThread(Z(t))) throw Error("Not authorized");
|
|
508
520
|
t.set("resolved", !0), t.set("resolvedUpdatedAt", (/* @__PURE__ */ new Date()).getTime()), t.set("resolvedBy", this.userId);
|
|
509
521
|
});
|
|
510
522
|
unresolveThread = this.transact((e) => {
|
|
511
523
|
let t = this.threadsYMap.get(e.threadId);
|
|
512
524
|
if (!t) throw Error("Thread not found");
|
|
513
|
-
if (!this.auth.canUnresolveThread(
|
|
525
|
+
if (!this.auth.canUnresolveThread(Z(t))) throw Error("Not authorized");
|
|
514
526
|
t.set("resolved", !1), t.set("resolvedUpdatedAt", (/* @__PURE__ */ new Date()).getTime());
|
|
515
527
|
});
|
|
516
528
|
addReaction = this.transact((e) => {
|
|
@@ -519,7 +531,7 @@ var Z = class extends o {
|
|
|
519
531
|
let n = $(t.get("comments"), (t) => t.get("id") === e.commentId);
|
|
520
532
|
if (n === -1) throw Error("Comment not found");
|
|
521
533
|
let r = t.get("comments").get(n);
|
|
522
|
-
if (!this.auth.canAddReaction(
|
|
534
|
+
if (!this.auth.canAddReaction(X(r), e.emoji)) throw Error("Not authorized");
|
|
523
535
|
let i = /* @__PURE__ */ new Date(), a = `${this.userId}-${e.emoji}`, o = r.get("reactionsByUser");
|
|
524
536
|
if (!o.has(a)) {
|
|
525
537
|
let t = new C.Map();
|
|
@@ -532,7 +544,7 @@ var Z = class extends o {
|
|
|
532
544
|
let n = $(t.get("comments"), (t) => t.get("id") === e.commentId);
|
|
533
545
|
if (n === -1) throw Error("Comment not found");
|
|
534
546
|
let r = t.get("comments").get(n);
|
|
535
|
-
if (!this.auth.canDeleteReaction(
|
|
547
|
+
if (!this.auth.canDeleteReaction(X(r), e.emoji)) throw Error("Not authorized");
|
|
536
548
|
let i = `${this.userId}-${e.emoji}`;
|
|
537
549
|
r.get("reactionsByUser").delete(i);
|
|
538
550
|
});
|
|
@@ -542,6 +554,6 @@ function $(e, t) {
|
|
|
542
554
|
return -1;
|
|
543
555
|
}
|
|
544
556
|
//#endregion
|
|
545
|
-
export {
|
|
557
|
+
export { W as CollaborationExtension, R as ForkYDocExtension, te as RESTYjsThreadStore, z as RelativePositionMappingExtension, H as SchemaMigration, P as YCursorExtension, F as YSyncExtension, I as YUndoExtension, ne as YjsThreadStore, Q as YjsThreadStoreBase, E as _blocksToProsemirrorNode, T as _prosemirrorJSONToBlocks, A as blocksToYDoc, O as blocksToYXmlFragment, U as createYjsVersioningAdapter, w as findTypeInOtherYdoc, G as withCollaboration, k as yDocToBlocks, D as yXmlFragmentToBlocks };
|
|
546
558
|
|
|
547
559
|
//# sourceMappingURL=yjs.js.map
|