mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-18 23:07:02 +08:00
fix(electron): respect locale for spellchecker (#8844)
may fix #8837. fix AF-1712 MacOS automatically do spellcheck based on given text. This only works for Win/Linux. 
This commit is contained in:
@@ -4,6 +4,8 @@ import {
|
||||
GlobalStateService,
|
||||
} from '@toeverything/infra';
|
||||
|
||||
import { DesktopApiService } from '../desktop-api';
|
||||
import { I18n } from '../i18n';
|
||||
import { UserDBService } from '../userspace';
|
||||
import { EditorSetting } from './entities/editor-setting';
|
||||
import { CurrentUserDBEditorSettingProvider } from './impls/user-db';
|
||||
@@ -25,5 +27,9 @@ export function configureEditorSettingModule(framework: Framework) {
|
||||
}
|
||||
|
||||
export function configureSpellCheckSettingModule(framework: Framework) {
|
||||
framework.service(SpellCheckSettingService, [GlobalStateService]);
|
||||
framework.service(SpellCheckSettingService, [
|
||||
GlobalStateService,
|
||||
I18n,
|
||||
DesktopApiService,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -2,14 +2,31 @@ import type {
|
||||
SpellCheckStateKey,
|
||||
SpellCheckStateSchema,
|
||||
} from '@affine/electron/main/shared-state-schema';
|
||||
import type { Language } from '@affine/i18n';
|
||||
import type { GlobalStateService } from '@toeverything/infra';
|
||||
import { LiveData, Service } from '@toeverything/infra';
|
||||
|
||||
import type { DesktopApiService } from '../../desktop-api';
|
||||
import type { I18n } from '../../i18n';
|
||||
|
||||
const SPELL_CHECK_SETTING_KEY: SpellCheckStateKey = 'spellCheckState';
|
||||
|
||||
export class SpellCheckSettingService extends Service {
|
||||
constructor(private readonly globalStateService: GlobalStateService) {
|
||||
constructor(
|
||||
private readonly globalStateService: GlobalStateService,
|
||||
private readonly i18n: I18n,
|
||||
private readonly desktopApiService: DesktopApiService
|
||||
) {
|
||||
super();
|
||||
|
||||
// this will be called even during initialization
|
||||
this.i18n.i18next.on('languageChanged', (language: Language) => {
|
||||
this.desktopApiService.handler.ui
|
||||
.onLanguageChange(language)
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
enabled$ = LiveData.from(
|
||||
|
||||
Reference in New Issue
Block a user