@mocanvas/editor · class

BindingUtil

declare abstract class BindingUtil<B extends UnknownBinding = UnknownBinding>

Describes how a binding type behaves. One instance per binding type per editor. Callbacks run inside the store transaction that caused them.


Methods · 3

constructor(editor: Editor)
abstract getDefaultProps(): Partial<B["props"]>
get type(): B["type"]

Properties · 17

canBind?(options: BindingCanBindOptions): boolean

Whether this binding type may connect these two shapes.

Consulted alongside ShapeUtil.canBind, which asks the same question from the shape's side; both must say yes.

readonly editor: Editor
static migrations?: unknown
onAfterChange?(options: BindingOnChangeOptions<B>): void
onAfterChangeFromShape?(options: BindingOnShapeChangeOptions<B>): void

The from shape changed (moved, resized, ...).

onAfterChangeToShape?(options: BindingOnShapeChangeOptions<B>): void

The to shape changed.

onAfterCreate?(options: BindingOnCreateOptions<B>): void
onAfterDelete?(options: BindingOnDeleteOptions<B>): void
onBeforeChange?(options: BindingOnChangeOptions<B>): B | void
onBeforeCreate?(options: BindingOnCreateOptions<B>): B | void
onBeforeDelete?(options: BindingOnDeleteOptions<B>): void
onBeforeDeleteFromShape?(options: BindingOnShapeDeleteOptions<B>): void

The from shape is about to be deleted; the binding is deleted right after.

onBeforeDeleteToShape?(options: BindingOnShapeDeleteOptions<B>): void

The to shape is about to be deleted; the binding is deleted right after.

onBeforeIsolateFromShape?(options: BindingOnShapeIsolateOptions<B>): void

The from shape is being isolated (partner going away); typically the binding converts to a static value.

onBeforeIsolateToShape?(options: BindingOnShapeIsolateOptions<B>): void
static props?: UnknownRecordProps

One validator per prop of the binding this util describes — the contract the store checks a record against before it is written, and what createSchema() reads to build the document schema. A binding type that declares none is not validated: see createBindingRecordType.

static type: string

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.