mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): prompt preview not working preset starts with [prompt]
This commit is contained in:
parent
29d6f48901
commit
41b2d5d013
@ -1,13 +1,15 @@
|
|||||||
import { PRESET_PLACEHOLDER } from 'features/stylePresets/hooks/usePresetModifiedPrompts';
|
import { PRESET_PLACEHOLDER } from 'features/stylePresets/hooks/usePresetModifiedPrompts';
|
||||||
|
|
||||||
export const getViewModeChunks = (currentPrompt: string, presetPrompt?: string): [string, string, string] => {
|
export const getViewModeChunks = (currentPrompt: string, presetPrompt?: string): [string, string, string] => {
|
||||||
if (!presetPrompt || !presetPrompt.length) {
|
if (!presetPrompt || !presetPrompt.length) {
|
||||||
return ['', currentPrompt, ''];
|
return ['', currentPrompt, ''];
|
||||||
}
|
}
|
||||||
const [firstPart, ...remainingParts] = presetPrompt.split(PRESET_PLACEHOLDER);
|
|
||||||
const chunks = [firstPart, remainingParts.join(PRESET_PLACEHOLDER)];
|
const [before, after] = presetPrompt.split(PRESET_PLACEHOLDER, 2);
|
||||||
if (chunks.filter((chunk) => chunk !== '').length === 1) {
|
|
||||||
return ['', currentPrompt, chunks[0] ?? ''];
|
if (!before || !after) {
|
||||||
} else {
|
return ['', `${currentPrompt} `, presetPrompt];
|
||||||
return [chunks[0] ?? '', currentPrompt, chunks[1] ?? ''];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return [before ?? '', currentPrompt, after ?? ''];
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user