mirror of
https://github.com/DominikDoom/a1111-sd-webui-tagcomplete.git
synced 2026-01-26 19:19:57 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
40d53d89d1 | ||
|
|
c733b836e8 |
@@ -367,7 +367,6 @@ function updateSelectionStyle(textArea, newIndex, oldIndex) {
|
||||
|
||||
var wildcardFiles = [];
|
||||
var wildcardExtFiles = [];
|
||||
var wildcards = {};
|
||||
var embeddings = [];
|
||||
var allTags = [];
|
||||
var results = [];
|
||||
@@ -408,12 +407,24 @@ function autocomplete(textArea, prompt, fixedTag = null) {
|
||||
|
||||
tagword = tagword.toLowerCase();
|
||||
|
||||
if (acConfig.useWildcards && [...tagword.matchAll(/\b__([^,_ ]+)__([^, ]*)\b/g)].length > 0) {
|
||||
if (acConfig.useWildcards && [...tagword.matchAll(/\b__([^, ]+)__([^, ]*)\b/g)].length > 0) {
|
||||
// Show wildcards from a file with that name
|
||||
wcMatch = [...tagword.matchAll(/\b__([^,_ ]+)__([^, ]*)\b/g)]
|
||||
wcMatch = [...tagword.matchAll(/\b__([^, ]+)__([^, ]*)\b/g)]
|
||||
let wcFile = wcMatch[0][1];
|
||||
let wcWord = wcMatch[0][2];
|
||||
results = wildcards[wcFile].filter(x => (wcWord !== null) ? x.toLowerCase().includes(wcWord) : x) // Filter by tagword
|
||||
|
||||
let wcBasePath = "";
|
||||
if (wildcardExtFiles.includes(wcFile))
|
||||
wcBasePath = "extensions/wildcards/wildcards";
|
||||
else if (wildcardFiles.includes(wcFile))
|
||||
wcBasePath = "scripts/wildcards";
|
||||
else
|
||||
throw "No valid wildcard file found";
|
||||
|
||||
let wildcards = readFile(`file/${wcBasePath}/${wcFile}.txt`).split("\n")
|
||||
.filter(x => x.trim().length > 0); // Remove empty lines
|
||||
|
||||
results = wildcards.filter(x => (wcWord !== null && wcWord.length > 0) ? x.toLowerCase().includes(wcWord) : x) // Filter by tagword
|
||||
.map(x => [wcFile + ": " + x.trim(), "wildcardTag"]); // Mark as wildcard
|
||||
} else if (acConfig.useWildcards && (tagword.startsWith("__") && !tagword.endsWith("__") || tagword === "__")) {
|
||||
// Show available wildcard files
|
||||
@@ -607,23 +618,6 @@ onUiUpdate(function () {
|
||||
wildcardExtFiles = readFile("file/tags/temp/wce.txt").split("\n")
|
||||
.filter(x => x.trim().length > 0) // Remove empty lines
|
||||
.map(x => x.trim().replace(".txt", "")); // Remove file extension & newlines
|
||||
|
||||
wildcardFiles.forEach(fName => {
|
||||
try {
|
||||
wildcards[fName] = readFile(`file/scripts/wildcards/${fName}.txt`).split("\n")
|
||||
.filter(x => x.trim().length > 0); // Remove empty lines
|
||||
} catch (e) {
|
||||
console.log(`Could not load wildcards for ${fName}`);
|
||||
}
|
||||
});
|
||||
wildcardExtFiles.forEach(fName => {
|
||||
try {
|
||||
wildcards[fName] = readFile(`file/extensions/wildcards/wildcards/${fName}.txt`).split("\n")
|
||||
.filter(x => x.trim().length > 0); // Remove empty lines
|
||||
} catch (e) {
|
||||
console.log(`Could not load wildcards for ${fName}`);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.error("Error loading wildcards: " + e);
|
||||
}
|
||||
|
||||
@@ -15,13 +15,13 @@ TEMP_PATH = FILE_DIR.joinpath('tags/temp')
|
||||
def get_wildcards():
|
||||
"""Returns a list of all wildcards. Works on nested folders."""
|
||||
wildcard_files = list(WILDCARD_PATH.rglob("*.txt"))
|
||||
resolved = [str(w.relative_to(WILDCARD_PATH)) for w in wildcard_files if w.name != "put wildcards here.txt"]
|
||||
resolved = [w.relative_to(WILDCARD_PATH).as_posix() for w in wildcard_files if w.name != "put wildcards here.txt"]
|
||||
return resolved
|
||||
|
||||
def get_ext_wildcards():
|
||||
"""Returns a list of all extension wildcards. Works on nested folders."""
|
||||
wildcard_files = list(WILDCARD_EXT_PATH.rglob("*.txt"))
|
||||
resolved = [str(w.relative_to(WILDCARD_EXT_PATH)) for w in wildcard_files if w.name != "put wildcards here.txt"]
|
||||
resolved = [w.relative_to(WILDCARD_EXT_PATH).as_posix() for w in wildcard_files if w.name != "put wildcards here.txt"]
|
||||
return resolved
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user