@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,263 @@
|
|
|
1
|
+
import { DOMSerializer, Fragment } from "prosemirror-model";
|
|
2
|
+
|
|
3
|
+
import { PartialBlock } from "../../../../blocks/defaultBlocks.js";
|
|
4
|
+
import type { BlockNoteEditor } from "../../../../editor/BlockNoteEditor.js";
|
|
5
|
+
import {
|
|
6
|
+
BlockSchema,
|
|
7
|
+
InlineContentSchema,
|
|
8
|
+
StyleSchema,
|
|
9
|
+
} from "../../../../schema/index.js";
|
|
10
|
+
import { UnreachableCaseError } from "../../../../util/typescript.js";
|
|
11
|
+
import {
|
|
12
|
+
inlineContentToNodes,
|
|
13
|
+
tableContentToNodes,
|
|
14
|
+
} from "../../../nodeConversions/blockToNode.js";
|
|
15
|
+
|
|
16
|
+
function addAttributesAndRemoveClasses(element: HTMLElement) {
|
|
17
|
+
// Removes all BlockNote specific class names.
|
|
18
|
+
const className =
|
|
19
|
+
[...element.classList].filter(
|
|
20
|
+
(className) => !className.startsWith("bn-")
|
|
21
|
+
) || [];
|
|
22
|
+
|
|
23
|
+
if (className.length > 0) {
|
|
24
|
+
element.className = className.join(" ");
|
|
25
|
+
} else {
|
|
26
|
+
element.removeAttribute("class");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function serializeInlineContentExternalHTML<
|
|
31
|
+
BSchema extends BlockSchema,
|
|
32
|
+
I extends InlineContentSchema,
|
|
33
|
+
S extends StyleSchema
|
|
34
|
+
>(
|
|
35
|
+
editor: BlockNoteEditor<any, I, S>,
|
|
36
|
+
blockContent: PartialBlock<BSchema, I, S>["content"],
|
|
37
|
+
serializer: DOMSerializer,
|
|
38
|
+
options?: { document?: Document }
|
|
39
|
+
) {
|
|
40
|
+
let nodes: any;
|
|
41
|
+
|
|
42
|
+
// TODO: reuse function from nodeconversions?
|
|
43
|
+
if (!blockContent) {
|
|
44
|
+
throw new Error("blockContent is required");
|
|
45
|
+
} else if (typeof blockContent === "string") {
|
|
46
|
+
nodes = inlineContentToNodes(
|
|
47
|
+
[blockContent],
|
|
48
|
+
editor.pmSchema,
|
|
49
|
+
editor.schema.styleSchema
|
|
50
|
+
);
|
|
51
|
+
} else if (Array.isArray(blockContent)) {
|
|
52
|
+
nodes = inlineContentToNodes(
|
|
53
|
+
blockContent,
|
|
54
|
+
editor.pmSchema,
|
|
55
|
+
editor.schema.styleSchema
|
|
56
|
+
);
|
|
57
|
+
} else if (blockContent.type === "tableContent") {
|
|
58
|
+
nodes = tableContentToNodes(
|
|
59
|
+
blockContent,
|
|
60
|
+
editor.pmSchema,
|
|
61
|
+
editor.schema.styleSchema
|
|
62
|
+
);
|
|
63
|
+
} else {
|
|
64
|
+
throw new UnreachableCaseError(blockContent.type);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// We call the prosemirror serializer here because it handles Marks and Inline Content nodes nicely.
|
|
68
|
+
// If we'd want to support custom serialization or externalHTML for Inline Content, we'd have to implement
|
|
69
|
+
// a custom serializer here.
|
|
70
|
+
const dom = serializer.serializeFragment(Fragment.from(nodes), options);
|
|
71
|
+
|
|
72
|
+
if (dom.nodeType === 1 /* Node.ELEMENT_NODE */) {
|
|
73
|
+
addAttributesAndRemoveClasses(dom as HTMLElement);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return dom;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* TODO: there's still quite some logic that handles getting and filtering properties,
|
|
81
|
+
* we should make sure the `toExternalHTML` methods of default blocks actually handle this,
|
|
82
|
+
* instead of the serializer.
|
|
83
|
+
*/
|
|
84
|
+
function serializeBlock<
|
|
85
|
+
BSchema extends BlockSchema,
|
|
86
|
+
I extends InlineContentSchema,
|
|
87
|
+
S extends StyleSchema
|
|
88
|
+
>(
|
|
89
|
+
fragment: DocumentFragment,
|
|
90
|
+
editor: BlockNoteEditor<BSchema, I, S>,
|
|
91
|
+
block: PartialBlock<BSchema, I, S>,
|
|
92
|
+
serializer: DOMSerializer,
|
|
93
|
+
orderedListItemBlockTypes: Set<string>,
|
|
94
|
+
unorderedListItemBlockTypes: Set<string>,
|
|
95
|
+
options?: { document?: Document }
|
|
96
|
+
) {
|
|
97
|
+
const doc = options?.document ?? document;
|
|
98
|
+
const BC_NODE = editor.pmSchema.nodes["blockContainer"];
|
|
99
|
+
|
|
100
|
+
let props = block.props;
|
|
101
|
+
// set default props in case we were passed a partial block
|
|
102
|
+
if (!block.props) {
|
|
103
|
+
props = {};
|
|
104
|
+
for (const [name, spec] of Object.entries(
|
|
105
|
+
editor.schema.blockSchema[block.type as any].propSchema
|
|
106
|
+
)) {
|
|
107
|
+
(props as any)[name] = spec.default;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const bc = BC_NODE.spec?.toDOM?.(
|
|
112
|
+
BC_NODE.create({
|
|
113
|
+
id: block.id,
|
|
114
|
+
...props,
|
|
115
|
+
})
|
|
116
|
+
) as {
|
|
117
|
+
dom: HTMLElement;
|
|
118
|
+
contentDOM?: HTMLElement;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// the container node is just used as a workaround to get some block-level attributes.
|
|
122
|
+
// we should change toExternalHTML so that this is not necessary
|
|
123
|
+
const attrs = [...bc.dom.attributes];
|
|
124
|
+
|
|
125
|
+
const ret = editor.blockImplementations[
|
|
126
|
+
block.type as any
|
|
127
|
+
].implementation.toExternalHTML({ ...block, props } as any, editor as any);
|
|
128
|
+
|
|
129
|
+
const elementFragment = doc.createDocumentFragment();
|
|
130
|
+
if (ret.dom.classList.contains("bn-block-content")) {
|
|
131
|
+
const blockContentDataAttributes = [...attrs, ...ret.dom.attributes].filter(
|
|
132
|
+
(attr) =>
|
|
133
|
+
attr.name.startsWith("data") &&
|
|
134
|
+
attr.name !== "data-content-type" &&
|
|
135
|
+
attr.name !== "data-file-block" &&
|
|
136
|
+
attr.name !== "data-node-view-wrapper" &&
|
|
137
|
+
attr.name !== "data-node-type" &&
|
|
138
|
+
attr.name !== "data-id" &&
|
|
139
|
+
attr.name !== "data-index" &&
|
|
140
|
+
attr.name !== "data-editable"
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
// ret.dom = ret.dom.firstChild! as any;
|
|
144
|
+
for (const attr of blockContentDataAttributes) {
|
|
145
|
+
(ret.dom.firstChild! as HTMLElement).setAttribute(attr.name, attr.value);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
addAttributesAndRemoveClasses(ret.dom.firstChild! as HTMLElement);
|
|
149
|
+
elementFragment.append(...ret.dom.childNodes);
|
|
150
|
+
} else {
|
|
151
|
+
elementFragment.append(ret.dom);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (ret.contentDOM && block.content) {
|
|
155
|
+
const ic = serializeInlineContentExternalHTML(
|
|
156
|
+
editor,
|
|
157
|
+
block.content as any, // TODO
|
|
158
|
+
serializer,
|
|
159
|
+
options
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
ret.contentDOM.appendChild(ic);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
let listType = undefined;
|
|
166
|
+
if (orderedListItemBlockTypes.has(block.type!)) {
|
|
167
|
+
listType = "OL";
|
|
168
|
+
} else if (unorderedListItemBlockTypes.has(block.type!)) {
|
|
169
|
+
listType = "UL";
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (listType) {
|
|
173
|
+
if (fragment.lastChild?.nodeName !== listType) {
|
|
174
|
+
const list = doc.createElement(listType);
|
|
175
|
+
fragment.append(list);
|
|
176
|
+
}
|
|
177
|
+
const li = doc.createElement("li");
|
|
178
|
+
li.append(elementFragment);
|
|
179
|
+
fragment.lastChild!.appendChild(li);
|
|
180
|
+
} else {
|
|
181
|
+
fragment.append(elementFragment);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (block.children && block.children.length > 0) {
|
|
185
|
+
const childFragment = doc.createDocumentFragment();
|
|
186
|
+
serializeBlocksToFragment(
|
|
187
|
+
childFragment,
|
|
188
|
+
editor,
|
|
189
|
+
block.children,
|
|
190
|
+
serializer,
|
|
191
|
+
orderedListItemBlockTypes,
|
|
192
|
+
unorderedListItemBlockTypes,
|
|
193
|
+
options
|
|
194
|
+
);
|
|
195
|
+
if (
|
|
196
|
+
fragment.lastChild?.nodeName === "UL" ||
|
|
197
|
+
fragment.lastChild?.nodeName === "OL"
|
|
198
|
+
) {
|
|
199
|
+
// add nested lists to the last list item
|
|
200
|
+
while (
|
|
201
|
+
childFragment.firstChild?.nodeName === "UL" ||
|
|
202
|
+
childFragment.firstChild?.nodeName === "OL"
|
|
203
|
+
) {
|
|
204
|
+
fragment.lastChild!.lastChild!.appendChild(childFragment.firstChild!);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
fragment.append(childFragment);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const serializeBlocksToFragment = <
|
|
213
|
+
BSchema extends BlockSchema,
|
|
214
|
+
I extends InlineContentSchema,
|
|
215
|
+
S extends StyleSchema
|
|
216
|
+
>(
|
|
217
|
+
fragment: DocumentFragment,
|
|
218
|
+
editor: BlockNoteEditor<BSchema, I, S>,
|
|
219
|
+
blocks: PartialBlock<BSchema, I, S>[],
|
|
220
|
+
serializer: DOMSerializer,
|
|
221
|
+
orderedListItemBlockTypes: Set<string>,
|
|
222
|
+
unorderedListItemBlockTypes: Set<string>,
|
|
223
|
+
options?: { document?: Document }
|
|
224
|
+
) => {
|
|
225
|
+
for (const block of blocks) {
|
|
226
|
+
serializeBlock(
|
|
227
|
+
fragment,
|
|
228
|
+
editor,
|
|
229
|
+
block,
|
|
230
|
+
serializer,
|
|
231
|
+
orderedListItemBlockTypes,
|
|
232
|
+
unorderedListItemBlockTypes,
|
|
233
|
+
options
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
export const serializeBlocksExternalHTML = <
|
|
239
|
+
BSchema extends BlockSchema,
|
|
240
|
+
I extends InlineContentSchema,
|
|
241
|
+
S extends StyleSchema
|
|
242
|
+
>(
|
|
243
|
+
editor: BlockNoteEditor<BSchema, I, S>,
|
|
244
|
+
blocks: PartialBlock<BSchema, I, S>[],
|
|
245
|
+
serializer: DOMSerializer,
|
|
246
|
+
orderedListItemBlockTypes: Set<string>,
|
|
247
|
+
unorderedListItemBlockTypes: Set<string>,
|
|
248
|
+
options?: { document?: Document }
|
|
249
|
+
) => {
|
|
250
|
+
const doc = options?.document ?? document;
|
|
251
|
+
const fragment = doc.createDocumentFragment();
|
|
252
|
+
|
|
253
|
+
serializeBlocksToFragment(
|
|
254
|
+
fragment,
|
|
255
|
+
editor,
|
|
256
|
+
blocks,
|
|
257
|
+
serializer,
|
|
258
|
+
orderedListItemBlockTypes,
|
|
259
|
+
unorderedListItemBlockTypes,
|
|
260
|
+
options
|
|
261
|
+
);
|
|
262
|
+
return fragment;
|
|
263
|
+
};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { DOMSerializer, Fragment } from "prosemirror-model";
|
|
2
|
+
|
|
3
|
+
import { PartialBlock } from "../../../../blocks/defaultBlocks.js";
|
|
4
|
+
import type { BlockNoteEditor } from "../../../../editor/BlockNoteEditor.js";
|
|
5
|
+
import {
|
|
6
|
+
BlockSchema,
|
|
7
|
+
InlineContentSchema,
|
|
8
|
+
StyleSchema,
|
|
9
|
+
} from "../../../../schema/index.js";
|
|
10
|
+
import { UnreachableCaseError } from "../../../../util/typescript.js";
|
|
11
|
+
import {
|
|
12
|
+
inlineContentToNodes,
|
|
13
|
+
tableContentToNodes,
|
|
14
|
+
} from "../../../nodeConversions/blockToNode.js";
|
|
15
|
+
|
|
16
|
+
export function serializeInlineContentInternalHTML<
|
|
17
|
+
BSchema extends BlockSchema,
|
|
18
|
+
I extends InlineContentSchema,
|
|
19
|
+
S extends StyleSchema
|
|
20
|
+
>(
|
|
21
|
+
editor: BlockNoteEditor<any, I, S>,
|
|
22
|
+
blockContent: PartialBlock<BSchema, I, S>["content"],
|
|
23
|
+
serializer: DOMSerializer,
|
|
24
|
+
_toExternalHTML: boolean, // TODO, externalHTML for IC
|
|
25
|
+
options?: { document?: Document }
|
|
26
|
+
) {
|
|
27
|
+
let nodes: any;
|
|
28
|
+
|
|
29
|
+
// TODO: reuse function from nodeconversions?
|
|
30
|
+
if (!blockContent) {
|
|
31
|
+
throw new Error("blockContent is required");
|
|
32
|
+
} else if (typeof blockContent === "string") {
|
|
33
|
+
nodes = inlineContentToNodes(
|
|
34
|
+
[blockContent],
|
|
35
|
+
editor.pmSchema,
|
|
36
|
+
editor.schema.styleSchema
|
|
37
|
+
);
|
|
38
|
+
} else if (Array.isArray(blockContent)) {
|
|
39
|
+
nodes = inlineContentToNodes(
|
|
40
|
+
blockContent,
|
|
41
|
+
editor.pmSchema,
|
|
42
|
+
editor.schema.styleSchema
|
|
43
|
+
);
|
|
44
|
+
} else if (blockContent.type === "tableContent") {
|
|
45
|
+
nodes = tableContentToNodes(
|
|
46
|
+
blockContent,
|
|
47
|
+
editor.pmSchema,
|
|
48
|
+
editor.schema.styleSchema
|
|
49
|
+
);
|
|
50
|
+
} else {
|
|
51
|
+
throw new UnreachableCaseError(blockContent.type);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// We call the prosemirror serializer here because it handles Marks and Inline Content nodes nicely.
|
|
55
|
+
// If we'd want to support custom serialization or externalHTML for Inline Content, we'd have to implement
|
|
56
|
+
// a custom serializer here.
|
|
57
|
+
const dom = serializer.serializeFragment(Fragment.from(nodes), options);
|
|
58
|
+
|
|
59
|
+
return dom;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function serializeBlock<
|
|
63
|
+
BSchema extends BlockSchema,
|
|
64
|
+
I extends InlineContentSchema,
|
|
65
|
+
S extends StyleSchema
|
|
66
|
+
>(
|
|
67
|
+
editor: BlockNoteEditor<BSchema, I, S>,
|
|
68
|
+
block: PartialBlock<BSchema, I, S>,
|
|
69
|
+
serializer: DOMSerializer,
|
|
70
|
+
toExternalHTML: boolean,
|
|
71
|
+
options?: { document?: Document }
|
|
72
|
+
) {
|
|
73
|
+
const BC_NODE = editor.pmSchema.nodes["blockContainer"];
|
|
74
|
+
|
|
75
|
+
let props = block.props;
|
|
76
|
+
// set default props in case we were passed a partial block
|
|
77
|
+
if (!block.props) {
|
|
78
|
+
props = {};
|
|
79
|
+
for (const [name, spec] of Object.entries(
|
|
80
|
+
editor.schema.blockSchema[block.type as any].propSchema
|
|
81
|
+
)) {
|
|
82
|
+
(props as any)[name] = spec.default;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const bc = BC_NODE.spec?.toDOM?.(
|
|
87
|
+
BC_NODE.create({
|
|
88
|
+
id: block.id,
|
|
89
|
+
...props,
|
|
90
|
+
})
|
|
91
|
+
) as {
|
|
92
|
+
dom: HTMLElement;
|
|
93
|
+
contentDOM?: HTMLElement;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const impl = editor.blockImplementations[block.type as any].implementation;
|
|
97
|
+
const ret = toExternalHTML
|
|
98
|
+
? impl.toExternalHTML({ ...block, props } as any, editor as any)
|
|
99
|
+
: impl.toInternalHTML({ ...block, props } as any, editor as any);
|
|
100
|
+
|
|
101
|
+
if (ret.contentDOM && block.content) {
|
|
102
|
+
const ic = serializeInlineContentInternalHTML(
|
|
103
|
+
editor,
|
|
104
|
+
block.content as any, // TODO
|
|
105
|
+
serializer,
|
|
106
|
+
toExternalHTML,
|
|
107
|
+
options
|
|
108
|
+
);
|
|
109
|
+
ret.contentDOM.appendChild(ic);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
bc.contentDOM?.appendChild(ret.dom);
|
|
113
|
+
|
|
114
|
+
if (block.children && block.children.length > 0) {
|
|
115
|
+
bc.contentDOM?.appendChild(
|
|
116
|
+
serializeBlocksInternalHTML(
|
|
117
|
+
editor,
|
|
118
|
+
block.children,
|
|
119
|
+
serializer,
|
|
120
|
+
toExternalHTML,
|
|
121
|
+
options
|
|
122
|
+
)
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
return bc.dom;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export const serializeBlocksInternalHTML = <
|
|
129
|
+
BSchema extends BlockSchema,
|
|
130
|
+
I extends InlineContentSchema,
|
|
131
|
+
S extends StyleSchema
|
|
132
|
+
>(
|
|
133
|
+
editor: BlockNoteEditor<BSchema, I, S>,
|
|
134
|
+
blocks: PartialBlock<BSchema, I, S>[],
|
|
135
|
+
serializer: DOMSerializer,
|
|
136
|
+
toExternalHTML: boolean,
|
|
137
|
+
options?: { document?: Document }
|
|
138
|
+
) => {
|
|
139
|
+
const BG_NODE = editor.pmSchema.nodes["blockGroup"];
|
|
140
|
+
|
|
141
|
+
const bg = BG_NODE.spec!.toDOM!(BG_NODE.create({})) as {
|
|
142
|
+
dom: HTMLElement;
|
|
143
|
+
contentDOM?: HTMLElement;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
for (const block of blocks) {
|
|
147
|
+
const blockDOM = serializeBlock(
|
|
148
|
+
editor,
|
|
149
|
+
block,
|
|
150
|
+
serializer,
|
|
151
|
+
toExternalHTML,
|
|
152
|
+
options
|
|
153
|
+
);
|
|
154
|
+
bg.contentDOM!.appendChild(blockDOM);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return bg.dom;
|
|
158
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
4
|
-
import { PartialBlock } from "../../../blocks/defaultBlocks";
|
|
5
|
-
import { BlockNoteEditor } from "../../../editor/BlockNoteEditor";
|
|
6
|
-
import { BlockSchema } from "../../../schema/blocks/types";
|
|
7
|
-
import { InlineContentSchema } from "../../../schema/inlineContent/types";
|
|
8
|
-
import { StyleSchema } from "../../../schema/styles/types";
|
|
9
|
-
import { customBlocksTestCases } from "../../testUtil/cases/customBlocks";
|
|
10
|
-
import { customInlineContentTestCases } from "../../testUtil/cases/customInlineContent";
|
|
11
|
-
import { customStylesTestCases } from "../../testUtil/cases/customStyles";
|
|
12
|
-
import { defaultSchemaTestCases } from "../../testUtil/cases/defaultSchema";
|
|
13
|
-
import { partialBlocksToBlocksForTesting } from "../../testUtil/partialBlockTestUtil";
|
|
4
|
+
import { PartialBlock } from "../../../blocks/defaultBlocks.js";
|
|
5
|
+
import { BlockNoteEditor } from "../../../editor/BlockNoteEditor.js";
|
|
6
|
+
import { BlockSchema } from "../../../schema/blocks/types.js";
|
|
7
|
+
import { InlineContentSchema } from "../../../schema/inlineContent/types.js";
|
|
8
|
+
import { StyleSchema } from "../../../schema/styles/types.js";
|
|
9
|
+
import { customBlocksTestCases } from "../../testUtil/cases/customBlocks.js";
|
|
10
|
+
import { customInlineContentTestCases } from "../../testUtil/cases/customInlineContent.js";
|
|
11
|
+
import { customStylesTestCases } from "../../testUtil/cases/customStyles.js";
|
|
12
|
+
import { defaultSchemaTestCases } from "../../testUtil/cases/defaultSchema.js";
|
|
13
|
+
import { partialBlocksToBlocksForTesting } from "../../testUtil/partialBlockTestUtil.js";
|
|
14
14
|
|
|
15
15
|
async function convertToMarkdownAndCompareSnapshots<
|
|
16
16
|
B extends BlockSchema,
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { Schema } from "prosemirror-model";
|
|
2
|
-
import { PartialBlock } from "../../../blocks/defaultBlocks";
|
|
3
|
-
import type { BlockNoteEditor } from "../../../editor/BlockNoteEditor";
|
|
4
|
-
import {
|
|
2
|
+
import { PartialBlock } from "../../../blocks/defaultBlocks.js";
|
|
3
|
+
import type { BlockNoteEditor } from "../../../editor/BlockNoteEditor.js";
|
|
4
|
+
import {
|
|
5
|
+
BlockSchema,
|
|
6
|
+
InlineContentSchema,
|
|
7
|
+
StyleSchema,
|
|
8
|
+
} from "../../../schema/index.js";
|
|
5
9
|
import {
|
|
6
10
|
esmDependencies,
|
|
7
11
|
initializeESMDependencies,
|
|
8
|
-
} from "../../../util/esmDependencies";
|
|
9
|
-
import { createExternalHTMLExporter } from "../html/externalHTMLExporter";
|
|
10
|
-
import { removeUnderlines } from "./removeUnderlinesRehypePlugin";
|
|
11
|
-
import { addSpacesToCheckboxes } from "./util/addSpacesToCheckboxesRehypePlugin";
|
|
12
|
+
} from "../../../util/esmDependencies.js";
|
|
13
|
+
import { createExternalHTMLExporter } from "../html/externalHTMLExporter.js";
|
|
14
|
+
import { removeUnderlines } from "./removeUnderlinesRehypePlugin.js";
|
|
15
|
+
import { addSpacesToCheckboxes } from "./util/addSpacesToCheckboxesRehypePlugin.js";
|
|
12
16
|
|
|
13
17
|
// Needs to be sync because it's used in drag handler event (SideMenuPlugin)
|
|
14
18
|
// Ideally, call `await initializeESMDependencies()` before calling this function
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Element as HASTElement, Parent as HASTParent } from "hast";
|
|
2
|
-
import { esmDependencies } from "../../../../util/esmDependencies";
|
|
2
|
+
import { esmDependencies } from "../../../../util/esmDependencies.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Rehype plugin which adds a space after each checkbox input element. This is
|
|
@@ -11,7 +11,7 @@ export function addSpacesToCheckboxes() {
|
|
|
11
11
|
|
|
12
12
|
if (!deps) {
|
|
13
13
|
throw new Error(
|
|
14
|
-
"
|
|
14
|
+
"addSpacesToCheckboxes requires ESM dependencies to be initialized"
|
|
15
15
|
);
|
|
16
16
|
}
|
|
17
17
|
|