react-draft-wysiwyg: textAlign is not restored

When initializing the Editor with some previously saved content, eg:

{"blocks":[
  {"key":"78mel",
  "text":"Lorem ipsum duis vulputate erat vel tortor ornare lobortis. In tempus aliquet elit nec porttitor.",
  "type":"unstyled",
  "depth":0,
  "inlineStyleRanges":[],
  "entityRanges":[],
  "data":{"textAlign":"center"}}
],"entityMap":{}}

The text alignment is not restored. All other properties are restored correctly (bold, italic, list …), but textAlign (here center but possibly right or justify) are not restored.

Here’s the full code of my component: https://gist.github.com/sylvainbx/e281f0596617b6119559f05388318e7d

I’m using react-draft-wysiwyg 1.9.0 and draft-js 0.10.0. Any suggestions are welcome 😃

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Comments: 17 (5 by maintainers)

Most upvoted comments

I was having the same issue using the default convertFromHTML (from Draft.js), but after switching to the recommended package: https://github.com/jpuri/html-to-draftjs and using htmlToDraft instead solved my issue.

I will check this again. Thanks for reporting @cesaracortes