mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-06 04:42:57 +00:00
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:
1 parent
84e7f50f96
commit
24290d4c19
4 files changed
+284
-17
No files matched your search
@@ -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 } = {}) {
|
||||
|
||||
Reference in new issue
Block a user