Allow custom words

This commit is contained in:
pythongosssss
2023-08-27 21:24:36 +01:00
parent e35fd2c7fe
commit 4ecef08774
4 changed files with 37 additions and 5 deletions
+18 -1
View File
@@ -41,7 +41,24 @@ app.registerExtension({
TextAreaAutoComplete.updateWords("pysssss.embeddings", words);
}
addEmbeddings();
async function addCustomWords() {
const resp = await api.fetchApi("/pysssss/autocomplete", { cache: "no-store" });
if (resp.status === 200) {
const text = await resp.text();
if (text) {
TextAreaAutoComplete.updateWords(
"pysssss.customwords",
text.split("\n").reduce((p, n) => {
n = n.trim();
p[n] = { text: n };
return p;
}, {})
);
}
}
}
Promise.all([addEmbeddings(), addCustomWords()]);
const STRING = ComfyWidgets.STRING;
ComfyWidgets.STRING = function (node, inputName, inputData) {
-4
View File
@@ -341,23 +341,19 @@ export class TextAreaAutoComplete {
switch (e.key) {
case "ArrowUp":
e.preventDefault();
this.selected.el.classList.remove("pysssss-autocomplete-item--selected");
if (this.selected.index) {
this.#setSelected(this.currentWords[this.selected.index - 1]);
} else {
this.#setSelected(this.currentWords[this.currentWords.length - 1]);
}
this.selected.el.classList.add("pysssss-autocomplete-item--selected");
break;
case "ArrowDown":
e.preventDefault();
this.selected.el.classList.remove("pysssss-autocomplete-item--selected");
if (this.selected.index === this.currentWords.length - 1) {
this.#setSelected(this.currentWords[0]);
} else {
this.#setSelected(this.currentWords[this.selected.index + 1]);
}
this.selected.el.classList.add("pysssss-autocomplete-item--selected");
break;
case "Tab":
e.preventDefault();