Fixed SD Promt
This commit is contained in:
+21
-1
@@ -6,12 +6,32 @@ export function parseImagePromptFromContent(content) {
|
||||
return { text, prompt };
|
||||
}
|
||||
|
||||
export function splitSdPromptForCopy(fullPrompt) {
|
||||
if (!fullPrompt) return '';
|
||||
const marker = '\n\nNegative prompt:';
|
||||
const i = fullPrompt.indexOf(marker);
|
||||
return (i >= 0 ? fullPrompt.slice(0, i) : fullPrompt).trim();
|
||||
}
|
||||
|
||||
export async function copyToClipboard(text) {
|
||||
if (!text) return false;
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
try {
|
||||
const ta = document.createElement('textarea');
|
||||
ta.value = text;
|
||||
ta.setAttribute('readonly', '');
|
||||
ta.style.cssText = 'position:fixed;left:-9999px;top:0';
|
||||
document.body.appendChild(ta);
|
||||
ta.select();
|
||||
const ok = document.execCommand('copy');
|
||||
document.body.removeChild(ta);
|
||||
return ok;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user