@blocknote/core 0.53.0 → 0.54.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/dist/BlockNoteExtension-BJCLnwrE.cjs +2 -0
  2. package/dist/BlockNoteExtension-BJCLnwrE.cjs.map +1 -0
  3. package/dist/BlockNoteExtension-CbvDA0F7.js +80 -0
  4. package/dist/BlockNoteExtension-CbvDA0F7.js.map +1 -0
  5. package/dist/{UserStore-QbbPFj0z.js → UserStore-C4TzkGEn.js} +3 -3
  6. package/dist/{UserStore-DCG6lsla.cjs.map → UserStore-C4TzkGEn.js.map} +1 -1
  7. package/dist/{UserStore-DCG6lsla.cjs → UserStore-mj3fXW4D.cjs} +2 -2
  8. package/dist/UserStore-mj3fXW4D.cjs.map +1 -0
  9. package/dist/blocknote.cjs +1 -1
  10. package/dist/blocknote.js +6 -6
  11. package/dist/blocks-CTB_5Vyj.cjs +12 -0
  12. package/dist/blocks-CTB_5Vyj.cjs.map +1 -0
  13. package/dist/{blocks-BEJW9OM_.js → blocks-Dol85hpH.js} +680 -670
  14. package/dist/blocks-Dol85hpH.js.map +1 -0
  15. package/dist/blocks.cjs +1 -1
  16. package/dist/blocks.js +2 -2
  17. package/dist/comments.cjs +1 -1
  18. package/dist/comments.cjs.map +1 -1
  19. package/dist/comments.js +7 -7
  20. package/dist/comments.js.map +1 -1
  21. package/dist/en-BuzSuuTq.cjs +2 -0
  22. package/dist/en-BuzSuuTq.cjs.map +1 -0
  23. package/dist/{en-CGKXfWma.js → en-uzHzj6eH.js} +10 -1
  24. package/dist/en-uzHzj6eH.js.map +1 -0
  25. package/dist/extensions-B7Rsp_Ft.cjs +58 -0
  26. package/dist/extensions-B7Rsp_Ft.cjs.map +1 -0
  27. package/dist/{extensions-BR5hkAio.js → extensions-D6JcJCwd.js} +735 -457
  28. package/dist/extensions-D6JcJCwd.js.map +1 -0
  29. package/dist/extensions.cjs +1 -1
  30. package/dist/extensions.js +4 -4
  31. package/dist/locales.cjs +1 -1
  32. package/dist/locales.cjs.map +1 -1
  33. package/dist/locales.js +199 -1
  34. package/dist/locales.js.map +1 -1
  35. package/dist/{src-BUXut68d.js → src-Buuo5l7X.js} +924 -851
  36. package/dist/src-Buuo5l7X.js.map +1 -0
  37. package/dist/src-C54Ok9E0.cjs +23 -0
  38. package/dist/src-C54Ok9E0.cjs.map +1 -0
  39. package/dist/style.css +1 -1
  40. package/dist/webpack-stats.json +1 -1
  41. package/dist/y.cjs +1 -1
  42. package/dist/y.cjs.map +1 -1
  43. package/dist/y.js +245 -242
  44. package/dist/y.js.map +1 -1
  45. package/dist/yjs.cjs +1 -1
  46. package/dist/yjs.cjs.map +1 -1
  47. package/dist/yjs.js +79 -67
  48. package/dist/yjs.js.map +1 -1
  49. package/package.json +17 -18
  50. package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +2505 -763
  51. package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +42 -0
  52. package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +16 -4
  53. package/src/api/exporters/markdown/htmlToMarkdown.ts +45 -10
  54. package/src/api/getBlocksChangedByTransaction.test.ts +211 -0
  55. package/src/api/getBlocksChangedByTransaction.ts +48 -12
  56. package/src/api/getChangedRange.ts +54 -0
  57. package/src/api/nodeConversions/blockToNode.ts +5 -1
  58. package/src/api/nodeConversions/nodeToBlock.ts +3 -0
  59. package/src/api/pmUtil.ts +16 -8
  60. package/src/blocks/Code/CodeBlockOptions.ts +83 -0
  61. package/src/blocks/Code/block.test.ts +1 -1
  62. package/src/blocks/Code/block.ts +29 -281
  63. package/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.ts +120 -0
  64. package/src/blocks/Code/helpers/parse/parsePreCode.ts +45 -0
  65. package/src/blocks/Code/helpers/render/createCodeBlock.ts +98 -0
  66. package/src/blocks/Code/helpers/toExternalHTML/createPreCode.ts +14 -0
  67. package/src/blocks/index.ts +3 -1
  68. package/src/comments/extension.ts +2 -4
  69. package/src/editor/Block.css +273 -2
  70. package/src/editor/BlockNoteEditor.ts +25 -4
  71. package/src/editor/BlockNoteExtension.ts +1 -1
  72. package/src/editor/managers/ExtensionManager/extensions.ts +6 -0
  73. package/src/editor/performance.test.ts +45 -0
  74. package/src/exporter/ExportImage.ts +50 -0
  75. package/src/exporter/Exporter.test.ts +186 -0
  76. package/src/exporter/Exporter.ts +66 -14
  77. package/src/exporter/index.ts +1 -0
  78. package/src/exporter/mapping.ts +4 -1
  79. package/src/extensions/FormattingToolbar/FormattingToolbar.ts +10 -8
  80. package/src/extensions/InlineContentBoundaryEdit/InlineContentBoundaryEdit.ts +109 -0
  81. package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +21 -0
  82. package/src/extensions/PreviousBlockType/PreviousBlockType.ts +5 -3
  83. package/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.ts +192 -0
  84. package/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.ts +142 -0
  85. package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.ts +120 -0
  86. package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.ts +89 -0
  87. package/src/extensions/SyntaxHighlighting/inlineHighlight.test.ts +135 -0
  88. package/src/extensions/SyntaxHighlighting/shiki.ts +116 -0
  89. package/src/extensions/TableHandles/TableHandles.browser.test.ts +305 -0
  90. package/src/extensions/TableHandles/TableHandles.ts +82 -41
  91. package/src/extensions/Versioning/inMemoryVersioning.ts +13 -3
  92. package/src/extensions/index.ts +4 -0
  93. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts +51 -2
  94. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +22 -2
  95. package/src/fonts/inter.css +9 -9
  96. package/src/i18n/locales/ar.ts +9 -0
  97. package/src/i18n/locales/de.ts +9 -0
  98. package/src/i18n/locales/en.ts +9 -0
  99. package/src/i18n/locales/es.ts +9 -0
  100. package/src/i18n/locales/fa.ts +9 -0
  101. package/src/i18n/locales/fr.ts +9 -0
  102. package/src/i18n/locales/he.ts +9 -0
  103. package/src/i18n/locales/hr.ts +9 -0
  104. package/src/i18n/locales/is.ts +9 -0
  105. package/src/i18n/locales/it.ts +9 -0
  106. package/src/i18n/locales/ja.ts +9 -0
  107. package/src/i18n/locales/ko.ts +9 -0
  108. package/src/i18n/locales/nl.ts +9 -0
  109. package/src/i18n/locales/no.ts +9 -0
  110. package/src/i18n/locales/pl.ts +9 -0
  111. package/src/i18n/locales/pt.ts +9 -0
  112. package/src/i18n/locales/ru.ts +9 -0
  113. package/src/i18n/locales/sk.ts +9 -0
  114. package/src/i18n/locales/uk.ts +9 -0
  115. package/src/i18n/locales/uz.ts +9 -0
  116. package/src/i18n/locales/vi.ts +9 -0
  117. package/src/i18n/locales/zh-tw.ts +9 -0
  118. package/src/i18n/locales/zh.ts +9 -0
  119. package/src/index.ts +5 -1
  120. package/src/schema/blocks/createSpec.ts +5 -7
  121. package/src/schema/blocks/types.ts +53 -3
  122. package/src/schema/contentTypePropagation.test.ts +1 -1
  123. package/src/schema/inlineContent/createSpec.test.ts +161 -0
  124. package/src/schema/inlineContent/createSpec.ts +175 -17
  125. package/src/schema/inlineContent/internal.ts +21 -2
  126. package/src/schema/inlineContent/types.ts +35 -5
  127. package/src/schema/nodeViewMutations.test.ts +81 -56
  128. package/src/schema/nodeViewMutations.ts +30 -27
  129. package/src/schema/schema.test.ts +110 -0
  130. package/src/schema/schema.ts +13 -4
  131. package/src/user/UserStore.ts +1 -1
  132. package/src/util/Store.test.ts +132 -0
  133. package/src/util/Store.ts +135 -0
  134. package/src/y/extensions/AttributionExtension.test.ts +18 -9
  135. package/src/y/extensions/Versioning.test.ts +20 -7
  136. package/src/y/versioning/__test__/yhub.test.ts +92 -59
  137. package/src/y/versioning/yhub.ts +35 -29
  138. package/src/yjs/comments/RESTYjsThreadStore.test.ts +85 -0
  139. package/src/yjs/comments/RESTYjsThreadStore.ts +7 -1
  140. package/src/yjs/extensions/ForkYDoc.test.ts +37 -0
  141. package/src/yjs/extensions/ForkYDoc.ts +26 -1
  142. package/src/yjs/extensions/RelativePositionMapping.ts +8 -2
  143. package/src/yjs/extensions/Versioning.test.ts +17 -5
  144. package/types/src/api/getChangedRange.d.ts +14 -0
  145. package/types/src/api/pmUtil.d.ts +7 -7
  146. package/types/src/blocks/Code/CodeBlockOptions.d.ts +61 -0
  147. package/types/src/blocks/Code/block.d.ts +3 -53
  148. package/types/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.d.ts +35 -0
  149. package/types/src/blocks/Code/helpers/parse/parsePreCode.d.ts +8 -0
  150. package/types/src/blocks/Code/helpers/render/createCodeBlock.d.ts +18 -0
  151. package/types/src/blocks/Code/helpers/toExternalHTML/createPreCode.d.ts +5 -0
  152. package/types/src/blocks/index.d.ts +3 -1
  153. package/types/src/comments/extension.d.ts +1 -15
  154. package/types/src/editor/BlockNoteEditor.d.ts +3 -3
  155. package/types/src/editor/BlockNoteExtension.d.ts +1 -1
  156. package/types/src/exporter/ExportImage.d.ts +36 -0
  157. package/types/src/exporter/Exporter.d.ts +30 -0
  158. package/types/src/exporter/Exporter.test.d.ts +1 -0
  159. package/types/src/exporter/index.d.ts +1 -0
  160. package/types/src/exporter/mapping.d.ts +1 -1
  161. package/types/src/extensions/FilePanel/FilePanel.d.ts +1 -1
  162. package/types/src/extensions/FormattingToolbar/FormattingToolbar.d.ts +1 -1
  163. package/types/src/extensions/InlineContentBoundaryEdit/InlineContentBoundaryEdit.d.ts +5 -0
  164. package/types/src/extensions/ShowSelection/ShowSelection.d.ts +1 -5
  165. package/types/src/extensions/SideMenu/SideMenu.d.ts +1 -1
  166. package/types/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.d.ts +45 -0
  167. package/types/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.d.ts +49 -0
  168. package/types/src/extensions/SuggestionMenu/SuggestionMenu.d.ts +1 -11
  169. package/types/src/extensions/SyntaxHighlighting/SyntaxHighlighting.d.ts +44 -0
  170. package/types/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.d.ts +1 -0
  171. package/types/src/extensions/SyntaxHighlighting/inlineHighlight.test.d.ts +1 -0
  172. package/types/src/extensions/SyntaxHighlighting/shiki.d.ts +13 -0
  173. package/types/src/extensions/TableHandles/TableHandles.browser.test.d.ts +1 -0
  174. package/types/src/extensions/TableHandles/TableHandles.d.ts +4 -1
  175. package/types/src/extensions/Versioning/Versioning.d.ts +1 -35
  176. package/types/src/extensions/index.d.ts +4 -0
  177. package/types/src/i18n/locales/en.d.ts +9 -0
  178. package/types/src/i18n/locales/fa.d.ts +9 -0
  179. package/types/src/i18n/locales/sk.d.ts +9 -0
  180. package/types/src/index.d.ts +2 -1
  181. package/types/src/schema/blocks/types.d.ts +36 -3
  182. package/types/src/schema/inlineContent/createSpec.d.ts +35 -3
  183. package/types/src/schema/inlineContent/createSpec.test.d.ts +1 -0
  184. package/types/src/schema/inlineContent/internal.d.ts +3 -2
  185. package/types/src/schema/inlineContent/types.d.ts +22 -3
  186. package/types/src/schema/nodeViewMutations.d.ts +2 -2
  187. package/types/src/schema/schema.test.d.ts +1 -0
  188. package/types/src/user/UserStore.d.ts +1 -1
  189. package/types/src/util/Store.d.ts +45 -0
  190. package/types/src/util/Store.test.d.ts +1 -0
  191. package/types/src/y/extensions/AttributionExtension.d.ts +1 -1
  192. package/types/src/y/extensions/DiffVersioningExtension.d.ts +1 -1
  193. package/types/src/y/extensions/ForkYDoc.d.ts +1 -5
  194. package/types/src/y/extensions/index.d.ts +2 -10
  195. package/types/src/y/versioning/yhub.d.ts +3 -2
  196. package/types/src/yjs/comments/RESTYjsThreadStore.test.d.ts +1 -0
  197. package/types/src/yjs/extensions/ForkYDoc.d.ts +1 -5
  198. package/types/src/yjs/extensions/index.d.ts +1 -5
  199. package/dist/BlockNoteExtension-B_IEJHS8.js +0 -38
  200. package/dist/BlockNoteExtension-B_IEJHS8.js.map +0 -1
  201. package/dist/BlockNoteExtension-M0znTzxP.cjs +0 -2
  202. package/dist/BlockNoteExtension-M0znTzxP.cjs.map +0 -1
  203. package/dist/UserStore-QbbPFj0z.js.map +0 -1
  204. package/dist/blocks-BEJW9OM_.js.map +0 -1
  205. package/dist/blocks-BPmJglFo.cjs +0 -12
  206. package/dist/blocks-BPmJglFo.cjs.map +0 -1
  207. package/dist/en-C5Z4Ag9_.cjs +0 -2
  208. package/dist/en-C5Z4Ag9_.cjs.map +0 -1
  209. package/dist/en-CGKXfWma.js.map +0 -1
  210. package/dist/extensions-AitWbYdJ.cjs +0 -52
  211. package/dist/extensions-AitWbYdJ.cjs.map +0 -1
  212. package/dist/extensions-BR5hkAio.js.map +0 -1
  213. package/dist/src-BHPuOo7W.cjs +0 -21
  214. package/dist/src-BHPuOo7W.cjs.map +0 -1
  215. package/dist/src-BUXut68d.js.map +0 -1
  216. package/src/blocks/Code/shiki.ts +0 -73
  217. package/src/blocks/File/helpers/uploadToTmpFilesDotOrg_DEV_ONLY.ts +0 -20
  218. package/types/src/blocks/Code/shiki.d.ts +0 -4
  219. package/types/src/blocks/File/helpers/uploadToTmpFilesDotOrg_DEV_ONLY.d.ts +0 -6
