@blocknote/core 0.9.5 → 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 +3699 -2600
- 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 -98
- 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 +117 -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} +70 -66
- package/src/{BlockNoteEditor.test.ts → editor/BlockNoteEditor.test.ts} +2 -2
- package/src/{BlockNoteEditor.ts → editor/BlockNoteEditor.ts} +382 -159
- 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 +77 -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 +51 -37
- 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 +19 -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,95 @@
|
|
|
1
|
+
import { blockToNode } from "../api/nodeConversions/nodeConversions";
|
|
2
|
+
import type { BlockNoteEditor } from "../editor/BlockNoteEditor";
|
|
3
|
+
import type {
|
|
4
|
+
Block,
|
|
5
|
+
BlockSchema,
|
|
6
|
+
InlineContentSchema,
|
|
7
|
+
StyleSchema,
|
|
8
|
+
} from "../schema";
|
|
9
|
+
import { mergeCSSClasses } from "../util/browser";
|
|
10
|
+
|
|
11
|
+
// Function that creates a ProseMirror `DOMOutputSpec` for a default block.
|
|
12
|
+
// Since all default blocks have the same structure (`blockContent` div with a
|
|
13
|
+
// `inlineContent` element inside), this function only needs the block's name
|
|
14
|
+
// for the `data-content-type` attribute of the `blockContent` element and the
|
|
15
|
+
// HTML tag of the `inlineContent` element, as well as any HTML attributes to
|
|
16
|
+
// add to those.
|
|
17
|
+
export function createDefaultBlockDOMOutputSpec(
|
|
18
|
+
blockName: string,
|
|
19
|
+
htmlTag: string,
|
|
20
|
+
blockContentHTMLAttributes: Record<string, string>,
|
|
21
|
+
inlineContentHTMLAttributes: Record<string, string>
|
|
22
|
+
) {
|
|
23
|
+
const blockContent = document.createElement("div");
|
|
24
|
+
blockContent.className = mergeCSSClasses(
|
|
25
|
+
"bn-block-content",
|
|
26
|
+
blockContentHTMLAttributes.class
|
|
27
|
+
);
|
|
28
|
+
blockContent.setAttribute("data-content-type", blockName);
|
|
29
|
+
for (const [attribute, value] of Object.entries(blockContentHTMLAttributes)) {
|
|
30
|
+
if (attribute !== "class") {
|
|
31
|
+
blockContent.setAttribute(attribute, value);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const inlineContent = document.createElement(htmlTag);
|
|
36
|
+
inlineContent.className = mergeCSSClasses(
|
|
37
|
+
"bn-inline-content",
|
|
38
|
+
inlineContentHTMLAttributes.class
|
|
39
|
+
);
|
|
40
|
+
for (const [attribute, value] of Object.entries(
|
|
41
|
+
inlineContentHTMLAttributes
|
|
42
|
+
)) {
|
|
43
|
+
if (attribute !== "class") {
|
|
44
|
+
inlineContent.setAttribute(attribute, value);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
blockContent.appendChild(inlineContent);
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
dom: blockContent,
|
|
52
|
+
contentDOM: inlineContent,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Function used to convert default blocks to HTML. It uses the corresponding
|
|
57
|
+
// node's `renderHTML` method to do the conversion by using a default
|
|
58
|
+
// `DOMSerializer`.
|
|
59
|
+
export const defaultBlockToHTML = <
|
|
60
|
+
BSchema extends BlockSchema,
|
|
61
|
+
I extends InlineContentSchema,
|
|
62
|
+
S extends StyleSchema
|
|
63
|
+
>(
|
|
64
|
+
block: Block<BSchema, I, S>,
|
|
65
|
+
editor: BlockNoteEditor<BSchema, I, S>
|
|
66
|
+
): {
|
|
67
|
+
dom: HTMLElement;
|
|
68
|
+
contentDOM?: HTMLElement;
|
|
69
|
+
} => {
|
|
70
|
+
const node = blockToNode(
|
|
71
|
+
block,
|
|
72
|
+
editor._tiptapEditor.schema,
|
|
73
|
+
editor.styleSchema
|
|
74
|
+
).firstChild!;
|
|
75
|
+
const toDOM = editor._tiptapEditor.schema.nodes[node.type.name].spec.toDOM;
|
|
76
|
+
|
|
77
|
+
if (toDOM === undefined) {
|
|
78
|
+
throw new Error(
|
|
79
|
+
"This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`."
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const renderSpec = toDOM(node);
|
|
84
|
+
|
|
85
|
+
if (typeof renderSpec !== "object" || !("dom" in renderSpec)) {
|
|
86
|
+
throw new Error(
|
|
87
|
+
"Cannot use this block's default HTML serialization as its corresponding TipTap node's `renderHTML` function does not return an object with the `dom` property."
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return renderSpec as {
|
|
92
|
+
dom: HTMLElement;
|
|
93
|
+
contentDOM?: HTMLElement;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import Bold from "@tiptap/extension-bold";
|
|
2
|
+
import Code from "@tiptap/extension-code";
|
|
3
|
+
import Italic from "@tiptap/extension-italic";
|
|
4
|
+
import Strike from "@tiptap/extension-strike";
|
|
5
|
+
import Underline from "@tiptap/extension-underline";
|
|
6
|
+
import { BackgroundColor } from "../extensions/BackgroundColor/BackgroundColorMark";
|
|
7
|
+
import { TextColor } from "../extensions/TextColor/TextColorMark";
|
|
8
|
+
import {
|
|
9
|
+
BlockSpecs,
|
|
10
|
+
InlineContentSpecs,
|
|
11
|
+
StyleSpecs,
|
|
12
|
+
createStyleSpecFromTipTapMark,
|
|
13
|
+
getBlockSchemaFromSpecs,
|
|
14
|
+
getInlineContentSchemaFromSpecs,
|
|
15
|
+
getStyleSchemaFromSpecs,
|
|
16
|
+
} from "../schema";
|
|
17
|
+
import { Heading } from "./HeadingBlockContent/HeadingBlockContent";
|
|
18
|
+
import { Image } from "./ImageBlockContent/ImageBlockContent";
|
|
19
|
+
import { BulletListItem } from "./ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent";
|
|
20
|
+
import { NumberedListItem } from "./ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent";
|
|
21
|
+
import { Paragraph } from "./ParagraphBlockContent/ParagraphBlockContent";
|
|
22
|
+
import { Table } from "./TableBlockContent/TableBlockContent";
|
|
23
|
+
|
|
24
|
+
export const defaultBlockSpecs = {
|
|
25
|
+
paragraph: Paragraph,
|
|
26
|
+
heading: Heading,
|
|
27
|
+
bulletListItem: BulletListItem,
|
|
28
|
+
numberedListItem: NumberedListItem,
|
|
29
|
+
image: Image,
|
|
30
|
+
table: Table,
|
|
31
|
+
} satisfies BlockSpecs;
|
|
32
|
+
|
|
33
|
+
export const defaultBlockSchema = getBlockSchemaFromSpecs(defaultBlockSpecs);
|
|
34
|
+
|
|
35
|
+
export type DefaultBlockSchema = typeof defaultBlockSchema;
|
|
36
|
+
|
|
37
|
+
export const defaultStyleSpecs = {
|
|
38
|
+
bold: createStyleSpecFromTipTapMark(Bold, "boolean"),
|
|
39
|
+
italic: createStyleSpecFromTipTapMark(Italic, "boolean"),
|
|
40
|
+
underline: createStyleSpecFromTipTapMark(Underline, "boolean"),
|
|
41
|
+
strike: createStyleSpecFromTipTapMark(Strike, "boolean"),
|
|
42
|
+
code: createStyleSpecFromTipTapMark(Code, "boolean"),
|
|
43
|
+
textColor: TextColor,
|
|
44
|
+
backgroundColor: BackgroundColor,
|
|
45
|
+
} satisfies StyleSpecs;
|
|
46
|
+
|
|
47
|
+
export const defaultStyleSchema = getStyleSchemaFromSpecs(defaultStyleSpecs);
|
|
48
|
+
|
|
49
|
+
export type DefaultStyleSchema = typeof defaultStyleSchema;
|
|
50
|
+
|
|
51
|
+
export const defaultInlineContentSpecs = {
|
|
52
|
+
text: { config: "text", implementation: {} as any },
|
|
53
|
+
link: { config: "link", implementation: {} as any },
|
|
54
|
+
} satisfies InlineContentSpecs;
|
|
55
|
+
|
|
56
|
+
export const defaultInlineContentSchema = getInlineContentSchemaFromSpecs(
|
|
57
|
+
defaultInlineContentSpecs
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
export type DefaultInlineContentSchema = typeof defaultInlineContentSchema;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Props, PropSchema } from "../schema";
|
|
2
|
+
|
|
3
|
+
// TODO: this system should probably be moved / refactored.
|
|
4
|
+
// The dependency from schema on this file doesn't make sense
|
|
5
|
+
|
|
6
|
+
export const defaultProps = {
|
|
7
|
+
backgroundColor: {
|
|
8
|
+
default: "default" as const,
|
|
9
|
+
},
|
|
10
|
+
textColor: {
|
|
11
|
+
default: "default" as const,
|
|
12
|
+
},
|
|
13
|
+
textAlignment: {
|
|
14
|
+
default: "left" as const,
|
|
15
|
+
values: ["left", "center", "right", "justify"] as const,
|
|
16
|
+
},
|
|
17
|
+
} satisfies PropSchema;
|
|
18
|
+
|
|
19
|
+
export type DefaultProps = Props<typeof defaultProps>;
|
|
20
|
+
|
|
21
|
+
// Default props which are set on `blockContainer` nodes rather than
|
|
22
|
+
// `blockContent` nodes. Ensures that they are not redundantly added to
|
|
23
|
+
// a custom block's TipTap node attributes.
|
|
24
|
+
export const inheritedProps = ["backgroundColor", "textColor"];
|
|
@@ -2,34 +2,35 @@
|
|
|
2
2
|
BASIC STYLES
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
.
|
|
5
|
+
.bn-block-outer {
|
|
6
6
|
line-height: 1.5;
|
|
7
7
|
transition: margin 0.2s;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
/*Ensures blocks & block content spans editor width*/
|
|
11
|
-
.block {
|
|
11
|
+
.bn-block {
|
|
12
12
|
display: flex;
|
|
13
13
|
flex-direction: column;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
/*Ensures block content inside React node views spans editor width*/
|
|
17
|
-
.
|
|
17
|
+
.bn-react-node-view-renderer {
|
|
18
18
|
display: flex;
|
|
19
19
|
flex-grow: 1;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
.
|
|
22
|
+
.bn-block-content {
|
|
23
23
|
padding: 3px 0;
|
|
24
24
|
flex-grow: 1;
|
|
25
25
|
transition: font-size 0.2s;
|
|
26
|
+
width: 100%;
|
|
26
27
|
/*
|
|
27
28
|
because the content elements are display: block
|
|
28
29
|
we use flex to position them next to list markers
|
|
29
30
|
*/
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
.
|
|
33
|
+
.bn-block-content::before {
|
|
33
34
|
/* content: ""; */
|
|
34
35
|
transition: all 0.2s;
|
|
35
36
|
/*margin: 0px;*/
|
|
@@ -39,15 +40,16 @@ BASIC STYLES
|
|
|
39
40
|
NESTED BLOCKS
|
|
40
41
|
*/
|
|
41
42
|
|
|
42
|
-
.
|
|
43
|
+
.bn-block-group .bn-block-group {
|
|
43
44
|
margin-left: 1.5em;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
.
|
|
47
|
+
.bn-block-group .bn-block-group > .bn-block-outer {
|
|
47
48
|
position: relative;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
.
|
|
51
|
+
.bn-block-group .bn-block-group
|
|
52
|
+
> .bn-block-outer:not([data-prev-depth-changed])::before {
|
|
51
53
|
content: " ";
|
|
52
54
|
display: inline;
|
|
53
55
|
position: absolute;
|
|
@@ -56,7 +58,8 @@ NESTED BLOCKS
|
|
|
56
58
|
transition: all 0.2s 0.1s;
|
|
57
59
|
}
|
|
58
60
|
|
|
59
|
-
.
|
|
61
|
+
.bn-block-group .bn-block-group
|
|
62
|
+
> .bn-block-outer[data-prev-depth-change="-2"]::before {
|
|
60
63
|
height: 0;
|
|
61
64
|
}
|
|
62
65
|
|
|
@@ -94,11 +97,12 @@ NESTED BLOCKS
|
|
|
94
97
|
--x: -5;
|
|
95
98
|
}
|
|
96
99
|
|
|
97
|
-
.
|
|
100
|
+
.bn-block-outer[data-prev-depth-change] {
|
|
98
101
|
margin-left: calc(10px * var(--x));
|
|
99
102
|
}
|
|
100
103
|
|
|
101
|
-
.
|
|
104
|
+
.bn-block-outer[data-prev-depth-change]
|
|
105
|
+
.bn-block-outer[data-prev-depth-change] {
|
|
102
106
|
margin-left: 0;
|
|
103
107
|
}
|
|
104
108
|
|
|
@@ -123,21 +127,21 @@ NESTED BLOCKS
|
|
|
123
127
|
--prev-level: 1.3em;
|
|
124
128
|
}
|
|
125
129
|
|
|
126
|
-
.
|
|
130
|
+
.bn-block-outer[data-prev-type="heading"] > .bn-block > .bn-block-content {
|
|
127
131
|
font-size: var(--prev-level);
|
|
128
132
|
font-weight: bold;
|
|
129
133
|
}
|
|
130
134
|
|
|
131
|
-
.
|
|
132
|
-
> .block
|
|
133
|
-
> .
|
|
135
|
+
.bn-block-outer:not([data-prev-type])
|
|
136
|
+
> .bn-block
|
|
137
|
+
> .bn-block-content[data-content-type="heading"] {
|
|
134
138
|
font-size: var(--level);
|
|
135
139
|
font-weight: bold;
|
|
136
140
|
}
|
|
137
141
|
|
|
138
142
|
/* LISTS */
|
|
139
143
|
|
|
140
|
-
.
|
|
144
|
+
.bn-block-content::before {
|
|
141
145
|
margin-right: 0;
|
|
142
146
|
content: "";
|
|
143
147
|
}
|
|
@@ -151,79 +155,81 @@ NESTED BLOCKS
|
|
|
151
155
|
--prev-index: attr(data-prev-index);
|
|
152
156
|
}
|
|
153
157
|
|
|
154
|
-
.
|
|
155
|
-
> .block
|
|
156
|
-
> .
|
|
158
|
+
.bn-block-outer[data-prev-type="numberedListItem"]:not([data-prev-index="none"])
|
|
159
|
+
> .bn-block
|
|
160
|
+
> .bn-block-content::before {
|
|
157
161
|
margin-right: 1.2em;
|
|
158
162
|
content: var(--prev-index) ".";
|
|
159
163
|
}
|
|
160
164
|
|
|
161
|
-
.
|
|
162
|
-
> .block
|
|
163
|
-
> .
|
|
165
|
+
.bn-block-outer:not([data-prev-type])
|
|
166
|
+
> .bn-block
|
|
167
|
+
> .bn-block-content[data-content-type="numberedListItem"]::before {
|
|
164
168
|
margin-right: 1.2em;
|
|
165
169
|
content: var(--index) ".";
|
|
166
170
|
}
|
|
167
171
|
|
|
168
172
|
/* Unordered */
|
|
169
173
|
/* No list nesting */
|
|
170
|
-
.
|
|
174
|
+
.bn-block-outer[data-prev-type="bulletListItem"]
|
|
175
|
+
> .bn-block
|
|
176
|
+
> .bn-block-content::before {
|
|
171
177
|
margin-right: 1.2em;
|
|
172
178
|
content: "•";
|
|
173
179
|
}
|
|
174
180
|
|
|
175
|
-
.
|
|
176
|
-
> .block
|
|
177
|
-
> .
|
|
181
|
+
.bn-block-outer:not([data-prev-type])
|
|
182
|
+
> .bn-block
|
|
183
|
+
> .bn-block-content[data-content-type="bulletListItem"]::before {
|
|
178
184
|
margin-right: 1.2em;
|
|
179
185
|
content: "•";
|
|
180
186
|
}
|
|
181
187
|
|
|
182
188
|
/* 1 level of list nesting */
|
|
183
189
|
[data-content-type="bulletListItem"]
|
|
184
|
-
~ .
|
|
185
|
-
> .
|
|
186
|
-
> .block
|
|
187
|
-
> .
|
|
190
|
+
~ .bn-block-group
|
|
191
|
+
> .bn-block-outer[data-prev-type="bulletListItem"]
|
|
192
|
+
> .bn-block
|
|
193
|
+
> .bn-block-content::before {
|
|
188
194
|
margin-right: 1.2em;
|
|
189
195
|
content: "◦";
|
|
190
196
|
}
|
|
191
197
|
|
|
192
198
|
[data-content-type="bulletListItem"]
|
|
193
|
-
~ .
|
|
194
|
-
> .
|
|
195
|
-
> .block
|
|
196
|
-
> .
|
|
199
|
+
~ .bn-block-group
|
|
200
|
+
> .bn-block-outer:not([data-prev-type])
|
|
201
|
+
> .bn-block
|
|
202
|
+
> .bn-block-content[data-content-type="bulletListItem"]::before {
|
|
197
203
|
margin-right: 1.2em;
|
|
198
204
|
content: "◦";
|
|
199
205
|
}
|
|
200
206
|
|
|
201
207
|
/* 2 levels of list nesting */
|
|
202
208
|
[data-content-type="bulletListItem"]
|
|
203
|
-
~ .
|
|
209
|
+
~ .bn-block-group
|
|
204
210
|
[data-content-type="bulletListItem"]
|
|
205
|
-
~ .
|
|
206
|
-
> .
|
|
207
|
-
> .block
|
|
208
|
-
> .
|
|
211
|
+
~ .bn-block-group
|
|
212
|
+
> .bn-block-outer[data-prev-type="bulletListItem"]
|
|
213
|
+
> .bn-block
|
|
214
|
+
> .bn-block-content::before {
|
|
209
215
|
margin-right: 1.2em;
|
|
210
216
|
content: "▪";
|
|
211
217
|
}
|
|
212
218
|
|
|
213
219
|
[data-content-type="bulletListItem"]
|
|
214
|
-
~ .
|
|
220
|
+
~ .bn-block-group
|
|
215
221
|
[data-content-type="bulletListItem"]
|
|
216
|
-
~ .
|
|
217
|
-
> .
|
|
218
|
-
> .block
|
|
219
|
-
> .
|
|
222
|
+
~ .bn-block-group
|
|
223
|
+
> .bn-block-outer:not([data-prev-type])
|
|
224
|
+
> .bn-block
|
|
225
|
+
> .bn-block-content[data-content-type="bulletListItem"]::before {
|
|
220
226
|
margin-right: 1.2em;
|
|
221
227
|
content: "▪";
|
|
222
228
|
}
|
|
223
229
|
|
|
224
230
|
/* IMAGES */
|
|
225
231
|
|
|
226
|
-
[data-content-type="image"] .wrapper {
|
|
232
|
+
[data-content-type="image"] .bn-image-block-content-wrapper {
|
|
227
233
|
display: flex;
|
|
228
234
|
flex-direction: column;
|
|
229
235
|
justify-content: center;
|
|
@@ -231,7 +237,7 @@ NESTED BLOCKS
|
|
|
231
237
|
width: 100%;
|
|
232
238
|
}
|
|
233
239
|
|
|
234
|
-
[data-content-type="image"] .
|
|
240
|
+
[data-content-type="image"] .bn-add-image-button {
|
|
235
241
|
display: flex;
|
|
236
242
|
flex-direction: row;
|
|
237
243
|
align-items: center;
|
|
@@ -243,27 +249,27 @@ NESTED BLOCKS
|
|
|
243
249
|
width: 100%;
|
|
244
250
|
}
|
|
245
251
|
|
|
246
|
-
[data-content-type="image"] .
|
|
252
|
+
[data-content-type="image"] .bn-add-image-button:hover {
|
|
247
253
|
background-color: gainsboro;
|
|
248
254
|
}
|
|
249
255
|
|
|
250
|
-
[data-content-type="image"] .
|
|
256
|
+
[data-content-type="image"] .bn-add-image-button-icon {
|
|
251
257
|
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20 5H4V19L13.2923 9.70649C13.6828 9.31595 14.3159 9.31591 14.7065 9.70641L20 15.0104V5ZM2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 11C6.89543 11 6 10.1046 6 9C6 7.89543 6.89543 7 8 7C9.10457 7 10 7.89543 10 9C10 10.1046 9.10457 11 8 11Z'%3E%3C/path%3E%3C/svg%3E");
|
|
252
258
|
width: 24px;
|
|
253
259
|
height: 24px;
|
|
254
260
|
}
|
|
255
261
|
|
|
256
|
-
[data-content-type="image"] .
|
|
262
|
+
[data-content-type="image"] .bn-add-image-button-text {
|
|
257
263
|
color: black;
|
|
258
264
|
}
|
|
259
265
|
|
|
260
|
-
[data-content-type="image"] .
|
|
266
|
+
[data-content-type="image"] .bn-image-and-caption-wrapper {
|
|
261
267
|
display: flex;
|
|
262
268
|
flex-direction: column;
|
|
263
269
|
border-radius: 4px;
|
|
264
270
|
}
|
|
265
271
|
|
|
266
|
-
[data-content-type="image"] .
|
|
272
|
+
[data-content-type="image"] .bn-image-wrapper {
|
|
267
273
|
display: flex;
|
|
268
274
|
flex-direction: row;
|
|
269
275
|
align-items: center;
|
|
@@ -271,12 +277,12 @@ NESTED BLOCKS
|
|
|
271
277
|
width: fit-content;
|
|
272
278
|
}
|
|
273
279
|
|
|
274
|
-
[data-content-type="image"] .image {
|
|
280
|
+
[data-content-type="image"] .bn-image {
|
|
275
281
|
border-radius: 4px;
|
|
276
282
|
max-width: 100%;
|
|
277
283
|
}
|
|
278
284
|
|
|
279
|
-
[data-content-type="image"] .
|
|
285
|
+
[data-content-type="image"] .bn-image-resize-handle {
|
|
280
286
|
display: none;
|
|
281
287
|
position: absolute;
|
|
282
288
|
width: 8px;
|
|
@@ -287,18 +293,14 @@ NESTED BLOCKS
|
|
|
287
293
|
cursor: ew-resize;
|
|
288
294
|
}
|
|
289
295
|
|
|
290
|
-
[data-content-type="image"] .imageWrapper:hover .resizeHandle {
|
|
291
|
-
display: block;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
296
|
[data-content-type="image"] .caption {
|
|
295
297
|
font-size: 0.8em
|
|
296
298
|
}
|
|
297
299
|
|
|
298
300
|
/* PLACEHOLDERS*/
|
|
299
301
|
|
|
300
|
-
.
|
|
301
|
-
.
|
|
302
|
+
.bn-is-empty .bn-inline-content:before,
|
|
303
|
+
.bn-is-filter .bn-inline-content:before {
|
|
302
304
|
/*float: left; */
|
|
303
305
|
content: "";
|
|
304
306
|
pointer-events: none;
|
|
@@ -310,25 +312,27 @@ NESTED BLOCKS
|
|
|
310
312
|
|
|
311
313
|
/* TODO: would be nicer if defined from code */
|
|
312
314
|
|
|
313
|
-
.
|
|
315
|
+
.bn-block-content.bn-is-empty.bn-has-anchor .bn-inline-content:before {
|
|
314
316
|
content: "Enter text or type '/' for commands";
|
|
315
317
|
}
|
|
316
318
|
|
|
317
|
-
.
|
|
319
|
+
.bn-block-content.bn-is-filter.bn-has-anchor .bn-inline-content:before {
|
|
318
320
|
content: "Type to filter";
|
|
319
321
|
}
|
|
320
322
|
|
|
321
|
-
.
|
|
323
|
+
.bn-block-content[data-content-type="heading"].bn-is-empty
|
|
324
|
+
.bn-inline-content:before {
|
|
322
325
|
content: "Heading";
|
|
323
326
|
}
|
|
324
327
|
|
|
325
|
-
.
|
|
326
|
-
.
|
|
327
|
-
.
|
|
328
|
+
.bn-block-content[data-content-type="bulletListItem"].bn-is-empty
|
|
329
|
+
.bn-inline-content:before,
|
|
330
|
+
.bn-block-content[data-content-type="numberedListItem"].bn-is-empty
|
|
331
|
+
.bn-inline-content:before {
|
|
328
332
|
content: "List";
|
|
329
333
|
}
|
|
330
334
|
|
|
331
|
-
.
|
|
335
|
+
.bn-is-empty .bn-block-content[data-content-type="captionedImage"] .bn-inline-content:before {
|
|
332
336
|
content: "Caption";
|
|
333
337
|
}
|
|
334
338
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { expect, it } from "vitest";
|
|
2
2
|
import { BlockNoteEditor } from "./BlockNoteEditor";
|
|
3
|
-
import { getBlockInfoFromPos } from "
|
|
3
|
+
import { getBlockInfoFromPos } from "../api/getBlockInfoFromPos";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @vitest-environment jsdom
|
|
7
7
|
*/
|
|
8
8
|
it("creates an editor", () => {
|
|
9
|
-
const editor =
|
|
9
|
+
const editor = BlockNoteEditor.create();
|
|
10
10
|
const blockInfo = getBlockInfoFromPos(editor._tiptapEditor.state.doc, 2);
|
|
11
11
|
expect(blockInfo?.contentNode.type.name).toEqual("paragraph");
|
|
12
12
|
});
|