@blocknote/core 0.20.0 → 0.22.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 (456) hide show
  1. package/dist/blocknote.js +1602 -1569
  2. package/dist/blocknote.js.map +1 -1
  3. package/dist/blocknote.umd.cjs +6 -6
  4. package/dist/blocknote.umd.cjs.map +1 -1
  5. package/dist/style.css +1 -1
  6. package/dist/tsconfig.tsbuildinfo +1 -1
  7. package/dist/webpack-stats.json +1 -1
  8. package/package.json +3 -3
  9. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +3 -3
  10. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +1 -3
  11. package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +1 -1
  12. package/src/api/blockManipulation/selections/selection.ts +5 -5
  13. package/src/api/clipboard/__snapshots__/external/pasteEndOfParagraph.html +96 -0
  14. package/src/api/clipboard/__snapshots__/external/pasteEndOfParagraphText.html +96 -0
  15. package/src/api/clipboard/__snapshots__/external/pasteImage.html +111 -0
  16. package/src/api/clipboard/__snapshots__/external/pasteParagraphInCustomBlock.html +96 -0
  17. package/src/api/clipboard/__snapshots__/external/pasteTable.html +149 -0
  18. package/src/api/clipboard/__snapshots__/external/pasteTableInExistingTable.html +124 -0
  19. package/src/api/clipboard/__snapshots__/internal/paragraphInCustomBlock.html +1 -0
  20. package/src/api/clipboard/__snapshots__/internal/tableAllCells.html +1 -0
  21. package/src/api/clipboard/__snapshots__/internal/tableCell.html +1 -0
  22. package/src/api/clipboard/__snapshots__/internal/tableRow.html +1 -0
  23. package/src/api/clipboard/clipboardExternal.test.ts +161 -0
  24. package/src/api/clipboard/{clipboard.test.ts → clipboardInternal.test.ts} +66 -40
  25. package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +1 -1
  26. package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +7 -14
  27. package/src/api/clipboard/fromClipboard/pasteExtension.ts +6 -6
  28. package/src/api/clipboard/testUtil.ts +27 -0
  29. package/src/api/clipboard/toClipboard/copyExtension.ts +8 -2
  30. package/src/api/exporters/html/__snapshots__/file/basic/internal.html +1 -1
  31. package/src/api/exporters/html/__snapshots__/file/nested/internal.html +1 -1
  32. package/src/api/exporters/html/__snapshots__/file/noCaption/internal.html +1 -1
  33. package/src/api/exporters/html/__snapshots__/file/noName/internal.html +1 -1
  34. package/src/api/exporters/html/__snapshots__/image/basic/internal.html +1 -1
  35. package/src/api/exporters/html/__snapshots__/image/nested/internal.html +1 -1
  36. package/src/api/exporters/html/__snapshots__/image/noCaption/internal.html +1 -1
  37. package/src/api/exporters/html/__snapshots__/image/noName/internal.html +1 -1
  38. package/src/api/exporters/html/__snapshots__/image/noPreview/internal.html +1 -1
  39. package/src/api/exporters/html/__snapshots__/simpleImage/basic/external.html +1 -1
  40. package/src/api/exporters/html/__snapshots__/simpleImage/basic/internal.html +1 -1
  41. package/src/api/exporters/html/__snapshots__/simpleImage/nested/external.html +1 -1
  42. package/src/api/exporters/html/__snapshots__/simpleImage/nested/internal.html +1 -1
  43. package/src/api/exporters/html/__snapshots__/simpleImage/noCaption/external.html +1 -1
  44. package/src/api/exporters/html/__snapshots__/simpleImage/noCaption/internal.html +1 -1
  45. package/src/api/exporters/html/__snapshots__/simpleImage/noName/external.html +1 -1
  46. package/src/api/exporters/html/__snapshots__/simpleImage/noName/internal.html +1 -1
  47. package/src/api/exporters/html/__snapshots__/simpleImage/noPreview/external.html +1 -1
  48. package/src/api/exporters/html/__snapshots__/simpleImage/noPreview/internal.html +1 -1
  49. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +7 -1
  50. package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +3 -1
  51. package/src/api/exporters/markdown/__snapshots__/simpleImage/basic/markdown.md +1 -1
  52. package/src/api/exporters/markdown/__snapshots__/simpleImage/nested/markdown.md +2 -2
  53. package/src/api/exporters/markdown/__snapshots__/simpleImage/noCaption/markdown.md +1 -1
  54. package/src/api/exporters/markdown/__snapshots__/simpleImage/noName/markdown.md +1 -1
  55. package/src/api/nodeConversions/nodeToBlock.ts +4 -1
  56. package/src/api/parsers/markdown/__snapshots__/pasted/styled.json +2 -2
  57. package/src/api/parsers/markdown/parseMarkdown.test.ts +5 -7
  58. package/src/api/testUtil/partialBlockTestUtil.ts +4 -1
  59. package/src/blocks/AudioBlockContent/AudioBlockContent.ts +13 -14
  60. package/src/blocks/FileBlockContent/FileBlockContent.ts +5 -12
  61. package/src/blocks/FileBlockContent/helpers/parse/parseEmbedElement.ts +5 -0
  62. package/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.ts +16 -0
  63. package/src/blocks/FileBlockContent/helpers/render/createAddFileButton.ts +63 -0
  64. package/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.ts +80 -0
  65. package/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.ts +24 -0
  66. package/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.ts +204 -0
  67. package/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.ts +13 -0
  68. package/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.ts +15 -0
  69. package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +3 -19
  70. package/src/blocks/ImageBlockContent/ImageBlockContent.ts +20 -28
  71. package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +3 -15
  72. package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +11 -3
  73. package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +25 -5
  74. package/src/blocks/VideoBlockContent/VideoBlockContent.ts +20 -27
  75. package/src/editor/Block.css +38 -54
  76. package/src/editor/BlockNoteEditor.test.ts +21 -1
  77. package/src/editor/BlockNoteEditor.ts +14 -7
  78. package/src/editor/BlockNoteExtensions.ts +7 -8
  79. package/src/editor/editor.css +7 -6
  80. package/src/editor/transformPasted.ts +57 -4
  81. package/src/extensions/LinkToolbar/protocols.ts +13 -0
  82. package/src/extensions/Placeholder/PlaceholderPlugin.ts +6 -6
  83. package/src/extensions/SideMenu/SideMenuPlugin.ts +5 -1
  84. package/src/extensions/SideMenu/dragging.ts +3 -0
  85. package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +3 -6
  86. package/src/extensions/TableHandles/TableHandlesPlugin.ts +15 -3
  87. package/src/index.ts +9 -2
  88. package/src/schema/blocks/createSpec.ts +1 -1
  89. package/src/schema/blocks/internal.ts +16 -6
  90. package/src/schema/inlineContent/createSpec.ts +2 -2
  91. package/src/schema/inlineContent/internal.ts +4 -1
  92. package/src/schema/propTypes.ts +41 -18
  93. package/types/src/api/blockManipulation/setupTestEnv.d.ts +8 -0
  94. package/types/src/api/clipboard/clipboardInternal.test.d.ts +1 -0
  95. package/types/src/api/clipboard/fromClipboard/handleVSCodePaste.d.ts +2 -3
  96. package/types/src/api/clipboard/fromClipboard/pasteExtension.d.ts +1 -3
  97. package/types/src/api/clipboard/testUtil.d.ts +509 -0
  98. package/types/src/api/testUtil/cases/customBlocks.d.ts +8 -0
  99. package/types/src/api/testUtil/cases/customInlineContent.d.ts +8 -0
  100. package/types/src/api/testUtil/cases/customStyles.d.ts +8 -0
  101. package/types/src/blocks/AudioBlockContent/AudioBlockContent.d.ts +2 -5
  102. package/types/src/blocks/FileBlockContent/FileBlockContent.d.ts +2 -5
  103. package/types/src/blocks/FileBlockContent/helpers/parse/parseEmbedElement.d.ts +3 -0
  104. package/types/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.d.ts +4 -0
  105. package/types/src/blocks/FileBlockContent/helpers/render/createAddFileButton.d.ts +6 -0
  106. package/types/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.d.ts +9 -0
  107. package/types/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.d.ts +6 -0
  108. package/types/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.d.ts +9 -0
  109. package/types/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.d.ts +3 -0
  110. package/types/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.d.ts +3 -0
  111. package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +2 -5
  112. package/types/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +12 -0
  113. package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +2 -5
  114. package/types/src/blocks/defaultBlocks.d.ts +16 -0
  115. package/types/src/editor/BlockNoteEditor.d.ts +6 -4
  116. package/types/src/editor/transformPasted.d.ts +8 -4
  117. package/types/src/extensions/LinkToolbar/protocols.d.ts +2 -0
  118. package/types/src/index.d.ts +9 -2
  119. package/types/src/schema/propTypes.d.ts +20 -2
  120. package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js +0 -30
  121. package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js.map +0 -1
  122. package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.js +0 -99
  123. package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.js.map +0 -1
  124. package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.js +0 -97
  125. package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.js.map +0 -1
  126. package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.js +0 -88
  127. package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.js.map +0 -1
  128. package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.js +0 -219
  129. package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.js.map +0 -1
  130. package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.js +0 -175
  131. package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.js.map +0 -1
  132. package/dist/src/api/blockManipulation/commands/nestBlock/nestBlock.js +0 -57
  133. package/dist/src/api/blockManipulation/commands/nestBlock/nestBlock.js.map +0 -1
  134. package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js +0 -5
  135. package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js.map +0 -1
  136. package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js +0 -31
  137. package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js.map +0 -1
  138. package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js +0 -71
  139. package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js.map +0 -1
  140. package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.js +0 -157
  141. package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.js.map +0 -1
  142. package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js +0 -27
  143. package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js.map +0 -1
  144. package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js +0 -67
  145. package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js.map +0 -1
  146. package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js +0 -148
  147. package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js.map +0 -1
  148. package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.test.js +0 -252
  149. package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.test.js.map +0 -1
  150. package/dist/src/api/blockManipulation/getBlock/getBlock.js +0 -56
  151. package/dist/src/api/blockManipulation/getBlock/getBlock.js.map +0 -1
  152. package/dist/src/api/blockManipulation/insertContentAt.js +0 -64
  153. package/dist/src/api/blockManipulation/insertContentAt.js.map +0 -1
  154. package/dist/src/api/blockManipulation/selections/selection.js +0 -149
  155. package/dist/src/api/blockManipulation/selections/selection.js.map +0 -1
  156. package/dist/src/api/blockManipulation/selections/selection.test.js +0 -39
  157. package/dist/src/api/blockManipulation/selections/selection.test.js.map +0 -1
  158. package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js +0 -79
  159. package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js.map +0 -1
  160. package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.js +0 -33
  161. package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.js.map +0 -1
  162. package/dist/src/api/blockManipulation/setupTestEnv.js +0 -172
  163. package/dist/src/api/blockManipulation/setupTestEnv.js.map +0 -1
  164. package/dist/src/api/clipboard/clipboard.test.js +0 -246
  165. package/dist/src/api/clipboard/clipboard.test.js.map +0 -1
  166. package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js +0 -8
  167. package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js.map +0 -1
  168. package/dist/src/api/clipboard/fromClipboard/fileDropExtension.js +0 -38
  169. package/dist/src/api/clipboard/fromClipboard/fileDropExtension.js.map +0 -1
  170. package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js +0 -111
  171. package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js.map +0 -1
  172. package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js +0 -26
  173. package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js.map +0 -1
  174. package/dist/src/api/clipboard/fromClipboard/pasteExtension.js +0 -57
  175. package/dist/src/api/clipboard/fromClipboard/pasteExtension.js.map +0 -1
  176. package/dist/src/api/clipboard/toClipboard/copyExtension.js +0 -132
  177. package/dist/src/api/clipboard/toClipboard/copyExtension.js.map +0 -1
  178. package/dist/src/api/exporters/html/externalHTMLExporter.js +0 -35
  179. package/dist/src/api/exporters/html/externalHTMLExporter.js.map +0 -1
  180. package/dist/src/api/exporters/html/htmlConversion.test.js +0 -72
  181. package/dist/src/api/exporters/html/htmlConversion.test.js.map +0 -1
  182. package/dist/src/api/exporters/html/internalHTMLSerializer.js +0 -21
  183. package/dist/src/api/exporters/html/internalHTMLSerializer.js.map +0 -1
  184. package/dist/src/api/exporters/html/util/serializeBlocksExternalHTML.js +0 -141
  185. package/dist/src/api/exporters/html/util/serializeBlocksExternalHTML.js.map +0 -1
  186. package/dist/src/api/exporters/html/util/serializeBlocksInternalHTML.js +0 -96
  187. package/dist/src/api/exporters/html/util/serializeBlocksInternalHTML.js.map +0 -1
  188. package/dist/src/api/exporters/markdown/markdownExporter.js +0 -31
  189. package/dist/src/api/exporters/markdown/markdownExporter.js.map +0 -1
  190. package/dist/src/api/exporters/markdown/markdownExporter.test.js +0 -57
  191. package/dist/src/api/exporters/markdown/markdownExporter.test.js.map +0 -1
  192. package/dist/src/api/exporters/markdown/removeUnderlinesRehypePlugin.js +0 -33
  193. package/dist/src/api/exporters/markdown/removeUnderlinesRehypePlugin.js.map +0 -1
  194. package/dist/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.js +0 -37
  195. package/dist/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.js.map +0 -1
  196. package/dist/src/api/getBlockInfoFromPos.js +0 -165
  197. package/dist/src/api/getBlockInfoFromPos.js.map +0 -1
  198. package/dist/src/api/nodeConversions/blockToNode.js +0 -197
  199. package/dist/src/api/nodeConversions/blockToNode.js.map +0 -1
  200. package/dist/src/api/nodeConversions/fragmentToBlocks.js +0 -50
  201. package/dist/src/api/nodeConversions/fragmentToBlocks.js.map +0 -1
  202. package/dist/src/api/nodeConversions/nodeConversions.test.js +0 -54
  203. package/dist/src/api/nodeConversions/nodeConversions.test.js.map +0 -1
  204. package/dist/src/api/nodeConversions/nodeToBlock.js +0 -316
  205. package/dist/src/api/nodeConversions/nodeToBlock.js.map +0 -1
  206. package/dist/src/api/nodeUtil.js +0 -28
  207. package/dist/src/api/nodeUtil.js.map +0 -1
  208. package/dist/src/api/parsers/html/parseHTML.js +0 -19
  209. package/dist/src/api/parsers/html/parseHTML.js.map +0 -1
  210. package/dist/src/api/parsers/html/parseHTML.test.js +0 -470
  211. package/dist/src/api/parsers/html/parseHTML.test.js.map +0 -1
  212. package/dist/src/api/parsers/html/util/nestedLists.js +0 -106
  213. package/dist/src/api/parsers/html/util/nestedLists.js.map +0 -1
  214. package/dist/src/api/parsers/html/util/nestedLists.test.js +0 -166
  215. package/dist/src/api/parsers/html/util/nestedLists.test.js.map +0 -1
  216. package/dist/src/api/parsers/markdown/parseMarkdown.js +0 -52
  217. package/dist/src/api/parsers/markdown/parseMarkdown.js.map +0 -1
  218. package/dist/src/api/parsers/markdown/parseMarkdown.test.js +0 -109
  219. package/dist/src/api/parsers/markdown/parseMarkdown.test.js.map +0 -1
  220. package/dist/src/api/testUtil/cases/customBlocks.js +0 -313
  221. package/dist/src/api/testUtil/cases/customBlocks.js.map +0 -1
  222. package/dist/src/api/testUtil/cases/customInlineContent.js +0 -91
  223. package/dist/src/api/testUtil/cases/customInlineContent.js.map +0 -1
  224. package/dist/src/api/testUtil/cases/customStyles.js +0 -83
  225. package/dist/src/api/testUtil/cases/customStyles.js.map +0 -1
  226. package/dist/src/api/testUtil/cases/defaultSchema.js +0 -673
  227. package/dist/src/api/testUtil/cases/defaultSchema.js.map +0 -1
  228. package/dist/src/api/testUtil/index.js +0 -2
  229. package/dist/src/api/testUtil/index.js.map +0 -1
  230. package/dist/src/api/testUtil/partialBlockTestUtil.js +0 -114
  231. package/dist/src/api/testUtil/partialBlockTestUtil.js.map +0 -1
  232. package/dist/src/api/testUtil/paste.js +0 -29
  233. package/dist/src/api/testUtil/paste.js.map +0 -1
  234. package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js +0 -97
  235. package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js.map +0 -1
  236. package/dist/src/blocks/AudioBlockContent/audioBlockHelpers.js +0 -5
  237. package/dist/src/blocks/AudioBlockContent/audioBlockHelpers.js.map +0 -1
  238. package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js +0 -281
  239. package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js.map +0 -1
  240. package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js +0 -110
  241. package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js.map +0 -1
  242. package/dist/src/blocks/FileBlockContent/FileBlockContent.js +0 -70
  243. package/dist/src/blocks/FileBlockContent/FileBlockContent.js.map +0 -1
  244. package/dist/src/blocks/FileBlockContent/fileBlockHelpers.js +0 -317
  245. package/dist/src/blocks/FileBlockContent/fileBlockHelpers.js.map +0 -1
  246. package/dist/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js +0 -15
  247. package/dist/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js.map +0 -1
  248. package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js +0 -145
  249. package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js.map +0 -1
  250. package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js +0 -106
  251. package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js.map +0 -1
  252. package/dist/src/blocks/ImageBlockContent/imageBlockHelpers.js +0 -6
  253. package/dist/src/blocks/ImageBlockContent/imageBlockHelpers.js.map +0 -1
  254. package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js +0 -113
  255. package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js.map +0 -1
  256. package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js +0 -224
  257. package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js.map +0 -1
  258. package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js +0 -45
  259. package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js.map +0 -1
  260. package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.js +0 -58
  261. package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.js.map +0 -1
  262. package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js +0 -130
  263. package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js.map +0 -1
  264. package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js +0 -52
  265. package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js.map +0 -1
  266. package/dist/src/blocks/TableBlockContent/TableBlockContent.js +0 -129
  267. package/dist/src/blocks/TableBlockContent/TableBlockContent.js.map +0 -1
  268. package/dist/src/blocks/TableBlockContent/TableExtension.js +0 -64
  269. package/dist/src/blocks/TableBlockContent/TableExtension.js.map +0 -1
  270. package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js +0 -103
  271. package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js.map +0 -1
  272. package/dist/src/blocks/VideoBlockContent/videoBlockHelpers.js +0 -6
  273. package/dist/src/blocks/VideoBlockContent/videoBlockHelpers.js.map +0 -1
  274. package/dist/src/blocks/defaultBlockHelpers.js +0 -50
  275. package/dist/src/blocks/defaultBlockHelpers.js.map +0 -1
  276. package/dist/src/blocks/defaultBlockTypeGuards.js +0 -40
  277. package/dist/src/blocks/defaultBlockTypeGuards.js.map +0 -1
  278. package/dist/src/blocks/defaultBlocks.js +0 -50
  279. package/dist/src/blocks/defaultBlocks.js.map +0 -1
  280. package/dist/src/blocks/defaultProps.js +0 -19
  281. package/dist/src/blocks/defaultProps.js.map +0 -1
  282. package/dist/src/editor/BlockNoteEditor.js +0 -748
  283. package/dist/src/editor/BlockNoteEditor.js.map +0 -1
  284. package/dist/src/editor/BlockNoteEditor.test.js +0 -65
  285. package/dist/src/editor/BlockNoteEditor.test.js.map +0 -1
  286. package/dist/src/editor/BlockNoteExtensions.js +0 -196
  287. package/dist/src/editor/BlockNoteExtensions.js.map +0 -1
  288. package/dist/src/editor/BlockNoteSchema.js +0 -38
  289. package/dist/src/editor/BlockNoteSchema.js.map +0 -1
  290. package/dist/src/editor/BlockNoteTipTapEditor.js +0 -169
  291. package/dist/src/editor/BlockNoteTipTapEditor.js.map +0 -1
  292. package/dist/src/editor/cursorPositionTypes.js +0 -2
  293. package/dist/src/editor/cursorPositionTypes.js.map +0 -1
  294. package/dist/src/editor/defaultColors.js +0 -77
  295. package/dist/src/editor/defaultColors.js.map +0 -1
  296. package/dist/src/editor/selectionTypes.js +0 -2
  297. package/dist/src/editor/selectionTypes.js.map +0 -1
  298. package/dist/src/editor/transformPasted.js +0 -79
  299. package/dist/src/editor/transformPasted.js.map +0 -1
  300. package/dist/src/exporter/Exporter.js +0 -36
  301. package/dist/src/exporter/Exporter.js.map +0 -1
  302. package/dist/src/exporter/index.js +0 -3
  303. package/dist/src/exporter/index.js.map +0 -1
  304. package/dist/src/exporter/mapping.js +0 -12
  305. package/dist/src/exporter/mapping.js.map +0 -1
  306. package/dist/src/extensions/BackgroundColor/BackgroundColorExtension.js +0 -30
  307. package/dist/src/extensions/BackgroundColor/BackgroundColorExtension.js.map +0 -1
  308. package/dist/src/extensions/BackgroundColor/BackgroundColorMark.js +0 -39
  309. package/dist/src/extensions/BackgroundColor/BackgroundColorMark.js.map +0 -1
  310. package/dist/src/extensions/FilePanel/FilePanelPlugin.js +0 -131
  311. package/dist/src/extensions/FilePanel/FilePanelPlugin.js.map +0 -1
  312. package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js +0 -197
  313. package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js.map +0 -1
  314. package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js +0 -341
  315. package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js.map +0 -1
  316. package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js +0 -251
  317. package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js.map +0 -1
  318. package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js +0 -54
  319. package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js.map +0 -1
  320. package/dist/src/extensions/Placeholder/PlaceholderPlugin.js +0 -90
  321. package/dist/src/extensions/Placeholder/PlaceholderPlugin.js.map +0 -1
  322. package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js +0 -187
  323. package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js.map +0 -1
  324. package/dist/src/extensions/SideMenu/MultipleNodeSelection.js +0 -68
  325. package/dist/src/extensions/SideMenu/MultipleNodeSelection.js.map +0 -1
  326. package/dist/src/extensions/SideMenu/SideMenuPlugin.js +0 -343
  327. package/dist/src/extensions/SideMenu/SideMenuPlugin.js.map +0 -1
  328. package/dist/src/extensions/SideMenu/dragging.js +0 -132
  329. package/dist/src/extensions/SideMenu/dragging.js.map +0 -1
  330. package/dist/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.js +0 -2
  331. package/dist/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.js.map +0 -1
  332. package/dist/src/extensions/SuggestionMenu/DefaultSuggestionItem.js +0 -2
  333. package/dist/src/extensions/SuggestionMenu/DefaultSuggestionItem.js.map +0 -1
  334. package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js +0 -245
  335. package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js.map +0 -1
  336. package/dist/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.js +0 -26
  337. package/dist/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.js.map +0 -1
  338. package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js +0 -241
  339. package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js.map +0 -1
  340. package/dist/src/extensions/TableHandles/TableHandlesPlugin.js +0 -570
  341. package/dist/src/extensions/TableHandles/TableHandlesPlugin.js.map +0 -1
  342. package/dist/src/extensions/TextAlignment/TextAlignmentExtension.js +0 -36
  343. package/dist/src/extensions/TextAlignment/TextAlignmentExtension.js.map +0 -1
  344. package/dist/src/extensions/TextColor/TextColorExtension.js +0 -29
  345. package/dist/src/extensions/TextColor/TextColorExtension.js.map +0 -1
  346. package/dist/src/extensions/TextColor/TextColorMark.js +0 -37
  347. package/dist/src/extensions/TextColor/TextColorMark.js.map +0 -1
  348. package/dist/src/extensions/TrailingNode/TrailingNodeExtension.js +0 -58
  349. package/dist/src/extensions/TrailingNode/TrailingNodeExtension.js.map +0 -1
  350. package/dist/src/extensions/UniqueID/UniqueID.js +0 -283
  351. package/dist/src/extensions/UniqueID/UniqueID.js.map +0 -1
  352. package/dist/src/extensions/getDraggableBlockFromElement.js +0 -13
  353. package/dist/src/extensions/getDraggableBlockFromElement.js.map +0 -1
  354. package/dist/src/extensions-shared/UiElementPosition.js +0 -2
  355. package/dist/src/extensions-shared/UiElementPosition.js.map +0 -1
  356. package/dist/src/i18n/dictionary.js +0 -4
  357. package/dist/src/i18n/dictionary.js.map +0 -1
  358. package/dist/src/i18n/locales/ar.js +0 -298
  359. package/dist/src/i18n/locales/ar.js.map +0 -1
  360. package/dist/src/i18n/locales/de.js +0 -313
  361. package/dist/src/i18n/locales/de.js.map +0 -1
  362. package/dist/src/i18n/locales/en.js +0 -314
  363. package/dist/src/i18n/locales/en.js.map +0 -1
  364. package/dist/src/i18n/locales/es.js +0 -312
  365. package/dist/src/i18n/locales/es.js.map +0 -1
  366. package/dist/src/i18n/locales/fr.js +0 -313
  367. package/dist/src/i18n/locales/fr.js.map +0 -1
  368. package/dist/src/i18n/locales/hr.js +0 -308
  369. package/dist/src/i18n/locales/hr.js.map +0 -1
  370. package/dist/src/i18n/locales/index.js +0 -16
  371. package/dist/src/i18n/locales/index.js.map +0 -1
  372. package/dist/src/i18n/locales/is.js +0 -305
  373. package/dist/src/i18n/locales/is.js.map +0 -1
  374. package/dist/src/i18n/locales/ja.js +0 -333
  375. package/dist/src/i18n/locales/ja.js.map +0 -1
  376. package/dist/src/i18n/locales/ko.js +0 -326
  377. package/dist/src/i18n/locales/ko.js.map +0 -1
  378. package/dist/src/i18n/locales/nl.js +0 -313
  379. package/dist/src/i18n/locales/nl.js.map +0 -1
  380. package/dist/src/i18n/locales/pl.js +0 -297
  381. package/dist/src/i18n/locales/pl.js.map +0 -1
  382. package/dist/src/i18n/locales/pt.js +0 -305
  383. package/dist/src/i18n/locales/pt.js.map +0 -1
  384. package/dist/src/i18n/locales/ru.js +0 -340
  385. package/dist/src/i18n/locales/ru.js.map +0 -1
  386. package/dist/src/i18n/locales/vi.js +0 -312
  387. package/dist/src/i18n/locales/vi.js.map +0 -1
  388. package/dist/src/i18n/locales/zh.js +0 -346
  389. package/dist/src/i18n/locales/zh.js.map +0 -1
  390. package/dist/src/index.js +0 -56
  391. package/dist/src/index.js.map +0 -1
  392. package/dist/src/pm-nodes/BlockContainer.js +0 -72
  393. package/dist/src/pm-nodes/BlockContainer.js.map +0 -1
  394. package/dist/src/pm-nodes/BlockGroup.js +0 -43
  395. package/dist/src/pm-nodes/BlockGroup.js.map +0 -1
  396. package/dist/src/pm-nodes/Doc.js +0 -7
  397. package/dist/src/pm-nodes/Doc.js.map +0 -1
  398. package/dist/src/pm-nodes/index.js +0 -4
  399. package/dist/src/pm-nodes/index.js.map +0 -1
  400. package/dist/src/schema/blocks/createSpec.js +0 -126
  401. package/dist/src/schema/blocks/createSpec.js.map +0 -1
  402. package/dist/src/schema/blocks/internal.js +0 -147
  403. package/dist/src/schema/blocks/internal.js.map +0 -1
  404. package/dist/src/schema/blocks/types.js +0 -2
  405. package/dist/src/schema/blocks/types.js.map +0 -1
  406. package/dist/src/schema/index.js +0 -11
  407. package/dist/src/schema/index.js.map +0 -1
  408. package/dist/src/schema/inlineContent/createSpec.js +0 -64
  409. package/dist/src/schema/inlineContent/createSpec.js.map +0 -1
  410. package/dist/src/schema/inlineContent/internal.js +0 -52
  411. package/dist/src/schema/inlineContent/internal.js.map +0 -1
  412. package/dist/src/schema/inlineContent/types.js +0 -10
  413. package/dist/src/schema/inlineContent/types.js.map +0 -1
  414. package/dist/src/schema/propTypes.js +0 -2
  415. package/dist/src/schema/propTypes.js.map +0 -1
  416. package/dist/src/schema/styles/createSpec.js +0 -48
  417. package/dist/src/schema/styles/createSpec.js.map +0 -1
  418. package/dist/src/schema/styles/internal.js +0 -53
  419. package/dist/src/schema/styles/internal.js.map +0 -1
  420. package/dist/src/schema/styles/types.js +0 -2
  421. package/dist/src/schema/styles/types.js.map +0 -1
  422. package/dist/src/util/EventEmitter.js +0 -33
  423. package/dist/src/util/EventEmitter.js.map +0 -1
  424. package/dist/src/util/browser.js +0 -17
  425. package/dist/src/util/browser.js.map +0 -1
  426. package/dist/src/util/combineByGroup.js +0 -20
  427. package/dist/src/util/combineByGroup.js.map +0 -1
  428. package/dist/src/util/esmDependencies.js +0 -35
  429. package/dist/src/util/esmDependencies.js.map +0 -1
  430. package/dist/src/util/string.js +0 -14
  431. package/dist/src/util/string.js.map +0 -1
  432. package/dist/src/util/typescript.js +0 -12
  433. package/dist/src/util/typescript.js.map +0 -1
  434. package/src/api/clipboard/__snapshots__/tableAllCells.html +0 -1
  435. package/src/api/clipboard/__snapshots__/tableCell.html +0 -1
  436. package/src/api/clipboard/__snapshots__/tableRow.html +0 -1
  437. package/src/blocks/FileBlockContent/fileBlockHelpers.ts +0 -456
  438. package/types/src/blocks/FileBlockContent/fileBlockHelpers.d.ts +0 -41
  439. /package/src/api/clipboard/__snapshots__/{childToParent.html → internal/childToParent.html} +0 -0
  440. /package/src/api/clipboard/__snapshots__/{childrenToNextParent.html → internal/childrenToNextParent.html} +0 -0
  441. /package/src/api/clipboard/__snapshots__/{childrenToNextParentsChildren.html → internal/childrenToNextParentsChildren.html} +0 -0
  442. /package/src/api/clipboard/__snapshots__/{image.html → internal/image.html} +0 -0
  443. /package/src/api/clipboard/__snapshots__/{multipleChildren.html → internal/multipleChildren.html} +0 -0
  444. /package/src/api/clipboard/__snapshots__/{multipleStyledText.html → internal/multipleStyledText.html} +0 -0
  445. /package/src/api/clipboard/__snapshots__/{nestedImage.html → internal/nestedImage.html} +0 -0
  446. /package/src/api/clipboard/__snapshots__/{partialChildToParent.html → internal/partialChildToParent.html} +0 -0
  447. /package/src/api/clipboard/__snapshots__/{styledText.html → internal/styledText.html} +0 -0
  448. /package/src/api/clipboard/__snapshots__/{tableCellText.html → internal/tableCellText.html} +0 -0
  449. /package/src/api/clipboard/__snapshots__/{unstyledText.html → internal/unstyledText.html} +0 -0
  450. /package/src/blocks/AudioBlockContent/{audioBlockHelpers.ts → parseAudioElement.ts} +0 -0
  451. /package/src/blocks/ImageBlockContent/{imageBlockHelpers.ts → parseImageElement.ts} +0 -0
  452. /package/src/blocks/VideoBlockContent/{videoBlockHelpers.ts → parseVideoElement.ts} +0 -0
  453. /package/types/src/api/clipboard/{clipboard.test.d.ts → clipboardExternal.test.d.ts} +0 -0
  454. /package/types/src/blocks/AudioBlockContent/{audioBlockHelpers.d.ts → parseAudioElement.d.ts} +0 -0
  455. /package/types/src/blocks/ImageBlockContent/{imageBlockHelpers.d.ts → parseImageElement.d.ts} +0 -0
  456. /package/types/src/blocks/VideoBlockContent/{videoBlockHelpers.d.ts → parseVideoElement.d.ts} +0 -0
