@mocanvas/editor · class

BaseFrameLikeShapeUtil

declare abstract class BaseFrameLikeShapeUtil<T extends FrameLikeShape = FrameLikeShape> extends BaseBoxShapeUtil<T>

Container behaviour, complete, for a w/h shape.

What you get by extending it: the shape answers ShapeUtil.isFrameLike true, clips its descendants to its own box, admits and releases children unless it is locked, and reparents shapes dragged in and out — including the ancestor-cycle guard that stops a container being dropped into its own descendant.

What a subclass typically changes:

- getClipPath → undefined turns an artboard into a *region*: it still groups, but stops cropping what hangs over its edge. Clipping is derived from this method, so the one override is enough. - canReceiveNewChildrenOfType narrows what may be dropped in. - canRemoveChildrenOfType is separate on purpose, so admission can be strict while removal stays permissive.


Methods · 10

protected canAdopt(shape: T, child: UnknownShape): boolean

Whether child may become a child of shape. @see onDragShapesIn

canDropShapes(shape: T, _shapes: UnknownShape[]): boolean
canReceiveNewChildrenOfType(shape: T, _type: string): boolean
canRemoveChildrenOfType(shape: T, _type: string): boolean
getClipPath(shape?: T): VecLike[] | undefined

The container's own box, as a polygon. Return undefined to stop clipping.

shape is optional to match the base signature — a subclass that clips nothing overrides this with a no-argument method — and a call without it has no box to describe.

isClipShape(shape: T): boolean

Clipping is *derived* from BaseFrameLikeShapeUtil.getClipPath, so a subclass that returns undefined from that one method stops cropping without having to know this hook exists.

isFrameLike(_shape: T): boolean
onDragShapesIn(shape: T, shapes: UnknownShape[]): void

Adopt the shapes dragged onto this container.

A shape is adopted only if the container admits its type, the shape is not locked, and the container is not one of the shape's own descendants — reparenting into a descendant would make a cycle in the shape tree.

onDragShapesOut(shape: T, shapes: UnknownShape[]): void

Release the shapes dragged out of this container, back onto the container's own parent.

providesBackgroundForChildren(_shape?: T): boolean

A container paints the surface its children sit on.

Mentioned here

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.