Merge pull request #2786 from SillyTavern/textarea-revert-nyxFix

initial reversion commit
This commit is contained in:
Cohee 2024-09-05 20:29:36 +03:00 committed by GitHub
commit 758c90be00
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 79 additions and 70 deletions

View File

@ -494,12 +494,15 @@
}
input:disabled,
textarea:disabled,
#AdvancedFormatting .disabled {
textarea:disabled {
cursor: not-allowed;
filter: brightness(0.5);
}
#AdvancedFormatting .disabled {
filter: brightness(0.5);
}
.debug-red {
border: 1px solid red !important;
}

View File

@ -3089,14 +3089,14 @@
<small data-i18n="Story String">Story String</small>
<i class="editor_maximize fa-solid fa-maximize right_menu_button" data-for="context_story_string" title="Expand the editor" data-i18n="[title]Expand the editor"></i>
</label>
<div contenteditable="true" id="context_story_string" class="text_pole textarea_compact"></div>
<textarea id="context_story_string" class="text_pole textarea_compact autoSetHeight"></textarea>
<div class="flex-container">
<div class="flex1">
<label for="context_example_separator">
<small data-i18n="Example Separator">Example Separator</small>
</label>
<div>
<div contenteditable="true" id="context_example_separator" class="text_pole textarea_compact"></div>
<textarea id="context_example_separator" class="text_pole textarea_compact autoSetHeight"></textarea>
</div>
</div>
<div class="flex1">
@ -3104,7 +3104,7 @@
<small data-i18n="Chat Start">Chat Start</small>
</label>
<div>
<div contenteditable="true" id="context_chat_start" class="text_pole textarea_compact"></div>
<textarea id="context_chat_start" class="text_pole textarea_compact autoSetHeight"></textarea>
</div>
</div>
</div>
@ -3182,7 +3182,7 @@
</small>
</div>
<div>
<div contenteditable="true" id="custom_stopping_strings" class="text_pole textarea_compact monospace"></div>
<textarea id="custom_stopping_strings" class="text_pole textarea_compact monospace autoSetHeight"></textarea>
</div>
<label class="checkbox_label" for="custom_stopping_strings_macro">
<input id="custom_stopping_strings_macro" type="checkbox" checked>
@ -3241,7 +3241,7 @@
<small data-i18n="System Prompt">System Prompt</small>
<i class="editor_maximize fa-solid fa-maximize right_menu_button" data-for="instruct_system_prompt" title="Expand the editor" data-i18n="[title]Expand the editor"></i>
</label>
<div contenteditable="true" id="instruct_system_prompt" class="text_pole textarea_compact"></div>
<textarea id="instruct_system_prompt" class="text_pole textarea_compact autoSetHeight"></textarea>
</div>
<div>
@ -3323,7 +3323,7 @@
</span>
</small>
<div>
<div contenteditable="true" id="start_reply_with" class="text_pole textarea_compact"></div>
<textarea id="start_reply_with" class="text_pole textarea_compact autoSetHeight"></textarea>
</div>
<label class="checkbox_label" for="chat-show-reply-prefix-checkbox">
<input id="chat-show-reply-prefix-checkbox" type="checkbox" />
@ -3353,7 +3353,7 @@
<small data-i18n="System Prompt Prefix">System Prompt Prefix</small>
</label>
<div>
<div contenteditable="true" id="instruct_system_sequence_prefix" class="text_pole textarea_compact"></div>
<textarea id="instruct_system_sequence_prefix" class="text_pole textarea_compact autoSetHeight"></textarea>
</div>
</div>
<div class="flexAuto" title="Inserted after a System prompt." data-i18n="[title]Inserted after a System prompt.">
@ -3361,38 +3361,38 @@
<small data-i18n="System Prompt Suffix">System Prompt Suffix</small>
</label>
<div>
<div contenteditable="true" id="instruct_system_sequence_suffix" class="text_pole wide100p textarea_compact"></div>
<textarea id="instruct_system_sequence_suffix" class="text_pole wide100p textarea_compact autoSetHeight"></textarea>
</div>
</div>
</div>
<div class="flex-container">
<div class="flexAuto" title="Inserted before a User message and as a last prompt line when impersonating." data-i18n="[title]Inserted before a User message and as a last prompt line when impersonating.">
<small data-i18n="User Prefix">User Message Prefix</small>
<div contenteditable="true" id="instruct_input_sequence" class="text_pole textarea_compact"></div>
<textarea id="instruct_input_sequence" class="text_pole textarea_compact autoSetHeight"></textarea>
</div>
<div class="flexAuto" title="Inserted after a User message." data-i18n="[title]Inserted after a User message.">
<small data-i18n="User Suffix">User Message Suffix</small>
<div contenteditable="true" id="instruct_input_suffix" class="text_pole wide100p textarea_compact"></div>
<textarea id="instruct_input_suffix" class="text_pole wide100p textarea_compact autoSetHeight"></textarea>
</div>
</div>
<div class="flex-container">
<div class="flexAuto" title="Inserted before an Assistant message and as a last prompt line when generating an AI reply." data-i18n="[title]Inserted before an Assistant message and as a last prompt line when generating an AI reply.">
<small data-i18n="Assistant Prefix">Assistant Message Prefix</small>
<div contenteditable="true" id="instruct_output_sequence" class="text_pole wide100p textarea_compact"></div>
<textarea id="instruct_output_sequence" class="text_pole wide100p textarea_compact autoSetHeight"></textarea>
</div>
<div class="flexAuto" title="Inserted after an Assistant message." data-i18n="[title]Inserted after an Assistant message.">
<small data-i18n="Assistant Suffix">Assistant Message Suffix</small>
<div contenteditable="true" id="instruct_output_suffix" class="text_pole wide100p textarea_compact"></div>
<textarea id="instruct_output_suffix" class="text_pole wide100p textarea_compact autoSetHeight"></textarea>
</div>
</div>
<div class="flex-container">
<div class="flexAuto" id="instruct_system_sequence_block" title="Inserted before a System (added by slash commands or extensions) message." data-i18n="[title]Inserted before a System (added by slash commands or extensions) message.">
<small data-i18n="System Prefix">System Message Prefix</small>
<div contenteditable="true" id="instruct_system_sequence" class="text_pole textarea_compact"></div>
<textarea id="instruct_system_sequence" class="text_pole textarea_compact autoSetHeight"></textarea>
</div>
<div class="flexAuto" id="instruct_system_suffix_block" title="Inserted after a System message." data-i18n="[title]Inserted after a System message.">
<small data-i18n="System Suffix">System Message Suffix</small>
<div contenteditable="true" id="instruct_system_suffix" class="text_pole wide100p textarea_compact"></div>
<textarea id="instruct_system_suffix" class="text_pole wide100p textarea_compact autoSetHeight"></textarea>
</div>
</div>
<div class="flexBasis100p" title="If enabled, System Sequences will be the same as User Sequences." data-i18n="[title]If enabled, System Sequences will be the same as User Sequences.">
@ -3408,37 +3408,37 @@
<div class="flex-container">
<div class="flexAuto" title="Inserted before the first Assistant's message." data-i18n="[title]Inserted before the first Assistant's message.">
<small data-i18n="First Assistant Prefix">First Assistant Prefix</small>
<div contenteditable="true" id="instruct_first_output_sequence" class="text_pole textarea_compact"></div>
<textarea id="instruct_first_output_sequence" class="text_pole textarea_compact autoSetHeight"></textarea>
</div>
<div class="flexAuto" title="Inserted before the last Assistant's message or as a last prompt line when generating an AI reply (except a neutral/system role)." data-i18n="[title]instruct_last_output_sequence">
<small data-i18n="Last Assistant Prefix">Last Assistant Prefix</small>
<div contenteditable="true" id="instruct_last_output_sequence" class="text_pole wide100p textarea_compact"></div>
<textarea id="instruct_last_output_sequence" class="text_pole wide100p textarea_compact autoSetHeight"></textarea>
</div>
</div>
<div class="flex-container">
<div class="flexAuto" title="Inserted before the first User's message." data-i18n="[title]Inserted before the first User's message.">
<small data-i18n="First User Prefix">First User Prefix</small>
<div contenteditable="true" id="instruct_first_input_sequence" class="text_pole textarea_compact"></div>
<textarea id="instruct_first_input_sequence" class="text_pole textarea_compact autoSetHeight"></textarea>
</div>
<div class="flexAuto" title="Inserted before the last User's message." data-i18n="[title]instruct_last_input_sequence">
<small data-i18n="Last User Prefix">Last User Prefix</small>
<div contenteditable="true" id="instruct_last_input_sequence" class="text_pole wide100p textarea_compact"></div>
<textarea id="instruct_last_input_sequence" class="text_pole wide100p textarea_compact autoSetHeight"></textarea>
</div>
</div>
<div class="flex-container">
<div class="flexAuto" title="Will be inserted as a last prompt line when using system/neutral generation." data-i18n="[title]Will be inserted as a last prompt line when using system/neutral generation.">
<small data-i18n="System Instruction Prefix">System Instruction Prefix</small>
<div contenteditable="true" id="instruct_last_system_sequence" class="text_pole textarea_compact"></div>
<textarea id="instruct_last_system_sequence" class="text_pole textarea_compact autoSetHeight"></textarea>
</div>
<div class="flexAuto" title="If a stop sequence is generated, everything past it will be removed from the output (inclusive)." data-i18n="[title]If a stop sequence is generated, everything past it will be removed from the output (inclusive).">
<small data-i18n="Stop Sequence">Stop Sequence</small>
<div contenteditable="true" id="instruct_stop_sequence" class="text_pole textarea_compact"></div>
<textarea id="instruct_stop_sequence" class="text_pole textarea_compact autoSetHeight"></textarea>
</div>
</div>
<div class="flex-container">
<div class="flexAuto" title="Will be inserted at the start of the chat history if it doesn't start with a User message." data-i18n="[title]Will be inserted at the start of the chat history if it doesn't start with a User message.">
<small data-i18n="User Filler Message">User Filler Message</small>
<div contenteditable="true" id="instruct_user_alignment_message" class="text_pole textarea_compact"></div>
<textarea id="instruct_user_alignment_message" class="text_pole textarea_compact autoSetHeight"></textarea>
</div>
</div>
</div>

