mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-14 15:32:35 +08:00
export toggles
This commit is contained in:
parent
5335249cd4
commit
6cae80e402
@ -57,7 +57,7 @@ app.registerExtension({
|
|||||||
node.subflow = subflow;
|
node.subflow = subflow;
|
||||||
};
|
};
|
||||||
|
|
||||||
// node.onSerialize = () =>
|
node.onAdded = () => refreshPins(node.widgets[0].value);
|
||||||
node.onConfigure = () => refreshPins(node.widgets[0].value);
|
node.onConfigure = () => refreshPins(node.widgets[0].value);
|
||||||
node.widgets[0].callback = (subflowName) => refreshPins(subflowName);
|
node.widgets[0].callback = (subflowName) => refreshPins(subflowName);
|
||||||
|
|
||||||
|
|||||||
@ -12957,9 +12957,9 @@ LGraphNode.prototype.executeAction = function(action)
|
|||||||
throw "no node passed";
|
throw "no node passed";
|
||||||
}
|
}
|
||||||
|
|
||||||
const getOption = ({ name, type }, pinType) => {
|
const getOption = ({ name, type, isExported }, pinType) => {
|
||||||
const color = LGraphCanvas.link_type_colors[type];
|
const color = LGraphCanvas.link_type_colors[type];
|
||||||
const innerHtml = `<span style='display: block; padding-left: 4px; background-color: ${color}; color: white'>${name}</span>`;
|
const innerHtml = `<span style='display: block; padding-left: 4px; color: ${color};'>${name}${isExported ? " (exported)" : ""} </span>`;
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
type: pinType,
|
type: pinType,
|
||||||
@ -12970,16 +12970,16 @@ LGraphNode.prototype.executeAction = function(action)
|
|||||||
let inputs = node.inputs ?? [];
|
let inputs = node.inputs ?? [];
|
||||||
let outputs = node.outputs ?? [];
|
let outputs = node.outputs ?? [];
|
||||||
if (node.properties?.exports?.inputs) {
|
if (node.properties?.exports?.inputs) {
|
||||||
inputs = inputs.filter(({name}) => !node.properties.exports.inputs.includes(name));
|
inputs = inputs.map( input => ( {...input, isExported: node.properties.exports.inputs.includes(input.name) }) );
|
||||||
}
|
}
|
||||||
if (node.properties?.exports?.outputs) {
|
if (node.properties?.exports?.outputs) {
|
||||||
outputs = outputs.filter(({name}) => !node.properties.exports.outputs.includes(name));
|
outputs = outputs.map( output => ( {...output, isExported: node.properties.exports.outputs.includes(output.name) }) );
|
||||||
}
|
}
|
||||||
|
|
||||||
const exportableVars = [
|
const exportableVars = [
|
||||||
...inputs.map((node) => getOption(node, "input")),
|
...inputs.map((input) => getOption(input, "input")),
|
||||||
null,
|
null,
|
||||||
...outputs.map((node) => getOption(node, "output")),
|
...outputs.map((output) => getOption(output, "output")),
|
||||||
];
|
];
|
||||||
new LiteGraph.ContextMenu(exportableVars, {
|
new LiteGraph.ContextMenu(exportableVars, {
|
||||||
event: e,
|
event: e,
|
||||||
@ -12999,11 +12999,19 @@ LGraphNode.prototype.executeAction = function(action)
|
|||||||
node.properties.exports = { inputs: [], outputs: [] };
|
node.properties.exports = { inputs: [], outputs: [] };
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(v);
|
const toggle = (arr, val) => {
|
||||||
|
if (arr.includes(val)) {
|
||||||
|
const i = arr.indexOf(val);
|
||||||
|
arr.splice(i, 1);
|
||||||
|
} else {
|
||||||
|
arr.push(val);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (v.type == "input") {
|
if (v.type == "input") {
|
||||||
node.properties.exports.inputs.push(v.name);
|
toggle(node.properties.exports.inputs, v.name);
|
||||||
} else if (v.type == "output") {
|
} else if (v.type == "output") {
|
||||||
node.properties.exports.outputs.push(v.name);
|
toggle(node.properties.exports.outputs, v.name);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
exportVar();
|
exportVar();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user