From ca266a20570313e2e2642da3c6a619243449a579 Mon Sep 17 00:00:00 2001 From: Edoardo Carmignani Date: Mon, 19 Jan 2026 12:11:53 +0100 Subject: [PATCH 1/2] fix: change logic for including subgraph nodes. Closes #11 - Change app.graph to app.canvas.graph to include subgraphs - Change condition in draw methods to ignore subgraphs input --- web/js/ExtraLinks.js | 45 ++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/web/js/ExtraLinks.js b/web/js/ExtraLinks.js index c8fd547..ba97aab 100644 --- a/web/js/ExtraLinks.js +++ b/web/js/ExtraLinks.js @@ -1,8 +1,8 @@ -import {app} from "../../../scripts/app.js" +import { app } from "../../../scripts/app.js" const LinkRenderers = { curved: { - draw: function(path, start, end, slot_id, start_node, end_node, radius, offset, curvature, pos, is_dragging) { + draw: function (path, start, end, slot_id, start_node, end_node, radius, offset, curvature, pos, is_dragging) { const outputs = start_node?.outputs.length ?? 1; @@ -32,7 +32,7 @@ const LinkRenderers = { path.arcTo(x1, y2, x1 + r * dirX, y2, r); path.lineTo(x2, y2); - if ( Math.abs(x2 - x1) > Math.abs(y2 - y1) ) { + if (Math.abs(x2 - x1) > Math.abs(y2 - y1)) { pos[0] = (x2 + x1) * 0.5; pos[1] = y2; pos[2] = Math.atan2(0, x2 - x1) @@ -42,7 +42,7 @@ const LinkRenderers = { pos[2] = Math.atan2(y2 - y1, 0) } } else { - if (is_dragging && !start_node) { + if (is_dragging || !start_node) { path.lineTo(x1 - r * dirX, y1); path.arcTo(x1, y1, x1, y1 + r * dirY, r); path.lineTo(x1, y2 - r * dirY); @@ -77,7 +77,7 @@ const LinkRenderers = { } }, manhattan: { - draw: function(path, start, end, slot_id, start_node, end_node, radius, offset, curvature, pos, is_dragging) { + draw: function (path, start, end, slot_id, start_node, end_node, radius, offset, curvature, pos, is_dragging) { const x0 = start.x; const y1 = start.y; @@ -107,7 +107,7 @@ const LinkRenderers = { pos[1] = (y1 + y2) * 0.5; pos[2] = Math.atan2(dy, (Math.abs(dy) < radius * 2) ? (Math.PI + radius) * 0.5 : 0); } else { - if (is_dragging && !start_node) { + if (is_dragging || !start_node) { const midX = (x0 + x2) * 0.5; path.arcTo(midX, y1, midX, y2, r); @@ -142,7 +142,8 @@ const LinkRenderers = { } }, subway: { - draw: function(path, start, end, slot_id, start_node, end_node, radius, offset, curvature, pos, is_dragging) { + draw: function (path, start, end, slot_id, start_node, end_node, radius, offset, curvature, pos, is_dragging) { + const x0 = start.x; const y0 = start.y; const x2 = end.x; @@ -176,7 +177,7 @@ const LinkRenderers = { pos[2] = Math.atan2(y2 - y0, (Math.abs(dy) < r * 2) ? (Math.PI + c2 - c1) : c2 - c1); } else { - if (is_dragging && !start_node) { + if (is_dragging || !start_node) { path.arcTo(turnX1, y0, turnX1, y2, r); path.arcTo(turnX1, y2, x2, y2, r); @@ -187,9 +188,10 @@ const LinkRenderers = { pos[2] = Math.atan2(dy, dx); return; } + const nodeHeight = start_node.collapsed ? start_node.height / 2 : start_node.size[1]; const sourceBottom = start_node.collapsed ? start_node.pos[1] - (nodeHeight - offset) / 2 : nodeHeight + start_node.pos[1]; - const sourceLeft = (start_node.pos[1] + nodeHeight < y2) ? start_node.pos[0] + start_node.size[0]: start_node.pos[0] + 10; + const sourceLeft = (start_node.pos[1] + nodeHeight < y2) ? start_node.pos[0] + start_node.size[0] : start_node.pos[0] + 10; const trayY = sourceBottom + ((slot_id + 1) * offset / 2); let turnX2 = x2 - offset; @@ -223,9 +225,9 @@ export class ExtraLinks { async waitForCanvas() { while (!app.canvas || - !app.canvas.linkRenderer || - !app.canvas.linkRenderer.pathRenderer || - !app.canvas.linkRenderer.pathRenderer.drawLink) { + !app.canvas.linkRenderer || + !app.canvas.linkRenderer.pathRenderer || + !app.canvas.linkRenderer.pathRenderer.drawLink) { await new Promise(resolve => setTimeout(resolve, 100)); } return true; @@ -246,21 +248,20 @@ export class ExtraLinks { return; } - const RADIUS = app.extensionManager.setting.get("Extra Links.Shapes.Radius") ?? 10; - const OFFSET = app.extensionManager.setting.get("Extra Links.Shapes.Offset") ?? 25; + const _graph = app.canvas.graph; + + const RADIUS = app.extensionManager.setting.get("Extra Links.Shapes.Radius") ?? 10; + const OFFSET = app.extensionManager.setting.get("Extra Links.Shapes.Offset") ?? 25; const CURVATURE = app.extensionManager.setting.get("Extra Links.Shapes.Curvature") ?? 5; const SHAPE = app.extensionManager.setting.get("Extra Links.General.Shape") ?? "curved"; - const full_link_object = app.graph.links[link2?.id]; + const full_link_object = _graph.links[link2?.id]; const outputId = full_link_object?.origin_slot ?? 0; - const start_node = app.graph.getNodeById(full_link_object?.origin_id); - const end_node = app.graph.getNodeById(full_link_object?.target_id); + const start_node = _graph.getNodeById(full_link_object?.origin_id); + const end_node = _graph.getNodeById(full_link_object?.target_id); - console.log(start_node) - // console.log(end_node) - - const is_dragging = (link2?.id == 'temp') || !app.graph.links[link2.id]; + const is_dragging = (link2?.id == 'temp') || !_graph.links[link2.id]; const startPos = link2.startPoint; const endPos = link2.endPoint; @@ -290,7 +291,7 @@ export class ExtraLinks { ctx.stroke(path); pathRendererConstructor.prototype.calculateCenterPoint = (...args) => { - link2.centerPos = {x: pos[0], y: pos[1]} + link2.centerPos = { x: pos[0], y: pos[1] } if (context.style.centerMarkerShape === 'arrow') { link2.centerAngle = pos[2]; } From a4d5272a4e5e5259057bcf9c5f9c999d6e5cf955 Mon Sep 17 00:00:00 2001 From: Edoardo Carmignani Date: Mon, 19 Jan 2026 12:20:04 +0100 Subject: [PATCH 2/2] chore: bump to version 1.1.2 --- .bumpversion.toml | 2 +- CHANGELOG.md | 11 +++++++++++ README.md | 1 + __init__.py | 2 +- pyproject.toml | 2 +- web/js/extralinks_register.js | 2 +- 6 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.bumpversion.toml b/.bumpversion.toml index aa6820b..f7bc313 100644 --- a/.bumpversion.toml +++ b/.bumpversion.toml @@ -1,5 +1,5 @@ [tool.bumpversion] -current_version = "1.1.1" +current_version = "1.1.2" parse = "(?P\\d+)\\.(?P\\d+)\\.(?P\\d+)" serialize = ["{major}.{minor}.{patch}"] search = "{current_version}" diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cd3af9..d7abd5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file. --- +## [1.1.2] - 2026-01-19 + +### Fixed + +- Change node retrieval logic to call `app.canvas.graph` instead of `app.graph` in order to make links behave correctly inside subgraphs. +- Change conditional `is_dragging && !start_node` to `is_dragging || !start_node` to solve subgraphs input issues. + +--- + +--- + ## [1.1.1] - 2025-12-11 ### Fixed diff --git a/README.md b/README.md index 44fe07f..2789275 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,7 @@ If issues persist, please open an issue with: ## Versioning & Releases +- **1.1.2** - Fixed links inside subgraphs. - **1.1.1** - Fixed collapsed state node links. - **1.1.0** - Added subway style and geometry awareness. - **1.0.2** - Fixed path method to patch each instance. diff --git a/__init__.py b/__init__.py index 9d3279a..a12b850 100644 --- a/__init__.py +++ b/__init__.py @@ -8,7 +8,7 @@ __author__ = 'Edoardo Carmignani' __email__ = 'edoardo.carmignani@gmail.com' -__version__ = '1.1.1' +__version__ = '1.1.2' WEB_DIRECTORY = './web' diff --git a/pyproject.toml b/pyproject.toml index 0bb8617..5bbbd14 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "extralinks" -version = "1.1.1" +version = "1.1.2" description = "More connection links." authors = [ {name = "Edoardo Carmignani", email = "edoardo.carmignani@gmail.com"} diff --git a/web/js/extralinks_register.js b/web/js/extralinks_register.js index 029f596..d3d5ca4 100644 --- a/web/js/extralinks_register.js +++ b/web/js/extralinks_register.js @@ -47,7 +47,7 @@ app.registerExtension({ }, { id: "Extra Links.ExtraLinks", - name: "Version 1.1.1", + name: "Version 1.1.2", type: () => { const container = document.createElement("span"); const btn = document.createElement("button");