mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-17 12:41:44 +02:00
disable ios compat behaviour on desktop (#1236)
This commit is contained in:
committed by
Ian Storm Taylor
parent
ca6ae43b74
commit
4fe6ac36ec
@@ -76,5 +76,6 @@ export const IS_FIREFOX = BROWSER === 'firefox'
|
||||
export const IS_SAFARI = BROWSER === 'safari'
|
||||
export const IS_IE = BROWSER === 'ie'
|
||||
|
||||
export const IS_IOS = OS === 'ios'
|
||||
export const IS_MAC = OS === 'macos'
|
||||
export const IS_WINDOWS = OS === 'windows'
|
||||
|
@@ -10,7 +10,7 @@ import Content from '../components/content'
|
||||
import Placeholder from '../components/placeholder'
|
||||
import findDOMNode from '../utils/find-dom-node'
|
||||
import findRange from '../utils/find-range'
|
||||
import { IS_CHROME, IS_MAC, IS_SAFARI } from '../constants/environment'
|
||||
import { IS_CHROME, IS_IOS, IS_MAC, IS_SAFARI } from '../constants/environment'
|
||||
|
||||
/**
|
||||
* Debug.
|
||||
@@ -77,14 +77,16 @@ function Plugin(options = {}) {
|
||||
// selection will be changed to span the existing word, so that the word is
|
||||
// replaced. But the `select` fires after the `beforeInput` event, even
|
||||
// though the native selection is updated. So we need to manually check if
|
||||
// the selection has gotten out of sync, and adjust it if so. (03/18/2017)
|
||||
const window = getWindow(e.target)
|
||||
const native = window.getSelection()
|
||||
const range = findRange(native, state)
|
||||
const hasMismatch = range && !range.equals(selection)
|
||||
// the selection has gotten out of sync, and adjust it if so. (10/16/2017)
|
||||
if (IS_IOS) {
|
||||
const window = getWindow(e.target)
|
||||
const native = window.getSelection()
|
||||
const range = findRange(native, state)
|
||||
const hasMismatch = range && !range.equals(selection)
|
||||
|
||||
if (hasMismatch) {
|
||||
change.select(range)
|
||||
if (hasMismatch) {
|
||||
change.select(range)
|
||||
}
|
||||
}
|
||||
|
||||
change.insertText(e.data)
|
||||
|
Reference in New Issue
Block a user