View File

@ -10616,10 +10616,12 @@ jQuery(async function () {
}
// Set the height of "autoSetHeight" textareas within the drawer to their scroll height
$(this).closest('.drawer').find('.drawer-content textarea.autoSetHeight').each(async function () {
await resetScrollHeight($(this));
return;
});
if (!CSS.supports('field-sizing', 'content')) {
$(this).closest('.drawer').find('.drawer-content textarea.autoSetHeight').each(async function () {
await resetScrollHeight($(this));
return;
});
}
} else if (drawerWasOpenAlready) { //to close manually
icon.toggleClass('closedIcon openIcon');
@ -10691,10 +10693,12 @@ jQuery(async function () {
$(this).closest('.inline-drawer').find('.inline-drawer-content').stop().slideToggle();
// Set the height of "autoSetHeight" textareas within the inline-drawer to their scroll height
$(this).closest('.inline-drawer').find('.inline-drawer-content textarea.autoSetHeight').each(async function () {
await resetScrollHeight($(this));
return;
});
if (!CSS.supports('field-sizing', 'content')) {
$(this).closest('.inline-drawer').find('.inline-drawer-content textarea.autoSetHeight').each(async function () {
await resetScrollHeight($(this));
return;
});
}
});
$(document).on('click', '.inline-drawer-maximize', function () {

View File

@ -1491,9 +1491,11 @@ function select_group_chats(groupId, skipAnimation) {
}
// Toggle textbox sizes, as input events have not fired here
$('#rm_group_chats_block .autoSetHeight').each(element => {
resetScrollHeight(element);
});
if (!CSS.supports('field-sizing', 'content')) {
$('#rm_group_chats_block .autoSetHeight').each(element => {
resetScrollHeight(element);
});
}
eventSource.emit('groupSelected', { detail: { id: openGroupId, group: group } });
}
@ -1964,9 +1966,11 @@ function doCurMemberListPopout() {
}
jQuery(() => {
$(document).on('input', '#rm_group_chats_block .autoSetHeight', function () {
resetScrollHeight($(this));
});
if (!CSS.supports('field-sizing', 'content')) {
$(document).on('input', '#rm_group_chats_block .autoSetHeight', function () {
resetScrollHeight($(this));
});
}
$(document).on('click', '.group_select', function () {
const groupId = $(this).attr('chid') || $(this).attr('grid') || $(this).data('id');

View File

@ -7,7 +7,7 @@ import {
power_user,
context_presets,
} from './power-user.js';
import { regexFromString } from './utils.js';
import { regexFromString, resetScrollHeight } from './utils.js';
/**
* @type {any[]} Instruct mode presets.
@ -95,11 +95,14 @@ export async function loadInstructMode(data) {
if (control.isCheckbox) {
$element.prop('checked', power_user.instruct[control.property]);
} else {
$element[0].innerText = (power_user.instruct[control.property]);
$element.val(power_user.instruct[control.property]);
}
$element.on('input', async function () {
power_user.instruct[control.property] = control.isCheckbox ? !!$(this).prop('checked') : $(this)[0].innerText;
power_user.instruct[control.property] = control.isCheckbox ? !!$(this).prop('checked') : $(this).val();
if (!CSS.supports('field-sizing', 'content')) {
await resetScrollHeight($(this));
}
saveSettingsDebounced();
});
@ -108,9 +111,6 @@ export async function loadInstructMode(data) {
}
});
$('#instruct_system_sequence').css('height', 'auto');
$('#instruct_system_suffix').css('height', 'auto');
instruct_presets.forEach((preset) => {
const name = preset.name;
const option = document.createElement('option');
@ -611,13 +611,13 @@ jQuery(() => {
if (state) {
$('#instruct_system_sequence_block').addClass('disabled');
$('#instruct_system_suffix_block').addClass('disabled');
$('#instruct_system_sequence').prop('contenteditable', false);
$('#instruct_system_suffix').prop('contenteditable', false);
$('#instruct_system_sequence').prop('readOnly', true);
$('#instruct_system_suffix').prop('readOnly', true);
} else {
$('#instruct_system_sequence_block').removeClass('disabled');
$('#instruct_system_suffix_block').removeClass('disabled');
$('#instruct_system_sequence').prop('contenteditable', true);
$('#instruct_system_suffix').prop('contenteditable', true);
$('#instruct_system_sequence').prop('readOnly', false);
$('#instruct_system_suffix').prop('readOnly', false);
}
});
@ -663,7 +663,7 @@ jQuery(() => {
if (control.isCheckbox) {
$element.prop('checked', power_user.instruct[control.property]).trigger('input');
} else {
$element[0].innerText = (power_user.instruct[control.property]);
$element.val(power_user.instruct[control.property]);
$element.trigger('input');
}
}

View File

@ -5281,9 +5281,11 @@ $(document).ready(async function () {
saveSettingsDebounced();
});
$(document).on('input', '#openai_settings .autoSetHeight', function () {
resetScrollHeight($(this));
});
if (!CSS.supports('field-sizing', 'content')) {
$(document).on('input', '#openai_settings .autoSetHeight', function () {
resetScrollHeight($(this));
});
}
if (!isMobile()) {
$('#model_openrouter_select').select2({

View File

@ -1740,20 +1740,23 @@ async function loadContextSettings() {
if (control.isCheckbox) {
$element.prop('checked', power_user.context[control.property]);
} else {
$element[0].innerText = power_user.context[control.property];
$element.val(power_user.context[control.property]);
}
console.log(`Setting ${$element.prop('id')} to ${power_user.context[control.property]}`);
// If the setting already exists, no need to duplicate it
// TODO: Maybe check the power_user object for the setting instead of a flag?
$element.on('input keyup', async function () {
const value = control.isCheckbox ? !!$(this).prop('checked') : $(this)[0].innerText;
$element.on('input', async function () {
const value = control.isCheckbox ? !!$(this).prop('checked') : $(this).val();
if (control.isGlobalSetting) {
power_user[control.property] = value;
} else {
power_user.context[control.property] = value;
}
console.log(`Setting ${$element.prop('id')} to ${value}`);
if (!CSS.supports('field-sizing', 'content')) {
await resetScrollHeight($(this));
}
saveSettingsDebounced();
});
});
@ -1793,7 +1796,7 @@ async function loadContextSettings() {
.prop('checked', control.isGlobalSetting ? power_user[control.property] : power_user.context[control.property])
.trigger('input');
} else {
$element[0].innerText = (control.isGlobalSetting ? power_user[control.property] : power_user.context[control.property]);
$element.val(control.isGlobalSetting ? power_user[control.property] : power_user.context[control.property]);
$element.trigger('input');
}
}
@ -3096,7 +3099,7 @@ $(document).ready(() => {
});
$('#start_reply_with').on('input', function () {
power_user.user_prompt_bias = String($(this)[0].innerText);
power_user.user_prompt_bias = String($(this).val());
saveSettingsDebounced();
});
@ -3628,7 +3631,7 @@ $(document).ready(() => {
});
$('#custom_stopping_strings').on('input', function () {
power_user.custom_stopping_strings = String($(this)[0].innerText).trim();
power_user.custom_stopping_strings = String($(this).val()).trim();
saveSettingsDebounced();
});

View File

@ -2028,7 +2028,9 @@ export function toggleDrawer(drawer, expand = true) {
}
// Set the height of "autoSetHeight" textareas within the inline-drawer to their scroll height
content.querySelectorAll('textarea.autoSetHeight').forEach(resetScrollHeight);
if (!CSS.supports('field-sizing', 'content')) {
content.querySelectorAll('textarea.autoSetHeight').forEach(resetScrollHeight);
}
}
export async function fetchFaFile(name) {

View File

@ -1176,6 +1176,7 @@ textarea {
textarea.autoSetHeight {
max-height: 50vh;
max-height: 50dvh;
field-sizing: content;
}
input,
@ -5454,16 +5455,6 @@ body:not(.movingUI) .drawer-content.maximized {
opacity: 0.7;
}
#advanced-formatting-button div[contenteditable] {
#AdvancedFormatting .autoSetHeight {
overflow-wrap: anywhere;
max-height: 50vh;
max-height: 50dvh;
resize: vertical;
overflow: auto;
min-height: 1.8em;
white-space: preserve-breaks;
}
div[contenteditable] br {
display: revert;
}