SyntheticBehaviorEvent
SyntheticBehaviorEvent = {
annotation: {_key?:string;name:string;value: {[prop:string]:unknown; }; };at?:NonNullable<EditorSelection>;type:StrictExtract<SyntheticBehaviorEventType,"annotation.add">; } | {annotation: {name:string; };at?:NonNullable<EditorSelection>;type:StrictExtract<SyntheticBehaviorEventType,"annotation.remove">; } | {at:BlockPath;props:Record<string,unknown>;type:StrictExtract<SyntheticBehaviorEventType,"block.set">; } | {at:BlockPath;props:string[];type:StrictExtract<SyntheticBehaviorEventType,"block.unset">; } | {at:ChildPath;props: {[prop:string]:unknown; };type:StrictExtract<SyntheticBehaviorEventType,"child.set">; } | {at:ChildPath;props:string[];type:StrictExtract<SyntheticBehaviorEventType,"child.unset">; } | {at?:NonNullable<EditorSelection>;decorator:string;type:StrictExtract<SyntheticBehaviorEventType,"decorator.add">; } | {at?:NonNullable<EditorSelection>;decorator:string;type:StrictExtract<SyntheticBehaviorEventType,"decorator.remove">; } | {at?:NonNullable<EditorSelection>;direction?:"backward"|"forward";type:StrictExtract<SyntheticBehaviorEventType,"delete">;unit?:"character"|"word"|"line"|"block"|"child"; } | {type:StrictExtract<SyntheticBehaviorEventType,"history.redo">; } | {type:StrictExtract<SyntheticBehaviorEventType,"history.undo">; } | {at:Path;position:"before"|"after";type:StrictExtract<SyntheticBehaviorEventType,"insert">;value:PortableTextTextBlock|PortableTextObject|PortableTextSpan; } | {at?:NonNullable<EditorSelection>;block:BlockWithOptionalKey;placement:InsertPlacement;select?:"start"|"end"|"none";type:StrictExtract<SyntheticBehaviorEventType,"insert.block">; } | {child:ChildWithOptionalKey;type:StrictExtract<SyntheticBehaviorEventType,"insert.child">; } | {at?:Path;offset?:number;text:string;type:StrictExtract<SyntheticBehaviorEventType,"insert.text">; } | {distance:number;type:StrictExtract<SyntheticBehaviorEventType,"move.backward">; } | {distance:number;type:StrictExtract<SyntheticBehaviorEventType,"move.forward">; } | {at:Path;offset:number;text:string;type:StrictExtract<SyntheticBehaviorEventType,"remove.text">; } | {at:EditorSelection;type:StrictExtract<SyntheticBehaviorEventType,"select">; } | {at:Path;type:StrictExtract<SyntheticBehaviorEventType,"set">;value:unknown; } | {at:Path;type:StrictExtract<SyntheticBehaviorEventType,"unset">; } |AbstractBehaviorEvent
Defined in: behavior.types.event.ts:102
Type Declaration
Section titled “Type Declaration”{ annotation: { _key?: string; name: string; value: {[prop: string]: unknown; }; }; at?: NonNullable<EditorSelection>; type: StrictExtract<SyntheticBehaviorEventType, "annotation.add">; }
annotation
Section titled “annotation”annotation:
object
annotation._key?
Section titled “annotation._key?”
optional_key:string
annotation.name
Section titled “annotation.name”name:
string
annotation.value
Section titled “annotation.value”value:
object
Index Signature
Section titled “Index Signature”[prop: string]: unknown
optionalat:NonNullable<EditorSelection>
type:
StrictExtract<SyntheticBehaviorEventType,"annotation.add">
{ annotation: { name: string; }; at?: NonNullable<EditorSelection>; type: StrictExtract<SyntheticBehaviorEventType, "annotation.remove">; }
annotation
Section titled “annotation”annotation:
object
annotation.name
Section titled “annotation.name”name:
string
optionalat:NonNullable<EditorSelection>
type:
StrictExtract<SyntheticBehaviorEventType,"annotation.remove">
{ at: BlockPath; props: Record<string, unknown>; type: StrictExtract<SyntheticBehaviorEventType, "block.set">; }
at:
BlockPath
props:
Record<string,unknown>
type:
StrictExtract<SyntheticBehaviorEventType,"block.set">
{ at: BlockPath; props: string[]; type: StrictExtract<SyntheticBehaviorEventType, "block.unset">; }
at:
BlockPath
props:
string[]
type:
StrictExtract<SyntheticBehaviorEventType,"block.unset">
{ at: ChildPath; props: {[prop: string]: unknown; }; type: StrictExtract<SyntheticBehaviorEventType, "child.set">; }
at:
ChildPath
props:
object
Index Signature
Section titled “Index Signature”[prop: string]: unknown
type:
StrictExtract<SyntheticBehaviorEventType,"child.set">
{ at: ChildPath; props: string[]; type: StrictExtract<SyntheticBehaviorEventType, "child.unset">; }
at:
ChildPath
props:
string[]
type:
StrictExtract<SyntheticBehaviorEventType,"child.unset">
{ at?: NonNullable<EditorSelection>; decorator: string; type: StrictExtract<SyntheticBehaviorEventType, "decorator.add">; }
optionalat:NonNullable<EditorSelection>
decorator
Section titled “decorator”decorator:
string
type:
StrictExtract<SyntheticBehaviorEventType,"decorator.add">
{ at?: NonNullable<EditorSelection>; decorator: string; type: StrictExtract<SyntheticBehaviorEventType, "decorator.remove">; }
optionalat:NonNullable<EditorSelection>
decorator
Section titled “decorator”decorator:
string
type:
StrictExtract<SyntheticBehaviorEventType,"decorator.remove">
{ at?: NonNullable<EditorSelection>; direction?: "backward" | "forward"; type: StrictExtract<SyntheticBehaviorEventType, "delete">; unit?: "character" | "word" | "line" | "block" | "child"; }
optionalat:NonNullable<EditorSelection>
direction?
Section titled “direction?”
optionaldirection:"backward"|"forward"
Defaults to forward deletion.
type:
StrictExtract<SyntheticBehaviorEventType,"delete">
optionalunit:"character"|"word"|"line"|"block"|"child"
Defaults to character deletion.
{ type: StrictExtract<SyntheticBehaviorEventType, "history.redo">; }
type:
StrictExtract<SyntheticBehaviorEventType,"history.redo">
{ type: StrictExtract<SyntheticBehaviorEventType, "history.undo">; }
type:
StrictExtract<SyntheticBehaviorEventType,"history.undo">
{ at: Path; position: "before" | "after"; type: StrictExtract<SyntheticBehaviorEventType, "insert">; value: PortableTextTextBlock | PortableTextObject | PortableTextSpan; }
at:
Path
position
Section titled “position”position:
"before"|"after"
type:
StrictExtract<SyntheticBehaviorEventType,"insert">
Primitive: insert a node into an array.
The last segment of at resolves the insertion point:
- A keyed
{_key}segment inserts relative to that sibling. - A numeric index inserts relative to that slot.
position (‘before’ or ‘after’) is always meaningful: before: [2]
inserts at index 2, after: [2] inserts at index 3.
Example
Section titled “Example”raise({ type: 'insert', at: [{_key: 'list'}, 'items', {_key: 'item3'}], value: newItem, position: 'after',})value:
PortableTextTextBlock|PortableTextObject|PortableTextSpan
{ at?: NonNullable<EditorSelection>; block: BlockWithOptionalKey; placement: InsertPlacement; select?: "start" | "end" | "none"; type: StrictExtract<SyntheticBehaviorEventType, "insert.block">; }
optionalat:NonNullable<EditorSelection>
block:
BlockWithOptionalKey
placement
Section titled “placement”placement:
InsertPlacement
select?
Section titled “select?”
optionalselect:"start"|"end"|"none"
type:
StrictExtract<SyntheticBehaviorEventType,"insert.block">
{ child: ChildWithOptionalKey; type: StrictExtract<SyntheticBehaviorEventType, "insert.child">; }
child:
ChildWithOptionalKey
type:
StrictExtract<SyntheticBehaviorEventType,"insert.child">
{ at?: Path; offset?: number; text: string; type: StrictExtract<SyntheticBehaviorEventType, "insert.text">; }
optionalat:Path
offset?
Section titled “offset?”
optionaloffset:number
text:
string
type:
StrictExtract<SyntheticBehaviorEventType,"insert.text">
Inserts text into a span.
Without at/offset, text is inserted at the current caret position.
This is the form used by typing handlers.
With at and offset, text is inserted at the explicit position.
Recommended for plugin behaviors and collaborative-edit contexts.
Example
Section titled “Example”// Caret formraise({type: 'insert.text', text: 'x'})
// Primitive form (@alpha)raise({ type: 'insert.text', at: [{_key: 'b1'}, 'children', {_key: 's1'}], offset: 5, text: 'world',}){ distance: number; type: StrictExtract<SyntheticBehaviorEventType, "move.backward">; }
distance
Section titled “distance”distance:
number
type:
StrictExtract<SyntheticBehaviorEventType,"move.backward">
{ distance: number; type: StrictExtract<SyntheticBehaviorEventType, "move.forward">; }
distance
Section titled “distance”distance:
number
type:
StrictExtract<SyntheticBehaviorEventType,"move.forward">
{ at: Path; offset: number; text: string; type: StrictExtract<SyntheticBehaviorEventType, "remove.text">; }
at:
Path
offset
Section titled “offset”offset:
number
text:
string
type:
StrictExtract<SyntheticBehaviorEventType,"remove.text">
Primitive: remove text from a span at the given offset.
The text field carries the exact text being removed (matches the
apply-layer shape so the inverse can be computed without re-reading
the span).
Recommended for collaborative-edit contexts (concurrent edits compose cleanly under operational transform).
Example
Section titled “Example”raise({ type: 'remove.text', at: [{_key: 'b1'}, 'children', {_key: 's1'}], offset: 5, text: 'world',}){ at: EditorSelection; type: StrictExtract<SyntheticBehaviorEventType, "select">; }
at:
EditorSelection
type:
StrictExtract<SyntheticBehaviorEventType,"select">
{ at: Path; type: StrictExtract<SyntheticBehaviorEventType, "set">; value: unknown; }
at:
Path
type:
StrictExtract<SyntheticBehaviorEventType,"set">
Primitive: set a property on a node, or replace a node wholesale.
The last segment of at is the property name (a string) for property
updates, OR a keyed/indexed segment for full-node replacement.
Note: set on span text ({at: [...spanPath, 'text'], value: '...'})
is legal but not recommended in collaborative-edit contexts. Use
insert.text and remove.text for text edits that compose under
operational transform.
Example
Section titled “Example”// Set a block's styleraise({type: 'set', at: [{_key: 'b1'}, 'style'], value: 'h1'})
// Replace a block wholesaleraise({type: 'set', at: [{_key: 'b1'}], value: newBlock})value:
unknown
{ at: Path; type: StrictExtract<SyntheticBehaviorEventType, "unset">; }
at:
Path
type:
StrictExtract<SyntheticBehaviorEventType,"unset">
Primitive: unset a property on an object, OR remove a node from an array.
When the last segment of at is a string, the property is removed.
When the last segment is a keyed {_key} segment or a numeric index,
the node at that array position is removed.
Example
Section titled “Example”// Remove a propertyraise({type: 'unset', at: [{_key: 'b1'}, 'level']})
// Remove a node from an arrayraise({type: 'unset', at: [{_key: 'list'}, 'items', {_key: 'item3'}]})AbstractBehaviorEvent