[wp-trac] [WordPress Trac] #41534: Styles added with `add_editor_style` are not added to custom `wp.mce` views on initial load

WordPress Trac noreply at wordpress.org
Wed Aug 2 14:54:55 UTC 2017


#41534: Styles added with `add_editor_style` are not added to custom `wp.mce` views
on initial load
-----------------------------+-----------------------------
 Reporter:  adamsilverstein  |      Owner:
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Editor           |    Version:  4.8
 Severity:  normal           |   Keywords:  needs-patch
  Focuses:  javascript       |
-----------------------------+-----------------------------
 We have a custom wp.mce view built to render a shortcode that broke since
 the recent upgrade of TinyMCE in r40583.

 Since this change, the view is rendered without its required stylesheets
 the first time the Visual editor loads. switching to the text view then
 back to visual correctly loads the stylesheets into the iframes.

 I tracked down what is supposed to happen: in `wp-includes/js/mce-view.js`
 the function `setIframes` iterates thru all of the view iframes embedded
 in the editor and copies the stylesheets from the editor into the view
 iframes. In this way, the stylesheet added to the editor with
 `add_editor_style` are added to the iframes so they have the styles they
 need to render.

 Since the TinyMCE update, the stylesheets are not yet present in the
 editor when this runs the first time. In my testing wrapping the
 `setIframes` callback in a `setTimeout(,0)` call was enough to resolve the
 issue although the root issue may be in where this call is triggered.

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


More information about the wp-trac mailing list