@blocknote/core 0.21.0 → 0.23.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 +2320 -1692
- 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/basicBlocks.html +1 -0
- package/src/api/clipboard/__snapshots__/internal/basicBlocksWithProps.html +1 -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} +186 -38
- package/src/api/clipboard/testUtil.ts +27 -0
- package/src/api/clipboard/toClipboard/copyExtension.ts +1 -0
- package/src/api/exporters/html/__snapshots__/pageBreak/basic/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/pageBreak/basic/internal.html +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/exporters/markdown/__snapshots__/pageBreak/basic/markdown.md +0 -0
- package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +16 -0
- package/src/api/nodeConversions/nodeToBlock.ts +4 -1
- package/src/api/parsers/html/__snapshots__/parse-codeblocks.json +62 -0
- package/src/api/parsers/html/parseHTML.test.ts +9 -0
- package/src/api/parsers/markdown/__snapshots__/pasted/styled.json +2 -2
- package/src/api/testUtil/cases/defaultSchema.ts +15 -1
- package/src/api/testUtil/partialBlockTestUtil.ts +4 -1
- package/src/blocks/CodeBlockContent/CodeBlockContent.ts +32 -11
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +3 -28
- package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +1 -1
- package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +4 -16
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +11 -3
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +26 -6
- package/src/blocks/PageBreakBlockContent/PageBreakBlockContent.ts +49 -0
- package/src/blocks/PageBreakBlockContent/getPageBreakSlashMenuItems.ts +45 -0
- package/src/blocks/PageBreakBlockContent/schema.ts +40 -0
- package/src/editor/Block.css +18 -4
- package/src/editor/BlockNoteEditor.test.ts +21 -1
- package/src/editor/BlockNoteEditor.ts +17 -0
- package/src/editor/BlockNoteExtensions.ts +111 -16
- package/src/editor/editor.css +28 -13
- package/src/editor/transformPasted.ts +57 -4
- package/src/extensions/SideMenu/SideMenuPlugin.ts +115 -23
- package/src/extensions/SideMenu/dragging.ts +0 -1
- package/src/extensions/SuggestionMenu/DefaultSuggestionItem.ts +1 -1
- package/src/i18n/locales/ar.ts +6 -0
- package/src/i18n/locales/de.ts +6 -0
- package/src/i18n/locales/en.ts +6 -0
- package/src/i18n/locales/es.ts +6 -0
- package/src/i18n/locales/fr.ts +47 -17
- package/src/i18n/locales/hr.ts +72 -54
- package/src/i18n/locales/index.ts +1 -0
- package/src/i18n/locales/is.ts +6 -0
- package/src/i18n/locales/it.ts +315 -0
- package/src/i18n/locales/ja.ts +6 -0
- package/src/i18n/locales/ko.ts +6 -0
- package/src/i18n/locales/nl.ts +6 -0
- package/src/i18n/locales/pl.ts +6 -0
- package/src/i18n/locales/pt.ts +6 -0
- package/src/i18n/locales/ru.ts +6 -0
- package/src/i18n/locales/vi.ts +6 -0
- package/src/i18n/locales/zh.ts +6 -0
- package/src/index.ts +3 -0
- 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/api/testUtil/cases/defaultSchema.d.ts +2 -1
- package/types/src/blocks/CodeBlockContent/CodeBlockContent.d.ts +2 -0
- package/types/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +12 -0
- package/types/src/blocks/PageBreakBlockContent/PageBreakBlockContent.d.ts +31 -0
- package/types/src/blocks/PageBreakBlockContent/getPageBreakSlashMenuItems.d.ts +8 -0
- package/types/src/blocks/PageBreakBlockContent/schema.d.ts +86 -0
- package/types/src/blocks/defaultBlocks.d.ts +16 -0
- package/types/src/editor/BlockNoteEditor.d.ts +15 -0
- package/types/src/editor/BlockNoteExtensions.d.ts +2 -0
- package/types/src/editor/transformPasted.d.ts +8 -4
- package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +25 -5
- package/types/src/extensions/SuggestionMenu/DefaultSuggestionItem.d.ts +1 -1
- package/types/src/i18n/locales/de.d.ts +6 -0
- package/types/src/i18n/locales/en.d.ts +6 -0
- package/types/src/i18n/locales/es.d.ts +6 -0
- package/types/src/i18n/locales/hr.d.ts +6 -0
- package/types/src/i18n/locales/index.d.ts +1 -0
- package/types/src/i18n/locales/it.d.ts +245 -0
- package/types/src/index.d.ts +3 -0
- 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
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"children": [],
|
|
4
|
+
"content": [
|
|
5
|
+
{
|
|
6
|
+
"styles": {},
|
|
7
|
+
"text": "Paragraph",
|
|
8
|
+
"type": "text",
|
|
9
|
+
},
|
|
10
|
+
],
|
|
11
|
+
"id": "0",
|
|
12
|
+
"props": {
|
|
13
|
+
"backgroundColor": "default",
|
|
14
|
+
"textAlignment": "left",
|
|
15
|
+
"textColor": "default",
|
|
16
|
+
},
|
|
17
|
+
"type": "paragraph",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"children": [],
|
|
21
|
+
"content": {
|
|
22
|
+
"columnWidths": [
|
|
23
|
+
undefined,
|
|
24
|
+
undefined,
|
|
25
|
+
undefined,
|
|
26
|
+
],
|
|
27
|
+
"rows": [
|
|
28
|
+
{
|
|
29
|
+
"cells": [
|
|
30
|
+
[
|
|
31
|
+
{
|
|
32
|
+
"styles": {},
|
|
33
|
+
"text": "Table Cell",
|
|
34
|
+
"type": "text",
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
[
|
|
38
|
+
{
|
|
39
|
+
"styles": {},
|
|
40
|
+
"text": "Table Cell",
|
|
41
|
+
"type": "text",
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
[],
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"cells": [
|
|
49
|
+
[
|
|
50
|
+
{
|
|
51
|
+
"styles": {},
|
|
52
|
+
"text": "Table Cell",
|
|
53
|
+
"type": "text",
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
[
|
|
57
|
+
{
|
|
58
|
+
"styles": {},
|
|
59
|
+
"text": "Cell 1",
|
|
60
|
+
"type": "text",
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
[
|
|
64
|
+
{
|
|
65
|
+
"styles": {},
|
|
66
|
+
"text": "Cell 2",
|
|
67
|
+
"type": "text",
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"cells": [
|
|
74
|
+
[],
|
|
75
|
+
[
|
|
76
|
+
{
|
|
77
|
+
"styles": {},
|
|
78
|
+
"text": "Cell 3",
|
|
79
|
+
"type": "text",
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
[
|
|
83
|
+
{
|
|
84
|
+
"styles": {},
|
|
85
|
+
"text": "Cell 4",
|
|
86
|
+
"type": "text",
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
"type": "tableContent",
|
|
93
|
+
},
|
|
94
|
+
"id": "1",
|
|
95
|
+
"props": {
|
|
96
|
+
"textColor": "default",
|
|
97
|
+
},
|
|
98
|
+
"type": "table",
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"children": [],
|
|
102
|
+
"content": [
|
|
103
|
+
{
|
|
104
|
+
"styles": {},
|
|
105
|
+
"text": "Custom Paragraph",
|
|
106
|
+
"type": "text",
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
"id": "2",
|
|
110
|
+
"props": {},
|
|
111
|
+
"type": "customParagraph",
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"children": [],
|
|
115
|
+
"content": [],
|
|
116
|
+
"id": "3",
|
|
117
|
+
"props": {
|
|
118
|
+
"backgroundColor": "default",
|
|
119
|
+
"textAlignment": "left",
|
|
120
|
+
"textColor": "default",
|
|
121
|
+
},
|
|
122
|
+
"type": "paragraph",
|
|
123
|
+
},
|
|
124
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<p>Paragraph</p><h1>Heading</h1><ol><li><p>Numbered List Item</p></li></ol><ul><li><p>Bullet List Item</p></li><li><input type="checkbox"><p class="bn-inline-content">Check List Item</p></li></ul><pre><code class="bn-inline-content language-javascript">console.log("Hello World");</code></pre><table><tr><td colspan="1" rowspan="1"><p>Table Cell</p></td><td colspan="1" rowspan="1"><p>Table Cell</p></td><td colspan="1" rowspan="1"><p>Table Cell</p></td></tr><tr><td colspan="1" rowspan="1"><p>Table Cell</p></td><td colspan="1" rowspan="1"><p>Table Cell</p></td><td colspan="1" rowspan="1"><p>Table Cell</p></td></tr><tr><td colspan="1" rowspan="1"><p>Table Cell</p></td><td colspan="1" rowspan="1"><p>Table Cell</p></td><td colspan="1" rowspan="1"><p>Table Cell</p></td></tr></table><p>Add image</p><p data-text-color="red"></p>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<p data-text-color="red">Paragraph</p><h2 data-level="2">Heading</h2><ol start="2"><li><p data-start="2">Numbered List Item</p></li></ol><ul><li><p data-background-color="red">Bullet List Item</p></li><li><input type="checkbox" checked="" data-checked="true"><p class="bn-inline-content">Check List Item</p></li></ul><pre><code class="bn-inline-content language-typescript">console.log("Hello World");</code></pre><table><tr><td colspan="1" rowspan="1"><p>Table Cell</p></td><td colspan="1" rowspan="1"><p>Table Cell</p></td><td colspan="1" rowspan="1"><p>Table Cell</p></td></tr><tr><td colspan="1" rowspan="1"><p>Table Cell</p></td><td colspan="1" rowspan="1"><p>Table Cell</p></td><td colspan="1" rowspan="1"><p>Table Cell</p></td></tr><tr><td colspan="1" rowspan="1"><p>Table Cell</p></td><td colspan="1" rowspan="1"><p>Table Cell</p></td><td colspan="1" rowspan="1"><p>Table Cell</p></td></tr></table><figure data-name="1280px-Placeholder_view_vector.svg.png" data-url="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3f/Placeholder_view_vector.svg/1280px-Placeholder_view_vector.svg.png" data-caption="Placeholder" data-preview-width="256"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3f/Placeholder_view_vector.svg/1280px-Placeholder_view_vector.svg.png" alt="1280px-Placeholder_view_vector.svg.png" width="256"><figcaption>Placeholder</figcaption></figure><p></p>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Paragraph
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { Node } from "prosemirror-model";
|
|
2
|
+
import { Selection, TextSelection } from "prosemirror-state";
|
|
3
|
+
import { afterAll, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
|
4
|
+
|
|
5
|
+
import { PartialBlock } from "../../blocks/defaultBlocks.js";
|
|
6
|
+
import { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
|
|
7
|
+
import { initializeESMDependencies } from "../../util/esmDependencies.js";
|
|
8
|
+
import { doPaste } from "../testUtil/paste.js";
|
|
9
|
+
import { schema } from "./testUtil.js";
|
|
10
|
+
|
|
11
|
+
type SelectionTestCase = {
|
|
12
|
+
testName: string;
|
|
13
|
+
createSelection: (doc: Node) => Selection;
|
|
14
|
+
} & (
|
|
15
|
+
| {
|
|
16
|
+
html: string;
|
|
17
|
+
}
|
|
18
|
+
| {
|
|
19
|
+
plainText: string;
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
// These tests are meant to test the pasting of external HTML in the editor.
|
|
24
|
+
// Each test case has an HTML string to be pasted, and a selection in the editor
|
|
25
|
+
// to paste at.
|
|
26
|
+
describe("Test external clipboard HTML", () => {
|
|
27
|
+
const initialContent: PartialBlock<typeof schema.blockSchema>[] = [
|
|
28
|
+
{
|
|
29
|
+
type: "paragraph",
|
|
30
|
+
content: "Paragraph",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
type: "table",
|
|
34
|
+
content: {
|
|
35
|
+
type: "tableContent",
|
|
36
|
+
rows: [
|
|
37
|
+
{
|
|
38
|
+
cells: ["Table Cell", "Table Cell"],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
cells: ["Table Cell", "Table Cell"],
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: "customParagraph",
|
|
48
|
+
content: "Custom Paragraph",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: "paragraph",
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
let editor: BlockNoteEditor<typeof schema.blockSchema>;
|
|
56
|
+
const div = document.createElement("div");
|
|
57
|
+
|
|
58
|
+
beforeEach(() => {
|
|
59
|
+
editor.replaceBlocks(editor.document, initialContent);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
beforeAll(async () => {
|
|
63
|
+
(window as any).__TEST_OPTIONS = (window as any).__TEST_OPTIONS || {};
|
|
64
|
+
|
|
65
|
+
editor = BlockNoteEditor.create({ schema });
|
|
66
|
+
editor.mount(div);
|
|
67
|
+
|
|
68
|
+
await initializeESMDependencies();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
afterAll(() => {
|
|
72
|
+
editor.mount(undefined);
|
|
73
|
+
editor._tiptapEditor.destroy();
|
|
74
|
+
editor = undefined as any;
|
|
75
|
+
|
|
76
|
+
delete (window as Window & { __TEST_OPTIONS?: any }).__TEST_OPTIONS;
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Sets the editor selection to the given start and end positions, then
|
|
80
|
+
// pastes the HTML and compares it the document after to a snapshot.
|
|
81
|
+
async function testPasteExternalHTML(testCase: SelectionTestCase) {
|
|
82
|
+
if (!editor.prosemirrorView) {
|
|
83
|
+
throw new Error("Editor view not initialized.");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
editor.dispatch(
|
|
87
|
+
editor._tiptapEditor.state.tr.setSelection(
|
|
88
|
+
testCase.createSelection(editor.prosemirrorView.state.doc)
|
|
89
|
+
)
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
doPaste(
|
|
93
|
+
editor.prosemirrorView,
|
|
94
|
+
"plainText" in testCase ? testCase.plainText : "",
|
|
95
|
+
"html" in testCase ? testCase.html : "",
|
|
96
|
+
"plainText" in testCase,
|
|
97
|
+
new ClipboardEvent("paste")
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
expect(editor.document).toMatchFileSnapshot(
|
|
101
|
+
`./__snapshots__/external/${testCase.testName}.html`
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const testCases: SelectionTestCase[] = [
|
|
106
|
+
{
|
|
107
|
+
testName: "pasteEndOfParagraph",
|
|
108
|
+
createSelection: (doc) => TextSelection.create(doc, 12),
|
|
109
|
+
html: `<p>Paragraph</p>`,
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
testName: "pasteEndOfParagraphText",
|
|
113
|
+
createSelection: (doc) => TextSelection.create(doc, 12),
|
|
114
|
+
plainText: `Paragraph`,
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
testName: "pasteImage",
|
|
118
|
+
createSelection: (doc) => TextSelection.create(doc, 12),
|
|
119
|
+
html: `<img src="exampleURL">`,
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
testName: "pasteTable",
|
|
123
|
+
createSelection: (doc) => TextSelection.create(doc, 12),
|
|
124
|
+
html: `<table>
|
|
125
|
+
<tr>
|
|
126
|
+
<td>Cell 1</td>
|
|
127
|
+
<td>Cell 2</td>
|
|
128
|
+
</tr>
|
|
129
|
+
<tr>
|
|
130
|
+
<td>Cell 3</td>
|
|
131
|
+
<td>Cell 4</td>
|
|
132
|
+
</tr>
|
|
133
|
+
</table>`,
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
testName: "pasteTableInExistingTable",
|
|
137
|
+
createSelection: (doc) => TextSelection.create(doc, 73),
|
|
138
|
+
html: `<table>
|
|
139
|
+
<tr>
|
|
140
|
+
<td>Cell 1</td>
|
|
141
|
+
<td>Cell 2</td>
|
|
142
|
+
</tr>
|
|
143
|
+
<tr>
|
|
144
|
+
<td>Cell 3</td>
|
|
145
|
+
<td>Cell 4</td>
|
|
146
|
+
</tr>
|
|
147
|
+
</table>`,
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
testName: "pasteParagraphInCustomBlock",
|
|
151
|
+
createSelection: (doc) => TextSelection.create(doc, 80, 96),
|
|
152
|
+
html: `<p>Paragraph</p>`,
|
|
153
|
+
},
|
|
154
|
+
];
|
|
155
|
+
|
|
156
|
+
for (const testCase of testCases) {
|
|
157
|
+
it(`${testCase.testName}`, async () => {
|
|
158
|
+
await testPasteExternalHTML(testCase);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
});
|
|
@@ -7,11 +7,13 @@ import { PartialBlock } from "../../blocks/defaultBlocks.js";
|
|
|
7
7
|
import { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
|
|
8
8
|
import { initializeESMDependencies } from "../../util/esmDependencies.js";
|
|
9
9
|
import { doPaste } from "../testUtil/paste.js";
|
|
10
|
+
import { schema } from "./testUtil.js";
|
|
10
11
|
import { selectedFragmentToHTML } from "./toClipboard/copyExtension.js";
|
|
11
12
|
|
|
12
13
|
type SelectionTestCase = {
|
|
13
14
|
testName: string;
|
|
14
|
-
|
|
15
|
+
createCopySelection: (doc: Node) => Selection;
|
|
16
|
+
createPasteSelection?: (doc: Node) => Selection;
|
|
15
17
|
};
|
|
16
18
|
|
|
17
19
|
// These tests are meant to test the copying of user selections in the editor.
|
|
@@ -19,7 +21,7 @@ type SelectionTestCase = {
|
|
|
19
21
|
// as they are represented in the BlockNote API, whereas here we want to test
|
|
20
22
|
// ProseMirror/TipTap selections directly.
|
|
21
23
|
describe("Test ProseMirror selection clipboard HTML", () => {
|
|
22
|
-
const initialContent: PartialBlock[] = [
|
|
24
|
+
const initialContent: PartialBlock<typeof schema.blockSchema>[] = [
|
|
23
25
|
{
|
|
24
26
|
type: "heading",
|
|
25
27
|
props: {
|
|
@@ -138,9 +140,133 @@ describe("Test ProseMirror selection clipboard HTML", () => {
|
|
|
138
140
|
// },
|
|
139
141
|
// ],
|
|
140
142
|
},
|
|
143
|
+
{
|
|
144
|
+
type: "paragraph",
|
|
145
|
+
content: "Paragraph",
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
type: "customParagraph",
|
|
149
|
+
content: "Paragraph",
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
type: "paragraph",
|
|
153
|
+
content: "Paragraph",
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
type: "heading",
|
|
157
|
+
content: "Heading",
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
type: "numberedListItem",
|
|
161
|
+
content: "Numbered List Item",
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
type: "bulletListItem",
|
|
165
|
+
content: "Bullet List Item",
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
type: "checkListItem",
|
|
169
|
+
content: "Check List Item",
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
type: "codeBlock",
|
|
173
|
+
content: 'console.log("Hello World");',
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
type: "table",
|
|
177
|
+
content: {
|
|
178
|
+
type: "tableContent",
|
|
179
|
+
rows: [
|
|
180
|
+
{
|
|
181
|
+
cells: [["Table Cell"], ["Table Cell"], ["Table Cell"]],
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
cells: [["Table Cell"], ["Table Cell"], ["Table Cell"]],
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
cells: [["Table Cell"], ["Table Cell"], ["Table Cell"]],
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
type: "image",
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
type: "paragraph",
|
|
197
|
+
props: {
|
|
198
|
+
textColor: "red",
|
|
199
|
+
},
|
|
200
|
+
content: "Paragraph",
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
type: "heading",
|
|
204
|
+
props: {
|
|
205
|
+
level: 2,
|
|
206
|
+
},
|
|
207
|
+
content: "Heading",
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
type: "numberedListItem",
|
|
211
|
+
props: {
|
|
212
|
+
start: 2,
|
|
213
|
+
},
|
|
214
|
+
content: "Numbered List Item",
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
type: "bulletListItem",
|
|
218
|
+
props: {
|
|
219
|
+
backgroundColor: "red",
|
|
220
|
+
},
|
|
221
|
+
content: "Bullet List Item",
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
type: "checkListItem",
|
|
225
|
+
props: {
|
|
226
|
+
checked: true,
|
|
227
|
+
},
|
|
228
|
+
content: "Check List Item",
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
type: "codeBlock",
|
|
232
|
+
props: {
|
|
233
|
+
language: "typescript",
|
|
234
|
+
},
|
|
235
|
+
content: 'console.log("Hello World");',
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
type: "table",
|
|
239
|
+
content: {
|
|
240
|
+
type: "tableContent",
|
|
241
|
+
rows: [
|
|
242
|
+
{
|
|
243
|
+
cells: [["Table Cell"], ["Table Cell"], ["Table Cell"]],
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
cells: [["Table Cell"], ["Table Cell"], ["Table Cell"]],
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
cells: [["Table Cell"], ["Table Cell"], ["Table Cell"]],
|
|
250
|
+
},
|
|
251
|
+
],
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
type: "image",
|
|
256
|
+
props: {
|
|
257
|
+
name: "1280px-Placeholder_view_vector.svg.png",
|
|
258
|
+
url: "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3f/Placeholder_view_vector.svg/1280px-Placeholder_view_vector.svg.png",
|
|
259
|
+
caption: "Placeholder",
|
|
260
|
+
showPreview: true,
|
|
261
|
+
previewWidth: 256,
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
type: "paragraph",
|
|
266
|
+
},
|
|
141
267
|
];
|
|
142
268
|
|
|
143
|
-
let editor: BlockNoteEditor
|
|
269
|
+
let editor: BlockNoteEditor<typeof schema.blockSchema>;
|
|
144
270
|
const div = document.createElement("div");
|
|
145
271
|
|
|
146
272
|
beforeEach(() => {
|
|
@@ -150,7 +276,7 @@ describe("Test ProseMirror selection clipboard HTML", () => {
|
|
|
150
276
|
beforeAll(async () => {
|
|
151
277
|
(window as any).__TEST_OPTIONS = (window as any).__TEST_OPTIONS || {};
|
|
152
278
|
|
|
153
|
-
editor = BlockNoteEditor.create();
|
|
279
|
+
editor = BlockNoteEditor.create({ schema });
|
|
154
280
|
editor.mount(div);
|
|
155
281
|
|
|
156
282
|
await initializeESMDependencies();
|
|
@@ -173,7 +299,7 @@ describe("Test ProseMirror selection clipboard HTML", () => {
|
|
|
173
299
|
|
|
174
300
|
editor.dispatch(
|
|
175
301
|
editor._tiptapEditor.state.tr.setSelection(
|
|
176
|
-
testCase.
|
|
302
|
+
testCase.createCopySelection(editor.prosemirrorView.state.doc)
|
|
177
303
|
)
|
|
178
304
|
);
|
|
179
305
|
|
|
@@ -183,9 +309,17 @@ describe("Test ProseMirror selection clipboard HTML", () => {
|
|
|
183
309
|
);
|
|
184
310
|
|
|
185
311
|
expect(externalHTML).toMatchFileSnapshot(
|
|
186
|
-
`./__snapshots__/${testCase.testName}.html`
|
|
312
|
+
`./__snapshots__/internal/${testCase.testName}.html`
|
|
187
313
|
);
|
|
188
314
|
|
|
315
|
+
if (testCase.createPasteSelection) {
|
|
316
|
+
editor.dispatch(
|
|
317
|
+
editor._tiptapEditor.state.tr.setSelection(
|
|
318
|
+
testCase.createPasteSelection(editor.prosemirrorView.state.doc)
|
|
319
|
+
)
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
|
|
189
323
|
const originalDocument = editor.document;
|
|
190
324
|
doPaste(
|
|
191
325
|
editor.prosemirrorView,
|
|
@@ -201,81 +335,95 @@ describe("Test ProseMirror selection clipboard HTML", () => {
|
|
|
201
335
|
|
|
202
336
|
const testCases: SelectionTestCase[] = [
|
|
203
337
|
// TODO: Consider adding test cases for nested blocks & double nested blocks.
|
|
204
|
-
//
|
|
338
|
+
// Copy/paste all of first heading's children.
|
|
205
339
|
{
|
|
206
340
|
testName: "multipleChildren",
|
|
207
|
-
|
|
341
|
+
createCopySelection: (doc) => TextSelection.create(doc, 16, 78),
|
|
208
342
|
},
|
|
209
|
-
//
|
|
343
|
+
// Copy/paste from start of first heading to end of its first child.
|
|
210
344
|
{
|
|
211
345
|
testName: "childToParent",
|
|
212
|
-
|
|
346
|
+
createCopySelection: (doc) => TextSelection.create(doc, 3, 34),
|
|
213
347
|
},
|
|
214
|
-
//
|
|
215
|
-
// child.
|
|
348
|
+
// Copy/paste from middle of first heading to the middle of its first child.
|
|
216
349
|
{
|
|
217
350
|
testName: "partialChildToParent",
|
|
218
|
-
|
|
351
|
+
createCopySelection: (doc) => TextSelection.create(doc, 6, 23),
|
|
219
352
|
},
|
|
220
|
-
//
|
|
221
|
-
//
|
|
353
|
+
// Copy/paste from start of first heading's first child to end of second
|
|
354
|
+
// heading's content (does not include second heading's children).
|
|
222
355
|
{
|
|
223
356
|
testName: "childrenToNextParent",
|
|
224
|
-
|
|
357
|
+
createCopySelection: (doc) => TextSelection.create(doc, 16, 93),
|
|
225
358
|
},
|
|
226
|
-
//
|
|
227
|
-
//
|
|
359
|
+
// Copy/paste from start of first heading's first child to end of second
|
|
360
|
+
// heading's last child.
|
|
228
361
|
{
|
|
229
362
|
testName: "childrenToNextParentsChildren",
|
|
230
|
-
|
|
363
|
+
createCopySelection: (doc) => TextSelection.create(doc, 16, 159),
|
|
231
364
|
},
|
|
232
|
-
//
|
|
365
|
+
// Copy/paste "Regular" text inside third heading.
|
|
233
366
|
{
|
|
234
367
|
testName: "unstyledText",
|
|
235
|
-
|
|
368
|
+
createCopySelection: (doc) => TextSelection.create(doc, 175, 182),
|
|
236
369
|
},
|
|
237
|
-
//
|
|
370
|
+
// Copy/paste "Italic" text inside third heading.
|
|
238
371
|
{
|
|
239
372
|
testName: "styledText",
|
|
240
|
-
|
|
373
|
+
createCopySelection: (doc) => TextSelection.create(doc, 169, 175),
|
|
241
374
|
},
|
|
242
|
-
//
|
|
375
|
+
// Copy/paste third heading's content (does not include third heading's
|
|
243
376
|
// children).
|
|
244
377
|
{
|
|
245
378
|
testName: "multipleStyledText",
|
|
246
|
-
|
|
379
|
+
createCopySelection: (doc) => TextSelection.create(doc, 165, 182),
|
|
247
380
|
},
|
|
248
|
-
//
|
|
381
|
+
// Copy/paste the image block content.
|
|
249
382
|
{
|
|
250
383
|
testName: "image",
|
|
251
|
-
|
|
384
|
+
createCopySelection: (doc) => NodeSelection.create(doc, 185),
|
|
252
385
|
},
|
|
253
|
-
//
|
|
254
|
-
// descendant.
|
|
386
|
+
// Copy/paste from start of third heading to end of it's last descendant.
|
|
255
387
|
{
|
|
256
388
|
testName: "nestedImage",
|
|
257
|
-
|
|
389
|
+
createCopySelection: (doc) => TextSelection.create(doc, 165, 205),
|
|
258
390
|
},
|
|
259
|
-
//
|
|
391
|
+
// Copy/paste text in first cell of the table.
|
|
260
392
|
{
|
|
261
393
|
testName: "tableCellText",
|
|
262
|
-
|
|
394
|
+
createCopySelection: (doc) => TextSelection.create(doc, 216, 226),
|
|
263
395
|
},
|
|
264
|
-
//
|
|
396
|
+
// Copy/paste first cell of the table.
|
|
265
397
|
// TODO: External HTML is wrapped in unnecessary `tr` element.
|
|
266
398
|
{
|
|
267
399
|
testName: "tableCell",
|
|
268
|
-
|
|
400
|
+
createCopySelection: (doc) => CellSelection.create(doc, 214),
|
|
269
401
|
},
|
|
270
|
-
//
|
|
402
|
+
// Copy/paste first row of the table.
|
|
271
403
|
{
|
|
272
404
|
testName: "tableRow",
|
|
273
|
-
|
|
405
|
+
createCopySelection: (doc) => CellSelection.create(doc, 214, 228),
|
|
274
406
|
},
|
|
275
|
-
//
|
|
407
|
+
// Copy/paste all cells of the table.
|
|
276
408
|
{
|
|
277
409
|
testName: "tableAllCells",
|
|
278
|
-
|
|
410
|
+
createCopySelection: (doc) => CellSelection.create(doc, 214, 258),
|
|
411
|
+
},
|
|
412
|
+
// Copy regular paragraph content and paste over custom block content.
|
|
413
|
+
{
|
|
414
|
+
testName: "paragraphInCustomBlock",
|
|
415
|
+
createCopySelection: (doc) => TextSelection.create(doc, 277, 286),
|
|
416
|
+
createPasteSelection: (doc) => TextSelection.create(doc, 290, 299),
|
|
417
|
+
},
|
|
418
|
+
// Copy/paste basic blocks.
|
|
419
|
+
{
|
|
420
|
+
testName: "basicBlocks",
|
|
421
|
+
createCopySelection: (doc) => TextSelection.create(doc, 303, 558),
|
|
422
|
+
},
|
|
423
|
+
// Copy/paste basic blocks with props.
|
|
424
|
+
{
|
|
425
|
+
testName: "basicBlocksWithProps",
|
|
426
|
+
createCopySelection: (doc) => TextSelection.create(doc, 558, 813),
|
|
279
427
|
},
|
|
280
428
|
];
|
|
281
429
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createBlockSpec } from "../../schema/index.js";
|
|
2
|
+
import { BlockNoteSchema } from "../../editor/BlockNoteSchema.js";
|
|
3
|
+
import { defaultBlockSpecs } from "../../blocks/defaultBlocks.js";
|
|
4
|
+
|
|
5
|
+
const CustomParagraph = createBlockSpec(
|
|
6
|
+
{
|
|
7
|
+
type: "customParagraph",
|
|
8
|
+
content: "inline",
|
|
9
|
+
propSchema: {},
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
render: () => {
|
|
13
|
+
const customParagraph = document.createElement("p");
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
dom: customParagraph,
|
|
17
|
+
contentDOM: customParagraph,
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
export const schema = BlockNoteSchema.create({
|
|
23
|
+
blockSpecs: {
|
|
24
|
+
...defaultBlockSpecs,
|
|
25
|
+
customParagraph: CustomParagraph as any,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<div data-page-break=""></div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<div class="bn-block-group" data-node-type="blockGroup"><div class="bn-block-outer" data-node-type="blockOuter" data-id="1"><div class="bn-block" data-node-type="blockContainer" data-id="1"><div class="bn-block-content" data-content-type="pageBreak"><div class="bn-page-break" data-page-break=""></div></div></div></div></div>
|
|
@@ -104,7 +104,9 @@ function serializeBlock<
|
|
|
104
104
|
for (const [name, spec] of Object.entries(
|
|
105
105
|
editor.schema.blockSchema[block.type as any].propSchema
|
|
106
106
|
)) {
|
|
107
|
-
(
|
|
107
|
+
if (spec.default !== undefined) {
|
|
108
|
+
(props as any)[name] = spec.default;
|
|
109
|
+
}
|
|
108
110
|
}
|
|
109
111
|
}
|
|
110
112
|
|
|
@@ -172,6 +174,10 @@ function serializeBlock<
|
|
|
172
174
|
if (listType) {
|
|
173
175
|
if (fragment.lastChild?.nodeName !== listType) {
|
|
174
176
|
const list = doc.createElement(listType);
|
|
177
|
+
|
|
178
|
+
if (listType === "OL" && props?.start && props?.start !== 1) {
|
|
179
|
+
list.setAttribute("start", props.start + "");
|
|
180
|
+
}
|
|
175
181
|
fragment.append(list);
|
|
176
182
|
}
|
|
177
183
|
const li = doc.createElement("li");
|