@blocknote/core 0.11.2 → 0.12.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 (138) hide show
  1. package/README.md +13 -17
  2. package/dist/blocknote.js +1662 -1447
  3. package/dist/blocknote.js.map +1 -1
  4. package/dist/blocknote.umd.cjs +6 -6
  5. package/dist/blocknote.umd.cjs.map +1 -1
  6. package/dist/style.css +1 -1
  7. package/dist/webpack-stats.json +1 -1
  8. package/package.json +7 -3
  9. package/src/api/blockManipulation/blockManipulation.test.ts +19 -15
  10. package/src/api/blockManipulation/blockManipulation.ts +107 -17
  11. package/src/api/exporters/html/externalHTMLExporter.ts +3 -7
  12. package/src/api/exporters/html/htmlConversion.test.ts +6 -3
  13. package/src/api/exporters/html/internalHTMLSerializer.ts +3 -7
  14. package/src/api/exporters/html/util/sharedHTMLConversion.ts +3 -3
  15. package/src/api/exporters/markdown/markdownExporter.test.ts +7 -3
  16. package/src/api/exporters/markdown/markdownExporter.ts +2 -6
  17. package/src/api/getCurrentBlockContentType.ts +14 -0
  18. package/src/api/nodeConversions/nodeConversions.test.ts +14 -7
  19. package/src/api/nodeConversions/nodeConversions.ts +1 -2
  20. package/src/api/parsers/html/parseHTML.test.ts +5 -1
  21. package/src/api/parsers/html/parseHTML.ts +2 -6
  22. package/src/api/parsers/html/util/nestedLists.ts +11 -1
  23. package/src/api/parsers/markdown/parseMarkdown.test.ts +3 -0
  24. package/src/api/parsers/markdown/parseMarkdown.ts +2 -6
  25. package/src/api/testUtil/cases/customBlocks.ts +18 -16
  26. package/src/api/testUtil/cases/customInlineContent.ts +12 -13
  27. package/src/api/testUtil/cases/customStyles.ts +12 -10
  28. package/src/api/testUtil/index.ts +4 -2
  29. package/src/api/testUtil/partialBlockTestUtil.ts +2 -6
  30. package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +50 -21
  31. package/src/blocks/ImageBlockContent/ImageBlockContent.ts +1 -2
  32. package/src/blocks/ImageBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.ts +8 -1
  33. package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +18 -5
  34. package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +7 -1
  35. package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +18 -5
  36. package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +14 -5
  37. package/src/blocks/defaultBlockHelpers.ts +3 -3
  38. package/src/blocks/defaultBlockTypeGuards.ts +84 -0
  39. package/src/blocks/defaultBlocks.ts +29 -3
  40. package/src/editor/Block.css +2 -31
  41. package/src/editor/BlockNoteEditor.ts +223 -267
  42. package/src/editor/BlockNoteExtensions.ts +5 -2
  43. package/src/editor/BlockNoteSchema.ts +98 -0
  44. package/src/editor/BlockNoteTipTapEditor.ts +162 -0
  45. package/src/editor/cursorPositionTypes.ts +2 -6
  46. package/src/editor/editor.css +0 -1
  47. package/src/editor/selectionTypes.ts +2 -6
  48. package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +22 -29
  49. package/src/extensions/{ImageToolbar → ImagePanel}/ImageToolbarPlugin.ts +54 -60
  50. package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +330 -0
  51. package/src/extensions/Placeholder/PlaceholderExtension.ts +81 -88
  52. package/src/extensions/SideMenu/SideMenuPlugin.ts +55 -56
  53. package/src/extensions/SuggestionMenu/DefaultSuggestionItem.ts +8 -0
  54. package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +353 -0
  55. package/src/extensions/{SlashMenu/defaultSlashMenuItems.ts → SuggestionMenu/getDefaultSlashMenuItems.ts} +119 -89
  56. package/src/extensions/TableHandles/TableHandlesPlugin.ts +62 -45
  57. package/src/extensions-shared/UiElementPosition.ts +4 -0
  58. package/src/index.ts +8 -8
  59. package/src/pm-nodes/BlockContainer.ts +5 -5
  60. package/src/schema/blocks/types.ts +15 -15
  61. package/src/schema/inlineContent/createSpec.ts +2 -2
  62. package/src/schema/inlineContent/types.ts +1 -1
  63. package/src/util/browser.ts +6 -4
  64. package/src/util/typescript.ts +7 -4
  65. package/types/src/api/blockManipulation/blockManipulation.d.ts +6 -1
  66. package/types/src/api/exporters/html/externalHTMLExporter.d.ts +2 -1
  67. package/types/src/api/exporters/html/internalHTMLSerializer.d.ts +2 -1
  68. package/types/src/api/exporters/markdown/markdownExporter.d.ts +2 -1
  69. package/types/src/api/getCurrentBlockContentType.d.ts +2 -0
  70. package/types/src/api/nodeConversions/nodeConversions.d.ts +2 -1
  71. package/types/src/api/parsers/html/parseHTML.d.ts +2 -1
  72. package/types/src/api/parsers/markdown/parseMarkdown.d.ts +2 -1
  73. package/types/src/api/testUtil/cases/customBlocks.d.ts +72 -13
  74. package/types/src/api/testUtil/cases/customInlineContent.d.ts +281 -6
  75. package/types/src/api/testUtil/cases/customStyles.d.ts +247 -13
  76. package/types/src/api/testUtil/index.d.ts +4 -2
  77. package/types/src/api/testUtil/partialBlockTestUtil.d.ts +2 -1
  78. package/types/src/blocks/ImageBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.d.ts +6 -1
  79. package/types/src/blocks/defaultBlockHelpers.d.ts +2 -2
  80. package/types/src/blocks/defaultBlockTypeGuards.d.ts +24 -0
  81. package/types/src/blocks/defaultBlocks.d.ts +21 -15
  82. package/types/src/editor/BlockNoteEditor.d.ts +51 -56
  83. package/types/src/editor/BlockNoteExtensions.d.ts +1 -0
  84. package/types/src/editor/BlockNoteSchema.d.ts +34 -0
  85. package/types/src/editor/BlockNoteTipTapEditor.d.ts +28 -0
  86. package/types/src/editor/cursorPositionTypes.d.ts +2 -1
  87. package/types/src/editor/selectionTypes.d.ts +2 -1
  88. package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +5 -6
  89. package/types/src/extensions/ImagePanel/ImageToolbarPlugin.d.ts +32 -0
  90. package/types/src/extensions/LinkToolbar/LinkToolbarPlugin.d.ts +40 -0
  91. package/types/src/extensions/Placeholder/PlaceholderExtension.d.ts +2 -15
  92. package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +8 -7
  93. package/types/src/extensions/SuggestionMenu/DefaultSuggestionItem.d.ts +8 -0
  94. package/types/src/extensions/SuggestionMenu/SuggestionPlugin.d.ts +31 -0
  95. package/types/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.d.ts +10 -0
  96. package/types/src/extensions/TableHandles/TableHandlesPlugin.d.ts +7 -7
  97. package/types/src/extensions-shared/UiElementPosition.d.ts +4 -0
  98. package/types/src/index.d.ts +8 -8
  99. package/types/src/pm-nodes/BlockContainer.d.ts +3 -2
  100. package/types/src/pm-nodes/BlockGroup.d.ts +1 -1
  101. package/types/src/schema/blocks/types.d.ts +15 -15
  102. package/types/src/schema/inlineContent/types.d.ts +1 -1
  103. package/types/src/util/browser.d.ts +1 -0
  104. package/types/src/util/typescript.d.ts +1 -0
  105. package/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.ts +0 -335
  106. package/src/extensions/SlashMenu/BaseSlashMenuItem.ts +0 -12
  107. package/src/extensions/SlashMenu/SlashMenuPlugin.ts +0 -53
  108. package/src/extensions-shared/BaseUiElementTypes.ts +0 -8
  109. package/src/extensions-shared/README.md +0 -3
  110. package/src/extensions-shared/suggestion/SuggestionItem.ts +0 -3
  111. package/src/extensions-shared/suggestion/SuggestionPlugin.ts +0 -448
  112. package/types/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.d.ts +0 -38
  113. package/types/src/extensions/ImageToolbar/ImageToolbarPlugin.d.ts +0 -31
  114. package/types/src/extensions/SlashMenu/BaseSlashMenuItem.d.ts +0 -7
  115. package/types/src/extensions/SlashMenu/SlashMenuPlugin.d.ts +0 -13
  116. package/types/src/extensions/SlashMenu/defaultSlashMenuItems.d.ts +0 -3
  117. package/types/src/extensions-shared/BaseUiElementTypes.d.ts +0 -7
  118. package/types/src/extensions-shared/suggestion/SuggestionItem.d.ts +0 -3
  119. package/types/src/extensions-shared/suggestion/SuggestionPlugin.d.ts +0 -36
  120. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-100.woff +0 -0
  121. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-100.woff2 +0 -0
  122. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-200.woff +0 -0
  123. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-200.woff2 +0 -0
  124. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-300.woff +0 -0
  125. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-300.woff2 +0 -0
  126. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-500.woff +0 -0
  127. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-500.woff2 +0 -0
  128. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-600.woff +0 -0
  129. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-600.woff2 +0 -0
  130. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-700.woff +0 -0
  131. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-700.woff2 +0 -0
  132. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-800.woff +0 -0
  133. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-800.woff2 +0 -0
  134. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-900.woff +0 -0
  135. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-900.woff2 +0 -0
  136. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-regular.woff +0 -0
  137. /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-regular.woff2 +0 -0
  138. /package/src/{assets/fonts-inter.css → fonts/inter.css} +0 -0
