mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add SD style deletion
This commit is contained in:
@ -534,6 +534,42 @@ function onStyleSelect() {
|
|||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function onDeleteStyleClick() {
|
||||||
|
const selectedStyle = String($('#sd_style').find(':selected').val());
|
||||||
|
const styleObject = extension_settings.sd.styles.find(x => x.name === selectedStyle);
|
||||||
|
|
||||||
|
if (!styleObject) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const confirmed = await callPopup(`Are you sure you want to delete the style "${selectedStyle}"?`, 'confirm', '', { okButton: 'Delete' });
|
||||||
|
|
||||||
|
if (!confirmed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const index = extension_settings.sd.styles.indexOf(styleObject);
|
||||||
|
|
||||||
|
if (index === -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
extension_settings.sd.styles.splice(index, 1);
|
||||||
|
$('#sd_style').find(`option[value="${selectedStyle}"]`).remove();
|
||||||
|
|
||||||
|
if (extension_settings.sd.styles.length > 0) {
|
||||||
|
extension_settings.sd.style = extension_settings.sd.styles[0].name;
|
||||||
|
$('#sd_style').val(extension_settings.sd.style).trigger('change');
|
||||||
|
} else {
|
||||||
|
extension_settings.sd.style = '';
|
||||||
|
$('#sd_prompt_prefix').val('').trigger('input');
|
||||||
|
$('#sd_negative_prompt').val('').trigger('input');
|
||||||
|
$('#sd_style').val('');
|
||||||
|
}
|
||||||
|
|
||||||
|
saveSettingsDebounced();
|
||||||
|
}
|
||||||
|
|
||||||
async function onSaveStyleClick() {
|
async function onSaveStyleClick() {
|
||||||
const userInput = await callPopup('Enter style name:', 'input', '', { okButton: 'Save' });
|
const userInput = await callPopup('Enter style name:', 'input', '', { okButton: 'Save' });
|
||||||
|
|
||||||
@ -3223,6 +3259,7 @@ jQuery(async () => {
|
|||||||
$('#sd_expand').on('input', onExpandInput);
|
$('#sd_expand').on('input', onExpandInput);
|
||||||
$('#sd_style').on('change', onStyleSelect);
|
$('#sd_style').on('change', onStyleSelect);
|
||||||
$('#sd_save_style').on('click', onSaveStyleClick);
|
$('#sd_save_style').on('click', onSaveStyleClick);
|
||||||
|
$('#sd_delete_style').on('click', onDeleteStyleClick);
|
||||||
$('#sd_character_prompt_block').hide();
|
$('#sd_character_prompt_block').hide();
|
||||||
$('#sd_interactive_mode').on('input', onInteractiveModeInput);
|
$('#sd_interactive_mode').on('input', onInteractiveModeInput);
|
||||||
$('#sd_openai_style').on('change', onOpenAiStyleSelect);
|
$('#sd_openai_style').on('change', onOpenAiStyleSelect);
|
||||||
|
Reference in New Issue
Block a user