mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 07:05:43 -03:00
Merge branch 'willmiao:main' into main
This commit is contained in:
@@ -1,8 +1,12 @@
|
|||||||
|
import { forwardMiddleMouseToCanvas } from "./utils.js";
|
||||||
|
|
||||||
export function addJsonDisplayWidget(node, name, opts) {
|
export function addJsonDisplayWidget(node, name, opts) {
|
||||||
// Create container for JSON display
|
// Create container for JSON display
|
||||||
const container = document.createElement("div");
|
const container = document.createElement("div");
|
||||||
container.className = "comfy-json-display-container";
|
container.className = "comfy-json-display-container";
|
||||||
|
|
||||||
|
forwardMiddleMouseToCanvas(container);
|
||||||
|
|
||||||
// Set initial height
|
// Set initial height
|
||||||
const defaultHeight = 200;
|
const defaultHeight = 200;
|
||||||
|
|
||||||
|
|||||||
@@ -11,12 +11,15 @@ import {
|
|||||||
EMPTY_CONTAINER_HEIGHT
|
EMPTY_CONTAINER_HEIGHT
|
||||||
} from "./loras_widget_utils.js";
|
} from "./loras_widget_utils.js";
|
||||||
import { initDrag, createContextMenu, initHeaderDrag, initReorderDrag, handleKeyboardNavigation } from "./loras_widget_events.js";
|
import { initDrag, createContextMenu, initHeaderDrag, initReorderDrag, handleKeyboardNavigation } from "./loras_widget_events.js";
|
||||||
|
import { forwardMiddleMouseToCanvas } from "./utils.js";
|
||||||
|
|
||||||
export function addLorasWidget(node, name, opts, callback) {
|
export function addLorasWidget(node, name, opts, callback) {
|
||||||
// Create container for loras
|
// Create container for loras
|
||||||
const container = document.createElement("div");
|
const container = document.createElement("div");
|
||||||
container.className = "comfy-loras-container";
|
container.className = "comfy-loras-container";
|
||||||
|
|
||||||
|
forwardMiddleMouseToCanvas(container);
|
||||||
|
|
||||||
// Set initial height using CSS variables approach
|
// Set initial height using CSS variables approach
|
||||||
const defaultHeight = 200;
|
const defaultHeight = 200;
|
||||||
|
|
||||||
@@ -287,14 +290,18 @@ export function addLorasWidget(node, name, opts, callback) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Move preview tooltip events to nameEl instead of loraEl
|
// Move preview tooltip events to nameEl instead of loraEl
|
||||||
|
let previewTimer; // Timer for delayed preview
|
||||||
nameEl.addEventListener('mouseenter', async (e) => {
|
nameEl.addEventListener('mouseenter', async (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const rect = nameEl.getBoundingClientRect();
|
const rect = nameEl.getBoundingClientRect();
|
||||||
await previewTooltip.show(name, rect.right, rect.top);
|
previewTimer = setTimeout(async () => {
|
||||||
|
await previewTooltip.show(name, rect.right, rect.top);
|
||||||
|
}, 400); // 400ms delay
|
||||||
});
|
});
|
||||||
|
|
||||||
nameEl.addEventListener('mouseleave', (e) => {
|
nameEl.addEventListener('mouseleave', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
clearTimeout(previewTimer); // Cancel if not triggered
|
||||||
previewTooltip.hide();
|
previewTooltip.hide();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
|
import { forwardMiddleMouseToCanvas } from "./utils.js";
|
||||||
|
|
||||||
export function addTagsWidget(node, name, opts, callback) {
|
export function addTagsWidget(node, name, opts, callback) {
|
||||||
// Create container for tags
|
// Create container for tags
|
||||||
const container = document.createElement("div");
|
const container = document.createElement("div");
|
||||||
container.className = "comfy-tags-container";
|
container.className = "comfy-tags-container";
|
||||||
|
|
||||||
|
forwardMiddleMouseToCanvas(container);
|
||||||
|
|
||||||
// Set initial height
|
// Set initial height
|
||||||
const defaultHeight = 150;
|
const defaultHeight = 150;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
export const CONVERTED_TYPE = 'converted-widget';
|
export const CONVERTED_TYPE = 'converted-widget';
|
||||||
|
import { app } from "../../scripts/app.js";
|
||||||
import { AutoComplete } from "./autocomplete.js";
|
import { AutoComplete } from "./autocomplete.js";
|
||||||
|
|
||||||
export function chainCallback(object, property, callback) {
|
export function chainCallback(object, property, callback) {
|
||||||
@@ -322,3 +323,30 @@ export function setupAutocompleteCleanup(node) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forward middle mouse (button 1) pointer events from a container to the ComfyUI canvas,
|
||||||
|
* so that workflow panning works even when the pointer is over a DOM widget.
|
||||||
|
* @param {HTMLElement} container - The root DOM element of the widget
|
||||||
|
*/
|
||||||
|
export function forwardMiddleMouseToCanvas(container) {
|
||||||
|
if (!container) return;
|
||||||
|
// Forward pointerdown
|
||||||
|
container.addEventListener('pointerdown', (event) => {
|
||||||
|
if (event.button === 1) {
|
||||||
|
app.canvas.processMouseDown(event);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Forward pointermove
|
||||||
|
container.addEventListener('pointermove', (event) => {
|
||||||
|
if ((event.buttons & 4) === 4) {
|
||||||
|
app.canvas.processMouseMove(event);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Forward pointerup
|
||||||
|
container.addEventListener('pointerup', (event) => {
|
||||||
|
if (event.button === 1) {
|
||||||
|
app.canvas.processMouseUp(event);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user