mirador-annotation-editor-video 1.0.96 → 1.0.98
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/demo/src/manifestsCatalog.js +1 -0
- package/es/IIIFUtils.js +1 -1
- package/es/annotationForm/MultiTagsInput.js +12 -105
- package/es/locales/locales_en.js +1 -0
- package/es/locales/locales_fr.js +1 -0
- package/package.json +3 -3
- package/src/IIIFUtils.js +1 -1
- package/src/annotationForm/MultiTagsInput.js +13 -121
- package/src/locales/locales_en.js +1 -0
- package/src/locales/locales_fr.js +1 -0
|
@@ -10,4 +10,5 @@ export const manifestsCatalog = [
|
|
|
10
10
|
{ manifestId: 'https://files.tetras-libre.fr/dev/vertical_video_with_annot.json' },
|
|
11
11
|
{ manifestId: 'https://files.tetras-libre.fr/dev/youtube.json' },
|
|
12
12
|
{ manifestId: 'https://files.tetras-libre.fr/dev/peertube.json' },
|
|
13
|
+
{ manifestId: 'https://files.tetras-libre.fr/dev/milansanremo25.json' },
|
|
13
14
|
];
|
package/es/IIIFUtils.js
CHANGED
|
@@ -59,7 +59,7 @@ const convertAnnotationStateToBeSaved = async (annotationState, canvas, windowId
|
|
|
59
59
|
annotationStateForSaving.body.push(...annotationState.maeData.tags.map(tag => ({
|
|
60
60
|
purpose: 'tagging',
|
|
61
61
|
type: 'TextualBody',
|
|
62
|
-
value: tag.
|
|
62
|
+
value: tag.value,
|
|
63
63
|
id: tag.id
|
|
64
64
|
})));
|
|
65
65
|
}
|
|
@@ -4,13 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.MultiTagsInput = MultiTagsInput;
|
|
7
|
-
var _react =
|
|
8
|
-
var _reactTagInput = require("react-tag-input");
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
9
|
var _material = require("@mui/material");
|
|
10
|
+
var _creatable = _interopRequireDefault(require("react-select/creatable"));
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
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); }
|
|
13
|
-
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; }
|
|
14
12
|
/**
|
|
15
13
|
* MultiTagsInput component
|
|
16
14
|
* @param t
|
|
@@ -26,112 +24,21 @@ function MultiTagsInput({
|
|
|
26
24
|
tags,
|
|
27
25
|
tagsSuggestions
|
|
28
26
|
}) {
|
|
29
|
-
const [showSuggestions, setShowSuggestions] = (0, _react.useState)(false);
|
|
30
27
|
const mappedSuggestionsTags = tagsSuggestions.map(suggestion => ({
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
label: suggestion,
|
|
29
|
+
value: suggestion
|
|
33
30
|
}));
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Handle tag deletion
|
|
37
|
-
* @param index
|
|
38
|
-
*/
|
|
39
|
-
const handleDelete = index => {
|
|
40
|
-
setTags(tags.filter((_, i) => i !== index));
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Handle tag update
|
|
45
|
-
* @param index
|
|
46
|
-
* @param newTag
|
|
47
|
-
*/
|
|
48
|
-
const onTagUpdate = (index, newTag) => {
|
|
49
|
-
const updatedTags = [...tags];
|
|
50
|
-
updatedTags.splice(index, 1, newTag);
|
|
51
|
-
setTags(updatedTags);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Handle tag addition
|
|
56
|
-
* @param tag
|
|
57
|
-
*/
|
|
58
|
-
const handleAddition = newTag => {
|
|
59
|
-
if (tags.length === 0 || !tags.find(tag => tag.id === newTag.id)) {
|
|
60
|
-
setTags([...tags, newTag]);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Handle tag drag
|
|
66
|
-
* @param tag
|
|
67
|
-
* @param currPos
|
|
68
|
-
* @param newPos
|
|
69
|
-
*/
|
|
70
|
-
const handleDrag = (tag, currPos, newPos) => {
|
|
71
|
-
const newTags = tags.slice();
|
|
72
|
-
newTags.splice(currPos, 1);
|
|
73
|
-
newTags.splice(newPos, 0, tag);
|
|
74
|
-
|
|
75
|
-
// re-render
|
|
76
|
-
setTags(newTags);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Handle tag click
|
|
81
|
-
* @param index
|
|
82
|
-
*/
|
|
83
|
-
const handleTagClick = index => {
|
|
84
|
-
console.log(`The tag at index ${index} was clicked`);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Clear all tags
|
|
89
|
-
*/
|
|
90
|
-
const onClearAll = () => {
|
|
91
|
-
setTags([]);
|
|
92
|
-
};
|
|
93
31
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
|
94
32
|
variant: "formSectionTitle"
|
|
95
|
-
}, t('tags')), /*#__PURE__*/_react.default.createElement(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
display: 'flex',
|
|
104
|
-
flexWrap: 'wrap',
|
|
105
|
-
gap: '8px'
|
|
106
|
-
}
|
|
107
|
-
}, mappedSuggestionsTags.map(suggestion => /*#__PURE__*/_react.default.createElement("button", {
|
|
108
|
-
key: suggestion.id,
|
|
109
|
-
type: "button",
|
|
110
|
-
onClick: () => handleAddition(suggestion),
|
|
111
|
-
style: {
|
|
112
|
-
padding: '6px 12px',
|
|
113
|
-
borderRadius: '16px',
|
|
114
|
-
border: '1px solid #ccc',
|
|
115
|
-
backgroundColor: '#f1f1f1',
|
|
116
|
-
cursor: 'pointer'
|
|
117
|
-
}
|
|
118
|
-
}, suggestion.text))), /*#__PURE__*/_react.default.createElement(_material.Divider, {
|
|
33
|
+
}, t('tags')), /*#__PURE__*/_react.default.createElement(_creatable.default, {
|
|
34
|
+
isMulti: true,
|
|
35
|
+
options: mappedSuggestionsTags,
|
|
36
|
+
value: tags,
|
|
37
|
+
onChange: setTags,
|
|
38
|
+
closeMenuOnSelect: false,
|
|
39
|
+
placeholder: t('tagsPlaceholder')
|
|
40
|
+
}), /*#__PURE__*/_react.default.createElement(_material.Divider, {
|
|
119
41
|
spacing: 2
|
|
120
|
-
}), /*#__PURE__*/_react.default.createElement(_reactTagInput.WithContext, {
|
|
121
|
-
placeholder: t('pressEnterToAddTag'),
|
|
122
|
-
clearAll: true,
|
|
123
|
-
editable: true,
|
|
124
|
-
handleAddition: handleAddition,
|
|
125
|
-
handleDelete: handleDelete,
|
|
126
|
-
handleDrag: handleDrag,
|
|
127
|
-
handleTagClick: handleTagClick,
|
|
128
|
-
inputFieldPosition: "bottom",
|
|
129
|
-
onClearAll: onClearAll,
|
|
130
|
-
onTagUpdate: onTagUpdate,
|
|
131
|
-
tags: tags,
|
|
132
|
-
suggestions: mappedSuggestionsTags,
|
|
133
|
-
minQueryLength: 1,
|
|
134
|
-
autocomplete: true
|
|
135
42
|
}));
|
|
136
43
|
}
|
|
137
44
|
MultiTagsInput.propTypes = {
|
package/es/locales/locales_en.js
CHANGED
package/es/locales/locales_fr.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mirador-annotation-editor-video",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.98",
|
|
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",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"react-refresh": "^0.14.0",
|
|
51
51
|
"react-refresh-webpack-plugin": "^0.1.0",
|
|
52
52
|
"react-resize-observer": "^1.1.1",
|
|
53
|
+
"react-select": "^5.10.1",
|
|
53
54
|
"react-sortablejs": "^6.1.4",
|
|
54
|
-
"react-tag-input": "^6.10.6",
|
|
55
55
|
"redux": "^5.0.1",
|
|
56
56
|
"sortablejs": "^1.15.2",
|
|
57
57
|
"use-image": "^1.1.1",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"jest-canvas-mock": "^2.2.0",
|
|
95
95
|
"jest-junit": "^15.0.0",
|
|
96
96
|
"jest-localstorage-mock": "^2.4.2",
|
|
97
|
-
"mirador": "npm:mirador-video@1.0.
|
|
97
|
+
"mirador": "npm:mirador-video@1.0.26",
|
|
98
98
|
"prop-types": "^15.7.2",
|
|
99
99
|
"react": "^18.2.0",
|
|
100
100
|
"react-dom": "^18.0",
|
package/src/IIIFUtils.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { WithContext as ReactTags } from 'react-tag-input';
|
|
1
|
+
import React from 'react';
|
|
3
2
|
import PropTypes from 'prop-types';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
} from '@mui/material';
|
|
3
|
+
import { Divider, Typography } from '@mui/material';
|
|
4
|
+
import CreatableSelect from 'react-select/creatable';
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
7
|
* MultiTagsInput component
|
|
@@ -20,73 +18,11 @@ export function MultiTagsInput({
|
|
|
20
18
|
tags,
|
|
21
19
|
tagsSuggestions,
|
|
22
20
|
}) {
|
|
23
|
-
const [showSuggestions, setShowSuggestions] = useState(false);
|
|
24
|
-
|
|
25
21
|
const mappedSuggestionsTags = tagsSuggestions.map((suggestion) => ({
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
label: suggestion,
|
|
23
|
+
value: suggestion,
|
|
28
24
|
}));
|
|
29
25
|
|
|
30
|
-
/**
|
|
31
|
-
* Handle tag deletion
|
|
32
|
-
* @param index
|
|
33
|
-
*/
|
|
34
|
-
const handleDelete = (index) => {
|
|
35
|
-
setTags(tags.filter((_, i) => i !== index));
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Handle tag update
|
|
40
|
-
* @param index
|
|
41
|
-
* @param newTag
|
|
42
|
-
*/
|
|
43
|
-
const onTagUpdate = (index, newTag) => {
|
|
44
|
-
const updatedTags = [...tags];
|
|
45
|
-
updatedTags.splice(index, 1, newTag);
|
|
46
|
-
setTags(updatedTags);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Handle tag addition
|
|
51
|
-
* @param tag
|
|
52
|
-
*/
|
|
53
|
-
const handleAddition = (newTag) => {
|
|
54
|
-
if (tags.length === 0 || !tags.find((tag) => tag.id === newTag.id)) {
|
|
55
|
-
setTags([...tags, newTag]);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Handle tag drag
|
|
61
|
-
* @param tag
|
|
62
|
-
* @param currPos
|
|
63
|
-
* @param newPos
|
|
64
|
-
*/
|
|
65
|
-
const handleDrag = (tag, currPos, newPos) => {
|
|
66
|
-
const newTags = tags.slice();
|
|
67
|
-
|
|
68
|
-
newTags.splice(currPos, 1);
|
|
69
|
-
newTags.splice(newPos, 0, tag);
|
|
70
|
-
|
|
71
|
-
// re-render
|
|
72
|
-
setTags(newTags);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Handle tag click
|
|
77
|
-
* @param index
|
|
78
|
-
*/
|
|
79
|
-
const handleTagClick = (index) => {
|
|
80
|
-
console.log(`The tag at index ${index} was clicked`);
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Clear all tags
|
|
85
|
-
*/
|
|
86
|
-
const onClearAll = () => {
|
|
87
|
-
setTags([]);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
26
|
return (
|
|
91
27
|
<>
|
|
92
28
|
<Typography variant="formSectionTitle">
|
|
@@ -95,63 +31,19 @@ export function MultiTagsInput({
|
|
|
95
31
|
{/* Show list of suggestions into a clickable tag */}
|
|
96
32
|
{/* add a toggle to show hide suggestions */}
|
|
97
33
|
|
|
98
|
-
<
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
)}
|
|
105
|
-
label="Suggestion"
|
|
34
|
+
<CreatableSelect
|
|
35
|
+
isMulti
|
|
36
|
+
options={mappedSuggestionsTags}
|
|
37
|
+
value={tags}
|
|
38
|
+
onChange={setTags}
|
|
39
|
+
closeMenuOnSelect={false}
|
|
40
|
+
placeholder={t('tagsPlaceholder')}
|
|
106
41
|
/>
|
|
107
|
-
|
|
108
|
-
showSuggestions
|
|
109
|
-
&& (
|
|
110
|
-
<div style={{
|
|
111
|
-
display: 'flex',
|
|
112
|
-
flexWrap: 'wrap',
|
|
113
|
-
gap: '8px',
|
|
114
|
-
}}
|
|
115
|
-
>
|
|
116
|
-
{mappedSuggestionsTags.map((suggestion) => (
|
|
117
|
-
<button
|
|
118
|
-
key={suggestion.id}
|
|
119
|
-
type="button"
|
|
120
|
-
onClick={() => handleAddition(suggestion)}
|
|
121
|
-
style={{
|
|
122
|
-
padding: '6px 12px',
|
|
123
|
-
borderRadius: '16px',
|
|
124
|
-
border: '1px solid #ccc',
|
|
125
|
-
backgroundColor: '#f1f1f1',
|
|
126
|
-
cursor: 'pointer',
|
|
127
|
-
}}
|
|
128
|
-
>
|
|
129
|
-
{suggestion.text}
|
|
130
|
-
</button>
|
|
131
|
-
))}
|
|
132
|
-
</div>
|
|
133
|
-
)
|
|
134
|
-
}
|
|
42
|
+
|
|
135
43
|
<Divider
|
|
136
44
|
spacing={2}
|
|
137
45
|
/>
|
|
138
46
|
|
|
139
|
-
<ReactTags
|
|
140
|
-
placeholder={t('pressEnterToAddTag')}
|
|
141
|
-
clearAll
|
|
142
|
-
editable
|
|
143
|
-
handleAddition={handleAddition}
|
|
144
|
-
handleDelete={handleDelete}
|
|
145
|
-
handleDrag={handleDrag}
|
|
146
|
-
handleTagClick={handleTagClick}
|
|
147
|
-
inputFieldPosition="bottom"
|
|
148
|
-
onClearAll={onClearAll}
|
|
149
|
-
onTagUpdate={onTagUpdate}
|
|
150
|
-
tags={tags}
|
|
151
|
-
suggestions={mappedSuggestionsTags}
|
|
152
|
-
minQueryLength={1}
|
|
153
|
-
autocomplete
|
|
154
|
-
/>
|
|
155
47
|
</>
|
|
156
48
|
);
|
|
157
49
|
}
|