mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Regex: Add script reordering
The engine runs with a foreach, so the scripts run sequentially. Ideally, scripts should be one-liners, but if multiple scripts run in a chain, allow the user to reorder them. Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
@@ -236,5 +236,25 @@ jQuery(async () => {
|
||||
onRegexEditorOpenClick(false);
|
||||
});
|
||||
|
||||
$('#saved_regex_scripts').sortable({
|
||||
stop: function () {
|
||||
let newScripts = [];
|
||||
$('#saved_regex_scripts').children().each(function () {
|
||||
const scriptName = $(this).find(".regex_script_name").text();
|
||||
const existingScript = extension_settings.regex.find((e) => e.scriptName === scriptName);
|
||||
if (existingScript) {
|
||||
newScripts.push(existingScript);
|
||||
}
|
||||
});
|
||||
|
||||
extension_settings.regex = newScripts;
|
||||
saveSettingsDebounced();
|
||||
|
||||
console.debug("Regex scripts reordered");
|
||||
// TODO: Maybe reload regex scripts after move
|
||||
},
|
||||
});
|
||||
|
||||
await loadRegexScripts();
|
||||
$("#saved_regex_scripts").sortable("enable");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user