tts: fix some direct text being skipped in tts, closes #1515 (#1543)

This commit is contained in:
Huang Xin
2025-07-06 18:13:40 +08:00
committed by GitHub
parent e8d09773a2
commit 85ac399e2c
2 changed files with 8 additions and 5 deletions
@@ -171,20 +171,23 @@ const TTSControl: React.FC<TTSControlProps> = ({ bookKey }) => {
return;
}
let ttsFromRange = range || progress.range;
if (viewSettings.ttsLocation) {
let ttsFromRange = range;
if (!ttsFromRange && viewSettings.ttsLocation) {
const { location } = progress;
const ttsCfi = viewSettings.ttsLocation;
const start = CFI.collapse(location);
const end = CFI.collapse(location, true);
if (CFI.compare(start, ttsCfi) * CFI.compare(end, ttsCfi) <= 0) {
const { index, anchor } = view.resolveCFI(ttsCfi);
const { doc } = view.renderer.getContents().find((x) => (x.index = index)) || {};
const { doc } = view.renderer.getContents().find((x) => x.index === index) || {};
if (doc) {
ttsFromRange = anchor(doc) || ttsFromRange;
ttsFromRange = anchor(doc);
}
}
}
if (!ttsFromRange) {
ttsFromRange = progress.range;
}
const primaryLang = bookData.book.primaryLanguage;