use postMessage

This commit is contained in:
Rami Bitar
2026-05-02 09:53:48 -04:00
parent e17fefe025
commit 82809b17b4
4 changed files with 9 additions and 76 deletions

View File

@@ -88,11 +88,12 @@ export default function EditorClient({
const persist = useCallback(async (route: string, next: any) => {
setSchema((s) => ({ ...s, [route]: next }));
await fetch("/api/save-schema", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ route, data: next }),
});
if (typeof window !== "undefined" && window.parent !== window) {
window.parent.postMessage(
{ type: "PUBLISH", path: route, data: next },
"*",
);
}
}, []);
const plugins = useMemo(