react-quill icon indicating copy to clipboard operation
react-quill copied to clipboard

How to disable newlines (Act as input) in react-quill 2.0.0

Open unreleased opened this issue 2 years ago • 2 comments

Hi there,

I've googled and googled but really can't see a way to disable newlines/enters for ReactQuill. I see plenty of posts for regular Quill but I'm not too sure how different the APIs/functionalities are.

Unfortunately, when I use my component like below.

<ReactQuill
  onKeyUp={(e) => handleKeyDown(e)}
  formats={["header"]}
  modules={{
    toolbar: false,
  }}
  ref={props.quill}
/>
const handleKeyDown = (e) => {
  if (e.keyCode === 13) {
    e.preventDefault()
  }
}

I call handleKeyDown(e) which gets triggered but when calling e.preventDefault() it does not work for the enter key (It's called and definitely reached!). However, it will work for any other key and if I only call e.preventDefault() it will stop every key except the enter button.

Any help as to why this doesn't work would be greatly appreciated.

unreleased avatar Dec 29 '22 21:12 unreleased

up

MarianCN avatar Apr 02 '23 21:04 MarianCN

up

alexjidras avatar Sep 01 '23 11:09 alexjidras