Exported reloadEditor

This commit is contained in:
bmen25124
2025-03-23 03:37:02 +03:00
parent 50334890a6
commit 80e1226d28
2 changed files with 14 additions and 13 deletions

View File

@ -79,7 +79,7 @@ import { ToolManager } from './tool-calling.js';
import { accountStorage } from './util/AccountStorage.js';
import { timestampToMoment, uuidv4 } from './utils.js';
import { getGlobalVariable, getLocalVariable, setGlobalVariable, setLocalVariable } from './variables.js';
import { convertCharacterBook, getWorldInfoPrompt, loadWorldInfo, saveWorldInfo, updateWorldInfoList } from './world-info.js';
import { convertCharacterBook, getWorldInfoPrompt, loadWorldInfo, reloadEditor, saveWorldInfo, updateWorldInfoList } from './world-info.js';
import { ChatCompletionService, TextCompletionService } from './custom-request.js';
import { ConnectionManagerRequestService } from './extensions/shared.js';
import { updateReasoningUI, parseReasoningFromString } from './reasoning.js';
@ -207,6 +207,7 @@ export function getContext() {
},
loadWorldInfo,
saveWorldInfo,
reloadWorldInfoEditor: reloadEditor,
updateWorldInfoList,
convertCharacterBook,
getWorldInfoPrompt,

View File

@ -908,20 +908,20 @@ export function setWorldInfoSettings(settings, data) {
registerWorldInfoSlashCommands();
}
function registerWorldInfoSlashCommands() {
/**
/**
* Reloads the editor with the specified world info file
* @param {string} file - The file to load in the editor
* @param {boolean} [loadIfNotSelected=false] - Indicates whether to load the file even if it's not currently selected
*/
function reloadEditor(file, loadIfNotSelected = false) {
export function reloadEditor(file, loadIfNotSelected = false) {
const currentIndex = Number($('#world_editor_select').val());
const selectedIndex = world_names.indexOf(file);
if (selectedIndex !== -1 && (loadIfNotSelected || currentIndex === selectedIndex)) {
$('#world_editor_select').val(selectedIndex).trigger('change');
}
}
}
function registerWorldInfoSlashCommands() {
/**
* Gets a *rough* approximation of the current chat context.
* Normally, it is provided externally by the prompt builder.