@blocknote/core 0.55.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 (678) 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-C4TzkGEn.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 +18 -19
  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-BAn9gxr-.js → en-Ne9rlj9Y.js} +42 -5
  14. package/dist/es-VeBX6MEG.js +3 -0
  15. package/dist/extensions-CEgexSyF.js +3091 -0
  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 +1418 -32
  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-DksfoQmN.js +3574 -0
  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 +1284 -559
  41. package/dist/yjs.js +211 -171
  42. package/dist/zh-hant-2ZrAkFnC.js +3 -0
  43. package/dist/zh-jglyCmjs.js +3 -0
  44. package/package.json +51 -27
  45. package/src/fonts/inter.css +111 -0
  46. package/types/src/api/blockManipulation/commands/insertBlocks/insertBlocks.d.ts +2 -1
  47. package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.d.ts +24 -24
  48. package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.d.ts +3 -2
  49. package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.d.ts +1 -1
  50. package/types/src/api/blockManipulation/commands/splitBlock/splitBlock.d.ts +2 -2
  51. package/types/src/api/blockManipulation/layoutBlocks/fixLayoutBlock.d.ts +34 -0
  52. package/types/src/api/blockManipulation/layoutBlocks/layoutBlocks.fixture.d.ts +465 -0
  53. package/types/src/api/blockManipulation/setupTestEnv.d.ts +15 -69
  54. package/types/src/api/blockManipulation/tables/tables.d.ts +9 -4
  55. package/types/src/api/clipboard/fromClipboard/normalizeOfficeHTML.d.ts +5 -0
  56. package/types/src/api/combineTransactionSteps.d.ts +12 -0
  57. package/types/src/api/exporters/markdown/wrapWithDelimiter.d.ts +6 -0
  58. package/types/src/api/getBlockInfoFromPos.d.ts +218 -44
  59. package/types/src/api/{getChangedRange.d.ts → getChangedRangeWithAttrs.d.ts} +1 -1
  60. package/types/src/api/getChangedRanges.d.ts +23 -0
  61. package/types/src/api/nodeConversions/fragmentToBlocks.d.ts +0 -3
  62. package/types/src/api/parsers/markdown/autolink.d.ts +5 -0
  63. package/types/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.d.ts +4 -0
  64. package/types/src/blocks/ToggleWrapper/createToggleFrame.d.ts +29 -0
  65. package/types/src/blocks/defaultBlockTypeItems.d.ts +37 -0
  66. package/types/src/blocks/defaultBlocks.d.ts +10 -0
  67. package/types/src/blocks/index.d.ts +2 -1
  68. package/types/src/editor/BlockNoteEditor.d.ts +38 -9
  69. package/types/src/editor/managers/BlockManager.d.ts +4 -3
  70. package/types/src/editor/managers/ExtensionManager/index.d.ts +19 -7
  71. package/types/src/editor/managers/StateManager.d.ts +1 -1
  72. package/types/src/editor/managers/StyleManager.d.ts +2 -1
  73. package/types/src/editor/transformPasted.d.ts +1 -1
  74. package/types/src/emoji-data/frimousse/ar.d.ts +2 -0
  75. package/types/src/emoji-data/frimousse/common.d.ts +3 -0
  76. package/types/src/emoji-data/frimousse/de.d.ts +2 -0
  77. package/types/src/emoji-data/frimousse/en.d.ts +2 -0
  78. package/types/src/emoji-data/frimousse/es.d.ts +2 -0
  79. package/types/src/emoji-data/frimousse/fa.d.ts +2 -0
  80. package/types/src/emoji-data/frimousse/fr.d.ts +2 -0
  81. package/types/src/emoji-data/frimousse/he.d.ts +2 -0
  82. package/types/src/emoji-data/frimousse/hr.d.ts +2 -0
  83. package/types/src/emoji-data/frimousse/is.d.ts +2 -0
  84. package/types/src/emoji-data/frimousse/it.d.ts +2 -0
  85. package/types/src/emoji-data/frimousse/ja.d.ts +2 -0
  86. package/types/src/emoji-data/frimousse/ko.d.ts +2 -0
  87. package/types/src/emoji-data/frimousse/loadFrimousseData.d.ts +2 -0
  88. package/types/src/emoji-data/frimousse/nb.d.ts +2 -0
  89. package/types/src/emoji-data/frimousse/nl.d.ts +2 -0
  90. package/types/src/emoji-data/frimousse/pl.d.ts +2 -0
  91. package/types/src/emoji-data/frimousse/pt.d.ts +2 -0
  92. package/types/src/emoji-data/frimousse/ru.d.ts +2 -0
  93. package/types/src/emoji-data/frimousse/sk.d.ts +2 -0
  94. package/types/src/emoji-data/frimousse/tr.d.ts +2 -0
  95. package/types/src/emoji-data/frimousse/types.d.ts +21 -0
  96. package/types/src/emoji-data/frimousse/uk.d.ts +2 -0
  97. package/types/src/emoji-data/frimousse/uz.d.ts +2 -0
  98. package/types/src/emoji-data/frimousse/vi.d.ts +2 -0
  99. package/types/src/emoji-data/frimousse/zh-hant.d.ts +2 -0
  100. package/types/src/emoji-data/frimousse/zh.d.ts +2 -0
  101. package/types/src/emoji-data/index.d.ts +3 -0
  102. package/types/src/emoji-data/searchEmojis.d.ts +5 -0
  103. package/types/src/exporter/Exporter.d.ts +11 -4
  104. package/types/src/exporter/mapping.d.ts +13 -1
  105. package/types/src/extensions/DropCursor/DropCursor.d.ts +1 -1
  106. package/types/src/extensions/DropCursor/dropIntoChildren.d.ts +38 -0
  107. package/types/src/extensions/Loading/Loading.d.ts +11 -0
  108. package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.d.ts +1 -1
  109. package/types/src/extensions/ReadOnly/ReadOnly.d.ts +21 -0
  110. package/types/src/extensions/SideMenu/MultipleNodeSelection.d.ts +13 -4
  111. package/types/src/extensions/SideMenu/SideMenu.d.ts +51 -89
  112. package/types/src/extensions/SideMenu/blockDropHandling.d.ts +11 -0
  113. package/types/src/extensions/SideMenu/blockGeometry.d.ts +22 -0
  114. package/types/src/extensions/SideMenu/dragging.d.ts +0 -4
  115. package/types/src/extensions/SideMenu/sideMenuHover.d.ts +58 -0
  116. package/types/src/extensions/Versioning/Versioning.d.ts +36 -311
  117. package/types/src/extensions/Versioning/createVersioning.d.ts +32 -0
  118. package/types/src/extensions/Versioning/formatVersionDate.d.ts +7 -0
  119. package/types/src/extensions/Versioning/inMemoryVersioning.d.ts +65 -36
  120. package/types/src/extensions/Versioning/index.d.ts +4 -0
  121. package/types/src/extensions/Versioning/scrollToFirstChange.d.ts +18 -0
  122. package/types/src/extensions/Versioning/types.d.ts +245 -0
  123. package/types/src/extensions/Versioning/versioningState.d.ts +49 -0
  124. package/types/src/extensions/blockDOM.d.ts +37 -0
  125. package/types/src/extensions/index.d.ts +3 -2
  126. package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.d.ts +1 -0
  127. package/types/src/i18n/dictionary.d.ts +4 -1
  128. package/types/src/i18n/locales/en.d.ts +38 -0
  129. package/types/src/i18n/locales/fa.d.ts +38 -0
  130. package/types/src/i18n/locales/index.d.ts +1 -0
  131. package/types/src/i18n/locales/sk.d.ts +38 -0
  132. package/types/src/i18n/locales/tr.d.ts +378 -0
  133. package/types/src/index.d.ts +5 -3
  134. package/types/src/pm-nodes/BlockContainer.d.ts +6 -0
  135. package/types/src/schema/blocks/children.d.ts +39 -0
  136. package/types/src/schema/blocks/createSpec.d.ts +13 -0
  137. package/types/src/schema/blocks/frame.d.ts +109 -0
  138. package/types/src/schema/blocks/internal.d.ts +6 -0
  139. package/types/src/schema/blocks/keyboard.d.ts +111 -0
  140. package/types/src/schema/blocks/layoutBlockAttributes.d.ts +9 -0
  141. package/types/src/schema/blocks/meta.d.ts +14 -0
  142. package/types/src/schema/blocks/types.d.ts +228 -15
  143. package/types/src/schema/blocks/validateChildren.d.ts +5 -0
  144. package/types/src/schema/dataAttributes.d.ts +19 -0
  145. package/types/src/schema/index.d.ts +3 -0
  146. package/types/src/schema/inlineContent/createSpec.d.ts +2 -1
  147. package/types/src/schema/inlineContent/internal.d.ts +1 -1
  148. package/types/src/schema/inlineContent/types.d.ts +2 -4
  149. package/types/src/schema/markGroups.d.ts +8 -0
  150. package/types/src/schema/styles/createSpec.d.ts +2 -1
  151. package/types/src/schema/styles/internal.d.ts +4 -1
  152. package/types/src/schema/styles/types.d.ts +2 -0
  153. package/types/src/user/userColors.d.ts +24 -3
  154. package/types/src/y/comments/RESTYjsThreadStore.d.ts +1 -1
  155. package/types/src/y/comments/YjsThreadStore.d.ts +1 -1
  156. package/types/src/y/comments/YjsThreadStoreBase.d.ts +2 -2
  157. package/types/src/y/comments/yjsHelpers.d.ts +5 -5
  158. package/types/src/y/extensions/AttributionExtension.d.ts +19 -21
  159. package/types/src/y/extensions/DiffVersioningExtension.d.ts +9 -4
  160. package/types/src/y/extensions/ForkYDoc.d.ts +3 -1
  161. package/types/src/y/extensions/Versioning.d.ts +4 -15
  162. package/types/src/y/extensions/YAttributionMarks.d.ts +13 -2
  163. package/types/src/y/extensions/YCursorPlugin.d.ts +1 -0
  164. package/types/src/y/extensions/YSync.d.ts +4 -18
  165. package/types/src/y/extensions/blockMatchNodes.d.ts +0 -22
  166. package/types/src/y/extensions/index.d.ts +27 -44
  167. package/types/src/y/extensions/persistentBlockGroups.d.ts +189 -0
  168. package/types/src/y/extensions/snapshotCodec.d.ts +13 -0
  169. package/types/src/y/extensions/snapshotPreview.d.ts +21 -0
  170. package/types/src/y/index.d.ts +1 -0
  171. package/types/src/y/utils.d.ts +39 -19
  172. package/types/src/y/versioning/index.d.ts +1 -1
  173. package/types/src/y/versioning/yhub.d.ts +71 -86
  174. package/types/src/y/versioning/yhubClient.d.ts +67 -0
  175. package/types/src/yjs/extensions/ForkYDoc.d.ts +2 -0
  176. package/types/src/yjs/extensions/Versioning.d.ts +37 -22
  177. package/types/src/yjs/extensions/YUndo.d.ts +3 -2
  178. package/types/src/yjs/extensions/index.d.ts +3 -2
  179. package/types/src/yjs/index.d.ts +1 -0
  180. package/dist/BlockNoteExtension-BJCLnwrE.cjs +0 -2
  181. package/dist/BlockNoteExtension-BJCLnwrE.cjs.map +0 -1
  182. package/dist/BlockNoteExtension-CbvDA0F7.js +0 -80
  183. package/dist/BlockNoteExtension-CbvDA0F7.js.map +0 -1
  184. package/dist/ThreadStore-Bx-gSEh1.cjs +0 -2
  185. package/dist/ThreadStore-Bx-gSEh1.cjs.map +0 -1
  186. package/dist/ThreadStore-et9wB5Xt.js +0 -11
  187. package/dist/ThreadStore-et9wB5Xt.js.map +0 -1
  188. package/dist/UserStore-C4TzkGEn.js.map +0 -1
  189. package/dist/UserStore-mj3fXW4D.cjs +0 -2
  190. package/dist/UserStore-mj3fXW4D.cjs.map +0 -1
  191. package/dist/blocknote.cjs +0 -1
  192. package/dist/blocks-DLgTreVu.cjs +0 -12
  193. package/dist/blocks-DLgTreVu.cjs.map +0 -1
  194. package/dist/blocks-DaEUT0O1.js +0 -3527
  195. package/dist/blocks-DaEUT0O1.js.map +0 -1
  196. package/dist/blocks.cjs +0 -1
  197. package/dist/comments.cjs +0 -2
  198. package/dist/comments.cjs.map +0 -1
  199. package/dist/comments.js.map +0 -1
  200. package/dist/en-BAn9gxr-.js.map +0 -1
  201. package/dist/en-CHnrV5l8.cjs +0 -2
  202. package/dist/en-CHnrV5l8.cjs.map +0 -1
  203. package/dist/extensions-B1JQURVF.js +0 -2138
  204. package/dist/extensions-B1JQURVF.js.map +0 -1
  205. package/dist/extensions-CZkqKzJO.cjs +0 -58
  206. package/dist/extensions-CZkqKzJO.cjs.map +0 -1
  207. package/dist/extensions.cjs +0 -1
  208. package/dist/locales.cjs +0 -2
  209. package/dist/locales.cjs.map +0 -1
  210. package/dist/locales.js.map +0 -1
  211. package/dist/src-D5w0XAHX.js +0 -3379
  212. package/dist/src-D5w0XAHX.js.map +0 -1
  213. package/dist/src-th5uZEvx.cjs +0 -23
  214. package/dist/src-th5uZEvx.cjs.map +0 -1
  215. package/dist/webpack-stats.json +0 -1
  216. package/dist/y.cjs +0 -2
  217. package/dist/y.cjs.map +0 -1
  218. package/dist/y.js.map +0 -1
  219. package/dist/yjs.cjs +0 -2
  220. package/dist/yjs.cjs.map +0 -1
  221. package/dist/yjs.js.map +0 -1
  222. package/src/api/README.md +0 -8
  223. package/src/api/__snapshots__/blocks-deleted-nested-deep.json +0 -26
  224. package/src/api/__snapshots__/blocks-deleted-nested.json +0 -68
  225. package/src/api/__snapshots__/blocks-deleted.json +0 -26
  226. package/src/api/__snapshots__/blocks-indented-changed.json +0 -129
  227. package/src/api/__snapshots__/blocks-inserted-nested.json +0 -62
  228. package/src/api/__snapshots__/blocks-inserted.json +0 -20
  229. package/src/api/__snapshots__/blocks-moved-deeper-into-nesting.json +0 -164
  230. package/src/api/__snapshots__/blocks-moved-down-twice-in-same-parent.json +0 -44
  231. package/src/api/__snapshots__/blocks-moved-insert-changes-sibling-order.json +0 -26
  232. package/src/api/__snapshots__/blocks-moved-multiple-in-same-transaction.json +0 -188
  233. package/src/api/__snapshots__/blocks-moved-nested-sibling-reorder.json +0 -180
  234. package/src/api/__snapshots__/blocks-moved-to-different-parent.json +0 -78
  235. package/src/api/__snapshots__/blocks-moved-to-root-level.json +0 -78
  236. package/src/api/__snapshots__/blocks-moved-up-down-in-same-parent.json +0 -44
  237. package/src/api/__snapshots__/blocks-moved-up-down-in-same-transaction.json +0 -44
  238. package/src/api/__snapshots__/blocks-outdented-changed.json +0 -129
  239. package/src/api/__snapshots__/blocks-updated-content-inserted.json +0 -42
  240. package/src/api/__snapshots__/blocks-updated-multiple-insert.json +0 -50
  241. package/src/api/__snapshots__/blocks-updated-multiple.json +0 -82
  242. package/src/api/__snapshots__/blocks-updated-nested-deep.json +0 -42
  243. package/src/api/__snapshots__/blocks-updated-nested-multiple.json +0 -118
  244. package/src/api/__snapshots__/blocks-updated-nested.json +0 -78
  245. package/src/api/__snapshots__/blocks-updated-single.json +0 -42
  246. package/src/api/__snapshots__/blocks-updated.json +0 -42
  247. package/src/api/blockManipulation/__snapshots__/transactions.test.ts.snap +0 -34
  248. package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +0 -4570
  249. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +0 -176
  250. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +0 -56
  251. package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +0 -2761
  252. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +0 -147
  253. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +0 -199
  254. package/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap +0 -13625
  255. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +0 -375
  256. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +0 -409
  257. package/src/api/blockManipulation/commands/nestBlock/__snapshots__/nestBlock.test.ts.snap +0 -952
  258. package/src/api/blockManipulation/commands/nestBlock/nestBlock.test.ts +0 -661
  259. package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +0 -208
  260. package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +0 -5710
  261. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +0 -235
  262. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +0 -135
  263. package/src/api/blockManipulation/commands/replaceBlocks/util/fixColumnList.ts +0 -173
  264. package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +0 -3507
  265. package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +0 -151
  266. package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +0 -58
  267. package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +0 -15085
  268. package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +0 -978
  269. package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +0 -685
  270. package/src/api/blockManipulation/getBlock/getBlock.ts +0 -111
  271. package/src/api/blockManipulation/insertContentAt.ts +0 -83
  272. package/src/api/blockManipulation/selections/selection.ts +0 -267
  273. package/src/api/blockManipulation/selections/textCursorPosition.ts +0 -118
  274. package/src/api/blockManipulation/setupTestEnv.ts +0 -191
  275. package/src/api/blockManipulation/tables/tables.test.ts +0 -2127
  276. package/src/api/blockManipulation/tables/tables.ts +0 -887
  277. package/src/api/clipboard/fromClipboard/acceptedMIMETypes.ts +0 -8
  278. package/src/api/clipboard/fromClipboard/fileDropExtension.ts +0 -55
  279. package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +0 -209
  280. package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +0 -38
  281. package/src/api/clipboard/fromClipboard/pasteExtension.ts +0 -157
  282. package/src/api/clipboard/toClipboard/copyExtension.ts +0 -299
  283. package/src/api/exporters/html/externalHTMLExporter.ts +0 -76
  284. package/src/api/exporters/html/internalHTMLSerializer.ts +0 -182
  285. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +0 -435
  286. package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +0 -253
  287. package/src/api/exporters/markdown/htmlToMarkdown.ts +0 -884
  288. package/src/api/exporters/markdown/markdownExporter.ts +0 -41
  289. package/src/api/getBlockInfoFromPos.test.ts +0 -256
  290. package/src/api/getBlockInfoFromPos.ts +0 -291
  291. package/src/api/getBlocksChangedByTransaction.test.ts +0 -783
  292. package/src/api/getBlocksChangedByTransaction.ts +0 -458
  293. package/src/api/getChangedRange.ts +0 -54
  294. package/src/api/nodeConversions/blockToNode.test.ts +0 -113
  295. package/src/api/nodeConversions/blockToNode.ts +0 -399
  296. package/src/api/nodeConversions/fragmentToBlocks.ts +0 -63
  297. package/src/api/nodeConversions/nodeToBlock.ts +0 -665
  298. package/src/api/nodeUtil.ts +0 -46
  299. package/src/api/parsers/html/parseHTML.ts +0 -80
  300. package/src/api/parsers/html/util/__snapshots__/nestedLists.test.ts.snap +0 -144
  301. package/src/api/parsers/html/util/nestedLists.test.ts +0 -165
  302. package/src/api/parsers/html/util/nestedLists.ts +0 -123
  303. package/src/api/parsers/html/util/normalizeWhitespace.ts +0 -87
  304. package/src/api/parsers/markdown/detectMarkdown.test.ts +0 -211
  305. package/src/api/parsers/markdown/detectMarkdown.ts +0 -61
  306. package/src/api/parsers/markdown/markdownToHtml.ts +0 -1340
  307. package/src/api/parsers/markdown/parseMarkdown.ts +0 -24
  308. package/src/api/pmUtil.ts +0 -79
  309. package/src/api/positionMapping.test.ts +0 -209
  310. package/src/api/positionMapping.ts +0 -42
  311. package/src/blocks/Audio/block.ts +0 -171
  312. package/src/blocks/Audio/parseAudioElement.ts +0 -5
  313. package/src/blocks/BlockNoteSchema.ts +0 -59
  314. package/src/blocks/Code/CodeBlockOptions.ts +0 -83
  315. package/src/blocks/Code/block.test.ts +0 -265
  316. package/src/blocks/Code/block.ts +0 -56
  317. package/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.ts +0 -120
  318. package/src/blocks/Code/helpers/parse/parsePreCode.ts +0 -45
  319. package/src/blocks/Code/helpers/render/createCodeBlock.ts +0 -98
  320. package/src/blocks/Code/helpers/toExternalHTML/createPreCode.ts +0 -14
  321. package/src/blocks/Divider/block.ts +0 -49
  322. package/src/blocks/File/block.ts +0 -95
  323. package/src/blocks/File/helpers/parse/parseEmbedElement.ts +0 -5
  324. package/src/blocks/File/helpers/parse/parseFigureElement.ts +0 -16
  325. package/src/blocks/File/helpers/render/createAddFileButton.ts +0 -69
  326. package/src/blocks/File/helpers/render/createFileBlockWrapper.ts +0 -88
  327. package/src/blocks/File/helpers/render/createFileNameWithIcon.ts +0 -37
  328. package/src/blocks/File/helpers/render/createResizableFileBlockWrapper.ts +0 -271
  329. package/src/blocks/File/helpers/toExternalHTML/createFigureWithCaption.ts +0 -13
  330. package/src/blocks/File/helpers/toExternalHTML/createLinkWithCaption.ts +0 -15
  331. package/src/blocks/Heading/block.ts +0 -188
  332. package/src/blocks/Image/block.ts +0 -193
  333. package/src/blocks/Image/parseImageElement.ts +0 -7
  334. package/src/blocks/ListItem/BulletListItem/block.ts +0 -127
  335. package/src/blocks/ListItem/CheckListItem/block.test.ts +0 -61
  336. package/src/blocks/ListItem/CheckListItem/block.ts +0 -182
  337. package/src/blocks/ListItem/ListItemKeyboardShortcuts.ts +0 -63
  338. package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.ts +0 -352
  339. package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +0 -242
  340. package/src/blocks/ListItem/NumberedListItem/block.ts +0 -141
  341. package/src/blocks/ListItem/ToggleListItem/block.ts +0 -128
  342. package/src/blocks/ListItem/getListItemContent.ts +0 -115
  343. package/src/blocks/PageBreak/block.ts +0 -72
  344. package/src/blocks/PageBreak/getPageBreakSlashMenuItems.ts +0 -47
  345. package/src/blocks/Paragraph/block.ts +0 -80
  346. package/src/blocks/Quote/block.ts +0 -99
  347. package/src/blocks/README.md +0 -3
  348. package/src/blocks/Table/TableExtension.test.ts +0 -231
  349. package/src/blocks/Table/TableExtension.ts +0 -115
  350. package/src/blocks/Table/block.ts +0 -500
  351. package/src/blocks/ToggleWrapper/createToggleWrapper.ts +0 -197
  352. package/src/blocks/Video/block.ts +0 -142
  353. package/src/blocks/Video/parseVideoElement.ts +0 -7
  354. package/src/blocks/defaultBlockHelpers.ts +0 -113
  355. package/src/blocks/defaultBlockTypeGuards.ts +0 -167
  356. package/src/blocks/defaultBlocks.ts +0 -208
  357. package/src/blocks/defaultProps.ts +0 -165
  358. package/src/blocks/getDetailsContent.ts +0 -77
  359. package/src/blocks/index.ts +0 -29
  360. package/src/blocks/utils/listItemEnterHandler.ts +0 -43
  361. package/src/comments/CommentEditorSubmitExtension.test.ts +0 -141
  362. package/src/comments/CommentEditorSubmitExtension.ts +0 -56
  363. package/src/comments/extension.ts +0 -396
  364. package/src/comments/index.ts +0 -8
  365. package/src/comments/mark.ts +0 -64
  366. package/src/comments/threadstore/DefaultThreadStoreAuth.ts +0 -106
  367. package/src/comments/threadstore/ThreadStore.ts +0 -130
  368. package/src/comments/threadstore/ThreadStoreAuth.ts +0 -13
  369. package/src/comments/threadstore/TipTapThreadStore.ts +0 -292
  370. package/src/comments/threadstore/tiptap/types.ts +0 -131
  371. package/src/comments/types.ts +0 -121
  372. package/src/editor/Block.css +0 -1366
  373. package/src/editor/BlockNoteEditor.test.ts +0 -278
  374. package/src/editor/BlockNoteEditor.ts +0 -1497
  375. package/src/editor/BlockNoteExtension.test.ts +0 -103
  376. package/src/editor/BlockNoteExtension.ts +0 -246
  377. package/src/editor/README.md +0 -3
  378. package/src/editor/cursorPositionTypes.ts +0 -17
  379. package/src/editor/defaultColors.ts +0 -77
  380. package/src/editor/editor.css +0 -197
  381. package/src/editor/managers/BlockManager.ts +0 -255
  382. package/src/editor/managers/EventManager.browser.test.ts +0 -334
  383. package/src/editor/managers/EventManager.ts +0 -260
  384. package/src/editor/managers/ExportManager.ts +0 -137
  385. package/src/editor/managers/ExtensionManager/ExtensionManager.test.ts +0 -336
  386. package/src/editor/managers/ExtensionManager/extensions.ts +0 -191
  387. package/src/editor/managers/ExtensionManager/index.ts +0 -697
  388. package/src/editor/managers/ExtensionManager/symbol.ts +0 -5
  389. package/src/editor/managers/SelectionManager.ts +0 -120
  390. package/src/editor/managers/StateManager.ts +0 -251
  391. package/src/editor/managers/StyleManager.browser.test.ts +0 -122
  392. package/src/editor/managers/StyleManager.test.ts +0 -98
  393. package/src/editor/managers/StyleManager.ts +0 -278
  394. package/src/editor/managers/index.ts +0 -8
  395. package/src/editor/performance.test.ts +0 -192
  396. package/src/editor/selectionTypes.ts +0 -14
  397. package/src/editor/transformPasted.test.ts +0 -295
  398. package/src/editor/transformPasted.ts +0 -293
  399. package/src/exporter/ExportImage.ts +0 -50
  400. package/src/exporter/Exporter.test.ts +0 -186
  401. package/src/exporter/Exporter.ts +0 -155
  402. package/src/exporter/index.ts +0 -3
  403. package/src/exporter/mapping.ts +0 -79
  404. package/src/extensions/BlockChange/BlockChange.ts +0 -67
  405. package/src/extensions/DropCursor/DropCursor.ts +0 -263
  406. package/src/extensions/DropCursor/utils.ts +0 -195
  407. package/src/extensions/FilePanel/FilePanel.ts +0 -41
  408. package/src/extensions/FormattingToolbar/FormattingToolbar.ts +0 -151
  409. package/src/extensions/History/History.ts +0 -11
  410. package/src/extensions/InlineContentBoundaryEdit/InlineContentBoundaryEdit.ts +0 -109
  411. package/src/extensions/LinkToolbar/LinkToolbar.ts +0 -76
  412. package/src/extensions/LinkToolbar/protocols.ts +0 -13
  413. package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.ts +0 -75
  414. package/src/extensions/Placeholder/Placeholder.ts +0 -149
  415. package/src/extensions/PositionMapping/PositionMapping.ts +0 -68
  416. package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +0 -120
  417. package/src/extensions/PreviousBlockType/PreviousBlockType.ts +0 -197
  418. package/src/extensions/README.md +0 -3
  419. package/src/extensions/ShowSelection/ShowSelection.ts +0 -61
  420. package/src/extensions/SideMenu/MultipleNodeSelection.ts +0 -89
  421. package/src/extensions/SideMenu/SideMenu.ts +0 -833
  422. package/src/extensions/SideMenu/dragging.ts +0 -213
  423. package/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.ts +0 -192
  424. package/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.ts +0 -142
  425. package/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.ts +0 -4
  426. package/src/extensions/SuggestionMenu/DefaultSuggestionItem.ts +0 -11
  427. package/src/extensions/SuggestionMenu/SuggestionMenu.test.ts +0 -309
  428. package/src/extensions/SuggestionMenu/SuggestionMenu.ts +0 -427
  429. package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +0 -76
  430. package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +0 -399
  431. package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.ts +0 -120
  432. package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.ts +0 -89
  433. package/src/extensions/SyntaxHighlighting/inlineHighlight.test.ts +0 -135
  434. package/src/extensions/SyntaxHighlighting/shiki.ts +0 -116
  435. package/src/extensions/TableHandles/TableHandles.browser.test.ts +0 -307
  436. package/src/extensions/TableHandles/TableHandles.ts +0 -1265
  437. package/src/extensions/TrailingNode/TrailingNode.ts +0 -233
  438. package/src/extensions/Versioning/Versioning.test.ts +0 -435
  439. package/src/extensions/Versioning/Versioning.ts +0 -628
  440. package/src/extensions/Versioning/inMemoryVersioning.test.ts +0 -469
  441. package/src/extensions/Versioning/inMemoryVersioning.ts +0 -273
  442. package/src/extensions/Versioning/index.ts +0 -2
  443. package/src/extensions/getDraggableBlockFromElement.ts +0 -19
  444. package/src/extensions/index.ts +0 -25
  445. package/src/extensions/tiptap-extensions/BackgroundColor/BackgroundColorExtension.ts +0 -17
  446. package/src/extensions/tiptap-extensions/HardBreak/HardBreak.ts +0 -35
  447. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts +0 -204
  448. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +0 -1002
  449. package/src/extensions/tiptap-extensions/Link/helpers/autolink.ts +0 -179
  450. package/src/extensions/tiptap-extensions/Link/helpers/clickHandler.ts +0 -82
  451. package/src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts +0 -412
  452. package/src/extensions/tiptap-extensions/Link/helpers/pasteHandler.ts +0 -53
  453. package/src/extensions/tiptap-extensions/Link/helpers/tlds.ts +0 -7
  454. package/src/extensions/tiptap-extensions/Link/helpers/whitespace.ts +0 -13
  455. package/src/extensions/tiptap-extensions/Link/index.ts +0 -2
  456. package/src/extensions/tiptap-extensions/Link/link.test.ts +0 -945
  457. package/src/extensions/tiptap-extensions/Link/link.ts +0 -238
  458. package/src/extensions/tiptap-extensions/TextAlignment/TextAlignmentExtension.ts +0 -33
  459. package/src/extensions/tiptap-extensions/TextColor/TextColorExtension.ts +0 -17
  460. package/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.ts +0 -187
  461. package/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts +0 -336
  462. package/src/extensions/tiptap-extensions/index.ts +0 -7
  463. package/src/extensions-shared/UiElementPosition.ts +0 -4
  464. package/src/i18n/dictionary.ts +0 -17
  465. package/src/i18n/index.ts +0 -2
  466. package/src/i18n/locales/ar.ts +0 -411
  467. package/src/i18n/locales/de.ts +0 -445
  468. package/src/i18n/locales/en.ts +0 -426
  469. package/src/i18n/locales/es.ts +0 -424
  470. package/src/i18n/locales/fa.ts +0 -395
  471. package/src/i18n/locales/fr.ts +0 -472
  472. package/src/i18n/locales/he.ts +0 -426
  473. package/src/i18n/locales/hr.ts +0 -440
  474. package/src/i18n/locales/index.ts +0 -23
  475. package/src/i18n/locales/is.ts +0 -440
  476. package/src/i18n/locales/it.ts +0 -448
  477. package/src/i18n/locales/ja.ts +0 -466
  478. package/src/i18n/locales/ko.ts +0 -439
  479. package/src/i18n/locales/nl.ts +0 -427
  480. package/src/i18n/locales/no.ts +0 -444
  481. package/src/i18n/locales/pl.ts +0 -417
  482. package/src/i18n/locales/pt.ts +0 -419
  483. package/src/i18n/locales/ru.ts +0 -470
  484. package/src/i18n/locales/sk.ts +0 -424
  485. package/src/i18n/locales/uk.ts +0 -450
  486. package/src/i18n/locales/uz.ts +0 -460
  487. package/src/i18n/locales/vi.ts +0 -425
  488. package/src/i18n/locales/zh-tw.ts +0 -467
  489. package/src/i18n/locales/zh.ts +0 -467
  490. package/src/index.ts +0 -56
  491. package/src/locales.ts +0 -1
  492. package/src/pm-nodes/BlockContainer.ts +0 -91
  493. package/src/pm-nodes/BlockGroup.ts +0 -57
  494. package/src/pm-nodes/Doc.ts +0 -11
  495. package/src/pm-nodes/README.md +0 -141
  496. package/src/pm-nodes/index.ts +0 -3
  497. package/src/pm-nodes/suggestionMarks.ts +0 -43
  498. package/src/schema/README.md +0 -3
  499. package/src/schema/blocks/createSpec.test.ts +0 -123
  500. package/src/schema/blocks/createSpec.ts +0 -506
  501. package/src/schema/blocks/extendBlockSpec.test.ts +0 -188
  502. package/src/schema/blocks/internal.test.ts +0 -86
  503. package/src/schema/blocks/internal.ts +0 -255
  504. package/src/schema/blocks/types.ts +0 -702
  505. package/src/schema/contentTypePropagation.test.ts +0 -182
  506. package/src/schema/index.ts +0 -12
  507. package/src/schema/inlineContent/createSpec.test.ts +0 -161
  508. package/src/schema/inlineContent/createSpec.ts +0 -409
  509. package/src/schema/inlineContent/internal.ts +0 -136
  510. package/src/schema/inlineContent/types.ts +0 -204
  511. package/src/schema/markGroups.ts +0 -50
  512. package/src/schema/nodeViewMutations.test.ts +0 -146
  513. package/src/schema/nodeViewMutations.ts +0 -49
  514. package/src/schema/propTypes.ts +0 -61
  515. package/src/schema/schema.test.ts +0 -110
  516. package/src/schema/schema.ts +0 -236
  517. package/src/schema/styles/createSpec.ts +0 -140
  518. package/src/schema/styles/internal.ts +0 -155
  519. package/src/schema/styles/types.ts +0 -57
  520. package/src/style.css +0 -2
  521. package/src/user/UserStore.ts +0 -199
  522. package/src/user/createUserStore.test.ts +0 -126
  523. package/src/user/index.ts +0 -2
  524. package/src/user/userColors.ts +0 -72
  525. package/src/util/EventEmitter.ts +0 -59
  526. package/src/util/README.md +0 -3
  527. package/src/util/Store.test.ts +0 -132
  528. package/src/util/Store.ts +0 -135
  529. package/src/util/browser.ts +0 -54
  530. package/src/util/combineByGroup.ts +0 -25
  531. package/src/util/expandToWords.ts +0 -38
  532. package/src/util/string.ts +0 -36
  533. package/src/util/table.ts +0 -110
  534. package/src/util/topo-sort.test.ts +0 -125
  535. package/src/util/topo-sort.ts +0 -206
  536. package/src/util/typescript.ts +0 -17
  537. package/src/vite-env.d.ts +0 -7
  538. package/src/y/README.md +0 -5
  539. package/src/y/comments/RESTYjsThreadStore.ts +0 -138
  540. package/src/y/comments/YjsThreadStore.test.ts +0 -295
  541. package/src/y/comments/YjsThreadStore.ts +0 -358
  542. package/src/y/comments/YjsThreadStoreBase.ts +0 -50
  543. package/src/y/comments/index.ts +0 -3
  544. package/src/y/comments/yjsHelpers.ts +0 -125
  545. package/src/y/extensions/AttributionExtension.test.ts +0 -95
  546. package/src/y/extensions/AttributionExtension.ts +0 -378
  547. package/src/y/extensions/DiffVersioningExtension.test.ts +0 -193
  548. package/src/y/extensions/DiffVersioningExtension.ts +0 -228
  549. package/src/y/extensions/ForkYDoc.test.ts +0 -253
  550. package/src/y/extensions/ForkYDoc.ts +0 -108
  551. package/src/y/extensions/RelativePositionMapping.test.ts +0 -418
  552. package/src/y/extensions/RelativePositionMapping.ts +0 -49
  553. package/src/y/extensions/Suggestions.ts +0 -174
  554. package/src/y/extensions/Versioning.test.ts +0 -408
  555. package/src/y/extensions/Versioning.ts +0 -115
  556. package/src/y/extensions/YAttributionMarks.ts +0 -320
  557. package/src/y/extensions/YCursorPlugin.ts +0 -189
  558. package/src/y/extensions/YSync.ts +0 -125
  559. package/src/y/extensions/blockMatchNodes.ts +0 -182
  560. package/src/y/extensions/index.ts +0 -156
  561. package/src/y/index.ts +0 -4
  562. package/src/y/utils.test.ts +0 -1042
  563. package/src/y/utils.ts +0 -242
  564. package/src/y/versioning/__test__/fixtures/activity-all-after.bin +0 -0
  565. package/src/y/versioning/__test__/fixtures/activity-all-after.json +0 -50
  566. package/src/y/versioning/__test__/fixtures/activity-all.bin +0 -0
  567. package/src/y/versioning/__test__/fixtures/activity-all.json +0 -20
  568. package/src/y/versioning/__test__/fixtures/activity-filtered-after.bin +0 -0
  569. package/src/y/versioning/__test__/fixtures/activity-filtered-after.json +0 -32
  570. package/src/y/versioning/__test__/fixtures/activity-filtered-before.json +0 -1
  571. package/src/y/versioning/__test__/fixtures/changeset.bin +0 -0
  572. package/src/y/versioning/__test__/fixtures/patch-response.json +0 -4
  573. package/src/y/versioning/__test__/yhub.test.ts +0 -785
  574. package/src/y/versioning/index.ts +0 -1
  575. package/src/y/versioning/yhub.ts +0 -637
  576. package/src/yjs/README.md +0 -5
  577. package/src/yjs/comments/RESTYjsThreadStore.test.ts +0 -85
  578. package/src/yjs/comments/RESTYjsThreadStore.ts +0 -172
  579. package/src/yjs/comments/YjsThreadStore.test.ts +0 -295
  580. package/src/yjs/comments/YjsThreadStore.ts +0 -345
  581. package/src/yjs/comments/YjsThreadStoreBase.ts +0 -50
  582. package/src/yjs/comments/index.ts +0 -3
  583. package/src/yjs/comments/yjsHelpers.ts +0 -127
  584. package/src/yjs/extensions/FixUpSchema.test.ts +0 -421
  585. package/src/yjs/extensions/FixUpSchema.ts +0 -88
  586. package/src/yjs/extensions/ForkYDoc.test.ts +0 -253
  587. package/src/yjs/extensions/ForkYDoc.ts +0 -159
  588. package/src/yjs/extensions/RelativePositionMapping.test.ts +0 -418
  589. package/src/yjs/extensions/RelativePositionMapping.ts +0 -77
  590. package/src/yjs/extensions/Versioning.test.ts +0 -561
  591. package/src/yjs/extensions/Versioning.ts +0 -83
  592. package/src/yjs/extensions/YCursorPlugin.ts +0 -201
  593. package/src/yjs/extensions/YSync.ts +0 -16
  594. package/src/yjs/extensions/YUndo.ts +0 -12
  595. package/src/yjs/extensions/__snapshots__/fork-yjs-snap-editor-forked.json +0 -19
  596. package/src/yjs/extensions/__snapshots__/fork-yjs-snap-editor.json +0 -19
  597. package/src/yjs/extensions/__snapshots__/fork-yjs-snap-forked.html +0 -1
  598. package/src/yjs/extensions/__snapshots__/fork-yjs-snap.html +0 -1
  599. package/src/yjs/extensions/index.ts +0 -89
  600. package/src/yjs/extensions/schemaMigration/SchemaMigration.ts +0 -59
  601. package/src/yjs/extensions/schemaMigration/migrationRules/index.ts +0 -4
  602. package/src/yjs/extensions/schemaMigration/migrationRules/migrationRule.ts +0 -4
  603. package/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.test.ts +0 -130
  604. package/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.ts +0 -91
  605. package/src/yjs/index.ts +0 -3
  606. package/src/yjs/utils.test.ts +0 -1013
  607. package/src/yjs/utils.ts +0 -186
  608. package/types/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.d.ts +0 -1
  609. package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.d.ts +0 -1
  610. package/types/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.d.ts +0 -1
  611. package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.test.d.ts +0 -1
  612. package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.d.ts +0 -1
  613. package/types/src/api/blockManipulation/commands/replaceBlocks/util/fixColumnList.d.ts +0 -32
  614. package/types/src/api/blockManipulation/commands/splitBlock/splitBlock.test.d.ts +0 -1
  615. package/types/src/api/blockManipulation/commands/updateBlock/updateBlock.test.d.ts +0 -1
  616. package/types/src/api/blockManipulation/tables/tables.test.d.ts +0 -1
  617. package/types/src/api/getBlockInfoFromPos.test.d.ts +0 -1
  618. package/types/src/api/getBlocksChangedByTransaction.test.d.ts +0 -1
  619. package/types/src/api/nodeConversions/blockToNode.test.d.ts +0 -1
  620. package/types/src/api/parsers/html/util/nestedLists.test.d.ts +0 -1
  621. package/types/src/api/parsers/markdown/detectMarkdown.test.d.ts +0 -1
  622. package/types/src/api/positionMapping.test.d.ts +0 -1
  623. package/types/src/blocks/Code/block.test.d.ts +0 -1
  624. package/types/src/blocks/ListItem/CheckListItem/block.test.d.ts +0 -1
  625. package/types/src/blocks/ListItem/ListItemKeyboardShortcuts.d.ts +0 -2
  626. package/types/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.d.ts +0 -1
  627. package/types/src/blocks/Table/TableExtension.test.d.ts +0 -1
  628. package/types/src/blocks/ToggleWrapper/createToggleWrapper.d.ts +0 -15
  629. package/types/src/blocks/utils/listItemEnterHandler.d.ts +0 -2
  630. package/types/src/comments/CommentEditorSubmitExtension.test.d.ts +0 -1
  631. package/types/src/editor/BlockNoteEditor.test.d.ts +0 -1
  632. package/types/src/editor/BlockNoteExtension.test.d.ts +0 -1
  633. package/types/src/editor/managers/EventManager.browser.test.d.ts +0 -1
  634. package/types/src/editor/managers/ExtensionManager/ExtensionManager.test.d.ts +0 -1
  635. package/types/src/editor/managers/StyleManager.browser.test.d.ts +0 -1
  636. package/types/src/editor/managers/StyleManager.test.d.ts +0 -1
  637. package/types/src/editor/performance.test.d.ts +0 -1
  638. package/types/src/editor/transformPasted.test.d.ts +0 -1
  639. package/types/src/exporter/Exporter.test.d.ts +0 -1
  640. package/types/src/extensions/PreviousBlockType/PreviousBlockType.test.d.ts +0 -1
  641. package/types/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.d.ts +0 -4
  642. package/types/src/extensions/SuggestionMenu/SuggestionMenu.test.d.ts +0 -1
  643. package/types/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.d.ts +0 -4
  644. package/types/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.d.ts +0 -1
  645. package/types/src/extensions/SyntaxHighlighting/inlineHighlight.test.d.ts +0 -1
  646. package/types/src/extensions/TableHandles/TableHandles.browser.test.d.ts +0 -1
  647. package/types/src/extensions/Versioning/Versioning.test.d.ts +0 -1
  648. package/types/src/extensions/Versioning/inMemoryVersioning.test.d.ts +0 -1
  649. package/types/src/extensions/getDraggableBlockFromElement.d.ts +0 -5
  650. package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.d.ts +0 -1
  651. package/types/src/extensions/tiptap-extensions/Link/link.test.d.ts +0 -1
  652. package/types/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.d.ts +0 -4
  653. package/types/src/schema/blocks/createSpec.test.d.ts +0 -1
  654. package/types/src/schema/blocks/extendBlockSpec.test.d.ts +0 -1
  655. package/types/src/schema/blocks/internal.test.d.ts +0 -1
  656. package/types/src/schema/contentTypePropagation.test.d.ts +0 -1
  657. package/types/src/schema/inlineContent/createSpec.test.d.ts +0 -1
  658. package/types/src/schema/nodeViewMutations.test.d.ts +0 -1
  659. package/types/src/schema/schema.test.d.ts +0 -1
  660. package/types/src/user/createUserStore.test.d.ts +0 -1
  661. package/types/src/util/Store.test.d.ts +0 -1
  662. package/types/src/util/topo-sort.test.d.ts +0 -1
  663. package/types/src/y/comments/YjsThreadStore.test.d.ts +0 -1
  664. package/types/src/y/extensions/AttributionExtension.test.d.ts +0 -1
  665. package/types/src/y/extensions/DiffVersioningExtension.test.d.ts +0 -1
  666. package/types/src/y/extensions/ForkYDoc.test.d.ts +0 -1
  667. package/types/src/y/extensions/RelativePositionMapping.test.d.ts +0 -1
  668. package/types/src/y/extensions/Versioning.test.d.ts +0 -1
  669. package/types/src/y/utils.test.d.ts +0 -1
  670. package/types/src/y/versioning/__test__/yhub.test.d.ts +0 -1
  671. package/types/src/yjs/comments/RESTYjsThreadStore.test.d.ts +0 -1
  672. package/types/src/yjs/comments/YjsThreadStore.test.d.ts +0 -1
  673. package/types/src/yjs/extensions/FixUpSchema.test.d.ts +0 -1
  674. package/types/src/yjs/extensions/ForkYDoc.test.d.ts +0 -1
  675. package/types/src/yjs/extensions/RelativePositionMapping.test.d.ts +0 -1
  676. package/types/src/yjs/extensions/Versioning.test.d.ts +0 -1
  677. package/types/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.test.d.ts +0 -1
  678. package/types/src/yjs/utils.test.d.ts +0 -1
