mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fixes #2578 use prompt bug on webkit browsers
This commit is contained in:
parent
0cee72dba5
commit
72357266a6
File diff suppressed because one or more lines are too long
2
invokeai/frontend/dist/index.html
vendored
2
invokeai/frontend/dist/index.html
vendored
@ -5,7 +5,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>InvokeAI - A Stable Diffusion Toolkit</title>
|
||||
<link rel="shortcut icon" type="icon" href="./assets/favicon-0d253ced.ico" />
|
||||
<script type="module" crossorigin src="./assets/index-34c8aef8.js"></script>
|
||||
<script type="module" crossorigin src="./assets/index-4baf9db0.js"></script>
|
||||
<link rel="stylesheet" href="./assets/index-b0bf79f4.css">
|
||||
</head>
|
||||
|
||||
|
@ -5,15 +5,24 @@ export function getPromptAndNegative(input_prompt: InvokeAI.Prompt) {
|
||||
let prompt: string = promptToString(input_prompt);
|
||||
let negativePrompt: string | null = null;
|
||||
|
||||
const negativePromptRegExp = new RegExp(/(?<=\[)[^\][]*(?=])/, 'gi');
|
||||
const negativePromptMatches = [...prompt.matchAll(negativePromptRegExp)];
|
||||
// Matches all negative prompts, 1st capturing group is the prompt itself
|
||||
const negativePromptRegExp = new RegExp(/\[([^\][]*)]/, 'gi');
|
||||
|
||||
if (negativePromptMatches && negativePromptMatches.length > 0) {
|
||||
negativePrompt = negativePromptMatches.join(', ');
|
||||
prompt = prompt
|
||||
.replaceAll(negativePromptRegExp, '')
|
||||
.replaceAll('[]', '')
|
||||
.trim();
|
||||
// Grab the actual prompt matches (capturing group 1 is 1st index of match)
|
||||
const negativePromptMatches = [...prompt.matchAll(negativePromptRegExp)].map(
|
||||
(match) => match[1]
|
||||
);
|
||||
|
||||
if (negativePromptMatches.length) {
|
||||
// Build the negative prompt itself
|
||||
negativePrompt = negativePromptMatches.join(' ');
|
||||
|
||||
// Replace each match, including its surrounding brackets
|
||||
// Remove each pair of empty brackets
|
||||
// Trim whitespace
|
||||
negativePromptMatches.forEach((match) => {
|
||||
prompt = prompt.replace(`[${match}]`, '').replaceAll('[]', '').trim();
|
||||
});
|
||||
}
|
||||
|
||||
return [prompt, negativePrompt];
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user