Fix the original missing menu options

This commit is contained in:
johnqiao 2023-11-24 19:06:40 -07:00
parent 355991ecc9
commit e32072ab34

View File

@ -766,10 +766,19 @@ app.registerExtension({
}, },
_addExtraNodeContextMenu(node, app) { _addExtraNodeContextMenu(node, app) {
node.prototype.getExtraMenuOptions = function (_, options) { const origGetExtraMenuOptions = node.prototype.getExtraMenuOptions;
if (isOutputNode(node)) { node.prototype.getExtraMenuOptions = function (_, options) {
origGetExtraMenuOptions?.apply?.(this, arguments);
if (isOutputNode(node)) {
const { potential_outputs } = getPotentialOutputsAndOutputNodes([this]); const { potential_outputs } = getPotentialOutputsAndOutputNodes([this]);
const hasOutput = potential_outputs.length > 0; const hasOutput = potential_outputs.length > 0;
// Check if the previous menu option is `null`. If it's not,
// then we need to add a `null` as a separator.
if (options[options.length - 1] !== null) {
options.push(null);
}
options.push({ options.push({
content: "🏞️ Share Output", content: "🏞️ Share Output",
disabled: !hasOutput, disabled: !hasOutput,
@ -793,6 +802,6 @@ app.registerExtension({
} }
}, null); }, null);
} }
} }
}, },
}); });