how to render data generated by text-editor

256 Views Asked by At

I am using this (Tiny) text editor in the web platform. Able to integrate basic editor also enter image description here Now problem i am facing is how to render output html data(which is in the string format) like this

enter image description here

so output data in string format is like this : enter image description here

please help me out to render this string formatted data in a separate block.

whole idea is like this i need a rich text editor like stackoverflow/medium and want to render the data in a separate location. I'm little confused about all this please help me out or suggest a better approach to handle this.

1

There are 1 best solutions below

0
RobinJoe On

There are a few options for getting content from the TinyMCE editor, and setting it in a new block.

One method could be to take the variable that has the string content you want to set in TinyMCE, and set it in the editor using the insert content API method:

tinymce.activeEditor.insertContent(<your-string-in-var>);

You could also use the execCommand API to set a block within the editor first if you need:

tinymce.activeEditor.execCommand('InsertHTML', false, '<div></div>');
tinymce.activeEditor.insertContent(<your-string-in-var>);

If you want to get the content and put it somewhere on the page, as you mention stackoverflow and medium, you can run the getContent API. Here's a guide on getting content from the editor to put somewhere else.