Skip to content
Snippets Groups Projects
Verified Commit dc014d05 authored by Loïs Poujade's avatar Loïs Poujade
Browse files

WIP standard image annotation

parent 1d84b116
No related branches found
No related tags found
1 merge request!5Create image annotation creation dialog
...@@ -86,6 +86,7 @@ class AnnotationCreation extends Component { ...@@ -86,6 +86,7 @@ class AnnotationCreation extends Component {
super(props); super(props);
const annoState = {}; const annoState = {};
annoState.image = false; annoState.image = false;
console.log('edition/creation annotation: ', props.annotation);
if (props.annotation) { if (props.annotation) {
// //
...@@ -97,14 +98,14 @@ class AnnotationCreation extends Component { ...@@ -97,14 +98,14 @@ class AnnotationCreation extends Component {
annoState.tags.push(body.value); annoState.tags.push(body.value);
} else if (body.type === 'TextualBody') { } else if (body.type === 'TextualBody') {
annoState.textBody = body.value; annoState.textBody = body.value;
} else if (body.type === 'imgBody') { } else if (body.type === 'Image') {
annoState.textBody = body.value; annoState.textBody = body.value;
annoState.image = body.image; annoState.image = body.image;
} }
}); });
} else if (props.annotation.body.type === 'TextualBody') { } else if (props.annotation.body.type === 'TextualBody') {
annoState.textBody = props.annotation.body.value; 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.textBody = props.annotation.body.value;
annoState.image = props.annotation.body.image; annoState.image = props.annotation.body.image;
} }
...@@ -142,7 +143,6 @@ class AnnotationCreation extends Component { ...@@ -142,7 +143,6 @@ class AnnotationCreation extends Component {
}; };
this.state = { this.state = {
...toolState, ...toolState,
annoBody: '',
textBody: '', textBody: '',
activeTool: 'cursor', activeTool: 'cursor',
closedMode: 'closed', closedMode: 'closed',
...@@ -474,7 +474,7 @@ class AnnotationCreation extends Component { ...@@ -474,7 +474,7 @@ class AnnotationCreation extends Component {
}); });
this.setState({ this.setState({
annoBody: '', textBody: '',
svg: null, svg: null,
textEditorStateBustingKey: textEditorStateBustingKey + 1, textEditorStateBustingKey: textEditorStateBustingKey + 1,
xywh: null, xywh: null,
...@@ -745,10 +745,6 @@ class AnnotationCreation extends Component { ...@@ -745,10 +745,6 @@ class AnnotationCreation extends Component {
<Grid item xs={12}> <Grid item xs={12}>
<TextEditor <TextEditor
key={textEditorStateBustingKey} key={textEditorStateBustingKey}
annoHtml={annoBody}
updateAnnotationBody={this.updateBody}
/>
<TextEditor
annoHtml={textBody} annoHtml={textBody}
updateAnnotationBody={this.updateTextBody} updateAnnotationBody={this.updateTextBody}
/> />
......
...@@ -26,7 +26,7 @@ export default class WebAnnotation { ...@@ -26,7 +26,7 @@ export default class WebAnnotation {
return { return {
body: this.createBody(), body: this.createBody(),
id: this.id, id: this.id,
motivation: 'commenting', motivation: 'supplementing',
target: this.target(), target: this.target(),
type: 'Annotation', type: 'Annotation',
}; };
...@@ -36,17 +36,21 @@ export default class WebAnnotation { ...@@ -36,17 +36,21 @@ export default class WebAnnotation {
createBody() { createBody() {
let bodies = []; let bodies = [];
if (this.body) { if (this.body && this.body.value != '') {
const annoBody = { const textBody = {
type: 'TextualBody', type: 'TextualBody',
value: this.body.value, value: this.body.value,
}; };
bodies.push(textBody);
}
if (this.image) { if (this.image) {
annoBody.type = 'ImageBody'; const imgBody = {
Object.assign(annoBody, this.image); type: 'Image',
} id: this.image.url,
bodies.push(annoBody); format: 'image/jpg',
};
bodies.push(imgBody);
} }
if (this.tags) { if (this.tags) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment