mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-13 17:10:06 +00:00
Migrate misc (#38)
This commit is contained in:
@@ -8,6 +8,7 @@ app.registerExtension({
|
||||
init() {
|
||||
const ctxMenu = LiteGraph.ContextMenu;
|
||||
const replace = () => {
|
||||
// @ts-ignore
|
||||
LiteGraph.ContextMenu = function (values, options) {
|
||||
options = options || {};
|
||||
if (options.scroll_speed) {
|
||||
@@ -40,7 +40,7 @@ app.registerExtension({
|
||||
|
||||
// Close out of modals using escape
|
||||
if (event.key === "Escape") {
|
||||
const modals = document.querySelectorAll(".comfy-modal");
|
||||
const modals = document.querySelectorAll<HTMLElement>(".comfy-modal");
|
||||
const modal = Array.from(modals).find(modal => window.getComputedStyle(modal).getPropertyValue("display") !== "none");
|
||||
if (modal) {
|
||||
modal.style.display = "none";
|
||||
@@ -9,6 +9,7 @@ const ext = {
|
||||
name: "Link Render Mode",
|
||||
defaultValue: 2,
|
||||
type: "combo",
|
||||
// @ts-ignore
|
||||
options: [...LiteGraph.LINK_RENDER_MODES, "Hidden"].map((m, i) => ({
|
||||
value: i,
|
||||
text: m,
|
||||
@@ -6,15 +6,26 @@ app.registerExtension({
|
||||
name: "Comfy.NoteNode",
|
||||
registerCustomNodes() {
|
||||
class NoteNode {
|
||||
static category: string;
|
||||
|
||||
// @ts-ignore
|
||||
color=LGraphCanvas.node_colors.yellow.color;
|
||||
// @ts-ignore
|
||||
bgcolor=LGraphCanvas.node_colors.yellow.bgcolor;
|
||||
// @ts-ignore
|
||||
groupcolor = LGraphCanvas.node_colors.yellow.groupcolor;
|
||||
properties: { text: string };
|
||||
serialize_widgets: boolean;
|
||||
isVirtualNode: boolean;
|
||||
collapsable: boolean;
|
||||
title_mode: number;
|
||||
|
||||
constructor() {
|
||||
if (!this.properties) {
|
||||
this.properties = {};
|
||||
this.properties.text="";
|
||||
this.properties = { text: "" };
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
// Should we extends LGraphNode?
|
||||
ComfyWidgets.STRING(this, "", ["", {default:this.properties.text, multiline: true}], app)
|
||||
|
||||
this.serialize_widgets = true;
|
||||
@@ -29,6 +40,7 @@ app.registerExtension({
|
||||
|
||||
LiteGraph.registerNodeType(
|
||||
"Note",
|
||||
// @ts-ignore
|
||||
Object.assign(NoteNode, {
|
||||
title_mode: LiteGraph.NORMAL_TITLE,
|
||||
title: "Note",
|
||||
@@ -35,19 +35,22 @@ app.registerExtension({
|
||||
true
|
||||
);
|
||||
|
||||
app.canvasEl.addEventListener("touchend", (e) => {
|
||||
app.canvasEl.addEventListener("touchend", (e: TouchEvent) => {
|
||||
touchZooming = false;
|
||||
touchCount = e.touches?.length ?? touchCount - 1;
|
||||
if (touchTime && !e.touches?.length) {
|
||||
if (new Date() - touchTime > 600) {
|
||||
if ((new Date()).getTime() - touchTime > 600) {
|
||||
try {
|
||||
// hack to get litegraph to use this event
|
||||
e.constructor = CustomEvent;
|
||||
} catch (error) {}
|
||||
// @ts-ignore
|
||||
e.clientX = lastTouch.clientX;
|
||||
// @ts-ignore
|
||||
e.clientY = lastTouch.clientY;
|
||||
|
||||
app.canvas.pointer_is_down = true;
|
||||
// @ts-ignore
|
||||
app.canvas._mousedown_callback(e);
|
||||
}
|
||||
touchTime = null;
|
||||
@@ -61,7 +64,9 @@ app.registerExtension({
|
||||
if (e.touches?.length === 2) {
|
||||
app.canvas.pointer_is_down = false;
|
||||
touchZooming = true;
|
||||
// @ts-ignore
|
||||
LiteGraph.closeAllContextMenus();
|
||||
// @ts-ignore
|
||||
app.canvas.search_box?.close();
|
||||
const newZoomPos = getMultiTouchPos(e);
|
||||
|
||||
@@ -85,7 +90,9 @@ app.registerExtension({
|
||||
},
|
||||
});
|
||||
|
||||
// @ts-ignore
|
||||
const processMouseDown = LGraphCanvas.prototype.processMouseDown;
|
||||
// @ts-ignore
|
||||
LGraphCanvas.prototype.processMouseDown = function (e) {
|
||||
if (touchZooming || touchCount) {
|
||||
return;
|
||||
@@ -93,7 +100,9 @@ LGraphCanvas.prototype.processMouseDown = function (e) {
|
||||
return processMouseDown.apply(this, arguments);
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
const processMouseMove = LGraphCanvas.prototype.processMouseMove;
|
||||
// @ts-ignore
|
||||
LGraphCanvas.prototype.processMouseMove = function (e) {
|
||||
if (touchZooming || touchCount > 1) {
|
||||
return;
|
||||
@@ -93,7 +93,7 @@ app.registerExtension({
|
||||
}
|
||||
|
||||
// Upload image to temp storage
|
||||
const blob = await new Promise((r) => canvas.toBlob(r));
|
||||
const blob = await new Promise<Blob>((r) => canvas.toBlob(r));
|
||||
const name = `${+new Date()}.png`;
|
||||
const file = new File([blob], name);
|
||||
const body = new FormData();
|
||||
@@ -117,7 +117,7 @@ app.registerExtension({
|
||||
// If width isnt specified then use video output resolution
|
||||
if (!w.value) {
|
||||
w.value = video.videoWidth || 640;
|
||||
h.value = video.videoHeight || 480;
|
||||
h.value = video.videoHeight || 480;
|
||||
}
|
||||
btn.disabled = false;
|
||||
btn.label = "capture";
|
||||
Reference in New Issue
Block a user