@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,245 @@
|
|
|
1
|
+
export declare const it: {
|
|
2
|
+
slash_menu: {
|
|
3
|
+
heading: {
|
|
4
|
+
title: string;
|
|
5
|
+
subtext: string;
|
|
6
|
+
aliases: string[];
|
|
7
|
+
group: string;
|
|
8
|
+
};
|
|
9
|
+
heading_2: {
|
|
10
|
+
title: string;
|
|
11
|
+
subtext: string;
|
|
12
|
+
aliases: string[];
|
|
13
|
+
group: string;
|
|
14
|
+
};
|
|
15
|
+
heading_3: {
|
|
16
|
+
title: string;
|
|
17
|
+
subtext: string;
|
|
18
|
+
aliases: string[];
|
|
19
|
+
group: string;
|
|
20
|
+
};
|
|
21
|
+
numbered_list: {
|
|
22
|
+
title: string;
|
|
23
|
+
subtext: string;
|
|
24
|
+
aliases: string[];
|
|
25
|
+
group: string;
|
|
26
|
+
};
|
|
27
|
+
bullet_list: {
|
|
28
|
+
title: string;
|
|
29
|
+
subtext: string;
|
|
30
|
+
aliases: string[];
|
|
31
|
+
group: string;
|
|
32
|
+
};
|
|
33
|
+
check_list: {
|
|
34
|
+
title: string;
|
|
35
|
+
subtext: string;
|
|
36
|
+
aliases: string[];
|
|
37
|
+
group: string;
|
|
38
|
+
};
|
|
39
|
+
paragraph: {
|
|
40
|
+
title: string;
|
|
41
|
+
subtext: string;
|
|
42
|
+
aliases: string[];
|
|
43
|
+
group: string;
|
|
44
|
+
};
|
|
45
|
+
code_block: {
|
|
46
|
+
title: string;
|
|
47
|
+
subtext: string;
|
|
48
|
+
aliases: string[];
|
|
49
|
+
group: string;
|
|
50
|
+
};
|
|
51
|
+
table: {
|
|
52
|
+
title: string;
|
|
53
|
+
subtext: string;
|
|
54
|
+
aliases: string[];
|
|
55
|
+
group: string;
|
|
56
|
+
};
|
|
57
|
+
image: {
|
|
58
|
+
title: string;
|
|
59
|
+
subtext: string;
|
|
60
|
+
aliases: string[];
|
|
61
|
+
group: string;
|
|
62
|
+
};
|
|
63
|
+
video: {
|
|
64
|
+
title: string;
|
|
65
|
+
subtext: string;
|
|
66
|
+
aliases: string[];
|
|
67
|
+
group: string;
|
|
68
|
+
};
|
|
69
|
+
audio: {
|
|
70
|
+
title: string;
|
|
71
|
+
subtext: string;
|
|
72
|
+
aliases: string[];
|
|
73
|
+
group: string;
|
|
74
|
+
};
|
|
75
|
+
file: {
|
|
76
|
+
title: string;
|
|
77
|
+
subtext: string;
|
|
78
|
+
aliases: string[];
|
|
79
|
+
group: string;
|
|
80
|
+
};
|
|
81
|
+
emoji: {
|
|
82
|
+
title: string;
|
|
83
|
+
subtext: string;
|
|
84
|
+
aliases: string[];
|
|
85
|
+
group: string;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
placeholders: {
|
|
89
|
+
default: string;
|
|
90
|
+
heading: string;
|
|
91
|
+
bulletListItem: string;
|
|
92
|
+
numberedListItem: string;
|
|
93
|
+
checkListItem: string;
|
|
94
|
+
};
|
|
95
|
+
file_blocks: {
|
|
96
|
+
image: {
|
|
97
|
+
add_button_text: string;
|
|
98
|
+
};
|
|
99
|
+
video: {
|
|
100
|
+
add_button_text: string;
|
|
101
|
+
};
|
|
102
|
+
audio: {
|
|
103
|
+
add_button_text: string;
|
|
104
|
+
};
|
|
105
|
+
file: {
|
|
106
|
+
add_button_text: string;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
side_menu: {
|
|
110
|
+
add_block_label: string;
|
|
111
|
+
drag_handle_label: string;
|
|
112
|
+
};
|
|
113
|
+
drag_handle: {
|
|
114
|
+
delete_menuitem: string;
|
|
115
|
+
colors_menuitem: string;
|
|
116
|
+
};
|
|
117
|
+
table_handle: {
|
|
118
|
+
delete_column_menuitem: string;
|
|
119
|
+
delete_row_menuitem: string;
|
|
120
|
+
add_left_menuitem: string;
|
|
121
|
+
add_right_menuitem: string;
|
|
122
|
+
add_above_menuitem: string;
|
|
123
|
+
add_below_menuitem: string;
|
|
124
|
+
};
|
|
125
|
+
suggestion_menu: {
|
|
126
|
+
no_items_title: string;
|
|
127
|
+
loading: string;
|
|
128
|
+
};
|
|
129
|
+
color_picker: {
|
|
130
|
+
text_title: string;
|
|
131
|
+
background_title: string;
|
|
132
|
+
colors: {
|
|
133
|
+
default: string;
|
|
134
|
+
gray: string;
|
|
135
|
+
brown: string;
|
|
136
|
+
red: string;
|
|
137
|
+
orange: string;
|
|
138
|
+
yellow: string;
|
|
139
|
+
green: string;
|
|
140
|
+
blue: string;
|
|
141
|
+
purple: string;
|
|
142
|
+
pink: string;
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
formatting_toolbar: {
|
|
146
|
+
bold: {
|
|
147
|
+
tooltip: string;
|
|
148
|
+
secondary_tooltip: string;
|
|
149
|
+
};
|
|
150
|
+
italic: {
|
|
151
|
+
tooltip: string;
|
|
152
|
+
secondary_tooltip: string;
|
|
153
|
+
};
|
|
154
|
+
underline: {
|
|
155
|
+
tooltip: string;
|
|
156
|
+
secondary_tooltip: string;
|
|
157
|
+
};
|
|
158
|
+
strike: {
|
|
159
|
+
tooltip: string;
|
|
160
|
+
secondary_tooltip: string;
|
|
161
|
+
};
|
|
162
|
+
code: {
|
|
163
|
+
tooltip: string;
|
|
164
|
+
secondary_tooltip: string;
|
|
165
|
+
};
|
|
166
|
+
colors: {
|
|
167
|
+
tooltip: string;
|
|
168
|
+
};
|
|
169
|
+
link: {
|
|
170
|
+
tooltip: string;
|
|
171
|
+
secondary_tooltip: string;
|
|
172
|
+
};
|
|
173
|
+
file_caption: {
|
|
174
|
+
tooltip: string;
|
|
175
|
+
input_placeholder: string;
|
|
176
|
+
};
|
|
177
|
+
file_replace: {
|
|
178
|
+
tooltip: Record<string, string>;
|
|
179
|
+
};
|
|
180
|
+
file_rename: {
|
|
181
|
+
tooltip: Record<string, string>;
|
|
182
|
+
input_placeholder: Record<string, string>;
|
|
183
|
+
};
|
|
184
|
+
file_download: {
|
|
185
|
+
tooltip: Record<string, string>;
|
|
186
|
+
};
|
|
187
|
+
file_delete: {
|
|
188
|
+
tooltip: Record<string, string>;
|
|
189
|
+
};
|
|
190
|
+
file_preview_toggle: {
|
|
191
|
+
tooltip: string;
|
|
192
|
+
};
|
|
193
|
+
nest: {
|
|
194
|
+
tooltip: string;
|
|
195
|
+
secondary_tooltip: string;
|
|
196
|
+
};
|
|
197
|
+
unnest: {
|
|
198
|
+
tooltip: string;
|
|
199
|
+
secondary_tooltip: string;
|
|
200
|
+
};
|
|
201
|
+
align_left: {
|
|
202
|
+
tooltip: string;
|
|
203
|
+
};
|
|
204
|
+
align_center: {
|
|
205
|
+
tooltip: string;
|
|
206
|
+
};
|
|
207
|
+
align_right: {
|
|
208
|
+
tooltip: string;
|
|
209
|
+
};
|
|
210
|
+
align_justify: {
|
|
211
|
+
tooltip: string;
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
file_panel: {
|
|
215
|
+
upload: {
|
|
216
|
+
title: string;
|
|
217
|
+
file_placeholder: Record<string, string>;
|
|
218
|
+
upload_error: string;
|
|
219
|
+
};
|
|
220
|
+
embed: {
|
|
221
|
+
title: string;
|
|
222
|
+
embed_button: Record<string, string>;
|
|
223
|
+
url_placeholder: string;
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
link_toolbar: {
|
|
227
|
+
delete: {
|
|
228
|
+
tooltip: string;
|
|
229
|
+
};
|
|
230
|
+
edit: {
|
|
231
|
+
text: string;
|
|
232
|
+
tooltip: string;
|
|
233
|
+
};
|
|
234
|
+
open: {
|
|
235
|
+
tooltip: string;
|
|
236
|
+
};
|
|
237
|
+
form: {
|
|
238
|
+
title_placeholder: string;
|
|
239
|
+
url_placeholder: string;
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
generic: {
|
|
243
|
+
ctrl_shortcut: string;
|
|
244
|
+
};
|
|
245
|
+
};
|
package/types/src/index.d.ts
CHANGED
|
@@ -6,6 +6,9 @@ export * from "./api/nodeUtil.js";
|
|
|
6
6
|
export * from "./api/testUtil/index.js";
|
|
7
7
|
export * from "./blocks/AudioBlockContent/AudioBlockContent.js";
|
|
8
8
|
export * from "./blocks/CodeBlockContent/CodeBlockContent.js";
|
|
9
|
+
export * from "./blocks/PageBreakBlockContent/PageBreakBlockContent.js";
|
|
10
|
+
export * from "./blocks/PageBreakBlockContent/getPageBreakSlashMenuItems.js";
|
|
11
|
+
export * from "./blocks/PageBreakBlockContent/schema.js";
|
|
9
12
|
export * from "./blocks/FileBlockContent/FileBlockContent.js";
|
|
10
13
|
export * from "./blocks/FileBlockContent/helpers/parse/parseEmbedElement.js";
|
|
11
14
|
export * from "./blocks/FileBlockContent/helpers/parse/parseFigureElement.js";
|
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
export type PropSpec<PType extends boolean | number | string> = {
|
|
2
|
-
values?: readonly PType[];
|
|
3
2
|
default: PType;
|
|
3
|
+
values?: readonly PType[];
|
|
4
|
+
} | {
|
|
5
|
+
default: undefined;
|
|
6
|
+
type: "string" | "number" | "boolean";
|
|
7
|
+
values?: readonly PType[];
|
|
4
8
|
};
|
|
5
9
|
export type PropSchema = Record<string, PropSpec<boolean | number | string>>;
|
|
6
10
|
export type Props<PSchema extends PropSchema> = {
|
|
7
|
-
[PName in keyof PSchema]: PSchema[PName]
|
|
11
|
+
[PName in keyof PSchema]: (PSchema[PName] extends {
|
|
12
|
+
default: boolean;
|
|
13
|
+
} | {
|
|
14
|
+
type: "boolean";
|
|
15
|
+
} ? PSchema[PName]["values"] extends readonly boolean[] ? PSchema[PName]["values"][number] : boolean : PSchema[PName] extends {
|
|
16
|
+
default: number;
|
|
17
|
+
} | {
|
|
18
|
+
type: "number";
|
|
19
|
+
} ? PSchema[PName]["values"] extends readonly number[] ? PSchema[PName]["values"][number] : number : PSchema[PName] extends {
|
|
20
|
+
default: string;
|
|
21
|
+
} | {
|
|
22
|
+
type: "string";
|
|
23
|
+
} ? PSchema[PName]["values"] extends readonly string[] ? PSchema[PName]["values"][number] : string : never) extends infer T ? PSchema[PName] extends {
|
|
24
|
+
optional: true;
|
|
25
|
+
} ? T | undefined : T : never;
|
|
8
26
|
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { blockToNode } from "../../../nodeConversions/blockToNode.js";
|
|
2
|
-
import { nodeToBlock } from "../../../nodeConversions/nodeToBlock.js";
|
|
3
|
-
import { getNodeById } from "../../../nodeUtil.js";
|
|
4
|
-
export function insertBlocks(editor, blocksToInsert, referenceBlock, placement = "before") {
|
|
5
|
-
const id = typeof referenceBlock === "string" ? referenceBlock : referenceBlock.id;
|
|
6
|
-
const nodesToInsert = [];
|
|
7
|
-
for (const blockSpec of blocksToInsert) {
|
|
8
|
-
nodesToInsert.push(blockToNode(blockSpec, editor.pmSchema, editor.schema.styleSchema));
|
|
9
|
-
}
|
|
10
|
-
const posInfo = getNodeById(id, editor._tiptapEditor.state.doc);
|
|
11
|
-
if (!posInfo) {
|
|
12
|
-
throw new Error(`Block with ID ${id} not found`);
|
|
13
|
-
}
|
|
14
|
-
// TODO: we might want to use the ReplaceStep directly here instead of insert,
|
|
15
|
-
// because the fitting algorithm should not be necessary and might even cause unexpected behavior
|
|
16
|
-
if (placement === "before") {
|
|
17
|
-
editor.dispatch(editor._tiptapEditor.state.tr.insert(posInfo.posBeforeNode, nodesToInsert));
|
|
18
|
-
}
|
|
19
|
-
if (placement === "after") {
|
|
20
|
-
editor.dispatch(editor._tiptapEditor.state.tr.insert(posInfo.posBeforeNode + posInfo.node.nodeSize, nodesToInsert));
|
|
21
|
-
}
|
|
22
|
-
// Now that the `PartialBlock`s have been converted to nodes, we can
|
|
23
|
-
// re-convert them into full `Block`s.
|
|
24
|
-
const insertedBlocks = [];
|
|
25
|
-
for (const node of nodesToInsert) {
|
|
26
|
-
insertedBlocks.push(nodeToBlock(node, editor.schema.blockSchema, editor.schema.inlineContentSchema, editor.schema.styleSchema, editor.blockCache));
|
|
27
|
-
}
|
|
28
|
-
return insertedBlocks;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=insertBlocks.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"insertBlocks.js","sourceRoot":"","sources":["../../../../../../src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AACt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Ac,GAA2B,EAAE,CAAC;IAClD,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;QACjC,cAAc,CAAC,IAAI,CACjB,WAAW,CACT,IAAI,EACJ,MAAM,CAAC,MAAM,CAAC,WAAW,EACzB,MAAM,CAAC,MAAM,CAAC,mBAAmB,EACjC,MAAM,CAAC,MAAM,CAAC,WAAW,EACzB,MAAM,CAAC,UAAU,CAClB,CACF,CAAC;IACJ,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC"}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { setupTestEnv } from "../../setupTestEnv.js";
|
|
3
|
-
import { insertBlocks } from "./insertBlocks.js";
|
|
4
|
-
const getEditor = setupTestEnv();
|
|
5
|
-
describe("Test insertBlocks", () => {
|
|
6
|
-
it("Insert single basic block before", () => {
|
|
7
|
-
insertBlocks(getEditor(), [{ type: "paragraph" }], "paragraph-0", "before");
|
|
8
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
9
|
-
});
|
|
10
|
-
it("Insert single basic block after", () => {
|
|
11
|
-
insertBlocks(getEditor(), [{ type: "paragraph" }], "paragraph-0", "after");
|
|
12
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
13
|
-
});
|
|
14
|
-
it("Insert multiple blocks before", () => {
|
|
15
|
-
insertBlocks(getEditor(), [
|
|
16
|
-
{ type: "paragraph", content: "Inserted paragraph 1" },
|
|
17
|
-
{ type: "paragraph", content: "Inserted paragraph 2" },
|
|
18
|
-
{ type: "paragraph", content: "Inserted paragraph 3" },
|
|
19
|
-
], "paragraph-0", "before");
|
|
20
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
21
|
-
});
|
|
22
|
-
it("Insert multiple blocks after", () => {
|
|
23
|
-
insertBlocks(getEditor(), [
|
|
24
|
-
{ type: "paragraph", content: "Inserted paragraph 1" },
|
|
25
|
-
{ type: "paragraph", content: "Inserted paragraph 2" },
|
|
26
|
-
{ type: "paragraph", content: "Inserted paragraph 3" },
|
|
27
|
-
], "paragraph-0", "after");
|
|
28
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
29
|
-
});
|
|
30
|
-
it("Insert single complex block before", () => {
|
|
31
|
-
insertBlocks(getEditor(), [
|
|
32
|
-
{
|
|
33
|
-
id: "inserted-heading-with-everything",
|
|
34
|
-
type: "heading",
|
|
35
|
-
props: {
|
|
36
|
-
backgroundColor: "red",
|
|
37
|
-
level: 2,
|
|
38
|
-
textAlignment: "center",
|
|
39
|
-
textColor: "red",
|
|
40
|
-
},
|
|
41
|
-
content: [
|
|
42
|
-
{ type: "text", text: "Heading", styles: { bold: true } },
|
|
43
|
-
{ type: "text", text: " with styled ", styles: {} },
|
|
44
|
-
{ type: "text", text: "content", styles: { italic: true } },
|
|
45
|
-
],
|
|
46
|
-
children: [
|
|
47
|
-
{
|
|
48
|
-
id: "inserted-nested-paragraph-2",
|
|
49
|
-
type: "paragraph",
|
|
50
|
-
content: "Nested Paragraph 2",
|
|
51
|
-
children: [
|
|
52
|
-
{
|
|
53
|
-
id: "inserted-double-nested-paragraph-2",
|
|
54
|
-
type: "paragraph",
|
|
55
|
-
content: "Double Nested Paragraph 2",
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
},
|
|
61
|
-
], "paragraph-0", "before");
|
|
62
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
63
|
-
});
|
|
64
|
-
it("Insert single complex block after", () => {
|
|
65
|
-
insertBlocks(getEditor(), [
|
|
66
|
-
{
|
|
67
|
-
id: "inserted-heading-with-everything",
|
|
68
|
-
type: "heading",
|
|
69
|
-
props: {
|
|
70
|
-
backgroundColor: "red",
|
|
71
|
-
level: 2,
|
|
72
|
-
textAlignment: "center",
|
|
73
|
-
textColor: "red",
|
|
74
|
-
},
|
|
75
|
-
content: [
|
|
76
|
-
{ type: "text", text: "Heading", styles: { bold: true } },
|
|
77
|
-
{ type: "text", text: " with styled ", styles: {} },
|
|
78
|
-
{ type: "text", text: "content", styles: { italic: true } },
|
|
79
|
-
],
|
|
80
|
-
children: [
|
|
81
|
-
{
|
|
82
|
-
id: "inserted-nested-paragraph-2",
|
|
83
|
-
type: "paragraph",
|
|
84
|
-
content: "Nested Paragraph 2",
|
|
85
|
-
children: [
|
|
86
|
-
{
|
|
87
|
-
id: "inserted-double-nested-paragraph-2",
|
|
88
|
-
type: "paragraph",
|
|
89
|
-
content: "Double Nested Paragraph 2",
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
|
-
},
|
|
93
|
-
],
|
|
94
|
-
},
|
|
95
|
-
], "paragraph-0", "after");
|
|
96
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
//# sourceMappingURL=insertBlocks.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"insertBlocks.test.js","sourceRoot":"","sources":["../../../../../../src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;AAEjC,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC1C,YAAY,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC;QAE5E,MAAM,CAAC,SAAS,EAAE,CAAC,QAAQ,CAAC,CAAC,eAAe,EAAE,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC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,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;iBAC5D;gBACD,QAAQ,EAAE;oBACR;wBACE,EAAE,EAAE,6BAA6B;wBACjC,IAAI,EAAE,WAAW;wBACjB,OAAO,EAAE,oBAAoB;wBAC7B,QAAQ,EAAE;4BACR;gCACE,EAAE,EAAE,oCAAoC;gCACxC,IAAI,EAAE,WAAW;gCACjB,OAAO,EAAE,2BAA2B;6BACrC;yBACF;qBACF;iBACF;aACF;SACF,EACD,aAAa,EACb,OAAO,CACR,CAAC;QAEF,MAAM,CAAC,SAAS,EAAE,CAAC,QAAQ,CAAC,CAAC,eAAe,EAAE,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { getBlockInfoFromResolvedPos, } from "../../../getBlockInfoFromPos.js";
|
|
2
|
-
/**
|
|
3
|
-
* Returns the block info from the parent block
|
|
4
|
-
* or undefined if we're at the root
|
|
5
|
-
*/
|
|
6
|
-
export const getParentBlockInfo = (doc, beforePos) => {
|
|
7
|
-
const $pos = doc.resolve(beforePos);
|
|
8
|
-
if ($pos.depth <= 1) {
|
|
9
|
-
return undefined;
|
|
10
|
-
}
|
|
11
|
-
// get start pos of parent
|
|
12
|
-
const parentBeforePos = $pos.posAtIndex($pos.index($pos.depth - 1), $pos.depth - 1);
|
|
13
|
-
const parentBlockInfo = getBlockInfoFromResolvedPos(doc.resolve(parentBeforePos));
|
|
14
|
-
return parentBlockInfo;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Returns the block info from the sibling block before (above) the given block,
|
|
18
|
-
* or undefined if the given block is the first sibling.
|
|
19
|
-
*/
|
|
20
|
-
export const getPrevBlockInfo = (doc, beforePos) => {
|
|
21
|
-
const $pos = doc.resolve(beforePos);
|
|
22
|
-
const indexInParent = $pos.index();
|
|
23
|
-
if (indexInParent === 0) {
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
|
-
const prevBlockBeforePos = $pos.posAtIndex(indexInParent - 1);
|
|
27
|
-
const prevBlockInfo = getBlockInfoFromResolvedPos(doc.resolve(prevBlockBeforePos));
|
|
28
|
-
return prevBlockInfo;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* If a block has children like this:
|
|
32
|
-
* A
|
|
33
|
-
* - B
|
|
34
|
-
* - C
|
|
35
|
-
* -- D
|
|
36
|
-
*
|
|
37
|
-
* Then the bottom nested block returned is D.
|
|
38
|
-
*/
|
|
39
|
-
export const getBottomNestedBlockInfo = (doc, blockInfo) => {
|
|
40
|
-
while (blockInfo.childContainer) {
|
|
41
|
-
const group = blockInfo.childContainer.node;
|
|
42
|
-
const newPos = doc
|
|
43
|
-
.resolve(blockInfo.childContainer.beforePos + 1)
|
|
44
|
-
.posAtIndex(group.childCount - 1);
|
|
45
|
-
blockInfo = getBlockInfoFromResolvedPos(doc.resolve(newPos));
|
|
46
|
-
}
|
|
47
|
-
return blockInfo;
|
|
48
|
-
};
|
|
49
|
-
const canMerge = (prevBlockInfo, nextBlockInfo) => {
|
|
50
|
-
return (prevBlockInfo.isBlockContainer &&
|
|
51
|
-
prevBlockInfo.blockContent.node.type.spec.content === "inline*" &&
|
|
52
|
-
prevBlockInfo.blockContent.node.childCount > 0 &&
|
|
53
|
-
nextBlockInfo.isBlockContainer &&
|
|
54
|
-
nextBlockInfo.blockContent.node.type.spec.content === "inline*");
|
|
55
|
-
};
|
|
56
|
-
const mergeBlocks = (state, dispatch, prevBlockInfo, nextBlockInfo) => {
|
|
57
|
-
// Un-nests all children of the next block.
|
|
58
|
-
if (!nextBlockInfo.isBlockContainer) {
|
|
59
|
-
throw new Error(`Attempted to merge block at position ${nextBlockInfo.bnBlock.beforePos} into previous block at position ${prevBlockInfo.bnBlock.beforePos}, but next block is not a block container`);
|
|
60
|
-
}
|
|
61
|
-
// Removes a level of nesting all children of the next block by 1 level, if it contains both content and block
|
|
62
|
-
// group nodes.
|
|
63
|
-
if (nextBlockInfo.childContainer) {
|
|
64
|
-
const childBlocksStart = state.doc.resolve(nextBlockInfo.childContainer.beforePos + 1);
|
|
65
|
-
const childBlocksEnd = state.doc.resolve(nextBlockInfo.childContainer.afterPos - 1);
|
|
66
|
-
const childBlocksRange = childBlocksStart.blockRange(childBlocksEnd);
|
|
67
|
-
if (dispatch) {
|
|
68
|
-
const pos = state.doc.resolve(nextBlockInfo.bnBlock.beforePos);
|
|
69
|
-
state.tr.lift(childBlocksRange, pos.depth);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
// Deletes the boundary between the two blocks. Can be thought of as
|
|
73
|
-
// removing the closing tags of the first block and the opening tags of the
|
|
74
|
-
// second one to stitch them together.
|
|
75
|
-
if (dispatch) {
|
|
76
|
-
if (!prevBlockInfo.isBlockContainer) {
|
|
77
|
-
throw new Error(`Attempted to merge block at position ${nextBlockInfo.bnBlock.beforePos} into previous block at position ${prevBlockInfo.bnBlock.beforePos}, but previous block is not a block container`);
|
|
78
|
-
}
|
|
79
|
-
// TODO: test merging between a columnList and paragraph, between two columnLists, and v.v.
|
|
80
|
-
dispatch(state.tr.delete(prevBlockInfo.blockContent.afterPos - 1, nextBlockInfo.blockContent.beforePos + 1));
|
|
81
|
-
}
|
|
82
|
-
return true;
|
|
83
|
-
};
|
|
84
|
-
export const mergeBlocksCommand = (posBetweenBlocks) => ({ state, dispatch, }) => {
|
|
85
|
-
const $pos = state.doc.resolve(posBetweenBlocks);
|
|
86
|
-
const nextBlockInfo = getBlockInfoFromResolvedPos($pos);
|
|
87
|
-
const prevBlockInfo = getPrevBlockInfo(state.doc, nextBlockInfo.bnBlock.beforePos);
|
|
88
|
-
if (!prevBlockInfo) {
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
const bottomNestedBlockInfo = getBottomNestedBlockInfo(state.doc, prevBlockInfo);
|
|
92
|
-
if (!canMerge(bottomNestedBlockInfo, nextBlockInfo)) {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
return mergeBlocks(state, dispatch, bottomNestedBlockInfo, nextBlockInfo);
|
|
96
|
-
};
|
|
97
|
-
//# sourceMappingURL=mergeBlocks.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mergeBlocks.js","sourceRoot":"","sources":["../../../../../../src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,2BAA2B,GAC5B,MAAM,iCAAiC,CAAC;AAEzC;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAS,EAAE,SAAiB,EAAE,EAAE;IACjE,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEpC,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC;QACpB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,0BAA0B;IAC1B,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU,CACrC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,EAC1B,IAAI,CAAC,KAAK,GAAG,CAAC,CACf,CAAC;IAEF,MAAM,eAAe,GAAG,2BAA2B,CACjD,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,CAC7B,CAAC;IACF,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAS,EAAE,SAAiB,EAAE,EAAE;IAC/D,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEpC,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;IAEnC,IAAI,aAAa,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,kBAAkB,GAAG,IAAI,CAAC,UA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,CAAC,MAAM,kBAAkB,GAC7B,CAAC,gBAAwB,EAAE,EAAE,CAC7B,CAAC,EACC,KAAK,EACL,QAAQ,GAIT,EAAE,EAAE;IACH,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACjD,MAAM,aAAa,GAAG,2BAA2B,CAAC,IAAI,CAAC,CAAC;IAExD,MAAM,aAAa,GAAG,gBAAgB,CACpC,KAAK,CAAC,GAAG,EACT,aAAa,CAAC,OAAO,CAAC,SAAS,CAChC,CAAC;IAEF,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,qBAAqB,GAAG,wBAAwB,CACpD,KAAK,CAAC,GAAG,EACT,aAAa,CACd,CAAC;IAEF,IAAI,CAAC,QAAQ,CAAC,qBAAqB,EAAE,aAAa,CAAC,EAAE,CAAC;QACpD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE,qBAAqB,EAAE,aAAa,CAAC,CAAC;AAC5E,CAAC,CAAC"}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { getBlockInfoFromSelection } from "../../../getBlockInfoFromPos.js";
|
|
3
|
-
import { setupTestEnv } from "../../setupTestEnv.js";
|
|
4
|
-
import { mergeBlocksCommand } from "./mergeBlocks.js";
|
|
5
|
-
const getEditor = setupTestEnv();
|
|
6
|
-
function mergeBlocks(posBetweenBlocks) {
|
|
7
|
-
return getEditor()._tiptapEditor.commands.command(mergeBlocksCommand(posBetweenBlocks));
|
|
8
|
-
}
|
|
9
|
-
function getPosBeforeSelectedBlock() {
|
|
10
|
-
return getBlockInfoFromSelection(getEditor()._tiptapEditor.state).bnBlock
|
|
11
|
-
.beforePos;
|
|
12
|
-
}
|
|
13
|
-
describe("Test mergeBlocks", () => {
|
|
14
|
-
it("Basic", () => {
|
|
15
|
-
getEditor().setTextCursorPosition("paragraph-1");
|
|
16
|
-
mergeBlocks(getPosBeforeSelectedBlock());
|
|
17
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
18
|
-
});
|
|
19
|
-
it("First block has children", () => {
|
|
20
|
-
getEditor().setTextCursorPosition("paragraph-2");
|
|
21
|
-
mergeBlocks(getPosBeforeSelectedBlock());
|
|
22
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
23
|
-
});
|
|
24
|
-
it("Second block has children", () => {
|
|
25
|
-
getEditor().setTextCursorPosition("paragraph-with-children");
|
|
26
|
-
mergeBlocks(getPosBeforeSelectedBlock());
|
|
27
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
28
|
-
});
|
|
29
|
-
it("Second block is empty", () => {
|
|
30
|
-
getEditor().setTextCursorPosition("empty-paragraph");
|
|
31
|
-
mergeBlocks(getPosBeforeSelectedBlock());
|
|
32
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
33
|
-
});
|
|
34
|
-
it("Blocks have different types", () => {
|
|
35
|
-
getEditor().setTextCursorPosition("paragraph-5");
|
|
36
|
-
mergeBlocks(getPosBeforeSelectedBlock());
|
|
37
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
38
|
-
});
|
|
39
|
-
it("Selection is updated", () => {
|
|
40
|
-
getEditor().setTextCursorPosition("paragraph-0", "end");
|
|
41
|
-
const firstBlockEndOffset = getEditor()._tiptapEditor.state.selection.$anchor.parentOffset;
|
|
42
|
-
getEditor().setTextCursorPosition("paragraph-1");
|
|
43
|
-
mergeBlocks(getPosBeforeSelectedBlock());
|
|
44
|
-
const anchorIsAtOldFirstBlockEndPos = getEditor()._tiptapEditor.state.selection.$anchor.parentOffset ===
|
|
45
|
-
firstBlockEndOffset;
|
|
46
|
-
expect(anchorIsAtOldFirstBlockEndPos).toBeTruthy();
|
|
47
|
-
});
|
|
48
|
-
// We expect a no-op for each of the remaining tests as merging should only
|
|
49
|
-
// happen for blocks which both have inline content. We also expect
|
|
50
|
-
// `mergeBlocks` to return false as TipTap commands should do that instead of
|
|
51
|
-
// throwing an error, when the command cannot be executed.
|
|
52
|
-
it("First block is empty", () => {
|
|
53
|
-
getEditor().setTextCursorPosition("paragraph-8");
|
|
54
|
-
const originalDocument = getEditor().document;
|
|
55
|
-
const ret = mergeBlocks(getPosBeforeSelectedBlock());
|
|
56
|
-
expect(getEditor().document).toEqual(originalDocument);
|
|
57
|
-
expect(ret).toBeFalsy();
|
|
58
|
-
});
|
|
59
|
-
it("Inline content & no content", () => {
|
|
60
|
-
getEditor().setTextCursorPosition("image-0");
|
|
61
|
-
const originalDocument = getEditor().document;
|
|
62
|
-
const ret = mergeBlocks(getPosBeforeSelectedBlock());
|
|
63
|
-
expect(getEditor().document).toEqual(originalDocument);
|
|
64
|
-
expect(ret).toBeFalsy();
|
|
65
|
-
});
|
|
66
|
-
it("Inline content & table content", () => {
|
|
67
|
-
getEditor().setTextCursorPosition("table-0");
|
|
68
|
-
const originalDocument = getEditor().document;
|
|
69
|
-
const ret = mergeBlocks(getPosBeforeSelectedBlock());
|
|
70
|
-
expect(getEditor().document).toEqual(originalDocument);
|
|
71
|
-
expect(ret).toBeFalsy();
|
|
72
|
-
});
|
|
73
|
-
it("No content & inline content", () => {
|
|
74
|
-
getEditor().setTextCursorPosition("paragraph-6");
|
|
75
|
-
const originalDocument = getEditor().document;
|
|
76
|
-
const ret = mergeBlocks(getPosBeforeSelectedBlock());
|
|
77
|
-
expect(getEditor().document).toEqual(originalDocument);
|
|
78
|
-
expect(ret).toBeFalsy();
|
|
79
|
-
});
|
|
80
|
-
it("Table content & inline content", () => {
|
|
81
|
-
getEditor().setTextCursorPosition("paragraph-7");
|
|
82
|
-
const originalDocument = getEditor().document;
|
|
83
|
-
const ret = mergeBlocks(getPosBeforeSelectedBlock());
|
|
84
|
-
expect(getEditor().document).toEqual(originalDocument);
|
|
85
|
-
expect(ret).toBeFalsy();
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
//# sourceMappingURL=mergeBlocks.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mergeBlocks.test.js","sourceRoot":"","sources":["../../../../../../src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;AAEjC,SAAS,WAAW,CAAC,gBAAwB;IAC3C,OAAO,SAAS,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,OAAO,CAC/C,kBAAkB,CAAC,gBAAgB,CAAC,CACrC,CAAC;AACJ,CAAC;AAED,SAAS,yBAAyB;IAChC,OAAO,yBAAyB,CAAC,SAAS,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,OAAO;SACtE,SAAS,CAAC;AACf,CAAC;AAED,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;QACf,SAAS,EAAE,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC;QAEjD,WAAW,CAAC,yBAAyB,EAAE,CAAC,CAAC;QAEzC,MAAM,CAAC,SAAS,EAAE,CAAC,QAAQ,CAAC,CAAC,eAAe,EAAE,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0BAA0B,EAAE,GAAG,EAAE;QAClC,SAAS,EAAE,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC;QAEjD,WAAW,CAAC,yBAAyB,EAAE,CAAC,CAAC;QAEzC,MAAM,CAAC,SAAS,EAAE,CAAC,QAAQ,CAAC,CAAC,eAAe,EAAE,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