Skip to content

Commit

Permalink
Added cancelSelected event
Browse files Browse the repository at this point in the history
  • Loading branch information
rsimon committed Sep 23, 2022
1 parent ccd7177 commit 48435f5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ <h1>Homer: The Odyssey</h1>
console.log('updated', previous, 'with', annotation);
});

r.on('cancelSelected', function(annotation) {
console.log('cancel', annotation);
});

// Wire the Add/Update/Remove buttons
document.getElementById('add-annotation').addEventListener('click', function() {
r.addAnnotation(myAnnotation);
Expand Down
3 changes: 2 additions & 1 deletion src/TextAnnotator.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,10 @@ export default class TextAnnotator extends Component {
}

/** Cancel button on annotation editor **/
onCancelAnnotation = () => {
onCancelAnnotation = annotation => {
this.clearState();
this.selectionHandler.clearSelection();
this.props.onCancelSelected(annotation);
}

/************************/
Expand Down
4 changes: 4 additions & 0 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export class Recogito {
onAnnotationCreated={this.handleAnnotationCreated}
onAnnotationUpdated={this.handleAnnotationUpdated}
onAnnotationDeleted={this.handleAnnotationDeleted}
onCancelSelected={this.handleCancelSelected}
relationVocabulary={config.relationVocabulary} />, this._appContainerEl);
}

Expand All @@ -93,6 +94,9 @@ export class Recogito {
handleAnnotationDeleted = annotation =>
this._emitter.emit('deleteAnnotation', annotation.underlying);

handleCancelSelected = annotation =>
this._emitter.emit('cancelSelected', annotation.underlying);

/******************/
/* External API */
/******************/
Expand Down

0 comments on commit 48435f5

Please sign in to comment.