@pie-element/extended-text-entry 13.4.1-next.3 → 14.0.0-beta.1
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 +0 -17
- package/configure/CHANGELOG.md +0 -11
- package/configure/lib/defaults.js +2 -3
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/index.js +97 -151
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/main.js +223 -298
- package/configure/lib/main.js.map +1 -1
- package/configure/package.json +9 -6
- package/controller/CHANGELOG.md +0 -11
- package/controller/lib/defaults.js +2 -3
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +73 -170
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +2 -2
- package/lib/annotation/annotation-editor.js +493 -566
- package/lib/annotation/annotation-editor.js.map +1 -1
- package/lib/annotation/annotation-menu.js +131 -190
- package/lib/annotation/annotation-menu.js.map +1 -1
- package/lib/annotation/annotation-utils.js +77 -121
- package/lib/annotation/annotation-utils.js.map +1 -1
- package/lib/annotation/freeform-editor.js +202 -227
- package/lib/annotation/freeform-editor.js.map +1 -1
- package/lib/index.js +77 -131
- package/lib/index.js.map +1 -1
- package/lib/main.js +179 -243
- package/lib/main.js.map +1 -1
- package/lib/print.js +45 -87
- package/lib/print.js.map +1 -1
- package/package.json +13 -19
- package/esm/configure.js +0 -9412
- package/esm/configure.js.map +0 -1
- package/esm/controller.js +0 -905
- package/esm/controller.js.map +0 -1
- package/esm/element.js +0 -21631
- package/esm/element.js.map +0 -1
- package/esm/package.json +0 -3
- package/esm/print.js +0 -21600
- package/esm/print.js.map +0 -1
- package/module/configure.js +0 -1
- package/module/controller.js +0 -139
- package/module/demo.js +0 -38
- package/module/element.js +0 -1
- package/module/index.html +0 -21
- package/module/manifest.json +0 -22
- package/module/print-demo.js +0 -76
- package/module/print.html +0 -18
- package/module/print.js +0 -1
|
@@ -1,300 +1,211 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
exports
|
|
9
|
-
|
|
10
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
-
|
|
12
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
-
|
|
18
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
-
|
|
20
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
|
-
|
|
22
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
|
-
|
|
7
|
+
exports.default = void 0;
|
|
24
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
-
|
|
26
9
|
var _react = _interopRequireDefault(require("react"));
|
|
27
|
-
|
|
28
|
-
var _styles = require("@material-ui/core/styles");
|
|
29
|
-
|
|
30
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
31
|
-
|
|
10
|
+
var _styles = require("@mui/material/styles");
|
|
32
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
33
|
-
|
|
34
12
|
var _annotationUtils = require("./annotation-utils");
|
|
35
|
-
|
|
36
13
|
var _freeformEditor = _interopRequireDefault(require("./freeform-editor"));
|
|
37
|
-
|
|
38
14
|
var _annotationMenu = _interopRequireDefault(require("./annotation-menu"));
|
|
39
|
-
|
|
40
|
-
var _editableHtml = _interopRequireDefault(require("@pie-lib/editable-html"));
|
|
41
|
-
|
|
15
|
+
var _editableHtmlTipTap = _interopRequireDefault(require("@pie-lib/editable-html-tip-tap"));
|
|
42
16
|
var _configUi = require("@pie-lib/config-ui");
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
},
|
|
115
|
-
'&.negative': {
|
|
116
|
-
color: 'rgb(204, 0, 136)'
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
labelHover: {
|
|
120
|
-
zIndex: 20,
|
|
121
|
-
'&.positive': {
|
|
122
|
-
color: 'rgb(0, 77, 0)'
|
|
123
|
-
},
|
|
124
|
-
'&.negative': {
|
|
125
|
-
color: 'rgb(153, 0, 102)'
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
highlight: {
|
|
129
|
-
zIndex: 10
|
|
130
|
-
},
|
|
131
|
-
hover: {
|
|
132
|
-
zIndex: 20,
|
|
133
|
-
'&.positive': {
|
|
134
|
-
backgroundColor: 'rgb(51, 255, 51, 0.7)'
|
|
135
|
-
},
|
|
136
|
-
'&.negative': {
|
|
137
|
-
backgroundColor: 'rgba(255, 102, 204, 0.55)'
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
sideAnnotationHover: {
|
|
141
|
-
zIndex: 20,
|
|
142
|
-
'&.negative': {
|
|
143
|
-
backgroundColor: 'rgb(255, 179, 230) !important',
|
|
144
|
-
'&:before': {
|
|
145
|
-
borderRightColor: 'rgb(255, 179, 230) !important'
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
'&.positive': {
|
|
149
|
-
backgroundColor: 'rgb(128, 255, 128) !important',
|
|
150
|
-
'&:before': {
|
|
151
|
-
borderRightColor: 'rgb(153, 255, 153) !important'
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
},
|
|
155
|
-
sideAnnotation: {
|
|
156
|
-
position: 'absolute',
|
|
157
|
-
padding: theme.spacing.unit / 2,
|
|
158
|
-
borderRadius: '4px',
|
|
159
|
-
marginLeft: theme.spacing.unit,
|
|
160
|
-
width: '180px',
|
|
161
|
-
whiteSpace: 'pre-wrap',
|
|
162
|
-
wordBreak: 'break-word',
|
|
163
|
-
border: "2px solid ".concat(theme.palette.common.white),
|
|
164
|
-
fontSize: theme.typography.fontSize,
|
|
165
|
-
fontStyle: 'normal',
|
|
166
|
-
fontWeight: 'normal',
|
|
167
|
-
'&:before': {
|
|
168
|
-
position: 'absolute',
|
|
169
|
-
right: '100%',
|
|
170
|
-
top: '5px',
|
|
171
|
-
border: 'solid transparent',
|
|
172
|
-
content: '""',
|
|
173
|
-
height: 0,
|
|
174
|
-
width: 0,
|
|
175
|
-
pointerEvents: 'none',
|
|
176
|
-
borderWidth: '7px'
|
|
177
|
-
},
|
|
178
|
-
'&.negative': {
|
|
179
|
-
backgroundColor: 'rgb(255, 204, 238)',
|
|
180
|
-
'&:before': {
|
|
181
|
-
borderRightColor: 'rgb(255, 204, 238)'
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
'&.positive': {
|
|
185
|
-
backgroundColor: 'rgb(153, 255, 153)',
|
|
186
|
-
'&:before': {
|
|
187
|
-
borderRightColor: 'rgb(153, 255, 153)'
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
var AnnotationEditor = /*#__PURE__*/function (_React$Component) {
|
|
195
|
-
(0, _inherits2["default"])(AnnotationEditor, _React$Component);
|
|
196
|
-
|
|
197
|
-
var _super = _createSuper(AnnotationEditor);
|
|
198
|
-
|
|
199
|
-
function AnnotationEditor(props) {
|
|
200
|
-
var _this;
|
|
201
|
-
|
|
202
|
-
(0, _classCallCheck2["default"])(this, AnnotationEditor);
|
|
203
|
-
_this = _super.call(this, props);
|
|
204
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "adjustAnnotationsPosition", function () {
|
|
205
|
-
if (_this.textRef && _this.labelsRef) {
|
|
206
|
-
var left = _this.textRef.offsetLeft + _this.textRef.offsetWidth + 8;
|
|
207
|
-
Array.from(_this.labelsRef.children).forEach(function (label) {
|
|
208
|
-
var spans = (0, _annotationUtils.getAnnotationElements)(label.dataset.annId);
|
|
209
|
-
var spanOffset = spans[0].offsetTop ? spans[0].offsetTop : spans[0].offsetParent.offsetTop;
|
|
210
|
-
var top = spanOffset - _this.textRef.scrollTop - 6;
|
|
211
|
-
label.style.top = "".concat(top, "px");
|
|
212
|
-
label.style.left = "".concat(left, "px");
|
|
17
|
+
const TextContainer = (0, _styles.styled)('div')({
|
|
18
|
+
padding: '10px 120px 10px 16px',
|
|
19
|
+
backgroundColor: 'rgba(0, 0, 0, 0.06)',
|
|
20
|
+
border: '1px solid #ccc',
|
|
21
|
+
borderRadius: '4px',
|
|
22
|
+
overflowY: 'scroll',
|
|
23
|
+
lineHeight: '36px',
|
|
24
|
+
whiteSpace: 'pre-wrap',
|
|
25
|
+
overflowWrap: 'break-word',
|
|
26
|
+
'& p': {
|
|
27
|
+
margin: 0
|
|
28
|
+
},
|
|
29
|
+
'& span[data-latex]': {
|
|
30
|
+
userSelect: 'none',
|
|
31
|
+
'-webkit-user-select': 'none',
|
|
32
|
+
'-moz-user-select': 'none',
|
|
33
|
+
'-ms-user-select': 'none'
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
const LabelsContainer = (0, _styles.styled)('div')({
|
|
37
|
+
width: '230px'
|
|
38
|
+
});
|
|
39
|
+
const Wrapper = (0, _styles.styled)('div')({
|
|
40
|
+
position: 'relative',
|
|
41
|
+
overflowX: 'hidden',
|
|
42
|
+
display: 'flex'
|
|
43
|
+
});
|
|
44
|
+
const CommentContainer = (0, _styles.styled)(_configUi.InputContainer)(({
|
|
45
|
+
theme
|
|
46
|
+
}) => ({
|
|
47
|
+
paddingTop: theme.spacing(2),
|
|
48
|
+
marginBottom: theme.spacing(2),
|
|
49
|
+
marginTop: theme.spacing(2),
|
|
50
|
+
width: '100%'
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
// Global styles for pseudo-elements that can't be applied inline
|
|
54
|
+
const globalStyles = `
|
|
55
|
+
.sideAnnotation:before {
|
|
56
|
+
position: absolute;
|
|
57
|
+
right: var(--before-right, 100%);
|
|
58
|
+
top: var(--before-top, 5px);
|
|
59
|
+
border: solid transparent;
|
|
60
|
+
content: "";
|
|
61
|
+
height: 0;
|
|
62
|
+
width: 0;
|
|
63
|
+
pointer-events: none;
|
|
64
|
+
border-width: var(--before-border-width, 7px);
|
|
65
|
+
border-right-color: var(--before-border-color, rgb(153, 255, 153));
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
|
|
69
|
+
// Inject styles if not already injected
|
|
70
|
+
if (!document.getElementById('annotation-editor-styles')) {
|
|
71
|
+
const styleElement = document.createElement('style');
|
|
72
|
+
styleElement.id = 'annotation-editor-styles';
|
|
73
|
+
styleElement.textContent = globalStyles;
|
|
74
|
+
document.head.appendChild(styleElement);
|
|
75
|
+
}
|
|
76
|
+
class AnnotationEditor extends _react.default.Component {
|
|
77
|
+
constructor(props) {
|
|
78
|
+
super(props);
|
|
79
|
+
(0, _defineProperty2.default)(this, "adjustAnnotationsPosition", () => {
|
|
80
|
+
if (this.textRef && this.labelsRef) {
|
|
81
|
+
const left = this.textRef.offsetLeft + this.textRef.offsetWidth + 8;
|
|
82
|
+
Array.from(this.labelsRef.children).forEach(label => {
|
|
83
|
+
const spans = (0, _annotationUtils.getAnnotationElements)(label.dataset.annId);
|
|
84
|
+
const spanOffset = spans[0].offsetTop ? spans[0].offsetTop : spans[0].offsetParent.offsetTop;
|
|
85
|
+
const top = spanOffset - this.textRef.scrollTop - 6;
|
|
86
|
+
label.style.top = `${top}px`;
|
|
87
|
+
label.style.left = `${left}px`;
|
|
213
88
|
});
|
|
214
89
|
}
|
|
215
90
|
});
|
|
216
|
-
(0, _defineProperty2
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
91
|
+
(0, _defineProperty2.default)(this, "handleClick", event => {
|
|
92
|
+
const {
|
|
93
|
+
annotations
|
|
94
|
+
} = this.props;
|
|
95
|
+
const {
|
|
96
|
+
selectionDetails
|
|
97
|
+
} = this.state;
|
|
222
98
|
if (selectionDetails) {
|
|
223
99
|
// new selection was made inside another annotation and should not update that annotation
|
|
224
100
|
return;
|
|
225
101
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
});
|
|
236
|
-
var isSideLabel = labelElem.hasAttribute('data-freeform');
|
|
237
|
-
|
|
102
|
+
const {
|
|
103
|
+
id,
|
|
104
|
+
annId
|
|
105
|
+
} = event.target.dataset;
|
|
106
|
+
const annotationId = id || annId;
|
|
107
|
+
const selectedElems = (0, _annotationUtils.getAnnotationElements)(annotationId);
|
|
108
|
+
const labelElem = (0, _annotationUtils.getLabelElement)(annotationId);
|
|
109
|
+
const annotationIndex = annotations.findIndex(annotation => annotation.id === annotationId);
|
|
110
|
+
const isSideLabel = labelElem.hasAttribute('data-freeform');
|
|
238
111
|
if (isSideLabel) {
|
|
239
|
-
labelElem.
|
|
112
|
+
labelElem.style.zIndex = '10';
|
|
240
113
|
}
|
|
241
|
-
|
|
242
|
-
_this.setState({
|
|
114
|
+
this.setState({
|
|
243
115
|
anchorEl: selectedElems[0],
|
|
244
116
|
openedMenu: !!id || !!annId && !isSideLabel,
|
|
245
117
|
// true if the annotation or the label was clicked
|
|
246
118
|
openedEditor: !!annId && isSideLabel,
|
|
247
119
|
// true if the side label was clicked
|
|
248
|
-
selectedElems
|
|
249
|
-
labelElem
|
|
250
|
-
annotationIndex
|
|
120
|
+
selectedElems,
|
|
121
|
+
labelElem,
|
|
122
|
+
annotationIndex,
|
|
251
123
|
annotation: annotations[annotationIndex],
|
|
252
124
|
selectionDetails: null
|
|
253
125
|
});
|
|
254
126
|
});
|
|
255
|
-
(0, _defineProperty2
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
selectedElems.forEach(
|
|
265
|
-
|
|
127
|
+
(0, _defineProperty2.default)(this, "handleHover", event => {
|
|
128
|
+
const {
|
|
129
|
+
id,
|
|
130
|
+
annId
|
|
131
|
+
} = event.target.dataset;
|
|
132
|
+
const annotationId = id || annId;
|
|
133
|
+
const selectedElems = (0, _annotationUtils.getAnnotationElements)(annotationId);
|
|
134
|
+
const labelElem = (0, _annotationUtils.getLabelElement)(annotationId);
|
|
135
|
+
const isSideLabel = labelElem.hasAttribute('data-freeform');
|
|
136
|
+
selectedElems.forEach(elem => {
|
|
137
|
+
elem.style.zIndex = '20';
|
|
138
|
+
if (elem.classList.contains('positive')) {
|
|
139
|
+
elem.style.backgroundColor = 'rgb(51, 255, 51, 0.7)';
|
|
140
|
+
} else if (elem.classList.contains('negative')) {
|
|
141
|
+
elem.style.backgroundColor = 'rgba(255, 102, 204, 0.55)';
|
|
142
|
+
}
|
|
266
143
|
});
|
|
267
|
-
|
|
144
|
+
if (isSideLabel) {
|
|
145
|
+
labelElem.style.zIndex = '20';
|
|
146
|
+
if (labelElem.classList.contains('positive')) {
|
|
147
|
+
labelElem.style.backgroundColor = 'rgb(128, 255, 128)';
|
|
148
|
+
labelElem.style.setProperty('--before-border-color', 'rgb(153, 255, 153)');
|
|
149
|
+
} else if (labelElem.classList.contains('negative')) {
|
|
150
|
+
labelElem.style.backgroundColor = 'rgb(255, 179, 230)';
|
|
151
|
+
labelElem.style.setProperty('--before-border-color', 'rgb(255, 179, 230)');
|
|
152
|
+
}
|
|
153
|
+
} else {
|
|
154
|
+
labelElem.style.zIndex = '20';
|
|
155
|
+
if (labelElem.classList.contains('positive')) {
|
|
156
|
+
labelElem.style.color = 'rgb(0, 77, 0)';
|
|
157
|
+
} else if (labelElem.classList.contains('negative')) {
|
|
158
|
+
labelElem.style.color = 'rgb(153, 0, 102)';
|
|
159
|
+
}
|
|
160
|
+
}
|
|
268
161
|
});
|
|
269
|
-
(0, _defineProperty2
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
selectedElems.forEach(
|
|
279
|
-
|
|
162
|
+
(0, _defineProperty2.default)(this, "handleCancelHover", event => {
|
|
163
|
+
const {
|
|
164
|
+
id,
|
|
165
|
+
annId
|
|
166
|
+
} = event.target.dataset;
|
|
167
|
+
const annotationId = id || annId;
|
|
168
|
+
const selectedElems = (0, _annotationUtils.getAnnotationElements)(annotationId);
|
|
169
|
+
const labelElem = (0, _annotationUtils.getLabelElement)(annotationId);
|
|
170
|
+
const isSideLabel = labelElem.hasAttribute('data-freeform');
|
|
171
|
+
selectedElems.forEach(elem => {
|
|
172
|
+
elem.style.zIndex = '';
|
|
173
|
+
if (elem.classList.contains('positive')) {
|
|
174
|
+
elem.style.backgroundColor = 'rgb(51, 255, 51, 0.5)';
|
|
175
|
+
} else if (elem.classList.contains('negative')) {
|
|
176
|
+
elem.style.backgroundColor = 'rgba(255, 102, 204, 0.4)';
|
|
177
|
+
}
|
|
280
178
|
});
|
|
281
|
-
|
|
179
|
+
if (isSideLabel) {
|
|
180
|
+
labelElem.style.zIndex = '';
|
|
181
|
+
if (labelElem.classList.contains('positive')) {
|
|
182
|
+
labelElem.style.backgroundColor = 'rgb(153, 255, 153)';
|
|
183
|
+
labelElem.style.removeProperty('--before-border-color');
|
|
184
|
+
} else if (labelElem.classList.contains('negative')) {
|
|
185
|
+
labelElem.style.backgroundColor = 'rgb(255, 204, 238)';
|
|
186
|
+
labelElem.style.removeProperty('--before-border-color');
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
labelElem.style.zIndex = '';
|
|
190
|
+
if (labelElem.classList.contains('positive')) {
|
|
191
|
+
labelElem.style.color = 'rgb(0, 128, 0)';
|
|
192
|
+
} else if (labelElem.classList.contains('negative')) {
|
|
193
|
+
labelElem.style.color = 'rgb(204, 0, 136)';
|
|
194
|
+
}
|
|
195
|
+
}
|
|
282
196
|
});
|
|
283
|
-
(0, _defineProperty2
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
197
|
+
(0, _defineProperty2.default)(this, "handleClose", event => {
|
|
198
|
+
const {
|
|
199
|
+
selectedElems,
|
|
200
|
+
labelElem
|
|
201
|
+
} = this.state;
|
|
289
202
|
if (selectedElems.length && !selectedElems[0].hasAttribute('data-id')) {
|
|
290
|
-
(0, _annotationUtils.removeElemsWrapping)(selectedElems,
|
|
203
|
+
(0, _annotationUtils.removeElemsWrapping)(selectedElems, this.textRef);
|
|
291
204
|
}
|
|
292
|
-
|
|
293
205
|
if (labelElem) {
|
|
294
|
-
labelElem.
|
|
206
|
+
labelElem.style.zIndex = '';
|
|
295
207
|
}
|
|
296
|
-
|
|
297
|
-
_this.setState({
|
|
208
|
+
this.setState({
|
|
298
209
|
anchorEl: null,
|
|
299
210
|
openedMenu: false,
|
|
300
211
|
openedEditor: false,
|
|
@@ -304,236 +215,285 @@ var AnnotationEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
304
215
|
annotationIndex: null,
|
|
305
216
|
annotation: null
|
|
306
217
|
});
|
|
307
|
-
|
|
308
218
|
(0, _annotationUtils.clearSelection)();
|
|
309
219
|
});
|
|
310
|
-
(0, _defineProperty2
|
|
311
|
-
|
|
220
|
+
(0, _defineProperty2.default)(this, "handleSelection", event => {
|
|
221
|
+
const selection = window.getSelection();
|
|
312
222
|
|
|
223
|
+
// prevent unwanted selections
|
|
313
224
|
if (event.detail > 2) {
|
|
314
225
|
(0, _annotationUtils.clearSelection)();
|
|
315
226
|
return;
|
|
316
227
|
}
|
|
317
|
-
|
|
318
228
|
if (selection && selection.rangeCount > 0) {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
var isSelectionInside = _this.textRef.contains(selectedRange.commonAncestorContainer);
|
|
323
|
-
|
|
229
|
+
const selectedRange = selection.getRangeAt(0);
|
|
230
|
+
const selectedText = selectedRange.toString();
|
|
231
|
+
const isSelectionInside = this.textRef.contains(selectedRange.commonAncestorContainer);
|
|
324
232
|
if (!selection.isCollapsed && selectedText !== '' && isSelectionInside) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
_this.setState({
|
|
233
|
+
const selectionDetails = (0, _annotationUtils.getRangeDetails)(selectedRange, this.textRef);
|
|
234
|
+
const selectedElems = (0, _annotationUtils.wrapRange)(selectedRange);
|
|
235
|
+
this.setState({
|
|
329
236
|
anchorEl: selectedElems[0],
|
|
330
237
|
openedMenu: true,
|
|
331
|
-
selectedElems
|
|
332
|
-
selectionDetails
|
|
238
|
+
selectedElems,
|
|
239
|
+
selectionDetails
|
|
333
240
|
});
|
|
334
241
|
}
|
|
335
242
|
}
|
|
336
243
|
});
|
|
337
|
-
(0, _defineProperty2
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
244
|
+
(0, _defineProperty2.default)(this, "deleteAnnotation", () => {
|
|
245
|
+
const {
|
|
246
|
+
annotations,
|
|
247
|
+
onChange
|
|
248
|
+
} = this.props;
|
|
249
|
+
const {
|
|
250
|
+
selectedElems,
|
|
251
|
+
labelElem,
|
|
252
|
+
annotationIndex,
|
|
253
|
+
annotation
|
|
254
|
+
} = this.state;
|
|
255
|
+
const parentRef = (0, _annotationUtils.isSideLabel)(annotation.label) ? this.labelsRef : selectedElems[0];
|
|
347
256
|
parentRef.removeChild(labelElem);
|
|
348
|
-
(0, _annotationUtils.removeElemsWrapping)(selectedElems,
|
|
257
|
+
(0, _annotationUtils.removeElemsWrapping)(selectedElems, this.textRef);
|
|
349
258
|
annotations.splice(annotationIndex, 1);
|
|
350
259
|
onChange(annotations);
|
|
351
|
-
|
|
352
|
-
_this.handleClose();
|
|
260
|
+
this.handleClose();
|
|
353
261
|
});
|
|
354
|
-
(0, _defineProperty2
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
262
|
+
(0, _defineProperty2.default)(this, "createDOMAnnotation", (elems, annotation) => {
|
|
263
|
+
const {
|
|
264
|
+
disabled
|
|
265
|
+
} = this.props;
|
|
266
|
+
const {
|
|
267
|
+
id,
|
|
268
|
+
label,
|
|
269
|
+
type
|
|
270
|
+
} = annotation;
|
|
271
|
+
(elems || []).forEach(elem => {
|
|
362
272
|
elem.dataset.id = id;
|
|
363
|
-
elem.className =
|
|
364
|
-
|
|
365
|
-
elem.
|
|
366
|
-
elem.
|
|
273
|
+
elem.className = `annotation ${type}`;
|
|
274
|
+
// Apply annotation styles directly
|
|
275
|
+
elem.style.position = 'relative';
|
|
276
|
+
elem.style.cursor = 'pointer';
|
|
277
|
+
if (type === 'positive') {
|
|
278
|
+
elem.style.backgroundColor = 'rgb(51, 255, 51, 0.5)';
|
|
279
|
+
} else if (type === 'negative') {
|
|
280
|
+
elem.style.backgroundColor = 'rgba(255, 102, 204, 0.4)';
|
|
281
|
+
}
|
|
282
|
+
elem.onclick = !disabled && this.handleClick;
|
|
283
|
+
elem.onmouseover = this.handleHover;
|
|
284
|
+
elem.onmouseout = this.handleCancelHover;
|
|
367
285
|
});
|
|
368
|
-
|
|
369
|
-
|
|
286
|
+
const firstSpan = elems && elems[0] || {};
|
|
287
|
+
const labelElem = document.createElement('SPAN');
|
|
370
288
|
labelElem.dataset.annId = id;
|
|
371
289
|
labelElem.innerHTML = label;
|
|
372
|
-
labelElem.onclick = !disabled &&
|
|
373
|
-
labelElem.onmouseover =
|
|
374
|
-
labelElem.onmouseout =
|
|
375
|
-
|
|
290
|
+
labelElem.onclick = !disabled && this.handleClick;
|
|
291
|
+
labelElem.onmouseover = this.handleHover;
|
|
292
|
+
labelElem.onmouseout = this.handleCancelHover;
|
|
376
293
|
if ((0, _annotationUtils.isSideLabel)(label)) {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
294
|
+
const spanOffset = firstSpan.offsetTop ? firstSpan.offsetTop : firstSpan.offsetParent.offsetTop;
|
|
295
|
+
const top = spanOffset - this.textRef.scrollTop;
|
|
296
|
+
const left = this.textRef.offsetLeft + this.textRef.offsetWidth + 8;
|
|
380
297
|
labelElem.dataset.freeform = true;
|
|
381
|
-
labelElem.className =
|
|
382
|
-
|
|
383
|
-
|
|
298
|
+
labelElem.className = `sideAnnotation ${type}`;
|
|
299
|
+
|
|
300
|
+
// Apply side annotation styles directly
|
|
301
|
+
labelElem.style.position = 'absolute';
|
|
302
|
+
labelElem.style.padding = '4px';
|
|
303
|
+
labelElem.style.borderRadius = '4px';
|
|
304
|
+
labelElem.style.marginLeft = '8px';
|
|
305
|
+
labelElem.style.width = '180px';
|
|
306
|
+
labelElem.style.whiteSpace = 'pre-wrap';
|
|
307
|
+
labelElem.style.wordBreak = 'break-word';
|
|
308
|
+
labelElem.style.border = '2px solid #ffffff';
|
|
309
|
+
labelElem.style.fontSize = '14px';
|
|
310
|
+
labelElem.style.fontStyle = 'normal';
|
|
311
|
+
labelElem.style.fontWeight = 'normal';
|
|
312
|
+
labelElem.style.top = `${top}px`;
|
|
313
|
+
labelElem.style.left = `${left}px`;
|
|
314
|
+
if (type === 'negative') {
|
|
315
|
+
labelElem.style.backgroundColor = 'rgb(255, 204, 238)';
|
|
316
|
+
} else if (type === 'positive') {
|
|
317
|
+
labelElem.style.backgroundColor = 'rgb(153, 255, 153)';
|
|
318
|
+
}
|
|
384
319
|
|
|
385
|
-
|
|
320
|
+
// Add pseudo-element styles via CSS
|
|
321
|
+
labelElem.style.setProperty('--before-border-width', '7px');
|
|
322
|
+
labelElem.style.setProperty('--before-top', '5px');
|
|
323
|
+
labelElem.style.setProperty('--before-right', '100%');
|
|
324
|
+
if (type === 'negative') {
|
|
325
|
+
labelElem.style.setProperty('--before-border-color', 'rgb(255, 204, 238)');
|
|
326
|
+
} else if (type === 'positive') {
|
|
327
|
+
labelElem.style.setProperty('--before-border-color', 'rgb(153, 255, 153)');
|
|
328
|
+
}
|
|
329
|
+
this.labelsRef.appendChild(labelElem);
|
|
386
330
|
} else {
|
|
387
|
-
labelElem.className =
|
|
331
|
+
labelElem.className = `annotationLabel ${type}`;
|
|
332
|
+
|
|
333
|
+
// Apply annotation label styles directly
|
|
334
|
+
labelElem.style.backgroundColor = 'rgb(242, 242, 242)';
|
|
335
|
+
labelElem.style.padding = '2px';
|
|
336
|
+
labelElem.style.position = 'absolute';
|
|
337
|
+
labelElem.style.userSelect = 'none';
|
|
338
|
+
labelElem.style.whiteSpace = 'nowrap';
|
|
339
|
+
labelElem.style.top = '-10px';
|
|
340
|
+
labelElem.style.left = '-2px';
|
|
341
|
+
labelElem.style.fontSize = '12px';
|
|
342
|
+
labelElem.style.fontStyle = 'normal';
|
|
343
|
+
labelElem.style.fontWeight = 'normal';
|
|
344
|
+
labelElem.style.lineHeight = '6px';
|
|
345
|
+
labelElem.style.webkitUserSelect = 'none';
|
|
346
|
+
labelElem.style.mozUserSelect = 'none';
|
|
347
|
+
labelElem.style.msUserSelect = 'none';
|
|
348
|
+
if (type === 'positive') {
|
|
349
|
+
labelElem.style.color = 'rgb(0, 128, 0)';
|
|
350
|
+
} else if (type === 'negative') {
|
|
351
|
+
labelElem.style.color = 'rgb(204, 0, 136)';
|
|
352
|
+
}
|
|
388
353
|
firstSpan.appendChild(labelElem);
|
|
389
354
|
}
|
|
390
355
|
});
|
|
391
|
-
(0, _defineProperty2
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
356
|
+
(0, _defineProperty2.default)(this, "createNewAnnotation", (label, type) => {
|
|
357
|
+
const {
|
|
358
|
+
selectedElems,
|
|
359
|
+
selectionDetails
|
|
360
|
+
} = this.state;
|
|
361
|
+
const annotation = {
|
|
397
362
|
id: [selectionDetails.start, selectionDetails.end, new Date().getTime()].join('-'),
|
|
398
|
-
label
|
|
399
|
-
type
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
363
|
+
label,
|
|
364
|
+
type,
|
|
365
|
+
...selectionDetails
|
|
366
|
+
};
|
|
367
|
+
this.createDOMAnnotation(selectedElems, annotation);
|
|
404
368
|
return annotation;
|
|
405
369
|
});
|
|
406
|
-
(0, _defineProperty2
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
370
|
+
(0, _defineProperty2.default)(this, "handleMenuClick", newAnnotation => {
|
|
371
|
+
const {
|
|
372
|
+
annotations,
|
|
373
|
+
onChange
|
|
374
|
+
} = this.props;
|
|
375
|
+
const {
|
|
376
|
+
annotation,
|
|
377
|
+
annotationIndex
|
|
378
|
+
} = this.state;
|
|
379
|
+
const {
|
|
380
|
+
type,
|
|
381
|
+
text: label
|
|
382
|
+
} = newAnnotation;
|
|
416
383
|
if (annotation) {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
384
|
+
const updatedAnnotation = {
|
|
385
|
+
...annotation,
|
|
386
|
+
label,
|
|
387
|
+
type
|
|
388
|
+
};
|
|
389
|
+
const {
|
|
390
|
+
type: oldType,
|
|
391
|
+
label: oldLabel
|
|
392
|
+
} = annotation;
|
|
393
|
+
this.updateLabel(oldLabel, updatedAnnotation, type !== oldType && oldType);
|
|
427
394
|
annotations.splice(annotationIndex, 1, updatedAnnotation);
|
|
428
395
|
} else {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
annotations.push(_newAnnotation);
|
|
396
|
+
const newAnnotation = this.createNewAnnotation(label, type);
|
|
397
|
+
annotations.push(newAnnotation);
|
|
432
398
|
}
|
|
433
|
-
|
|
434
399
|
onChange(annotations);
|
|
435
|
-
|
|
436
|
-
_this.handleClose();
|
|
400
|
+
this.handleClose();
|
|
437
401
|
});
|
|
438
|
-
(0, _defineProperty2
|
|
439
|
-
|
|
402
|
+
(0, _defineProperty2.default)(this, "editAnnotation", () => {
|
|
403
|
+
this.setState({
|
|
440
404
|
openedMenu: false,
|
|
441
405
|
openedEditor: true
|
|
442
406
|
});
|
|
443
407
|
});
|
|
444
|
-
(0, _defineProperty2
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
var labelElem = (0, _annotationUtils.getLabelElement)(annotation.id);
|
|
408
|
+
(0, _defineProperty2.default)(this, "addAnnotation", type => {
|
|
409
|
+
const {
|
|
410
|
+
annotations,
|
|
411
|
+
onChange
|
|
412
|
+
} = this.props;
|
|
413
|
+
const annotation = this.createNewAnnotation('', type);
|
|
414
|
+
const labelElem = (0, _annotationUtils.getLabelElement)(annotation.id);
|
|
452
415
|
annotations.push(annotation);
|
|
453
|
-
|
|
454
|
-
_this.setState({
|
|
416
|
+
this.setState({
|
|
455
417
|
openedMenu: false,
|
|
456
418
|
openedEditor: true,
|
|
457
419
|
annotationIndex: annotations.length - 1,
|
|
458
|
-
annotation
|
|
459
|
-
labelElem
|
|
420
|
+
annotation,
|
|
421
|
+
labelElem
|
|
460
422
|
});
|
|
461
|
-
|
|
462
423
|
onChange(annotations);
|
|
463
424
|
});
|
|
464
|
-
(0, _defineProperty2
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
425
|
+
(0, _defineProperty2.default)(this, "updateLabel", (oldLabel, annotation, oldType) => {
|
|
426
|
+
const {
|
|
427
|
+
selectedElems,
|
|
428
|
+
labelElem
|
|
429
|
+
} = this.state;
|
|
430
|
+
const {
|
|
431
|
+
label,
|
|
432
|
+
type
|
|
433
|
+
} = annotation;
|
|
471
434
|
if ((0, _annotationUtils.isSideLabel)(label) && (0, _annotationUtils.isSideLabel)(oldLabel) || !(0, _annotationUtils.isSideLabel)(label) && !(0, _annotationUtils.isSideLabel)(oldLabel)) {
|
|
472
435
|
labelElem.innerHTML = label;
|
|
473
|
-
|
|
474
436
|
if (oldType) {
|
|
475
437
|
labelElem.classList.remove(oldType);
|
|
476
438
|
labelElem.classList.add(type);
|
|
477
|
-
selectedElems.forEach(
|
|
439
|
+
selectedElems.forEach(elem => {
|
|
478
440
|
elem.classList.remove(oldType);
|
|
479
441
|
elem.classList.add(type);
|
|
480
442
|
});
|
|
481
443
|
}
|
|
482
444
|
} else if ((0, _annotationUtils.isSideLabel)(label) && !(0, _annotationUtils.isSideLabel)(oldLabel)) {
|
|
483
445
|
selectedElems[0].removeChild(labelElem);
|
|
484
|
-
|
|
485
|
-
_this.createDOMAnnotation(selectedElems, annotation);
|
|
446
|
+
this.createDOMAnnotation(selectedElems, annotation);
|
|
486
447
|
} else if (!(0, _annotationUtils.isSideLabel)(label) && (0, _annotationUtils.isSideLabel)(oldLabel)) {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
_this.createDOMAnnotation(selectedElems, annotation);
|
|
448
|
+
this.labelsRef.removeChild(labelElem);
|
|
449
|
+
this.createDOMAnnotation(selectedElems, annotation);
|
|
490
450
|
}
|
|
491
451
|
});
|
|
492
|
-
(0, _defineProperty2
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
452
|
+
(0, _defineProperty2.default)(this, "changeAnnotationType", newLabel => {
|
|
453
|
+
const {
|
|
454
|
+
annotations,
|
|
455
|
+
onChange
|
|
456
|
+
} = this.props;
|
|
457
|
+
const {
|
|
458
|
+
annotationIndex,
|
|
459
|
+
selectedElems
|
|
460
|
+
} = this.state;
|
|
461
|
+
const {
|
|
462
|
+
type: oldType,
|
|
463
|
+
label: oldLabel
|
|
464
|
+
} = annotations[annotationIndex];
|
|
465
|
+
const type = oldType === 'positive' ? 'negative' : 'positive';
|
|
466
|
+
const updatedAnnotation = {
|
|
467
|
+
...annotations[annotationIndex],
|
|
468
|
+
type,
|
|
506
469
|
label: newLabel
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
selectedElems.forEach(function (span) {
|
|
470
|
+
};
|
|
471
|
+
selectedElems.forEach(span => {
|
|
510
472
|
span.classList.remove(oldType);
|
|
511
473
|
span.classList.add(type);
|
|
512
474
|
});
|
|
513
|
-
|
|
514
|
-
_this.updateLabel(oldLabel, updatedAnnotation, oldType);
|
|
515
|
-
|
|
475
|
+
this.updateLabel(oldLabel, updatedAnnotation, oldType);
|
|
516
476
|
annotations.splice(annotationIndex, 1, updatedAnnotation);
|
|
517
477
|
onChange(annotations);
|
|
518
|
-
|
|
519
|
-
_this.handleClose();
|
|
478
|
+
this.handleClose();
|
|
520
479
|
});
|
|
521
|
-
(0, _defineProperty2
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
480
|
+
(0, _defineProperty2.default)(this, "updateAnnotation", (oldLabel, newLabel) => {
|
|
481
|
+
const {
|
|
482
|
+
annotations,
|
|
483
|
+
onChange
|
|
484
|
+
} = this.props;
|
|
485
|
+
const {
|
|
486
|
+
annotationIndex
|
|
487
|
+
} = this.state;
|
|
488
|
+
const updatedAnnotation = {
|
|
489
|
+
...annotations[annotationIndex],
|
|
528
490
|
label: newLabel
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
_this.updateLabel(oldLabel, updatedAnnotation);
|
|
532
|
-
|
|
491
|
+
};
|
|
492
|
+
this.updateLabel(oldLabel, updatedAnnotation);
|
|
533
493
|
annotations.splice(annotationIndex, 1, updatedAnnotation);
|
|
534
494
|
onChange(annotations);
|
|
535
495
|
});
|
|
536
|
-
|
|
496
|
+
this.state = {
|
|
537
497
|
anchorEl: null,
|
|
538
498
|
openedMenu: false,
|
|
539
499
|
openedEditor: false,
|
|
@@ -543,164 +503,131 @@ var AnnotationEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
543
503
|
annotation: null,
|
|
544
504
|
annotationIndex: null
|
|
545
505
|
};
|
|
546
|
-
return _this;
|
|
547
506
|
}
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
if (domStart && domEnd) {
|
|
566
|
-
var range = document.createRange();
|
|
567
|
-
range.setStart(domStart.node, domStart.offset);
|
|
568
|
-
range.setEnd(domEnd.node, domEnd.offset);
|
|
569
|
-
var spans = (0, _annotationUtils.wrapRange)(range);
|
|
570
|
-
|
|
571
|
-
_this2.createDOMAnnotation(spans, annotation);
|
|
572
|
-
}
|
|
573
|
-
});
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
if (this.textRef) {
|
|
577
|
-
this.adjustAnnotationsPosition();
|
|
578
|
-
this.textRef.addEventListener('scroll', this.adjustAnnotationsPosition);
|
|
579
|
-
}
|
|
507
|
+
componentDidMount() {
|
|
508
|
+
const {
|
|
509
|
+
annotations,
|
|
510
|
+
text
|
|
511
|
+
} = this.props;
|
|
512
|
+
if (text) {
|
|
513
|
+
annotations.forEach(annotation => {
|
|
514
|
+
const [domStart, domEnd] = (0, _annotationUtils.getDOMNodes)(annotation.start, annotation.end, this.textRef);
|
|
515
|
+
if (domStart && domEnd) {
|
|
516
|
+
const range = document.createRange();
|
|
517
|
+
range.setStart(domStart.node, domStart.offset);
|
|
518
|
+
range.setEnd(domEnd.node, domEnd.offset);
|
|
519
|
+
const spans = (0, _annotationUtils.wrapRange)(range);
|
|
520
|
+
this.createDOMAnnotation(spans, annotation);
|
|
521
|
+
}
|
|
522
|
+
});
|
|
580
523
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
this.textRef.removeEventListener('scroll', this.adjustAnnotationsPosition);
|
|
524
|
+
if (this.textRef) {
|
|
525
|
+
this.adjustAnnotationsPosition();
|
|
526
|
+
this.textRef.addEventListener('scroll', this.adjustAnnotationsPosition);
|
|
585
527
|
}
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
528
|
+
}
|
|
529
|
+
componentWillUnmount() {
|
|
530
|
+
this.textRef.removeEventListener('scroll', this.adjustAnnotationsPosition);
|
|
531
|
+
}
|
|
532
|
+
render() {
|
|
533
|
+
const {
|
|
534
|
+
comment,
|
|
535
|
+
customKeys,
|
|
536
|
+
disabled,
|
|
537
|
+
disabledMath,
|
|
538
|
+
keypadMode,
|
|
539
|
+
height,
|
|
540
|
+
width,
|
|
541
|
+
maxHeight,
|
|
542
|
+
onCommentChange,
|
|
543
|
+
predefinedAnnotations,
|
|
544
|
+
text
|
|
545
|
+
} = this.props;
|
|
546
|
+
const {
|
|
547
|
+
anchorEl,
|
|
548
|
+
annotation,
|
|
549
|
+
openedMenu,
|
|
550
|
+
openedEditor,
|
|
551
|
+
selectionDetails
|
|
552
|
+
} = this.state;
|
|
553
|
+
const anchorOffset = anchorEl && (anchorEl.offsetTop ? anchorEl.offsetTop : anchorEl.offsetParent.offsetTop);
|
|
554
|
+
const topOffset = this.textRef && anchorOffset ? anchorOffset - this.textRef.scrollTop - 8 : 0;
|
|
555
|
+
return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(Wrapper, null, /*#__PURE__*/_react.default.createElement(TextContainer, {
|
|
556
|
+
style: {
|
|
557
|
+
width: width - 34,
|
|
558
|
+
minHeight: height,
|
|
559
|
+
maxHeight: maxHeight
|
|
560
|
+
},
|
|
561
|
+
ref: r => this.textRef = r,
|
|
562
|
+
onMouseDown: !disabled ? _annotationUtils.clearSelection : () => {},
|
|
563
|
+
onMouseUp: !disabled ? this.handleSelection : () => {},
|
|
564
|
+
dangerouslySetInnerHTML: {
|
|
565
|
+
__html: text
|
|
566
|
+
}
|
|
567
|
+
}), /*#__PURE__*/_react.default.createElement(LabelsContainer, {
|
|
568
|
+
ref: r => this.labelsRef = r
|
|
569
|
+
})), /*#__PURE__*/_react.default.createElement(CommentContainer, {
|
|
570
|
+
label: 'Comment'
|
|
571
|
+
}, /*#__PURE__*/_react.default.createElement(_editableHtmlTipTap.default, {
|
|
572
|
+
className: "prompt",
|
|
573
|
+
markup: comment || '',
|
|
574
|
+
onChange: onCommentChange,
|
|
575
|
+
width: width && (width + 104).toString(),
|
|
576
|
+
disabled: disabled,
|
|
577
|
+
pluginProps: {
|
|
578
|
+
math: {
|
|
579
|
+
disabled: disabledMath,
|
|
580
|
+
customKeys: customKeys,
|
|
581
|
+
keypadMode: keypadMode,
|
|
582
|
+
controlledKeypadMode: false
|
|
620
583
|
},
|
|
621
|
-
|
|
622
|
-
|
|
584
|
+
video: {
|
|
585
|
+
disabled: true
|
|
623
586
|
},
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
630
|
-
className: classes.labelsContainer,
|
|
631
|
-
ref: function ref(r) {
|
|
632
|
-
return _this3.labelsRef = r;
|
|
633
|
-
}
|
|
634
|
-
})), /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
|
|
635
|
-
label: 'Comment',
|
|
636
|
-
className: classes.commentContainer
|
|
637
|
-
}, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
|
|
638
|
-
className: classes.prompt,
|
|
639
|
-
markup: comment || '',
|
|
640
|
-
onChange: onCommentChange,
|
|
641
|
-
width: width && (width + 104).toString(),
|
|
642
|
-
disabled: disabled,
|
|
643
|
-
pluginProps: {
|
|
644
|
-
math: {
|
|
645
|
-
disabled: disabledMath,
|
|
646
|
-
customKeys: customKeys,
|
|
647
|
-
keypadMode: keypadMode,
|
|
648
|
-
controlledKeypadMode: false
|
|
649
|
-
},
|
|
650
|
-
video: {
|
|
651
|
-
disabled: true
|
|
652
|
-
},
|
|
653
|
-
audio: {
|
|
654
|
-
disabled: true
|
|
655
|
-
},
|
|
656
|
-
textAlign: {
|
|
657
|
-
disabled: true
|
|
658
|
-
}
|
|
587
|
+
audio: {
|
|
588
|
+
disabled: true
|
|
589
|
+
},
|
|
590
|
+
textAlign: {
|
|
591
|
+
disabled: true
|
|
659
592
|
}
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
customKeys: _propTypes["default"].array,
|
|
699
|
-
keypadMode: _propTypes["default"].string,
|
|
700
|
-
classes: _propTypes["default"].object.isRequired
|
|
593
|
+
}
|
|
594
|
+
})), /*#__PURE__*/_react.default.createElement(_annotationMenu.default, {
|
|
595
|
+
anchorEl: anchorEl,
|
|
596
|
+
open: openedMenu && !disabled,
|
|
597
|
+
annotations: predefinedAnnotations,
|
|
598
|
+
isNewAnnotation: !!selectionDetails,
|
|
599
|
+
onClose: this.handleClose,
|
|
600
|
+
onDelete: this.deleteAnnotation,
|
|
601
|
+
onEdit: this.editAnnotation,
|
|
602
|
+
onWrite: this.addAnnotation,
|
|
603
|
+
onAnnotate: this.handleMenuClick
|
|
604
|
+
}), /*#__PURE__*/_react.default.createElement(_freeformEditor.default, {
|
|
605
|
+
anchorEl: this.textRef,
|
|
606
|
+
open: openedEditor && !disabled,
|
|
607
|
+
offset: topOffset,
|
|
608
|
+
value: annotation && annotation.label || '',
|
|
609
|
+
type: annotation && annotation.type,
|
|
610
|
+
onClose: this.handleClose,
|
|
611
|
+
onDelete: this.deleteAnnotation,
|
|
612
|
+
onSave: this.updateAnnotation,
|
|
613
|
+
onTypeChange: this.changeAnnotationType
|
|
614
|
+
}));
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
(0, _defineProperty2.default)(AnnotationEditor, "propTypes", {
|
|
618
|
+
text: _propTypes.default.string,
|
|
619
|
+
comment: _propTypes.default.string,
|
|
620
|
+
annotations: _propTypes.default.array,
|
|
621
|
+
predefinedAnnotations: _propTypes.default.array,
|
|
622
|
+
onChange: _propTypes.default.func.isRequired,
|
|
623
|
+
onCommentChange: _propTypes.default.func.isRequired,
|
|
624
|
+
width: _propTypes.default.number,
|
|
625
|
+
height: _propTypes.default.number,
|
|
626
|
+
maxHeight: _propTypes.default.string,
|
|
627
|
+
disabled: _propTypes.default.bool,
|
|
628
|
+
disabledMath: _propTypes.default.bool,
|
|
629
|
+
customKeys: _propTypes.default.array,
|
|
630
|
+
keypadMode: _propTypes.default.string
|
|
701
631
|
});
|
|
702
|
-
|
|
703
|
-
var _default = (0, _styles.withStyles)(style)(AnnotationEditor);
|
|
704
|
-
|
|
705
|
-
exports["default"] = _default;
|
|
632
|
+
var _default = exports.default = AnnotationEditor;
|
|
706
633
|
//# sourceMappingURL=annotation-editor.js.map
|