0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 07:13:08 -05:00

Fix handling of Japanese IME input

With the modern keyboard events, the Backspace/Enter handlers were being
triggered even when they were part of an IME composition, which broke
the native IME handling. We now ignore all keyboard events that are part
of composition to avoid this issue.
This commit is contained in:
Neil Jenkins 2024-02-01 21:24:11 +11:00
parent b415665d01
commit 73e9d083dd

View file

@ -18,7 +18,9 @@ import { moveRangeBoundariesDownTree } from '../range/Boundaries';
// --- // ---
const _onKey = function (this: Squire, event: KeyboardEvent): void { const _onKey = function (this: Squire, event: KeyboardEvent): void {
if (event.defaultPrevented) { // Ignore key events where event.isComposing, to stop us from blatting
// Kana-Kanji conversion
if (event.defaultPrevented || event.isComposing) {
return; return;
} }
@ -52,9 +54,6 @@ const _onKey = function (this: Squire, event: KeyboardEvent): void {
this._keyHandlers[key](this, event, range); this._keyHandlers[key](this, event, range);
} else if ( } else if (
!range.collapsed && !range.collapsed &&
// !event.isComposing stops us from blatting Kana-Kanji conversion in
// Safari
!event.isComposing &&
!event.ctrlKey && !event.ctrlKey &&
!event.metaKey && !event.metaKey &&
key.length === 1 key.length === 1