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
Branches
No related tags found
1 merge request!5Create image annotation creation dialog
......@@ -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,
......@@ -745,10 +745,6 @@ class AnnotationCreation extends Component {
<Grid item xs={12}>
<TextEditor
key={textEditorStateBustingKey}
annoHtml={annoBody}
updateAnnotationBody={this.updateBody}
/>
<TextEditor
annoHtml={textBody}
updateAnnotationBody={this.updateTextBody}
/>
......
......@@ -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);
const imgBody = {
type: 'Image',
id: this.image.url,
format: 'image/jpg',
};
bodies.push(imgBody);
}
if (this.tags) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment