HumhubをSafariで使ったときの漢字確定のバグを解消する
HumhubをSafariで使うと、日本語入力でEnterキーを押すと必ず改行になる。これを解消するためにkeyCode = 229のチェックを追加した。
function inOrNearComposition(view, event) { if (view.composing) { return true } // See https://www.stum.de/2016/06/24/handling-ime-events-in-javascript/. // On Japanese input method editors (IMEs), the Enter key is used to confirm character // selection. On Safari, when Enter is pressed, compositionend and keydown events are // emitted. The keydown event triggers newline insertion, which we don't want. // This method returns true if the keydown event should be ignored. // We only ignore it once, as pressing Enter a second time *should* insert a newline. // Furthermore, the keydown event timestamp must be close to the compositionEndedAt timestamp. // This guards against the case where compositionend is triggered without the keyboard // (e.g. character confirmation may be done with the mouse), and keydown is triggered // afterwards- we wouldn't want to ignore the keydown event in this case. if (result.safari && Math.abs(event.timeStamp - view.compositionEndedAt) < 500) { view.compositionEndedAt = -2e8; return true } if (event.keyCode===229) { return true} #←これを追加する return false }