@blocknote/core 0.16.0 → 0.17.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 (248) hide show
  1. package/dist/blocknote.js +3292 -2755
  2. package/dist/blocknote.js.map +1 -1
  3. package/dist/blocknote.umd.cjs +6 -6
  4. package/dist/blocknote.umd.cjs.map +1 -1
  5. package/dist/webpack-stats.json +1 -1
  6. package/package.json +5 -2
  7. package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +3087 -0
  8. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +132 -0
  9. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +71 -0
  10. package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +2276 -0
  11. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +131 -0
  12. package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +103 -0
  13. package/src/api/blockManipulation/commands/moveBlock/__snapshots__/moveBlock.test.ts.snap +3767 -0
  14. package/src/api/blockManipulation/commands/moveBlock/moveBlock.test.ts +192 -0
  15. package/src/api/blockManipulation/commands/moveBlock/moveBlock.ts +178 -0
  16. package/src/api/blockManipulation/commands/removeBlocks/__snapshots__/removeBlocks.test.ts.snap +1136 -0
  17. package/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.ts +34 -0
  18. package/src/api/blockManipulation/commands/removeBlocks/removeBlocks.ts +100 -0
  19. package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +4931 -0
  20. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +222 -0
  21. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +70 -0
  22. package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +2924 -0
  23. package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +136 -0
  24. package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +48 -0
  25. package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +8376 -0
  26. package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +300 -0
  27. package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +199 -0
  28. package/src/api/blockManipulation/insertContentAt.ts +96 -0
  29. package/src/api/blockManipulation/selections/textCursorPosition/__snapshots__/textCursorPosition.test.ts.snap +316 -0
  30. package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.ts +53 -0
  31. package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.ts +130 -0
  32. package/src/api/blockManipulation/setupTestEnv.ts +179 -0
  33. package/src/api/clipboard/__snapshots__/tableAllCells.html +1 -1
  34. package/src/api/clipboard/clipboard.test.ts +5 -6
  35. package/src/api/clipboard/fromClipboard/fileDropExtension.ts +8 -4
  36. package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +11 -6
  37. package/src/api/clipboard/fromClipboard/pasteExtension.ts +8 -4
  38. package/src/api/clipboard/toClipboard/copyExtension.ts +113 -61
  39. package/src/api/exporters/html/__snapshots__/complex/misc/external.html +1 -1
  40. package/src/api/exporters/html/__snapshots__/lists/basic/external.html +1 -1
  41. package/src/api/exporters/html/__snapshots__/lists/nested/external.html +1 -1
  42. package/src/api/exporters/html/externalHTMLExporter.ts +42 -94
  43. package/src/api/exporters/html/htmlConversion.test.ts +19 -13
  44. package/src/api/exporters/html/internalHTMLSerializer.ts +21 -72
  45. package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +263 -0
  46. package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +158 -0
  47. package/src/api/exporters/markdown/markdownExporter.test.ts +10 -10
  48. package/src/api/exporters/markdown/markdownExporter.ts +11 -7
  49. package/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.ts +2 -2
  50. package/src/api/getBlockInfoFromPos.ts +172 -90
  51. package/src/api/nodeConversions/blockToNode.ts +257 -0
  52. package/src/api/nodeConversions/fragmentToBlocks.ts +60 -0
  53. package/src/api/nodeConversions/nodeConversions.test.ts +9 -8
  54. package/src/api/nodeConversions/{nodeConversions.ts → nodeToBlock.ts} +20 -262
  55. package/src/api/parsers/html/parseHTML.test.ts +2 -2
  56. package/src/api/parsers/html/parseHTML.ts +8 -4
  57. package/src/api/parsers/html/util/nestedLists.test.ts +2 -2
  58. package/src/api/parsers/markdown/parseMarkdown.test.ts +2 -2
  59. package/src/api/parsers/markdown/parseMarkdown.ts +8 -4
  60. package/src/api/testUtil/cases/customBlocks.ts +11 -11
  61. package/src/api/testUtil/cases/customInlineContent.ts +6 -6
  62. package/src/api/testUtil/cases/customStyles.ts +6 -6
  63. package/src/api/testUtil/cases/defaultSchema.ts +4 -4
  64. package/src/api/testUtil/index.ts +6 -6
  65. package/src/api/testUtil/partialBlockTestUtil.ts +5 -5
  66. package/src/blocks/AudioBlockContent/AudioBlockContent.ts +5 -5
  67. package/src/blocks/FileBlockContent/FileBlockContent.ts +4 -4
  68. package/src/blocks/FileBlockContent/fileBlockHelpers.ts +2 -2
  69. package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +61 -39
  70. package/src/blocks/ImageBlockContent/ImageBlockContent.ts +5 -5
  71. package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +30 -18
  72. package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +67 -33
  73. package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +23 -19
  74. package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +22 -24
  75. package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +31 -19
  76. package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +16 -11
  77. package/src/blocks/TableBlockContent/TableBlockContent.ts +4 -4
  78. package/src/blocks/VideoBlockContent/VideoBlockContent.ts +5 -5
  79. package/src/blocks/defaultBlockHelpers.ts +4 -4
  80. package/src/blocks/defaultBlockTypeGuards.ts +5 -5
  81. package/src/blocks/defaultBlocks.ts +13 -13
  82. package/src/blocks/defaultProps.ts +1 -1
  83. package/src/editor/BlockNoteEditor.test.ts +14 -7
  84. package/src/editor/BlockNoteEditor.ts +82 -149
  85. package/src/editor/BlockNoteExtensions.ts +15 -11
  86. package/src/editor/BlockNoteSchema.ts +7 -7
  87. package/src/editor/BlockNoteTipTapEditor.ts +5 -3
  88. package/src/editor/cursorPositionTypes.ts +7 -2
  89. package/src/editor/selectionTypes.ts +6 -2
  90. package/src/extensions/BackgroundColor/BackgroundColorExtension.ts +1 -1
  91. package/src/extensions/BackgroundColor/BackgroundColorMark.ts +1 -1
  92. package/src/extensions/FilePanel/FilePanelPlugin.ts +4 -4
  93. package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +8 -4
  94. package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +334 -0
  95. package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +9 -4
  96. package/src/extensions/{NonEditableBlocks/NonEditableBlockPlugin.ts → NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.ts} +2 -2
  97. package/src/extensions/Placeholder/PlaceholderPlugin.ts +1 -1
  98. package/src/extensions/SideMenu/SideMenuPlugin.ts +72 -401
  99. package/src/extensions/SideMenu/dragging.ts +251 -0
  100. package/src/extensions/SuggestionMenu/DefaultSuggestionItem.ts +1 -1
  101. package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +8 -4
  102. package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +8 -4
  103. package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +19 -15
  104. package/src/extensions/TableHandles/TableHandlesPlugin.ts +11 -7
  105. package/src/extensions/TextColor/TextColorExtension.ts +1 -1
  106. package/src/extensions/TextColor/TextColorMark.ts +1 -1
  107. package/src/i18n/dictionary.ts +1 -1
  108. package/src/i18n/locales/ar.ts +1 -1
  109. package/src/i18n/locales/fr.ts +1 -1
  110. package/src/i18n/locales/hr.ts +308 -0
  111. package/src/i18n/locales/index.ts +15 -14
  112. package/src/i18n/locales/is.ts +1 -1
  113. package/src/i18n/locales/ja.ts +1 -1
  114. package/src/i18n/locales/ko.ts +1 -1
  115. package/src/i18n/locales/nl.ts +1 -1
  116. package/src/i18n/locales/pl.ts +1 -1
  117. package/src/i18n/locales/pt.ts +1 -1
  118. package/src/i18n/locales/ru.ts +1 -1
  119. package/src/i18n/locales/vi.ts +1 -1
  120. package/src/i18n/locales/zh.ts +1 -1
  121. package/src/index.ts +45 -44
  122. package/src/pm-nodes/BlockContainer.ts +3 -647
  123. package/src/pm-nodes/BlockGroup.ts +2 -2
  124. package/src/pm-nodes/index.ts +3 -3
  125. package/src/schema/blocks/createSpec.ts +8 -7
  126. package/src/schema/blocks/internal.ts +9 -9
  127. package/src/schema/blocks/types.ts +4 -4
  128. package/src/schema/index.ts +10 -10
  129. package/src/schema/inlineContent/createSpec.ts +9 -10
  130. package/src/schema/inlineContent/internal.ts +3 -3
  131. package/src/schema/inlineContent/types.ts +2 -2
  132. package/src/schema/styles/createSpec.ts +4 -3
  133. package/src/schema/styles/internal.ts +1 -1
  134. package/types/src/api/blockManipulation/commands/insertBlocks/insertBlocks.d.ts +4 -0
  135. package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.d.ts +7 -0
  136. package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.d.ts +1 -0
  137. package/types/src/api/blockManipulation/commands/moveBlock/moveBlock.d.ts +5 -0
  138. package/types/src/api/blockManipulation/commands/moveBlock/moveBlock.test.d.ts +1 -0
  139. package/types/src/api/blockManipulation/commands/removeBlocks/removeBlocks.d.ts +7 -0
  140. package/types/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.d.ts +1 -0
  141. package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.d.ts +7 -0
  142. package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.d.ts +1 -0
  143. package/types/src/api/blockManipulation/commands/splitBlock/splitBlock.d.ts +5 -0
  144. package/types/src/api/blockManipulation/commands/splitBlock/splitBlock.test.d.ts +1 -0
  145. package/types/src/api/blockManipulation/commands/updateBlock/updateBlock.d.ts +11 -0
  146. package/types/src/api/blockManipulation/commands/updateBlock/updateBlock.test.d.ts +1 -0
  147. package/types/src/api/blockManipulation/insertContentAt.d.ts +6 -0
  148. package/types/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.d.ts +5 -0
  149. package/types/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.d.ts +1 -0
  150. package/types/src/api/blockManipulation/setupTestEnv.d.ts +492 -0
  151. package/types/src/api/clipboard/fromClipboard/fileDropExtension.d.ts +3 -3
  152. package/types/src/api/clipboard/fromClipboard/handleFileInsertion.d.ts +1 -1
  153. package/types/src/api/clipboard/fromClipboard/pasteExtension.d.ts +2 -2
  154. package/types/src/api/clipboard/toClipboard/copyExtension.d.ts +5 -5
  155. package/types/src/api/exporters/html/externalHTMLExporter.d.ts +7 -9
  156. package/types/src/api/exporters/html/internalHTMLSerializer.d.ts +6 -10
  157. package/types/src/api/exporters/html/util/serializeBlocksExternalHTML.d.ts +10 -0
  158. package/types/src/api/exporters/html/util/serializeBlocksInternalHTML.d.ts +11 -0
  159. package/types/src/api/exporters/markdown/markdownExporter.d.ts +3 -3
  160. package/types/src/api/getBlockInfoFromPos.d.ts +63 -20
  161. package/types/src/api/nodeConversions/blockToNode.d.ts +15 -0
  162. package/types/src/api/nodeConversions/fragmentToBlocks.d.ts +7 -0
  163. package/types/src/api/nodeConversions/nodeToBlock.d.ts +16 -0
  164. package/types/src/api/parsers/html/parseHTML.d.ts +2 -2
  165. package/types/src/api/parsers/markdown/parseMarkdown.d.ts +2 -2
  166. package/types/src/api/testUtil/cases/customBlocks.d.ts +39 -39
  167. package/types/src/api/testUtil/cases/customInlineContent.d.ts +35 -35
  168. package/types/src/api/testUtil/cases/customStyles.d.ts +35 -35
  169. package/types/src/api/testUtil/cases/defaultSchema.d.ts +2 -2
  170. package/types/src/api/testUtil/index.d.ts +6 -6
  171. package/types/src/api/testUtil/partialBlockTestUtil.d.ts +4 -4
  172. package/types/src/blocks/AudioBlockContent/AudioBlockContent.d.ts +4 -4
  173. package/types/src/blocks/FileBlockContent/FileBlockContent.d.ts +4 -4
  174. package/types/src/blocks/FileBlockContent/fileBlockHelpers.d.ts +2 -2
  175. package/types/src/blocks/HeadingBlockContent/HeadingBlockContent.d.ts +2 -2
  176. package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +4 -4
  177. package/types/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.d.ts +2 -2
  178. package/types/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.d.ts +2 -2
  179. package/types/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.d.ts +2 -2
  180. package/types/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +2 -2
  181. package/types/src/blocks/ParagraphBlockContent/ParagraphBlockContent.d.ts +2 -2
  182. package/types/src/blocks/TableBlockContent/TableBlockContent.d.ts +2 -2
  183. package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +4 -4
  184. package/types/src/blocks/defaultBlockHelpers.d.ts +3 -3
  185. package/types/src/blocks/defaultBlockTypeGuards.d.ts +4 -4
  186. package/types/src/blocks/defaultBlocks.d.ts +38 -38
  187. package/types/src/blocks/defaultProps.d.ts +1 -1
  188. package/types/src/editor/BlockNoteEditor.d.ts +28 -16
  189. package/types/src/editor/BlockNoteExtensions.d.ts +3 -3
  190. package/types/src/editor/BlockNoteSchema.d.ts +4 -4
  191. package/types/src/editor/BlockNoteTipTapEditor.d.ts +2 -2
  192. package/types/src/editor/cursorPositionTypes.d.ts +3 -2
  193. package/types/src/editor/selectionTypes.d.ts +2 -2
  194. package/types/src/extensions/BackgroundColor/BackgroundColorMark.d.ts +1 -1
  195. package/types/src/extensions/FilePanel/FilePanelPlugin.d.ts +4 -4
  196. package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +4 -4
  197. package/types/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.d.ts +5 -0
  198. package/types/src/extensions/LinkToolbar/LinkToolbarPlugin.d.ts +4 -4
  199. package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.d.ts +2 -0
  200. package/types/src/extensions/Placeholder/PlaceholderPlugin.d.ts +1 -1
  201. package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +12 -28
  202. package/types/src/extensions/SideMenu/dragging.d.ts +17 -0
  203. package/types/src/extensions/SuggestionMenu/DefaultSuggestionItem.d.ts +1 -1
  204. package/types/src/extensions/SuggestionMenu/SuggestionPlugin.d.ts +4 -4
  205. package/types/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.d.ts +3 -3
  206. package/types/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.d.ts +4 -4
  207. package/types/src/extensions/TableHandles/TableHandlesPlugin.d.ts +4 -4
  208. package/types/src/extensions/TextColor/TextColorMark.d.ts +1 -1
  209. package/types/src/i18n/dictionary.d.ts +1 -1
  210. package/types/src/i18n/locales/ar.d.ts +1 -1
  211. package/types/src/i18n/locales/fr.d.ts +1 -1
  212. package/types/src/i18n/locales/hr.d.ts +239 -0
  213. package/types/src/i18n/locales/index.d.ts +15 -14
  214. package/types/src/i18n/locales/is.d.ts +1 -1
  215. package/types/src/i18n/locales/ja.d.ts +1 -1
  216. package/types/src/i18n/locales/ko.d.ts +1 -1
  217. package/types/src/i18n/locales/nl.d.ts +1 -1
  218. package/types/src/i18n/locales/pl.d.ts +1 -1
  219. package/types/src/i18n/locales/pt.d.ts +1 -1
  220. package/types/src/i18n/locales/ru.d.ts +1 -1
  221. package/types/src/i18n/locales/vi.d.ts +1 -1
  222. package/types/src/i18n/locales/zh.d.ts +1 -1
  223. package/types/src/index.d.ts +45 -44
  224. package/types/src/pm-nodes/BlockContainer.d.ts +2 -16
  225. package/types/src/pm-nodes/BlockGroup.d.ts +1 -1
  226. package/types/src/pm-nodes/index.d.ts +3 -3
  227. package/types/src/schema/blocks/createSpec.d.ts +5 -5
  228. package/types/src/schema/blocks/internal.d.ts +5 -5
  229. package/types/src/schema/blocks/types.d.ts +4 -4
  230. package/types/src/schema/index.d.ts +10 -10
  231. package/types/src/schema/inlineContent/createSpec.d.ts +3 -3
  232. package/types/src/schema/inlineContent/internal.d.ts +2 -2
  233. package/types/src/schema/inlineContent/types.d.ts +2 -2
  234. package/types/src/schema/styles/createSpec.d.ts +1 -1
  235. package/types/src/schema/styles/internal.d.ts +1 -1
  236. package/src/api/blockManipulation/__snapshots__/blockManipulation.test.ts.snap +0 -714
  237. package/src/api/blockManipulation/blockManipulation.test.ts +0 -292
  238. package/src/api/blockManipulation/blockManipulation.ts +0 -350
  239. package/src/api/exporters/html/util/sharedHTMLConversion.ts +0 -130
  240. package/src/api/exporters/html/util/simplifyBlocksRehypePlugin.ts +0 -218
  241. package/src/api/getCurrentBlockContentType.ts +0 -14
  242. package/types/src/api/blockManipulation/blockManipulation.d.ts +0 -14
  243. package/types/src/api/exporters/html/util/sharedHTMLConversion.d.ts +0 -9
  244. package/types/src/api/exporters/html/util/simplifyBlocksRehypePlugin.d.ts +0 -16
  245. package/types/src/api/getCurrentBlockContentType.d.ts +0 -2
  246. package/types/src/api/nodeConversions/nodeConversions.d.ts +0 -24
  247. package/types/src/extensions/NonEditableBlocks/NonEditableBlockPlugin.d.ts +0 -2
  248. /package/types/src/api/blockManipulation/{blockManipulation.test.d.ts → commands/insertBlocks/insertBlocks.test.d.ts} +0 -0
