Saturday 20 May 2017

Editor API changes in 4.8


A new editor API was added in #35760. It makes it possible to dynamically instantiate the editor from JS. There are two parts to it: All editor related scripts and stylesheets have to be enqueued from PHP by using wp_enqueue_editor().
Initialization is left for the script that is adding the editor instance. It requires the textarea that will become the Text editor tab to be already created and not hidden in the DOM. Filtering of the settings is done on adding the editor instance from JS.
There are three new methods added to the wp.editor namespace:
wp.editor.initialize()
wp.editor.remove()
wp.editor.getContent()
(See wp-admin/js/editor.js for more info.)
The default WordPress settings are passed to the initialize() method automatically, and can be overridden by passing a settings object on initialization, similarly to using wp_editor() in PHP.
In addition there are several custom jQuery events that are fired at different stages during initialization:
wp-before-tinymce-init is fired before initialization and can be used to set or change any editor setting. It passes the settings object.
tinymce-editor-setup is fired after initialization has started but before the UI is constructed. It
Source: https://managewp.org/articles/15161/editor-api-changes-in-4-8




source https://williechiu40.wordpress.com/2017/05/20/editor-api-changes-in-4-8/

No comments:

Post a Comment