Refactor clipboard copy to use navigator.clipboard API

- Replaced deprecated `document.execCommand("copy")` with `navigator.clipboard.writeText` in `EmbedVideoModal.js`.
- Simplified fallback mechanism in `EmbedVideoModal.js` to select text and prompt user for manual copy.
- Removed `document.execCommand("copy")` fallback in `LoginModalController.js` and updated tests.
- Added unit tests for `EmbedVideoModal` copy functionality.
- Updated `LoginModalController` tests to cover NIP-46 copy button behavior.

Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-02-17 04:52:40 +00:00
1 parent 84e7f50f96
commit 24290d4c19
4 files changed
+284 -17

No files matched your search

+3 -13
View File
@@ -414,19 +414,9 @@ export class EmbedVideoModal {
textarea.select();
textarea.setSelectionRange(0, textarea.value.length);
let succeeded = false;
try {
succeeded = this.document.execCommand("copy");
} catch (error) {
logger.user.warn("Embed modal copy fallback failed.", error);
succeeded = false;
}
if (succeeded) {
this.callbacks.showSuccess("Embed code copied to clipboard!");
} else {
this.callbacks.showError("Unable to copy embed code. Please copy it manually.");
}
this.callbacks.showError(
"Unable to copy embed code. Please copy it manually."
);
}
async open({ video, triggerElement } = {}) {