1

I'm trying to make markdown editor with auto resizable textarea.

I'm using marked library. But when I change value with value={marked(this.props.text)}, it outputs like: <p>Hello</p>

I can't even use dangerouslySetInnerHTML or innerHTML property since textarea doesn't render HTML.

When I use elements such as p, It doesn't look like textarea.

Can someone give me a hint?

LuckyTuvshee
  • 1,166
  • 8
  • 16

1 Answers1

0

I've solved it, see this post

In other to make the element look like textarea, you should translate a carriage return into a br html tag.


In this post:

You could just apply CSS white-space:pre on the element, exactly like the HTML textarea element is internally doing:

<span style="white-space:pre">your  text  \n will \n be \n on multiple \n lines</span>

Also read this comment - about carriage return

LuckyTuvshee
  • 1,166
  • 8
  • 16