@blocknote/core 0.54.0 → 0.54.2
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/blocknote.cjs +1 -1
- package/dist/blocknote.js +6 -6
- package/dist/{blocks-CzkqclGj.cjs → blocks-CTB_5Vyj.cjs} +4 -4
- package/dist/blocks-CTB_5Vyj.cjs.map +1 -0
- package/dist/{blocks-CzQLehlc.js → blocks-Dol85hpH.js} +337 -330
- package/dist/blocks-Dol85hpH.js.map +1 -0
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +2 -2
- package/dist/extensions-B7Rsp_Ft.cjs +58 -0
- package/dist/extensions-B7Rsp_Ft.cjs.map +1 -0
- package/dist/{extensions-DGuhtOgB.js → extensions-D6JcJCwd.js} +389 -346
- package/dist/extensions-D6JcJCwd.js.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +3 -3
- package/dist/{src-BkfZVfaO.js → src-Buuo5l7X.js} +521 -516
- package/dist/{src-BkfZVfaO.js.map → src-Buuo5l7X.js.map} +1 -1
- package/dist/{src-DM3syMdf.cjs → src-C54Ok9E0.cjs} +10 -10
- package/dist/{src-DM3syMdf.cjs.map → src-C54Ok9E0.cjs.map} +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 +205 -205
- package/dist/y.js.map +1 -1
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.js +21 -21
- package/package.json +1 -1
- package/src/api/getBlocksChangedByTransaction.test.ts +211 -0
- package/src/api/getBlocksChangedByTransaction.ts +48 -12
- package/src/api/getChangedRange.ts +54 -0
- package/src/blocks/index.ts +0 -1
- package/src/editor/performance.test.ts +45 -0
- package/src/exporter/Exporter.test.ts +148 -10
- package/src/exporter/Exporter.ts +20 -2
- package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +21 -0
- package/src/extensions/PreviousBlockType/PreviousBlockType.ts +5 -3
- package/src/extensions/TableHandles/TableHandles.browser.test.ts +305 -0
- package/src/extensions/TableHandles/TableHandles.ts +82 -41
- package/src/fonts/inter.css +9 -9
- package/src/schema/blocks/createSpec.ts +4 -5
- package/src/schema/inlineContent/createSpec.ts +4 -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/y/extensions/AttributionExtension.test.ts +8 -9
- package/src/y/versioning/__test__/yhub.test.ts +92 -59
- package/src/y/versioning/yhub.ts +35 -29
- package/types/src/api/getChangedRange.d.ts +14 -0
- package/types/src/blocks/index.d.ts +0 -1
- package/types/src/exporter/Exporter.d.ts +9 -0
- package/types/src/extensions/TableHandles/TableHandles.browser.test.d.ts +1 -0
- package/types/src/extensions/TableHandles/TableHandles.d.ts +3 -0
- package/types/src/schema/nodeViewMutations.d.ts +2 -2
- package/types/src/schema/schema.test.d.ts +1 -0
- package/types/src/y/versioning/yhub.d.ts +3 -2
- package/dist/blocks-CzQLehlc.js.map +0 -1
- package/dist/blocks-CzkqclGj.cjs.map +0 -1
- package/dist/extensions-CSB9ZvuL.cjs +0 -58
- package/dist/extensions-CSB9ZvuL.cjs.map +0 -1
- package/dist/extensions-DGuhtOgB.js.map +0 -1
- package/src/blocks/File/helpers/uploadToTmpFilesDotOrg_DEV_ONLY.ts +0 -20
- package/types/src/blocks/File/helpers/uploadToTmpFilesDotOrg_DEV_ONLY.d.ts +0 -6
package/dist/y.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Cn as e, D as t, Ft as n } from "./blocks-Dol85hpH.js";
|
|
2
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-
|
|
4
|
-
import { a as u, i as d, o as f } from "./extensions-
|
|
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
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
|
|
15
|
+
var T = (e, t) => e === void 0 ? void 0 : typeof e == "string" ? e : e[t], E = (e, t) => ({ mark: n, inline: r }) => {
|
|
16
16
|
let i = t?.editor, a = e === "insert" ? "ins" : e === "delete" ? "del" : r ? "span" : "div", o = document.createElement(a);
|
|
17
17
|
Object.assign(o.dataset, {
|
|
18
18
|
userIds: JSON.stringify(n.attrs.userIds),
|
|
19
19
|
inline: String(r)
|
|
20
20
|
}), e === "modification" && (o.dataset.type = "modification", o.dataset.format = JSON.stringify(n.attrs.format));
|
|
21
|
-
let u =
|
|
21
|
+
let u = T(t?.getAttributionMarkClassName?.({
|
|
22
22
|
contentType: r ? "inline-content" : "block",
|
|
23
23
|
modificationType: e === "modification" ? "format" : e
|
|
24
24
|
}), "content"), d = (n.attrs.userIds ?? [])[0], f = d ? l(d) : s[0];
|
|
@@ -37,7 +37,7 @@ var D = (e, t) => e === void 0 ? void 0 : typeof e == "string" ? e : e[t], O = (
|
|
|
37
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,8 +133,8 @@ 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)
|
|
@@ -146,19 +146,19 @@ var D = (e, t) => e === void 0 ? void 0 : typeof e == "string" ? e : e[t], O = (
|
|
|
146
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
|
-
}, l, u = (e) =>
|
|
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: o(t,
|
|
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")
|
|
@@ -167,7 +167,7 @@ var D = (e, t) => e === void 0 ? void 0 : typeof e == "string" ? e : e[t], O = (
|
|
|
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;
|
|
@@ -181,7 +181,7 @@ var D = (e, t) => e === void 0 ? void 0 : typeof e == "string" ? e : e[t], O = (
|
|
|
181
181
|
}
|
|
182
182
|
let a = d(i), o = i, s = i.parentElement;
|
|
183
183
|
for (; s;) {
|
|
184
|
-
let e = s.closest(
|
|
184
|
+
let e = s.closest(j);
|
|
185
185
|
if (!e) break;
|
|
186
186
|
let t = d(e);
|
|
187
187
|
if (t === a) o = e;
|
|
@@ -190,7 +190,7 @@ var D = (e, t) => e === void 0 ? void 0 : typeof e == "string" ? e : e[t], O = (
|
|
|
190
190
|
}
|
|
191
191
|
if (l === o) return;
|
|
192
192
|
l = o, r.setState(f(o));
|
|
193
|
-
let c =
|
|
193
|
+
let c = M(o.dataset.userIds);
|
|
194
194
|
c.length > 0 && t.loadUsers(c).then(() => {
|
|
195
195
|
l === o && r.setState(f(o));
|
|
196
196
|
});
|
|
@@ -198,39 +198,39 @@ var D = (e, t) => e === void 0 ? void 0 : typeof e == "string" ? e : e[t], O = (
|
|
|
198
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,28 +259,28 @@ 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
285
|
if (e.provider && "synced" in e.provider && typeof e.provider.synced == "boolean") {
|
|
286
286
|
if (e.provider.synced) n();
|
|
@@ -290,16 +290,16 @@ var V = (e, t) => {
|
|
|
290
290
|
else throw Error("YSyncExtension: provider must have a 'synced' boolean or an 'on' method to listen for 'sync'");
|
|
291
291
|
} else n();
|
|
292
292
|
},
|
|
293
|
-
prosemirrorPlugins: [
|
|
293
|
+
prosemirrorPlugins: [_e({
|
|
294
294
|
suggestionDoc: e.suggestionDoc,
|
|
295
|
-
mapAttributionToMark:
|
|
296
|
-
customCompare:
|
|
295
|
+
mapAttributionToMark: V,
|
|
296
|
+
customCompare: B
|
|
297
297
|
})],
|
|
298
298
|
runsBefore: ["default"]
|
|
299
299
|
}));
|
|
300
300
|
//#endregion
|
|
301
301
|
//#region src/y/utils.ts
|
|
302
|
-
function
|
|
302
|
+
function U(e, t) {
|
|
303
303
|
let n = e.doc;
|
|
304
304
|
if (!n) throw Error("type does not have a ydoc");
|
|
305
305
|
if (e._item === null) {
|
|
@@ -308,46 +308,46 @@ function W(e, t) {
|
|
|
308
308
|
return t.get(r, e.constructor);
|
|
309
309
|
}
|
|
310
310
|
{
|
|
311
|
-
let n = e._item, r = t.store.clients.get(n.id.client) ?? [], i = r[
|
|
311
|
+
let n = e._item, r = t.store.clients.get(n.id.client) ?? [], i = r[S.findIndexSS(r, n.id.clock)];
|
|
312
312
|
if (!i) throw Error("type does not exist in other ydoc");
|
|
313
313
|
let a = i.content;
|
|
314
314
|
if (!a) throw Error("type does not exist in other ydoc");
|
|
315
315
|
return a.type;
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
|
-
function
|
|
319
|
-
let r =
|
|
320
|
-
return
|
|
318
|
+
function Ce(t, n) {
|
|
319
|
+
let r = t.pmSchema.nodeFromJSON(n);
|
|
320
|
+
return e(r);
|
|
321
321
|
}
|
|
322
|
-
function
|
|
323
|
-
let r =
|
|
324
|
-
return
|
|
325
|
-
}
|
|
326
|
-
function K(e, t) {
|
|
327
|
-
let r = ce(t.toDeltaDeep(), e.pmSchema, null);
|
|
328
|
-
return r === null ? [] : n(r);
|
|
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));
|
|
329
325
|
}
|
|
330
|
-
function
|
|
331
|
-
|
|
326
|
+
function G(t, n) {
|
|
327
|
+
let r = ue(n.toDeltaDeep(), t.pmSchema, null);
|
|
328
|
+
return r === null ? [] : e(r);
|
|
332
329
|
}
|
|
333
|
-
function we(e, t, n
|
|
334
|
-
return
|
|
330
|
+
function we(e, t, n) {
|
|
331
|
+
return n ||= new S.Doc().get("prosemirror"), pe(W(e, t), n);
|
|
335
332
|
}
|
|
336
333
|
function Te(e, t, n = "prosemirror") {
|
|
337
|
-
|
|
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();
|
|
338
338
|
return i.get(n).applyDelta(r), i;
|
|
339
339
|
}
|
|
340
|
-
function
|
|
341
|
-
let n =
|
|
342
|
-
return
|
|
340
|
+
function K(e, t) {
|
|
341
|
+
let n = y(e), r = y(t);
|
|
342
|
+
return x.diff(n.done(), r.done(), { compare: B });
|
|
343
343
|
}
|
|
344
|
-
function
|
|
345
|
-
let r =
|
|
346
|
-
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);
|
|
347
347
|
}
|
|
348
348
|
//#endregion
|
|
349
349
|
//#region src/y/extensions/Suggestions.ts
|
|
350
|
-
var
|
|
350
|
+
var De = a(({ editor: e, options: t }) => {
|
|
351
351
|
let n = t.suggestionDoc;
|
|
352
352
|
if (!n) throw Error("Suggestion doc not found");
|
|
353
353
|
let r = p(t.resolveUsers);
|
|
@@ -363,7 +363,7 @@ var Ee = a(({ editor: e, options: t }) => {
|
|
|
363
363
|
return e.transact((r) => {
|
|
364
364
|
let i = r.doc.resolve(t), a = i.marks().find((e) => e.type.name === n);
|
|
365
365
|
if (!a) return;
|
|
366
|
-
let o =
|
|
366
|
+
let o = te(i, a.type);
|
|
367
367
|
if (o) return {
|
|
368
368
|
range: o,
|
|
369
369
|
mark: a,
|
|
@@ -371,7 +371,7 @@ var Ee = a(({ editor: e, options: t }) => {
|
|
|
371
371
|
return r.doc.textBetween(o.from, o.to);
|
|
372
372
|
},
|
|
373
373
|
get position() {
|
|
374
|
-
return
|
|
374
|
+
return ne(e.prosemirrorView, o.from, o.to).toJSON();
|
|
375
375
|
}
|
|
376
376
|
};
|
|
377
377
|
});
|
|
@@ -387,27 +387,27 @@ var Ee = a(({ editor: e, options: t }) => {
|
|
|
387
387
|
userStore: r,
|
|
388
388
|
runsBefore: ["ySync"],
|
|
389
389
|
viewSuggestions: () => {
|
|
390
|
-
t.renderer && (t.renderer.suggestionMode = !1), e.exec(
|
|
391
|
-
ytype:
|
|
390
|
+
t.renderer && (t.renderer.suggestionMode = !1), e.exec(_({
|
|
391
|
+
ytype: U(t.fragment, n),
|
|
392
392
|
renderer: t.renderer
|
|
393
393
|
}));
|
|
394
394
|
},
|
|
395
395
|
enableSuggestions: () => {
|
|
396
|
-
t.renderer && (t.renderer.suggestionMode = !0), e.exec(
|
|
397
|
-
ytype:
|
|
396
|
+
t.renderer && (t.renderer.suggestionMode = !0), e.exec(_({
|
|
397
|
+
ytype: U(t.fragment, n),
|
|
398
398
|
renderer: t.renderer
|
|
399
399
|
}));
|
|
400
400
|
},
|
|
401
401
|
disableSuggestions: () => {
|
|
402
|
-
e.exec(
|
|
402
|
+
e.exec(_({
|
|
403
403
|
ytype: t.fragment,
|
|
404
404
|
renderer: null
|
|
405
405
|
}));
|
|
406
406
|
},
|
|
407
|
-
applyAllSuggestions: () => e.exec(
|
|
408
|
-
applySuggestion: (t, n) => e.exec(
|
|
409
|
-
revertSuggestion: (t, n) => e.exec(
|
|
410
|
-
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()),
|
|
411
411
|
getSuggestionElementAtPos: i,
|
|
412
412
|
getMarkAtPos: a,
|
|
413
413
|
getSuggestionAtSelection: o,
|
|
@@ -423,32 +423,32 @@ var Ee = a(({ editor: e, options: t }) => {
|
|
|
423
423
|
});
|
|
424
424
|
//#endregion
|
|
425
425
|
//#region src/y/extensions/Versioning.ts
|
|
426
|
-
function
|
|
427
|
-
e.exec(
|
|
426
|
+
function Oe(e) {
|
|
427
|
+
e.exec(fe), e.removeBlocks(e.document);
|
|
428
428
|
}
|
|
429
|
-
function
|
|
429
|
+
function ke(e, t) {
|
|
430
430
|
return {
|
|
431
431
|
getCurrentDocument: () => t,
|
|
432
|
-
serializeCurrentContent: () =>
|
|
432
|
+
serializeCurrentContent: () => S.encodeStateAsUpdateV2(t.doc),
|
|
433
433
|
preview: {
|
|
434
434
|
enterPreview: (n, r, i) => {
|
|
435
435
|
let a;
|
|
436
436
|
if (r) {
|
|
437
|
-
let e = new
|
|
438
|
-
|
|
437
|
+
let e = new S.Doc({ isSuggestionDoc: !0 });
|
|
438
|
+
S.applyUpdateV2(e, r), a = { fragment: U(t, e) };
|
|
439
439
|
}
|
|
440
|
-
let o = new
|
|
441
|
-
|
|
442
|
-
let r =
|
|
440
|
+
let o = new S.Doc();
|
|
441
|
+
S.applyUpdateV2(o, n), Oe(e), e.exec((e, n) => {
|
|
442
|
+
let r = q({
|
|
443
443
|
tr: e.tr,
|
|
444
|
-
fragment:
|
|
445
|
-
renderer: a ?
|
|
444
|
+
fragment: U(t, o),
|
|
445
|
+
renderer: a ? S.createDiffRenderer(a.fragment.doc, o, i ? { attrs: i } : void 0) : void 0
|
|
446
446
|
});
|
|
447
447
|
return n && n(r), !0;
|
|
448
448
|
});
|
|
449
449
|
},
|
|
450
450
|
exitPreview: () => {
|
|
451
|
-
|
|
451
|
+
Oe(e), e.exec(_({ ytype: t }));
|
|
452
452
|
},
|
|
453
453
|
applyRestore: (e) => {}
|
|
454
454
|
}
|
|
@@ -456,7 +456,7 @@ function Oe(e, t) {
|
|
|
456
456
|
}
|
|
457
457
|
//#endregion
|
|
458
458
|
//#region src/y/extensions/YCursorPlugin.ts
|
|
459
|
-
function
|
|
459
|
+
function Ae(e) {
|
|
460
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 = [
|
|
461
461
|
n / 255,
|
|
462
462
|
r / 255,
|
|
@@ -464,15 +464,15 @@ function ke(e) {
|
|
|
464
464
|
].map((e) => e <= .03928 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4);
|
|
465
465
|
return .2126 * a[0] + .7152 * a[1] + .0722 * a[2] <= .179;
|
|
466
466
|
}
|
|
467
|
-
function
|
|
467
|
+
function je(e) {
|
|
468
468
|
let t = document.createElement("span");
|
|
469
469
|
t.classList.add("bn-collaboration-cursor__base");
|
|
470
470
|
let n = document.createElement("span");
|
|
471
|
-
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"}`);
|
|
472
472
|
let r = document.createElement("span");
|
|
473
|
-
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;
|
|
474
474
|
}
|
|
475
|
-
var
|
|
475
|
+
var Me = a(({ options: e }) => {
|
|
476
476
|
let t = /* @__PURE__ */ new Map(), n = e.provider && "awareness" in e.provider && typeof e.provider.awareness == "object" ? e.provider.awareness : void 0;
|
|
477
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 }) => {
|
|
478
478
|
for (let n of e) {
|
|
@@ -488,12 +488,12 @@ var je = a(({ options: e }) => {
|
|
|
488
488
|
}
|
|
489
489
|
})), {
|
|
490
490
|
key: "yCursor",
|
|
491
|
-
prosemirrorPlugins: [n ?
|
|
492
|
-
selectionBuilder:
|
|
491
|
+
prosemirrorPlugins: [n ? ve(n, {
|
|
492
|
+
selectionBuilder: ce,
|
|
493
493
|
cursorBuilder(n, r) {
|
|
494
494
|
let i = t.get(r);
|
|
495
495
|
if (!i) {
|
|
496
|
-
let a = (e.renderCursor ??
|
|
496
|
+
let a = (e.renderCursor ?? je)(n);
|
|
497
497
|
e.showCursorLabels !== "always" && (a.addEventListener("mouseenter", () => {
|
|
498
498
|
let e = t.get(r);
|
|
499
499
|
e.element.setAttribute("data-active", ""), e.hideTimeout && (clearTimeout(e.hideTimeout), t.set(r, {
|
|
@@ -525,19 +525,19 @@ var je = a(({ options: e }) => {
|
|
|
525
525
|
if (e) return e.user;
|
|
526
526
|
}
|
|
527
527
|
};
|
|
528
|
-
}),
|
|
529
|
-
function
|
|
530
|
-
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();
|
|
531
531
|
return e.on("beforeObserverCalls", (e) => {
|
|
532
|
-
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)]));
|
|
533
533
|
}), n;
|
|
534
534
|
}
|
|
535
|
-
var
|
|
536
|
-
let n = e?.color ??
|
|
535
|
+
var Re = a(({ options: e, editor: t }) => {
|
|
536
|
+
let n = e?.color ?? Ie;
|
|
537
537
|
return {
|
|
538
538
|
key: "diffVersioning",
|
|
539
|
-
blockNoteExtensions: [
|
|
540
|
-
resolveUsers: async (e) => e.filter((e) => e.startsWith(
|
|
539
|
+
blockNoteExtensions: [F({
|
|
540
|
+
resolveUsers: async (e) => e.filter((e) => e.startsWith(Ne)).map((e) => ({
|
|
541
541
|
id: e,
|
|
542
542
|
username: e.slice(8),
|
|
543
543
|
avatarUrl: "",
|
|
@@ -545,22 +545,22 @@ var Le = a(({ options: e, editor: t }) => {
|
|
|
545
545
|
})),
|
|
546
546
|
getAttributionMarkClassName: e?.getAttributionMarkClassName
|
|
547
547
|
})],
|
|
548
|
-
renderDiff: (e, n, r =
|
|
549
|
-
let i =
|
|
548
|
+
renderDiff: (e, n, r = Fe) => {
|
|
549
|
+
let i = Pe(r);
|
|
550
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.");
|
|
551
|
-
let a =
|
|
551
|
+
let a = W(t, n), o = W(t, e), s = new S.Doc({ gc: !1 }), c = s.get("prosemirror");
|
|
552
552
|
s.transact(() => {
|
|
553
|
-
c.applyDelta(
|
|
553
|
+
c.applyDelta(v(a));
|
|
554
554
|
});
|
|
555
|
-
let l = new
|
|
556
|
-
|
|
557
|
-
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);
|
|
558
558
|
l.transact(() => {
|
|
559
559
|
u.applyDelta(f);
|
|
560
560
|
}, i);
|
|
561
|
-
let p =
|
|
561
|
+
let p = S.createDiffRenderer(s, l, { attrs: d });
|
|
562
562
|
t.replaceBlocks(t.document, []), t.exec((e, t) => {
|
|
563
|
-
let n =
|
|
563
|
+
let n = q({
|
|
564
564
|
tr: e.tr,
|
|
565
565
|
fragment: u,
|
|
566
566
|
renderer: p
|
|
@@ -572,7 +572,7 @@ var Le = a(({ options: e, editor: t }) => {
|
|
|
572
572
|
t.replaceBlocks(t.document, []), t.replaceBlocks(t.document, e);
|
|
573
573
|
}
|
|
574
574
|
};
|
|
575
|
-
}),
|
|
575
|
+
}), ze = a(({ editor: e, options: t }) => {
|
|
576
576
|
let n = p(t.resolveUsers), r = {
|
|
577
577
|
...t,
|
|
578
578
|
resolveUsers: n
|
|
@@ -581,26 +581,26 @@ var Le = a(({ options: e, editor: t }) => {
|
|
|
581
581
|
key: "collaboration",
|
|
582
582
|
userStore: n,
|
|
583
583
|
blockNoteExtensions: [
|
|
584
|
-
t.suggestionDoc ?
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
584
|
+
t.suggestionDoc ? De(r) : null,
|
|
585
|
+
I(),
|
|
586
|
+
H(r),
|
|
587
|
+
Me(t),
|
|
588
588
|
t.versioningEndpoints ? u({
|
|
589
|
-
...
|
|
589
|
+
...ke(e, t.fragment),
|
|
590
590
|
endpoints: t.versioningEndpoints,
|
|
591
591
|
resolveUsers: n
|
|
592
592
|
}) : null,
|
|
593
|
-
|
|
593
|
+
F({
|
|
594
594
|
resolveUsers: n,
|
|
595
595
|
getAttributionMarkClassName: t.getAttributionMarkClassName
|
|
596
596
|
})
|
|
597
597
|
].filter((e) => e !== null)
|
|
598
598
|
};
|
|
599
599
|
});
|
|
600
|
-
function
|
|
600
|
+
function Be(e) {
|
|
601
601
|
return e.initialContent && console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider"), {
|
|
602
602
|
...e,
|
|
603
|
-
extensions: [...e.extensions ?? [],
|
|
603
|
+
extensions: [...e.extensions ?? [], ze(e.collaboration)],
|
|
604
604
|
disableExtensions: ["history", ...e.disableExtensions ?? []],
|
|
605
605
|
initialContent: [{
|
|
606
606
|
type: "paragraph",
|
|
@@ -610,16 +610,16 @@ function ze(e) {
|
|
|
610
610
|
}
|
|
611
611
|
//#endregion
|
|
612
612
|
//#region src/y/comments/yjsHelpers.ts
|
|
613
|
-
function
|
|
614
|
-
let t = new
|
|
613
|
+
function J(e) {
|
|
614
|
+
let t = new S.Type();
|
|
615
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");
|
|
616
|
-
return t.setAttr("reactionsByUser", new
|
|
616
|
+
return t.setAttr("reactionsByUser", new S.Type()), t.setAttr("metadata", e.metadata), t;
|
|
617
617
|
}
|
|
618
618
|
function Ve(e) {
|
|
619
|
-
let t = new
|
|
619
|
+
let t = new S.Type();
|
|
620
620
|
t.setAttr("id", e.id), t.setAttr("createdAt", e.createdAt.getTime()), t.setAttr("updatedAt", e.updatedAt.getTime());
|
|
621
|
-
let n = new
|
|
622
|
-
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;
|
|
623
623
|
}
|
|
624
624
|
function He(e) {
|
|
625
625
|
return {
|
|
@@ -679,7 +679,7 @@ var Z = class extends m {
|
|
|
679
679
|
getThreads() {
|
|
680
680
|
let e = /* @__PURE__ */ new Map();
|
|
681
681
|
return this.threadsYType.forEachAttr((t, n) => {
|
|
682
|
-
t instanceof
|
|
682
|
+
t instanceof S.Type && e.set(String(n), X(t));
|
|
683
683
|
}), e;
|
|
684
684
|
}
|
|
685
685
|
subscribe(e) {
|
|
@@ -743,7 +743,7 @@ var Z = class extends m {
|
|
|
743
743
|
if (!this.auth.canCreateThread()) throw Error("Not authorized");
|
|
744
744
|
let t = /* @__PURE__ */ new Date(), n = {
|
|
745
745
|
type: "comment",
|
|
746
|
-
id:
|
|
746
|
+
id: g(),
|
|
747
747
|
userId: this.userId,
|
|
748
748
|
createdAt: t,
|
|
749
749
|
updatedAt: t,
|
|
@@ -752,7 +752,7 @@ var Z = class extends m {
|
|
|
752
752
|
body: e.initialComment.body
|
|
753
753
|
}, r = {
|
|
754
754
|
type: "thread",
|
|
755
|
-
id:
|
|
755
|
+
id: g(),
|
|
756
756
|
createdAt: t,
|
|
757
757
|
updatedAt: t,
|
|
758
758
|
comments: [n],
|
|
@@ -768,7 +768,7 @@ var Z = class extends m {
|
|
|
768
768
|
if (!this.auth.canAddComment(X(t))) throw Error("Not authorized");
|
|
769
769
|
let n = /* @__PURE__ */ new Date(), r = {
|
|
770
770
|
type: "comment",
|
|
771
|
-
id:
|
|
771
|
+
id: g(),
|
|
772
772
|
userId: this.userId,
|
|
773
773
|
createdAt: n,
|
|
774
774
|
updatedAt: n,
|
|
@@ -777,7 +777,7 @@ var Z = class extends m {
|
|
|
777
777
|
metadata: e.comment.metadata,
|
|
778
778
|
body: e.comment.body
|
|
779
779
|
};
|
|
780
|
-
return t.getAttr("comments").push([
|
|
780
|
+
return t.getAttr("comments").push([J(r)]), t.setAttr("updatedAt", (/* @__PURE__ */ new Date()).getTime()), r;
|
|
781
781
|
});
|
|
782
782
|
updateComment = this.transact((e) => {
|
|
783
783
|
let t = this.threadsYType.getAttr(e.threadId);
|
|
@@ -823,7 +823,7 @@ var Z = class extends m {
|
|
|
823
823
|
if (!this.auth.canAddReaction(Y(i), e.emoji)) throw Error("Not authorized");
|
|
824
824
|
let a = /* @__PURE__ */ new Date(), o = `${this.userId}-${e.emoji}`, s = i.getAttr("reactionsByUser");
|
|
825
825
|
if (!s.hasAttr(o)) {
|
|
826
|
-
let t = new
|
|
826
|
+
let t = new S.Type();
|
|
827
827
|
t.setAttr("emoji", e.emoji), t.setAttr("createdAt", a.getTime()), t.setAttr("userId", this.userId), s.setAttr(o, t);
|
|
828
828
|
}
|
|
829
829
|
});
|
|
@@ -879,9 +879,9 @@ async function $(e, t, n) {
|
|
|
879
879
|
return r.arrayBuffer();
|
|
880
880
|
}
|
|
881
881
|
function Ye(e) {
|
|
882
|
-
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}`;
|
|
883
|
-
return (
|
|
884
|
-
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 () => {
|
|
885
885
|
let e = new URLSearchParams({
|
|
886
886
|
order: "desc",
|
|
887
887
|
limit: "1",
|
|
@@ -891,7 +891,7 @@ function Ye(e) {
|
|
|
891
891
|
limit: "1",
|
|
892
892
|
customAttributions: "true",
|
|
893
893
|
withCustomAttributions: "type:version"
|
|
894
|
-
}), [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];
|
|
895
895
|
if (!a || a.to <= (o?.to ?? 0)) return;
|
|
896
896
|
let c = a.by?.split(",").map((e) => e.trim()).filter(Boolean) ?? [];
|
|
897
897
|
return {
|
|
@@ -900,93 +900,93 @@ function Ye(e) {
|
|
|
900
900
|
updatedAt: a.to,
|
|
901
901
|
by: c.length > 0 ? c : void 0
|
|
902
902
|
};
|
|
903
|
-
},
|
|
903
|
+
}, p = async (e, t, n) => {
|
|
904
904
|
if (!e.doc) throw Error("Cannot patch document: the Y.Type is not attached to a Y.Doc.");
|
|
905
|
-
let
|
|
906
|
-
|
|
907
|
-
let
|
|
908
|
-
update:
|
|
909
|
-
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
|
|
910
910
|
};
|
|
911
|
-
|
|
911
|
+
n && (a.by = n), await $(u, i, {
|
|
912
912
|
method: "PATCH",
|
|
913
|
-
body:
|
|
913
|
+
body: w(a)
|
|
914
914
|
});
|
|
915
|
-
},
|
|
916
|
-
let
|
|
917
|
-
|
|
918
|
-
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 = [{
|
|
919
919
|
k: "type",
|
|
920
920
|
v: "version"
|
|
921
921
|
}, {
|
|
922
922
|
k: "id",
|
|
923
|
-
v:
|
|
923
|
+
v: i
|
|
924
924
|
}];
|
|
925
|
-
|
|
925
|
+
r?.name && o.push({
|
|
926
926
|
k: "name",
|
|
927
|
-
v:
|
|
927
|
+
v: r.name
|
|
928
928
|
});
|
|
929
|
-
let
|
|
930
|
-
return await
|
|
931
|
-
id:
|
|
932
|
-
name:
|
|
933
|
-
createdAt:
|
|
934
|
-
updatedAt:
|
|
935
|
-
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
|
|
936
936
|
};
|
|
937
|
-
},
|
|
937
|
+
}, h = async (e) => {
|
|
938
938
|
let t = new URLSearchParams({
|
|
939
939
|
ydoc: "true",
|
|
940
940
|
to: String(e)
|
|
941
|
-
}), n = await $(`${c}?${t}`, i), r =
|
|
942
|
-
if (!r.
|
|
943
|
-
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);
|
|
944
944
|
};
|
|
945
945
|
return {
|
|
946
946
|
list: async () => {
|
|
947
|
-
let t = e.groupMaxGap ?? 1e4,
|
|
947
|
+
let t = e.groupMaxGap ?? 1e4, c = e.groupMaxDuration, l = e.mergeUsers, u = new URLSearchParams({
|
|
948
948
|
order: "desc",
|
|
949
949
|
limit: String(a),
|
|
950
950
|
customAttributions: "true"
|
|
951
951
|
});
|
|
952
|
-
|
|
953
|
-
let
|
|
954
|
-
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;
|
|
955
955
|
return {
|
|
956
956
|
...e,
|
|
957
|
-
name:
|
|
957
|
+
name: r
|
|
958
958
|
};
|
|
959
|
-
})), h = await
|
|
960
|
-
return h ? [h, ...
|
|
959
|
+
})), h = await r();
|
|
960
|
+
return h ? [h, ...m] : m;
|
|
961
961
|
},
|
|
962
|
-
create:
|
|
963
|
-
getContent: async (e) =>
|
|
962
|
+
create: m,
|
|
963
|
+
getContent: async (e) => h(e.createdAt),
|
|
964
964
|
getAttributions: async (e, t) => {
|
|
965
965
|
let n = e.createdAt, r = t === void 0 ? 0 : t.createdAt, a = new URLSearchParams({
|
|
966
966
|
from: String(r),
|
|
967
967
|
to: String(n),
|
|
968
968
|
attributions: "true"
|
|
969
|
-
}), o = await $(`${c}?${a}`, i), s =
|
|
969
|
+
}), o = await $(`${c}?${a}`, i), s = C(new Uint8Array(o));
|
|
970
970
|
if (!s.attributions) throw Error(`YHub returned no attributions for snapshot ${String(e.id)}.`);
|
|
971
|
-
return
|
|
971
|
+
return S.decodeContentMap(s.attributions);
|
|
972
972
|
},
|
|
973
973
|
restore: async (e, t) => {
|
|
974
|
-
let n = t.createdAt, r = await
|
|
975
|
-
return await $(
|
|
974
|
+
let n = t.createdAt, r = await h(n);
|
|
975
|
+
return await $(l, i, {
|
|
976
976
|
method: "POST",
|
|
977
|
-
body:
|
|
977
|
+
body: w({ from: n })
|
|
978
978
|
}), r;
|
|
979
979
|
},
|
|
980
980
|
rename: async (e, t) => {
|
|
981
981
|
if (typeof e.id != "string") return;
|
|
982
|
-
let
|
|
983
|
-
if (!
|
|
984
|
-
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);
|
|
985
985
|
}
|
|
986
986
|
};
|
|
987
987
|
};
|
|
988
988
|
}
|
|
989
989
|
//#endregion
|
|
990
|
-
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 };
|
|
991
991
|
|
|
992
992
|
//# sourceMappingURL=y.js.map
|