Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(pdfjs): address requested changes
Elian Doran51b0eb74a5b0
diff --git a/apps/client/src/widgets/type_widgets/file/Pdf.tsx b/apps/client/src/widgets/type_widgets/file/Pdf.tsxindex fcce704cff..f254e13c44 100644--- a/apps/client/src/widgets/type_widgets/file/Pdf.tsx+++ b/apps/client/src/widgets/type_widgets/file/Pdf.tsx@@ -99,7 +99,7 @@ function useStyleInjection(iframeRef: RefObject<HTMLIFrameElement>) {function getRootCssVariables() {const styles = getComputedStyle(document.documentElement);- const vars = {};+ const vars: Record<string, string> = {};for (let i = 0; i < styles.length; i++) {const prop = styles[i];@@ -111,7 +111,7 @@ function getRootCssVariables() {return vars;}-function cssVarsToString(vars) {+function cssVarsToString(vars: Record<string, string>) {return `:root {\n${Object.entries(vars).map(([k, v]) => ` ${k}: ${v};`).join('\n')}\n}`;diff --git a/packages/pdfjs-viewer/src/custom.ts b/packages/pdfjs-viewer/src/custom.tsindex 99f66c26b8..39f5881195 100644--- a/packages/pdfjs-viewer/src/custom.ts+++ b/packages/pdfjs-viewer/src/custom.ts@@ -1,9 +1,6 @@import interceptPersistence from "./persistence";-const LOG_EVENT_BUS = false;-async function main() {- console.log("Hi");interceptPersistence(getCustomAppOptions());// Wait for the PDF viewer application to be available.@@ -66,15 +63,4 @@ function manageSave() {});}-function patchEventBus() {- const eventBus = window.PDFViewerApplication.eventBus;- const originalDispatch = eventBus.dispatch.bind(eventBus);-- eventBus.dispatch = (type: string, data?: any) => {- console.log("PDF.js event:", type, data);- return originalDispatch(type, data);- };-}-main();-console.log("Custom script loaded");diff --git a/packages/pdfjs-viewer/src/persistence.ts b/packages/pdfjs-viewer/src/persistence.tsindex a706712628..7f0110799d 100644--- a/packages/pdfjs-viewer/src/persistence.ts+++ b/packages/pdfjs-viewer/src/persistence.ts@@ -1,4 +1,6 @@export default function interceptViewHistory(customOptions?: object) {+ // We need to monkey-patch the localStorage used by PDF.js to store view history.+ // Other attempts to intercept the history saving/loading (like overriding methods on PDFViewerApplication) have failed.const originalSetItem = Storage.prototype.setItem;Storage.prototype.setItem = function (key: string, value: string) {if (key === "pdfjs.history") {