mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-16 12:14:14 +02:00
fix placeholder to not render when composing (#1346)
This commit is contained in:
@@ -226,6 +226,8 @@ class Content extends React.Component {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
onEvent(handler, event) {
|
onEvent(handler, event) {
|
||||||
|
debug('onEvent', handler)
|
||||||
|
|
||||||
// COMPAT: Composition events can change the DOM out of under React, so we
|
// COMPAT: Composition events can change the DOM out of under React, so we
|
||||||
// increment this key to ensure that a full re-render happens. (2017/10/16)
|
// increment this key to ensure that a full re-render happens. (2017/10/16)
|
||||||
if (handler == 'onCompositionEnd') {
|
if (handler == 'onCompositionEnd') {
|
||||||
|
@@ -24,7 +24,7 @@ import { IS_CHROME, IS_SAFARI } from '../constants/environment'
|
|||||||
* @type {Function}
|
* @type {Function}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const debug = Debug('slate:core:after')
|
const debug = Debug('slate:after')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The after plugin.
|
* The after plugin.
|
||||||
@@ -741,6 +741,7 @@ function AfterPlugin() {
|
|||||||
|
|
||||||
function renderPlaceholder(props) {
|
function renderPlaceholder(props) {
|
||||||
const { editor, node } = props
|
const { editor, node } = props
|
||||||
|
if (editor.state.isComposing) return
|
||||||
if (node.kind != 'block') return
|
if (node.kind != 'block') return
|
||||||
if (!Text.isTextList(node.nodes)) return
|
if (!Text.isTextList(node.nodes)) return
|
||||||
if (node.text != '') return
|
if (node.text != '') return
|
||||||
|
@@ -18,7 +18,7 @@ import findNode from '../utils/find-node'
|
|||||||
* @type {Function}
|
* @type {Function}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const debug = Debug('slate:core:before')
|
const debug = Debug('slate:before')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The core before plugin.
|
* The core before plugin.
|
||||||
@@ -136,6 +136,11 @@ function BeforePlugin() {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (compositionCount > n) return
|
if (compositionCount > n) return
|
||||||
isComposing = false
|
isComposing = false
|
||||||
|
|
||||||
|
// HACK: we need to re-render the editor here so that it will update its
|
||||||
|
// placeholder in case one is currently rendered. This should be handled
|
||||||
|
// differently ideally, in a less invasive way?
|
||||||
|
editor.setState({ isComposing: false })
|
||||||
})
|
})
|
||||||
|
|
||||||
debug('onCompositionEnd', { event })
|
debug('onCompositionEnd', { event })
|
||||||
@@ -153,6 +158,11 @@ function BeforePlugin() {
|
|||||||
isComposing = true
|
isComposing = true
|
||||||
compositionCount++
|
compositionCount++
|
||||||
|
|
||||||
|
// HACK: we need to re-render the editor here so that it will update its
|
||||||
|
// placeholder in case one is currently rendered. This should be handled
|
||||||
|
// differently ideally, in a less invasive way?
|
||||||
|
editor.setState({ isComposing: true })
|
||||||
|
|
||||||
debug('onCompositionStart', { event })
|
debug('onCompositionStart', { event })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user