Chat lorebook click unify (#5246)
* Unify chat lorebook button click behavior with character lorebook button * Update locale strings for chat lorebook button * Unify chat lorebook button click behavior with character lorebook button * Update locale strings for chat lorebook button * Also unify character lorebook button to support Alt modifier * Update locale strings for character lorebook button * Update public/locales/fr-fr.json Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Add long-press support for lorebook buttons on mobile * Update locale strings for lorebook button long-press * Fix long-press to use event delegation for dynamic elements --------- Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
+16
-4
@@ -5832,12 +5832,18 @@
|
||||
<div class="persona_controls_buttons_block buttons_block">
|
||||
<div id="persona_rename_button" class="menu_button fa-solid fa-pencil" title="Rename Persona" data-i18n="[title]Rename Persona"></div>
|
||||
<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>
|
||||
<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"></div>
|
||||
<div id="persona_lore_button" class="menu_button fa-solid fa-globe" title="Persona Lore Click to load Shift/Alt-click or long-press to open 'Link to Persona Lorebook' popup" data-i18n="[title]persona_lore_button_title"></div>
|
||||
|
||||
<div id="persona_set_image_button" class="menu_button fa-solid fa-image" title="Change Persona Image" data-i18n="[title]Change Persona Image"></div>
|
||||
<div id="persona_duplicate_button" class="menu_button fa-solid fa-clone" title="Duplicate Persona" data-i18n="[title]Duplicate Persona"></div>
|
||||
<div id="persona_delete_button" class="menu_button fa-solid fa-skull red_button" title="Delete Persona" data-i18n="[title]Delete Persona"></div>
|
||||
</div>
|
||||
<label class="flex1 height100p" for="persona-management-dropdown">
|
||||
<select id="persona-management-dropdown" class="text_pole">
|
||||
<option value="default" disabled selected data-i18n="More...">More...</option>
|
||||
<option id="persona_lorebook_link" data-i18n="Link to Persona Lorebook">Link to Persona Lorebook</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<h4 class="flex-container alignItemsBaseline">
|
||||
@@ -6003,8 +6009,8 @@
|
||||
<div id="favorite_button" class="menu_button fa-solid fa-star" title="Add to Favorites" data-i18n="[title]Add to Favorites"></div>
|
||||
<input type="hidden" id="fav_checkbox" name="fav" />
|
||||
<div id="advanced_div" class="menu_button fa-solid fa-book " title="Advanced Definitions" data-i18n="[title]Advanced Definition"></div>
|
||||
<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>
|
||||
<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>
|
||||
<div id="world_button" class="menu_button fa-solid fa-globe" title="Character Lore Click to load Shift/Alt-click or long-press to open 'Link to World Info' popup" data-i18n="[title]world_button_title"></div>
|
||||
<div class="chat_lorebook_button menu_button fa-solid fa-passport" title="Chat Lore Click to load Shift/Alt-click or long-press to open 'Link to Chat Lorebook' popup" data-i18n="[title]chat_lorebook_button_title"></div>
|
||||
<div id="char_connections_button" class="menu_button fa-solid fa-face-smile" title="Connected Personas" data-i18n="[title]Connected Personas"></div>
|
||||
<div id="export_button" class="menu_button fa-solid fa-file-export " title="Export and Download" data-i18n="[title]Export and Download"></div>
|
||||
<!-- <div id="set_chat_character_settings" class="menu_button fa-solid fa-scroll" title="Set a chat scenario override"></div> -->
|
||||
@@ -6155,8 +6161,14 @@
|
||||
<div id="group-metadata-controls" class="marginTopBot5">
|
||||
<div class="flex-container wide100p">
|
||||
<input id="rm_group_chat_name" class="text_pole flex1" type="text" name="chat_name" data-i18n="[placeholder]Chat Name (Optional)" placeholder="Chat Name (Optional)" />
|
||||
<div class="chat_lorebook_button menu_button fa-solid fa-passport" title="Chat Lore" data-i18n="[title]Chat Lore"></div>
|
||||
<div class="chat_lorebook_button menu_button fa-solid fa-passport" title="Chat Lore Click to load Shift/Alt-click or long-press to open 'Link to Chat Lorebook' popup" data-i18n="[title]chat_lorebook_button_title"></div>
|
||||
</div>
|
||||
<label class="flex1 height100p" for="group-chat-lorebook-dropdown">
|
||||
<select id="group-chat-lorebook-dropdown" class="text_pole">
|
||||
<option value="default" disabled selected data-i18n="More...">More...</option>
|
||||
<option id="group_chat_lorebook_link" data-i18n="Link to Chat Lorebook">Link to Chat Lorebook</option>
|
||||
</select>
|
||||
</label>
|
||||
<div id="group_tags_div" class="wide100p">
|
||||
<div class="tag_controls">
|
||||
<input id="groupTagInput" class="text_pole textarea_compact tag_input flex1 margin0" data-i18n="[placeholder]Search / Create Tags" placeholder="Search / Create tags" />
|
||||
|
||||
@@ -1518,10 +1518,10 @@
|
||||
"Contain": "Contenir",
|
||||
"Stretch": "Étirer",
|
||||
"Center": "Centrer",
|
||||
"Persona Lore Alt+Click to open the lorebook": "Lore de persona\nAlt+Click pour ouvrir le lorebook",
|
||||
"persona_lore_button_title": "Lore de persona\n\nCliquer pour charger\nMajuscule/Alt-clic ou appui long pour ouvrir la fenêtre contextuelle « Lien vers le Lorebook de persona ».",
|
||||
"None (disabled)": "Aucun (désactivé)",
|
||||
"world_button_title": "Lore de personnage\n\nCliquer pour charger\nMajuscule-clic pour ouvrir la fenêtre contextuelle « Lien vers le Wold Info ».",
|
||||
"Chat Lore Alt+Click to open the lorebook": "Lore du chat\nAlt+Click pour ouvrir le lorebook",
|
||||
"world_button_title": "Lore de personnage\n\nCliquer pour charger\nMajuscule/Alt-clic ou appui long pour ouvrir la fenêtre contextuelle « Lien vers le World Info ».",
|
||||
"chat_lorebook_button_title": "Lore du chat\n\nCliquer pour charger\nMajuscule/Alt-clic ou appui long pour ouvrir la fenêtre contextuelle « Lien vers le Lorebook du chat ».",
|
||||
"Manual": "Manuel",
|
||||
"Duplicate persona": "Dupliquer la persona",
|
||||
"popup-button-crop": "Recadrer",
|
||||
|
||||
@@ -1535,7 +1535,7 @@
|
||||
"Only apply color as accent": "색상은 오직 강조로써만 적용됩니다",
|
||||
"qr--colorClear": "색상 지우기",
|
||||
"Color": "색상",
|
||||
"world_button_title": "캐릭터 로어. 클릭하여 로드하세요. Shift를 클릭하면 '월드 인포 링크' 팝업이 열립니다.",
|
||||
"world_button_title": "캐릭터 로어. 클릭하여 로드하세요. Shift/Alt+클릭 또는 길게 누르면 '월드 인포 링크' 팝업이 열립니다.",
|
||||
"Select TTS Provider": "TTS 공급자 선택",
|
||||
"tts_enabled": "활성화",
|
||||
"Narrate user messages": "사용자 메시지 나레이션",
|
||||
|
||||
@@ -1904,7 +1904,7 @@
|
||||
"Save": "Сохранить",
|
||||
"Chat Lorebook": "Лорбук для чата",
|
||||
"chat_world_template_txt": "Выбранный мир будет привязан к этому чату. Будет работать наряду с глобальным лорбуком и лором персонажа.",
|
||||
"world_button_title": "Лор персонажа\n\nНажмите, чтобы загрузить\nShift + ЛКМ, чтобы открыть диалог привязки мира",
|
||||
"world_button_title": "Лор персонажа\n\nНажмите, чтобы загрузить\nShift / Alt + ЛКМ или долгое нажатие, чтобы открыть диалог привязки мира",
|
||||
"No auxillary Lorebooks set. Click here to select.": "Вспомогательный лорбук не выбран. Нажмите, чтобы выбрать.",
|
||||
"ext_regex_user_input_desc": "Отправленные вами сообщения.",
|
||||
"ext_regex_ai_input_desc": "Полученные от API ответы.",
|
||||
@@ -2130,7 +2130,7 @@
|
||||
"openai_reasoning_effort_low": "Поверхностные",
|
||||
"openai_reasoning_effort_medium": "Обычные",
|
||||
"openai_reasoning_effort_high": "Подробные",
|
||||
"Persona Lore Alt+Click to open the lorebook": "Лорбук данной персоны\nAlt + ЛКМ чтобы открыть лорбук",
|
||||
"persona_lore_button_title": "Лорбук данной персоны\n\nНажмите, чтобы открыть\nShift / Alt + ЛКМ или долгое нажатие, чтобы открыть диалог привязки лорбука",
|
||||
"Persona Lorebook for": "Лорбук для персоны",
|
||||
"persona_world_template_txt": "Выбранный мир будет привязан к этой персоне. Будет работать вместе с глобальным лорбуком и лорбуками персонажа и чата.",
|
||||
"Global list": "Глобальный список",
|
||||
@@ -2145,7 +2145,7 @@
|
||||
"Enter a valid API URL": "Введите корректный адрес API",
|
||||
"No Ollama model selected.": "Не выбрана модель Ollama",
|
||||
"Background Fitting": "Способ подгонки фона под разрешение",
|
||||
"Chat Lore Alt+Click to open the lorebook": "Лорбук данного чата\nAlt + ЛКМ чтобы открыть лорбук",
|
||||
"chat_lorebook_button_title": "Лорбук данного чата\n\nНажмите, чтобы открыть\nShift / Alt + ЛКМ или долгое нажатие, чтобы открыть диалог привязки лорбука",
|
||||
"Token Counter": "Подсчитать токены",
|
||||
"Type / paste in the box below to see the number of tokens in the text.": "Введите или вставьте текст в окошко ниже, чтобы подсчитать количество токенов в нём.",
|
||||
"Selected tokenizer:": "Выбранный токенайзер:",
|
||||
|
||||
@@ -1053,7 +1053,7 @@
|
||||
"Current Persona": "当前人设",
|
||||
"Rename Persona": "重命名人设",
|
||||
"Click to set user name for all messages": "点击为所有消息设置用户名",
|
||||
"Persona Lore Alt+Click to open the lorebook": "人设世界书\nAlt+单击 打开世界书",
|
||||
"persona_lore_button_title": "人设世界书\n\n单击加载\nShift/Alt+单击或长按打开“链接到人设世界书”弹出窗口",
|
||||
"Change Persona Image": "更改人设图",
|
||||
"Duplicate Persona": "复制人设",
|
||||
"Delete Persona": "删除人设",
|
||||
@@ -1093,8 +1093,8 @@
|
||||
"Click to select a new avatar for this character": "单击以为此角色选择新的头像",
|
||||
"Add to Favorites": "添加到收藏夹",
|
||||
"Advanced Definition": "高级定义",
|
||||
"world_button_title": "角色世界书\n\n单击加载\nShift+单击打开“链接到世界书”弹出窗口",
|
||||
"Chat Lore Alt+Click to open the lorebook": "聊天世界书\nAlt+单击打开世界书",
|
||||
"world_button_title": "角色世界书\n\n单击加载\nShift/Alt+单击或长按打开“链接到世界书”弹出窗口",
|
||||
"chat_lorebook_button_title": "聊天世界书\n\n单击加载\nShift/Alt+单击或长按打开“链接到聊天世界书”弹出窗口",
|
||||
"Connected Personas": "绑定的用户设定",
|
||||
"Export and Download": "导出并下载",
|
||||
"Duplicate Character": "复制角色",
|
||||
|
||||
@@ -1543,7 +1543,7 @@
|
||||
"When enabled, nodes that have swipes splitting off of them will appear subtly larger, in addition to having the double border.": "啟用後,具分支滑動的節點將顯示雙重邊框,還會略微放大。",
|
||||
"WI Entry Status:🔵 Constant🟢 Normal🔗 Vectorized": "世界資訊條目狀態:\\r🔵 恆定\\r🟢 正常\\r🔗 向量化",
|
||||
"Width of a node, in pixels at zoom level 1.0.": "縮放等級為 1.0 時,節點的像素寬度。",
|
||||
"world_button_title": "角色背景設定\n「Shift+點選」可開啟「連結至世界資訊」彈窗",
|
||||
"world_button_title": "角色背景設定\n「Shift/Alt+點選」或長按可開啟「連結至世界資訊」彈窗",
|
||||
"# of Beams": "# of Beams",
|
||||
"Additional Parameters": "其他參數",
|
||||
"All": "全部",
|
||||
@@ -2367,8 +2367,8 @@
|
||||
"Contain": "自適應",
|
||||
"Stretch": "拉伸",
|
||||
"Center": "置中",
|
||||
"Persona Lore Alt+Click to open the lorebook": "「Alt+點選」可開啟角色知識書",
|
||||
"Chat Lore Alt+Click to open the lorebook": "「Alt+點選」可開啟聊天知識書",
|
||||
"persona_lore_button_title": "人設知識書\n\n點選以載入\nShift/Alt+點選或長按開啟「連結人設知識書」彈窗",
|
||||
"chat_lorebook_button_title": "聊天知識書\n\n點選以載入\nShift/Alt+點選或長按開啟「連結聊天知識書」彈窗",
|
||||
"Function Tool": "功能工具",
|
||||
"Functions in this category are for advanced users only. Don't click anything if you're not sure about the consequences.": "此類功能僅供高階使用者使用。若不確定後果,請勿點選任何內容。",
|
||||
"Are you sure you want to delete this user?": "確定要刪除該使用者嗎?",
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
} from '../script.js';
|
||||
import { persona_description_positions, power_user } from './power-user.js';
|
||||
import { getTokenCountAsync } from './tokenizers.js';
|
||||
import { PAGINATION_TEMPLATE, clearInfoBlock, debounce, delay, download, ensureImageFormatSupported, flashHighlight, getBase64Async, getCharIndex, isFalseBoolean, isTrueBoolean, onlyUnique, parseJsonFile, setInfoBlock, localizePagination, renderPaginationDropdown, paginationDropdownChangeHandler } from './utils.js';
|
||||
import { PAGINATION_TEMPLATE, clearInfoBlock, debounce, delay, download, ensureImageFormatSupported, flashHighlight, getBase64Async, getCharIndex, isFalseBoolean, isTrueBoolean, onlyUnique, parseJsonFile, setInfoBlock, localizePagination, renderPaginationDropdown, paginationDropdownChangeHandler, addLongPressEvent } from './utils.js';
|
||||
import { debounce_timeout } from './constants.js';
|
||||
import { FILTER_TYPES, FilterHelper } from './filters.js';
|
||||
import { groups, selected_group } from './group-chats.js';
|
||||
@@ -1182,7 +1182,7 @@ async function onPersonaLoreButtonClick(event) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.altKey && selectedLorebook) {
|
||||
if (selectedLorebook && !event.shiftKey && !event.altKey) {
|
||||
openWorldInfoEditor(selectedLorebook);
|
||||
return;
|
||||
}
|
||||
@@ -2003,6 +2003,18 @@ export async function initPersonas() {
|
||||
$('#persona_depth_value').on('input', onPersonaDescriptionDepthValueInput);
|
||||
$('#persona_depth_role').on('input', onPersonaDescriptionDepthRoleInput);
|
||||
$('#persona_lore_button').on('click', onPersonaLoreButtonClick);
|
||||
addLongPressEvent('#persona_lore_button', function () {
|
||||
onPersonaLoreButtonClick({ shiftKey: true, altKey: false });
|
||||
});
|
||||
$('#persona-management-dropdown').on('change', async function () {
|
||||
const target = $(this).find(':selected').attr('id');
|
||||
$(this).prop('selectedIndex', 0);
|
||||
switch (target) {
|
||||
case 'persona_lorebook_link':
|
||||
await onPersonaLoreButtonClick({ shiftKey: true, altKey: false });
|
||||
break;
|
||||
}
|
||||
});
|
||||
$('#personas_backup').on('click', onBackupPersonas);
|
||||
$('#personas_restore').on('click', () => $('#personas_restore_input').trigger('click'));
|
||||
$('#personas_restore_input').on('change', onPersonasRestoreInput);
|
||||
|
||||
@@ -2938,3 +2938,46 @@ export function createTimeout(ms, errorMessage = '') {
|
||||
setTimeout(() => reject(new Error(errorMessage)), ms);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a long-press (touch hold) event as an alternative to modifier+click.
|
||||
* Supports event delegation for dynamically created elements.
|
||||
* @param {string} selector CSS selector for target elements
|
||||
* @param {function} callback Callback to invoke on long-press, `this` is the matched element
|
||||
* @param {number} [delay=500] Long-press duration in ms
|
||||
*/
|
||||
export function addLongPressEvent(selector, callback, delay = 500) {
|
||||
let timer = null;
|
||||
let fired = false;
|
||||
let target = null;
|
||||
|
||||
document.addEventListener('touchstart', function (event) {
|
||||
const el = event.target.closest(selector);
|
||||
if (!el) return;
|
||||
target = el;
|
||||
fired = false;
|
||||
timer = setTimeout(() => {
|
||||
fired = true;
|
||||
event.preventDefault();
|
||||
callback.call(el, event);
|
||||
}, delay);
|
||||
}, { passive: false });
|
||||
|
||||
document.addEventListener('touchend', cancelTimer);
|
||||
document.addEventListener('touchmove', cancelTimer);
|
||||
document.addEventListener('touchcancel', cancelTimer);
|
||||
|
||||
document.addEventListener('click', function (event) {
|
||||
if (fired && target && target.contains(event.target)) {
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
fired = false;
|
||||
target = null;
|
||||
}
|
||||
}, true);
|
||||
|
||||
function cancelTimer() {
|
||||
clearTimeout(timer);
|
||||
timer = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Fuse } from '../lib.js';
|
||||
|
||||
import { saveSettings, substituteParams, getRequestHeaders, chat_metadata, this_chid, characters, saveCharacterDebounced, menu_type, eventSource, event_types, getExtensionPromptByName, saveMetadata, getCurrentChatId, extension_prompt_roles, create_save, createOrEditCharacter, name1 } from '../script.js';
|
||||
import { download, debounce, initScrollHeight, resetScrollHeight, parseJsonFile, extractDataFromPng, getFileBuffer, getCharaFilename, getSortableDelay, escapeRegex, PAGINATION_TEMPLATE, navigation_option, waitUntilCondition, isTrueBoolean, setValueByPath, flashHighlight, select2ModifyOptions, getSelect2OptionId, dynamicSelect2DataViaAjax, highlightRegex, select2ChoiceClickSubscribe, isFalseBoolean, getSanitizedFilename, checkOverwriteExistingData, getStringHash, parseStringArray, cancelDebounce, findChar, onlyUnique, equalsIgnoreCaseAndAccents, uuidv4, normalizeArray, getUniqueName, logSlashCommandWarn } from './utils.js';
|
||||
import { download, debounce, initScrollHeight, resetScrollHeight, parseJsonFile, extractDataFromPng, getFileBuffer, getCharaFilename, getSortableDelay, escapeRegex, PAGINATION_TEMPLATE, navigation_option, waitUntilCondition, isTrueBoolean, setValueByPath, flashHighlight, select2ModifyOptions, getSelect2OptionId, dynamicSelect2DataViaAjax, highlightRegex, select2ChoiceClickSubscribe, isFalseBoolean, getSanitizedFilename, checkOverwriteExistingData, getStringHash, parseStringArray, cancelDebounce, findChar, onlyUnique, equalsIgnoreCaseAndAccents, uuidv4, normalizeArray, getUniqueName, logSlashCommandWarn, addLongPressEvent } from './utils.js';
|
||||
import { extension_settings, getContext } from './extensions.js';
|
||||
import { NOTE_MODULE_NAME, metadata_keys, shouldWIAddPrompt } from './authors-note.js';
|
||||
import { isMobile } from './RossAscends-mods.js';
|
||||
@@ -5738,7 +5738,7 @@ export function openWorldInfoEditor(worldName) {
|
||||
export async function assignLorebookToChat(event) {
|
||||
const selectedName = chat_metadata[METADATA_KEY];
|
||||
|
||||
if (selectedName && event.altKey) {
|
||||
if (selectedName && !event.shiftKey && !event.altKey) {
|
||||
openWorldInfoEditor(selectedName);
|
||||
return;
|
||||
}
|
||||
@@ -6110,15 +6110,18 @@ export function initWorldInfo() {
|
||||
|
||||
const worldName = characters[chid]?.data?.extensions?.world;
|
||||
const hasEmbed = checkEmbeddedWorld(chid);
|
||||
if (worldName && world_names.includes(worldName) && !event.shiftKey) {
|
||||
if (worldName && world_names.includes(worldName) && !event.shiftKey && !event.altKey) {
|
||||
openWorldInfoEditor(worldName);
|
||||
} else if (hasEmbed && !event.shiftKey) {
|
||||
} else if (hasEmbed && !event.shiftKey && !event.altKey) {
|
||||
await importEmbeddedWorldInfo();
|
||||
saveCharacterDebounced();
|
||||
} else {
|
||||
openSetWorldMenu();
|
||||
}
|
||||
});
|
||||
addLongPressEvent('#world_button', function () {
|
||||
$(this).trigger($.Event('click', { shiftKey: true }));
|
||||
});
|
||||
|
||||
const debouncedWorldInfoSearch = debounce((searchQuery) => {
|
||||
worldInfoFilter.setFilterData(FILTER_TYPES.WORLD_INFO_SEARCH, searchQuery);
|
||||
@@ -6140,6 +6143,14 @@ export function initWorldInfo() {
|
||||
});
|
||||
|
||||
$(document).on('click', '.chat_lorebook_button', assignLorebookToChat);
|
||||
addLongPressEvent('.chat_lorebook_button', function () {
|
||||
assignLorebookToChat({ shiftKey: true, altKey: false });
|
||||
});
|
||||
|
||||
$('#group-chat-lorebook-dropdown').on('change', async function () {
|
||||
$(this).prop('selectedIndex', 0);
|
||||
await assignLorebookToChat({ shiftKey: true, altKey: false });
|
||||
});
|
||||
|
||||
// Not needed on mobile
|
||||
if (!isMobile()) {
|
||||
|
||||
Reference in New Issue
Block a user