mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-20 03:47:01 -04:00
fix(ShikiCodeblocks): spoilers (#298)
* fix(ShikiCodeblocks): spoilers * fix a settings bug i thikn
This commit is contained in:
parent
2d08dd8a9c
commit
2de461985d
3 changed files with 25 additions and 9 deletions
|
@ -46,9 +46,11 @@ export interface HighlighterProps {
|
|||
}
|
||||
|
||||
export const createHighlighter = (props: HighlighterProps) => (
|
||||
<ErrorBoundary>
|
||||
<Highlighter {...props} />
|
||||
</ErrorBoundary>
|
||||
<pre className={cl("container")}>
|
||||
<ErrorBoundary>
|
||||
<Highlighter {...props} />
|
||||
</ErrorBoundary>
|
||||
</pre>
|
||||
);
|
||||
export const Highlighter = ({
|
||||
lang,
|
||||
|
@ -66,7 +68,7 @@ export const Highlighter = ({
|
|||
const shikiLang = lang ? resolveLang(lang) : null;
|
||||
const useHljs = shouldUseHljs({ lang, tryHljs });
|
||||
|
||||
const [preRef, isIntersecting] = useIntersection(true);
|
||||
const [rootRef, isIntersecting] = useIntersection(true);
|
||||
|
||||
const [tokens] = useAwaiter(async () => {
|
||||
if (!shikiLang || useHljs || !isIntersecting) return null;
|
||||
|
@ -93,8 +95,8 @@ export const Highlighter = ({
|
|||
if (isPreview) preClasses.push(cl("preview"));
|
||||
|
||||
return (
|
||||
<pre
|
||||
ref={preRef}
|
||||
<div
|
||||
ref={rootRef}
|
||||
className={preClasses.join(" ")}
|
||||
style={{
|
||||
backgroundColor: useHljs
|
||||
|
@ -123,7 +125,7 @@ export const Highlighter = ({
|
|||
theme={themeBase}
|
||||
/>}
|
||||
</code>
|
||||
</pre>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue