MCPcopy
hub / github.com/d3george/slash-admin / HighlightCode

Function HighlightCode

src/components/code/highlight-code.tsx:15–46  ·  view source on GitHub ↗
({ code, options, className, withCopy = true }: HighlightCodeProps)

Source from the content-addressed store, hash-verified

13});
14
15export function HighlightCode({ code, options, className, withCopy = true }: HighlightCodeProps) {
16 const { copyFn } = useCopyToClipboard();
17 const [hovered, setHovered] = useState(false);
18 const { themeMode } = useSettings();
19
20 return (
21 <div className={cn("w-full relative group", className)} onMouseEnter={() => setHovered(true)} onMouseLeave={() => setHovered(false)}>
22 {withCopy && hovered && (
23 <Button variant="outline" size="icon" className="absolute top-2 right-2 bg-accent" onClick={() => copyFn(code)}>
24 <Icon icon="eva:copy-fill" size={24} />
25 </Button>
26 )}
27 <div
28 // biome-ignore lint/security/noDangerouslySetInnerHtml: <explanation>
29 dangerouslySetInnerHTML={{
30 __html: highlighter.codeToHtml(code, {
31 lang: options?.lang || "typescript",
32 theme: options?.theme || (themeMode === "dark" ? "min-dark" : "snazzy-light"),
33 transformers: [
34 {
35 pre(node) {
36 this.addClassToHast(node, "p-3 rounded-md");
37 },
38 },
39 ],
40 ...options,
41 }),
42 }}
43 />
44 </div>
45 );
46}

Callers

nothing calls this directly

Calls 4

useCopyToClipboardFunction · 0.90
useSettingsFunction · 0.90
cnFunction · 0.90
copyFnFunction · 0.85

Tested by

no test coverage detected