@blocknote/core 0.17.1 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocknote.js +2774 -1804
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +9 -6
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js +27 -0
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.js +99 -0
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.js +97 -0
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.js +88 -0
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.js +116 -0
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.test.js +106 -0
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/nestBlock/nestBlock.js +57 -0
- package/dist/src/api/blockManipulation/commands/nestBlock/nestBlock.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js +43 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js +27 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js +29 -0
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.js +157 -0
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js +27 -0
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js +64 -0
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js +145 -0
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.test.js +252 -0
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.test.js.map +1 -0
- package/dist/src/api/blockManipulation/insertContentAt.js +64 -0
- package/dist/src/api/blockManipulation/insertContentAt.js.map +1 -0
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js +76 -0
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js.map +1 -0
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.js +33 -0
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.js.map +1 -0
- package/dist/src/api/blockManipulation/setupTestEnv.js +172 -0
- package/dist/src/api/blockManipulation/setupTestEnv.js.map +1 -0
- package/dist/src/api/clipboard/clipboard.test.js +246 -0
- package/dist/src/api/clipboard/clipboard.test.js.map +1 -0
- package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js +8 -0
- package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js.map +1 -0
- package/dist/src/api/clipboard/fromClipboard/fileDropExtension.js +38 -0
- package/dist/src/api/clipboard/fromClipboard/fileDropExtension.js.map +1 -0
- package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js +109 -0
- package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js.map +1 -0
- package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js +26 -0
- package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js.map +1 -0
- package/dist/src/api/clipboard/fromClipboard/pasteExtension.js +57 -0
- package/dist/src/api/clipboard/fromClipboard/pasteExtension.js.map +1 -0
- package/dist/src/api/clipboard/toClipboard/copyExtension.js +132 -0
- package/dist/src/api/clipboard/toClipboard/copyExtension.js.map +1 -0
- package/dist/src/api/exporters/html/externalHTMLExporter.js +35 -0
- package/dist/src/api/exporters/html/externalHTMLExporter.js.map +1 -0
- package/dist/src/api/exporters/html/htmlConversion.test.js +72 -0
- package/dist/src/api/exporters/html/htmlConversion.test.js.map +1 -0
- package/dist/src/api/exporters/html/internalHTMLSerializer.js +21 -0
- package/dist/src/api/exporters/html/internalHTMLSerializer.js.map +1 -0
- package/dist/src/api/exporters/html/util/serializeBlocksExternalHTML.js +141 -0
- package/dist/src/api/exporters/html/util/serializeBlocksExternalHTML.js.map +1 -0
- package/dist/src/api/exporters/html/util/serializeBlocksInternalHTML.js +96 -0
- package/dist/src/api/exporters/html/util/serializeBlocksInternalHTML.js.map +1 -0
- package/dist/src/api/exporters/markdown/markdownExporter.js +31 -0
- package/dist/src/api/exporters/markdown/markdownExporter.js.map +1 -0
- package/dist/src/api/exporters/markdown/markdownExporter.test.js +57 -0
- package/dist/src/api/exporters/markdown/markdownExporter.test.js.map +1 -0
- package/dist/src/api/exporters/markdown/removeUnderlinesRehypePlugin.js +33 -0
- package/dist/src/api/exporters/markdown/removeUnderlinesRehypePlugin.js.map +1 -0
- package/dist/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.js +37 -0
- package/dist/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.js.map +1 -0
- package/dist/src/api/getBlockInfoFromPos.js +171 -0
- package/dist/src/api/getBlockInfoFromPos.js.map +1 -0
- package/dist/src/api/nodeConversions/blockToNode.js +197 -0
- package/dist/src/api/nodeConversions/blockToNode.js.map +1 -0
- package/dist/src/api/nodeConversions/fragmentToBlocks.js +50 -0
- package/dist/src/api/nodeConversions/fragmentToBlocks.js.map +1 -0
- package/dist/src/api/nodeConversions/nodeConversions.test.js +54 -0
- package/dist/src/api/nodeConversions/nodeConversions.test.js.map +1 -0
- package/dist/src/api/nodeConversions/nodeToBlock.js +316 -0
- package/dist/src/api/nodeConversions/nodeToBlock.js.map +1 -0
- package/dist/src/api/nodeUtil.js +28 -0
- package/dist/src/api/nodeUtil.js.map +1 -0
- package/dist/src/api/parsers/html/parseHTML.js +19 -0
- package/dist/src/api/parsers/html/parseHTML.js.map +1 -0
- package/dist/src/api/parsers/html/parseHTML.test.js +470 -0
- package/dist/src/api/parsers/html/parseHTML.test.js.map +1 -0
- package/dist/src/api/parsers/html/util/nestedLists.js +106 -0
- package/dist/src/api/parsers/html/util/nestedLists.js.map +1 -0
- package/dist/src/api/parsers/html/util/nestedLists.test.js +166 -0
- package/dist/src/api/parsers/html/util/nestedLists.test.js.map +1 -0
- package/dist/src/api/parsers/markdown/parseMarkdown.js +52 -0
- package/dist/src/api/parsers/markdown/parseMarkdown.js.map +1 -0
- package/dist/src/api/parsers/markdown/parseMarkdown.test.js +109 -0
- package/dist/src/api/parsers/markdown/parseMarkdown.test.js.map +1 -0
- package/dist/src/api/testUtil/cases/customBlocks.js +313 -0
- package/dist/src/api/testUtil/cases/customBlocks.js.map +1 -0
- package/dist/src/api/testUtil/cases/customInlineContent.js +91 -0
- package/dist/src/api/testUtil/cases/customInlineContent.js.map +1 -0
- package/dist/src/api/testUtil/cases/customStyles.js +83 -0
- package/dist/src/api/testUtil/cases/customStyles.js.map +1 -0
- package/dist/src/api/testUtil/cases/defaultSchema.js +673 -0
- package/dist/src/api/testUtil/cases/defaultSchema.js.map +1 -0
- package/dist/src/api/testUtil/index.js +2 -0
- package/dist/src/api/testUtil/index.js.map +1 -0
- package/dist/src/api/testUtil/partialBlockTestUtil.js +114 -0
- package/dist/src/api/testUtil/partialBlockTestUtil.js.map +1 -0
- package/dist/src/api/testUtil/paste.js +29 -0
- package/dist/src/api/testUtil/paste.js.map +1 -0
- package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js +97 -0
- package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js.map +1 -0
- package/dist/src/blocks/AudioBlockContent/audioBlockHelpers.js +5 -0
- package/dist/src/blocks/AudioBlockContent/audioBlockHelpers.js.map +1 -0
- package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js +273 -0
- package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js.map +1 -0
- package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js +90 -0
- package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/FileBlockContent.js +70 -0
- package/dist/src/blocks/FileBlockContent/FileBlockContent.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/fileBlockHelpers.js +317 -0
- package/dist/src/blocks/FileBlockContent/fileBlockHelpers.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js +15 -0
- package/dist/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js.map +1 -0
- package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js +141 -0
- package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js.map +1 -0
- package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js +106 -0
- package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js.map +1 -0
- package/dist/src/blocks/ImageBlockContent/imageBlockHelpers.js +6 -0
- package/dist/src/blocks/ImageBlockContent/imageBlockHelpers.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js +111 -0
- package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js +218 -0
- package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js +41 -0
- package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.js +58 -0
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js +128 -0
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js.map +1 -0
- package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js +51 -0
- package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js.map +1 -0
- package/dist/src/blocks/TableBlockContent/TableBlockContent.js +130 -0
- package/dist/src/blocks/TableBlockContent/TableBlockContent.js.map +1 -0
- package/dist/src/blocks/TableBlockContent/TableExtension.js +57 -0
- package/dist/src/blocks/TableBlockContent/TableExtension.js.map +1 -0
- package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js +103 -0
- package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js.map +1 -0
- package/dist/src/blocks/VideoBlockContent/videoBlockHelpers.js +6 -0
- package/dist/src/blocks/VideoBlockContent/videoBlockHelpers.js.map +1 -0
- package/dist/src/blocks/defaultBlockHelpers.js +50 -0
- package/dist/src/blocks/defaultBlockHelpers.js.map +1 -0
- package/dist/src/blocks/defaultBlockTypeGuards.js +40 -0
- package/dist/src/blocks/defaultBlockTypeGuards.js.map +1 -0
- package/dist/src/blocks/defaultBlocks.js +50 -0
- package/dist/src/blocks/defaultBlocks.js.map +1 -0
- package/dist/src/blocks/defaultProps.js +19 -0
- package/dist/src/blocks/defaultProps.js.map +1 -0
- package/dist/src/editor/BlockNoteEditor.js +750 -0
- package/dist/src/editor/BlockNoteEditor.js.map +1 -0
- package/dist/src/editor/BlockNoteEditor.test.js +65 -0
- package/dist/src/editor/BlockNoteEditor.test.js.map +1 -0
- package/dist/src/editor/BlockNoteExtensions.js +149 -0
- package/dist/src/editor/BlockNoteExtensions.js.map +1 -0
- package/dist/src/editor/BlockNoteSchema.js +38 -0
- package/dist/src/editor/BlockNoteSchema.js.map +1 -0
- package/dist/src/editor/BlockNoteTipTapEditor.js +169 -0
- package/dist/src/editor/BlockNoteTipTapEditor.js.map +1 -0
- package/dist/src/editor/cursorPositionTypes.js +2 -0
- package/dist/src/editor/cursorPositionTypes.js.map +1 -0
- package/dist/src/editor/defaultColors.js +77 -0
- package/dist/src/editor/defaultColors.js.map +1 -0
- package/dist/src/editor/selectionTypes.js +2 -0
- package/dist/src/editor/selectionTypes.js.map +1 -0
- package/dist/src/editor/transformPasted.js +79 -0
- package/dist/src/editor/transformPasted.js.map +1 -0
- package/dist/src/exporter/Exporter.js +36 -0
- package/dist/src/exporter/Exporter.js.map +1 -0
- package/dist/src/exporter/index.js +3 -0
- package/dist/src/exporter/index.js.map +1 -0
- package/dist/src/exporter/mapping.js +12 -0
- package/dist/src/exporter/mapping.js.map +1 -0
- package/dist/src/extensions/BackgroundColor/BackgroundColorExtension.js +30 -0
- package/dist/src/extensions/BackgroundColor/BackgroundColorExtension.js.map +1 -0
- package/dist/src/extensions/BackgroundColor/BackgroundColorMark.js +39 -0
- package/dist/src/extensions/BackgroundColor/BackgroundColorMark.js.map +1 -0
- package/dist/src/extensions/FilePanel/FilePanelPlugin.js +131 -0
- package/dist/src/extensions/FilePanel/FilePanelPlugin.js.map +1 -0
- package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js +195 -0
- package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js.map +1 -0
- package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js +309 -0
- package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js.map +1 -0
- package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js +247 -0
- package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js.map +1 -0
- package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js +51 -0
- package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js.map +1 -0
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js +81 -0
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js.map +1 -0
- package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js +183 -0
- package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js.map +1 -0
- package/dist/src/extensions/SideMenu/MultipleNodeSelection.js +68 -0
- package/dist/src/extensions/SideMenu/MultipleNodeSelection.js.map +1 -0
- package/dist/src/extensions/SideMenu/SideMenuPlugin.js +339 -0
- package/dist/src/extensions/SideMenu/SideMenuPlugin.js.map +1 -0
- package/dist/src/extensions/SideMenu/dragging.js +128 -0
- package/dist/src/extensions/SideMenu/dragging.js.map +1 -0
- package/dist/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.js +2 -0
- package/dist/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.js.map +1 -0
- package/dist/src/extensions/SuggestionMenu/DefaultSuggestionItem.js +2 -0
- package/dist/src/extensions/SuggestionMenu/DefaultSuggestionItem.js.map +1 -0
- package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js +245 -0
- package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js.map +1 -0
- package/dist/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.js +26 -0
- package/dist/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.js.map +1 -0
- package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js +244 -0
- package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js.map +1 -0
- package/dist/src/extensions/TableHandles/TableHandlesPlugin.js +553 -0
- package/dist/src/extensions/TableHandles/TableHandlesPlugin.js.map +1 -0
- package/dist/src/extensions/TextAlignment/TextAlignmentExtension.js +36 -0
- package/dist/src/extensions/TextAlignment/TextAlignmentExtension.js.map +1 -0
- package/dist/src/extensions/TextColor/TextColorExtension.js +29 -0
- package/dist/src/extensions/TextColor/TextColorExtension.js.map +1 -0
- package/dist/src/extensions/TextColor/TextColorMark.js +37 -0
- package/dist/src/extensions/TextColor/TextColorMark.js.map +1 -0
- package/dist/src/extensions/TrailingNode/TrailingNodeExtension.js +58 -0
- package/dist/src/extensions/TrailingNode/TrailingNodeExtension.js.map +1 -0
- package/dist/src/extensions/UniqueID/UniqueID.js +283 -0
- package/dist/src/extensions/UniqueID/UniqueID.js.map +1 -0
- package/dist/src/extensions/getDraggableBlockFromElement.js +13 -0
- package/dist/src/extensions/getDraggableBlockFromElement.js.map +1 -0
- package/dist/src/extensions-shared/UiElementPosition.js +2 -0
- package/dist/src/extensions-shared/UiElementPosition.js.map +1 -0
- package/dist/src/i18n/dictionary.js +4 -0
- package/dist/src/i18n/dictionary.js.map +1 -0
- package/dist/src/i18n/locales/ar.js +298 -0
- package/dist/src/i18n/locales/ar.js.map +1 -0
- package/dist/src/i18n/locales/de.js +313 -0
- package/dist/src/i18n/locales/de.js.map +1 -0
- package/dist/src/i18n/locales/en.js +314 -0
- package/dist/src/i18n/locales/en.js.map +1 -0
- package/dist/src/i18n/locales/es.js +312 -0
- package/dist/src/i18n/locales/es.js.map +1 -0
- package/dist/src/i18n/locales/fr.js +313 -0
- package/dist/src/i18n/locales/fr.js.map +1 -0
- package/dist/src/i18n/locales/hr.js +308 -0
- package/dist/src/i18n/locales/hr.js.map +1 -0
- package/dist/src/i18n/locales/index.js +16 -0
- package/dist/src/i18n/locales/index.js.map +1 -0
- package/dist/src/i18n/locales/is.js +305 -0
- package/dist/src/i18n/locales/is.js.map +1 -0
- package/dist/src/i18n/locales/ja.js +333 -0
- package/dist/src/i18n/locales/ja.js.map +1 -0
- package/dist/src/i18n/locales/ko.js +326 -0
- package/dist/src/i18n/locales/ko.js.map +1 -0
- package/dist/src/i18n/locales/nl.js +313 -0
- package/dist/src/i18n/locales/nl.js.map +1 -0
- package/dist/src/i18n/locales/pl.js +297 -0
- package/dist/src/i18n/locales/pl.js.map +1 -0
- package/dist/src/i18n/locales/pt.js +305 -0
- package/dist/src/i18n/locales/pt.js.map +1 -0
- package/dist/src/i18n/locales/ru.js +340 -0
- package/dist/src/i18n/locales/ru.js.map +1 -0
- package/dist/src/i18n/locales/vi.js +312 -0
- package/dist/src/i18n/locales/vi.js.map +1 -0
- package/dist/src/i18n/locales/zh.js +346 -0
- package/dist/src/i18n/locales/zh.js.map +1 -0
- package/dist/src/index.js +55 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/pm-nodes/BlockContainer.js +72 -0
- package/dist/src/pm-nodes/BlockContainer.js.map +1 -0
- package/dist/src/pm-nodes/BlockGroup.js +43 -0
- package/dist/src/pm-nodes/BlockGroup.js.map +1 -0
- package/dist/src/pm-nodes/Doc.js +7 -0
- package/dist/src/pm-nodes/Doc.js.map +1 -0
- package/dist/src/pm-nodes/index.js +4 -0
- package/dist/src/pm-nodes/index.js.map +1 -0
- package/dist/src/schema/blocks/createSpec.js +126 -0
- package/dist/src/schema/blocks/createSpec.js.map +1 -0
- package/dist/src/schema/blocks/internal.js +147 -0
- package/dist/src/schema/blocks/internal.js.map +1 -0
- package/dist/src/schema/blocks/types.js +2 -0
- package/dist/src/schema/blocks/types.js.map +1 -0
- package/dist/src/schema/index.js +11 -0
- package/dist/src/schema/index.js.map +1 -0
- package/dist/src/schema/inlineContent/createSpec.js +64 -0
- package/dist/src/schema/inlineContent/createSpec.js.map +1 -0
- package/dist/src/schema/inlineContent/internal.js +52 -0
- package/dist/src/schema/inlineContent/internal.js.map +1 -0
- package/dist/src/schema/inlineContent/types.js +10 -0
- package/dist/src/schema/inlineContent/types.js.map +1 -0
- package/dist/src/schema/propTypes.js +2 -0
- package/dist/src/schema/propTypes.js.map +1 -0
- package/dist/src/schema/styles/createSpec.js +48 -0
- package/dist/src/schema/styles/createSpec.js.map +1 -0
- package/dist/src/schema/styles/internal.js +53 -0
- package/dist/src/schema/styles/internal.js.map +1 -0
- package/dist/src/schema/styles/types.js +2 -0
- package/dist/src/schema/styles/types.js.map +1 -0
- package/dist/src/util/EventEmitter.js +33 -0
- package/dist/src/util/EventEmitter.js.map +1 -0
- package/dist/src/util/browser.js +17 -0
- package/dist/src/util/browser.js.map +1 -0
- package/dist/src/util/combineByGroup.js +20 -0
- package/dist/src/util/combineByGroup.js.map +1 -0
- package/dist/src/util/esmDependencies.js +35 -0
- package/dist/src/util/esmDependencies.js.map +1 -0
- package/dist/src/util/string.js +14 -0
- package/dist/src/util/string.js.map +1 -0
- package/dist/src/util/typescript.js +12 -0
- package/dist/src/util/typescript.js.map +1 -0
- package/dist/style.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/webpack-stats.json +1 -1
- package/package.json +9 -7
- package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +30 -0
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +2 -0
- package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +25 -0
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +2 -2
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +104 -39
- package/src/api/blockManipulation/commands/moveBlock/__snapshots__/moveBlock.test.ts.snap +40 -0
- package/src/api/blockManipulation/commands/moveBlock/moveBlock.ts +3 -5
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +100 -0
- package/src/api/blockManipulation/commands/removeBlocks/__snapshots__/removeBlocks.test.ts.snap +10 -0
- package/src/api/blockManipulation/commands/removeBlocks/removeBlocks.ts +1 -1
- package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +40 -0
- package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +30 -0
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +8 -4
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +11 -7
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +87 -0
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +5 -5
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +192 -107
- package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.ts +48 -33
- package/src/api/clipboard/clipboard.test.ts +1 -1
- package/src/api/clipboard/fromClipboard/acceptedMIMETypes.ts +1 -0
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +1 -1
- package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +49 -0
- package/src/api/clipboard/fromClipboard/pasteExtension.ts +6 -0
- package/src/api/clipboard/toClipboard/copyExtension.ts +1 -1
- package/src/api/exporters/html/__snapshots__/codeBlock/defaultLanguage/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/codeBlock/defaultLanguage/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/codeBlock/empty/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/codeBlock/empty/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/codeBlock/python/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/codeBlock/python/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/image/basic/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/nested/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/noName/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/noPreview/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/lists/basic/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/lists/nested/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/basic/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/basic/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/nested/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/nested/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noCaption/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noName/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noName/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noPreview/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noPreview/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/table/allColWidths/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/table/allColWidths/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/table/basic/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/table/basic/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/table/mixedColWidths/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/table/mixedColWidths/internal.html +1 -0
- package/src/api/exporters/html/htmlConversion.test.ts +1 -4
- package/src/api/exporters/html/internalHTMLSerializer.ts +2 -7
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +7 -1
- package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +75 -33
- package/src/api/exporters/markdown/__snapshots__/codeBlock/defaultLanguage/markdown.md +3 -0
- package/src/api/exporters/markdown/__snapshots__/codeBlock/empty/markdown.md +2 -0
- package/src/api/exporters/markdown/__snapshots__/codeBlock/python/markdown.md +3 -0
- package/src/api/exporters/markdown/__snapshots__/table/allColWidths/markdown.md +5 -0
- package/src/api/exporters/markdown/__snapshots__/table/basic/markdown.md +5 -0
- package/src/api/exporters/markdown/__snapshots__/table/mixedColWidths/markdown.md +5 -0
- package/src/api/exporters/markdown/markdownExporter.test.ts +1 -4
- package/src/api/getBlockInfoFromPos.ts +113 -58
- package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +711 -0
- package/src/api/nodeConversions/blockToNode.ts +62 -26
- package/src/api/nodeConversions/fragmentToBlocks.ts +18 -0
- package/src/api/nodeConversions/nodeToBlock.ts +35 -22
- package/src/api/nodeUtil.ts +1 -1
- package/src/api/parsers/html/__snapshots__/parse-notion-html.json +5 -0
- package/src/api/parsers/markdown/parseMarkdown.ts +1 -1
- package/src/api/testUtil/cases/defaultSchema.ts +95 -0
- package/src/api/testUtil/partialBlockTestUtil.ts +41 -4
- package/src/blocks/AudioBlockContent/AudioBlockContent.ts +4 -2
- package/src/blocks/CodeBlockContent/CodeBlockContent.ts +369 -0
- package/src/blocks/CodeBlockContent/defaultSupportedLanguages.ts +96 -0
- package/src/blocks/FileBlockContent/fileBlockHelpers.ts +10 -2
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +19 -31
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +4 -2
- package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +5 -9
- package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +6 -10
- package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +1 -1
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +11 -4
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +5 -9
- package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +4 -8
- package/src/blocks/TableBlockContent/TableBlockContent.ts +83 -8
- package/src/blocks/TableBlockContent/TableExtension.ts +10 -1
- package/src/blocks/VideoBlockContent/VideoBlockContent.ts +4 -2
- package/src/blocks/defaultBlockHelpers.ts +7 -2
- package/src/blocks/defaultBlocks.ts +4 -0
- package/src/editor/Block.css +71 -3
- package/src/editor/BlockNoteEditor.test.ts +2 -2
- package/src/editor/BlockNoteEditor.ts +18 -21
- package/src/editor/BlockNoteExtensions.ts +2 -3
- package/src/editor/BlockNoteTipTapEditor.ts +8 -1
- package/src/editor/defaultColors.ts +77 -0
- package/src/editor/editor.css +43 -5
- package/src/editor/transformPasted.ts +6 -3
- package/src/exporter/Exporter.ts +101 -0
- package/src/exporter/index.ts +2 -0
- package/src/exporter/mapping.ts +75 -0
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +8 -0
- package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +201 -48
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.ts +1 -1
- package/src/extensions/Placeholder/PlaceholderPlugin.ts +5 -0
- package/src/extensions/SideMenu/SideMenuPlugin.ts +141 -52
- package/src/extensions/SideMenu/dragging.ts +3 -54
- package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +5 -0
- package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +2 -1
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +22 -6
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +225 -120
- package/src/extensions/TrailingNode/TrailingNodeExtension.ts +1 -1
- package/src/extensions/getDraggableBlockFromElement.ts +19 -0
- package/src/i18n/locales/ar.ts +6 -0
- package/src/i18n/locales/de.ts +299 -294
- package/src/i18n/locales/en.ts +6 -0
- package/src/i18n/locales/es.ts +310 -274
- package/src/i18n/locales/fr.ts +6 -0
- package/src/i18n/locales/is.ts +6 -0
- package/src/i18n/locales/ja.ts +6 -0
- package/src/i18n/locales/ko.ts +6 -0
- package/src/i18n/locales/nl.ts +6 -0
- package/src/i18n/locales/pl.ts +6 -0
- package/src/i18n/locales/pt.ts +10 -4
- package/src/i18n/locales/ru.ts +6 -0
- package/src/i18n/locales/vi.ts +6 -0
- package/src/i18n/locales/zh.ts +6 -0
- package/src/index.ts +9 -0
- package/src/pm-nodes/BlockContainer.ts +1 -1
- package/src/pm-nodes/BlockGroup.ts +2 -2
- package/src/pm-nodes/README.md +127 -28
- package/src/schema/blocks/createSpec.ts +4 -1
- package/src/schema/blocks/internal.ts +12 -2
- package/src/schema/blocks/types.ts +3 -1
- package/src/util/combineByGroup.ts +25 -0
- package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.d.ts +22 -2
- package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.d.ts +5 -0
- package/types/src/api/blockManipulation/setupTestEnv.d.ts +22 -8
- package/types/src/api/clipboard/fromClipboard/acceptedMIMETypes.d.ts +1 -1
- package/types/src/api/clipboard/fromClipboard/handleVSCodePaste.d.ts +3 -0
- package/types/src/api/exporters/html/util/serializeBlocksInternalHTML.d.ts +2 -3
- package/types/src/api/getBlockInfoFromPos.d.ts +55 -5
- package/types/src/api/nodeConversions/blockToNode.d.ts +1 -1
- package/types/src/api/nodeConversions/nodeToBlock.d.ts +3 -1
- package/types/src/api/testUtil/cases/customBlocks.d.ts +22 -8
- package/types/src/api/testUtil/cases/customInlineContent.d.ts +22 -8
- package/types/src/api/testUtil/cases/customStyles.d.ts +22 -8
- package/types/src/api/testUtil/partialBlockTestUtil.d.ts +2 -1
- package/types/src/blocks/AudioBlockContent/AudioBlockContent.d.ts +1 -0
- package/types/src/blocks/CodeBlockContent/CodeBlockContent.d.ts +57 -0
- package/types/src/blocks/CodeBlockContent/defaultSupportedLanguages.d.ts +6 -0
- package/types/src/blocks/FileBlockContent/fileBlockHelpers.d.ts +1 -0
- package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +1 -0
- package/types/src/blocks/TableBlockContent/TableBlockContent.d.ts +0 -12
- package/types/src/blocks/TableBlockContent/TableExtension.d.ts +3 -0
- package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +1 -0
- package/types/src/blocks/defaultBlocks.d.ts +45 -16
- package/types/src/editor/BlockNoteEditor.d.ts +4 -3
- package/types/src/editor/BlockNoteTipTapEditor.d.ts +1 -0
- package/types/src/editor/defaultColors.d.ts +76 -0
- package/types/src/exporter/Exporter.d.ts +43 -0
- package/types/src/exporter/index.d.ts +2 -0
- package/types/src/exporter/mapping.d.ts +30 -0
- package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +2 -1
- package/types/src/extensions/SideMenu/dragging.d.ts +1 -6
- package/types/src/extensions/TableHandles/TableHandlesPlugin.d.ts +9 -5
- package/types/src/extensions/getDraggableBlockFromElement.d.ts +5 -0
- package/types/src/i18n/locales/de.d.ts +6 -0
- package/types/src/i18n/locales/en.d.ts +6 -0
- package/types/src/i18n/locales/es.d.ts +6 -0
- package/types/src/index.d.ts +6 -0
- package/types/src/schema/blocks/createSpec.d.ts +1 -1
- package/types/src/schema/blocks/internal.d.ts +2 -2
- package/types/src/schema/blocks/types.d.ts +3 -1
- package/types/src/util/combineByGroup.d.ts +9 -0
|
@@ -54,7 +54,7 @@ function styledTextToNodes<T extends StyleSchema>(
|
|
|
54
54
|
// Converts text & line breaks to nodes.
|
|
55
55
|
.map((text) => {
|
|
56
56
|
if (text === "\n") {
|
|
57
|
-
return schema.nodes["hardBreak"].
|
|
57
|
+
return schema.nodes["hardBreak"].createChecked();
|
|
58
58
|
} else {
|
|
59
59
|
return schema.text(text, marks);
|
|
60
60
|
}
|
|
@@ -161,21 +161,35 @@ export function tableContentToNodes<
|
|
|
161
161
|
|
|
162
162
|
for (const row of tableContent.rows) {
|
|
163
163
|
const columnNodes: Node[] = [];
|
|
164
|
-
for (
|
|
164
|
+
for (let i = 0; i < row.cells.length; i++) {
|
|
165
|
+
const cell = row.cells[i];
|
|
165
166
|
let pNode: Node;
|
|
166
167
|
if (!cell) {
|
|
167
|
-
pNode = schema.nodes["tableParagraph"].
|
|
168
|
+
pNode = schema.nodes["tableParagraph"].createChecked({});
|
|
168
169
|
} else if (typeof cell === "string") {
|
|
169
|
-
pNode = schema.nodes["tableParagraph"].
|
|
170
|
+
pNode = schema.nodes["tableParagraph"].createChecked(
|
|
171
|
+
{},
|
|
172
|
+
schema.text(cell)
|
|
173
|
+
);
|
|
170
174
|
} else {
|
|
171
175
|
const textNodes = inlineContentToNodes(cell, schema, styleSchema);
|
|
172
|
-
pNode = schema.nodes["tableParagraph"].
|
|
176
|
+
pNode = schema.nodes["tableParagraph"].createChecked({}, textNodes);
|
|
173
177
|
}
|
|
174
178
|
|
|
175
|
-
const cellNode = schema.nodes["tableCell"].
|
|
179
|
+
const cellNode = schema.nodes["tableCell"].createChecked(
|
|
180
|
+
{
|
|
181
|
+
// The colwidth array should have multiple values when the colspan of
|
|
182
|
+
// a cell is greater than 1. However, this is not yet implemented so
|
|
183
|
+
// we can always assume a length of 1.
|
|
184
|
+
colwidth: tableContent.columnWidths?.[i]
|
|
185
|
+
? [tableContent.columnWidths[i]]
|
|
186
|
+
: null,
|
|
187
|
+
},
|
|
188
|
+
pNode
|
|
189
|
+
);
|
|
176
190
|
columnNodes.push(cellNode);
|
|
177
191
|
}
|
|
178
|
-
const rowNode = schema.nodes["tableRow"].
|
|
192
|
+
const rowNode = schema.nodes["tableRow"].createChecked({}, columnNodes);
|
|
179
193
|
rowNodes.push(rowNode);
|
|
180
194
|
}
|
|
181
195
|
return rowNodes;
|
|
@@ -201,16 +215,16 @@ function blockOrInlineContentToContentNode(
|
|
|
201
215
|
}
|
|
202
216
|
|
|
203
217
|
if (!block.content) {
|
|
204
|
-
contentNode = schema.nodes[type].
|
|
218
|
+
contentNode = schema.nodes[type].createChecked(block.props);
|
|
205
219
|
} else if (typeof block.content === "string") {
|
|
206
220
|
const nodes = inlineContentToNodes([block.content], schema, styleSchema);
|
|
207
|
-
contentNode = schema.nodes[type].
|
|
221
|
+
contentNode = schema.nodes[type].createChecked(block.props, nodes);
|
|
208
222
|
} else if (Array.isArray(block.content)) {
|
|
209
223
|
const nodes = inlineContentToNodes(block.content, schema, styleSchema);
|
|
210
|
-
contentNode = schema.nodes[type].
|
|
224
|
+
contentNode = schema.nodes[type].createChecked(block.props, nodes);
|
|
211
225
|
} else if (block.content.type === "tableContent") {
|
|
212
226
|
const nodes = tableContentToNodes(block.content, schema, styleSchema);
|
|
213
|
-
contentNode = schema.nodes[type].
|
|
227
|
+
contentNode = schema.nodes[type].createChecked(block.props, nodes);
|
|
214
228
|
} else {
|
|
215
229
|
throw new UnreachableCaseError(block.content.type);
|
|
216
230
|
}
|
|
@@ -218,7 +232,7 @@ function blockOrInlineContentToContentNode(
|
|
|
218
232
|
}
|
|
219
233
|
|
|
220
234
|
/**
|
|
221
|
-
* Converts a BlockNote block to a
|
|
235
|
+
* Converts a BlockNote block to a Prosemirror node.
|
|
222
236
|
*/
|
|
223
237
|
export function blockToNode(
|
|
224
238
|
block: PartialBlock<any, any, any>,
|
|
@@ -231,12 +245,6 @@ export function blockToNode(
|
|
|
231
245
|
id = UniqueID.options.generateID();
|
|
232
246
|
}
|
|
233
247
|
|
|
234
|
-
const contentNode = blockOrInlineContentToContentNode(
|
|
235
|
-
block,
|
|
236
|
-
schema,
|
|
237
|
-
styleSchema
|
|
238
|
-
);
|
|
239
|
-
|
|
240
248
|
const children: Node[] = [];
|
|
241
249
|
|
|
242
250
|
if (block.children) {
|
|
@@ -245,13 +253,41 @@ export function blockToNode(
|
|
|
245
253
|
}
|
|
246
254
|
}
|
|
247
255
|
|
|
248
|
-
const
|
|
256
|
+
const nodeTypeCorrespondingToBlock = schema.nodes[block.type];
|
|
249
257
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
258
|
+
if (nodeTypeCorrespondingToBlock.isInGroup("blockContent")) {
|
|
259
|
+
// Blocks with a type that matches "blockContent" group always need to be wrapped in a blockContainer
|
|
260
|
+
|
|
261
|
+
const contentNode = blockOrInlineContentToContentNode(
|
|
262
|
+
block,
|
|
263
|
+
schema,
|
|
264
|
+
styleSchema
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
const groupNode =
|
|
268
|
+
children.length > 0
|
|
269
|
+
? schema.nodes["blockGroup"].createChecked({}, children)
|
|
270
|
+
: undefined;
|
|
271
|
+
|
|
272
|
+
return schema.nodes["blockContainer"].createChecked(
|
|
273
|
+
{
|
|
274
|
+
id: id,
|
|
275
|
+
...block.props,
|
|
276
|
+
},
|
|
277
|
+
groupNode ? [contentNode, groupNode] : contentNode
|
|
278
|
+
);
|
|
279
|
+
} else if (nodeTypeCorrespondingToBlock.isInGroup("bnBlock")) {
|
|
280
|
+
// this is a bnBlock node like Column or ColumnList that directly translates to a prosemirror node
|
|
281
|
+
return schema.nodes[block.type].createChecked(
|
|
282
|
+
{
|
|
283
|
+
id: id,
|
|
284
|
+
...block.props,
|
|
285
|
+
},
|
|
286
|
+
children
|
|
287
|
+
);
|
|
288
|
+
} else {
|
|
289
|
+
throw new Error(
|
|
290
|
+
`block type ${block.type} doesn't match blockContent or bnBlock group`
|
|
291
|
+
);
|
|
292
|
+
}
|
|
257
293
|
}
|
|
@@ -43,6 +43,24 @@ export function fragmentToBlocks<
|
|
|
43
43
|
// so we don't need to serialize this block, just descend into the children of the blockGroup
|
|
44
44
|
return true;
|
|
45
45
|
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (node.type.name === "columnList" && node.childCount === 1) {
|
|
49
|
+
// column lists with a single column should be flattened (not the entire column list has been selected)
|
|
50
|
+
node.firstChild?.forEach((child) => {
|
|
51
|
+
blocks.push(
|
|
52
|
+
nodeToBlock(
|
|
53
|
+
child,
|
|
54
|
+
schema.blockSchema,
|
|
55
|
+
schema.inlineContentSchema,
|
|
56
|
+
schema.styleSchema
|
|
57
|
+
)
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (node.type.isInGroup("bnBlock")) {
|
|
46
64
|
blocks.push(
|
|
47
65
|
nodeToBlock(
|
|
48
66
|
node,
|
|
@@ -30,14 +30,24 @@ export function contentNodeToTableContent<
|
|
|
30
30
|
>(contentNode: Node, inlineContentSchema: I, styleSchema: S) {
|
|
31
31
|
const ret: TableContent<I, S> = {
|
|
32
32
|
type: "tableContent",
|
|
33
|
+
columnWidths: [],
|
|
33
34
|
rows: [],
|
|
34
35
|
};
|
|
35
36
|
|
|
36
|
-
contentNode.content.forEach((rowNode) => {
|
|
37
|
+
contentNode.content.forEach((rowNode, _offset, index) => {
|
|
37
38
|
const row: TableContent<I, S>["rows"][0] = {
|
|
38
39
|
cells: [],
|
|
39
40
|
};
|
|
40
41
|
|
|
42
|
+
if (index === 0) {
|
|
43
|
+
rowNode.content.forEach((cellNode) => {
|
|
44
|
+
// The colwidth array should have multiple values when the colspan of a
|
|
45
|
+
// cell is greater than 1. However, this is not yet implemented so we
|
|
46
|
+
// can always assume a length of 1.
|
|
47
|
+
ret.columnWidths.push(cellNode.attrs.colwidth?.[0] || undefined);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
41
51
|
rowNode.content.forEach((cellNode) => {
|
|
42
52
|
row.cells.push(
|
|
43
53
|
contentNodeToInlineContent(
|
|
@@ -296,7 +306,9 @@ export function nodeToCustomInlineContent<
|
|
|
296
306
|
}
|
|
297
307
|
|
|
298
308
|
/**
|
|
299
|
-
* Convert a
|
|
309
|
+
* Convert a Prosemirror node to a BlockNote block.
|
|
310
|
+
*
|
|
311
|
+
* TODO: test changes
|
|
300
312
|
*/
|
|
301
313
|
export function nodeToBlock<
|
|
302
314
|
BSchema extends BlockSchema,
|
|
@@ -309,11 +321,9 @@ export function nodeToBlock<
|
|
|
309
321
|
styleSchema: S,
|
|
310
322
|
blockCache?: WeakMap<Node, Block<BSchema, I, S>>
|
|
311
323
|
): Block<BSchema, I, S> {
|
|
312
|
-
if (node.type.
|
|
324
|
+
if (!node.type.isInGroup("bnBlock")) {
|
|
313
325
|
throw Error(
|
|
314
|
-
"Node must be
|
|
315
|
-
node.type.name +
|
|
316
|
-
"."
|
|
326
|
+
"Node must be in bnBlock group, but is of type" + node.type.name
|
|
317
327
|
);
|
|
318
328
|
}
|
|
319
329
|
|
|
@@ -323,29 +333,26 @@ export function nodeToBlock<
|
|
|
323
333
|
return cachedBlock;
|
|
324
334
|
}
|
|
325
335
|
|
|
326
|
-
const
|
|
327
|
-
getBlockInfoWithManualOffset(node, 0);
|
|
336
|
+
const blockInfo = getBlockInfoWithManualOffset(node, 0);
|
|
328
337
|
|
|
329
|
-
let id =
|
|
338
|
+
let id = blockInfo.bnBlock.node.attrs.id;
|
|
330
339
|
|
|
331
340
|
// Only used for blocks converted from other formats.
|
|
332
341
|
if (id === null) {
|
|
333
342
|
id = UniqueID.options.generateID();
|
|
334
343
|
}
|
|
335
344
|
|
|
345
|
+
const blockSpec = blockSchema[blockInfo.blockNoteType];
|
|
346
|
+
|
|
347
|
+
if (!blockSpec) {
|
|
348
|
+
throw Error("Block is of an unrecognized type: " + blockInfo.blockNoteType);
|
|
349
|
+
}
|
|
350
|
+
|
|
336
351
|
const props: any = {};
|
|
337
352
|
for (const [attr, value] of Object.entries({
|
|
338
353
|
...node.attrs,
|
|
339
|
-
...blockContent.node.attrs,
|
|
354
|
+
...(blockInfo.isBlockContainer ? blockInfo.blockContent.node.attrs : {}),
|
|
340
355
|
})) {
|
|
341
|
-
const blockSpec = blockSchema[blockContent.node.type.name];
|
|
342
|
-
|
|
343
|
-
if (!blockSpec) {
|
|
344
|
-
throw Error(
|
|
345
|
-
"Block is of an unrecognized type: " + blockContent.node.type.name
|
|
346
|
-
);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
356
|
const propSchema = blockSpec.propSchema;
|
|
350
357
|
|
|
351
358
|
if (attr in propSchema) {
|
|
@@ -353,10 +360,10 @@ export function nodeToBlock<
|
|
|
353
360
|
}
|
|
354
361
|
}
|
|
355
362
|
|
|
356
|
-
const blockConfig = blockSchema[
|
|
363
|
+
const blockConfig = blockSchema[blockInfo.blockNoteType];
|
|
357
364
|
|
|
358
365
|
const children: Block<BSchema, I, S>[] = [];
|
|
359
|
-
|
|
366
|
+
blockInfo.childContainer?.node.forEach((child) => {
|
|
360
367
|
children.push(
|
|
361
368
|
nodeToBlock(
|
|
362
369
|
child,
|
|
@@ -371,14 +378,20 @@ export function nodeToBlock<
|
|
|
371
378
|
let content: Block<any, any, any>["content"];
|
|
372
379
|
|
|
373
380
|
if (blockConfig.content === "inline") {
|
|
381
|
+
if (!blockInfo.isBlockContainer) {
|
|
382
|
+
throw new Error("impossible");
|
|
383
|
+
}
|
|
374
384
|
content = contentNodeToInlineContent(
|
|
375
|
-
blockContent.node,
|
|
385
|
+
blockInfo.blockContent.node,
|
|
376
386
|
inlineContentSchema,
|
|
377
387
|
styleSchema
|
|
378
388
|
);
|
|
379
389
|
} else if (blockConfig.content === "table") {
|
|
390
|
+
if (!blockInfo.isBlockContainer) {
|
|
391
|
+
throw new Error("impossible");
|
|
392
|
+
}
|
|
380
393
|
content = contentNodeToTableContent(
|
|
381
|
-
blockContent.node,
|
|
394
|
+
blockInfo.blockContent.node,
|
|
382
395
|
inlineContentSchema,
|
|
383
396
|
styleSchema
|
|
384
397
|
);
|
package/src/api/nodeUtil.ts
CHANGED
|
@@ -17,7 +17,7 @@ export function getNodeById(
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
// Keeps traversing nodes if block with target ID has not been found.
|
|
20
|
-
if (node.type.
|
|
20
|
+
if (!node.type.isInGroup("bnBlock") || node.attrs.id !== id) {
|
|
21
21
|
return true;
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -12,7 +12,7 @@ import { HTMLToBlocks } from "../html/parseHTML.js";
|
|
|
12
12
|
// modified version of https://github.com/syntax-tree/mdast-util-to-hast/blob/main/lib/handlers/code.js
|
|
13
13
|
// that outputs a data-language attribute instead of a CSS class (e.g.: language-typescript)
|
|
14
14
|
function code(state: any, node: any) {
|
|
15
|
-
const value = node.value ? node.value
|
|
15
|
+
const value = node.value ? node.value : "";
|
|
16
16
|
/** @type {Properties} */
|
|
17
17
|
const properties: any = {};
|
|
18
18
|
|
|
@@ -175,6 +175,33 @@ export const defaultSchemaTestCases: EditorTestCases<
|
|
|
175
175
|
},
|
|
176
176
|
],
|
|
177
177
|
},
|
|
178
|
+
{
|
|
179
|
+
name: "codeBlock/empty",
|
|
180
|
+
blocks: [
|
|
181
|
+
{
|
|
182
|
+
type: "codeBlock",
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
name: "codeBlock/defaultLanguage",
|
|
188
|
+
blocks: [
|
|
189
|
+
{
|
|
190
|
+
type: "codeBlock",
|
|
191
|
+
content: "console.log('Hello, world!');",
|
|
192
|
+
},
|
|
193
|
+
],
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
name: "codeBlock/python",
|
|
197
|
+
blocks: [
|
|
198
|
+
{
|
|
199
|
+
type: "codeBlock",
|
|
200
|
+
props: { language: "python" },
|
|
201
|
+
content: "print('Hello, world!')",
|
|
202
|
+
},
|
|
203
|
+
],
|
|
204
|
+
},
|
|
178
205
|
{
|
|
179
206
|
name: "file/button",
|
|
180
207
|
blocks: [
|
|
@@ -332,6 +359,74 @@ export const defaultSchemaTestCases: EditorTestCases<
|
|
|
332
359
|
},
|
|
333
360
|
],
|
|
334
361
|
},
|
|
362
|
+
{
|
|
363
|
+
name: "table/basic",
|
|
364
|
+
blocks: [
|
|
365
|
+
{
|
|
366
|
+
type: "table",
|
|
367
|
+
content: {
|
|
368
|
+
type: "tableContent",
|
|
369
|
+
rows: [
|
|
370
|
+
{
|
|
371
|
+
cells: ["Table Cell", "Table Cell", "Table Cell"],
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
cells: ["Table Cell", "Table Cell", "Table Cell"],
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
cells: ["Table Cell", "Table Cell", "Table Cell"],
|
|
378
|
+
},
|
|
379
|
+
],
|
|
380
|
+
},
|
|
381
|
+
},
|
|
382
|
+
],
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
name: "table/allColWidths",
|
|
386
|
+
blocks: [
|
|
387
|
+
{
|
|
388
|
+
type: "table",
|
|
389
|
+
content: {
|
|
390
|
+
type: "tableContent",
|
|
391
|
+
columnWidths: [100, 200, 300],
|
|
392
|
+
rows: [
|
|
393
|
+
{
|
|
394
|
+
cells: ["Table Cell", "Table Cell", "Table Cell"],
|
|
395
|
+
},
|
|
396
|
+
{
|
|
397
|
+
cells: ["Table Cell", "Table Cell", "Table Cell"],
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
cells: ["Table Cell", "Table Cell", "Table Cell"],
|
|
401
|
+
},
|
|
402
|
+
],
|
|
403
|
+
},
|
|
404
|
+
},
|
|
405
|
+
],
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
name: "table/mixedColWidths",
|
|
409
|
+
blocks: [
|
|
410
|
+
{
|
|
411
|
+
type: "table",
|
|
412
|
+
content: {
|
|
413
|
+
type: "tableContent",
|
|
414
|
+
columnWidths: [100, undefined, 300],
|
|
415
|
+
rows: [
|
|
416
|
+
{
|
|
417
|
+
cells: ["Table Cell", "Table Cell", "Table Cell"],
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
cells: ["Table Cell", "Table Cell", "Table Cell"],
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
cells: ["Table Cell", "Table Cell", "Table Cell"],
|
|
424
|
+
},
|
|
425
|
+
],
|
|
426
|
+
},
|
|
427
|
+
},
|
|
428
|
+
],
|
|
429
|
+
},
|
|
335
430
|
{
|
|
336
431
|
name: "link/basic",
|
|
337
432
|
blocks: [
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Block, PartialBlock } from "../../blocks/defaultBlocks.js";
|
|
2
|
+
import { BlockNoteSchema } from "../../editor/BlockNoteSchema.js";
|
|
2
3
|
import UniqueID from "../../extensions/UniqueID/UniqueID.js";
|
|
3
4
|
import { BlockSchema, TableContent } from "../../schema/blocks/types.js";
|
|
4
5
|
import {
|
|
@@ -54,6 +55,17 @@ function partialContentToInlineContent(
|
|
|
54
55
|
} as any;
|
|
55
56
|
}
|
|
56
57
|
});
|
|
58
|
+
} else if (content?.type === "tableContent") {
|
|
59
|
+
return {
|
|
60
|
+
type: "tableContent",
|
|
61
|
+
columnWidths: content.columnWidths,
|
|
62
|
+
rows: content.rows.map((row) => ({
|
|
63
|
+
...row,
|
|
64
|
+
cells: row.cells.map(
|
|
65
|
+
(cell) => partialContentToInlineContent(cell) as any
|
|
66
|
+
),
|
|
67
|
+
})),
|
|
68
|
+
};
|
|
57
69
|
}
|
|
58
70
|
|
|
59
71
|
return content;
|
|
@@ -64,11 +76,11 @@ export function partialBlocksToBlocksForTesting<
|
|
|
64
76
|
I extends InlineContentSchema,
|
|
65
77
|
S extends StyleSchema
|
|
66
78
|
>(
|
|
67
|
-
schema: BSchema,
|
|
68
|
-
partialBlocks: Array<PartialBlock<BSchema
|
|
79
|
+
schema: BlockNoteSchema<BSchema, I, S>,
|
|
80
|
+
partialBlocks: Array<PartialBlock<NoInfer<BSchema>, NoInfer<I>, NoInfer<S>>>
|
|
69
81
|
): Array<Block<BSchema, I, S>> {
|
|
70
82
|
return partialBlocks.map((partialBlock) =>
|
|
71
|
-
partialBlockToBlockForTesting(schema, partialBlock)
|
|
83
|
+
partialBlockToBlockForTesting(schema.blockSchema, partialBlock)
|
|
72
84
|
);
|
|
73
85
|
}
|
|
74
86
|
|
|
@@ -80,12 +92,19 @@ export function partialBlockToBlockForTesting<
|
|
|
80
92
|
schema: BSchema,
|
|
81
93
|
partialBlock: PartialBlock<BSchema, I, S>
|
|
82
94
|
): Block<BSchema, I, S> {
|
|
95
|
+
const contentType: "inline" | "table" | "none" =
|
|
96
|
+
schema[partialBlock.type!].content;
|
|
97
|
+
|
|
83
98
|
const withDefaults: Block<BSchema, I, S> = {
|
|
84
99
|
id: "",
|
|
85
100
|
type: partialBlock.type!,
|
|
86
101
|
props: {} as any,
|
|
87
102
|
content:
|
|
88
|
-
|
|
103
|
+
contentType === "inline"
|
|
104
|
+
? []
|
|
105
|
+
: contentType === "table"
|
|
106
|
+
? { type: "tableContent", columnWidths: [], rows: [] }
|
|
107
|
+
: (undefined as any),
|
|
89
108
|
children: [] as any,
|
|
90
109
|
...partialBlock,
|
|
91
110
|
};
|
|
@@ -98,6 +117,24 @@ export function partialBlockToBlockForTesting<
|
|
|
98
117
|
}
|
|
99
118
|
);
|
|
100
119
|
|
|
120
|
+
if (contentType === "inline") {
|
|
121
|
+
const content = withDefaults.content as InlineContent<I, S>[] | undefined;
|
|
122
|
+
withDefaults.content = partialContentToInlineContent(content) as any;
|
|
123
|
+
} else if (contentType === "table") {
|
|
124
|
+
const content = withDefaults.content as TableContent<I, S> | undefined;
|
|
125
|
+
withDefaults.content = {
|
|
126
|
+
type: "tableContent",
|
|
127
|
+
columnWidths:
|
|
128
|
+
content?.columnWidths ||
|
|
129
|
+
content?.rows[0]?.cells.map(() => undefined) ||
|
|
130
|
+
[],
|
|
131
|
+
rows:
|
|
132
|
+
content?.rows.map((row) => ({
|
|
133
|
+
cells: row.cells.map((cell) => partialContentToInlineContent(cell)),
|
|
134
|
+
})) || [],
|
|
135
|
+
} as any;
|
|
136
|
+
}
|
|
137
|
+
|
|
101
138
|
return {
|
|
102
139
|
...withDefaults,
|
|
103
140
|
content: partialContentToInlineContent(withDefaults.content),
|
|
@@ -17,6 +17,9 @@ import {
|
|
|
17
17
|
} from "../FileBlockContent/fileBlockHelpers.js";
|
|
18
18
|
import { parseAudioElement } from "./audioBlockHelpers.js";
|
|
19
19
|
|
|
20
|
+
export const FILE_AUDIO_ICON_SVG =
|
|
21
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z"></path></svg>';
|
|
22
|
+
|
|
20
23
|
export const audioPropSchema = {
|
|
21
24
|
backgroundColor: defaultProps.backgroundColor,
|
|
22
25
|
// File name.
|
|
@@ -50,8 +53,7 @@ export const audioRender = (
|
|
|
50
53
|
editor: BlockNoteEditor<any, any, any>
|
|
51
54
|
) => {
|
|
52
55
|
const icon = document.createElement("div");
|
|
53
|
-
icon.innerHTML =
|
|
54
|
-
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z"></path></svg>';
|
|
56
|
+
icon.innerHTML = FILE_AUDIO_ICON_SVG;
|
|
55
57
|
|
|
56
58
|
const audio = document.createElement("audio");
|
|
57
59
|
audio.className = "bn-audio";
|