1

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?

  • starting point js/mage/adminhtml/wysiwyg/tiny_mce/setup.js – jscar Oct 30 '17 at 13:07
  • Is that the Magento 1 path? – harri Oct 30 '17 at 13:10
  • Yes it is. Sorry, should have said that. – jscar Oct 30 '17 at 13:42
2

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.

2

I encountered the same problem, solved it by follow way.

Navigate to Dashboard > store > settings > Configuration > general > content management > WYSIWYG Options > Enable WYSIWYG Editor, choose Disabled by Default.

After setting, you could still use WYSIWYG Editor in catalog content, but it is not default now, it will not affect your html codes in page or block unless you click the Show/Hide Editor button.

  • I solved my problems with tinymce in Magento this way too. ;-) – Iveta Allogenes Jan 23 '19 at 10:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.