Skip to content

Commit

Permalink
Fix: Enable selection of draw annotations in read-only mode
Browse files Browse the repository at this point in the history
  • Loading branch information
pramodsum committed Dec 7, 2017
1 parent ec62439 commit 006c130
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 24 deletions.
4 changes: 0 additions & 4 deletions src/Annotator.scss
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,6 @@ $tablet: 'max-width: 768px';
white-space: normal;
}

.bp-annotation-drawing-dialog {
padding: 0;
}

.bp-use-default-cursor {
cursor: default;

Expand Down
1 change: 1 addition & 0 deletions src/BoxAnnotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class BoxAnnotations {
}

const enabledTypes = this.viewerConfig.enabledTypes || [...annotatorConfig.DEFAULT_TYPES];
enabledTypes.push('draw');

// Keeping disabledTypes for backwards compatibility
const disabledTypes = this.viewerConfig.disabledTypes || [];
Expand Down
36 changes: 16 additions & 20 deletions src/doc/DocAnnotator.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,39 +425,35 @@ class DocAnnotator extends Annotator {
bindDOMListeners() {
super.bindDOMListeners();

if (this.plainHighlightEnabled || this.commentHighlightEnabled) {
this.annotatedElement.addEventListener('mouseup', this.highlightMouseupHandler);
if (this.hasTouch && this.isMobile) {
if (this.drawEnabled) {
this.annotatedElement.addEventListener('touchstart', this.drawingSelectionHandler);
}
} else {
if (this.drawEnabled) {
this.annotatedElement.addEventListener('click', this.drawingSelectionHandler);
}

if (!this.hasTouch || !this.isMobile) {
// Highlight listeners
if (this.plainHighlightEnabled || this.commentHighlightEnabled) {
this.annotatedElement.addEventListener('mouseup', this.highlightMouseupHandler);
this.annotatedElement.addEventListener('mousemove', this.getHighlightMouseMoveHandler());
}
}

// Prevent all forms of highlight annotations if annotating (or plain AND comment highlights) is disabled
if (!this.permissions.canAnnotate) {
if (!this.permissions.canAnnotate || !this.plainHighlightEnabled || !!this.commentHighlightEnabled) {
return;
}

if (this.hasTouch && this.isMobile) {
if (this.drawEnabled) {
this.annotatedElement.addEventListener('touchstart', this.drawingSelectionHandler);
}

// Highlight listeners
if (this.plainHighlightEnabled || this.commentHighlightEnabled) {
document.addEventListener('selectionchange', this.onSelectionChange);
}
document.addEventListener('selectionchange', this.onSelectionChange);
} else {
if (this.drawEnabled) {
this.annotatedElement.addEventListener('click', this.drawingSelectionHandler);
}

// Highlight listeners
if (this.plainHighlightEnabled || this.commentHighlightEnabled) {
this.annotatedElement.addEventListener('dblclick', this.highlightMouseupHandler);
this.annotatedElement.addEventListener('mousedown', this.highlightMousedownHandler);
this.annotatedElement.addEventListener('contextmenu', this.highlightMousedownHandler);
}
this.annotatedElement.addEventListener('dblclick', this.highlightMouseupHandler);
this.annotatedElement.addEventListener('mousedown', this.highlightMousedownHandler);
this.annotatedElement.addEventListener('contextmenu', this.highlightMousedownHandler);
}
}

Expand Down

0 comments on commit 006c130

Please sign in to comment.