v1.0.5: preserve core context menu entries (Mask Editor, Open/Save Image)
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
# Changelog
|
||||
|
||||
## v1.0.5 (2026-09-07)
|
||||
|
||||
- Fixed the node's right-click context menu: it now preserves the core's extra entries (Open Image, Save Image, Bypass, Clipspace, and "Open in MaskEditor | Image Canvas"). The node's menu hook replaced the core implementation instead of chaining into it, which silently dropped those entries.
|
||||
- The node now reliably exposes its loaded preview to the core image checks (`node.imgs` / `previewMediaType`) in both the classic and the 2.0 layouts, so the Mask Editor and the image menu actions operate on it.
|
||||
|
||||
## v1.0.4 (2026-09-04)
|
||||
|
||||
- Added the **Free (Custom)** aspect-ratio option (both the classic and the 2.0 layouts): it lifts the ratio lock so the crop box can be any shape. The four box corners show resize handles — dragging one resizes the box freely (the opposite corner stays fixed), dragging inside the box still moves it, and the wheel zooms it at the box's own drawn ratio. The box starts as a centered 90×90% area so the handles stay inside the preview; a new image starts from that box too. The default (Original) and the preset ratios are unchanged.
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "ComfyUI-LoadImageCrop"
|
||||
description = "An extended Load Image node with an aspect-ratio-locked, WYSIWYG crop rectangle that outputs the cropped IMAGE and MASK."
|
||||
version = "1.0.4"
|
||||
version = "1.0.5"
|
||||
license = "MIT"
|
||||
|
||||
[project.urls]
|
||||
|
||||
+23
-2
@@ -310,6 +310,9 @@ function scheduleOverlay(node, ctx, widget, width, imgsArg) {
|
||||
if (imgs.length === 1 && !idx) idx = 0;
|
||||
const img = imgs[idx];
|
||||
if (!img) { st.rect = null; return; }
|
||||
// Keep the node visible to the core isImageNode() gate so the
|
||||
// "Open in MaskEditor | Image Canvas" context menu entry stays available.
|
||||
node.previewMediaType = "image";
|
||||
const nw = img.naturalWidth || img.width;
|
||||
const nh = img.naturalHeight || img.height;
|
||||
if (!nw || !nh) { st.rect = null; return; }
|
||||
@@ -648,7 +651,11 @@ function initNode(node) {
|
||||
};
|
||||
// context menu: the 2.0 menu already contains the core "Paste Image"
|
||||
// entry, so ours is added only in classic mode; both entries drive
|
||||
// the native node.pasteFile / node.pasteFiles methods
|
||||
// the native node.pasteFile / node.pasteFiles methods.
|
||||
// Chain into the core implementation so its entries (Open Image,
|
||||
// Save Image, Bypass, Clipspace, Open in MaskEditor | Image Canvas,
|
||||
// ...) are preserved on this node
|
||||
const coreExtraMenu = node.getExtraMenuOptions;
|
||||
node.getExtraMenuOptions = (canvas, options) => {
|
||||
const items = [];
|
||||
if (!isVueMode()) {
|
||||
@@ -657,7 +664,14 @@ function initNode(node) {
|
||||
callback: () => pasteFromClipboard(node)
|
||||
});
|
||||
}
|
||||
return items.concat(options || []);
|
||||
let base = options || [];
|
||||
if (typeof coreExtraMenu === "function") {
|
||||
try {
|
||||
const r = coreExtraMenu.call(node, canvas, base);
|
||||
if (Array.isArray(r)) base = r;
|
||||
} catch (_) { /* ignore */ }
|
||||
}
|
||||
return items.concat(base);
|
||||
};
|
||||
initCropFromWidgets(node);
|
||||
}
|
||||
@@ -709,6 +723,13 @@ function layoutVueOverlay(node) {
|
||||
const parts = vuePartsOf(node);
|
||||
if (!parts || !parts.img.complete || !parts.img.naturalWidth) return;
|
||||
|
||||
// Keep the node visible to the core image gates (isImageNode, mask
|
||||
// editor, open/copy image) which read node.imgs / previewMediaType.
|
||||
if (!Array.isArray(node.imgs) || !node.imgs.length) {
|
||||
node.imgs = [parts.img];
|
||||
}
|
||||
node.previewMediaType = "image";
|
||||
|
||||
const vw = parts.img.naturalWidth;
|
||||
const vh = parts.img.naturalHeight;
|
||||
const key = `${parts.img.src}|${ratioOf(node)}|${vw}x${vh}`;
|
||||
|
||||
Reference in New Issue
Block a user