aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-12-14 06:41:18 +0000
committerGitHub <noreply@github.com>2023-12-14 06:41:18 +0000
commit206de1a6b0c4caca61896fc679b8b81e30942536 (patch)
tree5f4ba5de4431b49a750af87bec7275bfaf7c839a
parentb943eebb1df5060c2cee194751b2778c83b875cb (diff)
parent89cfbc3bbe401fe1655afb07edbae34ec6af7aca (diff)
downloadstable-diffusion-webui-gfx803-206de1a6b0c4caca61896fc679b8b81e30942536.tar.gz
stable-diffusion-webui-gfx803-206de1a6b0c4caca61896fc679b8b81e30942536.tar.bz2
stable-diffusion-webui-gfx803-206de1a6b0c4caca61896fc679b8b81e30942536.zip
Merge pull request #14296 from akx/paste-resolution
Allow pasting in WIDTHxHEIGHT strings into the width/height fields
-rw-r--r--javascript/ui.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/javascript/ui.js b/javascript/ui.js
index 410fc44e..18c9f891 100644
--- a/javascript/ui.js
+++ b/javascript/ui.js
@@ -215,9 +215,33 @@ function restoreProgressImg2img() {
}
+/**
+ * Configure the width and height elements on `tabname` to accept
+ * pasting of resolutions in the form of "width x height".
+ */
+function setupResolutionPasting(tabname) {
+ var width = gradioApp().querySelector(`#${tabname}_width input[type=number]`);
+ var height = gradioApp().querySelector(`#${tabname}_height input[type=number]`);
+ for (const el of [width, height]) {
+ el.addEventListener('paste', function(event) {
+ var pasteData = event.clipboardData.getData('text/plain');
+ var parsed = pasteData.match(/^\s*(\d+)\D+(\d+)\s*$/);
+ if (parsed) {
+ width.value = parsed[1];
+ height.value = parsed[2];
+ updateInput(width);
+ updateInput(height);
+ event.preventDefault();
+ }
+ });
+ }
+}
+
onUiLoaded(function() {
showRestoreProgressButton('txt2img', localGet("txt2img_task_id"));
showRestoreProgressButton('img2img', localGet("img2img_task_id"));
+ setupResolutionPasting('txt2img');
+ setupResolutionPasting('img2img');
});