-
Notifications
You must be signed in to change notification settings - Fork 105
/
BoxAnnotations.js
54 lines (49 loc) · 1.39 KB
/
BoxAnnotations.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import DocAnnotator from './doc/DocAnnotator';
import ImageAnnotator from './image/ImageAnnotator';
import { TYPES } from './annotationConstants';
const ANNOTATORS = [
{
NAME: 'Document',
CONSTRUCTOR: DocAnnotator,
VIEWER: ['Document', 'Presentation'],
TYPE: [TYPES.point, TYPES.highlight, TYPES.draw]
},
{
NAME: 'Image',
CONSTRUCTOR: ImageAnnotator,
VIEWER: ['Image', 'MultiImage'],
TYPE: [TYPES.point]
}
];
class BoxAnnotations {
/**
* [constructor]
*
* @return {BoxAnnotations} BoxAnnotations instance
*/
constructor() {
this.annotators = ANNOTATORS;
}
/**
* Returns the available annotators
*
* @return {Array} List of supported annotators
*/
getAnnotators() {
return Array.isArray(this.annotators) ? this.annotators : [];
}
/**
* Chooses a annotator based on viewer.
*
* @param {Object} viewer - Current preview viewer
* @param {Array} [disabledAnnotators] - List of disabled annotators
* @return {Object} The annotator to use
*/
determineAnnotator(viewer, disabledAnnotators = []) {
return this.annotators.find(
(annotator) => !disabledAnnotators.includes(annotator.NAME) && annotator.VIEWER.includes(viewer)
);
}
}
global.BoxAnnotations = BoxAnnotations;
export default BoxAnnotations;