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'})

new AnnotationCommand()
Constructor defined in ui/AnnotationCommand.js#27
this.getAnnotationType()
Method defined in ui/AnnotationCommand.js#40

Get the type of an annotation.

Returns

String | The annotation's type.

this.getAnnotationData()
Method defined in ui/AnnotationCommand.js#49

Get the annotation's data.

Returns

Object | The annotation's data.

this.isDisabled(annos, sel)
Method defined in ui/AnnotationCommand.js#61

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

Parameters

annos | Array | annotations
sel | Object | selection

Returns

Boolean | Whether or not command could be executed.

this.canCreate(annos, sel)
Method defined in ui/AnnotationCommand.js#81

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

Parameters

annos | Array | annotations
sel | Object | selection

Returns

Boolean | Whether or not annotation could be created.

this.canFuse(annos, sel)
Method defined in ui/AnnotationCommand.js#95

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

Parameters

annos | Array | annotations
sel | Object | selection

Returns

Boolean | Whether or not annotations could be fused.

this.canDelete(annos, sel)
Method defined in ui/AnnotationCommand.js#109

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

Parameters

annos | Array | annotations
sel | Object | selection

Returns

Boolean | Whether or not annotation could be deleted.

this.canExpand(annos, sel)
Method defined in ui/AnnotationCommand.js#126

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

Parameters

annos | Array | annotations
sel | Object | selection

Returns

Boolean | Whether or not annotation could be expanded.

this.canTruncate(annos, sel)
Method defined in ui/AnnotationCommand.js#142

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

annos | Array | annotations
sel | Object | selection

Returns

Boolean | Whether or not annotation could be truncated.

this.getCommandState()
Method defined in ui/AnnotationCommand.js#157

Gets command state object.

Parameters

state.selection | Object | the current selection

Returns

Object | info object with command details.

this.execute()
Method defined in ui/AnnotationCommand.js#198

Execute command and trigger transformation.

Returns

Object | info object with execution details.

this._applyTransform()
Method defined in ui/AnnotationCommand.js#318

Apply an annotation transformation.

Returns

Object | transformed annotations.