@blocknote/core 0.15.11 → 0.17.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 (292) hide show
  1. package/dist/blocknote.js +3349 -2773
  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/webpack-stats.json +1 -1
  6. package/package.json +5 -2
  7. package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +3087 -0
  8. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +132 -0
  9. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +71 -0
  10. package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +2276 -0
  11. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +131 -0
  12. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +103 -0
  13. package/src/api/blockManipulation/commands/moveBlock/__snapshots__/moveBlock.test.ts.snap +3767 -0
  14. package/src/api/blockManipulation/commands/moveBlock/moveBlock.test.ts +192 -0
  15. package/src/api/blockManipulation/commands/moveBlock/moveBlock.ts +178 -0
  16. package/src/api/blockManipulation/commands/removeBlocks/__snapshots__/removeBlocks.test.ts.snap +1136 -0
  17. package/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.ts +34 -0
  18. package/src/api/blockManipulation/commands/removeBlocks/removeBlocks.ts +100 -0
  19. package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +4931 -0
  20. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +222 -0
  21. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +70 -0
  22. package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +2924 -0
  23. package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +136 -0
  24. package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +48 -0
  25. package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +8376 -0
  26. package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +300 -0
  27. package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +199 -0
  28. package/src/api/blockManipulation/insertContentAt.ts +96 -0
  29. package/src/api/blockManipulation/selections/textCursorPosition/__snapshots__/textCursorPosition.test.ts.snap +316 -0
  30. package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.ts +53 -0
  31. package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.ts +130 -0
  32. package/src/api/blockManipulation/setupTestEnv.ts +179 -0
  33. package/src/api/clipboard/__snapshots__/childToParent.html +1 -0
  34. package/src/api/clipboard/__snapshots__/childrenToNextParent.html +1 -0
  35. package/src/api/clipboard/__snapshots__/childrenToNextParentsChildren.html +1 -0
  36. package/src/api/clipboard/__snapshots__/image.html +1 -0
  37. package/src/api/clipboard/__snapshots__/multipleStyledText.html +1 -0
  38. package/src/api/clipboard/__snapshots__/nestedImage.html +1 -0
  39. package/src/api/clipboard/__snapshots__/partialChildToParent.html +1 -0
  40. package/src/api/clipboard/__snapshots__/styledText.html +1 -0
  41. package/src/api/clipboard/__snapshots__/tableAllCells.html +1 -0
  42. package/src/api/clipboard/__snapshots__/tableCell.html +1 -0
  43. package/src/api/clipboard/__snapshots__/tableCellText.html +1 -0
  44. package/src/api/clipboard/__snapshots__/tableRow.html +1 -0
  45. package/src/api/clipboard/__snapshots__/unstyledText.html +1 -0
  46. package/src/api/clipboard/clipboard.test.ts +283 -0
  47. package/src/api/{parsers → clipboard/fromClipboard}/fileDropExtension.ts +8 -4
  48. package/src/api/{parsers → clipboard/fromClipboard}/handleFileInsertion.ts +12 -7
  49. package/src/api/{parsers → clipboard/fromClipboard}/pasteExtension.ts +19 -8
  50. package/src/api/clipboard/toClipboard/copyExtension.ts +243 -0
  51. package/src/api/exporters/html/__snapshots__/complex/misc/external.html +1 -1
  52. package/src/api/exporters/html/__snapshots__/lists/basic/external.html +1 -1
  53. package/src/api/exporters/html/__snapshots__/lists/nested/external.html +1 -1
  54. package/src/api/exporters/html/externalHTMLExporter.ts +42 -87
  55. package/src/api/exporters/html/htmlConversion.test.ts +19 -156
  56. package/src/api/exporters/html/internalHTMLSerializer.ts +21 -69
  57. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +263 -0
  58. package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +158 -0
  59. package/src/api/exporters/markdown/markdownExporter.test.ts +10 -10
  60. package/src/api/exporters/markdown/markdownExporter.ts +11 -7
  61. package/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.ts +2 -2
  62. package/src/api/getBlockInfoFromPos.ts +172 -90
  63. package/src/api/nodeConversions/blockToNode.ts +257 -0
  64. package/src/api/nodeConversions/fragmentToBlocks.ts +60 -0
  65. package/src/api/nodeConversions/nodeConversions.test.ts +9 -8
  66. package/src/api/nodeConversions/{nodeConversions.ts → nodeToBlock.ts} +20 -262
  67. package/src/api/parsers/html/parseHTML.test.ts +5 -8
  68. package/src/api/parsers/html/parseHTML.ts +8 -4
  69. package/src/api/parsers/html/util/nestedLists.test.ts +2 -2
  70. package/src/api/parsers/markdown/__snapshots__/pasted/complex.json +319 -0
  71. package/src/api/parsers/markdown/__snapshots__/pasted/issue-226-1.json +81 -0
  72. package/src/api/parsers/{html/__snapshots__/paste/parse-deep-nested-content.json → markdown/__snapshots__/pasted/issue-226-2.json} +35 -110
  73. package/src/api/parsers/markdown/__snapshots__/pasted/nested.json +81 -0
  74. package/src/api/parsers/markdown/__snapshots__/pasted/non-nested.json +81 -0
  75. package/src/api/parsers/markdown/__snapshots__/pasted/styled.json +61 -0
  76. package/src/api/parsers/markdown/parseMarkdown.test.ts +16 -1
  77. package/src/api/parsers/markdown/parseMarkdown.ts +8 -4
  78. package/src/api/testUtil/cases/customBlocks.ts +11 -11
  79. package/src/api/testUtil/cases/customInlineContent.ts +6 -6
  80. package/src/api/testUtil/cases/customStyles.ts +6 -6
  81. package/src/api/testUtil/cases/defaultSchema.ts +4 -4
  82. package/src/api/testUtil/index.ts +6 -6
  83. package/src/api/testUtil/partialBlockTestUtil.ts +5 -5
  84. package/src/api/testUtil/paste.ts +46 -0
  85. package/src/blocks/AudioBlockContent/AudioBlockContent.ts +5 -5
  86. package/src/blocks/FileBlockContent/FileBlockContent.ts +4 -4
  87. package/src/blocks/FileBlockContent/fileBlockHelpers.ts +2 -2
  88. package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +61 -39
  89. package/src/blocks/ImageBlockContent/ImageBlockContent.ts +5 -5
  90. package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +30 -18
  91. package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +67 -33
  92. package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +23 -19
  93. package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +22 -24
  94. package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +31 -19
  95. package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +16 -11
  96. package/src/blocks/TableBlockContent/TableBlockContent.ts +4 -5
  97. package/src/blocks/VideoBlockContent/VideoBlockContent.ts +5 -5
  98. package/src/blocks/defaultBlockHelpers.ts +4 -4
  99. package/src/blocks/defaultBlockTypeGuards.ts +5 -5
  100. package/src/blocks/defaultBlocks.ts +13 -13
  101. package/src/blocks/defaultProps.ts +1 -1
  102. package/src/editor/BlockNoteEditor.test.ts +14 -7
  103. package/src/editor/BlockNoteEditor.ts +82 -149
  104. package/src/editor/BlockNoteExtensions.ts +15 -11
  105. package/src/editor/BlockNoteSchema.ts +7 -7
  106. package/src/editor/BlockNoteTipTapEditor.ts +5 -3
  107. package/src/editor/cursorPositionTypes.ts +7 -2
  108. package/src/editor/selectionTypes.ts +6 -2
  109. package/src/editor/transformPasted.ts +34 -2
  110. package/src/extensions/BackgroundColor/BackgroundColorExtension.ts +1 -1
  111. package/src/extensions/BackgroundColor/BackgroundColorMark.ts +1 -1
  112. package/src/extensions/FilePanel/FilePanelPlugin.ts +4 -4
  113. package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +8 -4
  114. package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +333 -0
  115. package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +9 -4
  116. package/src/extensions/{NonEditableBlocks/NonEditableBlockPlugin.ts → NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.ts} +2 -2
  117. package/src/extensions/Placeholder/PlaceholderPlugin.ts +1 -1
  118. package/src/extensions/SideMenu/SideMenuPlugin.ts +72 -402
  119. package/src/extensions/SideMenu/dragging.ts +251 -0
  120. package/src/extensions/SuggestionMenu/DefaultSuggestionItem.ts +1 -1
  121. package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +8 -4
  122. package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +8 -4
  123. package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +19 -15
  124. package/src/extensions/TableHandles/TableHandlesPlugin.ts +11 -7
  125. package/src/extensions/TextColor/TextColorExtension.ts +1 -1
  126. package/src/extensions/TextColor/TextColorMark.ts +1 -1
  127. package/src/i18n/dictionary.ts +1 -1
  128. package/src/i18n/locales/ar.ts +1 -1
  129. package/src/i18n/locales/fr.ts +1 -1
  130. package/src/i18n/locales/hr.ts +308 -0
  131. package/src/i18n/locales/index.ts +15 -14
  132. package/src/i18n/locales/is.ts +1 -1
  133. package/src/i18n/locales/ja.ts +1 -1
  134. package/src/i18n/locales/ko.ts +1 -1
  135. package/src/i18n/locales/nl.ts +1 -1
  136. package/src/i18n/locales/pl.ts +1 -1
  137. package/src/i18n/locales/pt.ts +1 -1
  138. package/src/i18n/locales/ru.ts +1 -1
  139. package/src/i18n/locales/vi.ts +1 -1
  140. package/src/i18n/locales/zh.ts +1 -1
  141. package/src/index.ts +45 -44
  142. package/src/pm-nodes/BlockContainer.ts +3 -647
  143. package/src/pm-nodes/BlockGroup.ts +2 -2
  144. package/src/pm-nodes/index.ts +3 -3
  145. package/src/schema/blocks/createSpec.ts +24 -14
  146. package/src/schema/blocks/internal.ts +9 -9
  147. package/src/schema/blocks/types.ts +4 -4
  148. package/src/schema/index.ts +10 -10
  149. package/src/schema/inlineContent/createSpec.ts +9 -10
  150. package/src/schema/inlineContent/internal.ts +3 -3
  151. package/src/schema/inlineContent/types.ts +2 -2
  152. package/src/schema/styles/createSpec.ts +4 -3
  153. package/src/schema/styles/internal.ts +1 -1
  154. package/types/src/api/blockManipulation/commands/insertBlocks/insertBlocks.d.ts +4 -0
  155. package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.d.ts +7 -0
  156. package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.d.ts +1 -0
  157. package/types/src/api/blockManipulation/commands/moveBlock/moveBlock.d.ts +5 -0
  158. package/types/src/api/blockManipulation/commands/moveBlock/moveBlock.test.d.ts +1 -0
  159. package/types/src/api/blockManipulation/commands/removeBlocks/removeBlocks.d.ts +7 -0
  160. package/types/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.d.ts +1 -0
  161. package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.d.ts +7 -0
  162. package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.d.ts +1 -0
  163. package/types/src/api/blockManipulation/commands/splitBlock/splitBlock.d.ts +5 -0
  164. package/types/src/api/blockManipulation/commands/splitBlock/splitBlock.test.d.ts +1 -0
  165. package/types/src/api/blockManipulation/commands/updateBlock/updateBlock.d.ts +11 -0
  166. package/types/src/api/blockManipulation/commands/updateBlock/updateBlock.test.d.ts +1 -0
  167. package/types/src/api/blockManipulation/insertContentAt.d.ts +6 -0
  168. package/types/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.d.ts +5 -0
  169. package/types/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.d.ts +1 -0
  170. package/types/src/api/blockManipulation/setupTestEnv.d.ts +492 -0
  171. package/types/src/api/clipboard/clipboard.test.d.ts +1 -0
  172. package/types/src/api/clipboard/fromClipboard/fileDropExtension.d.ts +6 -0
  173. package/types/src/api/{parsers → clipboard/fromClipboard}/handleFileInsertion.d.ts +2 -2
  174. package/types/src/api/clipboard/fromClipboard/pasteExtension.d.ts +6 -0
  175. package/types/src/api/clipboard/toClipboard/copyExtension.d.ts +12 -0
  176. package/types/src/api/exporters/html/externalHTMLExporter.d.ts +7 -8
  177. package/types/src/api/exporters/html/internalHTMLSerializer.d.ts +6 -10
  178. package/types/src/api/exporters/html/util/serializeBlocksExternalHTML.d.ts +10 -0
  179. package/types/src/api/exporters/html/util/serializeBlocksInternalHTML.d.ts +11 -0
  180. package/types/src/api/exporters/markdown/markdownExporter.d.ts +3 -3
  181. package/types/src/api/getBlockInfoFromPos.d.ts +63 -20
  182. package/types/src/api/nodeConversions/blockToNode.d.ts +15 -0
  183. package/types/src/api/nodeConversions/fragmentToBlocks.d.ts +7 -0
  184. package/types/src/api/nodeConversions/nodeToBlock.d.ts +16 -0
  185. package/types/src/api/parsers/html/parseHTML.d.ts +2 -2
  186. package/types/src/api/parsers/markdown/parseMarkdown.d.ts +2 -2
  187. package/types/src/api/testUtil/cases/customBlocks.d.ts +39 -39
  188. package/types/src/api/testUtil/cases/customInlineContent.d.ts +35 -35
  189. package/types/src/api/testUtil/cases/customStyles.d.ts +35 -35
  190. package/types/src/api/testUtil/cases/defaultSchema.d.ts +2 -2
  191. package/types/src/api/testUtil/index.d.ts +6 -6
  192. package/types/src/api/testUtil/partialBlockTestUtil.d.ts +4 -4
  193. package/types/src/api/testUtil/paste.d.ts +2 -0
  194. package/types/src/blocks/AudioBlockContent/AudioBlockContent.d.ts +4 -4
  195. package/types/src/blocks/FileBlockContent/FileBlockContent.d.ts +4 -4
  196. package/types/src/blocks/FileBlockContent/fileBlockHelpers.d.ts +2 -2
  197. package/types/src/blocks/HeadingBlockContent/HeadingBlockContent.d.ts +2 -2
  198. package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +4 -4
  199. package/types/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.d.ts +2 -2
  200. package/types/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.d.ts +2 -2
  201. package/types/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.d.ts +2 -2
  202. package/types/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +2 -2
  203. package/types/src/blocks/ParagraphBlockContent/ParagraphBlockContent.d.ts +2 -2
  204. package/types/src/blocks/TableBlockContent/TableBlockContent.d.ts +2 -2
  205. package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +4 -4
  206. package/types/src/blocks/defaultBlockHelpers.d.ts +3 -3
  207. package/types/src/blocks/defaultBlockTypeGuards.d.ts +4 -4
  208. package/types/src/blocks/defaultBlocks.d.ts +38 -38
  209. package/types/src/blocks/defaultProps.d.ts +1 -1
  210. package/types/src/editor/BlockNoteEditor.d.ts +28 -16
  211. package/types/src/editor/BlockNoteExtensions.d.ts +3 -3
  212. package/types/src/editor/BlockNoteSchema.d.ts +4 -4
  213. package/types/src/editor/BlockNoteTipTapEditor.d.ts +2 -2
  214. package/types/src/editor/cursorPositionTypes.d.ts +3 -2
  215. package/types/src/editor/selectionTypes.d.ts +2 -2
  216. package/types/src/editor/transformPasted.d.ts +8 -1
  217. package/types/src/extensions/BackgroundColor/BackgroundColorMark.d.ts +1 -1
  218. package/types/src/extensions/FilePanel/FilePanelPlugin.d.ts +4 -4
  219. package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +4 -4
  220. package/types/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.d.ts +5 -0
  221. package/types/src/extensions/LinkToolbar/LinkToolbarPlugin.d.ts +4 -4
  222. package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.d.ts +2 -0
  223. package/types/src/extensions/Placeholder/PlaceholderPlugin.d.ts +1 -1
  224. package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +12 -28
  225. package/types/src/extensions/SideMenu/dragging.d.ts +17 -0
  226. package/types/src/extensions/SuggestionMenu/DefaultSuggestionItem.d.ts +1 -1
  227. package/types/src/extensions/SuggestionMenu/SuggestionPlugin.d.ts +4 -4
  228. package/types/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.d.ts +3 -3
  229. package/types/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.d.ts +4 -4
  230. package/types/src/extensions/TableHandles/TableHandlesPlugin.d.ts +4 -4
  231. package/types/src/extensions/TextColor/TextColorMark.d.ts +1 -1
  232. package/types/src/i18n/dictionary.d.ts +1 -1
  233. package/types/src/i18n/locales/ar.d.ts +1 -1
  234. package/types/src/i18n/locales/fr.d.ts +1 -1
  235. package/types/src/i18n/locales/hr.d.ts +239 -0
  236. package/types/src/i18n/locales/index.d.ts +15 -14
  237. package/types/src/i18n/locales/is.d.ts +1 -1
  238. package/types/src/i18n/locales/ja.d.ts +1 -1
  239. package/types/src/i18n/locales/ko.d.ts +1 -1
  240. package/types/src/i18n/locales/nl.d.ts +1 -1
  241. package/types/src/i18n/locales/pl.d.ts +1 -1
  242. package/types/src/i18n/locales/pt.d.ts +1 -1
  243. package/types/src/i18n/locales/ru.d.ts +1 -1
  244. package/types/src/i18n/locales/vi.d.ts +1 -1
  245. package/types/src/i18n/locales/zh.d.ts +1 -1
  246. package/types/src/index.d.ts +45 -44
  247. package/types/src/pm-nodes/BlockContainer.d.ts +2 -16
  248. package/types/src/pm-nodes/BlockGroup.d.ts +1 -1
  249. package/types/src/pm-nodes/index.d.ts +3 -3
  250. package/types/src/schema/blocks/createSpec.d.ts +5 -5
  251. package/types/src/schema/blocks/internal.d.ts +5 -5
  252. package/types/src/schema/blocks/types.d.ts +4 -4
  253. package/types/src/schema/index.d.ts +10 -10
  254. package/types/src/schema/inlineContent/createSpec.d.ts +3 -3
  255. package/types/src/schema/inlineContent/internal.d.ts +2 -2
  256. package/types/src/schema/inlineContent/types.d.ts +2 -2
  257. package/types/src/schema/styles/createSpec.d.ts +1 -1
  258. package/types/src/schema/styles/internal.d.ts +1 -1
  259. package/src/api/blockManipulation/__snapshots__/blockManipulation.test.ts.snap +0 -714
  260. package/src/api/blockManipulation/blockManipulation.test.ts +0 -292
  261. package/src/api/blockManipulation/blockManipulation.ts +0 -350
  262. package/src/api/exporters/copyExtension.ts +0 -164
  263. package/src/api/exporters/html/__snapshots_fragment_edge_cases__/selectionLeavesBlockChildren.html +0 -1
  264. package/src/api/exporters/html/__snapshots_fragment_edge_cases__/selectionSpansBlocksChildren.html +0 -1
  265. package/src/api/exporters/html/util/sharedHTMLConversion.ts +0 -130
  266. package/src/api/exporters/html/util/simplifyBlocksRehypePlugin.ts +0 -218
  267. package/src/api/getCurrentBlockContentType.ts +0 -14
  268. package/src/api/parsers/html/__snapshots__/paste/parse-google-docs-html.json +0 -476
  269. package/types/src/api/blockManipulation/blockManipulation.d.ts +0 -14
  270. package/types/src/api/exporters/copyExtension.d.ts +0 -6
  271. package/types/src/api/exporters/html/util/sharedHTMLConversion.d.ts +0 -9
  272. package/types/src/api/exporters/html/util/simplifyBlocksRehypePlugin.d.ts +0 -16
  273. package/types/src/api/getCurrentBlockContentType.d.ts +0 -2
  274. package/types/src/api/nodeConversions/nodeConversions.d.ts +0 -24
  275. package/types/src/api/parsers/fileDropExtension.d.ts +0 -6
  276. package/types/src/api/parsers/pasteExtension.d.ts +0 -6
  277. package/types/src/extensions/NonEditableBlocks/NonEditableBlockPlugin.d.ts +0 -2
  278. /package/src/api/{exporters/html/__snapshots_fragment_edge_cases__/selectionWithinBlockChildren.html → clipboard/__snapshots__/multipleChildren.html} +0 -0
  279. /package/src/api/{parsers → clipboard/fromClipboard}/acceptedMIMETypes.ts +0 -0
  280. /package/src/api/parsers/html/__snapshots__/{paste/list-test.json → list-test.json} +0 -0
  281. /package/src/api/parsers/html/__snapshots__/{paste/parse-basic-block-types.json → parse-basic-block-types.json} +0 -0
  282. /package/src/api/parsers/html/__snapshots__/{paste/parse-div-with-inline-content.json → parse-div-with-inline-content.json} +0 -0
  283. /package/src/api/parsers/html/__snapshots__/{paste/parse-divs.json → parse-divs.json} +0 -0
  284. /package/src/api/parsers/html/__snapshots__/{paste/parse-fake-image-caption.json → parse-fake-image-caption.json} +0 -0
  285. /package/src/api/parsers/html/__snapshots__/{paste/parse-image-in-paragraph.json → parse-image-in-paragraph.json} +0 -0
  286. /package/src/api/parsers/html/__snapshots__/{paste/parse-mixed-nested-lists.json → parse-mixed-nested-lists.json} +0 -0
  287. /package/src/api/parsers/html/__snapshots__/{paste/parse-nested-lists-with-paragraphs.json → parse-nested-lists-with-paragraphs.json} +0 -0
  288. /package/src/api/parsers/html/__snapshots__/{paste/parse-nested-lists.json → parse-nested-lists.json} +0 -0
  289. /package/src/api/parsers/html/__snapshots__/{paste/parse-notion-html.json → parse-notion-html.json} +0 -0
  290. /package/src/api/parsers/html/__snapshots__/{paste/parse-two-divs.json → parse-two-divs.json} +0 -0
  291. /package/types/src/api/blockManipulation/{blockManipulation.test.d.ts → commands/insertBlocks/insertBlocks.test.d.ts} +0 -0
  292. /package/types/src/api/{parsers → clipboard/fromClipboard}/acceptedMIMETypes.d.ts +0 -0
