@blocknote/core 0.9.6 → 0.10.1

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 (347) hide show
  1. package/dist/blocknote.js +3696 -2609
  2. package/dist/blocknote.js.map +1 -1
  3. package/dist/blocknote.umd.cjs +7 -7
  4. package/dist/blocknote.umd.cjs.map +1 -1
  5. package/dist/style.css +1 -1
  6. package/dist/webpack-stats.json +1 -0
  7. package/package.json +11 -5
  8. package/src/api/README.md +8 -0
  9. package/src/api/blockManipulation/blockManipulation.test.ts +72 -10
  10. package/src/api/blockManipulation/blockManipulation.ts +38 -18
  11. package/src/api/exporters/copyExtension.ts +68 -0
  12. package/src/api/exporters/html/__snapshots__/complex/misc/external.html +1 -0
  13. package/src/api/exporters/html/__snapshots__/complex/misc/internal.html +1 -0
  14. package/src/api/exporters/html/__snapshots__/customParagraph/basic/external.html +1 -0
  15. package/src/api/exporters/html/__snapshots__/customParagraph/basic/internal.html +1 -0
  16. package/src/api/exporters/html/__snapshots__/customParagraph/nested/external.html +1 -0
  17. package/src/api/exporters/html/__snapshots__/customParagraph/nested/internal.html +1 -0
  18. package/src/api/exporters/html/__snapshots__/customParagraph/styled/external.html +1 -0
  19. package/src/api/exporters/html/__snapshots__/customParagraph/styled/internal.html +1 -0
  20. package/src/api/exporters/html/__snapshots__/fontSize/basic/external.html +1 -0
  21. package/src/api/exporters/html/__snapshots__/fontSize/basic/internal.html +1 -0
  22. package/src/api/exporters/html/__snapshots__/hardbreak/basic/external.html +1 -0
  23. package/src/api/exporters/html/__snapshots__/hardbreak/basic/internal.html +1 -0
  24. package/src/api/exporters/html/__snapshots__/hardbreak/between-links/external.html +1 -0
  25. package/src/api/exporters/html/__snapshots__/hardbreak/between-links/internal.html +1 -0
  26. package/src/api/exporters/html/__snapshots__/hardbreak/end/external.html +1 -0
  27. package/src/api/exporters/html/__snapshots__/hardbreak/end/internal.html +1 -0
  28. package/src/api/exporters/html/__snapshots__/hardbreak/link/external.html +1 -0
  29. package/src/api/exporters/html/__snapshots__/hardbreak/link/internal.html +1 -0
  30. package/src/api/exporters/html/__snapshots__/hardbreak/multiple/external.html +1 -0
  31. package/src/api/exporters/html/__snapshots__/hardbreak/multiple/internal.html +1 -0
  32. package/src/api/exporters/html/__snapshots__/hardbreak/only/external.html +1 -0
  33. package/src/api/exporters/html/__snapshots__/hardbreak/only/internal.html +1 -0
  34. package/src/api/exporters/html/__snapshots__/hardbreak/start/external.html +1 -0
  35. package/src/api/exporters/html/__snapshots__/hardbreak/start/internal.html +1 -0
  36. package/src/api/exporters/html/__snapshots__/hardbreak/styles/external.html +1 -0
  37. package/src/api/exporters/html/__snapshots__/hardbreak/styles/internal.html +1 -0
  38. package/src/api/exporters/html/__snapshots__/image/basic/external.html +1 -0
  39. package/src/api/exporters/html/__snapshots__/image/basic/internal.html +1 -0
  40. package/src/api/exporters/html/__snapshots__/image/button/external.html +1 -0
  41. package/src/api/exporters/html/__snapshots__/image/button/internal.html +1 -0
  42. package/src/api/exporters/html/__snapshots__/image/nested/external.html +1 -0
  43. package/src/api/exporters/html/__snapshots__/image/nested/internal.html +1 -0
  44. package/src/api/exporters/html/__snapshots__/link/adjacent/external.html +1 -0
  45. package/src/api/exporters/html/__snapshots__/link/adjacent/internal.html +1 -0
  46. package/src/api/exporters/html/__snapshots__/link/basic/external.html +1 -0
  47. package/src/api/exporters/html/__snapshots__/link/basic/internal.html +1 -0
  48. package/src/api/exporters/html/__snapshots__/link/styled/external.html +1 -0
  49. package/src/api/exporters/html/__snapshots__/link/styled/internal.html +1 -0
  50. package/src/api/exporters/html/__snapshots__/mention/basic/external.html +1 -0
  51. package/src/api/exporters/html/__snapshots__/mention/basic/internal.html +1 -0
  52. package/src/api/exporters/html/__snapshots__/paragraph/basic/external.html +1 -0
  53. package/src/api/exporters/html/__snapshots__/paragraph/basic/internal.html +1 -0
  54. package/src/api/exporters/html/__snapshots__/paragraph/empty/external.html +1 -0
  55. package/src/api/exporters/html/__snapshots__/paragraph/empty/internal.html +1 -0
  56. package/src/api/exporters/html/__snapshots__/paragraph/nested/external.html +1 -0
  57. package/src/api/exporters/html/__snapshots__/paragraph/nested/internal.html +1 -0
  58. package/src/api/exporters/html/__snapshots__/paragraph/styled/external.html +1 -0
  59. package/src/api/exporters/html/__snapshots__/paragraph/styled/internal.html +1 -0
  60. package/src/api/exporters/html/__snapshots__/paste/parse-basic-block-types.json +140 -0
  61. package/src/api/exporters/html/__snapshots__/paste/parse-deep-nested-content.json +240 -0
  62. package/src/api/exporters/html/__snapshots__/paste/parse-div-with-inline-content.json +91 -0
  63. package/src/api/exporters/html/__snapshots__/paste/parse-divs.json +19 -0
  64. package/src/api/exporters/html/__snapshots__/paste/parse-fake-image-caption.json +31 -0
  65. package/src/api/exporters/html/__snapshots__/paste/parse-mixed-nested-lists.json +70 -0
  66. package/src/api/exporters/html/__snapshots__/paste/parse-nested-lists-with-paragraphs.json +70 -0
  67. package/src/api/exporters/html/__snapshots__/paste/parse-nested-lists.json +70 -0
  68. package/src/api/exporters/html/__snapshots__/simpleCustomParagraph/basic/external.html +1 -0
  69. package/src/api/exporters/html/__snapshots__/simpleCustomParagraph/basic/internal.html +1 -0
  70. package/src/api/exporters/html/__snapshots__/simpleCustomParagraph/nested/external.html +1 -0
  71. package/src/api/exporters/html/__snapshots__/simpleCustomParagraph/nested/internal.html +1 -0
  72. package/src/api/exporters/html/__snapshots__/simpleCustomParagraph/styled/external.html +1 -0
  73. package/src/api/exporters/html/__snapshots__/simpleCustomParagraph/styled/internal.html +1 -0
  74. package/src/api/exporters/html/__snapshots__/simpleImage/basic/external.html +1 -0
  75. package/src/api/exporters/html/__snapshots__/simpleImage/basic/internal.html +1 -0
  76. package/src/api/exporters/html/__snapshots__/simpleImage/button/external.html +1 -0
  77. package/src/api/exporters/html/__snapshots__/simpleImage/button/internal.html +1 -0
  78. package/src/api/exporters/html/__snapshots__/simpleImage/nested/external.html +1 -0
  79. package/src/api/exporters/html/__snapshots__/simpleImage/nested/internal.html +1 -0
  80. package/src/api/exporters/html/__snapshots__/small/basic/external.html +1 -0
  81. package/src/api/exporters/html/__snapshots__/small/basic/internal.html +1 -0
  82. package/src/api/exporters/html/__snapshots__/tag/basic/external.html +1 -0
  83. package/src/api/exporters/html/__snapshots__/tag/basic/internal.html +1 -0
  84. package/src/api/exporters/html/externalHTMLExporter.ts +98 -0
  85. package/src/api/exporters/html/htmlConversion.test.ts +100 -0
  86. package/src/api/exporters/html/internalHTMLSerializer.ts +80 -0
  87. package/src/api/exporters/html/util/sharedHTMLConversion.ts +128 -0
  88. package/src/api/{formatConversions → exporters/html/util}/simplifyBlocksRehypePlugin.ts +13 -0
  89. package/src/api/exporters/markdown/__snapshots__/complex/misc/markdown.md +5 -0
  90. package/src/api/exporters/markdown/__snapshots__/customParagraph/basic/markdown.md +1 -0
  91. package/src/api/exporters/markdown/__snapshots__/customParagraph/nested/markdown.md +5 -0
  92. package/src/api/exporters/markdown/__snapshots__/customParagraph/styled/markdown.md +1 -0
  93. package/src/api/exporters/markdown/__snapshots__/fontSize/basic/markdown.md +1 -0
  94. package/src/api/exporters/markdown/__snapshots__/hardbreak/basic/markdown.md +2 -0
  95. package/src/api/exporters/markdown/__snapshots__/hardbreak/between-links/markdown.md +2 -0
  96. package/src/api/exporters/markdown/__snapshots__/hardbreak/end/markdown.md +1 -0
  97. package/src/api/exporters/markdown/__snapshots__/hardbreak/link/markdown.md +2 -0
  98. package/src/api/exporters/markdown/__snapshots__/hardbreak/multiple/markdown.md +3 -0
  99. package/src/api/exporters/markdown/__snapshots__/hardbreak/start/markdown.md +1 -0
  100. package/src/api/exporters/markdown/__snapshots__/hardbreak/styles/markdown.md +2 -0
  101. package/src/api/exporters/markdown/__snapshots__/image/basic/markdown.md +3 -0
  102. package/src/api/exporters/markdown/__snapshots__/image/button/markdown.md +1 -0
  103. package/src/api/exporters/markdown/__snapshots__/image/nested/markdown.md +7 -0
  104. package/src/api/exporters/markdown/__snapshots__/link/adjacent/markdown.md +1 -0
  105. package/src/api/exporters/markdown/__snapshots__/link/basic/markdown.md +1 -0
  106. package/src/api/exporters/markdown/__snapshots__/link/styled/markdown.md +1 -0
  107. package/src/api/exporters/markdown/__snapshots__/mention/basic/markdown.md +1 -0
  108. package/src/api/exporters/markdown/__snapshots__/paragraph/basic/markdown.md +1 -0
  109. package/src/api/exporters/markdown/__snapshots__/paragraph/nested/markdown.md +5 -0
  110. package/src/api/exporters/markdown/__snapshots__/paragraph/styled/markdown.md +1 -0
  111. package/src/api/exporters/markdown/__snapshots__/simpleCustomParagraph/basic/markdown.md +1 -0
  112. package/src/api/exporters/markdown/__snapshots__/simpleCustomParagraph/nested/markdown.md +5 -0
  113. package/src/api/exporters/markdown/__snapshots__/simpleCustomParagraph/styled/markdown.md +1 -0
  114. package/src/api/exporters/markdown/__snapshots__/simpleImage/basic/markdown.md +1 -0
  115. package/src/api/exporters/markdown/__snapshots__/simpleImage/button/markdown.md +1 -0
  116. package/src/api/exporters/markdown/__snapshots__/simpleImage/nested/markdown.md +3 -0
  117. package/src/api/exporters/markdown/__snapshots__/small/basic/markdown.md +1 -0
  118. package/src/api/exporters/markdown/__snapshots__/tag/basic/markdown.md +1 -0
  119. package/src/api/exporters/markdown/markdownExporter.test.ts +85 -0
  120. package/src/api/exporters/markdown/markdownExporter.ts +42 -0
  121. package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +486 -125
  122. package/src/api/nodeConversions/nodeConversions.test.ts +67 -498
  123. package/src/api/nodeConversions/nodeConversions.ts +311 -85
  124. package/src/api/parsers/html/__snapshots__/paste/list-test.json +105 -0
  125. package/src/api/parsers/html/__snapshots__/paste/parse-basic-block-types.json +140 -0
  126. package/src/api/parsers/html/__snapshots__/paste/parse-deep-nested-content.json +240 -0
  127. package/src/api/parsers/html/__snapshots__/paste/parse-div-with-inline-content.json +91 -0
  128. package/src/api/parsers/html/__snapshots__/paste/parse-divs.json +121 -0
  129. package/src/api/parsers/html/__snapshots__/paste/parse-fake-image-caption.json +31 -0
  130. package/src/api/parsers/html/__snapshots__/paste/parse-google-docs-html.json +476 -0
  131. package/src/api/parsers/html/__snapshots__/paste/parse-mixed-nested-lists.json +140 -0
  132. package/src/api/parsers/html/__snapshots__/paste/parse-nested-lists-with-paragraphs.json +140 -0
  133. package/src/api/parsers/html/__snapshots__/paste/parse-nested-lists.json +157 -0
  134. package/src/api/parsers/html/__snapshots__/paste/parse-notion-html.json +470 -0
  135. package/src/api/parsers/html/__snapshots__/paste/parse-two-divs.json +36 -0
  136. package/src/api/parsers/html/parseHTML.test.ts +440 -0
  137. package/src/api/parsers/html/parseHTML.ts +42 -0
  138. package/src/api/parsers/html/util/__snapshots__/nestedLists.test.ts.snap +129 -0
  139. package/src/api/parsers/html/util/nestedLists.test.ts +176 -0
  140. package/src/api/parsers/html/util/nestedLists.ts +113 -0
  141. package/src/api/parsers/markdown/__snapshots__/complex.json +353 -0
  142. package/src/api/parsers/markdown/__snapshots__/issue-226-1.json +71 -0
  143. package/src/api/parsers/markdown/__snapshots__/issue-226-2.json +144 -0
  144. package/src/api/parsers/markdown/__snapshots__/nested.json +72 -0
  145. package/src/api/parsers/markdown/__snapshots__/non-nested.json +71 -0
  146. package/src/api/parsers/markdown/__snapshots__/styled.json +58 -0
  147. package/src/api/parsers/markdown/parseMarkdown.test.ts +114 -0
  148. package/src/api/parsers/markdown/parseMarkdown.ts +84 -0
  149. package/src/api/parsers/pasteExtension.ts +59 -0
  150. package/src/api/testUtil/cases/customBlocks.ts +282 -0
  151. package/src/api/testUtil/cases/customInlineContent.ts +114 -0
  152. package/src/api/testUtil/cases/customStyles.ts +100 -0
  153. package/src/api/testUtil/cases/defaultSchema.ts +399 -0
  154. package/src/api/testUtil/index.ts +17 -0
  155. package/src/api/testUtil/partialBlockTestUtil.ts +127 -0
  156. package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +136 -0
  157. package/src/{extensions/Blocks/nodes/BlockContent → blocks}/ImageBlockContent/ImageBlockContent.ts +87 -31
  158. package/src/{extensions/Blocks/nodes/BlockContent → blocks}/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +34 -47
  159. package/src/{extensions/Blocks/nodes/BlockContent → blocks}/ListItemBlockContent/ListItemKeyboardShortcuts.ts +1 -1
  160. package/src/{extensions/Blocks/nodes/BlockContent → blocks}/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +1 -1
  161. package/src/{extensions/Blocks/nodes/BlockContent → blocks}/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +34 -56
  162. package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +43 -0
  163. package/src/blocks/README.md +3 -0
  164. package/src/blocks/TableBlockContent/TableBlockContent.ts +74 -0
  165. package/src/blocks/TableBlockContent/TableExtension.ts +63 -0
  166. package/src/blocks/defaultBlockHelpers.ts +95 -0
  167. package/src/blocks/defaultBlocks.ts +60 -0
  168. package/src/blocks/defaultProps.ts +24 -0
  169. package/src/{extensions/Blocks/nodes/Block.module.css → editor/Block.css} +69 -62
  170. package/src/{BlockNoteEditor.test.ts → editor/BlockNoteEditor.test.ts} +2 -2
  171. package/src/{BlockNoteEditor.ts → editor/BlockNoteEditor.ts} +363 -153
  172. package/src/{BlockNoteExtensions.ts → editor/BlockNoteExtensions.ts} +59 -40
  173. package/src/editor/README.md +3 -0
  174. package/src/editor/cursorPositionTypes.ts +16 -0
  175. package/src/{editor.module.css → editor/editor.css} +43 -15
  176. package/src/editor/selectionTypes.ts +14 -0
  177. package/src/editor/transformPasted.ts +58 -0
  178. package/src/extensions/BackgroundColor/BackgroundColorExtension.ts +1 -36
  179. package/src/extensions/BackgroundColor/BackgroundColorMark.ts +12 -27
  180. package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +16 -24
  181. package/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.ts +12 -10
  182. package/src/extensions/ImageToolbar/ImageToolbarPlugin.ts +35 -73
  183. package/src/extensions/Placeholder/PlaceholderExtension.ts +4 -4
  184. package/src/extensions/README.md +3 -0
  185. package/src/extensions/SideMenu/SideMenuPlugin.ts +66 -37
  186. package/src/extensions/SlashMenu/BaseSlashMenuItem.ts +7 -6
  187. package/src/extensions/SlashMenu/SlashMenuPlugin.ts +9 -7
  188. package/src/extensions/SlashMenu/defaultSlashMenuItems.ts +98 -35
  189. package/src/extensions/TableHandles/TableHandlesPlugin.ts +617 -0
  190. package/src/extensions/TextAlignment/TextAlignmentExtension.ts +3 -51
  191. package/src/extensions/TextColor/TextColorExtension.ts +1 -29
  192. package/src/extensions/TextColor/TextColorMark.ts +7 -27
  193. package/src/extensions/UniqueID/UniqueID.ts +28 -2
  194. package/src/extensions-shared/README.md +3 -0
  195. package/src/{shared/plugins → extensions-shared}/suggestion/SuggestionPlugin.ts +19 -13
  196. package/src/index.ts +21 -15
  197. package/src/{extensions/Blocks/nodes → pm-nodes}/BlockContainer.ts +161 -96
  198. package/src/pm-nodes/BlockGroup.ts +54 -0
  199. package/src/pm-nodes/Doc.ts +7 -0
  200. package/src/pm-nodes/README.md +42 -0
  201. package/src/pm-nodes/index.ts +3 -0
  202. package/src/schema/README.md +3 -0
  203. package/src/schema/blocks/createSpec.ts +220 -0
  204. package/src/schema/blocks/internal.ts +253 -0
  205. package/src/schema/blocks/types.ts +252 -0
  206. package/src/schema/index.ts +10 -0
  207. package/src/schema/inlineContent/createSpec.ts +119 -0
  208. package/src/schema/inlineContent/internal.ts +105 -0
  209. package/src/schema/inlineContent/types.ts +144 -0
  210. package/src/schema/propTypes.ts +32 -0
  211. package/src/schema/styles/createSpec.ts +85 -0
  212. package/src/schema/styles/internal.ts +96 -0
  213. package/src/schema/styles/types.ts +42 -0
  214. package/src/util/README.md +3 -0
  215. package/src/{shared/utils.ts → util/browser.ts} +4 -8
  216. package/src/util/string.ts +3 -0
  217. package/src/util/typescript.ts +5 -0
  218. package/types/src/api/blockManipulation/blockManipulation.d.ts +5 -4
  219. package/types/src/api/exporters/copyExtension.d.ts +6 -0
  220. package/types/src/api/exporters/html/externalHTMLExporter.d.ts +8 -0
  221. package/types/src/api/exporters/html/internalHTMLSerializer.d.ts +8 -0
  222. package/types/src/api/exporters/html/util/sharedHTMLConversion.d.ts +7 -0
  223. package/types/src/api/exporters/markdown/markdownExporter.d.ts +5 -0
  224. package/types/src/api/nodeConversions/nodeConversions.d.ts +14 -6
  225. package/types/src/api/parsers/html/parseHTML.d.ts +3 -0
  226. package/types/src/api/parsers/html/parseHTML.test.d.ts +1 -0
  227. package/types/src/api/parsers/html/util/nestedLists.d.ts +1 -0
  228. package/types/src/api/parsers/html/util/nestedLists.test.d.ts +1 -0
  229. package/types/src/api/parsers/markdown/parseMarkdown.d.ts +3 -0
  230. package/types/src/api/parsers/markdown/parseMarkdown.test.d.ts +1 -0
  231. package/types/src/api/parsers/pasteExtension.d.ts +6 -0
  232. package/types/src/api/testUtil/cases/customBlocks.d.ts +345 -0
  233. package/types/src/api/testUtil/cases/customInlineContent.d.ts +29 -0
  234. package/types/src/api/testUtil/cases/customStyles.d.ts +64 -0
  235. package/types/src/api/testUtil/cases/defaultSchema.d.ts +3 -0
  236. package/types/src/api/testUtil/index.d.ts +12 -0
  237. package/types/src/api/testUtil/partialBlockTestUtil.d.ts +7 -0
  238. package/types/src/blocks/HeadingBlockContent/HeadingBlockContent.d.ts +58 -0
  239. package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +93 -0
  240. package/types/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.d.ts +46 -0
  241. package/types/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +46 -0
  242. package/types/src/blocks/ParagraphBlockContent/ParagraphBlockContent.d.ts +52 -0
  243. package/types/src/blocks/TableBlockContent/TableBlockContent.d.ts +53 -0
  244. package/types/src/blocks/TableBlockContent/TableExtension.d.ts +2 -0
  245. package/types/src/blocks/defaultBlockHelpers.d.ts +10 -0
  246. package/types/src/blocks/defaultBlocks.d.ts +577 -0
  247. package/types/src/{extensions/Blocks/api → blocks}/defaultProps.d.ts +2 -1
  248. package/types/src/{BlockNoteEditor.d.ts → editor/BlockNoteEditor.d.ts} +54 -43
  249. package/types/src/editor/BlockNoteEditor.test.d.ts +1 -0
  250. package/types/src/{BlockNoteExtensions.d.ts → editor/BlockNoteExtensions.d.ts} +7 -4
  251. package/types/src/editor/cursorPositionTypes.d.ts +6 -0
  252. package/types/src/editor/selectionTypes.d.ts +4 -0
  253. package/types/src/editor/transformPasted.d.ts +12 -0
  254. package/types/src/extensions/BackgroundColor/BackgroundColorExtension.d.ts +0 -7
  255. package/types/src/extensions/BackgroundColor/BackgroundColorMark.d.ts +7 -9
  256. package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +8 -6
  257. package/types/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.d.ts +6 -6
  258. package/types/src/extensions/ImageToolbar/ImageToolbarPlugin.d.ts +11 -16
  259. package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +18 -11
  260. package/types/src/extensions/SlashMenu/BaseSlashMenuItem.d.ts +5 -6
  261. package/types/src/extensions/SlashMenu/SlashMenuPlugin.d.ts +6 -6
  262. package/types/src/extensions/SlashMenu/defaultSlashMenuItems.d.ts +2 -1
  263. package/types/src/extensions/TableHandles/TableHandlesPlugin.d.ts +74 -0
  264. package/types/src/extensions/TextAlignment/TextAlignmentExtension.d.ts +0 -7
  265. package/types/src/extensions/TextColor/TextColorExtension.d.ts +0 -7
  266. package/types/src/extensions/TextColor/TextColorMark.d.ts +7 -9
  267. package/types/src/extensions/UniqueID/UniqueID.d.ts +1 -1
  268. package/types/src/{shared/plugins → extensions-shared}/suggestion/SuggestionPlugin.d.ts +5 -4
  269. package/types/src/index.d.ts +20 -15
  270. package/types/src/{extensions/Blocks/nodes → pm-nodes}/BlockContainer.d.ts +5 -3
  271. package/types/src/pm-nodes/Doc.d.ts +2 -0
  272. package/types/src/pm-nodes/index.d.ts +3 -0
  273. package/types/src/schema/blocks/createSpec.d.ts +35 -0
  274. package/types/src/schema/blocks/internal.d.ts +45 -0
  275. package/types/src/schema/blocks/types.d.ts +107 -0
  276. package/types/src/schema/index.d.ts +10 -0
  277. package/types/src/schema/inlineContent/createSpec.d.ts +21 -0
  278. package/types/src/schema/inlineContent/internal.d.ts +28 -0
  279. package/types/src/schema/inlineContent/types.d.ts +62 -0
  280. package/types/src/schema/propTypes.d.ts +8 -0
  281. package/types/src/schema/styles/createSpec.d.ts +13 -0
  282. package/types/src/schema/styles/internal.d.ts +22 -0
  283. package/types/src/schema/styles/types.d.ts +21 -0
  284. package/types/src/{shared/utils.d.ts → util/browser.d.ts} +0 -3
  285. package/types/src/util/string.d.ts +1 -0
  286. package/types/src/util/typescript.d.ts +3 -0
  287. package/src/api/formatConversions/__snapshots__/formatConversions.test.ts.snap +0 -346
  288. package/src/api/formatConversions/formatConversions.test.ts +0 -753
  289. package/src/api/formatConversions/formatConversions.ts +0 -133
  290. package/src/api/nodeConversions/testUtil.ts +0 -65
  291. package/src/extensions/Blocks/api/block.ts +0 -307
  292. package/src/extensions/Blocks/api/blockTypes.ts +0 -249
  293. package/src/extensions/Blocks/api/cursorPositionTypes.ts +0 -7
  294. package/src/extensions/Blocks/api/defaultBlocks.ts +0 -16
  295. package/src/extensions/Blocks/api/defaultProps.ts +0 -16
  296. package/src/extensions/Blocks/api/inlineContentTypes.ts +0 -36
  297. package/src/extensions/Blocks/api/selectionTypes.ts +0 -5
  298. package/src/extensions/Blocks/api/serialization.ts +0 -29
  299. package/src/extensions/Blocks/helpers/findBlock.ts +0 -5
  300. package/src/extensions/Blocks/index.ts +0 -8
  301. package/src/extensions/Blocks/nodes/BlockAttributes.ts +0 -10
  302. package/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContent.ts +0 -142
  303. package/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContent.ts +0 -62
  304. package/src/extensions/Blocks/nodes/BlockGroup.ts +0 -53
  305. package/types/src/api/formatConversions/formatConversions.d.ts +0 -6
  306. package/types/src/api/nodeConversions/testUtil.d.ts +0 -2
  307. package/types/src/extensions/Blocks/api/block.d.ts +0 -20
  308. package/types/src/extensions/Blocks/api/blockTypes.d.ts +0 -103
  309. package/types/src/extensions/Blocks/api/cursorPositionTypes.d.ts +0 -6
  310. package/types/src/extensions/Blocks/api/defaultBlocks.d.ts +0 -117
  311. package/types/src/extensions/Blocks/api/inlineContentTypes.d.ts +0 -30
  312. package/types/src/extensions/Blocks/api/selectionTypes.d.ts +0 -4
  313. package/types/src/extensions/Blocks/api/serialization.d.ts +0 -2
  314. package/types/src/extensions/Blocks/helpers/findBlock.d.ts +0 -6
  315. package/types/src/extensions/Blocks/index.d.ts +0 -4
  316. package/types/src/extensions/Blocks/nodes/BlockAttributes.d.ts +0 -2
  317. package/types/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContent.d.ts +0 -43
  318. package/types/src/extensions/Blocks/nodes/BlockContent/ImageBlockContent/ImageBlockContent.d.ts +0 -37
  319. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.d.ts +0 -35
  320. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +0 -35
  321. package/types/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContent.d.ts +0 -44
  322. /package/src/{shared/EditorElement.ts → api/exporters/markdown/__snapshots__/hardbreak/only/markdown.md} +0 -0
  323. /package/{types/src/shared/EditorElement.d.ts → src/api/exporters/markdown/__snapshots__/paragraph/empty/markdown.md} +0 -0
  324. /package/src/api/{formatConversions → exporters/markdown}/removeUnderlinesRehypePlugin.ts +0 -0
  325. /package/src/{extensions/Blocks/helpers → api}/getBlockInfoFromPos.ts +0 -0
  326. /package/src/api/{util/nodeUtil.ts → nodeUtil.ts} +0 -0
  327. /package/src/{extensions/Blocks/nodes/BlockContent → blocks}/ImageBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.ts +0 -0
  328. /package/src/extensions/{Blocks → NonEditableBlocks}/NonEditableBlockPlugin.ts +0 -0
  329. /package/src/extensions/{Blocks → PreviousBlockType}/PreviousBlockTypePlugin.ts +0 -0
  330. /package/src/{shared → extensions-shared}/BaseUiElementTypes.ts +0 -0
  331. /package/src/{shared/plugins → extensions-shared}/suggestion/SuggestionItem.ts +0 -0
  332. /package/src/{shared → util}/EventEmitter.ts +0 -0
  333. /package/types/src/{BlockNoteEditor.test.d.ts → api/exporters/html/htmlConversion.test.d.ts} +0 -0
  334. /package/types/src/api/{formatConversions → exporters/html/util}/simplifyBlocksRehypePlugin.d.ts +0 -0
  335. /package/types/src/api/{formatConversions/formatConversions.test.d.ts → exporters/markdown/markdownExporter.test.d.ts} +0 -0
  336. /package/types/src/api/{formatConversions → exporters/markdown}/removeUnderlinesRehypePlugin.d.ts +0 -0
  337. /package/types/src/{extensions/Blocks/helpers → api}/getBlockInfoFromPos.d.ts +0 -0
  338. /package/types/src/api/{util/nodeUtil.d.ts → nodeUtil.d.ts} +0 -0
  339. /package/types/src/{extensions/Blocks/nodes/BlockContent → blocks}/ImageBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.d.ts +0 -0
  340. /package/types/src/{extensions/Blocks/nodes/BlockContent → blocks}/ListItemBlockContent/ListItemKeyboardShortcuts.d.ts +0 -0
  341. /package/types/src/{extensions/Blocks/nodes/BlockContent → blocks}/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.d.ts +0 -0
  342. /package/types/src/extensions/{Blocks → NonEditableBlocks}/NonEditableBlockPlugin.d.ts +0 -0
  343. /package/types/src/extensions/{Blocks → PreviousBlockType}/PreviousBlockTypePlugin.d.ts +0 -0
  344. /package/types/src/{shared → extensions-shared}/BaseUiElementTypes.d.ts +0 -0
  345. /package/types/src/{shared/plugins → extensions-shared}/suggestion/SuggestionItem.d.ts +0 -0
  346. /package/types/src/{extensions/Blocks/nodes → pm-nodes}/BlockGroup.d.ts +0 -0
  347. /package/types/src/{shared → util}/EventEmitter.d.ts +0 -0
