UNPKG

@roadiehq/rag-ai

Version:

29 lines (26 loc) 953 B
import { jsx } from 'react/jsx-runtime'; import { PrismAsyncLight } from 'react-syntax-highlighter'; import yaml from 'react-syntax-highlighter/dist/esm/languages/prism/yaml'; import json from 'react-syntax-highlighter/dist/esm/languages/prism/json'; import { oneLight, oneDark } from 'react-syntax-highlighter/dist/esm/styles/prism'; import { useTheme, Box } from '@material-ui/core'; PrismAsyncLight.registerLanguage("yaml", yaml); PrismAsyncLight.registerLanguage("json", json); const CodeHighlighter = ({ text, language = "yaml", showLineNumbers = true }) => { const theme = useTheme(); return /* @__PURE__ */ jsx(Box, { maxHeight: "20em", overflow: "scroll", children: /* @__PURE__ */ jsx( PrismAsyncLight, { language, style: theme.palette.type === "light" ? oneLight : oneDark, showLineNumbers, children: text } ) }); }; export { CodeHighlighter }; //# sourceMappingURL=CodeHighlighter.esm.js.map