initial commit: AF panel textareas >> contentEditable divs

This commit is contained in:
RossAscends 2024-08-05 14:30:15 +09:00
parent 64e716bb62
commit b48d905c45
3 changed files with 41 additions and 36 deletions

View File

@ -3061,14 +3061,14 @@
<label for="context_story_string">
<small data-i18n="Story String">Story String</small>
</label>
<textarea id="context_story_string" class="text_pole textarea_compact autoSetHeight" rows="1"></textarea>
<div contenteditable="true" id="context_story_string" class="text_pole textarea_compact autoSetHeight" rows="1"></div>
<div class="flex-container">
<div class="flex1">
<label for="context_example_separator">
<small data-i18n="Example Separator">Example Separator</small>
</label>
<div>
<textarea id="context_example_separator" class="text_pole textarea_compact autoSetHeight" maxlength="500" rows="1"></textarea>
<div contenteditable="true" id="context_example_separator" class="text_pole textarea_compact autoSetHeight" maxlength="500" rows="1"></div>
</div>
</div>
<div class="flex1">
@ -3076,7 +3076,7 @@
<small data-i18n="Chat Start">Chat Start</small>
</label>
<div>
<textarea id="context_chat_start" class="text_pole textarea_compact autoSetHeight" maxlength="500" rows="1"></textarea>
<div contenteditable="true" id="context_chat_start" class="text_pole textarea_compact autoSetHeight" maxlength="500" rows="1"></div>
</div>
</div>
</div>
@ -3172,7 +3172,7 @@
</small>
</label>
<div data-newbie-hidden>
<textarea id="instruct_activation_regex" class="text_pole textarea_compact autoSetHeight" maxlength="5000" rows="1"></textarea>
<div contenteditable="true" id="instruct_activation_regex" class="text_pole textarea_compact autoSetHeight" maxlength="5000" rows="1"></div>
</div>
<div data-newbie-hidden>
<label for="instruct_wrap" class="checkbox_label">
@ -3200,7 +3200,7 @@
<label>
<small data-i18n="System Prompt">System Prompt</small>
</label>
<textarea id="instruct_system_prompt" class="text_pole textarea_compact autoSetHeight" rows="1"></textarea>
<div contenteditable="true" id="instruct_system_prompt" class="text_pole textarea_compact autoSetHeight" rows="1"></div>
</div>
<div data-newbie-hidden class="inline-drawer wide100p flexFlowColumn">
<div class="inline-drawer-toggle inline-drawer-header">
@ -3217,7 +3217,7 @@
<small data-i18n="System Prompt Prefix">System Prompt Prefix</small>
</label>
<div>
<textarea id="instruct_system_sequence_prefix" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></textarea>
<div contenteditable="true" id="instruct_system_sequence_prefix" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></div>
</div>
</div>
<div class="flex1" title="Inserted after a System prompt." data-i18n="[title]Inserted after a System prompt.">
@ -3225,7 +3225,7 @@
<small data-i18n="System Prompt Suffix">System Prompt Suffix</small>
</label>
<div>
<textarea id="instruct_system_sequence_suffix" class="text_pole wide100p textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></textarea>
<div contenteditable="true" id="instruct_system_sequence_suffix" class="text_pole wide100p textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></div>
</div>
</div>
</div>
@ -3238,7 +3238,7 @@
<small data-i18n="User Message Prefix">User Message Prefix</small>
</label>
<div>
<textarea id="instruct_input_sequence" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></textarea>
<div contenteditable="true" id="instruct_input_sequence" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></div>
</div>
</div>
<div class="flex1" title="Inserted after a User message." data-i18n="[title]Inserted after a User message.">
@ -3246,7 +3246,7 @@
<small data-i18n="User Message Suffix">User Message Suffix</small>
</label>
<div>
<textarea id="instruct_input_suffix" class="text_pole wide100p textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></textarea>
<div contenteditable="true" id="instruct_input_suffix" class="text_pole wide100p textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></div>
</div>
</div>
</div>
@ -3256,7 +3256,7 @@
<small data-i18n="Assistant Message Prefix">Assistant Message Prefix</small>
</label>
<div>
<textarea id="instruct_output_sequence" class="text_pole wide100p textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></textarea>
<div contenteditable="true" id="instruct_output_sequence" class="text_pole wide100p textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></div>
</div>
</div>
<div class="flex1" title="Inserted after an Assistant message." data-i18n="[title]Inserted after an Assistant message.">
@ -3264,7 +3264,7 @@
<small data-i18n="Assistant Message Suffix">Assistant Message Suffix</small>
</label>
<div>
<textarea id="instruct_output_suffix" class="text_pole wide100p textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></textarea>
<div contenteditable="true" id="instruct_output_suffix" class="text_pole wide100p textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></div>
</div>
</div>
</div>
@ -3274,7 +3274,7 @@
<small data-i18n="System Message Prefix">System Message Prefix</small>
</label>
<div>
<textarea id="instruct_system_sequence" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></textarea>
<div contenteditable="true" id="instruct_system_sequence" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></div>
</div>
</div>
<div class="flex1" title="Inserted after a System message." data-i18n="[title]Inserted after a System message.">
@ -3282,7 +3282,7 @@
<small data-i18n="System Message Suffix">System Message Suffix</small>
</label>
<div>
<textarea id="instruct_system_suffix" class="text_pole wide100p textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></textarea>
<div contenteditable="true" id="instruct_system_suffix" class="text_pole wide100p textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></div>
</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.">
@ -3301,7 +3301,7 @@
<small data-i18n="First Assistant Prefix">First Assistant Prefix</small>
</label>
<div>
<textarea id="instruct_first_output_sequence" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></textarea>
<div contenteditable="true" id="instruct_first_output_sequence" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></div>
</div>
</div>
<div class="flex1" 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">
@ -3309,7 +3309,7 @@
<small data-i18n="Last Assistant Prefix">Last Assistant Prefix</small>
</label>
<div>
<textarea id="instruct_last_output_sequence" class="text_pole wide100p textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></textarea>
<div contenteditable="true" id="instruct_last_output_sequence" class="text_pole wide100p textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></div>
</div>
</div>
</div>
@ -3319,7 +3319,7 @@
<small data-i18n="First User Prefix">First User Prefix</small>
</label>
<div>
<textarea id="instruct_first_input_sequence" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></textarea>
<div contenteditable="true" id="instruct_first_input_sequence" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></div>
</div>
</div>
<div class="flex1" title="Inserted before the last User's message." data-i18n="[title]instruct_last_input_sequence">
@ -3327,7 +3327,7 @@
<small data-i18n="Last User Prefix">Last User Prefix</small>
</label>
<div>
<textarea id="instruct_last_input_sequence" class="text_pole wide100p textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></textarea>
<div contenteditable="true" id="instruct_last_input_sequence" class="text_pole wide100p textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></div>
</div>
</div>
</div>
@ -3337,7 +3337,7 @@
<small data-i18n="System Instruction Prefix">System Instruction Prefix</small>
</label>
<div>
<textarea id="instruct_last_system_sequence" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></textarea>
<div contenteditable="true" id="instruct_last_system_sequence" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></div>
</div>
</div>
<div class="flex1" 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).">
@ -3345,7 +3345,7 @@
<small data-i18n="Stop Sequence">Stop Sequence</small>
</label>
<div>
<textarea id="instruct_stop_sequence" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></textarea>
<div contenteditable="true" id="instruct_stop_sequence" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></div>
</div>
</div>
</div>
@ -3355,7 +3355,7 @@
<small data-i18n="User Filler Message">User Filler Message</small>
</label>
<div>
<textarea id="instruct_user_alignment_message" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></textarea>
<div contenteditable="true" id="instruct_user_alignment_message" class="text_pole textarea_compact autoSetHeight" maxlength="2000" placeholder="&mdash;" rows="1"></div>
</div>
</div>
</div>
@ -3448,7 +3448,7 @@
</span>
</h4>
<div>
<textarea id="start_reply_with" rows="2" class="text_pole textarea_compact" data-i18n="[placeholder]AI reply prefix" placeholder="AI reply prefix"></textarea>
<div contenteditable="true" id="start_reply_with" rows="2" class="text_pole textarea_compact" data-i18n="[placeholder]AI reply prefix" placeholder="AI reply prefix"></div>
</div>
<label class="checkbox_label" for="chat-show-reply-prefix-checkbox">
<input id="chat-show-reply-prefix-checkbox" type="checkbox" />
@ -3482,7 +3482,7 @@
</small>
</div>
<div>
<textarea id="custom_stopping_strings" rows="2" class="text_pole textarea_compact monospace" placeholder="[&quot;Ford&quot;, &quot;BMW&quot;, &quot;Fiat&quot;]"></textarea>
<div contenteditable="true" id="custom_stopping_strings" rows="2" class="text_pole textarea_compact monospace" placeholder="[&quot;Ford&quot;, &quot;BMW&quot;, &quot;Fiat&quot;]"></div>
</div>
<label class="checkbox_label" for="custom_stopping_strings_macro">
<input id="custom_stopping_strings_macro" type="checkbox" checked>

