mirror of
https://github.com/zadam/trilium.git
synced 2026-01-01 12:14:24 +01:00
chore(client/pdf): basic reaction to annotations
This commit is contained in:
parent
41bcf9524a
commit
5e42627bce
@ -4,6 +4,7 @@ const build = new BuildHelper("packages/pdfjs-viewer");
|
||||
|
||||
async function main() {
|
||||
build.copy("viewer", "web");
|
||||
build.copy("src/custom.mjs", "web/custom.mjs");
|
||||
build.copy("/node_modules/pdfjs-dist/build/pdf.mjs", "build/pdf.mjs");
|
||||
build.copy("/node_modules/pdfjs-dist/build/pdf.worker.mjs", "build/pdf.worker.mjs");
|
||||
}
|
||||
|
||||
21
packages/pdfjs-viewer/src/custom.mjs
Normal file
21
packages/pdfjs-viewer/src/custom.mjs
Normal file
@ -0,0 +1,21 @@
|
||||
document.addEventListener("webviewerloaded", async () => {
|
||||
const app = PDFViewerApplication;
|
||||
await app.initializedPromise;
|
||||
|
||||
app.eventBus.on("documentloaded", () => {
|
||||
const storage = app.pdfDocument.annotationStorage;
|
||||
|
||||
storage.onSetModified = (data) => {
|
||||
console.log("Annotations modified: ", all);
|
||||
storage.resetModified();
|
||||
};
|
||||
|
||||
const oldSetValue = storage.setValue;
|
||||
storage.setValue = (key, value) => {
|
||||
console.log("Setting annotation: ", key, value);
|
||||
oldSetValue.call(storage, key, value);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
console.log("Custom script loaded");
|
||||
@ -33,7 +33,8 @@ See https://github.com/adobe-type-tools/cmap-resources
|
||||
|
||||
<link rel="stylesheet" href="viewer.css" />
|
||||
|
||||
<script src="viewer.mjs" type="module"></script>
|
||||
<script src="custom.mjs" type="module"></script>
|
||||
<script src="viewer.mjs" type="module"></script>
|
||||
</head>
|
||||
|
||||
<body tabindex="0">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user