mirror of
https://github.com/zadam/trilium.git
synced 2026-01-06 14:44:25 +01:00
fix(pdfjs): preferences don't account for ntxId or noteId
This commit is contained in:
parent
120bb09171
commit
44d1d01105
11
apps/client/src/types-pdfjs.d.ts
vendored
11
apps/client/src/types-pdfjs.d.ts
vendored
@ -38,14 +38,17 @@ interface PdfOutlineItem {
|
|||||||
items: PdfOutlineItem[];
|
items: PdfOutlineItem[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PdfDocumentModifiedMessage {
|
interface WithContext {
|
||||||
type: "pdfjs-viewer-document-modified";
|
|
||||||
data: Uint8Array<ArrayBufferLike>;
|
|
||||||
ntxId: string;
|
ntxId: string;
|
||||||
noteId: string | null | undefined;
|
noteId: string | null | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PdfSaveViewHistoryMessage {
|
interface PdfDocumentModifiedMessage extends WithContext {
|
||||||
|
type: "pdfjs-viewer-document-modified";
|
||||||
|
data: Uint8Array<ArrayBufferLike>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PdfSaveViewHistoryMessage extends WithContext {
|
||||||
type: "pdfjs-viewer-save-view-history";
|
type: "pdfjs-viewer-save-view-history";
|
||||||
data: string;
|
data: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,7 +38,9 @@ export default function PdfPreview({ note, blob, componentId, noteContext }: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event.data.type === "pdfjs-viewer-save-view-history" && event.data?.data) {
|
if (event.data.type === "pdfjs-viewer-save-view-history" && event.data?.data) {
|
||||||
historyConfig?.storeFn(JSON.parse(event.data.data));
|
if (event.data.noteId === note.noteId && event.data.ntxId === noteContext.ntxId) {
|
||||||
|
historyConfig?.storeFn(JSON.parse(event.data.data));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.data.type === "pdfjs-viewer-toc") {
|
if (event.data.type === "pdfjs-viewer-toc") {
|
||||||
|
|||||||
@ -41,7 +41,9 @@ function saveHistory(value: string) {
|
|||||||
|
|
||||||
window.parent.postMessage({
|
window.parent.postMessage({
|
||||||
type: "pdfjs-viewer-save-view-history",
|
type: "pdfjs-viewer-save-view-history",
|
||||||
data: JSON.stringify(history)
|
data: JSON.stringify(history),
|
||||||
|
ntxId: window.TRILIUM_NTX_ID,
|
||||||
|
noteId: window.TRILIUM_NOTE_ID
|
||||||
} satisfies PdfSaveViewHistoryMessage, window.location.origin);
|
} satisfies PdfSaveViewHistoryMessage, window.location.origin);
|
||||||
saveTimeout = null;
|
saveTimeout = null;
|
||||||
}, 2_000);
|
}, 2_000);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user