@blocknote/core 0.18.0 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/blocknote.js +3145 -2970
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +9 -9
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js +27 -0
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.js +99 -0
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.js +97 -0
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.js +88 -0
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.js +116 -0
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.test.js +110 -0
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/nestBlock/nestBlock.js +57 -0
- package/dist/src/api/blockManipulation/commands/nestBlock/nestBlock.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js +5 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js +31 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js +71 -0
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.js +157 -0
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js +27 -0
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js +64 -0
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js +145 -0
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.test.js +252 -0
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.test.js.map +1 -0
- package/dist/src/api/blockManipulation/insertContentAt.js +64 -0
- package/dist/src/api/blockManipulation/insertContentAt.js.map +1 -0
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js +76 -0
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js.map +1 -0
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.js +33 -0
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.js.map +1 -0
- package/dist/src/api/blockManipulation/setupTestEnv.js +172 -0
- package/dist/src/api/blockManipulation/setupTestEnv.js.map +1 -0
- package/dist/src/api/clipboard/clipboard.test.js +246 -0
- package/dist/src/api/clipboard/clipboard.test.js.map +1 -0
- package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js +8 -0
- package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js.map +1 -0
- package/dist/src/api/clipboard/fromClipboard/fileDropExtension.js +38 -0
- package/dist/src/api/clipboard/fromClipboard/fileDropExtension.js.map +1 -0
- package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js +111 -0
- package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js.map +1 -0
- package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js +26 -0
- package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js.map +1 -0
- package/dist/src/api/clipboard/fromClipboard/pasteExtension.js +57 -0
- package/dist/src/api/clipboard/fromClipboard/pasteExtension.js.map +1 -0
- package/dist/src/api/clipboard/toClipboard/copyExtension.js +132 -0
- package/dist/src/api/clipboard/toClipboard/copyExtension.js.map +1 -0
- package/dist/src/api/exporters/html/externalHTMLExporter.js +35 -0
- package/dist/src/api/exporters/html/externalHTMLExporter.js.map +1 -0
- package/dist/src/api/exporters/html/htmlConversion.test.js +72 -0
- package/dist/src/api/exporters/html/htmlConversion.test.js.map +1 -0
- package/dist/src/api/exporters/html/internalHTMLSerializer.js +21 -0
- package/dist/src/api/exporters/html/internalHTMLSerializer.js.map +1 -0
- package/dist/src/api/exporters/html/util/serializeBlocksExternalHTML.js +141 -0
- package/dist/src/api/exporters/html/util/serializeBlocksExternalHTML.js.map +1 -0
- package/dist/src/api/exporters/html/util/serializeBlocksInternalHTML.js +96 -0
- package/dist/src/api/exporters/html/util/serializeBlocksInternalHTML.js.map +1 -0
- package/dist/src/api/exporters/markdown/markdownExporter.js +31 -0
- package/dist/src/api/exporters/markdown/markdownExporter.js.map +1 -0
- package/dist/src/api/exporters/markdown/markdownExporter.test.js +57 -0
- package/dist/src/api/exporters/markdown/markdownExporter.test.js.map +1 -0
- package/dist/src/api/exporters/markdown/removeUnderlinesRehypePlugin.js +33 -0
- package/dist/src/api/exporters/markdown/removeUnderlinesRehypePlugin.js.map +1 -0
- package/dist/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.js +37 -0
- package/dist/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.js.map +1 -0
- package/dist/src/api/getBlockInfoFromPos.js +165 -0
- package/dist/src/api/getBlockInfoFromPos.js.map +1 -0
- package/dist/src/api/nodeConversions/blockToNode.js +197 -0
- package/dist/src/api/nodeConversions/blockToNode.js.map +1 -0
- package/dist/src/api/nodeConversions/fragmentToBlocks.js +50 -0
- package/dist/src/api/nodeConversions/fragmentToBlocks.js.map +1 -0
- package/dist/src/api/nodeConversions/nodeConversions.test.js +54 -0
- package/dist/src/api/nodeConversions/nodeConversions.test.js.map +1 -0
- package/dist/src/api/nodeConversions/nodeToBlock.js +316 -0
- package/dist/src/api/nodeConversions/nodeToBlock.js.map +1 -0
- package/dist/src/api/nodeUtil.js +28 -0
- package/dist/src/api/nodeUtil.js.map +1 -0
- package/dist/src/api/parsers/html/parseHTML.js +19 -0
- package/dist/src/api/parsers/html/parseHTML.js.map +1 -0
- package/dist/src/api/parsers/html/parseHTML.test.js +470 -0
- package/dist/src/api/parsers/html/parseHTML.test.js.map +1 -0
- package/dist/src/api/parsers/html/util/nestedLists.js +106 -0
- package/dist/src/api/parsers/html/util/nestedLists.js.map +1 -0
- package/dist/src/api/parsers/html/util/nestedLists.test.js +166 -0
- package/dist/src/api/parsers/html/util/nestedLists.test.js.map +1 -0
- package/dist/src/api/parsers/markdown/parseMarkdown.js +52 -0
- package/dist/src/api/parsers/markdown/parseMarkdown.js.map +1 -0
- package/dist/src/api/parsers/markdown/parseMarkdown.test.js +109 -0
- package/dist/src/api/parsers/markdown/parseMarkdown.test.js.map +1 -0
- package/dist/src/api/testUtil/cases/customBlocks.js +313 -0
- package/dist/src/api/testUtil/cases/customBlocks.js.map +1 -0
- package/dist/src/api/testUtil/cases/customInlineContent.js +91 -0
- package/dist/src/api/testUtil/cases/customInlineContent.js.map +1 -0
- package/dist/src/api/testUtil/cases/customStyles.js +83 -0
- package/dist/src/api/testUtil/cases/customStyles.js.map +1 -0
- package/dist/src/api/testUtil/cases/defaultSchema.js +673 -0
- package/dist/src/api/testUtil/cases/defaultSchema.js.map +1 -0
- package/dist/src/api/testUtil/index.js +2 -0
- package/dist/src/api/testUtil/index.js.map +1 -0
- package/dist/src/api/testUtil/partialBlockTestUtil.js +114 -0
- package/dist/src/api/testUtil/partialBlockTestUtil.js.map +1 -0
- package/dist/src/api/testUtil/paste.js +29 -0
- package/dist/src/api/testUtil/paste.js.map +1 -0
- package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js +97 -0
- package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js.map +1 -0
- package/dist/src/blocks/AudioBlockContent/audioBlockHelpers.js +5 -0
- package/dist/src/blocks/AudioBlockContent/audioBlockHelpers.js.map +1 -0
- package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js +273 -0
- package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js.map +1 -0
- package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js +90 -0
- package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/FileBlockContent.js +70 -0
- package/dist/src/blocks/FileBlockContent/FileBlockContent.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/fileBlockHelpers.js +317 -0
- package/dist/src/blocks/FileBlockContent/fileBlockHelpers.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js +15 -0
- package/dist/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js.map +1 -0
- package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js +145 -0
- package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js.map +1 -0
- package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js +106 -0
- package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js.map +1 -0
- package/dist/src/blocks/ImageBlockContent/imageBlockHelpers.js +6 -0
- package/dist/src/blocks/ImageBlockContent/imageBlockHelpers.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js +113 -0
- package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js +224 -0
- package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js +45 -0
- package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.js +58 -0
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js +130 -0
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js.map +1 -0
- package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js +52 -0
- package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js.map +1 -0
- package/dist/src/blocks/TableBlockContent/TableBlockContent.js +129 -0
- package/dist/src/blocks/TableBlockContent/TableBlockContent.js.map +1 -0
- package/dist/src/blocks/TableBlockContent/TableExtension.js +57 -0
- package/dist/src/blocks/TableBlockContent/TableExtension.js.map +1 -0
- package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js +103 -0
- package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js.map +1 -0
- package/dist/src/blocks/VideoBlockContent/videoBlockHelpers.js +6 -0
- package/dist/src/blocks/VideoBlockContent/videoBlockHelpers.js.map +1 -0
- package/dist/src/blocks/defaultBlockHelpers.js +50 -0
- package/dist/src/blocks/defaultBlockHelpers.js.map +1 -0
- package/dist/src/blocks/defaultBlockTypeGuards.js +40 -0
- package/dist/src/blocks/defaultBlockTypeGuards.js.map +1 -0
- package/dist/src/blocks/defaultBlocks.js +50 -0
- package/dist/src/blocks/defaultBlocks.js.map +1 -0
- package/dist/src/blocks/defaultProps.js +19 -0
- package/dist/src/blocks/defaultProps.js.map +1 -0
- package/dist/src/editor/BlockNoteEditor.js +746 -0
- package/dist/src/editor/BlockNoteEditor.js.map +1 -0
- package/dist/src/editor/BlockNoteEditor.test.js +65 -0
- package/dist/src/editor/BlockNoteEditor.test.js.map +1 -0
- package/dist/src/editor/BlockNoteExtensions.js +195 -0
- package/dist/src/editor/BlockNoteExtensions.js.map +1 -0
- package/dist/src/editor/BlockNoteSchema.js +38 -0
- package/dist/src/editor/BlockNoteSchema.js.map +1 -0
- package/dist/src/editor/BlockNoteTipTapEditor.js +169 -0
- package/dist/src/editor/BlockNoteTipTapEditor.js.map +1 -0
- package/dist/src/editor/cursorPositionTypes.js +2 -0
- package/dist/src/editor/cursorPositionTypes.js.map +1 -0
- package/dist/src/editor/defaultColors.js +77 -0
- package/dist/src/editor/defaultColors.js.map +1 -0
- package/dist/src/editor/selectionTypes.js +2 -0
- package/dist/src/editor/selectionTypes.js.map +1 -0
- package/dist/src/editor/transformPasted.js +79 -0
- package/dist/src/editor/transformPasted.js.map +1 -0
- package/dist/src/exporter/Exporter.js +36 -0
- package/dist/src/exporter/Exporter.js.map +1 -0
- package/dist/src/exporter/index.js +3 -0
- package/dist/src/exporter/index.js.map +1 -0
- package/dist/src/exporter/mapping.js +12 -0
- package/dist/src/exporter/mapping.js.map +1 -0
- package/dist/src/extensions/BackgroundColor/BackgroundColorExtension.js +30 -0
- package/dist/src/extensions/BackgroundColor/BackgroundColorExtension.js.map +1 -0
- package/dist/src/extensions/BackgroundColor/BackgroundColorMark.js +39 -0
- package/dist/src/extensions/BackgroundColor/BackgroundColorMark.js.map +1 -0
- package/dist/src/extensions/FilePanel/FilePanelPlugin.js +131 -0
- package/dist/src/extensions/FilePanel/FilePanelPlugin.js.map +1 -0
- package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js +195 -0
- package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js.map +1 -0
- package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js +339 -0
- package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js.map +1 -0
- package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js +247 -0
- package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js.map +1 -0
- package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js +54 -0
- package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js.map +1 -0
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js +84 -0
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js.map +1 -0
- package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js +187 -0
- package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js.map +1 -0
- package/dist/src/extensions/SideMenu/MultipleNodeSelection.js +68 -0
- package/dist/src/extensions/SideMenu/MultipleNodeSelection.js.map +1 -0
- package/dist/src/extensions/SideMenu/SideMenuPlugin.js +339 -0
- package/dist/src/extensions/SideMenu/SideMenuPlugin.js.map +1 -0
- package/dist/src/extensions/SideMenu/dragging.js +128 -0
- package/dist/src/extensions/SideMenu/dragging.js.map +1 -0
- package/dist/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.js +2 -0
- package/dist/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.js.map +1 -0
- package/dist/src/extensions/SuggestionMenu/DefaultSuggestionItem.js +2 -0
- package/dist/src/extensions/SuggestionMenu/DefaultSuggestionItem.js.map +1 -0
- package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js +245 -0
- package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js.map +1 -0
- package/dist/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.js +26 -0
- package/dist/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.js.map +1 -0
- package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js +244 -0
- package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js.map +1 -0
- package/dist/src/extensions/TableHandles/TableHandlesPlugin.js +553 -0
- package/dist/src/extensions/TableHandles/TableHandlesPlugin.js.map +1 -0
- package/dist/src/extensions/TextAlignment/TextAlignmentExtension.js +36 -0
- package/dist/src/extensions/TextAlignment/TextAlignmentExtension.js.map +1 -0
- package/dist/src/extensions/TextColor/TextColorExtension.js +29 -0
- package/dist/src/extensions/TextColor/TextColorExtension.js.map +1 -0
- package/dist/src/extensions/TextColor/TextColorMark.js +37 -0
- package/dist/src/extensions/TextColor/TextColorMark.js.map +1 -0
- package/dist/src/extensions/TrailingNode/TrailingNodeExtension.js +58 -0
- package/dist/src/extensions/TrailingNode/TrailingNodeExtension.js.map +1 -0
- package/dist/src/extensions/UniqueID/UniqueID.js +283 -0
- package/dist/src/extensions/UniqueID/UniqueID.js.map +1 -0
- package/dist/src/extensions/getDraggableBlockFromElement.js +13 -0
- package/dist/src/extensions/getDraggableBlockFromElement.js.map +1 -0
- package/dist/src/extensions-shared/UiElementPosition.js +2 -0
- package/dist/src/extensions-shared/UiElementPosition.js.map +1 -0
- package/dist/src/i18n/dictionary.js +4 -0
- package/dist/src/i18n/dictionary.js.map +1 -0
- package/dist/src/i18n/locales/ar.js +298 -0
- package/dist/src/i18n/locales/ar.js.map +1 -0
- package/dist/src/i18n/locales/de.js +313 -0
- package/dist/src/i18n/locales/de.js.map +1 -0
- package/dist/src/i18n/locales/en.js +314 -0
- package/dist/src/i18n/locales/en.js.map +1 -0
- package/dist/src/i18n/locales/es.js +312 -0
- package/dist/src/i18n/locales/es.js.map +1 -0
- package/dist/src/i18n/locales/fr.js +313 -0
- package/dist/src/i18n/locales/fr.js.map +1 -0
- package/dist/src/i18n/locales/hr.js +308 -0
- package/dist/src/i18n/locales/hr.js.map +1 -0
- package/dist/src/i18n/locales/index.js +16 -0
- package/dist/src/i18n/locales/index.js.map +1 -0
- package/dist/src/i18n/locales/is.js +305 -0
- package/dist/src/i18n/locales/is.js.map +1 -0
- package/dist/src/i18n/locales/ja.js +333 -0
- package/dist/src/i18n/locales/ja.js.map +1 -0
- package/dist/src/i18n/locales/ko.js +326 -0
- package/dist/src/i18n/locales/ko.js.map +1 -0
- package/dist/src/i18n/locales/nl.js +313 -0
- package/dist/src/i18n/locales/nl.js.map +1 -0
- package/dist/src/i18n/locales/pl.js +297 -0
- package/dist/src/i18n/locales/pl.js.map +1 -0
- package/dist/src/i18n/locales/pt.js +305 -0
- package/dist/src/i18n/locales/pt.js.map +1 -0
- package/dist/src/i18n/locales/ru.js +340 -0
- package/dist/src/i18n/locales/ru.js.map +1 -0
- package/dist/src/i18n/locales/vi.js +312 -0
- package/dist/src/i18n/locales/vi.js.map +1 -0
- package/dist/src/i18n/locales/zh.js +346 -0
- package/dist/src/i18n/locales/zh.js.map +1 -0
- package/dist/src/index.js +55 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/pm-nodes/BlockContainer.js +72 -0
- package/dist/src/pm-nodes/BlockContainer.js.map +1 -0
- package/dist/src/pm-nodes/BlockGroup.js +43 -0
- package/dist/src/pm-nodes/BlockGroup.js.map +1 -0
- package/dist/src/pm-nodes/Doc.js +7 -0
- package/dist/src/pm-nodes/Doc.js.map +1 -0
- package/dist/src/pm-nodes/index.js +4 -0
- package/dist/src/pm-nodes/index.js.map +1 -0
- package/dist/src/schema/blocks/createSpec.js +126 -0
- package/dist/src/schema/blocks/createSpec.js.map +1 -0
- package/dist/src/schema/blocks/internal.js +147 -0
- package/dist/src/schema/blocks/internal.js.map +1 -0
- package/dist/src/schema/blocks/types.js +2 -0
- package/dist/src/schema/blocks/types.js.map +1 -0
- package/dist/src/schema/index.js +11 -0
- package/dist/src/schema/index.js.map +1 -0
- package/dist/src/schema/inlineContent/createSpec.js +64 -0
- package/dist/src/schema/inlineContent/createSpec.js.map +1 -0
- package/dist/src/schema/inlineContent/internal.js +52 -0
- package/dist/src/schema/inlineContent/internal.js.map +1 -0
- package/dist/src/schema/inlineContent/types.js +10 -0
- package/dist/src/schema/inlineContent/types.js.map +1 -0
- package/dist/src/schema/propTypes.js +2 -0
- package/dist/src/schema/propTypes.js.map +1 -0
- package/dist/src/schema/styles/createSpec.js +48 -0
- package/dist/src/schema/styles/createSpec.js.map +1 -0
- package/dist/src/schema/styles/internal.js +53 -0
- package/dist/src/schema/styles/internal.js.map +1 -0
- package/dist/src/schema/styles/types.js +2 -0
- package/dist/src/schema/styles/types.js.map +1 -0
- package/dist/src/util/EventEmitter.js +33 -0
- package/dist/src/util/EventEmitter.js.map +1 -0
- package/dist/src/util/browser.js +17 -0
- package/dist/src/util/browser.js.map +1 -0
- package/dist/src/util/combineByGroup.js +20 -0
- package/dist/src/util/combineByGroup.js.map +1 -0
- package/dist/src/util/esmDependencies.js +35 -0
- package/dist/src/util/esmDependencies.js.map +1 -0
- package/dist/src/util/string.js +14 -0
- package/dist/src/util/string.js.map +1 -0
- package/dist/src/util/typescript.js +12 -0
- package/dist/src/util/typescript.js.map +1 -0
- package/dist/style.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/webpack-stats.json +1 -1
- package/package.json +5 -5
- package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +0 -6
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +2 -0
- package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +0 -5
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +2 -2
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +104 -39
- package/src/api/blockManipulation/commands/moveBlock/__snapshots__/moveBlock.test.ts.snap +0 -8
- package/src/api/blockManipulation/commands/moveBlock/moveBlock.test.ts +7 -3
- package/src/api/blockManipulation/commands/moveBlock/moveBlock.ts +3 -5
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +100 -0
- package/src/api/blockManipulation/commands/removeBlocks/__snapshots__/removeBlocks.test.ts.snap +439 -2
- package/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.ts +6 -0
- package/src/api/blockManipulation/commands/removeBlocks/removeBlocks.ts +2 -82
- package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +0 -8
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +96 -20
- package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +0 -6
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +8 -4
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +13 -12
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +0 -490
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +5 -5
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +192 -107
- package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.ts +48 -33
- package/src/api/clipboard/fromClipboard/acceptedMIMETypes.ts +1 -1
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +7 -6
- package/src/api/clipboard/toClipboard/copyExtension.ts +1 -1
- package/src/api/exporters/html/htmlConversion.test.ts +1 -4
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +7 -1
- package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +56 -19
- package/src/api/exporters/markdown/markdownExporter.test.ts +1 -4
- package/src/api/getBlockInfoFromPos.ts +125 -80
- package/src/api/nodeConversions/blockToNode.ts +50 -25
- package/src/api/nodeConversions/fragmentToBlocks.ts +18 -0
- package/src/api/nodeConversions/nodeToBlock.ts +24 -21
- package/src/api/nodeUtil.ts +1 -1
- package/src/api/parsers/html/__snapshots__/parse-notion-html.json +1 -2
- package/src/api/testUtil/partialBlockTestUtil.ts +15 -3
- package/src/blocks/AudioBlockContent/AudioBlockContent.ts +4 -2
- package/src/blocks/FileBlockContent/fileBlockHelpers.ts +5 -4
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +35 -35
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +4 -2
- package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +14 -12
- package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +28 -16
- package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +5 -3
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +11 -4
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +13 -11
- package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +8 -9
- package/src/blocks/TableBlockContent/TableBlockContent.ts +0 -1
- package/src/blocks/VideoBlockContent/VideoBlockContent.ts +4 -2
- package/src/blocks/defaultBlockHelpers.ts +7 -2
- package/src/editor/Block.css +22 -1
- package/src/editor/BlockNoteEditor.test.ts +4 -7
- package/src/editor/BlockNoteEditor.ts +87 -61
- package/src/editor/BlockNoteExtensions.ts +92 -17
- package/src/editor/BlockNoteTipTapEditor.ts +8 -1
- package/src/editor/defaultColors.ts +77 -0
- package/src/editor/editor.css +10 -0
- package/src/editor/transformPasted.ts +6 -3
- package/src/exporter/Exporter.ts +101 -0
- package/src/exporter/index.ts +2 -0
- package/src/exporter/mapping.ts +75 -0
- package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +233 -53
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.ts +45 -42
- package/src/extensions/Placeholder/PlaceholderPlugin.ts +94 -90
- package/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.ts +173 -169
- package/src/extensions/SideMenu/SideMenuPlugin.ts +141 -52
- package/src/extensions/SideMenu/dragging.ts +3 -54
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +4 -6
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +1 -1
- package/src/extensions/TrailingNode/TrailingNodeExtension.ts +1 -1
- package/src/extensions/getDraggableBlockFromElement.ts +19 -0
- package/src/i18n/locales/de.ts +5 -5
- package/src/i18n/locales/pt.ts +5 -5
- package/src/index.ts +9 -5
- package/src/pm-nodes/BlockContainer.ts +1 -1
- package/src/pm-nodes/BlockGroup.ts +2 -2
- package/src/pm-nodes/README.md +127 -28
- package/src/schema/blocks/createSpec.ts +4 -1
- package/src/schema/blocks/internal.ts +12 -2
- package/src/schema/blocks/types.ts +1 -1
- package/src/util/combineByGroup.ts +25 -0
- package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.d.ts +22 -2
- package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.d.ts +5 -0
- package/types/src/api/blockManipulation/commands/removeBlocks/removeBlocks.d.ts +0 -3
- package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.d.ts +4 -0
- package/types/src/api/blockManipulation/setupTestEnv.d.ts +0 -6
- package/types/src/api/clipboard/fromClipboard/acceptedMIMETypes.d.ts +1 -1
- package/types/src/api/getBlockInfoFromPos.d.ts +38 -13
- package/types/src/api/nodeConversions/blockToNode.d.ts +1 -1
- package/types/src/api/nodeConversions/nodeToBlock.d.ts +3 -1
- package/types/src/api/testUtil/cases/customBlocks.d.ts +0 -6
- package/types/src/api/testUtil/cases/customInlineContent.d.ts +0 -6
- package/types/src/api/testUtil/cases/customStyles.d.ts +0 -6
- package/types/src/api/testUtil/partialBlockTestUtil.d.ts +2 -1
- package/types/src/blocks/AudioBlockContent/AudioBlockContent.d.ts +1 -0
- package/types/src/blocks/FileBlockContent/fileBlockHelpers.d.ts +1 -0
- package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +1 -0
- package/types/src/blocks/TableBlockContent/TableBlockContent.d.ts +0 -9
- package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +1 -0
- package/types/src/blocks/defaultBlocks.d.ts +0 -12
- package/types/src/editor/BlockNoteEditor.d.ts +23 -5
- package/types/src/editor/BlockNoteExtensions.d.ts +14 -7
- package/types/src/editor/BlockNoteTipTapEditor.d.ts +1 -0
- package/types/src/editor/defaultColors.d.ts +76 -0
- package/types/src/exporter/Exporter.d.ts +43 -0
- package/types/src/exporter/index.d.ts +2 -0
- package/types/src/exporter/mapping.d.ts +30 -0
- package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.d.ts +4 -1
- package/types/src/extensions/Placeholder/PlaceholderPlugin.d.ts +4 -1
- package/types/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.d.ts +4 -5
- package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +2 -1
- package/types/src/extensions/SideMenu/dragging.d.ts +1 -6
- package/types/src/extensions/getDraggableBlockFromElement.d.ts +5 -0
- package/types/src/index.d.ts +9 -5
- package/types/src/schema/blocks/createSpec.d.ts +1 -1
- package/types/src/schema/blocks/internal.d.ts +2 -2
- package/types/src/schema/blocks/types.d.ts +1 -1
- package/types/src/util/combineByGroup.d.ts +9 -0
- package/dist/angular-html-HQGguTAE.js +0 -33
- package/dist/angular-html-HQGguTAE.js.map +0 -1
- package/dist/angular-ts-q9PqJiJb.js +0 -22
- package/dist/angular-ts-q9PqJiJb.js.map +0 -1
- package/dist/astro-0iWgpDaK.js +0 -17
- package/dist/astro-0iWgpDaK.js.map +0 -1
- package/dist/blade-C3Z8AhvY.js +0 -19
- package/dist/blade-C3Z8AhvY.js.map +0 -1
- package/dist/c-TKJGJdXV.js +0 -7
- package/dist/c-TKJGJdXV.js.map +0 -1
- package/dist/coffee-CN_y6cG3.js +0 -9
- package/dist/coffee-CN_y6cG3.js.map +0 -1
- package/dist/cpp-Be_e67JE.js +0 -19
- package/dist/cpp-Be_e67JE.js.map +0 -1
- package/dist/css-DHLSoXzW.js +0 -7
- package/dist/css-DHLSoXzW.js.map +0 -1
- package/dist/glsl-8qSUIm5B.js +0 -9
- package/dist/glsl-8qSUIm5B.js.map +0 -1
- package/dist/graphql-D7_Dk2ma.js +0 -15
- package/dist/graphql-D7_Dk2ma.js.map +0 -1
- package/dist/haml-S3dmcfEW.js +0 -11
- package/dist/haml-S3dmcfEW.js.map +0 -1
- package/dist/handlebars-DaIrqVg3.js +0 -15
- package/dist/handlebars-DaIrqVg3.js.map +0 -1
- package/dist/html-Bx3A18fV.js +0 -11
- package/dist/html-Bx3A18fV.js.map +0 -1
- package/dist/html-derivative-Cf3KTZBS.js +0 -9
- package/dist/html-derivative-Cf3KTZBS.js.map +0 -1
- package/dist/http-BphR83YX.js +0 -15
- package/dist/http-BphR83YX.js.map +0 -1
- package/dist/imba-CmP25v0O.js +0 -9
- package/dist/imba-CmP25v0O.js.map +0 -1
- package/dist/java-Dg4kxH6C.js +0 -7
- package/dist/java-Dg4kxH6C.js.map +0 -1
- package/dist/javascript-CipAzIn1.js +0 -7
- package/dist/javascript-CipAzIn1.js.map +0 -1
- package/dist/jinja-tioldiz6.js +0 -12
- package/dist/jinja-tioldiz6.js.map +0 -1
- package/dist/jison-DWJFEE_I.js +0 -9
- package/dist/jison-DWJFEE_I.js.map +0 -1
- package/dist/json-_04EL6MS.js +0 -7
- package/dist/json-_04EL6MS.js.map +0 -1
- package/dist/json5-Dwmp5XFI.js +0 -7
- package/dist/json5-Dwmp5XFI.js.map +0 -1
- package/dist/jsonc-LqD5auy0.js +0 -7
- package/dist/jsonc-LqD5auy0.js.map +0 -1
- package/dist/jsonl-B4yVuYQH.js +0 -7
- package/dist/jsonl-B4yVuYQH.js.map +0 -1
- package/dist/jsx-Mg4WaD5k.js +0 -7
- package/dist/jsx-Mg4WaD5k.js.map +0 -1
- package/dist/julia-CWi-ZdpN.js +0 -17
- package/dist/julia-CWi-ZdpN.js.map +0 -1
- package/dist/less-BBvTHIGe.js +0 -7
- package/dist/less-BBvTHIGe.js.map +0 -1
- package/dist/markdown-DAXqtk9a.js +0 -7
- package/dist/markdown-DAXqtk9a.js.map +0 -1
- package/dist/marko-0aaNgUGV.js +0 -15
- package/dist/marko-0aaNgUGV.js.map +0 -1
- package/dist/mdc-hXJ2B4O0.js +0 -13
- package/dist/mdc-hXJ2B4O0.js.map +0 -1
- package/dist/mdx-CSCKbb_f.js +0 -7
- package/dist/mdx-CSCKbb_f.js.map +0 -1
- package/dist/php-B_-4RJ09.js +0 -19
- package/dist/php-B_-4RJ09.js.map +0 -1
- package/dist/postcss-SJfTvo_B.js +0 -7
- package/dist/postcss-SJfTvo_B.js.map +0 -1
- package/dist/pug-3q2tx0nf.js +0 -13
- package/dist/pug-3q2tx0nf.js.map +0 -1
- package/dist/python-Dpup1-fE.js +0 -7
- package/dist/python-Dpup1-fE.js.map +0 -1
- package/dist/r-Chyv38Fv.js +0 -7
- package/dist/r-Chyv38Fv.js.map +0 -1
- package/dist/regexp-BF0hfxNW.js +0 -7
- package/dist/regexp-BF0hfxNW.js.map +0 -1
- package/dist/sass-p2RMoqDT.js +0 -7
- package/dist/sass-p2RMoqDT.js.map +0 -1
- package/dist/scss-DmlHSoOY.js +0 -9
- package/dist/scss-DmlHSoOY.js.map +0 -1
- package/dist/shellscript-CZpPN8_x.js +0 -7
- package/dist/shellscript-CZpPN8_x.js.map +0 -1
- package/dist/sql-DtlkUz2m.js +0 -7
- package/dist/sql-DtlkUz2m.js.map +0 -1
- package/dist/stylus-DEr8eSLm.js +0 -7
- package/dist/stylus-DEr8eSLm.js.map +0 -1
- package/dist/svelte-BRIJF62h.js +0 -15
- package/dist/svelte-BRIJF62h.js.map +0 -1
- package/dist/ts-tags-qkUtuI0N.js +0 -42
- package/dist/ts-tags-qkUtuI0N.js.map +0 -1
- package/dist/tsx-DTfbgJxi.js +0 -7
- package/dist/tsx-DTfbgJxi.js.map +0 -1
- package/dist/typescript-CCd4aQHh.js +0 -7
- package/dist/typescript-CCd4aQHh.js.map +0 -1
- package/dist/vue-B3TdbERm.js +0 -32
- package/dist/vue-B3TdbERm.js.map +0 -1
- package/dist/vue-html-BGmTBZk0.js +0 -11
- package/dist/vue-html-BGmTBZk0.js.map +0 -1
- package/dist/wasm-VDIDph3E.js +0 -7
- package/dist/wasm-VDIDph3E.js.map +0 -1
- package/dist/wgsl-2np_U3Z8.js +0 -7
- package/dist/wgsl-2np_U3Z8.js.map +0 -1
- package/dist/xml-CNyphW9R.js +0 -9
- package/dist/xml-CNyphW9R.js.map +0 -1
- package/dist/yaml-DxFiVFcM.js +0 -7
- package/dist/yaml-DxFiVFcM.js.map +0 -1
|
@@ -8,29 +8,59 @@ type SingleBlockInfo = {
|
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
export type BlockInfo = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
/**
|
|
12
|
+
* The outer node that represents a BlockNote block. This is the node that has the ID.
|
|
13
|
+
* Most of the time, this will be a blockContainer node, but it could also be a Column or ColumnList
|
|
14
|
+
*/
|
|
15
|
+
bnBlock: SingleBlockInfo;
|
|
16
|
+
/**
|
|
17
|
+
* The type of BlockNote block that this node represents.
|
|
18
|
+
* When dealing with a blockContainer, this is retrieved from the blockContent node, otherwise it's retrieved from the bnBlock node.
|
|
19
|
+
*/
|
|
20
|
+
blockNoteType: string;
|
|
21
|
+
} & (
|
|
22
|
+
| {
|
|
23
|
+
// In case we're not dealing with a BlockContainer, we're dealing with a "wrapper node" (like a Column or ColumnList), so it will always have children
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The Prosemirror node that holds block.children. For non-blockContainer, this node will be the same as bnBlock.
|
|
27
|
+
*/
|
|
28
|
+
childContainer: SingleBlockInfo;
|
|
29
|
+
isBlockContainer: false;
|
|
30
|
+
}
|
|
31
|
+
| {
|
|
32
|
+
/**
|
|
33
|
+
* The Prosemirror node that holds block.children. For blockContainers, this is the blockGroup node, if it exists.
|
|
34
|
+
*/
|
|
35
|
+
childContainer?: SingleBlockInfo;
|
|
36
|
+
/**
|
|
37
|
+
* The Prosemirror node that wraps block.content and has most of the props
|
|
38
|
+
*/
|
|
39
|
+
blockContent: SingleBlockInfo;
|
|
40
|
+
/**
|
|
41
|
+
* Whether bnBlock is a blockContainer node
|
|
42
|
+
*/
|
|
43
|
+
isBlockContainer: true;
|
|
44
|
+
}
|
|
45
|
+
);
|
|
15
46
|
|
|
16
47
|
/**
|
|
17
|
-
* Retrieves the position just before the nearest
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* just before the last blockContainer is returned.
|
|
48
|
+
* Retrieves the position just before the nearest block node in a ProseMirror
|
|
49
|
+
* doc, relative to a position. If the position is within a block node or its
|
|
50
|
+
* descendants, the position just before it is returned. If the position is not
|
|
51
|
+
* within a block node or its descendants, the position just before the next
|
|
52
|
+
* closest block node is returned. If the position is beyond the last block, the
|
|
53
|
+
* position just before the last block is returned.
|
|
24
54
|
* @param doc The ProseMirror doc.
|
|
25
55
|
* @param pos An integer position in the document.
|
|
26
56
|
* @returns The position just before the nearest blockContainer node.
|
|
27
57
|
*/
|
|
28
|
-
export function
|
|
58
|
+
export function getNearestBlockPos(doc: Node, pos: number) {
|
|
29
59
|
const $pos = doc.resolve(pos);
|
|
30
60
|
|
|
31
|
-
// Checks if the position provided is already just before a
|
|
32
|
-
//
|
|
33
|
-
if ($pos.nodeAfter && $pos.nodeAfter.type.
|
|
61
|
+
// Checks if the position provided is already just before a block node, in
|
|
62
|
+
// which case we return the position.
|
|
63
|
+
if ($pos.nodeAfter && $pos.nodeAfter.type.isInGroup("bnBlock")) {
|
|
34
64
|
return {
|
|
35
65
|
posBeforeNode: $pos.pos,
|
|
36
66
|
node: $pos.nodeAfter,
|
|
@@ -38,11 +68,11 @@ export function getNearestBlockContainerPos(doc: Node, pos: number) {
|
|
|
38
68
|
}
|
|
39
69
|
|
|
40
70
|
// Checks the node containing the position and its ancestors until a
|
|
41
|
-
//
|
|
71
|
+
// block node is found and returned.
|
|
42
72
|
let depth = $pos.depth;
|
|
43
73
|
let node = $pos.node(depth);
|
|
44
74
|
while (depth > 0) {
|
|
45
|
-
if (node.type.
|
|
75
|
+
if (node.type.isInGroup("bnBlock")) {
|
|
46
76
|
return {
|
|
47
77
|
posBeforeNode: $pos.before(depth),
|
|
48
78
|
node: node,
|
|
@@ -53,16 +83,15 @@ export function getNearestBlockContainerPos(doc: Node, pos: number) {
|
|
|
53
83
|
node = $pos.node(depth);
|
|
54
84
|
}
|
|
55
85
|
|
|
56
|
-
// If the position doesn't lie within a
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
// collaboration plugin.
|
|
86
|
+
// If the position doesn't lie within a block node, we instead find the
|
|
87
|
+
// position of the next closest one. If the position is beyond the last block,
|
|
88
|
+
// we return the position of the last block. While running `doc.descendants`
|
|
89
|
+
// is expensive, this case should be very rarely triggered. However, it's
|
|
90
|
+
// possible for the position to sometimes be beyond the last block node. This
|
|
91
|
+
// is a problem specifically when using the collaboration plugin.
|
|
63
92
|
const allBlockContainerPositions: number[] = [];
|
|
64
93
|
doc.descendants((node, pos) => {
|
|
65
|
-
if (node.type.
|
|
94
|
+
if (node.type.isInGroup("bnBlock")) {
|
|
66
95
|
allBlockContainerPositions.push(pos);
|
|
67
96
|
}
|
|
68
97
|
});
|
|
@@ -88,62 +117,85 @@ export function getNearestBlockContainerPos(doc: Node, pos: number) {
|
|
|
88
117
|
* the ProseMirror positions just before & after each node.
|
|
89
118
|
* @param node The main `blockContainer` node that the block information should
|
|
90
119
|
* be retrieved from,
|
|
91
|
-
* @param
|
|
120
|
+
* @param bnBlockBeforePosOffset the position just before the
|
|
92
121
|
* `blockContainer` node in the document.
|
|
93
122
|
*/
|
|
94
123
|
export function getBlockInfoWithManualOffset(
|
|
95
124
|
node: Node,
|
|
96
|
-
|
|
125
|
+
bnBlockBeforePosOffset: number
|
|
97
126
|
): BlockInfo {
|
|
98
|
-
|
|
99
|
-
const blockContainerBeforePos = blockContainerBeforePosOffset;
|
|
100
|
-
const blockContainerAfterPos =
|
|
101
|
-
blockContainerBeforePos + blockContainerNode.nodeSize;
|
|
102
|
-
|
|
103
|
-
const blockContainer: SingleBlockInfo = {
|
|
104
|
-
node: blockContainerNode,
|
|
105
|
-
beforePos: blockContainerBeforePos,
|
|
106
|
-
afterPos: blockContainerAfterPos,
|
|
107
|
-
};
|
|
108
|
-
let blockContent: SingleBlockInfo | undefined = undefined;
|
|
109
|
-
let blockGroup: SingleBlockInfo | undefined = undefined;
|
|
110
|
-
|
|
111
|
-
blockContainerNode.forEach((node, offset) => {
|
|
112
|
-
if (node.type.spec.group === "blockContent") {
|
|
113
|
-
// console.log(beforePos, offset);
|
|
114
|
-
const blockContentNode = node;
|
|
115
|
-
const blockContentBeforePos = blockContainerBeforePos + offset + 1;
|
|
116
|
-
const blockContentAfterPos = blockContentBeforePos + node.nodeSize;
|
|
117
|
-
|
|
118
|
-
blockContent = {
|
|
119
|
-
node: blockContentNode,
|
|
120
|
-
beforePos: blockContentBeforePos,
|
|
121
|
-
afterPos: blockContentAfterPos,
|
|
122
|
-
};
|
|
123
|
-
} else if (node.type.name === "blockGroup") {
|
|
124
|
-
const blockGroupNode = node;
|
|
125
|
-
const blockGroupBeforePos = blockContainerBeforePos + offset + 1;
|
|
126
|
-
const blockGroupAfterPos = blockGroupBeforePos + node.nodeSize;
|
|
127
|
-
|
|
128
|
-
blockGroup = {
|
|
129
|
-
node: blockGroupNode,
|
|
130
|
-
beforePos: blockGroupBeforePos,
|
|
131
|
-
afterPos: blockGroupAfterPos,
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
if (!blockContent) {
|
|
127
|
+
if (!node.type.isInGroup("bnBlock")) {
|
|
137
128
|
throw new Error(
|
|
138
|
-
`
|
|
129
|
+
`Attempted to get bnBlock node at position but found node of different type ${node.type}`
|
|
139
130
|
);
|
|
140
131
|
}
|
|
141
132
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
133
|
+
const bnBlockNode = node;
|
|
134
|
+
const bnBlockBeforePos = bnBlockBeforePosOffset;
|
|
135
|
+
const bnBlockAfterPos = bnBlockBeforePos + bnBlockNode.nodeSize;
|
|
136
|
+
|
|
137
|
+
const bnBlock: SingleBlockInfo = {
|
|
138
|
+
node: bnBlockNode,
|
|
139
|
+
beforePos: bnBlockBeforePos,
|
|
140
|
+
afterPos: bnBlockAfterPos,
|
|
146
141
|
};
|
|
142
|
+
|
|
143
|
+
if (bnBlockNode.type.name === "blockContainer") {
|
|
144
|
+
let blockContent: SingleBlockInfo | undefined;
|
|
145
|
+
let blockGroup: SingleBlockInfo | undefined;
|
|
146
|
+
|
|
147
|
+
bnBlockNode.forEach((node, offset) => {
|
|
148
|
+
if (node.type.spec.group === "blockContent") {
|
|
149
|
+
// console.log(beforePos, offset);
|
|
150
|
+
const blockContentNode = node;
|
|
151
|
+
const blockContentBeforePos = bnBlockBeforePos + offset + 1;
|
|
152
|
+
const blockContentAfterPos = blockContentBeforePos + node.nodeSize;
|
|
153
|
+
|
|
154
|
+
blockContent = {
|
|
155
|
+
node: blockContentNode,
|
|
156
|
+
beforePos: blockContentBeforePos,
|
|
157
|
+
afterPos: blockContentAfterPos,
|
|
158
|
+
};
|
|
159
|
+
} else if (node.type.name === "blockGroup") {
|
|
160
|
+
const blockGroupNode = node;
|
|
161
|
+
const blockGroupBeforePos = bnBlockBeforePos + offset + 1;
|
|
162
|
+
const blockGroupAfterPos = blockGroupBeforePos + node.nodeSize;
|
|
163
|
+
|
|
164
|
+
blockGroup = {
|
|
165
|
+
node: blockGroupNode,
|
|
166
|
+
beforePos: blockGroupBeforePos,
|
|
167
|
+
afterPos: blockGroupAfterPos,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
if (!blockContent) {
|
|
173
|
+
throw new Error(
|
|
174
|
+
`blockContainer node does not contain a blockContent node in its children: ${bnBlockNode}`
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return {
|
|
179
|
+
isBlockContainer: true,
|
|
180
|
+
bnBlock,
|
|
181
|
+
blockContent,
|
|
182
|
+
childContainer: blockGroup,
|
|
183
|
+
blockNoteType: blockContent.node.type.name,
|
|
184
|
+
};
|
|
185
|
+
} else {
|
|
186
|
+
if (!bnBlock.node.type.isInGroup("childContainer")) {
|
|
187
|
+
throw new Error(
|
|
188
|
+
`bnBlock node is not in the childContainer group: ${bnBlock.node}`
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return {
|
|
193
|
+
isBlockContainer: false,
|
|
194
|
+
bnBlock: bnBlock,
|
|
195
|
+
childContainer: bnBlock,
|
|
196
|
+
blockNoteType: bnBlock.node.type.name,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
147
199
|
}
|
|
148
200
|
|
|
149
201
|
/**
|
|
@@ -173,11 +225,6 @@ export function getBlockInfoFromResolvedPos(resolvedPos: ResolvedPos) {
|
|
|
173
225
|
`Attempted to get blockContainer node at position ${resolvedPos.pos} but a node at this position does not exist`
|
|
174
226
|
);
|
|
175
227
|
}
|
|
176
|
-
if (resolvedPos.nodeAfter.type.name !== "blockContainer") {
|
|
177
|
-
throw new Error(
|
|
178
|
-
`Attempted to get blockContainer node at position ${resolvedPos.pos} but found node of different type ${resolvedPos.nodeAfter}`
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
228
|
return getBlockInfoWithManualOffset(resolvedPos.nodeAfter, resolvedPos.pos);
|
|
182
229
|
}
|
|
183
230
|
|
|
@@ -188,9 +235,7 @@ export function getBlockInfoFromResolvedPos(resolvedPos: ResolvedPos) {
|
|
|
188
235
|
* @param state The ProseMirror editor state.
|
|
189
236
|
*/
|
|
190
237
|
export function getBlockInfoFromSelection(state: EditorState) {
|
|
191
|
-
const posInfo =
|
|
192
|
-
|
|
193
|
-
state.selection.anchor
|
|
194
|
-
);
|
|
238
|
+
const posInfo = getNearestBlockPos(state.doc, state.selection.anchor);
|
|
239
|
+
|
|
195
240
|
return getBlockInfo(posInfo);
|
|
196
241
|
}
|
|
@@ -54,7 +54,7 @@ function styledTextToNodes<T extends StyleSchema>(
|
|
|
54
54
|
// Converts text & line breaks to nodes.
|
|
55
55
|
.map((text) => {
|
|
56
56
|
if (text === "\n") {
|
|
57
|
-
return schema.nodes["hardBreak"].
|
|
57
|
+
return schema.nodes["hardBreak"].createChecked();
|
|
58
58
|
} else {
|
|
59
59
|
return schema.text(text, marks);
|
|
60
60
|
}
|
|
@@ -165,15 +165,18 @@ export function tableContentToNodes<
|
|
|
165
165
|
const cell = row.cells[i];
|
|
166
166
|
let pNode: Node;
|
|
167
167
|
if (!cell) {
|
|
168
|
-
pNode = schema.nodes["tableParagraph"].
|
|
168
|
+
pNode = schema.nodes["tableParagraph"].createChecked({});
|
|
169
169
|
} else if (typeof cell === "string") {
|
|
170
|
-
pNode = schema.nodes["tableParagraph"].
|
|
170
|
+
pNode = schema.nodes["tableParagraph"].createChecked(
|
|
171
|
+
{},
|
|
172
|
+
schema.text(cell)
|
|
173
|
+
);
|
|
171
174
|
} else {
|
|
172
175
|
const textNodes = inlineContentToNodes(cell, schema, styleSchema);
|
|
173
|
-
pNode = schema.nodes["tableParagraph"].
|
|
176
|
+
pNode = schema.nodes["tableParagraph"].createChecked({}, textNodes);
|
|
174
177
|
}
|
|
175
178
|
|
|
176
|
-
const cellNode = schema.nodes["tableCell"].
|
|
179
|
+
const cellNode = schema.nodes["tableCell"].createChecked(
|
|
177
180
|
{
|
|
178
181
|
// The colwidth array should have multiple values when the colspan of
|
|
179
182
|
// a cell is greater than 1. However, this is not yet implemented so
|
|
@@ -186,7 +189,7 @@ export function tableContentToNodes<
|
|
|
186
189
|
);
|
|
187
190
|
columnNodes.push(cellNode);
|
|
188
191
|
}
|
|
189
|
-
const rowNode = schema.nodes["tableRow"].
|
|
192
|
+
const rowNode = schema.nodes["tableRow"].createChecked({}, columnNodes);
|
|
190
193
|
rowNodes.push(rowNode);
|
|
191
194
|
}
|
|
192
195
|
return rowNodes;
|
|
@@ -212,16 +215,16 @@ function blockOrInlineContentToContentNode(
|
|
|
212
215
|
}
|
|
213
216
|
|
|
214
217
|
if (!block.content) {
|
|
215
|
-
contentNode = schema.nodes[type].
|
|
218
|
+
contentNode = schema.nodes[type].createChecked(block.props);
|
|
216
219
|
} else if (typeof block.content === "string") {
|
|
217
220
|
const nodes = inlineContentToNodes([block.content], schema, styleSchema);
|
|
218
|
-
contentNode = schema.nodes[type].
|
|
221
|
+
contentNode = schema.nodes[type].createChecked(block.props, nodes);
|
|
219
222
|
} else if (Array.isArray(block.content)) {
|
|
220
223
|
const nodes = inlineContentToNodes(block.content, schema, styleSchema);
|
|
221
|
-
contentNode = schema.nodes[type].
|
|
224
|
+
contentNode = schema.nodes[type].createChecked(block.props, nodes);
|
|
222
225
|
} else if (block.content.type === "tableContent") {
|
|
223
226
|
const nodes = tableContentToNodes(block.content, schema, styleSchema);
|
|
224
|
-
contentNode = schema.nodes[type].
|
|
227
|
+
contentNode = schema.nodes[type].createChecked(block.props, nodes);
|
|
225
228
|
} else {
|
|
226
229
|
throw new UnreachableCaseError(block.content.type);
|
|
227
230
|
}
|
|
@@ -229,7 +232,7 @@ function blockOrInlineContentToContentNode(
|
|
|
229
232
|
}
|
|
230
233
|
|
|
231
234
|
/**
|
|
232
|
-
* Converts a BlockNote block to a
|
|
235
|
+
* Converts a BlockNote block to a Prosemirror node.
|
|
233
236
|
*/
|
|
234
237
|
export function blockToNode(
|
|
235
238
|
block: PartialBlock<any, any, any>,
|
|
@@ -242,12 +245,6 @@ export function blockToNode(
|
|
|
242
245
|
id = UniqueID.options.generateID();
|
|
243
246
|
}
|
|
244
247
|
|
|
245
|
-
const contentNode = blockOrInlineContentToContentNode(
|
|
246
|
-
block,
|
|
247
|
-
schema,
|
|
248
|
-
styleSchema
|
|
249
|
-
);
|
|
250
|
-
|
|
251
248
|
const children: Node[] = [];
|
|
252
249
|
|
|
253
250
|
if (block.children) {
|
|
@@ -256,13 +253,41 @@ export function blockToNode(
|
|
|
256
253
|
}
|
|
257
254
|
}
|
|
258
255
|
|
|
259
|
-
const
|
|
256
|
+
const nodeTypeCorrespondingToBlock = schema.nodes[block.type];
|
|
260
257
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
258
|
+
if (nodeTypeCorrespondingToBlock.isInGroup("blockContent")) {
|
|
259
|
+
// Blocks with a type that matches "blockContent" group always need to be wrapped in a blockContainer
|
|
260
|
+
|
|
261
|
+
const contentNode = blockOrInlineContentToContentNode(
|
|
262
|
+
block,
|
|
263
|
+
schema,
|
|
264
|
+
styleSchema
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
const groupNode =
|
|
268
|
+
children.length > 0
|
|
269
|
+
? schema.nodes["blockGroup"].createChecked({}, children)
|
|
270
|
+
: undefined;
|
|
271
|
+
|
|
272
|
+
return schema.nodes["blockContainer"].createChecked(
|
|
273
|
+
{
|
|
274
|
+
id: id,
|
|
275
|
+
...block.props,
|
|
276
|
+
},
|
|
277
|
+
groupNode ? [contentNode, groupNode] : contentNode
|
|
278
|
+
);
|
|
279
|
+
} else if (nodeTypeCorrespondingToBlock.isInGroup("bnBlock")) {
|
|
280
|
+
// this is a bnBlock node like Column or ColumnList that directly translates to a prosemirror node
|
|
281
|
+
return schema.nodes[block.type].createChecked(
|
|
282
|
+
{
|
|
283
|
+
id: id,
|
|
284
|
+
...block.props,
|
|
285
|
+
},
|
|
286
|
+
children
|
|
287
|
+
);
|
|
288
|
+
} else {
|
|
289
|
+
throw new Error(
|
|
290
|
+
`block type ${block.type} doesn't match blockContent or bnBlock group`
|
|
291
|
+
);
|
|
292
|
+
}
|
|
268
293
|
}
|
|
@@ -43,6 +43,24 @@ export function fragmentToBlocks<
|
|
|
43
43
|
// so we don't need to serialize this block, just descend into the children of the blockGroup
|
|
44
44
|
return true;
|
|
45
45
|
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (node.type.name === "columnList" && node.childCount === 1) {
|
|
49
|
+
// column lists with a single column should be flattened (not the entire column list has been selected)
|
|
50
|
+
node.firstChild?.forEach((child) => {
|
|
51
|
+
blocks.push(
|
|
52
|
+
nodeToBlock(
|
|
53
|
+
child,
|
|
54
|
+
schema.blockSchema,
|
|
55
|
+
schema.inlineContentSchema,
|
|
56
|
+
schema.styleSchema
|
|
57
|
+
)
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (node.type.isInGroup("bnBlock")) {
|
|
46
64
|
blocks.push(
|
|
47
65
|
nodeToBlock(
|
|
48
66
|
node,
|
|
@@ -306,7 +306,9 @@ export function nodeToCustomInlineContent<
|
|
|
306
306
|
}
|
|
307
307
|
|
|
308
308
|
/**
|
|
309
|
-
* Convert a
|
|
309
|
+
* Convert a Prosemirror node to a BlockNote block.
|
|
310
|
+
*
|
|
311
|
+
* TODO: test changes
|
|
310
312
|
*/
|
|
311
313
|
export function nodeToBlock<
|
|
312
314
|
BSchema extends BlockSchema,
|
|
@@ -319,11 +321,9 @@ export function nodeToBlock<
|
|
|
319
321
|
styleSchema: S,
|
|
320
322
|
blockCache?: WeakMap<Node, Block<BSchema, I, S>>
|
|
321
323
|
): Block<BSchema, I, S> {
|
|
322
|
-
if (node.type.
|
|
324
|
+
if (!node.type.isInGroup("bnBlock")) {
|
|
323
325
|
throw Error(
|
|
324
|
-
"Node must be
|
|
325
|
-
node.type.name +
|
|
326
|
-
"."
|
|
326
|
+
"Node must be in bnBlock group, but is of type" + node.type.name
|
|
327
327
|
);
|
|
328
328
|
}
|
|
329
329
|
|
|
@@ -333,29 +333,26 @@ export function nodeToBlock<
|
|
|
333
333
|
return cachedBlock;
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
-
const
|
|
337
|
-
getBlockInfoWithManualOffset(node, 0);
|
|
336
|
+
const blockInfo = getBlockInfoWithManualOffset(node, 0);
|
|
338
337
|
|
|
339
|
-
let id =
|
|
338
|
+
let id = blockInfo.bnBlock.node.attrs.id;
|
|
340
339
|
|
|
341
340
|
// Only used for blocks converted from other formats.
|
|
342
341
|
if (id === null) {
|
|
343
342
|
id = UniqueID.options.generateID();
|
|
344
343
|
}
|
|
345
344
|
|
|
345
|
+
const blockSpec = blockSchema[blockInfo.blockNoteType];
|
|
346
|
+
|
|
347
|
+
if (!blockSpec) {
|
|
348
|
+
throw Error("Block is of an unrecognized type: " + blockInfo.blockNoteType);
|
|
349
|
+
}
|
|
350
|
+
|
|
346
351
|
const props: any = {};
|
|
347
352
|
for (const [attr, value] of Object.entries({
|
|
348
353
|
...node.attrs,
|
|
349
|
-
...blockContent.node.attrs,
|
|
354
|
+
...(blockInfo.isBlockContainer ? blockInfo.blockContent.node.attrs : {}),
|
|
350
355
|
})) {
|
|
351
|
-
const blockSpec = blockSchema[blockContent.node.type.name];
|
|
352
|
-
|
|
353
|
-
if (!blockSpec) {
|
|
354
|
-
throw Error(
|
|
355
|
-
"Block is of an unrecognized type: " + blockContent.node.type.name
|
|
356
|
-
);
|
|
357
|
-
}
|
|
358
|
-
|
|
359
356
|
const propSchema = blockSpec.propSchema;
|
|
360
357
|
|
|
361
358
|
if (attr in propSchema) {
|
|
@@ -363,10 +360,10 @@ export function nodeToBlock<
|
|
|
363
360
|
}
|
|
364
361
|
}
|
|
365
362
|
|
|
366
|
-
const blockConfig = blockSchema[
|
|
363
|
+
const blockConfig = blockSchema[blockInfo.blockNoteType];
|
|
367
364
|
|
|
368
365
|
const children: Block<BSchema, I, S>[] = [];
|
|
369
|
-
|
|
366
|
+
blockInfo.childContainer?.node.forEach((child) => {
|
|
370
367
|
children.push(
|
|
371
368
|
nodeToBlock(
|
|
372
369
|
child,
|
|
@@ -381,14 +378,20 @@ export function nodeToBlock<
|
|
|
381
378
|
let content: Block<any, any, any>["content"];
|
|
382
379
|
|
|
383
380
|
if (blockConfig.content === "inline") {
|
|
381
|
+
if (!blockInfo.isBlockContainer) {
|
|
382
|
+
throw new Error("impossible");
|
|
383
|
+
}
|
|
384
384
|
content = contentNodeToInlineContent(
|
|
385
|
-
blockContent.node,
|
|
385
|
+
blockInfo.blockContent.node,
|
|
386
386
|
inlineContentSchema,
|
|
387
387
|
styleSchema
|
|
388
388
|
);
|
|
389
389
|
} else if (blockConfig.content === "table") {
|
|
390
|
+
if (!blockInfo.isBlockContainer) {
|
|
391
|
+
throw new Error("impossible");
|
|
392
|
+
}
|
|
390
393
|
content = contentNodeToTableContent(
|
|
391
|
-
blockContent.node,
|
|
394
|
+
blockInfo.blockContent.node,
|
|
392
395
|
inlineContentSchema,
|
|
393
396
|
styleSchema
|
|
394
397
|
);
|
package/src/api/nodeUtil.ts
CHANGED
|
@@ -17,7 +17,7 @@ export function getNodeById(
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
// Keeps traversing nodes if block with target ID has not been found.
|
|
20
|
-
if (node.type.
|
|
20
|
+
if (!node.type.isInGroup("bnBlock") || node.attrs.id !== id) {
|
|
21
21
|
return true;
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Block, PartialBlock } from "../../blocks/defaultBlocks.js";
|
|
2
|
+
import { BlockNoteSchema } from "../../editor/BlockNoteSchema.js";
|
|
2
3
|
import UniqueID from "../../extensions/UniqueID/UniqueID.js";
|
|
3
4
|
import { BlockSchema, TableContent } from "../../schema/blocks/types.js";
|
|
4
5
|
import {
|
|
@@ -54,6 +55,17 @@ function partialContentToInlineContent(
|
|
|
54
55
|
} as any;
|
|
55
56
|
}
|
|
56
57
|
});
|
|
58
|
+
} else if (content?.type === "tableContent") {
|
|
59
|
+
return {
|
|
60
|
+
type: "tableContent",
|
|
61
|
+
columnWidths: content.columnWidths,
|
|
62
|
+
rows: content.rows.map((row) => ({
|
|
63
|
+
...row,
|
|
64
|
+
cells: row.cells.map(
|
|
65
|
+
(cell) => partialContentToInlineContent(cell) as any
|
|
66
|
+
),
|
|
67
|
+
})),
|
|
68
|
+
};
|
|
57
69
|
}
|
|
58
70
|
|
|
59
71
|
return content;
|
|
@@ -64,11 +76,11 @@ export function partialBlocksToBlocksForTesting<
|
|
|
64
76
|
I extends InlineContentSchema,
|
|
65
77
|
S extends StyleSchema
|
|
66
78
|
>(
|
|
67
|
-
schema: BSchema,
|
|
68
|
-
partialBlocks: Array<PartialBlock<BSchema
|
|
79
|
+
schema: BlockNoteSchema<BSchema, I, S>,
|
|
80
|
+
partialBlocks: Array<PartialBlock<NoInfer<BSchema>, NoInfer<I>, NoInfer<S>>>
|
|
69
81
|
): Array<Block<BSchema, I, S>> {
|
|
70
82
|
return partialBlocks.map((partialBlock) =>
|
|
71
|
-
partialBlockToBlockForTesting(schema, partialBlock)
|
|
83
|
+
partialBlockToBlockForTesting(schema.blockSchema, partialBlock)
|
|
72
84
|
);
|
|
73
85
|
}
|
|
74
86
|
|
|
@@ -17,6 +17,9 @@ import {
|
|
|
17
17
|
} from "../FileBlockContent/fileBlockHelpers.js";
|
|
18
18
|
import { parseAudioElement } from "./audioBlockHelpers.js";
|
|
19
19
|
|
|
20
|
+
export const FILE_AUDIO_ICON_SVG =
|
|
21
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z"></path></svg>';
|
|
22
|
+
|
|
20
23
|
export const audioPropSchema = {
|
|
21
24
|
backgroundColor: defaultProps.backgroundColor,
|
|
22
25
|
// File name.
|
|
@@ -50,8 +53,7 @@ export const audioRender = (
|
|
|
50
53
|
editor: BlockNoteEditor<any, any, any>
|
|
51
54
|
) => {
|
|
52
55
|
const icon = document.createElement("div");
|
|
53
|
-
icon.innerHTML =
|
|
54
|
-
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z"></path></svg>';
|
|
56
|
+
icon.innerHTML = FILE_AUDIO_ICON_SVG;
|
|
55
57
|
|
|
56
58
|
const audio = document.createElement("audio");
|
|
57
59
|
audio.className = "bn-audio";
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
FileBlockConfig,
|
|
6
6
|
} from "../../schema/index.js";
|
|
7
7
|
|
|
8
|
+
export const FILE_ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z"></path></svg>`;
|
|
8
9
|
export const createFileBlockWrapper = (
|
|
9
10
|
block: BlockFromConfig<FileBlockConfig, any, any>,
|
|
10
11
|
editor: BlockNoteEditor<
|
|
@@ -81,8 +82,7 @@ export const createDefaultFilePreview = (
|
|
|
81
82
|
|
|
82
83
|
const icon = document.createElement("div");
|
|
83
84
|
icon.className = "bn-file-default-preview-icon";
|
|
84
|
-
icon.innerHTML =
|
|
85
|
-
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z"></path></svg>';
|
|
85
|
+
icon.innerHTML = FILE_ICON_SVG;
|
|
86
86
|
|
|
87
87
|
const fileName = document.createElement("p");
|
|
88
88
|
fileName.className = "bn-file-default-preview-name";
|
|
@@ -108,11 +108,12 @@ export const createFileAndCaptionWrapper = (
|
|
|
108
108
|
caption.className = "bn-file-caption";
|
|
109
109
|
caption.textContent = block.props.caption;
|
|
110
110
|
|
|
111
|
-
if (
|
|
111
|
+
if (
|
|
112
|
+
typeof block.props.previewWidth === "number" &&
|
|
112
113
|
block.props.previewWidth > 0 &&
|
|
113
114
|
block.props.caption !== undefined
|
|
114
115
|
) {
|
|
115
|
-
caption.style.width = `${block.props.previewWidth}px
|
|
116
|
+
caption.style.width = `${block.props.previewWidth}px`;
|
|
116
117
|
}
|
|
117
118
|
|
|
118
119
|
fileAndCaptionWrapper.appendChild(file);
|