mirror of
https://github.com/DominikDoom/a1111-sd-webui-tagcomplete.git
synced 2026-01-26 11:09:54 +00:00
Extract wildcard keep open as well
This commit is contained in:
@@ -25,6 +25,7 @@ var resultCount = 0;
|
||||
var previousTags = [];
|
||||
var tagword = "";
|
||||
var originalTagword = "";
|
||||
let hideBlocked = false;
|
||||
|
||||
// Tag selection for keyboard navigation
|
||||
var selectedTag = null;
|
||||
|
||||
@@ -183,7 +183,7 @@ class UmiParser extends BaseTagParser {
|
||||
}
|
||||
}
|
||||
|
||||
function updateUmiTags(tagType, newPrompt, textArea) {
|
||||
function updateUmiTags( tagType, sanitizedText, 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)];
|
||||
@@ -196,7 +196,10 @@ function updateUmiTags(tagType, newPrompt, textArea) {
|
||||
umiPreviousTags = umiTags;
|
||||
|
||||
hideResults(textArea);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add UMI parser
|
||||
|
||||
@@ -55,6 +55,20 @@ class WildcardFileParser extends BaseTagParser {
|
||||
}
|
||||
}
|
||||
|
||||
function keepOpenIfWildcard(tagType, sanitizedText, newPrompt, textArea) {
|
||||
// If it's a wildcard, we want to keep the results open so the user can select another wildcard
|
||||
if (tagType === ResultType.wildcardFile) {
|
||||
hideBlocked = true;
|
||||
autocomplete(textArea, newPrompt, sanitizedText);
|
||||
setTimeout(() => { hideBlocked = false; }, 100);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Register the parsers
|
||||
PARSERS.push(new WildcardParser(WC_TRIGGER));
|
||||
PARSERS.push(new WildcardFileParser(WC_FILE_TRIGGER));
|
||||
PARSERS.push(new WildcardFileParser(WC_FILE_TRIGGER));
|
||||
|
||||
// Add the keep open function to the queue
|
||||
QUEUE_AFTER_INSERT.push(keepOpenIfWildcard);
|
||||
@@ -288,10 +288,8 @@ function isEnabled() {
|
||||
const WEIGHT_REGEX = /[([]([^,()[\]:| ]+)(?::(?:\d+(?:\.\d+)?|\.\d+))?[)\]]/g;
|
||||
const TAG_REGEX = /(<[^\t\n\r,>]+>?|[^\s,|<>]+|<)/g
|
||||
|
||||
let hideBlocked = false;
|
||||
|
||||
// On click, insert the tag into the prompt textbox with respect to the cursor position
|
||||
function insertTextAtCursor(textArea, result, tagword) {
|
||||
async function insertTextAtCursor(textArea, result, tagword) {
|
||||
let text = result.text;
|
||||
let tagType = result.type;
|
||||
|
||||
@@ -361,15 +359,13 @@ function insertTextAtCursor(textArea, result, tagword) {
|
||||
previousTags = tags;
|
||||
|
||||
// Callback
|
||||
processQueue(QUEUE_AFTER_INSERT, null, tagType, newPrompt, textArea);
|
||||
let returns = await processQueueReturn(QUEUE_AFTER_INSERT, null, tagType, sanitizedText, newPrompt, textArea);
|
||||
// Return if any queue function returned true (has handled hide/show already)
|
||||
if (returns.some(x => x === true))
|
||||
return;
|
||||
|
||||
// Hide results after inserting
|
||||
if (tagType === ResultType.wildcardFile) {
|
||||
// If it's a wildcard, we want to keep the results open so the user can select another wildcard
|
||||
hideBlocked = true;
|
||||
autocomplete(textArea, prompt, sanitizedText);
|
||||
setTimeout(() => { hideBlocked = false; }, 100);
|
||||
} else if (!hideBlocked && isVisible(textArea)) {
|
||||
// Hide results after inserting, if it hasn't been hidden already by a queue function
|
||||
if (!hideBlocked && isVisible(textArea)) {
|
||||
hideResults(textArea);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user