From f3d7016ab248c7a9f70a078f1e3cef87753c5bd9 Mon Sep 17 00:00:00 2001 From: Hiroyasu Nishiyama Date: Fri, 3 Feb 2023 17:25:58 +0900 Subject: [PATCH] fix group position after undo --- .../@node-red/editor-client/src/js/ui/view.js | 85 +++++++++++++++++-- 1 file changed, 80 insertions(+), 5 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/view.js b/packages/node_modules/@node-red/editor-client/src/js/ui/view.js index 03e4d3cd9..4131f5dbf 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/view.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/view.js @@ -586,11 +586,28 @@ RED.view = (function() { var group = $(ui.helper).data("group"); if (group) { + var oldX = group.x; + var oldY = group.y; RED.group.addToGroup(group, nn); + var moveEvent = null; + if ((group.x !== oldX) || + (group.y !== oldY)) { + moveEvent = { + t: "move", + nodes: [{n: group, + ox: oldX, oy: oldY, + dx: group.x -oldX, + dy: group.y -oldY}], + dirty: true + }; + } historyEvent = { t: 'multi', events: [historyEvent], + }; + if (moveEvent) { + historyEvent.events.push(moveEvent) } historyEvent.events.push({ t: "addToGroup", @@ -1350,19 +1367,35 @@ RED.view = (function() { RED.editor.validateNode(nn); if (targetGroup) { + var oldX = targetGroup.x; + var oldY = targetGroup.y; RED.group.addToGroup(targetGroup, nn); + var moveEvent = null; + if ((targetGroup.x !== oldX) || + (targetGroup.y !== oldY)) { + moveEvent = { + t: "move", + nodes: [{n: targetGroup, + ox: oldX, oy: oldY, + dx: targetGroup.x -oldX, + dy: targetGroup.y -oldY}], + dirty: true + }; + } if (historyEvent.t !== "multi") { historyEvent = { t:'multi', events: [historyEvent] - } + }; } historyEvent.events.push({ t: "addToGroup", group: targetGroup, nodes: nn - }) - + }); + if (moveEvent) { + historyEvent.events.push(moveEvent); + } } if (spliceLink) { @@ -1698,6 +1731,7 @@ RED.view = (function() { // Check link splice or group-add if (movingSet.length() === 1 && movingSet.get(0).n.type !== "group") { + //}{//NIS node = movingSet.get(0); if (spliceActive) { if (!spliceTimer) { @@ -2057,11 +2091,25 @@ RED.view = (function() { if (mouse_mode == RED.state.MOVING_ACTIVE) { if (movingSet.length() > 0) { var addedToGroup = null; + var moveEvent = null; if (activeHoverGroup) { + var oldX = activeHoverGroup.x; + var oldY = activeHoverGroup.y; for (var j=0;j