tiny-mce-additions

Define custom formats for your theme’s tinyMCE text fields.

Usage

KeyTypeRequiredDefault
"tiny-mce-additions"arrayNo[]

Where "tiny-mce-additions" is a list of objects, each with the options below.

Format Options

These options come from the WordPress Codex and the tinyMCE docs.

KeyTypeDescription
"title"stringThe name of the style, which will appear in the tinyMCE style selection dropdown menu.
"inline"stringName of the inline element to produce, e.g "span". The current text selection will be wrapped in this inline element.
"block"stringName of the block element to produce for example “h1″. Existing block elements within the selection gets replaced with the new block element.
"selector"stringCSS 3 selector pattern to find elements within the selection by. This can be used to apply classes to specific elements or complex things like odd rows in a table.
"classes"stringSpace separated list of classes to apply to the selected elements or the new inline/block element.
"styles"stringName/value object with CSS style items to apply such as color etc.
"attributes"stringName/value object with attributes to apply to the selected elements or the new inline/block element.
"exact"booleanDisables the merge similar styles feature when used. This is needed for some CSS inheritance issues such as text-decoration for underline/strikethough.
"wrapper"booleanState that tells that the current format is a container format for block elements. For example a div wrapper or blockquote.

Example

This custom format will apply the custom-checkbox-list class to all <ul> elements within the selected HTML.

<?php # config.php
return [
    "enable" => ["styleselect"],
    "tiny-mce-additions" => [
      [
        "title" => "Checkbox List",
        "selector" => "ul",
        "classes" => "custom-checkbox-list",
      ]
    ]
]

Now in the editor we see our newly defined format:

Note that the extended toolbar (farthest right button) must be enabled to see this option.