diff --git a/src/AnnotationCreation.js b/src/AnnotationCreation.js index 15ae285b5bcc8a4d283a5de191a1b2368998228d..ad80f1754dbad98956c8cea673413bf31bc77423 100644 --- a/src/AnnotationCreation.js +++ b/src/AnnotationCreation.js @@ -86,6 +86,7 @@ class AnnotationCreation extends Component { super(props); const annoState = {}; annoState.image = false; + console.log('edition/creation annotation: ', props.annotation); if (props.annotation) { // @@ -97,14 +98,14 @@ class AnnotationCreation extends Component { annoState.tags.push(body.value); } else if (body.type === 'TextualBody') { annoState.textBody = body.value; - } else if (body.type === 'imgBody') { + } else if (body.type === 'Image') { annoState.textBody = body.value; annoState.image = body.image; } }); } else if (props.annotation.body.type === 'TextualBody') { annoState.textBody = props.annotation.body.value; - } else if (props.annotation.body.type === 'imgBody') { + } else if (props.annotation.body.type === 'Image') { annoState.textBody = props.annotation.body.value; annoState.image = props.annotation.body.image; } @@ -142,7 +143,6 @@ class AnnotationCreation extends Component { }; this.state = { ...toolState, - annoBody: '', textBody: '', activeTool: 'cursor', closedMode: 'closed', @@ -474,7 +474,7 @@ class AnnotationCreation extends Component { }); this.setState({ - annoBody: '', + textBody: '', svg: null, textEditorStateBustingKey: textEditorStateBustingKey + 1, xywh: null, @@ -744,11 +744,7 @@ class AnnotationCreation extends Component { </Grid> <Grid item xs={12}> <TextEditor - key={textEditorStateBustingKey} - annoHtml={annoBody} - updateAnnotationBody={this.updateBody} - /> - <TextEditor + key={textEditorStateBustingKey} annoHtml={textBody} updateAnnotationBody={this.updateTextBody} /> diff --git a/src/WebAnnotation.js b/src/WebAnnotation.js index e023d8c481a7592a75382b478a10be5a0afeab89..6c35a913091010d2c719fb25506cb086dc88a3b7 100644 --- a/src/WebAnnotation.js +++ b/src/WebAnnotation.js @@ -26,7 +26,7 @@ export default class WebAnnotation { return { body: this.createBody(), id: this.id, - motivation: 'commenting', + motivation: 'supplementing', target: this.target(), type: 'Annotation', }; @@ -36,17 +36,21 @@ export default class WebAnnotation { createBody() { let bodies = []; - if (this.body) { - const annoBody = { + if (this.body && this.body.value != '') { + const textBody = { type: 'TextualBody', value: this.body.value, }; + bodies.push(textBody); + } - if (this.image) { - annoBody.type = 'ImageBody'; - Object.assign(annoBody, this.image); - } - bodies.push(annoBody); + if (this.image) { + const imgBody = { + type: 'Image', + id: this.image.url, + format: 'image/jpg', + }; + bodies.push(imgBody); } if (this.tags) {