-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathpinNodes.js
49 lines (45 loc) · 1.22 KB
/
pinNodes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* Coded with love by Failfa.st
* LICENSE: AGPL 3.0
* https://github.com/failfa-st/failfast-comfyui-extensions/blob/main/LICENSE
*
* Visit https://github.com/failfa-st/failfast-comfyui-extensions for more info
*
* Homepage: https://failfa.st
* GitHub: https://github.com/failfa-st
* Discord: https://discord.com/invite/m3TBB9XEkb
*/
import { app } from "/scripts/app.js";
/**
* Pin/Unpin all nodes on canvas
*/
const pinNodesName = "Failfast.pinNodes";
app.registerExtension({
name: pinNodesName,
async setup(app) {
const getCanvasMenuOptions = LGraphCanvas.prototype.getCanvasMenuOptions;
LGraphCanvas.prototype.getCanvasMenuOptions = function () {
const menuOptions = getCanvasMenuOptions.apply(this, arguments);
menuOptions.push(
null,
{
content: "Pin all Nodes",
callback: () => {
app.graph._nodes.forEach((node) => {
node.flags.pinned = true;
});
},
},
{
content: "Unpin all Nodes",
callback: () => {
app.graph._nodes.forEach((node) => {
node.flags.pinned = false;
});
},
}
);
return menuOptions;
};
},
});