@blocknote/core 0.55.0 → 0.56.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 (460) hide show
  1. package/dist/BlockNoteExtension-DjEkXkR5.cjs +2 -0
  2. package/dist/BlockNoteExtension-DjEkXkR5.cjs.map +1 -0
  3. package/dist/{BlockNoteExtension-CbvDA0F7.js → BlockNoteExtension-TsTGtIeX.js} +34 -27
  4. package/dist/BlockNoteExtension-TsTGtIeX.js.map +1 -0
  5. package/dist/{UserStore-mj3fXW4D.cjs → UserStore-CTVzVGh-.cjs} +2 -2
  6. package/dist/{UserStore-mj3fXW4D.cjs.map → UserStore-CTVzVGh-.cjs.map} +1 -1
  7. package/dist/{UserStore-C4TzkGEn.js → UserStore-OZJP3K8T.js} +2 -2
  8. package/dist/{UserStore-C4TzkGEn.js.map → UserStore-OZJP3K8T.js.map} +1 -1
  9. package/dist/blocknote.cjs +1 -1
  10. package/dist/blocknote.js +6 -6
  11. package/dist/blocks-COVwe5Cf.cjs +12 -0
  12. package/dist/blocks-COVwe5Cf.cjs.map +1 -0
  13. package/dist/{blocks-DaEUT0O1.js → blocks-COYcDVg7.js} +1572 -1156
  14. package/dist/blocks-COYcDVg7.js.map +1 -0
  15. package/dist/blocks.cjs +1 -1
  16. package/dist/blocks.js +2 -2
  17. package/dist/comments.cjs +1 -1
  18. package/dist/comments.js +12 -12
  19. package/dist/{en-BAn9gxr-.js → en-Ch-vvt5e.js} +36 -2
  20. package/dist/en-Ch-vvt5e.js.map +1 -0
  21. package/dist/en-N5lu0-j8.cjs +2 -0
  22. package/dist/en-N5lu0-j8.cjs.map +1 -0
  23. package/dist/extensions-BbM81hHa.js +3069 -0
  24. package/dist/extensions-BbM81hHa.js.map +1 -0
  25. package/dist/extensions-D_WkAfSt.cjs +58 -0
  26. package/dist/extensions-D_WkAfSt.cjs.map +1 -0
  27. package/dist/extensions.cjs +1 -1
  28. package/dist/extensions.js +4 -4
  29. package/dist/locales.cjs +1 -1
  30. package/dist/locales.cjs.map +1 -1
  31. package/dist/locales.js +771 -23
  32. package/dist/locales.js.map +1 -1
  33. package/dist/src-4OQT3z5S.cjs +23 -0
  34. package/dist/src-4OQT3z5S.cjs.map +1 -0
  35. package/dist/{src-D5w0XAHX.js → src-BmLsLZfE.js} +1390 -1278
  36. package/dist/src-BmLsLZfE.js.map +1 -0
  37. package/dist/style.css +1 -1
  38. package/dist/webpack-stats.json +1 -1
  39. package/dist/y.cjs +1 -1
  40. package/dist/y.cjs.map +1 -1
  41. package/dist/y.js +1284 -554
  42. package/dist/y.js.map +1 -1
  43. package/dist/yjs.cjs +1 -1
  44. package/dist/yjs.cjs.map +1 -1
  45. package/dist/yjs.js +189 -148
  46. package/dist/yjs.js.map +1 -1
  47. package/package.json +8 -8
  48. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +45 -6
  49. package/src/api/blockManipulation/commands/insertBlocks/insertPlacement.test.ts +217 -0
  50. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +113 -9
  51. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +151 -163
  52. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +47 -31
  53. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +122 -181
  54. package/src/api/blockManipulation/commands/nestBlock/nestBlock.test.ts +256 -0
  55. package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +80 -40
  56. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +71 -0
  57. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +39 -31
  58. package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +221 -8
  59. package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +40 -8
  60. package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +272 -40
  61. package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +138 -117
  62. package/src/api/blockManipulation/getBlock/getBlock.ts +4 -11
  63. package/src/api/blockManipulation/layoutBlocks/fixLayoutBlock.ts +173 -0
  64. package/src/api/blockManipulation/layoutBlocks/layoutBlocks.browser.test.ts +293 -0
  65. package/src/api/blockManipulation/layoutBlocks/layoutBlocks.fixture.ts +145 -0
  66. package/src/api/blockManipulation/layoutBlocks/layoutBlocks.test.ts +783 -0
  67. package/src/api/blockManipulation/layoutBlocks/plainBlocks.test.ts +180 -0
  68. package/src/api/blockManipulation/layoutBlocks/titledBlocks.test.ts +365 -0
  69. package/src/api/blockManipulation/selections/selection.ts +20 -53
  70. package/src/api/blockManipulation/selections/textCursorPosition.ts +17 -72
  71. package/src/api/blockManipulation/setupTestEnv.ts +38 -6
  72. package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +4 -4
  73. package/src/api/clipboard/toClipboard/copyExtension.ts +3 -3
  74. package/src/api/combineTransactionSteps.ts +22 -0
  75. package/src/api/exporters/html/externalHTMLExporter.ts +1 -1
  76. package/src/api/exporters/html/internalHTMLSerializer.ts +4 -4
  77. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +111 -36
  78. package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +51 -21
  79. package/src/api/exporters/markdown/htmlToMarkdown.ts +12 -1
  80. package/src/api/exporters/markdown/markdownExporter.ts +1 -1
  81. package/src/api/getBlockInfoFromPos.test.ts +428 -3
  82. package/src/api/getBlockInfoFromPos.ts +531 -129
  83. package/src/api/getBlocksChangedByTransaction.test.ts +7 -7
  84. package/src/api/getBlocksChangedByTransaction.ts +3 -3
  85. package/src/api/{getChangedRange.ts → getChangedRangeWithAttrs.ts} +2 -2
  86. package/src/api/getChangedRanges.test.ts +391 -0
  87. package/src/api/getChangedRanges.ts +368 -0
  88. package/src/api/nodeConversions/blockToNode.ts +44 -16
  89. package/src/api/nodeConversions/fragmentToBlocks.ts +29 -44
  90. package/src/api/nodeConversions/nodeToBlock.ts +120 -68
  91. package/src/api/nodeUtil.ts +1 -1
  92. package/src/api/parsers/markdown/autolink.ts +23 -0
  93. package/src/api/parsers/markdown/markdownToHtml.ts +115 -11
  94. package/src/blocks/Code/block.test.ts +4 -4
  95. package/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.ts +6 -1
  96. package/src/blocks/Heading/block.ts +54 -15
  97. package/src/blocks/ListItem/BulletListItem/block.ts +6 -4
  98. package/src/blocks/ListItem/CheckListItem/block.test.ts +2 -2
  99. package/src/blocks/ListItem/CheckListItem/block.ts +6 -4
  100. package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +14 -17
  101. package/src/blocks/ListItem/NumberedListItem/block.ts +6 -4
  102. package/src/blocks/ListItem/ToggleListItem/block.ts +23 -12
  103. package/src/blocks/Table/block.ts +2 -10
  104. package/src/blocks/ToggleWrapper/createToggleFrame.ts +126 -0
  105. package/src/blocks/ToggleWrapper/toggleBlocks.browser.test.ts +1056 -0
  106. package/src/blocks/defaultBlockTypeItems.test.ts +70 -0
  107. package/src/blocks/defaultBlockTypeItems.ts +99 -0
  108. package/src/blocks/defaultBlocks.test.ts +67 -0
  109. package/src/blocks/defaultBlocks.ts +7 -1
  110. package/src/blocks/index.ts +2 -1
  111. package/src/editor/Block.css +286 -154
  112. package/src/editor/BlockNoteEditor.node.test.ts +35 -0
  113. package/src/editor/BlockNoteEditor.test.ts +2 -2
  114. package/src/editor/BlockNoteEditor.ts +71 -9
  115. package/src/editor/BlockNoteExtension.ts +5 -5
  116. package/src/editor/blockColors.browser.test.ts +127 -0
  117. package/src/editor/editor.css +60 -0
  118. package/src/editor/managers/BlockManager.ts +4 -3
  119. package/src/editor/managers/ExtensionManager/ExtensionManager.browser.test.ts +45 -0
  120. package/src/editor/managers/ExtensionManager/ExtensionManager.node.test.ts +209 -0
  121. package/src/editor/managers/ExtensionManager/extensions.ts +10 -1
  122. package/src/editor/managers/ExtensionManager/index.ts +135 -68
  123. package/src/editor/managers/StateManager.ts +14 -4
  124. package/src/editor/transformPasted.ts +14 -13
  125. package/src/exporter/Exporter.test.ts +70 -1
  126. package/src/exporter/Exporter.ts +34 -4
  127. package/src/exporter/mapping.ts +41 -10
  128. package/src/extensions/DropCursor/DropCursor.ts +119 -6
  129. package/src/extensions/DropCursor/dropIntoChildren.ts +80 -0
  130. package/src/extensions/FormattingToolbar/FormattingToolbar.ts +7 -1
  131. package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.test.ts +190 -0
  132. package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.ts +41 -4
  133. package/src/extensions/Placeholder/Placeholder.test.ts +23 -0
  134. package/src/extensions/Placeholder/Placeholder.ts +8 -7
  135. package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +36 -0
  136. package/src/extensions/PreviousBlockType/PreviousBlockType.ts +8 -4
  137. package/src/extensions/ReadOnly/ReadOnly.test.ts +181 -0
  138. package/src/extensions/ReadOnly/ReadOnly.ts +73 -0
  139. package/src/extensions/SideMenu/SideMenu.ts +401 -764
  140. package/src/extensions/SideMenu/blockDropHandling.ts +372 -0
  141. package/src/extensions/SideMenu/blockGeometry.browser.test.ts +148 -0
  142. package/src/extensions/SideMenu/blockGeometry.test.ts +46 -0
  143. package/src/extensions/SideMenu/blockGeometry.ts +53 -0
  144. package/src/extensions/SideMenu/dragging.ts +19 -32
  145. package/src/extensions/SideMenu/sideMenuHover.test.ts +36 -0
  146. package/src/extensions/SideMenu/sideMenuHover.ts +270 -0
  147. package/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.ts +5 -4
  148. package/src/extensions/SuggestionMenu/SuggestionMenu.ts +10 -1
  149. package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +36 -136
  150. package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.ts +14 -4
  151. package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.ts +1 -1
  152. package/src/extensions/SyntaxHighlighting/shiki.ts +1 -1
  153. package/src/extensions/TableHandles/TableHandles.ts +4 -6
  154. package/src/extensions/Versioning/Versioning.browser.test.ts +151 -0
  155. package/src/extensions/Versioning/Versioning.node.test.ts +177 -0
  156. package/src/extensions/Versioning/Versioning.ts +145 -612
  157. package/src/extensions/Versioning/__test__/result.ts +12 -0
  158. package/src/extensions/Versioning/comparison.test.ts +40 -0
  159. package/src/extensions/Versioning/createVersioning.test.ts +867 -0
  160. package/src/extensions/Versioning/createVersioning.ts +499 -0
  161. package/src/extensions/Versioning/formatVersionDate.ts +24 -0
  162. package/src/extensions/Versioning/inMemoryVersioning.test.ts +533 -430
  163. package/src/extensions/Versioning/inMemoryVersioning.ts +246 -251
  164. package/src/extensions/Versioning/index.ts +4 -0
  165. package/src/extensions/Versioning/scrollScheduling.test.ts +51 -0
  166. package/src/extensions/Versioning/scrollToFirstChange.test.ts +320 -0
  167. package/src/extensions/Versioning/scrollToFirstChange.ts +139 -0
  168. package/src/extensions/Versioning/types.ts +219 -0
  169. package/src/extensions/Versioning/versioningState.ts +154 -0
  170. package/src/extensions/blockDOM.browser.test.ts +102 -0
  171. package/src/extensions/blockDOM.test.ts +178 -0
  172. package/src/extensions/blockDOM.ts +135 -0
  173. package/src/extensions/index.ts +2 -0
  174. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts +1719 -53
  175. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +645 -531
  176. package/src/extensions/tiptap-extensions/KeyboardShortcuts/blockIdentity.browser.test.ts +152 -0
  177. package/src/extensions/tiptap-extensions/Link/helpers/autolink.ts +4 -9
  178. package/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.ts +10 -24
  179. package/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts +22 -19
  180. package/src/fonts/inter.browser.test.ts +57 -0
  181. package/src/fonts/inter.css +111 -0
  182. package/src/i18n/locales/ar.ts +32 -0
  183. package/src/i18n/locales/de.ts +32 -0
  184. package/src/i18n/locales/en.ts +32 -0
  185. package/src/i18n/locales/es.ts +32 -0
  186. package/src/i18n/locales/fa.ts +32 -0
  187. package/src/i18n/locales/fr.ts +32 -0
  188. package/src/i18n/locales/he.ts +32 -0
  189. package/src/i18n/locales/hr.ts +32 -0
  190. package/src/i18n/locales/is.ts +32 -0
  191. package/src/i18n/locales/it.ts +32 -0
  192. package/src/i18n/locales/ja.ts +32 -0
  193. package/src/i18n/locales/ko.ts +32 -0
  194. package/src/i18n/locales/nl.ts +32 -0
  195. package/src/i18n/locales/no.ts +32 -0
  196. package/src/i18n/locales/pl.ts +32 -0
  197. package/src/i18n/locales/pt.ts +32 -0
  198. package/src/i18n/locales/ru.ts +32 -0
  199. package/src/i18n/locales/sk.ts +32 -0
  200. package/src/i18n/locales/uk.ts +32 -0
  201. package/src/i18n/locales/uz.ts +32 -0
  202. package/src/i18n/locales/vi.ts +32 -0
  203. package/src/i18n/locales/zh-tw.ts +32 -0
  204. package/src/i18n/locales/zh.ts +32 -0
  205. package/src/index.ts +13 -3
  206. package/src/pm-nodes/BlockContainer.test.ts +101 -0
  207. package/src/pm-nodes/BlockContainer.ts +110 -1
  208. package/src/pm-nodes/BlockGroup.ts +2 -1
  209. package/src/pm-nodes/README.md +2 -0
  210. package/src/schema/blocks/children.test.ts +288 -0
  211. package/src/schema/blocks/children.ts +136 -0
  212. package/src/schema/blocks/createSpec.browser.test.ts +176 -0
  213. package/src/schema/blocks/createSpec.test.ts +231 -0
  214. package/src/schema/blocks/createSpec.ts +493 -267
  215. package/src/schema/blocks/frame.test.ts +112 -0
  216. package/src/schema/blocks/frame.ts +337 -0
  217. package/src/schema/blocks/internal.ts +50 -17
  218. package/src/schema/blocks/keyboard.ts +154 -0
  219. package/src/schema/blocks/layoutBlockAttributes.ts +29 -0
  220. package/src/schema/blocks/meta.test.ts +53 -0
  221. package/src/schema/blocks/meta.ts +35 -0
  222. package/src/schema/blocks/renderFrame.test.ts +691 -0
  223. package/src/schema/blocks/types.ts +285 -21
  224. package/src/schema/blocks/validateChildren.ts +156 -0
  225. package/src/schema/dataAttributes.test.ts +72 -0
  226. package/src/schema/dataAttributes.ts +69 -0
  227. package/src/schema/index.ts +3 -0
  228. package/src/schema/inlineContent/internal.ts +7 -12
  229. package/src/schema/markGroups.ts +34 -2
  230. package/src/schema/schema.ts +8 -1
  231. package/src/user/userColors.test.ts +108 -0
  232. package/src/user/userColors.ts +42 -13
  233. package/src/y/comments/RESTYjsThreadStore.ts +1 -1
  234. package/src/y/comments/YjsThreadStore.test.ts +1 -1
  235. package/src/y/comments/YjsThreadStore.ts +27 -27
  236. package/src/y/comments/YjsThreadStoreBase.ts +2 -2
  237. package/src/y/comments/yjsHelpers.ts +11 -11
  238. package/src/y/extensions/AttributionExtension.test.ts +271 -2
  239. package/src/y/extensions/AttributionExtension.ts +146 -123
  240. package/src/y/extensions/DiffVersioningExtension.test.ts +67 -18
  241. package/src/y/extensions/DiffVersioningExtension.ts +95 -123
  242. package/src/y/extensions/EmptyDocBinding.test.ts +282 -0
  243. package/src/y/extensions/ForkYDoc.node.test.ts +77 -0
  244. package/src/y/extensions/ForkYDoc.test.ts +93 -2
  245. package/src/y/extensions/ForkYDoc.ts +22 -13
  246. package/src/y/extensions/History.test.ts +125 -0
  247. package/src/y/extensions/RelativePositionMapping.test.ts +35 -0
  248. package/src/y/extensions/RelativePositionMapping.ts +7 -11
  249. package/src/y/extensions/Versioning.node.test.ts +126 -0
  250. package/src/y/extensions/Versioning.test.ts +110 -401
  251. package/src/y/extensions/Versioning.ts +66 -107
  252. package/src/y/extensions/YAttributionMarks.ts +111 -9
  253. package/src/y/extensions/YCursorPlugin.ts +3 -0
  254. package/src/y/extensions/YSync.node.test.ts +75 -0
  255. package/src/y/extensions/YSync.ts +76 -4
  256. package/src/y/extensions/YSyncRemount.test.ts +99 -0
  257. package/src/y/extensions/blockMatchNodes.ts +20 -29
  258. package/src/y/extensions/index.ts +10 -26
  259. package/src/y/extensions/legacyYjsDocBinding.test.ts +652 -0
  260. package/src/y/extensions/nestingChanges.test.ts +326 -0
  261. package/src/y/extensions/persistentBlockGroups.test.ts +1709 -0
  262. package/src/y/extensions/persistentBlockGroups.ts +953 -0
  263. package/src/y/extensions/snapshotCodec.test.ts +105 -0
  264. package/src/y/extensions/snapshotCodec.ts +39 -0
  265. package/src/y/extensions/snapshotPreview.test.ts +201 -0
  266. package/src/y/extensions/snapshotPreview.ts +292 -0
  267. package/src/y/extensions/tableReshape.test.ts +121 -0
  268. package/src/y/extensions/v1BindingSnapshotDiff.test.ts +121 -0
  269. package/src/y/extensions/versionDiffAttribution.test.ts +944 -0
  270. package/src/y/extensions/versionDiffPerformance.test.ts +101 -0
  271. package/src/y/index.ts +1 -0
  272. package/src/y/utils.test.ts +289 -22
  273. package/src/y/utils.ts +167 -43
  274. package/src/y/versioning/__test__/fixtures/activity-all-after.json +5 -5
  275. package/src/y/versioning/__test__/fixtures/activity-all.json +3 -3
  276. package/src/y/versioning/__test__/fixtures/activity-filtered-after.json +2 -2
  277. package/src/y/versioning/__test__/yhub.test.ts +902 -721
  278. package/src/y/versioning/index.ts +6 -1
  279. package/src/y/versioning/yhub.ts +316 -603
  280. package/src/y/versioning/yhubClient.ts +345 -0
  281. package/src/yjs/comments/RESTYjsThreadStore.test.ts +10 -0
  282. package/src/yjs/extensions/FixUpSchema.ts +11 -0
  283. package/src/yjs/extensions/ForkYDoc.browser.test.ts +84 -0
  284. package/src/yjs/extensions/ForkYDoc.node.test.ts +231 -0
  285. package/src/yjs/extensions/ForkYDoc.test.ts +68 -1
  286. package/src/yjs/extensions/ForkYDoc.ts +57 -39
  287. package/src/yjs/extensions/Versioning.test.ts +345 -530
  288. package/src/yjs/extensions/Versioning.ts +111 -68
  289. package/src/yjs/extensions/index.ts +1 -1
  290. package/src/yjs/index.ts +4 -0
  291. package/types/src/api/blockManipulation/commands/insertBlocks/insertBlocks.d.ts +2 -1
  292. package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.d.ts +24 -24
  293. package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.d.ts +3 -2
  294. package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.d.ts +1 -1
  295. package/types/src/api/blockManipulation/commands/splitBlock/splitBlock.d.ts +2 -2
  296. package/types/src/api/blockManipulation/layoutBlocks/fixLayoutBlock.d.ts +34 -0
  297. package/types/src/api/blockManipulation/layoutBlocks/layoutBlocks.browser.test.d.ts +1 -0
  298. package/types/src/api/blockManipulation/layoutBlocks/layoutBlocks.fixture.d.ts +460 -0
  299. package/types/src/api/blockManipulation/layoutBlocks/layoutBlocks.test.d.ts +1 -0
  300. package/types/src/api/blockManipulation/layoutBlocks/plainBlocks.test.d.ts +1 -0
  301. package/types/src/api/blockManipulation/layoutBlocks/titledBlocks.test.d.ts +1 -0
  302. package/types/src/api/blockManipulation/setupTestEnv.d.ts +15 -69
  303. package/types/src/api/combineTransactionSteps.d.ts +12 -0
  304. package/types/src/api/getBlockInfoFromPos.d.ts +218 -44
  305. package/types/src/api/{getChangedRange.d.ts → getChangedRangeWithAttrs.d.ts} +1 -1
  306. package/types/src/api/getChangedRanges.d.ts +23 -0
  307. package/types/src/api/getChangedRanges.test.d.ts +1 -0
  308. package/types/src/api/nodeConversions/fragmentToBlocks.d.ts +0 -3
  309. package/types/src/api/parsers/markdown/autolink.d.ts +5 -0
  310. package/types/src/blocks/ToggleWrapper/createToggleFrame.d.ts +29 -0
  311. package/types/src/blocks/ToggleWrapper/toggleBlocks.browser.test.d.ts +1 -0
  312. package/types/src/blocks/defaultBlockTypeItems.d.ts +37 -0
  313. package/types/src/blocks/defaultBlockTypeItems.test.d.ts +1 -0
  314. package/types/src/blocks/defaultBlocks.test.d.ts +1 -0
  315. package/types/src/blocks/index.d.ts +2 -1
  316. package/types/src/editor/BlockNoteEditor.d.ts +36 -8
  317. package/types/src/editor/BlockNoteEditor.node.test.d.ts +1 -0
  318. package/types/src/editor/blockColors.browser.test.d.ts +1 -0
  319. package/types/src/editor/managers/BlockManager.d.ts +4 -3
  320. package/types/src/editor/managers/ExtensionManager/ExtensionManager.browser.test.d.ts +1 -0
  321. package/types/src/editor/managers/ExtensionManager/ExtensionManager.node.test.d.ts +1 -0
  322. package/types/src/editor/managers/ExtensionManager/index.d.ts +15 -3
  323. package/types/src/editor/managers/StateManager.d.ts +1 -1
  324. package/types/src/editor/transformPasted.d.ts +1 -1
  325. package/types/src/exporter/Exporter.d.ts +11 -4
  326. package/types/src/exporter/mapping.d.ts +13 -1
  327. package/types/src/extensions/DropCursor/DropCursor.d.ts +1 -1
  328. package/types/src/extensions/DropCursor/dropIntoChildren.d.ts +38 -0
  329. package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.d.ts +1 -1
  330. package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.test.d.ts +1 -0
  331. package/types/src/extensions/Placeholder/Placeholder.test.d.ts +1 -0
  332. package/types/src/extensions/ReadOnly/ReadOnly.d.ts +21 -0
  333. package/types/src/extensions/ReadOnly/ReadOnly.test.d.ts +1 -0
  334. package/types/src/extensions/SideMenu/SideMenu.d.ts +49 -88
  335. package/types/src/extensions/SideMenu/blockDropHandling.d.ts +11 -0
  336. package/types/src/extensions/SideMenu/blockGeometry.browser.test.d.ts +1 -0
  337. package/types/src/extensions/SideMenu/blockGeometry.d.ts +22 -0
  338. package/types/src/extensions/SideMenu/blockGeometry.test.d.ts +1 -0
  339. package/types/src/extensions/SideMenu/dragging.d.ts +0 -4
  340. package/types/src/extensions/SideMenu/sideMenuHover.d.ts +58 -0
  341. package/types/src/extensions/SideMenu/sideMenuHover.test.d.ts +1 -0
  342. package/types/src/extensions/Versioning/Versioning.browser.test.d.ts +1 -0
  343. package/types/src/extensions/Versioning/Versioning.d.ts +34 -311
  344. package/types/src/extensions/Versioning/Versioning.node.test.d.ts +1 -0
  345. package/types/src/extensions/Versioning/__test__/result.d.ts +3 -0
  346. package/types/src/extensions/Versioning/comparison.test.d.ts +1 -0
  347. package/types/src/extensions/Versioning/createVersioning.d.ts +32 -0
  348. package/types/src/extensions/Versioning/createVersioning.test.d.ts +1 -0
  349. package/types/src/extensions/Versioning/formatVersionDate.d.ts +7 -0
  350. package/types/src/extensions/Versioning/inMemoryVersioning.d.ts +64 -36
  351. package/types/src/extensions/Versioning/index.d.ts +4 -0
  352. package/types/src/extensions/Versioning/scrollScheduling.test.d.ts +1 -0
  353. package/types/src/extensions/Versioning/scrollToFirstChange.d.ts +18 -0
  354. package/types/src/extensions/Versioning/scrollToFirstChange.test.d.ts +1 -0
  355. package/types/src/extensions/Versioning/types.d.ts +239 -0
  356. package/types/src/extensions/Versioning/versioningState.d.ts +43 -0
  357. package/types/src/extensions/blockDOM.browser.test.d.ts +1 -0
  358. package/types/src/extensions/blockDOM.d.ts +37 -0
  359. package/types/src/extensions/blockDOM.test.d.ts +1 -0
  360. package/types/src/extensions/index.d.ts +2 -0
  361. package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.d.ts +1 -0
  362. package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.d.ts +3 -0
  363. package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/blockIdentity.browser.test.d.ts +1 -0
  364. package/types/src/fonts/inter.browser.test.d.ts +2 -0
  365. package/types/src/i18n/locales/en.d.ts +32 -0
  366. package/types/src/i18n/locales/fa.d.ts +32 -0
  367. package/types/src/i18n/locales/sk.d.ts +32 -0
  368. package/types/src/index.d.ts +6 -3
  369. package/types/src/pm-nodes/BlockContainer.d.ts +6 -0
  370. package/types/src/pm-nodes/BlockContainer.test.d.ts +1 -0
  371. package/types/src/schema/blocks/children.d.ts +39 -0
  372. package/types/src/schema/blocks/children.test.d.ts +1 -0
  373. package/types/src/schema/blocks/createSpec.browser.test.d.ts +1 -0
  374. package/types/src/schema/blocks/createSpec.d.ts +13 -0
  375. package/types/src/schema/blocks/frame.d.ts +109 -0
  376. package/types/src/schema/blocks/frame.test.d.ts +1 -0
  377. package/types/src/schema/blocks/internal.d.ts +6 -0
  378. package/types/src/schema/blocks/keyboard.d.ts +111 -0
  379. package/types/src/schema/blocks/layoutBlockAttributes.d.ts +9 -0
  380. package/types/src/schema/blocks/meta.d.ts +14 -0
  381. package/types/src/schema/blocks/meta.test.d.ts +1 -0
  382. package/types/src/schema/blocks/renderFrame.test.d.ts +1 -0
  383. package/types/src/schema/blocks/types.d.ts +228 -15
  384. package/types/src/schema/blocks/validateChildren.d.ts +5 -0
  385. package/types/src/schema/dataAttributes.d.ts +19 -0
  386. package/types/src/schema/dataAttributes.test.d.ts +1 -0
  387. package/types/src/schema/index.d.ts +3 -0
  388. package/types/src/schema/markGroups.d.ts +8 -0
  389. package/types/src/user/userColors.d.ts +24 -3
  390. package/types/src/user/userColors.test.d.ts +1 -0
  391. package/types/src/y/comments/RESTYjsThreadStore.d.ts +1 -1
  392. package/types/src/y/comments/YjsThreadStore.d.ts +1 -1
  393. package/types/src/y/comments/YjsThreadStoreBase.d.ts +2 -2
  394. package/types/src/y/comments/yjsHelpers.d.ts +5 -5
  395. package/types/src/y/extensions/AttributionExtension.d.ts +19 -21
  396. package/types/src/y/extensions/DiffVersioningExtension.d.ts +9 -4
  397. package/types/src/y/extensions/EmptyDocBinding.test.d.ts +1 -0
  398. package/types/src/y/extensions/ForkYDoc.d.ts +3 -1
  399. package/types/src/y/extensions/ForkYDoc.node.test.d.ts +1 -0
  400. package/types/src/y/extensions/History.test.d.ts +1 -0
  401. package/types/src/y/extensions/Versioning.d.ts +4 -15
  402. package/types/src/y/extensions/Versioning.node.test.d.ts +1 -0
  403. package/types/src/y/extensions/YAttributionMarks.d.ts +13 -2
  404. package/types/src/y/extensions/YCursorPlugin.d.ts +1 -0
  405. package/types/src/y/extensions/YSync.d.ts +4 -18
  406. package/types/src/y/extensions/YSync.node.test.d.ts +1 -0
  407. package/types/src/y/extensions/YSyncRemount.test.d.ts +1 -0
  408. package/types/src/y/extensions/blockMatchNodes.d.ts +0 -22
  409. package/types/src/y/extensions/index.d.ts +27 -44
  410. package/types/src/y/extensions/legacyYjsDocBinding.test.d.ts +1 -0
  411. package/types/src/y/extensions/nestingChanges.test.d.ts +1 -0
  412. package/types/src/y/extensions/persistentBlockGroups.d.ts +189 -0
  413. package/types/src/y/extensions/persistentBlockGroups.test.d.ts +1 -0
  414. package/types/src/y/extensions/snapshotCodec.d.ts +13 -0
  415. package/types/src/y/extensions/snapshotCodec.test.d.ts +1 -0
  416. package/types/src/y/extensions/snapshotPreview.d.ts +21 -0
  417. package/types/src/y/extensions/snapshotPreview.test.d.ts +1 -0
  418. package/types/src/y/extensions/tableReshape.test.d.ts +1 -0
  419. package/types/src/y/extensions/v1BindingSnapshotDiff.test.d.ts +1 -0
  420. package/types/src/y/extensions/versionDiffAttribution.test.d.ts +1 -0
  421. package/types/src/y/extensions/versionDiffPerformance.test.d.ts +1 -0
  422. package/types/src/y/index.d.ts +1 -0
  423. package/types/src/y/utils.d.ts +39 -19
  424. package/types/src/y/versioning/index.d.ts +1 -1
  425. package/types/src/y/versioning/yhub.d.ts +69 -86
  426. package/types/src/y/versioning/yhubClient.d.ts +67 -0
  427. package/types/src/yjs/extensions/ForkYDoc.browser.test.d.ts +1 -0
  428. package/types/src/yjs/extensions/ForkYDoc.d.ts +2 -0
  429. package/types/src/yjs/extensions/ForkYDoc.node.test.d.ts +1 -0
  430. package/types/src/yjs/extensions/Versioning.d.ts +36 -22
  431. package/types/src/yjs/extensions/index.d.ts +2 -1
  432. package/types/src/yjs/index.d.ts +1 -0
  433. package/dist/BlockNoteExtension-BJCLnwrE.cjs +0 -2
  434. package/dist/BlockNoteExtension-BJCLnwrE.cjs.map +0 -1
  435. package/dist/BlockNoteExtension-CbvDA0F7.js.map +0 -1
  436. package/dist/blocks-DLgTreVu.cjs +0 -12
  437. package/dist/blocks-DLgTreVu.cjs.map +0 -1
  438. package/dist/blocks-DaEUT0O1.js.map +0 -1
  439. package/dist/en-BAn9gxr-.js.map +0 -1
  440. package/dist/en-CHnrV5l8.cjs +0 -2
  441. package/dist/en-CHnrV5l8.cjs.map +0 -1
  442. package/dist/extensions-B1JQURVF.js +0 -2138
  443. package/dist/extensions-B1JQURVF.js.map +0 -1
  444. package/dist/extensions-CZkqKzJO.cjs +0 -58
  445. package/dist/extensions-CZkqKzJO.cjs.map +0 -1
  446. package/dist/src-D5w0XAHX.js.map +0 -1
  447. package/dist/src-th5uZEvx.cjs +0 -23
  448. package/dist/src-th5uZEvx.cjs.map +0 -1
  449. package/src/api/blockManipulation/commands/replaceBlocks/util/fixColumnList.ts +0 -173
  450. package/src/blocks/ListItem/ListItemKeyboardShortcuts.ts +0 -63
  451. package/src/blocks/ToggleWrapper/createToggleWrapper.ts +0 -197
  452. package/src/blocks/utils/listItemEnterHandler.ts +0 -43
  453. package/src/extensions/Versioning/Versioning.test.ts +0 -435
  454. package/src/extensions/getDraggableBlockFromElement.ts +0 -19
  455. package/types/src/api/blockManipulation/commands/replaceBlocks/util/fixColumnList.d.ts +0 -32
  456. package/types/src/blocks/ListItem/ListItemKeyboardShortcuts.d.ts +0 -2
  457. package/types/src/blocks/ToggleWrapper/createToggleWrapper.d.ts +0 -15
  458. package/types/src/blocks/utils/listItemEnterHandler.d.ts +0 -2
  459. package/types/src/extensions/getDraggableBlockFromElement.d.ts +0 -5
  460. /package/types/src/{extensions/Versioning/Versioning.test.d.ts → api/blockManipulation/commands/insertBlocks/insertPlacement.test.d.ts} +0 -0
