Make WordPress Core

Opened 7 years ago

Closed 5 years ago

#41534 closed defect (bug) (wontfix)

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

Reported by: adamsilverstein's profile adamsilverstein Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.8
Component: Editor Keywords: reporter-feedback needs-patch
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 7 years ago.

Download all attachments as: .zip

Change History (5)

#1 @adamsilverstein
7 years 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.

This ticket was mentioned in Slack in #core by noisysocks. View the logs.


5 years ago

#3 @kirasong
5 years ago

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

Hi @adamsilverstein!

We chatted about this ticket in today's APAC triage session.

Folks present weren't able to reproduce this, and were guessing that's due to the custom view you mention. I agree that either way, it'd be ideal to solve this without the setTimeout so setting this to needs-patch.

Would you mind providing some sample code that causes the issue so that folks can test this and potential fixes?

Thanks so much!

#4 @adamsilverstein
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Thanks for the ping @mikeschroder :) It has been a long while since I filed this report and I would have to spend some time to dig to find or create a code sample.

Given that this issue was for the Classic (TinyMCE) editor, and that it is an edge case, I am more inclined to close as won't fix and spend my time working on issues that are more currently relevant.

If I missed something, or if this remains an issue for some users and still needs fixing, please feel free to re-open.

Note: See TracTickets for help on using tickets.