@@ -1,27 +1,70 @@
1
- import { Node, NodeType } from "prosemirror-model";
2
- export type BlockInfoWithoutPositions = {
3
- id: string;
1
+ import { Node, ResolvedPos } from "prosemirror-model";
2
+ import { EditorState } from "prosemirror-state";
3
+ type SingleBlockInfo = {
4
4
  node: Node;
5
- contentNode: Node;
6
- contentType: NodeType;
7
- numChildBlocks: number;
5
+ beforePos: number;
6
+ afterPos: number;
8
7
  };
9
- export type BlockInfo = BlockInfoWithoutPositions & {
10
- startPos: number;
11
- endPos: number;
12
- depth: number;
8
+ export type BlockInfo = {
9
+ blockContainer: SingleBlockInfo;
10
+ blockContent: SingleBlockInfo;
11
+ blockGroup?: SingleBlockInfo;
13
12
  };
14
13
  /**
15
- * Helper function for `getBlockInfoFromPos`, returns information regarding
16
- * provided blockContainer node.
17
- * @param blockContainer The blockContainer node to retrieve info for.
14
+ * Retrieves the position just before the nearest blockContainer node in a
15
+ * ProseMirror doc, relative to a position. If the position is within a
16
+ * blockContainer node or its descendants, the position just before it is
17
+ * returned. If the position is not within a blockContainer node or its
18
+ * descendants, the position just before the next closest blockContainer node
19
+ * is returned. If the position is beyond the last blockContainer, the position
20
+ * just before the last blockContainer is returned.
21
+ * @param doc The ProseMirror doc.
22
+ * @param pos An integer position in the document.
23
+ * @returns The position just before the nearest blockContainer node.
24
+ */
25
+ export declare function getNearestBlockContainerPos(doc: Node, pos: number): {
26
+ posBeforeNode: number;
27
+ node: Node;
28
+ };
29
+ /**
30
+ * Gets information regarding the ProseMirror nodes that make up a block in a
31
+ * BlockNote document. This includes the main `blockContainer` node, the
32
+ * `blockContent` node with the block's main body, and the optional `blockGroup`
33
+ * node which contains the block's children. As well as the nodes, also returns
34
+ * the ProseMirror positions just before & after each node.
35
+ * @param node The main `blockContainer` node that the block information should
36
+ * be retrieved from,
37
+ * @param blockContainerBeforePosOffset the position just before the
38
+ * `blockContainer` node in the document.
18
39
  */
19
- export declare function getBlockInfo(blockContainer: Node): BlockInfoWithoutPositions;
40
+ export declare function getBlockInfoWithManualOffset(node: Node, blockContainerBeforePosOffset: number): BlockInfo;
20
41
  /**
21
- * Retrieves information regarding the nearest blockContainer node in a
22
- * ProseMirror doc, relative to a position.
23
- * @param doc The ProseMirror doc.
24
- * @param pos An integer position.
25
- * @returns A BlockInfo object for the nearest blockContainer node.
42
+ * Gets information regarding the ProseMirror nodes that make up a block in a
43
+ * BlockNote document. This includes the main `blockContainer` node, the
44
+ * `blockContent` node with the block's main body, and the optional `blockGroup`
45
+ * node which contains the block's children. As well as the nodes, also returns
46
+ * the ProseMirror positions just before & after each node.
47
+ * @param posInfo An object with the main `blockContainer` node that the block
48
+ * information should be retrieved from, and the position just before it in the
49
+ * document.
50
+ */
51
+ export declare function getBlockInfo(posInfo: {
52
+ posBeforeNode: number;
53
+ node: Node;
54
+ }): BlockInfo;
55
+ /**
56
+ * Gets information regarding the ProseMirror nodes that make up a block from a
57
+ * resolved position just before the `blockContainer` node in the document that
58
+ * corresponds to it.
59
+ * @param resolvedPos The resolved position just before the `blockContainer`
60
+ * node.
61
+ */
62
+ export declare function getBlockInfoFromResolvedPos(resolvedPos: ResolvedPos): BlockInfo;
63
+ /**
64
+ * Gets information regarding the ProseMirror nodes that make up a block. The
65
+ * block chosen is the one currently containing the current ProseMirror
66
+ * selection.
67
+ * @param state The ProseMirror editor state.
26
68
  */
27
- export declare function getBlockInfoFromPos(doc: Node, pos: number): BlockInfo;
69
+ export declare function getBlockInfoFromSelection(state: EditorState): BlockInfo;
70
+ export {};
@@ -0,0 +1,15 @@
1
+ import { Node, Schema } from "@tiptap/pm/model";
2
+ import type { InlineContentSchema, PartialInlineContent, PartialTableContent, StyleSchema } from "../../schema";
3
+ import type { PartialBlock } from "../../blocks/defaultBlocks";
4
+ /**
5
+ * converts an array of inline content elements to prosemirror nodes
6
+ */
7
+ export declare function inlineContentToNodes<I extends InlineContentSchema, S extends StyleSchema>(blockContent: PartialInlineContent<I, S>, schema: Schema, styleSchema: S): Node[];
8
+ /**
9
+ * converts an array of inline content elements to prosemirror nodes
10
+ */
11
+ export declare function tableContentToNodes<I extends InlineContentSchema, S extends StyleSchema>(tableContent: PartialTableContent<I, S>, schema: Schema, styleSchema: StyleSchema): Node[];
12
+ /**
13
+ * Converts a BlockNote block to a TipTap node.
14
+ */
15
+ export declare function blockToNode(block: PartialBlock<any, any, any>, schema: Schema, styleSchema: StyleSchema): Node;
@@ -0,0 +1,7 @@
1
+ import { Fragment } from "@tiptap/pm/model";
2
+ import { BlockNoteSchema } from "../../editor/BlockNoteSchema.js";
3
+ import { BlockNoDefaults, BlockSchema, InlineContentSchema, StyleSchema } from "../../schema/index.js";
4
+ /**
5
+ * Converts all Blocks within a fragment to BlockNote blocks.
6
+ */
7
+ export declare function fragmentToBlocks<B extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(fragment: Fragment, schema: BlockNoteSchema<B, I, S>): BlockNoDefaults<B, I, S>[];
@@ -0,0 +1,16 @@
1
+ import { Node } from "@tiptap/pm/model";
2
+ import type { BlockSchema, InlineContent, InlineContentSchema, StyleSchema, TableContent } from "../../schema/index.js";
3
+ import type { Block } from "../../blocks/defaultBlocks.js";
4
+ /**
5
+ * Converts an internal (prosemirror) table node contentto a BlockNote Tablecontent
6
+ */
7
+ export declare function contentNodeToTableContent<I extends InlineContentSchema, S extends StyleSchema>(contentNode: Node, inlineContentSchema: I, styleSchema: S): TableContent<I, S>;
8
+ /**
9
+ * Converts an internal (prosemirror) content node to a BlockNote InlineContent array.
10
+ */
11
+ export declare function contentNodeToInlineContent<I extends InlineContentSchema, S extends StyleSchema>(contentNode: Node, inlineContentSchema: I, styleSchema: S): InlineContent<I, S>[];
12
+ export declare function nodeToCustomInlineContent<I extends InlineContentSchema, S extends StyleSchema>(node: Node, inlineContentSchema: I, styleSchema: S): InlineContent<I, S>;
13
+ /**
14
+ * Convert a TipTap node to a BlockNote block.
15
+ */
16
+ export declare function nodeToBlock<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(node: Node, blockSchema: BSchema, inlineContentSchema: I, styleSchema: S, blockCache?: WeakMap<Node, Block<BSchema, I, S>>): Block<BSchema, I, S>;
@@ -1,4 +1,4 @@
1
1
  import { Schema } from "prosemirror-model";
2
- import { BlockSchema, InlineContentSchema, StyleSchema } from "../../../schema";
3
- import { Block } from "../../../blocks/defaultBlocks";
2
+ import { BlockSchema, InlineContentSchema, StyleSchema } from "../../../schema/index.js";
3
+ import { Block } from "../../../blocks/defaultBlocks.js";
4
4
  export declare function HTMLToBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(html: string, blockSchema: BSchema, icSchema: I, styleSchema: S, pmSchema: Schema): Promise<Block<BSchema, I, S>[]>;
@@ -1,4 +1,4 @@
1
1
  import { Schema } from "prosemirror-model";
2
- import { Block } from "../../../blocks/defaultBlocks";
3
- import { BlockSchema, InlineContentSchema, StyleSchema } from "../../../schema";
2
+ import { Block } from "../../../blocks/defaultBlocks.js";
3
+ import { BlockSchema, InlineContentSchema, StyleSchema } from "../../../schema/index.js";
4
4
  export declare function markdownToBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(markdown: string, blockSchema: BSchema, icSchema: I, styleSchema: S, pmSchema: Schema): Promise<Block<BSchema, I, S>[]>;
@@ -1,7 +1,7 @@
1
- import { EditorTestCases } from "../index";
2
- import { DefaultInlineContentSchema, DefaultStyleSchema } from "../../../blocks/defaultBlocks";
3
- import { BlockNoteSchema } from "../../../editor/BlockNoteSchema";
4
- declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromSpecs<{
1
+ import { EditorTestCases } from "../index.js";
2
+ import { DefaultInlineContentSchema, DefaultStyleSchema } from "../../../blocks/defaultBlocks.js";
3
+ import { BlockNoteSchema } from "../../../editor/BlockNoteSchema.js";
4
+ declare const schema: BlockNoteSchema<import("../../../schema/index.js").BlockSchemaFromSpecs<{
5
5
  simpleImage: {
6
6
  config: {
7
7
  type: string;
@@ -31,7 +31,7 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
31
31
  };
32
32
  content: "none";
33
33
  };
34
- implementation: import("../../../schema").TiptapBlockImplementation<{
34
+ implementation: import("../../../schema/index.js").TiptapBlockImplementation<{
35
35
  type: string;
36
36
  propSchema: {
37
37
  textAlignment: {
@@ -58,7 +58,7 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
58
58
  };
59
59
  };
60
60
  content: "none";
61
- }, any, import("../../../schema").InlineContentSchema, import("../../../schema").StyleSchema>;
61
+ }, any, import("../../../schema/index.js").InlineContentSchema, import("../../../schema/index.js").StyleSchema>;
62
62
  };
63
63
  customParagraph: {
64
64
  config: {
@@ -77,7 +77,7 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
77
77
  };
78
78
  content: "inline";
79
79
  };
80
- implementation: import("../../../schema").TiptapBlockImplementation<{
80
+ implementation: import("../../../schema/index.js").TiptapBlockImplementation<{
81
81
  type: string;
82
82
  propSchema: {
83
83
  backgroundColor: {
@@ -92,7 +92,7 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
92
92
  };
93
93
  };
94
94
  content: "inline";
95
- }, any, import("../../../schema").InlineContentSchema, import("../../../schema").StyleSchema>;
95
+ }, any, import("../../../schema/index.js").InlineContentSchema, import("../../../schema/index.js").StyleSchema>;
96
96
  };
97
97
  simpleCustomParagraph: {
98
98
  config: {
@@ -111,7 +111,7 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
111
111
  };
112
112
  content: "inline";
113
113
  };
114
- implementation: import("../../../schema").TiptapBlockImplementation<{
114
+ implementation: import("../../../schema/index.js").TiptapBlockImplementation<{
115
115
  type: string;
116
116
  propSchema: {
117
117
  backgroundColor: {
@@ -126,7 +126,7 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
126
126
  };
127
127
  };
128
128
  content: "inline";
129
- }, any, import("../../../schema").InlineContentSchema, import("../../../schema").StyleSchema>;
129
+ }, any, import("../../../schema/index.js").InlineContentSchema, import("../../../schema/index.js").StyleSchema>;
130
130
  };
131
131
  paragraph: {
132
132
  config: {
@@ -145,7 +145,7 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
145
145
  };
146
146
  };
147
147
  };
