Migrate Clipspace to ts (#30)

* rename

* Migrate to ts
This commit is contained in:
Chenlei Hu
2024-06-18 14:05:49 -04:00
committed by GitHub
parent dd81f49ad9
commit 681bb69217
2 changed files with 8 additions and 6 deletions

View File

@@ -20,7 +20,7 @@ export class ClipspaceDialog extends ComfyDialog {
static invalidatePreview() {
if(ComfyApp.clipspace && ComfyApp.clipspace.imgs && ComfyApp.clipspace.imgs.length > 0) {
const img_preview = document.getElementById("clipspace_preview");
const img_preview = document.getElementById("clipspace_preview") as HTMLImageElement;
if(img_preview) {
img_preview.src = ComfyApp.clipspace.imgs[ComfyApp.clipspace['selectedIndex']].src;
img_preview.style.maxHeight = "100%";
@@ -57,7 +57,7 @@ export class ClipspaceDialog extends ComfyDialog {
super();
}
createButtons(self) {
createButtons() {
const buttons = [];
for(let idx in ClipspaceDialog.items) {
@@ -107,7 +107,7 @@ export class ClipspaceDialog extends ComfyDialog {
[
$el("option", {value:'selected'}, 'selected'),
$el("option", {value:'all'}, 'all')
]);
]) as HTMLSelectElement;
combo2.value = ComfyApp.clipspace['img_paste_mode'];
const row2 =
@@ -141,7 +141,7 @@ export class ClipspaceDialog extends ComfyDialog {
show() {
const img_preview = document.getElementById("clipspace_preview");
ClipspaceDialog.invalidate();
this.element.style.display = "block";
}
}
@@ -152,7 +152,7 @@ app.registerExtension({
app.openClipspace =
function () {
if(!ClipspaceDialog.instance) {
ClipspaceDialog.instance = new ClipspaceDialog(app);
ClipspaceDialog.instance = new ClipspaceDialog();
ComfyApp.clipspace_invalidate_handler = ClipspaceDialog.invalidate;
}

View File

@@ -21,7 +21,9 @@ type Props = {
[key: string]: any
};
export function $el(tag: string, propsOrChildren?: string | Element | Element[] | Props, children?: Element[] | Element): HTMLElement {
type Children = Element[] | Element | string | string[];
export function $el(tag: string, propsOrChildren?: Children | Props, children?: Children): HTMLElement {
const split = tag.split(".");
const element = document.createElement(split.shift() as string);
if (split.length > 0) {