Skip to content

Commit

Permalink
Implement link copying option for PDF view context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtcode committed Oct 14, 2024
1 parent ffc5593 commit 85934b1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/common/context-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ export function createViewContextMenu(reader, params) {
x: params.x,
y: params.y,
itemGroups: createItemGroup([
[
{
label: reader._getString('general.copyLink'),
disabled: !(params.overlay && params.overlay.type === 'external-link' && !reader.canCopy),
onCommand: () => {
navigator.clipboard.writeText(params.overlay.url);
}
}
],
[
{
label: reader._getString('general.copy'),
Expand Down
1 change: 1 addition & 0 deletions src/en-us.strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default {
'general.continue': 'Continue',
'general.dontShowAgain': 'Don’t Show Again',
'general.copy': 'Copy',
'general.copyLink': 'Copy Link',
'general.keys.ctrlShift': 'Ctrl+Shift+',
'general.close': 'Close',
'general.create': 'Create',
Expand Down
6 changes: 5 additions & 1 deletion src/pdf/pdf-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -1680,7 +1680,11 @@ class PDFView {
if (this._selectedAnnotationIDs.length !== 0) {
this._onSelectAnnotations([], event);
}
this._onOpenViewContextMenu({ x: br.x + event.clientX, y: br.y + event.clientY });
let overlay;
if (position) {
overlay = this._getSelectableOverlay(position);
}
this._onOpenViewContextMenu({ x: br.x + event.clientX, y: br.y + event.clientY, overlay });
}
else if (!selectedAnnotations.includes(selectableAnnotation)) {
this._onSelectAnnotations([selectableAnnotation.id], event);
Expand Down

0 comments on commit 85934b1

Please sign in to comment.