package/dist/yjs.js CHANGED
@@ -1,5 +1,5 @@
1
- import { An as e, Mt as t, bn as n, yt as r } from "./blocks-BEJW9OM_.js";
2
- import { n as i, t as a } from "./BlockNoteExtension-B_IEJHS8.js";
1
+ import { Cn as e, Ft as t, Nn as n, St as r } from "./blocks-Dol85hpH.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
- } else {
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;
@@ -22,15 +23,17 @@ function w(e, t) {
22
23
  return a.type;
23
24
  }
24
25
  }
25
- function T(e, t) {
26
- return n(e.pmSchema.nodeFromJSON(t));
26
+ function T(t, n) {
27
+ let r = t.pmSchema.nodeFromJSON(n);
28
+ return e(r);
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
- function D(e, t) {
33
- return n(S(t, e.pmSchema));
34
+ function D(t, n) {
35
+ let r = S(n, t.pmSchema);
36
+ return e(r);
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: t }) => (t.on("create", () => {
47
- let n = t.pmSchema, r, i = n.nodes.doc.createAndFill;
48
- n.nodes.doc.createAndFill = ((...e) => {
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 t = i.apply(n.nodes.doc, e), a = JSON.parse(JSON.stringify(t.toJSON()));
51
- return a.content[0].content[0].attrs.id = "initialBlockId", r = s.fromJSON(n, a), r;
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 = n.node;
54
- n.node = function(t, n, r, i) {
55
- let o = typeof t == "string" ? this.nodes[t] : t;
56
- return o && e(this, o) && Array.isArray(r) && (r = r.map((e) => e?.isText && e.marks.length ? e.mark(o.allowedMarks(e.marks)) : e)), a.call(this, t, n, r, i);
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
- })), L = a(({ editor: e, options: t }) => {
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
- }), R = a(({ editor: e }) => ({
204
+ }), z = a(({ editor: e }) => ({
193
205
  key: "yPositionMapping",
194
206
  mapPosition: (t, n = "left") => {
195
207
  let r = b.getState(e.prosemirrorState);
@@ -202,19 +214,19 @@ 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(t.doc, t.binding.type, i, t.binding.mapping);
206
- if (r === null) throw Error("Position not found, cannot track positions");
207
- return r + (n === "right" ? -1 : 1);
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
- })), z = (e, t) => {
222
+ })), B = (e, t) => {
211
223
  t(e), e.forEach((e) => {
212
- e instanceof C.XmlElement && z(e, t);
224
+ e instanceof C.XmlElement && B(e, t);
213
225
  });
214
- }, B = [(e, t) => {
226
+ }, V = [(e, t) => {
215
227
  let n = /* @__PURE__ */ new Map();
216
228
  return e.forEach((e) => {
217
- e instanceof C.XmlElement && z(e, (e) => {
229
+ e instanceof C.XmlElement && B(e, (e) => {
218
230
  if (e.nodeName === "blockContainer" && e.hasAttribute("id")) {
219
231
  let t = e.getAttribute("textColor"), i = e.getAttribute("backgroundColor"), a = {
220
232
  textColor: t === r.textColor.default ? void 0 : t,
@@ -223,7 +235,7 @@ var P = a(({ options: e }) => {
223
235
  (a.textColor || a.backgroundColor) && n.set(e.getAttribute("id"), a);
224
236
  }
225
237
  });
226
- }), n.size === 0 ? !1 : (t.doc.descendants((e, r) => {
238
+ }), n.size !== 0 && (t.doc.descendants((e, r) => {
227
239
  if (e.type.name === "blockContainer" && n.has(e.attrs.id)) {
228
240
  let i = t.doc.nodeAt(r + 1);
229
241
  if (!i) throw Error("No element found");
@@ -233,16 +245,16 @@ var P = a(({ options: e }) => {
233
245
  });
234
246
  }
235
247
  }), !0);
236
- }], V = a(({ options: e }) => {
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: new u("schemaMigration"),
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 B) t(e.fragment, a);
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 H(e, t) {
265
+ function U(e, t) {
254
266
  let { fragment: n } = t;
255
267
  function r() {
256
- let t = e.getExtension(L);
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 U = a(({ options: e }) => ({
293
+ var W = a(({ options: e }) => ({
282
294
  key: "collaboration",
283
295
  blockNoteExtensions: [
284
296
  j(),
285
- L(e),
286
- R(),
287
- V(e),
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 W(e) {
305
+ function G(e) {
294
306
  return {
295
307
  ...e,
296
- extensions: [...e.extensions ?? [], U(e.collaboration)],
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 G(e) {
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 K(e) {
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) => G(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;
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 q(e) {
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 J(e) {
325
- return [...e.values()].map((e) => q(e)).reduce((e, t) => {
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 Y(e) {
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: J(e.get("reactionsByUser")),
354
+ reactions: Y(e.get("reactionsByUser")),
343
355
  metadata: e.get("metadata"),
344
356
  body: e.get("body")
345
357
  };
346
358
  }
347
- function X(e) {
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) => Y(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 Z = class extends o {
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 X(t);
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, X(t));
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
- }, Q = class extends Z {
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
- }, te = class extends Z {
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, K(r)), r;
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(X(t))) throw Error("Not authorized");
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([G(r)]), t.set("updatedAt", (/* @__PURE__ */ new Date()).getTime()), r;
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(Y(r))) throw Error("Not authorized");
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(Y(r))) throw Error("Not authorized");
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(X(this.threadsYMap.get(e.threadId)))) throw Error("Not authorized");
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(X(t))) throw Error("Not authorized");
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(X(t))) throw Error("Not authorized");
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(Y(r), e.emoji)) throw Error("Not authorized");
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(Y(r), e.emoji)) throw Error("Not authorized");
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 { U as CollaborationExtension, L as ForkYDocExtension, Q as RESTYjsThreadStore, R as RelativePositionMappingExtension, V as SchemaMigration, P as YCursorExtension, F as YSyncExtension, I as YUndoExtension, te as YjsThreadStore, Z as YjsThreadStoreBase, E as _blocksToProsemirrorNode, T as _prosemirrorJSONToBlocks, A as blocksToYDoc, O as blocksToYXmlFragment, H as createYjsVersioningAdapter, w as findTypeInOtherYdoc, W as withCollaboration, k as yDocToBlocks, D as yXmlFragmentToBlocks };
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