diff --git a/frontend/src/ts/utils/caret.ts b/frontend/src/ts/utils/caret.ts index 11935474a789..97435fbc105f 100644 --- a/frontend/src/ts/utils/caret.ts +++ b/frontend/src/ts/utils/caret.ts @@ -405,8 +405,15 @@ export class Caret { isLanguageRightToLeft: boolean; isDirectionReversed: boolean; }): { left: number; top: number; width: number } { + // in zen, custom or polyglot mode we need to check per-letter + const checkRtlByLetter = + Config.mode === "zen" || + Config.mode === "custom" || + Config.funbox.includes("polyglot"); const [isWordRTL, isFullMatch] = isWordRightToLeft( - options.wordText, + checkRtlByLetter + ? (options.letter.native.textContent ?? "") + : options.wordText, options.isLanguageRightToLeft, options.isDirectionReversed, ); @@ -455,7 +462,7 @@ export class Caret { // yes, this is all super verbose, but its easier to maintain and understand if (isWordRTL) { - if (isFullMatch) options.word.addClass("wordRtl"); + if (!checkRtlByLetter && isFullMatch) options.word.addClass("wordRtl"); let afterLetterCorrection = 0; if (options.side === "afterLetter") { if (this.isFullWidth()) {