Replies: 1 comment
-
|
Ok. So I found a workaround that seems to work for me. Instead of changing the src on the So the canvasTweaksPlugin function becomes the following. export function canvasTweaksPlugin(projectId: string) {
return (editor: Editor) => {
editor.on("frame:render", ({ el }: { el: HTMLIFrameElement }) => {
const virtualUrl = `/virtual-preview-frame?projectId=${projectId}`;
if (el.src === "about:blank" || el.src === "") {
// Set a src for the service worker to intercept
// This is a workaround for 'about:blank' iframes losing controller inheritance
el.src = virtualUrl;
}
});
if (!editor.config.canvas) {
editor.config.canvas = {};
}
editor.config.canvas.frameContent = getIframeContents(projectId);
};
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is there a clean way to set the src of the iframe?
I am looking for a way to have a service worker control the loaded assets or urls from the editor. I already have a Service Worker initiated on the parent page and working. The content from the editor internal iframe however is a bit more difficult.
According to AI agents, JS spec should allow
about:blanksrc iframes to be controlled from the parent window SW. But I ran into issues.So here's some of the code I hacked together to somewhat get it to work. I get the requests from inside of the iframe in my SW, but as expected, it breaks things with the editor to do a in place reload.
The visible content stays there, but as soon as I scroll, it becomes blank.

Plugin
Service Worker
Beta Was this translation helpful? Give feedback.
All reactions