@blocknote/core 0.51.4 → 0.52.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (396) 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-DGsP5WKr.js → blocks-CiuUGa1E.js} +1093 -994
  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-Co4y7P63.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-Bcud0PIg.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 +9 -6
  101. package/src/blocks/Table/TableExtension.ts +20 -6
  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 +21 -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/extensions.d.ts +2 -2
  271. package/types/src/editor/managers/ExtensionManager/index.d.ts +13 -0
  272. package/types/src/editor/managers/SelectionManager.d.ts +1 -1
  273. package/types/src/extensions/PositionMapping/PositionMapping.d.ts +4 -0
  274. package/types/src/extensions/TableHandles/TableHandles.d.ts +6 -6
  275. package/types/src/extensions/Versioning/Versioning.d.ts +352 -0
  276. package/types/src/extensions/Versioning/Versioning.test.d.ts +1 -0
  277. package/types/src/extensions/Versioning/inMemoryVersioning.d.ts +37 -0
  278. package/types/src/extensions/Versioning/inMemoryVersioning.test.d.ts +1 -0
  279. package/types/src/extensions/Versioning/index.d.ts +2 -0
  280. package/types/src/extensions/index.d.ts +6 -9
  281. package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.d.ts +1 -0
  282. package/types/src/extensions/tiptap-extensions/UniqueID/UniqueID.d.ts +6 -1
  283. package/types/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.d.ts +4 -0
  284. package/types/src/extensions/tiptap-extensions/index.d.ts +1 -5
  285. package/types/src/i18n/locales/en.d.ts +9 -1
  286. package/types/src/i18n/locales/fa.d.ts +9 -1
  287. package/types/src/i18n/locales/sk.d.ts +9 -1
  288. package/types/src/index.d.ts +2 -0
  289. package/types/src/pm-nodes/suggestionMarks.d.ts +26 -0
  290. package/types/src/schema/blocks/createSpec.d.ts +4 -4
  291. package/types/src/schema/blocks/createSpec.test.d.ts +1 -0
  292. package/types/src/schema/blocks/extendBlockSpec.test.d.ts +1 -0
  293. package/types/src/schema/blocks/internal.d.ts +5 -7
  294. package/types/src/schema/blocks/types.d.ts +22 -14
  295. package/types/src/schema/contentTypePropagation.test.d.ts +1 -0
  296. package/types/src/schema/index.d.ts +1 -0
  297. package/types/src/schema/inlineContent/types.d.ts +3 -3
  298. package/types/src/schema/markGroups.d.ts +33 -0
  299. package/types/src/user/UserStore.d.ts +105 -0
  300. package/types/src/user/createUserStore.test.d.ts +1 -0
  301. package/types/src/user/index.d.ts +2 -0
  302. package/types/src/user/userColors.d.ts +36 -0
  303. package/types/src/y/comments/RESTYjsThreadStore.d.ts +77 -0
  304. package/types/src/y/comments/YjsThreadStore.d.ts +79 -0
  305. package/types/src/y/comments/YjsThreadStore.test.d.ts +1 -0
  306. package/types/src/y/comments/YjsThreadStoreBase.d.ts +15 -0
  307. package/types/src/y/comments/index.d.ts +3 -0
  308. package/types/src/y/comments/yjsHelpers.d.ts +13 -0
  309. package/types/src/y/extensions/AttributionExtension.d.ts +74 -0
  310. package/types/src/y/extensions/AttributionExtension.test.d.ts +1 -0
  311. package/types/src/y/extensions/DiffVersioningExtension.d.ts +69 -0
  312. package/types/src/y/extensions/DiffVersioningExtension.test.d.ts +1 -0
  313. package/types/src/{extensions/Collaboration → y/extensions}/ForkYDoc.d.ts +4 -2
  314. package/types/src/y/extensions/ForkYDoc.test.d.ts +1 -0
  315. package/types/src/y/extensions/RelativePositionMapping.d.ts +4 -0
  316. package/types/src/y/extensions/RelativePositionMapping.test.d.ts +1 -0
  317. package/types/src/y/extensions/Suggestions.d.ts +36 -0
  318. package/types/src/y/extensions/Versioning.d.ts +17 -0
  319. package/types/src/y/extensions/Versioning.test.d.ts +1 -0
  320. package/types/src/y/extensions/YAttributionMarks.d.ts +67 -0
  321. package/types/src/y/extensions/YCursorPlugin.d.ts +14 -0
  322. package/types/src/y/extensions/YSync.d.ts +32 -0
  323. package/types/src/y/extensions/blockMatchNodes.d.ts +25 -0
  324. package/types/src/y/extensions/index.d.ts +189 -0
  325. package/types/src/y/index.d.ts +4 -0
  326. package/types/src/y/utils.d.ts +82 -0
  327. package/types/src/y/utils.test.d.ts +1 -0
  328. package/types/src/y/versioning/__test__/yhub.test.d.ts +1 -0
  329. package/types/src/y/versioning/index.d.ts +1 -0
  330. package/types/src/y/versioning/yhub.d.ts +87 -0
  331. package/types/src/{comments/threadstore/yjs → yjs/comments}/RESTYjsThreadStore.d.ts +6 -10
  332. package/types/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStore.d.ts +3 -3
  333. package/types/src/yjs/comments/YjsThreadStore.test.d.ts +1 -0
  334. package/types/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStoreBase.d.ts +3 -3
  335. package/types/src/yjs/comments/index.d.ts +3 -0
  336. package/types/src/{comments/threadstore/yjs → yjs/comments}/yjsHelpers.d.ts +1 -1
  337. package/types/src/yjs/extensions/FixUpSchema.d.ts +3 -0
  338. package/types/src/yjs/extensions/FixUpSchema.test.d.ts +1 -0
  339. package/types/src/yjs/extensions/ForkYDoc.d.ts +27 -0
  340. package/types/src/yjs/extensions/ForkYDoc.test.d.ts +1 -0
  341. package/types/src/yjs/extensions/RelativePositionMapping.d.ts +4 -0
  342. package/types/src/yjs/extensions/RelativePositionMapping.test.d.ts +1 -0
  343. package/types/src/yjs/extensions/Versioning.d.ts +26 -0
  344. package/types/src/yjs/extensions/Versioning.test.d.ts +1 -0
  345. package/types/src/{extensions/Collaboration → yjs/extensions}/YCursorPlugin.d.ts +5 -2
  346. package/types/src/{extensions/Collaboration → yjs/extensions}/YSync.d.ts +1 -1
  347. package/types/src/{extensions/Collaboration/Collaboration.d.ts → yjs/extensions/index.d.ts} +36 -15
  348. package/types/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.test.d.ts +1 -0
  349. package/types/src/yjs/index.d.ts +2 -0
  350. package/types/src/yjs/utils.d.ts +5 -0
  351. package/dist/BlockNoteExtension-B6RhuQ3V.js +0 -27
  352. package/dist/BlockNoteExtension-B6RhuQ3V.js.map +0 -1
  353. package/dist/BlockNoteExtension-ab0REuob.cjs +0 -2
  354. package/dist/BlockNoteExtension-ab0REuob.cjs.map +0 -1
  355. package/dist/EventEmitter-CuPnGDYt.js +0 -22
  356. package/dist/EventEmitter-CuPnGDYt.js.map +0 -1
  357. package/dist/EventEmitter-DHdSnYCD.cjs +0 -2
  358. package/dist/EventEmitter-DHdSnYCD.cjs.map +0 -1
  359. package/dist/ShowSelection-BsHFfdMi.js +0 -29
  360. package/dist/ShowSelection-BsHFfdMi.js.map +0 -1
  361. package/dist/ShowSelection-DhXglbt8.cjs +0 -2
  362. package/dist/ShowSelection-DhXglbt8.cjs.map +0 -1
  363. package/dist/blocks-Bm6IfL1R.cjs +0 -11
  364. package/dist/blocks-Bm6IfL1R.cjs.map +0 -1
  365. package/dist/blocks-DGsP5WKr.js.map +0 -1
  366. package/dist/en-B9hMApn4.js.map +0 -1
  367. package/dist/en-Cj5r8sW_.cjs.map +0 -1
  368. package/dist/extensions-Co4y7P63.js.map +0 -1
  369. package/dist/extensions-IJK3t0sz.cjs +0 -52
  370. package/dist/extensions-IJK3t0sz.cjs.map +0 -1
  371. package/dist/src-B6rlChSc.cjs +0 -21
  372. package/dist/src-B6rlChSc.cjs.map +0 -1
  373. package/dist/src-Bcud0PIg.js.map +0 -1
  374. package/src/comments/userstore/UserStore.ts +0 -72
  375. package/src/extensions/Collaboration/Collaboration.ts +0 -55
  376. package/src/extensions/Collaboration/ForkYDoc.test.ts +0 -179
  377. package/src/extensions/tiptap-extensions/Suggestions/SuggestionMarks.ts +0 -175
  378. package/types/src/comments/userstore/UserStore.d.ts +0 -31
  379. package/types/src/extensions/tiptap-extensions/Suggestions/SuggestionMarks.d.ts +0 -4
  380. /package/src/{extensions/Collaboration → yjs/extensions}/YUndo.ts +0 -0
  381. /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap-editor-forked.json +0 -0
  382. /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap-editor.json +0 -0
  383. /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap-forked.html +0 -0
  384. /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap.html +0 -0
  385. /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/SchemaMigration.ts +0 -0
  386. /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/index.ts +0 -0
  387. /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/migrationRule.ts +0 -0
  388. /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/moveColorAttributes.ts +0 -0
  389. /package/types/src/{comments/threadstore/yjs/YjsThreadStore.test.d.ts → api/getBlockInfoFromPos.test.d.ts} +0 -0
  390. /package/types/src/{extensions/Collaboration/ForkYDoc.test.d.ts → api/nodeConversions/blockToNode.test.d.ts} +0 -0
  391. /package/types/src/{extensions/Collaboration/schemaMigration/migrationRules/moveColorAttributes.test.d.ts → editor/managers/ExtensionManager/ExtensionManager.test.d.ts} +0 -0
  392. /package/types/src/{extensions/Collaboration → yjs/extensions}/YUndo.d.ts +0 -0
  393. /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/SchemaMigration.d.ts +0 -0
  394. /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/index.d.ts +0 -0
  395. /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/migrationRule.d.ts +0 -0
  396. /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/moveColorAttributes.d.ts +0 -0
