diff --git a/src/TextAnnotator.jsx b/src/TextAnnotator.jsx index 469d248..197941f 100644 --- a/src/TextAnnotator.jsx +++ b/src/TextAnnotator.jsx @@ -130,10 +130,15 @@ export default class TextAnnotator extends Component { this.relationsLayer.addOrUpdateRelation(relation, previous); this.closeRelationsEditor(); - if (previous) - this.props.onAnnotationUpdated(relation.annotation, previous.annotation); - else + // This method will always receive a 'previous' connection - + // if the previous is just an empty connection, fire 'create', + // otherwise, fire 'update' + const isNew = previous.annotation.bodies.length === 0; + + if (isNew) this.props.onAnnotationCreated(relation.annotation); + else + this.props.onAnnotationUpdated(relation.annotation, previous.annotation); } /** 'Delete' on the relation editor popup **/ diff --git a/src/relations/Connection.js b/src/relations/Connection.js index ef601be..6df5d9a 100644 --- a/src/relations/Connection.js +++ b/src/relations/Connection.js @@ -51,7 +51,6 @@ export default class Connection extends EventEmitter { /** Initializes a fixed connection from an annotation **/ initFromAnnotation = function(contentEl, svgEl, annotation) { - console.log('init', annotation); const [ fromId, toId ] = annotation.target.map(t => t.id); const relation = annotation.bodies[0].value; diff --git a/src/relations/editor/RelationEditor.jsx b/src/relations/editor/RelationEditor.jsx index 67dc886..c83fc82 100644 --- a/src/relations/editor/RelationEditor.jsx +++ b/src/relations/editor/RelationEditor.jsx @@ -72,6 +72,7 @@ export default class RelationEditor extends Component { onSubmit = () => { const updatedAnnotation = this.props.relation.annotation.clone({ + motivation: 'linking', body: [{ type: 'TextualBody', value: this.state.content,