I am currently coding on front-end editing in wordpress. The outcome should be evernote-like editing using wordpress posts.
The Wordpress database stores markup without paragraphs and adds them on delivering. When you do initially set the tinymce content in php:
wp_editor( $content, $editor_id,$settings );
The content is written (without paragraphs) in the textarea, tinymce fetches this content on init and writes it after some PROCESSING in the visual editor.
To set the content I fetched from the wordpress database dynamically I use
but unfortunately this seems to bypass the PROCESSING done on tinymce init which results in lost of line breaks and paragraphs. The Processing seems to be the addition of linebreaks and paragraphs.
My current workaround is to set the content to wordpress to the worpress text-editor and then switch back to visual editor, since this seems to trigger the PROCESSING of breaks and paragraphs:
jQuery( "#myeditor-html" ).trigger( "click" ); jQuery('#textarea_id').val(content); jQuery( "#myeditor-tmce" ).trigger( "click" );
I really don't like this solution because
- Wordpress doesn't recommend switching if you love your visual content
- I would like to disable the 'quicktags' text-editor later on
I really can't find out what script is executed on jQuery( "#myeditor-tmce" ).trigger( "click" ).
Can anyone figure out the mentioned PROCESSING?