@blocknote/core 0.56.0 → 0.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (733) hide show
  1. package/NOTICE.txt +101 -0
  2. package/dist/BlockNoteExtension-U58cXw1g.js +64 -0
  3. package/dist/ThreadStore-CSEwCO0O.js +8 -0
  4. package/dist/{UserStore-OZJP3K8T.js → UserStore-BFv6NXA-.js} +3 -7
  5. package/dist/ar-DPJDxCQI.js +3 -0
  6. package/dist/blocknote.js +8 -6
  7. package/dist/blocks-BUX9dXi9.js +2063 -0
  8. package/dist/blocks.js +3 -2
  9. package/dist/comments.js +8 -9
  10. package/dist/de-CakHBokE.js +3 -0
  11. package/dist/emoji-data.js +102 -0
  12. package/dist/en-BGdzE27X.js +3 -0
  13. package/dist/{en-Ch-vvt5e.js → en-Ne9rlj9Y.js} +9 -6
  14. package/dist/es-VeBX6MEG.js +3 -0
  15. package/dist/{extensions-BbM81hHa.js → extensions-CEgexSyF.js} +846 -824
  16. package/dist/extensions.js +4 -4
  17. package/dist/fa-Dt7EYtKf.js +3 -0
  18. package/dist/fr-DUhhjxrJ.js +3 -0
  19. package/dist/getDefaultSlashMenuItems-DfDOr807.js +1939 -0
  20. package/dist/he-BShJg1dK.js +3 -0
  21. package/dist/hr-BXtyqmwg.js +3 -0
  22. package/dist/is-2Fb-0w_j.js +3 -0
  23. package/dist/it-CiZtVb3Y.js +3 -0
  24. package/dist/ja-CsxD3kEL.js +3 -0
  25. package/dist/ko-It6g03Cy.js +3 -0
  26. package/dist/locales.js +692 -54
  27. package/dist/markGroups-BszXCkX8.js +18 -0
  28. package/dist/nb-CLao87La.js +3 -0
  29. package/dist/nl-JQSo8dht.js +3 -0
  30. package/dist/pl-DEMBgHEP.js +3 -0
  31. package/dist/pt-CBCdYAax.js +3 -0
  32. package/dist/ru-BQk_9Q-L.js +3 -0
  33. package/dist/sk-kgB2DtDL.js +3 -0
  34. package/dist/{src-BmLsLZfE.js → src-DksfoQmN.js} +1173 -1090
  35. package/dist/style.css +1 -1
  36. package/dist/tr-DkcSXX8f.js +3 -0
  37. package/dist/uk-Bib-e6bV.js +3 -0
  38. package/dist/uz-B2jaKhJb.js +3 -0
  39. package/dist/vi-V_GFRxE8.js +3 -0
  40. package/dist/y.js +356 -361
  41. package/dist/yjs.js +134 -135
  42. package/dist/zh-hant-2ZrAkFnC.js +3 -0
  43. package/dist/zh-jglyCmjs.js +3 -0
  44. package/package.json +45 -21
  45. package/types/src/api/blockManipulation/layoutBlocks/layoutBlocks.fixture.d.ts +5 -0
  46. package/types/src/api/blockManipulation/tables/tables.d.ts +9 -4
  47. package/types/src/api/clipboard/fromClipboard/normalizeOfficeHTML.d.ts +5 -0
  48. package/types/src/api/exporters/markdown/wrapWithDelimiter.d.ts +6 -0
  49. package/types/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.d.ts +4 -0
  50. package/types/src/blocks/defaultBlocks.d.ts +10 -0
  51. package/types/src/editor/BlockNoteEditor.d.ts +2 -1
  52. package/types/src/editor/managers/ExtensionManager/index.d.ts +4 -4
  53. package/types/src/editor/managers/StyleManager.d.ts +2 -1
  54. package/types/src/emoji-data/frimousse/ar.d.ts +2 -0
  55. package/types/src/emoji-data/frimousse/common.d.ts +3 -0
  56. package/types/src/emoji-data/frimousse/de.d.ts +2 -0
  57. package/types/src/emoji-data/frimousse/en.d.ts +2 -0
  58. package/types/src/emoji-data/frimousse/es.d.ts +2 -0
  59. package/types/src/emoji-data/frimousse/fa.d.ts +2 -0
  60. package/types/src/emoji-data/frimousse/fr.d.ts +2 -0
  61. package/types/src/emoji-data/frimousse/he.d.ts +2 -0
  62. package/types/src/emoji-data/frimousse/hr.d.ts +2 -0
  63. package/types/src/emoji-data/frimousse/is.d.ts +2 -0
  64. package/types/src/emoji-data/frimousse/it.d.ts +2 -0
  65. package/types/src/emoji-data/frimousse/ja.d.ts +2 -0
  66. package/types/src/emoji-data/frimousse/ko.d.ts +2 -0
  67. package/types/src/emoji-data/frimousse/loadFrimousseData.d.ts +2 -0
  68. package/types/src/emoji-data/frimousse/nb.d.ts +2 -0
  69. package/types/src/emoji-data/frimousse/nl.d.ts +2 -0
  70. package/types/src/emoji-data/frimousse/pl.d.ts +2 -0
  71. package/types/src/emoji-data/frimousse/pt.d.ts +2 -0
  72. package/types/src/emoji-data/frimousse/ru.d.ts +2 -0
  73. package/types/src/emoji-data/frimousse/sk.d.ts +2 -0
  74. package/types/src/emoji-data/frimousse/tr.d.ts +2 -0
  75. package/types/src/emoji-data/frimousse/types.d.ts +21 -0
  76. package/types/src/emoji-data/frimousse/uk.d.ts +2 -0
  77. package/types/src/emoji-data/frimousse/uz.d.ts +2 -0
  78. package/types/src/emoji-data/frimousse/vi.d.ts +2 -0
  79. package/types/src/emoji-data/frimousse/zh-hant.d.ts +2 -0
  80. package/types/src/emoji-data/frimousse/zh.d.ts +2 -0
  81. package/types/src/emoji-data/index.d.ts +3 -0
  82. package/types/src/emoji-data/searchEmojis.d.ts +5 -0
  83. package/types/src/extensions/Loading/Loading.d.ts +11 -0
  84. package/types/src/extensions/SideMenu/MultipleNodeSelection.d.ts +13 -4
  85. package/types/src/extensions/SideMenu/SideMenu.d.ts +2 -1
  86. package/types/src/extensions/Versioning/Versioning.d.ts +2 -0
  87. package/types/src/extensions/Versioning/inMemoryVersioning.d.ts +1 -0
  88. package/types/src/extensions/Versioning/types.d.ts +12 -6
  89. package/types/src/extensions/Versioning/versioningState.d.ts +6 -0
  90. package/types/src/extensions/index.d.ts +1 -2
  91. package/types/src/i18n/dictionary.d.ts +4 -1
  92. package/types/src/i18n/locales/en.d.ts +6 -0
  93. package/types/src/i18n/locales/fa.d.ts +6 -0
  94. package/types/src/i18n/locales/index.d.ts +1 -0
  95. package/types/src/i18n/locales/sk.d.ts +6 -0
  96. package/types/src/i18n/locales/tr.d.ts +378 -0
  97. package/types/src/index.d.ts +0 -1
  98. package/types/src/schema/inlineContent/createSpec.d.ts +2 -1
  99. package/types/src/schema/inlineContent/internal.d.ts +1 -1
  100. package/types/src/schema/inlineContent/types.d.ts +2 -4
  101. package/types/src/schema/styles/createSpec.d.ts +2 -1
  102. package/types/src/schema/styles/internal.d.ts +4 -1
  103. package/types/src/schema/styles/types.d.ts +2 -0
  104. package/types/src/y/extensions/YSync.d.ts +1 -1
  105. package/types/src/y/extensions/index.d.ts +1 -1
  106. package/types/src/y/versioning/yhub.d.ts +2 -0
  107. package/types/src/yjs/extensions/Versioning.d.ts +1 -0
  108. package/types/src/yjs/extensions/YUndo.d.ts +3 -2
  109. package/types/src/yjs/extensions/index.d.ts +1 -1
  110. package/dist/BlockNoteExtension-DjEkXkR5.cjs +0 -2
  111. package/dist/BlockNoteExtension-DjEkXkR5.cjs.map +0 -1
  112. package/dist/BlockNoteExtension-TsTGtIeX.js +0 -87
  113. package/dist/BlockNoteExtension-TsTGtIeX.js.map +0 -1
  114. package/dist/ThreadStore-Bx-gSEh1.cjs +0 -2
  115. package/dist/ThreadStore-Bx-gSEh1.cjs.map +0 -1
  116. package/dist/ThreadStore-et9wB5Xt.js +0 -11
  117. package/dist/ThreadStore-et9wB5Xt.js.map +0 -1
  118. package/dist/UserStore-CTVzVGh-.cjs +0 -2
  119. package/dist/UserStore-CTVzVGh-.cjs.map +0 -1
  120. package/dist/UserStore-OZJP3K8T.js.map +0 -1
  121. package/dist/blocknote.cjs +0 -1
  122. package/dist/blocks-COVwe5Cf.cjs +0 -12
  123. package/dist/blocks-COVwe5Cf.cjs.map +0 -1
  124. package/dist/blocks-COYcDVg7.js +0 -3943
  125. package/dist/blocks-COYcDVg7.js.map +0 -1
  126. package/dist/blocks.cjs +0 -1
  127. package/dist/comments.cjs +0 -2
  128. package/dist/comments.cjs.map +0 -1
  129. package/dist/comments.js.map +0 -1
  130. package/dist/en-Ch-vvt5e.js.map +0 -1
  131. package/dist/en-N5lu0-j8.cjs +0 -2
  132. package/dist/en-N5lu0-j8.cjs.map +0 -1
  133. package/dist/extensions-BbM81hHa.js.map +0 -1
  134. package/dist/extensions-D_WkAfSt.cjs +0 -58
  135. package/dist/extensions-D_WkAfSt.cjs.map +0 -1
  136. package/dist/extensions.cjs +0 -1
  137. package/dist/locales.cjs +0 -2
  138. package/dist/locales.cjs.map +0 -1
  139. package/dist/locales.js.map +0 -1
  140. package/dist/src-4OQT3z5S.cjs +0 -23
  141. package/dist/src-4OQT3z5S.cjs.map +0 -1
  142. package/dist/src-BmLsLZfE.js.map +0 -1
  143. package/dist/webpack-stats.json +0 -1
  144. package/dist/y.cjs +0 -2
  145. package/dist/y.cjs.map +0 -1
  146. package/dist/y.js.map +0 -1
  147. package/dist/yjs.cjs +0 -2
  148. package/dist/yjs.cjs.map +0 -1
  149. package/dist/yjs.js.map +0 -1
  150. package/src/api/README.md +0 -8
  151. package/src/api/__snapshots__/blocks-deleted-nested-deep.json +0 -26
  152. package/src/api/__snapshots__/blocks-deleted-nested.json +0 -68
  153. package/src/api/__snapshots__/blocks-deleted.json +0 -26
  154. package/src/api/__snapshots__/blocks-indented-changed.json +0 -129
  155. package/src/api/__snapshots__/blocks-inserted-nested.json +0 -62
  156. package/src/api/__snapshots__/blocks-inserted.json +0 -20
  157. package/src/api/__snapshots__/blocks-moved-deeper-into-nesting.json +0 -164
  158. package/src/api/__snapshots__/blocks-moved-down-twice-in-same-parent.json +0 -44
  159. package/src/api/__snapshots__/blocks-moved-insert-changes-sibling-order.json +0 -26
  160. package/src/api/__snapshots__/blocks-moved-multiple-in-same-transaction.json +0 -188
  161. package/src/api/__snapshots__/blocks-moved-nested-sibling-reorder.json +0 -180
  162. package/src/api/__snapshots__/blocks-moved-to-different-parent.json +0 -78
  163. package/src/api/__snapshots__/blocks-moved-to-root-level.json +0 -78
  164. package/src/api/__snapshots__/blocks-moved-up-down-in-same-parent.json +0 -44
  165. package/src/api/__snapshots__/blocks-moved-up-down-in-same-transaction.json +0 -44
  166. package/src/api/__snapshots__/blocks-outdented-changed.json +0 -129
  167. package/src/api/__snapshots__/blocks-updated-content-inserted.json +0 -42
  168. package/src/api/__snapshots__/blocks-updated-multiple-insert.json +0 -50
  169. package/src/api/__snapshots__/blocks-updated-multiple.json +0 -82
  170. package/src/api/__snapshots__/blocks-updated-nested-deep.json +0 -42
  171. package/src/api/__snapshots__/blocks-updated-nested-multiple.json +0 -118
  172. package/src/api/__snapshots__/blocks-updated-nested.json +0 -78
  173. package/src/api/__snapshots__/blocks-updated-single.json +0 -42
  174. package/src/api/__snapshots__/blocks-updated.json +0 -42
  175. package/src/api/blockManipulation/__snapshots__/transactions.test.ts.snap +0 -34
  176. package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +0 -4570
  177. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +0 -176
  178. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +0 -95
  179. package/src/api/blockManipulation/commands/insertBlocks/insertPlacement.test.ts +0 -217
  180. package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +0 -2761
  181. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +0 -251
  182. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +0 -187
  183. package/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap +0 -13625
  184. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +0 -391
  185. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +0 -350
  186. package/src/api/blockManipulation/commands/nestBlock/__snapshots__/nestBlock.test.ts.snap +0 -952
  187. package/src/api/blockManipulation/commands/nestBlock/nestBlock.test.ts +0 -917
  188. package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +0 -248
  189. package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +0 -5710
  190. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +0 -306
  191. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +0 -143
  192. package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +0 -3507
  193. package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +0 -364
  194. package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +0 -90
  195. package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +0 -15085
  196. package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +0 -1210
  197. package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +0 -706
  198. package/src/api/blockManipulation/getBlock/getBlock.ts +0 -104
  199. package/src/api/blockManipulation/insertContentAt.ts +0 -83
  200. package/src/api/blockManipulation/layoutBlocks/fixLayoutBlock.ts +0 -173
  201. package/src/api/blockManipulation/layoutBlocks/layoutBlocks.browser.test.ts +0 -293
  202. package/src/api/blockManipulation/layoutBlocks/layoutBlocks.fixture.ts +0 -145
  203. package/src/api/blockManipulation/layoutBlocks/layoutBlocks.test.ts +0 -783
  204. package/src/api/blockManipulation/layoutBlocks/plainBlocks.test.ts +0 -180
  205. package/src/api/blockManipulation/layoutBlocks/titledBlocks.test.ts +0 -365
  206. package/src/api/blockManipulation/selections/selection.ts +0 -234
  207. package/src/api/blockManipulation/selections/textCursorPosition.ts +0 -63
  208. package/src/api/blockManipulation/setupTestEnv.ts +0 -223
  209. package/src/api/blockManipulation/tables/tables.test.ts +0 -2127
  210. package/src/api/blockManipulation/tables/tables.ts +0 -887
  211. package/src/api/clipboard/fromClipboard/acceptedMIMETypes.ts +0 -8
  212. package/src/api/clipboard/fromClipboard/fileDropExtension.ts +0 -55
  213. package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +0 -209
  214. package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +0 -38
  215. package/src/api/clipboard/fromClipboard/pasteExtension.ts +0 -157
  216. package/src/api/clipboard/toClipboard/copyExtension.ts +0 -299
  217. package/src/api/combineTransactionSteps.ts +0 -22
  218. package/src/api/exporters/html/externalHTMLExporter.ts +0 -76
  219. package/src/api/exporters/html/internalHTMLSerializer.ts +0 -182
  220. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +0 -510
  221. package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +0 -283
  222. package/src/api/exporters/markdown/htmlToMarkdown.ts +0 -895
  223. package/src/api/exporters/markdown/markdownExporter.ts +0 -41
  224. package/src/api/getBlockInfoFromPos.test.ts +0 -681
  225. package/src/api/getBlockInfoFromPos.ts +0 -693
  226. package/src/api/getBlocksChangedByTransaction.test.ts +0 -783
  227. package/src/api/getBlocksChangedByTransaction.ts +0 -458
  228. package/src/api/getChangedRangeWithAttrs.ts +0 -54
  229. package/src/api/getChangedRanges.test.ts +0 -391
  230. package/src/api/getChangedRanges.ts +0 -368
  231. package/src/api/nodeConversions/blockToNode.test.ts +0 -113
  232. package/src/api/nodeConversions/blockToNode.ts +0 -427
  233. package/src/api/nodeConversions/fragmentToBlocks.ts +0 -48
  234. package/src/api/nodeConversions/nodeToBlock.ts +0 -717
  235. package/src/api/nodeUtil.ts +0 -46
  236. package/src/api/parsers/html/parseHTML.ts +0 -80
  237. package/src/api/parsers/html/util/__snapshots__/nestedLists.test.ts.snap +0 -144
  238. package/src/api/parsers/html/util/nestedLists.test.ts +0 -165
  239. package/src/api/parsers/html/util/nestedLists.ts +0 -123
  240. package/src/api/parsers/html/util/normalizeWhitespace.ts +0 -87
  241. package/src/api/parsers/markdown/autolink.ts +0 -23
  242. package/src/api/parsers/markdown/detectMarkdown.test.ts +0 -211
  243. package/src/api/parsers/markdown/detectMarkdown.ts +0 -61
  244. package/src/api/parsers/markdown/markdownToHtml.ts +0 -1444
  245. package/src/api/parsers/markdown/parseMarkdown.ts +0 -24
  246. package/src/api/pmUtil.ts +0 -79
  247. package/src/api/positionMapping.test.ts +0 -209
  248. package/src/api/positionMapping.ts +0 -42
  249. package/src/blocks/Audio/block.ts +0 -171
  250. package/src/blocks/Audio/parseAudioElement.ts +0 -5
  251. package/src/blocks/BlockNoteSchema.ts +0 -59
  252. package/src/blocks/Code/CodeBlockOptions.ts +0 -83
  253. package/src/blocks/Code/block.test.ts +0 -265
  254. package/src/blocks/Code/block.ts +0 -56
  255. package/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.ts +0 -125
  256. package/src/blocks/Code/helpers/parse/parsePreCode.ts +0 -45
  257. package/src/blocks/Code/helpers/render/createCodeBlock.ts +0 -98
  258. package/src/blocks/Code/helpers/toExternalHTML/createPreCode.ts +0 -14
  259. package/src/blocks/Divider/block.ts +0 -49
  260. package/src/blocks/File/block.ts +0 -95
  261. package/src/blocks/File/helpers/parse/parseEmbedElement.ts +0 -5
  262. package/src/blocks/File/helpers/parse/parseFigureElement.ts +0 -16
  263. package/src/blocks/File/helpers/render/createAddFileButton.ts +0 -69
  264. package/src/blocks/File/helpers/render/createFileBlockWrapper.ts +0 -88
  265. package/src/blocks/File/helpers/render/createFileNameWithIcon.ts +0 -37
  266. package/src/blocks/File/helpers/render/createResizableFileBlockWrapper.ts +0 -271
  267. package/src/blocks/File/helpers/toExternalHTML/createFigureWithCaption.ts +0 -13
  268. package/src/blocks/File/helpers/toExternalHTML/createLinkWithCaption.ts +0 -15
  269. package/src/blocks/Heading/block.ts +0 -227
  270. package/src/blocks/Image/block.ts +0 -193
  271. package/src/blocks/Image/parseImageElement.ts +0 -7
  272. package/src/blocks/ListItem/BulletListItem/block.ts +0 -129
  273. package/src/blocks/ListItem/CheckListItem/block.test.ts +0 -61
  274. package/src/blocks/ListItem/CheckListItem/block.ts +0 -184
  275. package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.ts +0 -352
  276. package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +0 -239
  277. package/src/blocks/ListItem/NumberedListItem/block.ts +0 -143
  278. package/src/blocks/ListItem/ToggleListItem/block.ts +0 -139
  279. package/src/blocks/ListItem/getListItemContent.ts +0 -115
  280. package/src/blocks/PageBreak/block.ts +0 -72
  281. package/src/blocks/PageBreak/getPageBreakSlashMenuItems.ts +0 -47
  282. package/src/blocks/Paragraph/block.ts +0 -80
  283. package/src/blocks/Quote/block.ts +0 -99
  284. package/src/blocks/README.md +0 -3
  285. package/src/blocks/Table/TableExtension.test.ts +0 -231
  286. package/src/blocks/Table/TableExtension.ts +0 -115
  287. package/src/blocks/Table/block.ts +0 -492
  288. package/src/blocks/ToggleWrapper/createToggleFrame.ts +0 -126
  289. package/src/blocks/ToggleWrapper/toggleBlocks.browser.test.ts +0 -1056
  290. package/src/blocks/Video/block.ts +0 -142
  291. package/src/blocks/Video/parseVideoElement.ts +0 -7
  292. package/src/blocks/defaultBlockHelpers.ts +0 -113
  293. package/src/blocks/defaultBlockTypeGuards.ts +0 -167
  294. package/src/blocks/defaultBlockTypeItems.test.ts +0 -70
  295. package/src/blocks/defaultBlockTypeItems.ts +0 -99
  296. package/src/blocks/defaultBlocks.test.ts +0 -67
  297. package/src/blocks/defaultBlocks.ts +0 -214
  298. package/src/blocks/defaultProps.ts +0 -165
  299. package/src/blocks/getDetailsContent.ts +0 -77
  300. package/src/blocks/index.ts +0 -30
  301. package/src/comments/CommentEditorSubmitExtension.test.ts +0 -141
  302. package/src/comments/CommentEditorSubmitExtension.ts +0 -56
  303. package/src/comments/extension.ts +0 -396
  304. package/src/comments/index.ts +0 -8
  305. package/src/comments/mark.ts +0 -64
  306. package/src/comments/threadstore/DefaultThreadStoreAuth.ts +0 -106
  307. package/src/comments/threadstore/ThreadStore.ts +0 -130
  308. package/src/comments/threadstore/ThreadStoreAuth.ts +0 -13
  309. package/src/comments/threadstore/TipTapThreadStore.ts +0 -292
  310. package/src/comments/threadstore/tiptap/types.ts +0 -131
  311. package/src/comments/types.ts +0 -121
  312. package/src/editor/Block.css +0 -1498
  313. package/src/editor/BlockNoteEditor.node.test.ts +0 -35
  314. package/src/editor/BlockNoteEditor.test.ts +0 -278
  315. package/src/editor/BlockNoteEditor.ts +0 -1559
  316. package/src/editor/BlockNoteExtension.test.ts +0 -103
  317. package/src/editor/BlockNoteExtension.ts +0 -246
  318. package/src/editor/README.md +0 -3
  319. package/src/editor/blockColors.browser.test.ts +0 -127
  320. package/src/editor/cursorPositionTypes.ts +0 -17
  321. package/src/editor/defaultColors.ts +0 -77
  322. package/src/editor/editor.css +0 -257
  323. package/src/editor/managers/BlockManager.ts +0 -256
  324. package/src/editor/managers/EventManager.browser.test.ts +0 -334
  325. package/src/editor/managers/EventManager.ts +0 -260
  326. package/src/editor/managers/ExportManager.ts +0 -137
  327. package/src/editor/managers/ExtensionManager/ExtensionManager.browser.test.ts +0 -45
  328. package/src/editor/managers/ExtensionManager/ExtensionManager.node.test.ts +0 -209
  329. package/src/editor/managers/ExtensionManager/ExtensionManager.test.ts +0 -336
  330. package/src/editor/managers/ExtensionManager/extensions.ts +0 -200
  331. package/src/editor/managers/ExtensionManager/index.ts +0 -764
  332. package/src/editor/managers/ExtensionManager/symbol.ts +0 -5
  333. package/src/editor/managers/SelectionManager.ts +0 -120
  334. package/src/editor/managers/StateManager.ts +0 -261
  335. package/src/editor/managers/StyleManager.browser.test.ts +0 -122
  336. package/src/editor/managers/StyleManager.test.ts +0 -98
  337. package/src/editor/managers/StyleManager.ts +0 -278
  338. package/src/editor/managers/index.ts +0 -8
  339. package/src/editor/performance.test.ts +0 -192
  340. package/src/editor/selectionTypes.ts +0 -14
  341. package/src/editor/transformPasted.test.ts +0 -295
  342. package/src/editor/transformPasted.ts +0 -294
  343. package/src/exporter/ExportImage.ts +0 -50
  344. package/src/exporter/Exporter.test.ts +0 -255
  345. package/src/exporter/Exporter.ts +0 -185
  346. package/src/exporter/index.ts +0 -3
  347. package/src/exporter/mapping.ts +0 -110
  348. package/src/extensions/BlockChange/BlockChange.ts +0 -67
  349. package/src/extensions/DropCursor/DropCursor.ts +0 -376
  350. package/src/extensions/DropCursor/dropIntoChildren.ts +0 -80
  351. package/src/extensions/DropCursor/utils.ts +0 -195
  352. package/src/extensions/FilePanel/FilePanel.ts +0 -41
  353. package/src/extensions/FormattingToolbar/FormattingToolbar.ts +0 -157
  354. package/src/extensions/History/History.ts +0 -11
  355. package/src/extensions/InlineContentBoundaryEdit/InlineContentBoundaryEdit.ts +0 -109
  356. package/src/extensions/LinkToolbar/LinkToolbar.ts +0 -76
  357. package/src/extensions/LinkToolbar/protocols.ts +0 -13
  358. package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.test.ts +0 -190
  359. package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.ts +0 -112
  360. package/src/extensions/Placeholder/Placeholder.test.ts +0 -23
  361. package/src/extensions/Placeholder/Placeholder.ts +0 -150
  362. package/src/extensions/PositionMapping/PositionMapping.ts +0 -68
  363. package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +0 -156
  364. package/src/extensions/PreviousBlockType/PreviousBlockType.ts +0 -201
  365. package/src/extensions/README.md +0 -3
  366. package/src/extensions/ReadOnly/ReadOnly.test.ts +0 -181
  367. package/src/extensions/ReadOnly/ReadOnly.ts +0 -73
  368. package/src/extensions/ShowSelection/ShowSelection.ts +0 -61
  369. package/src/extensions/SideMenu/MultipleNodeSelection.ts +0 -89
  370. package/src/extensions/SideMenu/SideMenu.ts +0 -470
  371. package/src/extensions/SideMenu/blockDropHandling.ts +0 -372
  372. package/src/extensions/SideMenu/blockGeometry.browser.test.ts +0 -148
  373. package/src/extensions/SideMenu/blockGeometry.test.ts +0 -46
  374. package/src/extensions/SideMenu/blockGeometry.ts +0 -53
  375. package/src/extensions/SideMenu/dragging.ts +0 -200
  376. package/src/extensions/SideMenu/sideMenuHover.test.ts +0 -36
  377. package/src/extensions/SideMenu/sideMenuHover.ts +0 -270
  378. package/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.ts +0 -193
  379. package/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.ts +0 -142
  380. package/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.ts +0 -4
  381. package/src/extensions/SuggestionMenu/DefaultSuggestionItem.ts +0 -11
  382. package/src/extensions/SuggestionMenu/SuggestionMenu.test.ts +0 -309
  383. package/src/extensions/SuggestionMenu/SuggestionMenu.ts +0 -436
  384. package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +0 -76
  385. package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +0 -299
  386. package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.ts +0 -130
  387. package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.ts +0 -89
  388. package/src/extensions/SyntaxHighlighting/inlineHighlight.test.ts +0 -135
  389. package/src/extensions/SyntaxHighlighting/shiki.ts +0 -116
  390. package/src/extensions/TableHandles/TableHandles.browser.test.ts +0 -307
  391. package/src/extensions/TableHandles/TableHandles.ts +0 -1263
  392. package/src/extensions/TrailingNode/TrailingNode.ts +0 -233
  393. package/src/extensions/Versioning/Versioning.browser.test.ts +0 -151
  394. package/src/extensions/Versioning/Versioning.node.test.ts +0 -177
  395. package/src/extensions/Versioning/Versioning.ts +0 -161
  396. package/src/extensions/Versioning/__test__/result.ts +0 -12
  397. package/src/extensions/Versioning/comparison.test.ts +0 -40
  398. package/src/extensions/Versioning/createVersioning.test.ts +0 -867
  399. package/src/extensions/Versioning/createVersioning.ts +0 -499
  400. package/src/extensions/Versioning/formatVersionDate.ts +0 -24
  401. package/src/extensions/Versioning/inMemoryVersioning.test.ts +0 -572
  402. package/src/extensions/Versioning/inMemoryVersioning.ts +0 -268
  403. package/src/extensions/Versioning/index.ts +0 -6
  404. package/src/extensions/Versioning/scrollScheduling.test.ts +0 -51
  405. package/src/extensions/Versioning/scrollToFirstChange.test.ts +0 -320
  406. package/src/extensions/Versioning/scrollToFirstChange.ts +0 -139
  407. package/src/extensions/Versioning/types.ts +0 -219
  408. package/src/extensions/Versioning/versioningState.ts +0 -154
  409. package/src/extensions/blockDOM.browser.test.ts +0 -102
  410. package/src/extensions/blockDOM.test.ts +0 -178
  411. package/src/extensions/blockDOM.ts +0 -135
  412. package/src/extensions/index.ts +0 -27
  413. package/src/extensions/tiptap-extensions/BackgroundColor/BackgroundColorExtension.ts +0 -17
  414. package/src/extensions/tiptap-extensions/HardBreak/HardBreak.ts +0 -35
  415. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts +0 -1870
  416. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +0 -1116
  417. package/src/extensions/tiptap-extensions/KeyboardShortcuts/blockIdentity.browser.test.ts +0 -152
  418. package/src/extensions/tiptap-extensions/Link/helpers/autolink.ts +0 -174
  419. package/src/extensions/tiptap-extensions/Link/helpers/clickHandler.ts +0 -82
  420. package/src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts +0 -412
  421. package/src/extensions/tiptap-extensions/Link/helpers/pasteHandler.ts +0 -53
  422. package/src/extensions/tiptap-extensions/Link/helpers/tlds.ts +0 -7
  423. package/src/extensions/tiptap-extensions/Link/helpers/whitespace.ts +0 -13
  424. package/src/extensions/tiptap-extensions/Link/index.ts +0 -2
  425. package/src/extensions/tiptap-extensions/Link/link.test.ts +0 -945
  426. package/src/extensions/tiptap-extensions/Link/link.ts +0 -238
  427. package/src/extensions/tiptap-extensions/TextAlignment/TextAlignmentExtension.ts +0 -33
  428. package/src/extensions/tiptap-extensions/TextColor/TextColorExtension.ts +0 -17
  429. package/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.ts +0 -173
  430. package/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts +0 -339
  431. package/src/extensions/tiptap-extensions/index.ts +0 -7
  432. package/src/extensions-shared/UiElementPosition.ts +0 -4
  433. package/src/fonts/inter.browser.test.ts +0 -57
  434. package/src/i18n/dictionary.ts +0 -17
  435. package/src/i18n/index.ts +0 -2
  436. package/src/i18n/locales/ar.ts +0 -443
  437. package/src/i18n/locales/de.ts +0 -477
  438. package/src/i18n/locales/en.ts +0 -458
  439. package/src/i18n/locales/es.ts +0 -456
  440. package/src/i18n/locales/fa.ts +0 -427
  441. package/src/i18n/locales/fr.ts +0 -504
  442. package/src/i18n/locales/he.ts +0 -458
  443. package/src/i18n/locales/hr.ts +0 -472
  444. package/src/i18n/locales/index.ts +0 -23
  445. package/src/i18n/locales/is.ts +0 -472
  446. package/src/i18n/locales/it.ts +0 -480
  447. package/src/i18n/locales/ja.ts +0 -498
  448. package/src/i18n/locales/ko.ts +0 -471
  449. package/src/i18n/locales/nl.ts +0 -459
  450. package/src/i18n/locales/no.ts +0 -476
  451. package/src/i18n/locales/pl.ts +0 -449
  452. package/src/i18n/locales/pt.ts +0 -451
  453. package/src/i18n/locales/ru.ts +0 -502
  454. package/src/i18n/locales/sk.ts +0 -456
  455. package/src/i18n/locales/uk.ts +0 -482
  456. package/src/i18n/locales/uz.ts +0 -492
  457. package/src/i18n/locales/vi.ts +0 -457
  458. package/src/i18n/locales/zh-tw.ts +0 -499
  459. package/src/i18n/locales/zh.ts +0 -499
  460. package/src/index.ts +0 -66
  461. package/src/locales.ts +0 -1
  462. package/src/pm-nodes/BlockContainer.test.ts +0 -101
  463. package/src/pm-nodes/BlockContainer.ts +0 -200
  464. package/src/pm-nodes/BlockGroup.ts +0 -58
  465. package/src/pm-nodes/Doc.ts +0 -11
  466. package/src/pm-nodes/README.md +0 -143
  467. package/src/pm-nodes/index.ts +0 -3
  468. package/src/pm-nodes/suggestionMarks.ts +0 -43
  469. package/src/schema/README.md +0 -3
  470. package/src/schema/blocks/children.test.ts +0 -288
  471. package/src/schema/blocks/children.ts +0 -136
  472. package/src/schema/blocks/createSpec.browser.test.ts +0 -176
  473. package/src/schema/blocks/createSpec.test.ts +0 -354
  474. package/src/schema/blocks/createSpec.ts +0 -732
  475. package/src/schema/blocks/extendBlockSpec.test.ts +0 -188
  476. package/src/schema/blocks/frame.test.ts +0 -112
  477. package/src/schema/blocks/frame.ts +0 -337
  478. package/src/schema/blocks/internal.test.ts +0 -86
  479. package/src/schema/blocks/internal.ts +0 -288
  480. package/src/schema/blocks/keyboard.ts +0 -154
  481. package/src/schema/blocks/layoutBlockAttributes.ts +0 -29
  482. package/src/schema/blocks/meta.test.ts +0 -53
  483. package/src/schema/blocks/meta.ts +0 -35
  484. package/src/schema/blocks/renderFrame.test.ts +0 -691
  485. package/src/schema/blocks/types.ts +0 -966
  486. package/src/schema/blocks/validateChildren.ts +0 -156
  487. package/src/schema/contentTypePropagation.test.ts +0 -182
  488. package/src/schema/dataAttributes.test.ts +0 -72
  489. package/src/schema/dataAttributes.ts +0 -69
  490. package/src/schema/index.ts +0 -15
  491. package/src/schema/inlineContent/createSpec.test.ts +0 -161
  492. package/src/schema/inlineContent/createSpec.ts +0 -409
  493. package/src/schema/inlineContent/internal.ts +0 -131
  494. package/src/schema/inlineContent/types.ts +0 -204
  495. package/src/schema/markGroups.ts +0 -82
  496. package/src/schema/nodeViewMutations.test.ts +0 -146
  497. package/src/schema/nodeViewMutations.ts +0 -49
  498. package/src/schema/propTypes.ts +0 -61
  499. package/src/schema/schema.test.ts +0 -110
  500. package/src/schema/schema.ts +0 -243
  501. package/src/schema/styles/createSpec.ts +0 -140
  502. package/src/schema/styles/internal.ts +0 -155
  503. package/src/schema/styles/types.ts +0 -57
  504. package/src/style.css +0 -2
  505. package/src/user/UserStore.ts +0 -199
  506. package/src/user/createUserStore.test.ts +0 -126
  507. package/src/user/index.ts +0 -2
  508. package/src/user/userColors.test.ts +0 -108
  509. package/src/user/userColors.ts +0 -101
  510. package/src/util/EventEmitter.ts +0 -59
  511. package/src/util/README.md +0 -3
  512. package/src/util/Store.test.ts +0 -132
  513. package/src/util/Store.ts +0 -135
  514. package/src/util/browser.ts +0 -54
  515. package/src/util/combineByGroup.ts +0 -25
  516. package/src/util/expandToWords.ts +0 -38
  517. package/src/util/string.ts +0 -36
  518. package/src/util/table.ts +0 -110
  519. package/src/util/topo-sort.test.ts +0 -125
  520. package/src/util/topo-sort.ts +0 -206
  521. package/src/util/typescript.ts +0 -17
  522. package/src/vite-env.d.ts +0 -7
  523. package/src/y/README.md +0 -5
  524. package/src/y/comments/RESTYjsThreadStore.ts +0 -138
  525. package/src/y/comments/YjsThreadStore.test.ts +0 -295
  526. package/src/y/comments/YjsThreadStore.ts +0 -358
  527. package/src/y/comments/YjsThreadStoreBase.ts +0 -50
  528. package/src/y/comments/index.ts +0 -3
  529. package/src/y/comments/yjsHelpers.ts +0 -125
  530. package/src/y/extensions/AttributionExtension.test.ts +0 -364
  531. package/src/y/extensions/AttributionExtension.ts +0 -401
  532. package/src/y/extensions/DiffVersioningExtension.test.ts +0 -242
  533. package/src/y/extensions/DiffVersioningExtension.ts +0 -200
  534. package/src/y/extensions/EmptyDocBinding.test.ts +0 -282
  535. package/src/y/extensions/ForkYDoc.node.test.ts +0 -77
  536. package/src/y/extensions/ForkYDoc.test.ts +0 -344
  537. package/src/y/extensions/ForkYDoc.ts +0 -117
  538. package/src/y/extensions/History.test.ts +0 -125
  539. package/src/y/extensions/RelativePositionMapping.test.ts +0 -453
  540. package/src/y/extensions/RelativePositionMapping.ts +0 -45
  541. package/src/y/extensions/Suggestions.ts +0 -174
  542. package/src/y/extensions/Versioning.node.test.ts +0 -126
  543. package/src/y/extensions/Versioning.test.ts +0 -117
  544. package/src/y/extensions/Versioning.ts +0 -74
  545. package/src/y/extensions/YAttributionMarks.ts +0 -422
  546. package/src/y/extensions/YCursorPlugin.ts +0 -192
  547. package/src/y/extensions/YSync.node.test.ts +0 -75
  548. package/src/y/extensions/YSync.ts +0 -197
  549. package/src/y/extensions/YSyncRemount.test.ts +0 -99
  550. package/src/y/extensions/blockMatchNodes.ts +0 -173
  551. package/src/y/extensions/index.ts +0 -140
  552. package/src/y/extensions/legacyYjsDocBinding.test.ts +0 -652
  553. package/src/y/extensions/nestingChanges.test.ts +0 -326
  554. package/src/y/extensions/persistentBlockGroups.test.ts +0 -1709
  555. package/src/y/extensions/persistentBlockGroups.ts +0 -953
  556. package/src/y/extensions/snapshotCodec.test.ts +0 -105
  557. package/src/y/extensions/snapshotCodec.ts +0 -39
  558. package/src/y/extensions/snapshotPreview.test.ts +0 -201
  559. package/src/y/extensions/snapshotPreview.ts +0 -292
  560. package/src/y/extensions/tableReshape.test.ts +0 -121
  561. package/src/y/extensions/v1BindingSnapshotDiff.test.ts +0 -121
  562. package/src/y/extensions/versionDiffAttribution.test.ts +0 -944
  563. package/src/y/extensions/versionDiffPerformance.test.ts +0 -101
  564. package/src/y/index.ts +0 -5
  565. package/src/y/utils.test.ts +0 -1309
  566. package/src/y/utils.ts +0 -366
  567. package/src/y/versioning/__test__/fixtures/activity-all-after.bin +0 -0
  568. package/src/y/versioning/__test__/fixtures/activity-all-after.json +0 -50
  569. package/src/y/versioning/__test__/fixtures/activity-all.bin +0 -0
  570. package/src/y/versioning/__test__/fixtures/activity-all.json +0 -20
  571. package/src/y/versioning/__test__/fixtures/activity-filtered-after.bin +0 -0
  572. package/src/y/versioning/__test__/fixtures/activity-filtered-after.json +0 -32
  573. package/src/y/versioning/__test__/fixtures/activity-filtered-before.json +0 -1
  574. package/src/y/versioning/__test__/fixtures/changeset.bin +0 -0
  575. package/src/y/versioning/__test__/fixtures/patch-response.json +0 -4
  576. package/src/y/versioning/__test__/yhub.test.ts +0 -966
  577. package/src/y/versioning/index.ts +0 -6
  578. package/src/y/versioning/yhub.ts +0 -350
  579. package/src/y/versioning/yhubClient.ts +0 -345
  580. package/src/yjs/README.md +0 -5
  581. package/src/yjs/comments/RESTYjsThreadStore.test.ts +0 -95
  582. package/src/yjs/comments/RESTYjsThreadStore.ts +0 -172
  583. package/src/yjs/comments/YjsThreadStore.test.ts +0 -295
  584. package/src/yjs/comments/YjsThreadStore.ts +0 -345
  585. package/src/yjs/comments/YjsThreadStoreBase.ts +0 -50
  586. package/src/yjs/comments/index.ts +0 -3
  587. package/src/yjs/comments/yjsHelpers.ts +0 -127
  588. package/src/yjs/extensions/FixUpSchema.test.ts +0 -421
  589. package/src/yjs/extensions/FixUpSchema.ts +0 -99
  590. package/src/yjs/extensions/ForkYDoc.browser.test.ts +0 -84
  591. package/src/yjs/extensions/ForkYDoc.node.test.ts +0 -231
  592. package/src/yjs/extensions/ForkYDoc.test.ts +0 -320
  593. package/src/yjs/extensions/ForkYDoc.ts +0 -177
  594. package/src/yjs/extensions/RelativePositionMapping.test.ts +0 -418
  595. package/src/yjs/extensions/RelativePositionMapping.ts +0 -77
  596. package/src/yjs/extensions/Versioning.test.ts +0 -376
  597. package/src/yjs/extensions/Versioning.ts +0 -126
  598. package/src/yjs/extensions/YCursorPlugin.ts +0 -201
  599. package/src/yjs/extensions/YSync.ts +0 -16
  600. package/src/yjs/extensions/YUndo.ts +0 -12
  601. package/src/yjs/extensions/__snapshots__/fork-yjs-snap-editor-forked.json +0 -19
  602. package/src/yjs/extensions/__snapshots__/fork-yjs-snap-editor.json +0 -19
  603. package/src/yjs/extensions/__snapshots__/fork-yjs-snap-forked.html +0 -1
  604. package/src/yjs/extensions/__snapshots__/fork-yjs-snap.html +0 -1
  605. package/src/yjs/extensions/index.ts +0 -89
  606. package/src/yjs/extensions/schemaMigration/SchemaMigration.ts +0 -59
  607. package/src/yjs/extensions/schemaMigration/migrationRules/index.ts +0 -4
  608. package/src/yjs/extensions/schemaMigration/migrationRules/migrationRule.ts +0 -4
  609. package/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.test.ts +0 -130
  610. package/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.ts +0 -91
  611. package/src/yjs/index.ts +0 -7
  612. package/src/yjs/utils.test.ts +0 -1013
  613. package/src/yjs/utils.ts +0 -186
  614. package/types/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.d.ts +0 -1
  615. package/types/src/api/blockManipulation/commands/insertBlocks/insertPlacement.test.d.ts +0 -1
  616. package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.d.ts +0 -1
  617. package/types/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.d.ts +0 -1
  618. package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.test.d.ts +0 -1
  619. package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.d.ts +0 -1
  620. package/types/src/api/blockManipulation/commands/splitBlock/splitBlock.test.d.ts +0 -1
  621. package/types/src/api/blockManipulation/commands/updateBlock/updateBlock.test.d.ts +0 -1
  622. package/types/src/api/blockManipulation/layoutBlocks/layoutBlocks.browser.test.d.ts +0 -1
  623. package/types/src/api/blockManipulation/layoutBlocks/layoutBlocks.test.d.ts +0 -1
  624. package/types/src/api/blockManipulation/layoutBlocks/plainBlocks.test.d.ts +0 -1
  625. package/types/src/api/blockManipulation/layoutBlocks/titledBlocks.test.d.ts +0 -1
  626. package/types/src/api/blockManipulation/tables/tables.test.d.ts +0 -1
  627. package/types/src/api/getBlockInfoFromPos.test.d.ts +0 -1
  628. package/types/src/api/getBlocksChangedByTransaction.test.d.ts +0 -1
  629. package/types/src/api/getChangedRanges.test.d.ts +0 -1
  630. package/types/src/api/nodeConversions/blockToNode.test.d.ts +0 -1
  631. package/types/src/api/parsers/html/util/nestedLists.test.d.ts +0 -1
  632. package/types/src/api/parsers/markdown/detectMarkdown.test.d.ts +0 -1
  633. package/types/src/api/positionMapping.test.d.ts +0 -1
  634. package/types/src/blocks/Code/block.test.d.ts +0 -1
  635. package/types/src/blocks/ListItem/CheckListItem/block.test.d.ts +0 -1
  636. package/types/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.d.ts +0 -1
  637. package/types/src/blocks/Table/TableExtension.test.d.ts +0 -1
  638. package/types/src/blocks/ToggleWrapper/toggleBlocks.browser.test.d.ts +0 -1
  639. package/types/src/blocks/defaultBlockTypeItems.test.d.ts +0 -1
  640. package/types/src/blocks/defaultBlocks.test.d.ts +0 -1
  641. package/types/src/comments/CommentEditorSubmitExtension.test.d.ts +0 -1
  642. package/types/src/editor/BlockNoteEditor.node.test.d.ts +0 -1
  643. package/types/src/editor/BlockNoteEditor.test.d.ts +0 -1
  644. package/types/src/editor/BlockNoteExtension.test.d.ts +0 -1
  645. package/types/src/editor/blockColors.browser.test.d.ts +0 -1
  646. package/types/src/editor/managers/EventManager.browser.test.d.ts +0 -1
  647. package/types/src/editor/managers/ExtensionManager/ExtensionManager.browser.test.d.ts +0 -1
  648. package/types/src/editor/managers/ExtensionManager/ExtensionManager.node.test.d.ts +0 -1
  649. package/types/src/editor/managers/ExtensionManager/ExtensionManager.test.d.ts +0 -1
  650. package/types/src/editor/managers/StyleManager.browser.test.d.ts +0 -1
  651. package/types/src/editor/managers/StyleManager.test.d.ts +0 -1
  652. package/types/src/editor/performance.test.d.ts +0 -1
  653. package/types/src/editor/transformPasted.test.d.ts +0 -1
  654. package/types/src/exporter/Exporter.test.d.ts +0 -1
  655. package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.test.d.ts +0 -1
  656. package/types/src/extensions/Placeholder/Placeholder.test.d.ts +0 -1
  657. package/types/src/extensions/PreviousBlockType/PreviousBlockType.test.d.ts +0 -1
  658. package/types/src/extensions/ReadOnly/ReadOnly.test.d.ts +0 -1
  659. package/types/src/extensions/SideMenu/blockGeometry.browser.test.d.ts +0 -1
  660. package/types/src/extensions/SideMenu/blockGeometry.test.d.ts +0 -1
  661. package/types/src/extensions/SideMenu/sideMenuHover.test.d.ts +0 -1
  662. package/types/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.d.ts +0 -4
  663. package/types/src/extensions/SuggestionMenu/SuggestionMenu.test.d.ts +0 -1
  664. package/types/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.d.ts +0 -4
  665. package/types/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.d.ts +0 -1
  666. package/types/src/extensions/SyntaxHighlighting/inlineHighlight.test.d.ts +0 -1
  667. package/types/src/extensions/TableHandles/TableHandles.browser.test.d.ts +0 -1
  668. package/types/src/extensions/Versioning/Versioning.browser.test.d.ts +0 -1
  669. package/types/src/extensions/Versioning/Versioning.node.test.d.ts +0 -1
  670. package/types/src/extensions/Versioning/__test__/result.d.ts +0 -3
  671. package/types/src/extensions/Versioning/comparison.test.d.ts +0 -1
  672. package/types/src/extensions/Versioning/createVersioning.test.d.ts +0 -1
  673. package/types/src/extensions/Versioning/inMemoryVersioning.test.d.ts +0 -1
  674. package/types/src/extensions/Versioning/scrollScheduling.test.d.ts +0 -1
  675. package/types/src/extensions/Versioning/scrollToFirstChange.test.d.ts +0 -1
  676. package/types/src/extensions/blockDOM.browser.test.d.ts +0 -1
  677. package/types/src/extensions/blockDOM.test.d.ts +0 -1
  678. package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.d.ts +0 -4
  679. package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/blockIdentity.browser.test.d.ts +0 -1
  680. package/types/src/extensions/tiptap-extensions/Link/link.test.d.ts +0 -1
  681. package/types/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.d.ts +0 -4
  682. package/types/src/fonts/inter.browser.test.d.ts +0 -2
  683. package/types/src/pm-nodes/BlockContainer.test.d.ts +0 -1
  684. package/types/src/schema/blocks/children.test.d.ts +0 -1
  685. package/types/src/schema/blocks/createSpec.browser.test.d.ts +0 -1
  686. package/types/src/schema/blocks/createSpec.test.d.ts +0 -1
  687. package/types/src/schema/blocks/extendBlockSpec.test.d.ts +0 -1
  688. package/types/src/schema/blocks/frame.test.d.ts +0 -1
  689. package/types/src/schema/blocks/internal.test.d.ts +0 -1
  690. package/types/src/schema/blocks/meta.test.d.ts +0 -1
  691. package/types/src/schema/blocks/renderFrame.test.d.ts +0 -1
  692. package/types/src/schema/contentTypePropagation.test.d.ts +0 -1
  693. package/types/src/schema/dataAttributes.test.d.ts +0 -1
  694. package/types/src/schema/inlineContent/createSpec.test.d.ts +0 -1
  695. package/types/src/schema/nodeViewMutations.test.d.ts +0 -1
  696. package/types/src/schema/schema.test.d.ts +0 -1
  697. package/types/src/user/createUserStore.test.d.ts +0 -1
  698. package/types/src/user/userColors.test.d.ts +0 -1
  699. package/types/src/util/Store.test.d.ts +0 -1
  700. package/types/src/util/topo-sort.test.d.ts +0 -1
  701. package/types/src/y/comments/YjsThreadStore.test.d.ts +0 -1
  702. package/types/src/y/extensions/AttributionExtension.test.d.ts +0 -1
  703. package/types/src/y/extensions/DiffVersioningExtension.test.d.ts +0 -1
  704. package/types/src/y/extensions/EmptyDocBinding.test.d.ts +0 -1
  705. package/types/src/y/extensions/ForkYDoc.node.test.d.ts +0 -1
  706. package/types/src/y/extensions/ForkYDoc.test.d.ts +0 -1
  707. package/types/src/y/extensions/History.test.d.ts +0 -1
  708. package/types/src/y/extensions/RelativePositionMapping.test.d.ts +0 -1
  709. package/types/src/y/extensions/Versioning.node.test.d.ts +0 -1
  710. package/types/src/y/extensions/Versioning.test.d.ts +0 -1
  711. package/types/src/y/extensions/YSync.node.test.d.ts +0 -1
  712. package/types/src/y/extensions/YSyncRemount.test.d.ts +0 -1
  713. package/types/src/y/extensions/legacyYjsDocBinding.test.d.ts +0 -1
  714. package/types/src/y/extensions/nestingChanges.test.d.ts +0 -1
  715. package/types/src/y/extensions/persistentBlockGroups.test.d.ts +0 -1
  716. package/types/src/y/extensions/snapshotCodec.test.d.ts +0 -1
  717. package/types/src/y/extensions/snapshotPreview.test.d.ts +0 -1
  718. package/types/src/y/extensions/tableReshape.test.d.ts +0 -1
  719. package/types/src/y/extensions/v1BindingSnapshotDiff.test.d.ts +0 -1
  720. package/types/src/y/extensions/versionDiffAttribution.test.d.ts +0 -1
  721. package/types/src/y/extensions/versionDiffPerformance.test.d.ts +0 -1
  722. package/types/src/y/utils.test.d.ts +0 -1
  723. package/types/src/y/versioning/__test__/yhub.test.d.ts +0 -1
  724. package/types/src/yjs/comments/RESTYjsThreadStore.test.d.ts +0 -1
  725. package/types/src/yjs/comments/YjsThreadStore.test.d.ts +0 -1
  726. package/types/src/yjs/extensions/FixUpSchema.test.d.ts +0 -1
  727. package/types/src/yjs/extensions/ForkYDoc.browser.test.d.ts +0 -1
  728. package/types/src/yjs/extensions/ForkYDoc.node.test.d.ts +0 -1
  729. package/types/src/yjs/extensions/ForkYDoc.test.d.ts +0 -1
  730. package/types/src/yjs/extensions/RelativePositionMapping.test.d.ts +0 -1
  731. package/types/src/yjs/extensions/Versioning.test.d.ts +0 -1
  732. package/types/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.test.d.ts +0 -1
  733. package/types/src/yjs/utils.test.d.ts +0 -1