@@ -1 +1 @@
1
- {"builtAt":1706797867089,"assets":[{"name":"blocknote.umd.cjs","size":100892},{"name":"blocknote.umd.cjs.map","size":454885}],"chunks":[{"id":"a1ee98a","entry":true,"initial":true,"files":["blocknote.umd.cjs"],"names":["index"]}],"modules":[{"name":"./src/extensions/UniqueID/UniqueID.ts","size":8518,"chunks":["a1ee98a"]},{"name":"./src/api/getBlockInfoFromPos.ts","size":1691,"chunks":["a1ee98a"]},{"name":"./src/schema/inlineContent/types.ts","size":302,"chunks":["a1ee98a"]},{"name":"./src/util/typescript.ts","size":108,"chunks":["a1ee98a"]},{"name":"./src/api/nodeConversions/nodeConversions.ts","size":11959,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/html/util/sharedHTMLConversion.ts","size":2272,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/html/util/simplifyBlocksRehypePlugin.ts","size":2687,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/html/externalHTMLExporter.ts","size":1059,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/html/internalHTMLSerializer.ts","size":697,"chunks":["a1ee98a"]},{"name":"./src/blocks/ImageBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.ts","size":316,"chunks":["a1ee98a"]},{"name":"./src/util/browser.ts","size":432,"chunks":["a1ee98a"]},{"name":"./src/blocks/defaultBlockHelpers.ts","size":1724,"chunks":["a1ee98a"]},{"name":"./src/blocks/defaultProps.ts","size":269,"chunks":["a1ee98a"]},{"name":"./src/util/string.ts","size":108,"chunks":["a1ee98a"]},{"name":"./src/schema/blocks/internal.ts","size":3701,"chunks":["a1ee98a"]},{"name":"./src/schema/blocks/createSpec.ts","size":2781,"chunks":["a1ee98a"]},{"name":"./src/schema/inlineContent/internal.ts","size":1357,"chunks":["a1ee98a"]},{"name":"./src/schema/inlineContent/createSpec.ts","size":1613,"chunks":["a1ee98a"]},{"name":"./src/schema/styles/internal.ts","size":1162,"chunks":["a1ee98a"]},{"name":"./src/schema/styles/createSpec.ts","size":1263,"chunks":["a1ee98a"]},{"name":"./src/extensions/BackgroundColor/BackgroundColorMark.ts","size":946,"chunks":["a1ee98a"]},{"name":"./src/extensions/TextColor/TextColorMark.ts","size":866,"chunks":["a1ee98a"]},{"name":"./src/blocks/HeadingBlockContent/HeadingBlockContent.ts","size":2796,"chunks":["a1ee98a"]},{"name":"./src/util/EventEmitter.ts","size":744,"chunks":["a1ee98a"]},{"name":"./src/extensions/ImageToolbar/ImageToolbarPlugin.ts","size":3772,"chunks":["a1ee98a"]},{"name":"./src/blocks/ImageBlockContent/ImageBlockContent.ts","size":9277,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts","size":1106,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts","size":2691,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts","size":1862,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts","size":3148,"chunks":["a1ee98a"]},{"name":"./src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts","size":1002,"chunks":["a1ee98a"]},{"name":"./src/blocks/TableBlockContent/TableExtension.ts","size":1462,"chunks":["a1ee98a"]},{"name":"./src/blocks/TableBlockContent/TableBlockContent.ts","size":1207,"chunks":["a1ee98a"]},{"name":"./src/blocks/defaultBlocks.ts","size":1025,"chunks":["a1ee98a"]},{"name":"./src/api/nodeUtil.ts","size":548,"chunks":["a1ee98a"]},{"name":"./src/api/blockManipulation/blockManipulation.ts","size":4471,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/markdown/removeUnderlinesRehypePlugin.ts","size":752,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/markdown/markdownExporter.ts","size":549,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/html/util/nestedLists.ts","size":2022,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/html/parseHTML.ts","size":503,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/markdown/parseMarkdown.ts","size":1054,"chunks":["a1ee98a"]},{"name":"./src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts","size":4985,"chunks":["a1ee98a"]},{"name":"./src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.ts","size":7599,"chunks":["a1ee98a"]},{"name":"./src/extensions-shared/suggestion/SuggestionPlugin.ts","size":9492,"chunks":["a1ee98a"]},{"name":"./src/extensions/SlashMenu/SlashMenuPlugin.ts","size":839,"chunks":["a1ee98a"]},{"name":"./src/extensions/SideMenu/MultipleNodeSelection.ts","size":1616,"chunks":["a1ee98a"]},{"name":"./src/extensions/SideMenu/SideMenuPlugin.ts","size":15225,"chunks":["a1ee98a"]},{"name":"./src/extensions/SlashMenu/defaultSlashMenuItems.ts","size":4114,"chunks":["a1ee98a"]},{"name":"./src/extensions/TableHandles/TableHandlesPlugin.ts","size":14723,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/copyExtension.ts","size":2883,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/pasteExtension.ts","size":1131,"chunks":["a1ee98a"]},{"name":"./src/extensions/BackgroundColor/BackgroundColorExtension.ts","size":688,"chunks":["a1ee98a"]},{"name":"./src/extensions/Placeholder/PlaceholderExtension.ts","size":2106,"chunks":["a1ee98a"]},{"name":"./src/extensions/TextAlignment/TextAlignmentExtension.ts","size":748,"chunks":["a1ee98a"]},{"name":"./src/extensions/TextColor/TextColorExtension.ts","size":622,"chunks":["a1ee98a"]},{"name":"./src/extensions/TrailingNode/TrailingNodeExtension.ts","size":1594,"chunks":["a1ee98a"]},{"name":"./src/extensions/NonEditableBlocks/NonEditableBlockPlugin.ts","size":467,"chunks":["a1ee98a"]},{"name":"./src/extensions/PreviousBlockType/PreviousBlockTypePlugin.ts","size":4572,"chunks":["a1ee98a"]},{"name":"./src/pm-nodes/BlockContainer.ts","size":17223,"chunks":["a1ee98a"]},{"name":"./src/pm-nodes/BlockGroup.ts","size":1097,"chunks":["a1ee98a"]},{"name":"./src/pm-nodes/Doc.ts","size":90,"chunks":["a1ee98a"]},{"name":"./src/editor/BlockNoteExtensions.ts","size":3467,"chunks":["a1ee98a"]},{"name":"./src/editor/transformPasted.ts","size":1017,"chunks":["a1ee98a"]},{"name":"./src/editor/Block.css","size":17,"chunks":["a1ee98a"]},{"name":"./src/editor/editor.css","size":18,"chunks":["a1ee98a"]},{"name":"./src/editor/BlockNoteEditor.ts","size":22032,"chunks":["a1ee98a"]},{"name":"./src/api/testUtil/partialBlockTestUtil.ts","size":2166,"chunks":["a1ee98a"]},{"name":"./src/index.ts","size":0,"chunks":["a1ee98a"]}]}
1
+ {"builtAt":1710505056891,"assets":[{"name":"blocknote.umd.cjs","size":103230},{"name":"blocknote.umd.cjs.map","size":466910}],"chunks":[{"id":"a1ee98a","entry":true,"initial":true,"files":["blocknote.umd.cjs"],"names":["index"]}],"modules":[{"name":"./src/extensions/UniqueID/UniqueID.ts","size":8518,"chunks":["a1ee98a"]},{"name":"./src/api/getBlockInfoFromPos.ts","size":1691,"chunks":["a1ee98a"]},{"name":"./src/schema/inlineContent/types.ts","size":302,"chunks":["a1ee98a"]},{"name":"./src/util/typescript.ts","size":108,"chunks":["a1ee98a"]},{"name":"./src/api/nodeConversions/nodeConversions.ts","size":11959,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/html/util/sharedHTMLConversion.ts","size":2293,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/html/util/simplifyBlocksRehypePlugin.ts","size":2687,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/html/externalHTMLExporter.ts","size":1066,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/html/internalHTMLSerializer.ts","size":704,"chunks":["a1ee98a"]},{"name":"./src/blocks/ImageBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.ts","size":316,"chunks":["a1ee98a"]},{"name":"./src/util/browser.ts","size":515,"chunks":["a1ee98a"]},{"name":"./src/blocks/defaultBlockHelpers.ts","size":1731,"chunks":["a1ee98a"]},{"name":"./src/blocks/defaultProps.ts","size":269,"chunks":["a1ee98a"]},{"name":"./src/util/string.ts","size":108,"chunks":["a1ee98a"]},{"name":"./src/schema/blocks/internal.ts","size":3701,"chunks":["a1ee98a"]},{"name":"./src/schema/blocks/createSpec.ts","size":2781,"chunks":["a1ee98a"]},{"name":"./src/schema/inlineContent/internal.ts","size":1357,"chunks":["a1ee98a"]},{"name":"./src/schema/inlineContent/createSpec.ts","size":1627,"chunks":["a1ee98a"]},{"name":"./src/schema/styles/internal.ts","size":1162,"chunks":["a1ee98a"]},{"name":"./src/schema/styles/createSpec.ts","size":1263,"chunks":["a1ee98a"]},{"name":"./src/extensions/BackgroundColor/BackgroundColorMark.ts","size":946,"chunks":["a1ee98a"]},{"name":"./src/extensions/TextColor/TextColorMark.ts","size":866,"chunks":["a1ee98a"]},{"name":"./src/api/getCurrentBlockContentType.ts","size":192,"chunks":["a1ee98a"]},{"name":"./src/blocks/HeadingBlockContent/HeadingBlockContent.ts","size":3439,"chunks":["a1ee98a"]},{"name":"./src/blocks/ImageBlockContent/ImageBlockContent.ts","size":9280,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts","size":1151,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts","size":2964,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts","size":1862,"chunks":["a1ee98a"]},{"name":"./src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts","size":3421,"chunks":["a1ee98a"]},{"name":"./src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts","size":1172,"chunks":["a1ee98a"]},{"name":"./src/blocks/TableBlockContent/TableExtension.ts","size":1462,"chunks":["a1ee98a"]},{"name":"./src/blocks/TableBlockContent/TableBlockContent.ts","size":1207,"chunks":["a1ee98a"]},{"name":"./src/blocks/defaultBlocks.ts","size":1025,"chunks":["a1ee98a"]},{"name":"./src/blocks/defaultBlockTypeGuards.ts","size":757,"chunks":["a1ee98a"]},{"name":"./src/api/nodeUtil.ts","size":548,"chunks":["a1ee98a"]},{"name":"./src/api/blockManipulation/blockManipulation.ts","size":5738,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/markdown/removeUnderlinesRehypePlugin.ts","size":752,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/markdown/markdownExporter.ts","size":549,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/html/util/nestedLists.ts","size":2174,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/html/parseHTML.ts","size":503,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/markdown/parseMarkdown.ts","size":1054,"chunks":["a1ee98a"]},{"name":"./src/util/EventEmitter.ts","size":744,"chunks":["a1ee98a"]},{"name":"./src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts","size":4664,"chunks":["a1ee98a"]},{"name":"./src/extensions/LinkToolbar/LinkToolbarPlugin.ts","size":6822,"chunks":["a1ee98a"]},{"name":"./src/extensions/SuggestionMenu/SuggestionPlugin.ts","size":7620,"chunks":["a1ee98a"]},{"name":"./src/extensions/SideMenu/MultipleNodeSelection.ts","size":1616,"chunks":["a1ee98a"]},{"name":"./src/extensions/SideMenu/SideMenuPlugin.ts","size":14923,"chunks":["a1ee98a"]},{"name":"./src/extensions/ImagePanel/ImageToolbarPlugin.ts","size":3482,"chunks":["a1ee98a"]},{"name":"./src/extensions/TableHandles/TableHandlesPlugin.ts","size":14755,"chunks":["a1ee98a"]},{"name":"./src/api/exporters/copyExtension.ts","size":2883,"chunks":["a1ee98a"]},{"name":"./src/api/parsers/pasteExtension.ts","size":1131,"chunks":["a1ee98a"]},{"name":"./src/extensions/BackgroundColor/BackgroundColorExtension.ts","size":688,"chunks":["a1ee98a"]},{"name":"./src/extensions/Placeholder/PlaceholderExtension.ts","size":2880,"chunks":["a1ee98a"]},{"name":"./src/extensions/TextAlignment/TextAlignmentExtension.ts","size":748,"chunks":["a1ee98a"]},{"name":"./src/extensions/TextColor/TextColorExtension.ts","size":622,"chunks":["a1ee98a"]},{"name":"./src/extensions/TrailingNode/TrailingNodeExtension.ts","size":1594,"chunks":["a1ee98a"]},{"name":"./src/extensions/NonEditableBlocks/NonEditableBlockPlugin.ts","size":467,"chunks":["a1ee98a"]},{"name":"./src/extensions/PreviousBlockType/PreviousBlockTypePlugin.ts","size":4572,"chunks":["a1ee98a"]},{"name":"./src/pm-nodes/BlockContainer.ts","size":17235,"chunks":["a1ee98a"]},{"name":"./src/pm-nodes/BlockGroup.ts","size":1097,"chunks":["a1ee98a"]},{"name":"./src/pm-nodes/Doc.ts","size":90,"chunks":["a1ee98a"]},{"name":"./src/editor/BlockNoteExtensions.ts","size":3536,"chunks":["a1ee98a"]},{"name":"./src/editor/transformPasted.ts","size":1017,"chunks":["a1ee98a"]},{"name":"./src/editor/BlockNoteSchema.ts","size":827,"chunks":["a1ee98a"]},{"name":"./src/editor/BlockNoteTipTapEditor.ts","size":2514,"chunks":["a1ee98a"]},{"name":"./src/editor/Block.css","size":17,"chunks":["a1ee98a"]},{"name":"./src/editor/editor.css","size":18,"chunks":["a1ee98a"]},{"name":"./src/editor/BlockNoteEditor.ts","size":22844,"chunks":["a1ee98a"]},{"name":"./src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts","size":5300,"chunks":["a1ee98a"]},{"name":"./src/api/testUtil/partialBlockTestUtil.ts","size":2166,"chunks":["a1ee98a"]},{"name":"./src/index.ts","size":0,"chunks":["a1ee98a"]}]}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "homepage": "https://github.com/TypeCellOS/BlockNote",
4
4
  "private": false,
5
5
  "license": "MPL-2.0",
6
- "version": "0.11.2",
6
+ "version": "0.12.1",
7
7
  "files": [
8
8
  "dist",
9
9
  "types",
@@ -37,6 +37,10 @@
37
37
  "./style.css": {
38
38
  "import": "./dist/style.css",
39
39
  "require": "./dist/style.css"
40
+ },
41
+ "./fonts/inter.css": {
42
+ "import": "./src/fonts/inter.css",
43
+ "require": "./src/fonts/inter.css"
40
44
  }
41
45
  },
42
46
  "scripts": {
@@ -98,7 +102,7 @@
98
102
  "prettier": "^2.7.1",
99
103
  "rimraf": "^5.0.5",
100
104
  "rollup-plugin-webpack-stats": "^0.2.2",
101
- "typescript": "^5.0.4",
105
+ "typescript": "^5.3.3",
102
106
  "vite": "^4.4.8",
103
107
  "vite-plugin-eslint": "^1.8.1",
104
108
  "vitest": "^0.34.1"
@@ -112,5 +116,5 @@
112
116
  "access": "public",
113
117
  "registry": "https://registry.npmjs.org/"
114
118
  },
115
- "gitHead": "f83314be0a714548e7a9ae7e10dd24573ce9901b"
119
+ "gitHead": "686622a5185330515ba1ad60d73c7a3800f2a561"
116
120
  }
@@ -1,13 +1,15 @@
1
1
  import { afterEach, beforeEach, describe, expect, it } from "vitest";
2
2
  import {
3
+ Block,
3
4
  DefaultBlockSchema,
4
5
  DefaultInlineContentSchema,
5
6
  DefaultStyleSchema,
7
+ PartialBlock,
6
8
  } from "../../blocks/defaultBlocks";
7
9
  import { BlockNoteEditor } from "../../editor/BlockNoteEditor";
8
- import { Block, PartialBlock } from "../../schema/blocks/types";
9
10
 
10
11
  let editor: BlockNoteEditor;
12
+ const div = document.createElement("div");
11
13
 
12
14
  function waitForEditor() {
13
15
  // wait for create event on editor,
@@ -42,6 +44,7 @@ let insert: (
42
44
 
43
45
  beforeEach(() => {
44
46
  editor = BlockNoteEditor.create();
47
+ editor.mount(div);
45
48
 
46
49
  singleBlock = {
47
50
  type: "paragraph",
@@ -84,14 +87,15 @@ beforeEach(() => {
84
87
  ];
85
88
 
86
89
  insert = (placement) => {
87
- const existingBlock = editor.topLevelBlocks[0];
90
+ const existingBlock = editor.document[0];
88
91
  editor.insertBlocks(multipleBlocks, existingBlock, placement);
89
92
 
90
- return editor.topLevelBlocks;
93
+ return editor.document;
91
94
  };
92
95
  });
93
96
 
94
97
  afterEach(() => {
98
+ editor.mount(undefined);
95
99
  editor._tiptapEditor.destroy();
96
100
  editor = undefined as any;
97
101
  });
@@ -172,12 +176,12 @@ describe("Insert, Update, & Delete Blocks", () => {
172
176
  it("Insert, update, & delete single block", async () => {
173
177
  await waitForEditor();
174
178
 
175
- const existingBlock = editor.topLevelBlocks[0];
179
+ const existingBlock = editor.document[0];
176
180
  editor.insertBlocks([singleBlock], existingBlock);
177
181
 
178
- expect(editor.topLevelBlocks).toMatchSnapshot();
182
+ expect(editor.document).toMatchSnapshot();
179
183
 
180
- const newBlock = editor.topLevelBlocks[0];
184
+ const newBlock = editor.document[0];
181
185
  editor.updateBlock(newBlock, {
182
186
  type: "heading",
183
187
  props: {
@@ -203,32 +207,32 @@ describe("Insert, Update, & Delete Blocks", () => {
203
207
  children: [singleBlock],
204
208
  });
205
209
 
206
- expect(editor.topLevelBlocks).toMatchSnapshot();
210
+ expect(editor.document).toMatchSnapshot();
207
211
 
208
- const updatedBlock = editor.topLevelBlocks[0];
212
+ const updatedBlock = editor.document[0];
209
213
  editor.removeBlocks([updatedBlock]);
210
214
 
211
- expect(editor.topLevelBlocks).toMatchSnapshot();
215
+ expect(editor.document).toMatchSnapshot();
212
216
  });
213
217
 
214
218
  it("Insert, update, & delete multiple blocks", async () => {
215
219
  await waitForEditor();
216
220
 
217
- const existingBlock = editor.topLevelBlocks[0];
221
+ const existingBlock = editor.document[0];
218
222
  editor.insertBlocks(multipleBlocks, existingBlock);
219
223
 
220
- expect(editor.topLevelBlocks).toMatchSnapshot();
224
+ expect(editor.document).toMatchSnapshot();
221
225
 
222
- const newBlock = editor.topLevelBlocks[0];
226
+ const newBlock = editor.document[0];
223
227
  editor.updateBlock(newBlock, {
224
228
  type: "paragraph",
225
229
  });
226
230
 
227
- expect(editor.topLevelBlocks).toMatchSnapshot();
231
+ expect(editor.document).toMatchSnapshot();
228
232
 
229
- const updatedBlocks = editor.topLevelBlocks.slice(0, 2);
233
+ const updatedBlocks = editor.document.slice(0, 2);
230
234
  editor.removeBlocks([updatedBlocks[0].children[0], updatedBlocks[1]]);
231
235
 
232
- expect(editor.topLevelBlocks).toMatchSnapshot();
236
+ expect(editor.document).toMatchSnapshot();
233
237
  });
234
238
  });
@@ -1,17 +1,17 @@
1
1
  import { Node } from "prosemirror-model";
2
2
 
3
+ import { selectionToInsertionEnd } from "@tiptap/core";
4
+ import { Transaction } from "prosemirror-state";
5
+ import { Block, PartialBlock } from "../../blocks/defaultBlocks";
3
6
  import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
4
7
  import {
5
- Block,
6
8
  BlockIdentifier,
7
9
  BlockSchema,
8
10
  InlineContentSchema,
9
- PartialBlock,
10
11
  StyleSchema,
11
12
  } from "../../schema";
12
13
  import { blockToNode, nodeToBlock } from "../nodeConversions/nodeConversions";
13
14
  import { getNodeById } from "../nodeUtil";
14
- import { Transaction } from "prosemirror-state";
15
15
 
16
16
  export function insertBlocks<
17
17
  BSchema extends BlockSchema,
@@ -31,7 +31,7 @@ export function insertBlocks<
31
31
  const nodesToInsert: Node[] = [];
32
32
  for (const blockSpec of blocksToInsert) {
33
33
  nodesToInsert.push(
34
- blockToNode(blockSpec, ttEditor.schema, editor.styleSchema)
34
+ blockToNode(blockSpec, ttEditor.schema, editor.schema.styleSchema)
35
35
  );
36
36
  }
37
37
 
@@ -73,9 +73,9 @@ export function insertBlocks<
73
73
  insertedBlocks.push(
74
74
  nodeToBlock(
75
75
  node,
76
- editor.blockSchema,
77
- editor.inlineContentSchema,
78
- editor.styleSchema,
76
+ editor.schema.blockSchema,
77
+ editor.schema.inlineContentSchema,
78
+ editor.schema.styleSchema,
79
79
  editor.blockCache
80
80
  )
81
81
  );
@@ -107,9 +107,9 @@ export function updateBlock<
107
107
 
108
108
  return nodeToBlock(
109
109
  blockContainerNode,
110
- editor.blockSchema,
111
- editor.inlineContentSchema,
112
- editor.styleSchema,
110
+ editor.schema.blockSchema,
111
+ editor.schema.inlineContentSchema,
112
+ editor.schema.styleSchema,
113
113
  editor.blockCache
114
114
  );
115
115
  }
@@ -158,9 +158,9 @@ function removeBlocksWithCallback<
158
158
  removedBlocks.push(
159
159
  nodeToBlock(
160
160
  node,
161
- editor.blockSchema,
162
- editor.inlineContentSchema,
163
- editor.styleSchema,
161
+ editor.schema.blockSchema,
162
+ editor.schema.inlineContentSchema,
163
+ editor.schema.styleSchema,
164
164
  editor.blockCache
165
165
  )
166
166
  );
@@ -218,7 +218,9 @@ export function replaceBlocks<
218
218
 
219
219
  const nodesToInsert: Node[] = [];
220
220
  for (const block of blocksToInsert) {
221
- nodesToInsert.push(blockToNode(block, ttEditor.schema, editor.styleSchema));
221
+ nodesToInsert.push(
222
+ blockToNode(block, ttEditor.schema, editor.schema.styleSchema)
223
+ );
222
224
  }
223
225
 
224
226
  const idOfFirstBlock =
@@ -248,9 +250,9 @@ export function replaceBlocks<
248
250
  insertedBlocks.push(
249
251
  nodeToBlock(
250
252
  node,
251
- editor.blockSchema,
252
- editor.inlineContentSchema,
253
- editor.styleSchema,
253
+ editor.schema.blockSchema,
254
+ editor.schema.inlineContentSchema,
255
+ editor.schema.styleSchema,
254
256
  editor.blockCache
255
257
  )
256
258
  );
@@ -258,3 +260,91 @@ export function replaceBlocks<
258
260
 
259
261
  return { insertedBlocks, removedBlocks };
260
262
  }
263
+
264
+ // similar to tiptap insertContentAt
265
+ export function insertContentAt<
266
+ BSchema extends BlockSchema,
267
+ I extends InlineContentSchema,
268
+ S extends StyleSchema
269
+ >(
270
+ position: any,
271
+ nodes: Node[],
272
+ editor: BlockNoteEditor<BSchema, I, S>,
273
+ options: {
274
+ updateSelection: boolean;
275
+ } = { updateSelection: true }
276
+ ) {
277
+ const ttEditor = editor._tiptapEditor;
278
+ const tr = ttEditor.state.tr;
279
+
280
+ // don’t dispatch an empty fragment because this can lead to strange errors
281
+ // if (content.toString() === "<>") {
282
+ // return true;
283
+ // }
284
+
285
+ let { from, to } =
286
+ typeof position === "number"
287
+ ? { from: position, to: position }
288
+ : { from: position.from, to: position.to };
289
+
290
+ let isOnlyTextContent = true;
291
+ let isOnlyBlockContent = true;
292
+ // const nodes = isFragment(content) ? content : [content];
293
+
294
+ let text = "";
295
+
296
+ nodes.forEach((node) => {
297
+ // check if added node is valid
298
+ node.check();
299
+
300
+ if (isOnlyTextContent && node.isText && node.marks.length === 0) {
301
+ text += node.text;
302
+ } else {
303
+ isOnlyTextContent = false;
304
+ }
305
+
306
+ isOnlyBlockContent = isOnlyBlockContent ? node.isBlock : false;
307
+ });
308
+
309
+ // check if we can replace the wrapping node by
310
+ // the newly inserted content
311
+ // example:
312
+ // replace an empty paragraph by an inserted image
313
+ // instead of inserting the image below the paragraph
314
+ if (from === to && isOnlyBlockContent) {
315
+ const { parent } = tr.doc.resolve(from);
316
+ const isEmptyTextBlock =
317
+ parent.isTextblock && !parent.type.spec.code && !parent.childCount;
318
+
319
+ if (isEmptyTextBlock) {
320
+ from -= 1;
321
+ to += 1;
322
+ }
323
+ }
324
+
325
+ // if there is only plain text we have to use `insertText`
326
+ // because this will keep the current marks
327
+ if (isOnlyTextContent) {
328
+ // if value is string, we can use it directly
329
+ // otherwise if it is an array, we have to join it
330
+ // if (Array.isArray(value)) {
331
+ // tr.insertText(value.map((v) => v.text || "").join(""), from, to);
332
+ // } else if (typeof value === "object" && !!value && !!value.text) {
333
+ // tr.insertText(value.text, from, to);
334
+ // } else {
335
+ // tr.insertText(value as string, from, to);
336
+ // }
337
+ tr.insertText(text, from, to);
338
+ } else {
339
+ tr.replaceWith(from, to, nodes);
340
+ }
341
+
342
+ // set cursor at end of inserted content
343
+ if (options.updateSelection) {
344
+ selectionToInsertionEnd(tr, tr.steps.length - 1, -1);
345
+ }
346
+
347
+ ttEditor.view.dispatch(tr);
348
+
349
+ return true;
350
+ }
@@ -3,13 +3,9 @@ import rehypeParse from "rehype-parse";
3
3
  import rehypeStringify from "rehype-stringify";
4
4
  import { unified } from "unified";
5
5
 
6
+ import { PartialBlock } from "../../../blocks/defaultBlocks";
6
7
  import type { BlockNoteEditor } from "../../../editor/BlockNoteEditor";
7
- import {
8
- BlockSchema,
9
- InlineContentSchema,
10
- PartialBlock,
11
- StyleSchema,
12
- } from "../../../schema";
8
+ import { BlockSchema, InlineContentSchema, StyleSchema } from "../../../schema";
13
9
  import { blockToNode } from "../../nodeConversions/nodeConversions";
14
10
  import {
15
11
  serializeNodeInner,
@@ -87,7 +83,7 @@ export const createExternalHTMLExporter = <
87
83
 
88
84
  serializer.exportBlocks = (blocks: PartialBlock<BSchema, I, S>[]) => {
89
85
  const nodes = blocks.map((block) =>
90
- blockToNode(block, schema, editor.styleSchema)
86
+ blockToNode(block, schema, editor.schema.styleSchema)
91
87
  );
92
88
  const blockGroup = schema.nodes["blockGroup"].create(null, nodes);
93
89
 
@@ -2,7 +2,8 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest";
2
2
  import { BlockNoteEditor } from "../../../editor/BlockNoteEditor";
3
3
 
4
4
  import { addIdsToBlocks, partialBlocksToBlocksForTesting } from "../../..";
5
- import { BlockSchema, PartialBlock } from "../../../schema/blocks/types";
5
+ import { PartialBlock } from "../../../blocks/defaultBlocks";
6
+ import { BlockSchema } from "../../../schema/blocks/types";
6
7
  import { InlineContentSchema } from "../../../schema/inlineContent/types";
7
8
  import { StyleSchema } from "../../../schema/styles/types";
8
9
  import { customBlocksTestCases } from "../../testUtil/cases/customBlocks";
@@ -38,7 +39,7 @@ async function convertToHTMLAndCompareSnapshots<
38
39
 
39
40
  // turn the internalHTML back into blocks, and make sure no data was lost
40
41
  const fullBlocks = partialBlocksToBlocksForTesting(
41
- editor.blockSchema,
42
+ editor.schema.blockSchema,
42
43
  blocks
43
44
  );
44
45
  const parsed = await editor.tryParseHTMLToBlocks(internalHTML);
@@ -71,12 +72,14 @@ describe("Test HTML conversion", () => {
71
72
  for (const testCase of testCases) {
72
73
  describe("Case: " + testCase.name, () => {
73
74
  let editor: BlockNoteEditor<any, any, any>;
74
-
75
+ const div = document.createElement("div");
75
76
  beforeEach(() => {
76
77
  editor = testCase.createEditor();
78
+ editor.mount(div);
77
79
  });
78
80
 
79
81
  afterEach(() => {
82
+ editor.mount(undefined);
80
83
  editor._tiptapEditor.destroy();
81
84
  editor = undefined as any;
82
85
 
@@ -1,11 +1,7 @@
1
1
  import { DOMSerializer, Fragment, Node, Schema } from "prosemirror-model";
2
+ import { PartialBlock } from "../../../blocks/defaultBlocks";
2
3
  import type { BlockNoteEditor } from "../../../editor/BlockNoteEditor";
3
- import {
4
- BlockSchema,
5
- InlineContentSchema,
6
- PartialBlock,
7
- StyleSchema,
8
- } from "../../../schema";
4
+ import { BlockSchema, InlineContentSchema, StyleSchema } from "../../../schema";
9
5
  import { blockToNode } from "../../nodeConversions/nodeConversions";
10
6
  import {
11
7
  serializeNodeInner,
@@ -69,7 +65,7 @@ export const createInternalHTMLSerializer = <
69
65
 
70
66
  serializer.serializeBlocks = (blocks: PartialBlock<BSchema, I, S>[]) => {
71
67
  const nodes = blocks.map((block) =>
72
- blockToNode(block, schema, editor.styleSchema)
68
+ blockToNode(block, schema, editor.schema.styleSchema)
73
69
  );
74
70
  const blockGroup = schema.nodes["blockGroup"].create(null, nodes);
75
71
 
@@ -71,9 +71,9 @@ export const serializeNodeInner = <
71
71
  const blockContent = toHTML(
72
72
  nodeToBlock(
73
73
  node,
74
- editor.blockSchema,
75
- editor.inlineContentSchema,
76
- editor.styleSchema,
74
+ editor.schema.blockSchema,
75
+ editor.schema.inlineContentSchema,
76
+ editor.schema.styleSchema,
77
77
  editor.blockCache
78
78
  ),
79
79
  editor as any
@@ -1,15 +1,16 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { afterEach, beforeEach, describe, expect, it } from "vitest";
4
+ import { PartialBlock } from "../../../blocks/defaultBlocks";
4
5
  import { BlockNoteEditor } from "../../../editor/BlockNoteEditor";
5
- import { BlockSchema, PartialBlock } from "../../../schema/blocks/types";
6
+ import { BlockSchema } from "../../../schema/blocks/types";
6
7
  import { InlineContentSchema } from "../../../schema/inlineContent/types";
7
8
  import { StyleSchema } from "../../../schema/styles/types";
8
- import { partialBlocksToBlocksForTesting } from "../../testUtil/partialBlockTestUtil";
9
9
  import { customBlocksTestCases } from "../../testUtil/cases/customBlocks";
10
10
  import { customInlineContentTestCases } from "../../testUtil/cases/customInlineContent";
11
11
  import { customStylesTestCases } from "../../testUtil/cases/customStyles";
12
12
  import { defaultSchemaTestCases } from "../../testUtil/cases/defaultSchema";
13
+ import { partialBlocksToBlocksForTesting } from "../../testUtil/partialBlockTestUtil";
13
14
 
14
15
  async function convertToMarkdownAndCompareSnapshots<
15
16
  B extends BlockSchema,
@@ -22,7 +23,7 @@ async function convertToMarkdownAndCompareSnapshots<
22
23
  snapshotName: string
23
24
  ) {
24
25
  const fullBlocks = partialBlocksToBlocksForTesting(
25
- editor.blockSchema,
26
+ editor.schema.blockSchema,
26
27
  blocks
27
28
  );
28
29
  const md = await editor.blocksToMarkdownLossy(fullBlocks);
@@ -56,12 +57,15 @@ describe("markdownExporter", () => {
56
57
  for (const testCase of testCases) {
57
58
  describe("Case: " + testCase.name, () => {
58
59
  let editor: BlockNoteEditor<any, any, any>;
60
+ const div = document.createElement("div");
59
61
 
60
62
  beforeEach(() => {
61
63
  editor = testCase.createEditor();
64
+ editor.mount(div);
62
65
  });
63
66
 
64
67
  afterEach(() => {
68
+ editor.mount(undefined);
65
69
  editor._tiptapEditor.destroy();
66
70
  editor = undefined as any;
67
71
 
@@ -4,13 +4,9 @@ import rehypeRemark from "rehype-remark";
4
4
  import remarkGfm from "remark-gfm";
5
5
  import remarkStringify from "remark-stringify";
6
6
  import { unified } from "unified";
7
+ import { Block } from "../../../blocks/defaultBlocks";
7
8
  import type { BlockNoteEditor } from "../../../editor/BlockNoteEditor";
8
- import {
9
- Block,
10
- BlockSchema,
11
- InlineContentSchema,
12
- StyleSchema,
13
- } from "../../../schema";
9
+ import { BlockSchema, InlineContentSchema, StyleSchema } from "../../../schema";
14
10
  import { createExternalHTMLExporter } from "../html/externalHTMLExporter";
15
11
  import { removeUnderlines } from "./removeUnderlinesRehypePlugin";
16
12
 
@@ -0,0 +1,14 @@
1
+ import { Editor } from "@tiptap/core";
2
+ import { getBlockInfoFromPos } from "./getBlockInfoFromPos";
3
+
4
+ // Used to get the content type of the block that the text cursor is in. This is
5
+ // a band-aid fix to prevent input rules and keyboard shortcuts from triggering
6
+ // in tables, but really those should be extended to work with block selections.
7
+ export const getCurrentBlockContentType = (editor: Editor) => {
8
+ const { contentType } = getBlockInfoFromPos(
9
+ editor.state.doc,
10
+ editor.state.selection.from
11
+ );
12
+
13
+ return contentType.spec.content;
14
+ };
@@ -1,12 +1,16 @@
1
1
  import { afterEach, beforeEach, describe, expect, it } from "vitest";
2
2
 
3
3
  import { BlockNoteEditor } from "../../editor/BlockNoteEditor";
4
- import { PartialBlock } from "../../schema/blocks/types";
4
+
5
+ import { PartialBlock } from "../../blocks/defaultBlocks";
5
6
  import { customInlineContentTestCases } from "../testUtil/cases/customInlineContent";
6
7
  import { customStylesTestCases } from "../testUtil/cases/customStyles";
7
8
  import { defaultSchemaTestCases } from "../testUtil/cases/defaultSchema";
9
+ import {
10
+ addIdsToBlock,
11
+ partialBlockToBlockForTesting,
12
+ } from "../testUtil/partialBlockTestUtil";
8
13
  import { blockToNode, nodeToBlock } from "./nodeConversions";
9
- import { addIdsToBlock, partialBlockToBlockForTesting } from "../testUtil/partialBlockTestUtil";
10
14
 
11
15
  function validateConversion(
12
16
  block: PartialBlock<any, any, any>,
@@ -16,20 +20,20 @@ function validateConversion(
16
20
  const node = blockToNode(
17
21
  block,
18
22
  editor._tiptapEditor.schema,
19
- editor.styleSchema
23
+ editor.schema.styleSchema
20
24
  );
21
25
 
22
26
  expect(node).toMatchSnapshot();
23
27
 
24
28
  const outputBlock = nodeToBlock(
25
29
  node,
26
- editor.blockSchema,
27
- editor.inlineContentSchema,
28
- editor.styleSchema
30
+ editor.schema.blockSchema,
31
+ editor.schema.inlineContentSchema,
32
+ editor.schema.styleSchema
29
33
  );
30
34
 
31
35
  const fullOriginalBlock = partialBlockToBlockForTesting(
32
- editor.blockSchema,
36
+ editor.schema.blockSchema,
33
37
  block
34
38
  );
35
39
 
@@ -46,12 +50,15 @@ describe("Test BlockNote-Prosemirror conversion", () => {
46
50
  for (const testCase of testCases) {
47
51
  describe("Case: " + testCase.name, () => {
48
52
  let editor: BlockNoteEditor<any, any, any>;
53
+ const div = document.createElement("div");
49
54
 
50
55
  beforeEach(() => {
51
56
  editor = testCase.createEditor();
57
+ editor.mount(div);
52
58
  });
53
59
 
54
60
  afterEach(() => {
61
+ editor.mount(undefined);
55
62
  editor._tiptapEditor.destroy();
56
63
  editor = undefined as any;
57
64
 
@@ -2,14 +2,12 @@ import { Mark, Node, Schema } from "@tiptap/pm/model";
2
2
 
3
3
  import UniqueID from "../../extensions/UniqueID/UniqueID";
4
4
  import type {
5
- Block,
6
5
  BlockSchema,
7
6
  CustomInlineContentConfig,
8
7
  CustomInlineContentFromConfig,
9
8
  InlineContent,
10
9
  InlineContentFromConfig,
11
10
  InlineContentSchema,
12
- PartialBlock,
13
11
  PartialCustomInlineContentFromConfig,
14
12
  PartialInlineContent,
15
13
  PartialLink,
@@ -21,6 +19,7 @@ import type {
21
19
  } from "../../schema";
22
20
  import { getBlockInfo } from "../getBlockInfoFromPos";
23
21
 
22
+ import type { Block, PartialBlock } from "../../blocks/defaultBlocks";
24
23
  import {
25
24
  isLinkInlineContent,
26
25
  isPartialLinkInlineContent,
@@ -11,6 +11,8 @@ async function parseHTMLAndCompareSnapshots(
11
11
  const view: any = await import("prosemirror-view");
12
12
 
13
13
  const editor = BlockNoteEditor.create();
14
+ const div = document.createElement("div");
15
+ editor.mount(div);
14
16
  const blocks = await editor.tryParseHTMLToBlocks(html);
15
17
 
16
18
  const snapshotPath = "./__snapshots__/paste/" + snapshotName + ".json";
@@ -53,9 +55,11 @@ async function parseHTMLAndCompareSnapshots(
53
55
  // },
54
56
  // } as any);
55
57
 
56
- const pastedBlocks = editor.topLevelBlocks;
58
+ const pastedBlocks = editor.document;
57
59
  pastedBlocks.pop(); // trailing paragraph
58
60
  expect(pastedBlocks).toStrictEqual(blocks);
61
+
62
+ editor.mount(undefined);
59
63
  }
60
64
 
61
65
  describe("Parse HTML", () => {