| 4058 | 4058 | await onSourceChange(); |
| 4059 | 4059 | return extension_settings.sd.source; |
| 4060 | 4060 | }, |
| 4061 | 4061 | })); |
| 4062 | + |
| 4063 | + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 4064 | + name: 'imagine-style', |
| 4065 | + aliases: ['sd-style', 'img-style'], |
| 4066 | + returns: 'a name of the current style', |
| 4067 | + unnamedArgumentList: [ |
| 4068 | + SlashCommandArgument.fromProps({ |
| 4069 | + description: 'style name', |
| 4070 | + typeList: [ARGUMENT_TYPE.STRING], |
| 4071 | + isRequired: false, |
| 4072 | + forceEnum: true, |
| 4073 | + enumProvider: () => Array.from(document.querySelectorAll('#sd_style > [value]')).map(x => new SlashCommandEnumValue(x.getAttribute('value'), x.textContent)), |
| 4074 | + }), |
| 4075 | + ], |
| 4076 | + helpString: 'If an argument is provided, change the style of the image generation, e.g. <code>/imagine-style MyStyle</code>. Returns the current style.', |
| 4077 | + callback: async (_args, name) => { |
| 4078 | + if (!name) { |
| 4079 | + return extension_settings.sd.style; |
| 4080 | + } |
| 4081 | + const option = document.querySelector(`#sd_style [value="${name}"]`); |
| 4082 | + if (!(option instanceof HTMLOptionElement)) { |
| 4083 | + throw new Error('Could not find the style option in the dropdown.'); |
| 4084 | + } |
| 4085 | + option.selected = true; |
| 4086 | + onStyleSelect(); |
| 4087 | + return extension_settings.sd.style; |
| 4088 | + }, |
| 4089 | + })); |
| 4062 | 4090 | |
| 4063 | 4091 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 4064 | 4092 | name: 'imagine-comfy-workflow', |