defineBehavior
defineBehavior<
TPayload,TBehaviorEventType,TGuardResponse>(behavior):Behavior
Defined in: behavior.types.behavior.ts:56
Type Parameters
Section titled “Type Parameters”TPayload
Section titled “TPayload”TPayload extends Record<string, unknown>
TBehaviorEventType
Section titled “TBehaviorEventType”TBehaviorEventType extends `custom.${string}` | "*" | "annotation.add" | "annotation.remove" | "block.set" | "block.unset" | "child.set" | "child.unset" | "decorator.add" | "decorator.remove" | "delete" | "history.redo" | "history.undo" | "insert.block" | "insert.child" | "insert.text" | "move.backward" | "move.block" | "move.forward" | "select" | "annotation.set" | "annotation.toggle" | "decorator.toggle" | "delete.backward" | "delete.block" | "delete.child" | "delete.forward" | "delete.text" | "deserialize" | "deserialize.data" | "deserialization.success" | "deserialization.failure" | "insert.blocks" | "insert.break" | "insert.inline object" | "insert.soft break" | "insert.span" | "list item.add" | "list item.remove" | "list item.toggle" | "move.block down" | "move.block up" | "select.block" | "select.previous block" | "select.next block" | "serialize" | "serialize.data" | "serialization.success" | "serialization.failure" | "split" | "style.add" | "style.remove" | "style.toggle" | "clipboard.copy" | "clipboard.cut" | "clipboard.paste" | "drag.dragstart" | "drag.drag" | "drag.dragend" | "drag.dragenter" | "drag.dragover" | "drag.dragleave" | "drag.drop" | "input.*" | "keyboard.keydown" | "keyboard.keyup" | "mouse.click" | "delete.*" | "select.*" | "deserialize.*" | "serialize.*" | "split.*" | "annotation.*" | "block.*" | "child.*" | "decorator.*" | "history.*" | "insert.*" | "move.*" | "deserialization.*" | "list item.*" | "serialization.*" | "style.*" | "clipboard.*" | "drag.*" | "keyboard.*" | "mouse.*" = `custom.${string}`
TGuardResponse
Section titled “TGuardResponse”TGuardResponse = true
Parameters
Section titled “Parameters”behavior
Section titled “behavior”Behavior<TBehaviorEventType, TGuardResponse, ResolveBehaviorEvent<TBehaviorEventType, TPayload>>
Returns
Section titled “Returns”Example
Section titled “Example”const noLowerCaseA = defineBehavior({ on: 'insert.text', guard: ({event, snapshot}) => event.text === 'a', actions: [({event, snapshot}) => [{type: 'insert.text', text: 'A'}]],})