Skip to content

Commit

Permalink
feat: add waitForStyles option to iframe config
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Sep 14, 2024
1 parent cd4438e commit bc81d9c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
11 changes: 8 additions & 3 deletions apps/docs/pages/docs/api-reference/components/puck.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,21 @@ export function Editor() {

#### iframe params

| Param | Example | Type | Status |
| --------------------- | ---------------- | ------- | ------ |
| [`enabled`](#enabled) | `enabled: false` | boolean | - |
| Param | Example | Type | Status |
| ------------------------------- | ---------------------- | ------- | ------ |
| [`enabled`](#enabled) | `enabled: false` | boolean | - |
| [`waitForStyles`](#deferrender) | `waitForStyles: false` | boolean | - |

##### `enabled`

Render the Puck preview within iframe. Defaults to `true`.

Disabling iframes will also disable [viewports](#viewports).

##### `waitForStyles`

Defer rendering of the Puck preview until the iframe styles have loaded, showing a spinner. Defaults to `true`.

### `initialHistory`

Sets the undo/redo Puck history state when using the `usePuck` [history API](/docs/api-reference/functions/use-puck#history).
Expand Down
2 changes: 1 addition & 1 deletion packages/core/components/Puck/components/Canvas/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const Canvas = () => {
return (
<div
className={getClassName({
ready: status === "READY" || !iframe.enabled,
ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
showLoader,
})}
onClick={() =>
Expand Down
1 change: 1 addition & 0 deletions packages/core/components/Puck/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export function Puck<
}) {
const iframe: IframeConfig = {
enabled: true,
waitForStyles: true,
..._iframe,
};

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 @@ -13,6 +13,7 @@ export type Permissions = {

export type IframeConfig = {
enabled?: boolean;
waitForStyles?: boolean;
};

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

0 comments on commit bc81d9c

Please sign in to comment.