mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Added "Send on Enter" power user setting
Defaults to on. Intended for use on mobile, so line breaks can be more easily added while typing.
This commit is contained in:
@@ -1259,6 +1259,10 @@
|
||||
<label for="swipes-checkbox">
|
||||
<input id="swipes-checkbox" type="checkbox" />
|
||||
Swipes
|
||||
</label>
|
||||
<label for="sendOnEnter-checkbox">
|
||||
<input id="sendOnEnter-checkbox" type="checkbox" />
|
||||
Send on Enter
|
||||
</label>
|
||||
<label for="play_message_sound" class="checkbox_label">
|
||||
<input id="play_message_sound" type="checkbox" />
|
||||
|
@@ -405,6 +405,7 @@ var message_already_generated = "";
|
||||
var cycle_count_generation = 0;
|
||||
|
||||
var swipes = false;
|
||||
var sendOnEnter = true;
|
||||
|
||||
let anchor_order = 0;
|
||||
let style_anchor = true;
|
||||
@@ -878,6 +879,7 @@ function messageFormating(mes, ch_name, isSystem, forceAvatar) {
|
||||
.replace(/\*\*(.+?)\*\*/g, "<b>$1</b>")
|
||||
.replace(/\n/g, "<br/>");
|
||||
} else if (!isSystem) {
|
||||
|
||||
mes = mes.replace(/```[\s\S]*?```|``[\s\S]*?``|`[\s\S]*?`|(\".+?\")/gm, function(match, p1) {
|
||||
if (p1) {
|
||||
return "<q>" + p1.replace(/\"/g, "") + "</q>";
|
||||
@@ -885,16 +887,23 @@ function messageFormating(mes, ch_name, isSystem, forceAvatar) {
|
||||
return match;
|
||||
}
|
||||
});
|
||||
|
||||
mes = converter.makeHtml(mes);
|
||||
|
||||
//mes = mes.replace(/{.*}/g, "");
|
||||
mes = mes.replace(/{{(\*?.+?\*?)}}/g, "");
|
||||
|
||||
|
||||
|
||||
mes = mes.replace(/\n/g, "<br/>");
|
||||
mes = mes.trim();
|
||||
|
||||
mes = mes.replace(/<code(.*)>[\s\S]*?<\/code>/g, function (match) {
|
||||
return match.replace(/&/g, '&');
|
||||
});
|
||||
//mes = mes.replace(/(?<!<code>)(\".+?\")(?![^<]*<\/code>)/g, "<q>$1</q>");
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (forceAvatar) {
|
||||
@@ -2800,6 +2809,8 @@ async function getSettings(type) {
|
||||
|
||||
swipes = !!settings.swipes; //// swipecode
|
||||
$('#swipes-checkbox').prop('checked', swipes); /// swipecode
|
||||
sendOnEnter = !!settings.sendOnEnter;
|
||||
$('#sendOnEnter-checkbox').prop('checked', sendOnEnter);
|
||||
//console.log('getSettings -- swipes = ' + swipes + '. toggling box');
|
||||
hideSwipeButtons();
|
||||
//console.log('getsettings calling showswipebtns');
|
||||
@@ -2915,6 +2926,7 @@ async function saveSettings(type) {
|
||||
active_character: active_character,
|
||||
textgenerationwebui_settings: textgenerationwebui_settings,
|
||||
swipes: swipes,
|
||||
sendOnEnter: sendOnEnter,
|
||||
horde_settings: horde_settings,
|
||||
power_user: power_user,
|
||||
poe_settings: poe_settings,
|
||||
@@ -3556,6 +3568,12 @@ $(document).ready(function () {
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#sendOnEnter-checkbox').change(function () {
|
||||
sendOnEnter = !!$('#sendOnEnter-checkbox').prop('checked');
|
||||
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
///// SWIPE BUTTON CLICKS ///////
|
||||
|
||||
$(document).on('click', '.swipe_right', function () { //when we click swipe right button
|
||||
@@ -3847,7 +3865,7 @@ $(document).ready(function () {
|
||||
});
|
||||
|
||||
$("#send_textarea").keydown(function (e) {
|
||||
if (!e.shiftKey && !e.ctrlKey && e.key == "Enter" && is_send_press == false) {
|
||||
if (!e.shiftKey && !e.ctrlKey && e.key == "Enter" && is_send_press == false && !!$('#sendOnEnter-checkbox').prop('checked')) {
|
||||
is_send_press = true;
|
||||
e.preventDefault();
|
||||
Generate();
|
||||
|
Reference in New Issue
Block a user