148
- implementation: import("../../../schema").TiptapBlockImplementation<{
148
+ implementation: import("../../../schema/index.js").TiptapBlockImplementation<{
149
149
  type: "paragraph";
150
150
  content: "inline";
151
151
  propSchema: {
@@ -160,7 +160,7 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
160
160
  values: readonly ["left", "center", "right", "justify"];
161
161
  };
162
162
  };
163
- }, any, import("../../../schema").InlineContentSchema, import("../../../schema").StyleSchema>;
163
+ }, any, import("../../../schema/index.js").InlineContentSchema, import("../../../schema/index.js").StyleSchema>;
164
164
  };
165
165
  heading: {
166
166
  config: {
@@ -183,7 +183,7 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
183
183
  };
184
184
  };
185
185
  };
186
- implementation: import("../../../schema").TiptapBlockImplementation<{
186
+ implementation: import("../../../schema/index.js").TiptapBlockImplementation<{
187
187
  type: "heading";
188
188
  content: "inline";
189
189
  propSchema: {
@@ -202,7 +202,7 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
202
202
  values: readonly ["left", "center", "right", "justify"];
203
203
  };
204
204
  };
205
- }, any, import("../../../schema").InlineContentSchema, import("../../../schema").StyleSchema>;
205
+ }, any, import("../../../schema/index.js").InlineContentSchema, import("../../../schema/index.js").StyleSchema>;
206
206
  };