@@ -1,748 +0,0 @@
1
- import { Extension, getSchema, Mark, Node as TipTapNode, } from "@tiptap/core";
2
- import { getBlock, getNextBlock, getParentBlock, getPrevBlock, } from "../api/blockManipulation/getBlock/getBlock.js";
3
- import { insertBlocks } from "../api/blockManipulation/commands/insertBlocks/insertBlocks.js";
4
- import { moveBlocksDown, moveBlocksUp, } from "../api/blockManipulation/commands/moveBlocks/moveBlocks.js";
5
- import { canNestBlock, canUnnestBlock, nestBlock, unnestBlock, } from "../api/blockManipulation/commands/nestBlock/nestBlock.js";
6
- import { removeBlocks } from "../api/blockManipulation/commands/removeBlocks/removeBlocks.js";
7
- import { replaceBlocks } from "../api/blockManipulation/commands/replaceBlocks/replaceBlocks.js";
8
- import { updateBlock } from "../api/blockManipulation/commands/updateBlock/updateBlock.js";
9
- import { insertContentAt } from "../api/blockManipulation/insertContentAt.js";
10
- import { getTextCursorPosition, setTextCursorPosition, } from "../api/blockManipulation/selections/textCursorPosition/textCursorPosition.js";
11
- import { getSelection, setSelection, } from "../api/blockManipulation/selections/selection.js";
12
- import { createExternalHTMLExporter } from "../api/exporters/html/externalHTMLExporter.js";
13
- import { blocksToMarkdown } from "../api/exporters/markdown/markdownExporter.js";
14
- import { HTMLToBlocks } from "../api/parsers/html/parseHTML.js";
15
- import { markdownToBlocks } from "../api/parsers/markdown/parseMarkdown.js";
16
- import { UniqueID } from "../extensions/UniqueID/UniqueID.js";
17
- import { mergeCSSClasses } from "../util/browser.js";
18
- import { UnreachableCaseError } from "../util/typescript.js";
19
- import { getBlockNoteExtensions } from "./BlockNoteExtensions.js";
20
- import { transformPasted } from "./transformPasted.js";
21
- import { checkDefaultBlockTypeInSchema } from "../blocks/defaultBlockTypeGuards.js";
22
- import { BlockNoteSchema } from "./BlockNoteSchema.js";
23
- import { BlockNoteTipTapEditor, } from "./BlockNoteTipTapEditor.js";
24
- import { en } from "../i18n/locales/index.js";
25
- import { dropCursor } from "prosemirror-dropcursor";
26
- import { createInternalHTMLSerializer } from "../api/exporters/html/internalHTMLSerializer.js";
27
- import { inlineContentToNodes } from "../api/nodeConversions/blockToNode.js";
28
- import { nodeToBlock } from "../api/nodeConversions/nodeToBlock.js";
29
- import "../style.css";
30
- const blockNoteTipTapOptions = {
31
- enableInputRules: true,
32
- enablePasteRules: true,
33
- enableCoreExtensions: false,
34
- };
35
- export class BlockNoteEditor {
36
- options;
37
- _pmSchema;
38
- /**
39
- * extensions that are added to the editor, can be tiptap extensions or prosemirror plugins
40
- */
41
- extensions = {};
42
- /**
43
- * Boolean indicating whether the editor is in headless mode.
44
- * Headless mode means we can use features like importing / exporting blocks,
45
- * but there's no underlying editor (UI) instantiated.
46
- *
47
- * You probably don't need to set this manually, but use the `server-util` package instead that uses this option internally
48
- */
49
- headless = false;
50
- _tiptapEditor = undefined; // TODO: Type should actually reflect that it can be `undefined` in headless mode
51
- /**
52
- * Used by React to store a reference to an `ElementRenderer` helper utility to make sure we can render React elements
53
- * in the correct context (used by `ReactRenderUtil`)
54
- */
55
- elementRenderer = null;
56
- /**
57
- * Cache of all blocks. This makes sure we don't have to "recompute" blocks if underlying Prosemirror Nodes haven't changed.
58
- * This is especially useful when we want to keep track of the same block across multiple operations,
59
- * with this cache, blocks stay the same object reference (referential equality with ===).
60
- */
61
- blockCache = new WeakMap();
62
- /**
63
- * The dictionary contains translations for the editor.
64
- */
65
- dictionary;
66
- /**
67
- * The schema of the editor. The schema defines which Blocks, InlineContent, and Styles are available in the editor.
68
- */
69
- schema;
70
- blockImplementations;
71
- inlineContentImplementations;
72
- styleImplementations;
73
- formattingToolbar;
74
- linkToolbar;
75
- sideMenu;
76
- suggestionMenus;
77
- filePanel;
78
- tableHandles;
79
- /**
80
- * The `uploadFile` method is what the editor uses when files need to be uploaded (for example when selecting an image to upload).
81
- * This method should set when creating the editor as this is application-specific.
82
- *
83
- * `undefined` means the application doesn't support file uploads.
84
- *
85
- * @param file The file that should be uploaded.
86
- * @returns The URL of the uploaded file OR an object containing props that should be set on the file block (such as an id)
87
- */
88
- uploadFile;
89
- onUploadStartCallbacks = [];
90
- onUploadEndCallbacks = [];
91
- resolveFileUrl;
92
- get pmSchema() {
93
- return this._pmSchema;
94
- }
95
- static create(options = {}) {
96
- return new BlockNoteEditor(options);
97
- }
98
- constructor(options) {
99
- this.options = options;
100
- const anyOpts = options;
101
- if (anyOpts.onEditorContentChange) {
102
- throw new Error("onEditorContentChange initialization option is deprecated, use <BlockNoteView onChange={...} />, the useEditorChange(...) hook, or editor.onChange(...)");
103
- }
104
- if (anyOpts.onTextCursorPositionChange) {
105
- throw new Error("onTextCursorPositionChange initialization option is deprecated, use <BlockNoteView onSelectionChange={...} />, the useEditorSelectionChange(...) hook, or editor.onSelectionChange(...)");
106
- }
107
- if (anyOpts.onEditorReady) {
108
- throw new Error("onEditorReady is deprecated. Editor is immediately ready for use after creation.");
109
- }
110
- if (anyOpts.editable) {
111
- throw new Error("editable initialization option is deprecated, use <BlockNoteView editable={true/false} />, or alternatively editor.isEditable = true/false");
112
- }
113
- this.dictionary = options.dictionary || en;
114
- // apply defaults
115
- const newOptions = {
116
- defaultStyles: true,
117
- schema: options.schema || BlockNoteSchema.create(),
118
- _headless: false,
119
- ...options,
120
- placeholders: {
121
- ...this.dictionary.placeholders,
122
- ...options.placeholders,
123
- },
124
- };
125
- // @ts-ignore
126
- this.schema = newOptions.schema;
127
- this.blockImplementations = newOptions.schema.blockSpecs;
128
- this.inlineContentImplementations = newOptions.schema.inlineContentSpecs;
129
- this.styleImplementations = newOptions.schema.styleSpecs;
130
- this.extensions = getBlockNoteExtensions({
131
- editor: this,
132
- domAttributes: newOptions.domAttributes || {},
133
- blockSpecs: this.schema.blockSpecs,
134
- styleSpecs: this.schema.styleSpecs,
135
- inlineContentSpecs: this.schema.inlineContentSpecs,
136
- collaboration: newOptions.collaboration,
137
- trailingBlock: newOptions.trailingBlock,
138
- disableExtensions: newOptions.disableExtensions,
139
- setIdAttribute: newOptions.setIdAttribute,
140
- animations: newOptions.animations ?? true,
141
- tableHandles: checkDefaultBlockTypeInSchema("table", this),
142
- dropCursor: this.options.dropCursor ?? dropCursor,
143
- placeholders: newOptions.placeholders,
144
- tabBehavior: newOptions.tabBehavior,
145
- });
146
- // add extensions from _tiptapOptions
147
- (newOptions._tiptapOptions?.extensions || []).forEach((ext) => {
148
- this.extensions[ext.name] = ext;
149
- });
150
- // add extensions from options
151
- Object.entries(newOptions._extensions || {}).forEach(([key, ext]) => {
152
- this.extensions[key] = ext;
153
- });
154
- this.formattingToolbar = this.extensions["formattingToolbar"];
155
- this.linkToolbar = this.extensions["linkToolbar"];
156
- this.sideMenu = this.extensions["sideMenu"];
157
- this.suggestionMenus = this.extensions["suggestionMenus"];
158
- this.filePanel = this.extensions["filePanel"];
159
- this.tableHandles = this.extensions["tableHandles"];
160
- if (newOptions.uploadFile) {
161
- const uploadFile = newOptions.uploadFile;
162
- this.uploadFile = async (file, block) => {
163
- this.onUploadStartCallbacks.forEach((callback) => callback.apply(this, [block]));
164
- try {
165
- return await uploadFile(file, block);
166
- }
167
- finally {
168
- this.onUploadEndCallbacks.forEach((callback) => callback.apply(this, [block]));
169
- }
170
- };
171
- }
172
- this.resolveFileUrl = newOptions.resolveFileUrl || (async (url) => url);
173
- this.headless = newOptions._headless;
174
- if (newOptions.collaboration && newOptions.initialContent) {
175
- // eslint-disable-next-line no-console
176
- console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider");
177
- }
178
- const initialContent = newOptions.initialContent ||
179
- (options.collaboration
180
- ? [
181
- {
182
- type: "paragraph",
183
- id: "initialBlockId",
184
- },
185
- ]
186
- : [
187
- {
188
- type: "paragraph",
189
- id: UniqueID.options.generateID(),
190
- },
191
- ]);
192
- if (!Array.isArray(initialContent) || initialContent.length === 0) {
193
- throw new Error("initialContent must be a non-empty array of blocks, received: " +
194
- initialContent);
195
- }
196
- const tiptapExtensions = [
197
- ...Object.entries(this.extensions).map(([key, ext]) => {
198
- if (ext instanceof Extension ||
199
- ext instanceof TipTapNode ||
200
- ext instanceof Mark) {
201
- // tiptap extension
202
- return ext;
203
- }
204
- if (!ext.plugin) {
205
- throw new Error("Extension should either be a TipTap extension or a ProseMirror plugin in a plugin property");
206
- }
207
- // "blocknote" extensions (prosemirror plugins)
208
- return Extension.create({
209
- name: key,
210
- addProseMirrorPlugins: () => [ext.plugin],
211
- });
212
- }),
213
- ];
214
- const tiptapOptions = {
215
- ...blockNoteTipTapOptions,
216
- ...newOptions._tiptapOptions,
217
- content: initialContent,
218
- extensions: tiptapExtensions,
219
- editorProps: {
220
- ...newOptions._tiptapOptions?.editorProps,
221
- attributes: {
222
- // As of TipTap v2.5.0 the tabIndex is removed when the editor is not
223
- // editable, so you can't focus it. We want to revert this as we have
224
- // UI behaviour that relies on it.
225
- tabIndex: "0",
226
- ...newOptions._tiptapOptions?.editorProps?.attributes,
227
- ...newOptions.domAttributes?.editor,
228
- class: mergeCSSClasses("bn-editor", newOptions.defaultStyles ? "bn-default-styles" : "", newOptions.domAttributes?.editor?.class || ""),
229
- },
230
- transformPasted,
231
- },
232
- };
233
- if (!this.headless) {
234
- this._tiptapEditor = BlockNoteTipTapEditor.create(tiptapOptions, this.schema.styleSchema);
235
- this._pmSchema = this._tiptapEditor.schema;
236
- }
237
- else {
238
- // In headless mode, we don't instantiate an underlying TipTap editor,
239
- // but we still need the schema
240
- this._pmSchema = getSchema(tiptapOptions.extensions);
241
- }
242
- }
243
- dispatch(tr) {
244
- this._tiptapEditor.dispatch(tr);
245
- }
246
- /**
247
- * Mount the editor to a parent DOM element. Call mount(undefined) to clean up
248
- *
249
- * @warning Not needed to call manually when using React, use BlockNoteView to take care of mounting
250
- */
251
- mount = (parentElement) => {
252
- this._tiptapEditor.mount(parentElement);
253
- };
254
- get prosemirrorView() {
255
- return this._tiptapEditor.view;
256
- }
257
- get domElement() {
258
- return this._tiptapEditor.view.dom;
259
- }
260
- isFocused() {
261
- return this._tiptapEditor.view.hasFocus();
262
- }
263
- focus() {
264
- this._tiptapEditor.view.focus();
265
- }
266
- onUploadStart(callback) {
267
- this.onUploadStartCallbacks.push(callback);
268
- return () => {
269
- const index = this.onUploadStartCallbacks.indexOf(callback);
270
- if (index > -1) {
271
- this.onUploadStartCallbacks.splice(index, 1);
272
- }
273
- };
274
- }
275
- onUploadEnd(callback) {
276
- this.onUploadEndCallbacks.push(callback);
277
- return () => {
278
- const index = this.onUploadEndCallbacks.indexOf(callback);
279
- if (index > -1) {
280
- this.onUploadEndCallbacks.splice(index, 1);
281
- }
282
- };
283
- }
284
- /**
285
- * @deprecated, use `editor.document` instead
286
- */
287
- get topLevelBlocks() {
288
- return this.document;
289
- }
290
- /**
291
- * Gets a snapshot of all top-level (non-nested) blocks in the editor.
292
- * @returns A snapshot of all top-level (non-nested) blocks in the editor.
293
- */
294
- get document() {
295
- const blocks = [];
296
- this._tiptapEditor.state.doc.firstChild.descendants((node) => {
297
- blocks.push(nodeToBlock(node, this.schema.blockSchema, this.schema.inlineContentSchema, this.schema.styleSchema, this.blockCache));
298
- return false;
299
- });
300
- return blocks;
301
- }
302
- /**
303
- * Gets a snapshot of an existing block from the editor.
304
- * @param blockIdentifier The identifier of an existing block that should be
305
- * retrieved.
306
- * @returns The block that matches the identifier, or `undefined` if no
307
- * matching block was found.
308
- */
309
- getBlock(blockIdentifier) {
310
- return getBlock(this, blockIdentifier);
311
- }
312
- /**
313
- * Gets a snapshot of the previous sibling of an existing block from the
314
- * editor.
315
- * @param blockIdentifier The identifier of an existing block for which the
316
- * previous sibling should be retrieved.
317
- * @returns The previous sibling of the block that matches the identifier.
318
- * `undefined` if no matching block was found, or it's the first child/block
319
- * in the document.
320
- */
321
- getPrevBlock(blockIdentifier) {
322
- return getPrevBlock(this, blockIdentifier);
323
- }
324
- /**
325
- * Gets a snapshot of the next sibling of an existing block from the editor.
326
- * @param blockIdentifier The identifier of an existing block for which the
327
- * next sibling should be retrieved.
328
- * @returns The next sibling of the block that matches the identifier.
329
- * `undefined` if no matching block was found, or it's the last child/block in
330
- * the document.
331
- */
332
- getNextBlock(blockIdentifier) {
333
- return getNextBlock(this, blockIdentifier);
334
- }
335
- /**
336
- * Gets a snapshot of the parent of an existing block from the editor.
337
- * @param blockIdentifier The identifier of an existing block for which the
338
- * parent should be retrieved.
339
- * @returns The parent of the block that matches the identifier. `undefined`
340
- * if no matching block was found, or the block isn't nested.
341
- */
342
- getParentBlock(blockIdentifier) {
343
- return getParentBlock(this, blockIdentifier);
344
- }
345
- /**
346
- * Traverses all blocks in the editor depth-first, and executes a callback for each.
347
- * @param callback The callback to execute for each block. Returning `false` stops the traversal.
348
- * @param reverse Whether the blocks should be traversed in reverse order.
349
- */
350
- forEachBlock(callback, reverse = false) {
351
- const blocks = this.document.slice();
352
- if (reverse) {
353
- blocks.reverse();
354
- }
355
- function traverseBlockArray(blockArray) {
356
- for (const block of blockArray) {
357
- if (callback(block) === false) {
358
- return false;
359
- }
360
- const children = reverse
361
- ? block.children.slice().reverse()
362
- : block.children;
363
- if (!traverseBlockArray(children)) {
364
- return false;
365
- }
366
- }
367
- return true;
368
- }
369
- traverseBlockArray(blocks);
370
- }
371
- /**
372
- * Executes a callback whenever the editor's contents change.
373
- * @param callback The callback to execute.
374
- */
375
- onEditorContentChange(callback) {
376
- this._tiptapEditor.on("update", callback);
377
- }
378
- /**
379
- * Executes a callback whenever the editor's selection changes.
380
- * @param callback The callback to execute.
381
- */
382
- onEditorSelectionChange(callback) {
383
- this._tiptapEditor.on("selectionUpdate", callback);
384
- }
385
- /**
386
- * Gets a snapshot of the current text cursor position.
387
- * @returns A snapshot of the current text cursor position.
388
- */
389
- getTextCursorPosition() {
390
- return getTextCursorPosition(this);
391
- }
392
- /**
393
- * Sets the text cursor position to the start or end of an existing block. Throws an error if the target block could
394
- * not be found.
395
- * @param targetBlock The identifier of an existing block that the text cursor should be moved to.
396
- * @param placement Whether the text cursor should be placed at the start or end of the block.
397
- */
398
- setTextCursorPosition(targetBlock, placement = "start") {
399
- setTextCursorPosition(this, targetBlock, placement);
400
- }
401
- /**
402
- * Gets a snapshot of the current selection.
403
- */
404
- getSelection() {
405
- return getSelection(this);
406
- }
407
- setSelection(startBlock, endBlock) {
408
- setSelection(this, startBlock, endBlock);
409
- }
410
- /**
411
- * Checks if the editor is currently editable, or if it's locked.
412
- * @returns True if the editor is editable, false otherwise.
413
- */
414
- get isEditable() {
415
- if (!this._tiptapEditor) {
416
- if (!this.headless) {
417
- throw new Error("no editor, but also not headless?");
418
- }
419
- return false;
420
- }
421
- return this._tiptapEditor.isEditable === undefined
422
- ? true
423
- : this._tiptapEditor.isEditable;
424
- }
425
- /**
426
- * Makes the editor editable or locks it, depending on the argument passed.
427
- * @param editable True to make the editor editable, or false to lock it.
428
- */
429
- set isEditable(editable) {
430
- if (!this._tiptapEditor) {
431
- if (!this.headless) {
432
- throw new Error("no editor, but also not headless?");
433
- }
434
- // not relevant on headless
435
- return;
436
- }
437
- if (this._tiptapEditor.options.editable !== editable) {
438
- this._tiptapEditor.setEditable(editable);
439
- }
440
- }
441
- /**
442
- * Inserts new blocks into the editor. If a block's `id` is undefined, BlockNote generates one automatically. Throws an
443
- * error if the reference block could not be found.
444
- * @param blocksToInsert An array of partial blocks that should be inserted.
445
- * @param referenceBlock An identifier for an existing block, at which the new blocks should be inserted.
446
- * @param placement Whether the blocks should be inserted just before, just after, or nested inside the
447
- * `referenceBlock`.
448
- */
449
- insertBlocks(blocksToInsert, referenceBlock, placement = "before") {
450
- return insertBlocks(this, blocksToInsert, referenceBlock, placement);
451
- }
452
- /**
453
- * Updates an existing block in the editor. Since updatedBlock is a PartialBlock object, some fields might not be
454
- * defined. These undefined fields are kept as-is from the existing block. Throws an error if the block to update could
455
- * not be found.
456
- * @param blockToUpdate The block that should be updated.
457
- * @param update A partial block which defines how the existing block should be changed.
458
- */
459
- updateBlock(blockToUpdate, update) {
460
- return updateBlock(this, blockToUpdate, update);
461
- }
462
- /**
463
- * Removes existing blocks from the editor. Throws an error if any of the blocks could not be found.
464
- * @param blocksToRemove An array of identifiers for existing blocks that should be removed.
465
- */
466
- removeBlocks(blocksToRemove) {
467
- return removeBlocks(this, blocksToRemove);
468
- }
469
- /**
470
- * Replaces existing blocks in the editor with new blocks. If the blocks that should be removed are not adjacent or
471
- * are at different nesting levels, `blocksToInsert` will be inserted at the position of the first block in
472
- * `blocksToRemove`. Throws an error if any of the blocks to remove could not be found.
473
- * @param blocksToRemove An array of blocks that should be replaced.
474
- * @param blocksToInsert An array of partial blocks to replace the old ones with.
475
- */
476
- replaceBlocks(blocksToRemove, blocksToInsert) {
477
- return replaceBlocks(this, blocksToRemove, blocksToInsert);
478
- }
479
- /**
480
- * Insert a piece of content at the current cursor position.
481
- *
482
- * @param content can be a string, or array of partial inline content elements
483
- */
484
- insertInlineContent(content) {
485
- const nodes = inlineContentToNodes(content, this.pmSchema, this.schema.styleSchema);
486
- insertContentAt({
487
- from: this._tiptapEditor.state.selection.from,
488
- to: this._tiptapEditor.state.selection.to,
489
- }, nodes, this);
490
- }
491
- /**
492
- * Gets the active text styles at the text cursor position or at the end of the current selection if it's active.
493
- */
494
- getActiveStyles() {
495
- const styles = {};
496
- const marks = this._tiptapEditor.state.selection.$to.marks();
497
- for (const mark of marks) {
498
- const config = this.schema.styleSchema[mark.type.name];
499
- if (!config) {
500
- if (mark.type.name !== "link") {
501
- // eslint-disable-next-line no-console
502
- console.warn("mark not found in styleschema", mark.type.name);
503
- }
504
- continue;
505
- }
506
- if (config.propSchema === "boolean") {
507
- styles[config.type] = true;
508
- }
509
- else {
510
- styles[config.type] = mark.attrs.stringValue;
511
- }
512
- }
513
- return styles;
514
- }
515
- /**
516
- * Adds styles to the currently selected content.
517
- * @param styles The styles to add.
518
- */
519
- addStyles(styles) {
520
- for (const [style, value] of Object.entries(styles)) {
521
- const config = this.schema.styleSchema[style];
522
- if (!config) {
523
- throw new Error(`style ${style} not found in styleSchema`);
524
- }
525
- if (config.propSchema === "boolean") {
526
- this._tiptapEditor.commands.setMark(style);
527
- }
528
- else if (config.propSchema === "string") {
529
- this._tiptapEditor.commands.setMark(style, { stringValue: value });
530
- }
531
- else {
532
- throw new UnreachableCaseError(config.propSchema);
533
- }
534
- }
535
- }
536
- /**
537
- * Removes styles from the currently selected content.
538
- * @param styles The styles to remove.
539
- */
540
- removeStyles(styles) {
541
- for (const style of Object.keys(styles)) {
542
- this._tiptapEditor.commands.unsetMark(style);
543
- }
544
- }
545
- /**
546
- * Toggles styles on the currently selected content.
547
- * @param styles The styles to toggle.
548
- */
549
- toggleStyles(styles) {
550
- for (const [style, value] of Object.entries(styles)) {
551
- const config = this.schema.styleSchema[style];
552
- if (!config) {
553
- throw new Error(`style ${style} not found in styleSchema`);
554
- }
555
- if (config.propSchema === "boolean") {
556
- this._tiptapEditor.commands.toggleMark(style);
557
- }
558
- else if (config.propSchema === "string") {
559
- this._tiptapEditor.commands.toggleMark(style, { stringValue: value });
560
- }
561
- else {
562
- throw new UnreachableCaseError(config.propSchema);
563
- }
564
- }
565
- }
566
- /**
567
- * Gets the currently selected text.
568
- */
569
- getSelectedText() {
570
- return this._tiptapEditor.state.doc.textBetween(this._tiptapEditor.state.selection.from, this._tiptapEditor.state.selection.to);
571
- }
572
- /**
573
- * Gets the URL of the last link in the current selection, or `undefined` if there are no links in the selection.
574
- */
575
- getSelectedLinkUrl() {
576
- return this._tiptapEditor.getAttributes("link").href;
577
- }
578
- /**
579
- * Creates a new link to replace the selected content.
580
- * @param url The link URL.
581
- * @param text The text to display the link with.
582
- */
583
- createLink(url, text) {
584
- if (url === "") {
585
- return;
586
- }
587
- const { from, to } = this._tiptapEditor.state.selection;
588
- if (!text) {
589
- text = this._tiptapEditor.state.doc.textBetween(from, to);
590
- }
591
- const mark = this.pmSchema.mark("link", { href: url });
592
- this.dispatch(this._tiptapEditor.state.tr
593
- .insertText(text, from, to)
594
- .addMark(from, from + text.length, mark));
595
- }
596
- /**
597
- * Checks if the block containing the text cursor can be nested.
598
- */
599
- canNestBlock() {
600
- return canNestBlock(this);
601
- }
602
- /**
603
- * Nests the block containing the text cursor into the block above it.
604
- */
605
- nestBlock() {
606
- nestBlock(this);
607
- }
608
- /**
609
- * Checks if the block containing the text cursor is nested.
610
- */
611
- canUnnestBlock() {
612
- return canUnnestBlock(this);
613
- }
614
- /**
615
- * Lifts the block containing the text cursor out of its parent.
616
- */
617
- unnestBlock() {
618
- unnestBlock(this);
619
- }
620
- /**
621
- * Moves the selected blocks up. If the previous block has children, moves
622
- * them to the end of its children. If there is no previous block, but the
623
- * current blocks share a common parent, moves them out of & before it.
624
- */
625
- moveBlocksUp() {
626
- moveBlocksUp(this);
627
- }
628
- /**
629
- * Moves the selected blocks down. If the next block has children, moves
630
- * them to the start of its children. If there is no next block, but the
631
- * current blocks share a common parent, moves them out of & after it.
632
- */
633
- moveBlocksDown() {
634
- moveBlocksDown(this);
635
- }
636
- /**
637
- * Exports blocks into a simplified HTML string. To better conform to HTML standards, children of blocks which aren't list
638
- * items are un-nested in the output HTML.
639
- *
640
- * @param blocks An array of blocks that should be serialized into HTML.
641
- * @returns The blocks, serialized as an HTML string.
642
- */
643
- async blocksToHTMLLossy(blocks = this.document) {
644
- const exporter = createExternalHTMLExporter(this.pmSchema, this);
645
- return exporter.exportBlocks(blocks, {});
646
- }
647
- /**
648
- * Serializes blocks into an HTML string in the format that would normally be rendered by the editor.
649
- *
650
- * Use this method if you want to server-side render HTML (for example, a blog post that has been edited in BlockNote)
651
- * and serve it to users without loading the editor on the client (i.e.: displaying the blog post)
652
- *
653
- * @param blocks An array of blocks that should be serialized into HTML.
654
- * @returns The blocks, serialized as an HTML string.
655
- */
656
- async blocksToFullHTML(blocks) {
657
- const exporter = createInternalHTMLSerializer(this.pmSchema, this);
658
- return exporter.serializeBlocks(blocks, {});
659
- }
660
- /**
661
- * Parses blocks from an HTML string. Tries to create `Block` objects out of any HTML block-level elements, and
662
- * `InlineNode` objects from any HTML inline elements, though not all element types are recognized. If BlockNote
663
- * doesn't recognize an HTML element's tag, it will parse it as a paragraph or plain text.
664
- * @param html The HTML string to parse blocks from.
665
- * @returns The blocks parsed from the HTML string.
666
- */
667
- async tryParseHTMLToBlocks(html) {
668
- return HTMLToBlocks(html, this.schema.blockSchema, this.schema.inlineContentSchema, this.schema.styleSchema, this.pmSchema);
669
- }
670
- /**
671
- * Serializes blocks into a Markdown string. The output is simplified as Markdown does not support all features of
672
- * BlockNote - children of blocks which aren't list items are un-nested and certain styles are removed.
673
- * @param blocks An array of blocks that should be serialized into Markdown.
674
- * @returns The blocks, serialized as a Markdown string.
675
- */
676
- async blocksToMarkdownLossy(blocks = this.document) {
677
- return blocksToMarkdown(blocks, this.pmSchema, this, {});
678
- }
679
- /**
680
- * Creates a list of blocks from a Markdown string. Tries to create `Block` and `InlineNode` objects based on
681
- * Markdown syntax, though not all symbols are recognized. If BlockNote doesn't recognize a symbol, it will parse it
682
- * as text.
683
- * @param markdown The Markdown string to parse blocks from.
684
- * @returns The blocks parsed from the Markdown string.
685
- */
686
- async tryParseMarkdownToBlocks(markdown) {
687
- return markdownToBlocks(markdown, this.schema.blockSchema, this.schema.inlineContentSchema, this.schema.styleSchema, this.pmSchema);
688
- }
689
- /**
690
- * Updates the user info for the current user that's shown to other collaborators.
691
- */
692
- updateCollaborationUserInfo(user) {
693
- if (!this.options.collaboration) {
694
- throw new Error("Cannot update collaboration user info when collaboration is disabled.");
695
- }
696
- this._tiptapEditor.commands.updateUser(user);
697
- }
698
- /**
699
- * A callback function that runs whenever the editor's contents change.
700
- *
701
- * @param callback The callback to execute.
702
- * @returns A function to remove the callback.
703
- */
704
- onChange(callback) {
705
- if (this.headless) {
706
- // Note: would be nice if this is possible in headless mode as well
707
- return;
708
- }
709
- const cb = () => {
710
- callback(this);
711
- };
712
- this._tiptapEditor.on("update", cb);
713
- return () => {
714
- this._tiptapEditor.off("update", cb);
715
- };
716
- }
717
- /**
718
- * A callback function that runs whenever the text cursor position or selection changes.
719
- *
720
- * @param callback The callback to execute.
721
- * @returns A function to remove the callback.
722
- */
723
- onSelectionChange(callback) {
724
- if (this.headless) {
725
- return;
726
- }
727
- const cb = () => {
728
- callback(this);
729
- };
730
- this._tiptapEditor.on("selectionUpdate", cb);
731
- return () => {
732
- this._tiptapEditor.off("selectionUpdate", cb);
733
- };
734
- }
735
- openSuggestionMenu(triggerCharacter, pluginState) {
736
- const tr = this.prosemirrorView.state.tr;
737
- const transaction = pluginState && pluginState.deleteTriggerCharacter
738
- ? tr.insertText(triggerCharacter)
739
- : tr;
740
- this.prosemirrorView.focus();
741
- this.prosemirrorView.dispatch(transaction.scrollIntoView().setMeta(this.suggestionMenus.plugin, {
742
- triggerCharacter: triggerCharacter,
743
- deleteTriggerCharacter: pluginState?.deleteTriggerCharacter || false,
744
- ignoreQueryLength: pluginState?.ignoreQueryLength || false,
745
- }));
746
- }
747
- }
748
- //# sourceMappingURL=BlockNoteEditor.js.map