TLBindingCreate
Type for creating new bindings with required fromId and toId. The id is optional and will be generated if not provided.
type TLBindingCreate<T extends TLBinding = TLBinding> = T extends T
? {
fromId: T["fromId"];
id?: TLBindingId;
meta?: Partial<T["meta"]>;
props?: Partial<T["props"]>;
toId: T["toId"];
type: T["type"];
typeName?: T["typeName"];
}
: never;Example
// Create a new arrow binding
const newBinding: TLBindingCreate<TLArrowBinding> = {
type: "arrow",
fromId: "shape:arrow1",
toId: "shape:rectangle1",
props: {
terminal: "end",
normalizedAnchor: { x: 0.5, y: 0.5 },
isExact: false,
isPrecise: true,
},
};
editor.createBindings([newBinding]);Prev
TLBindingNext
TLBindingId