@@ -1,22 +1,22 @@
1
1
  import { Editor } from "@tiptap/core";
2
2
  import { TagParseRule } from "@tiptap/pm/model";
3
3
  import { NodeView } from "@tiptap/pm/view";
4
- import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
5
- import { InlineContentSchema } from "../inlineContent/types";
6
- import { StyleSchema } from "../styles/types";
4
+ import type { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
5
+ import { InlineContentSchema } from "../inlineContent/types.js";
6
+ import { StyleSchema } from "../styles/types.js";
7
7
  import {
8
8
  createInternalBlockSpec,
9
9
  createStronglyTypedTiptapNode,
10
10
  getBlockFromPos,
11
11
  propsToAttributes,
12
12
  wrapInBlockStructure,
13
- } from "./internal";
13
+ } from "./internal.js";
14
14
  import {
15
15
  BlockConfig,
16
16
  BlockFromConfig,
17
17
  BlockSchemaWithBlock,
18
18
  PartialBlockFromConfig,
19
- } from "./types";
19
+ } from "./types.js";
20
20
 
21
21
  // restrict content to "inline" and "none" only
22
22
  export type CustomBlockConfig = BlockConfig & {
@@ -154,15 +154,24 @@ export function createBlockSpec<
154
154
  return getParseRules(blockConfig, blockImplementation.parse);
155
155
  },
