mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2024-12-11 17:07:07 +01:00
Add option for inline character card replacements
This commit is contained in:
parent
7acd2916ec
commit
24b33a5f77
@ -4001,6 +4001,9 @@
|
||||
<option id="character_source" data-i18n="Link to Source">
|
||||
Link to Source
|
||||
</option>
|
||||
<option id="replace_update" data-i18n="Replace / Update">
|
||||
Replace / Update
|
||||
</option>
|
||||
<!--<option id="dupe_button">
|
||||
Duplicate
|
||||
</option>
|
||||
@ -4200,6 +4203,7 @@
|
||||
<input multiple type="file" id="character_import_file" accept=".json, image/png, .yaml, .yml" name="avatar">
|
||||
<input id="character_import_file_type" name="file_type" class="text_pole" maxlength="999" size="2" value="" autocomplete="off">
|
||||
</form>
|
||||
<input type="file" id="character_replace_file" accept="image/png" name="replace_avatar" hidden>
|
||||
</div>
|
||||
<div name="Character List Panel" id="rm_characters_block" class="right_menu">
|
||||
<div id="charListFixedTop">
|
||||
|
@ -9837,7 +9837,28 @@ jQuery(async function () {
|
||||
toastr.info('This character doesn\'t seem to have a source.');
|
||||
}
|
||||
} break;
|
||||
case 'replace_update': {
|
||||
const confirm = await callPopup('<p><b>Choose a new character card to replace this character with.</b></p><p>All chats, assets and group memberships will be preserved, but local changes to the character data will be lost.</p><p>Proceed?</p>', 'confirm', '');
|
||||
if (confirm) {
|
||||
async function uploadReplacementCard(e) {
|
||||
const file = e.target.files[0];
|
||||
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const cloneFile = new File([file], characters[this_chid].avatar, { type: file.type });
|
||||
const chatFile = characters[this_chid]['chat'];
|
||||
await processDroppedFiles([cloneFile], true);
|
||||
await openCharacterChat(chatFile);
|
||||
} catch {
|
||||
toastr.error('Failed to replace the character card.', 'Something went wrong');
|
||||
}
|
||||
}
|
||||
$('#character_replace_file').off('change').on('change', uploadReplacementCard).trigger('click');
|
||||
}
|
||||
} break;
|
||||
/*case 'delete_button':
|
||||
popup_type = "del_ch";
|
||||
callPopup(`
|
||||
|
Loading…
Reference in New Issue
Block a user