MCPcopy
hub / github.com/tldraw/tldraw / isAncestorSelected

Method isAncestorSelected

packages/editor/src/lib/editor/Editor.ts:2090–2096  ·  view source on GitHub ↗

* Determine whether or not any of a shape's ancestors are selected. * * @param shape - The shape (or shape id) of the shape to check. * * @public

(shape: TLShape | TLShapeId)

Source from the content-addressed store, hash-verified

2088 * @public
2089 */
2090 isAncestorSelected(shape: TLShape | TLShapeId): boolean {
2091 const id = typeof shape === 'string' ? shape : (shape?.id ?? null)
2092 const _shape = this.getShape(id)
2093 if (!_shape) return false
2094 const selectedShapeIds = this.getSelectedShapeIds()
2095 return !!this.findShapeAncestor(_shape, (parent) => selectedShapeIds.includes(parent.id))
2096 }
2097
2098 /**
2099 * Select one or more shapes.

Callers 1

onTranslateStartMethod · 0.80

Calls 4

getShapeMethod · 0.95
getSelectedShapeIdsMethod · 0.95
findShapeAncestorMethod · 0.95
includesMethod · 0.80

Tested by

no test coverage detected