WordPress.org

Make WordPress Core

#45289 closed defect (bug) (worksforme)

wp.editor.initialize not working

Reported by: otgschristian Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.0
Component: TinyMCE Keywords: needs-patch reporter-feedback
Focuses: Cc:

Description

WP 4.8 introduced some js methods to dynamically initialise / remove TinyMCE instances.

wp.editor.initialize()
wp.editor.remove()
wp.editor.getContent()

Working perfectly with last stable WP, but not with WP 5.0 (tested up to beta 3). The functions are no longer defined:

wp.editor.initialize is not a function

References:

https://make.wordpress.org/core/2017/05/20/editor-api-changes-in-4-8/

https://codex.wordpress.org/Javascript_Reference/wp.editor

Change History (7)

#1 @SergeyBiryukov
20 months ago

  • Milestone changed from Awaiting Review to 5.0

#2 @otgschristian
20 months ago

Addition: when using WP5.0 b3 with the last Gutenberg version from Github as standalone plugin I do not have the issue (while writing this it's version 4.2.0-rc.1).

#3 @otgschristian
20 months ago

Found out that ' wp-api-request' is no longer loaded by default. Adding 'wp-editor' as script dependency for the script using the above mentioned functions and it's working as again.

If this is expected feel free to close the ticket.

#4 @pento
20 months ago

  • Keywords reporter-feedback added

Thank you for the bug report, @otgschristian!

Do you have a sample of how you enqueued the JavaScript that caused this error?

#5 @otgschristian
20 months ago

@pento thanks for looking at it.

Here a simple plugin that shows the issue: https://github.com/CGlingener/wp-45289

#6 @mcsf
20 months ago

I don't think this is a defect, as Gutenberg indeed reimplements wp.editor.

Care should now be taken in third-party code to check for the existence of wp.editor.initialize, for instance, or to inspect wp.oldEditor.

#7 @azaozz
20 months ago

  • Milestone 5.0 deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Testing the demo plugin, all seems to work as expected, can see a postbox with another TinyMCE instance. Closing as worksforme.

Note: See TracTickets for help on using tickets.