From c0b1177a3203091ca43f2d08f24dd821f1237612 Mon Sep 17 00:00:00 2001 From: Connum Date: Mon, 26 Sep 2022 18:12:55 +0200 Subject: refactored image paste handling to fill unset images successively, then replace last existing image (fixes #981) --- script.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'script.js') diff --git a/script.js b/script.js index 7f26e23b..cf989605 100644 --- a/script.js +++ b/script.js @@ -39,3 +39,24 @@ document.addEventListener("DOMContentLoaded", function() { }); mutationObserver.observe( gradioApp(), { childList:true, subtree:true }) }); + +/** + * checks that a UI element is not in another hidden element or tab content + */ +function uiElementIsVisible(el) { + let isVisible = !el.closest('.\\!hidden'); + if ( ! isVisible ) { + return false; + } + + while( isVisible = el.closest('.tabitem')?.style.display !== 'none' ) { + if ( ! isVisible ) { + return false; + } else if ( el.parentElement ) { + el = el.parentElement + } else { + break; + } + } + return isVisible; +} \ No newline at end of file -- cgit v1.2.1