@blocknote/core 0.56.0 → 0.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (733) hide show
  1. package/NOTICE.txt +101 -0
  2. package/dist/BlockNoteExtension-U58cXw1g.js +64 -0
  3. package/dist/ThreadStore-CSEwCO0O.js +8 -0
  4. package/dist/{UserStore-OZJP3K8T.js → UserStore-BFv6NXA-.js} +3 -7
  5. package/dist/ar-DPJDxCQI.js +3 -0
  6. package/dist/blocknote.js +8 -6
  7. package/dist/blocks-BUX9dXi9.js +2063 -0
  8. package/dist/blocks.js +3 -2
  9. package/dist/comments.js +8 -9
  10. package/dist/de-CakHBokE.js +3 -0
  11. package/dist/emoji-data.js +102 -0
  12. package/dist/en-BGdzE27X.js +3 -0
  13. package/dist/{en-Ch-vvt5e.js → en-Ne9rlj9Y.js} +9 -6
  14. package/dist/es-VeBX6MEG.js +3 -0
  15. package/dist/{extensions-BbM81hHa.js → extensions-CEgexSyF.js} +846 -824
  16. package/dist/extensions.js +4 -4
  17. package/dist/fa-Dt7EYtKf.js +3 -0
  18. package/dist/fr-DUhhjxrJ.js +3 -0
  19. package/dist/getDefaultSlashMenuItems-DfDOr807.js +1939 -0
  20. package/dist/he-BShJg1dK.js +3 -0
  21. package/dist/hr-BXtyqmwg.js +3 -0
  22. package/dist/is-2Fb-0w_j.js +3 -0
  23. package/dist/it-CiZtVb3Y.js +3 -0
  24. package/dist/ja-CsxD3kEL.js +3 -0
  25. package/dist/ko-It6g03Cy.js +3 -0
  26. package/dist/locales.js +692 -54
  27. package/dist/markGroups-BszXCkX8.js +18 -0
  28. package/dist/nb-CLao87La.js +3 -0
  29. package/dist/nl-JQSo8dht.js +3 -0
  30. package/dist/pl-DEMBgHEP.js +3 -0
  31. package/dist/pt-CBCdYAax.js +3 -0
  32. package/dist/ru-BQk_9Q-L.js +3 -0
  33. package/dist/sk-kgB2DtDL.js +3 -0
  34. package/dist/{src-BmLsLZfE.js → src-DksfoQmN.js} +1173 -1090
  35. package/dist/style.css +1 -1
  36. package/dist/tr-DkcSXX8f.js +3 -0
  37. package/dist/uk-Bib-e6bV.js +3 -0
  38. package/dist/uz-B2jaKhJb.js +3 -0
  39. package/dist/vi-V_GFRxE8.js +3 -0
  40. package/dist/y.js +356 -361
  41. package/dist/yjs.js +134 -135
  42. package/dist/zh-hant-2ZrAkFnC.js +3 -0
  43. package/dist/zh-jglyCmjs.js +3 -0
  44. package/package.json +45 -21
  45. package/types/src/api/blockManipulation/layoutBlocks/layoutBlocks.fixture.d.ts +5 -0
  46. package/types/src/api/blockManipulation/tables/tables.d.ts +9 -4
  47. package/types/src/api/clipboard/fromClipboard/normalizeOfficeHTML.d.ts +5 -0
  48. package/types/src/api/exporters/markdown/wrapWithDelimiter.d.ts +6 -0
  49. package/types/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.d.ts +4 -0
  50. package/types/src/blocks/defaultBlocks.d.ts +10 -0
  51. package/types/src/editor/BlockNoteEditor.d.ts +2 -1
  52. package/types/src/editor/managers/ExtensionManager/index.d.ts +4 -4
  53. package/types/src/editor/managers/StyleManager.d.ts +2 -1
  54. package/types/src/emoji-data/frimousse/ar.d.ts +2 -0
  55. package/types/src/emoji-data/frimousse/common.d.ts +3 -0
  56. package/types/src/emoji-data/frimousse/de.d.ts +2 -0
  57. package/types/src/emoji-data/frimousse/en.d.ts +2 -0
  58. package/types/src/emoji-data/frimousse/es.d.ts +2 -0
  59. package/types/src/emoji-data/frimousse/fa.d.ts +2 -0
  60. package/types/src/emoji-data/frimousse/fr.d.ts +2 -0
  61. package/types/src/emoji-data/frimousse/he.d.ts +2 -0
  62. package/types/src/emoji-data/frimousse/hr.d.ts +2 -0
  63. package/types/src/emoji-data/frimousse/is.d.ts +2 -0
  64. package/types/src/emoji-data/frimousse/it.d.ts +2 -0
  65. package/types/src/emoji-data/frimousse/ja.d.ts +2 -0
  66. package/types/src/emoji-data/frimousse/ko.d.ts +2 -0
  67. package/types/src/emoji-data/frimousse/loadFrimousseData.d.ts +2 -0
  68. package/types/src/emoji-data/frimousse/nb.d.ts +2 -0
  69. package/types/src/emoji-data/frimousse/nl.d.ts +2 -0
  70. package/types/src/emoji-data/frimousse/pl.d.ts +2 -0
  71. package/types/src/emoji-data/frimousse/pt.d.ts +2 -0
  72. package/types/src/emoji-data/frimousse/ru.d.ts +2 -0
  73. package/types/src/emoji-data/frimousse/sk.d.ts +2 -0
  74. package/types/src/emoji-data/frimousse/tr.d.ts +2 -0
  75. package/types/src/emoji-data/frimousse/types.d.ts +21 -0
  76. package/types/src/emoji-data/frimousse/uk.d.ts +2 -0
  77. package/types/src/emoji-data/frimousse/uz.d.ts +2 -0
  78. package/types/src/emoji-data/frimousse/vi.d.ts +2 -0
  79. package/types/src/emoji-data/frimousse/zh-hant.d.ts +2 -0
  80. package/types/src/emoji-data/frimousse/zh.d.ts +2 -0
  81. package/types/src/emoji-data/index.d.ts +3 -0
  82. package/types/src/emoji-data/searchEmojis.d.ts +5 -0
  83. package/types/src/extensions/Loading/Loading.d.ts +11 -0
  84. package/types/src/extensions/SideMenu/MultipleNodeSelection.d.ts +13 -4
  85. package/types/src/extensions/SideMenu/SideMenu.d.ts +2 -1
  86. package/types/src/extensions/Versioning/Versioning.d.ts +2 -0
  87. package/types/src/extensions/Versioning/inMemoryVersioning.d.ts +1 -0
  88. package/types/src/extensions/Versioning/types.d.ts +12 -6
  89. package/types/src/extensions/Versioning/versioningState.d.ts +6 -0
  90. package/types/src/extensions/index.d.ts +1 -2
  91. package/types/src/i18n/dictionary.d.ts +4 -1
  92. package/types/src/i18n/locales/en.d.ts +6 -0
  93. package/types/src/i18n/locales/fa.d.ts +6 -0
  94. package/types/src/i18n/locales/index.d.ts +1 -0
  95. package/types/src/i18n/locales/sk.d.ts +6 -0
  96. package/types/src/i18n/locales/tr.d.ts +378 -0
  97. package/types/src/index.d.ts +0 -1
  98. package/types/src/schema/inlineContent/createSpec.d.ts +2 -1
  99. package/types/src/schema/inlineContent/internal.d.ts +1 -1
  100. package/types/src/schema/inlineContent/types.d.ts +2 -4
  101. package/types/src/schema/styles/createSpec.d.ts +2 -1
  102. package/types/src/schema/styles/internal.d.ts +4 -1
  103. package/types/src/schema/styles/types.d.ts +2 -0
  104. package/types/src/y/extensions/YSync.d.ts +1 -1
  105. package/types/src/y/extensions/index.d.ts +1 -1
  106. package/types/src/y/versioning/yhub.d.ts +2 -0
  107. package/types/src/yjs/extensions/Versioning.d.ts +1 -0
  108. package/types/src/yjs/extensions/YUndo.d.ts +3 -2
  109. package/types/src/yjs/extensions/index.d.ts +1 -1
  110. package/dist/BlockNoteExtension-DjEkXkR5.cjs +0 -2
  111. package/dist/BlockNoteExtension-DjEkXkR5.cjs.map +0 -1
  112. package/dist/BlockNoteExtension-TsTGtIeX.js +0 -87
  113. package/dist/BlockNoteExtension-TsTGtIeX.js.map +0 -1
  114. package/dist/ThreadStore-Bx-gSEh1.cjs +0 -2
  115. package/dist/ThreadStore-Bx-gSEh1.cjs.map +0 -1
  116. package/dist/ThreadStore-et9wB5Xt.js +0 -11
  117. package/dist/ThreadStore-et9wB5Xt.js.map +0 -1
  118. package/dist/UserStore-CTVzVGh-.cjs +0 -2
  119. package/dist/UserStore-CTVzVGh-.cjs.map +0 -1
  120. package/dist/UserStore-OZJP3K8T.js.map +0 -1
  121. package/dist/blocknote.cjs +0 -1
  122. package/dist/blocks-COVwe5Cf.cjs +0 -12
  123. package/dist/blocks-COVwe5Cf.cjs.map +0 -1
  124. package/dist/blocks-COYcDVg7.js +0 -3943
  125. package/dist/blocks-COYcDVg7.js.map +0 -1
  126. package/dist/blocks.cjs +0 -1
  127. package/dist/comments.cjs +0 -2
  128. package/dist/comments.cjs.map +0 -1
  129. package/dist/comments.js.map +0 -1
  130. package/dist/en-Ch-vvt5e.js.map +0 -1
  131. package/dist/en-N5lu0-j8.cjs +0 -2
  132. package/dist/en-N5lu0-j8.cjs.map +0 -1
  133. package/dist/extensions-BbM81hHa.js.map +0 -1
  134. package/dist/extensions-D_WkAfSt.cjs +0 -58
  135. package/dist/extensions-D_WkAfSt.cjs.map +0 -1
  136. package/dist/extensions.cjs +0 -1
  137. package/dist/locales.cjs +0 -2
  138. package/dist/locales.cjs.map +0 -1
  139. package/dist/locales.js.map +0 -1
  140. package/dist/src-4OQT3z5S.cjs +0 -23
  141. package/dist/src-4OQT3z5S.cjs.map +0 -1
  142. package/dist/src-BmLsLZfE.js.map +0 -1
  143. package/dist/webpack-stats.json +0 -1
  144. package/dist/y.cjs +0 -2
  145. package/dist/y.cjs.map +0 -1
  146. package/dist/y.js.map +0 -1
  147. package/dist/yjs.cjs +0 -2
  148. package/dist/yjs.cjs.map +0 -1
  149. package/dist/yjs.js.map +0 -1
  150. package/src/api/README.md +0 -8
  151. package/src/api/__snapshots__/blocks-deleted-nested-deep.json +0 -26
  152. package/src/api/__snapshots__/blocks-deleted-nested.json +0 -68
  153. package/src/api/__snapshots__/blocks-deleted.json +0 -26
  154. package/src/api/__snapshots__/blocks-indented-changed.json +0 -129
  155. package/src/api/__snapshots__/blocks-inserted-nested.json +0 -62
  156. package/src/api/__snapshots__/blocks-inserted.json +0 -20
  157. package/src/api/__snapshots__/blocks-moved-deeper-into-nesting.json +0 -164
  158. package/src/api/__snapshots__/blocks-moved-down-twice-in-same-parent.json +0 -44
  159. package/src/api/__snapshots__/blocks-moved-insert-changes-sibling-order.json +0 -26
  160. package/src/api/__snapshots__/blocks-moved-multiple-in-same-transaction.json +0 -188
  161. package/src/api/__snapshots__/blocks-moved-nested-sibling-reorder.json +0 -180
  162. package/src/api/__snapshots__/blocks-moved-to-different-parent.json +0 -78
  163. package/src/api/__snapshots__/blocks-moved-to-root-level.json +0 -78
  164. package/src/api/__snapshots__/blocks-moved-up-down-in-same-parent.json +0 -44
  165. package/src/api/__snapshots__/blocks-moved-up-down-in-same-transaction.json +0 -44
  166. package/src/api/__snapshots__/blocks-outdented-changed.json +0 -129
  167. package/src/api/__snapshots__/blocks-updated-content-inserted.json +0 -42
  168. package/src/api/__snapshots__/blocks-updated-multiple-insert.json +0 -50
  169. package/src/api/__snapshots__/blocks-updated-multiple.json +0 -82
  170. package/src/api/__snapshots__/blocks-updated-nested-deep.json +0 -42
  171. package/src/api/__snapshots__/blocks-updated-nested-multiple.json +0 -118
  172. package/src/api/__snapshots__/blocks-updated-nested.json +0 -78
  173. package/src/api/__snapshots__/blocks-updated-single.json +0 -42
  174. package/src/api/__snapshots__/blocks-updated.json +0 -42
  175. package/src/api/blockManipulation/__snapshots__/transactions.test.ts.snap +0 -34
  176. package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +0 -4570
  177. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +0 -176
  178. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +0 -95
  179. package/src/api/blockManipulation/commands/insertBlocks/insertPlacement.test.ts +0 -217
  180. package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +0 -2761
  181. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +0 -251
  182. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +0 -187
  183. package/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap +0 -13625
  184. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +0 -391
  185. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +0 -350
  186. package/src/api/blockManipulation/commands/nestBlock/__snapshots__/nestBlock.test.ts.snap +0 -952
  187. package/src/api/blockManipulation/commands/nestBlock/nestBlock.test.ts +0 -917
  188. package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +0 -248
  189. package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +0 -5710
  190. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +0 -306
  191. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +0 -143
  192. package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +0 -3507
  193. package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +0 -364
  194. package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +0 -90
  195. package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +0 -15085
  196. package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +0 -1210
  197. package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +0 -706
  198. package/src/api/blockManipulation/getBlock/getBlock.ts +0 -104
  199. package/src/api/blockManipulation/insertContentAt.ts +0 -83
  200. package/src/api/blockManipulation/layoutBlocks/fixLayoutBlock.ts +0 -173
  201. package/src/api/blockManipulation/layoutBlocks/layoutBlocks.browser.test.ts +0 -293
  202. package/src/api/blockManipulation/layoutBlocks/layoutBlocks.fixture.ts +0 -145
  203. package/src/api/blockManipulation/layoutBlocks/layoutBlocks.test.ts +0 -783
  204. package/src/api/blockManipulation/layoutBlocks/plainBlocks.test.ts +0 -180
  205. package/src/api/blockManipulation/layoutBlocks/titledBlocks.test.ts +0 -365
  206. package/src/api/blockManipulation/selections/selection.ts +0 -234
  207. package/src/api/blockManipulation/selections/textCursorPosition.ts +0 -63
  208. package/src/api/blockManipulation/setupTestEnv.ts +0 -223
  209. package/src/api/blockManipulation/tables/tables.test.ts +0 -2127
  210. package/src/api/blockManipulation/tables/tables.ts +0 -887
  211. package/src/api/clipboard/fromClipboard/acceptedMIMETypes.ts +0 -8
  212. package/src/api/clipboard/fromClipboard/fileDropExtension.ts +0 -55
  213. package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +0 -209
  214. package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +0 -38
  215. package/src/api/clipboard/fromClipboard/pasteExtension.ts +0 -157
  216. package/src/api/clipboard/toClipboard/copyExtension.ts +0 -299
  217. package/src/api/combineTransactionSteps.ts +0 -22
  218. package/src/api/exporters/html/externalHTMLExporter.ts +0 -76
  219. package/src/api/exporters/html/internalHTMLSerializer.ts +0 -182
  220. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +0 -510
  221. package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +0 -283
  222. package/src/api/exporters/markdown/htmlToMarkdown.ts +0 -895
  223. package/src/api/exporters/markdown/markdownExporter.ts +0 -41
  224. package/src/api/getBlockInfoFromPos.test.ts +0 -681
  225. package/src/api/getBlockInfoFromPos.ts +0 -693
  226. package/src/api/getBlocksChangedByTransaction.test.ts +0 -783
  227. package/src/api/getBlocksChangedByTransaction.ts +0 -458
  228. package/src/api/getChangedRangeWithAttrs.ts +0 -54
  229. package/src/api/getChangedRanges.test.ts +0 -391
  230. package/src/api/getChangedRanges.ts +0 -368
  231. package/src/api/nodeConversions/blockToNode.test.ts +0 -113
  232. package/src/api/nodeConversions/blockToNode.ts +0 -427
  233. package/src/api/nodeConversions/fragmentToBlocks.ts +0 -48
  234. package/src/api/nodeConversions/nodeToBlock.ts +0 -717
  235. package/src/api/nodeUtil.ts +0 -46
  236. package/src/api/parsers/html/parseHTML.ts +0 -80
  237. package/src/api/parsers/html/util/__snapshots__/nestedLists.test.ts.snap +0 -144
  238. package/src/api/parsers/html/util/nestedLists.test.ts +0 -165
  239. package/src/api/parsers/html/util/nestedLists.ts +0 -123
  240. package/src/api/parsers/html/util/normalizeWhitespace.ts +0 -87
  241. package/src/api/parsers/markdown/autolink.ts +0 -23
  242. package/src/api/parsers/markdown/detectMarkdown.test.ts +0 -211
  243. package/src/api/parsers/markdown/detectMarkdown.ts +0 -61
  244. package/src/api/parsers/markdown/markdownToHtml.ts +0 -1444
  245. package/src/api/parsers/markdown/parseMarkdown.ts +0 -24
  246. package/src/api/pmUtil.ts +0 -79
  247. package/src/api/positionMapping.test.ts +0 -209
  248. package/src/api/positionMapping.ts +0 -42
  249. package/src/blocks/Audio/block.ts +0 -171
  250. package/src/blocks/Audio/parseAudioElement.ts +0 -5
  251. package/src/blocks/BlockNoteSchema.ts +0 -59
  252. package/src/blocks/Code/CodeBlockOptions.ts +0 -83
  253. package/src/blocks/Code/block.test.ts +0 -265
  254. package/src/blocks/Code/block.ts +0 -56
  255. package/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.ts +0 -125
  256. package/src/blocks/Code/helpers/parse/parsePreCode.ts +0 -45
  257. package/src/blocks/Code/helpers/render/createCodeBlock.ts +0 -98
  258. package/src/blocks/Code/helpers/toExternalHTML/createPreCode.ts +0 -14
  259. package/src/blocks/Divider/block.ts +0 -49
  260. package/src/blocks/File/block.ts +0 -95
  261. package/src/blocks/File/helpers/parse/parseEmbedElement.ts +0 -5
  262. package/src/blocks/File/helpers/parse/parseFigureElement.ts +0 -16
  263. package/src/blocks/File/helpers/render/createAddFileButton.ts +0 -69
  264. package/src/blocks/File/helpers/render/createFileBlockWrapper.ts +0 -88
  265. package/src/blocks/File/helpers/render/createFileNameWithIcon.ts +0 -37
  266. package/src/blocks/File/helpers/render/createResizableFileBlockWrapper.ts +0 -271
  267. package/src/blocks/File/helpers/toExternalHTML/createFigureWithCaption.ts +0 -13
  268. package/src/blocks/File/helpers/toExternalHTML/createLinkWithCaption.ts +0 -15
  269. package/src/blocks/Heading/block.ts +0 -227
  270. package/src/blocks/Image/block.ts +0 -193
  271. package/src/blocks/Image/parseImageElement.ts +0 -7
  272. package/src/blocks/ListItem/BulletListItem/block.ts +0 -129
  273. package/src/blocks/ListItem/CheckListItem/block.test.ts +0 -61
  274. package/src/blocks/ListItem/CheckListItem/block.ts +0 -184
  275. package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.ts +0 -352
  276. package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +0 -239
  277. package/src/blocks/ListItem/NumberedListItem/block.ts +0 -143
  278. package/src/blocks/ListItem/ToggleListItem/block.ts +0 -139
  279. package/src/blocks/ListItem/getListItemContent.ts +0 -115
  280. package/src/blocks/PageBreak/block.ts +0 -72
  281. package/src/blocks/PageBreak/getPageBreakSlashMenuItems.ts +0 -47
  282. package/src/blocks/Paragraph/block.ts +0 -80
  283. package/src/blocks/Quote/block.ts +0 -99
  284. package/src/blocks/README.md +0 -3
  285. package/src/blocks/Table/TableExtension.test.ts +0 -231
  286. package/src/blocks/Table/TableExtension.ts +0 -115
  287. package/src/blocks/Table/block.ts +0 -492
  288. package/src/blocks/ToggleWrapper/createToggleFrame.ts +0 -126
  289. package/src/blocks/ToggleWrapper/toggleBlocks.browser.test.ts +0 -1056
  290. package/src/blocks/Video/block.ts +0 -142
  291. package/src/blocks/Video/parseVideoElement.ts +0 -7
  292. package/src/blocks/defaultBlockHelpers.ts +0 -113
  293. package/src/blocks/defaultBlockTypeGuards.ts +0 -167
  294. package/src/blocks/defaultBlockTypeItems.test.ts +0 -70
  295. package/src/blocks/defaultBlockTypeItems.ts +0 -99
  296. package/src/blocks/defaultBlocks.test.ts +0 -67
  297. package/src/blocks/defaultBlocks.ts +0 -214
  298. package/src/blocks/defaultProps.ts +0 -165
  299. package/src/blocks/getDetailsContent.ts +0 -77
  300. package/src/blocks/index.ts +0 -30
  301. package/src/comments/CommentEditorSubmitExtension.test.ts +0 -141
  302. package/src/comments/CommentEditorSubmitExtension.ts +0 -56
  303. package/src/comments/extension.ts +0 -396
  304. package/src/comments/index.ts +0 -8
  305. package/src/comments/mark.ts +0 -64
  306. package/src/comments/threadstore/DefaultThreadStoreAuth.ts +0 -106
  307. package/src/comments/threadstore/ThreadStore.ts +0 -130
  308. package/src/comments/threadstore/ThreadStoreAuth.ts +0 -13
  309. package/src/comments/threadstore/TipTapThreadStore.ts +0 -292
  310. package/src/comments/threadstore/tiptap/types.ts +0 -131
  311. package/src/comments/types.ts +0 -121
  312. package/src/editor/Block.css +0 -1498
  313. package/src/editor/BlockNoteEditor.node.test.ts +0 -35
  314. package/src/editor/BlockNoteEditor.test.ts +0 -278
  315. package/src/editor/BlockNoteEditor.ts +0 -1559
  316. package/src/editor/BlockNoteExtension.test.ts +0 -103
  317. package/src/editor/BlockNoteExtension.ts +0 -246
  318. package/src/editor/README.md +0 -3
  319. package/src/editor/blockColors.browser.test.ts +0 -127
  320. package/src/editor/cursorPositionTypes.ts +0 -17
  321. package/src/editor/defaultColors.ts +0 -77
  322. package/src/editor/editor.css +0 -257
  323. package/src/editor/managers/BlockManager.ts +0 -256
  324. package/src/editor/managers/EventManager.browser.test.ts +0 -334
  325. package/src/editor/managers/EventManager.ts +0 -260
  326. package/src/editor/managers/ExportManager.ts +0 -137
  327. package/src/editor/managers/ExtensionManager/ExtensionManager.browser.test.ts +0 -45
  328. package/src/editor/managers/ExtensionManager/ExtensionManager.node.test.ts +0 -209
  329. package/src/editor/managers/ExtensionManager/ExtensionManager.test.ts +0 -336
  330. package/src/editor/managers/ExtensionManager/extensions.ts +0 -200
  331. package/src/editor/managers/ExtensionManager/index.ts +0 -764
  332. package/src/editor/managers/ExtensionManager/symbol.ts +0 -5
  333. package/src/editor/managers/SelectionManager.ts +0 -120
  334. package/src/editor/managers/StateManager.ts +0 -261
  335. package/src/editor/managers/StyleManager.browser.test.ts +0 -122
  336. package/src/editor/managers/StyleManager.test.ts +0 -98
  337. package/src/editor/managers/StyleManager.ts +0 -278
  338. package/src/editor/managers/index.ts +0 -8
  339. package/src/editor/performance.test.ts +0 -192
  340. package/src/editor/selectionTypes.ts +0 -14
  341. package/src/editor/transformPasted.test.ts +0 -295
  342. package/src/editor/transformPasted.ts +0 -294
  343. package/src/exporter/ExportImage.ts +0 -50
  344. package/src/exporter/Exporter.test.ts +0 -255
  345. package/src/exporter/Exporter.ts +0 -185
  346. package/src/exporter/index.ts +0 -3
  347. package/src/exporter/mapping.ts +0 -110
  348. package/src/extensions/BlockChange/BlockChange.ts +0 -67
  349. package/src/extensions/DropCursor/DropCursor.ts +0 -376
  350. package/src/extensions/DropCursor/dropIntoChildren.ts +0 -80
  351. package/src/extensions/DropCursor/utils.ts +0 -195
  352. package/src/extensions/FilePanel/FilePanel.ts +0 -41
  353. package/src/extensions/FormattingToolbar/FormattingToolbar.ts +0 -157
  354. package/src/extensions/History/History.ts +0 -11
  355. package/src/extensions/InlineContentBoundaryEdit/InlineContentBoundaryEdit.ts +0 -109
  356. package/src/extensions/LinkToolbar/LinkToolbar.ts +0 -76
  357. package/src/extensions/LinkToolbar/protocols.ts +0 -13
  358. package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.test.ts +0 -190
  359. package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.ts +0 -112
  360. package/src/extensions/Placeholder/Placeholder.test.ts +0 -23
  361. package/src/extensions/Placeholder/Placeholder.ts +0 -150
  362. package/src/extensions/PositionMapping/PositionMapping.ts +0 -68
  363. package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +0 -156
  364. package/src/extensions/PreviousBlockType/PreviousBlockType.ts +0 -201
  365. package/src/extensions/README.md +0 -3
  366. package/src/extensions/ReadOnly/ReadOnly.test.ts +0 -181
  367. package/src/extensions/ReadOnly/ReadOnly.ts +0 -73
  368. package/src/extensions/ShowSelection/ShowSelection.ts +0 -61
  369. package/src/extensions/SideMenu/MultipleNodeSelection.ts +0 -89
  370. package/src/extensions/SideMenu/SideMenu.ts +0 -470
  371. package/src/extensions/SideMenu/blockDropHandling.ts +0 -372
  372. package/src/extensions/SideMenu/blockGeometry.browser.test.ts +0 -148
  373. package/src/extensions/SideMenu/blockGeometry.test.ts +0 -46
  374. package/src/extensions/SideMenu/blockGeometry.ts +0 -53
  375. package/src/extensions/SideMenu/dragging.ts +0 -200
  376. package/src/extensions/SideMenu/sideMenuHover.test.ts +0 -36
  377. package/src/extensions/SideMenu/sideMenuHover.ts +0 -270
  378. package/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.ts +0 -193
  379. package/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.ts +0 -142
  380. package/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.ts +0 -4
  381. package/src/extensions/SuggestionMenu/DefaultSuggestionItem.ts +0 -11
  382. package/src/extensions/SuggestionMenu/SuggestionMenu.test.ts +0 -309
  383. package/src/extensions/SuggestionMenu/SuggestionMenu.ts +0 -436
  384. package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +0 -76
  385. package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +0 -299
  386. package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.ts +0 -130
  387. package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.ts +0 -89
  388. package/src/extensions/SyntaxHighlighting/inlineHighlight.test.ts +0 -135
  389. package/src/extensions/SyntaxHighlighting/shiki.ts +0 -116
  390. package/src/extensions/TableHandles/TableHandles.browser.test.ts +0 -307
  391. package/src/extensions/TableHandles/TableHandles.ts +0 -1263
  392. package/src/extensions/TrailingNode/TrailingNode.ts +0 -233
  393. package/src/extensions/Versioning/Versioning.browser.test.ts +0 -151
  394. package/src/extensions/Versioning/Versioning.node.test.ts +0 -177
  395. package/src/extensions/Versioning/Versioning.ts +0 -161
  396. package/src/extensions/Versioning/__test__/result.ts +0 -12
  397. package/src/extensions/Versioning/comparison.test.ts +0 -40
  398. package/src/extensions/Versioning/createVersioning.test.ts +0 -867
  399. package/src/extensions/Versioning/createVersioning.ts +0 -499
  400. package/src/extensions/Versioning/formatVersionDate.ts +0 -24
  401. package/src/extensions/Versioning/inMemoryVersioning.test.ts +0 -572
  402. package/src/extensions/Versioning/inMemoryVersioning.ts +0 -268
  403. package/src/extensions/Versioning/index.ts +0 -6
  404. package/src/extensions/Versioning/scrollScheduling.test.ts +0 -51
  405. package/src/extensions/Versioning/scrollToFirstChange.test.ts +0 -320
  406. package/src/extensions/Versioning/scrollToFirstChange.ts +0 -139
  407. package/src/extensions/Versioning/types.ts +0 -219
  408. package/src/extensions/Versioning/versioningState.ts +0 -154
  409. package/src/extensions/blockDOM.browser.test.ts +0 -102
  410. package/src/extensions/blockDOM.test.ts +0 -178
  411. package/src/extensions/blockDOM.ts +0 -135
  412. package/src/extensions/index.ts +0 -27
  413. package/src/extensions/tiptap-extensions/BackgroundColor/BackgroundColorExtension.ts +0 -17
  414. package/src/extensions/tiptap-extensions/HardBreak/HardBreak.ts +0 -35
  415. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts +0 -1870
  416. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +0 -1116
  417. package/src/extensions/tiptap-extensions/KeyboardShortcuts/blockIdentity.browser.test.ts +0 -152
  418. package/src/extensions/tiptap-extensions/Link/helpers/autolink.ts +0 -174
  419. package/src/extensions/tiptap-extensions/Link/helpers/clickHandler.ts +0 -82
  420. package/src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts +0 -412
  421. package/src/extensions/tiptap-extensions/Link/helpers/pasteHandler.ts +0 -53
  422. package/src/extensions/tiptap-extensions/Link/helpers/tlds.ts +0 -7
  423. package/src/extensions/tiptap-extensions/Link/helpers/whitespace.ts +0 -13
  424. package/src/extensions/tiptap-extensions/Link/index.ts +0 -2
  425. package/src/extensions/tiptap-extensions/Link/link.test.ts +0 -945
  426. package/src/extensions/tiptap-extensions/Link/link.ts +0 -238
  427. package/src/extensions/tiptap-extensions/TextAlignment/TextAlignmentExtension.ts +0 -33
  428. package/src/extensions/tiptap-extensions/TextColor/TextColorExtension.ts +0 -17
  429. package/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.ts +0 -173
  430. package/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts +0 -339
  431. package/src/extensions/tiptap-extensions/index.ts +0 -7
  432. package/src/extensions-shared/UiElementPosition.ts +0 -4
  433. package/src/fonts/inter.browser.test.ts +0 -57
  434. package/src/i18n/dictionary.ts +0 -17
  435. package/src/i18n/index.ts +0 -2
  436. package/src/i18n/locales/ar.ts +0 -443
  437. package/src/i18n/locales/de.ts +0 -477
  438. package/src/i18n/locales/en.ts +0 -458
  439. package/src/i18n/locales/es.ts +0 -456
  440. package/src/i18n/locales/fa.ts +0 -427
  441. package/src/i18n/locales/fr.ts +0 -504
  442. package/src/i18n/locales/he.ts +0 -458
  443. package/src/i18n/locales/hr.ts +0 -472
  444. package/src/i18n/locales/index.ts +0 -23
  445. package/src/i18n/locales/is.ts +0 -472
  446. package/src/i18n/locales/it.ts +0 -480
  447. package/src/i18n/locales/ja.ts +0 -498
  448. package/src/i18n/locales/ko.ts +0 -471
  449. package/src/i18n/locales/nl.ts +0 -459
  450. package/src/i18n/locales/no.ts +0 -476
  451. package/src/i18n/locales/pl.ts +0 -449
  452. package/src/i18n/locales/pt.ts +0 -451
  453. package/src/i18n/locales/ru.ts +0 -502
  454. package/src/i18n/locales/sk.ts +0 -456
  455. package/src/i18n/locales/uk.ts +0 -482
  456. package/src/i18n/locales/uz.ts +0 -492
  457. package/src/i18n/locales/vi.ts +0 -457
  458. package/src/i18n/locales/zh-tw.ts +0 -499
  459. package/src/i18n/locales/zh.ts +0 -499
  460. package/src/index.ts +0 -66
  461. package/src/locales.ts +0 -1
  462. package/src/pm-nodes/BlockContainer.test.ts +0 -101
  463. package/src/pm-nodes/BlockContainer.ts +0 -200
  464. package/src/pm-nodes/BlockGroup.ts +0 -58
  465. package/src/pm-nodes/Doc.ts +0 -11
  466. package/src/pm-nodes/README.md +0 -143
  467. package/src/pm-nodes/index.ts +0 -3
  468. package/src/pm-nodes/suggestionMarks.ts +0 -43
  469. package/src/schema/README.md +0 -3
  470. package/src/schema/blocks/children.test.ts +0 -288
  471. package/src/schema/blocks/children.ts +0 -136
  472. package/src/schema/blocks/createSpec.browser.test.ts +0 -176
  473. package/src/schema/blocks/createSpec.test.ts +0 -354
  474. package/src/schema/blocks/createSpec.ts +0 -732
  475. package/src/schema/blocks/extendBlockSpec.test.ts +0 -188
  476. package/src/schema/blocks/frame.test.ts +0 -112
  477. package/src/schema/blocks/frame.ts +0 -337
  478. package/src/schema/blocks/internal.test.ts +0 -86
  479. package/src/schema/blocks/internal.ts +0 -288
  480. package/src/schema/blocks/keyboard.ts +0 -154
  481. package/src/schema/blocks/layoutBlockAttributes.ts +0 -29
  482. package/src/schema/blocks/meta.test.ts +0 -53
  483. package/src/schema/blocks/meta.ts +0 -35
  484. package/src/schema/blocks/renderFrame.test.ts +0 -691
  485. package/src/schema/blocks/types.ts +0 -966
  486. package/src/schema/blocks/validateChildren.ts +0 -156
  487. package/src/schema/contentTypePropagation.test.ts +0 -182
  488. package/src/schema/dataAttributes.test.ts +0 -72
  489. package/src/schema/dataAttributes.ts +0 -69
  490. package/src/schema/index.ts +0 -15
  491. package/src/schema/inlineContent/createSpec.test.ts +0 -161
  492. package/src/schema/inlineContent/createSpec.ts +0 -409
  493. package/src/schema/inlineContent/internal.ts +0 -131
  494. package/src/schema/inlineContent/types.ts +0 -204
  495. package/src/schema/markGroups.ts +0 -82
  496. package/src/schema/nodeViewMutations.test.ts +0 -146
  497. package/src/schema/nodeViewMutations.ts +0 -49
  498. package/src/schema/propTypes.ts +0 -61
  499. package/src/schema/schema.test.ts +0 -110
  500. package/src/schema/schema.ts +0 -243
  501. package/src/schema/styles/createSpec.ts +0 -140
  502. package/src/schema/styles/internal.ts +0 -155
  503. package/src/schema/styles/types.ts +0 -57
  504. package/src/style.css +0 -2
  505. package/src/user/UserStore.ts +0 -199
  506. package/src/user/createUserStore.test.ts +0 -126
  507. package/src/user/index.ts +0 -2
  508. package/src/user/userColors.test.ts +0 -108
  509. package/src/user/userColors.ts +0 -101
  510. package/src/util/EventEmitter.ts +0 -59
  511. package/src/util/README.md +0 -3
  512. package/src/util/Store.test.ts +0 -132
  513. package/src/util/Store.ts +0 -135
  514. package/src/util/browser.ts +0 -54
  515. package/src/util/combineByGroup.ts +0 -25
  516. package/src/util/expandToWords.ts +0 -38
  517. package/src/util/string.ts +0 -36
  518. package/src/util/table.ts +0 -110
  519. package/src/util/topo-sort.test.ts +0 -125
  520. package/src/util/topo-sort.ts +0 -206
  521. package/src/util/typescript.ts +0 -17
  522. package/src/vite-env.d.ts +0 -7
  523. package/src/y/README.md +0 -5
  524. package/src/y/comments/RESTYjsThreadStore.ts +0 -138
  525. package/src/y/comments/YjsThreadStore.test.ts +0 -295
  526. package/src/y/comments/YjsThreadStore.ts +0 -358
  527. package/src/y/comments/YjsThreadStoreBase.ts +0 -50
  528. package/src/y/comments/index.ts +0 -3
  529. package/src/y/comments/yjsHelpers.ts +0 -125
  530. package/src/y/extensions/AttributionExtension.test.ts +0 -364
  531. package/src/y/extensions/AttributionExtension.ts +0 -401
  532. package/src/y/extensions/DiffVersioningExtension.test.ts +0 -242
  533. package/src/y/extensions/DiffVersioningExtension.ts +0 -200
  534. package/src/y/extensions/EmptyDocBinding.test.ts +0 -282
  535. package/src/y/extensions/ForkYDoc.node.test.ts +0 -77
  536. package/src/y/extensions/ForkYDoc.test.ts +0 -344
  537. package/src/y/extensions/ForkYDoc.ts +0 -117
  538. package/src/y/extensions/History.test.ts +0 -125
  539. package/src/y/extensions/RelativePositionMapping.test.ts +0 -453
  540. package/src/y/extensions/RelativePositionMapping.ts +0 -45
  541. package/src/y/extensions/Suggestions.ts +0 -174
  542. package/src/y/extensions/Versioning.node.test.ts +0 -126
  543. package/src/y/extensions/Versioning.test.ts +0 -117
  544. package/src/y/extensions/Versioning.ts +0 -74
  545. package/src/y/extensions/YAttributionMarks.ts +0 -422
  546. package/src/y/extensions/YCursorPlugin.ts +0 -192
  547. package/src/y/extensions/YSync.node.test.ts +0 -75
  548. package/src/y/extensions/YSync.ts +0 -197
  549. package/src/y/extensions/YSyncRemount.test.ts +0 -99
  550. package/src/y/extensions/blockMatchNodes.ts +0 -173
  551. package/src/y/extensions/index.ts +0 -140
  552. package/src/y/extensions/legacyYjsDocBinding.test.ts +0 -652
  553. package/src/y/extensions/nestingChanges.test.ts +0 -326
  554. package/src/y/extensions/persistentBlockGroups.test.ts +0 -1709
  555. package/src/y/extensions/persistentBlockGroups.ts +0 -953
  556. package/src/y/extensions/snapshotCodec.test.ts +0 -105
  557. package/src/y/extensions/snapshotCodec.ts +0 -39
  558. package/src/y/extensions/snapshotPreview.test.ts +0 -201
  559. package/src/y/extensions/snapshotPreview.ts +0 -292
  560. package/src/y/extensions/tableReshape.test.ts +0 -121
  561. package/src/y/extensions/v1BindingSnapshotDiff.test.ts +0 -121
  562. package/src/y/extensions/versionDiffAttribution.test.ts +0 -944
  563. package/src/y/extensions/versionDiffPerformance.test.ts +0 -101
  564. package/src/y/index.ts +0 -5
  565. package/src/y/utils.test.ts +0 -1309
  566. package/src/y/utils.ts +0 -366
  567. package/src/y/versioning/__test__/fixtures/activity-all-after.bin +0 -0
  568. package/src/y/versioning/__test__/fixtures/activity-all-after.json +0 -50
  569. package/src/y/versioning/__test__/fixtures/activity-all.bin +0 -0
  570. package/src/y/versioning/__test__/fixtures/activity-all.json +0 -20
  571. package/src/y/versioning/__test__/fixtures/activity-filtered-after.bin +0 -0
  572. package/src/y/versioning/__test__/fixtures/activity-filtered-after.json +0 -32
  573. package/src/y/versioning/__test__/fixtures/activity-filtered-before.json +0 -1
  574. package/src/y/versioning/__test__/fixtures/changeset.bin +0 -0
  575. package/src/y/versioning/__test__/fixtures/patch-response.json +0 -4
  576. package/src/y/versioning/__test__/yhub.test.ts +0 -966
  577. package/src/y/versioning/index.ts +0 -6
  578. package/src/y/versioning/yhub.ts +0 -350
  579. package/src/y/versioning/yhubClient.ts +0 -345
  580. package/src/yjs/README.md +0 -5
  581. package/src/yjs/comments/RESTYjsThreadStore.test.ts +0 -95
  582. package/src/yjs/comments/RESTYjsThreadStore.ts +0 -172
  583. package/src/yjs/comments/YjsThreadStore.test.ts +0 -295
  584. package/src/yjs/comments/YjsThreadStore.ts +0 -345
  585. package/src/yjs/comments/YjsThreadStoreBase.ts +0 -50
  586. package/src/yjs/comments/index.ts +0 -3
  587. package/src/yjs/comments/yjsHelpers.ts +0 -127
  588. package/src/yjs/extensions/FixUpSchema.test.ts +0 -421
  589. package/src/yjs/extensions/FixUpSchema.ts +0 -99
  590. package/src/yjs/extensions/ForkYDoc.browser.test.ts +0 -84
  591. package/src/yjs/extensions/ForkYDoc.node.test.ts +0 -231
  592. package/src/yjs/extensions/ForkYDoc.test.ts +0 -320
  593. package/src/yjs/extensions/ForkYDoc.ts +0 -177
  594. package/src/yjs/extensions/RelativePositionMapping.test.ts +0 -418
  595. package/src/yjs/extensions/RelativePositionMapping.ts +0 -77
  596. package/src/yjs/extensions/Versioning.test.ts +0 -376
  597. package/src/yjs/extensions/Versioning.ts +0 -126
  598. package/src/yjs/extensions/YCursorPlugin.ts +0 -201
  599. package/src/yjs/extensions/YSync.ts +0 -16
  600. package/src/yjs/extensions/YUndo.ts +0 -12
  601. package/src/yjs/extensions/__snapshots__/fork-yjs-snap-editor-forked.json +0 -19
  602. package/src/yjs/extensions/__snapshots__/fork-yjs-snap-editor.json +0 -19
  603. package/src/yjs/extensions/__snapshots__/fork-yjs-snap-forked.html +0 -1
  604. package/src/yjs/extensions/__snapshots__/fork-yjs-snap.html +0 -1
  605. package/src/yjs/extensions/index.ts +0 -89
  606. package/src/yjs/extensions/schemaMigration/SchemaMigration.ts +0 -59
  607. package/src/yjs/extensions/schemaMigration/migrationRules/index.ts +0 -4
  608. package/src/yjs/extensions/schemaMigration/migrationRules/migrationRule.ts +0 -4
  609. package/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.test.ts +0 -130
  610. package/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.ts +0 -91
  611. package/src/yjs/index.ts +0 -7
  612. package/src/yjs/utils.test.ts +0 -1013
  613. package/src/yjs/utils.ts +0 -186
  614. package/types/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.d.ts +0 -1
  615. package/types/src/api/blockManipulation/commands/insertBlocks/insertPlacement.test.d.ts +0 -1
  616. package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.d.ts +0 -1
  617. package/types/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.d.ts +0 -1
  618. package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.test.d.ts +0 -1
  619. package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.d.ts +0 -1
  620. package/types/src/api/blockManipulation/commands/splitBlock/splitBlock.test.d.ts +0 -1
  621. package/types/src/api/blockManipulation/commands/updateBlock/updateBlock.test.d.ts +0 -1
  622. package/types/src/api/blockManipulation/layoutBlocks/layoutBlocks.browser.test.d.ts +0 -1
  623. package/types/src/api/blockManipulation/layoutBlocks/layoutBlocks.test.d.ts +0 -1
  624. package/types/src/api/blockManipulation/layoutBlocks/plainBlocks.test.d.ts +0 -1
  625. package/types/src/api/blockManipulation/layoutBlocks/titledBlocks.test.d.ts +0 -1
  626. package/types/src/api/blockManipulation/tables/tables.test.d.ts +0 -1
  627. package/types/src/api/getBlockInfoFromPos.test.d.ts +0 -1
  628. package/types/src/api/getBlocksChangedByTransaction.test.d.ts +0 -1
  629. package/types/src/api/getChangedRanges.test.d.ts +0 -1
  630. package/types/src/api/nodeConversions/blockToNode.test.d.ts +0 -1
  631. package/types/src/api/parsers/html/util/nestedLists.test.d.ts +0 -1
  632. package/types/src/api/parsers/markdown/detectMarkdown.test.d.ts +0 -1
  633. package/types/src/api/positionMapping.test.d.ts +0 -1
  634. package/types/src/blocks/Code/block.test.d.ts +0 -1
  635. package/types/src/blocks/ListItem/CheckListItem/block.test.d.ts +0 -1
  636. package/types/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.d.ts +0 -1
  637. package/types/src/blocks/Table/TableExtension.test.d.ts +0 -1
  638. package/types/src/blocks/ToggleWrapper/toggleBlocks.browser.test.d.ts +0 -1
  639. package/types/src/blocks/defaultBlockTypeItems.test.d.ts +0 -1
  640. package/types/src/blocks/defaultBlocks.test.d.ts +0 -1
  641. package/types/src/comments/CommentEditorSubmitExtension.test.d.ts +0 -1
  642. package/types/src/editor/BlockNoteEditor.node.test.d.ts +0 -1
  643. package/types/src/editor/BlockNoteEditor.test.d.ts +0 -1
  644. package/types/src/editor/BlockNoteExtension.test.d.ts +0 -1
  645. package/types/src/editor/blockColors.browser.test.d.ts +0 -1
  646. package/types/src/editor/managers/EventManager.browser.test.d.ts +0 -1
  647. package/types/src/editor/managers/ExtensionManager/ExtensionManager.browser.test.d.ts +0 -1
  648. package/types/src/editor/managers/ExtensionManager/ExtensionManager.node.test.d.ts +0 -1
  649. package/types/src/editor/managers/ExtensionManager/ExtensionManager.test.d.ts +0 -1
  650. package/types/src/editor/managers/StyleManager.browser.test.d.ts +0 -1
  651. package/types/src/editor/managers/StyleManager.test.d.ts +0 -1
  652. package/types/src/editor/performance.test.d.ts +0 -1
  653. package/types/src/editor/transformPasted.test.d.ts +0 -1
  654. package/types/src/exporter/Exporter.test.d.ts +0 -1
  655. package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.test.d.ts +0 -1
  656. package/types/src/extensions/Placeholder/Placeholder.test.d.ts +0 -1
  657. package/types/src/extensions/PreviousBlockType/PreviousBlockType.test.d.ts +0 -1
  658. package/types/src/extensions/ReadOnly/ReadOnly.test.d.ts +0 -1
  659. package/types/src/extensions/SideMenu/blockGeometry.browser.test.d.ts +0 -1
  660. package/types/src/extensions/SideMenu/blockGeometry.test.d.ts +0 -1
  661. package/types/src/extensions/SideMenu/sideMenuHover.test.d.ts +0 -1
  662. package/types/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.d.ts +0 -4
  663. package/types/src/extensions/SuggestionMenu/SuggestionMenu.test.d.ts +0 -1
  664. package/types/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.d.ts +0 -4
  665. package/types/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.d.ts +0 -1
  666. package/types/src/extensions/SyntaxHighlighting/inlineHighlight.test.d.ts +0 -1
  667. package/types/src/extensions/TableHandles/TableHandles.browser.test.d.ts +0 -1
  668. package/types/src/extensions/Versioning/Versioning.browser.test.d.ts +0 -1
  669. package/types/src/extensions/Versioning/Versioning.node.test.d.ts +0 -1
  670. package/types/src/extensions/Versioning/__test__/result.d.ts +0 -3
  671. package/types/src/extensions/Versioning/comparison.test.d.ts +0 -1
  672. package/types/src/extensions/Versioning/createVersioning.test.d.ts +0 -1
  673. package/types/src/extensions/Versioning/inMemoryVersioning.test.d.ts +0 -1
  674. package/types/src/extensions/Versioning/scrollScheduling.test.d.ts +0 -1
  675. package/types/src/extensions/Versioning/scrollToFirstChange.test.d.ts +0 -1
  676. package/types/src/extensions/blockDOM.browser.test.d.ts +0 -1
  677. package/types/src/extensions/blockDOM.test.d.ts +0 -1
  678. package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.d.ts +0 -4
  679. package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/blockIdentity.browser.test.d.ts +0 -1
  680. package/types/src/extensions/tiptap-extensions/Link/link.test.d.ts +0 -1
  681. package/types/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.d.ts +0 -4
  682. package/types/src/fonts/inter.browser.test.d.ts +0 -2
  683. package/types/src/pm-nodes/BlockContainer.test.d.ts +0 -1
  684. package/types/src/schema/blocks/children.test.d.ts +0 -1
  685. package/types/src/schema/blocks/createSpec.browser.test.d.ts +0 -1
  686. package/types/src/schema/blocks/createSpec.test.d.ts +0 -1
  687. package/types/src/schema/blocks/extendBlockSpec.test.d.ts +0 -1
  688. package/types/src/schema/blocks/frame.test.d.ts +0 -1
  689. package/types/src/schema/blocks/internal.test.d.ts +0 -1
  690. package/types/src/schema/blocks/meta.test.d.ts +0 -1
  691. package/types/src/schema/blocks/renderFrame.test.d.ts +0 -1
  692. package/types/src/schema/contentTypePropagation.test.d.ts +0 -1
  693. package/types/src/schema/dataAttributes.test.d.ts +0 -1
  694. package/types/src/schema/inlineContent/createSpec.test.d.ts +0 -1
  695. package/types/src/schema/nodeViewMutations.test.d.ts +0 -1
  696. package/types/src/schema/schema.test.d.ts +0 -1
  697. package/types/src/user/createUserStore.test.d.ts +0 -1
  698. package/types/src/user/userColors.test.d.ts +0 -1
  699. package/types/src/util/Store.test.d.ts +0 -1
  700. package/types/src/util/topo-sort.test.d.ts +0 -1
  701. package/types/src/y/comments/YjsThreadStore.test.d.ts +0 -1
  702. package/types/src/y/extensions/AttributionExtension.test.d.ts +0 -1
  703. package/types/src/y/extensions/DiffVersioningExtension.test.d.ts +0 -1
  704. package/types/src/y/extensions/EmptyDocBinding.test.d.ts +0 -1
  705. package/types/src/y/extensions/ForkYDoc.node.test.d.ts +0 -1
  706. package/types/src/y/extensions/ForkYDoc.test.d.ts +0 -1
  707. package/types/src/y/extensions/History.test.d.ts +0 -1
  708. package/types/src/y/extensions/RelativePositionMapping.test.d.ts +0 -1
  709. package/types/src/y/extensions/Versioning.node.test.d.ts +0 -1
  710. package/types/src/y/extensions/Versioning.test.d.ts +0 -1
  711. package/types/src/y/extensions/YSync.node.test.d.ts +0 -1
  712. package/types/src/y/extensions/YSyncRemount.test.d.ts +0 -1
  713. package/types/src/y/extensions/legacyYjsDocBinding.test.d.ts +0 -1
  714. package/types/src/y/extensions/nestingChanges.test.d.ts +0 -1
  715. package/types/src/y/extensions/persistentBlockGroups.test.d.ts +0 -1
  716. package/types/src/y/extensions/snapshotCodec.test.d.ts +0 -1
  717. package/types/src/y/extensions/snapshotPreview.test.d.ts +0 -1
  718. package/types/src/y/extensions/tableReshape.test.d.ts +0 -1
  719. package/types/src/y/extensions/v1BindingSnapshotDiff.test.d.ts +0 -1
  720. package/types/src/y/extensions/versionDiffAttribution.test.d.ts +0 -1
  721. package/types/src/y/extensions/versionDiffPerformance.test.d.ts +0 -1
  722. package/types/src/y/utils.test.d.ts +0 -1
  723. package/types/src/y/versioning/__test__/yhub.test.d.ts +0 -1
  724. package/types/src/yjs/comments/RESTYjsThreadStore.test.d.ts +0 -1
  725. package/types/src/yjs/comments/YjsThreadStore.test.d.ts +0 -1
  726. package/types/src/yjs/extensions/FixUpSchema.test.d.ts +0 -1
  727. package/types/src/yjs/extensions/ForkYDoc.browser.test.d.ts +0 -1
  728. package/types/src/yjs/extensions/ForkYDoc.node.test.d.ts +0 -1
  729. package/types/src/yjs/extensions/ForkYDoc.test.d.ts +0 -1
  730. package/types/src/yjs/extensions/RelativePositionMapping.test.d.ts +0 -1
  731. package/types/src/yjs/extensions/Versioning.test.d.ts +0 -1
  732. package/types/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.test.d.ts +0 -1
  733. package/types/src/yjs/utils.test.d.ts +0 -1
