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;
|
return !index;
|
||||||
}
|
}
|
||||||
|
|
||||||
async reload() {
|
async reload(data) {
|
||||||
let item = Zotero.Items.get(this._itemID);
|
let item = Zotero.Items.get(this._itemID);
|
||||||
let path = await item.getFilePathAsync();
|
let path = await item.getFilePathAsync();
|
||||||
let buf = await OS.File.read(path, {});
|
let buf = await OS.File.read(path, {});
|
||||||
buf = new Uint8Array(buf).buffer;
|
buf = new Uint8Array(buf).buffer;
|
||||||
this._postMessage({ action: 'reload', buf, }, [buf]);
|
this._postMessage({ action: 'reload', buf, data }, [buf]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async menuCmd(cmd) {
|
async menuCmd(cmd) {
|
||||||
|
@ -892,7 +892,7 @@ class ReaderInstance {
|
||||||
menuitem.addEventListener('command', async () => {
|
menuitem.addEventListener('command', async () => {
|
||||||
this._postMessage({ action: 'reloading' });
|
this._postMessage({ action: 'reloading' });
|
||||||
await Zotero.PDFWorker.rotatePages(this._itemID, data.pageIndexes, 270, true);
|
await Zotero.PDFWorker.rotatePages(this._itemID, data.pageIndexes, 270, true);
|
||||||
await this.reload();
|
await this.reload({ rotatedPageIndexes: data.pageIndexes });
|
||||||
});
|
});
|
||||||
popup.appendChild(menuitem);
|
popup.appendChild(menuitem);
|
||||||
// Rotate Right
|
// Rotate Right
|
||||||
|
@ -901,7 +901,7 @@ class ReaderInstance {
|
||||||
menuitem.addEventListener('command', async () => {
|
menuitem.addEventListener('command', async () => {
|
||||||
this._postMessage({ action: 'reloading' });
|
this._postMessage({ action: 'reloading' });
|
||||||
await Zotero.PDFWorker.rotatePages(this._itemID, data.pageIndexes, 90, true);
|
await Zotero.PDFWorker.rotatePages(this._itemID, data.pageIndexes, 90, true);
|
||||||
await this.reload();
|
await this.reload({ rotatedPageIndexes: data.pageIndexes });
|
||||||
});
|
});
|
||||||
popup.appendChild(menuitem);
|
popup.appendChild(menuitem);
|
||||||
// Rotate 180
|
// Rotate 180
|
||||||
|
@ -910,7 +910,7 @@ class ReaderInstance {
|
||||||
menuitem.addEventListener('command', async () => {
|
menuitem.addEventListener('command', async () => {
|
||||||
this._postMessage({ action: 'reloading' });
|
this._postMessage({ action: 'reloading' });
|
||||||
await Zotero.PDFWorker.rotatePages(this._itemID, data.pageIndexes, 180, true);
|
await Zotero.PDFWorker.rotatePages(this._itemID, data.pageIndexes, 180, true);
|
||||||
await this.reload();
|
await this.reload({ rotatedPageIndexes: data.pageIndexes });
|
||||||
});
|
});
|
||||||
popup.appendChild(menuitem);
|
popup.appendChild(menuitem);
|
||||||
// Separator
|
// Separator
|
||||||
|
@ -1026,26 +1026,22 @@ class ReaderInstance {
|
||||||
|
|
||||||
// Note: annotation.image is always saved separately from the rest
|
// Note: annotation.image is always saved separately from the rest
|
||||||
// of annotation properties
|
// of annotation properties
|
||||||
|
if (annotation.image) {
|
||||||
|
if (this._isReadOnly()) {
|
||||||
let item = Zotero.Items.getByLibraryAndKey(attachment.libraryID, annotation.key);
|
let item = Zotero.Items.getByLibraryAndKey(attachment.libraryID, annotation.key);
|
||||||
// Save image for read-only annotation.
|
if (item) {
|
||||||
if (item
|
|
||||||
&& !item.isEditable()
|
|
||||||
&& annotation.image
|
|
||||||
&& !await Zotero.Annotations.hasCacheImage(item)
|
|
||||||
) {
|
|
||||||
let blob = this._dataURLtoBlob(annotation.image);
|
let blob = this._dataURLtoBlob(annotation.image);
|
||||||
await Zotero.Annotations.saveCacheImage(item, blob);
|
await Zotero.Annotations.saveCacheImage(item, blob);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
let savedAnnotation = await Zotero.Annotations.saveFromJSON(attachment, annotation, saveOptions);
|
let savedAnnotation = await Zotero.Annotations.saveFromJSON(attachment, annotation, saveOptions);
|
||||||
if (annotation.image && !await Zotero.Annotations.hasCacheImage(savedAnnotation)) {
|
|
||||||
let blob = this._dataURLtoBlob(annotation.image);
|
let blob = this._dataURLtoBlob(annotation.image);
|
||||||
await Zotero.Annotations.saveCacheImage(savedAnnotation, blob);
|
await Zotero.Annotations.saveCacheImage(savedAnnotation, blob);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
finally {
|
finally {
|
||||||
await Zotero.Notifier.commit(notifierQueue);
|
await Zotero.Notifier.commit(notifierQueue);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit d03bd798fe01c5285c1671da37cee75036d0233d
|
Subproject commit ae444f1b72849b732b4b79957688c0375b6055eb
|
Loading…
Add table
Reference in a new issue