Merge remote-tracking branch 'origin/master' into menu-save-and-anchor

This commit is contained in:
pythongosssss
2023-03-28 09:53:55 +01:00
5 changed files with 381 additions and 28 deletions

View File

@@ -1,6 +1,6 @@
import { api } from "./api.js";
function $el(tag, propsOrChildren, children) {
export function $el(tag, propsOrChildren, children) {
const split = tag.split(".");
const element = document.createElement(split.shift());
element.classList.add(...split);
@@ -193,6 +193,17 @@ class ComfySettingsDialog extends ComfyDialog {
this.settings = [];
}
getSettingValue(id, defaultValue) {
const settingId = "Comfy.Settings." + id;
const v = localStorage[settingId];
return v == null ? defaultValue : JSON.parse(v);
}
setSettingValue(id, value) {
const settingId = "Comfy.Settings." + id;
localStorage[settingId] = JSON.stringify(value);
}
addSetting({ id, name, type, defaultValue, onChange }) {
if (!id) {
throw new Error("Settings must have an ID");
@@ -221,7 +232,7 @@ class ComfySettingsDialog extends ComfyDialog {
};
if (typeof type === "function") {
return type(name, setter);
return type(name, setter, value);
}
switch (type) {