Skip to content

Commit

Permalink
feat(annotations): Set region as default mode if discover FF is on
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingze Xiao committed Sep 15, 2020
1 parent 46aad4f commit 8c2a011
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/lib/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,8 @@ class Preview extends EventEmitter {

this.options.showAnnotationsHighlightText = !!options.showAnnotationsHighlightText;

this.options.enableAnnotationsDiscoverability = !!options.enableAnnotationsDiscoverability;

// Enable or disable hotkeys
this.options.useHotkeys = options.useHotkeys !== false;

Expand Down
7 changes: 6 additions & 1 deletion src/lib/viewers/BaseViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,7 @@ class BaseViewer extends EventEmitter {
const annotatorOptions = this.createAnnotatorOptions({
annotator: this.annotatorConf,
features: options && options.features,
initialMode: this.options.enableAnnotationsDiscoverability ? AnnotationMode.REGION : AnnotationMode.NONE,
intl: (options && options.intl) || intlUtil.createAnnotatorIntl(),
modeButtons: ANNOTATION_BUTTONS,
});
Expand Down Expand Up @@ -1082,7 +1083,11 @@ class BaseViewer extends EventEmitter {
*/
handleAnnotationControlsClick({ mode }) {
const nextMode = this.annotationControlsFSM.transition(AnnotationInput.CLICK, mode);
this.annotator.toggleAnnotationMode(nextMode);
this.annotator.toggleAnnotationMode(
this.options.enableAnnotationsDiscoverability && nextMode === AnnotationMode.NONE
? AnnotationMode.REGION
: nextMode,
);
this.annotationControls.setMode(nextMode);
}

Expand Down

0 comments on commit 8c2a011

Please sign in to comment.