Explorar el Código

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

lloydzhou hace 1 año
padre
commit
cd49c12181
Se han modificado 2 ficheros con 4 adiciones y 5 borrados
  1. 2 5
      app/components/markdown.tsx
  2. 2 0
      app/styles/globals.scss

+ 2 - 5
app/components/markdown.tsx

@@ -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);
     }
   }, []);
 

+ 2 - 0
app/styles/globals.scss

@@ -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;