@blocknote/core 0.51.4 → 0.52.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (396) hide show
  1. package/dist/BlockNoteExtension-B_IEJHS8.js +38 -0
  2. package/dist/BlockNoteExtension-B_IEJHS8.js.map +1 -0
  3. package/dist/BlockNoteExtension-M0znTzxP.cjs +2 -0
  4. package/dist/BlockNoteExtension-M0znTzxP.cjs.map +1 -0
  5. package/dist/ThreadStore-Bx-gSEh1.cjs +2 -0
  6. package/dist/ThreadStore-Bx-gSEh1.cjs.map +1 -0
  7. package/dist/ThreadStore-et9wB5Xt.js +11 -0
  8. package/dist/ThreadStore-et9wB5Xt.js.map +1 -0
  9. package/dist/UserStore-DCG6lsla.cjs +2 -0
  10. package/dist/UserStore-DCG6lsla.cjs.map +1 -0
  11. package/dist/UserStore-QbbPFj0z.js +73 -0
  12. package/dist/UserStore-QbbPFj0z.js.map +1 -0
  13. package/dist/blocknote.cjs +1 -1
  14. package/dist/blocknote.js +6 -7
  15. package/dist/blocks-BqHv0xhc.cjs +12 -0
  16. package/dist/blocks-BqHv0xhc.cjs.map +1 -0
  17. package/dist/{blocks-DGsP5WKr.js → blocks-CiuUGa1E.js} +1093 -994
  18. package/dist/blocks-CiuUGa1E.js.map +1 -0
  19. package/dist/blocks.cjs +1 -1
  20. package/dist/blocks.js +2 -2
  21. package/dist/comments.cjs +1 -1
  22. package/dist/comments.cjs.map +1 -1
  23. package/dist/comments.js +75 -340
  24. package/dist/comments.js.map +1 -1
  25. package/dist/{en-Cj5r8sW_.cjs → en-C5Z4Ag9_.cjs} +2 -2
  26. package/dist/en-C5Z4Ag9_.cjs.map +1 -0
  27. package/dist/{en-B9hMApn4.js → en-CGKXfWma.js} +9 -1
  28. package/dist/en-CGKXfWma.js.map +1 -0
  29. package/dist/{extensions-Co4y7P63.js → extensions-CrUGDOks.js} +655 -583
  30. package/dist/extensions-CrUGDOks.js.map +1 -0
  31. package/dist/extensions-Ghr9QqqR.cjs +52 -0
  32. package/dist/extensions-Ghr9QqqR.cjs.map +1 -0
  33. package/dist/extensions.cjs +1 -1
  34. package/dist/extensions.js +4 -4
  35. package/dist/locales.cjs +1 -1
  36. package/dist/locales.cjs.map +1 -1
  37. package/dist/locales.js +177 -1
  38. package/dist/locales.js.map +1 -1
  39. package/dist/{src-Bcud0PIg.js → src-DTF83Cl9.js} +1243 -1297
  40. package/dist/src-DTF83Cl9.js.map +1 -0
  41. package/dist/src-OfbaVbMw.cjs +21 -0
  42. package/dist/src-OfbaVbMw.cjs.map +1 -0
  43. package/dist/style.css +1 -1
  44. package/dist/webpack-stats.json +1 -1
  45. package/dist/y.cjs +2 -0
  46. package/dist/y.cjs.map +1 -0
  47. package/dist/y.js +989 -0
  48. package/dist/y.js.map +1 -0
  49. package/dist/yjs.cjs +1 -1
  50. package/dist/yjs.cjs.map +1 -1
  51. package/dist/yjs.js +535 -14
  52. package/dist/yjs.js.map +1 -1
  53. package/package.json +46 -19
  54. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +1 -1
  55. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +1 -1
  56. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +3 -3
  57. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +25 -20
  58. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +39 -29
  59. package/src/api/blockManipulation/commands/nestBlock/nestBlock.test.ts +2 -2
  60. package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +4 -8
  61. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +1 -1
  62. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +21 -9
  63. package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +6 -5
  64. package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +362 -4
  65. package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +240 -30
  66. package/src/api/blockManipulation/getBlock/getBlock.ts +4 -9
  67. package/src/api/blockManipulation/selections/selection.ts +3 -6
  68. package/src/api/blockManipulation/selections/textCursorPosition.ts +10 -10
  69. package/src/api/blockManipulation/setupTestEnv.ts +1 -1
  70. package/src/api/blockManipulation/tables/tables.test.ts +1 -1
  71. package/src/api/clipboard/fromClipboard/fileDropExtension.ts +1 -1
  72. package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +8 -4
  73. package/src/api/clipboard/fromClipboard/pasteExtension.ts +1 -1
  74. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +2 -1
  75. package/src/api/exporters/markdown/htmlToMarkdown.ts +79 -43
  76. package/src/api/getBlockInfoFromPos.test.ts +256 -0
  77. package/src/api/getBlockInfoFromPos.ts +53 -15
  78. package/src/api/getBlocksChangedByTransaction.test.ts +2 -1
  79. package/src/api/getBlocksChangedByTransaction.ts +6 -6
  80. package/src/api/nodeConversions/blockToNode.test.ts +113 -0
  81. package/src/api/nodeConversions/blockToNode.ts +15 -3
  82. package/src/api/nodeConversions/fragmentToBlocks.ts +2 -4
  83. package/src/api/nodeConversions/nodeToBlock.ts +28 -58
  84. package/src/api/nodeUtil.ts +6 -2
  85. package/src/api/parsers/html/parseHTML.ts +1 -1
  86. package/src/api/parsers/html/util/nestedLists.test.ts +1 -1
  87. package/src/api/parsers/markdown/detectMarkdown.test.ts +1 -1
  88. package/src/api/parsers/markdown/markdownToHtml.ts +228 -82
  89. package/src/api/pmUtil.ts +18 -1
  90. package/src/api/positionMapping.test.ts +20 -345
  91. package/src/api/positionMapping.ts +13 -83
  92. package/src/blocks/Audio/block.ts +1 -1
  93. package/src/blocks/Code/block.test.ts +14 -7
  94. package/src/blocks/Code/block.ts +2 -2
  95. package/src/blocks/Image/block.ts +1 -1
  96. package/src/blocks/ListItem/CheckListItem/block.test.ts +1 -1
  97. package/src/blocks/ListItem/ListItemKeyboardShortcuts.ts +2 -2
  98. package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.ts +4 -11
  99. package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +47 -50
  100. package/src/blocks/Table/TableExtension.test.ts +9 -6
  101. package/src/blocks/Table/TableExtension.ts +20 -6
  102. package/src/blocks/Table/block.ts +18 -5
  103. package/src/blocks/Video/block.ts +1 -1
  104. package/src/blocks/utils/listItemEnterHandler.ts +3 -2
  105. package/src/comments/extension.ts +30 -21
  106. package/src/comments/index.ts +0 -3
  107. package/src/comments/mark.ts +4 -0
  108. package/src/comments/threadstore/ThreadStore.ts +4 -8
  109. package/src/comments/types.ts +0 -8
  110. package/src/editor/Block.css +307 -3
  111. package/src/editor/BlockNoteEditor.test.ts +21 -18
  112. package/src/editor/BlockNoteEditor.ts +22 -57
  113. package/src/editor/BlockNoteExtension.test.ts +1 -1
  114. package/src/editor/managers/BlockManager.ts +1 -1
  115. package/src/editor/managers/ExtensionManager/ExtensionManager.test.ts +249 -0
  116. package/src/editor/managers/ExtensionManager/extensions.ts +7 -18
  117. package/src/editor/managers/ExtensionManager/index.ts +168 -68
  118. package/src/editor/managers/StateManager.ts +4 -3
  119. package/src/editor/performance.test.ts +14 -1
  120. package/src/editor/transformPasted.test.ts +1 -1
  121. package/src/extensions/Placeholder/Placeholder.ts +1 -0
  122. package/src/extensions/PositionMapping/PositionMapping.ts +68 -0
  123. package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +14 -1
  124. package/src/extensions/PreviousBlockType/PreviousBlockType.ts +14 -11
  125. package/src/extensions/SideMenu/SideMenu.ts +9 -2
  126. package/src/extensions/SuggestionMenu/SuggestionMenu.test.ts +1 -1
  127. package/src/extensions/TableHandles/TableHandles.ts +18 -20
  128. package/src/extensions/TrailingNode/TrailingNode.ts +33 -1
  129. package/src/extensions/Versioning/Versioning.test.ts +435 -0
  130. package/src/extensions/Versioning/Versioning.ts +628 -0
  131. package/src/extensions/Versioning/inMemoryVersioning.test.ts +469 -0
  132. package/src/extensions/Versioning/inMemoryVersioning.ts +263 -0
  133. package/src/extensions/Versioning/index.ts +2 -0
  134. package/src/extensions/index.ts +6 -9
  135. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts +155 -0
  136. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +6 -8
  137. package/src/extensions/tiptap-extensions/Link/helpers/autolink.ts +9 -9
  138. package/src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts +8 -10
  139. package/src/extensions/tiptap-extensions/Link/helpers/whitespace.ts +2 -2
  140. package/src/extensions/tiptap-extensions/Link/link.test.ts +26 -22
  141. package/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.ts +187 -0
  142. package/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts +37 -24
  143. package/src/extensions/tiptap-extensions/index.ts +1 -25
  144. package/src/i18n/locales/ar.ts +9 -0
  145. package/src/i18n/locales/de.ts +9 -0
  146. package/src/i18n/locales/en.ts +10 -1
  147. package/src/i18n/locales/es.ts +9 -0
  148. package/src/i18n/locales/fa.ts +11 -1
  149. package/src/i18n/locales/fr.ts +9 -0
  150. package/src/i18n/locales/he.ts +10 -1
  151. package/src/i18n/locales/hr.ts +10 -0
  152. package/src/i18n/locales/is.ts +10 -0
  153. package/src/i18n/locales/it.ts +9 -0
  154. package/src/i18n/locales/ja.ts +9 -0
  155. package/src/i18n/locales/ko.ts +9 -0
  156. package/src/i18n/locales/nl.ts +10 -0
  157. package/src/i18n/locales/no.ts +10 -0
  158. package/src/i18n/locales/pl.ts +9 -0
  159. package/src/i18n/locales/pt.ts +10 -0
  160. package/src/i18n/locales/ru.ts +10 -0
  161. package/src/i18n/locales/sk.ts +10 -1
  162. package/src/i18n/locales/uk.ts +9 -0
  163. package/src/i18n/locales/uz.ts +9 -0
  164. package/src/i18n/locales/vi.ts +9 -0
  165. package/src/i18n/locales/zh-tw.ts +9 -0
  166. package/src/i18n/locales/zh.ts +9 -0
  167. package/src/index.ts +2 -0
  168. package/src/pm-nodes/BlockContainer.ts +4 -1
  169. package/src/pm-nodes/BlockGroup.ts +4 -1
  170. package/src/pm-nodes/Doc.ts +4 -1
  171. package/src/pm-nodes/suggestionMarks.ts +43 -0
  172. package/src/schema/blocks/createSpec.test.ts +123 -0
  173. package/src/schema/blocks/createSpec.ts +82 -24
  174. package/src/schema/blocks/extendBlockSpec.test.ts +188 -0
  175. package/src/schema/blocks/internal.ts +13 -43
  176. package/src/schema/blocks/types.ts +69 -22
  177. package/src/schema/contentTypePropagation.test.ts +182 -0
  178. package/src/schema/index.ts +1 -0
  179. package/src/schema/inlineContent/internal.ts +1 -1
  180. package/src/schema/inlineContent/types.ts +3 -3
  181. package/src/schema/markGroups.ts +50 -0
  182. package/src/user/UserStore.ts +199 -0
  183. package/src/user/createUserStore.test.ts +126 -0
  184. package/src/user/index.ts +2 -0
  185. package/src/user/userColors.ts +72 -0
  186. package/src/util/string.ts +1 -1
  187. package/src/util/topo-sort.test.ts +1 -1
  188. package/src/util/typescript.ts +2 -1
  189. package/src/vite-env.d.ts +1 -1
  190. package/src/y/README.md +5 -0
  191. package/src/{comments/threadstore/yjs → y/comments}/RESTYjsThreadStore.ts +8 -14
  192. package/src/y/comments/YjsThreadStore.test.ts +295 -0
  193. package/src/y/comments/YjsThreadStore.ts +358 -0
  194. package/src/y/comments/YjsThreadStoreBase.ts +50 -0
  195. package/src/y/comments/index.ts +3 -0
  196. package/src/y/comments/yjsHelpers.ts +125 -0
  197. package/src/y/extensions/AttributionExtension.test.ts +86 -0
  198. package/src/y/extensions/AttributionExtension.ts +378 -0
  199. package/src/y/extensions/DiffVersioningExtension.test.ts +193 -0
  200. package/src/y/extensions/DiffVersioningExtension.ts +228 -0
  201. package/src/y/extensions/ForkYDoc.test.ts +253 -0
  202. package/src/y/extensions/ForkYDoc.ts +108 -0
  203. package/src/y/extensions/RelativePositionMapping.test.ts +418 -0
  204. package/src/y/extensions/RelativePositionMapping.ts +49 -0
  205. package/src/y/extensions/Suggestions.ts +174 -0
  206. package/src/y/extensions/Versioning.test.ts +395 -0
  207. package/src/y/extensions/Versioning.ts +115 -0
  208. package/src/y/extensions/YAttributionMarks.ts +320 -0
  209. package/src/{extensions/Collaboration → y/extensions}/YCursorPlugin.ts +15 -7
  210. package/src/y/extensions/YSync.ts +125 -0
  211. package/src/y/extensions/blockMatchNodes.ts +182 -0
  212. package/src/y/extensions/index.ts +156 -0
  213. package/src/y/index.ts +4 -0
  214. package/src/y/utils.test.ts +1042 -0
  215. package/src/y/utils.ts +242 -0
  216. package/src/y/versioning/__test__/fixtures/activity-all-after.bin +0 -0
  217. package/src/y/versioning/__test__/fixtures/activity-all-after.json +50 -0
  218. package/src/y/versioning/__test__/fixtures/activity-all.bin +0 -0
  219. package/src/y/versioning/__test__/fixtures/activity-all.json +20 -0
  220. package/src/y/versioning/__test__/fixtures/activity-filtered-after.bin +0 -0
  221. package/src/y/versioning/__test__/fixtures/activity-filtered-after.json +32 -0
  222. package/src/y/versioning/__test__/fixtures/activity-filtered-before.json +1 -0
  223. package/src/y/versioning/__test__/fixtures/changeset.bin +0 -0
  224. package/src/y/versioning/__test__/fixtures/patch-response.json +4 -0
  225. package/src/y/versioning/__test__/yhub.test.ts +752 -0
  226. package/src/y/versioning/index.ts +1 -0
  227. package/src/y/versioning/yhub.ts +631 -0
  228. package/src/yjs/README.md +5 -0
  229. package/src/yjs/comments/RESTYjsThreadStore.ts +166 -0
  230. package/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStore.test.ts +3 -3
  231. package/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStore.ts +7 -3
  232. package/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStoreBase.ts +3 -3
  233. package/src/yjs/comments/index.ts +3 -0
  234. package/src/{comments/threadstore/yjs → yjs/comments}/yjsHelpers.ts +5 -1
  235. package/src/yjs/extensions/FixUpSchema.test.ts +421 -0
  236. package/src/yjs/extensions/FixUpSchema.ts +88 -0
  237. package/src/yjs/extensions/ForkYDoc.test.ts +216 -0
  238. package/src/{extensions/Collaboration → yjs/extensions}/ForkYDoc.ts +38 -57
  239. package/src/yjs/extensions/RelativePositionMapping.test.ts +418 -0
  240. package/src/yjs/extensions/RelativePositionMapping.ts +71 -0
  241. package/src/yjs/extensions/Versioning.test.ts +549 -0
  242. package/src/yjs/extensions/Versioning.ts +83 -0
  243. package/src/yjs/extensions/YCursorPlugin.ts +201 -0
  244. package/src/{extensions/Collaboration → yjs/extensions}/YSync.ts +1 -1
  245. package/src/yjs/extensions/index.ts +89 -0
  246. package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/moveColorAttributes.test.ts +1 -1
  247. package/src/yjs/index.ts +2 -0
  248. package/src/yjs/utils.test.ts +5 -15
  249. package/src/yjs/utils.ts +36 -0
  250. package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.d.ts +3 -1
  251. package/types/src/api/blockManipulation/selections/selection.d.ts +1 -1
  252. package/types/src/api/getBlockInfoFromPos.d.ts +5 -9
  253. package/types/src/api/nodeConversions/nodeToBlock.d.ts +4 -6
  254. package/types/src/api/pmUtil.d.ts +12 -1
  255. package/types/src/blocks/Audio/block.d.ts +2 -2
  256. package/types/src/blocks/Code/block.d.ts +2 -2
  257. package/types/src/blocks/File/block.d.ts +2 -2
  258. package/types/src/blocks/Heading/block.d.ts +21 -21
  259. package/types/src/blocks/Image/block.d.ts +3 -3
  260. package/types/src/blocks/ListItem/CheckListItem/block.d.ts +6 -6
  261. package/types/src/blocks/ListItem/NumberedListItem/block.d.ts +6 -6
  262. package/types/src/blocks/Video/block.d.ts +3 -3
  263. package/types/src/blocks/defaultBlocks.d.ts +17 -17
  264. package/types/src/comments/extension.d.ts +18 -5
  265. package/types/src/comments/index.d.ts +0 -3
  266. package/types/src/comments/threadstore/ThreadStore.d.ts +4 -8
  267. package/types/src/comments/types.d.ts +0 -8
  268. package/types/src/editor/BlockNoteEditor.d.ts +8 -9
  269. package/types/src/editor/managers/BlockManager.d.ts +1 -1
  270. package/types/src/editor/managers/ExtensionManager/extensions.d.ts +2 -2
  271. package/types/src/editor/managers/ExtensionManager/index.d.ts +13 -0
  272. package/types/src/editor/managers/SelectionManager.d.ts +1 -1
  273. package/types/src/extensions/PositionMapping/PositionMapping.d.ts +4 -0
  274. package/types/src/extensions/TableHandles/TableHandles.d.ts +6 -6
  275. package/types/src/extensions/Versioning/Versioning.d.ts +352 -0
  276. package/types/src/extensions/Versioning/Versioning.test.d.ts +1 -0
  277. package/types/src/extensions/Versioning/inMemoryVersioning.d.ts +37 -0
  278. package/types/src/extensions/Versioning/inMemoryVersioning.test.d.ts +1 -0
  279. package/types/src/extensions/Versioning/index.d.ts +2 -0
  280. package/types/src/extensions/index.d.ts +6 -9
  281. package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.d.ts +1 -0
  282. package/types/src/extensions/tiptap-extensions/UniqueID/UniqueID.d.ts +6 -1
  283. package/types/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.d.ts +4 -0
  284. package/types/src/extensions/tiptap-extensions/index.d.ts +1 -5
  285. package/types/src/i18n/locales/en.d.ts +9 -1
  286. package/types/src/i18n/locales/fa.d.ts +9 -1
  287. package/types/src/i18n/locales/sk.d.ts +9 -1
  288. package/types/src/index.d.ts +2 -0
  289. package/types/src/pm-nodes/suggestionMarks.d.ts +26 -0
  290. package/types/src/schema/blocks/createSpec.d.ts +4 -4
  291. package/types/src/schema/blocks/createSpec.test.d.ts +1 -0
  292. package/types/src/schema/blocks/extendBlockSpec.test.d.ts +1 -0
  293. package/types/src/schema/blocks/internal.d.ts +5 -7
  294. package/types/src/schema/blocks/types.d.ts +22 -14
  295. package/types/src/schema/contentTypePropagation.test.d.ts +1 -0
  296. package/types/src/schema/index.d.ts +1 -0
  297. package/types/src/schema/inlineContent/types.d.ts +3 -3
  298. package/types/src/schema/markGroups.d.ts +33 -0
  299. package/types/src/user/UserStore.d.ts +105 -0
  300. package/types/src/user/createUserStore.test.d.ts +1 -0
  301. package/types/src/user/index.d.ts +2 -0
  302. package/types/src/user/userColors.d.ts +36 -0
  303. package/types/src/y/comments/RESTYjsThreadStore.d.ts +77 -0
  304. package/types/src/y/comments/YjsThreadStore.d.ts +79 -0
  305. package/types/src/y/comments/YjsThreadStore.test.d.ts +1 -0
  306. package/types/src/y/comments/YjsThreadStoreBase.d.ts +15 -0
  307. package/types/src/y/comments/index.d.ts +3 -0
  308. package/types/src/y/comments/yjsHelpers.d.ts +13 -0
  309. package/types/src/y/extensions/AttributionExtension.d.ts +74 -0
  310. package/types/src/y/extensions/AttributionExtension.test.d.ts +1 -0
  311. package/types/src/y/extensions/DiffVersioningExtension.d.ts +69 -0
  312. package/types/src/y/extensions/DiffVersioningExtension.test.d.ts +1 -0
  313. package/types/src/{extensions/Collaboration → y/extensions}/ForkYDoc.d.ts +4 -2
  314. package/types/src/y/extensions/ForkYDoc.test.d.ts +1 -0
  315. package/types/src/y/extensions/RelativePositionMapping.d.ts +4 -0
  316. package/types/src/y/extensions/RelativePositionMapping.test.d.ts +1 -0
  317. package/types/src/y/extensions/Suggestions.d.ts +36 -0
  318. package/types/src/y/extensions/Versioning.d.ts +17 -0
  319. package/types/src/y/extensions/Versioning.test.d.ts +1 -0
  320. package/types/src/y/extensions/YAttributionMarks.d.ts +67 -0
  321. package/types/src/y/extensions/YCursorPlugin.d.ts +14 -0
  322. package/types/src/y/extensions/YSync.d.ts +32 -0
  323. package/types/src/y/extensions/blockMatchNodes.d.ts +25 -0
  324. package/types/src/y/extensions/index.d.ts +189 -0
  325. package/types/src/y/index.d.ts +4 -0
  326. package/types/src/y/utils.d.ts +82 -0
  327. package/types/src/y/utils.test.d.ts +1 -0
  328. package/types/src/y/versioning/__test__/yhub.test.d.ts +1 -0
  329. package/types/src/y/versioning/index.d.ts +1 -0
  330. package/types/src/y/versioning/yhub.d.ts +87 -0
  331. package/types/src/{comments/threadstore/yjs → yjs/comments}/RESTYjsThreadStore.d.ts +6 -10
  332. package/types/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStore.d.ts +3 -3
  333. package/types/src/yjs/comments/YjsThreadStore.test.d.ts +1 -0
  334. package/types/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStoreBase.d.ts +3 -3
  335. package/types/src/yjs/comments/index.d.ts +3 -0
  336. package/types/src/{comments/threadstore/yjs → yjs/comments}/yjsHelpers.d.ts +1 -1
  337. package/types/src/yjs/extensions/FixUpSchema.d.ts +3 -0
  338. package/types/src/yjs/extensions/FixUpSchema.test.d.ts +1 -0
  339. package/types/src/yjs/extensions/ForkYDoc.d.ts +27 -0
  340. package/types/src/yjs/extensions/ForkYDoc.test.d.ts +1 -0
  341. package/types/src/yjs/extensions/RelativePositionMapping.d.ts +4 -0
  342. package/types/src/yjs/extensions/RelativePositionMapping.test.d.ts +1 -0
  343. package/types/src/yjs/extensions/Versioning.d.ts +26 -0
  344. package/types/src/yjs/extensions/Versioning.test.d.ts +1 -0
  345. package/types/src/{extensions/Collaboration → yjs/extensions}/YCursorPlugin.d.ts +5 -2
  346. package/types/src/{extensions/Collaboration → yjs/extensions}/YSync.d.ts +1 -1
  347. package/types/src/{extensions/Collaboration/Collaboration.d.ts → yjs/extensions/index.d.ts} +36 -15
  348. package/types/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.test.d.ts +1 -0
  349. package/types/src/yjs/index.d.ts +2 -0
  350. package/types/src/yjs/utils.d.ts +5 -0
  351. package/dist/BlockNoteExtension-B6RhuQ3V.js +0 -27
  352. package/dist/BlockNoteExtension-B6RhuQ3V.js.map +0 -1
  353. package/dist/BlockNoteExtension-ab0REuob.cjs +0 -2
  354. package/dist/BlockNoteExtension-ab0REuob.cjs.map +0 -1
  355. package/dist/EventEmitter-CuPnGDYt.js +0 -22
  356. package/dist/EventEmitter-CuPnGDYt.js.map +0 -1
  357. package/dist/EventEmitter-DHdSnYCD.cjs +0 -2
  358. package/dist/EventEmitter-DHdSnYCD.cjs.map +0 -1
  359. package/dist/ShowSelection-BsHFfdMi.js +0 -29
  360. package/dist/ShowSelection-BsHFfdMi.js.map +0 -1
  361. package/dist/ShowSelection-DhXglbt8.cjs +0 -2
  362. package/dist/ShowSelection-DhXglbt8.cjs.map +0 -1
  363. package/dist/blocks-Bm6IfL1R.cjs +0 -11
  364. package/dist/blocks-Bm6IfL1R.cjs.map +0 -1
  365. package/dist/blocks-DGsP5WKr.js.map +0 -1
  366. package/dist/en-B9hMApn4.js.map +0 -1
  367. package/dist/en-Cj5r8sW_.cjs.map +0 -1
  368. package/dist/extensions-Co4y7P63.js.map +0 -1
  369. package/dist/extensions-IJK3t0sz.cjs +0 -52
  370. package/dist/extensions-IJK3t0sz.cjs.map +0 -1
  371. package/dist/src-B6rlChSc.cjs +0 -21
  372. package/dist/src-B6rlChSc.cjs.map +0 -1
  373. package/dist/src-Bcud0PIg.js.map +0 -1
  374. package/src/comments/userstore/UserStore.ts +0 -72
  375. package/src/extensions/Collaboration/Collaboration.ts +0 -55
  376. package/src/extensions/Collaboration/ForkYDoc.test.ts +0 -179
  377. package/src/extensions/tiptap-extensions/Suggestions/SuggestionMarks.ts +0 -175
  378. package/types/src/comments/userstore/UserStore.d.ts +0 -31
  379. package/types/src/extensions/tiptap-extensions/Suggestions/SuggestionMarks.d.ts +0 -4
  380. /package/src/{extensions/Collaboration → yjs/extensions}/YUndo.ts +0 -0
  381. /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap-editor-forked.json +0 -0
  382. /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap-editor.json +0 -0
  383. /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap-forked.html +0 -0
  384. /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap.html +0 -0
  385. /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/SchemaMigration.ts +0 -0
  386. /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/index.ts +0 -0
  387. /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/migrationRule.ts +0 -0
  388. /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/moveColorAttributes.ts +0 -0
  389. /package/types/src/{comments/threadstore/yjs/YjsThreadStore.test.d.ts → api/getBlockInfoFromPos.test.d.ts} +0 -0
  390. /package/types/src/{extensions/Collaboration/ForkYDoc.test.d.ts → api/nodeConversions/blockToNode.test.d.ts} +0 -0
  391. /package/types/src/{extensions/Collaboration/schemaMigration/migrationRules/moveColorAttributes.test.d.ts → editor/managers/ExtensionManager/ExtensionManager.test.d.ts} +0 -0
  392. /package/types/src/{extensions/Collaboration → yjs/extensions}/YUndo.d.ts +0 -0
  393. /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/SchemaMigration.d.ts +0 -0
  394. /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/index.d.ts +0 -0
  395. /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/migrationRule.d.ts +0 -0
  396. /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/moveColorAttributes.d.ts +0 -0
