mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-02 07:01:30 -08:00
set new insert position
This commit is contained in:
parent
b3ecea0e8d
commit
615178dd8d
|
@ -196,7 +196,9 @@ export const mouseSelect = mixins(
|
||||||
this.$store.commit('setLastSelectedNodeOutputIndex', null);
|
this.$store.commit('setLastSelectedNodeOutputIndex', null);
|
||||||
this.$store.commit('setActiveNode', null);
|
this.$store.commit('setActiveNode', null);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.lastSelectedConnction = null;
|
this.lastSelectedConnection = null;
|
||||||
|
// @ts-ignore
|
||||||
|
this.newNodeInsertPosition = null;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -430,6 +430,7 @@ export default mixins(
|
||||||
stopExecutionInProgress: false,
|
stopExecutionInProgress: false,
|
||||||
blankRedirect: false,
|
blankRedirect: false,
|
||||||
credentialsUpdated: false,
|
credentialsUpdated: false,
|
||||||
|
newNodeInsertPosition: null as null | XYPositon,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
beforeDestroy () {
|
beforeDestroy () {
|
||||||
|
@ -1250,6 +1251,7 @@ export default mixins(
|
||||||
this.$store.commit('setLastSelectedNode', node.name);
|
this.$store.commit('setLastSelectedNode', node.name);
|
||||||
this.$store.commit('setLastSelectedNodeOutputIndex', null);
|
this.$store.commit('setLastSelectedNodeOutputIndex', null);
|
||||||
this.lastSelectedConnection = null;
|
this.lastSelectedConnection = null;
|
||||||
|
this.newNodeInsertPosition = null;
|
||||||
|
|
||||||
if (setActive === true) {
|
if (setActive === true) {
|
||||||
this.$store.commit('setActiveNode', node.name);
|
this.$store.commit('setActiveNode', node.name);
|
||||||
|
@ -1346,13 +1348,20 @@ export default mixins(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a node is active then add the new node directly after the current one
|
if (this.newNodeInsertPosition) {
|
||||||
// newNodeData.position = [activeNode.position[0], activeNode.position[1] + 60];
|
console.log('setting', this.newNodeInsertPosition);
|
||||||
newNodeData.position = getNewNodePosition(
|
newNodeData.position = [this.newNodeInsertPosition[0], this.newNodeInsertPosition[1] - NODE_SIZE / 2];
|
||||||
this.nodes,
|
this.newNodeInsertPosition = null;
|
||||||
[lastSelectedNode.position[0] + 200, lastSelectedNode.position[1]],
|
}
|
||||||
[100, 0],
|
else {
|
||||||
);
|
// If a node is active then add the new node directly after the current one
|
||||||
|
// newNodeData.position = [activeNode.position[0], activeNode.position[1] + 60];
|
||||||
|
newNodeData.position = getNewNodePosition(
|
||||||
|
this.nodes,
|
||||||
|
[lastSelectedNode.position[0] + 200, lastSelectedNode.position[1]],
|
||||||
|
[100, 0],
|
||||||
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// If no node is active find a free spot
|
// If no node is active find a free spot
|
||||||
newNodeData.position = getNewNodePosition(this.nodes, this.lastClickPosition);
|
newNodeData.position = getNewNodePosition(this.nodes, this.lastClickPosition);
|
||||||
|
@ -1460,6 +1469,7 @@ export default mixins(
|
||||||
const sourceNodeName = this.$store.getters.getNodeNameByIndex(info.sourceId.slice(NODE_NAME_PREFIX.length));
|
const sourceNodeName = this.$store.getters.getNodeNameByIndex(info.sourceId.slice(NODE_NAME_PREFIX.length));
|
||||||
this.$store.commit('setLastSelectedNode', sourceNodeName);
|
this.$store.commit('setLastSelectedNode', sourceNodeName);
|
||||||
this.$store.commit('setLastSelectedNodeOutputIndex', info.index);
|
this.$store.commit('setLastSelectedNodeOutputIndex', info.index);
|
||||||
|
this.newNodeInsertPosition = null;
|
||||||
|
|
||||||
if (info.connection) {
|
if (info.connection) {
|
||||||
this.lastSelectedConnection = info.connection;
|
this.lastSelectedConnection = info.connection;
|
||||||
|
@ -1632,6 +1642,7 @@ export default mixins(
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.instance.bind('connectionDrag', (connection: Connection) => {
|
this.instance.bind('connectionDrag', (connection: Connection) => {
|
||||||
|
this.newNodeInsertPosition = null;
|
||||||
addOverlays(connection, CONNECTOR_DROP_NODE_OVERLAY);
|
addOverlays(connection, CONNECTOR_DROP_NODE_OVERLAY);
|
||||||
|
|
||||||
let droppable = false;
|
let droppable = false;
|
||||||
|
@ -1657,7 +1668,8 @@ export default mixins(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onMouseUp = () => {
|
const onMouseUp = (e: MouseEvent) => {
|
||||||
|
this.newNodeInsertPosition = [e.pageX, e.pageY];
|
||||||
window.removeEventListener('mousemove', onMouseMove);
|
window.removeEventListener('mousemove', onMouseMove);
|
||||||
window.removeEventListener('mouseup', onMouseUp);
|
window.removeEventListener('mouseup', onMouseUp);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue