Re-render annotation images when rotating a page
Fixes #2824
(cherry picked from commit 006dd20d5b
)
This commit is contained in:
parent
ef5e80d4dc
commit
acfbbebd85
2 changed files with 19 additions and 23 deletions
|
@ -340,12 +340,12 @@ class ReaderInstance {
|
|||
return !index;
|
||||
}
|
||||
|
||||
async reload() {
|
||||
async reload(data) {
|
||||
let item = Zotero.Items.get(this._itemID);
|
||||
let path = await item.getFilePathAsync();
|
||||
let buf = await OS.File.read(path, {});
|
||||
buf = new Uint8Array(buf).buffer;
|
||||
this._postMessage({ action: 'reload', buf, }, [buf]);
|
||||
this._postMessage({ action: 'reload', buf, data }, [buf]);
|
||||
}
|
||||
|
||||
async menuCmd(cmd) {
|
||||
|
@ -892,7 +892,7 @@ class ReaderInstance {
|
|||
menuitem.addEventListener('command', async () => {
|
||||
this._postMessage({ action: 'reloading' });
|
||||
await Zotero.PDFWorker.rotatePages(this._itemID, data.pageIndexes, 270, true);
|
||||
await this.reload();
|
||||
await this.reload({ rotatedPageIndexes: data.pageIndexes });
|
||||
});
|
||||
popup.appendChild(menuitem);
|
||||
// Rotate Right
|
||||
|
@ -901,7 +901,7 @@ class ReaderInstance {
|
|||
menuitem.addEventListener('command', async () => {
|
||||
this._postMessage({ action: 'reloading' });
|
||||
await Zotero.PDFWorker.rotatePages(this._itemID, data.pageIndexes, 90, true);
|
||||
await this.reload();
|
||||
await this.reload({ rotatedPageIndexes: data.pageIndexes });
|
||||
});
|
||||
popup.appendChild(menuitem);
|
||||
// Rotate 180
|
||||
|
@ -910,7 +910,7 @@ class ReaderInstance {
|
|||
menuitem.addEventListener('command', async () => {
|
||||
this._postMessage({ action: 'reloading' });
|
||||
await Zotero.PDFWorker.rotatePages(this._itemID, data.pageIndexes, 180, true);
|
||||
await this.reload();
|
||||
await this.reload({ rotatedPageIndexes: data.pageIndexes });
|
||||
});
|
||||
popup.appendChild(menuitem);
|
||||
// Separator
|
||||
|
@ -1026,23 +1026,19 @@ class ReaderInstance {
|
|||
|
||||
// Note: annotation.image is always saved separately from the rest
|
||||
// of annotation properties
|
||||
|
||||
let item = Zotero.Items.getByLibraryAndKey(attachment.libraryID, annotation.key);
|
||||
// Save image for read-only annotation.
|
||||
if (item
|
||||
&& !item.isEditable()
|
||||
&& annotation.image
|
||||
&& !await Zotero.Annotations.hasCacheImage(item)
|
||||
) {
|
||||
let blob = this._dataURLtoBlob(annotation.image);
|
||||
await Zotero.Annotations.saveCacheImage(item, blob);
|
||||
continue;
|
||||
}
|
||||
|
||||
let savedAnnotation = await Zotero.Annotations.saveFromJSON(attachment, annotation, saveOptions);
|
||||
if (annotation.image && !await Zotero.Annotations.hasCacheImage(savedAnnotation)) {
|
||||
let blob = this._dataURLtoBlob(annotation.image);
|
||||
await Zotero.Annotations.saveCacheImage(savedAnnotation, blob);
|
||||
if (annotation.image) {
|
||||
if (this._isReadOnly()) {
|
||||
let item = Zotero.Items.getByLibraryAndKey(attachment.libraryID, annotation.key);
|
||||
if (item) {
|
||||
let blob = this._dataURLtoBlob(annotation.image);
|
||||
await Zotero.Annotations.saveCacheImage(item, blob);
|
||||
}
|
||||
}
|
||||
else {
|
||||
let savedAnnotation = await Zotero.Annotations.saveFromJSON(attachment, annotation, saveOptions);
|
||||
let blob = this._dataURLtoBlob(annotation.image);
|
||||
await Zotero.Annotations.saveCacheImage(savedAnnotation, blob);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit d03bd798fe01c5285c1671da37cee75036d0233d
|
||||
Subproject commit ae444f1b72849b732b4b79957688c0375b6055eb
|
Loading…
Add table
Reference in a new issue