@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
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Fragment, NodeType, Slice } from "prosemirror-model";
|
|
2
|
+
import { EditorState } from "prosemirror-state";
|
|
3
|
+
import { ReplaceAroundStep } from "prosemirror-transform";
|
|
4
|
+
|
|
5
|
+
import { BlockNoteEditor } from "../../../../editor/BlockNoteEditor.js";
|
|
6
|
+
import { getBlockInfoFromSelection } from "../../../getBlockInfoFromPos.js";
|
|
7
|
+
|
|
8
|
+
// TODO: Unit tests
|
|
9
|
+
/**
|
|
10
|
+
* This is a modified version of https://github.com/ProseMirror/prosemirror-schema-list/blob/569c2770cbb8092d8f11ea53ecf78cb7a4e8f15a/src/schema-list.ts#L232
|
|
11
|
+
*
|
|
12
|
+
* The original function derives too many information from the parentnode and itemtype
|
|
13
|
+
*/
|
|
14
|
+
function sinkListItem(itemType: NodeType, groupType: NodeType) {
|
|
15
|
+
return function ({ state, dispatch }: { state: EditorState; dispatch: any }) {
|
|
16
|
+
const { $from, $to } = state.selection;
|
|
17
|
+
const range = $from.blockRange(
|
|
18
|
+
$to,
|
|
19
|
+
(node) =>
|
|
20
|
+
node.childCount > 0 &&
|
|
21
|
+
(node.type.name === "blockGroup" || node.type.name === "column") // change necessary to not look at first item child type
|
|
22
|
+
);
|
|
23
|
+
if (!range) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
const startIndex = range.startIndex;
|
|
27
|
+
if (startIndex === 0) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const parent = range.parent;
|
|
31
|
+
const nodeBefore = parent.child(startIndex - 1);
|
|
32
|
+
if (nodeBefore.type !== itemType) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
if (dispatch) {
|
|
36
|
+
const nestedBefore =
|
|
37
|
+
nodeBefore.lastChild && nodeBefore.lastChild.type === groupType; // change necessary to check groupType instead of parent.type
|
|
38
|
+
const inner = Fragment.from(nestedBefore ? itemType.create() : null);
|
|
39
|
+
const slice = new Slice(
|
|
40
|
+
Fragment.from(
|
|
41
|
+
itemType.create(null, Fragment.from(groupType.create(null, inner))) // change necessary to create "groupType" instead of parent.type
|
|
42
|
+
),
|
|
43
|
+
nestedBefore ? 3 : 1,
|
|
44
|
+
0
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const before = range.start;
|
|
48
|
+
const after = range.end;
|
|
49
|
+
dispatch(
|
|
50
|
+
state.tr
|
|
51
|
+
.step(
|
|
52
|
+
new ReplaceAroundStep(
|
|
53
|
+
before - (nestedBefore ? 3 : 1),
|
|
54
|
+
after,
|
|
55
|
+
before,
|
|
56
|
+
after,
|
|
57
|
+
slice,
|
|
58
|
+
1,
|
|
59
|
+
true
|
|
60
|
+
)
|
|
61
|
+
)
|
|
62
|
+
.scrollIntoView()
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
return true;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function nestBlock(editor: BlockNoteEditor<any, any, any>) {
|
|
70
|
+
return editor._tiptapEditor.commands.command(
|
|
71
|
+
sinkListItem(
|
|
72
|
+
editor._tiptapEditor.schema.nodes["blockContainer"],
|
|
73
|
+
editor._tiptapEditor.schema.nodes["blockGroup"]
|
|
74
|
+
)
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function unnestBlock(editor: BlockNoteEditor<any, any, any>) {
|
|
79
|
+
editor._tiptapEditor.commands.liftListItem("blockContainer");
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function canNestBlock(editor: BlockNoteEditor<any, any, any>) {
|
|
83
|
+
const { bnBlock: blockContainer } = getBlockInfoFromSelection(
|
|
84
|
+
editor._tiptapEditor.state
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
editor._tiptapEditor.state.doc.resolve(blockContainer.beforePos)
|
|
89
|
+
.nodeBefore !== null
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
export function canUnnestBlock(editor: BlockNoteEditor<any, any, any>) {
|
|
93
|
+
const { bnBlock: blockContainer } = getBlockInfoFromSelection(
|
|
94
|
+
editor._tiptapEditor.state
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
editor._tiptapEditor.state.doc.resolve(blockContainer.beforePos).depth > 1
|
|
99
|
+
);
|
|
100
|
+
}
|
package/src/api/blockManipulation/commands/removeBlocks/__snapshots__/removeBlocks.test.ts.snap
CHANGED
|
@@ -171,6 +171,11 @@ exports[`Test removeBlocks > Remove multiple consecutive blocks 1`] = `
|
|
|
171
171
|
{
|
|
172
172
|
"children": [],
|
|
173
173
|
"content": {
|
|
174
|
+
"columnWidths": [
|
|
175
|
+
undefined,
|
|
176
|
+
undefined,
|
|
177
|
+
undefined,
|
|
178
|
+
],
|
|
174
179
|
"rows": [
|
|
175
180
|
{
|
|
176
181
|
"cells": [
|
|
@@ -922,6 +927,11 @@ exports[`Test removeBlocks > Remove single block 1`] = `
|
|
|
922
927
|
{
|
|
923
928
|
"children": [],
|
|
924
929
|
"content": {
|
|
930
|
+
"columnWidths": [
|
|
931
|
+
undefined,
|
|
932
|
+
undefined,
|
|
933
|
+
undefined,
|
|
934
|
+
],
|
|
925
935
|
"rows": [
|
|
926
936
|
{
|
|
927
937
|
"cells": [
|
|
@@ -45,7 +45,7 @@ export function removeBlocksWithCallback<
|
|
|
45
45
|
|
|
46
46
|
// Keeps traversing nodes if block with target ID has not been found.
|
|
47
47
|
if (
|
|
48
|
-
node.type.
|
|
48
|
+
!node.type.isInGroup("bnBlock") ||
|
|
49
49
|
!idsOfBlocksToRemove.has(node.attrs.id)
|
|
50
50
|
) {
|
|
51
51
|
return true;
|
package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap
CHANGED
|
@@ -171,6 +171,11 @@ exports[`Test replaceBlocks > Remove multiple consecutive blocks 1`] = `
|
|
|
171
171
|
{
|
|
172
172
|
"children": [],
|
|
173
173
|
"content": {
|
|
174
|
+
"columnWidths": [
|
|
175
|
+
undefined,
|
|
176
|
+
undefined,
|
|
177
|
+
undefined,
|
|
178
|
+
],
|
|
174
179
|
"rows": [
|
|
175
180
|
{
|
|
176
181
|
"cells": [
|
|
@@ -922,6 +927,11 @@ exports[`Test replaceBlocks > Remove single block 1`] = `
|
|
|
922
927
|
{
|
|
923
928
|
"children": [],
|
|
924
929
|
"content": {
|
|
930
|
+
"columnWidths": [
|
|
931
|
+
undefined,
|
|
932
|
+
undefined,
|
|
933
|
+
undefined,
|
|
934
|
+
],
|
|
925
935
|
"rows": [
|
|
926
936
|
{
|
|
927
937
|
"cells": [
|
|
@@ -1357,6 +1367,11 @@ exports[`Test replaceBlocks > Replace multiple consecutive blocks with multiple
|
|
|
1357
1367
|
{
|
|
1358
1368
|
"children": [],
|
|
1359
1369
|
"content": {
|
|
1370
|
+
"columnWidths": [
|
|
1371
|
+
undefined,
|
|
1372
|
+
undefined,
|
|
1373
|
+
undefined,
|
|
1374
|
+
],
|
|
1360
1375
|
"rows": [
|
|
1361
1376
|
{
|
|
1362
1377
|
"cells": [
|
|
@@ -1752,6 +1767,11 @@ exports[`Test replaceBlocks > Replace multiple consecutive blocks with single ba
|
|
|
1752
1767
|
{
|
|
1753
1768
|
"children": [],
|
|
1754
1769
|
"content": {
|
|
1770
|
+
"columnWidths": [
|
|
1771
|
+
undefined,
|
|
1772
|
+
undefined,
|
|
1773
|
+
undefined,
|
|
1774
|
+
],
|
|
1755
1775
|
"rows": [
|
|
1756
1776
|
{
|
|
1757
1777
|
"cells": [
|
|
@@ -2204,6 +2224,11 @@ exports[`Test replaceBlocks > Replace multiple consecutive blocks with single co
|
|
|
2204
2224
|
{
|
|
2205
2225
|
"children": [],
|
|
2206
2226
|
"content": {
|
|
2227
|
+
"columnWidths": [
|
|
2228
|
+
undefined,
|
|
2229
|
+
undefined,
|
|
2230
|
+
undefined,
|
|
2231
|
+
],
|
|
2207
2232
|
"rows": [
|
|
2208
2233
|
{
|
|
2209
2234
|
"cells": [
|
|
@@ -3730,6 +3755,11 @@ exports[`Test replaceBlocks > Replace single block with multiple 1`] = `
|
|
|
3730
3755
|
{
|
|
3731
3756
|
"children": [],
|
|
3732
3757
|
"content": {
|
|
3758
|
+
"columnWidths": [
|
|
3759
|
+
undefined,
|
|
3760
|
+
undefined,
|
|
3761
|
+
undefined,
|
|
3762
|
+
],
|
|
3733
3763
|
"rows": [
|
|
3734
3764
|
{
|
|
3735
3765
|
"cells": [
|
|
@@ -4195,6 +4225,11 @@ exports[`Test replaceBlocks > Replace single block with single basic 1`] = `
|
|
|
4195
4225
|
{
|
|
4196
4226
|
"children": [],
|
|
4197
4227
|
"content": {
|
|
4228
|
+
"columnWidths": [
|
|
4229
|
+
undefined,
|
|
4230
|
+
undefined,
|
|
4231
|
+
undefined,
|
|
4232
|
+
],
|
|
4198
4233
|
"rows": [
|
|
4199
4234
|
{
|
|
4200
4235
|
"cells": [
|
|
@@ -4717,6 +4752,11 @@ exports[`Test replaceBlocks > Replace single block with single complex 1`] = `
|
|
|
4717
4752
|
{
|
|
4718
4753
|
"children": [],
|
|
4719
4754
|
"content": {
|
|
4755
|
+
"columnWidths": [
|
|
4756
|
+
undefined,
|
|
4757
|
+
undefined,
|
|
4758
|
+
undefined,
|
|
4759
|
+
],
|
|
4720
4760
|
"rows": [
|
|
4721
4761
|
{
|
|
4722
4762
|
"cells": [
|
|
@@ -275,6 +275,11 @@ exports[`Test splitBlocks > Basic 1`] = `
|
|
|
275
275
|
{
|
|
276
276
|
"children": [],
|
|
277
277
|
"content": {
|
|
278
|
+
"columnWidths": [
|
|
279
|
+
undefined,
|
|
280
|
+
undefined,
|
|
281
|
+
undefined,
|
|
282
|
+
],
|
|
278
283
|
"rows": [
|
|
279
284
|
{
|
|
280
285
|
"cells": [
|
|
@@ -763,6 +768,11 @@ exports[`Test splitBlocks > Block has children 1`] = `
|
|
|
763
768
|
{
|
|
764
769
|
"children": [],
|
|
765
770
|
"content": {
|
|
771
|
+
"columnWidths": [
|
|
772
|
+
undefined,
|
|
773
|
+
undefined,
|
|
774
|
+
undefined,
|
|
775
|
+
],
|
|
766
776
|
"rows": [
|
|
767
777
|
{
|
|
768
778
|
"cells": [
|
|
@@ -1251,6 +1261,11 @@ exports[`Test splitBlocks > Don't keep props 1`] = `
|
|
|
1251
1261
|
{
|
|
1252
1262
|
"children": [],
|
|
1253
1263
|
"content": {
|
|
1264
|
+
"columnWidths": [
|
|
1265
|
+
undefined,
|
|
1266
|
+
undefined,
|
|
1267
|
+
undefined,
|
|
1268
|
+
],
|
|
1254
1269
|
"rows": [
|
|
1255
1270
|
{
|
|
1256
1271
|
"cells": [
|
|
@@ -1739,6 +1754,11 @@ exports[`Test splitBlocks > Don't keep type 1`] = `
|
|
|
1739
1754
|
{
|
|
1740
1755
|
"children": [],
|
|
1741
1756
|
"content": {
|
|
1757
|
+
"columnWidths": [
|
|
1758
|
+
undefined,
|
|
1759
|
+
undefined,
|
|
1760
|
+
undefined,
|
|
1761
|
+
],
|
|
1742
1762
|
"rows": [
|
|
1743
1763
|
{
|
|
1744
1764
|
"cells": [
|
|
@@ -2221,6 +2241,11 @@ exports[`Test splitBlocks > End of content 1`] = `
|
|
|
2221
2241
|
{
|
|
2222
2242
|
"children": [],
|
|
2223
2243
|
"content": {
|
|
2244
|
+
"columnWidths": [
|
|
2245
|
+
undefined,
|
|
2246
|
+
undefined,
|
|
2247
|
+
undefined,
|
|
2248
|
+
],
|
|
2224
2249
|
"rows": [
|
|
2225
2250
|
{
|
|
2226
2251
|
"cells": [
|
|
@@ -2710,6 +2735,11 @@ exports[`Test splitBlocks > Keep type 1`] = `
|
|
|
2710
2735
|
{
|
|
2711
2736
|
"children": [],
|
|
2712
2737
|
"content": {
|
|
2738
|
+
"columnWidths": [
|
|
2739
|
+
undefined,
|
|
2740
|
+
undefined,
|
|
2741
|
+
undefined,
|
|
2742
|
+
],
|
|
2713
2743
|
"rows": [
|
|
2714
2744
|
{
|
|
2715
2745
|
"cells": [
|
|
@@ -28,11 +28,15 @@ function setSelectionWithOffset(
|
|
|
28
28
|
offset: number
|
|
29
29
|
) {
|
|
30
30
|
const posInfo = getNodeById(targetBlockId, doc);
|
|
31
|
-
const
|
|
31
|
+
const info = getBlockInfo(posInfo);
|
|
32
|
+
|
|
33
|
+
if (!info.isBlockContainer) {
|
|
34
|
+
throw new Error("Target block is not a block container");
|
|
35
|
+
}
|
|
32
36
|
|
|
33
37
|
getEditor()._tiptapEditor.view.dispatch(
|
|
34
38
|
getEditor()._tiptapEditor.state.tr.setSelection(
|
|
35
|
-
TextSelection.create(doc, blockContent.beforePos + offset + 1)
|
|
39
|
+
TextSelection.create(doc, info.blockContent.beforePos + offset + 1)
|
|
36
40
|
)
|
|
37
41
|
);
|
|
38
42
|
}
|
|
@@ -123,12 +127,12 @@ describe("Test splitBlocks", () => {
|
|
|
123
127
|
|
|
124
128
|
splitBlock(getEditor()._tiptapEditor.state.selection.anchor);
|
|
125
129
|
|
|
126
|
-
const {
|
|
130
|
+
const { bnBlock } = getBlockInfoFromSelection(
|
|
127
131
|
getEditor()._tiptapEditor.state
|
|
128
132
|
);
|
|
129
133
|
|
|
130
134
|
const anchorIsAtStartOfNewBlock =
|
|
131
|
-
|
|
135
|
+
bnBlock.node.attrs.id === "0" &&
|
|
132
136
|
getEditor()._tiptapEditor.state.selection.$anchor.parentOffset === 0;
|
|
133
137
|
|
|
134
138
|
expect(anchorIsAtStartOfNewBlock).toBeTruthy();
|
|
@@ -22,20 +22,24 @@ export const splitBlockCommand = (
|
|
|
22
22
|
posInBlock
|
|
23
23
|
);
|
|
24
24
|
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
)
|
|
25
|
+
const info = getBlockInfo(nearestBlockContainerPos);
|
|
26
|
+
|
|
27
|
+
if (!info.isBlockContainer) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
`BlockContainer expected when calling splitBlock, position ${posInBlock}`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
28
32
|
|
|
29
33
|
const types = [
|
|
30
34
|
{
|
|
31
|
-
type:
|
|
32
|
-
attrs: keepProps ? { ...
|
|
35
|
+
type: info.bnBlock.node.type, // always keep blockcontainer type
|
|
36
|
+
attrs: keepProps ? { ...info.bnBlock.node.attrs, id: undefined } : {},
|
|
33
37
|
},
|
|
34
38
|
{
|
|
35
39
|
type: keepType
|
|
36
|
-
? blockContent.node.type
|
|
40
|
+
? info.blockContent.node.type
|
|
37
41
|
: state.schema.nodes["paragraph"],
|
|
38
|
-
attrs: keepProps ? { ...blockContent.node.attrs } : {},
|
|
42
|
+
attrs: keepProps ? { ...info.blockContent.node.attrs } : {},
|
|
39
43
|
},
|
|
40
44
|
];
|
|
41
45
|
|
package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap
CHANGED
|
@@ -258,6 +258,11 @@ exports[`Test updateBlock > Revert all props 1`] = `
|
|
|
258
258
|
{
|
|
259
259
|
"children": [],
|
|
260
260
|
"content": {
|
|
261
|
+
"columnWidths": [
|
|
262
|
+
undefined,
|
|
263
|
+
undefined,
|
|
264
|
+
undefined,
|
|
265
|
+
],
|
|
261
266
|
"rows": [
|
|
262
267
|
{
|
|
263
268
|
"cells": [
|
|
@@ -729,6 +734,11 @@ exports[`Test updateBlock > Revert single prop 1`] = `
|
|
|
729
734
|
{
|
|
730
735
|
"children": [],
|
|
731
736
|
"content": {
|
|
737
|
+
"columnWidths": [
|
|
738
|
+
undefined,
|
|
739
|
+
undefined,
|
|
740
|
+
undefined,
|
|
741
|
+
],
|
|
732
742
|
"rows": [
|
|
733
743
|
{
|
|
734
744
|
"cells": [
|
|
@@ -1200,6 +1210,11 @@ exports[`Test updateBlock > Update all props 1`] = `
|
|
|
1200
1210
|
{
|
|
1201
1211
|
"children": [],
|
|
1202
1212
|
"content": {
|
|
1213
|
+
"columnWidths": [
|
|
1214
|
+
undefined,
|
|
1215
|
+
undefined,
|
|
1216
|
+
undefined,
|
|
1217
|
+
],
|
|
1203
1218
|
"rows": [
|
|
1204
1219
|
{
|
|
1205
1220
|
"cells": [
|
|
@@ -1671,6 +1686,11 @@ exports[`Test updateBlock > Update children 1`] = `
|
|
|
1671
1686
|
{
|
|
1672
1687
|
"children": [],
|
|
1673
1688
|
"content": {
|
|
1689
|
+
"columnWidths": [
|
|
1690
|
+
undefined,
|
|
1691
|
+
undefined,
|
|
1692
|
+
undefined,
|
|
1693
|
+
],
|
|
1674
1694
|
"rows": [
|
|
1675
1695
|
{
|
|
1676
1696
|
"cells": [
|
|
@@ -1889,6 +1909,7 @@ exports[`Test updateBlock > Update inline content to empty table content 1`] = `
|
|
|
1889
1909
|
{
|
|
1890
1910
|
"children": [],
|
|
1891
1911
|
"content": {
|
|
1912
|
+
"columnWidths": [],
|
|
1892
1913
|
"rows": [],
|
|
1893
1914
|
"type": "tableContent",
|
|
1894
1915
|
},
|
|
@@ -2138,6 +2159,11 @@ exports[`Test updateBlock > Update inline content to empty table content 1`] = `
|
|
|
2138
2159
|
{
|
|
2139
2160
|
"children": [],
|
|
2140
2161
|
"content": {
|
|
2162
|
+
"columnWidths": [
|
|
2163
|
+
undefined,
|
|
2164
|
+
undefined,
|
|
2165
|
+
undefined,
|
|
2166
|
+
],
|
|
2141
2167
|
"rows": [
|
|
2142
2168
|
{
|
|
2143
2169
|
"cells": [
|
|
@@ -2607,6 +2633,11 @@ exports[`Test updateBlock > Update inline content to no content 1`] = `
|
|
|
2607
2633
|
{
|
|
2608
2634
|
"children": [],
|
|
2609
2635
|
"content": {
|
|
2636
|
+
"columnWidths": [
|
|
2637
|
+
undefined,
|
|
2638
|
+
undefined,
|
|
2639
|
+
undefined,
|
|
2640
|
+
],
|
|
2610
2641
|
"rows": [
|
|
2611
2642
|
{
|
|
2612
2643
|
"cells": [
|
|
@@ -2825,6 +2856,11 @@ exports[`Test updateBlock > Update inline content to table content 1`] = `
|
|
|
2825
2856
|
{
|
|
2826
2857
|
"children": [],
|
|
2827
2858
|
"content": {
|
|
2859
|
+
"columnWidths": [
|
|
2860
|
+
undefined,
|
|
2861
|
+
undefined,
|
|
2862
|
+
undefined,
|
|
2863
|
+
],
|
|
2828
2864
|
"rows": [
|
|
2829
2865
|
{
|
|
2830
2866
|
"cells": [
|
|
@@ -3150,6 +3186,11 @@ exports[`Test updateBlock > Update inline content to table content 1`] = `
|
|
|
3150
3186
|
{
|
|
3151
3187
|
"children": [],
|
|
3152
3188
|
"content": {
|
|
3189
|
+
"columnWidths": [
|
|
3190
|
+
undefined,
|
|
3191
|
+
undefined,
|
|
3192
|
+
undefined,
|
|
3193
|
+
],
|
|
3153
3194
|
"rows": [
|
|
3154
3195
|
{
|
|
3155
3196
|
"cells": [
|
|
@@ -3617,6 +3658,11 @@ exports[`Test updateBlock > Update no content to empty inline content 1`] = `
|
|
|
3617
3658
|
{
|
|
3618
3659
|
"children": [],
|
|
3619
3660
|
"content": {
|
|
3661
|
+
"columnWidths": [
|
|
3662
|
+
undefined,
|
|
3663
|
+
undefined,
|
|
3664
|
+
undefined,
|
|
3665
|
+
],
|
|
3620
3666
|
"rows": [
|
|
3621
3667
|
{
|
|
3622
3668
|
"cells": [
|
|
@@ -4056,6 +4102,7 @@ exports[`Test updateBlock > Update no content to empty table content 1`] = `
|
|
|
4056
4102
|
{
|
|
4057
4103
|
"children": [],
|
|
4058
4104
|
"content": {
|
|
4105
|
+
"columnWidths": [],
|
|
4059
4106
|
"rows": [],
|
|
4060
4107
|
"type": "tableContent",
|
|
4061
4108
|
},
|
|
@@ -4086,6 +4133,11 @@ exports[`Test updateBlock > Update no content to empty table content 1`] = `
|
|
|
4086
4133
|
{
|
|
4087
4134
|
"children": [],
|
|
4088
4135
|
"content": {
|
|
4136
|
+
"columnWidths": [
|
|
4137
|
+
undefined,
|
|
4138
|
+
undefined,
|
|
4139
|
+
undefined,
|
|
4140
|
+
],
|
|
4089
4141
|
"rows": [
|
|
4090
4142
|
{
|
|
4091
4143
|
"cells": [
|
|
@@ -4559,6 +4611,11 @@ exports[`Test updateBlock > Update no content to inline content 1`] = `
|
|
|
4559
4611
|
{
|
|
4560
4612
|
"children": [],
|
|
4561
4613
|
"content": {
|
|
4614
|
+
"columnWidths": [
|
|
4615
|
+
undefined,
|
|
4616
|
+
undefined,
|
|
4617
|
+
undefined,
|
|
4618
|
+
],
|
|
4562
4619
|
"rows": [
|
|
4563
4620
|
{
|
|
4564
4621
|
"cells": [
|
|
@@ -4998,6 +5055,11 @@ exports[`Test updateBlock > Update no content to table content 1`] = `
|
|
|
4998
5055
|
{
|
|
4999
5056
|
"children": [],
|
|
5000
5057
|
"content": {
|
|
5058
|
+
"columnWidths": [
|
|
5059
|
+
undefined,
|
|
5060
|
+
undefined,
|
|
5061
|
+
undefined,
|
|
5062
|
+
],
|
|
5001
5063
|
"rows": [
|
|
5002
5064
|
{
|
|
5003
5065
|
"cells": [
|
|
@@ -5104,6 +5166,11 @@ exports[`Test updateBlock > Update no content to table content 1`] = `
|
|
|
5104
5166
|
{
|
|
5105
5167
|
"children": [],
|
|
5106
5168
|
"content": {
|
|
5169
|
+
"columnWidths": [
|
|
5170
|
+
undefined,
|
|
5171
|
+
undefined,
|
|
5172
|
+
undefined,
|
|
5173
|
+
],
|
|
5107
5174
|
"rows": [
|
|
5108
5175
|
{
|
|
5109
5176
|
"cells": [
|
|
@@ -5575,6 +5642,11 @@ exports[`Test updateBlock > Update single prop 1`] = `
|
|
|
5575
5642
|
{
|
|
5576
5643
|
"children": [],
|
|
5577
5644
|
"content": {
|
|
5645
|
+
"columnWidths": [
|
|
5646
|
+
undefined,
|
|
5647
|
+
undefined,
|
|
5648
|
+
undefined,
|
|
5649
|
+
],
|
|
5578
5650
|
"rows": [
|
|
5579
5651
|
{
|
|
5580
5652
|
"cells": [
|
|
@@ -7235,6 +7307,11 @@ exports[`Test updateBlock > Update type 1`] = `
|
|
|
7235
7307
|
{
|
|
7236
7308
|
"children": [],
|
|
7237
7309
|
"content": {
|
|
7310
|
+
"columnWidths": [
|
|
7311
|
+
undefined,
|
|
7312
|
+
undefined,
|
|
7313
|
+
undefined,
|
|
7314
|
+
],
|
|
7238
7315
|
"rows": [
|
|
7239
7316
|
{
|
|
7240
7317
|
"cells": [
|
|
@@ -7705,6 +7782,11 @@ exports[`Test updateBlock > Update with plain content 1`] = `
|
|
|
7705
7782
|
{
|
|
7706
7783
|
"children": [],
|
|
7707
7784
|
"content": {
|
|
7785
|
+
"columnWidths": [
|
|
7786
|
+
undefined,
|
|
7787
|
+
undefined,
|
|
7788
|
+
undefined,
|
|
7789
|
+
],
|
|
7708
7790
|
"rows": [
|
|
7709
7791
|
{
|
|
7710
7792
|
"cells": [
|
|
@@ -8162,6 +8244,11 @@ exports[`Test updateBlock > Update with styled content 1`] = `
|
|
|
8162
8244
|
{
|
|
8163
8245
|
"children": [],
|
|
8164
8246
|
"content": {
|
|
8247
|
+
"columnWidths": [
|
|
8248
|
+
undefined,
|
|
8249
|
+
undefined,
|
|
8250
|
+
undefined,
|
|
8251
|
+
],
|
|
8165
8252
|
"rows": [
|
|
8166
8253
|
{
|
|
8167
8254
|
"cells": [
|
|
@@ -189,11 +189,11 @@ describe("Test updateBlock", () => {
|
|
|
189
189
|
});
|
|
190
190
|
|
|
191
191
|
it("Update inline content to empty table content", () => {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
192
|
+
expect(() => {
|
|
193
|
+
updateBlock(getEditor(), "paragraph-0", {
|
|
194
|
+
type: "table",
|
|
195
|
+
});
|
|
196
|
+
}).toThrow();
|
|
197
197
|
});
|
|
198
198
|
|
|
199
199
|
it("Update table content to empty inline content", () => {
|