Add /imagine-style command

This commit is contained in:
Cohee 2024-10-01 02:11:24 +03:00
parent 909ac0c622
commit a63f99b8ce
1 changed files with 29 additions and 1 deletions

View File

@ -4058,7 +4058,35 @@ jQuery(async () => {
await onSourceChange();
return extension_settings.sd.source;
},
}))
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'imagine-style',
aliases: ['sd-style', 'img-style'],
returns: 'a name of the current style',
unnamedArgumentList: [
SlashCommandArgument.fromProps({
description: 'style name',
typeList: [ARGUMENT_TYPE.STRING],
isRequired: false,
forceEnum: true,
enumProvider: () => Array.from(document.querySelectorAll('#sd_style > [value]')).map(x => new SlashCommandEnumValue(x.getAttribute('value'), x.textContent)),
}),
],
helpString: 'If an argument is provided, change the style of the image generation, e.g. <code>/imagine-style MyStyle</code>. Returns the current style.',
callback: async (_args, name) => {
if (!name) {
return extension_settings.sd.style;
}
const option = document.querySelector(`#sd_style [value="${name}"]`);
if (!(option instanceof HTMLOptionElement)) {
throw new Error('Could not find the style option in the dropdown.');
}
option.selected = true;
onStyleSelect();
return extension_settings.sd.style;
},
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'imagine-comfy-workflow',