I am adding HTML in CMS block editor but it keeps removing
<a> tags from Html.
Does anyone have a solution for this?
One of the possible solution for this
Go this file:
['a', 'href target rel media hreflang type charset name rev shape coords download', phrasingContent],
['a', 'href target rel media hreflang type charset name rev shape coords download', flowContent],
Good approach to override this file is you can do this some thing like that
The reason this fixes the issue is that the
flowContent array includes block level tags and inline tags unlike the
phrasingContent array which includes only inline elements.
The first element of this array is the a the tag we want to fix, the second array entry appears to be attributes allowed on a tags, and the third array entry (the one we care about) appears to be allowed children.
Another solution is to update Magento version to 2.3 because Magento 2.3 will finally have an update to Tinymce 4.x as @Aaditya suggested you in comment.
I hope this will help I hope this will help
I was also facing this issue, this can be solved by configuring
valid_children settings inside
Tinymce4Adapter.js file(for TinyMCE version 4.6)
As answered by https://magento.stackexchange.com/users/77224/mike-dubs here Magento 2.3 - TinyMCE4 Toolbar and Plugin Configuration
create the module as mentioned there and add below code inside Config plugin file to provide
valid_elements and valid_children settings to
Tinymce4Adapter.js as shown below
$settings['valid_elements'] = '*[*]'; $settings['valid_children'] = '+body[style],+div[a],+p[strong|a|#text],+a[div]';