@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.
Files changed (62) hide show
  1. package/dist/blocknote.cjs +1 -1
  2. package/dist/blocknote.js +6 -6
  3. package/dist/{blocks-CzkqclGj.cjs → blocks-CTB_5Vyj.cjs} +4 -4
  4. package/dist/blocks-CTB_5Vyj.cjs.map +1 -0
  5. package/dist/{blocks-CzQLehlc.js → blocks-Dol85hpH.js} +337 -330
  6. package/dist/blocks-Dol85hpH.js.map +1 -0
  7. package/dist/blocks.cjs +1 -1
  8. package/dist/blocks.js +2 -2
  9. package/dist/extensions-B7Rsp_Ft.cjs +58 -0
  10. package/dist/extensions-B7Rsp_Ft.cjs.map +1 -0
  11. package/dist/{extensions-DGuhtOgB.js → extensions-D6JcJCwd.js} +389 -346
  12. package/dist/extensions-D6JcJCwd.js.map +1 -0
  13. package/dist/extensions.cjs +1 -1
  14. package/dist/extensions.js +3 -3
  15. package/dist/{src-BkfZVfaO.js → src-Buuo5l7X.js} +521 -516
  16. package/dist/{src-BkfZVfaO.js.map → src-Buuo5l7X.js.map} +1 -1
  17. package/dist/{src-DM3syMdf.cjs → src-C54Ok9E0.cjs} +10 -10
  18. package/dist/{src-DM3syMdf.cjs.map → src-C54Ok9E0.cjs.map} +1 -1
  19. package/dist/webpack-stats.json +1 -1
  20. package/dist/y.cjs +1 -1
  21. package/dist/y.cjs.map +1 -1
  22. package/dist/y.js +205 -205
  23. package/dist/y.js.map +1 -1
  24. package/dist/yjs.cjs +1 -1
  25. package/dist/yjs.js +21 -21
  26. package/package.json +1 -1
  27. package/src/api/getBlocksChangedByTransaction.test.ts +211 -0
  28. package/src/api/getBlocksChangedByTransaction.ts +48 -12
  29. package/src/api/getChangedRange.ts +54 -0
  30. package/src/blocks/index.ts +0 -1
  31. package/src/editor/performance.test.ts +45 -0
  32. package/src/exporter/Exporter.test.ts +148 -10
  33. package/src/exporter/Exporter.ts +20 -2
  34. package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +21 -0
  35. package/src/extensions/PreviousBlockType/PreviousBlockType.ts +5 -3
  36. package/src/extensions/TableHandles/TableHandles.browser.test.ts +305 -0
  37. package/src/extensions/TableHandles/TableHandles.ts +82 -41
  38. package/src/fonts/inter.css +9 -9
  39. package/src/schema/blocks/createSpec.ts +4 -5
  40. package/src/schema/inlineContent/createSpec.ts +4 -5
  41. package/src/schema/nodeViewMutations.test.ts +81 -56
  42. package/src/schema/nodeViewMutations.ts +30 -27
  43. package/src/schema/schema.test.ts +110 -0
  44. package/src/schema/schema.ts +13 -4
  45. package/src/y/extensions/AttributionExtension.test.ts +8 -9
  46. package/src/y/versioning/__test__/yhub.test.ts +92 -59
  47. package/src/y/versioning/yhub.ts +35 -29
  48. package/types/src/api/getChangedRange.d.ts +14 -0
  49. package/types/src/blocks/index.d.ts +0 -1
  50. package/types/src/exporter/Exporter.d.ts +9 -0
  51. package/types/src/extensions/TableHandles/TableHandles.browser.test.d.ts +1 -0
  52. package/types/src/extensions/TableHandles/TableHandles.d.ts +3 -0
  53. package/types/src/schema/nodeViewMutations.d.ts +2 -2
  54. package/types/src/schema/schema.test.d.ts +1 -0
  55. package/types/src/y/versioning/yhub.d.ts +3 -2
  56. package/dist/blocks-CzQLehlc.js.map +0 -1
  57. package/dist/blocks-CzkqclGj.cjs.map +0 -1
  58. package/dist/extensions-CSB9ZvuL.cjs +0 -58
  59. package/dist/extensions-CSB9ZvuL.cjs.map +0 -1
  60. package/dist/extensions-DGuhtOgB.js.map +0 -1
  61. package/src/blocks/File/helpers/uploadToTmpFilesDotOrg_DEV_ONLY.ts +0 -20
  62. package/types/src/blocks/File/helpers/uploadToTmpFilesDotOrg_DEV_ONLY.d.ts +0 -6
