···5353 // `なno|` will still convert to `なの` instead of `なんお` without issue since the `no` -> `の` conversion will be found before `n` -> `ん` and `o` -> `お`.
5454 // `nn|` will still convert to `ん` instead of `んん` since `nn` -> `ん` will be found before `n` -> `ん`.
5555 // If the user pastes in a long string of `n` such as `nnnnn|` it should leave the last `n` and convert to `んんn`
5656- if (text[prevSelectionStart - 1] === 'n' && text.slice(0, prevSelectionStart - 1).replaceAll('nn', '').at(-1) !== 'n') {
5656+ const textLowered = text.toLowerCase();
5757+ if (textLowered[prevSelectionStart - 1] === 'n' && textLowered.slice(0, prevSelectionStart - 1).replaceAll('nn', '').at(-1) !== 'n') {
5858+ const n = text.slice(prevSelectionStart - 1, prevSelectionStart);
5759 const beforeN = text.slice(0, prevSelectionStart - 1);
5860 const afterN = text.slice(prevSelectionStart);
5959- kanaString = convertToKana(beforeN) + 'n' + convertToKana(afterN);
6060- } else if (text.slice(prevSelectionStart - 2, prevSelectionStart) === 'ny') {
6161+ kanaString = convertToKana(beforeN) + n + convertToKana(afterN);
6262+ } else if (textLowered.slice(prevSelectionStart - 2, prevSelectionStart) === 'ny') {
6363+ const ny = text.slice(prevSelectionStart - 2, prevSelectionStart);
6164 const beforeN = text.slice(0, prevSelectionStart - 2);
6265 const afterN = text.slice(prevSelectionStart);
6363- kanaString = convertToKana(beforeN) + 'ny' + convertToKana(afterN);
6666+ kanaString = convertToKana(beforeN) + ny + convertToKana(afterN);
6467 } else {
6568 kanaString = convertToKana(text);
6669 }