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.
import { AnnotationCommand } from 'substance'
config.addCommand('strong', AnnotationCommand, {nodeType: 'strong'})
Get the type of an annotation.
String | The annotation's type. |
Get the annotation's data.
Object | The annotation's data. |
Checks if command couldn't be executed with current selection.
annos | Array | annotations |
sel | Object | selection |
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.
annos | Array | annotations |
sel | Object | selection |
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.
annos | Array | annotations |
sel | Object | selection |
Boolean | Whether or not annotations could be fused. |
Checks if annotation could be deleted. Cursor or selection must be inside an existing annotation.
annos | Array | annotations |
sel | Object | selection |
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.
annos | Array | annotations |
sel | Object | selection |
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.
annos | Array | annotations |
sel | Object | selection |
Boolean | Whether or not annotation could be truncated. |
Gets command state object.
state.selection | Object | the current selection |
Object | info object with command details. |
Execute command and trigger transformation.
Object | info object with execution details. |
Apply an annotation transformation.
Object | transformed annotations. |