1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-07-31 20:40:19 +02:00

Make HAS_BEFORE_INPUT_SUPPORT flag more generic. (#4118)

* Change "HAS_BEFORE_INPUT_SUPPORT" flag to more generic.

* Fix patterns and styles issues.

* Fix lint issues.

* Create dirty-rabbits-speak.md

* Update dirty-rabbits-speak.md

* Update editable.tsx

Co-authored-by: Ian Storm Taylor <ian@ianstormtaylor.com>
This commit is contained in:
kamilkazmierczak
2021-04-13 17:20:09 +02:00
committed by GitHub
parent d79267c144
commit 6a1376332b
2 changed files with 11 additions and 6 deletions

View File

@@ -0,0 +1,5 @@
---
'slate-react': patch
---
Improved detection of legacy browsers that don't have proper `beforeinput` support.

View File

@@ -21,7 +21,6 @@ import {
IS_SAFARI,
IS_EDGE_LEGACY,
IS_CHROME_LEGACY,
IS_FIREFOX_LEGACY,
} from '../utils/environment'
import { ReactEditor } from '..'
import { ReadOnlyContext } from '../hooks/use-read-only'
@@ -50,11 +49,12 @@ import {
// COMPAT: Firefox/Edge Legacy don't support the `beforeinput` event
// Chrome Legacy doesn't support `beforeinput` correctly
const HAS_BEFORE_INPUT_SUPPORT = !(
IS_FIREFOX_LEGACY ||
IS_EDGE_LEGACY ||
IS_CHROME_LEGACY
)
const HAS_BEFORE_INPUT_SUPPORT =
!IS_CHROME_LEGACY &&
!IS_EDGE_LEGACY &&
globalThis.InputEvent &&
// @ts-ignore The `getTargetRanges` property isn't recognized.
typeof globalThis.InputEvent.prototype.getTargetRanges === 'function'
/**
* `RenderElementProps` are passed to the `renderElement` handler.