View File

@ -91,15 +91,17 @@ export function loadInstructMode(data) {
if (control.isCheckbox) {
$element.prop('checked', power_user.instruct[control.property]);
} else {
$element.val(power_user.instruct[control.property]);
$element[0].innerText = (power_user.instruct[control.property]);
}
$element.on('input', async function () {
power_user.instruct[control.property] = control.isCheckbox ? !!$(this).prop('checked') : $(this).val();
power_user.instruct[control.property] = control.isCheckbox ? !!$(this).prop('checked') : $(this)[0].innerText;
saveSettingsDebounced();
/*
if (!control.isCheckbox) {
await resetScrollHeight($element);
}
*/
});
if (control.trigger) {
@ -641,7 +643,8 @@ jQuery(() => {
if (control.isCheckbox) {
$element.prop('checked', power_user.instruct[control.property]).trigger('input');
} else {
$element.val(power_user.instruct[control.property]).trigger('input');
$element[0].innerText = (power_user.instruct[control.property]);
$element.trigger('input');
}
}
});

View File

@ -1607,7 +1607,7 @@ async function loadPowerUserSettings(settings, data) {
$('#auto_swipe_minimum_length').val(power_user.auto_swipe_minimum_length);
$('#auto_swipe_blacklist').val(power_user.auto_swipe_blacklist.join(', '));
$('#auto_swipe_blacklist_threshold').val(power_user.auto_swipe_blacklist_threshold);
$('#custom_stopping_strings').val(power_user.custom_stopping_strings);
$('#custom_stopping_strings').text(power_user.custom_stopping_strings);
$('#custom_stopping_strings_macro').prop('checked', power_user.custom_stopping_strings_macro);
$('#fuzzy_search_checkbox').prop('checked', power_user.fuzzy_search);
$('#persona_show_notifications').prop('checked', power_user.persona_show_notifications);
@ -1637,7 +1637,7 @@ async function loadPowerUserSettings(settings, data) {
$('#waifuMode').prop('checked', power_user.waifuMode);
$('#movingUImode').prop('checked', power_user.movingUI);
$('#noShadowsmode').prop('checked', power_user.noShadows);
$('#start_reply_with').val(power_user.user_prompt_bias);
$('#start_reply_with').text(power_user.user_prompt_bias);
$('#chat-show-reply-prefix-checkbox').prop('checked', power_user.show_user_prompt_bias);
$('#auto_continue_enabled').prop('checked', power_user.auto_continue.enabled);
$('#auto_continue_allow_chat_completions').prop('checked', power_user.auto_continue.allow_chat_completions);
@ -1887,13 +1887,14 @@ async function loadContextSettings() {
if (control.isCheckbox) {
$element.prop('checked', power_user.context[control.property]);
} else {
$element.val(power_user.context[control.property]);
$element.text(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', async function () {
const value = control.isCheckbox ? !!$(this).prop('checked') : $(this).val();
$element.on('input keyUp', async function () {
const value = control.isCheckbox ? !!$(this).prop('checked') : $(this)[0].innerText;
if (control.isGlobalSetting) {
power_user[control.property] = value;
} else {
@ -1901,9 +1902,11 @@ async function loadContextSettings() {
}
saveSettingsDebounced();
/*
if (!control.isCheckbox) {
await resetScrollHeight($element);
}
*/
});
});
@ -1917,7 +1920,7 @@ async function loadContextSettings() {
});
$('#context_presets').on('change', function () {
const name = String($(this).find(':selected').val());
const name = String($(this).find(':selected').text());
const preset = context_presets.find(x => x.name === name);
if (!preset) {
@ -1942,9 +1945,8 @@ async function loadContextSettings() {
.prop('checked', control.isGlobalSetting ? power_user[control.property] : power_user.context[control.property])
.trigger('input');
} else {
$element
.val(control.isGlobalSetting ? power_user[control.property] : power_user.context[control.property])
.trigger('input');
$element[0].innerText = (control.isGlobalSetting ? power_user[control.property] : power_user.context[control.property])
$element.trigger('input');
}
}
});
@ -3246,7 +3248,7 @@ $(document).ready(() => {
});
$('#start_reply_with').on('input', function () {
power_user.user_prompt_bias = String($(this).val());
power_user.user_prompt_bias = String($(this)[0].innerText);
saveSettingsDebounced();
});
@ -3785,7 +3787,7 @@ $(document).ready(() => {
});
$('#custom_stopping_strings').on('input', function () {
power_user.custom_stopping_strings = String($(this).val());
power_user.custom_stopping_strings = String($(this)[0].innerText).trim();
saveSettingsDebounced();
});