@blocknote/core 0.51.3 → 0.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (397) hide show
  1. package/dist/BlockNoteExtension-B_IEJHS8.js +38 -0
  2. package/dist/BlockNoteExtension-B_IEJHS8.js.map +1 -0
  3. package/dist/BlockNoteExtension-M0znTzxP.cjs +2 -0
  4. package/dist/BlockNoteExtension-M0znTzxP.cjs.map +1 -0
  5. package/dist/ThreadStore-Bx-gSEh1.cjs +2 -0
  6. package/dist/ThreadStore-Bx-gSEh1.cjs.map +1 -0
  7. package/dist/ThreadStore-et9wB5Xt.js +11 -0
  8. package/dist/ThreadStore-et9wB5Xt.js.map +1 -0
  9. package/dist/UserStore-DCG6lsla.cjs +2 -0
  10. package/dist/UserStore-DCG6lsla.cjs.map +1 -0
  11. package/dist/UserStore-QbbPFj0z.js +73 -0
  12. package/dist/UserStore-QbbPFj0z.js.map +1 -0
  13. package/dist/blocknote.cjs +1 -1
  14. package/dist/blocknote.js +6 -7
  15. package/dist/blocks-BqHv0xhc.cjs +12 -0
  16. package/dist/blocks-BqHv0xhc.cjs.map +1 -0
  17. package/dist/{blocks-D0lMxErU.js → blocks-CiuUGa1E.js} +1096 -998
  18. package/dist/blocks-CiuUGa1E.js.map +1 -0
  19. package/dist/blocks.cjs +1 -1
  20. package/dist/blocks.js +2 -2
  21. package/dist/comments.cjs +1 -1
  22. package/dist/comments.cjs.map +1 -1
  23. package/dist/comments.js +75 -340
  24. package/dist/comments.js.map +1 -1
  25. package/dist/{en-Cj5r8sW_.cjs → en-C5Z4Ag9_.cjs} +2 -2
  26. package/dist/en-C5Z4Ag9_.cjs.map +1 -0
  27. package/dist/{en-B9hMApn4.js → en-CGKXfWma.js} +9 -1
  28. package/dist/en-CGKXfWma.js.map +1 -0
  29. package/dist/{extensions-D2mx2C9y.js → extensions-CrUGDOks.js} +655 -583
  30. package/dist/extensions-CrUGDOks.js.map +1 -0
  31. package/dist/extensions-Ghr9QqqR.cjs +52 -0
  32. package/dist/extensions-Ghr9QqqR.cjs.map +1 -0
  33. package/dist/extensions.cjs +1 -1
  34. package/dist/extensions.js +4 -4
  35. package/dist/locales.cjs +1 -1
  36. package/dist/locales.cjs.map +1 -1
  37. package/dist/locales.js +177 -1
  38. package/dist/locales.js.map +1 -1
  39. package/dist/{src-Dvmif2FY.js → src-DTF83Cl9.js} +1243 -1297
  40. package/dist/src-DTF83Cl9.js.map +1 -0
  41. package/dist/src-OfbaVbMw.cjs +21 -0
  42. package/dist/src-OfbaVbMw.cjs.map +1 -0
  43. package/dist/style.css +1 -1
  44. package/dist/webpack-stats.json +1 -1
  45. package/dist/y.cjs +2 -0
  46. package/dist/y.cjs.map +1 -0
  47. package/dist/y.js +989 -0
  48. package/dist/y.js.map +1 -0
  49. package/dist/yjs.cjs +1 -1
  50. package/dist/yjs.cjs.map +1 -1
  51. package/dist/yjs.js +535 -14
  52. package/dist/yjs.js.map +1 -1
  53. package/package.json +46 -19
  54. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +1 -1
  55. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +1 -1
  56. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +3 -3
  57. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +25 -20
  58. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +39 -29
  59. package/src/api/blockManipulation/commands/nestBlock/nestBlock.test.ts +2 -2
  60. package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +4 -8
  61. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +1 -1
  62. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +21 -9
  63. package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +6 -5
  64. package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +362 -4
  65. package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +240 -30
  66. package/src/api/blockManipulation/getBlock/getBlock.ts +4 -9
  67. package/src/api/blockManipulation/selections/selection.ts +3 -6
  68. package/src/api/blockManipulation/selections/textCursorPosition.ts +10 -10
  69. package/src/api/blockManipulation/setupTestEnv.ts +1 -1
  70. package/src/api/blockManipulation/tables/tables.test.ts +1 -1
  71. package/src/api/clipboard/fromClipboard/fileDropExtension.ts +1 -1
  72. package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +8 -4
  73. package/src/api/clipboard/fromClipboard/pasteExtension.ts +1 -1
  74. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +2 -1
  75. package/src/api/exporters/markdown/htmlToMarkdown.ts +79 -43
  76. package/src/api/getBlockInfoFromPos.test.ts +256 -0
  77. package/src/api/getBlockInfoFromPos.ts +53 -15
  78. package/src/api/getBlocksChangedByTransaction.test.ts +2 -1
  79. package/src/api/getBlocksChangedByTransaction.ts +6 -6
  80. package/src/api/nodeConversions/blockToNode.test.ts +113 -0
  81. package/src/api/nodeConversions/blockToNode.ts +15 -3
  82. package/src/api/nodeConversions/fragmentToBlocks.ts +2 -4
  83. package/src/api/nodeConversions/nodeToBlock.ts +28 -58
  84. package/src/api/nodeUtil.ts +6 -2
  85. package/src/api/parsers/html/parseHTML.ts +1 -1
  86. package/src/api/parsers/html/util/nestedLists.test.ts +1 -1
  87. package/src/api/parsers/markdown/detectMarkdown.test.ts +1 -1
  88. package/src/api/parsers/markdown/markdownToHtml.ts +228 -82
  89. package/src/api/pmUtil.ts +18 -1
  90. package/src/api/positionMapping.test.ts +20 -345
  91. package/src/api/positionMapping.ts +13 -83
  92. package/src/blocks/Audio/block.ts +1 -1
  93. package/src/blocks/Code/block.test.ts +14 -7
  94. package/src/blocks/Code/block.ts +2 -2
  95. package/src/blocks/Image/block.ts +1 -1
  96. package/src/blocks/ListItem/CheckListItem/block.test.ts +1 -1
  97. package/src/blocks/ListItem/ListItemKeyboardShortcuts.ts +2 -2
  98. package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.ts +4 -11
  99. package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +47 -50
  100. package/src/blocks/Table/TableExtension.test.ts +129 -0
  101. package/src/blocks/Table/TableExtension.ts +23 -20
  102. package/src/blocks/Table/block.ts +18 -5
  103. package/src/blocks/Video/block.ts +1 -1
  104. package/src/blocks/utils/listItemEnterHandler.ts +3 -2
  105. package/src/comments/extension.ts +30 -21
  106. package/src/comments/index.ts +0 -3
  107. package/src/comments/mark.ts +4 -0
  108. package/src/comments/threadstore/ThreadStore.ts +4 -8
  109. package/src/comments/types.ts +0 -8
  110. package/src/editor/Block.css +307 -3
  111. package/src/editor/BlockNoteEditor.test.ts +39 -18
  112. package/src/editor/BlockNoteEditor.ts +22 -57
  113. package/src/editor/BlockNoteExtension.test.ts +1 -1
  114. package/src/editor/managers/BlockManager.ts +1 -1
  115. package/src/editor/managers/ExtensionManager/ExtensionManager.test.ts +249 -0
  116. package/src/editor/managers/ExtensionManager/extensions.ts +7 -18
  117. package/src/editor/managers/ExtensionManager/index.ts +168 -68
  118. package/src/editor/managers/StateManager.ts +4 -3
  119. package/src/editor/performance.test.ts +14 -1
  120. package/src/editor/transformPasted.test.ts +1 -1
  121. package/src/extensions/Placeholder/Placeholder.ts +1 -0
  122. package/src/extensions/PositionMapping/PositionMapping.ts +68 -0
  123. package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +14 -1
  124. package/src/extensions/PreviousBlockType/PreviousBlockType.ts +14 -11
  125. package/src/extensions/SideMenu/SideMenu.ts +9 -2
  126. package/src/extensions/SuggestionMenu/SuggestionMenu.test.ts +1 -1
  127. package/src/extensions/TableHandles/TableHandles.ts +18 -20
  128. package/src/extensions/TrailingNode/TrailingNode.ts +33 -1
  129. package/src/extensions/Versioning/Versioning.test.ts +435 -0
  130. package/src/extensions/Versioning/Versioning.ts +628 -0
  131. package/src/extensions/Versioning/inMemoryVersioning.test.ts +469 -0
  132. package/src/extensions/Versioning/inMemoryVersioning.ts +263 -0
  133. package/src/extensions/Versioning/index.ts +2 -0
  134. package/src/extensions/index.ts +6 -9
  135. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts +155 -0
  136. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +6 -8
  137. package/src/extensions/tiptap-extensions/Link/helpers/autolink.ts +9 -9
  138. package/src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts +8 -10
  139. package/src/extensions/tiptap-extensions/Link/helpers/whitespace.ts +2 -2
  140. package/src/extensions/tiptap-extensions/Link/link.test.ts +26 -22
  141. package/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.ts +187 -0
  142. package/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts +37 -24
  143. package/src/extensions/tiptap-extensions/index.ts +1 -25
  144. package/src/i18n/locales/ar.ts +9 -0
  145. package/src/i18n/locales/de.ts +9 -0
  146. package/src/i18n/locales/en.ts +10 -1
  147. package/src/i18n/locales/es.ts +9 -0
  148. package/src/i18n/locales/fa.ts +11 -1
  149. package/src/i18n/locales/fr.ts +9 -0
  150. package/src/i18n/locales/he.ts +10 -1
  151. package/src/i18n/locales/hr.ts +10 -0
  152. package/src/i18n/locales/is.ts +10 -0
  153. package/src/i18n/locales/it.ts +9 -0
  154. package/src/i18n/locales/ja.ts +9 -0
  155. package/src/i18n/locales/ko.ts +9 -0
  156. package/src/i18n/locales/nl.ts +10 -0
  157. package/src/i18n/locales/no.ts +10 -0
  158. package/src/i18n/locales/pl.ts +9 -0
  159. package/src/i18n/locales/pt.ts +10 -0
  160. package/src/i18n/locales/ru.ts +10 -0
  161. package/src/i18n/locales/sk.ts +10 -1
  162. package/src/i18n/locales/uk.ts +9 -0
  163. package/src/i18n/locales/uz.ts +9 -0
  164. package/src/i18n/locales/vi.ts +9 -0
  165. package/src/i18n/locales/zh-tw.ts +9 -0
  166. package/src/i18n/locales/zh.ts +9 -0
  167. package/src/index.ts +2 -0
  168. package/src/pm-nodes/BlockContainer.ts +4 -1
  169. package/src/pm-nodes/BlockGroup.ts +4 -1
  170. package/src/pm-nodes/Doc.ts +4 -1
  171. package/src/pm-nodes/suggestionMarks.ts +43 -0
  172. package/src/schema/blocks/createSpec.test.ts +123 -0
  173. package/src/schema/blocks/createSpec.ts +82 -24
  174. package/src/schema/blocks/extendBlockSpec.test.ts +188 -0
  175. package/src/schema/blocks/internal.ts +13 -43
  176. package/src/schema/blocks/types.ts +69 -22
  177. package/src/schema/contentTypePropagation.test.ts +182 -0
  178. package/src/schema/index.ts +1 -0
  179. package/src/schema/inlineContent/internal.ts +1 -1
  180. package/src/schema/inlineContent/types.ts +3 -3
  181. package/src/schema/markGroups.ts +50 -0
  182. package/src/user/UserStore.ts +199 -0
  183. package/src/user/createUserStore.test.ts +126 -0
  184. package/src/user/index.ts +2 -0
  185. package/src/user/userColors.ts +72 -0
  186. package/src/util/string.ts +1 -1
  187. package/src/util/topo-sort.test.ts +1 -1
  188. package/src/util/typescript.ts +2 -1
  189. package/src/vite-env.d.ts +1 -1
  190. package/src/y/README.md +5 -0
  191. package/src/{comments/threadstore/yjs → y/comments}/RESTYjsThreadStore.ts +8 -14
  192. package/src/y/comments/YjsThreadStore.test.ts +295 -0
  193. package/src/y/comments/YjsThreadStore.ts +358 -0
  194. package/src/y/comments/YjsThreadStoreBase.ts +50 -0
  195. package/src/y/comments/index.ts +3 -0
  196. package/src/y/comments/yjsHelpers.ts +125 -0
  197. package/src/y/extensions/AttributionExtension.test.ts +86 -0
  198. package/src/y/extensions/AttributionExtension.ts +378 -0
  199. package/src/y/extensions/DiffVersioningExtension.test.ts +193 -0
  200. package/src/y/extensions/DiffVersioningExtension.ts +228 -0
  201. package/src/y/extensions/ForkYDoc.test.ts +253 -0
  202. package/src/y/extensions/ForkYDoc.ts +108 -0
  203. package/src/y/extensions/RelativePositionMapping.test.ts +418 -0
  204. package/src/y/extensions/RelativePositionMapping.ts +49 -0
  205. package/src/y/extensions/Suggestions.ts +174 -0
  206. package/src/y/extensions/Versioning.test.ts +395 -0
  207. package/src/y/extensions/Versioning.ts +115 -0
  208. package/src/y/extensions/YAttributionMarks.ts +320 -0
  209. package/src/{extensions/Collaboration → y/extensions}/YCursorPlugin.ts +15 -7
  210. package/src/y/extensions/YSync.ts +125 -0
  211. package/src/y/extensions/blockMatchNodes.ts +182 -0
  212. package/src/y/extensions/index.ts +156 -0
  213. package/src/y/index.ts +4 -0
  214. package/src/y/utils.test.ts +1042 -0
  215. package/src/y/utils.ts +242 -0
  216. package/src/y/versioning/__test__/fixtures/activity-all-after.bin +0 -0
  217. package/src/y/versioning/__test__/fixtures/activity-all-after.json +50 -0
  218. package/src/y/versioning/__test__/fixtures/activity-all.bin +0 -0
  219. package/src/y/versioning/__test__/fixtures/activity-all.json +20 -0
  220. package/src/y/versioning/__test__/fixtures/activity-filtered-after.bin +0 -0
  221. package/src/y/versioning/__test__/fixtures/activity-filtered-after.json +32 -0
  222. package/src/y/versioning/__test__/fixtures/activity-filtered-before.json +1 -0
  223. package/src/y/versioning/__test__/fixtures/changeset.bin +0 -0
  224. package/src/y/versioning/__test__/fixtures/patch-response.json +4 -0
  225. package/src/y/versioning/__test__/yhub.test.ts +752 -0
  226. package/src/y/versioning/index.ts +1 -0
  227. package/src/y/versioning/yhub.ts +631 -0
  228. package/src/yjs/README.md +5 -0
  229. package/src/yjs/comments/RESTYjsThreadStore.ts +166 -0
  230. package/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStore.test.ts +3 -3
  231. package/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStore.ts +7 -3
  232. package/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStoreBase.ts +3 -3
  233. package/src/yjs/comments/index.ts +3 -0
  234. package/src/{comments/threadstore/yjs → yjs/comments}/yjsHelpers.ts +5 -1
  235. package/src/yjs/extensions/FixUpSchema.test.ts +421 -0
  236. package/src/yjs/extensions/FixUpSchema.ts +88 -0
  237. package/src/yjs/extensions/ForkYDoc.test.ts +216 -0
  238. package/src/{extensions/Collaboration → yjs/extensions}/ForkYDoc.ts +38 -57
  239. package/src/yjs/extensions/RelativePositionMapping.test.ts +418 -0
  240. package/src/yjs/extensions/RelativePositionMapping.ts +71 -0
  241. package/src/yjs/extensions/Versioning.test.ts +549 -0
  242. package/src/yjs/extensions/Versioning.ts +83 -0
  243. package/src/yjs/extensions/YCursorPlugin.ts +201 -0
  244. package/src/{extensions/Collaboration → yjs/extensions}/YSync.ts +1 -1
  245. package/src/yjs/extensions/index.ts +89 -0
  246. package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/moveColorAttributes.test.ts +1 -1
  247. package/src/yjs/index.ts +2 -0
  248. package/src/yjs/utils.test.ts +5 -15
  249. package/src/yjs/utils.ts +36 -0
  250. package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.d.ts +3 -1
  251. package/types/src/api/blockManipulation/selections/selection.d.ts +1 -1
  252. package/types/src/api/getBlockInfoFromPos.d.ts +5 -9
  253. package/types/src/api/nodeConversions/nodeToBlock.d.ts +4 -6
  254. package/types/src/api/pmUtil.d.ts +12 -1
  255. package/types/src/blocks/Audio/block.d.ts +2 -2
  256. package/types/src/blocks/Code/block.d.ts +2 -2
  257. package/types/src/blocks/File/block.d.ts +2 -2
  258. package/types/src/blocks/Heading/block.d.ts +21 -21
  259. package/types/src/blocks/Image/block.d.ts +3 -3
  260. package/types/src/blocks/ListItem/CheckListItem/block.d.ts +6 -6
  261. package/types/src/blocks/ListItem/NumberedListItem/block.d.ts +6 -6
  262. package/types/src/blocks/Video/block.d.ts +3 -3
  263. package/types/src/blocks/defaultBlocks.d.ts +17 -17
  264. package/types/src/comments/extension.d.ts +18 -5
  265. package/types/src/comments/index.d.ts +0 -3
  266. package/types/src/comments/threadstore/ThreadStore.d.ts +4 -8
  267. package/types/src/comments/types.d.ts +0 -8
  268. package/types/src/editor/BlockNoteEditor.d.ts +8 -9
  269. package/types/src/editor/managers/BlockManager.d.ts +1 -1
  270. package/types/src/editor/managers/ExtensionManager/ExtensionManager.test.d.ts +1 -0
  271. package/types/src/editor/managers/ExtensionManager/extensions.d.ts +2 -2
  272. package/types/src/editor/managers/ExtensionManager/index.d.ts +13 -0
  273. package/types/src/editor/managers/SelectionManager.d.ts +1 -1
  274. package/types/src/extensions/PositionMapping/PositionMapping.d.ts +4 -0
  275. package/types/src/extensions/TableHandles/TableHandles.d.ts +6 -6
  276. package/types/src/extensions/Versioning/Versioning.d.ts +352 -0
  277. package/types/src/extensions/Versioning/Versioning.test.d.ts +1 -0
  278. package/types/src/extensions/Versioning/inMemoryVersioning.d.ts +37 -0
  279. package/types/src/extensions/Versioning/inMemoryVersioning.test.d.ts +1 -0
  280. package/types/src/extensions/Versioning/index.d.ts +2 -0
  281. package/types/src/extensions/index.d.ts +6 -9
  282. package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.d.ts +1 -0
  283. package/types/src/extensions/tiptap-extensions/UniqueID/UniqueID.d.ts +6 -1
  284. package/types/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.d.ts +4 -0
  285. package/types/src/extensions/tiptap-extensions/index.d.ts +1 -5
  286. package/types/src/i18n/locales/en.d.ts +9 -1
  287. package/types/src/i18n/locales/fa.d.ts +9 -1
  288. package/types/src/i18n/locales/sk.d.ts +9 -1
  289. package/types/src/index.d.ts +2 -0
  290. package/types/src/pm-nodes/suggestionMarks.d.ts +26 -0
  291. package/types/src/schema/blocks/createSpec.d.ts +4 -4
  292. package/types/src/schema/blocks/createSpec.test.d.ts +1 -0
  293. package/types/src/schema/blocks/extendBlockSpec.test.d.ts +1 -0
  294. package/types/src/schema/blocks/internal.d.ts +5 -7
  295. package/types/src/schema/blocks/types.d.ts +22 -14
  296. package/types/src/schema/contentTypePropagation.test.d.ts +1 -0
  297. package/types/src/schema/index.d.ts +1 -0
  298. package/types/src/schema/inlineContent/types.d.ts +3 -3
  299. package/types/src/schema/markGroups.d.ts +33 -0
  300. package/types/src/user/UserStore.d.ts +105 -0
  301. package/types/src/user/createUserStore.test.d.ts +1 -0
  302. package/types/src/user/index.d.ts +2 -0
  303. package/types/src/user/userColors.d.ts +36 -0
  304. package/types/src/y/comments/RESTYjsThreadStore.d.ts +77 -0
  305. package/types/src/y/comments/YjsThreadStore.d.ts +79 -0
  306. package/types/src/y/comments/YjsThreadStore.test.d.ts +1 -0
  307. package/types/src/y/comments/YjsThreadStoreBase.d.ts +15 -0
  308. package/types/src/y/comments/index.d.ts +3 -0
  309. package/types/src/y/comments/yjsHelpers.d.ts +13 -0
  310. package/types/src/y/extensions/AttributionExtension.d.ts +74 -0
  311. package/types/src/y/extensions/AttributionExtension.test.d.ts +1 -0
  312. package/types/src/y/extensions/DiffVersioningExtension.d.ts +69 -0
  313. package/types/src/y/extensions/DiffVersioningExtension.test.d.ts +1 -0
  314. package/types/src/{extensions/Collaboration → y/extensions}/ForkYDoc.d.ts +4 -2
  315. package/types/src/y/extensions/ForkYDoc.test.d.ts +1 -0
  316. package/types/src/y/extensions/RelativePositionMapping.d.ts +4 -0
  317. package/types/src/y/extensions/RelativePositionMapping.test.d.ts +1 -0
  318. package/types/src/y/extensions/Suggestions.d.ts +36 -0
  319. package/types/src/y/extensions/Versioning.d.ts +17 -0
  320. package/types/src/y/extensions/Versioning.test.d.ts +1 -0
  321. package/types/src/y/extensions/YAttributionMarks.d.ts +67 -0
  322. package/types/src/y/extensions/YCursorPlugin.d.ts +14 -0
  323. package/types/src/y/extensions/YSync.d.ts +32 -0
  324. package/types/src/y/extensions/blockMatchNodes.d.ts +25 -0
  325. package/types/src/y/extensions/index.d.ts +189 -0
  326. package/types/src/y/index.d.ts +4 -0
  327. package/types/src/y/utils.d.ts +82 -0
  328. package/types/src/y/utils.test.d.ts +1 -0
  329. package/types/src/y/versioning/__test__/yhub.test.d.ts +1 -0
  330. package/types/src/y/versioning/index.d.ts +1 -0
  331. package/types/src/y/versioning/yhub.d.ts +87 -0
  332. package/types/src/{comments/threadstore/yjs → yjs/comments}/RESTYjsThreadStore.d.ts +6 -10
  333. package/types/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStore.d.ts +3 -3
  334. package/types/src/yjs/comments/YjsThreadStore.test.d.ts +1 -0
  335. package/types/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStoreBase.d.ts +3 -3
  336. package/types/src/yjs/comments/index.d.ts +3 -0
  337. package/types/src/{comments/threadstore/yjs → yjs/comments}/yjsHelpers.d.ts +1 -1
  338. package/types/src/yjs/extensions/FixUpSchema.d.ts +3 -0
  339. package/types/src/yjs/extensions/FixUpSchema.test.d.ts +1 -0
  340. package/types/src/yjs/extensions/ForkYDoc.d.ts +27 -0
  341. package/types/src/yjs/extensions/ForkYDoc.test.d.ts +1 -0
  342. package/types/src/yjs/extensions/RelativePositionMapping.d.ts +4 -0
  343. package/types/src/yjs/extensions/RelativePositionMapping.test.d.ts +1 -0
  344. package/types/src/yjs/extensions/Versioning.d.ts +26 -0
  345. package/types/src/yjs/extensions/Versioning.test.d.ts +1 -0
  346. package/types/src/{extensions/Collaboration → yjs/extensions}/YCursorPlugin.d.ts +5 -2
  347. package/types/src/{extensions/Collaboration → yjs/extensions}/YSync.d.ts +1 -1
  348. package/types/src/{extensions/Collaboration/Collaboration.d.ts → yjs/extensions/index.d.ts} +36 -15
  349. package/types/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.test.d.ts +1 -0
  350. package/types/src/yjs/index.d.ts +2 -0
  351. package/types/src/yjs/utils.d.ts +5 -0
  352. package/dist/BlockNoteExtension-B6RhuQ3V.js +0 -27
  353. package/dist/BlockNoteExtension-B6RhuQ3V.js.map +0 -1
  354. package/dist/BlockNoteExtension-ab0REuob.cjs +0 -2
  355. package/dist/BlockNoteExtension-ab0REuob.cjs.map +0 -1
  356. package/dist/EventEmitter-CuPnGDYt.js +0 -22
  357. package/dist/EventEmitter-CuPnGDYt.js.map +0 -1
  358. package/dist/EventEmitter-DHdSnYCD.cjs +0 -2
  359. package/dist/EventEmitter-DHdSnYCD.cjs.map +0 -1
  360. package/dist/ShowSelection-BsHFfdMi.js +0 -29
  361. package/dist/ShowSelection-BsHFfdMi.js.map +0 -1
  362. package/dist/ShowSelection-DhXglbt8.cjs +0 -2
  363. package/dist/ShowSelection-DhXglbt8.cjs.map +0 -1
  364. package/dist/blocks-D0lMxErU.js.map +0 -1
  365. package/dist/blocks-KyMOxPT3.cjs +0 -11
  366. package/dist/blocks-KyMOxPT3.cjs.map +0 -1
  367. package/dist/en-B9hMApn4.js.map +0 -1
  368. package/dist/en-Cj5r8sW_.cjs.map +0 -1
  369. package/dist/extensions-Cutrafjg.cjs +0 -52
  370. package/dist/extensions-Cutrafjg.cjs.map +0 -1
  371. package/dist/extensions-D2mx2C9y.js.map +0 -1
  372. package/dist/src-D5R5YzV7.cjs +0 -21
  373. package/dist/src-D5R5YzV7.cjs.map +0 -1
  374. package/dist/src-Dvmif2FY.js.map +0 -1
  375. package/src/comments/userstore/UserStore.ts +0 -72
  376. package/src/extensions/Collaboration/Collaboration.ts +0 -55
  377. package/src/extensions/Collaboration/ForkYDoc.test.ts +0 -179
  378. package/src/extensions/tiptap-extensions/Suggestions/SuggestionMarks.ts +0 -175
  379. package/types/src/comments/userstore/UserStore.d.ts +0 -31
  380. package/types/src/extensions/tiptap-extensions/Suggestions/SuggestionMarks.d.ts +0 -4
  381. /package/src/{extensions/Collaboration → yjs/extensions}/YUndo.ts +0 -0
  382. /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap-editor-forked.json +0 -0
  383. /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap-editor.json +0 -0
  384. /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap-forked.html +0 -0
  385. /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap.html +0 -0
  386. /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/SchemaMigration.ts +0 -0
  387. /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/index.ts +0 -0
  388. /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/migrationRule.ts +0 -0
  389. /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/moveColorAttributes.ts +0 -0
  390. /package/types/src/{comments/threadstore/yjs/YjsThreadStore.test.d.ts → api/getBlockInfoFromPos.test.d.ts} +0 -0
  391. /package/types/src/{extensions/Collaboration/ForkYDoc.test.d.ts → api/nodeConversions/blockToNode.test.d.ts} +0 -0
  392. /package/types/src/{extensions/Collaboration/schemaMigration/migrationRules/moveColorAttributes.test.d.ts → blocks/Table/TableExtension.test.d.ts} +0 -0
  393. /package/types/src/{extensions/Collaboration → yjs/extensions}/YUndo.d.ts +0 -0
  394. /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/SchemaMigration.d.ts +0 -0
  395. /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/index.d.ts +0 -0
  396. /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/migrationRule.d.ts +0 -0
  397. /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/moveColorAttributes.d.ts +0 -0
