@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
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { setupTestEnv } from "../../setupTestEnv.js";
|
|
3
|
-
import { updateBlock } from "./updateBlock.js";
|
|
4
|
-
const getEditor = setupTestEnv();
|
|
5
|
-
describe("Test updateBlock typing", () => {
|
|
6
|
-
it("Type is inferred correctly", () => {
|
|
7
|
-
try {
|
|
8
|
-
getEditor().updateBlock({ id: "placeholder-id" }, {
|
|
9
|
-
// @ts-expect-error invalid type
|
|
10
|
-
type: "non-existing",
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
catch (e) {
|
|
14
|
-
// ID doesn't exist, which is fine - this is a compile-time check
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
it("Props are inferred correctly", () => {
|
|
18
|
-
try {
|
|
19
|
-
getEditor().updateBlock({ id: "placeholder-id" }, {
|
|
20
|
-
type: "paragraph",
|
|
21
|
-
props: {
|
|
22
|
-
// @ts-expect-error invalid type
|
|
23
|
-
level: 1,
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
catch (e) {
|
|
28
|
-
// ID doesn't exist, which is fine - this is a compile-time check
|
|
29
|
-
}
|
|
30
|
-
try {
|
|
31
|
-
getEditor().updateBlock({ id: "placeholder-id" }, {
|
|
32
|
-
type: "heading",
|
|
33
|
-
props: {
|
|
34
|
-
level: 1,
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
catch (e) {
|
|
39
|
-
// ID doesn't exist, which is fine - this is a compile-time check
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
describe("Test updateBlock", () => {
|
|
44
|
-
it.skip("Update ID", () => {
|
|
45
|
-
updateBlock(getEditor(), "heading-with-everything", {
|
|
46
|
-
id: "new-id",
|
|
47
|
-
});
|
|
48
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
49
|
-
});
|
|
50
|
-
it("Update type", () => {
|
|
51
|
-
updateBlock(getEditor(), "heading-with-everything", {
|
|
52
|
-
type: "paragraph",
|
|
53
|
-
});
|
|
54
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
55
|
-
});
|
|
56
|
-
it("Update single prop", () => {
|
|
57
|
-
updateBlock(getEditor(), "heading-with-everything", {
|
|
58
|
-
props: {
|
|
59
|
-
level: 3,
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
63
|
-
});
|
|
64
|
-
it("Update all props", () => {
|
|
65
|
-
updateBlock(getEditor(), "heading-with-everything", {
|
|
66
|
-
props: {
|
|
67
|
-
backgroundColor: "blue",
|
|
68
|
-
level: 3,
|
|
69
|
-
textAlignment: "right",
|
|
70
|
-
textColor: "blue",
|
|
71
|
-
},
|
|
72
|
-
});
|
|
73
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
74
|
-
});
|
|
75
|
-
it("Revert single prop", () => {
|
|
76
|
-
updateBlock(getEditor(), "heading-with-everything", {
|
|
77
|
-
props: {
|
|
78
|
-
level: undefined,
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
82
|
-
});
|
|
83
|
-
it("Revert all props", () => {
|
|
84
|
-
updateBlock(getEditor(), "heading-with-everything", {
|
|
85
|
-
props: {
|
|
86
|
-
backgroundColor: undefined,
|
|
87
|
-
level: undefined,
|
|
88
|
-
textAlignment: undefined,
|
|
89
|
-
textColor: undefined,
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
93
|
-
});
|
|
94
|
-
it("Update with plain content", () => {
|
|
95
|
-
updateBlock(getEditor(), "heading-with-everything", {
|
|
96
|
-
content: "New content",
|
|
97
|
-
});
|
|
98
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
99
|
-
});
|
|
100
|
-
it("Update with styled content", () => {
|
|
101
|
-
updateBlock(getEditor(), "heading-with-everything", {
|
|
102
|
-
content: [
|
|
103
|
-
{ type: "text", text: "New", styles: { backgroundColor: "blue" } },
|
|
104
|
-
{ type: "text", text: " ", styles: {} },
|
|
105
|
-
{ type: "text", text: "content", styles: { backgroundColor: "blue" } },
|
|
106
|
-
],
|
|
107
|
-
});
|
|
108
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
109
|
-
});
|
|
110
|
-
it("Update children", () => {
|
|
111
|
-
updateBlock(getEditor(), "heading-with-everything", {
|
|
112
|
-
children: [
|
|
113
|
-
{
|
|
114
|
-
id: "new-nested-paragraph",
|
|
115
|
-
type: "paragraph",
|
|
116
|
-
content: "New nested Paragraph 2",
|
|
117
|
-
children: [
|
|
118
|
-
{
|
|
119
|
-
id: "new-double-nested-paragraph",
|
|
120
|
-
type: "paragraph",
|
|
121
|
-
content: "New double Nested Paragraph 2",
|
|
122
|
-
},
|
|
123
|
-
],
|
|
124
|
-
},
|
|
125
|
-
],
|
|
126
|
-
});
|
|
127
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
128
|
-
});
|
|
129
|
-
it.skip("Update everything", () => {
|
|
130
|
-
updateBlock(getEditor(), "heading-with-everything", {
|
|
131
|
-
id: "new-id",
|
|
132
|
-
type: "paragraph",
|
|
133
|
-
props: {
|
|
134
|
-
backgroundColor: "blue",
|
|
135
|
-
textAlignment: "right",
|
|
136
|
-
textColor: "blue",
|
|
137
|
-
},
|
|
138
|
-
content: [
|
|
139
|
-
{ type: "text", text: "New", styles: { backgroundColor: "blue" } },
|
|
140
|
-
{ type: "text", text: " ", styles: {} },
|
|
141
|
-
{ type: "text", text: "content", styles: { backgroundColor: "blue" } },
|
|
142
|
-
],
|
|
143
|
-
children: [
|
|
144
|
-
{
|
|
145
|
-
id: "new-nested-paragraph",
|
|
146
|
-
type: "paragraph",
|
|
147
|
-
content: "New nested Paragraph 2",
|
|
148
|
-
children: [
|
|
149
|
-
{
|
|
150
|
-
id: "new-double-nested-paragraph",
|
|
151
|
-
type: "paragraph",
|
|
152
|
-
content: "New double Nested Paragraph 2",
|
|
153
|
-
},
|
|
154
|
-
],
|
|
155
|
-
},
|
|
156
|
-
],
|
|
157
|
-
});
|
|
158
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
159
|
-
});
|
|
160
|
-
it("Update inline content to empty table content", () => {
|
|
161
|
-
expect(() => {
|
|
162
|
-
updateBlock(getEditor(), "paragraph-0", {
|
|
163
|
-
type: "table",
|
|
164
|
-
});
|
|
165
|
-
}).toThrow();
|
|
166
|
-
});
|
|
167
|
-
it("Update table content to empty inline content", () => {
|
|
168
|
-
updateBlock(getEditor(), "table-0", {
|
|
169
|
-
type: "paragraph",
|
|
170
|
-
});
|
|
171
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
172
|
-
});
|
|
173
|
-
it("Update inline content to table content", () => {
|
|
174
|
-
updateBlock(getEditor(), "paragraph-0", {
|
|
175
|
-
type: "table",
|
|
176
|
-
content: {
|
|
177
|
-
type: "tableContent",
|
|
178
|
-
rows: [
|
|
179
|
-
{
|
|
180
|
-
cells: ["Cell 1", "Cell 2", "Cell 3"],
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
cells: ["Cell 4", "Cell 5", "Cell 6"],
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
cells: ["Cell 7", "Cell 8", "Cell 9"],
|
|
187
|
-
},
|
|
188
|
-
],
|
|
189
|
-
},
|
|
190
|
-
});
|
|
191
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
192
|
-
});
|
|
193
|
-
it("Update table content to inline content", () => {
|
|
194
|
-
updateBlock(getEditor(), "table-0", {
|
|
195
|
-
type: "paragraph",
|
|
196
|
-
content: "Paragraph",
|
|
197
|
-
});
|
|
198
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
199
|
-
});
|
|
200
|
-
it("Update inline content to no content", () => {
|
|
201
|
-
updateBlock(getEditor(), "paragraph-0", {
|
|
202
|
-
type: "image",
|
|
203
|
-
});
|
|
204
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
205
|
-
});
|
|
206
|
-
it("Update no content to empty inline content", () => {
|
|
207
|
-
updateBlock(getEditor(), "image-0", {
|
|
208
|
-
type: "paragraph",
|
|
209
|
-
});
|
|
210
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
211
|
-
});
|
|
212
|
-
it("Update no content to inline content", () => {
|
|
213
|
-
updateBlock(getEditor(), "image-0", {
|
|
214
|
-
type: "paragraph",
|
|
215
|
-
content: "Paragraph",
|
|
216
|
-
});
|
|
217
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
218
|
-
});
|
|
219
|
-
it("Update no content to empty table content", () => {
|
|
220
|
-
updateBlock(getEditor(), "image-0", {
|
|
221
|
-
type: "table",
|
|
222
|
-
});
|
|
223
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
224
|
-
});
|
|
225
|
-
it("Update no content to table content", () => {
|
|
226
|
-
updateBlock(getEditor(), "image-0", {
|
|
227
|
-
type: "table",
|
|
228
|
-
content: {
|
|
229
|
-
type: "tableContent",
|
|
230
|
-
rows: [
|
|
231
|
-
{
|
|
232
|
-
cells: ["Cell 1", "Cell 2", "Cell 3"],
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
cells: ["Cell 4", "Cell 5", "Cell 6"],
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
cells: ["Cell 7", "Cell 8", "Cell 9"],
|
|
239
|
-
},
|
|
240
|
-
],
|
|
241
|
-
},
|
|
242
|
-
});
|
|
243
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
244
|
-
});
|
|
245
|
-
it("Update table content to no content", () => {
|
|
246
|
-
updateBlock(getEditor(), "table-0", {
|
|
247
|
-
type: "image",
|
|
248
|
-
});
|
|
249
|
-
expect(getEditor().document).toMatchSnapshot();
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
//# sourceMappingURL=updateBlock.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"updateBlock.test.js","sourceRoot":"","sources":["../../../../../../src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,O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AAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC;qBACtC;oBACD;wBACE,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC;qBACtC;iBACF;aACF;SACF,CAAC,CAAC;QAEH,MAAM,CAAC,SAAS,EAAE,CAAC,QAAQ,CAAC,CAAC,eAAe,EAAE,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,WAAW,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE;YAClC,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;QAEH,MAAM,CAAC,SAAS,EAAE,CAAC,QAAQ,CAAC,CAAC,eAAe,EAAE,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { nodeToBlock } from "../../nodeConversions/nodeToBlock.js";
|
|
2
|
-
import { getNodeById } from "../../nodeUtil.js";
|
|
3
|
-
export function getBlock(editor, blockIdentifier) {
|
|
4
|
-
const id = typeof blockIdentifier === "string" ? blockIdentifier : blockIdentifier.id;
|
|
5
|
-
const posInfo = getNodeById(id, editor._tiptapEditor.state.doc);
|
|
6
|
-
if (!posInfo) {
|
|
7
|
-
return undefined;
|
|
8
|
-
}
|
|
9
|
-
return nodeToBlock(posInfo.node, editor.schema.blockSchema, editor.schema.inlineContentSchema, editor.schema.styleSchema, editor.blockCache);
|
|
10
|
-
}
|
|
11
|
-
export function getPrevBlock(editor, blockIdentifier) {
|
|
12
|
-
const id = typeof blockIdentifier === "string" ? blockIdentifier : blockIdentifier.id;
|
|
13
|
-
const posInfo = getNodeById(id, editor._tiptapEditor.state.doc);
|
|
14
|
-
if (!posInfo) {
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
const $posBeforeNode = editor._tiptapEditor.state.doc.resolve(posInfo.posBeforeNode);
|
|
18
|
-
const nodeToConvert = $posBeforeNode.nodeBefore;
|
|
19
|
-
if (!nodeToConvert) {
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
return nodeToBlock(nodeToConvert, editor.schema.blockSchema, editor.schema.inlineContentSchema, editor.schema.styleSchema, editor.blockCache);
|
|
23
|
-
}
|
|
24
|
-
export function getNextBlock(editor, blockIdentifier) {
|
|
25
|
-
const id = typeof blockIdentifier === "string" ? blockIdentifier : blockIdentifier.id;
|
|
26
|
-
const posInfo = getNodeById(id, editor._tiptapEditor.state.doc);
|
|
27
|
-
if (!posInfo) {
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
const $posAfterNode = editor._tiptapEditor.state.doc.resolve(posInfo.posBeforeNode + posInfo.node.nodeSize);
|
|
31
|
-
const nodeToConvert = $posAfterNode.nodeAfter;
|
|
32
|
-
if (!nodeToConvert) {
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
|
-
return nodeToBlock(nodeToConvert, editor.schema.blockSchema, editor.schema.inlineContentSchema, editor.schema.styleSchema, editor.blockCache);
|
|
36
|
-
}
|
|
37
|
-
export function getParentBlock(editor, blockIdentifier) {
|
|
38
|
-
const id = typeof blockIdentifier === "string" ? blockIdentifier : blockIdentifier.id;
|
|
39
|
-
const posInfo = getNodeById(id, editor._tiptapEditor.state.doc);
|
|
40
|
-
if (!posInfo) {
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
const $posBeforeNode = editor._tiptapEditor.state.doc.resolve(posInfo.posBeforeNode);
|
|
44
|
-
const parentNode = $posBeforeNode.node();
|
|
45
|
-
const grandparentNode = $posBeforeNode.node(-1);
|
|
46
|
-
const nodeToConvert = grandparentNode.type.name !== "doc"
|
|
47
|
-
? parentNode.type.name === "blockGroup"
|
|
48
|
-
? grandparentNode
|
|
49
|
-
: parentNode
|
|
50
|
-
: undefined;
|
|
51
|
-
if (!nodeToConvert) {
|
|
52
|
-
return undefined;
|
|
53
|
-
}
|
|
54
|
-
return nodeToBlock(nodeToConvert, editor.schema.blockSchema, editor.schema.inlineContentSchema, editor.schema.styleSchema, editor.blockCache);
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=getBlock.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getBlock.js","sourceRoot":"","sources":["../../../../../src/api/blockManipulation/getBlock/getBlock.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,UAAU,QAAQ,CAKtB,MAAsC,EACtC,eAAgC;IAEhC,MAAM,EAAE,GACN,OAAO,eAAe,KAAK,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,EAAE,CAAC;IAE7E,MAAM,OAAO,GAAG,WAAW,CAAC,EAAE,EAAE,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAChE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,WAAW,CAChB,OAAO,CAAC,IAAI,EACZ,MAAM,CAAC,MAAM,CAAC,WAAW,EACzB,MAAM,CAAC,MAAM,CAAC,mBAAmB,EACjC,MAAM,CAAC,MAAM,CAAC,WAAW,EACzB,MAAM,CAAC,UAAU,CAClB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY,CAK1B,MAAsC,EACtC,eAAgC;IAEhC,MAAM,EAAE,GACN,OAAO,eAAe,KAAK,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,EAAE,CAAC;IAE7E,MAAM,OAAO,GAAG,WAAW,CAAC,EAAE,EAAE,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAChE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,SAAS,CAAC;IACnB,C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AM,UAAU,cAAc,CAK5B,MAAsC,EACtC,eAAgC;IAEhC,MAAM,EAAE,GACN,OAAO,eAAe,KAAK,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,EAAE,CAAC;IAE7E,MAAM,OAAO,GAAG,WAAW,CAAC,EAAE,EAAE,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAChE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,cAAc,GAAG,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAC3D,OAAO,CAAC,aAAa,CACtB,CAAC;IACF,MAAM,UAAU,GAAG,cAAc,CAAC,IAAI,EAAE,CAAC;IACzC,MAAM,eAAe,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,MAAM,aAAa,GACjB,eAAe,CAAC,IAAI,CAAC,IAAI,KAAK,KAAK;QACjC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,KAAK,YAAY;YACrC,CAAC,CAAC,eAAe;YACjB,CAAC,CAAC,UAAU;QACd,CAAC,CAAC,SAAS,CAAC;IAChB,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,WAAW,CAChB,aAAa,EACb,MAAM,CAAC,MAAM,CAAC,WAAW,EACzB,MAAM,CAAC,MAAM,CAAC,mBAAmB,EACjC,MAAM,CAAC,MAAM,CAAC,WAAW,EACzB,MAAM,CAAC,UAAU,CAClB,CAAC;AACJ,CAAC"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { selectionToInsertionEnd } from "@tiptap/core";
|
|
2
|
-
// similar to tiptap insertContentAt
|
|
3
|
-
export function insertContentAt(position, nodes, editor, options = { updateSelection: true }) {
|
|
4
|
-
const tr = editor._tiptapEditor.state.tr;
|
|
5
|
-
// don’t dispatch an empty fragment because this can lead to strange errors
|
|
6
|
-
// if (content.toString() === "<>") {
|
|
7
|
-
// return true;
|
|
8
|
-
// }
|
|
9
|
-
let { from, to } = typeof position === "number"
|
|
10
|
-
? { from: position, to: position }
|
|
11
|
-
: { from: position.from, to: position.to };
|
|
12
|
-
let isOnlyTextContent = true;
|
|
13
|
-
let isOnlyBlockContent = true;
|
|
14
|
-
// const nodes = isFragment(content) ? content : [content];
|
|
15
|
-
let text = "";
|
|
16
|
-
nodes.forEach((node) => {
|
|
17
|
-
// check if added node is valid
|
|
18
|
-
node.check();
|
|
19
|
-
if (isOnlyTextContent && node.isText && node.marks.length === 0) {
|
|
20
|
-
text += node.text;
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
isOnlyTextContent = false;
|
|
24
|
-
}
|
|
25
|
-
isOnlyBlockContent = isOnlyBlockContent ? node.isBlock : false;
|
|
26
|
-
});
|
|
27
|
-
// check if we can replace the wrapping node by
|
|
28
|
-
// the newly inserted content
|
|
29
|
-
// example:
|
|
30
|
-
// replace an empty paragraph by an inserted image
|
|
31
|
-
// instead of inserting the image below the paragraph
|
|
32
|
-
if (from === to && isOnlyBlockContent) {
|
|
33
|
-
const { parent } = tr.doc.resolve(from);
|
|
34
|
-
const isEmptyTextBlock = parent.isTextblock && !parent.type.spec.code && !parent.childCount;
|
|
35
|
-
if (isEmptyTextBlock) {
|
|
36
|
-
from -= 1;
|
|
37
|
-
to += 1;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
// if there is only plain text we have to use `insertText`
|
|
41
|
-
// because this will keep the current marks
|
|
42
|
-
if (isOnlyTextContent) {
|
|
43
|
-
// if value is string, we can use it directly
|
|
44
|
-
// otherwise if it is an array, we have to join it
|
|
45
|
-
// if (Array.isArray(value)) {
|
|
46
|
-
// tr.insertText(value.map((v) => v.text || "").join(""), from, to);
|
|
47
|
-
// } else if (typeof value === "object" && !!value && !!value.text) {
|
|
48
|
-
// tr.insertText(value.text, from, to);
|
|
49
|
-
// } else {
|
|
50
|
-
// tr.insertText(value as string, from, to);
|
|
51
|
-
// }
|
|
52
|
-
tr.insertText(text, from, to);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
tr.replaceWith(from, to, nodes);
|
|
56
|
-
}
|
|
57
|
-
// set cursor at end of inserted content
|
|
58
|
-
if (options.updateSelection) {
|
|
59
|
-
selectionToInsertionEnd(tr, tr.steps.length - 1, -1);
|
|
60
|
-
}
|
|
61
|
-
editor.dispatch(tr);
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
//# sourceMappingURL=insertContentAt.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"insertContentAt.js","sourceRoot":"","sources":["../../../../src/api/blockManipulation/insertContentAt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAUvD,oCAAoC;AACpC,MAAM,UAAU,eAAe,CAK7B,QAAa,EACb,KAAa,EACb,MAAsC,EACtC,UAEI,EAAE,eAAe,EAAE,IAAI,EAAE;IAE7B,MAAM,EAAE,GAAG,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;IAEzC,2EAA2E;IAC3E,qCAAqC;IACrC,iBAAiB;IACjB,IAAI;IAEJ,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,GACd,OAAO,QAAQ,KAAK,QAAQ;QAC1B,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE;QAClC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC;IAE/C,IAAI,iBAAiB,GAAG,IAAI,CAAC;IAC7B,IAAI,kBAAkB,GAAG,IAAI,CAAC;IAC9B,2DAA2D;IAE3D,IAAI,IAAI,GAAG,EAAE,CAAC;IAEd,KAAK,CAAC,OAAO,CAAC,CA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ClC,CAAC;IAED,wCAAwC;IACxC,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;QAC5B,uBAAuB,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAEpB,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { TextSelection } from "prosemirror-state";
|
|
2
|
-
import { TableMap } from "prosemirror-tables";
|
|
3
|
-
import { getBlockInfo, getNearestBlockPos } from "../../getBlockInfoFromPos.js";
|
|
4
|
-
import { nodeToBlock } from "../../nodeConversions/nodeToBlock.js";
|
|
5
|
-
import { getNodeById } from "../../nodeUtil.js";
|
|
6
|
-
export function getSelection(editor) {
|
|
7
|
-
const state = editor._tiptapEditor.state;
|
|
8
|
-
// Return undefined if the selection is collapsed or a node is selected.
|
|
9
|
-
if (state.selection.empty || "node" in state.selection) {
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
const $startBlockBeforePos = state.doc.resolve(getNearestBlockPos(state.doc, state.selection.from).posBeforeNode);
|
|
13
|
-
const $endBlockBeforePos = state.doc.resolve(getNearestBlockPos(state.doc, state.selection.to).posBeforeNode);
|
|
14
|
-
// Converts the node at the given index and depth around `$startBlockBeforePos`
|
|
15
|
-
// to a block. Used to get blocks at given indices at the shared depth and
|
|
16
|
-
// at the depth of `$startBlockBeforePos`.
|
|
17
|
-
const indexToBlock = (index, depth) => {
|
|
18
|
-
const pos = $startBlockBeforePos.posAtIndex(index, depth);
|
|
19
|
-
const node = state.doc.resolve(pos).nodeAfter;
|
|
20
|
-
if (!node) {
|
|
21
|
-
throw new Error(`Error getting selection - node not found at position ${pos}`);
|
|
22
|
-
}
|
|
23
|
-
return nodeToBlock(node, editor.schema.blockSchema, editor.schema.inlineContentSchema, editor.schema.styleSchema, editor.blockCache);
|
|
24
|
-
};
|
|
25
|
-
const blocks = [];
|
|
26
|
-
// Minimum depth at which the blocks share a common ancestor.
|
|
27
|
-
const sharedDepth = $startBlockBeforePos.sharedDepth($endBlockBeforePos.pos);
|
|
28
|
-
const startIndex = $startBlockBeforePos.index(sharedDepth);
|
|
29
|
-
const endIndex = $endBlockBeforePos.index(sharedDepth);
|
|
30
|
-
// In most cases, we want to return the blocks spanned by the selection at the
|
|
31
|
-
// shared depth. However, when the block in which the selection starts is at a
|
|
32
|
-
// higher depth than the shared depth, we omit the first block at the shared
|
|
33
|
-
// depth. Instead, we include the first block at its depth, and any blocks at
|
|
34
|
-
// a higher index up to the shared depth. The following example illustrates
|
|
35
|
-
// this:
|
|
36
|
-
// - id-0
|
|
37
|
-
// - id-1
|
|
38
|
-
// - >|id-2
|
|
39
|
-
// - id-3
|
|
40
|
-
// - id-4
|
|
41
|
-
// - id-5
|
|
42
|
-
// - id-6
|
|
43
|
-
// - id-7
|
|
44
|
-
// - id-8
|
|
45
|
-
// - id-9|<
|
|
46
|
-
// - id-10
|
|
47
|
-
// Here, each block is represented by its ID, and the selection is represented
|
|
48
|
-
// by the `>|` and `|<` markers. So the selection starts in block `id-2` and
|
|
49
|
-
// ends in block `id-8`. In this case, the shared depth is 0, since the blocks
|
|
50
|
-
// `id-6`, `id-7`, and `id-8` set the shared depth, as they are the least
|
|
51
|
-
// nested blocks spanned by the selection. Therefore, these blocks are all
|
|
52
|
-
// added to the `blocks` array. However, the selection starts in block `id-2`,
|
|
53
|
-
// which is at a higher depth than the shared depth. So we add block `id-2` to
|
|
54
|
-
// the `blocks` array, as well as any later siblings (in this case, `id-3`),
|
|
55
|
-
// and move up one level of depth. The ancestor of block `id-2` at this depth
|
|
56
|
-
// is block `id-1`, so we add all its later siblings to the `blocks` array as
|
|
57
|
-
// well, again moving up one level of depth. Since we're now at the shared
|
|
58
|
-
// depth, we are done. The final `blocks` array for this example would be:
|
|
59
|
-
// [ id-2, id-3, id-4, id-6, id-7, id-8, id-9 ]
|
|
60
|
-
if ($startBlockBeforePos.depth > sharedDepth) {
|
|
61
|
-
// Adds the block that the selection starts in.
|
|
62
|
-
blocks.push(nodeToBlock($startBlockBeforePos.nodeAfter, editor.schema.blockSchema, editor.schema.inlineContentSchema, editor.schema.styleSchema, editor.blockCache));
|
|
63
|
-
// Traverses all depths from the depth of the block in which the selection
|
|
64
|
-
// starts, up to the shared depth.
|
|
65
|
-
for (let depth = $startBlockBeforePos.depth; depth > sharedDepth; depth--) {
|
|
66
|
-
const parentNode = $startBlockBeforePos.node(depth);
|
|
67
|
-
if (parentNode.type.isInGroup("childContainer")) {
|
|
68
|
-
const startIndexAtDepth = $startBlockBeforePos.index(depth) + 1;
|
|
69
|
-
const childCountAtDepth = $startBlockBeforePos.node(depth).childCount;
|
|
70
|
-
// Adds all blocks after the index of the block in which the selection
|
|
71
|
-
// starts (or its ancestors at lower depths).
|
|
72
|
-
for (let i = startIndexAtDepth; i < childCountAtDepth; i++) {
|
|
73
|
-
blocks.push(indexToBlock(i, depth));
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
// Adds the first block spanned by the selection at the shared depth.
|
|
80
|
-
blocks.push(indexToBlock(startIndex, sharedDepth));
|
|
81
|
-
}
|
|
82
|
-
// Adds all blocks spanned by the selection at the shared depth, excluding
|
|
83
|
-
// the first.
|
|
84
|
-
for (let i = startIndex + 1; i <= endIndex; i++) {
|
|
85
|
-
blocks.push(indexToBlock(i, sharedDepth));
|
|
86
|
-
}
|
|
87
|
-
if (blocks.length === 0) {
|
|
88
|
-
throw new Error(`Error getting selection - selection doesn't span any blocks (${state.selection})`);
|
|
89
|
-
}
|
|
90
|
-
return {
|
|
91
|
-
blocks,
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
export function setSelection(editor, startBlock, endBlock) {
|
|
95
|
-
const startBlockId = typeof startBlock === "string" ? startBlock : startBlock.id;
|
|
96
|
-
const endBlockId = typeof endBlock === "string" ? endBlock : endBlock.id;
|
|
97
|
-
if (startBlockId === endBlockId) {
|
|
98
|
-
throw new Error(`Attempting to set selection with the same anchor and head blocks (id ${startBlockId})`);
|
|
99
|
-
}
|
|
100
|
-
const doc = editor._tiptapEditor.state.doc;
|
|
101
|
-
const anchorPosInfo = getNodeById(startBlockId, doc);
|
|
102
|
-
if (!anchorPosInfo) {
|
|
103
|
-
throw new Error(`Block with ID ${startBlockId} not found`);
|
|
104
|
-
}
|
|
105
|
-
const headPosInfo = getNodeById(endBlockId, doc);
|
|
106
|
-
if (!headPosInfo) {
|
|
107
|
-
throw new Error(`Block with ID ${endBlockId} not found`);
|
|
108
|
-
}
|
|
109
|
-
const anchorBlockInfo = getBlockInfo(anchorPosInfo);
|
|
110
|
-
const headBlockInfo = getBlockInfo(headPosInfo);
|
|
111
|
-
const anchorBlockConfig = editor.schema.blockSchema[anchorBlockInfo.blockNoteType];
|
|
112
|
-
const headBlockConfig = editor.schema.blockSchema[headBlockInfo.blockNoteType];
|
|
113
|
-
if (!anchorBlockInfo.isBlockContainer ||
|
|
114
|
-
anchorBlockConfig.content === "none") {
|
|
115
|
-
throw new Error(`Attempting to set selection anchor in block without content (id ${startBlockId})`);
|
|
116
|
-
}
|
|
117
|
-
if (!headBlockInfo.isBlockContainer || headBlockConfig.content === "none") {
|
|
118
|
-
throw new Error(`Attempting to set selection anchor in block without content (id ${endBlockId})`);
|
|
119
|
-
}
|
|
120
|
-
let startPos;
|
|
121
|
-
let endPos;
|
|
122
|
-
if (anchorBlockConfig.content === "table") {
|
|
123
|
-
const tableMap = TableMap.get(anchorBlockInfo.blockContent.node);
|
|
124
|
-
const firstCellPos = anchorBlockInfo.blockContent.beforePos +
|
|
125
|
-
tableMap.positionAt(0, 0, anchorBlockInfo.blockContent.node) +
|
|
126
|
-
1;
|
|
127
|
-
startPos = firstCellPos + 2;
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
startPos = anchorBlockInfo.blockContent.beforePos + 1;
|
|
131
|
-
}
|
|
132
|
-
if (headBlockConfig.content === "table") {
|
|
133
|
-
const tableMap = TableMap.get(headBlockInfo.blockContent.node);
|
|
134
|
-
const lastCellPos = headBlockInfo.blockContent.beforePos +
|
|
135
|
-
tableMap.positionAt(tableMap.height - 1, tableMap.width - 1, headBlockInfo.blockContent.node) +
|
|
136
|
-
1;
|
|
137
|
-
const lastCellNodeSize = doc.resolve(lastCellPos).nodeAfter.nodeSize;
|
|
138
|
-
endPos = lastCellPos + lastCellNodeSize - 2;
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
endPos = headBlockInfo.blockContent.afterPos - 1;
|
|
142
|
-
}
|
|
143
|
-
// TODO: We should polish up the `MultipleNodeSelection` and use that instead.
|
|
144
|
-
// Right now it's missing a few things like a jsonID and styling to show
|
|
145
|
-
// which nodes are selected. `TextSelection` is ok for now, but has the
|
|
146
|
-
// restriction that the start/end blocks must have content.
|
|
147
|
-
editor._tiptapEditor.dispatch(editor._tiptapEditor.state.tr.setSelection(TextSelection.create(editor._tiptapEditor.state.doc, startPos, endPos)));
|
|
148
|
-
}
|
|
149
|
-
//# sourceMappingURL=selection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"selection.js","sourceRoot":"","sources":["../../../../../src/api/blockManipulation/selections/selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAW9C,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,UAAU,YAAY,CAK1B,MAAsC;IAEtC,MAAM,KAAK,GAAG,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC;IAEzC,w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, expect, it } from "vitest";
|
|
2
|
-
import { setupTestEnv } from "../setupTestEnv.js";
|
|
3
|
-
import { getSelection, setSelection } from "./selection.js";
|
|
4
|
-
const getEditor = setupTestEnv();
|
|
5
|
-
describe("Test getSelection & setSelection", () => {
|
|
6
|
-
it("Basic", () => {
|
|
7
|
-
setSelection(getEditor(), "paragraph-0", "paragraph-1");
|
|
8
|
-
expect(getSelection(getEditor())).toMatchSnapshot();
|
|
9
|
-
});
|
|
10
|
-
it("Starts in block with children", () => {
|
|
11
|
-
setSelection(getEditor(), "paragraph-with-children", "paragraph-2");
|
|
12
|
-
expect(getSelection(getEditor())).toMatchSnapshot();
|
|
13
|
-
});
|
|
14
|
-
it("Starts in nested block", () => {
|
|
15
|
-
setSelection(getEditor(), "nested-paragraph-0", "paragraph-2");
|
|
16
|
-
expect(getSelection(getEditor())).toMatchSnapshot();
|
|
17
|
-
});
|
|
18
|
-
it("Ends in block with children", () => {
|
|
19
|
-
setSelection(getEditor(), "paragraph-1", "paragraph-with-children");
|
|
20
|
-
expect(getSelection(getEditor())).toMatchSnapshot();
|
|
21
|
-
});
|
|
22
|
-
it("Ends in nested block", () => {
|
|
23
|
-
setSelection(getEditor(), "paragraph-1", "nested-paragraph-0");
|
|
24
|
-
expect(getSelection(getEditor())).toMatchSnapshot();
|
|
25
|
-
});
|
|
26
|
-
it("Contains block with children", () => {
|
|
27
|
-
setSelection(getEditor(), "paragraph-1", "paragraph-2");
|
|
28
|
-
expect(getSelection(getEditor())).toMatchSnapshot();
|
|
29
|
-
});
|
|
30
|
-
it("Starts in table", () => {
|
|
31
|
-
setSelection(getEditor(), "table-0", "paragraph-7");
|
|
32
|
-
expect(getSelection(getEditor())).toMatchSnapshot();
|
|
33
|
-
});
|
|
34
|
-
it("Ends in table", () => {
|
|
35
|
-
setSelection(getEditor(), "paragraph-6", "table-0");
|
|
36
|
-
expect(getSelection(getEditor())).toMatchSnapshot();
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
//# sourceMappingURL=selection.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"selection.test.js","sourceRoot":"","sources":["../../../../../src/api/blockManipulation/selections/selection.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE5D,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;AAEjC,QAAQ,CAAC,kCAAkC,EAAE,GAAG,EAAE;IAChD,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;QACf,YAAY,CAAC,SAAS,EAAE,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC;QAExD,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;QACvC,YAAY,CAAC,SAAS,EAAE,EAAE,yBAAyB,EAAE,aAAa,CAAC,CAAC;QAEpE,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE;QAChC,YAAY,CAAC,SAAS,EAAE,EAAE,oBAAoB,EAAE,aAAa,CAAC,CAAC;QAE/D,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACrC,YAAY,CAAC,SAAS,EAAE,EAAE,aAAa,EAAE,yBAAyB,CAAC,CAAC;QAEpE,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC,CA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