Magento2 – Modify WYSIWYG or TinyMCE Configurations

magento2wysiwyg

Within the editor it seems html is validated so that multiple elements cannot be placed within a tags. I want to allow markup like below:

<a href="#"><h2>Category</h2><img src="logo.png" /><p>Some text...</p></a>

This however always ends up like so:

<a href="#"><h2>Category</h2></a><img src="logo.png" /><p>Some text...</p>

I have seen posts about this however am unsure how to modify valid_elements
or valid_child_elements within magento 2.

https://stackoverflow.com/questions/14597219/how-to-configure-tinymce-to-allow-block-level-elements-inside-anchor-a-tag

There is also this but this applies to Magento 1 :

https://www.pixafy.com/blog/2013/06/overcoming-magentos-wysiwyg-part-2-customizing-tinymce-settings/

So far have tried looking at module-backend/view/adminhtml/templates/widget/form/element.phtml and lib/web/tiny_mce/tiny_mce_src.js as this is the only place i could see configs like this but had no luck.

How can i override these settings with Magento 2?

Best Answer

Check my question on TinyMCE Community.

There is the answer: TinyMCE views anchor links as an inline element and will not allow block elements to be placed inside of them. This is a limitation of the current TinyMCE object model. As a workaround, you could use a span inside the anchor tag and style the text as needed based on the span.

Related Topic