@blocknote/core 0.51.3 → 0.52.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 (397) hide show
  1. package/dist/BlockNoteExtension-B_IEJHS8.js +38 -0
  2. package/dist/BlockNoteExtension-B_IEJHS8.js.map +1 -0
  3. package/dist/BlockNoteExtension-M0znTzxP.cjs +2 -0
  4. package/dist/BlockNoteExtension-M0znTzxP.cjs.map +1 -0
  5. package/dist/ThreadStore-Bx-gSEh1.cjs +2 -0
  6. package/dist/ThreadStore-Bx-gSEh1.cjs.map +1 -0
  7. package/dist/ThreadStore-et9wB5Xt.js +11 -0
  8. package/dist/ThreadStore-et9wB5Xt.js.map +1 -0
  9. package/dist/UserStore-DCG6lsla.cjs +2 -0
  10. package/dist/UserStore-DCG6lsla.cjs.map +1 -0
  11. package/dist/UserStore-QbbPFj0z.js +73 -0
  12. package/dist/UserStore-QbbPFj0z.js.map +1 -0
  13. package/dist/blocknote.cjs +1 -1
  14. package/dist/blocknote.js +6 -7
  15. package/dist/blocks-BqHv0xhc.cjs +12 -0
  16. package/dist/blocks-BqHv0xhc.cjs.map +1 -0
  17. package/dist/{blocks-D0lMxErU.js → blocks-CiuUGa1E.js} +1096 -998
  18. package/dist/blocks-CiuUGa1E.js.map +1 -0
  19. package/dist/blocks.cjs +1 -1
  20. package/dist/blocks.js +2 -2
  21. package/dist/comments.cjs +1 -1
  22. package/dist/comments.cjs.map +1 -1
  23. package/dist/comments.js +75 -340
  24. package/dist/comments.js.map +1 -1
  25. package/dist/{en-Cj5r8sW_.cjs → en-C5Z4Ag9_.cjs} +2 -2
  26. package/dist/en-C5Z4Ag9_.cjs.map +1 -0
  27. package/dist/{en-B9hMApn4.js → en-CGKXfWma.js} +9 -1
  28. package/dist/en-CGKXfWma.js.map +1 -0
  29. package/dist/{extensions-D2mx2C9y.js → extensions-CrUGDOks.js} +655 -583
  30. package/dist/extensions-CrUGDOks.js.map +1 -0
  31. package/dist/extensions-Ghr9QqqR.cjs +52 -0
  32. package/dist/extensions-Ghr9QqqR.cjs.map +1 -0
  33. package/dist/extensions.cjs +1 -1
  34. package/dist/extensions.js +4 -4
  35. package/dist/locales.cjs +1 -1
  36. package/dist/locales.cjs.map +1 -1
  37. package/dist/locales.js +177 -1
  38. package/dist/locales.js.map +1 -1
  39. package/dist/{src-Dvmif2FY.js → src-DTF83Cl9.js} +1243 -1297
  40. package/dist/src-DTF83Cl9.js.map +1 -0
  41. package/dist/src-OfbaVbMw.cjs +21 -0
  42. package/dist/src-OfbaVbMw.cjs.map +1 -0
  43. package/dist/style.css +1 -1
  44. package/dist/webpack-stats.json +1 -1
  45. package/dist/y.cjs +2 -0
  46. package/dist/y.cjs.map +1 -0
  47. package/dist/y.js +989 -0
  48. package/dist/y.js.map +1 -0
  49. package/dist/yjs.cjs +1 -1
  50. package/dist/yjs.cjs.map +1 -1
  51. package/dist/yjs.js +535 -14
  52. package/dist/yjs.js.map +1 -1
  53. package/package.json +46 -19
  54. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +1 -1
  55. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +1 -1
  56. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +3 -3
  57. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +25 -20
  58. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +39 -29
  59. package/src/api/blockManipulation/commands/nestBlock/nestBlock.test.ts +2 -2
  60. package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +4 -8
  61. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +1 -1
  62. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +21 -9
  63. package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +6 -5
  64. package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +362 -4
  65. package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +240 -30
  66. package/src/api/blockManipulation/getBlock/getBlock.ts +4 -9
  67. package/src/api/blockManipulation/selections/selection.ts +3 -6
  68. package/src/api/blockManipulation/selections/textCursorPosition.ts +10 -10
  69. package/src/api/blockManipulation/setupTestEnv.ts +1 -1
  70. package/src/api/blockManipulation/tables/tables.test.ts +1 -1
  71. package/src/api/clipboard/fromClipboard/fileDropExtension.ts +1 -1
  72. package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +8 -4
  73. package/src/api/clipboard/fromClipboard/pasteExtension.ts +1 -1
  74. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +2 -1
  75. package/src/api/exporters/markdown/htmlToMarkdown.ts +79 -43
  76. package/src/api/getBlockInfoFromPos.test.ts +256 -0
  77. package/src/api/getBlockInfoFromPos.ts +53 -15
  78. package/src/api/getBlocksChangedByTransaction.test.ts +2 -1
  79. package/src/api/getBlocksChangedByTransaction.ts +6 -6
  80. package/src/api/nodeConversions/blockToNode.test.ts +113 -0
  81. package/src/api/nodeConversions/blockToNode.ts +15 -3
  82. package/src/api/nodeConversions/fragmentToBlocks.ts +2 -4
  83. package/src/api/nodeConversions/nodeToBlock.ts +28 -58
  84. package/src/api/nodeUtil.ts +6 -2
  85. package/src/api/parsers/html/parseHTML.ts +1 -1
  86. package/src/api/parsers/html/util/nestedLists.test.ts +1 -1
  87. package/src/api/parsers/markdown/detectMarkdown.test.ts +1 -1
  88. package/src/api/parsers/markdown/markdownToHtml.ts +228 -82
  89. package/src/api/pmUtil.ts +18 -1
  90. package/src/api/positionMapping.test.ts +20 -345
  91. package/src/api/positionMapping.ts +13 -83
  92. package/src/blocks/Audio/block.ts +1 -1
  93. package/src/blocks/Code/block.test.ts +14 -7
  94. package/src/blocks/Code/block.ts +2 -2
  95. package/src/blocks/Image/block.ts +1 -1
  96. package/src/blocks/ListItem/CheckListItem/block.test.ts +1 -1
  97. package/src/blocks/ListItem/ListItemKeyboardShortcuts.ts +2 -2
  98. package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.ts +4 -11
  99. package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +47 -50
  100. package/src/blocks/Table/TableExtension.test.ts +129 -0
  101. package/src/blocks/Table/TableExtension.ts +23 -20
  102. package/src/blocks/Table/block.ts +18 -5
  103. package/src/blocks/Video/block.ts +1 -1
  104. package/src/blocks/utils/listItemEnterHandler.ts +3 -2
  105. package/src/comments/extension.ts +30 -21
  106. package/src/comments/index.ts +0 -3
  107. package/src/comments/mark.ts +4 -0
  108. package/src/comments/threadstore/ThreadStore.ts +4 -8
  109. package/src/comments/types.ts +0 -8
  110. package/src/editor/Block.css +307 -3
  111. package/src/editor/BlockNoteEditor.test.ts +39 -18
  112. package/src/editor/BlockNoteEditor.ts +22 -57
  113. package/src/editor/BlockNoteExtension.test.ts +1 -1
  114. package/src/editor/managers/BlockManager.ts +1 -1
  115. package/src/editor/managers/ExtensionManager/ExtensionManager.test.ts +249 -0
  116. package/src/editor/managers/ExtensionManager/extensions.ts +7 -18
  117. package/src/editor/managers/ExtensionManager/index.ts +168 -68
  118. package/src/editor/managers/StateManager.ts +4 -3
  119. package/src/editor/performance.test.ts +14 -1
  120. package/src/editor/transformPasted.test.ts +1 -1
  121. package/src/extensions/Placeholder/Placeholder.ts +1 -0
  122. package/src/extensions/PositionMapping/PositionMapping.ts +68 -0
  123. package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +14 -1
  124. package/src/extensions/PreviousBlockType/PreviousBlockType.ts +14 -11
  125. package/src/extensions/SideMenu/SideMenu.ts +9 -2
  126. package/src/extensions/SuggestionMenu/SuggestionMenu.test.ts +1 -1
  127. package/src/extensions/TableHandles/TableHandles.ts +18 -20
  128. package/src/extensions/TrailingNode/TrailingNode.ts +33 -1
  129. package/src/extensions/Versioning/Versioning.test.ts +435 -0
  130. package/src/extensions/Versioning/Versioning.ts +628 -0
  131. package/src/extensions/Versioning/inMemoryVersioning.test.ts +469 -0
  132. package/src/extensions/Versioning/inMemoryVersioning.ts +263 -0
  133. package/src/extensions/Versioning/index.ts +2 -0
  134. package/src/extensions/index.ts +6 -9
  135. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts +155 -0
  136. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +6 -8
  137. package/src/extensions/tiptap-extensions/Link/helpers/autolink.ts +9 -9
  138. package/src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts +8 -10
  139. package/src/extensions/tiptap-extensions/Link/helpers/whitespace.ts +2 -2
  140. package/src/extensions/tiptap-extensions/Link/link.test.ts +26 -22
  141. package/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.ts +187 -0
  142. package/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts +37 -24
  143. package/src/extensions/tiptap-extensions/index.ts +1 -25
  144. package/src/i18n/locales/ar.ts +9 -0
  145. package/src/i18n/locales/de.ts +9 -0
  146. package/src/i18n/locales/en.ts +10 -1
  147. package/src/i18n/locales/es.ts +9 -0
  148. package/src/i18n/locales/fa.ts +11 -1
  149. package/src/i18n/locales/fr.ts +9 -0
  150. package/src/i18n/locales/he.ts +10 -1
  151. package/src/i18n/locales/hr.ts +10 -0
  152. package/src/i18n/locales/is.ts +10 -0
  153. package/src/i18n/locales/it.ts +9 -0
  154. package/src/i18n/locales/ja.ts +9 -0
  155. package/src/i18n/locales/ko.ts +9 -0
  156. package/src/i18n/locales/nl.ts +10 -0
  157. package/src/i18n/locales/no.ts +10 -0
  158. package/src/i18n/locales/pl.ts +9 -0
  159. package/src/i18n/locales/pt.ts +10 -0
  160. package/src/i18n/locales/ru.ts +10 -0
  161. package/src/i18n/locales/sk.ts +10 -1
  162. package/src/i18n/locales/uk.ts +9 -0
  163. package/src/i18n/locales/uz.ts +9 -0
  164. package/src/i18n/locales/vi.ts +9 -0
  165. package/src/i18n/locales/zh-tw.ts +9 -0
  166. package/src/i18n/locales/zh.ts +9 -0
  167. package/src/index.ts +2 -0
  168. package/src/pm-nodes/BlockContainer.ts +4 -1
  169. package/src/pm-nodes/BlockGroup.ts +4 -1
  170. package/src/pm-nodes/Doc.ts +4 -1
  171. package/src/pm-nodes/suggestionMarks.ts +43 -0
  172. package/src/schema/blocks/createSpec.test.ts +123 -0
  173. package/src/schema/blocks/createSpec.ts +82 -24
  174. package/src/schema/blocks/extendBlockSpec.test.ts +188 -0
  175. package/src/schema/blocks/internal.ts +13 -43
  176. package/src/schema/blocks/types.ts +69 -22
  177. package/src/schema/contentTypePropagation.test.ts +182 -0
  178. package/src/schema/index.ts +1 -0
  179. package/src/schema/inlineContent/internal.ts +1 -1
  180. package/src/schema/inlineContent/types.ts +3 -3
  181. package/src/schema/markGroups.ts +50 -0
  182. package/src/user/UserStore.ts +199 -0
  183. package/src/user/createUserStore.test.ts +126 -0
  184. package/src/user/index.ts +2 -0
  185. package/src/user/userColors.ts +72 -0
  186. package/src/util/string.ts +1 -1
  187. package/src/util/topo-sort.test.ts +1 -1
  188. package/src/util/typescript.ts +2 -1
  189. package/src/vite-env.d.ts +1 -1
  190. package/src/y/README.md +5 -0
  191. package/src/{comments/threadstore/yjs → y/comments}/RESTYjsThreadStore.ts +8 -14
  192. package/src/y/comments/YjsThreadStore.test.ts +295 -0
  193. package/src/y/comments/YjsThreadStore.ts +358 -0
  194. package/src/y/comments/YjsThreadStoreBase.ts +50 -0
  195. package/src/y/comments/index.ts +3 -0
  196. package/src/y/comments/yjsHelpers.ts +125 -0
  197. package/src/y/extensions/AttributionExtension.test.ts +86 -0
  198. package/src/y/extensions/AttributionExtension.ts +378 -0
  199. package/src/y/extensions/DiffVersioningExtension.test.ts +193 -0
  200. package/src/y/extensions/DiffVersioningExtension.ts +228 -0
  201. package/src/y/extensions/ForkYDoc.test.ts +253 -0
  202. package/src/y/extensions/ForkYDoc.ts +108 -0
  203. package/src/y/extensions/RelativePositionMapping.test.ts +418 -0
  204. package/src/y/extensions/RelativePositionMapping.ts +49 -0
  205. package/src/y/extensions/Suggestions.ts +174 -0
  206. package/src/y/extensions/Versioning.test.ts +395 -0
  207. package/src/y/extensions/Versioning.ts +115 -0
  208. package/src/y/extensions/YAttributionMarks.ts +320 -0
  209. package/src/{extensions/Collaboration → y/extensions}/YCursorPlugin.ts +15 -7
  210. package/src/y/extensions/YSync.ts +125 -0
  211. package/src/y/extensions/blockMatchNodes.ts +182 -0
  212. package/src/y/extensions/index.ts +156 -0
  213. package/src/y/index.ts +4 -0
  214. package/src/y/utils.test.ts +1042 -0
  215. package/src/y/utils.ts +242 -0
  216. package/src/y/versioning/__test__/fixtures/activity-all-after.bin +0 -0
  217. package/src/y/versioning/__test__/fixtures/activity-all-after.json +50 -0
  218. package/src/y/versioning/__test__/fixtures/activity-all.bin +0 -0
  219. package/src/y/versioning/__test__/fixtures/activity-all.json +20 -0
  220. package/src/y/versioning/__test__/fixtures/activity-filtered-after.bin +0 -0
  221. package/src/y/versioning/__test__/fixtures/activity-filtered-after.json +32 -0
  222. package/src/y/versioning/__test__/fixtures/activity-filtered-before.json +1 -0
  223. package/src/y/versioning/__test__/fixtures/changeset.bin +0 -0
  224. package/src/y/versioning/__test__/fixtures/patch-response.json +4 -0
  225. package/src/y/versioning/__test__/yhub.test.ts +752 -0
  226. package/src/y/versioning/index.ts +1 -0
  227. package/src/y/versioning/yhub.ts +631 -0
  228. package/src/yjs/README.md +5 -0
  229. package/src/yjs/comments/RESTYjsThreadStore.ts +166 -0
  230. package/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStore.test.ts +3 -3
  231. package/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStore.ts +7 -3
  232. package/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStoreBase.ts +3 -3
  233. package/src/yjs/comments/index.ts +3 -0
  234. package/src/{comments/threadstore/yjs → yjs/comments}/yjsHelpers.ts +5 -1
  235. package/src/yjs/extensions/FixUpSchema.test.ts +421 -0
  236. package/src/yjs/extensions/FixUpSchema.ts +88 -0
  237. package/src/yjs/extensions/ForkYDoc.test.ts +216 -0
  238. package/src/{extensions/Collaboration → yjs/extensions}/ForkYDoc.ts +38 -57
  239. package/src/yjs/extensions/RelativePositionMapping.test.ts +418 -0
  240. package/src/yjs/extensions/RelativePositionMapping.ts +71 -0
  241. package/src/yjs/extensions/Versioning.test.ts +549 -0
  242. package/src/yjs/extensions/Versioning.ts +83 -0
  243. package/src/yjs/extensions/YCursorPlugin.ts +201 -0
  244. package/src/{extensions/Collaboration → yjs/extensions}/YSync.ts +1 -1
  245. package/src/yjs/extensions/index.ts +89 -0
  246. package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/moveColorAttributes.test.ts +1 -1
  247. package/src/yjs/index.ts +2 -0
  248. package/src/yjs/utils.test.ts +5 -15
  249. package/src/yjs/utils.ts +36 -0
  250. package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.d.ts +3 -1
  251. package/types/src/api/blockManipulation/selections/selection.d.ts +1 -1
  252. package/types/src/api/getBlockInfoFromPos.d.ts +5 -9
  253. package/types/src/api/nodeConversions/nodeToBlock.d.ts +4 -6
  254. package/types/src/api/pmUtil.d.ts +12 -1
  255. package/types/src/blocks/Audio/block.d.ts +2 -2
  256. package/types/src/blocks/Code/block.d.ts +2 -2
  257. package/types/src/blocks/File/block.d.ts +2 -2
  258. package/types/src/blocks/Heading/block.d.ts +21 -21
  259. package/types/src/blocks/Image/block.d.ts +3 -3
  260. package/types/src/blocks/ListItem/CheckListItem/block.d.ts +6 -6
  261. package/types/src/blocks/ListItem/NumberedListItem/block.d.ts +6 -6
  262. package/types/src/blocks/Video/block.d.ts +3 -3
  263. package/types/src/blocks/defaultBlocks.d.ts +17 -17
  264. package/types/src/comments/extension.d.ts +18 -5
  265. package/types/src/comments/index.d.ts +0 -3
  266. package/types/src/comments/threadstore/ThreadStore.d.ts +4 -8
  267. package/types/src/comments/types.d.ts +0 -8
  268. package/types/src/editor/BlockNoteEditor.d.ts +8 -9
  269. package/types/src/editor/managers/BlockManager.d.ts +1 -1
  270. package/types/src/editor/managers/ExtensionManager/ExtensionManager.test.d.ts +1 -0
  271. package/types/src/editor/managers/ExtensionManager/extensions.d.ts +2 -2
  272. package/types/src/editor/managers/ExtensionManager/index.d.ts +13 -0
  273. package/types/src/editor/managers/SelectionManager.d.ts +1 -1
  274. package/types/src/extensions/PositionMapping/PositionMapping.d.ts +4 -0
  275. package/types/src/extensions/TableHandles/TableHandles.d.ts +6 -6
  276. package/types/src/extensions/Versioning/Versioning.d.ts +352 -0
  277. package/types/src/extensions/Versioning/Versioning.test.d.ts +1 -0
  278. package/types/src/extensions/Versioning/inMemoryVersioning.d.ts +37 -0
  279. package/types/src/extensions/Versioning/inMemoryVersioning.test.d.ts +1 -0
  280. package/types/src/extensions/Versioning/index.d.ts +2 -0
  281. package/types/src/extensions/index.d.ts +6 -9
  282. package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.d.ts +1 -0
  283. package/types/src/extensions/tiptap-extensions/UniqueID/UniqueID.d.ts +6 -1
  284. package/types/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.d.ts +4 -0
  285. package/types/src/extensions/tiptap-extensions/index.d.ts +1 -5
  286. package/types/src/i18n/locales/en.d.ts +9 -1
  287. package/types/src/i18n/locales/fa.d.ts +9 -1
  288. package/types/src/i18n/locales/sk.d.ts +9 -1
  289. package/types/src/index.d.ts +2 -0
  290. package/types/src/pm-nodes/suggestionMarks.d.ts +26 -0
  291. package/types/src/schema/blocks/createSpec.d.ts +4 -4
  292. package/types/src/schema/blocks/createSpec.test.d.ts +1 -0
  293. package/types/src/schema/blocks/extendBlockSpec.test.d.ts +1 -0
  294. package/types/src/schema/blocks/internal.d.ts +5 -7
  295. package/types/src/schema/blocks/types.d.ts +22 -14
  296. package/types/src/schema/contentTypePropagation.test.d.ts +1 -0
  297. package/types/src/schema/index.d.ts +1 -0
  298. package/types/src/schema/inlineContent/types.d.ts +3 -3
  299. package/types/src/schema/markGroups.d.ts +33 -0
  300. package/types/src/user/UserStore.d.ts +105 -0
  301. package/types/src/user/createUserStore.test.d.ts +1 -0
  302. package/types/src/user/index.d.ts +2 -0
  303. package/types/src/user/userColors.d.ts +36 -0
  304. package/types/src/y/comments/RESTYjsThreadStore.d.ts +77 -0
  305. package/types/src/y/comments/YjsThreadStore.d.ts +79 -0
  306. package/types/src/y/comments/YjsThreadStore.test.d.ts +1 -0
  307. package/types/src/y/comments/YjsThreadStoreBase.d.ts +15 -0
  308. package/types/src/y/comments/index.d.ts +3 -0
  309. package/types/src/y/comments/yjsHelpers.d.ts +13 -0
  310. package/types/src/y/extensions/AttributionExtension.d.ts +74 -0
  311. package/types/src/y/extensions/AttributionExtension.test.d.ts +1 -0
  312. package/types/src/y/extensions/DiffVersioningExtension.d.ts +69 -0
  313. package/types/src/y/extensions/DiffVersioningExtension.test.d.ts +1 -0
  314. package/types/src/{extensions/Collaboration → y/extensions}/ForkYDoc.d.ts +4 -2
  315. package/types/src/y/extensions/ForkYDoc.test.d.ts +1 -0
  316. package/types/src/y/extensions/RelativePositionMapping.d.ts +4 -0
  317. package/types/src/y/extensions/RelativePositionMapping.test.d.ts +1 -0
  318. package/types/src/y/extensions/Suggestions.d.ts +36 -0
  319. package/types/src/y/extensions/Versioning.d.ts +17 -0
  320. package/types/src/y/extensions/Versioning.test.d.ts +1 -0
  321. package/types/src/y/extensions/YAttributionMarks.d.ts +67 -0
  322. package/types/src/y/extensions/YCursorPlugin.d.ts +14 -0
  323. package/types/src/y/extensions/YSync.d.ts +32 -0
  324. package/types/src/y/extensions/blockMatchNodes.d.ts +25 -0
  325. package/types/src/y/extensions/index.d.ts +189 -0
  326. package/types/src/y/index.d.ts +4 -0
  327. package/types/src/y/utils.d.ts +82 -0
  328. package/types/src/y/utils.test.d.ts +1 -0
  329. package/types/src/y/versioning/__test__/yhub.test.d.ts +1 -0
  330. package/types/src/y/versioning/index.d.ts +1 -0
  331. package/types/src/y/versioning/yhub.d.ts +87 -0
  332. package/types/src/{comments/threadstore/yjs → yjs/comments}/RESTYjsThreadStore.d.ts +6 -10
  333. package/types/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStore.d.ts +3 -3
  334. package/types/src/yjs/comments/YjsThreadStore.test.d.ts +1 -0
  335. package/types/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStoreBase.d.ts +3 -3
  336. package/types/src/yjs/comments/index.d.ts +3 -0
  337. package/types/src/{comments/threadstore/yjs → yjs/comments}/yjsHelpers.d.ts +1 -1
  338. package/types/src/yjs/extensions/FixUpSchema.d.ts +3 -0
  339. package/types/src/yjs/extensions/FixUpSchema.test.d.ts +1 -0
  340. package/types/src/yjs/extensions/ForkYDoc.d.ts +27 -0
  341. package/types/src/yjs/extensions/ForkYDoc.test.d.ts +1 -0
  342. package/types/src/yjs/extensions/RelativePositionMapping.d.ts +4 -0
  343. package/types/src/yjs/extensions/RelativePositionMapping.test.d.ts +1 -0
  344. package/types/src/yjs/extensions/Versioning.d.ts +26 -0
  345. package/types/src/yjs/extensions/Versioning.test.d.ts +1 -0
  346. package/types/src/{extensions/Collaboration → yjs/extensions}/YCursorPlugin.d.ts +5 -2
  347. package/types/src/{extensions/Collaboration → yjs/extensions}/YSync.d.ts +1 -1
  348. package/types/src/{extensions/Collaboration/Collaboration.d.ts → yjs/extensions/index.d.ts} +36 -15
  349. package/types/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.test.d.ts +1 -0
  350. package/types/src/yjs/index.d.ts +2 -0
  351. package/types/src/yjs/utils.d.ts +5 -0
  352. package/dist/BlockNoteExtension-B6RhuQ3V.js +0 -27
  353. package/dist/BlockNoteExtension-B6RhuQ3V.js.map +0 -1
  354. package/dist/BlockNoteExtension-ab0REuob.cjs +0 -2
  355. package/dist/BlockNoteExtension-ab0REuob.cjs.map +0 -1
  356. package/dist/EventEmitter-CuPnGDYt.js +0 -22
  357. package/dist/EventEmitter-CuPnGDYt.js.map +0 -1
  358. package/dist/EventEmitter-DHdSnYCD.cjs +0 -2
  359. package/dist/EventEmitter-DHdSnYCD.cjs.map +0 -1
  360. package/dist/ShowSelection-BsHFfdMi.js +0 -29
  361. package/dist/ShowSelection-BsHFfdMi.js.map +0 -1
  362. package/dist/ShowSelection-DhXglbt8.cjs +0 -2
  363. package/dist/ShowSelection-DhXglbt8.cjs.map +0 -1
  364. package/dist/blocks-D0lMxErU.js.map +0 -1
  365. package/dist/blocks-KyMOxPT3.cjs +0 -11
  366. package/dist/blocks-KyMOxPT3.cjs.map +0 -1
  367. package/dist/en-B9hMApn4.js.map +0 -1
  368. package/dist/en-Cj5r8sW_.cjs.map +0 -1
  369. package/dist/extensions-Cutrafjg.cjs +0 -52
  370. package/dist/extensions-Cutrafjg.cjs.map +0 -1
  371. package/dist/extensions-D2mx2C9y.js.map +0 -1
  372. package/dist/src-D5R5YzV7.cjs +0 -21
  373. package/dist/src-D5R5YzV7.cjs.map +0 -1
  374. package/dist/src-Dvmif2FY.js.map +0 -1
  375. package/src/comments/userstore/UserStore.ts +0 -72
  376. package/src/extensions/Collaboration/Collaboration.ts +0 -55
  377. package/src/extensions/Collaboration/ForkYDoc.test.ts +0 -179
  378. package/src/extensions/tiptap-extensions/Suggestions/SuggestionMarks.ts +0 -175
  379. package/types/src/comments/userstore/UserStore.d.ts +0 -31
  380. package/types/src/extensions/tiptap-extensions/Suggestions/SuggestionMarks.d.ts +0 -4
  381. /package/src/{extensions/Collaboration → yjs/extensions}/YUndo.ts +0 -0
  382. /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap-editor-forked.json +0 -0
  383. /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap-editor.json +0 -0
  384. /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap-forked.html +0 -0
  385. /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap.html +0 -0
  386. /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/SchemaMigration.ts +0 -0
  387. /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/index.ts +0 -0
  388. /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/migrationRule.ts +0 -0
  389. /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/moveColorAttributes.ts +0 -0
  390. /package/types/src/{comments/threadstore/yjs/YjsThreadStore.test.d.ts → api/getBlockInfoFromPos.test.d.ts} +0 -0
  391. /package/types/src/{extensions/Collaboration/ForkYDoc.test.d.ts → api/nodeConversions/blockToNode.test.d.ts} +0 -0
  392. /package/types/src/{extensions/Collaboration/schemaMigration/migrationRules/moveColorAttributes.test.d.ts → blocks/Table/TableExtension.test.d.ts} +0 -0
  393. /package/types/src/{extensions/Collaboration → yjs/extensions}/YUndo.d.ts +0 -0
  394. /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/SchemaMigration.d.ts +0 -0
  395. /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/index.d.ts +0 -0
  396. /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/migrationRule.d.ts +0 -0
  397. /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/moveColorAttributes.d.ts +0 -0
