@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
package/src/editor/editor.css
CHANGED
|
@@ -104,22 +104,60 @@ Tippy popups that are appended to document.body directly
|
|
|
104
104
|
white-space: nowrap;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
/* .tableWrapper {
|
|
108
|
+
padding
|
|
109
|
+
} */
|
|
110
|
+
|
|
111
|
+
.ProseMirror .tableWrapper {
|
|
112
|
+
position: relative;
|
|
113
|
+
top: -16px;
|
|
114
|
+
left: -16px;
|
|
115
|
+
/* padding: 16px; */
|
|
116
|
+
min-width: calc(100% + 16px);
|
|
117
|
+
padding-bottom: 16px;
|
|
118
|
+
overflow-y: hidden;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.ProseMirror .tableWrapper-inner {
|
|
122
|
+
/* position: relative; */
|
|
123
|
+
/* top: -16px;
|
|
124
|
+
left: -16px; */
|
|
125
|
+
padding: 16px;
|
|
126
|
+
}
|
|
127
|
+
|
|
107
128
|
/* table related: */
|
|
108
129
|
.bn-editor table {
|
|
109
130
|
width: auto !important;
|
|
131
|
+
word-break: break-word;
|
|
110
132
|
}
|
|
111
133
|
.bn-editor th,
|
|
112
134
|
.bn-editor td {
|
|
113
|
-
min-width: 1em;
|
|
114
135
|
border: 1px solid #ddd;
|
|
115
136
|
padding: 3px 5px;
|
|
116
137
|
}
|
|
117
138
|
|
|
118
|
-
.bn-editor .tableWrapper {
|
|
119
|
-
margin: 1em 0;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
139
|
.bn-editor th {
|
|
123
140
|
font-weight: bold;
|
|
124
141
|
text-align: left;
|
|
125
142
|
}
|
|
143
|
+
|
|
144
|
+
/* tiptap uses colwidth instead of data-colwidth, se we need to adjust this style from prosemirror-tables */
|
|
145
|
+
.ProseMirror td,
|
|
146
|
+
.ProseMirror th {
|
|
147
|
+
min-width: auto !important;
|
|
148
|
+
}
|
|
149
|
+
.ProseMirror td:not([colwidth]):not(.column-resize-dragging),
|
|
150
|
+
.ProseMirror th:not([colwidth]):not(.column-resize-dragging) {
|
|
151
|
+
/* if there's no explicit width set and the column is not being resized, set a default width */
|
|
152
|
+
min-width: var(--default-cell-min-width) !important;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.prosemirror-dropcursor-block {
|
|
156
|
+
transition-property: top, bottom;
|
|
157
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
158
|
+
transition-duration: 0.15s;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.prosemirror-dropcursor-vertical {
|
|
162
|
+
transition-property: left, right;
|
|
163
|
+
}
|
|
@@ -32,7 +32,10 @@ export function wrapTableRows(f: Fragment, schema: Schema) {
|
|
|
32
32
|
newItems[newItems.length - 1] = newTable;
|
|
33
33
|
} else {
|
|
34
34
|
// create new table to wrap tableRow with
|
|
35
|
-
const newTable = schema.nodes.table.
|
|
35
|
+
const newTable = schema.nodes.table.createChecked(
|
|
36
|
+
undefined,
|
|
37
|
+
f.child(i)
|
|
38
|
+
);
|
|
36
39
|
newItems.push(newTable);
|
|
37
40
|
}
|
|
38
41
|
} else {
|
|
@@ -64,7 +67,7 @@ export function transformPasted(slice: Slice, view: EditorView) {
|
|
|
64
67
|
// (if we remove this if-block, the nesting bug will be fixed, but lists won't be nested correctly)
|
|
65
68
|
if (
|
|
66
69
|
i + 1 < f.childCount &&
|
|
67
|
-
f.child(i + 1).type.
|
|
70
|
+
f.child(i + 1).type.name === "blockGroup" // TODO
|
|
68
71
|
) {
|
|
69
72
|
const nestedChild = f
|
|
70
73
|
.child(i + 1)
|
|
@@ -80,7 +83,7 @@ export function transformPasted(slice: Slice, view: EditorView) {
|
|
|
80
83
|
f = removeChild(f, i + 1);
|
|
81
84
|
}
|
|
82
85
|
}
|
|
83
|
-
const container = view.state.schema.nodes.blockContainer.
|
|
86
|
+
const container = view.state.schema.nodes.blockContainer.createChecked(
|
|
84
87
|
undefined,
|
|
85
88
|
content
|
|
86
89
|
);
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { BlockNoteSchema } from "../editor/BlockNoteSchema.js";
|
|
2
|
+
import { COLORS_DEFAULT } from "../editor/defaultColors.js";
|
|
3
|
+
import {
|
|
4
|
+
BlockFromConfig,
|
|
5
|
+
BlockSchema,
|
|
6
|
+
InlineContent,
|
|
7
|
+
InlineContentSchema,
|
|
8
|
+
StyleSchema,
|
|
9
|
+
StyledText,
|
|
10
|
+
Styles,
|
|
11
|
+
} from "../schema/index.js";
|
|
12
|
+
|
|
13
|
+
import type {
|
|
14
|
+
BlockMapping,
|
|
15
|
+
InlineContentMapping,
|
|
16
|
+
StyleMapping,
|
|
17
|
+
} from "./mapping.js";
|
|
18
|
+
|
|
19
|
+
export type ExporterOptions = {
|
|
20
|
+
/**
|
|
21
|
+
* A function that can be used to resolve files, images, etc.
|
|
22
|
+
* Exporters might need the binary contents of files like images,
|
|
23
|
+
* which might not always be available from the same origin as the main page.
|
|
24
|
+
* You can use this option to proxy requests through a server you control
|
|
25
|
+
* to avoid cross-origin (CORS) issues.
|
|
26
|
+
*
|
|
27
|
+
* @default uses a BlockNote hosted proxy (https://corsproxy.api.blocknotejs.org/)
|
|
28
|
+
* @param url - The URL of the file to resolve
|
|
29
|
+
* @returns A Promise that resolves to a string (the URL to use instead of the original)
|
|
30
|
+
* or a Blob (you can return the Blob directly if you have already fetched it)
|
|
31
|
+
*/
|
|
32
|
+
resolveFileUrl?: (url: string) => Promise<string | Blob>;
|
|
33
|
+
/**
|
|
34
|
+
* Colors to use for background of blocks, font colors, and highlight colors
|
|
35
|
+
*/
|
|
36
|
+
colors: typeof COLORS_DEFAULT;
|
|
37
|
+
};
|
|
38
|
+
export abstract class Exporter<
|
|
39
|
+
B extends BlockSchema,
|
|
40
|
+
I extends InlineContentSchema,
|
|
41
|
+
S extends StyleSchema,
|
|
42
|
+
RB,
|
|
43
|
+
RI,
|
|
44
|
+
RS,
|
|
45
|
+
TS
|
|
46
|
+
> {
|
|
47
|
+
public constructor(
|
|
48
|
+
_schema: BlockNoteSchema<B, I, S>, // only used for type inference
|
|
49
|
+
protected readonly mappings: {
|
|
50
|
+
blockMapping: BlockMapping<B, I, S, RB, RI>;
|
|
51
|
+
inlineContentMapping: InlineContentMapping<I, S, RI, TS>;
|
|
52
|
+
styleMapping: StyleMapping<S, RS>;
|
|
53
|
+
},
|
|
54
|
+
public readonly options: ExporterOptions
|
|
55
|
+
) {}
|
|
56
|
+
|
|
57
|
+
public async resolveFile(url: string) {
|
|
58
|
+
if (!this.options?.resolveFileUrl) {
|
|
59
|
+
return (await fetch(url)).blob();
|
|
60
|
+
}
|
|
61
|
+
const ret = await this.options.resolveFileUrl(url);
|
|
62
|
+
if (ret instanceof Blob) {
|
|
63
|
+
return ret;
|
|
64
|
+
}
|
|
65
|
+
return (await fetch(ret)).blob();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public mapStyles(styles: Styles<S>) {
|
|
69
|
+
const stylesArray = Object.entries(styles).map(([key, value]) => {
|
|
70
|
+
const mappedStyle = this.mappings.styleMapping[key](value, this);
|
|
71
|
+
return mappedStyle;
|
|
72
|
+
});
|
|
73
|
+
return stylesArray;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public mapInlineContent(inlineContent: InlineContent<I, S>) {
|
|
77
|
+
return this.mappings.inlineContentMapping[inlineContent.type](
|
|
78
|
+
inlineContent,
|
|
79
|
+
this
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
public transformInlineContent(inlineContentArray: InlineContent<I, S>[]) {
|
|
84
|
+
return inlineContentArray.map((ic) => this.mapInlineContent(ic));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
public abstract transformStyledText(styledText: StyledText<S>): TS;
|
|
88
|
+
|
|
89
|
+
public async mapBlock(
|
|
90
|
+
block: BlockFromConfig<B[keyof B], I, S>,
|
|
91
|
+
nestingLevel: number,
|
|
92
|
+
numberedListIndex: number
|
|
93
|
+
) {
|
|
94
|
+
return this.mappings.blockMapping[block.type](
|
|
95
|
+
block,
|
|
96
|
+
this,
|
|
97
|
+
nestingLevel,
|
|
98
|
+
numberedListIndex
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -35,6 +35,14 @@ export class FormattingToolbarView implements PluginView {
|
|
|
35
35
|
const isEmptyTextBlock =
|
|
36
36
|
!doc.textBetween(from, to).length && isTextSelection(state.selection);
|
|
37
37
|
|
|
38
|
+
// Don't show toolbar inside code blocks
|
|
39
|
+
if (
|
|
40
|
+
selection.$from.parent.type.spec.code ||
|
|
41
|
+
(isNodeSelection(selection) && selection.node.type.spec.code)
|
|
42
|
+
) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
|
|
38
46
|
// check view.hasFocus so that the toolbar doesn't show up when the editor is not focused or when for example a code block is focused
|
|
39
47
|
return !(!view.hasFocus() || empty || isEmptyTextBlock);
|
|
40
48
|
};
|
|
@@ -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 (
|
|
@@ -88,6 +88,11 @@ export const PlaceholderPlugin = (
|
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
// Don't show placeholder when the cursor is inside a code block
|
|
92
|
+
if (selection.$from.parent.type.spec.code) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
91
96
|
const $pos = selection.$anchor;
|
|
92
97
|
const node = $pos.parent;
|
|
93
98
|
|