Allow custom words
This commit is contained in:
+18
-1
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user