package/dist/y.js CHANGED
@@ -1,24 +1,24 @@
1
- import { It as e, O as t, wn as n } from "./blocks-CzQLehlc.js";
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-BkfZVfaO.js";
4
- import { a as u, i as d, o as f } from "./extensions-DGuhtOgB.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
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 g, getMarkRange as _, posToDOMRect as ee } from "@tiptap/core";
8
- import { uint32 as te, uuidv4 as v } from "lib0/random";
9
- import { Plugin as ne, PluginKey as re } from "prosemirror-state";
10
- import { acceptAllChanges as ie, acceptChanges as ae, configureYProsemirror as y, defaultSelectionBuilder as oe, deltaAttributionToFormat as se, deltaToPNode as ce, deltaToPSteps as le, docToDelta as b, nodeToDelta as x, pauseSync as ue, pmToFragment as de, rejectAllChanges as fe, rejectChanges as pe, relativePositionStore as me, syncPlugin as he, yCursorPlugin as ge, ySyncPluginKey as S } from "@y/prosemirror";
11
- import * as C from "lib0/delta";
12
- import * as w from "@y/y";
13
- import { decodeAny as T, encodeAny as E } from "lib0/buffer";
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 D = (e, t) => e === void 0 ? void 0 : typeof e == "string" ? e : e[t], O = (e, t) => ({ mark: n, inline: r }) => {
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 = D(t?.getAttributionMarkClassName?.({
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
- }, k = h.create({
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 O("insert", { getAttributionMarkClassName: this.options.getAttributionMarkClassName });
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
- }), _e = h.create({
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 O("delete", {
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
- }), A = h.create({
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 O("modification", { getAttributionMarkClassName: this.options.getAttributionMarkClassName });
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
- }), j = a(({ options: e }) => ({
88
+ }), A = a(({ options: e }) => ({
89
89
  key: "yAttributionMarks",
90
90
  tiptapExtensions: [
91
- k.configure({ getAttributionMarkClassName: e?.getAttributionMarkClassName }),
92
- _e.configure({ getAttributionMarkClassName: e?.getAttributionMarkClassName }),
93
- A.configure({ getAttributionMarkClassName: e?.getAttributionMarkClassName })
91
+ D.configure({ getAttributionMarkClassName: e?.getAttributionMarkClassName }),
92
+ O.configure({ getAttributionMarkClassName: e?.getAttributionMarkClassName }),
93
+ k.configure({ getAttributionMarkClassName: e?.getAttributionMarkClassName })
94
94
  ]
95
- })), ve = {
95
+ })), ye = {
96
96
  "y-attributed-insert": "insert",
97
97
  "y-attributed-delete": "delete",
98
98
  "y-attributed-format": "format"
99
- }, ye = new re("attributionLoadUsers"), M = "[data-user-ids]", N = (e) => {
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
- }, P = (e) => {
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
- }, F = (e) => {
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
- }, be = (e) => F(e).getBoundingClientRect(), xe = (e) => F(e).getClientRects(), I = a(({ options: e }) => {
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 = g(e);
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) ve[t.type.name] && t.attrs.userIds?.forEach((e) => a.add(e));
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 ne({
137
- key: ye,
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) => N(e).map((e) => t.getUser(e)?.username ?? e), d = (e) => {
150
- let t = N(e.dataset.userIds);
151
- return t.length === 0 ? "" : `${P(e.dataset.format).join(",")}:${t.join(",")}`;
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, N(e.dataset.userIds)).dark,
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 ? P(e.dataset.format) : void 0,
161
- className: D(n?.({
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(M);
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(M);
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 = N(o.dataset.userIds);
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: [j({ getAttributionMarkClassName: e?.getAttributionMarkClassName })]
201
+ blockNoteExtensions: [A({ getAttributionMarkClassName: e?.getAttributionMarkClassName })]
202
202
  };
203
- }), L = a(({ editor: e }) => ({
203
+ }), I = a(({ editor: e }) => ({
204
204
  key: "yPositionMapping",
205
205
  mapPosition: (t, n = "left") => {
206
- let r = S.getState(e.prosemirrorState);
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 = me(e.prosemirrorState.doc.resolve(t + (n === "right" ? 1 : -1)), r.ytype, r.renderer);
209
+ let i = ge(e.prosemirrorState.doc.resolve(t + (n === "right" ? 1 : -1)), r.ytype, r.renderer);
210
210
  return () => {
211
- let t = S.getState(e.prosemirrorState), r = i(e.prosemirrorState.doc, t.ytype, t.renderer);
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
- })), R = (e) => {
217
- for (let t of e.children) if (C.$insertOp.check(t)) {
218
- for (let e of t.insert) if (C.$deltaAny.check(e)) return e;
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
- }, z = (e) => {
222
- for (let t of e.children) if (C.$insertOp.check(t)) {
223
- for (let e of t.insert) if (C.$deltaAny.check(e) && e.name === "blockGroup") return !0;
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 B(e) {
227
+ function z(e) {
228
228
  if (e.name !== "table") return null;
229
229
  let t = [];
230
- for (let n of e.children) if (C.$insertOp.check(n)) for (let e of n.insert) {
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 (C.$insertOp.check(t)) for (let e of t.insert) {
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 V = (e, t) => {
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 = R(e), r = R(t);
266
- if (n?.name !== r?.name || z(e) !== z(t)) return !1;
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 = B(n), t = B(r);
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
- }, H = (e, t) => {
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
- }, U = a(({ options: e, editor: t }) => ({
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(y({ ytype: e.fragment }));
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: [he({
293
+ prosemirrorPlugins: [_e({
294
294
  suggestionDoc: e.suggestionDoc,
295
- mapAttributionToMark: H,
296
- customCompare: V
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 W(e, t) {
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[w.findIndexSS(r, n.id.clock)];
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 Se(e, t) {
319
- let r = e.pmSchema.nodeFromJSON(t);
320
- return n(r);
318
+ function Ce(t, n) {
319
+ let r = t.pmSchema.nodeFromJSON(n);
320
+ return e(r);
321
321
  }
322
- function G(t, n) {
323
- let r = n.map((n) => e(n, t.pmSchema));
324
- return t.pmSchema.topNodeType.create(null, t.pmSchema.nodes.blockGroup.create(null, r));
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 Ce(e, t, n) {
331
- return n ||= new w.Doc().get("prosemirror"), de(G(e, t), n);
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 = "prosemirror") {
334
- return K(e, t.get(n));
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
- let r = b(G(e, t)), i = new w.Doc();
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 q(e, t) {
341
- let n = x(e), r = x(t);
342
- return C.diff(n.done(), r.done(), { compare: V });
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 J({ tr: e, fragment: t, renderer: n }) {
345
- let r = se(t.toDeltaDeep({ renderer: n }), H), i = x(e.doc, void 0, !0), a = C.diff(i.done(), r.done(), { compare: V });
346
- return le(e, a, void 0, void 0);
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 Ee = a(({ editor: e, options: t }) => {
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 = _(i, a.type);
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 ee(e.prosemirrorView, o.from, o.to).toJSON();
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(y({
391
- ytype: W(t.fragment, n),
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(y({
397
- ytype: W(t.fragment, n),
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(y({
402
+ e.exec(_({
403
403
  ytype: t.fragment,
404
404
  renderer: null
405
405
  }));
406
406
  },
407
- applyAllSuggestions: () => e.exec(ie()),
408
- applySuggestion: (t, n) => e.exec(ae(t, n)),
409
- revertSuggestion: (t, n) => e.exec(pe(t, n)),
410
- revertAllSuggestions: () => e.exec(fe()),
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 De(e) {
427
- e.exec(ue), e.removeBlocks(e.document);
426
+ function Oe(e) {
427
+ e.exec(fe), e.removeBlocks(e.document);
428
428
  }
429
- function Oe(e, t) {
429
+ function ke(e, t) {
430
430
  return {
431
431
  getCurrentDocument: () => t,
432
- serializeCurrentContent: () => w.encodeStateAsUpdateV2(t.doc),
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 w.Doc({ isSuggestionDoc: !0 });
438
- w.applyUpdateV2(e, r), a = { fragment: W(t, e) };
437
+ let e = new S.Doc({ isSuggestionDoc: !0 });
438
+ S.applyUpdateV2(e, r), a = { fragment: U(t, e) };
439
439
  }
440
- let o = new w.Doc();
441
- w.applyUpdateV2(o, n), De(e), e.exec((e, n) => {
442
- let r = J({
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: W(t, o),
445
- renderer: a ? w.createDiffRenderer(a.fragment.doc, o, i ? { attrs: i } : void 0) : void 0
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
- De(e), e.exec(y({ ytype: t }));
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 ke(e) {
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 Ae(e) {
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: ${ke(e.color) ? "white" : "black"}`);
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: ${ke(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;
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 je = a(({ options: e }) => {
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 ? ge(n, {
492
- selectionBuilder: oe,
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 ?? Ae)(n);
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
- }), Me = "version:", Ne = (e) => Me + e, Pe = "This version", Fe = "#4363d8";
529
- function Ie(e, t) {
530
- let n = new w.Attributions();
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() || w.insertIntoIdMap(n.inserts, w.createIdMapFromIdSet(e.insertSet, [w.createContentAttribute("insert", t)])), e.deleteSet.isEmpty() || w.insertIntoIdMap(n.deletes, w.createIdMapFromIdSet(e.deleteSet, [w.createContentAttribute("delete", t)]));
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 Le = a(({ options: e, editor: t }) => {
536
- let n = e?.color ?? Fe;
535
+ var Re = a(({ options: e, editor: t }) => {
536
+ let n = e?.color ?? Ie;
537
537
  return {
538
538
  key: "diffVersioning",
539
- blockNoteExtensions: [I({
540
- resolveUsers: async (e) => e.filter((e) => e.startsWith(Me)).map((e) => ({
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 = Pe) => {
549
- let i = Ne(r);
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 = G(t, n), o = G(t, e), s = new w.Doc({ gc: !1 }), c = s.get("prosemirror");
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(b(a));
553
+ c.applyDelta(v(a));
554
554
  });
555
- let l = new w.Doc({ gc: !1 });
556
- w.applyUpdateV2(l, w.encodeStateAsUpdateV2(s));
557
- let u = W(c, l), d = Ie(l, i), f = q(a, o);
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 = w.createDiffRenderer(s, l, { attrs: d });
561
+ let p = S.createDiffRenderer(s, l, { attrs: d });
562
562
  t.replaceBlocks(t.document, []), t.exec((e, t) => {
563
- let n = J({
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
- }), Re = a(({ editor: e, options: t }) => {
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 ? Ee(r) : null,
585
- L(),
586
- U(r),
587
- je(t),
584
+ t.suggestionDoc ? De(r) : null,
585
+ I(),
586
+ H(r),
587
+ Me(t),
588
588
  t.versioningEndpoints ? u({
589
- ...Oe(e, t.fragment),
589
+ ...ke(e, t.fragment),
590
590
  endpoints: t.versioningEndpoints,
591
591
  resolveUsers: n
592
592
  }) : null,
593
- I({
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 ze(e) {
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 ?? [], Re(e.collaboration)],
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 Be(e) {
614
- let t = new w.Type();
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 w.Type()), t.setAttr("metadata", e.metadata), t;
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 w.Type();
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 w.Type();
622
- return n.push(e.comments.map((e) => Be(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;
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 w.Type && e.set(String(n), X(t));
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: v(),
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: v(),
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: v(),
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([Be(r)]), t.setAttr("updatedAt", (/* @__PURE__ */ new Date()).getTime()), r;
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 w.Type();
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 (u) => {
884
- let p = () => (u.getExtension("ySync")?.fragment.doc)?.get(Ke), m = async () => {
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 = T(new Uint8Array(n))[0], o = T(new Uint8Array(r))[0];
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
- }, h = async (e, a, o) => {
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 s = new w.Doc();
906
- s.get("__bn_version_markers", "XmlFragment").insert(0, ["v"]);
907
- let c = {
908
- update: w.encodeStateAsUpdate(s),
909
- customAttributions: a
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
- await $(`${t}/ydoc/${n}/${r}${o ? `?userid=${o}` : ""}`, i, {
911
+ n && (a.by = n), await $(u, i, {
912
912
  method: "PATCH",
913
- body: E(c)
913
+ body: w(a)
914
914
  });
915
- }, g = async (e, t) => {
916
- let n = String(te()), r = Date.now();
917
- t?.name && p()?.setAttr(n, t.name);
918
- let i = [{
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: n
923
+ v: i
924
924
  }];
925
- t?.name && i.push({
925
+ r?.name && o.push({
926
926
  k: "name",
927
- v: t.name
927
+ v: r.name
928
928
  });
929
- let a = u.getExtension("yCursor")?.getUser();
930
- return await h(e, i, a?.id), {
931
- id: n,
932
- name: t?.name,
933
- createdAt: r,
934
- updatedAt: r,
935
- by: a?.id
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
- }, _ = async (e) => {
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 = T(new Uint8Array(n));
942
- if (!r.nextDoc) throw Error(`YHub returned no document state at timestamp ${e}.`);
943
- return w.convertUpdateFormatV1ToV2(r.nextDoc);
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, n = e.groupMaxDuration, r = e.mergeUsers, c = new URLSearchParams({
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
- c.set("groupMaxGap", String(t)), o !== void 0 && c.set("group", String(o)), n !== void 0 && c.set("groupMaxDuration", String(n)), r !== void 0 && c.set("mergeUsers", String(r));
953
- let l = await $(`${s}?${c}`, i), u = T(new Uint8Array(l)), d = f(u.map((e, t) => Je(e, t)).filter((e) => e !== void 0).map((e) => {
954
- let t = e.name, n = (typeof e.id == "string" ? p()?.getAttr(e.id) : void 0) ?? t;
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: n
957
+ name: r
958
958
  };
959
- })), h = await m();
960
- return h ? [h, ...d] : d;
959
+ })), h = await r();
960
+ return h ? [h, ...m] : m;
961
961
  },
962
- create: g,
963
- getContent: async (e) => _(e.createdAt),
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 = T(new Uint8Array(o));
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 w.decodeContentMap(s.attributions);
971
+ return S.decodeContentMap(s.attributions);
972
972
  },
973
973
  restore: async (e, t) => {
974
- let n = t.createdAt, r = await _(n);
975
- return await $(`${l}?from=${n}`, i, {
974
+ let n = t.createdAt, r = await h(n);
975
+ return await $(l, i, {
976
976
  method: "POST",
977
- body: E({ from: n })
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 n = p();
983
- if (!n) throw Error("Cannot rename version: no live collaboration document is available.");
984
- t === void 0 || t === "" ? n.deleteAttr(e.id) : n.setAttr(e.id, 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 { I as AttributionExtension, Re as CollaborationExtension, Le as DiffVersioningExtension, We as RESTYjsThreadStore, L as RelativePositionMappingExtension, Ee as SuggestionsExtension, _e as YAttributedDeletion, A as YAttributedFormat, k as YAttributedInsertion, j as YAttributionMarksExtension, je as YCursorExtension, U as YSyncExtension, Ge as YjsThreadStore, Z as YjsThreadStoreBase, G as _blocksToProsemirrorNode, Se as _prosemirrorJSONToBlocks, Te as blocksToYDoc, Ce as blocksToYType, Ye as createYHubVersioningEndpoints, Oe as createYjsVersioningAdapter, q as docDiffToDelta, W as findTypeInOtherYdoc, J as getProseMirrorTrFromYFragment, xe as getReferenceClientRects, be as getReferenceRect, H as mapAttributionToMark, D as resolveAttributionMarkClassName, ze as withCollaboration, we as yDocToBlocks, K as yfragmentToBlocks };
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