mirror of
https://github.com/DominikDoom/a1111-sd-webui-tagcomplete.git
synced 2026-03-04 04:40:00 +00:00
Extract UMI after insert update
This commit is contained in:
@@ -23,6 +23,11 @@ class UmiParser extends BaseTagParser {
|
||||
}
|
||||
});
|
||||
|
||||
// Safety check since UMI parsing sometimes seems to trigger outside of an UMI subprompt and thus fails
|
||||
if (umiTagsWithOperators.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const promptSplitToTags = umiTagsWithOperators.replace(']###[', '][').split("][");
|
||||
|
||||
const clean = (str) => str
|
||||
@@ -178,4 +183,23 @@ class UmiParser extends BaseTagParser {
|
||||
}
|
||||
}
|
||||
|
||||
PARSERS.push(new UmiParser(UMI_TRIGGER));
|
||||
function updateUmiTags(tagType, newPrompt, textArea) {
|
||||
// If it was a yaml wildcard, also update the umiPreviousTags
|
||||
if (tagType === ResultType.yamlWildcard && originalTagword.length > 0) {
|
||||
let umiSubPrompts = [...newPrompt.matchAll(UMI_PROMPT_REGEX)];
|
||||
|
||||
let umiTags = [];
|
||||
umiSubPrompts.forEach(umiSubPrompt => {
|
||||
umiTags = umiTags.concat([...umiSubPrompt[0].matchAll(UMI_TAG_REGEX)].map(x => x[1].toLowerCase()));
|
||||
});
|
||||
|
||||
umiPreviousTags = umiTags;
|
||||
|
||||
hideResults(textArea);
|
||||
}
|
||||
}
|
||||
|
||||
// Add UMI parser
|
||||
PARSERS.push(new UmiParser(UMI_TRIGGER));
|
||||
// Add tag update after insert
|
||||
QUEUE_AFTER_INSERT.push(updateUmiTags);
|
||||
@@ -361,21 +361,7 @@ function insertTextAtCursor(textArea, result, tagword) {
|
||||
previousTags = tags;
|
||||
|
||||
// Callback
|
||||
processQueue(QUEUE_AFTER_INSERT, null, tagType);
|
||||
|
||||
// If it was a yaml wildcard, also update the umiPreviousTags
|
||||
if (tagType === ResultType.yamlWildcard && originalTagword.length > 0) {
|
||||
let umiSubPrompts = [...newPrompt.matchAll(UMI_PROMPT_REGEX)];
|
||||
|
||||
let umiTags = [];
|
||||
umiSubPrompts.forEach(umiSubPrompt => {
|
||||
umiTags = umiTags.concat([...umiSubPrompt[0].matchAll(UMI_TAG_REGEX)].map(x => x[1].toLowerCase()));
|
||||
});
|
||||
|
||||
umiPreviousTags = umiTags;
|
||||
|
||||
hideResults(textArea);
|
||||
}
|
||||
processQueue(QUEUE_AFTER_INSERT, null, tagType, newPrompt, textArea);
|
||||
|
||||
// Hide results after inserting
|
||||
if (tagType === ResultType.wildcardFile) {
|
||||
@@ -383,7 +369,7 @@ function insertTextAtCursor(textArea, result, tagword) {
|
||||
hideBlocked = true;
|
||||
autocomplete(textArea, prompt, sanitizedText);
|
||||
setTimeout(() => { hideBlocked = false; }, 100);
|
||||
} else {
|
||||
} else if (!hideBlocked && isVisible(textArea)) {
|
||||
hideResults(textArea);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user