@pie-element/extended-text-entry 13.4.1-next.0 → 14.0.0-beta.0

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.
@@ -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["default"] = void 0;
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
15
  var _editableHtml = _interopRequireDefault(require("@pie-lib/editable-html"));
41
-
42
16
  var _configUi = require("@pie-lib/config-ui");
43
-
44
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
45
-
46
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
47
-
48
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
49
-
50
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
51
-
52
- var style = function style(theme) {
53
- return {
54
- textContainer: {
55
- padding: '10px 120px 10px 16px',
56
- backgroundColor: 'rgba(0, 0, 0, 0.06)',
57
- border: '1px solid #ccc',
58
- borderRadius: '4px',
59
- overflowY: 'scroll',
60
- lineHeight: '36px',
61
- whiteSpace: 'pre-wrap',
62
- overflowWrap: 'break-word',
63
- '& p': {
64
- margin: 0
65
- },
66
- '& span[data-latex]': {
67
- userSelect: 'none',
68
- '-webkit-user-select': 'none',
69
- '-moz-user-select': 'none',
70
- '-ms-user-select': 'none'
71
- }
72
- },
73
- labelsContainer: {
74
- width: '230px'
75
- },
76
- wrapper: {
77
- position: 'relative',
78
- overflowX: 'hidden',
79
- display: 'flex'
80
- },
81
- commentContainer: {
82
- paddingTop: theme.spacing.unit * 2,
83
- marginBottom: theme.spacing.unit * 2,
84
- marginTop: theme.spacing.unit * 2,
85
- width: '100%'
86
- },
87
- annotation: {
88
- position: 'relative',
89
- cursor: 'pointer',
90
- '&.positive': {
91
- backgroundColor: 'rgb(51, 255, 51, 0.5)'
92
- },
93
- '&.negative': {
94
- backgroundColor: 'rgba(255, 102, 204, 0.4)'
95
- }
96
- },
97
- annotationLabel: {
98
- backgroundColor: 'rgb(242, 242, 242)',
99
- padding: '2px',
100
- position: 'absolute',
101
- userSelect: 'none',
102
- whiteSpace: 'nowrap',
103
- top: '-10px',
104
- left: '-2px',
105
- fontSize: theme.typography.fontSize - 2,
106
- fontStyle: 'normal',
107
- fontWeight: 'normal',
108
- lineHeight: '6px',
109
- '-webkit-user-select': 'none',
110
- '-moz-user-select': 'none',
111
- '-ms-user-select': 'none',
112
- '&.positive': {
113
- color: 'rgb(0, 128, 0)'
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["default"])((0, _assertThisInitialized2["default"])(_this), "handleClick", function (event) {
217
- var _this$props = _this.props,
218
- annotations = _this$props.annotations,
219
- classes = _this$props.classes;
220
- var selectionDetails = _this.state.selectionDetails;
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
- var _event$target$dataset = event.target.dataset,
228
- id = _event$target$dataset.id,
229
- annId = _event$target$dataset.annId;
230
- var annotationId = id || annId;
231
- var selectedElems = (0, _annotationUtils.getAnnotationElements)(annotationId);
232
- var labelElem = (0, _annotationUtils.getLabelElement)(annotationId);
233
- var annotationIndex = annotations.findIndex(function (annotation) {
234
- return annotation.id === annotationId;
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.classList.add(classes.highlight);
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: selectedElems,
249
- labelElem: labelElem,
250
- annotationIndex: annotationIndex,
120
+ selectedElems,
121
+ labelElem,
122
+ annotationIndex,
251
123
  annotation: annotations[annotationIndex],
252
124
  selectionDetails: null
253
125
  });
254
126
  });
255
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleHover", function (event) {
256
- var classes = _this.props.classes;
257
- var _event$target$dataset2 = event.target.dataset,
258
- id = _event$target$dataset2.id,
259
- annId = _event$target$dataset2.annId;
260
- var annotationId = id || annId;
261
- var selectedElems = (0, _annotationUtils.getAnnotationElements)(annotationId);
262
- var labelElem = (0, _annotationUtils.getLabelElement)(annotationId);
263
- var isSideLabel = labelElem.hasAttribute('data-freeform');
264
- selectedElems.forEach(function (elem) {
265
- return elem.classList.add(classes.hover);
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
- labelElem.classList.add(isSideLabel ? classes.sideAnnotationHover : classes.labelHover);
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["default"])((0, _assertThisInitialized2["default"])(_this), "handleCancelHover", function (event) {
270
- var classes = _this.props.classes;
271
- var _event$target$dataset3 = event.target.dataset,
272
- id = _event$target$dataset3.id,
273
- annId = _event$target$dataset3.annId;
274
- var annotationId = id || annId;
275
- var selectedElems = (0, _annotationUtils.getAnnotationElements)(annotationId);
276
- var labelElem = (0, _annotationUtils.getLabelElement)(annotationId);
277
- var isSideLabel = labelElem.hasAttribute('data-freeform');
278
- selectedElems.forEach(function (elem) {
279
- return elem.classList.remove(classes.hover);
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
- labelElem.classList.remove(isSideLabel ? classes.sideAnnotationHover : classes.labelHover);
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["default"])((0, _assertThisInitialized2["default"])(_this), "handleClose", function (event) {
284
- var classes = _this.props.classes;
285
- var _this$state = _this.state,
286
- selectedElems = _this$state.selectedElems,
287
- labelElem = _this$state.labelElem;
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, _this.textRef);
203
+ (0, _annotationUtils.removeElemsWrapping)(selectedElems, this.textRef);
291
204
  }
292
-
293
205
  if (labelElem) {
294
- labelElem.classList.remove(classes.highlight);
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["default"])((0, _assertThisInitialized2["default"])(_this), "handleSelection", function (event) {
311
- var selection = window.getSelection(); // prevent unwanted selections
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
- var selectedRange = selection.getRangeAt(0);
320
- var selectedText = selectedRange.toString();
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
- var selectionDetails = (0, _annotationUtils.getRangeDetails)(selectedRange, _this.textRef);
326
- var selectedElems = (0, _annotationUtils.wrapRange)(selectedRange);
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: selectedElems,
332
- selectionDetails: selectionDetails
238
+ selectedElems,
239
+ selectionDetails
333
240
  });
334
241
  }
335
242
  }
336
243
  });
337
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "deleteAnnotation", function () {
338
- var _this$props2 = _this.props,
339
- annotations = _this$props2.annotations,
340
- onChange = _this$props2.onChange;
341
- var _this$state2 = _this.state,
342
- selectedElems = _this$state2.selectedElems,
343
- labelElem = _this$state2.labelElem,
344
- annotationIndex = _this$state2.annotationIndex,
345
- annotation = _this$state2.annotation;
346
- var parentRef = (0, _annotationUtils.isSideLabel)(annotation.label) ? _this.labelsRef : selectedElems[0];
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, _this.textRef);
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["default"])((0, _assertThisInitialized2["default"])(_this), "createDOMAnnotation", function (elems, annotation) {
355
- var _this$props3 = _this.props,
356
- classes = _this$props3.classes,
357
- disabled = _this$props3.disabled;
358
- var id = annotation.id,
359
- label = annotation.label,
360
- type = annotation.type;
361
- (elems || []).forEach(function (elem) {
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 = (0, _classnames["default"])(classes.annotation, type);
364
- elem.onclick = !disabled && _this.handleClick;
365
- elem.onmouseover = _this.handleHover;
366
- elem.onmouseout = _this.handleCancelHover;
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
- var firstSpan = elems && elems[0] || {};
369
- var labelElem = document.createElement('SPAN');
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 && _this.handleClick;
373
- labelElem.onmouseover = _this.handleHover;
374
- labelElem.onmouseout = _this.handleCancelHover;
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
- var spanOffset = firstSpan.offsetTop ? firstSpan.offsetTop : firstSpan.offsetParent.offsetTop;
378
- var top = spanOffset - _this.textRef.scrollTop;
379
- var left = _this.textRef.offsetLeft + _this.textRef.offsetWidth + 8;
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 = (0, _classnames["default"])(classes.sideAnnotation, type);
382
- labelElem.style.top = "".concat(top, "px");
383
- labelElem.style.left = "".concat(left, "px");
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
- _this.labelsRef.appendChild(labelElem);
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 = (0, _classnames["default"])(classes.annotationLabel, type);
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["default"])((0, _assertThisInitialized2["default"])(_this), "createNewAnnotation", function (label, type) {
392
- var _this$state3 = _this.state,
393
- selectedElems = _this$state3.selectedElems,
394
- selectionDetails = _this$state3.selectionDetails;
395
-
396
- var annotation = _objectSpread({
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: label,
399
- type: type
400
- }, selectionDetails);
401
-
402
- _this.createDOMAnnotation(selectedElems, annotation);
403
-
363
+ label,
364
+ type,
365
+ ...selectionDetails
366
+ };
367
+ this.createDOMAnnotation(selectedElems, annotation);
404
368
  return annotation;
405
369
  });
406
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleMenuClick", function (newAnnotation) {
407
- var _this$props4 = _this.props,
408
- annotations = _this$props4.annotations,
409
- onChange = _this$props4.onChange;
410
- var _this$state4 = _this.state,
411
- annotation = _this$state4.annotation,
412
- annotationIndex = _this$state4.annotationIndex;
413
- var type = newAnnotation.type,
414
- label = newAnnotation.text;
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
- var updatedAnnotation = _objectSpread(_objectSpread({}, annotation), {}, {
418
- label: label,
419
- type: type
420
- });
421
-
422
- var oldType = annotation.type,
423
- oldLabel = annotation.label;
424
-
425
- _this.updateLabel(oldLabel, updatedAnnotation, type !== oldType && oldType);
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
- var _newAnnotation = _this.createNewAnnotation(label, type);
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["default"])((0, _assertThisInitialized2["default"])(_this), "editAnnotation", function () {
439
- _this.setState({
402
+ (0, _defineProperty2.default)(this, "editAnnotation", () => {
403
+ this.setState({
440
404
  openedMenu: false,
441
405
  openedEditor: true
442
406
  });
443
407
  });
444
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "addAnnotation", function (type) {
445
- var _this$props5 = _this.props,
446
- annotations = _this$props5.annotations,
447
- onChange = _this$props5.onChange;
448
-
449
- var annotation = _this.createNewAnnotation('', type);
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: annotation,
459
- labelElem: labelElem
420
+ annotation,
421
+ labelElem
460
422
  });
461
-
462
423
  onChange(annotations);
463
424
  });
464
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "updateLabel", function (oldLabel, annotation, oldType) {
465
- var _this$state5 = _this.state,
466
- selectedElems = _this$state5.selectedElems,
467
- labelElem = _this$state5.labelElem;
468
- var label = annotation.label,
469
- type = annotation.type;
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(function (elem) {
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
- _this.labelsRef.removeChild(labelElem);
488
-
489
- _this.createDOMAnnotation(selectedElems, annotation);
448
+ this.labelsRef.removeChild(labelElem);
449
+ this.createDOMAnnotation(selectedElems, annotation);
490
450
  }
491
451
  });
492
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeAnnotationType", function (newLabel) {
493
- var _this$props6 = _this.props,
494
- annotations = _this$props6.annotations,
495
- onChange = _this$props6.onChange;
496
- var _this$state6 = _this.state,
497
- annotationIndex = _this$state6.annotationIndex,
498
- selectedElems = _this$state6.selectedElems;
499
- var _annotations$annotati = annotations[annotationIndex],
500
- oldType = _annotations$annotati.type,
501
- oldLabel = _annotations$annotati.label;
502
- var type = oldType === 'positive' ? 'negative' : 'positive';
503
-
504
- var updatedAnnotation = _objectSpread(_objectSpread({}, annotations[annotationIndex]), {}, {
505
- type: type,
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["default"])((0, _assertThisInitialized2["default"])(_this), "updateAnnotation", function (oldLabel, newLabel) {
522
- var _this$props7 = _this.props,
523
- annotations = _this$props7.annotations,
524
- onChange = _this$props7.onChange;
525
- var annotationIndex = _this.state.annotationIndex;
526
-
527
- var updatedAnnotation = _objectSpread(_objectSpread({}, annotations[annotationIndex]), {}, {
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
- _this.state = {
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
- (0, _createClass2["default"])(AnnotationEditor, [{
550
- key: "componentDidMount",
551
- value: function componentDidMount() {
552
- var _this2 = this;
553
-
554
- var _this$props8 = this.props,
555
- annotations = _this$props8.annotations,
556
- text = _this$props8.text;
557
-
558
- if (text) {
559
- annotations.forEach(function (annotation) {
560
- var _getDOMNodes = (0, _annotationUtils.getDOMNodes)(annotation.start, annotation.end, _this2.textRef),
561
- _getDOMNodes2 = (0, _slicedToArray2["default"])(_getDOMNodes, 2),
562
- domStart = _getDOMNodes2[0],
563
- domEnd = _getDOMNodes2[1];
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
- key: "componentWillUnmount",
583
- value: function componentWillUnmount() {
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
- key: "render",
588
- value: function render() {
589
- var _this3 = this;
590
-
591
- var _this$props9 = this.props,
592
- classes = _this$props9.classes,
593
- comment = _this$props9.comment,
594
- customKeys = _this$props9.customKeys,
595
- disabled = _this$props9.disabled,
596
- disabledMath = _this$props9.disabledMath,
597
- keypadMode = _this$props9.keypadMode,
598
- height = _this$props9.height,
599
- width = _this$props9.width,
600
- maxHeight = _this$props9.maxHeight,
601
- onCommentChange = _this$props9.onCommentChange,
602
- predefinedAnnotations = _this$props9.predefinedAnnotations,
603
- text = _this$props9.text;
604
- var _this$state7 = this.state,
605
- anchorEl = _this$state7.anchorEl,
606
- annotation = _this$state7.annotation,
607
- openedMenu = _this$state7.openedMenu,
608
- openedEditor = _this$state7.openedEditor,
609
- selectionDetails = _this$state7.selectionDetails;
610
- var anchorOffset = anchorEl && (anchorEl.offsetTop ? anchorEl.offsetTop : anchorEl.offsetParent.offsetTop);
611
- var topOffset = this.textRef && anchorOffset ? anchorOffset - this.textRef.scrollTop - 8 : 0;
612
- return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
613
- className: classes.wrapper
614
- }, /*#__PURE__*/_react["default"].createElement("div", {
615
- className: classes.textContainer,
616
- style: {
617
- width: width - 34,
618
- minHeight: height,
619
- maxHeight: maxHeight
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(_editableHtml.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
- ref: function ref(r) {
622
- return _this3.textRef = r;
584
+ video: {
585
+ disabled: true
623
586
  },
624
- onMouseDown: !disabled ? _annotationUtils.clearSelection : function () {},
625
- onMouseUp: !disabled ? this.handleSelection : function () {},
626
- dangerouslySetInnerHTML: {
627
- __html: text
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
- })), /*#__PURE__*/_react["default"].createElement(_annotationMenu["default"], {
661
- anchorEl: anchorEl,
662
- open: openedMenu && !disabled,
663
- annotations: predefinedAnnotations,
664
- isNewAnnotation: !!selectionDetails,
665
- onClose: this.handleClose,
666
- onDelete: this.deleteAnnotation,
667
- onEdit: this.editAnnotation,
668
- onWrite: this.addAnnotation,
669
- onAnnotate: this.handleMenuClick
670
- }), /*#__PURE__*/_react["default"].createElement(_freeformEditor["default"], {
671
- anchorEl: this.textRef,
672
- open: openedEditor && !disabled,
673
- offset: topOffset,
674
- value: annotation && annotation.label || '',
675
- type: annotation && annotation.type,
676
- onClose: this.handleClose,
677
- onDelete: this.deleteAnnotation,
678
- onSave: this.updateAnnotation,
679
- onTypeChange: this.changeAnnotationType
680
- }));
681
- }
682
- }]);
683
- return AnnotationEditor;
684
- }(_react["default"].Component);
685
-
686
- (0, _defineProperty2["default"])(AnnotationEditor, "propTypes", {
687
- text: _propTypes["default"].string,
688
- comment: _propTypes["default"].string,
689
- annotations: _propTypes["default"].array,
690
- predefinedAnnotations: _propTypes["default"].array,
691
- onChange: _propTypes["default"].func.isRequired,
692
- onCommentChange: _propTypes["default"].func.isRequired,
693
- width: _propTypes["default"].number,
694
- height: _propTypes["default"].number,
695
- maxHeight: _propTypes["default"].string,
696
- disabled: _propTypes["default"].bool,
697
- disabledMath: _propTypes["default"].bool,
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