diff --git a/src/BoxAnnotations.ts b/src/BoxAnnotations.ts index 8d13c73b0..f471463c7 100644 --- a/src/BoxAnnotations.ts +++ b/src/BoxAnnotations.ts @@ -1,6 +1,6 @@ import getProp from 'lodash/get'; import DocumentAnnotator from './document/DocumentAnnotator'; -import { Permissions, PERMISSIONS, Type } from './@types'; +import { IntlOptions, Permissions, PERMISSIONS, Type } from './@types'; type Annotator = { CONSTRUCTOR: typeof DocumentAnnotator; @@ -9,6 +9,10 @@ type Annotator = { VIEWERS: string[]; }; +type AnnotationsOptions = { + intl: IntlOptions; +}; + type PreviewOptions = { file?: { permissions?: Permissions; @@ -37,26 +41,30 @@ type ViewerOptions = Record; */ const ANNOTATORS: Annotator[] = [ { - NAME: 'Document', CONSTRUCTOR: DocumentAnnotator, - VIEWERS: ['Document', 'Presentation'], + NAME: 'Document', TYPES: [Type.region], + VIEWERS: ['Document', 'Presentation'], }, ]; class BoxAnnotations { annotators: Annotator[]; + annotationsOptions?: AnnotationsOptions; + viewerOptions?: ViewerOptions | null; /** * [constructor] * * @param {Object} viewerOptions - Viewer-specific annotator options + * @param {AnnotationsOptions } options - options passed to the annotations instance * @return {BoxAnnotations} BoxAnnotations instance */ - constructor(viewerOptions?: ViewerOptions) { + constructor(viewerOptions?: ViewerOptions, options?: AnnotationsOptions) { this.annotators = ANNOTATORS; + this.annotationsOptions = options; this.viewerOptions = viewerOptions; } @@ -115,6 +123,10 @@ class BoxAnnotations { return { ...annotator, TYPES: enabledTypes }; } + + getOptions(): AnnotationsOptions | undefined { + return this.annotationsOptions; + } } global.BoxAnnotations = BoxAnnotations; diff --git a/src/__tests__/BoxAnnotations-test.js b/src/__tests__/BoxAnnotations-test.js index 9a5a3f224..938d44779 100644 --- a/src/__tests__/BoxAnnotations-test.js +++ b/src/__tests__/BoxAnnotations-test.js @@ -169,4 +169,17 @@ describe('BoxAnnotations', () => { expect(loader.determineAnnotator(options, config)).toBeNull(); }); }); + + describe('getOptions', () => { + it.each([undefined, { intl: { messages: { test: 'Hello' } } }])( + 'should return the passed in options when they are %o', + mockOptions => { + loader = new BoxAnnotations(null, mockOptions); + + const options = loader.getOptions(); + + expect(options).toEqual(mockOptions); + }, + ); + }); });