diff options
author | DepFA <35278260+dfaker@users.noreply.github.com> | 2022-10-11 15:15:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-11 15:15:09 +0100 |
commit | 1eaad955330bbe2d55f6b528c902758739413dc8 (patch) | |
tree | fba92d854e283d3a413b1b36682bb23171a086d7 /script.js | |
parent | 7aa8fcac1e45c3ad9c6a40df0e44a346afcd5032 (diff) | |
parent | e0ee5bf703996b33e6d97aa36e0973ceedc88503 (diff) |
Merge branch 'master' into embed-embeddings-in-images
Diffstat (limited to 'script.js')
-rw-r--r-- | script.js | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -6,6 +6,10 @@ function get_uiCurrentTab() { return gradioApp().querySelector('.tabs button:not(.border-transparent)') } +function get_uiCurrentTabContent() { + return gradioApp().querySelector('.tabitem[id^=tab_]:not([style*="display: none"])') +} + uiUpdateCallbacks = [] uiTabChangeCallbacks = [] let uiCurrentTab = null @@ -41,6 +45,25 @@ document.addEventListener("DOMContentLoaded", function() { }); /** + * Add a ctrl+enter as a shortcut to start a generation + */ + document.addEventListener('keydown', function(e) { + var handled = false; + if (e.key !== undefined) { + if((e.key == "Enter" && (e.metaKey || e.ctrlKey))) handled = true; + } else if (e.keyCode !== undefined) { + if((e.keyCode == 13 && (e.metaKey || e.ctrlKey))) handled = true; + } + if (handled) { + button = get_uiCurrentTabContent().querySelector('button[id$=_generate]'); + if (button) { + button.click(); + } + e.preventDefault(); + } +}) + +/** * checks that a UI element is not in another hidden element or tab content */ function uiElementIsVisible(el) { |