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