WordPress.org

Make WordPress Core

Opened 5 months ago

Last modified 5 months ago

#41534 new defect (bug)

Styles added with `add_editor_style` are not added to custom `wp.mce` views on initial load

Reported by: adamsilverstein Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.8
Component: Editor Keywords: has-patch 2nd-opinion
Focuses: javascript Cc:

Description

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.

Attachments (1)

41534.diff (643 bytes) - added by adamsilverstein 5 months ago.

Download all attachments as: .zip

Change History (2)

#1 @adamsilverstein
5 months ago

  • Keywords has-patch 2nd-opinion added; needs-patch removed

41534.diff resolves the issue in my testing, although would be preferable to track down and fix the ordering of the triggered callbacks to make this unnecessary.

Note: See TracTickets for help on using tickets.