Add Copy Link to Annotation / Page context menu options

This commit is contained in:
Abe Jellinek 2026-05-12 14:49:08 -04:00
parent b1a026148e
commit bd11ff8cca
3 changed files with 29 additions and 19 deletions

View file

@ -631,6 +631,33 @@ class ReaderInstance {
// As above
setTimeout(() => this._openReadAloudVoicesDialog({ lang, tier, ftl }));
},
onCopyLinkToAnnotation: (annotation) => {
let { position, id } = annotation;
let attachment = Zotero.Items.get(this._item.id);
let itemURI = 'zotero://open/'
+ Zotero.API.getLibraryPrefix(attachment.libraryID)
+ '/items/' + attachment.key;
// See Note HTML/Markdown translators
if (position.type === 'FragmentSelector') {
itemURI += '?cfi=' + encodeURIComponent(position.value);
}
else if (position.type === 'CssSelector') {
itemURI += '?sel=' + encodeURIComponent(position.value);
}
else {
itemURI += '?page=' + (position.pageIndex + 1);
}
itemURI += '&annotation=' + id;
Zotero.Utilities.Internal.copyTextToClipboard(itemURI);
},
onCopyLinkToPage: (pageIndex) => {
let attachment = Zotero.Items.get(this._item.id);
let itemURI = 'zotero://open/'
+ Zotero.API.getLibraryPrefix(attachment.libraryID)
+ '/items/' + attachment.key
+ '?page=' + (pageIndex + 1);
Zotero.Utilities.Internal.copyTextToClipboard(itemURI);
}
}, this._iframeWindow, { cloneFunctions: true }));
this._resolveInitPromise();
@ -708,10 +735,6 @@ class ReaderInstance {
return this._item?.id;
}
get selectedAnnotationKeys() {
return Array.from(this._internalReader._state.selectedAnnotationIDs);
}
async updateTitle() {
this._title = await this._item.getTabTitle();
this._setTitleValue(this._title);

View file

@ -2781,21 +2781,6 @@ var ZoteroPane = new function () {
links = items.map((item) => {
let itemPath = Zotero.API.getLibraryPrefix(item.libraryID) + '/items/' + item.key;
if (type === 'reader') {
if (items.length === 1 && selectedAnnotation && selectedAnnotation.annotationPosition) {
let { annotationPosition, key } = selectedAnnotation;
annotationPosition = JSON.parse(annotationPosition);
// See Note HTML/Markdown translators
if (annotationPosition.type === 'FragmentSelector') {
itemPath += '?cfi=' + encodeURIComponent(annotationPosition.value);
}
else if (annotationPosition.type === 'CssSelector') {
itemPath += '?sel=' + encodeURIComponent(annotationPosition.value);
}
else {
itemPath += '?page=' + (annotationPosition.pageIndex + 1);
}
itemPath += '&annotation=' + key;
}
return 'zotero://open/' + itemPath;
}
else {

View file

@ -103,6 +103,8 @@ reader-convert-to-underline = Convert to Underline
reader-size = Size
reader-merge = Merge
reader-copy-link = Copy Link
reader-copy-link-to-annotation = Copy Link to Annotation
reader-copy-link-to-page = Copy Link to Page
reader-theme-original = Original
reader-theme-snow = Snow
reader-theme-sepia = Sepia