mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
slashcommand /movingui to set a MUI preset
This commit is contained in:
@ -2352,6 +2352,28 @@ async function setThemeCallback(_, text) {
|
|||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function setmovingUIPreset(_, text) {
|
||||||
|
const fuse = new Fuse(movingUIPresets, {
|
||||||
|
keys: [
|
||||||
|
{ name: 'name', weight: 1 },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
const results = fuse.search(text);
|
||||||
|
console.debug('movingUI preset fuzzy search results for ' + text, results);
|
||||||
|
const preset = results[0]?.item;
|
||||||
|
|
||||||
|
if (!preset) {
|
||||||
|
toastr.warning(`Could not find preset with name: ${text}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
power_user.movingUIPreset = preset.name;
|
||||||
|
applyMovingUIPreset(preset.name);
|
||||||
|
$("#movingUIPresets").val(preset.name);
|
||||||
|
saveSettingsDebounced();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the custom stopping strings from the power user settings.
|
* Gets the custom stopping strings from the power user settings.
|
||||||
* @param {number | undefined} limit Number of strings to return. If 0 or undefined, returns all strings.
|
* @param {number | undefined} limit Number of strings to return. If 0 or undefined, returns all strings.
|
||||||
@ -3027,4 +3049,5 @@ $(document).ready(() => {
|
|||||||
registerSlashCommand('resetpanels', doResetPanels, ['resetui'], '– resets UI panels to original state.', true, true);
|
registerSlashCommand('resetpanels', doResetPanels, ['resetui'], '– resets UI panels to original state.', true, true);
|
||||||
registerSlashCommand('bgcol', setAvgBG, [], '– WIP test of auto-bg avg coloring', true, true);
|
registerSlashCommand('bgcol', setAvgBG, [], '– WIP test of auto-bg avg coloring', true, true);
|
||||||
registerSlashCommand('theme', setThemeCallback, [], '<span class="monospace">(name)</span> – sets a UI theme by name', true, true);
|
registerSlashCommand('theme', setThemeCallback, [], '<span class="monospace">(name)</span> – sets a UI theme by name', true, true);
|
||||||
|
registerSlashCommand('movingui', setmovingUIPreset, [], '<span class="monospace">(name)</span> – activates a movingUI preset by name', true, true);
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user