@@ -2,18 +2,20 @@ import { EditorOptions } from "@tiptap/core";
2
2
  import { Node } from "prosemirror-model";
3
3
  import { Editor as TiptapEditor } from "@tiptap/core/dist/packages/core/src/Editor";
4
4
  import * as Y from "yjs";
5
- import { Block, BlockIdentifier, BlockNoteDOMAttributes, BlockSchema, PartialBlock } from "./extensions/Blocks/api/blockTypes";
6
- import { TextCursorPosition } from "./extensions/Blocks/api/cursorPositionTypes";
7
- import { DefaultBlockSchema } from "./extensions/Blocks/api/defaultBlocks";
8
- import { Styles } from "./extensions/Blocks/api/inlineContentTypes";
9
- import { Selection } from "./extensions/Blocks/api/selectionTypes";
10
- import { FormattingToolbarProsemirrorPlugin } from "./extensions/FormattingToolbar/FormattingToolbarPlugin";
11
- import { HyperlinkToolbarProsemirrorPlugin } from "./extensions/HyperlinkToolbar/HyperlinkToolbarPlugin";
12
- import { ImageToolbarProsemirrorPlugin } from "./extensions/ImageToolbar/ImageToolbarPlugin";
13
- import { SideMenuProsemirrorPlugin } from "./extensions/SideMenu/SideMenuPlugin";
14
- import { BaseSlashMenuItem } from "./extensions/SlashMenu/BaseSlashMenuItem";
15
- import { SlashMenuProsemirrorPlugin } from "./extensions/SlashMenu/SlashMenuPlugin";
16
- export type BlockNoteEditorOptions<BSchema extends BlockSchema> = {
5
+ import { DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema, defaultBlockSpecs, defaultInlineContentSpecs, defaultStyleSpecs } from "../blocks/defaultBlocks";
6
+ import { FormattingToolbarProsemirrorPlugin } from "../extensions/FormattingToolbar/FormattingToolbarPlugin";
7
+ import { HyperlinkToolbarProsemirrorPlugin } from "../extensions/HyperlinkToolbar/HyperlinkToolbarPlugin";
8
+ import { ImageToolbarProsemirrorPlugin } from "../extensions/ImageToolbar/ImageToolbarPlugin";
9
+ import { SideMenuProsemirrorPlugin } from "../extensions/SideMenu/SideMenuPlugin";
10
+ import { BaseSlashMenuItem } from "../extensions/SlashMenu/BaseSlashMenuItem";
11
+ import { SlashMenuProsemirrorPlugin } from "../extensions/SlashMenu/SlashMenuPlugin";
12
+ import { TableHandlesProsemirrorPlugin } from "../extensions/TableHandles/TableHandlesPlugin";
13
+ import { Block, BlockIdentifier, BlockNoteDOMAttributes, BlockSchema, BlockSchemaFromSpecs, BlockSchemaWithBlock, BlockSpecs, InlineContentSchema, InlineContentSchemaFromSpecs, InlineContentSpecs, PartialBlock, StyleSchema, StyleSchemaFromSpecs, StyleSpecs, Styles } from "../schema";
14
+ import { TextCursorPosition } from "./cursorPositionTypes";
15
+ import { Selection } from "./selectionTypes";
16
+ import "./Block.css";
17
+ import "./editor.css";
18
+ export type BlockNoteEditorOptions<BSpecs extends BlockSpecs, ISpecs extends InlineContentSpecs, SSpecs extends StyleSpecs> = {
17
19
  enableBlockNoteExtensions: boolean;
18
20
  /**
19
21
  *
@@ -21,7 +23,7 @@ export type BlockNoteEditorOptions<BSchema extends BlockSchema> = {
21
23
  *
22
24
  * @default defaultSlashMenuItems from `./extensions/SlashMenu`
23
25
  */
24
- slashMenuItems: BaseSlashMenuItem<any>[];
26
+ slashMenuItems: BaseSlashMenuItem<any, any, any>[];
25
27
  /**
26
28
  * The HTML element that should be used as the parent element for the editor.
27
29
  *
@@ -37,15 +39,15 @@ export type BlockNoteEditorOptions<BSchema extends BlockSchema> = {
37
39
  /**
38
40
  * A callback function that runs when the editor is ready to be used.
39
41
  */
40
- onEditorReady: (editor: BlockNoteEditor<BSchema>) => void;
42
+ onEditorReady: (editor: BlockNoteEditor<BlockSchemaFromSpecs<BSpecs>, InlineContentSchemaFromSpecs<ISpecs>, StyleSchemaFromSpecs<SSpecs>>) => void;
41
43
  /**
42
44
  * A callback function that runs whenever the editor's contents change.
43
45
  */
44
- onEditorContentChange: (editor: BlockNoteEditor<BSchema>) => void;
46
+ onEditorContentChange: (editor: BlockNoteEditor<BlockSchemaFromSpecs<BSpecs>, InlineContentSchemaFromSpecs<ISpecs>, StyleSchemaFromSpecs<SSpecs>>) => void;
45
47
  /**
46
48
  * A callback function that runs whenever the text cursor position changes.
47
49
  */
48
- onTextCursorPositionChange: (editor: BlockNoteEditor<BSchema>) => void;
50
+ onTextCursorPositionChange: (editor: BlockNoteEditor<BlockSchemaFromSpecs<BSpecs>, InlineContentSchemaFromSpecs<ISpecs>, StyleSchemaFromSpecs<SSpecs>>) => void;
49
51
  /**
50
52
  * Locks the editor from being editable by the user if set to `false`.
51
53
  */
@@ -53,7 +55,7 @@ export type BlockNoteEditorOptions<BSchema extends BlockSchema> = {
53
55
  /**
54
56
  * The content that should be in the editor when it's created, represented as an array of partial block objects.
55
57
  */
56
- initialContent: PartialBlock<BSchema>[];
58
+ initialContent: PartialBlock<BlockSchemaFromSpecs<BSpecs>, InlineContentSchemaFromSpecs<ISpecs>, StyleSchemaFromSpecs<SSpecs>>[];
57
59
  /**
58
60
  * Use default BlockNote font and reset the styles of <p> <li> <h1> elements etc., that are used in BlockNote.
59
61
  *
@@ -63,7 +65,9 @@ export type BlockNoteEditorOptions<BSchema extends BlockSchema> = {
63
65
  /**
64
66
  * A list of block types that should be available in the editor.
65
67
  */
66
- blockSchema: BSchema;
68
+ blockSpecs: BSpecs;
69
+ styleSpecs: SSpecs;
70
+ inlineContentSpecs: ISpecs;
67
71
  /**
68
72
  * A custom function to handle file uploads.
69
73
  * @param file The file that should be uploaded.
@@ -96,21 +100,28 @@ export type BlockNoteEditorOptions<BSchema extends BlockSchema> = {
96
100
  };
97
101
  _tiptapOptions: Partial<EditorOptions>;
98
102
  };
99
- export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockSchema> {
103
+ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema> {
100
104
  private readonly options;
101
105
  readonly _tiptapEditor: TiptapEditor & {
102
106
  contentComponent: any;
103
107
  };
104
- blockCache: WeakMap<Node, Block<BSchema>>;
105
- readonly schema: BSchema;
108
+ blockCache: WeakMap<Node, Block<any, any, any>>;
109
+ readonly blockSchema: BSchema;
110
+ readonly inlineContentSchema: ISchema;
111
+ readonly styleSchema: SSchema;
112
+ readonly blockImplementations: BlockSpecs;
113
+ readonly inlineContentImplementations: InlineContentSpecs;
114
+ readonly styleImplementations: StyleSpecs;
106
115
  ready: boolean;
107
- readonly sideMenu: SideMenuProsemirrorPlugin<BSchema>;
108
- readonly formattingToolbar: FormattingToolbarProsemirrorPlugin<BSchema>;
109
- readonly slashMenu: SlashMenuProsemirrorPlugin<BSchema, any>;
110
- readonly hyperlinkToolbar: HyperlinkToolbarProsemirrorPlugin<BSchema>;
111
- readonly imageToolbar: ImageToolbarProsemirrorPlugin<BSchema>;
116
+ readonly sideMenu: SideMenuProsemirrorPlugin<BSchema, ISchema, SSchema>;
117
+ readonly formattingToolbar: FormattingToolbarProsemirrorPlugin;
118
+ readonly slashMenu: SlashMenuProsemirrorPlugin<BSchema, ISchema, SSchema, any>;
119
+ readonly hyperlinkToolbar: HyperlinkToolbarProsemirrorPlugin<BSchema, ISchema, SSchema>;
120
+ readonly imageToolbar: ImageToolbarProsemirrorPlugin<BSchema, ISchema, SSchema>;
121
+ readonly tableHandles: TableHandlesProsemirrorPlugin<BSchema extends BlockSchemaWithBlock<"table", DefaultBlockSchema["table"]> ? BSchema : any, ISchema, SSchema> | undefined;
112
122
  readonly uploadFile: ((file: File) => Promise<string>) | undefined;
113
- constructor(options?: Partial<BlockNoteEditorOptions<BSchema>>);
123
+ static create<BSpecs extends BlockSpecs = typeof defaultBlockSpecs, ISpecs extends InlineContentSpecs = typeof defaultInlineContentSpecs, SSpecs extends StyleSpecs = typeof defaultStyleSpecs>(options?: Partial<BlockNoteEditorOptions<BSpecs, ISpecs, SSpecs>>): BlockNoteEditor<BlockSchemaFromSpecs<BSpecs>, InlineContentSchemaFromSpecs<ISpecs>, StyleSchemaFromSpecs<SSpecs>>;
124
+ private constructor();
114
125
  get prosemirrorView(): import("prosemirror-view").EditorView;
115
126
  get domElement(): HTMLDivElement;
116
127
  isFocused(): boolean;
@@ -119,19 +130,19 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
119
130
  * Gets a snapshot of all top-level (non-nested) blocks in the editor.
120
131
  * @returns A snapshot of all top-level (non-nested) blocks in the editor.
121
132
  */
122
- get topLevelBlocks(): Block<BSchema>[];
133
+ get topLevelBlocks(): Block<BSchema, ISchema, SSchema>[];
123
134
  /**
124
135
  * Gets a snapshot of an existing block from the editor.
125
136
  * @param blockIdentifier The identifier of an existing block that should be retrieved.
126
137
  * @returns The block that matches the identifier, or `undefined` if no matching block was found.
127
138
  */
128
- getBlock(blockIdentifier: BlockIdentifier): Block<BSchema> | undefined;
139
+ getBlock(blockIdentifier: BlockIdentifier): Block<BSchema, ISchema, SSchema> | undefined;
129
140
  /**
130
141
  * Traverses all blocks in the editor depth-first, and executes a callback for each.
131
142
  * @param callback The callback to execute for each block. Returning `false` stops the traversal.
132
143
  * @param reverse Whether the blocks should be traversed in reverse order.
133
144
  */
134
- forEachBlock(callback: (block: Block<BSchema>) => boolean, reverse?: boolean): void;
145
+ forEachBlock(callback: (block: Block<BSchema, ISchema, SSchema>) => boolean, reverse?: boolean): void;
135
146
  /**
136
147
  * Executes a callback whenever the editor's contents change.
137
148
  * @param callback The callback to execute.
@@ -146,7 +157,7 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
146
157
  * Gets a snapshot of the current text cursor position.
147
158
  * @returns A snapshot of the current text cursor position.
148
159
  */
149
- getTextCursorPosition(): TextCursorPosition<BSchema>;
160
+ getTextCursorPosition(): TextCursorPosition<BSchema, ISchema, SSchema>;
150
161
  /**
151
162
  * Sets the text cursor position to the start or end of an existing block. Throws an error if the target block could
152
163
  * not be found.
@@ -157,7 +168,7 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
157
168
  /**
158
169
  * Gets a snapshot of the current selection.
159
170
  */
160
- getSelection(): Selection<BSchema> | undefined;
171
+ getSelection(): Selection<BSchema, ISchema, SSchema> | undefined;
161
172
  /**
162
173
  * Checks if the editor is currently editable, or if it's locked.
163
174
  * @returns True if the editor is editable, false otherwise.
@@ -176,7 +187,7 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
176
187
  * @param placement Whether the blocks should be inserted just before, just after, or nested inside the
177
188
  * `referenceBlock`. Inserts the blocks at the start of the existing block's children if "nested" is used.
178
189
  */
179
- insertBlocks(blocksToInsert: PartialBlock<BSchema>[], referenceBlock: BlockIdentifier, placement?: "before" | "after" | "nested"): void;
190
+ insertBlocks(blocksToInsert: PartialBlock<BSchema, ISchema, SSchema>[], referenceBlock: BlockIdentifier, placement?: "before" | "after" | "nested"): void;
180
191
  /**
181
192
  * Updates an existing block in the editor. Since updatedBlock is a PartialBlock object, some fields might not be
182
193
  * defined. These undefined fields are kept as-is from the existing block. Throws an error if the block to update could
@@ -184,7 +195,7 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
184
195
  * @param blockToUpdate The block that should be updated.
185
196
  * @param update A partial block which defines how the existing block should be changed.
186
197
  */
187
- updateBlock(blockToUpdate: BlockIdentifier, update: PartialBlock<BSchema>): void;
198
+ updateBlock(blockToUpdate: BlockIdentifier, update: PartialBlock<BSchema, ISchema, SSchema>): void;
188
199
  /**
189
200
  * Removes existing blocks from the editor. Throws an error if any of the blocks could not be found.
190
201
  * @param blocksToRemove An array of identifiers for existing blocks that should be removed.
@@ -197,26 +208,26 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
197
208
  * @param blocksToRemove An array of blocks that should be replaced.
198
209
  * @param blocksToInsert An array of partial blocks to replace the old ones with.
199
210
  */
200
- replaceBlocks(blocksToRemove: BlockIdentifier[], blocksToInsert: PartialBlock<BSchema>[]): void;
211
+ replaceBlocks(blocksToRemove: BlockIdentifier[], blocksToInsert: PartialBlock<BSchema, ISchema, SSchema>[]): void;
201
212
  /**
202
213
  * Gets the active text styles at the text cursor position or at the end of the current selection if it's active.
203
214
  */
204
- getActiveStyles(): Styles;
215
+ getActiveStyles(): Styles<SSchema>;
205
216
  /**
206
217
  * Adds styles to the currently selected content.
207
218
  * @param styles The styles to add.
208
219
  */
209
- addStyles(styles: Styles): void;
220
+ addStyles(styles: Styles<SSchema>): void;
210
221
  /**
211
222
  * Removes styles from the currently selected content.
212
223
  * @param styles The styles to remove.
213
224
  */
214
- removeStyles(styles: Styles): void;
225
+ removeStyles(styles: Styles<SSchema>): void;
215
226
  /**
216
227
  * Toggles styles on the currently selected content.
217
228
  * @param styles The styles to toggle.
218
229
  */
219
- toggleStyles(styles: Styles): void;
230
+ toggleStyles(styles: Styles<SSchema>): void;
220
231
  /**
221
232
  * Gets the currently selected text.
222
233
  */
@@ -253,7 +264,7 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
253
264
  * @param blocks An array of blocks that should be serialized into HTML.
254
265
  * @returns The blocks, serialized as an HTML string.
255
266
  */
256
- blocksToHTML(blocks: Block<BSchema>[]): Promise<string>;
267
+ blocksToHTMLLossy(blocks?: Block<BSchema, ISchema, SSchema>[]): Promise<string>;
257
268
  /**
258
269
  * Parses blocks from an HTML string. Tries to create `Block` objects out of any HTML block-level elements, and
259
270
  * `InlineNode` objects from any HTML inline elements, though not all element types are recognized. If BlockNote
@@ -261,14 +272,14 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
261
272
  * @param html The HTML string to parse blocks from.
262
273
  * @returns The blocks parsed from the HTML string.
263
274
  */
264
- HTMLToBlocks(html: string): Promise<Block<BSchema>[]>;
275
+ tryParseHTMLToBlocks(html: string): Promise<Block<BSchema, ISchema, SSchema>[]>;
265
276
  /**
266
277
  * Serializes blocks into a Markdown string. The output is simplified as Markdown does not support all features of
267
278
  * BlockNote - children of blocks which aren't list items are un-nested and certain styles are removed.
268
279
  * @param blocks An array of blocks that should be serialized into Markdown.
269
280
  * @returns The blocks, serialized as a Markdown string.
270
281
  */
271
- blocksToMarkdown(blocks: Block<BSchema>[]): Promise<string>;
282
+ blocksToMarkdownLossy(blocks?: Block<BSchema, ISchema, SSchema>[]): Promise<string>;
272
283
  /**
273
284
  * Creates a list of blocks from a Markdown string. Tries to create `Block` and `InlineNode` objects based on
274
285
  * Markdown syntax, though not all symbols are recognized. If BlockNote doesn't recognize a symbol, it will parse it
@@ -276,7 +287,7 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
276
287
  * @param markdown The Markdown string to parse blocks from.
277
288
  * @returns The blocks parsed from the Markdown string.
278
289
  */
279
- markdownToBlocks(markdown: string): Promise<Block<BSchema>[]>;
290
+ tryParseMarkdownToBlocks(markdown: string): Promise<Block<BSchema, ISchema, SSchema>[]>;
280
291
  /**
281
292
  * Updates the user info for the current user that's shown to other collaborators.
282
293
  */
@@ -0,0 +1 @@
1
+ export {};
@@ -1,14 +1,17 @@
1
1
  import { Extensions } from "@tiptap/core";
2
- import { BlockNoteEditor } from "./BlockNoteEditor";
2
+ import type { BlockNoteEditor } from "./BlockNoteEditor";
3
3
  import * as Y from "yjs";
4
- import { BlockNoteDOMAttributes } from "./extensions/Blocks/api/blockTypes";
4
+ import { BlockNoteDOMAttributes, BlockSpecs, InlineContentSchema, InlineContentSpecs, StyleSchema, StyleSpecs } from "../schema";
5
5
  /**
6
6
  * Get all the Tiptap extensions BlockNote is configured with by default
7
7
  */
8
- export declare const getBlockNoteExtensions: <BSchema extends Record<string, import("./extensions/Blocks/api/blockTypes").BlockSpec<string, import("./extensions/Blocks/api/blockTypes").PropSchema, boolean>>>(opts: {
9
- editor: BlockNoteEditor<BSchema>;
8
+ export declare const getBlockNoteExtensions: <BSchema extends Record<string, import("../schema").BlockConfig>, I extends InlineContentSchema, S extends StyleSchema>(opts: {
9
+ editor: BlockNoteEditor<BSchema, I, S>;
10
10
  domAttributes: Partial<BlockNoteDOMAttributes>;
11
11
  blockSchema: BSchema;
12
+ blockSpecs: BlockSpecs;
13
+ inlineContentSpecs: InlineContentSpecs;
14
+ styleSpecs: StyleSpecs;
12
15
  collaboration?: {
13
16
  fragment: Y.XmlFragment;
14
17
  user: {
@@ -0,0 +1,6 @@
1
+ import { Block, BlockSchema, InlineContentSchema, StyleSchema } from "../schema";
2
+ export type TextCursorPosition<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> = {
3
+ block: Block<BSchema, I, S>;
4
+ prevBlock: Block<BSchema, I, S> | undefined;
5
+ nextBlock: Block<BSchema, I, S> | undefined;
6
+ };
@@ -0,0 +1,4 @@
1
+ import { Block, BlockSchema, InlineContentSchema, StyleSchema } from "../schema";
2
+ export type Selection<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> = {
3
+ blocks: Block<BSchema, I, S>[];
4
+ };
@@ -0,0 +1,12 @@
1
+ import { Slice } from "@tiptap/pm/model";
2
+ import { EditorView } from "@tiptap/pm/view";
3
+ /**
4
+ * fix for https://github.com/ProseMirror/prosemirror/issues/1430#issuecomment-1822570821
5
+ *
6
+ * Without this fix, pasting two paragraphs would cause the second one to be indented in the other
7
+ * this fix wraps every element in the slice in it's own blockContainer, to prevent Prosemirror from nesting the
8
+ * elements on paste.
9
+ *
10
+ * The exception is when we encounter blockGroups with listitems, because those actually should be nested
11
+ */
12
+ export declare function transformPasted(slice: Slice, view: EditorView): Slice;
@@ -1,9 +1,2 @@
1
1
  import { Extension } from "@tiptap/core";
2
- declare module "@tiptap/core" {
3
- interface Commands<ReturnType> {
4
- blockBackgroundColor: {
5
- setBlockBackgroundColor: (posInBlock: number, color: string) => ReturnType;
6
- };
7
- }
8
- }
9
2
  export declare const BackgroundColorExtension: Extension<any, any>;
@@ -1,9 +1,7 @@
1
- import { Mark } from "@tiptap/core";
2
- declare module "@tiptap/core" {
3
- interface Commands<ReturnType> {
4
- backgroundColor: {
5
- setBackgroundColor: (color: string) => ReturnType;
6
- };
7
- }
8
- }
9
- export declare const BackgroundColorMark: Mark<any, any>;
1
+ export declare const BackgroundColor: {
2
+ config: {
3
+ type: string;
4
+ propSchema: "string";
5
+ };
6
+ implementation: import("../../schema").StyleImplementation;
7
+ };
@@ -1,10 +1,12 @@
1
1
  import { EditorState, Plugin, PluginKey } from "prosemirror-state";
2
2
  import { EditorView } from "prosemirror-view";
3
- import { BaseUiElementCallbacks, BaseUiElementState, BlockNoteEditor, BlockSchema } from "../..";
4
- import { EventEmitter } from "../../shared/EventEmitter";
3
+ import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
4
+ import { BaseUiElementCallbacks, BaseUiElementState } from "../../extensions-shared/BaseUiElementTypes";
5
+ import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema";
6
+ import { EventEmitter } from "../../util/EventEmitter";
5
7
  export type FormattingToolbarCallbacks = BaseUiElementCallbacks;
6
8
  export type FormattingToolbarState = BaseUiElementState;
7
- export declare class FormattingToolbarView<BSchema extends BlockSchema> {
9
+ export declare class FormattingToolbarView {
8
10
  private readonly editor;
9
11
  private readonly pmView;
10
12
  private formattingToolbarState?;
@@ -18,7 +20,7 @@ export declare class FormattingToolbarView<BSchema extends BlockSchema> {
18
20
  from: number;
19
21
  to: number;
20
22
  }) => boolean;
21
- constructor(editor: BlockNoteEditor<BSchema>, pmView: EditorView, updateFormattingToolbar: (formattingToolbarState: FormattingToolbarState) => void);
23
+ constructor(editor: BlockNoteEditor<BlockSchema, InlineContentSchema, StyleSchema>, pmView: EditorView, updateFormattingToolbar: (formattingToolbarState: FormattingToolbarState) => void);
22
24
  viewMousedownHandler: () => void;
23
25
  viewMouseupHandler: () => void;
24
26
  dragstartHandler: () => void;
@@ -30,9 +32,9 @@ export declare class FormattingToolbarView<BSchema extends BlockSchema> {
30
32
  getSelectionBoundingBox(): DOMRect;
31
33
  }
32
34
  export declare const formattingToolbarPluginKey: PluginKey<any>;
33
- export declare class FormattingToolbarProsemirrorPlugin<BSchema extends BlockSchema> extends EventEmitter<any> {
35
+ export declare class FormattingToolbarProsemirrorPlugin extends EventEmitter<any> {
34
36
  private view;
35
37
  readonly plugin: Plugin;
36
- constructor(editor: BlockNoteEditor<BSchema>);
38
+ constructor(editor: BlockNoteEditor<any, any, any>);
37
39
  onUpdate(callback: (state: FormattingToolbarState) => void): () => void;
38
40
  }
@@ -1,17 +1,17 @@
1
1
  import { Plugin, PluginKey } from "prosemirror-state";
2
- import { BlockNoteEditor } from "../../BlockNoteEditor";
3
- import { BaseUiElementState } from "../../shared/BaseUiElementTypes";
4
- import { EventEmitter } from "../../shared/EventEmitter";
5
- import { BlockSchema } from "../Blocks/api/blockTypes";
2
+ import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
3
+ import { BaseUiElementState } from "../../extensions-shared/BaseUiElementTypes";
4
+ import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema";
5
+ import { EventEmitter } from "../../util/EventEmitter";
6
6
  export type HyperlinkToolbarState = BaseUiElementState & {
7
7
  url: string;
8
8
  text: string;
9
9
  };
10
10
  export declare const hyperlinkToolbarPluginKey: PluginKey<any>;
11
- export declare class HyperlinkToolbarProsemirrorPlugin<BSchema extends BlockSchema> extends EventEmitter<any> {
11
+ export declare class HyperlinkToolbarProsemirrorPlugin<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> extends EventEmitter<any> {
12
12
  private view;
13
13
  readonly plugin: Plugin;
14
- constructor(editor: BlockNoteEditor<BSchema>);
14
+ constructor(editor: BlockNoteEditor<BSchema, I, S>);
15
15
  onUpdate(callback: (state: HyperlinkToolbarState) => void): () => void;
16
16
  /**
17
17
  * Edit the currently hovered hyperlink.
@@ -1,25 +1,20 @@
1
1
  import { EditorState, Plugin, PluginKey } from "prosemirror-state";
2
2
  import { EditorView } from "prosemirror-view";
3
- import { BaseUiElementCallbacks, BaseUiElementState, BlockNoteEditor, BlockSchema, BlockSpec, SpecificBlock } from "../..";
4
- import { EventEmitter } from "../../shared/EventEmitter";
3
+ import { EventEmitter } from "../../util/EventEmitter";
4
+ import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
5
+ import { BlockSchema, InlineContentSchema, SpecificBlock, StyleSchema } from "../../schema";
6
+ import { BaseUiElementCallbacks, BaseUiElementState } from "../../extensions-shared/BaseUiElementTypes";
5
7
  export type ImageToolbarCallbacks = BaseUiElementCallbacks;
6
- export type ImageToolbarState = BaseUiElementState & {
7
- block: SpecificBlock<BlockSchema & {
8
- image: BlockSpec<"image", {
9
- src: {
10
- default: string;
11
- };
12
- }, false>;
13
- }, "image">;
8
+ export type ImageToolbarState<B extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema = StyleSchema> = BaseUiElementState & {
9
+ block: SpecificBlock<B, "image", I, S>;
14
10
  };
15
- export declare class ImageToolbarView {
11
+ export declare class ImageToolbarView<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> {
16
12
  private readonly pluginKey;
17
13
  private readonly pmView;
18
14
  private imageToolbarState?;
19
15
  updateImageToolbar: () => void;
20
16
  prevWasEditable: boolean | null;
21
- shouldShow: (state: EditorState) => boolean;
22
- constructor(pluginKey: PluginKey, pmView: EditorView, updateImageToolbar: (imageToolbarState: ImageToolbarState) => void);
17
+ constructor(pluginKey: PluginKey, pmView: EditorView, updateImageToolbar: (imageToolbarState: ImageToolbarState<BSchema, I, S>) => void);
23
18
  mouseDownHandler: () => void;
24
19
  dragstartHandler: () => void;
25
20
  blurHandler: (event: FocusEvent) => void;
@@ -28,9 +23,9 @@ export declare class ImageToolbarView {
28
23
  destroy(): void;
29
24
  }
30
25
  export declare const imageToolbarPluginKey: PluginKey<any>;
31
- export declare class ImageToolbarProsemirrorPlugin<BSchema extends BlockSchema> extends EventEmitter<any> {
26
+ export declare class ImageToolbarProsemirrorPlugin<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> extends EventEmitter<any> {
32
27
  private view;
33
28
  readonly plugin: Plugin;
34
- constructor(_editor: BlockNoteEditor<BSchema>);
35
- onUpdate(callback: (state: ImageToolbarState) => void): () => void;
29
+ constructor(_editor: BlockNoteEditor<BSchema, I, S>);
30
+ onUpdate(callback: (state: ImageToolbarState<BSchema, I, S>) => void): () => void;
36
31
  }
@@ -1,14 +1,21 @@
1
1
  import { PluginView } from "@tiptap/pm/state";
2
2
  import { Plugin, PluginKey } from "prosemirror-state";
3
3
  import { EditorView } from "prosemirror-view";
4
- import { BlockNoteEditor } from "../../BlockNoteEditor";
5
- import { BaseUiElementState } from "../../shared/BaseUiElementTypes";
6
- import { EventEmitter } from "../../shared/EventEmitter";
7
- import { Block, BlockSchema } from "../Blocks/api/blockTypes";
8
- export type SideMenuState<BSchema extends BlockSchema> = BaseUiElementState & {
9
- block: Block<BSchema>;
4
+ import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
5
+ import { BaseUiElementState } from "../../extensions-shared/BaseUiElementTypes";
6
+ import { Block, BlockSchema, InlineContentSchema, StyleSchema } from "../../schema";
7
+ import { EventEmitter } from "../../util/EventEmitter";
8
+ export type SideMenuState<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> = BaseUiElementState & {
9
+ block: Block<BSchema, I, S>;
10
10
  };
11
- export declare class SideMenuView<BSchema extends BlockSchema> implements PluginView {
11
+ export declare function getDraggableBlockFromCoords(coords: {
12
+ left: number;
13
+ top: number;
14
+ }, view: EditorView): {
15
+ node: HTMLElement;
16
+ id: string;
17
+ } | undefined;
18
+ export declare class SideMenuView<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> implements PluginView {
12
19
  private readonly editor;
13
20
  private readonly pmView;
14
21
  private readonly updateSideMenu;
@@ -18,7 +25,7 @@ export declare class SideMenuView<BSchema extends BlockSchema> implements Plugin
18
25
  private hoveredBlock;
19
26
  isDragging: boolean;
20
27
  menuFrozen: boolean;
21
- constructor(editor: BlockNoteEditor<BSchema>, pmView: EditorView, updateSideMenu: (sideMenuState: SideMenuState<BSchema>) => void);
28
+ constructor(editor: BlockNoteEditor<BSchema, I, S>, pmView: EditorView, updateSideMenu: (sideMenuState: SideMenuState<BSchema, I, S>) => void);
22
29
  /**
23
30
  * Sets isDragging when dragging text.
24
31
  */
@@ -43,12 +50,12 @@ export declare class SideMenuView<BSchema extends BlockSchema> implements Plugin
43
50
  addBlock(): void;
44
51
  }
45
52
  export declare const sideMenuPluginKey: PluginKey<any>;
46
- export declare class SideMenuProsemirrorPlugin<BSchema extends BlockSchema> extends EventEmitter<any> {
53
+ export declare class SideMenuProsemirrorPlugin<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> extends EventEmitter<any> {
47
54
  private readonly editor;
48
55
  private sideMenuView;
49
56
  readonly plugin: Plugin;
50
- constructor(editor: BlockNoteEditor<BSchema>);
51
- onUpdate(callback: (state: SideMenuState<BSchema>) => void): () => void;
57
+ constructor(editor: BlockNoteEditor<BSchema, I, S>);
58
+ onUpdate(callback: (state: SideMenuState<BSchema, I, S>) => void): () => void;
52
59
  /**
53
60
  * If the block is empty, opens the slash menu. If the block has content,
54
61
  * creates a new block below and opens the slash menu in it.
@@ -1,8 +1,7 @@
1
- import { SuggestionItem } from "../../shared/plugins/suggestion/SuggestionItem";
2
- import { BlockNoteEditor } from "../../BlockNoteEditor";
3
- import { BlockSchema } from "../Blocks/api/blockTypes";
4
- import { DefaultBlockSchema } from "../Blocks/api/defaultBlocks";
5
- export type BaseSlashMenuItem<BSchema extends BlockSchema = DefaultBlockSchema> = SuggestionItem & {
6
- execute: (editor: BlockNoteEditor<BSchema>) => void;
1
+ import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
2
+ import { SuggestionItem } from "../../extensions-shared/suggestion/SuggestionItem";
3
+ import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema";
4
+ export type BaseSlashMenuItem<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> = SuggestionItem & {
5
+ execute: (editor: BlockNoteEditor<BSchema, I, S>) => void;
7
6
  aliases?: string[];
8
7
  };
@@ -1,13 +1,13 @@
1
1
  import { Plugin, PluginKey } from "prosemirror-state";
2
- import { BlockNoteEditor } from "../../BlockNoteEditor";
3
- import { EventEmitter } from "../../shared/EventEmitter";
4
- import { SuggestionsMenuState } from "../../shared/plugins/suggestion/SuggestionPlugin";
5
- import { BlockSchema } from "../Blocks/api/blockTypes";
2
+ import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
3
+ import { SuggestionsMenuState } from "../../extensions-shared/suggestion/SuggestionPlugin";
4
+ import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema";
5
+ import { EventEmitter } from "../../util/EventEmitter";
6
6
  import { BaseSlashMenuItem } from "./BaseSlashMenuItem";
7
7
  export declare const slashMenuPluginKey: PluginKey<any>;
8
- export declare class SlashMenuProsemirrorPlugin<BSchema extends BlockSchema, SlashMenuItem extends BaseSlashMenuItem<BSchema>> extends EventEmitter<any> {
8
+ export declare class SlashMenuProsemirrorPlugin<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema, SlashMenuItem extends BaseSlashMenuItem<BSchema, I, S>> extends EventEmitter<any> {
9
9
  readonly plugin: Plugin;
10
10
  readonly itemCallback: (item: SlashMenuItem) => void;
11
- constructor(editor: BlockNoteEditor<BSchema>, items: SlashMenuItem[]);
11
+ constructor(editor: BlockNoteEditor<BSchema, I, S>, items: SlashMenuItem[]);
12
12
  onUpdate(callback: (state: SuggestionsMenuState<SlashMenuItem>) => void): () => void;
13
13
  }
@@ -1,2 +1,3 @@
1
+ import { InlineContentSchema, StyleSchema } from "../../schema";
1
2
  import { BaseSlashMenuItem } from "./BaseSlashMenuItem";
2
- export declare const getDefaultSlashMenuItems: <BSchema extends Record<string, import("../Blocks/api/blockTypes").BlockSpec<string, import("../Blocks/api/blockTypes").PropSchema, boolean>>>(schema?: BSchema) => BaseSlashMenuItem<BSchema>[];
3
+ export declare const getDefaultSlashMenuItems: <BSchema extends Record<string, import("../../schema").BlockConfig>, I extends InlineContentSchema, S extends StyleSchema>(schema?: BSchema) => BaseSlashMenuItem<BSchema, I, S>[];
@@ -0,0 +1,74 @@
1
+ import { Plugin, PluginKey, PluginView } from "prosemirror-state";
2
+ import { EditorView } from "prosemirror-view";
3
+ import { EventEmitter } from "../../util/EventEmitter";
4
+ import { DefaultBlockSchema } from "../../blocks/defaultBlocks";
5
+ import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
6
+ import { BlockFromConfigNoChildren, BlockSchemaWithBlock, InlineContentSchema, StyleSchema } from "../../schema";
7
+ export type TableHandlesState<I extends InlineContentSchema, S extends StyleSchema> = {
8
+ show: boolean;
9
+ referencePosCell: DOMRect;
10
+ referencePosTable: DOMRect;
11
+ block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], I, S>;
12
+ colIndex: number;
13
+ rowIndex: number;
14
+ draggingState: {
15
+ draggedCellOrientation: "row" | "col";
16
+ originalIndex: number;
17
+ mousePos: number;
18
+ } | undefined;
19
+ };
20
+ export declare class TableHandlesView<BSchema extends BlockSchemaWithBlock<"table", DefaultBlockSchema["table"]>, I extends InlineContentSchema, S extends StyleSchema> implements PluginView {
21
+ private readonly editor;
22
+ private readonly pmView;
23
+ state?: TableHandlesState<I, S>;
24
+ updateState: () => void;
25
+ tableId: string | undefined;
26
+ tablePos: number | undefined;
27
+ menuFrozen: boolean;
28
+ prevWasEditable: boolean | null;
29
+ constructor(editor: BlockNoteEditor<BSchema, I, S>, pmView: EditorView, updateState: (state: TableHandlesState<I, S>) => void);
30
+ mouseMoveHandler: (event: MouseEvent) => false | undefined;
31
+ dragOverHandler: (event: DragEvent) => void;
32
+ dropHandler: (event: DragEvent) => void;
33
+ scrollHandler: () => void;
34
+ destroy(): void;
35
+ }
36
+ export declare const tableHandlesPluginKey: PluginKey<any>;
37
+ export declare class TableHandlesProsemirrorPlugin<BSchema extends BlockSchemaWithBlock<"table", DefaultBlockSchema["table"]>, I extends InlineContentSchema, S extends StyleSchema> extends EventEmitter<any> {
38
+ private readonly editor;
39
+ private view;
40
+ readonly plugin: Plugin;
41
+ constructor(editor: BlockNoteEditor<BSchema, I, S>);
42
+ onUpdate(callback: (state: TableHandlesState<I, S>) => void): () => void;
43
+ /**
44
+ * Callback that should be set on the `dragStart` event for whichever element
45
+ * is used as the column drag handle.
46
+ */
47
+ colDragStart: (event: {
48
+ dataTransfer: DataTransfer | null;
49
+ clientX: number;
50
+ }) => void;
51
+ /**
52
+ * Callback that should be set on the `dragStart` event for whichever element
53
+ * is used as the row drag handle.
54
+ */
55
+ rowDragStart: (event: {
56
+ dataTransfer: DataTransfer | null;
57
+ clientY: number;
58
+ }) => void;
59
+ /**
60
+ * Callback that should be set on the `dragEnd` event for both the element
61
+ * used as the row drag handle, and the one used as the column drag handle.
62
+ */
63
+ dragEnd: () => void;
64
+ /**
65
+ * Freezes the drag handles. When frozen, they will stay attached to the same
66
+ * cell regardless of which cell is hovered by the mouse cursor.
67
+ */
68
+ freezeHandles: () => boolean;
69
+ /**
70
+ * Unfreezes the drag handles. When frozen, they will stay attached to the
71
+ * same cell regardless of which cell is hovered by the mouse cursor.
72
+ */
73
+ unfreezeHandles: () => boolean;
74
+ }
@@ -1,9 +1,2 @@
1
1
  import { Extension } from "@tiptap/core";
2
- declare module "@tiptap/core" {
3
- interface Commands<ReturnType> {
4
- textAlignment: {
5
- setTextAlignment: (textAlignment: "left" | "center" | "right" | "justify") => ReturnType;
6
- };
7
- }
8
- }
9
2
  export declare const TextAlignmentExtension: Extension<any, any>;
@@ -1,9 +1,2 @@
1
1
  import { Extension } from "@tiptap/core";
2
- declare module "@tiptap/core" {
3
- interface Commands<ReturnType> {
4
- blockTextColor: {
5
- setBlockTextColor: (posInBlock: number, color: string) => ReturnType;
6
- };
7
- }
8
- }
9
2
  export declare const TextColorExtension: Extension<any, any>;