@@ -0,0 +1,87 @@
1
+ import * as Y from "@y/y";
2
+ import { VersioningEndpointsFactory } from "../../extensions/Versioning/index.js";
3
+ /**
4
+ * Options for creating a YHub versioning endpoints instance.
5
+ */
6
+ export interface YHubVersioningOptions {
7
+ /**
8
+ * Base URL of the YHub API (e.g. `"https://yhub.example.com"`).
9
+ * Must **not** include a trailing slash.
10
+ */
11
+ baseUrl: string;
12
+ /** YHub organisation identifier. */
13
+ org: string;
14
+ /** Document identifier within the organisation. */
15
+ docId: string;
16
+ /**
17
+ * Optional headers to include in every request (e.g. authentication tokens).
18
+ */
19
+ headers?: Record<string, string>;
20
+ /**
21
+ * Maximum number of activity entries to fetch when listing versions.
22
+ * @default 50
23
+ */
24
+ activityLimit?: number;
25
+ /**
26
+ * When set, forwarded as the `group` query param to the YHub activity API,
27
+ * controlling whether adjacent edits are grouped into single entries.
28
+ */
29
+ group?: boolean;
30
+ /**
31
+ * Maximum gap (in ms) between edits for them to be grouped together.
32
+ * Forwarded as the `groupMaxGap` query param.
33
+ * @default 10000
34
+ */
35
+ groupMaxGap?: number;
36
+ /**
37
+ * Maximum total duration (in ms) a single group of edits may span.
38
+ * When set, forwarded as the `groupMaxDuration` query param.
39
+ */
40
+ groupMaxDuration?: number;
41
+ /**
42
+ * When `true`, adjacent edits are grouped together even when made by
43
+ * *different* users (their ids accumulate in the grouped entry's `by`).
44
+ * When `false` (the default), only same-user adjacent edits are merged.
45
+ * Forwarded as the `mergeUsers` query param.
46
+ * @default false
47
+ */
48
+ mergeUsers?: boolean;
49
+ }
50
+ /**
51
+ * Create a {@link VersioningEndpoints} implementation backed by the
52
+ * [YHub](https://github.com/yjs/yhub) HTTP API.
53
+ *
54
+ * Versions are created by PATCHing the document with custom attributions
55
+ * (`type:version` + an optional `name`). The `list` endpoint returns the full
56
+ * activity timeline, mapping `type:version` markers to named versions and every
57
+ * other entry to a history-only snapshot, so the sidebar can show both the
58
+ * named versions and the complete edit history.
59
+ *
60
+ * A version's id lives in immutable YHub attributions (`type:version` + `id`),
61
+ * so it is fixed at creation time. Version *names*, however, are stored in a
62
+ * mutable `__bn_version_names` map on the live collaboration doc (see
63
+ * {@link VERSION_NAMES_MAP}), so `rename` is supported and simply updates that
64
+ * store.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * import { withCollaboration } from "@blocknote/core/y";
69
+ * import { createYHubVersioningEndpoints } from "@blocknote/core/y";
70
+ *
71
+ * const editor = BlockNoteEditor.create(
72
+ * withCollaboration({
73
+ * collaboration: {
74
+ * fragment,
75
+ * user: { name: "Alice", color: "#ff0" },
76
+ * provider,
77
+ * versioningEndpoints: createYHubVersioningEndpoints({
78
+ * baseUrl: "https://yhub.example.com",
79
+ * org: "my-org",
80
+ * docId: "my-doc",
81
+ * }),
82
+ * },
83
+ * }),
84
+ * );
85
+ * ```
86
+ */
87
+ export declare function createYHubVersioningEndpoints(options: YHubVersioningOptions): VersioningEndpointsFactory<Y.Type, Uint8Array, Y.ContentMap>;
@@ -1,7 +1,8 @@
1
1
  import * as Y from "yjs";