156
156
 
157
- renderHTML() {
158
- // renderHTML is not really used, as we always use a nodeView, and we use toExternalHTML / toInternalHTML for serialization
159
- // There's an edge case when this gets called nevertheless; before the nodeviews have been mounted
160
- // this is why we implement it with a temporary placeholder
157
+ renderHTML({ HTMLAttributes }) {
158
+ // renderHTML is used for copy/pasting content from the editor back into
159
+ // the editor, so we need to make sure the `blockContent` element is
160
+ // structured correctly as this is what's used for parsing blocks. We
161
+ // just render a placeholder div inside as the `blockContent` element
162
+ // already has all the information needed for proper parsing.
161
163
  const div = document.createElement("div");
162
- div.setAttribute("data-tmp-placeholder", "true");
163
- return {
164
- dom: div,
165
- };
164
+ return wrapInBlockStructure(
165
+ {
166
+ dom: div,
167
+ contentDOM: blockConfig.content === "inline" ? div : undefined,
168
+ },
169
+ blockConfig.type,
170
+ {},
171
+ blockConfig.propSchema,
172
+ blockConfig.isFileBlock,
173
+ HTMLAttributes
174
+ );
166
175
  },
167
176
 
168
177
  addNodeView() {
@@ -222,6 +231,8 @@ export function createBlockSpec<
222
231
  blockContentDOMAttributes
223
232
  );
224
233
  },
