facebookarchive / draft-js

A React framework for building text editors.
https://draftjs.org/
MIT License
22.57k stars 2.64k forks source link

Modifier.replaceWithFragment doesn't keep block type when fragment has only one content block #1868

Open marconi1992 opened 6 years ago

marconi1992 commented 6 years ago

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

API Bug:

Passing a fragment with only a ContentBlock that has a type different to unstyled to Modifier.replaceWithFragment the type is lost in the new ContentState

Example in JSFiddle

UAT Bug:

Pasting only an HTML element the block type is not preserved.

Steps to reproduce:

What is the expected behavior?

Keep the block type.

Which versions of Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of Draft.js?

version: 0.10.5 browser: It's not brower issue, the bug is happening in the helper.

colinjeanne commented 6 years ago

This is a dupe of https://github.com/facebook/draft-js/issues/1511