@mocanvas/editor · class
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): booleanWhether child may become a child of shape. @see onDragShapesIn
canDropShapes(shape: T, _shapes: UnknownShape[]): booleancanReceiveNewChildrenOfType(shape: T, _type: string): booleancanRemoveChildrenOfType(shape: T, _type: string): booleangetClipPath(shape?: T): VecLike[] | undefinedThe 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): booleanClipping 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): booleanonDragShapesIn(shape: T, shapes: UnknownShape[]): voidAdopt 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[]): voidRelease the shapes dragged out of this container, back onto the container's own parent.
providesBackgroundForChildren(_shape?: T): booleanA 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.