Exported reloadEditor
| @@ -79,7 +79,7 @@ import { ToolManager } from './tool-calling.js'; | |||
| 79 | import { accountStorage } from './util/AccountStorage.js'; | 79 | import { accountStorage } from './util/AccountStorage.js'; |
| 80 | import { timestampToMoment, uuidv4 } from './utils.js'; | 80 | import { timestampToMoment, uuidv4 } from './utils.js'; |
| 81 | import { getGlobalVariable, getLocalVariable, setGlobalVariable, setLocalVariable } from './variables.js'; | 81 | import { getGlobalVariable, getLocalVariable, setGlobalVariable, setLocalVariable } from './variables.js'; |
| 82 | import { convertCharacterBook, getWorldInfoPrompt, loadWorldInfo, saveWorldInfo, updateWorldInfoList } from './world-info.js'; | 82 | import { convertCharacterBook, getWorldInfoPrompt, loadWorldInfo, reloadEditor, saveWorldInfo, updateWorldInfoList } from './world-info.js'; |
| 83 | import { ChatCompletionService, TextCompletionService } from './custom-request.js'; | 83 | import { ChatCompletionService, TextCompletionService } from './custom-request.js'; |
| 84 | import { ConnectionManagerRequestService } from './extensions/shared.js'; | 84 | import { ConnectionManagerRequestService } from './extensions/shared.js'; |
| 85 | import { updateReasoningUI, parseReasoningFromString } from './reasoning.js'; | 85 | import { updateReasoningUI, parseReasoningFromString } from './reasoning.js'; |
| @@ -207,6 +207,7 @@ export function getContext() { | |||
| 207 | }, | 207 | }, |
| 208 | loadWorldInfo, | 208 | loadWorldInfo, |
| 209 | saveWorldInfo, | 209 | saveWorldInfo, |
| 210 | reloadWorldInfoEditor: reloadEditor, | ||
| 210 | updateWorldInfoList, | 211 | updateWorldInfoList, |
| 211 | convertCharacterBook, | 212 | convertCharacterBook, |
| 212 | getWorldInfoPrompt, | 213 | getWorldInfoPrompt, |
| @@ -908,20 +908,20 @@ export function setWorldInfoSettings(settings, data) { | |||
| 908 | registerWorldInfoSlashCommands(); | 908 | registerWorldInfoSlashCommands(); |
| 909 | } | 909 | } |
| 910 | 910 | ||
| 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 |
| 914 | * @param {string} file - The file to load in the editor | 914 | * @param {boolean} [loadIfNotSelected=false] - Indicates whether to load the file 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()); |
| 918 | const currentIndex = Number($('#world_editor_select').val()); | 918 | const selectedIndex = world_names.indexOf(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 | } | ||
| 923 | } | 921 | } |
| 922 | } | ||
| 924 | 923 | ||
| 924 | function registerWorldInfoSlashCommands() { | ||
| 925 | /** | 925 | /** |
| 926 | * Gets a *rough* approximation of the current chat context. | 926 | * Gets a *rough* approximation of the current chat context. |
| 927 | * Normally, it is provided externally by the prompt builder. | 927 | * Normally, it is provided externally by the prompt builder. |