Merge pull request #3765 from SillyTavern/feat/wi-content-expando

Add expand editor for WI content
This commit is contained in:
Cohee
2025-03-27 20:57:57 +02:00
committed by GitHub
2 changed files with 10 additions and 3 deletions

View File

@ -6086,8 +6086,11 @@
<label for="content ">
<small>
<span class="alignitemscenter flex-container flexnowrap wide100p justifySpaceBetween">
<span data-i18n="Content" class="alignitemscenter flex-container flexNoGap mdhotkey_location">
Content
<span class="alignitemscenter flex-container">
<span data-i18n="Content" class="mdhotkey_location">
Content
</span>
<i class="editor_maximize fa-solid fa-maximize right_menu_button" title="Expand the editor" data-i18n="[title]Expand the editor"></i>
</span>
<span>
(<span data-i18n="extension_token_counter">Tokens:</span>&nbsp; <span class="world_entry_form_token_counter" data-first-run="true">counting...</span>)&nbsp;

View File

@ -2680,8 +2680,10 @@ export async function getWorldEntry(name, data, entry) {
$(counter).text(numberOfTokens);
}, debounce_timeout.relaxed);
const contentInputId = `world_entry_content_${entry.uid}`;
const contentInput = template.find('textarea[name="content"]');
contentInput.data('uid', entry.uid);
contentInput.attr('id', contentInputId);
contentInput.on('input', async function (_, { skipCount } = {}) {
const uid = $(this).data('uid');
const value = $(this).val();
@ -2698,7 +2700,9 @@ export async function getWorldEntry(name, data, entry) {
countTokensDebounced(counter, value);
});
contentInput.val(entry.content).trigger('input', { skipCount: true });
//initScrollHeight(contentInput);
const contentExpandButton = template.find('.editor_maximize');
contentExpandButton.attr('data-for', contentInputId);
template.find('.inline-drawer-toggle').on('click', function () {
if (counter.data('first-run')) {