Cleanup
This commit is contained in:
parent
70c72b45ed
commit
ba094bc4a5
|
@ -12,7 +12,6 @@ import RelationEditor from './relations/editor/RelationEditor';
|
||||||
export default class TextAnnotator extends Component {
|
export default class TextAnnotator extends Component {
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
showEditor: false,
|
|
||||||
selectionBounds: null,
|
selectionBounds: null,
|
||||||
selectedAnnotation: null,
|
selectedAnnotation: null,
|
||||||
|
|
||||||
|
@ -23,7 +22,6 @@ export default class TextAnnotator extends Component {
|
||||||
/** Helper **/
|
/** Helper **/
|
||||||
_clearState = () => {
|
_clearState = () => {
|
||||||
this.setState({
|
this.setState({
|
||||||
showEditor: false,
|
|
||||||
selectionBounds: null,
|
selectionBounds: null,
|
||||||
selectedAnnotation: null
|
selectedAnnotation: null
|
||||||
});
|
});
|
||||||
|
@ -63,7 +61,6 @@ export default class TextAnnotator extends Component {
|
||||||
const { selection, clientRect } = evt;
|
const { selection, clientRect } = evt;
|
||||||
if (selection) {
|
if (selection) {
|
||||||
this.setState({
|
this.setState({
|
||||||
showEditor: true,
|
|
||||||
selectionBounds: clientRect,
|
selectionBounds: clientRect,
|
||||||
selectedAnnotation: selection
|
selectedAnnotation: selection
|
||||||
});
|
});
|
||||||
|
@ -147,12 +144,12 @@ 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.setState({ showEditor: false });
|
this._clearState();
|
||||||
}
|
}
|
||||||
|
|
||||||
setAnnotations = annotations => {
|
setAnnotations = annotations => {
|
||||||
this.highlighter.init(annotations);
|
this.highlighter.init(annotations).then(() =>
|
||||||
this.relationsLayer.init(annotations);
|
this.relationsLayer.init(annotations));
|
||||||
}
|
}
|
||||||
|
|
||||||
getAnnotations = () => {
|
getAnnotations = () => {
|
||||||
|
@ -163,7 +160,7 @@ export default class TextAnnotator extends Component {
|
||||||
|
|
||||||
setMode = mode => {
|
setMode = mode => {
|
||||||
if (mode === 'RELATIONS') {
|
if (mode === 'RELATIONS') {
|
||||||
this.setState({ showEditor: false });
|
this._clearState();
|
||||||
|
|
||||||
this.selectionHandler.enabled = false;
|
this.selectionHandler.enabled = false;
|
||||||
|
|
||||||
|
@ -182,9 +179,8 @@ export default class TextAnnotator extends Component {
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{ this.state.showEditor &&
|
{ this.state.selectedAnnotation &&
|
||||||
<Editor
|
<Editor
|
||||||
open={this.state.showEditor}
|
|
||||||
readOnly={this.props.readOnly}
|
readOnly={this.props.readOnly}
|
||||||
bounds={this.state.selectionBounds}
|
bounds={this.state.selectionBounds}
|
||||||
containerEl={this.props.containerEl}
|
containerEl={this.props.containerEl}
|
||||||
|
|
Loading…
Reference in New Issue