react-contenteditable
react-contenteditable copied to clipboard
Disable multiline Input
Is it possible to disable mulitline Input?
Meaning, no breaks. And when the user presses return while typing, nothing happens.
You can just add onKeyDown={e => e.keyCode === 13 && e.preventDefault()} to your ContentEditable component.
@ericnmurphy but this doesn't prevent someone pasting in line breaks, or does it?
I use this code to keep single line
onChange={e => {
// strip html
const node = document.createElement('div')
node.innerHTML = e.target.value
const value = node.innerText.replace(/(?:\r\n|\r|\n)/g, ' ')
this.onChange(value)
}}