@@ -1,22 +1,22 @@
1
- import { $t as e, At as t, Dn as n, Dt as r, Et as i, H as a, Qt as o, Rn as s, Tt as c, Ut as l, Yn as u, Zt as d, _n as f, _t as p, an as m, f as h, fn as g, gn as _, hn as v, in as ee, jn as te, jt as ne, kt as y, ln as re, m as b, mn as x, mt as ie, nn as ae, on as S, rn as oe, sn as se, t as ce, wt as le, yn as C, yt as ue, zn as w } from "./blocks-D0lMxErU.js";
2
- import { C as de, D as fe, E as pe, O as me, S as he, T as ge, _ as _e, b as ve, d as ye, f as be, l as xe, m as Se, n as Ce, o as we, p as Te, t as Ee, u as De, v as Oe, w as ke, x as Ae } from "./extensions-D2mx2C9y.js";
3
- import { r as je, t as Me } from "./BlockNoteExtension-B6RhuQ3V.js";
4
- import { t as Ne } from "./ShowSelection-BsHFfdMi.js";
5
- import { t as Pe } from "./en-B9hMApn4.js";
6
- import { t as Fe } from "./EventEmitter-CuPnGDYt.js";
7
- import { DOMParser as Ie, DOMSerializer as Le, Fragment as T, Node as Re, NodeRange as ze, Slice as E } from "prosemirror-model";
8
- import { ReplaceAroundStep as D, ReplaceStep as Be, canJoin as Ve, liftTarget as He } from "prosemirror-transform";
9
- import { Editor as Ue, Extension as O, Mark as k, Node as A, combineTransactionSteps as We, createDocument as Ge, extensions as j, findChildrenInRange as Ke, findParentNodeClosestToPos as qe, getAttributes as Je, getChangedRanges as Ye, getMarkRange as Xe, getMarksBetween as Ze, getSchema as Qe, isNodeSelection as $e, markPasteRule as et, mergeAttributes as tt, posToDOMRect as nt, selectionToInsertionEnd as rt } from "@tiptap/core";
10
- import { NodeSelection as M, Plugin as N, TextSelection as P } from "prosemirror-state";
11
- import { Fragment as F, Slice as I } from "@tiptap/pm/model";
12
- import { CellSelection as it, TableMap as at } from "prosemirror-tables";
13
- import { Plugin as ot, PluginKey as st } from "@tiptap/pm/state";
14
- import { InputRule as ct, inputRules as lt } from "@handlewithcare/prosemirror-inputrules";
15
- import { keymap as ut } from "@tiptap/pm/keymap";
16
- import { Gapcursor as dt } from "@tiptap/extensions/gap-cursor";
17
- import { Text as ft } from "@tiptap/extension-text";
1
+ import { $n as e, $t as t, Cn as n, Dt as r, En as i, Et as a, Fn as o, Gt as s, In as c, Jn as l, Kn as u, Mt as d, Nt as f, O as p, Ot as m, Qn as h, W as g, Xn as _, Yn as v, _n as ee, bn as te, dn as ne, en as re, f as ie, gn as ae, gt as y, hn as oe, jt as b, kt as x, m as se, qn as S, t as ce, tn as le, vn as ue, xn as de, xt as fe, yn as C, yt as pe } from "./blocks-CiuUGa1E.js";
2
+ import { r as me, t as he } from "./BlockNoteExtension-B_IEJHS8.js";
3
+ import { A as ge, D as _e, O as ve, T as ye, _ as be, b as xe, c as Se, f as Ce, g as we, h as Te, k as Ee, s as De, v as Oe, w as ke, x as Ae, y as je } from "./extensions-CrUGDOks.js";
4
+ import { r as Me } from "./UserStore-QbbPFj0z.js";
5
+ import { t as Ne } from "./en-CGKXfWma.js";
6
+ import { DOMParser as Pe, DOMSerializer as Fe, Fragment as w, NodeRange as Ie, Slice as T } from "prosemirror-model";
7
+ import { ReplaceAroundStep as E, ReplaceStep as Le, canJoin as Re, liftTarget as ze } from "prosemirror-transform";
8
+ import { Editor as Be, Extension as D, Mark as Ve, Node as O, combineTransactionSteps as He, createDocument as Ue, extensions as k, findChildrenInRange as We, findParentNodeClosestToPos as Ge, getAttributes as Ke, getChangedRanges as qe, getMarkRange as Je, getMarksBetween as Ye, getSchema as Xe, isNodeSelection as Ze, markPasteRule as Qe, mergeAttributes as $e, posToDOMRect as et, selectionToInsertionEnd as tt } from "@tiptap/core";
9
+ import { NodeSelection as A, Plugin as j, TextSelection as M } from "prosemirror-state";
10
+ import { Fragment as N, Slice as P } from "@tiptap/pm/model";
11
+ import { CellSelection as F, TableMap as nt } from "prosemirror-tables";
12
+ import { Plugin as rt, PluginKey as it } from "@tiptap/pm/state";
13
+ import { digestString as at } from "lib0/hash/fnv1a";
14
+ import { InputRule as ot, inputRules as st } from "@handlewithcare/prosemirror-inputrules";
15
+ import { keymap as ct } from "@tiptap/pm/keymap";
16
+ import { Text as lt } from "@tiptap/extension-text";
17
+ import { Gapcursor as ut } from "@tiptap/extensions/gap-cursor";
18
18
  //#region src/schema/inlineContent/createSpec.ts
