-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Syntax highlight for job input and output data
- Loading branch information
Showing
5 changed files
with
192 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { useMemo } from "react"; | ||
|
||
// @ts-expect-error | ||
import { Light as SyntaxHighlighter } from "react-syntax-highlighter"; | ||
|
||
// @ts-expect-error | ||
import json from "react-syntax-highlighter/dist/esm/languages/hljs/json"; | ||
|
||
// @ts-expect-error | ||
import style from "react-syntax-highlighter/dist/esm/styles/hljs/stackoverflow-light"; | ||
|
||
style["hljs"].padding = "1rem"; | ||
delete style["hljs"].background; | ||
|
||
SyntaxHighlighter.registerLanguage("json", json); | ||
|
||
type SyntaxHighlightProps = { | ||
json: string; | ||
}; | ||
|
||
export function JsonHighlight({ json }: SyntaxHighlightProps) { | ||
const data = useMemo(() => { | ||
const parsed = JSON.parse(json); | ||
return JSON.stringify(parsed, null, 2); | ||
}, [json]); | ||
|
||
return ( | ||
<SyntaxHighlighter | ||
className="rounded-md text-xs border border-border" | ||
style={style} | ||
language="json" | ||
> | ||
{data} | ||
</SyntaxHighlighter> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.