Import it from @grafloria/engine.
Also has every member of DiagramEntity, listed on its own entry.
tsclass NodeModel extends DiagramEntity
Properties
| Name | Type | Default | Description |
|---|---|---|---|
diagram? | DiagramModel | ||
position | Point | ||
size | Size | ||
rotation | number | 0 | |
scale | Point | ||
positionMode | PositioningMode | 'absolute' | |
transformOrigin | Point | ||
zIndex? | number | Model-level stacking order (lower renders further back), as on GroupModel. A document fact, so undo and the diff/collab layers see it (unlike style.zIndex). | |
flexConfig? | FlexItemConfig | ||
gridConfig? | GridItemConfig | ||
portRenderingConfig? | any | ||
dragHandlerConfig? | any | ||
connectionGroup? | string | ||
type | string | ||
systemType? | string | ||
definitionId? | string | ||
parentId? | string | ||
children | Set<string> | ||
depth | number | 0 | |
ports | Map<string, PortModel> | ||
state | NodeState | ||
behavior | NodeBehavior | ||
style | Partial<NodeStyle> | {} | |
classes | Set<string> | ||
data | Record<string, any> | {} | |
computed | Map<string, any> |
Methods
constructor(config: { id?: string; type: string; position: Point; size?: Size; systemType?: string; definitionId?: string; })setPosition(x: number, y: number, z?: number): void— Set positionmove(dx: number, dy: number, dz?: number): void— Move by deltasetSize(width: number, height: number, depth?: number): void— Set size.resize(dw: number, dh: number, dd?: number): void— Resize by deltasetRotation(degrees: number): void— Set rotationrotate(degrees: number): void— Rotate by deltasetScale(x: number, y: number): void— Set scaleaddPort(port: PortModel): void— Add portremovePort(portId: string): PortModel | undefined— Remove portgetPort(portId: string): PortModel | undefined— Get port by IDgetPorts(): PortModel[]— Get all portsgetIncomingLinks(): import('./LinkModel').LinkModel[]— Links arriving at this node (resolved through the owning diagram; empty when the node isn't attached to a diagram yet)getOutgoingLinks(): import('./LinkModel').LinkModel[]— Links leaving this node (resolved through the owning diagram)getPortsByType(type: 'input' | 'output' | 'bi'): PortModel[]— Get ports by typegetPortBySide(side: 'top' | 'right' | 'bottom' | 'left'): PortModel | undefined— Get port by side Returns the first port found on the specified sidegetPortsBySide(side: 'top' | 'right' | 'bottom' | 'left'): PortModel[]— Get all ports on a specific side Useful for nodes with multiple ports per sidegetAvailablePorts(type?: 'input' | 'output' | 'bi'): PortModel[]— Get available ports that can accept connectionsgetConnectedPorts(): PortModel[]— Get ports that have active connectionssetState(state: Partial<NodeState>): void— Set state propertyreplaceState(state: Partial<NodeState>): void— REPLACE the DOCUMENT half ofstate, keeping THIS viewer's own view half.setBehavior(behavior: Partial<NodeBehavior>): void— Set behavior propertyisSelected(): boolean— Check if node is selectedsetSelected(selected: boolean): void— Set selection stateisHighlighted(): boolean— Check if node is highlighted (attention state, independent of selection)setHighlighted(highlighted: boolean): void— Set highlight state (attention emphasis without selecting the node)isSelectable(): boolean— Check if node is selectable (based on behavior) Note: Locked nodes are still selectable so users can unlock themisDraggable(): boolean— Check if node is draggable (based on behavior and state) Note: Locked nodes cannot be draggedsetStyle(style: Partial<NodeStyle>): void— Set style propertyreplaceStyle(style: Partial<NodeStyle>): void— REPLACE the whole style object — the writesetStylecannot express.addClass(className: string): void— Add CSS classremoveClass(className: string): void— Remove CSS classsetClasses(classNames: string[]): void— REPLACE the whole class collection.setData(key: string, value: any): void— Set data propertygetData(key: string): any— Get data propertysetComputed(key: string, value: any): void— Set computed propertygetComputed(key: string): any— Get computed propertygetWorldPosition(): Point— Get world position (absolute coordinates accounting for parent chain) For nodes without parents, this is the same as position For child nodes, this walks up the parent chain and accumulates offsetsgetBoundingBox(): BoundingBox— Get bounding box in world coordinates For child nodes, this accounts for parent positiongetCenter(): Point— Get center point in world coordinatescontainsPoint(point: Point): boolean— Check if point is inside nodeintersectsBounds(bounds: BoundingBox): boolean— Check if intersects with bounding boxsetParent(parentId: string | undefined): void— Set parentaddChild(childId: string): void— Add childremoveChild(childId: string): void— Remove childsetChildren(childIds: string[]): void— REPLACE the whole child collection. The collab reducer's write path.setTransformOrigin(x: number, y: number): void— Set transform origingetAbsoluteTransformOrigin(): Point— Get absolute transform origin in pixelsgetLocalPosition(): Point— Get local position Returns the position property as-isgetGlobalPosition(): Point— Get global position In absolute mode: returns position as-is In relative mode: transforms position by parent's hierarchy transformsetLocalPosition(x: number, y: number, z?: number): void— Set local position Sets position directly and switches to relative modesetGlobalPosition(x: number, y: number, z?: number): void— Set global position Converts global coordinates to local if parent existsgetLocalTransformMatrix(): TransformMatrix— Get local transform matrix Composes translation, rotation, and scale relative to transform origingetGlobalTransformMatrix(): TransformMatrix— Get global transform matrix In absolute mode: returns local matrix In relative mode: composes parent's global matrix with local matrixgetGlobalBounds(): BoundingBox— Get global bounding box Calculates bounds by transforming all 4 corners through global matrixgetChildren(): NodeModel[]— Get direct children nodesgetParent(): NodeModel | undefined— Get parent node Public version of getParentNodegetAncestors(): NodeModel[]— Get all ancestor nodes up to root Returns array with direct parent first, then grandparent, etc.getDescendants(): NodeModel[]— Get all descendant nodes recursivelygetRoot(): NodeModel— Get root node of hierarchy Returns self if this is the rootgetSiblings(): NodeModel[]— Get sibling nodes (same parent, excluding self)isAncestorOf(nodeId: string): boolean— Check if this node is an ancestor of another nodegetDepth(): number— Get depth in hierarchy Root nodes have depth 0, their children have depth 1, etc.validateHierarchy(): boolean— Validate hierarchy for circular referencesupdateHierarchyDepth(): void— Update depth for this node and all descendants Recalculates depth values based on current hierarchygetAffectedByTransform(): NodeModel[]— Get all nodes affected by transform changes Returns this node plus all descendants in relative positioning modegetEffectiveZIndex(): number— The stacking index a renderer should paint by.setZIndex(z: number | undefined): void— Set the stacking index (lower renders further back). Tracked for undo/diff.bringToFront(diagram?: DiagramModel): void— Bring this node in front of every other node in the diagram. Falls back to a relative bump when the node is detached, exactly asGroupModel.bringToFrontdoes.sendToBack(diagram?: DiagramModel): void— Send this node behind every other node in the diagram.setFlexItem(config: FlexItemConfig): void— Set flexbox item configurationclearFlexItem(): void— Clear flexbox item configurationgetFlexItem(): FlexItemConfig | undefined— Get flexbox item configurationhasFlexItem(): boolean— Check if node has flex item configurationsetGridItem(config: GridItemConfig): void— Set grid item configurationclearGridItem(): void— Clear grid item configurationgetGridItem(): GridItemConfig | undefined— Get grid item configurationhasGridItem(): boolean— Check if node has grid item configurationsetPortRenderingConfig(config: any): void— Set port rendering configurationgetPortRenderingConfig(): any | undefined— Get port rendering configurationgetPortRenderingMode(): 'svg' | 'html' | 'auto'— Get port rendering mode Auto-detects based on configuration and metadatasetDragHandlerConfig(config: any): void— Set drag handler configurationgetDragHandlerConfig(): any | undefined— Get drag handler configurationisDragHandler(): boolean— Check if this node is a drag handlersetConnectionGroup(group: string): void— Set connection groupgetConnectionGroup(): string | undefined— Get connection groupserialize(): SerializedNode— Serialize to JSONstatic fromJSON(data: SerializedNode): NodeModel(static) — Deserialize from JSON
Was this page helpful?