@@ -1,4 +1,4 @@
1
- import { afterEach, describe, expect, it } from "vitest";
1
+ import { afterEach, describe, expect, it } from "vite-plus/test";
2
2
  import { TextSelection } from "@tiptap/pm/state";
3
3
  import { Slice, Fragment } from "@tiptap/pm/model";
4
4
 
@@ -26,7 +26,7 @@ function tokenizeToObjects(text: string, defaultProtocol = "http") {
26
26
  * - A link token wrapped in () or []
27
27
  */
28
28
  function isValidLinkStructure(
29
- tokens: Array<{ isLink: boolean; value: string }>
29
+ tokens: Array<{ isLink: boolean; value: string }>,
30
30
  ) {
31
31
  if (tokens.length === 1) {
32
32
  return tokens[0].isLink;
@@ -51,7 +51,7 @@ function createEditor(links?: { isValidLink?: (href: string) => boolean }) {
51
51
  function typeTextThenSpace(
52
52
  editor: BlockNoteEditor<any, any, any>,
53
53
  blockId: string,
54
- text: string
54
+ text: string,
55
55
  ) {
56
56
  editor.setTextCursorPosition(blockId, "end");
57
57
  const view = editor._tiptapEditor.view;
@@ -252,13 +252,9 @@ describe("findLinks() baseline behavior", () => {
252
252
  });
253
253
 
254
254
  it("keeps balanced parentheses in path (Wikipedia-style)", () => {
255
- const results = findLinks(
256
- "https://en.wikipedia.org/wiki/Foo_(bar)"
257
- );
255
+ const results = findLinks("https://en.wikipedia.org/wiki/Foo_(bar)");
258
256
  expect(results).toHaveLength(1);
259
- expect(results[0].value).toBe(
260
- "https://en.wikipedia.org/wiki/Foo_(bar)"
261
- );
257
+ expect(results[0].value).toBe("https://en.wikipedia.org/wiki/Foo_(bar)");
262
258
  });
263
259
  });
264
260
 
@@ -601,7 +597,11 @@ describe("Link extension autolink behavior", () => {
601
597
  describe("should autolink", () => {
602
598
  it("autolinks https URL when followed by space", () => {
603
599
  setupEditorWithBlock();
604
- const links = typeTextThenSpace(editor, "test-block", "https://example.com");
600
+ const links = typeTextThenSpace(
601
+ editor,
602
+ "test-block",
603
+ "https://example.com",
604
+ );
605
605
  expect(links).toHaveLength(1);
606
606
  expect(links[0].href).toBe("https://example.com");
607
607
  expect(links[0].text).toBe("https://example.com");
@@ -609,7 +609,11 @@ describe("Link extension autolink behavior", () => {
609
609
 
610
610
  it("autolinks http URL when followed by space", () => {
611
611
  setupEditorWithBlock();
612
- const links = typeTextThenSpace(editor, "test-block", "http://example.com");
612
+ const links = typeTextThenSpace(
613
+ editor,
614
+ "test-block",
615
+ "http://example.com",
616
+ );
613
617
  expect(links).toHaveLength(1);
614
618
  expect(links[0].href).toBe("http://example.com");
615
619
  });
@@ -635,7 +639,7 @@ describe("Link extension autolink behavior", () => {
635
639
  const links = typeTextThenSpace(
636
640
  editor,
637
641
  "test-block",
638
- "https://example.com/path?q=1"
642
+ "https://example.com/path?q=1",
639
643
  );
640
644
  expect(links).toHaveLength(1);
641
645
  expect(links[0].href).toBe("https://example.com/path?q=1");
@@ -680,7 +684,7 @@ describe("Link extension autolink behavior", () => {
680
684
  const links = typeTextThenSpace(
681
685
  editor,
682
686
  "test-block",
683
- "(https://example.com)"
687
+ "(https://example.com)",
684
688
  );
685
689
  expect(links).toHaveLength(1);
686
690
  expect(links[0].href).toBe("https://example.com");
@@ -692,7 +696,7 @@ describe("Link extension autolink behavior", () => {
692
696
  const links = typeTextThenSpace(
693
697
  editor,
694
698
  "test-block",
695
- "[https://example.com]"
699
+ "[https://example.com]",
696
700
  );
697
701
  expect(links).toHaveLength(1);
698
702
  expect(links[0].href).toBe("https://example.com");
@@ -737,7 +741,7 @@ describe("Link extension paste handler behavior", () => {
737
741
 
738
742
  // Create selection over the text
739
743
  const tr = view.state.tr.setSelection(
740
- TextSelection.create(view.state.doc, textStart, textEnd)
744
+ TextSelection.create(view.state.doc, textStart, textEnd),
741
745
  );
742
746
  view.dispatch(tr);
743
747
 
@@ -747,7 +751,7 @@ describe("Link extension paste handler behavior", () => {
747
751
 
748
752
  // Dispatch paste through the editor view
749
753
  const handled = view.someProp("handlePaste", (f) =>
750
- f(view, new ClipboardEvent("paste"), slice)
754
+ f(view, new ClipboardEvent("paste"), slice),
751
755
  );
752
756
 
753
757
  expect(handled).toBeTruthy();
@@ -782,7 +786,7 @@ describe("Link extension paste handler behavior", () => {
782
786
  });
783
787
 
784
788
  const tr = view.state.tr.setSelection(
785
- TextSelection.create(view.state.doc, textStart, textEnd)
789
+ TextSelection.create(view.state.doc, textStart, textEnd),
786
790
  );
787
791
  view.dispatch(tr);
788
792
 
@@ -790,7 +794,7 @@ describe("Link extension paste handler behavior", () => {
790
794
  const slice = new Slice(Fragment.from(textNode), 0, 0);
791
795
 
792
796
  const handled = view.someProp("handlePaste", (f) =>
793
- f(view, new ClipboardEvent("paste"), slice)
797
+ f(view, new ClipboardEvent("paste"), slice),
794
798
  );
795
799
 
796
800
  // Should not be handled (not a URL)
@@ -819,7 +823,7 @@ describe("Link extension paste handler behavior", () => {
819
823
  const slice = new Slice(Fragment.from(textNode), 0, 0);
820
824
 
821
825
  const handled = view.someProp("handlePaste", (f) =>
822
- f(view, new ClipboardEvent("paste"), slice)
826
+ f(view, new ClipboardEvent("paste"), slice),
823
827
  );
824
828
 
825
829
  // Should not be handled because selection is empty
@@ -849,7 +853,7 @@ describe("Link extension isValidLink option", () => {
849
853
  const links = typeTextThenSpace(
850
854
  editor,
851
855
  "test-block",
852
- "https://example.com"
856
+ "https://example.com",
853
857
  );
854
858
  expect(links).toHaveLength(0);
855
859
  });
@@ -894,7 +898,7 @@ describe("Link extension isValidLink option", () => {
894
898
  });
895
899
 
896
900
  const tr = view.state.tr.setSelection(
897
- TextSelection.create(view.state.doc, textStart, textEnd)
901
+ TextSelection.create(view.state.doc, textStart, textEnd),
898
902
  );
899
903
  view.dispatch(tr);
900
904
 
@@ -902,7 +906,7 @@ describe("Link extension isValidLink option", () => {
902
906
  const slice = new Slice(Fragment.from(textNode), 0, 0);
903
907
 
904
908
  const handled = view.someProp("handlePaste", (f) =>
905
- f(view, new ClipboardEvent("paste"), slice)
909
+ f(view, new ClipboardEvent("paste"), slice),
906
910
  );
907
911
 
908
912
  expect(handled).toBeFalsy();
@@ -0,0 +1,187 @@
1
+ /**
2
+ * @vitest-environment jsdom
3
+ */
4
+
5
+ import { Node } from "prosemirror-model";
6
+ import { afterEach, beforeAll, describe, expect, it } from "vite-plus/test";
7
+
8
+ import { BlockNoteEditor } from "../../../editor/BlockNoteEditor.js";
9
+ import { YAttributionMarksExtension } from "../../../y/extensions/YAttributionMarks.js";
10
+
11
+ // Track editors created in each test so we can unmount them in afterEach —
12
+ // otherwise prosemirror-view's DOMObserver leaves a setTimeout alive that
13
+ // fires after vitest tears down jsdom, throwing
14
+ // `ReferenceError: document is not defined` and failing the run.
15
+ const activeEditors: BlockNoteEditor<any, any, any>[] = [];
16
+
17
+ afterEach(() => {
18
+ while (activeEditors.length) {
19
+ activeEditors.pop()!.unmount();
20
+ }
21
+ });
22
+
23
+ /**
24
+ * The UniqueID extension's `appendTransaction` hook assigns a fresh id to any
25
+ * newly-inserted node whose id duplicates an existing one. The one exception is
26
+ * suggested-deletion nodes (carrying a `y-attributed-delete` mark): in
27
+ * suggestion mode, Yjs keeps the deleted node in the document with the SAME id
28
+ * as the surviving node, and rewriting that id would corrupt the suggestion.
29
+ * These tests exercise both branches.
30
+ */
31
+
32
+ function createEditor() {
33
+ // The suggested-deletion cases mark nodes with `y-attributed-delete`, which
34
+ // only exists in the schema when the suggestion-marks bundle is loaded.
35
+ const editor = BlockNoteEditor.create({
36
+ extensions: [YAttributionMarksExtension()],
37
+ });
38
+ editor.mount(document.createElement("div"));
39
+ activeEditors.push(editor);
40
+ editor.replaceBlocks(editor.document, [
41
+ { id: "block-a", type: "paragraph", content: "A" },
42
+ { id: "block-b", type: "paragraph", content: "B" },
43
+ ]);
44
+ return editor;
45
+ }
46
+
47
+ /**
48
+ * Builds a `blockContainer` node holding a single paragraph with the given
49
+ * block `id`, optionally carrying a `y-attributed-delete` mark to simulate a
50
+ * suggested deletion.
51
+ */
52
+ function makeBlockContainer(
53
+ editor: BlockNoteEditor,
54
+ id: string,
55
+ text: string,
56
+ suggestedDelete: boolean,
57
+ ) {
58
+ const schema = editor.pmSchema;
59
+ const paragraph = schema.nodes["paragraph"].createChecked(
60
+ {},
61
+ schema.text(text),
62
+ );
63
+ const marks = suggestedDelete
64
+ ? [schema.marks["y-attributed-delete"].create({ id: 1 })]
65
+ : undefined;
66
+
67
+ return schema.nodes["blockContainer"].createChecked({ id }, paragraph, marks);
68
+ }
69
+
70
+ /** Returns the ids of all blockContainer nodes in document order. */
71
+ function getBlockIds(doc: Node) {
72
+ const ids: (string | null)[] = [];
73
+ doc.descendants((node) => {
74
+ if (node.type.name === "blockContainer") {
75
+ ids.push(node.attrs.id);
76
+ }
77
+ return true;
78
+ });
79
+ return ids;
80
+ }
81
+
82
+ describe("UniqueID: duplicate id handling", () => {
83
+ let editor: BlockNoteEditor;
84
+
85
+ beforeAll(() => {
86
+ // Reset the mock id counter so generated ids are deterministic.
87
+ (window as any).__TEST_OPTIONS = {};
88
+ });
89
+
90
+ it("assigns a fresh id to a newly-inserted plain block that duplicates another new block", () => {
91
+ editor = createEditor();
92
+ const view = editor._tiptapEditor.view;
93
+
94
+ // Insert TWO new blocks sharing the same id "dup" in a single transaction.
95
+ // Both land in the same changed range, so UniqueID detects the duplicate
96
+ // and rewrites one of them with a fresh generated id.
97
+ const dup1 = makeBlockContainer(editor, "dup", "Dup 1", false);
98
+ const dup2 = makeBlockContainer(editor, "dup", "Dup 2", false);
99
+
100
+ // Position at the boundary between the first block and the second block
101
+ // inside the blockGroup.
102
+ const firstBlock = view.state.doc.firstChild!.firstChild!;
103
+ const insertPos = firstBlock.nodeSize + 1;
104
+
105
+ view.dispatch(view.state.tr.insert(insertPos, [dup1, dup2]));
106
+
107
+ const ids = getBlockIds(view.state.doc);
108
+
109
+ // Four blocks now exist, and UniqueID has resolved the duplicate so that
110
+ // all ids are distinct and non-null.
111
+ expect(ids).toHaveLength(4);
112
+ expect(ids.every((id) => id !== null)).toBe(true);
113
+ expect(new Set(ids).size).toBe(4);
114
+ });
115
+
116
+ it("preserves the duplicate id of a suggested-deletion block while still rewriting the plain duplicate", () => {
117
+ editor = createEditor();
118
+ const view = editor._tiptapEditor.view;
119
+
120
+ // Insert two new blocks sharing the id "dup" in a single transaction: a
121
+ // plain (live) one and a suggested-deletion one (y-attributed-delete mark).
122
+ // The plain block's id is rewritten, but the suggested-deletion block MUST
123
+ // keep its "dup" id, because in suggestion mode it intentionally shares the
124
+ // id with the surviving node.
125
+ const liveDup = makeBlockContainer(editor, "dup", "Live dup", false);
126
+ const deletedDup = makeBlockContainer(editor, "dup", "Deleted dup", true);
127
+
128
+ const firstBlock = view.state.doc.firstChild!.firstChild!;
129
+ const insertPos = firstBlock.nodeSize + 1;
130
+
131
+ // Insert the live block first, then the suggested-deletion block after it.
132
+ view.dispatch(view.state.tr.insert(insertPos, [liveDup, deletedDup]));
133
+
134
+ const ids = getBlockIds(view.state.doc);
135
+
136
+ expect(ids).toHaveLength(4);
137
+ // The suggested-deletion block keeps "dup".
138
+ const dupCount = ids.filter((id) => id === "dup").length;
139
+ expect(dupCount).toBe(1);
140
+
141
+ // Confirm it is specifically the suggested-deletion node that kept "dup".
142
+ let suggestedDeletionId: string | null = null;
143
+ view.state.doc.descendants((node) => {
144
+ if (
145
+ node.type.name === "blockContainer" &&
146
+ node.marks.some((m) => m.type.name === "y-attributed-delete")
147
+ ) {
148
+ suggestedDeletionId = node.attrs.id;
149
+ }
150
+ return true;
151
+ });
152
+ expect(suggestedDeletionId).toBe("dup");
153
+ });
154
+
155
+ it("exposes distinct ids in editor.document even though two ProseMirror nodes share the same id", () => {
156
+ editor = createEditor();
157
+ const view = editor._tiptapEditor.view;
158
+
159
+ // Insert a suggested-deletion copy of the FIRST block, sharing its id
160
+ // "block-a". This mirrors suggestion mode: Yjs keeps the deleted node in
161
+ // the document with the same id as the surviving node, and UniqueID leaves
162
+ // that duplicate id untouched.
163
+ const deletedCopy = makeBlockContainer(
164
+ editor,
165
+ "block-a",
166
+ "A deleted copy",
167
+ true,
168
+ );
169
+
170
+ const firstBlock = view.state.doc.firstChild!.firstChild!;
171
+ const insertPos = firstBlock.nodeSize + 1;
172
+
173
+ view.dispatch(view.state.tr.insert(insertPos, deletedCopy));
174
+
175
+ // At the ProseMirror level, two nodes now share the id "block-a": the live
176
+ // one and the suggested-deletion one.
177
+ const pmIds = getBlockIds(view.state.doc);
178
+ expect(pmIds.filter((id) => id === "block-a")).toHaveLength(2);
179
+
180
+ // But editor.document disambiguates them via getNodeId: the suggested
181
+ // deletion node is reported as "block-a-1", so all block ids are distinct.
182
+ const docIds = editor.document.map((block) => block.id);
183
+ expect(docIds).toContain("block-a");
184
+ expect(docIds).toContain("block-a-1");
185
+ expect(new Set(docIds).size).toBe(docIds.length);
186
+ });
187
+ });
@@ -4,9 +4,10 @@ import {
4
4
  findChildrenInRange,
5
5
  getChangedRanges,
6
6
  } from "@tiptap/core";
7
- import { Fragment, Slice } from "prosemirror-model";
8
- import { Plugin, PluginKey } from "prosemirror-state";
9
7
  import { uuidv4 } from "lib0/random";
8
+ import { Fragment, Node, Slice } from "prosemirror-model";
9
+ import { Plugin, PluginKey } from "prosemirror-state";
10
+ import { isSuggestedDeletionNode } from "../../../api/getBlockInfoFromPos.js";
10
11
 
11
12
  /**
12
13
  * Code from Tiptap UniqueID extension (https://tiptap.dev/api/extensions/unique-id)
@@ -41,6 +42,20 @@ function findDuplicates(items: any) {
41
42
  return duplicates;
42
43
  }
43
44
 
45
+ /**
46
+ * Whether a node is marked as deleted by a suggestion (carries the
47
+ * `y-attributed-delete` node mark).
48
+ *
49
+ * Under the suggestion/matchNodes binding, changing a block's content type
50
+ * renders the block as a deleted copy (this mark) next to its inserted
51
+ * replacement - and both copies share the same `id`. The deleted copy must be
52
+ * ignored by the uniqueness logic, otherwise its `id` looks like a duplicate
53
+ * and we'd regenerate the `id` on the surviving block.
54
+ */
55
+ function isMarkedDeleted(node: Node) {
56
+ return node.marks.some((mark) => mark.type.name === "y-attributed-delete");
57
+ }
58
+
44
59
  const UniqueID = Extension.create({
45
60
  name: "uniqueID",
46
61
  // we’ll set a very high priority to make sure this runs first
@@ -48,8 +63,7 @@ const UniqueID = Extension.create({
48
63
  priority: 10000,
49
64
  addOptions() {
50
65
  return {
51
- attributeName: "id",
52
- types: [],
66
+ types: [] as string[],
53
67
  setIdAttribute: false,
54
68
  isWithinEditor: undefined as ((element: Element) => boolean) | undefined,
55
69
  generateID: () => {
@@ -67,7 +81,6 @@ const UniqueID = Extension.create({
67
81
 
68
82
  return uuidv4();
69
83
  },
70
- filterTransaction: null,
71
84
  };
72
85
  },
73
86
  addGlobalAttributes() {
@@ -75,19 +88,17 @@ const UniqueID = Extension.create({
75
88
  {
76
89
  types: this.options.types,
77
90
  attributes: {
78
- [this.options.attributeName]: {
91
+ id: {
79
92
  default: null,
80
- parseHTML: (element) =>
81
- element.getAttribute(`data-${this.options.attributeName}`),
93
+ parseHTML: (element) => element.getAttribute(`data-id`),
82
94
  renderHTML: (attributes) => {
83
95
  const defaultIdAttributes = {
84
- [`data-${this.options.attributeName}`]:
85
- attributes[this.options.attributeName],
96
+ [`data-id`]: attributes.id,
86
97
  };
87
98
  if (this.options.setIdAttribute) {
88
99
  return {
89
100
  ...defaultIdAttributes,
90
- id: attributes[this.options.attributeName],
101
+ id: attributes.id,
91
102
  };
92
103
  } else {
93
104
  return defaultIdAttributes;
@@ -139,14 +150,11 @@ const UniqueID = Extension.create({
139
150
  const docChanges =
140
151
  transactions.some((transaction) => transaction.docChanged) &&
141
152
  !oldState.doc.eq(newState.doc);
142
- const filterTransactions =
143
- this.options.filterTransaction &&
144
- transactions.some((tr) => !this.options.filterTransaction?.(tr));
145
- if (!docChanges || filterTransactions) {
153
+ if (!docChanges) {
146
154
  return;
147
155
  }
148
156
  const { tr } = newState;
149
- const { types, attributeName, generateID } = this.options;
157
+ const { types, generateID } = this.options;
150
158
  const transform = combineTransactionSteps(
151
159
  oldState.doc,
152
160
  transactions as any,
@@ -164,16 +172,20 @@ const UniqueID = Extension.create({
164
172
  },
165
173
  );
166
174
  const newIds = newNodes
167
- .map(({ node }) => node.attrs[attributeName])
175
+ .map(({ node }) => node.attrs.id)
168
176
  .filter((id) => id !== null);
169
177
  const duplicatedNewIds = findDuplicates(newIds);
170
178
 
171
179
  newNodes.forEach(({ node, pos }) => {
180
+ // ignore ids on blocks marked as deleted (see above).
181
+ if (isMarkedDeleted(node)) {
182
+ return;
183
+ }
172
184
  // instead of checking `node.attrs[attributeName]` directly
173
185
  // we look at the current state of the node within `tr.doc`.
174
186
  // this helps to prevent adding new ids to the same node
175
187
  // if the node changed multiple times within one transaction
176
- const id = tr.doc.nodeAt(pos)?.attrs[attributeName];
188
+ const id = tr.doc.nodeAt(pos)?.attrs.id;
177
189
 
178
190
  if (id === null) {
179
191
  // edge case, when using collaboration, yjs will set the id to null in `_forceRerender`
@@ -197,7 +209,7 @@ const UniqueID = Extension.create({
197
209
  // yes, apply the fix
198
210
  tr.setNodeMarkup(pos, undefined, {
199
211
  ...node.attrs,
200
- [attributeName]: "initialBlockId",
212
+ id: "initialBlockId",
201
213
  });
202
214
  return;
203
215
  }
@@ -205,17 +217,18 @@ const UniqueID = Extension.create({
205
217
 
206
218
  tr.setNodeMarkup(pos, undefined, {
207
219
  ...node.attrs,
208
- [attributeName]: generateID(),
220
+ id: generateID(),
209
221
  });
210
222
  return;
211
223
  }
212
224
  // check if the node doesn’t exist in the old state
213
225
  const { deleted } = mapping.invert().mapResult(pos);
214
226
  const newNode = deleted && duplicatedNewIds.includes(id);
215
- if (newNode) {
227
+ // purposefully skip rewriting ids for suggested deletion nodes, to avoid modifying them
228
+ if (newNode && !isSuggestedDeletionNode(node)) {
216
229
  tr.setNodeMarkup(pos, undefined, {
217
230
  ...node.attrs,
218
- [attributeName]: generateID(),
231
+ id: generateID(),
219
232
  });
220
233
  }
221
234
  });
@@ -279,7 +292,7 @@ const UniqueID = Extension.create({
279
292
  if (!transformPasted) {
280
293
  return slice;
281
294
  }
282
- const { types, attributeName } = this.options;
295
+ const { types } = this.options;
283
296
  const removeId = (fragment: any) => {
284
297
  const list: any[] = [];
285
298
  fragment.forEach((node: any) => {
@@ -297,7 +310,7 @@ const UniqueID = Extension.create({
297
310
  const nodeWithoutId = node.type.create(
298
311
  {
299
312
  ...node.attrs,
300
- [attributeName]: null,
313
+ id: null,
301
314
  },
302
315
  removeId(node.content),
303
316
  node.marks,
@@ -1,31 +1,7 @@
1
- import { BackgroundColorExtension } from "./BackgroundColor/BackgroundColorExtension.js";
2
- import { HardBreak } from "./HardBreak/HardBreak.js";
3
- import { KeyboardShortcutsExtension } from "./KeyboardShortcuts/KeyboardShortcutsExtension.js";
4
- import {
5
- SuggestionAddMark,
6
- SuggestionDeleteMark,
7
- SuggestionModificationMark,
8
- } from "./Suggestions/SuggestionMarks.js";
9
- import { TextAlignmentExtension } from "./TextAlignment/TextAlignmentExtension.js";
10
- import { TextColorExtension } from "./TextColor/TextColorExtension.js";
11
- import { UniqueID } from "./UniqueID/UniqueID.js";
12
-
13
1
  export * from "./BackgroundColor/BackgroundColorExtension.js";
14
2
  export * from "./HardBreak/HardBreak.js";
15
3
  export * from "./KeyboardShortcuts/KeyboardShortcutsExtension.js";
16
- export * from "./Suggestions/SuggestionMarks.js";
17
4
  export * from "./TextAlignment/TextAlignmentExtension.js";
18
5
  export * from "./TextColor/TextColorExtension.js";
19
6
  export * from "./UniqueID/UniqueID.js";
20
-
21
- export const DEFAULT_TIP_TAP_EXTENSIONS = [
22
- BackgroundColorExtension,
23
- HardBreak,
24
- KeyboardShortcutsExtension,
25
- SuggestionAddMark,
26
- SuggestionDeleteMark,
27
- SuggestionModificationMark,
28
- TextAlignmentExtension,
29
- TextColorExtension,
30
- UniqueID,
31
- ];
7
+ export * from "./Link/link.js";
@@ -370,6 +370,7 @@ export const ar: Dictionary = {
370
370
  save_button_text: "حفظ",
371
371
  cancel_button_text: "إلغاء",
372
372
  deleted_reference_text: "تم حذف المحتوى الأصلي",
373
+ discard_pending_comment: "هل أنت متأكد أنك تريد تجاهل هذا التعليق؟",
373
374
  actions: {
374
375
  add_reaction: "أضف تفاعلًا",
375
376
  resolve: "حل",
@@ -386,6 +387,14 @@ export const ar: Dictionary = {
386
387
  more_replies: (count) => `${count} ردود أخرى`,
387
388
  },
388
389
  },
390
+ suggestion_changes: {
391
+ formatting_change: "تغيير التنسيق",
392
+ deleted: "محذوف",
393
+ inserted_by: (users: string) => `أُدرج بواسطة: ${users}`,
394
+ deleted_by: (users: string) => `حُذف بواسطة: ${users}`,
395
+ formatting_change_by: (formats: string, users: string) =>
396
+ `تغيير التنسيق (${formats}) بواسطة: ${users}`,
397
+ },
389
398
  generic: {
390
399
  ctrl_shortcut: "Ctrl",
391
400
  },
@@ -404,6 +404,7 @@ export const de: Dictionary = {
404
404
  save_button_text: "Speichern",
405
405
  cancel_button_text: "Abbrechen",
406
406
  deleted_reference_text: "Originalinhalt gelöscht",
407
+ discard_pending_comment: "Möchten Sie diesen Kommentar wirklich verwerfen?",
407
408
  actions: {
408
409
  add_reaction: "Reaktion hinzufügen",
409
410
  resolve: "Lösen",
@@ -420,6 +421,14 @@ export const de: Dictionary = {
420
421
  more_replies: (count) => `${count} weitere Antworten`,
421
422
  },
422
423
  },
424
+ suggestion_changes: {
425
+ formatting_change: "Formatierungsänderung",
426
+ deleted: "Gelöscht",
427
+ inserted_by: (users: string) => `Eingefügt von: ${users}`,
428
+ deleted_by: (users: string) => `Gelöscht von: ${users}`,
429
+ formatting_change_by: (formats: string, users: string) =>
430
+ `Formatierungsänderung (${formats}) von: ${users}`,
431
+ },
423
432
  generic: {
424
433
  ctrl_shortcut: "Strg",
425
434
  },
@@ -188,7 +188,7 @@ export const en = {
188
188
  new_comment: "Write a comment...",
189
189
  edit_comment: "Edit comment...",
190
190
  comment_reply: "Add comment...",
191
- } as Record<string | "default" | "emptyDocument", string | undefined>,
191
+ } as Record<string, string | undefined>,
192
192
  file_blocks: {
193
193
  add_button_text: {
194
194
  image: "Add image",
@@ -385,6 +385,7 @@ export const en = {
385
385
  save_button_text: "Save",
386
386
  cancel_button_text: "Cancel",
387
387
  deleted_reference_text: "Original content deleted",
388
+ discard_pending_comment: "Are you sure you want to discard this comment?",
388
389
  actions: {
389
390
  add_reaction: "Add reaction",
390
391
  resolve: "Resolve",
@@ -401,6 +402,14 @@ export const en = {
401
402
  more_replies: (count: number) => `${count} more replies`,
402
403
  },
403
404
  },
405
+ suggestion_changes: {
406
+ formatting_change: "Formatting Change",
407
+ deleted: "Deleted",
408
+ inserted_by: (users: string) => `Inserted by: ${users}`,
409
+ deleted_by: (users: string) => `Deleted by: ${users}`,
410
+ formatting_change_by: (formats: string, users: string) =>
411
+ `Formatting change (${formats}) by: ${users}`,
412
+ },
404
413
  generic: {
405
414
  ctrl_shortcut: "Ctrl",
406
415
  },
@@ -383,6 +383,7 @@ export const es: Dictionary = {
383
383
  save_button_text: "Guardar",
384
384
  cancel_button_text: "Cancelar",
385
385
  deleted_reference_text: "Contenido original eliminado",
386
+ discard_pending_comment: "¿Seguro que quieres descartar este comentario?",
386
387
  actions: {
387
388
  add_reaction: "Agregar reacción",
388
389
  resolve: "Resolver",
@@ -399,6 +400,14 @@ export const es: Dictionary = {
399
400
  more_replies: (count) => `${count} respuestas más`,
400
401
  },
401
402
  },
403
+ suggestion_changes: {
404
+ formatting_change: "Cambio de formato",
405
+ deleted: "Eliminado",
406
+ inserted_by: (users: string) => `Insertado por: ${users}`,
407
+ deleted_by: (users: string) => `Eliminado por: ${users}`,
408
+ formatting_change_by: (formats: string, users: string) =>
409
+ `Cambio de formato (${formats}) por: ${users}`,
410
+ },
402
411
  generic: {
403
412
  ctrl_shortcut: "Ctrl",
404
413
  },
@@ -156,7 +156,7 @@ export const fa = {
156
156
  new_comment: "یک دیدگاه بنویسید...",
157
157
  edit_comment: "ویرایش دیدگاه...",
158
158
  comment_reply: "افزودن دیدگاه...",
159
- } as Record<string | "default" | "emptyDocument", string | undefined>,
159
+ } as Record<string, string | undefined>,
160
160
  file_blocks: {
161
161
  add_button_text: {
162
162
  image: "افزودن تصویر",
@@ -353,6 +353,8 @@ export const fa = {
353
353
  save_button_text: "ذخیره",
354
354
  cancel_button_text: "لغو",
355
355
  deleted_reference_text: "محتوای اصلی حذف شد",
356
+ discard_pending_comment:
357
+ "آیا مطمئن هستید که می‌خواهید این دیدگاه را نادیده بگیرید؟",
356
358
  actions: {
357
359
  add_reaction: "افزودن واکنش",
358
360
  resolve: "حل کردن",
@@ -369,6 +371,14 @@ export const fa = {
369
371
  more_replies: (count: number) => `${count} پاسخ دیگر`,
370
372
  },
371
373
  },
374
+ suggestion_changes: {
375
+ formatting_change: "تغییر قالب‌بندی",
376
+ deleted: "حذف\u200cشده",
377
+ inserted_by: (users: string) => `درج‌شده توسط: ${users}`,
378
+ deleted_by: (users: string) => `حذف‌شده توسط: ${users}`,
379
+ formatting_change_by: (formats: string, users: string) =>
380
+ `تغییر قالب‌بندی (${formats}) توسط: ${users}`,
381
+ },
372
382
  generic: {
373
383
  ctrl_shortcut: "Ctrl",
374
384
  },