Skip to content

Commit a4690bd

Browse files
committed
added DragNUWA image canvas node
1 parent b5ab5d1 commit a4690bd

File tree

9 files changed

+661
-9
lines changed

9 files changed

+661
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.js/*
22
json_data/*
3+
js/test.*
34

45
# Byte-compiled / optimized / DLL files
56
__pycache__/

__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"ImageGetter": ImageGetter,
1919
"FlowBuilder": FlowBuilder,
2020
"CachedGetter": CachedGetter,
21+
"DragNUWAImageCanvas": DragNUWAImageCanvas,
2122
}
2223

2324
NODE_DISPLAY_NAME_MAPPINGS = {
@@ -32,6 +33,7 @@
3233
"CachedGetter": "CachedGetter",
3334
"ImageGetter": "ImageGetter",
3435
"FlowBuilder": END_EMOJI + " FlowBuilder",
36+
"DragNUWAImageCanvas": "DragNUWAImageCanvas",
3537
}
3638

3739

js/collor_setting_node.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { app } from '../../scripts/app.js'
2+
import { api } from '../../scripts/api.js'
3+
4+
import { log } from './comfy_shared.js'
5+
6+
7+
class ColorSettingNode {
8+
defaultVisibility = true;
9+
serialize_widgets = true;
10+
constructor() {
11+
if (!this.properties) {
12+
this.properties = {};
13+
}
14+
15+
const node = this;
16+
17+
this.addWidget(
18+
"button",
19+
"Add Color",
20+
"",
21+
() => {
22+
23+
}
24+
)
25+
}
26+
27+
}

js/extension_template.js

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import { ComfyWidgets } from "../../scripts/widgets.js";
2+
import { app } from "../../scripts/app.js";
3+
import * as shared from "./comfy_shared.js";
4+
5+
6+
class DragNUWAImageCanvas extends LiteGraph.LGraghNode {
7+
title = "DragNUWACanvas"
8+
category = "komojini/image"
9+
10+
color = LGraphCanvas.node_colors.yellow.color
11+
bgcolor = LGraphCanvas.node_colors.yellow.bgcolor
12+
groupcolor = LGraphCanvas.node_colors.yellow.groupcolor
13+
14+
constructor() {
15+
super()
16+
this.uuid = shared.makeUUID()
17+
18+
shared.log(`Constructing DRAGNUWACanvas instance`)
19+
20+
this.collapsable = true
21+
this.isVirtualNode = true
22+
this.shape = LiteGraph.BOX_SHAPE
23+
this.serialize_widgets = true
24+
25+
const inner = document.createElement("div")
26+
inner.style.margin = "0"
27+
inner.style.padding = "0"
28+
inner.style.pointerEvents = "none"
29+
30+
this.calculatedHeight = 0
31+
32+
this.htmlWidget = this.addDOMWidget("HTML", "html", inner, {
33+
setValue: (val) => {
34+
this._raw_html = val
35+
},
36+
getValue: () => this._raw_html,
37+
getMinHeight: () => this.calculatedHeight,
38+
hideOnZoom: false,
39+
})
40+
41+
this.setupDialog()
42+
}
43+
44+
setupDialog() {
45+
this.dialog = new app.ui.dialog.constructor()
46+
this.dialog.element.classList.add('comfy-settings')
47+
48+
const closeButton = this.dialog.element.querySelector('button')
49+
closeButton.textContent = 'CANCEL'
50+
const saveButton = document.createElement('button')
51+
saveButton.textContent = 'SAVE'
52+
saveButton.onclick = () => {
53+
this.closeEditorDialog(true)
54+
}
55+
closeButton.onclick = () => {
56+
this.closeEditorDialog(false)
57+
}
58+
closeButton.before(saveButton)
59+
}
60+
61+
openEditorDialog() {
62+
const container = document.createElement("div")
63+
64+
Object.assign(container.style, {
65+
display: 'flex',
66+
gap: '10px',
67+
flexDirection: 'column',
68+
})
69+
70+
const editorsContainer = document.createElement('div')
71+
Object.assign(editorsContainer.style, {
72+
display: 'flex',
73+
gap: '10px',
74+
flexDirection: 'row',
75+
})
76+
77+
container.append(editorsContainer)
78+
79+
this.dialog.show('')
80+
this.dialog.textElement.append(container)
81+
}
82+
83+
onCreate() {}
84+
onNodeCreated() {}
85+
onRemoved() {}
86+
getExtraMenuOptions() {}
87+
setMode(mode) {}
88+
89+
}
90+
91+
const komojiniCanvas = {
92+
name: "komojini.image",
93+
init: async () => {},
94+
setup: () => {},
95+
async beforeRegisterNodeDef(nodeType, nodeData, app) {},
96+
97+
registerCustomNodes() {
98+
99+
LiteGraph.registerNodeType("DragNUWAImageCanvas", DragNUWAImageCanvas)
100+
101+
DragNUWAImageCanvas.title_mode = LiteGraph.NO_TITLE
102+
103+
TestNode.category = "komojini.canvas";
104+
},
105+
}
106+
107+
app.registerExtension(komojiniCanvas)

js/getter_setter_nodes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export class JsSetter {
8787
this.inputs[0].type = type;
8888
this.inputs[0].name = type;
8989

90-
if (app.ui.settings.getSettingValue("KJNodes.nodeAutoColor")){
90+
if (app.ui.settings.getSettingValue("komojini.NodeAutoColor")){
9191
setColorAndBgColor.call(this, type);
9292
}
9393
} else {
@@ -257,7 +257,7 @@ export class JsGetter {
257257
this.setType(linkType);
258258
this.title = "Get_" + setter.widgets[0].value;
259259

260-
if (app.ui.settings.getSettingValue("KJNodes.nodeAutoColor")){
260+
if (app.ui.settings.getSettingValue("komojini.NodeAutoColor")){
261261
setColorAndBgColor.call(this, linkType);
262262
}
263263

0 commit comments

Comments
 (0)