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

Merge branch '1-edit-annotations-on-videos' into 5-images-in-annotations

parents 7cb70ef8 ef26ae0c
No related merge requests found
...@@ -143,8 +143,14 @@ class AnnotationCreation extends Component { ...@@ -143,8 +143,14 @@ class AnnotationCreation extends Component {
strokeWidth: 3, strokeWidth: 3,
...(props.config.annotation.defaults || {}), ...(props.config.annotation.defaults || {}),
}; };
const timeState = props.currentTime !== null
? { tend: Math.floor(props.currentTime) + 10, tstart: Math.floor(props.currentTime) }
: { tend: null, tstart: null };
this.state = { this.state = {
...toolState, ...toolState,
...timeState,
textBody: '', textBody: '',
activeTool: 'cursor', activeTool: 'cursor',
closedMode: 'closed', closedMode: 'closed',
...@@ -155,9 +161,7 @@ class AnnotationCreation extends Component { ...@@ -155,9 +161,7 @@ class AnnotationCreation extends Component {
popoverAnchorEl: null, popoverAnchorEl: null,
popoverLineWeightAnchorEl: null, popoverLineWeightAnchorEl: null,
svg: null, svg: null,
tend: Math.floor(props.currentTime) + 10,
textEditorStateBustingKey: 0, textEditorStateBustingKey: 0,
tstart: Math.floor(props.currentTime),
imgConstrain: false, imgConstrain: false,
imgHeight: { imgHeight: {
lastSubmittedValue: '', lastSubmittedValue: '',
...@@ -477,7 +481,8 @@ class AnnotationCreation extends Component { ...@@ -477,7 +481,8 @@ class AnnotationCreation extends Component {
textBody, image, imgWidth, imgHeight, imgUrl, tags, xywh, svg, textBody, image, imgWidth, imgHeight, imgUrl, tags, xywh, svg,
imgConstrain, tstart, tend, textEditorStateBustingKey, imgConstrain, tstart, tend, textEditorStateBustingKey,
} = this.state; } = this.state;
const annoBody = { value: !textBody.length ? `${secondsToHMS(tstart)} -> ${secondsToHMS(tend)}` : textBody }; const t = (tstart && tend) ? `${tstart},${tend}` : null;
const annoBody = { value: (!textBody.length && t) ? `${secondsToHMS(tstart)} -> ${secondsToHMS(tend)}` : textBody };
let imgBody; let imgBody;
if (imgWidth.validity === 1 && imgHeight.validity === 1 && imgUrl.validity === 1) { if (imgWidth.validity === 1 && imgHeight.validity === 1 && imgUrl.validity === 1) {
...@@ -497,7 +502,7 @@ class AnnotationCreation extends Component { ...@@ -497,7 +502,7 @@ class AnnotationCreation extends Component {
const anno = new WebAnnotation({ const anno = new WebAnnotation({
body: annoBody, body: annoBody,
canvasId: canvas.id, canvasId: canvas.id,
fragsel: { t: `${tstart},${tend}`, xywh }, fragsel: { t, xywh },
id: (annotation && annotation.id) || `${uuid()}`, id: (annotation && annotation.id) || `${uuid()}`,
image: imgBody, image: imgBody,
manifestId: canvas.options.resource.id, manifestId: canvas.options.resource.id,
...@@ -519,10 +524,10 @@ class AnnotationCreation extends Component { ...@@ -519,10 +524,10 @@ class AnnotationCreation extends Component {
this.setState({ this.setState({
image: false, image: false,
svg: null, svg: null,
tend: 0, tend: null,
textBody: '', textBody: '',
textEditorStateBustingKey: textEditorStateBustingKey + 1, textEditorStateBustingKey: textEditorStateBustingKey + 1,
tstart: 0, tstart: null,
xywh: null, xywh: null,
}); });
} }
...@@ -919,7 +924,7 @@ AnnotationCreation.propTypes = { ...@@ -919,7 +924,7 @@ AnnotationCreation.propTypes = {
), ),
}), }),
}).isRequired, }).isRequired,
currentTime: PropTypes.number, currentTime: PropTypes.oneOfType([PropTypes.number, PropTypes.instanceOf(null)]),
id: PropTypes.string.isRequired, id: PropTypes.string.isRequired,
paused: PropTypes.bool, paused: PropTypes.bool,
receiveAnnotation: PropTypes.func.isRequired, receiveAnnotation: PropTypes.func.isRequired,
...@@ -932,7 +937,7 @@ AnnotationCreation.defaultProps = { ...@@ -932,7 +937,7 @@ AnnotationCreation.defaultProps = {
annotation: null, annotation: null,
canvases: [], canvases: [],
closeCompanionWindow: () => {}, closeCompanionWindow: () => {},
currentTime: 0, currentTime: null,
paused: true, paused: true,
setCurrentTime: () => {}, setCurrentTime: () => {},
setSeekTo: () => {}, setSeekTo: () => {},
......
...@@ -58,9 +58,10 @@ export default class WebAnnotation { ...@@ -58,9 +58,10 @@ export default class WebAnnotation {
return bodies; return bodies;
} }
/** */ /** Fill target object with selectors (if any), else returns target url */
target() { target() {
if (!this.svg && !this.fragsel) { if (!this.svg
&& (!this.fragsel || !Object.values(this.fragsel).find((e) => e !== null))) {
return this.canvasId; return this.canvasId;
} }
const target = { source: this.source() }; const target = { source: this.source() };
......
...@@ -25,7 +25,7 @@ function mapStateToProps(state, { id: companionWindowId, windowId }) { ...@@ -25,7 +25,7 @@ function mapStateToProps(state, { id: companionWindowId, windowId }) {
const canvases = getVisibleCanvases(state, { windowId }); const canvases = getVisibleCanvases(state, { windowId });
const annotation = getPresentAnnotationsOnSelectedCanvases(state, { windowId }) const annotation = getPresentAnnotationsOnSelectedCanvases(state, { windowId })
.flatMap((annoPage) => annoPage.json.items) .flatMap((annoPage) => annoPage.json.items || [])
.find((annot) => annot.id === annotationid); .find((annot) => annot.id === annotationid);
return { return {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment