@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/y.js CHANGED
@@ -1,31 +1,31 @@
1
- import { Mt as e, O as t, bn as n } from "./blocks-BEJW9OM_.js";
2
- import { i as r, n as i, t as a } from "./BlockNoteExtension-B_IEJHS8.js";
3
- import { _ as o, h as s, v as c, y as l } from "./src-BUXut68d.js";
4
- import { a as u, i as d, o as f } from "./extensions-BR5hkAio.js";
5
- import { n as p } from "./UserStore-QbbPFj0z.js";
1
+ import { Cn as e, D as t, Ft as n } from "./blocks-Dol85hpH.js";
2
+ import { a as r, n as i, t as a } from "./BlockNoteExtension-CbvDA0F7.js";
3
+ import { _ as o, b as s, x as c, y as l } from "./src-Buuo5l7X.js";
4
+ import { a as u, i as d, o as f } from "./extensions-D6JcJCwd.js";
5
+ import { n as p } from "./UserStore-C4TzkGEn.js";
6
6
  import { t as m } from "./ThreadStore-et9wB5Xt.js";
7
- import { Mark as h, getChangedRanges as 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 }) => {
16
- let i = t?.editor, a = e === "insert" ? "ins" : e === "delete" ? "del" : r ? "span" : "div", s = document.createElement(a);
17
- Object.assign(s.dataset, {
15
+ var T = (e, t) => e === void 0 ? void 0 : typeof e == "string" ? e : e[t], E = (e, t) => ({ mark: n, inline: r }) => {
16
+ let i = t?.editor, a = e === "insert" ? "ins" : e === "delete" ? "del" : r ? "span" : "div", o = document.createElement(a);
17
+ Object.assign(o.dataset, {
18
18
  userIds: JSON.stringify(n.attrs.userIds),
19
19
  inline: String(r)
20
- }), e === "modification" && (s.dataset.type = "modification", s.dataset.format = JSON.stringify(n.attrs.format));
21
- let u = D(t?.getAttributionMarkClassName?.({
20
+ }), e === "modification" && (o.dataset.type = "modification", o.dataset.format = JSON.stringify(n.attrs.format));
21
+ let u = T(t?.getAttributionMarkClassName?.({
22
22
  contentType: r ? "inline-content" : "block",
23
23
  modificationType: e === "modification" ? "format" : e
24
- }), "content"), d = (n.attrs.userIds ?? [])[0], f = d ? o(d) : c[0];
25
- if (u) s.style.cssText = "display: contents";
24
+ }), "content"), d = (n.attrs.userIds ?? [])[0], f = d ? l(d) : s[0];
25
+ if (u) o.style.cssText = "display: contents";
26
26
  else {
27
- let e = d ? `var(${l(d).light}, ${f.light})` : f.light, t = d ? `var(${l(d).dark}, ${f.dark})` : f.dark;
28
- s.style.cssText = `display: contents; --user-color-light: ${e}; --user-color-dark: ${t}`;
27
+ let e = d ? `var(${c(d).light}, ${f.light})` : f.light, t = d ? `var(${c(d).dark}, ${f.dark})` : f.dark;
28
+ o.style.cssText = `display: contents; --user-color-light: ${e}; --user-color-dark: ${t}`;
29
29
  }
30
30
  let p = document.createElement("span");
31
31
  if (r) p.className = u ?? (e === "delete" ? "bn-suggestion-mark bn-suggestion-mark--delete" : "bn-suggestion-mark");
@@ -33,11 +33,11 @@ var D = (e, t) => e === void 0 ? void 0 : typeof e == "string" ? e : e[t], O = (
33
33
  let e = i?.dictionary.suggestion_changes.deleted;
34
34
  e && p.style.setProperty("--deleted-label", JSON.stringify(e));
35
35
  }
36
- return s.appendChild(p), {
37
- dom: s,
36
+ return o.appendChild(p), {
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,104 +133,104 @@ var D = (e, t) => e === void 0 ? void 0 : typeof e == "string" ? e : e[t], O = (
133
133
  key: "attribution",
134
134
  userStore: t,
135
135
  store: r,
136
- prosemirrorPlugins: [new 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)
141
141
  }
142
142
  })],
143
143
  mount({ dom: e, root: i, signal: a }) {
144
- let o = () => {
144
+ let s = () => {
145
145
  for (let [n, r] of t.store.state) {
146
- let { light: t, dark: i } = l(n);
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
- }, c, 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: s(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")
165
165
  };
166
166
  }, p = () => {
167
- c && (c = void 0, r.setState(void 0));
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;
174
174
  }
175
175
  };
176
176
  i.addEventListener("mouseover", (e) => {
177
- let n = m(e.target instanceof Element ? e.target : null);
178
- if (!n) {
177
+ let n = e.target instanceof Element ? e.target : null, i = m(n);
178
+ if (!i) {
179
179
  p();
180
180
  return;
181
181
  }
182
- let i = d(n), a = n, o = n.parentElement;
183
- for (; o;) {
184
- let e = o.closest(M);
182
+ let a = d(i), o = i, s = i.parentElement;
183
+ for (; s;) {
184
+ let e = s.closest(j);
185
185
  if (!e) break;
186
186
  let t = d(e);
187
- if (t === i) a = e;
187
+ if (t === a) o = e;
188
188
  else if (t) break;
189
- o = e.parentElement;
189
+ s = e.parentElement;
190
190
  }
191
- if (c === a) return;
192
- c = a, r.setState(f(a));
193
- let s = N(a.dataset.userIds);
194
- s.length > 0 && t.loadUsers(s).then(() => {
195
- c === a && r.setState(f(a));
191
+ if (l === o) return;
192
+ l = o, r.setState(f(o));
193
+ let c = M(o.dataset.userIds);
194
+ c.length > 0 && t.loadUsers(c).then(() => {
195
+ l === o && r.setState(f(o));
196
196
  });
197
- }, { signal: a }), a.addEventListener("abort", p), o();
198
- let h = t.store.subscribe(o);
197
+ }, { signal: a }), a.addEventListener("abort", p), s();
198
+ let h = t.store.subscribe(s);
199
199
  a.addEventListener("abort", h);
200
200
  },
201
- blockNoteExtensions: [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,92 +259,95 @@ 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
- if (e.provider && "synced" in e.provider && typeof e.provider.synced == "boolean") if (e.provider.synced) n();
286
- else if ("on" in e.provider && typeof e.provider.on == "function") e.provider.on("synced", (e) => {
287
- e && n();
288
- });
289
- else throw Error("YSyncExtension: provider must have a 'synced' boolean or an 'on' method to listen for 'sync'");
290
- else n();
285
+ if (e.provider && "synced" in e.provider && typeof e.provider.synced == "boolean") {
286
+ if (e.provider.synced) n();
287
+ else if ("on" in e.provider && typeof e.provider.on == "function") e.provider.on("synced", (e) => {
288
+ e && n();
289
+ });
290
+ else throw Error("YSyncExtension: provider must have a 'synced' boolean or an 'on' method to listen for 'sync'");
291
+ } else n();
291
292
  },
292
- prosemirrorPlugins: [he({
293
+ prosemirrorPlugins: [_e({
293
294
  suggestionDoc: e.suggestionDoc,
294
- mapAttributionToMark: H,
295
- customCompare: V
295
+ mapAttributionToMark: V,
296
+ customCompare: B
296
297
  })],
297
298
  runsBefore: ["default"]
298
299
  }));
299
300
  //#endregion
300
301
  //#region src/y/utils.ts
301
- function W(e, t) {
302
+ function U(e, t) {
302
303
  let n = e.doc;
303
304
  if (!n) throw Error("type does not have a ydoc");
304
305
  if (e._item === null) {
305
306
  let r = Array.from(n.share.keys()).find((t) => n.share.get(t) === e);
306
307
  if (r == null) throw Error("type does not exist in other ydoc");
307
308
  return t.get(r, e.constructor);
308
- } else {
309
- let n = e._item, r = t.store.clients.get(n.id.client) ?? [], i = r[w.findIndexSS(r, n.id.clock)];
309
+ }
310
+ {
311
+ let n = e._item, r = t.store.clients.get(n.id.client) ?? [], i = r[S.findIndexSS(r, n.id.clock)];
310
312
  if (!i) throw Error("type does not exist in other ydoc");
311
313
  let a = i.content;
312
314
  if (!a) throw Error("type does not exist in other ydoc");
313
315
  return a.type;
314
316
  }
315
317
  }
316
- function Se(e, t) {
317
- return n(e.pmSchema.nodeFromJSON(t));
318
- }
319
- function G(t, n) {
320
- let r = n.map((n) => e(n, t.pmSchema));
321
- return t.pmSchema.topNodeType.create(null, t.pmSchema.nodes.blockGroup.create(null, r));
318
+ function Ce(t, n) {
319
+ let r = t.pmSchema.nodeFromJSON(n);
320
+ return e(r);
322
321
  }
323
- function K(e, t) {
324
- let r = ce(t.toDeltaDeep(), e.pmSchema, null);
325
- 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));
326
325
  }
327
- function Ce(e, t, n) {
328
- 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);
329
329
  }
330
- function we(e, t, n = "prosemirror") {
331
- 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);
332
332
  }
333
333
  function Te(e, t, n = "prosemirror") {
334
- 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();
335
338
  return i.get(n).applyDelta(r), i;
336
339
  }
337
- function q(e, t) {
338
- let n = x(e), r = x(t);
339
- 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 });
340
343
  }
