feat(nodes): nested boundaries

Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
Braks
2021-12-20 19:29:52 +01:00
parent f00f34d84b
commit 3f0b0dbd70
8 changed files with 165 additions and 109 deletions
+3 -1
View File
@@ -1,5 +1,5 @@
import { Elements, FlowActions, FlowGetters, FlowState } from '~/types'
import { getConnectedEdges, getNodesInside, getRectOfNodes, parseElements, processElements } from '~/utils'
import { getConnectedEdges, getNodesInside, getRectOfNodes, isGraphNode, parseElements, processElements } from '~/utils'
export default (state: FlowState, getters: FlowGetters): FlowActions => {
const setElements: FlowActions['setElements'] = async (elements, force = true) => {
@@ -26,6 +26,7 @@ export default (state: FlowState, getters: FlowGetters): FlowActions => {
const startX = state.userSelectionRect.startX
const startY = state.userSelectionRect.startY
state.selectedElements?.forEach((el) => isGraphNode(el) && (el.selected = undefined))
const nextUserSelectRect: FlowState['userSelectionRect'] = {
...state.userSelectionRect,
x: mousePos.x < startX ? mousePos.x : state.userSelectionRect.x,
@@ -37,6 +38,7 @@ export default (state: FlowState, getters: FlowGetters): FlowActions => {
const selectedEdges = getConnectedEdges(selectedNodes, getters.getEdges.value)
const nextSelectedElements = [...selectedNodes, ...selectedEdges]
nextSelectedElements.forEach((el) => isGraphNode(el) && (el.selected = true))
state.userSelectionRect = nextUserSelectRect
state.selectedElements = nextSelectedElements
}