AnnotationCommand
Class defined in ui/AnnotationCommand.js#25 inherits from

A class for commands intended to be executed on the annotations.

See the example below to learn how to register an AnnotationCommand for a strong annotation.

Example
import { AnnotationCommand } from 'substance'

config.addCommand('strong', AnnotationCommand, {nodeType: 'strong'})

Get the type of an annotation.

Returns
String

The annotation's type.

Get the annotation's data.

Returns
Object

The annotation's data.

Checks if command couldn't be executed with current selection.

Parameters
annosArray

annotations

selObject

selection

Returns
Boolean

Whether or not command could be executed.

Checks if new annotations could be created. There should be no annotation overlapping, selection must be not collapsed.

Parameters
annosArray

annotations

selObject

selection

Returns
Boolean

Whether or not annotation could be created.

Checks if annotations could be fused. There should be more than one annotation overlaped by current selection.

Parameters
annosArray

annotations

selObject

selection

Returns
Boolean

Whether or not annotations could be fused.

Checks if annotation could be deleted. Cursor or selection must be inside an existing annotation.

Parameters
annosArray

annotations

selObject

selection

Returns
Boolean

Whether or not annotation could be deleted.

Checks if annotation could be expanded. There should be overlap with only a single annotation, selection should be also outside of this annotation.

Parameters
annosArray

annotations

selObject

selection

Returns
Boolean

Whether or not annotation could be expanded.

Checks if annotation could be truncated. There should be overlap with only a single annotation, selection should also have boundary in common with this annotation.

Parameters
annosArray

annotations

selObject

selection

Returns
Boolean

Whether or not annotation could be truncated.

Gets command state object.

Parameters
state.selectionObject

the current selection

Returns
Object

info object with command details.

Execute command and trigger transformation.

Returns
Object

info object with execution details.

Apply an annotation transformation.

Returns
Object

transformed annotations.