mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-07 21:32:51 +00:00
Refactor copy logic to remove deprecated execCommand
Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
84e7f50f96
commit
6d0bd25067
3 files changed
+112
-17
No files matched your search
@@ -399,6 +399,7 @@ export class EmbedVideoModal {
|
||||
return;
|
||||
}
|
||||
|
||||
// Attempt to copy using the Clipboard API
|
||||
if (navigator?.clipboard?.writeText) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(snippet);
|
||||
@@ -409,24 +410,13 @@ export class EmbedVideoModal {
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: Select the text so the user can copy manually
|
||||
const textarea = this.snippetTextarea;
|
||||
textarea.focus();
|
||||
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