@@ -34,6 +34,7 @@ export type Options = {
3434 } ;
3535 fileOptions ?: FileOptions ;
3636 hasTouch ?: boolean ;
37+ initialColor ?: string ;
3738 initialMode ?: store . Mode ;
3839 intl : IntlOptions ;
3940 locale ?: string ;
@@ -60,7 +61,17 @@ export default class BaseAnnotator extends EventEmitter {
6061
6162 store : store . AppStore ;
6263
63- constructor ( { apiHost, container, features = { } , file, fileOptions, initialMode, intl, token } : Options ) {
64+ constructor ( {
65+ apiHost,
66+ container,
67+ features = { } ,
68+ file,
69+ fileOptions,
70+ initialColor,
71+ initialMode,
72+ intl,
73+ token,
74+ } : Options ) {
6475 super ( ) ;
6576
6677 const fileOptionsValue = fileOptions ?. [ file . id ] ;
@@ -72,7 +83,7 @@ export default class BaseAnnotator extends EventEmitter {
7283 annotations : {
7384 activeId : fileOptionsValue ?. annotations ?. activeId ?? null ,
7485 } ,
75- common : { mode : initialMode } ,
86+ common : { color : initialColor , mode : initialMode } ,
7687 options : {
7788 features,
7889 fileId : file . id ,
@@ -93,6 +104,7 @@ export default class BaseAnnotator extends EventEmitter {
93104 this . addListener ( LegacyEvent . SCALE , this . handleScale ) ;
94105 this . addListener ( Event . ACTIVE_SET , this . handleSetActive ) ;
95106 this . addListener ( Event . ANNOTATION_REMOVE , this . handleRemove ) ;
107+ this . addListener ( Event . COLOR_SET , this . handleColorSet ) ;
96108 this . addListener ( Event . VISIBLE_SET , this . handleSetVisible ) ;
97109
98110 // Load any required data at startup
@@ -155,6 +167,10 @@ export default class BaseAnnotator extends EventEmitter {
155167 this . store . dispatch ( store . setActiveAnnotationIdAction ( annotationId ) ) ;
156168 }
157169
170+ public setColor ( color : string ) : void {
171+ this . store . dispatch ( store . setColorAction ( color ) ) ;
172+ }
173+
158174 public setVisibility ( visibility : boolean ) : void {
159175 if ( ! this . containerEl ) {
160176 return ;
@@ -195,6 +211,10 @@ export default class BaseAnnotator extends EventEmitter {
195211 this . setVisibility ( visibility ) ;
196212 } ;
197213
214+ protected handleColorSet = ( color : string ) : void => {
215+ this . setColor ( color ) ;
216+ } ;
217+
198218 protected hydrate ( ) : void {
199219 // Redux dispatch method signature doesn't seem to like async actions
200220 this . store . dispatch < any > ( store . fetchAnnotationsAction ( ) ) ; // eslint-disable-line @typescript-eslint/no-explicit-any
0 commit comments