@blocknote/core 0.18.0 → 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 +2191 -2068
- 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 +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 +5 -5
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +2 -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/moveBlock.ts +3 -5
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +100 -0
- package/src/api/blockManipulation/commands/removeBlocks/removeBlocks.ts +1 -1
- 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/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/handleFileInsertion.ts +1 -1
- 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 +113 -58
- 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/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 +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/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 +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 +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 +201 -48
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.ts +1 -1
- 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/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/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/VideoBlockContent/VideoBlockContent.d.ts +1 -0
- 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/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
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { BlockNoteSchema } from "../editor/BlockNoteSchema.js";
|
|
2
|
+
import {
|
|
3
|
+
BlockFromConfigNoChildren,
|
|
4
|
+
BlockSchema,
|
|
5
|
+
InlineContentFromConfig,
|
|
6
|
+
InlineContentSchema,
|
|
7
|
+
StyleSchema,
|
|
8
|
+
Styles,
|
|
9
|
+
} from "../schema/index.js";
|
|
10
|
+
import type { Exporter } from "./Exporter.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Defines a mapping from all block types with a schema to a result type `R`.
|
|
14
|
+
*/
|
|
15
|
+
export type BlockMapping<
|
|
16
|
+
B extends BlockSchema,
|
|
17
|
+
I extends InlineContentSchema,
|
|
18
|
+
S extends StyleSchema,
|
|
19
|
+
RB,
|
|
20
|
+
RI
|
|
21
|
+
> = {
|
|
22
|
+
[K in keyof B]: (
|
|
23
|
+
block: BlockFromConfigNoChildren<B[K], I, S>,
|
|
24
|
+
// we don't know the exact types that are supported by the exporter at this point,
|
|
25
|
+
// because the mapping only knows about converting certain types (which might be a subset of the supported types)
|
|
26
|
+
// this is why there are many `any` types here (same for types below)
|
|
27
|
+
exporter: Exporter<any, any, any, RB, RI, any, any>,
|
|
28
|
+
nestingLevel: number,
|
|
29
|
+
numberedListIndex?: number
|
|
30
|
+
) => RB | Promise<RB>;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Defines a mapping from all inline content types with a schema to a result type R.
|
|
35
|
+
*/
|
|
36
|
+
export type InlineContentMapping<
|
|
37
|
+
I extends InlineContentSchema,
|
|
38
|
+
S extends StyleSchema,
|
|
39
|
+
RI,
|
|
40
|
+
TS
|
|
41
|
+
> = {
|
|
42
|
+
[K in keyof I]: (
|
|
43
|
+
inlineContent: InlineContentFromConfig<I[K], S>,
|
|
44
|
+
exporter: Exporter<any, I, S, any, RI, any, TS>
|
|
45
|
+
) => RI;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Defines a mapping from all style types with a schema to a result type R.
|
|
50
|
+
*/
|
|
51
|
+
export type StyleMapping<S extends StyleSchema, RS> = {
|
|
52
|
+
[K in keyof S]: (
|
|
53
|
+
style: Styles<S>[K],
|
|
54
|
+
exporter: Exporter<any, any, any, any, any, RS, any>
|
|
55
|
+
) => RS;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The mapping factory is a utility function to easily create mappings for
|
|
60
|
+
* a BlockNoteSchema. Using the factory makes it easier to get typescript code completion etc.
|
|
61
|
+
*/
|
|
62
|
+
export function mappingFactory<
|
|
63
|
+
B extends BlockSchema,
|
|
64
|
+
I extends InlineContentSchema,
|
|
65
|
+
S extends StyleSchema
|
|
66
|
+
>(_schema: BlockNoteSchema<B, I, S>) {
|
|
67
|
+
return {
|
|
68
|
+
createBlockMapping: <R, RI>(mapping: BlockMapping<B, I, S, R, RI>) =>
|
|
69
|
+
mapping,
|
|
70
|
+
createInlineContentMapping: <R, RS>(
|
|
71
|
+
mapping: InlineContentMapping<I, S, R, RS>
|
|
72
|
+
) => mapping,
|
|
73
|
+
createStyleMapping: <R>(mapping: StyleMapping<S, R>) => mapping,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { Extension } from "@tiptap/core";
|
|
2
2
|
|
|
3
3
|
import { TextSelection } from "prosemirror-state";
|
|
4
|
+
import { ReplaceAroundStep } from "prosemirror-transform";
|
|
4
5
|
import {
|
|
5
|
-
|
|
6
|
+
getBottomNestedBlockInfo,
|
|
7
|
+
getParentBlockInfo,
|
|
8
|
+
getPrevBlockInfo,
|
|
6
9
|
mergeBlocksCommand,
|
|
7
10
|
} from "../../api/blockManipulation/commands/mergeBlocks/mergeBlocks.js";
|
|
11
|
+
import { nestBlock } from "../../api/blockManipulation/commands/nestBlock/nestBlock.js";
|
|
8
12
|
import { splitBlockCommand } from "../../api/blockManipulation/commands/splitBlock/splitBlock.js";
|
|
9
13
|
import { updateBlockCommand } from "../../api/blockManipulation/commands/updateBlock/updateBlock.js";
|
|
10
|
-
import {
|
|
11
|
-
getBlockInfoFromResolvedPos,
|
|
12
|
-
getBlockInfoFromSelection,
|
|
13
|
-
} from "../../api/getBlockInfoFromPos.js";
|
|
14
|
+
import { getBlockInfoFromSelection } from "../../api/getBlockInfoFromPos.js";
|
|
14
15
|
import { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
|
|
15
16
|
|
|
16
17
|
export const KeyboardShortcutsExtension = Extension.create<{
|
|
@@ -42,7 +43,7 @@ export const KeyboardShortcutsExtension = Extension.create<{
|
|
|
42
43
|
return commands.command(
|
|
43
44
|
updateBlockCommand(
|
|
44
45
|
this.options.editor,
|
|
45
|
-
blockInfo.
|
|
46
|
+
blockInfo.bnBlock.beforePos,
|
|
46
47
|
{
|
|
47
48
|
type: "paragraph",
|
|
48
49
|
props: {},
|
|
@@ -67,29 +68,20 @@ export const KeyboardShortcutsExtension = Extension.create<{
|
|
|
67
68
|
|
|
68
69
|
return false;
|
|
69
70
|
}),
|
|
70
|
-
// Merges block with the previous one if it isn't indented,
|
|
71
|
-
// first block in the doc, and the selection is at the start of the
|
|
71
|
+
// Merges block with the previous one if it isn't indented, and the selection is at the start of the
|
|
72
72
|
// block. The target block for merging must contain inline content.
|
|
73
73
|
() =>
|
|
74
74
|
commands.command(({ state }) => {
|
|
75
|
-
const { blockContainer, blockContent } =
|
|
75
|
+
const { bnBlock: blockContainer, blockContent } =
|
|
76
76
|
getBlockInfoFromSelection(state);
|
|
77
77
|
|
|
78
|
-
const { depth } = state.doc.resolve(blockContainer.beforePos);
|
|
79
|
-
|
|
80
78
|
const selectionAtBlockStart =
|
|
81
79
|
state.selection.from === blockContent.beforePos + 1;
|
|
82
80
|
const selectionEmpty = state.selection.empty;
|
|
83
|
-
const blockAtDocStart = blockContainer.beforePos === 1;
|
|
84
81
|
|
|
85
82
|
const posBetweenBlocks = blockContainer.beforePos;
|
|
86
83
|
|
|
87
|
-
if (
|
|
88
|
-
!blockAtDocStart &&
|
|
89
|
-
selectionAtBlockStart &&
|
|
90
|
-
selectionEmpty &&
|
|
91
|
-
depth === 1
|
|
92
|
-
) {
|
|
84
|
+
if (selectionAtBlockStart && selectionEmpty) {
|
|
93
85
|
return chain()
|
|
94
86
|
.command(mergeBlocksCommand(posBetweenBlocks))
|
|
95
87
|
.scrollIntoView()
|
|
@@ -98,6 +90,162 @@ export const KeyboardShortcutsExtension = Extension.create<{
|
|
|
98
90
|
|
|
99
91
|
return false;
|
|
100
92
|
}),
|
|
93
|
+
() =>
|
|
94
|
+
commands.command(({ state, dispatch }) => {
|
|
95
|
+
// when at the start of a first block in a column
|
|
96
|
+
const blockInfo = getBlockInfoFromSelection(state);
|
|
97
|
+
|
|
98
|
+
const selectionAtBlockStart =
|
|
99
|
+
state.selection.from === blockInfo.blockContent.beforePos + 1;
|
|
100
|
+
|
|
101
|
+
if (!selectionAtBlockStart) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const prevBlockInfo = getPrevBlockInfo(
|
|
106
|
+
state.doc,
|
|
107
|
+
blockInfo.bnBlock.beforePos
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
if (prevBlockInfo) {
|
|
111
|
+
// should be no previous block
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const parentBlockInfo = getParentBlockInfo(
|
|
116
|
+
state.doc,
|
|
117
|
+
blockInfo.bnBlock.beforePos
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
if (parentBlockInfo?.blockNoteType !== "column") {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const column = parentBlockInfo;
|
|
125
|
+
|
|
126
|
+
const columnList = getParentBlockInfo(
|
|
127
|
+
state.doc,
|
|
128
|
+
column.bnBlock.beforePos
|
|
129
|
+
);
|
|
130
|
+
if (columnList?.blockNoteType !== "columnList") {
|
|
131
|
+
throw new Error("parent of column is not a column list");
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const shouldRemoveColumn =
|
|
135
|
+
column.childContainer!.node.childCount === 1;
|
|
136
|
+
|
|
137
|
+
const shouldRemoveColumnList =
|
|
138
|
+
shouldRemoveColumn &&
|
|
139
|
+
columnList.childContainer!.node.childCount === 2;
|
|
140
|
+
|
|
141
|
+
const isFirstColumn =
|
|
142
|
+
columnList.childContainer!.node.firstChild ===
|
|
143
|
+
column.bnBlock.node;
|
|
144
|
+
|
|
145
|
+
if (dispatch) {
|
|
146
|
+
const blockToMove = state.doc.slice(
|
|
147
|
+
blockInfo.bnBlock.beforePos,
|
|
148
|
+
blockInfo.bnBlock.afterPos,
|
|
149
|
+
false
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
/*
|
|
153
|
+
There are 3 different cases:
|
|
154
|
+
a) remove entire column list (if no columns would be remaining)
|
|
155
|
+
b) remove just a column (if no blocks inside a column would be remaining)
|
|
156
|
+
c) keep columns (if there are blocks remaining inside a column)
|
|
157
|
+
|
|
158
|
+
Each of these 3 cases has 2 sub-cases, depending on whether the backspace happens at the start of the first (most-left) column,
|
|
159
|
+
or at the start of a non-first column.
|
|
160
|
+
*/
|
|
161
|
+
if (shouldRemoveColumnList) {
|
|
162
|
+
if (isFirstColumn) {
|
|
163
|
+
state.tr.step(
|
|
164
|
+
new ReplaceAroundStep(
|
|
165
|
+
// replace entire column list
|
|
166
|
+
columnList.bnBlock.beforePos,
|
|
167
|
+
columnList.bnBlock.afterPos,
|
|
168
|
+
// select content of remaining column:
|
|
169
|
+
column.bnBlock.afterPos + 1,
|
|
170
|
+
columnList.bnBlock.afterPos - 2,
|
|
171
|
+
blockToMove,
|
|
172
|
+
blockToMove.size, // append existing content to blockToMove
|
|
173
|
+
false
|
|
174
|
+
)
|
|
175
|
+
);
|
|
176
|
+
const pos = state.tr.doc.resolve(column.bnBlock.beforePos);
|
|
177
|
+
state.tr.setSelection(TextSelection.between(pos, pos));
|
|
178
|
+
} else {
|
|
179
|
+
// replaces the column list with the blockToMove slice, prepended with the content of the remaining column
|
|
180
|
+
state.tr.step(
|
|
181
|
+
new ReplaceAroundStep(
|
|
182
|
+
// replace entire column list
|
|
183
|
+
columnList.bnBlock.beforePos,
|
|
184
|
+
columnList.bnBlock.afterPos,
|
|
185
|
+
// select content of existing column:
|
|
186
|
+
columnList.bnBlock.beforePos + 2,
|
|
187
|
+
column.bnBlock.beforePos - 1,
|
|
188
|
+
blockToMove,
|
|
189
|
+
0, // prepend existing content to blockToMove
|
|
190
|
+
false
|
|
191
|
+
)
|
|
192
|
+
);
|
|
193
|
+
const pos = state.tr.doc.resolve(
|
|
194
|
+
state.tr.mapping.map(column.bnBlock.beforePos - 1)
|
|
195
|
+
);
|
|
196
|
+
state.tr.setSelection(TextSelection.between(pos, pos));
|
|
197
|
+
}
|
|
198
|
+
} else if (shouldRemoveColumn) {
|
|
199
|
+
if (isFirstColumn) {
|
|
200
|
+
// delete column
|
|
201
|
+
state.tr.delete(
|
|
202
|
+
column.bnBlock.beforePos,
|
|
203
|
+
column.bnBlock.afterPos
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
// move before columnlist
|
|
207
|
+
state.tr.insert(
|
|
208
|
+
columnList.bnBlock.beforePos,
|
|
209
|
+
blockToMove.content
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
const pos = state.tr.doc.resolve(
|
|
213
|
+
columnList.bnBlock.beforePos
|
|
214
|
+
);
|
|
215
|
+
state.tr.setSelection(TextSelection.between(pos, pos));
|
|
216
|
+
} else {
|
|
217
|
+
// just delete the </column><column> closing and opening tags to merge the columns
|
|
218
|
+
state.tr.delete(
|
|
219
|
+
column.bnBlock.beforePos - 1,
|
|
220
|
+
column.bnBlock.beforePos + 1
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
} else {
|
|
224
|
+
// delete block
|
|
225
|
+
state.tr.delete(
|
|
226
|
+
blockInfo.bnBlock.beforePos,
|
|
227
|
+
blockInfo.bnBlock.afterPos
|
|
228
|
+
);
|
|
229
|
+
if (isFirstColumn) {
|
|
230
|
+
// move before columnlist
|
|
231
|
+
state.tr.insert(
|
|
232
|
+
columnList.bnBlock.beforePos - 1,
|
|
233
|
+
blockToMove.content
|
|
234
|
+
);
|
|
235
|
+
} else {
|
|
236
|
+
// append block to previous column
|
|
237
|
+
state.tr.insert(
|
|
238
|
+
column.bnBlock.beforePos - 1,
|
|
239
|
+
blockToMove.content
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
const pos = state.tr.doc.resolve(column.bnBlock.beforePos - 1);
|
|
243
|
+
state.tr.setSelection(TextSelection.between(pos, pos));
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return true;
|
|
248
|
+
}),
|
|
101
249
|
// Deletes previous block if it contains no content and isn't a table,
|
|
102
250
|
// when the selection is empty and at the start of the block. Moves the
|
|
103
251
|
// current block into the deleted block's place.
|
|
@@ -105,47 +253,49 @@ export const KeyboardShortcutsExtension = Extension.create<{
|
|
|
105
253
|
commands.command(({ state }) => {
|
|
106
254
|
const blockInfo = getBlockInfoFromSelection(state);
|
|
107
255
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
256
|
+
if (!blockInfo.isBlockContainer) {
|
|
257
|
+
// TODO
|
|
258
|
+
throw new Error(`todo`);
|
|
259
|
+
}
|
|
111
260
|
|
|
112
261
|
const selectionAtBlockStart =
|
|
113
262
|
state.selection.from === blockInfo.blockContent.beforePos + 1;
|
|
114
263
|
const selectionEmpty = state.selection.empty;
|
|
115
|
-
const blockAtDocStart = blockInfo.blockContainer.beforePos === 1;
|
|
116
264
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
) {
|
|
123
|
-
const
|
|
265
|
+
const prevBlockInfo = getPrevBlockInfo(
|
|
266
|
+
state.doc,
|
|
267
|
+
blockInfo.bnBlock.beforePos
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
if (prevBlockInfo && selectionAtBlockStart && selectionEmpty) {
|
|
271
|
+
const bottomBlock = getBottomNestedBlockInfo(
|
|
124
272
|
state.doc,
|
|
125
|
-
|
|
126
|
-
);
|
|
127
|
-
const prevBlockInfo = getBlockInfoFromResolvedPos(
|
|
128
|
-
state.doc.resolve(prevBlockPos.pos)
|
|
273
|
+
prevBlockInfo
|
|
129
274
|
);
|
|
130
275
|
|
|
276
|
+
if (!bottomBlock.isBlockContainer) {
|
|
277
|
+
// TODO
|
|
278
|
+
throw new Error(`todo`);
|
|
279
|
+
}
|
|
280
|
+
|
|
131
281
|
const prevBlockNotTableAndNoContent =
|
|
132
|
-
|
|
133
|
-
(
|
|
282
|
+
bottomBlock.blockContent.node.type.spec.content === "" ||
|
|
283
|
+
(bottomBlock.blockContent.node.type.spec.content ===
|
|
134
284
|
"inline*" &&
|
|
135
|
-
|
|
285
|
+
bottomBlock.blockContent.node.childCount === 0);
|
|
136
286
|
|
|
137
287
|
if (prevBlockNotTableAndNoContent) {
|
|
138
288
|
return chain()
|
|
139
289
|
.cut(
|
|
140
290
|
{
|
|
141
|
-
from: blockInfo.
|
|
142
|
-
to: blockInfo.
|
|
291
|
+
from: blockInfo.bnBlock.beforePos,
|
|
292
|
+
to: blockInfo.bnBlock.afterPos,
|
|
143
293
|
},
|
|
144
|
-
|
|
294
|
+
bottomBlock.bnBlock.afterPos
|
|
145
295
|
)
|
|
146
296
|
.deleteRange({
|
|
147
|
-
from:
|
|
148
|
-
to:
|
|
297
|
+
from: bottomBlock.bnBlock.beforePos,
|
|
298
|
+
to: bottomBlock.bnBlock.afterPos,
|
|
149
299
|
})
|
|
150
300
|
.run();
|
|
151
301
|
}
|
|
@@ -165,8 +315,11 @@ export const KeyboardShortcutsExtension = Extension.create<{
|
|
|
165
315
|
() =>
|
|
166
316
|
commands.command(({ state }) => {
|
|
167
317
|
// TODO: Change this to not rely on offsets & schema assumptions
|
|
168
|
-
const {
|
|
169
|
-
|
|
318
|
+
const {
|
|
319
|
+
bnBlock: blockContainer,
|
|
320
|
+
blockContent,
|
|
321
|
+
childContainer,
|
|
322
|
+
} = getBlockInfoFromSelection(state);
|
|
170
323
|
|
|
171
324
|
const { depth } = state.doc.resolve(blockContainer.beforePos);
|
|
172
325
|
const blockAtDocEnd =
|
|
@@ -174,7 +327,7 @@ export const KeyboardShortcutsExtension = Extension.create<{
|
|
|
174
327
|
const selectionAtBlockEnd =
|
|
175
328
|
state.selection.from === blockContent.afterPos - 1;
|
|
176
329
|
const selectionEmpty = state.selection.empty;
|
|
177
|
-
const hasChildBlocks =
|
|
330
|
+
const hasChildBlocks = childContainer !== undefined;
|
|
178
331
|
|
|
179
332
|
if (
|
|
180
333
|
!blockAtDocEnd &&
|
|
@@ -205,7 +358,7 @@ export const KeyboardShortcutsExtension = Extension.create<{
|
|
|
205
358
|
// of the block.
|
|
206
359
|
() =>
|
|
207
360
|
commands.command(({ state }) => {
|
|
208
|
-
const { blockContent, blockContainer } =
|
|
361
|
+
const { blockContent, bnBlock: blockContainer } =
|
|
209
362
|
getBlockInfoFromSelection(state);
|
|
210
363
|
|
|
211
364
|
const { depth } = state.doc.resolve(blockContainer.beforePos);
|
|
@@ -232,7 +385,7 @@ export const KeyboardShortcutsExtension = Extension.create<{
|
|
|
232
385
|
// empty & at the start of the block.
|
|
233
386
|
() =>
|
|
234
387
|
commands.command(({ state, dispatch }) => {
|
|
235
|
-
const { blockContainer, blockContent } =
|
|
388
|
+
const { bnBlock: blockContainer, blockContent } =
|
|
236
389
|
getBlockInfoFromSelection(state);
|
|
237
390
|
|
|
238
391
|
const selectionAtBlockStart =
|
|
@@ -306,8 +459,8 @@ export const KeyboardShortcutsExtension = Extension.create<{
|
|
|
306
459
|
// don't handle tabs if a toolbar is shown, so we can tab into / out of it
|
|
307
460
|
return false;
|
|
308
461
|
}
|
|
309
|
-
this.editor
|
|
310
|
-
return true;
|
|
462
|
+
return nestBlock(this.options.editor);
|
|
463
|
+
// return true;
|
|
311
464
|
},
|
|
312
465
|
"Shift-Tab": () => {
|
|
313
466
|
if (
|