fix(client/pdfjs): not reacting to all changes

This commit is contained in:
Elian Doran 2025-12-29 10:33:57 +02:00
parent 3e255fa647
commit 08f6a32c34
No known key found for this signature in database

View File

@ -16,8 +16,8 @@ async function main() {
clearTimeout(timeout);
}
timeout = setTimeout(async () => {
console.log("Triggered debounce save");
const data = await app.pdfDocument.saveDocument();
if (!storage) return;
const data = await app.pdfDocument.saveDocument(storage);
window.parent.postMessage({
type: "pdfjs-viewer-document-modified",
data: data
@ -27,9 +27,16 @@ async function main() {
}, 2_000);
}
storage.onSetModified = async () => {
debouncedSave();
};
app.eventBus.on("annotationeditorcommit", debouncedSave);
app.eventBus.on("annotationeditorparamschanged", debouncedSave);
app.eventBus.on("annotationeditorstateschanged", evt => {
const { activeEditorId } = evt;
// When activeEditorId becomes null, an editor was just committed
if (activeEditorId === null) {
debouncedSave();
}
});
});
};