mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Make resizable inputs in editor of WI
This commit is contained in:
@@ -3291,37 +3291,49 @@
|
|||||||
template.data('uid', entry.uid);
|
template.data('uid', entry.uid);
|
||||||
|
|
||||||
// key
|
// key
|
||||||
const keyInput = template.find('input[name="key"]');
|
const keyInput = template.find('textarea[name="key"]');
|
||||||
keyInput.data('uid', entry.uid);
|
keyInput.data('uid', entry.uid);
|
||||||
keyInput.on('input', function () {
|
keyInput.on('input', function () {
|
||||||
const uid = $(this).data('uid');
|
const uid = $(this).data('uid');
|
||||||
const value = $(this).val();
|
const value = $(this).val();
|
||||||
|
$(this).css("height", ""); //reset the height
|
||||||
|
$(this).css("height", $(this).prop('scrollHeight') + "px");
|
||||||
world_info_data.entries[uid].key = value.split(',').map(x => x.trim()).filter(x => x);
|
world_info_data.entries[uid].key = value.split(',').map(x => x.trim()).filter(x => x);
|
||||||
saveWorldInfo();
|
saveWorldInfo();
|
||||||
});
|
});
|
||||||
keyInput.val(entry.key.join(',')).trigger('input');
|
keyInput.val(entry.key.join(',')).trigger('input');
|
||||||
|
keyInput.css("height", ""); //reset the height
|
||||||
|
keyInput.css("height", $(this).prop('scrollHeight') + "px");
|
||||||
|
|
||||||
// keysecondary
|
// keysecondary
|
||||||
const keySecondaryInput = template.find('input[name="keysecondary"]');
|
const keySecondaryInput = template.find('textarea[name="keysecondary"]');
|
||||||
keySecondaryInput.data('uid', entry.uid);
|
keySecondaryInput.data('uid', entry.uid);
|
||||||
keySecondaryInput.on('input', function() {
|
keySecondaryInput.on('input', function() {
|
||||||
const uid = $(this).data('uid');
|
const uid = $(this).data('uid');
|
||||||
const value = $(this).val();
|
const value = $(this).val();
|
||||||
|
$(this).css("height", ""); //reset the height
|
||||||
|
$(this).css("height", $(this).prop('scrollHeight') + "px");
|
||||||
world_info_data.entries[uid].keysecondary = value.split(',').map(x => x.trim()).filter(x => x);
|
world_info_data.entries[uid].keysecondary = value.split(',').map(x => x.trim()).filter(x => x);
|
||||||
saveWorldInfo();
|
saveWorldInfo();
|
||||||
});
|
});
|
||||||
keySecondaryInput.val(entry.keysecondary.join(',')).trigger('input');
|
keySecondaryInput.val(entry.keysecondary.join(',')).trigger('input');
|
||||||
|
keySecondaryInput.css("height", ""); //reset the height
|
||||||
|
keySecondaryInput.css("height", $(this).prop('scrollHeight') + "px");
|
||||||
|
|
||||||
// comment
|
// comment
|
||||||
const commentInput = template.find('input[name="comment"]');
|
const commentInput = template.find('textarea[name="comment"]');
|
||||||
commentInput.data('uid', entry.uid);
|
commentInput.data('uid', entry.uid);
|
||||||
commentInput.on('input', function() {
|
commentInput.on('input', function() {
|
||||||
const uid = $(this).data('uid');
|
const uid = $(this).data('uid');
|
||||||
const value = $(this).val();
|
const value = $(this).val();
|
||||||
|
$(this).css("height", ""); //reset the height
|
||||||
|
$(this).css("height", $(this).prop('scrollHeight') + "px");
|
||||||
world_info_data.entries[uid].comment = value;
|
world_info_data.entries[uid].comment = value;
|
||||||
saveWorldInfo();
|
saveWorldInfo();
|
||||||
});
|
});
|
||||||
commentInput.val(entry.comment).trigger('input');
|
commentInput.val(entry.comment).trigger('input');
|
||||||
|
commentInput.css("height", ""); //reset the height
|
||||||
|
commentInput.css("height", $(this).prop('scrollHeight') + "px");
|
||||||
|
|
||||||
// content
|
// content
|
||||||
const contentInput = template.find('textarea[name="content"]');
|
const contentInput = template.find('textarea[name="content"]');
|
||||||
@@ -3330,6 +3342,8 @@
|
|||||||
const uid = $(this).data('uid');
|
const uid = $(this).data('uid');
|
||||||
const value = $(this).val();
|
const value = $(this).val();
|
||||||
world_info_data.entries[uid].content = value;
|
world_info_data.entries[uid].content = value;
|
||||||
|
$(this).css("height", ""); //reset the height
|
||||||
|
$(this).css("height", $(this).prop('scrollHeight') + "px");
|
||||||
saveWorldInfo();
|
saveWorldInfo();
|
||||||
|
|
||||||
// count tokens
|
// count tokens
|
||||||
@@ -3337,6 +3351,8 @@
|
|||||||
$(this).closest('.world_entry').find('.world_entry_form_token_counter').html(numberOfTokens);
|
$(this).closest('.world_entry').find('.world_entry_form_token_counter').html(numberOfTokens);
|
||||||
});
|
});
|
||||||
contentInput.val(entry.content).trigger('input');
|
contentInput.val(entry.content).trigger('input');
|
||||||
|
contentInput.css("height", ""); //reset the height
|
||||||
|
contentInput.css("height", $(this).prop('scrollHeight') + "px");
|
||||||
|
|
||||||
// selective
|
// selective
|
||||||
const selectiveInput = template.find('input[name="selective"]');
|
const selectiveInput = template.find('input[name="selective"]');
|
||||||
@@ -3376,6 +3392,7 @@
|
|||||||
orderInput.on('input', function() {
|
orderInput.on('input', function() {
|
||||||
const uid = $(this).data('uid');
|
const uid = $(this).data('uid');
|
||||||
const value = Number($(this).val());
|
const value = Number($(this).val());
|
||||||
|
|
||||||
world_info_data.entries[uid].order = !isNaN(value) ? value : 0;
|
world_info_data.entries[uid].order = !isNaN(value) ? value : 0;
|
||||||
saveWorldInfo();
|
saveWorldInfo();
|
||||||
});
|
});
|
||||||
@@ -3675,14 +3692,14 @@
|
|||||||
<h4>Key</h4>
|
<h4>Key</h4>
|
||||||
<h5>Comma-separated list of keywords (e.g: foo,bar).</h5>
|
<h5>Comma-separated list of keywords (e.g: foo,bar).</h5>
|
||||||
</label>
|
</label>
|
||||||
<input class="text_pole" type="text" name="key" placeholder=""/>
|
<textarea class="text_pole" name="key" rows="1" placeholder=""></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="world_entry_form_control keysecondary">
|
<div class="world_entry_form_control keysecondary">
|
||||||
<label for="keysecondary">
|
<label for="keysecondary">
|
||||||
<h4>Secondary Key</h4>
|
<h4>Secondary Key</h4>
|
||||||
<h5>Comma-separated list of additional keywords.</h5>
|
<h5>Comma-separated list of additional keywords.</h5>
|
||||||
</label>
|
</label>
|
||||||
<input class="text_pole" type="text" name="keysecondary" placeholder=""/>
|
<textarea class="text_pole" name="keysecondary" rows="1" placeholder=""></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="world_entry_thin_controls">
|
<div class="world_entry_thin_controls">
|
||||||
@@ -3698,7 +3715,7 @@
|
|||||||
<h4>Comment</h4>
|
<h4>Comment</h4>
|
||||||
<h5>Optional comment (doesn't affect the AI).</h5>
|
<h5>Optional comment (doesn't affect the AI).</h5>
|
||||||
</label>
|
</label>
|
||||||
<input class="text_pole" type="text" name="comment" placeholder=""/>
|
<textarea class="text_pole" rows="1" name="comment"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="world_entry_form_control">
|
<div class="world_entry_form_control">
|
||||||
|
Reference in New Issue
Block a user