@blocknote/core 0.55.0 → 0.57.0

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