19
- function pt(e, t) {
19
+ function dt(e, t) {
20
20
  let n = [{
21
21
  tag: `[data-inline-content-type="${e.type}"]`,
22
22
  contentElement: (e) => {
@@ -33,65 +33,65 @@ function pt(e, t) {
33
33
  }
34
34
  }), n;
35
35
  }
36
- function mt(r, i) {
37
- return e(A.create({
38
- name: r.type,
36
+ function ft(e, n) {
37
+ return le(O.create({
38
+ name: e.type,
39
39
  inline: !0,
40
40
  group: "inline",
41
- draggable: i.meta?.draggable,
42
- selectable: r.content === "styled",
43
- atom: r.content === "none",
44
- content: r.content === "styled" ? "inline*" : "",
41
+ draggable: n.meta?.draggable,
42
+ selectable: e.content === "styled",
43
+ atom: e.content === "none",
44
+ content: e.content === "styled" ? "inline*" : "",
45
45
  addAttributes() {
46
- return n(r.propSchema);
46
+ return ne(e.propSchema);
47
47
  },
48
48
  addKeyboardShortcuts() {
49
- return o(r);
49
+ return re(e);
50
50
  },
51
51
  parseHTML() {
52
- return pt(r, i.parse);
52
+ return dt(e, n.parse);
53
53
  },
54
- renderHTML({ node: e }) {
55
- let t = this.options.editor;
56
- return d(i.render.call({
54
+ renderHTML({ node: r }) {
55
+ let i = this.options.editor;
56
+ return t(n.render.call({
57
57
  renderType: "dom",
58
58
  props: void 0
59
- }, S(e, t.schema.inlineContentSchema, t.schema.styleSchema), () => {}, t), r.type, e.attrs, r.propSchema);
59
+ }, te(r, i.schema.inlineContentSchema, i.schema.styleSchema), () => {}, i), e.type, r.attrs, e.propSchema);
60
60
  },
61
61
  addNodeView() {
62
- return (e) => {
63
- let { node: n, getPos: a } = e, o = this.options.editor;
64
- return d(i.render.call({
62
+ return (r) => {
63
+ let { node: i, getPos: a } = r, o = this.options.editor;
64
+ return t(n.render.call({
65
65
  renderType: "nodeView",
66
- props: e
67
- }, S(n, o.schema.inlineContentSchema, o.schema.styleSchema), (e) => {
68
- let r = t([e], o.pmSchema), i = a();
69
- i && o.transact((e) => e.replaceWith(i, i + n.nodeSize, r));
70
- }, o), r.type, n.attrs, r.propSchema);
66
+ props: r
67
+ }, te(i, o.schema.inlineContentSchema, o.schema.styleSchema), (e) => {
68
+ let t = d([e], o.pmSchema), n = a();
69
+ n && o.transact((e) => e.replaceWith(n, n + i.nodeSize, t));
70
+ }, o), e.type, i.attrs, e.propSchema);
71
71
  };
72
72
  }
73
- }), r.propSchema, {
74
- ...i,
75
- toExternalHTML: i.toExternalHTML,
76
- render(e, t, n) {
77
- return d(i.render(e, t, n), r.type, e.props, r.propSchema);
73
+ }), e.propSchema, {
74
+ ...n,
75
+ toExternalHTML: n.toExternalHTML,
76
+ render(r, i, a) {
77
+ return t(n.render(r, i, a), e.type, r.props, e.propSchema);
78
78
  }
79
79
  });
80
80
  }
81
81
  //#endregion
82
82
  //#region src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts
83
- function ht(e, t, n, i = "before") {
84
- let a = typeof n == "string" ? n : n.id, o = g(e), s = t.map((e) => {
85
- let t = y(e, o);
83
+ function pt(e, t, n, r = "before") {
84
+ let a = typeof n == "string" ? n : n.id, o = i(e), s = t.map((e) => {
85
+ let t = b(e, o);
86
86
  return t.check(), t;
87
- }), c = r(a, e.doc);
87
+ }), c = x(a, e.doc);
88
88
  if (!c) throw Error(`Block with ID ${a} not found`);
89
89
  let l = c.posBeforeNode;
90
- return i === "after" && (l += c.node.nodeSize), e.step(new Be(l, l, new E(T.from(s), 0, 0))), s.map((e) => m(e, o));
90
+ return r === "after" && (l += c.node.nodeSize), e.step(new Le(l, l, new T(w.from(s), 0, 0))), s.map((t) => C(t, e.doc));
91
91
  }
92
92
  //#endregion
93
93
  //#region src/api/blockManipulation/commands/replaceBlocks/util/fixColumnList.ts
94
- function L(e) {
94
+ function I(e) {
95
95
  if (!e || e.type.name !== "column") throw Error("Invalid columnPos: does not point to column node.");
96
96
  let t = e.firstChild;
97
97
  if (!t) throw Error("Invalid column: does not have child node.");
@@ -99,87 +99,89 @@ function L(e) {
99
99
  if (!n) throw Error("Invalid blockContainer: does not have child node.");
100
100
  return e.childCount === 1 && t.childCount === 1 && n.type.name === "paragraph" && n.content.content.length === 0;
101
101
  }
102
- function gt(e, t) {
102
+ function mt(e, t) {
103
103
  let n = e.doc.resolve(t), r = n.nodeAfter;
104
104
  if (!r || r.type.name !== "columnList") throw Error("Invalid columnListPos: does not point to columnList node.");
105
105
  for (let t = r.childCount - 1; t >= 0; t--) {
106
106
  let r = e.doc.resolve(n.pos + 1).posAtIndex(t), i = e.doc.resolve(r).nodeAfter;
107
107
  if (!i || i.type.name !== "column") throw Error("Invalid columnPos: does not point to column node.");
108
- L(i) && e.delete(r, r + i.nodeSize);
108
+ I(i) && e.delete(r, r + i.nodeSize);
109
109
  }
110
110
  }
111
- function R(e, t) {
112
- gt(e, t);
111
+ function L(e, t) {
112
+ mt(e, t);
113
113
  let n = e.doc.resolve(t).nodeAfter;
114
114
  if (!n || n.type.name !== "columnList") throw Error("Invalid columnListPos: does not point to columnList node.");
115
115
  if (n.childCount > 2) return;
116
116
  if (n.childCount < 2) throw Error("Invalid columnList: contains fewer than two children.");
117
117
  let r = t + 1, i = e.doc.resolve(r).nodeAfter, a = t + n.nodeSize - 1, o = e.doc.resolve(a).nodeBefore;
118
118
  if (!i || !o) throw Error("Invalid columnList: does not contain children.");
119
- let s = L(i), c = L(o);
119
+ let s = I(i), c = I(o);
120
120
  if (s && c) {
121
121
  e.delete(t, t + n.nodeSize);
122
122
  return;
123
123
  }
124
124
  if (s) {
125
- e.step(new D(t, t + n.nodeSize, a - o.nodeSize + 1, a - 1, E.empty, 0, !1));
125
+ e.step(new E(t, t + n.nodeSize, a - o.nodeSize + 1, a - 1, T.empty, 0, !1));
126
126
  return;
127
127
  }
128
128
  if (c) {
129
- e.step(new D(t, t + n.nodeSize, r + 1, r + i.nodeSize - 1, E.empty, 0, !1));
129
+ e.step(new E(t, t + n.nodeSize, r + 1, r + i.nodeSize - 1, T.empty, 0, !1));
130
130
  return;
131
131
  }
132
132
  }
133
133
  //#endregion
134
134
  //#region src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts
135
- function z(e, t, n) {
136
- let r = g(e), i = n.map((e) => {
137
- let t = y(e, r);
135
+ function R(t, n, r, a = {}) {
136
+ let o = i(t), s = r.map((e) => {
137
+ let t = b(e, o);
138
138
  return t.check(), t;
139
- }), a = new Set(t.map((e) => typeof e == "string" ? e : e.id)), o = [], s = /* @__PURE__ */ new Set(), c = typeof t[0] == "string" ? t[0] : t[0].id, l = 0;
140
- if (e.doc.descendants((t, u) => {
141
- if (a.size === 0) return !1;
142
- if (!t.type.isInGroup("bnBlock") || !a.has(t.attrs.id)) return !0;
143
- if (o.push(m(t, r)), a.delete(t.attrs.id), n.length > 0 && t.attrs.id === c) {
144
- let t = e.doc.nodeSize;
145
- e.insert(u, i);
146
- let n = e.doc.nodeSize;
147
- l += t - n;
148
- }
149
- let d = e.doc.nodeSize, f = e.doc.resolve(u - l);
150
- f.node().type.name === "column" ? s.add(f.before(-1)) : f.node().type.name === "columnList" && s.add(f.before()), f.node().type.name === "blockGroup" && f.node(f.depth - 1).type.name !== "doc" && f.node().childCount === 1 ? e.delete(f.before(), f.after()) : e.delete(u - l, u - l + t.nodeSize);
151
- let p = e.doc.nodeSize;
152
- return l += d - p, !1;
153
- }), a.size > 0) {
154
- let e = [...a].join("\n");
139
+ }), c = new Set(n.map((e) => typeof e == "string" ? e : e.id)), l = [], u = /* @__PURE__ */ new Set(), d = typeof n[0] == "string" ? n[0] : n[0].id, f = 0;
140
+ if (t.doc.descendants((n, i) => {
141
+ if (c.size === 0) return !1;
142
+ if (!n.type.isInGroup("bnBlock")) return !0;
143
+ let a = e(n, t.doc);
144
+ if (!c.has(a)) return !0;
145
+ if (l.push(C(n, t.doc)), c.delete(a), r.length > 0 && a === d) {
146
+ let e = t.doc.nodeSize;
147
+ t.insert(i, s);
148
+ let n = t.doc.nodeSize;
149
+ f += e - n;
150
+ }
151
+ let o = t.doc.nodeSize, p = t.doc.resolve(i - f);
152
+ p.node().type.name === "column" ? u.add(p.before(-1)) : p.node().type.name === "columnList" && u.add(p.before()), p.node().type.name === "blockGroup" && p.node(p.depth - 1).type.name !== "doc" && p.node().childCount === 1 ? t.delete(p.before(), p.after()) : t.delete(i - f, i - f + n.nodeSize);
153
+ let m = t.doc.nodeSize;
154
+ return f += o - m, !1;
155
+ }), c.size > 0) {
156
+ let e = [...c].join("\n");
155
157
  throw Error("Blocks with the following IDs could not be found in the editor: " + e);
156
158
  }
157
- return s.forEach((t) => R(e, t)), {
158
- insertedBlocks: i.map((e) => m(e, r)),
159
- removedBlocks: o
159
+ return a.fixColumns !== !1 && u.forEach((e) => L(t, e)), {
160
+ insertedBlocks: s.map((e) => C(e, t.doc)),
161
+ removedBlocks: l
160
162
  };
161
163
  }
162
164
  //#endregion
163
165
  //#region src/api/exporters/html/util/serializeBlocksInternalHTML.ts
164
- function _t(e, n, r, i, a) {
165
- let o;
166
- if (!n) throw Error("blockContent is required");
167
- if (typeof n == "string") o = t([n], e.pmSchema, i);
168
- else if (Array.isArray(n)) o = t(n, e.pmSchema, i);
169
- else if (n.type === "tableContent") o = ne(n, e.pmSchema);
170
- else throw new w(n.type);
171
- let s = (a?.document ?? document).createDocumentFragment();
172
- for (let t of o) if (t.type.name !== "text" && e.schema.inlineContentSchema[t.type.name]) {
173
- let n = e.schema.inlineContentSpecs[t.type.name].implementation;
174
- if (n) {
175
- let i = S(t, e.schema.inlineContentSchema, e.schema.styleSchema), o = n.render.call({
166
+ function ht(e, t, n, r, i) {
167
+ let a;
168
+ if (!t) throw Error("blockContent is required");
169
+ if (typeof t == "string") a = d([t], e.pmSchema, r);
170
+ else if (Array.isArray(t)) a = d(t, e.pmSchema, r);
171
+ else if (t.type === "tableContent") a = f(t, e.pmSchema);
172
+ else throw new c(t.type);
173
+ let o = (i?.document ?? document).createDocumentFragment();
174
+ for (let t of a) if (t.type.name !== "text" && e.schema.inlineContentSchema[t.type.name]) {
175
+ let r = e.schema.inlineContentSpecs[t.type.name].implementation;
176
+ if (r) {
177
+ let a = te(t, e.schema.inlineContentSchema, e.schema.styleSchema), s = r.render.call({
176
178
  renderType: "dom",
177
179
  props: void 0
178
- }, i, () => {}, e);
179
- if (o) {
180
- if (s.appendChild(o.dom), o.contentDOM) {
181
- let e = r.serializeFragment(t.content, a);
182
- o.contentDOM.dataset.editable = "", o.contentDOM.appendChild(e);
180
+ }, a, () => {}, e);
181
+ if (s) {
182
+ if (o.appendChild(s.dom), s.contentDOM) {
183
+ let e = n.serializeFragment(t.content, i);
184
+ s.contentDOM.dataset.editable = "", s.contentDOM.appendChild(e);
183
185
  }
184
186
  continue;
185
187
  }
@@ -190,17 +192,17 @@ function _t(e, n, r, i, a) {
190
192
  let t = e.schema.styleSpecs[r.type.name].implementation.render(r.attrs.stringValue, e);
191
193
  t.contentDOM.appendChild(n), n = t.dom;
192
194
  } else {
193
- let e = r.type.spec.toDOM(r, !0), t = Le.renderSpec(document, e);
195
+ let e = r.type.spec.toDOM(r, !0), t = Fe.renderSpec(document, e);
194
196
  t.contentDOM.appendChild(n), n = t.dom;
195
197
  }
196
- s.appendChild(n);
198
+ o.appendChild(n);
197
199
  } else {
198
- let e = r.serializeFragment(T.from([t]), a);
199
- s.appendChild(e);
200
+ let e = n.serializeFragment(w.from([t]), i);
201
+ o.appendChild(e);
200
202
  }
201
- return s;
203
+ return o;
202
204
  }
203
- function vt(e, t, n, r) {
205
+ function gt(e, t, n, r) {
204
206
  let i = e.pmSchema.nodes.blockContainer, a = t.props || {};
205
207
  for (let [n, r] of Object.entries(e.schema.blockSchema[t.type].propSchema)) !(n in a) && r.default !== void 0 && (a[n] = r.default);
206
208
  let o = t.children || [], s = e.blockImplementations[t.type].implementation.render.call({
@@ -212,12 +214,12 @@ function vt(e, t, n, r) {
212
214
  children: o
213
215
  }, e);
214
216
  if (s.contentDOM && t.content) {
215
- let i = _t(e, t.content, n, t.type, r);
217
+ let i = ht(e, t.content, n, t.type, r);
216
218
  s.contentDOM.appendChild(i);
217
219
  }
218
220
  if (e.pmSchema.nodes[t.type].isInGroup("bnBlock")) {
219
221
  if (t.children && t.children.length > 0) {
220
- let i = yt(e, t.children, n, r);
222
+ let i = _t(e, t.children, n, r);
221
223
  s.contentDOM?.append(i);
222
224
  }
223
225
  return s.dom;
@@ -226,146 +228,195 @@ function vt(e, t, n, r) {
226
228
  id: t.id,
227
229
  ...a
228
230
  }));
229
- return c.contentDOM?.appendChild(s.dom), t.children && t.children.length > 0 && c.contentDOM?.appendChild(bt(e, t.children, n, r)), c.dom;
231
+ return c.contentDOM?.appendChild(s.dom), t.children && t.children.length > 0 && c.contentDOM?.appendChild(vt(e, t.children, n, r)), c.dom;
230
232
  }
231
- function yt(e, t, n, r) {
233
+ function _t(e, t, n, r) {
232
234
  let i = (r?.document ?? document).createDocumentFragment();
233
235
  for (let a of t) {
234
- let t = vt(e, a, n, r);
236
+ let t = gt(e, a, n, r);
235
237
  i.appendChild(t);
236
238
  }
237
239
  return i;
238
240
  }
239
- var bt = (e, t, n, r) => {
240
- let i = e.pmSchema.nodes.blockGroup, a = i.spec.toDOM(i.create({})), o = yt(e, t, n, r);
241
+ var vt = (e, t, n, r) => {
242
+ let i = e.pmSchema.nodes.blockGroup, a = i.spec.toDOM(i.create({})), o = _t(e, t, n, r);
241
243
  return a.contentDOM?.appendChild(o), a.dom;
242
- }, xt = (e) => (e.querySelectorAll("[data-content-type=\"numberedListItem\"]").forEach((e) => {
244
+ }, yt = (e) => (e.querySelectorAll("[data-content-type=\"numberedListItem\"]").forEach((e) => {
243
245
  let t = e.closest(".bn-block-outer")?.previousElementSibling?.querySelector("[data-content-type=\"numberedListItem\"]");
244
246
  if (!t) e.setAttribute("data-index", e.getAttribute("data-start") || "1");
245
247
  else {
246
248
  let n = t.getAttribute("data-index");
247
249
  e.setAttribute("data-index", (parseInt(n || "0") + 1).toString());
248
250
  }
249
- }), e), St = (e) => (e.querySelectorAll("[data-content-type=\"checkListItem\"] input").forEach((e) => {
251
+ }), e), bt = (e) => (e.querySelectorAll("[data-content-type=\"checkListItem\"] input").forEach((e) => {
250
252
  e.disabled = !0;
251
- }), e), Ct = (e) => (e.querySelectorAll(".bn-toggle-wrapper[data-show-children=\"false\"]").forEach((e) => {
253
+ }), e), xt = (e) => (e.querySelectorAll(".bn-toggle-wrapper[data-show-children=\"false\"]").forEach((e) => {
252
254
  e.setAttribute("data-show-children", "true");
253
- }), e), wt = (e) => (e.querySelectorAll("[data-content-type=\"table\"] table").forEach((e) => {
255
+ }), e), St = (e) => (e.querySelectorAll("[data-content-type=\"table\"] table").forEach((e) => {
254
256
  e.setAttribute("style", "--default-cell-min-width: 120px;"), e.setAttribute("data-show-children", "true");
255
- }), e), Tt = (e) => (e.querySelectorAll("[data-content-type=\"table\"] table").forEach((e) => {
257
+ }), e), Ct = (e) => (e.querySelectorAll("[data-content-type=\"table\"] table").forEach((e) => {
256
258
  let t = document.createElement("div");
257
259
  t.className = "tableWrapper";
258
260
  let n = document.createElement("div");
259
261
  n.className = "tableWrapper-inner", t.appendChild(n), e.parentElement?.appendChild(t), t.appendChild(e);
260
- }), e), Et = (e) => (e.querySelectorAll(".bn-inline-content:empty").forEach((e) => {
262
+ }), e), wt = (e) => (e.querySelectorAll(".bn-inline-content:empty").forEach((e) => {
261
263
  let t = document.createElement("span");
262
264
  t.className = "ProseMirror-trailingBreak", t.setAttribute("style", "display: inline-block;"), e.appendChild(t);
263
- }), e), Dt = (e, t) => {
264
- let n = Le.fromSchema(e), r = [
265
+ }), e), Tt = (e, t) => {
266
+ let n = Fe.fromSchema(e), r = [
267
+ yt,
268
+ bt,
265
269
  xt,
266
270
  St,
267
271
  Ct,
268
- wt,
269
- Tt,
270
- Et
272
+ wt
271
273
  ];
272
274
  return { serializeBlocks: (e, i) => {
273
- let a = bt(t, e, n, i);
275
+ let a = vt(t, e, n, i);
274
276
  for (let e of r) a = e(a);
275
277
  return a.outerHTML;
276
278
  } };
279
+ }, Et = (e) => {
280
+ let t = 0;
281
+ for (let n = 0; n < e.length; n++) t = Math.imul(31, t) + e.charCodeAt(n);
282
+ return Math.abs(t);
283
+ }, z = [
284
+ {
285
+ light: "#fff0c2",
286
+ dark: "#8a6d1a"
287
+ },
288
+ {
289
+ light: "#fcc9c3",
290
+ dark: "#8a2e24"
291
+ },
292
+ {
293
+ light: "#d4e8eb",
294
+ dark: "#4a7178"
295
+ },
296
+ {
297
+ light: "#c2eeff",
298
+ dark: "#1a6e8a"
299
+ },
300
+ {
301
+ light: "#bef3ff",
302
+ dark: "#0a7a8a"
303
+ }
304
+ ], Dt = (e) => z[Et(e) % z.length], Ot = (e, t) => {
305
+ if (!t || t.length === 0) return z[0];
306
+ let n = t[0], r = e.getUser(n);
307
+ return r?.color && r.colorLight ? {
308
+ light: r.colorLight,
309
+ dark: r.color
310
+ } : Dt(n);
311
+ }, kt = (e) => at(e).toString(16).padStart(8, "0"), At = (e) => {
312
+ let t = kt(e);
313
+ return {
314
+ light: `--user-color-${t}-light`,
315
+ dark: `--user-color-${t}-dark`
316
+ };
317
+ }, B = class {
318
+ callbacks = {};
319
+ on(e, t) {
320
+ return this.callbacks[e] || (this.callbacks[e] = []), this.callbacks[e].push(t), () => this.off(e, t);
321
+ }
322
+ emit(e, ...t) {
323
+ let n = this.callbacks[e];
324
+ n && n.forEach((e) => e.apply(this, t));
325
+ }
326
+ off(e, t) {
327
+ let n = this.callbacks[e];
328
+ n && (t ? this.callbacks[e] = n.filter((e) => e !== t) : delete this.callbacks[e]);
329
+ }
330
+ removeAllListeners() {
331
+ this.callbacks = {};
332
+ }
277
333
  };
278
334
  //#endregion
279
335
  //#region src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts
280
- function Ot(e) {
281
- return e.transact((e) => {
282
- let t = C(e.doc, e.selection.anchor);
283
- if (e.selection instanceof it) return {
336
+ function jt(t) {
337
+ return t.transact((t) => {
338
+ let n = l(t, t.selection.anchor), r = e(n.bnBlock.node, t.doc);
339
+ if (t.selection instanceof F) return {
284
340
  type: "cell",
285
- anchorBlockId: t.node.attrs.id,
286
- anchorCellOffset: e.selection.$anchorCell.pos - t.posBeforeNode,
287
- headCellOffset: e.selection.$headCell.pos - t.posBeforeNode
341
+ anchorBlockId: r,
342
+ anchorCellOffset: t.selection.$anchorCell.pos - n.bnBlock.beforePos,
343
+ headCellOffset: t.selection.$headCell.pos - n.bnBlock.beforePos
288
344
  };
289
- if (e.selection instanceof M) return {
345
+ if (t.selection instanceof A) return {
290
346
  type: "node",
291
- anchorBlockId: t.node.attrs.id
347
+ anchorBlockId: r
292
348
  };
293
349
  {
294
- let n = C(e.doc, e.selection.head);
350
+ let i = l(t, t.selection.head);
295
351
  return {
296
352
  type: "text",
297
- anchorBlockId: t.node.attrs.id,
298
- headBlockId: n.node.attrs.id,
299
- anchorOffset: e.selection.anchor - t.posBeforeNode,
300
- headOffset: e.selection.head - n.posBeforeNode
353
+ anchorBlockId: r,
354
+ headBlockId: e(i.bnBlock.node, t.doc),
355
+ anchorOffset: t.selection.anchor - n.bnBlock.beforePos,
356
+ headOffset: t.selection.head - i.bnBlock.beforePos
301
357
  };
302
358
  }
303
359
  });
304
360
  }
305
- function kt(e, t) {
306
- let n = r(t.anchorBlockId, e.doc)?.posBeforeNode;
361
+ function Mt(e, t) {
362
+ let n = x(t.anchorBlockId, e.doc)?.posBeforeNode;
307
363
  if (n === void 0) throw Error(`Could not find block with ID ${t.anchorBlockId} to update selection`);
308
- let i;
309
- if (t.type === "cell") i = it.create(e.doc, n + t.anchorCellOffset, n + t.headCellOffset);
310
- else if (t.type === "node") i = M.create(e.doc, n + 1);
364
+ let r;
365
+ if (t.type === "cell") r = F.create(e.doc, n + t.anchorCellOffset, n + t.headCellOffset);
366
+ else if (t.type === "node") r = A.create(e.doc, n + 1);
311
367
  else {
312
- let a = r(t.headBlockId, e.doc)?.posBeforeNode;
313
- if (a === void 0) throw Error(`Could not find block with ID ${t.headBlockId} to update selection`);
314
- i = P.create(e.doc, n + t.anchorOffset, a + t.headOffset);
368
+ let i = x(t.headBlockId, e.doc)?.posBeforeNode;
369
+ if (i === void 0) throw Error(`Could not find block with ID ${t.headBlockId} to update selection`);
370
+ r = M.create(e.doc, n + t.anchorOffset, i + t.headOffset);
315
371
  }
316
- e.setSelection(i);
372
+ e.setSelection(r);
317
373
  }
318
- function At(e) {
374
+ function Nt(e) {
319
375
  return e.flatMap((e) => e.type === "column" ? e.children : [e]);
320
376
  }
321
- function B(e, t, n, r) {
322
- e.transact(() => {
323
- let i = e.getBlock(n);
324
- if (i?.type === "columnList") {
325
- let t = r === "after" ? e.getNextBlock(i) : e.getPrevBlock(i);
326
- t && (n = t, r = r === "after" ? "before" : "after");
327
- }
328
- e.removeBlocks(t), e.insertBlocks(At(t), n, r);
377
+ function V(e, t, n, r) {
378
+ e.transact((e) => {
379
+ R(e, t, [], { fixColumns: !1 }), pt(e, Nt(t), n, r);
329
380
  });
330
381
  }
331
- function jt(e, t, n) {
382
+ function Pt(e, t, n) {
332
383
  e.transact((r) => {
333
- let i = e.getSelection()?.blocks || [e.getTextCursorPosition().block], a = Ot(e);
334
- B(e, i, t, n), kt(r, a);
384
+ let i = e.getSelection()?.blocks || [e.getTextCursorPosition().block], a = jt(e);
385
+ V(e, i, t, n), Mt(r, a);
335
386
  });
336
387
  }
337
- function Mt(e) {
388
+ function Ft(e) {
338
389
  return !e || e.type !== "columnList";
339
390
  }
340
- function Nt(e, t, n) {
391
+ function It(e, t, n) {
341
392
  let r, i;
342
393
  if (t ? t.children.length > 0 ? (r = t.children[t.children.length - 1], i = "after") : (r = t, i = "before") : n && (r = n, i = "before"), !r || !i) return;
343
394
  let a = e.getParentBlock(r);
344
- return Mt(a) ? {
395
+ return Ft(a) ? {
345
396
  referenceBlock: r,
346
397
  placement: i
347
- } : Nt(e, i === "after" ? r : e.getPrevBlock(r), a);
398
+ } : It(e, i === "after" ? r : e.getPrevBlock(r), a);
348
399
  }
349
- function Pt(e, t, n) {
400
+ function Lt(e, t, n) {
350
401
  let r, i;
351
402
  if (t ? t.children.length > 0 ? (r = t.children[0], i = "before") : (r = t, i = "after") : n && (r = n, i = "after"), !r || !i) return;
352
403
  let a = e.getParentBlock(r);
353
- return Mt(a) ? {
404
+ return Ft(a) ? {
354
405
  referenceBlock: r,
355
406
  placement: i
356
- } : Pt(e, i === "before" ? r : e.getNextBlock(r), a);
407
+ } : Lt(e, i === "before" ? r : e.getNextBlock(r), a);
357
408
  }
358
- function Ft(e, t) {
409
+ function Rt(e, t) {
359
410
  e.transact(() => {
360
411
  let n;
361
412
  if (t) {
362
413
  if (n = e.getBlock(t), !n) return;
363
414
  } else n = e.getSelection()?.blocks[0] || e.getTextCursorPosition().block;
364
- let r = Nt(e, e.getPrevBlock(n), e.getParentBlock(n));
365
- r && (t ? B(e, [n], r.referenceBlock, r.placement) : jt(e, r.referenceBlock, r.placement));
415
+ let r = It(e, e.getPrevBlock(n), e.getParentBlock(n));
416
+ r && (t ? V(e, [n], r.referenceBlock, r.placement) : Pt(e, r.referenceBlock, r.placement));
366
417
  });
367
418
  }
368
- function It(e, t) {
419
+ function zt(e, t) {
369
420
  e.transact(() => {
370
421
  let n;
371
422
  if (t) {
@@ -374,100 +425,101 @@ function It(e, t) {
374
425
  let t = e.getSelection();
375
426
  n = t?.blocks[t?.blocks.length - 1] || e.getTextCursorPosition().block;
376
427
  }
377
- let r = Pt(e, e.getNextBlock(n), e.getParentBlock(n));
378
- r && (t ? B(e, [n], r.referenceBlock, r.placement) : jt(e, r.referenceBlock, r.placement));
428
+ let r = Lt(e, e.getNextBlock(n), e.getParentBlock(n));
429
+ r && (t ? V(e, [n], r.referenceBlock, r.placement) : Pt(e, r.referenceBlock, r.placement));
379
430
  });
380
431
  }
381
432
  //#endregion
382
433
  //#region src/api/blockManipulation/commands/nestBlock/nestBlock.ts
383
- function Lt(e, t, n) {
434
+ function Bt(e, t, n) {
384
435
  let { $from: r, $to: i } = e.selection, a = r.blockRange(i, (e) => e.childCount > 0 && (e.type.name === "blockGroup" || e.type.name === "column"));
385
436
  if (!a) return !1;
386
437
  let o = a.startIndex;
387
438
  if (o === 0) return !1;
388
439
  let s = a.parent.child(o - 1);
389
440
  if (s.type !== t) return !1;
390
- let c = s.lastChild && s.lastChild.type === n, l = T.from(c ? t.create() : null), u = new E(T.from(t.create(null, T.from(n.create(null, l)))), c ? 3 : 1, 0), d = a.start, f = a.end;
391
- return e.step(new D(d - (c ? 3 : 1), f, d, f, u, 1, !0)).scrollIntoView(), !0;
441
+ let c = s.lastChild && s.lastChild.type === n, l = w.from(c ? t.create() : null), u = new T(w.from(t.create(null, w.from(n.create(null, l)))), c ? 3 : 1, 0), d = a.start, f = a.end;
442
+ return e.step(new E(d - (c ? 3 : 1), f, d, f, u, 1, !0)).scrollIntoView(), !0;
392
443
  }
393
- function Rt(e) {
394
- return e.transact((t) => Lt(t, e.pmSchema.nodes.blockContainer, e.pmSchema.nodes.blockGroup));
444
+ function Vt(e) {
445
+ return e.transact((t) => Bt(t, e.pmSchema.nodes.blockContainer, e.pmSchema.nodes.blockGroup));
395
446
  }
396
- function zt(e, t, n, r) {
447
+ function Ht(e, t, n, r) {
397
448
  let i = r.end, a = r.$to.end(r.depth);
398
449
  if (i < a) {
399
450
  let o = r.parent.child(r.endIndex - 1), s = o.lastChild && o.lastChild.type === n;
400
- e.step(new D(i - (s ? 2 : 1), a, i, a, new E(T.from(t.create(null, n.create())), s ? 2 : 1, 0), +!s, !0)), r = new ze(e.doc.resolve(r.$from.pos), e.doc.resolve(a), r.depth);
451
+ e.step(new E(i - (s ? 2 : 1), a, i, a, new T(w.from(t.create(null, n.create())), s ? 2 : 1, 0), +!s, !0)), r = new Ie(e.doc.resolve(r.$from.pos), e.doc.resolve(a), r.depth);
401
452
  }
402
- let o = He(r);
453
+ let o = ze(r);
403
454
  if (o == null) return !1;
404
455
  e.lift(r, o);
405
456
  let s = e.doc.resolve(e.mapping.map(i, -1) - 1);
406
- return Ve(e.doc, s.pos) && s.nodeBefore.type === s.nodeAfter.type && e.join(s.pos), e.scrollIntoView(), !0;
457
+ return Re(e.doc, s.pos) && s.nodeBefore.type === s.nodeAfter.type && e.join(s.pos), e.scrollIntoView(), !0;
407
458
  }
408
- function V(e, t, n) {
459
+ function H(e, t, n) {
409
460
  let { $from: r, $to: i } = e.selection, a = r.blockRange(i, (e) => e.childCount > 0 && (e.type.name === "blockGroup" || e.type.name === "column"));
410
- return a && r.node(a.depth - 1).type === t ? zt(e, t, n, a) : !1;
461
+ return a && r.node(a.depth - 1).type === t ? Ht(e, t, n, a) : !1;
411
462
  }
412
- function Bt(e) {
413
- return e.transact((t) => V(t, e.pmSchema.nodes.blockContainer, e.pmSchema.nodes.blockGroup));
463
+ function Ut(e) {
464
+ return e.transact((t) => H(t, e.pmSchema.nodes.blockContainer, e.pmSchema.nodes.blockGroup));
414
465
  }
415
- function Vt(e) {
466
+ function Wt(e) {
416
467
  return e.transact((e) => {
417
- let { bnBlock: t } = f(e);
468
+ let { bnBlock: t } = _(e);
418
469
  return e.doc.resolve(t.beforePos).nodeBefore !== null;
419
470
  });
420
471
  }
421
- function Ht(e) {
472
+ function Gt(e) {
422
473
  return e.transact((e) => {
423
- let { bnBlock: t } = f(e);
474
+ let { bnBlock: t } = _(e);
424
475
  return e.doc.resolve(t.beforePos).depth > 1;
425
476
  });
426
477
  }
427
478
  //#endregion
428
479
  //#region src/api/blockManipulation/getBlock/getBlock.ts
429
- function Ut(e, t) {
430
- let n = typeof t == "string" ? t : t.id, i = g(e), a = r(n, e);
431
- if (a) return m(a.node, i);
480
+ function Kt(e, t) {
481
+ let n = x(typeof t == "string" ? t : t.id, e);
482
+ if (n) return C(n.node, e);
432
483
  }
433
- function Wt(e, t) {
434
- let n = r(typeof t == "string" ? t : t.id, e), i = g(e);
484
+ function qt(e, t) {
485
+ let n = x(typeof t == "string" ? t : t.id, e);
435
486
  if (!n) return;
436
- let a = e.resolve(n.posBeforeNode).nodeBefore;
437
- if (a) return m(a, i);
487
+ let r = e.resolve(n.posBeforeNode).nodeBefore;
488
+ if (r) return C(r, e);
438
489
  }
439
- function Gt(e, t) {
440
- let n = r(typeof t == "string" ? t : t.id, e), i = g(e);
490
+ function Jt(e, t) {
491
+ let n = x(typeof t == "string" ? t : t.id, e);
441
492
  if (!n) return;
442
- let a = e.resolve(n.posBeforeNode + n.node.nodeSize).nodeAfter;
443
- if (a) return m(a, i);
493
+ let r = e.resolve(n.posBeforeNode + n.node.nodeSize).nodeAfter;
494
+ if (r) return C(r, e);
444
495
  }
445
- function Kt(e, t) {
446
- let n = typeof t == "string" ? t : t.id, i = g(e), a = r(n, e);
447
- if (!a) return;
448
- let o = e.resolve(a.posBeforeNode), s = o.node(), c = o.node(-1), l = c.type.name === "doc" ? void 0 : s.type.name === "blockGroup" ? c : s;
449
- if (l) return m(l, i);
496
+ function Yt(e, t) {
497
+ let n = x(typeof t == "string" ? t : t.id, e);
498
+ if (!n) return;
499
+ let r = e.resolve(n.posBeforeNode), i = r.node(), a = r.node(-1), o = a.type.name === "doc" ? void 0 : i.type.name === "blockGroup" ? a : i;
500
+ if (o) return C(o, e);
450
501
  }
451
502
  //#endregion
452
503
  //#region src/editor/managers/BlockManager.ts
453
- var qt = class {
504
+ var Xt = class {
505
+ editor;
454
506
  constructor(e) {
455
507
  this.editor = e;
456
508
  }
457
509
  get document() {
458
- return this.editor.transact((e) => ee(e.doc, this.editor.pmSchema));
510
+ return this.editor.transact((e) => ue(e.doc));
459
511
  }
460
512
  getBlock(e) {
461
- return this.editor.transact((t) => Ut(t.doc, e));
513
+ return this.editor.transact((t) => Kt(t.doc, e));
462
514
  }
463
515
  getPrevBlock(e) {
464
- return this.editor.transact((t) => Wt(t.doc, e));
516
+ return this.editor.transact((t) => qt(t.doc, e));
465
517
  }
466
518
  getNextBlock(e) {
467
- return this.editor.transact((t) => Gt(t.doc, e));
519
+ return this.editor.transact((t) => Jt(t.doc, e));
468
520
  }
469
521
  getParentBlock(e) {
470
- return this.editor.transact((t) => Kt(t.doc, e));
522
+ return this.editor.transact((t) => Yt(t.doc, e));
471
523
  }
472
524
  forEachBlock(e, t = !1) {
473
525
  let n = this.document.slice();
@@ -479,36 +531,37 @@ var qt = class {
479
531
  r(n);
480
532
  }
481
533
  insertBlocks(e, t, n = "before") {
482
- return this.editor.transact((r) => ht(r, e, t, n));
534
+ return this.editor.transact((r) => pt(r, e, t, n));
483
535
  }
484
536
  updateBlock(e, t) {
485
- return this.editor.transact((n) => le(n, e, t));
537
+ return this.editor.transact((n) => a(n, e, t));
486
538
  }
487
539
  removeBlocks(e) {
488
- return this.editor.transact((t) => z(t, e, []).removedBlocks);
540
+ return this.editor.transact((t) => R(t, e, []).removedBlocks);
489
541
  }
490
542
  replaceBlocks(e, t) {
491
- return this.editor.transact((n) => z(n, e, t));
543
+ return this.editor.transact((n) => R(n, e, t));
492
544
  }
493
545
  canNestBlock() {
494
- return Vt(this.editor);
546
+ return Wt(this.editor);
495
547
  }
496
548
  nestBlock() {
497
- Rt(this.editor);
549
+ Vt(this.editor);
498
550
  }
499
551
  canUnnestBlock() {
500
- return Ht(this.editor);
552
+ return Gt(this.editor);
501
553
  }
502
554
  unnestBlock() {
503
- Bt(this.editor);
555
+ Ut(this.editor);
504
556
  }
505
557
  moveBlocksUp(e) {
506
- return Ft(this.editor, e);
558
+ return Rt(this.editor, e);
507
559
  }
508
560
  moveBlocksDown(e) {
509
- return It(this.editor, e);
561
+ return zt(this.editor, e);
510
562
  }
511
- }, Jt = class extends Fe {
563
+ }, Zt = class extends B {
564
+ editor;
512
565
  constructor(e) {
513
566
  super(), this.editor = e, e.on("create", () => {
514
567
  e._tiptapEditor.on("update", ({ transaction: t, appendedTransactions: n }) => {
@@ -531,8 +584,8 @@ var qt = class {
531
584
  }
532
585
  onChange(e, t = !0) {
533
586
  let n = ({ transaction: n, appendedTransactions: r }) => {
534
- !t && Yt(n) || e(this.editor, { getChanges() {
535
- return fe(n, r);
587
+ !t && Qt(n) || e(this.editor, { getChanges() {
588
+ return Ee(n, r);
536
589
  } });
537
590
  };
538
591
  return this.on("onChange", n), () => {
@@ -541,7 +594,7 @@ var qt = class {
541
594
  }
542
595
  onSelectionChange(e, t = !1) {
543
596
  let n = (n) => {
544
- !t && Yt(n.transaction) || e(this.editor);
597
+ !t && Qt(n.transaction) || e(this.editor);
545
598
  };
546
599
  return this.on("onSelectionChange", n), () => {
547
600
  this.off("onSelectionChange", n);
@@ -558,30 +611,30 @@ var qt = class {
558
611
  };
559
612
  }
560
613
  };
561
- function Yt(e) {
614
+ function Qt(e) {
562
615
  return !!e.getMeta("y-sync$");
563
616
  }
564
617
  //#endregion
565
618
  //#region src/api/parsers/html/util/nestedLists.ts
566
- function Xt(e) {
619
+ function $t(e) {
567
620
  return Array.prototype.indexOf.call(e.parentElement.childNodes, e);
568
621
  }
569
- function Zt(e) {
622
+ function en(e) {
570
623
  return e.nodeType === 3 && !/\S/.test(e.nodeValue || "");
571
624
  }
572
- function Qt(e) {
625
+ function tn(e) {
573
626
  e.querySelectorAll("li > ul, li > ol").forEach((e) => {
574
- let t = Xt(e), n = e.parentElement, r = Array.from(n.childNodes).slice(t + 1);
627
+ let t = $t(e), n = e.parentElement, r = Array.from(n.childNodes).slice(t + 1);
575
628
  e.remove(), r.forEach((e) => {
576
629
  e.remove();
577
630
  }), n.insertAdjacentElement("afterend", e), r.reverse().forEach((t) => {
578
- if (Zt(t)) return;
631
+ if (en(t)) return;
579
632
  let n = document.createElement("li");
580
633
  n.append(t), e.insertAdjacentElement("afterend", n);
581
634
  }), n.childNodes.length === 0 && n.remove();
582
635
  });
583
636
  }
584
- function $t(e) {
637
+ function nn(e) {
585
638
  e.querySelectorAll("li + ul, li + ol").forEach((e) => {
586
639
  let t = e.previousElementSibling, n = document.createElement("div");
587
640
  t.insertAdjacentElement("afterend", n), n.append(t);
@@ -589,25 +642,25 @@ function $t(e) {
589
642
  for (r.setAttribute("data-node-type", "blockGroup"), n.append(r); n.nextElementSibling?.nodeName === "UL" || n.nextElementSibling?.nodeName === "OL";) r.append(n.nextElementSibling);
590
643
  });
591
644
  }
592
- var en = null;
593
- function tn() {
594
- return en ||= document.implementation.createHTMLDocument("title");
645
+ var rn = null;
646
+ function an() {
647
+ return rn ||= document.implementation.createHTMLDocument("title");
595
648
  }
596
- function nn(e) {
649
+ function on(e) {
597
650
  if (typeof e == "string") {
598
- let t = tn().createElement("div");
651
+ let t = an().createElement("div");
599
652
  t.innerHTML = e, e = t;
600
653
  }
601
- return Qt(e), $t(e), e;
654
+ return tn(e), nn(e), e;
602
655
  }
603
656
  //#endregion
604
657
  //#region src/api/parsers/html/util/normalizeWhitespace.ts
605
- function rn(e) {
658
+ function sn(e) {
606
659
  let t = e.ownerDocument.createTreeWalker(e, 128), n;
607
660
  for (; n = t.nextNode();) if (/^\s*notionvc:/.test(n.nodeValue || "")) return !0;
608
661
  return !1;
609
662
  }
610
- function an(e) {
663
+ function cn(e) {
611
664
  let t = new Set(["PRE", "CODE"]), n = e.ownerDocument.createTreeWalker(e, 4, { acceptNode(n) {
612
665
  let r = n.parentElement;
613
666
  for (; r && r !== e;) {
@@ -619,78 +672,78 @@ function an(e) {
619
672
  for (; i = n.nextNode();) r.push(i);
620
673
  for (let e of r) e.nodeValue && /[\r\n]/.test(e.nodeValue) && (e.nodeValue = e.nodeValue.replace(/[ \t\r\n\f]+/g, " "));
621
674
  }
622
- function on(e) {
623
- rn(e) || an(e);
675
+ function ln(e) {
676
+ sn(e) || cn(e);
624
677
  }
625
678
  //#endregion
626
679
  //#region src/api/parsers/html/parseHTML.ts
627
- function H(e, t) {
628
- let n = nn(e);
629
- on(n);
630
- let r = Ie.fromSchema(t).parse(n, { topNode: t.nodes.blockGroup.create() }), i = [];
631
- for (let e = 0; e < r.childCount; e++) i.push(m(r.child(e), t));
680
+ function U(e, t) {
681
+ let n = on(e);
682
+ ln(n);
683
+ let r = Pe.fromSchema(t).parse(n, { topNode: t.nodes.blockGroup.create() }), i = [];
684
+ for (let e = 0; e < r.childCount; e++) i.push(C(r.child(e), r));
632
685
  return i;
633
686
  }
634
687
  //#endregion
635
688
  //#region src/api/parsers/markdown/markdownToHtml.ts
636
- function U(e) {
689
+ function W(e) {
637
690
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
638
691
  }
639
- function sn(e) {
692
+ function un(e) {
640
693
  return e ? /\w/.test(e) : !1;
641
694
  }
642
- function W(e, t, n) {
695
+ function G(e, t, n) {
643
696
  let r = t > 0 ? e[t - 1] : void 0, i = t + n < e.length ? e[t + n] : void 0;
644
- return sn(r) && sn(i);
697
+ return un(r) && un(i);
645
698
  }
646
- function cn(e, t) {
699
+ function dn(e, t) {
647
700
  if (e[t] !== "\\" || t + 1 >= e.length) return null;
648
701
  let n = e[t + 1];
649
702
  return n === "\n" ? {
650
703
  html: "<br>\n",
651
704
  end: t + 2
652
705
  } : "\\`*_{}[]()#+-.!~|>".includes(n) ? {
653
- html: U(n),
706
+ html: W(n),
654
707
  end: t + 2
655
708
  } : null;
656
709
  }
657
- function ln(e, t) {
658
- return e[t] === "`" ? Tn(e, t) : null;
659
- }
660
- function un(e, t) {
661
- return e[t] !== "!" || e[t + 1] !== "[" ? null : En(e, t);
662
- }
663
- function dn(e, t) {
664
- return e[t] === "[" ? Dn(e, t) : null;
665
- }
666
710
  function fn(e, t) {
667
- return e[t] !== "~" || e[t + 1] !== "~" ? null : K(e, t, "~~", "<del>", "</del>");
711
+ return e[t] === "`" ? On(e, t) : null;
668
712
  }
669
713
  function pn(e, t) {
670
- return e[t] === "*" && e[t + 1] === "*" && e[t + 2] === "*" || e[t] === "_" && e[t + 1] === "_" && e[t + 2] === "_" && !W(e, t, 3) ? K(e, t, e.substring(t, t + 3), "<strong><em>", "</em></strong>") : null;
714
+ return e[t] !== "!" || e[t + 1] !== "[" ? null : kn(e, t);
671
715
  }
672
716
  function mn(e, t) {
673
- return e[t] === "*" && e[t + 1] === "*" || e[t] === "_" && e[t + 1] === "_" && !W(e, t, 2) ? K(e, t, e.substring(t, t + 2), "<strong>", "</strong>") : null;
717
+ return e[t] === "[" ? An(e, t) : null;
674
718
  }
675
719
  function hn(e, t) {
676
- return e[t] === "*" || e[t] === "_" && !W(e, t, 1) ? K(e, t, e[t], "<em>", "</em>") : null;
720
+ return e[t] !== "~" || e[t + 1] !== "~" ? null : q(e, t, "~~", "<del>", "</del>");
677
721
  }
678
722
  function gn(e, t) {
723
+ return e[t] === "*" && e[t + 1] === "*" && e[t + 2] === "*" || e[t] === "_" && e[t + 1] === "_" && e[t + 2] === "_" && !G(e, t, 3) ? q(e, t, e.substring(t, t + 3), "<strong><em>", "</em></strong>") : null;
724
+ }
725
+ function _n(e, t) {
726
+ return e[t] === "*" && e[t + 1] === "*" || e[t] === "_" && e[t + 1] === "_" && !G(e, t, 2) ? q(e, t, e.substring(t, t + 2), "<strong>", "</strong>") : null;
727
+ }
728
+ function vn(e, t) {
729
+ return e[t] === "*" || e[t] === "_" && !G(e, t, 1) ? q(e, t, e[t], "<em>", "</em>") : null;
730
+ }
731
+ function yn(e, t) {
679
732
  return e[t] === "\n" ? {
680
733
  html: "<br>\n",
681
734
  end: t + 1
682
735
  } : null;
683
736
  }
684
- var _n = /^<\/?[a-zA-Z][a-zA-Z0-9-]*(?:\s+[a-zA-Z_:][a-zA-Z0-9_.:-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*\s*\/?>/, vn = /^<!--[\s\S]*?-->/, yn = /^<!\[CDATA\[[\s\S]*?\]\]>/, bn = /^<\?[\s\S]*?\?>/, xn = /^<![A-Za-z][\s\S]*?>/;
685
- function Sn(e, t) {
737
+ var bn = /^<\/?[a-zA-Z][a-zA-Z0-9-]*(?:\s+[a-zA-Z_:][a-zA-Z0-9_.:-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*\s*\/?>/, xn = /^<!--[\s\S]*?-->/, Sn = /^<!\[CDATA\[[\s\S]*?\]\]>/, Cn = /^<\?[\s\S]*?\?>/, wn = /^<![A-Za-z][\s\S]*?>/;
738
+ function Tn(e, t) {
686
739
  if (e[t] !== "<") return null;
687
740
  let n = e.substring(t);
688
741
  for (let e of [
689
- vn,
690
- yn,
691
- bn,
692
742
  xn,
693
- _n
743
+ Sn,
744
+ Cn,
745
+ wn,
746
+ bn
694
747
  ]) {
695
748
  let r = n.match(e);
696
749
  if (r) return {
@@ -700,19 +753,19 @@ function Sn(e, t) {
700
753
  }
701
754
  return null;
702
755
  }
703
- var Cn = /* @__PURE__ */ new Set("\\`![~*_\n<"), wn = [
704
- cn,
705
- ln,
706
- un,
756
+ var En = /* @__PURE__ */ new Set("\\`![~*_\n<"), Dn = [
707
757
  dn,
708
758
  fn,
709
759
  pn,
710
760
  mn,
711
761
  hn,
712
- Sn,
713
- gn
762
+ gn,
763
+ _n,
764
+ vn,
765
+ Tn,
766
+ yn
714
767
  ];
715
- function G(e) {
768
+ function K(e) {
716
769
  let t = "", n = 0;
717
770
  for (; n < e.length;) {
718
771
  if (e[n] === "\n" && n >= 2 && e[n - 1] === " " && e[n - 2] === " ") {
@@ -720,7 +773,7 @@ function G(e) {
720
773
  continue;
721
774
  }
722
775
  let r = !1;
723
- if (Cn.has(e[n])) for (let i of wn) {
776
+ if (En.has(e[n])) for (let i of Dn) {
724
777
  let a = i(e, n);
725
778
  if (a) {
726
779
  t += a.html, n = a.end, r = !0;
@@ -729,13 +782,13 @@ function G(e) {
729
782
  }
730
783
  if (!r) {
731
784
  let r = n;
732
- for (n++; n < e.length && !Cn.has(e[n]);) n++;
733
- t += U(e.substring(r, n));
785
+ for (n++; n < e.length && !En.has(e[n]);) n++;
786
+ t += W(e.substring(r, n));
734
787
  }
735
788
  }
736
789
  return t;
737
790
  }
738
- function Tn(e, t) {
791
+ function On(e, t) {
739
792
  let n = 0, r = t;
740
793
  for (; r < e.length && e[r] === "`";) n++, r++;
741
794
  let i = r;
@@ -745,46 +798,46 @@ function Tn(e, t) {
745
798
  if (t === n) {
746
799
  let t = e.substring(r, a);
747
800
  return t = t.replace(/\n/g, " "), t.length >= 2 && t[0] === " " && t[t.length - 1] === " " && /[^ ]/.test(t) && (t = t.substring(1, t.length - 1)), {
748
- html: `<code>${U(t)}</code>`,
801
+ html: `<code>${W(t)}</code>`,
749
802
  end: i
750
803
  };
751
804
  }
752
805
  } else i++;
753
806
  return null;
754
807
  }
755
- function En(e, t) {
756
- let n = On(e, t + 1);
808
+ function kn(e, t) {
809
+ let n = jn(e, t + 1);
757
810
  if (n === -1) return null;
758
811
  let r = t + 2;
759
812
  if (e[n + 1] !== "(") return null;
760
- let i = n + 2, a = kn(e, i - 1);
813
+ let i = n + 2, a = Mn(e, i - 1);
761
814
  if (a === -1) return null;
762
- let o = e.substring(r, n), { url: s, title: c } = An(e.substring(i, a));
763
- if (te(s)) {
815
+ let o = e.substring(r, n), { url: s, title: c } = Nn(e.substring(i, a));
816
+ if (oe(s)) {
764
817
  let e = o || c;
765
818
  return {
766
- html: `<video src="${U(s)}"${e ? ` data-name="${U(e)}"` : ""} data-url="${U(s)}" controls></video>`,
819
+ html: `<video src="${W(s)}"${e ? ` data-name="${W(e)}"` : ""} data-url="${W(s)}" controls></video>`,
767
820
  end: a + 1
768
821
  };
769
822
  }
770
- let l = c === void 0 ? "" : ` title="${U(c)}"`;
823
+ let l = c === void 0 ? "" : ` title="${W(c)}"`;
771
824
  return {
772
- html: `<img src="${U(s)}" alt="${U(o)}"${l}>`,
825
+ html: `<img src="${W(s)}" alt="${W(o)}"${l}>`,
773
826
  end: a + 1
774
827
  };
775
828
  }
776
- function Dn(e, t) {
777
- let n = t + 1, r = On(e, t);
829
+ function An(e, t) {
830
+ let n = t + 1, r = jn(e, t);
778
831
  if (r === -1 || e[r + 1] !== "(") return null;
779
- let i = r + 2, a = kn(e, r + 1);
832
+ let i = r + 2, a = Mn(e, r + 1);
780
833
  if (a === -1) return null;
781
- let o = e.substring(n, r), { url: s, title: c } = An(e.substring(i, a)), l = c === void 0 ? "" : ` title="${U(c)}"`;
834
+ let o = e.substring(n, r), { url: s, title: c } = Nn(e.substring(i, a)), l = c === void 0 ? "" : ` title="${W(c)}"`;
782
835
  return {
783
- html: `<a href="${U(s)}"${l}>${G(o)}</a>`,
836
+ html: `<a href="${W(s)}"${l}>${K(o)}</a>`,
784
837
  end: a + 1
785
838
  };
786
839
  }
787
- function On(e, t) {
840
+ function jn(e, t) {
788
841
  let n = 0;
789
842
  for (let r = t; r < e.length; r++) {
790
843
  if (e[r] === "\\" && r + 1 < e.length) {
@@ -795,7 +848,7 @@ function On(e, t) {
795
848
  }
796
849
  return -1;
797
850
  }
798
- function kn(e, t) {
851
+ function Mn(e, t) {
799
852
  let n = 0;
800
853
  for (let r = t; r < e.length; r++) {
801
854
  if (e[r] === "\\" && r + 1 < e.length) {
@@ -806,7 +859,7 @@ function kn(e, t) {
806
859
  }
807
860
  return -1;
808
861
  }
809
- function An(e) {
862
+ function Nn(e) {
810
863
  e = e.trim();
811
864
  let t, n;
812
865
  if (e.startsWith("<")) {
@@ -836,7 +889,7 @@ function An(e) {
836
889
  title: r
837
890
  };
838
891
  }
839
- function K(e, t, n, r, i) {
892
+ function q(e, t, n, r, i) {
840
893
  let a = n.length, o = t + a;
841
894
  if (o >= e.length || e[o] === " " || e[o] === " ") return null;
842
895
  let s = o;
@@ -860,7 +913,7 @@ function K(e, t, n, r, i) {
860
913
  continue;
861
914
  }
862
915
  return {
863
- html: r + G(t) + i,
916
+ html: r + K(t) + i,
864
917
  end: s + a
865
918
  };
866
919
  }
@@ -868,13 +921,13 @@ function K(e, t, n, r, i) {
868
921
  }
869
922
  return null;
870
923
  }
871
- var jn = new Set(/* @__PURE__ */ "address.article.aside.audio.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.section.source.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul".split("."));
872
- function Mn(e) {
924
+ var Pn = new Set(/* @__PURE__ */ "address.article.aside.audio.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.section.source.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul".split("."));
925
+ function Fn(e) {
873
926
  if (/^ {0,3}<(!--|\?|![A-Za-z]|!\[CDATA\[)/.test(e)) return !0;
874
927
  let t = e.match(/^ {0,3}<\/?([a-zA-Z][a-zA-Z0-9-]*)(?:\s|\/?>|$)/);
875
- return t ? jn.has(t[1].toLowerCase()) : !1;
928
+ return t ? Pn.has(t[1].toLowerCase()) : !1;
876
929
  }
877
- function q(e) {
930
+ function J(e) {
878
931
  let t = e.split("\n"), n = [], r = 0, i = !0;
879
932
  for (; r < t.length;) {
880
933
  let e = t[r];
@@ -933,7 +986,7 @@ function q(e) {
933
986
  continue;
934
987
  }
935
988
  }
936
- let s = Nn(t, r);
989
+ let s = In(t, r);
937
990
  if (s) {
938
991
  n.push(s.token), r = s.nextLine, i = !1;
939
992
  continue;
@@ -989,7 +1042,7 @@ function q(e) {
989
1042
  }), i = !1;
990
1043
  continue;
991
1044
  }
992
- if (Mn(e)) {
1045
+ if (Fn(e)) {
993
1046
  let e = [];
994
1047
  for (; r < t.length && t[r].trim() !== "";) e.push(t[r]), r++;
995
1048
  n.push({
@@ -1001,7 +1054,7 @@ function q(e) {
1001
1054
  let l = [e];
1002
1055
  for (r++; r < t.length;) {
1003
1056
  let e = t[r];
1004
- if (e.trim() === "" || /^(#{1,6})\s/.test(e) || /^(`{3,}|~{3,})/.test(e) || /^\s{0,3}>/.test(e) || /^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(e) || /^\s*([-*+]|\d+[.)])\s+/.test(e) || /^\s*\|(.+\|)+\s*$/.test(e) || Mn(e) || r + 1 < t.length && /^[=-]+\s*$/.test(t[r + 1]) && e.trim().length > 0) break;
1057
+ if (e.trim() === "" || /^(#{1,6})\s/.test(e) || /^(`{3,}|~{3,})/.test(e) || /^\s{0,3}>/.test(e) || /^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(e) || /^\s*([-*+]|\d+[.)])\s+/.test(e) || /^\s*\|(.+\|)+\s*$/.test(e) || Fn(e) || r + 1 < t.length && /^[=-]+\s*$/.test(t[r + 1]) && e.trim().length > 0) break;
1005
1058
  l.push(e), r++;
1006
1059
  }
1007
1060
  n.push({
@@ -1011,15 +1064,15 @@ function q(e) {
1011
1064
  }
1012
1065
  return n;
1013
1066
  }
1014
- function Nn(e, t) {
1067
+ function In(e, t) {
1015
1068
  if (t + 1 >= e.length) return null;
1016
1069
  let n = e[t], r = e[t + 1];
1017
1070
  if (!r.includes("|") || !/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/.test(r) || !n.includes("|")) return null;
1018
- let i = J(n), a = Pn(r), o = [], s = t + 2;
1071
+ let i = Y(n), a = Ln(r), o = [], s = t + 2;
1019
1072
  for (; s < e.length;) {
1020
1073
  let t = e[s];
1021
1074
  if (!t.includes("|")) break;
1022
- o.push(J(t)), s++;
1075
+ o.push(Y(t)), s++;
1023
1076
  }
1024
1077
  return {
1025
1078
  token: {
@@ -1031,37 +1084,37 @@ function Nn(e, t) {
1031
1084
  nextLine: s
1032
1085
  };
1033
1086
  }
1034
- function J(e) {
1087
+ function Y(e) {
1035
1088
  let t = e.trim(), n = t.startsWith("|") ? t.substring(1) : t, r = n.endsWith("|") ? n.substring(0, n.length - 1) : n, i = [], a = "";
1036
1089
  for (let e = 0; e < r.length; e++) r[e] === "\\" && e + 1 < r.length && r[e + 1] === "|" ? (a += "|", e++) : r[e] === "|" ? (i.push(a.trim()), a = "") : a += r[e];
1037
1090
  return i.push(a.trim()), i;
1038
1091
  }
1039
- function Pn(e) {
1040
- return J(e).map((e) => {
1092
+ function Ln(e) {
1093
+ return Y(e).map((e) => {
1041
1094
  let t = e.trim(), n = t.startsWith(":"), r = t.endsWith(":");
1042
1095
  return n && r ? "center" : r ? "right" : n ? "left" : null;
1043
1096
  });
1044
1097
  }
1045
- function Y(e) {
1098
+ function Rn(e) {
1046
1099
  let t = "", n = 0;
1047
1100
  for (; n < e.length;) {
1048
1101
  let r = e[n];
1049
1102
  switch (r.type) {
1050
1103
  case "heading": {
1051
1104
  let e = r;
1052
- t += `<h${e.level}>${G(e.content)}</h${e.level}>`, n++;
1105
+ t += `<h${e.level}>${K(e.content)}</h${e.level}>`, n++;
1053
1106
  break;
1054
1107
  }
1055
1108
  case "paragraph":
1056
- t += `<p>${G(r.content)}</p>`, n++;
1109
+ t += `<p>${K(r.content)}</p>`, n++;
1057
1110
  break;
1058
1111
  case "codeBlock": {
1059
- let e = r, i = e.language ? ` data-language="${U(e.language)}"` : "";
1060
- t += `<pre><code${i}>${U(e.code)}</code></pre>`, n++;
1112
+ let e = r, i = e.language ? ` data-language="${W(e.language)}"` : "";
1113
+ t += `<pre><code${i}>${W(e.code)}</code></pre>`, n++;
1061
1114
  break;
1062
1115
  }
1063
1116
  case "blockquote": {
1064
- let e = Y(q(r.content));
1117
+ let e = Rn(J(r.content));
1065
1118
  t += `<blockquote>${e}</blockquote>`, n++;
1066
1119
  break;
1067
1120
  }
@@ -1069,12 +1122,12 @@ function Y(e) {
1069
1122
  t += "<hr>", n++;
1070
1123
  break;
1071
1124
  case "listItem": {
1072
- let r = Fn(e, n);
1125
+ let r = zn(e, n);
1073
1126
  t += r.html, n = r.nextIndex;
1074
1127
  break;
1075
1128
  }
1076
1129
  case "table":
1077
- t += Ln(r), n++;
1130
+ t += Vn(r), n++;
1078
1131
  break;
1079
1132
  case "rawHtml":
1080
1133
  t += r.content, n++;
@@ -1084,10 +1137,10 @@ function Y(e) {
1084
1137
  }
1085
1138
  return t;
1086
1139
  }
1087
- function Fn(e, t) {
1140
+ function zn(e, t) {
1088
1141
  let n = "", r = t, i = null;
1089
1142
  for (; r < e.length && e[r].type === "listItem";) {
1090
- let t = e[r], a = In(t.listType);
1143
+ let t = e[r], a = Bn(t.listType);
1091
1144
  if (i !== null && i !== a && (n += `</${i === "ordered" ? "ol" : "ul"}>`, i = null), i === null) {
1092
1145
  if (a === "ordered") {
1093
1146
  let e = t.start !== void 0 && t.start !== 1 ? ` start="${t.start}"` : "";
@@ -1097,11 +1150,11 @@ function Fn(e, t) {
1097
1150
  }
1098
1151
  if (t.listType === "task") {
1099
1152
  let e = t.checked ? " checked" : "";
1100
- n += `<li><input type="checkbox" disabled${e}><p>${G(t.content)}</p>`;
1101
- } else n += `<li><p>${G(t.content)}</p>`;
1153
+ n += `<li><input type="checkbox" disabled${e}><p>${K(t.content)}</p>`;
1154
+ } else n += `<li><p>${K(t.content)}</p>`;
1102
1155
  if (t.childContent) {
1103
- let e = q(t.childContent);
1104
- n += Y(e);
1156
+ let e = J(t.childContent);
1157
+ n += Rn(e);
1105
1158
  }
1106
1159
  n += "</li>", r++;
1107
1160
  }
@@ -1110,16 +1163,16 @@ function Fn(e, t) {
1110
1163
  nextIndex: r
1111
1164
  };
1112
1165
  }
1113
- function In(e) {
1166
+ function Bn(e) {
1114
1167
  return e === "ordered" ? "ordered" : "bullet";
1115
1168
  }
1116
- function Ln(e) {
1169
+ function Vn(e) {
1117
1170
  let t = "<table>", n = e.headers.every((e) => e.trim() === ""), r = e.headers.length;
1118
1171
  if (!n) {
1119
1172
  t += "<thead><tr>";
1120
1173
  for (let n = 0; n < r; n++) {
1121
1174
  let r = e.alignments[n], i = r ? ` align="${r}"` : "";
1122
- t += `<th${i}>${G(e.headers[n])}</th>`;
1175
+ t += `<th${i}>${K(e.headers[n])}</th>`;
1123
1176
  }
1124
1177
  t += "</tr></thead>";
1125
1178
  }
@@ -1129,7 +1182,7 @@ function Ln(e) {
1129
1182
  t += "<tr>";
1130
1183
  for (let i = 0; i < r; i++) {
1131
1184
  let r = i < n.length ? n[i] : "", a = e.alignments[i], o = a ? ` align="${a}"` : "";
1132
- t += `<td${o}>${G(r)}</td>`;
1185
+ t += `<td${o}>${K(r)}</td>`;
1133
1186
  }
1134
1187
  t += "</tr>";
1135
1188
  }
@@ -1137,37 +1190,38 @@ function Ln(e) {
1137
1190
  }
1138
1191
  return t += "</table>", t;
1139
1192
  }
1140
- function Rn(e) {
1141
- return Y(q(e));
1193
+ function Hn(e) {
1194
+ return Rn(J(e));
1142
1195
  }
1143
1196
  //#endregion
1144
1197
  //#region src/api/parsers/markdown/parseMarkdown.ts
1145
- function zn(e) {
1146
- return Rn(e);
1198
+ function Un(e) {
1199
+ return Hn(e);
1147
1200
  }
1148
- function Bn(e, t) {
1149
- return H(zn(e), t);
1201
+ function Wn(e, t) {
1202
+ return U(Un(e), t);
1150
1203
  }
1151
1204
  //#endregion
1152
1205
  //#region src/editor/managers/ExportManager.ts
1153
- var Vn = class {
1206
+ var Gn = class {
1207
+ editor;
1154
1208
  constructor(e) {
1155
1209
  this.editor = e;
1156
1210
  }
1157
1211
  blocksToHTMLLossy(e = this.editor.document) {
1158
- return me(this.editor.pmSchema, this.editor).exportBlocks(e, {});
1212
+ return ge(this.editor.pmSchema, this.editor).exportBlocks(e, {});
1159
1213
  }
1160
1214
  blocksToFullHTML(e = this.editor.document) {
1161
- return Dt(this.editor.pmSchema, this.editor).serializeBlocks(e, {});
1215
+ return Tt(this.editor.pmSchema, this.editor).serializeBlocks(e, {});
1162
1216
  }
1163
1217
  tryParseHTMLToBlocks(e) {
1164
- return H(e, this.editor.pmSchema);
1218
+ return U(e, this.editor.pmSchema);
1165
1219
  }
1166
1220
  blocksToMarkdownLossy(e = this.editor.document) {
1167
- return De(e, this.editor.pmSchema, this.editor, {});
1221
+ return we(e, this.editor.pmSchema, this.editor, {});
1168
1222
  }
1169
1223
  tryParseMarkdownToBlocks(e) {
1170
- return Bn(e, this.editor.pmSchema);
1224
+ return Wn(e, this.editor.pmSchema);
1171
1225
  }
1172
1226
  pasteHTML(e, t = !1) {
1173
1227
  let n = e;
@@ -1181,564 +1235,216 @@ var Vn = class {
1181
1235
  return this.editor.prosemirrorView?.pasteText(e);
1182
1236
  }
1183
1237
  pasteMarkdown(e) {
1184
- let t = zn(e);
1238
+ let t = Un(e);
1185
1239
  return this.pasteHTML(t);
1186
1240
  }
1187
1241
  };
1188
1242
  //#endregion
1189
1243
  //#region src/api/blockManipulation/selections/textCursorPosition.ts
1190
- function Hn(e) {
1191
- let { bnBlock: t } = f(e), n = g(e.doc), r = e.doc.resolve(t.beforePos), i = r.nodeBefore, a = e.doc.resolve(t.afterPos).nodeAfter, o;
1192
- return r.depth > 1 && (o = r.node(), o.type.isInGroup("bnBlock") || (o = r.node(r.depth - 1))), {
1193
- block: m(t.node, n),
1194
- prevBlock: i === null ? void 0 : m(i, n),
1195
- nextBlock: a === null ? void 0 : m(a, n),
1196
- parentBlock: o === void 0 ? void 0 : m(o, n)
1244
+ function Kn(e) {
1245
+ let { bnBlock: t } = _(e), n = e.doc.resolve(t.beforePos), r = n.nodeBefore, i = e.doc.resolve(t.afterPos).nodeAfter, a;
1246
+ return n.depth > 1 && (a = n.node(), a.type.isInGroup("bnBlock") || (a = n.node(n.depth - 1))), {
1247
+ block: C(t.node, e.doc),
1248
+ prevBlock: r === null ? void 0 : C(r, e.doc),
1249
+ nextBlock: i === null ? void 0 : C(i, e.doc),
1250
+ parentBlock: a === void 0 ? void 0 : C(a, e.doc)
1197
1251
  };
1198
1252
  }
1199
- function Un(e, t, n = "start") {
1200
- let i = typeof t == "string" ? t : t.id, a = re(g(e.doc)), o = r(i, e.doc);
1201
- if (!o) throw Error(`Block with ID ${i} not found`);
1202
- let s = x(o), c = a.blockSchema[s.blockNoteType].content;
1203
- if (s.isBlockContainer) {
1204
- let t = s.blockContent;
1205
- if (c === "none") {
1206
- e.setSelection(M.create(e.doc, t.beforePos));
1253
+ function qn(t, r, a = "start") {
1254
+ let o = typeof r == "string" ? r : r.id, s = n(i(t.doc)), l = x(o, t.doc);
1255
+ if (!l) throw Error(`Block with ID ${o} not found`);
1256
+ let u = S(l), d = s.blockSchema[u.blockNoteType].content;
1257
+ if (u.isBlockContainer) {
1258
+ let e = u.blockContent;
1259
+ if (d === "none") {
1260
+ t.setSelection(A.create(t.doc, e.beforePos));
1207
1261
  return;
1208
1262
  }
1209
- if (c === "inline") n === "start" ? e.setSelection(P.create(e.doc, t.beforePos + 1)) : e.setSelection(P.create(e.doc, t.afterPos - 1));
1210
- else if (c === "table") n === "start" ? e.setSelection(P.create(e.doc, t.beforePos + 4)) : e.setSelection(P.create(e.doc, t.afterPos - 4));
1211
- else throw new w(c);
1212
- } else Un(e, (n === "start" ? s.childContainer.node.firstChild : s.childContainer.node.lastChild).attrs.id, n);
1263
+ if (d === "inline" || d === "plain") a === "start" ? t.setSelection(M.create(t.doc, e.beforePos + 1)) : t.setSelection(M.create(t.doc, e.afterPos - 1));
1264
+ else if (d === "table") a === "start" ? t.setSelection(M.create(t.doc, e.beforePos + 4)) : t.setSelection(M.create(t.doc, e.afterPos - 4));
1265
+ else throw new c(d);
1266
+ } else qn(t, e(a === "start" ? u.childContainer.node.firstChild : u.childContainer.node.lastChild, t.doc), a);
1213
1267
  }
1214
1268
  //#endregion
1215
- //#region src/extensions/tiptap-extensions/Link/helpers/tlds.ts
1216
- var Wn = "aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2";
1269
+ //#region src/api/clipboard/fromClipboard/acceptedMIMETypes.ts
1270
+ var Jn = [
1271
+ "vscode-editor-data",
1272
+ "blocknote/html",
1273
+ "text/markdown",
1274
+ "text/html",
1275
+ "text/plain",
1276
+ "Files"
1277
+ ];
1217
1278
  //#endregion
1218
- //#region src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts
1219
- function Gn(e) {
1220
- let t = [], n = [], r = 0;
1221
- for (; r < e.length;) {
1222
- let i = 0;
1223
- for (; r + i < e.length && e.charCodeAt(r + i) >= 48 && e.charCodeAt(r + i) <= 57;) i++;
1224
- if (i > 0) {
1225
- t.push(n.join(""));
1226
- let a = parseInt(e.substring(r, r + i), 10);
1227
- for (; a-- > 0;) n.pop();
1228
- r += i;
1229
- } else n.push(e[r]), r++;
1230
- }
1231
- return t;
1232
- }
1233
- var Kn = new Set(Gn(Wn)), qn = new Set(["localhost"]), Jn = /[.,;:!?"']+$/, Yn = /(?:https?|ftp|ftps):\/\/[^\s]+/g, Xn = /mailto:[^\s]+/g, Zn = /[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}/g, Qn = /(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(?::\d{1,5})?(?:[/?#][^\s]*)?/g;
1234
- function $n(e) {
1235
- let t = e, n = !0;
1236
- for (; n;) {
1237
- n = !1;
1238
- let e = t;
1239
- t = t.replace(Jn, ""), t !== e && (n = !0);
1240
- for (let [e, r] of [["(", ")"], ["[", "]"]]) for (; t.endsWith(r);) {
1241
- let i = er(t, e);
1242
- if (er(t, r) > i) t = t.slice(0, -1), n = !0;
1243
- else break;
1244
- }
1245
- }
1246
- return t;
1247
- }
1248
- function er(e, t) {
1249
- let n = 0;
1250
- for (let r = 0; r < e.length; r++) e[r] === t && n++;
1251
- return n;
1252
- }
1253
- function tr(e) {
1254
- let t = e.split(".");
1255
- return t[t.length - 1].toLowerCase();
1279
+ //#region src/api/clipboard/fromClipboard/handleFileInsertion.ts
1280
+ function Yn(e, t) {
1281
+ if (!e.startsWith(".") || !t.startsWith(".")) throw Error("The strings provided are not valid file extensions.");
1282
+ return e === t;
1256
1283
  }
1257
- function nr(e) {
1258
- let t = tr(e);
1259
- return Kn.has(t);
1284
+ function Xn(e, t) {
1285
+ let n = e.split("/"), r = t.split("/");
1286
+ if (n.length !== 2) throw Error(`The string ${e} is not a valid MIME type.`);
1287
+ if (r.length !== 2) throw Error(`The string ${t} is not a valid MIME type.`);
1288
+ return n[1] === "*" || r[1] === "*" ? n[0] === r[0] : (n[0] === "*" || r[0] === "*" || n[0] === r[0]) && n[1] === r[1];
1260
1289
  }
1261
- function rr(e, t, n) {
1262
- return t === "email" ? "mailto:" + e : /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(e) || /^mailto:/i.test(e) ? e : n + "://" + e;
1290
+ function Zn(e, t, n, r = "after") {
1291
+ let i;
1292
+ return i = Array.isArray(t.content) && t.content.length === 0 ? e.updateBlock(t, n).id : e.insertBlocks([n], t, r)[0].id, i;
1263
1293
  }
1264
- function ir(e, t) {
1265
- if (!e) return [];
1266
- let n = t?.defaultProtocol || "http", r = [];
1267
- for (let t of e.matchAll(Yn)) r.push({
1268
- type: "url",
1269
- value: t[0],
1270
- start: t.index,
1271
- end: t.index + t[0].length
1272
- });
1273
- for (let t of e.matchAll(Xn)) r.push({
1274
- type: "url",
1275
- value: t[0],
1276
- start: t.index,
1277
- end: t.index + t[0].length
1278
- });
1279
- for (let t of e.matchAll(Zn)) r.push({
1280
- type: "email",
1281
- value: t[0],
1282
- start: t.index,
1283
- end: t.index + t[0].length
1284
- });
1285
- for (let t of e.matchAll(Qn)) r.push({
1286
- type: "url",
1287
- value: t[0],
1288
- start: t.index,
1289
- end: t.index + t[0].length
1290
- });
1291
- r.sort((e, t) => e.start - t.start || t.end - e.end);
1292
- let i = [], a = -1;
1293
- for (let e of r) e.start >= a && (i.push(e), a = e.end);
1294
- let o = [];
1295
- for (let e of i) {
1296
- let t = $n(e.value);
1297
- if (!t) continue;
1298
- let r = e.start, i = r + t.length;
1299
- if (e.type === "url" && !/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t)) {
1300
- let e = new URL("http://" + t).hostname;
1301
- if (!nr(e)) continue;
1302
- }
1303
- if (e.type === "email") {
1304
- let e = t.split("@")[1];
1305
- if (!nr(e)) continue;
1294
+ async function Qn(t, n) {
1295
+ if (!n.uploadFile) {
1296
+ console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");
1297
+ return;
1298
+ }
1299
+ let r = "dataTransfer" in t ? t.dataTransfer : t.clipboardData;
1300
+ if (r === null) return;
1301
+ let i = null;
1302
+ for (let e of Jn) if (r.types.includes(e)) {
1303
+ i = e;
1304
+ break;
1305
+ }
1306
+ if (i !== "Files") return;
1307
+ let a = r.items;
1308
+ if (a) {
1309
+ t.preventDefault();
1310
+ for (let r = 0; r < a.length; r++) {
1311
+ let i = "file";
1312
+ for (let e of Object.values(n.schema.blockSpecs)) for (let t of e.implementation.meta?.fileBlockAccept || []) {
1313
+ let n = t.startsWith("."), o = a[r].getAsFile();
1314
+ if (o && (!n && o.type && Xn(a[r].type, t) || n && Yn("." + o.name.split(".").pop(), t))) {
1315
+ i = e.config.type;
1316
+ break;
1317
+ }
1318
+ }
1319
+ let o = a[r].getAsFile();
1320
+ if (o) {
1321
+ let r = {
1322
+ type: i,
1323
+ props: { name: o.name }
1324
+ }, a;
1325
+ if (t.type === "paste") {
1326
+ let e = n.getTextCursorPosition().block;
1327
+ a = Zn(n, e, r);
1328
+ } else if (t.type === "drop") {
1329
+ let i = {
1330
+ left: t.clientX,
1331
+ top: t.clientY
1332
+ }, o = n.prosemirrorView.posAtCoords(i);
1333
+ if (!o) return;
1334
+ a = n.transact((t) => {
1335
+ let a = e(l(t, o.pos).bnBlock.node, t.doc), s = (n.domElement?.querySelector(`[data-id="${a}"]`))?.getBoundingClientRect();
1336
+ return Zn(n, n.getBlock(a), r, s && (s.top + s.bottom) / 2 > i.top ? "before" : "after");
1337
+ });
1338
+ } else return;
1339
+ let s = await n.uploadFile(o, a), c = typeof s == "string" ? { props: { url: s } } : { ...s };
1340
+ n.updateBlock(a, c);
1341
+ }
1306
1342
  }
1307
- let a = rr(t, e.type, n);
1308
- o.push({
1309
- type: e.type,
1310
- value: t,
1311
- isLink: !0,
1312
- href: a,
1313
- start: r,
1314
- end: i
1315
- });
1316
1343
  }
1317
- return o;
1318
1344
  }
1319
- function ar(e, t = "http") {
1320
- if (!e) return [X(e, 0, 0)];
1321
- for (let [n, r] of [
1322
- ["(", ")"],
1323
- ["[", "]"],
1324
- ["{", "}"]
1325
- ]) if (e.startsWith(n) && e.endsWith(r) && e.length > 2) {
1326
- let i = e.slice(1, -1);
1327
- if (or(i)) return [
1328
- X(n, 0, 1),
1329
- sr(i, 1, 1 + i.length, t),
1330
- X(r, 1 + i.length, e.length)
1331
- ];
1345
+ //#endregion
1346
+ //#region src/api/clipboard/fromClipboard/fileDropExtension.ts
1347
+ var $n = (e) => D.create({
1348
+ name: "dropFile",
1349
+ addProseMirrorPlugins() {
1350
+ return [new j({ props: { handleDOMEvents: { drop(t, n) {
1351
+ if (!e.isEditable) return;
1352
+ let r = null;
1353
+ for (let e of Jn) if (n.dataTransfer.types.includes(e)) {
1354
+ r = e;
1355
+ break;
1356
+ }
1357
+ return r === null ? !0 : r === "Files" ? (Qn(n, e), !0) : !1;
1358
+ } } } })];
1332
1359
  }
1333
- if (e.endsWith(".") && e.length > 1) {
1334
- let n = e.slice(0, -1);
1335
- if (or(n)) return [sr(n, 0, n.length, t), X(".", n.length, e.length)];
1360
+ }), er = /(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/, tr = /(_|__|\*|\*\*|~~|==|\+\+)(?!\s)(?:[^\s](?:.{0,62}[^\s])?|\S)(?=\1)/, nr = /\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/, rr = /(?:\s|^)`(?!\s)(?:[^\s`](?:[^`]{0,46}[^\s`])?|[^\s`])`([^\w]|$)/, ir = /(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/, ar = /(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/, or = /\n{2} {0,3}-{2,48}\n{2}/, sr = /(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/, cr = /(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/, lr = /(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/, ur = /^\s*\|(.+\|)+\s*$/m, dr = /^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m, fr = /^\s*\|(.+\|)+\s*$/m, pr = (e) => er.test(e) || tr.test(e) || nr.test(e) || rr.test(e) || ir.test(e) || ar.test(e) || or.test(e) || sr.test(e) || cr.test(e) || lr.test(e) || ur.test(e) || dr.test(e) || fr.test(e);
1361
+ //#endregion
1362
+ //#region src/api/clipboard/fromClipboard/handleVSCodePaste.ts
1363
+ function mr(e, t) {
1364
+ let { schema: n } = t.state;
1365
+ if (!e.clipboardData) return !1;
1366
+ let r = e.clipboardData.getData("text/plain");
1367
+ if (!r || !n.nodes.codeBlock) return !1;
1368
+ let i = e.clipboardData.getData("vscode-editor-data"), a = (i ? JSON.parse(i) : void 0)?.mode;
1369
+ return a ? (t.pasteHTML(`<pre><code class="language-${a}">${r.replace(/\r\n?/g, "\n")}</code></pre>`), !0) : !1;
1370
+ }
1371
+ //#endregion
1372
+ //#region src/api/clipboard/fromClipboard/pasteExtension.ts
1373
+ function hr({ event: e, editor: t, prioritizeMarkdownOverHTML: n, plainTextAsMarkdown: r }) {
1374
+ if (t.transact((e) => e.selection.$from.parent.type.spec.code && e.selection.$to.parent.type.spec.code)) {
1375
+ let n = e.clipboardData?.getData("text/plain");
1376
+ if (n) return t.pasteText(n), !0;
1377
+ }
1378
+ let i;
1379
+ for (let t of Jn) if (e.clipboardData.types.includes(t)) {
1380
+ i = t;
1381
+ break;
1382
+ }
1383
+ if (!i) return !0;
1384
+ if (i === "vscode-editor-data") {
1385
+ if (mr(e, t.prosemirrorView)) return !0;
1386
+ i = "text/plain";
1387
+ }
1388
+ if (i === "Files") return Qn(e, t), !0;
1389
+ let a = e.clipboardData.getData(i);
1390
+ if (i === "blocknote/html") return t.pasteHTML(a, !0), !0;
1391
+ if (i === "text/markdown") return t.pasteMarkdown(a), !0;
1392
+ if (n) {
1393
+ let n = e.clipboardData.getData("text/plain");
1394
+ if (pr(n)) return t.pasteMarkdown(n), !0;
1336
1395
  }
1337
- return or(e) ? [sr(e, 0, e.length, t)] : [X(e, 0, e.length)];
1396
+ return i === "text/html" ? (t.pasteHTML(a), !0) : r ? (t.pasteMarkdown(a), !0) : (t.pasteText(a), !0);
1338
1397
  }
1339
- function or(e) {
1340
- if (/^(?:https?|ftp|ftps):\/\/[^\s]+$/.test(e) || /^mailto:[^\s]+$/.test(e) || qn.has(e.toLowerCase())) return !0;
1341
- let t = e.match(/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+([a-zA-Z]{2,})(?::\d{1,5})?(?:[/?#][^\s]*)?$/);
1342
- if (t) {
1343
- let e = t[1].toLowerCase();
1344
- if (Kn.has(e)) return !0;
1398
+ var gr = (e, t) => D.create({
1399
+ name: "pasteFromClipboard",
1400
+ addProseMirrorPlugins() {
1401
+ return [new j({ props: { handleDOMEvents: { paste(n, r) {
1402
+ if (r.preventDefault(), e.isEditable) return t({
1403
+ event: r,
1404
+ editor: e,
1405
+ defaultPasteHandler: ({ prioritizeMarkdownOverHTML: t = !0, plainTextAsMarkdown: n = !0 } = {}) => hr({
1406
+ event: r,
1407
+ editor: e,
1408
+ prioritizeMarkdownOverHTML: t,
1409
+ plainTextAsMarkdown: n
1410
+ })
1411
+ });
1412
+ } } } })];
1345
1413
  }
1346
- return !1;
1414
+ });
1415
+ //#endregion
1416
+ //#region src/api/clipboard/toClipboard/copyExtension.ts
1417
+ function _r(e, t, n) {
1418
+ let r = !1, i = e.state.selection instanceof F;
1419
+ if (!i) {
1420
+ let n = e.state.doc.slice(e.state.selection.from, e.state.selection.to, !1).content, i = [];
1421
+ for (let e = 0; e < n.childCount; e++) i.push(n.child(e));
1422
+ r = i.find((e) => e.type.isInGroup("bnBlock") || e.type.name === "blockGroup" || e.type.spec.group === "blockContent") === void 0, r && (t = n);
1423
+ }
1424
+ let a, o = ge(e.state.schema, n);
1425
+ if (i) {
1426
+ t.firstChild?.type.name === "table" && (t = t.firstChild.content);
1427
+ let e = ee(t, n.schema.inlineContentSchema, n.schema.styleSchema);
1428
+ a = `<table>${o.exportInlineContent(e, {})}</table>`;
1429
+ } else if (r) {
1430
+ let e = ae(t, n.schema.inlineContentSchema, n.schema.styleSchema);
1431
+ a = o.exportInlineContent(e, {});
1432
+ } else {
1433
+ let e = Te(t);
1434
+ a = o.exportBlocks(e, {});
1435
+ }
1436
+ return a;
1347
1437
  }
1348
- function sr(e, t, n, r) {
1349
- let i = e.includes("@") && !e.includes("://") && !e.startsWith("mailto:") ? "email" : "url";
1438
+ function vr(e, t) {
1439
+ "node" in e.state.selection && e.state.selection.node.type.spec.group === "blockContent" && t.transact((t) => t.setSelection(new A(t.doc.resolve(e.state.selection.from - 1))));
1440
+ let n = e.serializeForClipboard(e.state.selection.content()).dom.innerHTML, r = e.state.selection.content().content, i = _r(e, r, t), { $from: a, $to: o } = e.state.selection, s = a.parent.type.name, c = t.blockImplementations[s];
1350
1441
  return {
1351
- type: i,
1352
- value: e,
1353
- isLink: !0,
1354
- href: rr(e, i, r),
1355
- start: t,
1356
- end: n
1442
+ clipboardHTML: n,
1443
+ externalHTML: i,
1444
+ markdown: a.sameParent(o) && c?.implementation.meta?.code === !0 ? e.state.doc.textBetween(a.pos, o.pos) : be(i)
1357
1445
  };
1358
1446
  }
1359
- function X(e, t, n) {
1360
- return {
1361
- type: "text",
1362
- value: e,
1363
- isLink: !1,
1364
- href: e,
1365
- start: t,
1366
- end: n
1367
- };
1368
- }
1369
- //#endregion
1370
- //#region src/extensions/tiptap-extensions/Link/helpers/whitespace.ts
1371
- var cr = "[\0- \xA0 ᠎ -\u2029  ]", lr = new RegExp(cr), ur = RegExp(`${cr}$`), dr = new RegExp(cr, "g");
1372
- //#endregion
1373
- //#region src/extensions/tiptap-extensions/Link/helpers/autolink.ts
1374
- function fr(e) {
1375
- return e.length === 1 ? e[0].isLink : e.length === 3 && e[1].isLink ? ["()", "[]"].includes(e[0].value + e[2].value) : !1;
1376
- }
1377
- function pr(e) {
1378
- return new ot({
1379
- key: new st("autolink"),
1380
- appendTransaction: (t, n, r) => {
1381
- let i = t.some((e) => e.docChanged) && !n.doc.eq(r.doc), a = t.some((e) => e.getMeta("preventAutolink"));
1382
- if (!i || a) return;
1383
- let { tr: o } = r;
1384
- if (Ye(We(n.doc, [...t])).forEach(({ newRange: t }) => {
1385
- let n = Ke(r.doc, t, (e) => e.isTextblock), i, a;
1386
- if (n.length > 1) i = n[0], a = r.doc.textBetween(i.pos, i.pos + i.node.nodeSize, void 0, " ");
1387
- else if (n.length) {
1388
- let e = r.doc.textBetween(t.from, t.to, " ", " ");
1389
- if (!ur.test(e)) return;
1390
- i = n[0], a = r.doc.textBetween(i.pos, t.to, void 0, " ");
1391
- }
1392
- if (i && a) {
1393
- let t = a.split(lr).filter(Boolean);
1394
- if (t.length <= 0) return;
1395
- let n = t[t.length - 1], s = i.pos + a.lastIndexOf(n);
1396
- if (!n) return;
1397
- let c = ar(n, e.defaultProtocol);
1398
- if (!fr(c)) return;
1399
- c.filter((e) => e.isLink).map((e) => ({
1400
- ...e,
1401
- from: s + e.start + 1,
1402
- to: s + e.end + 1
1403
- })).filter((e) => r.schema.marks.code ? !r.doc.rangeHasMark(e.from, e.to, r.schema.marks.code) : !0).filter((t) => e.validate(t.value)).filter((t) => e.shouldAutoLink(t.value)).forEach((t) => {
1404
- Ze(t.from, t.to, r.doc).some((t) => t.mark.type === e.type) || o.addMark(t.from, t.to, e.type.create({ href: t.href }));
1405
- });
1406
- }
1407
- }), o.steps.length) return o;
1408
- }
1409
- });
1410
- }
1411
- //#endregion
1412
- //#region src/extensions/tiptap-extensions/Link/helpers/clickHandler.ts
1413
- function mr(e) {
1414
- return new ot({
1415
- key: new st("handleClickLink"),
1416
- props: { handleClick: (t, n, r) => {
1417
- if (r.button !== 0 || !t.editable) return !1;
1418
- let i = null;
1419
- if (r.target instanceof HTMLAnchorElement && r.target.getAttribute("data-inline-content-type") === "link") i = r.target;
1420
- else {
1421
- let t = r.target;
1422
- if (!t) return !1;
1423
- let n = e.tiptapEditor.view.dom;
1424
- i = t.closest("a[data-inline-content-type=\"link\"]"), i && !n.contains(i) && (i = null);
1425
- }
1426
- if (!i) return !1;
1427
- if (e.onClick) {
1428
- if (!e.editor) throw Error("BlockNoteEditor not found in Link click handler");
1429
- return e.onClick(r, e.editor) ?? !0;
1430
- }
1431
- let a = Je(t.state, e.type.name), o = i.href ?? a.href, s = i.target ?? a.target;
1432
- return o ? (window.open(o, s), !0) : !1;
1433
- } }
1434
- });
1435
- }
1436
- //#endregion
1437
- //#region src/extensions/tiptap-extensions/Link/helpers/pasteHandler.ts
1438
- function hr(e) {
1439
- return new ot({
1440
- key: new st("handlePasteLink"),
1441
- props: { handlePaste: (t, n, r) => {
1442
- let { shouldAutoLink: i, isValidLink: a } = e, { state: o } = t, { selection: s } = o, { empty: c } = s;
1443
- if (c) return !1;
1444
- let l = "";
1445
- r.content.forEach((e) => {
1446
- l += e.textContent;
1447
- });
1448
- let u = ir(l, { defaultProtocol: e.defaultProtocol }).find((e) => e.isLink && e.value === l);
1449
- return !l || !u || !a(u.value) || i !== void 0 && !i(u.value) ? !1 : e.editor.commands.setMark(e.type, { href: u.href });
1450
- } }
1451
- });
1452
- }
1453
- //#endregion
1454
- //#region src/extensions/tiptap-extensions/Link/link.ts
1455
- var Z = "https", gr = /^(?:(?:http|https|ftp|ftps|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z0-9+.\-]+(?:[^a-z+.\-:]|$))/i;
1456
- function _r(e) {
1457
- if (!e) return !0;
1458
- let t = e.replace(dr, "");
1459
- return gr.test(t);
1460
- }
1461
- function vr(e) {
1462
- let t = /^[a-z][a-z0-9+.-]*:\/\//i.test(e), n = /^[a-z][a-z0-9+.-]*:/i.test(e);
1463
- if (t || n && !e.includes("@")) return !0;
1464
- let r = (e.includes("@") ? e.split("@").pop() : e).split(/[/?#:]/)[0];
1465
- return !(/^\d{1,3}(\.\d{1,3}){3}$/.test(r) || !/\./.test(r));
1466
- }
1467
- var yr = k.create({
1468
- name: "link",
1469
- keepOnSplit: !1,
1470
- exitable: !0,
1471
- inclusive: !1,
1472
- addOptions() {
1473
- return {
1474
- HTMLAttributes: {
1475
- target: "_blank",
1476
- rel: "noopener noreferrer nofollow",
1477
- className: "bn-inline-content-section",
1478
- "data-inline-content-type": "link"
1479
- },
1480
- editor: void 0,
1481
- onClick: void 0,
1482
- isValidLink: _r
1483
- };
1484
- },
1485
- addAttributes() {
1486
- return { href: {
1487
- default: null,
1488
- parseHTML(e) {
1489
- return e.getAttribute("href");
1490
- }
1491
- } };
1492
- },
1493
- parseHTML() {
1494
- let e = this.options.isValidLink;
1495
- return [{
1496
- tag: "a[href]",
1497
- getAttrs: (t) => {
1498
- let n = t.getAttribute("href");
1499
- return !n || !e(n) ? !1 : null;
1500
- }
1501
- }];
1502
- },
1503
- renderHTML({ HTMLAttributes: e }) {
1504
- return this.options.isValidLink(e.href) ? [
1505
- "a",
1506
- tt(e, this.options.HTMLAttributes),
1507
- 0
1508
- ] : [
1509
- "a",
1510
- tt({
1511
- ...e,
1512
- href: ""
1513
- }, this.options.HTMLAttributes),
1514
- 0
1515
- ];
1516
- },
1517
- addPasteRules() {
1518
- let e = this.options.isValidLink;
1519
- return [et({
1520
- find: (t) => {
1521
- let n = [];
1522
- if (t) {
1523
- let r = ir(t, { defaultProtocol: Z }).filter((t) => t.isLink && e(t.value));
1524
- for (let e of r) vr(e.value) && n.push({
1525
- text: e.value,
1526
- data: { href: e.href },
1527
- index: e.start
1528
- });
1529
- }
1530
- return n;
1531
- },
1532
- type: this.type,
1533
- getAttributes: (e) => ({ href: e.data?.href })
1534
- })];
1535
- },
1536
- addProseMirrorPlugins() {
1537
- let e = [];
1538
- return e.push(pr({
1539
- type: this.type,
1540
- defaultProtocol: Z,
1541
- validate: this.options.isValidLink,
1542
- shouldAutoLink: vr
1543
- })), e.push(mr({
1544
- type: this.type,
1545
- tiptapEditor: this.editor,
1546
- editor: this.options.editor,
1547
- onClick: this.options.onClick
1548
- })), e.push(hr({
1549
- editor: this.editor,
1550
- defaultProtocol: Z,
1551
- type: this.type,
1552
- shouldAutoLink: vr,
1553
- isValidLink: this.options.isValidLink
1554
- })), e;
1555
- }
1556
- }), br = Me(({ editor: e, options: t }) => ({
1557
- key: "link",
1558
- tiptapExtensions: [yr.configure({
1559
- HTMLAttributes: t.HTMLAttributes ?? {},
1560
- editor: e,
1561
- onClick: t.onClick,
1562
- ...t.isValidLink ? { isValidLink: t.isValidLink } : {}
1563
- })]
1564
- })), xr = [
1565
- "vscode-editor-data",
1566
- "blocknote/html",
1567
- "text/markdown",
1568
- "text/html",
1569
- "text/plain",
1570
- "Files"
1571
- ];
1572
- //#endregion
1573
- //#region src/api/clipboard/fromClipboard/handleFileInsertion.ts
1574
- function Sr(e, t) {
1575
- if (!e.startsWith(".") || !t.startsWith(".")) throw Error("The strings provided are not valid file extensions.");
1576
- return e === t;
1577
- }
1578
- function Cr(e, t) {
1579
- let n = e.split("/"), r = t.split("/");
1580
- if (n.length !== 2) throw Error(`The string ${e} is not a valid MIME type.`);
1581
- if (r.length !== 2) throw Error(`The string ${t} is not a valid MIME type.`);
1582
- return n[1] === "*" || r[1] === "*" ? n[0] === r[0] : (n[0] === "*" || r[0] === "*" || n[0] === r[0]) && n[1] === r[1];
1583
- }
1584
- function wr(e, t, n, r = "after") {
1585
- let i;
1586
- return i = Array.isArray(t.content) && t.content.length === 0 ? e.updateBlock(t, n).id : e.insertBlocks([n], t, r)[0].id, i;
1587
- }
1588
- async function Tr(e, t) {
1589
- if (!t.uploadFile) {
1590
- console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");
1591
- return;
1592
- }
1593
- let n = "dataTransfer" in e ? e.dataTransfer : e.clipboardData;
1594
- if (n === null) return;
1595
- let r = null;
1596
- for (let e of xr) if (n.types.includes(e)) {
1597
- r = e;
1598
- break;
1599
- }
1600
- if (r !== "Files") return;
1601
- let i = n.items;
1602
- if (i) {
1603
- e.preventDefault();
1604
- for (let n = 0; n < i.length; n++) {
1605
- let r = "file";
1606
- for (let e of Object.values(t.schema.blockSpecs)) for (let t of e.implementation.meta?.fileBlockAccept || []) {
1607
- let a = t.startsWith("."), o = i[n].getAsFile();
1608
- if (o && (!a && o.type && Cr(i[n].type, t) || a && Sr("." + o.name.split(".").pop(), t))) {
1609
- r = e.config.type;
1610
- break;
1611
- }
1612
- }
1613
- let a = i[n].getAsFile();
1614
- if (a) {
1615
- let n = {
1616
- type: r,
1617
- props: { name: a.name }
1618
- }, i;
1619
- if (e.type === "paste") {
1620
- let e = t.getTextCursorPosition().block;
1621
- i = wr(t, e, n);
1622
- } else if (e.type === "drop") {
1623
- let r = {
1624
- left: e.clientX,
1625
- top: e.clientY
1626
- }, a = t.prosemirrorView.posAtCoords(r);
1627
- if (!a) return;
1628
- i = t.transact((e) => {
1629
- let i = C(e.doc, a.pos), o = (t.domElement?.querySelector(`[data-id="${i.node.attrs.id}"]`))?.getBoundingClientRect();
1630
- return wr(t, t.getBlock(i.node.attrs.id), n, o && (o.top + o.bottom) / 2 > r.top ? "before" : "after");
1631
- });
1632
- } else return;
1633
- let o = await t.uploadFile(a, i), s = typeof o == "string" ? { props: { url: o } } : { ...o };
1634
- t.updateBlock(i, s);
1635
- }
1636
- }
1637
- }
1638
- }
1639
- //#endregion
1640
- //#region src/api/clipboard/fromClipboard/fileDropExtension.ts
1641
- var Er = (e) => O.create({
1642
- name: "dropFile",
1643
- addProseMirrorPlugins() {
1644
- return [new N({ props: { handleDOMEvents: { drop(t, n) {
1645
- if (!e.isEditable) return;
1646
- let r = null;
1647
- for (let e of xr) if (n.dataTransfer.types.includes(e)) {
1648
- r = e;
1649
- break;
1650
- }
1651
- return r === null ? !0 : r === "Files" ? (Tr(n, e), !0) : !1;
1652
- } } } })];
1653
- }
1654
- }), Dr = /(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/, Or = /(_|__|\*|\*\*|~~|==|\+\+)(?!\s)(?:[^\s](?:.{0,62}[^\s])?|\S)(?=\1)/, kr = /\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/, Ar = /(?:\s|^)`(?!\s)(?:[^\s`](?:[^`]{0,46}[^\s`])?|[^\s`])`([^\w]|$)/, jr = /(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/, Mr = /(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/, Nr = /\n{2} {0,3}-{2,48}\n{2}/, Pr = /(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/, Fr = /(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/, Ir = /(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/, Lr = /^\s*\|(.+\|)+\s*$/m, Rr = /^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m, zr = /^\s*\|(.+\|)+\s*$/m, Br = (e) => Dr.test(e) || Or.test(e) || kr.test(e) || Ar.test(e) || jr.test(e) || Mr.test(e) || Nr.test(e) || Pr.test(e) || Fr.test(e) || Ir.test(e) || Lr.test(e) || Rr.test(e) || zr.test(e);
1655
- //#endregion
1656
- //#region src/api/clipboard/fromClipboard/handleVSCodePaste.ts
1657
- function Vr(e, t) {
1658
- let { schema: n } = t.state;
1659
- if (!e.clipboardData) return !1;
1660
- let r = e.clipboardData.getData("text/plain");
1661
- if (!r || !n.nodes.codeBlock) return !1;
1662
- let i = e.clipboardData.getData("vscode-editor-data"), a = (i ? JSON.parse(i) : void 0)?.mode;
1663
- return a ? (t.pasteHTML(`<pre><code class="language-${a}">${r.replace(/\r\n?/g, "\n")}</code></pre>`), !0) : !1;
1664
- }
1665
- //#endregion
1666
- //#region src/api/clipboard/fromClipboard/pasteExtension.ts
1667
- function Hr({ event: e, editor: t, prioritizeMarkdownOverHTML: n, plainTextAsMarkdown: r }) {
1668
- if (t.transact((e) => e.selection.$from.parent.type.spec.code && e.selection.$to.parent.type.spec.code)) {
1669
- let n = e.clipboardData?.getData("text/plain");
1670
- if (n) return t.pasteText(n), !0;
1671
- }
1672
- let i;
1673
- for (let t of xr) if (e.clipboardData.types.includes(t)) {
1674
- i = t;
1675
- break;
1676
- }
1677
- if (!i) return !0;
1678
- if (i === "vscode-editor-data") {
1679
- if (Vr(e, t.prosemirrorView)) return !0;
1680
- i = "text/plain";
1681
- }
1682
- if (i === "Files") return Tr(e, t), !0;
1683
- let a = e.clipboardData.getData(i);
1684
- if (i === "blocknote/html") return t.pasteHTML(a, !0), !0;
1685
- if (i === "text/markdown") return t.pasteMarkdown(a), !0;
1686
- if (n) {
1687
- let n = e.clipboardData.getData("text/plain");
1688
- if (Br(n)) return t.pasteMarkdown(n), !0;
1689
- }
1690
- return i === "text/html" ? (t.pasteHTML(a), !0) : r ? (t.pasteMarkdown(a), !0) : (t.pasteText(a), !0);
1691
- }
1692
- var Ur = (e, t) => O.create({
1693
- name: "pasteFromClipboard",
1694
- addProseMirrorPlugins() {
1695
- return [new N({ props: { handleDOMEvents: { paste(n, r) {
1696
- if (r.preventDefault(), e.isEditable) return t({
1697
- event: r,
1698
- editor: e,
1699
- defaultPasteHandler: ({ prioritizeMarkdownOverHTML: t = !0, plainTextAsMarkdown: n = !0 } = {}) => Hr({
1700
- event: r,
1701
- editor: e,
1702
- prioritizeMarkdownOverHTML: t,
1703
- plainTextAsMarkdown: n
1704
- })
1705
- });
1706
- } } } })];
1707
- }
1708
- });
1709
- //#endregion
1710
- //#region src/api/clipboard/toClipboard/copyExtension.ts
1711
- function Wr(e, t, n) {
1712
- let r = !1, i = e.state.selection instanceof it;
1713
- if (!i) {
1714
- let n = e.state.doc.slice(e.state.selection.from, e.state.selection.to, !1).content, i = [];
1715
- for (let e = 0; e < n.childCount; e++) i.push(n.child(e));
1716
- r = i.find((e) => e.type.isInGroup("bnBlock") || e.type.name === "blockGroup" || e.type.spec.group === "blockContent") === void 0, r && (t = n);
1717
- }
1718
- let a, o = me(e.state.schema, n);
1719
- if (i) {
1720
- t.firstChild?.type.name === "table" && (t = t.firstChild.content);
1721
- let e = oe(t, n.schema.inlineContentSchema, n.schema.styleSchema);
1722
- a = `<table>${o.exportInlineContent(e, {})}</table>`;
1723
- } else if (r) {
1724
- let e = ae(t, n.schema.inlineContentSchema, n.schema.styleSchema);
1725
- a = o.exportInlineContent(e, {});
1726
- } else {
1727
- let e = xe(t);
1728
- a = o.exportBlocks(e, {});
1729
- }
1730
- return a;
1731
- }
1732
- function Gr(e, t) {
1733
- "node" in e.state.selection && e.state.selection.node.type.spec.group === "blockContent" && t.transact((t) => t.setSelection(new M(t.doc.resolve(e.state.selection.from - 1))));
1734
- let n = e.serializeForClipboard(e.state.selection.content()).dom.innerHTML, r = e.state.selection.content().content, i = Wr(e, r, t), { $from: a, $to: o } = e.state.selection, s = a.parent.type.name, c = t.blockImplementations[s];
1735
- return {
1736
- clipboardHTML: n,
1737
- externalHTML: i,
1738
- markdown: a.sameParent(o) && c?.implementation.meta?.code === !0 ? e.state.doc.textBetween(a.pos, o.pos) : ye(i)
1739
- };
1740
- }
1741
- var Kr = (e) => {
1447
+ var yr = (e) => {
1742
1448
  if (e.state.selection.empty) return !0;
1743
1449
  let t = window.getSelection();
1744
1450
  if (t && !t.isCollapsed) {
@@ -1749,37 +1455,37 @@ var Kr = (e) => {
1749
1455
  }
1750
1456
  }
1751
1457
  return !1;
1752
- }, qr = (e, t, n) => {
1458
+ }, br = (e, t, n) => {
1753
1459
  n.preventDefault(), n.clipboardData.clearData();
1754
- let { clipboardHTML: r, externalHTML: i, markdown: a } = Gr(t, e);
1460
+ let { clipboardHTML: r, externalHTML: i, markdown: a } = vr(t, e);
1755
1461
  n.clipboardData.setData("blocknote/html", r), n.clipboardData.setData("text/html", i), n.clipboardData.setData("text/plain", a);
1756
- }, Jr = (e) => O.create({
1462
+ }, xr = (e) => D.create({
1757
1463
  name: "copyToClipboard",
1758
1464
  addProseMirrorPlugins() {
1759
- return [new N({ props: { handleDOMEvents: {
1465
+ return [new j({ props: { handleDOMEvents: {
1760
1466
  copy(t, n) {
1761
- return Kr(t) || qr(e, t, n), !0;
1467
+ return yr(t) || br(e, t, n), !0;
1762
1468
  },
1763
1469
  cut(t, n) {
1764
- return Kr(t) ? !0 : (qr(e, t, n), t.editable && t.dispatch(t.state.tr.deleteSelection()), !0);
1470
+ return yr(t) ? !0 : (br(e, t, n), t.editable && t.dispatch(t.state.tr.deleteSelection()), !0);
1765
1471
  },
1766
1472
  dragstart(t, n) {
1767
1473
  if (!("node" in t.state.selection) || t.state.selection.node.type.spec.group !== "blockContent") return;
1768
- e.transact((e) => e.setSelection(new M(e.doc.resolve(t.state.selection.from - 1)))), n.preventDefault(), n.dataTransfer.clearData();
1769
- let { clipboardHTML: r, externalHTML: i, markdown: a } = Gr(t, e);
1474
+ e.transact((e) => e.setSelection(new A(e.doc.resolve(t.state.selection.from - 1)))), n.preventDefault(), n.dataTransfer.clearData();
1475
+ let { clipboardHTML: r, externalHTML: i, markdown: a } = vr(t, e);
1770
1476
  return n.dataTransfer.setData("blocknote/html", r), n.dataTransfer.setData("text/html", i), n.dataTransfer.setData("text/plain", a), !0;
1771
1477
  }
1772
1478
  } } })];
1773
1479
  }
1774
- }), Yr = O.create({
1480
+ }), Sr = D.create({
1775
1481
  name: "blockBackgroundColor",
1776
1482
  addGlobalAttributes() {
1777
1483
  return [{
1778
1484
  types: ["tableCell", "tableHeader"],
1779
- attributes: { backgroundColor: p() }
1485
+ attributes: { backgroundColor: pe() }
1780
1486
  }];
1781
1487
  }
1782
- }), Xr = A.create({
1488
+ }), Cr = O.create({
1783
1489
  name: "hardBreak",
1784
1490
  inline: !0,
1785
1491
  group: "inline",
@@ -1790,33 +1496,33 @@ var Kr = (e) => {
1790
1496
  return [{ tag: "br" }];
1791
1497
  },
1792
1498
  renderHTML({ HTMLAttributes: e }) {
1793
- return ["br", tt(this.options.HTMLAttributes, e)];
1499
+ return ["br", $e(this.options.HTMLAttributes, e)];
1794
1500
  },
1795
1501
  renderText() {
1796
1502
  return "\n";
1797
1503
  }
1798
- }), Zr = (e, t) => {
1504
+ }), wr = (e, t) => {
1799
1505
  let n = e.resolve(t), r = n.depth - 1;
1800
1506
  if (r < 1) return;
1801
1507
  let i = n.before(r), a = e.resolve(i).nodeAfter;
1802
- if (a) return a.type.spec.group?.includes("bnBlock") ? v(e.resolve(i)) : Zr(e, i);
1803
- }, Q = (e, t) => {
1508
+ if (a) return a.type.spec.group?.includes("bnBlock") ? v(e.resolve(i)) : wr(e, i);
1509
+ }, X = (e, t) => {
1804
1510
  let n = e.resolve(t), r = n.index();
1805
1511
  if (r === 0) return;
1806
1512
  let i = n.posAtIndex(r - 1);
1807
1513
  return v(e.resolve(i));
1808
- }, $ = (e, t) => {
1514
+ }, Z = (e, t) => {
1809
1515
  let n = e.resolve(t), r = n.index();
1810
1516
  if (r === n.node().childCount - 1) return;
1811
1517
  let i = n.posAtIndex(r + 1);
1812
1518
  return v(e.resolve(i));
1813
- }, Qr = (e, t) => {
1519
+ }, Tr = (e, t) => {
1814
1520
  for (; t.childContainer;) {
1815
1521
  let n = t.childContainer.node, r = e.resolve(t.childContainer.beforePos + 1).posAtIndex(n.childCount - 1);
1816
1522
  t = v(e.resolve(r));
1817
1523
  }
1818
1524
  return t;
1819
- }, $r = (e, t) => e.isBlockContainer && e.blockContent.node.type.spec.content === "inline*" && e.blockContent.node.childCount > 0 && t.isBlockContainer && t.blockContent.node.type.spec.content === "inline*", ei = (e, t, n, r) => {
1525
+ }, Er = (e, t) => e.isBlockContainer && e.blockContent.node.type.spec.content === "inline*" && e.blockContent.node.childCount > 0 && t.isBlockContainer && t.blockContent.node.type.spec.content === "inline*", Dr = (e, t, n, r) => {
1820
1526
  if (!r.isBlockContainer) throw Error(`Attempted to merge block at position ${r.bnBlock.beforePos} into previous block at position ${n.bnBlock.beforePos}, but next block is not a block container`);
1821
1527
  if (r.childContainer) {
1822
1528
  let n = e.doc.resolve(r.childContainer.beforePos + 1), i = e.doc.resolve(r.childContainer.afterPos - 1), a = n.blockRange(i);
@@ -1830,12 +1536,12 @@ var Kr = (e) => {
1830
1536
  t(e.tr.delete(n.blockContent.afterPos - 1, r.blockContent.beforePos + 1));
1831
1537
  }
1832
1538
  return !0;
1833
- }, ti = (e) => ({ state: t, dispatch: n }) => {
1834
- let r = v(t.doc.resolve(e)), i = Q(t.doc, r.bnBlock.beforePos);
1539
+ }, Or = (e) => ({ state: t, dispatch: n }) => {
1540
+ let r = v(t.doc.resolve(e)), i = X(t.doc, r.bnBlock.beforePos);
1835
1541
  if (!i) return !1;
1836
- let a = Qr(t.doc, i);
1837
- return $r(a, r) ? ei(t, n, a, r) : !1;
1838
- }, ni = O.create({
1542
+ let a = Tr(t.doc, i);
1543
+ return Er(a, r) ? Dr(t, n, a, r) : !1;
1544
+ }, kr = D.create({
1839
1545
  priority: 50,
1840
1546
  addKeyboardShortcuts() {
1841
1547
  let e = () => this.editor.commands.first(({ chain: e, commands: t }) => [
@@ -1844,8 +1550,8 @@ var Kr = (e) => {
1844
1550
  () => t.command(({ state: e }) => {
1845
1551
  let n = _(e);
1846
1552
  if (!n.isBlockContainer) return !1;
1847
- let r = e.selection.from === n.blockContent.beforePos + 1, i = n.blockContent.node.type.name === "paragraph";
1848
- return r && !i ? t.command(c(n.bnBlock.beforePos, {
1553
+ let i = e.selection.from === n.blockContent.beforePos + 1, a = n.blockContent.node.type.name === "paragraph";
1554
+ return i && !a ? t.command(r(n.bnBlock.beforePos, {
1849
1555
  type: "paragraph",
1850
1556
  props: {}
1851
1557
  })) : !1;
@@ -1854,24 +1560,24 @@ var Kr = (e) => {
1854
1560
  let n = _(e);
1855
1561
  if (!n.isBlockContainer) return !1;
1856
1562
  let { blockContent: r } = n;
1857
- return e.selection.from === r.beforePos + 1 ? V(t, t.doc.type.schema.nodes.blockContainer, t.doc.type.schema.nodes.blockGroup) : !1;
1563
+ return e.selection.from === r.beforePos + 1 ? H(t, t.doc.type.schema.nodes.blockContainer, t.doc.type.schema.nodes.blockGroup) : !1;
1858
1564
  }),
1859
1565
  () => t.command(({ state: t }) => {
1860
1566
  let n = _(t);
1861
1567
  if (!n.isBlockContainer) return !1;
1862
- let { bnBlock: r, blockContent: i } = n, a = Q(t.doc, n.bnBlock.beforePos);
1568
+ let { bnBlock: r, blockContent: i } = n, a = X(t.doc, n.bnBlock.beforePos);
1863
1569
  if (!a || !a.isBlockContainer || a.blockContent.node.type.spec.content !== "inline*") return !1;
1864
1570
  let o = t.selection.from === i.beforePos + 1, s = t.selection.empty, c = r.beforePos;
1865
- return o && s ? e().command(ti(c)).scrollIntoView().run() : !1;
1571
+ return o && s ? e().command(Or(c)).scrollIntoView().run() : !1;
1866
1572
  }),
1867
1573
  () => t.command(({ state: e, tr: t, dispatch: n }) => {
1868
1574
  let r = _(e);
1869
1575
  if (!r.isBlockContainer || e.selection.from !== r.blockContent.beforePos + 1) return !1;
1870
- let i = Q(e.doc, r.bnBlock.beforePos);
1576
+ let i = X(e.doc, r.bnBlock.beforePos);
1871
1577
  if (!i || i.isBlockContainer) return !1;
1872
1578
  if (n) {
1873
1579
  let e = i.bnBlock.afterPos - 1, n = t.doc.resolve(e - 1);
1874
- return t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), t.insert(n.pos, r.bnBlock.node), t.setSelection(P.near(t.doc.resolve(n.pos + 1))), !0;
1580
+ return t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), t.insert(n.pos, r.bnBlock.node), t.setSelection(M.near(t.doc.resolve(n.pos + 1))), !0;
1875
1581
  }
1876
1582
  return !1;
1877
1583
  }),
@@ -1881,15 +1587,15 @@ var Kr = (e) => {
1881
1587
  let i = t.doc.resolve(r.bnBlock.beforePos);
1882
1588
  if (i.nodeBefore || i.node().type.name !== "column") return !1;
1883
1589
  let a = t.doc.resolve(r.bnBlock.beforePos), o = t.doc.resolve(a.before()), s = o.before();
1884
- return n && (t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), R(t, s), o.pos === s + 1 ? (t.insert(s, r.bnBlock.node), t.setSelection(P.near(t.doc.resolve(s)))) : (t.insert(o.pos - 1, r.bnBlock.node), t.setSelection(P.near(t.doc.resolve(o.pos))))), !0;
1590
+ return n && (t.delete(r.bnBlock.beforePos, r.bnBlock.afterPos), L(t, s), o.pos === s + 1 ? (t.insert(s, r.bnBlock.node), t.setSelection(M.near(t.doc.resolve(s)))) : (t.insert(o.pos - 1, r.bnBlock.node), t.setSelection(M.near(t.doc.resolve(o.pos))))), !0;
1885
1591
  }),
1886
1592
  () => t.command(({ state: t }) => {
1887
1593
  let n = _(t);
1888
1594
  if (!n.isBlockContainer) return !1;
1889
1595
  if (n.blockContent.node.childCount === 0 && n.blockContent.node.type.spec.content === "inline*") {
1890
- let r = Q(t.doc, n.bnBlock.beforePos);
1596
+ let r = X(t.doc, n.bnBlock.beforePos);
1891
1597
  if (!r) return !1;
1892
- let i = Qr(t.doc, r);
1598
+ let i = Tr(t.doc, r);
1893
1599
  if (!i.isBlockContainer || !i || !i.isBlockContainer) return !1;
1894
1600
  let a = e();
1895
1601
  if (n.childContainer && a.insertContentAt(n.bnBlock.afterPos, n.childContainer?.node.content), i.blockContent.node.type.spec.content === "tableRow+") {
@@ -1910,9 +1616,9 @@ var Kr = (e) => {
1910
1616
  () => t.command(({ state: t }) => {
1911
1617
  let n = _(t);
1912
1618
  if (!n.isBlockContainer) return !1;
1913
- let r = t.selection.from === n.blockContent.beforePos + 1, i = t.selection.empty, a = Q(t.doc, n.bnBlock.beforePos);
1619
+ let r = t.selection.from === n.blockContent.beforePos + 1, i = t.selection.empty, a = X(t.doc, n.bnBlock.beforePos);
1914
1620
  if (a && r && i) {
1915
- let r = Qr(t.doc, a);
1621
+ let r = Tr(t.doc, a);
1916
1622
  if (!r.isBlockContainer) return !1;
1917
1623
  if (r.blockContent.node.type.spec.content === "" || r.blockContent.node.type.spec.content === "inline*" && r.blockContent.node.childCount === 0) return e().cut({
1918
1624
  from: n.bnBlock.beforePos,
@@ -1933,7 +1639,7 @@ var Kr = (e) => {
1933
1639
  if (!s.isBlockContainer) return !1;
1934
1640
  if (a && o) {
1935
1641
  let n = s.blockContent.node, a = n.type.spec.content === "inline*", o = r.node.type.spec.content === "inline*";
1936
- return e().insertContentAt(s.bnBlock.afterPos, s.childContainer?.node.content || T.empty).deleteRange(i.node.childCount === 1 ? {
1642
+ return e().insertContentAt(s.bnBlock.afterPos, s.childContainer?.node.content || w.empty).deleteRange(i.node.childCount === 1 ? {
1937
1643
  from: i.beforePos,
1938
1644
  to: i.afterPos
1939
1645
  } : {
@@ -1946,19 +1652,19 @@ var Kr = (e) => {
1946
1652
  () => t.command(({ state: t }) => {
1947
1653
  let n = _(t);
1948
1654
  if (!n.isBlockContainer) return !1;
1949
- let { bnBlock: r, blockContent: i } = n, a = $(t.doc, n.bnBlock.beforePos);
1655
+ let { bnBlock: r, blockContent: i } = n, a = Z(t.doc, n.bnBlock.beforePos);
1950
1656
  if (!a || !a.isBlockContainer) return !1;
1951
1657
  let o = t.selection.from === i.afterPos - 1, s = t.selection.empty, c = r.afterPos;
1952
- return o && s ? e().command(ti(c)).scrollIntoView().run() : !1;
1658
+ return o && s ? e().command(Or(c)).scrollIntoView().run() : !1;
1953
1659
  }),
1954
1660
  () => t.command(({ state: e, tr: t, dispatch: n }) => {
1955
1661
  let r = _(e);
1956
1662
  if (!r.isBlockContainer || e.selection.from !== r.blockContent.afterPos - 1) return !1;
1957
- let i = $(e.doc, r.bnBlock.beforePos);
1663
+ let i = Z(e.doc, r.bnBlock.beforePos);
1958
1664
  if (!i || i.isBlockContainer) return !1;
1959
1665
  if (n) {
1960
1666
  let e = i.bnBlock.beforePos + 1, n = t.doc.resolve(e + 1);
1961
- return t.delete(n.pos, n.pos + n.nodeAfter.nodeSize), R(t, i.bnBlock.beforePos), t.insert(r.bnBlock.afterPos, n.nodeAfter), t.setSelection(P.near(t.doc.resolve(n.pos))), !0;
1667
+ return t.delete(n.pos, n.pos + n.nodeAfter.nodeSize), L(t, i.bnBlock.beforePos), t.insert(r.bnBlock.afterPos, n.nodeAfter), t.setSelection(M.near(t.doc.resolve(n.pos))), !0;
1962
1668
  }
1963
1669
  return !1;
1964
1670
  }),
@@ -1970,7 +1676,7 @@ var Kr = (e) => {
1970
1676
  let a = t.doc.resolve(r.bnBlock.afterPos), o = t.doc.resolve(a.after()), s = o.after();
1971
1677
  if (n) {
1972
1678
  let e = o.pos === s - 1 ? s : o.pos + 1, n = v(t.doc.resolve(e));
1973
- t.delete(n.bnBlock.beforePos, n.bnBlock.afterPos), R(t, s - o.node().nodeSize), t.insert(a.pos, n.bnBlock.node), t.setSelection(P.near(t.doc.resolve(e)));
1679
+ t.delete(n.bnBlock.beforePos, n.bnBlock.afterPos), L(t, s - o.node().nodeSize), t.insert(a.pos, n.bnBlock.node), t.setSelection(M.near(t.doc.resolve(e)));
1974
1680
  }
1975
1681
  return !0;
1976
1682
  }),
@@ -1980,14 +1686,14 @@ var Kr = (e) => {
1980
1686
  let { blockContent: r } = n, i = t.selection.from === r.afterPos - 1, a = t.selection.empty;
1981
1687
  if (i && a) {
1982
1688
  let i = (e, t) => {
1983
- let n = $(e, t);
1689
+ let n = Z(e, t);
1984
1690
  if (n) return n;
1985
- let r = Zr(e, t);
1691
+ let r = wr(e, t);
1986
1692
  if (r) return i(e, r.bnBlock.beforePos);
1987
1693
  }, a = i(t.doc, n.bnBlock.beforePos);
1988
1694
  if (!a || !a.isBlockContainer) return !1;
1989
1695
  let o = a.blockContent.node, s = o.type.spec.content === "inline*", c = r.node.type.spec.content === "inline*";
1990
- return e().insertContentAt(a.bnBlock.afterPos, a.childContainer?.node.content || T.empty).deleteRange({
1696
+ return e().insertContentAt(a.bnBlock.afterPos, a.childContainer?.node.content || w.empty).deleteRange({
1991
1697
  from: a.bnBlock.beforePos,
1992
1698
  to: a.bnBlock.afterPos
1993
1699
  }).insertContentAt(t.selection.from, s && c ? o.content : null).setTextSelection(t.selection.from).scrollIntoView().run();
@@ -1998,7 +1704,7 @@ var Kr = (e) => {
1998
1704
  let n = _(t);
1999
1705
  if (!n.isBlockContainer) return !1;
2000
1706
  if (n.blockContent.node.childCount === 0 && n.blockContent.node.type.spec.content === "inline*") {
2001
- let r = $(t.doc, n.bnBlock.beforePos);
1707
+ let r = Z(t.doc, n.bnBlock.beforePos);
2002
1708
  if (!r || !r.isBlockContainer) return !1;
2003
1709
  let i = e();
2004
1710
  if (r.blockContent.node.type.spec.content === "tableRow+") {
@@ -2015,7 +1721,7 @@ var Kr = (e) => {
2015
1721
  () => t.command(({ state: t }) => {
2016
1722
  let n = _(t);
2017
1723
  if (!n.isBlockContainer) return !1;
2018
- let r = t.selection.from === n.blockContent.afterPos - 1, i = t.selection.empty, a = $(t.doc, n.bnBlock.beforePos);
1724
+ let r = t.selection.from === n.blockContent.afterPos - 1, i = t.selection.empty, a = Z(t.doc, n.bnBlock.beforePos);
2019
1725
  if (!a || !a.isBlockContainer) return !1;
2020
1726
  if (a && r && i && (a.blockContent.node.type.spec.content === "" || a.blockContent.node.type.spec.content === "inline*" && a.blockContent.node.childCount === 0)) {
2021
1727
  let t = a.bnBlock.node.lastChild.content;
@@ -2031,220 +1737,446 @@ var Kr = (e) => {
2031
1737
  let n = _(e);
2032
1738
  if (!n.isBlockContainer) return !1;
2033
1739
  let { bnBlock: r, blockContent: i } = n, { depth: a } = e.doc.resolve(r.beforePos), o = e.selection.$anchor.parentOffset === 0, s = e.selection.anchor === e.selection.head, c = i.node.childCount === 0;
2034
- return o && s && c && a > 1 ? V(t, t.doc.type.schema.nodes.blockContainer, t.doc.type.schema.nodes.blockGroup) : !1;
1740
+ return o && s && c && a > 1 ? H(t, t.doc.type.schema.nodes.blockContainer, t.doc.type.schema.nodes.blockGroup) : !1;
2035
1741
  }),
2036
1742
  () => t.command(({ state: t }) => {
2037
- let r = _(t), i = this.options.editor.schema.blockSchema[r.blockNoteType].meta?.hardBreakShortcut ?? "shift+enter";
1743
+ let r = _(t), i = this.options.editor.schema.blockSpecs[r.blockNoteType]?.implementation?.meta?.hardBreakShortcut ?? "shift+enter";
2038
1744
  if (i === "none") return !1;
2039
1745
  if (i === "shift+enter" && e || i === "enter") {
2040
1746
  let e = n.storedMarks || n.selection.$head.marks().filter((e) => this.editor.extensionManager.splittableMarks.includes(e.type.name));
2041
1747
  return n.insert(n.selection.head, n.doc.type.schema.nodes.hardBreak.create()).ensureMarks(e), !0;
2042
1748
  }
2043
- return !1;
2044
- }),
2045
- () => t.command(({ state: e, dispatch: t, tr: n }) => {
2046
- let r = _(e);
2047
- if (!r.isBlockContainer) return !1;
2048
- let { bnBlock: i, blockContent: a } = r, o = e.selection.$anchor.parentOffset === 0, s = e.selection.anchor === e.selection.head, c = a.node.childCount === 0;
2049
- if (o && s && c) {
2050
- let a = i.afterPos, o = a + 2;
2051
- if (t) {
2052
- let t = e.schema.nodes.blockContainer.createAndFill(void 0, [e.schema.nodes.paragraph.createAndFill() || void 0, r.childContainer?.node].filter((e) => e !== void 0));
2053
- n.insert(a, t).setSelection(new P(n.doc.resolve(o))).scrollIntoView(), r.childContainer && n.delete(r.childContainer.beforePos, r.childContainer.afterPos);
2054
- }
2055
- return !0;
1749
+ return !1;
1750
+ }),
1751
+ () => t.command(({ state: e, dispatch: t, tr: n }) => {
1752
+ let r = _(e);
1753
+ if (!r.isBlockContainer) return !1;
1754
+ let { bnBlock: i, blockContent: a } = r, o = e.selection.$anchor.parentOffset === 0, s = e.selection.anchor === e.selection.head, c = a.node.childCount === 0;
1755
+ if (o && s && c) {
1756
+ let a = i.afterPos, o = a + 2;
1757
+ if (t) {
1758
+ let t = e.schema.nodes.blockContainer.createAndFill(void 0, [e.schema.nodes.paragraph.createAndFill() || void 0, r.childContainer?.node].filter((e) => e !== void 0));
1759
+ n.insert(a, t).setSelection(new M(n.doc.resolve(o))).scrollIntoView(), r.childContainer && n.delete(r.childContainer.beforePos, r.childContainer.afterPos);
1760
+ }
1761
+ return !0;
1762
+ }
1763
+ return !1;
1764
+ }),
1765
+ () => t.command(({ state: e, chain: t }) => {
1766
+ let n = _(e);
1767
+ if (!n.isBlockContainer) return !1;
1768
+ let { blockContent: r } = n, i = e.selection.$anchor.parentOffset === 0;
1769
+ return r.node.childCount === 0 ? !1 : (t().deleteSelection().command(g(e.selection.from, i, i)).scrollIntoView().run(), !0);
1770
+ })
1771
+ ]);
1772
+ return {
1773
+ Backspace: e,
1774
+ Delete: t,
1775
+ Enter: () => n(),
1776
+ "Shift-Enter": () => n(!0),
1777
+ Tab: () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(se)?.store.state || this.options.editor.getExtension(y)?.store.state !== void 0) ? !1 : Vt(this.options.editor),
1778
+ "Shift-Tab": () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(se)?.store.state || this.options.editor.getExtension(y)?.store.state !== void 0) ? !1 : Ut(this.options.editor),
1779
+ "Shift-Mod-ArrowUp": () => (this.options.editor.moveBlocksUp(), !0),
1780
+ "Shift-Mod-ArrowDown": () => (this.options.editor.moveBlocksDown(), !0),
1781
+ "Mod-z": () => this.options.editor.undo(),
1782
+ "Mod-y": () => this.options.editor.redo(),
1783
+ "Shift-Mod-z": () => this.options.editor.redo()
1784
+ };
1785
+ }
1786
+ }), Ar = D.create({
1787
+ name: "textAlignment",
1788
+ addGlobalAttributes() {
1789
+ return [{
1790
+ types: ["tableCell", "tableHeader"],
1791
+ attributes: { textAlignment: {
1792
+ default: "left",
1793
+ parseHTML: (e) => e.getAttribute("data-text-alignment"),
1794
+ renderHTML: (e) => e.textAlignment === "left" ? {} : { "data-text-alignment": e.textAlignment }
1795
+ } }
1796
+ }];
1797
+ }
1798
+ }), jr = D.create({
1799
+ name: "blockTextColor",
1800
+ addGlobalAttributes() {
1801
+ return [{
1802
+ types: [
1803
+ "table",
1804
+ "tableCell",
1805
+ "tableHeader"
1806
+ ],
1807
+ attributes: { textColor: fe() }
1808
+ }];
1809
+ }
1810
+ }), Mr = "aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2";
1811
+ //#endregion
1812
+ //#region src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts
1813
+ function Nr(e) {
1814
+ let t = [], n = [], r = 0;
1815
+ for (; r < e.length;) {
1816
+ let i = 0;
1817
+ for (; r + i < e.length && e.charCodeAt(r + i) >= 48 && e.charCodeAt(r + i) <= 57;) i++;
1818
+ if (i > 0) {
1819
+ t.push(n.join(""));
1820
+ let a = parseInt(e.substring(r, r + i), 10);
1821
+ for (; a-- > 0;) n.pop();
1822
+ r += i;
1823
+ } else n.push(e[r]), r++;
1824
+ }
1825
+ return t;
1826
+ }
1827
+ var Pr = new Set(Nr(Mr)), Fr = new Set(["localhost"]), Ir = /[.,;:!?"']+$/, Lr = /(?:https?|ftp|ftps):\/\/[^\s]+/g, Rr = /mailto:[^\s]+/g, zr = /[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}/g, Br = /(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(?::\d{1,5})?(?:[/?#][^\s]*)?/g;
1828
+ function Vr(e) {
1829
+ let t = e, n = !0;
1830
+ for (; n;) {
1831
+ n = !1;
1832
+ let e = t;
1833
+ t = t.replace(Ir, ""), t !== e && (n = !0);
1834
+ for (let [e, r] of [["(", ")"], ["[", "]"]]) for (; t.endsWith(r);) {
1835
+ let i = Hr(t, e);
1836
+ if (Hr(t, r) > i) t = t.slice(0, -1), n = !0;
1837
+ else break;
1838
+ }
1839
+ }
1840
+ return t;
1841
+ }
1842
+ function Hr(e, t) {
1843
+ let n = 0;
1844
+ for (let r = 0; r < e.length; r++) e[r] === t && n++;
1845
+ return n;
1846
+ }
1847
+ function Ur(e) {
1848
+ let t = e.split(".");
1849
+ return t[t.length - 1].toLowerCase();
1850
+ }
1851
+ function Wr(e) {
1852
+ let t = Ur(e);
1853
+ return Pr.has(t);
1854
+ }
1855
+ function Gr(e, t, n) {
1856
+ return t === "email" ? "mailto:" + e : /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(e) || /^mailto:/i.test(e) ? e : n + "://" + e;
1857
+ }
1858
+ function Kr(e, t) {
1859
+ if (!e) return [];
1860
+ let n = t?.defaultProtocol || "http", r = [];
1861
+ for (let t of e.matchAll(Lr)) r.push({
1862
+ type: "url",
1863
+ value: t[0],
1864
+ start: t.index,
1865
+ end: t.index + t[0].length
1866
+ });
1867
+ for (let t of e.matchAll(Rr)) r.push({
1868
+ type: "url",
1869
+ value: t[0],
1870
+ start: t.index,
1871
+ end: t.index + t[0].length
1872
+ });
1873
+ for (let t of e.matchAll(zr)) r.push({
1874
+ type: "email",
1875
+ value: t[0],
1876
+ start: t.index,
1877
+ end: t.index + t[0].length
1878
+ });
1879
+ for (let t of e.matchAll(Br)) r.push({
1880
+ type: "url",
1881
+ value: t[0],
1882
+ start: t.index,
1883
+ end: t.index + t[0].length
1884
+ });
1885
+ r.sort((e, t) => e.start - t.start || t.end - e.end);
1886
+ let i = [], a = -1;
1887
+ for (let e of r) e.start >= a && (i.push(e), a = e.end);
1888
+ let o = [];
1889
+ for (let e of i) {
1890
+ let t = Vr(e.value);
1891
+ if (!t) continue;
1892
+ let r = e.start, i = r + t.length;
1893
+ if (e.type === "url" && !/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t)) {
1894
+ let e = new URL("http://" + t).hostname;
1895
+ if (!Wr(e)) continue;
1896
+ }
1897
+ if (e.type === "email") {
1898
+ let e = t.split("@")[1];
1899
+ if (!Wr(e)) continue;
1900
+ }
1901
+ let a = Gr(t, e.type, n);
1902
+ o.push({
1903
+ type: e.type,
1904
+ value: t,
1905
+ isLink: !0,
1906
+ href: a,
1907
+ start: r,
1908
+ end: i
1909
+ });
1910
+ }
1911
+ return o;
1912
+ }
1913
+ function qr(e, t = "http") {
1914
+ if (!e) return [$(e, 0, 0)];
1915
+ for (let [n, r] of [
1916
+ ["(", ")"],
1917
+ ["[", "]"],
1918
+ ["{", "}"]
1919
+ ]) if (e.startsWith(n) && e.endsWith(r) && e.length > 2) {
1920
+ let i = e.slice(1, -1);
1921
+ if (Q(i)) return [
1922
+ $(n, 0, 1),
1923
+ Jr(i, 1, 1 + i.length, t),
1924
+ $(r, 1 + i.length, e.length)
1925
+ ];
1926
+ }
1927
+ if (e.endsWith(".") && e.length > 1) {
1928
+ let n = e.slice(0, -1);
1929
+ if (Q(n)) return [Jr(n, 0, n.length, t), $(".", n.length, e.length)];
1930
+ }
1931
+ return Q(e) ? [Jr(e, 0, e.length, t)] : [$(e, 0, e.length)];
1932
+ }
1933
+ function Q(e) {
1934
+ if (/^(?:https?|ftp|ftps):\/\/[^\s]+$/.test(e) || /^mailto:[^\s]+$/.test(e) || Fr.has(e.toLowerCase())) return !0;
1935
+ let t = e.match(/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+([a-zA-Z]{2,})(?::\d{1,5})?(?:[/?#][^\s]*)?$/);
1936
+ if (t) {
1937
+ let e = t[1].toLowerCase();
1938
+ if (Pr.has(e)) return !0;
1939
+ }
1940
+ return !1;
1941
+ }
1942
+ function Jr(e, t, n, r) {
1943
+ let i = e.includes("@") && !e.includes("://") && !e.startsWith("mailto:") ? "email" : "url";
1944
+ return {
1945
+ type: i,
1946
+ value: e,
1947
+ isLink: !0,
1948
+ href: Gr(e, i, r),
1949
+ start: t,
1950
+ end: n
1951
+ };
1952
+ }
1953
+ function $(e, t, n) {
1954
+ return {
1955
+ type: "text",
1956
+ value: e,
1957
+ isLink: !1,
1958
+ href: e,
1959
+ start: t,
1960
+ end: n
1961
+ };
1962
+ }
1963
+ //#endregion
1964
+ //#region src/extensions/tiptap-extensions/Link/helpers/whitespace.ts
1965
+ var Yr = "[\0- \xA0 ᠎ -\u2029  ]", Xr = new RegExp(Yr), Zr = RegExp(`${Yr}$`), Qr = new RegExp(Yr, "g");
1966
+ //#endregion
1967
+ //#region src/extensions/tiptap-extensions/Link/helpers/autolink.ts
1968
+ function $r(e) {
1969
+ return e.length === 1 ? e[0].isLink : e.length === 3 && e[1].isLink ? ["()", "[]"].includes(e[0].value + e[2].value) : !1;
1970
+ }
1971
+ function ei(e) {
1972
+ return new rt({
1973
+ key: new it("autolink"),
1974
+ appendTransaction: (t, n, r) => {
1975
+ let i = t.some((e) => e.docChanged) && !n.doc.eq(r.doc), a = t.some((e) => e.getMeta("preventAutolink"));
1976
+ if (!i || a) return;
1977
+ let { tr: o } = r;
1978
+ if (qe(He(n.doc, [...t])).forEach(({ newRange: t }) => {
1979
+ let n = We(r.doc, t, (e) => e.isTextblock), i, a;
1980
+ if (n.length > 1) i = n[0], a = r.doc.textBetween(i.pos, i.pos + i.node.nodeSize, void 0, " ");
1981
+ else if (n.length) {
1982
+ let e = r.doc.textBetween(t.from, t.to, " ", " ");
1983
+ if (!Zr.test(e)) return;
1984
+ i = n[0], a = r.doc.textBetween(i.pos, t.to, void 0, " ");
1985
+ }
1986
+ if (i && a) {
1987
+ let t = a.split(Xr).filter(Boolean);
1988
+ if (t.length <= 0) return;
1989
+ let n = t[t.length - 1], s = i.pos + a.lastIndexOf(n);
1990
+ if (!n) return;
1991
+ let c = qr(n, e.defaultProtocol);
1992
+ if (!$r(c)) return;
1993
+ c.filter((e) => e.isLink).map((e) => ({
1994
+ ...e,
1995
+ from: s + e.start + 1,
1996
+ to: s + e.end + 1
1997
+ })).filter((e) => r.schema.marks.code ? !r.doc.rangeHasMark(e.from, e.to, r.schema.marks.code) : !0).filter((t) => e.validate(t.value)).filter((t) => e.shouldAutoLink(t.value)).forEach((t) => {
1998
+ Ye(t.from, t.to, r.doc).some((t) => t.mark.type === e.type) || o.addMark(t.from, t.to, e.type.create({ href: t.href }));
1999
+ });
2056
2000
  }
2057
- return !1;
2058
- }),
2059
- () => t.command(({ state: e, chain: t }) => {
2060
- let n = _(e);
2061
- if (!n.isBlockContainer) return !1;
2062
- let { blockContent: r } = n, i = e.selection.$anchor.parentOffset === 0;
2063
- return r.node.childCount === 0 ? !1 : (t().deleteSelection().command(a(e.selection.from, i, i)).run(), !0);
2064
- })
2065
- ]);
2001
+ }), o.steps.length) return o;
2002
+ }
2003
+ });
2004
+ }
2005
+ //#endregion
2006
+ //#region src/extensions/tiptap-extensions/Link/helpers/clickHandler.ts
2007
+ function ti(e) {
2008
+ return new rt({
2009
+ key: new it("handleClickLink"),
2010
+ props: { handleClick: (t, n, r) => {
2011
+ if (r.button !== 0 || !t.editable) return !1;
2012
+ let i = null;
2013
+ if (r.target instanceof HTMLAnchorElement && r.target.getAttribute("data-inline-content-type") === "link") i = r.target;
2014
+ else {
2015
+ let t = r.target;
2016
+ if (!t) return !1;
2017
+ let n = e.tiptapEditor.view.dom;
2018
+ i = t.closest("a[data-inline-content-type=\"link\"]"), i && !n.contains(i) && (i = null);
2019
+ }
2020
+ if (!i) return !1;
2021
+ if (e.onClick) {
2022
+ if (!e.editor) throw Error("BlockNoteEditor not found in Link click handler");
2023
+ return e.onClick(r, e.editor) ?? !0;
2024
+ }
2025
+ let a = Ke(t.state, e.type.name), o = i.href ?? a.href, s = i.target ?? a.target;
2026
+ return o ? (window.open(o, s), !0) : !1;
2027
+ } }
2028
+ });
2029
+ }
2030
+ //#endregion
2031
+ //#region src/extensions/tiptap-extensions/Link/helpers/pasteHandler.ts
2032
+ function ni(e) {
2033
+ return new rt({
2034
+ key: new it("handlePasteLink"),
2035
+ props: { handlePaste: (t, n, r) => {
2036
+ let { shouldAutoLink: i, isValidLink: a } = e, { state: o } = t, { selection: s } = o, { empty: c } = s;
2037
+ if (c) return !1;
2038
+ let l = "";
2039
+ r.content.forEach((e) => {
2040
+ l += e.textContent;
2041
+ });
2042
+ let u = Kr(l, { defaultProtocol: e.defaultProtocol }).find((e) => e.isLink && e.value === l);
2043
+ return !l || !u || !a(u.value) || i !== void 0 && !i(u.value) ? !1 : e.editor.commands.setMark(e.type, { href: u.href });
2044
+ } }
2045
+ });
2046
+ }
2047
+ //#endregion
2048
+ //#region src/extensions/tiptap-extensions/Link/link.ts
2049
+ var ri = "https", ii = /^(?:(?:http|https|ftp|ftps|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z0-9+.\-]+(?:[^a-z+.\-:]|$))/i;
2050
+ function ai(e) {
2051
+ if (!e) return !0;
2052
+ let t = e.replace(Qr, "");
2053
+ return ii.test(t);
2054
+ }
2055
+ function oi(e) {
2056
+ let t = /^[a-z][a-z0-9+.-]*:\/\//i.test(e), n = /^[a-z][a-z0-9+.-]*:/i.test(e);
2057
+ if (t || n && !e.includes("@")) return !0;
2058
+ let r = (e.includes("@") ? e.split("@").pop() : e).split(/[/?#:]/)[0];
2059
+ return !(/^\d{1,3}(\.\d{1,3}){3}$/.test(r) || !/\./.test(r));
2060
+ }
2061
+ var si = Ve.create({
2062
+ name: "link",
2063
+ keepOnSplit: !1,
2064
+ exitable: !0,
2065
+ inclusive: !1,
2066
+ addOptions() {
2066
2067
  return {
2067
- Backspace: e,
2068
- Delete: t,
2069
- Enter: () => n(),
2070
- "Shift-Enter": () => n(!0),
2071
- Tab: () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(b)?.store.state || this.options.editor.getExtension(ie)?.store.state !== void 0) ? !1 : Rt(this.options.editor),
2072
- "Shift-Tab": () => this.options.tabBehavior !== "prefer-indent" && (this.options.editor.getExtension(b)?.store.state || this.options.editor.getExtension(ie)?.store.state !== void 0) ? !1 : Bt(this.options.editor),
2073
- "Shift-Mod-ArrowUp": () => (this.options.editor.moveBlocksUp(), !0),
2074
- "Shift-Mod-ArrowDown": () => (this.options.editor.moveBlocksDown(), !0),
2075
- "Mod-z": () => this.options.editor.undo(),
2076
- "Mod-y": () => this.options.editor.redo(),
2077
- "Shift-Mod-z": () => this.options.editor.redo()
2068
+ HTMLAttributes: {
2069
+ target: "_blank",
2070
+ rel: "noopener noreferrer nofollow",
2071
+ className: "bn-inline-content-section",
2072
+ "data-inline-content-type": "link"
2073
+ },
2074
+ editor: void 0,
2075
+ onClick: void 0,
2076
+ isValidLink: ai
2078
2077
  };
2079
- }
2080
- }), ri = k.create({
2081
- name: "insertion",
2082
- inclusive: !1,
2083
- excludes: "deletion modification insertion",
2084
- addAttributes() {
2085
- return { id: {
2086
- default: null,
2087
- validate: "number"
2088
- } };
2089
2078
  },
2090
- extendMarkSchema(e) {
2091
- return e.name === "insertion" ? {
2092
- blocknoteIgnore: !0,
2093
- inclusive: !1,
2094
- toDOM(e, t) {
2095
- return [
2096
- "ins",
2097
- {
2098
- "data-id": String(e.attrs.id),
2099
- "data-inline": String(t),
2100
- ...!t && { style: "display: contents" }
2101
- },
2102
- 0
2103
- ];
2104
- },
2105
- parseDOM: [{
2106
- tag: "ins",
2107
- getAttrs(e) {
2108
- return e.dataset.id ? { id: parseInt(e.dataset.id, 10) } : !1;
2109
- }
2110
- }]
2111
- } : {};
2112
- }
2113
- }), ii = k.create({
2114
- name: "deletion",
2115
- inclusive: !1,
2116
- excludes: "insertion modification deletion",
2117
2079
  addAttributes() {
2118
- return { id: {
2080
+ return { href: {
2119
2081
  default: null,
2120
- validate: "number"
2082
+ parseHTML(e) {
2083
+ return e.getAttribute("href");
2084
+ }
2121
2085
  } };
2122
2086
  },
2123
- extendMarkSchema(e) {
2124
- return e.name === "deletion" ? {
2125
- blocknoteIgnore: !0,
2126
- inclusive: !1,
2127
- toDOM(e, t) {
2128
- return [
2129
- "del",
2130
- {
2131
- "data-id": String(e.attrs.id),
2132
- "data-inline": String(t),
2133
- ...!t && { style: "display: contents" }
2134
- },
2135
- 0
2136
- ];
2137
- },
2138
- parseDOM: [{
2139
- tag: "del",
2140
- getAttrs(e) {
2141
- return e.dataset.id ? { id: parseInt(e.dataset.id, 10) } : !1;
2087
+ parseHTML() {
2088
+ let e = this.options.isValidLink;
2089
+ return [{
2090
+ tag: "a[href]",
2091
+ getAttrs: (t) => {
2092
+ let n = t.getAttribute("href");
2093
+ return !n || !e(n) ? !1 : null;
2094
+ }
2095
+ }];
2096
+ },
2097
+ renderHTML({ HTMLAttributes: e }) {
2098
+ return this.options.isValidLink(e.href) ? [
2099
+ "a",
2100
+ $e(e, this.options.HTMLAttributes),
2101
+ 0
2102
+ ] : [
2103
+ "a",
2104
+ $e({
2105
+ ...e,
2106
+ href: ""
2107
+ }, this.options.HTMLAttributes),
2108
+ 0
2109
+ ];
2110
+ },
2111
+ addPasteRules() {
2112
+ let e = this.options.isValidLink;
2113
+ return [Qe({
2114
+ find: (t) => {
2115
+ let n = [];
2116
+ if (t) {
2117
+ let r = Kr(t, { defaultProtocol: ri }).filter((t) => t.isLink && e(t.value));
2118
+ for (let e of r) oi(e.value) && n.push({
2119
+ text: e.value,
2120
+ data: { href: e.href },
2121
+ index: e.start
2122
+ });
2142
2123
  }
2143
- }]
2144
- } : {};
2145
- }
2146
- }), ai = k.create({
2147
- name: "modification",
2148
- inclusive: !1,
2149
- excludes: "deletion insertion",
2150
- addAttributes() {
2151
- return {
2152
- id: {
2153
- default: null,
2154
- validate: "number"
2155
- },
2156
- type: { validate: "string" },
2157
- attrName: {
2158
- default: null,
2159
- validate: "string|null"
2124
+ return n;
2160
2125
  },
2161
- previousValue: { default: null },
2162
- newValue: { default: null }
2163
- };
2126
+ type: this.type,
2127
+ getAttributes: (e) => ({ href: e.data?.href })
2128
+ })];
2164
2129
  },
2165
- extendMarkSchema(e) {
2166
- return e.name === "modification" ? {
2167
- blocknoteIgnore: !0,
2168
- inclusive: !1,
2169
- toDOM(e, t) {
2170
- return [
2171
- t ? "span" : "div",
2172
- {
2173
- "data-type": "modification",
2174
- "data-id": String(e.attrs.id),
2175
- "data-mod-type": e.attrs.type,
2176
- "data-mod-prev-val": JSON.stringify(e.attrs.previousValue),
2177
- "data-mod-new-val": JSON.stringify(e.attrs.newValue)
2178
- },
2179
- 0
2180
- ];
2181
- },
2182
- parseDOM: [{
2183
- tag: "span[data-type='modification']",
2184
- getAttrs(e) {
2185
- return e.dataset.id ? {
2186
- id: parseInt(e.dataset.id, 10),
2187
- type: e.dataset.modType,
2188
- previousValue: e.dataset.modPrevVal,
2189
- newValue: e.dataset.modNewVal
2190
- } : !1;
2191
- }
2192
- }, {
2193
- tag: "div[data-type='modification']",
2194
- getAttrs(e) {
2195
- return e.dataset.id ? {
2196
- id: parseInt(e.dataset.id, 10),
2197
- type: e.dataset.modType,
2198
- previousValue: e.dataset.modPrevVal
2199
- } : !1;
2200
- }
2201
- }]
2202
- } : {};
2203
- }
2204
- }), oi = O.create({
2205
- name: "textAlignment",
2206
- addGlobalAttributes() {
2207
- return [{
2208
- types: ["tableCell", "tableHeader"],
2209
- attributes: { textAlignment: {
2210
- default: "left",
2211
- parseHTML: (e) => e.getAttribute("data-text-alignment"),
2212
- renderHTML: (e) => e.textAlignment === "left" ? {} : { "data-text-alignment": e.textAlignment }
2213
- } }
2214
- }];
2215
- }
2216
- }), si = O.create({
2217
- name: "blockTextColor",
2218
- addGlobalAttributes() {
2219
- return [{
2220
- types: [
2221
- "table",
2222
- "tableCell",
2223
- "tableHeader"
2224
- ],
2225
- attributes: { textColor: ue() }
2226
- }];
2130
+ addProseMirrorPlugins() {
2131
+ let e = [];
2132
+ return e.push(ei({
2133
+ type: this.type,
2134
+ defaultProtocol: ri,
2135
+ validate: this.options.isValidLink,
2136
+ shouldAutoLink: oi
2137
+ })), e.push(ti({
2138
+ type: this.type,
2139
+ tiptapEditor: this.editor,
2140
+ editor: this.options.editor,
2141
+ onClick: this.options.onClick
2142
+ })), e.push(ni({
2143
+ editor: this.editor,
2144
+ defaultProtocol: ri,
2145
+ type: this.type,
2146
+ shouldAutoLink: oi,
2147
+ isValidLink: this.options.isValidLink
2148
+ })), e;
2227
2149
  }
2228
- }), ci = {
2150
+ }), ci = he(({ editor: e, options: t }) => ({
2151
+ key: "link",
2152
+ tiptapExtensions: [si.configure({
2153
+ HTMLAttributes: t.HTMLAttributes ?? {},
2154
+ editor: e,
2155
+ onClick: t.onClick,
2156
+ ...t.isValidLink ? { isValidLink: t.isValidLink } : {}
2157
+ })]
2158
+ })), li = {
2229
2159
  blockColor: "data-block-color",
2230
2160
  blockStyle: "data-block-style",
2231
2161
  id: "data-id",
2232
2162
  depth: "data-depth",
2233
2163
  depthChange: "data-depth-change"
2234
- }, li = A.create({
2164
+ }, ui = O.create({
2235
2165
  name: "blockContainer",
2236
2166
  group: "blockGroupChild bnBlock",
2237
2167
  content: "blockContent blockGroup?",
2238
2168
  priority: 50,
2239
2169
  defining: !0,
2240
- marks: "insertion modification deletion",
2170
+ marks() {
2171
+ return p(this.editor);
2172
+ },
2241
2173
  parseHTML() {
2242
2174
  return [{
2243
2175
  tag: "div[data-node-type=" + this.name + "]",
2244
2176
  getAttrs: (e) => {
2245
2177
  if (typeof e == "string") return !1;
2246
2178
  let t = {};
2247
- for (let [n, r] of Object.entries(ci)) e.getAttribute(r) && (t[n] = e.getAttribute(r));
2179
+ for (let [n, r] of Object.entries(li)) e.getAttribute(r) && (t[n] = e.getAttribute(r));
2248
2180
  return t;
2249
2181
  }
2250
2182
  }, {
@@ -2260,18 +2192,20 @@ var Kr = (e) => {
2260
2192
  ...this.options.domAttributes?.block || {},
2261
2193
  ...e
2262
2194
  }, r = document.createElement("div");
2263
- r.className = s("bn-block", n.class), r.setAttribute("data-node-type", this.name);
2195
+ r.className = o("bn-block", n.class), r.setAttribute("data-node-type", this.name);
2264
2196
  for (let [e, t] of Object.entries(n)) e !== "class" && r.setAttribute(e, t);
2265
2197
  return t.appendChild(r), {
2266
2198
  dom: t,
2267
2199
  contentDOM: r
2268
2200
  };
2269
2201
  }
2270
- }), ui = A.create({
2202
+ }), di = O.create({
2271
2203
  name: "blockGroup",
2272
2204
  group: "childContainer",
2273
2205
  content: "blockGroupChild+",
2274
- marks: "deletion insertion modification",
2206
+ marks() {
2207
+ return p(this.editor);
2208
+ },
2275
2209
  parseHTML() {
2276
2210
  return [{
2277
2211
  tag: "div",
@@ -2283,38 +2217,31 @@ var Kr = (e) => {
2283
2217
  ...this.options.domAttributes?.blockGroup || {},
2284
2218
  ...e
2285
2219
  }, n = document.createElement("div");
2286
- n.className = s("bn-block-group", t.class), n.setAttribute("data-node-type", "blockGroup");
2220
+ n.className = o("bn-block-group", t.class), n.setAttribute("data-node-type", "blockGroup");
2287
2221
  for (let [e, r] of Object.entries(t)) e !== "class" && n.setAttribute(e, r);
2288
2222
  return {
2289
2223
  dom: n,
2290
2224
  contentDOM: n
2291
2225
  };
2292
2226
  }
2293
- }), di = A.create({
2227
+ }), fi = O.create({
2294
2228
  name: "doc",
2295
2229
  topNode: !0,
2296
2230
  content: "blockGroup",
2297
- marks: "insertion modification deletion"
2298
- }), fi = Me(({ options: e }) => ({
2299
- key: "collaboration",
2300
- blockNoteExtensions: [
2301
- he(e),
2302
- ge(e),
2303
- ke(e),
2304
- de(),
2305
- Ae(e)
2306
- ]
2307
- }));
2231
+ marks() {
2232
+ return p(this.editor);
2233
+ }
2234
+ });
2308
2235
  //#endregion
2309
2236
  //#region src/editor/managers/ExtensionManager/extensions.ts
2310
2237
  function pi(e, t) {
2311
2238
  return [
2312
- j.ClipboardTextSerializer,
2313
- j.Commands,
2314
- j.Editable,
2315
- j.FocusEvents,
2316
- j.Tabindex,
2317
- dt,
2239
+ k.ClipboardTextSerializer,
2240
+ k.Commands,
2241
+ k.Editable,
2242
+ k.FocusEvents,
2243
+ k.Tabindex,
2244
+ ut,
2318
2245
  u.configure({
2319
2246
  types: [
2320
2247
  "blockContainer",
@@ -2324,68 +2251,70 @@ function pi(e, t) {
2324
2251
  setIdAttribute: t.setIdAttribute,
2325
2252
  isWithinEditor: e.isWithinEditor
2326
2253
  }),
2327
- Xr,
2328
- ft,
2329
- ri,
2330
- ii,
2331
- ai,
2254
+ Cr,
2255
+ lt,
2332
2256
  ...Object.values(e.schema.styleSpecs).map((t) => t.implementation.mark.configure({ editor: e })),
2333
- si,
2334
- Yr,
2335
- oi,
2336
- O.create({
2257
+ jr,
2258
+ Sr,
2259
+ Ar,
2260
+ D.create({
2337
2261
  name: "OverrideEscape",
2338
- addKeyboardShortcuts: () => ({ Escape: () => e.getExtension(h)?.shown() ? !1 : (e.blur(), !0) })
2262
+ addKeyboardShortcuts: () => ({ Escape: () => e.getExtension(ie)?.shown() ? !1 : (e.blur(), !0) })
2339
2263
  }),
2340
- di,
2341
- li.configure({
2264
+ fi,
2265
+ ui.configure({
2342
2266
  editor: e,
2343
2267
  domAttributes: t.domAttributes
2344
2268
  }),
2345
- ni.configure({
2269
+ kr.configure({
2346
2270
  editor: e,
2347
2271
  tabBehavior: t.tabBehavior
2348
2272
  }),
2349
- ui.configure({ domAttributes: t.domAttributes }),
2273
+ di.configure({ domAttributes: t.domAttributes }),
2350
2274
  ...Object.values(e.schema.inlineContentSpecs).filter((e) => e.config !== "link" && e.config !== "text").map((t) => t.implementation.node.configure({ editor: e })),
2351
2275
  ...Object.values(e.schema.blockSpecs).flatMap((n) => [..."node" in n.implementation ? [n.implementation.node.configure({
2352
2276
  editor: e,
2353
2277
  domAttributes: t.domAttributes
2354
2278
  })] : []]),
2355
- Jr(e),
2356
- Ur(e, t.pasteHandler || ((e) => e.defaultPasteHandler())),
2357
- Er(e)
2279
+ xr(e),
2280
+ gr(e, t.pasteHandler || ((e) => e.defaultPasteHandler())),
2281
+ $n(e)
2358
2282
  ];
2359
2283
  }
2360
2284
  function mi(e, t) {
2361
2285
  let n = [
2362
- pe(),
2363
- ve(t),
2364
- ie(t),
2365
- b(t),
2366
- br({
2286
+ ve(),
2287
+ _e(t),
2288
+ y(t),
2289
+ se(t),
2290
+ ci({
2367
2291
  HTMLAttributes: t.links?.HTMLAttributes ?? {},
2368
2292
  onClick: t.links?.onClick,
2369
2293
  ...t.links?.isValidLink ? { isValidLink: t.links.isValidLink } : {}
2370
2294
  }),
2371
- _e(t),
2372
- Se(),
2373
- Te(t),
2374
- Ne(t),
2375
- we(t),
2376
- h(t),
2377
- ...t.trailingBlock === !1 ? [] : [Ee()]
2295
+ ke(t),
2296
+ Ae(),
2297
+ xe(t),
2298
+ Me(t),
2299
+ Ce(t),
2300
+ ie(t),
2301
+ ye(),
2302
+ je(),
2303
+ ...t.trailingBlock === !1 ? [] : [De()]
2378
2304
  ];
2379
- return t.collaboration ? n.push(fi(t.collaboration)) : n.push(Oe()), "table" in e.schema.blockSpecs && n.push(Ce(t)), t.animations !== !1 && n.push(be()), n;
2305
+ return "table" in e.schema.blockSpecs && n.push(Se(t)), t.animations !== !1 && n.push(Oe()), n;
2380
2306
  }
2381
2307
  //#endregion
2382
2308
  //#region src/editor/managers/ExtensionManager/index.ts
2383
2309
  var hi = class {
2310
+ editor;
2311
+ options;
2384
2312
  disabledExtensions = /* @__PURE__ */ new Set();
2385
2313
  extensions = [];
2386
2314
  abortMap = /* @__PURE__ */ new Map();
2387
2315
  extensionFactories = /* @__PURE__ */ new Map();
2388
2316
  extensionPlugins = /* @__PURE__ */ new Map();
2317
+ blockNoteExtensionDependents = /* @__PURE__ */ new Map();
2389
2318
  constructor(e, t) {
2390
2319
  this.editor = e, this.options = t, e.onMount(() => {
2391
2320
  for (let t of this.extensions) if (t.mount) {
@@ -2406,26 +2335,23 @@ var hi = class {
2406
2335
  for (let e of Object.values(this.editor.schema.blockSpecs)) for (let t of e.extensions ?? []) this.addExtension(t);
2407
2336
  }
2408
2337
  registerExtension(e) {
2409
- let t = [].concat(e).filter(Boolean);
2410
- if (!t.length) {
2411
- console.warn("No extensions found to register", e);
2412
- return;
2413
- }
2414
- let n = t.map((e) => this.addExtension(e)).filter(Boolean), r = /* @__PURE__ */ new Set();
2415
- for (let e of n) e?.tiptapExtensions && console.warn(`Extension ${e.key} has tiptap extensions, but these cannot be changed after initializing the editor. Please separate the extension into multiple extensions if you want to add them, or re-initialize the editor.`, e), e?.inputRules?.length && console.warn(`Extension ${e.key} has input rules, but these cannot be changed after initializing the editor. Please separate the extension into multiple extensions if you want to add them, or re-initialize the editor.`, e), this.getProsemirrorPluginsFromExtension(e).plugins.forEach((e) => {
2416
- r.add(e);
2417
- });
2418
- this.updatePlugins((e) => [...e, ...r]);
2419
- }
2420
- addExtension(e) {
2421
- let t;
2422
- if (t = typeof e == "function" ? e({ editor: this.editor }) : e, !(!t || this.disabledExtensions.has(t.key))) {
2423
- if (typeof e == "function") {
2424
- let e = t[je];
2425
- typeof e == "function" && this.extensionFactories.set(e, t);
2338
+ this.replaceExtension(void 0, e);
2339
+ }
2340
+ addExtension(e, t) {
2341
+ let n;
2342
+ if (n = typeof e == "function" ? e({ editor: this.editor }) : e, !(!n || this.disabledExtensions.has(n.key))) {
2343
+ if (t) {
2344
+ let e = this.blockNoteExtensionDependents.get(n.key);
2345
+ e || (e = /* @__PURE__ */ new Set(), this.blockNoteExtensionDependents.set(n.key, e)), e.add(t);
2346
+ }
2347
+ if (!this.extensions.some((e) => e.key === n.key)) {
2348
+ if (typeof e == "function") {
2349
+ let e = n[me];
2350
+ typeof e == "function" && this.extensionFactories.set(e, n);
2351
+ }
2352
+ if (this.extensions.push(n), n.blockNoteExtensions) for (let e of n.blockNoteExtensions) this.addExtension(e, n.key);
2353
+ return n;
2426
2354
  }
2427
- if (this.extensions.push(t), t.blockNoteExtensions) for (let e of t.blockNoteExtensions) this.addExtension(e);
2428
- return t;
2429
2355
  }
2430
2356
  }
2431
2357
  resolveExtensions(e) {
@@ -2442,43 +2368,62 @@ var hi = class {
2442
2368
  return t;
2443
2369
  }
2444
2370
  unregisterExtension(e) {
2445
- let t = this.resolveExtensions(e);
2446
- if (!t.length) {
2447
- console.warn("No extensions found to unregister", e);
2448
- return;
2449
- }
2450
- let n = !1, r = /* @__PURE__ */ new Set();
2451
- for (let i of t) this.extensions = this.extensions.filter((e) => e !== i), this.extensionFactories.forEach((e, t) => {
2452
- e === i && this.extensionFactories.delete(t);
2453
- }), this.abortMap.get(i)?.abort(), this.abortMap.delete(i), this.extensionPlugins.get(i)?.forEach((e) => {
2454
- r.add(e);
2455
- }), this.extensionPlugins.delete(i), i.tiptapExtensions && !n && (n = !0, console.warn(`Extension ${i.key} has tiptap extensions, but they will not be removed. Please separate the extension into multiple extensions if you want to remove them, or re-initialize the editor.`, e));
2456
- this.updatePlugins((e) => e.filter((e) => !r.has(e)));
2371
+ this.replaceExtension(e, []);
2372
+ }
2373
+ replaceExtension(e, t) {
2374
+ let n = this.resolveExtensions(e);
2375
+ e && !n.length && console.warn("No extensions found to unregister", e);
2376
+ let r = !1, i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
2377
+ for (let t of n) this.extensions = this.extensions.filter((e) => e !== t), this.extensionFactories.forEach((e, n) => {
2378
+ e === t && this.extensionFactories.delete(n);
2379
+ }), this.abortMap.get(t)?.abort(), this.abortMap.delete(t), this.extensionPlugins.get(t)?.forEach((e) => {
2380
+ i.add(e);
2381
+ let t = e.spec?.key, n = typeof t == "object" && t ? t.key : t;
2382
+ typeof n == "string" && a.add(n);
2383
+ }), this.extensionPlugins.delete(t), t.tiptapExtensions && !r && (r = !0, console.warn(`Extension ${t.key} has tiptap extensions, but they will not be removed. Please separate the extension into multiple extensions if you want to remove them, or re-initialize the editor.`, e));
2384
+ let o = [].concat(t).filter(Boolean).map((e) => this.addExtension(e)).filter(Boolean), s = [];
2385
+ for (let e of o) e?.tiptapExtensions && console.warn(`Extension ${e.key} has tiptap extensions, but these cannot be changed after initializing the editor. Please separate the extension into multiple extensions if you want to add them, or re-initialize the editor.`, e), e?.inputRules?.length && console.warn(`Extension ${e.key} has input rules, but these cannot be changed after initializing the editor. Please separate the extension into multiple extensions if you want to add them, or re-initialize the editor.`, e), this.getProsemirrorPluginsFromExtension(e).plugins.forEach((e) => {
2386
+ s.push(e);
2387
+ });
2388
+ !i.size && !a.size && !s.length || this.updatePlugins((e) => [...e.filter((e) => {
2389
+ if (i.has(e)) return !1;
2390
+ if (a.size) {
2391
+ let t = e.spec?.key, n = typeof t == "object" && t ? t.key : t;
2392
+ if (typeof n == "string" && a.has(n)) return !1;
2393
+ }
2394
+ return !0;
2395
+ }), ...s]);
2457
2396
  }
2458
2397
  updatePlugins(e) {
2459
2398
  let t = this.editor.prosemirrorState, n = t.reconfigure({ plugins: e(t.plugins.slice()) });
2460
2399
  this.editor.prosemirrorView.updateState(n);
2461
2400
  }
2462
2401
  getTiptapExtensions() {
2463
- let e = pi(this.editor, this.options).filter((e) => !this.disabledExtensions.has(e.name)), t = l(this.extensions), n = /* @__PURE__ */ new Map();
2402
+ let e = pi(this.editor, this.options).filter((e) => !this.disabledExtensions.has(e.name)), t = s(this.extensions.map((e) => {
2403
+ let t = this.blockNoteExtensionDependents.get(e.key);
2404
+ return t?.size ? {
2405
+ key: e.key,
2406
+ runsBefore: [...e.runsBefore ?? [], ...t]
2407
+ } : e;
2408
+ })), n = /* @__PURE__ */ new Map();
2464
2409
  for (let r of this.extensions) {
2465
2410
  r.tiptapExtensions && e.push(...r.tiptapExtensions);
2466
2411
  let i = t(r.key), { plugins: a, inputRules: o } = this.getProsemirrorPluginsFromExtension(r);
2467
- a.length && e.push(O.create({
2412
+ a.length && e.push(D.create({
2468
2413
  name: r.key,
2469
2414
  priority: i,
2470
2415
  addProseMirrorPlugins: () => a
2471
2416
  })), o.length && (n.has(i) || n.set(i, []), n.get(i).push(...o));
2472
2417
  }
2473
- e.push(O.create({
2418
+ e.push(D.create({
2474
2419
  name: "blocknote-input-rules",
2475
2420
  addProseMirrorPlugins() {
2476
2421
  let e = [];
2477
- Array.from(n.keys()).sort().reverse().forEach((t) => {
2422
+ Array.from(n.keys()).sort((e, t) => e - t).reverse().forEach((t) => {
2478
2423
  e.push(...n.get(t));
2479
2424
  });
2480
- let t = lt({ rules: e });
2481
- return [t, new N({ props: { handleKeyDown(e, n) {
2425
+ let t = st({ rules: e });
2426
+ return [t, new j({ props: { handleKeyDown(e, n) {
2482
2427
  if (n.key !== "Enter" || n.shiftKey || n.ctrlKey || n.metaKey || n.altKey) return !1;
2483
2428
  let { $cursor: r } = e.state.selection;
2484
2429
  return r ? !!t.props.handleTextInput?.call(t, e, r.pos, r.pos, "\n", () => e.state.tr.insertText("\n", r.pos, r.pos)) : !1;
@@ -2488,31 +2433,28 @@ var hi = class {
2488
2433
  for (let t of this.options._tiptapOptions?.extensions ?? []) e.push(t);
2489
2434
  return e;
2490
2435
  }
2491
- getProsemirrorPluginsFromExtension(e) {
2492
- let t = [...e.prosemirrorPlugins ?? []], n = [];
2493
- return !e.prosemirrorPlugins?.length && !Object.keys(e.keyboardShortcuts || {}).length && !e.inputRules?.length ? {
2494
- plugins: t,
2495
- inputRules: n
2496
- } : (this.extensionPlugins.set(e, t), e.inputRules?.length && n.push(...e.inputRules.map((e) => new ct(e.find, (t, n, r, a) => {
2497
- let o = e.replace({
2498
- match: n,
2436
+ getProsemirrorPluginsFromExtension(t) {
2437
+ let n = [...t.prosemirrorPlugins ?? []], r = [];
2438
+ return !t.prosemirrorPlugins?.length && !Object.keys(t.keyboardShortcuts || {}).length && !t.inputRules?.length ? {
2439
+ plugins: n,
2440
+ inputRules: r
2441
+ } : (this.extensionPlugins.set(t, n), t.inputRules?.length && r.push(...t.inputRules.map((t) => new ot(t.find, (n, r, i, a) => {
2442
+ let o = t.replace({
2443
+ match: r,
2499
2444
  range: {
2500
- from: r,
2445
+ from: i,
2501
2446
  to: a
2502
2447
  },
2503
2448
  editor: this.editor
2504
2449
  });
2505
2450
  if (o) {
2506
- let e = t.tr, n = f(e);
2507
- if (!n.isBlockContainer || this.editor.schema.blockSchema[n.blockNoteType]?.content !== "inline") return null;
2508
- e.deleteRange(r, a), i(e, n.bnBlock.beforePos, o);
2509
- let s = n.bnBlock.node.attrs.id;
2510
- return s && Un(e, s, "start"), e;
2451
+ let t = n.tr, r = _(t);
2452
+ return !r.isBlockContainer || this.editor.schema.blockSchema[r.blockNoteType]?.content !== "inline" ? null : (t.deleteRange(i, a), m(t, r.bnBlock.beforePos, o), qn(t, e(r.bnBlock.node, t.doc), "start"), t);
2511
2453
  }
2512
2454
  return null;
2513
- }, { undoable: !0 }))), Object.keys(e.keyboardShortcuts || {}).length && t.push(ut(Object.fromEntries(Object.entries(e.keyboardShortcuts).map(([e, t]) => [e, () => t({ editor: this.editor })])))), {
2514
- plugins: t,
2515
- inputRules: n
2455
+ }, { undoable: !0 }))), Object.keys(t.keyboardShortcuts || {}).length && n.push(ct(Object.fromEntries(Object.entries(t.keyboardShortcuts).map(([e, t]) => [e, () => t({ editor: this.editor })])))), {
2456
+ plugins: n,
2457
+ inputRules: r
2516
2458
  });
2517
2459
  }
2518
2460
  getExtensions() {
@@ -2555,63 +2497,63 @@ function gi(e, t) {
2555
2497
  //#endregion
2556
2498
  //#region src/api/blockManipulation/selections/selection.ts
2557
2499
  function _i(e) {
2558
- let t = g(e);
2559
2500
  if (e.selection.empty || "node" in e.selection) return;
2560
- let n = e.doc.resolve(C(e.doc, e.selection.from).posBeforeNode), r = e.doc.resolve(C(e.doc, e.selection.to).posBeforeNode), i = (r, i) => {
2561
- let a = n.posAtIndex(r, i), o = e.doc.resolve(a).nodeAfter;
2562
- if (!o) throw Error(`Error getting selection - node not found at position ${a}`);
2563
- return m(o, t);
2564
- }, a = [], o = n.sharedDepth(r.pos), s = n.index(o), c = r.index(o);
2565
- if (n.depth > o) {
2566
- a.push(m(n.nodeAfter, t));
2567
- for (let e = n.depth; e > o; e--) if (n.node(e).type.isInGroup("childContainer")) {
2568
- let t = n.index(e) + 1, r = n.node(e).childCount;
2569
- for (let n = t; n < r; n++) a.push(i(n, e));
2570
- }
2571
- } else a.push(i(s, o));
2572
- for (let e = s + 1; e <= c; e++) a.push(i(e, o));
2573
- if (a.length === 0) throw Error(`Error getting selection - selection doesn't span any blocks (${e.selection})`);
2574
- return { blocks: a };
2575
- }
2576
- function vi(e, t, n) {
2577
- let i = typeof t == "string" ? t : t.id, a = typeof n == "string" ? n : n.id, o = re(g(e));
2578
- if (i === a) throw Error(`Attempting to set selection with the same anchor and head blocks (id ${i})`);
2579
- let s = r(i, e.doc);
2580
- if (!s) throw Error(`Block with ID ${i} not found`);
2581
- let c = r(a, e.doc);
2501
+ let t = e.doc.resolve(h(e.doc, e.selection.from).posBeforeNode), n = e.doc.resolve(h(e.doc, e.selection.to).posBeforeNode), r = (n, r) => {
2502
+ let i = t.posAtIndex(n, r), a = e.doc.resolve(i).nodeAfter;
2503
+ if (!a) throw Error(`Error getting selection - node not found at position ${i}`);
2504
+ return C(a, e.doc);
2505
+ }, i = [], a = t.sharedDepth(n.pos), o = t.index(a), s = n.index(a);
2506
+ if (t.depth > a) {
2507
+ i.push(C(t.nodeAfter, e.doc));
2508
+ for (let e = t.depth; e > a; e--) if (t.node(e).type.isInGroup("childContainer")) {
2509
+ let n = t.index(e) + 1, a = t.node(e).childCount;
2510
+ for (let t = n; t < a; t++) i.push(r(t, e));
2511
+ }
2512
+ } else i.push(r(o, a));
2513
+ for (let e = o + 1; e <= s; e++) i.push(r(e, a));
2514
+ if (i.length === 0) throw Error(`Error getting selection - selection doesn't span any blocks (${e.selection})`);
2515
+ return { blocks: i };
2516
+ }
2517
+ function vi(e, t, r) {
2518
+ let a = typeof t == "string" ? t : t.id, o = typeof r == "string" ? r : r.id, s = n(i(e));
2519
+ if (a === o) throw Error(`Attempting to set selection with the same anchor and head blocks (id ${a})`);
2520
+ let c = x(a, e.doc);
2582
2521
  if (!c) throw Error(`Block with ID ${a} not found`);
2583
- let l = x(s), u = x(c), d = o.blockSchema[l.blockNoteType], f = o.blockSchema[u.blockNoteType];
2584
- if (!l.isBlockContainer || d.content === "none") throw Error(`Attempting to set selection anchor in block without content (id ${i})`);
2522
+ let l = x(o, e.doc);
2523
+ if (!l) throw Error(`Block with ID ${o} not found`);
2524
+ let u = S(c), d = S(l), f = s.blockSchema[u.blockNoteType], p = s.blockSchema[d.blockNoteType];
2585
2525
  if (!u.isBlockContainer || f.content === "none") throw Error(`Attempting to set selection anchor in block without content (id ${a})`);
2586
- let p, m;
2587
- if (d.content === "table") {
2588
- let e = at.get(l.blockContent.node);
2589
- p = l.blockContent.beforePos + e.positionAt(0, 0, l.blockContent.node) + 1 + 2;
2590
- } else p = l.blockContent.beforePos + 1;
2526
+ if (!d.isBlockContainer || p.content === "none") throw Error(`Attempting to set selection anchor in block without content (id ${o})`);
2527
+ let m, h;
2591
2528
  if (f.content === "table") {
2592
- let t = at.get(u.blockContent.node), n = u.blockContent.beforePos + t.positionAt(t.height - 1, t.width - 1, u.blockContent.node) + 1;
2593
- m = n + e.doc.resolve(n).nodeAfter.nodeSize - 2;
2594
- } else m = u.blockContent.afterPos - 1;
2595
- e.setSelection(P.create(e.doc, p, m));
2529
+ let e = nt.get(u.blockContent.node);
2530
+ m = u.blockContent.beforePos + e.positionAt(0, 0, u.blockContent.node) + 1 + 2;
2531
+ } else m = u.blockContent.beforePos + 1;
2532
+ if (p.content === "table") {
2533
+ let t = nt.get(d.blockContent.node), n = d.blockContent.beforePos + t.positionAt(t.height - 1, t.width - 1, d.blockContent.node) + 1;
2534
+ h = n + e.doc.resolve(n).nodeAfter.nodeSize - 2;
2535
+ } else h = d.blockContent.afterPos - 1;
2536
+ e.setSelection(M.create(e.doc, m, h));
2596
2537
  }
2597
2538
  function yi(e, t = !1) {
2598
- let n = g(e), r = t ? gi(e.doc, e.selection) : e.selection, i = r.$from, a = r.$to;
2599
- for (; a.parentOffset >= a.parent.nodeSize - 2 && a.depth > 0;) a = e.doc.resolve(a.pos + 1);
2600
- for (; a.parentOffset === 0 && a.depth > 0;) a = e.doc.resolve(a.pos - 1);
2601
- for (; i.parentOffset === 0 && i.depth > 0;) i = e.doc.resolve(i.pos - 1);
2539
+ let n = t ? gi(e.doc, e.selection) : e.selection, r = n.$from, i = n.$to;
2602
2540
  for (; i.parentOffset >= i.parent.nodeSize - 2 && i.depth > 0;) i = e.doc.resolve(i.pos + 1);
2603
- let o = se(e.doc.slice(i.pos, a.pos, !0), n);
2541
+ for (; i.parentOffset === 0 && i.depth > 0;) i = e.doc.resolve(i.pos - 1);
2542
+ for (; r.parentOffset === 0 && r.depth > 0;) r = e.doc.resolve(r.pos - 1);
2543
+ for (; r.parentOffset >= r.parent.nodeSize - 2 && r.depth > 0;) r = e.doc.resolve(r.pos + 1);
2544
+ let a = de(e.doc.slice(r.pos, i.pos, !0));
2604
2545
  return {
2605
2546
  _meta: {
2606
- startPos: i.pos,
2607
- endPos: a.pos
2547
+ startPos: r.pos,
2548
+ endPos: i.pos
2608
2549
  },
2609
- ...o
2550
+ ...a
2610
2551
  };
2611
2552
  }
2612
2553
  //#endregion
2613
2554
  //#region src/editor/managers/SelectionManager.ts
2614
2555
  var bi = class {
2556
+ editor;
2615
2557
  constructor(e) {
2616
2558
  this.editor = e;
2617
2559
  }
@@ -2625,21 +2567,22 @@ var bi = class {
2625
2567
  return this.editor.transact((n) => vi(n, e, t));
2626
2568
  }
2627
2569
  getTextCursorPosition() {
2628
- return this.editor.transact((e) => Hn(e));
2570
+ return this.editor.transact((e) => Kn(e));
2629
2571
  }
2630
2572
  setTextCursorPosition(e, t = "start") {
2631
- return this.editor.transact((n) => Un(n, e, t));
2573
+ return this.editor.transact((n) => qn(n, e, t));
2632
2574
  }
2633
2575
  getSelectionBoundingBox() {
2634
2576
  if (!this.editor.prosemirrorView) return;
2635
2577
  let { selection: e } = this.editor.prosemirrorState, { ranges: t } = e, n = Math.min(...t.map((e) => e.$from.pos)), r = Math.max(...t.map((e) => e.$to.pos));
2636
- if ($e(e)) {
2578
+ if (Ze(e)) {
2637
2579
  let e = this.editor.prosemirrorView.nodeDOM(n);
2638
2580
  if (e) return e.getBoundingClientRect();
2639
2581
  }
2640
- return nt(this.editor.prosemirrorView, n, r).toJSON();
2582
+ return et(this.editor.prosemirrorView, n, r).toJSON();
2641
2583
  }
2642
2584
  }, xi = class {
2585
+ editor;
2643
2586
  constructor(e) {
2644
2587
  this.editor = e;
2645
2588
  }
@@ -2731,21 +2674,22 @@ function Si(e, t, n, r = { updateSelection: !0 }) {
2731
2674
  let { parent: t } = e.doc.resolve(i);
2732
2675
  t.isTextblock && !t.type.spec.code && !t.childCount && (--i, a += 1);
2733
2676
  }
2734
- return o ? e.insertText(c, i, a) : e.replaceWith(i, a, n), r.updateSelection && rt(e, e.steps.length - 1, -1), !0;
2677
+ return o ? e.insertText(c, i, a) : e.replaceWith(i, a, n), r.updateSelection && tt(e, e.steps.length - 1, -1), !0;
2735
2678
  }
2736
2679
  //#endregion
2737
2680
  //#region src/editor/managers/StyleManager.ts
2738
2681
  var Ci = class {
2682
+ editor;
2739
2683
  constructor(e) {
2740
2684
  this.editor = e;
2741
2685
  }
2742
- insertInlineContent(e, { updateSelection: n = !1 } = {}) {
2743
- let r = t(e, this.editor.pmSchema);
2686
+ insertInlineContent(e, { updateSelection: t = !1 } = {}) {
2687
+ let n = d(e, this.editor.pmSchema);
2744
2688
  this.editor.transact((e) => {
2745
2689
  Si(e, {
2746
2690
  from: e.selection.from,
2747
2691
  to: e.selection.to
2748
- }, r, { updateSelection: n });
2692
+ }, n, { updateSelection: t });
2749
2693
  });
2750
2694
  }
2751
2695
  getActiveStyles() {
@@ -2768,7 +2712,7 @@ var Ci = class {
2768
2712
  if (!e) throw Error(`style ${t} not found in styleSchema`);
2769
2713
  if (e.propSchema === "boolean") this.editor._tiptapEditor.commands.setMark(t);
2770
2714
  else if (e.propSchema === "string") this.editor._tiptapEditor.commands.setMark(t, { stringValue: n });
2771
- else throw new w(e.propSchema);
2715
+ else throw new c(e.propSchema);
2772
2716
  }
2773
2717
  }
2774
2718
  removeStyles(e) {
@@ -2780,7 +2724,7 @@ var Ci = class {
2780
2724
  if (!e) throw Error(`style ${t} not found in styleSchema`);
2781
2725
  if (e.propSchema === "boolean") this.editor._tiptapEditor.commands.toggleMark(t);
2782
2726
  else if (e.propSchema === "string") this.editor._tiptapEditor.commands.toggleMark(t, { stringValue: n });
2783
- else throw new w(e.propSchema);
2727
+ else throw new c(e.propSchema);
2784
2728
  }
2785
2729
  }
2786
2730
  getSelectedText() {
@@ -2790,7 +2734,7 @@ var Ci = class {
2790
2734
  return this.editor.transact((t) => {
2791
2735
  let n = t.doc.resolve(e), r = n.marks().find((e) => e.type.name === "link");
2792
2736
  if (!r) return;
2793
- let i = Xe(n, r.type);
2737
+ let i = Je(n, r.type);
2794
2738
  if (i) return {
2795
2739
  href: r.attrs.href,
2796
2740
  from: i.from,
@@ -2830,10 +2774,10 @@ var Ci = class {
2830
2774
  //#endregion
2831
2775
  //#region src/editor/transformPasted.ts
2832
2776
  function wi(e) {
2833
- return qe(e.state.selection.$from, (e) => e.type.name === "tableCell" || e.type.name === "tableHeader") !== void 0;
2777
+ return Ge(e.state.selection.$from, (e) => e.type.name === "tableCell" || e.type.name === "tableHeader") !== void 0;
2834
2778
  }
2835
2779
  function Ti(e, t) {
2836
- let n = t.nodes.hardBreak, r = F.empty;
2780
+ let n = t.nodes.hardBreak, r = N.empty;
2837
2781
  return e.forEach((e) => {
2838
2782
  e.isTextblock && e.childCount > 0 ? (r = r.append(e.content), r = r.addToEnd(n.create())) : e.isText ? r = r.addToEnd(e) : e.isBlock && e.childCount > 0 && (r = r.append(Ti(e.content, t)), r = r.addToEnd(n.create()));
2839
2783
  }), r.lastChild?.type === n && (r = r.cut(0, r.size - 1)), r;
@@ -2842,7 +2786,7 @@ function Ei(e, t) {
2842
2786
  let n = [];
2843
2787
  return e.forEach((e, r, i) => {
2844
2788
  i !== t && n.push(e);
2845
- }), F.from(n);
2789
+ }), N.from(n);
2846
2790
  }
2847
2791
  function Di(e, t) {
2848
2792
  let n = [];
@@ -2854,10 +2798,10 @@ function Di(e, t) {
2854
2798
  n.push(i);
2855
2799
  }
2856
2800
  else n.push(e.child(r));
2857
- return e = F.from(n), e;
2801
+ return e = N.from(n), e;
2858
2802
  }
2859
2803
  function Oi(e, t) {
2860
- let n = F.from(e.content);
2804
+ let n = N.from(e.content);
2861
2805
  n = Di(n, t.state.schema);
2862
2806
  let r = ki(n, t, e);
2863
2807
  if (r) return r;
@@ -2865,9 +2809,9 @@ function Oi(e, t) {
2865
2809
  let e = !1;
2866
2810
  if (n.descendants((t) => {
2867
2811
  t.type.isInGroup("tableContent") && (e = !0);
2868
- }), !e && !t.state.schema.nodes.tableParagraph.validContent(n)) return new I(Ti(n, t.state.schema), 0, 0);
2812
+ }), !e && !t.state.schema.nodes.tableParagraph.validContent(n)) return new P(Ti(n, t.state.schema), 0, 0);
2869
2813
  }
2870
- if (!Ai(n, t)) return new I(n, e.openStart, e.openEnd);
2814
+ if (!Ai(n, t)) return new P(n, e.openStart, e.openEnd);
2871
2815
  for (let e = 0; e < n.childCount; e++) if (n.child(e).type.spec.group === "blockContent") {
2872
2816
  let r = [n.child(e)];
2873
2817
  if (e + 1 < n.childCount && n.child(e + 1).type.name === "blockGroup") {
@@ -2877,7 +2821,7 @@ function Oi(e, t) {
2877
2821
  let i = t.state.schema.nodes.blockContainer.createChecked(void 0, r);
2878
2822
  n = n.replaceChild(e, i);
2879
2823
  }
2880
- return new I(n, e.openStart, e.openEnd);
2824
+ return new P(n, e.openStart, e.openEnd);
2881
2825
  }
2882
2826
  function ki(e, t, n) {
2883
2827
  if (wi(t) || t.dragging) return null;
@@ -2886,7 +2830,7 @@ function ki(e, t, n) {
2886
2830
  let a = e.firstChild, o = a?.firstChild, s = o?.firstChild;
2887
2831
  if (a?.type.name !== "blockGroup" || o?.type.name !== "blockContainer" || s?.type.name !== "paragraph") return null;
2888
2832
  let c = i.type.create(i.attrs, s.content), l = o.copy(o.content.replaceChild(0, c)), u = a.copy(a.content.replaceChild(0, l));
2889
- return new I(e.replaceChild(0, u), n.openStart, n.openEnd);
2833
+ return new P(e.replaceChild(0, u), n.openStart, n.openEnd);
2890
2834
  }
2891
2835
  function Ai(e, t) {
2892
2836
  let n = e.childCount === 1, r = e.firstChild?.type.spec.content === "inline*", i = e.firstChild?.type.spec.content === "tableRow+";
@@ -2905,7 +2849,8 @@ var ji = {
2905
2849
  enableInputRules: !0,
2906
2850
  enablePasteRules: !0,
2907
2851
  enableCoreExtensions: !1
2908
- }, Mi = class e extends Fe {
2852
+ }, Mi = class e extends B {
2853
+ options;
2909
2854
  pmSchema;
2910
2855
  _tiptapEditor;
2911
2856
  elementRenderer = null;
@@ -2924,7 +2869,7 @@ var ji = {
2924
2869
  return new e(t ?? {});
2925
2870
  }
2926
2871
  constructor(e) {
2927
- super(), this.options = e, this.dictionary = e.dictionary || Pe, this.settings = { tables: {
2872
+ super(), this.options = e, this.dictionary = e.dictionary || Ne, this.settings = { tables: {
2928
2873
  splitCells: e?.tables?.splitCells ?? !1,
2929
2874
  cellBackgroundColor: e?.tables?.cellBackgroundColor ?? !1,
2930
2875
  cellTextColor: e?.tables?.cellTextColor ?? !1,
@@ -2950,59 +2895,57 @@ var ji = {
2950
2895
  }
2951
2896
  };
2952
2897
  }
2953
- this.resolveFileUrl = t.resolveFileUrl, this._eventManager = new Jt(this), this._extensionManager = new hi(this, t);
2954
- let n = this._extensionManager.getTiptapExtensions(), r = this._extensionManager.hasExtension("ySync") || this._extensionManager.hasExtension("liveblocksExtension");
2955
- r && t.initialContent && console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider");
2956
- let i = {
2898
+ this.resolveFileUrl = t.resolveFileUrl, this._eventManager = new Zt(this), this._extensionManager = new hi(this, t);
2899
+ let n = this._extensionManager.getTiptapExtensions(), r = {
2957
2900
  ...ji,
2958
2901
  ...t._tiptapOptions,
2959
2902
  element: null,
2960
2903
  autofocus: t.autofocus ?? !1,
2961
2904
  extensions: n,
2962
2905
  editorProps: {
2906
+ scrollMargin: {
2907
+ top: 72,
2908
+ bottom: 72,
2909
+ left: 0,
2910
+ right: 0
2911
+ },
2963
2912
  ...t._tiptapOptions?.editorProps,
2964
2913
  attributes: {
2965
2914
  tabIndex: "0",
2966
2915
  ...t._tiptapOptions?.editorProps?.attributes,
2967
2916
  ...t.domAttributes?.editor,
2968
- class: s("bn-editor", t.defaultStyles ? "bn-default-styles" : "", t.domAttributes?.editor?.class || "")
2917
+ class: o("bn-editor", t.defaultStyles ? "bn-default-styles" : "", t.domAttributes?.editor?.class || "")
2969
2918
  },
2970
2919
  transformPasted: Oi
2971
2920
  }
2972
2921
  };
2973
2922
  try {
2974
- let e = t.initialContent || (r ? [{
2975
- type: "paragraph",
2976
- id: "initialBlockId"
2977
- }] : [{
2923
+ let e = t.initialContent || [{
2978
2924
  type: "paragraph",
2979
2925
  id: u.options.generateID()
2980
- }]);
2981
- if (!Array.isArray(e) || e.length === 0) throw Error("initialContent must be a non-empty array of blocks, received: " + e);
2982
- let n = Qe(i.extensions), a = Ge({
2926
+ }];
2927
+ if (!Array.isArray(e) || e.length === 0) throw Error("initialContent must be a non-empty array of blocks, received: " + JSON.stringify(e));
2928
+ let n = Xe(r.extensions);
2929
+ n.cached.blockNoteEditor = this;
2930
+ let i = Ue({
2983
2931
  type: "doc",
2984
2932
  content: [{
2985
2933
  type: "blockGroup",
2986
- content: e.map((e) => y(e, n, this.schema.styleSchema).toJSON())
2934
+ content: e.map((e) => b(e, n, this.schema.styleSchema).toJSON())
2987
2935
  }]
2988
- }, n, i.parseOptions);
2989
- this._tiptapEditor = new Ue({
2990
- ...i,
2991
- content: a.toJSON()
2936
+ }, n, r.parseOptions);
2937
+ this._tiptapEditor = new Be({
2938
+ ...r,
2939
+ content: i.toJSON()
2992
2940
  }), this.pmSchema = this._tiptapEditor.schema;
2993
2941
  } catch (e) {
2994
2942
  throw Error("Error creating document from blocks passed as `initialContent`", { cause: e });
2995
2943
  }
2996
- let a, o = this.pmSchema.nodes.doc.createAndFill;
2997
- this.pmSchema.nodes.doc.createAndFill = (...e) => {
2998
- if (a) return a;
2999
- let t = o.apply(this.pmSchema.nodes.doc, e), n = JSON.parse(JSON.stringify(t.toJSON()));
3000
- return n.content[0].content[0].attrs.id = "initialBlockId", a = Re.fromJSON(this.pmSchema, n), a;
3001
- }, this.pmSchema.cached.blockNoteEditor = this, this._tiptapEditor.on("mount", () => {
2944
+ this.pmSchema.cached.blockNoteEditor = this, this._tiptapEditor.on("mount", () => {
3002
2945
  this.headless = !1;
3003
2946
  }), this._tiptapEditor.on("unmount", () => {
3004
2947
  this.headless = !0;
3005
- }), this._blockManager = new qt(this), this._exportManager = new Vn(this), this._selectionManager = new bi(this), this._stateManager = new xi(this), this._styleManager = new Ci(this), this.emit("create");
2948
+ }), this._blockManager = new Xt(this), this._exportManager = new Gn(this), this._selectionManager = new bi(this), this._stateManager = new xi(this), this._styleManager = new Ci(this), this.emit("create");
3006
2949
  }
3007
2950
  _blockManager;
3008
2951
  _eventManager;
@@ -3025,6 +2968,7 @@ var ji = {
3025
2968
  }
3026
2969
  unregisterExtension = (...e) => this._extensionManager.unregisterExtension(...e);
3027
2970
  registerExtension = (...e) => this._extensionManager.registerExtension(...e);
2971
+ replaceExtension = (...e) => this._extensionManager.replaceExtension(...e);
3028
2972
  getExtension = ((...e) => this._extensionManager.getExtension(...e));
3029
2973
  mount = (e, t) => {
3030
2974
  let n = e.getRootNode(), r = typeof ShadowRoot < "u" && n instanceof ShadowRoot;
@@ -3098,7 +3042,7 @@ var ji = {
3098
3042
  this._tiptapEditor.on("selectionUpdate", e);
3099
3043
  }
3100
3044
  onBeforeChange(e) {
3101
- return this._extensionManager.getExtension(pe).subscribe(e);
3045
+ return this._extensionManager.getExtension(ve).subscribe(e);
3102
3046
  }
3103
3047
  getTextCursorPosition() {
3104
3048
  return this._selectionManager.getTextCursorPosition();
@@ -3234,6 +3178,8 @@ var ji = {
3234
3178
  return this._exportManager.pasteMarkdown(e);
3235
3179
  }
3236
3180
  }, Ni = class {
3181
+ mappings;
3182
+ options;
3237
3183
  constructor(e, t, n) {
3238
3184
  this.mappings = t, this.options = n;
3239
3185
  }
@@ -3275,6 +3221,6 @@ function Fi(e, ...t) {
3275
3221
  return n;
3276
3222
  }
3277
3223
  //#endregion
3278
- export { L as _, gi as a, mt as b, zn as c, Gt as d, Kt as f, R as g, z as h, Mi as i, H as l, Dt as m, Pi as n, Gr as o, Wt as p, Ni as r, Bn as s, Fi as t, Ut as u, gt as v, pt as x, ht as y };
3224
+ export { I as C, dt as D, ft as E, L as S, pt as T, Dt as _, gi as a, Tt as b, Un as c, Jt as d, Yt as f, kt as g, Ot as h, Mi as i, U as l, B as m, Pi as n, vr as o, qt as p, Ni as r, Wn as s, Fi as t, Kt as u, z as v, mt as w, R as x, At as y };
3279
3225
 
3280
- //# sourceMappingURL=src-Dvmif2FY.js.map
3226
+ //# sourceMappingURL=src-DTF83Cl9.js.map