TinyMCE 4.7.11 custom styles using styleselect – what does the ‘attributes’ argument do?

I’m writing a plugin to add custom formats to TinyMCE using styleselect.

I’ve scoured the documentation and hundreds of examples covering the inline, block, selector, classes, and wrapper arguments.

I can’t find a single example of how to use “attributes” argument.

Both WordPress and TinyMCE say this:

“Name/value object with attributes to apply to the selected elements or the new inline/block element.”

Part of my array deals with external links – namely to add classes that help with Google analytics.

array(
‘title’ => ‘Link Resource’,
‘selector’ => ‘a’,
‘classes’ => ‘smart-link-external smart-link-resource’,
‘wrapper’ => false,
),

I was hoping to use the attributes argument to add things like rel=”external”.

I’m not sure this is even the intended use for the argument, let alone how to configure it.

Any help would be greatly appreciated.

Read more here:: TinyMCE 4.7.11 custom styles using styleselect – what does the ‘attributes’ argument do?

Leave a Reply

Your email address will not be published. Required fields are marked *