mirror of
https://github.com/zadam/trilium.git
synced 2025-12-31 03:34:23 +01:00
chore(pdfjs): address requested changes
This commit is contained in:
parent
2304407986
commit
51b0eb74a5
@ -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}`;
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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") {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user