Merge branch 'staging' into feature/exorcism

This commit is contained in:
Cohee
2023-08-31 00:42:34 +03:00
12 changed files with 417 additions and 208 deletions

View File

@ -4,7 +4,7 @@ import { callPopup, event_types, eventSource, is_send_press, main_api, substitut
import { is_group_generating } from "./group-chats.js";
import { TokenHandler } from "./openai.js";
import { power_user } from "./power-user.js";
import { debounce, waitUntilCondition } from "./utils.js";
import { debounce, waitUntilCondition, escapeHtml } from "./utils.js";
function debouncePromise(func, delay) {
let timeoutId;
@ -1291,7 +1291,7 @@ PromptManagerModule.prototype.renderPromptManager = function () {
const prompts = [...this.serviceSettings.prompts]
.filter(prompt => prompt && !prompt?.system_prompt)
.sort((promptA, promptB) => promptA.name.localeCompare(promptB.name))
.reduce((acc, prompt) => acc + `<option value="${prompt.identifier}">${prompt.name}</option>`, '');
.reduce((acc, prompt) => acc + `<option value="${prompt.identifier}">${escapeHtml(prompt.name)}</option>`, '');
const footerHtml = `
<div class="${this.configuration.prefix}prompt_manager_footer">
@ -1440,13 +1440,14 @@ PromptManagerModule.prototype.renderPromptManagerListItems = function () {
toggleSpanHtml = `<span class="fa-solid"></span>`;
}
const encodedName = escapeHtml(prompt.name);
listItemHtml += `
<li class="${prefix}prompt_manager_prompt ${draggableClass} ${enabledClass} ${markerClass}" data-pm-identifier="${prompt.identifier}">
<span class="${prefix}prompt_manager_prompt_name" data-pm-name="${prompt.name}">
<span class="${prefix}prompt_manager_prompt_name" data-pm-name="${encodedName}">
${prompt.marker ? '<span class="fa-solid fa-thumb-tack" title="Marker"></span>' : ''}
${!prompt.marker && prompt.system_prompt ? '<span class="fa-solid fa-square-poll-horizontal" title="Global Prompt"></span>' : ''}
${!prompt.marker && !prompt.system_prompt ? '<span class="fa-solid fa-user" title="User Prompt"></span>' : ''}
${this.isPromptInspectionAllowed(prompt) ? `<a class="prompt-manager-inspect-action">${prompt.name}</a>` : prompt.name}
${this.isPromptInspectionAllowed(prompt) ? `<a class="prompt-manager-inspect-action">${encodedName}</a>` : encodedName}
</span>
<span>
<span class="prompt_manager_prompt_controls">

View File

@ -1021,9 +1021,9 @@ export function initRossMods() {
}
if (event.key == "Escape") { //closes various panels
//dont override Escape hotkey functions from script.js
//"close edit box" and "cancel stream generation".
if ($("#curEditTextarea").is(":visible") || $("#mes_stop").is(":visible")) {
console.debug('escape key, but deferring to script.js routines')
return
@ -1060,13 +1060,11 @@ export function initRossMods() {
.not('#left-nav-panel')
.not('#right-nav-panel')
.not('#floatingPrompt')
console.log(visibleDrawerContent)
$(visibleDrawerContent).parent().find('.drawer-icon').trigger('click');
return
}
if ($("#floatingPrompt").is(":visible")) {
console.log('saw AN visible, trying to close')
$("#ANClose").trigger('click');
return
}
@ -1097,7 +1095,7 @@ export function initRossMods() {
if (event.ctrlKey && /^[1-9]$/.test(event.key)) {
// Your code here
// This will eventually be to trigger quick replies
event.preventDefault();
console.log("Ctrl +" + event.key + " pressed!");
}

View File

@ -385,7 +385,7 @@ jQuery(async () => {
const buttonHtml = $(await $.get(`${extensionFolderPath}/menuButton.html`));
buttonHtml.on('click', onCfgMenuItemClick)
buttonHtml.insertAfter("#option_toggle_AN");
buttonHtml.appendTo("#options_advanced");
// Hook events
eventSource.on(event_types.CHAT_CHANGED, async () => {

View File

@ -165,6 +165,7 @@ let power_user = {
continue_on_send: false,
trim_spaces: true,
relaxed_api_urls: false,
disable_group_trimming: false,
default_instruct: '',
instruct: {
@ -789,6 +790,7 @@ function loadPowerUserSettings(settings, data) {
$("#trim_sentences_checkbox").prop("checked", power_user.trim_sentences);
$("#include_newline_checkbox").prop("checked", power_user.include_newline);
$('#render_formulas').prop("checked", power_user.render_formulas);
$('#disable_group_trimming').prop("checked", power_user.disable_group_trimming);
$("#markdown_escape_strings").val(power_user.markdown_escape_strings);
$("#fast_ui_mode").prop("checked", power_user.fast_ui_mode);
$("#waifuMode").prop("checked", power_user.waifuMode);
@ -2160,6 +2162,11 @@ $(document).ready(() => {
saveSettingsDebounced();
});
$('#disable_group_trimming').on('input', function () {
power_user.disable_group_trimming = !!$(this).prop('checked');
saveSettingsDebounced();
});
$('#debug_menu').on('click', function () {
showDebugMenu();
});

View File

@ -14,6 +14,10 @@ export const PAGINATION_TEMPLATE = '<%= rangeStart %>-<%= rangeEnd %> of <%= tot
*/
export const navigation_option = { none: 0, previous: 1, last: 2, };
export function escapeHtml(str) {
return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}
/**
* Determines if a value is unique in an array.
* @param {any} value Current value.