341
- function J({ tr: e, fragment: t, renderer: n }) {
342
- let r = se(t.toDeltaDeep({ renderer: n }), H), i = x(e.doc, void 0, !0);
343
- return le(e, C.diff(i.done(), r.done(), { compare: V }), 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);
344
347
  }
345
348
  //#endregion
346
349
  //#region src/y/extensions/Suggestions.ts
347
- var Ee = a(({ editor: e, options: t }) => {
350
+ var De = a(({ editor: e, options: t }) => {
348
351
  let n = t.suggestionDoc;
349
352
  if (!n) throw Error("Suggestion doc not found");
350
353
  let r = p(t.resolveUsers);
@@ -360,7 +363,7 @@ var Ee = a(({ editor: e, options: t }) => {
360
363
  return e.transact((r) => {
361
364
  let i = r.doc.resolve(t), a = i.marks().find((e) => e.type.name === n);
362
365
  if (!a) return;
363
- let o = _(i, a.type);
366
+ let o = te(i, a.type);
364
367
  if (o) return {
365
368
  range: o,
366
369
  mark: a,
@@ -368,7 +371,7 @@ var Ee = a(({ editor: e, options: t }) => {
368
371
  return r.doc.textBetween(o.from, o.to);
369
372
  },
370
373
  get position() {
371
- return ee(e.prosemirrorView, o.from, o.to).toJSON();
374
+ return ne(e.prosemirrorView, o.from, o.to).toJSON();
372
375
  }
373
376
  };
374
377
  });
@@ -384,68 +387,68 @@ var Ee = a(({ editor: e, options: t }) => {
384
387
  userStore: r,
385
388
  runsBefore: ["ySync"],
386
389
  viewSuggestions: () => {
387
- t.renderer && (t.renderer.suggestionMode = !1), e.exec(y({
388
- ytype: W(t.fragment, n),
390
+ t.renderer && (t.renderer.suggestionMode = !1), e.exec(_({
391
+ ytype: U(t.fragment, n),
389
392
  renderer: t.renderer
390
393
  }));
391
394
  },
392
395
  enableSuggestions: () => {
393
- t.renderer && (t.renderer.suggestionMode = !0), e.exec(y({
394
- ytype: W(t.fragment, n),
396
+ t.renderer && (t.renderer.suggestionMode = !0), e.exec(_({
397
+ ytype: U(t.fragment, n),
395
398
  renderer: t.renderer
396
399
  }));
397
400
  },
398
401
  disableSuggestions: () => {
399
- e.exec(y({
402
+ e.exec(_({
400
403
  ytype: t.fragment,
401
404
  renderer: null
402
405
  }));
403
406
  },
404
- applyAllSuggestions: () => e.exec(ie()),
405
- applySuggestion: (t, n) => e.exec(ae(t, n)),
406
- revertSuggestion: (t, n) => e.exec(pe(t, n)),
407
- 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()),
408
411
  getSuggestionElementAtPos: i,
409
412
  getMarkAtPos: a,
410
413
  getSuggestionAtSelection: o,
411
414
  getSuggestionAtCoords: (t) => e.transact(() => {
412
415
  let n = e.prosemirrorView.posAtCoords(t);
413
- if (!(n === null || n?.inside === -1)) return a(n.pos, "y-attributed-insert") || a(n.pos, "y-attributed-delete") || a(n.pos, "y-attributed-format");
416
+ if (n !== null && n?.inside !== -1) return a(n.pos, "y-attributed-insert") || a(n.pos, "y-attributed-delete") || a(n.pos, "y-attributed-format");
414
417
  }),
415
418
  checkUnresolvedSuggestions: () => {
416
419
  let t = !1;
417
- return e.prosemirrorState.doc.descendants((e) => t ? !1 : (t = e.marks.findIndex((e) => e.type.name === "y-attributed-insert" || e.type.name === "y-attributed-delete" || e.type.name === "y-attributed-format") !== -1, !0)), t;
420
+ return e.prosemirrorState.doc.descendants((e) => !t && (t = e.marks.findIndex((e) => e.type.name === "y-attributed-insert" || e.type.name === "y-attributed-delete" || e.type.name === "y-attributed-format") !== -1, !0)), t;
418
421
  }
419
422
  };
420
423
  });
421
424
  //#endregion
422
425
  //#region src/y/extensions/Versioning.ts
423
- function De(e) {
424
- e.exec(ue), e.removeBlocks(e.document);
426
+ function Oe(e) {
427
+ e.exec(fe), e.removeBlocks(e.document);
425
428
  }
426
- function Oe(e, t) {
429
+ function ke(e, t) {
427
430
  return {
428
431
  getCurrentDocument: () => t,
429
- serializeCurrentContent: () => w.encodeStateAsUpdateV2(t.doc),
432
+ serializeCurrentContent: () => S.encodeStateAsUpdateV2(t.doc),
430
433
  preview: {
431
434
  enterPreview: (n, r, i) => {
432
435
  let a;
433
436
  if (r) {
434
- let e = new w.Doc({ isSuggestionDoc: !0 });
435
- 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) };
436
439
  }
437
- let o = new w.Doc();
438
- w.applyUpdateV2(o, n), De(e), e.exec((e, n) => {
439
- let r = J({
440
+ let o = new S.Doc();
441
+ S.applyUpdateV2(o, n), Oe(e), e.exec((e, n) => {
442
+ let r = q({
440
443
  tr: e.tr,
441
- fragment: W(t, o),
442
- 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
443
446
  });
444
447
  return n && n(r), !0;
445
448
  });
446
449
  },
447
450
  exitPreview: () => {
448
- De(e), e.exec(y({ ytype: t }));
451
+ Oe(e), e.exec(_({ ytype: t }));
449
452
  },
450
453
  applyRestore: (e) => {}
451
454
  }
@@ -453,7 +456,7 @@ function Oe(e, t) {
453
456
  }
454
457
  //#endregion
455
458
  //#region src/y/extensions/YCursorPlugin.ts
456
- function ke(e) {
459
+ function Ae(e) {
457
460
  let t = e.charAt(0) === "#" ? e.substring(1, 7) : e, n = parseInt(t.substring(0, 2), 16), r = parseInt(t.substring(2, 4), 16), i = parseInt(t.substring(4, 6), 16), a = [
458
461
  n / 255,
459
462
  r / 255,
@@ -461,15 +464,15 @@ function ke(e) {
461
464
  ].map((e) => e <= .03928 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4);
462
465
  return .2126 * a[0] + .7152 * a[1] + .0722 * a[2] <= .179;
463
466
  }
464
- function Ae(e) {
467
+ function je(e) {
465
468
  let t = document.createElement("span");
466
469
  t.classList.add("bn-collaboration-cursor__base");
467
470
  let n = document.createElement("span");
468
- n.setAttribute("contentedEditable", "false"), n.classList.add("bn-collaboration-cursor__caret"), n.setAttribute("style", `background-color: ${e.color}; color: ${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"}`);
469
472
  let r = document.createElement("span");
470
- 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;
471
474
  }
472
- var je = a(({ options: e }) => {
475
+ var Me = a(({ options: e }) => {
473
476
  let t = /* @__PURE__ */ new Map(), n = e.provider && "awareness" in e.provider && typeof e.provider.awareness == "object" ? e.provider.awareness : void 0;
474
477
  return n && ("setLocalStateField" in n && typeof n.setLocalStateField == "function" && n.setLocalStateField("user", e.user), "on" in n && typeof n.on == "function" && e.showCursorLabels !== "always" && n.on("change", ({ updated: e }) => {
475
478
  for (let n of e) {
@@ -485,12 +488,12 @@ var je = a(({ options: e }) => {
485
488
  }
486
489
  })), {
487
490
  key: "yCursor",
488
- prosemirrorPlugins: [n ? ge(n, {
489
- selectionBuilder: oe,
491
+ prosemirrorPlugins: [n ? ve(n, {
492
+ selectionBuilder: ce,
490
493
  cursorBuilder(n, r) {
491
494
  let i = t.get(r);
492
495
  if (!i) {
493
- let a = (e.renderCursor ?? Ae)(n);
496
+ let a = (e.renderCursor ?? je)(n);
494
497
  e.showCursorLabels !== "always" && (a.addEventListener("mouseenter", () => {
495
498
  let e = t.get(r);
496
499
  e.element.setAttribute("data-active", ""), e.hideTimeout && (clearTimeout(e.hideTimeout), t.set(r, {
@@ -522,19 +525,19 @@ var je = a(({ options: e }) => {
522
525
  if (e) return e.user;
523
526
  }
524
527
  };
525
- }), Me = "version:", Ne = (e) => Me + e, Pe = "This version", Fe = "#4363d8";
526
- function Ie(e, t) {
527
- 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();
528
531
  return e.on("beforeObserverCalls", (e) => {
529
- 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)]));
530
533
  }), n;
531
534
  }
532
- var Le = a(({ options: e, editor: t }) => {
533
- let n = e?.color ?? Fe;
535
+ var Re = a(({ options: e, editor: t }) => {
536
+ let n = e?.color ?? Ie;
534
537
  return {
535
538
  key: "diffVersioning",
536
- blockNoteExtensions: [I({
537
- 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) => ({
538
541
  id: e,
539
542
  username: e.slice(8),
540
543
  avatarUrl: "",
@@ -542,22 +545,22 @@ var Le = a(({ options: e, editor: t }) => {
542
545
  })),
543
546
  getAttributionMarkClassName: e?.getAttributionMarkClassName
544
547
  })],
545
- renderDiff: (e, n, r = Pe) => {
546
- let i = Ne(r);
548
+ renderDiff: (e, n, r = Fe) => {
549
+ let i = Pe(r);
547
550
  if (!t.pmSchema.marks["y-attributed-insert"]) throw Error("DiffVersioningExtension: the y-attributed-* marks are missing from the schema. This should not happen — the extension registers them via AttributionExtension.");
548
- let a = 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");
549
552
  s.transact(() => {
550
- c.applyDelta(b(a));
553
+ c.applyDelta(v(a));
551
554
  });
552
- let l = new w.Doc({ gc: !1 });
553
- w.applyUpdateV2(l, w.encodeStateAsUpdateV2(s));
554
- 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);
555
558
  l.transact(() => {
556
559
  u.applyDelta(f);
557
560
  }, i);
558
- let p = w.createDiffRenderer(s, l, { attrs: d });
561
+ let p = S.createDiffRenderer(s, l, { attrs: d });
559
562
  t.replaceBlocks(t.document, []), t.exec((e, t) => {
560
- let n = J({
563
+ let n = q({
561
564
  tr: e.tr,
562
565
  fragment: u,
563
566
  renderer: p
@@ -569,7 +572,7 @@ var Le = a(({ options: e, editor: t }) => {
569
572
  t.replaceBlocks(t.document, []), t.replaceBlocks(t.document, e);
570
573
  }
571
574
  };
572
- }), Re = a(({ editor: e, options: t }) => {
575
+ }), ze = a(({ editor: e, options: t }) => {
573
576
  let n = p(t.resolveUsers), r = {
574
577
  ...t,
575
578
  resolveUsers: n
@@ -578,26 +581,26 @@ var Le = a(({ options: e, editor: t }) => {
578
581
  key: "collaboration",
579
582
  userStore: n,
580
583
  blockNoteExtensions: [
581
- t.suggestionDoc ? Ee(r) : null,
582
- L(),
583
- U(r),
584
- je(t),
584
+ t.suggestionDoc ? De(r) : null,
585
+ I(),
586
+ H(r),
587
+ Me(t),
585
588
  t.versioningEndpoints ? u({
586
- ...Oe(e, t.fragment),
589
+ ...ke(e, t.fragment),
587
590
  endpoints: t.versioningEndpoints,
588
591
  resolveUsers: n
589
592
  }) : null,
590
- I({
593
+ F({
591
594
  resolveUsers: n,
592
595
  getAttributionMarkClassName: t.getAttributionMarkClassName
593
596
  })
594
597
  ].filter((e) => e !== null)
595
598
  };
596
599
  });
597
- function ze(e) {
600
+ function Be(e) {
598
601
  return e.initialContent && console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider"), {
599
602
  ...e,
600
- extensions: [...e.extensions ?? [], Re(e.collaboration)],
603
+ extensions: [...e.extensions ?? [], ze(e.collaboration)],
601
604
  disableExtensions: ["history", ...e.disableExtensions ?? []],
602
605
  initialContent: [{
603
606
  type: "paragraph",
@@ -607,16 +610,16 @@ function ze(e) {
607
610
  }
608
611
  //#endregion
609
612
  //#region src/y/comments/yjsHelpers.ts
610
- function Be(e) {
611
- let t = new w.Type();
613
+ function J(e) {
614
+ let t = new S.Type();
612
615
  if (t.setAttr("id", e.id), t.setAttr("userId", e.userId), t.setAttr("createdAt", e.createdAt.getTime()), t.setAttr("updatedAt", e.updatedAt.getTime()), e.deletedAt ? (t.setAttr("deletedAt", e.deletedAt.getTime()), t.setAttr("body", void 0)) : t.setAttr("body", e.body), e.reactions.length > 0) throw Error("Reactions should be empty in commentToYType");
613
- return t.setAttr("reactionsByUser", new w.Type()), t.setAttr("metadata", e.metadata), t;
616
+ return t.setAttr("reactionsByUser", new S.Type()), t.setAttr("metadata", e.metadata), t;
614
617
  }
615
618
  function Ve(e) {
616
- let t = new w.Type();
619
+ let t = new S.Type();
617
620
  t.setAttr("id", e.id), t.setAttr("createdAt", e.createdAt.getTime()), t.setAttr("updatedAt", e.updatedAt.getTime());
618
- let n = new w.Type();
619
- 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;
620
623
  }
621
624
  function He(e) {
622
625
  return {
@@ -676,7 +679,7 @@ var Z = class extends m {
676
679
  getThreads() {
677
680
  let e = /* @__PURE__ */ new Map();
678
681
  return this.threadsYType.forEachAttr((t, n) => {
679
- t instanceof w.Type && e.set(String(n), X(t));
682
+ t instanceof S.Type && e.set(String(n), X(t));
680
683
  }), e;
681
684
  }
682
685
  subscribe(e) {
@@ -740,7 +743,7 @@ var Z = class extends m {
740
743
  if (!this.auth.canCreateThread()) throw Error("Not authorized");
741
744
  let t = /* @__PURE__ */ new Date(), n = {
742
745
  type: "comment",
743
- id: v(),
746
+ id: g(),
744
747
  userId: this.userId,
745
748
  createdAt: t,
746
749
  updatedAt: t,
@@ -749,7 +752,7 @@ var Z = class extends m {
749
752
  body: e.initialComment.body
750
753
  }, r = {
751
754
  type: "thread",
752
- id: v(),
755
+ id: g(),
753
756
  createdAt: t,
754
757
  updatedAt: t,
755
758
  comments: [n],
@@ -765,7 +768,7 @@ var Z = class extends m {
765
768
  if (!this.auth.canAddComment(X(t))) throw Error("Not authorized");
766
769
  let n = /* @__PURE__ */ new Date(), r = {
767
770
  type: "comment",
768
- id: v(),
771
+ id: g(),
769
772
  userId: this.userId,
770
773
  createdAt: n,
771
774
  updatedAt: n,
@@ -774,7 +777,7 @@ var Z = class extends m {
774
777
  metadata: e.comment.metadata,
775
778
  body: e.comment.body
776
779
  };
777
- return t.getAttr("comments").push([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;
778
781
  });
779
782
  updateComment = this.transact((e) => {
780
783
  let t = this.threadsYType.getAttr(e.threadId);
@@ -820,7 +823,7 @@ var Z = class extends m {
820
823
  if (!this.auth.canAddReaction(Y(i), e.emoji)) throw Error("Not authorized");
821
824
  let a = /* @__PURE__ */ new Date(), o = `${this.userId}-${e.emoji}`, s = i.getAttr("reactionsByUser");
822
825
  if (!s.hasAttr(o)) {
823
- let t = new w.Type();
826
+ let t = new S.Type();
824
827
  t.setAttr("emoji", e.emoji), t.setAttr("createdAt", a.getTime()), t.setAttr("userId", this.userId), s.setAttr(o, t);
825
828
  }
826
829
  });
@@ -876,9 +879,9 @@ async function $(e, t, n) {
876
879
  return r.arrayBuffer();
877
880
  }
878
881
  function Ye(e) {
879
- let { baseUrl: t, org: n, docId: r, headers: i = {}, activityLimit: a = 50, group: o } = e, s = `${t}/activity/${n}/${r}`, c = `${t}/changeset/${n}/${r}`, l = `${t}/rollback/${n}/${r}`;
880
- return (u) => {
881
- 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 () => {
882
885
  let e = new URLSearchParams({
883
886
  order: "desc",
884
887
  limit: "1",
@@ -888,7 +891,7 @@ function Ye(e) {
888
891
  limit: "1",
889
892
  customAttributions: "true",
890
893
  withCustomAttributions: "type:version"
891
- }), [n, r] = await Promise.all([$(`${s}?${e}`, i), $(`${s}?${t}`, i)]), a = 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];
892
895
  if (!a || a.to <= (o?.to ?? 0)) return;
893
896
  let c = a.by?.split(",").map((e) => e.trim()).filter(Boolean) ?? [];
894
897
  return {
@@ -897,93 +900,93 @@ function Ye(e) {
897
900
  updatedAt: a.to,
898
901
  by: c.length > 0 ? c : void 0
899
902
  };
900
- }, h = async (e, a, o) => {
903
+ }, p = async (e, t, n) => {
901
904
  if (!e.doc) throw Error("Cannot patch document: the Y.Type is not attached to a Y.Doc.");
902
- let s = new w.Doc();
903
- s.get("__bn_version_markers", "XmlFragment").insert(0, ["v"]);
904
- let c = {
905
- update: w.encodeStateAsUpdate(s),
906
- 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
907
910
  };
908
- await $(`${t}/ydoc/${n}/${r}${o ? `?userid=${o}` : ""}`, i, {
911
+ n && (a.by = n), await $(u, i, {
909
912
  method: "PATCH",
910
- body: E(c)
913
+ body: w(a)
911
914
  });
912
- }, g = async (e, t) => {
913
- let n = String(te()), r = Date.now();
914
- t?.name && p()?.setAttr(n, t.name);
915
- 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 = [{
916
919
  k: "type",
917
920
  v: "version"
918
921
  }, {
919
922
  k: "id",
920
- v: n
923
+ v: i
921
924
  }];
922
- t?.name && i.push({
925
+ r?.name && o.push({
923
926
  k: "name",
924
- v: t.name
927
+ v: r.name
925
928
  });
926
- let a = u.getExtension("yCursor")?.getUser();
927
- return await h(e, i, a?.id), {
928
- id: n,
929
- name: t?.name,
930
- createdAt: r,
931
- updatedAt: r,
932
- 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
933
936
  };
934
- }, _ = async (e) => {
935
- let t = await $(`${c}?${new URLSearchParams({
937
+ }, h = async (e) => {
938
+ let t = new URLSearchParams({
936
939
  ydoc: "true",
937
940
  to: String(e)
938
- })}`, i), n = T(new Uint8Array(t));
939
- if (!n.nextDoc) throw Error(`YHub returned no document state at timestamp ${e}.`);
940
- return w.convertUpdateFormatV1ToV2(n.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);
941
944
  };
942
945
  return {
943
946
  list: async () => {
944
- 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({
945
948
  order: "desc",
946
949
  limit: String(a),
947
950
  customAttributions: "true"
948
951
  });
949
- 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));
950
- let l = await $(`${s}?${c}`, i), u = f(T(new Uint8Array(l)).map((e, t) => Je(e, t)).filter((e) => e !== void 0).map((e) => {
951
- 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;
952
955
  return {
953
956
  ...e,
954
- name: n
957
+ name: r
955
958
  };
956
- })), d = await m();
957
- return d ? [d, ...u] : u;
959
+ })), h = await r();
960
+ return h ? [h, ...m] : m;
958
961
  },
959
- create: g,
960
- getContent: async (e) => _(e.createdAt),
962
+ create: m,
963
+ getContent: async (e) => h(e.createdAt),
961
964
  getAttributions: async (e, t) => {
962
- let n = e.createdAt, r = t === void 0 ? 0 : t.createdAt, a = await $(`${c}?${new URLSearchParams({
965
+ let n = e.createdAt, r = t === void 0 ? 0 : t.createdAt, a = new URLSearchParams({
963
966
  from: String(r),
964
967
  to: String(n),
965
968
  attributions: "true"
966
- })}`, i), o = T(new Uint8Array(a));
967
- if (!o.attributions) throw Error(`YHub returned no attributions for snapshot ${String(e.id)}.`);
968
- return w.decodeContentMap(o.attributions);
969
+ }), o = await $(`${c}?${a}`, i), s = C(new Uint8Array(o));
970
+ if (!s.attributions) throw Error(`YHub returned no attributions for snapshot ${String(e.id)}.`);
971
+ return S.decodeContentMap(s.attributions);
969
972
  },
970
973
  restore: async (e, t) => {
971
- let n = t.createdAt, r = await _(n);
972
- return await $(`${l}?from=${n}`, i, {
974
+ let n = t.createdAt, r = await h(n);
975
+ return await $(l, i, {
973
976
  method: "POST",
974
- body: E({ from: n })
977
+ body: w({ from: n })
975
978
  }), r;
976
979
  },
977
980
  rename: async (e, t) => {
978
981
  if (typeof e.id != "string") return;
979
- let n = p();
980
- if (!n) throw Error("Cannot rename version: no live collaboration document is available.");
981
- 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);
982
985
  }
983
986
  };
984
987
  };
985
988
  }
986
989
  //#endregion
987
- 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 };
988
991
 
989
992
  //# sourceMappingURL=y.js.map