mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-31 10:51:44 +02:00
Fix double-handling of iOS return and backspace keypresses (#1520)
Fixes #1519
This commit is contained in:
committed by
Ian Storm Taylor
parent
c9f98525b2
commit
b991d71abf
@@ -6,6 +6,7 @@ import React from 'react'
|
|||||||
import getWindow from 'get-window'
|
import getWindow from 'get-window'
|
||||||
import { Block, Inline, Text } from 'slate'
|
import { Block, Inline, Text } from 'slate'
|
||||||
|
|
||||||
|
import { IS_IOS } from '../constants/environment'
|
||||||
import EVENT_HANDLERS from '../constants/event-handlers'
|
import EVENT_HANDLERS from '../constants/event-handlers'
|
||||||
import HOTKEYS from '../constants/hotkeys'
|
import HOTKEYS from '../constants/hotkeys'
|
||||||
import Content from '../components/content'
|
import Content from '../components/content'
|
||||||
@@ -362,17 +363,20 @@ function AfterPlugin() {
|
|||||||
|
|
||||||
const { value } = change
|
const { value } = change
|
||||||
|
|
||||||
if (HOTKEYS.SPLIT_BLOCK(event)) {
|
// COMPAT: In iOS, some of these hotkeys are handled in the
|
||||||
|
// `onNativeBeforeInput` handler of the `<Content>` component in order to
|
||||||
|
// preserve native autocorrect behavior, so they shouldn't be handled here.
|
||||||
|
if (HOTKEYS.SPLIT_BLOCK(event) && !IS_IOS) {
|
||||||
return value.isInVoid
|
return value.isInVoid
|
||||||
? change.collapseToStartOfNextText()
|
? change.collapseToStartOfNextText()
|
||||||
: change.splitBlock()
|
: change.splitBlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HOTKEYS.DELETE_CHAR_BACKWARD(event)) {
|
if (HOTKEYS.DELETE_CHAR_BACKWARD(event) && !IS_IOS) {
|
||||||
return change.deleteCharBackward()
|
return change.deleteCharBackward()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HOTKEYS.DELETE_CHAR_FORWARD(event)) {
|
if (HOTKEYS.DELETE_CHAR_FORWARD(event) && !IS_IOS) {
|
||||||
return change.deleteCharForward()
|
return change.deleteCharForward()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user