207
207
  bulletListItem: {
208
208
  config: {
@@ -221,7 +221,7 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
221
221
  };
222
222
  };
223
223
  };
224
- implementation: import("../../../schema").TiptapBlockImplementation<{
224
+ implementation: import("../../../schema/index.js").TiptapBlockImplementation<{
225
225
  type: "bulletListItem";
226
226
  content: "inline";
227
227
  propSchema: {
@@ -236,7 +236,7 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
236
236
  values: readonly ["left", "center", "right", "justify"];
237
237
  };
238
238
  };
239
- }, any, import("../../../schema").InlineContentSchema, import("../../../schema").StyleSchema>;
239
+ }, any, import("../../../schema/index.js").InlineContentSchema, import("../../../schema/index.js").StyleSchema>;
240
240
  };
241
241
  numberedListItem: {
242
242
  config: {
@@ -255,7 +255,7 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
255
255
  };
256
256
  };
257
257
  };
258
- implementation: import("../../../schema").TiptapBlockImplementation<{
258
+ implementation: import("../../../schema/index.js").TiptapBlockImplementation<{
259
259
  type: "numberedListItem";
260
260
  content: "inline";
261
261
  propSchema: {
@@ -270,7 +270,7 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
270
270
  values: readonly ["left", "center", "right", "justify"];
271
271
  };
272
272
  };
273
- }, any, import("../../../schema").InlineContentSchema, import("../../../schema").StyleSchema>;
273
+ }, any, import("../../../schema/index.js").InlineContentSchema, import("../../../schema/index.js").StyleSchema>;
274
274
  };
