Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/core/components/AutoFrame/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from "react";
import hash from "object-hash";
import { createPortal } from "react-dom";
import { usePropsContext } from "../Puck";

const styleSelector = 'style, link[rel="stylesheet"]';

Expand Down Expand Up @@ -285,7 +286,6 @@ const CopyHostStyles = ({
});

// Reset HTML (inside the promise) so in case running twice (i.e. for React Strict mode)
doc.head.innerHTML = "";

// Inject initial values in bulk
doc.head.append(...filtered);
Expand Down Expand Up @@ -340,6 +340,9 @@ function AutoFrame({
const [ctx, setCtx] = useState<AutoFrameContext>({});
const [mountTarget, setMountTarget] = useState<HTMLElement | null>();
const [stylesLoaded, setStylesLoaded] = useState(false);
const {
srcDoc = '<!DOCTYPE html><html><head></head><body><div id="frame-root" data-puck-entry></div></body></html>',
} = usePropsContext().iframe ?? {};

useEffect(() => {
if (frameRef.current) {
Expand Down Expand Up @@ -368,7 +371,7 @@ function AutoFrame({
{...props}
className={className}
id={id}
srcDoc='<!DOCTYPE html><html><head></head><body><div id="frame-root" data-puck-entry></div></body></html>'
srcDoc={srcDoc}
ref={frameRef}
onLoad={() => {
setLoaded(true);
Expand Down
1 change: 1 addition & 0 deletions packages/core/types/API/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type Permissions = {
export type IframeConfig = {
enabled?: boolean;
waitForStyles?: boolean;
srcDoc?: string;
};

export type OnAction<UserData extends Data = Data> = (
Expand Down