Skip to content

Commit 44360d0

Browse files
Conrad Chanmergify[bot]
andauthored
chore(highlight): Remove highlight text feature option (#638)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent eb98ddb commit 44360d0

File tree

3 files changed

+20
-39
lines changed

3 files changed

+20
-39
lines changed

src/document/DocumentAnnotator.ts

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ export default class DocumentAnnotator extends BaseAnnotator {
3030
constructor(options: Options) {
3131
super(options);
3232

33-
if (this.isFeatureEnabled('highlightText')) {
34-
this.highlightListener = new HighlightListener({ getSelection, store: this.store });
35-
}
33+
this.highlightListener = new HighlightListener({ getSelection, store: this.store });
3634

3735
this.addListener(Event.ANNOTATIONS_MODE_CHANGE, this.handleChangeMode);
3836
}
@@ -76,23 +74,21 @@ export default class DocumentAnnotator extends BaseAnnotator {
7674
managers.add(new DrawingManager({ location: pageNumber, referenceEl: pageReferenceEl }));
7775
}
7876

79-
if (this.isFeatureEnabled('highlightText')) {
80-
const textLayer = pageEl.querySelector('.textLayer') as HTMLElement;
81-
82-
if (textLayer) {
83-
managers.add(
84-
new HighlightCreatorManager({
85-
getSelection,
86-
referenceEl: textLayer,
87-
selectionChangeDelay: TEXT_LAYER_ENHANCEMENT,
88-
store: this.store,
89-
}),
90-
);
91-
}
92-
93-
managers.add(new HighlightManager({ location: pageNumber, referenceEl: pageReferenceEl }));
77+
const textLayer = pageEl.querySelector('.textLayer') as HTMLElement;
78+
79+
if (textLayer) {
80+
managers.add(
81+
new HighlightCreatorManager({
82+
getSelection,
83+
referenceEl: textLayer,
84+
selectionChangeDelay: TEXT_LAYER_ENHANCEMENT,
85+
store: this.store,
86+
}),
87+
);
9488
}
9589

90+
managers.add(new HighlightManager({ location: pageNumber, referenceEl: pageReferenceEl }));
91+
9692
managers.add(new RegionManager({ location: pageNumber, referenceEl: pageReferenceEl }));
9793

9894
const canvasLayerEl = pageEl.querySelector<HTMLElement>('.canvasWrapper');

src/document/__tests__/DocumentAnnotator-test.ts

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,16 @@ describe('DocumentAnnotator', () => {
7676
});
7777

7878
describe('constructor()', () => {
79-
test('should not create HighlightListener if feature is not enabled', () => {
80-
expect(annotator.highlightListener).toBeUndefined();
81-
});
82-
83-
test('should create HighlightListener if feature is enabled', () => {
84-
annotator = getAnnotator({ features: { highlightText: true } });
79+
test('should create HighlightListener', () => {
80+
annotator = getAnnotator();
8581

8682
expect(annotator.highlightListener).toBeInstanceOf(HighlightListener);
8783
});
8884
});
8985

9086
describe('destroy()', () => {
9187
test('should remove event handler ', () => {
92-
annotator = getAnnotator({ features: { highlightText: true } });
88+
annotator = getAnnotator();
9389

9490
jest.spyOn(annotator, 'removeListener');
9591
jest.spyOn(annotator.highlightListener as HighlightListener, 'destroy');
@@ -138,25 +134,14 @@ describe('DocumentAnnotator', () => {
138134
const managers = annotator.getPageManagers(getPage());
139135
const managerIterator = managers.values();
140136

141-
expect(managerIterator.next().value).toBeInstanceOf(PopupManager);
142-
expect(managerIterator.next().value).toBeInstanceOf(RegionManager);
143-
expect(managerIterator.next().value).toBeInstanceOf(RegionCreationManager);
144-
});
145-
146-
test('should create HighlightManager if feature is enabled', () => {
147-
annotator = getAnnotator({ features: { highlightText: true } });
148-
149-
const managers = annotator.getPageManagers(getPage());
150-
const managerIterator = managers.values();
151-
152137
expect(managerIterator.next().value).toBeInstanceOf(PopupManager);
153138
expect(managerIterator.next().value).toBeInstanceOf(HighlightManager);
154139
expect(managerIterator.next().value).toBeInstanceOf(RegionManager);
155140
expect(managerIterator.next().value).toBeInstanceOf(RegionCreationManager);
156141
});
157142

158-
test('should create HighlightCreatorManager if feature is enabled and textLayer is present', () => {
159-
annotator = getAnnotator({ features: { highlightText: true } });
143+
test('should create HighlightCreatorManager if textLayer is present', () => {
144+
annotator = getAnnotator();
160145

161146
const managers = annotator.getPageManagers(getPage(2));
162147
const managerIterator = managers.values();

test/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
}
5757

5858
/* global BoxAnnotations */
59-
var annotations = new BoxAnnotations(null, { features: { highlightText: true } });
59+
var annotations = new BoxAnnotations(null);
6060

6161
/* global Box */
6262
var preview = new Box.Preview();

0 commit comments

Comments
 (0)