mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-21 14:41:23 +02:00
add on blur logic to content component
This commit is contained in:
@@ -64,6 +64,22 @@ class Content extends React.Component {
|
|||||||
this.props.onBeforeInput(e)
|
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.
|
* On change, bubble up.
|
||||||
*
|
*
|
||||||
@@ -296,6 +312,7 @@ class Content extends React.Component {
|
|||||||
contentEditable suppressContentEditableWarning
|
contentEditable suppressContentEditableWarning
|
||||||
style={style}
|
style={style}
|
||||||
onBeforeInput={e => this.onBeforeInput(e)}
|
onBeforeInput={e => this.onBeforeInput(e)}
|
||||||
|
onBlur={e => this.onBlur(e)}
|
||||||
onCopy={e => this.onCopy(e)}
|
onCopy={e => this.onCopy(e)}
|
||||||
onCut={e => this.onCut(e)}
|
onCut={e => this.onCut(e)}
|
||||||
onKeyDown={e => this.onKeyDown(e)}
|
onKeyDown={e => this.onKeyDown(e)}
|
||||||
|
Reference in New Issue
Block a user