add unload handler

This commit is contained in:
contributor
2026-03-14 00:46:55 +02:00
parent 6ab421ffa0
commit 9a9cfdec2b

View File

@@ -18,13 +18,15 @@ async function main() {
interceptPersistence(getCustomAppOptions(urlParams));
}
const pdfOptionsHandler = (event) => {
if (event.detail?.source === window && window.PDFViewerApplicationOptions) {
window.PDFViewerApplicationOptions.set("disablePreferences", true);
window.PDFViewerApplicationOptions.set("enableHighlightFloatingButton", true);
}
};
if (window.parent && window.parent !== window) {
window.parent.addEventListener('webviewerloaded', (event) => {
if (event.detail?.source === window && window.PDFViewerApplicationOptions) {
window.PDFViewerApplicationOptions.set("disablePreferences", true);
window.PDFViewerApplicationOptions.set("enableHighlightFloatingButton", true);
}
});
window.parent.addEventListener('webviewerloaded', pdfOptionsHandler);
window.addEventListener('unload', () => window.parent.removeEventListener('webviewerloaded', pdfOptionsHandler));
}
// Wait for the PDF viewer application to be available.