mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
refactor(slash-commands): 重命名 goto-floor 命令为 chat-jump
- 将命令名称从 'goto-floor' 修改为 'chat-jump',以更好地反映其功能
This commit is contained in:
@ -2132,7 +2132,7 @@ export function initDefaultSlashCommands() {
|
||||
}));
|
||||
|
||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||
name: 'goto-floor',
|
||||
name: 'chat-jump',
|
||||
aliases: ['floor', 'jump', 'scrollto'],
|
||||
callback: async (_, index) => {
|
||||
const floorIndex = Number(index);
|
||||
@ -2141,16 +2141,16 @@ export function initDefaultSlashCommands() {
|
||||
if (isNaN(floorIndex) || floorIndex < 0 || (chatLength !== -1 && floorIndex >= chatLength)) {
|
||||
const maxIndex = (chatLength !== -1 ? chatLength - 1 : 'unknown');
|
||||
toastr.warning(`Invalid message index: ${index}. Please enter a number between 0 and ${maxIndex}.`);
|
||||
console.warn(`WARN: Invalid message index provided for /goto-floor: ${index}. Max index: ${maxIndex}`);
|
||||
console.warn(`WARN: Invalid message index provided for /chat-jump: ${index}. Max index: ${maxIndex}`);
|
||||
return '';
|
||||
}
|
||||
|
||||
// --- Load all messages first to ensure the target element exists ---
|
||||
console.log(`INFO: Attempting to load all messages before attempting to goto-floor ${index}.`);
|
||||
console.log(`INFO: Attempting to load all messages before attempting to chat-jump ${index}.`);
|
||||
try {
|
||||
// Assuming showMoreMessages is available globally or within scope
|
||||
await showMoreMessages(Number.MAX_SAFE_INTEGER);
|
||||
console.log(`INFO: All messages loaded (or loading initiated).`);
|
||||
console.log('INFO: All messages loaded (or loading initiated).');
|
||||
// Give the rendering a moment to potentially catch up after showMoreMessages
|
||||
await new Promise(resolve => setTimeout(resolve, 100)); // Adjust delay if needed
|
||||
} catch (error) {
|
||||
@ -2192,7 +2192,7 @@ export function initDefaultSlashCommands() {
|
||||
} else {
|
||||
// Only warn if element is not found *after* attempting to load all messages
|
||||
toastr.warning(`Could not find element for message ${floorIndex} (using [mesid="${floorIndex}"]) even after attempting to load all messages. It might not be rendered yet or the index is invalid.`);
|
||||
console.warn(`WARN: Element not found for message index ${floorIndex} using querySelector [mesid="${floorIndex}"] in /goto-floor, even after attempting to load all messages.`);
|
||||
console.warn(`WARN: Element not found for message index ${floorIndex} using querySelector [mesid="${floorIndex}"] in /chat-jump, even after attempting to load all messages.`);
|
||||
// Do NOT scroll the chat container in this case
|
||||
}
|
||||
return ''; // Return empty string as expected by some slash command parsers
|
||||
@ -2213,12 +2213,12 @@ export function initDefaultSlashCommands() {
|
||||
A warning is displayed if the message element cannot be located even after attempting to load all messages.
|
||||
</div>
|
||||
<div>
|
||||
<strong>Example:</strong> <pre><code>/goto-floor 10</code></pre> Scrolls to the 11th message (mesid=10).
|
||||
<strong>Example:</strong> <pre><code>/chat-jump 10</code></pre> Scrolls to the 11th message (mesid=10).
|
||||
</div>
|
||||
`,
|
||||
}));
|
||||
|
||||
const styleId = 'goto-floor-highlight-style';
|
||||
const styleId = 'chat-jump-highlight-style';
|
||||
if (document.getElementById(styleId)) {
|
||||
document.getElementById(styleId).remove();
|
||||
}
|
||||
|
Reference in New Issue
Block a user