mirador-annotation-editor-video 1.1.5 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/__tests__/AnnotationCreation.test.js +62 -28
- package/__tests__/AnnotationExportDialog.test.js +18 -16
- package/__tests__/CanvasListItem.test.js +53 -19
- package/__tests__/LocalStorageAdapter.test.js +1 -1
- package/__tests__/miradorAnnotationPlugin.test.js +97 -70
- package/__tests__/style-mock.js +1 -0
- package/__tests__/test-utils.js +57 -0
- package/demo/src/index.js +9 -4
- package/demo/src/quillConfig.js +34 -0
- package/es/AnnotationExportDialog.js +17 -25
- package/es/CanvasListItem.js +8 -4
- package/es/IIIFUtils.js +35 -3
- package/es/SingleCanvasDialog.js +1 -4
- package/es/TextEditor.js +9 -19
- package/es/annotationForm/AnnotationForm.js +14 -41
- package/es/annotationForm/AnnotationFormBody.js +36 -27
- package/es/annotationForm/AnnotationFormHeader.js +3 -3
- package/es/annotationForm/AnnotationFormOverlay/AnnotationDrawing.js +3 -1
- package/es/annotationForm/AnnotationFormOverlay/AnnotationFormOverlay.js +1 -1
- package/es/annotationForm/AnnotationFormOverlay/AnnotationFormOverlayTool.js +3 -2
- package/es/annotationForm/AnnotationFormOverlay/AnnotationFormOverlayToolOptions.js +8 -6
- package/es/annotationForm/AnnotationFormOverlay/KonvaDrawing/KonvaUtils.js +17 -19
- package/es/annotationForm/AnnotationFormOverlay/KonvaDrawing/shapes/ColorPicker.js +16 -6
- package/es/annotationForm/AnnotationFormTemplateSelector.js +9 -9
- package/es/annotationForm/AnnotationFormUtils.js +3 -0
- package/es/annotationForm/Debug.js +1 -0
- package/es/annotationForm/DebugInformation.js +27 -0
- package/es/annotationForm/MultiTagsInput.js +4 -1
- package/es/annotationForm/MultipleBodyTemplate.js +7 -9
- package/es/annotationForm/TaggingTemplate.js +0 -1
- package/es/annotationForm/TargetFormSection.js +4 -3
- package/es/annotationForm/TargetSpatialInput.js +4 -3
- package/es/annotationForm/TextCommentInput.js +25 -12
- package/es/annotationForm/TextCommentTemplate.js +0 -1
- package/es/annotationForm/UnsupportedMedia.js +43 -0
- package/es/containers/miradorAnnotationPlugin.js +1 -50
- package/es/custom.css +0 -13
- package/es/index.js +5 -12
- package/es/locales/locales.js +3 -2
- package/es/locales/locales_en.js +1 -1
- package/es/playerReferences.js +2 -1
- package/es/plugins/annotationCreationCompanionWindow.js +5 -8
- package/es/plugins/annotationSaga.js +44 -0
- package/es/plugins/canvasAnnotationsPlugin.js +86 -61
- package/es/plugins/canvasAnnotationsPluginUtils.js +202 -0
- package/es/plugins/externalStorageAnnotationPlugin.js +6 -71
- package/es/plugins/miradorAnnotationPlugin.js +44 -6
- package/es/plugins/windowSideBarButtonsPlugin.js +8 -10
- package/jest.config.js +14 -3
- package/package.json +8 -3
- package/setupJest.js +1 -4
- package/src/AnnotationExportDialog.js +12 -24
- package/src/CanvasListItem.js +4 -3
- package/src/IIIFUtils.js +33 -5
- package/src/SingleCanvasDialog.js +0 -3
- package/src/TextEditor.js +8 -32
- package/src/annotationForm/AnnotationForm.js +8 -47
- package/src/annotationForm/AnnotationFormBody.js +62 -83
- package/src/annotationForm/AnnotationFormHeader.js +3 -3
- package/src/annotationForm/AnnotationFormOverlay/AnnotationDrawing.js +3 -9
- package/src/annotationForm/AnnotationFormOverlay/AnnotationFormOverlay.js +1 -1
- package/src/annotationForm/AnnotationFormOverlay/AnnotationFormOverlayTool.js +2 -1
- package/src/annotationForm/AnnotationFormOverlay/AnnotationFormOverlayToolOptions.js +10 -6
- package/src/annotationForm/AnnotationFormOverlay/KonvaDrawing/KonvaUtils.js +25 -20
- package/src/annotationForm/AnnotationFormOverlay/KonvaDrawing/shapes/ColorPicker.js +14 -12
- package/src/annotationForm/AnnotationFormTemplateSelector.js +5 -7
- package/src/annotationForm/AnnotationFormUtils.js +2 -0
- package/src/annotationForm/Debug.js +0 -0
- package/src/annotationForm/DebugInformation.js +59 -0
- package/src/annotationForm/MultiTagsInput.js +4 -1
- package/src/annotationForm/MultipleBodyTemplate.js +7 -8
- package/src/annotationForm/TaggingTemplate.js +0 -1
- package/src/annotationForm/TargetFormSection.js +2 -3
- package/src/annotationForm/TargetSpatialInput.js +3 -3
- package/src/annotationForm/TextCommentInput.js +28 -14
- package/src/annotationForm/TextCommentTemplate.js +0 -1
- package/src/annotationForm/UnsupportedMedia.js +31 -0
- package/src/containers/miradorAnnotationPlugin.js +0 -36
- package/src/custom.css +0 -13
- package/src/index.js +10 -15
- package/src/locales/locales.js +3 -1
- package/src/locales/locales_en.js +1 -1
- package/src/playerReferences.js +5 -2
- package/src/plugins/annotationCreationCompanionWindow.js +9 -23
- package/src/plugins/annotationSaga.js +50 -0
- package/src/plugins/canvasAnnotationsPlugin.js +122 -98
- package/src/plugins/canvasAnnotationsPluginUtils.js +199 -0
- package/src/plugins/externalStorageAnnotationPlugin.js +6 -79
- package/src/plugins/miradorAnnotationPlugin.js +32 -4
- package/src/plugins/windowSideBarButtonsPlugin.js +6 -8
- package/webpack.config.js +1 -0
|
@@ -7,6 +7,8 @@ import TargetFormSection from './TargetFormSection';
|
|
|
7
7
|
import { resizeKonvaStage } from './AnnotationFormOverlay/KonvaDrawing/KonvaUtils';
|
|
8
8
|
import { MultiTagsInput } from './MultiTagsInput';
|
|
9
9
|
import { TextCommentInput } from './TextCommentInput';
|
|
10
|
+
import { useSelector } from 'react-redux';
|
|
11
|
+
import { getConfig } from 'mirador/dist/es/src/state/selectors';
|
|
10
12
|
|
|
11
13
|
/** Tagging Template* */
|
|
12
14
|
export default function MultipleBodyTemplate(
|
|
@@ -17,10 +19,11 @@ export default function MultipleBodyTemplate(
|
|
|
17
19
|
saveAnnotation,
|
|
18
20
|
t,
|
|
19
21
|
windowId,
|
|
20
|
-
tagsSuggestions,
|
|
21
|
-
commentTemplate,
|
|
22
22
|
},
|
|
23
23
|
) {
|
|
24
|
+
const annotationConfig = useSelector((state) => getConfig(state)).annotation;
|
|
25
|
+
const tagsSuggestions = annotationConfig.tagsSuggestions ?? [];
|
|
26
|
+
|
|
24
27
|
let maeAnnotation = annotation;
|
|
25
28
|
|
|
26
29
|
if (!maeAnnotation.id) {
|
|
@@ -110,7 +113,7 @@ export default function MultipleBodyTemplate(
|
|
|
110
113
|
* @param selectedTemplate
|
|
111
114
|
*/
|
|
112
115
|
const onChangeTemplate = (selectedTemplate) => {
|
|
113
|
-
const associatedTag = mappedSuggestionsTags.find((tag) => tag.value === selectedTemplate.
|
|
116
|
+
const associatedTag = mappedSuggestionsTags.find((tag) => tag.value === selectedTemplate.title);
|
|
114
117
|
if (associatedTag) {
|
|
115
118
|
if (!annotationState.maeData.tags.find((tag) => tag.value === associatedTag.value)) {
|
|
116
119
|
setAnnotationState({
|
|
@@ -128,7 +131,7 @@ export default function MultipleBodyTemplate(
|
|
|
128
131
|
}
|
|
129
132
|
}
|
|
130
133
|
|
|
131
|
-
updateAnnotationTextualBodyValue(selectedTemplate.
|
|
134
|
+
updateAnnotationTextualBodyValue(selectedTemplate.content);
|
|
132
135
|
};
|
|
133
136
|
|
|
134
137
|
const mappedSuggestionsTags = tagsSuggestions.map((suggestion) => ({
|
|
@@ -140,7 +143,6 @@ export default function MultipleBodyTemplate(
|
|
|
140
143
|
<Grid container direction="column" spacing={2}>
|
|
141
144
|
<Grid item>
|
|
142
145
|
<TextCommentInput
|
|
143
|
-
commentTemplates={commentTemplate}
|
|
144
146
|
comment={annotationState.maeData.textBody.value}
|
|
145
147
|
setComment={updateAnnotationTextualBodyValue}
|
|
146
148
|
onChangeTemplate={onChangeTemplate}
|
|
@@ -195,14 +197,11 @@ MultipleBodyTemplate.propTypes = {
|
|
|
195
197
|
manifestNetwork: PropTypes.string,
|
|
196
198
|
target: PropTypes.string,
|
|
197
199
|
}).isRequired,
|
|
198
|
-
commentTemplate: PropTypes.string.isRequired,
|
|
199
|
-
// eslint-disable-next-line react/forbid-prop-types
|
|
200
200
|
closeFormCompanionWindow: PropTypes.func.isRequired,
|
|
201
201
|
// eslint-disable-next-line react/forbid-prop-types
|
|
202
202
|
playerReferences: PropTypes.object.isRequired,
|
|
203
203
|
// eslint-disable-next-line react/forbid-prop-types
|
|
204
204
|
saveAnnotation: PropTypes.func.isRequired,
|
|
205
205
|
t: PropTypes.func.isRequired,
|
|
206
|
-
tagsSuggestions: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
207
206
|
windowId: PropTypes.string.isRequired,
|
|
208
207
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { Grid, Typography } from '@mui/material';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
4
5
|
import { MEDIA_TYPES, TEMPLATE } from './AnnotationFormUtils';
|
|
5
6
|
import TargetTimeInput from './TargetTimeInput';
|
|
6
7
|
import { TargetSpatialInput } from './TargetSpatialInput';
|
|
@@ -9,7 +10,6 @@ import { TargetSpatialInput } from './TargetSpatialInput';
|
|
|
9
10
|
*
|
|
10
11
|
* @param onChangeTarget
|
|
11
12
|
* @param spatialTarget
|
|
12
|
-
* @param t
|
|
13
13
|
* @param playerReferences
|
|
14
14
|
* @param target
|
|
15
15
|
* @param timeTarget
|
|
@@ -21,13 +21,13 @@ export default function TargetFormSection(
|
|
|
21
21
|
{
|
|
22
22
|
onChangeTarget,
|
|
23
23
|
spatialTarget,
|
|
24
|
-
t,
|
|
25
24
|
playerReferences,
|
|
26
25
|
target,
|
|
27
26
|
timeTarget,
|
|
28
27
|
windowId,
|
|
29
28
|
},
|
|
30
29
|
) {
|
|
30
|
+
const { t } = useTranslation();
|
|
31
31
|
if (!target) {
|
|
32
32
|
// eslint-disable-next-line no-param-reassign
|
|
33
33
|
target = {};
|
|
@@ -122,7 +122,6 @@ TargetFormSection.propTypes = {
|
|
|
122
122
|
// eslint-disable-next-line react/forbid-prop-types
|
|
123
123
|
playerReferences: PropTypes.object.isRequired,
|
|
124
124
|
spatialTarget: PropTypes.bool.isRequired,
|
|
125
|
-
t: PropTypes.func.isRequired,
|
|
126
125
|
// eslint-disable-next-line react/forbid-prop-types
|
|
127
126
|
target: PropTypes.object.isRequired,
|
|
128
127
|
timeTarget: PropTypes.bool.isRequired,
|
|
@@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import Typography from '@mui/material/Typography';
|
|
4
4
|
import { Grid } from '@mui/material';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
5
6
|
import AnnotationDrawing from './AnnotationFormOverlay/AnnotationDrawing';
|
|
6
7
|
import { TARGET_TOOL_STATE, TARGET_VIEW } from './AnnotationFormUtils';
|
|
7
8
|
import AnnotationFormOverlay from './AnnotationFormOverlay/AnnotationFormOverlay';
|
|
@@ -11,11 +12,9 @@ import { KONVA_MODE } from './AnnotationFormOverlay/KonvaDrawing/KonvaUtils';
|
|
|
11
12
|
export function TargetSpatialInput({
|
|
12
13
|
playerReferences,
|
|
13
14
|
setTargetDrawingState,
|
|
14
|
-
t,
|
|
15
15
|
targetDrawingState,
|
|
16
16
|
windowId,
|
|
17
17
|
}) {
|
|
18
|
-
// TODO the targetSVGToolSTate is not used. Why the defaultToolState is used?
|
|
19
18
|
const [toolState, setToolState] = useState(TARGET_TOOL_STATE);
|
|
20
19
|
const [viewTool, setViewTool] = useState(TARGET_VIEW);
|
|
21
20
|
const [scale, setScale] = useState(playerReferences.getScale());
|
|
@@ -24,6 +23,8 @@ export function TargetSpatialInput({
|
|
|
24
23
|
setScale(playerReferences.getScale());
|
|
25
24
|
};
|
|
26
25
|
|
|
26
|
+
const { t } = useTranslation();
|
|
27
|
+
|
|
27
28
|
const [drawingState, setDrawingState] = useState({
|
|
28
29
|
...targetDrawingState,
|
|
29
30
|
currentShape: null,
|
|
@@ -130,7 +131,6 @@ TargetSpatialInput.propTypes = {
|
|
|
130
131
|
// eslint-disable-next-line react/forbid-prop-types
|
|
131
132
|
playerReferences: PropTypes.object.isRequired,
|
|
132
133
|
setTargetDrawingState: PropTypes.func.isRequired,
|
|
133
|
-
t: PropTypes.func.isRequired,
|
|
134
134
|
// eslint-disable-next-line react/forbid-prop-types
|
|
135
135
|
targetDrawingState: PropTypes.object.isRequired,
|
|
136
136
|
windowId: PropTypes.string.isRequired,
|
|
@@ -3,6 +3,8 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import { Grid, Typography } from '@mui/material';
|
|
4
4
|
import CreatableSelect from 'react-select/creatable';
|
|
5
5
|
import TextEditor from '../TextEditor';
|
|
6
|
+
import { useSelector } from 'react-redux';
|
|
7
|
+
import { getConfig } from 'mirador/dist/es/src/state/selectors';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* TextCommentInput component
|
|
@@ -15,11 +17,33 @@ import TextEditor from '../TextEditor';
|
|
|
15
17
|
*/
|
|
16
18
|
export function TextCommentInput({
|
|
17
19
|
comment,
|
|
18
|
-
commentTemplates,
|
|
19
20
|
onChangeTemplate,
|
|
20
21
|
setComment,
|
|
21
22
|
t,
|
|
22
23
|
}) {
|
|
24
|
+
/**
|
|
25
|
+
* Format the option label for the select component
|
|
26
|
+
* @param option
|
|
27
|
+
* @returns {React.JSX.Element}
|
|
28
|
+
*/
|
|
29
|
+
const formatOptionLabel = (option) => (
|
|
30
|
+
<div title={option.title}>
|
|
31
|
+
{option.label}
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
const annotationConfig = useSelector((state) => getConfig(state)).annotation;
|
|
35
|
+
const commentTemplates = annotationConfig.commentTemplates ?? [];
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Handle template selection change
|
|
39
|
+
* @param selectedOption
|
|
40
|
+
*/
|
|
41
|
+
const onLocalChangeTemplate = (selectedOption) => {
|
|
42
|
+
if (selectedOption) {
|
|
43
|
+
onChangeTemplate(selectedOption.value);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
23
47
|
return (
|
|
24
48
|
<>
|
|
25
49
|
<Grid container item>
|
|
@@ -33,21 +57,13 @@ export function TextCommentInput({
|
|
|
33
57
|
options={commentTemplates.map((template) => ({
|
|
34
58
|
label: template.title,
|
|
35
59
|
title: template.content, // Add title attribute for tooltip
|
|
36
|
-
value: template
|
|
60
|
+
value: template,
|
|
37
61
|
}))}
|
|
38
62
|
placeholder={t('useTemplate')}
|
|
39
|
-
onChange={
|
|
40
|
-
if (selectedOption) {
|
|
41
|
-
onChangeTemplate(selectedOption);
|
|
42
|
-
}
|
|
43
|
-
}}
|
|
63
|
+
onChange={onLocalChangeTemplate}
|
|
44
64
|
isClearable
|
|
45
65
|
isSearchable
|
|
46
|
-
formatOptionLabel={
|
|
47
|
-
<div title={option.title}>
|
|
48
|
-
{option.label}
|
|
49
|
-
</div>
|
|
50
|
-
)}
|
|
66
|
+
formatOptionLabel={formatOptionLabel}
|
|
51
67
|
styles={{
|
|
52
68
|
marginBottom: '20px',
|
|
53
69
|
}}
|
|
@@ -67,8 +83,6 @@ export function TextCommentInput({
|
|
|
67
83
|
|
|
68
84
|
TextCommentInput.propTypes = {
|
|
69
85
|
comment: PropTypes.string.isRequired,
|
|
70
|
-
// eslint-disable-next-line react/forbid-prop-types
|
|
71
|
-
commentTemplates: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
72
86
|
onChangeTemplate: PropTypes.func.isRequired,
|
|
73
87
|
setComment: PropTypes.func.isRequired,
|
|
74
88
|
t: PropTypes.func.isRequired,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import CompanionWindow from 'mirador/dist/es/src/containers/CompanionWindow';
|
|
3
|
+
import { Grid } from '@mui/material';
|
|
4
|
+
import Typography from '@mui/material/Typography';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
|
|
8
|
+
/** */
|
|
9
|
+
export default function UnsupportedMedia({ id, windowId, mediaType }) {
|
|
10
|
+
const { t } = useTranslation();
|
|
11
|
+
return (
|
|
12
|
+
<CompanionWindow title={t('media_not_supported')} windowId={windowId} id={id}>
|
|
13
|
+
<Grid container padding={1} spacing={1}>
|
|
14
|
+
<Grid item>
|
|
15
|
+
<Typography>{t('media_not_supported')}</Typography>
|
|
16
|
+
</Grid>
|
|
17
|
+
<Grid item>
|
|
18
|
+
<Typography>
|
|
19
|
+
{t('detected_media_type', { mediaType })}
|
|
20
|
+
</Typography>
|
|
21
|
+
</Grid>
|
|
22
|
+
</Grid>
|
|
23
|
+
</CompanionWindow>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
UnsupportedMedia.propTypes = {
|
|
28
|
+
id: PropTypes.string.isRequired,
|
|
29
|
+
mediaType: PropTypes.string.isRequired,
|
|
30
|
+
windowId: PropTypes.string.isRequired,
|
|
31
|
+
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { compose } from 'redux';
|
|
2
|
-
import { connect } from 'react-redux';
|
|
3
|
-
import { getWindowViewType } from 'mirador/dist/es/src/state/selectors';
|
|
4
|
-
import { getVisibleCanvases } from 'mirador/dist/es/src/state/selectors/canvases';
|
|
5
|
-
import { getCompanionWindowsForContent } from 'mirador/dist/es/src/state/selectors/companionWindows';
|
|
6
|
-
import { getWindowCurrentTime } from 'mirador/dist/es/src/state/selectors/window';
|
|
7
|
-
import { withTranslation } from 'react-i18next';
|
|
8
|
-
import MiradorAnnotation from '../plugins/miradorAnnotationPlugin';
|
|
9
|
-
|
|
10
|
-
// TODO use selector in main componenent
|
|
11
|
-
/**
|
|
12
|
-
* this function map the state to the annotationPlugin's props
|
|
13
|
-
* */
|
|
14
|
-
function mapStateToProps(state, { targetProps: { windowId } }) {
|
|
15
|
-
// Annotation edit companion window ou annotation creation companion window is the same thing
|
|
16
|
-
const annotationCreationCompanionWindows = getCompanionWindowsForContent(state, { content: 'annotationCreation', windowId });
|
|
17
|
-
let annotationEditCompanionWindowIsOpened = true;
|
|
18
|
-
if (Object.keys(annotationCreationCompanionWindows).length !== 0) {
|
|
19
|
-
annotationEditCompanionWindowIsOpened = false;
|
|
20
|
-
}
|
|
21
|
-
const currrentTime = getWindowCurrentTime(state, { windowId });
|
|
22
|
-
return {
|
|
23
|
-
annotationEditCompanionWindowIsOpened,
|
|
24
|
-
canvases: getVisibleCanvases(state, { windowId }),
|
|
25
|
-
config: state.config,
|
|
26
|
-
currentTime: currrentTime,
|
|
27
|
-
windowViewType: getWindowViewType(state, { windowId }),
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const enhance = compose(
|
|
32
|
-
connect(mapStateToProps),
|
|
33
|
-
withTranslation(),
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
export default enhance(MiradorAnnotation);
|
package/src/custom.css
CHANGED
|
@@ -19,19 +19,6 @@
|
|
|
19
19
|
width: 100%;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
/*
|
|
23
|
-
.ReactTags__tag {
|
|
24
|
-
background-color: #f0f0f0;
|
|
25
|
-
border: 1px solid #ccc;
|
|
26
|
-
border-radius: 3px;
|
|
27
|
-
color: #333;
|
|
28
|
-
display: inline-block;
|
|
29
|
-
margin: 0 5px 5px 0;
|
|
30
|
-
padding: 5px 10px;
|
|
31
|
-
}
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
22
|
.ReactTags__clearAll {
|
|
36
23
|
cursor: pointer;
|
|
37
24
|
padding: 10px;
|
package/src/index.js
CHANGED
|
@@ -1,28 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
import miradorAnnotationPlugin from './containers/miradorAnnotationPlugin';
|
|
1
|
+
import miradorAnnotationPlugin from './plugins/miradorAnnotationPlugin';
|
|
3
2
|
import externalStorageAnnotationPlugin from './plugins/externalStorageAnnotationPlugin';
|
|
4
3
|
import canvasAnnotationsPlugin from './plugins/canvasAnnotationsPlugin';
|
|
5
|
-
import
|
|
4
|
+
import annotationCreationCompanionWindowPlugin from './plugins/annotationCreationCompanionWindow';
|
|
6
5
|
import windowSideBarButtonsPlugin from './plugins/windowSideBarButtonsPlugin';
|
|
7
|
-
import
|
|
6
|
+
import annotationSagaPlugin from './plugins/annotationSaga';
|
|
8
7
|
|
|
9
8
|
export {
|
|
10
9
|
miradorAnnotationPlugin, externalStorageAnnotationPlugin,
|
|
11
|
-
canvasAnnotationsPlugin,
|
|
10
|
+
canvasAnnotationsPlugin, annotationCreationCompanionWindowPlugin,
|
|
12
11
|
windowSideBarButtonsPlugin,
|
|
13
12
|
};
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
component: miradorAnnotationPlugin,
|
|
18
|
-
config: {
|
|
19
|
-
translations,
|
|
20
|
-
},
|
|
21
|
-
mode: 'wrap',
|
|
22
|
-
target: 'AnnotationSettings',
|
|
23
|
-
},
|
|
14
|
+
const annotationPlugins = [
|
|
15
|
+
miradorAnnotationPlugin,
|
|
24
16
|
externalStorageAnnotationPlugin,
|
|
25
17
|
canvasAnnotationsPlugin,
|
|
26
|
-
|
|
18
|
+
annotationCreationCompanionWindowPlugin,
|
|
27
19
|
windowSideBarButtonsPlugin,
|
|
20
|
+
annotationSagaPlugin,
|
|
28
21
|
];
|
|
22
|
+
|
|
23
|
+
export default annotationPlugins;
|
package/src/locales/locales.js
CHANGED
|
@@ -49,7 +49,7 @@ export const en = {
|
|
|
49
49
|
manifest_url: 'Manifest URL',
|
|
50
50
|
media_not_supported: 'Media not supported',
|
|
51
51
|
media_not_supported_text: 'The media you try to annotate is not supported by this instance at the moment',
|
|
52
|
-
metadata: '
|
|
52
|
+
metadata: 'Metadata',
|
|
53
53
|
new_annotation: 'New annotation',
|
|
54
54
|
no_annotation: 'No annotations stored yet.',
|
|
55
55
|
note: 'Note',
|
package/src/playerReferences.js
CHANGED
|
@@ -76,11 +76,14 @@ export class WindowPlayer {
|
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
78
|
* Get player initialisation status
|
|
79
|
+
* // TODO in MAEV env add this.media.canvasOverlay check
|
|
79
80
|
* @returns {*|boolean}
|
|
80
81
|
*/
|
|
81
82
|
isInitializedCorrectly() {
|
|
82
|
-
this.isInitCorrectly = this.media
|
|
83
|
-
&& (this.mediaType
|
|
83
|
+
this.isInitCorrectly = this.media
|
|
84
|
+
&& ((this.mediaType === MEDIA_TYPES.IMAGE && this.media.current && this.media.current.canvas)
|
|
85
|
+
|| (this.mediaType === MEDIA_TYPES.VIDEO && this.media.video
|
|
86
|
+
&& this.media.canvasOverlay));
|
|
84
87
|
|
|
85
88
|
return this.isInitCorrectly;
|
|
86
89
|
}
|
|
@@ -6,17 +6,13 @@ import {
|
|
|
6
6
|
} from 'mirador/dist/es/src/state/selectors/annotations';
|
|
7
7
|
import { OSDReferences } from 'mirador/dist/es/src/plugins/OSDReferences';
|
|
8
8
|
import { VideosReferences } from 'mirador/dist/es/src/plugins/VideosReferences';
|
|
9
|
-
import { withTranslation } from 'react-i18next';
|
|
10
|
-
import annotationForm from '../annotationForm/AnnotationForm';
|
|
11
9
|
import { checkMediaType, WindowPlayer } from '../playerReferences';
|
|
12
10
|
import { MEDIA_TYPES } from '../annotationForm/AnnotationFormUtils';
|
|
11
|
+
import AnnotationForm from '../annotationForm/AnnotationForm';
|
|
13
12
|
import translations from '../locales/locales';
|
|
14
13
|
|
|
15
14
|
/** */
|
|
16
|
-
const mapDispatchToProps = (dispatch, {
|
|
17
|
-
id,
|
|
18
|
-
windowId,
|
|
19
|
-
}) => ({
|
|
15
|
+
const mapDispatchToProps = (dispatch, { id, windowId }) => ({
|
|
20
16
|
closeCompanionWindow: () => dispatch(
|
|
21
17
|
actions.removeCompanionWindow(windowId, id),
|
|
22
18
|
),
|
|
@@ -26,15 +22,9 @@ const mapDispatchToProps = (dispatch, {
|
|
|
26
22
|
});
|
|
27
23
|
|
|
28
24
|
/** */
|
|
29
|
-
function mapStateToProps(state, {
|
|
30
|
-
id: companionWindowId,
|
|
31
|
-
windowId,
|
|
32
|
-
}) {
|
|
25
|
+
function mapStateToProps(state, { id: companionWindowId, windowId }) {
|
|
33
26
|
const currentTime = null;
|
|
34
|
-
const cw = getCompanionWindow(state, {
|
|
35
|
-
companionWindowId,
|
|
36
|
-
windowId,
|
|
37
|
-
});
|
|
27
|
+
const cw = getCompanionWindow(state, { companionWindowId, windowId });
|
|
38
28
|
const { annotationid } = cw;
|
|
39
29
|
const canvases = getVisibleCanvases(state, { windowId });
|
|
40
30
|
|
|
@@ -67,21 +57,17 @@ function mapStateToProps(state, {
|
|
|
67
57
|
return {
|
|
68
58
|
annotation,
|
|
69
59
|
canvases,
|
|
70
|
-
config: {
|
|
71
|
-
...state.config,
|
|
72
|
-
translations,
|
|
73
|
-
},
|
|
60
|
+
config: { ...state.config, translations },
|
|
74
61
|
currentTime,
|
|
75
62
|
playerReferences,
|
|
76
63
|
};
|
|
77
64
|
}
|
|
78
65
|
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
// eslint-disable-next-line import/no-anonymous-default-export
|
|
82
|
-
export default {
|
|
66
|
+
const annotationCreationCompanionWindowPlugin = {
|
|
83
67
|
companionWindowKey: 'annotationCreation',
|
|
84
|
-
component:
|
|
68
|
+
component: AnnotationForm,
|
|
85
69
|
mapDispatchToProps,
|
|
86
70
|
mapStateToProps,
|
|
87
71
|
};
|
|
72
|
+
|
|
73
|
+
export default annotationCreationCompanionWindowPlugin;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
all, call, put, select, takeEvery,
|
|
3
|
+
} from 'redux-saga/effects';
|
|
4
|
+
|
|
5
|
+
import { receiveAnnotation } from 'mirador/dist/es/src/state/actions';
|
|
6
|
+
import ActionTypes from 'mirador/dist/es/src/state/actions/action-types';
|
|
7
|
+
import {
|
|
8
|
+
getConfig,
|
|
9
|
+
} from 'mirador/dist/es/src/state/selectors';
|
|
10
|
+
|
|
11
|
+
/** Retrieves all the annotations available in the annotation adapter */
|
|
12
|
+
function* retrieveAnnotationsFormStore(canvasId) {
|
|
13
|
+
const config = yield select(getConfig);
|
|
14
|
+
|
|
15
|
+
if (config && config.annotation.adapter) {
|
|
16
|
+
const storageAdapter = config.annotation.adapter(canvasId);
|
|
17
|
+
const annoPage = yield call([
|
|
18
|
+
storageAdapter,
|
|
19
|
+
storageAdapter.all,
|
|
20
|
+
]);
|
|
21
|
+
if (annoPage) {
|
|
22
|
+
yield put(
|
|
23
|
+
receiveAnnotation(canvasId, storageAdapter.annotationPageId, annoPage),
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A generator function which takesEvery SET_CANVAS mirador action
|
|
31
|
+
* and fetches the associated annotations from the store.
|
|
32
|
+
*/
|
|
33
|
+
function* setAnnotations(action) {
|
|
34
|
+
const { canvasId } = action;
|
|
35
|
+
|
|
36
|
+
yield call(retrieveAnnotationsFormStore, canvasId);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Annotation saga for setting inital annotations */
|
|
40
|
+
function* annotationSaga() {
|
|
41
|
+
yield all([takeEvery(ActionTypes.SET_CANVAS, setAnnotations)]);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const annotationSagaPlugin = {
|
|
45
|
+
mode: 'wrap',
|
|
46
|
+
saga: annotationSaga,
|
|
47
|
+
target: 'Window',
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default annotationSagaPlugin;
|