275
275
  checkListItem: {
276
276
  config: {
@@ -292,7 +292,7 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
292
292
  };
293
293
  };
294
294
  };
295
- implementation: import("../../../schema").TiptapBlockImplementation<{
295
+ implementation: import("../../../schema/index.js").TiptapBlockImplementation<{
296
296
  type: "checkListItem";
297
297
  content: "inline";
298
298
  propSchema: {
@@ -310,7 +310,7 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
310
310
  values: readonly ["left", "center", "right", "justify"];
311
311
  };
312
312
  };
313
- }, any, import("../../../schema").InlineContentSchema, import("../../../schema").StyleSchema>;
313
+ }, any, import("../../../schema/index.js").InlineContentSchema, import("../../../schema/index.js").StyleSchema>;
314
314
  };
315
315
  table: {
316
316
  config: {
@@ -329,7 +329,7 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
329
329
  };
330
330
  };
331
331
  };
332
- implementation: import("../../../schema").TiptapBlockImplementation<{
332
+ implementation: import("../../../schema/index.js").TiptapBlockImplementation<{
333
333
  type: "table";
334
334
  content: "table";
335
335
  propSchema: {
@@ -344,7 +344,7 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
344
344
  values: readonly ["left", "center", "right", "justify"];
345
345
  };
346
346
  };
347
- }, any, import("../../../schema").InlineContentSchema, import("../../../schema").StyleSchema>;
347
+ }, any, import("../../../schema/index.js").InlineContentSchema, import("../../../schema/index.js").StyleSchema>;
348
348
  };
