Alt+Click to open lorebook
| @@ -4813,7 +4813,7 @@ | ||
| 4813 | 4813 | </div> |
| 4814 | 4814 | <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"> |
| 4815 | 4815 | </div> |
| 4816 | 4816 | <div id="persona_lore_button" class="menu_button fa-solid fa-globe" title="Persona Lore Alt+Click to open the lorebook" data-i18n="[title]Persona Lore Alt+Click to open the lorebook"> |
| 4817 | 4817 | </div> |
| 4818 | 4818 | </div> |
| 4819 | 4819 | <div> |
| @@ -4931,7 +4931,7 @@ | ||
| 4931 | 4931 | <input type="hidden" id="fav_checkbox" name="fav" /> |
| 4932 | 4932 | <div id="advanced_div" class="menu_button fa-solid fa-book " title="Advanced Definitions" data-i18n="[title]Advanced Definition"></div> |
| 4933 | 4933 | <div id="world_button" class="menu_button fa-solid fa-globe" title="Character Lore Click to load Shift-click to open 'Link to World Info' popup" data-i18n="[title]world_button_title"></div> |
| 4934 | 4934 | <div class="chat_lorebook_button menu_button fa-solid fa-passport" title="Chat Lore Alt+Click to open the lorebook" data-i18n="[title]Chat Lore Alt+Click to open the lorebook"></div> |
| 4935 | 4935 | <div id="export_button" class="menu_button fa-solid fa-file-export " title="Export and Download" data-i18n="[title]Export and Download"></div> |
| 4936 | 4936 | <!-- <div id="set_chat_scenario" class="menu_button fa-solid fa-scroll" title="Set a chat scenario override"></div> --> |
| 4937 | 4937 | <!-- <div id="set_character_world" class="menu_button fa-solid fa-globe" title="Set a character World Info / Lorebook"></div> --> |
| @@ -23,7 +23,7 @@ import { FILTER_TYPES, FilterHelper } from './filters.js'; | ||
| 23 | 23 | import { selected_group } from './group-chats.js'; |
| 24 | 24 | import { POPUP_RESULT, POPUP_TYPE, Popup, callGenericPopup } from './popup.js'; |
| 25 | 25 | import { t } from './i18n.js'; |
| 26 | 26 | import { openWorldInfoEditor, world_names } from './world-info.js'; |
| 27 | 27 | import { renderTemplateAsync } from './templates.js'; |
| 28 | 28 | |
| 29 | 29 | let savePersonasPage = 0; |
| @@ -783,7 +783,11 @@ function onPersonaDescriptionDepthRoleInput() { | ||
| 783 | 783 | saveSettingsDebounced(); |
| 784 | 784 | } |
| 785 | 785 | |
| 786 | -async function onPersonaLoreButtonClick() { | |
| 786 | +/** | |
| 787 | + * Opens a popup to set the lorebook for the current persona. | |
| 788 | + * @param {PointerEvent} event Click event | |
| 789 | + */ | |
| 790 | +async function onPersonaLoreButtonClick(event) { | |
| 787 | 791 | const personaName = power_user.personas[user_avatar]; |
| 788 | 792 | const selectedLorebook = power_user.persona_description_lorebook; |
| 789 | 793 | |
| @@ -792,6 +796,11 @@ async function onPersonaLoreButtonClick() { | ||
| 792 | 796 | return; |
| 793 | 797 | } |
| 794 | 798 | |
| 799 | + if (event.altKey && selectedLorebook) { | |
| 800 | + openWorldInfoEditor(selectedLorebook); | |
| 801 | + return; | |
| 802 | + } | |
| 803 | + | |
| 795 | 804 | const template = $(await renderTemplateAsync('personaLorebook')); |
| 796 | 805 | |
| 797 | 806 | const worldSelect = template.find('select'); |
| @@ -4855,8 +4855,32 @@ export async function importWorldInfo(file) { | ||
| 4855 | 4855 | }); |
| 4856 | 4856 | } |
| 4857 | 4857 | |
| 4858 | -export async function assignLorebookToChat() { | |
| 4858 | +/** | |
| 4859 | + * Forces the world info editor to open on a specific world. | |
| 4860 | + * @param {string} worldName The name of the world to open | |
| 4861 | + */ | |
| 4862 | +export function openWorldInfoEditor(worldName) { | |
| 4863 | + console.log(`Opening lorebook for ${worldName}`); | |
| 4864 | + if (!$('#WorldInfo').is(':visible')) { | |
| 4865 | + $('#WIDrawerIcon').trigger('click'); | |
| 4866 | + } | |
| 4867 | + const index = world_names.indexOf(worldName); | |
| 4868 | + $('#world_editor_select').val(index).trigger('change'); | |
| 4869 | +} | |
| 4870 | + | |
| 4871 | +/** | |
| 4872 | + * Assigns a lorebook to the current chat. | |
| 4873 | + * @param {PointerEvent} event Pointer event | |
| 4874 | + * @returns {Promise<void>} | |
| 4875 | + */ | |
| 4876 | +export async function assignLorebookToChat(event) { | |
| 4859 | 4877 | const selectedName = chat_metadata[METADATA_KEY]; |
| 4878 | + | |
| 4879 | + if (selectedName && event.altKey) { | |
| 4880 | + openWorldInfoEditor(selectedName); | |
| 4881 | + return; | |
| 4882 | + } | |
| 4883 | + | |
| 4860 | 4884 | const template = $(await renderTemplateAsync('chatLorebook')); |
| 4861 | 4885 | |
| 4862 | 4886 | const worldSelect = template.find('select'); |
| @@ -5036,11 +5060,7 @@ jQuery(() => { | ||
| 5036 | 5060 | const worldName = characters[chid]?.data?.extensions?.world; |
| 5037 | 5061 | const hasEmbed = checkEmbeddedWorld(chid); |
| 5038 | 5062 | if (worldName && world_names.includes(worldName) && !event.shiftKey) { |
| 5039 | - if (!$('#WorldInfo').is(':visible')) { | |
| 5063 | + openWorldInfoEditor(worldName); | |
| 5040 | - $('#WIDrawerIcon').trigger('click'); | |
| 5041 | - } | |
| 5042 | - const index = world_names.indexOf(worldName); | |
| 5043 | - $('#world_editor_select').val(index).trigger('change'); | |
| 5044 | 5064 | } else if (hasEmbed && !event.shiftKey) { |
| 5045 | 5065 | await importEmbeddedWorldInfo(); |
| 5046 | 5066 | saveCharacterDebounced(); |