@pie-element/extended-text-entry 15.1.1-next.11 → 15.1.2-next.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.
- package/configure.js +2 -0
- package/controller.js +1 -0
- package/dist/author/defaults.d.ts +166 -0
- package/dist/author/defaults.js +209 -0
- package/dist/author/index.d.ts +52 -0
- package/dist/author/index.js +74 -0
- package/dist/author/main.d.ts +26 -0
- package/dist/author/main.js +166 -0
- package/dist/browser/author/index.js +495 -0
- package/dist/browser/author/index.js.map +1 -0
- package/dist/browser/browser-kkT1XVKw.js +210 -0
- package/dist/browser/browser-kkT1XVKw.js.map +1 -0
- package/dist/browser/controller/index.js +184 -0
- package/dist/browser/controller/index.js.map +1 -0
- package/dist/browser/delivery/index.js +98 -0
- package/dist/browser/delivery/index.js.map +1 -0
- package/dist/browser/dist-D8VooYkz.js +49034 -0
- package/dist/browser/dist-D8VooYkz.js.map +1 -0
- package/dist/browser/extended-text-entry.css +2 -0
- package/dist/browser/main-C2oHx_V9.js +714 -0
- package/dist/browser/main-C2oHx_V9.js.map +1 -0
- package/dist/browser/print/index.js +53 -0
- package/dist/browser/print/index.js.map +1 -0
- package/dist/controller/defaults.d.ts +33 -0
- package/dist/controller/defaults.js +104 -0
- package/dist/controller/index.d.ts +59 -0
- package/dist/controller/index.js +72 -0
- package/dist/delivery/annotation/annotation-editor.d.ts +47 -0
- package/dist/delivery/annotation/annotation-editor.js +296 -0
- package/dist/delivery/annotation/annotation-menu.d.ts +25 -0
- package/dist/delivery/annotation/annotation-menu.js +113 -0
- package/dist/delivery/annotation/annotation-utils.d.ts +20 -0
- package/dist/delivery/annotation/annotation-utils.js +65 -0
- package/dist/delivery/annotation/freeform-editor.d.ts +30 -0
- package/dist/delivery/annotation/freeform-editor.js +143 -0
- package/dist/delivery/index.d.ts +23 -0
- package/dist/delivery/index.js +68 -0
- package/dist/delivery/main.d.ts +27 -0
- package/dist/delivery/main.js +134 -0
- package/dist/extended-text-entry.css +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.iife.d.ts +8 -0
- package/dist/index.iife.js +403 -0
- package/dist/index.js +2 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_DataView.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Hash.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_ListCache.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Map.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_MapCache.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Promise.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Set.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Stack.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Symbol.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_Uint8Array.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_WeakMap.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayEach.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayFilter.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayLikeKeys.js +15 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_arrayPush.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_assignValue.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_assocIndexOf.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseAssign.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseAssignIn.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseAssignValue.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseClone.js +57 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseCreate.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseGetAllKeys.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseGetTag.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsArguments.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsMap.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsNative.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsSet.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseIsTypedArray.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseKeys.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseKeysIn.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseTimes.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseTrim.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_baseUnary.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneArrayBuffer.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneBuffer.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneDataView.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneRegExp.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneSymbol.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_cloneTypedArray.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copyArray.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copyObject.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copySymbols.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_copySymbolsIn.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_coreJsData.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_defineProperty.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_freeGlobal.js +4 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getAllKeys.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getAllKeysIn.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getMapData.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getNative.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getPrototype.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getRawTag.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getSymbols.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getSymbolsIn.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getTag.js +23 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_getValue.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashClear.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashDelete.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashGet.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashHas.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_hashSet.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_initCloneArray.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_initCloneByTag.js +33 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_initCloneObject.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isIndex.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isKeyable.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isMasked.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_isPrototype.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheClear.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheDelete.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheGet.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheHas.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_listCacheSet.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheClear.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheDelete.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheGet.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheHas.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_mapCacheSet.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nativeCreate.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nativeKeys.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nativeKeysIn.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_nodeUtil.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_objectToString.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_overArg.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_root.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackClear.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackDelete.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackGet.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackHas.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_stackSet.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_toSource.js +15 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/_trimmedEndIndex.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/cloneDeep.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/debounce.js +50 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/eq.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArguments.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArray.js +4 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isArrayLike.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isBuffer.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isFunction.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isLength.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isMap.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isObject.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isObjectLike.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isSet.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isSymbol.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/isTypedArray.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/keys.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/keysIn.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/now.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/stubArray.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/stubFalse.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.18.1/node_modules/lodash-es/toNumber.js +19 -0
- package/dist/print/index.d.ts +15 -0
- package/dist/print/index.js +49 -0
- package/package.json +83 -21
- package/CHANGELOG.json +0 -1282
- package/CHANGELOG.md +0 -2260
- package/LICENSE.md +0 -5
- package/README.md +0 -1
- package/configure/CHANGELOG.json +0 -922
- package/configure/CHANGELOG.md +0 -1949
- package/configure/lib/defaults.js +0 -224
- package/configure/lib/defaults.js.map +0 -1
- package/configure/lib/index.js +0 -125
- package/configure/lib/index.js.map +0 -1
- package/configure/lib/main.js +0 -247
- package/configure/lib/main.js.map +0 -1
- package/configure/package.json +0 -23
- package/controller/CHANGELOG.json +0 -362
- package/controller/CHANGELOG.md +0 -1179
- package/controller/lib/defaults.js +0 -91
- package/controller/lib/defaults.js.map +0 -1
- package/controller/lib/index.js +0 -101
- package/controller/lib/index.js.map +0 -1
- package/controller/package.json +0 -16
- package/docs/config-schema.json +0 -1782
- package/docs/config-schema.json.md +0 -1333
- package/docs/demo/config.js +0 -7
- package/docs/demo/generate.js +0 -14
- package/docs/demo/index.html +0 -3
- package/docs/demo/session.js +0 -7
- package/docs/pie-schema.json +0 -954
- package/docs/pie-schema.json.md +0 -717
- package/lib/annotation/annotation-editor.js +0 -636
- package/lib/annotation/annotation-editor.js.map +0 -1
- package/lib/annotation/annotation-menu.js +0 -147
- package/lib/annotation/annotation-menu.js.map +0 -1
- package/lib/annotation/annotation-utils.js +0 -205
- package/lib/annotation/annotation-utils.js.map +0 -1
- package/lib/annotation/freeform-editor.js +0 -241
- package/lib/annotation/freeform-editor.js.map +0 -1
- package/lib/index.js +0 -108
- package/lib/index.js.map +0 -1
- package/lib/main.js +0 -205
- package/lib/main.js.map +0 -1
- package/lib/print.js +0 -86
- package/lib/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,636 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _styles = require("@mui/material/styles");
|
|
11
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
-
var _annotationUtils = require("./annotation-utils");
|
|
13
|
-
var _freeformEditor = _interopRequireDefault(require("./freeform-editor"));
|
|
14
|
-
var _annotationMenu = _interopRequireDefault(require("./annotation-menu"));
|
|
15
|
-
var _editableHtmlTipTap = _interopRequireDefault(require("@pie-lib/editable-html-tip-tap"));
|
|
16
|
-
var _configUi = require("@pie-lib/config-ui");
|
|
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`;
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
(0, _defineProperty2.default)(this, "handleClick", event => {
|
|
92
|
-
const {
|
|
93
|
-
annotations
|
|
94
|
-
} = this.props;
|
|
95
|
-
const {
|
|
96
|
-
selectionDetails
|
|
97
|
-
} = this.state;
|
|
98
|
-
if (selectionDetails) {
|
|
99
|
-
// new selection was made inside another annotation and should not update that annotation
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
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');
|
|
111
|
-
if (isSideLabel) {
|
|
112
|
-
labelElem.style.zIndex = '10';
|
|
113
|
-
}
|
|
114
|
-
this.setState({
|
|
115
|
-
anchorEl: selectedElems[0],
|
|
116
|
-
openedMenu: !!id || !!annId && !isSideLabel,
|
|
117
|
-
// true if the annotation or the label was clicked
|
|
118
|
-
openedEditor: !!annId && isSideLabel,
|
|
119
|
-
// true if the side label was clicked
|
|
120
|
-
selectedElems,
|
|
121
|
-
labelElem,
|
|
122
|
-
annotationIndex,
|
|
123
|
-
annotation: annotations[annotationIndex],
|
|
124
|
-
selectionDetails: null
|
|
125
|
-
});
|
|
126
|
-
});
|
|
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
|
-
}
|
|
143
|
-
});
|
|
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
|
-
}
|
|
161
|
-
});
|
|
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
|
-
}
|
|
178
|
-
});
|
|
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
|
-
}
|
|
196
|
-
});
|
|
197
|
-
(0, _defineProperty2.default)(this, "handleClose", event => {
|
|
198
|
-
const {
|
|
199
|
-
selectedElems,
|
|
200
|
-
labelElem
|
|
201
|
-
} = this.state;
|
|
202
|
-
if (selectedElems.length && !selectedElems[0].hasAttribute('data-id')) {
|
|
203
|
-
(0, _annotationUtils.removeElemsWrapping)(selectedElems, this.textRef);
|
|
204
|
-
}
|
|
205
|
-
if (labelElem) {
|
|
206
|
-
labelElem.style.zIndex = '';
|
|
207
|
-
}
|
|
208
|
-
this.setState({
|
|
209
|
-
anchorEl: null,
|
|
210
|
-
openedMenu: false,
|
|
211
|
-
openedEditor: false,
|
|
212
|
-
selectedElems: [],
|
|
213
|
-
labelElem: null,
|
|
214
|
-
selectionDetails: null,
|
|
215
|
-
annotationIndex: null,
|
|
216
|
-
annotation: null
|
|
217
|
-
});
|
|
218
|
-
(0, _annotationUtils.clearSelection)();
|
|
219
|
-
});
|
|
220
|
-
(0, _defineProperty2.default)(this, "handleSelection", event => {
|
|
221
|
-
const selection = window.getSelection();
|
|
222
|
-
|
|
223
|
-
// prevent unwanted selections
|
|
224
|
-
if (event.detail > 2) {
|
|
225
|
-
(0, _annotationUtils.clearSelection)();
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
if (selection && selection.rangeCount > 0) {
|
|
229
|
-
const selectedRange = selection.getRangeAt(0);
|
|
230
|
-
const selectedText = selectedRange.toString();
|
|
231
|
-
const isSelectionInside = this.textRef.contains(selectedRange.commonAncestorContainer);
|
|
232
|
-
if (!selection.isCollapsed && selectedText !== '' && isSelectionInside) {
|
|
233
|
-
const selectionDetails = (0, _annotationUtils.getRangeDetails)(selectedRange, this.textRef);
|
|
234
|
-
const selectedElems = (0, _annotationUtils.wrapRange)(selectedRange);
|
|
235
|
-
this.setState({
|
|
236
|
-
anchorEl: selectedElems[0],
|
|
237
|
-
openedMenu: true,
|
|
238
|
-
selectedElems,
|
|
239
|
-
selectionDetails
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
});
|
|
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];
|
|
256
|
-
parentRef.removeChild(labelElem);
|
|
257
|
-
(0, _annotationUtils.removeElemsWrapping)(selectedElems, this.textRef);
|
|
258
|
-
annotations.splice(annotationIndex, 1);
|
|
259
|
-
onChange(annotations);
|
|
260
|
-
this.handleClose();
|
|
261
|
-
});
|
|
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 => {
|
|
272
|
-
elem.dataset.id = id;
|
|
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;
|
|
285
|
-
});
|
|
286
|
-
const firstSpan = elems && elems[0] || {};
|
|
287
|
-
const labelElem = document.createElement('SPAN');
|
|
288
|
-
labelElem.dataset.annId = id;
|
|
289
|
-
labelElem.innerHTML = label;
|
|
290
|
-
labelElem.onclick = !disabled && this.handleClick;
|
|
291
|
-
labelElem.onmouseover = this.handleHover;
|
|
292
|
-
labelElem.onmouseout = this.handleCancelHover;
|
|
293
|
-
if ((0, _annotationUtils.isSideLabel)(label)) {
|
|
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;
|
|
297
|
-
labelElem.dataset.freeform = true;
|
|
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
|
-
}
|
|
319
|
-
|
|
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);
|
|
330
|
-
} else {
|
|
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
|
-
}
|
|
353
|
-
firstSpan.appendChild(labelElem);
|
|
354
|
-
}
|
|
355
|
-
});
|
|
356
|
-
(0, _defineProperty2.default)(this, "createNewAnnotation", (label, type) => {
|
|
357
|
-
const {
|
|
358
|
-
selectedElems,
|
|
359
|
-
selectionDetails
|
|
360
|
-
} = this.state;
|
|
361
|
-
const annotation = {
|
|
362
|
-
id: [selectionDetails.start, selectionDetails.end, new Date().getTime()].join('-'),
|
|
363
|
-
label,
|
|
364
|
-
type,
|
|
365
|
-
...selectionDetails
|
|
366
|
-
};
|
|
367
|
-
this.createDOMAnnotation(selectedElems, annotation);
|
|
368
|
-
return annotation;
|
|
369
|
-
});
|
|
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;
|
|
383
|
-
if (annotation) {
|
|
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);
|
|
394
|
-
annotations.splice(annotationIndex, 1, updatedAnnotation);
|
|
395
|
-
} else {
|
|
396
|
-
const newAnnotation = this.createNewAnnotation(label, type);
|
|
397
|
-
annotations.push(newAnnotation);
|
|
398
|
-
}
|
|
399
|
-
onChange(annotations);
|
|
400
|
-
this.handleClose();
|
|
401
|
-
});
|
|
402
|
-
(0, _defineProperty2.default)(this, "editAnnotation", () => {
|
|
403
|
-
this.setState({
|
|
404
|
-
openedMenu: false,
|
|
405
|
-
openedEditor: true
|
|
406
|
-
});
|
|
407
|
-
});
|
|
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);
|
|
415
|
-
annotations.push(annotation);
|
|
416
|
-
this.setState({
|
|
417
|
-
openedMenu: false,
|
|
418
|
-
openedEditor: true,
|
|
419
|
-
annotationIndex: annotations.length - 1,
|
|
420
|
-
annotation,
|
|
421
|
-
labelElem
|
|
422
|
-
});
|
|
423
|
-
onChange(annotations);
|
|
424
|
-
});
|
|
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;
|
|
434
|
-
if ((0, _annotationUtils.isSideLabel)(label) && (0, _annotationUtils.isSideLabel)(oldLabel) || !(0, _annotationUtils.isSideLabel)(label) && !(0, _annotationUtils.isSideLabel)(oldLabel)) {
|
|
435
|
-
labelElem.innerHTML = label;
|
|
436
|
-
if (oldType) {
|
|
437
|
-
labelElem.classList.remove(oldType);
|
|
438
|
-
labelElem.classList.add(type);
|
|
439
|
-
selectedElems.forEach(elem => {
|
|
440
|
-
elem.classList.remove(oldType);
|
|
441
|
-
elem.classList.add(type);
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
} else if ((0, _annotationUtils.isSideLabel)(label) && !(0, _annotationUtils.isSideLabel)(oldLabel)) {
|
|
445
|
-
selectedElems[0].removeChild(labelElem);
|
|
446
|
-
this.createDOMAnnotation(selectedElems, annotation);
|
|
447
|
-
} else if (!(0, _annotationUtils.isSideLabel)(label) && (0, _annotationUtils.isSideLabel)(oldLabel)) {
|
|
448
|
-
this.labelsRef.removeChild(labelElem);
|
|
449
|
-
this.createDOMAnnotation(selectedElems, annotation);
|
|
450
|
-
}
|
|
451
|
-
});
|
|
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,
|
|
469
|
-
label: newLabel
|
|
470
|
-
};
|
|
471
|
-
selectedElems.forEach(span => {
|
|
472
|
-
span.classList.remove(oldType);
|
|
473
|
-
span.classList.add(type);
|
|
474
|
-
});
|
|
475
|
-
this.updateLabel(oldLabel, updatedAnnotation, oldType);
|
|
476
|
-
annotations.splice(annotationIndex, 1, updatedAnnotation);
|
|
477
|
-
onChange(annotations);
|
|
478
|
-
this.handleClose();
|
|
479
|
-
});
|
|
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],
|
|
490
|
-
label: newLabel
|
|
491
|
-
};
|
|
492
|
-
this.updateLabel(oldLabel, updatedAnnotation);
|
|
493
|
-
annotations.splice(annotationIndex, 1, updatedAnnotation);
|
|
494
|
-
onChange(annotations);
|
|
495
|
-
});
|
|
496
|
-
this.state = {
|
|
497
|
-
anchorEl: null,
|
|
498
|
-
openedMenu: false,
|
|
499
|
-
openedEditor: false,
|
|
500
|
-
selectedElems: [],
|
|
501
|
-
labelElem: null,
|
|
502
|
-
selectionDetails: null,
|
|
503
|
-
annotation: null,
|
|
504
|
-
annotationIndex: null
|
|
505
|
-
};
|
|
506
|
-
}
|
|
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
|
-
});
|
|
523
|
-
}
|
|
524
|
-
if (this.textRef) {
|
|
525
|
-
this.adjustAnnotationsPosition();
|
|
526
|
-
this.textRef.addEventListener('scroll', this.adjustAnnotationsPosition);
|
|
527
|
-
}
|
|
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
|
|
583
|
-
},
|
|
584
|
-
video: {
|
|
585
|
-
disabled: true
|
|
586
|
-
},
|
|
587
|
-
audio: {
|
|
588
|
-
disabled: true
|
|
589
|
-
},
|
|
590
|
-
textAlign: {
|
|
591
|
-
disabled: true
|
|
592
|
-
},
|
|
593
|
-
h3: {
|
|
594
|
-
disabled: true
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
})), /*#__PURE__*/_react.default.createElement(_annotationMenu.default, {
|
|
598
|
-
anchorEl: anchorEl,
|
|
599
|
-
open: openedMenu && !disabled,
|
|
600
|
-
annotations: predefinedAnnotations,
|
|
601
|
-
isNewAnnotation: !!selectionDetails,
|
|
602
|
-
onClose: this.handleClose,
|
|
603
|
-
onDelete: this.deleteAnnotation,
|
|
604
|
-
onEdit: this.editAnnotation,
|
|
605
|
-
onWrite: this.addAnnotation,
|
|
606
|
-
onAnnotate: this.handleMenuClick
|
|
607
|
-
}), /*#__PURE__*/_react.default.createElement(_freeformEditor.default, {
|
|
608
|
-
anchorEl: this.textRef,
|
|
609
|
-
open: openedEditor && !disabled,
|
|
610
|
-
offset: topOffset,
|
|
611
|
-
value: annotation && annotation.label || '',
|
|
612
|
-
type: annotation && annotation.type,
|
|
613
|
-
onClose: this.handleClose,
|
|
614
|
-
onDelete: this.deleteAnnotation,
|
|
615
|
-
onSave: this.updateAnnotation,
|
|
616
|
-
onTypeChange: this.changeAnnotationType
|
|
617
|
-
}));
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
(0, _defineProperty2.default)(AnnotationEditor, "propTypes", {
|
|
621
|
-
text: _propTypes.default.string,
|
|
622
|
-
comment: _propTypes.default.string,
|
|
623
|
-
annotations: _propTypes.default.array,
|
|
624
|
-
predefinedAnnotations: _propTypes.default.array,
|
|
625
|
-
onChange: _propTypes.default.func.isRequired,
|
|
626
|
-
onCommentChange: _propTypes.default.func.isRequired,
|
|
627
|
-
width: _propTypes.default.number,
|
|
628
|
-
height: _propTypes.default.number,
|
|
629
|
-
maxHeight: _propTypes.default.string,
|
|
630
|
-
disabled: _propTypes.default.bool,
|
|
631
|
-
disabledMath: _propTypes.default.bool,
|
|
632
|
-
customKeys: _propTypes.default.array,
|
|
633
|
-
keypadMode: _propTypes.default.string
|
|
634
|
-
});
|
|
635
|
-
var _default = exports.default = AnnotationEditor;
|
|
636
|
-
//# sourceMappingURL=annotation-editor.js.map
|