@blocknote/core 0.27.2 → 0.29.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.cjs +10 -10
- package/dist/blocknote.cjs.map +1 -1
- package/dist/blocknote.js +3032 -3118
- package/dist/blocknote.js.map +1 -1
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +10 -10
- package/dist/locales.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +2 -2
- package/src/api/__snapshots__/blocks-deleted-nested-deep.json +26 -0
- package/src/api/__snapshots__/blocks-deleted-nested.json +68 -0
- package/src/api/__snapshots__/blocks-deleted.json +26 -0
- package/src/api/__snapshots__/blocks-inserted-nested.json +62 -0
- package/src/api/__snapshots__/blocks-inserted.json +20 -0
- package/src/api/__snapshots__/blocks-updated-content-inserted.json +42 -0
- package/src/api/__snapshots__/blocks-updated-multiple-insert.json +50 -0
- package/src/api/__snapshots__/blocks-updated-multiple.json +82 -0
- package/src/api/__snapshots__/blocks-updated-nested-deep.json +42 -0
- package/src/api/__snapshots__/blocks-updated-nested-multiple.json +118 -0
- package/src/api/__snapshots__/blocks-updated-nested.json +78 -0
- package/src/api/__snapshots__/blocks-updated-single.json +42 -0
- package/src/api/__snapshots__/blocks-updated.json +42 -0
- package/src/api/blockManipulation/__snapshots__/transactions.test.ts.snap +34 -0
- package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +312 -0
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +127 -94
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +19 -37
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +8 -6
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +25 -31
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +93 -91
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +16 -20
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +14 -1
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +18 -56
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +52 -46
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +1051 -0
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +247 -154
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +109 -142
- package/src/api/blockManipulation/getBlock/getBlock.ts +23 -48
- package/src/api/blockManipulation/insertContentAt.ts +4 -17
- package/src/api/blockManipulation/selections/selection.test.ts +32 -16
- package/src/api/blockManipulation/selections/selection.ts +25 -51
- package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.ts +35 -14
- package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.ts +34 -65
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +8 -10
- package/src/api/clipboard/toClipboard/copyExtension.ts +7 -7
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +7 -16
- package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +3 -17
- package/src/api/getBlockInfoFromPos.ts +13 -1
- package/src/api/nodeConversions/blockToNode.ts +21 -10
- package/src/api/nodeConversions/fragmentToBlocks.ts +5 -18
- package/src/api/nodeConversions/nodeToBlock.ts +11 -8
- package/src/api/nodeUtil.test.ts +228 -0
- package/src/api/nodeUtil.ts +235 -2
- package/src/api/parsers/html/parseHTML.ts +2 -10
- package/src/api/parsers/markdown/parseMarkdown.ts +2 -8
- package/src/api/pmUtil.ts +54 -0
- package/src/api/positionMapping.test.ts +370 -0
- package/src/api/positionMapping.ts +114 -0
- package/src/blocks/FileBlockContent/helpers/render/createAddFileButton.ts +2 -2
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +9 -13
- package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +5 -9
- package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +19 -31
- package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +10 -8
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +9 -13
- package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +1 -1
- package/src/blocks/QuoteBlockContent/QuoteBlockContent.ts +5 -9
- package/src/blocks/defaultBlockHelpers.ts +1 -1
- package/src/editor/BlockNoteEditor.test.ts +1 -1
- package/src/editor/BlockNoteEditor.ts +259 -130
- package/src/editor/BlockNoteTipTapEditor.ts +91 -8
- package/src/extensions/Comments/CommentsPlugin.ts +32 -34
- package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +4 -8
- package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +12 -13
- package/src/extensions/ShowSelection/ShowSelectionPlugin.ts +1 -3
- package/src/extensions/SideMenu/MultipleNodeSelection.ts +3 -1
- package/src/extensions/SideMenu/dragging.ts +1 -1
- package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +38 -25
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +8 -8
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +150 -136
- package/src/i18n/locales/de.ts +10 -10
- package/src/index.ts +4 -3
- package/src/schema/inlineContent/createSpec.ts +1 -5
- package/types/src/api/blockManipulation/commands/insertBlocks/insertBlocks.d.ts +2 -2
- package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.d.ts +4 -8
- package/types/src/api/blockManipulation/commands/updateBlock/updateBlock.d.ts +9 -10
- package/types/src/api/blockManipulation/getBlock/getBlock.d.ts +7 -7
- package/types/src/api/blockManipulation/insertContentAt.d.ts +5 -3
- package/types/src/api/blockManipulation/selections/selection.d.ts +3 -3
- package/types/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.d.ts +5 -5
- package/types/src/api/getBlockInfoFromPos.d.ts +8 -1
- package/types/src/api/nodeConversions/blockToNode.d.ts +3 -3
- package/types/src/api/nodeConversions/fragmentToBlocks.d.ts +1 -2
- package/types/src/api/nodeConversions/nodeToBlock.d.ts +2 -2
- package/types/src/api/nodeUtil.d.ts +67 -1
- package/types/src/api/parsers/html/parseHTML.d.ts +1 -1
- package/types/src/api/parsers/markdown/parseMarkdown.d.ts +1 -1
- package/types/src/api/pmUtil.d.ts +12 -0
- package/types/src/api/positionMapping.d.ts +25 -0
- package/types/src/editor/BlockNoteEditor.d.ts +72 -10
- package/types/src/editor/BlockNoteTipTapEditor.d.ts +15 -2
- package/types/src/extensions/TableHandles/TableHandlesPlugin.d.ts +1 -1
- package/types/src/index.d.ts +1 -2
- package/src/api/blockManipulation/commands/removeBlocks/__snapshots__/removeBlocks.test.ts.snap +0 -1859
- package/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.ts +0 -40
- package/src/api/blockManipulation/commands/removeBlocks/removeBlocks.ts +0 -20
- package/src/api/clipboard/__snapshots__/external/pasteEndOfParagraph.html +0 -138
- package/src/api/clipboard/__snapshots__/external/pasteEndOfParagraphText.html +0 -138
- package/src/api/clipboard/__snapshots__/external/pasteImage.html +0 -153
- package/src/api/clipboard/__snapshots__/external/pasteParagraphInCustomBlock.html +0 -138
- package/src/api/clipboard/__snapshots__/external/pasteTable.html +0 -233
- package/src/api/clipboard/__snapshots__/external/pasteTableInExistingTable.html +0 -216
- package/src/api/clipboard/__snapshots__/internal/basicBlocks.html +0 -1
- package/src/api/clipboard/__snapshots__/internal/basicBlocksWithProps.html +0 -1
- package/src/api/clipboard/__snapshots__/internal/childToParent.html +0 -1
- package/src/api/clipboard/__snapshots__/internal/childrenToNextParent.html +0 -1
- package/src/api/clipboard/__snapshots__/internal/childrenToNextParentsChildren.html +0 -1
- package/src/api/clipboard/__snapshots__/internal/image.html +0 -1
- package/src/api/clipboard/__snapshots__/internal/multipleChildren.html +0 -1
- package/src/api/clipboard/__snapshots__/internal/multipleStyledText.html +0 -1
- package/src/api/clipboard/__snapshots__/internal/nestedImage.html +0 -1
- package/src/api/clipboard/__snapshots__/internal/paragraphInCustomBlock.html +0 -1
- package/src/api/clipboard/__snapshots__/internal/partialChildToParent.html +0 -1
- package/src/api/clipboard/__snapshots__/internal/styledText.html +0 -1
- package/src/api/clipboard/__snapshots__/internal/tableAllCells.html +0 -1
- package/src/api/clipboard/__snapshots__/internal/tableCell.html +0 -1
- package/src/api/clipboard/__snapshots__/internal/tableCellText.html +0 -1
- package/src/api/clipboard/__snapshots__/internal/tableRow.html +0 -1
- package/src/api/clipboard/__snapshots__/internal/unstyledText.html +0 -1
- package/src/api/clipboard/clipboardExternal.test.ts +0 -161
- package/src/api/clipboard/clipboardInternal.test.ts +0 -435
- package/src/api/clipboard/testUtil.ts +0 -27
- package/src/api/exporters/html/__snapshots__/codeBlock/contains-newlines/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/codeBlock/contains-newlines/internal.html +0 -3
- package/src/api/exporters/html/__snapshots__/codeBlock/defaultLanguage/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/codeBlock/defaultLanguage/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/codeBlock/empty/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/codeBlock/empty/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/codeBlock/python/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/codeBlock/python/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/complex/misc/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/complex/misc/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/customBlock/basic/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/customBlock/basic/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/customParagraph/basic/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/customParagraph/basic/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/customParagraph/lineBreaks/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/customParagraph/lineBreaks/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/customParagraph/nested/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/customParagraph/nested/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/customParagraph/styled/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/customParagraph/styled/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/file/basic/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/file/basic/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/file/button/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/file/button/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/file/nested/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/file/nested/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/file/noCaption/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/file/noCaption/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/file/noName/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/file/noName/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/fontSize/basic/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/fontSize/basic/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/hardbreak/basic/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/hardbreak/basic/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/hardbreak/between-links/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/hardbreak/between-links/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/hardbreak/end/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/hardbreak/end/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/hardbreak/link/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/hardbreak/link/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/hardbreak/multiple/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/hardbreak/multiple/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/hardbreak/only/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/hardbreak/only/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/hardbreak/start/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/hardbreak/start/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/hardbreak/styles/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/hardbreak/styles/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/image/basic/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/image/basic/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/image/button/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/image/button/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/image/nested/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/image/nested/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/image/noCaption/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/image/noCaption/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/image/noName/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/image/noName/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/image/noPreview/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/image/noPreview/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/link/adjacent/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/link/adjacent/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/link/basic/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/link/basic/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/link/styled/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/link/styled/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/lists/basic/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/lists/basic/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/lists/nested/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/lists/nested/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/mention/basic/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/mention/basic/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/pageBreak/basic/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/pageBreak/basic/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/paragraph/basic/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/paragraph/basic/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/paragraph/empty/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/paragraph/empty/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/paragraph/lineBreaks/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/paragraph/lineBreaks/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/paragraph/nested/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/paragraph/nested/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/paragraph/styled/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/paragraph/styled/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/paste/parse-basic-block-types.json +0 -140
- package/src/api/exporters/html/__snapshots__/paste/parse-deep-nested-content.json +0 -240
- package/src/api/exporters/html/__snapshots__/paste/parse-div-with-inline-content.json +0 -91
- package/src/api/exporters/html/__snapshots__/paste/parse-divs.json +0 -19
- package/src/api/exporters/html/__snapshots__/paste/parse-fake-image-caption.json +0 -31
- package/src/api/exporters/html/__snapshots__/paste/parse-mixed-nested-lists.json +0 -70
- package/src/api/exporters/html/__snapshots__/paste/parse-nested-lists-with-paragraphs.json +0 -70
- package/src/api/exporters/html/__snapshots__/paste/parse-nested-lists.json +0 -70
- package/src/api/exporters/html/__snapshots__/simpleCustomParagraph/basic/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/simpleCustomParagraph/basic/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/simpleCustomParagraph/nested/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/simpleCustomParagraph/nested/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/simpleCustomParagraph/styled/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/simpleCustomParagraph/styled/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/simpleFile/basic/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/simpleFile/basic/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/simpleFile/button/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/simpleFile/button/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/simpleFile/nested/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/simpleFile/nested/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/basic/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/basic/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/button/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/button/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/nested/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/nested/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noCaption/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noCaption/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noName/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noName/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noPreview/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noPreview/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/small/basic/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/small/basic/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/table/allColWidths/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/table/allColWidths/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/table/basic/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/table/basic/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/table/headerCols/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/table/headerCols/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/table/headerRows/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/table/headerRows/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/table/headersRows/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/table/headersRows/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/table/mixedCellColors/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/table/mixedCellColors/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/table/mixedColWidths/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/table/mixedColWidths/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/table/mixedRowspansAndColspans/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/table/mixedRowspansAndColspans/internal.html +0 -1
- package/src/api/exporters/html/__snapshots__/tag/basic/external.html +0 -1
- package/src/api/exporters/html/__snapshots__/tag/basic/internal.html +0 -1
- package/src/api/exporters/html/htmlConversion.test.ts +0 -110
- package/src/api/exporters/markdown/__snapshots__/codeBlock/contains-newlines/markdown.md +0 -4
- package/src/api/exporters/markdown/__snapshots__/codeBlock/defaultLanguage/markdown.md +0 -3
- package/src/api/exporters/markdown/__snapshots__/codeBlock/empty/markdown.md +0 -2
- package/src/api/exporters/markdown/__snapshots__/codeBlock/python/markdown.md +0 -3
- package/src/api/exporters/markdown/__snapshots__/complex/misc/markdown.md +0 -5
- package/src/api/exporters/markdown/__snapshots__/customBlock/basic/markdown.md +0 -5
- package/src/api/exporters/markdown/__snapshots__/customParagraph/basic/markdown.md +0 -1
- package/src/api/exporters/markdown/__snapshots__/customParagraph/lineBreaks/markdown.md +0 -1
- package/src/api/exporters/markdown/__snapshots__/customParagraph/nested/markdown.md +0 -5
- package/src/api/exporters/markdown/__snapshots__/customParagraph/styled/markdown.md +0 -1
- package/src/api/exporters/markdown/__snapshots__/file/basic/markdown.md +0 -3
- package/src/api/exporters/markdown/__snapshots__/file/button/markdown.md +0 -1
- package/src/api/exporters/markdown/__snapshots__/file/nested/markdown.md +0 -7
- package/src/api/exporters/markdown/__snapshots__/file/noCaption/markdown.md +0 -1
- package/src/api/exporters/markdown/__snapshots__/file/noName/markdown.md +0 -3
- package/src/api/exporters/markdown/__snapshots__/fontSize/basic/markdown.md +0 -1
- package/src/api/exporters/markdown/__snapshots__/hardbreak/basic/markdown.md +0 -2
- package/src/api/exporters/markdown/__snapshots__/hardbreak/between-links/markdown.md +0 -2
- package/src/api/exporters/markdown/__snapshots__/hardbreak/end/markdown.md +0 -1
- package/src/api/exporters/markdown/__snapshots__/hardbreak/link/markdown.md +0 -2
- package/src/api/exporters/markdown/__snapshots__/hardbreak/multiple/markdown.md +0 -3
- package/src/api/exporters/markdown/__snapshots__/hardbreak/only/markdown.md +0 -0
- package/src/api/exporters/markdown/__snapshots__/hardbreak/start/markdown.md +0 -1
- package/src/api/exporters/markdown/__snapshots__/hardbreak/styles/markdown.md +0 -2
- package/src/api/exporters/markdown/__snapshots__/image/basic/markdown.md +0 -3
- package/src/api/exporters/markdown/__snapshots__/image/button/markdown.md +0 -1
- package/src/api/exporters/markdown/__snapshots__/image/nested/markdown.md +0 -7
- package/src/api/exporters/markdown/__snapshots__/image/noCaption/markdown.md +0 -1
- package/src/api/exporters/markdown/__snapshots__/image/noName/markdown.md +0 -3
- package/src/api/exporters/markdown/__snapshots__/image/noPreview/markdown.md +0 -3
- package/src/api/exporters/markdown/__snapshots__/link/adjacent/markdown.md +0 -1
- package/src/api/exporters/markdown/__snapshots__/link/basic/markdown.md +0 -1
- package/src/api/exporters/markdown/__snapshots__/link/styled/markdown.md +0 -1
- package/src/api/exporters/markdown/__snapshots__/lists/basic/markdown.md +0 -10
- package/src/api/exporters/markdown/__snapshots__/lists/nested/markdown.md +0 -10
- package/src/api/exporters/markdown/__snapshots__/mention/basic/markdown.md +0 -1
- package/src/api/exporters/markdown/__snapshots__/pageBreak/basic/markdown.md +0 -0
- package/src/api/exporters/markdown/__snapshots__/paragraph/basic/markdown.md +0 -1
- package/src/api/exporters/markdown/__snapshots__/paragraph/empty/markdown.md +0 -0
- package/src/api/exporters/markdown/__snapshots__/paragraph/lineBreaks/markdown.md +0 -2
- package/src/api/exporters/markdown/__snapshots__/paragraph/nested/markdown.md +0 -5
- package/src/api/exporters/markdown/__snapshots__/paragraph/styled/markdown.md +0 -1
- package/src/api/exporters/markdown/__snapshots__/simpleCustomParagraph/basic/markdown.md +0 -1
- package/src/api/exporters/markdown/__snapshots__/simpleCustomParagraph/nested/markdown.md +0 -5
- package/src/api/exporters/markdown/__snapshots__/simpleCustomParagraph/styled/markdown.md +0 -1
- package/src/api/exporters/markdown/__snapshots__/simpleFile/basic/markdown.md +0 -3
- package/src/api/exporters/markdown/__snapshots__/simpleFile/button/markdown.md +0 -1
- package/src/api/exporters/markdown/__snapshots__/simpleFile/nested/markdown.md +0 -7
- package/src/api/exporters/markdown/__snapshots__/simpleImage/basic/markdown.md +0 -3
- package/src/api/exporters/markdown/__snapshots__/simpleImage/button/markdown.md +0 -1
- package/src/api/exporters/markdown/__snapshots__/simpleImage/nested/markdown.md +0 -7
- package/src/api/exporters/markdown/__snapshots__/simpleImage/noCaption/markdown.md +0 -1
- package/src/api/exporters/markdown/__snapshots__/simpleImage/noName/markdown.md +0 -3
- package/src/api/exporters/markdown/__snapshots__/simpleImage/noPreview/markdown.md +0 -3
- package/src/api/exporters/markdown/__snapshots__/small/basic/markdown.md +0 -1
- package/src/api/exporters/markdown/__snapshots__/table/allColWidths/markdown.md +0 -5
- package/src/api/exporters/markdown/__snapshots__/table/basic/markdown.md +0 -5
- package/src/api/exporters/markdown/__snapshots__/table/headerCols/markdown.md +0 -4
- package/src/api/exporters/markdown/__snapshots__/table/headerRows/markdown.md +0 -4
- package/src/api/exporters/markdown/__snapshots__/table/mixedCellColors/markdown.md +0 -5
- package/src/api/exporters/markdown/__snapshots__/table/mixedColWidths/markdown.md +0 -5
- package/src/api/exporters/markdown/__snapshots__/table/mixedRowspansAndColspans/markdown.md +0 -5
- package/src/api/exporters/markdown/__snapshots__/tag/basic/markdown.md +0 -1
- package/src/api/exporters/markdown/markdownExporter.test.ts +0 -86
- package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +0 -3473
- package/src/api/nodeConversions/nodeConversions.test.ts +0 -83
- package/src/api/parsers/html/__snapshots__/list-test.json +0 -177
- package/src/api/parsers/html/__snapshots__/parse-2-tables.json +0 -129
- package/src/api/parsers/html/__snapshots__/parse-basic-block-types.json +0 -142
- package/src/api/parsers/html/__snapshots__/parse-codeblocks.json +0 -62
- package/src/api/parsers/html/__snapshots__/parse-div-with-inline-content.json +0 -91
- package/src/api/parsers/html/__snapshots__/parse-divs.json +0 -121
- package/src/api/parsers/html/__snapshots__/parse-fake-image-caption.json +0 -33
- package/src/api/parsers/html/__snapshots__/parse-image-in-paragraph.json +0 -16
- package/src/api/parsers/html/__snapshots__/parse-mixed-nested-lists.json +0 -265
- package/src/api/parsers/html/__snapshots__/parse-nested-lists-with-paragraphs.json +0 -265
- package/src/api/parsers/html/__snapshots__/parse-nested-lists.json +0 -265
- package/src/api/parsers/html/__snapshots__/parse-notion-html.json +0 -565
- package/src/api/parsers/html/__snapshots__/parse-two-divs.json +0 -36
- package/src/api/parsers/html/parseHTML.test.ts +0 -563
- package/src/api/parsers/markdown/__snapshots__/complex.json +0 -353
- package/src/api/parsers/markdown/__snapshots__/issue-226-1.json +0 -71
- package/src/api/parsers/markdown/__snapshots__/issue-226-2.json +0 -144
- package/src/api/parsers/markdown/__snapshots__/nested.json +0 -72
- package/src/api/parsers/markdown/__snapshots__/non-nested.json +0 -71
- package/src/api/parsers/markdown/__snapshots__/pasted/complex.json +0 -319
- package/src/api/parsers/markdown/__snapshots__/pasted/issue-226-1.json +0 -81
- package/src/api/parsers/markdown/__snapshots__/pasted/issue-226-2.json +0 -165
- package/src/api/parsers/markdown/__snapshots__/pasted/nested.json +0 -81
- package/src/api/parsers/markdown/__snapshots__/pasted/non-nested.json +0 -81
- package/src/api/parsers/markdown/__snapshots__/pasted/styled.json +0 -61
- package/src/api/parsers/markdown/__snapshots__/pasted/whitespace bold.json +0 -42
- package/src/api/parsers/markdown/__snapshots__/styled.json +0 -58
- package/src/api/parsers/markdown/__snapshots__/whitespace bold.json +0 -19
- package/src/api/parsers/markdown/parseMarkdown.test.ts +0 -135
- package/src/api/testUtil/cases/customBlocks.ts +0 -342
- package/src/api/testUtil/cases/customInlineContent.ts +0 -113
- package/src/api/testUtil/cases/customStyles.ts +0 -102
- package/src/api/testUtil/cases/defaultSchema.ts +0 -1493
- package/src/api/testUtil/index.ts +0 -19
- package/src/api/testUtil/partialBlockTestUtil.ts +0 -198
- package/src/api/testUtil/paste.ts +0 -46
- package/types/src/api/blockManipulation/commands/removeBlocks/removeBlocks.d.ts +0 -4
- package/types/src/api/clipboard/clipboardInternal.test.d.ts +0 -1
- package/types/src/api/clipboard/testUtil.d.ts +0 -541
- package/types/src/api/exporters/html/htmlConversion.test.d.ts +0 -1
- package/types/src/api/exporters/markdown/markdownExporter.test.d.ts +0 -1
- package/types/src/api/nodeConversions/nodeConversions.test.d.ts +0 -1
- package/types/src/api/parsers/html/parseHTML.test.d.ts +0 -1
- package/types/src/api/parsers/markdown/parseMarkdown.test.d.ts +0 -1
- package/types/src/api/testUtil/cases/customBlocks.d.ts +0 -670
- package/types/src/api/testUtil/cases/customInlineContent.d.ts +0 -558
- package/types/src/api/testUtil/cases/customStyles.d.ts +0 -552
- package/types/src/api/testUtil/cases/defaultSchema.d.ts +0 -4
- package/types/src/api/testUtil/index.d.ts +0 -14
- package/types/src/api/testUtil/partialBlockTestUtil.d.ts +0 -9
- package/types/src/api/testUtil/paste.d.ts +0 -2
- /package/types/src/api/{blockManipulation/commands/removeBlocks/removeBlocks.test.d.ts → nodeUtil.test.d.ts} +0 -0
- /package/types/src/api/{clipboard/clipboardExternal.test.d.ts → positionMapping.test.d.ts} +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Fragment } from "@tiptap/pm/model";
|
|
2
|
-
import { BlockNoteSchema } from "../../editor/BlockNoteSchema.js";
|
|
3
2
|
import { BlockNoDefaults, BlockSchema, InlineContentSchema, StyleSchema } from "../../schema/index.js";
|
|
4
3
|
/**
|
|
5
4
|
* Converts all Blocks within a fragment to BlockNote blocks.
|
|
6
5
|
*/
|
|
7
|
-
export declare function fragmentToBlocks<B extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(fragment: Fragment
|
|
6
|
+
export declare function fragmentToBlocks<B extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(fragment: Fragment): BlockNoDefaults<B, I, S>[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Node } from "@tiptap/pm/model";
|
|
1
|
+
import { Node, Schema } from "@tiptap/pm/model";
|
|
2
2
|
import type { BlockSchema, InlineContent, InlineContentSchema, StyleSchema, TableContent } from "../../schema/index.js";
|
|
3
3
|
import type { Block } from "../../blocks/defaultBlocks.js";
|
|
4
4
|
/**
|
|
@@ -15,4 +15,4 @@ export declare function nodeToCustomInlineContent<I extends InlineContentSchema,
|
|
|
15
15
|
*
|
|
16
16
|
* TODO: test changes
|
|
17
17
|
*/
|
|
18
|
-
export declare function nodeToBlock<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(node: Node,
|
|
18
|
+
export declare function nodeToBlock<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(node: Node, schema: Schema, blockSchema?: BSchema, inlineContentSchema?: I, styleSchema?: S, blockCache?: import("../../index.js").BlockCache<any, any, any>): Block<BSchema, I, S>;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import { Node } from "prosemirror-model";
|
|
1
|
+
import type { Node } from "prosemirror-model";
|
|
2
|
+
import type { Transaction } from "prosemirror-state";
|
|
3
|
+
import { Block, DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema } from "../blocks/defaultBlocks.js";
|
|
4
|
+
import type { BlockSchema } from "../schema/index.js";
|
|
5
|
+
import type { InlineContentSchema } from "../schema/inlineContent/types.js";
|
|
6
|
+
import type { StyleSchema } from "../schema/styles/types.js";
|
|
2
7
|
/**
|
|
3
8
|
* Get a TipTap node by id
|
|
4
9
|
*/
|
|
@@ -6,3 +11,64 @@ export declare function getNodeById(id: string, doc: Node): {
|
|
|
6
11
|
node: Node;
|
|
7
12
|
posBeforeNode: number;
|
|
8
13
|
} | undefined;
|
|
14
|
+
export declare function isNodeBlock(node: Node): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* This attributes the changes to a specific source.
|
|
17
|
+
*/
|
|
18
|
+
export type BlockChangeSource = {
|
|
19
|
+
/**
|
|
20
|
+
* When an event is triggered by the local user, the source is "local".
|
|
21
|
+
* This is the default source.
|
|
22
|
+
*/
|
|
23
|
+
type: "local";
|
|
24
|
+
} | {
|
|
25
|
+
/**
|
|
26
|
+
* When an event is triggered by a paste operation, the source is "paste".
|
|
27
|
+
*/
|
|
28
|
+
type: "paste";
|
|
29
|
+
} | {
|
|
30
|
+
/**
|
|
31
|
+
* When an event is triggered by a drop operation, the source is "drop".
|
|
32
|
+
*/
|
|
33
|
+
type: "drop";
|
|
34
|
+
} | {
|
|
35
|
+
/**
|
|
36
|
+
* When an event is triggered by an undo or redo operation, the source is "undo" or "redo".
|
|
37
|
+
* @note Y.js undo/redo are not differentiated.
|
|
38
|
+
*/
|
|
39
|
+
type: "undo" | "redo" | "undo-redo";
|
|
40
|
+
} | {
|
|
41
|
+
/**
|
|
42
|
+
* When an event is triggered by a remote user, the source is "remote".
|
|
43
|
+
*/
|
|
44
|
+
type: "yjs-remote";
|
|
45
|
+
};
|
|
46
|
+
export type BlocksChanged<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema> = Array<{
|
|
47
|
+
/**
|
|
48
|
+
* The affected block.
|
|
49
|
+
*/
|
|
50
|
+
block: Block<BSchema, ISchema, SSchema>;
|
|
51
|
+
/**
|
|
52
|
+
* The source of the change.
|
|
53
|
+
*/
|
|
54
|
+
source: BlockChangeSource;
|
|
55
|
+
} & ({
|
|
56
|
+
type: "insert" | "delete";
|
|
57
|
+
/**
|
|
58
|
+
* Insert and delete changes don't have a previous block.
|
|
59
|
+
*/
|
|
60
|
+
prevBlock: undefined;
|
|
61
|
+
} | {
|
|
62
|
+
type: "update";
|
|
63
|
+
/**
|
|
64
|
+
* The block before the update.
|
|
65
|
+
*/
|
|
66
|
+
prevBlock: Block<BSchema, ISchema, SSchema>;
|
|
67
|
+
})>;
|
|
68
|
+
/**
|
|
69
|
+
* Get the blocks that were changed by a transaction.
|
|
70
|
+
* @param transaction The transaction to get the changes from.
|
|
71
|
+
* @param editor The editor to get the changes from.
|
|
72
|
+
* @returns The blocks that were changed by the transaction.
|
|
73
|
+
*/
|
|
74
|
+
export declare function getBlocksChangedByTransaction<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema>(transaction: Transaction, appendedTransactions?: Transaction[]): BlocksChanged<BSchema, ISchema, SSchema>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Schema } from "prosemirror-model";
|
|
2
2
|
import { BlockSchema, InlineContentSchema, StyleSchema } from "../../../schema/index.js";
|
|
3
3
|
import { Block } from "../../../blocks/defaultBlocks.js";
|
|
4
|
-
export declare function HTMLToBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(html: string,
|
|
4
|
+
export declare function HTMLToBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(html: string, pmSchema: Schema): Promise<Block<BSchema, I, S>[]>;
|
|
@@ -2,4 +2,4 @@ import { Schema } from "prosemirror-model";
|
|
|
2
2
|
import { Block } from "../../../blocks/defaultBlocks.js";
|
|
3
3
|
import { BlockSchema, InlineContentSchema, StyleSchema } from "../../../schema/index.js";
|
|
4
4
|
export declare function markdownToHTML(markdown: string): Promise<string>;
|
|
5
|
-
export declare function markdownToBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(markdown: string,
|
|
5
|
+
export declare function markdownToBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(markdown: string, pmSchema: Schema): Promise<Block<BSchema, I, S>[]>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Node, Schema } from "prosemirror-model";
|
|
2
|
+
import type { Transaction } from "prosemirror-state";
|
|
3
|
+
import type { BlockSchema } from "../schema/blocks/types.js";
|
|
4
|
+
import type { InlineContentSchema } from "../schema/inlineContent/types.js";
|
|
5
|
+
import type { StyleSchema } from "../schema/styles/types.js";
|
|
6
|
+
import { BlockNoteSchema } from "../editor/BlockNoteSchema.js";
|
|
7
|
+
export declare function getPmSchema(trOrNode: Transaction | Node): Schema<any, any>;
|
|
8
|
+
export declare function getBlockNoteSchema<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(schema: Schema): BlockNoteSchema<BSchema, I, S>;
|
|
9
|
+
export declare function getBlockSchema<BSchema extends BlockSchema>(schema: Schema): BSchema;
|
|
10
|
+
export declare function getInlineContentSchema<I extends InlineContentSchema>(schema: Schema): I;
|
|
11
|
+
export declare function getStyleSchema<S extends StyleSchema>(schema: Schema): S;
|
|
12
|
+
export declare function getBlockCache(schema: Schema): import("../index.js").BlockCache<any, any, any>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { BlockNoteEditor } from "../editor/BlockNoteEditor.js";
|
|
2
|
+
/**
|
|
3
|
+
* This is used to keep track of positions of elements in the editor.
|
|
4
|
+
* It is needed because y-prosemirror's sync plugin can disrupt normal prosemirror position mapping.
|
|
5
|
+
*
|
|
6
|
+
* It is specifically made to be able to be used whether the editor is being used in a collaboratively, or single user, providing the same API.
|
|
7
|
+
*
|
|
8
|
+
* @param editor The editor to track the position of.
|
|
9
|
+
* @param position The position to track.
|
|
10
|
+
* @param side The side of the position to track. "left" is the default. "right" would move with the change if the change is in the right direction.
|
|
11
|
+
* @returns A function that returns the position of the element.
|
|
12
|
+
*/
|
|
13
|
+
export declare function trackPosition(
|
|
14
|
+
/**
|
|
15
|
+
* The editor to track the position of.
|
|
16
|
+
*/
|
|
17
|
+
editor: BlockNoteEditor<any, any, any>,
|
|
18
|
+
/**
|
|
19
|
+
* The position to track.
|
|
20
|
+
*/
|
|
21
|
+
position: number,
|
|
22
|
+
/**
|
|
23
|
+
* This is the side of the position to track. "left" is the default. "right" would move with the change if the change is in the right direction.
|
|
24
|
+
*/
|
|
25
|
+
side?: "left" | "right"): () => number;
|
|
@@ -16,16 +16,18 @@ import { Selection } from "./selectionTypes.js";
|
|
|
16
16
|
import { BlockNoteSchema } from "./BlockNoteSchema.js";
|
|
17
17
|
import { BlockNoteTipTapEditor } from "./BlockNoteTipTapEditor.js";
|
|
18
18
|
import { Dictionary } from "../i18n/dictionary.js";
|
|
19
|
-
import { Plugin, Transaction } from "@tiptap/pm/state";
|
|
19
|
+
import { type Command, type Plugin, type Transaction } from "@tiptap/pm/state";
|
|
20
20
|
import { EditorView } from "prosemirror-view";
|
|
21
|
+
import { BlocksChanged } from "../api/nodeUtil.js";
|
|
22
|
+
import { CodeBlockOptions } from "../blocks/CodeBlockContent/CodeBlockContent.js";
|
|
21
23
|
import type { ThreadStore, User } from "../comments/index.js";
|
|
22
24
|
import "../style.css";
|
|
23
25
|
import { EventEmitter } from "../util/EventEmitter.js";
|
|
24
|
-
import { CodeBlockOptions } from "../blocks/CodeBlockContent/CodeBlockContent.js";
|
|
25
26
|
export type BlockNoteExtensionFactory = (editor: BlockNoteEditor<any, any, any>) => BlockNoteExtension;
|
|
26
27
|
export type BlockNoteExtension = AnyExtension | {
|
|
27
28
|
plugin: Plugin;
|
|
28
29
|
};
|
|
30
|
+
export type BlockCache<BSchema extends BlockSchema = any, ISchema extends InlineContentSchema = any, SSchema extends StyleSchema = any> = WeakMap<Node, Block<BSchema, ISchema, SSchema>>;
|
|
29
31
|
export type BlockNoteEditorOptions<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema> = {
|
|
30
32
|
/**
|
|
31
33
|
* Whether changes to blocks (like indentation, creating lists, changing headings) should be animated or not. Defaults to `true`.
|
|
@@ -267,7 +269,7 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
267
269
|
* This is especially useful when we want to keep track of the same block across multiple operations,
|
|
268
270
|
* with this cache, blocks stay the same object reference (referential equality with ===).
|
|
269
271
|
*/
|
|
270
|
-
blockCache:
|
|
272
|
+
blockCache: BlockCache;
|
|
271
273
|
/**
|
|
272
274
|
* The dictionary contains translations for the editor.
|
|
273
275
|
*/
|
|
@@ -315,7 +317,61 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
315
317
|
};
|
|
316
318
|
static create<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema>(options?: Partial<BlockNoteEditorOptions<BSchema, ISchema, SSchema>>): BlockNoteEditor<BSchema, ISchema, SSchema>;
|
|
317
319
|
protected constructor(options: Partial<BlockNoteEditorOptions<any, any, any>>);
|
|
318
|
-
|
|
320
|
+
/**
|
|
321
|
+
* Stores the currently active transaction, which is the accumulated transaction from all {@link dispatch} calls during a {@link transact} calls
|
|
322
|
+
*/
|
|
323
|
+
private activeTransaction;
|
|
324
|
+
/**
|
|
325
|
+
* Execute a prosemirror command. This is mostly for backwards compatibility with older code.
|
|
326
|
+
*
|
|
327
|
+
* @note You should prefer the {@link transact} method when possible, as it will automatically handle the dispatching of the transaction and work across blocknote transactions.
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* ```ts
|
|
331
|
+
* editor.exec((state, dispatch, view) => {
|
|
332
|
+
* dispatch(state.tr.insertText("Hello, world!"));
|
|
333
|
+
* });
|
|
334
|
+
* ```
|
|
335
|
+
*/
|
|
336
|
+
exec(command: Command): boolean;
|
|
337
|
+
/**
|
|
338
|
+
* Check if a command can be executed. A command should return `false` if it is not valid in the current state.
|
|
339
|
+
*
|
|
340
|
+
* @example
|
|
341
|
+
* ```ts
|
|
342
|
+
* if (editor.canExec(command)) {
|
|
343
|
+
* // show button
|
|
344
|
+
* } else {
|
|
345
|
+
* // hide button
|
|
346
|
+
* }
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
canExec(command: Command): boolean;
|
|
350
|
+
/**
|
|
351
|
+
* Execute a function within a "blocknote transaction".
|
|
352
|
+
* All changes to the editor within the transaction will be grouped together, so that
|
|
353
|
+
* we can dispatch them as a single operation (thus creating only a single undo step)
|
|
354
|
+
*
|
|
355
|
+
* @note There is no need to dispatch the transaction, as it will be automatically dispatched when the callback is complete.
|
|
356
|
+
*
|
|
357
|
+
* @example
|
|
358
|
+
* ```ts
|
|
359
|
+
* // All changes to the editor will be grouped together
|
|
360
|
+
* editor.transact((tr) => {
|
|
361
|
+
* tr.insertText("Hello, world!");
|
|
362
|
+
* // These two operations will be grouped together in a single undo step
|
|
363
|
+
* editor.transact((tr) => {
|
|
364
|
+
* tr.insertText("Hello, world!");
|
|
365
|
+
* });
|
|
366
|
+
* });
|
|
367
|
+
* ```
|
|
368
|
+
*/
|
|
369
|
+
transact<T>(callback: (
|
|
370
|
+
/**
|
|
371
|
+
* The current active transaction, this will automatically be dispatched to the editor when the callback is complete
|
|
372
|
+
* If another `transact` call is made within the callback, it will be passed the same transaction as the parent call.
|
|
373
|
+
*/
|
|
374
|
+
tr: Transaction) => T): T;
|
|
319
375
|
/**
|
|
320
376
|
* Mount the editor to a parent DOM element. Call mount(undefined) to clean up
|
|
321
377
|
*
|
|
@@ -326,10 +382,6 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
326
382
|
* Get the underlying prosemirror view
|
|
327
383
|
*/
|
|
328
384
|
get prosemirrorView(): EditorView | undefined;
|
|
329
|
-
/**
|
|
330
|
-
* Get the underlying prosemirror state
|
|
331
|
-
*/
|
|
332
|
-
get prosemirrorState(): import("prosemirror-state").EditorState;
|
|
333
385
|
get domElement(): HTMLDivElement | undefined;
|
|
334
386
|
isFocused(): boolean;
|
|
335
387
|
focus(): void;
|
|
@@ -415,6 +467,11 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
415
467
|
* Gets a snapshot of the current selection.
|
|
416
468
|
*/
|
|
417
469
|
getSelection(): Selection<BSchema, ISchema, SSchema> | undefined;
|
|
470
|
+
/**
|
|
471
|
+
* Sets the selection to a range of blocks.
|
|
472
|
+
* @param startBlock The identifier of the block that should be the start of the selection.
|
|
473
|
+
* @param endBlock The identifier of the block that should be the end of the selection.
|
|
474
|
+
*/
|
|
418
475
|
setSelection(startBlock: BlockIdentifier, endBlock: BlockIdentifier): void;
|
|
419
476
|
/**
|
|
420
477
|
* Checks if the editor is currently editable, or if it's locked.
|
|
@@ -447,7 +504,7 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
447
504
|
* Removes existing blocks from the editor. Throws an error if any of the blocks could not be found.
|
|
448
505
|
* @param blocksToRemove An array of identifiers for existing blocks that should be removed.
|
|
449
506
|
*/
|
|
450
|
-
removeBlocks(blocksToRemove: BlockIdentifier[]): Block<
|
|
507
|
+
removeBlocks(blocksToRemove: BlockIdentifier[]): Block<Record<string, import("../index.js").BlockConfig>, InlineContentSchema, StyleSchema>[];
|
|
451
508
|
/**
|
|
452
509
|
* Replaces existing blocks in the editor with new blocks. If the blocks that should be removed are not adjacent or
|
|
453
510
|
* are at different nesting levels, `blocksToInsert` will be inserted at the position of the first block in
|
|
@@ -580,7 +637,12 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
580
637
|
* @param callback The callback to execute.
|
|
581
638
|
* @returns A function to remove the callback.
|
|
582
639
|
*/
|
|
583
|
-
onChange(callback: (editor: BlockNoteEditor<BSchema, ISchema, SSchema
|
|
640
|
+
onChange(callback: (editor: BlockNoteEditor<BSchema, ISchema, SSchema>, context: {
|
|
641
|
+
/**
|
|
642
|
+
* Returns the blocks that were inserted, updated, or deleted by the change that occurred.
|
|
643
|
+
*/
|
|
644
|
+
getChanges(): BlocksChanged<BSchema, ISchema, SSchema>;
|
|
645
|
+
}) => void): (() => void) | undefined;
|
|
584
646
|
/**
|
|
585
647
|
* A callback function that runs whenever the text cursor position or selection changes.
|
|
586
648
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EditorOptions } from "@tiptap/core";
|
|
1
|
+
import { Editor, EditorOptions } from "@tiptap/core";
|
|
2
2
|
import { Editor as TiptapEditor } from "@tiptap/core";
|
|
3
3
|
import { EditorState, Transaction } from "@tiptap/pm/state";
|
|
4
4
|
import { PartialBlock } from "../blocks/defaultBlocks.js";
|
|
@@ -16,7 +16,7 @@ export declare class BlockNoteTipTapEditor extends TiptapEditor {
|
|
|
16
16
|
static create: (options: BlockNoteTipTapEditorOptions, styleSchema: StyleSchema) => BlockNoteTipTapEditor;
|
|
17
17
|
protected constructor(options: BlockNoteTipTapEditorOptions, styleSchema: StyleSchema);
|
|
18
18
|
get state(): EditorState;
|
|
19
|
-
dispatch(
|
|
19
|
+
dispatch(transaction: Transaction): void;
|
|
20
20
|
/**
|
|
21
21
|
* Replace the default `createView` method with a custom one - which we call on mount
|
|
22
22
|
*/
|
|
@@ -28,3 +28,16 @@ export declare class BlockNoteTipTapEditor extends TiptapEditor {
|
|
|
28
28
|
*/
|
|
29
29
|
mount: (blockNoteEditor: BlockNoteEditor<any, any, any>, element?: HTMLElement | null, contentComponent?: any) => void;
|
|
30
30
|
}
|
|
31
|
+
declare module "@tiptap/core" {
|
|
32
|
+
interface EditorEvents {
|
|
33
|
+
/**
|
|
34
|
+
* This is a custom event that will be emitted in Tiptap V3.
|
|
35
|
+
* We use it to provide the appendedTransactions, until Tiptap V3 is released.
|
|
36
|
+
*/
|
|
37
|
+
"v3-update": {
|
|
38
|
+
editor: Editor;
|
|
39
|
+
transaction: Transaction;
|
|
40
|
+
appendedTransactions: Transaction[];
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -102,7 +102,7 @@ export declare class TableHandlesProsemirrorPlugin<I extends InlineContentSchema
|
|
|
102
102
|
} | {
|
|
103
103
|
orientation: "column";
|
|
104
104
|
side: "left" | "right";
|
|
105
|
-
}) =>
|
|
105
|
+
}) => void;
|
|
106
106
|
/**
|
|
107
107
|
* Removes a row or column from the table using prosemirror-table commands
|
|
108
108
|
*/
|
package/types/src/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ export * from "./api/exporters/html/externalHTMLExporter.js";
|
|
|
3
3
|
export * from "./api/exporters/html/internalHTMLSerializer.js";
|
|
4
4
|
export * from "./api/getBlockInfoFromPos.js";
|
|
5
5
|
export * from "./api/nodeUtil.js";
|
|
6
|
-
export * from "./api/testUtil/index.js";
|
|
7
6
|
export * from "./blocks/AudioBlockContent/AudioBlockContent.js";
|
|
8
7
|
export * from "./blocks/CodeBlockContent/CodeBlockContent.js";
|
|
9
8
|
export * from "./blocks/FileBlockContent/FileBlockContent.js";
|
|
@@ -54,9 +53,9 @@ export * from "./util/string.js";
|
|
|
54
53
|
export * from "./util/typescript.js";
|
|
55
54
|
export type { CodeBlockOptions } from "./blocks/CodeBlockContent/CodeBlockContent.js";
|
|
56
55
|
export { UnreachableCaseError, assertEmpty } from "./util/typescript.js";
|
|
56
|
+
export { selectedFragmentToHTML } from "./api/clipboard/toClipboard/copyExtension.js";
|
|
57
57
|
export * from "./api/nodeConversions/blockToNode.js";
|
|
58
58
|
export * from "./api/nodeConversions/nodeToBlock.js";
|
|
59
|
-
export * from "./api/testUtil/partialBlockTestUtil.js";
|
|
60
59
|
export * from "./extensions/UniqueID/UniqueID.js";
|
|
61
60
|
export * from "./api/exporters/markdown/markdownExporter.js";
|
|
62
61
|
export * from "./api/parsers/html/parseHTML.js";
|