fix: make highlight work in LoadedCode
This commit is contained in:
parent
2d051be06b
commit
8a39615ca9
@ -18,10 +18,10 @@ export const LoadedCode = forwardRef<HTMLPreElement, { from: string }>(
|
|||||||
})();
|
})();
|
||||||
}, [from]);
|
}, [from]);
|
||||||
|
|
||||||
const ref = useRef<HTMLElement | null>(null);
|
const ref = useRef<HTMLPreElement | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (ref.current && !ref.current.dataset.highlighted) {
|
if (state && ref.current && !ref.current.dataset.highlighted) {
|
||||||
hljs.highlightElement(ref.current);
|
hljs.highlightElement(ref.current);
|
||||||
}
|
}
|
||||||
}, [state]);
|
}, [state]);
|
||||||
@ -31,7 +31,7 @@ export const LoadedCode = forwardRef<HTMLPreElement, { from: string }>(
|
|||||||
className={`relative hljs w-full h-64 rounded-lg ${
|
className={`relative hljs w-full h-64 rounded-lg ${
|
||||||
!state ? "animate-pulse" : ""
|
!state ? "animate-pulse" : ""
|
||||||
}`}
|
}`}
|
||||||
ref={outRef}
|
ref={ref}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
preset="default"
|
preset="default"
|
||||||
@ -58,7 +58,7 @@ export const LoadedCode = forwardRef<HTMLPreElement, { from: string }>(
|
|||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
</Button>
|
</Button>
|
||||||
<code className="language-tsx" ref={ref}>
|
<code className="language-tsx" ref={outRef}>
|
||||||
{state ?? null}
|
{state ?? null}
|
||||||
</code>
|
</code>
|
||||||
</pre>
|
</pre>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user