Add /imagine-style command
This commit is contained in:
parent
909ac0c622
commit
a63f99b8ce
|
@ -4058,7 +4058,35 @@ jQuery(async () => {
|
||||||
await onSourceChange();
|
await onSourceChange();
|
||||||
return extension_settings.sd.source;
|
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({
|
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||||
name: 'imagine-comfy-workflow',
|
name: 'imagine-comfy-workflow',
|
||||||
|
|
Loading…
Reference in New Issue