mirror of
https://github.com/FranP-code/ChatGPT.git
synced 2025-10-13 00:13:25 +00:00
feat: autofocus (#550)
This commit is contained in:
8
src-tauri/src/scripts/chat.js
vendored
8
src-tauri/src/scripts/chat.js
vendored
@@ -9,6 +9,9 @@ async function init() {
|
|||||||
childList: true,
|
childList: true,
|
||||||
subtree: true,
|
subtree: true,
|
||||||
});
|
});
|
||||||
|
document.addEventListener('visibilitychange', () =>
|
||||||
|
document.getElementsByTagName('textarea')[0]?.focus()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function chatBtns() {
|
function chatBtns() {
|
||||||
@@ -92,6 +95,11 @@ function copyToClipboard(text, btn) {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function focusOnInput() {
|
||||||
|
// This currently works because there is only a single `<textarea>` element on the ChatGPT UI page.
|
||||||
|
document.getElementsByTagName("textarea")[0].focus();
|
||||||
|
}
|
||||||
|
|
||||||
function setIcon(type) {
|
function setIcon(type) {
|
||||||
return {
|
return {
|
||||||
copy: `<svg class="chatappico copy" stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect></svg>`,
|
copy: `<svg class="chatappico copy" stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect></svg>`,
|
||||||
|
|||||||
Reference in New Issue
Block a user