@@ -0,0 +1,189 @@
1
+ import * as delta from "lib0/delta";
2
+ import * as dt from "lib0/delta/transformer";
3
+ import type * as s from "lib0/schema";
4
+ /**
5
+ * # Persistent block groups
6
+ *
7
+ * A `@y/prosemirror` transformer (the `transformers` option of `syncPlugin`)
8
+ * that keeps BlockNote's nested `blockGroup` nodes alive in the Yjs document
9
+ * and hides the empty ones from ProseMirror.
10
+ *
11
+ * ## The problem
12
+ *
13
+ * BlockNote nests child blocks as `blockContainer > [blockContent, blockGroup?]`
14
+ * and its ProseMirror schema forbids an empty `blockGroup`
15
+ * (`content: "blockGroupChild+"`). So the editor creates the group together
16
+ * with the first nested block and removes it with the last one. Under
17
+ * concurrency that is a conflict generator: two users who nest a first child
18
+ * under the same block at the same time each insert their own `blockGroup`,
19
+ * and after the merge the container holds two groups, which the schema
20
+ * rejects. BlockNote worked around it by replacing the whole container
21
+ * whenever a group appeared or disappeared (the nesting check that used to be
22
+ * in `blockMatchNodes`), which turns the same race into two copies of the
23
+ * parent block and rewrites the parent on every first nesting and last
24
+ * un-nesting.
25
+ *
26
+ * ## The model
27
+ *
28
+ * What Yjs stores is decoupled from what ProseMirror shows:
29
+ *
30
+ * - **Yjs (side A)** keeps every `blockGroup` once it exists. Emptying one
31
+ * leaves it in place, and (with `implicitGroups`, the default) a container
32
+ * the editor creates gets an empty group right away. Two users nesting a
33
+ * first child concurrently therefore write into the *same* group item, and
34
+ * Yjs merges their children like any other concurrent list insert.
35
+ * - **ProseMirror (side B)** sees one `blockGroup` per container, present only
36
+ * while it has children.
37
+ *
38
+ * Yjs ProseMirror
39
+ * blockContainer[ content, group[] ] ⇄ blockContainer[ content ]
40
+ * blockContainer[ content, group[a] ] ⇄ blockContainer[ content, group[a] ]
41
+ * blockContainer[ content, g1[a], g2[b] ] ⇄ blockContainer[ content, group[a, b] ]
42
+ * blockContainer[ content ] ⇄ blockContainer[ content ] (legacy)
43
+ *
44
+ * The third row is what a document written before this transformer (no
45
+ * groups until the first nesting) produces when two users nest a first child
46
+ * concurrently: the view merges every group of a container into one, so the
47
+ * race degrades to an ordering question instead of invalid content. Edits
48
+ * inside the merged group route back to the Yjs group that holds that
49
+ * position. A legacy container never gets a group implicitly (that would be a
50
+ * concurrent write by every client that opens the document); its first nesting
51
+ * creates the group, as before.
52
+ *
53
+ * ## Rules, per `blockContainer`
54
+ *
55
+ * Yjs → view (`applyA`):
56
+ * - every `blockGroup` child collapses into one view group placed after all
57
+ * other children; it exists iff the groups hold at least one child in total
58
+ * - a change that makes the total go 0 → n inserts the view group, n → 0
59
+ * deletes it, n → m modifies it with the inner change re-based onto merged
60
+ * coordinates (a group's children start at the sum of the lengths of the
61
+ * groups before it)
62
+ * - the group wrapper's own attributes, formats and attribution have no view
63
+ * counterpart and are dropped; a group inserted by a suggestion renders its
64
+ * *children* as inserted, which is what the user sees anyway
65
+ *
66
+ * view → Yjs (`applyB`):
67
+ * - an edit at a merged offset routes into the group covering it; at a
68
+ * boundary between two groups the earlier group wins
69
+ * - deleting the view group empties every Yjs group and keeps them all
70
+ * - inserting a view group (only possible while no view group exists) routes
71
+ * its children into the first Yjs group, or, when the container has no
72
+ * group at all (a legacy container), inserts the group as the editor built
73
+ * it
74
+ * - a container the view inserts without a group gets an empty group appended
75
+ * (`implicitGroups`)
76
+ *
77
+ * Cursor positions (root marks) map through the same layout, in both
78
+ * directions.
79
+ *
80
+ * ## Shape of the implementation
81
+ *
82
+ * {@link persistentBlockGroups} composes lib0's `children` template
83
+ * recursively over the node types that can hold containers (`blockGroup`,
84
+ * `column`, `columnList`) and pipes the stateful per-container stage
85
+ * ({@link PersistentGroupTransformer}) after the recursion, so that stage sees
86
+ * its container's children in Yjs layout on the way in and in view layout on
87
+ * the way back. Every other node type (block content, inline content) opts
88
+ * out of the recursion and costs nothing.
89
+ *
90
+ * The per-container state is the container's Yjs child layout: a list of
91
+ * {@link Seg}s, one per child, telling groups (with their child count) apart
92
+ * from everything else. It is kept current from the changes that flow through,
93
+ * so no stage ever re-reads a document; a change costs O(size of the change)
94
+ * plus O(children of the containers on its path), and a container has two or
95
+ * three children.
96
+ *
97
+ * ## Assumptions
98
+ *
99
+ * - `blockContainer` children are a content node followed by zero or more
100
+ * `blockGroup`s (BlockNote never produces anything else). The code tolerates
101
+ * other layouts, but the view then shows non-group children in Yjs order
102
+ * followed by the merged group, which may differ from the Yjs order.
103
+ * - the view inserts at most one `blockGroup` per container (its schema
104
+ * guarantees that).
105
+ */
106
+ /**
107
+ * Options of {@link persistentBlockGroups}.
108
+ */
109
+ export type PersistentBlockGroupsOptions = {
110
+ /** The nested list node that is kept and hidden. Default `"blockGroup"`. */
111
+ groupName?: string;
112
+ /** The block node whose children the group lives in. Default `"blockContainer"`. */
113
+ containerName?: string;
114
+ /**
115
+ * The node types (besides the container) that can hold containers, so the
116
+ * recursion descends into them. Default `["blockGroup", "column", "columnList"]`.
117
+ */
118
+ nestingNodes?: readonly string[];
119
+ /**
120
+ * Whether a container the view creates gets an empty group right away
121
+ * (default `true`). With `false`, groups are only kept once the first
122
+ * nesting creates them; concurrent first nestings then leave two groups in
123
+ * Yjs, which the view merges.
124
+ */
125
+ implicitGroups?: boolean;
126
+ };
127
+ type AnyDelta = delta.DeltaAny;
128
+ type AnyBuilder = delta.DeltaBuilderAny;
129
+ /**
130
+ * One child of a container in Yjs layout: a group with its child count, or
131
+ * anything else.
132
+ */
133
+ type Seg = {
134
+ readonly group: false;
135
+ } | {
136
+ readonly group: true;
137
+ readonly len: number;
138
+ };
139
+ /**
140
+ * The stateful per-container stage. Side A is the container's children in
141
+ * Yjs layout, side B in view layout (see the module doc for the rules).
142
+ */
143
+ export declare class PersistentGroupTransformer extends dt.Transformer<any, any> {
144
+ readonly groupName: string;
145
+ readonly implicitGroups: boolean;
146
+ /**
147
+ * The container's Yjs child layout, kept current from the changes that
148
+ * flow through (both directions).
149
+ */
150
+ segs: Seg[];
151
+ /**
152
+ * Whether no change has been seen yet. The first change a stage receives
153
+ * is the whole container node (lib0's `children` feeds a freshly inserted
154
+ * child through a fresh stage); when that node comes from the view, the
155
+ * container is new and gets its implicit group.
156
+ */
157
+ fresh: boolean;
158
+ constructor($in: s.Schema<AnyDelta>, $out: s.Schema<AnyDelta>, groupName: string, implicitGroups: boolean);
159
+ /** Yjs layout change → view layout change. */
160
+ applyA(da: AnyBuilder): dt.TransformResultAny;
161
+ /** View layout change → Yjs layout change. */
162
+ applyB(db: AnyBuilder): dt.TransformResultAny;
163
+ }
164
+ /** Template of the per-container stage. */
165
+ export declare class PersistentGroup extends dt.Template<any, any> {
166
+ readonly groupName: string;
167
+ readonly implicitGroups: boolean;
168
+ constructor($d: s.Schema<AnyDelta>, groupName: string, implicitGroups: boolean);
169
+ get name(): string;
170
+ init(): dt.Transformer<any, any>;
171
+ }
172
+ /**
173
+ * The transformer: hide empty `blockGroup`s from the view, keep them in Yjs,
174
+ * create them with every new container, and merge concurrently created ones
175
+ * (module doc above). Slot it into the sync plugin:
176
+ *
177
+ * ```ts
178
+ * syncPlugin({ transformers: [persistentBlockGroups], customCompare: blockMatchNodes })
179
+ * ```
180
+ *
181
+ * and into the standalone conversions with
182
+ * `defaultTransformer({ mapAttributionToMark, transformers: [persistentBlockGroups] })`.
183
+ *
184
+ * The returned template is the recursion over the document (lib0's
185
+ * `children`): containers get the per-container stage, the `nestingNodes`
186
+ * descend, every other node opts out.
187
+ */
188
+ export declare function persistentBlockGroups<IN extends delta.DeltaConf>($d: s.Schema<delta.Delta<IN>>, options?: PersistentBlockGroupsOptions): dt.Template<IN, any>;
189
+ export {};
@@ -0,0 +1,13 @@
1
+ import * as Y from "@y/y";
2
+ /** Serialize the live fragment as a V2 update. */
3
+ export declare function serializeFragment(fragment: Y.Node): Uint8Array;
4
+ export type DecodedFragment = {
5
+ doc: Y.Doc;
6
+ fragment: Y.Node;
7
+ };
8
+ /** Materialize a stored update into a throwaway doc and resolve `fragment` inside it. */
9
+ export declare function decodeFragmentUpdate(fragment: Y.Node, content: Uint8Array, opts?: {
10
+ suggestionDoc?: boolean;
11
+ }): DecodedFragment;
12
+ /** Release a decoded throwaway doc. */
13
+ export declare function destroyDecodedFragment(decoded: DecodedFragment | undefined): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ import * as Y from "@y/y";
2
+ import type { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
3
+ /**
4
+ * Throws when something syncs `doc` (a provider or a persistence layer listens
5
+ * to its updates). A decoded snapshot is written to (see
6
+ * {@link splitChangedBlocks}), and that write must never reach a stored
7
+ * document.
8
+ */
9
+ export declare function assertUnsyncedDoc(doc: Y.Doc): void;
10
+ /**
11
+ * Decode a snapshot, diff it against a baseline if given, and render it.
12
+ *
13
+ * Snapshots are decoded into throwaway documents, so pointing the binding at
14
+ * one is already an isolated state: the live fragment stops receiving view
15
+ * updates, and nothing typed into the preview reaches the live document.
16
+ * {@link configureYProsemirror} rebuilds the binding against the decoded
17
+ * fragment through the same `customCompare`/attribution pipeline the live
18
+ * binding uses; passing the `renderer` keeps the attribution tooltips
19
+ * ("who/when") working.
20
+ */
21
+ export declare function showSnapshotPreview(editor: BlockNoteEditor<any, any, any>, fragment: Y.Node, snapshotContent: Uint8Array, compareToContent?: Uint8Array, attributions?: Y.ContentMap): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -2,3 +2,4 @@ export * from "./extensions/index.js";
2
2
  export * from "./utils.js";
3
3
  export * from "./comments/index.js";
4
4
  export * from "./versioning/index.js";
5
+ export { createYVersionView } from "./extensions/Versioning.js";
@@ -1,15 +1,38 @@
1
+ import { defaultTransformer, ynodeToPmnode } from "@y/prosemirror";
1
2
  import * as d from "lib0/delta";
2
3
  import { Node } from "prosemirror-model";
3
- import { Transaction } from "prosemirror-state";
4
+ import type { Transaction } from "prosemirror-state";
4
5
  import { type Block, type BlockNoteEditor, type BlockSchema, type InlineContentSchema, type PartialBlock, type StyleSchema } from "../index.js";
5
6
  import * as Y from "@y/y";
6
7
  /**
7
- * Find the equivalent of a Y.Type in another Y.Doc.
8
+ * The Y ⇄ ProseMirror pipeline of the collaboration binding (see
9
+ * `YSyncExtension`): attributions become `y-attributed-*` marks and nested
10
+ * `blockGroup`s are persistent (kept in Y, hidden while empty, merged in the
11
+ * view). Every conversion outside a bound editor goes through the same
12
+ * pipeline, so a document imported with `blocksToYDoc` gets its groups and one
13
+ * read with `yDocToBlocks` hides the empty ones.
14
+ */
15
+ export declare const blockNoteTransformer: ReturnType<typeof defaultTransformer>;
16
+ /**
17
+ * Find the equivalent of a Y.Node in another Y.Doc.
8
18
  *
9
19
  * For root types this looks up the matching shared key; for sub-types it
10
20
  * locates the item by its client/clock ID in the target doc's store.
11
21
  */
12
- export declare function findTypeInOtherYdoc<T extends Y.Type<any>>(ytype: T, otherYdoc: Y.Doc): T;
22
+ export declare function findTypeInOtherYdoc<T extends Y.Node<any>>(ytype: T, otherYdoc: Y.Doc): T;
23
+ /**
24
+ * Collect all stored Yjs ID ranges belonging to a fragment, including deleted
25
+ * descendants. Items belonging to other shared types are excluded.
26
+ *
27
+ * Resolves the fragment in the supplied document and scans its stored items:
28
+ * walking visible content would miss deleted subtrees. To include all deleted
29
+ * descendants, the document or update must retain them; content already
30
+ * garbage-collected cannot be recovered here.
31
+ *
32
+ * Updates are loaded into a temporary document with `gc: false`, which is
33
+ * destroyed after collection. Caller-provided documents are never destroyed.
34
+ */
35
+ export declare function collectFragmentIds(fragment: Y.Node, docOrUpdate: Uint8Array | Y.Doc): Y.IdSet;
13
36
  /**
14
37
  * Turn Prosemirror JSON to BlockNote style JSON
15
38
  * @param editor BlockNote editor
@@ -24,16 +47,15 @@ export declare function _prosemirrorJSONToBlocks<BSchema extends BlockSchema, IS
24
47
  * @returns Prosemirror root node
25
48
  */
26
49
  export declare function _blocksToProsemirrorNode<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema>(editor: BlockNoteEditor<BSchema, ISchema, SSchema>, blocks: PartialBlock<BSchema, ISchema, SSchema>[]): Node;
27
- /** YJS / BLOCKNOTE conversions */
28
50
  /**
29
- * Turn a Y.Type collaborative doc into a BlockNote document (BlockNote style JSON of all blocks)
51
+ * Turn a Y.Node collaborative doc into a BlockNote document (BlockNote style JSON of all blocks)
30
52
  * @param editor BlockNote editor
31
- * @param fragment Y.Type
53
+ * @param fragment Y.Node
32
54
  * @returns BlockNote document (BlockNote style JSON of all blocks)
33
55
  */
34
- export declare function yfragmentToBlocks<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema>(editor: BlockNoteEditor<BSchema, ISchema, SSchema>, fragment: Y.Type): Block<BSchema, ISchema, SSchema>[];
56
+ export declare function yfragmentToBlocks<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema>(editor: BlockNoteEditor<BSchema, ISchema, SSchema>, fragment: Y.Node): Block<BSchema, ISchema, SSchema>[];
35
57
  /**
36
- * Convert blocks to a Y.Type
58
+ * Convert blocks to a Y.Node
37
59
  *
38
60
  * This can be used when importing existing content to Y.Doc for the first time,
39
61
  * note that this should not be used to rehydrate a Y.Doc from a database once
@@ -42,9 +64,9 @@ export declare function yfragmentToBlocks<BSchema extends BlockSchema, ISchema e
42
64
  * @param editor BlockNote editor
43
65
  * @param blocks the blocks to convert
44
66
  * @param fragment XML fragment name
45
- * @returns Y.Type
67
+ * @returns Y.Node
46
68
  */
47
- export declare function blocksToYType<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema>(editor: BlockNoteEditor<BSchema, ISchema, SSchema>, blocks: Block<BSchema, ISchema, SSchema>[], fragment?: Y.Type): Y.Type<any>;
69
+ export declare function blocksToYType<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema>(editor: BlockNoteEditor<BSchema, ISchema, SSchema>, blocks: Block<BSchema, ISchema, SSchema>[], fragment?: Y.Node): Y.Node<any>;
48
70
  /**
49
71
  * Turn a Y.Doc collaborative doc into a BlockNote document (BlockNote style JSON of all blocks)
50
72
  * @param editor BlockNote editor
@@ -70,13 +92,11 @@ export declare function blocksToYDoc<BSchema extends BlockSchema, ISchema extend
70
92
  */
71
93
  export declare function docDiffToDelta(previousDoc: Node, newDoc: Node): d.Delta<d.DeltaConf>;
72
94
  /**
73
- * Build a ProseMirror transaction that turns `tr.doc` into the content of a
74
- * Y.Type `fragment`, applying the `renderer`'s authorship as
75
- * `y-attributed-*` marks. Used to render a (read-only) diff of a snapshot / a
76
- * version comparison into the editor.
95
+ * Append steps that render a Y node into the transaction's current document.
96
+ * Supports both plain and already-attributed documents, replacing old preview
97
+ * marks with the renderer's attributions using BlockNote's node-pairing policy.
98
+ * Defaults to the binding's pipeline ({@link blockNoteTransformer}). Does not
99
+ * dispatch or write to the Y node; the caller controls sync configuration and
100
+ * dispatch.
77
101
  */
78
- export declare function getProseMirrorTrFromYFragment({ tr, fragment, renderer, }: {
79
- tr: Transaction;
80
- fragment: Y.Type;
81
- renderer?: Y.AbstractRenderer | null;
82
- }): Transaction;
102
+ export declare function yNodeToTransaction(tr: Transaction, node: Y.Node, options?: NonNullable<Parameters<typeof ynodeToPmnode>[2]>): Transaction;
@@ -1 +1 @@
1
- export * from "./yhub.js";
1
+ export { createYHubVersionStorage, YVersioningExtension, YHubVersioningExtension, type YHubVersionStorageOptions, } from "./yhub.js";
@@ -1,88 +1,71 @@
1
1
  import * as Y from "@y/y";
2
- import { VersioningEndpointsFactory } from "../../extensions/Versioning/index.js";
3
- /**
4
- * Options for creating a YHub versioning endpoints instance.
5
- */
6
- export interface YHubVersioningOptions {
7
- /**
8
- * Base URL of the YHub API, including the API prefix
9
- * (e.g. `"https://yhub.example.com/api"`).
10
- * Must **not** include a trailing slash.
11
- */
12
- baseUrl: string;
13
- /** YHub organisation identifier. */
14
- org: string;
15
- /** Document identifier within the organisation. */
16
- docId: string;
17
- /**
18
- * Optional headers to include in every request (e.g. authentication tokens).
19
- */
20
- headers?: Record<string, string>;
21
- /**
22
- * Maximum number of activity entries to fetch when listing versions.
23
- * @default 50
24
- */
25
- activityLimit?: number;
26
- /**
27
- * When set, forwarded as the `group` query param to the YHub activity API,
28
- * controlling whether adjacent edits are grouped into single entries.
29
- */
30
- group?: boolean;
31
- /**
32
- * Maximum gap (in ms) between edits for them to be grouped together.
33
- * Forwarded as the `groupMaxGap` query param.
34
- * @default 10000
35
- */
36
- groupMaxGap?: number;
37
- /**
38
- * Maximum total duration (in ms) a single group of edits may span.
39
- * When set, forwarded as the `groupMaxDuration` query param.
40
- */
41
- groupMaxDuration?: number;
42
- /**
43
- * When `true`, adjacent edits are grouped together even when made by
44
- * *different* users (their ids accumulate in the grouped entry's `by`).
45
- * When `false` (the default), only same-user adjacent edits are merged.
46
- * Forwarded as the `mergeUsers` query param.
47
- * @default false
48
- */
49
- mergeUsers?: boolean;
2
+ import type { VersionStorage } from "../../extensions/Versioning/types.js";
3
+ import { type YHubClientOptions, type YHubQueryParams } from "./yhubClient.js";
4
+ export interface YHubVersionStorageOptions extends YHubClientOptions {
5
+ /** Activity grouping and filters. `limit` is the page size, defaulting to 50. History is newest first. */
6
+ activityParams?: YHubQueryParams;
50
7
  }
51
- /**
52
- * Create a {@link VersioningEndpoints} implementation backed by the
53
- * [YHub](https://github.com/yjs/yhub) HTTP API.
54
- *
55
- * Versions are created by PATCHing the document with custom attributions
56
- * (`type:version` + an optional `name`). The `list` endpoint returns the full
57
- * activity timeline, mapping `type:version` markers to named versions and every
58
- * other entry to a history-only snapshot, so the sidebar can show both the
59
- * named versions and the complete edit history.
60
- *
61
- * A version's id lives in immutable YHub attributions (`type:version` + `id`),
62
- * so it is fixed at creation time. Version *names*, however, are stored in a
63
- * mutable `__bn_version_names` map on the live collaboration doc (see
64
- * {@link VERSION_NAMES_MAP}), so `rename` is supported and simply updates that
65
- * store.
66
- *
67
- * @example
68
- * ```ts
69
- * import { withCollaboration } from "@blocknote/core/y";
70
- * import { createYHubVersioningEndpoints } from "@blocknote/core/y";
71
- *
72
- * const editor = BlockNoteEditor.create(
73
- * withCollaboration({
74
- * collaboration: {
75
- * fragment,
76
- * user: { name: "Alice", color: "#ff0" },
77
- * provider,
78
- * versioningEndpoints: createYHubVersioningEndpoints({
79
- * baseUrl: "https://yhub.example.com/api",
80
- * org: "my-org",
81
- * docId: "my-doc",
82
- * }),
83
- * },
84
- * }),
85
- * );
86
- * ```
87
- */
88
- export declare function createYHubVersioningEndpoints(options: YHubVersioningOptions): VersioningEndpointsFactory<Y.Type, Uint8Array, Y.ContentMap>;
8
+ type YHubStorage = VersionStorage<Uint8Array, Y.ContentMap> & Required<Pick<VersionStorage<Uint8Array, Y.ContentMap>, "getAttributions" | "create" | "restore" | "rename" | "remove">>;
9
+ /** Configure Y14 history independently of collaboration installation. */
10
+ export declare function YVersioningExtension(options: {
11
+ storage: VersionStorage<Uint8Array, Y.ContentMap>;
12
+ scrollToFirstChange?: boolean;
13
+ }): import("../../index.js").ExtensionFactoryInstance<{
14
+ store: import("../../index.js").Store<import("../../extensions/index.js").VersioningState>;
15
+ open: () => boolean;
16
+ close: () => void;
17
+ list: () => Promise<import("../../extensions/index.js").VersionOperationResult>;
18
+ loadMore: () => Promise<import("../../extensions/index.js").VersionOperationResult>;
19
+ select: (target: import("../../extensions/index.js").VersionSelection, selectionOptions?: {
20
+ compareTo?: string;
21
+ } | undefined) => Promise<import("../../extensions/index.js").VersionOperationResult>;
22
+ restore: (id: string) => Promise<import("../../extensions/index.js").VersionOperationResult>;
23
+ rename: (id: string, name?: string) => Promise<import("../../extensions/index.js").VersionOperationResult>;
24
+ readonly canCompare: boolean;
25
+ readonly historyIncludesBeginning: boolean;
26
+ readonly canCreate: boolean;
27
+ readonly canRename: boolean;
28
+ readonly canRestore: boolean;
29
+ readonly canRemove: boolean;
30
+ create(this: void, name?: string): Promise<import("../../extensions/index.js").VersionOperationResult>;
31
+ remove(this: void, id: string): Promise<import("../../extensions/index.js").VersionOperationResult>;
32
+ dispose(): void;
33
+ } & {
34
+ readonly key: "versioning";
35
+ readonly userStore: import("../../index.js").UserStore<import("../../index.js").User>;
36
+ readonly mount: () => () => void;
37
+ }>;
38
+ /** Install YHub history for the editor's live collaboration document. */
39
+ export declare function YHubVersioningExtension(options: YHubVersionStorageOptions & {
40
+ scrollToFirstChange?: boolean;
41
+ }): import("../../index.js").ExtensionFactoryInstance<{
42
+ store: import("../../index.js").Store<import("../../extensions/index.js").VersioningState>;
43
+ open: () => boolean;
44
+ close: () => void;
45
+ list: () => Promise<import("../../extensions/index.js").VersionOperationResult>;
46
+ loadMore: () => Promise<import("../../extensions/index.js").VersionOperationResult>;
47
+ select: (target: import("../../extensions/index.js").VersionSelection, selectionOptions?: {
48
+ compareTo?: string;
49
+ } | undefined) => Promise<import("../../extensions/index.js").VersionOperationResult>;
50
+ restore: (id: string) => Promise<import("../../extensions/index.js").VersionOperationResult>;
51
+ rename: (id: string, name?: string) => Promise<import("../../extensions/index.js").VersionOperationResult>;
52
+ readonly canCompare: boolean;
53
+ readonly historyIncludesBeginning: boolean;
54
+ readonly canCreate: boolean;
55
+ readonly canRename: boolean;
56
+ readonly canRestore: boolean;
57
+ readonly canRemove: boolean;
58
+ create(this: void, name?: string): Promise<import("../../extensions/index.js").VersionOperationResult>;
59
+ remove(this: void, id: string): Promise<import("../../extensions/index.js").VersionOperationResult>;
60
+ dispose(): void;
61
+ } & {
62
+ readonly key: "versioning";
63
+ readonly userStore: import("../../index.js").UserStore<import("../../index.js").User>;
64
+ readonly mount: () => () => void;
65
+ }>;
66
+ /** Continuous history for a live fragment, with no editor dependency. */
67
+ export declare function createYHubVersionStorage(options: YHubVersionStorageOptions & {
68
+ fragment: Y.Node;
69
+ beforeRestoreName: string;
70
+ }): YHubStorage;
71
+ export {};
@@ -0,0 +1,67 @@
1
+ import type { VersionResult } from "../../extensions/Versioning/types.js";
2
+ export interface YHubClientOptions {
3
+ /** API base URL, including the API prefix, without a trailing slash. */
4
+ baseUrl: string;
5
+ /** Organisation identifier. */
6
+ org: string;
7
+ /** Document identifier within the organisation. */
8
+ docId: string;
9
+ /** Headers included in every request, e.g. authentication tokens. */
10
+ headers?: Record<string, string>;
11
+ /** Authentication query parameters included in every request. The open YHub demo uses `userid`. */
12
+ queryParams?: YHubQueryParams;
13
+ /** Bounds each request, including reading the response body. Defaults to 30 seconds. */
14
+ timeoutMs?: number;
15
+ }
16
+ export interface YHubVersion<Metadata = unknown> {
17
+ type: "version:v1";
18
+ t: number;
19
+ name: string;
20
+ custom: Metadata | null | undefined;
21
+ updatedAt: number;
22
+ }
23
+ /** Activity with wire-format authors and attribution pairs normalized. */
24
+ export interface YHubActivityEntry<Metadata = unknown> {
25
+ from: number;
26
+ to: number;
27
+ by: string[];
28
+ customAttributions: Record<string, string>;
29
+ version?: YHubVersion<Metadata>;
30
+ }
31
+ export interface YHubChangeset {
32
+ /** Encoded document state at the requested timestamp. */
33
+ ydoc?: Uint8Array;
34
+ /** Encoded content map, when requested. */
35
+ attributions?: Uint8Array;
36
+ }
37
+ export interface YHubDocument {
38
+ doc: Uint8Array;
39
+ }
40
+ /** Query values are serialized without adding defaults. */
41
+ export type YHubQueryParams = Record<string, string | number | boolean | undefined>;
42
+ export interface YHubRollbackParams {
43
+ /** Inclusive start of the rollback window, in Unix milliseconds. */
44
+ from: number;
45
+ /** Encoded content IDs to roll back. */
46
+ contentIds: Uint8Array;
47
+ }
48
+ /** Document-scoped REST operations; binary Yjs payloads remain encoded. */
49
+ export declare class YHubClient<Metadata = unknown> {
50
+ private readonly baseUrl;
51
+ private readonly documentPath;
52
+ private readonly headers;
53
+ private readonly queryParams;
54
+ private readonly timeoutMs;
55
+ constructor({ baseUrl, org, docId, headers, queryParams, timeoutMs, }: YHubClientOptions);
56
+ private request;
57
+ getVersion(t: number): Promise<VersionResult<YHubVersion<Metadata> | undefined>>;
58
+ createVersion(t: number, name: string, custom?: Metadata | null): Promise<VersionResult<YHubVersion<Metadata>>>;
59
+ updateVersion(version: YHubVersion<Metadata>, name: string, custom?: Metadata | null | undefined): Promise<VersionResult<YHubVersion<Metadata>>>;
60
+ deleteVersion(version: YHubVersion<Metadata>): Promise<VersionResult<void>>;
61
+ getActivity(params?: YHubQueryParams, signal?: AbortSignal): Promise<VersionResult<YHubActivityEntry<Metadata>[]>>;
62
+ getChangeset(params?: YHubQueryParams, signal?: AbortSignal): Promise<VersionResult<YHubChangeset>>;
63
+ getDocument(params?: YHubQueryParams): Promise<VersionResult<Uint8Array>>;
64
+ getContent(to: number, signal?: AbortSignal): Promise<VersionResult<Uint8Array>>;
65
+ getAttributions(from: number, to?: number, signal?: AbortSignal): Promise<VersionResult<Uint8Array>>;
66
+ rollback(params: YHubRollbackParams): Promise<VersionResult<void>>;
67
+ }
@@ -12,6 +12,8 @@ export declare const ForkYDocExtension: (options: CollaborationOptions) => impor
12
12
  readonly fork: ({ initialUpdate, }?: {
13
13
  initialUpdate?: Uint8Array;
14
14
  }) => void;
15
+ /** Replace only the local fork, retaining live restoration state. */
16
+ readonly replaceSnapshot: (initialUpdate: Uint8Array) => void;
15
17
  /**
16
18
  * Resume syncing the Y.js document to the remote
17
19
  * If `keepChanges` is true, any changes that have been made to the forked document will be applied to the original document.
@@ -0,0 +1 @@
1
+ export {};