@blocknote/core 0.15.11 → 0.17.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 +3349 -2773
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +6 -6
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +5 -2
- package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +3087 -0
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +132 -0
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +71 -0
- package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +2276 -0
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +131 -0
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +103 -0
- package/src/api/blockManipulation/commands/moveBlock/__snapshots__/moveBlock.test.ts.snap +3767 -0
- package/src/api/blockManipulation/commands/moveBlock/moveBlock.test.ts +192 -0
- package/src/api/blockManipulation/commands/moveBlock/moveBlock.ts +178 -0
- package/src/api/blockManipulation/commands/removeBlocks/__snapshots__/removeBlocks.test.ts.snap +1136 -0
- package/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.ts +34 -0
- package/src/api/blockManipulation/commands/removeBlocks/removeBlocks.ts +100 -0
- package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +4931 -0
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +222 -0
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +70 -0
- package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +2924 -0
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +136 -0
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +48 -0
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +8376 -0
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +300 -0
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +199 -0
- package/src/api/blockManipulation/insertContentAt.ts +96 -0
- package/src/api/blockManipulation/selections/textCursorPosition/__snapshots__/textCursorPosition.test.ts.snap +316 -0
- package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.ts +53 -0
- package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.ts +130 -0
- package/src/api/blockManipulation/setupTestEnv.ts +179 -0
- package/src/api/clipboard/__snapshots__/childToParent.html +1 -0
- package/src/api/clipboard/__snapshots__/childrenToNextParent.html +1 -0
- package/src/api/clipboard/__snapshots__/childrenToNextParentsChildren.html +1 -0
- package/src/api/clipboard/__snapshots__/image.html +1 -0
- package/src/api/clipboard/__snapshots__/multipleStyledText.html +1 -0
- package/src/api/clipboard/__snapshots__/nestedImage.html +1 -0
- package/src/api/clipboard/__snapshots__/partialChildToParent.html +1 -0
- package/src/api/clipboard/__snapshots__/styledText.html +1 -0
- package/src/api/clipboard/__snapshots__/tableAllCells.html +1 -0
- package/src/api/clipboard/__snapshots__/tableCell.html +1 -0
- package/src/api/clipboard/__snapshots__/tableCellText.html +1 -0
- package/src/api/clipboard/__snapshots__/tableRow.html +1 -0
- package/src/api/clipboard/__snapshots__/unstyledText.html +1 -0
- package/src/api/clipboard/clipboard.test.ts +283 -0
- package/src/api/{parsers → clipboard/fromClipboard}/fileDropExtension.ts +8 -4
- package/src/api/{parsers → clipboard/fromClipboard}/handleFileInsertion.ts +12 -7
- package/src/api/{parsers → clipboard/fromClipboard}/pasteExtension.ts +19 -8
- package/src/api/clipboard/toClipboard/copyExtension.ts +243 -0
- package/src/api/exporters/html/__snapshots__/complex/misc/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/lists/basic/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/lists/nested/external.html +1 -1
- package/src/api/exporters/html/externalHTMLExporter.ts +42 -87
- package/src/api/exporters/html/htmlConversion.test.ts +19 -156
- package/src/api/exporters/html/internalHTMLSerializer.ts +21 -69
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +263 -0
- package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +158 -0
- package/src/api/exporters/markdown/markdownExporter.test.ts +10 -10
- package/src/api/exporters/markdown/markdownExporter.ts +11 -7
- package/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.ts +2 -2
- package/src/api/getBlockInfoFromPos.ts +172 -90
- package/src/api/nodeConversions/blockToNode.ts +257 -0
- package/src/api/nodeConversions/fragmentToBlocks.ts +60 -0
- package/src/api/nodeConversions/nodeConversions.test.ts +9 -8
- package/src/api/nodeConversions/{nodeConversions.ts → nodeToBlock.ts} +20 -262
- package/src/api/parsers/html/parseHTML.test.ts +5 -8
- package/src/api/parsers/html/parseHTML.ts +8 -4
- package/src/api/parsers/html/util/nestedLists.test.ts +2 -2
- package/src/api/parsers/markdown/__snapshots__/pasted/complex.json +319 -0
- package/src/api/parsers/markdown/__snapshots__/pasted/issue-226-1.json +81 -0
- package/src/api/parsers/{html/__snapshots__/paste/parse-deep-nested-content.json → markdown/__snapshots__/pasted/issue-226-2.json} +35 -110
- package/src/api/parsers/markdown/__snapshots__/pasted/nested.json +81 -0
- package/src/api/parsers/markdown/__snapshots__/pasted/non-nested.json +81 -0
- package/src/api/parsers/markdown/__snapshots__/pasted/styled.json +61 -0
- package/src/api/parsers/markdown/parseMarkdown.test.ts +16 -1
- package/src/api/parsers/markdown/parseMarkdown.ts +8 -4
- package/src/api/testUtil/cases/customBlocks.ts +11 -11
- package/src/api/testUtil/cases/customInlineContent.ts +6 -6
- package/src/api/testUtil/cases/customStyles.ts +6 -6
- package/src/api/testUtil/cases/defaultSchema.ts +4 -4
- package/src/api/testUtil/index.ts +6 -6
- package/src/api/testUtil/partialBlockTestUtil.ts +5 -5
- package/src/api/testUtil/paste.ts +46 -0
- package/src/blocks/AudioBlockContent/AudioBlockContent.ts +5 -5
- package/src/blocks/FileBlockContent/FileBlockContent.ts +4 -4
- package/src/blocks/FileBlockContent/fileBlockHelpers.ts +2 -2
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +61 -39
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +5 -5
- package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +30 -18
- package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +67 -33
- package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +23 -19
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +22 -24
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +31 -19
- package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +16 -11
- package/src/blocks/TableBlockContent/TableBlockContent.ts +4 -5
- package/src/blocks/VideoBlockContent/VideoBlockContent.ts +5 -5
- package/src/blocks/defaultBlockHelpers.ts +4 -4
- package/src/blocks/defaultBlockTypeGuards.ts +5 -5
- package/src/blocks/defaultBlocks.ts +13 -13
- package/src/blocks/defaultProps.ts +1 -1
- package/src/editor/BlockNoteEditor.test.ts +14 -7
- package/src/editor/BlockNoteEditor.ts +82 -149
- package/src/editor/BlockNoteExtensions.ts +15 -11
- package/src/editor/BlockNoteSchema.ts +7 -7
- package/src/editor/BlockNoteTipTapEditor.ts +5 -3
- package/src/editor/cursorPositionTypes.ts +7 -2
- package/src/editor/selectionTypes.ts +6 -2
- package/src/editor/transformPasted.ts +34 -2
- package/src/extensions/BackgroundColor/BackgroundColorExtension.ts +1 -1
- package/src/extensions/BackgroundColor/BackgroundColorMark.ts +1 -1
- package/src/extensions/FilePanel/FilePanelPlugin.ts +4 -4
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +8 -4
- package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +333 -0
- package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +9 -4
- package/src/extensions/{NonEditableBlocks/NonEditableBlockPlugin.ts → NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.ts} +2 -2
- package/src/extensions/Placeholder/PlaceholderPlugin.ts +1 -1
- package/src/extensions/SideMenu/SideMenuPlugin.ts +72 -402
- package/src/extensions/SideMenu/dragging.ts +251 -0
- package/src/extensions/SuggestionMenu/DefaultSuggestionItem.ts +1 -1
- package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +8 -4
- package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +8 -4
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +19 -15
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +11 -7
- package/src/extensions/TextColor/TextColorExtension.ts +1 -1
- package/src/extensions/TextColor/TextColorMark.ts +1 -1
- package/src/i18n/dictionary.ts +1 -1
- package/src/i18n/locales/ar.ts +1 -1
- package/src/i18n/locales/fr.ts +1 -1
- package/src/i18n/locales/hr.ts +308 -0
- package/src/i18n/locales/index.ts +15 -14
- package/src/i18n/locales/is.ts +1 -1
- package/src/i18n/locales/ja.ts +1 -1
- package/src/i18n/locales/ko.ts +1 -1
- package/src/i18n/locales/nl.ts +1 -1
- package/src/i18n/locales/pl.ts +1 -1
- package/src/i18n/locales/pt.ts +1 -1
- package/src/i18n/locales/ru.ts +1 -1
- package/src/i18n/locales/vi.ts +1 -1
- package/src/i18n/locales/zh.ts +1 -1
- package/src/index.ts +45 -44
- package/src/pm-nodes/BlockContainer.ts +3 -647
- package/src/pm-nodes/BlockGroup.ts +2 -2
- package/src/pm-nodes/index.ts +3 -3
- package/src/schema/blocks/createSpec.ts +24 -14
- package/src/schema/blocks/internal.ts +9 -9
- package/src/schema/blocks/types.ts +4 -4
- package/src/schema/index.ts +10 -10
- package/src/schema/inlineContent/createSpec.ts +9 -10
- package/src/schema/inlineContent/internal.ts +3 -3
- package/src/schema/inlineContent/types.ts +2 -2
- package/src/schema/styles/createSpec.ts +4 -3
- package/src/schema/styles/internal.ts +1 -1
- package/types/src/api/blockManipulation/commands/insertBlocks/insertBlocks.d.ts +4 -0
- package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.d.ts +7 -0
- package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.d.ts +1 -0
- package/types/src/api/blockManipulation/commands/moveBlock/moveBlock.d.ts +5 -0
- package/types/src/api/blockManipulation/commands/moveBlock/moveBlock.test.d.ts +1 -0
- package/types/src/api/blockManipulation/commands/removeBlocks/removeBlocks.d.ts +7 -0
- package/types/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.d.ts +1 -0
- package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.d.ts +7 -0
- package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.d.ts +1 -0
- package/types/src/api/blockManipulation/commands/splitBlock/splitBlock.d.ts +5 -0
- package/types/src/api/blockManipulation/commands/splitBlock/splitBlock.test.d.ts +1 -0
- package/types/src/api/blockManipulation/commands/updateBlock/updateBlock.d.ts +11 -0
- package/types/src/api/blockManipulation/commands/updateBlock/updateBlock.test.d.ts +1 -0
- package/types/src/api/blockManipulation/insertContentAt.d.ts +6 -0
- package/types/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.d.ts +5 -0
- package/types/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.d.ts +1 -0
- package/types/src/api/blockManipulation/setupTestEnv.d.ts +492 -0
- package/types/src/api/clipboard/clipboard.test.d.ts +1 -0
- package/types/src/api/clipboard/fromClipboard/fileDropExtension.d.ts +6 -0
- package/types/src/api/{parsers → clipboard/fromClipboard}/handleFileInsertion.d.ts +2 -2
- package/types/src/api/clipboard/fromClipboard/pasteExtension.d.ts +6 -0
- package/types/src/api/clipboard/toClipboard/copyExtension.d.ts +12 -0
- package/types/src/api/exporters/html/externalHTMLExporter.d.ts +7 -8
- package/types/src/api/exporters/html/internalHTMLSerializer.d.ts +6 -10
- package/types/src/api/exporters/html/util/serializeBlocksExternalHTML.d.ts +10 -0
- package/types/src/api/exporters/html/util/serializeBlocksInternalHTML.d.ts +11 -0
- package/types/src/api/exporters/markdown/markdownExporter.d.ts +3 -3
- package/types/src/api/getBlockInfoFromPos.d.ts +63 -20
- package/types/src/api/nodeConversions/blockToNode.d.ts +15 -0
- package/types/src/api/nodeConversions/fragmentToBlocks.d.ts +7 -0
- package/types/src/api/nodeConversions/nodeToBlock.d.ts +16 -0
- package/types/src/api/parsers/html/parseHTML.d.ts +2 -2
- package/types/src/api/parsers/markdown/parseMarkdown.d.ts +2 -2
- package/types/src/api/testUtil/cases/customBlocks.d.ts +39 -39
- package/types/src/api/testUtil/cases/customInlineContent.d.ts +35 -35
- package/types/src/api/testUtil/cases/customStyles.d.ts +35 -35
- package/types/src/api/testUtil/cases/defaultSchema.d.ts +2 -2
- package/types/src/api/testUtil/index.d.ts +6 -6
- package/types/src/api/testUtil/partialBlockTestUtil.d.ts +4 -4
- package/types/src/api/testUtil/paste.d.ts +2 -0
- package/types/src/blocks/AudioBlockContent/AudioBlockContent.d.ts +4 -4
- package/types/src/blocks/FileBlockContent/FileBlockContent.d.ts +4 -4
- package/types/src/blocks/FileBlockContent/fileBlockHelpers.d.ts +2 -2
- package/types/src/blocks/HeadingBlockContent/HeadingBlockContent.d.ts +2 -2
- package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +4 -4
- package/types/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.d.ts +2 -2
- package/types/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.d.ts +2 -2
- package/types/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.d.ts +2 -2
- package/types/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +2 -2
- package/types/src/blocks/ParagraphBlockContent/ParagraphBlockContent.d.ts +2 -2
- package/types/src/blocks/TableBlockContent/TableBlockContent.d.ts +2 -2
- package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +4 -4
- package/types/src/blocks/defaultBlockHelpers.d.ts +3 -3
- package/types/src/blocks/defaultBlockTypeGuards.d.ts +4 -4
- package/types/src/blocks/defaultBlocks.d.ts +38 -38
- package/types/src/blocks/defaultProps.d.ts +1 -1
- package/types/src/editor/BlockNoteEditor.d.ts +28 -16
- package/types/src/editor/BlockNoteExtensions.d.ts +3 -3
- package/types/src/editor/BlockNoteSchema.d.ts +4 -4
- package/types/src/editor/BlockNoteTipTapEditor.d.ts +2 -2
- package/types/src/editor/cursorPositionTypes.d.ts +3 -2
- package/types/src/editor/selectionTypes.d.ts +2 -2
- package/types/src/editor/transformPasted.d.ts +8 -1
- package/types/src/extensions/BackgroundColor/BackgroundColorMark.d.ts +1 -1
- package/types/src/extensions/FilePanel/FilePanelPlugin.d.ts +4 -4
- package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +4 -4
- package/types/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.d.ts +5 -0
- package/types/src/extensions/LinkToolbar/LinkToolbarPlugin.d.ts +4 -4
- package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.d.ts +2 -0
- package/types/src/extensions/Placeholder/PlaceholderPlugin.d.ts +1 -1
- package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +12 -28
- package/types/src/extensions/SideMenu/dragging.d.ts +17 -0
- package/types/src/extensions/SuggestionMenu/DefaultSuggestionItem.d.ts +1 -1
- package/types/src/extensions/SuggestionMenu/SuggestionPlugin.d.ts +4 -4
- package/types/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.d.ts +3 -3
- package/types/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.d.ts +4 -4
- package/types/src/extensions/TableHandles/TableHandlesPlugin.d.ts +4 -4
- package/types/src/extensions/TextColor/TextColorMark.d.ts +1 -1
- package/types/src/i18n/dictionary.d.ts +1 -1
- package/types/src/i18n/locales/ar.d.ts +1 -1
- package/types/src/i18n/locales/fr.d.ts +1 -1
- package/types/src/i18n/locales/hr.d.ts +239 -0
- package/types/src/i18n/locales/index.d.ts +15 -14
- package/types/src/i18n/locales/is.d.ts +1 -1
- package/types/src/i18n/locales/ja.d.ts +1 -1
- package/types/src/i18n/locales/ko.d.ts +1 -1
- package/types/src/i18n/locales/nl.d.ts +1 -1
- package/types/src/i18n/locales/pl.d.ts +1 -1
- package/types/src/i18n/locales/pt.d.ts +1 -1
- package/types/src/i18n/locales/ru.d.ts +1 -1
- package/types/src/i18n/locales/vi.d.ts +1 -1
- package/types/src/i18n/locales/zh.d.ts +1 -1
- package/types/src/index.d.ts +45 -44
- package/types/src/pm-nodes/BlockContainer.d.ts +2 -16
- package/types/src/pm-nodes/BlockGroup.d.ts +1 -1
- package/types/src/pm-nodes/index.d.ts +3 -3
- package/types/src/schema/blocks/createSpec.d.ts +5 -5
- package/types/src/schema/blocks/internal.d.ts +5 -5
- package/types/src/schema/blocks/types.d.ts +4 -4
- package/types/src/schema/index.d.ts +10 -10
- package/types/src/schema/inlineContent/createSpec.d.ts +3 -3
- package/types/src/schema/inlineContent/internal.d.ts +2 -2
- package/types/src/schema/inlineContent/types.d.ts +2 -2
- package/types/src/schema/styles/createSpec.d.ts +1 -1
- package/types/src/schema/styles/internal.d.ts +1 -1
- package/src/api/blockManipulation/__snapshots__/blockManipulation.test.ts.snap +0 -714
- package/src/api/blockManipulation/blockManipulation.test.ts +0 -292
- package/src/api/blockManipulation/blockManipulation.ts +0 -350
- package/src/api/exporters/copyExtension.ts +0 -164
- package/src/api/exporters/html/__snapshots_fragment_edge_cases__/selectionLeavesBlockChildren.html +0 -1
- package/src/api/exporters/html/__snapshots_fragment_edge_cases__/selectionSpansBlocksChildren.html +0 -1
- package/src/api/exporters/html/util/sharedHTMLConversion.ts +0 -130
- package/src/api/exporters/html/util/simplifyBlocksRehypePlugin.ts +0 -218
- package/src/api/getCurrentBlockContentType.ts +0 -14
- package/src/api/parsers/html/__snapshots__/paste/parse-google-docs-html.json +0 -476
- package/types/src/api/blockManipulation/blockManipulation.d.ts +0 -14
- package/types/src/api/exporters/copyExtension.d.ts +0 -6
- package/types/src/api/exporters/html/util/sharedHTMLConversion.d.ts +0 -9
- package/types/src/api/exporters/html/util/simplifyBlocksRehypePlugin.d.ts +0 -16
- package/types/src/api/getCurrentBlockContentType.d.ts +0 -2
- package/types/src/api/nodeConversions/nodeConversions.d.ts +0 -24
- package/types/src/api/parsers/fileDropExtension.d.ts +0 -6
- package/types/src/api/parsers/pasteExtension.d.ts +0 -6
- package/types/src/extensions/NonEditableBlocks/NonEditableBlockPlugin.d.ts +0 -2
- /package/src/api/{exporters/html/__snapshots_fragment_edge_cases__/selectionWithinBlockChildren.html → clipboard/__snapshots__/multipleChildren.html} +0 -0
- /package/src/api/{parsers → clipboard/fromClipboard}/acceptedMIMETypes.ts +0 -0
- /package/src/api/parsers/html/__snapshots__/{paste/list-test.json → list-test.json} +0 -0
- /package/src/api/parsers/html/__snapshots__/{paste/parse-basic-block-types.json → parse-basic-block-types.json} +0 -0
- /package/src/api/parsers/html/__snapshots__/{paste/parse-div-with-inline-content.json → parse-div-with-inline-content.json} +0 -0
- /package/src/api/parsers/html/__snapshots__/{paste/parse-divs.json → parse-divs.json} +0 -0
- /package/src/api/parsers/html/__snapshots__/{paste/parse-fake-image-caption.json → parse-fake-image-caption.json} +0 -0
- /package/src/api/parsers/html/__snapshots__/{paste/parse-image-in-paragraph.json → parse-image-in-paragraph.json} +0 -0
- /package/src/api/parsers/html/__snapshots__/{paste/parse-mixed-nested-lists.json → parse-mixed-nested-lists.json} +0 -0
- /package/src/api/parsers/html/__snapshots__/{paste/parse-nested-lists-with-paragraphs.json → parse-nested-lists-with-paragraphs.json} +0 -0
- /package/src/api/parsers/html/__snapshots__/{paste/parse-nested-lists.json → parse-nested-lists.json} +0 -0
- /package/src/api/parsers/html/__snapshots__/{paste/parse-notion-html.json → parse-notion-html.json} +0 -0
- /package/src/api/parsers/html/__snapshots__/{paste/parse-two-divs.json → parse-two-divs.json} +0 -0
- /package/types/src/api/blockManipulation/{blockManipulation.test.d.ts → commands/insertBlocks/insertBlocks.test.d.ts} +0 -0
- /package/types/src/api/{parsers → clipboard/fromClipboard}/acceptedMIMETypes.d.ts +0 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "5",
|
|
4
|
+
"type": "paragraph",
|
|
5
|
+
"props": {
|
|
6
|
+
"textColor": "default",
|
|
7
|
+
"backgroundColor": "default",
|
|
8
|
+
"textAlignment": "left"
|
|
9
|
+
},
|
|
10
|
+
"content": [
|
|
11
|
+
{
|
|
12
|
+
"type": "text",
|
|
13
|
+
"text": "# Heading",
|
|
14
|
+
"styles": {}
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"children": []
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"id": "6",
|
|
21
|
+
"type": "paragraph",
|
|
22
|
+
"props": {
|
|
23
|
+
"textColor": "default",
|
|
24
|
+
"backgroundColor": "default",
|
|
25
|
+
"textAlignment": "left"
|
|
26
|
+
},
|
|
27
|
+
"content": [
|
|
28
|
+
{
|
|
29
|
+
"type": "text",
|
|
30
|
+
"text": "Paragraph",
|
|
31
|
+
"styles": {}
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"children": []
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"id": "7",
|
|
38
|
+
"type": "paragraph",
|
|
39
|
+
"props": {
|
|
40
|
+
"textColor": "default",
|
|
41
|
+
"backgroundColor": "default",
|
|
42
|
+
"textAlignment": "left"
|
|
43
|
+
},
|
|
44
|
+
"content": [
|
|
45
|
+
{
|
|
46
|
+
"type": "text",
|
|
47
|
+
"text": "* Bullet List Item",
|
|
48
|
+
"styles": {}
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"children": []
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"id": "8",
|
|
55
|
+
"type": "paragraph",
|
|
56
|
+
"props": {
|
|
57
|
+
"textColor": "default",
|
|
58
|
+
"backgroundColor": "default",
|
|
59
|
+
"textAlignment": "left"
|
|
60
|
+
},
|
|
61
|
+
"content": [
|
|
62
|
+
{
|
|
63
|
+
"type": "text",
|
|
64
|
+
"text": " 1. Numbered List Item",
|
|
65
|
+
"styles": {}
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"children": []
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"id": "9",
|
|
72
|
+
"type": "paragraph",
|
|
73
|
+
"props": {
|
|
74
|
+
"textColor": "default",
|
|
75
|
+
"backgroundColor": "default",
|
|
76
|
+
"textAlignment": "left"
|
|
77
|
+
},
|
|
78
|
+
"content": [],
|
|
79
|
+
"children": []
|
|
80
|
+
}
|
|
81
|
+
]
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "5",
|
|
4
|
+
"type": "paragraph",
|
|
5
|
+
"props": {
|
|
6
|
+
"textColor": "default",
|
|
7
|
+
"backgroundColor": "default",
|
|
8
|
+
"textAlignment": "left"
|
|
9
|
+
},
|
|
10
|
+
"content": [
|
|
11
|
+
{
|
|
12
|
+
"type": "text",
|
|
13
|
+
"text": "# Heading",
|
|
14
|
+
"styles": {}
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"children": []
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"id": "6",
|
|
21
|
+
"type": "paragraph",
|
|
22
|
+
"props": {
|
|
23
|
+
"textColor": "default",
|
|
24
|
+
"backgroundColor": "default",
|
|
25
|
+
"textAlignment": "left"
|
|
26
|
+
},
|
|
27
|
+
"content": [
|
|
28
|
+
{
|
|
29
|
+
"type": "text",
|
|
30
|
+
"text": "Paragraph",
|
|
31
|
+
"styles": {}
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"children": []
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"id": "7",
|
|
38
|
+
"type": "paragraph",
|
|
39
|
+
"props": {
|
|
40
|
+
"textColor": "default",
|
|
41
|
+
"backgroundColor": "default",
|
|
42
|
+
"textAlignment": "left"
|
|
43
|
+
},
|
|
44
|
+
"content": [
|
|
45
|
+
{
|
|
46
|
+
"type": "text",
|
|
47
|
+
"text": "* Bullet List Item",
|
|
48
|
+
"styles": {}
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"children": []
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"id": "8",
|
|
55
|
+
"type": "paragraph",
|
|
56
|
+
"props": {
|
|
57
|
+
"textColor": "default",
|
|
58
|
+
"backgroundColor": "default",
|
|
59
|
+
"textAlignment": "left"
|
|
60
|
+
},
|
|
61
|
+
"content": [
|
|
62
|
+
{
|
|
63
|
+
"type": "text",
|
|
64
|
+
"text": "1. Numbered List Item",
|
|
65
|
+
"styles": {}
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"children": []
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"id": "9",
|
|
72
|
+
"type": "paragraph",
|
|
73
|
+
"props": {
|
|
74
|
+
"textColor": "default",
|
|
75
|
+
"backgroundColor": "default",
|
|
76
|
+
"textAlignment": "left"
|
|
77
|
+
},
|
|
78
|
+
"content": [],
|
|
79
|
+
"children": []
|
|
80
|
+
}
|
|
81
|
+
]
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "2",
|
|
4
|
+
"type": "paragraph",
|
|
5
|
+
"props": {
|
|
6
|
+
"textColor": "default",
|
|
7
|
+
"backgroundColor": "default",
|
|
8
|
+
"textAlignment": "left"
|
|
9
|
+
},
|
|
10
|
+
"content": [
|
|
11
|
+
{
|
|
12
|
+
"type": "text",
|
|
13
|
+
"text": "Bold",
|
|
14
|
+
"styles": {
|
|
15
|
+
"bold": true
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"type": "text",
|
|
20
|
+
"text": " ",
|
|
21
|
+
"styles": {}
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"type": "text",
|
|
25
|
+
"text": "Italic",
|
|
26
|
+
"styles": {
|
|
27
|
+
"italic": true
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"type": "text",
|
|
32
|
+
"text": " ",
|
|
33
|
+
"styles": {}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"type": "text",
|
|
37
|
+
"text": "Strikethrough",
|
|
38
|
+
"styles": {
|
|
39
|
+
"strike": true
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"type": "text",
|
|
44
|
+
"text": " ***Multiple***",
|
|
45
|
+
"styles": {}
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"children": []
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"id": "3",
|
|
52
|
+
"type": "paragraph",
|
|
53
|
+
"props": {
|
|
54
|
+
"textColor": "default",
|
|
55
|
+
"backgroundColor": "default",
|
|
56
|
+
"textAlignment": "left"
|
|
57
|
+
},
|
|
58
|
+
"content": [],
|
|
59
|
+
"children": []
|
|
60
|
+
}
|
|
61
|
+
]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { BlockNoteEditor } from "
|
|
2
|
+
import { BlockNoteEditor } from "../../../index.js";
|
|
3
|
+
import { doPaste } from "../../testUtil/paste.js";
|
|
3
4
|
|
|
4
5
|
async function parseMarkdownAndCompareSnapshots(
|
|
5
6
|
md: string,
|
|
@@ -14,6 +15,20 @@ async function parseMarkdownAndCompareSnapshots(
|
|
|
14
15
|
expect(JSON.stringify(blocks, undefined, 2)).toMatchFileSnapshot(
|
|
15
16
|
snapshotPath
|
|
16
17
|
);
|
|
18
|
+
|
|
19
|
+
doPaste(
|
|
20
|
+
editor._tiptapEditor.view,
|
|
21
|
+
md,
|
|
22
|
+
null,
|
|
23
|
+
true,
|
|
24
|
+
new ClipboardEvent("paste")
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const pastedSnapshotPath = "./__snapshots__/pasted/" + snapshotName + ".json";
|
|
28
|
+
expect(JSON.stringify(editor.document, undefined, 2)).toMatchFileSnapshot(
|
|
29
|
+
pastedSnapshotPath
|
|
30
|
+
);
|
|
31
|
+
|
|
17
32
|
editor.mount(undefined);
|
|
18
33
|
}
|
|
19
34
|
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { Schema } from "prosemirror-model";
|
|
2
2
|
|
|
3
|
-
import { Block } from "../../../blocks/defaultBlocks";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import { Block } from "../../../blocks/defaultBlocks.js";
|
|
4
|
+
import {
|
|
5
|
+
BlockSchema,
|
|
6
|
+
InlineContentSchema,
|
|
7
|
+
StyleSchema,
|
|
8
|
+
} from "../../../schema/index.js";
|
|
9
|
+
import { initializeESMDependencies } from "../../../util/esmDependencies.js";
|
|
10
|
+
import { HTMLToBlocks } from "../html/parseHTML.js";
|
|
7
11
|
|
|
8
12
|
// modified version of https://github.com/syntax-tree/mdast-util-to-hast/blob/main/lib/handlers/code.js
|
|
9
13
|
// that outputs a data-language attribute instead of a CSS class (e.g.: language-typescript)
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { EditorTestCases } from "../index";
|
|
1
|
+
import { EditorTestCases } from "../index.js";
|
|
2
2
|
|
|
3
|
-
import { uploadToTmpFilesDotOrg_DEV_ONLY } from "../../../blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY";
|
|
3
|
+
import { uploadToTmpFilesDotOrg_DEV_ONLY } from "../../../blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js";
|
|
4
|
+
import {
|
|
5
|
+
imagePropSchema,
|
|
6
|
+
imageRender,
|
|
7
|
+
} from "../../../blocks/ImageBlockContent/ImageBlockContent.js";
|
|
4
8
|
import {
|
|
5
9
|
DefaultInlineContentSchema,
|
|
6
10
|
DefaultStyleSchema,
|
|
7
11
|
defaultBlockSpecs,
|
|
8
|
-
} from "../../../blocks/defaultBlocks";
|
|
9
|
-
import { defaultProps } from "../../../blocks/defaultProps";
|
|
10
|
-
import { BlockNoteEditor } from "../../../editor/BlockNoteEditor";
|
|
11
|
-
import { BlockNoteSchema } from "../../../editor/BlockNoteSchema";
|
|
12
|
-
import { createBlockSpec } from "../../../schema";
|
|
13
|
-
import {
|
|
14
|
-
imagePropSchema,
|
|
15
|
-
imageRender,
|
|
16
|
-
} from "../../../blocks/ImageBlockContent/ImageBlockContent";
|
|
12
|
+
} from "../../../blocks/defaultBlocks.js";
|
|
13
|
+
import { defaultProps } from "../../../blocks/defaultProps.js";
|
|
14
|
+
import { BlockNoteEditor } from "../../../editor/BlockNoteEditor.js";
|
|
15
|
+
import { BlockNoteSchema } from "../../../editor/BlockNoteSchema.js";
|
|
16
|
+
import { createBlockSpec } from "../../../schema/index.js";
|
|
17
17
|
|
|
18
18
|
// This is a modified version of the default image block that does not implement
|
|
19
19
|
// a `toExternalHTML` function. It's used to test if the custom serializer by
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { EditorTestCases } from "../index";
|
|
1
|
+
import { EditorTestCases } from "../index.js";
|
|
2
2
|
|
|
3
|
-
import { uploadToTmpFilesDotOrg_DEV_ONLY } from "../../../blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY";
|
|
3
|
+
import { uploadToTmpFilesDotOrg_DEV_ONLY } from "../../../blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js";
|
|
4
4
|
import {
|
|
5
5
|
DefaultBlockSchema,
|
|
6
6
|
DefaultStyleSchema,
|
|
7
7
|
defaultInlineContentSpecs,
|
|
8
|
-
} from "../../../blocks/defaultBlocks";
|
|
9
|
-
import { BlockNoteEditor } from "../../../editor/BlockNoteEditor";
|
|
10
|
-
import { BlockNoteSchema } from "../../../editor/BlockNoteSchema";
|
|
11
|
-
import { createInlineContentSpec } from "../../../schema/inlineContent/createSpec";
|
|
8
|
+
} from "../../../blocks/defaultBlocks.js";
|
|
9
|
+
import { BlockNoteEditor } from "../../../editor/BlockNoteEditor.js";
|
|
10
|
+
import { BlockNoteSchema } from "../../../editor/BlockNoteSchema.js";
|
|
11
|
+
import { createInlineContentSpec } from "../../../schema/inlineContent/createSpec.js";
|
|
12
12
|
|
|
13
13
|
const mention = createInlineContentSpec(
|
|
14
14
|
{
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { EditorTestCases } from "../index";
|
|
1
|
+
import { EditorTestCases } from "../index.js";
|
|
2
2
|
|
|
3
|
-
import { uploadToTmpFilesDotOrg_DEV_ONLY } from "../../../blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY";
|
|
3
|
+
import { uploadToTmpFilesDotOrg_DEV_ONLY } from "../../../blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js";
|
|
4
4
|
import {
|
|
5
5
|
DefaultBlockSchema,
|
|
6
6
|
DefaultInlineContentSchema,
|
|
7
7
|
defaultStyleSpecs,
|
|
8
|
-
} from "../../../blocks/defaultBlocks";
|
|
9
|
-
import { BlockNoteEditor } from "../../../editor/BlockNoteEditor";
|
|
10
|
-
import { BlockNoteSchema } from "../../../editor/BlockNoteSchema";
|
|
11
|
-
import { createStyleSpec } from "../../../schema/styles/createSpec";
|
|
8
|
+
} from "../../../blocks/defaultBlocks.js";
|
|
9
|
+
import { BlockNoteEditor } from "../../../editor/BlockNoteEditor.js";
|
|
10
|
+
import { BlockNoteSchema } from "../../../editor/BlockNoteSchema.js";
|
|
11
|
+
import { createStyleSpec } from "../../../schema/styles/createSpec.js";
|
|
12
12
|
|
|
13
13
|
const small = createStyleSpec(
|
|
14
14
|
{
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { EditorTestCases } from "../index";
|
|
1
|
+
import { EditorTestCases } from "../index.js";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { uploadToTmpFilesDotOrg_DEV_ONLY } from "../../../blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js";
|
|
4
4
|
import {
|
|
5
5
|
DefaultBlockSchema,
|
|
6
6
|
DefaultInlineContentSchema,
|
|
7
7
|
DefaultStyleSchema,
|
|
8
|
-
} from "../../../blocks/defaultBlocks";
|
|
9
|
-
import {
|
|
8
|
+
} from "../../../blocks/defaultBlocks.js";
|
|
9
|
+
import { BlockNoteEditor } from "../../../editor/BlockNoteEditor.js";
|
|
10
10
|
|
|
11
11
|
export const defaultSchemaTestCases: EditorTestCases<
|
|
12
12
|
DefaultBlockSchema,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { PartialBlock } from "../../blocks/defaultBlocks";
|
|
2
|
-
import { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
3
|
-
import { BlockSchema } from "../../schema/blocks/types";
|
|
4
|
-
import { InlineContentSchema } from "../../schema/inlineContent/types";
|
|
5
|
-
import { StyleSchema } from "../../schema/styles/types";
|
|
6
|
-
import { NoInfer } from "../../util/typescript";
|
|
1
|
+
import { PartialBlock } from "../../blocks/defaultBlocks.js";
|
|
2
|
+
import { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
|
|
3
|
+
import { BlockSchema } from "../../schema/blocks/types.js";
|
|
4
|
+
import { InlineContentSchema } from "../../schema/inlineContent/types.js";
|
|
5
|
+
import { StyleSchema } from "../../schema/styles/types.js";
|
|
6
|
+
import { NoInfer } from "../../util/typescript.js";
|
|
7
7
|
|
|
8
8
|
export type EditorTestCases<
|
|
9
9
|
B extends BlockSchema,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Block, PartialBlock } from "../../blocks/defaultBlocks";
|
|
2
|
-
import UniqueID from "../../extensions/UniqueID/UniqueID";
|
|
3
|
-
import { BlockSchema, TableContent } from "../../schema/blocks/types";
|
|
1
|
+
import { Block, PartialBlock } from "../../blocks/defaultBlocks.js";
|
|
2
|
+
import UniqueID from "../../extensions/UniqueID/UniqueID.js";
|
|
3
|
+
import { BlockSchema, TableContent } from "../../schema/blocks/types.js";
|
|
4
4
|
import {
|
|
5
5
|
InlineContent,
|
|
6
6
|
InlineContentSchema,
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
StyledText,
|
|
9
9
|
isPartialLinkInlineContent,
|
|
10
10
|
isStyledTextInlineContent,
|
|
11
|
-
} from "../../schema/inlineContent/types";
|
|
12
|
-
import { StyleSchema } from "../../schema/styles/types";
|
|
11
|
+
} from "../../schema/inlineContent/types.js";
|
|
12
|
+
import { StyleSchema } from "../../schema/styles/types.js";
|
|
13
13
|
|
|
14
14
|
function textShorthandToStyledText(
|
|
15
15
|
content: string | StyledText<any>[] = ""
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Slice } from "@tiptap/pm/model";
|
|
2
|
+
import { EditorView } from "@tiptap/pm/view";
|
|
3
|
+
import * as pmView from "@tiptap/pm/view";
|
|
4
|
+
|
|
5
|
+
function sliceSingleNode(slice: Slice) {
|
|
6
|
+
return slice.openStart === 0 &&
|
|
7
|
+
slice.openEnd === 0 &&
|
|
8
|
+
slice.content.childCount === 1
|
|
9
|
+
? slice.content.firstChild
|
|
10
|
+
: null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// This function is a copy of the `doPaste` function from `@tiptap/pm/view`,
|
|
14
|
+
// but made to work in a JSDOM environment. To do this, the `tr.scrollIntoView`
|
|
15
|
+
// call has been removed.
|
|
16
|
+
// https://github.com/ProseMirror/prosemirror-view/blob/17b508f618c944c54776f8ddac45edcb49970796/src/input.ts#L624
|
|
17
|
+
export function doPaste(
|
|
18
|
+
view: EditorView,
|
|
19
|
+
text: string,
|
|
20
|
+
html: string | null,
|
|
21
|
+
preferPlain: boolean,
|
|
22
|
+
event: ClipboardEvent
|
|
23
|
+
) {
|
|
24
|
+
const slice = (pmView as any).__parseFromClipboard(
|
|
25
|
+
view,
|
|
26
|
+
text,
|
|
27
|
+
html,
|
|
28
|
+
preferPlain,
|
|
29
|
+
view.state.selection.$from
|
|
30
|
+
);
|
|
31
|
+
if (
|
|
32
|
+
view.someProp("handlePaste", (f) => f(view, event, slice || Slice.empty))
|
|
33
|
+
) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
if (!slice) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const singleNode = sliceSingleNode(slice);
|
|
41
|
+
const tr = singleNode
|
|
42
|
+
? view.state.tr.replaceSelectionWith(singleNode, preferPlain)
|
|
43
|
+
: view.state.tr.replaceSelection(slice);
|
|
44
|
+
view.dispatch(tr.setMeta("paste", true).setMeta("uiEvent", "paste"));
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
1
|
+
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
|
|
2
2
|
import {
|
|
3
3
|
BlockFromConfig,
|
|
4
4
|
createBlockSpec,
|
|
5
5
|
FileBlockConfig,
|
|
6
6
|
Props,
|
|
7
7
|
PropSchema,
|
|
8
|
-
} from "../../schema";
|
|
9
|
-
import { defaultProps } from "../defaultProps";
|
|
8
|
+
} from "../../schema/index.js";
|
|
9
|
+
import { defaultProps } from "../defaultProps.js";
|
|
10
10
|
|
|
11
11
|
import {
|
|
12
12
|
createFigureWithCaption,
|
|
@@ -14,8 +14,8 @@ import {
|
|
|
14
14
|
createFileBlockWrapper,
|
|
15
15
|
createLinkWithCaption,
|
|
16
16
|
parseFigureElement,
|
|
17
|
-
} from "../FileBlockContent/fileBlockHelpers";
|
|
18
|
-
import { parseAudioElement } from "./audioBlockHelpers";
|
|
17
|
+
} from "../FileBlockContent/fileBlockHelpers.js";
|
|
18
|
+
import { parseAudioElement } from "./audioBlockHelpers.js";
|
|
19
19
|
|
|
20
20
|
export const audioPropSchema = {
|
|
21
21
|
backgroundColor: defaultProps.backgroundColor,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
1
|
+
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
|
|
2
2
|
import {
|
|
3
3
|
BlockFromConfig,
|
|
4
4
|
FileBlockConfig,
|
|
5
5
|
PropSchema,
|
|
6
6
|
createBlockSpec,
|
|
7
|
-
} from "../../schema";
|
|
8
|
-
import { defaultProps } from "../defaultProps";
|
|
7
|
+
} from "../../schema/index.js";
|
|
8
|
+
import { defaultProps } from "../defaultProps.js";
|
|
9
9
|
import {
|
|
10
10
|
createDefaultFilePreview,
|
|
11
11
|
createFileAndCaptionWrapper,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
createLinkWithCaption,
|
|
14
14
|
parseEmbedElement,
|
|
15
15
|
parseFigureElement,
|
|
16
|
-
} from "./fileBlockHelpers";
|
|
16
|
+
} from "./fileBlockHelpers.js";
|
|
17
17
|
|
|
18
18
|
export const filePropSchema = {
|
|
19
19
|
backgroundColor: defaultProps.backgroundColor,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
1
|
+
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
|
|
2
2
|
import {
|
|
3
3
|
BlockFromConfig,
|
|
4
4
|
BlockSchemaWithBlock,
|
|
5
5
|
FileBlockConfig,
|
|
6
|
-
} from "../../schema";
|
|
6
|
+
} from "../../schema/index.js";
|
|
7
7
|
|
|
8
8
|
export const createFileBlockWrapper = (
|
|
9
9
|
block: BlockFromConfig<FileBlockConfig, any, any>,
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { InputRule } from "@tiptap/core";
|
|
2
|
+
import { updateBlockCommand } from "../../api/blockManipulation/commands/updateBlock/updateBlock.js";
|
|
3
|
+
import { getBlockInfoFromSelection } from "../../api/getBlockInfoFromPos.js";
|
|
2
4
|
import {
|
|
3
5
|
PropSchema,
|
|
4
6
|
createBlockSpecFromStronglyTypedTiptapNode,
|
|
5
7
|
createStronglyTypedTiptapNode,
|
|
6
|
-
} from "../../schema";
|
|
7
|
-
import { createDefaultBlockDOMOutputSpec } from "../defaultBlockHelpers";
|
|
8
|
-
import { defaultProps } from "../defaultProps";
|
|
9
|
-
import { getCurrentBlockContentType } from "../../api/getCurrentBlockContentType";
|
|
8
|
+
} from "../../schema/index.js";
|
|
9
|
+
import { createDefaultBlockDOMOutputSpec } from "../defaultBlockHelpers.js";
|
|
10
|
+
import { defaultProps } from "../defaultProps.js";
|
|
10
11
|
|
|
11
12
|
export const headingPropSchema = {
|
|
12
13
|
...defaultProps,
|
|
@@ -46,19 +47,27 @@ const HeadingBlockContent = createStronglyTypedTiptapNode({
|
|
|
46
47
|
return new InputRule({
|
|
47
48
|
find: new RegExp(`^(#{${level}})\\s$`),
|
|
48
49
|
handler: ({ state, chain, range }) => {
|
|
49
|
-
|
|
50
|
+
const blockInfo = getBlockInfoFromSelection(state);
|
|
51
|
+
if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
|
|
50
52
|
return;
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
chain()
|
|
54
|
-
.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
.command(
|
|
57
|
+
updateBlockCommand(
|
|
58
|
+
this.options.editor,
|
|
59
|
+
blockInfo.blockContainer.beforePos,
|
|
60
|
+
{
|
|
61
|
+
type: "heading",
|
|
62
|
+
props: {
|
|
63
|
+
level: level as any,
|
|
64
|
+
},
|
|
65
|
+
}
|
|
66
|
+
)
|
|
67
|
+
)
|
|
60
68
|
// Removes the "#" character(s) used to set the heading.
|
|
61
|
-
.deleteRange({ from: range.from, to: range.to })
|
|
69
|
+
.deleteRange({ from: range.from, to: range.to })
|
|
70
|
+
.run();
|
|
62
71
|
},
|
|
63
72
|
});
|
|
64
73
|
}),
|
|
@@ -68,48 +77,61 @@ const HeadingBlockContent = createStronglyTypedTiptapNode({
|
|
|
68
77
|
addKeyboardShortcuts() {
|
|
69
78
|
return {
|
|
70
79
|
"Mod-Alt-1": () => {
|
|
71
|
-
|
|
80
|
+
const blockInfo = getBlockInfoFromSelection(this.editor.state);
|
|
81
|
+
if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
|
|
72
82
|
return true;
|
|
73
83
|
}
|
|
74
84
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
85
|
+
// call updateBlockCommand
|
|
86
|
+
return this.editor.commands.command(
|
|
87
|
+
updateBlockCommand(
|
|
88
|
+
this.options.editor,
|
|
89
|
+
blockInfo.blockContainer.beforePos,
|
|
90
|
+
{
|
|
91
|
+
type: "heading",
|
|
92
|
+
props: {
|
|
93
|
+
level: 1 as any,
|
|
94
|
+
},
|
|
95
|
+
}
|
|
96
|
+
)
|
|
83
97
|
);
|
|
84
98
|
},
|
|
85
99
|
"Mod-Alt-2": () => {
|
|
86
|
-
|
|
100
|
+
const blockInfo = getBlockInfoFromSelection(this.editor.state);
|
|
101
|
+
if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
|
|
87
102
|
return true;
|
|
88
103
|
}
|
|
89
104
|
|
|
90
|
-
return this.editor.commands.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
105
|
+
return this.editor.commands.command(
|
|
106
|
+
updateBlockCommand(
|
|
107
|
+
this.options.editor,
|
|
108
|
+
blockInfo.blockContainer.beforePos,
|
|
109
|
+
{
|
|
110
|
+
type: "heading",
|
|
111
|
+
props: {
|
|
112
|
+
level: 2 as any,
|
|
113
|
+
},
|
|
114
|
+
}
|
|
115
|
+
)
|
|
98
116
|
);
|
|
99
117
|
},
|
|
100
118
|
"Mod-Alt-3": () => {
|
|
101
|
-
|
|
119
|
+
const blockInfo = getBlockInfoFromSelection(this.editor.state);
|
|
120
|
+
if (blockInfo.blockContent.node.type.spec.content !== "inline*") {
|
|
102
121
|
return true;
|
|
103
122
|
}
|
|
104
123
|
|
|
105
|
-
return this.editor.commands.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
124
|
+
return this.editor.commands.command(
|
|
125
|
+
updateBlockCommand(
|
|
126
|
+
this.options.editor,
|
|
127
|
+
blockInfo.blockContainer.beforePos,
|
|
128
|
+
{
|
|
129
|
+
type: "heading",
|
|
130
|
+
props: {
|
|
131
|
+
level: 3 as any,
|
|
132
|
+
},
|
|
133
|
+
}
|
|
134
|
+
)
|
|
113
135
|
);
|
|
114
136
|
},
|
|
115
137
|
};
|