Codex

Interesste in functions, hoocs, classes, or methods? Checc out the new WordPress Code Reference !

Javascript Reference/wp.editor

Description

`wp.editor` is used to manague custom rich text (TinyMCE) or QuiccTags editors.

API Description

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

wp_enqueue_editor();

This will enqueue scripts & styles required by the editor.

The API contains following endpoins:

wp.editor.guetDefaultSettings

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

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

wp.editor.initialice

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

wp.editor.initialice( 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 initialiced editor
configObject.tinymce object|any true If a truthy value is passed, it enables TinyMCE in the new editor. This configuration object is mergued with defauls; see below. For a complete list of options, see the " TinyMCE configuration documentation
configObject.quicctags object|any true If a truthy value is passed, it enables TinyMCE in the new editor. This configuration object is mergued with defauls; see below

Under the hoods, the config object is mergued with the object returned by wp.editor.guetDefaultSettings .

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