@@ -1,1340 +0,0 @@
1
- import { isVideoUrl } from "../../../util/string.js";
2
-
3
- /**
4
- * Custom markdown-to-HTML converter for BlockNote.
5
- * Replaces the unified/remark/rehype pipeline with a direct, minimal implementation
6
- * that handles exactly the markdown features BlockNote needs.
7
- */
8
-
9
- // ─── HTML Escaping ───────────────────────────────────────────────────────────
10
-
11
- function escapeHtml(str: string): string {
12
- return str
13
- .replace(/&/g, "&")
14
- .replace(/</g, "&lt;")
15
- .replace(/>/g, "&gt;")
16
- .replace(/"/g, "&quot;");
17
- }
18
-
19
- // ─── Helpers ─────────────────────────────────────────────────────────────────
20
-
21
- function isAlphanumeric(char: string | undefined): boolean {
22
- if (!char) {
23
- return false;
24
- }
25
- return /\w/.test(char);
26
- }
27
-
28
- /**
29
- * Returns true when an underscore delimiter at position `i` is "intraword",
30
- * meaning the characters on both sides are alphanumeric (e.g. `snake_case`).
31
- * In that case the underscore should NOT be treated as emphasis per CommonMark.
32
- */
33
- function isIntraword(text: string, i: number, delimLen: number): boolean {
34
- const before = i > 0 ? text[i - 1] : undefined;
35
- const after = i + delimLen < text.length ? text[i + delimLen] : undefined;
36
- return isAlphanumeric(before) && isAlphanumeric(after);
37
- }
38
-
39
- // ─── Inline Parser ───────────────────────────────────────────────────────────
40
-
41
- type InlineTokenizer = (
42
- text: string,
43
- i: number,
44
- ) => { html: string; end: number } | null;
45
-
46
- function tryBackslashEscape(
47
- text: string,
48
- i: number,
49
- ): { html: string; end: number } | null {
50
- if (text[i] !== "\\" || i + 1 >= text.length) {
51
- return null;
52
- }
53
- const next = text[i + 1];
54
- // Hard line break: backslash at end of line
55
- if (next === "\n") {
56
- return { html: "<br>\n", end: i + 2 };
57
- }
58
- // Escapable characters
59
- if ("\\`*_{}[]()#+-.!~|>".includes(next)) {
60
- return { html: escapeHtml(next), end: i + 2 };
61
- }
62
- return null;
63
- }
64
-
65
- function tryInlineCode(
66
- text: string,
67
- i: number,
68
- ): { html: string; end: number } | null {
69
- if (text[i] !== "`") {
70
- return null;
71
- }
72
- return parseInlineCode(text, i);
73
- }
74
-
75
- function tryImage(
76
- text: string,
77
- i: number,
78
- ): { html: string; end: number } | null {
79
- if (text[i] !== "!" || text[i + 1] !== "[") {
80
- return null;
81
- }
82
- return parseImage(text, i);
83
- }
84
-
85
- function tryLink(
86
- text: string,
87
- i: number,
88
- ): { html: string; end: number } | null {
89
- if (text[i] !== "[") {
90
- return null;
91
- }
92
- return parseLink(text, i);
93
- }
94
-
95
- function tryStrikethrough(
96
- text: string,
97
- i: number,
98
- ): { html: string; end: number } | null {
99
- if (text[i] !== "~" || text[i + 1] !== "~") {
100
- return null;
101
- }
102
- return parseDelimited(text, i, "~~", "<del>", "</del>");
103
- }
104
-
105
- function tryBoldItalic(
106
- text: string,
107
- i: number,
108
- ): { html: string; end: number } | null {
109
- if (
110
- (text[i] === "*" && text[i + 1] === "*" && text[i + 2] === "*") ||
111
- (text[i] === "_" &&
112
- text[i + 1] === "_" &&
113
- text[i + 2] === "_" &&
114
- !isIntraword(text, i, 3))
115
- ) {
116
- const delimiter = text.substring(i, i + 3);
117
- return parseDelimited(text, i, delimiter, "<strong><em>", "</em></strong>");
118
- }
119
- return null;
120
- }
121
-
122
- function tryBold(
123
- text: string,
124
- i: number,
125
- ): { html: string; end: number } | null {
126
- if (
127
- (text[i] === "*" && text[i + 1] === "*") ||
128
- (text[i] === "_" && text[i + 1] === "_" && !isIntraword(text, i, 2))
129
- ) {
130
- const delimiter = text.substring(i, i + 2);
131
- return parseDelimited(text, i, delimiter, "<strong>", "</strong>");
132
- }
133
- return null;
134
- }
135
-
136
- function tryItalic(
137
- text: string,
138
- i: number,
139
- ): { html: string; end: number } | null {
140
- if (text[i] === "*" || (text[i] === "_" && !isIntraword(text, i, 1))) {
141
- return parseDelimited(text, i, text[i], "<em>", "</em>");
142
- }
143
- return null;
144
- }
145
-
146
- function trySoftBreak(
147
- text: string,
148
- i: number,
149
- ): { html: string; end: number } | null {
150
- if (text[i] === "\n") {
151
- return { html: "<br>\n", end: i + 1 };
152
- }
153
- return null;
154
- }
155
-
156
- // Inline raw HTML: pass through tags, comments, CDATA, processing
157
- // instructions, and declarations verbatim so authors can mix HTML into
158
- // markdown (e.g. `text <em>foo</em> more`). Anything that doesn't match
159
- // these shapes falls through and gets HTML-escaped as plain text.
160
- const INLINE_HTML_TAG_RE =
161
- /^<\/?[a-zA-Z][a-zA-Z0-9-]*(?:\s+[a-zA-Z_:][a-zA-Z0-9_.:-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*\s*\/?>/;
162
- const HTML_COMMENT_RE = /^<!--[\s\S]*?-->/;
163
- const HTML_CDATA_RE = /^<!\[CDATA\[[\s\S]*?\]\]>/;
164
- const HTML_PI_RE = /^<\?[\s\S]*?\?>/;
165
- const HTML_DECL_RE = /^<![A-Za-z][\s\S]*?>/;
166
-
167
- function tryInlineHtml(
168
- text: string,
169
- i: number,
170
- ): { html: string; end: number } | null {
171
- if (text[i] !== "<") {
172
- return null;
173
- }
174
- const rest = text.substring(i);
175
- for (const re of [
176
- HTML_COMMENT_RE,
177
- HTML_CDATA_RE,
178
- HTML_PI_RE,
179
- HTML_DECL_RE,
180
- INLINE_HTML_TAG_RE,
181
- ]) {
182
- const m = rest.match(re);
183
- if (m) {
184
- return { html: m[0], end: i + m[0].length };
185
- }
186
- }
187
- return null;
188
- }
189
-
190
- /** Characters that can start an inline syntax token. */
191
- const SPECIAL_CHARS = new Set("\\`![~*_\n<");
192
-
193
- /**
194
- * Ordered array of inline tokenizers, tried in priority order.
195
- * The first match wins.
196
- */
197
- const inlineTokenizers: InlineTokenizer[] = [
198
- tryBackslashEscape,
199
- tryInlineCode,
200
- tryImage,
201
- tryLink,
202
- tryStrikethrough,
203
- tryBoldItalic, // *** / ___
204
- tryBold, // ** / __
205
- tryItalic, // * / _
206
- tryInlineHtml,
207
- trySoftBreak,
208
- ];
209
-
210
- /**
211
- * Parse inline markdown syntax and return HTML.
212
- * Handles: bold, italic, bold+italic, strikethrough, inline code,
213
- * links, images (with video detection), hard line breaks, backslash escapes.
214
- */
215
- function parseInline(text: string): string {
216
- let result = "";
217
- let i = 0;
218
-
219
- while (i < text.length) {
220
- // Hard line break: 2+ trailing spaces immediately before a newline.
221
- // (The other hard-break form, backslash + newline, is handled by
222
- // tryBackslashEscape.) Strip the trailing spaces from the accumulated
223
- // result before emitting the <br>.
224
- if (
225
- text[i] === "\n" &&
226
- i >= 2 &&
227
- text[i - 1] === " " &&
228
- text[i - 2] === " "
229
- ) {
230
- result = result.replace(/ +$/, "");
231
- result += "<br>\n";
232
- i++;
233
- continue;
234
- }
235
-
236
- // Try each tokenizer in priority order
237
- let matched = false;
238
- if (SPECIAL_CHARS.has(text[i])) {
239
- for (const tokenizer of inlineTokenizers) {
240
- const r = tokenizer(text, i);
241
- if (r) {
242
- result += r.html;
243
- i = r.end;
244
- matched = true;
245
- break;
246
- }
247
- }
248
- }
249
-
250
- if (!matched) {
251
- // Batch consecutive plain-text characters and escape once
252
- const runStart = i;
253
- i++;
254
- while (i < text.length && !SPECIAL_CHARS.has(text[i])) {
255
- i++;
256
- }
257
- result += escapeHtml(text.substring(runStart, i));
258
- }
259
- }
260
-
261
- return result;
262
- }
263
-
264
- function parseInlineCode(
265
- text: string,
266
- start: number,
267
- ): { html: string; end: number } | null {
268
- // Count opening backticks
269
- let openCount = 0;
270
- let i = start;
271
- while (i < text.length && text[i] === "`") {
272
- openCount++;
273
- i++;
274
- }
275
-
276
- // Find matching closing backticks
277
- let j = i;
278
- while (j < text.length) {
279
- if (text[j] === "`") {
280
- let closeCount = 0;
281
- const closeStart = j;
282
- while (j < text.length && text[j] === "`") {
283
- closeCount++;
284
- j++;
285
- }
286
- if (closeCount === openCount) {
287
- let code = text.substring(i, closeStart);
288
- // Per CommonMark: line endings inside a code span are converted to
289
- // single spaces, then if the result starts AND ends with a space and
290
- // is not all-spaces, one leading + trailing space is stripped (so
291
- // `` ` `foo` ` `` is `<code>`foo`</code>`).
292
- code = code.replace(/\n/g, " ");
293
- if (
294
- code.length >= 2 &&
295
- code[0] === " " &&
296
- code[code.length - 1] === " " &&
297
- /[^ ]/.test(code)
298
- ) {
299
- code = code.substring(1, code.length - 1);
300
- }
301
- return {
302
- html: `<code>${escapeHtml(code)}</code>`,
303
- end: j,
304
- };
305
- }
306
- } else {
307
- j++;
308
- }
309
- }
310
- return null;
311
- }
312
-
313
- function parseImage(
314
- text: string,
315
- start: number,
316
- ): { html: string; end: number } | null {
317
- // ![alt](url) or ![alt](url "title")
318
- // Use balanced bracket matching to handle nested/escaped brackets in alt text
319
- const altEnd = findClosingBracket(text, start + 1);
320
- if (altEnd === -1) {
321
- return null;
322
- }
323
- const altStart = start + 2; // after ![
324
-
325
- if (text[altEnd + 1] !== "(") {
326
- return null;
327
- }
328
-
329
- const urlStart = altEnd + 2;
330
- const parenEnd = findClosingParen(text, urlStart - 1);
331
- if (parenEnd === -1) {
332
- return null;
333
- }
334
-
335
- const alt = text.substring(altStart, altEnd);
336
- const { url, title } = parseDestinationAndTitle(
337
- text.substring(urlStart, parenEnd),
338
- );
339
-
340
- if (isVideoUrl(url)) {
341
- // Use the alt text as the video's display name (falling back to the
342
- // title) so a video link written with the standard `![name](url)` form
343
- // round-trips into BlockNote's video block. Captioned videos go through
344
- // raw `<figure>` HTML instead, see htmlToMarkdown.serializeMediaFigure.
345
- const name = alt || title;
346
- return {
347
- html: `<video src="${escapeHtml(url)}"${name ? ` data-name="${escapeHtml(name)}"` : ""} data-url="${escapeHtml(url)}" controls></video>`,
348
- end: parenEnd + 1,
349
- };
350
- }
351
-
352
- const titleAttr = title !== undefined ? ` title="${escapeHtml(title)}"` : "";
353
- return {
354
- html: `<img src="${escapeHtml(url)}" alt="${escapeHtml(alt)}"${titleAttr}>`,
355
- end: parenEnd + 1,
356
- };
357
- }
358
-
359
- function parseLink(
360
- text: string,
361
- start: number,
362
- ): { html: string; end: number } | null {
363
- // [text](url)
364
- const textStart = start + 1;
365
- const textEnd = findClosingBracket(text, start);
366
- if (textEnd === -1) {
367
- return null;
368
- }
369
-
370
- if (text[textEnd + 1] !== "(") {
371
- return null;
372
- }
373
-
374
- const urlStart = textEnd + 2;
375
- const parenEnd = findClosingParen(text, textEnd + 1);
376
- if (parenEnd === -1) {
377
- return null;
378
- }
379
-
380
- const linkText = text.substring(textStart, textEnd);
381
- const { url, title } = parseDestinationAndTitle(
382
- text.substring(urlStart, parenEnd),
383
- );
384
-
385
- const titleAttr = title !== undefined ? ` title="${escapeHtml(title)}"` : "";
386
- return {
387
- html: `<a href="${escapeHtml(url)}"${titleAttr}>${parseInline(linkText)}</a>`,
388
- end: parenEnd + 1,
389
- };
390
- }
391
-
392
- function findClosingBracket(text: string, openPos: number): number {
393
- let depth = 0;
394
- for (let i = openPos; i < text.length; i++) {
395
- if (text[i] === "\\" && i + 1 < text.length) {
396
- i++; // skip escaped
397
- continue;
398
- }
399
- if (text[i] === "[") {
400
- depth++;
401
- }
402
- if (text[i] === "]") {
403
- depth--;
404
- if (depth === 0) {
405
- return i;
406
- }
407
- }
408
- }
409
- return -1;
410
- }
411
-
412
- function findClosingParen(text: string, openPos: number): number {
413
- let depth = 0;
414
- for (let i = openPos; i < text.length; i++) {
415
- if (text[i] === "\\" && i + 1 < text.length) {
416
- i++;
417
- continue;
418
- }
419
- if (text[i] === "(") {
420
- depth++;
421
- }
422
- if (text[i] === ")") {
423
- depth--;
424
- if (depth === 0) {
425
- return i;
426
- }
427
- }
428
- }
429
- return -1;
430
- }
431
-
432
- /**
433
- * Parse the inside of `(...)` from a link/image (the URL and optional title).
434
- * Handles three URL forms:
435
- * - bare: `/uri` or `/uri "title"`
436
- * - angle-bracket: `<url>` or `<url> "title"` (brackets are stripped)
437
- * And three title-quote forms: `"..."`, `'...'`, `(...)`.
438
- */
439
- function parseDestinationAndTitle(raw: string): {
440
- url: string;
441
- title?: string;
442
- } {
443
- raw = raw.trim();
444
- let url: string;
445
- let rest: string;
446
-
447
- if (raw.startsWith("<")) {
448
- const close = raw.indexOf(">");
449
- if (close === -1) {
450
- // Unmatched `<` — treat the whole thing as the URL minus the `<`.
451
- url = raw.substring(1);
452
- rest = "";
453
- } else {
454
- url = raw.substring(1, close);
455
- rest = raw.substring(close + 1).trim();
456
- }
457
- } else {
458
- // Split at first unescaped whitespace.
459
- let split = raw.length;
460
- for (let i = 0; i < raw.length; i++) {
461
- if (raw[i] === "\\" && i + 1 < raw.length) {
462
- i++;
463
- continue;
464
- }
465
- if (raw[i] === " " || raw[i] === "\t" || raw[i] === "\n") {
466
- split = i;
467
- break;
468
- }
469
- }
470
- url = raw.substring(0, split);
471
- rest = raw.substring(split).trim();
472
- }
473
-
474
- let title: string | undefined;
475
- if (rest.length > 0) {
476
- const titleMatch = rest.match(/^"([^"]*)"$|^'([^']*)'$|^\(([^)]*)\)$/);
477
- if (titleMatch) {
478
- title = titleMatch[1] ?? titleMatch[2] ?? titleMatch[3];
479
- }
480
- }
481
-
482
- return { url, title };
483
- }
484
-
485
- function parseDelimited(
486
- text: string,
487
- start: number,
488
- delimiter: string,
489
- openTag: string,
490
- closeTag: string,
491
- ): { html: string; end: number } | null {
492
- const len = delimiter.length;
493
- const afterOpen = start + len;
494
-
495
- if (afterOpen >= text.length) {
496
- return null;
497
- }
498
-
499
- // Opening delimiter must not be followed by whitespace
500
- if (text[afterOpen] === " " || text[afterOpen] === "\t") {
501
- return null;
502
- }
503
-
504
- // Find closing delimiter
505
- let j = afterOpen;
506
- while (j < text.length) {
507
- // Skip escaped characters
508
- if (text[j] === "\\" && j + 1 < text.length) {
509
- j += 2;
510
- continue;
511
- }
512
-
513
- if (text.substring(j, j + len) === delimiter) {
514
- // Closing delimiter must not be preceded by whitespace
515
- if (text[j - 1] === " " || text[j - 1] === "\t") {
516
- j++;
517
- continue;
518
- }
519
-
520
- // For single-char delimiters, don't accept closer if it's part of a
521
- // multi-char run (e.g., don't treat the * in ** as italic closer)
522
- if (
523
- len === 1 &&
524
- ((j > 0 &&
525
- text[j - 1] === delimiter[0] &&
526
- !(j >= 2 && text[j - 2] === "\\")) ||
527
- (j + len < text.length && text[j + len] === delimiter[0]))
528
- ) {
529
- j++;
530
- continue;
531
- }
532
-
533
- const inner = text.substring(afterOpen, j);
534
- if (inner.length === 0) {
535
- j++;
536
- continue;
537
- }
538
-
539
- return {
540
- html: openTag + parseInline(inner) + closeTag,
541
- end: j + len,
542
- };
543
- }
544
- j++;
545
- }
546
-
547
- return null;
548
- }
549
-
550
- // ─── Block-Level Types ───────────────────────────────────────────────────────
551
-
552
- interface BlockToken {
553
- type: string;
554
- }
555
-
556
- interface HeadingToken extends BlockToken {
557
- type: "heading";
558
- level: number;
559
- content: string;
560
- }
561
-
562
- interface ParagraphToken extends BlockToken {
563
- type: "paragraph";
564
- content: string;
565
- }
566
-
567
- interface CodeBlockToken extends BlockToken {
568
- type: "codeBlock";
569
- language: string;
570
- code: string;
571
- }
572
-
573
- interface BlockquoteToken extends BlockToken {
574
- type: "blockquote";
575
- content: string;
576
- }
577
-
578
- interface HorizontalRuleToken extends BlockToken {
579
- type: "hr";
580
- }
581
-
582
- interface ListItemToken extends BlockToken {
583
- type: "listItem";
584
- listType: "bullet" | "ordered" | "task";
585
- indent: number;
586
- content: string;
587
- start?: number; // for ordered lists
588
- checked?: boolean; // for task lists
589
- childContent?: string; // recursively parsed content within this item
590
- }
591
-
592
- interface TableToken extends BlockToken {
593
- type: "table";
594
- headers: string[];
595
- rows: string[][];
596
- alignments: ("left" | "center" | "right" | null)[];
597
- }
598
-
599
- interface RawHtmlToken extends BlockToken {
600
- type: "rawHtml";
601
- content: string;
602
- }
603
-
604
- type Token =
605
- | HeadingToken
606
- | ParagraphToken
607
- | CodeBlockToken
608
- | BlockquoteToken
609
- | HorizontalRuleToken
610
- | ListItemToken
611
- | TableToken
612
- | RawHtmlToken;
613
-
614
- /**
615
- * HTML block-level tag names (from the CommonMark type-6 list, plus `audio`
616
- * which BlockNote serializes as raw HTML since markdown has no shorthand
617
- * for it). When a line starts with `<` followed by one of these tag names,
618
- * the run of non-blank lines is emitted verbatim as raw HTML rather than
619
- * wrapped in a paragraph.
620
- */
621
- const HTML_BLOCK_TAGS = new Set([
622
- "address",
623
- "article",
624
- "aside",
625
- "audio",
626
- "base",
627
- "basefont",
628
- "blockquote",
629
- "body",
630
- "caption",
631
- "center",
632
- "col",
633
- "colgroup",
634
- "dd",
635
- "details",
636
- "dialog",
637
- "dir",
638
- "div",
639
- "dl",
640
- "dt",
641
- "fieldset",
642
- "figcaption",
643
- "figure",
644
- "footer",
645
- "form",
646
- "frame",
647
- "frameset",
648
- "h1",
649
- "h2",
650
- "h3",
651
- "h4",
652
- "h5",
653
- "h6",
654
- "head",
655
- "header",
656
- "hr",
657
- "html",
658
- "iframe",
659
- "legend",
660
- "li",
661
- "link",
662
- "main",
663
- "menu",
664
- "menuitem",
665
- "nav",
666
- "noframes",
667
- "ol",
668
- "optgroup",
669
- "option",
670
- "p",
671
- "param",
672
- "section",
673
- "source",
674
- "summary",
675
- "table",
676
- "tbody",
677
- "td",
678
- "tfoot",
679
- "th",
680
- "thead",
681
- "title",
682
- "tr",
683
- "track",
684
- "ul",
685
- ]);
686
-
687
- function isHtmlBlockStart(line: string): boolean {
688
- // <!-- ..., <?..., <![CDATA[..., <!DOCTYPE, etc.
689
- if (/^ {0,3}<(!--|\?|![A-Za-z]|!\[CDATA\[)/.test(line)) {
690
- return true;
691
- }
692
- const m = line.match(/^ {0,3}<\/?([a-zA-Z][a-zA-Z0-9-]*)(?:\s|\/?>|$)/);
693
- if (!m) {
694
- return false;
695
- }
696
- return HTML_BLOCK_TAGS.has(m[1].toLowerCase());
697
- }
698
-
699
- // ─── Block-Level Tokenizer ──────────────────────────────────────────────────
700
-
701
- function tokenize(markdown: string): Token[] {
702
- const lines = markdown.split("\n");
703
- const tokens: Token[] = [];
704
- let i = 0;
705
- let prevLineWasBlank = true; // treat start of document as after blank
706
-
707
- while (i < lines.length) {
708
- const line = lines[i];
709
-
710
- // Blank line — skip
711
- if (line.trim() === "") {
712
- prevLineWasBlank = true;
713
- i++;
714
- continue;
715
- }
716
-
717
- // Fenced code block (0-3 leading spaces allowed per CommonMark)
718
- const fenceMatch = line.match(/^ {0,3}(`{3,}|~{3,})(.*)$/);
719
- if (fenceMatch) {
720
- const fence = fenceMatch[1];
721
- const fenceChar = fence[0];
722
- const fenceLen = fence.length;
723
- const language = fenceMatch[2].trim();
724
- const codeLines: string[] = [];
725
- i++;
726
- while (i < lines.length) {
727
- const closingMatch = lines[i].match(
728
- new RegExp(`^ {0,3}${fenceChar}{${fenceLen},}\\s*$`),
729
- );
730
- if (closingMatch) {
731
- i++;
732
- break;
733
- }
734
- codeLines.push(lines[i]);
735
- i++;
736
- }
737
- tokens.push({
738
- type: "codeBlock",
739
- language: language || "",
740
- code: codeLines.join("\n"),
741
- });
742
- prevLineWasBlank = false;
743
- continue;
744
- }
745
-
746
- // ATX Heading.
747
- // - Closing `#` sequence requires a preceding space (so `### foo###`
748
- // keeps the trailing #s as text, while `### foo ###` strips them).
749
- // - Trailing whitespace is always stripped from the heading content.
750
- const headingMatch = line.match(/^(#{1,6})\s+(.+?)(?:\s+#+\s*|\s*)$/);
751
- if (headingMatch) {
752
- tokens.push({
753
- type: "heading",
754
- level: headingMatch[1].length,
755
- content: headingMatch[2],
756
- });
757
- prevLineWasBlank = false;
758
- i++;
759
- continue;
760
- }
761
-
762
- // Horizontal rule: ---, ***, ___ (3+ chars, optionally with spaces)
763
- if (/^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(line)) {
764
- // Setext H2: --- immediately after a paragraph (no blank line between)
765
- const prevToken = tokens[tokens.length - 1];
766
- if (
767
- !prevLineWasBlank &&
768
- line.trim().match(/^-+$/) &&
769
- prevToken &&
770
- prevToken.type === "paragraph"
771
- ) {
772
- const para = prevToken as ParagraphToken;
773
- tokens[tokens.length - 1] = {
774
- type: "heading",
775
- level: 2,
776
- content: para.content,
777
- };
778
- prevLineWasBlank = false;
779
- i++;
780
- continue;
781
- }
782
- tokens.push({ type: "hr" });
783
- prevLineWasBlank = false;
784
- i++;
785
- continue;
786
- }
787
-
788
- // Setext heading detection: check if next line is === or ---
789
- if (i + 1 < lines.length) {
790
- const nextLine = lines[i + 1];
791
- if (/^={1,}\s*$/.test(nextLine) && line.trim().length > 0) {
792
- tokens.push({
793
- type: "heading",
794
- level: 1,
795
- content: line.trim(),
796
- });
797
- prevLineWasBlank = false;
798
- i += 2;
799
- continue;
800
- }
801
- // Setext H2 --- handled in HR section above
802
- }
803
-
804
- // Table: detect by looking for separator row
805
- const tableResult = tryParseTable(lines, i);
806
- if (tableResult) {
807
- tokens.push(tableResult.token);
808
- i = tableResult.nextLine;
809
- prevLineWasBlank = false;
810
- continue;
811
- }
812
-
813
- // Blockquote
814
- if (/^\s{0,3}>/.test(line)) {
815
- const quoteLines: string[] = [];
816
- while (i < lines.length && /^\s{0,3}>/.test(lines[i])) {
817
- // Remove the > prefix
818
- quoteLines.push(lines[i].replace(/^\s{0,3}>\s?/, ""));
819
- i++;
820
- }
821
- // Lazy continuation: collect non-blank lines that don't start a new
822
- // block-level element (per CommonMark spec)
823
- while (i < lines.length) {
824
- const cur = lines[i];
825
- if (cur.trim() === "") {
826
- break;
827
- }
828
- // Stop on block-level markers
829
- if (/^\s{0,3}>/.test(cur)) {
830
- break;
831
- } // new blockquote
832
- if (/^(#{1,6})\s/.test(cur)) {
833
- break;
834
- } // heading
835
- if (/^(`{3,}|~{3,})/.test(cur)) {
836
- break;
837
- } // code fence
838
- if (/^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(cur)) {
839
- break;
840
- } // hr
841
- if (/^\s*([-*+]|\d+[.)])\s+/.test(cur)) {
842
- break;
843
- } // list item
844
- if (/^\s*\|(.+\|)+\s*$/.test(cur)) {
845
- break;
846
- } // table
847
- quoteLines.push(cur);
848
- i++;
849
- }
850
- tokens.push({
851
- type: "blockquote",
852
- content: quoteLines.join("\n"),
853
- });
854
- prevLineWasBlank = false;
855
- continue;
856
- }
857
-
858
- // List item (bullet, ordered, or task)
859
- const listItemMatch = line.match(
860
- /^(\s*)([-*+]|\d+[.)])(\s+)(\[[ xX]\] )?(.*)$/,
861
- );
862
- if (listItemMatch) {
863
- const indent = listItemMatch[1].length;
864
- const marker = listItemMatch[2];
865
- const markerSpaces = listItemMatch[3];
866
- const checkbox = listItemMatch[4];
867
- const firstLineContent = listItemMatch[5];
868
-
869
- let listType: "bullet" | "ordered" | "task";
870
- let start: number | undefined;
871
- let checked: boolean | undefined;
872
-
873
- if (checkbox) {
874
- listType = "task";
875
- checked = checkbox.trim() !== "[ ]";
876
- } else if (/^\d+[.)]$/.test(marker)) {
877
- listType = "ordered";
878
- start = parseInt(marker, 10);
879
- } else {
880
- listType = "bullet";
881
- }
882
-
883
- // Content indent = column where content actually starts
884
- const contentIndent =
885
- indent +
886
- marker.length +
887
- markerSpaces.length +
888
- (checkbox ? checkbox.length : 0);
889
-
890
- // Minimum indent for child content: anything indented past the marker
891
- // (sub-lists can start at indent > marker position)
892
- const minChildIndent = indent + 1;
893
-
894
- // Helper to check if a line belongs to this list item
895
- const belongsToItem = (lineStr: string): boolean => {
896
- if (lineStr.trim() === "") {
897
- return true;
898
- } // blank lines checked separately
899
- const lineInd = lineStr.match(/^\s*/)![0].length;
900
- // Lines at contentIndent are continuation text
901
- if (lineInd >= contentIndent) {
902
- return true;
903
- }
904
- // Lines between marker and content column that start a sub-list
905
- if (
906
- lineInd >= minChildIndent &&
907
- lineStr.match(/^\s*([-*+]|\d+[.)])\s+/)
908
- ) {
909
- return true;
910
- }
911
- return false;
912
- };
913
-
914
- // Consume ALL subsequent lines that belong to this list item
915
- i++;
916
- const subLines: string[] = [];
917
- while (i < lines.length) {
918
- const cur = lines[i];
919
-
920
- if (cur.trim() === "") {
921
- // Blank line: include if followed by content that belongs to this item
922
- let lookAhead = i + 1;
923
- while (lookAhead < lines.length && lines[lookAhead].trim() === "") {
924
- lookAhead++;
925
- }
926
- if (lookAhead < lines.length && belongsToItem(lines[lookAhead])) {
927
- subLines.push("");
928
- i++;
929
- continue;
930
- }
931
- break;
932
- }
933
-
934
- if (!belongsToItem(cur)) {
935
- break;
936
- }
937
-
938
- // Strip indent: for lines at contentIndent+, strip contentIndent chars;
939
- // for sub-list lines between minChildIndent and contentIndent, strip minChildIndent
940
- const lineIndent = cur.match(/^\s*/)![0].length;
941
- if (lineIndent >= contentIndent) {
942
- subLines.push(cur.substring(contentIndent));
943
- } else {
944
- // Sub-list item between minChildIndent and contentIndent
945
- subLines.push(cur.substring(minChildIndent));
946
- }
947
- i++;
948
- }
949
-
950
- // Build the list item token
951
- // If there are sub-lines, they become child content (recursively tokenized)
952
- // Don't trim — preserve relative indentation of sub-lines
953
- const childContent = subLines.join("\n").replace(/^\n+|\n+$/g, "");
954
- tokens.push({
955
- type: "listItem",
956
- listType,
957
- indent,
958
- content: firstLineContent.trim(),
959
- start,
960
- checked,
961
- childContent: childContent || undefined,
962
- });
963
- prevLineWasBlank = false;
964
- continue;
965
- }
966
-
967
- // Block-level raw HTML: a line starting with `<tag>` (block-level tag),
968
- // `<!-- ... -->`, `<?...?>`, `<!DOCTYPE ...>`, or `<![CDATA[...]]>`.
969
- // Lines are emitted verbatim until the next blank line.
970
- if (isHtmlBlockStart(line)) {
971
- const htmlLines: string[] = [];
972
- while (i < lines.length && lines[i].trim() !== "") {
973
- htmlLines.push(lines[i]);
974
- i++;
975
- }
976
- tokens.push({
977
- type: "rawHtml",
978
- content: htmlLines.join("\n"),
979
- });
980
- prevLineWasBlank = false;
981
- continue;
982
- }
983
-
984
- // Paragraph (default)
985
- const paraLines: string[] = [line];
986
- i++;
987
- while (i < lines.length) {
988
- const nextLine = lines[i];
989
- // Stop paragraph on blank line
990
- if (nextLine.trim() === "") {
991
- break;
992
- }
993
- // Stop on block-level element
994
- if (/^(#{1,6})\s/.test(nextLine)) {
995
- break;
996
- }
997
- if (/^(`{3,}|~{3,})/.test(nextLine)) {
998
- break;
999
- }
1000
- if (/^\s{0,3}>/.test(nextLine)) {
1001
- break;
1002
- }
1003
- if (/^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(nextLine)) {
1004
- break;
1005
- }
1006
- if (/^\s*([-*+]|\d+[.)])\s+/.test(nextLine)) {
1007
- break;
1008
- }
1009
- if (/^\s*\|(.+\|)+\s*$/.test(nextLine)) {
1010
- break;
1011
- }
1012
- if (isHtmlBlockStart(nextLine)) {
1013
- break;
1014
- }
1015
- // Check if next-next line is setext marker
1016
- if (
1017
- i + 1 < lines.length &&
1018
- /^[=-]+\s*$/.test(lines[i + 1]) &&
1019
- nextLine.trim().length > 0
1020
- ) {
1021
- break;
1022
- }
1023
- paraLines.push(nextLine);
1024
- i++;
1025
- }
1026
- // CommonMark allows up to 3 leading spaces of indent on paragraph lines.
1027
- // Also strip trailing whitespace from the final line so a trailing
1028
- // hard-break sequence (` \n` at end of paragraph) doesn't leak as
1029
- // literal trailing spaces in the rendered output.
1030
- tokens.push({
1031
- type: "paragraph",
1032
- content: paraLines
1033
- .map((l) => l.replace(/^ {1,3}/, ""))
1034
- .join("\n")
1035
- .replace(/[ \t]+$/, ""),
1036
- });
1037
- prevLineWasBlank = false;
1038
- }
1039
-
1040
- return tokens;
1041
- }
1042
-
1043
- function tryParseTable(
1044
- lines: string[],
1045
- start: number,
1046
- ): { token: TableToken; nextLine: number } | null {
1047
- // A table needs at least a header row and a separator row
1048
- if (start + 1 >= lines.length) {
1049
- return null;
1050
- }
1051
-
1052
- const headerLine = lines[start];
1053
- const separatorLine = lines[start + 1];
1054
-
1055
- // Check separator line format: | --- | --- | or --- | --- (outer pipes optional)
1056
- // Must contain at least one pipe and only dashes, colons, pipes, and whitespace
1057
- if (
1058
- !separatorLine.includes("|") ||
1059
- !/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/.test(separatorLine)
1060
- ) {
1061
- return null;
1062
- }
1063
-
1064
- // Check header line has at least one pipe (required to distinguish from plain text)
1065
- if (!headerLine.includes("|")) {
1066
- return null;
1067
- }
1068
-
1069
- const headers = parsePipeCells(headerLine);
1070
- const alignments = parseAlignments(separatorLine);
1071
-
1072
- const rows: string[][] = [];
1073
- let i = start + 2;
1074
- while (i < lines.length) {
1075
- const line = lines[i];
1076
- if (!line.includes("|")) {
1077
- break;
1078
- }
1079
- rows.push(parsePipeCells(line));
1080
- i++;
1081
- }
1082
-
1083
- return {
1084
- token: {
1085
- type: "table",
1086
- headers,
1087
- rows,
1088
- alignments,
1089
- },
1090
- nextLine: i,
1091
- };
1092
- }
1093
-
1094
- function parsePipeCells(line: string): string[] {
1095
- // Trim leading/trailing pipes and split
1096
- const trimmed = line.trim();
1097
- const withoutOuterPipes = trimmed.startsWith("|")
1098
- ? trimmed.substring(1)
1099
- : trimmed;
1100
- const content = withoutOuterPipes.endsWith("|")
1101
- ? withoutOuterPipes.substring(0, withoutOuterPipes.length - 1)
1102
- : withoutOuterPipes;
1103
-
1104
- // Split by pipes, handling escaped pipes
1105
- const cells: string[] = [];
1106
- let current = "";
1107
- for (let i = 0; i < content.length; i++) {
1108
- if (
1109
- content[i] === "\\" &&
1110
- i + 1 < content.length &&
1111
- content[i + 1] === "|"
1112
- ) {
1113
- current += "|";
1114
- i++;
1115
- } else if (content[i] === "|") {
1116
- cells.push(current.trim());
1117
- current = "";
1118
- } else {
1119
- current += content[i];
1120
- }
1121
- }
1122
- cells.push(current.trim());
1123
-
1124
- return cells;
1125
- }
1126
-
1127
- function parseAlignments(
1128
- separatorLine: string,
1129
- ): ("left" | "center" | "right" | null)[] {
1130
- const cells = parsePipeCells(separatorLine);
1131
- return cells.map((cell) => {
1132
- const trimmed = cell.trim();
1133
- const left = trimmed.startsWith(":");
1134
- const right = trimmed.endsWith(":");
1135
- if (left && right) {
1136
- return "center";
1137
- }
1138
- if (right) {
1139
- return "right";
1140
- }
1141
- if (left) {
1142
- return "left";
1143
- }
1144
- return null;
1145
- });
1146
- }
1147
-
1148
- // ─── HTML Emitter ────────────────────────────────────────────────────────────
1149
-
1150
- function tokensToHtml(tokens: Token[]): string {
1151
- let html = "";
1152
- let i = 0;
1153
-
1154
- while (i < tokens.length) {
1155
- const token = tokens[i];
1156
-
1157
- switch (token.type) {
1158
- case "heading": {
1159
- const t = token as HeadingToken;
1160
- html += `<h${t.level}>${parseInline(t.content)}</h${t.level}>`;
1161
- i++;
1162
- break;
1163
- }
1164
-
1165
- case "paragraph": {
1166
- const t = token as ParagraphToken;
1167
- html += `<p>${parseInline(t.content)}</p>`;
1168
- i++;
1169
- break;
1170
- }
1171
-
1172
- case "codeBlock": {
1173
- const t = token as CodeBlockToken;
1174
- const langAttr = t.language
1175
- ? ` data-language="${escapeHtml(t.language)}"`
1176
- : "";
1177
- html += `<pre><code${langAttr}>${escapeHtml(t.code)}</code></pre>`;
1178
- i++;
1179
- break;
1180
- }
1181
-
1182
- case "blockquote": {
1183
- const t = token as BlockquoteToken;
1184
- // Recursively parse blockquote content as markdown
1185
- const innerTokens = tokenize(t.content);
1186
- const innerHtml = tokensToHtml(innerTokens);
1187
- html += `<blockquote>${innerHtml}</blockquote>`;
1188
- i++;
1189
- break;
1190
- }
1191
-
1192
- case "hr":
1193
- html += `<hr>`;
1194
- i++;
1195
- break;
1196
-
1197
- case "listItem": {
1198
- // Collect consecutive list items and build nested list structure
1199
- const listHtml = emitListItems(tokens, i);
1200
- html += listHtml.html;
1201
- i = listHtml.nextIndex;
1202
- break;
1203
- }
1204
-
1205
- case "table": {
1206
- const t = token as TableToken;
1207
- html += emitTable(t);
1208
- i++;
1209
- break;
1210
- }
1211
-
1212
- case "rawHtml": {
1213
- const t = token as RawHtmlToken;
1214
- html += t.content;
1215
- i++;
1216
- break;
1217
- }
1218
-
1219
- default:
1220
- i++;
1221
- }
1222
- }
1223
-
1224
- return html;
1225
- }
1226
-
1227
- function emitListItems(
1228
- tokens: Token[],
1229
- startIdx: number,
1230
- ): { html: string; nextIndex: number } {
1231
- let html = "";
1232
- let i = startIdx;
1233
- let currentListType: "bullet" | "ordered" | null = null;
1234
-
1235
- while (i < tokens.length && tokens[i].type === "listItem") {
1236
- const item = tokens[i] as ListItemToken;
1237
- const effectiveType = getEffectiveListType(item.listType);
1238
-
1239
- // Check if we need to switch list type
1240
- if (currentListType !== null && currentListType !== effectiveType) {
1241
- // Close current list, open new one
1242
- html += `</${currentListType === "ordered" ? "ol" : "ul"}>`;
1243
- currentListType = null;
1244
- }
1245
-
1246
- // Open list if needed
1247
- if (currentListType === null) {
1248
- if (effectiveType === "ordered") {
1249
- const startAttr =
1250
- item.start !== undefined && item.start !== 1
1251
- ? ` start="${item.start}"`
1252
- : "";
1253
- html += `<ol${startAttr}>`;
1254
- } else {
1255
- html += `<ul>`;
1256
- }
1257
- currentListType = effectiveType;
1258
- }
1259
-
1260
- // Emit list item
1261
- if (item.listType === "task") {
1262
- const checkedAttr = item.checked ? " checked" : "";
1263
- html += `<li><input type="checkbox" disabled${checkedAttr}><p>${parseInline(item.content)}</p>`;
1264
- } else {
1265
- html += `<li><p>${parseInline(item.content)}</p>`;
1266
- }
1267
-
1268
- // Render child content (nested items, continuation paragraphs, etc.)
1269
- if (item.childContent) {
1270
- const childTokens = tokenize(item.childContent);
1271
- html += tokensToHtml(childTokens);
1272
- }
1273
-
1274
- html += `</li>`;
1275
- i++;
1276
- }
1277
-
1278
- // Close the list
1279
- if (currentListType !== null) {
1280
- html += `</${currentListType === "ordered" ? "ol" : "ul"}>`;
1281
- }
1282
-
1283
- return { html, nextIndex: i };
1284
- }
1285
-
1286
- function getEffectiveListType(
1287
- listType: "bullet" | "ordered" | "task",
1288
- ): "bullet" | "ordered" {
1289
- return listType === "ordered" ? "ordered" : "bullet";
1290
- }
1291
-
1292
- function emitTable(table: TableToken): string {
1293
- let html = "<table>";
1294
-
1295
- // BlockNote tables have no required header row, but the markdown table
1296
- // syntax does. When we serialize a headerless BlockNote table to markdown
1297
- // we emit an empty header row; on re-parse, treat that empty header as
1298
- // "no header" so the round-trip is stable (issue #739).
1299
- const headerIsEmpty = table.headers.every((h) => h.trim() === "");
1300
- const colCount = table.headers.length;
1301
-
1302
- if (!headerIsEmpty) {
1303
- html += "<thead><tr>";
1304
- for (let c = 0; c < colCount; c++) {
1305
- const align = table.alignments[c];
1306
- const alignAttr = align ? ` align="${align}"` : "";
1307
- html += `<th${alignAttr}>${parseInline(table.headers[c])}</th>`;
1308
- }
1309
- html += "</tr></thead>";
1310
- }
1311
-
1312
- if (table.rows.length > 0) {
1313
- html += "<tbody>";
1314
- for (const row of table.rows) {
1315
- html += "<tr>";
1316
- for (let c = 0; c < colCount; c++) {
1317
- const cell = c < row.length ? row[c] : "";
1318
- const align = table.alignments[c];
1319
- const alignAttr = align ? ` align="${align}"` : "";
1320
- html += `<td${alignAttr}>${parseInline(cell)}</td>`;
1321
- }
1322
- html += "</tr>";
1323
- }
1324
- html += "</tbody>";
1325
- }
1326
-
1327
- html += "</table>";
1328
- return html;
1329
- }
1330
-
1331
- // ─── Public API ──────────────────────────────────────────────────────────────
1332
-
1333
- /**
1334
- * Convert a markdown string to an HTML string.
1335
- * This is a direct replacement for the unified/remark/rehype pipeline.
1336
- */
1337
- export function markdownToHtml(markdown: string): string {
1338
- const tokens = tokenize(markdown);
1339
- return tokensToHtml(tokens);
1340
- }