MCPcopy Create free account
hub / github.com/alibaba/lowcode-graph / getGraphState

Function getGraphState

packages/plugin-tools/src/common/utils.ts:83–102  ·  view source on GitHub ↗
(graph: G6.Graph)

Source from the content-addressed store, hash-verified

81
82/** 获取图表状态 */
83export function getGraphState(graph: G6.Graph): GraphState {
84 let graphState: GraphState = GraphState.MultiSelected;
85
86 const selectedNodes = getSelectedNodes(graph);
87 const selectedEdges = getSelectedEdges(graph);
88
89 if (selectedNodes.length === 1 && !selectedEdges.length) {
90 graphState = GraphState.NodeSelected;
91 }
92
93 if (selectedEdges.length === 1 && !selectedNodes.length) {
94 graphState = GraphState.EdgeSelected;
95 }
96
97 if (!selectedNodes.length && !selectedEdges.length) {
98 graphState = GraphState.CanvasSelected;
99 }
100
101 return graphState;
102}
103
104/** 设置选中元素 */
105export function setSelectedItems(graph: G6.Graph, items: G6.Item[] | string[]) {

Callers 1

setSelectedItemsFunction · 0.70

Calls 2

getSelectedNodesFunction · 0.70
getSelectedEdgesFunction · 0.70

Tested by

no test coverage detected