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);
|
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();
|
await loadRegexScripts();
|
||||||
|
$("#saved_regex_scripts").sortable("enable");
|
||||||
});
|
});
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<div class="regex-script-label flex-container flexnowrap">
|
<div class="regex-script-label flex-container flexnowrap">
|
||||||
|
<span class="drag-handle menu-handle">☰</span>
|
||||||
<div class="regex_script_name flexGrow overflow-hidden"></div>
|
<div class="regex_script_name flexGrow overflow-hidden"></div>
|
||||||
<div class="flex-container flexnowrap">
|
<div class="flex-container flexnowrap">
|
||||||
<div class="edit_existing_regex menu_button">
|
<div class="edit_existing_regex menu_button">
|
||||||
|
Reference in New Issue
Block a user