mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-12-11 13:57:28 +08:00
using lazy mode to normalize accents
This commit is contained in:
parent
918ee8b366
commit
bec505f9fb
2 changed files with 2 additions and 22 deletions
|
|
@ -31,10 +31,10 @@ import * as Hangul from "hangul-js";
|
|||
import * as CustomTextState from "../states/custom-text-name";
|
||||
import * as FunboxList from "../test/funbox/funbox-list";
|
||||
import * as KeymapEvent from "../observables/keymap-event";
|
||||
import * as LazyMode from "../test/lazy-mode";
|
||||
import { IgnoredKeys } from "../constants/ignored-keys";
|
||||
import { ModifierKeys } from "../constants/modifier-keys";
|
||||
import { navigate } from "./route-controller";
|
||||
import { unaccentedCharacter } from "../utils/strings";
|
||||
|
||||
let dontInsertSpace = false;
|
||||
let correctShiftUsed = true;
|
||||
|
|
@ -1100,7 +1100,7 @@ $(document).on("keydown", async (event) => {
|
|||
const len: number = TestInput.input.current.length; // have to do this because prettier wraps the line and causes an error
|
||||
|
||||
const currentChar = TestWords.words.getCurrent().charAt(len).toString();
|
||||
const unaccentedChar = unaccentedCharacter(currentChar);
|
||||
const unaccentedChar = LazyMode.replaceAccents(currentChar);
|
||||
|
||||
if (unaccentedChar !== currentChar)
|
||||
//dead key + unaccented character = accented character
|
||||
|
|
|
|||
|
|
@ -149,23 +149,3 @@ export function cleanTypographySymbols(textToClean: string): string {
|
|||
(char) => specials[char as keyof typeof specials] || ""
|
||||
);
|
||||
}
|
||||
|
||||
export function unaccentedCharacter(character: string): string {
|
||||
const charMap = {
|
||||
e: ["ê", "ë"],
|
||||
a: ["â", "ã", "ä"],
|
||||
o: ["ô", "ö", "õ"],
|
||||
i: ["î", "ï", "ĩ"],
|
||||
u: ["û", "ü"],
|
||||
n: ["ñ"],
|
||||
y: ["ÿ"],
|
||||
};
|
||||
|
||||
for (const [normalizedChar, accentedChars] of Object.entries(charMap)) {
|
||||
if (accentedChars.includes(character)) {
|
||||
return normalizedChar;
|
||||
}
|
||||
}
|
||||
|
||||
return character;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue