@blocknote/core 0.18.0 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/blocknote.js +3145 -2970
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +9 -9
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js +27 -0
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.js +99 -0
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.js +97 -0
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.js +88 -0
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.js +116 -0
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.test.js +110 -0
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/nestBlock/nestBlock.js +57 -0
- package/dist/src/api/blockManipulation/commands/nestBlock/nestBlock.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js +5 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js +31 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js +71 -0
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.js +157 -0
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js +27 -0
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js +64 -0
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js +145 -0
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.test.js +252 -0
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.test.js.map +1 -0
- package/dist/src/api/blockManipulation/insertContentAt.js +64 -0
- package/dist/src/api/blockManipulation/insertContentAt.js.map +1 -0
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js +76 -0
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js.map +1 -0
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.js +33 -0
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.js.map +1 -0
- package/dist/src/api/blockManipulation/setupTestEnv.js +172 -0
- package/dist/src/api/blockManipulation/setupTestEnv.js.map +1 -0
- package/dist/src/api/clipboard/clipboard.test.js +246 -0
- package/dist/src/api/clipboard/clipboard.test.js.map +1 -0
- package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js +8 -0
- package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js.map +1 -0
- package/dist/src/api/clipboard/fromClipboard/fileDropExtension.js +38 -0
- package/dist/src/api/clipboard/fromClipboard/fileDropExtension.js.map +1 -0
- package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js +111 -0
- package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js.map +1 -0
- package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js +26 -0
- package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js.map +1 -0
- package/dist/src/api/clipboard/fromClipboard/pasteExtension.js +57 -0
- package/dist/src/api/clipboard/fromClipboard/pasteExtension.js.map +1 -0
- package/dist/src/api/clipboard/toClipboard/copyExtension.js +132 -0
- package/dist/src/api/clipboard/toClipboard/copyExtension.js.map +1 -0
- package/dist/src/api/exporters/html/externalHTMLExporter.js +35 -0
- package/dist/src/api/exporters/html/externalHTMLExporter.js.map +1 -0
- package/dist/src/api/exporters/html/htmlConversion.test.js +72 -0
- package/dist/src/api/exporters/html/htmlConversion.test.js.map +1 -0
- package/dist/src/api/exporters/html/internalHTMLSerializer.js +21 -0
- package/dist/src/api/exporters/html/internalHTMLSerializer.js.map +1 -0
- package/dist/src/api/exporters/html/util/serializeBlocksExternalHTML.js +141 -0
- package/dist/src/api/exporters/html/util/serializeBlocksExternalHTML.js.map +1 -0
- package/dist/src/api/exporters/html/util/serializeBlocksInternalHTML.js +96 -0
- package/dist/src/api/exporters/html/util/serializeBlocksInternalHTML.js.map +1 -0
- package/dist/src/api/exporters/markdown/markdownExporter.js +31 -0
- package/dist/src/api/exporters/markdown/markdownExporter.js.map +1 -0
- package/dist/src/api/exporters/markdown/markdownExporter.test.js +57 -0
- package/dist/src/api/exporters/markdown/markdownExporter.test.js.map +1 -0
- package/dist/src/api/exporters/markdown/removeUnderlinesRehypePlugin.js +33 -0
- package/dist/src/api/exporters/markdown/removeUnderlinesRehypePlugin.js.map +1 -0
- package/dist/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.js +37 -0
- package/dist/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.js.map +1 -0
- package/dist/src/api/getBlockInfoFromPos.js +165 -0
- package/dist/src/api/getBlockInfoFromPos.js.map +1 -0
- package/dist/src/api/nodeConversions/blockToNode.js +197 -0
- package/dist/src/api/nodeConversions/blockToNode.js.map +1 -0
- package/dist/src/api/nodeConversions/fragmentToBlocks.js +50 -0
- package/dist/src/api/nodeConversions/fragmentToBlocks.js.map +1 -0
- package/dist/src/api/nodeConversions/nodeConversions.test.js +54 -0
- package/dist/src/api/nodeConversions/nodeConversions.test.js.map +1 -0
- package/dist/src/api/nodeConversions/nodeToBlock.js +316 -0
- package/dist/src/api/nodeConversions/nodeToBlock.js.map +1 -0
- package/dist/src/api/nodeUtil.js +28 -0
- package/dist/src/api/nodeUtil.js.map +1 -0
- package/dist/src/api/parsers/html/parseHTML.js +19 -0
- package/dist/src/api/parsers/html/parseHTML.js.map +1 -0
- package/dist/src/api/parsers/html/parseHTML.test.js +470 -0
- package/dist/src/api/parsers/html/parseHTML.test.js.map +1 -0
- package/dist/src/api/parsers/html/util/nestedLists.js +106 -0
- package/dist/src/api/parsers/html/util/nestedLists.js.map +1 -0
- package/dist/src/api/parsers/html/util/nestedLists.test.js +166 -0
- package/dist/src/api/parsers/html/util/nestedLists.test.js.map +1 -0
- package/dist/src/api/parsers/markdown/parseMarkdown.js +52 -0
- package/dist/src/api/parsers/markdown/parseMarkdown.js.map +1 -0
- package/dist/src/api/parsers/markdown/parseMarkdown.test.js +109 -0
- package/dist/src/api/parsers/markdown/parseMarkdown.test.js.map +1 -0
- package/dist/src/api/testUtil/cases/customBlocks.js +313 -0
- package/dist/src/api/testUtil/cases/customBlocks.js.map +1 -0
- package/dist/src/api/testUtil/cases/customInlineContent.js +91 -0
- package/dist/src/api/testUtil/cases/customInlineContent.js.map +1 -0
- package/dist/src/api/testUtil/cases/customStyles.js +83 -0
- package/dist/src/api/testUtil/cases/customStyles.js.map +1 -0
- package/dist/src/api/testUtil/cases/defaultSchema.js +673 -0
- package/dist/src/api/testUtil/cases/defaultSchema.js.map +1 -0
- package/dist/src/api/testUtil/index.js +2 -0
- package/dist/src/api/testUtil/index.js.map +1 -0
- package/dist/src/api/testUtil/partialBlockTestUtil.js +114 -0
- package/dist/src/api/testUtil/partialBlockTestUtil.js.map +1 -0
- package/dist/src/api/testUtil/paste.js +29 -0
- package/dist/src/api/testUtil/paste.js.map +1 -0
- package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js +97 -0
- package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js.map +1 -0
- package/dist/src/blocks/AudioBlockContent/audioBlockHelpers.js +5 -0
- package/dist/src/blocks/AudioBlockContent/audioBlockHelpers.js.map +1 -0
- package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js +273 -0
- package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js.map +1 -0
- package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js +90 -0
- package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/FileBlockContent.js +70 -0
- package/dist/src/blocks/FileBlockContent/FileBlockContent.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/fileBlockHelpers.js +317 -0
- package/dist/src/blocks/FileBlockContent/fileBlockHelpers.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js +15 -0
- package/dist/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js.map +1 -0
- package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js +145 -0
- package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js.map +1 -0
- package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js +106 -0
- package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js.map +1 -0
- package/dist/src/blocks/ImageBlockContent/imageBlockHelpers.js +6 -0
- package/dist/src/blocks/ImageBlockContent/imageBlockHelpers.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js +113 -0
- package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js +224 -0
- package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js +45 -0
- package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.js +58 -0
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js +130 -0
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js.map +1 -0
- package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js +52 -0
- package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js.map +1 -0
- package/dist/src/blocks/TableBlockContent/TableBlockContent.js +129 -0
- package/dist/src/blocks/TableBlockContent/TableBlockContent.js.map +1 -0
- package/dist/src/blocks/TableBlockContent/TableExtension.js +57 -0
- package/dist/src/blocks/TableBlockContent/TableExtension.js.map +1 -0
- package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js +103 -0
- package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js.map +1 -0
- package/dist/src/blocks/VideoBlockContent/videoBlockHelpers.js +6 -0
- package/dist/src/blocks/VideoBlockContent/videoBlockHelpers.js.map +1 -0
- package/dist/src/blocks/defaultBlockHelpers.js +50 -0
- package/dist/src/blocks/defaultBlockHelpers.js.map +1 -0
- package/dist/src/blocks/defaultBlockTypeGuards.js +40 -0
- package/dist/src/blocks/defaultBlockTypeGuards.js.map +1 -0
- package/dist/src/blocks/defaultBlocks.js +50 -0
- package/dist/src/blocks/defaultBlocks.js.map +1 -0
- package/dist/src/blocks/defaultProps.js +19 -0
- package/dist/src/blocks/defaultProps.js.map +1 -0
- package/dist/src/editor/BlockNoteEditor.js +746 -0
- package/dist/src/editor/BlockNoteEditor.js.map +1 -0
- package/dist/src/editor/BlockNoteEditor.test.js +65 -0
- package/dist/src/editor/BlockNoteEditor.test.js.map +1 -0
- package/dist/src/editor/BlockNoteExtensions.js +195 -0
- package/dist/src/editor/BlockNoteExtensions.js.map +1 -0
- package/dist/src/editor/BlockNoteSchema.js +38 -0
- package/dist/src/editor/BlockNoteSchema.js.map +1 -0
- package/dist/src/editor/BlockNoteTipTapEditor.js +169 -0
- package/dist/src/editor/BlockNoteTipTapEditor.js.map +1 -0
- package/dist/src/editor/cursorPositionTypes.js +2 -0
- package/dist/src/editor/cursorPositionTypes.js.map +1 -0
- package/dist/src/editor/defaultColors.js +77 -0
- package/dist/src/editor/defaultColors.js.map +1 -0
- package/dist/src/editor/selectionTypes.js +2 -0
- package/dist/src/editor/selectionTypes.js.map +1 -0
- package/dist/src/editor/transformPasted.js +79 -0
- package/dist/src/editor/transformPasted.js.map +1 -0
- package/dist/src/exporter/Exporter.js +36 -0
- package/dist/src/exporter/Exporter.js.map +1 -0
- package/dist/src/exporter/index.js +3 -0
- package/dist/src/exporter/index.js.map +1 -0
- package/dist/src/exporter/mapping.js +12 -0
- package/dist/src/exporter/mapping.js.map +1 -0
- package/dist/src/extensions/BackgroundColor/BackgroundColorExtension.js +30 -0
- package/dist/src/extensions/BackgroundColor/BackgroundColorExtension.js.map +1 -0
- package/dist/src/extensions/BackgroundColor/BackgroundColorMark.js +39 -0
- package/dist/src/extensions/BackgroundColor/BackgroundColorMark.js.map +1 -0
- package/dist/src/extensions/FilePanel/FilePanelPlugin.js +131 -0
- package/dist/src/extensions/FilePanel/FilePanelPlugin.js.map +1 -0
- package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js +195 -0
- package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js.map +1 -0
- package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js +339 -0
- package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js.map +1 -0
- package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js +247 -0
- package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js.map +1 -0
- package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js +54 -0
- package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js.map +1 -0
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js +84 -0
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js.map +1 -0
- package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js +187 -0
- package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js.map +1 -0
- package/dist/src/extensions/SideMenu/MultipleNodeSelection.js +68 -0
- package/dist/src/extensions/SideMenu/MultipleNodeSelection.js.map +1 -0
- package/dist/src/extensions/SideMenu/SideMenuPlugin.js +339 -0
- package/dist/src/extensions/SideMenu/SideMenuPlugin.js.map +1 -0
- package/dist/src/extensions/SideMenu/dragging.js +128 -0
- package/dist/src/extensions/SideMenu/dragging.js.map +1 -0
- package/dist/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.js +2 -0
- package/dist/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.js.map +1 -0
- package/dist/src/extensions/SuggestionMenu/DefaultSuggestionItem.js +2 -0
- package/dist/src/extensions/SuggestionMenu/DefaultSuggestionItem.js.map +1 -0
- package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js +245 -0
- package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js.map +1 -0
- package/dist/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.js +26 -0
- package/dist/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.js.map +1 -0
- package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js +244 -0
- package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js.map +1 -0
- package/dist/src/extensions/TableHandles/TableHandlesPlugin.js +553 -0
- package/dist/src/extensions/TableHandles/TableHandlesPlugin.js.map +1 -0
- package/dist/src/extensions/TextAlignment/TextAlignmentExtension.js +36 -0
- package/dist/src/extensions/TextAlignment/TextAlignmentExtension.js.map +1 -0
- package/dist/src/extensions/TextColor/TextColorExtension.js +29 -0
- package/dist/src/extensions/TextColor/TextColorExtension.js.map +1 -0
- package/dist/src/extensions/TextColor/TextColorMark.js +37 -0
- package/dist/src/extensions/TextColor/TextColorMark.js.map +1 -0
- package/dist/src/extensions/TrailingNode/TrailingNodeExtension.js +58 -0
- package/dist/src/extensions/TrailingNode/TrailingNodeExtension.js.map +1 -0
- package/dist/src/extensions/UniqueID/UniqueID.js +283 -0
- package/dist/src/extensions/UniqueID/UniqueID.js.map +1 -0
- package/dist/src/extensions/getDraggableBlockFromElement.js +13 -0
- package/dist/src/extensions/getDraggableBlockFromElement.js.map +1 -0
- package/dist/src/extensions-shared/UiElementPosition.js +2 -0
- package/dist/src/extensions-shared/UiElementPosition.js.map +1 -0
- package/dist/src/i18n/dictionary.js +4 -0
- package/dist/src/i18n/dictionary.js.map +1 -0
- package/dist/src/i18n/locales/ar.js +298 -0
- package/dist/src/i18n/locales/ar.js.map +1 -0
- package/dist/src/i18n/locales/de.js +313 -0
- package/dist/src/i18n/locales/de.js.map +1 -0
- package/dist/src/i18n/locales/en.js +314 -0
- package/dist/src/i18n/locales/en.js.map +1 -0
- package/dist/src/i18n/locales/es.js +312 -0
- package/dist/src/i18n/locales/es.js.map +1 -0
- package/dist/src/i18n/locales/fr.js +313 -0
- package/dist/src/i18n/locales/fr.js.map +1 -0
- package/dist/src/i18n/locales/hr.js +308 -0
- package/dist/src/i18n/locales/hr.js.map +1 -0
- package/dist/src/i18n/locales/index.js +16 -0
- package/dist/src/i18n/locales/index.js.map +1 -0
- package/dist/src/i18n/locales/is.js +305 -0
- package/dist/src/i18n/locales/is.js.map +1 -0
- package/dist/src/i18n/locales/ja.js +333 -0
- package/dist/src/i18n/locales/ja.js.map +1 -0
- package/dist/src/i18n/locales/ko.js +326 -0
- package/dist/src/i18n/locales/ko.js.map +1 -0
- package/dist/src/i18n/locales/nl.js +313 -0
- package/dist/src/i18n/locales/nl.js.map +1 -0
- package/dist/src/i18n/locales/pl.js +297 -0
- package/dist/src/i18n/locales/pl.js.map +1 -0
- package/dist/src/i18n/locales/pt.js +305 -0
- package/dist/src/i18n/locales/pt.js.map +1 -0
- package/dist/src/i18n/locales/ru.js +340 -0
- package/dist/src/i18n/locales/ru.js.map +1 -0
- package/dist/src/i18n/locales/vi.js +312 -0
- package/dist/src/i18n/locales/vi.js.map +1 -0
- package/dist/src/i18n/locales/zh.js +346 -0
- package/dist/src/i18n/locales/zh.js.map +1 -0
- package/dist/src/index.js +55 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/pm-nodes/BlockContainer.js +72 -0
- package/dist/src/pm-nodes/BlockContainer.js.map +1 -0
- package/dist/src/pm-nodes/BlockGroup.js +43 -0
- package/dist/src/pm-nodes/BlockGroup.js.map +1 -0
- package/dist/src/pm-nodes/Doc.js +7 -0
- package/dist/src/pm-nodes/Doc.js.map +1 -0
- package/dist/src/pm-nodes/index.js +4 -0
- package/dist/src/pm-nodes/index.js.map +1 -0
- package/dist/src/schema/blocks/createSpec.js +126 -0
- package/dist/src/schema/blocks/createSpec.js.map +1 -0
- package/dist/src/schema/blocks/internal.js +147 -0
- package/dist/src/schema/blocks/internal.js.map +1 -0
- package/dist/src/schema/blocks/types.js +2 -0
- package/dist/src/schema/blocks/types.js.map +1 -0
- package/dist/src/schema/index.js +11 -0
- package/dist/src/schema/index.js.map +1 -0
- package/dist/src/schema/inlineContent/createSpec.js +64 -0
- package/dist/src/schema/inlineContent/createSpec.js.map +1 -0
- package/dist/src/schema/inlineContent/internal.js +52 -0
- package/dist/src/schema/inlineContent/internal.js.map +1 -0
- package/dist/src/schema/inlineContent/types.js +10 -0
- package/dist/src/schema/inlineContent/types.js.map +1 -0
- package/dist/src/schema/propTypes.js +2 -0
- package/dist/src/schema/propTypes.js.map +1 -0
- package/dist/src/schema/styles/createSpec.js +48 -0
- package/dist/src/schema/styles/createSpec.js.map +1 -0
- package/dist/src/schema/styles/internal.js +53 -0
- package/dist/src/schema/styles/internal.js.map +1 -0
- package/dist/src/schema/styles/types.js +2 -0
- package/dist/src/schema/styles/types.js.map +1 -0
- package/dist/src/util/EventEmitter.js +33 -0
- package/dist/src/util/EventEmitter.js.map +1 -0
- package/dist/src/util/browser.js +17 -0
- package/dist/src/util/browser.js.map +1 -0
- package/dist/src/util/combineByGroup.js +20 -0
- package/dist/src/util/combineByGroup.js.map +1 -0
- package/dist/src/util/esmDependencies.js +35 -0
- package/dist/src/util/esmDependencies.js.map +1 -0
- package/dist/src/util/string.js +14 -0
- package/dist/src/util/string.js.map +1 -0
- package/dist/src/util/typescript.js +12 -0
- package/dist/src/util/typescript.js.map +1 -0
- package/dist/style.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/webpack-stats.json +1 -1
- package/package.json +5 -5
- package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +0 -6
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +2 -0
- package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +0 -5
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +2 -2
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +104 -39
- package/src/api/blockManipulation/commands/moveBlock/__snapshots__/moveBlock.test.ts.snap +0 -8
- package/src/api/blockManipulation/commands/moveBlock/moveBlock.test.ts +7 -3
- package/src/api/blockManipulation/commands/moveBlock/moveBlock.ts +3 -5
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +100 -0
- package/src/api/blockManipulation/commands/removeBlocks/__snapshots__/removeBlocks.test.ts.snap +439 -2
- package/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.ts +6 -0
- package/src/api/blockManipulation/commands/removeBlocks/removeBlocks.ts +2 -82
- package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +0 -8
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +96 -20
- package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +0 -6
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +8 -4
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +13 -12
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +0 -490
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +5 -5
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +192 -107
- package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.ts +48 -33
- package/src/api/clipboard/fromClipboard/acceptedMIMETypes.ts +1 -1
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +7 -6
- package/src/api/clipboard/toClipboard/copyExtension.ts +1 -1
- package/src/api/exporters/html/htmlConversion.test.ts +1 -4
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +7 -1
- package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +56 -19
- package/src/api/exporters/markdown/markdownExporter.test.ts +1 -4
- package/src/api/getBlockInfoFromPos.ts +125 -80
- package/src/api/nodeConversions/blockToNode.ts +50 -25
- package/src/api/nodeConversions/fragmentToBlocks.ts +18 -0
- package/src/api/nodeConversions/nodeToBlock.ts +24 -21
- package/src/api/nodeUtil.ts +1 -1
- package/src/api/parsers/html/__snapshots__/parse-notion-html.json +1 -2
- package/src/api/testUtil/partialBlockTestUtil.ts +15 -3
- package/src/blocks/AudioBlockContent/AudioBlockContent.ts +4 -2
- package/src/blocks/FileBlockContent/fileBlockHelpers.ts +5 -4
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +35 -35
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +4 -2
- package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +14 -12
- package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +28 -16
- package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +5 -3
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +11 -4
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +13 -11
- package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +8 -9
- package/src/blocks/TableBlockContent/TableBlockContent.ts +0 -1
- package/src/blocks/VideoBlockContent/VideoBlockContent.ts +4 -2
- package/src/blocks/defaultBlockHelpers.ts +7 -2
- package/src/editor/Block.css +22 -1
- package/src/editor/BlockNoteEditor.test.ts +4 -7
- package/src/editor/BlockNoteEditor.ts +87 -61
- package/src/editor/BlockNoteExtensions.ts +92 -17
- package/src/editor/BlockNoteTipTapEditor.ts +8 -1
- package/src/editor/defaultColors.ts +77 -0
- package/src/editor/editor.css +10 -0
- package/src/editor/transformPasted.ts +6 -3
- package/src/exporter/Exporter.ts +101 -0
- package/src/exporter/index.ts +2 -0
- package/src/exporter/mapping.ts +75 -0
- package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +233 -53
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.ts +45 -42
- package/src/extensions/Placeholder/PlaceholderPlugin.ts +94 -90
- package/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.ts +173 -169
- package/src/extensions/SideMenu/SideMenuPlugin.ts +141 -52
- package/src/extensions/SideMenu/dragging.ts +3 -54
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +4 -6
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +1 -1
- package/src/extensions/TrailingNode/TrailingNodeExtension.ts +1 -1
- package/src/extensions/getDraggableBlockFromElement.ts +19 -0
- package/src/i18n/locales/de.ts +5 -5
- package/src/i18n/locales/pt.ts +5 -5
- package/src/index.ts +9 -5
- package/src/pm-nodes/BlockContainer.ts +1 -1
- package/src/pm-nodes/BlockGroup.ts +2 -2
- package/src/pm-nodes/README.md +127 -28
- package/src/schema/blocks/createSpec.ts +4 -1
- package/src/schema/blocks/internal.ts +12 -2
- package/src/schema/blocks/types.ts +1 -1
- package/src/util/combineByGroup.ts +25 -0
- package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.d.ts +22 -2
- package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.d.ts +5 -0
- package/types/src/api/blockManipulation/commands/removeBlocks/removeBlocks.d.ts +0 -3
- package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.d.ts +4 -0
- package/types/src/api/blockManipulation/setupTestEnv.d.ts +0 -6
- package/types/src/api/clipboard/fromClipboard/acceptedMIMETypes.d.ts +1 -1
- package/types/src/api/getBlockInfoFromPos.d.ts +38 -13
- package/types/src/api/nodeConversions/blockToNode.d.ts +1 -1
- package/types/src/api/nodeConversions/nodeToBlock.d.ts +3 -1
- package/types/src/api/testUtil/cases/customBlocks.d.ts +0 -6
- package/types/src/api/testUtil/cases/customInlineContent.d.ts +0 -6
- package/types/src/api/testUtil/cases/customStyles.d.ts +0 -6
- package/types/src/api/testUtil/partialBlockTestUtil.d.ts +2 -1
- package/types/src/blocks/AudioBlockContent/AudioBlockContent.d.ts +1 -0
- package/types/src/blocks/FileBlockContent/fileBlockHelpers.d.ts +1 -0
- package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +1 -0
- package/types/src/blocks/TableBlockContent/TableBlockContent.d.ts +0 -9
- package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +1 -0
- package/types/src/blocks/defaultBlocks.d.ts +0 -12
- package/types/src/editor/BlockNoteEditor.d.ts +23 -5
- package/types/src/editor/BlockNoteExtensions.d.ts +14 -7
- package/types/src/editor/BlockNoteTipTapEditor.d.ts +1 -0
- package/types/src/editor/defaultColors.d.ts +76 -0
- package/types/src/exporter/Exporter.d.ts +43 -0
- package/types/src/exporter/index.d.ts +2 -0
- package/types/src/exporter/mapping.d.ts +30 -0
- package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.d.ts +4 -1
- package/types/src/extensions/Placeholder/PlaceholderPlugin.d.ts +4 -1
- package/types/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.d.ts +4 -5
- package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +2 -1
- package/types/src/extensions/SideMenu/dragging.d.ts +1 -6
- package/types/src/extensions/getDraggableBlockFromElement.d.ts +5 -0
- package/types/src/index.d.ts +9 -5
- package/types/src/schema/blocks/createSpec.d.ts +1 -1
- package/types/src/schema/blocks/internal.d.ts +2 -2
- package/types/src/schema/blocks/types.d.ts +1 -1
- package/types/src/util/combineByGroup.d.ts +9 -0
- package/dist/angular-html-HQGguTAE.js +0 -33
- package/dist/angular-html-HQGguTAE.js.map +0 -1
- package/dist/angular-ts-q9PqJiJb.js +0 -22
- package/dist/angular-ts-q9PqJiJb.js.map +0 -1
- package/dist/astro-0iWgpDaK.js +0 -17
- package/dist/astro-0iWgpDaK.js.map +0 -1
- package/dist/blade-C3Z8AhvY.js +0 -19
- package/dist/blade-C3Z8AhvY.js.map +0 -1
- package/dist/c-TKJGJdXV.js +0 -7
- package/dist/c-TKJGJdXV.js.map +0 -1
- package/dist/coffee-CN_y6cG3.js +0 -9
- package/dist/coffee-CN_y6cG3.js.map +0 -1
- package/dist/cpp-Be_e67JE.js +0 -19
- package/dist/cpp-Be_e67JE.js.map +0 -1
- package/dist/css-DHLSoXzW.js +0 -7
- package/dist/css-DHLSoXzW.js.map +0 -1
- package/dist/glsl-8qSUIm5B.js +0 -9
- package/dist/glsl-8qSUIm5B.js.map +0 -1
- package/dist/graphql-D7_Dk2ma.js +0 -15
- package/dist/graphql-D7_Dk2ma.js.map +0 -1
- package/dist/haml-S3dmcfEW.js +0 -11
- package/dist/haml-S3dmcfEW.js.map +0 -1
- package/dist/handlebars-DaIrqVg3.js +0 -15
- package/dist/handlebars-DaIrqVg3.js.map +0 -1
- package/dist/html-Bx3A18fV.js +0 -11
- package/dist/html-Bx3A18fV.js.map +0 -1
- package/dist/html-derivative-Cf3KTZBS.js +0 -9
- package/dist/html-derivative-Cf3KTZBS.js.map +0 -1
- package/dist/http-BphR83YX.js +0 -15
- package/dist/http-BphR83YX.js.map +0 -1
- package/dist/imba-CmP25v0O.js +0 -9
- package/dist/imba-CmP25v0O.js.map +0 -1
- package/dist/java-Dg4kxH6C.js +0 -7
- package/dist/java-Dg4kxH6C.js.map +0 -1
- package/dist/javascript-CipAzIn1.js +0 -7
- package/dist/javascript-CipAzIn1.js.map +0 -1
- package/dist/jinja-tioldiz6.js +0 -12
- package/dist/jinja-tioldiz6.js.map +0 -1
- package/dist/jison-DWJFEE_I.js +0 -9
- package/dist/jison-DWJFEE_I.js.map +0 -1
- package/dist/json-_04EL6MS.js +0 -7
- package/dist/json-_04EL6MS.js.map +0 -1
- package/dist/json5-Dwmp5XFI.js +0 -7
- package/dist/json5-Dwmp5XFI.js.map +0 -1
- package/dist/jsonc-LqD5auy0.js +0 -7
- package/dist/jsonc-LqD5auy0.js.map +0 -1
- package/dist/jsonl-B4yVuYQH.js +0 -7
- package/dist/jsonl-B4yVuYQH.js.map +0 -1
- package/dist/jsx-Mg4WaD5k.js +0 -7
- package/dist/jsx-Mg4WaD5k.js.map +0 -1
- package/dist/julia-CWi-ZdpN.js +0 -17
- package/dist/julia-CWi-ZdpN.js.map +0 -1
- package/dist/less-BBvTHIGe.js +0 -7
- package/dist/less-BBvTHIGe.js.map +0 -1
- package/dist/markdown-DAXqtk9a.js +0 -7
- package/dist/markdown-DAXqtk9a.js.map +0 -1
- package/dist/marko-0aaNgUGV.js +0 -15
- package/dist/marko-0aaNgUGV.js.map +0 -1
- package/dist/mdc-hXJ2B4O0.js +0 -13
- package/dist/mdc-hXJ2B4O0.js.map +0 -1
- package/dist/mdx-CSCKbb_f.js +0 -7
- package/dist/mdx-CSCKbb_f.js.map +0 -1
- package/dist/php-B_-4RJ09.js +0 -19
- package/dist/php-B_-4RJ09.js.map +0 -1
- package/dist/postcss-SJfTvo_B.js +0 -7
- package/dist/postcss-SJfTvo_B.js.map +0 -1
- package/dist/pug-3q2tx0nf.js +0 -13
- package/dist/pug-3q2tx0nf.js.map +0 -1
- package/dist/python-Dpup1-fE.js +0 -7
- package/dist/python-Dpup1-fE.js.map +0 -1
- package/dist/r-Chyv38Fv.js +0 -7
- package/dist/r-Chyv38Fv.js.map +0 -1
- package/dist/regexp-BF0hfxNW.js +0 -7
- package/dist/regexp-BF0hfxNW.js.map +0 -1
- package/dist/sass-p2RMoqDT.js +0 -7
- package/dist/sass-p2RMoqDT.js.map +0 -1
- package/dist/scss-DmlHSoOY.js +0 -9
- package/dist/scss-DmlHSoOY.js.map +0 -1
- package/dist/shellscript-CZpPN8_x.js +0 -7
- package/dist/shellscript-CZpPN8_x.js.map +0 -1
- package/dist/sql-DtlkUz2m.js +0 -7
- package/dist/sql-DtlkUz2m.js.map +0 -1
- package/dist/stylus-DEr8eSLm.js +0 -7
- package/dist/stylus-DEr8eSLm.js.map +0 -1
- package/dist/svelte-BRIJF62h.js +0 -15
- package/dist/svelte-BRIJF62h.js.map +0 -1
- package/dist/ts-tags-qkUtuI0N.js +0 -42
- package/dist/ts-tags-qkUtuI0N.js.map +0 -1
- package/dist/tsx-DTfbgJxi.js +0 -7
- package/dist/tsx-DTfbgJxi.js.map +0 -1
- package/dist/typescript-CCd4aQHh.js +0 -7
- package/dist/typescript-CCd4aQHh.js.map +0 -1
- package/dist/vue-B3TdbERm.js +0 -32
- package/dist/vue-B3TdbERm.js.map +0 -1
- package/dist/vue-html-BGmTBZk0.js +0 -11
- package/dist/vue-html-BGmTBZk0.js.map +0 -1
- package/dist/wasm-VDIDph3E.js +0 -7
- package/dist/wasm-VDIDph3E.js.map +0 -1
- package/dist/wgsl-2np_U3Z8.js +0 -7
- package/dist/wgsl-2np_U3Z8.js.map +0 -1
- package/dist/xml-CNyphW9R.js +0 -9
- package/dist/xml-CNyphW9R.js.map +0 -1
- package/dist/yaml-DxFiVFcM.js +0 -7
- package/dist/yaml-DxFiVFcM.js.map +0 -1
|
@@ -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
|
+
}
|
|
@@ -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<{
|
|
@@ -32,6 +33,9 @@ export const KeyboardShortcutsExtension = Extension.create<{
|
|
|
32
33
|
() =>
|
|
33
34
|
commands.command(({ state }) => {
|
|
34
35
|
const blockInfo = getBlockInfoFromSelection(state);
|
|
36
|
+
if (!blockInfo.isBlockContainer) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
35
39
|
|
|
36
40
|
const selectionAtBlockStart =
|
|
37
41
|
state.selection.from === blockInfo.blockContent.beforePos + 1;
|
|
@@ -42,7 +46,7 @@ export const KeyboardShortcutsExtension = Extension.create<{
|
|
|
42
46
|
return commands.command(
|
|
43
47
|
updateBlockCommand(
|
|
44
48
|
this.options.editor,
|
|
45
|
-
blockInfo.
|
|
49
|
+
blockInfo.bnBlock.beforePos,
|
|
46
50
|
{
|
|
47
51
|
type: "paragraph",
|
|
48
52
|
props: {},
|
|
@@ -56,7 +60,11 @@ export const KeyboardShortcutsExtension = Extension.create<{
|
|
|
56
60
|
// Removes a level of nesting if the block is indented if the selection is at the start of the block.
|
|
57
61
|
() =>
|
|
58
62
|
commands.command(({ state }) => {
|
|
59
|
-
const
|
|
63
|
+
const blockInfo = getBlockInfoFromSelection(state);
|
|
64
|
+
if (!blockInfo.isBlockContainer) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
const { blockContent } = blockInfo;
|
|
60
68
|
|
|
61
69
|
const selectionAtBlockStart =
|
|
62
70
|
state.selection.from === blockContent.beforePos + 1;
|
|
@@ -67,29 +75,23 @@ export const KeyboardShortcutsExtension = Extension.create<{
|
|
|
67
75
|
|
|
68
76
|
return false;
|
|
69
77
|
}),
|
|
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
|
|
78
|
+
// Merges block with the previous one if it isn't indented, and the selection is at the start of the
|
|
72
79
|
// block. The target block for merging must contain inline content.
|
|
73
80
|
() =>
|
|
74
81
|
commands.command(({ state }) => {
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
82
|
+
const blockInfo = getBlockInfoFromSelection(state);
|
|
83
|
+
if (!blockInfo.isBlockContainer) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
const { bnBlock: blockContainer, blockContent } = blockInfo;
|
|
79
87
|
|
|
80
88
|
const selectionAtBlockStart =
|
|
81
89
|
state.selection.from === blockContent.beforePos + 1;
|
|
82
90
|
const selectionEmpty = state.selection.empty;
|
|
83
|
-
const blockAtDocStart = blockContainer.beforePos === 1;
|
|
84
91
|
|
|
85
92
|
const posBetweenBlocks = blockContainer.beforePos;
|
|
86
93
|
|
|
87
|
-
if (
|
|
88
|
-
!blockAtDocStart &&
|
|
89
|
-
selectionAtBlockStart &&
|
|
90
|
-
selectionEmpty &&
|
|
91
|
-
depth === 1
|
|
92
|
-
) {
|
|
94
|
+
if (selectionAtBlockStart && selectionEmpty) {
|
|
93
95
|
return chain()
|
|
94
96
|
.command(mergeBlocksCommand(posBetweenBlocks))
|
|
95
97
|
.scrollIntoView()
|
|
@@ -98,6 +100,165 @@ export const KeyboardShortcutsExtension = Extension.create<{
|
|
|
98
100
|
|
|
99
101
|
return false;
|
|
100
102
|
}),
|
|
103
|
+
() =>
|
|
104
|
+
commands.command(({ state, dispatch }) => {
|
|
105
|
+
// when at the start of a first block in a column
|
|
106
|
+
const blockInfo = getBlockInfoFromSelection(state);
|
|
107
|
+
if (!blockInfo.isBlockContainer) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const selectionAtBlockStart =
|
|
112
|
+
state.selection.from === blockInfo.blockContent.beforePos + 1;
|
|
113
|
+
|
|
114
|
+
if (!selectionAtBlockStart) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const prevBlockInfo = getPrevBlockInfo(
|
|
119
|
+
state.doc,
|
|
120
|
+
blockInfo.bnBlock.beforePos
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
if (prevBlockInfo) {
|
|
124
|
+
// should be no previous block
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const parentBlockInfo = getParentBlockInfo(
|
|
129
|
+
state.doc,
|
|
130
|
+
blockInfo.bnBlock.beforePos
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
if (parentBlockInfo?.blockNoteType !== "column") {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const column = parentBlockInfo;
|
|
138
|
+
|
|
139
|
+
const columnList = getParentBlockInfo(
|
|
140
|
+
state.doc,
|
|
141
|
+
column.bnBlock.beforePos
|
|
142
|
+
);
|
|
143
|
+
if (columnList?.blockNoteType !== "columnList") {
|
|
144
|
+
throw new Error("parent of column is not a column list");
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const shouldRemoveColumn =
|
|
148
|
+
column.childContainer!.node.childCount === 1;
|
|
149
|
+
|
|
150
|
+
const shouldRemoveColumnList =
|
|
151
|
+
shouldRemoveColumn &&
|
|
152
|
+
columnList.childContainer!.node.childCount === 2;
|
|
153
|
+
|
|
154
|
+
const isFirstColumn =
|
|
155
|
+
columnList.childContainer!.node.firstChild ===
|
|
156
|
+
column.bnBlock.node;
|
|
157
|
+
|
|
158
|
+
if (dispatch) {
|
|
159
|
+
const blockToMove = state.doc.slice(
|
|
160
|
+
blockInfo.bnBlock.beforePos,
|
|
161
|
+
blockInfo.bnBlock.afterPos,
|
|
162
|
+
false
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
/*
|
|
166
|
+
There are 3 different cases:
|
|
167
|
+
a) remove entire column list (if no columns would be remaining)
|
|
168
|
+
b) remove just a column (if no blocks inside a column would be remaining)
|
|
169
|
+
c) keep columns (if there are blocks remaining inside a column)
|
|
170
|
+
|
|
171
|
+
Each of these 3 cases has 2 sub-cases, depending on whether the backspace happens at the start of the first (most-left) column,
|
|
172
|
+
or at the start of a non-first column.
|
|
173
|
+
*/
|
|
174
|
+
if (shouldRemoveColumnList) {
|
|
175
|
+
if (isFirstColumn) {
|
|
176
|
+
state.tr.step(
|
|
177
|
+
new ReplaceAroundStep(
|
|
178
|
+
// replace entire column list
|
|
179
|
+
columnList.bnBlock.beforePos,
|
|
180
|
+
columnList.bnBlock.afterPos,
|
|
181
|
+
// select content of remaining column:
|
|
182
|
+
column.bnBlock.afterPos + 1,
|
|
183
|
+
columnList.bnBlock.afterPos - 2,
|
|
184
|
+
blockToMove,
|
|
185
|
+
blockToMove.size, // append existing content to blockToMove
|
|
186
|
+
false
|
|
187
|
+
)
|
|
188
|
+
);
|
|
189
|
+
const pos = state.tr.doc.resolve(column.bnBlock.beforePos);
|
|
190
|
+
state.tr.setSelection(TextSelection.between(pos, pos));
|
|
191
|
+
} else {
|
|
192
|
+
// replaces the column list with the blockToMove slice, prepended with the content of the remaining column
|
|
193
|
+
state.tr.step(
|
|
194
|
+
new ReplaceAroundStep(
|
|
195
|
+
// replace entire column list
|
|
196
|
+
columnList.bnBlock.beforePos,
|
|
197
|
+
columnList.bnBlock.afterPos,
|
|
198
|
+
// select content of existing column:
|
|
199
|
+
columnList.bnBlock.beforePos + 2,
|
|
200
|
+
column.bnBlock.beforePos - 1,
|
|
201
|
+
blockToMove,
|
|
202
|
+
0, // prepend existing content to blockToMove
|
|
203
|
+
false
|
|
204
|
+
)
|
|
205
|
+
);
|
|
206
|
+
const pos = state.tr.doc.resolve(
|
|
207
|
+
state.tr.mapping.map(column.bnBlock.beforePos - 1)
|
|
208
|
+
);
|
|
209
|
+
state.tr.setSelection(TextSelection.between(pos, pos));
|
|
210
|
+
}
|
|
211
|
+
} else if (shouldRemoveColumn) {
|
|
212
|
+
if (isFirstColumn) {
|
|
213
|
+
// delete column
|
|
214
|
+
state.tr.delete(
|
|
215
|
+
column.bnBlock.beforePos,
|
|
216
|
+
column.bnBlock.afterPos
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
// move before columnlist
|
|
220
|
+
state.tr.insert(
|
|
221
|
+
columnList.bnBlock.beforePos,
|
|
222
|
+
blockToMove.content
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
const pos = state.tr.doc.resolve(
|
|
226
|
+
columnList.bnBlock.beforePos
|
|
227
|
+
);
|
|
228
|
+
state.tr.setSelection(TextSelection.between(pos, pos));
|
|
229
|
+
} else {
|
|
230
|
+
// just delete the </column><column> closing and opening tags to merge the columns
|
|
231
|
+
state.tr.delete(
|
|
232
|
+
column.bnBlock.beforePos - 1,
|
|
233
|
+
column.bnBlock.beforePos + 1
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
} else {
|
|
237
|
+
// delete block
|
|
238
|
+
state.tr.delete(
|
|
239
|
+
blockInfo.bnBlock.beforePos,
|
|
240
|
+
blockInfo.bnBlock.afterPos
|
|
241
|
+
);
|
|
242
|
+
if (isFirstColumn) {
|
|
243
|
+
// move before columnlist
|
|
244
|
+
state.tr.insert(
|
|
245
|
+
columnList.bnBlock.beforePos - 1,
|
|
246
|
+
blockToMove.content
|
|
247
|
+
);
|
|
248
|
+
} else {
|
|
249
|
+
// append block to previous column
|
|
250
|
+
state.tr.insert(
|
|
251
|
+
column.bnBlock.beforePos - 1,
|
|
252
|
+
blockToMove.content
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
const pos = state.tr.doc.resolve(column.bnBlock.beforePos - 1);
|
|
256
|
+
state.tr.setSelection(TextSelection.between(pos, pos));
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return true;
|
|
261
|
+
}),
|
|
101
262
|
// Deletes previous block if it contains no content and isn't a table,
|
|
102
263
|
// when the selection is empty and at the start of the block. Moves the
|
|
103
264
|
// current block into the deleted block's place.
|
|
@@ -105,47 +266,49 @@ export const KeyboardShortcutsExtension = Extension.create<{
|
|
|
105
266
|
commands.command(({ state }) => {
|
|
106
267
|
const blockInfo = getBlockInfoFromSelection(state);
|
|
107
268
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
269
|
+
if (!blockInfo.isBlockContainer) {
|
|
270
|
+
// TODO
|
|
271
|
+
throw new Error(`todo`);
|
|
272
|
+
}
|
|
111
273
|
|
|
112
274
|
const selectionAtBlockStart =
|
|
113
275
|
state.selection.from === blockInfo.blockContent.beforePos + 1;
|
|
114
276
|
const selectionEmpty = state.selection.empty;
|
|
115
|
-
const blockAtDocStart = blockInfo.blockContainer.beforePos === 1;
|
|
116
277
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
) {
|
|
123
|
-
const
|
|
278
|
+
const prevBlockInfo = getPrevBlockInfo(
|
|
279
|
+
state.doc,
|
|
280
|
+
blockInfo.bnBlock.beforePos
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
if (prevBlockInfo && selectionAtBlockStart && selectionEmpty) {
|
|
284
|
+
const bottomBlock = getBottomNestedBlockInfo(
|
|
124
285
|
state.doc,
|
|
125
|
-
|
|
126
|
-
);
|
|
127
|
-
const prevBlockInfo = getBlockInfoFromResolvedPos(
|
|
128
|
-
state.doc.resolve(prevBlockPos.pos)
|
|
286
|
+
prevBlockInfo
|
|
129
287
|
);
|
|
130
288
|
|
|
289
|
+
if (!bottomBlock.isBlockContainer) {
|
|
290
|
+
// TODO
|
|
291
|
+
throw new Error(`todo`);
|
|
292
|
+
}
|
|
293
|
+
|
|
131
294
|
const prevBlockNotTableAndNoContent =
|
|
132
|
-
|
|
133
|
-
(
|
|
295
|
+
bottomBlock.blockContent.node.type.spec.content === "" ||
|
|
296
|
+
(bottomBlock.blockContent.node.type.spec.content ===
|
|
134
297
|
"inline*" &&
|
|
135
|
-
|
|
298
|
+
bottomBlock.blockContent.node.childCount === 0);
|
|
136
299
|
|
|
137
300
|
if (prevBlockNotTableAndNoContent) {
|
|
138
301
|
return chain()
|
|
139
302
|
.cut(
|
|
140
303
|
{
|
|
141
|
-
from: blockInfo.
|
|
142
|
-
to: blockInfo.
|
|
304
|
+
from: blockInfo.bnBlock.beforePos,
|
|
305
|
+
to: blockInfo.bnBlock.afterPos,
|
|
143
306
|
},
|
|
144
|
-
|
|
307
|
+
bottomBlock.bnBlock.afterPos
|
|
145
308
|
)
|
|
146
309
|
.deleteRange({
|
|
147
|
-
from:
|
|
148
|
-
to:
|
|
310
|
+
from: bottomBlock.bnBlock.beforePos,
|
|
311
|
+
to: bottomBlock.bnBlock.afterPos,
|
|
149
312
|
})
|
|
150
313
|
.run();
|
|
151
314
|
}
|
|
@@ -165,8 +328,15 @@ export const KeyboardShortcutsExtension = Extension.create<{
|
|
|
165
328
|
() =>
|
|
166
329
|
commands.command(({ state }) => {
|
|
167
330
|
// TODO: Change this to not rely on offsets & schema assumptions
|
|
168
|
-
const
|
|
169
|
-
|
|
331
|
+
const blockInfo = getBlockInfoFromSelection(state);
|
|
332
|
+
if (!blockInfo.isBlockContainer) {
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
const {
|
|
336
|
+
bnBlock: blockContainer,
|
|
337
|
+
blockContent,
|
|
338
|
+
childContainer,
|
|
339
|
+
} = blockInfo;
|
|
170
340
|
|
|
171
341
|
const { depth } = state.doc.resolve(blockContainer.beforePos);
|
|
172
342
|
const blockAtDocEnd =
|
|
@@ -174,7 +344,7 @@ export const KeyboardShortcutsExtension = Extension.create<{
|
|
|
174
344
|
const selectionAtBlockEnd =
|
|
175
345
|
state.selection.from === blockContent.afterPos - 1;
|
|
176
346
|
const selectionEmpty = state.selection.empty;
|
|
177
|
-
const hasChildBlocks =
|
|
347
|
+
const hasChildBlocks = childContainer !== undefined;
|
|
178
348
|
|
|
179
349
|
if (
|
|
180
350
|
!blockAtDocEnd &&
|
|
@@ -205,8 +375,11 @@ export const KeyboardShortcutsExtension = Extension.create<{
|
|
|
205
375
|
// of the block.
|
|
206
376
|
() =>
|
|
207
377
|
commands.command(({ state }) => {
|
|
208
|
-
const
|
|
209
|
-
|
|
378
|
+
const blockInfo = getBlockInfoFromSelection(state);
|
|
379
|
+
if (!blockInfo.isBlockContainer) {
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
const { bnBlock: blockContainer, blockContent } = blockInfo;
|
|
210
383
|
|
|
211
384
|
const { depth } = state.doc.resolve(blockContainer.beforePos);
|
|
212
385
|
|
|
@@ -232,8 +405,11 @@ export const KeyboardShortcutsExtension = Extension.create<{
|
|
|
232
405
|
// empty & at the start of the block.
|
|
233
406
|
() =>
|
|
234
407
|
commands.command(({ state, dispatch }) => {
|
|
235
|
-
const
|
|
236
|
-
|
|
408
|
+
const blockInfo = getBlockInfoFromSelection(state);
|
|
409
|
+
if (!blockInfo.isBlockContainer) {
|
|
410
|
+
return false;
|
|
411
|
+
}
|
|
412
|
+
const { bnBlock: blockContainer, blockContent } = blockInfo;
|
|
237
413
|
|
|
238
414
|
const selectionAtBlockStart =
|
|
239
415
|
state.selection.$anchor.parentOffset === 0;
|
|
@@ -266,7 +442,11 @@ export const KeyboardShortcutsExtension = Extension.create<{
|
|
|
266
442
|
// deletes the selection beforehand, if it's not empty.
|
|
267
443
|
() =>
|
|
268
444
|
commands.command(({ state, chain }) => {
|
|
269
|
-
const
|
|
445
|
+
const blockInfo = getBlockInfoFromSelection(state);
|
|
446
|
+
if (!blockInfo.isBlockContainer) {
|
|
447
|
+
return false;
|
|
448
|
+
}
|
|
449
|
+
const { blockContent } = blockInfo;
|
|
270
450
|
|
|
271
451
|
const selectionAtBlockStart =
|
|
272
452
|
state.selection.$anchor.parentOffset === 0;
|
|
@@ -306,8 +486,8 @@ export const KeyboardShortcutsExtension = Extension.create<{
|
|
|
306
486
|
// don't handle tabs if a toolbar is shown, so we can tab into / out of it
|
|
307
487
|
return false;
|
|
308
488
|
}
|
|
309
|
-
this.editor
|
|
310
|
-
return true;
|
|
489
|
+
return nestBlock(this.options.editor);
|
|
490
|
+
// return true;
|
|
311
491
|
},
|
|
312
492
|
"Shift-Tab": () => {
|
|
313
493
|
if (
|
|
@@ -15,51 +15,54 @@ const PLUGIN_KEY = new PluginKey("node-selection-keyboard");
|
|
|
15
15
|
// While a more elegant solution would probably process transactions instead of
|
|
16
16
|
// keystrokes, this brings us most of the way to Notion's UX without much added
|
|
17
17
|
// complexity.
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// Checks
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
18
|
+
export class NodeSelectionKeyboardPlugin {
|
|
19
|
+
public readonly plugin: Plugin;
|
|
20
|
+
constructor() {
|
|
21
|
+
this.plugin = new Plugin({
|
|
22
|
+
key: PLUGIN_KEY,
|
|
23
|
+
props: {
|
|
24
|
+
handleKeyDown: (view, event) => {
|
|
25
|
+
// Checks for node selection
|
|
26
|
+
if ("node" in view.state.selection) {
|
|
27
|
+
// Checks if key press uses ctrl/meta modifier
|
|
28
|
+
if (event.ctrlKey || event.metaKey) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
// Checks if key press is alphanumeric
|
|
32
|
+
if (event.key.length === 1) {
|
|
33
|
+
event.preventDefault();
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
// Checks if key press is Enter
|
|
38
|
+
if (
|
|
39
|
+
event.key === "Enter" &&
|
|
40
|
+
!event.shiftKey &&
|
|
41
|
+
!event.altKey &&
|
|
42
|
+
!event.ctrlKey &&
|
|
43
|
+
!event.metaKey
|
|
44
|
+
) {
|
|
45
|
+
const tr = view.state.tr;
|
|
46
|
+
view.dispatch(
|
|
47
|
+
tr
|
|
48
|
+
.insert(
|
|
49
|
+
view.state.tr.selection.$to.after(),
|
|
50
|
+
view.state.schema.nodes["paragraph"].createChecked()
|
|
51
|
+
)
|
|
52
|
+
.setSelection(
|
|
53
|
+
new TextSelection(
|
|
54
|
+
tr.doc.resolve(view.state.tr.selection.$to.after() + 1)
|
|
55
|
+
)
|
|
53
56
|
)
|
|
54
|
-
|
|
55
|
-
);
|
|
57
|
+
);
|
|
56
58
|
|
|
57
|
-
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
58
61
|
}
|
|
59
|
-
}
|
|
60
62
|
|
|
61
|
-
|
|
63
|
+
return false;
|
|
64
|
+
},
|
|
62
65
|
},
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|