Merge pull request #2768 from SillyTavern/expand-contenteditable

7cba747c528b89dea7fcd562b97b24d85eee0b2e

Cohee <18619528+Cohee1207@users.noreply.github.com>

Signed
2 files changed, +12 -4Ignore whitespace
public/index.html+4 -2
@@ -3085,8 +3085,9 @@
30853085 <select id="context_presets" data-preset-manager-for="context" class="flex1 text_pole"></select>
30863086 </div>
30873087 <div>
30883088 <label for="context_story_string" class="flex-container">
30893089 <small data-i18n="Story String">Story String</small>
3090+ <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>
30903091 </label>
30913092 <div contenteditable="true" id="context_story_string" class="text_pole textarea_compact"></div>
30923093 <div class="flex-container">
@@ -3236,8 +3237,9 @@
32363237 <input type="text" id="instruct_activation_regex" class="text_pole textarea_compact" placeholder="e.g. /llama(-)?[3|3.1]/i"></input>
32373238 </div>
32383239 <div>
3239- <label>
3240+ <label for="instruct_system_prompt" class="flex-container">
32403241 <small data-i18n="System Prompt">System Prompt</small>
3242+ <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>
32413243 </label>
32423244 <div contenteditable="true" id="instruct_system_prompt" class="text_pole textarea_compact"></div>
32433245 </div>
public/scripts/chats.js+8 -2
@@ -1416,6 +1416,7 @@ jQuery(function () {
14161416 $(document).on('click', '.editor_maximize', function () {
14171417 const broId = $(this).attr('data-for');
14181418 const bro = $(`#${broId}`);
1419+ const contentEditable = bro.is('[contenteditable]');
14191420 const withTab = $(this).attr('data-tab');
14201421
14211422 if (!bro.length) {
@@ -1427,11 +1428,16 @@ jQuery(function () {
14271428 wrapper.classList.add('height100p', 'wide100p', 'flex-container');
14281429 wrapper.classList.add('flexFlowColumn', 'justifyCenter', 'alignitemscenter');
14291430 const textarea = document.createElement('textarea');
14301431 textarea.value = String(contentEditable ? bro[0].innerText : bro.val());
14311432 textarea.classList.add('height100p', 'wide100p', 'maximized_textarea');
14321433 bro.hasClass('monospace') && textarea.classList.add('monospace');
14331434 textarea.addEventListener('input', function () {
1434- bro.val(textarea.value).trigger('input');
1435+ if (contentEditable) {
1436+ bro[0].innerText = textarea.value;
1437+ bro.trigger('input');
1438+ } else {
1439+ bro.val(textarea.value).trigger('input');
1440+ }
14351441 });
14361442 wrapper.appendChild(textarea);
14371443