mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
sendTextArea: the same but prettier
and also no jQuery
This commit is contained in:
@@ -881,13 +881,14 @@ export function initRossMods() {
|
|||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(sendTextArea).on('input', () => {
|
sendTextArea.addEventListener('input', () => {
|
||||||
const scrollbarShown = sendTextArea.clientWidth < sendTextArea.offsetWidth && sendTextArea.offsetHeight >= window.innerHeight / 2;
|
const hasContent = sendTextArea.value !== '';
|
||||||
if ((sendTextArea.scrollHeight > sendTextArea.offsetHeight && !scrollbarShown) || sendTextArea.value === '') {
|
const fitsCurrentSize = sendTextArea.scrollHeight <= sendTextArea.offsetHeight;
|
||||||
autoFitSendTextArea();
|
const isScrollbarShown = sendTextArea.clientWidth < sendTextArea.offsetWidth;
|
||||||
} else {
|
const isHalfScreenHeight = sendTextArea.offsetHeight >= window.innerHeight / 2;
|
||||||
autoFitSendTextAreaDebounced();
|
const needsDebounce = hasContent && (fitsCurrentSize || (isScrollbarShown && isHalfScreenHeight));
|
||||||
}
|
if (needsDebounce) autoFitSendTextAreaDebounced();
|
||||||
|
else autoFitSendTextArea();
|
||||||
saveUserInputDebounced();
|
saveUserInputDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user