From bd11ff8cca14708eba7b492c931cdf7a01d8f59b Mon Sep 17 00:00:00 2001 From: Abe Jellinek <1770299+AbeJellinek@users.noreply.github.com> Date: Tue, 12 May 2026 14:49:08 -0400 Subject: [PATCH] Add Copy Link to Annotation / Page context menu options --- chrome/content/zotero/xpcom/reader.js | 31 +++++++++++++++++++++++---- chrome/content/zotero/zoteroPane.js | 15 ------------- chrome/locale/en-US/zotero/reader.ftl | 2 ++ 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/chrome/content/zotero/xpcom/reader.js b/chrome/content/zotero/xpcom/reader.js index 1f9198106a..fa7723977d 100644 --- a/chrome/content/zotero/xpcom/reader.js +++ b/chrome/content/zotero/xpcom/reader.js @@ -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); diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index b5ad43403e..c27a5ccfca 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -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 { diff --git a/chrome/locale/en-US/zotero/reader.ftl b/chrome/locale/en-US/zotero/reader.ftl index 5861fb133a..c7c03f78c6 100644 --- a/chrome/locale/en-US/zotero/reader.ftl +++ b/chrome/locale/en-US/zotero/reader.ftl @@ -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