File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -215,9 +215,33 @@ function restoreProgressImg2img() {
215
215
}
216
216
217
217
218
+ /**
219
+ * Configure the width and height elements on `tabname` to accept
220
+ * pasting of resolutions in the form of "width x height".
221
+ */
222
+ function setupResolutionPasting ( tabname ) {
223
+ var width = gradioApp ( ) . querySelector ( `#${ tabname } _width input[type=number]` ) ;
224
+ var height = gradioApp ( ) . querySelector ( `#${ tabname } _height input[type=number]` ) ;
225
+ for ( const el of [ width , height ] ) {
226
+ el . addEventListener ( 'paste' , function ( event ) {
227
+ var pasteData = event . clipboardData . getData ( 'text/plain' ) ;
228
+ var parsed = pasteData . match ( / ^ \s * ( \d + ) \D + ( \d + ) \s * $ / ) ;
229
+ if ( parsed ) {
230
+ width . value = parsed [ 1 ] ;
231
+ height . value = parsed [ 2 ] ;
232
+ updateInput ( width ) ;
233
+ updateInput ( height ) ;
234
+ event . preventDefault ( ) ;
235
+ }
236
+ } ) ;
237
+ }
238
+ }
239
+
218
240
onUiLoaded ( function ( ) {
219
241
showRestoreProgressButton ( 'txt2img' , localGet ( "txt2img_task_id" ) ) ;
220
242
showRestoreProgressButton ( 'img2img' , localGet ( "img2img_task_id" ) ) ;
243
+ setupResolutionPasting ( 'txt2img' ) ;
244
+ setupResolutionPasting ( 'img2img' ) ;
221
245
} ) ;
222
246
223
247
You can’t perform that action at this time.
0 commit comments