Skip to content

Commit

Permalink
fix: artifact render error (ChatGPTNextWeb#5306)
Browse files Browse the repository at this point in the history
fix: artifact render error
  • Loading branch information
mayfwl authored Aug 21, 2024
1 parent 1748dd6 commit 4ec6b06
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/components/artifacts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down

0 comments on commit 4ec6b06

Please sign in to comment.