@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
|
@@ -1,748 +0,0 @@
|
|
|
1
|
-
import { Extension, getSchema, Mark, Node as TipTapNode, } from "@tiptap/core";
|
|
2
|
-
import { getBlock, getNextBlock, getParentBlock, getPrevBlock, } from "../api/blockManipulation/getBlock/getBlock.js";
|
|
3
|
-
import { insertBlocks } from "../api/blockManipulation/commands/insertBlocks/insertBlocks.js";
|
|
4
|
-
import { moveBlocksDown, moveBlocksUp, } from "../api/blockManipulation/commands/moveBlocks/moveBlocks.js";
|
|
5
|
-
import { canNestBlock, canUnnestBlock, nestBlock, unnestBlock, } from "../api/blockManipulation/commands/nestBlock/nestBlock.js";
|
|
6
|
-
import { removeBlocks } from "../api/blockManipulation/commands/removeBlocks/removeBlocks.js";
|
|
7
|
-
import { replaceBlocks } from "../api/blockManipulation/commands/replaceBlocks/replaceBlocks.js";
|
|
8
|
-
import { updateBlock } from "../api/blockManipulation/commands/updateBlock/updateBlock.js";
|
|
9
|
-
import { insertContentAt } from "../api/blockManipulation/insertContentAt.js";
|
|
10
|
-
import { getTextCursorPosition, setTextCursorPosition, } from "../api/blockManipulation/selections/textCursorPosition/textCursorPosition.js";
|
|
11
|
-
import { getSelection, setSelection, } from "../api/blockManipulation/selections/selection.js";
|
|
12
|
-
import { createExternalHTMLExporter } from "../api/exporters/html/externalHTMLExporter.js";
|
|
13
|
-
import { blocksToMarkdown } from "../api/exporters/markdown/markdownExporter.js";
|
|
14
|
-
import { HTMLToBlocks } from "../api/parsers/html/parseHTML.js";
|
|
15
|
-
import { markdownToBlocks } from "../api/parsers/markdown/parseMarkdown.js";
|
|
16
|
-
import { UniqueID } from "../extensions/UniqueID/UniqueID.js";
|
|
17
|
-
import { mergeCSSClasses } from "../util/browser.js";
|
|
18
|
-
import { UnreachableCaseError } from "../util/typescript.js";
|
|
19
|
-
import { getBlockNoteExtensions } from "./BlockNoteExtensions.js";
|
|
20
|
-
import { transformPasted } from "./transformPasted.js";
|
|
21
|
-
import { checkDefaultBlockTypeInSchema } from "../blocks/defaultBlockTypeGuards.js";
|
|
22
|
-
import { BlockNoteSchema } from "./BlockNoteSchema.js";
|
|
23
|
-
import { BlockNoteTipTapEditor, } from "./BlockNoteTipTapEditor.js";
|
|
24
|
-
import { en } from "../i18n/locales/index.js";
|
|
25
|
-
import { dropCursor } from "prosemirror-dropcursor";
|
|
26
|
-
import { createInternalHTMLSerializer } from "../api/exporters/html/internalHTMLSerializer.js";
|
|
27
|
-
import { inlineContentToNodes } from "../api/nodeConversions/blockToNode.js";
|
|
28
|
-
import { nodeToBlock } from "../api/nodeConversions/nodeToBlock.js";
|
|
29
|
-
import "../style.css";
|
|
30
|
-
const blockNoteTipTapOptions = {
|
|
31
|
-
enableInputRules: true,
|
|
32
|
-
enablePasteRules: true,
|
|
33
|
-
enableCoreExtensions: false,
|
|
34
|
-
};
|
|
35
|
-
export class BlockNoteEditor {
|
|
36
|
-
options;
|
|
37
|
-
_pmSchema;
|
|
38
|
-
/**
|
|
39
|
-
* extensions that are added to the editor, can be tiptap extensions or prosemirror plugins
|
|
40
|
-
*/
|
|
41
|
-
extensions = {};
|
|
42
|
-
/**
|
|
43
|
-
* Boolean indicating whether the editor is in headless mode.
|
|
44
|
-
* Headless mode means we can use features like importing / exporting blocks,
|
|
45
|
-
* but there's no underlying editor (UI) instantiated.
|
|
46
|
-
*
|
|
47
|
-
* You probably don't need to set this manually, but use the `server-util` package instead that uses this option internally
|
|
48
|
-
*/
|
|
49
|
-
headless = false;
|
|
50
|
-
_tiptapEditor = undefined; // TODO: Type should actually reflect that it can be `undefined` in headless mode
|
|
51
|
-
/**
|
|
52
|
-
* Used by React to store a reference to an `ElementRenderer` helper utility to make sure we can render React elements
|
|
53
|
-
* in the correct context (used by `ReactRenderUtil`)
|
|
54
|
-
*/
|
|
55
|
-
elementRenderer = null;
|
|
56
|
-
/**
|
|
57
|
-
* Cache of all blocks. This makes sure we don't have to "recompute" blocks if underlying Prosemirror Nodes haven't changed.
|
|
58
|
-
* This is especially useful when we want to keep track of the same block across multiple operations,
|
|
59
|
-
* with this cache, blocks stay the same object reference (referential equality with ===).
|
|
60
|
-
*/
|
|
61
|
-
blockCache = new WeakMap();
|
|
62
|
-
/**
|
|
63
|
-
* The dictionary contains translations for the editor.
|
|
64
|
-
*/
|
|
65
|
-
dictionary;
|
|
66
|
-
/**
|
|
67
|
-
* The schema of the editor. The schema defines which Blocks, InlineContent, and Styles are available in the editor.
|
|
68
|
-
*/
|
|
69
|
-
schema;
|
|
70
|
-
blockImplementations;
|
|
71
|
-
inlineContentImplementations;
|
|
72
|
-
styleImplementations;
|
|
73
|
-
formattingToolbar;
|
|
74
|
-
linkToolbar;
|
|
75
|
-
sideMenu;
|
|
76
|
-
suggestionMenus;
|
|
77
|
-
filePanel;
|
|
78
|
-
tableHandles;
|
|
79
|
-
/**
|
|
80
|
-
* The `uploadFile` method is what the editor uses when files need to be uploaded (for example when selecting an image to upload).
|
|
81
|
-
* This method should set when creating the editor as this is application-specific.
|
|
82
|
-
*
|
|
83
|
-
* `undefined` means the application doesn't support file uploads.
|
|
84
|
-
*
|
|
85
|
-
* @param file The file that should be uploaded.
|
|
86
|
-
* @returns The URL of the uploaded file OR an object containing props that should be set on the file block (such as an id)
|
|
87
|
-
*/
|
|
88
|
-
uploadFile;
|
|
89
|
-
onUploadStartCallbacks = [];
|
|
90
|
-
onUploadEndCallbacks = [];
|
|
91
|
-
resolveFileUrl;
|
|
92
|
-
get pmSchema() {
|
|
93
|
-
return this._pmSchema;
|
|
94
|
-
}
|
|
95
|
-
static create(options = {}) {
|
|
96
|
-
return new BlockNoteEditor(options);
|
|
97
|
-
}
|
|
98
|
-
constructor(options) {
|
|
99
|
-
this.options = options;
|
|
100
|
-
const anyOpts = options;
|
|
101
|
-
if (anyOpts.onEditorContentChange) {
|
|
102
|
-
throw new Error("onEditorContentChange initialization option is deprecated, use <BlockNoteView onChange={...} />, the useEditorChange(...) hook, or editor.onChange(...)");
|
|
103
|
-
}
|
|
104
|
-
if (anyOpts.onTextCursorPositionChange) {
|
|
105
|
-
throw new Error("onTextCursorPositionChange initialization option is deprecated, use <BlockNoteView onSelectionChange={...} />, the useEditorSelectionChange(...) hook, or editor.onSelectionChange(...)");
|
|
106
|
-
}
|
|
107
|
-
if (anyOpts.onEditorReady) {
|
|
108
|
-
throw new Error("onEditorReady is deprecated. Editor is immediately ready for use after creation.");
|
|
109
|
-
}
|
|
110
|
-
if (anyOpts.editable) {
|
|
111
|
-
throw new Error("editable initialization option is deprecated, use <BlockNoteView editable={true/false} />, or alternatively editor.isEditable = true/false");
|
|
112
|
-
}
|
|
113
|
-
this.dictionary = options.dictionary || en;
|
|
114
|
-
// apply defaults
|
|
115
|
-
const newOptions = {
|
|
116
|
-
defaultStyles: true,
|
|
117
|
-
schema: options.schema || BlockNoteSchema.create(),
|
|
118
|
-
_headless: false,
|
|
119
|
-
...options,
|
|
120
|
-
placeholders: {
|
|
121
|
-
...this.dictionary.placeholders,
|
|
122
|
-
...options.placeholders,
|
|
123
|
-
},
|
|
124
|
-
};
|
|
125
|
-
// @ts-ignore
|
|
126
|
-
this.schema = newOptions.schema;
|
|
127
|
-
this.blockImplementations = newOptions.schema.blockSpecs;
|
|
128
|
-
this.inlineContentImplementations = newOptions.schema.inlineContentSpecs;
|
|
129
|
-
this.styleImplementations = newOptions.schema.styleSpecs;
|
|
130
|
-
this.extensions = getBlockNoteExtensions({
|
|
131
|
-
editor: this,
|
|
132
|
-
domAttributes: newOptions.domAttributes || {},
|
|
133
|
-
blockSpecs: this.schema.blockSpecs,
|
|
134
|
-
styleSpecs: this.schema.styleSpecs,
|
|
135
|
-
inlineContentSpecs: this.schema.inlineContentSpecs,
|
|
136
|
-
collaboration: newOptions.collaboration,
|
|
137
|
-
trailingBlock: newOptions.trailingBlock,
|
|
138
|
-
disableExtensions: newOptions.disableExtensions,
|
|
139
|
-
setIdAttribute: newOptions.setIdAttribute,
|
|
140
|
-
animations: newOptions.animations ?? true,
|
|
141
|
-
tableHandles: checkDefaultBlockTypeInSchema("table", this),
|
|
142
|
-
dropCursor: this.options.dropCursor ?? dropCursor,
|
|
143
|
-
placeholders: newOptions.placeholders,
|
|
144
|
-
tabBehavior: newOptions.tabBehavior,
|
|
145
|
-
});
|
|
146
|
-
// add extensions from _tiptapOptions
|
|
147
|
-
(newOptions._tiptapOptions?.extensions || []).forEach((ext) => {
|
|
148
|
-
this.extensions[ext.name] = ext;
|
|
149
|
-
});
|
|
150
|
-
// add extensions from options
|
|
151
|
-
Object.entries(newOptions._extensions || {}).forEach(([key, ext]) => {
|
|
152
|
-
this.extensions[key] = ext;
|
|
153
|
-
});
|
|
154
|
-
this.formattingToolbar = this.extensions["formattingToolbar"];
|
|
155
|
-
this.linkToolbar = this.extensions["linkToolbar"];
|
|
156
|
-
this.sideMenu = this.extensions["sideMenu"];
|
|
157
|
-
this.suggestionMenus = this.extensions["suggestionMenus"];
|
|
158
|
-
this.filePanel = this.extensions["filePanel"];
|
|
159
|
-
this.tableHandles = this.extensions["tableHandles"];
|
|
160
|
-
if (newOptions.uploadFile) {
|
|
161
|
-
const uploadFile = newOptions.uploadFile;
|
|
162
|
-
this.uploadFile = async (file, block) => {
|
|
163
|
-
this.onUploadStartCallbacks.forEach((callback) => callback.apply(this, [block]));
|
|
164
|
-
try {
|
|
165
|
-
return await uploadFile(file, block);
|
|
166
|
-
}
|
|
167
|
-
finally {
|
|
168
|
-
this.onUploadEndCallbacks.forEach((callback) => callback.apply(this, [block]));
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
this.resolveFileUrl = newOptions.resolveFileUrl || (async (url) => url);
|
|
173
|
-
this.headless = newOptions._headless;
|
|
174
|
-
if (newOptions.collaboration && newOptions.initialContent) {
|
|
175
|
-
// eslint-disable-next-line no-console
|
|
176
|
-
console.warn("When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider");
|
|
177
|
-
}
|
|
178
|
-
const initialContent = newOptions.initialContent ||
|
|
179
|
-
(options.collaboration
|
|
180
|
-
? [
|
|
181
|
-
{
|
|
182
|
-
type: "paragraph",
|
|
183
|
-
id: "initialBlockId",
|
|
184
|
-
},
|
|
185
|
-
]
|
|
186
|
-
: [
|
|
187
|
-
{
|
|
188
|
-
type: "paragraph",
|
|
189
|
-
id: UniqueID.options.generateID(),
|
|
190
|
-
},
|
|
191
|
-
]);
|
|
192
|
-
if (!Array.isArray(initialContent) || initialContent.length === 0) {
|
|
193
|
-
throw new Error("initialContent must be a non-empty array of blocks, received: " +
|
|
194
|
-
initialContent);
|
|
195
|
-
}
|
|
196
|
-
const tiptapExtensions = [
|
|
197
|
-
...Object.entries(this.extensions).map(([key, ext]) => {
|
|
198
|
-
if (ext instanceof Extension ||
|
|
199
|
-
ext instanceof TipTapNode ||
|
|
200
|
-
ext instanceof Mark) {
|
|
201
|
-
// tiptap extension
|
|
202
|
-
return ext;
|
|
203
|
-
}
|
|
204
|
-
if (!ext.plugin) {
|
|
205
|
-
throw new Error("Extension should either be a TipTap extension or a ProseMirror plugin in a plugin property");
|
|
206
|
-
}
|
|
207
|
-
// "blocknote" extensions (prosemirror plugins)
|
|
208
|
-
return Extension.create({
|
|
209
|
-
name: key,
|
|
210
|
-
addProseMirrorPlugins: () => [ext.plugin],
|
|
211
|
-
});
|
|
212
|
-
}),
|
|
213
|
-
];
|
|
214
|
-
const tiptapOptions = {
|
|
215
|
-
...blockNoteTipTapOptions,
|
|
216
|
-
...newOptions._tiptapOptions,
|
|
217
|
-
content: initialContent,
|
|
218
|
-
extensions: tiptapExtensions,
|
|
219
|
-
editorProps: {
|
|
220
|
-
...newOptions._tiptapOptions?.editorProps,
|
|
221
|
-
attributes: {
|
|
222
|
-
// As of TipTap v2.5.0 the tabIndex is removed when the editor is not
|
|
223
|
-
// editable, so you can't focus it. We want to revert this as we have
|
|
224
|
-
// UI behaviour that relies on it.
|
|
225
|
-
tabIndex: "0",
|
|
226
|
-
...newOptions._tiptapOptions?.editorProps?.attributes,
|
|
227
|
-
...newOptions.domAttributes?.editor,
|
|
228
|
-
class: mergeCSSClasses("bn-editor", newOptions.defaultStyles ? "bn-default-styles" : "", newOptions.domAttributes?.editor?.class || ""),
|
|
229
|
-
},
|
|
230
|
-
transformPasted,
|
|
231
|
-
},
|
|
232
|
-
};
|
|
233
|
-
if (!this.headless) {
|
|
234
|
-
this._tiptapEditor = BlockNoteTipTapEditor.create(tiptapOptions, this.schema.styleSchema);
|
|
235
|
-
this._pmSchema = this._tiptapEditor.schema;
|
|
236
|
-
}
|
|
237
|
-
else {
|
|
238
|
-
// In headless mode, we don't instantiate an underlying TipTap editor,
|
|
239
|
-
// but we still need the schema
|
|
240
|
-
this._pmSchema = getSchema(tiptapOptions.extensions);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
dispatch(tr) {
|
|
244
|
-
this._tiptapEditor.dispatch(tr);
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Mount the editor to a parent DOM element. Call mount(undefined) to clean up
|
|
248
|
-
*
|
|
249
|
-
* @warning Not needed to call manually when using React, use BlockNoteView to take care of mounting
|
|
250
|
-
*/
|
|
251
|
-
mount = (parentElement) => {
|
|
252
|
-
this._tiptapEditor.mount(parentElement);
|
|
253
|
-
};
|
|
254
|
-
get prosemirrorView() {
|
|
255
|
-
return this._tiptapEditor.view;
|
|
256
|
-
}
|
|
257
|
-
get domElement() {
|
|
258
|
-
return this._tiptapEditor.view.dom;
|
|
259
|
-
}
|
|
260
|
-
isFocused() {
|
|
261
|
-
return this._tiptapEditor.view.hasFocus();
|
|
262
|
-
}
|
|
263
|
-
focus() {
|
|
264
|
-
this._tiptapEditor.view.focus();
|
|
265
|
-
}
|
|
266
|
-
onUploadStart(callback) {
|
|
267
|
-
this.onUploadStartCallbacks.push(callback);
|
|
268
|
-
return () => {
|
|
269
|
-
const index = this.onUploadStartCallbacks.indexOf(callback);
|
|
270
|
-
if (index > -1) {
|
|
271
|
-
this.onUploadStartCallbacks.splice(index, 1);
|
|
272
|
-
}
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
onUploadEnd(callback) {
|
|
276
|
-
this.onUploadEndCallbacks.push(callback);
|
|
277
|
-
return () => {
|
|
278
|
-
const index = this.onUploadEndCallbacks.indexOf(callback);
|
|
279
|
-
if (index > -1) {
|
|
280
|
-
this.onUploadEndCallbacks.splice(index, 1);
|
|
281
|
-
}
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* @deprecated, use `editor.document` instead
|
|
286
|
-
*/
|
|
287
|
-
get topLevelBlocks() {
|
|
288
|
-
return this.document;
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Gets a snapshot of all top-level (non-nested) blocks in the editor.
|
|
292
|
-
* @returns A snapshot of all top-level (non-nested) blocks in the editor.
|
|
293
|
-
*/
|
|
294
|
-
get document() {
|
|
295
|
-
const blocks = [];
|
|
296
|
-
this._tiptapEditor.state.doc.firstChild.descendants((node) => {
|
|
297
|
-
blocks.push(nodeToBlock(node, this.schema.blockSchema, this.schema.inlineContentSchema, this.schema.styleSchema, this.blockCache));
|
|
298
|
-
return false;
|
|
299
|
-
});
|
|
300
|
-
return blocks;
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Gets a snapshot of an existing block from the editor.
|
|
304
|
-
* @param blockIdentifier The identifier of an existing block that should be
|
|
305
|
-
* retrieved.
|
|
306
|
-
* @returns The block that matches the identifier, or `undefined` if no
|
|
307
|
-
* matching block was found.
|
|
308
|
-
*/
|
|
309
|
-
getBlock(blockIdentifier) {
|
|
310
|
-
return getBlock(this, blockIdentifier);
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* Gets a snapshot of the previous sibling of an existing block from the
|
|
314
|
-
* editor.
|
|
315
|
-
* @param blockIdentifier The identifier of an existing block for which the
|
|
316
|
-
* previous sibling should be retrieved.
|
|
317
|
-
* @returns The previous sibling of the block that matches the identifier.
|
|
318
|
-
* `undefined` if no matching block was found, or it's the first child/block
|
|
319
|
-
* in the document.
|
|
320
|
-
*/
|
|
321
|
-
getPrevBlock(blockIdentifier) {
|
|
322
|
-
return getPrevBlock(this, blockIdentifier);
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Gets a snapshot of the next sibling of an existing block from the editor.
|
|
326
|
-
* @param blockIdentifier The identifier of an existing block for which the
|
|
327
|
-
* next sibling should be retrieved.
|
|
328
|
-
* @returns The next sibling of the block that matches the identifier.
|
|
329
|
-
* `undefined` if no matching block was found, or it's the last child/block in
|
|
330
|
-
* the document.
|
|
331
|
-
*/
|
|
332
|
-
getNextBlock(blockIdentifier) {
|
|
333
|
-
return getNextBlock(this, blockIdentifier);
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
|
-
* Gets a snapshot of the parent of an existing block from the editor.
|
|
337
|
-
* @param blockIdentifier The identifier of an existing block for which the
|
|
338
|
-
* parent should be retrieved.
|
|
339
|
-
* @returns The parent of the block that matches the identifier. `undefined`
|
|
340
|
-
* if no matching block was found, or the block isn't nested.
|
|
341
|
-
*/
|
|
342
|
-
getParentBlock(blockIdentifier) {
|
|
343
|
-
return getParentBlock(this, blockIdentifier);
|
|
344
|
-
}
|
|
345
|
-
/**
|
|
346
|
-
* Traverses all blocks in the editor depth-first, and executes a callback for each.
|
|
347
|
-
* @param callback The callback to execute for each block. Returning `false` stops the traversal.
|
|
348
|
-
* @param reverse Whether the blocks should be traversed in reverse order.
|
|
349
|
-
*/
|
|
350
|
-
forEachBlock(callback, reverse = false) {
|
|
351
|
-
const blocks = this.document.slice();
|
|
352
|
-
if (reverse) {
|
|
353
|
-
blocks.reverse();
|
|
354
|
-
}
|
|
355
|
-
function traverseBlockArray(blockArray) {
|
|
356
|
-
for (const block of blockArray) {
|
|
357
|
-
if (callback(block) === false) {
|
|
358
|
-
return false;
|
|
359
|
-
}
|
|
360
|
-
const children = reverse
|
|
361
|
-
? block.children.slice().reverse()
|
|
362
|
-
: block.children;
|
|
363
|
-
if (!traverseBlockArray(children)) {
|
|
364
|
-
return false;
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
return true;
|
|
368
|
-
}
|
|
369
|
-
traverseBlockArray(blocks);
|
|
370
|
-
}
|
|
371
|
-
/**
|
|
372
|
-
* Executes a callback whenever the editor's contents change.
|
|
373
|
-
* @param callback The callback to execute.
|
|
374
|
-
*/
|
|
375
|
-
onEditorContentChange(callback) {
|
|
376
|
-
this._tiptapEditor.on("update", callback);
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* Executes a callback whenever the editor's selection changes.
|
|
380
|
-
* @param callback The callback to execute.
|
|
381
|
-
*/
|
|
382
|
-
onEditorSelectionChange(callback) {
|
|
383
|
-
this._tiptapEditor.on("selectionUpdate", callback);
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Gets a snapshot of the current text cursor position.
|
|
387
|
-
* @returns A snapshot of the current text cursor position.
|
|
388
|
-
*/
|
|
389
|
-
getTextCursorPosition() {
|
|
390
|
-
return getTextCursorPosition(this);
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Sets the text cursor position to the start or end of an existing block. Throws an error if the target block could
|
|
394
|
-
* not be found.
|
|
395
|
-
* @param targetBlock The identifier of an existing block that the text cursor should be moved to.
|
|
396
|
-
* @param placement Whether the text cursor should be placed at the start or end of the block.
|
|
397
|
-
*/
|
|
398
|
-
setTextCursorPosition(targetBlock, placement = "start") {
|
|
399
|
-
setTextCursorPosition(this, targetBlock, placement);
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* Gets a snapshot of the current selection.
|
|
403
|
-
*/
|
|
404
|
-
getSelection() {
|
|
405
|
-
return getSelection(this);
|
|
406
|
-
}
|
|
407
|
-
setSelection(startBlock, endBlock) {
|
|
408
|
-
setSelection(this, startBlock, endBlock);
|
|
409
|
-
}
|
|
410
|
-
/**
|
|
411
|
-
* Checks if the editor is currently editable, or if it's locked.
|
|
412
|
-
* @returns True if the editor is editable, false otherwise.
|
|
413
|
-
*/
|
|
414
|
-
get isEditable() {
|
|
415
|
-
if (!this._tiptapEditor) {
|
|
416
|
-
if (!this.headless) {
|
|
417
|
-
throw new Error("no editor, but also not headless?");
|
|
418
|
-
}
|
|
419
|
-
return false;
|
|
420
|
-
}
|
|
421
|
-
return this._tiptapEditor.isEditable === undefined
|
|
422
|
-
? true
|
|
423
|
-
: this._tiptapEditor.isEditable;
|
|
424
|
-
}
|
|
425
|
-
/**
|
|
426
|
-
* Makes the editor editable or locks it, depending on the argument passed.
|
|
427
|
-
* @param editable True to make the editor editable, or false to lock it.
|
|
428
|
-
*/
|
|
429
|
-
set isEditable(editable) {
|
|
430
|
-
if (!this._tiptapEditor) {
|
|
431
|
-
if (!this.headless) {
|
|
432
|
-
throw new Error("no editor, but also not headless?");
|
|
433
|
-
}
|
|
434
|
-
// not relevant on headless
|
|
435
|
-
return;
|
|
436
|
-
}
|
|
437
|
-
if (this._tiptapEditor.options.editable !== editable) {
|
|
438
|
-
this._tiptapEditor.setEditable(editable);
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
/**
|
|
442
|
-
* Inserts new blocks into the editor. If a block's `id` is undefined, BlockNote generates one automatically. Throws an
|
|
443
|
-
* error if the reference block could not be found.
|
|
444
|
-
* @param blocksToInsert An array of partial blocks that should be inserted.
|
|
445
|
-
* @param referenceBlock An identifier for an existing block, at which the new blocks should be inserted.
|
|
446
|
-
* @param placement Whether the blocks should be inserted just before, just after, or nested inside the
|
|
447
|
-
* `referenceBlock`.
|
|
448
|
-
*/
|
|
449
|
-
insertBlocks(blocksToInsert, referenceBlock, placement = "before") {
|
|
450
|
-
return insertBlocks(this, blocksToInsert, referenceBlock, placement);
|
|
451
|
-
}
|
|
452
|
-
/**
|
|
453
|
-
* Updates an existing block in the editor. Since updatedBlock is a PartialBlock object, some fields might not be
|
|
454
|
-
* defined. These undefined fields are kept as-is from the existing block. Throws an error if the block to update could
|
|
455
|
-
* not be found.
|
|
456
|
-
* @param blockToUpdate The block that should be updated.
|
|
457
|
-
* @param update A partial block which defines how the existing block should be changed.
|
|
458
|
-
*/
|
|
459
|
-
updateBlock(blockToUpdate, update) {
|
|
460
|
-
return updateBlock(this, blockToUpdate, update);
|
|
461
|
-
}
|
|
462
|
-
/**
|
|
463
|
-
* Removes existing blocks from the editor. Throws an error if any of the blocks could not be found.
|
|
464
|
-
* @param blocksToRemove An array of identifiers for existing blocks that should be removed.
|
|
465
|
-
*/
|
|
466
|
-
removeBlocks(blocksToRemove) {
|
|
467
|
-
return removeBlocks(this, blocksToRemove);
|
|
468
|
-
}
|
|
469
|
-
/**
|
|
470
|
-
* Replaces existing blocks in the editor with new blocks. If the blocks that should be removed are not adjacent or
|
|
471
|
-
* are at different nesting levels, `blocksToInsert` will be inserted at the position of the first block in
|
|
472
|
-
* `blocksToRemove`. Throws an error if any of the blocks to remove could not be found.
|
|
473
|
-
* @param blocksToRemove An array of blocks that should be replaced.
|
|
474
|
-
* @param blocksToInsert An array of partial blocks to replace the old ones with.
|
|
475
|
-
*/
|
|
476
|
-
replaceBlocks(blocksToRemove, blocksToInsert) {
|
|
477
|
-
return replaceBlocks(this, blocksToRemove, blocksToInsert);
|
|
478
|
-
}
|
|
479
|
-
/**
|
|
480
|
-
* Insert a piece of content at the current cursor position.
|
|
481
|
-
*
|
|
482
|
-
* @param content can be a string, or array of partial inline content elements
|
|
483
|
-
*/
|
|
484
|
-
insertInlineContent(content) {
|
|
485
|
-
const nodes = inlineContentToNodes(content, this.pmSchema, this.schema.styleSchema);
|
|
486
|
-
insertContentAt({
|
|
487
|
-
from: this._tiptapEditor.state.selection.from,
|
|
488
|
-
to: this._tiptapEditor.state.selection.to,
|
|
489
|
-
}, nodes, this);
|
|
490
|
-
}
|
|
491
|
-
/**
|
|
492
|
-
* Gets the active text styles at the text cursor position or at the end of the current selection if it's active.
|
|
493
|
-
*/
|
|
494
|
-
getActiveStyles() {
|
|
495
|
-
const styles = {};
|
|
496
|
-
const marks = this._tiptapEditor.state.selection.$to.marks();
|
|
497
|
-
for (const mark of marks) {
|
|
498
|
-
const config = this.schema.styleSchema[mark.type.name];
|
|
499
|
-
if (!config) {
|
|
500
|
-
if (mark.type.name !== "link") {
|
|
501
|
-
// eslint-disable-next-line no-console
|
|
502
|
-
console.warn("mark not found in styleschema", mark.type.name);
|
|
503
|
-
}
|
|
504
|
-
continue;
|
|
505
|
-
}
|
|
506
|
-
if (config.propSchema === "boolean") {
|
|
507
|
-
styles[config.type] = true;
|
|
508
|
-
}
|
|
509
|
-
else {
|
|
510
|
-
styles[config.type] = mark.attrs.stringValue;
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
return styles;
|
|
514
|
-
}
|
|
515
|
-
/**
|
|
516
|
-
* Adds styles to the currently selected content.
|
|
517
|
-
* @param styles The styles to add.
|
|
518
|
-
*/
|
|
519
|
-
addStyles(styles) {
|
|
520
|
-
for (const [style, value] of Object.entries(styles)) {
|
|
521
|
-
const config = this.schema.styleSchema[style];
|
|
522
|
-
if (!config) {
|
|
523
|
-
throw new Error(`style ${style} not found in styleSchema`);
|
|
524
|
-
}
|
|
525
|
-
if (config.propSchema === "boolean") {
|
|
526
|
-
this._tiptapEditor.commands.setMark(style);
|
|
527
|
-
}
|
|
528
|
-
else if (config.propSchema === "string") {
|
|
529
|
-
this._tiptapEditor.commands.setMark(style, { stringValue: value });
|
|
530
|
-
}
|
|
531
|
-
else {
|
|
532
|
-
throw new UnreachableCaseError(config.propSchema);
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
/**
|
|
537
|
-
* Removes styles from the currently selected content.
|
|
538
|
-
* @param styles The styles to remove.
|
|
539
|
-
*/
|
|
540
|
-
removeStyles(styles) {
|
|
541
|
-
for (const style of Object.keys(styles)) {
|
|
542
|
-
this._tiptapEditor.commands.unsetMark(style);
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
/**
|
|
546
|
-
* Toggles styles on the currently selected content.
|
|
547
|
-
* @param styles The styles to toggle.
|
|
548
|
-
*/
|
|
549
|
-
toggleStyles(styles) {
|
|
550
|
-
for (const [style, value] of Object.entries(styles)) {
|
|
551
|
-
const config = this.schema.styleSchema[style];
|
|
552
|
-
if (!config) {
|
|
553
|
-
throw new Error(`style ${style} not found in styleSchema`);
|
|
554
|
-
}
|
|
555
|
-
if (config.propSchema === "boolean") {
|
|
556
|
-
this._tiptapEditor.commands.toggleMark(style);
|
|
557
|
-
}
|
|
558
|
-
else if (config.propSchema === "string") {
|
|
559
|
-
this._tiptapEditor.commands.toggleMark(style, { stringValue: value });
|
|
560
|
-
}
|
|
561
|
-
else {
|
|
562
|
-
throw new UnreachableCaseError(config.propSchema);
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
/**
|
|
567
|
-
* Gets the currently selected text.
|
|
568
|
-
*/
|
|
569
|
-
getSelectedText() {
|
|
570
|
-
return this._tiptapEditor.state.doc.textBetween(this._tiptapEditor.state.selection.from, this._tiptapEditor.state.selection.to);
|
|
571
|
-
}
|
|
572
|
-
/**
|
|
573
|
-
* Gets the URL of the last link in the current selection, or `undefined` if there are no links in the selection.
|
|
574
|
-
*/
|
|
575
|
-
getSelectedLinkUrl() {
|
|
576
|
-
return this._tiptapEditor.getAttributes("link").href;
|
|
577
|
-
}
|
|
578
|
-
/**
|
|
579
|
-
* Creates a new link to replace the selected content.
|
|
580
|
-
* @param url The link URL.
|
|
581
|
-
* @param text The text to display the link with.
|
|
582
|
-
*/
|
|
583
|
-
createLink(url, text) {
|
|
584
|
-
if (url === "") {
|
|
585
|
-
return;
|
|
586
|
-
}
|
|
587
|
-
const { from, to } = this._tiptapEditor.state.selection;
|
|
588
|
-
if (!text) {
|
|
589
|
-
text = this._tiptapEditor.state.doc.textBetween(from, to);
|
|
590
|
-
}
|
|
591
|
-
const mark = this.pmSchema.mark("link", { href: url });
|
|
592
|
-
this.dispatch(this._tiptapEditor.state.tr
|
|
593
|
-
.insertText(text, from, to)
|
|
594
|
-
.addMark(from, from + text.length, mark));
|
|
595
|
-
}
|
|
596
|
-
/**
|
|
597
|
-
* Checks if the block containing the text cursor can be nested.
|
|
598
|
-
*/
|
|
599
|
-
canNestBlock() {
|
|
600
|
-
return canNestBlock(this);
|
|
601
|
-
}
|
|
602
|
-
/**
|
|
603
|
-
* Nests the block containing the text cursor into the block above it.
|
|
604
|
-
*/
|
|
605
|
-
nestBlock() {
|
|
606
|
-
nestBlock(this);
|
|
607
|
-
}
|
|
608
|
-
/**
|
|
609
|
-
* Checks if the block containing the text cursor is nested.
|
|
610
|
-
*/
|
|
611
|
-
canUnnestBlock() {
|
|
612
|
-
return canUnnestBlock(this);
|
|
613
|
-
}
|
|
614
|
-
/**
|
|
615
|
-
* Lifts the block containing the text cursor out of its parent.
|
|
616
|
-
*/
|
|
617
|
-
unnestBlock() {
|
|
618
|
-
unnestBlock(this);
|
|
619
|
-
}
|
|
620
|
-
/**
|
|
621
|
-
* Moves the selected blocks up. If the previous block has children, moves
|
|
622
|
-
* them to the end of its children. If there is no previous block, but the
|
|
623
|
-
* current blocks share a common parent, moves them out of & before it.
|
|
624
|
-
*/
|
|
625
|
-
moveBlocksUp() {
|
|
626
|
-
moveBlocksUp(this);
|
|
627
|
-
}
|
|
628
|
-
/**
|
|
629
|
-
* Moves the selected blocks down. If the next block has children, moves
|
|
630
|
-
* them to the start of its children. If there is no next block, but the
|
|
631
|
-
* current blocks share a common parent, moves them out of & after it.
|
|
632
|
-
*/
|
|
633
|
-
moveBlocksDown() {
|
|
634
|
-
moveBlocksDown(this);
|
|
635
|
-
}
|
|
636
|
-
/**
|
|
637
|
-
* Exports blocks into a simplified HTML string. To better conform to HTML standards, children of blocks which aren't list
|
|
638
|
-
* items are un-nested in the output HTML.
|
|
639
|
-
*
|
|
640
|
-
* @param blocks An array of blocks that should be serialized into HTML.
|
|
641
|
-
* @returns The blocks, serialized as an HTML string.
|
|
642
|
-
*/
|
|
643
|
-
async blocksToHTMLLossy(blocks = this.document) {
|
|
644
|
-
const exporter = createExternalHTMLExporter(this.pmSchema, this);
|
|
645
|
-
return exporter.exportBlocks(blocks, {});
|
|
646
|
-
}
|
|
647
|
-
/**
|
|
648
|
-
* Serializes blocks into an HTML string in the format that would normally be rendered by the editor.
|
|
649
|
-
*
|
|
650
|
-
* Use this method if you want to server-side render HTML (for example, a blog post that has been edited in BlockNote)
|
|
651
|
-
* and serve it to users without loading the editor on the client (i.e.: displaying the blog post)
|
|
652
|
-
*
|
|
653
|
-
* @param blocks An array of blocks that should be serialized into HTML.
|
|
654
|
-
* @returns The blocks, serialized as an HTML string.
|
|
655
|
-
*/
|
|
656
|
-
async blocksToFullHTML(blocks) {
|
|
657
|
-
const exporter = createInternalHTMLSerializer(this.pmSchema, this);
|
|
658
|
-
return exporter.serializeBlocks(blocks, {});
|
|
659
|
-
}
|
|
660
|
-
/**
|
|
661
|
-
* Parses blocks from an HTML string. Tries to create `Block` objects out of any HTML block-level elements, and
|
|
662
|
-
* `InlineNode` objects from any HTML inline elements, though not all element types are recognized. If BlockNote
|
|
663
|
-
* doesn't recognize an HTML element's tag, it will parse it as a paragraph or plain text.
|
|
664
|
-
* @param html The HTML string to parse blocks from.
|
|
665
|
-
* @returns The blocks parsed from the HTML string.
|
|
666
|
-
*/
|
|
667
|
-
async tryParseHTMLToBlocks(html) {
|
|
668
|
-
return HTMLToBlocks(html, this.schema.blockSchema, this.schema.inlineContentSchema, this.schema.styleSchema, this.pmSchema);
|
|
669
|
-
}
|
|
670
|
-
/**
|
|
671
|
-
* Serializes blocks into a Markdown string. The output is simplified as Markdown does not support all features of
|
|
672
|
-
* BlockNote - children of blocks which aren't list items are un-nested and certain styles are removed.
|
|
673
|
-
* @param blocks An array of blocks that should be serialized into Markdown.
|
|
674
|
-
* @returns The blocks, serialized as a Markdown string.
|
|
675
|
-
*/
|
|
676
|
-
async blocksToMarkdownLossy(blocks = this.document) {
|
|
677
|
-
return blocksToMarkdown(blocks, this.pmSchema, this, {});
|
|
678
|
-
}
|
|
679
|
-
/**
|
|
680
|
-
* Creates a list of blocks from a Markdown string. Tries to create `Block` and `InlineNode` objects based on
|
|
681
|
-
* Markdown syntax, though not all symbols are recognized. If BlockNote doesn't recognize a symbol, it will parse it
|
|
682
|
-
* as text.
|
|
683
|
-
* @param markdown The Markdown string to parse blocks from.
|
|
684
|
-
* @returns The blocks parsed from the Markdown string.
|
|
685
|
-
*/
|
|
686
|
-
async tryParseMarkdownToBlocks(markdown) {
|
|
687
|
-
return markdownToBlocks(markdown, this.schema.blockSchema, this.schema.inlineContentSchema, this.schema.styleSchema, this.pmSchema);
|
|
688
|
-
}
|
|
689
|
-
/**
|
|
690
|
-
* Updates the user info for the current user that's shown to other collaborators.
|
|
691
|
-
*/
|
|
692
|
-
updateCollaborationUserInfo(user) {
|
|
693
|
-
if (!this.options.collaboration) {
|
|
694
|
-
throw new Error("Cannot update collaboration user info when collaboration is disabled.");
|
|
695
|
-
}
|
|
696
|
-
this._tiptapEditor.commands.updateUser(user);
|
|
697
|
-
}
|
|
698
|
-
/**
|
|
699
|
-
* A callback function that runs whenever the editor's contents change.
|
|
700
|
-
*
|
|
701
|
-
* @param callback The callback to execute.
|
|
702
|
-
* @returns A function to remove the callback.
|
|
703
|
-
*/
|
|
704
|
-
onChange(callback) {
|
|
705
|
-
if (this.headless) {
|
|
706
|
-
// Note: would be nice if this is possible in headless mode as well
|
|
707
|
-
return;
|
|
708
|
-
}
|
|
709
|
-
const cb = () => {
|
|
710
|
-
callback(this);
|
|
711
|
-
};
|
|
712
|
-
this._tiptapEditor.on("update", cb);
|
|
713
|
-
return () => {
|
|
714
|
-
this._tiptapEditor.off("update", cb);
|
|
715
|
-
};
|
|
716
|
-
}
|
|
717
|
-
/**
|
|
718
|
-
* A callback function that runs whenever the text cursor position or selection changes.
|
|
719
|
-
*
|
|
720
|
-
* @param callback The callback to execute.
|
|
721
|
-
* @returns A function to remove the callback.
|
|
722
|
-
*/
|
|
723
|
-
onSelectionChange(callback) {
|
|
724
|
-
if (this.headless) {
|
|
725
|
-
return;
|
|
726
|
-
}
|
|
727
|
-
const cb = () => {
|
|
728
|
-
callback(this);
|
|
729
|
-
};
|
|
730
|
-
this._tiptapEditor.on("selectionUpdate", cb);
|
|
731
|
-
return () => {
|
|
732
|
-
this._tiptapEditor.off("selectionUpdate", cb);
|
|
733
|
-
};
|
|
734
|
-
}
|
|
735
|
-
openSuggestionMenu(triggerCharacter, pluginState) {
|
|
736
|
-
const tr = this.prosemirrorView.state.tr;
|
|
737
|
-
const transaction = pluginState && pluginState.deleteTriggerCharacter
|
|
738
|
-
? tr.insertText(triggerCharacter)
|
|
739
|
-
: tr;
|
|
740
|
-
this.prosemirrorView.focus();
|
|
741
|
-
this.prosemirrorView.dispatch(transaction.scrollIntoView().setMeta(this.suggestionMenus.plugin, {
|
|
742
|
-
triggerCharacter: triggerCharacter,
|
|
743
|
-
deleteTriggerCharacter: pluginState?.deleteTriggerCharacter || false,
|
|
744
|
-
ignoreQueryLength: pluginState?.ignoreQueryLength || false,
|
|
745
|
-
}));
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
//# sourceMappingURL=BlockNoteEditor.js.map
|