diff --git a/public/scripts/extensions/regex/dropdown.html b/public/scripts/extensions/regex/dropdown.html
index 259001793..68559b79b 100644
--- a/public/scripts/extensions/regex/dropdown.html
+++ b/public/scripts/extensions/regex/dropdown.html
@@ -21,13 +21,28 @@
Import
-
+
+
-
diff --git a/public/scripts/extensions/regex/index.js b/public/scripts/extensions/regex/index.js
index 6db623c74..8ea2bd249 100644
--- a/public/scripts/extensions/regex/index.js
+++ b/public/scripts/extensions/regex/index.js
@@ -607,22 +607,67 @@ jQuery(async () => {
$('#import_regex_file').trigger('click');
});
- $('#export_global_regex').on('click', async function () {
- const regexScripts = extension_settings?.regex ?? [];
- if (regexScripts.length) {
- const fileName = 'regex-global.json';
- const fileData = JSON.stringify(regexScripts, null, 4);
- download(fileData, fileName, 'application/json');
+ function getSelectedScripts() {
+ const scripts = getRegexScripts();
+ const selector = '#regex_container .regex-script-label:has(.regex_bulk_checkbox:checked)';
+ const selectedIds = Array.from(document.querySelectorAll(selector)).map(e => e.getAttribute('id')).filter(id => id);
+ return scripts.filter(script => selectedIds.includes(script.id));
+ }
+
+ $('#bulk_enable_regex').on('click', async function () {
+ const scripts = getSelectedScripts().filter(script => script.disabled);
+ if (scripts.length === 0) {
+ toastr.warning(t`No regex scripts selected for enabling.`);
+ return;
}
+ for (const script of scripts) {
+ script.disabled = false;
+ }
+ saveSettingsDebounced();
+ await loadRegexScripts();
});
- $('#export_scoped_regex').on('click', async function () {
- const regexScripts = characters[this_chid]?.data?.extensions?.regex_scripts ?? [];
- if (regexScripts.length) {
- const fileName = `regex-${sanitizeFileName(characters[this_chid].name)}.json`;
- const fileData = JSON.stringify(regexScripts, null, 4);
- download(fileData, fileName, 'application/json');
+ $('#bulk_disable_regex').on('click', async function () {
+ const scripts = getSelectedScripts().filter(script => !script.disabled);
+ if (scripts.length === 0) {
+ toastr.warning(t`No regex scripts selected for disabling.`);
+ return;
}
+ for (const script of scripts) {
+ script.disabled = true;
+ }
+ saveSettingsDebounced();
+ await loadRegexScripts();
+ });
+
+ $('#bulk_delete_regex').on('click', async function () {
+ const scripts = getSelectedScripts();
+ if (scripts.length === 0) {
+ toastr.warning(t`No regex scripts selected for deletion.`);
+ return;
+ }
+ const confirm = await callGenericPopup('Are you sure you want to delete the selected regex scripts?', POPUP_TYPE.CONFIRM);
+ if (!confirm) {
+ return;
+ }
+ for (const script of scripts) {
+ const isScoped = characters[this_chid]?.data?.extensions?.regex_scripts?.some(s => s.id === script.id);
+ await deleteRegexScript({ id: script.id, isScoped: isScoped });
+ }
+ await reloadCurrentChat();
+ saveSettingsDebounced();
+ });
+
+ $('#bulk_export_regex').on('click', async function () {
+ const scripts = getSelectedScripts();
+ if (scripts.length === 0) {
+ toastr.warning(t`No regex scripts selected for export.`);
+ return;
+ }
+ const fileName = `regex-${new Date().toISOString()}.json`;
+ const fileData = JSON.stringify(scripts, null, 4);
+ download(fileData, fileName, 'application/json');
+ await loadRegexScripts();
});
let sortableDatas = [
diff --git a/public/scripts/extensions/regex/scriptTemplate.html b/public/scripts/extensions/regex/scriptTemplate.html
index cafe992f0..36bdfd5d7 100644
--- a/public/scripts/extensions/regex/scriptTemplate.html
+++ b/public/scripts/extensions/regex/scriptTemplate.html
@@ -1,4 +1,5 @@
+
☰
diff --git a/public/scripts/extensions/regex/style.css b/public/scripts/extensions/regex/style.css
index 2a2da50ed..8d270ca78 100644
--- a/public/scripts/extensions/regex/style.css
+++ b/public/scripts/extensions/regex/style.css
@@ -56,7 +56,7 @@
}
.regex-script-label {
- align-items: center;
+ align-items: baseline;
border: 1px solid var(--SmartThemeBorderColor);
border-radius: 10px;
padding: 0 5px;
@@ -126,3 +126,25 @@ input.enable_scoped {
right: 10px;
transform: translateY(-50%);
}
+
+.regex_settings label[for="regex_bulk_edit"]:has(#regex_bulk_edit:checked) {
+ color: var(--golden);
+}
+
+.regex_settings .regex-script-container .regex-script-label .regex_bulk_checkbox {
+ margin-left: 5px;
+ margin-right: 5px;
+}
+
+.regex_settings .regex_bulk_operations,
+.regex_settings .regex_bulk_checkbox {
+ display: none;
+}
+
+.regex_settings:has(#regex_bulk_edit:checked) .regex_bulk_operations {
+ display: flex;
+}
+
+.regex_settings:has(#regex_bulk_edit:checked) .regex_bulk_checkbox {
+ display: inline-grid;
+}