Преглед на файлове

fix: artifact render error (#5306)

fix: artifact render error
mayfwl преди 1 година
родител
ревизия
4ec6b067e7
променени са 1 файла, в които са добавени 3 реда и са изтрити 3 реда
  1. 3 3
      app/components/artifacts.tsx

+ 3 - 3
app/components/artifacts.tsx

@@ -81,10 +81,10 @@ export const HTMLPreview = forwardRef<HTMLPreviewHander, HTMLPreviewProps>(
 
     const srcDoc = useMemo(() => {
       const script = `<script>new ResizeObserver((entries) => parent.postMessage({id: '${frameId}', height: entries[0].target.clientHeight}, '*')).observe(document.body)</script>`;
-      if (props.code.includes("</head>")) {
-        props.code.replace("</head>", "</head>" + script);
+      if (props.code.includes("<!DOCTYPE html>")) {
+        props.code.replace("<!DOCTYPE html>", "<!DOCTYPE html>" + script);
       }
-      return props.code + script;
+      return script + props.code;
     }, [props.code, frameId]);
 
     const handleOnLoad = () => {