MCPcopy
hub / github.com/tldraw/tldraw / getShape

Method getShape

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

* Get a shape by its id. * * @example * ```ts * editor.getShape('box1') * ``` * * @param shape - The shape (or the id of the shape) to get. * * @public

(shape: TLShape | TLParentId)

Source from the content-addressed store, hash-verified

6247 * @public
6248 */
6249 getShape<T extends TLShape = TLShape>(shape: TLShape | TLParentId): T | undefined {
6250 const id = typeof shape === 'string' ? shape : shape.id
6251 if (!isShapeId(id)) return undefined
6252 return this.store.get(id) as T
6253 }
6254
6255 /**
6256 * Get the parent shape for a given shape. Returns undefined if the shape is the direct child of

Callers 15

constructorMethod · 0.95
isAncestorSelectedMethod · 0.95
selectAllMethod · 0.95
selectAdjacentShapeMethod · 0.95
selectParentShapeMethod · 0.95
selectFirstChildShapeMethod · 0.95
getFocusedGroupMethod · 0.95
setFocusedGroupMethod · 0.95
getEditingShapeMethod · 0.95

Calls 2

isShapeIdFunction · 0.90
getMethod · 0.65

Tested by 15

createHighlightShapeFunction · 0.64
arrowFunction · 0.64
bindingsFunction · 0.64
arrowFunction · 0.64
createDrawShapeFunction · 0.64
geoShapeFunction · 0.64
lineShapeFunction · 0.64
getGeoFunction · 0.64
getShapeFunction · 0.64
rotateXFunction · 0.64