Marker creation

A hash of key-value pairs to associate with the marker. There are also reserved property names that have marker-specific meaning.

reversed

optional

Boolean Creates the marker in a reversed orientation. (default: false)

invalidate

optional

String Determines the rules by which changes to the buffer invalidate the marker. (default: 'overlap') It can be any of the following strategies, in order of fragility:

never: The marker is never marked as invalid. This is a good choice for
markers representing selections in an editor.

surround: The marker is invalidated by changes that completely surround it.

overlap: The marker is invalidated by changes that surround the
start or end of the marker. This is the default.

inside: The marker is invalidated by changes that extend into the
inside of the marker. Changes that end at the marker's start or
start at the marker's end do not invalidate the marker.

touch: The marker is invalidated by a change that touches the marked
region in any way, including changes that end at the marker's
start or start at the marker's end. This is the most fragile strategy.

exclusive

Boolean indicating whether insertions at the start or end of the marked range should be interpreted as happening outside the marker. Defaults to false, except when using the inside invalidation strategy or when when the marker has no tail, in which case it defaults to true. Explicitly assigning this option overrides behavior in all circumstances.

String Determines the rules by which changes to the buffer invalidate the marker. (default: 'overlap') It can be any of the following strategies, in order of fragility:

never: The marker is never marked as invalid. This is a good choice for
markers representing selections in an editor.

surround: The marker is invalidated by changes that completely surround it.

overlap: The marker is invalidated by changes that surround the
start or end of the marker. This is the default.

inside: The marker is invalidated by changes that extend into the
inside of the marker. Changes that end at the marker's start or
start at the marker's end do not invalidate the marker.

touch: The marker is invalidated by a change that touches the marked
region in any way, including changes that end at the marker's
start or start at the marker's end. This is the most fragile strategy.

.exclusive

Boolean indicating whether insertions at the start or end of the marked range should be interpreted as happening outside the marker. Defaults to false, except when using the inside invalidation strategy or when when the marker has no tail, in which case it defaults to true. Explicitly assigning this option overrides behavior in all circumstances.

Return values

Returns a Marker.

Event subscription

Subscribe to be notified asynchronously whenever markers are
created, updated, or destroyed on this layer. Prefer this method for
optimal performance when interacting with layers that could contain large
numbers of markers.

Subscribers are notified once, asynchronously when any number of changes
occur in a given tick of the event loop. You should re-query the layer
to determine the state of markers in which you're interested in. It may
be counter-intuitive, but this is much more efficient than subscribing to
events on individual markers, which are expensive to deliver.

Argument

Description

callback()

A Function that will be called with no arguments when changes occur on this layer.