fix: 修复查看全部按钮导致artifacts失效

This commit is contained in:
lloydzhou 2024-08-20 23:00:19 +08:00
parent a6b14c7910
commit cd49c12181
2 changed files with 4 additions and 5 deletions

View File

@ -79,6 +79,7 @@ export function PreCode(props: { children: any }) {
setMermaidCode((mermaidDom as HTMLElement).innerText);
}
const htmlDom = ref.current.querySelector("code.language-html");
const refText = ref.current?.innerText;
if (htmlDom) {
setHtmlCode((htmlDom as HTMLElement).innerText);
} else if (refText?.startsWith("<!DOCTYPE")) {
@ -86,11 +87,6 @@ export function PreCode(props: { children: any }) {
}
}, 600);
useEffect(() => {
setTimeout(renderArtifacts, 1);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [refText]);
const enableArtifacts = useMemo(
() => plugins?.includes(Plugin.Artifacts),
[plugins],
@ -119,6 +115,7 @@ export function PreCode(props: { children: any }) {
codeElement.style.whiteSpace = "pre-wrap";
}
});
setTimeout(renderArtifacts, 1);
}
}, []);

View File

@ -314,7 +314,9 @@ code{
height: fit-content;
display: inline-flex;
justify-content: center;
pointer-events: none;
button{
pointer-events: auto;
margin-top: 3em;
margin-bottom: 4em;
padding: 5px 16px;