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:
kingbri
2023-07-18 01:09:00 -04:00
parent eb90162579
commit d61eba4cb4
2 changed files with 21 additions and 0 deletions

View File

@@ -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");
});

View File

@@ -1,4 +1,5 @@
<div class="regex-script-label flex-container flexnowrap">
<span class="drag-handle menu-handle">&#9776;</span>
<div class="regex_script_name flexGrow overflow-hidden"></div>
<div class="flex-container flexnowrap">
<div class="edit_existing_regex menu_button">