|
@@ -297,7 +297,11 @@ const initChart = () => {
|
|
|
const id = v4()
|
|
|
return new Shape.Edge({
|
|
|
id,
|
|
|
- attrs: lineStyle,
|
|
|
+ attrs: {
|
|
|
+ select: false,
|
|
|
+ hover: false,
|
|
|
+ line: lineStyle,
|
|
|
+ },
|
|
|
zIndex: -1,
|
|
|
tools: [
|
|
|
{
|
|
@@ -352,43 +356,79 @@ const initEdges = () => {
|
|
|
}
|
|
|
}
|
|
|
const initWatch = () => {
|
|
|
- state.graph.on('node:click', ({ e, x, y, node, view, port }) => {
|
|
|
+ state.graph.on('blank:click', () => {
|
|
|
+ state.graph.getCells().forEach(v => {
|
|
|
+ v.attr('select', false)
|
|
|
+ if (v.shape === 'edge') {
|
|
|
+ setEdgeStyle(v)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ state.graph.on('cell:click', () => {
|
|
|
+ state.graph.getCells().forEach(v => {
|
|
|
+ v.attr('select', false)
|
|
|
+ if (v.shape === 'edge') {
|
|
|
+ setEdgeStyle(v)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ state.graph.on('node:click', ({node}) => {
|
|
|
setTimeout(() => {
|
|
|
if (!state.isPort) {
|
|
|
WorkflowStore.nodePanel(node)
|
|
|
+ // state.graph.getCells().forEach(v => v.attr('select', false))
|
|
|
+ node.attr('select', true)
|
|
|
+ const connectEdges = state.graph.getConnectedEdges(node.id)
|
|
|
+ connectEdges.forEach(edge => {
|
|
|
+ edge.attr('select', true)
|
|
|
+ setEdgeStyle(edge)
|
|
|
+ })
|
|
|
}
|
|
|
}, 50)
|
|
|
})
|
|
|
- state.graph.on('node:port:click', ({ e, x, y, node, view, port }) => {
|
|
|
+ state.graph.on('edge:click', ({edge}) => {
|
|
|
+ edge.attr('select', true)
|
|
|
+ const connectNodes = state.graph.getNeighbors(edge)
|
|
|
+ connectNodes.forEach(node => {
|
|
|
+ node.attr('select', true)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ state.graph.on('node:port:click', () => {
|
|
|
state.isPort = true;
|
|
|
setTimeout(() => {
|
|
|
state.isPort = false
|
|
|
}, 100)
|
|
|
})
|
|
|
- state.graph.on('node:mouseenter', ({ e, node, view }) => {
|
|
|
+ state.graph.on('node:mouseenter', ({node}) => {
|
|
|
+ node.attr('hover', true)
|
|
|
const connectEdges = state.graph.getConnectedEdges(node.id)
|
|
|
connectEdges.forEach(edge => {
|
|
|
- edge.attr(lineActiveStyle)
|
|
|
+ edge.attr('hover', true)
|
|
|
+ setEdgeStyle(edge)
|
|
|
})
|
|
|
})
|
|
|
- state.graph.on('node:mouseleave', ({ e, node, view }) => {
|
|
|
+ state.graph.on('node:mouseleave', ({node}) => {
|
|
|
+ node.attr('hover', false)
|
|
|
const connectEdges = state.graph.getConnectedEdges(node.id)
|
|
|
connectEdges.forEach(edge => {
|
|
|
- edge.attr(lineStyle)
|
|
|
+ edge.attr('hover', false)
|
|
|
+ setEdgeStyle(edge)
|
|
|
})
|
|
|
})
|
|
|
- state.graph.on('edge:mouseenter', ({ e, edge, view }) => {
|
|
|
- edge.attr(lineActiveStyle)
|
|
|
+ state.graph.on('edge:mouseenter', ({edge}) => {
|
|
|
+ edge.attr('hover', true)
|
|
|
+ setEdgeStyle(edge)
|
|
|
const connectNodes = state.graph.getNeighbors(edge)
|
|
|
connectNodes.forEach(node => {
|
|
|
- node.attr('active', true)
|
|
|
+ node.attr('hover', true)
|
|
|
})
|
|
|
})
|
|
|
- state.graph.on('edge:mouseleave', ({ e, edge, view }) => {
|
|
|
- edge.attr(lineStyle)
|
|
|
+ state.graph.on('edge:mouseleave', ({edge}) => {
|
|
|
+ edge.attr('hover', false)
|
|
|
+ setEdgeStyle(edge)
|
|
|
const connectNodes = state.graph.getNeighbors(edge)
|
|
|
connectNodes.forEach(node => {
|
|
|
- node.attr('active', false)
|
|
|
+ node.attr('hover', false)
|
|
|
})
|
|
|
})
|
|
|
state.graph.on('scale', ({ sx, sy, ox, oy }) => {
|
|
@@ -433,6 +473,7 @@ const initPlug = () => {
|
|
|
}),
|
|
|
)
|
|
|
}
|
|
|
+const setEdgeStyle = (edge) => edge.attr('line', edge.getAttrByPath('hover') || edge.getAttrByPath('select') ? lineActiveStyle : lineStyle)
|
|
|
const graphZoom = (z) => {
|
|
|
if (z) {
|
|
|
state.graph.zoomTo(z)
|