@blocknote/core 0.28.0 → 0.29.1
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 +9 -9
- package/dist/blocknote.cjs.map +1 -1
- package/dist/blocknote.js +3221 -3351
- package/dist/blocknote.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.ts +4 -2
- 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 -131
- 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 +22 -19
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +8 -8
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +150 -136
- 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/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/clipboardExternal.test.d.ts +0 -1
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin, PluginKey, PluginView } from "prosemirror-state";
|
|
1
|
+
import { EditorState, Plugin, PluginKey, PluginView } from "prosemirror-state";
|
|
2
2
|
import {
|
|
3
3
|
CellSelection,
|
|
4
4
|
addColumnAfter,
|
|
@@ -263,9 +263,8 @@ export class TableHandlesView<
|
|
|
263
263
|
| BlockFromConfigNoChildren<DefaultBlockSchema["table"], I, S>
|
|
264
264
|
| undefined;
|
|
265
265
|
|
|
266
|
-
const pmNodeInfo =
|
|
267
|
-
blockEl.id,
|
|
268
|
-
this.editor._tiptapEditor.state.doc
|
|
266
|
+
const pmNodeInfo = this.editor.transact((tr) =>
|
|
267
|
+
getNodeById(blockEl.id, tr.doc)
|
|
269
268
|
);
|
|
270
269
|
if (!pmNodeInfo) {
|
|
271
270
|
throw new Error(`Block with ID ${blockEl.id} not found`);
|
|
@@ -273,10 +272,10 @@ export class TableHandlesView<
|
|
|
273
272
|
|
|
274
273
|
const block = nodeToBlock(
|
|
275
274
|
pmNodeInfo.node,
|
|
275
|
+
this.editor.pmSchema,
|
|
276
276
|
this.editor.schema.blockSchema,
|
|
277
277
|
this.editor.schema.inlineContentSchema,
|
|
278
|
-
this.editor.schema.styleSchema
|
|
279
|
-
this.editor.blockCache
|
|
278
|
+
this.editor.schema.styleSchema
|
|
280
279
|
);
|
|
281
280
|
|
|
282
281
|
if (checkBlockIsDefaultType("table", block, this.editor)) {
|
|
@@ -447,9 +446,7 @@ export class TableHandlesView<
|
|
|
447
446
|
// Dispatches a dummy transaction to force a decorations update if
|
|
448
447
|
// necessary.
|
|
449
448
|
if (dispatchDecorationsTransaction) {
|
|
450
|
-
this.editor.
|
|
451
|
-
this.pmView.state.tr.setMeta(tableHandlesPluginKey, true)
|
|
452
|
-
);
|
|
449
|
+
this.editor.transact((tr) => tr.setMeta(tableHandlesPluginKey, true));
|
|
453
450
|
}
|
|
454
451
|
};
|
|
455
452
|
|
|
@@ -814,12 +811,12 @@ export class TableHandlesProsemirrorPlugin<
|
|
|
814
811
|
};
|
|
815
812
|
this.view!.emitUpdate();
|
|
816
813
|
|
|
817
|
-
this.editor.
|
|
818
|
-
|
|
814
|
+
this.editor.transact((tr) =>
|
|
815
|
+
tr.setMeta(tableHandlesPluginKey, {
|
|
819
816
|
draggedCellOrientation:
|
|
820
|
-
this.view!.state
|
|
821
|
-
originalIndex: this.view!.state
|
|
822
|
-
newIndex: this.view!.state
|
|
817
|
+
this.view!.state!.draggingState!.draggedCellOrientation,
|
|
818
|
+
originalIndex: this.view!.state!.colIndex,
|
|
819
|
+
newIndex: this.view!.state!.colIndex,
|
|
823
820
|
tablePos: this.view!.tablePos,
|
|
824
821
|
})
|
|
825
822
|
);
|
|
@@ -857,12 +854,12 @@ export class TableHandlesProsemirrorPlugin<
|
|
|
857
854
|
};
|
|
858
855
|
this.view!.emitUpdate();
|
|
859
856
|
|
|
860
|
-
this.editor.
|
|
861
|
-
|
|
857
|
+
this.editor.transact((tr) =>
|
|
858
|
+
tr.setMeta(tableHandlesPluginKey, {
|
|
862
859
|
draggedCellOrientation:
|
|
863
|
-
this.view!.state
|
|
864
|
-
originalIndex: this.view!.state
|
|
865
|
-
newIndex: this.view!.state
|
|
860
|
+
this.view!.state!.draggingState!.draggedCellOrientation,
|
|
861
|
+
originalIndex: this.view!.state!.rowIndex,
|
|
862
|
+
newIndex: this.view!.state!.rowIndex,
|
|
866
863
|
tablePos: this.view!.tablePos,
|
|
867
864
|
})
|
|
868
865
|
);
|
|
@@ -890,9 +887,7 @@ export class TableHandlesProsemirrorPlugin<
|
|
|
890
887
|
this.view!.state.draggingState = undefined;
|
|
891
888
|
this.view!.emitUpdate();
|
|
892
889
|
|
|
893
|
-
this.editor.
|
|
894
|
-
this.editor._tiptapEditor.state.tr.setMeta(tableHandlesPluginKey, null)
|
|
895
|
-
);
|
|
890
|
+
this.editor.transact((tr) => tr.setMeta(tableHandlesPluginKey, null));
|
|
896
891
|
|
|
897
892
|
if (!this.editor.prosemirrorView) {
|
|
898
893
|
throw new Error("Editor view not initialized.");
|
|
@@ -939,6 +934,7 @@ export class TableHandlesProsemirrorPlugin<
|
|
|
939
934
|
* @returns The new state after the selection has been set.
|
|
940
935
|
*/
|
|
941
936
|
private setCellSelection = (
|
|
937
|
+
state: EditorState,
|
|
942
938
|
relativeStartCell: RelativeCellIndices,
|
|
943
939
|
relativeEndCell: RelativeCellIndices = relativeStartCell
|
|
944
940
|
) => {
|
|
@@ -948,7 +944,6 @@ export class TableHandlesProsemirrorPlugin<
|
|
|
948
944
|
throw new Error("Table handles view not initialized");
|
|
949
945
|
}
|
|
950
946
|
|
|
951
|
-
const state = this.editor.prosemirrorState;
|
|
952
947
|
const tableResolvedPos = state.doc.resolve(view.tablePos! + 1);
|
|
953
948
|
const startRowResolvedPos = state.doc.resolve(
|
|
954
949
|
tableResolvedPos.posAtIndex(relativeStartCell.row) + 1
|
|
@@ -986,24 +981,28 @@ export class TableHandlesProsemirrorPlugin<
|
|
|
986
981
|
| { orientation: "row"; side: "above" | "below" }
|
|
987
982
|
| { orientation: "column"; side: "left" | "right" }
|
|
988
983
|
) => {
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
984
|
+
this.editor.exec((beforeState, dispatch) => {
|
|
985
|
+
const state = this.setCellSelection(
|
|
986
|
+
beforeState,
|
|
987
|
+
direction.orientation === "row"
|
|
988
|
+
? { row: index, col: 0 }
|
|
989
|
+
: { row: 0, col: index }
|
|
990
|
+
);
|
|
991
|
+
|
|
992
|
+
if (direction.orientation === "row") {
|
|
993
|
+
if (direction.side === "above") {
|
|
994
|
+
return addRowBefore(state, dispatch);
|
|
995
|
+
} else {
|
|
996
|
+
return addRowAfter(state, dispatch);
|
|
997
|
+
}
|
|
1003
998
|
} else {
|
|
1004
|
-
|
|
999
|
+
if (direction.side === "left") {
|
|
1000
|
+
return addColumnBefore(state, dispatch);
|
|
1001
|
+
} else {
|
|
1002
|
+
return addColumnAfter(state, dispatch);
|
|
1003
|
+
}
|
|
1005
1004
|
}
|
|
1006
|
-
}
|
|
1005
|
+
});
|
|
1007
1006
|
};
|
|
1008
1007
|
|
|
1009
1008
|
/**
|
|
@@ -1013,14 +1012,22 @@ export class TableHandlesProsemirrorPlugin<
|
|
|
1013
1012
|
index: RelativeCellIndices["row"] | RelativeCellIndices["col"],
|
|
1014
1013
|
direction: "row" | "column"
|
|
1015
1014
|
) => {
|
|
1016
|
-
const state = this.setCellSelection(
|
|
1017
|
-
direction === "row" ? { row: index, col: 0 } : { row: 0, col: index }
|
|
1018
|
-
);
|
|
1019
|
-
|
|
1020
1015
|
if (direction === "row") {
|
|
1021
|
-
return
|
|
1016
|
+
return this.editor.exec((beforeState, dispatch) => {
|
|
1017
|
+
const state = this.setCellSelection(beforeState, {
|
|
1018
|
+
row: index,
|
|
1019
|
+
col: 0,
|
|
1020
|
+
});
|
|
1021
|
+
return deleteRow(state, dispatch);
|
|
1022
|
+
});
|
|
1022
1023
|
} else {
|
|
1023
|
-
return
|
|
1024
|
+
return this.editor.exec((beforeState, dispatch) => {
|
|
1025
|
+
const state = this.setCellSelection(beforeState, {
|
|
1026
|
+
row: 0,
|
|
1027
|
+
col: index,
|
|
1028
|
+
});
|
|
1029
|
+
return deleteColumn(state, dispatch);
|
|
1030
|
+
});
|
|
1024
1031
|
}
|
|
1025
1032
|
};
|
|
1026
1033
|
|
|
@@ -1031,14 +1038,17 @@ export class TableHandlesProsemirrorPlugin<
|
|
|
1031
1038
|
relativeStartCell: RelativeCellIndices;
|
|
1032
1039
|
relativeEndCell: RelativeCellIndices;
|
|
1033
1040
|
}) => {
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1041
|
+
return this.editor.exec((beforeState, dispatch) => {
|
|
1042
|
+
const state = cellsToMerge
|
|
1043
|
+
? this.setCellSelection(
|
|
1044
|
+
beforeState,
|
|
1045
|
+
cellsToMerge.relativeStartCell,
|
|
1046
|
+
cellsToMerge.relativeEndCell
|
|
1047
|
+
)
|
|
1048
|
+
: beforeState;
|
|
1049
|
+
|
|
1050
|
+
return mergeCells(state, dispatch);
|
|
1051
|
+
});
|
|
1042
1052
|
};
|
|
1043
1053
|
|
|
1044
1054
|
/**
|
|
@@ -1046,11 +1056,13 @@ export class TableHandlesProsemirrorPlugin<
|
|
|
1046
1056
|
* If no cell is provided, the current cell selected will be split.
|
|
1047
1057
|
*/
|
|
1048
1058
|
splitCell = (relativeCellToSplit?: RelativeCellIndices) => {
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1059
|
+
return this.editor.exec((beforeState, dispatch) => {
|
|
1060
|
+
const state = relativeCellToSplit
|
|
1061
|
+
? this.setCellSelection(beforeState, relativeCellToSplit)
|
|
1062
|
+
: beforeState;
|
|
1052
1063
|
|
|
1053
|
-
|
|
1064
|
+
return splitCell(state, dispatch);
|
|
1065
|
+
});
|
|
1054
1066
|
};
|
|
1055
1067
|
|
|
1056
1068
|
/**
|
|
@@ -1068,69 +1080,71 @@ export class TableHandlesProsemirrorPlugin<
|
|
|
1068
1080
|
cells: RelativeCellIndices[];
|
|
1069
1081
|
} => {
|
|
1070
1082
|
// Based on the current selection, find the table cells that are within the selected range
|
|
1071
|
-
const state = this.editor.prosemirrorState;
|
|
1072
|
-
const selection = state.selection;
|
|
1073
|
-
|
|
1074
|
-
let $fromCell = selection.$from;
|
|
1075
|
-
let $toCell = selection.$to;
|
|
1076
|
-
if (isTableCellSelection(selection)) {
|
|
1077
|
-
// When the selection is a table cell selection, we can find the
|
|
1078
|
-
// from and to cells by iterating over the ranges in the selection
|
|
1079
|
-
const { ranges } = selection;
|
|
1080
|
-
ranges.forEach((range) => {
|
|
1081
|
-
$fromCell = range.$from.min($fromCell ?? range.$from);
|
|
1082
|
-
$toCell = range.$to.max($toCell ?? range.$to);
|
|
1083
|
-
});
|
|
1084
|
-
} else {
|
|
1085
|
-
// When the selection is a normal text selection
|
|
1086
|
-
// Assumes we are within a tableParagraph
|
|
1087
|
-
// And find the from and to cells by resolving the positions
|
|
1088
|
-
$fromCell = state.doc.resolve(
|
|
1089
|
-
selection.$from.pos - selection.$from.parentOffset - 1
|
|
1090
|
-
);
|
|
1091
|
-
$toCell = state.doc.resolve(
|
|
1092
|
-
selection.$to.pos - selection.$to.parentOffset - 1
|
|
1093
|
-
);
|
|
1094
1083
|
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1084
|
+
return this.editor.transact((tr) => {
|
|
1085
|
+
const selection = tr.selection;
|
|
1086
|
+
|
|
1087
|
+
let $fromCell = selection.$from;
|
|
1088
|
+
let $toCell = selection.$to;
|
|
1089
|
+
if (isTableCellSelection(selection)) {
|
|
1090
|
+
// When the selection is a table cell selection, we can find the
|
|
1091
|
+
// from and to cells by iterating over the ranges in the selection
|
|
1092
|
+
const { ranges } = selection;
|
|
1093
|
+
ranges.forEach((range) => {
|
|
1094
|
+
$fromCell = range.$from.min($fromCell ?? range.$from);
|
|
1095
|
+
$toCell = range.$to.max($toCell ?? range.$to);
|
|
1096
|
+
});
|
|
1097
|
+
} else {
|
|
1098
|
+
// When the selection is a normal text selection
|
|
1099
|
+
// Assumes we are within a tableParagraph
|
|
1100
|
+
// And find the from and to cells by resolving the positions
|
|
1101
|
+
$fromCell = tr.doc.resolve(
|
|
1102
|
+
selection.$from.pos - selection.$from.parentOffset - 1
|
|
1103
|
+
);
|
|
1104
|
+
$toCell = tr.doc.resolve(
|
|
1105
|
+
selection.$to.pos - selection.$to.parentOffset - 1
|
|
1106
|
+
);
|
|
1107
|
+
|
|
1108
|
+
// Opt-out when the selection is not pointing into cells
|
|
1109
|
+
if ($fromCell.pos === 0 || $toCell.pos === 0) {
|
|
1110
|
+
return undefined;
|
|
1111
|
+
}
|
|
1098
1112
|
}
|
|
1099
|
-
}
|
|
1100
1113
|
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1114
|
+
// Find the row and table that the from and to cells are in
|
|
1115
|
+
const $fromRow = tr.doc.resolve(
|
|
1116
|
+
$fromCell.pos - $fromCell.parentOffset - 1
|
|
1117
|
+
);
|
|
1118
|
+
const $toRow = tr.doc.resolve($toCell.pos - $toCell.parentOffset - 1);
|
|
1119
|
+
|
|
1120
|
+
// Find the table
|
|
1121
|
+
const $table = tr.doc.resolve($fromRow.pos - $fromRow.parentOffset - 1);
|
|
1122
|
+
|
|
1123
|
+
// Find the column and row indices of the from and to cells
|
|
1124
|
+
const fromColIndex = $fromCell.index($fromRow.depth);
|
|
1125
|
+
const fromRowIndex = $fromRow.index($table.depth);
|
|
1126
|
+
const toColIndex = $toCell.index($toRow.depth);
|
|
1127
|
+
const toRowIndex = $toRow.index($table.depth);
|
|
1128
|
+
|
|
1129
|
+
const cells: RelativeCellIndices[] = [];
|
|
1130
|
+
for (let row = fromRowIndex; row <= toRowIndex; row++) {
|
|
1131
|
+
for (let col = fromColIndex; col <= toColIndex; col++) {
|
|
1132
|
+
cells.push({ row, col });
|
|
1133
|
+
}
|
|
1120
1134
|
}
|
|
1121
|
-
}
|
|
1122
1135
|
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1136
|
+
return {
|
|
1137
|
+
from: {
|
|
1138
|
+
row: fromRowIndex,
|
|
1139
|
+
col: fromColIndex,
|
|
1140
|
+
},
|
|
1141
|
+
to: {
|
|
1142
|
+
row: toRowIndex,
|
|
1143
|
+
col: toColIndex,
|
|
1144
|
+
},
|
|
1145
|
+
cells,
|
|
1146
|
+
};
|
|
1147
|
+
});
|
|
1134
1148
|
};
|
|
1135
1149
|
|
|
1136
1150
|
/**
|
|
@@ -1143,32 +1157,32 @@ export class TableHandlesProsemirrorPlugin<
|
|
|
1143
1157
|
| BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>
|
|
1144
1158
|
| undefined
|
|
1145
1159
|
) => {
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
: undefined;
|
|
1160
|
+
return this.editor.transact((tr) => {
|
|
1161
|
+
const isSelectingTableCells = isTableCellSelection(tr.selection)
|
|
1162
|
+
? tr.selection
|
|
1163
|
+
: undefined;
|
|
1151
1164
|
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1165
|
+
if (
|
|
1166
|
+
!isSelectingTableCells ||
|
|
1167
|
+
!block ||
|
|
1168
|
+
// Only offer the merge button if there is more than one cell selected.
|
|
1169
|
+
isSelectingTableCells.ranges.length <= 1
|
|
1170
|
+
) {
|
|
1171
|
+
return undefined;
|
|
1172
|
+
}
|
|
1160
1173
|
|
|
1161
|
-
|
|
1174
|
+
const cellSelection = this.getCellSelection();
|
|
1162
1175
|
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1176
|
+
if (!cellSelection) {
|
|
1177
|
+
return undefined;
|
|
1178
|
+
}
|
|
1166
1179
|
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1180
|
+
if (areInSameColumn(cellSelection.from, cellSelection.to, block)) {
|
|
1181
|
+
return "vertical";
|
|
1182
|
+
}
|
|
1170
1183
|
|
|
1171
|
-
|
|
1184
|
+
return "horizontal";
|
|
1185
|
+
});
|
|
1172
1186
|
};
|
|
1173
1187
|
|
|
1174
1188
|
cropEmptyRowsOrColumns = (
|
package/src/index.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";
|
|
@@ -59,10 +58,12 @@ export * from "./util/typescript.js";
|
|
|
59
58
|
export type { CodeBlockOptions } from "./blocks/CodeBlockContent/CodeBlockContent.js";
|
|
60
59
|
export { UnreachableCaseError, assertEmpty } from "./util/typescript.js";
|
|
61
60
|
|
|
62
|
-
//
|
|
61
|
+
// Unit testing
|
|
62
|
+
export { selectedFragmentToHTML } from "./api/clipboard/toClipboard/copyExtension.js";
|
|
63
|
+
|
|
64
|
+
// Node conversions
|
|
63
65
|
export * from "./api/nodeConversions/blockToNode.js";
|
|
64
66
|
export * from "./api/nodeConversions/nodeToBlock.js";
|
|
65
|
-
export * from "./api/testUtil/partialBlockTestUtil.js";
|
|
66
67
|
export * from "./extensions/UniqueID/UniqueID.js";
|
|
67
68
|
|
|
68
69
|
// for server-util (TODO: maybe move):
|
|
@@ -136,11 +136,7 @@ export function createInlineContentSpec<
|
|
|
136
136
|
return;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
const content = inlineContentToNodes(
|
|
140
|
-
[update],
|
|
141
|
-
editor._tiptapEditor.schema,
|
|
142
|
-
editor.schema.styleSchema
|
|
143
|
-
);
|
|
139
|
+
const content = inlineContentToNodes([update], editor.pmSchema);
|
|
144
140
|
|
|
145
141
|
editor.dispatch(
|
|
146
142
|
editor.prosemirrorView.state.tr.replaceWith(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Block, PartialBlock } from "../../../../blocks/defaultBlocks.js";
|
|
2
|
-
import type { BlockNoteEditor } from "../../../../editor/BlockNoteEditor";
|
|
3
2
|
import { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../../../schema/index.js";
|
|
4
|
-
|
|
3
|
+
import type { Transaction } from "prosemirror-state";
|
|
4
|
+
export declare function insertBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(tr: Transaction, blocksToInsert: PartialBlock<BSchema, I, S>[], referenceBlock: BlockIdentifier, placement?: "before" | "after"): Block<BSchema, I, S>[];
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
import { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../../../schema/index.js";
|
|
4
|
-
export declare function removeAndInsertBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(
|
|
5
|
-
insertedBlocks: Block<BSchema, I, S>[];
|
|
6
|
-
removedBlocks: Block<BSchema, I, S>[];
|
|
7
|
-
};
|
|
8
|
-
export declare function replaceBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(editor: BlockNoteEditor<BSchema, I, S>, blocksToRemove: BlockIdentifier[], blocksToInsert: PartialBlock<BSchema, I, S>[]): {
|
|
1
|
+
import type { Transaction } from "prosemirror-state";
|
|
2
|
+
import type { Block, PartialBlock } from "../../../../blocks/defaultBlocks.js";
|
|
3
|
+
import type { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../../../schema/index.js";
|
|
4
|
+
export declare function removeAndInsertBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(tr: Transaction, blocksToRemove: BlockIdentifier[], blocksToInsert: PartialBlock<BSchema, I, S>[]): {
|
|
9
5
|
insertedBlocks: Block<BSchema, I, S>[];
|
|
10
6
|
removedBlocks: Block<BSchema, I, S>[];
|
|
11
7
|
};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Block, PartialBlock } from "../../../../blocks/defaultBlocks.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
dispatch: ((args?: any) => any) | undefined;
|
|
1
|
+
import type { Transaction } from "prosemirror-state";
|
|
2
|
+
import type { Block, PartialBlock } from "../../../../blocks/defaultBlocks.js";
|
|
3
|
+
import type { BlockIdentifier, 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
|
+
export declare const updateBlockCommand: <BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(posBeforeBlock: number, block: PartialBlock<BSchema, I, S>) => ({ tr, dispatch, }: {
|
|
7
|
+
tr: Transaction;
|
|
8
|
+
dispatch?: () => void;
|
|
10
9
|
}) => boolean;
|
|
11
|
-
export declare function updateBlock<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(
|
|
10
|
+
export declare function updateBlock<BSchema extends BlockSchema = any, I extends InlineContentSchema = any, S extends StyleSchema = any>(tr: Transaction, blockToUpdate: BlockIdentifier, update: PartialBlock<BSchema, I, S>): Block<BSchema, I, S>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
import { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../../schema/index.js";
|
|
4
|
-
export declare function getBlock<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(
|
|
5
|
-
export declare function getPrevBlock<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(
|
|
6
|
-
export declare function getNextBlock<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(
|
|
7
|
-
export declare function getParentBlock<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(
|
|
1
|
+
import type { Node } from "prosemirror-model";
|
|
2
|
+
import type { Block } from "../../../blocks/defaultBlocks.js";
|
|
3
|
+
import type { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../../schema/index.js";
|
|
4
|
+
export declare function getBlock<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(doc: Node, blockIdentifier: BlockIdentifier): Block<BSchema, I, S> | undefined;
|
|
5
|
+
export declare function getPrevBlock<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(doc: Node, blockIdentifier: BlockIdentifier): Block<BSchema, I, S> | undefined;
|
|
6
|
+
export declare function getNextBlock<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(doc: Node, blockIdentifier: BlockIdentifier): Block<BSchema, I, S> | undefined;
|
|
7
|
+
export declare function getParentBlock<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(doc: Node, blockIdentifier: BlockIdentifier): Block<BSchema, I, S> | undefined;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Node } from "prosemirror-model";
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import type { Transaction } from "prosemirror-state";
|
|
3
|
+
export declare function insertContentAt(tr: Transaction, position: number | {
|
|
4
|
+
from: number;
|
|
5
|
+
to: number;
|
|
6
|
+
}, nodes: Node[], options?: {
|
|
5
7
|
updateSelection: boolean;
|
|
6
8
|
}): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Transaction } from "prosemirror-state";
|
|
2
2
|
import { Selection } from "../../../editor/selectionTypes.js";
|
|
3
3
|
import { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../../schema/index.js";
|
|
4
|
-
export declare function getSelection<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(
|
|
5
|
-
export declare function setSelection
|
|
4
|
+
export declare function getSelection<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(tr: Transaction): Selection<BSchema, I, S> | undefined;
|
|
5
|
+
export declare function setSelection(tr: Transaction, startBlock: BlockIdentifier, endBlock: BlockIdentifier): void;
|
package/types/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { TextCursorPosition } from "../../../../editor/cursorPositionTypes.js";
|
|
3
|
-
import { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../../../schema/index.js";
|
|
4
|
-
export declare function getTextCursorPosition<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(
|
|
5
|
-
export declare function setTextCursorPosition
|
|
1
|
+
import { type Transaction } from "prosemirror-state";
|
|
2
|
+
import type { TextCursorPosition } from "../../../../editor/cursorPositionTypes.js";
|
|
3
|
+
import type { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../../../schema/index.js";
|
|
4
|
+
export declare function getTextCursorPosition<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(tr: Transaction): TextCursorPosition<BSchema, I, S>;
|
|
5
|
+
export declare function setTextCursorPosition(tr: Transaction, targetBlock: BlockIdentifier, placement?: "start" | "end"): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Node, ResolvedPos } from "prosemirror-model";
|
|
2
|
-
import { EditorState } from "prosemirror-state";
|
|
2
|
+
import { EditorState, Transaction } from "prosemirror-state";
|
|
3
3
|
type SingleBlockInfo = {
|
|
4
4
|
node: Node;
|
|
5
5
|
beforePos: number;
|
|
@@ -92,4 +92,11 @@ export declare function getBlockInfoFromResolvedPos(resolvedPos: ResolvedPos): B
|
|
|
92
92
|
* @param state The ProseMirror editor state.
|
|
93
93
|
*/
|
|
94
94
|
export declare function getBlockInfoFromSelection(state: EditorState): BlockInfo;
|
|
95
|
+
/**
|
|
96
|
+
* Gets information regarding the ProseMirror nodes that make up a block. The
|
|
97
|
+
* block chosen is the one currently containing the current ProseMirror
|
|
98
|
+
* selection.
|
|
99
|
+
* @param tr The ProseMirror transaction.
|
|
100
|
+
*/
|
|
101
|
+
export declare function getBlockInfoFromTransaction(tr: Transaction): BlockInfo;
|
|
95
102
|
export {};
|
|
@@ -4,12 +4,12 @@ import type { PartialBlock } from "../../blocks/defaultBlocks";
|
|
|
4
4
|
/**
|
|
5
5
|
* converts an array of inline content elements to prosemirror nodes
|
|
6
6
|
*/
|
|
7
|
-
export declare function inlineContentToNodes<I extends InlineContentSchema, S extends StyleSchema>(blockContent: PartialInlineContent<I, S>, schema: Schema,
|
|
7
|
+
export declare function inlineContentToNodes<I extends InlineContentSchema, S extends StyleSchema>(blockContent: PartialInlineContent<I, S>, schema: Schema, blockType?: string, styleSchema?: S): Node[];
|
|
8
8
|
/**
|
|
9
9
|
* converts an array of inline content elements to prosemirror nodes
|
|
10
10
|
*/
|
|
11
|
-
export declare function tableContentToNodes<I extends InlineContentSchema, S extends StyleSchema>(tableContent: PartialTableContent<I, S>, schema: Schema, styleSchema
|
|
11
|
+
export declare function tableContentToNodes<I extends InlineContentSchema, S extends StyleSchema>(tableContent: PartialTableContent<I, S>, schema: Schema, styleSchema?: StyleSchema): Node[];
|
|
12
12
|
/**
|
|
13
13
|
* Converts a BlockNote block to a Prosemirror node.
|
|
14
14
|
*/
|
|
15
|
-
export declare function blockToNode(block: PartialBlock<any, any, any>, schema: Schema, styleSchema
|
|
15
|
+
export declare function blockToNode(block: PartialBlock<any, any, any>, schema: Schema, styleSchema?: StyleSchema): Node;
|
|
@@ -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>;
|