Cleanup
This commit is contained in:
parent
ba094bc4a5
commit
dfa396031e
|
@ -19,8 +19,8 @@ export default class TextAnnotator extends Component {
|
||||||
selectedRelation: null
|
selectedRelation: null
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Helper **/
|
/** Shorthand **/
|
||||||
_clearState = () => {
|
clearState = () => {
|
||||||
this.setState({
|
this.setState({
|
||||||
selectionBounds: null,
|
selectionBounds: null,
|
||||||
selectedAnnotation: null
|
selectedAnnotation: null
|
||||||
|
@ -65,14 +65,13 @@ export default class TextAnnotator extends Component {
|
||||||
selectedAnnotation: selection
|
selectedAnnotation: selection
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this._clearState();
|
this.clearState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Common handler for annotation CREATE or UPDATE **/
|
/** Common handler for annotation CREATE or UPDATE **/
|
||||||
onCreateOrUpdateAnnotation = method => (annotation, previous) => {
|
onCreateOrUpdateAnnotation = method => (annotation, previous) => {
|
||||||
// Clear the annotation layer
|
this.clearState();
|
||||||
this._clearState();
|
|
||||||
|
|
||||||
this.selectionHandler.clearSelection();
|
this.selectionHandler.clearSelection();
|
||||||
this.highlighter.addOrUpdateAnnotation(annotation, previous);
|
this.highlighter.addOrUpdateAnnotation(annotation, previous);
|
||||||
|
@ -86,14 +85,14 @@ export default class TextAnnotator extends Component {
|
||||||
const connections = this.relationsLayer.getConnectionsFor(annotation);
|
const connections = this.relationsLayer.getConnectionsFor(annotation);
|
||||||
connections.forEach(c => c.destroy());
|
connections.forEach(c => c.destroy());
|
||||||
|
|
||||||
this._clearState();
|
this.clearState();
|
||||||
this.selectionHandler.clearSelection();
|
this.selectionHandler.clearSelection();
|
||||||
this.highlighter.removeAnnotation(annotation);
|
this.highlighter.removeAnnotation(annotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Cancel button on annotation editor **/
|
/** Cancel button on annotation editor **/
|
||||||
onCancelAnnotation = () => {
|
onCancelAnnotation = () => {
|
||||||
this._clearState();
|
this.clearState();
|
||||||
this.selectionHandler.clearSelection();
|
this.selectionHandler.clearSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +143,7 @@ export default class TextAnnotator extends Component {
|
||||||
// If the editor is currently open on this annotation, close it
|
// If the editor is currently open on this annotation, close it
|
||||||
const { selectedAnnotation } = this.state;
|
const { selectedAnnotation } = this.state;
|
||||||
if (selectedAnnotation && annotation.isEqual(selectedAnnotation))
|
if (selectedAnnotation && annotation.isEqual(selectedAnnotation))
|
||||||
this._clearState();
|
this.clearState();
|
||||||
}
|
}
|
||||||
|
|
||||||
setAnnotations = annotations => {
|
setAnnotations = annotations => {
|
||||||
|
@ -160,7 +159,7 @@ export default class TextAnnotator extends Component {
|
||||||
|
|
||||||
setMode = mode => {
|
setMode = mode => {
|
||||||
if (mode === 'RELATIONS') {
|
if (mode === 'RELATIONS') {
|
||||||
this._clearState();
|
this.clearState();
|
||||||
|
|
||||||
this.selectionHandler.enabled = false;
|
this.selectionHandler.enabled = false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue