Update contextmenu.js

This commit is contained in:
kijai 2025-03-15 11:33:08 +02:00
parent 51e792ccdf
commit 02c76c88b4

View File

@ -48,11 +48,28 @@ app.registerExtension({
} }
}, },
async setup(app) { async setup(app) {
const onChange = (value) => { const updateSlots = (value) => {
if (value!="disabled") { const valuesToAddToIn = ["GetNode"];
const valuesToAddToIn = ["GetNode"]; const valuesToAddToOut = ["SetNode"];
const valuesToAddToOut = ["SetNode"]; // Remove entries if they exist
for (const arr of Object.values(LiteGraph.slot_types_default_in)) {
for (const valueToAdd of valuesToAddToIn) {
const idx = arr.indexOf(valueToAdd);
if (idx !== -1) {
arr.splice(idx, 1);
}
}
}
for (const arr of Object.values(LiteGraph.slot_types_default_out)) {
for (const valueToAdd of valuesToAddToOut) {
const idx = arr.indexOf(valueToAdd);
if (idx !== -1) {
arr.splice(idx, 1);
}
}
}
if (value!="disabled") {
for (const arr of Object.values(LiteGraph.slot_types_default_in)) { for (const arr of Object.values(LiteGraph.slot_types_default_in)) {
for (const valueToAdd of valuesToAddToIn) { for (const valueToAdd of valuesToAddToIn) {
const idx = arr.indexOf(valueToAdd); const idx = arr.indexOf(valueToAdd);
@ -90,7 +107,7 @@ app.registerExtension({
options: ['disabled', 'top', 'bottom'], options: ['disabled', 'top', 'bottom'],
defaultValue: 'disabled', defaultValue: 'disabled',
type: "combo", type: "combo",
onChange: onChange, onChange: updateSlots,
}); });
app.ui.settings.addSetting({ app.ui.settings.addSetting({