@@ -0,0 +1,1042 @@
1
+ import { Block, docToBlocks } from "../index.js";
2
+ import { BlockNoteEditor } from "../editor/BlockNoteEditor.js";
3
+ import { describe, expect, it } from "vite-plus/test";
4
+ import * as Y from "@y/y";
5
+ import {
6
+ _blocksToProsemirrorNode,
7
+ blocksToYDoc,
8
+ blocksToYType,
9
+ yDocToBlocks,
10
+ yfragmentToBlocks,
11
+ } from "./utils.js";
12
+
13
+ describe("Test y (v14) utils", () => {
14
+ const editor = BlockNoteEditor.create();
15
+
16
+ const testConversion = (testName: string, blocks: Block[]) => {
17
+ it(`${testName} - converts to and from prosemirror (doc)`, () => {
18
+ const node = _blocksToProsemirrorNode(editor, blocks);
19
+ const blockOutput = docToBlocks(node);
20
+ expect(blockOutput).toEqual(blocks);
21
+ });
22
+
23
+ it(`${testName} - converts to and from yjs (doc)`, () => {
24
+ const ydoc = blocksToYDoc(editor, blocks);
25
+ const blockOutput = yDocToBlocks(editor, ydoc);
26
+ expect(blockOutput).toEqual(blocks);
27
+ });
28
+
29
+ it(`${testName} - converts to and from yjs (fragment)`, () => {
30
+ const doc = new Y.Doc();
31
+ const fragment = doc.get("test");
32
+ blocksToYType(editor, blocks, fragment);
33
+
34
+ const blockOutput = yfragmentToBlocks(editor, fragment);
35
+ expect(blockOutput).toEqual(blocks);
36
+ });
37
+ };
38
+
39
+ describe("Original test case", () => {
40
+ const blocks: Block[] = [
41
+ {
42
+ id: "1",
43
+ type: "heading",
44
+ props: {
45
+ backgroundColor: "blue",
46
+ textColor: "yellow",
47
+ textAlignment: "right",
48
+ level: 2,
49
+ isToggleable: false,
50
+ },
51
+ content: [
52
+ {
53
+ type: "text",
54
+ text: "Heading ",
55
+ styles: {
56
+ bold: true,
57
+ underline: true,
58
+ },
59
+ },
60
+ {
61
+ type: "text",
62
+ text: "2",
63
+ styles: {
64
+ italic: true,
65
+ strike: true,
66
+ },
67
+ },
68
+ ],
69
+ children: [
70
+ {
71
+ id: "2",
72
+ type: "paragraph",
73
+ props: {
74
+ backgroundColor: "red",
75
+ textAlignment: "left",
76
+ textColor: "default",
77
+ },
78
+ content: [
79
+ {
80
+ type: "text",
81
+ text: "Paragraph",
82
+ styles: {},
83
+ },
84
+ ],
85
+ children: [],
86
+ },
87
+ {
88
+ id: "3",
89
+ type: "bulletListItem",
90
+ props: {
91
+ backgroundColor: "default",
92
+ textColor: "default",
93
+ textAlignment: "left",
94
+ },
95
+ content: [
96
+ {
97
+ type: "text",
98
+ text: "list item",
99
+ styles: {},
100
+ },
101
+ ],
102
+ children: [],
103
+ },
104
+ ],
105
+ },
106
+ {
107
+ id: "4",
108
+ type: "image",
109
+ props: {
110
+ backgroundColor: "default",
111
+ textAlignment: "left",
112
+ name: "Example",
113
+ url: "exampleURL",
114
+ caption: "Caption",
115
+ showPreview: true,
116
+ previewWidth: 256,
117
+ },
118
+ content: undefined,
119
+ children: [],
120
+ },
121
+ {
122
+ id: "5",
123
+ type: "image",
124
+ props: {
125
+ backgroundColor: "default",
126
+ textAlignment: "left",
127
+ name: "Example",
128
+ url: "exampleURL",
129
+ caption: "Caption",
130
+ showPreview: false,
131
+ previewWidth: 256,
132
+ },
133
+ content: undefined,
134
+ children: [],
135
+ },
136
+ ];
137
+
138
+ testConversion("original test case", blocks);
139
+ });
140
+
141
+ describe("Empty document", () => {
142
+ it("empty document - handles empty array", () => {
143
+ const blocks: Block[] = [];
144
+ const node = _blocksToProsemirrorNode(editor, blocks);
145
+ const blockOutput = docToBlocks(node);
146
+ expect(blockOutput).toEqual([]);
147
+ });
148
+
149
+ // An empty block array round-trips through yjs to the canonical empty
150
+ // BlockNote document: a single empty paragraph. (The id is generated, so we
151
+ // normalize it before comparing.)
152
+ const emptyDocument: Block[] = [
153
+ {
154
+ id: "0",
155
+ type: "paragraph",
156
+ props: {
157
+ backgroundColor: "default",
158
+ textColor: "default",
159
+ textAlignment: "left",
160
+ },
161
+ content: [],
162
+ children: [],
163
+ },
164
+ ];
165
+ const normalizeIds = (blocks: Block[]) =>
166
+ blocks.map((block) => ({ ...block, id: "0" }));
167
+
168
+ it("empty document - converts to and from yjs (doc)", () => {
169
+ const blocks: Block[] = [];
170
+ const ydoc = blocksToYDoc(editor, blocks);
171
+ const blockOutput = yDocToBlocks(editor, ydoc);
172
+ expect(normalizeIds(blockOutput)).toEqual(emptyDocument);
173
+ });
174
+
175
+ it("empty document - converts to and from yjs (fragment)", () => {
176
+ const blocks: Block[] = [];
177
+ const doc = new Y.Doc();
178
+ const fragment = doc.get("test");
179
+ blocksToYType(editor, blocks, fragment);
180
+
181
+ const blockOutput = yfragmentToBlocks(editor, fragment);
182
+ expect(normalizeIds(blockOutput)).toEqual(emptyDocument);
183
+ });
184
+ });
185
+
186
+ describe("Simple paragraphs", () => {
187
+ const blocks: Block[] = [
188
+ {
189
+ id: "1",
190
+ type: "paragraph",
191
+ props: {
192
+ backgroundColor: "default",
193
+ textColor: "default",
194
+ textAlignment: "left",
195
+ },
196
+ content: [
197
+ {
198
+ type: "text",
199
+ text: "First paragraph",
200
+ styles: {},
201
+ },
202
+ ],
203
+ children: [],
204
+ },
205
+ {
206
+ id: "2",
207
+ type: "paragraph",
208
+ props: {
209
+ backgroundColor: "default",
210
+ textColor: "default",
211
+ textAlignment: "center",
212
+ },
213
+ content: [
214
+ {
215
+ type: "text",
216
+ text: "Second paragraph",
217
+ styles: {},
218
+ },
219
+ ],
220
+ children: [],
221
+ },
222
+ ];
223
+ testConversion("simple paragraphs", blocks);
224
+ });
225
+
226
+ describe("Deeply nested lists", () => {
227
+ const blocks: Block[] = [
228
+ {
229
+ id: "1",
230
+ type: "bulletListItem",
231
+ props: {
232
+ backgroundColor: "default",
233
+ textColor: "default",
234
+ textAlignment: "left",
235
+ },
236
+ content: [
237
+ {
238
+ type: "text",
239
+ text: "Level 1",
240
+ styles: {},
241
+ },
242
+ ],
243
+ children: [
244
+ {
245
+ id: "2",
246
+ type: "bulletListItem",
247
+ props: {
248
+ backgroundColor: "default",
249
+ textColor: "default",
250
+ textAlignment: "left",
251
+ },
252
+ content: [
253
+ {
254
+ type: "text",
255
+ text: "Level 2",
256
+ styles: {},
257
+ },
258
+ ],
259
+ children: [
260
+ {
261
+ id: "3",
262
+ type: "bulletListItem",
263
+ props: {
264
+ backgroundColor: "default",
265
+ textColor: "default",
266
+ textAlignment: "left",
267
+ },
268
+ content: [
269
+ {
270
+ type: "text",
271
+ text: "Level 3",
272
+ styles: {},
273
+ },
274
+ ],
275
+ children: [
276
+ {
277
+ id: "4",
278
+ type: "bulletListItem",
279
+ props: {
280
+ backgroundColor: "default",
281
+ textColor: "default",
282
+ textAlignment: "left",
283
+ },
284
+ content: [
285
+ {
286
+ type: "text",
287
+ text: "Level 4",
288
+ styles: {},
289
+ },
290
+ ],
291
+ children: [],
292
+ },
293
+ ],
294
+ },
295
+ ],
296
+ },
297
+ ],
298
+ },
299
+ ];
300
+ testConversion("deeply nested lists", blocks);
301
+ });
302
+
303
+ describe("Numbered lists", () => {
304
+ const blocks = [
305
+ {
306
+ id: "1",
307
+ type: "numberedListItem",
308
+ props: {
309
+ backgroundColor: "default",
310
+ textColor: "default",
311
+ textAlignment: "left",
312
+ },
313
+ content: [
314
+ {
315
+ type: "text",
316
+ text: "First item",
317
+ styles: {},
318
+ },
319
+ ],
320
+ children: [],
321
+ },
322
+ {
323
+ id: "2",
324
+ type: "numberedListItem",
325
+ props: {
326
+ backgroundColor: "default",
327
+ textColor: "default",
328
+ textAlignment: "left",
329
+ },
330
+ content: [
331
+ {
332
+ type: "text",
333
+ text: "Second item",
334
+ styles: {},
335
+ },
336
+ ],
337
+ children: [
338
+ {
339
+ id: "3",
340
+ type: "numberedListItem",
341
+ props: {
342
+ backgroundColor: "default",
343
+ textColor: "default",
344
+ textAlignment: "left",
345
+ },
346
+ content: [
347
+ {
348
+ type: "text",
349
+ text: "Nested item",
350
+ styles: {},
351
+ },
352
+ ],
353
+ children: [],
354
+ },
355
+ ],
356
+ },
357
+ ] as unknown as Block[];
358
+ testConversion("numbered lists", blocks);
359
+ });
360
+
361
+ describe("Checklists", () => {
362
+ const blocks: Block[] = [
363
+ {
364
+ id: "1",
365
+ type: "checkListItem",
366
+ props: {
367
+ backgroundColor: "default",
368
+ textColor: "default",
369
+ textAlignment: "left",
370
+ checked: true,
371
+ },
372
+ content: [
373
+ {
374
+ type: "text",
375
+ text: "Completed task",
376
+ styles: {},
377
+ },
378
+ ],
379
+ children: [],
380
+ },
381
+ {
382
+ id: "2",
383
+ type: "checkListItem",
384
+ props: {
385
+ backgroundColor: "default",
386
+ textColor: "default",
387
+ textAlignment: "left",
388
+ checked: false,
389
+ },
390
+ content: [
391
+ {
392
+ type: "text",
393
+ text: "Pending task",
394
+ styles: {},
395
+ },
396
+ ],
397
+ children: [
398
+ {
399
+ id: "3",
400
+ type: "checkListItem",
401
+ props: {
402
+ backgroundColor: "default",
403
+ textColor: "default",
404
+ textAlignment: "left",
405
+ checked: false,
406
+ },
407
+ content: [
408
+ {
409
+ type: "text",
410
+ text: "Subtask",
411
+ styles: {},
412
+ },
413
+ ],
414
+ children: [],
415
+ },
416
+ ],
417
+ },
418
+ ];
419
+ testConversion("checklists", blocks);
420
+ });
421
+
422
+ describe("Toggle lists", () => {
423
+ const blocks: Block[] = [
424
+ {
425
+ id: "1",
426
+ type: "toggleListItem",
427
+ props: {
428
+ backgroundColor: "default",
429
+ textColor: "default",
430
+ textAlignment: "left",
431
+ },
432
+ content: [
433
+ {
434
+ type: "text",
435
+ text: "Toggle item",
436
+ styles: {},
437
+ },
438
+ ],
439
+ children: [
440
+ {
441
+ id: "2",
442
+ type: "paragraph",
443
+ props: {
444
+ backgroundColor: "default",
445
+ textColor: "default",
446
+ textAlignment: "left",
447
+ },
448
+ content: [
449
+ {
450
+ type: "text",
451
+ text: "Hidden content",
452
+ styles: {},
453
+ },
454
+ ],
455
+ children: [],
456
+ },
457
+ ],
458
+ },
459
+ ];
460
+ testConversion("toggle lists", blocks);
461
+ });
462
+
463
+ describe("Code blocks", () => {
464
+ const blocks: Block[] = [
465
+ {
466
+ id: "1",
467
+ type: "codeBlock",
468
+ props: {
469
+ language: "javascript",
470
+ },
471
+ content: [
472
+ {
473
+ type: "text",
474
+ text: 'console.log("Hello, world!");',
475
+ styles: {},
476
+ },
477
+ ],
478
+ children: [],
479
+ },
480
+ {
481
+ id: "2",
482
+ type: "codeBlock",
483
+ props: {
484
+ language: "typescript",
485
+ },
486
+ content: [
487
+ {
488
+ type: "text",
489
+ text: "const x: number = 42;",
490
+ styles: {},
491
+ },
492
+ ],
493
+ children: [],
494
+ },
495
+ ];
496
+ testConversion("code blocks", blocks);
497
+ });
498
+
499
+ describe("Quotes", () => {
500
+ const blocks: Block[] = [
501
+ {
502
+ id: "1",
503
+ type: "quote",
504
+ props: {
505
+ backgroundColor: "default",
506
+ textColor: "default",
507
+ },
508
+ content: [
509
+ {
510
+ type: "text",
511
+ text: "This is a quote",
512
+ styles: {
513
+ italic: true,
514
+ },
515
+ },
516
+ ],
517
+ children: [
518
+ {
519
+ id: "2",
520
+ type: "paragraph",
521
+ props: {
522
+ backgroundColor: "default",
523
+ textColor: "default",
524
+ textAlignment: "left",
525
+ },
526
+ content: [
527
+ {
528
+ type: "text",
529
+ text: "Nested in quote",
530
+ styles: {},
531
+ },
532
+ ],
533
+ children: [],
534
+ },
535
+ ],
536
+ },
537
+ ];
538
+ testConversion("quotes", blocks);
539
+ });
540
+
541
+ describe("Headings with different levels", () => {
542
+ const blocks: Block[] = [
543
+ {
544
+ id: "1",
545
+ type: "heading",
546
+ props: {
547
+ backgroundColor: "default",
548
+ textColor: "default",
549
+ textAlignment: "left",
550
+ level: 1,
551
+ isToggleable: false,
552
+ },
553
+ content: [
554
+ {
555
+ type: "text",
556
+ text: "Heading 1",
557
+ styles: {},
558
+ },
559
+ ],
560
+ children: [],
561
+ },
562
+ {
563
+ id: "2",
564
+ type: "heading",
565
+ props: {
566
+ backgroundColor: "default",
567
+ textColor: "default",
568
+ textAlignment: "left",
569
+ level: 2,
570
+ isToggleable: false,
571
+ },
572
+ content: [
573
+ {
574
+ type: "text",
575
+ text: "Heading 2",
576
+ styles: {},
577
+ },
578
+ ],
579
+ children: [],
580
+ },
581
+ {
582
+ id: "3",
583
+ type: "heading",
584
+ props: {
585
+ backgroundColor: "default",
586
+ textColor: "default",
587
+ textAlignment: "left",
588
+ level: 3,
589
+ isToggleable: true,
590
+ },
591
+ content: [
592
+ {
593
+ type: "text",
594
+ text: "Toggle Heading 3",
595
+ styles: {},
596
+ },
597
+ ],
598
+ children: [
599
+ {
600
+ id: "4",
601
+ type: "paragraph",
602
+ props: {
603
+ backgroundColor: "default",
604
+ textColor: "default",
605
+ textAlignment: "left",
606
+ },
607
+ content: [
608
+ {
609
+ type: "text",
610
+ text: "Content under toggle heading",
611
+ styles: {},
612
+ },
613
+ ],
614
+ children: [],
615
+ },
616
+ ],
617
+ },
618
+ ];
619
+ testConversion("headings with different levels", blocks);
620
+ });
621
+
622
+ describe("Inline styles and links", () => {
623
+ const blocks: Block[] = [
624
+ {
625
+ id: "1",
626
+ type: "paragraph",
627
+ props: {
628
+ backgroundColor: "default",
629
+ textColor: "default",
630
+ textAlignment: "left",
631
+ },
632
+ content: [
633
+ {
634
+ type: "text",
635
+ text: "Bold ",
636
+ styles: {
637
+ bold: true,
638
+ },
639
+ },
640
+ {
641
+ type: "text",
642
+ text: "italic ",
643
+ styles: {
644
+ italic: true,
645
+ },
646
+ },
647
+ {
648
+ type: "text",
649
+ text: "underline ",
650
+ styles: {
651
+ underline: true,
652
+ },
653
+ },
654
+ {
655
+ type: "text",
656
+ text: "strikethrough ",
657
+ styles: {
658
+ strike: true,
659
+ },
660
+ },
661
+ {
662
+ type: "text",
663
+ text: "code",
664
+ styles: {
665
+ code: true,
666
+ },
667
+ },
668
+ ],
669
+ children: [],
670
+ },
671
+ {
672
+ id: "2",
673
+ type: "paragraph",
674
+ props: {
675
+ backgroundColor: "default",
676
+ textColor: "default",
677
+ textAlignment: "left",
678
+ },
679
+ content: [
680
+ {
681
+ type: "link",
682
+ href: "https://example.com",
683
+ content: [
684
+ {
685
+ type: "text",
686
+ text: "Link text",
687
+ styles: {},
688
+ },
689
+ ],
690
+ },
691
+ ],
692
+ children: [],
693
+ },
694
+ ];
695
+ testConversion("inline styles and links", blocks);
696
+ });
697
+
698
+ describe("Tables", () => {
699
+ const blocks = [
700
+ {
701
+ id: "1",
702
+ type: "table",
703
+ props: {
704
+ textColor: "default",
705
+ },
706
+ content: {
707
+ type: "tableContent",
708
+ columnWidths: [100, 100, 100],
709
+ headerRows: 1,
710
+ headerCols: undefined,
711
+ rows: [
712
+ {
713
+ cells: [
714
+ {
715
+ type: "tableCell",
716
+ props: {
717
+ backgroundColor: "default",
718
+ textColor: "default",
719
+ textAlignment: "left",
720
+ colspan: 1,
721
+ rowspan: 1,
722
+ },
723
+ content: [
724
+ {
725
+ type: "text",
726
+ text: "Header 1",
727
+ styles: {
728
+ bold: true,
729
+ },
730
+ },
731
+ ],
732
+ },
733
+ {
734
+ type: "tableCell",
735
+ props: {
736
+ backgroundColor: "default",
737
+ textColor: "default",
738
+ textAlignment: "left",
739
+ colspan: 1,
740
+ rowspan: 1,
741
+ },
742
+ content: [
743
+ {
744
+ type: "text",
745
+ text: "Header 2",
746
+ styles: {
747
+ bold: true,
748
+ },
749
+ },
750
+ ],
751
+ },
752
+ {
753
+ type: "tableCell",
754
+ props: {
755
+ backgroundColor: "default",
756
+ textColor: "default",
757
+ textAlignment: "left",
758
+ colspan: 1,
759
+ rowspan: 1,
760
+ },
761
+ content: [
762
+ {
763
+ type: "text",
764
+ text: "Header 3",
765
+ styles: {
766
+ bold: true,
767
+ },
768
+ },
769
+ ],
770
+ },
771
+ ],
772
+ },
773
+ {
774
+ cells: [
775
+ {
776
+ type: "tableCell",
777
+ props: {
778
+ backgroundColor: "default",
779
+ textColor: "default",
780
+ textAlignment: "left",
781
+ colspan: 1,
782
+ rowspan: 1,
783
+ },
784
+ content: [
785
+ {
786
+ type: "text",
787
+ text: "Cell 1",
788
+ styles: {},
789
+ },
790
+ ],
791
+ },
792
+ {
793
+ type: "tableCell",
794
+ props: {
795
+ backgroundColor: "default",
796
+ textColor: "default",
797
+ textAlignment: "left",
798
+ colspan: 1,
799
+ rowspan: 1,
800
+ },
801
+ content: [
802
+ {
803
+ type: "text",
804
+ text: "Cell 2",
805
+ styles: {},
806
+ },
807
+ ],
808
+ },
809
+ {
810
+ type: "tableCell",
811
+ props: {
812
+ backgroundColor: "default",
813
+ textColor: "default",
814
+ textAlignment: "left",
815
+ colspan: 1,
816
+ rowspan: 1,
817
+ },
818
+ content: [
819
+ {
820
+ type: "text",
821
+ text: "Cell 3",
822
+ styles: {},
823
+ },
824
+ ],
825
+ },
826
+ ],
827
+ },
828
+ ],
829
+ },
830
+ children: [],
831
+ },
832
+ ] as unknown as Block[];
833
+ testConversion("tables", blocks);
834
+ });
835
+
836
+ describe("Divider", () => {
837
+ const blocks = [
838
+ {
839
+ id: "1",
840
+ type: "paragraph",
841
+ props: {
842
+ backgroundColor: "default",
843
+ textColor: "default",
844
+ textAlignment: "left",
845
+ },
846
+ content: [
847
+ {
848
+ type: "text",
849
+ text: "Before divider",
850
+ styles: {},
851
+ },
852
+ ],
853
+ children: [],
854
+ },
855
+ {
856
+ id: "2",
857
+ type: "divider",
858
+ props: {},
859
+ content: undefined,
860
+ children: [],
861
+ },
862
+ {
863
+ id: "3",
864
+ type: "paragraph",
865
+ props: {
866
+ backgroundColor: "default",
867
+ textColor: "default",
868
+ textAlignment: "left",
869
+ },
870
+ content: [
871
+ {
872
+ type: "text",
873
+ text: "After divider",
874
+ styles: {},
875
+ },
876
+ ],
877
+ children: [],
878
+ },
879
+ ] as unknown as Block[];
880
+ testConversion("divider", blocks);
881
+ });
882
+
883
+ describe("Complex mixed document", () => {
884
+ const blocks: Block[] = [
885
+ {
886
+ id: "1",
887
+ type: "heading",
888
+ props: {
889
+ backgroundColor: "blue",
890
+ textColor: "yellow",
891
+ textAlignment: "center",
892
+ level: 1,
893
+ isToggleable: false,
894
+ },
895
+ content: [
896
+ {
897
+ type: "text",
898
+ text: "Main Title",
899
+ styles: {
900
+ bold: true,
901
+ },
902
+ },
903
+ ],
904
+ children: [],
905
+ },
906
+ {
907
+ id: "2",
908
+ type: "paragraph",
909
+ props: {
910
+ backgroundColor: "red",
911
+ textColor: "default",
912
+ textAlignment: "right",
913
+ },
914
+ content: [
915
+ {
916
+ type: "text",
917
+ text: "This is a paragraph with ",
918
+ styles: {},
919
+ },
920
+ {
921
+ type: "text",
922
+ text: "mixed",
923
+ styles: {
924
+ bold: true,
925
+ italic: true,
926
+ },
927
+ },
928
+ {
929
+ type: "text",
930
+ text: " styles and a ",
931
+ styles: {},
932
+ },
933
+ {
934
+ type: "link",
935
+ href: "https://example.com",
936
+ content: [
937
+ {
938
+ type: "text",
939
+ text: "link",
940
+ styles: {},
941
+ },
942
+ ],
943
+ },
944
+ {
945
+ type: "text",
946
+ text: ".",
947
+ styles: {},
948
+ },
949
+ ],
950
+ children: [
951
+ {
952
+ id: "3",
953
+ type: "bulletListItem",
954
+ props: {
955
+ backgroundColor: "default",
956
+ textColor: "default",
957
+ textAlignment: "left",
958
+ },
959
+ content: [
960
+ {
961
+ type: "text",
962
+ text: "Nested list item",
963
+ styles: {},
964
+ },
965
+ ],
966
+ children: [],
967
+ },
968
+ ],
969
+ },
970
+ {
971
+ id: "4",
972
+ type: "quote",
973
+ props: {
974
+ backgroundColor: "default",
975
+ textColor: "default",
976
+ },
977
+ content: [
978
+ {
979
+ type: "text",
980
+ text: "Important quote",
981
+ styles: {
982
+ italic: true,
983
+ },
984
+ },
985
+ ],
986
+ children: [],
987
+ },
988
+ {
989
+ id: "5",
990
+ type: "codeBlock",
991
+ props: {
992
+ language: "typescript",
993
+ },
994
+ content: [
995
+ {
996
+ type: "text",
997
+ text: "const example = () => {\n return 'code';\n};",
998
+ styles: {},
999
+ },
1000
+ ],
1001
+ children: [],
1002
+ },
1003
+ {
1004
+ id: "6",
1005
+ type: "checkListItem",
1006
+ props: {
1007
+ backgroundColor: "default",
1008
+ textColor: "default",
1009
+ textAlignment: "left",
1010
+ checked: true,
1011
+ },
1012
+ content: [
1013
+ {
1014
+ type: "text",
1015
+ text: "Completed checklist item",
1016
+ styles: {},
1017
+ },
1018
+ ],
1019
+ children: [],
1020
+ },
1021
+ {
1022
+ id: "7",
1023
+ type: "checkListItem",
1024
+ props: {
1025
+ backgroundColor: "default",
1026
+ textColor: "default",
1027
+ textAlignment: "left",
1028
+ checked: false,
1029
+ },
1030
+ content: [
1031
+ {
1032
+ type: "text",
1033
+ text: "Pending checklist item",
1034
+ styles: {},
1035
+ },
1036
+ ],
1037
+ children: [],
1038
+ },
1039
+ ];
1040
+ testConversion("complex mixed document", blocks);
1041
+ });
1042
+ });