@blocknote/core 0.21.0 → 0.22.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 +1023 -999
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +7 -7
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +3 -3
- package/src/api/clipboard/__snapshots__/external/pasteEndOfParagraph.html +96 -0
- package/src/api/clipboard/__snapshots__/external/pasteEndOfParagraphText.html +96 -0
- package/src/api/clipboard/__snapshots__/external/pasteImage.html +111 -0
- package/src/api/clipboard/__snapshots__/external/pasteParagraphInCustomBlock.html +96 -0
- package/src/api/clipboard/__snapshots__/external/pasteTable.html +149 -0
- package/src/api/clipboard/__snapshots__/external/pasteTableInExistingTable.html +124 -0
- package/src/api/clipboard/__snapshots__/internal/paragraphInCustomBlock.html +1 -0
- package/src/api/clipboard/clipboardExternal.test.ts +161 -0
- package/src/api/clipboard/{clipboard.test.ts → clipboardInternal.test.ts} +60 -38
- package/src/api/clipboard/testUtil.ts +27 -0
- package/src/api/clipboard/toClipboard/copyExtension.ts +1 -0
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +7 -1
- package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +3 -1
- package/src/api/nodeConversions/nodeToBlock.ts +4 -1
- package/src/api/parsers/markdown/__snapshots__/pasted/styled.json +2 -2
- package/src/api/testUtil/partialBlockTestUtil.ts +4 -1
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +3 -19
- package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +3 -15
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +11 -3
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +25 -5
- package/src/editor/Block.css +3 -3
- package/src/editor/BlockNoteEditor.test.ts +21 -1
- package/src/editor/editor.css +6 -6
- package/src/editor/transformPasted.ts +57 -4
- package/src/schema/blocks/createSpec.ts +1 -1
- package/src/schema/blocks/internal.ts +16 -6
- package/src/schema/inlineContent/internal.ts +4 -1
- package/src/schema/propTypes.ts +41 -18
- package/types/src/api/blockManipulation/setupTestEnv.d.ts +8 -0
- package/types/src/api/clipboard/clipboardInternal.test.d.ts +1 -0
- package/types/src/api/clipboard/testUtil.d.ts +509 -0
- package/types/src/api/testUtil/cases/customBlocks.d.ts +8 -0
- package/types/src/api/testUtil/cases/customInlineContent.d.ts +8 -0
- package/types/src/api/testUtil/cases/customStyles.d.ts +8 -0
- package/types/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +12 -0
- package/types/src/blocks/defaultBlocks.d.ts +16 -0
- package/types/src/editor/transformPasted.d.ts +8 -4
- package/types/src/schema/propTypes.d.ts +20 -2
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js +0 -30
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.js +0 -99
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.js +0 -97
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.js +0 -88
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.js +0 -219
- package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.js +0 -175
- package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/nestBlock/nestBlock.js +0 -57
- package/dist/src/api/blockManipulation/commands/nestBlock/nestBlock.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js +0 -5
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js +0 -31
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js +0 -71
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.js +0 -157
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js +0 -27
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js +0 -67
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js +0 -148
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.test.js +0 -252
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.test.js.map +0 -1
- package/dist/src/api/blockManipulation/getBlock/getBlock.js +0 -56
- package/dist/src/api/blockManipulation/getBlock/getBlock.js.map +0 -1
- package/dist/src/api/blockManipulation/insertContentAt.js +0 -64
- package/dist/src/api/blockManipulation/insertContentAt.js.map +0 -1
- package/dist/src/api/blockManipulation/selections/selection.js +0 -149
- package/dist/src/api/blockManipulation/selections/selection.js.map +0 -1
- package/dist/src/api/blockManipulation/selections/selection.test.js +0 -39
- package/dist/src/api/blockManipulation/selections/selection.test.js.map +0 -1
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js +0 -79
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js.map +0 -1
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.js +0 -33
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.js.map +0 -1
- package/dist/src/api/blockManipulation/setupTestEnv.js +0 -172
- package/dist/src/api/blockManipulation/setupTestEnv.js.map +0 -1
- package/dist/src/api/clipboard/clipboard.test.js +0 -249
- package/dist/src/api/clipboard/clipboard.test.js.map +0 -1
- package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js +0 -8
- package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js.map +0 -1
- package/dist/src/api/clipboard/fromClipboard/fileDropExtension.js +0 -38
- package/dist/src/api/clipboard/fromClipboard/fileDropExtension.js.map +0 -1
- package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js +0 -111
- package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js.map +0 -1
- package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js +0 -25
- package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js.map +0 -1
- package/dist/src/api/clipboard/fromClipboard/pasteExtension.js +0 -57
- package/dist/src/api/clipboard/fromClipboard/pasteExtension.js.map +0 -1
- package/dist/src/api/clipboard/toClipboard/copyExtension.js +0 -134
- package/dist/src/api/clipboard/toClipboard/copyExtension.js.map +0 -1
- package/dist/src/api/exporters/html/externalHTMLExporter.js +0 -35
- package/dist/src/api/exporters/html/externalHTMLExporter.js.map +0 -1
- package/dist/src/api/exporters/html/htmlConversion.test.js +0 -72
- package/dist/src/api/exporters/html/htmlConversion.test.js.map +0 -1
- package/dist/src/api/exporters/html/internalHTMLSerializer.js +0 -21
- package/dist/src/api/exporters/html/internalHTMLSerializer.js.map +0 -1
- package/dist/src/api/exporters/html/util/serializeBlocksExternalHTML.js +0 -141
- package/dist/src/api/exporters/html/util/serializeBlocksExternalHTML.js.map +0 -1
- package/dist/src/api/exporters/html/util/serializeBlocksInternalHTML.js +0 -96
- package/dist/src/api/exporters/html/util/serializeBlocksInternalHTML.js.map +0 -1
- package/dist/src/api/exporters/markdown/markdownExporter.js +0 -31
- package/dist/src/api/exporters/markdown/markdownExporter.js.map +0 -1
- package/dist/src/api/exporters/markdown/markdownExporter.test.js +0 -57
- package/dist/src/api/exporters/markdown/markdownExporter.test.js.map +0 -1
- package/dist/src/api/exporters/markdown/removeUnderlinesRehypePlugin.js +0 -33
- package/dist/src/api/exporters/markdown/removeUnderlinesRehypePlugin.js.map +0 -1
- package/dist/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.js +0 -37
- package/dist/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.js.map +0 -1
- package/dist/src/api/getBlockInfoFromPos.js +0 -165
- package/dist/src/api/getBlockInfoFromPos.js.map +0 -1
- package/dist/src/api/nodeConversions/blockToNode.js +0 -197
- package/dist/src/api/nodeConversions/blockToNode.js.map +0 -1
- package/dist/src/api/nodeConversions/fragmentToBlocks.js +0 -50
- package/dist/src/api/nodeConversions/fragmentToBlocks.js.map +0 -1
- package/dist/src/api/nodeConversions/nodeConversions.test.js +0 -54
- package/dist/src/api/nodeConversions/nodeConversions.test.js.map +0 -1
- package/dist/src/api/nodeConversions/nodeToBlock.js +0 -316
- package/dist/src/api/nodeConversions/nodeToBlock.js.map +0 -1
- package/dist/src/api/nodeUtil.js +0 -28
- package/dist/src/api/nodeUtil.js.map +0 -1
- package/dist/src/api/parsers/html/parseHTML.js +0 -19
- package/dist/src/api/parsers/html/parseHTML.js.map +0 -1
- package/dist/src/api/parsers/html/parseHTML.test.js +0 -470
- package/dist/src/api/parsers/html/parseHTML.test.js.map +0 -1
- package/dist/src/api/parsers/html/util/nestedLists.js +0 -106
- package/dist/src/api/parsers/html/util/nestedLists.js.map +0 -1
- package/dist/src/api/parsers/html/util/nestedLists.test.js +0 -166
- package/dist/src/api/parsers/html/util/nestedLists.test.js.map +0 -1
- package/dist/src/api/parsers/markdown/parseMarkdown.js +0 -52
- package/dist/src/api/parsers/markdown/parseMarkdown.js.map +0 -1
- package/dist/src/api/parsers/markdown/parseMarkdown.test.js +0 -112
- package/dist/src/api/parsers/markdown/parseMarkdown.test.js.map +0 -1
- package/dist/src/api/testUtil/cases/customBlocks.js +0 -313
- package/dist/src/api/testUtil/cases/customBlocks.js.map +0 -1
- package/dist/src/api/testUtil/cases/customInlineContent.js +0 -91
- package/dist/src/api/testUtil/cases/customInlineContent.js.map +0 -1
- package/dist/src/api/testUtil/cases/customStyles.js +0 -83
- package/dist/src/api/testUtil/cases/customStyles.js.map +0 -1
- package/dist/src/api/testUtil/cases/defaultSchema.js +0 -673
- package/dist/src/api/testUtil/cases/defaultSchema.js.map +0 -1
- package/dist/src/api/testUtil/index.js +0 -2
- package/dist/src/api/testUtil/index.js.map +0 -1
- package/dist/src/api/testUtil/partialBlockTestUtil.js +0 -114
- package/dist/src/api/testUtil/partialBlockTestUtil.js.map +0 -1
- package/dist/src/api/testUtil/paste.js +0 -29
- package/dist/src/api/testUtil/paste.js.map +0 -1
- package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js +0 -104
- package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js.map +0 -1
- package/dist/src/blocks/AudioBlockContent/parseAudioElement.js +0 -5
- package/dist/src/blocks/AudioBlockContent/parseAudioElement.js.map +0 -1
- package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js +0 -281
- package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js.map +0 -1
- package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js +0 -110
- package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/FileBlockContent.js +0 -71
- package/dist/src/blocks/FileBlockContent/FileBlockContent.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/helpers/parse/parseEmbedElement.js +0 -5
- package/dist/src/blocks/FileBlockContent/helpers/parse/parseEmbedElement.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.js +0 -10
- package/dist/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/helpers/render/createAddFileButton.js +0 -39
- package/dist/src/blocks/FileBlockContent/helpers/render/createAddFileButton.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.js +0 -51
- package/dist/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.js +0 -17
- package/dist/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.js +0 -147
- package/dist/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.js +0 -9
- package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.js +0 -11
- package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js +0 -15
- package/dist/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js.map +0 -1
- package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js +0 -145
- package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js.map +0 -1
- package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js +0 -114
- package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js.map +0 -1
- package/dist/src/blocks/ImageBlockContent/parseImageElement.js +0 -6
- package/dist/src/blocks/ImageBlockContent/parseImageElement.js.map +0 -1
- package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js +0 -113
- package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js.map +0 -1
- package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js +0 -224
- package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js.map +0 -1
- package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js +0 -45
- package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js.map +0 -1
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.js +0 -58
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.js.map +0 -1
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js +0 -130
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js.map +0 -1
- package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js +0 -52
- package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js.map +0 -1
- package/dist/src/blocks/TableBlockContent/TableBlockContent.js +0 -129
- package/dist/src/blocks/TableBlockContent/TableBlockContent.js.map +0 -1
- package/dist/src/blocks/TableBlockContent/TableExtension.js +0 -64
- package/dist/src/blocks/TableBlockContent/TableExtension.js.map +0 -1
- package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js +0 -114
- package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js.map +0 -1
- package/dist/src/blocks/VideoBlockContent/parseVideoElement.js +0 -6
- package/dist/src/blocks/VideoBlockContent/parseVideoElement.js.map +0 -1
- package/dist/src/blocks/defaultBlockHelpers.js +0 -50
- package/dist/src/blocks/defaultBlockHelpers.js.map +0 -1
- package/dist/src/blocks/defaultBlockTypeGuards.js +0 -40
- package/dist/src/blocks/defaultBlockTypeGuards.js.map +0 -1
- package/dist/src/blocks/defaultBlocks.js +0 -50
- package/dist/src/blocks/defaultBlocks.js.map +0 -1
- package/dist/src/blocks/defaultProps.js +0 -19
- package/dist/src/blocks/defaultProps.js.map +0 -1
- package/dist/src/editor/BlockNoteEditor.js +0 -751
- package/dist/src/editor/BlockNoteEditor.js.map +0 -1
- package/dist/src/editor/BlockNoteEditor.test.js +0 -65
- package/dist/src/editor/BlockNoteEditor.test.js.map +0 -1
- package/dist/src/editor/BlockNoteExtensions.js +0 -192
- package/dist/src/editor/BlockNoteExtensions.js.map +0 -1
- package/dist/src/editor/BlockNoteSchema.js +0 -38
- package/dist/src/editor/BlockNoteSchema.js.map +0 -1
- package/dist/src/editor/BlockNoteTipTapEditor.js +0 -169
- package/dist/src/editor/BlockNoteTipTapEditor.js.map +0 -1
- package/dist/src/editor/cursorPositionTypes.js +0 -2
- package/dist/src/editor/cursorPositionTypes.js.map +0 -1
- package/dist/src/editor/defaultColors.js +0 -77
- package/dist/src/editor/defaultColors.js.map +0 -1
- package/dist/src/editor/selectionTypes.js +0 -2
- package/dist/src/editor/selectionTypes.js.map +0 -1
- package/dist/src/editor/transformPasted.js +0 -79
- package/dist/src/editor/transformPasted.js.map +0 -1
- package/dist/src/exporter/Exporter.js +0 -36
- package/dist/src/exporter/Exporter.js.map +0 -1
- package/dist/src/exporter/index.js +0 -3
- package/dist/src/exporter/index.js.map +0 -1
- package/dist/src/exporter/mapping.js +0 -12
- package/dist/src/exporter/mapping.js.map +0 -1
- package/dist/src/extensions/BackgroundColor/BackgroundColorExtension.js +0 -30
- package/dist/src/extensions/BackgroundColor/BackgroundColorExtension.js.map +0 -1
- package/dist/src/extensions/BackgroundColor/BackgroundColorMark.js +0 -39
- package/dist/src/extensions/BackgroundColor/BackgroundColorMark.js.map +0 -1
- package/dist/src/extensions/FilePanel/FilePanelPlugin.js +0 -131
- package/dist/src/extensions/FilePanel/FilePanelPlugin.js.map +0 -1
- package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js +0 -197
- package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js.map +0 -1
- package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js +0 -341
- package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js.map +0 -1
- package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js +0 -251
- package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js.map +0 -1
- package/dist/src/extensions/LinkToolbar/protocols.js +0 -14
- package/dist/src/extensions/LinkToolbar/protocols.js.map +0 -1
- package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js +0 -54
- package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js.map +0 -1
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js +0 -90
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js.map +0 -1
- package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js +0 -187
- package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js.map +0 -1
- package/dist/src/extensions/SideMenu/MultipleNodeSelection.js +0 -68
- package/dist/src/extensions/SideMenu/MultipleNodeSelection.js.map +0 -1
- package/dist/src/extensions/SideMenu/SideMenuPlugin.js +0 -347
- package/dist/src/extensions/SideMenu/SideMenuPlugin.js.map +0 -1
- package/dist/src/extensions/SideMenu/dragging.js +0 -135
- package/dist/src/extensions/SideMenu/dragging.js.map +0 -1
- package/dist/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.js +0 -2
- package/dist/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.js.map +0 -1
- package/dist/src/extensions/SuggestionMenu/DefaultSuggestionItem.js +0 -2
- package/dist/src/extensions/SuggestionMenu/DefaultSuggestionItem.js.map +0 -1
- package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js +0 -245
- package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js.map +0 -1
- package/dist/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.js +0 -26
- package/dist/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.js.map +0 -1
- package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js +0 -241
- package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js.map +0 -1
- package/dist/src/extensions/TableHandles/TableHandlesPlugin.js +0 -579
- package/dist/src/extensions/TableHandles/TableHandlesPlugin.js.map +0 -1
- package/dist/src/extensions/TextAlignment/TextAlignmentExtension.js +0 -36
- package/dist/src/extensions/TextAlignment/TextAlignmentExtension.js.map +0 -1
- package/dist/src/extensions/TextColor/TextColorExtension.js +0 -29
- package/dist/src/extensions/TextColor/TextColorExtension.js.map +0 -1
- package/dist/src/extensions/TextColor/TextColorMark.js +0 -37
- package/dist/src/extensions/TextColor/TextColorMark.js.map +0 -1
- package/dist/src/extensions/TrailingNode/TrailingNodeExtension.js +0 -58
- package/dist/src/extensions/TrailingNode/TrailingNodeExtension.js.map +0 -1
- package/dist/src/extensions/UniqueID/UniqueID.js +0 -283
- package/dist/src/extensions/UniqueID/UniqueID.js.map +0 -1
- package/dist/src/extensions/getDraggableBlockFromElement.js +0 -13
- package/dist/src/extensions/getDraggableBlockFromElement.js.map +0 -1
- package/dist/src/extensions-shared/UiElementPosition.js +0 -2
- package/dist/src/extensions-shared/UiElementPosition.js.map +0 -1
- package/dist/src/i18n/dictionary.js +0 -4
- package/dist/src/i18n/dictionary.js.map +0 -1
- package/dist/src/i18n/locales/ar.js +0 -298
- package/dist/src/i18n/locales/ar.js.map +0 -1
- package/dist/src/i18n/locales/de.js +0 -313
- package/dist/src/i18n/locales/de.js.map +0 -1
- package/dist/src/i18n/locales/en.js +0 -314
- package/dist/src/i18n/locales/en.js.map +0 -1
- package/dist/src/i18n/locales/es.js +0 -312
- package/dist/src/i18n/locales/es.js.map +0 -1
- package/dist/src/i18n/locales/fr.js +0 -313
- package/dist/src/i18n/locales/fr.js.map +0 -1
- package/dist/src/i18n/locales/hr.js +0 -308
- package/dist/src/i18n/locales/hr.js.map +0 -1
- package/dist/src/i18n/locales/index.js +0 -16
- package/dist/src/i18n/locales/index.js.map +0 -1
- package/dist/src/i18n/locales/is.js +0 -305
- package/dist/src/i18n/locales/is.js.map +0 -1
- package/dist/src/i18n/locales/ja.js +0 -333
- package/dist/src/i18n/locales/ja.js.map +0 -1
- package/dist/src/i18n/locales/ko.js +0 -326
- package/dist/src/i18n/locales/ko.js.map +0 -1
- package/dist/src/i18n/locales/nl.js +0 -313
- package/dist/src/i18n/locales/nl.js.map +0 -1
- package/dist/src/i18n/locales/pl.js +0 -297
- package/dist/src/i18n/locales/pl.js.map +0 -1
- package/dist/src/i18n/locales/pt.js +0 -305
- package/dist/src/i18n/locales/pt.js.map +0 -1
- package/dist/src/i18n/locales/ru.js +0 -340
- package/dist/src/i18n/locales/ru.js.map +0 -1
- package/dist/src/i18n/locales/vi.js +0 -312
- package/dist/src/i18n/locales/vi.js.map +0 -1
- package/dist/src/i18n/locales/zh.js +0 -346
- package/dist/src/i18n/locales/zh.js.map +0 -1
- package/dist/src/index.js +0 -63
- package/dist/src/index.js.map +0 -1
- package/dist/src/pm-nodes/BlockContainer.js +0 -72
- package/dist/src/pm-nodes/BlockContainer.js.map +0 -1
- package/dist/src/pm-nodes/BlockGroup.js +0 -43
- package/dist/src/pm-nodes/BlockGroup.js.map +0 -1
- package/dist/src/pm-nodes/Doc.js +0 -7
- package/dist/src/pm-nodes/Doc.js.map +0 -1
- package/dist/src/pm-nodes/index.js +0 -4
- package/dist/src/pm-nodes/index.js.map +0 -1
- package/dist/src/schema/blocks/createSpec.js +0 -126
- package/dist/src/schema/blocks/createSpec.js.map +0 -1
- package/dist/src/schema/blocks/internal.js +0 -147
- package/dist/src/schema/blocks/internal.js.map +0 -1
- package/dist/src/schema/blocks/types.js +0 -2
- package/dist/src/schema/blocks/types.js.map +0 -1
- package/dist/src/schema/index.js +0 -11
- package/dist/src/schema/index.js.map +0 -1
- package/dist/src/schema/inlineContent/createSpec.js +0 -64
- package/dist/src/schema/inlineContent/createSpec.js.map +0 -1
- package/dist/src/schema/inlineContent/internal.js +0 -52
- package/dist/src/schema/inlineContent/internal.js.map +0 -1
- package/dist/src/schema/inlineContent/types.js +0 -10
- package/dist/src/schema/inlineContent/types.js.map +0 -1
- package/dist/src/schema/propTypes.js +0 -2
- package/dist/src/schema/propTypes.js.map +0 -1
- package/dist/src/schema/styles/createSpec.js +0 -48
- package/dist/src/schema/styles/createSpec.js.map +0 -1
- package/dist/src/schema/styles/internal.js +0 -53
- package/dist/src/schema/styles/internal.js.map +0 -1
- package/dist/src/schema/styles/types.js +0 -2
- package/dist/src/schema/styles/types.js.map +0 -1
- package/dist/src/util/EventEmitter.js +0 -33
- package/dist/src/util/EventEmitter.js.map +0 -1
- package/dist/src/util/browser.js +0 -17
- package/dist/src/util/browser.js.map +0 -1
- package/dist/src/util/combineByGroup.js +0 -20
- package/dist/src/util/combineByGroup.js.map +0 -1
- package/dist/src/util/esmDependencies.js +0 -35
- package/dist/src/util/esmDependencies.js.map +0 -1
- package/dist/src/util/string.js +0 -14
- package/dist/src/util/string.js.map +0 -1
- package/dist/src/util/typescript.js +0 -12
- package/dist/src/util/typescript.js.map +0 -1
- /package/src/api/clipboard/__snapshots__/{childToParent.html → internal/childToParent.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{childrenToNextParent.html → internal/childrenToNextParent.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{childrenToNextParentsChildren.html → internal/childrenToNextParentsChildren.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{image.html → internal/image.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{multipleChildren.html → internal/multipleChildren.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{multipleStyledText.html → internal/multipleStyledText.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{nestedImage.html → internal/nestedImage.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{partialChildToParent.html → internal/partialChildToParent.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{styledText.html → internal/styledText.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{tableAllCells.html → internal/tableAllCells.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{tableCell.html → internal/tableCell.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{tableCellText.html → internal/tableCellText.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{tableRow.html → internal/tableRow.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{unstyledText.html → internal/unstyledText.html} +0 -0
- /package/types/src/api/clipboard/{clipboard.test.d.ts → clipboardExternal.test.d.ts} +0 -0
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
import { NodeSelection, TextSelection } from "prosemirror-state";
|
|
2
|
-
import { CellSelection } from "prosemirror-tables";
|
|
3
|
-
import { afterAll, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
|
4
|
-
import { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
|
|
5
|
-
import { initializeESMDependencies } from "../../util/esmDependencies.js";
|
|
6
|
-
import { doPaste } from "../testUtil/paste.js";
|
|
7
|
-
import { selectedFragmentToHTML } from "./toClipboard/copyExtension.js";
|
|
8
|
-
// These tests are meant to test the copying of user selections in the editor.
|
|
9
|
-
// The test cases used for the other HTML conversion tests are not suitable here
|
|
10
|
-
// as they are represented in the BlockNote API, whereas here we want to test
|
|
11
|
-
// ProseMirror/TipTap selections directly.
|
|
12
|
-
describe("Test ProseMirror selection clipboard HTML", () => {
|
|
13
|
-
const initialContent = [
|
|
14
|
-
{
|
|
15
|
-
type: "heading",
|
|
16
|
-
props: {
|
|
17
|
-
level: 2,
|
|
18
|
-
textColor: "red",
|
|
19
|
-
},
|
|
20
|
-
content: "Heading 1",
|
|
21
|
-
children: [
|
|
22
|
-
{
|
|
23
|
-
type: "paragraph",
|
|
24
|
-
content: "Nested Paragraph 1",
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
type: "paragraph",
|
|
28
|
-
content: "Nested Paragraph 2",
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
type: "paragraph",
|
|
32
|
-
content: "Nested Paragraph 3",
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
type: "heading",
|
|
38
|
-
props: {
|
|
39
|
-
level: 2,
|
|
40
|
-
textColor: "red",
|
|
41
|
-
},
|
|
42
|
-
content: "Heading 2",
|
|
43
|
-
children: [
|
|
44
|
-
{
|
|
45
|
-
type: "paragraph",
|
|
46
|
-
content: "Nested Paragraph 1",
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
type: "paragraph",
|
|
50
|
-
content: "Nested Paragraph 2",
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
type: "paragraph",
|
|
54
|
-
content: "Nested Paragraph 3",
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
type: "heading",
|
|
60
|
-
props: {
|
|
61
|
-
level: 2,
|
|
62
|
-
textColor: "red",
|
|
63
|
-
},
|
|
64
|
-
content: [
|
|
65
|
-
{
|
|
66
|
-
type: "text",
|
|
67
|
-
text: "Bold",
|
|
68
|
-
styles: {
|
|
69
|
-
bold: true,
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
type: "text",
|
|
74
|
-
text: "Italic",
|
|
75
|
-
styles: {
|
|
76
|
-
italic: true,
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
type: "text",
|
|
81
|
-
text: "Regular",
|
|
82
|
-
styles: {},
|
|
83
|
-
},
|
|
84
|
-
],
|
|
85
|
-
children: [
|
|
86
|
-
{
|
|
87
|
-
type: "image",
|
|
88
|
-
props: {
|
|
89
|
-
url: "https://ralfvanveen.com/wp-content/uploads/2021/06/Placeholder-_-Glossary.svg",
|
|
90
|
-
},
|
|
91
|
-
children: [
|
|
92
|
-
{
|
|
93
|
-
type: "paragraph",
|
|
94
|
-
content: "Nested Paragraph",
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
type: "table",
|
|
102
|
-
content: {
|
|
103
|
-
type: "tableContent",
|
|
104
|
-
rows: [
|
|
105
|
-
{
|
|
106
|
-
cells: ["Table Cell", "Table Cell"],
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
cells: ["Table Cell", "Table Cell"],
|
|
110
|
-
},
|
|
111
|
-
],
|
|
112
|
-
},
|
|
113
|
-
// Not needed as selections starting in table cells will get snapped to
|
|
114
|
-
// the table boundaries.
|
|
115
|
-
// children: [
|
|
116
|
-
// {
|
|
117
|
-
// type: "table",
|
|
118
|
-
// content: {
|
|
119
|
-
// type: "tableContent",
|
|
120
|
-
// rows: [
|
|
121
|
-
// {
|
|
122
|
-
// cells: ["Table Cell", "Table Cell"],
|
|
123
|
-
// },
|
|
124
|
-
// {
|
|
125
|
-
// cells: ["Table Cell", "Table Cell"],
|
|
126
|
-
// },
|
|
127
|
-
// ],
|
|
128
|
-
// },
|
|
129
|
-
// },
|
|
130
|
-
// ],
|
|
131
|
-
},
|
|
132
|
-
];
|
|
133
|
-
let editor;
|
|
134
|
-
const div = document.createElement("div");
|
|
135
|
-
beforeEach(() => {
|
|
136
|
-
editor.replaceBlocks(editor.document, initialContent);
|
|
137
|
-
});
|
|
138
|
-
beforeAll(async () => {
|
|
139
|
-
window.__TEST_OPTIONS = window.__TEST_OPTIONS || {};
|
|
140
|
-
editor = BlockNoteEditor.create();
|
|
141
|
-
editor.mount(div);
|
|
142
|
-
await initializeESMDependencies();
|
|
143
|
-
});
|
|
144
|
-
afterAll(() => {
|
|
145
|
-
editor.mount(undefined);
|
|
146
|
-
editor._tiptapEditor.destroy();
|
|
147
|
-
editor = undefined;
|
|
148
|
-
delete window.__TEST_OPTIONS;
|
|
149
|
-
});
|
|
150
|
-
// Sets the editor selection to the given start and end positions, then
|
|
151
|
-
// exports the selected content to HTML and compares it to a snapshot.
|
|
152
|
-
async function testSelection(testCase) {
|
|
153
|
-
if (!editor.prosemirrorView) {
|
|
154
|
-
throw new Error("Editor view not initialized.");
|
|
155
|
-
}
|
|
156
|
-
editor.dispatch(editor._tiptapEditor.state.tr.setSelection(testCase.createSelection(editor.prosemirrorView.state.doc)));
|
|
157
|
-
const { clipboardHTML, externalHTML } = selectedFragmentToHTML(editor.prosemirrorView, editor);
|
|
158
|
-
expect(externalHTML).toMatchFileSnapshot(`./__snapshots__/${testCase.testName}.html`);
|
|
159
|
-
const originalDocument = editor.document;
|
|
160
|
-
doPaste(editor.prosemirrorView, "text", clipboardHTML, false, new ClipboardEvent("paste"));
|
|
161
|
-
const newDocument = editor.document;
|
|
162
|
-
expect(newDocument).toStrictEqual(originalDocument);
|
|
163
|
-
}
|
|
164
|
-
const testCases = [
|
|
165
|
-
// TODO: Consider adding test cases for nested blocks & double nested blocks.
|
|
166
|
-
// Selection spans all of first heading's children.
|
|
167
|
-
{
|
|
168
|
-
testName: "multipleChildren",
|
|
169
|
-
createSelection: (doc) => TextSelection.create(doc, 16, 78),
|
|
170
|
-
},
|
|
171
|
-
// Selection spans from start of first heading to end of its first child.
|
|
172
|
-
{
|
|
173
|
-
testName: "childToParent",
|
|
174
|
-
createSelection: (doc) => TextSelection.create(doc, 3, 34),
|
|
175
|
-
},
|
|
176
|
-
// Selection spans from middle of first heading to the middle of its first
|
|
177
|
-
// child.
|
|
178
|
-
{
|
|
179
|
-
testName: "partialChildToParent",
|
|
180
|
-
createSelection: (doc) => TextSelection.create(doc, 6, 23),
|
|
181
|
-
},
|
|
182
|
-
// Selection spans from start of first heading's first child to end of
|
|
183
|
-
// second heading's content (does not include second heading's children).
|
|
184
|
-
{
|
|
185
|
-
testName: "childrenToNextParent",
|
|
186
|
-
createSelection: (doc) => TextSelection.create(doc, 16, 93),
|
|
187
|
-
},
|
|
188
|
-
// Selection spans from start of first heading's first child to end of
|
|
189
|
-
// second heading's last child.
|
|
190
|
-
{
|
|
191
|
-
testName: "childrenToNextParentsChildren",
|
|
192
|
-
createSelection: (doc) => TextSelection.create(doc, 16, 159),
|
|
193
|
-
},
|
|
194
|
-
// Selection spans "Regular" text inside third heading.
|
|
195
|
-
{
|
|
196
|
-
testName: "unstyledText",
|
|
197
|
-
createSelection: (doc) => TextSelection.create(doc, 175, 182),
|
|
198
|
-
},
|
|
199
|
-
// Selection spans "Italic" text inside third heading.
|
|
200
|
-
{
|
|
201
|
-
testName: "styledText",
|
|
202
|
-
createSelection: (doc) => TextSelection.create(doc, 169, 175),
|
|
203
|
-
},
|
|
204
|
-
// Selection spans third heading's content (does not include third heading's
|
|
205
|
-
// children).
|
|
206
|
-
{
|
|
207
|
-
testName: "multipleStyledText",
|
|
208
|
-
createSelection: (doc) => TextSelection.create(doc, 165, 182),
|
|
209
|
-
},
|
|
210
|
-
// Selection spans the image block content.
|
|
211
|
-
{
|
|
212
|
-
testName: "image",
|
|
213
|
-
createSelection: (doc) => NodeSelection.create(doc, 185),
|
|
214
|
-
},
|
|
215
|
-
// Selection spans from start of third heading to end of it's last
|
|
216
|
-
// descendant.
|
|
217
|
-
{
|
|
218
|
-
testName: "nestedImage",
|
|
219
|
-
createSelection: (doc) => TextSelection.create(doc, 165, 205),
|
|
220
|
-
},
|
|
221
|
-
// Selection spans text in first cell of the table.
|
|
222
|
-
{
|
|
223
|
-
testName: "tableCellText",
|
|
224
|
-
createSelection: (doc) => TextSelection.create(doc, 216, 226),
|
|
225
|
-
},
|
|
226
|
-
// Selection spans first cell of the table.
|
|
227
|
-
// TODO: External HTML is wrapped in unnecessary `tr` element.
|
|
228
|
-
{
|
|
229
|
-
testName: "tableCell",
|
|
230
|
-
createSelection: (doc) => CellSelection.create(doc, 214),
|
|
231
|
-
},
|
|
232
|
-
// Selection spans first row of the table.
|
|
233
|
-
{
|
|
234
|
-
testName: "tableRow",
|
|
235
|
-
createSelection: (doc) => CellSelection.create(doc, 214, 228),
|
|
236
|
-
},
|
|
237
|
-
// Selection spans all cells of the table.
|
|
238
|
-
{
|
|
239
|
-
testName: "tableAllCells",
|
|
240
|
-
createSelection: (doc) => CellSelection.create(doc, 214, 258),
|
|
241
|
-
},
|
|
242
|
-
];
|
|
243
|
-
for (const testCase of testCases) {
|
|
244
|
-
it(`${testCase.testName}`, async () => {
|
|
245
|
-
await testSelection(testCase);
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
//# sourceMappingURL=clipboard.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clipboard.test.js","sourceRoot":"","sources":["../../../../src/api/clipboard/clipboard.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAa,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAG/E,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAOxE,8EAA8E;AAC9E,gFAAgF;AAChF,6EAA6E;AAC7E,0CAA0C;AAC1C,QAAQ,CAAC,2CAA2C,EAAE,GAAG,EAAE;IACzD,MAAM,cAAc,GAAmB;QACrC;YACE,IAAI,EAAE,SAAS;YACf,KAAK,EAAE;gBACL,KAAK,EAAE,CAAC;gBACR,SAAS,EAAE,KAAK;aACjB;YACD,OAAO,EAAE,WAAW;YACpB,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,WAAW;oBACjB,OAAO,EAAE,oBAAoB;iBAC9B;gBACD;oBACE,IAAI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,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;SAC9D;QACD,2CAA2C;QAC3C,8DAA8D;QAC9D;YACE,QAAQ,EAAE,WAAW;YACrB,eAAe,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC;SACzD;QACD,0CAA0C;QAC1C;YACE,QAAQ,EAAE,UAAU;YACpB,eAAe,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;SAC9D;QACD,0CAA0C;QAC1C;YACE,QAAQ,EAAE,eAAe;YACzB,eAAe,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;SAC9D;KACF,CAAC;IAEF,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,EAAE,CAAC,GAAG,QAAQ,CAAC,QAAQ,EAAE,EAAE,KAAK,IAAI,EAAE;YACpC,MAAM,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"acceptedMIMETypes.js","sourceRoot":"","sources":["../../../../../src/api/clipboard/fromClipboard/acceptedMIMETypes.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,oBAAoB;IACpB,gBAAgB;IAChB,WAAW;IACX,YAAY;IACZ,OAAO;CACC,CAAC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Extension } from "@tiptap/core";
|
|
2
|
-
import { Plugin } from "prosemirror-state";
|
|
3
|
-
import { acceptedMIMETypes } from "./acceptedMIMETypes.js";
|
|
4
|
-
import { handleFileInsertion } from "./handleFileInsertion.js";
|
|
5
|
-
export const createDropFileExtension = (editor) => Extension.create({
|
|
6
|
-
name: "dropFile",
|
|
7
|
-
addProseMirrorPlugins() {
|
|
8
|
-
return [
|
|
9
|
-
new Plugin({
|
|
10
|
-
props: {
|
|
11
|
-
handleDOMEvents: {
|
|
12
|
-
drop(_view, event) {
|
|
13
|
-
if (!editor.isEditable) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
let format = null;
|
|
17
|
-
for (const mimeType of acceptedMIMETypes) {
|
|
18
|
-
if (event.dataTransfer.types.includes(mimeType)) {
|
|
19
|
-
format = mimeType;
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
if (format === null) {
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
if (format === "Files") {
|
|
27
|
-
handleFileInsertion(event, editor);
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
return false;
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
}),
|
|
35
|
-
];
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
//# sourceMappingURL=fileDropExtension.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fileDropExtension.js","sourceRoot":"","sources":["../../../../../src/api/clipboard/fromClipboard/fileDropExtension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAQ3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAKrC,MAAsC,EACtC,EAAE,CACF,SAAS,CAAC,MAAM,CAAwD;IACtE,IAAI,EAAE,UAAU;IAChB,qBAAqB;QACnB,OAAO;YACL,IAAI,MAAM,CAAC;gBACT,KAAK,EAAE;oBACL,eAAe,EAAE;wBACf,IAAI,CAAC,KAAK,EAAE,KAAK;4BACf,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;gCACvB,OAAO;4BACT,CAAC;4BAED,IAAI,MAAM,GAA8C,IAAI,CAAC;4BAC7D,KAAK,MAAM,QAAQ,IAAI,iBAAiB,EAAE,CAAC;gCACzC,IAAI,KAAK,CAAC,YAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;oCACjD,MAAM,GAAG,QAAQ,CAAC;oCAClB,MAAM;gCACR,CAAC;4BACH,CAAC;4BACD,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;gCACpB,OAAO,IAAI,CAAC;4BACd,CAAC;4BAED,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;gCACvB,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;gCACnC,OAAO,IAAI,CAAC;4BACd,CAAC;4BAED,OAAO,KAAK,CAAC;wBACf,CAAC;qBACF;iBACF;aACF,CAAC;SACH,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { getBlockInfo, getNearestBlockPos } from "../../getBlockInfoFromPos.js";
|
|
2
|
-
import { acceptedMIMETypes } from "./acceptedMIMETypes.js";
|
|
3
|
-
function checkFileExtensionsMatch(fileExtension1, fileExtension2) {
|
|
4
|
-
if (!fileExtension1.startsWith(".") || !fileExtension2.startsWith(".")) {
|
|
5
|
-
throw new Error(`The strings provided are not valid file extensions.`);
|
|
6
|
-
}
|
|
7
|
-
return fileExtension1 === fileExtension2;
|
|
8
|
-
}
|
|
9
|
-
function checkMIMETypesMatch(mimeType1, mimeType2) {
|
|
10
|
-
const types1 = mimeType1.split("/");
|
|
11
|
-
const types2 = mimeType2.split("/");
|
|
12
|
-
if (types1.length !== 2) {
|
|
13
|
-
throw new Error(`The string ${mimeType1} is not a valid MIME type.`);
|
|
14
|
-
}
|
|
15
|
-
if (types2.length !== 2) {
|
|
16
|
-
throw new Error(`The string ${mimeType2} is not a valid MIME type.`);
|
|
17
|
-
}
|
|
18
|
-
if (types1[1] === "*" || types2[1] === "*") {
|
|
19
|
-
return types1[0] === types2[0];
|
|
20
|
-
}
|
|
21
|
-
if (types1[0] === "*" || types2[0] === "*") {
|
|
22
|
-
return types1[1] === types2[1];
|
|
23
|
-
}
|
|
24
|
-
return types1[0] === types2[0] && types1[1] === types2[1];
|
|
25
|
-
}
|
|
26
|
-
export async function handleFileInsertion(event, editor) {
|
|
27
|
-
if (!editor.uploadFile) {
|
|
28
|
-
// eslint-disable-next-line no-console
|
|
29
|
-
console.warn("Attempted ot insert file, but uploadFile is not set in the BlockNote editor options");
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const dataTransfer = "dataTransfer" in event ? event.dataTransfer : event.clipboardData;
|
|
33
|
-
if (dataTransfer === null) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
let format = null;
|
|
37
|
-
for (const mimeType of acceptedMIMETypes) {
|
|
38
|
-
if (dataTransfer.types.includes(mimeType)) {
|
|
39
|
-
format = mimeType;
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
if (format !== "Files") {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const items = dataTransfer.items;
|
|
47
|
-
if (!items) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
event.preventDefault();
|
|
51
|
-
const fileBlockConfigs = Object.values(editor.schema.blockSchema).filter((blockConfig) => blockConfig.isFileBlock);
|
|
52
|
-
for (let i = 0; i < items.length; i++) {
|
|
53
|
-
// Gets file block corresponding to MIME type.
|
|
54
|
-
let fileBlockType = "file";
|
|
55
|
-
for (const fileBlockConfig of fileBlockConfigs) {
|
|
56
|
-
for (const mimeType of fileBlockConfig.fileBlockAccept || []) {
|
|
57
|
-
const isFileExtension = mimeType.startsWith(".");
|
|
58
|
-
const file = items[i].getAsFile();
|
|
59
|
-
if (file) {
|
|
60
|
-
if ((!isFileExtension &&
|
|
61
|
-
file.type &&
|
|
62
|
-
checkMIMETypesMatch(items[i].type, mimeType)) ||
|
|
63
|
-
(isFileExtension &&
|
|
64
|
-
checkFileExtensionsMatch("." + file.name.split(".").pop(), mimeType))) {
|
|
65
|
-
fileBlockType = fileBlockConfig.type;
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
const file = items[i].getAsFile();
|
|
72
|
-
if (file) {
|
|
73
|
-
const fileBlock = {
|
|
74
|
-
type: fileBlockType,
|
|
75
|
-
props: {
|
|
76
|
-
name: file.name,
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
let insertedBlockId = undefined;
|
|
80
|
-
if (event.type === "paste") {
|
|
81
|
-
insertedBlockId = editor.insertBlocks([fileBlock], editor.getTextCursorPosition().block, "after")[0].id;
|
|
82
|
-
}
|
|
83
|
-
else if (event.type === "drop") {
|
|
84
|
-
const coords = {
|
|
85
|
-
left: event.clientX,
|
|
86
|
-
top: event.clientY,
|
|
87
|
-
};
|
|
88
|
-
const pos = editor.prosemirrorView?.posAtCoords(coords);
|
|
89
|
-
if (!pos) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
const posInfo = getNearestBlockPos(editor._tiptapEditor.state.doc, pos.pos);
|
|
93
|
-
const blockInfo = getBlockInfo(posInfo);
|
|
94
|
-
insertedBlockId = editor.insertBlocks([fileBlock], blockInfo.bnBlock.node.attrs.id, "after")[0].id;
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
const updateData = await editor.uploadFile(file, insertedBlockId);
|
|
100
|
-
const updatedFileBlock = typeof updateData === "string"
|
|
101
|
-
? {
|
|
102
|
-
props: {
|
|
103
|
-
url: updateData,
|
|
104
|
-
},
|
|
105
|
-
}
|
|
106
|
-
: { ...updateData };
|
|
107
|
-
editor.updateBlock(insertedBlockId, updatedFileBlock);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
//# sourceMappingURL=handleFileInsertion.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handleFileInsertion.js","sourceRoot":"","sources":["../../../../../src/api/clipboard/fromClipboard/handleFileInsertion.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,SAAS,wBAAwB,CAC/B,cAAsB,EACtB,cAAsB;IAEtB,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACvE,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IAED,OAAO,cAAc,KAAK,cAAc,CAAC;AAC3C,CAAC;AAED,SAAS,mBAAmB,CAAC,SAAiB,EAAE,SAAiB;IAC/D,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAEpC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,cAAc,SAAS,4BAA4B,CAAC,CAAC;IACvE,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,cAAc,SAAS,4BAA4B,CAAC,CAAC;IACvE,CAAC;IAED,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QAC3C,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC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,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export async function handleVSCodePaste(event, view) {
|
|
2
|
-
const { schema } = view.state;
|
|
3
|
-
if (!event.clipboardData) {
|
|
4
|
-
return false;
|
|
5
|
-
}
|
|
6
|
-
const text = event.clipboardData.getData("text/plain");
|
|
7
|
-
if (!text) {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
if (!schema.nodes.codeBlock) {
|
|
11
|
-
view.pasteText(text);
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
const vscode = event.clipboardData.getData("vscode-editor-data");
|
|
15
|
-
const vscodeData = vscode ? JSON.parse(vscode) : undefined;
|
|
16
|
-
const language = vscodeData?.mode;
|
|
17
|
-
if (!language) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
// strip carriage return chars from text pasted as code
|
|
21
|
-
// see: https://github.com/ProseMirror/prosemirror-view/commit/a50a6bcceb4ce52ac8fcc6162488d8875613aacd
|
|
22
|
-
view.pasteHTML(`<pre><code class="language-${language}">${text.replace(/\r\n?/g, "\n")}</code></pre>`);
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=handleVSCodePaste.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handleVSCodePaste.js","sourceRoot":"","sources":["../../../../../src/api/clipboard/fromClipboard/handleVSCodePaste.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,KAAqB,EACrB,IAAgB;IAEhB,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;IAE9B,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,IAAI,GAAG,KAAK,CAAC,aAAc,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAExD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;QAC5B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,MAAM,GAAG,KAAK,CAAC,aAAc,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAClE,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3D,MAAM,QAAQ,GAAG,UAAU,EAAE,IAAI,CAAC;IAElC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,KAAK,CAAC;IACf,CAAC;IAED,uDAAuD;IACvD,uGAAuG;IACvG,IAAI,CAAC,SAAS,CACZ,8BAA8B,QAAQ,KAAK,IAAI,CAAC,OAAO,CACrD,QAAQ,EACR,IAAI,CACL,eAAe,CACjB,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { Extension } from "@tiptap/core";
|
|
2
|
-
import { Plugin } from "prosemirror-state";
|
|
3
|
-
import { nestedListsToBlockNoteStructure } from "../../parsers/html/util/nestedLists.js";
|
|
4
|
-
import { acceptedMIMETypes } from "./acceptedMIMETypes.js";
|
|
5
|
-
import { handleFileInsertion } from "./handleFileInsertion.js";
|
|
6
|
-
import { handleVSCodePaste } from "./handleVSCodePaste.js";
|
|
7
|
-
export const createPasteFromClipboardExtension = (editor) => Extension.create({
|
|
8
|
-
name: "pasteFromClipboard",
|
|
9
|
-
addProseMirrorPlugins() {
|
|
10
|
-
return [
|
|
11
|
-
new Plugin({
|
|
12
|
-
props: {
|
|
13
|
-
handleDOMEvents: {
|
|
14
|
-
paste(view, event) {
|
|
15
|
-
event.preventDefault();
|
|
16
|
-
if (!editor.isEditable) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
let format;
|
|
20
|
-
for (const mimeType of acceptedMIMETypes) {
|
|
21
|
-
if (event.clipboardData.types.includes(mimeType)) {
|
|
22
|
-
format = mimeType;
|
|
23
|
-
break;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (!format) {
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
if (format === "vscode-editor-data") {
|
|
30
|
-
handleVSCodePaste(event, view);
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
if (format === "Files") {
|
|
34
|
-
handleFileInsertion(event, editor);
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
let data = event.clipboardData.getData(format);
|
|
38
|
-
if (format === "blocknote/html") {
|
|
39
|
-
view.pasteHTML(data);
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
if (format === "text/html") {
|
|
43
|
-
const htmlNode = nestedListsToBlockNoteStructure(data.trim());
|
|
44
|
-
data = htmlNode.innerHTML;
|
|
45
|
-
view.pasteHTML(data);
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
view.pasteText(data);
|
|
49
|
-
return true;
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
}),
|
|
54
|
-
];
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
//# sourceMappingURL=pasteExtension.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pasteExtension.js","sourceRoot":"","sources":["../../../../../src/api/clipboard/fromClipboard/pasteExtension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAQ3C,OAAO,EAAE,+BAA+B,EAAE,MAAM,wCAAwC,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3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