@blocknote/core 0.9.6 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocknote.js +3697 -2609
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +7 -7
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -0
- package/package.json +8 -4
- package/src/api/README.md +8 -0
- package/src/api/blockManipulation/blockManipulation.test.ts +72 -10
- package/src/api/blockManipulation/blockManipulation.ts +38 -18
- package/src/api/exporters/copyExtension.ts +68 -0
- package/src/api/exporters/html/__snapshots__/complex/misc/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/complex/misc/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/customParagraph/basic/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/customParagraph/basic/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/customParagraph/nested/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/customParagraph/nested/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/customParagraph/styled/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/customParagraph/styled/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/fontSize/basic/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/fontSize/basic/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/hardbreak/basic/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/hardbreak/basic/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/hardbreak/between-links/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/hardbreak/between-links/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/hardbreak/end/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/hardbreak/end/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/hardbreak/link/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/hardbreak/link/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/hardbreak/multiple/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/hardbreak/multiple/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/hardbreak/only/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/hardbreak/only/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/hardbreak/start/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/hardbreak/start/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/hardbreak/styles/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/hardbreak/styles/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/image/basic/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/image/basic/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/image/button/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/image/button/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/image/nested/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/image/nested/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/link/adjacent/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/link/adjacent/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/link/basic/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/link/basic/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/link/styled/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/link/styled/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/mention/basic/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/mention/basic/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/paragraph/basic/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/paragraph/basic/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/paragraph/empty/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/paragraph/empty/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/paragraph/nested/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/paragraph/nested/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/paragraph/styled/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/paragraph/styled/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/paste/parse-basic-block-types.json +140 -0
- package/src/api/exporters/html/__snapshots__/paste/parse-deep-nested-content.json +240 -0
- package/src/api/exporters/html/__snapshots__/paste/parse-div-with-inline-content.json +91 -0
- package/src/api/exporters/html/__snapshots__/paste/parse-divs.json +19 -0
- package/src/api/exporters/html/__snapshots__/paste/parse-fake-image-caption.json +31 -0
- package/src/api/exporters/html/__snapshots__/paste/parse-mixed-nested-lists.json +70 -0
- package/src/api/exporters/html/__snapshots__/paste/parse-nested-lists-with-paragraphs.json +70 -0
- package/src/api/exporters/html/__snapshots__/paste/parse-nested-lists.json +70 -0
- package/src/api/exporters/html/__snapshots__/simpleCustomParagraph/basic/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/simpleCustomParagraph/basic/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/simpleCustomParagraph/nested/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/simpleCustomParagraph/nested/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/simpleCustomParagraph/styled/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/simpleCustomParagraph/styled/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/simpleImage/basic/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/simpleImage/basic/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/simpleImage/button/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/simpleImage/button/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/simpleImage/nested/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/simpleImage/nested/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/small/basic/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/small/basic/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/tag/basic/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/tag/basic/internal.html +1 -0
- package/src/api/exporters/html/externalHTMLExporter.ts +98 -0
- package/src/api/exporters/html/htmlConversion.test.ts +100 -0
- package/src/api/exporters/html/internalHTMLSerializer.ts +80 -0
- package/src/api/exporters/html/util/sharedHTMLConversion.ts +128 -0
- package/src/api/{formatConversions → exporters/html/util}/simplifyBlocksRehypePlugin.ts +13 -0
- package/src/api/exporters/markdown/__snapshots__/complex/misc/markdown.md +5 -0
- package/src/api/exporters/markdown/__snapshots__/customParagraph/basic/markdown.md +1 -0
- package/src/api/exporters/markdown/__snapshots__/customParagraph/nested/markdown.md +5 -0
- package/src/api/exporters/markdown/__snapshots__/customParagraph/styled/markdown.md +1 -0
- package/src/api/exporters/markdown/__snapshots__/fontSize/basic/markdown.md +1 -0
- package/src/api/exporters/markdown/__snapshots__/hardbreak/basic/markdown.md +2 -0
- package/src/api/exporters/markdown/__snapshots__/hardbreak/between-links/markdown.md +2 -0
- package/src/api/exporters/markdown/__snapshots__/hardbreak/end/markdown.md +1 -0
- package/src/api/exporters/markdown/__snapshots__/hardbreak/link/markdown.md +2 -0
- package/src/api/exporters/markdown/__snapshots__/hardbreak/multiple/markdown.md +3 -0
- package/src/api/exporters/markdown/__snapshots__/hardbreak/start/markdown.md +1 -0
- package/src/api/exporters/markdown/__snapshots__/hardbreak/styles/markdown.md +2 -0
- package/src/api/exporters/markdown/__snapshots__/image/basic/markdown.md +3 -0
- package/src/api/exporters/markdown/__snapshots__/image/button/markdown.md +1 -0
- package/src/api/exporters/markdown/__snapshots__/image/nested/markdown.md +7 -0
- package/src/api/exporters/markdown/__snapshots__/link/adjacent/markdown.md +1 -0
- package/src/api/exporters/markdown/__snapshots__/link/basic/markdown.md +1 -0
- package/src/api/exporters/markdown/__snapshots__/link/styled/markdown.md +1 -0
- package/src/api/exporters/markdown/__snapshots__/mention/basic/markdown.md +1 -0
- package/src/api/exporters/markdown/__snapshots__/paragraph/basic/markdown.md +1 -0
- package/src/api/exporters/markdown/__snapshots__/paragraph/empty/markdown.md +0 -0
- package/src/api/exporters/markdown/__snapshots__/paragraph/nested/markdown.md +5 -0
- package/src/api/exporters/markdown/__snapshots__/paragraph/styled/markdown.md +1 -0
- package/src/api/exporters/markdown/__snapshots__/simpleCustomParagraph/basic/markdown.md +1 -0
- package/src/api/exporters/markdown/__snapshots__/simpleCustomParagraph/nested/markdown.md +5 -0
- package/src/api/exporters/markdown/__snapshots__/simpleCustomParagraph/styled/markdown.md +1 -0
- package/src/api/exporters/markdown/__snapshots__/simpleImage/basic/markdown.md +1 -0
- package/src/api/exporters/markdown/__snapshots__/simpleImage/button/markdown.md +1 -0
- package/src/api/exporters/markdown/__snapshots__/simpleImage/nested/markdown.md +3 -0
- package/src/api/exporters/markdown/__snapshots__/small/basic/markdown.md +1 -0
- package/src/api/exporters/markdown/__snapshots__/tag/basic/markdown.md +1 -0
- package/src/api/exporters/markdown/markdownExporter.test.ts +85 -0
- package/src/api/exporters/markdown/markdownExporter.ts +42 -0
- package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +486 -125
- package/src/api/nodeConversions/nodeConversions.test.ts +67 -498
- package/src/api/nodeConversions/nodeConversions.ts +311 -85
- package/src/api/parsers/html/__snapshots__/paste/list-test.json +105 -0
- package/src/api/parsers/html/__snapshots__/paste/parse-basic-block-types.json +140 -0
- package/src/api/parsers/html/__snapshots__/paste/parse-deep-nested-content.json +240 -0
- package/src/api/parsers/html/__snapshots__/paste/parse-div-with-inline-content.json +91 -0
- package/src/api/parsers/html/__snapshots__/paste/parse-divs.json +121 -0
- package/src/api/parsers/html/__snapshots__/paste/parse-fake-image-caption.json +31 -0
- package/src/api/parsers/html/__snapshots__/paste/parse-google-docs-html.json +476 -0
- package/src/api/parsers/html/__snapshots__/paste/parse-mixed-nested-lists.json +140 -0
- package/src/api/parsers/html/__snapshots__/paste/parse-nested-lists-with-paragraphs.json +140 -0
- package/src/api/parsers/html/__snapshots__/paste/parse-nested-lists.json +157 -0
- package/src/api/parsers/html/__snapshots__/paste/parse-notion-html.json +470 -0
- package/src/api/parsers/html/__snapshots__/paste/parse-two-divs.json +36 -0
- package/src/api/parsers/html/parseHTML.test.ts +440 -0
- package/src/api/parsers/html/parseHTML.ts +42 -0
- package/src/api/parsers/html/util/__snapshots__/nestedLists.test.ts.snap +129 -0
- package/src/api/parsers/html/util/nestedLists.test.ts +176 -0
- package/src/api/parsers/html/util/nestedLists.ts +113 -0
- package/src/api/parsers/markdown/__snapshots__/complex.json +353 -0
- package/src/api/parsers/markdown/__snapshots__/issue-226-1.json +71 -0
- package/src/api/parsers/markdown/__snapshots__/issue-226-2.json +144 -0
- package/src/api/parsers/markdown/__snapshots__/nested.json +72 -0
- package/src/api/parsers/markdown/__snapshots__/non-nested.json +71 -0
- package/src/api/parsers/markdown/__snapshots__/styled.json +58 -0
- package/src/api/parsers/markdown/parseMarkdown.test.ts +114 -0
- package/src/api/parsers/markdown/parseMarkdown.ts +84 -0
- package/src/api/parsers/pasteExtension.ts +59 -0
- package/src/api/testUtil/cases/customBlocks.ts +282 -0
- package/src/api/testUtil/cases/customInlineContent.ts +114 -0
- package/src/api/testUtil/cases/customStyles.ts +100 -0
- package/src/api/testUtil/cases/defaultSchema.ts +399 -0
- package/src/api/testUtil/index.ts +17 -0
- package/src/api/testUtil/partialBlockTestUtil.ts +127 -0
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +136 -0
- package/src/{extensions/Blocks/nodes/BlockContent → blocks}/ImageBlockContent/ImageBlockContent.ts +87 -31
- package/src/{extensions/Blocks/nodes/BlockContent → blocks}/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +34 -47
- package/src/{extensions/Blocks/nodes/BlockContent → blocks}/ListItemBlockContent/ListItemKeyboardShortcuts.ts +1 -1
- package/src/{extensions/Blocks/nodes/BlockContent → blocks}/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +1 -1
- package/src/{extensions/Blocks/nodes/BlockContent → blocks}/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +34 -56
- package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +43 -0
- package/src/blocks/README.md +3 -0
- package/src/blocks/TableBlockContent/TableBlockContent.ts +74 -0
- package/src/blocks/TableBlockContent/TableExtension.ts +63 -0
- package/src/blocks/defaultBlockHelpers.ts +95 -0
- package/src/blocks/defaultBlocks.ts +60 -0
- package/src/blocks/defaultProps.ts +24 -0
- package/src/{extensions/Blocks/nodes/Block.module.css → editor/Block.css} +69 -62
- package/src/{BlockNoteEditor.test.ts → editor/BlockNoteEditor.test.ts} +2 -2
- package/src/{BlockNoteEditor.ts → editor/BlockNoteEditor.ts} +364 -153
- package/src/{BlockNoteExtensions.ts → editor/BlockNoteExtensions.ts} +59 -40
- package/src/editor/README.md +3 -0
- package/src/editor/cursorPositionTypes.ts +16 -0
- package/src/{editor.module.css → editor/editor.css} +42 -15
- package/src/editor/selectionTypes.ts +14 -0
- package/src/editor/transformPasted.ts +58 -0
- package/src/extensions/BackgroundColor/BackgroundColorExtension.ts +1 -36
- package/src/extensions/BackgroundColor/BackgroundColorMark.ts +12 -27
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +16 -24
- package/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.ts +12 -10
- package/src/extensions/ImageToolbar/ImageToolbarPlugin.ts +35 -73
- package/src/extensions/Placeholder/PlaceholderExtension.ts +4 -4
- package/src/extensions/README.md +3 -0
- package/src/extensions/SideMenu/SideMenuPlugin.ts +66 -37
- package/src/extensions/SlashMenu/BaseSlashMenuItem.ts +7 -6
- package/src/extensions/SlashMenu/SlashMenuPlugin.ts +9 -7
- package/src/extensions/SlashMenu/defaultSlashMenuItems.ts +98 -35
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +617 -0
- package/src/extensions/TextAlignment/TextAlignmentExtension.ts +3 -51
- package/src/extensions/TextColor/TextColorExtension.ts +1 -29
- package/src/extensions/TextColor/TextColorMark.ts +7 -27
- package/src/extensions/UniqueID/UniqueID.ts +28 -2
- package/src/extensions-shared/README.md +3 -0
- package/src/{shared/plugins → extensions-shared}/suggestion/SuggestionPlugin.ts +19 -13
- package/src/index.ts +21 -15
- package/src/{extensions/Blocks/nodes → pm-nodes}/BlockContainer.ts +161 -96
- package/src/pm-nodes/BlockGroup.ts +54 -0
- package/src/pm-nodes/Doc.ts +7 -0
- package/src/pm-nodes/README.md +42 -0
- package/src/pm-nodes/index.ts +3 -0
- package/src/schema/README.md +3 -0
- package/src/schema/blocks/createSpec.ts +220 -0
- package/src/schema/blocks/internal.ts +253 -0
- package/src/schema/blocks/types.ts +252 -0
- package/src/schema/index.ts +10 -0
- package/src/schema/inlineContent/createSpec.ts +119 -0
- package/src/schema/inlineContent/internal.ts +105 -0
- package/src/schema/inlineContent/types.ts +144 -0
- package/src/schema/propTypes.ts +32 -0
- package/src/schema/styles/createSpec.ts +85 -0
- package/src/schema/styles/internal.ts +96 -0
- package/src/schema/styles/types.ts +42 -0
- package/src/util/README.md +3 -0
- package/src/{shared/utils.ts → util/browser.ts} +4 -8
- package/src/util/string.ts +3 -0
- package/src/util/typescript.ts +5 -0
- package/types/src/BlockNoteEditor.d.ts +49 -36
- package/types/src/BlockNoteExtensions.d.ts +8 -3
- package/types/src/api/blockManipulation/blockManipulation.d.ts +5 -4
- package/types/src/api/exporters/copyExtension.d.ts +6 -0
- package/types/src/api/exporters/html/externalHTMLExporter.d.ts +8 -0
- package/types/src/api/exporters/html/internalHTMLSerializer.d.ts +8 -0
- package/types/src/api/exporters/html/util/sharedHTMLConversion.d.ts +7 -0
- package/types/src/api/exporters/markdown/markdownExporter.d.ts +5 -0
- package/types/src/api/exporters/markdown/markdownExporter.test.d.ts +1 -0
- package/types/src/api/getBlockInfoFromPos.d.ts +27 -0
- package/types/src/api/nodeConversions/nodeConversions.d.ts +14 -6
- package/types/src/api/nodeConversions/testUtil.d.ts +7 -2
- package/types/src/api/nodeUtil.d.ts +8 -0
- package/types/src/api/parsers/html/parseHTML.d.ts +3 -0
- package/types/src/api/parsers/html/parseHTML.test.d.ts +1 -0
- package/types/src/api/parsers/html/util/nestedLists.d.ts +1 -0
- package/types/src/api/parsers/html/util/nestedLists.test.d.ts +1 -0
- package/types/src/api/parsers/markdown/parseMarkdown.d.ts +3 -0
- package/types/src/api/parsers/markdown/parseMarkdown.test.d.ts +1 -0
- package/types/src/api/parsers/pasteExtension.d.ts +6 -0
- package/types/src/api/testCases/cases/customBlocks.d.ts +345 -0
- package/types/src/api/testCases/cases/customInlineContent.d.ts +29 -0
- package/types/src/api/testCases/cases/customStyles.d.ts +64 -0
- package/types/src/api/testCases/cases/defaultSchema.d.ts +3 -0
- package/types/src/api/testCases/index.d.ts +12 -0
- package/types/src/api/testUtil/cases/customBlocks.d.ts +345 -0
- package/types/src/api/testUtil/cases/customInlineContent.d.ts +29 -0
- package/types/src/api/testUtil/cases/customStyles.d.ts +64 -0
- package/types/src/api/testUtil/cases/defaultSchema.d.ts +3 -0
- package/types/src/api/testUtil/index.d.ts +12 -0
- package/types/src/api/testUtil/partialBlockTestUtil.d.ts +7 -0
- package/types/src/blocks/HeadingBlockContent/HeadingBlockContent.d.ts +58 -0
- package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +93 -0
- package/types/src/blocks/ImageBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.d.ts +1 -0
- package/types/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.d.ts +46 -0
- package/types/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.d.ts +2 -0
- package/types/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.d.ts +2 -0
- package/types/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +46 -0
- package/types/src/blocks/ParagraphBlockContent/ParagraphBlockContent.d.ts +52 -0
- package/types/src/blocks/TableBlockContent/TableBlockContent.d.ts +53 -0
- package/types/src/blocks/TableBlockContent/TableExtension.d.ts +2 -0
- package/types/src/blocks/defaultBlockHelpers.d.ts +10 -0
- package/types/src/blocks/defaultBlocks.d.ts +577 -0
- package/types/src/blocks/defaultProps.d.ts +15 -0
- package/types/src/editor/BlockNoteEditor.d.ts +299 -0
- package/types/src/editor/BlockNoteEditor.test.d.ts +1 -0
- package/types/src/editor/BlockNoteExtensions.d.ts +24 -0
- package/types/src/editor/cursorPositionTypes.d.ts +6 -0
- package/types/src/editor/selectionTypes.d.ts +4 -0
- package/types/src/editor/transformPasted.d.ts +12 -0
- package/types/src/extensions/BackgroundColor/BackgroundColorExtension.d.ts +0 -7
- package/types/src/extensions/BackgroundColor/BackgroundColorMark.d.ts +7 -9
- package/types/src/extensions/Blocks/api/blocks/createSpec.d.ts +35 -0
- package/types/src/extensions/Blocks/api/blocks/internal.d.ts +45 -0
- package/types/src/extensions/Blocks/api/blocks/types.d.ts +114 -0
- package/types/src/extensions/Blocks/api/cursorPositionTypes.d.ts +7 -5
- package/types/src/extensions/Blocks/api/defaultBlocks.d.ts +573 -113
- package/types/src/extensions/Blocks/api/defaultProps.d.ts +2 -1
- package/types/src/extensions/Blocks/api/inlineContent/createSpec.d.ts +21 -0
- package/types/src/extensions/Blocks/api/inlineContent/internal.d.ts +25 -0
- package/types/src/extensions/Blocks/api/inlineContent/types.d.ts +62 -0
- package/types/src/extensions/Blocks/api/selectionTypes.d.ts +5 -3
- package/types/src/extensions/Blocks/api/styles/createSpec.d.ts +13 -0
- package/types/src/extensions/Blocks/api/styles/internal.d.ts +22 -0
- package/types/src/extensions/Blocks/api/styles/types.d.ts +21 -0
- package/types/src/extensions/Blocks/nodes/BlockContainer.d.ts +8 -4
- package/types/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContent.d.ts +38 -23
- package/types/src/extensions/Blocks/nodes/BlockContent/ImageBlockContent/ImageBlockContent.d.ts +75 -17
- package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.d.ts +30 -19
- package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +30 -19
- package/types/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContent.d.ts +36 -28
- package/types/src/extensions/Blocks/nodes/BlockContent/TableBlockContent/TableBlockContent.d.ts +53 -0
- package/types/src/extensions/Blocks/nodes/BlockContent/TableBlockContent/TableExtension.d.ts +2 -0
- package/types/src/extensions/Blocks/nodes/BlockContent/defaultBlockHelpers.d.ts +12 -0
- package/types/src/extensions/Blocks/nodes/BlockGroup.d.ts +1 -1
- package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +8 -6
- package/types/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.d.ts +6 -6
- package/types/src/extensions/ImageToolbar/ImageToolbarPlugin.d.ts +11 -16
- package/types/src/extensions/NonEditableBlocks/NonEditableBlockPlugin.d.ts +2 -0
- package/types/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.d.ts +14 -0
- package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +18 -11
- package/types/src/extensions/SlashMenu/BaseSlashMenuItem.d.ts +5 -6
- package/types/src/extensions/SlashMenu/SlashMenuPlugin.d.ts +6 -6
- package/types/src/extensions/SlashMenu/defaultSlashMenuItems.d.ts +2 -1
- package/types/src/extensions/TableHandles/TableHandlesPlugin.d.ts +74 -0
- package/types/src/extensions/TextAlignment/TextAlignmentExtension.d.ts +0 -7
- package/types/src/extensions/TextColor/TextColorExtension.d.ts +0 -7
- package/types/src/extensions/TextColor/TextColorMark.d.ts +7 -9
- package/types/src/extensions/UniqueID/UniqueID.d.ts +1 -1
- package/types/src/extensions-shared/BaseUiElementTypes.d.ts +7 -0
- package/types/src/extensions-shared/suggestion/SuggestionItem.d.ts +3 -0
- package/types/src/extensions-shared/suggestion/SuggestionPlugin.d.ts +36 -0
- package/types/src/index.d.ts +20 -15
- package/types/src/pm-nodes/BlockContainer.d.ts +28 -0
- package/types/src/pm-nodes/BlockGroup.d.ts +10 -0
- package/types/src/pm-nodes/Doc.d.ts +2 -0
- package/types/src/pm-nodes/index.d.ts +3 -0
- package/types/src/schema/blocks/createSpec.d.ts +35 -0
- package/types/src/schema/blocks/internal.d.ts +45 -0
- package/types/src/schema/blocks/types.d.ts +107 -0
- package/types/src/schema/index.d.ts +10 -0
- package/types/src/schema/inlineContent/createSpec.d.ts +21 -0
- package/types/src/schema/inlineContent/internal.d.ts +28 -0
- package/types/src/schema/inlineContent/types.d.ts +62 -0
- package/types/src/schema/propTypes.d.ts +8 -0
- package/types/src/schema/styles/createSpec.d.ts +13 -0
- package/types/src/schema/styles/internal.d.ts +22 -0
- package/types/src/schema/styles/types.d.ts +21 -0
- package/types/src/shared/plugins/suggestion/SuggestionPlugin.d.ts +4 -2
- package/types/src/util/EventEmitter.d.ts +11 -0
- package/types/src/util/browser.d.ts +3 -0
- package/types/src/util/string.d.ts +1 -0
- package/types/src/util/typescript.d.ts +3 -0
- package/src/api/formatConversions/__snapshots__/formatConversions.test.ts.snap +0 -346
- package/src/api/formatConversions/formatConversions.test.ts +0 -753
- package/src/api/formatConversions/formatConversions.ts +0 -133
- package/src/api/nodeConversions/testUtil.ts +0 -65
- package/src/extensions/Blocks/api/block.ts +0 -307
- package/src/extensions/Blocks/api/blockTypes.ts +0 -249
- package/src/extensions/Blocks/api/cursorPositionTypes.ts +0 -7
- package/src/extensions/Blocks/api/defaultBlocks.ts +0 -16
- package/src/extensions/Blocks/api/defaultProps.ts +0 -16
- package/src/extensions/Blocks/api/inlineContentTypes.ts +0 -36
- package/src/extensions/Blocks/api/selectionTypes.ts +0 -5
- package/src/extensions/Blocks/api/serialization.ts +0 -29
- package/src/extensions/Blocks/helpers/findBlock.ts +0 -5
- package/src/extensions/Blocks/index.ts +0 -8
- package/src/extensions/Blocks/nodes/BlockAttributes.ts +0 -10
- package/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContent.ts +0 -142
- package/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContent.ts +0 -62
- package/src/extensions/Blocks/nodes/BlockGroup.ts +0 -53
- package/types/src/api/formatConversions/formatConversions.d.ts +0 -6
- package/types/src/extensions/Blocks/api/block.d.ts +0 -20
- package/types/src/extensions/Blocks/api/blockTypes.d.ts +0 -103
- package/types/src/extensions/Blocks/api/inlineContentTypes.d.ts +0 -30
- package/types/src/extensions/Blocks/api/serialization.d.ts +0 -2
- /package/src/{shared/EditorElement.ts → api/exporters/markdown/__snapshots__/hardbreak/only/markdown.md} +0 -0
- /package/src/api/{formatConversions → exporters/markdown}/removeUnderlinesRehypePlugin.ts +0 -0
- /package/src/{extensions/Blocks/helpers → api}/getBlockInfoFromPos.ts +0 -0
- /package/src/api/{util/nodeUtil.ts → nodeUtil.ts} +0 -0
- /package/src/{extensions/Blocks/nodes/BlockContent → blocks}/ImageBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.ts +0 -0
- /package/src/extensions/{Blocks → NonEditableBlocks}/NonEditableBlockPlugin.ts +0 -0
- /package/src/extensions/{Blocks → PreviousBlockType}/PreviousBlockTypePlugin.ts +0 -0
- /package/src/{shared → extensions-shared}/BaseUiElementTypes.ts +0 -0
- /package/src/{shared/plugins → extensions-shared}/suggestion/SuggestionItem.ts +0 -0
- /package/src/{shared → util}/EventEmitter.ts +0 -0
- /package/types/src/api/{formatConversions/formatConversions.test.d.ts → exporters/html/htmlConversion.test.d.ts} +0 -0
- /package/types/src/api/{formatConversions → exporters/html/util}/simplifyBlocksRehypePlugin.d.ts +0 -0
- /package/types/src/api/{formatConversions → exporters/markdown}/removeUnderlinesRehypePlugin.d.ts +0 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { EditorOptions } from "@tiptap/core";
|
|
2
|
+
import { Node } from "prosemirror-model";
|
|
3
|
+
import { Editor as TiptapEditor } from "@tiptap/core/dist/packages/core/src/Editor";
|
|
4
|
+
import * as Y from "yjs";
|
|
5
|
+
import { DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema, defaultBlockSpecs, defaultInlineContentSpecs, defaultStyleSpecs } from "../blocks/defaultBlocks";
|
|
6
|
+
import { FormattingToolbarProsemirrorPlugin } from "../extensions/FormattingToolbar/FormattingToolbarPlugin";
|
|
7
|
+
import { HyperlinkToolbarProsemirrorPlugin } from "../extensions/HyperlinkToolbar/HyperlinkToolbarPlugin";
|
|
8
|
+
import { ImageToolbarProsemirrorPlugin } from "../extensions/ImageToolbar/ImageToolbarPlugin";
|
|
9
|
+
import { SideMenuProsemirrorPlugin } from "../extensions/SideMenu/SideMenuPlugin";
|
|
10
|
+
import { BaseSlashMenuItem } from "../extensions/SlashMenu/BaseSlashMenuItem";
|
|
11
|
+
import { SlashMenuProsemirrorPlugin } from "../extensions/SlashMenu/SlashMenuPlugin";
|
|
12
|
+
import { TableHandlesProsemirrorPlugin } from "../extensions/TableHandles/TableHandlesPlugin";
|
|
13
|
+
import { Block, BlockIdentifier, BlockNoteDOMAttributes, BlockSchema, BlockSchemaFromSpecs, BlockSchemaWithBlock, BlockSpecs, InlineContentSchema, InlineContentSchemaFromSpecs, InlineContentSpecs, PartialBlock, StyleSchema, StyleSchemaFromSpecs, StyleSpecs, Styles } from "../schema";
|
|
14
|
+
import { TextCursorPosition } from "./cursorPositionTypes";
|
|
15
|
+
import { Selection } from "./selectionTypes";
|
|
16
|
+
import "prosemirror-tables/style/tables.css";
|
|
17
|
+
import "./Block.css";
|
|
18
|
+
import "./editor.css";
|
|
19
|
+
export type BlockNoteEditorOptions<BSpecs extends BlockSpecs, ISpecs extends InlineContentSpecs, SSpecs extends StyleSpecs> = {
|
|
20
|
+
enableBlockNoteExtensions: boolean;
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* (couldn't fix any type, see https://github.com/TypeCellOS/BlockNote/pull/191#discussion_r1210708771)
|
|
24
|
+
*
|
|
25
|
+
* @default defaultSlashMenuItems from `./extensions/SlashMenu`
|
|
26
|
+
*/
|
|
27
|
+
slashMenuItems: BaseSlashMenuItem<any, any, any>[];
|
|
28
|
+
/**
|
|
29
|
+
* The HTML element that should be used as the parent element for the editor.
|
|
30
|
+
*
|
|
31
|
+
* @default: undefined, the editor is not attached to the DOM
|
|
32
|
+
*/
|
|
33
|
+
parentElement: HTMLElement;
|
|
34
|
+
/**
|
|
35
|
+
* An object containing attributes that should be added to HTML elements of the editor.
|
|
36
|
+
*
|
|
37
|
+
* @example { editor: { class: "my-editor-class" } }
|
|
38
|
+
*/
|
|
39
|
+
domAttributes: Partial<BlockNoteDOMAttributes>;
|
|
40
|
+
/**
|
|
41
|
+
* A callback function that runs when the editor is ready to be used.
|
|
42
|
+
*/
|
|
43
|
+
onEditorReady: (editor: BlockNoteEditor<BlockSchemaFromSpecs<BSpecs>, InlineContentSchemaFromSpecs<ISpecs>, StyleSchemaFromSpecs<SSpecs>>) => void;
|
|
44
|
+
/**
|
|
45
|
+
* A callback function that runs whenever the editor's contents change.
|
|
46
|
+
*/
|
|
47
|
+
onEditorContentChange: (editor: BlockNoteEditor<BlockSchemaFromSpecs<BSpecs>, InlineContentSchemaFromSpecs<ISpecs>, StyleSchemaFromSpecs<SSpecs>>) => void;
|
|
48
|
+
/**
|
|
49
|
+
* A callback function that runs whenever the text cursor position changes.
|
|
50
|
+
*/
|
|
51
|
+
onTextCursorPositionChange: (editor: BlockNoteEditor<BlockSchemaFromSpecs<BSpecs>, InlineContentSchemaFromSpecs<ISpecs>, StyleSchemaFromSpecs<SSpecs>>) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Locks the editor from being editable by the user if set to `false`.
|
|
54
|
+
*/
|
|
55
|
+
editable: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The content that should be in the editor when it's created, represented as an array of partial block objects.
|
|
58
|
+
*/
|
|
59
|
+
initialContent: PartialBlock<BlockSchemaFromSpecs<BSpecs>, InlineContentSchemaFromSpecs<ISpecs>, StyleSchemaFromSpecs<SSpecs>>[];
|
|
60
|
+
/**
|
|
61
|
+
* Use default BlockNote font and reset the styles of <p> <li> <h1> elements etc., that are used in BlockNote.
|
|
62
|
+
*
|
|
63
|
+
* @default true
|
|
64
|
+
*/
|
|
65
|
+
defaultStyles: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* A list of block types that should be available in the editor.
|
|
68
|
+
*/
|
|
69
|
+
blockSpecs: BSpecs;
|
|
70
|
+
styleSpecs: SSpecs;
|
|
71
|
+
inlineContentSpecs: ISpecs;
|
|
72
|
+
/**
|
|
73
|
+
* A custom function to handle file uploads.
|
|
74
|
+
* @param file The file that should be uploaded.
|
|
75
|
+
* @returns The URL of the uploaded file.
|
|
76
|
+
*/
|
|
77
|
+
uploadFile: (file: File) => Promise<string>;
|
|
78
|
+
/**
|
|
79
|
+
* When enabled, allows for collaboration between multiple users.
|
|
80
|
+
*/
|
|
81
|
+
collaboration: {
|
|
82
|
+
/**
|
|
83
|
+
* The Yjs XML fragment that's used for collaboration.
|
|
84
|
+
*/
|
|
85
|
+
fragment: Y.XmlFragment;
|
|
86
|
+
/**
|
|
87
|
+
* The user info for the current user that's shown to other collaborators.
|
|
88
|
+
*/
|
|
89
|
+
user: {
|
|
90
|
+
name: string;
|
|
91
|
+
color: string;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* A Yjs provider (used for awareness / cursor information)
|
|
95
|
+
*/
|
|
96
|
+
provider: any;
|
|
97
|
+
/**
|
|
98
|
+
* Optional function to customize how cursors of users are rendered
|
|
99
|
+
*/
|
|
100
|
+
renderCursor?: (user: any) => HTMLElement;
|
|
101
|
+
};
|
|
102
|
+
_tiptapOptions: Partial<EditorOptions>;
|
|
103
|
+
};
|
|
104
|
+
export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema> {
|
|
105
|
+
private readonly options;
|
|
106
|
+
readonly _tiptapEditor: TiptapEditor & {
|
|
107
|
+
contentComponent: any;
|
|
108
|
+
};
|
|
109
|
+
blockCache: WeakMap<Node, Block<any, any, any>>;
|
|
110
|
+
readonly blockSchema: BSchema;
|
|
111
|
+
readonly inlineContentSchema: ISchema;
|
|
112
|
+
readonly styleSchema: SSchema;
|
|
113
|
+
readonly blockImplementations: BlockSpecs;
|
|
114
|
+
readonly inlineContentImplementations: InlineContentSpecs;
|
|
115
|
+
readonly styleImplementations: StyleSpecs;
|
|
116
|
+
ready: boolean;
|
|
117
|
+
readonly sideMenu: SideMenuProsemirrorPlugin<BSchema, ISchema, SSchema>;
|
|
118
|
+
readonly formattingToolbar: FormattingToolbarProsemirrorPlugin;
|
|
119
|
+
readonly slashMenu: SlashMenuProsemirrorPlugin<BSchema, ISchema, SSchema, any>;
|
|
120
|
+
readonly hyperlinkToolbar: HyperlinkToolbarProsemirrorPlugin<BSchema, ISchema, SSchema>;
|
|
121
|
+
readonly imageToolbar: ImageToolbarProsemirrorPlugin<BSchema, ISchema, SSchema>;
|
|
122
|
+
readonly tableHandles: TableHandlesProsemirrorPlugin<BSchema extends BlockSchemaWithBlock<"table", DefaultBlockSchema["table"]> ? BSchema : any, ISchema, SSchema> | undefined;
|
|
123
|
+
readonly uploadFile: ((file: File) => Promise<string>) | undefined;
|
|
124
|
+
static create<BSpecs extends BlockSpecs = typeof defaultBlockSpecs, ISpecs extends InlineContentSpecs = typeof defaultInlineContentSpecs, SSpecs extends StyleSpecs = typeof defaultStyleSpecs>(options?: Partial<BlockNoteEditorOptions<BSpecs, ISpecs, SSpecs>>): BlockNoteEditor<BlockSchemaFromSpecs<BSpecs>, InlineContentSchemaFromSpecs<ISpecs>, StyleSchemaFromSpecs<SSpecs>>;
|
|
125
|
+
private constructor();
|
|
126
|
+
get prosemirrorView(): import("prosemirror-view").EditorView;
|
|
127
|
+
get domElement(): HTMLDivElement;
|
|
128
|
+
isFocused(): boolean;
|
|
129
|
+
focus(): void;
|
|
130
|
+
/**
|
|
131
|
+
* Gets a snapshot of all top-level (non-nested) blocks in the editor.
|
|
132
|
+
* @returns A snapshot of all top-level (non-nested) blocks in the editor.
|
|
133
|
+
*/
|
|
134
|
+
get topLevelBlocks(): Block<BSchema, ISchema, SSchema>[];
|
|
135
|
+
/**
|
|
136
|
+
* Gets a snapshot of an existing block from the editor.
|
|
137
|
+
* @param blockIdentifier The identifier of an existing block that should be retrieved.
|
|
138
|
+
* @returns The block that matches the identifier, or `undefined` if no matching block was found.
|
|
139
|
+
*/
|
|
140
|
+
getBlock(blockIdentifier: BlockIdentifier): Block<BSchema, ISchema, SSchema> | undefined;
|
|
141
|
+
/**
|
|
142
|
+
* Traverses all blocks in the editor depth-first, and executes a callback for each.
|
|
143
|
+
* @param callback The callback to execute for each block. Returning `false` stops the traversal.
|
|
144
|
+
* @param reverse Whether the blocks should be traversed in reverse order.
|
|
145
|
+
*/
|
|
146
|
+
forEachBlock(callback: (block: Block<BSchema, ISchema, SSchema>) => boolean, reverse?: boolean): void;
|
|
147
|
+
/**
|
|
148
|
+
* Executes a callback whenever the editor's contents change.
|
|
149
|
+
* @param callback The callback to execute.
|
|
150
|
+
*/
|
|
151
|
+
onEditorContentChange(callback: () => void): void;
|
|
152
|
+
/**
|
|
153
|
+
* Executes a callback whenever the editor's selection changes.
|
|
154
|
+
* @param callback The callback to execute.
|
|
155
|
+
*/
|
|
156
|
+
onEditorSelectionChange(callback: () => void): void;
|
|
157
|
+
/**
|
|
158
|
+
* Gets a snapshot of the current text cursor position.
|
|
159
|
+
* @returns A snapshot of the current text cursor position.
|
|
160
|
+
*/
|
|
161
|
+
getTextCursorPosition(): TextCursorPosition<BSchema, ISchema, SSchema>;
|
|
162
|
+
/**
|
|
163
|
+
* Sets the text cursor position to the start or end of an existing block. Throws an error if the target block could
|
|
164
|
+
* not be found.
|
|
165
|
+
* @param targetBlock The identifier of an existing block that the text cursor should be moved to.
|
|
166
|
+
* @param placement Whether the text cursor should be placed at the start or end of the block.
|
|
167
|
+
*/
|
|
168
|
+
setTextCursorPosition(targetBlock: BlockIdentifier, placement?: "start" | "end"): void;
|
|
169
|
+
/**
|
|
170
|
+
* Gets a snapshot of the current selection.
|
|
171
|
+
*/
|
|
172
|
+
getSelection(): Selection<BSchema, ISchema, SSchema> | undefined;
|
|
173
|
+
/**
|
|
174
|
+
* Checks if the editor is currently editable, or if it's locked.
|
|
175
|
+
* @returns True if the editor is editable, false otherwise.
|
|
176
|
+
*/
|
|
177
|
+
get isEditable(): boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Makes the editor editable or locks it, depending on the argument passed.
|
|
180
|
+
* @param editable True to make the editor editable, or false to lock it.
|
|
181
|
+
*/
|
|
182
|
+
set isEditable(editable: boolean);
|
|
183
|
+
/**
|
|
184
|
+
* Inserts new blocks into the editor. If a block's `id` is undefined, BlockNote generates one automatically. Throws an
|
|
185
|
+
* error if the reference block could not be found.
|
|
186
|
+
* @param blocksToInsert An array of partial blocks that should be inserted.
|
|
187
|
+
* @param referenceBlock An identifier for an existing block, at which the new blocks should be inserted.
|
|
188
|
+
* @param placement Whether the blocks should be inserted just before, just after, or nested inside the
|
|
189
|
+
* `referenceBlock`. Inserts the blocks at the start of the existing block's children if "nested" is used.
|
|
190
|
+
*/
|
|
191
|
+
insertBlocks(blocksToInsert: PartialBlock<BSchema, ISchema, SSchema>[], referenceBlock: BlockIdentifier, placement?: "before" | "after" | "nested"): void;
|
|
192
|
+
/**
|
|
193
|
+
* Updates an existing block in the editor. Since updatedBlock is a PartialBlock object, some fields might not be
|
|
194
|
+
* defined. These undefined fields are kept as-is from the existing block. Throws an error if the block to update could
|
|
195
|
+
* not be found.
|
|
196
|
+
* @param blockToUpdate The block that should be updated.
|
|
197
|
+
* @param update A partial block which defines how the existing block should be changed.
|
|
198
|
+
*/
|
|
199
|
+
updateBlock(blockToUpdate: BlockIdentifier, update: PartialBlock<BSchema, ISchema, SSchema>): void;
|
|
200
|
+
/**
|
|
201
|
+
* Removes existing blocks from the editor. Throws an error if any of the blocks could not be found.
|
|
202
|
+
* @param blocksToRemove An array of identifiers for existing blocks that should be removed.
|
|
203
|
+
*/
|
|
204
|
+
removeBlocks(blocksToRemove: BlockIdentifier[]): void;
|
|
205
|
+
/**
|
|
206
|
+
* Replaces existing blocks in the editor with new blocks. If the blocks that should be removed are not adjacent or
|
|
207
|
+
* are at different nesting levels, `blocksToInsert` will be inserted at the position of the first block in
|
|
208
|
+
* `blocksToRemove`. Throws an error if any of the blocks to remove could not be found.
|
|
209
|
+
* @param blocksToRemove An array of blocks that should be replaced.
|
|
210
|
+
* @param blocksToInsert An array of partial blocks to replace the old ones with.
|
|
211
|
+
*/
|
|
212
|
+
replaceBlocks(blocksToRemove: BlockIdentifier[], blocksToInsert: PartialBlock<BSchema, ISchema, SSchema>[]): void;
|
|
213
|
+
/**
|
|
214
|
+
* Gets the active text styles at the text cursor position or at the end of the current selection if it's active.
|
|
215
|
+
*/
|
|
216
|
+
getActiveStyles(): Styles<SSchema>;
|
|
217
|
+
/**
|
|
218
|
+
* Adds styles to the currently selected content.
|
|
219
|
+
* @param styles The styles to add.
|
|
220
|
+
*/
|
|
221
|
+
addStyles(styles: Styles<SSchema>): void;
|
|
222
|
+
/**
|
|
223
|
+
* Removes styles from the currently selected content.
|
|
224
|
+
* @param styles The styles to remove.
|
|
225
|
+
*/
|
|
226
|
+
removeStyles(styles: Styles<SSchema>): void;
|
|
227
|
+
/**
|
|
228
|
+
* Toggles styles on the currently selected content.
|
|
229
|
+
* @param styles The styles to toggle.
|
|
230
|
+
*/
|
|
231
|
+
toggleStyles(styles: Styles<SSchema>): void;
|
|
232
|
+
/**
|
|
233
|
+
* Gets the currently selected text.
|
|
234
|
+
*/
|
|
235
|
+
getSelectedText(): string;
|
|
236
|
+
/**
|
|
237
|
+
* Gets the URL of the last link in the current selection, or `undefined` if there are no links in the selection.
|
|
238
|
+
*/
|
|
239
|
+
getSelectedLinkUrl(): string | undefined;
|
|
240
|
+
/**
|
|
241
|
+
* Creates a new link to replace the selected content.
|
|
242
|
+
* @param url The link URL.
|
|
243
|
+
* @param text The text to display the link with.
|
|
244
|
+
*/
|
|
245
|
+
createLink(url: string, text?: string): void;
|
|
246
|
+
/**
|
|
247
|
+
* Checks if the block containing the text cursor can be nested.
|
|
248
|
+
*/
|
|
249
|
+
canNestBlock(): boolean;
|
|
250
|
+
/**
|
|
251
|
+
* Nests the block containing the text cursor into the block above it.
|
|
252
|
+
*/
|
|
253
|
+
nestBlock(): void;
|
|
254
|
+
/**
|
|
255
|
+
* Checks if the block containing the text cursor is nested.
|
|
256
|
+
*/
|
|
257
|
+
canUnnestBlock(): boolean;
|
|
258
|
+
/**
|
|
259
|
+
* Lifts the block containing the text cursor out of its parent.
|
|
260
|
+
*/
|
|
261
|
+
unnestBlock(): void;
|
|
262
|
+
/**
|
|
263
|
+
* Serializes blocks into an HTML string. To better conform to HTML standards, children of blocks which aren't list
|
|
264
|
+
* items are un-nested in the output HTML.
|
|
265
|
+
* @param blocks An array of blocks that should be serialized into HTML.
|
|
266
|
+
* @returns The blocks, serialized as an HTML string.
|
|
267
|
+
*/
|
|
268
|
+
blocksToHTMLLossy(blocks?: Block<BSchema, ISchema, SSchema>[]): Promise<string>;
|
|
269
|
+
/**
|
|
270
|
+
* Parses blocks from an HTML string. Tries to create `Block` objects out of any HTML block-level elements, and
|
|
271
|
+
* `InlineNode` objects from any HTML inline elements, though not all element types are recognized. If BlockNote
|
|
272
|
+
* doesn't recognize an HTML element's tag, it will parse it as a paragraph or plain text.
|
|
273
|
+
* @param html The HTML string to parse blocks from.
|
|
274
|
+
* @returns The blocks parsed from the HTML string.
|
|
275
|
+
*/
|
|
276
|
+
tryParseHTMLToBlocks(html: string): Promise<Block<BSchema, ISchema, SSchema>[]>;
|
|
277
|
+
/**
|
|
278
|
+
* Serializes blocks into a Markdown string. The output is simplified as Markdown does not support all features of
|
|
279
|
+
* BlockNote - children of blocks which aren't list items are un-nested and certain styles are removed.
|
|
280
|
+
* @param blocks An array of blocks that should be serialized into Markdown.
|
|
281
|
+
* @returns The blocks, serialized as a Markdown string.
|
|
282
|
+
*/
|
|
283
|
+
blocksToMarkdownLossy(blocks?: Block<BSchema, ISchema, SSchema>[]): Promise<string>;
|
|
284
|
+
/**
|
|
285
|
+
* Creates a list of blocks from a Markdown string. Tries to create `Block` and `InlineNode` objects based on
|
|
286
|
+
* Markdown syntax, though not all symbols are recognized. If BlockNote doesn't recognize a symbol, it will parse it
|
|
287
|
+
* as text.
|
|
288
|
+
* @param markdown The Markdown string to parse blocks from.
|
|
289
|
+
* @returns The blocks parsed from the Markdown string.
|
|
290
|
+
*/
|
|
291
|
+
tryParseMarkdownToBlocks(markdown: string): Promise<Block<BSchema, ISchema, SSchema>[]>;
|
|
292
|
+
/**
|
|
293
|
+
* Updates the user info for the current user that's shown to other collaborators.
|
|
294
|
+
*/
|
|
295
|
+
updateCollaborationUserInfo(user: {
|
|
296
|
+
name: string;
|
|
297
|
+
color: string;
|
|
298
|
+
}): void;
|
|
299
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Extensions } from "@tiptap/core";
|
|
2
|
+
import type { BlockNoteEditor } from "./BlockNoteEditor";
|
|
3
|
+
import * as Y from "yjs";
|
|
4
|
+
import { BlockNoteDOMAttributes, BlockSpecs, InlineContentSchema, InlineContentSpecs, StyleSchema, StyleSpecs } from "../schema";
|
|
5
|
+
/**
|
|
6
|
+
* Get all the Tiptap extensions BlockNote is configured with by default
|
|
7
|
+
*/
|
|
8
|
+
export declare const getBlockNoteExtensions: <BSchema extends Record<string, import("../schema").BlockConfig>, I extends InlineContentSchema, S extends StyleSchema>(opts: {
|
|
9
|
+
editor: BlockNoteEditor<BSchema, I, S>;
|
|
10
|
+
domAttributes: Partial<BlockNoteDOMAttributes>;
|
|
11
|
+
blockSchema: BSchema;
|
|
12
|
+
blockSpecs: BlockSpecs;
|
|
13
|
+
inlineContentSpecs: InlineContentSpecs;
|
|
14
|
+
styleSpecs: StyleSpecs;
|
|
15
|
+
collaboration?: {
|
|
16
|
+
fragment: Y.XmlFragment;
|
|
17
|
+
user: {
|
|
18
|
+
name: string;
|
|
19
|
+
color: string;
|
|
20
|
+
};
|
|
21
|
+
provider: any;
|
|
22
|
+
renderCursor?: ((user: any) => HTMLElement) | undefined;
|
|
23
|
+
} | undefined;
|
|
24
|
+
}) => Extensions;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Block, BlockSchema, InlineContentSchema, StyleSchema } from "../schema";
|
|
2
|
+
export type TextCursorPosition<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> = {
|
|
3
|
+
block: Block<BSchema, I, S>;
|
|
4
|
+
prevBlock: Block<BSchema, I, S> | undefined;
|
|
5
|
+
nextBlock: Block<BSchema, I, S> | undefined;
|
|
6
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Slice } from "@tiptap/pm/model";
|
|
2
|
+
import { EditorView } from "@tiptap/pm/view";
|
|
3
|
+
/**
|
|
4
|
+
* fix for https://github.com/ProseMirror/prosemirror/issues/1430#issuecomment-1822570821
|
|
5
|
+
*
|
|
6
|
+
* Without this fix, pasting two paragraphs would cause the second one to be indented in the other
|
|
7
|
+
* this fix wraps every element in the slice in it's own blockContainer, to prevent Prosemirror from nesting the
|
|
8
|
+
* elements on paste.
|
|
9
|
+
*
|
|
10
|
+
* The exception is when we encounter blockGroups with listitems, because those actually should be nested
|
|
11
|
+
*/
|
|
12
|
+
export declare function transformPasted(slice: Slice, view: EditorView): Slice;
|
|
@@ -1,9 +1,2 @@
|
|
|
1
1
|
import { Extension } from "@tiptap/core";
|
|
2
|
-
declare module "@tiptap/core" {
|
|
3
|
-
interface Commands<ReturnType> {
|
|
4
|
-
blockBackgroundColor: {
|
|
5
|
-
setBlockBackgroundColor: (posInBlock: number, color: string) => ReturnType;
|
|
6
|
-
};
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
2
|
export declare const BackgroundColorExtension: Extension<any, any>;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
export declare const BackgroundColorMark: Mark<any, any>;
|
|
1
|
+
export declare const BackgroundColor: {
|
|
2
|
+
config: {
|
|
3
|
+
type: string;
|
|
4
|
+
propSchema: "string";
|
|
5
|
+
};
|
|
6
|
+
implementation: import("../../schema").StyleImplementation;
|
|
7
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ParseRule } from "@tiptap/pm/model";
|
|
2
|
+
import { BlockNoteEditor } from "../../../../BlockNoteEditor";
|
|
3
|
+
import { InlineContentSchema } from "../inlineContent/types";
|
|
4
|
+
import { StyleSchema } from "../styles/types";
|
|
5
|
+
import { BlockConfig, BlockFromConfig, BlockSchemaWithBlock, PartialBlockFromConfig } from "./types";
|
|
6
|
+
export type CustomBlockConfig = BlockConfig & {
|
|
7
|
+
content: "inline" | "none";
|
|
8
|
+
};
|
|
9
|
+
export type CustomBlockImplementation<T extends CustomBlockConfig, I extends InlineContentSchema, S extends StyleSchema> = {
|
|
10
|
+
render: (
|
|
11
|
+
/**
|
|
12
|
+
* The custom block to render
|
|
13
|
+
*/
|
|
14
|
+
block: BlockFromConfig<T, I, S>,
|
|
15
|
+
/**
|
|
16
|
+
* The BlockNote editor instance
|
|
17
|
+
* This is typed generically. If you want an editor with your custom schema, you need to
|
|
18
|
+
* cast it manually, e.g.: `const e = editor as BlockNoteEditor<typeof mySchema>;`
|
|
19
|
+
*/
|
|
20
|
+
editor: BlockNoteEditor<BlockSchemaWithBlock<T["type"], T>, I, S>) => {
|
|
21
|
+
dom: HTMLElement;
|
|
22
|
+
contentDOM?: HTMLElement;
|
|
23
|
+
destroy?: () => void;
|
|
24
|
+
};
|
|
25
|
+
toExternalHTML?: (block: BlockFromConfig<T, I, S>, editor: BlockNoteEditor<BlockSchemaWithBlock<T["type"], T>, I, S>) => {
|
|
26
|
+
dom: HTMLElement;
|
|
27
|
+
contentDOM?: HTMLElement;
|
|
28
|
+
};
|
|
29
|
+
parse?: (el: HTMLElement) => PartialBlockFromConfig<T, I, S>["props"] | undefined;
|
|
30
|
+
};
|
|
31
|
+
export declare function getParseRules(config: BlockConfig, customParseFunction: CustomBlockImplementation<any, any, any>["parse"]): ParseRule[];
|
|
32
|
+
export declare function createBlockSpec<T extends CustomBlockConfig, I extends InlineContentSchema, S extends StyleSchema>(blockConfig: T, blockImplementation: CustomBlockImplementation<T, I, S>): {
|
|
33
|
+
config: T;
|
|
34
|
+
implementation: import("./types").TiptapBlockImplementation<T, any, InlineContentSchema, StyleSchema>;
|
|
35
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Attributes, Editor, Extension, Node, NodeConfig } from "@tiptap/core";
|
|
2
|
+
import { BlockNoteEditor } from "../../../../BlockNoteEditor";
|
|
3
|
+
import { InlineContentSchema } from "../inlineContent/types";
|
|
4
|
+
import { StyleSchema } from "../styles/types";
|
|
5
|
+
import { BlockConfig, BlockSchemaFromSpecs, BlockSchemaWithBlock, BlockSpecs, Props, PropSchema, SpecificBlock, TiptapBlockImplementation } from "./types";
|
|
6
|
+
export declare function camelToDataKebab(str: string): string;
|
|
7
|
+
export declare function propsToAttributes(propSchema: PropSchema): Attributes;
|
|
8
|
+
export declare function getBlockFromPos<BType extends string, Config extends BlockConfig, BSchema extends BlockSchemaWithBlock<BType, Config>, I extends InlineContentSchema, S extends StyleSchema>(getPos: (() => number) | boolean, editor: BlockNoteEditor<BSchema, I, S>, tipTapEditor: Editor, type: BType): SpecificBlock<BSchema, BType, I, S>;
|
|
9
|
+
export declare function wrapInBlockStructure<BType extends string, PSchema extends PropSchema>(element: {
|
|
10
|
+
dom: HTMLElement;
|
|
11
|
+
contentDOM?: HTMLElement;
|
|
12
|
+
destroy?: () => void;
|
|
13
|
+
}, blockType: BType, blockProps: Props<PSchema>, propSchema: PSchema, domAttributes?: Record<string, string>): {
|
|
14
|
+
dom: HTMLElement;
|
|
15
|
+
contentDOM?: HTMLElement;
|
|
16
|
+
destroy?: () => void;
|
|
17
|
+
};
|
|
18
|
+
type StronglyTypedTipTapNode<Name extends string, Content extends "inline*" | "tableRow+" | ""> = Node & {
|
|
19
|
+
name: Name;
|
|
20
|
+
config: {
|
|
21
|
+
content: Content;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export declare function createStronglyTypedTiptapNode<Name extends string, Content extends "inline*" | "tableRow+" | "">(config: NodeConfig & {
|
|
25
|
+
name: Name;
|
|
26
|
+
content: Content;
|
|
27
|
+
}): StronglyTypedTipTapNode<Name, Content>;
|
|
28
|
+
export declare function createInternalBlockSpec<T extends BlockConfig>(config: T, implementation: TiptapBlockImplementation<T, any, InlineContentSchema, StyleSchema>): {
|
|
29
|
+
config: T;
|
|
30
|
+
implementation: TiptapBlockImplementation<T, any, InlineContentSchema, StyleSchema>;
|
|
31
|
+
};
|
|
32
|
+
export declare function createBlockSpecFromStronglyTypedTiptapNode<T extends Node, P extends PropSchema>(node: T, propSchema: P, requiredExtensions?: Array<Extension | Node>): {
|
|
33
|
+
config: {
|
|
34
|
+
type: T["name"];
|
|
35
|
+
content: T["config"]["content"] extends "inline*" ? "inline" : T["config"]["content"] extends "tableRow+" ? "table" : "none";
|
|
36
|
+
propSchema: P;
|
|
37
|
+
};
|
|
38
|
+
implementation: TiptapBlockImplementation<{
|
|
39
|
+
type: T["name"];
|
|
40
|
+
content: T["config"]["content"] extends "inline*" ? "inline" : T["config"]["content"] extends "tableRow+" ? "table" : "none";
|
|
41
|
+
propSchema: P;
|
|
42
|
+
}, any, InlineContentSchema, StyleSchema>;
|
|
43
|
+
};
|
|
44
|
+
export declare function getBlockSchemaFromSpecs<T extends BlockSpecs>(specs: T): BlockSchemaFromSpecs<T>;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/** Define the main block types **/
|
|
2
|
+
import { Extension, Node } from "@tiptap/core";
|
|
3
|
+
import { BlockNoteEditor } from "../../../../BlockNoteEditor";
|
|
4
|
+
import { InlineContent, InlineContentSchema, PartialInlineContent } from "../inlineContent/types";
|
|
5
|
+
import { StyleSchema } from "../styles/types";
|
|
6
|
+
export type BlockNoteDOMElement = "editor" | "blockContainer" | "blockGroup" | "blockContent" | "inlineContent";
|
|
7
|
+
export type BlockNoteDOMAttributes = Partial<{
|
|
8
|
+
[DOMElement in BlockNoteDOMElement]: Record<string, string>;
|
|
9
|
+
}>;
|
|
10
|
+
export type PropSpec<PType extends boolean | number | string> = {
|
|
11
|
+
values?: readonly PType[];
|
|
12
|
+
default: PType;
|
|
13
|
+
};
|
|
14
|
+
export type PropSchema = Record<string, PropSpec<boolean | number | string>>;
|
|
15
|
+
export type Props<PSchema extends PropSchema> = {
|
|
16
|
+
[PName in keyof PSchema]: PSchema[PName]["default"] extends boolean ? PSchema[PName]["values"] extends readonly boolean[] ? PSchema[PName]["values"][number] : boolean : PSchema[PName]["default"] extends number ? PSchema[PName]["values"] extends readonly number[] ? PSchema[PName]["values"][number] : number : PSchema[PName]["default"] extends string ? PSchema[PName]["values"] extends readonly string[] ? PSchema[PName]["values"][number] : string : never;
|
|
17
|
+
};
|
|
18
|
+
export type BlockConfig = {
|
|
19
|
+
type: string;
|
|
20
|
+
readonly propSchema: PropSchema;
|
|
21
|
+
content: "inline" | "none" | "table";
|
|
22
|
+
};
|
|
23
|
+
export type TiptapBlockImplementation<T extends BlockConfig, B extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> = {
|
|
24
|
+
requiredExtensions?: Array<Extension | Node>;
|
|
25
|
+
node: Node;
|
|
26
|
+
toInternalHTML: (block: BlockFromConfigNoChildren<T, I, S> & {
|
|
27
|
+
children: Block<B, I, S>[];
|
|
28
|
+
}, editor: BlockNoteEditor<B, I, S>) => {
|
|
29
|
+
dom: HTMLElement;
|
|
30
|
+
contentDOM?: HTMLElement;
|
|
31
|
+
};
|
|
32
|
+
toExternalHTML: (block: BlockFromConfigNoChildren<T, I, S> & {
|
|
33
|
+
children: Block<B, I, S>[];
|
|
34
|
+
}, editor: BlockNoteEditor<B, I, S>) => {
|
|
35
|
+
dom: HTMLElement;
|
|
36
|
+
contentDOM?: HTMLElement;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export type BlockSpec<T extends BlockConfig, B extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> = {
|
|
40
|
+
config: T;
|
|
41
|
+
implementation: TiptapBlockImplementation<T, B, I, S>;
|
|
42
|
+
};
|
|
43
|
+
type NamesMatch<Blocks extends Record<string, BlockConfig>> = Blocks extends {
|
|
44
|
+
[Type in keyof Blocks]: Type extends string ? Blocks[Type] extends {
|
|
45
|
+
type: Type;
|
|
46
|
+
} ? Blocks[Type] : never : never;
|
|
47
|
+
} ? Blocks : never;
|
|
48
|
+
export type BlockSchema = NamesMatch<Record<string, BlockConfig>>;
|
|
49
|
+
export type BlockSpecs = Record<string, BlockSpec<any, any, InlineContentSchema, StyleSchema>>;
|
|
50
|
+
export type BlockImplementations = Record<string, TiptapBlockImplementation<any, any, any, any>>;
|
|
51
|
+
export type BlockSchemaFromSpecs<T extends BlockSpecs> = {
|
|
52
|
+
[K in keyof T]: T[K]["config"];
|
|
53
|
+
};
|
|
54
|
+
export type BlockSchemaWithBlock<BType extends string, C extends BlockConfig> = {
|
|
55
|
+
[k in BType]: C;
|
|
56
|
+
};
|
|
57
|
+
export type TableContent<I extends InlineContentSchema, S extends StyleSchema = StyleSchema> = {
|
|
58
|
+
type: "tableContent";
|
|
59
|
+
rows: {
|
|
60
|
+
cells: InlineContent<I, S>[][];
|
|
61
|
+
}[];
|
|
62
|
+
};
|
|
63
|
+
export type BlockFromConfigNoChildren<B extends BlockConfig, I extends InlineContentSchema, S extends StyleSchema> = {
|
|
64
|
+
id: string;
|
|
65
|
+
type: B["type"];
|
|
66
|
+
props: Props<B["propSchema"]>;
|
|
67
|
+
content: B["content"] extends "inline" ? InlineContent<I, S>[] : B["content"] extends "table" ? TableContent<I, S> : B["content"] extends "none" ? undefined : never;
|
|
68
|
+
};
|
|
69
|
+
export type BlockFromConfig<B extends BlockConfig, I extends InlineContentSchema, S extends StyleSchema> = BlockFromConfigNoChildren<B, I, S> & {
|
|
70
|
+
children: Block<BlockSchema, I, S>[];
|
|
71
|
+
};
|
|
72
|
+
type BlocksWithoutChildren<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> = {
|
|
73
|
+
[BType in keyof BSchema]: BlockFromConfigNoChildren<BSchema[BType], I, S>;
|
|
74
|
+
};
|
|
75
|
+
export type Block<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> = BlocksWithoutChildren<BSchema, I, S>[keyof BSchema] & {
|
|
76
|
+
children: Block<BSchema, I, S>[];
|
|
77
|
+
};
|
|
78
|
+
export type SpecificBlock<BSchema extends BlockSchema, BType extends keyof BSchema, I extends InlineContentSchema, S extends StyleSchema> = BlocksWithoutChildren<BSchema, I, S>[BType] & {
|
|
79
|
+
children: Block<BSchema, I, S>[];
|
|
80
|
+
};
|
|
81
|
+
/** CODE FOR PARTIAL BLOCKS, analogous to above
|
|
82
|
+
*
|
|
83
|
+
* Partial blocks are convenience-wrappers to make it easier to
|
|
84
|
+
*create/update blocks in the editor.
|
|
85
|
+
*
|
|
86
|
+
*/
|
|
87
|
+
export type PartialTableContent<I extends InlineContentSchema, S extends StyleSchema = StyleSchema> = {
|
|
88
|
+
type: "tableContent";
|
|
89
|
+
rows: {
|
|
90
|
+
cells: PartialInlineContent<I, S>[];
|
|
91
|
+
}[];
|
|
92
|
+
};
|
|
93
|
+
type PartialBlockFromConfigNoChildren<B extends BlockConfig, I extends InlineContentSchema, S extends StyleSchema> = {
|
|
94
|
+
id?: string;
|
|
95
|
+
type?: B["type"];
|
|
96
|
+
props?: Partial<Props<B["propSchema"]>>;
|
|
97
|
+
content?: B["content"] extends "inline" ? PartialInlineContent<I, S> : B["content"] extends "table" ? PartialTableContent<I, S> : undefined;
|
|
98
|
+
};
|
|
99
|
+
type PartialBlocksWithoutChildren<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> = {
|
|
100
|
+
[BType in keyof BSchema]: PartialBlockFromConfigNoChildren<BSchema[BType], I, S>;
|
|
101
|
+
};
|
|
102
|
+
export type PartialBlock<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> = PartialBlocksWithoutChildren<BSchema, I, S>[keyof PartialBlocksWithoutChildren<BSchema, I, S>] & Partial<{
|
|
103
|
+
children: PartialBlock<BSchema, I, S>[];
|
|
104
|
+
}>;
|
|
105
|
+
export type SpecificPartialBlock<BSchema extends BlockSchema, I extends InlineContentSchema, BType extends keyof BSchema, S extends StyleSchema> = PartialBlocksWithoutChildren<BSchema, I, S>[BType] & {
|
|
106
|
+
children?: Block<BSchema, I, S>[];
|
|
107
|
+
};
|
|
108
|
+
export type PartialBlockFromConfig<B extends BlockConfig, I extends InlineContentSchema, S extends StyleSchema> = PartialBlockFromConfigNoChildren<B, I, S> & {
|
|
109
|
+
children?: Block<BlockSchema, I, S>[];
|
|
110
|
+
};
|
|
111
|
+
export type BlockIdentifier = {
|
|
112
|
+
id: string;
|
|
113
|
+
} | string;
|
|
114
|
+
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { Block, BlockSchema } from "./
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { Block, BlockSchema } from "./blocks/types";
|
|
2
|
+
import { InlineContentSchema } from "./inlineContent/types";
|
|
3
|
+
import { StyleSchema } from "./styles/types";
|
|
4
|
+
export type TextCursorPosition<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> = {
|
|
5
|
+
block: Block<BSchema, I, S>;
|
|
6
|
+
prevBlock: Block<BSchema, I, S> | undefined;
|
|
7
|
+
nextBlock: Block<BSchema, I, S> | undefined;
|
|
6
8
|
};
|