@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,114 @@
|
|
|
1
|
+
import UniqueID from "../../extensions/UniqueID/UniqueID.js";
|
|
2
|
+
import { isPartialLinkInlineContent, isStyledTextInlineContent, } from "../../schema/inlineContent/types.js";
|
|
3
|
+
function textShorthandToStyledText(content = "") {
|
|
4
|
+
if (typeof content === "string") {
|
|
5
|
+
return [
|
|
6
|
+
{
|
|
7
|
+
type: "text",
|
|
8
|
+
text: content,
|
|
9
|
+
styles: {},
|
|
10
|
+
},
|
|
11
|
+
];
|
|
12
|
+
}
|
|
13
|
+
return content;
|
|
14
|
+
}
|
|
15
|
+
function partialContentToInlineContent(content) {
|
|
16
|
+
if (typeof content === "string") {
|
|
17
|
+
return textShorthandToStyledText(content);
|
|
18
|
+
}
|
|
19
|
+
if (Array.isArray(content)) {
|
|
20
|
+
return content.flatMap((partialContent) => {
|
|
21
|
+
if (typeof partialContent === "string") {
|
|
22
|
+
return textShorthandToStyledText(partialContent);
|
|
23
|
+
}
|
|
24
|
+
else if (isPartialLinkInlineContent(partialContent)) {
|
|
25
|
+
return {
|
|
26
|
+
...partialContent,
|
|
27
|
+
content: textShorthandToStyledText(partialContent.content),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
else if (isStyledTextInlineContent(partialContent)) {
|
|
31
|
+
return partialContent;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
// custom inline content
|
|
35
|
+
return {
|
|
36
|
+
props: {},
|
|
37
|
+
...partialContent,
|
|
38
|
+
content: partialContentToInlineContent(partialContent.content),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
else if (content?.type === "tableContent") {
|
|
44
|
+
return {
|
|
45
|
+
type: "tableContent",
|
|
46
|
+
columnWidths: content.columnWidths,
|
|
47
|
+
rows: content.rows.map((row) => ({
|
|
48
|
+
...row,
|
|
49
|
+
cells: row.cells.map((cell) => partialContentToInlineContent(cell)),
|
|
50
|
+
})),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return content;
|
|
54
|
+
}
|
|
55
|
+
export function partialBlocksToBlocksForTesting(schema, partialBlocks) {
|
|
56
|
+
return partialBlocks.map((partialBlock) => partialBlockToBlockForTesting(schema.blockSchema, partialBlock));
|
|
57
|
+
}
|
|
58
|
+
export function partialBlockToBlockForTesting(schema, partialBlock) {
|
|
59
|
+
const contentType = schema[partialBlock.type].content;
|
|
60
|
+
const withDefaults = {
|
|
61
|
+
id: "",
|
|
62
|
+
type: partialBlock.type,
|
|
63
|
+
props: {},
|
|
64
|
+
content: contentType === "inline"
|
|
65
|
+
? []
|
|
66
|
+
: contentType === "table"
|
|
67
|
+
? { type: "tableContent", columnWidths: [], rows: [] }
|
|
68
|
+
: undefined,
|
|
69
|
+
children: [],
|
|
70
|
+
...partialBlock,
|
|
71
|
+
};
|
|
72
|
+
Object.entries(schema[partialBlock.type].propSchema).forEach(([propKey, propValue]) => {
|
|
73
|
+
if (withDefaults.props[propKey] === undefined) {
|
|
74
|
+
withDefaults.props[propKey] = propValue.default;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
if (contentType === "inline") {
|
|
78
|
+
const content = withDefaults.content;
|
|
79
|
+
withDefaults.content = partialContentToInlineContent(content);
|
|
80
|
+
}
|
|
81
|
+
else if (contentType === "table") {
|
|
82
|
+
const content = withDefaults.content;
|
|
83
|
+
withDefaults.content = {
|
|
84
|
+
type: "tableContent",
|
|
85
|
+
columnWidths: content?.columnWidths ||
|
|
86
|
+
content?.rows[0]?.cells.map(() => undefined) ||
|
|
87
|
+
[],
|
|
88
|
+
rows: content?.rows.map((row) => ({
|
|
89
|
+
cells: row.cells.map((cell) => partialContentToInlineContent(cell)),
|
|
90
|
+
})) || [],
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
...withDefaults,
|
|
95
|
+
content: partialContentToInlineContent(withDefaults.content),
|
|
96
|
+
children: withDefaults.children.map((c) => {
|
|
97
|
+
return partialBlockToBlockForTesting(schema, c);
|
|
98
|
+
}),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export function addIdsToBlock(block) {
|
|
102
|
+
if (!block.id) {
|
|
103
|
+
block.id = UniqueID.options.generateID();
|
|
104
|
+
}
|
|
105
|
+
if (block.children) {
|
|
106
|
+
addIdsToBlocks(block.children);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
export function addIdsToBlocks(blocks) {
|
|
110
|
+
for (const block of blocks) {
|
|
111
|
+
addIdsToBlock(block);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=partialBlockTestUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"partialBlockTestUtil.js","sourceRoot":"","sources":["../../../../src/api/testUtil/partialBlockTestUtil.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,MAAM,uCAAuC,CAAC;AAE7D,OAAO,EAKL,0BAA0B,EAC1B,yBAAyB,GAC1B,MAAM,qCAAqC,CAAC;AAG7C,SAAS,yBAAyB,CAChC,UAAsC,EAAE;IAExC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO;YACL;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,OAAO;gBACb,MAAM,EAAE,EAAE;aACX;SACF,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,6BAA6B,CACpC,OAAuE;IAEvE,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@@
|
|
|
1
|
+
import { Slice } from "@tiptap/pm/model";
|
|
2
|
+
import * as pmView from "@tiptap/pm/view";
|
|
3
|
+
function sliceSingleNode(slice) {
|
|
4
|
+
return slice.openStart === 0 &&
|
|
5
|
+
slice.openEnd === 0 &&
|
|
6
|
+
slice.content.childCount === 1
|
|
7
|
+
? slice.content.firstChild
|
|
8
|
+
: null;
|
|
9
|
+
}
|
|
10
|
+
// This function is a copy of the `doPaste` function from `@tiptap/pm/view`,
|
|
11
|
+
// but made to work in a JSDOM environment. To do this, the `tr.scrollIntoView`
|
|
12
|
+
// call has been removed.
|
|
13
|
+
// https://github.com/ProseMirror/prosemirror-view/blob/17b508f618c944c54776f8ddac45edcb49970796/src/input.ts#L624
|
|
14
|
+
export function doPaste(view, text, html, preferPlain, event) {
|
|
15
|
+
const slice = pmView.__parseFromClipboard(view, text, html, preferPlain, view.state.selection.$from);
|
|
16
|
+
if (view.someProp("handlePaste", (f) => f(view, event, slice || Slice.empty))) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
if (!slice) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
const singleNode = sliceSingleNode(slice);
|
|
23
|
+
const tr = singleNode
|
|
24
|
+
? view.state.tr.replaceSelectionWith(singleNode, preferPlain)
|
|
25
|
+
: view.state.tr.replaceSelection(slice);
|
|
26
|
+
view.dispatch(tr.setMeta("paste", true).setMeta("uiEvent", "paste"));
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=paste.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paste.js","sourceRoot":"","sources":["../../../../src/api/testUtil/paste.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAC;AAE1C,SAAS,eAAe,CAAC,KAAY;IACnC,OAAO,KAAK,CAAC,SAAS,KAAK,CAA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Spec, } from "../../schema/index.js";
|
|
2
|
+
import { defaultProps } from "../defaultProps.js";
|
|
3
|
+
import { createFigureWithCaption, createFileAndCaptionWrapper, createFileBlockWrapper, createLinkWithCaption, parseFigureElement, } from "../FileBlockContent/fileBlockHelpers.js";
|
|
4
|
+
import { parseAudioElement } from "./audioBlockHelpers.js";
|
|
5
|
+
export const FILE_AUDIO_ICON_SVG = '<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>';
|
|
6
|
+
export const audioPropSchema = {
|
|
7
|
+
backgroundColor: defaultProps.backgroundColor,
|
|
8
|
+
// File name.
|
|
9
|
+
name: {
|
|
10
|
+
default: "",
|
|
11
|
+
},
|
|
12
|
+
// File url.
|
|
13
|
+
url: {
|
|
14
|
+
default: "",
|
|
15
|
+
},
|
|
16
|
+
// File caption.
|
|
17
|
+
caption: {
|
|
18
|
+
default: "",
|
|
19
|
+
},
|
|
20
|
+
showPreview: {
|
|
21
|
+
default: true,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
export const audioBlockConfig = {
|
|
25
|
+
type: "audio",
|
|
26
|
+
propSchema: audioPropSchema,
|
|
27
|
+
content: "none",
|
|
28
|
+
isFileBlock: true,
|
|
29
|
+
fileBlockAccept: ["audio/*"],
|
|
30
|
+
};
|
|
31
|
+
export const audioRender = (block, editor) => {
|
|
32
|
+
const icon = document.createElement("div");
|
|
33
|
+
icon.innerHTML = FILE_AUDIO_ICON_SVG;
|
|
34
|
+
const audio = document.createElement("audio");
|
|
35
|
+
audio.className = "bn-audio";
|
|
36
|
+
editor.resolveFileUrl(block.props.url).then((downloadUrl) => {
|
|
37
|
+
audio.src = downloadUrl;
|
|
38
|
+
});
|
|
39
|
+
audio.controls = true;
|
|
40
|
+
audio.contentEditable = "false";
|
|
41
|
+
audio.draggable = false;
|
|
42
|
+
const element = createFileAndCaptionWrapper(block, audio);
|
|
43
|
+
return createFileBlockWrapper(block, editor, element, editor.dictionary.file_blocks.audio.add_button_text, icon.firstElementChild);
|
|
44
|
+
};
|
|
45
|
+
export const audioParse = (element) => {
|
|
46
|
+
if (element.tagName === "AUDIO") {
|
|
47
|
+
return parseAudioElement(element);
|
|
48
|
+
}
|
|
49
|
+
if (element.tagName === "FIGURE") {
|
|
50
|
+
const parsedFigure = parseFigureElement(element, "audio");
|
|
51
|
+
if (!parsedFigure) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
const { targetElement, caption } = parsedFigure;
|
|
55
|
+
return {
|
|
56
|
+
...parseAudioElement(targetElement),
|
|
57
|
+
caption,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return undefined;
|
|
61
|
+
};
|
|
62
|
+
export const audioToExternalHTML = (block) => {
|
|
63
|
+
if (!block.props.url) {
|
|
64
|
+
const div = document.createElement("p");
|
|
65
|
+
div.textContent = "Add audio";
|
|
66
|
+
return {
|
|
67
|
+
dom: div,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
let audio;
|
|
71
|
+
if (block.props.showPreview) {
|
|
72
|
+
audio = document.createElement("audio");
|
|
73
|
+
audio.src = block.props.url;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
audio = document.createElement("a");
|
|
77
|
+
audio.href = block.props.url;
|
|
78
|
+
audio.textContent = block.props.name || block.props.url;
|
|
79
|
+
}
|
|
80
|
+
if (block.props.caption) {
|
|
81
|
+
if (block.props.showPreview) {
|
|
82
|
+
return createFigureWithCaption(audio, block.props.caption);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
return createLinkWithCaption(audio, block.props.caption);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
dom: audio,
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
export const AudioBlock = createBlockSpec(audioBlockConfig, {
|
|
93
|
+
render: audioRender,
|
|
94
|
+
parse: audioParse,
|
|
95
|
+
toExternalHTML: audioToExternalHTML,
|
|
96
|
+
});
|
|
97
|
+
//# sourceMappingURL=AudioBlockContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AudioBlockContent.js","sourceRoot":"","sources":["../../../../src/blocks/AudioBlockContent/AudioBlockContent.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,eAAe,GAIhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EACL,uBAAuB,EACvB,2BAA2B,EAC3B,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,CAAC,MAAM,mBAAmB,GAC9B,yxBAAyxB,CAAC;AAE5xB,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,eAAe,EAAE,YAAY,CAAC,eAAe;IAC7C,aAAa;IACb,IAAI,EAAE;QACJ,OAAO,EAAE,EAAW;KACrB;IACD,YAAY;IACZ,GAAG,EAAE;QACH,OAAO,EAAE,EAAW;KACrB;IACD,gB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IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACxB,IAAI,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;YAC5B,OAAO,uBAAuB,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC7D,CAAC;aAAM,CAAC;YACN,OAAO,qBAAqB,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;IAED,OAAO;QACL,GAAG,EAAE,KAAK;KACX,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAC,gBAAgB,EAAE;IAC1D,MAAM,EAAE,WAAW;IACnB,KAAK,EAAE,UAAU;IACjB,cAAc,EAAE,mBAAmB;CACpC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audioBlockHelpers.js","sourceRoot":"","sources":["../../../../src/blocks/AudioBlockContent/audioBlockHelpers.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,YAA8B,EAAE,EAAE;IAClE,MAAM,GAAG,GAAG,YAAY,CAAC,GAAG,IAAI,SAAS,CAAC;IAE1C,OAAO,EAAE,GAAG,EAAE,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { InputRule, isTextSelection } from "@tiptap/core";
|
|
2
|
+
import { TextSelection } from "@tiptap/pm/state";
|
|
3
|
+
import { createHighlightPlugin } from "prosemirror-highlight";
|
|
4
|
+
import { createParser } from "prosemirror-highlight/shiki";
|
|
5
|
+
import { bundledLanguagesInfo, createHighlighter, } from "shiki";
|
|
6
|
+
import { createBlockSpecFromStronglyTypedTiptapNode, createStronglyTypedTiptapNode, } from "../../schema/index.js";
|
|
7
|
+
import { createDefaultBlockDOMOutputSpec } from "../defaultBlockHelpers.js";
|
|
8
|
+
import { defaultSupportedLanguages, } from "./defaultSupportedLanguages.js";
|
|
9
|
+
export const defaultCodeBlockPropSchema = {
|
|
10
|
+
language: {
|
|
11
|
+
default: "javascript",
|
|
12
|
+
values: [...defaultSupportedLanguages.map((lang) => lang.id)],
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
const CodeBlockContent = createStronglyTypedTiptapNode({
|
|
16
|
+
name: "codeBlock",
|
|
17
|
+
content: "inline*",
|
|
18
|
+
group: "blockContent",
|
|
19
|
+
marks: "",
|
|
20
|
+
code: true,
|
|
21
|
+
defining: true,
|
|
22
|
+
addOptions() {
|
|
23
|
+
return {
|
|
24
|
+
defaultLanguage: "javascript",
|
|
25
|
+
indentLineWithTab: true,
|
|
26
|
+
supportedLanguages: defaultSupportedLanguages,
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
addAttributes() {
|
|
30
|
+
return {
|
|
31
|
+
language: {
|
|
32
|
+
default: this.options.defaultLanguage,
|
|
33
|
+
parseHTML: (inputElement) => {
|
|
34
|
+
let element = inputElement;
|
|
35
|
+
if (element?.tagName === "DIV" &&
|
|
36
|
+
element?.dataset.contentType === "codeBlock") {
|
|
37
|
+
element = element.children[0];
|
|
38
|
+
}
|
|
39
|
+
if (element?.tagName === "PRE") {
|
|
40
|
+
element = element?.children[0];
|
|
41
|
+
}
|
|
42
|
+
const dataLanguage = element?.getAttribute("data-language");
|
|
43
|
+
if (dataLanguage) {
|
|
44
|
+
return dataLanguage.toLowerCase();
|
|
45
|
+
}
|
|
46
|
+
const classNames = [...(element?.className.split(" ") || [])];
|
|
47
|
+
const languages = classNames
|
|
48
|
+
.filter((className) => className.startsWith("language-"))
|
|
49
|
+
.map((className) => className.replace("language-", ""));
|
|
50
|
+
const [language] = languages;
|
|
51
|
+
if (!language) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
return language.toLowerCase();
|
|
55
|
+
},
|
|
56
|
+
renderHTML: (attributes) => {
|
|
57
|
+
return attributes.language && attributes.language !== "text"
|
|
58
|
+
? {
|
|
59
|
+
class: `language-${attributes.language}`,
|
|
60
|
+
}
|
|
61
|
+
: {};
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
parseHTML() {
|
|
67
|
+
return [
|
|
68
|
+
{
|
|
69
|
+
tag: "div[data-content-type=" + this.name + "]",
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
tag: "pre",
|
|
73
|
+
preserveWhitespace: "full",
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
},
|
|
77
|
+
renderHTML({ HTMLAttributes }) {
|
|
78
|
+
const pre = document.createElement("pre");
|
|
79
|
+
const { dom, contentDOM } = createDefaultBlockDOMOutputSpec(this.name, "code", this.options.domAttributes?.blockContent || {}, {
|
|
80
|
+
...(this.options.domAttributes?.inlineContent || {}),
|
|
81
|
+
...HTMLAttributes,
|
|
82
|
+
});
|
|
83
|
+
dom.removeChild(contentDOM);
|
|
84
|
+
dom.appendChild(pre);
|
|
85
|
+
pre.appendChild(contentDOM);
|
|
86
|
+
return {
|
|
87
|
+
dom,
|
|
88
|
+
contentDOM,
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
addNodeView() {
|
|
92
|
+
const supportedLanguages = this.options
|
|
93
|
+
.supportedLanguages;
|
|
94
|
+
return ({ editor, node, getPos, HTMLAttributes }) => {
|
|
95
|
+
const pre = document.createElement("pre");
|
|
96
|
+
const select = document.createElement("select");
|
|
97
|
+
const selectWrapper = document.createElement("div");
|
|
98
|
+
const { dom, contentDOM } = createDefaultBlockDOMOutputSpec(this.name, "code", {
|
|
99
|
+
...(this.options.domAttributes?.blockContent || {}),
|
|
100
|
+
...HTMLAttributes,
|
|
101
|
+
}, this.options.domAttributes?.inlineContent || {});
|
|
102
|
+
const handleLanguageChange = (event) => {
|
|
103
|
+
const language = event.target.value;
|
|
104
|
+
editor.commands.command(({ tr }) => {
|
|
105
|
+
tr.setNodeAttribute(getPos(), "language", language);
|
|
106
|
+
return true;
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
supportedLanguages.forEach(({ id, name }) => {
|
|
110
|
+
const option = document.createElement("option");
|
|
111
|
+
option.value = id;
|
|
112
|
+
option.text = name;
|
|
113
|
+
select.appendChild(option);
|
|
114
|
+
});
|
|
115
|
+
selectWrapper.contentEditable = "false";
|
|
116
|
+
select.value = node.attrs.language || this.options.defaultLanguage;
|
|
117
|
+
dom.removeChild(contentDOM);
|
|
118
|
+
dom.appendChild(selectWrapper);
|
|
119
|
+
dom.appendChild(pre);
|
|
120
|
+
pre.appendChild(contentDOM);
|
|
121
|
+
selectWrapper.appendChild(select);
|
|
122
|
+
select.addEventListener("change", handleLanguageChange);
|
|
123
|
+
return {
|
|
124
|
+
dom,
|
|
125
|
+
contentDOM,
|
|
126
|
+
update: (newNode) => {
|
|
127
|
+
if (newNode.type !== this.type) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
return true;
|
|
131
|
+
},
|
|
132
|
+
destroy: () => {
|
|
133
|
+
select.removeEventListener("change", handleLanguageChange);
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
},
|
|
138
|
+
addProseMirrorPlugins() {
|
|
139
|
+
let highlighter;
|
|
140
|
+
let parser;
|
|
141
|
+
const supportedLanguages = this.options
|
|
142
|
+
.supportedLanguages;
|
|
143
|
+
const lazyParser = (options) => {
|
|
144
|
+
if (!highlighter) {
|
|
145
|
+
return createHighlighter({
|
|
146
|
+
themes: ["github-dark"],
|
|
147
|
+
langs: [],
|
|
148
|
+
}).then((createdHighlighter) => {
|
|
149
|
+
highlighter = createdHighlighter;
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
const language = options.language;
|
|
153
|
+
if (language &&
|
|
154
|
+
language !== "text" &&
|
|
155
|
+
!highlighter.getLoadedLanguages().includes(language) &&
|
|
156
|
+
supportedLanguages.find(({ id }) => id === language) &&
|
|
157
|
+
bundledLanguagesInfo.find(({ id }) => id === language)) {
|
|
158
|
+
return highlighter.loadLanguage(language);
|
|
159
|
+
}
|
|
160
|
+
if (!parser) {
|
|
161
|
+
parser = createParser(highlighter);
|
|
162
|
+
}
|
|
163
|
+
return parser(options);
|
|
164
|
+
};
|
|
165
|
+
const shikiLazyPlugin = createHighlightPlugin({
|
|
166
|
+
parser: lazyParser,
|
|
167
|
+
languageExtractor: (node) => node.attrs.language,
|
|
168
|
+
nodeTypes: [this.name],
|
|
169
|
+
});
|
|
170
|
+
return [shikiLazyPlugin];
|
|
171
|
+
},
|
|
172
|
+
addInputRules() {
|
|
173
|
+
const supportedLanguages = this.options
|
|
174
|
+
.supportedLanguages;
|
|
175
|
+
return [
|
|
176
|
+
new InputRule({
|
|
177
|
+
find: /^```(.*?)\s$/,
|
|
178
|
+
handler: ({ state, range, match }) => {
|
|
179
|
+
const $start = state.doc.resolve(range.from);
|
|
180
|
+
const languageName = match[1].trim();
|
|
181
|
+
const attributes = {
|
|
182
|
+
language: supportedLanguages.find(({ match }) => {
|
|
183
|
+
return match.includes(languageName);
|
|
184
|
+
})?.id || this.options.defaultLanguage,
|
|
185
|
+
};
|
|
186
|
+
if (!$start
|
|
187
|
+
.node(-1)
|
|
188
|
+
.canReplaceWith($start.index(-1), $start.indexAfter(-1), this.type)) {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
state.tr
|
|
192
|
+
.delete(range.from, range.to)
|
|
193
|
+
.setBlockType(range.from, range.from, this.type, attributes)
|
|
194
|
+
.setSelection(TextSelection.create(state.tr.doc, range.from));
|
|
195
|
+
return;
|
|
196
|
+
},
|
|
197
|
+
}),
|
|
198
|
+
];
|
|
199
|
+
},
|
|
200
|
+
addKeyboardShortcuts() {
|
|
201
|
+
return {
|
|
202
|
+
Delete: ({ editor }) => {
|
|
203
|
+
const { selection } = editor.state;
|
|
204
|
+
const { $from } = selection;
|
|
205
|
+
// When inside empty codeblock, on `DELETE` key press, delete the codeblock
|
|
206
|
+
if (editor.isActive(this.name) &&
|
|
207
|
+
!$from.parent.textContent &&
|
|
208
|
+
isTextSelection(selection)) {
|
|
209
|
+
// Get the start position of the codeblock for node selection
|
|
210
|
+
const from = $from.pos - $from.parentOffset - 2;
|
|
211
|
+
editor.chain().setNodeSelection(from).deleteSelection().run();
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
return false;
|
|
215
|
+
},
|
|
216
|
+
Tab: ({ editor }) => {
|
|
217
|
+
if (!this.options.indentLineWithTab) {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
if (editor.isActive(this.name)) {
|
|
221
|
+
editor.commands.insertContent(" ");
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
return false;
|
|
225
|
+
},
|
|
226
|
+
Enter: ({ editor }) => {
|
|
227
|
+
const { $from } = editor.state.selection;
|
|
228
|
+
if (!editor.isActive(this.name)) {
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
const isAtEnd = $from.parentOffset === $from.parent.nodeSize - 2;
|
|
232
|
+
const endsWithDoubleNewline = $from.parent.textContent.endsWith("\n\n");
|
|
233
|
+
if (!isAtEnd || !endsWithDoubleNewline) {
|
|
234
|
+
editor.commands.insertContent("\n");
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
return editor
|
|
238
|
+
.chain()
|
|
239
|
+
.command(({ tr }) => {
|
|
240
|
+
tr.delete($from.pos - 2, $from.pos);
|
|
241
|
+
return true;
|
|
242
|
+
})
|
|
243
|
+
.exitCode()
|
|
244
|
+
.run();
|
|
245
|
+
},
|
|
246
|
+
"Shift-Enter": ({ editor }) => {
|
|
247
|
+
const { $from } = editor.state.selection;
|
|
248
|
+
if (!editor.isActive(this.name)) {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
editor
|
|
252
|
+
.chain()
|
|
253
|
+
.insertContentAt($from.pos - $from.parentOffset + $from.parent.nodeSize, {
|
|
254
|
+
type: "paragraph",
|
|
255
|
+
})
|
|
256
|
+
.run();
|
|
257
|
+
return true;
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
},
|
|
261
|
+
});
|
|
262
|
+
export const CodeBlock = createBlockSpecFromStronglyTypedTiptapNode(CodeBlockContent, defaultCodeBlockPropSchema);
|
|
263
|
+
export function customizeCodeBlock(options) {
|
|
264
|
+
return createBlockSpecFromStronglyTypedTiptapNode(CodeBlockContent.configure(options), {
|
|
265
|
+
language: {
|
|
266
|
+
default: options.defaultLanguage ||
|
|
267
|
+
defaultCodeBlockPropSchema.language.default,
|
|
268
|
+
values: options.supportedLanguages?.map((lang) => lang.id) ||
|
|
269
|
+
defaultCodeBlockPropSchema.language.values,
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
//# sourceMappingURL=CodeBlockContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeBlockContent.js","sourceRoot":"","sources":["../../../../src/blocks/CodeBlockContent/CodeBlockContent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAU,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAEL,oBAAoB,EACpB,iBAAiB,GAElB,MAAM,OAAO,CAAC;AACf,OAAO,EACL,0CAA0C,EAC1C,6BAA6B,GAE9B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EACL,yBAAyB,GAE1B,MAAM,gCAAgC,CAAC;AAQxC,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,QAAQ,EAAE;QACR,OAAO,EAAE,YAAY;QACrB,MAAM,EAAE,CAAC,GAAG,yBAAyB,CAAC,GA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ACE,QAAQ,EAAE;YACR,OAAO,EACL,OAAO,CAAC,eAAe;gBACvB,0BAA0B,CAAC,QAAQ,CAAC,OAAO;YAC7C,MAAM,EACJ,OAAO,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;gBAClD,0BAA0B,CAAC,QAAQ,CAAC,MAAM;SAC7C;KACF,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { bundledLanguagesInfo } from "shiki/bundle/web";
|
|
2
|
+
export const defaultSupportedLanguages = [
|
|
3
|
+
{
|
|
4
|
+
id: "text",
|
|
5
|
+
name: "Plain Text",
|
|
6
|
+
match: ["text", "txt", "plain"],
|
|
7
|
+
},
|
|
8
|
+
...bundledLanguagesInfo
|
|
9
|
+
.filter((lang) => {
|
|
10
|
+
return ![
|
|
11
|
+
"angular-html",
|
|
12
|
+
"angular-ts",
|
|
13
|
+
"astro",
|
|
14
|
+
"blade",
|
|
15
|
+
"coffee",
|
|
16
|
+
"handlebars",
|
|
17
|
+
"html-derivative",
|
|
18
|
+
"http",
|
|
19
|
+
"imba",
|
|
20
|
+
"jinja",
|
|
21
|
+
"jison",
|
|
22
|
+
"json5",
|
|
23
|
+
"marko",
|
|
24
|
+
"mdc",
|
|
25
|
+
"stylus",
|
|
26
|
+
"ts-tags",
|
|
27
|
+
].includes(lang.id);
|
|
28
|
+
})
|
|
29
|
+
.map((lang) => ({
|
|
30
|
+
match: [lang.id, ...(lang.aliases || [])],
|
|
31
|
+
id: lang.id,
|
|
32
|
+
name: lang.name,
|
|
33
|
+
})),
|
|
34
|
+
{
|
|
35
|
+
id: "haskell",
|
|
36
|
+
name: "Haskell",
|
|
37
|
+
match: ["haskell", "hs"],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: "csharp",
|
|
41
|
+
name: "C#",
|
|
42
|
+
match: ["c#", "csharp", "cs"],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: "latex",
|
|
46
|
+
name: "LaTeX",
|
|
47
|
+
match: ["latex"],
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: "lua",
|
|
51
|
+
name: "Lua",
|
|
52
|
+
match: ["lua"],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: "mermaid",
|
|
56
|
+
name: "Mermaid",
|
|
57
|
+
match: ["mermaid", "mmd"],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: "ruby",
|
|
61
|
+
name: "Ruby",
|
|
62
|
+
match: ["ruby", "rb"],
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: "rust",
|
|
66
|
+
name: "Rust",
|
|
67
|
+
match: ["rust", "rs"],
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
id: "scala",
|
|
71
|
+
name: "Scala",
|
|
72
|
+
match: ["scala"],
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
id: "swift",
|
|
76
|
+
name: "Swift",
|
|
77
|
+
match: ["swift"],
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: "kotlin",
|
|
81
|
+
name: "Kotlin",
|
|
82
|
+
match: ["kotlin", "kt", "kts"],
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: "objective-c",
|
|
86
|
+
name: "Objective C",
|
|
87
|
+
match: ["objective-c", "objc"],
|
|
88
|
+
},
|
|
89
|
+
];
|
|
90
|
+
//# sourceMappingURL=defaultSupportedLanguages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultSupportedLanguages.js","sourceRoot":"","sources":["../../../../src/blocks/CodeBlockContent/defaultSupportedLanguages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAQxD,MAAM,CAAC,MAAM,yBAAyB,GAA8B;IAClE;QACE,EAAE,EAAE,MAAM;QACV,IAAI,EAA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