-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore: Bundling Annotators separately in annotations.js (#75)
- Determines which annotator to initialize based on the viewer provided in options - Bundles the annotators separately to reduce the size of preview.js - Only loads annotations.js if ?showAnnotations=true and not a shared link - Moving showAnnotate() and other basic annotation methods into BaseViewer - Triggering annotations load on 'load' event
- Loading branch information
Showing
22 changed files
with
871 additions
and
765 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import DocAnnotator from './doc/DocAnnotator'; | ||
import ImageAnnotator from './image/ImageAnnotator'; | ||
|
||
const ANNOTATORS = [ | ||
{ | ||
NAME: 'Document', | ||
CONSTRUCTOR: DocAnnotator, | ||
VIEWER: ['Document', 'Presentation'], | ||
TYPE: ['point', 'highlight'] | ||
}, | ||
{ | ||
NAME: 'Image', | ||
CONSTRUCTOR: ImageAnnotator, | ||
VIEWER: ['Image'], | ||
TYPE: ['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 file extension. | ||
* | ||
* @param {Object} file - Box file | ||
* @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; |
Oops, something went wrong.