draft-js-basic-html-editor icon indicating copy to clipboard operation
draft-js-basic-html-editor copied to clipboard

Handling line breaks within blocks

Open dburrows opened this issue 9 years ago • 2 comments

Support for line breaks is needed, especially in code blocks.

Probably best to use the meta key (e.metaKey) modifier to add line breaks instead of creating a new block.

Code blocks: '\n' should work fine if we wrap with

Paragraphs: we'll need to insert a '
' as an inline tag and convert on exit

dburrows avatar Mar 12 '16 16:03 dburrows

Should be able to do this by passing in a handleReturn function as a prop

dburrows avatar Mar 12 '16 16:03 dburrows

Code block line breaks done, just added '\n' on metakey+return when in code block type.

For breaks in HTML the quick solution of just adding <br/> tags doesn't work well enough, confuses editor no end when we have lines that just have <br/>. Will implement by concatenating sequential blocks with some kind of 'mergeWithPreviousWithBR' metadata them when this PR lands in Draft https://github.com/facebook/draft-js/pull/216

dburrows avatar Mar 22 '16 18:03 dburrows