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
|
@@ -2,17 +2,19 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { styled } from '@mui/material/styles';
|
|
4
4
|
import { Grid } from '@mui/material';
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import { useSelector } from 'react-redux';
|
|
7
|
+
import { getConfig } from 'mirador/dist/es/src/state/selectors';
|
|
7
8
|
import TextCommentTemplate from './TextCommentTemplate';
|
|
8
9
|
import ImageCommentTemplate from './ImageCommentTemplate';
|
|
9
10
|
import NetworkCommentTemplate from './NetworkCommentTemplate';
|
|
10
11
|
import DrawingTemplate from './DrawingTemplate';
|
|
11
12
|
import IIIFTemplate from './IIIFTemplate';
|
|
12
13
|
import TaggingTemplate from './TaggingTemplate';
|
|
13
|
-
|
|
14
|
-
import './debug.css';
|
|
15
14
|
import MultipleBodyTemplate from './MultipleBodyTemplate';
|
|
15
|
+
import './debug.css';
|
|
16
|
+
import { DebugInformation } from './DebugInformation';
|
|
17
|
+
import { TEMPLATE } from './AnnotationFormUtils';
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* This function contain the logic for loading annotation and render proper template type
|
|
@@ -22,17 +24,18 @@ export default function AnnotationFormBody(
|
|
|
22
24
|
annotation,
|
|
23
25
|
canvases,
|
|
24
26
|
closeFormCompanionWindow,
|
|
25
|
-
config,
|
|
26
|
-
debugMode,
|
|
27
27
|
playerReferences,
|
|
28
28
|
saveAnnotation,
|
|
29
|
-
t,
|
|
30
29
|
templateType,
|
|
31
30
|
windowId,
|
|
32
31
|
},
|
|
33
32
|
) {
|
|
33
|
+
const { t } = useTranslation();
|
|
34
|
+
|
|
35
|
+
const debugMode = useSelector((state) => getConfig(state)).debug ?? false;
|
|
34
36
|
return (
|
|
35
37
|
<Grid container direction="column">
|
|
38
|
+
|
|
36
39
|
<TemplateContainer item>
|
|
37
40
|
{
|
|
38
41
|
templateType.id === TEMPLATE.TEXT_TYPE && (
|
|
@@ -47,32 +50,56 @@ export default function AnnotationFormBody(
|
|
|
47
50
|
)
|
|
48
51
|
}
|
|
49
52
|
{
|
|
50
|
-
templateType.id === TEMPLATE.
|
|
51
|
-
<
|
|
53
|
+
templateType.id === TEMPLATE.MULTIPLE_BODY_TYPE && (
|
|
54
|
+
<MultipleBodyTemplate
|
|
52
55
|
annotation={annotation}
|
|
53
56
|
closeFormCompanionWindow={closeFormCompanionWindow}
|
|
54
57
|
playerReferences={playerReferences}
|
|
55
58
|
saveAnnotation={saveAnnotation}
|
|
59
|
+
t={t}
|
|
56
60
|
windowId={windowId}
|
|
61
|
+
/>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
{
|
|
65
|
+
templateType.id === TEMPLATE.TAGGING_TYPE && (
|
|
66
|
+
<TaggingTemplate
|
|
67
|
+
annotation={annotation}
|
|
68
|
+
closeFormCompanionWindow={closeFormCompanionWindow}
|
|
69
|
+
playerReferences={playerReferences}
|
|
70
|
+
saveAnnotation={saveAnnotation}
|
|
57
71
|
t={t}
|
|
72
|
+
windowId={windowId}
|
|
58
73
|
/>
|
|
59
74
|
)
|
|
60
75
|
}
|
|
61
76
|
{
|
|
62
|
-
templateType.id === TEMPLATE.
|
|
63
|
-
<
|
|
77
|
+
templateType.id === TEMPLATE.IIIF_TYPE && (
|
|
78
|
+
<IIIFTemplate
|
|
64
79
|
annotation={annotation}
|
|
80
|
+
canvases={canvases}
|
|
65
81
|
closeFormCompanionWindow={closeFormCompanionWindow}
|
|
66
82
|
playerReferences={playerReferences}
|
|
67
83
|
saveAnnotation={saveAnnotation}
|
|
68
84
|
t={t}
|
|
85
|
+
/>
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
{
|
|
89
|
+
templateType.id === TEMPLATE.IMAGE_TYPE && (
|
|
90
|
+
<ImageCommentTemplate
|
|
91
|
+
annotation={annotation}
|
|
92
|
+
closeFormCompanionWindow={closeFormCompanionWindow}
|
|
93
|
+
playerReferences={playerReferences}
|
|
94
|
+
saveAnnotation={saveAnnotation}
|
|
69
95
|
windowId={windowId}
|
|
96
|
+
t={t}
|
|
70
97
|
/>
|
|
71
98
|
)
|
|
72
99
|
}
|
|
73
100
|
{
|
|
74
|
-
templateType.id === TEMPLATE.
|
|
75
|
-
<
|
|
101
|
+
templateType.id === TEMPLATE.KONVA_TYPE && (
|
|
102
|
+
<DrawingTemplate
|
|
76
103
|
annotation={annotation}
|
|
77
104
|
closeFormCompanionWindow={closeFormCompanionWindow}
|
|
78
105
|
playerReferences={playerReferences}
|
|
@@ -83,80 +110,24 @@ export default function AnnotationFormBody(
|
|
|
83
110
|
)
|
|
84
111
|
}
|
|
85
112
|
{
|
|
86
|
-
templateType.id === TEMPLATE.
|
|
87
|
-
<
|
|
113
|
+
templateType.id === TEMPLATE.MANIFEST_TYPE && (
|
|
114
|
+
<NetworkCommentTemplate
|
|
88
115
|
annotation={annotation}
|
|
89
|
-
canvases={canvases}
|
|
90
116
|
closeFormCompanionWindow={closeFormCompanionWindow}
|
|
91
117
|
playerReferences={playerReferences}
|
|
92
118
|
saveAnnotation={saveAnnotation}
|
|
93
119
|
t={t}
|
|
120
|
+
windowId={windowId}
|
|
94
121
|
/>
|
|
95
122
|
)
|
|
96
123
|
}
|
|
97
|
-
|
|
98
|
-
<TaggingTemplate
|
|
99
|
-
annotation={annotation}
|
|
100
|
-
closeFormCompanionWindow={closeFormCompanionWindow}
|
|
101
|
-
playerReferences={playerReferences}
|
|
102
|
-
saveAnnotation={saveAnnotation}
|
|
103
|
-
t={t}
|
|
104
|
-
windowId={windowId}
|
|
105
|
-
/>
|
|
106
|
-
)}
|
|
107
|
-
{templateType.id === TEMPLATE.MULTIPLE_BODY_TYPE && (
|
|
108
|
-
<MultipleBodyTemplate
|
|
109
|
-
annotation={annotation}
|
|
110
|
-
closeFormCompanionWindow={closeFormCompanionWindow}
|
|
111
|
-
playerReferences={playerReferences}
|
|
112
|
-
saveAnnotation={saveAnnotation}
|
|
113
|
-
t={t}
|
|
114
|
-
windowId={windowId}
|
|
115
|
-
commentTemplate={config?.annotation?.commentTemplates ?? []}
|
|
116
|
-
tagsSuggestions={config?.annotation?.tagsSuggestions ?? []}
|
|
117
|
-
/>
|
|
118
|
-
)}
|
|
124
|
+
|
|
119
125
|
</TemplateContainer>
|
|
120
126
|
{debugMode && (
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
<Typography>
|
|
126
|
-
{t('scale')}
|
|
127
|
-
:
|
|
128
|
-
{playerReferences.getScale()}
|
|
129
|
-
</Typography>
|
|
130
|
-
<Typography>
|
|
131
|
-
{t('zoom')}
|
|
132
|
-
:
|
|
133
|
-
{playerReferences.getZoom()}
|
|
134
|
-
</Typography>
|
|
135
|
-
<Typography>
|
|
136
|
-
{t('image_true_size')}
|
|
137
|
-
:
|
|
138
|
-
{playerReferences.getMediaTrueWidth()}
|
|
139
|
-
{' '}
|
|
140
|
-
x
|
|
141
|
-
{playerReferences.getMediaTrueHeight()}
|
|
142
|
-
</Typography>
|
|
143
|
-
<Typography>
|
|
144
|
-
{t('container_size')}
|
|
145
|
-
:
|
|
146
|
-
{playerReferences.getContainerWidth()}
|
|
147
|
-
{' '}
|
|
148
|
-
x
|
|
149
|
-
{playerReferences.getContainerHeight()}
|
|
150
|
-
</Typography>
|
|
151
|
-
<Typography>
|
|
152
|
-
{t('image_displayed')}
|
|
153
|
-
:
|
|
154
|
-
{playerReferences.getDisplayedMediaWidth()}
|
|
155
|
-
{' '}
|
|
156
|
-
x
|
|
157
|
-
{playerReferences.getDisplayedMediaHeight()}
|
|
158
|
-
</Typography>
|
|
159
|
-
</>
|
|
127
|
+
<DebugInformation
|
|
128
|
+
playerReferences={playerReferences}
|
|
129
|
+
t={t}
|
|
130
|
+
/>
|
|
160
131
|
)}
|
|
161
132
|
</Grid>
|
|
162
133
|
);
|
|
@@ -184,16 +155,24 @@ AnnotationFormBody.propTypes = {
|
|
|
184
155
|
target: PropTypes.string,
|
|
185
156
|
}).isRequired,
|
|
186
157
|
// eslint-disable-next-line react/forbid-prop-types
|
|
187
|
-
canvases: PropTypes.
|
|
158
|
+
canvases: PropTypes.arrayOf(
|
|
159
|
+
PropTypes.shape({
|
|
160
|
+
id: PropTypes.string,
|
|
161
|
+
index: PropTypes.number,
|
|
162
|
+
}),
|
|
163
|
+
).isRequired,
|
|
188
164
|
closeFormCompanionWindow: PropTypes.func.isRequired,
|
|
189
165
|
// eslint-disable-next-line react/forbid-prop-types
|
|
190
|
-
config: PropTypes.object.isRequired,
|
|
191
|
-
debugMode: PropTypes.bool.isRequired,
|
|
192
|
-
// eslint-disable-next-line react/forbid-prop-types
|
|
193
166
|
playerReferences: PropTypes.object.isRequired,
|
|
194
167
|
// eslint-disable-next-line react/forbid-prop-types
|
|
195
168
|
saveAnnotation: PropTypes.func.isRequired,
|
|
196
|
-
|
|
197
|
-
|
|
169
|
+
templateType: PropTypes.shape(
|
|
170
|
+
{
|
|
171
|
+
description: PropTypes.string,
|
|
172
|
+
icon: PropTypes.element,
|
|
173
|
+
id: PropTypes.string,
|
|
174
|
+
label: PropTypes.string,
|
|
175
|
+
},
|
|
176
|
+
).isRequired,
|
|
198
177
|
windowId: PropTypes.string.isRequired,
|
|
199
178
|
};
|
|
@@ -33,7 +33,7 @@ export default function AnnotationFormHeader(
|
|
|
33
33
|
<Grid item>
|
|
34
34
|
{annotation.id == null
|
|
35
35
|
&& (
|
|
36
|
-
<MiradorMenuButton
|
|
36
|
+
<MiradorMenuButton aria-label="back" TooltipProps="back">
|
|
37
37
|
<ChevronLeftIcon onClick={goBackToTemplateSelection} />
|
|
38
38
|
</MiradorMenuButton>
|
|
39
39
|
)}
|
|
@@ -62,12 +62,12 @@ AnnotationFormHeader.propTypes = {
|
|
|
62
62
|
PropTypes.string,
|
|
63
63
|
]).isRequired,
|
|
64
64
|
setCommentingType: PropTypes.func.isRequired,
|
|
65
|
-
templateType: PropTypes.
|
|
65
|
+
templateType: PropTypes.shape(
|
|
66
66
|
{
|
|
67
67
|
description: PropTypes.string,
|
|
68
68
|
icon: PropTypes.element,
|
|
69
69
|
id: PropTypes.string,
|
|
70
70
|
label: PropTypes.string,
|
|
71
71
|
},
|
|
72
|
-
)
|
|
72
|
+
).isRequired,
|
|
73
73
|
};
|
|
@@ -470,6 +470,7 @@ export default function AnnotationDrawing(
|
|
|
470
470
|
pos.y = drawingState.currentShape.y;
|
|
471
471
|
}
|
|
472
472
|
|
|
473
|
+
// eslint-disable-next-line no-case-declarations
|
|
473
474
|
const radius = Math.sqrt(
|
|
474
475
|
(pos.x - drawingState.currentShape.x) ** 2
|
|
475
476
|
+ (pos.y - drawingState.currentShape.y) ** 2,
|
|
@@ -644,17 +645,10 @@ AnnotationDrawing.propTypes = {
|
|
|
644
645
|
setDrawingState: PropTypes.func.isRequired,
|
|
645
646
|
setToolState: PropTypes.func.isRequired,
|
|
646
647
|
tabView: PropTypes.string.isRequired,
|
|
647
|
-
toolState: PropTypes.oneOfType(
|
|
648
|
-
PropTypes.string,
|
|
649
|
-
PropTypes.string,
|
|
650
|
-
PropTypes.string,
|
|
651
|
-
PropTypes.oneOfType(
|
|
652
|
-
PropTypes.string,
|
|
653
|
-
),
|
|
654
|
-
PropTypes.string,
|
|
648
|
+
toolState: PropTypes.oneOfType([
|
|
655
649
|
PropTypes.string,
|
|
656
650
|
PropTypes.number,
|
|
657
|
-
).isRequired,
|
|
651
|
+
]).isRequired,
|
|
658
652
|
updateCurrentShapeInShapes: PropTypes.func.isRequired,
|
|
659
653
|
updateScale: PropTypes.func.isRequired,
|
|
660
654
|
windowId: PropTypes.string.isRequired,
|
|
@@ -177,7 +177,7 @@ AnnotationFormOverlay.propTypes = {
|
|
|
177
177
|
t: PropTypes.func.isRequired,
|
|
178
178
|
toolState: PropTypes.shape({
|
|
179
179
|
activeTool: PropTypes.string.isRequired,
|
|
180
|
-
closedMode: PropTypes.
|
|
180
|
+
closedMode: PropTypes.string.isRequired,
|
|
181
181
|
fillColor: PropTypes.string.isRequired,
|
|
182
182
|
image: PropTypes.shape({
|
|
183
183
|
id: PropTypes.string,
|
|
@@ -110,6 +110,7 @@ function AnnotationFormOverlayTool({
|
|
|
110
110
|
onChange={changeTool}
|
|
111
111
|
aria-label={t('tool_selection')}
|
|
112
112
|
size="small"
|
|
113
|
+
data-testid="tool_selection"
|
|
113
114
|
>
|
|
114
115
|
{(displayMode !== KONVA_MODE.IMAGE) && (
|
|
115
116
|
<Tooltip title={t('rectangle')}>
|
|
@@ -198,7 +199,7 @@ AnnotationFormOverlayTool.propTypes = {
|
|
|
198
199
|
t: PropTypes.func.isRequired,
|
|
199
200
|
toolState: PropTypes.shape({
|
|
200
201
|
activeTool: PropTypes.string.isRequired,
|
|
201
|
-
closedMode: PropTypes.
|
|
202
|
+
closedMode: PropTypes.string.isRequired,
|
|
202
203
|
fillColor: PropTypes.string.isRequired,
|
|
203
204
|
image: PropTypes.shape({
|
|
204
205
|
id: PropTypes.string,
|
|
@@ -3,6 +3,8 @@ import Typography from '@mui/material/Typography';
|
|
|
3
3
|
import React, { useState } from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { v4 as uuidv4 } from 'uuid';
|
|
6
|
+
import { useSelector } from 'react-redux';
|
|
7
|
+
import { getConfig } from 'mirador/dist/es/src/state/selectors';
|
|
6
8
|
import ImageFormField from './ImageFormField';
|
|
7
9
|
import {
|
|
8
10
|
isShapesTool,
|
|
@@ -136,10 +138,14 @@ function AnnotationFormOverlayToolOptions({
|
|
|
136
138
|
},
|
|
137
139
|
);
|
|
138
140
|
};
|
|
141
|
+
|
|
142
|
+
const annotationConfig = useSelector((state) => getConfig(state)).annotation;
|
|
143
|
+
const allowTargetShapesStyling = annotationConfig?.allowTargetShapesStyling === true;
|
|
144
|
+
|
|
139
145
|
return (
|
|
140
146
|
<div>
|
|
141
147
|
{
|
|
142
|
-
((displayMode === KONVA_MODE.DRAW || displayMode === KONVA_MODE.TARGET)
|
|
148
|
+
((displayMode === KONVA_MODE.DRAW || (allowTargetShapesStyling && displayMode === KONVA_MODE.TARGET))
|
|
143
149
|
&& isShapesTool(toolState.activeTool)) && (
|
|
144
150
|
<Grid container>
|
|
145
151
|
<ColorPicker
|
|
@@ -151,7 +157,6 @@ function AnnotationFormOverlayToolOptions({
|
|
|
151
157
|
openChooseColor={openChooseColor}
|
|
152
158
|
openChooseLineWeight={openChooseLineWeight}
|
|
153
159
|
updateColor={updateColor}
|
|
154
|
-
t={t}
|
|
155
160
|
toolOptions={toolOptions}
|
|
156
161
|
toolState={toolState}
|
|
157
162
|
/>
|
|
@@ -185,7 +190,6 @@ function AnnotationFormOverlayToolOptions({
|
|
|
185
190
|
handleLineWeightSelect={handleLineWeightSelect}
|
|
186
191
|
openChooseColor={openChooseColor}
|
|
187
192
|
openChooseLineWeight={openChooseLineWeight}
|
|
188
|
-
t={t}
|
|
189
193
|
toolOptions={toolOptions}
|
|
190
194
|
toolState={toolState}
|
|
191
195
|
updateColor={updateColor}
|
|
@@ -233,8 +237,8 @@ AnnotationFormOverlayToolOptions.propTypes = {
|
|
|
233
237
|
t: PropTypes.func.isRequired,
|
|
234
238
|
toolState: PropTypes.shape({
|
|
235
239
|
activeTool: PropTypes.string.isRequired,
|
|
236
|
-
closedMode: PropTypes.
|
|
237
|
-
fillColor: PropTypes.string
|
|
240
|
+
closedMode: PropTypes.string.isRequired,
|
|
241
|
+
fillColor: PropTypes.string,
|
|
238
242
|
image: PropTypes.shape({
|
|
239
243
|
id: PropTypes.string,
|
|
240
244
|
}),
|
|
@@ -242,7 +246,7 @@ AnnotationFormOverlayToolOptions.propTypes = {
|
|
|
242
246
|
strokeWidth: PropTypes.number.isRequired,
|
|
243
247
|
text: PropTypes.string,
|
|
244
248
|
textBody: PropTypes.string,
|
|
245
|
-
updateColor: PropTypes.func
|
|
249
|
+
updateColor: PropTypes.func,
|
|
246
250
|
}).isRequired,
|
|
247
251
|
};
|
|
248
252
|
|
|
@@ -9,6 +9,17 @@ export function getKonvaStage(windowId) {
|
|
|
9
9
|
return window.Konva.stages.find((s) => s.attrs.id === windowId);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param windowId
|
|
15
|
+
* @param shapeId
|
|
16
|
+
* @returns {Node}
|
|
17
|
+
*/
|
|
18
|
+
export function getKonvaShape(windowId, shapeId) {
|
|
19
|
+
const stage = getKonvaStage(windowId);
|
|
20
|
+
return stage.findOne(`#${shapeId}`);
|
|
21
|
+
}
|
|
22
|
+
|
|
12
23
|
/**
|
|
13
24
|
* Resize the Konva stage and redraw it
|
|
14
25
|
* @param windowId
|
|
@@ -16,8 +27,16 @@ export function getKonvaStage(windowId) {
|
|
|
16
27
|
* @param height
|
|
17
28
|
* @param scale
|
|
18
29
|
* @param hideAfterResize
|
|
30
|
+
* @param scaleStrokeForPNGExport
|
|
19
31
|
*/
|
|
20
|
-
export function resizeKonvaStage(
|
|
32
|
+
export function resizeKonvaStage(
|
|
33
|
+
windowId,
|
|
34
|
+
width,
|
|
35
|
+
height,
|
|
36
|
+
scale,
|
|
37
|
+
hideAfterResize = true,
|
|
38
|
+
scaleStrokeForPNGExport = false,
|
|
39
|
+
) {
|
|
21
40
|
hideKonvaStage();
|
|
22
41
|
const stage = getKonvaStage(windowId);
|
|
23
42
|
stage.width(width);
|
|
@@ -123,28 +142,15 @@ export async function getSvg(windowId) {
|
|
|
123
142
|
return svg;
|
|
124
143
|
}
|
|
125
144
|
|
|
126
|
-
/**
|
|
127
|
-
*
|
|
128
|
-
* @param windowId
|
|
129
|
-
* @param shapeId
|
|
130
|
-
* @returns {Node}
|
|
131
|
-
*/
|
|
132
|
-
export function getKonvaShape(windowId, shapeId) {
|
|
133
|
-
const stage = getKonvaStage(windowId);
|
|
134
|
-
const shape = stage.findOne(`#${shapeId}`);
|
|
135
|
-
return shape;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
145
|
/** Export the stage as a JPG image in a data url */
|
|
139
146
|
export async function getKonvaAsDataURL(windowId) {
|
|
140
147
|
const stage = getKonvaStage(windowId);
|
|
141
148
|
stage.find('Transformer')
|
|
142
149
|
.forEach((node) => node.visible(false));
|
|
143
|
-
|
|
150
|
+
return stage.toDataURL({
|
|
144
151
|
mimeType: 'image/jpg',
|
|
145
152
|
quality: 0.2,
|
|
146
153
|
});
|
|
147
|
-
return dataURL;
|
|
148
154
|
}
|
|
149
155
|
|
|
150
156
|
export const defaultLineWeightChoices = [0, 2, 5, 10, 20, 50];
|
|
@@ -186,22 +192,21 @@ export function isShapesTool(activeTool) {
|
|
|
186
192
|
export const rgbaToObj = (rgba = 'rgba(255,255,255,0.5)') => {
|
|
187
193
|
const rgbaArray = rgba.split(',');
|
|
188
194
|
return {
|
|
189
|
-
|
|
195
|
+
/* eslint-disable sort-keys */
|
|
190
196
|
r: Number(rgbaArray[0].split('(')[1]),
|
|
191
|
-
// eslint-disable-next-line sort-keys
|
|
192
197
|
g: Number(rgbaArray[1]),
|
|
193
|
-
// eslint-disable-next-line sort-keys
|
|
194
198
|
b: Number(rgbaArray[2]),
|
|
195
|
-
// eslint-disable-next-line sort-keys
|
|
196
199
|
a: Number(rgbaArray[3].split(')')[0]),
|
|
200
|
+
/* eslint-enable sort-keys */
|
|
197
201
|
};
|
|
198
202
|
};
|
|
199
203
|
|
|
200
204
|
/** Convert color object to rgba string */
|
|
201
205
|
export const objToRgba = (obj = {
|
|
202
|
-
|
|
206
|
+
/* eslint-disable sort-keys */
|
|
203
207
|
r: 255,
|
|
204
208
|
g: 255,
|
|
205
209
|
b: 255,
|
|
206
210
|
a: 0.5,
|
|
211
|
+
/* eslint-enable sort-keys */
|
|
207
212
|
}) => `rgba(${obj.r},${obj.g},${obj.b},${obj.a})`;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable react/forbid-prop-types */
|
|
1
2
|
import {
|
|
2
3
|
ClickAwayListener,
|
|
3
4
|
Divider,
|
|
@@ -21,6 +22,7 @@ import React from 'react';
|
|
|
21
22
|
import { styled } from '@mui/material/styles';
|
|
22
23
|
import * as Proptypes from 'prop-types';
|
|
23
24
|
import PropTypes from 'prop-types';
|
|
25
|
+
import { useTranslation } from 'react-i18next';
|
|
24
26
|
import { defaultLineWeightChoices, OVERLAY_TOOL } from '../KonvaUtils';
|
|
25
27
|
|
|
26
28
|
/** Display color picker and border * */
|
|
@@ -33,12 +35,13 @@ export default function ColorPicker(
|
|
|
33
35
|
handleLineWeightSelect,
|
|
34
36
|
openChooseColor,
|
|
35
37
|
openChooseLineWeight,
|
|
36
|
-
t,
|
|
37
38
|
toolOptions,
|
|
38
39
|
toolState,
|
|
39
40
|
updateColor,
|
|
40
41
|
},
|
|
41
42
|
) {
|
|
43
|
+
const { t } = useTranslation();
|
|
44
|
+
|
|
42
45
|
return (
|
|
43
46
|
<Grid container spacing={1}>
|
|
44
47
|
<Grid item xs={12}>
|
|
@@ -160,18 +163,17 @@ ColorPicker.propTypes = {
|
|
|
160
163
|
handleLineWeightSelect: Proptypes.func.isRequired,
|
|
161
164
|
openChooseColor: Proptypes.func.isRequired,
|
|
162
165
|
openChooseLineWeight: Proptypes.func.isRequired,
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
).isRequired,
|
|
166
|
+
toolOptions: Proptypes.shape({
|
|
167
|
+
colorPopoverOpen: PropTypes.bool,
|
|
168
|
+
currentColorType: PropTypes.any,
|
|
169
|
+
lineWeightPopoverOpen: PropTypes.bool,
|
|
170
|
+
popoverAnchorEl: PropTypes.any,
|
|
171
|
+
popoverLineWeightAnchorEl: PropTypes.any,
|
|
172
|
+
}).isRequired,
|
|
171
173
|
toolState: PropTypes.shape({
|
|
172
174
|
activeTool: PropTypes.string.isRequired,
|
|
173
|
-
closedMode: PropTypes.
|
|
174
|
-
fillColor: PropTypes.string
|
|
175
|
+
closedMode: PropTypes.string.isRequired,
|
|
176
|
+
fillColor: PropTypes.string,
|
|
175
177
|
image: PropTypes.shape({
|
|
176
178
|
id: PropTypes.string,
|
|
177
179
|
}),
|
|
@@ -179,7 +181,7 @@ ColorPicker.propTypes = {
|
|
|
179
181
|
strokeWidth: PropTypes.number.isRequired,
|
|
180
182
|
text: PropTypes.string,
|
|
181
183
|
textBody: PropTypes.string,
|
|
182
|
-
updateColor: PropTypes.func
|
|
184
|
+
updateColor: PropTypes.func,
|
|
183
185
|
}).isRequired,
|
|
184
186
|
updateColor: Proptypes.func.isRequired,
|
|
185
187
|
};
|
|
@@ -4,6 +4,7 @@ import { styled } from '@mui/material/styles';
|
|
|
4
4
|
import {
|
|
5
5
|
Card, CardActionArea, CardContent, Grid,
|
|
6
6
|
} from '@mui/material';
|
|
7
|
+
import { useTranslation } from 'react-i18next';
|
|
7
8
|
import PropTypes from 'prop-types';
|
|
8
9
|
import { MEDIA_TYPES, TEMPLATE_TYPES } from './AnnotationFormUtils';
|
|
9
10
|
/**
|
|
@@ -13,11 +14,11 @@ import { MEDIA_TYPES, TEMPLATE_TYPES } from './AnnotationFormUtils';
|
|
|
13
14
|
export default function AnnotationFormTemplateSelector({
|
|
14
15
|
mediaType,
|
|
15
16
|
setCommentingType,
|
|
16
|
-
t,
|
|
17
17
|
}) {
|
|
18
|
+
const { t } = useTranslation();
|
|
18
19
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
* Sets the comment type for the application.
|
|
21
|
+
*/
|
|
21
22
|
const setCommentType = (template) => setCommentingType(template);
|
|
22
23
|
const templates = TEMPLATE_TYPES(t);
|
|
23
24
|
|
|
@@ -53,9 +54,7 @@ export default function AnnotationFormTemplateSelector({
|
|
|
53
54
|
</CardContainer>
|
|
54
55
|
);
|
|
55
56
|
}
|
|
56
|
-
const CardContainer = styled('div')(({
|
|
57
|
-
theme,
|
|
58
|
-
}) => ({
|
|
57
|
+
const CardContainer = styled('div')(() => ({
|
|
59
58
|
display: 'flex',
|
|
60
59
|
flexDirection: 'column',
|
|
61
60
|
gap: '30px',
|
|
@@ -76,5 +75,4 @@ const DescriptionCardTypography = styled(Typography, { name: 'CompanionWindow',
|
|
|
76
75
|
AnnotationFormTemplateSelector.propTypes = {
|
|
77
76
|
mediaType: PropTypes.string.isRequired,
|
|
78
77
|
setCommentingType: PropTypes.func.isRequired,
|
|
79
|
-
t: PropTypes.func.isRequired,
|
|
80
78
|
};
|
|
@@ -20,12 +20,14 @@ export const TEMPLATE = {
|
|
|
20
20
|
TEXT_TYPE: 'text',
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
// TODO Move in MediaUtils
|
|
23
24
|
export const MEDIA_TYPES = {
|
|
24
25
|
AUDIO: 'Audio',
|
|
25
26
|
IMAGE: 'Image',
|
|
26
27
|
UNKNOWN: 'Unknown',
|
|
27
28
|
VIDEO: 'Video',
|
|
28
29
|
};
|
|
30
|
+
|
|
29
31
|
/** Return template type * */
|
|
30
32
|
export const getTemplateType = (t, templateType) => TEMPLATE_TYPES(t)
|
|
31
33
|
.find(
|
|
File without changes
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import Typography from '@mui/material/Typography';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* DebugInformation component to display media and container details
|
|
7
|
+
* @param playerReferences
|
|
8
|
+
* @returns {Element}
|
|
9
|
+
* @constructor
|
|
10
|
+
*/
|
|
11
|
+
export function DebugInformation({ playerReferences, t }) {
|
|
12
|
+
return (
|
|
13
|
+
<>
|
|
14
|
+
<Typography>
|
|
15
|
+
{playerReferences.getMediaType()}
|
|
16
|
+
</Typography>
|
|
17
|
+
<Typography>
|
|
18
|
+
{t('scale')}
|
|
19
|
+
:
|
|
20
|
+
{playerReferences.getScale()}
|
|
21
|
+
</Typography>
|
|
22
|
+
<Typography>
|
|
23
|
+
{t('zoom')}
|
|
24
|
+
:
|
|
25
|
+
{playerReferences.getZoom()}
|
|
26
|
+
</Typography>
|
|
27
|
+
<Typography>
|
|
28
|
+
{t('image_true_size')}
|
|
29
|
+
:
|
|
30
|
+
{playerReferences.getMediaTrueWidth()}
|
|
31
|
+
{' '}
|
|
32
|
+
x
|
|
33
|
+
{playerReferences.getMediaTrueHeight()}
|
|
34
|
+
</Typography>
|
|
35
|
+
<Typography>
|
|
36
|
+
{t('container_size')}
|
|
37
|
+
:
|
|
38
|
+
{playerReferences.getContainerWidth()}
|
|
39
|
+
{' '}
|
|
40
|
+
x
|
|
41
|
+
{playerReferences.getContainerHeight()}
|
|
42
|
+
</Typography>
|
|
43
|
+
<Typography>
|
|
44
|
+
{t('image_displayed')}
|
|
45
|
+
:
|
|
46
|
+
{playerReferences.getDisplayedMediaWidth()}
|
|
47
|
+
{' '}
|
|
48
|
+
x
|
|
49
|
+
{playerReferences.getDisplayedMediaHeight()}
|
|
50
|
+
</Typography>
|
|
51
|
+
</>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
DebugInformation.propTypes = {
|
|
56
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
57
|
+
playerReferences: PropTypes.any.isRequired,
|
|
58
|
+
t: PropTypes.func.isRequired,
|
|
59
|
+
};
|
|
@@ -43,5 +43,8 @@ MultiTagsInput.propTypes = {
|
|
|
43
43
|
t: PropTypes.func.isRequired,
|
|
44
44
|
// eslint-disable-next-line react/forbid-prop-types
|
|
45
45
|
tags: PropTypes.any.isRequired,
|
|
46
|
-
tagsSuggestions: PropTypes.arrayOf(PropTypes.
|
|
46
|
+
tagsSuggestions: PropTypes.arrayOf(PropTypes.shape({
|
|
47
|
+
label: PropTypes.string,
|
|
48
|
+
value: PropTypes.string,
|
|
49
|
+
})).isRequired,
|
|
47
50
|
};
|