From 8912957a264629347c5b4b2c0ff467ffc0696a5a Mon Sep 17 00:00:00 2001 From: ReUnknown Date: Wed, 3 May 2023 19:35:27 +0900 Subject: [PATCH 1/2] Support for image browser --- javascript/_textAreas.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/javascript/_textAreas.js b/javascript/_textAreas.js index 953215c..e98b26a 100644 --- a/javascript/_textAreas.js +++ b/javascript/_textAreas.js @@ -22,24 +22,32 @@ const thirdParty = { "Edit Caption", "Edit Tags" ] + }, + "image browser": { + "base": "#tab_image_browser", + "hasIds": false, + "selectors": [ + "Filename keyword search", + "EXIF keyword search" + ] } } function getTextAreas() { // First get all core text areas let textAreas = [...gradioApp().querySelectorAll(core.join(", "))]; - + for (const [key, entry] of Object.entries(thirdParty)) { if (entry.hasIds) { // If the entry has proper ids, we can just select them textAreas = textAreas.concat([...gradioApp().querySelectorAll(entry.selectors.join(", "))]); } 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")]; - + + let allTextAreas = [...base.querySelectorAll("textarea")]; + // 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))); textAreas = textAreas.concat(matchingTextAreas); From 664ae50c1a22d6f226b2a7c521590c0765c0051b Mon Sep 17 00:00:00 2001 From: ReUnknown Date: Wed, 3 May 2023 19:49:42 +0900 Subject: [PATCH 2/2] Support for Tagger --- javascript/_textAreas.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/javascript/_textAreas.js b/javascript/_textAreas.js index e98b26a..bbbd15f 100644 --- a/javascript/_textAreas.js +++ b/javascript/_textAreas.js @@ -30,6 +30,14 @@ const thirdParty = { "Filename keyword search", "EXIF keyword search" ] + }, + "tab_tagger": { + "base": "#tab_tagger", + "hasIds": false, + "selectors": [ + "Additional tags (split by comma)", + "Exclude tags (split by comma)" + ] } }