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

fix: chinese input double in qq browser (#4452)

* fix: chinese input double in qq browser

* add changeset

* update changeset
This commit is contained in:
Dylan Schiemann
2021-08-13 04:46:06 -07:00
committed by GitHub
parent 834ce3483d
commit 935b3a79d6
3 changed files with 17 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
'slate-react': patch
---
double ime fix for qq browser

View File

@@ -21,6 +21,7 @@ import {
IS_CHROME, IS_CHROME,
IS_FIREFOX, IS_FIREFOX,
IS_FIREFOX_LEGACY, IS_FIREFOX_LEGACY,
IS_QQBROWSER,
IS_SAFARI, IS_SAFARI,
} from '../utils/environment' } from '../utils/environment'
import { ReactEditor } from '..' import { ReactEditor } from '..'
@@ -714,7 +715,13 @@ export const Editable = (props: EditableProps) => {
// aren't correct and never fire the "insertFromComposition" // aren't correct and never fire the "insertFromComposition"
// type that we need. So instead, insert whenever a composition // type that we need. So instead, insert whenever a composition
// ends since it will already have been committed to the DOM. // ends since it will already have been committed to the DOM.
if (!IS_SAFARI && !IS_FIREFOX_LEGACY && !IS_IOS && event.data) { if (
!IS_SAFARI &&
!IS_FIREFOX_LEGACY &&
!IS_IOS &&
!IS_QQBROWSER &&
event.data
) {
Editor.insertText(editor, event.data) Editor.insertText(editor, event.data)
} }
} }

View File

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