Skip to content

Commit

Permalink
fix(code-viewer): support additionalLanguages (#889)
Browse files Browse the repository at this point in the history
  • Loading branch information
danilowoz committed Apr 6, 2023
1 parent 2a7212c commit 99cb481
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion sandpack-react/src/components/CodeViewer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useClasser } from "@code-hike/classer";
import * as React from "react";

import type { SandpackInitMode } from "../..";
import type { CustomLanguage, SandpackInitMode } from "../..";
import { useActiveCode } from "../../hooks/useActiveCode";
import { useSandpack } from "../../hooks/useSandpack";
import { THEME_PREFIX } from "../../styles";
Expand Down Expand Up @@ -30,6 +30,12 @@ export interface CodeViewerProps {
* a certain control of when to initialize them.
*/
initMode?: SandpackInitMode;
/**
* Provides a way to add custom language modes by supplying a language
* type, applicable file extensions, and a LanguageSupport instance
* for that syntax mode
*/
additionalLanguages?: CustomLanguage[];
}

export const SandpackCodeViewer = React.forwardRef<
Expand All @@ -44,6 +50,7 @@ export const SandpackCodeViewer = React.forwardRef<
code: propCode,
initMode,
wrapContent,
additionalLanguages,
...props
},
ref
Expand All @@ -61,6 +68,7 @@ export const SandpackCodeViewer = React.forwardRef<
<div className={classNames(c("code-editor"), editorClassName)}>
<CodeEditor
ref={ref}
additionalLanguages={additionalLanguages}
code={propCode ?? code}
decorators={decorators}
filePath={sandpack.activeFile}
Expand Down

1 comment on commit 99cb481

@vercel
Copy link

@vercel vercel bot commented on 99cb481 Apr 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.