Skip to content

Commit

Permalink
feat(web): add KeymanWeb API for auto-correct
Browse files Browse the repository at this point in the history
Part-of: #12203
  • Loading branch information
ermshiperete committed Jan 6, 2025
1 parent 6fb5c64 commit 94cf821
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions android/KMEA/app/src/main/assets/android-host.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,11 @@ function enableSuggestions(model, suggestionType) {
[true, true, false], // 2 = SuggestionType.PREDICTIONS_WITH_CORRECTIONS
[true, true, true], // 3 = SuggestionType.PREDICTIONS_WITH_AUTO_CORRECT
];
const t = suggestionSettings[suggestionType]
const t = suggestionSettings[suggestionType]
? suggestionSettings[suggestionType] : suggestionSettings[0];
keyman.core.languageProcessor.mayPredict = t[0];
keyman.core.languageProcessor.maySuggest = t[1];
// keyman.core.languageProcessor.mayAutoCorrect = t[2];
keyman.core.languageProcessor.mayAutoCorrect = t[2];

registerModel(model);
}
Expand Down
9 changes: 9 additions & 0 deletions web/src/engine/main/src/headless/languageProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class LanguageProcessor extends EventEmitter<LanguageProcessorEventMap> {

private _mayPredict: boolean = true;
private _mayCorrect: boolean = true;
private _mayAutoCorrect: boolean = false; // initialized to false - #12767

private _state: StateChangeEnum = 'inactive';

Expand Down Expand Up @@ -402,6 +403,14 @@ export class LanguageProcessor extends EventEmitter<LanguageProcessorEventMap> {
this._mayCorrect = flag;
}

public get mayAutoCorrect() {
return this._mayAutoCorrect;
}

public set mayAutoCorrect(flag: boolean) {
this._mayAutoCorrect = flag;
}

public get wordbreaksAfterSuggestions() {
return this.configuration.wordbreaksAfterSuggestions;
}
Expand Down

0 comments on commit 94cf821

Please sign in to comment.