Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new TS frontend #4375

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions web/assets/index-Bln5LBF6.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions web/assets/index-Bln5LBF6.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions web/assets/index-CdKLK0Jn.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions web/assets/index-DEXCSpmt.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4,370 changes: 4,370 additions & 0 deletions web/assets/index-Dj_yIC5Q.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions web/assets/index-Dj_yIC5Q.js.map

Large diffs are not rendered by default.

Binary file added web/assets/primeicons-C6QP2o4f.woff2
Binary file not shown.
Binary file added web/assets/primeicons-DMOk5skT.eot
Binary file not shown.
345 changes: 345 additions & 0 deletions web/assets/primeicons-Dr5RGzOO.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/assets/primeicons-MpK4pl85.ttf
Binary file not shown.
Binary file added web/assets/primeicons-WjwUDZjB.woff
Binary file not shown.
1 change: 1 addition & 0 deletions web/assets/userSelection-CL2rbEda.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions web/assets/userSelection-Dh-tiIjz.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions web/assets/userSelection-Dh-tiIjz.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

168 changes: 2 additions & 166 deletions web/extensions/core/clipspace.js
Original file line number Diff line number Diff line change
@@ -1,166 +1,2 @@
import { app } from "../../scripts/app.js";
import { ComfyDialog, $el } from "../../scripts/ui.js";
import { ComfyApp } from "../../scripts/app.js";

export class ClipspaceDialog extends ComfyDialog {
static items = [];
static instance = null;

static registerButton(name, contextPredicate, callback) {
const item =
$el("button", {
type: "button",
textContent: name,
contextPredicate: contextPredicate,
onclick: callback
})

ClipspaceDialog.items.push(item);
}

static invalidatePreview() {
if(ComfyApp.clipspace && ComfyApp.clipspace.imgs && ComfyApp.clipspace.imgs.length > 0) {
const img_preview = document.getElementById("clipspace_preview");
if(img_preview) {
img_preview.src = ComfyApp.clipspace.imgs[ComfyApp.clipspace['selectedIndex']].src;
img_preview.style.maxHeight = "100%";
img_preview.style.maxWidth = "100%";
}
}
}

static invalidate() {
if(ClipspaceDialog.instance) {
const self = ClipspaceDialog.instance;
// allow reconstruct controls when copying from non-image to image content.
const children = $el("div.comfy-modal-content", [ self.createImgSettings(), ...self.createButtons() ]);

if(self.element) {
// update
self.element.removeChild(self.element.firstChild);
self.element.appendChild(children);
}
else {
// new
self.element = $el("div.comfy-modal", { parent: document.body }, [children,]);
}

if(self.element.children[0].children.length <= 1) {
self.element.children[0].appendChild($el("p", {}, ["Unable to find the features to edit content of a format stored in the current Clipspace."]));
}

ClipspaceDialog.invalidatePreview();
}
}

constructor() {
super();
}

createButtons(self) {
const buttons = [];

for(let idx in ClipspaceDialog.items) {
const item = ClipspaceDialog.items[idx];
if(!item.contextPredicate || item.contextPredicate())
buttons.push(ClipspaceDialog.items[idx]);
}

buttons.push(
$el("button", {
type: "button",
textContent: "Close",
onclick: () => { this.close(); }
})
);

return buttons;
}

createImgSettings() {
if(ComfyApp.clipspace.imgs) {
const combo_items = [];
const imgs = ComfyApp.clipspace.imgs;

for(let i=0; i < imgs.length; i++) {
combo_items.push($el("option", {value:i}, [`${i}`]));
}

const combo1 = $el("select",
{id:"clipspace_img_selector", onchange:(event) => {
ComfyApp.clipspace['selectedIndex'] = event.target.selectedIndex;
ClipspaceDialog.invalidatePreview();
} }, combo_items);

const row1 =
$el("tr", {},
[
$el("td", {}, [$el("font", {color:"white"}, ["Select Image"])]),
$el("td", {}, [combo1])
]);


const combo2 = $el("select",
{id:"clipspace_img_paste_mode", onchange:(event) => {
ComfyApp.clipspace['img_paste_mode'] = event.target.value;
} },
[
$el("option", {value:'selected'}, 'selected'),
$el("option", {value:'all'}, 'all')
]);
combo2.value = ComfyApp.clipspace['img_paste_mode'];

const row2 =
$el("tr", {},
[
$el("td", {}, [$el("font", {color:"white"}, ["Paste Mode"])]),
$el("td", {}, [combo2])
]);

const td = $el("td", {align:'center', width:'100px', height:'100px', colSpan:'2'},
[ $el("img",{id:"clipspace_preview", ondragstart:() => false},[]) ]);

const row3 =
$el("tr", {}, [td]);

return $el("table", {}, [row1, row2, row3]);
}
else {
return [];
}
}

createImgPreview() {
if(ComfyApp.clipspace.imgs) {
return $el("img",{id:"clipspace_preview", ondragstart:() => false});
}
else
return [];
}

show() {
const img_preview = document.getElementById("clipspace_preview");
ClipspaceDialog.invalidate();

this.element.style.display = "block";
}
}

app.registerExtension({
name: "Comfy.Clipspace",
init(app) {
app.openClipspace =
function () {
if(!ClipspaceDialog.instance) {
ClipspaceDialog.instance = new ClipspaceDialog(app);
ComfyApp.clipspace_invalidate_handler = ClipspaceDialog.invalidate;
}

if(ComfyApp.clipspace) {
ClipspaceDialog.instance.show();
}
else
app.ui.dialog.show("Clipspace is Empty!");
};
}
});
// Shim for extensions/core/clipspace.ts
export const ClipspaceDialog = window.comfyAPI.clipspace.ClipspaceDialog;
Loading
Loading