1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-19 05:31:56 +02:00

add on blur logic to content component

This commit is contained in:
Ian Storm Taylor
2016-06-28 16:13:50 -07:00
parent 753b3f8074
commit d5f0a55515

View File

@@ -64,6 +64,22 @@ class Content extends React.Component {
this.props.onBeforeInput(e)
}
/**
* On blur, update the selection to be not focused.
*
* @param {Event} e
*/
onBlur(e) {
if (this.tmp.isCopying) return
let { state } = this.props
let { document, selection } = state
selection = selection.merge({ isFocused: false })
state = state.merge({ selection })
this.onChange(state)
}
/**
* On change, bubble up.
*
@@ -296,6 +312,7 @@ class Content extends React.Component {
contentEditable suppressContentEditableWarning
style={style}
onBeforeInput={e => this.onBeforeInput(e)}
onBlur={e => this.onBlur(e)}
onCopy={e => this.onCopy(e)}
onCut={e => this.onCut(e)}
onKeyDown={e => this.onKeyDown(e)}