@blocknote/core 0.55.0 → 0.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (678) hide show
  1. package/NOTICE.txt +101 -0
  2. package/dist/BlockNoteExtension-U58cXw1g.js +64 -0
  3. package/dist/ThreadStore-CSEwCO0O.js +8 -0
  4. package/dist/{UserStore-C4TzkGEn.js → UserStore-BFv6NXA-.js} +3 -7
  5. package/dist/ar-DPJDxCQI.js +3 -0
  6. package/dist/blocknote.js +8 -6
  7. package/dist/blocks-BUX9dXi9.js +2063 -0
  8. package/dist/blocks.js +3 -2
  9. package/dist/comments.js +18 -19
  10. package/dist/de-CakHBokE.js +3 -0
  11. package/dist/emoji-data.js +102 -0
  12. package/dist/en-BGdzE27X.js +3 -0
  13. package/dist/{en-BAn9gxr-.js → en-Ne9rlj9Y.js} +42 -5
  14. package/dist/es-VeBX6MEG.js +3 -0
  15. package/dist/extensions-CEgexSyF.js +3091 -0
  16. package/dist/extensions.js +4 -4
  17. package/dist/fa-Dt7EYtKf.js +3 -0
  18. package/dist/fr-DUhhjxrJ.js +3 -0
  19. package/dist/getDefaultSlashMenuItems-DfDOr807.js +1939 -0
  20. package/dist/he-BShJg1dK.js +3 -0
  21. package/dist/hr-BXtyqmwg.js +3 -0
  22. package/dist/is-2Fb-0w_j.js +3 -0
  23. package/dist/it-CiZtVb3Y.js +3 -0
  24. package/dist/ja-CsxD3kEL.js +3 -0
  25. package/dist/ko-It6g03Cy.js +3 -0
  26. package/dist/locales.js +1418 -32
  27. package/dist/markGroups-BszXCkX8.js +18 -0
  28. package/dist/nb-CLao87La.js +3 -0
  29. package/dist/nl-JQSo8dht.js +3 -0
  30. package/dist/pl-DEMBgHEP.js +3 -0
  31. package/dist/pt-CBCdYAax.js +3 -0
  32. package/dist/ru-BQk_9Q-L.js +3 -0
  33. package/dist/sk-kgB2DtDL.js +3 -0
  34. package/dist/src-DksfoQmN.js +3574 -0
  35. package/dist/style.css +1 -1
  36. package/dist/tr-DkcSXX8f.js +3 -0
  37. package/dist/uk-Bib-e6bV.js +3 -0
  38. package/dist/uz-B2jaKhJb.js +3 -0
  39. package/dist/vi-V_GFRxE8.js +3 -0
  40. package/dist/y.js +1284 -559
  41. package/dist/yjs.js +211 -171
  42. package/dist/zh-hant-2ZrAkFnC.js +3 -0
  43. package/dist/zh-jglyCmjs.js +3 -0
  44. package/package.json +51 -27
  45. package/src/fonts/inter.css +111 -0
  46. package/types/src/api/blockManipulation/commands/insertBlocks/insertBlocks.d.ts +2 -1
  47. package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.d.ts +24 -24
  48. package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.d.ts +3 -2
  49. package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.d.ts +1 -1
  50. package/types/src/api/blockManipulation/commands/splitBlock/splitBlock.d.ts +2 -2
  51. package/types/src/api/blockManipulation/layoutBlocks/fixLayoutBlock.d.ts +34 -0
  52. package/types/src/api/blockManipulation/layoutBlocks/layoutBlocks.fixture.d.ts +465 -0
  53. package/types/src/api/blockManipulation/setupTestEnv.d.ts +15 -69
  54. package/types/src/api/blockManipulation/tables/tables.d.ts +9 -4
  55. package/types/src/api/clipboard/fromClipboard/normalizeOfficeHTML.d.ts +5 -0
  56. package/types/src/api/combineTransactionSteps.d.ts +12 -0
  57. package/types/src/api/exporters/markdown/wrapWithDelimiter.d.ts +6 -0
  58. package/types/src/api/getBlockInfoFromPos.d.ts +218 -44
  59. package/types/src/api/{getChangedRange.d.ts → getChangedRangeWithAttrs.d.ts} +1 -1
  60. package/types/src/api/getChangedRanges.d.ts +23 -0
  61. package/types/src/api/nodeConversions/fragmentToBlocks.d.ts +0 -3
  62. package/types/src/api/parsers/markdown/autolink.d.ts +5 -0
  63. package/types/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.d.ts +4 -0
  64. package/types/src/blocks/ToggleWrapper/createToggleFrame.d.ts +29 -0
  65. package/types/src/blocks/defaultBlockTypeItems.d.ts +37 -0
  66. package/types/src/blocks/defaultBlocks.d.ts +10 -0
  67. package/types/src/blocks/index.d.ts +2 -1
  68. package/types/src/editor/BlockNoteEditor.d.ts +38 -9
  69. package/types/src/editor/managers/BlockManager.d.ts +4 -3
  70. package/types/src/editor/managers/ExtensionManager/index.d.ts +19 -7
  71. package/types/src/editor/managers/StateManager.d.ts +1 -1
  72. package/types/src/editor/managers/StyleManager.d.ts +2 -1
  73. package/types/src/editor/transformPasted.d.ts +1 -1
  74. package/types/src/emoji-data/frimousse/ar.d.ts +2 -0
  75. package/types/src/emoji-data/frimousse/common.d.ts +3 -0
  76. package/types/src/emoji-data/frimousse/de.d.ts +2 -0
  77. package/types/src/emoji-data/frimousse/en.d.ts +2 -0
  78. package/types/src/emoji-data/frimousse/es.d.ts +2 -0
  79. package/types/src/emoji-data/frimousse/fa.d.ts +2 -0
  80. package/types/src/emoji-data/frimousse/fr.d.ts +2 -0
  81. package/types/src/emoji-data/frimousse/he.d.ts +2 -0
  82. package/types/src/emoji-data/frimousse/hr.d.ts +2 -0
  83. package/types/src/emoji-data/frimousse/is.d.ts +2 -0
  84. package/types/src/emoji-data/frimousse/it.d.ts +2 -0
  85. package/types/src/emoji-data/frimousse/ja.d.ts +2 -0
  86. package/types/src/emoji-data/frimousse/ko.d.ts +2 -0
  87. package/types/src/emoji-data/frimousse/loadFrimousseData.d.ts +2 -0
  88. package/types/src/emoji-data/frimousse/nb.d.ts +2 -0
  89. package/types/src/emoji-data/frimousse/nl.d.ts +2 -0
  90. package/types/src/emoji-data/frimousse/pl.d.ts +2 -0
  91. package/types/src/emoji-data/frimousse/pt.d.ts +2 -0
  92. package/types/src/emoji-data/frimousse/ru.d.ts +2 -0
  93. package/types/src/emoji-data/frimousse/sk.d.ts +2 -0
  94. package/types/src/emoji-data/frimousse/tr.d.ts +2 -0
  95. package/types/src/emoji-data/frimousse/types.d.ts +21 -0
  96. package/types/src/emoji-data/frimousse/uk.d.ts +2 -0
  97. package/types/src/emoji-data/frimousse/uz.d.ts +2 -0
  98. package/types/src/emoji-data/frimousse/vi.d.ts +2 -0
  99. package/types/src/emoji-data/frimousse/zh-hant.d.ts +2 -0
  100. package/types/src/emoji-data/frimousse/zh.d.ts +2 -0
  101. package/types/src/emoji-data/index.d.ts +3 -0
  102. package/types/src/emoji-data/searchEmojis.d.ts +5 -0
  103. package/types/src/exporter/Exporter.d.ts +11 -4
  104. package/types/src/exporter/mapping.d.ts +13 -1
  105. package/types/src/extensions/DropCursor/DropCursor.d.ts +1 -1
  106. package/types/src/extensions/DropCursor/dropIntoChildren.d.ts +38 -0
  107. package/types/src/extensions/Loading/Loading.d.ts +11 -0
  108. package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.d.ts +1 -1
  109. package/types/src/extensions/ReadOnly/ReadOnly.d.ts +21 -0
  110. package/types/src/extensions/SideMenu/MultipleNodeSelection.d.ts +13 -4
  111. package/types/src/extensions/SideMenu/SideMenu.d.ts +51 -89
  112. package/types/src/extensions/SideMenu/blockDropHandling.d.ts +11 -0
  113. package/types/src/extensions/SideMenu/blockGeometry.d.ts +22 -0
  114. package/types/src/extensions/SideMenu/dragging.d.ts +0 -4
  115. package/types/src/extensions/SideMenu/sideMenuHover.d.ts +58 -0
  116. package/types/src/extensions/Versioning/Versioning.d.ts +36 -311
  117. package/types/src/extensions/Versioning/createVersioning.d.ts +32 -0
  118. package/types/src/extensions/Versioning/formatVersionDate.d.ts +7 -0
  119. package/types/src/extensions/Versioning/inMemoryVersioning.d.ts +65 -36
  120. package/types/src/extensions/Versioning/index.d.ts +4 -0
  121. package/types/src/extensions/Versioning/scrollToFirstChange.d.ts +18 -0
  122. package/types/src/extensions/Versioning/types.d.ts +245 -0
  123. package/types/src/extensions/Versioning/versioningState.d.ts +49 -0
  124. package/types/src/extensions/blockDOM.d.ts +37 -0
  125. package/types/src/extensions/index.d.ts +3 -2
  126. package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.d.ts +1 -0
  127. package/types/src/i18n/dictionary.d.ts +4 -1
  128. package/types/src/i18n/locales/en.d.ts +38 -0
  129. package/types/src/i18n/locales/fa.d.ts +38 -0
  130. package/types/src/i18n/locales/index.d.ts +1 -0
  131. package/types/src/i18n/locales/sk.d.ts +38 -0
  132. package/types/src/i18n/locales/tr.d.ts +378 -0
  133. package/types/src/index.d.ts +5 -3
  134. package/types/src/pm-nodes/BlockContainer.d.ts +6 -0
  135. package/types/src/schema/blocks/children.d.ts +39 -0
  136. package/types/src/schema/blocks/createSpec.d.ts +13 -0
  137. package/types/src/schema/blocks/frame.d.ts +109 -0
  138. package/types/src/schema/blocks/internal.d.ts +6 -0
  139. package/types/src/schema/blocks/keyboard.d.ts +111 -0
  140. package/types/src/schema/blocks/layoutBlockAttributes.d.ts +9 -0
  141. package/types/src/schema/blocks/meta.d.ts +14 -0
  142. package/types/src/schema/blocks/types.d.ts +228 -15
  143. package/types/src/schema/blocks/validateChildren.d.ts +5 -0
  144. package/types/src/schema/dataAttributes.d.ts +19 -0
  145. package/types/src/schema/index.d.ts +3 -0
  146. package/types/src/schema/inlineContent/createSpec.d.ts +2 -1
  147. package/types/src/schema/inlineContent/internal.d.ts +1 -1
  148. package/types/src/schema/inlineContent/types.d.ts +2 -4
  149. package/types/src/schema/markGroups.d.ts +8 -0
  150. package/types/src/schema/styles/createSpec.d.ts +2 -1
  151. package/types/src/schema/styles/internal.d.ts +4 -1
  152. package/types/src/schema/styles/types.d.ts +2 -0
  153. package/types/src/user/userColors.d.ts +24 -3
  154. package/types/src/y/comments/RESTYjsThreadStore.d.ts +1 -1
  155. package/types/src/y/comments/YjsThreadStore.d.ts +1 -1
  156. package/types/src/y/comments/YjsThreadStoreBase.d.ts +2 -2
  157. package/types/src/y/comments/yjsHelpers.d.ts +5 -5
  158. package/types/src/y/extensions/AttributionExtension.d.ts +19 -21
  159. package/types/src/y/extensions/DiffVersioningExtension.d.ts +9 -4
  160. package/types/src/y/extensions/ForkYDoc.d.ts +3 -1
  161. package/types/src/y/extensions/Versioning.d.ts +4 -15
  162. package/types/src/y/extensions/YAttributionMarks.d.ts +13 -2
  163. package/types/src/y/extensions/YCursorPlugin.d.ts +1 -0
  164. package/types/src/y/extensions/YSync.d.ts +4 -18
  165. package/types/src/y/extensions/blockMatchNodes.d.ts +0 -22
  166. package/types/src/y/extensions/index.d.ts +27 -44
  167. package/types/src/y/extensions/persistentBlockGroups.d.ts +189 -0
  168. package/types/src/y/extensions/snapshotCodec.d.ts +13 -0
  169. package/types/src/y/extensions/snapshotPreview.d.ts +21 -0
  170. package/types/src/y/index.d.ts +1 -0
  171. package/types/src/y/utils.d.ts +39 -19
  172. package/types/src/y/versioning/index.d.ts +1 -1
  173. package/types/src/y/versioning/yhub.d.ts +71 -86
  174. package/types/src/y/versioning/yhubClient.d.ts +67 -0
  175. package/types/src/yjs/extensions/ForkYDoc.d.ts +2 -0
  176. package/types/src/yjs/extensions/Versioning.d.ts +37 -22
  177. package/types/src/yjs/extensions/YUndo.d.ts +3 -2
  178. package/types/src/yjs/extensions/index.d.ts +3 -2
  179. package/types/src/yjs/index.d.ts +1 -0
  180. package/dist/BlockNoteExtension-BJCLnwrE.cjs +0 -2
  181. package/dist/BlockNoteExtension-BJCLnwrE.cjs.map +0 -1
  182. package/dist/BlockNoteExtension-CbvDA0F7.js +0 -80
  183. package/dist/BlockNoteExtension-CbvDA0F7.js.map +0 -1
  184. package/dist/ThreadStore-Bx-gSEh1.cjs +0 -2
  185. package/dist/ThreadStore-Bx-gSEh1.cjs.map +0 -1
  186. package/dist/ThreadStore-et9wB5Xt.js +0 -11
  187. package/dist/ThreadStore-et9wB5Xt.js.map +0 -1
  188. package/dist/UserStore-C4TzkGEn.js.map +0 -1
  189. package/dist/UserStore-mj3fXW4D.cjs +0 -2
  190. package/dist/UserStore-mj3fXW4D.cjs.map +0 -1
  191. package/dist/blocknote.cjs +0 -1
  192. package/dist/blocks-DLgTreVu.cjs +0 -12
  193. package/dist/blocks-DLgTreVu.cjs.map +0 -1
  194. package/dist/blocks-DaEUT0O1.js +0 -3527
  195. package/dist/blocks-DaEUT0O1.js.map +0 -1
  196. package/dist/blocks.cjs +0 -1
  197. package/dist/comments.cjs +0 -2
  198. package/dist/comments.cjs.map +0 -1
  199. package/dist/comments.js.map +0 -1
  200. package/dist/en-BAn9gxr-.js.map +0 -1
  201. package/dist/en-CHnrV5l8.cjs +0 -2
  202. package/dist/en-CHnrV5l8.cjs.map +0 -1
  203. package/dist/extensions-B1JQURVF.js +0 -2138
  204. package/dist/extensions-B1JQURVF.js.map +0 -1
  205. package/dist/extensions-CZkqKzJO.cjs +0 -58
  206. package/dist/extensions-CZkqKzJO.cjs.map +0 -1
  207. package/dist/extensions.cjs +0 -1
  208. package/dist/locales.cjs +0 -2
  209. package/dist/locales.cjs.map +0 -1
  210. package/dist/locales.js.map +0 -1
  211. package/dist/src-D5w0XAHX.js +0 -3379
  212. package/dist/src-D5w0XAHX.js.map +0 -1
  213. package/dist/src-th5uZEvx.cjs +0 -23
  214. package/dist/src-th5uZEvx.cjs.map +0 -1
  215. package/dist/webpack-stats.json +0 -1
  216. package/dist/y.cjs +0 -2
  217. package/dist/y.cjs.map +0 -1
  218. package/dist/y.js.map +0 -1
  219. package/dist/yjs.cjs +0 -2
  220. package/dist/yjs.cjs.map +0 -1
  221. package/dist/yjs.js.map +0 -1
  222. package/src/api/README.md +0 -8
  223. package/src/api/__snapshots__/blocks-deleted-nested-deep.json +0 -26
  224. package/src/api/__snapshots__/blocks-deleted-nested.json +0 -68
  225. package/src/api/__snapshots__/blocks-deleted.json +0 -26
  226. package/src/api/__snapshots__/blocks-indented-changed.json +0 -129
  227. package/src/api/__snapshots__/blocks-inserted-nested.json +0 -62
  228. package/src/api/__snapshots__/blocks-inserted.json +0 -20
  229. package/src/api/__snapshots__/blocks-moved-deeper-into-nesting.json +0 -164
  230. package/src/api/__snapshots__/blocks-moved-down-twice-in-same-parent.json +0 -44
  231. package/src/api/__snapshots__/blocks-moved-insert-changes-sibling-order.json +0 -26
  232. package/src/api/__snapshots__/blocks-moved-multiple-in-same-transaction.json +0 -188
  233. package/src/api/__snapshots__/blocks-moved-nested-sibling-reorder.json +0 -180
  234. package/src/api/__snapshots__/blocks-moved-to-different-parent.json +0 -78
  235. package/src/api/__snapshots__/blocks-moved-to-root-level.json +0 -78
  236. package/src/api/__snapshots__/blocks-moved-up-down-in-same-parent.json +0 -44
  237. package/src/api/__snapshots__/blocks-moved-up-down-in-same-transaction.json +0 -44
  238. package/src/api/__snapshots__/blocks-outdented-changed.json +0 -129
  239. package/src/api/__snapshots__/blocks-updated-content-inserted.json +0 -42
  240. package/src/api/__snapshots__/blocks-updated-multiple-insert.json +0 -50
  241. package/src/api/__snapshots__/blocks-updated-multiple.json +0 -82
  242. package/src/api/__snapshots__/blocks-updated-nested-deep.json +0 -42
  243. package/src/api/__snapshots__/blocks-updated-nested-multiple.json +0 -118
  244. package/src/api/__snapshots__/blocks-updated-nested.json +0 -78
  245. package/src/api/__snapshots__/blocks-updated-single.json +0 -42
  246. package/src/api/__snapshots__/blocks-updated.json +0 -42
  247. package/src/api/blockManipulation/__snapshots__/transactions.test.ts.snap +0 -34
  248. package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +0 -4570
  249. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +0 -176
  250. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +0 -56
  251. package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +0 -2761
  252. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +0 -147
  253. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +0 -199
  254. package/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap +0 -13625
  255. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +0 -375
  256. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +0 -409
  257. package/src/api/blockManipulation/commands/nestBlock/__snapshots__/nestBlock.test.ts.snap +0 -952
  258. package/src/api/blockManipulation/commands/nestBlock/nestBlock.test.ts +0 -661
  259. package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +0 -208
  260. package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +0 -5710
  261. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +0 -235
  262. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +0 -135
  263. package/src/api/blockManipulation/commands/replaceBlocks/util/fixColumnList.ts +0 -173
  264. package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +0 -3507
  265. package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +0 -151
  266. package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +0 -58
  267. package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +0 -15085
  268. package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +0 -978
  269. package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +0 -685
  270. package/src/api/blockManipulation/getBlock/getBlock.ts +0 -111
  271. package/src/api/blockManipulation/insertContentAt.ts +0 -83
  272. package/src/api/blockManipulation/selections/selection.ts +0 -267
  273. package/src/api/blockManipulation/selections/textCursorPosition.ts +0 -118
  274. package/src/api/blockManipulation/setupTestEnv.ts +0 -191
  275. package/src/api/blockManipulation/tables/tables.test.ts +0 -2127
  276. package/src/api/blockManipulation/tables/tables.ts +0 -887
  277. package/src/api/clipboard/fromClipboard/acceptedMIMETypes.ts +0 -8
  278. package/src/api/clipboard/fromClipboard/fileDropExtension.ts +0 -55
  279. package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +0 -209
  280. package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +0 -38
  281. package/src/api/clipboard/fromClipboard/pasteExtension.ts +0 -157
  282. package/src/api/clipboard/toClipboard/copyExtension.ts +0 -299
  283. package/src/api/exporters/html/externalHTMLExporter.ts +0 -76
  284. package/src/api/exporters/html/internalHTMLSerializer.ts +0 -182
  285. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +0 -435
  286. package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +0 -253
  287. package/src/api/exporters/markdown/htmlToMarkdown.ts +0 -884
  288. package/src/api/exporters/markdown/markdownExporter.ts +0 -41
  289. package/src/api/getBlockInfoFromPos.test.ts +0 -256
  290. package/src/api/getBlockInfoFromPos.ts +0 -291
  291. package/src/api/getBlocksChangedByTransaction.test.ts +0 -783
  292. package/src/api/getBlocksChangedByTransaction.ts +0 -458
  293. package/src/api/getChangedRange.ts +0 -54
  294. package/src/api/nodeConversions/blockToNode.test.ts +0 -113
  295. package/src/api/nodeConversions/blockToNode.ts +0 -399
  296. package/src/api/nodeConversions/fragmentToBlocks.ts +0 -63
  297. package/src/api/nodeConversions/nodeToBlock.ts +0 -665
  298. package/src/api/nodeUtil.ts +0 -46
  299. package/src/api/parsers/html/parseHTML.ts +0 -80
  300. package/src/api/parsers/html/util/__snapshots__/nestedLists.test.ts.snap +0 -144
  301. package/src/api/parsers/html/util/nestedLists.test.ts +0 -165
  302. package/src/api/parsers/html/util/nestedLists.ts +0 -123
  303. package/src/api/parsers/html/util/normalizeWhitespace.ts +0 -87
  304. package/src/api/parsers/markdown/detectMarkdown.test.ts +0 -211
  305. package/src/api/parsers/markdown/detectMarkdown.ts +0 -61
  306. package/src/api/parsers/markdown/markdownToHtml.ts +0 -1340
  307. package/src/api/parsers/markdown/parseMarkdown.ts +0 -24
  308. package/src/api/pmUtil.ts +0 -79
  309. package/src/api/positionMapping.test.ts +0 -209
  310. package/src/api/positionMapping.ts +0 -42
  311. package/src/blocks/Audio/block.ts +0 -171
  312. package/src/blocks/Audio/parseAudioElement.ts +0 -5
  313. package/src/blocks/BlockNoteSchema.ts +0 -59
  314. package/src/blocks/Code/CodeBlockOptions.ts +0 -83
  315. package/src/blocks/Code/block.test.ts +0 -265
  316. package/src/blocks/Code/block.ts +0 -56
  317. package/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.ts +0 -120
  318. package/src/blocks/Code/helpers/parse/parsePreCode.ts +0 -45
  319. package/src/blocks/Code/helpers/render/createCodeBlock.ts +0 -98
  320. package/src/blocks/Code/helpers/toExternalHTML/createPreCode.ts +0 -14
  321. package/src/blocks/Divider/block.ts +0 -49
  322. package/src/blocks/File/block.ts +0 -95
  323. package/src/blocks/File/helpers/parse/parseEmbedElement.ts +0 -5
  324. package/src/blocks/File/helpers/parse/parseFigureElement.ts +0 -16
  325. package/src/blocks/File/helpers/render/createAddFileButton.ts +0 -69
  326. package/src/blocks/File/helpers/render/createFileBlockWrapper.ts +0 -88
  327. package/src/blocks/File/helpers/render/createFileNameWithIcon.ts +0 -37
  328. package/src/blocks/File/helpers/render/createResizableFileBlockWrapper.ts +0 -271
  329. package/src/blocks/File/helpers/toExternalHTML/createFigureWithCaption.ts +0 -13
  330. package/src/blocks/File/helpers/toExternalHTML/createLinkWithCaption.ts +0 -15
  331. package/src/blocks/Heading/block.ts +0 -188
  332. package/src/blocks/Image/block.ts +0 -193
  333. package/src/blocks/Image/parseImageElement.ts +0 -7
  334. package/src/blocks/ListItem/BulletListItem/block.ts +0 -127
  335. package/src/blocks/ListItem/CheckListItem/block.test.ts +0 -61
  336. package/src/blocks/ListItem/CheckListItem/block.ts +0 -182
  337. package/src/blocks/ListItem/ListItemKeyboardShortcuts.ts +0 -63
  338. package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.ts +0 -352
  339. package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +0 -242
  340. package/src/blocks/ListItem/NumberedListItem/block.ts +0 -141
  341. package/src/blocks/ListItem/ToggleListItem/block.ts +0 -128
  342. package/src/blocks/ListItem/getListItemContent.ts +0 -115
  343. package/src/blocks/PageBreak/block.ts +0 -72
  344. package/src/blocks/PageBreak/getPageBreakSlashMenuItems.ts +0 -47
  345. package/src/blocks/Paragraph/block.ts +0 -80
  346. package/src/blocks/Quote/block.ts +0 -99
  347. package/src/blocks/README.md +0 -3
  348. package/src/blocks/Table/TableExtension.test.ts +0 -231
  349. package/src/blocks/Table/TableExtension.ts +0 -115
  350. package/src/blocks/Table/block.ts +0 -500
  351. package/src/blocks/ToggleWrapper/createToggleWrapper.ts +0 -197
  352. package/src/blocks/Video/block.ts +0 -142
  353. package/src/blocks/Video/parseVideoElement.ts +0 -7
  354. package/src/blocks/defaultBlockHelpers.ts +0 -113
  355. package/src/blocks/defaultBlockTypeGuards.ts +0 -167
  356. package/src/blocks/defaultBlocks.ts +0 -208
  357. package/src/blocks/defaultProps.ts +0 -165
  358. package/src/blocks/getDetailsContent.ts +0 -77
  359. package/src/blocks/index.ts +0 -29
  360. package/src/blocks/utils/listItemEnterHandler.ts +0 -43
  361. package/src/comments/CommentEditorSubmitExtension.test.ts +0 -141
  362. package/src/comments/CommentEditorSubmitExtension.ts +0 -56
  363. package/src/comments/extension.ts +0 -396
  364. package/src/comments/index.ts +0 -8
  365. package/src/comments/mark.ts +0 -64
  366. package/src/comments/threadstore/DefaultThreadStoreAuth.ts +0 -106
  367. package/src/comments/threadstore/ThreadStore.ts +0 -130
  368. package/src/comments/threadstore/ThreadStoreAuth.ts +0 -13
  369. package/src/comments/threadstore/TipTapThreadStore.ts +0 -292
  370. package/src/comments/threadstore/tiptap/types.ts +0 -131
  371. package/src/comments/types.ts +0 -121
  372. package/src/editor/Block.css +0 -1366
  373. package/src/editor/BlockNoteEditor.test.ts +0 -278
  374. package/src/editor/BlockNoteEditor.ts +0 -1497
  375. package/src/editor/BlockNoteExtension.test.ts +0 -103
  376. package/src/editor/BlockNoteExtension.ts +0 -246
  377. package/src/editor/README.md +0 -3
  378. package/src/editor/cursorPositionTypes.ts +0 -17
  379. package/src/editor/defaultColors.ts +0 -77
  380. package/src/editor/editor.css +0 -197
  381. package/src/editor/managers/BlockManager.ts +0 -255
  382. package/src/editor/managers/EventManager.browser.test.ts +0 -334
  383. package/src/editor/managers/EventManager.ts +0 -260
  384. package/src/editor/managers/ExportManager.ts +0 -137
  385. package/src/editor/managers/ExtensionManager/ExtensionManager.test.ts +0 -336
  386. package/src/editor/managers/ExtensionManager/extensions.ts +0 -191
  387. package/src/editor/managers/ExtensionManager/index.ts +0 -697
  388. package/src/editor/managers/ExtensionManager/symbol.ts +0 -5
  389. package/src/editor/managers/SelectionManager.ts +0 -120
  390. package/src/editor/managers/StateManager.ts +0 -251
  391. package/src/editor/managers/StyleManager.browser.test.ts +0 -122
  392. package/src/editor/managers/StyleManager.test.ts +0 -98
  393. package/src/editor/managers/StyleManager.ts +0 -278
  394. package/src/editor/managers/index.ts +0 -8
  395. package/src/editor/performance.test.ts +0 -192
  396. package/src/editor/selectionTypes.ts +0 -14
  397. package/src/editor/transformPasted.test.ts +0 -295
  398. package/src/editor/transformPasted.ts +0 -293
  399. package/src/exporter/ExportImage.ts +0 -50
  400. package/src/exporter/Exporter.test.ts +0 -186
  401. package/src/exporter/Exporter.ts +0 -155
  402. package/src/exporter/index.ts +0 -3
  403. package/src/exporter/mapping.ts +0 -79
  404. package/src/extensions/BlockChange/BlockChange.ts +0 -67
  405. package/src/extensions/DropCursor/DropCursor.ts +0 -263
  406. package/src/extensions/DropCursor/utils.ts +0 -195
  407. package/src/extensions/FilePanel/FilePanel.ts +0 -41
  408. package/src/extensions/FormattingToolbar/FormattingToolbar.ts +0 -151
  409. package/src/extensions/History/History.ts +0 -11
  410. package/src/extensions/InlineContentBoundaryEdit/InlineContentBoundaryEdit.ts +0 -109
  411. package/src/extensions/LinkToolbar/LinkToolbar.ts +0 -76
  412. package/src/extensions/LinkToolbar/protocols.ts +0 -13
  413. package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.ts +0 -75
  414. package/src/extensions/Placeholder/Placeholder.ts +0 -149
  415. package/src/extensions/PositionMapping/PositionMapping.ts +0 -68
  416. package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +0 -120
  417. package/src/extensions/PreviousBlockType/PreviousBlockType.ts +0 -197
  418. package/src/extensions/README.md +0 -3
  419. package/src/extensions/ShowSelection/ShowSelection.ts +0 -61
  420. package/src/extensions/SideMenu/MultipleNodeSelection.ts +0 -89
  421. package/src/extensions/SideMenu/SideMenu.ts +0 -833
  422. package/src/extensions/SideMenu/dragging.ts +0 -213
  423. package/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.ts +0 -192
  424. package/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.ts +0 -142
  425. package/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.ts +0 -4
  426. package/src/extensions/SuggestionMenu/DefaultSuggestionItem.ts +0 -11
  427. package/src/extensions/SuggestionMenu/SuggestionMenu.test.ts +0 -309
  428. package/src/extensions/SuggestionMenu/SuggestionMenu.ts +0 -427
  429. package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +0 -76
  430. package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +0 -399
  431. package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.ts +0 -120
  432. package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.ts +0 -89
  433. package/src/extensions/SyntaxHighlighting/inlineHighlight.test.ts +0 -135
  434. package/src/extensions/SyntaxHighlighting/shiki.ts +0 -116
  435. package/src/extensions/TableHandles/TableHandles.browser.test.ts +0 -307
  436. package/src/extensions/TableHandles/TableHandles.ts +0 -1265
  437. package/src/extensions/TrailingNode/TrailingNode.ts +0 -233
  438. package/src/extensions/Versioning/Versioning.test.ts +0 -435
  439. package/src/extensions/Versioning/Versioning.ts +0 -628
  440. package/src/extensions/Versioning/inMemoryVersioning.test.ts +0 -469
  441. package/src/extensions/Versioning/inMemoryVersioning.ts +0 -273
  442. package/src/extensions/Versioning/index.ts +0 -2
  443. package/src/extensions/getDraggableBlockFromElement.ts +0 -19
  444. package/src/extensions/index.ts +0 -25
  445. package/src/extensions/tiptap-extensions/BackgroundColor/BackgroundColorExtension.ts +0 -17
  446. package/src/extensions/tiptap-extensions/HardBreak/HardBreak.ts +0 -35
  447. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts +0 -204
  448. package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +0 -1002
  449. package/src/extensions/tiptap-extensions/Link/helpers/autolink.ts +0 -179
  450. package/src/extensions/tiptap-extensions/Link/helpers/clickHandler.ts +0 -82
  451. package/src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts +0 -412
  452. package/src/extensions/tiptap-extensions/Link/helpers/pasteHandler.ts +0 -53
  453. package/src/extensions/tiptap-extensions/Link/helpers/tlds.ts +0 -7
  454. package/src/extensions/tiptap-extensions/Link/helpers/whitespace.ts +0 -13
  455. package/src/extensions/tiptap-extensions/Link/index.ts +0 -2
  456. package/src/extensions/tiptap-extensions/Link/link.test.ts +0 -945
  457. package/src/extensions/tiptap-extensions/Link/link.ts +0 -238
  458. package/src/extensions/tiptap-extensions/TextAlignment/TextAlignmentExtension.ts +0 -33
  459. package/src/extensions/tiptap-extensions/TextColor/TextColorExtension.ts +0 -17
  460. package/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.ts +0 -187
  461. package/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts +0 -336
  462. package/src/extensions/tiptap-extensions/index.ts +0 -7
  463. package/src/extensions-shared/UiElementPosition.ts +0 -4
  464. package/src/i18n/dictionary.ts +0 -17
  465. package/src/i18n/index.ts +0 -2
  466. package/src/i18n/locales/ar.ts +0 -411
  467. package/src/i18n/locales/de.ts +0 -445
  468. package/src/i18n/locales/en.ts +0 -426
  469. package/src/i18n/locales/es.ts +0 -424
  470. package/src/i18n/locales/fa.ts +0 -395
  471. package/src/i18n/locales/fr.ts +0 -472
  472. package/src/i18n/locales/he.ts +0 -426
  473. package/src/i18n/locales/hr.ts +0 -440
  474. package/src/i18n/locales/index.ts +0 -23
  475. package/src/i18n/locales/is.ts +0 -440
  476. package/src/i18n/locales/it.ts +0 -448
  477. package/src/i18n/locales/ja.ts +0 -466
  478. package/src/i18n/locales/ko.ts +0 -439
  479. package/src/i18n/locales/nl.ts +0 -427
  480. package/src/i18n/locales/no.ts +0 -444
  481. package/src/i18n/locales/pl.ts +0 -417
  482. package/src/i18n/locales/pt.ts +0 -419
  483. package/src/i18n/locales/ru.ts +0 -470
  484. package/src/i18n/locales/sk.ts +0 -424
  485. package/src/i18n/locales/uk.ts +0 -450
  486. package/src/i18n/locales/uz.ts +0 -460
  487. package/src/i18n/locales/vi.ts +0 -425
  488. package/src/i18n/locales/zh-tw.ts +0 -467
  489. package/src/i18n/locales/zh.ts +0 -467
  490. package/src/index.ts +0 -56
  491. package/src/locales.ts +0 -1
  492. package/src/pm-nodes/BlockContainer.ts +0 -91
  493. package/src/pm-nodes/BlockGroup.ts +0 -57
  494. package/src/pm-nodes/Doc.ts +0 -11
  495. package/src/pm-nodes/README.md +0 -141
  496. package/src/pm-nodes/index.ts +0 -3
  497. package/src/pm-nodes/suggestionMarks.ts +0 -43
  498. package/src/schema/README.md +0 -3
  499. package/src/schema/blocks/createSpec.test.ts +0 -123
  500. package/src/schema/blocks/createSpec.ts +0 -506
  501. package/src/schema/blocks/extendBlockSpec.test.ts +0 -188
  502. package/src/schema/blocks/internal.test.ts +0 -86
  503. package/src/schema/blocks/internal.ts +0 -255
  504. package/src/schema/blocks/types.ts +0 -702
  505. package/src/schema/contentTypePropagation.test.ts +0 -182
  506. package/src/schema/index.ts +0 -12
  507. package/src/schema/inlineContent/createSpec.test.ts +0 -161
  508. package/src/schema/inlineContent/createSpec.ts +0 -409
  509. package/src/schema/inlineContent/internal.ts +0 -136
  510. package/src/schema/inlineContent/types.ts +0 -204
  511. package/src/schema/markGroups.ts +0 -50
  512. package/src/schema/nodeViewMutations.test.ts +0 -146
  513. package/src/schema/nodeViewMutations.ts +0 -49
  514. package/src/schema/propTypes.ts +0 -61
  515. package/src/schema/schema.test.ts +0 -110
  516. package/src/schema/schema.ts +0 -236
  517. package/src/schema/styles/createSpec.ts +0 -140
  518. package/src/schema/styles/internal.ts +0 -155
  519. package/src/schema/styles/types.ts +0 -57
  520. package/src/style.css +0 -2
  521. package/src/user/UserStore.ts +0 -199
  522. package/src/user/createUserStore.test.ts +0 -126
  523. package/src/user/index.ts +0 -2
  524. package/src/user/userColors.ts +0 -72
  525. package/src/util/EventEmitter.ts +0 -59
  526. package/src/util/README.md +0 -3
  527. package/src/util/Store.test.ts +0 -132
  528. package/src/util/Store.ts +0 -135
  529. package/src/util/browser.ts +0 -54
  530. package/src/util/combineByGroup.ts +0 -25
  531. package/src/util/expandToWords.ts +0 -38
  532. package/src/util/string.ts +0 -36
  533. package/src/util/table.ts +0 -110
  534. package/src/util/topo-sort.test.ts +0 -125
  535. package/src/util/topo-sort.ts +0 -206
  536. package/src/util/typescript.ts +0 -17
  537. package/src/vite-env.d.ts +0 -7
  538. package/src/y/README.md +0 -5
  539. package/src/y/comments/RESTYjsThreadStore.ts +0 -138
  540. package/src/y/comments/YjsThreadStore.test.ts +0 -295
  541. package/src/y/comments/YjsThreadStore.ts +0 -358
  542. package/src/y/comments/YjsThreadStoreBase.ts +0 -50
  543. package/src/y/comments/index.ts +0 -3
  544. package/src/y/comments/yjsHelpers.ts +0 -125
  545. package/src/y/extensions/AttributionExtension.test.ts +0 -95
  546. package/src/y/extensions/AttributionExtension.ts +0 -378
  547. package/src/y/extensions/DiffVersioningExtension.test.ts +0 -193
  548. package/src/y/extensions/DiffVersioningExtension.ts +0 -228
  549. package/src/y/extensions/ForkYDoc.test.ts +0 -253
  550. package/src/y/extensions/ForkYDoc.ts +0 -108
  551. package/src/y/extensions/RelativePositionMapping.test.ts +0 -418
  552. package/src/y/extensions/RelativePositionMapping.ts +0 -49
  553. package/src/y/extensions/Suggestions.ts +0 -174
  554. package/src/y/extensions/Versioning.test.ts +0 -408
  555. package/src/y/extensions/Versioning.ts +0 -115
  556. package/src/y/extensions/YAttributionMarks.ts +0 -320
  557. package/src/y/extensions/YCursorPlugin.ts +0 -189
  558. package/src/y/extensions/YSync.ts +0 -125
  559. package/src/y/extensions/blockMatchNodes.ts +0 -182
  560. package/src/y/extensions/index.ts +0 -156
  561. package/src/y/index.ts +0 -4
  562. package/src/y/utils.test.ts +0 -1042
  563. package/src/y/utils.ts +0 -242
  564. package/src/y/versioning/__test__/fixtures/activity-all-after.bin +0 -0
  565. package/src/y/versioning/__test__/fixtures/activity-all-after.json +0 -50
  566. package/src/y/versioning/__test__/fixtures/activity-all.bin +0 -0
  567. package/src/y/versioning/__test__/fixtures/activity-all.json +0 -20
  568. package/src/y/versioning/__test__/fixtures/activity-filtered-after.bin +0 -0
  569. package/src/y/versioning/__test__/fixtures/activity-filtered-after.json +0 -32
  570. package/src/y/versioning/__test__/fixtures/activity-filtered-before.json +0 -1
  571. package/src/y/versioning/__test__/fixtures/changeset.bin +0 -0
  572. package/src/y/versioning/__test__/fixtures/patch-response.json +0 -4
  573. package/src/y/versioning/__test__/yhub.test.ts +0 -785
  574. package/src/y/versioning/index.ts +0 -1
  575. package/src/y/versioning/yhub.ts +0 -637
  576. package/src/yjs/README.md +0 -5
  577. package/src/yjs/comments/RESTYjsThreadStore.test.ts +0 -85
  578. package/src/yjs/comments/RESTYjsThreadStore.ts +0 -172
  579. package/src/yjs/comments/YjsThreadStore.test.ts +0 -295
  580. package/src/yjs/comments/YjsThreadStore.ts +0 -345
  581. package/src/yjs/comments/YjsThreadStoreBase.ts +0 -50
  582. package/src/yjs/comments/index.ts +0 -3
  583. package/src/yjs/comments/yjsHelpers.ts +0 -127
  584. package/src/yjs/extensions/FixUpSchema.test.ts +0 -421
  585. package/src/yjs/extensions/FixUpSchema.ts +0 -88
  586. package/src/yjs/extensions/ForkYDoc.test.ts +0 -253
  587. package/src/yjs/extensions/ForkYDoc.ts +0 -159
  588. package/src/yjs/extensions/RelativePositionMapping.test.ts +0 -418
  589. package/src/yjs/extensions/RelativePositionMapping.ts +0 -77
  590. package/src/yjs/extensions/Versioning.test.ts +0 -561
  591. package/src/yjs/extensions/Versioning.ts +0 -83
  592. package/src/yjs/extensions/YCursorPlugin.ts +0 -201
  593. package/src/yjs/extensions/YSync.ts +0 -16
  594. package/src/yjs/extensions/YUndo.ts +0 -12
  595. package/src/yjs/extensions/__snapshots__/fork-yjs-snap-editor-forked.json +0 -19
  596. package/src/yjs/extensions/__snapshots__/fork-yjs-snap-editor.json +0 -19
  597. package/src/yjs/extensions/__snapshots__/fork-yjs-snap-forked.html +0 -1
  598. package/src/yjs/extensions/__snapshots__/fork-yjs-snap.html +0 -1
  599. package/src/yjs/extensions/index.ts +0 -89
  600. package/src/yjs/extensions/schemaMigration/SchemaMigration.ts +0 -59
  601. package/src/yjs/extensions/schemaMigration/migrationRules/index.ts +0 -4
  602. package/src/yjs/extensions/schemaMigration/migrationRules/migrationRule.ts +0 -4
  603. package/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.test.ts +0 -130
  604. package/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.ts +0 -91
  605. package/src/yjs/index.ts +0 -3
  606. package/src/yjs/utils.test.ts +0 -1013
  607. package/src/yjs/utils.ts +0 -186
  608. package/types/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.d.ts +0 -1
  609. package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.d.ts +0 -1
  610. package/types/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.d.ts +0 -1
  611. package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.test.d.ts +0 -1
  612. package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.d.ts +0 -1
  613. package/types/src/api/blockManipulation/commands/replaceBlocks/util/fixColumnList.d.ts +0 -32
  614. package/types/src/api/blockManipulation/commands/splitBlock/splitBlock.test.d.ts +0 -1
  615. package/types/src/api/blockManipulation/commands/updateBlock/updateBlock.test.d.ts +0 -1
  616. package/types/src/api/blockManipulation/tables/tables.test.d.ts +0 -1
  617. package/types/src/api/getBlockInfoFromPos.test.d.ts +0 -1
  618. package/types/src/api/getBlocksChangedByTransaction.test.d.ts +0 -1
  619. package/types/src/api/nodeConversions/blockToNode.test.d.ts +0 -1
  620. package/types/src/api/parsers/html/util/nestedLists.test.d.ts +0 -1
  621. package/types/src/api/parsers/markdown/detectMarkdown.test.d.ts +0 -1
  622. package/types/src/api/positionMapping.test.d.ts +0 -1
  623. package/types/src/blocks/Code/block.test.d.ts +0 -1
  624. package/types/src/blocks/ListItem/CheckListItem/block.test.d.ts +0 -1
  625. package/types/src/blocks/ListItem/ListItemKeyboardShortcuts.d.ts +0 -2
  626. package/types/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.d.ts +0 -1
  627. package/types/src/blocks/Table/TableExtension.test.d.ts +0 -1
  628. package/types/src/blocks/ToggleWrapper/createToggleWrapper.d.ts +0 -15
  629. package/types/src/blocks/utils/listItemEnterHandler.d.ts +0 -2
  630. package/types/src/comments/CommentEditorSubmitExtension.test.d.ts +0 -1
  631. package/types/src/editor/BlockNoteEditor.test.d.ts +0 -1
  632. package/types/src/editor/BlockNoteExtension.test.d.ts +0 -1
  633. package/types/src/editor/managers/EventManager.browser.test.d.ts +0 -1
  634. package/types/src/editor/managers/ExtensionManager/ExtensionManager.test.d.ts +0 -1
  635. package/types/src/editor/managers/StyleManager.browser.test.d.ts +0 -1
  636. package/types/src/editor/managers/StyleManager.test.d.ts +0 -1
  637. package/types/src/editor/performance.test.d.ts +0 -1
  638. package/types/src/editor/transformPasted.test.d.ts +0 -1
  639. package/types/src/exporter/Exporter.test.d.ts +0 -1
  640. package/types/src/extensions/PreviousBlockType/PreviousBlockType.test.d.ts +0 -1
  641. package/types/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.d.ts +0 -4
  642. package/types/src/extensions/SuggestionMenu/SuggestionMenu.test.d.ts +0 -1
  643. package/types/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.d.ts +0 -4
  644. package/types/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.d.ts +0 -1
  645. package/types/src/extensions/SyntaxHighlighting/inlineHighlight.test.d.ts +0 -1
  646. package/types/src/extensions/TableHandles/TableHandles.browser.test.d.ts +0 -1
  647. package/types/src/extensions/Versioning/Versioning.test.d.ts +0 -1
  648. package/types/src/extensions/Versioning/inMemoryVersioning.test.d.ts +0 -1
  649. package/types/src/extensions/getDraggableBlockFromElement.d.ts +0 -5
  650. package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.d.ts +0 -1
  651. package/types/src/extensions/tiptap-extensions/Link/link.test.d.ts +0 -1
  652. package/types/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.d.ts +0 -4
  653. package/types/src/schema/blocks/createSpec.test.d.ts +0 -1
  654. package/types/src/schema/blocks/extendBlockSpec.test.d.ts +0 -1
  655. package/types/src/schema/blocks/internal.test.d.ts +0 -1
  656. package/types/src/schema/contentTypePropagation.test.d.ts +0 -1
  657. package/types/src/schema/inlineContent/createSpec.test.d.ts +0 -1
  658. package/types/src/schema/nodeViewMutations.test.d.ts +0 -1
  659. package/types/src/schema/schema.test.d.ts +0 -1
  660. package/types/src/user/createUserStore.test.d.ts +0 -1
  661. package/types/src/util/Store.test.d.ts +0 -1
  662. package/types/src/util/topo-sort.test.d.ts +0 -1
  663. package/types/src/y/comments/YjsThreadStore.test.d.ts +0 -1
  664. package/types/src/y/extensions/AttributionExtension.test.d.ts +0 -1
  665. package/types/src/y/extensions/DiffVersioningExtension.test.d.ts +0 -1
  666. package/types/src/y/extensions/ForkYDoc.test.d.ts +0 -1
  667. package/types/src/y/extensions/RelativePositionMapping.test.d.ts +0 -1
  668. package/types/src/y/extensions/Versioning.test.d.ts +0 -1
  669. package/types/src/y/utils.test.d.ts +0 -1
  670. package/types/src/y/versioning/__test__/yhub.test.d.ts +0 -1
  671. package/types/src/yjs/comments/RESTYjsThreadStore.test.d.ts +0 -1
  672. package/types/src/yjs/comments/YjsThreadStore.test.d.ts +0 -1
  673. package/types/src/yjs/extensions/FixUpSchema.test.d.ts +0 -1
  674. package/types/src/yjs/extensions/ForkYDoc.test.d.ts +0 -1
  675. package/types/src/yjs/extensions/RelativePositionMapping.test.d.ts +0 -1
  676. package/types/src/yjs/extensions/Versioning.test.d.ts +0 -1
  677. package/types/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.test.d.ts +0 -1
  678. package/types/src/yjs/utils.test.d.ts +0 -1
