can you load up a text area with html but display the wysiwyg formatted output (im using tinymce)

StackOverflow https://stackoverflow.com/questions/1225501

  •  22-07-2019
  •  | 
  •  

Question

i have setup tinymce in a webpage for users to generate html data that i am putting on my website.

the issue is that i have existing html pages that i want to use as a starter.

I want to have the first time they go to tinymce page, it prepopulates the textarea with the wysiwyg view of the html file on my local disk.

is there any way to take an html stream and have it prepopulate a textarea so it shows the wysiwyg instead of the html. i need to ensure that this conversion doesn't lose any formatting.

Was it helpful?

Solution

When set up to load onto an existing textarea, TinyMCE will display the HTML already loaded into that textarea. Load the HTML into the textarea on the server side. For example (pseudocode):

echo "<textarea class=\"text\">"
echo html_encode( html_stream )
echo "</textarea>"

And the JavsaScript:

<script type="text/javascript">
tinyMCE.init({
    mode : "specific_textareas",
    editor_selector : "text",
});
</script>

OTHER TIPS

I have built a custom CMS with TinyMCE which does essentially what you describe. I have found when I prepopulate the textarea that TinyMCE displays as WYSIWYG by default.

The HTML can be read from file on disk, or stored elsewhere.

Have you actually tried yet?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top