Skip to content

Commit

Permalink
feat: support deleting nodes using the backspace key
Browse files Browse the repository at this point in the history
  • Loading branch information
iamppz committed Nov 2, 2023
1 parent 6b91123 commit c8b74c9
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 18 deletions.
5 changes: 3 additions & 2 deletions dist/FlowChart.common.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/FlowChart.common.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions dist/FlowChart.umd.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/FlowChart.umd.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/FlowChart.umd.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/FlowChart.umd.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flowchart-vue",
"version": "0.31.0",
"version": "0.32.0",
"license": "MIT",
"main": "dist/FlowChart.umd.min.js",
"repository": {
Expand Down
19 changes: 10 additions & 9 deletions src/components/flowchart/Flowchart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export default {
&& x.source.position === this.connectingInfo.sourcePosition
&& x.destination.id === this.hoveredConnector.node.id
&& x.destination.position === this.hoveredConnector.position);
return !connectionToItself && !connectionAlreadyExists;
},
async handleChartMouseMove(event) {
Expand Down Expand Up @@ -277,17 +277,17 @@ export default {
},
isMouseOverAnyNode() {
let cursorPosition = { x: this.cursorToChartOffset.x, y: this.cursorToChartOffset.y };
let result = false;
for(let currentNodeIndex = 0; currentNodeIndex < this.internalNodes.length; currentNodeIndex++) {
const node = this.internalNodes[currentNodeIndex];
const nodeArea = {
start: { x: node.x, y: node.y },
end: { x: node.x + node.width, y: node.y + node.height }
}
const mousePointIntersectNodeArea =
const mousePointIntersectNodeArea =
cursorPosition.x >= nodeArea.start.x && cursorPosition.x <= nodeArea.end.x
&& cursorPosition.y >= nodeArea.start.y && cursorPosition.y <= nodeArea.end.y;
Expand All @@ -296,7 +296,7 @@ export default {
break;
}
}
return result;
},
getConnectorPosition(node) {
Expand All @@ -315,7 +315,7 @@ export default {
if (this.hasNodeConnector(node, "left")) {
result.left = { x: node.x, y: node.y + halfHeight };
}
return result;
},
hasNodeConnector(node, position) {
Expand Down Expand Up @@ -471,7 +471,7 @@ export default {
haveNodesSelectedConnectors(connection) {
const sourceNode = this.nodes.find(x => x.id === connection.source.id);
const destinationNode = this.nodes.find(x => x.id === connection.destination.id);
return this.hasNodeConnector(sourceNode, connection.source.position)
return this.hasNodeConnector(sourceNode, connection.source.position)
&& this.hasNodeConnector(destinationNode, connection.destination.position);
},
renderNodes() {
Expand Down Expand Up @@ -745,7 +745,7 @@ export default {
return;
}
const anyElementToRemove = this.currentConnections.length > 0 || this.currentNodes.length > 0;
if (!anyElementToRemove) {
if (!anyElementToRemove) {
return;
}
if (!this.removeRequiresConfirmation) {
Expand Down Expand Up @@ -860,6 +860,7 @@ export default {
}
break;
case 46:
case 8:
that.remove();
break;
default:
Expand Down

0 comments on commit c8b74c9

Please sign in to comment.