Home Plugins tinymce custom styles
TinyMCE Custom Styles logo

TinyMCE Custom Styles

by Tim Reeves on WordPress.org

Enhance TinyMCE visual editor with a dedicated stylesheet, a stylesheet shared with the frontend, and custom styles in the Formats dropdown.

(14)

Please someone take over maintaining this plugin, or it will get abandoned – with over 9.000 active installations.

I’m now 69 and although retired, all my time is taken up with other projects, while I still have the energy for them. Why you might want to take it over? It’s really useful:

Make your editing experience as simple and good as possible by improving the way you work with the TinyMCE visual editor (including Gutenberg Classic block). This plugin adds custom CSS file(s) to the frontend and to the TinyMCE editor; and it allows you to populate TinyMCE’s ‘Formats’ dropdown with your own styles. The features in more detail:

1. Installs two CSS stylesheet files into your chosen location (so you can still do updates of the active theme and this plugin and even switch to another theme). In general you will need to fetch the auto-created stub files via FTP, edit them locally and upload them, overwriting the previous versions.

  • editor-style.css is used for styling your TinyMCE Editor
  • editor-style-shared.css is used for styles to be used by the frontend AND in your TinyMCE editor (so you do not have to copy)

To use this feature, you have to write your own CSS code into these files.

2. The main feature of this Plugin is to offer a Backend-GUI to create custom styles for TinyMCE (‘Formats’ dropdown) dynamically.

  • Easy to add, change and delete styles
  • No editing of source code required (excepting the CSS stylesheets)
  • Allows you to add block- and inline elements which are not provided by TinyMCE, e.g.
    , , etc.
  • The plugin’s backend page contains a lot of description and some links to help you define your styles correctly
  • Note that each style can have both CSS Classes and/or CSS Inline-Styles. The latter (excepting color) will even be applied to the Formats dropdown menu items. However, I do not recommend inline styles as they are inserted into the text of the post/page and remain unchanged if you later alter the style in the plugin settings – so in general stick to Classes!

How the two stylesheets are applied
The shared style sheet file is enqueued to be included on frontend pages (via the usual tag in the area) using the standard WordPress function wp_enqueue_style.

So, as with most other stylesheets, the statements in it will automatically apply to the whole HTML page. So define class names which will not collide with any already in use by the theme – and do not define styles for HTML elements without a limiting class name unless you want them to apply to all elements of that tag type (including in header, footer, sidebar…).

Both stylesheets are passed to TinyMCE by calling: add_filter(‘mce_css’, …)

What this causes to happen is that they are linked in to the HTML document which is the source for an