234
+ // TODO: this should not have wrapInBlockStructure and generally be a lot simpler
235
+ // post-processing in externalHTMLExporter should not be necessary
225
236
  toExternalHTML: (block, editor) => {
226
237
  const blockContentDOMAttributes =
227
238
  node.options.domAttributes?.blockContent || {};
@@ -233,7 +244,6 @@ export function createBlockSpec<
233
244
  if (output === undefined) {
234
245
  output = blockImplementation.render(block as any, editor as any);
235
246
  }
236
-
237
247
  return wrapInBlockStructure(
238
248
  output,
239
249
  block.type,
@@ -6,14 +6,14 @@ import {
6
6
  Node,
7
7
  NodeConfig,
8
8
  } from "@tiptap/core";
9
- import { defaultBlockToHTML } from "../../blocks/defaultBlockHelpers";
10
- import { inheritedProps } from "../../blocks/defaultProps";
11
- import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
12
- import { mergeCSSClasses } from "../../util/browser";
13
- import { camelToDataKebab } from "../../util/string";
14
- import { InlineContentSchema } from "../inlineContent/types";
15
- import { PropSchema, Props } from "../propTypes";
16
- import { StyleSchema } from "../styles/types";
9
+ import { defaultBlockToHTML } from "../../blocks/defaultBlockHelpers.js";
10
+ import { inheritedProps } from "../../blocks/defaultProps.js";
11
+ import type { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
12
+ import { mergeCSSClasses } from "../../util/browser.js";
13
+ import { camelToDataKebab } from "../../util/string.js";
14
+ import { InlineContentSchema } from "../inlineContent/types.js";
15
+ import { PropSchema, Props } from "../propTypes.js";
16
+ import { StyleSchema } from "../styles/types.js";
17
17
  import {
18
18
  BlockConfig,
19
19
  BlockSchemaFromSpecs,
@@ -22,7 +22,7 @@ import {
22
22
  BlockSpecs,
23
23
  SpecificBlock,
24
24
  TiptapBlockImplementation,
25
- } from "./types";
25
+ } from "./types.js";
26
26
 
27
27
  // Function that uses the 'propSchema' of a blockConfig to create a TipTap
28
28
  // node's `addAttributes` property.
@@ -1,14 +1,14 @@
1
1
  /** Define the main block types **/
2
2
  import type { Extension, Node } from "@tiptap/core";
3
3
 
4
- import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
4
+ import type { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
5
5
  import type {
6
6
  InlineContent,
7
7
  InlineContentSchema,
8
8
  PartialInlineContent,
9
- } from "../inlineContent/types";
10
- import type { PropSchema, Props } from "../propTypes";
11
- import type { StyleSchema } from "../styles/types";
9
+ } from "../inlineContent/types.js";
10
+ import type { PropSchema, Props } from "../propTypes.js";
11
+ import type { StyleSchema } from "../styles/types.js";
12
12
 
13
13
  export type BlockNoteDOMElement =
14
14
  | "editor"
@@ -1,10 +1,10 @@
1
- export * from "./blocks/createSpec";
2
- export * from "./blocks/internal";
3
- export * from "./blocks/types";
4
- export * from "./inlineContent/createSpec";
5
- export * from "./inlineContent/internal";
6
- export * from "./inlineContent/types";
7
- export * from "./propTypes";
8
- export * from "./styles/createSpec";
9
- export * from "./styles/internal";
10
- export * from "./styles/types";
1
+ export * from "./blocks/createSpec.js";
2
+ export * from "./blocks/internal.js";
3
+ export * from "./blocks/types.js";
4
+ export * from "./inlineContent/createSpec.js";
5
+ export * from "./inlineContent/internal.js";
6
+ export * from "./inlineContent/types.js";
7
+ export * from "./propTypes.js";
8
+ export * from "./styles/createSpec.js";
9
+ export * from "./styles/internal.js";
10
+ export * from "./styles/types.js";
@@ -1,24 +1,23 @@
1
1
  import { Node } from "@tiptap/core";
2
+
2
3
  import { TagParseRule } from "@tiptap/pm/model";
3
- import {
4
- inlineContentToNodes,
5
- nodeToCustomInlineContent,
6
- } from "../../api/nodeConversions/nodeConversions";
7
- import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
8
- import { propsToAttributes } from "../blocks/internal";
9
- import { Props } from "../propTypes";
10
- import { StyleSchema } from "../styles/types";
4
+ import { inlineContentToNodes } from "../../api/nodeConversions/blockToNode.js";
5
+ import { nodeToCustomInlineContent } from "../../api/nodeConversions/nodeToBlock.js";
6
+ import type { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
7
+ import { propsToAttributes } from "../blocks/internal.js";
8
+ import { Props } from "../propTypes.js";
9
+ import { StyleSchema } from "../styles/types.js";
11
10
  import {
12
11
  addInlineContentAttributes,
13
12
  addInlineContentKeyboardShortcuts,
14
13
  createInlineContentSpecFromTipTapNode,
15
- } from "./internal";
14
+ } from "./internal.js";
16
15
  import {
17
16
  CustomInlineContentConfig,
18
17
  InlineContentFromConfig,
19
18
  InlineContentSpec,
20
19
  PartialCustomInlineContentFromConfig,
21
- } from "./types";
20
+ } from "./types.js";
22
21
 
23
22
  // TODO: support serialization
24
23
 
@@ -1,7 +1,7 @@
1
1
  import { KeyboardShortcutCommand, Node } from "@tiptap/core";
2
2
 
3
- import { camelToDataKebab } from "../../util/string";
4
- import { PropSchema, Props } from "../propTypes";
3
+ import { camelToDataKebab } from "../../util/string.js";
4
+ import { PropSchema, Props } from "../propTypes.js";
5
5
  import {
6
6
  CustomInlineContentConfig,
7
7
  InlineContentConfig,
@@ -9,7 +9,7 @@ import {
9
9
  InlineContentSchemaFromSpecs,
10
10
  InlineContentSpec,
11
11
  InlineContentSpecs,
12
- } from "./types";
12
+ } from "./types.js";
13
13
 
14
14
  // Function that adds necessary classes and attributes to the `dom` element
15
15
  // returned from a custom inline content's 'render' function, to ensure no data
@@ -1,6 +1,6 @@
1
1
  import { Node } from "@tiptap/core";
2
- import { PropSchema, Props } from "../propTypes";
3
- import { StyleSchema, Styles } from "../styles/types";
2
+ import { PropSchema, Props } from "../propTypes.js";
3
+ import { StyleSchema, Styles } from "../styles/types.js";
4
4
 
5
5
  export type CustomInlineContentConfig = {
6
6
  type: string;
@@ -1,12 +1,13 @@
1
1
  import { Mark } from "@tiptap/core";
2
+
2
3
  import { ParseRule } from "@tiptap/pm/model";
4
+ import { UnreachableCaseError } from "../../util/typescript.js";
3
5
  import {
4
6
  addStyleAttributes,
5
7
  createInternalStyleSpec,
6
8
  stylePropsToAttributes,
7
- } from "./internal";
8
- import { StyleConfig, StyleSpec } from "./types";
9
- import {UnreachableCaseError} from "../../util/typescript";
9
+ } from "./internal.js";
10
+ import { StyleConfig, StyleSpec } from "./types.js";
10
11
 
11
12
  export type CustomStyleImplementation<T extends StyleConfig> = {
12
13
  render: T["propSchema"] extends "boolean"
@@ -6,7 +6,7 @@ import {
6
6
  StyleSchemaFromSpecs,
7
7
  StyleSpec,
8
8
  StyleSpecs,
9
- } from "./types";
9
+ } from "./types.js";
10
10
 
11
11
  export function stylePropsToAttributes(
12
12
  propSchema: StylePropSchema
@@ -0,0 +1,4 @@
1
+ import { Block, PartialBlock } from "../../../../blocks/defaultBlocks.js";
2
+ import type { BlockNoteEditor } from "../../../../editor/BlockNoteEditor";
3
+ import { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../../../schema/index.js";
4
+ export declare function insertBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(editor: BlockNoteEditor<BSchema, I, S>, blocksToInsert: PartialBlock<BSchema, I, S>[], referenceBlock: BlockIdentifier, placement?: "before" | "after"): Block<BSchema, I, S>[];
@@ -0,0 +1,7 @@
1
+ import { Node, ResolvedPos } from "prosemirror-model";
2
+ import { EditorState } from "prosemirror-state";
3
+ export declare const getPrevBlockPos: (doc: Node, $nextBlockPos: ResolvedPos) => ResolvedPos;
4
+ export declare const mergeBlocksCommand: (posBetweenBlocks: number) => ({ state, dispatch, }: {
5
+ state: EditorState;
6
+ dispatch: ((args?: any) => any) | undefined;
7
+ }) => boolean;
@@ -0,0 +1,5 @@
1
+ import type { BlockNoteEditor } from "../../../../editor/BlockNoteEditor";
2
+ import { BlockIdentifier } from "../../../../schema/index.js";
3
+ export declare function moveSelectedBlockAndSelection(editor: BlockNoteEditor<any, any, any>, referenceBlock: BlockIdentifier, placement: "before" | "after"): void;
4
+ export declare function moveBlockUp(editor: BlockNoteEditor<any, any, any>): void;
5
+ export declare function moveBlockDown(editor: BlockNoteEditor<any, any, any>): void;
@@ -0,0 +1,7 @@
1
+ import { Node } from "prosemirror-model";
2
+ import { Transaction } from "prosemirror-state";
3
+ import { Block } from "../../../../blocks/defaultBlocks.js";
4
+ import type { BlockNoteEditor } from "../../../../editor/BlockNoteEditor";
5
+ import { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../../../schema/index.js";
6
+ export declare function removeBlocksWithCallback<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(editor: BlockNoteEditor<BSchema, I, S>, blocksToRemove: BlockIdentifier[], callback?: (node: Node, pos: number, tr: Transaction, removedSize: number) => number): Block<BSchema, I, S>[];
7
+ export declare function removeBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(editor: BlockNoteEditor<BSchema, I, S>, blocksToRemove: BlockIdentifier[]): Block<BSchema, I, S>[];
@@ -0,0 +1,7 @@
1
+ import { Block, PartialBlock } from "../../../../blocks/defaultBlocks.js";
2
+ import type { BlockNoteEditor } from "../../../../editor/BlockNoteEditor";
3
+ import { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../../../schema/index.js";
4
+ export declare function replaceBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(editor: BlockNoteEditor<BSchema, I, S>, blocksToRemove: BlockIdentifier[], blocksToInsert: PartialBlock<BSchema, I, S>[]): {
5
+ insertedBlocks: Block<BSchema, I, S>[];
6
+ removedBlocks: Block<BSchema, I, S>[];
7
+ };
@@ -0,0 +1,5 @@
1
+ import { EditorState } from "prosemirror-state";
2
+ export declare const splitBlockCommand: (posInBlock: number, keepType?: boolean, keepProps?: boolean) => ({ state, dispatch, }: {
3
+ state: EditorState;
4
+ dispatch: ((args?: any) => any) | undefined;
5
+ }) => boolean;
@@ -0,0 +1,11 @@
1
+ import { EditorState } from "prosemirror-state";
2
+ import { Block, PartialBlock } from "../../../../blocks/defaultBlocks.js";
3
+ import { BlockNoteEditor } from "../../../../editor/BlockNoteEditor.js";
4
+ import { BlockIdentifier, BlockSchema } from "../../../../schema/blocks/types.js";
5
+ import { InlineContentSchema } from "../../../../schema/inlineContent/types.js";
6
+ import { StyleSchema } from "../../../../schema/styles/types.js";
7
+ export declare const updateBlockCommand: <BSchema extends Record<string, import("../../../../schema/blocks/types.js").BlockConfig>, I extends InlineContentSchema, S extends StyleSchema>(editor: BlockNoteEditor<BSchema, I, S>, posBeforeBlock: number, block: PartialBlock<BSchema, I, S>) => ({ state, dispatch, }: {
8
+ state: EditorState;
9
+ dispatch: ((args?: any) => any) | undefined;
10
+ }) => boolean;
11
+ export declare function updateBlock<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(editor: BlockNoteEditor<BSchema, I, S>, blockToUpdate: BlockIdentifier, update: PartialBlock<BSchema, I, S>): Block<BSchema, I, S>;
@@ -0,0 +1,6 @@
1
+ import { Node } from "prosemirror-model";
2
+ import type { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
3
+ import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema/index.js";
4
+ export declare function insertContentAt<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(position: any, nodes: Node[], editor: BlockNoteEditor<BSchema, I, S>, options?: {
5
+ updateSelection: boolean;
6
+ }): boolean;
@@ -0,0 +1,5 @@
1
+ import type { BlockNoteEditor } from "../../../../editor/BlockNoteEditor.js";
2
+ import { TextCursorPosition } from "../../../../editor/cursorPositionTypes.js";
3
+ import { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../../../schema/index.js";
4
+ export declare function getTextCursorPosition<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(editor: BlockNoteEditor<BSchema, I, S>): TextCursorPosition<BSchema, I, S>;
5
+ export declare function setTextCursorPosition<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(editor: BlockNoteEditor<BSchema, I, S>, targetBlock: BlockIdentifier, placement?: "start" | "end"): void;