Support » Plugin: TinyMCE Advanced » Visual editor changes HTML formatting

  • fotkin

    (@fotkin)


    when I switch between visual and text version of the page, change HTML formatting, and then switch to visual to see if everything is OK, then switch back to HTML, and all my HTML formatting is gone. is there a way to stop TinyMCE from doing so?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Jumping in because I had the same issue. @fotkin

    May be worth checking the settings for the plugin at http://www.MYSITE.COM/wp-admin/options-general.php?page=tinymce-advanced and the “advanced options” area. Specifically looking at the “Keep paragraph tags” option. Once I unchecked it, it seemed to work fine and as expected again.

    I did a little research about this… and turns out, that when you switch from text view to a visual view, TinyMCE parses your content into DOM, and it doesn’t care what you had in your HTML… then when you switch back to Text view, it converts DOM back to HTML, wiping all your formatting and stuff πŸ™

    I looked around, and looks like there is no way to stop this behavior. And may be it is even a good way getting rid of different HTML errors users might make while poking around with it πŸ™‚

    So, I ended up with keeping HTML locally on my computer, was using Atom to edit, and then when I was ready, I copied and pasted to WordPress πŸ™‚

    Would be great if WordPress would save original HTML somewhere in the database, together with formatting and comments… Btw, may be there is Plugin for that? πŸ™‚ Or, if not, may be someone can develop one!

    @fotkin, I just carried out a test and it works well for me. I suspect that you might have a conflict with your theme or a plugin.

    For the theme you might like to test one of WordPress default themes like Twenty Fifteen or Sixteen. If it is not the theme, then you can disable all of your other plugins and carry out a test.

    Let me know how you go.

    Regards

    @mbrsolution take a look at the video I have recorded:

    I switched off all plugins and changed theme to default one, and still can not preserve HTML, very annoying…

    @fotkin, I now see what you mean. I believe that is how WordPress formats the bulleted list. If you want to change the style you need to use a third party plugin or add your own customization in your child theme. You might like to read the following documentation.

    In regards to paragraph and line space did you enable the following feature Keep paragraph tags in the plugin?

    Regards

    Plugin Author Andrew Ozz

    (@azaozz)

    WordPress Dev

    all my HTML formatting is gone

    I’m assuming you mean all the “white space” from the HTML source.

    …when you switch from text view to a visual view, TinyMCE parses your content into DOM, and it doesn’t care what you had in your HTML… then when you switch back to Text view, it converts DOM back to HTML, wiping all your formatting and stuff.

    This is correct, and is not really TinyMCE doing it, it’s the browser. How else would you see a “preview” of the HTML πŸ™‚

    White space doesn’t matter in the HTML source. All spaces, tabs, line breaks, etc. are rendered as a single space when you load it in the browser. There is really no good way to take some HTML source, load it in a browser (convert to a DOM), then extract the source out of that DOM and preserve the previous spaces.

    Would be great (may be there is a WordPress plugin called Preserve HTML) that saves original HTML somewhere into database πŸ™‚ But I understand that as soon as you make changes in visual editor, TinyMCE needs to recreate HTML from DOM, and it doesn’t care about formatting and HTML comments and the rest of the stuff πŸ™‚

    I solved this issue by saving original HTML files locally and was using Atom Editor to edit them, so we can close this issue… But Google will bring a lot of people who are having the same problem… πŸ™‚

    Plugin Author Andrew Ozz

    (@azaozz)

    WordPress Dev

    …as soon as you make changes in visual editor, TinyMCE needs to recreate HTML from DOM, and it doesn’t care about (source) formatting…

    Right, it’s not that it doesn’t care, but the HTML source is now different and the previous “white space” is gone. Frankly I don’t like that too, but that’s the way browsers work πŸ™‚

    • This reply was modified 3 months, 1 week ago by  Andrew Ozz.
Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.