Skip to content
Snippets Groups Projects
Commit 0c1ca8fe authored by Alf Eaton's avatar Alf Eaton Committed by Yannis Barlas
Browse files

Fire onBlur event

parent f65a5351
No related branches found
No related tags found
No related merge requests found
......@@ -28,8 +28,17 @@ class Editor extends React.Component {
}),
attributes: {
class: classnames(baseClasses.ProseMirror, classes.ProseMirror)
},
handleDOMEvents: {
blur: this.props.onBlur ? view => {
this.props.onBlur(view.state.doc.content)
} : null
}
})
if (this.props.autoFocus) {
this.view.focus()
}
}
dispatchTransaction = transaction => {
......
......@@ -26,7 +26,7 @@ const serializer = schema => {
class HtmlEditor extends React.Component {
componentWillMount () {
const { value, onChange, options } = this.props
const { value, onChange, onBlur, options } = this.props
const { schema } = options
const parse = parser(schema)
......@@ -37,6 +37,10 @@ class HtmlEditor extends React.Component {
this.onChange = debounce(value => {
onChange(serialize(value))
}, 1000, { maxWait: 5000 })
this.onBlur = value => {
onBlur(serialize(value))
}
}
render () {
......@@ -50,6 +54,7 @@ class HtmlEditor extends React.Component {
placeholderClassName={placeholderClassName}
title={title}
onChange={this.onChange}
onBlur={this.onBlur}
/>
)
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment