@blocknote/core 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocknote.js +2191 -2068
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +9 -9
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js +27 -0
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.js +99 -0
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.js +97 -0
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.js +88 -0
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.js +116 -0
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.test.js +106 -0
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/nestBlock/nestBlock.js +57 -0
- package/dist/src/api/blockManipulation/commands/nestBlock/nestBlock.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js +43 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js +27 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js +29 -0
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.js +157 -0
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js +27 -0
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js +64 -0
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js +145 -0
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.test.js +252 -0
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.test.js.map +1 -0
- package/dist/src/api/blockManipulation/insertContentAt.js +64 -0
- package/dist/src/api/blockManipulation/insertContentAt.js.map +1 -0
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js +76 -0
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js.map +1 -0
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.js +33 -0
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.js.map +1 -0
- package/dist/src/api/blockManipulation/setupTestEnv.js +172 -0
- package/dist/src/api/blockManipulation/setupTestEnv.js.map +1 -0
- package/dist/src/api/clipboard/clipboard.test.js +246 -0
- package/dist/src/api/clipboard/clipboard.test.js.map +1 -0
- package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js +8 -0
- package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js.map +1 -0
- package/dist/src/api/clipboard/fromClipboard/fileDropExtension.js +38 -0
- package/dist/src/api/clipboard/fromClipboard/fileDropExtension.js.map +1 -0
- package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js +109 -0
- package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js.map +1 -0
- package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js +26 -0
- package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js.map +1 -0
- package/dist/src/api/clipboard/fromClipboard/pasteExtension.js +57 -0
- package/dist/src/api/clipboard/fromClipboard/pasteExtension.js.map +1 -0
- package/dist/src/api/clipboard/toClipboard/copyExtension.js +132 -0
- package/dist/src/api/clipboard/toClipboard/copyExtension.js.map +1 -0
- package/dist/src/api/exporters/html/externalHTMLExporter.js +35 -0
- package/dist/src/api/exporters/html/externalHTMLExporter.js.map +1 -0
- package/dist/src/api/exporters/html/htmlConversion.test.js +72 -0
- package/dist/src/api/exporters/html/htmlConversion.test.js.map +1 -0
- package/dist/src/api/exporters/html/internalHTMLSerializer.js +21 -0
- package/dist/src/api/exporters/html/internalHTMLSerializer.js.map +1 -0
- package/dist/src/api/exporters/html/util/serializeBlocksExternalHTML.js +141 -0
- package/dist/src/api/exporters/html/util/serializeBlocksExternalHTML.js.map +1 -0
- package/dist/src/api/exporters/html/util/serializeBlocksInternalHTML.js +96 -0
- package/dist/src/api/exporters/html/util/serializeBlocksInternalHTML.js.map +1 -0
- package/dist/src/api/exporters/markdown/markdownExporter.js +31 -0
- package/dist/src/api/exporters/markdown/markdownExporter.js.map +1 -0
- package/dist/src/api/exporters/markdown/markdownExporter.test.js +57 -0
- package/dist/src/api/exporters/markdown/markdownExporter.test.js.map +1 -0
- package/dist/src/api/exporters/markdown/removeUnderlinesRehypePlugin.js +33 -0
- package/dist/src/api/exporters/markdown/removeUnderlinesRehypePlugin.js.map +1 -0
- package/dist/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.js +37 -0
- package/dist/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.js.map +1 -0
- package/dist/src/api/getBlockInfoFromPos.js +171 -0
- package/dist/src/api/getBlockInfoFromPos.js.map +1 -0
- package/dist/src/api/nodeConversions/blockToNode.js +197 -0
- package/dist/src/api/nodeConversions/blockToNode.js.map +1 -0
- package/dist/src/api/nodeConversions/fragmentToBlocks.js +50 -0
- package/dist/src/api/nodeConversions/fragmentToBlocks.js.map +1 -0
- package/dist/src/api/nodeConversions/nodeConversions.test.js +54 -0
- package/dist/src/api/nodeConversions/nodeConversions.test.js.map +1 -0
- package/dist/src/api/nodeConversions/nodeToBlock.js +316 -0
- package/dist/src/api/nodeConversions/nodeToBlock.js.map +1 -0
- package/dist/src/api/nodeUtil.js +28 -0
- package/dist/src/api/nodeUtil.js.map +1 -0
- package/dist/src/api/parsers/html/parseHTML.js +19 -0
- package/dist/src/api/parsers/html/parseHTML.js.map +1 -0
- package/dist/src/api/parsers/html/parseHTML.test.js +470 -0
- package/dist/src/api/parsers/html/parseHTML.test.js.map +1 -0
- package/dist/src/api/parsers/html/util/nestedLists.js +106 -0
- package/dist/src/api/parsers/html/util/nestedLists.js.map +1 -0
- package/dist/src/api/parsers/html/util/nestedLists.test.js +166 -0
- package/dist/src/api/parsers/html/util/nestedLists.test.js.map +1 -0
- package/dist/src/api/parsers/markdown/parseMarkdown.js +52 -0
- package/dist/src/api/parsers/markdown/parseMarkdown.js.map +1 -0
- package/dist/src/api/parsers/markdown/parseMarkdown.test.js +109 -0
- package/dist/src/api/parsers/markdown/parseMarkdown.test.js.map +1 -0
- package/dist/src/api/testUtil/cases/customBlocks.js +313 -0
- package/dist/src/api/testUtil/cases/customBlocks.js.map +1 -0
- package/dist/src/api/testUtil/cases/customInlineContent.js +91 -0
- package/dist/src/api/testUtil/cases/customInlineContent.js.map +1 -0
- package/dist/src/api/testUtil/cases/customStyles.js +83 -0
- package/dist/src/api/testUtil/cases/customStyles.js.map +1 -0
- package/dist/src/api/testUtil/cases/defaultSchema.js +673 -0
- package/dist/src/api/testUtil/cases/defaultSchema.js.map +1 -0
- package/dist/src/api/testUtil/index.js +2 -0
- package/dist/src/api/testUtil/index.js.map +1 -0
- package/dist/src/api/testUtil/partialBlockTestUtil.js +114 -0
- package/dist/src/api/testUtil/partialBlockTestUtil.js.map +1 -0
- package/dist/src/api/testUtil/paste.js +29 -0
- package/dist/src/api/testUtil/paste.js.map +1 -0
- package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js +97 -0
- package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js.map +1 -0
- package/dist/src/blocks/AudioBlockContent/audioBlockHelpers.js +5 -0
- package/dist/src/blocks/AudioBlockContent/audioBlockHelpers.js.map +1 -0
- package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js +273 -0
- package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js.map +1 -0
- package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js +90 -0
- package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/FileBlockContent.js +70 -0
- package/dist/src/blocks/FileBlockContent/FileBlockContent.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/fileBlockHelpers.js +317 -0
- package/dist/src/blocks/FileBlockContent/fileBlockHelpers.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js +15 -0
- package/dist/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js.map +1 -0
- package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js +141 -0
- package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js.map +1 -0
- package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js +106 -0
- package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js.map +1 -0
- package/dist/src/blocks/ImageBlockContent/imageBlockHelpers.js +6 -0
- package/dist/src/blocks/ImageBlockContent/imageBlockHelpers.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js +111 -0
- package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js +218 -0
- package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js +41 -0
- package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.js +58 -0
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js +128 -0
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js.map +1 -0
- package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js +51 -0
- package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js.map +1 -0
- package/dist/src/blocks/TableBlockContent/TableBlockContent.js +130 -0
- package/dist/src/blocks/TableBlockContent/TableBlockContent.js.map +1 -0
- package/dist/src/blocks/TableBlockContent/TableExtension.js +57 -0
- package/dist/src/blocks/TableBlockContent/TableExtension.js.map +1 -0
- package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js +103 -0
- package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js.map +1 -0
- package/dist/src/blocks/VideoBlockContent/videoBlockHelpers.js +6 -0
- package/dist/src/blocks/VideoBlockContent/videoBlockHelpers.js.map +1 -0
- package/dist/src/blocks/defaultBlockHelpers.js +50 -0
- package/dist/src/blocks/defaultBlockHelpers.js.map +1 -0
- package/dist/src/blocks/defaultBlockTypeGuards.js +40 -0
- package/dist/src/blocks/defaultBlockTypeGuards.js.map +1 -0
- package/dist/src/blocks/defaultBlocks.js +50 -0
- package/dist/src/blocks/defaultBlocks.js.map +1 -0
- package/dist/src/blocks/defaultProps.js +19 -0
- package/dist/src/blocks/defaultProps.js.map +1 -0
- package/dist/src/editor/BlockNoteEditor.js +750 -0
- package/dist/src/editor/BlockNoteEditor.js.map +1 -0
- package/dist/src/editor/BlockNoteEditor.test.js +65 -0
- package/dist/src/editor/BlockNoteEditor.test.js.map +1 -0
- package/dist/src/editor/BlockNoteExtensions.js +149 -0
- package/dist/src/editor/BlockNoteExtensions.js.map +1 -0
- package/dist/src/editor/BlockNoteSchema.js +38 -0
- package/dist/src/editor/BlockNoteSchema.js.map +1 -0
- package/dist/src/editor/BlockNoteTipTapEditor.js +169 -0
- package/dist/src/editor/BlockNoteTipTapEditor.js.map +1 -0
- package/dist/src/editor/cursorPositionTypes.js +2 -0
- package/dist/src/editor/cursorPositionTypes.js.map +1 -0
- package/dist/src/editor/defaultColors.js +77 -0
- package/dist/src/editor/defaultColors.js.map +1 -0
- package/dist/src/editor/selectionTypes.js +2 -0
- package/dist/src/editor/selectionTypes.js.map +1 -0
- package/dist/src/editor/transformPasted.js +79 -0
- package/dist/src/editor/transformPasted.js.map +1 -0
- package/dist/src/exporter/Exporter.js +36 -0
- package/dist/src/exporter/Exporter.js.map +1 -0
- package/dist/src/exporter/index.js +3 -0
- package/dist/src/exporter/index.js.map +1 -0
- package/dist/src/exporter/mapping.js +12 -0
- package/dist/src/exporter/mapping.js.map +1 -0
- package/dist/src/extensions/BackgroundColor/BackgroundColorExtension.js +30 -0
- package/dist/src/extensions/BackgroundColor/BackgroundColorExtension.js.map +1 -0
- package/dist/src/extensions/BackgroundColor/BackgroundColorMark.js +39 -0
- package/dist/src/extensions/BackgroundColor/BackgroundColorMark.js.map +1 -0
- package/dist/src/extensions/FilePanel/FilePanelPlugin.js +131 -0
- package/dist/src/extensions/FilePanel/FilePanelPlugin.js.map +1 -0
- package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js +195 -0
- package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js.map +1 -0
- package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js +309 -0
- package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js.map +1 -0
- package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js +247 -0
- package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js.map +1 -0
- package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js +51 -0
- package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js.map +1 -0
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js +81 -0
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js.map +1 -0
- package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js +183 -0
- package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js.map +1 -0
- package/dist/src/extensions/SideMenu/MultipleNodeSelection.js +68 -0
- package/dist/src/extensions/SideMenu/MultipleNodeSelection.js.map +1 -0
- package/dist/src/extensions/SideMenu/SideMenuPlugin.js +339 -0
- package/dist/src/extensions/SideMenu/SideMenuPlugin.js.map +1 -0
- package/dist/src/extensions/SideMenu/dragging.js +128 -0
- package/dist/src/extensions/SideMenu/dragging.js.map +1 -0
- package/dist/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.js +2 -0
- package/dist/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.js.map +1 -0
- package/dist/src/extensions/SuggestionMenu/DefaultSuggestionItem.js +2 -0
- package/dist/src/extensions/SuggestionMenu/DefaultSuggestionItem.js.map +1 -0
- package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js +245 -0
- package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js.map +1 -0
- package/dist/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.js +26 -0
- package/dist/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.js.map +1 -0
- package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js +244 -0
- package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js.map +1 -0
- package/dist/src/extensions/TableHandles/TableHandlesPlugin.js +553 -0
- package/dist/src/extensions/TableHandles/TableHandlesPlugin.js.map +1 -0
- package/dist/src/extensions/TextAlignment/TextAlignmentExtension.js +36 -0
- package/dist/src/extensions/TextAlignment/TextAlignmentExtension.js.map +1 -0
- package/dist/src/extensions/TextColor/TextColorExtension.js +29 -0
- package/dist/src/extensions/TextColor/TextColorExtension.js.map +1 -0
- package/dist/src/extensions/TextColor/TextColorMark.js +37 -0
- package/dist/src/extensions/TextColor/TextColorMark.js.map +1 -0
- package/dist/src/extensions/TrailingNode/TrailingNodeExtension.js +58 -0
- package/dist/src/extensions/TrailingNode/TrailingNodeExtension.js.map +1 -0
- package/dist/src/extensions/UniqueID/UniqueID.js +283 -0
- package/dist/src/extensions/UniqueID/UniqueID.js.map +1 -0
- package/dist/src/extensions/getDraggableBlockFromElement.js +13 -0
- package/dist/src/extensions/getDraggableBlockFromElement.js.map +1 -0
- package/dist/src/extensions-shared/UiElementPosition.js +2 -0
- package/dist/src/extensions-shared/UiElementPosition.js.map +1 -0
- package/dist/src/i18n/dictionary.js +4 -0
- package/dist/src/i18n/dictionary.js.map +1 -0
- package/dist/src/i18n/locales/ar.js +298 -0
- package/dist/src/i18n/locales/ar.js.map +1 -0
- package/dist/src/i18n/locales/de.js +313 -0
- package/dist/src/i18n/locales/de.js.map +1 -0
- package/dist/src/i18n/locales/en.js +314 -0
- package/dist/src/i18n/locales/en.js.map +1 -0
- package/dist/src/i18n/locales/es.js +312 -0
- package/dist/src/i18n/locales/es.js.map +1 -0
- package/dist/src/i18n/locales/fr.js +313 -0
- package/dist/src/i18n/locales/fr.js.map +1 -0
- package/dist/src/i18n/locales/hr.js +308 -0
- package/dist/src/i18n/locales/hr.js.map +1 -0
- package/dist/src/i18n/locales/index.js +16 -0
- package/dist/src/i18n/locales/index.js.map +1 -0
- package/dist/src/i18n/locales/is.js +305 -0
- package/dist/src/i18n/locales/is.js.map +1 -0
- package/dist/src/i18n/locales/ja.js +333 -0
- package/dist/src/i18n/locales/ja.js.map +1 -0
- package/dist/src/i18n/locales/ko.js +326 -0
- package/dist/src/i18n/locales/ko.js.map +1 -0
- package/dist/src/i18n/locales/nl.js +313 -0
- package/dist/src/i18n/locales/nl.js.map +1 -0
- package/dist/src/i18n/locales/pl.js +297 -0
- package/dist/src/i18n/locales/pl.js.map +1 -0
- package/dist/src/i18n/locales/pt.js +305 -0
- package/dist/src/i18n/locales/pt.js.map +1 -0
- package/dist/src/i18n/locales/ru.js +340 -0
- package/dist/src/i18n/locales/ru.js.map +1 -0
- package/dist/src/i18n/locales/vi.js +312 -0
- package/dist/src/i18n/locales/vi.js.map +1 -0
- package/dist/src/i18n/locales/zh.js +346 -0
- package/dist/src/i18n/locales/zh.js.map +1 -0
- package/dist/src/index.js +55 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/pm-nodes/BlockContainer.js +72 -0
- package/dist/src/pm-nodes/BlockContainer.js.map +1 -0
- package/dist/src/pm-nodes/BlockGroup.js +43 -0
- package/dist/src/pm-nodes/BlockGroup.js.map +1 -0
- package/dist/src/pm-nodes/Doc.js +7 -0
- package/dist/src/pm-nodes/Doc.js.map +1 -0
- package/dist/src/pm-nodes/index.js +4 -0
- package/dist/src/pm-nodes/index.js.map +1 -0
- package/dist/src/schema/blocks/createSpec.js +126 -0
- package/dist/src/schema/blocks/createSpec.js.map +1 -0
- package/dist/src/schema/blocks/internal.js +147 -0
- package/dist/src/schema/blocks/internal.js.map +1 -0
- package/dist/src/schema/blocks/types.js +2 -0
- package/dist/src/schema/blocks/types.js.map +1 -0
- package/dist/src/schema/index.js +11 -0
- package/dist/src/schema/index.js.map +1 -0
- package/dist/src/schema/inlineContent/createSpec.js +64 -0
- package/dist/src/schema/inlineContent/createSpec.js.map +1 -0
- package/dist/src/schema/inlineContent/internal.js +52 -0
- package/dist/src/schema/inlineContent/internal.js.map +1 -0
- package/dist/src/schema/inlineContent/types.js +10 -0
- package/dist/src/schema/inlineContent/types.js.map +1 -0
- package/dist/src/schema/propTypes.js +2 -0
- package/dist/src/schema/propTypes.js.map +1 -0
- package/dist/src/schema/styles/createSpec.js +48 -0
- package/dist/src/schema/styles/createSpec.js.map +1 -0
- package/dist/src/schema/styles/internal.js +53 -0
- package/dist/src/schema/styles/internal.js.map +1 -0
- package/dist/src/schema/styles/types.js +2 -0
- package/dist/src/schema/styles/types.js.map +1 -0
- package/dist/src/util/EventEmitter.js +33 -0
- package/dist/src/util/EventEmitter.js.map +1 -0
- package/dist/src/util/browser.js +17 -0
- package/dist/src/util/browser.js.map +1 -0
- package/dist/src/util/combineByGroup.js +20 -0
- package/dist/src/util/combineByGroup.js.map +1 -0
- package/dist/src/util/esmDependencies.js +35 -0
- package/dist/src/util/esmDependencies.js.map +1 -0
- package/dist/src/util/string.js +14 -0
- package/dist/src/util/string.js.map +1 -0
- package/dist/src/util/typescript.js +12 -0
- package/dist/src/util/typescript.js.map +1 -0
- package/dist/style.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/webpack-stats.json +1 -1
- package/package.json +5 -5
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +2 -0
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +2 -2
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +104 -39
- package/src/api/blockManipulation/commands/moveBlock/moveBlock.ts +3 -5
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +100 -0
- package/src/api/blockManipulation/commands/removeBlocks/removeBlocks.ts +1 -1
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +8 -4
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +11 -7
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +5 -5
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +192 -107
- package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.ts +48 -33
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +1 -1
- package/src/api/clipboard/toClipboard/copyExtension.ts +1 -1
- package/src/api/exporters/html/htmlConversion.test.ts +1 -4
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +7 -1
- package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +56 -19
- package/src/api/exporters/markdown/markdownExporter.test.ts +1 -4
- package/src/api/getBlockInfoFromPos.ts +113 -58
- package/src/api/nodeConversions/blockToNode.ts +50 -25
- package/src/api/nodeConversions/fragmentToBlocks.ts +18 -0
- package/src/api/nodeConversions/nodeToBlock.ts +24 -21
- package/src/api/nodeUtil.ts +1 -1
- package/src/api/testUtil/partialBlockTestUtil.ts +15 -3
- package/src/blocks/AudioBlockContent/AudioBlockContent.ts +4 -2
- package/src/blocks/FileBlockContent/fileBlockHelpers.ts +5 -4
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +19 -31
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +4 -2
- package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +5 -9
- package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +6 -10
- package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +1 -1
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +11 -4
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +5 -9
- package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +4 -8
- package/src/blocks/VideoBlockContent/VideoBlockContent.ts +4 -2
- package/src/blocks/defaultBlockHelpers.ts +7 -2
- package/src/editor/Block.css +22 -1
- package/src/editor/BlockNoteEditor.test.ts +2 -2
- package/src/editor/BlockNoteEditor.ts +18 -21
- package/src/editor/BlockNoteExtensions.ts +2 -3
- package/src/editor/BlockNoteTipTapEditor.ts +8 -1
- package/src/editor/defaultColors.ts +77 -0
- package/src/editor/editor.css +10 -0
- package/src/editor/transformPasted.ts +6 -3
- package/src/exporter/Exporter.ts +101 -0
- package/src/exporter/index.ts +2 -0
- package/src/exporter/mapping.ts +75 -0
- package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +201 -48
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.ts +1 -1
- package/src/extensions/SideMenu/SideMenuPlugin.ts +141 -52
- package/src/extensions/SideMenu/dragging.ts +3 -54
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +4 -6
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +1 -1
- package/src/extensions/TrailingNode/TrailingNodeExtension.ts +1 -1
- package/src/extensions/getDraggableBlockFromElement.ts +19 -0
- package/src/i18n/locales/de.ts +5 -5
- package/src/i18n/locales/pt.ts +5 -5
- package/src/index.ts +9 -5
- package/src/pm-nodes/BlockContainer.ts +1 -1
- package/src/pm-nodes/BlockGroup.ts +2 -2
- package/src/pm-nodes/README.md +127 -28
- package/src/schema/blocks/createSpec.ts +4 -1
- package/src/schema/blocks/internal.ts +12 -2
- package/src/schema/blocks/types.ts +1 -1
- package/src/util/combineByGroup.ts +25 -0
- package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.d.ts +22 -2
- package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.d.ts +5 -0
- package/types/src/api/getBlockInfoFromPos.d.ts +55 -5
- package/types/src/api/nodeConversions/blockToNode.d.ts +1 -1
- package/types/src/api/nodeConversions/nodeToBlock.d.ts +3 -1
- package/types/src/api/testUtil/partialBlockTestUtil.d.ts +2 -1
- package/types/src/blocks/AudioBlockContent/AudioBlockContent.d.ts +1 -0
- package/types/src/blocks/FileBlockContent/fileBlockHelpers.d.ts +1 -0
- package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +1 -0
- package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +1 -0
- package/types/src/editor/BlockNoteEditor.d.ts +4 -3
- package/types/src/editor/BlockNoteTipTapEditor.d.ts +1 -0
- package/types/src/editor/defaultColors.d.ts +76 -0
- package/types/src/exporter/Exporter.d.ts +43 -0
- package/types/src/exporter/index.d.ts +2 -0
- package/types/src/exporter/mapping.d.ts +30 -0
- package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +2 -1
- package/types/src/extensions/SideMenu/dragging.d.ts +1 -6
- package/types/src/extensions/getDraggableBlockFromElement.d.ts +5 -0
- package/types/src/index.d.ts +9 -5
- package/types/src/schema/blocks/createSpec.d.ts +1 -1
- package/types/src/schema/blocks/internal.d.ts +2 -2
- package/types/src/schema/blocks/types.d.ts +1 -1
- package/types/src/util/combineByGroup.d.ts +9 -0
- package/dist/angular-html-HQGguTAE.js +0 -33
- package/dist/angular-html-HQGguTAE.js.map +0 -1
- package/dist/angular-ts-q9PqJiJb.js +0 -22
- package/dist/angular-ts-q9PqJiJb.js.map +0 -1
- package/dist/astro-0iWgpDaK.js +0 -17
- package/dist/astro-0iWgpDaK.js.map +0 -1
- package/dist/blade-C3Z8AhvY.js +0 -19
- package/dist/blade-C3Z8AhvY.js.map +0 -1
- package/dist/c-TKJGJdXV.js +0 -7
- package/dist/c-TKJGJdXV.js.map +0 -1
- package/dist/coffee-CN_y6cG3.js +0 -9
- package/dist/coffee-CN_y6cG3.js.map +0 -1
- package/dist/cpp-Be_e67JE.js +0 -19
- package/dist/cpp-Be_e67JE.js.map +0 -1
- package/dist/css-DHLSoXzW.js +0 -7
- package/dist/css-DHLSoXzW.js.map +0 -1
- package/dist/glsl-8qSUIm5B.js +0 -9
- package/dist/glsl-8qSUIm5B.js.map +0 -1
- package/dist/graphql-D7_Dk2ma.js +0 -15
- package/dist/graphql-D7_Dk2ma.js.map +0 -1
- package/dist/haml-S3dmcfEW.js +0 -11
- package/dist/haml-S3dmcfEW.js.map +0 -1
- package/dist/handlebars-DaIrqVg3.js +0 -15
- package/dist/handlebars-DaIrqVg3.js.map +0 -1
- package/dist/html-Bx3A18fV.js +0 -11
- package/dist/html-Bx3A18fV.js.map +0 -1
- package/dist/html-derivative-Cf3KTZBS.js +0 -9
- package/dist/html-derivative-Cf3KTZBS.js.map +0 -1
- package/dist/http-BphR83YX.js +0 -15
- package/dist/http-BphR83YX.js.map +0 -1
- package/dist/imba-CmP25v0O.js +0 -9
- package/dist/imba-CmP25v0O.js.map +0 -1
- package/dist/java-Dg4kxH6C.js +0 -7
- package/dist/java-Dg4kxH6C.js.map +0 -1
- package/dist/javascript-CipAzIn1.js +0 -7
- package/dist/javascript-CipAzIn1.js.map +0 -1
- package/dist/jinja-tioldiz6.js +0 -12
- package/dist/jinja-tioldiz6.js.map +0 -1
- package/dist/jison-DWJFEE_I.js +0 -9
- package/dist/jison-DWJFEE_I.js.map +0 -1
- package/dist/json-_04EL6MS.js +0 -7
- package/dist/json-_04EL6MS.js.map +0 -1
- package/dist/json5-Dwmp5XFI.js +0 -7
- package/dist/json5-Dwmp5XFI.js.map +0 -1
- package/dist/jsonc-LqD5auy0.js +0 -7
- package/dist/jsonc-LqD5auy0.js.map +0 -1
- package/dist/jsonl-B4yVuYQH.js +0 -7
- package/dist/jsonl-B4yVuYQH.js.map +0 -1
- package/dist/jsx-Mg4WaD5k.js +0 -7
- package/dist/jsx-Mg4WaD5k.js.map +0 -1
- package/dist/julia-CWi-ZdpN.js +0 -17
- package/dist/julia-CWi-ZdpN.js.map +0 -1
- package/dist/less-BBvTHIGe.js +0 -7
- package/dist/less-BBvTHIGe.js.map +0 -1
- package/dist/markdown-DAXqtk9a.js +0 -7
- package/dist/markdown-DAXqtk9a.js.map +0 -1
- package/dist/marko-0aaNgUGV.js +0 -15
- package/dist/marko-0aaNgUGV.js.map +0 -1
- package/dist/mdc-hXJ2B4O0.js +0 -13
- package/dist/mdc-hXJ2B4O0.js.map +0 -1
- package/dist/mdx-CSCKbb_f.js +0 -7
- package/dist/mdx-CSCKbb_f.js.map +0 -1
- package/dist/php-B_-4RJ09.js +0 -19
- package/dist/php-B_-4RJ09.js.map +0 -1
- package/dist/postcss-SJfTvo_B.js +0 -7
- package/dist/postcss-SJfTvo_B.js.map +0 -1
- package/dist/pug-3q2tx0nf.js +0 -13
- package/dist/pug-3q2tx0nf.js.map +0 -1
- package/dist/python-Dpup1-fE.js +0 -7
- package/dist/python-Dpup1-fE.js.map +0 -1
- package/dist/r-Chyv38Fv.js +0 -7
- package/dist/r-Chyv38Fv.js.map +0 -1
- package/dist/regexp-BF0hfxNW.js +0 -7
- package/dist/regexp-BF0hfxNW.js.map +0 -1
- package/dist/sass-p2RMoqDT.js +0 -7
- package/dist/sass-p2RMoqDT.js.map +0 -1
- package/dist/scss-DmlHSoOY.js +0 -9
- package/dist/scss-DmlHSoOY.js.map +0 -1
- package/dist/shellscript-CZpPN8_x.js +0 -7
- package/dist/shellscript-CZpPN8_x.js.map +0 -1
- package/dist/sql-DtlkUz2m.js +0 -7
- package/dist/sql-DtlkUz2m.js.map +0 -1
- package/dist/stylus-DEr8eSLm.js +0 -7
- package/dist/stylus-DEr8eSLm.js.map +0 -1
- package/dist/svelte-BRIJF62h.js +0 -15
- package/dist/svelte-BRIJF62h.js.map +0 -1
- package/dist/ts-tags-qkUtuI0N.js +0 -42
- package/dist/ts-tags-qkUtuI0N.js.map +0 -1
- package/dist/tsx-DTfbgJxi.js +0 -7
- package/dist/tsx-DTfbgJxi.js.map +0 -1
- package/dist/typescript-CCd4aQHh.js +0 -7
- package/dist/typescript-CCd4aQHh.js.map +0 -1
- package/dist/vue-B3TdbERm.js +0 -32
- package/dist/vue-B3TdbERm.js.map +0 -1
- package/dist/vue-html-BGmTBZk0.js +0 -11
- package/dist/vue-html-BGmTBZk0.js.map +0 -1
- package/dist/wasm-VDIDph3E.js +0 -7
- package/dist/wasm-VDIDph3E.js.map +0 -1
- package/dist/wgsl-2np_U3Z8.js +0 -7
- package/dist/wgsl-2np_U3Z8.js.map +0 -1
- package/dist/xml-CNyphW9R.js +0 -9
- package/dist/xml-CNyphW9R.js.map +0 -1
- package/dist/yaml-DxFiVFcM.js +0 -7
- package/dist/yaml-DxFiVFcM.js.map +0 -1
|
@@ -12,12 +12,8 @@ import {
|
|
|
12
12
|
} from "../../schema/index.js";
|
|
13
13
|
import { EventEmitter } from "../../util/EventEmitter.js";
|
|
14
14
|
import { initializeESMDependencies } from "../../util/esmDependencies.js";
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
getDraggableBlockFromElement,
|
|
18
|
-
unsetDragImage,
|
|
19
|
-
} from "./dragging.js";
|
|
20
|
-
|
|
15
|
+
import { getDraggableBlockFromElement } from "../getDraggableBlockFromElement.js";
|
|
16
|
+
import { dragStart, unsetDragImage } from "./dragging.js";
|
|
21
17
|
export type SideMenuState<
|
|
22
18
|
BSchema extends BlockSchema,
|
|
23
19
|
I extends InlineContentSchema,
|
|
@@ -27,13 +23,45 @@ export type SideMenuState<
|
|
|
27
23
|
block: Block<BSchema, I, S>;
|
|
28
24
|
};
|
|
29
25
|
|
|
30
|
-
const
|
|
26
|
+
const PERCENTAGE_OF_BLOCK_WIDTH_CONSIDERED_SIDE_DROP = 0.1;
|
|
27
|
+
|
|
28
|
+
function getBlockFromCoords(
|
|
29
|
+
view: EditorView,
|
|
30
|
+
coords: { left: number; top: number },
|
|
31
|
+
adjustForColumns = true
|
|
32
|
+
) {
|
|
33
|
+
const elements = view.root.elementsFromPoint(coords.left, coords.top);
|
|
34
|
+
|
|
35
|
+
for (const element of elements) {
|
|
36
|
+
if (!view.dom.contains(element)) {
|
|
37
|
+
// probably a ui overlay like formatting toolbar etc
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (adjustForColumns) {
|
|
41
|
+
const column = element.closest("[data-node-type=columnList]");
|
|
42
|
+
if (column) {
|
|
43
|
+
return getBlockFromCoords(
|
|
44
|
+
view,
|
|
45
|
+
{
|
|
46
|
+
left: coords.left + 50, // bit hacky, but if we're inside a column, offset x position to right to account for the width of sidemenu itself
|
|
47
|
+
top: coords.top,
|
|
48
|
+
},
|
|
49
|
+
false
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return getDraggableBlockFromElement(element, view);
|
|
54
|
+
}
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function getBlockFromMousePos(
|
|
31
59
|
mousePos: {
|
|
32
60
|
x: number;
|
|
33
61
|
y: number;
|
|
34
62
|
},
|
|
35
63
|
view: EditorView
|
|
36
|
-
): { node: HTMLElement; id: string } | undefined
|
|
64
|
+
): { node: HTMLElement; id: string } | undefined {
|
|
37
65
|
// Editor itself may have padding or other styling which affects
|
|
38
66
|
// size/position, so we get the boundingRect of the first child (i.e. the
|
|
39
67
|
// blockGroup that wraps all blocks in the editor) for more accurate side
|
|
@@ -50,22 +78,41 @@ const getBlockFromMousePos = (
|
|
|
50
78
|
|
|
51
79
|
// Gets block at mouse cursor's vertical position.
|
|
52
80
|
const coords = {
|
|
53
|
-
left:
|
|
81
|
+
left: mousePos.x,
|
|
54
82
|
top: mousePos.y,
|
|
55
83
|
};
|
|
56
84
|
|
|
57
|
-
const
|
|
58
|
-
|
|
85
|
+
const mouseLeftOfEditor = coords.left < editorBoundingBox.left;
|
|
86
|
+
const mouseRightOfEditor = coords.left > editorBoundingBox.right;
|
|
59
87
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
88
|
+
if (mouseLeftOfEditor) {
|
|
89
|
+
coords.left = editorBoundingBox.left + 10;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (mouseRightOfEditor) {
|
|
93
|
+
coords.left = editorBoundingBox.right - 10;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let block = getBlockFromCoords(view, coords);
|
|
97
|
+
|
|
98
|
+
if (!mouseRightOfEditor && block) {
|
|
99
|
+
// note: this case is not necessary when we're on the right side of the editor
|
|
100
|
+
|
|
101
|
+
/* Now, because blocks can be nested
|
|
102
|
+
| BlockA |
|
|
103
|
+
x | BlockB y|
|
|
104
|
+
|
|
105
|
+
hovering over position x (the "margin of block B") will return block A instead of block B.
|
|
106
|
+
to fix this, we get the block from the right side of block A (position y, which will fall in BlockB correctly)
|
|
107
|
+
*/
|
|
108
|
+
|
|
109
|
+
const rect = block.node.getBoundingClientRect();
|
|
110
|
+
coords.left = rect.right - 10;
|
|
111
|
+
block = getBlockFromCoords(view, coords, false);
|
|
65
112
|
}
|
|
66
113
|
|
|
67
114
|
return block;
|
|
68
|
-
}
|
|
115
|
+
}
|
|
69
116
|
|
|
70
117
|
/**
|
|
71
118
|
* With the sidemenu plugin we can position a menu next to a hovered block.
|
|
@@ -158,6 +205,7 @@ export class SideMenuView<
|
|
|
158
205
|
this.hoveredBlock = block.node;
|
|
159
206
|
|
|
160
207
|
// Gets the block's content node, which lets to ignore child blocks when determining the block menu's position.
|
|
208
|
+
// TODO: needed?
|
|
161
209
|
const blockContent = block.node.firstChild as HTMLElement;
|
|
162
210
|
|
|
163
211
|
if (!blockContent) {
|
|
@@ -168,15 +216,20 @@ export class SideMenuView<
|
|
|
168
216
|
|
|
169
217
|
// Shows or updates elements.
|
|
170
218
|
if (this.editor.isEditable) {
|
|
171
|
-
const editorBoundingBox = (
|
|
172
|
-
this.pmView.dom.firstChild as HTMLElement
|
|
173
|
-
).getBoundingClientRect();
|
|
174
219
|
const blockContentBoundingBox = blockContent.getBoundingClientRect();
|
|
175
|
-
|
|
220
|
+
const column = block.node.closest("[data-node-type=column]");
|
|
176
221
|
this.updateState({
|
|
177
222
|
show: true,
|
|
178
223
|
referencePos: new DOMRect(
|
|
179
|
-
|
|
224
|
+
column
|
|
225
|
+
? // We take the first child as column elements have some default
|
|
226
|
+
// padding. This is a little weird since this child element will
|
|
227
|
+
// be the first block, but since it's always non-nested and we
|
|
228
|
+
// only take the x coordinate, it's ok.
|
|
229
|
+
column.firstElementChild!.getBoundingClientRect().x
|
|
230
|
+
: (
|
|
231
|
+
this.pmView.dom.firstChild as HTMLElement
|
|
232
|
+
).getBoundingClientRect().x,
|
|
180
233
|
blockContentBoundingBox.y,
|
|
181
234
|
blockContentBoundingBox.width,
|
|
182
235
|
blockContentBoundingBox.height
|
|
@@ -209,22 +262,7 @@ export class SideMenuView<
|
|
|
209
262
|
});
|
|
210
263
|
|
|
211
264
|
if (!pos || pos.inside === -1) {
|
|
212
|
-
const evt =
|
|
213
|
-
const editorBoundingBox = (
|
|
214
|
-
this.pmView.dom.firstChild as HTMLElement
|
|
215
|
-
).getBoundingClientRect();
|
|
216
|
-
evt.clientX =
|
|
217
|
-
event.clientX < editorBoundingBox.left ||
|
|
218
|
-
event.clientX > editorBoundingBox.left + editorBoundingBox.width
|
|
219
|
-
? editorBoundingBox.left + editorBoundingBox.width / 2
|
|
220
|
-
: event.clientX;
|
|
221
|
-
evt.clientY = Math.min(
|
|
222
|
-
Math.max(event.clientY, editorBoundingBox.top),
|
|
223
|
-
editorBoundingBox.top + editorBoundingBox.height
|
|
224
|
-
);
|
|
225
|
-
evt.dataTransfer = event.dataTransfer;
|
|
226
|
-
evt.preventDefault = () => event.preventDefault();
|
|
227
|
-
evt.synthetic = true; // prevent recursion
|
|
265
|
+
const evt = this.createSyntheticEvent(event);
|
|
228
266
|
// console.log("dispatch fake drop");
|
|
229
267
|
this.pmView.dom.dispatchEvent(evt);
|
|
230
268
|
}
|
|
@@ -248,15 +286,7 @@ export class SideMenuView<
|
|
|
248
286
|
});
|
|
249
287
|
|
|
250
288
|
if (!pos || (pos.inside === -1 && this.pmView.dom.firstChild)) {
|
|
251
|
-
const evt =
|
|
252
|
-
const editorBoundingBox = (
|
|
253
|
-
this.pmView.dom.firstChild as HTMLElement
|
|
254
|
-
).getBoundingClientRect();
|
|
255
|
-
evt.clientX = editorBoundingBox.left + editorBoundingBox.width / 2;
|
|
256
|
-
evt.clientY = event.clientY;
|
|
257
|
-
evt.dataTransfer = event.dataTransfer;
|
|
258
|
-
evt.preventDefault = () => event.preventDefault();
|
|
259
|
-
evt.synthetic = true; // prevent recursion
|
|
289
|
+
const evt = this.createSyntheticEvent(event);
|
|
260
290
|
// console.log("dispatch fake dragover");
|
|
261
291
|
this.pmView.dom.dispatchEvent(evt);
|
|
262
292
|
}
|
|
@@ -314,6 +344,62 @@ export class SideMenuView<
|
|
|
314
344
|
this.updateStateFromMousePos();
|
|
315
345
|
};
|
|
316
346
|
|
|
347
|
+
private createSyntheticEvent(event: DragEvent) {
|
|
348
|
+
const evt = new Event(event.type, event) as any;
|
|
349
|
+
const editorBoundingBox = (
|
|
350
|
+
this.pmView.dom.firstChild as HTMLElement
|
|
351
|
+
).getBoundingClientRect();
|
|
352
|
+
evt.clientX = event.clientX;
|
|
353
|
+
evt.clientY = event.clientY;
|
|
354
|
+
if (
|
|
355
|
+
event.clientX < editorBoundingBox.left &&
|
|
356
|
+
event.clientX >
|
|
357
|
+
editorBoundingBox.left -
|
|
358
|
+
editorBoundingBox.width *
|
|
359
|
+
PERCENTAGE_OF_BLOCK_WIDTH_CONSIDERED_SIDE_DROP
|
|
360
|
+
) {
|
|
361
|
+
// when we're slightly left of the editor, we can drop to the side of the block
|
|
362
|
+
evt.clientX =
|
|
363
|
+
editorBoundingBox.left +
|
|
364
|
+
(editorBoundingBox.width *
|
|
365
|
+
PERCENTAGE_OF_BLOCK_WIDTH_CONSIDERED_SIDE_DROP) /
|
|
366
|
+
2;
|
|
367
|
+
} else if (
|
|
368
|
+
event.clientX > editorBoundingBox.right &&
|
|
369
|
+
event.clientX <
|
|
370
|
+
editorBoundingBox.right +
|
|
371
|
+
editorBoundingBox.width *
|
|
372
|
+
PERCENTAGE_OF_BLOCK_WIDTH_CONSIDERED_SIDE_DROP
|
|
373
|
+
) {
|
|
374
|
+
// when we're slightly right of the editor, we can drop to the side of the block
|
|
375
|
+
evt.clientX =
|
|
376
|
+
editorBoundingBox.right -
|
|
377
|
+
(editorBoundingBox.width *
|
|
378
|
+
PERCENTAGE_OF_BLOCK_WIDTH_CONSIDERED_SIDE_DROP) /
|
|
379
|
+
2;
|
|
380
|
+
} else if (
|
|
381
|
+
event.clientX < editorBoundingBox.left ||
|
|
382
|
+
event.clientX > editorBoundingBox.right
|
|
383
|
+
) {
|
|
384
|
+
// when mouse is outside of the editor on x axis, drop it somewhere safe (but not to the side of a block)
|
|
385
|
+
evt.clientX =
|
|
386
|
+
editorBoundingBox.left +
|
|
387
|
+
PERCENTAGE_OF_BLOCK_WIDTH_CONSIDERED_SIDE_DROP *
|
|
388
|
+
editorBoundingBox.width *
|
|
389
|
+
2; // put it somewhere in first block, but safe outside of the PERCENTAGE_OF_BLOCK_WIDTH_CONSIDERED_SIDE_DROP margin
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
evt.clientY = Math.min(
|
|
393
|
+
Math.max(event.clientY, editorBoundingBox.top),
|
|
394
|
+
editorBoundingBox.top + editorBoundingBox.height
|
|
395
|
+
);
|
|
396
|
+
|
|
397
|
+
evt.dataTransfer = event.dataTransfer;
|
|
398
|
+
evt.preventDefault = () => event.preventDefault();
|
|
399
|
+
evt.synthetic = true; // prevent recursion
|
|
400
|
+
return evt;
|
|
401
|
+
}
|
|
402
|
+
|
|
317
403
|
// Needed in cases where the editor state updates without the mouse cursor
|
|
318
404
|
// moving, as some state updates can require a side menu update. For example,
|
|
319
405
|
// adding a button to the side menu which removes the block can cause the
|
|
@@ -386,11 +472,14 @@ export class SideMenuProsemirrorPlugin<
|
|
|
386
472
|
/**
|
|
387
473
|
* Handles drag & drop events for blocks.
|
|
388
474
|
*/
|
|
389
|
-
blockDragStart = (
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
475
|
+
blockDragStart = (
|
|
476
|
+
event: {
|
|
477
|
+
dataTransfer: DataTransfer | null;
|
|
478
|
+
clientY: number;
|
|
479
|
+
},
|
|
480
|
+
block: Block<BSchema, I, S>
|
|
481
|
+
) => {
|
|
482
|
+
dragStart(event, block, this.editor);
|
|
394
483
|
};
|
|
395
484
|
|
|
396
485
|
/**
|
|
@@ -6,6 +6,7 @@ import { EditorView } from "prosemirror-view";
|
|
|
6
6
|
import { createExternalHTMLExporter } from "../../api/exporters/html/externalHTMLExporter.js";
|
|
7
7
|
import { cleanHTMLToMarkdown } from "../../api/exporters/markdown/markdownExporter.js";
|
|
8
8
|
import { fragmentToBlocks } from "../../api/nodeConversions/fragmentToBlocks.js";
|
|
9
|
+
import { getNodeById } from "../../api/nodeUtil.js";
|
|
9
10
|
import { Block } from "../../blocks/defaultBlocks.js";
|
|
10
11
|
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
|
|
11
12
|
import { UiElementPosition } from "../../extensions-shared/UiElementPosition.js";
|
|
@@ -27,39 +28,6 @@ export type SideMenuState<
|
|
|
27
28
|
block: Block<BSchema, I, S>;
|
|
28
29
|
};
|
|
29
30
|
|
|
30
|
-
export function getDraggableBlockFromElement(
|
|
31
|
-
element: Element,
|
|
32
|
-
view: EditorView
|
|
33
|
-
) {
|
|
34
|
-
while (
|
|
35
|
-
element &&
|
|
36
|
-
element.parentElement &&
|
|
37
|
-
element.parentElement !== view.dom &&
|
|
38
|
-
element.getAttribute?.("data-node-type") !== "blockContainer"
|
|
39
|
-
) {
|
|
40
|
-
element = element.parentElement;
|
|
41
|
-
}
|
|
42
|
-
if (element.getAttribute?.("data-node-type") !== "blockContainer") {
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
return { node: element as HTMLElement, id: element.getAttribute("data-id")! };
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function blockPositionFromElement(element: Element, view: EditorView) {
|
|
49
|
-
const block = getDraggableBlockFromElement(element, view);
|
|
50
|
-
|
|
51
|
-
if (block && block.node.nodeType === 1) {
|
|
52
|
-
// TODO: this uses undocumented PM APIs? do we need this / let's add docs?
|
|
53
|
-
const docView = (view as any).docView;
|
|
54
|
-
const desc = docView.nearestDesc(block.node, true);
|
|
55
|
-
if (!desc || desc === docView) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
return desc.posBefore;
|
|
59
|
-
}
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
31
|
function blockPositionsFromSelection(selection: Selection, doc: Node) {
|
|
64
32
|
// Absolute positions just before the first block spanned by the selection, and just after the last block. Having the
|
|
65
33
|
// selection start and end just before and just after the target blocks ensures no whitespace/line breaks are left
|
|
@@ -172,6 +140,7 @@ export function dragStart<
|
|
|
172
140
|
S extends StyleSchema
|
|
173
141
|
>(
|
|
174
142
|
e: { dataTransfer: DataTransfer | null; clientY: number },
|
|
143
|
+
block: Block<BSchema, I, S>,
|
|
175
144
|
editor: BlockNoteEditor<BSchema, I, S>
|
|
176
145
|
) {
|
|
177
146
|
if (!e.dataTransfer) {
|
|
@@ -180,28 +149,8 @@ export function dragStart<
|
|
|
180
149
|
|
|
181
150
|
const view = editor.prosemirrorView;
|
|
182
151
|
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
const coords = {
|
|
186
|
-
left: editorBoundingBox.left + editorBoundingBox.width / 2, // take middle of editor
|
|
187
|
-
top: e.clientY,
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
const elements = view.root.elementsFromPoint(coords.left, coords.top);
|
|
191
|
-
let blockEl = undefined;
|
|
192
|
-
|
|
193
|
-
for (const element of elements) {
|
|
194
|
-
if (view.dom.contains(element)) {
|
|
195
|
-
blockEl = getDraggableBlockFromElement(element, view);
|
|
196
|
-
break;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (!blockEl) {
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
152
|
+
const pos = getNodeById(block.id, view.state.doc).posBeforeNode;
|
|
203
153
|
|
|
204
|
-
const pos = blockPositionFromElement(blockEl.node, view);
|
|
205
154
|
if (pos != null) {
|
|
206
155
|
const selection = view.state.selection;
|
|
207
156
|
const doc = view.state.doc;
|
|
@@ -62,12 +62,10 @@ export function insertOrUpdateBlock<
|
|
|
62
62
|
currentBlock.content.length === 0)
|
|
63
63
|
) {
|
|
64
64
|
newBlock = editor.updateBlock(currentBlock, block);
|
|
65
|
-
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
editor.setTextCursorPosition(newBlock);
|
|
70
|
-
}
|
|
65
|
+
// We make sure to reset the cursor position to the new block as calling
|
|
66
|
+
// `updateBlock` may move it out. This generally happens when the content
|
|
67
|
+
// changes, or the update makes the block multi-column.
|
|
68
|
+
editor.setTextCursorPosition(newBlock);
|
|
71
69
|
} else {
|
|
72
70
|
newBlock = editor.insertBlocks([block], currentBlock, "after")[0];
|
|
73
71
|
editor.setTextCursorPosition(editor.getTextCursorPosition().nextBlock!);
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
StyleSchema,
|
|
13
13
|
} from "../../schema/index.js";
|
|
14
14
|
import { EventEmitter } from "../../util/EventEmitter.js";
|
|
15
|
-
import { getDraggableBlockFromElement } from "../
|
|
15
|
+
import { getDraggableBlockFromElement } from "../getDraggableBlockFromElement.js";
|
|
16
16
|
|
|
17
17
|
let dragImageElement: HTMLElement | undefined;
|
|
18
18
|
|
|
@@ -62,7 +62,7 @@ export const TrailingNode = Extension.create<TrailingNodeOptions>({
|
|
|
62
62
|
lastNode = lastNode.lastChild;
|
|
63
63
|
|
|
64
64
|
if (!lastNode || lastNode.type.name !== "blockContainer") {
|
|
65
|
-
|
|
65
|
+
return true; // not a blockContainer, but for example Columns. Insert trailing node
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
const lastContentNode = lastNode.firstChild;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EditorView } from "prosemirror-view";
|
|
2
|
+
|
|
3
|
+
export function getDraggableBlockFromElement(
|
|
4
|
+
element: Element,
|
|
5
|
+
view: EditorView
|
|
6
|
+
) {
|
|
7
|
+
while (
|
|
8
|
+
element &&
|
|
9
|
+
element.parentElement &&
|
|
10
|
+
element.parentElement !== view.dom &&
|
|
11
|
+
element.getAttribute?.("data-node-type") !== "blockContainer"
|
|
12
|
+
) {
|
|
13
|
+
element = element.parentElement;
|
|
14
|
+
}
|
|
15
|
+
if (element.getAttribute?.("data-node-type") !== "blockContainer") {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
return { node: element as HTMLElement, id: element.getAttribute("data-id")! };
|
|
19
|
+
}
|
package/src/i18n/locales/de.ts
CHANGED
|
@@ -22,13 +22,13 @@ export const de = {
|
|
|
22
22
|
title: "Nummerierte Liste",
|
|
23
23
|
subtext: "Liste mit nummerierten Elementen",
|
|
24
24
|
aliases: ["ol", "li", "liste", "nummerierteliste", "nummerierte liste"],
|
|
25
|
-
group: "Grundlegende
|
|
25
|
+
group: "Grundlegende blöcke",
|
|
26
26
|
},
|
|
27
27
|
bullet_list: {
|
|
28
28
|
title: "Aufzählungsliste",
|
|
29
29
|
subtext: "Liste mit unnummerierten Elementen",
|
|
30
30
|
aliases: ["ul", "li", "liste", "aufzählungsliste", "aufzählung liste"],
|
|
31
|
-
group: "Grundlegende
|
|
31
|
+
group: "Grundlegende blöcke",
|
|
32
32
|
},
|
|
33
33
|
check_list: {
|
|
34
34
|
title: "Checkliste",
|
|
@@ -42,19 +42,19 @@ export const de = {
|
|
|
42
42
|
"geprüfte liste",
|
|
43
43
|
"kontrollkästchen",
|
|
44
44
|
],
|
|
45
|
-
group: "Grundlegende
|
|
45
|
+
group: "Grundlegende blöcke",
|
|
46
46
|
},
|
|
47
47
|
paragraph: {
|
|
48
48
|
title: "Absatz",
|
|
49
49
|
subtext: "Der Hauptteil Ihres Dokuments",
|
|
50
50
|
aliases: ["p", "absatz"],
|
|
51
|
-
group: "Grundlegende
|
|
51
|
+
group: "Grundlegende blöcke",
|
|
52
52
|
},
|
|
53
53
|
code_block: {
|
|
54
54
|
title: "Codeblock",
|
|
55
55
|
subtext: "Codeblock mit Syntaxhervorhebung",
|
|
56
56
|
aliases: ["code", "pre"],
|
|
57
|
-
group: "Grundlegende
|
|
57
|
+
group: "Grundlegende blöcke",
|
|
58
58
|
},
|
|
59
59
|
table: {
|
|
60
60
|
title: "Tabelle",
|
package/src/i18n/locales/pt.ts
CHANGED
|
@@ -24,13 +24,13 @@ export const pt: Dictionary = {
|
|
|
24
24
|
title: "Lista Numerada",
|
|
25
25
|
subtext: "Usado para exibir uma lista numerada",
|
|
26
26
|
aliases: ["ol", "li", "lista", "listanumerada", "lista numerada"],
|
|
27
|
-
group: "Blocos
|
|
27
|
+
group: "Blocos básicos",
|
|
28
28
|
},
|
|
29
29
|
bullet_list: {
|
|
30
30
|
title: "Lista com Marcadores",
|
|
31
31
|
subtext: "Usado para exibir uma lista não ordenada",
|
|
32
32
|
aliases: ["ul", "li", "lista", "listamarcadores", "lista com marcadores"],
|
|
33
|
-
group: "Blocos
|
|
33
|
+
group: "Blocos básicos",
|
|
34
34
|
},
|
|
35
35
|
check_list: {
|
|
36
36
|
title: "Lista de verificação",
|
|
@@ -43,19 +43,19 @@ export const pt: Dictionary = {
|
|
|
43
43
|
"lista marcada",
|
|
44
44
|
"caixa de seleção",
|
|
45
45
|
],
|
|
46
|
-
group: "Blocos
|
|
46
|
+
group: "Blocos básicos",
|
|
47
47
|
},
|
|
48
48
|
paragraph: {
|
|
49
49
|
title: "Parágrafo",
|
|
50
50
|
subtext: "Usado para o corpo do seu documento",
|
|
51
51
|
aliases: ["p", "paragrafo"],
|
|
52
|
-
group: "Blocos
|
|
52
|
+
group: "Blocos básicos",
|
|
53
53
|
},
|
|
54
54
|
code_block: {
|
|
55
55
|
title: "Bloco de Código",
|
|
56
56
|
subtext: "Usado para exibir código com destaque de sintaxe",
|
|
57
57
|
aliases: ["codigo", "pre"],
|
|
58
|
-
group: "Blocos
|
|
58
|
+
group: "Blocos básicos",
|
|
59
59
|
},
|
|
60
60
|
table: {
|
|
61
61
|
title: "Tabela",
|
package/src/index.ts
CHANGED
|
@@ -2,13 +2,10 @@ import * as locales from "./i18n/locales/index.js";
|
|
|
2
2
|
export * from "./api/exporters/html/externalHTMLExporter.js";
|
|
3
3
|
export * from "./api/exporters/html/internalHTMLSerializer.js";
|
|
4
4
|
export * from "./api/getBlockInfoFromPos.js";
|
|
5
|
+
export * from "./api/nodeUtil.js";
|
|
5
6
|
export * from "./api/testUtil/index.js";
|
|
6
7
|
export * from "./blocks/AudioBlockContent/AudioBlockContent.js";
|
|
7
8
|
export * from "./blocks/CodeBlockContent/CodeBlockContent.js";
|
|
8
|
-
export * from "./blocks/defaultBlockHelpers.js";
|
|
9
|
-
export * from "./blocks/defaultBlocks.js";
|
|
10
|
-
export * from "./blocks/defaultBlockTypeGuards.js";
|
|
11
|
-
export * from "./blocks/defaultProps.js";
|
|
12
9
|
export * from "./blocks/FileBlockContent/FileBlockContent.js";
|
|
13
10
|
export * from "./blocks/FileBlockContent/fileBlockHelpers.js";
|
|
14
11
|
export * from "./blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js";
|
|
@@ -19,10 +16,16 @@ export {
|
|
|
19
16
|
EMPTY_CELL_WIDTH,
|
|
20
17
|
} from "./blocks/TableBlockContent/TableExtension.js";
|
|
21
18
|
export * from "./blocks/VideoBlockContent/VideoBlockContent.js";
|
|
19
|
+
export * from "./blocks/defaultBlockHelpers.js";
|
|
20
|
+
export * from "./blocks/defaultBlockTypeGuards.js";
|
|
21
|
+
export * from "./blocks/defaultBlocks.js";
|
|
22
|
+
export * from "./blocks/defaultProps.js";
|
|
22
23
|
export * from "./editor/BlockNoteEditor.js";
|
|
23
24
|
export * from "./editor/BlockNoteExtensions.js";
|
|
24
25
|
export * from "./editor/BlockNoteSchema.js";
|
|
26
|
+
export * from "./editor/defaultColors.js";
|
|
25
27
|
export * from "./editor/selectionTypes.js";
|
|
28
|
+
export * from "./exporter/index.js";
|
|
26
29
|
export * from "./extensions-shared/UiElementPosition.js";
|
|
27
30
|
export * from "./extensions/FilePanel/FilePanelPlugin.js";
|
|
28
31
|
export * from "./extensions/FormattingToolbar/FormattingToolbarPlugin.js";
|
|
@@ -30,13 +33,14 @@ export * from "./extensions/LinkToolbar/LinkToolbarPlugin.js";
|
|
|
30
33
|
export * from "./extensions/SideMenu/SideMenuPlugin.js";
|
|
31
34
|
export * from "./extensions/SuggestionMenu/DefaultGridSuggestionItem.js";
|
|
32
35
|
export * from "./extensions/SuggestionMenu/DefaultSuggestionItem.js";
|
|
36
|
+
export * from "./extensions/SuggestionMenu/SuggestionPlugin.js";
|
|
33
37
|
export * from "./extensions/SuggestionMenu/getDefaultEmojiPickerItems.js";
|
|
34
38
|
export * from "./extensions/SuggestionMenu/getDefaultSlashMenuItems.js";
|
|
35
|
-
export * from "./extensions/SuggestionMenu/SuggestionPlugin.js";
|
|
36
39
|
export * from "./extensions/TableHandles/TableHandlesPlugin.js";
|
|
37
40
|
export * from "./i18n/dictionary.js";
|
|
38
41
|
export * from "./schema/index.js";
|
|
39
42
|
export * from "./util/browser.js";
|
|
43
|
+
export * from "./util/combineByGroup.js";
|
|
40
44
|
export * from "./util/esmDependencies.js";
|
|
41
45
|
export * from "./util/string.js";
|
|
42
46
|
export * from "./util/typescript.js";
|
|
@@ -21,7 +21,7 @@ export const BlockContainer = Node.create<{
|
|
|
21
21
|
editor: BlockNoteEditor<any, any, any>;
|
|
22
22
|
}>({
|
|
23
23
|
name: "blockContainer",
|
|
24
|
-
group: "
|
|
24
|
+
group: "blockGroupChild bnBlock",
|
|
25
25
|
// A block always contains content, and optionally a blockGroup which contains nested blocks
|
|
26
26
|
content: "blockContent blockGroup?",
|
|
27
27
|
// Ensures content-specific keyboard handlers trigger first.
|