mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-06-07 21:20:49 +00:00
fix bug
This commit is contained in:
parent
4d3661c188
commit
f97e76be3c
@ -443,7 +443,7 @@ function extraNetworksRemoveFromPrompt(textarea, text, is_neg) {
|
|||||||
let match = text.match(is_neg ? re_extranet_neg : re_extranet);
|
let match = text.match(is_neg ? re_extranet_neg : re_extranet);
|
||||||
let replaced = false;
|
let replaced = false;
|
||||||
let res;
|
let res;
|
||||||
let prefix = opts.extra_networks_add_text_separator;
|
let sep = opts.extra_networks_add_text_separator;
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
const content = match[1];
|
const content = match[1];
|
||||||
@ -465,12 +465,17 @@ function extraNetworksRemoveFromPrompt(textarea, text, is_neg) {
|
|||||||
if (postfix && res.slice(idx, idx + postfix.length) === postfix) {
|
if (postfix && res.slice(idx, idx + postfix.length) === postfix) {
|
||||||
res = res.slice(0, idx) + res.slice(idx + postfix.length);
|
res = res.slice(0, idx) + res.slice(idx + postfix.length);
|
||||||
}
|
}
|
||||||
if (res.slice(idx - prefix.length, idx) === prefix) {
|
if (res.slice(idx - sep.length, idx) === sep) {
|
||||||
res = res.slice(0, idx - prefix.length) + res.slice(idx);
|
res = res.slice(0, idx - sep.length) + res.slice(idx);
|
||||||
|
}
|
||||||
|
// Remove separator if it is at beginning of string.
|
||||||
|
console.log("HERE!:", res);
|
||||||
|
if (res.startsWith(sep)) {
|
||||||
|
res = res.slice(sep.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
res = textarea.value.replaceAll(new RegExp(`((?:${prefix})?${text})`, "g"), "");
|
res = textarea.value.replaceAll(new RegExp(`((?:${sep})?${text})`, "g"), "");
|
||||||
replaced = (res !== textarea.value);
|
replaced = (res !== textarea.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -484,8 +489,13 @@ function extraNetworksRemoveFromPrompt(textarea, text, is_neg) {
|
|||||||
|
|
||||||
function extraNetworksUpdatePrompt(textarea, text, is_neg) {
|
function extraNetworksUpdatePrompt(textarea, text, is_neg) {
|
||||||
if (!extraNetworksRemoveFromPrompt(textarea, text, is_neg)) {
|
if (!extraNetworksRemoveFromPrompt(textarea, text, is_neg)) {
|
||||||
|
if (!textarea.value) {
|
||||||
|
// if textarea is empty, dont add the separator.
|
||||||
|
textarea.value = text;
|
||||||
|
} else {
|
||||||
textarea.value = textarea.value + opts.extra_networks_add_text_separator + text;
|
textarea.value = textarea.value + opts.extra_networks_add_text_separator + text;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
updateInput(textarea);
|
updateInput(textarea);
|
||||||
}
|
}
|
||||||
@ -606,11 +616,18 @@ function extraNetworksFetchMetadata(extra_networks_tabname, card_name) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function extraNetworksUnrelatedTabSelected() {
|
function extraNetworksUnrelatedTabSelected(tabname) {
|
||||||
/** called from python when user selects an unrelated tab (generate) */
|
/** called from python when user selects an unrelated tab (generate) */
|
||||||
for (const [k, v] of Object.entries(extra_networks_tabs)) {
|
for (const v of Object.values(extra_networks_tabs)) {
|
||||||
v.unload();
|
v.unload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Move all prompts into the selected tab.
|
||||||
|
const prompt_container_elem = document.querySelector(`#${tabname}_prompt_container`);
|
||||||
|
const prompt_row_elem = document.querySelector(`#${tabname}_prompt_row`);
|
||||||
|
const neg_prompt_row_elem = document.querySelector(`#${tabname}_neg_prompt_row`);
|
||||||
|
prompt_container_elem.insertBefore(neg_prompt_row_elem, prompt_container_elem.firstChild);
|
||||||
|
prompt_container_elem.insertBefore(prompt_row_elem, prompt_container_elem.firstChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function extraNetworksTabSelected(tabname_full, show_prompt, show_neg_prompt) {
|
async function extraNetworksTabSelected(tabname_full, show_prompt, show_neg_prompt) {
|
||||||
|
Loading…
Reference in New Issue
Block a user