Move persona buttons to right panel - Move all buttons from the persona list to the right panel, to the already existing ones - Common CSS class/style for '.buttons_block' - Common CSS style for a red button - Refactored a few persona buttons' functionalities
| @@ -4957,14 +4957,16 @@ | ||
| 4957 | 4957 | <div class="persona_management_current_persona"> |
| 4958 | 4958 | <h4 class="standoutHeader" data-i18n="Current Persona">Current Persona</h4> |
| 4959 | 4959 | |
| 4960 | - <h4 data-i18n="Name">Name</h4> | |
| 4960 | + <div id="persona_controls" class="flex-container"> | |
| 4961 | - <div class="change_name"> | |
| 4961 | + <h5 id="your_name" class="persona_name">[Persona Name]</h5> | |
| 4962 | - <input id="your_name" name="your_name" data-i18n="[placeholder]Enter your name" placeholder="Enter your name" class="text_pole wide100p" value="" autocomplete="off"> | |
| 4962 | + <div class="persona_controls_buttons_block buttons_block"> | |
| 4963 | 4963 | <div id="your_name_buttonpersona_rename_button" class="menu_button fa-solid fa-checkpencil" title="ClickRename toPersona set/ aBind newName UserTo NameAvatar" data-i18n="[title]ClickRename toPersona set/ aBind newName UserTo NameAvatar"></div> |
| 4964 | - </div> | |
| 4964 | + <div id="sync_name_button" class="menu_button fa-solid fa-sync" title="Click to set user name for all messages" data-i18n="[title]Click to set user name for all messages"></div> | |
| 4965 | 4965 | <div id="sync_name_buttonpersona_lore_button" class="menu_button fa-solid fa-syncglobe" title="Persona Lore Alt+Click to set user name foropen allthe messageslorebook" data-i18n="[title]Click toPersona setLore userAlt+Click nameto foropen allthe messageslorebook"></div> |
| 4966 | - </div> | |
| 4966 | + | |
| 4967 | 4967 | <div id="persona_lore_buttonpersona_set_image_button" class="menu_button fa-solid fa-globeimage" title="Persona Lore Alt+Click to openChange thePersona lorebookImage" data-i18n="[title]Persona Lore Alt+Click to openChange thePersona lorebookImage"></div> |
| 4968 | + <div id="persona_duplicate_button" class="menu_button fa-solid fa-clone" title="Duplicate Persona" data-i18n="[title]Duplicate Persona"></div> | |
| 4969 | + <div id="persona_delete_button" class="menu_button fa-solid fa-skull red_button" title="Delete Persona" data-i18n="[title]Delete Persona"></div> | |
| 4968 | 4970 | </div> |
| 4969 | 4971 | </div> |
| 4970 | 4972 | |
| @@ -5109,13 +5111,13 @@ | ||
| 5109 | 5111 | </div> |
| 5110 | 5112 | </div> |
| 5111 | 5113 | <div class="flex-container flexFlowColumn expander flexNoGap"> |
| 5112 | 5114 | <div id="avatar_div" class="avatar_div buttons_block alignitemsflexstart justifySpaceBetween flexnowrap"> |
| 5113 | 5115 | <label id="avatar_div_div" class="add_avatar avatar" for="add_avatar_button" title="Click to select a new avatar for this character" data-i18n="[title]Click to select a new avatar for this character"> |
| 5114 | 5116 | <img id="avatar_load_preview" src="img/ai4.png" alt="avatar"> |
| 5115 | 5117 | <input hidden type="file" id="add_avatar_button" name="avatar" accept="image/*"> |
| 5116 | 5118 | </label> |
| 5117 | 5119 | <div class="flex-container" id="avatar_controls"> |
| 5118 | 5120 | <div class="form_create_bottom_buttons_block buttons_block"> |
| 5119 | 5121 | <div id="rm_button_back" class="menu_button fa-solid fa-left-long "></div> |
| 5120 | 5122 | <!-- <div id="renameCharButton" class="menu_button fa-solid fa-user-pen" title="Rename Character"></div> --> |
| 5121 | 5123 | <div id="favorite_button" class="menu_button fa-solid fa-star" title="Add to Favorites" data-i18n="[title]Add to Favorites"></div> |
| @@ -5131,7 +5133,7 @@ | ||
| 5131 | 5133 | <label for="create_button" id="create_button_label" class="menu_button fa-solid fa-user-check" title="Create Character" data-i18n="[title]Create Character"> |
| 5132 | 5134 | <input type="submit" id="create_button" name="create_button"> |
| 5133 | 5135 | </label> |
| 5134 | 5136 | <div id="delete_button" class="menu_button fa-solid fa-skull red_button" title="Delete Character" data-i18n="[title]Delete Character"></div> |
| 5135 | 5137 | </div> |
| 5136 | 5138 | <label class="flex1 height100p" for="char-management-dropdown"> |
| 5137 | 5139 | <select id="char-management-dropdown" class="text_pole"> |
| @@ -5469,23 +5471,23 @@ | ||
| 5469 | 5471 | <div class="wide100p character_name_block"> |
| 5470 | 5472 | <span class="ch_name flex1"></span> |
| 5471 | 5473 | <div class="avatar-buttons"> |
| 5472 | 5474 | <!-- <button class="menu_button bind_user_name" title="Bind user name to that avatar" data-i18n="[title]Bind user name to that avatar"> |
| 5473 | 5475 | <i class="fa-fw fa-solid fa-user-edit fa-sm"></i> |
| 5474 | 5476 | </button> |
| 5475 | 5477 | <button class="menu_button set_persona_image" title="Change persona image" data-i18n="[title]Change persona image"> |
| 5476 | 5478 | <i class="fa-fw fa-solid fa-image fa-sm"></i> |
| 5477 | 5479 | </button> |
| 5478 | - <!-- | |
| 5480 | + | |
| 5479 | 5481 | <button class="menu_button set_default_persona" title="Select this as default persona for the new chats." data-i18n="[title]Select this as default persona for the new chats."> |
| 5480 | 5482 | <i class="fa-fw fa-solid fa-crown fa-sm"></i> |
| 5481 | 5483 | </button> |
| 5482 | - --> | |
| 5484 | + | |
| 5483 | 5485 | <button class="menu_button duplicate_persona" title="Duplicate persona" data-i18n="[title]Duplicate persona"> |
| 5484 | 5486 | <i class="fa-fw fa-solid fa-clone fa-sm"></i> |
| 5485 | 5487 | </button> |
| 5486 | 5488 | <button class="menu_button delete_avatar" title="Delete persona" data-i18n="[title]Delete persona"> |
| 5487 | 5489 | <i class="fa-fw fa-solid fa-trash-alt fa-sm"></i> |
| 5488 | 5490 | </button> --> |
| 5489 | 5491 | </div> |
| 5490 | 5492 | </div> |
| 5491 | 5493 | <div class="ch_description"></div> |
| @@ -6810,7 +6810,7 @@ export function setUserName(value, { toastPersonaNameChange = true } = {}) { | ||
| 6810 | 6810 | if (name1 === undefined || name1 == '') |
| 6811 | 6811 | name1 = default_user_name; |
| 6812 | 6812 | console.log(`User name changed to ${name1}`); |
| 6813 | 6813 | $('#your_name').valtext(name1); |
| 6814 | 6814 | if (toastPersonaNameChange && power_user.persona_show_notifications) { |
| 6815 | 6815 | toastr.success(t`Your messages will now be sent as ${name1}`, t`Persona Changed`); |
| 6816 | 6816 | } |
| @@ -6864,7 +6864,7 @@ export async function getSettings() { | ||
| 6864 | 6864 | settings = JSON.parse(data.settings); |
| 6865 | 6865 | if (settings.username !== undefined && settings.username !== '') { |
| 6866 | 6866 | name1 = settings.username; |
| 6867 | 6867 | $('#your_name').valtext(name1); |
| 6868 | 6868 | } |
| 6869 | 6869 | |
| 6870 | 6870 | await setUserControls(data.enable_accounts); |
| @@ -466,6 +466,8 @@ const countPersonaDescriptionTokens = debounce(async () => { | ||
| 466 | 466 | }, debounce_timeout.relaxed); |
| 467 | 467 | |
| 468 | 468 | export function setPersonaDescription() { |
| 469 | + $('#your_name').text(name1); | |
| 470 | + | |
| 469 | 471 | if (power_user.persona_description_position === persona_description_positions.AFTER_CHAR) { |
| 470 | 472 | power_user.persona_description_position = persona_description_positions.IN_PROMPT; |
| 471 | 473 | } |
| @@ -674,9 +676,8 @@ async function updatePersonaNameIfExists(avatarId, newName) { | ||
| 674 | 676 | saveSettingsDebounced(); |
| 675 | 677 | } |
| 676 | 678 | |
| 677 | 679 | async function bindUserNameToPersona(e) { |
| 678 | - e?.stopPropagation(); | |
| 680 | + const avatarId = user_avatar; | |
| 679 | - const avatarId = $(this).closest('.avatar-container').find('.avatar').attr('imgfile'); | |
| 680 | 681 | |
| 681 | 682 | if (!avatarId) { |
| 682 | 683 | console.warn('No avatar id found'); |
| @@ -719,6 +720,7 @@ async function bindUserNameToPersona(e) { | ||
| 719 | 720 | if (isCurrentPersona) { |
| 720 | 721 | console.log(`Auto-updating user name to ${personaName}`); |
| 721 | 722 | setUserName(personaName); |
| 723 | + await updatePersonaNameIfExists(user_avatar, personaName); | |
| 722 | 724 | } |
| 723 | 725 | } else { |
| 724 | 726 | // If the user clicked ok, but didn't enter a name, delete the persona |
| @@ -730,6 +732,8 @@ async function bindUserNameToPersona(e) { | ||
| 730 | 732 | saveSettingsDebounced(); |
| 731 | 733 | await getUserAvatars(true, avatarId); |
| 732 | 734 | setPersonaDescription(); |
| 735 | + | |
| 736 | + retriggerFirstMessageOnEmptyChat(); | |
| 733 | 737 | } |
| 734 | 738 | |
| 735 | 739 | function selectCurrentPersona({ toastPersonaNameChange = true } = {}) { |
| @@ -969,22 +973,15 @@ async function lockPersona(type = 'chat') { | ||
| 969 | 973 | } |
| 970 | 974 | |
| 971 | 975 | |
| 972 | 976 | async function deleteUserAvatar(e) { |
| 973 | - e?.stopPropagation(); | |
| 977 | + const avatarId = user_avatar; | |
| 974 | - const avatarId = $(this).closest('.avatar-container').find('.avatar').attr('imgfile'); | |
| 975 | 978 | |
| 976 | 979 | if (!avatarId) { |
| 977 | 980 | console.warn('No avatar id found'); |
| 978 | 981 | return; |
| 979 | 982 | } |
| 980 | - | |
| 983 | + const confirm = await Popup.show.confirm(t`Delete Persona`, | |
| 981 | - if (avatarId == user_avatar) { | |
| 984 | + t`Are you sure you want to delete this avatar?` + '<br />' + t`All information associated with its linked persona will be lost.`); | |
| 982 | - console.warn(`User tried to delete their current avatar ${avatarId}`); | |
| 983 | - toastr.warning(t`You cannot delete the avatar you are currently using`, t`Persona Warning`); | |
| 984 | - return; | |
| 985 | - } | |
| 986 | - | |
| 987 | - const confirm = await Popup.show.confirm(t`Are you sure you want to delete this avatar?`, t`All information associated with its linked persona will be lost.`); | |
| 988 | 985 | |
| 989 | 986 | if (!confirm) { |
| 990 | 987 | console.debug('User cancelled deleting avatar'); |
| @@ -1016,8 +1013,9 @@ async function deleteUserAvatar(e) { | ||
| 1016 | 1013 | } |
| 1017 | 1014 | |
| 1018 | 1015 | saveSettingsDebounced(); |
| 1019 | - await getUserAvatars(); | |
| 1016 | + | |
| 1020 | - updatePersonaLockIcons(); | |
| 1017 | + // Use the existing mechanism to re-render the persona list and choose the next persona here | |
| 1018 | + await loadPersonaForCurrentChat({ doRender: true }); | |
| 1021 | 1019 | } |
| 1022 | 1020 | } |
| 1023 | 1021 | |
| @@ -1237,9 +1235,9 @@ function updatePersonaLockIcons() { | ||
| 1237 | 1235 | $('#lock_persona_to_char i.icon').toggleClass('fa-unlock', !hasCharLock); |
| 1238 | 1236 | } |
| 1239 | 1237 | |
| 1240 | 1238 | async function loadPersonaForCurrentChat({ doRender = false } = {}) { |
| 1241 | 1239 | // Cache persona list to check if they exist |
| 1242 | 1240 | const userAvatars = await getUserAvatars(falsedoRender); |
| 1243 | 1241 | |
| 1244 | 1242 | // Define a persona for this chat |
| 1245 | 1243 | let chatPersona = ''; |
| @@ -1500,9 +1498,8 @@ async function duplicatePersona(avatarId) { | ||
| 1500 | 1498 | } |
| 1501 | 1499 | |
| 1502 | 1500 | export function initPersonas() { |
| 1503 | - $(document).on('click', '.bind_user_name', bindUserNameToPersona); | |
| 1504 | 1501 | $(document).on('click', '.set_default_persona', toggleDefaultPersonaClicked); |
| 1505 | 1502 | $(document'#persona_delete_button').on('click', '.delete_avatar', deleteUserAvatar); |
| 1506 | 1503 | $('#lock_persona_default').on('click', () => togglePersonaLock('default')); |
| 1507 | 1504 | $('#lock_user_name').on('click', () => togglePersonaLock('chat')); |
| 1508 | 1505 | $('#lock_persona_to_char').on('click', () => togglePersonaLock('character')); |
| @@ -1548,11 +1545,13 @@ export function initPersonas() { | ||
| 1548 | 1545 | retriggerFirstMessageOnEmptyChat(); |
| 1549 | 1546 | }); |
| 1550 | 1547 | |
| 1551 | 1548 | $('#your_name_buttonpersona_rename_button').click(async function () { |
| 1552 | 1549 | const userName = String($('#your_name').val()).trim(); |
| 1553 | 1550 | setUserName(userName); |
| 1554 | 1551 | await updatePersonaNameIfExists(user_avatar, userName); |
| 1555 | 1552 | retriggerFirstMessageOnEmptyChat(); |
| 1553 | + // TODO: Do both binding and/or rename? | |
| 1554 | + //bindUserNameToPersona(); | |
| 1556 | 1555 | }); |
| 1557 | 1556 | |
| 1558 | 1557 | $(document).on('click', '#user_avatar_block .avatar_upload', function () { |
| @@ -1560,28 +1559,15 @@ export function initPersonas() { | ||
| 1560 | 1559 | $('#avatar_upload_file').trigger('click'); |
| 1561 | 1560 | }); |
| 1562 | 1561 | |
| 1563 | 1562 | $(document'#persona_duplicate_button').on('click', '#user_avatar_block .duplicate_persona',() function=> duplicatePersona(euser_avatar) {); |
| 1564 | - e.stopPropagation(); | |
| 1565 | - const avatarId = $(this).closest('.avatar-container').find('.avatar').attr('imgfile'); | |
| 1566 | - | |
| 1567 | - if (!avatarId) { | |
| 1568 | - console.log('no imgfile'); | |
| 1569 | - return; | |
| 1570 | - } | |
| 1571 | - | |
| 1572 | - duplicatePersona(avatarId); | |
| 1573 | - }); | |
| 1574 | - | |
| 1575 | - $(document).on('click', '#user_avatar_block .set_persona_image', function (e) { | |
| 1576 | - e.stopPropagation(); | |
| 1577 | - const avatarId = $(this).closest('.avatar-container').find('.avatar').attr('imgfile'); | |
| 1578 | 1563 | |
| 1579 | - if (!avatarId) { | |
| 1564 | + $('#persona_set_image_button').on('click', function () { | |
| 1565 | + if (!user_avatar) { | |
| 1580 | 1566 | console.log('no imgfile'); |
| 1581 | 1567 | return; |
| 1582 | 1568 | } |
| 1583 | 1569 | |
| 1584 | 1570 | $('#avatar_upload_overwrite').val(avatarIduser_avatar); |
| 1585 | 1571 | $('#avatar_upload_file').trigger('click'); |
| 1586 | 1572 | }); |
| 1587 | 1573 | |
| @@ -2919,6 +2919,16 @@ select option:not(:checked) { | ||
| 2919 | 2919 | filter: grayscale(0.5); |
| 2920 | 2920 | } |
| 2921 | 2921 | |
| 2922 | +#persona_controls .persona_name { | |
| 2923 | + text-overflow: ellipsis; | |
| 2924 | + overflow: hidden; | |
| 2925 | + text-align: left; | |
| 2926 | + white-space: nowrap; | |
| 2927 | + margin-right: 10px; | |
| 2928 | + font-size: calc(var(--mainFontSize) * 1.25); | |
| 2929 | + color: var(--grey50); | |
| 2930 | +} | |
| 2931 | + | |
| 2922 | 2932 | input[type=search]::-webkit-search-cancel-button { |
| 2923 | 2933 | -webkit-appearance: none; |
| 2924 | 2934 | height: 1em; |
| @@ -3395,12 +3405,7 @@ grammarly-extension { | ||
| 3395 | 3405 | cursor: pointer; |
| 3396 | 3406 | } |
| 3397 | 3407 | |
| 3398 | 3408 | #rm_characters_block .form_create_bottom_buttons_blockbuttons_block { |
| 3399 | - justify-content: space-evenly !important; | |
| 3400 | - flex-grow: 0; | |
| 3401 | -} | |
| 3402 | - | |
| 3403 | -.form_create_bottom_buttons_block { | |
| 3404 | 3409 | display: flex; |
| 3405 | 3410 | flex: 1; |
| 3406 | 3411 | gap: 5px; |
| @@ -3409,18 +3414,21 @@ grammarly-extension { | ||
| 3409 | 3414 | flex-wrap: wrap; |
| 3410 | 3415 | } |
| 3411 | 3416 | |
| 3412 | 3417 | .form_create_bottom_buttons_blockbuttons_block .menu_button { |
| 3413 | 3418 | display: flex; |
| 3414 | 3419 | justify-content: center; |
| 3415 | 3420 | align-items: center; |
| 3421 | + padding: 5px; | |
| 3422 | + margin: 0; | |
| 3423 | + filter: grayscale(0.5); | |
| 3416 | 3424 | } |
| 3417 | 3425 | |
| 3418 | -#delete_button, | |
| 3426 | +.red_button, | |
| 3419 | 3427 | .redWarningBG { |
| 3420 | 3428 | background-color: var(--crimson70a) !important; |
| 3421 | 3429 | } |
| 3422 | 3430 | |
| 3423 | 3431 | #delete_button.red_button:hover, |
| 3424 | 3432 | .redWarningBG:hover { |
| 3425 | 3433 | background-color: var(--fullred) !important; |
| 3426 | 3434 | } |
| @@ -3614,13 +3622,6 @@ grammarly-extension { | ||
| 3614 | 3622 | min-width: calc(1.25em + 12px); |
| 3615 | 3623 | } |
| 3616 | 3624 | |
| 3617 | -.avatar_div .menu_button, | |
| 3618 | -.form_create_bottom_buttons_block .menu_button { | |
| 3619 | - padding: 5px; | |
| 3620 | - margin: 0; | |
| 3621 | - filter: grayscale(0.5); | |
| 3622 | -} | |
| 3623 | - | |
| 3624 | 3625 | .menu_button:hover, |
| 3625 | 3626 | .menu_button.active { |
| 3626 | 3627 | background-color: var(--white30a); |