2
- import { CommentBody } from "../../types.js";
3
- import { ThreadStoreAuth } from "../ThreadStoreAuth.js";
2
+ import type { CommentBody } from "../../comments/types.js";
3
+ import type { ThreadStoreAuth } from "../../comments/threadstore/ThreadStoreAuth.js";
4
4
  import { YjsThreadStoreBase } from "./YjsThreadStoreBase.js";
5
+ import { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
5
6
  /**
6
7
  * This is a REST-based implementation of the YjsThreadStoreBase.
7
8
  * It Reads data directly from the underlying document (same as YjsThreadStore),
@@ -24,15 +25,10 @@ export declare class RESTYjsThreadStore extends YjsThreadStoreBase {
24
25
  addThreadToDocument: (options: {
25
26
  threadId: string;
26
27
  selection: {
27
- prosemirror: {
28
- head: number;
29
- anchor: number;
30
- };
31
- yjs: {
32
- head: any;
33
- anchor: any;
34
- };
28
+ head: number;
29
+ anchor: number;
35
30
  };
31
+ editor: BlockNoteEditor<any, any, any>;
36
32
  }) => Promise<any>;
37
33
  createThread: (options: {
38
34
  initialComment: {
@@ -1,6 +1,6 @@
1
1
  import * as Y from "yjs";
2
- import { CommentBody, ThreadData } from "../../types.js";
3
- import { ThreadStoreAuth } from "../ThreadStoreAuth.js";
2
+ import type { CommentBody, ThreadData } from "../../comments/types.js";
3
+ import type { ThreadStoreAuth } from "../../comments/threadstore/ThreadStoreAuth.js";
4
4
  import { YjsThreadStoreBase } from "./YjsThreadStoreBase.js";
5
5
  /**
6
6
  * This is a Yjs-based implementation of the ThreadStore interface.
@@ -38,7 +38,7 @@ export declare class YjsThreadStore extends YjsThreadStoreBase {
38
38
  userId: string;
39
39
  createdAt: Date;
40
40
  updatedAt: Date;
41
- reactions: import("../../types.js").CommentReactionData[];
41
+ reactions: import("../../comments/types.js").CommentReactionData[];
42
42
  metadata: any;
43
43
  } & {
44
44
  deletedAt?: never;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,7 @@
1
1
  import * as Y from "yjs";
2
- import { ThreadData } from "../../types.js";
3
- import { ThreadStore } from "../ThreadStore.js";
4
- import { ThreadStoreAuth } from "../ThreadStoreAuth.js";
2
+ import type { ThreadData } from "../../comments/types.js";
3
+ import { ThreadStore } from "../../comments/threadstore/ThreadStore.js";
4
+ import type { ThreadStoreAuth } from "../../comments/threadstore/ThreadStoreAuth.js";
5
5
  /**
6
6
  * This is an abstract class that only implements the READ methods required by the ThreadStore interface.
7
7
  * The data is read from a Yjs Map.
@@ -0,0 +1,3 @@
1
+ export * from "./RESTYjsThreadStore.js";
2
+ export * from "./YjsThreadStore.js";
3
+ export * from "./YjsThreadStoreBase.js";
@@ -1,5 +1,5 @@
1
1
  import * as Y from "yjs";
2
- import { CommentData, ThreadData } from "../../types.js";
2
+ import type { CommentData, ThreadData } from "../../comments/types.js";
3
3
  export declare function commentToYMap(comment: CommentData): Y.Map<any>;
4
4
  export declare function threadToYMap(thread: ThreadData): Y.Map<unknown>;
5
5
  type SingleUserCommentReactionData = {
@@ -0,0 +1,3 @@
1
+ export declare const FixUpSchemaExtension: (options?: any) => import("../../index.js").ExtensionFactoryInstance<{
2
+ readonly key: "fixUpSchema";
3
+ }>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,27 @@
1
+ import type { CollaborationOptions } from "./index.js";
2
+ export declare const ForkYDocExtension: (options: CollaborationOptions) => import("../../index.js").ExtensionFactoryInstance<{
3
+ readonly key: "yForkDoc";
4
+ readonly store: import("@tanstack/store").Store<{
5
+ isForked: boolean;
6
+ }, (cb: {
7
+ isForked: boolean;
8
+ }) => {
9
+ isForked: boolean;
10
+ }>;
11
+ /**
12
+ * Fork the Y.js document from syncing to the remote,
13
+ * allowing modifications to the document without affecting the remote.
14
+ * These changes can later be rolled back or applied to the remote.
15
+ */
16
+ readonly fork: ({ initialUpdate, }?: {
17
+ initialUpdate?: Uint8Array;
18
+ }) => void;
19
+ /**
20
+ * Resume syncing the Y.js document to the remote
21
+ * If `keepChanges` is true, any changes that have been made to the forked document will be applied to the original document.
22
+ * Otherwise, the original document will be restored and the changes will be discarded.
23
+ */
24
+ readonly merge: ({ keepChanges }: {
25
+ keepChanges: boolean;
26
+ }) => void;
27
+ }>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export declare const RelativePositionMappingExtension: (options?: any) => import("../../index.js").ExtensionFactoryInstance<{
2
+ readonly key: "yPositionMapping";
3
+ readonly mapPosition: (position: number, side?: "left" | "right") => () => number;
4
+ }>;
@@ -0,0 +1,26 @@
1
+ import * as Y from "yjs";
2
+ import type { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
3
+ import type { PreviewController } from "../../extensions/Versioning/index.js";
4
+ import type { CollaborationOptions } from "./index.js";
5
+ /**
6
+ * Creates a Yjs v13 adapter that provides the {@link PreviewController}
7
+ * and `getCurrentDocument` callback required by the base
8
+ * {@link VersioningExtension}.
9
+ *
10
+ * Delegates to the {@link ForkYDocExtension} for entering/exiting preview:
11
+ * - **enterPreview**: calls `fork({ initialUpdate: snapshotContent })` to
12
+ * switch the editor to a temporary doc built from the snapshot.
13
+ * - **exitPreview**: calls `merge({ keepChanges: false })` to discard the
14
+ * preview and restore the live document.
15
+ * - **applyRestore**: calls `merge({ keepChanges: true })` to apply the
16
+ * snapshot content back to the live document.
17
+ */
18
+ export declare function createYjsVersioningAdapter(
19
+ /** The BlockNote editor instance (must have ForkYDocExtension). */
20
+ editor: BlockNoteEditor<any, any, any>,
21
+ /** The full collaboration options (used for `fragment` access). */
22
+ options: CollaborationOptions): {
23
+ preview: PreviewController<Uint8Array>;
24
+ getCurrentDocument: () => Y.XmlFragment;
25
+ serializeCurrentContent: () => Uint8Array;
26
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,11 +1,13 @@
1
- import { CollaborationOptions } from "./Collaboration.js";
1
+ import type { CollaborationOptions } from "./index.js";
2
2
  export type CollaborationUser = {
3
+ id?: string;
3
4
  name: string;
4
5
  color: string;
5
- [key: string]: string;
6
+ [key: string]: unknown;
6
7
  };
7
8
  export declare const YCursorExtension: (options: CollaborationOptions) => import("../../index.js").ExtensionFactoryInstance<{
8
9
  readonly key: "yCursor";
10
+ readonly mount: () => (() => void) | undefined;
9
11
  readonly prosemirrorPlugins: any[];
10
12
  readonly dependsOn: readonly ["ySync"];
11
13
  readonly updateUser: (user: {
@@ -13,4 +15,5 @@ export declare const YCursorExtension: (options: CollaborationOptions) => import
13
15
  color: string;
14
16
  [key: string]: string;
15
17
  }) => void;
18
+ readonly getUser: () => CollaborationUser | undefined;
16
19
  }>;
@@ -1,4 +1,4 @@
1
- import { CollaborationOptions } from "./Collaboration.js";
1
+ import type { CollaborationOptions } from "./index.js";
2
2
  export declare const YSyncExtension: (options: Pick<CollaborationOptions, "fragment">) => import("../../index.js").ExtensionFactoryInstance<{
3
3
  readonly key: "ySync";
4
4
  readonly prosemirrorPlugins: readonly [any];
@@ -1,5 +1,7 @@
1
- import type * as Y from "yjs";
2
1
  import type { Awareness } from "y-protocols/awareness";
2
+ import type * as Y from "yjs";
3
+ import type { BlockNoteEditorOptions } from "../../editor/BlockNoteEditor";
4
+ import { CollaborationUser } from "./YCursorPlugin.js";
3
5
  export type CollaborationOptions = {
4
6
  /**
5
7
  * The Yjs XML fragment that's used for collaboration.
@@ -8,10 +10,7 @@ export type CollaborationOptions = {
8
10
  /**
9
11
  * The user info for the current user that's shown to other collaborators.
10
12
  */
11
- user: {
12
- name: string;
13
- color: string;
14
- };
13
+ user: CollaborationUser;
15
14
  /**
16
15
  * A Yjs provider (used for awareness / cursor information)
17
16
  */
@@ -21,7 +20,7 @@ export type CollaborationOptions = {
21
20
  /**
22
21
  * Optional function to customize how cursors of users are rendered
23
22
  */
24
- renderCursor?: (user: any) => HTMLElement;
23
+ renderCursor?: (user: CollaborationUser) => HTMLElement;
25
24
  /**
26
25
  * Optional flag to set when the user label should be shown with the default
27
26
  * collaboration cursor. Setting to "always" will always show the label,
@@ -30,9 +29,11 @@ export type CollaborationOptions = {
30
29
  */
31
30
  showCursorLabels?: "always" | "activity";
32
31
  };
33
- export declare const CollaborationExtension: (options: CollaborationOptions) => import("../../index.js").ExtensionFactoryInstance<{
32
+ export declare const CollaborationExtension: (options: CollaborationOptions) => import("../..").ExtensionFactoryInstance<{
34
33
  readonly key: "collaboration";
35
- readonly blockNoteExtensions: readonly [import("../../index.js").ExtensionFactoryInstance<{
34
+ readonly blockNoteExtensions: readonly [import("../..").ExtensionFactoryInstance<{
35
+ readonly key: "fixUpSchema";
36
+ }>, import("../..").ExtensionFactoryInstance<{
36
37
  readonly key: "yForkDoc";
37
38
  readonly store: import("@tanstack/store").Store<{
38
39
  isForked: boolean;
@@ -41,12 +42,21 @@ export declare const CollaborationExtension: (options: CollaborationOptions) =>
41
42
  }) => {
42
43
  isForked: boolean;
43
44
  }>;
44
- readonly fork: () => void;
45
+ readonly fork: ({ initialUpdate, }?: {
46
+ initialUpdate?: Uint8Array;
47
+ }) => void;
45
48
  readonly merge: ({ keepChanges }: {
46
49
  keepChanges: boolean;
47
50
  }) => void;
48
- }>, import("../../index.js").ExtensionFactoryInstance<{
51
+ }>, import("../..").ExtensionFactoryInstance<{
52
+ readonly key: "yPositionMapping";
53
+ readonly mapPosition: (position: number, side?: "left" | "right") => () => number;
54
+ }>, import("../..").ExtensionFactoryInstance<{
55
+ readonly key: "schemaMigration";
56
+ readonly prosemirrorPlugins: readonly [import("prosemirror-state").Plugin<any>];
57
+ }>, import("../..").ExtensionFactoryInstance<{
49
58
  readonly key: "yCursor";
59
+ readonly mount: () => (() => void) | undefined;
50
60
  readonly prosemirrorPlugins: any[];
51
61
  readonly dependsOn: readonly ["ySync"];
52
62
  readonly updateUser: (user: {
@@ -54,11 +64,12 @@ export declare const CollaborationExtension: (options: CollaborationOptions) =>
54
64
  color: string;
55
65
  [key: string]: string;
56
66
  }) => void;
57
- }>, import("../../index.js").ExtensionFactoryInstance<{
67
+ readonly getUser: () => CollaborationUser | undefined;
68
+ }>, import("../..").ExtensionFactoryInstance<{
58
69
  readonly key: "ySync";
59
70
  readonly prosemirrorPlugins: readonly [any];
60
71
  readonly runsBefore: readonly ["default"];
61
- }>, import("../../index.js").ExtensionFactoryInstance<{
72
+ }>, import("../..").ExtensionFactoryInstance<{
62
73
  readonly key: "yUndo";
63
74
  readonly prosemirrorPlugins: readonly [import("prosemirror-state").Plugin<{
64
75
  undoManager: Y.UndoManager;
@@ -69,8 +80,18 @@ export declare const CollaborationExtension: (options: CollaborationOptions) =>
69
80
  readonly dependsOn: readonly ["yCursor", "ySync"];
70
81
  readonly undoCommand: import("prosemirror-state").Command;
71
82
  readonly redoCommand: import("prosemirror-state").Command;
72
- }>, import("../../index.js").ExtensionFactoryInstance<{
73
- readonly key: "schemaMigration";
74
- readonly prosemirrorPlugins: readonly [import("prosemirror-state").Plugin<any>];
75
83
  }>];
76
84
  }>;
85
+ export declare function withCollaboration<Options extends Partial<BlockNoteEditorOptions<any, any, any>>>(options: Options & {
86
+ /**
87
+ * Options for configuring the collaboration functionality.
88
+ */
89
+ collaboration: CollaborationOptions;
90
+ }): Options;
91
+ export * from "./ForkYDoc.js";
92
+ export * from "./RelativePositionMapping.js";
93
+ export * from "./schemaMigration/SchemaMigration.js";
94
+ export * from "./Versioning.js";
95
+ export * from "./YCursorPlugin.js";
96
+ export * from "./YSync.js";
97
+ export * from "./YUndo.js";
@@ -1 +1,3 @@
1
1
  export * from "./utils.js";
2
+ export * from "./extensions/index.js";
3
+ export * from "./comments/index.js";
@@ -1,5 +1,10 @@
1
1
  import * as Y from "yjs";
2
2
  import { type Block, type BlockNoteEditor, type BlockSchema, type InlineContentSchema, type PartialBlock, type StyleSchema } from "../index.js";
3
+ /**
4
+ * Find a Y.AbstractType in another Y.Doc that corresponds to the same
5
+ * logical type in the original doc.
6
+ */
7
+ export declare function findTypeInOtherYdoc<T extends Y.AbstractType<any>>(ytype: T, otherYdoc: Y.Doc): T;
3
8
  /**
4
9
  * Turn Prosemirror JSON to BlockNote style JSON
5
10
  * @param editor BlockNote editor
@@ -1,27 +0,0 @@
1
- import { Store as e } from "@tanstack/store";
2
- //#region src/editor/managers/ExtensionManager/symbol.ts
3
- var t = Symbol("originalFactory");
4
- //#endregion
5
- //#region src/editor/BlockNoteExtension.ts
6
- function n(e) {
7
- if (typeof e == "object" && "key" in e) return function n() {
8
- return e[t] = n, e;
9
- };
10
- if (typeof e != "function") throw Error("factory must be a function");
11
- return function n(r) {
12
- return (i) => {
13
- let a = e({
14
- editor: i.editor,
15
- options: r
16
- });
17
- return a[t] = n, a;
18
- };
19
- };
20
- }
21
- function r(t, n) {
22
- return new e(t, n);
23
- }
24
- //#endregion
25
- export { r as n, t as r, n as t };
26
-
27
- //# sourceMappingURL=BlockNoteExtension-B6RhuQ3V.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BlockNoteExtension-B6RhuQ3V.js","names":[],"sources":["../src/editor/managers/ExtensionManager/symbol.ts","../src/editor/BlockNoteExtension.ts"],"sourcesContent":["/**\n * Symbol used to track the original factory function for extensions.\n * This allows us to retrieve the original factory for comparison and other operations.\n */\nexport const originalFactorySymbol = Symbol(\"originalFactory\");\n","import { Store, StoreOptions } from \"@tanstack/store\";\nimport { type AnyExtension } from \"@tiptap/core\";\nimport type { Plugin as ProsemirrorPlugin } from \"prosemirror-state\";\nimport type { PartialBlockNoDefaults } from \"../schema/index.js\";\nimport type { BlockNoteEditor } from \"./BlockNoteEditor.js\";\nimport { originalFactorySymbol } from \"./managers/ExtensionManager/symbol.js\";\n\n/**\n * This function is called when the extension is destroyed.\n */\ntype OnDestroy = () => void;\n\n/**\n * Describes a BlockNote extension.\n */\nexport interface Extension<State = any, Key extends string = string> {\n /**\n * The unique identifier for the extension.\n */\n readonly key: Key;\n\n /**\n * Triggered when the extension is mounted to the editor.\n */\n readonly mount?: (ctx: {\n /**\n * The DOM element that the editor is mounted to.\n */\n dom: HTMLElement;\n /**\n * The root document of the {@link document} that the editor is mounted to.\n */\n root: Document | ShadowRoot;\n /**\n * An {@link AbortSignal} that will be aborted when the extension is destroyed.\n */\n signal: AbortSignal;\n }) => void | OnDestroy;\n\n /**\n * The store for the extension.\n */\n readonly store?: Store<State>;\n\n /**\n * Declares what {@link Extension}s that this extension depends on.\n */\n readonly runsBefore?: ReadonlyArray<string>;\n\n /**\n * Input rules for a block: An input rule is what is used to replace text in a block when a regular expression match is found.\n * As an example, typing `#` in a paragraph block will trigger an input rule to replace the text with a heading block.\n */\n readonly inputRules?: ReadonlyArray<InputRule>;\n\n /**\n * A mapping of a keyboard shortcut to a function that will be called when the shortcut is pressed\n *\n * The keys are in the format:\n * - Key names may be strings like `Shift-Ctrl-Enter`—a key identifier prefixed with zero or more modifiers\n * - Key identifiers are based on the strings that can appear in KeyEvent.key\n * - Use lowercase letters to refer to letter keys (or uppercase letters if you want shift to be held)\n * - You may use `Space` as an alias for the \" \" name\n * - Modifiers can be given in any order: `Shift-` (or `s-`), `Alt-` (or `a-`), `Ctrl-` (or `c-` or `Control-`) and `Cmd-` (or `m-` or `Meta-`)\n * - For characters that are created by holding shift, the Shift- prefix is implied, and should not be added explicitly\n * - You can use Mod- as a shorthand for Cmd- on Mac and Ctrl- on other platforms\n *\n * @example\n * ```typescript\n * keyboardShortcuts: {\n * \"Mod-Enter\": (ctx) => { return true; },\n * \"Shift-Ctrl-Space\": (ctx) => { return true; },\n * \"a\": (ctx) => { return true; },\n * \"Space\": (ctx) => { return true; }\n * }\n * ```\n */\n readonly keyboardShortcuts?: Record<\n string,\n (ctx: { editor: BlockNoteEditor<any, any, any> }) => boolean\n >;\n\n /**\n * Add additional prosemirror plugins to the editor.\n */\n readonly prosemirrorPlugins?: ReadonlyArray<ProsemirrorPlugin>;\n\n /**\n * Add additional tiptap extensions to the editor.\n */\n readonly tiptapExtensions?: ReadonlyArray<AnyExtension>;\n\n /**\n * Add additional BlockNote extensions to the editor.\n */\n readonly blockNoteExtensions?: ReadonlyArray<ExtensionFactoryInstance>;\n}\n\n/**\n * An input rule is what is used to replace text in a block when a regular expression match is found.\n * As an example, typing `#` in a paragraph block will trigger an input rule to replace the text with a heading block.\n */\ntype InputRule = {\n /**\n * The regex to match when to trigger the input rule\n */\n find: RegExp;\n /**\n * The function to call when the input rule is matched\n * @returns undefined if the input rule should not be triggered, or an object with the type and props to update the block\n */\n replace: (props: {\n /**\n * The result of the regex match\n */\n match: RegExpMatchArray;\n // TODO this will be a Point, when we have the Location API\n /**\n * The range of the text that was matched\n */\n range: { from: number; to: number };\n /**\n * The editor instance\n */\n editor: BlockNoteEditor<any, any, any>;\n }) => undefined | PartialBlockNoDefaults<any, any, any>;\n};\n\n/**\n * These are the arguments that are passed to an {@link ExtensionFactoryInstance}.\n */\nexport interface ExtensionOptions<\n Options extends Record<string, any> | undefined =\n | Record<string, any>\n | undefined,\n> {\n options: Options;\n editor: BlockNoteEditor<any, any, any>;\n}\n\n// a type that maps the extension key to the return type of the extension factory\nexport type ExtensionMap<T extends ReadonlyArray<ExtensionFactoryInstance>> = {\n [K in T[number] extends ExtensionFactoryInstance<infer Ext>\n ? Ext[\"key\"]\n : never]: T[number] extends ExtensionFactoryInstance<infer Ext>\n ? Ext\n : never;\n};\n\n/**\n * This is a type that represents the function which will actually create the extension.\n * It requires the editor instance to be passed in, but will already have the options applied automatically.\n *\n * @note Only the BlockNoteEditor should instantiate this function, not the user. Look at {@link createExtension} for user-facing functions.\n */\nexport type ExtensionFactoryInstance<\n Ext extends Extension<any, any> = Extension<any, any>,\n> = (ctx: Omit<ExtensionOptions<any>, \"options\">) => Ext;\n\n/**\n * This is the return type of the {@link createExtension} function.\n * It is a function that can be invoked with the extension's options to create a new extension factory.\n */\nexport type ExtensionFactory<\n State = any,\n Key extends string = string,\n Factory extends (ctx: any) => Extension<State, Key> = (\n ctx: ExtensionOptions<any>,\n ) => Extension<State, Key>,\n> =\n Parameters<Factory>[0] extends ExtensionOptions<infer Options>\n ? undefined extends Options\n ? (\n options?: Exclude<Options, undefined>,\n ) => ExtensionFactoryInstance<ReturnType<Factory>>\n : (options: Options) => ExtensionFactoryInstance<ReturnType<Factory>>\n : () => ExtensionFactoryInstance<ReturnType<Factory>>;\n\n/**\n * Constructs a BlockNote {@link ExtensionFactory} from a factory function or object\n */\n// This overload is for `createExtension({ key: \"test\", ... })`\nexport function createExtension<\n const State = any,\n const Key extends string = string,\n const Ext extends Extension<State, Key> = Extension<State, Key>,\n>(factory: Ext): ExtensionFactoryInstance<Ext>;\n// This overload is for `createExtension(({editor, options}) => ({ key: \"test\", ... }))`\nexport function createExtension<\n const State = any,\n const Options extends Record<string, any> | undefined = any,\n const Key extends string = string,\n const Factory extends (ctx: any) => Extension<State, Key> = (\n ctx: ExtensionOptions<Options>,\n ) => Extension<State, Key>,\n>(factory: Factory): ExtensionFactory<State, Key, Factory>;\n// This overload is for both of the above overloads as it is the implementation of the function\nexport function createExtension<\n const State = any,\n const Options extends Record<string, any> | undefined = any,\n const Key extends string = string,\n const Factory extends\n | Extension<State, Key>\n | ((ctx: any) => Extension<State, Key>) = (\n ctx: ExtensionOptions<Options>,\n ) => Extension<State, Key>,\n>(\n factory: Factory,\n): Factory extends Extension<State, Key>\n ? ExtensionFactoryInstance<Factory>\n : Factory extends (ctx: any) => Extension<State, Key>\n ? ExtensionFactory<State, Key, Factory>\n : never {\n if (typeof factory === \"object\" && \"key\" in factory) {\n return function factoryFn() {\n (factory as any)[originalFactorySymbol] = factoryFn;\n return factory;\n } as any;\n }\n\n if (typeof factory !== \"function\") {\n throw new Error(\"factory must be a function\");\n }\n\n return function factoryFn(options: Options) {\n return (ctx: { editor: BlockNoteEditor<any, any, any> }) => {\n const extension = factory({ editor: ctx.editor, options });\n // We stick a symbol onto the extension to allow us to retrieve the original factory for comparison later.\n // This enables us to do things like: `editor.getExtension(YSync).prosemirrorPlugins`\n (extension as any)[originalFactorySymbol] = factoryFn;\n return extension;\n };\n } as any;\n}\n\nexport function createStore<T = any>(\n initialState: T,\n options?: StoreOptions<T>,\n): Store<T> {\n return new Store(initialState, options);\n}\n"],"mappings":";;AAIA,IAAa,IAAwB,OAAO,kBAAkB;;;ACiM9D,SAAgB,EAUd,GAKU;AACV,KAAI,OAAO,KAAY,YAAY,SAAS,EAC1C,QAAO,SAAS,IAAY;AAE1B,SADC,EAAgB,KAAyB,GACnC;;AAIX,KAAI,OAAO,KAAY,WACrB,OAAU,MAAM,6BAA6B;AAG/C,QAAO,SAAS,EAAU,GAAkB;AAC1C,UAAQ,MAAoD;GAC1D,IAAM,IAAY,EAAQ;IAAE,QAAQ,EAAI;IAAQ;IAAS,CAAC;AAI1D,UADC,EAAkB,KAAyB,GACrC;;;;AAKb,SAAgB,EACd,GACA,GACU;AACV,QAAO,IAAI,EAAM,GAAc,EAAQ"}
@@ -1,2 +0,0 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@tanstack/store`);var l=Symbol(`originalFactory`);function u(e){if(typeof e==`object`&&`key`in e)return function t(){return e[l]=t,e};if(typeof e!=`function`)throw Error(`factory must be a function`);return function t(n){return r=>{let i=e({editor:r.editor,options:n});return i[l]=t,i}}}function d(e,t){return new c.Store(e,t)}Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return u}});
2
- //# sourceMappingURL=BlockNoteExtension-ab0REuob.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BlockNoteExtension-ab0REuob.cjs","names":[],"sources":["../src/editor/managers/ExtensionManager/symbol.ts","../src/editor/BlockNoteExtension.ts"],"sourcesContent":["/**\n * Symbol used to track the original factory function for extensions.\n * This allows us to retrieve the original factory for comparison and other operations.\n */\nexport const originalFactorySymbol = Symbol(\"originalFactory\");\n","import { Store, StoreOptions } from \"@tanstack/store\";\nimport { type AnyExtension } from \"@tiptap/core\";\nimport type { Plugin as ProsemirrorPlugin } from \"prosemirror-state\";\nimport type { PartialBlockNoDefaults } from \"../schema/index.js\";\nimport type { BlockNoteEditor } from \"./BlockNoteEditor.js\";\nimport { originalFactorySymbol } from \"./managers/ExtensionManager/symbol.js\";\n\n/**\n * This function is called when the extension is destroyed.\n */\ntype OnDestroy = () => void;\n\n/**\n * Describes a BlockNote extension.\n */\nexport interface Extension<State = any, Key extends string = string> {\n /**\n * The unique identifier for the extension.\n */\n readonly key: Key;\n\n /**\n * Triggered when the extension is mounted to the editor.\n */\n readonly mount?: (ctx: {\n /**\n * The DOM element that the editor is mounted to.\n */\n dom: HTMLElement;\n /**\n * The root document of the {@link document} that the editor is mounted to.\n */\n root: Document | ShadowRoot;\n /**\n * An {@link AbortSignal} that will be aborted when the extension is destroyed.\n */\n signal: AbortSignal;\n }) => void | OnDestroy;\n\n /**\n * The store for the extension.\n */\n readonly store?: Store<State>;\n\n /**\n * Declares what {@link Extension}s that this extension depends on.\n */\n readonly runsBefore?: ReadonlyArray<string>;\n\n /**\n * Input rules for a block: An input rule is what is used to replace text in a block when a regular expression match is found.\n * As an example, typing `#` in a paragraph block will trigger an input rule to replace the text with a heading block.\n */\n readonly inputRules?: ReadonlyArray<InputRule>;\n\n /**\n * A mapping of a keyboard shortcut to a function that will be called when the shortcut is pressed\n *\n * The keys are in the format:\n * - Key names may be strings like `Shift-Ctrl-Enter`—a key identifier prefixed with zero or more modifiers\n * - Key identifiers are based on the strings that can appear in KeyEvent.key\n * - Use lowercase letters to refer to letter keys (or uppercase letters if you want shift to be held)\n * - You may use `Space` as an alias for the \" \" name\n * - Modifiers can be given in any order: `Shift-` (or `s-`), `Alt-` (or `a-`), `Ctrl-` (or `c-` or `Control-`) and `Cmd-` (or `m-` or `Meta-`)\n * - For characters that are created by holding shift, the Shift- prefix is implied, and should not be added explicitly\n * - You can use Mod- as a shorthand for Cmd- on Mac and Ctrl- on other platforms\n *\n * @example\n * ```typescript\n * keyboardShortcuts: {\n * \"Mod-Enter\": (ctx) => { return true; },\n * \"Shift-Ctrl-Space\": (ctx) => { return true; },\n * \"a\": (ctx) => { return true; },\n * \"Space\": (ctx) => { return true; }\n * }\n * ```\n */\n readonly keyboardShortcuts?: Record<\n string,\n (ctx: { editor: BlockNoteEditor<any, any, any> }) => boolean\n >;\n\n /**\n * Add additional prosemirror plugins to the editor.\n */\n readonly prosemirrorPlugins?: ReadonlyArray<ProsemirrorPlugin>;\n\n /**\n * Add additional tiptap extensions to the editor.\n */\n readonly tiptapExtensions?: ReadonlyArray<AnyExtension>;\n\n /**\n * Add additional BlockNote extensions to the editor.\n */\n readonly blockNoteExtensions?: ReadonlyArray<ExtensionFactoryInstance>;\n}\n\n/**\n * An input rule is what is used to replace text in a block when a regular expression match is found.\n * As an example, typing `#` in a paragraph block will trigger an input rule to replace the text with a heading block.\n */\ntype InputRule = {\n /**\n * The regex to match when to trigger the input rule\n */\n find: RegExp;\n /**\n * The function to call when the input rule is matched\n * @returns undefined if the input rule should not be triggered, or an object with the type and props to update the block\n */\n replace: (props: {\n /**\n * The result of the regex match\n */\n match: RegExpMatchArray;\n // TODO this will be a Point, when we have the Location API\n /**\n * The range of the text that was matched\n */\n range: { from: number; to: number };\n /**\n * The editor instance\n */\n editor: BlockNoteEditor<any, any, any>;\n }) => undefined | PartialBlockNoDefaults<any, any, any>;\n};\n\n/**\n * These are the arguments that are passed to an {@link ExtensionFactoryInstance}.\n */\nexport interface ExtensionOptions<\n Options extends Record<string, any> | undefined =\n | Record<string, any>\n | undefined,\n> {\n options: Options;\n editor: BlockNoteEditor<any, any, any>;\n}\n\n// a type that maps the extension key to the return type of the extension factory\nexport type ExtensionMap<T extends ReadonlyArray<ExtensionFactoryInstance>> = {\n [K in T[number] extends ExtensionFactoryInstance<infer Ext>\n ? Ext[\"key\"]\n : never]: T[number] extends ExtensionFactoryInstance<infer Ext>\n ? Ext\n : never;\n};\n\n/**\n * This is a type that represents the function which will actually create the extension.\n * It requires the editor instance to be passed in, but will already have the options applied automatically.\n *\n * @note Only the BlockNoteEditor should instantiate this function, not the user. Look at {@link createExtension} for user-facing functions.\n */\nexport type ExtensionFactoryInstance<\n Ext extends Extension<any, any> = Extension<any, any>,\n> = (ctx: Omit<ExtensionOptions<any>, \"options\">) => Ext;\n\n/**\n * This is the return type of the {@link createExtension} function.\n * It is a function that can be invoked with the extension's options to create a new extension factory.\n */\nexport type ExtensionFactory<\n State = any,\n Key extends string = string,\n Factory extends (ctx: any) => Extension<State, Key> = (\n ctx: ExtensionOptions<any>,\n ) => Extension<State, Key>,\n> =\n Parameters<Factory>[0] extends ExtensionOptions<infer Options>\n ? undefined extends Options\n ? (\n options?: Exclude<Options, undefined>,\n ) => ExtensionFactoryInstance<ReturnType<Factory>>\n : (options: Options) => ExtensionFactoryInstance<ReturnType<Factory>>\n : () => ExtensionFactoryInstance<ReturnType<Factory>>;\n\n/**\n * Constructs a BlockNote {@link ExtensionFactory} from a factory function or object\n */\n// This overload is for `createExtension({ key: \"test\", ... })`\nexport function createExtension<\n const State = any,\n const Key extends string = string,\n const Ext extends Extension<State, Key> = Extension<State, Key>,\n>(factory: Ext): ExtensionFactoryInstance<Ext>;\n// This overload is for `createExtension(({editor, options}) => ({ key: \"test\", ... }))`\nexport function createExtension<\n const State = any,\n const Options extends Record<string, any> | undefined = any,\n const Key extends string = string,\n const Factory extends (ctx: any) => Extension<State, Key> = (\n ctx: ExtensionOptions<Options>,\n ) => Extension<State, Key>,\n>(factory: Factory): ExtensionFactory<State, Key, Factory>;\n// This overload is for both of the above overloads as it is the implementation of the function\nexport function createExtension<\n const State = any,\n const Options extends Record<string, any> | undefined = any,\n const Key extends string = string,\n const Factory extends\n | Extension<State, Key>\n | ((ctx: any) => Extension<State, Key>) = (\n ctx: ExtensionOptions<Options>,\n ) => Extension<State, Key>,\n>(\n factory: Factory,\n): Factory extends Extension<State, Key>\n ? ExtensionFactoryInstance<Factory>\n : Factory extends (ctx: any) => Extension<State, Key>\n ? ExtensionFactory<State, Key, Factory>\n : never {\n if (typeof factory === \"object\" && \"key\" in factory) {\n return function factoryFn() {\n (factory as any)[originalFactorySymbol] = factoryFn;\n return factory;\n } as any;\n }\n\n if (typeof factory !== \"function\") {\n throw new Error(\"factory must be a function\");\n }\n\n return function factoryFn(options: Options) {\n return (ctx: { editor: BlockNoteEditor<any, any, any> }) => {\n const extension = factory({ editor: ctx.editor, options });\n // We stick a symbol onto the extension to allow us to retrieve the original factory for comparison later.\n // This enables us to do things like: `editor.getExtension(YSync).prosemirrorPlugins`\n (extension as any)[originalFactorySymbol] = factoryFn;\n return extension;\n };\n } as any;\n}\n\nexport function createStore<T = any>(\n initialState: T,\n options?: StoreOptions<T>,\n): Store<T> {\n return new Store(initialState, options);\n}\n"],"mappings":"+fAIA,IAAa,EAAwB,OAAO,kBAAkB,CCiM9D,SAAgB,EAUd,EAKU,CACV,GAAI,OAAO,GAAY,UAAY,QAAS,EAC1C,OAAO,SAAS,GAAY,CAE1B,MADC,GAAgB,GAAyB,EACnC,GAIX,GAAI,OAAO,GAAY,WACrB,MAAU,MAAM,6BAA6B,CAG/C,OAAO,SAAS,EAAU,EAAkB,CAC1C,MAAQ,IAAoD,CAC1D,IAAM,EAAY,EAAQ,CAAE,OAAQ,EAAI,OAAQ,UAAS,CAAC,CAI1D,MADC,GAAkB,GAAyB,EACrC,IAKb,SAAgB,EACd,EACA,EACU,CACV,OAAO,IAAI,EAAA,MAAM,EAAc,EAAQ"}
@@ -1,22 +0,0 @@
1
- //#region src/util/EventEmitter.ts
2
- var e = class {
3
- callbacks = {};
4
- on(e, t) {
5
- return this.callbacks[e] || (this.callbacks[e] = []), this.callbacks[e].push(t), () => this.off(e, t);
6
- }
7
- emit(e, ...t) {
8
- let n = this.callbacks[e];
9
- n && n.forEach((e) => e.apply(this, t));
10
- }
11
- off(e, t) {
12
- let n = this.callbacks[e];
13
- n && (t ? this.callbacks[e] = n.filter((e) => e !== t) : delete this.callbacks[e]);
14
- }
15
- removeAllListeners() {
16
- this.callbacks = {};
17
- }
18
- };
19
- //#endregion
20
- export { e as t };
21
-
22
- //# sourceMappingURL=EventEmitter-CuPnGDYt.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EventEmitter-CuPnGDYt.js","names":[],"sources":["../src/util/EventEmitter.ts"],"sourcesContent":["// from https://raw.githubusercontent.com/ueberdosis/tiptap/develop/packages/core/src/EventEmitter.ts (MIT)\n\ntype StringKeyOf<T> = Extract<keyof T, string>;\ntype CallbackType<\n T extends Record<string, any>,\n EventName extends StringKeyOf<T>,\n> = T[EventName] extends any[] ? T[EventName] : [T[EventName]];\ntype CallbackFunction<\n T extends Record<string, any>,\n EventName extends StringKeyOf<T>,\n> = (...props: CallbackType<T, EventName>) => any;\n\nexport class EventEmitter<T extends Record<string, any>> {\n // eslint-disable-next-line @typescript-eslint/ban-types\n private callbacks: { [key: string]: Function[] } = {};\n\n public on<EventName extends StringKeyOf<T>>(\n event: EventName,\n fn: CallbackFunction<T, EventName>,\n ) {\n if (!this.callbacks[event]) {\n this.callbacks[event] = [];\n }\n\n this.callbacks[event].push(fn);\n\n return () => this.off(event, fn);\n }\n\n protected emit<EventName extends StringKeyOf<T>>(\n event: EventName,\n ...args: CallbackType<T, EventName>\n ) {\n const callbacks = this.callbacks[event];\n\n if (callbacks) {\n callbacks.forEach((callback) => callback.apply(this, args));\n }\n }\n\n public off<EventName extends StringKeyOf<T>>(\n event: EventName,\n fn?: CallbackFunction<T, EventName>,\n ) {\n const callbacks = this.callbacks[event];\n\n if (callbacks) {\n if (fn) {\n this.callbacks[event] = callbacks.filter((callback) => callback !== fn);\n } else {\n delete this.callbacks[event];\n }\n }\n }\n\n protected removeAllListeners(): void {\n this.callbacks = {};\n }\n}\n"],"mappings":";AAYA,IAAa,IAAb,MAAyD;CAEvD,YAAmD,EAAE;CAErD,GACE,GACA,GACA;AAOA,SANK,KAAK,UAAU,OAClB,KAAK,UAAU,KAAS,EAAE,GAG5B,KAAK,UAAU,GAAO,KAAK,EAAG,QAEjB,KAAK,IAAI,GAAO,EAAG;;CAGlC,KACE,GACA,GAAG,GACH;EACA,IAAM,IAAY,KAAK,UAAU;AAEjC,EAAI,KACF,EAAU,SAAS,MAAa,EAAS,MAAM,MAAM,EAAK,CAAC;;CAI/D,IACE,GACA,GACA;EACA,IAAM,IAAY,KAAK,UAAU;AAEjC,EAAI,MACE,IACF,KAAK,UAAU,KAAS,EAAU,QAAQ,MAAa,MAAa,EAAG,GAEvE,OAAO,KAAK,UAAU;;CAK5B,qBAAqC;AACnC,OAAK,YAAY,EAAE"}
@@ -1,2 +0,0 @@
1
- var e=class{callbacks={};on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),()=>this.off(e,t)}emit(e,...t){let n=this.callbacks[e];n&&n.forEach(e=>e.apply(this,t))}off(e,t){let n=this.callbacks[e];n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e])}removeAllListeners(){this.callbacks={}}};Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
2
- //# sourceMappingURL=EventEmitter-DHdSnYCD.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EventEmitter-DHdSnYCD.cjs","names":[],"sources":["../src/util/EventEmitter.ts"],"sourcesContent":["// from https://raw.githubusercontent.com/ueberdosis/tiptap/develop/packages/core/src/EventEmitter.ts (MIT)\n\ntype StringKeyOf<T> = Extract<keyof T, string>;\ntype CallbackType<\n T extends Record<string, any>,\n EventName extends StringKeyOf<T>,\n> = T[EventName] extends any[] ? T[EventName] : [T[EventName]];\ntype CallbackFunction<\n T extends Record<string, any>,\n EventName extends StringKeyOf<T>,\n> = (...props: CallbackType<T, EventName>) => any;\n\nexport class EventEmitter<T extends Record<string, any>> {\n // eslint-disable-next-line @typescript-eslint/ban-types\n private callbacks: { [key: string]: Function[] } = {};\n\n public on<EventName extends StringKeyOf<T>>(\n event: EventName,\n fn: CallbackFunction<T, EventName>,\n ) {\n if (!this.callbacks[event]) {\n this.callbacks[event] = [];\n }\n\n this.callbacks[event].push(fn);\n\n return () => this.off(event, fn);\n }\n\n protected emit<EventName extends StringKeyOf<T>>(\n event: EventName,\n ...args: CallbackType<T, EventName>\n ) {\n const callbacks = this.callbacks[event];\n\n if (callbacks) {\n callbacks.forEach((callback) => callback.apply(this, args));\n }\n }\n\n public off<EventName extends StringKeyOf<T>>(\n event: EventName,\n fn?: CallbackFunction<T, EventName>,\n ) {\n const callbacks = this.callbacks[event];\n\n if (callbacks) {\n if (fn) {\n this.callbacks[event] = callbacks.filter((callback) => callback !== fn);\n } else {\n delete this.callbacks[event];\n }\n }\n }\n\n protected removeAllListeners(): void {\n this.callbacks = {};\n }\n}\n"],"mappings":"AAYA,IAAa,EAAb,KAAyD,CAEvD,UAAmD,EAAE,CAErD,GACE,EACA,EACA,CAOA,OANK,KAAK,UAAU,KAClB,KAAK,UAAU,GAAS,EAAE,EAG5B,KAAK,UAAU,GAAO,KAAK,EAAG,KAEjB,KAAK,IAAI,EAAO,EAAG,CAGlC,KACE,EACA,GAAG,EACH,CACA,IAAM,EAAY,KAAK,UAAU,GAE7B,GACF,EAAU,QAAS,GAAa,EAAS,MAAM,KAAM,EAAK,CAAC,CAI/D,IACE,EACA,EACA,CACA,IAAM,EAAY,KAAK,UAAU,GAE7B,IACE,EACF,KAAK,UAAU,GAAS,EAAU,OAAQ,GAAa,IAAa,EAAG,CAEvE,OAAO,KAAK,UAAU,IAK5B,oBAAqC,CACnC,KAAK,UAAY,EAAE"}
@@ -1,29 +0,0 @@
1
- import { n as e, t } from "./BlockNoteExtension-B6RhuQ3V.js";
2
- import { Plugin as n, PluginKey as r } from "prosemirror-state";
3
- import { Decoration as i, DecorationSet as a } from "prosemirror-view";
4
- //#region src/extensions/ShowSelection/ShowSelection.ts
5
- var o = new r("blocknote-show-selection"), s = t(({ editor: t }) => {
6
- let r = e({ enabledSet: /* @__PURE__ */ new Set() }, { onUpdate() {
7
- t.transact((e) => e.setMeta(o, {}));
8
- } });
9
- return {
10
- key: "showSelection",
11
- store: r,
12
- prosemirrorPlugins: [new n({
13
- key: o,
14
- props: { decorations: (e) => {
15
- let { doc: t, selection: n } = e;
16
- if (r.state.enabledSet.size === 0) return a.empty;
17
- let o = i.inline(n.from, n.to, { "data-show-selection": "true" });
18
- return a.create(t, [o]);
19
- } }
20
- })],
21
- showSelection(e, t) {
22
- r.setState({ enabledSet: e ? new Set([...r.state.enabledSet, t]) : new Set([...r.state.enabledSet].filter((e) => e !== t)) });
23
- }
24
- };
25
- });
26
- //#endregion
27
- export { s as t };
28
-
29
- //# sourceMappingURL=ShowSelection-BsHFfdMi.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ShowSelection-BsHFfdMi.js","names":[],"sources":["../src/extensions/ShowSelection/ShowSelection.ts"],"sourcesContent":["import { Plugin, PluginKey } from \"prosemirror-state\";\nimport { Decoration, DecorationSet } from \"prosemirror-view\";\nimport {\n createExtension,\n createStore,\n} from \"../../editor/BlockNoteExtension.js\";\n\nconst PLUGIN_KEY = new PluginKey(`blocknote-show-selection`);\n\n/**\n * Plugin that shows adds a decoration around the current selection\n * This can be used to highlight the current selection in the UI even when the\n * text editor is not focused.\n */\nexport const ShowSelectionExtension = createExtension(({ editor }) => {\n const store = createStore(\n { enabledSet: new Set<string>() },\n {\n onUpdate() {\n editor.transact((tr) => tr.setMeta(PLUGIN_KEY, {}));\n },\n },\n );\n return {\n key: \"showSelection\",\n store,\n prosemirrorPlugins: [\n new Plugin({\n key: PLUGIN_KEY,\n props: {\n decorations: (state) => {\n const { doc, selection } = state;\n if (store.state.enabledSet.size === 0) {\n return DecorationSet.empty;\n }\n const dec = Decoration.inline(selection.from, selection.to, {\n \"data-show-selection\": \"true\",\n });\n return DecorationSet.create(doc, [dec]);\n },\n },\n }),\n ],\n /**\n * Show or hide the selection decoration\n *\n * @param shouldShow - Whether to show the selection decoration\n * @param key - The key of the selection to show or hide,\n * this is necessary to prevent disabling ShowSelection from one place\n * will interfere with other parts of the code that need to show the selection decoration\n * (e.g.: CreateLinkButton and AIExtension)\n */\n showSelection(shouldShow: boolean, key: string) {\n store.setState({\n enabledSet: shouldShow\n ? new Set([...store.state.enabledSet, key])\n : new Set([...store.state.enabledSet].filter((k) => k !== key)),\n });\n },\n } as const;\n});\n"],"mappings":";;;;AAOA,IAAM,IAAa,IAAI,EAAU,2BAA2B,EAO/C,IAAyB,GAAiB,EAAE,gBAAa;CACpE,IAAM,IAAQ,EACZ,EAAE,4BAAY,IAAI,KAAa,EAAE,EACjC,EACE,WAAW;AACT,IAAO,UAAU,MAAO,EAAG,QAAQ,GAAY,EAAE,CAAC,CAAC;IAEtD,CACF;AACD,QAAO;EACL,KAAK;EACL;EACA,oBAAoB,CAClB,IAAI,EAAO;GACT,KAAK;GACL,OAAO,EACL,cAAc,MAAU;IACtB,IAAM,EAAE,QAAK,iBAAc;AAC3B,QAAI,EAAM,MAAM,WAAW,SAAS,EAClC,QAAO,EAAc;IAEvB,IAAM,IAAM,EAAW,OAAO,EAAU,MAAM,EAAU,IAAI,EAC1D,uBAAuB,QACxB,CAAC;AACF,WAAO,EAAc,OAAO,GAAK,CAAC,EAAI,CAAC;MAE1C;GACF,CAAC,CACH;EAUD,cAAc,GAAqB,GAAa;AAC9C,KAAM,SAAS,EACb,YAAY,IACR,IAAI,IAAI,CAAC,GAAG,EAAM,MAAM,YAAY,EAAI,CAAC,GACzC,IAAI,IAAI,CAAC,GAAG,EAAM,MAAM,WAAW,CAAC,QAAQ,MAAM,MAAM,EAAI,CAAC,EAClE,CAAC;;EAEL;EACD"}
@@ -1,2 +0,0 @@
1
- const e=require(`./BlockNoteExtension-ab0REuob.cjs`);let t=require(`prosemirror-state`),n=require(`prosemirror-view`);var r=new t.PluginKey(`blocknote-show-selection`),i=e.t(({editor:i})=>{let a=e.n({enabledSet:new Set},{onUpdate(){i.transact(e=>e.setMeta(r,{}))}});return{key:`showSelection`,store:a,prosemirrorPlugins:[new t.Plugin({key:r,props:{decorations:e=>{let{doc:t,selection:r}=e;if(a.state.enabledSet.size===0)return n.DecorationSet.empty;let i=n.Decoration.inline(r.from,r.to,{"data-show-selection":`true`});return n.DecorationSet.create(t,[i])}}})],showSelection(e,t){a.setState({enabledSet:e?new Set([...a.state.enabledSet,t]):new Set([...a.state.enabledSet].filter(e=>e!==t))})}}});Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return i}});
2
- //# sourceMappingURL=ShowSelection-DhXglbt8.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ShowSelection-DhXglbt8.cjs","names":[],"sources":["../src/extensions/ShowSelection/ShowSelection.ts"],"sourcesContent":["import { Plugin, PluginKey } from \"prosemirror-state\";\nimport { Decoration, DecorationSet } from \"prosemirror-view\";\nimport {\n createExtension,\n createStore,\n} from \"../../editor/BlockNoteExtension.js\";\n\nconst PLUGIN_KEY = new PluginKey(`blocknote-show-selection`);\n\n/**\n * Plugin that shows adds a decoration around the current selection\n * This can be used to highlight the current selection in the UI even when the\n * text editor is not focused.\n */\nexport const ShowSelectionExtension = createExtension(({ editor }) => {\n const store = createStore(\n { enabledSet: new Set<string>() },\n {\n onUpdate() {\n editor.transact((tr) => tr.setMeta(PLUGIN_KEY, {}));\n },\n },\n );\n return {\n key: \"showSelection\",\n store,\n prosemirrorPlugins: [\n new Plugin({\n key: PLUGIN_KEY,\n props: {\n decorations: (state) => {\n const { doc, selection } = state;\n if (store.state.enabledSet.size === 0) {\n return DecorationSet.empty;\n }\n const dec = Decoration.inline(selection.from, selection.to, {\n \"data-show-selection\": \"true\",\n });\n return DecorationSet.create(doc, [dec]);\n },\n },\n }),\n ],\n /**\n * Show or hide the selection decoration\n *\n * @param shouldShow - Whether to show the selection decoration\n * @param key - The key of the selection to show or hide,\n * this is necessary to prevent disabling ShowSelection from one place\n * will interfere with other parts of the code that need to show the selection decoration\n * (e.g.: CreateLinkButton and AIExtension)\n */\n showSelection(shouldShow: boolean, key: string) {\n store.setState({\n enabledSet: shouldShow\n ? new Set([...store.state.enabledSet, key])\n : new Set([...store.state.enabledSet].filter((k) => k !== key)),\n });\n },\n } as const;\n});\n"],"mappings":"sHAOA,IAAM,EAAa,IAAI,EAAA,UAAU,2BAA2B,CAO/C,EAAyB,EAAA,GAAiB,CAAE,YAAa,CACpE,IAAM,EAAQ,EAAA,EACZ,CAAE,WAAY,IAAI,IAAe,CACjC,CACE,UAAW,CACT,EAAO,SAAU,GAAO,EAAG,QAAQ,EAAY,EAAE,CAAC,CAAC,EAEtD,CACF,CACD,MAAO,CACL,IAAK,gBACL,QACA,mBAAoB,CAClB,IAAI,EAAA,OAAO,CACT,IAAK,EACL,MAAO,CACL,YAAc,GAAU,CACtB,GAAM,CAAE,MAAK,aAAc,EAC3B,GAAI,EAAM,MAAM,WAAW,OAAS,EAClC,OAAO,EAAA,cAAc,MAEvB,IAAM,EAAM,EAAA,WAAW,OAAO,EAAU,KAAM,EAAU,GAAI,CAC1D,sBAAuB,OACxB,CAAC,CACF,OAAO,EAAA,cAAc,OAAO,EAAK,CAAC,EAAI,CAAC,EAE1C,CACF,CAAC,CACH,CAUD,cAAc,EAAqB,EAAa,CAC9C,EAAM,SAAS,CACb,WAAY,EACR,IAAI,IAAI,CAAC,GAAG,EAAM,MAAM,WAAY,EAAI,CAAC,CACzC,IAAI,IAAI,CAAC,GAAG,EAAM,MAAM,WAAW,CAAC,OAAQ,GAAM,IAAM,EAAI,CAAC,CAClE,CAAC,EAEL,EACD"}