Skip to main content
Version: v1

StablePlace Interface

A location in a trait. This is NOT the location of a node, but a location where a node could be inserted: it is next to a sibling or at one end of the trait.

To be well formed, either sibling or trait must be defined, but not both.

Any given insertion location can be described by two StablePlace objects, one with Side.After and one with Side.Before. For example, in a trait containing two strings "foo" and "bar", there are 6 different StablePlaces corresponding to 3 locations in the trait a new node could be inserted: at the start, before "foo", after "foo", before "bar", after "bar", and at the end. Neither of the two ways to specify the same location are considered to be after each other.

The anchor (referenceSibling or referenceTrait) used for a particular StablePlace can have an impact in collaborative scenarios.

StablePlace objects can be conveniently constructed with the helper methods exported on a constant of the same name.

Signature

export interface StablePlace

Example

StablePlace.before(node) StablePlace.atStartOf(trait)

Properties

Property Modifiers Type Description
referenceSibling optional NodeId The sibling to which this 'StablePlace' is anchored (by 'side'). If specified, referenceTrait must be unspecified.
referenceTrait optional TraitLocation The trait to which this 'StablePlace' is anchored (by 'side'). If specified, referenceSibling must be unspecified.
side Side Where this StablePlace is relative to the sibling (if specified), or an end of the trait (if no sibling specified). If 'After' and there is no sibling, this StablePlace is after the front of the trait. If 'Before' and there is no sibling, this StablePlace is before the back of the trait.

Property Details

referenceSibling

The sibling to which this 'StablePlace' is anchored (by 'side'). If specified, referenceTrait must be unspecified.

Signature

readonly referenceSibling?: NodeId;

Type: NodeId

referenceTrait

The trait to which this 'StablePlace' is anchored (by 'side'). If specified, referenceSibling must be unspecified.

Signature

readonly referenceTrait?: TraitLocation;

Type: TraitLocation

side

Where this StablePlace is relative to the sibling (if specified), or an end of the trait (if no sibling specified). If 'After' and there is no sibling, this StablePlace is after the front of the trait. If 'Before' and there is no sibling, this StablePlace is before the back of the trait.

Signature

readonly side: Side;

Type: Side