package/dist/yjs.cjs DELETED
@@ -1,2 +0,0 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./blocks-COVwe5Cf.cjs"),t=require("./BlockNoteExtension-DjEkXkR5.cjs"),n=require("./extensions-D_WkAfSt.cjs"),r=require("./ThreadStore-Bx-gSEh1.cjs");let i=require("prosemirror-model"),a=require("lib0/random"),o=require("@tiptap/pm/state"),s=require("y-prosemirror"),c=require("yjs");c=e.Lr(c,1);function l(e,t){let n=e.doc;if(!n)throw Error(`type does not have a ydoc`);if(e._item===null){let r=Array.from(n.share.keys()).find(t=>n.share.get(t)===e);if(r==null)throw Error(`type does not exist in other ydoc`);return t.get(r,e.constructor)}{let n=e._item,r=t.store.clients.get(n.id.client)??[],i=r[c.findIndexSS(r,n.id.clock)];if(!i)throw Error(`type does not exist in other ydoc`);let a=i.content;if(!a)throw Error(`type does not exist in other ydoc`);return a.type}}function u(t,n){let r=t.pmSchema.nodeFromJSON(n);return e.En(r)}function d(t,n){let r=n.map(n=>e.Ot(n,t.pmSchema));return t.pmSchema.topNodeType.create(null,t.pmSchema.nodes.blockGroup.create(null,r))}function f(t,n){let r=(0,s.yXmlFragmentToProseMirrorRootNode)(n,t.pmSchema);return e.En(r)}function p(e,t,n){return(0,s.prosemirrorToYXmlFragment)(d(e,t),n)}function m(e,t,n=`prosemirror`){return f(e,t.getXmlFragment(n))}function h(e,t,n=`prosemirror`){return(0,s.prosemirrorToYDoc)(d(e,t),n)}var g=t.t(({editor:t})=>(t.on(`create`,()=>{let n=t.pmSchema,r,a=n.nodes.doc.createAndFill;n.nodes.doc.createAndFill=((...e)=>{if(e[1])return a.apply(n.nodes.doc,e);if(r)return r;let t=a.apply(n.nodes.doc,e),o=JSON.parse(JSON.stringify(t.toJSON()));return o.content[0].content[0].attrs.id=`initialBlockId`,r=i.Node.fromJSON(n,o),r});let o=n.node;n.node=function(t,n,r,i){let a=typeof t==`string`?this.nodes[t]:t;return a&&e.In(this,a)&&Array.isArray(r)&&(r=r.map(e=>e?.isText&&e.marks.length?e.mark(a.allowedMarks(e.marks)):e)),o.call(this,t,n,r,i)}}),{key:`fixUpSchema`}));function _(e){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=[n/255,r/255,i/255].map(e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4);return .2126*a[0]+.7152*a[1]+.0722*a[2]<=.179}function v(e){let t=document.createElement(`span`);t.classList.add(`bn-collaboration-cursor__base`);let n=document.createElement(`span`);n.setAttribute(`contentedEditable`,`false`),n.classList.add(`bn-collaboration-cursor__caret`),n.setAttribute(`style`,`background-color: ${e.color}; color: ${_(e.color)?`white`:`black`}`);let r=document.createElement(`span`);return r.classList.add(`bn-collaboration-cursor__label`),r.setAttribute(`style`,`background-color: ${e.color}; color: ${_(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}var y=t.t(({options:e})=>{let t=new Map,n=e.provider&&`awareness`in e.provider&&typeof e.provider.awareness==`object`?e.provider.awareness:void 0;n&&`setLocalStateField`in n&&typeof n.setLocalStateField==`function`&&n.setLocalStateField(`user`,e.user);let r=({updated:e})=>{for(let n of e){let e=t.get(n);e&&(setTimeout(()=>{e.element.setAttribute(`data-active`,``)},10),e.hideTimeout&&clearTimeout(e.hideTimeout),t.set(n,{element:e.element,hideTimeout:setTimeout(()=>{e.element.removeAttribute(`data-active`)},2e3)}))}};return{key:`yCursor`,mount(){if(n&&e.showCursorLabels!==`always`&&`on`in n&&typeof n.on==`function`)return n.on(`change`,r),()=>{`off`in n&&typeof n.off==`function`&&n.off(`change`,r)}},prosemirrorPlugins:[n?(0,s.yCursorPlugin)(n,{selectionBuilder:s.defaultSelectionBuilder,cursorBuilder(n,r){let i=t.get(r);if(!i){let a=(e.renderCursor??v)(n);e.showCursorLabels!==`always`&&(a.addEventListener(`mouseenter`,()=>{let e=t.get(r);e.element.setAttribute(`data-active`,``),e.hideTimeout&&(clearTimeout(e.hideTimeout),t.set(r,{element:e.element,hideTimeout:void 0}))}),a.addEventListener(`mouseleave`,()=>{let e=t.get(r);t.set(r,{element:e.element,hideTimeout:setTimeout(()=>{e.element.removeAttribute(`data-active`)},2e3)})})),i={element:a,hideTimeout:void 0},t.set(r,i)}return i.element}}):void 0].filter(Boolean),dependsOn:[`ySync`],updateUser(e){n?.setLocalStateField(`user`,e)},getUser(){let e=n?.getLocalState();if(e)return e.user}}}),b=t.t(({options:e})=>({key:`ySync`,prosemirrorPlugins:[(0,s.ySyncPlugin)(e.fragment)],runsBefore:[`default`]})),x=t.t(()=>({key:`yUndo`,prosemirrorPlugins:[(0,s.yUndoPlugin)()],dependsOn:[`yCursor`,`ySync`],undoCommand:s.undoCommand,redoCommand:s.redoCommand})),S=t.t(({editor:e,options:n})=>{let r,i=t.n({isForked:!1});return{key:`yForkDoc`,store:i,fork({initialUpdate:t}={}){if(r)return;let a=n.fragment;if(!a)throw Error(`No fragment to fork from`);let o=new c.Doc;c.applyUpdate(o,t??c.encodeStateAsUpdate(a.doc));let u=l(a,o),d=s.yUndoPluginKey.getState(e.prosemirrorState)?.undoManager;r={undoHistory:d?{undoStack:d.undoStack,redoStack:d.redoStack}:void 0,originalFragment:a,forkedFragment:u,cursor:e.getExtension(y)};let f={...n,fragment:u};e.replaceExtension([`ySync`,`yCursor`,`yUndo`],[b(f),...d?[x()]:[]],{resetPluginStateFor:[s.ySyncPluginKey,s.yUndoPluginKey]}),n.provider?.awareness?.setLocalStateField(`cursor`,null),i.setState({isForked:!0})},replaceSnapshot(t){if(!r)throw Error(`Replacing a snapshot requires a forked document`);let i=new c.Doc;c.applyUpdate(i,t);let a=l(r.originalFragment,i),o=r.forkedFragment.doc;e.replaceExtension([`ySync`,`yUndo`],[b({...n,fragment:a}),...r.undoHistory?[x()]:[]],{resetPluginStateFor:[s.ySyncPluginKey,s.yUndoPluginKey]}),r.forkedFragment=a,o?.destroy()},merge({keepChanges:t}){if(!r)return;let{originalFragment:a,forkedFragment:o,undoHistory:l,cursor:u}=r;if(e.replaceExtension([`ySync`,`yCursor`,`yUndo`],[b(n),...u?[u]:[],...l?[x()]:[]],{resetPluginStateFor:[s.ySyncPluginKey,s.yUndoPluginKey]}),l){let t=s.yUndoPluginKey.getState(e.prosemirrorState).undoManager;t.undoStack=l.undoStack,t.redoStack=l.redoStack}if(t){let t=c.encodeStateAsUpdate(o.doc,c.encodeStateVector(a.doc));c.applyUpdate(a.doc,t,e)}r=void 0,o.doc.destroy(),i.setState({isForked:!1})}}}),C=t.t(({editor:e})=>({key:`yPositionMapping`,mapPosition:(t,n=`left`)=>{let r=s.ySyncPluginKey.getState(e.prosemirrorState);if(!r)throw Error(`YSync plugin state not found`);if(t===0)return()=>0;if(r.binding.type.length===0){let r=e.getExtension(`positionMapping`);if(!r)throw Error(`positionMapping extension is not available; cannot map position before sync`);return r.mapPosition(t,n)}let i=(0,s.absolutePositionToRelativePosition)(t+(n===`right`?1:-1),r.binding.type,r.binding.mapping);return()=>{let t=s.ySyncPluginKey.getState(e.prosemirrorState),r=t.binding.type,a=(0,s.relativePositionToAbsolutePosition)(r.doc,r,i,t.binding.mapping);if(a===null)throw Error(`Position not found, cannot track positions`);return a+(n===`right`?-1:1)}}})),w=(e,t)=>{t(e),e.forEach(e=>{e instanceof c.XmlElement&&w(e,t)})},T=[(t,n)=>{let r=new Map;return t.forEach(t=>{t instanceof c.XmlElement&&w(t,t=>{if(t.nodeName===`blockContainer`&&t.hasAttribute(`id`)){let n=t.getAttribute(`textColor`),i=t.getAttribute(`backgroundColor`),a={textColor:n===e.xt.textColor.default?void 0:n,backgroundColor:i===e.xt.backgroundColor.default?void 0:i};(a.textColor||a.backgroundColor)&&r.set(t.getAttribute(`id`),a)}})}),r.size!==0&&(n.doc.descendants((e,t)=>{if(e.type.name===`blockContainer`&&r.has(e.attrs.id)){let i=n.doc.nodeAt(t+1);if(!i)throw Error(`No element found`);n.setNodeMarkup(t+1,void 0,{...i.attrs,...r.get(e.attrs.id)})}}),!0)}],E=t.t(({options:e})=>{let t=!1,n=new o.PluginKey(`schemaMigration`);return{key:`schemaMigration`,prosemirrorPlugins:[new o.Plugin({key:n,appendTransaction:(n,r,i)=>{if(t||!n.some(e=>e.getMeta(`y-sync$`))||n.every(e=>!e.docChanged)||!e.fragment.firstChild)return;let a=i.tr;for(let t of T)t(e.fragment,a);if(t=!0,a.docChanged)return a}})]}}),D=t.t(({options:e})=>({key:`collaboration`,fragment:e.fragment,blockNoteExtensions:[g(),S(e),C(),E(e),y(e),b(e),x()]}));function O(e){return{...e,extensions:[...e.extensions??[],D(e.collaboration)],disableExtensions:[`history`,...e.disableExtensions??[]],initialContent:[{type:`paragraph`,id:`initialBlockId`}]}}function k(e){let t=new c.Map;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`);return t.set(`reactionsByUser`,new c.Map),t.set(`metadata`,e.metadata),t}function A(e){let t=new c.Map;t.set(`id`,e.id),t.set(`createdAt`,e.createdAt.getTime()),t.set(`updatedAt`,e.updatedAt.getTime());let n=new c.Array;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}function j(e){return{emoji:e.get(`emoji`),createdAt:new Date(e.get(`createdAt`)),userId:e.get(`userId`)}}function M(e){return[...e.values()].map(e=>j(e)).reduce((e,t)=>{let n=e.find(e=>e.emoji===t.emoji);return n?(n.userIds.push(t.userId),n.createdAt=new Date(Math.min(n.createdAt.getTime(),t.createdAt.getTime()))):e.push({emoji:t.emoji,createdAt:t.createdAt,userIds:[t.userId]}),e},[])}function N(e){return{type:`comment`,id:e.get(`id`),userId:e.get(`userId`),createdAt:new Date(e.get(`createdAt`)),updatedAt:new Date(e.get(`updatedAt`)),deletedAt:e.get(`deletedAt`)?new Date(e.get(`deletedAt`)):void 0,reactions:M(e.get(`reactionsByUser`)),metadata:e.get(`metadata`),body:e.get(`body`)}}function P(e){return{type:`thread`,id:e.get(`id`),createdAt:new Date(e.get(`createdAt`)),updatedAt:new Date(e.get(`updatedAt`)),comments:(e.get(`comments`)||[]).map(e=>N(e)),resolved:e.get(`resolved`),resolvedUpdatedAt:new Date(e.get(`resolvedUpdatedAt`)),resolvedBy:e.get(`resolvedBy`),metadata:e.get(`metadata`)}}var F=class extends r.t{threadsYMap;constructor(e,t){super(t),this.threadsYMap=e}getThread(e){let t=this.threadsYMap.get(e);if(!t)throw Error(`Thread not found`);return P(t)}getThreads(){let e=new Map;return this.threadsYMap.forEach((t,n)=>{t instanceof c.Map&&e.set(n,P(t))}),e}subscribe(e){let t=()=>{e(this.getThreads())};return this.threadsYMap.observeDeep(t),()=>{this.threadsYMap.unobserveDeep(t)}}},I=class extends F{BASE_URL;headers;constructor(e,t,n,r){super(n,r),this.BASE_URL=e,this.headers=t}doRequest=async(e,t,n)=>{let r=await fetch(`${this.BASE_URL}${e}`,{method:t,body:JSON.stringify(n),headers:{"Content-Type":`application/json`,...this.headers}});if(!r.ok)throw Error(`Failed to ${t} ${e}: ${r.statusText}`);return r.json()};addThreadToDocument=async e=>{let{threadId:t,selection:n}=e,r=s.ySyncPluginKey.getState(e.editor.prosemirrorState)?.binding,i=r?{head:(0,s.absolutePositionToRelativePosition)(n.head,r.type,r.mapping),anchor:(0,s.absolutePositionToRelativePosition)(n.anchor,r.type,r.mapping)}:void 0;return this.doRequest(`/${t}/addToDocument`,`POST`,{selection:{prosemirror:n,yjs:i}})};createThread=async e=>this.doRequest(``,`POST`,e);addComment=e=>{let{threadId:t,...n}=e;return this.doRequest(`/${t}/comments`,`POST`,n)};updateComment=e=>{let{threadId:t,commentId:n,...r}=e;return this.doRequest(`/${t}/comments/${n}`,`PUT`,r)};deleteComment=e=>{let{threadId:t,commentId:n,...r}=e;return this.doRequest(`/${t}/comments/${n}?soft=${!!r.softDelete}`,`DELETE`)};deleteThread=e=>this.doRequest(`/${e.threadId}`,`DELETE`);resolveThread=e=>this.doRequest(`/${e.threadId}/resolve`,`POST`);unresolveThread=e=>this.doRequest(`/${e.threadId}/unresolve`,`POST`);addReaction=e=>{let{threadId:t,commentId:n,...r}=e;return this.doRequest(`/${t}/comments/${n}/reactions`,`POST`,r)};deleteReaction=e=>this.doRequest(`/${e.threadId}/comments/${e.commentId}/reactions/${e.emoji}`,`DELETE`)},L=class extends F{userId;constructor(e,t,n){super(t,n),this.userId=e}transact=e=>async t=>this.threadsYMap.doc.transact(()=>e(t));createThread=this.transact(e=>{if(!this.auth.canCreateThread())throw Error(`Not authorized`);let t=new Date,n={type:`comment`,id:(0,a.uuidv4)(),userId:this.userId,createdAt:t,updatedAt:t,reactions:[],metadata:e.initialComment.metadata,body:e.initialComment.body},r={type:`thread`,id:(0,a.uuidv4)(),createdAt:t,updatedAt:t,comments:[n],resolved:!1,metadata:e.metadata};return this.threadsYMap.set(r.id,A(r)),r});addThreadToDocument=void 0;addComment=this.transact(e=>{let t=this.threadsYMap.get(e.threadId);if(!t)throw Error(`Thread not found`);if(!this.auth.canAddComment(P(t)))throw Error(`Not authorized`);let n=new Date,r={type:`comment`,id:(0,a.uuidv4)(),userId:this.userId,createdAt:n,updatedAt:n,deletedAt:void 0,reactions:[],metadata:e.comment.metadata,body:e.comment.body};return t.get(`comments`).push([k(r)]),t.set(`updatedAt`,new Date().getTime()),r});updateComment=this.transact(e=>{let t=this.threadsYMap.get(e.threadId);if(!t)throw Error(`Thread not found`);let n=R(t.get(`comments`),t=>t.get(`id`)===e.commentId);if(n===-1)throw Error(`Comment not found`);let r=t.get(`comments`).get(n);if(!this.auth.canUpdateComment(N(r)))throw Error(`Not authorized`);r.set(`body`,e.comment.body),r.set(`updatedAt`,new Date().getTime()),r.set(`metadata`,e.comment.metadata)});deleteComment=this.transact(e=>{let t=this.threadsYMap.get(e.threadId);if(!t)throw Error(`Thread not found`);let n=R(t.get(`comments`),t=>t.get(`id`)===e.commentId);if(n===-1)throw Error(`Comment not found`);let r=t.get(`comments`).get(n);if(!this.auth.canDeleteComment(N(r)))throw Error(`Not authorized`);if(r.get(`deletedAt`))throw Error(`Comment already deleted`);e.softDelete?(r.set(`deletedAt`,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`,new Date().getTime()):this.threadsYMap.delete(e.threadId)),t.set(`updatedAt`,new Date().getTime())});deleteThread=this.transact(e=>{if(!this.auth.canDeleteThread(P(this.threadsYMap.get(e.threadId))))throw Error(`Not authorized`);this.threadsYMap.delete(e.threadId)});resolveThread=this.transact(e=>{let t=this.threadsYMap.get(e.threadId);if(!t)throw Error(`Thread not found`);if(!this.auth.canResolveThread(P(t)))throw Error(`Not authorized`);t.set(`resolved`,!0),t.set(`resolvedUpdatedAt`,new Date().getTime()),t.set(`resolvedBy`,this.userId)});unresolveThread=this.transact(e=>{let t=this.threadsYMap.get(e.threadId);if(!t)throw Error(`Thread not found`);if(!this.auth.canUnresolveThread(P(t)))throw Error(`Not authorized`);t.set(`resolved`,!1),t.set(`resolvedUpdatedAt`,new Date().getTime())});addReaction=this.transact(e=>{let t=this.threadsYMap.get(e.threadId);if(!t)throw Error(`Thread not found`);let n=R(t.get(`comments`),t=>t.get(`id`)===e.commentId);if(n===-1)throw Error(`Comment not found`);let r=t.get(`comments`).get(n);if(!this.auth.canAddReaction(N(r),e.emoji))throw Error(`Not authorized`);let i=new Date,a=`${this.userId}-${e.emoji}`,o=r.get(`reactionsByUser`);if(!o.has(a)){let t=new c.Map;t.set(`emoji`,e.emoji),t.set(`createdAt`,i.getTime()),t.set(`userId`,this.userId),o.set(a,t)}});deleteReaction=this.transact(e=>{let t=this.threadsYMap.get(e.threadId);if(!t)throw Error(`Thread not found`);let n=R(t.get(`comments`),t=>t.get(`id`)===e.commentId);if(n===-1)throw Error(`Comment not found`);let r=t.get(`comments`).get(n);if(!this.auth.canDeleteReaction(N(r),e.emoji))throw Error(`Not authorized`);let i=`${this.userId}-${e.emoji}`;r.get(`reactionsByUser`).delete(i)})};function R(e,t){for(let n=0;n<e.length;n++)if(t(e.get(n)))return n;return-1}function z(e){return n.i(t=>({adapter:{get supportsComparison(){return t.getExtension(`diffVersioning`)!==void 0},open(){let e=t.getExtension(D);if(!e)throw Error(`Yjs versioning requires Yjs collaboration`);return B(t,e.fragment).open()}},...e}))()}function B(e,t){return{get supportsComparison(){return e.getExtension(`diffVersioning`)!==void 0},open(){let n=e.getExtension(S);if(!n||n.store.state.isForked||s.ySyncPluginKey.getState(e.prosemirrorState)?.type!==t)throw Error(`Versioning requires an active live binding and an available fork`);let r={content:c.encodeStateAsUpdate(t.doc),capturedAt:Date.now()};try{n.fork()}catch(e){throw n.merge({keepChanges:!1}),e}let i=!1;return{current:r,show({content:r,comparison:a}){if(i)throw Error(`Version view is closed`);if(n.replaceSnapshot(r),a){let n=e.getExtension(`diffVersioning`);if(!n)throw Error(`Version comparison requires a diff renderer`);function o(n){let r=new c.Doc;try{return c.applyUpdate(r,n),f(e,l(t,r))}finally{r.destroy()}}n.renderDiff(o(r),o(a.content))}},close(){i||=(n.merge({keepChanges:!1}),!0)}}}}}exports.CollaborationExtension=D,exports.ForkYDocExtension=S,exports.RESTYjsThreadStore=I,exports.RelativePositionMappingExtension=C,exports.SchemaMigration=E,exports.YCursorExtension=y,exports.YSyncExtension=b,exports.YUndoExtension=x,exports.YjsThreadStore=L,exports.YjsThreadStoreBase=F,exports.YjsVersioningExtension=z,exports._blocksToProsemirrorNode=d,exports._prosemirrorJSONToBlocks=u,exports.blocksToYDoc=h,exports.blocksToYXmlFragment=p,exports.createYjsVersionView=B,exports.findTypeInOtherYdoc=l,exports.withCollaboration=O,exports.yDocToBlocks=m,exports.yXmlFragmentToBlocks=f;
2
- //# sourceMappingURL=yjs.cjs.map
package/dist/yjs.cjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"yjs.cjs","names":[],"sources":["../src/yjs/utils.ts","../src/yjs/extensions/FixUpSchema.ts","../src/yjs/extensions/YCursorPlugin.ts","../src/yjs/extensions/YSync.ts","../src/yjs/extensions/YUndo.ts","../src/yjs/extensions/ForkYDoc.ts","../src/yjs/extensions/RelativePositionMapping.ts","../src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.ts","../src/yjs/extensions/schemaMigration/migrationRules/index.ts","../src/yjs/extensions/schemaMigration/SchemaMigration.ts","../src/yjs/extensions/index.ts","../src/yjs/comments/yjsHelpers.ts","../src/yjs/comments/YjsThreadStoreBase.ts","../src/yjs/comments/RESTYjsThreadStore.ts","../src/yjs/comments/YjsThreadStore.ts","../src/yjs/extensions/Versioning.ts"],"sourcesContent":["import {\n prosemirrorToYDoc,\n prosemirrorToYXmlFragment,\n yXmlFragmentToProseMirrorRootNode,\n} from \"y-prosemirror\";\nimport * as Y from \"yjs\";\n\nimport {\n type Block,\n type BlockNoteEditor,\n type BlockSchema,\n type InlineContentSchema,\n type PartialBlock,\n type StyleSchema,\n blockToNode,\n docToBlocks,\n} from \"../index.js\";\n\n/**\n * Find a Y.AbstractType in another Y.Doc that corresponds to the same\n * logical type in the original doc.\n */\nexport function findTypeInOtherYdoc<T extends Y.AbstractType<any>>(\n ytype: T,\n otherYdoc: Y.Doc,\n): T {\n const ydoc = ytype.doc;\n if (!ydoc) {\n throw new Error(\"type does not have a ydoc\");\n }\n if (ytype._item === null) {\n const rootKey = Array.from(ydoc.share.keys()).find(\n (key) => ydoc.share.get(key) === ytype,\n );\n if (rootKey == null) {\n throw new Error(\"type does not exist in other ydoc\");\n }\n return otherYdoc.get(rootKey, ytype.constructor as new () => T) as T;\n } else {\n const ytypeItem = ytype._item;\n const otherStructs = otherYdoc.store.clients.get(ytypeItem.id.client) ?? [];\n const itemIndex = Y.findIndexSS(otherStructs, ytypeItem.id.clock);\n const otherItem = otherStructs[itemIndex] as Y.Item | undefined;\n if (!otherItem) {\n throw new Error(\"type does not exist in other ydoc\");\n }\n const otherContent = otherItem.content as Y.ContentType | undefined;\n if (!otherContent) {\n throw new Error(\"type does not exist in other ydoc\");\n }\n return otherContent.type as T;\n }\n}\n\n/**\n * Turn Prosemirror JSON to BlockNote style JSON\n * @param editor BlockNote editor\n * @param json Prosemirror JSON\n * @returns BlockNote style JSON\n */\nexport function _prosemirrorJSONToBlocks<\n BSchema extends BlockSchema,\n ISchema extends InlineContentSchema,\n SSchema extends StyleSchema,\n>(editor: BlockNoteEditor<BSchema, ISchema, SSchema>, json: any) {\n // note: theoretically this should also be possible without creating prosemirror nodes,\n // but this is definitely the easiest way\n const doc = editor.pmSchema.nodeFromJSON(json);\n return docToBlocks<BSchema, ISchema, SSchema>(doc);\n}\n\n/**\n * Turn BlockNote JSON to Prosemirror node / state\n * @param editor BlockNote editor\n * @param blocks BlockNote blocks\n * @returns Prosemirror root node\n */\nexport function _blocksToProsemirrorNode<\n BSchema extends BlockSchema,\n ISchema extends InlineContentSchema,\n SSchema extends StyleSchema,\n>(\n editor: BlockNoteEditor<BSchema, ISchema, SSchema>,\n blocks: PartialBlock<BSchema, ISchema, SSchema>[],\n) {\n const pmNodes = blocks.map((b) => blockToNode(b, editor.pmSchema));\n\n const doc = editor.pmSchema.topNodeType.create(\n null,\n editor.pmSchema.nodes[\"blockGroup\"].create(null, pmNodes),\n );\n return doc;\n}\n\n/** YJS / BLOCKNOTE conversions */\n\n/**\n * Turn a Y.XmlFragment collaborative doc into a BlockNote document (BlockNote style JSON of all blocks)\n * @param editor BlockNote editor\n * @param xmlFragment Y.XmlFragment\n * @returns BlockNote document (BlockNote style JSON of all blocks)\n */\nexport function yXmlFragmentToBlocks<\n BSchema extends BlockSchema,\n ISchema extends InlineContentSchema,\n SSchema extends StyleSchema,\n>(\n editor: BlockNoteEditor<BSchema, ISchema, SSchema>,\n xmlFragment: Y.XmlFragment,\n) {\n const pmNode = yXmlFragmentToProseMirrorRootNode(\n xmlFragment,\n editor.pmSchema,\n );\n return docToBlocks<BSchema, ISchema, SSchema>(pmNode);\n}\n\n/**\n * Convert blocks to a Y.XmlFragment\n *\n * This can be used when importing existing content to Y.Doc for the first time,\n * note that this should not be used to rehydrate a Y.Doc from a database once\n * collaboration has begun as all history will be lost\n *\n * @param editor BlockNote editor\n * @param blocks the blocks to convert\n * @param xmlFragment XML fragment name\n * @returns Y.XmlFragment\n */\nexport function blocksToYXmlFragment<\n BSchema extends BlockSchema,\n ISchema extends InlineContentSchema,\n SSchema extends StyleSchema,\n>(\n editor: BlockNoteEditor<BSchema, ISchema, SSchema>,\n blocks: Block<BSchema, ISchema, SSchema>[],\n xmlFragment?: Y.XmlFragment,\n) {\n return prosemirrorToYXmlFragment(\n _blocksToProsemirrorNode(editor, blocks),\n xmlFragment,\n );\n}\n\n/**\n * Turn a Y.Doc collaborative doc into a BlockNote document (BlockNote style JSON of all blocks)\n * @param editor BlockNote editor\n * @param ydoc Y.Doc\n * @param xmlFragment XML fragment name\n * @returns BlockNote document (BlockNote style JSON of all blocks)\n */\nexport function yDocToBlocks<\n BSchema extends BlockSchema,\n ISchema extends InlineContentSchema,\n SSchema extends StyleSchema,\n>(\n editor: BlockNoteEditor<BSchema, ISchema, SSchema>,\n ydoc: Y.Doc,\n xmlFragment = \"prosemirror\",\n) {\n return yXmlFragmentToBlocks(editor, ydoc.getXmlFragment(xmlFragment));\n}\n\n/**\n * This can be used when importing existing content to Y.Doc for the first time,\n * note that this should not be used to rehydrate a Y.Doc from a database once\n * collaboration has begun as all history will be lost\n *\n * @param editor BlockNote editor\n * @param blocks the blocks to convert\n * @param xmlFragment XML fragment name\n */\nexport function blocksToYDoc<\n BSchema extends BlockSchema,\n ISchema extends InlineContentSchema,\n SSchema extends StyleSchema,\n>(\n editor: BlockNoteEditor<BSchema, ISchema, SSchema>,\n blocks: PartialBlock<BSchema, ISchema, SSchema>[],\n xmlFragment = \"prosemirror\",\n) {\n return prosemirrorToYDoc(\n _blocksToProsemirrorNode(editor, blocks),\n xmlFragment,\n );\n}\n","import { Attrs, Fragment, Mark, Node, NodeType } from \"prosemirror-model\";\n\nimport { isPlainContentNodeType } from \"../../api/pmUtil.js\";\nimport { createExtension } from \"../../editor/BlockNoteExtension.js\";\n\n// Collaboration-only patches to the live ProseMirror schema. Both are applied\n// once on `create`, before y-prosemirror binds and reconstructs the document.\nexport const FixUpSchemaExtension = createExtension(({ editor }) => {\n editor.on(\"create\", () => {\n const schema = editor.pmSchema;\n\n // 1. Preserve the initial block id.\n // When y-prosemirror creates an empty document, the `blockContainer` node is created with an `id` of `null`.\n // This causes the unique id extension to generate a new id for the initial block, which is not what we want\n // Since it will be randomly generated & cause there to be more updates to the ydoc\n // This is a hack to make it so that anytime `schema.doc.createAndFill` is called, the initial block id is already set to \"initialBlockId\"\n let cache: Node | undefined = undefined;\n // eslint-disable-next-line @typescript-eslint/unbound-method -- intentionally saving reference for monkey-patching\n const oldCreateAndFill = schema.nodes.doc.createAndFill;\n schema.nodes.doc.createAndFill = ((...args: any) => {\n // Only cache empty-document creation. Content renderers also call this\n // method, and their supplied content must not become the empty skeleton.\n if (args[1]) {\n return oldCreateAndFill.apply(schema.nodes.doc, args);\n }\n if (cache) {\n return cache;\n }\n const ret = oldCreateAndFill.apply(schema.nodes.doc, args)!;\n\n // create a copy that we can mutate (otherwise, assigning attrs is not safe and corrupts the pm state)\n const jsonNode = JSON.parse(JSON.stringify(ret.toJSON()));\n // The first fill of the doc's blockGroup is always a `blockContainer`:\n // layout block nodes are clamped below its priority\n // (`layoutNodePriority`) precisely so auto-fill picks it first. If\n // that ever stops holding, throwing here is better than silently\n // leaving the id unset, which would let every peer generate its own\n // initial block id.\n jsonNode.content[0].content[0].attrs.id = \"initialBlockId\";\n\n cache = Node.fromJSON(schema, jsonNode);\n return cache;\n }) as unknown as typeof schema.nodes.doc.createAndFill;\n\n // 2. Drop marks a plain block no longer allows, instead of deleting the block.\n // When a block's content type changes across BlockNote versions — e.g. a\n // `codeBlock` that was `\"inline\"` (formatting marks like bold allowed) and is\n // now `\"plain\"` (only the `\"annotation\"` mark group: comments + suggestions) —\n // old Yjs documents carry text with marks the new node type disallows.\n //\n // y-prosemirror rebuilds each block by calling `schema.node(nodeName, attrs,\n // children)`, where `children` are text nodes that may still carry those\n // disallowed marks. `createChecked` then throws, and y-prosemirror's error\n // handler DELETES the whole block from the Yjs doc — a deletion that propagates\n // to every peer (data loss).\n //\n // Rather than mutating the Yjs doc to strip those marks, we leave them in place\n // (marks are just format attributes; they don't affect position counting, so\n // editing text is unaffected) and simply never materialize the disallowed ones\n // into ProseMirror. We do that by wrapping `schema.node` to filter each text\n // child's marks through the parent node type's `allowedMarks` before the node\n // is built. The wrapper is scoped to plain-content blocks (the only place this\n // migration applies); all other node types pass through untouched.\n //\n // NOTE: this covers marks that EXIST in the schema but aren't allowed on the\n // node. A mark whose type is entirely absent from the schema still hits\n // y-prosemirror's earlier `schema.mark` throw (and delete) path — that's a\n // different migration scenario and is out of scope here.\n // eslint-disable-next-line @typescript-eslint/unbound-method -- intentionally saving reference for monkey-patching\n const originalNode = schema.node;\n schema.node = function (\n this: typeof schema,\n type: string | NodeType,\n attrs?: Attrs | null,\n content?: Fragment | Node | readonly Node[],\n marks?: readonly Mark[],\n ) {\n const nodeType = typeof type === \"string\" ? this.nodes[type] : type;\n // y-prosemirror always passes `content` as a plain array of nodes; only\n // touch text children that carry marks.\n if (\n nodeType &&\n isPlainContentNodeType(this, nodeType) &&\n Array.isArray(content)\n ) {\n content = (content as readonly Node[]).map((child) =>\n child?.isText && child.marks.length\n ? child.mark(nodeType.allowedMarks(child.marks))\n : child,\n );\n }\n return originalNode.call(this, type, attrs, content, marks);\n } as typeof schema.node;\n });\n\n return {\n key: \"fixUpSchema\",\n } as const;\n});\n","import { defaultSelectionBuilder, yCursorPlugin } from \"y-prosemirror\";\nimport {\n createExtension,\n ExtensionOptions,\n} from \"../../editor/BlockNoteExtension.js\";\nimport type { CollaborationOptions } from \"./index.js\";\n\nexport type CollaborationUser = {\n id?: string;\n name: string;\n color: string;\n [key: string]: unknown;\n};\n\n/**\n * Determine whether the foreground color should be white or black based on a provided background color\n * Inspired by: https://stackoverflow.com/a/3943023\n */\nfunction isDarkColor(bgColor: string): boolean {\n const color = bgColor.charAt(0) === \"#\" ? bgColor.substring(1, 7) : bgColor;\n const r = parseInt(color.substring(0, 2), 16); // hexToR\n const g = parseInt(color.substring(2, 4), 16); // hexToG\n const b = parseInt(color.substring(4, 6), 16); // hexToB\n const uicolors = [r / 255, g / 255, b / 255];\n const c = uicolors.map((col) => {\n if (col <= 0.03928) {\n return col / 12.92;\n }\n return Math.pow((col + 0.055) / 1.055, 2.4);\n });\n const L = 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2];\n return L <= 0.179;\n}\n\nfunction defaultCursorRender(user: CollaborationUser) {\n const cursorElement = document.createElement(\"span\");\n\n cursorElement.classList.add(\"bn-collaboration-cursor__base\");\n\n const caretElement = document.createElement(\"span\");\n caretElement.setAttribute(\"contentedEditable\", \"false\");\n caretElement.classList.add(\"bn-collaboration-cursor__caret\");\n caretElement.setAttribute(\n \"style\",\n `background-color: ${user.color}; color: ${\n isDarkColor(user.color) ? \"white\" : \"black\"\n }`,\n );\n\n const labelElement = document.createElement(\"span\");\n\n labelElement.classList.add(\"bn-collaboration-cursor__label\");\n labelElement.setAttribute(\n \"style\",\n `background-color: ${user.color}; color: ${\n isDarkColor(user.color) ? \"white\" : \"black\"\n }`,\n );\n labelElement.insertBefore(document.createTextNode(user.name), null);\n\n caretElement.insertBefore(labelElement, null);\n\n cursorElement.insertBefore(document.createTextNode(\"\\u2060\"), null); // Non-breaking space\n cursorElement.insertBefore(caretElement, null);\n cursorElement.insertBefore(document.createTextNode(\"\\u2060\"), null); // Non-breaking space\n\n return cursorElement;\n}\n\nexport const YCursorExtension = createExtension(\n ({ options }: ExtensionOptions<CollaborationOptions>) => {\n const recentlyUpdatedCursors = new Map();\n const awareness =\n options.provider &&\n \"awareness\" in options.provider &&\n typeof options.provider.awareness === \"object\"\n ? options.provider.awareness\n : undefined;\n if (awareness) {\n if (\n \"setLocalStateField\" in awareness &&\n typeof awareness.setLocalStateField === \"function\"\n ) {\n awareness.setLocalStateField(\"user\", options.user);\n }\n }\n\n const handleAwarenessChange = ({\n updated,\n }: {\n added: Array<number>;\n updated: Array<number>;\n removed: Array<number>;\n }) => {\n for (const clientID of updated) {\n const cursor = recentlyUpdatedCursors.get(clientID);\n\n if (cursor) {\n setTimeout(() => {\n cursor.element.setAttribute(\"data-active\", \"\");\n }, 10);\n\n if (cursor.hideTimeout) {\n clearTimeout(cursor.hideTimeout);\n }\n\n recentlyUpdatedCursors.set(clientID, {\n element: cursor.element,\n hideTimeout: setTimeout(() => {\n cursor.element.removeAttribute(\"data-active\");\n }, 2000),\n });\n }\n }\n };\n\n return {\n key: \"yCursor\",\n mount() {\n if (\n awareness &&\n options.showCursorLabels !== \"always\" &&\n \"on\" in awareness &&\n typeof awareness.on === \"function\"\n ) {\n awareness.on(\"change\", handleAwarenessChange);\n\n return () => {\n if (\"off\" in awareness && typeof awareness.off === \"function\") {\n awareness.off(\"change\", handleAwarenessChange);\n }\n };\n }\n\n return undefined;\n },\n prosemirrorPlugins: [\n awareness\n ? yCursorPlugin(awareness, {\n selectionBuilder: defaultSelectionBuilder,\n cursorBuilder(user: CollaborationUser, clientID: number) {\n let cursorData = recentlyUpdatedCursors.get(clientID);\n\n if (!cursorData) {\n const cursorElement = (\n options.renderCursor ?? defaultCursorRender\n )(user);\n\n if (options.showCursorLabels !== \"always\") {\n cursorElement.addEventListener(\"mouseenter\", () => {\n const cursor = recentlyUpdatedCursors.get(clientID)!;\n cursor.element.setAttribute(\"data-active\", \"\");\n\n if (cursor.hideTimeout) {\n clearTimeout(cursor.hideTimeout);\n recentlyUpdatedCursors.set(clientID, {\n element: cursor.element,\n hideTimeout: undefined,\n });\n }\n });\n\n cursorElement.addEventListener(\"mouseleave\", () => {\n const cursor = recentlyUpdatedCursors.get(clientID)!;\n\n recentlyUpdatedCursors.set(clientID, {\n element: cursor.element,\n hideTimeout: setTimeout(() => {\n cursor.element.removeAttribute(\"data-active\");\n }, 2000),\n });\n });\n }\n\n cursorData = {\n element: cursorElement,\n hideTimeout: undefined,\n };\n\n recentlyUpdatedCursors.set(clientID, cursorData);\n }\n\n return cursorData.element;\n },\n })\n : undefined,\n ].filter(Boolean),\n dependsOn: [\"ySync\"],\n updateUser(user: { name: string; color: string; [key: string]: string }) {\n awareness?.setLocalStateField(\"user\", user);\n },\n getUser(): CollaborationUser | undefined {\n const state = awareness?.getLocalState();\n if (!state) {\n return undefined;\n }\n return state[\"user\"];\n },\n } as const;\n },\n);\n","import { ySyncPlugin } from \"y-prosemirror\";\nimport {\n ExtensionOptions,\n createExtension,\n} from \"../../editor/BlockNoteExtension.js\";\nimport type { CollaborationOptions } from \"./index.js\";\n\nexport const YSyncExtension = createExtension(\n ({ options }: ExtensionOptions<Pick<CollaborationOptions, \"fragment\">>) => {\n return {\n key: \"ySync\",\n prosemirrorPlugins: [ySyncPlugin(options.fragment)],\n runsBefore: [\"default\"],\n } as const;\n },\n);\n","import { redoCommand, undoCommand, yUndoPlugin } from \"y-prosemirror\";\nimport { createExtension } from \"../../editor/BlockNoteExtension.js\";\n\nexport const YUndoExtension = createExtension(() => {\n return {\n key: \"yUndo\",\n prosemirrorPlugins: [yUndoPlugin()],\n dependsOn: [\"yCursor\", \"ySync\"],\n undoCommand: undoCommand,\n redoCommand: redoCommand,\n } as const;\n});\n","import { ySyncPluginKey, yUndoPluginKey } from \"y-prosemirror\";\nimport * as Y from \"yjs\";\nimport {\n createExtension,\n createStore,\n ExtensionOptions,\n} from \"../../editor/BlockNoteExtension.js\";\nimport type { CollaborationOptions } from \"./index.js\";\nimport { YCursorExtension } from \"./YCursorPlugin.js\";\nimport { YSyncExtension } from \"./YSync.js\";\nimport { YUndoExtension } from \"./YUndo.js\";\nimport { findTypeInOtherYdoc } from \"../utils.js\";\n\nexport const ForkYDocExtension = createExtension(\n ({ editor, options }: ExtensionOptions<CollaborationOptions>) => {\n let forkedState:\n | {\n originalFragment: Y.XmlFragment;\n undoHistory:\n | {\n undoStack: Y.UndoManager[\"undoStack\"];\n redoStack: Y.UndoManager[\"redoStack\"];\n }\n | undefined;\n forkedFragment: Y.XmlFragment;\n cursor: ReturnType<ReturnType<typeof YCursorExtension>> | undefined;\n }\n | undefined = undefined;\n\n const store = createStore({ isForked: false });\n\n return {\n key: \"yForkDoc\",\n store,\n /**\n * Fork the Y.js document from syncing to the remote,\n * allowing modifications to the document without affecting the remote.\n * These changes can later be rolled back or applied to the remote.\n */\n fork({\n /**\n * The initial update to apply to the forked document.\n * If not provided, the current document state is used.\n */\n initialUpdate,\n }: {\n initialUpdate?: Uint8Array;\n } = {}) {\n if (forkedState) {\n return;\n }\n\n const originalFragment = options.fragment;\n\n if (!originalFragment) {\n throw new Error(\"No fragment to fork from\");\n }\n\n const doc = new Y.Doc();\n // Copy the original document (or apply the provided update) to a new Yjs document\n Y.applyUpdate(\n doc,\n initialUpdate ?? Y.encodeStateAsUpdate(originalFragment.doc!),\n );\n\n // Find the forked fragment in the new Yjs document\n const forkedFragment = findTypeInOtherYdoc(originalFragment, doc);\n\n // Version previews detach undo before forking. Keep it absent through\n // snapshot replacement and merge; the preview owner reinstalls it.\n const originalUndoManager = yUndoPluginKey.getState(\n editor.prosemirrorState,\n )?.undoManager;\n forkedState = {\n undoHistory: originalUndoManager\n ? {\n undoStack: originalUndoManager.undoStack,\n redoStack: originalUndoManager.redoStack,\n }\n : undefined,\n originalFragment,\n forkedFragment,\n cursor: editor.getExtension(YCursorExtension),\n };\n\n const newOptions = {\n ...options,\n fragment: forkedFragment,\n };\n\n // Atomically swap the yjs plugins to avoid re-entrant dispatch issues\n // where y-prosemirror's view hooks can dispatch a transaction between\n // separate unregister/register calls, re-introducing stale plugins.\n editor.replaceExtension(\n [\"ySync\", \"yCursor\", \"yUndo\"],\n [\n YSyncExtension(newOptions),\n // No need to register the cursor plugin again, it's a local fork\n ...(originalUndoManager ? [YUndoExtension()] : []),\n ],\n { resetPluginStateFor: [ySyncPluginKey, yUndoPluginKey] },\n );\n options.provider?.awareness?.setLocalStateField(\"cursor\", null);\n\n // Tell the store that the editor is now forked\n store.setState({ isForked: true });\n },\n\n /** Replace only the local fork, retaining live restoration state. */\n replaceSnapshot(initialUpdate: Uint8Array) {\n if (!forkedState) {\n throw new Error(\"Replacing a snapshot requires a forked document\");\n }\n const doc = new Y.Doc();\n Y.applyUpdate(doc, initialUpdate);\n const fragment = findTypeInOtherYdoc(forkedState.originalFragment, doc);\n const oldDoc = forkedState.forkedFragment.doc;\n editor.replaceExtension(\n [\"ySync\", \"yUndo\"],\n [\n YSyncExtension({ ...options, fragment }),\n ...(forkedState.undoHistory ? [YUndoExtension()] : []),\n ],\n { resetPluginStateFor: [ySyncPluginKey, yUndoPluginKey] },\n );\n forkedState.forkedFragment = fragment;\n oldDoc?.destroy();\n },\n\n /**\n * Resume syncing the Y.js document to the remote\n * If `keepChanges` is true, any changes that have been made to the forked document will be applied to the original document.\n * Otherwise, the original document will be restored and the changes will be discarded.\n */\n merge({ keepChanges }: { keepChanges: boolean }) {\n if (!forkedState) {\n return;\n }\n\n const { originalFragment, forkedFragment, undoHistory, cursor } =\n forkedState;\n\n // Atomically swap the forked plugins back to the original ones\n editor.replaceExtension(\n [\"ySync\", \"yCursor\", \"yUndo\"],\n [\n YSyncExtension(options),\n ...(cursor ? [cursor] : []),\n ...(undoHistory ? [YUndoExtension()] : []),\n ],\n { resetPluginStateFor: [ySyncPluginKey, yUndoPluginKey] },\n );\n if (undoHistory) {\n const undoManager = yUndoPluginKey.getState(\n editor.prosemirrorState,\n )!.undoManager;\n undoManager.undoStack = undoHistory.undoStack;\n undoManager.redoStack = undoHistory.redoStack;\n }\n if (keepChanges) {\n // Apply any changes that have been made to the fork, onto the original doc\n const update = Y.encodeStateAsUpdate(\n forkedFragment.doc!,\n Y.encodeStateVector(originalFragment.doc!),\n );\n // Keep the existing editor origin for the merged update.\n Y.applyUpdate(originalFragment.doc!, update, editor);\n }\n // Reset the forked state\n forkedState = undefined;\n forkedFragment.doc!.destroy();\n // Tell the store that the editor is no longer forked\n store.setState({ isForked: false });\n },\n } as const;\n },\n);\n","import {\n absolutePositionToRelativePosition,\n relativePositionToAbsolutePosition,\n ySyncPluginKey,\n} from \"y-prosemirror\";\nimport { createExtension } from \"../../editor/BlockNoteExtension.js\";\nimport type { PositionMappingExtension } from \"../../extensions/index.js\";\n\nexport const RelativePositionMappingExtension = createExtension(\n ({ editor }) => {\n return {\n key: \"yPositionMapping\",\n mapPosition: (position: number, side: \"left\" | \"right\" = \"left\") => {\n const ySyncPluginState = ySyncPluginKey.getState(\n editor.prosemirrorState,\n );\n if (!ySyncPluginState) {\n throw new Error(\"YSync plugin state not found\");\n }\n\n // 0 is a special case & always should map to itself\n if (position === 0) {\n return () => 0;\n }\n\n // If the document is empty, it has not been synced yet\n if (ySyncPluginState.binding.type.length === 0) {\n // so, we just fallback to the prosemirror position mapping extension\n // If a remote transaction or sync happens in this case. The position map will be invalidated,\n // and the positions will be moved to the end of the document\n // This is acceptable, because the document had not been synced so there are no positions to map properly into\n const fallback =\n editor.getExtension<typeof PositionMappingExtension>(\n \"positionMapping\",\n );\n if (!fallback) {\n throw new Error(\n \"positionMapping extension is not available; cannot map position before sync\",\n );\n }\n return fallback.mapPosition(position, side);\n }\n\n const relativePosition = absolutePositionToRelativePosition(\n position + (side === \"right\" ? 1 : -1),\n ySyncPluginState.binding.type,\n ySyncPluginState.binding.mapping,\n );\n\n return () => {\n const curYSyncPluginState = ySyncPluginKey.getState(\n editor.prosemirrorState,\n ) as typeof ySyncPluginState;\n // Resolve against the doc that owns the currently bound type, and not\n // against `curYSyncPluginState.doc`. Those can point at different\n // Y.Docs (e.g. right after forking the doc, see `ForkYDocExtension`),\n // in which case the resolved type wouldn't be part of the bound\n // fragment and the position would be reported as \"not found\".\n const boundType = curYSyncPluginState.binding.type;\n const pos = relativePositionToAbsolutePosition(\n boundType.doc,\n boundType,\n relativePosition,\n curYSyncPluginState.binding.mapping,\n );\n\n // This can happen if the element is garbage collected\n if (pos === null) {\n throw new Error(\"Position not found, cannot track positions\");\n }\n\n return pos + (side === \"right\" ? -1 : 1);\n };\n },\n } as const;\n },\n);\n","import * as Y from \"yjs\";\n\nimport { MigrationRule } from \"./migrationRule.js\";\nimport { defaultProps } from \"../../../../blocks/defaultProps.js\";\n\n// Helper function to recursively traverse a `Y.XMLElement` and its descendant\n// elements.\nconst traverseElement = (\n rootElement: Y.XmlElement,\n cb: (element: Y.XmlElement) => void,\n) => {\n cb(rootElement);\n rootElement.forEach((element) => {\n if (element instanceof Y.XmlElement) {\n traverseElement(element, cb);\n }\n });\n};\n\n// Moves `textColor` and `backgroundColor` attributes from `blockContainer`\n// nodes to their child `blockContent` nodes. This is due to a schema change\n// introduced in PR #TODO.\nexport const moveColorAttributes: MigrationRule = (fragment, tr) => {\n // Stores necessary info for all `blockContainer` nodes which still have\n // `textColor` or `backgroundColor` attributes that need to be moved.\n const targetBlockContainers: Map<\n string,\n {\n textColor: string | undefined;\n backgroundColor: string | undefined;\n }\n > = new Map();\n // Finds all elements which still have `textColor` or `backgroundColor`\n // attributes in the current Yjs fragment.\n fragment.forEach((element) => {\n if (element instanceof Y.XmlElement) {\n traverseElement(element, (element) => {\n if (\n element.nodeName === \"blockContainer\" &&\n element.hasAttribute(\"id\")\n ) {\n const textColor = element.getAttribute(\"textColor\");\n const backgroundColor = element.getAttribute(\"backgroundColor\");\n\n const colors = {\n textColor:\n textColor === defaultProps.textColor.default\n ? undefined\n : textColor,\n backgroundColor:\n backgroundColor === defaultProps.backgroundColor.default\n ? undefined\n : backgroundColor,\n };\n\n if (colors.textColor || colors.backgroundColor) {\n targetBlockContainers.set(element.getAttribute(\"id\")!, colors);\n }\n }\n });\n }\n });\n\n if (targetBlockContainers.size === 0) {\n return false;\n }\n\n // Appends transactions to add the `textColor` and `backgroundColor`\n // attributes found on each `blockContainer` node to move them to the child\n // `blockContent` node.\n tr.doc.descendants((node, pos) => {\n if (\n node.type.name === \"blockContainer\" &&\n targetBlockContainers.has(node.attrs.id)\n ) {\n const el = tr.doc.nodeAt(pos + 1);\n if (!el) {\n throw new Error(\"No element found\");\n }\n\n tr.setNodeMarkup(pos + 1, undefined, {\n // preserve existing attributes\n ...el.attrs,\n // add the textColor and backgroundColor attributes\n ...targetBlockContainers.get(node.attrs.id),\n });\n }\n });\n\n return true;\n};\n","import { MigrationRule } from \"./migrationRule.js\";\nimport { moveColorAttributes } from \"./moveColorAttributes.js\";\n\nexport default [moveColorAttributes] as MigrationRule[];\n","import { Plugin, PluginKey } from \"@tiptap/pm/state\";\nimport * as Y from \"yjs\";\n\nimport {\n createExtension,\n ExtensionOptions,\n} from \"../../../editor/BlockNoteExtension.js\";\nimport migrationRules from \"./migrationRules/index.js\";\n\n// This plugin allows us to update collaboration YDocs whenever BlockNote's\n// underlying ProseMirror schema changes. The plugin reads the current Yjs\n// fragment and dispatches additional transactions to the ProseMirror state, in\n// case things are found in the fragment that don't adhere to the editor schema\n// and need to be fixed. These fixes are defined as `MigrationRule`s within the\n// `migrationRules` directory.\nexport const SchemaMigration = createExtension(\n ({ options }: ExtensionOptions<{ fragment: Y.XmlFragment }>) => {\n let migrationDone = false;\n const pluginKey = new PluginKey(\"schemaMigration\");\n\n return {\n key: \"schemaMigration\",\n prosemirrorPlugins: [\n new Plugin({\n key: pluginKey,\n appendTransaction: (transactions, _oldState, newState) => {\n if (migrationDone) {\n return undefined;\n }\n\n if (\n // If any of the transactions are not due to a yjs sync, we don't need to run the migration\n !transactions.some((tr) => tr.getMeta(\"y-sync$\")) ||\n // If none of the transactions result in a document change, we don't need to run the migration\n transactions.every((tr) => !tr.docChanged) ||\n // If the fragment is still empty, we can't run the migration (since it has not yet been applied to the Y.Doc)\n !options.fragment.firstChild\n ) {\n return undefined;\n }\n\n const tr = newState.tr;\n for (const migrationRule of migrationRules) {\n migrationRule(options.fragment, tr);\n }\n\n migrationDone = true;\n\n if (!tr.docChanged) {\n return undefined;\n }\n\n return tr;\n },\n }),\n ],\n } as const;\n },\n);\n","import type { Awareness } from \"y-protocols/awareness\";\nimport type * as Y from \"yjs\";\nimport type { BlockNoteEditorOptions } from \"../../editor/BlockNoteEditor\";\nimport {\n createExtension,\n type ExtensionOptions,\n} from \"../../editor/BlockNoteExtension.js\";\nimport { FixUpSchemaExtension } from \"./FixUpSchema.js\";\nimport { ForkYDocExtension } from \"./ForkYDoc.js\";\nimport { RelativePositionMappingExtension } from \"./RelativePositionMapping.js\";\nimport { SchemaMigration } from \"./schemaMigration/SchemaMigration.js\";\nimport { CollaborationUser, YCursorExtension } from \"./YCursorPlugin.js\";\nimport { YSyncExtension } from \"./YSync.js\";\nimport { YUndoExtension } from \"./YUndo.js\";\n\nexport type CollaborationOptions = {\n /**\n * The Yjs XML fragment that's used for collaboration.\n */\n fragment: Y.XmlFragment;\n /**\n * The user info for the current user that's shown to other collaborators.\n */\n user: CollaborationUser;\n /**\n * A Yjs provider (used for awareness / cursor information)\n */\n provider?: { awareness?: Awareness };\n /**\n * Optional function to customize how cursors of users are rendered\n */\n renderCursor?: (user: CollaborationUser) => HTMLElement;\n /**\n * Optional flag to set when the user label should be shown with the default\n * collaboration cursor. Setting to \"always\" will always show the label,\n * while \"activity\" will only show the label when the user moves the cursor\n * or types. Defaults to \"activity\".\n */\n showCursorLabels?: \"always\" | \"activity\";\n};\n\nexport const CollaborationExtension = createExtension(\n ({ options }: ExtensionOptions<CollaborationOptions>) => {\n return {\n key: \"collaboration\",\n fragment: options.fragment,\n blockNoteExtensions: [\n FixUpSchemaExtension(),\n ForkYDocExtension(options),\n RelativePositionMappingExtension(),\n SchemaMigration(options),\n YCursorExtension(options),\n YSyncExtension(options),\n YUndoExtension(),\n ],\n } as const;\n },\n);\n\nexport function withCollaboration<\n Options extends Partial<BlockNoteEditorOptions<any, any, any>>,\n>(\n options: Options & {\n /**\n * Options for configuring the collaboration functionality.\n */\n collaboration: CollaborationOptions;\n },\n): Options {\n return {\n ...options,\n extensions: [\n ...(options.extensions ?? []),\n CollaborationExtension(options.collaboration),\n ],\n // We disable the default prosemirror history plugin, since it's not compatible with yjs\n disableExtensions: [\"history\", ...(options.disableExtensions ?? [])],\n // We don't want the default initial content, since it will generate a random id for the initial block on each client,\n // leading to conflicts when syncing happens afterwards.\n initialContent: [{ type: \"paragraph\", id: \"initialBlockId\" }],\n };\n}\n\nexport * from \"./ForkYDoc.js\";\nexport * from \"./RelativePositionMapping.js\";\nexport * from \"./schemaMigration/SchemaMigration.js\";\nexport * from \"./YCursorPlugin.js\";\nexport * from \"./YSync.js\";\nexport * from \"./YUndo.js\";\n","import * as Y from \"yjs\";\nimport type {\n CommentData,\n CommentReactionData,\n ThreadData,\n} from \"../../comments/types.js\";\n\nexport function commentToYMap(comment: CommentData) {\n const yMap = new Y.Map<any>();\n yMap.set(\"id\", comment.id);\n yMap.set(\"userId\", comment.userId);\n yMap.set(\"createdAt\", comment.createdAt.getTime());\n yMap.set(\"updatedAt\", comment.updatedAt.getTime());\n if (comment.deletedAt) {\n yMap.set(\"deletedAt\", comment.deletedAt.getTime());\n yMap.set(\"body\", undefined);\n } else {\n yMap.set(\"body\", comment.body);\n }\n if (comment.reactions.length > 0) {\n throw new Error(\"Reactions should be empty in commentToYMap\");\n }\n\n /**\n * Reactions are stored in a map keyed by {userId-emoji},\n * this makes it easy to add / remove reactions and in a way that works local-first.\n * The cost is that \"reading\" the reactions is a bit more complex (see yMapToReactions).\n */\n yMap.set(\"reactionsByUser\", new Y.Map());\n yMap.set(\"metadata\", comment.metadata);\n\n return yMap;\n}\n\nexport function threadToYMap(thread: ThreadData) {\n const yMap = new Y.Map();\n yMap.set(\"id\", thread.id);\n yMap.set(\"createdAt\", thread.createdAt.getTime());\n yMap.set(\"updatedAt\", thread.updatedAt.getTime());\n const commentsArray = new Y.Array<Y.Map<any>>();\n\n commentsArray.push(thread.comments.map((comment) => commentToYMap(comment)));\n\n yMap.set(\"comments\", commentsArray);\n yMap.set(\"resolved\", thread.resolved);\n yMap.set(\"resolvedUpdatedAt\", thread.resolvedUpdatedAt?.getTime());\n yMap.set(\"resolvedBy\", thread.resolvedBy);\n yMap.set(\"metadata\", thread.metadata);\n return yMap;\n}\n\ntype SingleUserCommentReactionData = {\n emoji: string;\n createdAt: Date;\n userId: string;\n};\n\nexport function yMapToReaction(\n yMap: Y.Map<any>,\n): SingleUserCommentReactionData {\n return {\n emoji: yMap.get(\"emoji\"),\n createdAt: new Date(yMap.get(\"createdAt\")),\n userId: yMap.get(\"userId\"),\n };\n}\n\nfunction yMapToReactions(yMap: Y.Map<any>): CommentReactionData[] {\n const flatReactions = [...yMap.values()].map((reaction: Y.Map<any>) =>\n yMapToReaction(reaction),\n );\n // combine reactions by the same emoji\n return flatReactions.reduce(\n (acc: CommentReactionData[], reaction: SingleUserCommentReactionData) => {\n const existingReaction = acc.find((r) => r.emoji === reaction.emoji);\n if (existingReaction) {\n existingReaction.userIds.push(reaction.userId);\n existingReaction.createdAt = new Date(\n Math.min(\n existingReaction.createdAt.getTime(),\n reaction.createdAt.getTime(),\n ),\n );\n } else {\n acc.push({\n emoji: reaction.emoji,\n createdAt: reaction.createdAt,\n userIds: [reaction.userId],\n });\n }\n return acc;\n },\n [] as CommentReactionData[],\n );\n}\n\nexport function yMapToComment(yMap: Y.Map<any>): CommentData {\n return {\n type: \"comment\",\n id: yMap.get(\"id\"),\n userId: yMap.get(\"userId\"),\n createdAt: new Date(yMap.get(\"createdAt\")),\n updatedAt: new Date(yMap.get(\"updatedAt\")),\n deletedAt: yMap.get(\"deletedAt\")\n ? new Date(yMap.get(\"deletedAt\"))\n : undefined,\n reactions: yMapToReactions(yMap.get(\"reactionsByUser\")),\n metadata: yMap.get(\"metadata\"),\n body: yMap.get(\"body\"),\n };\n}\n\nexport function yMapToThread(yMap: Y.Map<any>): ThreadData {\n return {\n type: \"thread\",\n id: yMap.get(\"id\"),\n createdAt: new Date(yMap.get(\"createdAt\")),\n updatedAt: new Date(yMap.get(\"updatedAt\")),\n comments: ((yMap.get(\"comments\") as Y.Array<Y.Map<any>>) || []).map(\n (comment) => yMapToComment(comment),\n ),\n resolved: yMap.get(\"resolved\"),\n resolvedUpdatedAt: new Date(yMap.get(\"resolvedUpdatedAt\")),\n resolvedBy: yMap.get(\"resolvedBy\"),\n metadata: yMap.get(\"metadata\"),\n };\n}\n","import * as Y from \"yjs\";\nimport type { ThreadData } from \"../../comments/types.js\";\nimport { ThreadStore } from \"../../comments/threadstore/ThreadStore.js\";\nimport type { ThreadStoreAuth } from \"../../comments/threadstore/ThreadStoreAuth.js\";\nimport { yMapToThread } from \"./yjsHelpers.js\";\n\n/**\n * This is an abstract class that only implements the READ methods required by the ThreadStore interface.\n * The data is read from a Yjs Map.\n */\nexport abstract class YjsThreadStoreBase extends ThreadStore {\n constructor(\n protected readonly threadsYMap: Y.Map<any>,\n auth: ThreadStoreAuth,\n ) {\n super(auth);\n }\n\n // TODO: async / reactive interface?\n public getThread(threadId: string) {\n const yThread = this.threadsYMap.get(threadId);\n if (!yThread) {\n throw new Error(\"Thread not found\");\n }\n const thread = yMapToThread(yThread);\n return thread;\n }\n\n public getThreads(): Map<string, ThreadData> {\n const threadMap = new Map<string, ThreadData>();\n this.threadsYMap.forEach((yThread, id) => {\n if (yThread instanceof Y.Map) {\n threadMap.set(id, yMapToThread(yThread));\n }\n });\n return threadMap;\n }\n\n public subscribe(cb: (threads: Map<string, ThreadData>) => void) {\n const observer = () => {\n cb(this.getThreads());\n };\n\n this.threadsYMap.observeDeep(observer);\n\n return () => {\n this.threadsYMap.unobserveDeep(observer);\n };\n }\n}\n","import * as Y from \"yjs\";\nimport {\n absolutePositionToRelativePosition,\n ySyncPluginKey,\n} from \"y-prosemirror\";\nimport type { CommentBody } from \"../../comments/types.js\";\nimport type { ThreadStoreAuth } from \"../../comments/threadstore/ThreadStoreAuth.js\";\nimport { YjsThreadStoreBase } from \"./YjsThreadStoreBase.js\";\nimport { BlockNoteEditor } from \"../../editor/BlockNoteEditor.js\";\n\n/**\n * This is a REST-based implementation of the YjsThreadStoreBase.\n * It Reads data directly from the underlying document (same as YjsThreadStore),\n * but for Writes, it sends data to a REST API that should:\n * - check the user has the correct permissions to make the desired changes\n * - apply the updates to the underlying Yjs document\n *\n * (see https://github.com/TypeCellOS/BlockNote-demo-nextjs-hocuspocus)\n *\n * The reason we still use the Yjs document as underlying storage is that it makes it easy to\n * sync updates in real-time to other collaborators.\n * (but technically, you could also implement a different storage altogether\n * and not store the thread related data in the Yjs document)\n */\nexport class RESTYjsThreadStore extends YjsThreadStoreBase {\n constructor(\n private readonly BASE_URL: string,\n private readonly headers: Record<string, string>,\n threadsYMap: Y.Map<any>,\n auth: ThreadStoreAuth,\n ) {\n super(threadsYMap, auth);\n }\n\n private doRequest = async (path: string, method: string, body?: any) => {\n const response = await fetch(`${this.BASE_URL}${path}`, {\n method,\n body: JSON.stringify(body),\n headers: {\n \"Content-Type\": \"application/json\",\n ...this.headers,\n },\n });\n\n if (!response.ok) {\n throw new Error(`Failed to ${method} ${path}: ${response.statusText}`);\n }\n\n return response.json();\n };\n\n public addThreadToDocument = async (options: {\n threadId: string;\n selection: {\n head: number;\n anchor: number;\n };\n editor: BlockNoteEditor<any, any, any>;\n }) => {\n const { threadId, selection } = options;\n\n // Note: the positions have to be resolved against the *binding's* type and\n // mapping. The plugin state has a `type` of its own, but no `mapping`, and\n // its `type` can go stale (e.g. while the doc is forked, see\n // `ForkYDocExtension`).\n const binding = ySyncPluginKey.getState(\n options.editor.prosemirrorState,\n )?.binding;\n const yjsSelection = binding\n ? {\n head: absolutePositionToRelativePosition(\n selection.head,\n binding.type,\n binding.mapping,\n ),\n anchor: absolutePositionToRelativePosition(\n selection.anchor,\n binding.type,\n binding.mapping,\n ),\n }\n : undefined;\n\n return this.doRequest(`/${threadId}/addToDocument`, \"POST\", {\n selection: {\n prosemirror: selection,\n yjs: yjsSelection,\n },\n });\n };\n\n public createThread = async (options: {\n initialComment: {\n body: CommentBody;\n metadata?: any;\n };\n metadata?: any;\n }) => {\n return this.doRequest(\"\", \"POST\", options);\n };\n\n public addComment = (options: {\n comment: {\n body: CommentBody;\n metadata?: any;\n };\n threadId: string;\n }) => {\n const { threadId, ...rest } = options;\n return this.doRequest(`/${threadId}/comments`, \"POST\", rest);\n };\n\n public updateComment = (options: {\n comment: {\n body: CommentBody;\n metadata?: any;\n };\n threadId: string;\n commentId: string;\n }) => {\n const { threadId, commentId, ...rest } = options;\n return this.doRequest(`/${threadId}/comments/${commentId}`, \"PUT\", rest);\n };\n\n public deleteComment = (options: {\n threadId: string;\n commentId: string;\n softDelete?: boolean;\n }) => {\n const { threadId, commentId, ...rest } = options;\n return this.doRequest(\n `/${threadId}/comments/${commentId}?soft=${!!rest.softDelete}`,\n \"DELETE\",\n );\n };\n\n public deleteThread = (options: { threadId: string }) => {\n return this.doRequest(`/${options.threadId}`, \"DELETE\");\n };\n\n public resolveThread = (options: { threadId: string }) => {\n return this.doRequest(`/${options.threadId}/resolve`, \"POST\");\n };\n\n public unresolveThread = (options: { threadId: string }) => {\n return this.doRequest(`/${options.threadId}/unresolve`, \"POST\");\n };\n\n public addReaction = (options: {\n threadId: string;\n commentId: string;\n emoji: string;\n }) => {\n const { threadId, commentId, ...rest } = options;\n return this.doRequest(\n `/${threadId}/comments/${commentId}/reactions`,\n \"POST\",\n rest,\n );\n };\n\n public deleteReaction = (options: {\n threadId: string;\n commentId: string;\n emoji: string;\n }) => {\n return this.doRequest(\n `/${options.threadId}/comments/${options.commentId}/reactions/${options.emoji}`,\n \"DELETE\",\n );\n };\n}\n","import * as Y from \"yjs\";\nimport { uuidv4 } from \"lib0/random\";\nimport type {\n CommentBody,\n CommentData,\n ThreadData,\n} from \"../../comments/types.js\";\nimport type { ThreadStoreAuth } from \"../../comments/threadstore/ThreadStoreAuth.js\";\nimport { YjsThreadStoreBase } from \"./YjsThreadStoreBase.js\";\nimport {\n commentToYMap,\n threadToYMap,\n yMapToComment,\n yMapToThread,\n} from \"./yjsHelpers.js\";\n\n/**\n * This is a Yjs-based implementation of the ThreadStore interface.\n *\n * It reads and writes thread / comments information directly to the underlying Yjs Document.\n *\n * @important While this is the easiest to add to your app, there are two challenges:\n * - The user needs to be able to write to the Yjs document to store the information.\n * So a user without write access to the Yjs document cannot leave any comments.\n * - Even with write access, the operations are not secure. Unless your Yjs server\n * guards against malicious operations, it's technically possible for one user to make changes to another user's comments, etc.\n * (even though these options are not visible in the UI, a malicious user can make unauthorized changes to the underlying Yjs document)\n */\nexport class YjsThreadStore extends YjsThreadStoreBase {\n constructor(\n private readonly userId: string,\n threadsYMap: Y.Map<any>,\n auth: ThreadStoreAuth,\n ) {\n super(threadsYMap, auth);\n }\n\n private transact = <T, R>(\n fn: (options: T) => R,\n ): ((options: T) => Promise<R>) => {\n return async (options: T) => {\n return this.threadsYMap.doc!.transact(() => {\n return fn(options);\n });\n };\n };\n\n public createThread = this.transact(\n (options: {\n initialComment: {\n body: CommentBody;\n metadata?: any;\n };\n metadata?: any;\n }) => {\n if (!this.auth.canCreateThread()) {\n throw new Error(\"Not authorized\");\n }\n\n const date = new Date();\n\n const comment: CommentData = {\n type: \"comment\",\n id: uuidv4(),\n userId: this.userId,\n createdAt: date,\n updatedAt: date,\n reactions: [],\n metadata: options.initialComment.metadata,\n body: options.initialComment.body,\n };\n\n const thread: ThreadData = {\n type: \"thread\",\n id: uuidv4(),\n createdAt: date,\n updatedAt: date,\n comments: [comment],\n resolved: false,\n metadata: options.metadata,\n };\n\n this.threadsYMap.set(thread.id, threadToYMap(thread));\n\n return thread;\n },\n );\n\n // YjsThreadStore does not support addThreadToDocument\n public addThreadToDocument = undefined;\n\n public addComment = this.transact(\n (options: {\n comment: {\n body: CommentBody;\n metadata?: any;\n };\n threadId: string;\n }) => {\n const yThread = this.threadsYMap.get(options.threadId);\n if (!yThread) {\n throw new Error(\"Thread not found\");\n }\n\n if (!this.auth.canAddComment(yMapToThread(yThread))) {\n throw new Error(\"Not authorized\");\n }\n\n const date = new Date();\n const comment: CommentData = {\n type: \"comment\",\n id: uuidv4(),\n userId: this.userId,\n createdAt: date,\n updatedAt: date,\n deletedAt: undefined,\n reactions: [],\n metadata: options.comment.metadata,\n body: options.comment.body,\n };\n\n (yThread.get(\"comments\") as Y.Array<Y.Map<any>>).push([\n commentToYMap(comment),\n ]);\n\n yThread.set(\"updatedAt\", new Date().getTime());\n return comment;\n },\n );\n\n public updateComment = this.transact(\n (options: {\n comment: {\n body: CommentBody;\n metadata?: any;\n };\n threadId: string;\n commentId: string;\n }) => {\n const yThread = this.threadsYMap.get(options.threadId);\n if (!yThread) {\n throw new Error(\"Thread not found\");\n }\n\n const yCommentIndex = yArrayFindIndex(\n yThread.get(\"comments\"),\n (comment) => comment.get(\"id\") === options.commentId,\n );\n\n if (yCommentIndex === -1) {\n throw new Error(\"Comment not found\");\n }\n\n const yComment = yThread.get(\"comments\").get(yCommentIndex);\n\n if (!this.auth.canUpdateComment(yMapToComment(yComment))) {\n throw new Error(\"Not authorized\");\n }\n\n yComment.set(\"body\", options.comment.body);\n yComment.set(\"updatedAt\", new Date().getTime());\n yComment.set(\"metadata\", options.comment.metadata);\n },\n );\n\n public deleteComment = this.transact(\n (options: {\n threadId: string;\n commentId: string;\n softDelete?: boolean;\n }) => {\n const yThread = this.threadsYMap.get(options.threadId);\n if (!yThread) {\n throw new Error(\"Thread not found\");\n }\n\n const yCommentIndex = yArrayFindIndex(\n yThread.get(\"comments\"),\n (comment) => comment.get(\"id\") === options.commentId,\n );\n\n if (yCommentIndex === -1) {\n throw new Error(\"Comment not found\");\n }\n\n const yComment = yThread.get(\"comments\").get(yCommentIndex);\n\n if (!this.auth.canDeleteComment(yMapToComment(yComment))) {\n throw new Error(\"Not authorized\");\n }\n\n if (yComment.get(\"deletedAt\")) {\n throw new Error(\"Comment already deleted\");\n }\n\n if (options.softDelete) {\n yComment.set(\"deletedAt\", new Date().getTime());\n yComment.set(\"body\", undefined);\n } else {\n yThread.get(\"comments\").delete(yCommentIndex);\n }\n\n if (\n (yThread.get(\"comments\") as Y.Array<any>)\n .toArray()\n .every((comment) => comment.get(\"deletedAt\"))\n ) {\n // all comments deleted\n if (options.softDelete) {\n yThread.set(\"deletedAt\", new Date().getTime());\n } else {\n this.threadsYMap.delete(options.threadId);\n }\n }\n\n yThread.set(\"updatedAt\", new Date().getTime());\n },\n );\n\n public deleteThread = this.transact((options: { threadId: string }) => {\n if (\n !this.auth.canDeleteThread(\n yMapToThread(this.threadsYMap.get(options.threadId)),\n )\n ) {\n throw new Error(\"Not authorized\");\n }\n\n this.threadsYMap.delete(options.threadId);\n });\n\n public resolveThread = this.transact((options: { threadId: string }) => {\n const yThread = this.threadsYMap.get(options.threadId);\n if (!yThread) {\n throw new Error(\"Thread not found\");\n }\n\n if (!this.auth.canResolveThread(yMapToThread(yThread))) {\n throw new Error(\"Not authorized\");\n }\n\n yThread.set(\"resolved\", true);\n yThread.set(\"resolvedUpdatedAt\", new Date().getTime());\n yThread.set(\"resolvedBy\", this.userId);\n });\n\n public unresolveThread = this.transact((options: { threadId: string }) => {\n const yThread = this.threadsYMap.get(options.threadId);\n if (!yThread) {\n throw new Error(\"Thread not found\");\n }\n\n if (!this.auth.canUnresolveThread(yMapToThread(yThread))) {\n throw new Error(\"Not authorized\");\n }\n\n yThread.set(\"resolved\", false);\n yThread.set(\"resolvedUpdatedAt\", new Date().getTime());\n });\n\n public addReaction = this.transact(\n (options: { threadId: string; commentId: string; emoji: string }) => {\n const yThread = this.threadsYMap.get(options.threadId);\n if (!yThread) {\n throw new Error(\"Thread not found\");\n }\n\n const yCommentIndex = yArrayFindIndex(\n yThread.get(\"comments\"),\n (comment) => comment.get(\"id\") === options.commentId,\n );\n\n if (yCommentIndex === -1) {\n throw new Error(\"Comment not found\");\n }\n\n const yComment = yThread.get(\"comments\").get(yCommentIndex);\n\n if (!this.auth.canAddReaction(yMapToComment(yComment), options.emoji)) {\n throw new Error(\"Not authorized\");\n }\n\n const date = new Date();\n\n const key = `${this.userId}-${options.emoji}`;\n\n const reactionsByUser = yComment.get(\"reactionsByUser\");\n\n if (reactionsByUser.has(key)) {\n // already exists\n return;\n } else {\n const reaction = new Y.Map();\n reaction.set(\"emoji\", options.emoji);\n reaction.set(\"createdAt\", date.getTime());\n reaction.set(\"userId\", this.userId);\n reactionsByUser.set(key, reaction);\n }\n },\n );\n\n public deleteReaction = this.transact(\n (options: { threadId: string; commentId: string; emoji: string }) => {\n const yThread = this.threadsYMap.get(options.threadId);\n if (!yThread) {\n throw new Error(\"Thread not found\");\n }\n\n const yCommentIndex = yArrayFindIndex(\n yThread.get(\"comments\"),\n (comment) => comment.get(\"id\") === options.commentId,\n );\n\n if (yCommentIndex === -1) {\n throw new Error(\"Comment not found\");\n }\n\n const yComment = yThread.get(\"comments\").get(yCommentIndex);\n\n if (\n !this.auth.canDeleteReaction(yMapToComment(yComment), options.emoji)\n ) {\n throw new Error(\"Not authorized\");\n }\n\n const key = `${this.userId}-${options.emoji}`;\n\n const reactionsByUser = yComment.get(\"reactionsByUser\");\n\n reactionsByUser.delete(key);\n },\n );\n}\n\nfunction yArrayFindIndex(\n yArray: Y.Array<any>,\n predicate: (item: any) => boolean,\n) {\n for (let i = 0; i < yArray.length; i++) {\n if (predicate(yArray.get(i))) {\n return i;\n }\n }\n return -1;\n}\n","import * as Y from \"yjs\";\nimport { ySyncPluginKey } from \"y-prosemirror\";\nimport type { BlockNoteEditor } from \"../../editor/BlockNoteEditor.js\";\nimport { ForkYDocExtension } from \"./ForkYDoc.js\";\nimport type {\n VersionStorage,\n VersionViewAdapter,\n} from \"../../extensions/Versioning/types.js\";\nimport { createVersioningExtension } from \"../../extensions/Versioning/Versioning.js\";\nimport type { UserStoreOrResolver } from \"../../user/index.js\";\nimport { CollaborationExtension } from \"./index.js\";\nimport type { DiffVersioningExtension } from \"../../y/extensions/DiffVersioningExtension.js\";\nimport { findTypeInOtherYdoc, yXmlFragmentToBlocks } from \"../utils.js\";\nimport type {\n BlockSchema,\n InlineContentSchema,\n StyleSchema,\n} from \"../../schema/index.js\";\n\n/**\n * Install history separately, using the editor's Yjs collaboration fragment.\n * Register DiffVersioningExtension from `@blocknote/core/y` to opt into\n * content comparisons. Diffs mark changes, not their original authors.\n */\nexport function YjsVersioningExtension(options: {\n storage: VersionStorage<Uint8Array>;\n resolveUsers?: UserStoreOrResolver;\n scrollToFirstChange?: boolean;\n}) {\n return createVersioningExtension((editor) => ({\n adapter: {\n get supportsComparison() {\n return editor.getExtension(\"diffVersioning\") !== undefined;\n },\n open() {\n const collaboration = editor.getExtension(CollaborationExtension);\n if (!collaboration) {\n throw new Error(\"Yjs versioning requires Yjs collaboration\");\n }\n return createYjsVersionView(editor, collaboration.fragment).open();\n },\n },\n ...options,\n }))();\n}\n\nexport function createYjsVersionView<\n BSchema extends BlockSchema,\n ISchema extends InlineContentSchema,\n SSchema extends StyleSchema,\n>(\n editor: BlockNoteEditor<BSchema, ISchema, SSchema>,\n fragment: Y.XmlFragment,\n): VersionViewAdapter<Uint8Array> {\n return {\n get supportsComparison() {\n return editor.getExtension(\"diffVersioning\") !== undefined;\n },\n open() {\n const fork = editor.getExtension(ForkYDocExtension);\n if (\n !fork ||\n fork.store.state.isForked ||\n ySyncPluginKey.getState(editor.prosemirrorState)?.type !== fragment\n ) {\n throw new Error(\n \"Versioning requires an active live binding and an available fork\",\n );\n }\n const current = {\n content: Y.encodeStateAsUpdate(fragment.doc!),\n capturedAt: Date.now(),\n };\n try {\n fork.fork();\n } catch (error) {\n fork.merge({ keepChanges: false });\n throw error;\n }\n let closed = false;\n return {\n current,\n show({ content, comparison }) {\n if (closed) {\n throw new Error(\"Version view is closed\");\n }\n fork.replaceSnapshot(content);\n if (comparison) {\n const diff =\n editor.getExtension<typeof DiffVersioningExtension>(\n \"diffVersioning\",\n );\n if (!diff) {\n throw new Error(\"Version comparison requires a diff renderer\");\n }\n function blocksFromUpdate(update: Uint8Array) {\n const doc = new Y.Doc();\n try {\n Y.applyUpdate(doc, update);\n return yXmlFragmentToBlocks(\n editor,\n findTypeInOtherYdoc(fragment, doc),\n );\n } finally {\n doc.destroy();\n }\n }\n // The binding points at a disposable fork. Any rendered suggestion\n // marks stay there and are discarded when switching or closing.\n diff.renderDiff(\n blocksFromUpdate(content),\n blocksFromUpdate(comparison.content),\n );\n }\n },\n close() {\n if (closed) {\n return;\n }\n fork.merge({ keepChanges: false });\n closed = true;\n },\n };\n },\n };\n}\n"],"mappings":"4XAsBA,SAAgB,EACd,EACA,EACG,CACH,IAAM,EAAO,EAAM,IACnB,GAAI,CAAC,EACH,MAAU,MAAM,2BAA2B,EAE7C,GAAI,EAAM,QAAU,KAAM,CACxB,IAAM,EAAU,MAAM,KAAK,EAAK,MAAM,KAAK,CAAC,CAAC,CAAC,KAC3C,GAAQ,EAAK,MAAM,IAAI,CAAG,IAAM,CACnC,EACA,GAAI,GAAW,KACb,MAAU,MAAM,mCAAmC,EAErD,OAAO,EAAU,IAAI,EAAS,EAAM,WAA0B,CAChE,CAAO,CACL,IAAM,EAAY,EAAM,MAClB,EAAe,EAAU,MAAM,QAAQ,IAAI,EAAU,GAAG,MAAM,GAAK,CAAC,EAEpE,EAAY,EADA,EAAE,YAAY,EAAc,EAAU,GAAG,KAC5B,GAC/B,GAAI,CAAC,EACH,MAAU,MAAM,mCAAmC,EAErD,IAAM,EAAe,EAAU,QAC/B,GAAI,CAAC,EACH,MAA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AGA,EAAK,WACH,EAAiB,CAAO,EACxB,EAAiB,EAAW,OAAO,CACrC,CACF,CACF,EACA,OAAQ,CACF,AAIJ,KADA,EAAK,MAAM,CAAE,YAAa,EAAM,CAAC,EACxB,GACX,CACF,CACF,CACF,CACF"}
package/dist/yjs.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"yjs.js","names":[],"sources":["../src/yjs/utils.ts","../src/yjs/extensions/FixUpSchema.ts","../src/yjs/extensions/YCursorPlugin.ts","../src/yjs/extensions/YSync.ts","../src/yjs/extensions/YUndo.ts","../src/yjs/extensions/ForkYDoc.ts","../src/yjs/extensions/RelativePositionMapping.ts","../src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.ts","../src/yjs/extensions/schemaMigration/migrationRules/index.ts","../src/yjs/extensions/schemaMigration/SchemaMigration.ts","../src/yjs/extensions/index.ts","../src/yjs/comments/yjsHelpers.ts","../src/yjs/comments/YjsThreadStoreBase.ts","../src/yjs/comments/RESTYjsThreadStore.ts","../src/yjs/comments/YjsThreadStore.ts","../src/yjs/extensions/Versioning.ts"],"sourcesContent":["import {\n prosemirrorToYDoc,\n prosemirrorToYXmlFragment,\n yXmlFragmentToProseMirrorRootNode,\n} from \"y-prosemirror\";\nimport * as Y from \"yjs\";\n\nimport {\n type Block,\n type BlockNoteEditor,\n type BlockSchema,\n type InlineContentSchema,\n type PartialBlock,\n type StyleSchema,\n blockToNode,\n docToBlocks,\n} from \"../index.js\";\n\n/**\n * Find a Y.AbstractType in another Y.Doc that corresponds to the same\n * logical type in the original doc.\n */\nexport function findTypeInOtherYdoc<T extends Y.AbstractType<any>>(\n ytype: T,\n otherYdoc: Y.Doc,\n): T {\n const ydoc = ytype.doc;\n if (!ydoc) {\n throw new Error(\"type does not have a ydoc\");\n }\n if (ytype._item === null) {\n const rootKey = Array.from(ydoc.share.keys()).find(\n (key) => ydoc.share.get(key) === ytype,\n );\n if (rootKey == null) {\n throw new Error(\"type does not exist in other ydoc\");\n }\n return otherYdoc.get(rootKey, ytype.constructor as new () => T) as T;\n } else {\n const ytypeItem = ytype._item;\n const otherStructs = otherYdoc.store.clients.get(ytypeItem.id.client) ?? [];\n const itemIndex = Y.findIndexSS(otherStructs, ytypeItem.id.clock);\n const otherItem = otherStructs[itemIndex] as Y.Item | undefined;\n if (!otherItem) {\n throw new Error(\"type does not exist in other ydoc\");\n }\n const otherContent = otherItem.content as Y.ContentType | undefined;\n if (!otherContent) {\n throw new Error(\"type does not exist in other ydoc\");\n }\n return otherContent.type as T;\n }\n}\n\n/**\n * Turn Prosemirror JSON to BlockNote style JSON\n * @param editor BlockNote editor\n * @param json Prosemirror JSON\n * @returns BlockNote style JSON\n */\nexport function _prosemirrorJSONToBlocks<\n BSchema extends BlockSchema,\n ISchema extends InlineContentSchema,\n SSchema extends StyleSchema,\n>(editor: BlockNoteEditor<BSchema, ISchema, SSchema>, json: any) {\n // note: theoretically this should also be possible without creating prosemirror nodes,\n // but this is definitely the easiest way\n const doc = editor.pmSchema.nodeFromJSON(json);\n return docToBlocks<BSchema, ISchema, SSchema>(doc);\n}\n\n/**\n * Turn BlockNote JSON to Prosemirror node / state\n * @param editor BlockNote editor\n * @param blocks BlockNote blocks\n * @returns Prosemirror root node\n */\nexport function _blocksToProsemirrorNode<\n BSchema extends BlockSchema,\n ISchema extends InlineContentSchema,\n SSchema extends StyleSchema,\n>(\n editor: BlockNoteEditor<BSchema, ISchema, SSchema>,\n blocks: PartialBlock<BSchema, ISchema, SSchema>[],\n) {\n const pmNodes = blocks.map((b) => blockToNode(b, editor.pmSchema));\n\n const doc = editor.pmSchema.topNodeType.create(\n null,\n editor.pmSchema.nodes[\"blockGroup\"].create(null, pmNodes),\n );\n return doc;\n}\n\n/** YJS / BLOCKNOTE conversions */\n\n/**\n * Turn a Y.XmlFragment collaborative doc into a BlockNote document (BlockNote style JSON of all blocks)\n * @param editor BlockNote editor\n * @param xmlFragment Y.XmlFragment\n * @returns BlockNote document (BlockNote style JSON of all blocks)\n */\nexport function yXmlFragmentToBlocks<\n BSchema extends BlockSchema,\n ISchema extends InlineContentSchema,\n SSchema extends StyleSchema,\n>(\n editor: BlockNoteEditor<BSchema, ISchema, SSchema>,\n xmlFragment: Y.XmlFragment,\n) {\n const pmNode = yXmlFragmentToProseMirrorRootNode(\n xmlFragment,\n editor.pmSchema,\n );\n return docToBlocks<BSchema, ISchema, SSchema>(pmNode);\n}\n\n/**\n * Convert blocks to a Y.XmlFragment\n *\n * This can be used when importing existing content to Y.Doc for the first time,\n * note that this should not be used to rehydrate a Y.Doc from a database once\n * collaboration has begun as all history will be lost\n *\n * @param editor BlockNote editor\n * @param blocks the blocks to convert\n * @param xmlFragment XML fragment name\n * @returns Y.XmlFragment\n */\nexport function blocksToYXmlFragment<\n BSchema extends BlockSchema,\n ISchema extends InlineContentSchema,\n SSchema extends StyleSchema,\n>(\n editor: BlockNoteEditor<BSchema, ISchema, SSchema>,\n blocks: Block<BSchema, ISchema, SSchema>[],\n xmlFragment?: Y.XmlFragment,\n) {\n return prosemirrorToYXmlFragment(\n _blocksToProsemirrorNode(editor, blocks),\n xmlFragment,\n );\n}\n\n/**\n * Turn a Y.Doc collaborative doc into a BlockNote document (BlockNote style JSON of all blocks)\n * @param editor BlockNote editor\n * @param ydoc Y.Doc\n * @param xmlFragment XML fragment name\n * @returns BlockNote document (BlockNote style JSON of all blocks)\n */\nexport function yDocToBlocks<\n BSchema extends BlockSchema,\n ISchema extends InlineContentSchema,\n SSchema extends StyleSchema,\n>(\n editor: BlockNoteEditor<BSchema, ISchema, SSchema>,\n ydoc: Y.Doc,\n xmlFragment = \"prosemirror\",\n) {\n return yXmlFragmentToBlocks(editor, ydoc.getXmlFragment(xmlFragment));\n}\n\n/**\n * This can be used when importing existing content to Y.Doc for the first time,\n * note that this should not be used to rehydrate a Y.Doc from a database once\n * collaboration has begun as all history will be lost\n *\n * @param editor BlockNote editor\n * @param blocks the blocks to convert\n * @param xmlFragment XML fragment name\n */\nexport function blocksToYDoc<\n BSchema extends BlockSchema,\n ISchema extends InlineContentSchema,\n SSchema extends StyleSchema,\n>(\n editor: BlockNoteEditor<BSchema, ISchema, SSchema>,\n blocks: PartialBlock<BSchema, ISchema, SSchema>[],\n xmlFragment = \"prosemirror\",\n) {\n return prosemirrorToYDoc(\n _blocksToProsemirrorNode(editor, blocks),\n xmlFragment,\n );\n}\n","import { Attrs, Fragment, Mark, Node, NodeType } from \"prosemirror-model\";\n\nimport { isPlainContentNodeType } from \"../../api/pmUtil.js\";\nimport { createExtension } from \"../../editor/BlockNoteExtension.js\";\n\n// Collaboration-only patches to the live ProseMirror schema. Both are applied\n// once on `create`, before y-prosemirror binds and reconstructs the document.\nexport const FixUpSchemaExtension = createExtension(({ editor }) => {\n editor.on(\"create\", () => {\n const schema = editor.pmSchema;\n\n // 1. Preserve the initial block id.\n // When y-prosemirror creates an empty document, the `blockContainer` node is created with an `id` of `null`.\n // This causes the unique id extension to generate a new id for the initial block, which is not what we want\n // Since it will be randomly generated & cause there to be more updates to the ydoc\n // This is a hack to make it so that anytime `schema.doc.createAndFill` is called, the initial block id is already set to \"initialBlockId\"\n let cache: Node | undefined = undefined;\n // eslint-disable-next-line @typescript-eslint/unbound-method -- intentionally saving reference for monkey-patching\n const oldCreateAndFill = schema.nodes.doc.createAndFill;\n schema.nodes.doc.createAndFill = ((...args: any) => {\n // Only cache empty-document creation. Content renderers also call this\n // method, and their supplied content must not become the empty skeleton.\n if (args[1]) {\n return oldCreateAndFill.apply(schema.nodes.doc, args);\n }\n if (cache) {\n return cache;\n }\n const ret = oldCreateAndFill.apply(schema.nodes.doc, args)!;\n\n // create a copy that we can mutate (otherwise, assigning attrs is not safe and corrupts the pm state)\n const jsonNode = JSON.parse(JSON.stringify(ret.toJSON()));\n // The first fill of the doc's blockGroup is always a `blockContainer`:\n // layout block nodes are clamped below its priority\n // (`layoutNodePriority`) precisely so auto-fill picks it first. If\n // that ever stops holding, throwing here is better than silently\n // leaving the id unset, which would let every peer generate its own\n // initial block id.\n jsonNode.content[0].content[0].attrs.id = \"initialBlockId\";\n\n cache = Node.fromJSON(schema, jsonNode);\n return cache;\n }) as unknown as typeof schema.nodes.doc.createAndFill;\n\n // 2. Drop marks a plain block no longer allows, instead of deleting the block.\n // When a block's content type changes across BlockNote versions — e.g. a\n // `codeBlock` that was `\"inline\"` (formatting marks like bold allowed) and is\n // now `\"plain\"` (only the `\"annotation\"` mark group: comments + suggestions) —\n // old Yjs documents carry text with marks the new node type disallows.\n //\n // y-prosemirror rebuilds each block by calling `schema.node(nodeName, attrs,\n // children)`, where `children` are text nodes that may still carry those\n // disallowed marks. `createChecked` then throws, and y-prosemirror's error\n // handler DELETES the whole block from the Yjs doc — a deletion that propagates\n // to every peer (data loss).\n //\n // Rather than mutating the Yjs doc to strip those marks, we leave them in place\n // (marks are just format attributes; they don't affect position counting, so\n // editing text is unaffected) and simply never materialize the disallowed ones\n // into ProseMirror. We do that by wrapping `schema.node` to filter each text\n // child's marks through the parent node type's `allowedMarks` before the node\n // is built. The wrapper is scoped to plain-content blocks (the only place this\n // migration applies); all other node types pass through untouched.\n //\n // NOTE: this covers marks that EXIST in the schema but aren't allowed on the\n // node. A mark whose type is entirely absent from the schema still hits\n // y-prosemirror's earlier `schema.mark` throw (and delete) path — that's a\n // different migration scenario and is out of scope here.\n // eslint-disable-next-line @typescript-eslint/unbound-method -- intentionally saving reference for monkey-patching\n const originalNode = schema.node;\n schema.node = function (\n this: typeof schema,\n type: string | NodeType,\n attrs?: Attrs | null,\n content?: Fragment | Node | readonly Node[],\n marks?: readonly Mark[],\n ) {\n const nodeType = typeof type === \"string\" ? this.nodes[type] : type;\n // y-prosemirror always passes `content` as a plain array of nodes; only\n // touch text children that carry marks.\n if (\n nodeType &&\n isPlainContentNodeType(this, nodeType) &&\n Array.isArray(content)\n ) {\n content = (content as readonly Node[]).map((child) =>\n child?.isText && child.marks.length\n ? child.mark(nodeType.allowedMarks(child.marks))\n : child,\n );\n }\n return originalNode.call(this, type, attrs, content, marks);\n } as typeof schema.node;\n });\n\n return {\n key: \"fixUpSchema\",\n } as const;\n});\n","import { defaultSelectionBuilder, yCursorPlugin } from \"y-prosemirror\";\nimport {\n createExtension,\n ExtensionOptions,\n} from \"../../editor/BlockNoteExtension.js\";\nimport type { CollaborationOptions } from \"./index.js\";\n\nexport type CollaborationUser = {\n id?: string;\n name: string;\n color: string;\n [key: string]: unknown;\n};\n\n/**\n * Determine whether the foreground color should be white or black based on a provided background color\n * Inspired by: https://stackoverflow.com/a/3943023\n */\nfunction isDarkColor(bgColor: string): boolean {\n const color = bgColor.charAt(0) === \"#\" ? bgColor.substring(1, 7) : bgColor;\n const r = parseInt(color.substring(0, 2), 16); // hexToR\n const g = parseInt(color.substring(2, 4), 16); // hexToG\n const b = parseInt(color.substring(4, 6), 16); // hexToB\n const uicolors = [r / 255, g / 255, b / 255];\n const c = uicolors.map((col) => {\n if (col <= 0.03928) {\n return col / 12.92;\n }\n return Math.pow((col + 0.055) / 1.055, 2.4);\n });\n const L = 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2];\n return L <= 0.179;\n}\n\nfunction defaultCursorRender(user: CollaborationUser) {\n const cursorElement = document.createElement(\"span\");\n\n cursorElement.classList.add(\"bn-collaboration-cursor__base\");\n\n const caretElement = document.createElement(\"span\");\n caretElement.setAttribute(\"contentedEditable\", \"false\");\n caretElement.classList.add(\"bn-collaboration-cursor__caret\");\n caretElement.setAttribute(\n \"style\",\n `background-color: ${user.color}; color: ${\n isDarkColor(user.color) ? \"white\" : \"black\"\n }`,\n );\n\n const labelElement = document.createElement(\"span\");\n\n labelElement.classList.add(\"bn-collaboration-cursor__label\");\n labelElement.setAttribute(\n \"style\",\n `background-color: ${user.color}; color: ${\n isDarkColor(user.color) ? \"white\" : \"black\"\n }`,\n );\n labelElement.insertBefore(document.createTextNode(user.name), null);\n\n caretElement.insertBefore(labelElement, null);\n\n cursorElement.insertBefore(document.createTextNode(\"\\u2060\"), null); // Non-breaking space\n cursorElement.insertBefore(caretElement, null);\n cursorElement.insertBefore(document.createTextNode(\"\\u2060\"), null); // Non-breaking space\n\n return cursorElement;\n}\n\nexport const YCursorExtension = createExtension(\n ({ options }: ExtensionOptions<CollaborationOptions>) => {\n const recentlyUpdatedCursors = new Map();\n const awareness =\n options.provider &&\n \"awareness\" in options.provider &&\n typeof options.provider.awareness === \"object\"\n ? options.provider.awareness\n : undefined;\n if (awareness) {\n if (\n \"setLocalStateField\" in awareness &&\n typeof awareness.setLocalStateField === \"function\"\n ) {\n awareness.setLocalStateField(\"user\", options.user);\n }\n }\n\n const handleAwarenessChange = ({\n updated,\n }: {\n added: Array<number>;\n updated: Array<number>;\n removed: Array<number>;\n }) => {\n for (const clientID of updated) {\n const cursor = recentlyUpdatedCursors.get(clientID);\n\n if (cursor) {\n setTimeout(() => {\n cursor.element.setAttribute(\"data-active\", \"\");\n }, 10);\n\n if (cursor.hideTimeout) {\n clearTimeout(cursor.hideTimeout);\n }\n\n recentlyUpdatedCursors.set(clientID, {\n element: cursor.element,\n hideTimeout: setTimeout(() => {\n cursor.element.removeAttribute(\"data-active\");\n }, 2000),\n });\n }\n }\n };\n\n return {\n key: \"yCursor\",\n mount() {\n if (\n awareness &&\n options.showCursorLabels !== \"always\" &&\n \"on\" in awareness &&\n typeof awareness.on === \"function\"\n ) {\n awareness.on(\"change\", handleAwarenessChange);\n\n return () => {\n if (\"off\" in awareness && typeof awareness.off === \"function\") {\n awareness.off(\"change\", handleAwarenessChange);\n }\n };\n }\n\n return undefined;\n },\n prosemirrorPlugins: [\n awareness\n ? yCursorPlugin(awareness, {\n selectionBuilder: defaultSelectionBuilder,\n cursorBuilder(user: CollaborationUser, clientID: number) {\n let cursorData = recentlyUpdatedCursors.get(clientID);\n\n if (!cursorData) {\n const cursorElement = (\n options.renderCursor ?? defaultCursorRender\n )(user);\n\n if (options.showCursorLabels !== \"always\") {\n cursorElement.addEventListener(\"mouseenter\", () => {\n const cursor = recentlyUpdatedCursors.get(clientID)!;\n cursor.element.setAttribute(\"data-active\", \"\");\n\n if (cursor.hideTimeout) {\n clearTimeout(cursor.hideTimeout);\n recentlyUpdatedCursors.set(clientID, {\n element: cursor.element,\n hideTimeout: undefined,\n });\n }\n });\n\n cursorElement.addEventListener(\"mouseleave\", () => {\n const cursor = recentlyUpdatedCursors.get(clientID)!;\n\n recentlyUpdatedCursors.set(clientID, {\n element: cursor.element,\n hideTimeout: setTimeout(() => {\n cursor.element.removeAttribute(\"data-active\");\n }, 2000),\n });\n });\n }\n\n cursorData = {\n element: cursorElement,\n hideTimeout: undefined,\n };\n\n recentlyUpdatedCursors.set(clientID, cursorData);\n }\n\n return cursorData.element;\n },\n })\n : undefined,\n ].filter(Boolean),\n dependsOn: [\"ySync\"],\n updateUser(user: { name: string; color: string; [key: string]: string }) {\n awareness?.setLocalStateField(\"user\", user);\n },\n getUser(): CollaborationUser | undefined {\n const state = awareness?.getLocalState();\n if (!state) {\n return undefined;\n }\n return state[\"user\"];\n },\n } as const;\n },\n);\n","import { ySyncPlugin } from \"y-prosemirror\";\nimport {\n ExtensionOptions,\n createExtension,\n} from \"../../editor/BlockNoteExtension.js\";\nimport type { CollaborationOptions } from \"./index.js\";\n\nexport const YSyncExtension = createExtension(\n ({ options }: ExtensionOptions<Pick<CollaborationOptions, \"fragment\">>) => {\n return {\n key: \"ySync\",\n prosemirrorPlugins: [ySyncPlugin(options.fragment)],\n runsBefore: [\"default\"],\n } as const;\n },\n);\n","import { redoCommand, undoCommand, yUndoPlugin } from \"y-prosemirror\";\nimport { createExtension } from \"../../editor/BlockNoteExtension.js\";\n\nexport const YUndoExtension = createExtension(() => {\n return {\n key: \"yUndo\",\n prosemirrorPlugins: [yUndoPlugin()],\n dependsOn: [\"yCursor\", \"ySync\"],\n undoCommand: undoCommand,\n redoCommand: redoCommand,\n } as const;\n});\n","import { ySyncPluginKey, yUndoPluginKey } from \"y-prosemirror\";\nimport * as Y from \"yjs\";\nimport {\n createExtension,\n createStore,\n ExtensionOptions,\n} from \"../../editor/BlockNoteExtension.js\";\nimport type { CollaborationOptions } from \"./index.js\";\nimport { YCursorExtension } from \"./YCursorPlugin.js\";\nimport { YSyncExtension } from \"./YSync.js\";\nimport { YUndoExtension } from \"./YUndo.js\";\nimport { findTypeInOtherYdoc } from \"../utils.js\";\n\nexport const ForkYDocExtension = createExtension(\n ({ editor, options }: ExtensionOptions<CollaborationOptions>) => {\n let forkedState:\n | {\n originalFragment: Y.XmlFragment;\n undoHistory:\n | {\n undoStack: Y.UndoManager[\"undoStack\"];\n redoStack: Y.UndoManager[\"redoStack\"];\n }\n | undefined;\n forkedFragment: Y.XmlFragment;\n cursor: ReturnType<ReturnType<typeof YCursorExtension>> | undefined;\n }\n | undefined = undefined;\n\n const store = createStore({ isForked: false });\n\n return {\n key: \"yForkDoc\",\n store,\n /**\n * Fork the Y.js document from syncing to the remote,\n * allowing modifications to the document without affecting the remote.\n * These changes can later be rolled back or applied to the remote.\n */\n fork({\n /**\n * The initial update to apply to the forked document.\n * If not provided, the current document state is used.\n */\n initialUpdate,\n }: {\n initialUpdate?: Uint8Array;\n } = {}) {\n if (forkedState) {\n return;\n }\n\n const originalFragment = options.fragment;\n\n if (!originalFragment) {\n throw new Error(\"No fragment to fork from\");\n }\n\n const doc = new Y.Doc();\n // Copy the original document (or apply the provided update) to a new Yjs document\n Y.applyUpdate(\n doc,\n initialUpdate ?? Y.encodeStateAsUpdate(originalFragment.doc!),\n );\n\n // Find the forked fragment in the new Yjs document\n const forkedFragment = findTypeInOtherYdoc(originalFragment, doc);\n\n // Version previews detach undo before forking. Keep it absent through\n // snapshot replacement and merge; the preview owner reinstalls it.\n const originalUndoManager = yUndoPluginKey.getState(\n editor.prosemirrorState,\n )?.undoManager;\n forkedState = {\n undoHistory: originalUndoManager\n ? {\n undoStack: originalUndoManager.undoStack,\n redoStack: originalUndoManager.redoStack,\n }\n : undefined,\n originalFragment,\n forkedFragment,\n cursor: editor.getExtension(YCursorExtension),\n };\n\n const newOptions = {\n ...options,\n fragment: forkedFragment,\n };\n\n // Atomically swap the yjs plugins to avoid re-entrant dispatch issues\n // where y-prosemirror's view hooks can dispatch a transaction between\n // separate unregister/register calls, re-introducing stale plugins.\n editor.replaceExtension(\n [\"ySync\", \"yCursor\", \"yUndo\"],\n [\n YSyncExtension(newOptions),\n // No need to register the cursor plugin again, it's a local fork\n ...(originalUndoManager ? [YUndoExtension()] : []),\n ],\n { resetPluginStateFor: [ySyncPluginKey, yUndoPluginKey] },\n );\n options.provider?.awareness?.setLocalStateField(\"cursor\", null);\n\n // Tell the store that the editor is now forked\n store.setState({ isForked: true });\n },\n\n /** Replace only the local fork, retaining live restoration state. */\n replaceSnapshot(initialUpdate: Uint8Array) {\n if (!forkedState) {\n throw new Error(\"Replacing a snapshot requires a forked document\");\n }\n const doc = new Y.Doc();\n Y.applyUpdate(doc, initialUpdate);\n const fragment = findTypeInOtherYdoc(forkedState.originalFragment, doc);\n const oldDoc = forkedState.forkedFragment.doc;\n editor.replaceExtension(\n [\"ySync\", \"yUndo\"],\n [\n YSyncExtension({ ...options, fragment }),\n ...(forkedState.undoHistory ? [YUndoExtension()] : []),\n ],\n { resetPluginStateFor: [ySyncPluginKey, yUndoPluginKey] },\n );\n forkedState.forkedFragment = fragment;\n oldDoc?.destroy();\n },\n\n /**\n * Resume syncing the Y.js document to the remote\n * If `keepChanges` is true, any changes that have been made to the forked document will be applied to the original document.\n * Otherwise, the original document will be restored and the changes will be discarded.\n */\n merge({ keepChanges }: { keepChanges: boolean }) {\n if (!forkedState) {\n return;\n }\n\n const { originalFragment, forkedFragment, undoHistory, cursor } =\n forkedState;\n\n // Atomically swap the forked plugins back to the original ones\n editor.replaceExtension(\n [\"ySync\", \"yCursor\", \"yUndo\"],\n [\n YSyncExtension(options),\n ...(cursor ? [cursor] : []),\n ...(undoHistory ? [YUndoExtension()] : []),\n ],\n { resetPluginStateFor: [ySyncPluginKey, yUndoPluginKey] },\n );\n if (undoHistory) {\n const undoManager = yUndoPluginKey.getState(\n editor.prosemirrorState,\n )!.undoManager;\n undoManager.undoStack = undoHistory.undoStack;\n undoManager.redoStack = undoHistory.redoStack;\n }\n if (keepChanges) {\n // Apply any changes that have been made to the fork, onto the original doc\n const update = Y.encodeStateAsUpdate(\n forkedFragment.doc!,\n Y.encodeStateVector(originalFragment.doc!),\n );\n // Keep the existing editor origin for the merged update.\n Y.applyUpdate(originalFragment.doc!, update, editor);\n }\n // Reset the forked state\n forkedState = undefined;\n forkedFragment.doc!.destroy();\n // Tell the store that the editor is no longer forked\n store.setState({ isForked: false });\n },\n } as const;\n },\n);\n","import {\n absolutePositionToRelativePosition,\n relativePositionToAbsolutePosition,\n ySyncPluginKey,\n} from \"y-prosemirror\";\nimport { createExtension } from \"../../editor/BlockNoteExtension.js\";\nimport type { PositionMappingExtension } from \"../../extensions/index.js\";\n\nexport const RelativePositionMappingExtension = createExtension(\n ({ editor }) => {\n return {\n key: \"yPositionMapping\",\n mapPosition: (position: number, side: \"left\" | \"right\" = \"left\") => {\n const ySyncPluginState = ySyncPluginKey.getState(\n editor.prosemirrorState,\n );\n if (!ySyncPluginState) {\n throw new Error(\"YSync plugin state not found\");\n }\n\n // 0 is a special case & always should map to itself\n if (position === 0) {\n return () => 0;\n }\n\n // If the document is empty, it has not been synced yet\n if (ySyncPluginState.binding.type.length === 0) {\n // so, we just fallback to the prosemirror position mapping extension\n // If a remote transaction or sync happens in this case. The position map will be invalidated,\n // and the positions will be moved to the end of the document\n // This is acceptable, because the document had not been synced so there are no positions to map properly into\n const fallback =\n editor.getExtension<typeof PositionMappingExtension>(\n \"positionMapping\",\n );\n if (!fallback) {\n throw new Error(\n \"positionMapping extension is not available; cannot map position before sync\",\n );\n }\n return fallback.mapPosition(position, side);\n }\n\n const relativePosition = absolutePositionToRelativePosition(\n position + (side === \"right\" ? 1 : -1),\n ySyncPluginState.binding.type,\n ySyncPluginState.binding.mapping,\n );\n\n return () => {\n const curYSyncPluginState = ySyncPluginKey.getState(\n editor.prosemirrorState,\n ) as typeof ySyncPluginState;\n // Resolve against the doc that owns the currently bound type, and not\n // against `curYSyncPluginState.doc`. Those can point at different\n // Y.Docs (e.g. right after forking the doc, see `ForkYDocExtension`),\n // in which case the resolved type wouldn't be part of the bound\n // fragment and the position would be reported as \"not found\".\n const boundType = curYSyncPluginState.binding.type;\n const pos = relativePositionToAbsolutePosition(\n boundType.doc,\n boundType,\n relativePosition,\n curYSyncPluginState.binding.mapping,\n );\n\n // This can happen if the element is garbage collected\n if (pos === null) {\n throw new Error(\"Position not found, cannot track positions\");\n }\n\n return pos + (side === \"right\" ? -1 : 1);\n };\n },\n } as const;\n },\n);\n","import * as Y from \"yjs\";\n\nimport { MigrationRule } from \"./migrationRule.js\";\nimport { defaultProps } from \"../../../../blocks/defaultProps.js\";\n\n// Helper function to recursively traverse a `Y.XMLElement` and its descendant\n// elements.\nconst traverseElement = (\n rootElement: Y.XmlElement,\n cb: (element: Y.XmlElement) => void,\n) => {\n cb(rootElement);\n rootElement.forEach((element) => {\n if (element instanceof Y.XmlElement) {\n traverseElement(element, cb);\n }\n });\n};\n\n// Moves `textColor` and `backgroundColor` attributes from `blockContainer`\n// nodes to their child `blockContent` nodes. This is due to a schema change\n// introduced in PR #TODO.\nexport const moveColorAttributes: MigrationRule = (fragment, tr) => {\n // Stores necessary info for all `blockContainer` nodes which still have\n // `textColor` or `backgroundColor` attributes that need to be moved.\n const targetBlockContainers: Map<\n string,\n {\n textColor: string | undefined;\n backgroundColor: string | undefined;\n }\n > = new Map();\n // Finds all elements which still have `textColor` or `backgroundColor`\n // attributes in the current Yjs fragment.\n fragment.forEach((element) => {\n if (element instanceof Y.XmlElement) {\n traverseElement(element, (element) => {\n if (\n element.nodeName === \"blockContainer\" &&\n element.hasAttribute(\"id\")\n ) {\n const textColor = element.getAttribute(\"textColor\");\n const backgroundColor = element.getAttribute(\"backgroundColor\");\n\n const colors = {\n textColor:\n textColor === defaultProps.textColor.default\n ? undefined\n : textColor,\n backgroundColor:\n backgroundColor === defaultProps.backgroundColor.default\n ? undefined\n : backgroundColor,\n };\n\n if (colors.textColor || colors.backgroundColor) {\n targetBlockContainers.set(element.getAttribute(\"id\")!, colors);\n }\n }\n });\n }\n });\n\n if (targetBlockContainers.size === 0) {\n return false;\n }\n\n // Appends transactions to add the `textColor` and `backgroundColor`\n // attributes found on each `blockContainer` node to move them to the child\n // `blockContent` node.\n tr.doc.descendants((node, pos) => {\n if (\n node.type.name === \"blockContainer\" &&\n targetBlockContainers.has(node.attrs.id)\n ) {\n const el = tr.doc.nodeAt(pos + 1);\n if (!el) {\n throw new Error(\"No element found\");\n }\n\n tr.setNodeMarkup(pos + 1, undefined, {\n // preserve existing attributes\n ...el.attrs,\n // add the textColor and backgroundColor attributes\n ...targetBlockContainers.get(node.attrs.id),\n });\n }\n });\n\n return true;\n};\n","import { MigrationRule } from \"./migrationRule.js\";\nimport { moveColorAttributes } from \"./moveColorAttributes.js\";\n\nexport default [moveColorAttributes] as MigrationRule[];\n","import { Plugin, PluginKey } from \"@tiptap/pm/state\";\nimport * as Y from \"yjs\";\n\nimport {\n createExtension,\n ExtensionOptions,\n} from \"../../../editor/BlockNoteExtension.js\";\nimport migrationRules from \"./migrationRules/index.js\";\n\n// This plugin allows us to update collaboration YDocs whenever BlockNote's\n// underlying ProseMirror schema changes. The plugin reads the current Yjs\n// fragment and dispatches additional transactions to the ProseMirror state, in\n// case things are found in the fragment that don't adhere to the editor schema\n// and need to be fixed. These fixes are defined as `MigrationRule`s within the\n// `migrationRules` directory.\nexport const SchemaMigration = createExtension(\n ({ options }: ExtensionOptions<{ fragment: Y.XmlFragment }>) => {\n let migrationDone = false;\n const pluginKey = new PluginKey(\"schemaMigration\");\n\n return {\n key: \"schemaMigration\",\n prosemirrorPlugins: [\n new Plugin({\n key: pluginKey,\n appendTransaction: (transactions, _oldState, newState) => {\n if (migrationDone) {\n return undefined;\n }\n\n if (\n // If any of the transactions are not due to a yjs sync, we don't need to run the migration\n !transactions.some((tr) => tr.getMeta(\"y-sync$\")) ||\n // If none of the transactions result in a document change, we don't need to run the migration\n transactions.every((tr) => !tr.docChanged) ||\n // If the fragment is still empty, we can't run the migration (since it has not yet been applied to the Y.Doc)\n !options.fragment.firstChild\n ) {\n return undefined;\n }\n\n const tr = newState.tr;\n for (const migrationRule of migrationRules) {\n migrationRule(options.fragment, tr);\n }\n\n migrationDone = true;\n\n if (!tr.docChanged) {\n return undefined;\n }\n\n return tr;\n },\n }),\n ],\n } as const;\n },\n);\n","import type { Awareness } from \"y-protocols/awareness\";\nimport type * as Y from \"yjs\";\nimport type { BlockNoteEditorOptions } from \"../../editor/BlockNoteEditor\";\nimport {\n createExtension,\n type ExtensionOptions,\n} from \"../../editor/BlockNoteExtension.js\";\nimport { FixUpSchemaExtension } from \"./FixUpSchema.js\";\nimport { ForkYDocExtension } from \"./ForkYDoc.js\";\nimport { RelativePositionMappingExtension } from \"./RelativePositionMapping.js\";\nimport { SchemaMigration } from \"./schemaMigration/SchemaMigration.js\";\nimport { CollaborationUser, YCursorExtension } from \"./YCursorPlugin.js\";\nimport { YSyncExtension } from \"./YSync.js\";\nimport { YUndoExtension } from \"./YUndo.js\";\n\nexport type CollaborationOptions = {\n /**\n * The Yjs XML fragment that's used for collaboration.\n */\n fragment: Y.XmlFragment;\n /**\n * The user info for the current user that's shown to other collaborators.\n */\n user: CollaborationUser;\n /**\n * A Yjs provider (used for awareness / cursor information)\n */\n provider?: { awareness?: Awareness };\n /**\n * Optional function to customize how cursors of users are rendered\n */\n renderCursor?: (user: CollaborationUser) => HTMLElement;\n /**\n * Optional flag to set when the user label should be shown with the default\n * collaboration cursor. Setting to \"always\" will always show the label,\n * while \"activity\" will only show the label when the user moves the cursor\n * or types. Defaults to \"activity\".\n */\n showCursorLabels?: \"always\" | \"activity\";\n};\n\nexport const CollaborationExtension = createExtension(\n ({ options }: ExtensionOptions<CollaborationOptions>) => {\n return {\n key: \"collaboration\",\n fragment: options.fragment,\n blockNoteExtensions: [\n FixUpSchemaExtension(),\n ForkYDocExtension(options),\n RelativePositionMappingExtension(),\n SchemaMigration(options),\n YCursorExtension(options),\n YSyncExtension(options),\n YUndoExtension(),\n ],\n } as const;\n },\n);\n\nexport function withCollaboration<\n Options extends Partial<BlockNoteEditorOptions<any, any, any>>,\n>(\n options: Options & {\n /**\n * Options for configuring the collaboration functionality.\n */\n collaboration: CollaborationOptions;\n },\n): Options {\n return {\n ...options,\n extensions: [\n ...(options.extensions ?? []),\n CollaborationExtension(options.collaboration),\n ],\n // We disable the default prosemirror history plugin, since it's not compatible with yjs\n disableExtensions: [\"history\", ...(options.disableExtensions ?? [])],\n // We don't want the default initial content, since it will generate a random id for the initial block on each client,\n // leading to conflicts when syncing happens afterwards.\n initialContent: [{ type: \"paragraph\", id: \"initialBlockId\" }],\n };\n}\n\nexport * from \"./ForkYDoc.js\";\nexport * from \"./RelativePositionMapping.js\";\nexport * from \"./schemaMigration/SchemaMigration.js\";\nexport * from \"./YCursorPlugin.js\";\nexport * from \"./YSync.js\";\nexport * from \"./YUndo.js\";\n","import * as Y from \"yjs\";\nimport type {\n CommentData,\n CommentReactionData,\n ThreadData,\n} from \"../../comments/types.js\";\n\nexport function commentToYMap(comment: CommentData) {\n const yMap = new Y.Map<any>();\n yMap.set(\"id\", comment.id);\n yMap.set(\"userId\", comment.userId);\n yMap.set(\"createdAt\", comment.createdAt.getTime());\n yMap.set(\"updatedAt\", comment.updatedAt.getTime());\n if (comment.deletedAt) {\n yMap.set(\"deletedAt\", comment.deletedAt.getTime());\n yMap.set(\"body\", undefined);\n } else {\n yMap.set(\"body\", comment.body);\n }\n if (comment.reactions.length > 0) {\n throw new Error(\"Reactions should be empty in commentToYMap\");\n }\n\n /**\n * Reactions are stored in a map keyed by {userId-emoji},\n * this makes it easy to add / remove reactions and in a way that works local-first.\n * The cost is that \"reading\" the reactions is a bit more complex (see yMapToReactions).\n */\n yMap.set(\"reactionsByUser\", new Y.Map());\n yMap.set(\"metadata\", comment.metadata);\n\n return yMap;\n}\n\nexport function threadToYMap(thread: ThreadData) {\n const yMap = new Y.Map();\n yMap.set(\"id\", thread.id);\n yMap.set(\"createdAt\", thread.createdAt.getTime());\n yMap.set(\"updatedAt\", thread.updatedAt.getTime());\n const commentsArray = new Y.Array<Y.Map<any>>();\n\n commentsArray.push(thread.comments.map((comment) => commentToYMap(comment)));\n\n yMap.set(\"comments\", commentsArray);\n yMap.set(\"resolved\", thread.resolved);\n yMap.set(\"resolvedUpdatedAt\", thread.resolvedUpdatedAt?.getTime());\n yMap.set(\"resolvedBy\", thread.resolvedBy);\n yMap.set(\"metadata\", thread.metadata);\n return yMap;\n}\n\ntype SingleUserCommentReactionData = {\n emoji: string;\n createdAt: Date;\n userId: string;\n};\n\nexport function yMapToReaction(\n yMap: Y.Map<any>,\n): SingleUserCommentReactionData {\n return {\n emoji: yMap.get(\"emoji\"),\n createdAt: new Date(yMap.get(\"createdAt\")),\n userId: yMap.get(\"userId\"),\n };\n}\n\nfunction yMapToReactions(yMap: Y.Map<any>): CommentReactionData[] {\n const flatReactions = [...yMap.values()].map((reaction: Y.Map<any>) =>\n yMapToReaction(reaction),\n );\n // combine reactions by the same emoji\n return flatReactions.reduce(\n (acc: CommentReactionData[], reaction: SingleUserCommentReactionData) => {\n const existingReaction = acc.find((r) => r.emoji === reaction.emoji);\n if (existingReaction) {\n existingReaction.userIds.push(reaction.userId);\n existingReaction.createdAt = new Date(\n Math.min(\n existingReaction.createdAt.getTime(),\n reaction.createdAt.getTime(),\n ),\n );\n } else {\n acc.push({\n emoji: reaction.emoji,\n createdAt: reaction.createdAt,\n userIds: [reaction.userId],\n });\n }\n return acc;\n },\n [] as CommentReactionData[],\n );\n}\n\nexport function yMapToComment(yMap: Y.Map<any>): CommentData {\n return {\n type: \"comment\",\n id: yMap.get(\"id\"),\n userId: yMap.get(\"userId\"),\n createdAt: new Date(yMap.get(\"createdAt\")),\n updatedAt: new Date(yMap.get(\"updatedAt\")),\n deletedAt: yMap.get(\"deletedAt\")\n ? new Date(yMap.get(\"deletedAt\"))\n : undefined,\n reactions: yMapToReactions(yMap.get(\"reactionsByUser\")),\n metadata: yMap.get(\"metadata\"),\n body: yMap.get(\"body\"),\n };\n}\n\nexport function yMapToThread(yMap: Y.Map<any>): ThreadData {\n return {\n type: \"thread\",\n id: yMap.get(\"id\"),\n createdAt: new Date(yMap.get(\"createdAt\")),\n updatedAt: new Date(yMap.get(\"updatedAt\")),\n comments: ((yMap.get(\"comments\") as Y.Array<Y.Map<any>>) || []).map(\n (comment) => yMapToComment(comment),\n ),\n resolved: yMap.get(\"resolved\"),\n resolvedUpdatedAt: new Date(yMap.get(\"resolvedUpdatedAt\")),\n resolvedBy: yMap.get(\"resolvedBy\"),\n metadata: yMap.get(\"metadata\"),\n };\n}\n","import * as Y from \"yjs\";\nimport type { ThreadData } from \"../../comments/types.js\";\nimport { ThreadStore } from \"../../comments/threadstore/ThreadStore.js\";\nimport type { ThreadStoreAuth } from \"../../comments/threadstore/ThreadStoreAuth.js\";\nimport { yMapToThread } from \"./yjsHelpers.js\";\n\n/**\n * This is an abstract class that only implements the READ methods required by the ThreadStore interface.\n * The data is read from a Yjs Map.\n */\nexport abstract class YjsThreadStoreBase extends ThreadStore {\n constructor(\n protected readonly threadsYMap: Y.Map<any>,\n auth: ThreadStoreAuth,\n ) {\n super(auth);\n }\n\n // TODO: async / reactive interface?\n public getThread(threadId: string) {\n const yThread = this.threadsYMap.get(threadId);\n if (!yThread) {\n throw new Error(\"Thread not found\");\n }\n const thread = yMapToThread(yThread);\n return thread;\n }\n\n public getThreads(): Map<string, ThreadData> {\n const threadMap = new Map<string, ThreadData>();\n this.threadsYMap.forEach((yThread, id) => {\n if (yThread instanceof Y.Map) {\n threadMap.set(id, yMapToThread(yThread));\n }\n });\n return threadMap;\n }\n\n public subscribe(cb: (threads: Map<string, ThreadData>) => void) {\n const observer = () => {\n cb(this.getThreads());\n };\n\n this.threadsYMap.observeDeep(observer);\n\n return () => {\n this.threadsYMap.unobserveDeep(observer);\n };\n }\n}\n","import * as Y from \"yjs\";\nimport {\n absolutePositionToRelativePosition,\n ySyncPluginKey,\n} from \"y-prosemirror\";\nimport type { CommentBody } from \"../../comments/types.js\";\nimport type { ThreadStoreAuth } from \"../../comments/threadstore/ThreadStoreAuth.js\";\nimport { YjsThreadStoreBase } from \"./YjsThreadStoreBase.js\";\nimport { BlockNoteEditor } from \"../../editor/BlockNoteEditor.js\";\n\n/**\n * This is a REST-based implementation of the YjsThreadStoreBase.\n * It Reads data directly from the underlying document (same as YjsThreadStore),\n * but for Writes, it sends data to a REST API that should:\n * - check the user has the correct permissions to make the desired changes\n * - apply the updates to the underlying Yjs document\n *\n * (see https://github.com/TypeCellOS/BlockNote-demo-nextjs-hocuspocus)\n *\n * The reason we still use the Yjs document as underlying storage is that it makes it easy to\n * sync updates in real-time to other collaborators.\n * (but technically, you could also implement a different storage altogether\n * and not store the thread related data in the Yjs document)\n */\nexport class RESTYjsThreadStore extends YjsThreadStoreBase {\n constructor(\n private readonly BASE_URL: string,\n private readonly headers: Record<string, string>,\n threadsYMap: Y.Map<any>,\n auth: ThreadStoreAuth,\n ) {\n super(threadsYMap, auth);\n }\n\n private doRequest = async (path: string, method: string, body?: any) => {\n const response = await fetch(`${this.BASE_URL}${path}`, {\n method,\n body: JSON.stringify(body),\n headers: {\n \"Content-Type\": \"application/json\",\n ...this.headers,\n },\n });\n\n if (!response.ok) {\n throw new Error(`Failed to ${method} ${path}: ${response.statusText}`);\n }\n\n return response.json();\n };\n\n public addThreadToDocument = async (options: {\n threadId: string;\n selection: {\n head: number;\n anchor: number;\n };\n editor: BlockNoteEditor<any, any, any>;\n }) => {\n const { threadId, selection } = options;\n\n // Note: the positions have to be resolved against the *binding's* type and\n // mapping. The plugin state has a `type` of its own, but no `mapping`, and\n // its `type` can go stale (e.g. while the doc is forked, see\n // `ForkYDocExtension`).\n const binding = ySyncPluginKey.getState(\n options.editor.prosemirrorState,\n )?.binding;\n const yjsSelection = binding\n ? {\n head: absolutePositionToRelativePosition(\n selection.head,\n binding.type,\n binding.mapping,\n ),\n anchor: absolutePositionToRelativePosition(\n selection.anchor,\n binding.type,\n binding.mapping,\n ),\n }\n : undefined;\n\n return this.doRequest(`/${threadId}/addToDocument`, \"POST\", {\n selection: {\n prosemirror: selection,\n yjs: yjsSelection,\n },\n });\n };\n\n public createThread = async (options: {\n initialComment: {\n body: CommentBody;\n metadata?: any;\n };\n metadata?: any;\n }) => {\n return this.doRequest(\"\", \"POST\", options);\n };\n\n public addComment = (options: {\n comment: {\n body: CommentBody;\n metadata?: any;\n };\n threadId: string;\n }) => {\n const { threadId, ...rest } = options;\n return this.doRequest(`/${threadId}/comments`, \"POST\", rest);\n };\n\n public updateComment = (options: {\n comment: {\n body: CommentBody;\n metadata?: any;\n };\n threadId: string;\n commentId: string;\n }) => {\n const { threadId, commentId, ...rest } = options;\n return this.doRequest(`/${threadId}/comments/${commentId}`, \"PUT\", rest);\n };\n\n public deleteComment = (options: {\n threadId: string;\n commentId: string;\n softDelete?: boolean;\n }) => {\n const { threadId, commentId, ...rest } = options;\n return this.doRequest(\n `/${threadId}/comments/${commentId}?soft=${!!rest.softDelete}`,\n \"DELETE\",\n );\n };\n\n public deleteThread = (options: { threadId: string }) => {\n return this.doRequest(`/${options.threadId}`, \"DELETE\");\n };\n\n public resolveThread = (options: { threadId: string }) => {\n return this.doRequest(`/${options.threadId}/resolve`, \"POST\");\n };\n\n public unresolveThread = (options: { threadId: string }) => {\n return this.doRequest(`/${options.threadId}/unresolve`, \"POST\");\n };\n\n public addReaction = (options: {\n threadId: string;\n commentId: string;\n emoji: string;\n }) => {\n const { threadId, commentId, ...rest } = options;\n return this.doRequest(\n `/${threadId}/comments/${commentId}/reactions`,\n \"POST\",\n rest,\n );\n };\n\n public deleteReaction = (options: {\n threadId: string;\n commentId: string;\n emoji: string;\n }) => {\n return this.doRequest(\n `/${options.threadId}/comments/${options.commentId}/reactions/${options.emoji}`,\n \"DELETE\",\n );\n };\n}\n","import * as Y from \"yjs\";\nimport { uuidv4 } from \"lib0/random\";\nimport type {\n CommentBody,\n CommentData,\n ThreadData,\n} from \"../../comments/types.js\";\nimport type { ThreadStoreAuth } from \"../../comments/threadstore/ThreadStoreAuth.js\";\nimport { YjsThreadStoreBase } from \"./YjsThreadStoreBase.js\";\nimport {\n commentToYMap,\n threadToYMap,\n yMapToComment,\n yMapToThread,\n} from \"./yjsHelpers.js\";\n\n/**\n * This is a Yjs-based implementation of the ThreadStore interface.\n *\n * It reads and writes thread / comments information directly to the underlying Yjs Document.\n *\n * @important While this is the easiest to add to your app, there are two challenges:\n * - The user needs to be able to write to the Yjs document to store the information.\n * So a user without write access to the Yjs document cannot leave any comments.\n * - Even with write access, the operations are not secure. Unless your Yjs server\n * guards against malicious operations, it's technically possible for one user to make changes to another user's comments, etc.\n * (even though these options are not visible in the UI, a malicious user can make unauthorized changes to the underlying Yjs document)\n */\nexport class YjsThreadStore extends YjsThreadStoreBase {\n constructor(\n private readonly userId: string,\n threadsYMap: Y.Map<any>,\n auth: ThreadStoreAuth,\n ) {\n super(threadsYMap, auth);\n }\n\n private transact = <T, R>(\n fn: (options: T) => R,\n ): ((options: T) => Promise<R>) => {\n return async (options: T) => {\n return this.threadsYMap.doc!.transact(() => {\n return fn(options);\n });\n };\n };\n\n public createThread = this.transact(\n (options: {\n initialComment: {\n body: CommentBody;\n metadata?: any;\n };\n metadata?: any;\n }) => {\n if (!this.auth.canCreateThread()) {\n throw new Error(\"Not authorized\");\n }\n\n const date = new Date();\n\n const comment: CommentData = {\n type: \"comment\",\n id: uuidv4(),\n userId: this.userId,\n createdAt: date,\n updatedAt: date,\n reactions: [],\n metadata: options.initialComment.metadata,\n body: options.initialComment.body,\n };\n\n const thread: ThreadData = {\n type: \"thread\",\n id: uuidv4(),\n createdAt: date,\n updatedAt: date,\n comments: [comment],\n resolved: false,\n metadata: options.metadata,\n };\n\n this.threadsYMap.set(thread.id, threadToYMap(thread));\n\n return thread;\n },\n );\n\n // YjsThreadStore does not support addThreadToDocument\n public addThreadToDocument = undefined;\n\n public addComment = this.transact(\n (options: {\n comment: {\n body: CommentBody;\n metadata?: any;\n };\n threadId: string;\n }) => {\n const yThread = this.threadsYMap.get(options.threadId);\n if (!yThread) {\n throw new Error(\"Thread not found\");\n }\n\n if (!this.auth.canAddComment(yMapToThread(yThread))) {\n throw new Error(\"Not authorized\");\n }\n\n const date = new Date();\n const comment: CommentData = {\n type: \"comment\",\n id: uuidv4(),\n userId: this.userId,\n createdAt: date,\n updatedAt: date,\n deletedAt: undefined,\n reactions: [],\n metadata: options.comment.metadata,\n body: options.comment.body,\n };\n\n (yThread.get(\"comments\") as Y.Array<Y.Map<any>>).push([\n commentToYMap(comment),\n ]);\n\n yThread.set(\"updatedAt\", new Date().getTime());\n return comment;\n },\n );\n\n public updateComment = this.transact(\n (options: {\n comment: {\n body: CommentBody;\n metadata?: any;\n };\n threadId: string;\n commentId: string;\n }) => {\n const yThread = this.threadsYMap.get(options.threadId);\n if (!yThread) {\n throw new Error(\"Thread not found\");\n }\n\n const yCommentIndex = yArrayFindIndex(\n yThread.get(\"comments\"),\n (comment) => comment.get(\"id\") === options.commentId,\n );\n\n if (yCommentIndex === -1) {\n throw new Error(\"Comment not found\");\n }\n\n const yComment = yThread.get(\"comments\").get(yCommentIndex);\n\n if (!this.auth.canUpdateComment(yMapToComment(yComment))) {\n throw new Error(\"Not authorized\");\n }\n\n yComment.set(\"body\", options.comment.body);\n yComment.set(\"updatedAt\", new Date().getTime());\n yComment.set(\"metadata\", options.comment.metadata);\n },\n );\n\n public deleteComment = this.transact(\n (options: {\n threadId: string;\n commentId: string;\n softDelete?: boolean;\n }) => {\n const yThread = this.threadsYMap.get(options.threadId);\n if (!yThread) {\n throw new Error(\"Thread not found\");\n }\n\n const yCommentIndex = yArrayFindIndex(\n yThread.get(\"comments\"),\n (comment) => comment.get(\"id\") === options.commentId,\n );\n\n if (yCommentIndex === -1) {\n throw new Error(\"Comment not found\");\n }\n\n const yComment = yThread.get(\"comments\").get(yCommentIndex);\n\n if (!this.auth.canDeleteComment(yMapToComment(yComment))) {\n throw new Error(\"Not authorized\");\n }\n\n if (yComment.get(\"deletedAt\")) {\n throw new Error(\"Comment already deleted\");\n }\n\n if (options.softDelete) {\n yComment.set(\"deletedAt\", new Date().getTime());\n yComment.set(\"body\", undefined);\n } else {\n yThread.get(\"comments\").delete(yCommentIndex);\n }\n\n if (\n (yThread.get(\"comments\") as Y.Array<any>)\n .toArray()\n .every((comment) => comment.get(\"deletedAt\"))\n ) {\n // all comments deleted\n if (options.softDelete) {\n yThread.set(\"deletedAt\", new Date().getTime());\n } else {\n this.threadsYMap.delete(options.threadId);\n }\n }\n\n yThread.set(\"updatedAt\", new Date().getTime());\n },\n );\n\n public deleteThread = this.transact((options: { threadId: string }) => {\n if (\n !this.auth.canDeleteThread(\n yMapToThread(this.threadsYMap.get(options.threadId)),\n )\n ) {\n throw new Error(\"Not authorized\");\n }\n\n this.threadsYMap.delete(options.threadId);\n });\n\n public resolveThread = this.transact((options: { threadId: string }) => {\n const yThread = this.threadsYMap.get(options.threadId);\n if (!yThread) {\n throw new Error(\"Thread not found\");\n }\n\n if (!this.auth.canResolveThread(yMapToThread(yThread))) {\n throw new Error(\"Not authorized\");\n }\n\n yThread.set(\"resolved\", true);\n yThread.set(\"resolvedUpdatedAt\", new Date().getTime());\n yThread.set(\"resolvedBy\", this.userId);\n });\n\n public unresolveThread = this.transact((options: { threadId: string }) => {\n const yThread = this.threadsYMap.get(options.threadId);\n if (!yThread) {\n throw new Error(\"Thread not found\");\n }\n\n if (!this.auth.canUnresolveThread(yMapToThread(yThread))) {\n throw new Error(\"Not authorized\");\n }\n\n yThread.set(\"resolved\", false);\n yThread.set(\"resolvedUpdatedAt\", new Date().getTime());\n });\n\n public addReaction = this.transact(\n (options: { threadId: string; commentId: string; emoji: string }) => {\n const yThread = this.threadsYMap.get(options.threadId);\n if (!yThread) {\n throw new Error(\"Thread not found\");\n }\n\n const yCommentIndex = yArrayFindIndex(\n yThread.get(\"comments\"),\n (comment) => comment.get(\"id\") === options.commentId,\n );\n\n if (yCommentIndex === -1) {\n throw new Error(\"Comment not found\");\n }\n\n const yComment = yThread.get(\"comments\").get(yCommentIndex);\n\n if (!this.auth.canAddReaction(yMapToComment(yComment), options.emoji)) {\n throw new Error(\"Not authorized\");\n }\n\n const date = new Date();\n\n const key = `${this.userId}-${options.emoji}`;\n\n const reactionsByUser = yComment.get(\"reactionsByUser\");\n\n if (reactionsByUser.has(key)) {\n // already exists\n return;\n } else {\n const reaction = new Y.Map();\n reaction.set(\"emoji\", options.emoji);\n reaction.set(\"createdAt\", date.getTime());\n reaction.set(\"userId\", this.userId);\n reactionsByUser.set(key, reaction);\n }\n },\n );\n\n public deleteReaction = this.transact(\n (options: { threadId: string; commentId: string; emoji: string }) => {\n const yThread = this.threadsYMap.get(options.threadId);\n if (!yThread) {\n throw new Error(\"Thread not found\");\n }\n\n const yCommentIndex = yArrayFindIndex(\n yThread.get(\"comments\"),\n (comment) => comment.get(\"id\") === options.commentId,\n );\n\n if (yCommentIndex === -1) {\n throw new Error(\"Comment not found\");\n }\n\n const yComment = yThread.get(\"comments\").get(yCommentIndex);\n\n if (\n !this.auth.canDeleteReaction(yMapToComment(yComment), options.emoji)\n ) {\n throw new Error(\"Not authorized\");\n }\n\n const key = `${this.userId}-${options.emoji}`;\n\n const reactionsByUser = yComment.get(\"reactionsByUser\");\n\n reactionsByUser.delete(key);\n },\n );\n}\n\nfunction yArrayFindIndex(\n yArray: Y.Array<any>,\n predicate: (item: any) => boolean,\n) {\n for (let i = 0; i < yArray.length; i++) {\n if (predicate(yArray.get(i))) {\n return i;\n }\n }\n return -1;\n}\n","import * as Y from \"yjs\";\nimport { ySyncPluginKey } from \"y-prosemirror\";\nimport type { BlockNoteEditor } from \"../../editor/BlockNoteEditor.js\";\nimport { ForkYDocExtension } from \"./ForkYDoc.js\";\nimport type {\n VersionStorage,\n VersionViewAdapter,\n} from \"../../extensions/Versioning/types.js\";\nimport { createVersioningExtension } from \"../../extensions/Versioning/Versioning.js\";\nimport type { UserStoreOrResolver } from \"../../user/index.js\";\nimport { CollaborationExtension } from \"./index.js\";\nimport type { DiffVersioningExtension } from \"../../y/extensions/DiffVersioningExtension.js\";\nimport { findTypeInOtherYdoc, yXmlFragmentToBlocks } from \"../utils.js\";\nimport type {\n BlockSchema,\n InlineContentSchema,\n StyleSchema,\n} from \"../../schema/index.js\";\n\n/**\n * Install history separately, using the editor's Yjs collaboration fragment.\n * Register DiffVersioningExtension from `@blocknote/core/y` to opt into\n * content comparisons. Diffs mark changes, not their original authors.\n */\nexport function YjsVersioningExtension(options: {\n storage: VersionStorage<Uint8Array>;\n resolveUsers?: UserStoreOrResolver;\n scrollToFirstChange?: boolean;\n}) {\n return createVersioningExtension((editor) => ({\n adapter: {\n get supportsComparison() {\n return editor.getExtension(\"diffVersioning\") !== undefined;\n },\n open() {\n const collaboration = editor.getExtension(CollaborationExtension);\n if (!collaboration) {\n throw new Error(\"Yjs versioning requires Yjs collaboration\");\n }\n return createYjsVersionView(editor, collaboration.fragment).open();\n },\n },\n ...options,\n }))();\n}\n\nexport function createYjsVersionView<\n BSchema extends BlockSchema,\n ISchema extends InlineContentSchema,\n SSchema extends StyleSchema,\n>(\n editor: BlockNoteEditor<BSchema, ISchema, SSchema>,\n fragment: Y.XmlFragment,\n): VersionViewAdapter<Uint8Array> {\n return {\n get supportsComparison() {\n return editor.getExtension(\"diffVersioning\") !== undefined;\n },\n open() {\n const fork = editor.getExtension(ForkYDocExtension);\n if (\n !fork ||\n fork.store.state.isForked ||\n ySyncPluginKey.getState(editor.prosemirrorState)?.type !== fragment\n ) {\n throw new Error(\n \"Versioning requires an active live binding and an available fork\",\n );\n }\n const current = {\n content: Y.encodeStateAsUpdate(fragment.doc!),\n capturedAt: Date.now(),\n };\n try {\n fork.fork();\n } catch (error) {\n fork.merge({ keepChanges: false });\n throw error;\n }\n let closed = false;\n return {\n current,\n show({ content, comparison }) {\n if (closed) {\n throw new Error(\"Version view is closed\");\n }\n fork.replaceSnapshot(content);\n if (comparison) {\n const diff =\n editor.getExtension<typeof DiffVersioningExtension>(\n \"diffVersioning\",\n );\n if (!diff) {\n throw new Error(\"Version comparison requires a diff renderer\");\n }\n function blocksFromUpdate(update: Uint8Array) {\n const doc = new Y.Doc();\n try {\n Y.applyUpdate(doc, update);\n return yXmlFragmentToBlocks(\n editor,\n findTypeInOtherYdoc(fragment, doc),\n );\n } finally {\n doc.destroy();\n }\n }\n // The binding points at a disposable fork. Any rendered suggestion\n // marks stay there and are discarded when switching or closing.\n diff.renderDiff(\n blocksFromUpdate(content),\n blocksFromUpdate(comparison.content),\n );\n }\n },\n close() {\n if (closed) {\n return;\n }\n fork.merge({ keepChanges: false });\n closed = true;\n },\n };\n },\n };\n}\n"],"mappings":";;;;;;;;;;AAsBA,SAAgB,EACd,GACA,GACG;CACH,IAAM,IAAO,EAAM;CACnB,IAAI,CAAC,GACH,MAAU,MAAM,2BAA2B;CAE7C,IAAI,EAAM,UAAU,MAAM;EACxB,IAAM,IAAU,MAAM,KAAK,EAAK,MAAM,KAAK,CAAC,CAAC,CAAC,MAC3C,MAAQ,EAAK,MAAM,IAAI,CAAG,MAAM,CACnC;EACA,IAAI,KAAW,MACb,MAAU,MAAM,mCAAmC;EAErD,OAAO,EAAU,IAAI,GAAS,EAAM,WAA0B;CAChE;CAAO;EACL,IAAM,IAAY,EAAM,OAClB,IAAe,EAAU,MAAM,QAAQ,IAAI,EAAU,GAAG,MAAM,KAAK,CAAC,GAEpE,IAAY,EADA,EAAE,YAAY,GAAc,EAAU,GAAG,KAC5B;EAC/B,IAAI,CAAC,GACH,MAAU,MAAM,mCAAmC;EAErD,IAAM,IAAe,EAAU;EAC/B,IAAI,CAAC,GACH,MAAU,MAAM,mCAAmC;EAErD,OAAO,EAAa;CACtB;AACF;AAQA,SAAgB,EAId,GAAoD,GAAW;CAG/D,IAAM,IAAM,EAAO,SAAS,aAAa,CAAI;CAC7C,OAAO,EAAuC,CAAG;AACnD;AAQA,SAAgB,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CACL,EAAE,CAAC,CAAC;AACN;AAEA,SAAgB,EAKd,GACA,GACgC;CAChC,OAAO;EACL,IAAI,qBAAqB;GACvB,OAAO,EAAO,aAAa,gBAAgB,MAAM,KAAA;EACnD;EACA,OAAO;GACL,IAAM,IAAO,EAAO,aAAa,CAAiB;GAClD,IACE,CAAC,KACD,EAAK,MAAM,MAAM,YACjB,EAAe,SAAS,EAAO,gBAAgB,CAAC,EAAE,SAAS,GAE3D,MAAU,MACR,kEACF;GAEF,IAAM,IAAU;IACd,SAAS,EAAE,oBAAoB,EAAS,GAAI;IAC5C,YAAY,KAAK,IAAI;GACvB;GACA,IAAI;IACF,EAAK,KAAK;GACZ,SAAS,GAAO;IAEd,MADA,EAAK,MAAM,EAAE,aAAa,GAAM,CAAC,GAC3B;GACR;GACA,IAAI,IAAS;GACb,OAAO;IACL;IACA,KAAK,EAAE,YAAS,iBAAc;KAC5B,IAAI,GACF,MAAU,MAAM,wBAAwB;KAG1C,IADA,EAAK,gBAAgB,CAAO,GACxB,GAAY;MACd,IAAM,IACJ,EAAO,aACL,gBACF;MACF,IAAI,CAAC,GACH,MAAU,MAAM,6CAA6C;MAE/D,SAAS,EAAiB,GAAoB;OAC5C,IAAM,IAAM,IAAI,EAAE,IAAI;OACtB,IAAI;QAEF,OADA,EAAE,YAAY,GAAK,CAAM,GAClB,EACL,GACA,EAAoB,GAAU,CAAG,CACnC;OACF,UAAU;QACR,EAAI,QAAQ;OACd;MACF;MAGA,EAAK,WACH,EAAiB,CAAO,GACxB,EAAiB,EAAW,OAAO,CACrC;KACF;IACF;IACA,QAAQ;KACF,AAIJ,OADA,EAAK,MAAM,EAAE,aAAa,GAAM,CAAC,GACxB;IACX;GACF;EACF;CACF;AACF"}
package/src/api/README.md DELETED
@@ -1,8 +0,0 @@
1
- ### @blocknote/core/src/api
2
-
3
- Implements the BlockNote API surface
4
-
5
- - `blockManipulation`: API to insert / update / remove blocks
6
- - `exporters`: exporting to HTML / markdown / other formats
7
- - `nodeConversions`: internal API for converting between BlockNote Schema (Blocks) and Prosemirror (Nodes)
8
- - `parsers`: importing from HTML / markdown / other formats
@@ -1,26 +0,0 @@
1
- [
2
- {
3
- "block": {
4
- "children": [],
5
- "content": [
6
- {
7
- "styles": {},
8
- "text": "Double Nested Paragraph 0",
9
- "type": "text",
10
- },
11
- ],
12
- "id": "double-nested-paragraph-0",
13
- "props": {
14
- "backgroundColor": "default",
15
- "textAlignment": "left",
16
- "textColor": "default",
17
- },
18
- "type": "paragraph",
19
- },
20
- "prevBlock": undefined,
21
- "source": {
22
- "type": "local",
23
- },
24
- "type": "delete",
25
- },
26
- ]
@@ -1,68 +0,0 @@
1
- [
2
- {
3
- "block": {
4
- "children": [
5
- {
6
- "children": [],
7
- "content": [
8
- {
9
- "styles": {},
10
- "text": "Double Nested Paragraph 0",
11
- "type": "text",
12
- },
13
- ],
14
- "id": "double-nested-paragraph-0",
15
- "props": {
16
- "backgroundColor": "default",
17
- "textAlignment": "left",
18
- "textColor": "default",
19
- },
20
- "type": "paragraph",
21
- },
22
- ],
23
- "content": [
24
- {
25
- "styles": {},
26
- "text": "Nested Paragraph 0",
27
- "type": "text",
28
- },
29
- ],
30
- "id": "nested-paragraph-0",
31
- "props": {
32
- "backgroundColor": "default",
33
- "textAlignment": "left",
34
- "textColor": "default",
35
- },
36
- "type": "paragraph",
37
- },
38
- "prevBlock": undefined,
39
- "source": {
40
- "type": "local",
41
- },
42
- "type": "delete",
43
- },
44
- {
45
- "block": {
46
- "children": [],
47
- "content": [
48
- {
49
- "styles": {},
50
- "text": "Double Nested Paragraph 0",
51
- "type": "text",
52
- },
53
- ],
54
- "id": "double-nested-paragraph-0",
55
- "props": {
56
- "backgroundColor": "default",
57
- "textAlignment": "left",
58
- "textColor": "default",
59
- },
60
- "type": "paragraph",
61
- },
62
- "prevBlock": undefined,
63
- "source": {
64
- "type": "local",
65
- },
66
- "type": "delete",
67
- },
68
- ]
@@ -1,26 +0,0 @@
1
- [
2
- {
3
- "block": {
4
- "children": [],
5
- "content": [
6
- {
7
- "styles": {},
8
- "text": "Paragraph 0",
9
- "type": "text",
10
- },
11
- ],
12
- "id": "paragraph-0",
13
- "props": {
14
- "backgroundColor": "default",
15
- "textAlignment": "left",
16
- "textColor": "default",
17
- },
18
- "type": "paragraph",
19
- },
20
- "prevBlock": undefined,
21
- "source": {
22
- "type": "local",
23
- },
24
- "type": "delete",
25
- },
26
- ]