@@ -1,1870 +0,0 @@
1
- /**
2
- * @vitest-environment jsdom
3
- */
4
-
5
- import { closeHistory } from "@tiptap/pm/history";
6
- import { NodeSelection, Selection, TextSelection } from "prosemirror-state";
7
- import { afterEach, describe, expect, it } from "vite-plus/test";
8
-
9
- import { mergeBlocksCommand } from "../../../api/blockManipulation/commands/mergeBlocks/mergeBlocks.js";
10
- import {
11
- getBlockInfoAt,
12
- getBlockInfoFromSelection,
13
- } from "../../../api/getBlockInfoFromPos.js";
14
- import { getNodeById } from "../../../api/nodeUtil.js";
15
- import { BlockNoteSchema } from "../../../blocks/BlockNoteSchema.js";
16
- import {
17
- defaultBlockSpecs,
18
- type PartialBlock,
19
- } from "../../../blocks/defaultBlocks.js";
20
- import {
21
- BlockNoteEditor,
22
- type BlockNoteEditorOptions,
23
- } from "../../../editor/BlockNoteEditor.js";
24
- import { createBlockSpec } from "../../../schema/index.js";
25
-
26
- // Blocks configured with the deprecated `meta.hardBreakShortcut`, which still
27
- // sets the default of `keyboard.enter` and `keyboard.shiftEnter`.
28
- const createHardBreakTestBlockSpec = <
29
- const T extends string,
30
- const S extends "shift+enter" | "enter" | "none",
31
- const C extends "inline" | "plain",
32
- >(
33
- type: T,
34
- hardBreakShortcut: S,
35
- content: C = "inline" as C,
36
- ) =>
37
- createBlockSpec(
38
- {
39
- type,
40
- propSchema: {},
41
- content,
42
- },
43
- {
44
- meta: {
45
- hardBreakShortcut,
46
- },
47
- render: () => {
48
- const dom = document.createElement("p");
49
- return {
50
- dom,
51
- contentDOM: dom,
52
- };
53
- },
54
- },
55
- )();
56
-
57
- // The same blocks, configured with the `experimental_keyboard` settings that
58
- // replace the
59
- // deprecated `meta.hardBreakShortcut`.
60
- const createKeyboardTestBlockSpec = <
61
- const T extends string,
62
- const C extends "inline" | "plain",
63
- >(
64
- type: T,
65
- keyboard: {
66
- enter?: "split" | "into-children" | "line-break";
67
- shiftEnter?: "line-break" | "same-as-enter";
68
- },
69
- content: C = "inline" as C,
70
- ) =>
71
- createBlockSpec(
72
- {
73
- type,
74
- propSchema: {},
75
- content,
76
- },
77
- {
78
- experimental_keyboard: keyboard,
79
- render: () => {
80
- const dom = document.createElement("p");
81
- return {
82
- dom,
83
- contentDOM: dom,
84
- };
85
- },
86
- },
87
- )();
88
-
89
- // A block whose keyboard function leaves settings `undefined` when a prop is
90
- // off. Those settings must keep their defaults.
91
- const conditionalKeyboardBlock = createBlockSpec(
92
- {
93
- type: "conditionalKeyboard",
94
- propSchema: { on: { default: false } },
95
- content: "inline",
96
- },
97
- {
98
- experimental_keyboard: (block) => ({
99
- enter: block.props.on ? "into-children" : undefined,
100
- resetsTo: block.props.on ? { type: "heading" } : undefined,
101
- }),
102
- render: () => {
103
- const dom = document.createElement("p");
104
- return { dom, contentDOM: dom };
105
- },
106
- },
107
- )();
108
-
109
- const schema = BlockNoteSchema.create({
110
- blockSpecs: {
111
- ...defaultBlockSpecs,
112
- conditionalKeyboard: conditionalKeyboardBlock,
113
- keyboardEnter: createKeyboardTestBlockSpec("keyboardEnter", {
114
- enter: "line-break",
115
- }),
116
- keyboardNone: createKeyboardTestBlockSpec("keyboardNone", {
117
- shiftEnter: "same-as-enter",
118
- }),
119
- keyboardEnterPlain: createKeyboardTestBlockSpec(
120
- "keyboardEnterPlain",
121
- { enter: "line-break" },
122
- "plain",
123
- ),
124
- hardBreakEnter: createHardBreakTestBlockSpec("hardBreakEnter", "enter"),
125
- hardBreakNone: createHardBreakTestBlockSpec("hardBreakNone", "none"),
126
- // "plain" content (`text*`) can't hold a `hardBreak` node, so these blocks
127
- // insert a literal newline character instead - e.g. code/math/diagram source.
128
- hardBreakEnterPlain: createHardBreakTestBlockSpec(
129
- "hardBreakEnterPlain",
130
- "enter",
131
- "plain",
132
- ),
133
- },
134
- });
135
-
136
- function createEditor(
137
- blockType:
138
- | "paragraph"
139
- | "hardBreakEnter"
140
- | "hardBreakNone"
141
- | "hardBreakEnterPlain"
142
- | "keyboardEnter"
143
- | "keyboardNone"
144
- | "keyboardEnterPlain",
145
- ) {
146
- const editor = BlockNoteEditor.create({
147
- schema,
148
- initialContent: [
149
- {
150
- id: "block-0",
151
- type: blockType,
152
- content: "Hello world",
153
- },
154
- ],
155
- });
156
- editor.mount(document.createElement("div"));
157
- editor.setTextCursorPosition("block-0", "end");
158
- return editor;
159
- }
160
-
161
- /**
162
- * Simulates a keyboard shortcut by dispatching a keydown event through the
163
- * editor's `handleKeyDown` props, which is how ProseMirror invokes the
164
- * keymap plugins created by `addKeyboardShortcuts`.
165
- */
166
- function pressKeys(editor: BlockNoteEditor<any, any, any>, keys: string) {
167
- editor._tiptapEditor.commands.keyboardShortcut(keys);
168
- }
169
-
170
- /**
171
- * Dispatches a keydown event straight to the view's handlers. Unlike
172
- * `pressKeys`, whose command loses the selection and stored marks the handler
173
- * sets, this leaves the state as a real key press does. Use it for tests that
174
- * check the caret or the styles of what is typed next.
175
- */
176
- function keyDown(
177
- editor: BlockNoteEditor<any, any, any>,
178
- init: KeyboardEventInit,
179
- ) {
180
- const view = editor._tiptapEditor.view;
181
- view.someProp("handleKeyDown", (handler) =>
182
- handler(view, new KeyboardEvent("keydown", init)),
183
- );
184
- }
185
-
186
- function countHardBreaks(editor: BlockNoteEditor<any, any, any>) {
187
- let count = 0;
188
- editor._tiptapEditor.state.doc.descendants((node) => {
189
- if (node.type.name === "hardBreak") {
190
- count += 1;
191
- }
192
- });
193
- return count;
194
- }
195
-
196
- function getTextContent(editor: BlockNoteEditor<any, any, any>) {
197
- let text = "";
198
- editor._tiptapEditor.state.doc.descendants((node) => {
199
- if (node.isText) {
200
- text += node.text;
201
- }
202
- });
203
- return text;
204
- }
205
-
206
- describe("KeyboardShortcutsExtension Mod-a (select all)", () => {
207
- // BlockNote disables TipTap's core extensions, so it has no default `Mod-a`
208
- // binding and select-all used to rely on the browser's native behaviour. That
209
- // native select-all collapses to a cursor when the editor's first element is
210
- // non-editable - e.g. the checkbox `<div>` of a check list item as the first
211
- // block - so `Mod-a` is now handled explicitly. These tests exercise the
212
- // keymap path (not native selection) and would collapse before the fix.
213
- function createSelectAllEditor(
214
- blocks: PartialBlock<any, any, any>[],
215
- selectAllBehavior?: BlockNoteEditorOptions<
216
- typeof schema.blockSchema,
217
- typeof schema.inlineContentSchema,
218
- typeof schema.styleSchema
219
- >["selectAllBehavior"],
220
- ) {
221
- const editor = BlockNoteEditor.create({
222
- schema,
223
- selectAllBehavior,
224
- initialContent: blocks.map((block, index) => ({
225
- id: `block-${index}`,
226
- ...block,
227
- })),
228
- });
229
- editor.mount(document.createElement("div"));
230
- return editor;
231
- }
232
-
233
- // Dispatches a real `Mod-a` keydown through ProseMirror's `handleKeyDown`, the
234
- // path browsers use to invoke the keymap. TipTap's `keyboardShortcut` command
235
- // doesn't reliably simulate modifier combos in jsdom, and prosemirror-keymap
236
- // resolves `Mod` to `Ctrl` outside of a Mac environment (jsdom reports none).
237
- function pressSelectAll(editor: BlockNoteEditor<any, any, any>) {
238
- const view = editor._tiptapEditor.view;
239
- const event = new KeyboardEvent("keydown", {
240
- key: "a",
241
- code: "KeyA",
242
- ctrlKey: true,
243
- });
244
- view.someProp("handleKeyDown", (handler) => handler(view, event));
245
- }
246
-
247
- function pressBackspace(editor: BlockNoteEditor<any, any, any>) {
248
- const view = editor._tiptapEditor.view;
249
- const event = new KeyboardEvent("keydown", {
250
- key: "Backspace",
251
- code: "Backspace",
252
- });
253
- view.someProp("handleKeyDown", (handler) => handler(view, event));
254
- }
255
-
256
- function expectWholeDocSelected(editor: BlockNoteEditor<any, any, any>) {
257
- const { selection, doc } = editor._tiptapEditor.state;
258
- // Select-all spans all content as a `TextSelection` (from the first
259
- // selectable position to the last), not an `AllSelection`.
260
- expect(selection).toBeInstanceOf(TextSelection);
261
- expect(selection.from).toBe(Selection.atStart(doc).from);
262
- expect(selection.to).toBe(Selection.atEnd(doc).to);
263
- }
264
-
265
- function expectBlockContentSelected(
266
- editor: BlockNoteEditor<any, any, any>,
267
- blockId: string,
268
- ) {
269
- const { selection, doc } = editor._tiptapEditor.state;
270
- const blockInfo = getBlockInfoAt(
271
- doc,
272
- getNodeById(blockId, doc)!.posBeforeNode,
273
- );
274
- if (!blockInfo.hasContent) {
275
- throw new Error(`Block ${blockId} is not a block container`);
276
- }
277
- // The current block's content is selected as a `TextSelection` spanning its
278
- // full content, without reaching into neighbouring blocks.
279
- expect(selection).toBeInstanceOf(TextSelection);
280
- expect(selection.from).toBe(blockInfo.contentStart);
281
- expect(selection.to).toBe(blockInfo.contentEnd);
282
- }
283
-
284
- // Like `expectBlockContentSelected`, but for blocks whose content isn't
285
- // directly inline (e.g. tables), where the selection snaps inward to the
286
- // nearest inline positions rather than sitting exactly on the content bounds.
287
- function expectSelectionWithinBlock(
288
- editor: BlockNoteEditor<any, any, any>,
289
- blockId: string,
290
- ) {
291
- const { selection, doc } = editor._tiptapEditor.state;
292
- const blockInfo = getBlockInfoAt(
293
- doc,
294
- getNodeById(blockId, doc)!.posBeforeNode,
295
- );
296
- if (!blockInfo.hasContent) {
297
- throw new Error(`Block ${blockId} is not a block container`);
298
- }
299
- expect(selection).toBeInstanceOf(TextSelection);
300
- expect(selection.empty).toBe(false);
301
- // The selection stays inside the block's content, without reaching into
302
- // neighbouring blocks.
303
- expect(selection.from).toBeGreaterThanOrEqual(blockInfo.contentStart);
304
- expect(selection.to).toBeLessThanOrEqual(blockInfo.contentEnd);
305
- }
306
-
307
- it("selects the block first when explicitly configured", () => {
308
- const editor = createSelectAllEditor(
309
- [
310
- { type: "paragraph", content: "First" },
311
- { type: "paragraph", content: "Second" },
312
- ],
313
- "block-first",
314
- );
315
- editor.setTextCursorPosition("block-0", "end");
316
-
317
- pressSelectAll(editor);
318
- expectBlockContentSelected(editor, "block-0");
319
-
320
- pressSelectAll(editor);
321
- expectWholeDocSelected(editor);
322
-
323
- editor._tiptapEditor.destroy();
324
- });
325
-
326
- it("selects the whole document immediately when configured", () => {
327
- const editor = createSelectAllEditor(
328
- [
329
- { type: "checkListItem", content: "First" },
330
- { type: "paragraph", content: "Second" },
331
- ],
332
- "document",
333
- );
334
- editor.setTextCursorPosition("block-1", "end");
335
-
336
- pressSelectAll(editor);
337
- expectWholeDocSelected(editor);
338
-
339
- pressSelectAll(editor);
340
- expectWholeDocSelected(editor);
341
-
342
- pressBackspace(editor);
343
- expect(editor.document).toEqual([
344
- expect.objectContaining({ type: "paragraph", content: [] }),
345
- ]);
346
-
347
- editor._tiptapEditor.destroy();
348
- });
349
-
350
- // Each test walks the full Notion-style flow: the first `Mod-a` selects the
351
- // current block, the second expands to the whole document, and Backspace
352
- // clears it (issue #2973 - the bug was specific to documents starting with a
353
- // check list item).
354
- it("escalates the selection and clears a paragraph-first document", () => {
355
- const editor = createSelectAllEditor([
356
- { type: "paragraph", content: "First" },
357
- { type: "paragraph", content: "Second" },
358
- ]);
359
- editor.setTextCursorPosition("block-0", "end");
360
-
361
- pressSelectAll(editor);
362
- expectBlockContentSelected(editor, "block-0");
363
-
364
- pressSelectAll(editor);
365
- expectWholeDocSelected(editor);
366
-
367
- pressBackspace(editor);
368
- expect(editor.document).toEqual([
369
- expect.objectContaining({ type: "paragraph", content: [] }),
370
- ]);
371
-
372
- editor._tiptapEditor.destroy();
373
- });
374
-
375
- it("escalates the selection and clears a check-list-first document", () => {
376
- const editor = createSelectAllEditor([
377
- { type: "checkListItem", content: "First" },
378
- { type: "paragraph", content: "Second" },
379
- ]);
380
- // Cursor starts in a later block to check select-all still spans the whole
381
- // document, not just the current block.
382
- editor.setTextCursorPosition("block-1", "end");
383
-
384
- pressSelectAll(editor);
385
- expectBlockContentSelected(editor, "block-1");
386
-
387
- pressSelectAll(editor);
388
- expectWholeDocSelected(editor);
389
-
390
- pressBackspace(editor);
391
- expect(editor.document).toEqual([
392
- expect.objectContaining({ type: "paragraph", content: [] }),
393
- ]);
394
-
395
- editor._tiptapEditor.destroy();
396
- });
397
-
398
- it("escalates the selection and clears an all-check-list document", () => {
399
- const editor = createSelectAllEditor([
400
- { type: "checkListItem", content: "First" },
401
- { type: "checkListItem", content: "Second" },
402
- ]);
403
- editor.setTextCursorPosition("block-0", "end");
404
-
405
- pressSelectAll(editor);
406
- expectBlockContentSelected(editor, "block-0");
407
-
408
- pressSelectAll(editor);
409
- expectWholeDocSelected(editor);
410
-
411
- pressBackspace(editor);
412
- expect(editor.document).toEqual([
413
- expect.objectContaining({ type: "paragraph", content: [] }),
414
- ]);
415
-
416
- editor._tiptapEditor.destroy();
417
- });
418
-
419
- it("escalates the selection and clears a document ending in a check list item", () => {
420
- const editor = createSelectAllEditor([
421
- { type: "paragraph", content: "First" },
422
- { type: "checkListItem", content: "Second" },
423
- ]);
424
- editor.setTextCursorPosition("block-0", "end");
425
-
426
- pressSelectAll(editor);
427
- expectBlockContentSelected(editor, "block-0");
428
-
429
- pressSelectAll(editor);
430
- expectWholeDocSelected(editor);
431
-
432
- pressBackspace(editor);
433
- expect(editor.document).toEqual([
434
- expect.objectContaining({ type: "paragraph", content: [] }),
435
- ]);
436
-
437
- editor._tiptapEditor.destroy();
438
- });
439
-
440
- it("keeps the block type when clearing a single-block document", () => {
441
- const editor = createSelectAllEditor([
442
- { type: "checkListItem", content: "Only" },
443
- ]);
444
- editor.setTextCursorPosition("block-0", "end");
445
-
446
- pressSelectAll(editor);
447
- expectBlockContentSelected(editor, "block-0");
448
-
449
- pressSelectAll(editor);
450
- expectWholeDocSelected(editor);
451
-
452
- // A single block can only ever have its content selected, so Backspace
453
- // clears the content but (correctly) leaves the block type unchanged.
454
- pressBackspace(editor);
455
- expect(editor.document).toEqual([
456
- expect.objectContaining({ type: "checkListItem", content: [] }),
457
- ]);
458
-
459
- editor._tiptapEditor.destroy();
460
- });
461
-
462
- it("escalates the selection and clears a document containing a table", () => {
463
- const editor = createSelectAllEditor([
464
- { type: "paragraph", content: "Before" },
465
- {
466
- type: "table",
467
- content: {
468
- type: "tableContent",
469
- rows: [{ cells: ["A1", "B1"] }, { cells: ["A2", "B2"] }],
470
- },
471
- },
472
- { type: "paragraph", content: "After" },
473
- ]);
474
- editor.setTextCursorPosition("block-1", "start");
475
-
476
- // A table's content node isn't directly inline, so the first `Mod-a` selects
477
- // across its cells rather than producing an invalid whole-block selection.
478
- pressSelectAll(editor);
479
- expectSelectionWithinBlock(editor, "block-1");
480
-
481
- pressSelectAll(editor);
482
- expectWholeDocSelected(editor);
483
-
484
- pressBackspace(editor);
485
- expect(editor.document).toEqual([
486
- expect.objectContaining({ type: "paragraph", content: [] }),
487
- ]);
488
-
489
- editor._tiptapEditor.destroy();
490
- });
491
- });
492
-
493
- /**
494
- * Characterization tests for the Backspace/Delete/Enter/Tab handlers: they pin
495
- * the current document transformations so the BlockInfo migration inside the
496
- * handlers is provably behavior-preserving.
497
- */
498
- function createEditorWithBlocks(
499
- initialContent: any[],
500
- cursor: { id: string; placement: "start" | "end" },
501
- ) {
502
- const editor = BlockNoteEditor.create({ schema, initialContent });
503
- editor.mount(document.createElement("div"));
504
- editor.setTextCursorPosition(cursor.id, cursor.placement);
505
- return editor;
506
- }
507
-
508
- /** Compact structural view of the document for snapshotting. */
509
- function outline(blocks: any[]): any[] {
510
- return blocks.map((b) => ({
511
- type: b.type,
512
- text: Array.isArray(b.content)
513
- ? b.content.map((c: any) => c.text ?? "").join("")
514
- : undefined,
515
- ...(b.children.length > 0 ? { children: outline(b.children) } : {}),
516
- }));
517
- }
518
-
519
- describe("KeyboardShortcutsExtension Backspace", () => {
520
- it("merges a block into the previous one at block start", () => {
521
- const editor = createEditorWithBlocks(
522
- [
523
- { id: "a", type: "paragraph", content: "Hello" },
524
- { id: "b", type: "paragraph", content: "World" },
525
- ],
526
- { id: "b", placement: "start" },
527
- );
528
-
529
- pressKeys(editor, "Backspace");
530
-
531
- expect(outline(editor.document)).toMatchInlineSnapshot(`
532
- [
533
- {
534
- "text": "HelloWorld",
535
- "type": "paragraph",
536
- },
537
- ]
538
- `);
539
- editor._tiptapEditor.destroy();
540
- });
541
-
542
- it("merges into the previous block's deepest descendant", () => {
543
- const editor = createEditorWithBlocks(
544
- [
545
- {
546
- id: "a",
547
- type: "paragraph",
548
- content: "Parent",
549
- children: [{ id: "a1", type: "paragraph", content: "Nested" }],
550
- },
551
- { id: "b", type: "paragraph", content: "World" },
552
- ],
553
- { id: "b", placement: "start" },
554
- );
555
-
556
- pressKeys(editor, "Backspace");
557
-
558
- expect(outline(editor.document)).toMatchInlineSnapshot(`
559
- [
560
- {
561
- "children": [
562
- {
563
- "text": "NestedWorld",
564
- "type": "paragraph",
565
- },
566
- ],
567
- "text": "Parent",
568
- "type": "paragraph",
569
- },
570
- ]
571
- `);
572
- editor._tiptapEditor.destroy();
573
- });
574
-
575
- it("merges a nested first child into its parent at block start", () => {
576
- const editor = createEditorWithBlocks(
577
- [
578
- {
579
- id: "a",
580
- type: "paragraph",
581
- content: "Parent",
582
- children: [{ id: "a1", type: "paragraph", content: "Nested" }],
583
- },
584
- ],
585
- { id: "a1", placement: "start" },
586
- );
587
-
588
- pressKeys(editor, "Backspace");
589
-
590
- expect(outline(editor.document)).toMatchInlineSnapshot(`
591
- [
592
- {
593
- "text": "ParentNested",
594
- "type": "paragraph",
595
- },
596
- ]
597
- `);
598
- editor._tiptapEditor.destroy();
599
- });
600
-
601
- it("deletes an empty block, moving its children out", () => {
602
- const editor = createEditorWithBlocks(
603
- [
604
- { id: "a", type: "paragraph", content: "Before" },
605
- {
606
- id: "b",
607
- type: "paragraph",
608
- content: "",
609
- children: [{ id: "b1", type: "paragraph", content: "Child" }],
610
- },
611
- ],
612
- { id: "b", placement: "start" },
613
- );
614
-
615
- pressKeys(editor, "Backspace");
616
-
617
- expect(outline(editor.document)).toMatchInlineSnapshot(`
618
- [
619
- {
620
- "text": "Before",
621
- "type": "paragraph",
622
- },
623
- {
624
- "text": "Child",
625
- "type": "paragraph",
626
- },
627
- ]
628
- `);
629
- editor._tiptapEditor.destroy();
630
- });
631
- // The block above isn't rich text, but its last child is: the text joins
632
- // that child, as after any block with children.
633
- it("merges into the last child of a block above whose own content isn't inline", () => {
634
- const editor = createEditorWithBlocks(
635
- [
636
- {
637
- id: "code",
638
- type: "codeBlock",
639
- content: "x",
640
- children: [{ id: "child", type: "paragraph", content: "Child" }],
641
- },
642
- { id: "after", type: "paragraph", content: "After" },
643
- ],
644
- { id: "after", placement: "start" },
645
- );
646
-
647
- pressKeys(editor, "Backspace");
648
-
649
- expect(outline(editor.document)).toMatchInlineSnapshot(`
650
- [
651
- {
652
- "children": [
653
- {
654
- "text": "ChildAfter",
655
- "type": "paragraph",
656
- },
657
- ],
658
- "text": "x",
659
- "type": "codeBlock",
660
- },
661
- ]
662
- `);
663
- editor._tiptapEditor.destroy();
664
- });
665
-
666
- it("does not merge rich text into a code block above", () => {
667
- const editor = createEditorWithBlocks(
668
- [
669
- { id: "code", type: "codeBlock", content: "x" },
670
- { id: "after", type: "paragraph", content: "After" },
671
- ],
672
- { id: "after", placement: "start" },
673
- );
674
-
675
- pressKeys(editor, "Backspace");
676
-
677
- expect(outline(editor.document)).toMatchInlineSnapshot(`
678
- [
679
- {
680
- "text": "x",
681
- "type": "codeBlock",
682
- },
683
- {
684
- "text": "After",
685
- "type": "paragraph",
686
- },
687
- ]
688
- `);
689
- editor._tiptapEditor.destroy();
690
- });
691
-
692
- // #2566: the caret used to jump to the end of the top-level block above,
693
- // instead of the last block nested under it.
694
- it("in an empty block moves the caret to the end of the deepest last block above", () => {
695
- const editor = createEditorWithBlocks(
696
- [
697
- {
698
- id: "list",
699
- type: "bulletListItem",
700
- content: "One",
701
- children: [
702
- { id: "nested", type: "bulletListItem", content: "Two" },
703
- { id: "last", type: "bulletListItem" },
704
- ],
705
- },
706
- { id: "empty", type: "paragraph" },
707
- ],
708
- { id: "empty", placement: "start" },
709
- );
710
-
711
- keyDown(editor, { key: "Backspace", keyCode: 8 });
712
-
713
- expect(editor.getBlock("empty")).toBeUndefined();
714
- expect(editor.getTextCursorPosition().block.id).toBe("last");
715
- editor._tiptapEditor.destroy();
716
- });
717
-
718
- // #605: Backspace in an empty block below an image used to delete the image
719
- // too.
720
- it("in an empty block below a block without content deletes only the empty block", () => {
721
- const editor = createEditorWithBlocks(
722
- [
723
- { id: "image", type: "image" },
724
- { id: "empty", type: "paragraph" },
725
- ],
726
- { id: "empty", placement: "start" },
727
- );
728
-
729
- pressKeys(editor, "Backspace");
730
-
731
- expect(editor.document.map((block) => block.id)).toEqual(["image"]);
732
- editor._tiptapEditor.destroy();
733
- });
734
- it("keeps the default of a keyboard setting given as undefined", () => {
735
- const editor = createEditorWithBlocks(
736
- [{ id: "a", type: "conditionalKeyboard", content: "Text" }],
737
- { id: "a", placement: "start" },
738
- );
739
-
740
- // `resetsTo` is undefined for this block, so the default applies.
741
- pressKeys(editor, "Backspace");
742
-
743
- expect(editor.getBlock("a")!.type).toBe("paragraph");
744
- editor._tiptapEditor.destroy();
745
- });
746
- });
747
-
748
- describe("KeyboardShortcutsExtension Delete", () => {
749
- it("merges the next block in at block end", () => {
750
- const editor = createEditorWithBlocks(
751
- [
752
- { id: "a", type: "paragraph", content: "Hello" },
753
- { id: "b", type: "paragraph", content: "World" },
754
- ],
755
- { id: "a", placement: "end" },
756
- );
757
-
758
- pressKeys(editor, "Delete");
759
-
760
- expect(outline(editor.document)).toMatchInlineSnapshot(`
761
- [
762
- {
763
- "text": "HelloWorld",
764
- "type": "paragraph",
765
- },
766
- ]
767
- `);
768
- editor._tiptapEditor.destroy();
769
- });
770
-
771
- it("merges a next block that has children, un-nesting them", () => {
772
- const editor = createEditorWithBlocks(
773
- [
774
- { id: "a", type: "paragraph", content: "Hello" },
775
- {
776
- id: "b",
777
- type: "paragraph",
778
- content: "World",
779
- children: [
780
- { id: "b1", type: "paragraph", content: "Child 1" },
781
- { id: "b2", type: "paragraph", content: "Child 2" },
782
- ],
783
- },
784
- ],
785
- { id: "a", placement: "end" },
786
- );
787
-
788
- pressKeys(editor, "Delete");
789
-
790
- expect(outline(editor.document)).toMatchInlineSnapshot(`
791
- [
792
- {
793
- "text": "HelloWorld",
794
- "type": "paragraph",
795
- },
796
- {
797
- "text": "Child 1",
798
- "type": "paragraph",
799
- },
800
- {
801
- "text": "Child 2",
802
- "type": "paragraph",
803
- },
804
- ]
805
- `);
806
- editor._tiptapEditor.destroy();
807
- });
808
-
809
- it("removes an empty next block, adopting its children", () => {
810
- const editor = createEditorWithBlocks(
811
- [
812
- { id: "a", type: "paragraph", content: "Hello" },
813
- {
814
- id: "b",
815
- type: "paragraph",
816
- content: "",
817
- children: [{ id: "b1", type: "paragraph", content: "Child" }],
818
- },
819
- ],
820
- { id: "a", placement: "end" },
821
- );
822
-
823
- pressKeys(editor, "Delete");
824
-
825
- expect(outline(editor.document)).toMatchInlineSnapshot(`
826
- [
827
- {
828
- "text": "Hello",
829
- "type": "paragraph",
830
- },
831
- {
832
- "text": "Child",
833
- "type": "paragraph",
834
- },
835
- ]
836
- `);
837
- editor._tiptapEditor.destroy();
838
- });
839
-
840
- it("removes an empty current block on Delete", () => {
841
- const editor = createEditorWithBlocks(
842
- [
843
- { id: "a", type: "paragraph", content: "" },
844
- { id: "b", type: "paragraph", content: "After" },
845
- ],
846
- { id: "a", placement: "start" },
847
- );
848
-
849
- pressKeys(editor, "Delete");
850
-
851
- expect(outline(editor.document)).toMatchInlineSnapshot(`
852
- [
853
- {
854
- "text": "After",
855
- "type": "paragraph",
856
- },
857
- ]
858
- `);
859
- editor._tiptapEditor.destroy();
860
- });
861
- });
862
-
863
- describe("KeyboardShortcutsExtension Enter", () => {
864
- it("lifts an empty nested block on Enter", () => {
865
- const editor = createEditorWithBlocks(
866
- [
867
- {
868
- id: "a",
869
- type: "paragraph",
870
- content: "Parent",
871
- children: [{ id: "a1", type: "paragraph", content: "" }],
872
- },
873
- ],
874
- { id: "a1", placement: "start" },
875
- );
876
-
877
- pressKeys(editor, "Enter");
878
-
879
- expect(outline(editor.document)).toMatchInlineSnapshot(`
880
- [
881
- {
882
- "text": "Parent",
883
- "type": "paragraph",
884
- },
885
- {
886
- "text": "",
887
- "type": "paragraph",
888
- },
889
- ]
890
- `);
891
- editor._tiptapEditor.destroy();
892
- });
893
- });
894
-
895
- describe("KeyboardShortcutsExtension Shift-Tab", () => {
896
- it("un-nests a nested block", () => {
897
- const editor = createEditorWithBlocks(
898
- [
899
- {
900
- id: "a",
901
- type: "paragraph",
902
- content: "Parent",
903
- children: [{ id: "a1", type: "paragraph", content: "Nested" }],
904
- },
905
- ],
906
- { id: "a1", placement: "start" },
907
- );
908
-
909
- pressKeys(editor, "Shift-Tab");
910
-
911
- expect(outline(editor.document)).toMatchInlineSnapshot(`
912
- [
913
- {
914
- "text": "Parent",
915
- "type": "paragraph",
916
- },
917
- {
918
- "text": "Nested",
919
- "type": "paragraph",
920
- },
921
- ]
922
- `);
923
- editor._tiptapEditor.destroy();
924
- });
925
- });
926
-
927
- describe("KeyboardShortcutsExtension line breaks", () => {
928
- it("inserts a hard break on Shift-Enter by default", () => {
929
- const editor = createEditor("paragraph");
930
-
931
- pressKeys(editor, "Shift-Enter");
932
-
933
- expect(countHardBreaks(editor)).toBe(1);
934
- expect(editor.document.length).toBe(1);
935
-
936
- editor._tiptapEditor.destroy();
937
- });
938
-
939
- // #1672: text typed after the line break used to lose the styles of the
940
- // text before it.
941
- it("keeps the styles of the text before the line break", () => {
942
- const editor = createEditorWithBlocks(
943
- [
944
- {
945
- id: "p",
946
- type: "paragraph",
947
- content: [
948
- { type: "text", text: "Red", styles: { textColor: "red" } },
949
- ],
950
- },
951
- ],
952
- { id: "p", placement: "end" },
953
- );
954
-
955
- keyDown(editor, { key: "Enter", keyCode: 13, shiftKey: true });
956
- // Typing: `insertText` takes the stored marks, as the browser input does.
957
- const view = editor._tiptapEditor.view;
958
- view.dispatch(view.state.tr.insertText("x"));
959
-
960
- expect(editor.getBlock("p")!.content).toEqual([
961
- { type: "text", text: "Red\nx", styles: { textColor: "red" } },
962
- ]);
963
- editor._tiptapEditor.destroy();
964
- });
965
-
966
- it("splits the block on Enter by default", () => {
967
- const editor = createEditor("paragraph");
968
-
969
- pressKeys(editor, "Enter");
970
-
971
- expect(countHardBreaks(editor)).toBe(0);
972
- expect(editor.document.length).toBe(2);
973
-
974
- editor._tiptapEditor.destroy();
975
- });
976
- });
977
-
978
- describe.each([
979
- {
980
- setting: "meta.hardBreakShortcut (deprecated)",
981
- enter: "hardBreakEnter",
982
- none: "hardBreakNone",
983
- plain: "hardBreakEnterPlain",
984
- },
985
- {
986
- setting: "keyboard",
987
- enter: "keyboardEnter",
988
- none: "keyboardNone",
989
- plain: "keyboardEnterPlain",
990
- },
991
- ] as const)(
992
- "hard breaks configured with $setting",
993
- ({ enter, none, plain }) => {
994
- it("inserts a hard break on Enter when Enter makes line breaks", () => {
995
- const editor = createEditor(enter);
996
-
997
- pressKeys(editor, "Enter");
998
-
999
- expect(countHardBreaks(editor)).toBe(1);
1000
- expect(editor.document.length).toBe(1);
1001
-
1002
- editor._tiptapEditor.destroy();
1003
- });
1004
-
1005
- it("inserts a hard break on Shift-Enter when Enter makes line breaks", () => {
1006
- const editor = createEditor(enter);
1007
-
1008
- pressKeys(editor, "Shift-Enter");
1009
-
1010
- expect(countHardBreaks(editor)).toBe(1);
1011
- expect(editor.document.length).toBe(1);
1012
-
1013
- editor._tiptapEditor.destroy();
1014
- });
1015
-
1016
- it("does not insert a hard break on Shift-Enter when it acts as Enter", () => {
1017
- const editor = createEditor(none);
1018
-
1019
- pressKeys(editor, "Shift-Enter");
1020
-
1021
- expect(countHardBreaks(editor)).toBe(0);
1022
-
1023
- editor._tiptapEditor.destroy();
1024
- });
1025
-
1026
- it("splits the block on Enter when Shift-Enter acts as Enter", () => {
1027
- const editor = createEditor(none);
1028
-
1029
- pressKeys(editor, "Enter");
1030
-
1031
- expect(countHardBreaks(editor)).toBe(0);
1032
- expect(editor.document.length).toBe(2);
1033
-
1034
- editor._tiptapEditor.destroy();
1035
- });
1036
-
1037
- it('inserts a newline character on Enter when content is "plain"', () => {
1038
- const editor = createEditor(plain);
1039
-
1040
- pressKeys(editor, "Enter");
1041
-
1042
- // A "plain" block can't hold a `hardBreak` node, so no node is inserted and
1043
- // the block is not split - a literal newline is added to its text instead.
1044
- expect(countHardBreaks(editor)).toBe(0);
1045
- expect(editor.document.length).toBe(1);
1046
- expect(getTextContent(editor)).toBe("Hello world\n");
1047
-
1048
- editor._tiptapEditor.destroy();
1049
- });
1050
-
1051
- it('inserts a newline character on Shift-Enter when content is "plain"', () => {
1052
- const editor = createEditor(plain);
1053
-
1054
- pressKeys(editor, "Shift-Enter");
1055
-
1056
- expect(countHardBreaks(editor)).toBe(0);
1057
- expect(editor.document.length).toBe(1);
1058
- expect(getTextContent(editor)).toBe("Hello world\n");
1059
-
1060
- editor._tiptapEditor.destroy();
1061
- });
1062
- },
1063
- );
1064
-
1065
- describe("Delete preserves the caret before appended text", () => {
1066
- function paragraph(id: string, children: PartialBlock[] = []): PartialBlock {
1067
- return { id, type: "paragraph", content: id, children };
1068
- }
1069
-
1070
- it.each([
1071
- {
1072
- name: "sole child",
1073
- initialContent: [paragraph("selected", [paragraph("removed")])],
1074
- },
1075
- {
1076
- name: "following shallower block",
1077
- initialContent: [
1078
- paragraph("parent", [paragraph("selected")]),
1079
- paragraph("removed"),
1080
- ],
1081
- },
1082
- ])("$name", ({ initialContent }) => {
1083
- const editor = BlockNoteEditor.create({ initialContent });
1084
- editor.mount(document.createElement("div"));
1085
- editor.setTextCursorPosition("selected", "end");
1086
-
1087
- const view = editor.prosemirrorView;
1088
- const event = new KeyboardEvent("keydown", {
1089
- key: "Delete",
1090
- code: "Delete",
1091
- keyCode: 46,
1092
- });
1093
- view.someProp("handleKeyDown", (handler) => handler(view, event));
1094
-
1095
- expect(editor.getBlock("removed")).toBeUndefined();
1096
- expect(editor.getTextCursorPosition().block.id).toBe("selected");
1097
- expect(editor.prosemirrorState.selection.$from.parentOffset).toBe(
1098
- "selected".length,
1099
- );
1100
- editor._tiptapEditor.destroy();
1101
- });
1102
- });
1103
-
1104
- describe("KeyboardShortcutsExtension Backspace", () => {
1105
- let editor: BlockNoteEditor | undefined;
1106
-
1107
- afterEach(() => {
1108
- editor?._tiptapEditor.destroy();
1109
- editor = undefined;
1110
- });
1111
-
1112
- function createEditor(
1113
- content: string,
1114
- type:
1115
- | "paragraph"
1116
- | "bulletListItem"
1117
- | "numberedListItem"
1118
- | "checkListItem" = "paragraph",
1119
- ) {
1120
- const instance = BlockNoteEditor.create({
1121
- trailingBlock: false,
1122
- initialContent: [
1123
- {
1124
- id: "parent",
1125
- content: "Parent",
1126
- children: [
1127
- { id: "before", content: "Before" },
1128
- { id: "current", type, content },
1129
- { id: "after", content: "After" },
1130
- ],
1131
- },
1132
- ],
1133
- });
1134
- editor = instance;
1135
- instance.mount(document.createElement("div"));
1136
- instance.setTextCursorPosition("current", "start");
1137
- return instance;
1138
- }
1139
-
1140
- function pressKey(
1141
- instance: BlockNoteEditor,
1142
- key: "Backspace" | "Shift-Tab" | "Delete",
1143
- ) {
1144
- const event = new KeyboardEvent("keydown", {
1145
- key: key === "Shift-Tab" ? "Tab" : key,
1146
- shiftKey: key === "Shift-Tab",
1147
- bubbles: true,
1148
- cancelable: true,
1149
- });
1150
- const view = instance.prosemirrorView;
1151
- view.someProp("handleKeyDown", (handler) => handler(view, event));
1152
- }
1153
-
1154
- function expectUnindented(instance: BlockNoteEditor) {
1155
- expect(instance.document.map((block) => block.id)).toEqual([
1156
- "parent",
1157
- "current",
1158
- ]);
1159
- expect(
1160
- instance.getBlock("parent")?.children.map((block) => block.id),
1161
- ).toEqual(["before"]);
1162
- expect(
1163
- instance.getBlock("current")?.children.map((block) => block.id),
1164
- ).toEqual(["after"]);
1165
- }
1166
-
1167
- describe.each(["", "Current"])("Backspace with content %j", (content) => {
1168
- it("merges without changing following siblings' nesting", () => {
1169
- const instance = createEditor(content);
1170
- pressKey(instance, "Backspace");
1171
-
1172
- expect(instance.document.map((block) => block.id)).toEqual(["parent"]);
1173
- expect(
1174
- instance.getBlock("parent")?.children.map((block) => block.id),
1175
- ).toEqual(["before", "after"]);
1176
- expect(instance.getBlock("current")).toBeUndefined();
1177
- expect(instance.getBlock("before")?.content).toEqual([
1178
- { type: "text", text: `Before${content}`, styles: {} },
1179
- ]);
1180
- expect(instance.getTextCursorPosition().block.id).toBe("before");
1181
- });
1182
- });
1183
-
1184
- it("still unindents with Shift-Tab", () => {
1185
- const instance = createEditor("Current");
1186
- pressKey(instance, "Shift-Tab");
1187
- expectUnindented(instance);
1188
- });
1189
-
1190
- it.each(["bulletListItem", "numberedListItem", "checkListItem"] as const)(
1191
- "converts %s to a paragraph before merging",
1192
- (type) => {
1193
- const instance = createEditor("Current", type);
1194
- pressKey(instance, "Backspace");
1195
- expect(instance.getBlock("current")?.type).toBe("paragraph");
1196
- expect(
1197
- instance.getBlock("parent")?.children.map((block) => block.id),
1198
- ).toEqual(["before", "current", "after"]);
1199
- pressKey(instance, "Backspace");
1200
- expect(instance.getBlock("current")).toBeUndefined();
1201
- expect(instance.getBlock("before")?.content).toEqual([
1202
- { type: "text", text: "BeforeCurrent", styles: {} },
1203
- ]);
1204
- },
1205
- );
1206
-
1207
- it("does not merge when the cursor is inside the block", () => {
1208
- const instance = createEditor("Current");
1209
- instance.setTextCursorPosition("current", "end");
1210
- // The shortcut must leave normal character deletion to the browser.
1211
- pressKey(instance, "Backspace");
1212
- expect(
1213
- instance.getBlock("parent")?.children.map((block) => block.id),
1214
- ).toEqual(["before", "current", "after"]);
1215
- expect(instance.getBlock("current")?.content).toEqual([
1216
- { type: "text", text: "Current", styles: {} },
1217
- ]);
1218
- });
1219
-
1220
- function createScenario(initialContent: PartialBlock[]) {
1221
- const instance = createEditor("");
1222
- instance.replaceBlocks(instance.document, initialContent);
1223
- instance.setTextCursorPosition("current", "start");
1224
- return instance;
1225
- }
1226
-
1227
- describe.each(["paragraph", "image", "table"] as const)(
1228
- "first child of %s",
1229
- (type) => {
1230
- it.each([false, true])(
1231
- "deletes an empty first child (only child: %s)",
1232
- (onlyChild) => {
1233
- const instance = createScenario([
1234
- {
1235
- id: "parent",
1236
- ...parentSpec(type),
1237
- children: [
1238
- { id: "current", content: "" },
1239
- ...(onlyChild ? [] : [{ id: "after", content: "After" }]),
1240
- ],
1241
- },
1242
- ]);
1243
- pressKey(instance, "Backspace");
1244
- expect(instance.getBlock("current")).toBeUndefined();
1245
- expect(
1246
- instance.getBlock("parent")?.children.map((block) => block.id),
1247
- ).toEqual(onlyChild ? [] : ["after"]);
1248
- expect(instance.getBlock("parent")?.type).toBe(type);
1249
- expectSelectionAtEnd(instance, "parent", type);
1250
- instance.prosemirrorView.state.doc.check();
1251
- },
1252
- );
1253
-
1254
- it("preserves descendants when removing an empty first child", () => {
1255
- const instance = createScenario([
1256
- {
1257
- id: "parent",
1258
- ...parentSpec(type),
1259
- children: [
1260
- {
1261
- id: "current",
1262
- children: [{ id: "grandchild", content: "Keep me" }],
1263
- },
1264
- { id: "after", content: "After" },
1265
- ],
1266
- },
1267
- ]);
1268
- pressKey(instance, "Backspace");
1269
- expect(instance.getBlock("current")).toBeUndefined();
1270
- expect(
1271
- instance.getBlock("parent")?.children.map((block) => block.id),
1272
- ).toEqual(["grandchild", "after"]);
1273
- expect(instance.getBlock("grandchild")?.content).toEqual([
1274
- { type: "text", text: "Keep me", styles: {} },
1275
- ]);
1276
- instance.prosemirrorView.state.doc.check();
1277
- expectSelectionAtEnd(instance, "parent", type);
1278
- });
1279
- },
1280
- );
1281
-
1282
- it("merges into a paragraph nested under a non-text previous sibling", () => {
1283
- const instance = createScenario([
1284
- {
1285
- id: "parent",
1286
- content: "Parent",
1287
- children: [
1288
- {
1289
- id: "image",
1290
- type: "image",
1291
- children: [{ id: "target", content: "Target" }],
1292
- },
1293
- { id: "current", content: "Current" },
1294
- { id: "after", content: "After" },
1295
- ],
1296
- },
1297
- ]);
1298
- pressKey(instance, "Backspace");
1299
- expect(instance.getBlock("current")).toBeUndefined();
1300
- expect(instance.getBlock("target")?.content).toEqual([
1301
- { type: "text", text: "TargetCurrent", styles: {} },
1302
- ]);
1303
- expect(
1304
- instance.getBlock("parent")?.children.map((block) => block.id),
1305
- ).toEqual(["image", "after"]);
1306
- });
1307
-
1308
- it("keeps the only root block", () => {
1309
- const instance = createScenario([{ id: "current", content: "" }]);
1310
- pressKey(instance, "Backspace");
1311
- expect(instance.document.map((block) => block.id)).toEqual(["current"]);
1312
- });
1313
-
1314
- it.each(["", "Parent"])(
1315
- "merges the first child's text into parent %j",
1316
- (content) => {
1317
- const instance = createScenario([
1318
- {
1319
- id: "parent",
1320
- content,
1321
- children: [
1322
- {
1323
- id: "current",
1324
- content: "Current",
1325
- children: [{ id: "grandchild", content: "Keep" }],
1326
- },
1327
- { id: "after", content: "After" },
1328
- ],
1329
- },
1330
- ]);
1331
- pressKey(instance, "Backspace");
1332
- expect(instance.getBlock("current")).toBeUndefined();
1333
- expect(instance.getBlock("parent")?.content).toEqual([
1334
- { type: "text", text: `${content}Current`, styles: {} },
1335
- ]);
1336
- expect(
1337
- instance.getBlock("parent")?.children.map((block) => block.id),
1338
- ).toEqual(["grandchild", "after"]);
1339
- expect(instance.getTextCursorPosition().block.id).toBe("parent");
1340
- expect(instance.prosemirrorView.state.selection.$from.parentOffset).toBe(
1341
- content.length,
1342
- );
1343
- },
1344
- );
1345
-
1346
- it("unindents nonempty first children of non-text parents without losing text", () => {
1347
- const instance = createScenario([
1348
- {
1349
- id: "parent",
1350
- type: "image",
1351
- children: [{ id: "current", content: "Keep" }],
1352
- },
1353
- ]);
1354
- pressKey(instance, "Backspace");
1355
- expect(instance.document.map((block) => block.id)).toEqual([
1356
- "parent",
1357
- "current",
1358
- ]);
1359
- expect(instance.getBlock("current")?.content).toEqual([
1360
- { type: "text", text: "Keep", styles: {} },
1361
- ]);
1362
- });
1363
-
1364
- it.each(["", "Current"])(
1365
- "handles an empty previous sibling with current text %j",
1366
- (content) => {
1367
- const instance = createScenario([
1368
- {
1369
- id: "parent",
1370
- content: "Parent",
1371
- children: [
1372
- { id: "before", content: "", props: { textAlignment: "right" } },
1373
- { id: "current", content },
1374
- { id: "after", content: "After" },
1375
- ],
1376
- },
1377
- ]);
1378
- pressKey(instance, "Backspace");
1379
- expect(
1380
- instance.getBlock("parent")?.children.map((block) => block.id),
1381
- ).toEqual(["before", "after"]);
1382
- instance.prosemirrorView.state.doc.check();
1383
- expect(instance.getTextCursorPosition().block.id).toBe("before");
1384
- expect(instance.getBlock("before")?.props).toMatchObject({
1385
- textAlignment: "right",
1386
- });
1387
- expect(instance.getBlock("before")?.content).toEqual(
1388
- content ? [{ type: "text", text: content, styles: {} }] : [],
1389
- );
1390
- expect(instance.prosemirrorView.state.selection.$from.parentOffset).toBe(
1391
- 0,
1392
- );
1393
- },
1394
- );
1395
-
1396
- it("unindents nonempty blocks after a table when merging is impossible", () => {
1397
- const instance = createScenario([
1398
- {
1399
- id: "parent",
1400
- content: "Parent",
1401
- children: [
1402
- {
1403
- id: "table",
1404
- type: "table",
1405
- content: { type: "tableContent", rows: [{ cells: ["Cell"] }] },
1406
- },
1407
- { id: "current", content: "Keep" },
1408
- ],
1409
- },
1410
- ]);
1411
- pressKey(instance, "Backspace");
1412
- expect(instance.document.map((block) => block.id)).toEqual([
1413
- "parent",
1414
- "current",
1415
- ]);
1416
- expect(instance.getBlock("table")?.type).toBe("table");
1417
- expect(instance.getBlock("current")?.content).toEqual([
1418
- { type: "text", text: "Keep", styles: {} },
1419
- ]);
1420
- });
1421
-
1422
- it.each(["image", "table"] as const)(
1423
- "deletes empty blocks after %s while preserving descendants",
1424
- (type) => {
1425
- const previous: PartialBlock =
1426
- type === "table"
1427
- ? {
1428
- id: "previous",
1429
- type,
1430
- content: { type: "tableContent", rows: [{ cells: ["Cell"] }] },
1431
- }
1432
- : { id: "previous", type };
1433
- const instance = createScenario([
1434
- {
1435
- id: "parent",
1436
- content: "Parent",
1437
- children: [
1438
- previous,
1439
- {
1440
- id: "current",
1441
- children: [{ id: "grandchild", content: "Keep" }],
1442
- },
1443
- { id: "after", content: "After" },
1444
- ],
1445
- },
1446
- ]);
1447
- pressKey(instance, "Backspace");
1448
- expect(instance.getBlock("current")).toBeUndefined();
1449
- expect(
1450
- instance.getBlock("parent")?.children.map((block) => block.id),
1451
- ).toEqual(["previous", "grandchild", "after"]);
1452
- expectSelectionAtEnd(instance, "previous", type);
1453
- expect(instance.getBlock("grandchild")?.content).toEqual([
1454
- { type: "text", text: "Keep", styles: {} },
1455
- ]);
1456
- instance.prosemirrorView.state.doc.check();
1457
- },
1458
- );
1459
-
1460
- it("merges a deeply nested only child and can undo the operation", () => {
1461
- const instance = createScenario([
1462
- {
1463
- id: "root",
1464
- content: "Root",
1465
- children: [
1466
- {
1467
- id: "parent",
1468
- content: "Parent",
1469
- children: [{ id: "current", content: "Current" }],
1470
- },
1471
- ],
1472
- },
1473
- ]);
1474
- const before = instance.document;
1475
- instance.prosemirrorView.dispatch(
1476
- closeHistory(instance.prosemirrorView.state.tr),
1477
- );
1478
- pressKey(instance, "Backspace");
1479
- expect(instance.getBlock("current")).toBeUndefined();
1480
- expect(instance.getBlock("parent")?.children).toEqual([]);
1481
- expect(instance.getBlock("parent")?.content).toEqual([
1482
- { type: "text", text: "ParentCurrent", styles: {} },
1483
- ]);
1484
- expect(instance.prosemirrorView.state.selection.$from.parentOffset).toBe(6);
1485
- instance.undo();
1486
- expect(instance.document).toEqual(before);
1487
- });
1488
-
1489
- it.each(["", "Current"])(
1490
- "the merge command handles a first child with text %j directly",
1491
- (content) => {
1492
- const instance = createScenario([
1493
- {
1494
- id: "parent",
1495
- content: "Parent",
1496
- children: [
1497
- { id: "current", content },
1498
- { id: "after", content: "After" },
1499
- ],
1500
- },
1501
- ]);
1502
- const pos = getBlockInfoFromSelection(instance.prosemirrorView.state)
1503
- .block.beforePos;
1504
- const command = mergeBlocksCommand(pos);
1505
- const before = instance.document;
1506
- expect(instance._tiptapEditor.can().command(command)).toBe(true);
1507
- expect(instance.document).toEqual(before);
1508
- expect(instance._tiptapEditor.commands.command(command)).toBe(true);
1509
- expect(instance.getBlock("current")).toBeUndefined();
1510
- expect(instance.getBlock("parent")?.content).toEqual([
1511
- { type: "text", text: `Parent${content}`, styles: {} },
1512
- ]);
1513
- expect(
1514
- instance.getBlock("parent")?.children.map((block) => block.id),
1515
- ).toEqual(["after"]);
1516
- },
1517
- );
1518
-
1519
- it("the merge command rejects incompatible parents without mutating", () => {
1520
- const instance = createScenario([
1521
- {
1522
- id: "parent",
1523
- type: "image",
1524
- children: [{ id: "current", content: "Keep" }],
1525
- },
1526
- ]);
1527
- const pos = getBlockInfoFromSelection(instance.prosemirrorView.state).block
1528
- .beforePos;
1529
- const before = instance.document;
1530
- expect(
1531
- instance._tiptapEditor.commands.command(mergeBlocksCommand(pos)),
1532
- ).toBe(false);
1533
- expect(instance.document).toEqual(before);
1534
- });
1535
-
1536
- it.each(["image", "table"] as const)(
1537
- "the merge command rejects %s on either side and as a parent",
1538
- (type) => {
1539
- const nonText: PartialBlock =
1540
- type === "image"
1541
- ? { id: "non-text", type }
1542
- : {
1543
- id: "non-text",
1544
- type,
1545
- content: { type: "tableContent", rows: [{ cells: ["Cell"] }] },
1546
- };
1547
- const instance = createScenario([{ id: "current", content: "" }]);
1548
- for (const content of ["", "Text"]) {
1549
- for (const blocks of [
1550
- [nonText, { id: "current", content }],
1551
- [
1552
- { id: "text", content },
1553
- { ...nonText, id: "current" },
1554
- ],
1555
- [{ ...nonText, children: [{ id: "current", content }] }],
1556
- ]) {
1557
- instance.replaceBlocks(instance.document, blocks);
1558
- const pos = instance.prosemirrorView.state.doc;
1559
- let beforePos: number | undefined;
1560
- pos.descendants((node, position) => {
1561
- if (node.attrs.id === "current") {
1562
- beforePos = position;
1563
- }
1564
- });
1565
- if (beforePos === undefined) {
1566
- throw new Error("Missing test block");
1567
- }
1568
- const before = instance.document;
1569
- const command = mergeBlocksCommand(beforePos);
1570
- expect(instance._tiptapEditor.can().command(command)).toBe(false);
1571
- expect(instance._tiptapEditor.commands.command(command)).toBe(false);
1572
- expect(instance.document).toEqual(before);
1573
- }
1574
- }
1575
- },
1576
- );
1577
-
1578
- function expectSelectionAtEnd(
1579
- instance: BlockNoteEditor,
1580
- id: string,
1581
- type: "paragraph" | "image" | "table",
1582
- ) {
1583
- expect(instance.getTextCursorPosition().block.id).toBe(id);
1584
- const selection = instance.prosemirrorView.state.selection;
1585
- if (type === "image") {
1586
- expect(selection).toBeInstanceOf(NodeSelection);
1587
- } else {
1588
- expect(selection).toBeInstanceOf(TextSelection);
1589
- expect(selection.empty).toBe(true);
1590
- expect(selection.$from.parentOffset).toBe(
1591
- selection.$from.parent.content.size,
1592
- );
1593
- if (type === "table") {
1594
- expect(["Cell", "Last"]).toContain(selection.$from.parent.textContent);
1595
- expect(
1596
- selection.$from.node(selection.$from.depth - 1).type.name,
1597
- ).toMatch(/table.*Cell/i);
1598
- }
1599
- }
1600
- }
1601
-
1602
- it("replaces a preceding image with a nonempty paragraph and keeps its descendants", () => {
1603
- const instance = createScenario([
1604
- {
1605
- id: "parent",
1606
- content: "Parent",
1607
- children: [
1608
- { id: "image", type: "image" },
1609
- {
1610
- id: "current",
1611
- content: "Keep",
1612
- children: [{ id: "child", content: "Child" }],
1613
- },
1614
- { id: "after", content: "After" },
1615
- ],
1616
- },
1617
- ]);
1618
- const current = instance.getBlock("current");
1619
- pressKey(instance, "Backspace");
1620
- expect(instance.getBlock("image")).toBeUndefined();
1621
- expect(instance.getBlock("current")).toEqual(current);
1622
- expect(
1623
- instance.getBlock("parent")?.children.map((block) => block.id),
1624
- ).toEqual(["current", "after"]);
1625
- expect(instance.getTextCursorPosition().block.id).toBe("current");
1626
- expect(instance.prosemirrorView.state.selection.$from.parentOffset).toBe(0);
1627
- });
1628
-
1629
- it("deletes selected text before attempting to merge or unindent", () => {
1630
- const instance = createEditor("Current");
1631
- const start = instance.prosemirrorView.state.selection.from;
1632
- instance.prosemirrorView.dispatch(
1633
- instance.prosemirrorView.state.tr.setSelection(
1634
- TextSelection.create(
1635
- instance.prosemirrorView.state.doc,
1636
- start,
1637
- start + 3,
1638
- ),
1639
- ),
1640
- );
1641
- pressKey(instance, "Backspace");
1642
- expect(instance.getBlock("current")?.content).toEqual([
1643
- { type: "text", text: "rent", styles: {} },
1644
- ]);
1645
- expect(
1646
- instance.getBlock("parent")?.children.map((block) => block.id),
1647
- ).toEqual(["before", "current", "after"]);
1648
- });
1649
-
1650
- it("Delete still merges forward", () => {
1651
- const instance = createEditor("Current");
1652
- instance.setTextCursorPosition("before", "end");
1653
- pressKey(instance, "Delete");
1654
- expect(instance.getBlock("current")).toBeUndefined();
1655
- expect(instance.getBlock("before")?.content).toEqual([
1656
- { type: "text", text: "BeforeCurrent", styles: {} },
1657
- ]);
1658
- expect(
1659
- instance.getBlock("parent")?.children.map((block) => block.id),
1660
- ).toEqual(["before", "after"]);
1661
- });
1662
-
1663
- it.each(["image", "table"] as const)(
1664
- "promotes descendants of an empty only child under %s and supports undo",
1665
- (type) => {
1666
- const instance = createScenario([
1667
- {
1668
- id: "parent",
1669
- ...parentSpec(type),
1670
- children: [
1671
- {
1672
- id: "current",
1673
- children: [
1674
- {
1675
- id: "child",
1676
- content: "Keep",
1677
- children: [{ id: "grandchild", content: "Deep" }],
1678
- },
1679
- ],
1680
- },
1681
- ],
1682
- },
1683
- ]);
1684
- const before = instance.document;
1685
- const child = instance.getBlock("child");
1686
- instance.prosemirrorView.dispatch(
1687
- closeHistory(instance.prosemirrorView.state.tr),
1688
- );
1689
- pressKey(instance, "Backspace");
1690
- expect(
1691
- instance.getBlock("parent")?.children.map((block) => block.id),
1692
- ).toEqual(["child"]);
1693
- expect(instance.getBlock("child")).toEqual(child);
1694
- expectSelectionAtEnd(instance, "parent", type);
1695
- instance.prosemirrorView.state.doc.check();
1696
- instance.undo();
1697
- expect(instance.document).toEqual(before);
1698
- },
1699
- );
1700
-
1701
- function parentSpec(type: "paragraph" | "image" | "table"): PartialBlock {
1702
- if (type === "table") {
1703
- return {
1704
- type,
1705
- content: { type: "tableContent", rows: [{ cells: ["First", "Last"] }] },
1706
- };
1707
- }
1708
- return { type };
1709
- }
1710
-
1711
- it("selects the last cell of a deeply nested preceding table", () => {
1712
- const instance = createScenario([
1713
- {
1714
- id: "parent",
1715
- content: "Parent",
1716
- children: [
1717
- {
1718
- id: "before",
1719
- content: "Before",
1720
- children: [
1721
- {
1722
- id: "table",
1723
- type: "table",
1724
- content: {
1725
- type: "tableContent",
1726
- rows: [{ cells: ["A", "B"] }, { cells: ["C", "Last"] }],
1727
- },
1728
- },
1729
- ],
1730
- },
1731
- { id: "current" },
1732
- { id: "after", content: "After" },
1733
- ],
1734
- },
1735
- ]);
1736
- pressKey(instance, "Backspace");
1737
- expect(instance.getBlock("current")).toBeUndefined();
1738
- expect(
1739
- instance.getBlock("parent")?.children.map((block) => block.id),
1740
- ).toEqual(["before", "after"]);
1741
- expectSelectionAtEnd(instance, "table", "table");
1742
- });
1743
-
1744
- it("preserves inline styles and target properties when merging into the parent", () => {
1745
- const instance = createScenario([
1746
- {
1747
- id: "parent",
1748
- props: { textAlignment: "right" },
1749
- content: [{ type: "text", text: "Parent", styles: { bold: true } }],
1750
- children: [
1751
- {
1752
- id: "current",
1753
- props: { textAlignment: "center" },
1754
- content: [
1755
- { type: "text", text: "Child", styles: { italic: true } },
1756
- ],
1757
- },
1758
- ],
1759
- },
1760
- ]);
1761
- pressKey(instance, "Backspace");
1762
- expect(instance.getBlock("parent")?.props).toMatchObject({
1763
- textAlignment: "right",
1764
- });
1765
- expect(instance.getBlock("parent")?.content).toEqual([
1766
- { type: "text", text: "Parent", styles: { bold: true } },
1767
- { type: "text", text: "Child", styles: { italic: true } },
1768
- ]);
1769
- expect(instance.getBlock("current")).toBeUndefined();
1770
- });
1771
-
1772
- it.each([false, true])(
1773
- "matches PR examples 2 and 4 (previous block has children: %s)",
1774
- (nestedTarget) => {
1775
- const instance = createScenario([
1776
- {
1777
- id: "parent",
1778
- content: "Parent",
1779
- children: nestedTarget ? [{ id: "target", content: "Target" }] : [],
1780
- },
1781
- {
1782
- id: "current",
1783
- content: "Current",
1784
- children: [{ id: "child", content: "Child" }],
1785
- },
1786
- ]);
1787
- pressKey(instance, "Backspace");
1788
- expect(instance.document.map((block) => block.id)).toEqual([
1789
- "parent",
1790
- "child",
1791
- ]);
1792
- const target = nestedTarget ? "target" : "parent";
1793
- expect(instance.getBlock(target)?.content).toEqual([
1794
- {
1795
- type: "text",
1796
- text: `${nestedTarget ? "Target" : "Parent"}Current`,
1797
- styles: {},
1798
- },
1799
- ]);
1800
- expect(instance.getTextCursorPosition().block.id).toBe(target);
1801
- expect(instance.prosemirrorView.state.selection.$from.parentOffset).toBe(
1802
- 6,
1803
- );
1804
- expect(instance.getBlock("child")?.content).toEqual([
1805
- { type: "text", text: "Child", styles: {} },
1806
- ]);
1807
- },
1808
- );
1809
-
1810
- it("deletes a selected nested image", () => {
1811
- const instance = createScenario([
1812
- {
1813
- id: "parent",
1814
- content: "Parent",
1815
- children: [
1816
- { id: "current", type: "image" },
1817
- { id: "after", content: "After" },
1818
- ],
1819
- },
1820
- ]);
1821
- const info = getBlockInfoFromSelection(instance.prosemirrorView.state);
1822
- if (!info.hasContent) {
1823
- throw new Error("Expected image block");
1824
- }
1825
- instance.prosemirrorView.dispatch(
1826
- instance.prosemirrorView.state.tr.setSelection(
1827
- NodeSelection.create(
1828
- instance.prosemirrorView.state.doc,
1829
- info.content.beforePos,
1830
- ),
1831
- ),
1832
- );
1833
- pressKey(instance, "Backspace");
1834
- expect(instance.getBlock("current")).toBeUndefined();
1835
- expect(
1836
- instance.getBlock("parent")?.children.map((block) => block.id),
1837
- ).toEqual(["after"]);
1838
- });
1839
-
1840
- it("does nothing at the start of a nested table cell", () => {
1841
- const instance = createScenario([
1842
- {
1843
- id: "parent",
1844
- content: "Parent",
1845
- children: [
1846
- { id: "current", ...parentSpec("table") },
1847
- { id: "after", content: "After" },
1848
- ],
1849
- },
1850
- ]);
1851
- let pos: number | undefined;
1852
- instance.prosemirrorView.state.doc.descendants((node, nodePos) => {
1853
- if (node.isText && node.text === "First") {
1854
- pos = nodePos;
1855
- }
1856
- });
1857
- if (pos === undefined) {
1858
- throw new Error("Expected table cell text");
1859
- }
1860
- instance.prosemirrorView.dispatch(
1861
- instance.prosemirrorView.state.tr.setSelection(
1862
- TextSelection.create(instance.prosemirrorView.state.doc, pos),
1863
- ),
1864
- );
1865
- const before = instance.document;
1866
- pressKey(instance, "Backspace");
1867
- expect(instance.document).toEqual(before);
1868
- expect(instance.prosemirrorView.state.selection.from).toBe(pos);
1869
- });
1870
- });