Merge pull request #3744 from bmen25124/updateEditor_export_new_parm Exported reloadEditor

a8f1bf7a17e69f6cbbf325f3dc2d0c4b9b96293b

Cohee <18619528+Cohee1207@users.noreply.github.com>

Signed
2 files changed, +14 -13Ignore whitespace
public/scripts/st-context.js+2 -1
@@ -79,7 +79,7 @@ import { ToolManager } from './tool-calling.js';
7979import { accountStorage } from './util/AccountStorage.js';
8080import { timestampToMoment, uuidv4 } from './utils.js';
8181import { getGlobalVariable, getLocalVariable, setGlobalVariable, setLocalVariable } from './variables.js';
8282import { convertCharacterBook, getWorldInfoPrompt, loadWorldInfo, reloadEditor, saveWorldInfo, updateWorldInfoList } from './world-info.js';
8383import { ChatCompletionService, TextCompletionService } from './custom-request.js';
8484import { ConnectionManagerRequestService } from './extensions/shared.js';
8585import { updateReasoningUI, parseReasoningFromString } from './reasoning.js';
@@ -207,6 +207,7 @@ export function getContext() {
207207 },
208208 loadWorldInfo,
209209 saveWorldInfo,
210+ reloadWorldInfoEditor: reloadEditor,
210211 updateWorldInfoList,
211212 convertCharacterBook,
212213 getWorldInfoPrompt,
public/scripts/world-info.js+12 -12
@@ -908,20 +908,20 @@ export function setWorldInfoSettings(settings, data) {
908908 registerWorldInfoSlashCommands();
909909}
910910
911-function registerWorldInfoSlashCommands() {
911+/**
912- /**
912+ * Reloads the editor with the specified world info file
913- * Reloads the editor with the specified world info file
913+ * @param {string} file - The file to load in the editor
914914 * @param {stringboolean} file[loadIfNotSelected=false] - TheIndicates filewhether to load in the editorfile even if it's not currently selected
915- * @param {boolean} [loadIfNotSelected=false] - Indicates whether to load the file even if it's not currently selected
915+ */
916- */
916+export function reloadEditor(file, loadIfNotSelected = false) {
917- function reloadEditor(file, loadIfNotSelected = false) {
917+ const currentIndex = Number($('#world_editor_select').val());
918918 const currentIndexselectedIndex = Number($('#world_editor_select')world_names.valindexOf()file);
919- const selectedIndex = world_names.indexOf(file);
919+ if (selectedIndex !== -1 && (loadIfNotSelected || currentIndex === selectedIndex)) {
920- if (selectedIndex !== -1 && (loadIfNotSelected || currentIndex === selectedIndex)) {
920+ $('#world_editor_select').val(selectedIndex).trigger('change');
921- $('#world_editor_select').val(selectedIndex).trigger('change');
922- }
923921 }
922+}
924923
924+function registerWorldInfoSlashCommands() {
925925 /**
926926 * Gets a *rough* approximation of the current chat context.
927927 * Normally, it is provided externally by the prompt builder.