Behavior API
Reference docs for the behavior API.
defineBehavior
Options Object
- on (string): Internal editor event
- guard (function or boolean): function accepts
context
andevent
, returns boolean - actions (array): function accepts
context
andevent
, returns array of actions
Example
Behavior Event types
Native event types
- copy
- paste
- key.down
- key.up
Synthetic event types
- annotation.add
- annotation.remove
- blur
- decorator.toggle
- delete.backward
- delete.forward
- focus
- insert.block object
- insert.inline object
- insert.break
- insert.sort break
- insert.text
- list item.toggle
- select
- style.toggle
Behavior Actions
Actions as part of synthetic events
- annotation.add
- annotation.remove
- blur
- decorator.toggle
- delete.backward
- delete.forward
- focus
- insert.block object
- insert.inline object
- insert.break
- insert.sort break
- insert.text
- list item.toggle
- select
- style.toggle
Additional actions
- annotation.toggle
- decorator.add
- decorator.remove
- insert.span
- insert.text block
- list item.add
- list item.remove
- move.block
- move.block down
- move.block up
- noop
- delete.block
- delete.text
- effect
- raise
- select.previous block
- select.next block
- style.add
- style.remove
- text block.set
- text block.unset
raise
The raise
action type is used to trigger synthetic events.
Properties:
- type:
raise
- event: Behavior event object
The raise
action also has a handy shorthand function. It accepts a behavior event object.