@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
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
/** Define the main block types **/
|
|
2
|
-
import { Node, NodeConfig } from "@tiptap/core";
|
|
3
|
-
import { BlockNoteEditor } from "../../../BlockNoteEditor";
|
|
4
|
-
import { InlineContent, PartialInlineContent } from "./inlineContentTypes";
|
|
5
|
-
import { DefaultBlockSchema } from "./defaultBlocks";
|
|
6
|
-
|
|
7
|
-
export type BlockNoteDOMElement =
|
|
8
|
-
| "editor"
|
|
9
|
-
| "blockContainer"
|
|
10
|
-
| "blockGroup"
|
|
11
|
-
| "blockContent"
|
|
12
|
-
| "inlineContent";
|
|
13
|
-
|
|
14
|
-
export type BlockNoteDOMAttributes = Partial<{
|
|
15
|
-
[DOMElement in BlockNoteDOMElement]: Record<string, string>;
|
|
16
|
-
}>;
|
|
17
|
-
|
|
18
|
-
// A configuration for a TipTap node, but with stricter type constraints on the
|
|
19
|
-
// "name" and "content" properties. The "name" property is now always a string
|
|
20
|
-
// literal type, and the "content" property can only be "inline*" or "". Used as
|
|
21
|
-
// the parameter in `createTipTapNode`. The "group" is also removed as
|
|
22
|
-
// `createTipTapNode` always sets it to "blockContent"
|
|
23
|
-
export type TipTapNodeConfig<
|
|
24
|
-
Name extends string,
|
|
25
|
-
ContainsInlineContent extends boolean,
|
|
26
|
-
Options extends {
|
|
27
|
-
domAttributes?: BlockNoteDOMAttributes;
|
|
28
|
-
} = {
|
|
29
|
-
domAttributes?: BlockNoteDOMAttributes;
|
|
30
|
-
},
|
|
31
|
-
Storage = any
|
|
32
|
-
> = {
|
|
33
|
-
[K in keyof NodeConfig<Options, Storage>]: K extends "name"
|
|
34
|
-
? Name
|
|
35
|
-
: K extends "content"
|
|
36
|
-
? ContainsInlineContent extends true
|
|
37
|
-
? "inline*"
|
|
38
|
-
: ""
|
|
39
|
-
: K extends "group"
|
|
40
|
-
? never
|
|
41
|
-
: NodeConfig<Options, Storage>[K];
|
|
42
|
-
} & {
|
|
43
|
-
name: Name;
|
|
44
|
-
content: ContainsInlineContent extends true ? "inline*" : "";
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// A TipTap node with stricter type constraints on the "name", "group", and
|
|
48
|
-
// "content properties. The "name" property is now a string literal type, and
|
|
49
|
-
// the "blockGroup" property is now "blockContent", and the "content" property
|
|
50
|
-
// can only be "inline*" or "". Returned by `createTipTapNode`.
|
|
51
|
-
export type TipTapNode<
|
|
52
|
-
Name extends string,
|
|
53
|
-
ContainsInlineContent extends boolean,
|
|
54
|
-
Options extends {
|
|
55
|
-
domAttributes?: BlockNoteDOMAttributes;
|
|
56
|
-
} = {
|
|
57
|
-
domAttributes?: BlockNoteDOMAttributes;
|
|
58
|
-
},
|
|
59
|
-
Storage = any
|
|
60
|
-
> = {
|
|
61
|
-
[Key in keyof Node<Options, Storage>]: Key extends "name"
|
|
62
|
-
? Name
|
|
63
|
-
: Key extends "config"
|
|
64
|
-
? {
|
|
65
|
-
[ConfigKey in keyof Node<
|
|
66
|
-
Options,
|
|
67
|
-
Storage
|
|
68
|
-
>["config"]]: ConfigKey extends "group"
|
|
69
|
-
? "blockContent"
|
|
70
|
-
: ConfigKey extends "content"
|
|
71
|
-
? ContainsInlineContent extends true
|
|
72
|
-
? "inline*"
|
|
73
|
-
: ""
|
|
74
|
-
: NodeConfig<Options, Storage>["config"][ConfigKey];
|
|
75
|
-
} & {
|
|
76
|
-
group: "blockContent";
|
|
77
|
-
content: ContainsInlineContent extends true ? "inline*" : "";
|
|
78
|
-
}
|
|
79
|
-
: Node<Options, Storage>["config"][Key];
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
// Defines a single prop spec, which includes the default value the prop should
|
|
83
|
-
// take and possible values it can take.
|
|
84
|
-
export type PropSpec<PType extends boolean | number | string> = {
|
|
85
|
-
values?: readonly PType[];
|
|
86
|
-
default: PType;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
// Defines multiple block prop specs. The key of each prop is the name of the
|
|
90
|
-
// prop, while the value is a corresponding prop spec. This should be included
|
|
91
|
-
// in a block config or schema. From a prop schema, we can derive both the props'
|
|
92
|
-
// internal implementation (as TipTap node attributes) and the type information
|
|
93
|
-
// for the external API.
|
|
94
|
-
export type PropSchema = Record<string, PropSpec<boolean | number | string>>;
|
|
95
|
-
|
|
96
|
-
// Defines Props objects for use in Block objects in the external API. Converts
|
|
97
|
-
// each prop spec into a union type of its possible values, or a string if no
|
|
98
|
-
// values are specified.
|
|
99
|
-
export type Props<PSchema extends PropSchema> = {
|
|
100
|
-
[PName in keyof PSchema]: PSchema[PName]["default"] extends boolean
|
|
101
|
-
? PSchema[PName]["values"] extends readonly boolean[]
|
|
102
|
-
? PSchema[PName]["values"][number]
|
|
103
|
-
: boolean
|
|
104
|
-
: PSchema[PName]["default"] extends number
|
|
105
|
-
? PSchema[PName]["values"] extends readonly number[]
|
|
106
|
-
? PSchema[PName]["values"][number]
|
|
107
|
-
: number
|
|
108
|
-
: PSchema[PName]["default"] extends string
|
|
109
|
-
? PSchema[PName]["values"] extends readonly string[]
|
|
110
|
-
? PSchema[PName]["values"][number]
|
|
111
|
-
: string
|
|
112
|
-
: never;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
// Defines the config for a single block. Meant to be used as an argument to
|
|
116
|
-
// `createBlockSpec`, which will create a new block spec from it. This is the
|
|
117
|
-
// main way we expect people to create custom blocks as consumers don't need to
|
|
118
|
-
// know anything about the TipTap API since the associated nodes are created
|
|
119
|
-
// automatically.
|
|
120
|
-
export type BlockConfig<
|
|
121
|
-
Type extends string,
|
|
122
|
-
PSchema extends PropSchema,
|
|
123
|
-
ContainsInlineContent extends boolean,
|
|
124
|
-
BSchema extends BlockSchema
|
|
125
|
-
> = {
|
|
126
|
-
// Attributes to define block in the API as well as a TipTap node.
|
|
127
|
-
type: Type;
|
|
128
|
-
readonly propSchema: PSchema;
|
|
129
|
-
|
|
130
|
-
// Additional attributes to help define block as a TipTap node.
|
|
131
|
-
containsInlineContent: ContainsInlineContent;
|
|
132
|
-
render: (
|
|
133
|
-
/**
|
|
134
|
-
* The custom block to render
|
|
135
|
-
*/
|
|
136
|
-
block: SpecificBlock<
|
|
137
|
-
BSchema & {
|
|
138
|
-
[k in Type]: BlockSpec<Type, PSchema, ContainsInlineContent>;
|
|
139
|
-
},
|
|
140
|
-
Type
|
|
141
|
-
>,
|
|
142
|
-
/**
|
|
143
|
-
* The BlockNote editor instance
|
|
144
|
-
* This is typed generically. If you want an editor with your custom schema, you need to
|
|
145
|
-
* cast it manually, e.g.: `const e = editor as BlockNoteEditor<typeof mySchema>;`
|
|
146
|
-
*/
|
|
147
|
-
editor: BlockNoteEditor<
|
|
148
|
-
BSchema & { [k in Type]: BlockSpec<Type, PSchema, ContainsInlineContent> }
|
|
149
|
-
>
|
|
150
|
-
// (note) if we want to fix the manual cast, we need to prevent circular references and separate block definition and render implementations
|
|
151
|
-
// or allow manually passing <BSchema>, but that's not possible without passing the other generics because Typescript doesn't support partial inferred generics
|
|
152
|
-
) => ContainsInlineContent extends true
|
|
153
|
-
? {
|
|
154
|
-
dom: HTMLElement;
|
|
155
|
-
contentDOM: HTMLElement;
|
|
156
|
-
destroy?: () => void;
|
|
157
|
-
}
|
|
158
|
-
: {
|
|
159
|
-
dom: HTMLElement;
|
|
160
|
-
destroy?: () => void;
|
|
161
|
-
};
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
// Defines a single block spec, which includes the props that the block has and
|
|
165
|
-
// the TipTap node used to implement it. Usually created using `createBlockSpec`
|
|
166
|
-
// though it can also be defined from scratch by providing your own TipTap node,
|
|
167
|
-
// allowing for more advanced custom blocks.
|
|
168
|
-
export type BlockSpec<
|
|
169
|
-
Type extends string,
|
|
170
|
-
PSchema extends PropSchema,
|
|
171
|
-
ContainsInlineContent extends boolean
|
|
172
|
-
> = {
|
|
173
|
-
node: TipTapNode<Type, ContainsInlineContent, any>;
|
|
174
|
-
readonly propSchema: PSchema;
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
// Utility type. For a given object block schema, ensures that the key of each
|
|
178
|
-
// block spec matches the name of the TipTap node in it.
|
|
179
|
-
type NamesMatch<
|
|
180
|
-
Blocks extends Record<string, BlockSpec<string, PropSchema, boolean>>
|
|
181
|
-
> = Blocks extends {
|
|
182
|
-
[Type in keyof Blocks]: Type extends string
|
|
183
|
-
? Blocks[Type] extends BlockSpec<Type, PropSchema, boolean>
|
|
184
|
-
? Blocks[Type]
|
|
185
|
-
: never
|
|
186
|
-
: never;
|
|
187
|
-
}
|
|
188
|
-
? Blocks
|
|
189
|
-
: never;
|
|
190
|
-
|
|
191
|
-
// Defines multiple block specs. Also ensures that the key of each block schema
|
|
192
|
-
// is the same as name of the TipTap node in it. This should be passed in the
|
|
193
|
-
// `blocks` option of the BlockNoteEditor. From a block schema, we can derive
|
|
194
|
-
// both the blocks' internal implementation (as TipTap nodes) and the type
|
|
195
|
-
// information for the external API.
|
|
196
|
-
export type BlockSchema = NamesMatch<
|
|
197
|
-
Record<string, BlockSpec<string, PropSchema, boolean>>
|
|
198
|
-
>;
|
|
199
|
-
|
|
200
|
-
// Converts each block spec into a Block object without children. We later merge
|
|
201
|
-
// them into a union type and add a children property to create the Block and
|
|
202
|
-
// PartialBlock objects we use in the external API.
|
|
203
|
-
type BlocksWithoutChildren<BSchema extends BlockSchema> = {
|
|
204
|
-
[BType in keyof BSchema]: {
|
|
205
|
-
id: string;
|
|
206
|
-
type: BType;
|
|
207
|
-
props: Props<BSchema[BType]["propSchema"]>;
|
|
208
|
-
content: BSchema[BType]["node"]["config"]["content"] extends "inline*"
|
|
209
|
-
? InlineContent[]
|
|
210
|
-
: undefined;
|
|
211
|
-
};
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
// Converts each block spec into a Block object without children, merges them
|
|
215
|
-
// into a union type, and adds a children property
|
|
216
|
-
export type Block<BSchema extends BlockSchema = DefaultBlockSchema> =
|
|
217
|
-
BlocksWithoutChildren<BSchema>[keyof BlocksWithoutChildren<BSchema>] & {
|
|
218
|
-
children: Block<BSchema>[];
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
export type SpecificBlock<
|
|
222
|
-
BSchema extends BlockSchema,
|
|
223
|
-
BlockType extends keyof BSchema
|
|
224
|
-
> = BlocksWithoutChildren<BSchema>[BlockType] & {
|
|
225
|
-
children: Block<BSchema>[];
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
// Same as BlockWithoutChildren, but as a partial type with some changes to make
|
|
229
|
-
// it easier to create/update blocks in the editor.
|
|
230
|
-
type PartialBlocksWithoutChildren<BSchema extends BlockSchema> = {
|
|
231
|
-
[BType in keyof BSchema]: Partial<{
|
|
232
|
-
id: string;
|
|
233
|
-
type: BType;
|
|
234
|
-
props: Partial<Props<BSchema[BType]["propSchema"]>>;
|
|
235
|
-
content: BSchema[BType]["node"]["config"]["content"] extends "inline*"
|
|
236
|
-
? PartialInlineContent[] | string
|
|
237
|
-
: undefined;
|
|
238
|
-
}>;
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
// Same as Block, but as a partial type with some changes to make it easier to
|
|
242
|
-
// create/update blocks in the editor.
|
|
243
|
-
export type PartialBlock<BSchema extends BlockSchema = DefaultBlockSchema> =
|
|
244
|
-
PartialBlocksWithoutChildren<BSchema>[keyof PartialBlocksWithoutChildren<BSchema>] &
|
|
245
|
-
Partial<{
|
|
246
|
-
children: PartialBlock<BSchema>[];
|
|
247
|
-
}>;
|
|
248
|
-
|
|
249
|
-
export type BlockIdentifier = { id: string } | string;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Heading } from "../nodes/BlockContent/HeadingBlockContent/HeadingBlockContent";
|
|
2
|
-
import { BulletListItem } from "../nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent";
|
|
3
|
-
import { NumberedListItem } from "../nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent";
|
|
4
|
-
import { Paragraph } from "../nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContent";
|
|
5
|
-
import { Image } from "../nodes/BlockContent/ImageBlockContent/ImageBlockContent";
|
|
6
|
-
import { BlockSchema } from "./blockTypes";
|
|
7
|
-
|
|
8
|
-
export const defaultBlockSchema = {
|
|
9
|
-
paragraph: Paragraph,
|
|
10
|
-
heading: Heading,
|
|
11
|
-
bulletListItem: BulletListItem,
|
|
12
|
-
numberedListItem: NumberedListItem,
|
|
13
|
-
image: Image,
|
|
14
|
-
} as const satisfies BlockSchema;
|
|
15
|
-
|
|
16
|
-
export type DefaultBlockSchema = typeof defaultBlockSchema;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Props, PropSchema } from "./blockTypes";
|
|
2
|
-
|
|
3
|
-
export const defaultProps = {
|
|
4
|
-
backgroundColor: {
|
|
5
|
-
default: "default" as const,
|
|
6
|
-
},
|
|
7
|
-
textColor: {
|
|
8
|
-
default: "default" as const,
|
|
9
|
-
},
|
|
10
|
-
textAlignment: {
|
|
11
|
-
default: "left" as const,
|
|
12
|
-
values: ["left", "center", "right", "justify"] as const,
|
|
13
|
-
},
|
|
14
|
-
} satisfies PropSchema;
|
|
15
|
-
|
|
16
|
-
export type DefaultProps = Props<typeof defaultProps>;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export type Styles = {
|
|
2
|
-
bold?: true;
|
|
3
|
-
italic?: true;
|
|
4
|
-
underline?: true;
|
|
5
|
-
strike?: true;
|
|
6
|
-
code?: true;
|
|
7
|
-
textColor?: string;
|
|
8
|
-
backgroundColor?: string;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export type ToggledStyle = {
|
|
12
|
-
[K in keyof Styles]-?: Required<Styles>[K] extends true ? K : never;
|
|
13
|
-
}[keyof Styles];
|
|
14
|
-
|
|
15
|
-
export type ColorStyle = {
|
|
16
|
-
[K in keyof Styles]-?: Required<Styles>[K] extends string ? K : never;
|
|
17
|
-
}[keyof Styles];
|
|
18
|
-
|
|
19
|
-
export type StyledText = {
|
|
20
|
-
type: "text";
|
|
21
|
-
text: string;
|
|
22
|
-
styles: Styles;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export type Link = {
|
|
26
|
-
type: "link";
|
|
27
|
-
href: string;
|
|
28
|
-
content: StyledText[];
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export type PartialLink = Omit<Link, "content"> & {
|
|
32
|
-
content: string | Link["content"];
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export type InlineContent = StyledText | Link;
|
|
36
|
-
export type PartialInlineContent = StyledText | PartialLink;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Extension } from "@tiptap/core";
|
|
2
|
-
import { Plugin } from "prosemirror-state";
|
|
3
|
-
import { DOMSerializer, Schema } from "prosemirror-model";
|
|
4
|
-
|
|
5
|
-
const customBlockSerializer = (schema: Schema) => {
|
|
6
|
-
const defaultSerializer = DOMSerializer.fromSchema(schema);
|
|
7
|
-
|
|
8
|
-
return new DOMSerializer(
|
|
9
|
-
{
|
|
10
|
-
...defaultSerializer.nodes,
|
|
11
|
-
// TODO: If a serializer is defined in the config for a custom block, it
|
|
12
|
-
// should be added here. We still need to figure out how the serializer
|
|
13
|
-
// should be defined in the custom blocks API though, and implement that,
|
|
14
|
-
// before we can do this.
|
|
15
|
-
},
|
|
16
|
-
defaultSerializer.marks
|
|
17
|
-
);
|
|
18
|
-
};
|
|
19
|
-
export const CustomBlockSerializerExtension = Extension.create({
|
|
20
|
-
addProseMirrorPlugins() {
|
|
21
|
-
return [
|
|
22
|
-
new Plugin({
|
|
23
|
-
props: {
|
|
24
|
-
clipboardSerializer: customBlockSerializer(this.editor.schema),
|
|
25
|
-
},
|
|
26
|
-
}),
|
|
27
|
-
];
|
|
28
|
-
},
|
|
29
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// Object containing all possible block attributes.
|
|
2
|
-
const BlockAttributes: Record<string, string> = {
|
|
3
|
-
blockColor: "data-block-color",
|
|
4
|
-
blockStyle: "data-block-style",
|
|
5
|
-
id: "data-id",
|
|
6
|
-
depth: "data-depth",
|
|
7
|
-
depthChange: "data-depth-change",
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export default BlockAttributes;
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { InputRule, mergeAttributes } from "@tiptap/core";
|
|
2
|
-
import { defaultProps } from "../../../api/defaultProps";
|
|
3
|
-
import { createTipTapBlock } from "../../../api/block";
|
|
4
|
-
import { BlockSpec, PropSchema } from "../../../api/blockTypes";
|
|
5
|
-
import { mergeCSSClasses } from "../../../../../shared/utils";
|
|
6
|
-
import styles from "../../Block.module.css";
|
|
7
|
-
|
|
8
|
-
export const headingPropSchema = {
|
|
9
|
-
...defaultProps,
|
|
10
|
-
level: { default: 1, values: [1, 2, 3] as const },
|
|
11
|
-
} satisfies PropSchema;
|
|
12
|
-
|
|
13
|
-
const HeadingBlockContent = createTipTapBlock<"heading", true>({
|
|
14
|
-
name: "heading",
|
|
15
|
-
content: "inline*",
|
|
16
|
-
|
|
17
|
-
addAttributes() {
|
|
18
|
-
return {
|
|
19
|
-
level: {
|
|
20
|
-
default: 1,
|
|
21
|
-
// instead of "level" attributes, use "data-level"
|
|
22
|
-
parseHTML: (element) => element.getAttribute("data-level")!,
|
|
23
|
-
renderHTML: (attributes) => {
|
|
24
|
-
return {
|
|
25
|
-
"data-level": (attributes.level as number).toString(),
|
|
26
|
-
};
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
addInputRules() {
|
|
33
|
-
return [
|
|
34
|
-
...[1, 2, 3].map((level) => {
|
|
35
|
-
// Creates a heading of appropriate level when starting with "#", "##", or "###".
|
|
36
|
-
return new InputRule({
|
|
37
|
-
find: new RegExp(`^(#{${level}})\\s$`),
|
|
38
|
-
handler: ({ state, chain, range }) => {
|
|
39
|
-
chain()
|
|
40
|
-
.BNUpdateBlock<{
|
|
41
|
-
heading: BlockSpec<"heading", typeof headingPropSchema, true>;
|
|
42
|
-
}>(state.selection.from, {
|
|
43
|
-
type: "heading",
|
|
44
|
-
props: {
|
|
45
|
-
level: level as 1 | 2 | 3,
|
|
46
|
-
},
|
|
47
|
-
})
|
|
48
|
-
// Removes the "#" character(s) used to set the heading.
|
|
49
|
-
.deleteRange({ from: range.from, to: range.to });
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
}),
|
|
53
|
-
];
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
addKeyboardShortcuts() {
|
|
57
|
-
return {
|
|
58
|
-
"Mod-Alt-1": () =>
|
|
59
|
-
this.editor.commands.BNUpdateBlock<{
|
|
60
|
-
heading: BlockSpec<"heading", typeof headingPropSchema, true>;
|
|
61
|
-
}>(this.editor.state.selection.anchor, {
|
|
62
|
-
type: "heading",
|
|
63
|
-
props: {
|
|
64
|
-
level: 1,
|
|
65
|
-
},
|
|
66
|
-
}),
|
|
67
|
-
"Mod-Alt-2": () =>
|
|
68
|
-
this.editor.commands.BNUpdateBlock<{
|
|
69
|
-
heading: BlockSpec<"heading", typeof headingPropSchema, true>;
|
|
70
|
-
}>(this.editor.state.selection.anchor, {
|
|
71
|
-
type: "heading",
|
|
72
|
-
props: {
|
|
73
|
-
level: 2,
|
|
74
|
-
},
|
|
75
|
-
}),
|
|
76
|
-
"Mod-Alt-3": () =>
|
|
77
|
-
this.editor.commands.BNUpdateBlock<{
|
|
78
|
-
heading: BlockSpec<"heading", typeof headingPropSchema, true>;
|
|
79
|
-
}>(this.editor.state.selection.anchor, {
|
|
80
|
-
type: "heading",
|
|
81
|
-
props: {
|
|
82
|
-
level: 3,
|
|
83
|
-
},
|
|
84
|
-
}),
|
|
85
|
-
};
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
parseHTML() {
|
|
89
|
-
return [
|
|
90
|
-
{
|
|
91
|
-
tag: "h1",
|
|
92
|
-
attrs: { level: 1 },
|
|
93
|
-
node: "heading",
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
tag: "h2",
|
|
97
|
-
attrs: { level: 2 },
|
|
98
|
-
node: "heading",
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
tag: "h3",
|
|
102
|
-
attrs: { level: 3 },
|
|
103
|
-
node: "heading",
|
|
104
|
-
},
|
|
105
|
-
];
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
renderHTML({ node, HTMLAttributes }) {
|
|
109
|
-
const blockContentDOMAttributes =
|
|
110
|
-
this.options.domAttributes?.blockContent || {};
|
|
111
|
-
const inlineContentDOMAttributes =
|
|
112
|
-
this.options.domAttributes?.inlineContent || {};
|
|
113
|
-
|
|
114
|
-
return [
|
|
115
|
-
"div",
|
|
116
|
-
mergeAttributes(HTMLAttributes, {
|
|
117
|
-
...blockContentDOMAttributes,
|
|
118
|
-
class: mergeCSSClasses(
|
|
119
|
-
styles.blockContent,
|
|
120
|
-
blockContentDOMAttributes.class
|
|
121
|
-
),
|
|
122
|
-
"data-content-type": this.name,
|
|
123
|
-
}),
|
|
124
|
-
[
|
|
125
|
-
`h${node.attrs.level}`,
|
|
126
|
-
{
|
|
127
|
-
...inlineContentDOMAttributes,
|
|
128
|
-
class: mergeCSSClasses(
|
|
129
|
-
styles.inlineContent,
|
|
130
|
-
inlineContentDOMAttributes.class
|
|
131
|
-
),
|
|
132
|
-
},
|
|
133
|
-
0,
|
|
134
|
-
],
|
|
135
|
-
];
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
export const Heading = {
|
|
140
|
-
node: HeadingBlockContent,
|
|
141
|
-
propSchema: headingPropSchema,
|
|
142
|
-
} satisfies BlockSpec<"heading", typeof headingPropSchema, true>;
|
package/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContent.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { mergeAttributes } from "@tiptap/core";
|
|
2
|
-
import { defaultProps } from "../../../api/defaultProps";
|
|
3
|
-
import { createTipTapBlock } from "../../../api/block";
|
|
4
|
-
import { mergeCSSClasses } from "../../../../../shared/utils";
|
|
5
|
-
import styles from "../../Block.module.css";
|
|
6
|
-
|
|
7
|
-
export const paragraphPropSchema = {
|
|
8
|
-
...defaultProps,
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const ParagraphBlockContent = createTipTapBlock<"paragraph", true>({
|
|
12
|
-
name: "paragraph",
|
|
13
|
-
content: "inline*",
|
|
14
|
-
|
|
15
|
-
parseHTML() {
|
|
16
|
-
return [
|
|
17
|
-
{
|
|
18
|
-
tag: "p",
|
|
19
|
-
priority: 200,
|
|
20
|
-
node: "paragraph",
|
|
21
|
-
},
|
|
22
|
-
];
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
renderHTML({ HTMLAttributes }) {
|
|
26
|
-
const blockContentDOMAttributes =
|
|
27
|
-
this.options.domAttributes?.blockContent || {};
|
|
28
|
-
const inlineContentDOMAttributes =
|
|
29
|
-
this.options.domAttributes?.inlineContent || {};
|
|
30
|
-
|
|
31
|
-
return [
|
|
32
|
-
"div",
|
|
33
|
-
mergeAttributes(
|
|
34
|
-
{
|
|
35
|
-
...blockContentDOMAttributes,
|
|
36
|
-
class: mergeCSSClasses(
|
|
37
|
-
styles.blockContent,
|
|
38
|
-
blockContentDOMAttributes.class
|
|
39
|
-
),
|
|
40
|
-
"data-content-type": this.name,
|
|
41
|
-
},
|
|
42
|
-
HTMLAttributes
|
|
43
|
-
),
|
|
44
|
-
[
|
|
45
|
-
"p",
|
|
46
|
-
{
|
|
47
|
-
...inlineContentDOMAttributes,
|
|
48
|
-
class: mergeCSSClasses(
|
|
49
|
-
styles.inlineContent,
|
|
50
|
-
inlineContentDOMAttributes.class
|
|
51
|
-
),
|
|
52
|
-
},
|
|
53
|
-
0,
|
|
54
|
-
],
|
|
55
|
-
];
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
export const Paragraph = {
|
|
60
|
-
node: ParagraphBlockContent,
|
|
61
|
-
propSchema: paragraphPropSchema,
|
|
62
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { mergeAttributes, Node } from "@tiptap/core";
|
|
2
|
-
import styles from "./Block.module.css";
|
|
3
|
-
import { BlockNoteDOMAttributes } from "../api/blockTypes";
|
|
4
|
-
import { mergeCSSClasses } from "../../../shared/utils";
|
|
5
|
-
|
|
6
|
-
export const BlockGroup = Node.create<{
|
|
7
|
-
domAttributes?: BlockNoteDOMAttributes;
|
|
8
|
-
}>({
|
|
9
|
-
name: "blockGroup",
|
|
10
|
-
group: "blockGroup",
|
|
11
|
-
content: "blockContainer+",
|
|
12
|
-
|
|
13
|
-
parseHTML() {
|
|
14
|
-
return [
|
|
15
|
-
{
|
|
16
|
-
tag: "div",
|
|
17
|
-
getAttrs: (element) => {
|
|
18
|
-
if (typeof element === "string") {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (element.getAttribute("data-node-type") === "blockGroup") {
|
|
23
|
-
// Null means the element matches, but we don't want to add any attributes to the node.
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return false;
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
];
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
renderHTML({ HTMLAttributes }) {
|
|
34
|
-
const blockGroupDOMAttributes =
|
|
35
|
-
this.options.domAttributes?.blockGroup || {};
|
|
36
|
-
|
|
37
|
-
return [
|
|
38
|
-
"div",
|
|
39
|
-
mergeAttributes(
|
|
40
|
-
{
|
|
41
|
-
...blockGroupDOMAttributes,
|
|
42
|
-
class: mergeCSSClasses(
|
|
43
|
-
styles.blockGroup,
|
|
44
|
-
blockGroupDOMAttributes.class
|
|
45
|
-
),
|
|
46
|
-
"data-node-type": "blockGroup",
|
|
47
|
-
},
|
|
48
|
-
HTMLAttributes
|
|
49
|
-
),
|
|
50
|
-
0,
|
|
51
|
-
];
|
|
52
|
-
},
|
|
53
|
-
});
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Schema } from "prosemirror-model";
|
|
2
|
-
import { Block, BlockSchema } from "../../extensions/Blocks/api/blockTypes";
|
|
3
|
-
export declare function blocksToHTML<BSchema extends BlockSchema>(blocks: Block<BSchema>[], schema: Schema): Promise<string>;
|
|
4
|
-
export declare function HTMLToBlocks<BSchema extends BlockSchema>(html: string, blockSchema: BSchema, schema: Schema): Promise<Block<BSchema>[]>;
|
|
5
|
-
export declare function blocksToMarkdown<BSchema extends BlockSchema>(blocks: Block<BSchema>[], schema: Schema): Promise<string>;
|
|
6
|
-
export declare function markdownToBlocks<BSchema extends BlockSchema>(markdown: string, blockSchema: BSchema, schema: Schema): Promise<Block<BSchema>[]>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Attributes } from "@tiptap/core";
|
|
2
|
-
import { BlockNoteDOMAttributes } from "../../..";
|
|
3
|
-
import { BlockConfig, BlockSchema, BlockSpec, PropSchema, TipTapNode, TipTapNodeConfig } from "./blockTypes";
|
|
4
|
-
import { ParseRule } from "prosemirror-model";
|
|
5
|
-
export declare function camelToDataKebab(str: string): string;
|
|
6
|
-
export declare function propsToAttributes<BType extends string, PSchema extends PropSchema, ContainsInlineContent extends boolean, BSchema extends BlockSchema>(blockConfig: Omit<BlockConfig<BType, PSchema, ContainsInlineContent, BSchema>, "render">): Attributes;
|
|
7
|
-
export declare function parse<BType extends string, PSchema extends PropSchema, ContainsInlineContent extends boolean, BSchema extends BlockSchema>(blockConfig: Omit<BlockConfig<BType, PSchema, ContainsInlineContent, BSchema>, "render">): ParseRule[];
|
|
8
|
-
export declare function render<BType extends string, PSchema extends PropSchema, ContainsInlineContent extends boolean, BSchema extends BlockSchema>(blockConfig: Omit<BlockConfig<BType, PSchema, ContainsInlineContent, BSchema>, "render">, HTMLAttributes: Record<string, any>): {
|
|
9
|
-
dom: HTMLDivElement;
|
|
10
|
-
contentDOM: HTMLDivElement;
|
|
11
|
-
} | {
|
|
12
|
-
dom: HTMLDivElement;
|
|
13
|
-
contentDOM?: undefined;
|
|
14
|
-
};
|
|
15
|
-
export declare function createBlockSpec<BType extends string, PSchema extends PropSchema, ContainsInlineContent extends false, BSchema extends BlockSchema>(blockConfig: BlockConfig<BType, PSchema, ContainsInlineContent, BSchema>): BlockSpec<BType, PSchema, ContainsInlineContent>;
|
|
16
|
-
export declare function createTipTapBlock<Type extends string, ContainsInlineContent extends boolean, Options extends {
|
|
17
|
-
domAttributes?: BlockNoteDOMAttributes;
|
|
18
|
-
} = {
|
|
19
|
-
domAttributes?: BlockNoteDOMAttributes;
|
|
20
|
-
}, Storage = any>(config: TipTapNodeConfig<Type, ContainsInlineContent, Options, Storage>): TipTapNode<Type, ContainsInlineContent, Options, Storage>;
|