QUESTPIE
Admin WorkspaceLive Preview

Preview Protocol Reference

postMessage protocol for the existing FormView + LivePreviewMode iframe preview system.

The preview protocol connects the admin form and the frontend iframe. Messages are implementation details of the current Live Preview system: the form is authoritative, the iframe mirrors data, and persistence still goes through the existing save/autosave path.

Message Families

DirectionMessagePurpose
preview -> adminPREVIEW_READYiframe loaded and can receive messages
admin -> previewINIT_SNAPSHOTseed iframe local draft from the form snapshot
admin -> previewPATCH_BATCHapply unsaved field changes
preview -> adminPATCH_APPLIEDacknowledge an applied patch batch
admin -> previewPREVIEW_REFRESHask iframe to re-run its loader
preview -> adminREFRESH_COMPLETErefresh finished
preview -> adminFIELD_CLICKEDuser clicked an annotated frontend field
preview -> adminBLOCK_CLICKEDuser clicked an annotated frontend block
admin -> previewFOCUS_FIELDhighlight a frontend field
admin -> previewSELECT_BLOCKhighlight a frontend block
preview -> adminFIELD_VALUE_EDITEDuser committed an inline scalar edit in the iframe
admin -> previewCOMMITsave succeeded, replace mirror with saved snapshot
admin -> previewFULL_RESYNCdiscard local mirror and reload from the loader
preview -> adminRESYNC_REQUESTiframe detected mismatch and asks for refresh

Handshake

Mermaid

Patch Batch

Mermaid

Patch paths use dot notation:

type PreviewPatchOp = {
	op: "set" | "remove";
	path: string;
	value?: unknown;
};

type PatchBatchMessage = {
	type: "PATCH_BATCH";
	seq: number;
	ops: PreviewPatchOp[];
	snapshotVersion?: number;
};

Examples:

title
seo.description
content._values.block_123.heading

Inline Edit

Mermaid

Suggested payload:

type FieldValueEditedMessage = {
	type: "FIELD_VALUE_EDITED";
	path: string;
	value: unknown;
	inputKind: "text" | "textarea" | "number" | "boolean";
	blockId?: string;
	fieldType?: "regular" | "block" | "relation";
};

The admin must only call form.setValue after the message is validated against the active schema and supported editable field types.

Commit

Mermaid

COMMIT does not save from the iframe. It tells the iframe that the existing form save succeeded and that the saved snapshot is now the baseline.

Resync

Mermaid

Use FULL_RESYNC for locale changes, workflow stage changes, restore/revert actions, sequence gaps, schema mismatches, and block tree changes that cannot be safely patched.

Security Rules

Mermaid

Admin-side handlers must validate:

  • message origin
  • active preview session
  • message type and payload shape
  • field path exists in the active collection schema or block value map
  • field type supports the requested inline edit kind
  • value is serializable and reasonably sized

Do not use wildcard postMessage targets when the preview origin can be resolved from .preview({ url }). Do not allow iframe messages to set arbitrary form paths.

On this page