mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-04-21 13:51:59 +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:
parent
d79267c144
commit
6a1376332b
5
.changeset/dirty-rabbits-speak.md
Normal file
5
.changeset/dirty-rabbits-speak.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
'slate-react': patch
|
||||
---
|
||||
|
||||
Improved detection of legacy browsers that don't have proper `beforeinput` support.
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user