mirador-annotation-editor-video 1.1.0 → 1.1.2
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/es/IIIFUtils.js +3 -2
- package/es/annotationForm/AnnotationFormOverlay/AnnotationFormOverlayTool.js +3 -2
- package/es/annotationForm/AnnotationFormOverlay/AnnotationFormOverlayToolOptions.js +1 -1
- package/es/annotationForm/AnnotationFormOverlay/KonvaDrawing/shapes/Rectangle.js +1 -0
- package/es/annotationForm/AnnotationFormUtils.js +12 -18
- package/es/annotationForm/TargetSpatialInput.js +1 -1
- package/package.json +2 -2
- package/src/IIIFUtils.js +7 -3
- package/src/annotationForm/AnnotationFormOverlay/AnnotationFormOverlayTool.js +3 -1
- package/src/annotationForm/AnnotationFormOverlay/AnnotationFormOverlayToolOptions.js +1 -1
- package/src/annotationForm/AnnotationFormOverlay/KonvaDrawing/shapes/Rectangle.js +1 -0
- package/src/annotationForm/AnnotationFormUtils.js +9 -13
- package/src/annotationForm/TargetSpatialInput.js +2 -2
package/es/IIIFUtils.js
CHANGED
|
@@ -106,7 +106,7 @@ const getIIIFTargetFromMaeData = (maeData, canvasId, windowId = null, playerScal
|
|
|
106
106
|
case _AnnotationFormUtils.TEMPLATE.MULTIPLE_BODY_TYPE:
|
|
107
107
|
case _AnnotationFormUtils.TEMPLATE.TEXT_TYPE:
|
|
108
108
|
// In some case the target can be simplified in a string
|
|
109
|
-
if (maeTarget.drawingState.shapes
|
|
109
|
+
if (isSimpleTarget(maeTarget.drawingState.shapes)) {
|
|
110
110
|
return getIIIFTargetFromRectangleShape(maeTarget, canvasId, maeTarget.drawingState.shapes[0]);
|
|
111
111
|
}
|
|
112
112
|
// On the other case, the target is a SVG
|
|
@@ -119,6 +119,8 @@ const getIIIFTargetFromMaeData = (maeData, canvasId, windowId = null, playerScal
|
|
|
119
119
|
// Default return
|
|
120
120
|
return getIIIFTargetFullCanvas(maeData, canvasId);
|
|
121
121
|
};
|
|
122
|
+
exports.getIIIFTargetFromMaeData = getIIIFTargetFromMaeData;
|
|
123
|
+
const isSimpleTarget = shapes => shapes.length === 1 && shapes[0].type === _KonvaUtils.SHAPES_TOOL.RECTANGLE && shapes[0].strokeColor === _AnnotationFormUtils.TARGET_TOOL_STATE.strokeColor && shapes[0].fillColor === _AnnotationFormUtils.TARGET_TOOL_STATE.fillColor;
|
|
122
124
|
|
|
123
125
|
/**
|
|
124
126
|
* Get the IIIF target from a Konva annotation (Drawing template)
|
|
@@ -126,7 +128,6 @@ const getIIIFTargetFromMaeData = (maeData, canvasId, windowId = null, playerScal
|
|
|
126
128
|
* @param canvasId
|
|
127
129
|
* @returns {`${string}#${string}`}
|
|
128
130
|
*/
|
|
129
|
-
exports.getIIIFTargetFromMaeData = getIIIFTargetFromMaeData;
|
|
130
131
|
const getIIIFTargetFromKonvaType = (maeData, canvasId) => {
|
|
131
132
|
// Simplified target for Konva annotation
|
|
132
133
|
console.log('Implement target as string with Konva annotation');
|
|
@@ -55,7 +55,7 @@ function AnnotationFormOverlayTool({
|
|
|
55
55
|
activeTool: _KonvaUtils.SHAPES_TOOL.RECTANGLE
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, toolState.activeTool === _KonvaUtils.OVERLAY_TOOL.EDIT && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, currentShape && displayMode === _KonvaUtils.KONVA_MODE.DRAW && /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
58
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, toolState.activeTool === _KonvaUtils.OVERLAY_TOOL.EDIT && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, (currentShape && displayMode === _KonvaUtils.KONVA_MODE.DRAW || currentShape && displayMode === _KonvaUtils.KONVA_MODE.TARGET) && /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
59
59
|
variant: "subFormSectionTitle"
|
|
60
60
|
}, t('selected_object')), /*#__PURE__*/_react.default.createElement(_AnnotationFormOverlayToolOptions.default, {
|
|
61
61
|
t: t,
|
|
@@ -72,7 +72,8 @@ function AnnotationFormOverlayTool({
|
|
|
72
72
|
text: currentShape.text
|
|
73
73
|
},
|
|
74
74
|
setToolState: customUpdateToolState,
|
|
75
|
-
displayMode: displayMode
|
|
75
|
+
displayMode: displayMode,
|
|
76
|
+
currentShape: currentShape
|
|
76
77
|
})), displayMode === _KonvaUtils.KONVA_MODE.DRAW && shapes.length > 0 && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
77
78
|
variant: "subFormSectionTitle"
|
|
78
79
|
}, t('object_list')), /*#__PURE__*/_react.default.createElement(_ShapesList.default, {
|
|
@@ -136,7 +136,7 @@ function AnnotationFormOverlayToolOptions({
|
|
|
136
136
|
text
|
|
137
137
|
});
|
|
138
138
|
};
|
|
139
|
-
return /*#__PURE__*/_react.default.createElement("div", null, displayMode === _KonvaUtils.KONVA_MODE.DRAW && (0, _KonvaUtils.isShapesTool)(toolState.activeTool) && /*#__PURE__*/_react.default.createElement(_material.Grid, {
|
|
139
|
+
return /*#__PURE__*/_react.default.createElement("div", null, (displayMode === _KonvaUtils.KONVA_MODE.DRAW || displayMode === _KonvaUtils.KONVA_MODE.TARGET) && (0, _KonvaUtils.isShapesTool)(toolState.activeTool) && /*#__PURE__*/_react.default.createElement(_material.Grid, {
|
|
140
140
|
container: true
|
|
141
141
|
}, /*#__PURE__*/_react.default.createElement(_ColorPicker.default, {
|
|
142
142
|
currentColor: currentColor,
|
|
@@ -72,6 +72,7 @@ function Rectangle({
|
|
|
72
72
|
}
|
|
73
73
|
Rectangle.propTypes = {
|
|
74
74
|
activeTool: _propTypes.default.string.isRequired,
|
|
75
|
+
baseStrokeWidth: _propTypes.default.number.isRequired,
|
|
75
76
|
displayMode: _propTypes.default.string.isRequired,
|
|
76
77
|
handleDragEnd: _propTypes.default.func.isRequired,
|
|
77
78
|
handleDragStart: _propTypes.default.func.isRequired,
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.TEMPLATE_TYPES = exports.TEMPLATE = exports.TARGET_VIEW = exports.TAG_VIEW = exports.StyledToggleButtonGroup = exports.OVERLAY_VIEW = exports.MEDIA_TYPES = exports.MANIFEST_LINK_VIEW = exports.IMAGE_TOOL_STATE = exports.DEFAULT_TOOL_STATE = void 0;
|
|
7
|
-
exports.getTargetSVGToolState = getTargetSVGToolState;
|
|
8
|
-
exports.isValidUrl = exports.getTemplateType = void 0;
|
|
6
|
+
exports.isValidUrl = exports.getTemplateType = exports.TEMPLATE_TYPES = exports.TEMPLATE = exports.TARGET_VIEW = exports.TARGET_TOOL_STATE = exports.TAG_VIEW = exports.StyledToggleButtonGroup = exports.OVERLAY_VIEW = exports.MEDIA_TYPES = exports.MANIFEST_LINK_VIEW = exports.IMAGE_TOOL_STATE = exports.DEFAULT_TOOL_STATE = void 0;
|
|
9
7
|
exports.saveAnnotationInStorageAdapter = saveAnnotationInStorageAdapter;
|
|
10
8
|
exports.secondsToHMSarray = secondsToHMSarray;
|
|
11
9
|
var _TextFields = _interopRequireDefault(require("@mui/icons-material/TextFields"));
|
|
@@ -158,22 +156,18 @@ const IMAGE_TOOL_STATE = exports.IMAGE_TOOL_STATE = {
|
|
|
158
156
|
|
|
159
157
|
/**
|
|
160
158
|
* Specific Tool state for the target SVG
|
|
161
|
-
* @param imageZoom
|
|
162
|
-
* @returns {{activeTool: string, closedMode: string, image: {id: null}, imageEvent: null,
|
|
163
|
-
* strokeColor: string, strokeWidth: number}}
|
|
164
159
|
*/
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
160
|
+
const TARGET_TOOL_STATE = exports.TARGET_TOOL_STATE = {
|
|
161
|
+
activeTool: _KonvaUtils.OVERLAY_TOOL.SHAPE,
|
|
162
|
+
closedMode: 'closed',
|
|
163
|
+
fillColor: 'rgba(100,100,100, 0)',
|
|
164
|
+
image: {
|
|
165
|
+
id: null
|
|
166
|
+
},
|
|
167
|
+
imageEvent: null,
|
|
168
|
+
strokeColor: 'rgba(255,0, 0, 0.5)',
|
|
169
|
+
strokeWidth: 5
|
|
170
|
+
};
|
|
177
171
|
const TARGET_VIEW = exports.TARGET_VIEW = 'target';
|
|
178
172
|
const OVERLAY_VIEW = exports.OVERLAY_VIEW = 'layer';
|
|
179
173
|
const TAG_VIEW = exports.TAG_VIEW = 'tag';
|
|
@@ -24,7 +24,7 @@ function TargetSpatialInput({
|
|
|
24
24
|
windowId
|
|
25
25
|
}) {
|
|
26
26
|
// TODO the targetSVGToolSTate is not used. Why the defaultToolState is used?
|
|
27
|
-
const [toolState, setToolState] = (0, _react.useState)(
|
|
27
|
+
const [toolState, setToolState] = (0, _react.useState)(_AnnotationFormUtils.TARGET_TOOL_STATE);
|
|
28
28
|
const [viewTool, setViewTool] = (0, _react.useState)(_AnnotationFormUtils.TARGET_VIEW);
|
|
29
29
|
const [scale, setScale] = (0, _react.useState)(playerReferences.getScale());
|
|
30
30
|
/** Change scale from container / canva */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mirador-annotation-editor-video",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Mirador annotation editor video plugin in a React component. Mirador 4 (Alpha 2) compatible ",
|
|
5
5
|
"main": "es/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"prop-types": "^15.7.2",
|
|
64
64
|
"react": "^18.2.0",
|
|
65
65
|
"react-dom": "^18.0.0",
|
|
66
|
-
"uuid": "^
|
|
66
|
+
"uuid": "^8.0.0"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@babel/cli": "^7.25.9",
|
package/src/IIIFUtils.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
OVERLAY_TOOL,
|
|
6
6
|
SHAPES_TOOL,
|
|
7
7
|
} from './annotationForm/AnnotationFormOverlay/KonvaDrawing/KonvaUtils';
|
|
8
|
-
import { TEMPLATE } from './annotationForm/AnnotationFormUtils';
|
|
8
|
+
import { TARGET_TOOL_STATE, TEMPLATE } from './annotationForm/AnnotationFormUtils';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Check if annotation is exportable to image in case of Konva annotation
|
|
@@ -136,8 +136,7 @@ export const getIIIFTargetFromMaeData = (
|
|
|
136
136
|
case TEMPLATE.MULTIPLE_BODY_TYPE:
|
|
137
137
|
case TEMPLATE.TEXT_TYPE:
|
|
138
138
|
// In some case the target can be simplified in a string
|
|
139
|
-
if (maeTarget.drawingState.shapes
|
|
140
|
-
&& maeTarget.drawingState.shapes[0].type === SHAPES_TOOL.RECTANGLE) {
|
|
139
|
+
if (isSimpleTarget(maeTarget.drawingState.shapes)) {
|
|
141
140
|
return getIIIFTargetFromRectangleShape(
|
|
142
141
|
maeTarget,
|
|
143
142
|
canvasId,
|
|
@@ -155,6 +154,11 @@ export const getIIIFTargetFromMaeData = (
|
|
|
155
154
|
return getIIIFTargetFullCanvas(maeData, canvasId);
|
|
156
155
|
};
|
|
157
156
|
|
|
157
|
+
const isSimpleTarget = (shapes) => shapes.length === 1
|
|
158
|
+
&& shapes[0].type === SHAPES_TOOL.RECTANGLE
|
|
159
|
+
&& shapes[0].strokeColor === TARGET_TOOL_STATE.strokeColor
|
|
160
|
+
&& shapes[0].fillColor === TARGET_TOOL_STATE.fillColor;
|
|
161
|
+
|
|
158
162
|
/**
|
|
159
163
|
* Get the IIIF target from a Konva annotation (Drawing template)
|
|
160
164
|
* @param maeData
|
|
@@ -58,7 +58,8 @@ function AnnotationFormOverlayTool({
|
|
|
58
58
|
toolState.activeTool === OVERLAY_TOOL.EDIT && (
|
|
59
59
|
<>
|
|
60
60
|
{
|
|
61
|
-
currentShape && displayMode === KONVA_MODE.DRAW
|
|
61
|
+
((currentShape && displayMode === KONVA_MODE.DRAW)
|
|
62
|
+
|| (currentShape && displayMode === KONVA_MODE.TARGET)) && (
|
|
62
63
|
<div>
|
|
63
64
|
<Typography variant="subFormSectionTitle">
|
|
64
65
|
{t('selected_object')}
|
|
@@ -77,6 +78,7 @@ function AnnotationFormOverlayTool({
|
|
|
77
78
|
}}
|
|
78
79
|
setToolState={customUpdateToolState}
|
|
79
80
|
displayMode={displayMode}
|
|
81
|
+
currentShape={currentShape}
|
|
80
82
|
/>
|
|
81
83
|
</div>
|
|
82
84
|
)
|
|
@@ -139,7 +139,7 @@ function AnnotationFormOverlayToolOptions({
|
|
|
139
139
|
return (
|
|
140
140
|
<div>
|
|
141
141
|
{
|
|
142
|
-
(displayMode === KONVA_MODE.DRAW
|
|
142
|
+
((displayMode === KONVA_MODE.DRAW || displayMode === KONVA_MODE.TARGET)
|
|
143
143
|
&& isShapesTool(toolState.activeTool)) && (
|
|
144
144
|
<Grid container>
|
|
145
145
|
<ColorPicker
|
|
@@ -73,6 +73,7 @@ function Rectangle({
|
|
|
73
73
|
|
|
74
74
|
Rectangle.propTypes = {
|
|
75
75
|
activeTool: PropTypes.string.isRequired,
|
|
76
|
+
baseStrokeWidth: PropTypes.number.isRequired,
|
|
76
77
|
displayMode: PropTypes.string.isRequired,
|
|
77
78
|
handleDragEnd: PropTypes.func.isRequired,
|
|
78
79
|
handleDragStart: PropTypes.func.isRequired,
|
|
@@ -145,20 +145,16 @@ export const IMAGE_TOOL_STATE = {
|
|
|
145
145
|
|
|
146
146
|
/**
|
|
147
147
|
* Specific Tool state for the target SVG
|
|
148
|
-
* @param imageZoom
|
|
149
|
-
* @returns {{activeTool: string, closedMode: string, image: {id: null}, imageEvent: null,
|
|
150
|
-
* strokeColor: string, strokeWidth: number}}
|
|
151
148
|
*/
|
|
152
|
-
export
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
149
|
+
export const TARGET_TOOL_STATE = {
|
|
150
|
+
activeTool: OVERLAY_TOOL.SHAPE,
|
|
151
|
+
closedMode: 'closed',
|
|
152
|
+
fillColor: 'rgba(100,100,100, 0)',
|
|
153
|
+
image: { id: null },
|
|
154
|
+
imageEvent: null,
|
|
155
|
+
strokeColor: 'rgba(255,0, 0, 0.5)',
|
|
156
|
+
strokeWidth: 5,
|
|
157
|
+
};
|
|
162
158
|
|
|
163
159
|
export const TARGET_VIEW = 'target';
|
|
164
160
|
export const OVERLAY_VIEW = 'layer';
|
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import Typography from '@mui/material/Typography';
|
|
4
4
|
import { Grid } from '@mui/material';
|
|
5
5
|
import AnnotationDrawing from './AnnotationFormOverlay/AnnotationDrawing';
|
|
6
|
-
import {
|
|
6
|
+
import { TARGET_TOOL_STATE, TARGET_VIEW } from './AnnotationFormUtils';
|
|
7
7
|
import AnnotationFormOverlay from './AnnotationFormOverlay/AnnotationFormOverlay';
|
|
8
8
|
import { KONVA_MODE } from './AnnotationFormOverlay/KonvaDrawing/KonvaUtils';
|
|
9
9
|
|
|
@@ -16,7 +16,7 @@ export function TargetSpatialInput({
|
|
|
16
16
|
windowId,
|
|
17
17
|
}) {
|
|
18
18
|
// TODO the targetSVGToolSTate is not used. Why the defaultToolState is used?
|
|
19
|
-
const [toolState, setToolState] = useState(
|
|
19
|
+
const [toolState, setToolState] = useState(TARGET_TOOL_STATE);
|
|
20
20
|
const [viewTool, setViewTool] = useState(TARGET_VIEW);
|
|
21
21
|
const [scale, setScale] = useState(playerReferences.getScale());
|
|
22
22
|
/** Change scale from container / canva */
|