WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Javascript Reference/wp.editor

Description

`wp.editor` is used to manage custom rich text (TinyMCE) or QuickTags editors.

API Description

In order to use this API, you should enqueue the editor with PHP, like follow:

wp_enqueue_editor();

This will enqueue scripts & styles required by the editor.

The API contains following endpoints:

wp.editor.getDefaultSettings

This function returns the default object that will be merged with specific configuration when initializing new editors.

If this property is null or undefined, please make sure you called wp_enqueue_editor(); from PHP.

wp.editor.initialize

This method will allow you to initialize a new editor. You can use it in JavaScript this way:

wp.editor.initialize( editorId, configObject );

The config object may contain following properties:

Property Type Default value Description
editorId string Id of the DOM element to use as base. It will be replaced with the editor
configObject object { tinymce: true } Configuration for the newly initialized editor
configObject.tinymce object|any true If a truthy value is passed, it enables TinyMCE in the new editor. This configuration object is merged with defaults; see below. For a complete list of options, see the " TinyMCE configuration documentation
configObject.quicktags object|any true If a truthy value is passed, it enables TinyMCE in the new editor. This configuration object is merged with defaults; see below

Under the hoods, the config object is merged with the object returned by wp.editor.getDefaultSettings.

If this function does nothing, please make sure that wp.editor.getDefaultSettings is a function. See above for documentation.