WordPress.org

Make WordPress Core

Opened 3 weeks ago

Closed 13 days ago

Last modified 13 days ago

#43969 closed defect (bug) (fixed)

Custom themes will not work in TinyMCE 4.7

Reported by: programmin Owned by: azaozz
Milestone: 4.9.6 Priority: normal
Severity: normal Version: trunk
Component: TinyMCE Keywords: dev-feedback needs-patch
Focuses: ui Cc:

Description

Themes (meaning Tinymce js themes) that previously worked with TinyMCE <= 4.6 will not work in the upcoming 4.7.

For example if you have been filtering wp_editor_settings and change the array with:

 'theme' => 'myspecialtheme',
 'theme_url' => 'full url of js file'

it looks quite broken because the format of the theme.js file (generally the js/tinymce/themes/modern/theme.js) is vastly different format pre-4.7.

Attachments (1)

43969.patch (978 bytes) - added by azaozz 13 days ago.

Download all attachments as: .zip

Change History (21)

#1 @desrosj
3 weeks ago

  • Keywords dev-feedback added
  • Milestone changed from Awaiting Review to 4.9.6

#2 @desrosj
2 weeks ago

  • Keywords needs-patch added

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


2 weeks ago

#4 @SergeyBiryukov
2 weeks ago

  • Keywords needs-patch removed

Related: #43862.

#5 @SergeyBiryukov
2 weeks ago

  • Keywords needs-patch added

#6 @programmin
2 weeks ago

Confusingly it looks like if SCRIPT_DEBUG is TRUE it actually does work if you set a custom theme js, but on a production test site in which it references wp-includes/js/tinymce/wp-tinymce.php (which includes modern theme) it doesn't work and the option no longer overrides the modern theme.

#7 @programmin
2 weeks ago

The root of the problem may be that previously mce-themes were:

tinymce.ThemeManager.add('nameoftheme', function... )

and now the theme is

(function () { var modern = (function () {...})() } ) ()

Note that before the function does not immediately run... now it does meaning there is no way to tell mce php loader to not run that modern theme behavior.

This ticket was mentioned in Slack in #core-tinymce by azaozz. View the logs.


2 weeks ago

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


13 days ago

#10 @azaozz
13 days ago

@programmin do you use a custom TinyMCE theme somewhere? Asking as this seems very rare :) If this is in a WP plugin, could you update the plugin to fix this issue?

#11 @programmin
13 days ago

Yes, and it looks like it can work fine, but only when turning off the $compress_scripts or $concatenate_scripts so that it doesn't output the highly optimized wp-tinymce.php while in print_tinymce_scripts(). Not optimal but that works.

#12 follow-up: @programmin
13 days ago

Really a TinyMCE bug as that code is coming from their default modern theme...

https://github.com/tinymce/tinymce/issues/4387

#13 in reply to: ↑ 12 @azaozz
13 days ago

Replying to programmin:

Really a TinyMCE bug as that code is coming from their default modern theme...

Yeah, I see.

it can work fine, but only when turning off the $compress_scripts or $concatenate_scripts...

Yes, not optimal but better than reverting to the old version imho. We can turn off concatenation "automatically" when theme_url is set in the init array. Patch coming up.

@azaozz
13 days ago

#14 @azaozz
13 days ago

In 43969.patch: disable concatenation if a custom TinyMCE theme is used (theme_url is set).

@programmin could you test this fast please, so we can add before RC :)

#15 follow-up: @programmin
13 days ago

@azaozz Yes, that patch looks good and seems to do the exact same thing as my hacky filter fix. Would be awesomer to have the scripts included in wp-tinymce.php filterable or have one for the base TinyMCE though.

#16 in reply to: ↑ 15 ; follow-up: @azaozz
13 days ago

Replying to programmin:

Would be awesomer to have the scripts included in wp-tinymce.php filterable or have one for the base TinyMCE though.

That's not possible :( wp-tinymce.js.gz (that is outputted from wp-tinymce.php) is concatenated and compressed at build time by Grunt.

#17 @azaozz
13 days ago

  • Owner set to azaozz
  • Resolution set to fixed
  • Status changed from new to closed

In 43222:

TinyMCE: switch off concatenation when a custom TinyMCE theme is used. Prevents conflict with the default theme as it loads first.

Props programmin, azaozz.
Fixes #43969.

#18 @azaozz
13 days ago

In 43224:

TinyMCE: switch off concatenation when a custom TinyMCE theme is used. Prevents conflict with the default theme as it loads first.

Props programmin, azaozz.
Merges [43222] to the 4.9 branch.
Fixes #43969.

#19 in reply to: ↑ 16 ; follow-up: @programmin
13 days ago

Replying to azaozz:

Replying to programmin:

Would be awesomer to have the scripts included in wp-tinymce.php filterable or have one for the base TinyMCE though.

That's not possible :( wp-tinymce.js.gz (that is outputted from wp-tinymce.php) is concatenated and compressed at build time by Grunt.

Where is that compiled? Can one autobuild a copy with a replacement for "modern" theme?

#20 in reply to: ↑ 19 @azaozz
13 days ago

Replying to programmin:

Where is that compiled? Can one autobuild a copy with a replacement for "modern" theme?

Probably. Can try to adjust the build script for your plugin. Mostly here: https://core.trac.wordpress.org/browser/trunk/Gruntfile.js#L567 and https://core.trac.wordpress.org/browser/trunk/Gruntfile.js#L596.

Note: See TracTickets for help on using tickets.