Skip to content

Commit

Permalink
Merge pull request #228 from re-unknown/main
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikDoom authored Sep 2, 2023
2 parents 3e57842 + e5f9318 commit 86ea94a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions javascript/_textAreas.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ const core = [
"#img2img_prompt > label > textarea",
"#txt2img_neg_prompt > label > textarea",
"#img2img_neg_prompt > label > textarea",
".prompt > label > textarea"
".prompt > label > textarea",
"#txt2img_edit_style_prompt > label > textarea",
"#txt2img_edit_style_neg_prompt > label > textarea",
"#img2img_edit_style_prompt > label > textarea",
"#img2img_edit_style_neg_prompt > label > textarea"
];

// Third party text area selectors
Expand Down Expand Up @@ -108,7 +112,7 @@ function addOnDemandObservers(setupFunction) {

let base = gradioApp().querySelector(entry.base);
if (!base) continue;

let accordions = [...base?.querySelectorAll(".gradio-accordion")];
if (!accordions) continue;

Expand All @@ -133,12 +137,12 @@ function addOnDemandObservers(setupFunction) {
[...gradioApp().querySelectorAll(entry.selectors.join(", "))].forEach(x => setupFunction(x));
} else { // Otherwise, we have to find the text areas by their adjacent labels
let base = gradioApp().querySelector(entry.base);

// Safety check
if (!base) continue;

let allTextAreas = [...base.querySelectorAll("textarea, input[type='text']")];

// Filter the text areas where the adjacent label matches one of the selectors
let matchingTextAreas = allTextAreas.filter(ta => [...ta.parentElement.childNodes].some(x => entry.selectors.includes(x.innerText)));
matchingTextAreas.forEach(x => setupFunction(x));
Expand Down

0 comments on commit 86ea94a

Please sign in to comment.