This commit is contained in:
kk8bit
2025-03-31 19:35:26 +08:00
parent 859eab0f5f
commit 5b3c2e1708
5 changed files with 66 additions and 16 deletions
+4
View File
@@ -1,3 +1,7 @@
# Changelog
## [0.51.0] - 2025-03-31
- node align 新增快捷键`Shift+WASD`
# Changelog
## [0.50.5] - 2025-03-27
- node align bar可吸附菜单栏
+12 -6
View File
@@ -1,12 +1,12 @@
{
"KayTool_ShowRunOption": {
"name": "在'节点右键'菜单中显示 '▶️ Run' 选项"
"name": "在'节点右键菜单'中显示 '▶️ Run' 选项"
},
"KayTool_ShowSetGetOptions": {
"name": "在'节点右键'菜单中显示 '🛜 Set/Get' 选项"
"name": "在'节点右键菜单'中显示 '🛜 Set/Get' 选项"
},
"KayTool_ShiftR": {
"name": "使用 'Shift+R' 快捷键在选中的节点上快速执行 '▶️ Run' "
"name": "使用 'Shift+R' 快捷键在选中的节点上快速执行 '▶️ Run'"
},
"KayTool_ShowWorkflowPNG": {
"name": "在KayTool菜单中显示 'Workflow PNG' 选项"
@@ -19,15 +19,21 @@
"tooltip": "建议设置 100"
},
"KayTool_SetGetForegroundColor": {
"name": "调整 '🛜 Set/Get' 节点颜色"
"name": " '🛜 Set/Get' 节点颜色"
},
"KayTool_SetGetBackgroundColor": {
"name": "调整 '🛜 Set/Get' 标题颜色"
"name": " '🛜 Set/Get' 标题颜色"
},
"KayTool_CustomWebLogo": {
"name": "文件必须 < 1MB",
"tooltip": "这是一个测试功能,文件必须 < 1MB ,否则可能无法显示"
"tooltip": "这是一个测试功能,文件最好 <1MB ,否则可能无法显示"
},
"KayTool_EnableAlignmentShortcuts": {
"name": "启用快捷键'Shift+W/A/S/D'",
"tooltip": "W/A/S/D对应上、左、下、右对齐"
},
"KayTool_NodeAlignDisplayMode": {
"name": "工具栏显示模式",
"options": {
+2 -2
View File
@@ -1,7 +1,7 @@
[project]
name = "kaytool"
description ="KayTool enhances ComfyUI workflow efficiency with practical tools, including: image processing (resize, color, blur, expand, merge, crop), background/mask tasks via BiRefNet/RemBG, wireless data transfer (Get & Out), AI translation (Tencent/Baidu), dynamic math operations, flexible text handling, precision sliders, metadata/color profile-supported image saving, batch processing via image folder loading, canvas workflow node map export as PNG with embedded metadata, quick Run options via right-click (Run Group/Node), node alignment toolbar with custom styled styles, and custom ComfyUI logo integration."
version = "0.50.8"
version = "0.51.0"
license = {file = "LICENSE"}
dependencies = ["rembg, timm"]
@@ -12,4 +12,4 @@ Repository = "https://github.com/kk8bit/KayTool"
[tool.comfy]
PublisherId = "kk8bit"
DisplayName = "KayTool"
Icon = ""
Icon = ""
+36 -5
View File
@@ -1,6 +1,7 @@
import { app } from "../../../scripts/app.js";
// SVG 定义(已包含你的现有 SVG,新增参考代码中的两个)
// Based on NodeAligner by Tenney95 GitHub:https://github.com/Tenney95/ComfyUI-NodeAligner
const kayAlignBottomSvg = `<svg t="1725534360155" class="icon" viewBox="0 0 1170 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1662" width="100%"><path d="M1170.285714 987.428571a36.571429 36.571429 0 0 0-36.571428-36.571428H36.571429a36.571429 36.571429 0 0 0 0 73.142857h1097.142857a36.571429 36.571429 0 0 0 36.571428-36.571429z m-219.428571-146.285714v-512a36.571429 36.571429 0 0 0-36.571429-36.571428h-219.428571a36.571429 36.571429 0 0 0-36.571429 36.571428v512a36.571429 36.571429 0 0 0 36.571429 36.571429h219.428571a36.571429 36.571429 0 0 0 36.571429-36.571429z m-438.857143 0V36.571429a36.571429 36.571429 0 0 0-36.571429-36.571429h-219.428571a36.571429 36.571429 0 0 0-36.571429 36.571429v804.571428a36.571429 36.571429 0 0 0 36.571429 36.571429h219.428571a36.571429 36.571429 0 0 0 36.571429-36.571429z" fill="#666666" p-id="1663"></path></svg>`;
const kayAlignCenterHorizontallySvg = `<svg t="1725534379860" class="icon" viewBox="0 0 1243 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2250" width="100%"><path d="M548.571429 472.356571h146.285714V231.643429a36.571429 36.571429 0 0 1 36.571428-36.571429h219.428572a36.571429 36.571429 0 0 1 36.571428 36.571429v240.713142h179.785143a39.643429 39.643429 0 0 1 0 79.286858H987.428571v240.713142a36.571429 36.571429 0 0 1-36.571428 36.571429h-219.428572a36.571429 36.571429 0 0 1-36.571428-36.571429V551.64571h-146.285714V950.857143a36.571429 36.571429 0 0 1-36.571429 36.571428H292.571429a36.571429 36.571429 0 0 1-36.571429-36.571428V551.643429H76.214857a39.643429 39.643429 0 1 1 0-79.286858H256V73.142857A36.571429 36.571429 0 0 1 292.571429 36.571429h219.428571a36.571429 36.571429 0 0 1 36.571429 36.571428v399.213714z" fill="#666666" p-id="2251"></path></svg>`;
const kayAlignCenterVerticallySvg = `<svg t="1725534363707" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1809" width="100%"><path d="M477.312 576V448H266.688a32 32 0 0 1-32-32v-192a32 32 0 0 1 32-32h210.624V34.688a34.688 34.688 0 0 1 69.376 0V192h210.624a32 32 0 0 1 32 32v192a32 32 0 0 1-32 32H546.688v128H896a32 32 0 0 1 32 32v192a32 32 0 0 1-32 32H546.688v157.312a34.688 34.688 0 0 1-69.376 0V832H128a32 32 0 0 1-32-32v-192A32 32 0 0 1 128 576h349.312z" fill="#666666" p-id="1810"></path></svg>`;
@@ -12,6 +13,7 @@ const kayEqualHeightSvg = `<svg t="1725606224564" class="icon" viewBox="0 0 1088
const kayHorizontalDistributionSvg = `<svg t="1725534354023" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1515" width="100%"><path d="M96 0a32 32 0 0 1 32 32v960a32 32 0 0 1-64 0V32A32 32 0 0 1 96 0z m832 0a32 32 0 0 1 32 32v960a32 32 0 0 1-64 0V32a32 32 0 0 1 32-32zM384 800v-576a32 32 0 0 1 32-32h192a32 32 0 0 1 32 32v576a32 32 0 0 1-32 32h-192a32 32 0 0 1-32-32z" fill="#666666" p-id="1516"></path></svg>`;
const kayVerticalDistributionSvg = `<svg t="1725534350231" class="icon" viewBox="0 0 1170 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1368" width="100%"><path d="M1170.285714 36.571429a36.571429 36.571429 0 0 1-36.571428 36.571428H36.571429a36.571429 36.571429 0 0 1 0-73.142857h1097.142857a36.571429 36.571429 0 0 1 36.571428 36.571429z m0 950.857142a36.571429 36.571429 0 0 1-36.571428 36.571429H36.571429a36.571429 36.571429 0 0 1 0-73.142857h1097.142857a36.571429 36.571429 0 0 1 36.571428 36.571428zM256 365.714286h658.285714a36.571429 36.571429 0 0 1 36.571429 36.571428v219.428572a36.571429 36.571429 0 0 1-36.571429 36.571428h-658.285714a36.571429 36.571429 0 0 1-36.571429-36.571428v-219.428572a36.571429 36.571429 0 0 1 36.571429-36.571428z" fill="#666666" p-id="1369"></path></svg>`;
let stylesInjected = false;
const KayNodeAlignmentManager = {
@@ -34,8 +36,9 @@ const KayNodeAlignmentManager = {
this.setupToolbar();
this.restorePosition();
this.bindCanvasEvents();
this.bindKeyboardShortcuts();
const displayMode = app.ui.settings.getSettingValue("KayTool.NodeAlignDisplayMode") || "permanent";
const displayMode = app.ui.settings.getSettingValue("KayTool.NodeAlignDisplayMode");
this.updateDisplayMode(displayMode);
},
@@ -204,7 +207,6 @@ const KayNodeAlignmentManager = {
document.addEventListener('mousemove', this.onDragging.bind(this));
document.addEventListener('mouseup', this.onDragEnd.bind(this));
document.addEventListener('selectstart', e => this.dragState.isDragging && e.preventDefault());
this.addTooltip();
},
@@ -558,9 +560,38 @@ const KayNodeAlignmentManager = {
bindCanvasEvents() {
if (!this.canvas) return;
this.canvas.addEventListener('click', () => {
const currentMode = app.ui.settings.getSettingValue("KayTool.NodeAlignDisplayMode") || "permanent";
const currentMode = app.ui.settings.getSettingValue("KayTool.NodeAlignDisplayMode");
this.updateDisplayMode(currentMode);
});
},
bindKeyboardShortcuts() {
document.addEventListener('keydown', (e) => {
// 只在 Shift 键按下且没有其他修饰键(如 Ctrl、Alt)时检查 WASD
if (!e.shiftKey || e.ctrlKey || e.altKey || e.metaKey) return;
const enableShortcuts = app.ui.settings.getSettingValue("KayTool.EnableAlignmentShortcuts");
if (!enableShortcuts || this.getSelectedNodes().length < 2) return;
switch (e.key.toLowerCase()) {
case 'w':
e.preventDefault();
this.alignTop();
break;
case 'a':
e.preventDefault();
this.alignLeft();
break;
case 's':
e.preventDefault();
this.alignBottom();
break;
case 'd':
e.preventDefault();
this.alignRight();
break;
}
});
}
};
@@ -568,7 +599,7 @@ function initializeKayNodeAlignment() {
if (!KayNodeAlignmentManager.isInitialized) {
KayNodeAlignmentManager.init();
} else {
const displayMode = app.ui.settings.getSettingValue("KayTool.NodeAlignDisplayMode") || "permanent";
const displayMode = app.ui.settings.getSettingValue("KayTool.NodeAlignDisplayMode");
KayNodeAlignmentManager.updateDisplayMode(displayMode);
}
}
+12 -3
View File
@@ -99,12 +99,21 @@ app.registerExtension({
if (!manager || !initFn) return;
if (!manager.isInitialized) {
initFn(); // 始终初始化,确保事件绑定
initFn();
}
manager.updateDisplayMode(value); // 直接更新模式,“disabled”仅隐藏
manager.updateDisplayMode(value); //
}
});
app.ui.settings.addSetting({
id: "KayTool.EnableAlignmentShortcuts",
name: "Enable Shift+WASD for Quick Alignment (Up/Left/Down/Right)",
type: "boolean",
defaultValue: true,
category: ["KayTool", "NodeAlignment", "Shortcuts"],
tooltip: "Use Shift+W (Up), Shift+A (Left), Shift+S (Down), Shift+D (Right) to align selected nodes."
});
app.ui.settings.addSetting({
id: "KayTool.NodeAlignBackgroundOpacity",
name: "Node Alignment Toolbar Background Opacity",
@@ -213,7 +222,7 @@ function updateSetGetNodeColors() {
if (node.type === "KaySetNode" || node.type === "KayGetNode" || node.type === "KayGet多元Node") {
node.color = fgColor;
node.bgcolor = bgColor;
if (node.updateColors) node.updateColors();
node.updateColors();
}
});
app.graph.setDirtyCanvas(true, true);