From 48435f54c10336879aab24724baa9096261f7c25 Mon Sep 17 00:00:00 2001 From: Rainer Simon Date: Fri, 23 Sep 2022 09:02:38 +0200 Subject: [PATCH] Added cancelSelected event --- public/index.html | 4 ++++ src/TextAnnotator.jsx | 3 ++- src/index.jsx | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index 4810f6f..80d788d 100644 --- a/public/index.html +++ b/public/index.html @@ -109,6 +109,10 @@

Homer: The Odyssey

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); diff --git a/src/TextAnnotator.jsx b/src/TextAnnotator.jsx index 9332768..061651c 100644 --- a/src/TextAnnotator.jsx +++ b/src/TextAnnotator.jsx @@ -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); } /************************/ diff --git a/src/index.jsx b/src/index.jsx index 44f4700..bc183ba 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -78,6 +78,7 @@ export class Recogito { onAnnotationCreated={this.handleAnnotationCreated} onAnnotationUpdated={this.handleAnnotationUpdated} onAnnotationDeleted={this.handleAnnotationDeleted} + onCancelSelected={this.handleCancelSelected} relationVocabulary={config.relationVocabulary} />, this._appContainerEl); } @@ -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 */ /******************/