1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-30 10:29:48 +02:00

Fix double-handling of iOS return and backspace keypresses (#1520)

Fixes #1519
This commit is contained in:
Ryan Grove
2018-01-10 22:26:42 -08:00
committed by Ian Storm Taylor
parent c9f98525b2
commit b991d71abf

View File

@@ -6,6 +6,7 @@ import React from 'react'
import getWindow from 'get-window'
import { Block, Inline, Text } from 'slate'
import { IS_IOS } from '../constants/environment'
import EVENT_HANDLERS from '../constants/event-handlers'
import HOTKEYS from '../constants/hotkeys'
import Content from '../components/content'
@@ -362,17 +363,20 @@ function AfterPlugin() {
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
? change.collapseToStartOfNextText()
: change.splitBlock()
}
if (HOTKEYS.DELETE_CHAR_BACKWARD(event)) {
if (HOTKEYS.DELETE_CHAR_BACKWARD(event) && !IS_IOS) {
return change.deleteCharBackward()
}
if (HOTKEYS.DELETE_CHAR_FORWARD(event)) {
if (HOTKEYS.DELETE_CHAR_FORWARD(event) && !IS_IOS) {
return change.deleteCharForward()
}