@bian-womp/spark-workbench 0.2.87 → 0.2.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkbenchCanvas.d.ts","sourceRoot":"","sources":["../../../../src/misc/WorkbenchCanvas.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AAYf,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAqB1D,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,WAAW,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;CAC3C,CAAC;AAEF,eAAO,MAAM,eAAe;iBAGX,OAAO;cACV,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,MAAM;eAC3C,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,GAAG,CAAC,OAAO;yBACvC,CACnB,MAAM,EAAE,MAAM,KACX;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS;+
|
|
1
|
+
{"version":3,"file":"WorkbenchCanvas.d.ts","sourceRoot":"","sources":["../../../../src/misc/WorkbenchCanvas.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AAYf,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAqB1D,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,WAAW,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;CAC3C,CAAC;AAEF,eAAO,MAAM,eAAe;iBAGX,OAAO;cACV,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,MAAM;eAC3C,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,GAAG,CAAC,OAAO;yBACvC,CACnB,MAAM,EAAE,MAAM,KACX;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS;+CA68BpD,CAAC"}
|
package/lib/esm/index.js
CHANGED
|
@@ -5121,30 +5121,26 @@ const WorkbenchCanvas = React.forwardRef(({ showValues, toString, toElement, get
|
|
|
5121
5121
|
};
|
|
5122
5122
|
const onContextMenu = (e) => {
|
|
5123
5123
|
e.preventDefault();
|
|
5124
|
-
|
|
5125
|
-
const
|
|
5126
|
-
|
|
5127
|
-
const { left, top, right, bottom } = selectionBounds;
|
|
5128
|
-
if (e.clientX >= left &&
|
|
5129
|
-
e.clientX <= right &&
|
|
5130
|
-
e.clientY >= top &&
|
|
5131
|
-
e.clientY <= bottom) {
|
|
5132
|
-
setSelectionMenuPos({ x: e.clientX, y: e.clientY });
|
|
5133
|
-
setSelectionMenuOpen(true);
|
|
5134
|
-
setMenuOpen(false);
|
|
5135
|
-
setNodeMenuOpen(false);
|
|
5136
|
-
return;
|
|
5137
|
-
}
|
|
5138
|
-
}
|
|
5124
|
+
const selection = wb.getSelection();
|
|
5125
|
+
const isSingleNodeSelected = selection.nodes.length === 1;
|
|
5126
|
+
const hasMultipleNodesSelected = selection.nodes.length > 1;
|
|
5139
5127
|
// Determine if right-clicked over a node by hit-testing
|
|
5140
5128
|
const target = e.target?.closest(".react-flow__node");
|
|
5141
5129
|
if (target) {
|
|
5142
5130
|
// Resolve node id from data-id attribute React Flow sets
|
|
5143
5131
|
const nodeId = target.getAttribute("data-id");
|
|
5144
|
-
const selection = wb.getSelection();
|
|
5145
5132
|
const isSelected = nodeId && selection.nodes.includes(nodeId);
|
|
5146
|
-
if (isSelected) {
|
|
5147
|
-
// Right-clicked on
|
|
5133
|
+
if (isSelected && isSingleNodeSelected) {
|
|
5134
|
+
// Right-clicked on the single selected node - show node menu
|
|
5135
|
+
setNodeAtMenu(nodeId);
|
|
5136
|
+
setNodeMenuPos({ x: e.clientX, y: e.clientY });
|
|
5137
|
+
setNodeMenuOpen(true);
|
|
5138
|
+
setMenuOpen(false);
|
|
5139
|
+
setSelectionMenuOpen(false);
|
|
5140
|
+
return;
|
|
5141
|
+
}
|
|
5142
|
+
else if (isSelected) {
|
|
5143
|
+
// Right-clicked on a node that's part of multi-selection - show selection menu
|
|
5148
5144
|
setSelectionMenuPos({ x: e.clientX, y: e.clientY });
|
|
5149
5145
|
setSelectionMenuOpen(true);
|
|
5150
5146
|
setMenuOpen(false);
|
|
@@ -5165,10 +5161,45 @@ const WorkbenchCanvas = React.forwardRef(({ showValues, toString, toElement, get
|
|
|
5165
5161
|
const edgeTarget = e.target?.closest(".react-flow__edge");
|
|
5166
5162
|
if (edgeTarget) {
|
|
5167
5163
|
const edgeId = edgeTarget.getAttribute("data-id");
|
|
5168
|
-
const selection = wb.getSelection();
|
|
5169
5164
|
const isSelected = edgeId && selection.edges.includes(edgeId);
|
|
5170
|
-
if (isSelected) {
|
|
5171
|
-
// Right-clicked on
|
|
5165
|
+
if (isSelected && isSingleNodeSelected) {
|
|
5166
|
+
// Right-clicked on an edge, but only one node is selected - show node menu
|
|
5167
|
+
const nodeId = selection.nodes[0];
|
|
5168
|
+
setNodeAtMenu(nodeId);
|
|
5169
|
+
setNodeMenuPos({ x: e.clientX, y: e.clientY });
|
|
5170
|
+
setNodeMenuOpen(true);
|
|
5171
|
+
setMenuOpen(false);
|
|
5172
|
+
setSelectionMenuOpen(false);
|
|
5173
|
+
return;
|
|
5174
|
+
}
|
|
5175
|
+
else if (isSelected) {
|
|
5176
|
+
// Right-clicked on a selected edge with multiple nodes - show selection menu
|
|
5177
|
+
setSelectionMenuPos({ x: e.clientX, y: e.clientY });
|
|
5178
|
+
setSelectionMenuOpen(true);
|
|
5179
|
+
setMenuOpen(false);
|
|
5180
|
+
setNodeMenuOpen(false);
|
|
5181
|
+
return;
|
|
5182
|
+
}
|
|
5183
|
+
}
|
|
5184
|
+
// If only one node is selected (even with edges), show node menu for empty space clicks
|
|
5185
|
+
if (isSingleNodeSelected) {
|
|
5186
|
+
const nodeId = selection.nodes[0];
|
|
5187
|
+
setNodeAtMenu(nodeId);
|
|
5188
|
+
setNodeMenuPos({ x: e.clientX, y: e.clientY });
|
|
5189
|
+
setNodeMenuOpen(true);
|
|
5190
|
+
setMenuOpen(false);
|
|
5191
|
+
setSelectionMenuOpen(false);
|
|
5192
|
+
return;
|
|
5193
|
+
}
|
|
5194
|
+
// Check if the cursor is inside the rectangular bounds of the current selection
|
|
5195
|
+
// (for multi-selection when right-clicking on empty space within selection bounds)
|
|
5196
|
+
const selectionBounds = getSelectionScreenBounds();
|
|
5197
|
+
if (selectionBounds && hasMultipleNodesSelected) {
|
|
5198
|
+
const { left, top, right, bottom } = selectionBounds;
|
|
5199
|
+
if (e.clientX >= left &&
|
|
5200
|
+
e.clientX <= right &&
|
|
5201
|
+
e.clientY >= top &&
|
|
5202
|
+
e.clientY <= bottom) {
|
|
5172
5203
|
setSelectionMenuPos({ x: e.clientX, y: e.clientY });
|
|
5173
5204
|
setSelectionMenuOpen(true);
|
|
5174
5205
|
setMenuOpen(false);
|
|
@@ -5176,7 +5207,7 @@ const WorkbenchCanvas = React.forwardRef(({ showValues, toString, toElement, get
|
|
|
5176
5207
|
return;
|
|
5177
5208
|
}
|
|
5178
5209
|
}
|
|
5179
|
-
// Right-clicked on empty space - show default menu
|
|
5210
|
+
// Right-clicked on empty space with no selection - show default menu
|
|
5180
5211
|
setMenuPos({ x: e.clientX, y: e.clientY });
|
|
5181
5212
|
setMenuOpen(true);
|
|
5182
5213
|
setNodeMenuOpen(false);
|