mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add optional {{char}} display name visible in formatted messages
This commit is contained in:
@ -1501,6 +1501,10 @@
|
|||||||
<input id="auto_fix_generated_markdown" type="checkbox" />
|
<input id="auto_fix_generated_markdown" type="checkbox" />
|
||||||
Auto-fix Markdown
|
Auto-fix Markdown
|
||||||
</label>
|
</label>
|
||||||
|
<label class="checkbox_label" for="allow_name2_display">
|
||||||
|
<input id="allow_name2_display" type="checkbox" />
|
||||||
|
Allow {{char}}: display in bot messages
|
||||||
|
</label>
|
||||||
<label for="auto_scroll_chat_to_bottom">
|
<label for="auto_scroll_chat_to_bottom">
|
||||||
<input id="auto_scroll_chat_to_bottom" type="checkbox" />
|
<input id="auto_scroll_chat_to_bottom" type="checkbox" />
|
||||||
Auto-scroll Chat
|
Auto-scroll Chat
|
||||||
|
@ -143,7 +143,7 @@ export {
|
|||||||
setRightTabSelectedClass,
|
setRightTabSelectedClass,
|
||||||
openCharacterChat,
|
openCharacterChat,
|
||||||
saveChat,
|
saveChat,
|
||||||
messageFormating,
|
messageFormatting,
|
||||||
getExtensionPrompt,
|
getExtensionPrompt,
|
||||||
showSwipeButtons,
|
showSwipeButtons,
|
||||||
hideSwipeButtons,
|
hideSwipeButtons,
|
||||||
@ -931,7 +931,7 @@ export async function reloadCurrentChat() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function messageFormating(mes, ch_name, isSystem, forceAvatar) {
|
function messageFormatting(mes, ch_name, isSystem, isUser) {
|
||||||
if (!mes) {
|
if (!mes) {
|
||||||
mes = '';
|
mes = '';
|
||||||
}
|
}
|
||||||
@ -967,9 +967,9 @@ function messageFormating(mes, ch_name, isSystem, forceAvatar) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if (ch_name && (forceAvatar || ch_name !== name1)) {
|
if (!power_user.allow_name2_display && ch_name && !isUser && !isSystem) {
|
||||||
mes = mes.replaceAll(ch_name + ":", "");
|
mes = mes.replaceAll(`${ch_name}:`, "");
|
||||||
} */
|
}
|
||||||
|
|
||||||
return mes;
|
return mes;
|
||||||
}
|
}
|
||||||
@ -1057,13 +1057,13 @@ function addOneMessage(mes, { type = "normal", insertAfter = null, scroll = true
|
|||||||
if (count_view_mes == 0) {
|
if (count_view_mes == 0) {
|
||||||
messageText = substituteParams(messageText);
|
messageText = substituteParams(messageText);
|
||||||
}
|
}
|
||||||
messageText = messageFormating(
|
messageText = messageFormatting(
|
||||||
messageText,
|
messageText,
|
||||||
characterName,
|
characterName,
|
||||||
isSystem,
|
isSystem,
|
||||||
mes.force_avatar
|
mes.is_user,
|
||||||
);
|
);
|
||||||
const bias = messageFormating(mes.extra?.bias ?? "");
|
const bias = messageFormatting(mes.extra?.bias ?? "");
|
||||||
|
|
||||||
let params = {
|
let params = {
|
||||||
mesId: count_view_mes,
|
mesId: count_view_mes,
|
||||||
@ -1414,7 +1414,12 @@ class StreamingProcessor {
|
|||||||
chat[messageId]['swipes'][chat[messageId]['swipe_id']] = processedText;
|
chat[messageId]['swipes'][chat[messageId]['swipe_id']] = processedText;
|
||||||
}
|
}
|
||||||
|
|
||||||
let formattedText = messageFormating(processedText, chat[messageId].name, chat[messageId].is_system, chat[messageId].force_avatar);
|
let formattedText = messageFormatting(
|
||||||
|
processedText,
|
||||||
|
chat[messageId].name,
|
||||||
|
chat[messageId].is_system,
|
||||||
|
chat[messageId].is_user,
|
||||||
|
);
|
||||||
const mesText = $(`#chat .mes[mesid="${messageId}"] .mes_text`);
|
const mesText = $(`#chat .mes[mesid="${messageId}"] .mes_text`);
|
||||||
mesText.html(formattedText);
|
mesText.html(formattedText);
|
||||||
$(`#chat .mes[mesid="${messageId}"] .mes_timer`).text(timePassed.timerValue).attr('title', timePassed.timerTitle);
|
$(`#chat .mes[mesid="${messageId}"] .mes_timer`).text(timePassed.timerValue).attr('title', timePassed.timerTitle);
|
||||||
@ -3245,7 +3250,12 @@ function messageEditAuto(div) {
|
|||||||
}
|
}
|
||||||
chat[this_edit_mes_id]["extra"]["bias"] = bias ?? null;
|
chat[this_edit_mes_id]["extra"]["bias"] = bias ?? null;
|
||||||
mesBlock.find(".mes_text").val('');
|
mesBlock.find(".mes_text").val('');
|
||||||
mesBlock.find(".mes_text").val(messageFormating(text, this_edit_mes_chname, chat[this_edit_mes_id].is_system, chat[this_edit_mes_id].force_avatar));
|
mesBlock.find(".mes_text").val(messageFormatting(
|
||||||
|
text,
|
||||||
|
this_edit_mes_chname,
|
||||||
|
chat[this_edit_mes_id].is_system,
|
||||||
|
chat[this_edit_mes_id].is_user,
|
||||||
|
));
|
||||||
saveChatDebounced();
|
saveChatDebounced();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3266,10 +3276,15 @@ function messageEditDone(div) {
|
|||||||
mesBlock.find(".mes_edit_buttons").css("display", "none");
|
mesBlock.find(".mes_edit_buttons").css("display", "none");
|
||||||
mesBlock.find(".mes_edit").css("display", "inline-block");
|
mesBlock.find(".mes_edit").css("display", "inline-block");
|
||||||
mesBlock.find(".mes_text").append(
|
mesBlock.find(".mes_text").append(
|
||||||
messageFormating(text, this_edit_mes_chname, chat[this_edit_mes_id].is_system, chat[this_edit_mes_id].force_avatar)
|
messageFormatting(
|
||||||
|
text,
|
||||||
|
this_edit_mes_chname,
|
||||||
|
chat[this_edit_mes_id].is_system,
|
||||||
|
chat[this_edit_mes_id].is_user,
|
||||||
|
)
|
||||||
);
|
);
|
||||||
mesBlock.find(".mes_bias").empty();
|
mesBlock.find(".mes_bias").empty();
|
||||||
mesBlock.find(".mes_bias").append(messageFormating(bias));
|
mesBlock.find(".mes_bias").append(messageFormatting(bias));
|
||||||
appendImageToMessage(chat[this_edit_mes_id], div.closest(".mes"));
|
appendImageToMessage(chat[this_edit_mes_id], div.closest(".mes"));
|
||||||
addCopyToCodeBlocks(div.closest(".mes"));
|
addCopyToCodeBlocks(div.closest(".mes"));
|
||||||
this_edit_mes_id = undefined;
|
this_edit_mes_id = undefined;
|
||||||
@ -5204,7 +5219,12 @@ $(document).ready(function () {
|
|||||||
$(this)
|
$(this)
|
||||||
.closest(".mes_block")
|
.closest(".mes_block")
|
||||||
.find(".mes_text")
|
.find(".mes_text")
|
||||||
.append(messageFormating(text, this_edit_mes_chname, chat[this_edit_mes_id].is_system, chat[this_edit_mes_id].force_avatar));
|
.append(messageFormatting(
|
||||||
|
text,
|
||||||
|
this_edit_mes_chname,
|
||||||
|
chat[this_edit_mes_id].is_system,
|
||||||
|
chat[this_edit_mes_id].is_user,
|
||||||
|
));
|
||||||
appendImageToMessage(chat[this_edit_mes_id], $(this).closest(".mes"));
|
appendImageToMessage(chat[this_edit_mes_id], $(this).closest(".mes"));
|
||||||
addCopyToCodeBlocks($(this).closest(".mes"));
|
addCopyToCodeBlocks($(this).closest(".mes"));
|
||||||
this_edit_mes_id = undefined;
|
this_edit_mes_id = undefined;
|
||||||
|
@ -100,6 +100,7 @@ let power_user = {
|
|||||||
auto_fix_generated_markdown: true,
|
auto_fix_generated_markdown: true,
|
||||||
send_on_enter: send_on_enter_options.AUTO,
|
send_on_enter: send_on_enter_options.AUTO,
|
||||||
render_formulas: false,
|
render_formulas: false,
|
||||||
|
allow_name2_display: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
let themes = [];
|
let themes = [];
|
||||||
@ -372,6 +373,7 @@ function loadPowerUserSettings(settings, data) {
|
|||||||
$("#play_message_sound").prop("checked", power_user.play_message_sound);
|
$("#play_message_sound").prop("checked", power_user.play_message_sound);
|
||||||
$("#play_sound_unfocused").prop("checked", power_user.play_sound_unfocused);
|
$("#play_sound_unfocused").prop("checked", power_user.play_sound_unfocused);
|
||||||
$("#auto_save_msg_edits").prop("checked", power_user.auto_save_msg_edits);
|
$("#auto_save_msg_edits").prop("checked", power_user.auto_save_msg_edits);
|
||||||
|
$("#allow_name2_display").prop("checked", power_user.allow_name2_display);
|
||||||
$(`input[name="avatar_style"][value="${power_user.avatar_style}"]`).prop("checked", true);
|
$(`input[name="avatar_style"][value="${power_user.avatar_style}"]`).prop("checked", true);
|
||||||
$(`input[name="chat_display"][value="${power_user.chat_display}"]`).prop("checked", true);
|
$(`input[name="chat_display"][value="${power_user.chat_display}"]`).prop("checked", true);
|
||||||
$(`input[name="sheld_width"][value="${power_user.sheld_width}"]`).prop("checked", true);
|
$(`input[name="sheld_width"][value="${power_user.sheld_width}"]`).prop("checked", true);
|
||||||
@ -747,6 +749,12 @@ $(document).ready(() => {
|
|||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
$("#allow_name2_display").on("input", function () {
|
||||||
|
power_user.allow_name2_display = !!$(this).prop('checked');
|
||||||
|
reloadCurrentChat();
|
||||||
|
saveSettingsDebounced();
|
||||||
|
});
|
||||||
|
|
||||||
$(window).on('focus', function () {
|
$(window).on('focus', function () {
|
||||||
browser_has_focus = true;
|
browser_has_focus = true;
|
||||||
});
|
});
|
||||||
|
@ -1857,6 +1857,7 @@ input[type='checkbox']:not(#nav-toggle):not(#rm_button_panel_pin) {
|
|||||||
background-color: white;
|
background-color: white;
|
||||||
box-shadow: inset 0 0 3px 0 var(--black70a);
|
box-shadow: inset 0 0 3px 0 var(--black70a);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the checkbox starts with a size 0 background of a checkmark */
|
/* the checkbox starts with a size 0 background of a checkmark */
|
||||||
|
Reference in New Issue
Block a user