Allow configuring textarea font/text size

This commit is contained in:
space-nuko 2023-02-12 01:31:59 -08:00
parent 5db59edbf6
commit e9363ebe29
3 changed files with 27 additions and 18 deletions

View File

@ -1,6 +1,9 @@
config:
alignToGrid: True
gridSize: 20
textArea:
fontFamily: monospace
fontSize: 14px
paths:
configs: []
checkpoints: []

View File

@ -121,12 +121,7 @@ function onConfig(json) {
}
fetch("config", {cache: "no-store"})
.then(response => response.json())
.then(json => onConfig(json));
function onObjectInfo(json) {
function onObjectInfo(json, config) {
for (let key in json) {
function MyNode()
{
@ -137,7 +132,6 @@ function onObjectInfo(json) {
min_height = 1;
min_width = 1;
for (let x in inp) {
let default_val = min_val = max_val = step_val = multiline = undefined;
let opts = {};
if (inp[x].length > 1) {
opts = inp[x][1];
@ -146,7 +140,7 @@ function onObjectInfo(json) {
let type = inp[x][0];
let widgetClass = COMFY_WIDGETS[type];
if (widgetClass) {
new widgetClass(opts).addWidget(this, x);
new widgetClass(opts, config).addWidget(this, x);
} else {
this.addInput(x, type);
}
@ -182,10 +176,17 @@ function onObjectInfo(json) {
// loadGraphData(graph, JSON.parse(base_txt2img_graph));
}
fetch("object_info", {cache: "no-store"})
.then(response => response.json())
.then(json => onObjectInfo(json));
let pConfig = fetch("config", {cache: "no-store"});
let pObjectInfo = fetch("object_info", {cache: "no-store"});
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
graph.start();

View File

@ -8,7 +8,7 @@ class BaseWidget {
class IntWidget extends BaseWidget {
constructor(opts) {
constructor(opts, config) {
super();
this.default_val = opts['default'] || 0;
this.min_val = opts['min'] || 0;
@ -34,7 +34,7 @@ COMFY_WIDGETS["INT"] = IntWidget;
class FloatWidget extends BaseWidget {
constructor(opts) {
constructor(opts, config) {
super();
this.default_val = opts['default'] || 0;
this.min_val = opts['min'] || 0;
@ -55,10 +55,12 @@ COMFY_WIDGETS["FLOAT"] = FloatWidget;
class StringWidget extends BaseWidget {
constructor(opts) {
constructor(opts, config) {
super();
this.default_val = opts['default'] || "";
this.multiline = opts['multiline'] || false;
this.fontFamily = config["textArea"]["fontFamily"];
this.fontSize = config["textArea"]["fontSize"] || 10.0;
}
addWidget(node, x) {
@ -85,7 +87,7 @@ class StringWidget extends BaseWidget {
this.input_div.style.height = height_div;
this.input_div.style.position = 'absolute';
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) {
this.input_div.hidden = false;
@ -104,6 +106,9 @@ class StringWidget extends BaseWidget {
w.input_div.style.overflow = 'hidden';
w.input_div.style.overflowY = 'auto';
w.input_div.style.padding = 2;
if (this.fontFamily) {
w.input_div.style.fontFamily = this.fontFamily;
}
w.input_div.innerText = this.default_val;
document.addEventListener('click', function(event) {
if (!w.input_div.contains(event.target)) {
@ -149,7 +154,7 @@ COMFY_WIDGETS["STRING"] = StringWidget;
class ComboWidget extends BaseWidget {
constructor(opts) {
constructor(opts, config) {
super();
this.choices = opts['choices'] || [];
}
@ -163,7 +168,7 @@ COMFY_WIDGETS["COMBO"] = ComboWidget;
class RegionWidget extends BaseWidget {
constructor(opts) {
constructor(opts, config) {
super();
}