@blocknote/core 0.9.6 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocknote.js +3696 -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 +11 -5
- 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/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} +363 -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} +43 -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/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/nodeConversions/nodeConversions.d.ts +14 -6
- 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/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/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.d.ts +46 -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/{extensions/Blocks/api → blocks}/defaultProps.d.ts +2 -1
- package/types/src/{BlockNoteEditor.d.ts → editor/BlockNoteEditor.d.ts} +54 -43
- package/types/src/editor/BlockNoteEditor.test.d.ts +1 -0
- package/types/src/{BlockNoteExtensions.d.ts → editor/BlockNoteExtensions.d.ts} +7 -4
- 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/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/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/{shared/plugins → extensions-shared}/suggestion/SuggestionPlugin.d.ts +5 -4
- package/types/src/index.d.ts +20 -15
- package/types/src/{extensions/Blocks/nodes → pm-nodes}/BlockContainer.d.ts +5 -3
- 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/utils.d.ts → util/browser.d.ts} +0 -3
- 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/api/nodeConversions/testUtil.d.ts +0 -2
- 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/cursorPositionTypes.d.ts +0 -6
- package/types/src/extensions/Blocks/api/defaultBlocks.d.ts +0 -117
- package/types/src/extensions/Blocks/api/inlineContentTypes.d.ts +0 -30
- package/types/src/extensions/Blocks/api/selectionTypes.d.ts +0 -4
- package/types/src/extensions/Blocks/api/serialization.d.ts +0 -2
- package/types/src/extensions/Blocks/helpers/findBlock.d.ts +0 -6
- package/types/src/extensions/Blocks/index.d.ts +0 -4
- package/types/src/extensions/Blocks/nodes/BlockAttributes.d.ts +0 -2
- package/types/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContent.d.ts +0 -43
- package/types/src/extensions/Blocks/nodes/BlockContent/ImageBlockContent/ImageBlockContent.d.ts +0 -37
- package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.d.ts +0 -35
- package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +0 -35
- package/types/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContent.d.ts +0 -44
- /package/src/{shared/EditorElement.ts → api/exporters/markdown/__snapshots__/hardbreak/only/markdown.md} +0 -0
- /package/{types/src/shared/EditorElement.d.ts → src/api/exporters/markdown/__snapshots__/paragraph/empty/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/{BlockNoteEditor.test.d.ts → api/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/formatConversions.test.d.ts → exporters/markdown/markdownExporter.test.d.ts} +0 -0
- /package/types/src/api/{formatConversions → exporters/markdown}/removeUnderlinesRehypePlugin.d.ts +0 -0
- /package/types/src/{extensions/Blocks/helpers → api}/getBlockInfoFromPos.d.ts +0 -0
- /package/types/src/api/{util/nodeUtil.d.ts → nodeUtil.d.ts} +0 -0
- /package/types/src/{extensions/Blocks/nodes/BlockContent → blocks}/ImageBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.d.ts +0 -0
- /package/types/src/{extensions/Blocks/nodes/BlockContent → blocks}/ListItemBlockContent/ListItemKeyboardShortcuts.d.ts +0 -0
- /package/types/src/{extensions/Blocks/nodes/BlockContent → blocks}/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.d.ts +0 -0
- /package/types/src/extensions/{Blocks → NonEditableBlocks}/NonEditableBlockPlugin.d.ts +0 -0
- /package/types/src/extensions/{Blocks → PreviousBlockType}/PreviousBlockTypePlugin.d.ts +0 -0
- /package/types/src/{shared → extensions-shared}/BaseUiElementTypes.d.ts +0 -0
- /package/types/src/{shared/plugins → extensions-shared}/suggestion/SuggestionItem.d.ts +0 -0
- /package/types/src/{extensions/Blocks/nodes → pm-nodes}/BlockGroup.d.ts +0 -0
- /package/types/src/{shared → util}/EventEmitter.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,24 +2,24 @@
|
|
|
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;
|
|
@@ -30,7 +30,7 @@ BASIC STYLES
|
|
|
30
30
|
*/
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
.
|
|
33
|
+
.bn-block-content::before {
|
|
34
34
|
/* content: ""; */
|
|
35
35
|
transition: all 0.2s;
|
|
36
36
|
/*margin: 0px;*/
|
|
@@ -40,15 +40,16 @@ BASIC STYLES
|
|
|
40
40
|
NESTED BLOCKS
|
|
41
41
|
*/
|
|
42
42
|
|
|
43
|
-
.
|
|
43
|
+
.bn-block-group .bn-block-group {
|
|
44
44
|
margin-left: 1.5em;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
.
|
|
47
|
+
.bn-block-group .bn-block-group > .bn-block-outer {
|
|
48
48
|
position: relative;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
.
|
|
51
|
+
.bn-block-group .bn-block-group
|
|
52
|
+
> .bn-block-outer:not([data-prev-depth-changed])::before {
|
|
52
53
|
content: " ";
|
|
53
54
|
display: inline;
|
|
54
55
|
position: absolute;
|
|
@@ -57,7 +58,8 @@ NESTED BLOCKS
|
|
|
57
58
|
transition: all 0.2s 0.1s;
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
.
|
|
61
|
+
.bn-block-group .bn-block-group
|
|
62
|
+
> .bn-block-outer[data-prev-depth-change="-2"]::before {
|
|
61
63
|
height: 0;
|
|
62
64
|
}
|
|
63
65
|
|
|
@@ -95,11 +97,12 @@ NESTED BLOCKS
|
|
|
95
97
|
--x: -5;
|
|
96
98
|
}
|
|
97
99
|
|
|
98
|
-
.
|
|
100
|
+
.bn-block-outer[data-prev-depth-change] {
|
|
99
101
|
margin-left: calc(10px * var(--x));
|
|
100
102
|
}
|
|
101
103
|
|
|
102
|
-
.
|
|
104
|
+
.bn-block-outer[data-prev-depth-change]
|
|
105
|
+
.bn-block-outer[data-prev-depth-change] {
|
|
103
106
|
margin-left: 0;
|
|
104
107
|
}
|
|
105
108
|
|
|
@@ -124,21 +127,21 @@ NESTED BLOCKS
|
|
|
124
127
|
--prev-level: 1.3em;
|
|
125
128
|
}
|
|
126
129
|
|
|
127
|
-
.
|
|
130
|
+
.bn-block-outer[data-prev-type="heading"] > .bn-block > .bn-block-content {
|
|
128
131
|
font-size: var(--prev-level);
|
|
129
132
|
font-weight: bold;
|
|
130
133
|
}
|
|
131
134
|
|
|
132
|
-
.
|
|
133
|
-
> .block
|
|
134
|
-
> .
|
|
135
|
+
.bn-block-outer:not([data-prev-type])
|
|
136
|
+
> .bn-block
|
|
137
|
+
> .bn-block-content[data-content-type="heading"] {
|
|
135
138
|
font-size: var(--level);
|
|
136
139
|
font-weight: bold;
|
|
137
140
|
}
|
|
138
141
|
|
|
139
142
|
/* LISTS */
|
|
140
143
|
|
|
141
|
-
.
|
|
144
|
+
.bn-block-content::before {
|
|
142
145
|
margin-right: 0;
|
|
143
146
|
content: "";
|
|
144
147
|
}
|
|
@@ -152,79 +155,81 @@ NESTED BLOCKS
|
|
|
152
155
|
--prev-index: attr(data-prev-index);
|
|
153
156
|
}
|
|
154
157
|
|
|
155
|
-
.
|
|
156
|
-
> .block
|
|
157
|
-
> .
|
|
158
|
+
.bn-block-outer[data-prev-type="numberedListItem"]:not([data-prev-index="none"])
|
|
159
|
+
> .bn-block
|
|
160
|
+
> .bn-block-content::before {
|
|
158
161
|
margin-right: 1.2em;
|
|
159
162
|
content: var(--prev-index) ".";
|
|
160
163
|
}
|
|
161
164
|
|
|
162
|
-
.
|
|
163
|
-
> .block
|
|
164
|
-
> .
|
|
165
|
+
.bn-block-outer:not([data-prev-type])
|
|
166
|
+
> .bn-block
|
|
167
|
+
> .bn-block-content[data-content-type="numberedListItem"]::before {
|
|
165
168
|
margin-right: 1.2em;
|
|
166
169
|
content: var(--index) ".";
|
|
167
170
|
}
|
|
168
171
|
|
|
169
172
|
/* Unordered */
|
|
170
173
|
/* No list nesting */
|
|
171
|
-
.
|
|
174
|
+
.bn-block-outer[data-prev-type="bulletListItem"]
|
|
175
|
+
> .bn-block
|
|
176
|
+
> .bn-block-content::before {
|
|
172
177
|
margin-right: 1.2em;
|
|
173
178
|
content: "•";
|
|
174
179
|
}
|
|
175
180
|
|
|
176
|
-
.
|
|
177
|
-
> .block
|
|
178
|
-
> .
|
|
181
|
+
.bn-block-outer:not([data-prev-type])
|
|
182
|
+
> .bn-block
|
|
183
|
+
> .bn-block-content[data-content-type="bulletListItem"]::before {
|
|
179
184
|
margin-right: 1.2em;
|
|
180
185
|
content: "•";
|
|
181
186
|
}
|
|
182
187
|
|
|
183
188
|
/* 1 level of list nesting */
|
|
184
189
|
[data-content-type="bulletListItem"]
|
|
185
|
-
~ .
|
|
186
|
-
> .
|
|
187
|
-
> .block
|
|
188
|
-
> .
|
|
190
|
+
~ .bn-block-group
|
|
191
|
+
> .bn-block-outer[data-prev-type="bulletListItem"]
|
|
192
|
+
> .bn-block
|
|
193
|
+
> .bn-block-content::before {
|
|
189
194
|
margin-right: 1.2em;
|
|
190
195
|
content: "◦";
|
|
191
196
|
}
|
|
192
197
|
|
|
193
198
|
[data-content-type="bulletListItem"]
|
|
194
|
-
~ .
|
|
195
|
-
> .
|
|
196
|
-
> .block
|
|
197
|
-
> .
|
|
199
|
+
~ .bn-block-group
|
|
200
|
+
> .bn-block-outer:not([data-prev-type])
|
|
201
|
+
> .bn-block
|
|
202
|
+
> .bn-block-content[data-content-type="bulletListItem"]::before {
|
|
198
203
|
margin-right: 1.2em;
|
|
199
204
|
content: "◦";
|
|
200
205
|
}
|
|
201
206
|
|
|
202
207
|
/* 2 levels of list nesting */
|
|
203
208
|
[data-content-type="bulletListItem"]
|
|
204
|
-
~ .
|
|
209
|
+
~ .bn-block-group
|
|
205
210
|
[data-content-type="bulletListItem"]
|
|
206
|
-
~ .
|
|
207
|
-
> .
|
|
208
|
-
> .block
|
|
209
|
-
> .
|
|
211
|
+
~ .bn-block-group
|
|
212
|
+
> .bn-block-outer[data-prev-type="bulletListItem"]
|
|
213
|
+
> .bn-block
|
|
214
|
+
> .bn-block-content::before {
|
|
210
215
|
margin-right: 1.2em;
|
|
211
216
|
content: "▪";
|
|
212
217
|
}
|
|
213
218
|
|
|
214
219
|
[data-content-type="bulletListItem"]
|
|
215
|
-
~ .
|
|
220
|
+
~ .bn-block-group
|
|
216
221
|
[data-content-type="bulletListItem"]
|
|
217
|
-
~ .
|
|
218
|
-
> .
|
|
219
|
-
> .block
|
|
220
|
-
> .
|
|
222
|
+
~ .bn-block-group
|
|
223
|
+
> .bn-block-outer:not([data-prev-type])
|
|
224
|
+
> .bn-block
|
|
225
|
+
> .bn-block-content[data-content-type="bulletListItem"]::before {
|
|
221
226
|
margin-right: 1.2em;
|
|
222
227
|
content: "▪";
|
|
223
228
|
}
|
|
224
229
|
|
|
225
230
|
/* IMAGES */
|
|
226
231
|
|
|
227
|
-
[data-content-type="image"] .wrapper {
|
|
232
|
+
[data-content-type="image"] .bn-image-block-content-wrapper {
|
|
228
233
|
display: flex;
|
|
229
234
|
flex-direction: column;
|
|
230
235
|
justify-content: center;
|
|
@@ -232,7 +237,7 @@ NESTED BLOCKS
|
|
|
232
237
|
width: 100%;
|
|
233
238
|
}
|
|
234
239
|
|
|
235
|
-
[data-content-type="image"] .
|
|
240
|
+
[data-content-type="image"] .bn-add-image-button {
|
|
236
241
|
display: flex;
|
|
237
242
|
flex-direction: row;
|
|
238
243
|
align-items: center;
|
|
@@ -244,27 +249,27 @@ NESTED BLOCKS
|
|
|
244
249
|
width: 100%;
|
|
245
250
|
}
|
|
246
251
|
|
|
247
|
-
[data-content-type="image"] .
|
|
252
|
+
[data-content-type="image"] .bn-add-image-button:hover {
|
|
248
253
|
background-color: gainsboro;
|
|
249
254
|
}
|
|
250
255
|
|
|
251
|
-
[data-content-type="image"] .
|
|
256
|
+
[data-content-type="image"] .bn-add-image-button-icon {
|
|
252
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");
|
|
253
258
|
width: 24px;
|
|
254
259
|
height: 24px;
|
|
255
260
|
}
|
|
256
261
|
|
|
257
|
-
[data-content-type="image"] .
|
|
262
|
+
[data-content-type="image"] .bn-add-image-button-text {
|
|
258
263
|
color: black;
|
|
259
264
|
}
|
|
260
265
|
|
|
261
|
-
[data-content-type="image"] .
|
|
266
|
+
[data-content-type="image"] .bn-image-and-caption-wrapper {
|
|
262
267
|
display: flex;
|
|
263
268
|
flex-direction: column;
|
|
264
269
|
border-radius: 4px;
|
|
265
270
|
}
|
|
266
271
|
|
|
267
|
-
[data-content-type="image"] .
|
|
272
|
+
[data-content-type="image"] .bn-image-wrapper {
|
|
268
273
|
display: flex;
|
|
269
274
|
flex-direction: row;
|
|
270
275
|
align-items: center;
|
|
@@ -272,12 +277,12 @@ NESTED BLOCKS
|
|
|
272
277
|
width: fit-content;
|
|
273
278
|
}
|
|
274
279
|
|
|
275
|
-
[data-content-type="image"] .image {
|
|
280
|
+
[data-content-type="image"] .bn-image {
|
|
276
281
|
border-radius: 4px;
|
|
277
282
|
max-width: 100%;
|
|
278
283
|
}
|
|
279
284
|
|
|
280
|
-
[data-content-type="image"] .
|
|
285
|
+
[data-content-type="image"] .bn-image-resize-handle {
|
|
281
286
|
display: none;
|
|
282
287
|
position: absolute;
|
|
283
288
|
width: 8px;
|
|
@@ -294,8 +299,8 @@ NESTED BLOCKS
|
|
|
294
299
|
|
|
295
300
|
/* PLACEHOLDERS*/
|
|
296
301
|
|
|
297
|
-
.
|
|
298
|
-
.
|
|
302
|
+
.bn-is-empty .bn-inline-content:before,
|
|
303
|
+
.bn-is-filter .bn-inline-content:before {
|
|
299
304
|
/*float: left; */
|
|
300
305
|
content: "";
|
|
301
306
|
pointer-events: none;
|
|
@@ -307,25 +312,27 @@ NESTED BLOCKS
|
|
|
307
312
|
|
|
308
313
|
/* TODO: would be nicer if defined from code */
|
|
309
314
|
|
|
310
|
-
.
|
|
315
|
+
.bn-block-content.bn-is-empty.bn-has-anchor .bn-inline-content:before {
|
|
311
316
|
content: "Enter text or type '/' for commands";
|
|
312
317
|
}
|
|
313
318
|
|
|
314
|
-
.
|
|
319
|
+
.bn-block-content.bn-is-filter.bn-has-anchor .bn-inline-content:before {
|
|
315
320
|
content: "Type to filter";
|
|
316
321
|
}
|
|
317
322
|
|
|
318
|
-
.
|
|
323
|
+
.bn-block-content[data-content-type="heading"].bn-is-empty
|
|
324
|
+
.bn-inline-content:before {
|
|
319
325
|
content: "Heading";
|
|
320
326
|
}
|
|
321
327
|
|
|
322
|
-
.
|
|
323
|
-
.
|
|
324
|
-
.
|
|
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 {
|
|
325
332
|
content: "List";
|
|
326
333
|
}
|
|
327
334
|
|
|
328
|
-
.
|
|
335
|
+
.bn-is-empty .bn-block-content[data-content-type="captionedImage"] .bn-inline-content:before {
|
|
329
336
|
content: "Caption";
|
|
330
337
|
}
|
|
331
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
|
});
|