@blocknote/core 0.20.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocknote.js +1602 -1569
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +6 -6
- 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/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +3 -3
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +1 -3
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +1 -1
- package/src/api/blockManipulation/selections/selection.ts +5 -5
- package/src/api/clipboard/__snapshots__/external/pasteEndOfParagraph.html +96 -0
- package/src/api/clipboard/__snapshots__/external/pasteEndOfParagraphText.html +96 -0
- package/src/api/clipboard/__snapshots__/external/pasteImage.html +111 -0
- package/src/api/clipboard/__snapshots__/external/pasteParagraphInCustomBlock.html +96 -0
- package/src/api/clipboard/__snapshots__/external/pasteTable.html +149 -0
- package/src/api/clipboard/__snapshots__/external/pasteTableInExistingTable.html +124 -0
- package/src/api/clipboard/__snapshots__/internal/paragraphInCustomBlock.html +1 -0
- package/src/api/clipboard/__snapshots__/internal/tableAllCells.html +1 -0
- package/src/api/clipboard/__snapshots__/internal/tableCell.html +1 -0
- package/src/api/clipboard/__snapshots__/internal/tableRow.html +1 -0
- package/src/api/clipboard/clipboardExternal.test.ts +161 -0
- package/src/api/clipboard/{clipboard.test.ts → clipboardInternal.test.ts} +66 -40
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +1 -1
- package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +7 -14
- package/src/api/clipboard/fromClipboard/pasteExtension.ts +6 -6
- package/src/api/clipboard/testUtil.ts +27 -0
- package/src/api/clipboard/toClipboard/copyExtension.ts +8 -2
- package/src/api/exporters/html/__snapshots__/file/basic/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/file/nested/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/file/noCaption/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/file/noName/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/basic/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/nested/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/noCaption/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/noName/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/noPreview/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/basic/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/basic/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/nested/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/nested/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noCaption/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noCaption/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noName/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noName/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noPreview/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noPreview/internal.html +1 -1
- 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__/simpleImage/basic/markdown.md +1 -1
- package/src/api/exporters/markdown/__snapshots__/simpleImage/nested/markdown.md +2 -2
- package/src/api/exporters/markdown/__snapshots__/simpleImage/noCaption/markdown.md +1 -1
- package/src/api/exporters/markdown/__snapshots__/simpleImage/noName/markdown.md +1 -1
- package/src/api/nodeConversions/nodeToBlock.ts +4 -1
- package/src/api/parsers/markdown/__snapshots__/pasted/styled.json +2 -2
- package/src/api/parsers/markdown/parseMarkdown.test.ts +5 -7
- package/src/api/testUtil/partialBlockTestUtil.ts +4 -1
- package/src/blocks/AudioBlockContent/AudioBlockContent.ts +13 -14
- package/src/blocks/FileBlockContent/FileBlockContent.ts +5 -12
- package/src/blocks/FileBlockContent/helpers/parse/parseEmbedElement.ts +5 -0
- package/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.ts +16 -0
- package/src/blocks/FileBlockContent/helpers/render/createAddFileButton.ts +63 -0
- package/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.ts +80 -0
- package/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.ts +24 -0
- package/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.ts +204 -0
- package/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.ts +13 -0
- package/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.ts +15 -0
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +3 -19
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +20 -28
- package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +3 -15
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +11 -3
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +25 -5
- package/src/blocks/VideoBlockContent/VideoBlockContent.ts +20 -27
- package/src/editor/Block.css +38 -54
- package/src/editor/BlockNoteEditor.test.ts +21 -1
- package/src/editor/BlockNoteEditor.ts +14 -7
- package/src/editor/BlockNoteExtensions.ts +7 -8
- package/src/editor/editor.css +7 -6
- package/src/editor/transformPasted.ts +57 -4
- package/src/extensions/LinkToolbar/protocols.ts +13 -0
- package/src/extensions/Placeholder/PlaceholderPlugin.ts +6 -6
- package/src/extensions/SideMenu/SideMenuPlugin.ts +5 -1
- package/src/extensions/SideMenu/dragging.ts +3 -0
- package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +3 -6
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +15 -3
- package/src/index.ts +9 -2
- package/src/schema/blocks/createSpec.ts +1 -1
- package/src/schema/blocks/internal.ts +16 -6
- package/src/schema/inlineContent/createSpec.ts +2 -2
- 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/fromClipboard/handleVSCodePaste.d.ts +2 -3
- package/types/src/api/clipboard/fromClipboard/pasteExtension.d.ts +1 -3
- package/types/src/api/clipboard/testUtil.d.ts +509 -0
- package/types/src/api/testUtil/cases/customBlocks.d.ts +8 -0
- package/types/src/api/testUtil/cases/customInlineContent.d.ts +8 -0
- package/types/src/api/testUtil/cases/customStyles.d.ts +8 -0
- package/types/src/blocks/AudioBlockContent/AudioBlockContent.d.ts +2 -5
- package/types/src/blocks/FileBlockContent/FileBlockContent.d.ts +2 -5
- package/types/src/blocks/FileBlockContent/helpers/parse/parseEmbedElement.d.ts +3 -0
- package/types/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.d.ts +4 -0
- package/types/src/blocks/FileBlockContent/helpers/render/createAddFileButton.d.ts +6 -0
- package/types/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.d.ts +9 -0
- package/types/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.d.ts +6 -0
- package/types/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.d.ts +9 -0
- package/types/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.d.ts +3 -0
- package/types/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.d.ts +3 -0
- package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +2 -5
- package/types/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +12 -0
- package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +2 -5
- package/types/src/blocks/defaultBlocks.d.ts +16 -0
- package/types/src/editor/BlockNoteEditor.d.ts +6 -4
- package/types/src/editor/transformPasted.d.ts +8 -4
- package/types/src/extensions/LinkToolbar/protocols.d.ts +2 -0
- package/types/src/index.d.ts +9 -2
- 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 -246
- 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 -26
- 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 -132
- 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 -109
- 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 -97
- package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js.map +0 -1
- package/dist/src/blocks/AudioBlockContent/audioBlockHelpers.js +0 -5
- package/dist/src/blocks/AudioBlockContent/audioBlockHelpers.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 -70
- package/dist/src/blocks/FileBlockContent/FileBlockContent.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/fileBlockHelpers.js +0 -317
- package/dist/src/blocks/FileBlockContent/fileBlockHelpers.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 -106
- package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js.map +0 -1
- package/dist/src/blocks/ImageBlockContent/imageBlockHelpers.js +0 -6
- package/dist/src/blocks/ImageBlockContent/imageBlockHelpers.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 -103
- package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js.map +0 -1
- package/dist/src/blocks/VideoBlockContent/videoBlockHelpers.js +0 -6
- package/dist/src/blocks/VideoBlockContent/videoBlockHelpers.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 -748
- 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 -196
- 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/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 -343
- package/dist/src/extensions/SideMenu/SideMenuPlugin.js.map +0 -1
- package/dist/src/extensions/SideMenu/dragging.js +0 -132
- 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 -570
- 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 -56
- 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__/tableAllCells.html +0 -1
- package/src/api/clipboard/__snapshots__/tableCell.html +0 -1
- package/src/api/clipboard/__snapshots__/tableRow.html +0 -1
- package/src/blocks/FileBlockContent/fileBlockHelpers.ts +0 -456
- package/types/src/blocks/FileBlockContent/fileBlockHelpers.d.ts +0 -41
- /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__/{tableCellText.html → internal/tableCellText.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{unstyledText.html → internal/unstyledText.html} +0 -0
- /package/src/blocks/AudioBlockContent/{audioBlockHelpers.ts → parseAudioElement.ts} +0 -0
- /package/src/blocks/ImageBlockContent/{imageBlockHelpers.ts → parseImageElement.ts} +0 -0
- /package/src/blocks/VideoBlockContent/{videoBlockHelpers.ts → parseVideoElement.ts} +0 -0
- /package/types/src/api/clipboard/{clipboard.test.d.ts → clipboardExternal.test.d.ts} +0 -0
- /package/types/src/blocks/AudioBlockContent/{audioBlockHelpers.d.ts → parseAudioElement.d.ts} +0 -0
- /package/types/src/blocks/ImageBlockContent/{imageBlockHelpers.d.ts → parseImageElement.d.ts} +0 -0
- /package/types/src/blocks/VideoBlockContent/{videoBlockHelpers.d.ts → parseVideoElement.d.ts} +0 -0
|
@@ -139,6 +139,10 @@ declare const schema: BlockNoteSchema<import("../../../index.js").BlockSchemaFro
|
|
|
139
139
|
type: "numberedListItem";
|
|
140
140
|
content: "inline";
|
|
141
141
|
propSchema: {
|
|
142
|
+
start: {
|
|
143
|
+
default: undefined;
|
|
144
|
+
type: "number";
|
|
145
|
+
};
|
|
142
146
|
backgroundColor: {
|
|
143
147
|
default: "default";
|
|
144
148
|
};
|
|
@@ -155,6 +159,10 @@ declare const schema: BlockNoteSchema<import("../../../index.js").BlockSchemaFro
|
|
|
155
159
|
type: "numberedListItem";
|
|
156
160
|
content: "inline";
|
|
157
161
|
propSchema: {
|
|
162
|
+
start: {
|
|
163
|
+
default: undefined;
|
|
164
|
+
type: "number";
|
|
165
|
+
};
|
|
158
166
|
backgroundColor: {
|
|
159
167
|
default: "default";
|
|
160
168
|
};
|
|
@@ -42,11 +42,8 @@ export declare const audioBlockConfig: {
|
|
|
42
42
|
fileBlockAccept: string[];
|
|
43
43
|
};
|
|
44
44
|
export declare const audioRender: (block: BlockFromConfig<typeof audioBlockConfig, any, any>, editor: BlockNoteEditor<any, any, any>) => {
|
|
45
|
-
dom:
|
|
46
|
-
destroy?: undefined;
|
|
47
|
-
} | {
|
|
48
|
-
dom: HTMLDivElement;
|
|
49
|
-
destroy: (() => void) | undefined;
|
|
45
|
+
dom: HTMLElement;
|
|
46
|
+
destroy?: (() => void) | undefined;
|
|
50
47
|
};
|
|
51
48
|
export declare const audioParse: (element: HTMLElement) => Partial<Props<typeof audioBlockConfig.propSchema>> | undefined;
|
|
52
49
|
export declare const audioToExternalHTML: (block: BlockFromConfig<typeof audioBlockConfig, any, any>) => {
|
|
@@ -34,11 +34,8 @@ export declare const fileBlockConfig: {
|
|
|
34
34
|
isFileBlock: true;
|
|
35
35
|
};
|
|
36
36
|
export declare const fileRender: (block: BlockFromConfig<typeof fileBlockConfig, any, any>, editor: BlockNoteEditor<any, any, any>) => {
|
|
37
|
-
dom:
|
|
38
|
-
destroy?: undefined;
|
|
39
|
-
} | {
|
|
40
|
-
dom: HTMLDivElement;
|
|
41
|
-
destroy: (() => void) | undefined;
|
|
37
|
+
dom: HTMLElement;
|
|
38
|
+
destroy?: (() => void) | undefined;
|
|
42
39
|
};
|
|
43
40
|
export declare const fileParse: (element: HTMLElement) => {
|
|
44
41
|
url: string | undefined;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BlockNoteEditor } from "../../../../editor/BlockNoteEditor.js";
|
|
2
|
+
import { BlockFromConfig, FileBlockConfig } from "../../../../schema/index.js";
|
|
3
|
+
export declare const createAddFileButton: (block: BlockFromConfig<FileBlockConfig, any, any>, editor: BlockNoteEditor<any, any, any>, buttonText?: string, buttonIcon?: HTMLElement) => {
|
|
4
|
+
dom: HTMLDivElement;
|
|
5
|
+
destroy: () => void;
|
|
6
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BlockNoteEditor } from "../../../../editor/BlockNoteEditor.js";
|
|
2
|
+
import { BlockFromConfig, BlockSchemaWithBlock, FileBlockConfig } from "../../../../schema/index.js";
|
|
3
|
+
export declare const createFileBlockWrapper: (block: BlockFromConfig<FileBlockConfig, any, any>, editor: BlockNoteEditor<BlockSchemaWithBlock<FileBlockConfig["type"], FileBlockConfig>, any, any>, element?: {
|
|
4
|
+
dom: HTMLElement;
|
|
5
|
+
destroy?: () => void;
|
|
6
|
+
}, buttonText?: string, buttonIcon?: HTMLElement) => {
|
|
7
|
+
dom: HTMLElement;
|
|
8
|
+
destroy?: (() => void) | undefined;
|
|
9
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BlockFromConfig, FileBlockConfig } from "../../../../schema/index.js";
|
|
2
|
+
export declare const FILE_ICON_SVG = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z\"></path></svg>";
|
|
3
|
+
export declare const createFileNameWithIcon: (block: BlockFromConfig<FileBlockConfig, any, any>) => {
|
|
4
|
+
dom: HTMLElement;
|
|
5
|
+
destroy?: () => void;
|
|
6
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BlockNoteEditor } from "../../../../editor/BlockNoteEditor.js";
|
|
2
|
+
import { BlockFromConfig, FileBlockConfig } from "../../../../schema/index.js";
|
|
3
|
+
export declare const createResizableFileBlockWrapper: (block: BlockFromConfig<FileBlockConfig, any, any>, editor: BlockNoteEditor<any, any, any>, element: {
|
|
4
|
+
dom: HTMLElement;
|
|
5
|
+
destroy?: () => void;
|
|
6
|
+
}, resizeHandlesContainerElement: HTMLElement, buttonText: string, buttonIcon: HTMLElement) => {
|
|
7
|
+
dom: HTMLElement;
|
|
8
|
+
destroy: () => void;
|
|
9
|
+
};
|
|
@@ -56,11 +56,8 @@ export declare const imageBlockConfig: {
|
|
|
56
56
|
fileBlockAccept: string[];
|
|
57
57
|
};
|
|
58
58
|
export declare const imageRender: (block: BlockFromConfig<typeof imageBlockConfig, any, any>, editor: BlockNoteEditor<any, any, any>) => {
|
|
59
|
-
dom:
|
|
60
|
-
destroy
|
|
61
|
-
} | {
|
|
62
|
-
dom: HTMLDivElement;
|
|
63
|
-
destroy: (() => void) | undefined;
|
|
59
|
+
dom: HTMLElement;
|
|
60
|
+
destroy: () => void;
|
|
64
61
|
};
|
|
65
62
|
export declare const imageParse: (element: HTMLElement) => Partial<Props<typeof imageBlockConfig.propSchema>> | undefined;
|
|
66
63
|
export declare const imageToExternalHTML: (block: BlockFromConfig<typeof imageBlockConfig, any, any>) => {
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export declare const numberedListItemPropSchema: {
|
|
2
|
+
start: {
|
|
3
|
+
default: undefined;
|
|
4
|
+
type: "number";
|
|
5
|
+
};
|
|
2
6
|
backgroundColor: {
|
|
3
7
|
default: "default";
|
|
4
8
|
};
|
|
@@ -15,6 +19,10 @@ export declare const NumberedListItem: {
|
|
|
15
19
|
type: "numberedListItem";
|
|
16
20
|
content: "inline";
|
|
17
21
|
propSchema: {
|
|
22
|
+
start: {
|
|
23
|
+
default: undefined;
|
|
24
|
+
type: "number";
|
|
25
|
+
};
|
|
18
26
|
backgroundColor: {
|
|
19
27
|
default: "default";
|
|
20
28
|
};
|
|
@@ -31,6 +39,10 @@ export declare const NumberedListItem: {
|
|
|
31
39
|
type: "numberedListItem";
|
|
32
40
|
content: "inline";
|
|
33
41
|
propSchema: {
|
|
42
|
+
start: {
|
|
43
|
+
default: undefined;
|
|
44
|
+
type: "number";
|
|
45
|
+
};
|
|
34
46
|
backgroundColor: {
|
|
35
47
|
default: "default";
|
|
36
48
|
};
|
|
@@ -56,11 +56,8 @@ export declare const videoBlockConfig: {
|
|
|
56
56
|
fileBlockAccept: string[];
|
|
57
57
|
};
|
|
58
58
|
export declare const videoRender: (block: BlockFromConfig<typeof videoBlockConfig, any, any>, editor: BlockNoteEditor<any, any, any>) => {
|
|
59
|
-
dom:
|
|
60
|
-
destroy
|
|
61
|
-
} | {
|
|
62
|
-
dom: HTMLDivElement;
|
|
63
|
-
destroy: (() => void) | undefined;
|
|
59
|
+
dom: HTMLElement;
|
|
60
|
+
destroy: () => void;
|
|
64
61
|
};
|
|
65
62
|
export declare const videoParse: (element: HTMLElement) => Partial<Props<typeof videoBlockConfig.propSchema>> | undefined;
|
|
66
63
|
export declare const videoToExternalHTML: (block: BlockFromConfig<typeof videoBlockConfig, any, any>) => {
|
|
@@ -138,6 +138,10 @@ export declare const defaultBlockSpecs: {
|
|
|
138
138
|
type: "numberedListItem";
|
|
139
139
|
content: "inline";
|
|
140
140
|
propSchema: {
|
|
141
|
+
start: {
|
|
142
|
+
default: undefined;
|
|
143
|
+
type: "number";
|
|
144
|
+
};
|
|
141
145
|
backgroundColor: {
|
|
142
146
|
default: "default";
|
|
143
147
|
};
|
|
@@ -154,6 +158,10 @@ export declare const defaultBlockSpecs: {
|
|
|
154
158
|
type: "numberedListItem";
|
|
155
159
|
content: "inline";
|
|
156
160
|
propSchema: {
|
|
161
|
+
start: {
|
|
162
|
+
default: undefined;
|
|
163
|
+
type: "number";
|
|
164
|
+
};
|
|
157
165
|
backgroundColor: {
|
|
158
166
|
default: "default";
|
|
159
167
|
};
|
|
@@ -578,6 +586,10 @@ export declare const defaultBlockSchema: import("../schema/index.js").BlockSchem
|
|
|
578
586
|
type: "numberedListItem";
|
|
579
587
|
content: "inline";
|
|
580
588
|
propSchema: {
|
|
589
|
+
start: {
|
|
590
|
+
default: undefined;
|
|
591
|
+
type: "number";
|
|
592
|
+
};
|
|
581
593
|
backgroundColor: {
|
|
582
594
|
default: "default";
|
|
583
595
|
};
|
|
@@ -594,6 +606,10 @@ export declare const defaultBlockSchema: import("../schema/index.js").BlockSchem
|
|
|
594
606
|
type: "numberedListItem";
|
|
595
607
|
content: "inline";
|
|
596
608
|
propSchema: {
|
|
609
|
+
start: {
|
|
610
|
+
default: undefined;
|
|
611
|
+
type: "number";
|
|
612
|
+
};
|
|
597
613
|
backgroundColor: {
|
|
598
614
|
default: "default";
|
|
599
615
|
};
|
|
@@ -17,6 +17,7 @@ import { BlockNoteTipTapEditor } from "./BlockNoteTipTapEditor.js";
|
|
|
17
17
|
import { Dictionary } from "../i18n/dictionary.js";
|
|
18
18
|
import { Plugin, Transaction } from "@tiptap/pm/state";
|
|
19
19
|
import "../style.css";
|
|
20
|
+
import { EditorView } from "prosemirror-view";
|
|
20
21
|
export type BlockNoteExtension = AnyExtension | {
|
|
21
22
|
plugin: Plugin;
|
|
22
23
|
};
|
|
@@ -153,7 +154,8 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
153
154
|
* You probably don't need to set this manually, but use the `server-util` package instead that uses this option internally
|
|
154
155
|
*/
|
|
155
156
|
readonly headless: boolean;
|
|
156
|
-
readonly _tiptapEditor: BlockNoteTipTapEditor & {
|
|
157
|
+
readonly _tiptapEditor: Omit<BlockNoteTipTapEditor, "view"> & {
|
|
158
|
+
view: EditorView | undefined;
|
|
157
159
|
contentComponent: any;
|
|
158
160
|
};
|
|
159
161
|
/**
|
|
@@ -196,7 +198,7 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
196
198
|
readonly uploadFile: ((file: File, blockId?: string) => Promise<string | Record<string, any>>) | undefined;
|
|
197
199
|
private onUploadStartCallbacks;
|
|
198
200
|
private onUploadEndCallbacks;
|
|
199
|
-
readonly resolveFileUrl
|
|
201
|
+
readonly resolveFileUrl?: (url: string) => Promise<string>;
|
|
200
202
|
get pmSchema(): Schema<any, any>;
|
|
201
203
|
static create<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema>(options?: Partial<BlockNoteEditorOptions<BSchema, ISchema, SSchema>>): BlockNoteEditor<BSchema, ISchema, SSchema>;
|
|
202
204
|
protected constructor(options: Partial<BlockNoteEditorOptions<any, any, any>>);
|
|
@@ -207,8 +209,8 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
207
209
|
* @warning Not needed to call manually when using React, use BlockNoteView to take care of mounting
|
|
208
210
|
*/
|
|
209
211
|
mount: (parentElement?: HTMLElement | null) => void;
|
|
210
|
-
get prosemirrorView():
|
|
211
|
-
get domElement(): HTMLDivElement;
|
|
212
|
+
get prosemirrorView(): EditorView | undefined;
|
|
213
|
+
get domElement(): HTMLDivElement | undefined;
|
|
212
214
|
isFocused(): boolean;
|
|
213
215
|
focus(): void;
|
|
214
216
|
onUploadStart(callback: (blockId?: string) => void): () => void;
|
|
@@ -10,10 +10,14 @@ export declare function wrapTableRows(f: Fragment, schema: Schema): Fragment;
|
|
|
10
10
|
/**
|
|
11
11
|
* fix for https://github.com/ProseMirror/prosemirror/issues/1430#issuecomment-1822570821
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* This fix wraps pasted ProseMirror nodes in their own `blockContainer` nodes
|
|
14
|
+
* in most cases. This is to ensure that ProseMirror inserts them as separate
|
|
15
|
+
* blocks, which it sometimes doesn't do because it doesn't have enough context
|
|
16
|
+
* about the hierarchy of the pasted nodes. The issue can be seen when pasting
|
|
17
|
+
* e.g. an image or two consecutive paragraphs, where PM tries to nest the
|
|
18
|
+
* pasted block(s) when it shouldn't.
|
|
16
19
|
*
|
|
17
|
-
*
|
|
20
|
+
* However, the fix is not applied in a few cases. See `shouldApplyFix` for
|
|
21
|
+
* which cases are excluded.
|
|
18
22
|
*/
|
|
19
23
|
export declare function transformPasted(slice: Slice, view: EditorView): Slice;
|
package/types/src/index.d.ts
CHANGED
|
@@ -7,10 +7,16 @@ export * from "./api/testUtil/index.js";
|
|
|
7
7
|
export * from "./blocks/AudioBlockContent/AudioBlockContent.js";
|
|
8
8
|
export * from "./blocks/CodeBlockContent/CodeBlockContent.js";
|
|
9
9
|
export * from "./blocks/FileBlockContent/FileBlockContent.js";
|
|
10
|
-
export * from "./blocks/FileBlockContent/
|
|
10
|
+
export * from "./blocks/FileBlockContent/helpers/parse/parseEmbedElement.js";
|
|
11
|
+
export * from "./blocks/FileBlockContent/helpers/parse/parseFigureElement.js";
|
|
12
|
+
export * from "./blocks/FileBlockContent/helpers/render/createAddFileButton.js";
|
|
13
|
+
export * from "./blocks/FileBlockContent/helpers/render/createFileBlockWrapper.js";
|
|
14
|
+
export * from "./blocks/FileBlockContent/helpers/render/createFileNameWithIcon.js";
|
|
15
|
+
export * from "./blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.js";
|
|
16
|
+
export * from "./blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.js";
|
|
17
|
+
export * from "./blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.js";
|
|
11
18
|
export * from "./blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js";
|
|
12
19
|
export * from "./blocks/ImageBlockContent/ImageBlockContent.js";
|
|
13
|
-
export { parseImageElement } from "./blocks/ImageBlockContent/imageBlockHelpers.js";
|
|
14
20
|
export { EMPTY_CELL_HEIGHT, EMPTY_CELL_WIDTH, } from "./blocks/TableBlockContent/TableExtension.js";
|
|
15
21
|
export * from "./blocks/VideoBlockContent/VideoBlockContent.js";
|
|
16
22
|
export * from "./blocks/defaultBlockHelpers.js";
|
|
@@ -27,6 +33,7 @@ export * from "./extensions-shared/UiElementPosition.js";
|
|
|
27
33
|
export * from "./extensions/FilePanel/FilePanelPlugin.js";
|
|
28
34
|
export * from "./extensions/FormattingToolbar/FormattingToolbarPlugin.js";
|
|
29
35
|
export * from "./extensions/LinkToolbar/LinkToolbarPlugin.js";
|
|
36
|
+
export * from "./extensions/LinkToolbar/protocols.js";
|
|
30
37
|
export * from "./extensions/SideMenu/SideMenuPlugin.js";
|
|
31
38
|
export * from "./extensions/SuggestionMenu/DefaultGridSuggestionItem.js";
|
|
32
39
|
export * from "./extensions/SuggestionMenu/DefaultSuggestionItem.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,E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IACpE,sCAAsC;IACtC,MAAM,cAAc,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,iC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AAE,EAAE,EAAE;oBACnD,EAAE,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,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