mirror of
https://github.com/zadam/trilium.git
synced 2026-03-16 00:50:22 +01:00
pdf.js floating highlight button (#9048)
This commit is contained in:
@@ -18,6 +18,8 @@ async function main() {
|
||||
interceptPersistence(getCustomAppOptions(urlParams));
|
||||
}
|
||||
|
||||
configurePdfViewerOptions();
|
||||
|
||||
// Wait for the PDF viewer application to be available.
|
||||
while (!window.PDFViewerApplication) {
|
||||
await new Promise(r => setTimeout(r, 50));
|
||||
@@ -39,6 +41,19 @@ async function main() {
|
||||
await app.initializedPromise;
|
||||
};
|
||||
|
||||
function configurePdfViewerOptions() {
|
||||
const pdfOptionsHandler = (event: CustomEvent) => {
|
||||
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", pdfOptionsHandler, { once: true });
|
||||
window.addEventListener("pagehide", () => window.parent?.removeEventListener("webviewerloaded", pdfOptionsHandler));
|
||||
}
|
||||
}
|
||||
|
||||
function hideSidebar() {
|
||||
window.TRILIUM_HIDE_SIDEBAR = true;
|
||||
const toggleButtonEl = document.getElementById("viewsManagerToggleButton");
|
||||
|
||||
1
packages/pdfjs-viewer/src/typings.d.ts
vendored
1
packages/pdfjs-viewer/src/typings.d.ts
vendored
@@ -46,5 +46,6 @@ declare global {
|
||||
};
|
||||
store: ViewHistory;
|
||||
};
|
||||
PDFViewerApplicationOptions?: { set(name: string, value: any): void; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user