diff --git a/src/system/Sandpack.ts b/src/system/Sandpack.ts index 863305bf..e5062212 100644 --- a/src/system/Sandpack.ts +++ b/src/system/Sandpack.ts @@ -109,7 +109,7 @@ const defaultSandpackConfig: SandpackConfig = { ] } -const defaultCodeBlockLanguages = { +export const defaultCodeBlockLanguages = { js: 'JavaScript', ts: 'TypeScript', tsx: 'TypeScript (React)', @@ -120,7 +120,7 @@ const defaultCodeBlockLanguages = { export const [SandpackSystem] = system( (r, [{ activeEditor, activeEditorType, createEditorSubscription }]) => { const sandpackConfig = r.node(defaultSandpackConfig) - const codeBlockLanguages = r.node(defaultCodeBlockLanguages) + const codeBlockLanguages = r.node>(defaultCodeBlockLanguages) const insertSandpack = r.node() const insertCodeBlock = r.node() diff --git a/src/ui/MDXEditor.tsx b/src/ui/MDXEditor.tsx index 10e57162..3feabd49 100644 --- a/src/ui/MDXEditor.tsx +++ b/src/ui/MDXEditor.tsx @@ -26,7 +26,7 @@ import { importMarkdownToLexical } from '../import' import { EditorSystemComponent, useEmitterValues, usePublisher } from '../system/EditorSystemComponent' -import { SandpackConfig } from '../system/Sandpack' +import { SandpackConfig, defaultCodeBlockLanguages } from '../system/Sandpack' import { NodeDecoratorComponents } from '../types/ExtendedEditorConfig' import { JsxComponentDescriptor } from '../types/JsxComponentDescriptors' import { ViewMode } from '../types/ViewMode' @@ -143,6 +143,7 @@ export interface MDXEditorProps { * The supported code block languages. */ codeBlockLanguages?: Record + /** * Implement this so that users can drag and drop or paste images into the editor. * Pass an implementation that takes a file as an argument, and returns Promise, where string is the url of the image to be inserted. @@ -331,7 +332,8 @@ export const MDXEditor = React.forwardRef( visitors: exportVisitors = Object.values(defaultLexicalVisitors) } = {}, lexicalNodes = Object.values(defaultLexicalNodes), - customLeafDirectiveEditors = [] + customLeafDirectiveEditors = [], + codeBlockLanguages = defaultCodeBlockLanguages }, ref ) => { @@ -361,6 +363,7 @@ export const MDXEditor = React.forwardRef( }} >