349
349
  file: {
350
350
  config: {
@@ -366,7 +366,7 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
366
366
  content: "none";
367
367
  isFileBlock: true;
368
368
  };
369
- implementation: import("../../../schema").TiptapBlockImplementation<{
369
+ implementation: import("../../../schema/index.js").TiptapBlockImplementation<{
370
370
  type: "file";
371
371
  propSchema: {
372
372
  backgroundColor: {
@@ -384,7 +384,7 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
384
384
  };
385
385
  content: "none";
386
386
  isFileBlock: true;
387
- }, any, import("../../../schema").InlineContentSchema, import("../../../schema").StyleSchema>;
387
+ }, any, import("../../../schema/index.js").InlineContentSchema, import("../../../schema/index.js").StyleSchema>;
388
388
  };
389
389
  image: {
390
390
  config: {
@@ -417,7 +417,7 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
417
417
  isFileBlock: true;
418
418
  fileBlockAccept: string[];
419
419
  };
420
- implementation: import("../../../schema").TiptapBlockImplementation<{
420
+ implementation: import("../../../schema/index.js").TiptapBlockImplementation<{
421
421
  type: "image";
422
422
  propSchema: {
423
423
  textAlignment: {
@@ -446,7 +446,7 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
446
446
  content: "none";
447
447
  isFileBlock: true;
448
448
  fileBlockAccept: string[];
449
- }, any, import("../../../schema").InlineContentSchema, import("../../../schema").StyleSchema>;
449
+ }, any, import("../../../schema/index.js").InlineContentSchema, import("../../../schema/index.js").StyleSchema>;
450
450
  };
451
451
  video: {
452
452
  config: {
@@ -479,7 +479,7 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
479
479
  isFileBlock: true;
480
480
  fileBlockAccept: string[];
481
481
  };
482
- implementation: import("../../../schema").TiptapBlockImplementation<{
482
+ implementation: import("../../../schema/index.js").TiptapBlockImplementation<{
483
483
  type: "video";
484
484
  propSchema: {
485
485
  textAlignment: {
@@ -508,7 +508,7 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
508
508
  content: "none";
509
509
  isFileBlock: true;
510
510
  fileBlockAccept: string[];
511
- }, any, import("../../../schema").InlineContentSchema, import("../../../schema").StyleSchema>;
511
+ }, any, import("../../../schema/index.js").InlineContentSchema, import("../../../schema/index.js").StyleSchema>;
512
512
  };
513
513
  audio: {
514
514
  config: {
@@ -534,7 +534,7 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
534
534
  isFileBlock: true;
535
535
  fileBlockAccept: string[];
536
536
  };
537
- implementation: import("../../../schema").TiptapBlockImplementation<{
537
+ implementation: import("../../../schema/index.js").TiptapBlockImplementation<{
538
538
  type: "audio";
539
539
  propSchema: {
540
540
  backgroundColor: {
@@ -556,9 +556,9 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
556
556
  content: "none";
557
557
  isFileBlock: true;
558
558
  fileBlockAccept: string[];
559
- }, any, import("../../../schema").InlineContentSchema, import("../../../schema").StyleSchema>;
559
+ }, any, import("../../../schema/index.js").InlineContentSchema, import("../../../schema/index.js").StyleSchema>;
560
560
  };
561
- }>, import("../../../schema").InlineContentSchemaFromSpecs<{
561
+ }>, import("../../../schema/index.js").InlineContentSchemaFromSpecs<{
562
562
  text: {
563
563
  config: "text";
564
564
  implementation: any;
@@ -567,55 +567,55 @@ declare const schema: BlockNoteSchema<import("../../../schema").BlockSchemaFromS
567
567
  config: "link";
568
568
  implementation: any;
569
569
  };
570
- }>, import("../../../schema").StyleSchemaFromSpecs<{
570
+ }>, import("../../../schema/index.js").StyleSchemaFromSpecs<{
571
571
  bold: {
572
572
  config: {
573
573
  type: string;
574
574
  propSchema: "boolean";
575
575
  };
576
- implementation: import("../../../schema").StyleImplementation;
576
+ implementation: import("../../../schema/index.js").StyleImplementation;
577
577
  };
578
578
  italic: {
579
579
  config: {
580
580
  type: string;
581
581
  propSchema: "boolean";
582
582
  };
583
- implementation: import("../../../schema").StyleImplementation;
583
+ implementation: import("../../../schema/index.js").StyleImplementation;
584
584
  };
585
585
  underline: {
586
586
  config: {
587
587
  type: string;
588
588
  propSchema: "boolean";
589
589
  };
590
- implementation: import("../../../schema").StyleImplementation;
590
+ implementation: import("../../../schema/index.js").StyleImplementation;
591
591
  };
592
592
  strike: {
593
593
  config: {
594
594
  type: string;
595
595
  propSchema: "boolean";
596
596
  };
597
- implementation: import("../../../schema").StyleImplementation;
597
+ implementation: import("../../../schema/index.js").StyleImplementation;
598
598
  };
599
599
  code: {
600
600
  config: {
601
601
  type: string;
602
602
  propSchema: "boolean";
603
603
  };
604
- implementation: import("../../../schema").StyleImplementation;
604
+ implementation: import("../../../schema/index.js").StyleImplementation;
605
605
  };
606
606
  textColor: {
607
607
  config: {
608
608
  type: string;
609
609
  propSchema: "string";
610
610
  };
611
- implementation: import("../../../schema").StyleImplementation;
611
+ implementation: import("../../../schema/index.js").StyleImplementation;
612
612
  };
613
613
  backgroundColor: {
614
614
  config: {
615
615
  type: string;
616
616
  propSchema: "string";
617
617
  };
618
- implementation: import("../../../schema").StyleImplementation;
618
+ implementation: import("../../../schema/index.js").StyleImplementation;
619
619
  };
620
620
  }>>;
621
621
  export declare const customBlocksTestCases: EditorTestCases<typeof schema.blockSchema, DefaultInlineContentSchema, DefaultStyleSchema>;