Skip to content

Commit

Permalink
feat(annotations): Add annotator create event (#1219)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingze authored Jun 10, 2020
1 parent 178f245 commit e9d21a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib/viewers/BaseViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,8 @@ class BaseViewer extends EventEmitter {

this.annotator = new this.annotatorConf.CONSTRUCTOR(annotatorOptions);

this.emit('annotator_create', this.annotator);

if (this.annotatorPromiseResolver) {
this.annotatorPromiseResolver();
}
Expand Down
8 changes: 8 additions & 0 deletions src/lib/viewers/__tests__/BaseViewer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,14 @@ describe('lib/viewers/BaseViewer', () => {
expect(intl.createAnnotatorIntl).to.be.called;
expect(base.createAnnotatorOptions).to.be.calledWith(sinon.match(annotationsOptions));
});

it('should emit annotator_create event', () => {
sandbox.stub(base, 'areAnnotationsEnabled').returns(true);

base.createAnnotator();

expect(base.emit).to.be.calledWith('annotator_create', annotatorMock);
});
});

describe('initAnnotations()', () => {
Expand Down

0 comments on commit e9d21a0

Please sign in to comment.