[wp-trac] [WordPress Trac] #42003: TinyMCE views add <p> tags around shortcodes when switching from Visual to Text/HTML editor

WordPress Trac noreply at wordpress.org
Wed Sep 27 07:52:48 UTC 2017


#42003: TinyMCE views add <p> tags around shortcodes when switching from Visual to
Text/HTML editor
----------------------------+-----------------------------
 Reporter:  lvl99           |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Editor          |    Version:  trunk
 Severity:  normal          |   Keywords:
  Focuses:  ui, javascript  |
----------------------------+-----------------------------
 I'm using the Shortcake plugin to manage an admin interface for creating
 and modifying shortcode content.

 Shortcodes which are managed by Shortcake use the WordPress TinyMCE View
 plugin to render the shortcode in the editor.

 When switching from the Visual to the Text/HTML editor (and even when
 saving posts) all shortcodes which have TinyMCE views then have extra
 newlines inserted around them. In the case of shortcodes which are used in
 inline positions (i.e. within a header tag) this then adds extra
 paragraphs and breaks the content.

 I've found that this is all due to one line which inserts <p> tags around
 the shortcode text:
 https://github.com/WordPress/WordPress/blob/b32256701a69f15e82b9ebff6acf11acd801375b
 /wp-includes/js/tinymce/plugins/wpview/plugin.js#L22

 I feel that the TinyMCE View should be able to support both block and
 inline elements. I found in my exploration that removing the <p> tags
 solved my issue, however I'm not sure what any residual issue from
 removing the extra tags may have caused. It'd be great to get some others'
 opinions on it.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/42003>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list