mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-11 01:33:58 +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:
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_SAFARI,
|
||||||
IS_EDGE_LEGACY,
|
IS_EDGE_LEGACY,
|
||||||
IS_CHROME_LEGACY,
|
IS_CHROME_LEGACY,
|
||||||
IS_FIREFOX_LEGACY,
|
|
||||||
} from '../utils/environment'
|
} from '../utils/environment'
|
||||||
import { ReactEditor } from '..'
|
import { ReactEditor } from '..'
|
||||||
import { ReadOnlyContext } from '../hooks/use-read-only'
|
import { ReadOnlyContext } from '../hooks/use-read-only'
|
||||||
@@ -50,11 +49,12 @@ import {
|
|||||||
|
|
||||||
// COMPAT: Firefox/Edge Legacy don't support the `beforeinput` event
|
// COMPAT: Firefox/Edge Legacy don't support the `beforeinput` event
|
||||||
// Chrome Legacy doesn't support `beforeinput` correctly
|
// Chrome Legacy doesn't support `beforeinput` correctly
|
||||||
const HAS_BEFORE_INPUT_SUPPORT = !(
|
const HAS_BEFORE_INPUT_SUPPORT =
|
||||||
IS_FIREFOX_LEGACY ||
|
!IS_CHROME_LEGACY &&
|
||||||
IS_EDGE_LEGACY ||
|
!IS_EDGE_LEGACY &&
|
||||||
IS_CHROME_LEGACY
|
globalThis.InputEvent &&
|
||||||
)
|
// @ts-ignore The `getTargetRanges` property isn't recognized.
|
||||||
|
typeof globalThis.InputEvent.prototype.getTargetRanges === 'function'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `RenderElementProps` are passed to the `renderElement` handler.
|
* `RenderElementProps` are passed to the `renderElement` handler.
|
||||||
|
Reference in New Issue
Block a user