fix(anki): regenerate sentence furigana from the final sentence (#268)

This commit is contained in:
2026-09-22 21:43:19 -07:00
committed by GitHub
parent b0fb39a8f5
commit 7c161723cd
16 changed files with 489 additions and 18 deletions
+10
View File
@@ -15,6 +15,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { generateSentenceFurigana } from './core/services/tokenizer/sentence-furigana';
import {
app,
BrowserWindow,
@@ -5131,6 +5132,13 @@ function createMainWindow(): BrowserWindow {
return window;
}
function generateMiningSentenceFurigana(
text: string,
highlightedText?: string,
): Promise<string | null> {
return generateSentenceFurigana(text, highlightedText, getYomitanParserRuntimeDeps(), logger);
}
function initializeOverlayRuntime(): void {
initializeOverlayRuntimeHandler();
if (!(appState.initialArgs && isHeadlessInitialCommand(appState.initialArgs))) {
@@ -5140,6 +5148,7 @@ function initializeOverlayRuntime(): void {
appState.ankiIntegration?.setKnownWordCacheUpdatedCallback(refreshCurrentSubtitleAnnotations);
appState.ankiIntegration?.setSubtitleMiningContextConsumer(consumePendingSubtitleMiningContext);
appState.ankiIntegration?.setMediaTimingReviewCallback(mediaTimingReviewRuntime.requestReview);
appState.ankiIntegration?.setSentenceFuriganaGenerator(generateMiningSentenceFurigana);
syncOverlayMpvSubtitleSuppression();
}
@@ -6015,6 +6024,7 @@ const { registerIpcRuntimeHandlers } = composeIpcRuntimeHandlers({
appState.ankiIntegration?.setMediaTimingReviewCallback(
mediaTimingReviewRuntime.requestReview,
);
appState.ankiIntegration?.setSentenceFuriganaGenerator(generateMiningSentenceFurigana);
},
getKnownWordCacheStatePath: () => path.join(USER_DATA_PATH, 'known-words-cache.json'),
getCachedMediaPath: (currentVideoPath, kind) =>