mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-11 06:40:48 +08:00
Allow configuring textarea font/text size
This commit is contained in:
parent
5db59edbf6
commit
e9363ebe29
@ -1,6 +1,9 @@
|
|||||||
config:
|
config:
|
||||||
alignToGrid: True
|
alignToGrid: True
|
||||||
gridSize: 20
|
gridSize: 20
|
||||||
|
textArea:
|
||||||
|
fontFamily: monospace
|
||||||
|
fontSize: 14px
|
||||||
paths:
|
paths:
|
||||||
configs: []
|
configs: []
|
||||||
checkpoints: []
|
checkpoints: []
|
||||||
|
|||||||
@ -121,12 +121,7 @@ function onConfig(json) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fetch("config", {cache: "no-store"})
|
function onObjectInfo(json, config) {
|
||||||
.then(response => response.json())
|
|
||||||
.then(json => onConfig(json));
|
|
||||||
|
|
||||||
|
|
||||||
function onObjectInfo(json) {
|
|
||||||
for (let key in json) {
|
for (let key in json) {
|
||||||
function MyNode()
|
function MyNode()
|
||||||
{
|
{
|
||||||
@ -137,7 +132,6 @@ function onObjectInfo(json) {
|
|||||||
min_height = 1;
|
min_height = 1;
|
||||||
min_width = 1;
|
min_width = 1;
|
||||||
for (let x in inp) {
|
for (let x in inp) {
|
||||||
let default_val = min_val = max_val = step_val = multiline = undefined;
|
|
||||||
let opts = {};
|
let opts = {};
|
||||||
if (inp[x].length > 1) {
|
if (inp[x].length > 1) {
|
||||||
opts = inp[x][1];
|
opts = inp[x][1];
|
||||||
@ -146,7 +140,7 @@ function onObjectInfo(json) {
|
|||||||
let type = inp[x][0];
|
let type = inp[x][0];
|
||||||
let widgetClass = COMFY_WIDGETS[type];
|
let widgetClass = COMFY_WIDGETS[type];
|
||||||
if (widgetClass) {
|
if (widgetClass) {
|
||||||
new widgetClass(opts).addWidget(this, x);
|
new widgetClass(opts, config).addWidget(this, x);
|
||||||
} else {
|
} else {
|
||||||
this.addInput(x, type);
|
this.addInput(x, type);
|
||||||
}
|
}
|
||||||
@ -182,10 +176,17 @@ function onObjectInfo(json) {
|
|||||||
// loadGraphData(graph, JSON.parse(base_txt2img_graph));
|
// loadGraphData(graph, JSON.parse(base_txt2img_graph));
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch("object_info", {cache: "no-store"})
|
let pConfig = fetch("config", {cache: "no-store"});
|
||||||
.then(response => response.json())
|
let pObjectInfo = fetch("object_info", {cache: "no-store"});
|
||||||
.then(json => onObjectInfo(json));
|
Promise.all([pConfig, pObjectInfo])
|
||||||
|
.then(results => Promise.all(results.map(r => r.json())))
|
||||||
|
.then(results => {
|
||||||
|
config = results[0];
|
||||||
|
objectInfo = results[1];
|
||||||
|
onConfig(config);
|
||||||
|
console.log(objectInfo);
|
||||||
|
onObjectInfo(objectInfo, config);
|
||||||
|
});
|
||||||
|
|
||||||
//register in the system
|
//register in the system
|
||||||
graph.start();
|
graph.start();
|
||||||
|
|||||||
@ -8,7 +8,7 @@ class BaseWidget {
|
|||||||
|
|
||||||
|
|
||||||
class IntWidget extends BaseWidget {
|
class IntWidget extends BaseWidget {
|
||||||
constructor(opts) {
|
constructor(opts, config) {
|
||||||
super();
|
super();
|
||||||
this.default_val = opts['default'] || 0;
|
this.default_val = opts['default'] || 0;
|
||||||
this.min_val = opts['min'] || 0;
|
this.min_val = opts['min'] || 0;
|
||||||
@ -34,7 +34,7 @@ COMFY_WIDGETS["INT"] = IntWidget;
|
|||||||
|
|
||||||
|
|
||||||
class FloatWidget extends BaseWidget {
|
class FloatWidget extends BaseWidget {
|
||||||
constructor(opts) {
|
constructor(opts, config) {
|
||||||
super();
|
super();
|
||||||
this.default_val = opts['default'] || 0;
|
this.default_val = opts['default'] || 0;
|
||||||
this.min_val = opts['min'] || 0;
|
this.min_val = opts['min'] || 0;
|
||||||
@ -55,10 +55,12 @@ COMFY_WIDGETS["FLOAT"] = FloatWidget;
|
|||||||
|
|
||||||
|
|
||||||
class StringWidget extends BaseWidget {
|
class StringWidget extends BaseWidget {
|
||||||
constructor(opts) {
|
constructor(opts, config) {
|
||||||
super();
|
super();
|
||||||
this.default_val = opts['default'] || "";
|
this.default_val = opts['default'] || "";
|
||||||
this.multiline = opts['multiline'] || false;
|
this.multiline = opts['multiline'] || false;
|
||||||
|
this.fontFamily = config["textArea"]["fontFamily"];
|
||||||
|
this.fontSize = config["textArea"]["fontSize"] || 10.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
addWidget(node, x) {
|
addWidget(node, x) {
|
||||||
@ -85,7 +87,7 @@ class StringWidget extends BaseWidget {
|
|||||||
this.input_div.style.height = height_div;
|
this.input_div.style.height = height_div;
|
||||||
this.input_div.style.position = 'absolute';
|
this.input_div.style.position = 'absolute';
|
||||||
this.input_div.style.zIndex = 1;
|
this.input_div.style.zIndex = 1;
|
||||||
this.input_div.style.fontSize = t.d * 10.0;
|
this.input_div.style.fontSize = t.d * this.fontSize;
|
||||||
|
|
||||||
if (show_text) {
|
if (show_text) {
|
||||||
this.input_div.hidden = false;
|
this.input_div.hidden = false;
|
||||||
@ -104,6 +106,9 @@ class StringWidget extends BaseWidget {
|
|||||||
w.input_div.style.overflow = 'hidden';
|
w.input_div.style.overflow = 'hidden';
|
||||||
w.input_div.style.overflowY = 'auto';
|
w.input_div.style.overflowY = 'auto';
|
||||||
w.input_div.style.padding = 2;
|
w.input_div.style.padding = 2;
|
||||||
|
if (this.fontFamily) {
|
||||||
|
w.input_div.style.fontFamily = this.fontFamily;
|
||||||
|
}
|
||||||
w.input_div.innerText = this.default_val;
|
w.input_div.innerText = this.default_val;
|
||||||
document.addEventListener('click', function(event) {
|
document.addEventListener('click', function(event) {
|
||||||
if (!w.input_div.contains(event.target)) {
|
if (!w.input_div.contains(event.target)) {
|
||||||
@ -149,7 +154,7 @@ COMFY_WIDGETS["STRING"] = StringWidget;
|
|||||||
|
|
||||||
|
|
||||||
class ComboWidget extends BaseWidget {
|
class ComboWidget extends BaseWidget {
|
||||||
constructor(opts) {
|
constructor(opts, config) {
|
||||||
super();
|
super();
|
||||||
this.choices = opts['choices'] || [];
|
this.choices = opts['choices'] || [];
|
||||||
}
|
}
|
||||||
@ -163,7 +168,7 @@ COMFY_WIDGETS["COMBO"] = ComboWidget;
|
|||||||
|
|
||||||
|
|
||||||
class RegionWidget extends BaseWidget {
|
class RegionWidget extends BaseWidget {
|
||||||
constructor(opts) {
|
constructor(opts, config) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user