@@ -0,0 +1,3574 @@
1
+ import { B as e, Bt as t, Ft as n, Gt as r, Ht as i, It as a, J as o, Jt as s, Kt as c, Lt as l, Mt as u, N as d, Nt as f, Pt as p, Q as m, R as h, Rt as g, St as _, U as ee, Ut as te, Vt as v, W as ne, Wt as re, X as y, Xt as b, Y as ie, Yt as x, Z as ae, an as S, dt as oe, en as se, ft as ce, g as le, h as C, i as ue, in as w, m as T, o as de, p as fe, q as pe, qt as E, rn as me, rt as D, sn as he, tt as ge, xt as O, z as _e, zt as k } from "./getDefaultSlashMenuItems-DfDOr807.js";
2
+ import { Dt as ve, Et as ye, Lt as A, Tt as j, _t as be, ft as xe, t as Se, ut as Ce } from "./blocks-BUX9dXi9.js";
3
+ import { r as we } from "./markGroups-BszXCkX8.js";
4
+ import { C as Te, D as Ee, E as De, I as Oe, L as ke, M as Ae, N as je, O as Me, P as Ne, R as Pe, S as Fe, T as Ie, U as M, V as Le, _ as Re, b as ze, g as Be, h as Ve, k as He, l as Ue, u as We, w as Ge, x as Ke, y as qe, z as Je } from "./extensions-CEgexSyF.js";
5
+ import { r as Ye, t as Xe } from "./BlockNoteExtension-U58cXw1g.js";
6
+ import { r as Ze } from "./UserStore-BFv6NXA-.js";
7
+ import { t as Qe } from "./en-Ne9rlj9Y.js";
8
+ import { DOMParser as $e, DOMSerializer as et, Fragment as N, NodeRange as tt, Slice as P } from "prosemirror-model";
9
+ import { ReplaceAroundStep as nt, ReplaceStep as F, canJoin as rt, liftTarget as it } from "prosemirror-transform";
10
+ import { NodeSelection as I, Plugin as L, Selection as R, TextSelection as z } from "prosemirror-state";
11
+ import { DOMParser as at, Fragment as B, Slice as V } from "@tiptap/pm/model";
12
+ import { Editor as ot, Extension as H, Mark as st, Node as U, createDocument as ct, extensions as W, findChildrenInRange as lt, findParentNodeClosestToPos as ut, getAttributes as dt, getMarkRange as ft, getMarksBetween as pt, getSchema as mt, isNodeSelection as ht, markPasteRule as gt, mergeAttributes as G, posToDOMRect as _t, selectionToInsertionEnd as vt } from "@tiptap/core";
13
+ import { CellSelection as K, TableMap as yt } from "prosemirror-tables";
14
+ import { Plugin as bt, PluginKey as xt } from "@tiptap/pm/state";
15
+ import { digestString as St } from "lib0/hash/fnv1a";
16
+ import { InputRule as Ct, inputRules as wt } from "@handlewithcare/prosemirror-inputrules";
17
+ import { keydownHandler as Tt } from "@tiptap/pm/keymap";
18
+ import { Text as Et } from "@tiptap/extension-text";
19
+ import { Gapcursor as Dt } from "@tiptap/extensions/gap-cursor";
20
+ // src/schema/blocks/types.ts
21
+ function Ot(e) {
22
+ return typeof e == "string" ? e : e.map((e) => typeof e == "string" ? e : e.text).join("");
23
+ }
24
+ // src/schema/inlineContent/createSpec.ts
25
+ function kt(e) {
26
+ return e.matches("[data-editable]") ? e : e.querySelector("[data-editable]") || e;
27
+ }
28
+ function At(e, t) {
29
+ return at.fromSchema(t).parse(e, {
30
+ topNode: t.nodes.paragraph.create(),
31
+ preserveWhitespace: !0
32
+ }).content;
33
+ }
34
+ function jt(e, t) {
35
+ let n = [];
36
+ return e.forEach((e) => {
37
+ if (e.isText) n.push(e);
38
+ else {
39
+ let r = e.type === t.linebreakReplacement ? "\n" : e.textContent;
40
+ r && n.push(t.text(r, e.marks));
41
+ }
42
+ }), B.fromArray(n);
43
+ }
44
+ function Mt(e, t, n) {
45
+ let r = e.content === "plain" || n && e.content === "styled" ? (t) => (r, i) => {
46
+ let a = n?.({
47
+ el: r,
48
+ schema: i
49
+ });
50
+ if (a !== void 0) return e.content === "plain" ? jt(a, i) : a;
51
+ let o = At(t(r), i);
52
+ return e.content === "plain" ? jt(o, i) : o;
53
+ } : void 0, i = [{
54
+ tag: `[data-inline-content-type="${e.type}"]`,
55
+ contentElement: (e) => kt(e),
56
+ getContent: r ? (e, t) => r(kt)(e, t) : void 0
57
+ }];
58
+ return t && i.push({
59
+ tag: "*",
60
+ getAttrs(e) {
61
+ if (typeof e == "string") return !1;
62
+ let n = t?.(e);
63
+ return n !== void 0 && n;
64
+ },
65
+ preserveWhitespace: r ? !0 : void 0,
66
+ getContent: r ? (e, t) => r((e) => e)(e, t) : void 0
67
+ }), i;
68
+ }
69
+ function Nt(e, t, n) {
70
+ let r = U.create({
71
+ name: e.type,
72
+ inline: !0,
73
+ group: "inline",
74
+ draggable: t.meta?.draggable,
75
+ selectable: e.content !== "none",
76
+ atom: e.content === "none",
77
+ code: t.meta?.code,
78
+ content: e.content === "styled" ? "inline*" : e.content === "plain" ? "text*" : "",
79
+ marks() {
80
+ return e.content === "plain" ? we(this.editor) : void 0;
81
+ },
82
+ addAttributes() {
83
+ return d(e.propSchema);
84
+ },
85
+ addKeyboardShortcuts() {
86
+ return ye(e);
87
+ },
88
+ parseHTML() {
89
+ return Mt(e, t.parse, t.parseContent);
90
+ },
91
+ renderHTML({ node: n }) {
92
+ let r = this.options.editor, i = t.render.call({
93
+ renderType: "dom",
94
+ props: void 0
95
+ }, ae(n, r.schema.inlineContentSchema, r.schema.styleSchema), () => {}, r, n, () => void 0);
96
+ return j(i, e.type, n.attrs, e.propSchema);
97
+ },
98
+ addNodeView() {
99
+ return (n) => {
100
+ let { node: r, getPos: i } = n, a = this.options.editor, o = t.render.call({
101
+ renderType: "nodeView",
102
+ props: n
103
+ }, ae(r, a.schema.inlineContentSchema, a.schema.styleSchema), (e) => {
104
+ let t = C([e], a.pmSchema), n = i();
105
+ n && a.transact((e) => e.replaceWith(n, n + r.nodeSize, t));
106
+ }, a, r, i), s = j(o, e.type, r.attrs, e.propSchema);
107
+ return ce(s), s;
108
+ };
109
+ }
110
+ });
111
+ return ve(r, e.propSchema, {
112
+ ...t,
113
+ toExternalHTML: t.toExternalHTML,
114
+ render(n, r, i) {
115
+ let a = C([n], i.pmSchema)[0], o = t.render(n, r, i, a, () => void 0);
116
+ return j(o, e.type, n.props, e.propSchema);
117
+ }
118
+ }, n);
119
+ }
120
+ // src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts
121
+ function Pt(e, t, n, r = "before") {
122
+ let i = typeof n == "string" ? n : n.id, a = D(e), o = t.map((e) => {
123
+ let t = T(e, a);
124
+ return t.check(), t;
125
+ }), s = M(i, e.doc);
126
+ if (!s) throw Error(`Block with ID ${i} not found`);
127
+ if (o.length === 0) return [];
128
+ let c = re(e.doc, k(e.doc, s.posBeforeNode), r, o[0].type);
129
+ if (!c) throw Error(`Cannot insert blocks at "${r}" of block "${i}": no valid position for them`);
130
+ if (c.wrapIn && !c.wrapIn.validContent(N.from(o))) throw Error(`Cannot insert blocks at "${r}" of block "${i}": a "${c.wrapIn.name}" doesn't accept them`);
131
+ let l = c.wrapIn ? N.from(c.wrapIn.create(null, o)) : N.from(o), u = e.doc.resolve(c.pos);
132
+ if (!u.parent.canReplace(u.index(), u.index(), l)) throw Error(`Cannot insert blocks at "${r}" of block "${i}": a "${u.parent.type.name}" doesn't accept them`);
133
+ return e.step(new F(c.pos, c.pos, new P(l, 0, 0))), o.map((t) => y(t, e.doc));
134
+ }
135
+ // src/api/blockManipulation/layoutBlocks/fixLayoutBlock.ts
136
+ function Ft(e) {
137
+ if (e.type.name === "blockContainer") {
138
+ let t = e.firstChild;
139
+ return e.childCount === 1 && !!t && t.type.name === "paragraph" && t.childCount === 0;
140
+ }
141
+ return w(e.type) ? e.childCount === 1 ? Ft(e.firstChild) : e.childCount === 0 && he(e.type.spec.blockConfig?.children) >= 1 : !1;
142
+ }
143
+ function It(e, t) {
144
+ let n = e.doc.resolve(t).nodeAfter;
145
+ if (!n || !w(n.type)) throw Error("Invalid layoutBlockPos: does not point to a layout block node.");
146
+ if (S(n.type)) return;
147
+ let r = n.type.spec.blockConfig?.children;
148
+ if (r && "dissolve" in r && r.dissolve === !1) return;
149
+ let i = he(n.type.spec.blockConfig?.children), a = [], o = [];
150
+ if (n.forEach((e, n) => {
151
+ if (!Ft(e)) a.push({
152
+ node: e,
153
+ offset: n
154
+ });
155
+ else if (w(e.type)) {
156
+ let r = t + 1 + n;
157
+ o.push({
158
+ from: r,
159
+ to: r + e.nodeSize
160
+ });
161
+ }
162
+ }), a.length >= i) {
163
+ for (let { from: t, to: n } of o.reverse()) e.delete(t, n);
164
+ return;
165
+ }
166
+ if (a.length === 1) {
167
+ let [{ node: r, offset: i }] = a, o = t + 1 + i, s = S(r.type) ? {
168
+ from: o + 1,
169
+ to: o + r.nodeSize - 1
170
+ } : {
171
+ from: o,
172
+ to: o + r.nodeSize
173
+ };
174
+ e.step(new nt(t, t + n.nodeSize, s.from, s.to, P.empty, 0, !1));
175
+ return;
176
+ }
177
+ let s = [];
178
+ for (let { node: e } of a) S(e.type) ? e.forEach((e) => s.push(e)) : s.push(e);
179
+ e.replaceWith(t, t + n.nodeSize, N.from(s));
180
+ }
181
+ function Lt(e, t) {
182
+ [...t].sort((e, t) => t.depth - e.depth).forEach(({ id: t }) => {
183
+ let n = M(t, e.doc);
184
+ n && w(n.node.type) && It(e, n.posBeforeNode);
185
+ });
186
+ }
187
+ // src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts
188
+ function q(e, t, n, r = {}) {
189
+ let i = D(e), a = n.map((e) => {
190
+ let t = T(e, i);
191
+ return t.check(), t;
192
+ }), o = new Set(t.map((e) => typeof e == "string" ? e : e.id)), c = [], l = [], u = typeof t[0] == "string" ? t[0] : t[0].id, d = e.steps.length, f = (t) => e.mapping.slice(d).map(t);
193
+ if (e.doc.descendants((t, r) => {
194
+ if (o.size === 0) return !1;
195
+ if (!t.type.isInGroup("bnBlock")) return !0;
196
+ let i = s(t, e.doc);
197
+ if (!o.has(i)) return !0;
198
+ c.push(y(t, e.doc)), o.delete(i), n.length > 0 && i === u && e.insert(f(r), a);
199
+ let d = e.doc.resolve(f(r));
200
+ for (let e of g(d.doc, d.pos)) l.some((t) => t.id === e.id) || l.push(e);
201
+ let p = d.node();
202
+ return p.type.name === "blockGroup" && d.node(d.depth - 1).type.name !== "doc" && p.childCount === 1 ? e.delete(d.before(), d.after()) : e.delete(d.pos, d.pos + t.nodeSize), !1;
203
+ }), o.size > 0) {
204
+ let e = [...o].join("\n");
205
+ throw Error("Blocks with the following IDs could not be found in the editor: " + e);
206
+ }
207
+ return r.fixLayoutBlocks !== !1 && Lt(e, l), {
208
+ insertedBlocks: a.map((t) => y(t, e.doc)),
209
+ removedBlocks: c
210
+ };
211
+ }
212
+ // src/api/blockManipulation/commands/updateBlock/updateBlock.ts
213
+ var Rt = (e, t) => ({ tr: n, dispatch: r }) => (r && J(n, e, t), !0);
214
+ function J(e, t, n, r, i) {
215
+ let a = e.mapping.maps.length, o = k(e.doc, t), s = o.hasContent && o.blockNoteType === "table" ? Gt(e) : null, c = D(e);
216
+ if (r !== void 0 && i !== void 0 && r > i) throw Error("Invalid replaceFromPos or replaceToPos");
217
+ let l = n.type || o.blockNoteType, u = c.nodes[l], d = u.isInGroup("bnBlock") ? u : c.nodes.blockContainer, f = o.hasContent && r !== void 0 && r >= o.contentStart && r <= o.contentEnd ? r - o.contentStart : void 0, p = o.hasContent && i !== void 0 && i >= o.contentStart && i <= o.contentEnd ? i - o.contentStart : void 0;
218
+ if (o.hasContent !== u.isInGroup("blockContent") || !o.hasContent && !u.validContent(o.block.node.content)) {
219
+ let t = y(o.block.node, e.doc), r = ge(c)[l], i, a = [...t.children];
220
+ Array.isArray(t.content) && t.content.length && (r.content === "inline" || r.content === "plain" ? i = t.content : w(u) && a.unshift({
221
+ type: "paragraph",
222
+ content: t.content
223
+ }));
224
+ let s = T({
225
+ id: t.id,
226
+ ...i ? { content: i } : {},
227
+ ...a.length > 0 ? { children: a } : {},
228
+ ...n
229
+ }, c);
230
+ s.check();
231
+ let d = e.doc.resolve(o.block.beforePos);
232
+ if (!d.parent.canReplace(d.index(), d.index(), N.from(s))) throw Error(`Cannot update block to "${l}": a "${d.parent.type.name}" doesn't accept it`);
233
+ e.replaceWith(o.block.beforePos, o.block.afterPos, s);
234
+ } else Ut(n, e, o), o.hasContent && zt(n, e, c.nodes[o.blockNoteType], u, o, f, p), Vt(e, o.block.beforePos, d, { ...n.props }), s && o.hasContent && Kt(e, e.mapping.slice(a).map(o.content.beforePos), s);
235
+ }
236
+ function zt(e, t, n, r, i, a, o) {
237
+ let s = D(t), c = "keep";
238
+ if (e.content) {
239
+ if (typeof e.content == "string") c = C([e.content], s, r.name);
240
+ else if (Array.isArray(e.content)) c = C(e.content, s, r.name);
241
+ else if (e.content.type === "tableContent") c = le(e.content, s);
242
+ else throw new _(e.content.type);
243
+ } else {
244
+ let e = i.content.node.content;
245
+ if (n.spec.content !== "" && r.spec.content !== n.spec.content && !r.validContent(e)) {
246
+ if (r.inlineContent && n.inlineContent) {
247
+ let e = i.content.node.textContent;
248
+ c = e.length > 0 ? [s.text(e)] : [];
249
+ } else c = [];
250
+ }
251
+ }
252
+ if (c === "keep") Vt(t, i.content.beforePos, r, { ...e.props });
253
+ else if (a !== void 0 || o !== void 0) {
254
+ let n = Ht(t, i.content.beforePos, r, { ...e.props }), s = n + 1 + (a ?? 0), l = n + 1 + (o ?? i.content.node.content.size), u = t.doc.resolve(n).depth, d = t.doc.resolve(s).depth, f = t.doc.resolve(l).depth;
255
+ t.replace(s, l, new P(N.from(c), d - u - 1, f - u - 1));
256
+ } else r === n || r.validContent(i.content.node.content) ? Bt(t, Ht(t, i.content.beforePos, r, { ...e.props }), N.from(c)) : t.replaceWith(i.content.beforePos, i.content.afterPos, r.createChecked({
257
+ ...i.content.node.attrs,
258
+ ...e.props
259
+ }, c));
260
+ }
261
+ function Bt(e, t, n) {
262
+ let r = e.doc.nodeAt(t);
263
+ if (!r) throw RangeError("No node at given position");
264
+ let i = r.content, a = t + 1;
265
+ if (r.isTextblock) {
266
+ let t = i.findDiffStart(n);
267
+ if (t === null) return;
268
+ let { a: r, b: o } = i.findDiffEnd(n), s = Math.max(0, t - r, t - o);
269
+ s > 0 && (r += s, o += s), e.replace(a + t, a + r, new P(n.cut(t, o), 0, 0));
270
+ return;
271
+ }
272
+ let o = i.childCount, s = n.childCount, c = 0;
273
+ for (; c < o && c < s && i.child(c).eq(n.child(c));) c++;
274
+ let l = o, u = s;
275
+ for (; l > c && u > c && i.child(l - 1).eq(n.child(u - 1));) l--, u--;
276
+ if (c === l && c === u) return;
277
+ let d = a;
278
+ for (let e = 0; e < c; e++) d += i.child(e).nodeSize;
279
+ let f = d;
280
+ for (let e = c; e < l; e++) f += i.child(e).nodeSize;
281
+ let p = [];
282
+ for (let e = c; e < u; e++) p.push(n.child(e));
283
+ e.step(new F(d, f, new P(N.from(p), 0, 0)));
284
+ }
285
+ function Vt(e, t, n, r) {
286
+ let i = e.doc.nodeAt(t);
287
+ if (!i) throw RangeError("No node at given position");
288
+ let a = n.spec.attrs ?? {}, o = {};
289
+ for (let e of Object.keys(r)) e in a && (o[e] = r[e]);
290
+ let s = {
291
+ ...i.attrs,
292
+ ...o
293
+ };
294
+ if (i.type === n) for (let n of Object.keys(s)) s[n] !== i.attrs[n] && e.setNodeAttribute(t, n, s[n]);
295
+ else !i.isLeaf && n.isLeaf ? e.step(new F(t, t + i.nodeSize, new P(N.from(n.createChecked(s, i.content, i.marks)), 0, 0))) : e.setNodeMarkup(t, n, s);
296
+ }
297
+ function Ht(e, t, n, r) {
298
+ let i = e.mapping.maps.length;
299
+ return Vt(e, t, n, r), e.mapping.slice(i).map(t, -1);
300
+ }
301
+ function Ut(e, t, n) {
302
+ let r = D(t);
303
+ if (e.children !== void 0 && e.children.length > 0) {
304
+ let i = e.children.map((e) => {
305
+ let t = T(e, r);
306
+ return t.check(), t;
307
+ });
308
+ n.children ? Bt(t, n.children.beforePos, N.from(i)) : n.hasContent && t.insert(n.content.afterPos, me(r, i));
309
+ }
310
+ }
311
+ function Wt(e, t, n, r, i) {
312
+ let a = typeof t == "string" ? t : t.id, o = M(a, e.doc);
313
+ if (!o) throw Error(`Block with ID ${a} not found`);
314
+ J(e, o.posBeforeNode, n, r, i);
315
+ let s = e.doc.resolve(o.posBeforeNode).nodeAfter;
316
+ if (!s) throw Error(`Block with ID ${a} not found after update`);
317
+ return y(s, e.doc);
318
+ }
319
+ function Gt(e) {
320
+ let t = "selection" in e ? e.selection : null;
321
+ if (!(t instanceof z)) return null;
322
+ let n = e.doc.resolve(t.head), r = -1, i = -1;
323
+ for (let e = n.depth; e >= 0; e--) {
324
+ let t = n.node(e).type.name;
325
+ if (r < 0 && (t === "tableCell" || t === "tableHeader") && (r = e), t === "table") {
326
+ i = e;
327
+ break;
328
+ }
329
+ }
330
+ if (r < 0 || i < 0) return null;
331
+ let a = n.before(r), o = n.before(i), s = e.doc.nodeAt(o);
332
+ if (!s || s.type.name !== "table") return null;
333
+ let c = yt.get(s), l = a - (o + 1), u = c.map.indexOf(l);
334
+ if (u < 0) return null;
335
+ let d = Math.floor(u / c.width), f = u % c.width, p = a + 1 + 1;
336
+ return {
337
+ row: d,
338
+ col: f,
339
+ offset: Math.max(0, t.head - p)
340
+ };
341
+ }
342
+ function Kt(e, t, n) {
343
+ let r = e.doc.nodeAt(t);
344
+ if (!r || r.type.name !== "table") return !1;
345
+ let i = yt.get(r), a = Math.max(0, Math.min(n.row, i.height - 1)), o = Math.max(0, Math.min(n.col, i.width - 1)), s = a * i.width + o, c = i.map[s];
346
+ if (c == null) return !1;
347
+ let l = t + 1 + c + 1, u = e.doc.nodeAt(l), d = l + 1, f = u ? u.content.size : 0, p = d + Math.max(0, Math.min(n.offset, f));
348
+ return "selection" in e && e.setSelection(z.create(e.doc, p)), !0;
349
+ }
350
+ // src/pm-nodes/BlockContainer.ts
351
+ var qt = [["textColor", "data-text-color"], ["backgroundColor", "data-background-color"]];
352
+ function Jt(e) {
353
+ return typeof e == "string" && e !== "default";
354
+ }
355
+ function Yt(e) {
356
+ return qt.some(([t]) => Jt(e[t]));
357
+ }
358
+ function Xt(e, t) {
359
+ for (let [n, r] of qt) {
360
+ let i = t?.[n];
361
+ Jt(i) ? e.setAttribute(r, i) : e.removeAttribute(r);
362
+ }
363
+ }
364
+ var Zt = {
365
+ blockColor: "data-block-color",
366
+ blockStyle: "data-block-style",
367
+ id: "data-id",
368
+ depth: "data-depth",
369
+ depthChange: "data-depth-change"
370
+ }, Qt = U.create({
371
+ name: "blockContainer",
372
+ group: "blockGroupChild bnBlock",
373
+ content: "blockContent blockGroup?",
374
+ priority: 50,
375
+ defining: !0,
376
+ marks() {
377
+ return A(this.editor);
378
+ },
379
+ parseHTML() {
380
+ return [{
381
+ tag: "div[data-node-type=" + this.name + "]",
382
+ getAttrs: (e) => {
383
+ if (typeof e == "string") return !1;
384
+ let t = {};
385
+ for (let [n, r] of Object.entries(Zt)) e.getAttribute(r) && (t[n] = e.getAttribute(r));
386
+ return t;
387
+ },
388
+ contentElement: (e) => _e(e) ?? e
389
+ }, {
390
+ tag: "div[data-node-type=\"blockOuter\"]",
391
+ skip: !0
392
+ }];
393
+ },
394
+ renderHTML({ HTMLAttributes: e }) {
395
+ let t = document.createElement("div");
396
+ t.className = "bn-block-outer", t.setAttribute("data-node-type", "blockOuter");
397
+ for (let [n, r] of Object.entries(e)) n !== "class" && t.setAttribute(n, r);
398
+ let n = {
399
+ ...this.options.domAttributes?.block || {},
400
+ ...e
401
+ }, r = document.createElement("div");
402
+ r.className = O("bn-block", n.class), r.setAttribute("data-node-type", this.name);
403
+ for (let [e, t] of Object.entries(n)) e !== "class" && r.setAttribute(e, t);
404
+ return t.appendChild(r), {
405
+ dom: t,
406
+ contentDOM: r
407
+ };
408
+ },
409
+ addNodeView() {
410
+ return ((t) => {
411
+ let { dom: n, contentDOM: r } = this.type.spec.toDOM(t.node), i = this.options.editor, a = h({
412
+ props: t,
413
+ editor: i,
414
+ blockNode: (e) => e.firstChild,
415
+ unframed: r
416
+ });
417
+ a.dom !== r && r.appendChild(a.dom);
418
+ let o = t.node.firstChild.attrs;
419
+ return Yt(o) && Xt(r, o), {
420
+ dom: n,
421
+ contentDOM: a.slot,
422
+ update(e, t, n) {
423
+ let i = a.node;
424
+ return !e.sameMarkup(i) || !a.update(e, t, n) ? !1 : (e.firstChild.sameMarkup(i.firstChild) || Xt(r, e.firstChild.attrs), !0);
425
+ },
426
+ ...e(a)
427
+ };
428
+ });
429
+ }
430
+ });
431
+ // src/api/exporters/html/util/serializeBlocksInternalHTML.ts
432
+ function $t(e, t, n, r, i) {
433
+ let a;
434
+ if (!t) throw Error("blockContent is required");
435
+ if (typeof t == "string") a = C([t], e.pmSchema, r);
436
+ else if (Array.isArray(t)) a = C(t, e.pmSchema, r);
437
+ else if (t.type === "tableContent") a = le(t, e.pmSchema);
438
+ else throw new _(t.type);
439
+ let o = (i?.document ?? document).createDocumentFragment();
440
+ for (let t of a) if (t.type.name !== "text" && e.schema.inlineContentSchema[t.type.name]) {
441
+ let r = e.schema.inlineContentSpecs[t.type.name].implementation;
442
+ if (r) {
443
+ let a = ae(t, e.schema.inlineContentSchema, e.schema.styleSchema), s = r.render.call({
444
+ renderType: "dom",
445
+ props: void 0
446
+ }, a, () => {}, e);
447
+ if (s) {
448
+ if (o.appendChild(s.dom), s.contentDOM) {
449
+ let e = n.serializeFragment(t.content, i);
450
+ s.contentDOM.dataset.editable = "", s.contentDOM.appendChild(e);
451
+ }
452
+ continue;
453
+ }
454
+ }
455
+ } else if (t.type.name === "text") {
456
+ let n = document.createTextNode(t.textContent);
457
+ for (let r of t.marks.toReversed()) if (r.type.name in e.schema.styleSpecs) {
458
+ let t = e.schema.styleSpecs[r.type.name].implementation.render(r.attrs.stringValue, e);
459
+ t.contentDOM.appendChild(n), n = t.dom;
460
+ } else {
461
+ let e = r.type.spec.toDOM(r, !0), t = et.renderSpec(document, e);
462
+ t.contentDOM.appendChild(n), n = t.dom;
463
+ }
464
+ o.appendChild(n);
465
+ } else {
466
+ let e = n.serializeFragment(N.from([t]), i);
467
+ o.appendChild(e);
468
+ }
469
+ return o;
470
+ }
471
+ function en(e, t, n, r) {
472
+ let i = e.pmSchema.nodes.blockContainer, a = t.props || {};
473
+ for (let [n, r] of Object.entries(e.schema.blockSchema[t.type].propSchema)) !(n in a) && r.default !== void 0 && (a[n] = r.default);
474
+ let o = t.children || [], s = e.blockImplementations[t.type].implementation, c = {
475
+ ...t,
476
+ props: a,
477
+ children: o
478
+ };
479
+ if (w(e.pmSchema.nodes[t.type])) {
480
+ let i = ne(e, c);
481
+ if (!i) throw Error(`Layout block "${t.type}" drew no frame. This is a bug in BlockNote.`);
482
+ return o.length > 0 && i.slot.append(tn(e, o, n, r)), i.dom;
483
+ }
484
+ if (!s.render) throw Error(`Block "${t.type}" has no \`render\`. This is a bug in BlockNote.`);
485
+ let l = s.render.call({
486
+ renderType: "dom",
487
+ props: void 0
488
+ }, c, e);
489
+ if (l.contentDOM && t.content) {
490
+ let i = $t(e, t.content, n, t.type, r);
491
+ l.contentDOM.appendChild(i);
492
+ }
493
+ let u = i.spec?.toDOM?.(i.create({
494
+ id: t.id,
495
+ ...a
496
+ }));
497
+ u.contentDOM && Xt(u.contentDOM, a);
498
+ let d = u.contentDOM, f = ne(e, c);
499
+ return f && (ee(f.slot), u.contentDOM?.appendChild(f.dom), d = f.slot), d?.appendChild(l.dom), o.length > 0 && d?.appendChild(nn(e, o, n, r)), u.dom;
500
+ }
501
+ function tn(e, t, n, r) {
502
+ let i = (r?.document ?? document).createDocumentFragment();
503
+ for (let a of t) {
504
+ let t = en(e, a, n, r);
505
+ i.appendChild(t);
506
+ }
507
+ return i;
508
+ }
509
+ var nn = (e, t, n, r) => {
510
+ let i = e.pmSchema.nodes.blockGroup, a = i.spec.toDOM(i.create({})), o = tn(e, t, n, r);
511
+ return a.contentDOM?.appendChild(o), a.dom;
512
+ }, rn = (e) => (e.querySelectorAll("[data-content-type=\"numberedListItem\"]").forEach((e) => {
513
+ let t = e.closest(".bn-block-outer")?.previousElementSibling?.querySelector("[data-content-type=\"numberedListItem\"]");
514
+ if (!t) e.setAttribute("data-index", e.getAttribute("data-start") || "1");
515
+ else {
516
+ let n = t.getAttribute("data-index");
517
+ e.setAttribute("data-index", (parseInt(n || "0") + 1).toString());
518
+ }
519
+ }), e), an = (e) => (e.querySelectorAll("[data-content-type=\"checkListItem\"] input").forEach((e) => {
520
+ e.disabled = !0;
521
+ }), e), on = (e) => (e.querySelectorAll(".bn-toggle-button[aria-expanded=\"false\"]").forEach((e) => {
522
+ e.setAttribute("aria-expanded", "true");
523
+ }), e), sn = (e) => (e.querySelectorAll("[data-content-type=\"table\"] table").forEach((e) => {
524
+ e.setAttribute("style", "--default-cell-min-width: 120px;"), e.setAttribute("data-show-children", "true");
525
+ }), e), cn = (e) => (e.querySelectorAll("[data-content-type=\"table\"] table").forEach((e) => {
526
+ let t = document.createElement("div");
527
+ t.className = "tableWrapper";
528
+ let n = document.createElement("div");
529
+ n.className = "tableWrapper-inner", t.appendChild(n), e.parentElement?.appendChild(t), t.appendChild(e);
530
+ }), e), ln = (e) => (e.querySelectorAll(".bn-inline-content:empty").forEach((e) => {
531
+ let t = document.createElement("span");
532
+ t.className = "ProseMirror-trailingBreak", t.setAttribute("style", "display: inline-block;"), e.appendChild(t);
533
+ }), e), un = (e, t) => {
534
+ let n = et.fromSchema(e), r = [
535
+ rn,
536
+ an,
537
+ on,
538
+ sn,
539
+ cn,
540
+ ln
541
+ ];
542
+ return { serializeBlocks: (e, i) => {
543
+ let a = nn(t, e, n, i);
544
+ for (let e of r) a = e(a);
545
+ return a.outerHTML;
546
+ } };
547
+ }, dn = (e) => {
548
+ let t = 0;
549
+ for (let n = 0; n < e.length; n++) t = Math.imul(31, t) + e.charCodeAt(n);
550
+ return Math.abs(t);
551
+ }, Y = [
552
+ {
553
+ light: "#fff0c2",
554
+ dark: "#8a6d1a"
555
+ },
556
+ {
557
+ light: "#cdeffd",
558
+ dark: "#0b6a8a"
559
+ },
560
+ {
561
+ light: "#d6defd",
562
+ dark: "#2948b3"
563
+ },
564
+ {
565
+ light: "#eadcfb",
566
+ dark: "#6b2fa3"
567
+ },
568
+ {
569
+ light: "#f1e2d3",
570
+ dark: "#7a4a1e"
571
+ },
572
+ {
573
+ light: "#dfe4ea",
574
+ dark: "#46525f"
575
+ }
576
+ ], fn = (e) => Y[dn(e) % Y.length], pn = (e) => {
577
+ if (e?.color) return {
578
+ light: e.colorLight ?? `color-mix(in srgb, ${e.color} 30%, white)`,
579
+ dark: e.color
580
+ };
581
+ }, mn = (e, t) => {
582
+ if (!t || t.length === 0) return Y[0];
583
+ let n = t[0];
584
+ return pn(e.getUser(n)) ?? fn(n);
585
+ }, hn = (e) => St(e).toString(16).padStart(8, "0"), gn = (e) => {
586
+ let t = hn(e);
587
+ return {
588
+ light: `--user-color-${t}-light`,
589
+ dark: `--user-color-${t}-dark`
590
+ };
591
+ }, _n = class {
592
+ callbacks = {};
593
+ on(e, t) {
594
+ return this.callbacks[e] || (this.callbacks[e] = []), this.callbacks[e].push(t), () => this.off(e, t);
595
+ }
596
+ emit(e, ...t) {
597
+ let n = this.callbacks[e];
598
+ n && n.forEach((e) => e.apply(this, t));
599
+ }
600
+ off(e, t) {
601
+ let n = this.callbacks[e];
602
+ n && (t ? this.callbacks[e] = n.filter((e) => e !== t) : delete this.callbacks[e]);
603
+ }
604
+ removeAllListeners() {
605
+ this.callbacks = {};
606
+ }
607
+ };
608
+ // src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts
609
+ function vn(e, t) {
610
+ return e.flatMap((e) => S(t.nodes[e.type]) ? vn(e.children, t) : [e]);
611
+ }
612
+ function yn(e) {
613
+ return e.transact((e) => {
614
+ let t = i(e, e.selection.anchor), n = s(t.block.node, e.doc);
615
+ if (e.selection instanceof K) return {
616
+ type: "cell",
617
+ anchorBlockId: n,
618
+ anchorCellOffset: e.selection.$anchorCell.pos - t.block.beforePos,
619
+ headCellOffset: e.selection.$headCell.pos - t.block.beforePos
620
+ };
621
+ if (e.selection instanceof I) return {
622
+ type: "node",
623
+ anchorBlockId: n
624
+ };
625
+ {
626
+ let r = i(e, e.selection.head);
627
+ return {
628
+ type: "text",
629
+ anchorBlockId: n,
630
+ headBlockId: s(r.block.node, e.doc),
631
+ anchorOffset: e.selection.anchor - t.block.beforePos,
632
+ headOffset: e.selection.head - r.block.beforePos
633
+ };
634
+ }
635
+ });
636
+ }
637
+ function bn(e, t) {
638
+ let n = M(t.anchorBlockId, e.doc)?.posBeforeNode;
639
+ if (n === void 0) throw Error(`Could not find block with ID ${t.anchorBlockId} to update selection`);
640
+ let r;
641
+ if (t.type === "cell") r = K.create(e.doc, n + t.anchorCellOffset, n + t.headCellOffset);
642
+ else if (t.type === "node") {
643
+ let t = k(e.doc, n);
644
+ r = I.create(e.doc, t.hasContent ? t.content.beforePos : n);
645
+ } else {
646
+ let i = M(t.headBlockId, e.doc)?.posBeforeNode;
647
+ if (i === void 0) throw Error(`Could not find block with ID ${t.headBlockId} to update selection`);
648
+ r = z.create(e.doc, n + t.anchorOffset, i + t.headOffset);
649
+ }
650
+ e.setSelection(r);
651
+ }
652
+ function xn(e, t, n, r) {
653
+ e.transact((i) => {
654
+ q(i, t, [], { fixLayoutBlocks: !1 }), Pt(i, vn(t, e.pmSchema), n, r);
655
+ });
656
+ }
657
+ function Sn(e, t, n) {
658
+ e.transact((r) => {
659
+ let i = e.getSelection()?.blocks || [e.getTextCursorPosition().block], a = yn(e);
660
+ xn(e, i, t, n), bn(r, a);
661
+ });
662
+ }
663
+ function Cn(e, t) {
664
+ let n = vn([t], e.pmSchema)[0], r = n && e.pmSchema.nodes[n.type];
665
+ return r && w(r) ? r : e.pmSchema.nodes.blockContainer;
666
+ }
667
+ function wn(e, t, n, r, i) {
668
+ let a = n === "up" ? "before" : "after", o = n === "up" ? "after" : "before";
669
+ for (; r || i;) {
670
+ let s = r && r.children.length > 0, c = r ? s ? r.children[n === "up" ? r.children.length - 1 : 0] : r : i, l = s ? o : a;
671
+ if (e.transact((e) => {
672
+ let n = M(c.id, e.doc);
673
+ return n !== void 0 && re(e.doc, k(e.doc, n.posBeforeNode), l, t) !== null;
674
+ })) return {
675
+ referenceBlock: c,
676
+ placement: l
677
+ };
678
+ i = e.getParentBlock(c), r = l === o ? c : n === "up" ? e.getPrevBlock(c) : e.getNextBlock(c);
679
+ }
680
+ }
681
+ function Tn(e, t, n) {
682
+ e.transact(() => {
683
+ let r;
684
+ if (n) {
685
+ let t = e.getBlock(n);
686
+ if (!t) return;
687
+ r = [t];
688
+ } else r = e.getSelection()?.blocks || [e.getTextCursorPosition().block];
689
+ let i = r[t === "up" ? 0 : r.length - 1], a = wn(e, Cn(e, r[0]), t, t === "up" ? e.getPrevBlock(i) : e.getNextBlock(i), e.getParentBlock(i));
690
+ a && (n ? xn(e, r, a.referenceBlock, a.placement) : Sn(e, a.referenceBlock, a.placement));
691
+ });
692
+ }
693
+ function En(e, t) {
694
+ Tn(e, "up", t);
695
+ }
696
+ function Dn(e, t) {
697
+ Tn(e, "down", t);
698
+ }
699
+ // src/api/blockManipulation/commands/nestBlock/nestBlock.ts
700
+ function On(e, t) {
701
+ return e.childCount > 0 && e.type.isInGroup("childContainer") && e.type.contentMatch.matchType(t) !== null;
702
+ }
703
+ function kn(e, t, n) {
704
+ let { $from: r, $to: i } = e.selection, a = r.blockRange(i, (e) => On(e, t));
705
+ if (!a) return !1;
706
+ let o = a.startIndex;
707
+ if (o === 0) return !1;
708
+ let s = a.parent.child(o - 1);
709
+ if (s.type !== t) return !1;
710
+ let c = s.lastChild && s.lastChild.type === n ? 2 : 1, l = new P(N.from(t.create(null, N.from(n.create()))), c, 0), u = a.start, d = a.end;
711
+ return e.step(new nt(u - c, d, u, d, l, 2 - c, !0)).scrollIntoView(), !0;
712
+ }
713
+ function An(e) {
714
+ return (t) => kn(t, e.pmSchema.nodes.blockContainer, e.pmSchema.nodes.blockGroup);
715
+ }
716
+ function jn(e) {
717
+ return e.transact(An(e));
718
+ }
719
+ function Mn(e, t, n, r) {
720
+ let i = r.end, a = r.$to.end(r.depth);
721
+ if (i < a) {
722
+ let o = r.parent.child(r.endIndex - 1), s = o.lastChild && o.lastChild.type === n;
723
+ e.step(new nt(i - (s ? 2 : 1), a, i, a, new P(N.from(t.create(null, n.create())), s ? 2 : 1, 0), +!s, !0)), r = new tt(e.doc.resolve(r.$from.pos), e.doc.resolve(a), r.depth);
724
+ }
725
+ let o = it(r);
726
+ if (o == null) return !1;
727
+ e.lift(r, o);
728
+ let s = e.doc.resolve(e.mapping.map(i, -1) - 1);
729
+ return rt(e.doc, s.pos) && s.nodeBefore.type === s.nodeAfter.type && e.join(s.pos), e.scrollIntoView(), !0;
730
+ }
731
+ function Nn(e, t, n, r) {
732
+ let { $from: i, $to: a } = e.selection, o = i.blockRange(a, (e) => On(e, t));
733
+ if (!o) return !1;
734
+ let s = i.node(o.depth - 1);
735
+ return s.type === t && !r(s) ? !1 : s.type === t && Mn(e, t, n, o);
736
+ }
737
+ function Pn(e) {
738
+ return (t) => Nn(t, e.pmSchema.nodes.blockContainer, e.pmSchema.nodes.blockGroup, (n) => {
739
+ let r = y(n, t.doc);
740
+ return e.schema.blockSpecs[r.type].implementation.keyboard(r).childrenCanOutdent;
741
+ });
742
+ }
743
+ function Fn(e) {
744
+ return e.transact(Pn(e));
745
+ }
746
+ function In(e) {
747
+ return e.canExec((t) => An(e)(t.tr));
748
+ }
749
+ function Ln(e) {
750
+ return e.canExec((t) => Pn(e)(t.tr));
751
+ }
752
+ // src/api/blockManipulation/getBlock/getBlock.ts
753
+ function Rn(e, t) {
754
+ let n = typeof t == "string" ? t : t.id, r = M(n, e);
755
+ if (r) return y(r.node, e);
756
+ }
757
+ function zn(e, t) {
758
+ let n = typeof t == "string" ? t : t.id, r = M(n, e);
759
+ if (!r) return;
760
+ let i = e.resolve(r.posBeforeNode).nodeBefore;
761
+ if (i) return y(i, e);
762
+ }
763
+ function Bn(e, t) {
764
+ let n = typeof t == "string" ? t : t.id, r = M(n, e);
765
+ if (!r) return;
766
+ let i = e.resolve(r.posBeforeNode + r.node.nodeSize).nodeAfter;
767
+ if (i) return y(i, e);
768
+ }
769
+ function Vn(e, t) {
770
+ let n = typeof t == "string" ? t : t.id, r = M(n, e);
771
+ if (!r) return;
772
+ let i = x(e, r.posBeforeNode);
773
+ if (i) return y(i.block.node, e);
774
+ }
775
+ // src/editor/managers/BlockManager.ts
776
+ var Hn = class {
777
+ editor;
778
+ constructor(e) {
779
+ this.editor = e;
780
+ }
781
+ get document() {
782
+ return this.editor.transact((e) => ie(e.doc));
783
+ }
784
+ getBlock(e) {
785
+ return this.editor.transact((t) => Rn(t.doc, e));
786
+ }
787
+ getPrevBlock(e) {
788
+ return this.editor.transact((t) => zn(t.doc, e));
789
+ }
790
+ getNextBlock(e) {
791
+ return this.editor.transact((t) => Bn(t.doc, e));
792
+ }
793
+ getParentBlock(e) {
794
+ return this.editor.transact((t) => Vn(t.doc, e));
795
+ }
796
+ forEachBlock(e, t = !1) {
797
+ let n = this.document.slice();
798
+ t && n.reverse();
799
+ function r(n) {
800
+ for (let i of n) if (e(i) === !1 || !r(t ? i.children.toReversed() : i.children)) return !1;
801
+ return !0;
802
+ }
803
+ r(n);
804
+ }
805
+ insertBlocks(e, t, n = "before") {
806
+ return this.editor.transact((r) => Pt(r, e, t, n));
807
+ }
808
+ updateBlock(e, t) {
809
+ return this.editor.transact((n) => Wt(n, e, t));
810
+ }
811
+ removeBlocks(e) {
812
+ return this.editor.transact((t) => q(t, e, []).removedBlocks);
813
+ }
814
+ replaceBlocks(e, t) {
815
+ return this.editor.transact((n) => q(n, e, t));
816
+ }
817
+ canNestBlock() {
818
+ return In(this.editor);
819
+ }
820
+ nestBlock() {
821
+ jn(this.editor);
822
+ }
823
+ canUnnestBlock() {
824
+ return Ln(this.editor);
825
+ }
826
+ unnestBlock() {
827
+ Fn(this.editor);
828
+ }
829
+ moveBlocksUp(e) {
830
+ return En(this.editor, e);
831
+ }
832
+ moveBlocksDown(e) {
833
+ return Dn(this.editor, e);
834
+ }
835
+ }, Un = class extends _n {
836
+ editor;
837
+ constructor(e) {
838
+ super(), this.editor = e, e.on("create", () => {
839
+ e._tiptapEditor.on("update", ({ transaction: t, appendedTransactions: n }) => {
840
+ this.emit("onChange", {
841
+ editor: e,
842
+ transaction: t,
843
+ appendedTransactions: n
844
+ });
845
+ }), e._tiptapEditor.on("selectionUpdate", ({ transaction: t }) => {
846
+ this.emit("onSelectionChange", {
847
+ editor: e,
848
+ transaction: t
849
+ });
850
+ }), e._tiptapEditor.on("focus", ({ event: t }) => {
851
+ this.emit("onFocusChange", {
852
+ editor: e,
853
+ focused: !0,
854
+ event: t
855
+ });
856
+ }), e._tiptapEditor.on("blur", ({ event: t }) => {
857
+ this.emit("onFocusChange", {
858
+ editor: e,
859
+ focused: !1,
860
+ event: t
861
+ });
862
+ }), e._tiptapEditor.on("mount", () => {
863
+ this.emit("onMount", { editor: e });
864
+ }), e._tiptapEditor.on("unmount", () => {
865
+ this.emit("onUnmount", { editor: e });
866
+ });
867
+ let t;
868
+ this.onMount(() => {
869
+ t = this.attachUIFocusTracker();
870
+ }), this.onUnmount(() => {
871
+ t && t();
872
+ });
873
+ });
874
+ }
875
+ attachUIFocusTracker() {
876
+ if (typeof document > "u") return () => {};
877
+ let e = this.editor.isFocused({ includeEditorUI: !0 }), t, n = (t) => {
878
+ let n = this.editor.isFocused({ includeEditorUI: !0 });
879
+ n !== e && (e = n, this.emit("onFocusChangeWithinUI", {
880
+ editor: this.editor,
881
+ focused: n,
882
+ event: t
883
+ }));
884
+ }, r = (e) => n(e), i = (e) => {
885
+ clearTimeout(t), t = setTimeout(() => n(e));
886
+ };
887
+ return document.addEventListener("focusin", r, !0), document.addEventListener("focusout", i, !0), () => {
888
+ clearTimeout(t), document.removeEventListener("focusin", r, !0), document.removeEventListener("focusout", i, !0);
889
+ };
890
+ }
891
+ onChange(e, t = !0) {
892
+ return this.on("onChange", ({ transaction: n, appendedTransactions: r }) => {
893
+ this.editor.getExtension("versioning")?.isPreviewOpen || n.getMeta("blocknoteVersionPreview") || !t && Wn(n) || e(this.editor, { getChanges() {
894
+ return Je(n, r);
895
+ } });
896
+ });
897
+ }
898
+ onSelectionChange(e, t = !1) {
899
+ return this.on("onSelectionChange", ({ transaction: n }) => {
900
+ (t || !Wn(n)) && e(this.editor);
901
+ });
902
+ }
903
+ onFocusChange(e, t) {
904
+ return this.on(t?.includeEditorUI ? "onFocusChangeWithinUI" : "onFocusChange", ({ focused: t, event: n }) => e(this.editor, {
905
+ focused: t,
906
+ event: n
907
+ }));
908
+ }
909
+ onMount(e) {
910
+ return this.on("onMount", e);
911
+ }
912
+ onUnmount(e) {
913
+ return this.on("onUnmount", e);
914
+ }
915
+ };
916
+ function Wn(e) {
917
+ return !!e.getMeta("y-sync$");
918
+ }
919
+ // src/api/parsers/html/util/nestedLists.ts
920
+ function Gn(e) {
921
+ return Array.prototype.indexOf.call(e.parentElement.childNodes, e);
922
+ }
923
+ function Kn(e) {
924
+ return e.nodeType === 3 && !/\S/.test(e.nodeValue || "");
925
+ }
926
+ function qn(e) {
927
+ e.querySelectorAll("li > ul, li > ol").forEach((e) => {
928
+ let t = Gn(e), n = e.parentElement, r = Array.from(n.childNodes).slice(t + 1);
929
+ e.remove(), r.forEach((e) => {
930
+ e.remove();
931
+ }), n.insertAdjacentElement("afterend", e), r.reverse().forEach((t) => {
932
+ if (Kn(t)) return;
933
+ let n = document.createElement("li");
934
+ n.append(t), e.insertAdjacentElement("afterend", n);
935
+ }), n.childNodes.length === 0 && n.remove();
936
+ });
937
+ }
938
+ function Jn(e) {
939
+ e.querySelectorAll("li + ul, li + ol").forEach((e) => {
940
+ let t = e.previousElementSibling, n = document.createElement("div");
941
+ t.insertAdjacentElement("afterend", n), n.append(t);
942
+ let r = document.createElement("div");
943
+ for (r.setAttribute("data-node-type", "blockGroup"), n.append(r); n.nextElementSibling?.nodeName === "UL" || n.nextElementSibling?.nodeName === "OL";) r.append(n.nextElementSibling);
944
+ });
945
+ }
946
+ var Yn = null;
947
+ function Xn() {
948
+ return Yn ||= document.implementation.createHTMLDocument("title");
949
+ }
950
+ function Zn(e) {
951
+ if (typeof e == "string") {
952
+ let t = Xn().createElement("div");
953
+ t.innerHTML = e, e = t;
954
+ }
955
+ return qn(e), Jn(e), e;
956
+ }
957
+ // src/api/parsers/html/util/normalizeWhitespace.ts
958
+ function Qn(e) {
959
+ let t = e.ownerDocument.createTreeWalker(e, 128), n;
960
+ for (; n = t.nextNode();) if (/^\s*notionvc:/.test(n.nodeValue || "")) return !0;
961
+ return !1;
962
+ }
963
+ function $n(e) {
964
+ let t = /* @__PURE__ */ new Set(["PRE", "CODE"]), n = e.ownerDocument.createTreeWalker(e, 4, { acceptNode(n) {
965
+ let r = n.parentElement;
966
+ for (; r && r !== e;) {
967
+ if (t.has(r.tagName)) return 2;
968
+ r = r.parentElement;
969
+ }
970
+ return 1;
971
+ } }), r = [], i;
972
+ for (; i = n.nextNode();) r.push(i);
973
+ for (let e of r) e.nodeValue && /[\r\n]/.test(e.nodeValue) && (e.nodeValue = e.nodeValue.replace(/[ \t\r\n\f]+/g, " "));
974
+ }
975
+ function er(e) {
976
+ Qn(e) || $n(e);
977
+ }
978
+ // src/api/parsers/html/parseHTML.ts
979
+ function tr(e) {
980
+ let t = [];
981
+ for (let n of e) if (n.type === "text") {
982
+ let e = n.text.split("").join("");
983
+ e.length > 0 && t.push({
984
+ ...n,
985
+ text: e
986
+ });
987
+ } else Array.isArray(n.content) ? t.push({
988
+ ...n,
989
+ content: tr(n.content)
990
+ }) : t.push(n);
991
+ return t;
992
+ }
993
+ function nr(e) {
994
+ for (let t of e) Array.isArray(t.content) && (t.content = tr(t.content)), t.children.length > 0 && nr(t.children);
995
+ }
996
+ function rr(e, t) {
997
+ let n = Zn(e);
998
+ er(n);
999
+ let r = $e.fromSchema(t).parse(n, { topNode: t.nodes.blockGroup.create() }), i = [];
1000
+ for (let e = 0; e < r.childCount; e++) i.push(y(r.child(e), r));
1001
+ return nr(i), i;
1002
+ }
1003
+ // src/api/parsers/markdown/markdownToHtml.ts
1004
+ function X(e) {
1005
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
1006
+ }
1007
+ function ir(e) {
1008
+ return e ? /\w/.test(e) : !1;
1009
+ }
1010
+ function ar(e, t, n) {
1011
+ let r = t > 0 ? e[t - 1] : void 0, i = t + n < e.length ? e[t + n] : void 0;
1012
+ return ir(r) && ir(i);
1013
+ }
1014
+ function or(e, t) {
1015
+ if (e[t] !== "\\" || t + 1 >= e.length) return null;
1016
+ let n = e[t + 1];
1017
+ return n === "\n" ? {
1018
+ html: "<br>\n",
1019
+ end: t + 2
1020
+ } : "\\`*_{}[]()#+-.!~|<>".includes(n) ? {
1021
+ html: X(n),
1022
+ end: t + 2
1023
+ } : null;
1024
+ }
1025
+ function sr(e, t) {
1026
+ return e[t] === "`" ? Er(e, t) : null;
1027
+ }
1028
+ function cr(e, t) {
1029
+ return e[t] !== "!" || e[t + 1] !== "[" ? null : Dr(e, t);
1030
+ }
1031
+ function lr(e, t) {
1032
+ return e[t] === "[" ? Or(e, t) : null;
1033
+ }
1034
+ function ur(e, t) {
1035
+ let n = e.substring(t);
1036
+ if (e[t] === "<") {
1037
+ let e = n.match(/^<([a-zA-Z][a-zA-Z0-9+.-]{1,31}:[^\s<>]*)>/);
1038
+ if (e) {
1039
+ let n = e[1];
1040
+ return {
1041
+ html: `<a href="${X(n)}">${X(n)}</a>`,
1042
+ end: t + e[0].length
1043
+ };
1044
+ }
1045
+ let r = n.match(/^<([^\s<>]+)>/), i = r?.[1], a = i ? Fe(i).find((e) => e.type === "email" && e.start === 0 && e.end === i.length) : void 0;
1046
+ return r && i && a ? {
1047
+ html: `<a href="${X(a.href)}">${X(i)}</a>`,
1048
+ end: t + r[0].length
1049
+ } : null;
1050
+ }
1051
+ if (t > 0 && /[a-zA-Z0-9_]/.test(e[t - 1])) return null;
1052
+ let r = n.match(/^(https?:\/\/|www\.)[^\s<>]+/i);
1053
+ if (!r) return null;
1054
+ let i = Ke(r[0]);
1055
+ return i ? {
1056
+ html: `<a href="${X(i.href)}">${X(i.value)}</a>`,
1057
+ end: t + i.value.length
1058
+ } : null;
1059
+ }
1060
+ function dr(e, t, n) {
1061
+ return e[t] !== "~" || e[t + 1] !== "~" ? null : Q(e, t, "~~", "<del>", "</del>", n);
1062
+ }
1063
+ function fr(e, t, n) {
1064
+ return e[t] === "*" && e[t + 1] === "*" && e[t + 2] === "*" || e[t] === "_" && e[t + 1] === "_" && e[t + 2] === "_" && !ar(e, t, 3) ? Q(e, t, e.substring(t, t + 3), "<strong><em>", "</em></strong>", n) : null;
1065
+ }
1066
+ function pr(e, t, n) {
1067
+ return e[t] === "*" && e[t + 1] === "*" || e[t] === "_" && e[t + 1] === "_" && !ar(e, t, 2) ? Q(e, t, e.substring(t, t + 2), "<strong>", "</strong>", n) : null;
1068
+ }
1069
+ function mr(e, t, n) {
1070
+ return e[t] === "*" || e[t] === "_" && !ar(e, t, 1) ? Q(e, t, e[t], "<em>", "</em>", n) : null;
1071
+ }
1072
+ function hr(e, t) {
1073
+ return e[t] === "\n" ? {
1074
+ html: "<br>\n",
1075
+ end: t + 1
1076
+ } : null;
1077
+ }
1078
+ var gr = /^<\/?[a-zA-Z][a-zA-Z0-9-]*(?:\s+[a-zA-Z_:][a-zA-Z0-9_.:-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*\s*\/?>/, _r = /^<!--[\s\S]*?-->/, vr = /^<!\[CDATA\[[\s\S]*?\]\]>/, yr = /^<\?[\s\S]*?\?>/, br = /^<![A-Za-z][\s\S]*?>/;
1079
+ function xr(e, t) {
1080
+ if (e[t] !== "<") return null;
1081
+ let n = e.substring(t);
1082
+ for (let e of [
1083
+ _r,
1084
+ vr,
1085
+ yr,
1086
+ br,
1087
+ gr
1088
+ ]) {
1089
+ let r = n.match(e);
1090
+ if (r) return {
1091
+ html: r[0],
1092
+ end: t + r[0].length
1093
+ };
1094
+ }
1095
+ return null;
1096
+ }
1097
+ var Sr = /* @__PURE__ */ new Set("\\`![~*_\n<");
1098
+ function Cr(e, t) {
1099
+ let n = e[t];
1100
+ return Sr.has(n) ? !0 : n === "h" ? e.startsWith("http://", t) || e.startsWith("https://", t) : n === "w" && e.startsWith("www.", t);
1101
+ }
1102
+ var wr = [
1103
+ or,
1104
+ sr,
1105
+ cr,
1106
+ lr,
1107
+ ur,
1108
+ dr,
1109
+ fr,
1110
+ pr,
1111
+ mr,
1112
+ xr,
1113
+ hr
1114
+ ], Tr = wr.filter((e) => e !== lr && e !== ur);
1115
+ function Z(e, t = !0) {
1116
+ let n = "", r = 0, i = t ? wr : Tr;
1117
+ for (; r < e.length;) {
1118
+ if (e[r] === "\n" && r >= 2 && e[r - 1] === " " && e[r - 2] === " ") {
1119
+ n = n.replace(/ +$/, ""), n += "<br>\n", r++;
1120
+ continue;
1121
+ }
1122
+ let a = !1;
1123
+ if (Cr(e, r)) for (let o of i) {
1124
+ let i = o(e, r, t);
1125
+ if (i) {
1126
+ n += i.html, r = i.end, a = !0;
1127
+ break;
1128
+ }
1129
+ }
1130
+ if (!a) {
1131
+ let t = r;
1132
+ for (r++; r < e.length && !Cr(e, r);) r++;
1133
+ n += X(e.substring(t, r));
1134
+ }
1135
+ }
1136
+ return n;
1137
+ }
1138
+ function Er(e, t) {
1139
+ let n = 0, r = t;
1140
+ for (; r < e.length && e[r] === "`";) n++, r++;
1141
+ let i = r;
1142
+ for (; i < e.length;) if (e[i] === "`") {
1143
+ let t = 0, a = i;
1144
+ for (; i < e.length && e[i] === "`";) t++, i++;
1145
+ if (t === n) {
1146
+ let t = e.substring(r, a);
1147
+ return t = t.replace(/\n/g, " "), t.length >= 2 && t[0] === " " && t.at(-1) === " " && /[^ ]/.test(t) && (t = t.substring(1, t.length - 1)), {
1148
+ html: `<code>${X(t)}</code>`,
1149
+ end: i
1150
+ };
1151
+ }
1152
+ } else i++;
1153
+ return null;
1154
+ }
1155
+ function Dr(e, t) {
1156
+ let n = kr(e, t + 1);
1157
+ if (n === -1) return null;
1158
+ let r = t + 2;
1159
+ if (e[n + 1] !== "(") return null;
1160
+ let i = n + 2, a = Ar(e, i - 1);
1161
+ if (a === -1) return null;
1162
+ let o = e.substring(r, n), { url: s, title: c } = jr(e.substring(i, a));
1163
+ if (oe(s)) {
1164
+ let e = o || c;
1165
+ return {
1166
+ html: `<video src="${X(s)}"${e ? ` data-name="${X(e)}"` : ""} data-url="${X(s)}" controls></video>`,
1167
+ end: a + 1
1168
+ };
1169
+ }
1170
+ let l = c === void 0 ? "" : ` title="${X(c)}"`;
1171
+ return {
1172
+ html: `<img src="${X(s)}" alt="${X(o)}"${l}>`,
1173
+ end: a + 1
1174
+ };
1175
+ }
1176
+ function Or(e, t) {
1177
+ let n = t + 1, r = kr(e, t);
1178
+ if (r === -1 || e[r + 1] !== "(") return null;
1179
+ let i = r + 2, a = Ar(e, r + 1);
1180
+ if (a === -1) return null;
1181
+ let o = e.substring(n, r), { url: s, title: c } = jr(e.substring(i, a)), l = c === void 0 ? "" : ` title="${X(c)}"`;
1182
+ return {
1183
+ html: `<a href="${X(s)}"${l}>${Z(o, !1)}</a>`,
1184
+ end: a + 1
1185
+ };
1186
+ }
1187
+ function kr(e, t) {
1188
+ let n = 0;
1189
+ for (let r = t; r < e.length; r++) if (e[r] === "\\" && r + 1 < e.length) r++;
1190
+ else if (e[r] === "[" && n++, e[r] === "]" && (n--, n === 0)) return r;
1191
+ return -1;
1192
+ }
1193
+ function Ar(e, t) {
1194
+ let n = 0;
1195
+ for (let r = t; r < e.length; r++) if (e[r] === "\\" && r + 1 < e.length) r++;
1196
+ else if (e[r] === "(" && n++, e[r] === ")" && (n--, n === 0)) return r;
1197
+ return -1;
1198
+ }
1199
+ function jr(e) {
1200
+ e = e.trim();
1201
+ let t, n;
1202
+ if (e.startsWith("<")) {
1203
+ let r = e.indexOf(">");
1204
+ r === -1 ? (t = e.substring(1), n = "") : (t = e.substring(1, r), n = e.substring(r + 1).trim());
1205
+ } else {
1206
+ let r = e.length;
1207
+ for (let t = 0; t < e.length; t++) if (e[t] === "\\" && t + 1 < e.length) t++;
1208
+ else if (e[t] === " " || e[t] === " " || e[t] === "\n") {
1209
+ r = t;
1210
+ break;
1211
+ }
1212
+ t = e.substring(0, r), n = e.substring(r).trim();
1213
+ }
1214
+ let r;
1215
+ if (n.length > 0) {
1216
+ let e = n.match(/^"([^"]*)"$|^'([^']*)'$|^\(([^)]*)\)$/);
1217
+ e && (r = e[1] ?? e[2] ?? e[3]);
1218
+ }
1219
+ return {
1220
+ url: t,
1221
+ title: r
1222
+ };
1223
+ }
1224
+ function Q(e, t, n, r, i, a) {
1225
+ let o = n.length, s = t + o;
1226
+ if (s >= e.length || e[s] === " " || e[s] === " ") return null;
1227
+ let c = s;
1228
+ for (; c < e.length;) if (e[c] === "\\" && c + 1 < e.length) c += 2;
1229
+ else {
1230
+ if (e.substring(c, c + o) === n) {
1231
+ if (e[c - 1] === " " || e[c - 1] === " " || o === 1 && (c > 0 && e[c - 1] === n[0] && !(c >= 2 && e[c - 2] === "\\") || c + o < e.length && e[c + o] === n[0])) {
1232
+ c++;
1233
+ continue;
1234
+ }
1235
+ let t = e.substring(s, c);
1236
+ if (t.length === 0) {
1237
+ c++;
1238
+ continue;
1239
+ }
1240
+ return {
1241
+ html: r + Z(t, a) + i,
1242
+ end: c + o
1243
+ };
1244
+ }
1245
+ c++;
1246
+ }
1247
+ return null;
1248
+ }
1249
+ var Mr = /* @__PURE__ */ 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("."));
1250
+ function Nr(e) {
1251
+ if (/^ {0,3}<(!--|\?|![A-Za-z]|!\[CDATA\[)/.test(e)) return !0;
1252
+ let t = e.match(/^ {0,3}<\/?([a-zA-Z][a-zA-Z0-9-]*)(?:\s|\/?>|$)/);
1253
+ return t ? Mr.has(t[1].toLowerCase()) : !1;
1254
+ }
1255
+ function Pr(e) {
1256
+ let t = e.split("\n"), n = [], r = 0, i = !0;
1257
+ for (; r < t.length;) {
1258
+ let e = t[r];
1259
+ if (e.trim() === "") {
1260
+ i = !0, r++;
1261
+ continue;
1262
+ }
1263
+ let a = e.match(/^ {0,3}(`{3,}|~{3,})(.*)$/);
1264
+ if (a) {
1265
+ let e = a[1], o = e[0], s = e.length, c = a[2].trim(), l = [];
1266
+ for (r++; r < t.length;) {
1267
+ if (t[r].match(RegExp(`^ {0,3}${o}{${s},}\\s*$`))) {
1268
+ r++;
1269
+ break;
1270
+ }
1271
+ l.push(t[r]), r++;
1272
+ }
1273
+ n.push({
1274
+ type: "codeBlock",
1275
+ language: c || "",
1276
+ code: l.join("\n")
1277
+ }), i = !1;
1278
+ continue;
1279
+ }
1280
+ let o = e.match(/^(#{1,6})\s+(.+?)(?:\s+#+\s*|\s*)$/);
1281
+ if (o) {
1282
+ n.push({
1283
+ type: "heading",
1284
+ level: o[1].length,
1285
+ content: o[2]
1286
+ }), i = !1, r++;
1287
+ continue;
1288
+ }
1289
+ if (/^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(e)) {
1290
+ let t = n.at(-1);
1291
+ if (!i && e.trim().match(/^-+$/) && t && t.type === "paragraph") {
1292
+ let e = t;
1293
+ n[n.length - 1] = {
1294
+ type: "heading",
1295
+ level: 2,
1296
+ content: e.content
1297
+ }, i = !1, r++;
1298
+ continue;
1299
+ }
1300
+ n.push({ type: "hr" }), i = !1, r++;
1301
+ continue;
1302
+ }
1303
+ if (r + 1 < t.length) {
1304
+ let a = t[r + 1];
1305
+ if (/^={1,}\s*$/.test(a) && e.trim().length > 0) {
1306
+ n.push({
1307
+ type: "heading",
1308
+ level: 1,
1309
+ content: e.trim()
1310
+ }), i = !1, r += 2;
1311
+ continue;
1312
+ }
1313
+ }
1314
+ let s = Fr(t, r);
1315
+ if (s) {
1316
+ n.push(s.token), r = s.nextLine, i = !1;
1317
+ continue;
1318
+ }
1319
+ if (/^\s{0,3}>/.test(e)) {
1320
+ let e = [];
1321
+ for (; r < t.length && /^\s{0,3}>/.test(t[r]);) e.push(t[r].replace(/^\s{0,3}>\s?/, "")), r++;
1322
+ for (; r < t.length;) {
1323
+ let n = t[r];
1324
+ if (n.trim() === "" || /^\s{0,3}>/.test(n) || /^(#{1,6})\s/.test(n) || /^(`{3,}|~{3,})/.test(n) || /^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(n) || /^\s*([-*+]|\d+[.)])\s+/.test(n) || /^\s*\|(.+\|)+\s*$/.test(n)) break;
1325
+ e.push(n), r++;
1326
+ }
1327
+ n.push({
1328
+ type: "blockquote",
1329
+ content: e.join("\n")
1330
+ }), i = !1;
1331
+ continue;
1332
+ }
1333
+ let c = e.match(/^(\s*)([-*+]|\d+[.)])(\s+)(\[[ xX]\] )?(.*)$/);
1334
+ if (c) {
1335
+ let e = c[1].length, a = c[2], o = c[3], s = c[4], l = c[5], u, d, f;
1336
+ s ? (u = "task", f = s.trim() !== "[ ]") : /^\d+[.)]$/.test(a) ? (u = "ordered", d = parseInt(a, 10)) : u = "bullet";
1337
+ let p = e + a.length + o.length + (s ? s.length : 0), m = e + 1, h = (e) => {
1338
+ if (e.trim() === "") return !0;
1339
+ let t = e.match(/^\s*/)[0].length;
1340
+ return !!(t >= p || t >= m && e.match(/^\s*([-*+]|\d+[.)])\s+/));
1341
+ };
1342
+ r++;
1343
+ let g = [];
1344
+ for (; r < t.length;) {
1345
+ let e = t[r];
1346
+ if (e.trim() === "") {
1347
+ let e = r + 1;
1348
+ for (; e < t.length && t[e].trim() === "";) e++;
1349
+ if (e < t.length && h(t[e])) {
1350
+ g.push(""), r++;
1351
+ continue;
1352
+ }
1353
+ break;
1354
+ }
1355
+ if (!h(e)) break;
1356
+ e.match(/^\s*/)[0].length >= p ? g.push(e.substring(p)) : g.push(e.substring(m)), r++;
1357
+ }
1358
+ let _ = g.join("\n").replace(/^\n+|\n+$/g, "");
1359
+ n.push({
1360
+ type: "listItem",
1361
+ listType: u,
1362
+ indent: e,
1363
+ content: l.trim(),
1364
+ start: d,
1365
+ checked: f,
1366
+ childContent: _ || void 0
1367
+ }), i = !1;
1368
+ continue;
1369
+ }
1370
+ if (Nr(e)) {
1371
+ let e = [];
1372
+ for (; r < t.length && t[r].trim() !== "";) e.push(t[r]), r++;
1373
+ n.push({
1374
+ type: "rawHtml",
1375
+ content: e.join("\n")
1376
+ }), i = !1;
1377
+ continue;
1378
+ }
1379
+ let l = [e];
1380
+ for (r++; r < t.length;) {
1381
+ let e = t[r];
1382
+ 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) || Nr(e) || r + 1 < t.length && /^[=-]+\s*$/.test(t[r + 1]) && e.trim().length > 0) break;
1383
+ l.push(e), r++;
1384
+ }
1385
+ n.push({
1386
+ type: "paragraph",
1387
+ content: l.map((e) => e.replace(/^ {1,3}/, "")).join("\n").replace(/[ \t]+$/, "")
1388
+ }), i = !1;
1389
+ }
1390
+ return n;
1391
+ }
1392
+ function Fr(e, t) {
1393
+ if (t + 1 >= e.length) return null;
1394
+ let n = e[t], r = e[t + 1];
1395
+ if (!r.includes("|") || !/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/.test(r) || !n.includes("|")) return null;
1396
+ let i = Ir(n), a = Lr(r), o = [], s = t + 2;
1397
+ for (; s < e.length;) {
1398
+ let t = e[s];
1399
+ if (!t.includes("|")) break;
1400
+ o.push(Ir(t)), s++;
1401
+ }
1402
+ return {
1403
+ token: {
1404
+ type: "table",
1405
+ headers: i,
1406
+ rows: o,
1407
+ alignments: a
1408
+ },
1409
+ nextLine: s
1410
+ };
1411
+ }
1412
+ function Ir(e) {
1413
+ let t = e.trim(), n = t.startsWith("|") ? t.substring(1) : t, r = n.endsWith("|") ? n.substring(0, n.length - 1) : n, i = [], a = "";
1414
+ 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];
1415
+ return i.push(a.trim()), i;
1416
+ }
1417
+ function Lr(e) {
1418
+ return Ir(e).map((e) => {
1419
+ let t = e.trim(), n = t.startsWith(":"), r = t.endsWith(":");
1420
+ return n && r ? "center" : r ? "right" : n ? "left" : null;
1421
+ });
1422
+ }
1423
+ function Rr(e) {
1424
+ let t = "", n = 0;
1425
+ for (; n < e.length;) {
1426
+ let r = e[n];
1427
+ switch (r.type) {
1428
+ case "heading": {
1429
+ let e = r;
1430
+ t += `<h${e.level}>${Z(e.content)}</h${e.level}>`, n++;
1431
+ break;
1432
+ }
1433
+ case "paragraph":
1434
+ t += `<p>${Z(r.content)}</p>`, n++;
1435
+ break;
1436
+ case "codeBlock": {
1437
+ let e = r, i = e.language ? ` data-language="${X(e.language)}"` : "";
1438
+ t += `<pre><code${i}>${X(e.code)}</code></pre>`, n++;
1439
+ break;
1440
+ }
1441
+ case "blockquote": {
1442
+ let e = Rr(Pr(r.content));
1443
+ t += `<blockquote>${e}</blockquote>`, n++;
1444
+ break;
1445
+ }
1446
+ case "hr":
1447
+ t += "<hr>", n++;
1448
+ break;
1449
+ case "listItem": {
1450
+ let r = zr(e, n);
1451
+ t += r.html, n = r.nextIndex;
1452
+ break;
1453
+ }
1454
+ case "table":
1455
+ t += Vr(r), n++;
1456
+ break;
1457
+ case "rawHtml":
1458
+ t += r.content, n++;
1459
+ break;
1460
+ default: n++;
1461
+ }
1462
+ }
1463
+ return t;
1464
+ }
1465
+ function zr(e, t) {
1466
+ let n = "", r = t, i = null;
1467
+ for (; r < e.length && e[r].type === "listItem";) {
1468
+ let t = e[r], a = Br(t.listType);
1469
+ if (i !== null && i !== a && (n += `</${i === "ordered" ? "ol" : "ul"}>`, i = null), i === null) {
1470
+ if (a === "ordered") {
1471
+ let e = t.start !== void 0 && t.start !== 1 ? ` start="${t.start}"` : "";
1472
+ n += `<ol${e}>`;
1473
+ } else n += "<ul>";
1474
+ i = a;
1475
+ }
1476
+ if (t.listType === "task") {
1477
+ let e = t.checked ? " checked" : "";
1478
+ n += `<li><input type="checkbox" disabled${e}><p>${Z(t.content)}</p>`;
1479
+ } else n += `<li><p>${Z(t.content)}</p>`;
1480
+ if (t.childContent) {
1481
+ let e = Pr(t.childContent);
1482
+ n += Rr(e);
1483
+ }
1484
+ n += "</li>", r++;
1485
+ }
1486
+ return i !== null && (n += `</${i === "ordered" ? "ol" : "ul"}>`), {
1487
+ html: n,
1488
+ nextIndex: r
1489
+ };
1490
+ }
1491
+ function Br(e) {
1492
+ return e === "ordered" ? "ordered" : "bullet";
1493
+ }
1494
+ function Vr(e) {
1495
+ let t = "<table>", n = e.headers.every((e) => e.trim() === ""), r = e.headers.length;
1496
+ if (!n) {
1497
+ t += "<thead><tr>";
1498
+ for (let n = 0; n < r; n++) {
1499
+ let r = e.alignments[n], i = r ? ` align="${r}"` : "";
1500
+ t += `<th${i}>${Z(e.headers[n])}</th>`;
1501
+ }
1502
+ t += "</tr></thead>";
1503
+ }
1504
+ if (e.rows.length > 0) {
1505
+ t += "<tbody>";
1506
+ for (let n of e.rows) {
1507
+ t += "<tr>";
1508
+ for (let i = 0; i < r; i++) {
1509
+ let r = i < n.length ? n[i] : "", a = e.alignments[i], o = a ? ` align="${a}"` : "";
1510
+ t += `<td${o}>${Z(r)}</td>`;
1511
+ }
1512
+ t += "</tr>";
1513
+ }
1514
+ t += "</tbody>";
1515
+ }
1516
+ return t += "</table>", t;
1517
+ }
1518
+ function Hr(e) {
1519
+ return Rr(Pr(e));
1520
+ }
1521
+ // src/api/parsers/markdown/parseMarkdown.ts
1522
+ function Ur(e) {
1523
+ return Hr(e);
1524
+ }
1525
+ function Wr(e, t) {
1526
+ return rr(Ur(e), t);
1527
+ }
1528
+ // src/editor/managers/ExportManager.ts
1529
+ var Gr = class {
1530
+ editor;
1531
+ constructor(e) {
1532
+ this.editor = e;
1533
+ }
1534
+ blocksToHTMLLossy(e = this.editor.document) {
1535
+ return Le(this.editor.pmSchema, this.editor).exportBlocks(e, {});
1536
+ }
1537
+ blocksToFullHTML(e = this.editor.document) {
1538
+ return un(this.editor.pmSchema, this.editor).serializeBlocks(e, {});
1539
+ }
1540
+ tryParseHTMLToBlocks(e) {
1541
+ return rr(e, this.editor.pmSchema);
1542
+ }
1543
+ blocksToMarkdownLossy(e = this.editor.document) {
1544
+ return qe(e, this.editor.pmSchema, this.editor, {});
1545
+ }
1546
+ tryParseMarkdownToBlocks(e) {
1547
+ return Wr(e, this.editor.pmSchema);
1548
+ }
1549
+ pasteHTML(e, t = !1) {
1550
+ let n = e;
1551
+ if (!t) {
1552
+ let t = this.tryParseHTMLToBlocks(e);
1553
+ n = this.blocksToFullHTML(t);
1554
+ }
1555
+ n && this.editor.prosemirrorView?.pasteHTML(n);
1556
+ }
1557
+ pasteText(e) {
1558
+ return this.editor.prosemirrorView?.pasteText(e);
1559
+ }
1560
+ pasteMarkdown(e) {
1561
+ let t = Ur(e);
1562
+ return this.pasteHTML(t);
1563
+ }
1564
+ };
1565
+ // src/api/blockManipulation/selections/textCursorPosition.ts
1566
+ function Kr(e) {
1567
+ let { block: t } = v(e), n = e.doc.resolve(t.beforePos).nodeBefore, r = e.doc.resolve(t.afterPos).nodeAfter, i = x(e.doc, t.beforePos)?.block.node;
1568
+ return {
1569
+ block: y(t.node, e.doc),
1570
+ prevBlock: n === null ? void 0 : y(n, e.doc),
1571
+ nextBlock: r === null ? void 0 : y(r, e.doc),
1572
+ parentBlock: i === void 0 ? void 0 : y(i, e.doc)
1573
+ };
1574
+ }
1575
+ function qr(e, n, r = "start") {
1576
+ let i = typeof n == "string" ? n : n.id, a = M(i, e.doc);
1577
+ if (!a) throw Error(`Block with ID ${i} not found`);
1578
+ e.setSelection(l(e.doc, t(a.node, a.posBeforeNode), r));
1579
+ }
1580
+ // src/api/clipboard/fromClipboard/acceptedMIMETypes.ts
1581
+ var $ = [
1582
+ "vscode-editor-data",
1583
+ "blocknote/html",
1584
+ "text/markdown",
1585
+ "text/html",
1586
+ "text/plain",
1587
+ "Files"
1588
+ ];
1589
+ // src/api/clipboard/fromClipboard/handleFileInsertion.ts
1590
+ function Jr(e, t) {
1591
+ if (!e.startsWith(".") || !t.startsWith(".")) throw Error("The strings provided are not valid file extensions.");
1592
+ return e === t;
1593
+ }
1594
+ function Yr(e, t) {
1595
+ let n = e.split("/"), r = t.split("/");
1596
+ if (n.length !== 2) throw Error(`The string ${e} is not a valid MIME type.`);
1597
+ if (r.length !== 2) throw Error(`The string ${t} is not a valid MIME type.`);
1598
+ return n[1] === "*" || r[1] === "*" ? n[0] === r[0] : (n[0] === "*" || r[0] === "*" || n[0] === r[0]) && n[1] === r[1];
1599
+ }
1600
+ function Xr(e, t, n, r = "after") {
1601
+ let i;
1602
+ return i = Array.isArray(t.content) && t.content.length === 0 ? e.updateBlock(t, n).id : e.insertBlocks([n], t, r)[0].id, i;
1603
+ }
1604
+ async function Zr(e, t) {
1605
+ if (!t.uploadFile) {
1606
+ console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");
1607
+ return;
1608
+ }
1609
+ let n = "dataTransfer" in e ? e.dataTransfer : e.clipboardData;
1610
+ if (n === null) return;
1611
+ let r = null;
1612
+ for (let e of $) if (n.types.includes(e)) {
1613
+ r = e;
1614
+ break;
1615
+ }
1616
+ if (r !== "Files") return;
1617
+ let a = n.items;
1618
+ if (!a) return;
1619
+ e.preventDefault();
1620
+ let o = Array.from(a, (e) => ({
1621
+ file: e.getAsFile(),
1622
+ type: e.type
1623
+ }));
1624
+ for (let { file: n, type: r } of o) {
1625
+ let a = "file";
1626
+ for (let e of Object.values(t.schema.blockSpecs)) for (let t of e.implementation.meta.fileBlockAccept || []) {
1627
+ let i = t.startsWith(".");
1628
+ if (n && (!i && n.type && Yr(r, t) || i && Jr("." + n.name.split(".").pop(), t))) {
1629
+ a = e.config.type;
1630
+ break;
1631
+ }
1632
+ }
1633
+ if (n) {
1634
+ let r = {
1635
+ type: a,
1636
+ props: { name: n.name }
1637
+ }, o;
1638
+ if (e.type === "paste") {
1639
+ let e = t.getTextCursorPosition().block;
1640
+ o = Xr(t, e, r);
1641
+ } else if (e.type === "drop") {
1642
+ let n = {
1643
+ left: e.clientX,
1644
+ top: e.clientY
1645
+ }, a = t.prosemirrorView.posAtCoords(n);
1646
+ if (!a) return;
1647
+ o = t.transact((e) => {
1648
+ let o = i(e, a.pos), c = s(o.block.node, e.doc), l = (t.domElement?.querySelector(`[data-id="${c}"]`))?.getBoundingClientRect(), u = t.getBlock(c);
1649
+ if (u) return Xr(t, u, r, l && (l.top + l.bottom) / 2 > n.top ? "before" : "after");
1650
+ });
1651
+ } else return;
1652
+ if (!o) return;
1653
+ let c = await t.uploadFile(n, o).catch(() => void 0);
1654
+ if (c === void 0 || !t.getBlock(o)) continue;
1655
+ let l = typeof c == "string" ? { props: { url: c } } : { ...c };
1656
+ t.updateBlock(o, l);
1657
+ }
1658
+ }
1659
+ }
1660
+ // src/api/clipboard/fromClipboard/fileDropExtension.ts
1661
+ var Qr = (e) => H.create({
1662
+ name: "dropFile",
1663
+ addProseMirrorPlugins() {
1664
+ return [new L({ props: { handleDOMEvents: { drop(t, n) {
1665
+ if (!e.isEditable) return;
1666
+ let r = null;
1667
+ for (let e of $) if (n.dataTransfer.types.includes(e)) {
1668
+ r = e;
1669
+ break;
1670
+ }
1671
+ return r === null || r === "Files" && (Zr(n, e), !0);
1672
+ } } } })];
1673
+ }
1674
+ }), $r = /(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/, ei = /(_|__|\*|\*\*|~~|==|\+\+)(?!\s)(?:[^\s](?:.{0,62}[^\s])?|\S)(?=\1)/, ti = /\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/, ni = /(?:\s|^)`(?!\s)(?:[^\s`](?:[^`]{0,46}[^\s`])?|[^\s`])`([^\w]|$)/, ri = /(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/, ii = /(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/, ai = /\n{2} {0,3}-{2,48}\n{2}/, oi = /(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/, si = /(?:\n|^)(?!\s)\w[^\n]{0,64}\r?\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/, ci = /(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/, li = /^\s*\|(.+\|)+\s*$/m, ui = /^\s*\|(\s*[-:]+[-:]\s*\|)+\s*$/m, di = /^\s*\|(.+\|)+\s*$/m, fi = (e) => $r.test(e) || ei.test(e) || ti.test(e) || ni.test(e) || ri.test(e) || ii.test(e) || ai.test(e) || oi.test(e) || si.test(e) || ci.test(e) || li.test(e) || ui.test(e) || di.test(e);
1675
+ // src/api/clipboard/fromClipboard/handleVSCodePaste.ts
1676
+ function pi(e, t) {
1677
+ let { schema: n } = t.state;
1678
+ if (!e.clipboardData) return !1;
1679
+ let r = e.clipboardData.getData("text/plain");
1680
+ if (!r || !n.nodes.codeBlock) return !1;
1681
+ let i = e.clipboardData.getData("vscode-editor-data"), a = (i ? JSON.parse(i) : void 0)?.mode;
1682
+ return a ? (t.pasteHTML(`<pre><code class="language-${a}">${r.replace(/\r\n?/g, "\n")}</code></pre>`), !0) : !1;
1683
+ }
1684
+ // src/api/clipboard/fromClipboard/normalizeOfficeHTML.ts
1685
+ var mi = /urn:schemas-microsoft-com:office:word|<meta\b[^>]*Word\.Document|mso-list\s*:\s*l\d+\s+level\d+/i, hi = "[id^=\"docs-internal-guid-\"]";
1686
+ function gi(e) {
1687
+ return e.getAttribute("style")?.match(/(?:^|;)\s*mso-list\s*:\s*([^;]+)/i)?.[1].trim();
1688
+ }
1689
+ function _i(e) {
1690
+ let t = gi(e)?.match(/^l(\d+)\s+level(\d+)\s+lfo(\d+)$/i);
1691
+ return t ? {
1692
+ level: Number(t[2]),
1693
+ id: `${t[1]}:${t[3]}`
1694
+ } : void 0;
1695
+ }
1696
+ function vi(e) {
1697
+ return e.nodeType === 8 || e.nodeType === 3 && !e.textContent?.trim();
1698
+ }
1699
+ function yi(e) {
1700
+ let t = e;
1701
+ for (;;) {
1702
+ let e = Array.from(t.childNodes).filter((e) => !vi(e)), n = e[0];
1703
+ if (e.length !== 1 || !(n instanceof Element) || !/^(UL|OL)$/.test(n.tagName)) break;
1704
+ t = n;
1705
+ }
1706
+ let n = Array.from(t.childNodes).filter((e) => !vi(e));
1707
+ if (!n.every((e) => e instanceof HTMLLIElement)) return;
1708
+ let r = n[0], i = r && _i(r);
1709
+ if (i && n.every((e) => {
1710
+ let t = _i(e);
1711
+ return t?.id === i.id && t.level === i.level;
1712
+ })) return {
1713
+ list: t,
1714
+ items: n,
1715
+ ...i
1716
+ };
1717
+ }
1718
+ function bi(e) {
1719
+ let t = [], n;
1720
+ for (let r of e.querySelectorAll("p[style], ul, ol")) {
1721
+ if (r.parentElement?.closest("ul, ol, li")) continue;
1722
+ let i = r.tagName !== "P", a = i ? yi(r) : void 0, o = i ? a : _i(r);
1723
+ if (!o) continue;
1724
+ let { level: s, id: c } = o, l = r.previousSibling;
1725
+ for (; l && vi(l);) l = l.previousSibling;
1726
+ for ((c !== n || l !== t[0]?.element) && (t.length = 0), n = c; t.length && t[t.length - 1].level > s;) t.pop();
1727
+ if (a) {
1728
+ let e = t[t.length - 1], n = a.items[a.items.length - 1];
1729
+ if (e?.level === s) {
1730
+ if (e.element.tagName !== a.list.tagName) {
1731
+ t.length = 0;
1732
+ continue;
1733
+ }
1734
+ e.element.append(...a.list.childNodes), e.lastItem = n, r.remove();
1735
+ } else e && s === e.level + 1 ? (e.lastItem.append(a.list), r !== a.list && r.remove(), t.push({
1736
+ element: a.list,
1737
+ level: s,
1738
+ lastItem: n
1739
+ })) : !e && r === a.list ? t.push({
1740
+ element: a.list,
1741
+ level: s,
1742
+ lastItem: n
1743
+ }) : t.length = 0;
1744
+ continue;
1745
+ }
1746
+ let u = "", d = [];
1747
+ for (let e of r.querySelectorAll("span[style]")) gi(e)?.toLowerCase() === "ignore" && !d.some((t) => t.contains(e)) && (u += e.textContent, d.push(e));
1748
+ u = u.trim();
1749
+ let f = /^(?:[0-9]+[.)]|\([0-9]+\))$/.test(u);
1750
+ if (!f && u && !/^[·•o▪●○■□‣⁃\-\uF0B7]$/u.test(u)) {
1751
+ t.length = 0;
1752
+ continue;
1753
+ }
1754
+ let p = f ? "ol" : "ul";
1755
+ for (let e of d) e.remove();
1756
+ t[t.length - 1]?.level === s && t[t.length - 1].element.tagName.toLowerCase() !== p && t.pop();
1757
+ let m = e.ownerDocument.createElement("li");
1758
+ m.setAttribute("style", r.getAttribute("style"));
1759
+ let h = t[t.length - 1];
1760
+ if (!h || h.level !== s) {
1761
+ let n = e.ownerDocument.createElement(p);
1762
+ h ? h.lastItem.append(n) : r.before(n), h = {
1763
+ element: n,
1764
+ level: s,
1765
+ lastItem: m
1766
+ }, t.push(h);
1767
+ }
1768
+ h.element.append(m), h.lastItem = m, m.append(r);
1769
+ }
1770
+ }
1771
+ function xi(e) {
1772
+ let t = mi.test(e);
1773
+ if (!t && !e.includes("docs-internal-guid-")) return e;
1774
+ let n = globalThis.document.implementation.createHTMLDocument(""), r = n.createElement("div");
1775
+ if (r.innerHTML = e, t) {
1776
+ for (let e of Array.from(r.getElementsByTagName("o:p"))) {
1777
+ let t = e.closest("p");
1778
+ e.remove(), t && !t.textContent?.trim() && !t.querySelector("br, img, svg, video, audio, iframe, object, input") && t.append("");
1779
+ }
1780
+ bi(r);
1781
+ }
1782
+ for (let e of r.querySelectorAll(hi)) if (e.matches("b, div") && !e.parentElement?.closest("p, h1, h2, h3, h4, h5, h6, pre") && !Array.from(e.childNodes).some((e) => e.nodeType === 3 && !!e.textContent?.trim() || e.nodeType === 1 && !/^(BR|P|DIV|H[1-6]|UL|OL|TABLE|BLOCKQUOTE|PRE|HR|FIGURE)$/.test(e.nodeName))) for (let t of e.querySelectorAll(":scope > br")) {
1783
+ let e = n.createElement("p");
1784
+ e.textContent = "", t.replaceWith(e);
1785
+ }
1786
+ return r.innerHTML;
1787
+ }
1788
+ // src/api/clipboard/fromClipboard/pasteExtension.ts
1789
+ function Si({ event: e, editor: t, prioritizeMarkdownOverHTML: n, plainTextAsMarkdown: r }) {
1790
+ if (t.transact((e) => e.selection.$from.parent.type.spec.code && e.selection.$to.parent.type.spec.code)) {
1791
+ let n = e.clipboardData?.getData("text/plain");
1792
+ if (n) return t.pasteText(n), !0;
1793
+ }
1794
+ let i;
1795
+ for (let t of $) if (e.clipboardData.types.includes(t)) {
1796
+ i = t;
1797
+ break;
1798
+ }
1799
+ if (!i) return !0;
1800
+ if (i === "vscode-editor-data") {
1801
+ if (pi(e, t.prosemirrorView)) return !0;
1802
+ i = "text/plain";
1803
+ }
1804
+ if (i === "Files") return Zr(e, t), !0;
1805
+ let a = e.clipboardData.getData(i);
1806
+ if (i === "blocknote/html") return t.pasteHTML(a, !0), !0;
1807
+ if (i === "text/markdown") return t.pasteMarkdown(a), !0;
1808
+ if (n) {
1809
+ let n = e.clipboardData.getData("text/plain");
1810
+ if (fi(n)) return t.pasteMarkdown(n), !0;
1811
+ }
1812
+ return i === "text/html" ? (t.pasteHTML(xi(a)), !0) : r ? (t.pasteMarkdown(a), !0) : (t.pasteText(a), !0);
1813
+ }
1814
+ var Ci = (e, t) => H.create({
1815
+ name: "pasteFromClipboard",
1816
+ addProseMirrorPlugins() {
1817
+ return [new L({ props: { handleDOMEvents: { paste(n, r) {
1818
+ if (r.preventDefault(), e.isEditable) return t({
1819
+ event: r,
1820
+ editor: e,
1821
+ defaultPasteHandler: ({ prioritizeMarkdownOverHTML: t = !0, plainTextAsMarkdown: n = !0 } = {}) => Si({
1822
+ event: r,
1823
+ editor: e,
1824
+ prioritizeMarkdownOverHTML: t,
1825
+ plainTextAsMarkdown: n
1826
+ })
1827
+ });
1828
+ } } } })];
1829
+ }
1830
+ });
1831
+ // src/api/clipboard/toClipboard/copyExtension.ts
1832
+ function wi(e, t, n) {
1833
+ let r = !1, i = e.state.selection instanceof K;
1834
+ if (!i) {
1835
+ let n = e.state.doc.slice(e.state.selection.from, e.state.selection.to, !1).content, i = [];
1836
+ for (let e = 0; e < n.childCount; e++) i.push(n.child(e));
1837
+ r = i.find((e) => e.type.isInGroup("bnBlock") || e.type.name === "blockGroup" || e.type.spec.group === "blockContent") === void 0, r && (t = n);
1838
+ }
1839
+ let a, s = Le(e.state.schema, n);
1840
+ if (i) {
1841
+ t.firstChild?.type.name === "table" && (t = t.firstChild.content);
1842
+ let e = o(t, n.schema.inlineContentSchema, n.schema.styleSchema);
1843
+ a = `<table>${s.exportInlineContent(e, {})}</table>`;
1844
+ } else if (r) {
1845
+ let e = pe(t, n.schema.inlineContentSchema, n.schema.styleSchema);
1846
+ a = s.exportInlineContent(e, {});
1847
+ } else {
1848
+ let e = ke(t);
1849
+ a = s.exportBlocks(e, {});
1850
+ }
1851
+ return a;
1852
+ }
1853
+ function Ti(e, t) {
1854
+ "node" in e.state.selection && e.state.selection.node.type.spec.group === "blockContent" && t.transact((t) => t.setSelection(new I(t.doc.resolve(e.state.selection.from - 1))));
1855
+ function n(e) {
1856
+ let t = [];
1857
+ return e.forEach((e) => {
1858
+ let r = e.mark(e.marks.filter((e) => !e.type.spec.blocknoteIgnore));
1859
+ t.push(r.content.size > 0 ? r.copy(n(r.content)) : r);
1860
+ }), N.fromArray(t);
1861
+ }
1862
+ let r = e.state.selection.content(), i = e.serializeForClipboard(new P(n(r.content), r.openStart, r.openEnd)).dom.innerHTML, a = wi(e, r.content, t), { $from: o, $to: s } = e.state.selection, c = o.parent.type.name, l = t.schema.blockSpecs[c];
1863
+ return {
1864
+ clipboardHTML: i,
1865
+ externalHTML: a,
1866
+ markdown: o.sameParent(s) && l?.implementation.meta.code === !0 ? e.state.doc.textBetween(o.pos, s.pos) : ze(a)
1867
+ };
1868
+ }
1869
+ var Ei = (e) => {
1870
+ if (e.state.selection.empty) return !0;
1871
+ let t = window.getSelection();
1872
+ if (t && !t.isCollapsed) {
1873
+ let e = t.focusNode;
1874
+ for (; e;) {
1875
+ if (e instanceof HTMLElement && e.getAttribute("contenteditable") === "false") return !0;
1876
+ e = e.parentElement;
1877
+ }
1878
+ }
1879
+ return !1;
1880
+ }, Di = (e, t, n) => {
1881
+ n.preventDefault(), n.clipboardData.clearData();
1882
+ let { clipboardHTML: r, externalHTML: i, markdown: a } = Ti(t, e);
1883
+ n.clipboardData.setData("blocknote/html", r), n.clipboardData.setData("text/html", i), n.clipboardData.setData("text/plain", a);
1884
+ }, Oi = (e) => H.create({
1885
+ name: "copyToClipboard",
1886
+ addProseMirrorPlugins() {
1887
+ return [new L({ props: { handleDOMEvents: {
1888
+ copy(t, n) {
1889
+ return Ei(t) || Di(e, t, n), !0;
1890
+ },
1891
+ cut(t, n) {
1892
+ return Ei(t) || (Di(e, t, n), t.editable && t.dispatch(t.state.tr.deleteSelection())), !0;
1893
+ },
1894
+ dragstart(t, n) {
1895
+ if (!("node" in t.state.selection) || t.state.selection.node.type.spec.group !== "blockContent") return;
1896
+ e.transact((e) => e.setSelection(new I(e.doc.resolve(t.state.selection.from - 1)))), n.preventDefault(), n.dataTransfer.clearData();
1897
+ let { clipboardHTML: r, externalHTML: i, markdown: a } = Ti(t, e);
1898
+ return n.dataTransfer.setData("blocknote/html", r), n.dataTransfer.setData("text/html", i), n.dataTransfer.setData("text/plain", a), !0;
1899
+ }
1900
+ } } })];
1901
+ }
1902
+ }), ki = H.create({
1903
+ name: "blockBackgroundColor",
1904
+ addGlobalAttributes() {
1905
+ return [{
1906
+ types: ["tableCell", "tableHeader"],
1907
+ attributes: { backgroundColor: Ce() }
1908
+ }];
1909
+ }
1910
+ }), Ai = U.create({
1911
+ name: "hardBreak",
1912
+ inline: !0,
1913
+ group: "inline",
1914
+ selectable: !1,
1915
+ linebreakReplacement: !0,
1916
+ priority: 10,
1917
+ parseHTML() {
1918
+ return [{ tag: "br" }];
1919
+ },
1920
+ renderHTML({ HTMLAttributes: e }) {
1921
+ return ["br", G(this.options.HTMLAttributes, e)];
1922
+ },
1923
+ renderText() {
1924
+ return "\n";
1925
+ }
1926
+ });
1927
+ // src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts
1928
+ function ji(e, t) {
1929
+ return e.contentKind === "inline" && t.contentKind === "inline" ? t.content.node.content : void 0;
1930
+ }
1931
+ function Mi(e, t, n, r) {
1932
+ if (!n.children) return !1;
1933
+ let i = ji(n, r);
1934
+ if (i === void 0 || i.size > 0 && !n.content.node.type.validContent(n.content.node.content.append(i))) return !1;
1935
+ if (t) {
1936
+ let a = e.tr;
1937
+ n.children.node.childCount === 1 && !r.children ? a.delete(n.children.beforePos, n.children.afterPos) : a.replaceWith(r.block.beforePos, r.block.afterPos, r.children?.node.content ?? N.empty);
1938
+ let o = n.contentEnd;
1939
+ i.size > 0 && a.insert(o, i), a.setSelection(R.near(a.doc.resolve(o), -1)), t(a.scrollIntoView());
1940
+ }
1941
+ return !0;
1942
+ }
1943
+ var Ni = (e) => ({ state: t, dispatch: n }) => {
1944
+ let i = k(t.doc, e);
1945
+ if (!i.hasContent) return !1;
1946
+ let a = b(t.doc, i.block.beforePos);
1947
+ if (!a) {
1948
+ let e = x(t.doc, i.block.beforePos);
1949
+ return e?.hasContent ? Mi(t, n, e, i) : !1;
1950
+ }
1951
+ let o = r(a);
1952
+ if (!o.hasContent || ji(o, i) === void 0) return !1;
1953
+ if (o.isContentEmpty && o.content.node.sameMarkup(i.content.node)) {
1954
+ if (n) {
1955
+ let e = t.tr.delete(i.block.beforePos, i.block.afterPos).replaceWith(o.block.beforePos, o.block.afterPos, i.block.node);
1956
+ e.setSelection(z.create(e.doc, o.contentStart)), n(e.scrollIntoView());
1957
+ }
1958
+ return !0;
1959
+ }
1960
+ if (n && i.children) {
1961
+ let e = t.doc.resolve(i.children.childrenStart).blockRange(t.doc.resolve(i.children.childrenEnd));
1962
+ if (!e) throw Error("Children of a block are expected to form a block range");
1963
+ t.tr.lift(e, t.doc.resolve(i.block.beforePos).depth);
1964
+ }
1965
+ return n && n(t.tr.delete(o.contentEnd, i.contentStart)), !0;
1966
+ }, Pi = (e, t, n, r) => ({ state: i, dispatch: a }) => !a || Fi(i.tr, e, t, n, r), Fi = (e, n, r, i, a) => {
1967
+ let o = c(e.doc, n), s = t(o.node, o.posBeforeNode);
1968
+ if (!s.hasContent) return !1;
1969
+ let l = D(e), u = [{
1970
+ type: s.block.node.type,
1971
+ attrs: i ? {
1972
+ ...s.block.node.attrs,
1973
+ id: void 0
1974
+ } : {}
1975
+ }, {
1976
+ type: r ? s.content.node.type : l.nodes.paragraph,
1977
+ attrs: i ? { ...s.content.node.attrs } : {}
1978
+ }], d = a && n !== s.contentStart ? s.children : void 0;
1979
+ if (d && e.delete(d.beforePos, d.afterPos), e.split(n, 2, u), d) {
1980
+ let t = e.doc.nodeAt(s.block.beforePos);
1981
+ if (!t?.firstChild) throw Error("Split lost its original block");
1982
+ e.insert(s.block.beforePos + 1 + t.firstChild.nodeSize, d.node);
1983
+ }
1984
+ return !0;
1985
+ };
1986
+ // src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts
1987
+ function Ii(e, t, n) {
1988
+ let r = g(e.doc, t.beforePos);
1989
+ e.delete(t.beforePos, t.afterPos);
1990
+ let i = e.mapping.map(n);
1991
+ e.insert(i, t.node);
1992
+ let a = e.steps.length;
1993
+ Lt(e, r), e.setSelection(z.near(e.doc.resolve(e.mapping.slice(a).map(i) + 1)));
1994
+ }
1995
+ function Li(e, t, n, r = n.block) {
1996
+ return e.insertContentAt(n.block.afterPos, n.children?.node.content || N.empty).deleteRange({
1997
+ from: r.beforePos,
1998
+ to: r.afterPos
1999
+ }).insertContentAt(t.contentEnd, ji(t, n) ?? null).setTextSelection(t.contentEnd).scrollIntoView().run();
2000
+ }
2001
+ var Ri = H.create({
2002
+ priority: 50,
2003
+ addKeyboardShortcuts() {
2004
+ let e = this.options.editor;
2005
+ function i(t, n) {
2006
+ let r = y(t, n);
2007
+ return e.schema.blockSpecs[r.type].implementation.keyboard(r);
2008
+ }
2009
+ function a(e) {
2010
+ return (t) => i(t, e).childrenCanOutdent;
2011
+ }
2012
+ let o = () => this.editor.commands.first(({ chain: e, commands: o }) => [
2013
+ () => o.deleteSelection(),
2014
+ () => o.undoInputRule(),
2015
+ () => o.command(({ state: e }) => {
2016
+ let t = v(e);
2017
+ if (!t.hasContent || e.selection.from !== t.contentStart) return !1;
2018
+ let n = i(t.block.node, e.doc).resetsTo, r = t.content.node;
2019
+ return r.type.name === n.type && Object.entries(n.props ?? {}).every(([e, t]) => r.attrs[e] === t) ? !1 : o.command(Rt(t.block.beforePos, n));
2020
+ }),
2021
+ () => o.command(({ state: t }) => {
2022
+ let n = v(t);
2023
+ if (!n.hasContent) return !1;
2024
+ let { block: r } = n, i = b(t.doc, n.block.beforePos);
2025
+ if (i && !i.hasContent) return !1;
2026
+ let a = t.selection.from === n.contentStart, o = t.selection.empty, s = r.beforePos;
2027
+ return a && o ? e().command(Ni(s)).scrollIntoView().run() : !1;
2028
+ }),
2029
+ () => o.command(({ state: e, tr: r, dispatch: i }) => {
2030
+ let a = v(e);
2031
+ if (!a.hasContent || e.selection.from !== a.contentStart) return !1;
2032
+ let o = a.block.node.type, s = b(r.doc, a.block.beforePos), c;
2033
+ if (s) {
2034
+ if (s.hasContent) return !1;
2035
+ } else {
2036
+ let e = r.doc.resolve(a.block.beforePos);
2037
+ if (!w(e.parent.type)) return !1;
2038
+ let i = r.doc.resolve(e.before()), l = i.nodeBefore;
2039
+ w(i.parent.type) && l && w(l.type) ? s = t(l, i.pos - l.nodeSize) : c = n(r.doc, i.pos, o);
2040
+ }
2041
+ return s && (c = re(r.doc, s, "last-child", o)?.pos), c !== void 0 && (i && Ii(r, a.block, c), !0);
2042
+ }),
2043
+ () => o.command(({ state: e, tr: t, dispatch: n }) => {
2044
+ let i = v(e);
2045
+ if (!i.hasContent || !e.selection.empty || i.contentKind !== "inline" || !i.isContentEmpty) return !1;
2046
+ let a = b(e.doc, i.block.beforePos), o = a ? void 0 : x(e.doc, i.block.beforePos), s = a ? r(a) : o;
2047
+ return s?.hasContent ? (n && (o?.children?.node.childCount === 1 && !i.children ? t.delete(o.children.beforePos, o.children.afterPos) : t.replaceWith(i.block.beforePos, i.block.afterPos, i.children?.node.content ?? N.empty), t.setSelection(s.contentKind === "none" ? I.create(t.doc, s.content.beforePos) : z.near(t.doc.resolve(s.contentEnd), -1)), t.scrollIntoView()), !0) : !1;
2048
+ }),
2049
+ () => o.command(({ state: e, tr: t, dispatch: n }) => {
2050
+ let i = v(e);
2051
+ if (!i.hasContent) return !1;
2052
+ let a = e.selection.from === i.contentStart, o = e.selection.empty, s = b(e.doc, i.block.beforePos);
2053
+ if (s && a && o) {
2054
+ let e = r(s);
2055
+ if (!e.hasContent) return !1;
2056
+ if (e.contentKind === "none" || e.contentKind === "inline" && e.isContentEmpty) return n && (t.delete(i.block.beforePos, i.block.afterPos), t.replaceWith(e.block.beforePos, e.block.afterPos, i.block.node), t.setSelection(z.near(t.doc.resolve(e.block.beforePos + 2))), t.scrollIntoView()), !0;
2057
+ }
2058
+ return !1;
2059
+ }),
2060
+ () => o.command(({ state: e, tr: t }) => {
2061
+ let n = v(e);
2062
+ return !n.hasContent || !e.selection.empty || e.selection.from !== n.contentStart ? !1 : Nn(t, t.doc.type.schema.nodes.blockContainer, t.doc.type.schema.nodes.blockGroup, a(t.doc));
2063
+ })
2064
+ ]), s = () => this.editor.commands.first(({ chain: e, commands: n }) => [
2065
+ () => n.deleteSelection(),
2066
+ () => n.command(({ state: t }) => {
2067
+ let n = v(t);
2068
+ if (!n.hasContent || !n.children) return !1;
2069
+ let { children: r } = n;
2070
+ if (r.node.childCount === 0) return !1;
2071
+ let i = t.selection.from === n.contentEnd, a = t.selection.empty, o = k(t.doc, r.childrenStart);
2072
+ return o.hasContent && i && a ? Li(e(), n, o, r.node.childCount === 1 ? r : o.block) : !1;
2073
+ }),
2074
+ () => n.command(({ state: t }) => {
2075
+ let n = v(t);
2076
+ if (!n.hasContent) return !1;
2077
+ let { block: r } = n, i = E(t.doc, n.block.beforePos);
2078
+ if (!i || !i.hasContent) return !1;
2079
+ let a = t.selection.from === n.contentEnd, o = t.selection.empty, s = r.afterPos;
2080
+ return a && o ? e().command(Ni(s)).scrollIntoView().run() : !1;
2081
+ }),
2082
+ () => n.command(({ state: e, tr: n, dispatch: r }) => {
2083
+ let i = v(e);
2084
+ if (!i.hasContent || e.selection.from !== i.contentEnd) return !1;
2085
+ let a = n.doc.resolve(i.block.afterPos);
2086
+ for (; !a.nodeAfter && a.depth > 0 && w(a.parent.type);) a = n.doc.resolve(a.after());
2087
+ let o = a.nodeAfter;
2088
+ if (!o || a.pos === i.block.afterPos && !w(o.type)) return !1;
2089
+ let s = te(t(o, a.pos));
2090
+ return s ? (r && Ii(n, s.block, i.block.afterPos), !0) : !1;
2091
+ }),
2092
+ () => n.command(({ state: t }) => {
2093
+ let n = v(t);
2094
+ if (!n.hasContent) return !1;
2095
+ let r = t.selection.from === n.contentEnd, i = t.selection.empty;
2096
+ if (r && i) {
2097
+ let r, i = n;
2098
+ for (; i && (r = E(t.doc, i.block.beforePos), !r);) i = x(t.doc, i.block.beforePos);
2099
+ return !r || !r.hasContent ? !1 : Li(e(), n, r, r.block);
2100
+ }
2101
+ return !1;
2102
+ }),
2103
+ () => n.command(({ state: t }) => {
2104
+ let n = v(t);
2105
+ if (!n.hasContent) return !1;
2106
+ if (n.isContentEmpty && n.contentKind === "inline") {
2107
+ let r = E(t.doc, n.block.beforePos);
2108
+ if (!r || !r.hasContent) return !1;
2109
+ let i = e();
2110
+ return i.command(({ tr: e }) => (e.setSelection(l(e.doc, r, "start")), !0)), i.deleteRange({
2111
+ from: n.block.beforePos,
2112
+ to: n.block.afterPos
2113
+ }).scrollIntoView().run();
2114
+ }
2115
+ return !1;
2116
+ }),
2117
+ () => n.command(({ state: t }) => {
2118
+ let n = v(t);
2119
+ if (!n.hasContent) return !1;
2120
+ let r = t.selection.from === n.contentEnd, i = t.selection.empty, a = E(t.doc, n.block.beforePos);
2121
+ return !a || !a.hasContent ? !1 : a && r && i && (a.contentKind === "none" || a.contentKind === "inline" && a.isContentEmpty) ? e().deleteRange({
2122
+ from: a.block.beforePos,
2123
+ to: a.block.afterPos
2124
+ }).insertContentAt(n.block.afterPos, a.children?.node.content ?? null).run() : !1;
2125
+ })
2126
+ ]), c = (e = !1) => this.editor.commands.first(({ commands: t, tr: r }) => [
2127
+ () => t.command(({ state: e }) => {
2128
+ let n = v(e);
2129
+ if (!n.hasContent || !e.selection.empty || !n.isContentEmpty) return !1;
2130
+ let r = i(n.block.node, e.doc);
2131
+ return r.emptyEnterResets ? t.command(Rt(n.block.beforePos, r.resetsTo)) : !1;
2132
+ }),
2133
+ () => t.command(({ state: e, tr: t }) => {
2134
+ let n = v(e);
2135
+ if (!n.hasContent) return !1;
2136
+ let { block: r } = n, { depth: o } = e.doc.resolve(r.beforePos), s = e.selection.$anchor.parentOffset === 0, c = e.selection.anchor === e.selection.head, l = n.isContentEmpty;
2137
+ if (s && c && l && o > 1) {
2138
+ let n = x(e.doc, r.beforePos);
2139
+ return n && i(n.block.node, e.doc).emptyChildEnter !== "outdent" ? !1 : Nn(t, t.doc.type.schema.nodes.blockContainer, t.doc.type.schema.nodes.blockGroup, a(t.doc));
2140
+ }
2141
+ return !1;
2142
+ }),
2143
+ () => t.command(({ state: t }) => {
2144
+ let n = v(t), a = this.options.editor.schema.blockSpecs[n.blockNoteType], o = i(n.block.node, t.doc);
2145
+ if (o.enter === "line-break" || e && o.shiftEnter === "line-break") {
2146
+ if (a?.config?.content === "plain") return r.insertText("\n", r.selection.head), !0;
2147
+ let e = r.storedMarks || r.selection.$head.marks().filter((e) => this.editor.extensionManager.splittableMarks.includes(e.type.name));
2148
+ return r.insert(r.selection.head, r.doc.type.schema.nodes.hardBreak.create()).ensureMarks(e), !0;
2149
+ }
2150
+ return !1;
2151
+ }),
2152
+ () => t.command(({ state: e, tr: t, dispatch: r }) => {
2153
+ let a = v(e);
2154
+ if (!a.hasContent) return !1;
2155
+ let o = e.selection.anchor === e.selection.head, s = a.isContentEmpty;
2156
+ if (!o || !s) return !1;
2157
+ let c = t.doc.resolve(a.block.beforePos);
2158
+ if (t.doc.resolve(a.block.afterPos).nodeAfter !== null) return !1;
2159
+ let l = x(t.doc, a.block.beforePos);
2160
+ if (!l || i(l.block.node, t.doc).emptyChildEnter !== "exit-at-end" || c.index() === 0 && l.hasContent) return !1;
2161
+ let u = n(t.doc, l.block.afterPos, e.schema.nodes.blockContainer, "after");
2162
+ return u !== void 0 && (r && (Ii(t, a.block, u), t.scrollIntoView()), !0);
2163
+ }),
2164
+ () => t.command(({ state: e, dispatch: t, tr: n }) => {
2165
+ let r = v(e);
2166
+ if (!r.hasContent) return !1;
2167
+ let { block: a } = r, o = e.selection.$anchor.parentOffset === 0, s = e.selection.anchor === e.selection.head, c = r.isContentEmpty;
2168
+ if (o && s && c && i(r.block.node, e.doc).enter !== "into-children") {
2169
+ let i = a.afterPos, o = i + 2;
2170
+ if (t) {
2171
+ let t = e.schema.nodes.blockContainer.createAndFill(void 0, [e.schema.nodes.paragraph.createAndFill() || void 0, r.children?.node].filter((e) => e !== void 0));
2172
+ n.insert(i, t).setSelection(new z(n.doc.resolve(o))).scrollIntoView(), r.children && n.delete(r.children.beforePos, r.children.afterPos);
2173
+ }
2174
+ return !0;
2175
+ }
2176
+ return !1;
2177
+ }),
2178
+ () => t.command(({ state: e, tr: t, dispatch: n }) => {
2179
+ let r = v(e);
2180
+ if (!r.hasContent || r.contentKind === "table" || !e.selection.empty || r.isContentEmpty || e.selection.from !== r.contentStart) return !1;
2181
+ if (n) {
2182
+ let n = i(r.block.node, e.doc).splitKeepsType ? r.content.node.type : e.schema.nodes.paragraph, a = e.schema.nodes.blockContainer.create(void 0, n.create());
2183
+ t.insert(r.block.beforePos, a).scrollIntoView();
2184
+ }
2185
+ return !0;
2186
+ }),
2187
+ () => t.command(({ state: e, tr: t, dispatch: n }) => {
2188
+ let r = v(e);
2189
+ if (!r.hasContent || i(r.block.node, e.doc).enter !== "into-children" || !e.selection.empty || e.selection.from < r.contentStart || e.selection.from > r.contentEnd) return !1;
2190
+ if (n) {
2191
+ let n = r.content.node.cut(e.selection.from - r.contentStart), i = e.schema.nodes.blockContainer.create(void 0, e.schema.nodes.paragraph.create(void 0, n.content));
2192
+ t.delete(e.selection.from, r.contentEnd);
2193
+ let a = k(t.doc, r.block.beforePos).children, o = a ? a.childrenStart : t.mapping.map(r.content.afterPos);
2194
+ t.insert(o, a ? i : e.schema.nodes.blockGroup.create(void 0, i)).setSelection(new z(t.doc.resolve(o + (a ? 2 : 3)))).scrollIntoView();
2195
+ }
2196
+ return !0;
2197
+ }),
2198
+ () => t.command(({ state: e, chain: t }) => {
2199
+ let n = v(e);
2200
+ if (!n.hasContent) return !1;
2201
+ let r = e.selection.$anchor.parentOffset === 0;
2202
+ if (!n.isContentEmpty) {
2203
+ let a = i(n.block.node, e.doc), o = r || a.splitKeepsType;
2204
+ return t().deleteSelection().command(Pi(e.selection.from, o, r, a.splitKeepsChildren)).scrollIntoView().run(), !0;
2205
+ }
2206
+ return !1;
2207
+ })
2208
+ ]), u = this.options;
2209
+ function d(e) {
2210
+ let { editor: t, tabBehavior: n } = u;
2211
+ return n !== "prefer-indent" && (t.getExtension(de)?.store.state || t.getExtension(fe)?.store.state !== void 0) ? !1 : e ? Fn(t) : jn(t);
2212
+ }
2213
+ return {
2214
+ Backspace: o,
2215
+ Delete: s,
2216
+ Enter: () => c(),
2217
+ "Shift-Enter": () => c(!0),
2218
+ Tab: () => d(!1),
2219
+ "Shift-Tab": () => d(!0),
2220
+ "Shift-Mod-ArrowUp": () => (this.options.editor.moveBlocksUp(), !0),
2221
+ "Shift-Mod-ArrowDown": () => (this.options.editor.moveBlocksDown(), !0),
2222
+ "Mod-z": () => this.options.editor.undo(),
2223
+ "Mod-y": () => this.options.editor.redo(),
2224
+ "Shift-Mod-z": () => this.options.editor.redo(),
2225
+ "Mod-a": () => {
2226
+ let e = this.editor.view, { doc: t, selection: n, tr: r } = e.state, i = z.between(R.atStart(t).$from, R.atEnd(t).$to);
2227
+ if (this.options.selectAllBehavior === "document") return e.dispatch(r.setSelection(i)), !0;
2228
+ let a, o = v(e.state);
2229
+ if (o.hasContent) {
2230
+ let e = o.contentStart, n = o.contentEnd, r = z.between(t.resolve(e), t.resolve(n));
2231
+ !r.empty && r.from >= e && r.to <= n && (a = r);
2232
+ }
2233
+ let s = !a || n.from < a.from || n.to > a.to || n.from === a.from && n.to === a.to;
2234
+ return a && !s ? r.setSelection(a).scrollIntoView() : r.setSelection(i), e.dispatch(r), !0;
2235
+ }
2236
+ };
2237
+ }
2238
+ }), zi = H.create({
2239
+ name: "textAlignment",
2240
+ addGlobalAttributes() {
2241
+ return [{
2242
+ types: ["tableCell", "tableHeader"],
2243
+ attributes: { textAlignment: {
2244
+ default: "left",
2245
+ parseHTML: (e) => e.getAttribute("data-text-alignment"),
2246
+ renderHTML: (e) => e.textAlignment === "left" ? {} : { "data-text-alignment": e.textAlignment }
2247
+ } }
2248
+ }];
2249
+ }
2250
+ }), Bi = H.create({
2251
+ name: "blockTextColor",
2252
+ addGlobalAttributes() {
2253
+ return [{
2254
+ types: [
2255
+ "table",
2256
+ "tableCell",
2257
+ "tableHeader"
2258
+ ],
2259
+ attributes: { textColor: xe() }
2260
+ }];
2261
+ }
2262
+ }), Vi = "[\0- \xA0 ᠎ -\u2029  ]", Hi = new RegExp(Vi), Ui = RegExp(`${Vi}$`), Wi = new RegExp(Vi, "g");
2263
+ // src/extensions/tiptap-extensions/Link/helpers/autolink.ts
2264
+ function Gi(e) {
2265
+ return e.length === 1 ? e[0].isLink : e.length === 3 && e[1].isLink ? ["()", "[]"].includes(e[0].value + e[2].value) : !1;
2266
+ }
2267
+ function Ki(e) {
2268
+ return new bt({
2269
+ key: new xt("autolink"),
2270
+ appendTransaction: (t, n, r) => {
2271
+ let i = t.some((e) => e.docChanged) && !n.doc.eq(r.doc), a = t.some((e) => e.getMeta("preventAutolink"));
2272
+ if (!i || a) return;
2273
+ let { tr: o } = r, s = p(n.doc, t);
2274
+ if (f(s).forEach(({ newRange: t }) => {
2275
+ let n = lt(r.doc, t, (e) => e.isTextblock), i, a;
2276
+ if (n.length > 1) i = n[0], a = r.doc.textBetween(i.pos, i.pos + i.node.nodeSize, void 0, " ");
2277
+ else if (n.length) {
2278
+ let e = r.doc.textBetween(t.from, t.to, " ", " ");
2279
+ if (!Ui.test(e)) return;
2280
+ i = n[0], a = r.doc.textBetween(i.pos, t.to, void 0, " ");
2281
+ }
2282
+ if (i && a) {
2283
+ let t = a.split(Hi).filter(Boolean);
2284
+ if (t.length <= 0) return;
2285
+ let n = t.at(-1) ?? "", s = i.pos + a.lastIndexOf(n);
2286
+ if (!n) return;
2287
+ let c = Te(n, e.defaultProtocol);
2288
+ if (!Gi(c)) return;
2289
+ c.filter((e) => e.isLink).map((e) => ({
2290
+ ...e,
2291
+ from: s + e.start + 1,
2292
+ to: s + e.end + 1
2293
+ })).filter((e) => !r.schema.marks.code || !r.doc.rangeHasMark(e.from, e.to, r.schema.marks.code)).filter((t) => e.validate(t.value)).filter((t) => e.shouldAutoLink(t.value)).forEach((t) => {
2294
+ pt(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 }));
2295
+ });
2296
+ }
2297
+ }), o.steps.length) return o;
2298
+ }
2299
+ });
2300
+ }
2301
+ // src/extensions/tiptap-extensions/Link/helpers/clickHandler.ts
2302
+ function qi(e) {
2303
+ return new bt({
2304
+ key: new xt("handleClickLink"),
2305
+ props: { handleClick: (t, n, r) => {
2306
+ if (r.button !== 0 || !t.editable) return !1;
2307
+ let i = null;
2308
+ if (r.target instanceof HTMLAnchorElement && r.target.getAttribute("data-inline-content-type") === "link") i = r.target;
2309
+ else {
2310
+ let t = r.target;
2311
+ if (!t) return !1;
2312
+ let n = e.tiptapEditor.view.dom;
2313
+ i = t.closest("a[data-inline-content-type=\"link\"]"), i && !n.contains(i) && (i = null);
2314
+ }
2315
+ if (!i) return !1;
2316
+ if (e.onClick) {
2317
+ if (!e.editor) throw Error("BlockNoteEditor not found in Link click handler");
2318
+ return e.onClick(r, e.editor) ?? !0;
2319
+ }
2320
+ let a = dt(t.state, e.type.name), o = i.href ?? a.href, s = i.target ?? a.target;
2321
+ return o ? (window.open(o, s), !0) : !1;
2322
+ } }
2323
+ });
2324
+ }
2325
+ // src/extensions/tiptap-extensions/Link/helpers/pasteHandler.ts
2326
+ function Ji(e) {
2327
+ return new bt({
2328
+ key: new xt("handlePasteLink"),
2329
+ props: { handlePaste: (t, n, r) => {
2330
+ let { shouldAutoLink: i, isValidLink: a } = e, { state: o } = t, { selection: s } = o, { empty: c } = s;
2331
+ if (c) return !1;
2332
+ let l = "";
2333
+ r.content.forEach((e) => {
2334
+ l += e.textContent;
2335
+ });
2336
+ let u = Fe(l, { defaultProtocol: e.defaultProtocol }).find((e) => e.isLink && e.value === l);
2337
+ return !l || !u || !a(u.value) || i !== void 0 && !i(u.value) ? !1 : e.editor.commands.setMark(e.type, { href: u.href });
2338
+ } }
2339
+ });
2340
+ }
2341
+ // src/extensions/tiptap-extensions/Link/link.ts
2342
+ var Yi = "https", Xi = /^(?:(?:http|https|ftp|ftps|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z0-9+.\-]+(?:[^a-z+.\-:]|$))/i;
2343
+ function Zi(e) {
2344
+ if (!e) return !0;
2345
+ let t = e.replace(Wi, "");
2346
+ return Xi.test(t);
2347
+ }
2348
+ function Qi(e) {
2349
+ let t = /^[a-z][a-z0-9+.-]*:\/\//i.test(e), n = /^[a-z][a-z0-9+.-]*:/i.test(e);
2350
+ if (t || n && !e.includes("@")) return !0;
2351
+ let r = (e.includes("@") ? e.split("@").pop() : e).split(/[/?#:]/)[0];
2352
+ return !(/^\d{1,3}(\.\d{1,3}){3}$/.test(r) || !/\./.test(r));
2353
+ }
2354
+ var $i = st.create({
2355
+ name: "link",
2356
+ keepOnSplit: !1,
2357
+ exitable: !0,
2358
+ inclusive: !1,
2359
+ addOptions() {
2360
+ return {
2361
+ HTMLAttributes: {
2362
+ target: "_blank",
2363
+ rel: "noopener noreferrer nofollow",
2364
+ className: "bn-inline-content-section",
2365
+ "data-inline-content-type": "link"
2366
+ },
2367
+ editor: void 0,
2368
+ onClick: void 0,
2369
+ isValidLink: Zi
2370
+ };
2371
+ },
2372
+ addAttributes() {
2373
+ return { href: {
2374
+ default: null,
2375
+ parseHTML(e) {
2376
+ return e.getAttribute("href");
2377
+ }
2378
+ } };
2379
+ },
2380
+ parseHTML() {
2381
+ let e = this.options.isValidLink;
2382
+ return [{
2383
+ tag: "a[href]",
2384
+ getAttrs: (t) => {
2385
+ let n = t.getAttribute("href");
2386
+ return !n || !e(n) ? !1 : null;
2387
+ }
2388
+ }];
2389
+ },
2390
+ renderHTML({ HTMLAttributes: e }) {
2391
+ return this.options.isValidLink(e.href) ? [
2392
+ "a",
2393
+ G(e, this.options.HTMLAttributes),
2394
+ 0
2395
+ ] : [
2396
+ "a",
2397
+ G({
2398
+ ...e,
2399
+ href: ""
2400
+ }, this.options.HTMLAttributes),
2401
+ 0
2402
+ ];
2403
+ },
2404
+ addPasteRules() {
2405
+ let e = this.options.isValidLink;
2406
+ return [gt({
2407
+ find: (t) => {
2408
+ let n = [];
2409
+ if (t) {
2410
+ let r = Fe(t, { defaultProtocol: Yi }).filter((t) => t.isLink && e(t.value));
2411
+ for (let e of r) Qi(e.value) && n.push({
2412
+ text: e.value,
2413
+ data: { href: e.href },
2414
+ index: e.start
2415
+ });
2416
+ }
2417
+ return n;
2418
+ },
2419
+ type: this.type,
2420
+ getAttributes: (e) => ({ href: e.data?.href })
2421
+ })];
2422
+ },
2423
+ addProseMirrorPlugins() {
2424
+ let e = [];
2425
+ return e.push(Ki({
2426
+ type: this.type,
2427
+ defaultProtocol: Yi,
2428
+ validate: this.options.isValidLink,
2429
+ shouldAutoLink: Qi
2430
+ })), e.push(qi({
2431
+ type: this.type,
2432
+ tiptapEditor: this.editor,
2433
+ editor: this.options.editor,
2434
+ onClick: this.options.onClick
2435
+ })), e.push(Ji({
2436
+ editor: this.editor,
2437
+ defaultProtocol: Yi,
2438
+ type: this.type,
2439
+ shouldAutoLink: Qi,
2440
+ isValidLink: this.options.isValidLink
2441
+ })), e;
2442
+ }
2443
+ }), ea = Xe(({ editor: e, options: t }) => ({
2444
+ key: "link",
2445
+ tiptapExtensions: [$i.configure({
2446
+ HTMLAttributes: t.HTMLAttributes ?? {},
2447
+ editor: e,
2448
+ onClick: t.onClick,
2449
+ ...t.isValidLink ? { isValidLink: t.isValidLink } : {}
2450
+ })]
2451
+ })), ta = U.create({
2452
+ name: "blockGroup",
2453
+ group: se,
2454
+ content: "blockGroupChild+",
2455
+ marks() {
2456
+ return A(this.editor);
2457
+ },
2458
+ parseHTML() {
2459
+ return [{
2460
+ tag: "div",
2461
+ getAttrs: (e) => typeof e != "string" && e.getAttribute("data-node-type") === "blockGroup" && null
2462
+ }];
2463
+ },
2464
+ renderHTML({ HTMLAttributes: e }) {
2465
+ let t = {
2466
+ ...this.options.domAttributes?.blockGroup || {},
2467
+ ...e
2468
+ }, n = document.createElement("div");
2469
+ n.className = O("bn-block-group", t.class), n.setAttribute("data-node-type", "blockGroup");
2470
+ for (let [e, r] of Object.entries(t)) e !== "class" && n.setAttribute(e, r);
2471
+ return {
2472
+ dom: n,
2473
+ contentDOM: n
2474
+ };
2475
+ }
2476
+ }), na = U.create({
2477
+ name: "doc",
2478
+ topNode: !0,
2479
+ content: "blockGroup",
2480
+ marks() {
2481
+ return A(this.editor);
2482
+ }
2483
+ });
2484
+ // src/editor/managers/ExtensionManager/extensions.ts
2485
+ function ra(e, t) {
2486
+ return [
2487
+ W.ClipboardTextSerializer,
2488
+ W.Commands,
2489
+ W.Editable,
2490
+ W.FocusEvents,
2491
+ W.Tabindex,
2492
+ Dt,
2493
+ u.configure({
2494
+ types: ["blockContainer", ...Object.values(e.schema.blockSpecs).filter((e) => e.config.layoutOnly === !0).map((e) => e.config.type)],
2495
+ setIdAttribute: t.setIdAttribute,
2496
+ isWithinEditor: e.isWithinEditor
2497
+ }),
2498
+ Ai,
2499
+ Et,
2500
+ ...Object.values(e.schema.styleSpecs).map((t) => t.implementation.mark.configure({ editor: e })),
2501
+ Bi,
2502
+ ki,
2503
+ zi,
2504
+ H.create({
2505
+ name: "OverrideEscape",
2506
+ addKeyboardShortcuts: () => ({ Escape: () => !e.getExtension(ue)?.shown() && (e.blur(), !0) })
2507
+ }),
2508
+ na,
2509
+ Qt.configure({
2510
+ editor: e,
2511
+ domAttributes: t.domAttributes
2512
+ }),
2513
+ Ri.configure({
2514
+ editor: e,
2515
+ tabBehavior: t.tabBehavior,
2516
+ selectAllBehavior: t.selectAllBehavior ?? "block-first"
2517
+ }),
2518
+ ta.configure({ domAttributes: t.domAttributes }),
2519
+ ...Object.values(e.schema.inlineContentSpecs).filter((e) => e.config !== "link" && e.config !== "text").map((t) => t.implementation.node.configure({ editor: e })),
2520
+ ...Object.values(e.schema.blockSpecs).flatMap((n) => [..."node" in n.implementation ? [n.implementation.node.configure({
2521
+ editor: e,
2522
+ domAttributes: t.domAttributes
2523
+ })] : []]),
2524
+ Oi(e),
2525
+ Ci(e, t.pasteHandler || ((e) => e.defaultPasteHandler())),
2526
+ Qr(e)
2527
+ ];
2528
+ }
2529
+ function ia(e, t) {
2530
+ let n = [
2531
+ Pe(),
2532
+ Oe(t),
2533
+ fe(t),
2534
+ de(t),
2535
+ ea({
2536
+ HTMLAttributes: t.links?.HTMLAttributes ?? {},
2537
+ onClick: t.links?.onClick,
2538
+ ...t.links?.isValidLink ? { isValidLink: t.links.isValidLink } : {}
2539
+ }),
2540
+ Ae(t),
2541
+ Me(),
2542
+ Ee(),
2543
+ De(t),
2544
+ He({ editable: t._tiptapOptions?.editable }),
2545
+ Ze(t),
2546
+ Re(t),
2547
+ Be(),
2548
+ Ve(),
2549
+ ue(t),
2550
+ Ne(),
2551
+ je(),
2552
+ Ie(),
2553
+ ...t.trailingBlock === !1 ? [] : [Ue()]
2554
+ ];
2555
+ return "table" in e.schema.blockSpecs && n.push(We(t)), t.animations !== !1 && n.push(Ge()), n;
2556
+ }
2557
+ // src/editor/managers/ExtensionManager/index.ts
2558
+ function aa(e) {
2559
+ return "key" in e && typeof e.key == "string" ? e.key : void 0;
2560
+ }
2561
+ var oa = class {
2562
+ editor;
2563
+ options;
2564
+ disabledExtensions = /* @__PURE__ */ new Set();
2565
+ extensions = [];
2566
+ abortMap = /* @__PURE__ */ new Map();
2567
+ extensionFactories = /* @__PURE__ */ new Map();
2568
+ extensionPlugins = /* @__PURE__ */ new Map();
2569
+ runtimeExtensions = /* @__PURE__ */ new Set();
2570
+ blockNoteExtensionDependents = /* @__PURE__ */ new Map();
2571
+ constructor(e, t) {
2572
+ this.editor = e, this.options = t, e.onMount(() => {
2573
+ for (let e of this.extensions) this.mountExtension(e);
2574
+ }), e.onUnmount(() => {
2575
+ for (let [e, t] of this.abortMap.entries()) this.abortMap.delete(e), t.abort();
2576
+ }), this.disabledExtensions = new Set(t.disableExtensions || []);
2577
+ for (let e of ia(this.editor, this.options)) this.addExtension(e);
2578
+ for (let e of this.options.extensions ?? []) this.addExtension(e);
2579
+ for (let e of [
2580
+ this.editor.schema.blockSpecs,
2581
+ this.editor.schema.inlineContentSpecs,
2582
+ this.editor.schema.styleSpecs
2583
+ ]) for (let t of Object.values(e)) for (let e of t.extensions ?? []) this.addExtension(e);
2584
+ }
2585
+ mountExtension(e) {
2586
+ if (!e.mount || this.editor.headless || this.abortMap.has(e) || !this.extensions.includes(e)) return;
2587
+ let t = new window.AbortController();
2588
+ this.abortMap.set(e, t);
2589
+ let n = e.mount({
2590
+ dom: this.editor.prosemirrorView.dom,
2591
+ root: this.editor.prosemirrorView.root,
2592
+ signal: t.signal
2593
+ });
2594
+ n && (t.signal.aborted ? n() : t.signal.addEventListener("abort", n, { once: !0 }));
2595
+ }
2596
+ registerExtension(e) {
2597
+ this.replaceExtension(void 0, e);
2598
+ }
2599
+ addExtension(e, t) {
2600
+ let n;
2601
+ if (n = typeof e == "function" ? e({ editor: this.editor }) : e, !n || this.disabledExtensions.has(n.key)) return;
2602
+ if (t) {
2603
+ let e = this.blockNoteExtensionDependents.get(n.key);
2604
+ e || (e = /* @__PURE__ */ new Set(), this.blockNoteExtensionDependents.set(n.key, e)), e.add(t);
2605
+ }
2606
+ if (this.extensions.some((e) => e.key === n.key)) return;
2607
+ let r = n[Ye];
2608
+ if (typeof r == "function" && this.extensionFactories.set(r, n), this.extensions.push(n), n.blockNoteExtensions) for (let e of n.blockNoteExtensions) this.addExtension(e, n.key);
2609
+ return n;
2610
+ }
2611
+ resolveExtensions(e) {
2612
+ let t = [];
2613
+ if (typeof e == "function") {
2614
+ let n = this.extensionFactories.get(e);
2615
+ n && t.push(n);
2616
+ } else if (Array.isArray(e)) for (let n of e) t.push(...this.resolveExtensions(n));
2617
+ else if (e && typeof e == "object" && "key" in e) this.extensions.includes(e) && t.push(e);
2618
+ else if (typeof e == "string") {
2619
+ let n = this.extensions.find((t) => t.key === e);
2620
+ n && t.push(n);
2621
+ }
2622
+ return t;
2623
+ }
2624
+ unregisterExtension(e) {
2625
+ let t = [...new Set(this.resolveExtensions(e))];
2626
+ return t.length && this.replaceExtension(t, []), Array.isArray(e) ? t : t[0];
2627
+ }
2628
+ replaceExtension(e, t, n) {
2629
+ let r = new Set(this.resolveExtensions(e));
2630
+ e && !r.size && console.warn("No extensions found to unregister", e), this.extensions = this.extensions.filter((e) => !r.has(e));
2631
+ for (let [e, t] of this.extensionFactories) r.has(t) && this.extensionFactories.delete(e);
2632
+ let i = [], a = !1, o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
2633
+ for (let e of r) for (let t of this.extensionPlugins.get(e) ?? []) {
2634
+ o.add(t);
2635
+ let e = aa(t);
2636
+ e && s.add(e);
2637
+ }
2638
+ for (let t of r) {
2639
+ for (let [e, n] of this.blockNoteExtensionDependents) n.delete(t.key), n.size || this.blockNoteExtensionDependents.delete(e);
2640
+ this.extensionPlugins.delete(t), this.runtimeExtensions.delete(t);
2641
+ let n = this.abortMap.get(t);
2642
+ this.abortMap.delete(t), n && i.push(n), t.tiptapExtensions && !a && (a = !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));
2643
+ }
2644
+ let c = [];
2645
+ try {
2646
+ let e = Array.isArray(t) ? t : [t], r = new Set(this.extensions);
2647
+ for (let t of e) this.addExtension(t);
2648
+ c = this.extensions.filter((e) => !r.has(e));
2649
+ for (let e of this.runtimeExtensions) for (let t of this.extensionPlugins.get(e) ?? []) {
2650
+ o.add(t);
2651
+ let e = aa(t);
2652
+ e && s.add(e);
2653
+ }
2654
+ let i = c.filter((e) => !this.runtimeExtensions.has(e));
2655
+ for (let e of c) this.runtimeExtensions.has(e) || (this.runtimeExtensions.add(e), 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));
2656
+ let a = this.editor.prosemirrorState, l = [...a.plugins.filter((e) => {
2657
+ let t = aa(e);
2658
+ return !o.has(e) && !(t && s.has(t));
2659
+ }), ...this.getRuntimePlugins()];
2660
+ if (!(l.length === a.plugins.length && l.every((e, t) => e === a.plugins[t])) || n?.resetPluginStateFor.length) {
2661
+ let e;
2662
+ try {
2663
+ e = this.reconfigurePlugins(l, n?.resetPluginStateFor);
2664
+ } catch (e) {
2665
+ let t = new Set(i);
2666
+ this.extensions = this.extensions.filter((e) => !t.has(e));
2667
+ for (let e of t) {
2668
+ this.runtimeExtensions.delete(e), this.extensionPlugins.delete(e);
2669
+ for (let [t, n] of this.blockNoteExtensionDependents) n.delete(e.key), n.size || this.blockNoteExtensionDependents.delete(t);
2670
+ }
2671
+ for (let [e, n] of this.extensionFactories) t.has(n) && this.extensionFactories.delete(e);
2672
+ throw e;
2673
+ }
2674
+ this.editor.prosemirrorView.updateState(e);
2675
+ }
2676
+ } finally {
2677
+ for (let e of i) e.abort();
2678
+ }
2679
+ for (let e of c) this.mountExtension(e);
2680
+ }
2681
+ reconfigurePlugins(e, t) {
2682
+ let n = this.editor.prosemirrorState, r = new Set(t);
2683
+ return (r.size ? n.reconfigure({ plugins: n.plugins.filter((e) => !e.spec.key || !r.has(e.spec.key)) }) : n).reconfigure({ plugins: e });
2684
+ }
2685
+ getExtensionPriority() {
2686
+ return be(this.extensions.map((e) => {
2687
+ let t = this.blockNoteExtensionDependents.get(e.key);
2688
+ return t?.size ? {
2689
+ key: e.key,
2690
+ runsBefore: [...e.runsBefore ?? [], ...t]
2691
+ } : e;
2692
+ }));
2693
+ }
2694
+ getRuntimePlugins() {
2695
+ let e = this.getExtensionPriority();
2696
+ return this.extensions.filter((e) => this.runtimeExtensions.has(e)).reverse().sort((t, n) => e(n.key) - e(t.key)).flatMap((e) => this.extensionPlugins.get(e) ?? []);
2697
+ }
2698
+ getTiptapExtensions() {
2699
+ let e = ra(this.editor, this.options).filter((e) => !this.disabledExtensions.has(e.name)), t = this.getExtensionPriority(), n = /* @__PURE__ */ new Map();
2700
+ for (let r of this.extensions) {
2701
+ r.tiptapExtensions && e.push(...r.tiptapExtensions);
2702
+ let i = t(r.key), { plugins: a, inputRules: o } = this.getProsemirrorPluginsFromExtension(r);
2703
+ a.length && e.push(H.create({
2704
+ name: r.key,
2705
+ priority: i,
2706
+ addProseMirrorPlugins: () => this.runtimeExtensions.has(r) ? [] : this.extensionPlugins.get(r) ?? []
2707
+ })), o.length && (n.has(i) || n.set(i, []), n.get(i).push(...o));
2708
+ }
2709
+ e.push(H.create({
2710
+ name: "blocknote-runtime-extensions",
2711
+ priority: -Infinity,
2712
+ addProseMirrorPlugins: () => this.getRuntimePlugins()
2713
+ })), e.push(H.create({
2714
+ name: "blocknote-input-rules",
2715
+ addProseMirrorPlugins() {
2716
+ let e = [];
2717
+ Array.from(n.keys()).sort((e, t) => e - t).reverse().forEach((t) => {
2718
+ e.push(...n.get(t));
2719
+ });
2720
+ let t = wt({ rules: e });
2721
+ return [t, new L({ props: { handleKeyDown(e, n) {
2722
+ if (n.key !== "Enter" || n.shiftKey || n.ctrlKey || n.metaKey || n.altKey) return !1;
2723
+ let { $cursor: r } = e.state.selection;
2724
+ return r ? !!t.props.handleTextInput?.call(t, e, r.pos, r.pos, "\n", () => e.state.tr.insertText("\n", r.pos, r.pos)) : !1;
2725
+ } } })];
2726
+ }
2727
+ }));
2728
+ for (let t of this.options._tiptapOptions?.extensions ?? []) e.push(t);
2729
+ return e;
2730
+ }
2731
+ getProsemirrorPluginsFromExtension(e) {
2732
+ let t = [...e.prosemirrorPlugins ?? []], n = [];
2733
+ if (!e.prosemirrorPlugins?.length && !Object.keys(e.keyboardShortcuts || {}).length && !e.inputRules?.length) return {
2734
+ plugins: t,
2735
+ inputRules: n
2736
+ };
2737
+ if (this.extensionPlugins.set(e, t), e.inputRules?.length && n.push(...e.inputRules.map((e) => new Ct(e.find, (t, n, r, i) => {
2738
+ let a = e.replace({
2739
+ match: n,
2740
+ range: {
2741
+ from: r,
2742
+ to: i
2743
+ },
2744
+ editor: this.editor
2745
+ });
2746
+ if (a) {
2747
+ let e = t.tr, n = v(e);
2748
+ return !n.hasContent || this.editor.schema.blockSchema[n.blockNoteType]?.content !== "inline" ? null : (e.deleteRange(r, i), J(e, n.block.beforePos, a), qr(e, s(n.block.node, e.doc), "start"), e);
2749
+ }
2750
+ return null;
2751
+ }, { undoable: !0 }))), Object.keys(e.keyboardShortcuts || {}).length) {
2752
+ let n, r = Tt(Object.fromEntries(Object.entries(e.keyboardShortcuts).map(([e, t]) => [e, () => {
2753
+ if (!n) throw Error("Keyboard shortcut called outside handleKeyDown");
2754
+ return t({
2755
+ editor: this.editor,
2756
+ event: n
2757
+ });
2758
+ }])));
2759
+ t.push(new L({ props: { handleKeyDown: (e, t) => {
2760
+ let i = n;
2761
+ n = t;
2762
+ try {
2763
+ return r(e, t);
2764
+ } finally {
2765
+ n = i;
2766
+ }
2767
+ } } }));
2768
+ }
2769
+ return {
2770
+ plugins: t,
2771
+ inputRules: n
2772
+ };
2773
+ }
2774
+ getExtensions() {
2775
+ return new Map(this.extensions.map((e) => [e.key, e]));
2776
+ }
2777
+ getExtension(e) {
2778
+ if (typeof e == "string") return this.extensions.find((t) => t.key === e) || void 0;
2779
+ if (typeof e == "function") return this.extensionFactories.get(e) || void 0;
2780
+ throw Error(`Invalid extension type: ${typeof e}`);
2781
+ }
2782
+ hasExtension(e) {
2783
+ return typeof e == "string" ? this.extensions.some((t) => t.key === e) : typeof e == "object" && "key" in e ? this.extensions.some((t) => t.key === e.key) : typeof e == "function" && this.extensionFactories.has(e);
2784
+ }
2785
+ };
2786
+ // src/util/expandToWords.ts
2787
+ function sa(e, t) {
2788
+ let { $from: n, $to: r } = t;
2789
+ if (n.pos > n.start() && n.pos < e.content.size) {
2790
+ let t = e.textBetween(n.pos, n.pos + 1);
2791
+ if (/^[\w\p{P}]$/u.test(t)) {
2792
+ let t = e.textBetween(n.start(), n.pos).match(/[\w\p{P}]+$/u);
2793
+ t && (n = e.resolve(n.pos - t[0].length));
2794
+ }
2795
+ }
2796
+ if (r.pos < r.end() && r.pos > 0) {
2797
+ let t = e.textBetween(r.pos - 1, r.pos);
2798
+ if (/^[\w\p{P}]$/u.test(t)) {
2799
+ let t = e.textBetween(r.pos, r.end()).match(/^[\w\p{P}]+/u);
2800
+ t && (r = e.resolve(r.pos + t[0].length));
2801
+ }
2802
+ }
2803
+ return {
2804
+ $from: n,
2805
+ $to: r,
2806
+ from: n.pos,
2807
+ to: r.pos
2808
+ };
2809
+ }
2810
+ // src/api/blockManipulation/selections/selection.ts
2811
+ function ca(e) {
2812
+ if (e.selection.empty || "node" in e.selection) return;
2813
+ let t = e.doc.resolve(c(e.doc, e.selection.from).posBeforeNode), n = e.doc.resolve(c(e.doc, e.selection.to).posBeforeNode), r = (n, r) => {
2814
+ let i = t.posAtIndex(n, r), a = e.doc.resolve(i).nodeAfter;
2815
+ if (!a) throw Error(`Error getting selection - node not found at position ${i}`);
2816
+ return y(a, e.doc);
2817
+ }, i = [], a = t.sharedDepth(n.pos), o = t.index(a), s = n.index(a);
2818
+ if (t.depth > a) {
2819
+ i.push(y(t.nodeAfter, e.doc));
2820
+ for (let e = t.depth; e > a; e--) if (t.node(e).type.isInGroup("childContainer")) {
2821
+ let n = t.index(e) + 1, a = t.node(e).childCount;
2822
+ for (let t = n; t < a; t++) i.push(r(t, e));
2823
+ }
2824
+ } else i.push(r(o, a));
2825
+ for (let e = o + 1; e <= s; e++) i.push(r(e, a));
2826
+ if (i.length === 0) throw Error(`Error getting selection - selection doesn't span any blocks (${e.selection})`);
2827
+ return { blocks: i };
2828
+ }
2829
+ function la(e, n, r) {
2830
+ let i = typeof n == "string" ? n : n.id, o = typeof r == "string" ? r : r.id;
2831
+ if (i === o) throw Error(`Attempting to set selection with the same anchor and head blocks (id ${i})`);
2832
+ let s = M(i, e.doc);
2833
+ if (!s) throw Error(`Block with ID ${i} not found`);
2834
+ let c = M(o, e.doc);
2835
+ if (!c) throw Error(`Block with ID ${o} not found`);
2836
+ let l = t(s.node, s.posBeforeNode), u = t(c.node, c.posBeforeNode), d = a(l, "start");
2837
+ if (d === null) throw Error(`Attempting to set selection anchor in block without content (id ${i})`);
2838
+ let f = a(u, "end");
2839
+ if (f === null) throw Error(`Attempting to set selection head in block without content (id ${o})`);
2840
+ e.setSelection(z.create(e.doc, d, f));
2841
+ }
2842
+ function ua(e, t = !1) {
2843
+ let n = t ? sa(e.doc, e.selection) : e.selection, r = n.$from, i = n.$to;
2844
+ for (; i.parentOffset >= i.parent.nodeSize - 2 && i.depth > 0;) i = e.doc.resolve(i.pos + 1);
2845
+ for (; i.parentOffset === 0 && i.depth > 0;) i = e.doc.resolve(i.pos - 1);
2846
+ for (; r.parentOffset === 0 && r.depth > 0;) r = e.doc.resolve(r.pos - 1);
2847
+ for (; r.parentOffset >= r.parent.nodeSize - 2 && r.depth > 0;) r = e.doc.resolve(r.pos + 1);
2848
+ let a = m(e.doc.slice(r.pos, i.pos, !0));
2849
+ return {
2850
+ _meta: {
2851
+ startPos: r.pos,
2852
+ endPos: i.pos
2853
+ },
2854
+ ...a
2855
+ };
2856
+ }
2857
+ // src/editor/managers/SelectionManager.ts
2858
+ var da = class {
2859
+ editor;
2860
+ constructor(e) {
2861
+ this.editor = e;
2862
+ }
2863
+ getSelection() {
2864
+ return this.editor.transact((e) => ca(e));
2865
+ }
2866
+ getSelectionCutBlocks(e = !1) {
2867
+ return this.editor.transact((t) => ua(t, e));
2868
+ }
2869
+ setSelection(e, t) {
2870
+ return this.editor.transact((n) => la(n, e, t));
2871
+ }
2872
+ getTextCursorPosition() {
2873
+ return this.editor.transact((e) => Kr(e));
2874
+ }
2875
+ setTextCursorPosition(e, t = "start") {
2876
+ return this.editor.transact((n) => qr(n, e, t));
2877
+ }
2878
+ getSelectionBoundingBox() {
2879
+ if (!this.editor.prosemirrorView) return;
2880
+ 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));
2881
+ if (ht(e)) {
2882
+ let e = this.editor.prosemirrorView.nodeDOM(n);
2883
+ if (e) return e.getBoundingClientRect();
2884
+ }
2885
+ return _t(this.editor.prosemirrorView, n, r).toJSON();
2886
+ }
2887
+ }, fa = class {
2888
+ editor;
2889
+ constructor(e) {
2890
+ this.editor = e;
2891
+ }
2892
+ activeTransaction = null;
2893
+ can(e) {
2894
+ try {
2895
+ return this.isInCan = !0, e();
2896
+ } finally {
2897
+ this.isInCan = !1;
2898
+ }
2899
+ }
2900
+ isInCan = !1;
2901
+ exec(e) {
2902
+ if (this.activeTransaction) throw Error("`exec` should not be called within a `transact` call, move the `exec` call outside of the `transact` call");
2903
+ if (this.isInCan) return this.canExec(e);
2904
+ let t = this.prosemirrorState, n = this.prosemirrorView;
2905
+ return e(t, (e) => this.prosemirrorView.dispatch(e), n);
2906
+ }
2907
+ canExec(e) {
2908
+ if (this.activeTransaction) throw Error("`canExec` should not be called within a `transact` call, move the `canExec` call outside of the `transact` call");
2909
+ let t = this.prosemirrorState, n = this.prosemirrorView;
2910
+ return e(t, void 0, n);
2911
+ }
2912
+ transact(e) {
2913
+ if (this.activeTransaction) return e(this.activeTransaction);
2914
+ try {
2915
+ this.activeTransaction = this.editor._tiptapEditor.state.tr;
2916
+ let t = e(this.activeTransaction), n = this.activeTransaction;
2917
+ return this.activeTransaction = null, n && (n.docChanged || n.selectionSet || n.scrolledIntoView || n.storedMarksSet || !n.isGeneric) && this.prosemirrorView.dispatch(n), t;
2918
+ } finally {
2919
+ this.activeTransaction = null;
2920
+ }
2921
+ }
2922
+ get prosemirrorState() {
2923
+ if (this.activeTransaction) throw Error("`prosemirrorState` should not be called within a `transact` call, move the `prosemirrorState` call outside of the `transact` call or use `editor.transact` to read the current editor state");
2924
+ return this.editor._tiptapEditor.state;
2925
+ }
2926
+ get prosemirrorView() {
2927
+ return this.editor._tiptapEditor.view;
2928
+ }
2929
+ isFocused() {
2930
+ return this.prosemirrorView?.hasFocus() || !1;
2931
+ }
2932
+ focus() {
2933
+ this.prosemirrorView?.focus();
2934
+ }
2935
+ get isEditable() {
2936
+ if (!this.editor._tiptapEditor) {
2937
+ if (!this.editor.headless) throw Error("no editor, but also not headless?");
2938
+ return !1;
2939
+ }
2940
+ if (this.editor.headless) {
2941
+ let e = this.editor.getExtension(He)?.store.state;
2942
+ if (e) return e.isEditable && e.enabledSet.size === 0;
2943
+ }
2944
+ return this.editor._tiptapEditor.isEditable === void 0 || this.editor._tiptapEditor.isEditable;
2945
+ }
2946
+ set isEditable(e) {
2947
+ if (this.editor._tiptapEditor) this.editor.getExtension(He).setEditable(e);
2948
+ else if (!this.editor.headless) throw Error("no editor, but also not headless?");
2949
+ }
2950
+ undo() {
2951
+ let e = this.editor.getExtension("yUndo");
2952
+ if (e) return this.exec(e.undoCommand);
2953
+ let t = this.editor.getExtension("history");
2954
+ if (t) return this.exec(t.undoCommand);
2955
+ throw Error("No undo plugin found");
2956
+ }
2957
+ redo() {
2958
+ let e = this.editor.getExtension("yUndo");
2959
+ if (e) return this.exec(e.redoCommand);
2960
+ let t = this.editor.getExtension("history");
2961
+ if (t) return this.exec(t.redoCommand);
2962
+ throw Error("No redo plugin found");
2963
+ }
2964
+ };
2965
+ // src/api/blockManipulation/insertContentAt.ts
2966
+ function pa(e, t, n, r = { updateSelection: !0 }) {
2967
+ let { from: i, to: a } = typeof t == "number" ? {
2968
+ from: t,
2969
+ to: t
2970
+ } : {
2971
+ from: t.from,
2972
+ to: t.to
2973
+ }, o = !0, s = !0, c = "";
2974
+ if (n.forEach((e) => {
2975
+ e.check(), o && e.isText && e.marks.length === 0 ? c += e.text : o = !1, s = s ? e.isBlock : !1;
2976
+ }), i === a && s) {
2977
+ let { parent: t } = e.doc.resolve(i);
2978
+ t.isTextblock && !t.type.spec.code && !t.childCount && (--i, a += 1);
2979
+ }
2980
+ return o ? e.insertText(c, i, a) : e.replaceWith(i, a, n), r.updateSelection && vt(e, e.steps.length - 1, -1), !0;
2981
+ }
2982
+ // src/editor/managers/StyleManager.ts
2983
+ var ma = class {
2984
+ editor;
2985
+ constructor(e) {
2986
+ this.editor = e;
2987
+ }
2988
+ insertInlineContent(e, { updateSelection: t = !1 } = {}) {
2989
+ let n = C(e, this.editor.pmSchema);
2990
+ this.editor.transact((e) => {
2991
+ pa(e, {
2992
+ from: e.selection.from,
2993
+ to: e.selection.to
2994
+ }, n, { updateSelection: t });
2995
+ });
2996
+ }
2997
+ getActiveStyles() {
2998
+ return this.editor.transact((e) => {
2999
+ let t = {}, n = e.selection.empty && e.storedMarks || e.selection.$to.marks();
3000
+ for (let e of n) {
3001
+ let n = this.editor.schema.styleSchema[e.type.name];
3002
+ n ? n.propSchema === "boolean" ? t[n.type] = !0 : t[n.type] = e.attrs.stringValue : e.type.name !== "link" && !e.type.spec.blocknoteIgnore && console.warn("mark not found in styleschema", e.type.name);
3003
+ }
3004
+ return t;
3005
+ });
3006
+ }
3007
+ addStyles(e) {
3008
+ for (let [t, n] of Object.entries(e)) {
3009
+ let e = this.editor.schema.styleSchema[t];
3010
+ if (!e) throw Error(`style ${t} not found in styleSchema`);
3011
+ if (e.propSchema === "boolean") this.editor._tiptapEditor.commands.setMark(t);
3012
+ else if (e.propSchema === "string") this.editor._tiptapEditor.commands.setMark(t, { stringValue: n });
3013
+ else throw new _(e.propSchema);
3014
+ }
3015
+ }
3016
+ removeStyles(e) {
3017
+ for (let t of Object.keys(e)) this.editor._tiptapEditor.commands.unsetMark(t);
3018
+ }
3019
+ toggleStyles(e) {
3020
+ for (let [t, n] of Object.entries(e)) {
3021
+ let e = this.editor.schema.styleSchema[t];
3022
+ if (!e) throw Error(`style ${t} not found in styleSchema`);
3023
+ if (e.propSchema === "boolean") this.editor._tiptapEditor.commands.toggleMark(t);
3024
+ else if (e.propSchema === "string") this.editor._tiptapEditor.commands.toggleMark(t, { stringValue: n });
3025
+ else throw new _(e.propSchema);
3026
+ }
3027
+ }
3028
+ getSelectedText() {
3029
+ return this.editor.transact((e) => e.doc.textBetween(e.selection.from, e.selection.to, "\n"));
3030
+ }
3031
+ getLinkMarkAtPos(e) {
3032
+ return this.editor.transact((t) => {
3033
+ let n = this.editor.pmSchema.marks.link, r = ft(t.doc.resolve(e), n);
3034
+ if (!r) return;
3035
+ let i = t.doc.nodeAt(r.from)?.marks.find((e) => e.type === n);
3036
+ if (i) return {
3037
+ href: i.attrs.href,
3038
+ from: r.from,
3039
+ to: r.to,
3040
+ text: t.doc.textBetween(r.from, r.to)
3041
+ };
3042
+ });
3043
+ }
3044
+ getSelectedLinkUrl() {
3045
+ return this.editor.transact((e) => (e.doc.nodeAt(e.selection.from)?.marks.find((e) => e.type.name === "link"))?.attrs.href);
3046
+ }
3047
+ createLink(e, t) {
3048
+ e !== "" && this.editor.transact((n) => {
3049
+ let { from: r, to: i } = n.selection, a = this.editor.pmSchema.mark("link", { href: e });
3050
+ t ? n.insertText(t, r, i).addMark(r, r + t.length, a) : n.addMark(r, i, a);
3051
+ });
3052
+ }
3053
+ editLink(e, t, n = this.editor.transact((e) => e.selection.anchor)) {
3054
+ this.editor.transact((r) => {
3055
+ let { from: i, to: a } = this.getLinkMarkAtPos(n) || {
3056
+ from: r.selection.from,
3057
+ to: r.selection.to
3058
+ }, o = this.editor.pmSchema.mark("link", { href: e });
3059
+ t !== r.doc.textBetween(i, a) && r.insertText(t, i, a), r.addMark(i, i + t.length, o);
3060
+ }), this.editor.prosemirrorView.focus();
3061
+ }
3062
+ deleteLink(e = this.editor.transact((e) => e.selection.anchor)) {
3063
+ this.editor.transact((t) => {
3064
+ let { from: n, to: r } = this.getLinkMarkAtPos(e) || {
3065
+ from: t.selection.from,
3066
+ to: t.selection.to
3067
+ };
3068
+ t.removeMark(n, r, this.editor.pmSchema.marks.link).setMeta("preventAutolink", !0);
3069
+ }), this.editor.prosemirrorView.focus();
3070
+ }
3071
+ };
3072
+ // src/editor/transformPasted.ts
3073
+ function ha(e) {
3074
+ return ut(e.state.selection.$from, (e) => e.type.name === "tableCell" || e.type.name === "tableHeader") !== void 0;
3075
+ }
3076
+ function ga(e, t) {
3077
+ let n = t.nodes.hardBreak, r = B.empty;
3078
+ return e.forEach((e) => {
3079
+ 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(ga(e.content, t)), r = r.addToEnd(n.create()));
3080
+ }), r.lastChild?.type === n && (r = r.cut(0, r.size - 1)), r;
3081
+ }
3082
+ function _a(e, t) {
3083
+ let n = [];
3084
+ return e.forEach((e, r, i) => {
3085
+ i !== t && n.push(e);
3086
+ }), B.from(n);
3087
+ }
3088
+ function va(e, t) {
3089
+ let n = [];
3090
+ for (let r = 0; r < e.childCount; r++) if (e.child(r).type.name === "tableRow") {
3091
+ let i = n.at(-1);
3092
+ if (i?.type.name === "table") {
3093
+ let t = i.copy(i.content.addToEnd(e.child(r)));
3094
+ n[n.length - 1] = t;
3095
+ } else {
3096
+ let i = t.nodes.table.createChecked(void 0, e.child(r));
3097
+ n.push(i);
3098
+ }
3099
+ } else n.push(e.child(r));
3100
+ return e = B.from(n), e;
3101
+ }
3102
+ function ya(e, t) {
3103
+ let n = B.from(e.content);
3104
+ n = va(n, t.state.schema);
3105
+ let r = ba(n, t, e);
3106
+ if (r) return r;
3107
+ let i = t.state.schema.nodes.tableParagraph;
3108
+ if (i && ha(t)) {
3109
+ let e = !1;
3110
+ if (n.descendants((t) => {
3111
+ t.type.isInGroup("tableContent") && (e = !0);
3112
+ }), !e && !i.validContent(n)) return new V(ga(n, t.state.schema), 0, 0);
3113
+ }
3114
+ if (!xa(n, t)) return new V(n, e.openStart, e.openEnd);
3115
+ for (let e = 0; e < n.childCount; e++) if (n.child(e).type.spec.group === "blockContent") {
3116
+ let r = [n.child(e)];
3117
+ if (e + 1 < n.childCount && n.child(e + 1).type.name === "blockGroup") {
3118
+ let t = n.child(e + 1).child(0).child(0);
3119
+ (t.type.name === "bulletListItem" || t.type.name === "numberedListItem" || t.type.name === "checkListItem") && (r.push(n.child(e + 1)), n = _a(n, e + 1));
3120
+ }
3121
+ let i = t.state.schema.nodes.blockContainer.createChecked(void 0, r);
3122
+ n = n.replaceChild(e, i);
3123
+ }
3124
+ return new V(n, e.openStart, e.openEnd);
3125
+ }
3126
+ function ba(e, t, n) {
3127
+ if (ha(t) || t.dragging) return null;
3128
+ let r = v(t.state);
3129
+ if (!r.hasContent || r.content.node.type.name === "paragraph" || r.contentKind !== "inline" || !r.isContentEmpty) return null;
3130
+ let i = r.content.node, a = e.firstChild, o = a?.firstChild, s = o?.firstChild;
3131
+ if (a?.type.name !== "blockGroup" || o?.type.name !== "blockContainer" || s?.type.name !== "paragraph") return null;
3132
+ 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));
3133
+ return new V(e.replaceChild(0, u), n.openStart, n.openEnd);
3134
+ }
3135
+ function xa(e, t) {
3136
+ let n = e.childCount === 1, r = e.firstChild?.type.spec.content === "inline*", i = e.firstChild?.type.spec.content === "tableRow+";
3137
+ if (n) {
3138
+ if (r) return !1;
3139
+ if (i) {
3140
+ let e = v(t.state);
3141
+ if (e.hasContent) return e.contentKind !== "table";
3142
+ }
3143
+ }
3144
+ return !0;
3145
+ }
3146
+ // src/editor/BlockNoteEditor.ts
3147
+ var Sa = {
3148
+ enableInputRules: !0,
3149
+ enablePasteRules: !0,
3150
+ enableCoreExtensions: !1
3151
+ }, Ca = class e extends _n {
3152
+ options;
3153
+ pmSchema;
3154
+ _tiptapEditor;
3155
+ elementRenderer = null;
3156
+ blockCache = /* @__PURE__ */ new WeakMap();
3157
+ dictionary;
3158
+ schema;
3159
+ blockImplementations;
3160
+ inlineContentImplementations;
3161
+ styleImplementations;
3162
+ uploadFile;
3163
+ onUploadStartCallbacks = [];
3164
+ onUploadEndCallbacks = [];
3165
+ resolveFileUrl;
3166
+ settings;
3167
+ static create(t) {
3168
+ return new e(t ?? {});
3169
+ }
3170
+ constructor(e) {
3171
+ super(), this.options = e, this.dictionary = e.dictionary || Qe, this.dictionary.emoji_picker === void 0 && (this.dictionary.emoji_picker = Qe.emoji_picker), this.settings = { tables: {
3172
+ splitCells: e?.tables?.splitCells ?? !1,
3173
+ cellBackgroundColor: e?.tables?.cellBackgroundColor ?? !1,
3174
+ cellTextColor: e?.tables?.cellTextColor ?? !1,
3175
+ headers: e?.tables?.headers ?? !1
3176
+ } };
3177
+ let t = {
3178
+ defaultStyles: !0,
3179
+ schema: e.schema || Se.create(),
3180
+ ...e,
3181
+ placeholders: {
3182
+ ...this.dictionary.placeholders,
3183
+ ...e.placeholders
3184
+ }
3185
+ };
3186
+ if (this.schema = t.schema, this.blockImplementations = t.schema.blockSpecs, this.inlineContentImplementations = t.schema.inlineContentSpecs, this.styleImplementations = t.schema.styleSpecs, t.uploadFile) {
3187
+ let e = t.uploadFile;
3188
+ this.uploadFile = async (t, n) => {
3189
+ this.onUploadStartCallbacks.forEach((e) => e.apply(this, [n]));
3190
+ try {
3191
+ return await e(t, n);
3192
+ } finally {
3193
+ this.onUploadEndCallbacks.forEach((e) => e.apply(this, [n]));
3194
+ }
3195
+ };
3196
+ }
3197
+ this.resolveFileUrl = t.resolveFileUrl, this._eventManager = new Un(this), this._extensionManager = new oa(this, t);
3198
+ let n = this._extensionManager.getTiptapExtensions(), r = {
3199
+ ...Sa,
3200
+ ...t._tiptapOptions,
3201
+ editable: !0,
3202
+ element: null,
3203
+ autofocus: t.autofocus ?? !1,
3204
+ extensions: n,
3205
+ editorProps: {
3206
+ scrollMargin: {
3207
+ top: 72,
3208
+ bottom: 72,
3209
+ left: 0,
3210
+ right: 0
3211
+ },
3212
+ ...t._tiptapOptions?.editorProps,
3213
+ attributes: {
3214
+ tabIndex: "0",
3215
+ ...t._tiptapOptions?.editorProps?.attributes,
3216
+ ...t.domAttributes?.editor,
3217
+ class: O("bn-editor", t.defaultStyles ? "bn-default-styles" : "", t.domAttributes?.editor?.class || "")
3218
+ },
3219
+ transformPasted: ya
3220
+ }
3221
+ };
3222
+ try {
3223
+ let e = t.initialContent || [{
3224
+ type: "paragraph",
3225
+ id: u.options.generateID()
3226
+ }];
3227
+ if (!Array.isArray(e) || e.length === 0) throw Error("initialContent must be a non-empty array of blocks, received: " + JSON.stringify(e));
3228
+ let n = mt(r.extensions);
3229
+ n.cached.blockNoteEditor = this;
3230
+ let i = e.map((e) => T(e, n, this.schema.styleSchema).toJSON()), a = ct({
3231
+ type: "doc",
3232
+ content: [{
3233
+ type: "blockGroup",
3234
+ content: i
3235
+ }]
3236
+ }, n, r.parseOptions);
3237
+ a.check(), this._tiptapEditor = new ot({
3238
+ ...r,
3239
+ content: a.toJSON()
3240
+ }), this.pmSchema = this._tiptapEditor.schema;
3241
+ } catch (e) {
3242
+ throw Error("Error creating document from blocks passed as `initialContent`", { cause: e });
3243
+ }
3244
+ this.pmSchema.cached.blockNoteEditor = this, this._tiptapEditor.on("mount", () => {
3245
+ this.headless = !1;
3246
+ }), this._tiptapEditor.on("unmount", () => {
3247
+ this.headless = !0;
3248
+ }), this._tiptapEditor.on("destroy", () => {
3249
+ this.emit("destroy");
3250
+ }), this._blockManager = new Hn(this), this._exportManager = new Gr(this), this._selectionManager = new da(this), this._stateManager = new fa(this), this._styleManager = new ma(this), this.emit("create");
3251
+ }
3252
+ _blockManager;
3253
+ _eventManager;
3254
+ _exportManager;
3255
+ _extensionManager;
3256
+ _selectionManager;
3257
+ _stateManager;
3258
+ _styleManager;
3259
+ get extensions() {
3260
+ return this._extensionManager.getExtensions();
3261
+ }
3262
+ exec(e) {
3263
+ return this._stateManager.exec(e);
3264
+ }
3265
+ canExec(e) {
3266
+ return this._stateManager.canExec(e);
3267
+ }
3268
+ transact(e) {
3269
+ return this._stateManager.transact(e);
3270
+ }
3271
+ unregisterExtension(e) {
3272
+ return this._extensionManager.unregisterExtension(e);
3273
+ }
3274
+ registerExtension = (...e) => this._extensionManager.registerExtension(...e);
3275
+ replaceExtension = (...e) => this._extensionManager.replaceExtension(...e);
3276
+ getExtension = ((e) => this._extensionManager.getExtension(e));
3277
+ mount = (e) => {
3278
+ this._tiptapEditor.mount({ mount: e }), this._tiptapEditor.isEditorContentInitialized = !0;
3279
+ };
3280
+ unmount = () => {
3281
+ this._tiptapEditor.isEditorContentInitialized = !1, this._tiptapEditor.unmount();
3282
+ };
3283
+ get prosemirrorState() {
3284
+ return this._stateManager.prosemirrorState;
3285
+ }
3286
+ get prosemirrorView() {
3287
+ return this._stateManager.prosemirrorView;
3288
+ }
3289
+ get domElement() {
3290
+ if (!this.headless) return this.prosemirrorView?.dom;
3291
+ }
3292
+ _portalElements = /* @__PURE__ */ new Map();
3293
+ registerPortalElement = (e) => {
3294
+ this._portalElements.set(e, (this._portalElements.get(e) ?? 0) + 1);
3295
+ };
3296
+ unregisterPortalElement = (e) => {
3297
+ let t = this._portalElements.get(e);
3298
+ t !== void 0 && (t <= 1 ? this._portalElements.delete(e) : this._portalElements.set(e, t - 1));
3299
+ };
3300
+ isWithinEditor = (e) => {
3301
+ if (this.domElement?.parentElement?.contains(e)) return !0;
3302
+ for (let t of this._portalElements.keys()) if (t.contains(e)) return !0;
3303
+ return !1;
3304
+ };
3305
+ isFocused(e) {
3306
+ if (this.headless) return !1;
3307
+ let t = this.prosemirrorView?.hasFocus() || !1;
3308
+ if (!e?.includeEditorUI) return t;
3309
+ let n = typeof document < "u" ? document.activeElement : null;
3310
+ return t || !!n && this.isWithinEditor(n);
3311
+ }
3312
+ headless = !0;
3313
+ focus() {
3314
+ this.headless || this.prosemirrorView.focus();
3315
+ }
3316
+ blur() {
3317
+ this.headless || this.domElement?.blur();
3318
+ }
3319
+ onUploadStart(e) {
3320
+ return this.onUploadStartCallbacks.push(e), () => {
3321
+ let t = this.onUploadStartCallbacks.indexOf(e);
3322
+ t > -1 && this.onUploadStartCallbacks.splice(t, 1);
3323
+ };
3324
+ }
3325
+ onUploadEnd(e) {
3326
+ return this.onUploadEndCallbacks.push(e), () => {
3327
+ let t = this.onUploadEndCallbacks.indexOf(e);
3328
+ t > -1 && this.onUploadEndCallbacks.splice(t, 1);
3329
+ };
3330
+ }
3331
+ get topLevelBlocks() {
3332
+ return this.document;
3333
+ }
3334
+ get document() {
3335
+ return this._blockManager.document;
3336
+ }
3337
+ getBlock(e) {
3338
+ return this._blockManager.getBlock(e);
3339
+ }
3340
+ getPrevBlock(e) {
3341
+ return this._blockManager.getPrevBlock(e);
3342
+ }
3343
+ getNextBlock(e) {
3344
+ return this._blockManager.getNextBlock(e);
3345
+ }
3346
+ getParentBlock(e) {
3347
+ return this._blockManager.getParentBlock(e);
3348
+ }
3349
+ forEachBlock(e, t = !1) {
3350
+ this._blockManager.forEachBlock(e, t);
3351
+ }
3352
+ onEditorContentChange(e) {
3353
+ this._tiptapEditor.on("update", e);
3354
+ }
3355
+ onEditorSelectionChange(e) {
3356
+ this._tiptapEditor.on("selectionUpdate", e);
3357
+ }
3358
+ onBeforeChange(e) {
3359
+ return this._extensionManager.getExtension(Pe).subscribe(e);
3360
+ }
3361
+ getTextCursorPosition() {
3362
+ return this._selectionManager.getTextCursorPosition();
3363
+ }
3364
+ setTextCursorPosition(e, t = "start") {
3365
+ return this._selectionManager.setTextCursorPosition(e, t);
3366
+ }
3367
+ getSelection() {
3368
+ return this._selectionManager.getSelection();
3369
+ }
3370
+ getSelectionCutBlocks(e = !1) {
3371
+ return this._selectionManager.getSelectionCutBlocks(e);
3372
+ }
3373
+ setSelection(e, t) {
3374
+ return this._selectionManager.setSelection(e, t);
3375
+ }
3376
+ get isEditable() {
3377
+ return this._stateManager.isEditable;
3378
+ }
3379
+ set isEditable(e) {
3380
+ this._stateManager.isEditable = e;
3381
+ }
3382
+ insertBlocks(e, t, n = "before") {
3383
+ return this._blockManager.insertBlocks(e, t, n);
3384
+ }
3385
+ updateBlock(e, t) {
3386
+ return this._blockManager.updateBlock(e, t);
3387
+ }
3388
+ removeBlocks(e) {
3389
+ return this._blockManager.removeBlocks(e);
3390
+ }
3391
+ replaceBlocks(e, t) {
3392
+ return this._blockManager.replaceBlocks(e, t);
3393
+ }
3394
+ undo() {
3395
+ return this._stateManager.undo();
3396
+ }
3397
+ redo() {
3398
+ return this._stateManager.redo();
3399
+ }
3400
+ insertInlineContent(e, { updateSelection: t = !1 } = {}) {
3401
+ this._styleManager.insertInlineContent(e, { updateSelection: t });
3402
+ }
3403
+ getActiveStyles() {
3404
+ return this._styleManager.getActiveStyles();
3405
+ }
3406
+ addStyles(e) {
3407
+ this._styleManager.addStyles(e);
3408
+ }
3409
+ removeStyles(e) {
3410
+ this._styleManager.removeStyles(e);
3411
+ }
3412
+ toggleStyles(e) {
3413
+ this._styleManager.toggleStyles(e);
3414
+ }
3415
+ getSelectedText() {
3416
+ return this._styleManager.getSelectedText();
3417
+ }
3418
+ getSelectedLinkUrl() {
3419
+ return this._styleManager.getSelectedLinkUrl();
3420
+ }
3421
+ createLink(e, t) {
3422
+ this._styleManager.createLink(e, t);
3423
+ }
3424
+ getLinkMarkAtPos(e) {
3425
+ return this._styleManager.getLinkMarkAtPos(e);
3426
+ }
3427
+ editLink(e, t, n) {
3428
+ this._styleManager.editLink(e, t, n);
3429
+ }
3430
+ deleteLink(e) {
3431
+ this._styleManager.deleteLink(e);
3432
+ }
3433
+ canNestBlock() {
3434
+ return this._blockManager.canNestBlock();
3435
+ }
3436
+ nestBlock() {
3437
+ this._blockManager.nestBlock();
3438
+ }
3439
+ canUnnestBlock() {
3440
+ return this._blockManager.canUnnestBlock();
3441
+ }
3442
+ unnestBlock() {
3443
+ this._blockManager.unnestBlock();
3444
+ }
3445
+ moveBlocksUp(e) {
3446
+ return this._blockManager.moveBlocksUp(e);
3447
+ }
3448
+ moveBlocksDown(e) {
3449
+ return this._blockManager.moveBlocksDown(e);
3450
+ }
3451
+ blocksToHTMLLossy(e = this.document) {
3452
+ return this._exportManager.blocksToHTMLLossy(e);
3453
+ }
3454
+ blocksToFullHTML(e = this.document) {
3455
+ return this._exportManager.blocksToFullHTML(e);
3456
+ }
3457
+ tryParseHTMLToBlocks(e) {
3458
+ return this._exportManager.tryParseHTMLToBlocks(e);
3459
+ }
3460
+ blocksToMarkdownLossy(e = this.document) {
3461
+ return this._exportManager.blocksToMarkdownLossy(e);
3462
+ }
3463
+ tryParseMarkdownToBlocks(e) {
3464
+ return this._exportManager.tryParseMarkdownToBlocks(e);
3465
+ }
3466
+ onChange(e, t) {
3467
+ return this._eventManager.onChange(e, t);
3468
+ }
3469
+ onSelectionChange(e, t) {
3470
+ return this._eventManager.onSelectionChange(e, t);
3471
+ }
3472
+ onFocusChange(e, t) {
3473
+ return this._eventManager.onFocusChange(e, t);
3474
+ }
3475
+ onMount(e) {
3476
+ return this._eventManager.onMount(e);
3477
+ }
3478
+ onUnmount(e) {
3479
+ return this._eventManager.onUnmount(e);
3480
+ }
3481
+ getSelectionBoundingBox() {
3482
+ return this._selectionManager.getSelectionBoundingBox();
3483
+ }
3484
+ get isEmpty() {
3485
+ let e = this.document;
3486
+ return e.length === 0 || e.length === 1 && e[0].type === "paragraph" && e[0].content.length === 0;
3487
+ }
3488
+ pasteHTML(e, t = !1) {
3489
+ this._exportManager.pasteHTML(e, t);
3490
+ }
3491
+ pasteText(e) {
3492
+ return this._exportManager.pasteText(e);
3493
+ }
3494
+ pasteMarkdown(e) {
3495
+ return this._exportManager.pasteMarkdown(e);
3496
+ }
3497
+ }, wa = class {
3498
+ schema;
3499
+ mappings;
3500
+ options;
3501
+ constructor(e, t, n) {
3502
+ this.schema = e, this.mappings = t, this.options = n;
3503
+ }
3504
+ placesChildren(e) {
3505
+ let t = this.mappings.blockMapping[e.type];
3506
+ return typeof t == "object" && !!t;
3507
+ }
3508
+ get dictionary() {
3509
+ return this.options.dictionary?.exporter ?? Qe.exporter;
3510
+ }
3511
+ async resolveFile(e) {
3512
+ if (!this.options?.resolveFileUrl) return this.fetchBlob(e);
3513
+ let t = await this.options.resolveFileUrl(e);
3514
+ return t instanceof Blob ? t : this.fetchBlob(t);
3515
+ }
3516
+ async fetchBlob(e) {
3517
+ let t = await fetch(e);
3518
+ if (!t.ok) throw Error(`Failed to fetch file "${e}": ${t.status} ${t.statusText}`);
3519
+ return t.blob();
3520
+ }
3521
+ mapStyles(e) {
3522
+ return Object.entries(e).map(([e, t]) => {
3523
+ let n = this.mappings.styleMapping[e];
3524
+ if (!n) throw Error(`Exporter is missing a style mapping for style "${e}". If this style comes from a separate package, spread that package's exporter mappings into your styleMapping.`);
3525
+ return n(t, this);
3526
+ });
3527
+ }
3528
+ mapInlineContent(e) {
3529
+ let t = this.mappings.inlineContentMapping[e.type];
3530
+ if (!t) throw Error(`Exporter is missing an inline content mapping for inline content type "${e.type}". If this inline content comes from a separate package, spread that package's exporter mappings into your inlineContentMapping.`);
3531
+ return t(e, this);
3532
+ }
3533
+ transformInlineContent(e) {
3534
+ return e.map((e) => this.mapInlineContent(e));
3535
+ }
3536
+ async mapBlock(e, t, n, r) {
3537
+ let i = this.mappings.blockMapping[e.type];
3538
+ if (!i) throw Error(`Exporter is missing a block mapping for block type "${e.type}". If this block comes from a separate package, spread that package's exporter mappings into your blockMapping.`);
3539
+ if (typeof i == "function") {
3540
+ let r = this.schema.blockSpecs[e.type];
3541
+ if (r !== void 0 && r.config.layoutOnly === !0) throw Error(`The mapping for layout block type "${e.type}" must be a \`{ withChildren }\` mapping, which places the block's children.`);
3542
+ return i(e, this, t, n);
3543
+ }
3544
+ return i.withChildren(e, this, t, n, r ?? []);
3545
+ }
3546
+ };
3547
+ // src/exporter/ExportImage.ts
3548
+ function Ta(e) {
3549
+ if ("toBase64" in e && typeof e.toBase64 == "function") return e.toBase64();
3550
+ let t = "";
3551
+ for (let n of e) t += String.fromCharCode(n);
3552
+ return btoa(t);
3553
+ }
3554
+ function Ea(e) {
3555
+ return `data:${e.mimeType};base64,${Ta(e.data)}`;
3556
+ }
3557
+ // src/exporter/mapping.ts
3558
+ function Da(e) {
3559
+ return {
3560
+ createBlockMapping: (e) => e,
3561
+ createInlineContentMapping: (e) => e,
3562
+ createStyleMapping: (e) => e
3563
+ };
3564
+ }
3565
+ // src/util/combineByGroup.ts
3566
+ function Oa(e, ...t) {
3567
+ let n = [...e];
3568
+ for (let e of t) for (let t of e) {
3569
+ let e = n.findLastIndex((e) => e.group === t.group);
3570
+ e === -1 ? n.push(t) : n.splice(e + 1, 0, t);
3571
+ }
3572
+ return n;
3573
+ }
3574
+ export { Ft as A, un as C, J as D, Rt as E, Nt as M, Mt as N, q as O, Ot as P, pn as S, Wt as T, mn as _, wa as a, Y as b, Ti as c, rr as d, Rn as f, _n as g, zn as h, Ea as i, Pt as j, It as k, Wr as l, Vn as m, Da as n, Ca as o, Bn as p, Ta as r, sa as s, Oa as t, Ur as u, hn as v, Gt as w, gn as x, fn as y };