fix: cross-window CSSStyleSheet crash in preview/export

This commit is contained in:
Walid 2026-07-19 13:32:24 +06:00
parent 156a14ee9b
commit 57b1645e9f
3 changed files with 7 additions and 7 deletions

File diff suppressed because one or more lines are too long

View file

@ -433,11 +433,11 @@ export class PDFExportModal extends Modal {
if (immediate) {
// Double rAF: ensures the spinner paints before synchronous pagination blocks the thread.
window.requestAnimationFrame(() => window.requestAnimationFrame(() => void safeDo()));
activeWindow.requestAnimationFrame(() => activeWindow.requestAnimationFrame(() => void safeDo()));
} else {
this.renderDebounceTimer = window.setTimeout(() => {
this.renderDebounceTimer = null;
window.requestAnimationFrame(() => window.requestAnimationFrame(() => void safeDo()));
activeWindow.requestAnimationFrame(() => activeWindow.requestAnimationFrame(() => void safeDo()));
}, 150);
}
}
@ -601,7 +601,7 @@ export class PDFExportModal extends Modal {
.mpdf-hf-right { margin-left: auto; }
${docCSS}
`;
const pageSheet = new CSSStyleSheet();
const pageSheet = new (activeWindow as unknown as typeof window).CSSStyleSheet();
pageSheet.replaceSync(shadowCSS);
for (const layout of layouts) {

View file

@ -375,7 +375,7 @@ export function paginateEl(
const sandboxShadow = sandboxHost.attachShadow({ mode: "open" });
const sandboxSheet = new CSSStyleSheet();
const sandboxSheet = new (activeWindow as unknown as typeof window).CSSStyleSheet();
sandboxSheet.replaceSync(docCSS);
sandboxShadow.adoptedStyleSheets = [sandboxSheet];