mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 15:15:44 -03:00
feat: Enhance copyTriggerWord function with modern clipboard API and fallback for non-secure contexts. Fixes https://github.com/willmiao/ComfyUI-Lora-Manager/issues/110
This commit is contained in:
@@ -336,7 +336,22 @@ async function saveTriggerWords() {
|
|||||||
*/
|
*/
|
||||||
window.copyTriggerWord = async function(word) {
|
window.copyTriggerWord = async function(word) {
|
||||||
try {
|
try {
|
||||||
|
// Modern clipboard API - with fallback for non-secure contexts
|
||||||
|
if (navigator.clipboard && window.isSecureContext) {
|
||||||
await navigator.clipboard.writeText(word);
|
await navigator.clipboard.writeText(word);
|
||||||
|
} else {
|
||||||
|
// Fallback for older browsers or non-secure contexts
|
||||||
|
const textarea = document.createElement('textarea');
|
||||||
|
textarea.value = word;
|
||||||
|
textarea.style.position = 'absolute';
|
||||||
|
textarea.style.left = '-99999px';
|
||||||
|
document.body.appendChild(textarea);
|
||||||
|
textarea.select();
|
||||||
|
const success = document.execCommand('copy');
|
||||||
|
document.body.removeChild(textarea);
|
||||||
|
|
||||||
|
if (!success) throw new Error('Copy command failed');
|
||||||
|
}
|
||||||
showToast('Trigger word copied', 'success');
|
showToast('Trigger word copied', 'success');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Copy failed:', err);
|
console.error('Copy failed:', err);
|
||||||
|
|||||||
Reference in New Issue
Block a user