Skip to content

Commit

Permalink
Enable configuration for auto-turnoff of note, text, and image tools
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtcode committed Nov 18, 2024
1 parent 4643dcc commit e62baf1
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/common/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ class Reader {
hyphenate: options.hyphenate,
showAnnotations: options.showAnnotations !== undefined ? options.showAnnotations : true, // show/hide annotations in views
useDarkModeForContent: options.useDarkModeForContent !== undefined ? options.useDarkModeForContent : true,
autoDisableNoteTool: options.autoDisableNoteTool !== undefined ? options.autoDisableNoteTool : true,
autoDisableTextTool: options.autoDisableTextTool !== undefined ? options.autoDisableTextTool : true,
autoDisableImageTool: options.autoDisableImageTool !== undefined ? options.autoDisableImageTool : true,
textSelectionAnnotationMode: options.textSelectionAnnotationMode || 'highlight',
colorScheme: options.colorScheme,
tool: this._tools['pointer'], // Must always be a reference to one of this._tools objects
Expand Down Expand Up @@ -610,6 +613,18 @@ class Reader {
this._updateState({ useDarkModeForContent: use });
}

setAutoDisableNoteTool(autoDisable) {
this._updateState({ autoDisableNoteTool: autoDisable });
}

setAutoDisableTextTool(autoDisable) {
this._updateState({ autoDisableTextTool: autoDisable });
}

setAutoDisableImageTool(autoDisable) {
this._updateState({ autoDisableImageTool: autoDisable });
}

setColorScheme(colorScheme) {
this._updateState({ colorScheme });
}
Expand Down Expand Up @@ -803,7 +818,11 @@ class Reader {
if (select) {
this.setSelectedAnnotations([annotation.id], true);
}
if (['note', 'text'].includes(annotation.type)) {
if (
annotation.type === 'note' && this._state.autoDisableNoteTool
|| annotation.type === 'text' && this._state.autoDisableTextTool
|| annotation.type === 'image' && this._state.autoDisableImageTool
) {
this.setTool({ type: 'pointer' });
}
return annotation;
Expand Down

0 comments on commit e62baf1

Please sign in to comment.