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
|
@@ -24,6 +24,17 @@ function getKonvaStage(windowId) {
|
|
|
24
24
|
return window.Konva.stages.find(s => s.attrs.id === windowId);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @param windowId
|
|
30
|
+
* @param shapeId
|
|
31
|
+
* @returns {Node}
|
|
32
|
+
*/
|
|
33
|
+
function getKonvaShape(windowId, shapeId) {
|
|
34
|
+
const stage = getKonvaStage(windowId);
|
|
35
|
+
return stage.findOne(`#${shapeId}`);
|
|
36
|
+
}
|
|
37
|
+
|
|
27
38
|
/**
|
|
28
39
|
* Resize the Konva stage and redraw it
|
|
29
40
|
* @param windowId
|
|
@@ -31,6 +42,7 @@ function getKonvaStage(windowId) {
|
|
|
31
42
|
* @param height
|
|
32
43
|
* @param scale
|
|
33
44
|
* @param hideAfterResize
|
|
45
|
+
* @param scaleStrokeForPNGExport
|
|
34
46
|
*/
|
|
35
47
|
function resizeKonvaStage(windowId, width, height, scale, hideAfterResize = true, scaleStrokeForPNGExport = false) {
|
|
36
48
|
hideKonvaStage();
|
|
@@ -119,27 +131,14 @@ async function getSvg(windowId) {
|
|
|
119
131
|
return svg;
|
|
120
132
|
}
|
|
121
133
|
|
|
122
|
-
/**
|
|
123
|
-
*
|
|
124
|
-
* @param windowId
|
|
125
|
-
* @param shapeId
|
|
126
|
-
* @returns {Node}
|
|
127
|
-
*/
|
|
128
|
-
function getKonvaShape(windowId, shapeId) {
|
|
129
|
-
const stage = getKonvaStage(windowId);
|
|
130
|
-
const shape = stage.findOne(`#${shapeId}`);
|
|
131
|
-
return shape;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
134
|
/** Export the stage as a JPG image in a data url */
|
|
135
135
|
async function getKonvaAsDataURL(windowId) {
|
|
136
136
|
const stage = getKonvaStage(windowId);
|
|
137
137
|
stage.find('Transformer').forEach(node => node.visible(false));
|
|
138
|
-
|
|
138
|
+
return stage.toDataURL({
|
|
139
139
|
mimeType: 'image/jpg',
|
|
140
140
|
quality: 0.2
|
|
141
141
|
});
|
|
142
|
-
return dataURL;
|
|
143
142
|
}
|
|
144
143
|
const defaultLineWeightChoices = exports.defaultLineWeightChoices = [0, 2, 5, 10, 20, 50];
|
|
145
144
|
const KONVA_MODE = exports.KONVA_MODE = {
|
|
@@ -176,24 +175,23 @@ function isShapesTool(activeTool) {
|
|
|
176
175
|
const rgbaToObj = (rgba = 'rgba(255,255,255,0.5)') => {
|
|
177
176
|
const rgbaArray = rgba.split(',');
|
|
178
177
|
return {
|
|
179
|
-
|
|
178
|
+
/* eslint-disable sort-keys */
|
|
180
179
|
r: Number(rgbaArray[0].split('(')[1]),
|
|
181
|
-
// eslint-disable-next-line sort-keys
|
|
182
180
|
g: Number(rgbaArray[1]),
|
|
183
|
-
// eslint-disable-next-line sort-keys
|
|
184
181
|
b: Number(rgbaArray[2]),
|
|
185
|
-
// eslint-disable-next-line sort-keys
|
|
186
182
|
a: Number(rgbaArray[3].split(')')[0])
|
|
183
|
+
/* eslint-enable sort-keys */
|
|
187
184
|
};
|
|
188
185
|
};
|
|
189
186
|
|
|
190
187
|
/** Convert color object to rgba string */
|
|
191
188
|
exports.rgbaToObj = rgbaToObj;
|
|
192
189
|
const objToRgba = (obj = {
|
|
193
|
-
|
|
190
|
+
/* eslint-disable sort-keys */
|
|
194
191
|
r: 255,
|
|
195
192
|
g: 255,
|
|
196
193
|
b: 255,
|
|
197
194
|
a: 0.5
|
|
195
|
+
/* eslint-enable sort-keys */
|
|
198
196
|
}) => `rgba(${obj.r},${obj.g},${obj.b},${obj.a})`;
|
|
199
197
|
exports.objToRgba = objToRgba;
|
|
@@ -19,10 +19,13 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
19
19
|
var _styles = require("@mui/material/styles");
|
|
20
20
|
var _propTypes = _interopRequireWildcard(require("prop-types"));
|
|
21
21
|
var Proptypes = _propTypes;
|
|
22
|
+
var _reactI18next = require("react-i18next");
|
|
22
23
|
var _KonvaUtils = require("../KonvaUtils");
|
|
23
24
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
24
25
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
25
26
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
27
|
+
/* eslint-disable react/forbid-prop-types */
|
|
28
|
+
|
|
26
29
|
/** Display color picker and border * */
|
|
27
30
|
function ColorPicker({
|
|
28
31
|
changeClosedMode,
|
|
@@ -32,11 +35,13 @@ function ColorPicker({
|
|
|
32
35
|
handleLineWeightSelect,
|
|
33
36
|
openChooseColor,
|
|
34
37
|
openChooseLineWeight,
|
|
35
|
-
t,
|
|
36
38
|
toolOptions,
|
|
37
39
|
toolState,
|
|
38
40
|
updateColor
|
|
39
41
|
}) {
|
|
42
|
+
const {
|
|
43
|
+
t
|
|
44
|
+
} = (0, _reactI18next.useTranslation)();
|
|
40
45
|
return /*#__PURE__*/_react.default.createElement(_material.Grid, {
|
|
41
46
|
container: true,
|
|
42
47
|
spacing: 1
|
|
@@ -128,12 +133,17 @@ ColorPicker.propTypes = {
|
|
|
128
133
|
handleLineWeightSelect: Proptypes.func.isRequired,
|
|
129
134
|
openChooseColor: Proptypes.func.isRequired,
|
|
130
135
|
openChooseLineWeight: Proptypes.func.isRequired,
|
|
131
|
-
|
|
132
|
-
|
|
136
|
+
toolOptions: Proptypes.shape({
|
|
137
|
+
colorPopoverOpen: _propTypes.default.bool,
|
|
138
|
+
currentColorType: _propTypes.default.any,
|
|
139
|
+
lineWeightPopoverOpen: _propTypes.default.bool,
|
|
140
|
+
popoverAnchorEl: _propTypes.default.any,
|
|
141
|
+
popoverLineWeightAnchorEl: _propTypes.default.any
|
|
142
|
+
}).isRequired,
|
|
133
143
|
toolState: _propTypes.default.shape({
|
|
134
144
|
activeTool: _propTypes.default.string.isRequired,
|
|
135
|
-
closedMode: _propTypes.default.
|
|
136
|
-
fillColor: _propTypes.default.string
|
|
145
|
+
closedMode: _propTypes.default.string.isRequired,
|
|
146
|
+
fillColor: _propTypes.default.string,
|
|
137
147
|
image: _propTypes.default.shape({
|
|
138
148
|
id: _propTypes.default.string
|
|
139
149
|
}),
|
|
@@ -141,7 +151,7 @@ ColorPicker.propTypes = {
|
|
|
141
151
|
strokeWidth: _propTypes.default.number.isRequired,
|
|
142
152
|
text: _propTypes.default.string,
|
|
143
153
|
textBody: _propTypes.default.string,
|
|
144
|
-
updateColor: _propTypes.default.func
|
|
154
|
+
updateColor: _propTypes.default.func
|
|
145
155
|
}).isRequired,
|
|
146
156
|
updateColor: Proptypes.func.isRequired
|
|
147
157
|
};
|
|
@@ -8,6 +8,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
8
8
|
var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
|
9
9
|
var _styles = require("@mui/material/styles");
|
|
10
10
|
var _material = require("@mui/material");
|
|
11
|
+
var _reactI18next = require("react-i18next");
|
|
11
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
13
|
var _AnnotationFormUtils = require("./AnnotationFormUtils");
|
|
13
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -17,12 +18,14 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
17
18
|
*/
|
|
18
19
|
function AnnotationFormTemplateSelector({
|
|
19
20
|
mediaType,
|
|
20
|
-
setCommentingType
|
|
21
|
-
t
|
|
21
|
+
setCommentingType
|
|
22
22
|
}) {
|
|
23
|
+
const {
|
|
24
|
+
t
|
|
25
|
+
} = (0, _reactI18next.useTranslation)();
|
|
23
26
|
/**
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
* Sets the comment type for the application.
|
|
28
|
+
*/
|
|
26
29
|
const setCommentType = template => setCommentingType(template);
|
|
27
30
|
const templates = (0, _AnnotationFormUtils.TEMPLATE_TYPES)(t);
|
|
28
31
|
return /*#__PURE__*/_react.default.createElement(CardContainer, null, mediaType === _AnnotationFormUtils.MEDIA_TYPES.AUDIO ? /*#__PURE__*/_react.default.createElement(_material.Grid, {
|
|
@@ -44,9 +47,7 @@ function AnnotationFormTemplateSelector({
|
|
|
44
47
|
variant: "body2"
|
|
45
48
|
}, t(template.description)))))));
|
|
46
49
|
}
|
|
47
|
-
const CardContainer = (0, _styles.styled)('div')(({
|
|
48
|
-
theme
|
|
49
|
-
}) => ({
|
|
50
|
+
const CardContainer = (0, _styles.styled)('div')(() => ({
|
|
50
51
|
display: 'flex',
|
|
51
52
|
flexDirection: 'column',
|
|
52
53
|
gap: '30px',
|
|
@@ -69,6 +70,5 @@ const DescriptionCardTypography = (0, _styles.styled)(_Typography.default, {
|
|
|
69
70
|
});
|
|
70
71
|
AnnotationFormTemplateSelector.propTypes = {
|
|
71
72
|
mediaType: _propTypes.default.string.isRequired,
|
|
72
|
-
setCommentingType: _propTypes.default.func.isRequired
|
|
73
|
-
t: _propTypes.default.func.isRequired
|
|
73
|
+
setCommentingType: _propTypes.default.func.isRequired
|
|
74
74
|
};
|
|
@@ -27,12 +27,15 @@ const TEMPLATE = exports.TEMPLATE = {
|
|
|
27
27
|
TAGGING_TYPE: 'tagging',
|
|
28
28
|
TEXT_TYPE: 'text'
|
|
29
29
|
};
|
|
30
|
+
|
|
31
|
+
// TODO Move in MediaUtils
|
|
30
32
|
const MEDIA_TYPES = exports.MEDIA_TYPES = {
|
|
31
33
|
AUDIO: 'Audio',
|
|
32
34
|
IMAGE: 'Image',
|
|
33
35
|
UNKNOWN: 'Unknown',
|
|
34
36
|
VIDEO: 'Video'
|
|
35
37
|
};
|
|
38
|
+
|
|
36
39
|
/** Return template type * */
|
|
37
40
|
const getTemplateType = (t, templateType) => TEMPLATE_TYPES(t).find(type => type.id === templateType);
|
|
38
41
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DebugInformation = DebugInformation;
|
|
7
|
+
var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
/**
|
|
12
|
+
* DebugInformation component to display media and container details
|
|
13
|
+
* @param playerReferences
|
|
14
|
+
* @returns {Element}
|
|
15
|
+
* @constructor
|
|
16
|
+
*/
|
|
17
|
+
function DebugInformation({
|
|
18
|
+
playerReferences,
|
|
19
|
+
t
|
|
20
|
+
}) {
|
|
21
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Typography.default, null, playerReferences.getMediaType()), /*#__PURE__*/_react.default.createElement(_Typography.default, null, t('scale'), ":", playerReferences.getScale()), /*#__PURE__*/_react.default.createElement(_Typography.default, null, t('zoom'), ":", playerReferences.getZoom()), /*#__PURE__*/_react.default.createElement(_Typography.default, null, t('image_true_size'), ":", playerReferences.getMediaTrueWidth(), ' ', "x", playerReferences.getMediaTrueHeight()), /*#__PURE__*/_react.default.createElement(_Typography.default, null, t('container_size'), ":", playerReferences.getContainerWidth(), ' ', "x", playerReferences.getContainerHeight()), /*#__PURE__*/_react.default.createElement(_Typography.default, null, t('image_displayed'), ":", playerReferences.getDisplayedMediaWidth(), ' ', "x", playerReferences.getDisplayedMediaHeight()));
|
|
22
|
+
}
|
|
23
|
+
DebugInformation.propTypes = {
|
|
24
|
+
// eslint-disable-next-line react/forbid-prop-types
|
|
25
|
+
playerReferences: _propTypes.default.any.isRequired,
|
|
26
|
+
t: _propTypes.default.func.isRequired
|
|
27
|
+
};
|
|
@@ -42,5 +42,8 @@ MultiTagsInput.propTypes = {
|
|
|
42
42
|
t: _propTypes.default.func.isRequired,
|
|
43
43
|
// eslint-disable-next-line react/forbid-prop-types
|
|
44
44
|
tags: _propTypes.default.any.isRequired,
|
|
45
|
-
tagsSuggestions: _propTypes.default.arrayOf(_propTypes.default.
|
|
45
|
+
tagsSuggestions: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
46
|
+
label: _propTypes.default.string,
|
|
47
|
+
value: _propTypes.default.string
|
|
48
|
+
})).isRequired
|
|
46
49
|
};
|
|
@@ -13,6 +13,8 @@ var _TargetFormSection = _interopRequireDefault(require("./TargetFormSection"));
|
|
|
13
13
|
var _KonvaUtils = require("./AnnotationFormOverlay/KonvaDrawing/KonvaUtils");
|
|
14
14
|
var _MultiTagsInput = require("./MultiTagsInput");
|
|
15
15
|
var _TextCommentInput = require("./TextCommentInput");
|
|
16
|
+
var _reactRedux = require("react-redux");
|
|
17
|
+
var _selectors = require("mirador/dist/es/src/state/selectors");
|
|
16
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
19
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
20
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -23,10 +25,10 @@ function MultipleBodyTemplate({
|
|
|
23
25
|
playerReferences,
|
|
24
26
|
saveAnnotation,
|
|
25
27
|
t,
|
|
26
|
-
windowId
|
|
27
|
-
tagsSuggestions,
|
|
28
|
-
commentTemplate
|
|
28
|
+
windowId
|
|
29
29
|
}) {
|
|
30
|
+
const annotationConfig = (0, _reactRedux.useSelector)(state => (0, _selectors.getConfig)(state)).annotation;
|
|
31
|
+
const tagsSuggestions = annotationConfig.tagsSuggestions ?? [];
|
|
30
32
|
let maeAnnotation = annotation;
|
|
31
33
|
if (!maeAnnotation.id) {
|
|
32
34
|
// If the annotation does not have maeData, the annotation was not created with mae
|
|
@@ -106,7 +108,7 @@ function MultipleBodyTemplate({
|
|
|
106
108
|
* @param selectedTemplate
|
|
107
109
|
*/
|
|
108
110
|
const onChangeTemplate = selectedTemplate => {
|
|
109
|
-
const associatedTag = mappedSuggestionsTags.find(tag => tag.value === selectedTemplate.
|
|
111
|
+
const associatedTag = mappedSuggestionsTags.find(tag => tag.value === selectedTemplate.title);
|
|
110
112
|
if (associatedTag) {
|
|
111
113
|
if (!annotationState.maeData.tags.find(tag => tag.value === associatedTag.value)) {
|
|
112
114
|
setAnnotationState({
|
|
@@ -123,7 +125,7 @@ function MultipleBodyTemplate({
|
|
|
123
125
|
return;
|
|
124
126
|
}
|
|
125
127
|
}
|
|
126
|
-
updateAnnotationTextualBodyValue(selectedTemplate.
|
|
128
|
+
updateAnnotationTextualBodyValue(selectedTemplate.content);
|
|
127
129
|
};
|
|
128
130
|
const mappedSuggestionsTags = tagsSuggestions.map(suggestion => ({
|
|
129
131
|
label: suggestion,
|
|
@@ -136,7 +138,6 @@ function MultipleBodyTemplate({
|
|
|
136
138
|
}, /*#__PURE__*/_react.default.createElement(_material.Grid, {
|
|
137
139
|
item: true
|
|
138
140
|
}, /*#__PURE__*/_react.default.createElement(_TextCommentInput.TextCommentInput, {
|
|
139
|
-
commentTemplates: commentTemplate,
|
|
140
141
|
comment: annotationState.maeData.textBody.value,
|
|
141
142
|
setComment: updateAnnotationTextualBodyValue,
|
|
142
143
|
onChangeTemplate: onChangeTemplate,
|
|
@@ -178,14 +179,11 @@ MultipleBodyTemplate.propTypes = {
|
|
|
178
179
|
manifestNetwork: _propTypes.default.string,
|
|
179
180
|
target: _propTypes.default.string
|
|
180
181
|
}).isRequired,
|
|
181
|
-
commentTemplate: _propTypes.default.string.isRequired,
|
|
182
|
-
// eslint-disable-next-line react/forbid-prop-types
|
|
183
182
|
closeFormCompanionWindow: _propTypes.default.func.isRequired,
|
|
184
183
|
// eslint-disable-next-line react/forbid-prop-types
|
|
185
184
|
playerReferences: _propTypes.default.object.isRequired,
|
|
186
185
|
// eslint-disable-next-line react/forbid-prop-types
|
|
187
186
|
saveAnnotation: _propTypes.default.func.isRequired,
|
|
188
187
|
t: _propTypes.default.func.isRequired,
|
|
189
|
-
tagsSuggestions: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
190
188
|
windowId: _propTypes.default.string.isRequired
|
|
191
189
|
};
|
|
@@ -7,6 +7,7 @@ exports.default = TargetFormSection;
|
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _material = require("@mui/material");
|
|
10
|
+
var _reactI18next = require("react-i18next");
|
|
10
11
|
var _AnnotationFormUtils = require("./AnnotationFormUtils");
|
|
11
12
|
var _TargetTimeInput = _interopRequireDefault(require("./TargetTimeInput"));
|
|
12
13
|
var _TargetSpatialInput = require("./TargetSpatialInput");
|
|
@@ -15,7 +16,6 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
15
16
|
*
|
|
16
17
|
* @param onChangeTarget
|
|
17
18
|
* @param spatialTarget
|
|
18
|
-
* @param t
|
|
19
19
|
* @param playerReferences
|
|
20
20
|
* @param target
|
|
21
21
|
* @param timeTarget
|
|
@@ -26,12 +26,14 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
26
26
|
function TargetFormSection({
|
|
27
27
|
onChangeTarget,
|
|
28
28
|
spatialTarget,
|
|
29
|
-
t,
|
|
30
29
|
playerReferences,
|
|
31
30
|
target,
|
|
32
31
|
timeTarget,
|
|
33
32
|
windowId
|
|
34
33
|
}) {
|
|
34
|
+
const {
|
|
35
|
+
t
|
|
36
|
+
} = (0, _reactI18next.useTranslation)();
|
|
35
37
|
if (!target) {
|
|
36
38
|
// eslint-disable-next-line no-param-reassign
|
|
37
39
|
target = {};
|
|
@@ -113,7 +115,6 @@ TargetFormSection.propTypes = {
|
|
|
113
115
|
// eslint-disable-next-line react/forbid-prop-types
|
|
114
116
|
playerReferences: _propTypes.default.object.isRequired,
|
|
115
117
|
spatialTarget: _propTypes.default.bool.isRequired,
|
|
116
|
-
t: _propTypes.default.func.isRequired,
|
|
117
118
|
// eslint-disable-next-line react/forbid-prop-types
|
|
118
119
|
target: _propTypes.default.object.isRequired,
|
|
119
120
|
timeTarget: _propTypes.default.bool.isRequired,
|
|
@@ -8,6 +8,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
|
10
10
|
var _material = require("@mui/material");
|
|
11
|
+
var _reactI18next = require("react-i18next");
|
|
11
12
|
var _AnnotationDrawing = _interopRequireDefault(require("./AnnotationFormOverlay/AnnotationDrawing"));
|
|
12
13
|
var _AnnotationFormUtils = require("./AnnotationFormUtils");
|
|
13
14
|
var _AnnotationFormOverlay = _interopRequireDefault(require("./AnnotationFormOverlay/AnnotationFormOverlay"));
|
|
@@ -19,11 +20,9 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
19
20
|
function TargetSpatialInput({
|
|
20
21
|
playerReferences,
|
|
21
22
|
setTargetDrawingState,
|
|
22
|
-
t,
|
|
23
23
|
targetDrawingState,
|
|
24
24
|
windowId
|
|
25
25
|
}) {
|
|
26
|
-
// TODO the targetSVGToolSTate is not used. Why the defaultToolState is used?
|
|
27
26
|
const [toolState, setToolState] = (0, _react.useState)(_AnnotationFormUtils.TARGET_TOOL_STATE);
|
|
28
27
|
const [viewTool, setViewTool] = (0, _react.useState)(_AnnotationFormUtils.TARGET_VIEW);
|
|
29
28
|
const [scale, setScale] = (0, _react.useState)(playerReferences.getScale());
|
|
@@ -31,6 +30,9 @@ function TargetSpatialInput({
|
|
|
31
30
|
const updateScale = () => {
|
|
32
31
|
setScale(playerReferences.getScale());
|
|
33
32
|
};
|
|
33
|
+
const {
|
|
34
|
+
t
|
|
35
|
+
} = (0, _reactI18next.useTranslation)();
|
|
34
36
|
const [drawingState, setDrawingState] = (0, _react.useState)({
|
|
35
37
|
...targetDrawingState,
|
|
36
38
|
currentShape: null,
|
|
@@ -135,7 +137,6 @@ TargetSpatialInput.propTypes = {
|
|
|
135
137
|
// eslint-disable-next-line react/forbid-prop-types
|
|
136
138
|
playerReferences: _propTypes.default.object.isRequired,
|
|
137
139
|
setTargetDrawingState: _propTypes.default.func.isRequired,
|
|
138
|
-
t: _propTypes.default.func.isRequired,
|
|
139
140
|
// eslint-disable-next-line react/forbid-prop-types
|
|
140
141
|
targetDrawingState: _propTypes.default.object.isRequired,
|
|
141
142
|
windowId: _propTypes.default.string.isRequired
|
|
@@ -9,6 +9,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
9
9
|
var _material = require("@mui/material");
|
|
10
10
|
var _creatable = _interopRequireDefault(require("react-select/creatable"));
|
|
11
11
|
var _TextEditor = _interopRequireDefault(require("../TextEditor"));
|
|
12
|
+
var _reactRedux = require("react-redux");
|
|
13
|
+
var _selectors = require("mirador/dist/es/src/state/selectors");
|
|
12
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
15
|
/**
|
|
14
16
|
* TextCommentInput component
|
|
@@ -21,11 +23,30 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
21
23
|
*/
|
|
22
24
|
function TextCommentInput({
|
|
23
25
|
comment,
|
|
24
|
-
commentTemplates,
|
|
25
26
|
onChangeTemplate,
|
|
26
27
|
setComment,
|
|
27
28
|
t
|
|
28
29
|
}) {
|
|
30
|
+
/**
|
|
31
|
+
* Format the option label for the select component
|
|
32
|
+
* @param option
|
|
33
|
+
* @returns {React.JSX.Element}
|
|
34
|
+
*/
|
|
35
|
+
const formatOptionLabel = option => /*#__PURE__*/_react.default.createElement("div", {
|
|
36
|
+
title: option.title
|
|
37
|
+
}, option.label);
|
|
38
|
+
const annotationConfig = (0, _reactRedux.useSelector)(state => (0, _selectors.getConfig)(state)).annotation;
|
|
39
|
+
const commentTemplates = annotationConfig.commentTemplates ?? [];
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Handle template selection change
|
|
43
|
+
* @param selectedOption
|
|
44
|
+
*/
|
|
45
|
+
const onLocalChangeTemplate = selectedOption => {
|
|
46
|
+
if (selectedOption) {
|
|
47
|
+
onChangeTemplate(selectedOption.value);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
29
50
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_material.Grid, {
|
|
30
51
|
container: true,
|
|
31
52
|
item: true
|
|
@@ -41,19 +62,13 @@ function TextCommentInput({
|
|
|
41
62
|
label: template.title,
|
|
42
63
|
title: template.content,
|
|
43
64
|
// Add title attribute for tooltip
|
|
44
|
-
value: template
|
|
65
|
+
value: template
|
|
45
66
|
})),
|
|
46
67
|
placeholder: t('useTemplate'),
|
|
47
|
-
onChange:
|
|
48
|
-
if (selectedOption) {
|
|
49
|
-
onChangeTemplate(selectedOption);
|
|
50
|
-
}
|
|
51
|
-
},
|
|
68
|
+
onChange: onLocalChangeTemplate,
|
|
52
69
|
isClearable: true,
|
|
53
70
|
isSearchable: true,
|
|
54
|
-
formatOptionLabel:
|
|
55
|
-
title: option.title
|
|
56
|
-
}, option.label),
|
|
71
|
+
formatOptionLabel: formatOptionLabel,
|
|
57
72
|
styles: {
|
|
58
73
|
marginBottom: '20px'
|
|
59
74
|
}
|
|
@@ -67,8 +82,6 @@ function TextCommentInput({
|
|
|
67
82
|
}
|
|
68
83
|
TextCommentInput.propTypes = {
|
|
69
84
|
comment: _propTypes.default.string.isRequired,
|
|
70
|
-
// eslint-disable-next-line react/forbid-prop-types
|
|
71
|
-
commentTemplates: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
|
|
72
85
|
onChangeTemplate: _propTypes.default.func.isRequired,
|
|
73
86
|
setComment: _propTypes.default.func.isRequired,
|
|
74
87
|
t: _propTypes.default.func.isRequired
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = UnsupportedMedia;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _CompanionWindow = _interopRequireDefault(require("mirador/dist/es/src/containers/CompanionWindow"));
|
|
9
|
+
var _material = require("@mui/material");
|
|
10
|
+
var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
|
11
|
+
var _reactI18next = require("react-i18next");
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
/** */
|
|
15
|
+
function UnsupportedMedia({
|
|
16
|
+
id,
|
|
17
|
+
windowId,
|
|
18
|
+
mediaType
|
|
19
|
+
}) {
|
|
20
|
+
const {
|
|
21
|
+
t
|
|
22
|
+
} = (0, _reactI18next.useTranslation)();
|
|
23
|
+
return /*#__PURE__*/_react.default.createElement(_CompanionWindow.default, {
|
|
24
|
+
title: t('media_not_supported'),
|
|
25
|
+
windowId: windowId,
|
|
26
|
+
id: id
|
|
27
|
+
}, /*#__PURE__*/_react.default.createElement(_material.Grid, {
|
|
28
|
+
container: true,
|
|
29
|
+
padding: 1,
|
|
30
|
+
spacing: 1
|
|
31
|
+
}, /*#__PURE__*/_react.default.createElement(_material.Grid, {
|
|
32
|
+
item: true
|
|
33
|
+
}, /*#__PURE__*/_react.default.createElement(_Typography.default, null, t('media_not_supported'))), /*#__PURE__*/_react.default.createElement(_material.Grid, {
|
|
34
|
+
item: true
|
|
35
|
+
}, /*#__PURE__*/_react.default.createElement(_Typography.default, null, t('detected_media_type', {
|
|
36
|
+
mediaType
|
|
37
|
+
})))));
|
|
38
|
+
}
|
|
39
|
+
UnsupportedMedia.propTypes = {
|
|
40
|
+
id: _propTypes.default.string.isRequired,
|
|
41
|
+
mediaType: _propTypes.default.string.isRequired,
|
|
42
|
+
windowId: _propTypes.default.string.isRequired
|
|
43
|
+
};
|
|
@@ -1,50 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _redux = require("redux");
|
|
8
|
-
var _reactRedux = require("react-redux");
|
|
9
|
-
var _selectors = require("mirador/dist/es/src/state/selectors");
|
|
10
|
-
var _canvases = require("mirador/dist/es/src/state/selectors/canvases");
|
|
11
|
-
var _companionWindows = require("mirador/dist/es/src/state/selectors/companionWindows");
|
|
12
|
-
var _window = require("mirador/dist/es/src/state/selectors/window");
|
|
13
|
-
var _reactI18next = require("react-i18next");
|
|
14
|
-
var _miradorAnnotationPlugin = _interopRequireDefault(require("../plugins/miradorAnnotationPlugin"));
|
|
15
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
-
// TODO use selector in main componenent
|
|
17
|
-
/**
|
|
18
|
-
* this function map the state to the annotationPlugin's props
|
|
19
|
-
* */
|
|
20
|
-
function mapStateToProps(state, {
|
|
21
|
-
targetProps: {
|
|
22
|
-
windowId
|
|
23
|
-
}
|
|
24
|
-
}) {
|
|
25
|
-
// Annotation edit companion window ou annotation creation companion window is the same thing
|
|
26
|
-
const annotationCreationCompanionWindows = (0, _companionWindows.getCompanionWindowsForContent)(state, {
|
|
27
|
-
content: 'annotationCreation',
|
|
28
|
-
windowId
|
|
29
|
-
});
|
|
30
|
-
let annotationEditCompanionWindowIsOpened = true;
|
|
31
|
-
if (Object.keys(annotationCreationCompanionWindows).length !== 0) {
|
|
32
|
-
annotationEditCompanionWindowIsOpened = false;
|
|
33
|
-
}
|
|
34
|
-
const currrentTime = (0, _window.getWindowCurrentTime)(state, {
|
|
35
|
-
windowId
|
|
36
|
-
});
|
|
37
|
-
return {
|
|
38
|
-
annotationEditCompanionWindowIsOpened,
|
|
39
|
-
canvases: (0, _canvases.getVisibleCanvases)(state, {
|
|
40
|
-
windowId
|
|
41
|
-
}),
|
|
42
|
-
config: state.config,
|
|
43
|
-
currentTime: currrentTime,
|
|
44
|
-
windowViewType: (0, _selectors.getWindowViewType)(state, {
|
|
45
|
-
windowId
|
|
46
|
-
})
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
const enhance = (0, _redux.compose)((0, _reactRedux.connect)(mapStateToProps), (0, _reactI18next.withTranslation)());
|
|
50
|
-
var _default = exports.default = enhance(_miradorAnnotationPlugin.default);
|
|
1
|
+
"use strict";
|
package/es/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/es/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "
|
|
6
|
+
Object.defineProperty(exports, "annotationCreationCompanionWindowPlugin", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
9
|
return _annotationCreationCompanionWindow.default;
|
|
@@ -34,19 +34,12 @@ Object.defineProperty(exports, "windowSideBarButtonsPlugin", {
|
|
|
34
34
|
return _windowSideBarButtonsPlugin.default;
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
|
-
var _miradorAnnotationPlugin = _interopRequireDefault(require("./
|
|
37
|
+
var _miradorAnnotationPlugin = _interopRequireDefault(require("./plugins/miradorAnnotationPlugin"));
|
|
38
38
|
var _externalStorageAnnotationPlugin = _interopRequireDefault(require("./plugins/externalStorageAnnotationPlugin"));
|
|
39
39
|
var _canvasAnnotationsPlugin = _interopRequireDefault(require("./plugins/canvasAnnotationsPlugin"));
|
|
40
40
|
var _annotationCreationCompanionWindow = _interopRequireDefault(require("./plugins/annotationCreationCompanionWindow"));
|
|
41
41
|
var _windowSideBarButtonsPlugin = _interopRequireDefault(require("./plugins/windowSideBarButtonsPlugin"));
|
|
42
|
-
var
|
|
42
|
+
var _annotationSaga = _interopRequireDefault(require("./plugins/annotationSaga"));
|
|
43
43
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
44
|
-
|
|
45
|
-
var _default = exports.default =
|
|
46
|
-
component: _miradorAnnotationPlugin.default,
|
|
47
|
-
config: {
|
|
48
|
-
translations: _locales.default
|
|
49
|
-
},
|
|
50
|
-
mode: 'wrap',
|
|
51
|
-
target: 'AnnotationSettings'
|
|
52
|
-
}, _externalStorageAnnotationPlugin.default, _canvasAnnotationsPlugin.default, _annotationCreationCompanionWindow.default, _windowSideBarButtonsPlugin.default];
|
|
44
|
+
const annotationPlugins = [_miradorAnnotationPlugin.default, _externalStorageAnnotationPlugin.default, _canvasAnnotationsPlugin.default, _annotationCreationCompanionWindow.default, _windowSideBarButtonsPlugin.default, _annotationSaga.default];
|
|
45
|
+
var _default = exports.default = annotationPlugins;
|
package/es/locales/locales.js
CHANGED
|
@@ -7,7 +7,8 @@ exports.default = void 0;
|
|
|
7
7
|
var _locales_en = require("./locales_en");
|
|
8
8
|
var _locales_fr = require("./locales_fr");
|
|
9
9
|
// Add your locales here
|
|
10
|
-
|
|
10
|
+
const locales = {
|
|
11
11
|
en: _locales_en.en,
|
|
12
12
|
fr: _locales_fr.fr
|
|
13
|
-
};
|
|
13
|
+
};
|
|
14
|
+
var _default = exports.default = locales;
|
package/es/locales/locales_en.js
CHANGED
|
@@ -55,7 +55,7 @@ const en = exports.en = {
|
|
|
55
55
|
manifest_url: 'Manifest URL',
|
|
56
56
|
media_not_supported: 'Media not supported',
|
|
57
57
|
media_not_supported_text: 'The media you try to annotate is not supported by this instance at the moment',
|
|
58
|
-
metadata: '
|
|
58
|
+
metadata: 'Metadata',
|
|
59
59
|
new_annotation: 'New annotation',
|
|
60
60
|
no_annotation: 'No annotations stored yet.',
|
|
61
61
|
note: 'Note',
|