1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-13 18:53:59 +02:00

Fix CJK IME(like Chinese, Japanese) double input (#4702)

* fix: resolve CJK IME double input

* fix: resolve UC mobile no input issue

* feat: add changeset

* Update .changeset/large-melons-warn.md

Co-authored-by: Dylan Schiemann <dylan@dojotoolkit.org>

* fix: more specific way to deal with browsers

Co-authored-by: Dylan Schiemann <dylan@dojotoolkit.org>
This commit is contained in:
ttitoo
2021-12-05 19:35:24 +08:00
committed by GitHub
parent c020ca23b6
commit 8bc6a46460
3 changed files with 17 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
'slate-react': minor
---
Fix CJK IME (e.g. Chinese or Japanese) double input

View File

@@ -24,6 +24,8 @@ import {
IS_FIREFOX_LEGACY,
IS_QQBROWSER,
IS_SAFARI,
IS_UC_MOBILE,
IS_WECHATBROWSER,
CAN_USE_DOM,
} from '../utils/environment'
import { ReactEditor } from '..'
@@ -772,6 +774,8 @@ export const Editable = (props: EditableProps) => {
!IS_FIREFOX_LEGACY &&
!IS_IOS &&
!IS_QQBROWSER &&
!IS_WECHATBROWSER &&
!IS_UC_MOBILE &&
event.data
) {
Editor.insertText(editor, event.data)

View File

@@ -43,6 +43,14 @@ export const IS_FIREFOX_LEGACY =
export const IS_QQBROWSER =
typeof navigator !== 'undefined' && /.*QQBrowser/.test(navigator.userAgent)
// UC mobile browser
export const IS_UC_MOBILE =
typeof navigator !== 'undefined' && /.*UCBrowser/.test(navigator.userAgent)
// Wechat browser
export const IS_WECHATBROWSER =
typeof navigator !== 'undefined' && /.*Wechat/.test(navigator.userAgent)
// Check if DOM is available as React does internally.
// https://github.com/facebook/react/blob/master/packages/shared/ExecutionEnvironment.js
export const CAN_USE_DOM = !!(