Skip to content
D
Documentation

SelectionManager

reference
1 min readUpdated

Import it from @grafloria/engine.

SelectionManager provides advanced selection operations

Implements 12 selection patterns from industry research:

  • Hierarchical: children, descendants, ancestors, siblings, tree
  • Graph: connected, connected component, path
  • Group: group members, groups containing
  • Filter: by type, by filter, in rectangle
  • Bulk: select all, invert selection
ts
class SelectionManager

Methods

  • constructor( diagram: DiagramModel | null, private store?: DiagramStore, private eventBus?: EventBus )
  • setDiagram(diagram: DiagramModel | null): void — Update diagram reference
  • selectChildren(nodeId: string, options: SelectionOptions = {}): string[] — Select immediate children of a node
  • selectDescendants(nodeId: string, options: SelectionOptions = {}): string[] — Select all descendants of a node (recursive)
  • selectAncestors(nodeId: string, options: SelectionOptions = {}): string[] — Select all ancestors of a node (recursive)
  • selectSiblings(nodeId: string, options: SelectionOptions = {}): string[] — Select all siblings of a node (nodes with same parent)
  • selectTree(nodeId: string, options: SelectionOptions = {}): string[] — Select entire tree starting from a node (node + all descendants)
  • selectConnected(nodeId: string, options: ConnectedSelectionOptions = {}): string[] — Select nodes directly connected to a node via links
  • selectConnectedComponent(nodeId: string, options: SelectionOptions = {}): string[] — Select entire connected component (all nodes reachable from a node)
  • selectPath(fromNodeId: string, toNodeId: string, options: SelectionOptions = {}): string[] — Select shortest path between two nodes
  • selectGroupMembers(groupId: string, options: SelectionOptions = {}): string[] — Select all members of a group
  • selectGroupsContaining(nodeId: string, options: SelectionOptions = {}): string[] — Select all groups that contain a specific node
  • selectByType(type: string, options: TypeSelectionOptions = {}): string[] — Select all nodes of a specific type
  • selectByFilter( predicate: (node: NodeModel) => boolean, options: FilterSelectionOptions = {} ): string[] — Select nodes matching a predicate function
  • selectInRectangle(rect: BoundingBox, options: RectSelectionOptions = {}): string[] — Select all nodes within or intersecting a rectangle
  • selectAll(options: BulkSelectionOptions = {}): { nodes: string[]; links: string[]; groups: string[] } — Select all entities in the diagram
  • invertSelection(options: BulkSelectionOptions = {}): { nodes: string[]; links: string[]; groups: string[] } — Invert current selection

Was this page helpful?

SelectionManager — Grafloria