@blocknote/core 0.18.0 → 0.19.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.
- package/README.md +2 -0
- package/dist/blocknote.js +3145 -2970
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +9 -9
- 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 +110 -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 +5 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js +31 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js +71 -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 +111 -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 +165 -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 +145 -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 +113 -0
- package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js +224 -0
- package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js +45 -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 +130 -0
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js.map +1 -0
- package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js +52 -0
- package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js.map +1 -0
- package/dist/src/blocks/TableBlockContent/TableBlockContent.js +129 -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 +746 -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 +195 -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 +339 -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 +54 -0
- package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js.map +1 -0
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js +84 -0
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js.map +1 -0
- package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js +187 -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 +5 -5
- package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +0 -6
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +2 -0
- package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +0 -5
- 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 +0 -8
- package/src/api/blockManipulation/commands/moveBlock/moveBlock.test.ts +7 -3
- 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 +439 -2
- package/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.ts +6 -0
- package/src/api/blockManipulation/commands/removeBlocks/removeBlocks.ts +2 -82
- package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +0 -8
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +96 -20
- package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +0 -6
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +8 -4
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +13 -12
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +0 -490
- 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/fromClipboard/acceptedMIMETypes.ts +1 -1
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +7 -6
- package/src/api/clipboard/toClipboard/copyExtension.ts +1 -1
- package/src/api/exporters/html/htmlConversion.test.ts +1 -4
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +7 -1
- package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +56 -19
- package/src/api/exporters/markdown/markdownExporter.test.ts +1 -4
- package/src/api/getBlockInfoFromPos.ts +125 -80
- package/src/api/nodeConversions/blockToNode.ts +50 -25
- package/src/api/nodeConversions/fragmentToBlocks.ts +18 -0
- package/src/api/nodeConversions/nodeToBlock.ts +24 -21
- package/src/api/nodeUtil.ts +1 -1
- package/src/api/parsers/html/__snapshots__/parse-notion-html.json +1 -2
- package/src/api/testUtil/partialBlockTestUtil.ts +15 -3
- package/src/blocks/AudioBlockContent/AudioBlockContent.ts +4 -2
- package/src/blocks/FileBlockContent/fileBlockHelpers.ts +5 -4
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +35 -35
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +4 -2
- package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +14 -12
- package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +28 -16
- package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +5 -3
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +11 -4
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +13 -11
- package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +8 -9
- package/src/blocks/TableBlockContent/TableBlockContent.ts +0 -1
- package/src/blocks/VideoBlockContent/VideoBlockContent.ts +4 -2
- package/src/blocks/defaultBlockHelpers.ts +7 -2
- package/src/editor/Block.css +22 -1
- package/src/editor/BlockNoteEditor.test.ts +4 -7
- package/src/editor/BlockNoteEditor.ts +87 -61
- package/src/editor/BlockNoteExtensions.ts +92 -17
- package/src/editor/BlockNoteTipTapEditor.ts +8 -1
- package/src/editor/defaultColors.ts +77 -0
- package/src/editor/editor.css +10 -0
- 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/KeyboardShortcuts/KeyboardShortcutsExtension.ts +233 -53
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.ts +45 -42
- package/src/extensions/Placeholder/PlaceholderPlugin.ts +94 -90
- package/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.ts +173 -169
- package/src/extensions/SideMenu/SideMenuPlugin.ts +141 -52
- package/src/extensions/SideMenu/dragging.ts +3 -54
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +4 -6
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +1 -1
- package/src/extensions/TrailingNode/TrailingNodeExtension.ts +1 -1
- package/src/extensions/getDraggableBlockFromElement.ts +19 -0
- package/src/i18n/locales/de.ts +5 -5
- package/src/i18n/locales/pt.ts +5 -5
- package/src/index.ts +9 -5
- 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 +1 -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/commands/removeBlocks/removeBlocks.d.ts +0 -3
- package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.d.ts +4 -0
- package/types/src/api/blockManipulation/setupTestEnv.d.ts +0 -6
- package/types/src/api/clipboard/fromClipboard/acceptedMIMETypes.d.ts +1 -1
- package/types/src/api/getBlockInfoFromPos.d.ts +38 -13
- 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 +0 -6
- package/types/src/api/testUtil/cases/customInlineContent.d.ts +0 -6
- package/types/src/api/testUtil/cases/customStyles.d.ts +0 -6
- package/types/src/api/testUtil/partialBlockTestUtil.d.ts +2 -1
- package/types/src/blocks/AudioBlockContent/AudioBlockContent.d.ts +1 -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 -9
- package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +1 -0
- package/types/src/blocks/defaultBlocks.d.ts +0 -12
- package/types/src/editor/BlockNoteEditor.d.ts +23 -5
- package/types/src/editor/BlockNoteExtensions.d.ts +14 -7
- 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/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.d.ts +4 -1
- package/types/src/extensions/Placeholder/PlaceholderPlugin.d.ts +4 -1
- package/types/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.d.ts +4 -5
- package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +2 -1
- package/types/src/extensions/SideMenu/dragging.d.ts +1 -6
- package/types/src/extensions/getDraggableBlockFromElement.d.ts +5 -0
- package/types/src/index.d.ts +9 -5
- 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 +1 -1
- package/types/src/util/combineByGroup.d.ts +9 -0
- package/dist/angular-html-HQGguTAE.js +0 -33
- package/dist/angular-html-HQGguTAE.js.map +0 -1
- package/dist/angular-ts-q9PqJiJb.js +0 -22
- package/dist/angular-ts-q9PqJiJb.js.map +0 -1
- package/dist/astro-0iWgpDaK.js +0 -17
- package/dist/astro-0iWgpDaK.js.map +0 -1
- package/dist/blade-C3Z8AhvY.js +0 -19
- package/dist/blade-C3Z8AhvY.js.map +0 -1
- package/dist/c-TKJGJdXV.js +0 -7
- package/dist/c-TKJGJdXV.js.map +0 -1
- package/dist/coffee-CN_y6cG3.js +0 -9
- package/dist/coffee-CN_y6cG3.js.map +0 -1
- package/dist/cpp-Be_e67JE.js +0 -19
- package/dist/cpp-Be_e67JE.js.map +0 -1
- package/dist/css-DHLSoXzW.js +0 -7
- package/dist/css-DHLSoXzW.js.map +0 -1
- package/dist/glsl-8qSUIm5B.js +0 -9
- package/dist/glsl-8qSUIm5B.js.map +0 -1
- package/dist/graphql-D7_Dk2ma.js +0 -15
- package/dist/graphql-D7_Dk2ma.js.map +0 -1
- package/dist/haml-S3dmcfEW.js +0 -11
- package/dist/haml-S3dmcfEW.js.map +0 -1
- package/dist/handlebars-DaIrqVg3.js +0 -15
- package/dist/handlebars-DaIrqVg3.js.map +0 -1
- package/dist/html-Bx3A18fV.js +0 -11
- package/dist/html-Bx3A18fV.js.map +0 -1
- package/dist/html-derivative-Cf3KTZBS.js +0 -9
- package/dist/html-derivative-Cf3KTZBS.js.map +0 -1
- package/dist/http-BphR83YX.js +0 -15
- package/dist/http-BphR83YX.js.map +0 -1
- package/dist/imba-CmP25v0O.js +0 -9
- package/dist/imba-CmP25v0O.js.map +0 -1
- package/dist/java-Dg4kxH6C.js +0 -7
- package/dist/java-Dg4kxH6C.js.map +0 -1
- package/dist/javascript-CipAzIn1.js +0 -7
- package/dist/javascript-CipAzIn1.js.map +0 -1
- package/dist/jinja-tioldiz6.js +0 -12
- package/dist/jinja-tioldiz6.js.map +0 -1
- package/dist/jison-DWJFEE_I.js +0 -9
- package/dist/jison-DWJFEE_I.js.map +0 -1
- package/dist/json-_04EL6MS.js +0 -7
- package/dist/json-_04EL6MS.js.map +0 -1
- package/dist/json5-Dwmp5XFI.js +0 -7
- package/dist/json5-Dwmp5XFI.js.map +0 -1
- package/dist/jsonc-LqD5auy0.js +0 -7
- package/dist/jsonc-LqD5auy0.js.map +0 -1
- package/dist/jsonl-B4yVuYQH.js +0 -7
- package/dist/jsonl-B4yVuYQH.js.map +0 -1
- package/dist/jsx-Mg4WaD5k.js +0 -7
- package/dist/jsx-Mg4WaD5k.js.map +0 -1
- package/dist/julia-CWi-ZdpN.js +0 -17
- package/dist/julia-CWi-ZdpN.js.map +0 -1
- package/dist/less-BBvTHIGe.js +0 -7
- package/dist/less-BBvTHIGe.js.map +0 -1
- package/dist/markdown-DAXqtk9a.js +0 -7
- package/dist/markdown-DAXqtk9a.js.map +0 -1
- package/dist/marko-0aaNgUGV.js +0 -15
- package/dist/marko-0aaNgUGV.js.map +0 -1
- package/dist/mdc-hXJ2B4O0.js +0 -13
- package/dist/mdc-hXJ2B4O0.js.map +0 -1
- package/dist/mdx-CSCKbb_f.js +0 -7
- package/dist/mdx-CSCKbb_f.js.map +0 -1
- package/dist/php-B_-4RJ09.js +0 -19
- package/dist/php-B_-4RJ09.js.map +0 -1
- package/dist/postcss-SJfTvo_B.js +0 -7
- package/dist/postcss-SJfTvo_B.js.map +0 -1
- package/dist/pug-3q2tx0nf.js +0 -13
- package/dist/pug-3q2tx0nf.js.map +0 -1
- package/dist/python-Dpup1-fE.js +0 -7
- package/dist/python-Dpup1-fE.js.map +0 -1
- package/dist/r-Chyv38Fv.js +0 -7
- package/dist/r-Chyv38Fv.js.map +0 -1
- package/dist/regexp-BF0hfxNW.js +0 -7
- package/dist/regexp-BF0hfxNW.js.map +0 -1
- package/dist/sass-p2RMoqDT.js +0 -7
- package/dist/sass-p2RMoqDT.js.map +0 -1
- package/dist/scss-DmlHSoOY.js +0 -9
- package/dist/scss-DmlHSoOY.js.map +0 -1
- package/dist/shellscript-CZpPN8_x.js +0 -7
- package/dist/shellscript-CZpPN8_x.js.map +0 -1
- package/dist/sql-DtlkUz2m.js +0 -7
- package/dist/sql-DtlkUz2m.js.map +0 -1
- package/dist/stylus-DEr8eSLm.js +0 -7
- package/dist/stylus-DEr8eSLm.js.map +0 -1
- package/dist/svelte-BRIJF62h.js +0 -15
- package/dist/svelte-BRIJF62h.js.map +0 -1
- package/dist/ts-tags-qkUtuI0N.js +0 -42
- package/dist/ts-tags-qkUtuI0N.js.map +0 -1
- package/dist/tsx-DTfbgJxi.js +0 -7
- package/dist/tsx-DTfbgJxi.js.map +0 -1
- package/dist/typescript-CCd4aQHh.js +0 -7
- package/dist/typescript-CCd4aQHh.js.map +0 -1
- package/dist/vue-B3TdbERm.js +0 -32
- package/dist/vue-B3TdbERm.js.map +0 -1
- package/dist/vue-html-BGmTBZk0.js +0 -11
- package/dist/vue-html-BGmTBZk0.js.map +0 -1
- package/dist/wasm-VDIDph3E.js +0 -7
- package/dist/wasm-VDIDph3E.js.map +0 -1
- package/dist/wgsl-2np_U3Z8.js +0 -7
- package/dist/wgsl-2np_U3Z8.js.map +0 -1
- package/dist/xml-CNyphW9R.js +0 -9
- package/dist/xml-CNyphW9R.js.map +0 -1
- package/dist/yaml-DxFiVFcM.js +0 -7
- package/dist/yaml-DxFiVFcM.js.map +0 -1
package/src/api/blockManipulation/commands/removeBlocks/__snapshots__/removeBlocks.test.ts.snap
CHANGED
|
@@ -1,7 +1,58 @@
|
|
|
1
1
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
|
-
exports[`Test removeBlocks > Remove
|
|
3
|
+
exports[`Test removeBlocks > Remove all child blocks 1`] = `
|
|
4
4
|
[
|
|
5
|
+
{
|
|
6
|
+
"children": [],
|
|
7
|
+
"content": [
|
|
8
|
+
{
|
|
9
|
+
"styles": {},
|
|
10
|
+
"text": "Paragraph 0",
|
|
11
|
+
"type": "text",
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
"id": "paragraph-0",
|
|
15
|
+
"props": {
|
|
16
|
+
"backgroundColor": "default",
|
|
17
|
+
"textAlignment": "left",
|
|
18
|
+
"textColor": "default",
|
|
19
|
+
},
|
|
20
|
+
"type": "paragraph",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"children": [],
|
|
24
|
+
"content": [
|
|
25
|
+
{
|
|
26
|
+
"styles": {},
|
|
27
|
+
"text": "Paragraph 1",
|
|
28
|
+
"type": "text",
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
"id": "paragraph-1",
|
|
32
|
+
"props": {
|
|
33
|
+
"backgroundColor": "default",
|
|
34
|
+
"textAlignment": "left",
|
|
35
|
+
"textColor": "default",
|
|
36
|
+
},
|
|
37
|
+
"type": "paragraph",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"children": [],
|
|
41
|
+
"content": [
|
|
42
|
+
{
|
|
43
|
+
"styles": {},
|
|
44
|
+
"text": "Paragraph with children",
|
|
45
|
+
"type": "text",
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
"id": "paragraph-with-children",
|
|
49
|
+
"props": {
|
|
50
|
+
"backgroundColor": "default",
|
|
51
|
+
"textAlignment": "left",
|
|
52
|
+
"textColor": "default",
|
|
53
|
+
},
|
|
54
|
+
"type": "paragraph",
|
|
55
|
+
},
|
|
5
56
|
{
|
|
6
57
|
"children": [],
|
|
7
58
|
"content": [
|
|
@@ -256,8 +307,395 @@ exports[`Test removeBlocks > Remove multiple consecutive blocks 1`] = `
|
|
|
256
307
|
"type": "tableContent",
|
|
257
308
|
},
|
|
258
309
|
"id": "table-0",
|
|
310
|
+
"props": {
|
|
311
|
+
"textColor": "default",
|
|
312
|
+
},
|
|
313
|
+
"type": "table",
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
"children": [],
|
|
317
|
+
"content": [
|
|
318
|
+
{
|
|
319
|
+
"styles": {},
|
|
320
|
+
"text": "Paragraph 7",
|
|
321
|
+
"type": "text",
|
|
322
|
+
},
|
|
323
|
+
],
|
|
324
|
+
"id": "paragraph-7",
|
|
325
|
+
"props": {
|
|
326
|
+
"backgroundColor": "default",
|
|
327
|
+
"textAlignment": "left",
|
|
328
|
+
"textColor": "default",
|
|
329
|
+
},
|
|
330
|
+
"type": "paragraph",
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
"children": [],
|
|
334
|
+
"content": [],
|
|
335
|
+
"id": "empty-paragraph",
|
|
336
|
+
"props": {
|
|
337
|
+
"backgroundColor": "default",
|
|
338
|
+
"textAlignment": "left",
|
|
339
|
+
"textColor": "default",
|
|
340
|
+
},
|
|
341
|
+
"type": "paragraph",
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
"children": [],
|
|
345
|
+
"content": [
|
|
346
|
+
{
|
|
347
|
+
"styles": {},
|
|
348
|
+
"text": "Paragraph 8",
|
|
349
|
+
"type": "text",
|
|
350
|
+
},
|
|
351
|
+
],
|
|
352
|
+
"id": "paragraph-8",
|
|
353
|
+
"props": {
|
|
354
|
+
"backgroundColor": "default",
|
|
355
|
+
"textAlignment": "left",
|
|
356
|
+
"textColor": "default",
|
|
357
|
+
},
|
|
358
|
+
"type": "paragraph",
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
"children": [
|
|
362
|
+
{
|
|
363
|
+
"children": [
|
|
364
|
+
{
|
|
365
|
+
"children": [],
|
|
366
|
+
"content": [
|
|
367
|
+
{
|
|
368
|
+
"styles": {},
|
|
369
|
+
"text": "Double Nested Paragraph 1",
|
|
370
|
+
"type": "text",
|
|
371
|
+
},
|
|
372
|
+
],
|
|
373
|
+
"id": "double-nested-paragraph-1",
|
|
374
|
+
"props": {
|
|
375
|
+
"backgroundColor": "default",
|
|
376
|
+
"textAlignment": "left",
|
|
377
|
+
"textColor": "default",
|
|
378
|
+
},
|
|
379
|
+
"type": "paragraph",
|
|
380
|
+
},
|
|
381
|
+
],
|
|
382
|
+
"content": [
|
|
383
|
+
{
|
|
384
|
+
"styles": {},
|
|
385
|
+
"text": "Nested Paragraph 1",
|
|
386
|
+
"type": "text",
|
|
387
|
+
},
|
|
388
|
+
],
|
|
389
|
+
"id": "nested-paragraph-1",
|
|
390
|
+
"props": {
|
|
391
|
+
"backgroundColor": "default",
|
|
392
|
+
"textAlignment": "left",
|
|
393
|
+
"textColor": "default",
|
|
394
|
+
},
|
|
395
|
+
"type": "paragraph",
|
|
396
|
+
},
|
|
397
|
+
],
|
|
398
|
+
"content": [
|
|
399
|
+
{
|
|
400
|
+
"styles": {
|
|
401
|
+
"bold": true,
|
|
402
|
+
},
|
|
403
|
+
"text": "Heading",
|
|
404
|
+
"type": "text",
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
"styles": {},
|
|
408
|
+
"text": " with styled ",
|
|
409
|
+
"type": "text",
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
"styles": {
|
|
413
|
+
"italic": true,
|
|
414
|
+
},
|
|
415
|
+
"text": "content",
|
|
416
|
+
"type": "text",
|
|
417
|
+
},
|
|
418
|
+
],
|
|
419
|
+
"id": "heading-with-everything",
|
|
420
|
+
"props": {
|
|
421
|
+
"backgroundColor": "red",
|
|
422
|
+
"level": 2,
|
|
423
|
+
"textAlignment": "center",
|
|
424
|
+
"textColor": "red",
|
|
425
|
+
},
|
|
426
|
+
"type": "heading",
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
"children": [],
|
|
430
|
+
"content": [],
|
|
431
|
+
"id": "trailing-paragraph",
|
|
432
|
+
"props": {
|
|
433
|
+
"backgroundColor": "default",
|
|
434
|
+
"textAlignment": "left",
|
|
435
|
+
"textColor": "default",
|
|
436
|
+
},
|
|
437
|
+
"type": "paragraph",
|
|
438
|
+
},
|
|
439
|
+
]
|
|
440
|
+
`;
|
|
441
|
+
|
|
442
|
+
exports[`Test removeBlocks > Remove multiple consecutive blocks 1`] = `
|
|
443
|
+
[
|
|
444
|
+
{
|
|
445
|
+
"children": [],
|
|
446
|
+
"content": [
|
|
447
|
+
{
|
|
448
|
+
"styles": {},
|
|
449
|
+
"text": "Paragraph 2",
|
|
450
|
+
"type": "text",
|
|
451
|
+
},
|
|
452
|
+
],
|
|
453
|
+
"id": "paragraph-2",
|
|
454
|
+
"props": {
|
|
455
|
+
"backgroundColor": "default",
|
|
456
|
+
"textAlignment": "left",
|
|
457
|
+
"textColor": "default",
|
|
458
|
+
},
|
|
459
|
+
"type": "paragraph",
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
"children": [],
|
|
463
|
+
"content": [
|
|
464
|
+
{
|
|
465
|
+
"styles": {},
|
|
466
|
+
"text": "Paragraph with props",
|
|
467
|
+
"type": "text",
|
|
468
|
+
},
|
|
469
|
+
],
|
|
470
|
+
"id": "paragraph-with-props",
|
|
471
|
+
"props": {
|
|
472
|
+
"backgroundColor": "default",
|
|
473
|
+
"textAlignment": "center",
|
|
474
|
+
"textColor": "red",
|
|
475
|
+
},
|
|
476
|
+
"type": "paragraph",
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
"children": [],
|
|
480
|
+
"content": [
|
|
481
|
+
{
|
|
482
|
+
"styles": {},
|
|
483
|
+
"text": "Paragraph 3",
|
|
484
|
+
"type": "text",
|
|
485
|
+
},
|
|
486
|
+
],
|
|
487
|
+
"id": "paragraph-3",
|
|
488
|
+
"props": {
|
|
489
|
+
"backgroundColor": "default",
|
|
490
|
+
"textAlignment": "left",
|
|
491
|
+
"textColor": "default",
|
|
492
|
+
},
|
|
493
|
+
"type": "paragraph",
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
"children": [],
|
|
497
|
+
"content": [
|
|
498
|
+
{
|
|
499
|
+
"styles": {
|
|
500
|
+
"bold": true,
|
|
501
|
+
},
|
|
502
|
+
"text": "Paragraph",
|
|
503
|
+
"type": "text",
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
"styles": {},
|
|
507
|
+
"text": " with styled ",
|
|
508
|
+
"type": "text",
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
"styles": {
|
|
512
|
+
"italic": true,
|
|
513
|
+
},
|
|
514
|
+
"text": "content",
|
|
515
|
+
"type": "text",
|
|
516
|
+
},
|
|
517
|
+
],
|
|
518
|
+
"id": "paragraph-with-styled-content",
|
|
519
|
+
"props": {
|
|
520
|
+
"backgroundColor": "default",
|
|
521
|
+
"textAlignment": "left",
|
|
522
|
+
"textColor": "default",
|
|
523
|
+
},
|
|
524
|
+
"type": "paragraph",
|
|
525
|
+
},
|
|
526
|
+
{
|
|
527
|
+
"children": [],
|
|
528
|
+
"content": [
|
|
529
|
+
{
|
|
530
|
+
"styles": {},
|
|
531
|
+
"text": "Paragraph 4",
|
|
532
|
+
"type": "text",
|
|
533
|
+
},
|
|
534
|
+
],
|
|
535
|
+
"id": "paragraph-4",
|
|
536
|
+
"props": {
|
|
537
|
+
"backgroundColor": "default",
|
|
538
|
+
"textAlignment": "left",
|
|
539
|
+
"textColor": "default",
|
|
540
|
+
},
|
|
541
|
+
"type": "paragraph",
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
"children": [],
|
|
545
|
+
"content": [
|
|
546
|
+
{
|
|
547
|
+
"styles": {},
|
|
548
|
+
"text": "Heading 1",
|
|
549
|
+
"type": "text",
|
|
550
|
+
},
|
|
551
|
+
],
|
|
552
|
+
"id": "heading-0",
|
|
259
553
|
"props": {
|
|
260
554
|
"backgroundColor": "default",
|
|
555
|
+
"level": 1,
|
|
556
|
+
"textAlignment": "left",
|
|
557
|
+
"textColor": "default",
|
|
558
|
+
},
|
|
559
|
+
"type": "heading",
|
|
560
|
+
},
|
|
561
|
+
{
|
|
562
|
+
"children": [],
|
|
563
|
+
"content": [
|
|
564
|
+
{
|
|
565
|
+
"styles": {},
|
|
566
|
+
"text": "Paragraph 5",
|
|
567
|
+
"type": "text",
|
|
568
|
+
},
|
|
569
|
+
],
|
|
570
|
+
"id": "paragraph-5",
|
|
571
|
+
"props": {
|
|
572
|
+
"backgroundColor": "default",
|
|
573
|
+
"textAlignment": "left",
|
|
574
|
+
"textColor": "default",
|
|
575
|
+
},
|
|
576
|
+
"type": "paragraph",
|
|
577
|
+
},
|
|
578
|
+
{
|
|
579
|
+
"children": [],
|
|
580
|
+
"content": undefined,
|
|
581
|
+
"id": "image-0",
|
|
582
|
+
"props": {
|
|
583
|
+
"backgroundColor": "default",
|
|
584
|
+
"caption": "",
|
|
585
|
+
"name": "",
|
|
586
|
+
"previewWidth": 512,
|
|
587
|
+
"showPreview": true,
|
|
588
|
+
"textAlignment": "left",
|
|
589
|
+
"url": "https://via.placeholder.com/150",
|
|
590
|
+
},
|
|
591
|
+
"type": "image",
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
"children": [],
|
|
595
|
+
"content": [
|
|
596
|
+
{
|
|
597
|
+
"styles": {},
|
|
598
|
+
"text": "Paragraph 6",
|
|
599
|
+
"type": "text",
|
|
600
|
+
},
|
|
601
|
+
],
|
|
602
|
+
"id": "paragraph-6",
|
|
603
|
+
"props": {
|
|
604
|
+
"backgroundColor": "default",
|
|
605
|
+
"textAlignment": "left",
|
|
606
|
+
"textColor": "default",
|
|
607
|
+
},
|
|
608
|
+
"type": "paragraph",
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
"children": [],
|
|
612
|
+
"content": {
|
|
613
|
+
"columnWidths": [
|
|
614
|
+
undefined,
|
|
615
|
+
undefined,
|
|
616
|
+
undefined,
|
|
617
|
+
],
|
|
618
|
+
"rows": [
|
|
619
|
+
{
|
|
620
|
+
"cells": [
|
|
621
|
+
[
|
|
622
|
+
{
|
|
623
|
+
"styles": {},
|
|
624
|
+
"text": "Cell 1",
|
|
625
|
+
"type": "text",
|
|
626
|
+
},
|
|
627
|
+
],
|
|
628
|
+
[
|
|
629
|
+
{
|
|
630
|
+
"styles": {},
|
|
631
|
+
"text": "Cell 2",
|
|
632
|
+
"type": "text",
|
|
633
|
+
},
|
|
634
|
+
],
|
|
635
|
+
[
|
|
636
|
+
{
|
|
637
|
+
"styles": {},
|
|
638
|
+
"text": "Cell 3",
|
|
639
|
+
"type": "text",
|
|
640
|
+
},
|
|
641
|
+
],
|
|
642
|
+
],
|
|
643
|
+
},
|
|
644
|
+
{
|
|
645
|
+
"cells": [
|
|
646
|
+
[
|
|
647
|
+
{
|
|
648
|
+
"styles": {},
|
|
649
|
+
"text": "Cell 4",
|
|
650
|
+
"type": "text",
|
|
651
|
+
},
|
|
652
|
+
],
|
|
653
|
+
[
|
|
654
|
+
{
|
|
655
|
+
"styles": {},
|
|
656
|
+
"text": "Cell 5",
|
|
657
|
+
"type": "text",
|
|
658
|
+
},
|
|
659
|
+
],
|
|
660
|
+
[
|
|
661
|
+
{
|
|
662
|
+
"styles": {},
|
|
663
|
+
"text": "Cell 6",
|
|
664
|
+
"type": "text",
|
|
665
|
+
},
|
|
666
|
+
],
|
|
667
|
+
],
|
|
668
|
+
},
|
|
669
|
+
{
|
|
670
|
+
"cells": [
|
|
671
|
+
[
|
|
672
|
+
{
|
|
673
|
+
"styles": {},
|
|
674
|
+
"text": "Cell 7",
|
|
675
|
+
"type": "text",
|
|
676
|
+
},
|
|
677
|
+
],
|
|
678
|
+
[
|
|
679
|
+
{
|
|
680
|
+
"styles": {},
|
|
681
|
+
"text": "Cell 8",
|
|
682
|
+
"type": "text",
|
|
683
|
+
},
|
|
684
|
+
],
|
|
685
|
+
[
|
|
686
|
+
{
|
|
687
|
+
"styles": {},
|
|
688
|
+
"text": "Cell 9",
|
|
689
|
+
"type": "text",
|
|
690
|
+
},
|
|
691
|
+
],
|
|
692
|
+
],
|
|
693
|
+
},
|
|
694
|
+
],
|
|
695
|
+
"type": "tableContent",
|
|
696
|
+
},
|
|
697
|
+
"id": "table-0",
|
|
698
|
+
"props": {
|
|
261
699
|
"textColor": "default",
|
|
262
700
|
},
|
|
263
701
|
"type": "table",
|
|
@@ -1013,7 +1451,6 @@ exports[`Test removeBlocks > Remove single block 1`] = `
|
|
|
1013
1451
|
},
|
|
1014
1452
|
"id": "table-0",
|
|
1015
1453
|
"props": {
|
|
1016
|
-
"backgroundColor": "default",
|
|
1017
1454
|
"textColor": "default",
|
|
1018
1455
|
},
|
|
1019
1456
|
"type": "table",
|
|
@@ -31,4 +31,10 @@ describe("Test removeBlocks", () => {
|
|
|
31
31
|
|
|
32
32
|
expect(getEditor().document).toMatchSnapshot();
|
|
33
33
|
});
|
|
34
|
+
|
|
35
|
+
it("Remove all child blocks", () => {
|
|
36
|
+
removeBlocks(getEditor(), ["nested-paragraph-0"]);
|
|
37
|
+
|
|
38
|
+
expect(getEditor().document).toMatchSnapshot();
|
|
39
|
+
});
|
|
34
40
|
});
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { Node } from "prosemirror-model";
|
|
2
|
-
import { Transaction } from "prosemirror-state";
|
|
3
|
-
|
|
4
1
|
import { Block } from "../../../../blocks/defaultBlocks.js";
|
|
5
2
|
import type { BlockNoteEditor } from "../../../../editor/BlockNoteEditor";
|
|
6
3
|
import {
|
|
@@ -9,84 +6,7 @@ import {
|
|
|
9
6
|
InlineContentSchema,
|
|
10
7
|
StyleSchema,
|
|
11
8
|
} from "../../../../schema/index.js";
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
export function removeBlocksWithCallback<
|
|
15
|
-
BSchema extends BlockSchema,
|
|
16
|
-
I extends InlineContentSchema,
|
|
17
|
-
S extends StyleSchema
|
|
18
|
-
>(
|
|
19
|
-
editor: BlockNoteEditor<BSchema, I, S>,
|
|
20
|
-
blocksToRemove: BlockIdentifier[],
|
|
21
|
-
// Should return new removedSize.
|
|
22
|
-
callback?: (
|
|
23
|
-
node: Node,
|
|
24
|
-
pos: number,
|
|
25
|
-
tr: Transaction,
|
|
26
|
-
removedSize: number
|
|
27
|
-
) => number
|
|
28
|
-
): Block<BSchema, I, S>[] {
|
|
29
|
-
const ttEditor = editor._tiptapEditor;
|
|
30
|
-
const tr = ttEditor.state.tr;
|
|
31
|
-
|
|
32
|
-
const idsOfBlocksToRemove = new Set<string>(
|
|
33
|
-
blocksToRemove.map((block) =>
|
|
34
|
-
typeof block === "string" ? block : block.id
|
|
35
|
-
)
|
|
36
|
-
);
|
|
37
|
-
const removedBlocks: Block<BSchema, I, S>[] = [];
|
|
38
|
-
let removedSize = 0;
|
|
39
|
-
|
|
40
|
-
ttEditor.state.doc.descendants((node, pos) => {
|
|
41
|
-
// Skips traversing nodes after all target blocks have been removed.
|
|
42
|
-
if (idsOfBlocksToRemove.size === 0) {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Keeps traversing nodes if block with target ID has not been found.
|
|
47
|
-
if (
|
|
48
|
-
node.type.name !== "blockContainer" ||
|
|
49
|
-
!idsOfBlocksToRemove.has(node.attrs.id)
|
|
50
|
-
) {
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Saves the block that is being deleted.
|
|
55
|
-
removedBlocks.push(
|
|
56
|
-
nodeToBlock(
|
|
57
|
-
node,
|
|
58
|
-
editor.schema.blockSchema,
|
|
59
|
-
editor.schema.inlineContentSchema,
|
|
60
|
-
editor.schema.styleSchema,
|
|
61
|
-
editor.blockCache
|
|
62
|
-
)
|
|
63
|
-
);
|
|
64
|
-
idsOfBlocksToRemove.delete(node.attrs.id);
|
|
65
|
-
|
|
66
|
-
// Removes the block and calculates the change in document size.
|
|
67
|
-
removedSize = callback?.(node, pos, tr, removedSize) || removedSize;
|
|
68
|
-
const oldDocSize = tr.doc.nodeSize;
|
|
69
|
-
tr.delete(pos - removedSize - 1, pos - removedSize + node.nodeSize + 1);
|
|
70
|
-
const newDocSize = tr.doc.nodeSize;
|
|
71
|
-
removedSize += oldDocSize - newDocSize;
|
|
72
|
-
|
|
73
|
-
return false;
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
// Throws an error if now all blocks could be found.
|
|
77
|
-
if (idsOfBlocksToRemove.size > 0) {
|
|
78
|
-
const notFoundIds = [...idsOfBlocksToRemove].join("\n");
|
|
79
|
-
|
|
80
|
-
throw Error(
|
|
81
|
-
"Blocks with the following IDs could not be found in the editor: " +
|
|
82
|
-
notFoundIds
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
editor.dispatch(tr);
|
|
87
|
-
|
|
88
|
-
return removedBlocks;
|
|
89
|
-
}
|
|
9
|
+
import { removeAndInsertBlocks } from "../replaceBlocks/replaceBlocks.js";
|
|
90
10
|
|
|
91
11
|
export function removeBlocks<
|
|
92
12
|
BSchema extends BlockSchema,
|
|
@@ -96,5 +16,5 @@ export function removeBlocks<
|
|
|
96
16
|
editor: BlockNoteEditor<BSchema, I, S>,
|
|
97
17
|
blocksToRemove: BlockIdentifier[]
|
|
98
18
|
): Block<BSchema, I, S>[] {
|
|
99
|
-
return
|
|
19
|
+
return removeAndInsertBlocks(editor, blocksToRemove, []).removedBlocks;
|
|
100
20
|
}
|
package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap
CHANGED
|
@@ -257,7 +257,6 @@ exports[`Test replaceBlocks > Remove multiple consecutive blocks 1`] = `
|
|
|
257
257
|
},
|
|
258
258
|
"id": "table-0",
|
|
259
259
|
"props": {
|
|
260
|
-
"backgroundColor": "default",
|
|
261
260
|
"textColor": "default",
|
|
262
261
|
},
|
|
263
262
|
"type": "table",
|
|
@@ -1013,7 +1012,6 @@ exports[`Test replaceBlocks > Remove single block 1`] = `
|
|
|
1013
1012
|
},
|
|
1014
1013
|
"id": "table-0",
|
|
1015
1014
|
"props": {
|
|
1016
|
-
"backgroundColor": "default",
|
|
1017
1015
|
"textColor": "default",
|
|
1018
1016
|
},
|
|
1019
1017
|
"type": "table",
|
|
@@ -1453,7 +1451,6 @@ exports[`Test replaceBlocks > Replace multiple consecutive blocks with multiple
|
|
|
1453
1451
|
},
|
|
1454
1452
|
"id": "table-0",
|
|
1455
1453
|
"props": {
|
|
1456
|
-
"backgroundColor": "default",
|
|
1457
1454
|
"textColor": "default",
|
|
1458
1455
|
},
|
|
1459
1456
|
"type": "table",
|
|
@@ -1853,7 +1850,6 @@ exports[`Test replaceBlocks > Replace multiple consecutive blocks with single ba
|
|
|
1853
1850
|
},
|
|
1854
1851
|
"id": "table-0",
|
|
1855
1852
|
"props": {
|
|
1856
|
-
"backgroundColor": "default",
|
|
1857
1853
|
"textColor": "default",
|
|
1858
1854
|
},
|
|
1859
1855
|
"type": "table",
|
|
@@ -2310,7 +2306,6 @@ exports[`Test replaceBlocks > Replace multiple consecutive blocks with single co
|
|
|
2310
2306
|
},
|
|
2311
2307
|
"id": "table-0",
|
|
2312
2308
|
"props": {
|
|
2313
|
-
"backgroundColor": "default",
|
|
2314
2309
|
"textColor": "default",
|
|
2315
2310
|
},
|
|
2316
2311
|
"type": "table",
|
|
@@ -3841,7 +3836,6 @@ exports[`Test replaceBlocks > Replace single block with multiple 1`] = `
|
|
|
3841
3836
|
},
|
|
3842
3837
|
"id": "table-0",
|
|
3843
3838
|
"props": {
|
|
3844
|
-
"backgroundColor": "default",
|
|
3845
3839
|
"textColor": "default",
|
|
3846
3840
|
},
|
|
3847
3841
|
"type": "table",
|
|
@@ -4311,7 +4305,6 @@ exports[`Test replaceBlocks > Replace single block with single basic 1`] = `
|
|
|
4311
4305
|
},
|
|
4312
4306
|
"id": "table-0",
|
|
4313
4307
|
"props": {
|
|
4314
|
-
"backgroundColor": "default",
|
|
4315
4308
|
"textColor": "default",
|
|
4316
4309
|
},
|
|
4317
4310
|
"type": "table",
|
|
@@ -4838,7 +4831,6 @@ exports[`Test replaceBlocks > Replace single block with single complex 1`] = `
|
|
|
4838
4831
|
},
|
|
4839
4832
|
"id": "table-0",
|
|
4840
4833
|
"props": {
|
|
4841
|
-
"backgroundColor": "default",
|
|
4842
4834
|
"textColor": "default",
|
|
4843
4835
|
},
|
|
4844
4836
|
"type": "table",
|