@blocknote/core 0.17.1 → 0.19.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 +2774 -1804
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +9 -6
- 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 +106 -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 +43 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js +27 -0
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js +29 -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 +109 -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 +171 -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 +141 -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 +111 -0
- package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js +218 -0
- package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js.map +1 -0
- package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js +41 -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 +128 -0
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js.map +1 -0
- package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js +51 -0
- package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js.map +1 -0
- package/dist/src/blocks/TableBlockContent/TableBlockContent.js +130 -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 +750 -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 +149 -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 +309 -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 +51 -0
- package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js.map +1 -0
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js +81 -0
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js.map +1 -0
- package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js +183 -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 +9 -7
- package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +30 -0
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +2 -0
- package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +25 -0
- 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 +40 -0
- 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 +10 -0
- package/src/api/blockManipulation/commands/removeBlocks/removeBlocks.ts +1 -1
- package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +40 -0
- package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +30 -0
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +8 -4
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +11 -7
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +87 -0
- 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/clipboard.test.ts +1 -1
- package/src/api/clipboard/fromClipboard/acceptedMIMETypes.ts +1 -0
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +1 -1
- package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +49 -0
- package/src/api/clipboard/fromClipboard/pasteExtension.ts +6 -0
- package/src/api/clipboard/toClipboard/copyExtension.ts +1 -1
- package/src/api/exporters/html/__snapshots__/codeBlock/defaultLanguage/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/codeBlock/defaultLanguage/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/codeBlock/empty/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/codeBlock/empty/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/codeBlock/python/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/codeBlock/python/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/image/basic/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/nested/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/noName/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/noPreview/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/lists/basic/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/lists/nested/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/basic/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/basic/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/nested/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/nested/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noCaption/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noName/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noName/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noPreview/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noPreview/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/table/allColWidths/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/table/allColWidths/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/table/basic/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/table/basic/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/table/mixedColWidths/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/table/mixedColWidths/internal.html +1 -0
- package/src/api/exporters/html/htmlConversion.test.ts +1 -4
- package/src/api/exporters/html/internalHTMLSerializer.ts +2 -7
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +7 -1
- package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +75 -33
- package/src/api/exporters/markdown/__snapshots__/codeBlock/defaultLanguage/markdown.md +3 -0
- package/src/api/exporters/markdown/__snapshots__/codeBlock/empty/markdown.md +2 -0
- package/src/api/exporters/markdown/__snapshots__/codeBlock/python/markdown.md +3 -0
- package/src/api/exporters/markdown/__snapshots__/table/allColWidths/markdown.md +5 -0
- package/src/api/exporters/markdown/__snapshots__/table/basic/markdown.md +5 -0
- package/src/api/exporters/markdown/__snapshots__/table/mixedColWidths/markdown.md +5 -0
- package/src/api/exporters/markdown/markdownExporter.test.ts +1 -4
- package/src/api/getBlockInfoFromPos.ts +113 -58
- package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +711 -0
- package/src/api/nodeConversions/blockToNode.ts +62 -26
- package/src/api/nodeConversions/fragmentToBlocks.ts +18 -0
- package/src/api/nodeConversions/nodeToBlock.ts +35 -22
- package/src/api/nodeUtil.ts +1 -1
- package/src/api/parsers/html/__snapshots__/parse-notion-html.json +5 -0
- package/src/api/parsers/markdown/parseMarkdown.ts +1 -1
- package/src/api/testUtil/cases/defaultSchema.ts +95 -0
- package/src/api/testUtil/partialBlockTestUtil.ts +41 -4
- package/src/blocks/AudioBlockContent/AudioBlockContent.ts +4 -2
- package/src/blocks/CodeBlockContent/CodeBlockContent.ts +369 -0
- package/src/blocks/CodeBlockContent/defaultSupportedLanguages.ts +96 -0
- package/src/blocks/FileBlockContent/fileBlockHelpers.ts +10 -2
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +19 -31
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +4 -2
- package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +5 -9
- package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +6 -10
- package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +1 -1
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +11 -4
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +5 -9
- package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +4 -8
- package/src/blocks/TableBlockContent/TableBlockContent.ts +83 -8
- package/src/blocks/TableBlockContent/TableExtension.ts +10 -1
- package/src/blocks/VideoBlockContent/VideoBlockContent.ts +4 -2
- package/src/blocks/defaultBlockHelpers.ts +7 -2
- package/src/blocks/defaultBlocks.ts +4 -0
- package/src/editor/Block.css +71 -3
- package/src/editor/BlockNoteEditor.test.ts +2 -2
- package/src/editor/BlockNoteEditor.ts +18 -21
- package/src/editor/BlockNoteExtensions.ts +2 -3
- package/src/editor/BlockNoteTipTapEditor.ts +8 -1
- package/src/editor/defaultColors.ts +77 -0
- package/src/editor/editor.css +43 -5
- 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/FormattingToolbar/FormattingToolbarPlugin.ts +8 -0
- package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +201 -48
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.ts +1 -1
- package/src/extensions/Placeholder/PlaceholderPlugin.ts +5 -0
- package/src/extensions/SideMenu/SideMenuPlugin.ts +141 -52
- package/src/extensions/SideMenu/dragging.ts +3 -54
- package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +5 -0
- package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +2 -1
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +22 -6
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +225 -120
- package/src/extensions/TrailingNode/TrailingNodeExtension.ts +1 -1
- package/src/extensions/getDraggableBlockFromElement.ts +19 -0
- package/src/i18n/locales/ar.ts +6 -0
- package/src/i18n/locales/de.ts +299 -294
- package/src/i18n/locales/en.ts +6 -0
- package/src/i18n/locales/es.ts +310 -274
- package/src/i18n/locales/fr.ts +6 -0
- package/src/i18n/locales/is.ts +6 -0
- package/src/i18n/locales/ja.ts +6 -0
- package/src/i18n/locales/ko.ts +6 -0
- package/src/i18n/locales/nl.ts +6 -0
- package/src/i18n/locales/pl.ts +6 -0
- package/src/i18n/locales/pt.ts +10 -4
- package/src/i18n/locales/ru.ts +6 -0
- package/src/i18n/locales/vi.ts +6 -0
- package/src/i18n/locales/zh.ts +6 -0
- package/src/index.ts +9 -0
- 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 +3 -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/setupTestEnv.d.ts +22 -8
- package/types/src/api/clipboard/fromClipboard/acceptedMIMETypes.d.ts +1 -1
- package/types/src/api/clipboard/fromClipboard/handleVSCodePaste.d.ts +3 -0
- package/types/src/api/exporters/html/util/serializeBlocksInternalHTML.d.ts +2 -3
- package/types/src/api/getBlockInfoFromPos.d.ts +55 -5
- 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 +22 -8
- package/types/src/api/testUtil/cases/customInlineContent.d.ts +22 -8
- package/types/src/api/testUtil/cases/customStyles.d.ts +22 -8
- package/types/src/api/testUtil/partialBlockTestUtil.d.ts +2 -1
- package/types/src/blocks/AudioBlockContent/AudioBlockContent.d.ts +1 -0
- package/types/src/blocks/CodeBlockContent/CodeBlockContent.d.ts +57 -0
- package/types/src/blocks/CodeBlockContent/defaultSupportedLanguages.d.ts +6 -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 -12
- package/types/src/blocks/TableBlockContent/TableExtension.d.ts +3 -0
- package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +1 -0
- package/types/src/blocks/defaultBlocks.d.ts +45 -16
- package/types/src/editor/BlockNoteEditor.d.ts +4 -3
- 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/SideMenu/SideMenuPlugin.d.ts +2 -1
- package/types/src/extensions/SideMenu/dragging.d.ts +1 -6
- package/types/src/extensions/TableHandles/TableHandlesPlugin.d.ts +9 -5
- package/types/src/extensions/getDraggableBlockFromElement.d.ts +5 -0
- package/types/src/i18n/locales/de.d.ts +6 -0
- package/types/src/i18n/locales/en.d.ts +6 -0
- package/types/src/i18n/locales/es.d.ts +6 -0
- package/types/src/index.d.ts +6 -0
- 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 +3 -1
- package/types/src/util/combineByGroup.d.ts +9 -0
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import { InputRule, isTextSelection } from "@tiptap/core";
|
|
2
|
+
import { TextSelection } from "@tiptap/pm/state";
|
|
3
|
+
import { createHighlightPlugin, Parser } from "prosemirror-highlight";
|
|
4
|
+
import { createParser } from "prosemirror-highlight/shiki";
|
|
5
|
+
import {
|
|
6
|
+
BundledLanguage,
|
|
7
|
+
bundledLanguagesInfo,
|
|
8
|
+
createHighlighter,
|
|
9
|
+
Highlighter,
|
|
10
|
+
} from "shiki";
|
|
11
|
+
import {
|
|
12
|
+
createBlockSpecFromStronglyTypedTiptapNode,
|
|
13
|
+
createStronglyTypedTiptapNode,
|
|
14
|
+
PropSchema,
|
|
15
|
+
} from "../../schema/index.js";
|
|
16
|
+
import { createDefaultBlockDOMOutputSpec } from "../defaultBlockHelpers.js";
|
|
17
|
+
import {
|
|
18
|
+
defaultSupportedLanguages,
|
|
19
|
+
SupportedLanguageConfig,
|
|
20
|
+
} from "./defaultSupportedLanguages.js";
|
|
21
|
+
|
|
22
|
+
interface CodeBlockOptions {
|
|
23
|
+
defaultLanguage: string;
|
|
24
|
+
indentLineWithTab: boolean;
|
|
25
|
+
supportedLanguages: SupportedLanguageConfig[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const defaultCodeBlockPropSchema = {
|
|
29
|
+
language: {
|
|
30
|
+
default: "javascript",
|
|
31
|
+
values: [...defaultSupportedLanguages.map((lang) => lang.id)],
|
|
32
|
+
},
|
|
33
|
+
} satisfies PropSchema;
|
|
34
|
+
|
|
35
|
+
const CodeBlockContent = createStronglyTypedTiptapNode({
|
|
36
|
+
name: "codeBlock",
|
|
37
|
+
content: "inline*",
|
|
38
|
+
group: "blockContent",
|
|
39
|
+
marks: "",
|
|
40
|
+
code: true,
|
|
41
|
+
defining: true,
|
|
42
|
+
addOptions() {
|
|
43
|
+
return {
|
|
44
|
+
defaultLanguage: "javascript",
|
|
45
|
+
indentLineWithTab: true,
|
|
46
|
+
supportedLanguages: defaultSupportedLanguages,
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
addAttributes() {
|
|
50
|
+
return {
|
|
51
|
+
language: {
|
|
52
|
+
default: this.options.defaultLanguage,
|
|
53
|
+
parseHTML: (inputElement) => {
|
|
54
|
+
let element = inputElement as HTMLElement | null;
|
|
55
|
+
|
|
56
|
+
if (
|
|
57
|
+
element?.tagName === "DIV" &&
|
|
58
|
+
element?.dataset.contentType === "codeBlock"
|
|
59
|
+
) {
|
|
60
|
+
element = element.children[0] as HTMLElement | null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (element?.tagName === "PRE") {
|
|
64
|
+
element = element?.children[0] as HTMLElement | null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const dataLanguage = element?.getAttribute("data-language");
|
|
68
|
+
|
|
69
|
+
if (dataLanguage) {
|
|
70
|
+
return dataLanguage.toLowerCase();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const classNames = [...(element?.className.split(" ") || [])];
|
|
74
|
+
const languages = classNames
|
|
75
|
+
.filter((className) => className.startsWith("language-"))
|
|
76
|
+
.map((className) => className.replace("language-", ""));
|
|
77
|
+
const [language] = languages;
|
|
78
|
+
|
|
79
|
+
if (!language) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return language.toLowerCase();
|
|
84
|
+
},
|
|
85
|
+
renderHTML: (attributes) => {
|
|
86
|
+
return attributes.language && attributes.language !== "text"
|
|
87
|
+
? {
|
|
88
|
+
class: `language-${attributes.language}`,
|
|
89
|
+
}
|
|
90
|
+
: {};
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
parseHTML() {
|
|
96
|
+
return [
|
|
97
|
+
{
|
|
98
|
+
tag: "div[data-content-type=" + this.name + "]",
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
tag: "pre",
|
|
102
|
+
preserveWhitespace: "full",
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
},
|
|
106
|
+
renderHTML({ HTMLAttributes }) {
|
|
107
|
+
const pre = document.createElement("pre");
|
|
108
|
+
const { dom, contentDOM } = createDefaultBlockDOMOutputSpec(
|
|
109
|
+
this.name,
|
|
110
|
+
"code",
|
|
111
|
+
this.options.domAttributes?.blockContent || {},
|
|
112
|
+
{
|
|
113
|
+
...(this.options.domAttributes?.inlineContent || {}),
|
|
114
|
+
...HTMLAttributes,
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
dom.removeChild(contentDOM);
|
|
119
|
+
dom.appendChild(pre);
|
|
120
|
+
pre.appendChild(contentDOM);
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
dom,
|
|
124
|
+
contentDOM,
|
|
125
|
+
};
|
|
126
|
+
},
|
|
127
|
+
addNodeView() {
|
|
128
|
+
const supportedLanguages = this.options
|
|
129
|
+
.supportedLanguages as SupportedLanguageConfig[];
|
|
130
|
+
|
|
131
|
+
return ({ editor, node, getPos, HTMLAttributes }) => {
|
|
132
|
+
const pre = document.createElement("pre");
|
|
133
|
+
const select = document.createElement("select");
|
|
134
|
+
const selectWrapper = document.createElement("div");
|
|
135
|
+
const { dom, contentDOM } = createDefaultBlockDOMOutputSpec(
|
|
136
|
+
this.name,
|
|
137
|
+
"code",
|
|
138
|
+
{
|
|
139
|
+
...(this.options.domAttributes?.blockContent || {}),
|
|
140
|
+
...HTMLAttributes,
|
|
141
|
+
},
|
|
142
|
+
this.options.domAttributes?.inlineContent || {}
|
|
143
|
+
);
|
|
144
|
+
const handleLanguageChange = (event: Event) => {
|
|
145
|
+
const language = (event.target as HTMLSelectElement).value;
|
|
146
|
+
|
|
147
|
+
editor.commands.command(({ tr }) => {
|
|
148
|
+
tr.setNodeAttribute(getPos(), "language", language);
|
|
149
|
+
|
|
150
|
+
return true;
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
supportedLanguages.forEach(({ id, name }) => {
|
|
155
|
+
const option = document.createElement("option");
|
|
156
|
+
|
|
157
|
+
option.value = id;
|
|
158
|
+
option.text = name;
|
|
159
|
+
select.appendChild(option);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
selectWrapper.contentEditable = "false";
|
|
163
|
+
select.value = node.attrs.language || this.options.defaultLanguage;
|
|
164
|
+
dom.removeChild(contentDOM);
|
|
165
|
+
dom.appendChild(selectWrapper);
|
|
166
|
+
dom.appendChild(pre);
|
|
167
|
+
pre.appendChild(contentDOM);
|
|
168
|
+
selectWrapper.appendChild(select);
|
|
169
|
+
select.addEventListener("change", handleLanguageChange);
|
|
170
|
+
|
|
171
|
+
return {
|
|
172
|
+
dom,
|
|
173
|
+
contentDOM,
|
|
174
|
+
update: (newNode) => {
|
|
175
|
+
if (newNode.type !== this.type) {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return true;
|
|
180
|
+
},
|
|
181
|
+
destroy: () => {
|
|
182
|
+
select.removeEventListener("change", handleLanguageChange);
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
},
|
|
187
|
+
addProseMirrorPlugins() {
|
|
188
|
+
let highlighter: Highlighter | undefined;
|
|
189
|
+
let parser: Parser | undefined;
|
|
190
|
+
|
|
191
|
+
const supportedLanguages = this.options
|
|
192
|
+
.supportedLanguages as SupportedLanguageConfig[];
|
|
193
|
+
const lazyParser: Parser = (options) => {
|
|
194
|
+
if (!highlighter) {
|
|
195
|
+
return createHighlighter({
|
|
196
|
+
themes: ["github-dark"],
|
|
197
|
+
langs: [],
|
|
198
|
+
}).then((createdHighlighter) => {
|
|
199
|
+
highlighter = createdHighlighter;
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const language = options.language;
|
|
204
|
+
|
|
205
|
+
if (
|
|
206
|
+
language &&
|
|
207
|
+
language !== "text" &&
|
|
208
|
+
!highlighter.getLoadedLanguages().includes(language) &&
|
|
209
|
+
supportedLanguages.find(({ id }) => id === language) &&
|
|
210
|
+
bundledLanguagesInfo.find(({ id }) => id === language)
|
|
211
|
+
) {
|
|
212
|
+
return highlighter.loadLanguage(language as BundledLanguage);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (!parser) {
|
|
216
|
+
parser = createParser(highlighter);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return parser(options);
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
const shikiLazyPlugin = createHighlightPlugin({
|
|
223
|
+
parser: lazyParser,
|
|
224
|
+
languageExtractor: (node) => node.attrs.language,
|
|
225
|
+
nodeTypes: [this.name],
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
return [shikiLazyPlugin];
|
|
229
|
+
},
|
|
230
|
+
addInputRules() {
|
|
231
|
+
const supportedLanguages = this.options
|
|
232
|
+
.supportedLanguages as SupportedLanguageConfig[];
|
|
233
|
+
|
|
234
|
+
return [
|
|
235
|
+
new InputRule({
|
|
236
|
+
find: /^```(.*?)\s$/,
|
|
237
|
+
handler: ({ state, range, match }) => {
|
|
238
|
+
const $start = state.doc.resolve(range.from);
|
|
239
|
+
const languageName = match[1].trim();
|
|
240
|
+
const attributes = {
|
|
241
|
+
language:
|
|
242
|
+
supportedLanguages.find(({ match }) => {
|
|
243
|
+
return match.includes(languageName);
|
|
244
|
+
})?.id || this.options.defaultLanguage,
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
if (
|
|
248
|
+
!$start
|
|
249
|
+
.node(-1)
|
|
250
|
+
.canReplaceWith(
|
|
251
|
+
$start.index(-1),
|
|
252
|
+
$start.indexAfter(-1),
|
|
253
|
+
this.type
|
|
254
|
+
)
|
|
255
|
+
) {
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
state.tr
|
|
260
|
+
.delete(range.from, range.to)
|
|
261
|
+
.setBlockType(range.from, range.from, this.type, attributes)
|
|
262
|
+
.setSelection(TextSelection.create(state.tr.doc, range.from));
|
|
263
|
+
|
|
264
|
+
return;
|
|
265
|
+
},
|
|
266
|
+
}),
|
|
267
|
+
];
|
|
268
|
+
},
|
|
269
|
+
addKeyboardShortcuts() {
|
|
270
|
+
return {
|
|
271
|
+
Delete: ({ editor }) => {
|
|
272
|
+
const { selection } = editor.state;
|
|
273
|
+
const { $from } = selection;
|
|
274
|
+
|
|
275
|
+
// When inside empty codeblock, on `DELETE` key press, delete the codeblock
|
|
276
|
+
if (
|
|
277
|
+
editor.isActive(this.name) &&
|
|
278
|
+
!$from.parent.textContent &&
|
|
279
|
+
isTextSelection(selection)
|
|
280
|
+
) {
|
|
281
|
+
// Get the start position of the codeblock for node selection
|
|
282
|
+
const from = $from.pos - $from.parentOffset - 2;
|
|
283
|
+
|
|
284
|
+
editor.chain().setNodeSelection(from).deleteSelection().run();
|
|
285
|
+
|
|
286
|
+
return true;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return false;
|
|
290
|
+
},
|
|
291
|
+
Tab: ({ editor }) => {
|
|
292
|
+
if (!this.options.indentLineWithTab) {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
if (editor.isActive(this.name)) {
|
|
296
|
+
editor.commands.insertContent(" ");
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
return false;
|
|
301
|
+
},
|
|
302
|
+
Enter: ({ editor }) => {
|
|
303
|
+
const { $from } = editor.state.selection;
|
|
304
|
+
|
|
305
|
+
if (!editor.isActive(this.name)) {
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
const isAtEnd = $from.parentOffset === $from.parent.nodeSize - 2;
|
|
310
|
+
const endsWithDoubleNewline = $from.parent.textContent.endsWith("\n\n");
|
|
311
|
+
|
|
312
|
+
if (!isAtEnd || !endsWithDoubleNewline) {
|
|
313
|
+
editor.commands.insertContent("\n");
|
|
314
|
+
return true;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
return editor
|
|
318
|
+
.chain()
|
|
319
|
+
.command(({ tr }) => {
|
|
320
|
+
tr.delete($from.pos - 2, $from.pos);
|
|
321
|
+
|
|
322
|
+
return true;
|
|
323
|
+
})
|
|
324
|
+
.exitCode()
|
|
325
|
+
.run();
|
|
326
|
+
},
|
|
327
|
+
"Shift-Enter": ({ editor }) => {
|
|
328
|
+
const { $from } = editor.state.selection;
|
|
329
|
+
|
|
330
|
+
if (!editor.isActive(this.name)) {
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
editor
|
|
335
|
+
.chain()
|
|
336
|
+
.insertContentAt(
|
|
337
|
+
$from.pos - $from.parentOffset + $from.parent.nodeSize,
|
|
338
|
+
{
|
|
339
|
+
type: "paragraph",
|
|
340
|
+
}
|
|
341
|
+
)
|
|
342
|
+
.run();
|
|
343
|
+
|
|
344
|
+
return true;
|
|
345
|
+
},
|
|
346
|
+
};
|
|
347
|
+
},
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
export const CodeBlock = createBlockSpecFromStronglyTypedTiptapNode(
|
|
351
|
+
CodeBlockContent,
|
|
352
|
+
defaultCodeBlockPropSchema
|
|
353
|
+
);
|
|
354
|
+
|
|
355
|
+
export function customizeCodeBlock(options: Partial<CodeBlockOptions>) {
|
|
356
|
+
return createBlockSpecFromStronglyTypedTiptapNode(
|
|
357
|
+
CodeBlockContent.configure(options),
|
|
358
|
+
{
|
|
359
|
+
language: {
|
|
360
|
+
default:
|
|
361
|
+
options.defaultLanguage ||
|
|
362
|
+
defaultCodeBlockPropSchema.language.default,
|
|
363
|
+
values:
|
|
364
|
+
options.supportedLanguages?.map((lang) => lang.id) ||
|
|
365
|
+
defaultCodeBlockPropSchema.language.values,
|
|
366
|
+
},
|
|
367
|
+
}
|
|
368
|
+
);
|
|
369
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { bundledLanguagesInfo } from "shiki/bundle/web";
|
|
2
|
+
|
|
3
|
+
export type SupportedLanguageConfig = {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
match: string[];
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const defaultSupportedLanguages: SupportedLanguageConfig[] = [
|
|
10
|
+
{
|
|
11
|
+
id: "text",
|
|
12
|
+
name: "Plain Text",
|
|
13
|
+
match: ["text", "txt", "plain"],
|
|
14
|
+
},
|
|
15
|
+
...bundledLanguagesInfo
|
|
16
|
+
.filter((lang) => {
|
|
17
|
+
return ![
|
|
18
|
+
"angular-html",
|
|
19
|
+
"angular-ts",
|
|
20
|
+
"astro",
|
|
21
|
+
"blade",
|
|
22
|
+
"coffee",
|
|
23
|
+
"handlebars",
|
|
24
|
+
"html-derivative",
|
|
25
|
+
"http",
|
|
26
|
+
"imba",
|
|
27
|
+
"jinja",
|
|
28
|
+
"jison",
|
|
29
|
+
"json5",
|
|
30
|
+
"marko",
|
|
31
|
+
"mdc",
|
|
32
|
+
"stylus",
|
|
33
|
+
"ts-tags",
|
|
34
|
+
].includes(lang.id);
|
|
35
|
+
})
|
|
36
|
+
.map((lang) => ({
|
|
37
|
+
match: [lang.id, ...(lang.aliases || [])],
|
|
38
|
+
id: lang.id,
|
|
39
|
+
name: lang.name,
|
|
40
|
+
})),
|
|
41
|
+
{
|
|
42
|
+
id: "haskell",
|
|
43
|
+
name: "Haskell",
|
|
44
|
+
match: ["haskell", "hs"],
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: "csharp",
|
|
48
|
+
name: "C#",
|
|
49
|
+
match: ["c#", "csharp", "cs"],
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: "latex",
|
|
53
|
+
name: "LaTeX",
|
|
54
|
+
match: ["latex"],
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: "lua",
|
|
58
|
+
name: "Lua",
|
|
59
|
+
match: ["lua"],
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: "mermaid",
|
|
63
|
+
name: "Mermaid",
|
|
64
|
+
match: ["mermaid", "mmd"],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: "ruby",
|
|
68
|
+
name: "Ruby",
|
|
69
|
+
match: ["ruby", "rb"],
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
id: "rust",
|
|
73
|
+
name: "Rust",
|
|
74
|
+
match: ["rust", "rs"],
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: "scala",
|
|
78
|
+
name: "Scala",
|
|
79
|
+
match: ["scala"],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
id: "swift",
|
|
83
|
+
name: "Swift",
|
|
84
|
+
match: ["swift"],
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: "kotlin",
|
|
88
|
+
name: "Kotlin",
|
|
89
|
+
match: ["kotlin", "kt", "kts"],
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: "objective-c",
|
|
93
|
+
name: "Objective C",
|
|
94
|
+
match: ["objective-c", "objc"],
|
|
95
|
+
},
|
|
96
|
+
];
|
|
@@ -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,6 +108,14 @@ export const createFileAndCaptionWrapper = (
|
|
|
108
108
|
caption.className = "bn-file-caption";
|
|
109
109
|
caption.textContent = block.props.caption;
|
|
110
110
|
|
|
111
|
+
if (
|
|
112
|
+
typeof block.props.previewWidth === "number" &&
|
|
113
|
+
block.props.previewWidth > 0 &&
|
|
114
|
+
block.props.caption !== undefined
|
|
115
|
+
) {
|
|
116
|
+
caption.style.width = `${block.props.previewWidth}px`;
|
|
117
|
+
}
|
|
118
|
+
|
|
111
119
|
fileAndCaptionWrapper.appendChild(file);
|
|
112
120
|
fileAndCaptionWrapper.appendChild(caption);
|
|
113
121
|
|
|
@@ -56,7 +56,7 @@ const HeadingBlockContent = createStronglyTypedTiptapNode({
|
|
|
56
56
|
.command(
|
|
57
57
|
updateBlockCommand(
|
|
58
58
|
this.options.editor,
|
|
59
|
-
blockInfo.
|
|
59
|
+
blockInfo.bnBlock.beforePos,
|
|
60
60
|
{
|
|
61
61
|
type: "heading",
|
|
62
62
|
props: {
|
|
@@ -84,16 +84,12 @@ const HeadingBlockContent = createStronglyTypedTiptapNode({
|
|
|
84
84
|
|
|
85
85
|
// call updateBlockCommand
|
|
86
86
|
return this.editor.commands.command(
|
|
87
|
-
updateBlockCommand(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
level: 1 as any,
|
|
94
|
-
},
|
|
95
|
-
}
|
|
96
|
-
)
|
|
87
|
+
updateBlockCommand(this.options.editor, blockInfo.bnBlock.beforePos, {
|
|
88
|
+
type: "heading",
|
|
89
|
+
props: {
|
|
90
|
+
level: 1 as any,
|
|
91
|
+
},
|
|
92
|
+
})
|
|
97
93
|
);
|
|
98
94
|
},
|
|
99
95
|
"Mod-Alt-2": () => {
|
|
@@ -103,16 +99,12 @@ const HeadingBlockContent = createStronglyTypedTiptapNode({
|
|
|
103
99
|
}
|
|
104
100
|
|
|
105
101
|
return this.editor.commands.command(
|
|
106
|
-
updateBlockCommand(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
level: 2 as any,
|
|
113
|
-
},
|
|
114
|
-
}
|
|
115
|
-
)
|
|
102
|
+
updateBlockCommand(this.options.editor, blockInfo.bnBlock.beforePos, {
|
|
103
|
+
type: "heading",
|
|
104
|
+
props: {
|
|
105
|
+
level: 2 as any,
|
|
106
|
+
},
|
|
107
|
+
})
|
|
116
108
|
);
|
|
117
109
|
},
|
|
118
110
|
"Mod-Alt-3": () => {
|
|
@@ -122,16 +114,12 @@ const HeadingBlockContent = createStronglyTypedTiptapNode({
|
|
|
122
114
|
}
|
|
123
115
|
|
|
124
116
|
return this.editor.commands.command(
|
|
125
|
-
updateBlockCommand(
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
level: 3 as any,
|
|
132
|
-
},
|
|
133
|
-
}
|
|
134
|
-
)
|
|
117
|
+
updateBlockCommand(this.options.editor, blockInfo.bnBlock.beforePos, {
|
|
118
|
+
type: "heading",
|
|
119
|
+
props: {
|
|
120
|
+
level: 3 as any,
|
|
121
|
+
},
|
|
122
|
+
})
|
|
135
123
|
);
|
|
136
124
|
},
|
|
137
125
|
};
|
|
@@ -17,6 +17,9 @@ import {
|
|
|
17
17
|
} from "../FileBlockContent/fileBlockHelpers.js";
|
|
18
18
|
import { parseImageElement } from "./imageBlockHelpers.js";
|
|
19
19
|
|
|
20
|
+
export const FILE_IMAGE_ICON_SVG =
|
|
21
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z"></path></svg>';
|
|
22
|
+
|
|
20
23
|
export const imagePropSchema = {
|
|
21
24
|
textAlignment: defaultProps.textAlignment,
|
|
22
25
|
backgroundColor: defaultProps.backgroundColor,
|
|
@@ -55,8 +58,7 @@ export const imageRender = (
|
|
|
55
58
|
editor: BlockNoteEditor<any, any, any>
|
|
56
59
|
) => {
|
|
57
60
|
const icon = document.createElement("div");
|
|
58
|
-
icon.innerHTML =
|
|
59
|
-
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z"></path></svg>';
|
|
61
|
+
icon.innerHTML = FILE_IMAGE_ICON_SVG;
|
|
60
62
|
|
|
61
63
|
const image = document.createElement("img");
|
|
62
64
|
image.className = "bn-visual-media";
|
package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts
CHANGED
|
@@ -36,7 +36,7 @@ const BulletListItemBlockContent = createStronglyTypedTiptapNode({
|
|
|
36
36
|
.command(
|
|
37
37
|
updateBlockCommand(
|
|
38
38
|
this.options.editor,
|
|
39
|
-
blockInfo.
|
|
39
|
+
blockInfo.bnBlock.beforePos,
|
|
40
40
|
{
|
|
41
41
|
type: "bulletListItem",
|
|
42
42
|
props: {},
|
|
@@ -60,14 +60,10 @@ const BulletListItemBlockContent = createStronglyTypedTiptapNode({
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
return this.options.editor.commands.command(
|
|
63
|
-
updateBlockCommand(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
type: "bulletListItem",
|
|
68
|
-
props: {},
|
|
69
|
-
}
|
|
70
|
-
)
|
|
63
|
+
updateBlockCommand(this.options.editor, blockInfo.bnBlock.beforePos, {
|
|
64
|
+
type: "bulletListItem",
|
|
65
|
+
props: {},
|
|
66
|
+
})
|
|
71
67
|
);
|
|
72
68
|
},
|
|
73
69
|
};
|
package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts
CHANGED
|
@@ -57,7 +57,7 @@ const checkListItemBlockContent = createStronglyTypedTiptapNode({
|
|
|
57
57
|
.command(
|
|
58
58
|
updateBlockCommand(
|
|
59
59
|
this.options.editor,
|
|
60
|
-
blockInfo.
|
|
60
|
+
blockInfo.bnBlock.beforePos,
|
|
61
61
|
{
|
|
62
62
|
type: "checkListItem",
|
|
63
63
|
props: {
|
|
@@ -83,7 +83,7 @@ const checkListItemBlockContent = createStronglyTypedTiptapNode({
|
|
|
83
83
|
.command(
|
|
84
84
|
updateBlockCommand(
|
|
85
85
|
this.options.editor,
|
|
86
|
-
blockInfo.
|
|
86
|
+
blockInfo.bnBlock.beforePos,
|
|
87
87
|
{
|
|
88
88
|
type: "checkListItem",
|
|
89
89
|
props: {
|
|
@@ -109,14 +109,10 @@ const checkListItemBlockContent = createStronglyTypedTiptapNode({
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
return this.editor.commands.command(
|
|
112
|
-
updateBlockCommand(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
type: "checkListItem",
|
|
117
|
-
props: {},
|
|
118
|
-
}
|
|
119
|
-
)
|
|
112
|
+
updateBlockCommand(this.options.editor, blockInfo.bnBlock.beforePos, {
|
|
113
|
+
type: "checkListItem",
|
|
114
|
+
props: {},
|
|
115
|
+
})
|
|
120
116
|
);
|
|
121
117
|
},
|
|
122
118
|
};
|
|
@@ -5,7 +5,7 @@ import { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
|
|
|
5
5
|
|
|
6
6
|
export const handleEnter = (editor: BlockNoteEditor<any, any, any>) => {
|
|
7
7
|
const ttEditor = editor._tiptapEditor;
|
|
8
|
-
const { blockContent, blockContainer } = getBlockInfoFromSelection(
|
|
8
|
+
const { blockContent, bnBlock: blockContainer } = getBlockInfoFromSelection(
|
|
9
9
|
ttEditor.state
|
|
10
10
|
);
|
|
11
11
|
|