Skip to content

Commit

Permalink
fix: TTS readaloud SVG deep utterances (no aria-label / title), escap…
Browse files Browse the repository at this point in the history
…ability (Fixes #2629)
  • Loading branch information
danielweck committed Oct 31, 2024
1 parent b8b59e0 commit fc74d55
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 30 deletions.
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@
"node-fetch": "^3.3.2",
"proxy-agent": "^6.4.0",
"r2-lcp-js": "^1.0.41",
"r2-navigator-js": "^1.16.3",
"r2-navigator-js": "^1.16.4",
"r2-opds-js": "^1.0.44",
"r2-shared-js": "^1.0.77",
"r2-streamer-js": "^1.0.48",
Expand Down
2 changes: 2 additions & 0 deletions src/main/redux/sagas/annotation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ function* importAnnotationSet(action: annotationActions.importAnnotationSet.TAct
audioPlaybackInfo: undefined,
paginationInfo: undefined,
selectionInfo: {
textFragment: undefined,

rawBefore: textQuoteSelector?.prefix,
rawAfter: textQuoteSelector?.suffix,
rawText: textQuoteSelector?.exact,
Expand Down
34 changes: 20 additions & 14 deletions src/renderer/reader/components/Reader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1104,11 +1104,11 @@ class Reader extends React.Component<IProps, IState> {
registerKeyboardListener(
true, // listen for key up (not key down)
this.props.keyboardShortcuts.AudioPrevious,
this.onKeyboardAudioPrevious);
this.onKeyboardAudioPrevious_);
registerKeyboardListener(
true, // listen for key up (not key down)
this.props.keyboardShortcuts.AudioNext,
this.onKeyboardAudioNext);
this.onKeyboardAudioNext_);
registerKeyboardListener(
true, // listen for key up (not key down)
this.props.keyboardShortcuts.AudioPreviousAlt,
Expand Down Expand Up @@ -1156,8 +1156,8 @@ class Reader extends React.Component<IProps, IState> {
unregisterKeyboardListener(this.onKeyboardShowTOC);
unregisterKeyboardListener(this.onKeyboardCloseReader);
unregisterKeyboardListener(this.onKeyboardAudioPlayPause);
unregisterKeyboardListener(this.onKeyboardAudioPrevious);
unregisterKeyboardListener(this.onKeyboardAudioNext);
unregisterKeyboardListener(this.onKeyboardAudioPrevious_);
unregisterKeyboardListener(this.onKeyboardAudioNext_);
unregisterKeyboardListener(this.onKeyboardAudioPreviousAlt);
unregisterKeyboardListener(this.onKeyboardAudioNextAlt);
unregisterKeyboardListener(this.onKeyboardAudioStop);
Expand Down Expand Up @@ -1303,9 +1303,12 @@ class Reader extends React.Component<IProps, IState> {
};

private onKeyboardAudioPreviousAlt = () => {
this.onKeyboardAudioPrevious(true);
this.onKeyboardAudioPrevious(false, true);
};
private onKeyboardAudioPrevious = (skipSentences = false) => {
private onKeyboardAudioPrevious_ = () => {
this.onKeyboardAudioPrevious(false, false);
};
private onKeyboardAudioPrevious = (skipSentences: boolean, escape: boolean) => {
if (!this.state.shortcutEnable) {
if (DEBUG_KEYBOARD) {
console.log("!shortcutEnable (onKeyboardAudioPrevious)");
Expand All @@ -1324,14 +1327,17 @@ class Reader extends React.Component<IProps, IState> {
} else {
// const doc = document as TKeyboardDocument;
// const skipSentences = doc._keyModifierShift && doc._keyModifierAlt;
this.handleTTSPrevious(skipSentences);
this.handleTTSPrevious(skipSentences, escape);
}
};

private onKeyboardAudioNextAlt = () => {
this.onKeyboardAudioNext(true);
this.onKeyboardAudioNext(false, true);
};
private onKeyboardAudioNext_ = () => {
this.onKeyboardAudioNext(false, false);
};
private onKeyboardAudioNext = (skipSentences = false) => {
private onKeyboardAudioNext = (skipSentences: boolean, escape: boolean) => {
if (!this.state.shortcutEnable) {
if (DEBUG_KEYBOARD) {
console.log("!shortcutEnable (onKeyboardAudioNext)");
Expand All @@ -1350,7 +1356,7 @@ class Reader extends React.Component<IProps, IState> {
} else {
// const doc = document as TKeyboardDocument;
// const skipSentences = doc._keyModifierShift && doc._keyModifierAlt;
this.handleTTSNext(skipSentences);
this.handleTTSNext(skipSentences, escape);
}
};

Expand Down Expand Up @@ -2668,11 +2674,11 @@ class Reader extends React.Component<IProps, IState> {
private handleTTSResume() {
ttsResume();
}
private handleTTSNext(skipSentences = false) {
ttsNext(skipSentences);
private handleTTSNext(skipSentences: boolean, escape: boolean) {
ttsNext(skipSentences, escape);
}
private handleTTSPrevious(skipSentences = false) {
ttsPrevious(skipSentences);
private handleTTSPrevious(skipSentences: boolean, escape: boolean) {
ttsPrevious(skipSentences, escape);
}
private handleTTSPlaybackRate(speed: string) {
ttsPlaybackRate(parseFloat(speed));
Expand Down
12 changes: 6 additions & 6 deletions src/renderer/reader/components/ReaderHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ interface IBaseProps extends TranslatorProps {
handleTTSPause: () => void;
handleTTSStop: () => void;
handleTTSResume: () => void;
handleTTSPrevious: (skipSentences?: boolean) => void;
handleTTSNext: (skipSentences?: boolean) => void;
handleTTSPrevious: (skipSentences: boolean, escape: boolean) => void;
handleTTSNext: (skipSentences: boolean, escape: boolean) => void;
handleTTSPlaybackRate: (speed: string) => void;
handleTTSVoice: (voice: SpeechSynthesisVoice | null) => void;

Expand Down Expand Up @@ -613,9 +613,9 @@ export class ReaderHeader extends React.Component<IProps, IState> {
}
} else {
if (isRTL) {
this.props.handleTTSNext(e.shiftKey && e.altKey);
this.props.handleTTSNext(e.shiftKey && e.altKey && e.metaKey, e.shiftKey && e.altKey);
} else {
this.props.handleTTSPrevious(e.shiftKey && e.altKey);
this.props.handleTTSPrevious(e.shiftKey && e.altKey && e.metaKey, e.shiftKey && e.altKey);
}
}
}}
Expand Down Expand Up @@ -685,13 +685,13 @@ export class ReaderHeader extends React.Component<IProps, IState> {
if (useMO) {
this.props.handleMediaOverlaysPrevious();
} else {
this.props.handleTTSPrevious(e.shiftKey && e.altKey);
this.props.handleTTSPrevious(e.shiftKey && e.altKey && e.metaKey, e.shiftKey && e.altKey);
}
} else {
if (useMO) {
this.props.handleMediaOverlaysNext();
} else {
this.props.handleTTSNext(e.shiftKey && e.altKey);
this.props.handleTTSNext(e.shiftKey && e.altKey && e.metaKey, e.shiftKey && e.altKey);
}
}
}}
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/reader/redux/sagas/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ function converterSearchResultToHighlightHandlerState(v: ISearchResult, color =
group: "search",
color,
selectionInfo: {
textFragment: undefined,

cleanBefore: v.cleanBefore,
cleanText: v.cleanText,
cleanAfter: v.cleanAfter,
Expand Down

0 comments on commit fc74d55

Please sign in to comment.