Skip to content
Snippets Groups Projects
Commit b3824ca8 authored by Samuel Jugnet's avatar Samuel Jugnet
Browse files

get svg in annotation creation

parent 12d9f9a2
Branches
No related tags found
1 merge request!10Draft: MigratingAnnotationCreation to MUI5.
Pipeline #1715 failed
...@@ -36,6 +36,8 @@ import ImageFormField from './ImageFormField'; ...@@ -36,6 +36,8 @@ import ImageFormField from './ImageFormField';
import { secondsToHMS } from './utils'; import { secondsToHMS } from './utils';
import TextField from '@mui/material/TextField'; import TextField from '@mui/material/TextField';
import { exportStageSVG } from 'react-konva-to-svg';
/** Extract time information from annotation target */ /** Extract time information from annotation target */
function timeFromAnnoTarget(annotarget) { function timeFromAnnoTarget(annotarget) {
console.info('TODO proper time extraction from: ', annotarget); console.info('TODO proper time extraction from: ', annotarget);
...@@ -303,8 +305,22 @@ class AnnotationCreation extends Component { ...@@ -303,8 +305,22 @@ class AnnotationCreation extends Component {
}); });
} }
getSvg = async () => {
const stage = window.Konva.stages.find((stage) => stage.attrs.id === this.props.windowId);
const svg = await exportStageSVG(stage);
return svg;
}
/** */ /** */
submitForm(e) { async submitForm(e) {
e.preventDefault(); e.preventDefault();
const { const {
annotation, annotation,
...@@ -313,13 +329,16 @@ class AnnotationCreation extends Component { ...@@ -313,13 +329,16 @@ class AnnotationCreation extends Component {
config, config,
} = this.props; } = this.props;
const { const {
title, title,
textBody, textBody,
image, image,
tags, tags,
xywh, xywh,
svg, // svg,
tstart, tstart,
tend, tend,
textEditorStateBustingKey, textEditorStateBustingKey,
...@@ -327,8 +346,11 @@ class AnnotationCreation extends Component { ...@@ -327,8 +346,11 @@ class AnnotationCreation extends Component {
console.log('submitting form', this.state); console.log('submitting form', this.state);
const svg = await this.getSvg();
console.log('svg', svg);
const t = (tstart && tend) ? `${tstart},${tend}` : null; const t = (tstart && tend) ? `${tstart},${tend}` : null;
const body = { value: (!textBody.length && t) ? `${secondsToHMS(tstart)} -> ${secondsToHMS(tend)}` : textBody }; const body = { value: (!textBody.length && t) ? `${secondsToHMS(tstart)} -> ${secondsToHMS(tend)}` : textBody };
canvases.forEach(async (canvas) => { canvases.forEach(async (canvas) => {
...@@ -345,7 +367,7 @@ class AnnotationCreation extends Component { ...@@ -345,7 +367,7 @@ class AnnotationCreation extends Component {
id: (annotation && annotation.id) || `${uuid()}`, id: (annotation && annotation.id) || `${uuid()}`,
image, image,
manifestId: canvas.options.resource.id, manifestId: canvas.options.resource.id,
svg, svg,//<------
tags, tags,
}).toJson(); }).toJson();
......
...@@ -308,15 +308,7 @@ class AnnotationDrawing extends Component { ...@@ -308,15 +308,7 @@ class AnnotationDrawing extends Component {
}; };
exportStageSVG=(stage)=>{
const svg = exportStageSVG({
container: stage,
width: 1920,
height: 1080,
});
console.log('svg',svg);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment