Open PDF files over viewAttachment() to reuse its logic (download, etc.)
This commit is contained in:
parent
966bee275c
commit
a40ac2907e
3 changed files with 20 additions and 7 deletions
|
@ -551,7 +551,13 @@ class EditorInstance {
|
|||
this.onNavigate(uri, { position });
|
||||
}
|
||||
else {
|
||||
await Zotero.Reader.openURI(uri, { position });
|
||||
let zp = Zotero.getActiveZoteroPane();
|
||||
if (zp) {
|
||||
let item = await Zotero.URI.getURIItem(uri);
|
||||
if (item) {
|
||||
zp.viewPDF(item.id, { position });
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -567,7 +573,10 @@ class EditorInstance {
|
|||
}
|
||||
let attachments = Zotero.Items.get(item.getAttachments()).filter(x => x.isPDFAttachment());
|
||||
if (citationItem.locator && attachments.length === 1) {
|
||||
await Zotero.Reader.open(attachments[0].id, { pageLabel: citationItem.locator });
|
||||
let zp = Zotero.getActiveZoteroPane();
|
||||
if (zp) {
|
||||
zp.viewPDF(attachments[0].id, { pageLabel: citationItem.locator });
|
||||
}
|
||||
}
|
||||
else {
|
||||
this._showInLibrary(item.id);
|
||||
|
|
|
@ -4175,7 +4175,7 @@ var ZoteroPane = new function()
|
|||
});
|
||||
|
||||
|
||||
this.viewAttachment = Zotero.serial(async function (itemIDs, event, noLocateOnMissing, forceExternalViewer) {
|
||||
this.viewAttachment = Zotero.serial(async function (itemIDs, event, noLocateOnMissing, extraData) {
|
||||
// If view isn't editable, don't show Locate button, since the updated
|
||||
// path couldn't be sent back up
|
||||
if (!this.collectionsView.editable) {
|
||||
|
@ -4210,7 +4210,11 @@ var ZoteroPane = new function()
|
|||
// TEMP
|
||||
if (Zotero.isPDFBuild && (library.libraryType == 'user' || Zotero.enablePDFBuildForGroups)) {
|
||||
let originalEvent = event && event.originalEvent || event;
|
||||
this.viewPDF(itemID, originalEvent && originalEvent.shiftKey);
|
||||
await Zotero.Reader.open(
|
||||
itemID,
|
||||
extraData && extraData.location,
|
||||
originalEvent && originalEvent.shiftKey
|
||||
);
|
||||
return;
|
||||
}
|
||||
let pdfHandler = Zotero.Prefs.get("fileHandler.pdf");
|
||||
|
@ -4378,8 +4382,8 @@ var ZoteroPane = new function()
|
|||
}
|
||||
});
|
||||
|
||||
this.viewPDF = function (itemID, openWindow) {
|
||||
Zotero.Reader.open(itemID, null, openWindow);
|
||||
this.viewPDF = async function (itemID, location) {
|
||||
await this.viewAttachment(itemID, null, false, { location });
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 24012c75dcf6d7a30c17340b1999c8e106e111bf
|
||||
Subproject commit 0d2f9200260f3c2e72487373e3ad10d7e9d1d6aa
|
Loading…
Add table
Reference in a new issue