mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-18 13:11:17 +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_SAFARI = BROWSER === 'safari'
|
||||||
export const IS_IE = BROWSER === 'ie'
|
export const IS_IE = BROWSER === 'ie'
|
||||||
|
|
||||||
|
export const IS_IOS = OS === 'ios'
|
||||||
export const IS_MAC = OS === 'macos'
|
export const IS_MAC = OS === 'macos'
|
||||||
export const IS_WINDOWS = OS === 'windows'
|
export const IS_WINDOWS = OS === 'windows'
|
||||||
|
@@ -10,7 +10,7 @@ import Content from '../components/content'
|
|||||||
import Placeholder from '../components/placeholder'
|
import Placeholder from '../components/placeholder'
|
||||||
import findDOMNode from '../utils/find-dom-node'
|
import findDOMNode from '../utils/find-dom-node'
|
||||||
import findRange from '../utils/find-range'
|
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.
|
* Debug.
|
||||||
@@ -77,7 +77,8 @@ function Plugin(options = {}) {
|
|||||||
// selection will be changed to span the existing word, so that the word is
|
// selection will be changed to span the existing word, so that the word is
|
||||||
// replaced. But the `select` fires after the `beforeInput` event, even
|
// replaced. But the `select` fires after the `beforeInput` event, even
|
||||||
// though the native selection is updated. So we need to manually check if
|
// 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)
|
// the selection has gotten out of sync, and adjust it if so. (10/16/2017)
|
||||||
|
if (IS_IOS) {
|
||||||
const window = getWindow(e.target)
|
const window = getWindow(e.target)
|
||||||
const native = window.getSelection()
|
const native = window.getSelection()
|
||||||
const range = findRange(native, state)
|
const range = findRange(native, state)
|
||||||
@@ -86,6 +87,7 @@ function Plugin(options = {}) {
|
|||||||
if (hasMismatch) {
|
if (hasMismatch) {
|
||||||
change.select(range)
|
change.select(range)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
change.insertText(e.data)
|
change.insertText(e.data)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user