@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
|
@@ -1,45 +1,49 @@
|
|
|
1
1
|
import { Extensions, extensions } from "@tiptap/core";
|
|
2
2
|
|
|
3
|
-
import { BlockNoteEditor } from "./BlockNoteEditor";
|
|
3
|
+
import type { BlockNoteEditor } from "./BlockNoteEditor";
|
|
4
4
|
|
|
5
|
-
import { Bold } from "@tiptap/extension-bold";
|
|
6
|
-
import { Code } from "@tiptap/extension-code";
|
|
7
5
|
import Collaboration from "@tiptap/extension-collaboration";
|
|
8
6
|
import CollaborationCursor from "@tiptap/extension-collaboration-cursor";
|
|
9
7
|
import { Dropcursor } from "@tiptap/extension-dropcursor";
|
|
10
8
|
import { Gapcursor } from "@tiptap/extension-gapcursor";
|
|
11
9
|
import { HardBreak } from "@tiptap/extension-hard-break";
|
|
12
10
|
import { History } from "@tiptap/extension-history";
|
|
13
|
-
import { Italic } from "@tiptap/extension-italic";
|
|
14
11
|
import { Link } from "@tiptap/extension-link";
|
|
15
|
-
import { Strike } from "@tiptap/extension-strike";
|
|
16
12
|
import { Text } from "@tiptap/extension-text";
|
|
17
|
-
import { Underline } from "@tiptap/extension-underline";
|
|
18
13
|
import * as Y from "yjs";
|
|
19
|
-
import
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
14
|
+
import { createCopyToClipboardExtension } from "../api/exporters/copyExtension";
|
|
15
|
+
import { createPasteFromClipboardExtension } from "../api/parsers/pasteExtension";
|
|
16
|
+
import { BackgroundColorExtension } from "../extensions/BackgroundColor/BackgroundColorExtension";
|
|
17
|
+
import { Placeholder } from "../extensions/Placeholder/PlaceholderExtension";
|
|
18
|
+
import { TextAlignmentExtension } from "../extensions/TextAlignment/TextAlignmentExtension";
|
|
19
|
+
import { TextColorExtension } from "../extensions/TextColor/TextColorExtension";
|
|
20
|
+
import { TrailingNode } from "../extensions/TrailingNode/TrailingNodeExtension";
|
|
21
|
+
import UniqueID from "../extensions/UniqueID/UniqueID";
|
|
22
|
+
import { BlockContainer, BlockGroup, Doc } from "../pm-nodes";
|
|
23
23
|
import {
|
|
24
24
|
BlockNoteDOMAttributes,
|
|
25
25
|
BlockSchema,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
import { TextColorMark } from "./extensions/TextColor/TextColorMark";
|
|
33
|
-
import { TrailingNode } from "./extensions/TrailingNode/TrailingNodeExtension";
|
|
34
|
-
import UniqueID from "./extensions/UniqueID/UniqueID";
|
|
26
|
+
BlockSpecs,
|
|
27
|
+
InlineContentSchema,
|
|
28
|
+
InlineContentSpecs,
|
|
29
|
+
StyleSchema,
|
|
30
|
+
StyleSpecs,
|
|
31
|
+
} from "../schema";
|
|
35
32
|
|
|
36
33
|
/**
|
|
37
34
|
* Get all the Tiptap extensions BlockNote is configured with by default
|
|
38
35
|
*/
|
|
39
|
-
export const getBlockNoteExtensions = <
|
|
40
|
-
|
|
36
|
+
export const getBlockNoteExtensions = <
|
|
37
|
+
BSchema extends BlockSchema,
|
|
38
|
+
I extends InlineContentSchema,
|
|
39
|
+
S extends StyleSchema
|
|
40
|
+
>(opts: {
|
|
41
|
+
editor: BlockNoteEditor<BSchema, I, S>;
|
|
41
42
|
domAttributes: Partial<BlockNoteDOMAttributes>;
|
|
42
43
|
blockSchema: BSchema;
|
|
44
|
+
blockSpecs: BlockSpecs;
|
|
45
|
+
inlineContentSpecs: InlineContentSpecs;
|
|
46
|
+
styleSpecs: StyleSpecs;
|
|
43
47
|
collaboration?: {
|
|
44
48
|
fragment: Y.XmlFragment;
|
|
45
49
|
user: {
|
|
@@ -62,9 +66,6 @@ export const getBlockNoteExtensions = <BSchema extends BlockSchema>(opts: {
|
|
|
62
66
|
|
|
63
67
|
// DropCursor,
|
|
64
68
|
Placeholder.configure({
|
|
65
|
-
emptyNodeClass: blockStyles.isEmpty,
|
|
66
|
-
hasAnchorClass: blockStyles.hasAnchor,
|
|
67
|
-
isFilterClass: blockStyles.isFilter,
|
|
68
69
|
includeChildren: true,
|
|
69
70
|
showOnlyCurrent: false,
|
|
70
71
|
}),
|
|
@@ -78,33 +79,51 @@ export const getBlockNoteExtensions = <BSchema extends BlockSchema>(opts: {
|
|
|
78
79
|
Text,
|
|
79
80
|
|
|
80
81
|
// marks:
|
|
81
|
-
Bold,
|
|
82
|
-
Code,
|
|
83
|
-
Italic,
|
|
84
|
-
Strike,
|
|
85
|
-
Underline,
|
|
86
82
|
Link,
|
|
87
|
-
|
|
83
|
+
...Object.values(opts.styleSpecs).map((styleSpec) => {
|
|
84
|
+
return styleSpec.implementation.mark;
|
|
85
|
+
}),
|
|
86
|
+
|
|
88
87
|
TextColorExtension,
|
|
89
|
-
|
|
88
|
+
|
|
90
89
|
BackgroundColorExtension,
|
|
91
90
|
TextAlignmentExtension,
|
|
92
91
|
|
|
93
92
|
// nodes
|
|
94
93
|
Doc,
|
|
95
94
|
BlockContainer.configure({
|
|
95
|
+
editor: opts.editor as any,
|
|
96
96
|
domAttributes: opts.domAttributes,
|
|
97
97
|
}),
|
|
98
98
|
BlockGroup.configure({
|
|
99
99
|
domAttributes: opts.domAttributes,
|
|
100
100
|
}),
|
|
101
|
-
...Object.values(opts.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
101
|
+
...Object.values(opts.inlineContentSpecs)
|
|
102
|
+
.filter((a) => a.config !== "link" && a.config !== "text")
|
|
103
|
+
.map((inlineContentSpec) => {
|
|
104
|
+
return inlineContentSpec.implementation!.node.configure({
|
|
105
|
+
editor: opts.editor as any,
|
|
106
|
+
});
|
|
107
|
+
}),
|
|
108
|
+
|
|
109
|
+
...Object.values(opts.blockSpecs).flatMap((blockSpec) => {
|
|
110
|
+
return [
|
|
111
|
+
// dependent nodes (e.g.: tablecell / row)
|
|
112
|
+
...(blockSpec.implementation.requiredExtensions || []).map((ext) =>
|
|
113
|
+
ext.configure({
|
|
114
|
+
editor: opts.editor,
|
|
115
|
+
domAttributes: opts.domAttributes,
|
|
116
|
+
})
|
|
117
|
+
),
|
|
118
|
+
// the actual node itself
|
|
119
|
+
blockSpec.implementation.node.configure({
|
|
120
|
+
editor: opts.editor,
|
|
121
|
+
domAttributes: opts.domAttributes,
|
|
122
|
+
}),
|
|
123
|
+
];
|
|
124
|
+
}),
|
|
125
|
+
createCopyToClipboardExtension(opts.editor),
|
|
126
|
+
createPasteFromClipboardExtension(opts.editor),
|
|
108
127
|
|
|
109
128
|
Dropcursor.configure({ width: 5, color: "#ddeeff" }),
|
|
110
129
|
// This needs to be at the bottom of this list, because Key events (such as enter, when selecting a /command),
|
|
@@ -122,12 +141,12 @@ export const getBlockNoteExtensions = <BSchema extends BlockSchema>(opts: {
|
|
|
122
141
|
const defaultRender = (user: { color: string; name: string }) => {
|
|
123
142
|
const cursor = document.createElement("span");
|
|
124
143
|
|
|
125
|
-
cursor.classList.add(
|
|
144
|
+
cursor.classList.add("collaboration-cursor__caret");
|
|
126
145
|
cursor.setAttribute("style", `border-color: ${user.color}`);
|
|
127
146
|
|
|
128
147
|
const label = document.createElement("span");
|
|
129
148
|
|
|
130
|
-
label.classList.add(
|
|
149
|
+
label.classList.add("collaboration-cursor__label");
|
|
131
150
|
label.setAttribute("style", `background-color: ${user.color}`);
|
|
132
151
|
label.insertBefore(document.createTextNode(user.name), null);
|
|
133
152
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Block,
|
|
3
|
+
BlockSchema,
|
|
4
|
+
InlineContentSchema,
|
|
5
|
+
StyleSchema,
|
|
6
|
+
} from "../schema";
|
|
7
|
+
|
|
8
|
+
export type TextCursorPosition<
|
|
9
|
+
BSchema extends BlockSchema,
|
|
10
|
+
I extends InlineContentSchema,
|
|
11
|
+
S extends StyleSchema
|
|
12
|
+
> = {
|
|
13
|
+
block: Block<BSchema, I, S>;
|
|
14
|
+
prevBlock: Block<BSchema, I, S> | undefined;
|
|
15
|
+
nextBlock: Block<BSchema, I, S> | undefined;
|
|
16
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
@import url("
|
|
1
|
+
@import url("../assets/fonts-inter.css");
|
|
2
2
|
|
|
3
|
-
.
|
|
3
|
+
.bn-editor {
|
|
4
4
|
outline: none;
|
|
5
5
|
padding-inline: 54px;
|
|
6
6
|
|
|
@@ -11,31 +11,31 @@
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
/*
|
|
14
|
-
|
|
14
|
+
bn-root should be applied to all top-level elements
|
|
15
15
|
|
|
16
16
|
This includes the Prosemirror editor, but also <div> element such as
|
|
17
17
|
Tippy popups that are appended to document.body directly
|
|
18
18
|
*/
|
|
19
|
-
.
|
|
19
|
+
.bn-root {
|
|
20
20
|
-webkit-box-sizing: border-box;
|
|
21
21
|
-moz-box-sizing: border-box;
|
|
22
22
|
box-sizing: border-box;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
.
|
|
26
|
-
.
|
|
27
|
-
.
|
|
25
|
+
.bn-root *,
|
|
26
|
+
.bn-root *::before,
|
|
27
|
+
.bn-root *::after {
|
|
28
28
|
-webkit-box-sizing: inherit;
|
|
29
29
|
-moz-box-sizing: inherit;
|
|
30
30
|
box-sizing: inherit;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/* reset styles, they will be set on blockContent */
|
|
34
|
-
.
|
|
35
|
-
.
|
|
36
|
-
.
|
|
37
|
-
.
|
|
38
|
-
.
|
|
34
|
+
.bn-default-styles p,
|
|
35
|
+
.bn-default-styles h1,
|
|
36
|
+
.bn-default-styles h2,
|
|
37
|
+
.bn-default-styles h3,
|
|
38
|
+
.bn-default-styles li {
|
|
39
39
|
all: unset;
|
|
40
40
|
margin: 0;
|
|
41
41
|
padding: 0;
|
|
@@ -44,7 +44,7 @@ Tippy popups that are appended to document.body directly
|
|
|
44
44
|
min-width: 2px !important;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
.
|
|
47
|
+
.bn-default-styles {
|
|
48
48
|
font-size: 16px;
|
|
49
49
|
font-weight: normal;
|
|
50
50
|
font-family: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont,
|
|
@@ -54,9 +54,16 @@ Tippy popups that are appended to document.body directly
|
|
|
54
54
|
-moz-osx-font-smoothing: grayscale;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
.
|
|
57
|
+
.bn-table-drop-cursor {
|
|
58
58
|
position: absolute;
|
|
59
|
-
|
|
59
|
+
z-index: 20;
|
|
60
|
+
background-color: #adf;
|
|
61
|
+
pointer-events: none;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.bn-drag-preview {
|
|
65
|
+
position: absolute;
|
|
66
|
+
left: -100000px;
|
|
60
67
|
}
|
|
61
68
|
|
|
62
69
|
/* Give a remote user a caret */
|
|
@@ -85,3 +92,23 @@ Tippy popups that are appended to document.body directly
|
|
|
85
92
|
user-select: none;
|
|
86
93
|
white-space: nowrap;
|
|
87
94
|
}
|
|
95
|
+
|
|
96
|
+
/* table related: */
|
|
97
|
+
.bn-editor table {
|
|
98
|
+
width: auto !important;
|
|
99
|
+
}
|
|
100
|
+
.bn-editor th,
|
|
101
|
+
.bn-editor td {
|
|
102
|
+
min-width: 1em;
|
|
103
|
+
border: 1px solid #ddd;
|
|
104
|
+
padding: 3px 5px;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.bn-editor .tableWrapper {
|
|
108
|
+
margin: 1em 0;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.bn-editor th {
|
|
112
|
+
font-weight: bold;
|
|
113
|
+
text-align: left;
|
|
114
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Block,
|
|
3
|
+
BlockSchema,
|
|
4
|
+
InlineContentSchema,
|
|
5
|
+
StyleSchema,
|
|
6
|
+
} from "../schema";
|
|
7
|
+
|
|
8
|
+
export type Selection<
|
|
9
|
+
BSchema extends BlockSchema,
|
|
10
|
+
I extends InlineContentSchema,
|
|
11
|
+
S extends StyleSchema
|
|
12
|
+
> = {
|
|
13
|
+
blocks: Block<BSchema, I, S>[];
|
|
14
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Fragment, Slice } from "@tiptap/pm/model";
|
|
2
|
+
import { EditorView } from "@tiptap/pm/view";
|
|
3
|
+
|
|
4
|
+
// helper function to remove a child from a fragment
|
|
5
|
+
function removeChild(node: Fragment, n: number) {
|
|
6
|
+
const children: any[] = [];
|
|
7
|
+
node.forEach((child, _, i) => {
|
|
8
|
+
if (i !== n) {
|
|
9
|
+
children.push(child);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
return Fragment.from(children);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* fix for https://github.com/ProseMirror/prosemirror/issues/1430#issuecomment-1822570821
|
|
17
|
+
*
|
|
18
|
+
* Without this fix, pasting two paragraphs would cause the second one to be indented in the other
|
|
19
|
+
* this fix wraps every element in the slice in it's own blockContainer, to prevent Prosemirror from nesting the
|
|
20
|
+
* elements on paste.
|
|
21
|
+
*
|
|
22
|
+
* The exception is when we encounter blockGroups with listitems, because those actually should be nested
|
|
23
|
+
*/
|
|
24
|
+
export function transformPasted(slice: Slice, view: EditorView) {
|
|
25
|
+
let f = Fragment.from(slice.content);
|
|
26
|
+
for (let i = 0; i < f.childCount; i++) {
|
|
27
|
+
if (f.child(i).type.spec.group === "blockContent") {
|
|
28
|
+
const content = [f.child(i)];
|
|
29
|
+
|
|
30
|
+
// when there is a blockGroup with lists, it should be nested in the new blockcontainer
|
|
31
|
+
// (if we remove this if-block, the nesting bug will be fixed, but lists won't be nested correctly)
|
|
32
|
+
if (
|
|
33
|
+
i + 1 < f.childCount &&
|
|
34
|
+
f.child(i + 1).type.spec.group === "blockGroup"
|
|
35
|
+
) {
|
|
36
|
+
const nestedChild = f
|
|
37
|
+
.child(i + 1)
|
|
38
|
+
.child(0)
|
|
39
|
+
.child(0);
|
|
40
|
+
|
|
41
|
+
if (
|
|
42
|
+
nestedChild.type.name === "bulletListItem" ||
|
|
43
|
+
nestedChild.type.name === "numberedListItem"
|
|
44
|
+
) {
|
|
45
|
+
content.push(f.child(i + 1));
|
|
46
|
+
f = removeChild(f, i + 1);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const container = view.state.schema.nodes.blockContainer.create(
|
|
50
|
+
undefined,
|
|
51
|
+
content
|
|
52
|
+
);
|
|
53
|
+
f = f.replaceChild(i, container);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return new Slice(f, slice.openStart, slice.openEnd);
|
|
58
|
+
}
|
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
import { Extension } from "@tiptap/core";
|
|
2
|
-
import {
|
|
3
|
-
import { defaultProps } from "../Blocks/api/defaultProps";
|
|
4
|
-
|
|
5
|
-
declare module "@tiptap/core" {
|
|
6
|
-
interface Commands<ReturnType> {
|
|
7
|
-
blockBackgroundColor: {
|
|
8
|
-
setBlockBackgroundColor: (
|
|
9
|
-
posInBlock: number,
|
|
10
|
-
color: string
|
|
11
|
-
) => ReturnType;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
}
|
|
2
|
+
import { defaultProps } from "../../blocks/defaultProps";
|
|
15
3
|
|
|
16
4
|
export const BackgroundColorExtension = Extension.create({
|
|
17
5
|
name: "blockBackgroundColor",
|
|
@@ -37,27 +25,4 @@ export const BackgroundColorExtension = Extension.create({
|
|
|
37
25
|
},
|
|
38
26
|
];
|
|
39
27
|
},
|
|
40
|
-
|
|
41
|
-
addCommands() {
|
|
42
|
-
return {
|
|
43
|
-
setBlockBackgroundColor:
|
|
44
|
-
(posInBlock, color) =>
|
|
45
|
-
({ state, view }) => {
|
|
46
|
-
const blockInfo = getBlockInfoFromPos(state.doc, posInBlock);
|
|
47
|
-
if (blockInfo === undefined) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
state.tr.setNodeAttribute(
|
|
52
|
-
blockInfo.startPos - 1,
|
|
53
|
-
"backgroundColor",
|
|
54
|
-
color
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
view.focus();
|
|
58
|
-
|
|
59
|
-
return true;
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
},
|
|
63
28
|
});
|
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
import { Mark } from "@tiptap/core";
|
|
2
|
-
import {
|
|
2
|
+
import { createStyleSpecFromTipTapMark } from "../../schema";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
interface Commands<ReturnType> {
|
|
6
|
-
backgroundColor: {
|
|
7
|
-
setBackgroundColor: (color: string) => ReturnType;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const BackgroundColorMark = Mark.create({
|
|
4
|
+
const BackgroundColorMark = Mark.create({
|
|
13
5
|
name: "backgroundColor",
|
|
14
6
|
|
|
15
7
|
addAttributes() {
|
|
16
8
|
return {
|
|
17
|
-
|
|
9
|
+
stringValue: {
|
|
18
10
|
default: undefined,
|
|
19
11
|
parseHTML: (element) => element.getAttribute("data-background-color"),
|
|
20
12
|
renderHTML: (attributes) => ({
|
|
21
|
-
"data-background-color": attributes.
|
|
13
|
+
"data-background-color": attributes.stringValue,
|
|
22
14
|
}),
|
|
23
15
|
},
|
|
24
16
|
};
|
|
@@ -34,7 +26,9 @@ export const BackgroundColorMark = Mark.create({
|
|
|
34
26
|
}
|
|
35
27
|
|
|
36
28
|
if (element.hasAttribute("data-background-color")) {
|
|
37
|
-
return {
|
|
29
|
+
return {
|
|
30
|
+
stringValue: element.getAttribute("data-background-color"),
|
|
31
|
+
};
|
|
38
32
|
}
|
|
39
33
|
|
|
40
34
|
return false;
|
|
@@ -46,18 +40,9 @@ export const BackgroundColorMark = Mark.create({
|
|
|
46
40
|
renderHTML({ HTMLAttributes }) {
|
|
47
41
|
return ["span", HTMLAttributes, 0];
|
|
48
42
|
},
|
|
49
|
-
|
|
50
|
-
addCommands() {
|
|
51
|
-
return {
|
|
52
|
-
setBackgroundColor:
|
|
53
|
-
(color) =>
|
|
54
|
-
({ commands }) => {
|
|
55
|
-
if (color !== defaultProps.backgroundColor.default) {
|
|
56
|
-
return commands.setMark(this.name, { color: color });
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return commands.unsetMark(this.name);
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
},
|
|
63
43
|
});
|
|
44
|
+
|
|
45
|
+
export const BackgroundColor = createStyleSpecFromTipTapMark(
|
|
46
|
+
BackgroundColorMark,
|
|
47
|
+
"string"
|
|
48
|
+
);
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { isNodeSelection,
|
|
1
|
+
import { isNodeSelection, posToDOMRect } from "@tiptap/core";
|
|
2
2
|
import { EditorState, Plugin, PluginKey } from "prosemirror-state";
|
|
3
3
|
import { EditorView } from "prosemirror-view";
|
|
4
|
+
|
|
5
|
+
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
4
6
|
import {
|
|
5
7
|
BaseUiElementCallbacks,
|
|
6
8
|
BaseUiElementState,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from "
|
|
10
|
-
import { EventEmitter } from "../../shared/EventEmitter";
|
|
9
|
+
} from "../../extensions-shared/BaseUiElementTypes";
|
|
10
|
+
import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema";
|
|
11
|
+
import { EventEmitter } from "../../util/EventEmitter";
|
|
11
12
|
|
|
12
13
|
export type FormattingToolbarCallbacks = BaseUiElementCallbacks;
|
|
13
14
|
|
|
14
15
|
export type FormattingToolbarState = BaseUiElementState;
|
|
15
16
|
|
|
16
|
-
export class FormattingToolbarView
|
|
17
|
+
export class FormattingToolbarView {
|
|
17
18
|
private formattingToolbarState?: FormattingToolbarState;
|
|
18
19
|
public updateFormattingToolbar: () => void;
|
|
19
20
|
|
|
@@ -26,21 +27,14 @@ export class FormattingToolbarView<BSchema extends BlockSchema> {
|
|
|
26
27
|
state: EditorState;
|
|
27
28
|
from: number;
|
|
28
29
|
to: number;
|
|
29
|
-
}) => boolean = ({
|
|
30
|
-
const { doc, selection } = state;
|
|
31
|
-
const { empty } = selection;
|
|
32
|
-
|
|
33
|
-
// Sometime check for `empty` is not enough.
|
|
34
|
-
// Doubleclick an empty paragraph returns a node size of 2.
|
|
35
|
-
// So we check also for an empty text size.
|
|
36
|
-
const isEmptyTextBlock =
|
|
37
|
-
!doc.textBetween(from, to).length && isTextSelection(state.selection);
|
|
38
|
-
|
|
39
|
-
return !(!view.hasFocus() || empty || isEmptyTextBlock);
|
|
40
|
-
};
|
|
30
|
+
}) => boolean = ({ state }) => !state.selection.empty;
|
|
41
31
|
|
|
42
32
|
constructor(
|
|
43
|
-
private readonly editor: BlockNoteEditor<
|
|
33
|
+
private readonly editor: BlockNoteEditor<
|
|
34
|
+
BlockSchema,
|
|
35
|
+
InlineContentSchema,
|
|
36
|
+
StyleSchema
|
|
37
|
+
>,
|
|
44
38
|
private readonly pmView: EditorView,
|
|
45
39
|
updateFormattingToolbar: (
|
|
46
40
|
formattingToolbarState: FormattingToolbarState
|
|
@@ -216,13 +210,11 @@ export const formattingToolbarPluginKey = new PluginKey(
|
|
|
216
210
|
"FormattingToolbarPlugin"
|
|
217
211
|
);
|
|
218
212
|
|
|
219
|
-
export class FormattingToolbarProsemirrorPlugin<
|
|
220
|
-
|
|
221
|
-
> extends EventEmitter<any> {
|
|
222
|
-
private view: FormattingToolbarView<BSchema> | undefined;
|
|
213
|
+
export class FormattingToolbarProsemirrorPlugin extends EventEmitter<any> {
|
|
214
|
+
private view: FormattingToolbarView | undefined;
|
|
223
215
|
public readonly plugin: Plugin;
|
|
224
216
|
|
|
225
|
-
constructor(editor: BlockNoteEditor<
|
|
217
|
+
constructor(editor: BlockNoteEditor<any, any, any>) {
|
|
226
218
|
super();
|
|
227
219
|
this.plugin = new Plugin({
|
|
228
220
|
key: formattingToolbarPluginKey,
|
|
@@ -2,10 +2,10 @@ import { getMarkRange, posToDOMRect, Range } from "@tiptap/core";
|
|
|
2
2
|
import { EditorView } from "@tiptap/pm/view";
|
|
3
3
|
import { Mark } from "prosemirror-model";
|
|
4
4
|
import { Plugin, PluginKey } from "prosemirror-state";
|
|
5
|
-
import { BlockNoteEditor } from "../../BlockNoteEditor";
|
|
6
|
-
import { BaseUiElementState } from "../../shared/BaseUiElementTypes";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
5
|
+
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
6
|
+
import { BaseUiElementState } from "../../extensions-shared/BaseUiElementTypes";
|
|
7
|
+
import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema";
|
|
8
|
+
import { EventEmitter } from "../../util/EventEmitter";
|
|
9
9
|
|
|
10
10
|
export type HyperlinkToolbarState = BaseUiElementState & {
|
|
11
11
|
// The hovered hyperlink's URL, and the text it's displayed with in the
|
|
@@ -14,11 +14,11 @@ export type HyperlinkToolbarState = BaseUiElementState & {
|
|
|
14
14
|
text: string;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
class HyperlinkToolbarView
|
|
17
|
+
class HyperlinkToolbarView {
|
|
18
18
|
private hyperlinkToolbarState?: HyperlinkToolbarState;
|
|
19
19
|
public updateHyperlinkToolbar: () => void;
|
|
20
20
|
|
|
21
|
-
menuUpdateTimer:
|
|
21
|
+
menuUpdateTimer: ReturnType<typeof setTimeout> | undefined;
|
|
22
22
|
startMenuUpdateTimer: () => void;
|
|
23
23
|
stopMenuUpdateTimer: () => void;
|
|
24
24
|
|
|
@@ -32,7 +32,7 @@ class HyperlinkToolbarView<BSchema extends BlockSchema> {
|
|
|
32
32
|
hyperlinkMarkRange: Range | undefined;
|
|
33
33
|
|
|
34
34
|
constructor(
|
|
35
|
-
private readonly editor: BlockNoteEditor<
|
|
35
|
+
private readonly editor: BlockNoteEditor<any, any, any>,
|
|
36
36
|
private readonly pmView: EditorView,
|
|
37
37
|
updateHyperlinkToolbar: (
|
|
38
38
|
hyperlinkToolbarState: HyperlinkToolbarState
|
|
@@ -275,12 +275,14 @@ export const hyperlinkToolbarPluginKey = new PluginKey(
|
|
|
275
275
|
);
|
|
276
276
|
|
|
277
277
|
export class HyperlinkToolbarProsemirrorPlugin<
|
|
278
|
-
BSchema extends BlockSchema
|
|
278
|
+
BSchema extends BlockSchema,
|
|
279
|
+
I extends InlineContentSchema,
|
|
280
|
+
S extends StyleSchema
|
|
279
281
|
> extends EventEmitter<any> {
|
|
280
|
-
private view: HyperlinkToolbarView
|
|
282
|
+
private view: HyperlinkToolbarView | undefined;
|
|
281
283
|
public readonly plugin: Plugin;
|
|
282
284
|
|
|
283
|
-
constructor(editor: BlockNoteEditor<BSchema>) {
|
|
285
|
+
constructor(editor: BlockNoteEditor<BSchema, I, S>) {
|
|
284
286
|
super();
|
|
285
287
|
this.plugin = new Plugin({
|
|
286
288
|
key: hyperlinkToolbarPluginKey,
|