Pasting code into pre-formatted text in Visual Editor not working in 3.3.1

Pre-formatted text in the Visual Editor is not behaving like I’m used to. I’ve got an old installation (3.2.1), and when create pre-formatted text, all the line-breaks and spacing is preserved. In the latest version (3.3.1), the line breaks are interpreted as new paragraphs, and the code is broken across those paragraphs, leading spaces removed.

Process:

  1. Copy code from text editor.
  2. Click on the “New Post” link.
  3. Choose “Preformatted” from the format menu.
  4. Paste (ctrl-v).

3.2.1 – Correctly formatted code

screenshot of correctly formatted code

3.3.1 – Incorrectly formatted code

screenshot of incorrectly formatted code

I know I can switch to code view and put tags in myself, but I’m not looking for a workaround.

3 Answers
3

When you paste your code, TinyMCE (the visual editor) automatically switches back to paragraph mode because that’s the default for the editor. You have to highlight you pasted code and re-select “preformatted” to get it to be tagged correctly.

Also, TinyMCE always closes tags when you press enter. If you want to go to a new line without closing a tag, press shift + enter instead.

Leave a Comment