Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: copy URL of focus #571

Merged
merged 3 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,19 @@
});
return false;
});
this.register(getOpt('copyUrlKey'), () => {
const link = this.resultsManager.getElementToNavigate();
if (
link == null || link.localName !== 'a' || !link.href ||
!navigator.clipboard
) {
return true;
}
navigator.clipboard.writeText(link.href).then(
() => false,

Check failure on line 598 in src/main.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 10 spaces but found 8
(err) => true,

Check failure on line 599 in src/main.js

View workflow job for this annotation

GitHub Actions / lint

Expected indentation of 10 spaces but found 8
);
});
}

initChangeToolsNavigation() {
Expand Down
1 change: 1 addition & 0 deletions src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ const DEFAULT_KEYBINDINGS = {
showImagesLarge: ['z l'],
showImagesMedium: ['z e'],
showImagesIcon: ['z i'],
copyUrlKey: [],
};

const DEFAULT_OPTIONS = {
Expand Down
4 changes: 4 additions & 0 deletions src/options_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ <h2>Keybindings</h2>
<label for="navigate-previous-result-page" class="option-desc">Previous page</label>
<input id="navigate-previous-result-page" class="input-keybinding" type="text" value="left">
</div>
<div class="option">
<label for="copy-url-key" class="option-desc">Copy URL of focus</label>
<input id="copy-url-key" class="input-keybinding" type="text" value="">
</div>
</details>
<details>
<summary><h3>Results filtering</h3></summary>
Expand Down
1 change: 1 addition & 0 deletions src/options_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ const KEYBINDING_TO_DIV = {
showImagesLarge: 'show-images-large',
showImagesMedium: 'show-images-medium',
showImagesIcon: 'show-images-icon',
copyUrlKey: 'copy-url-key',
};

/**
Expand Down
Loading