CKEditor is removing empty anchor tags such as the following:
<a data-original-title="youtube" class="youtube" href="#"> </a>
I am able to stop removing anchors if the html is altered as following:
<a data-original-title="youtube" class="youtube" href="#" data-cke-survive="true"> </a> //--OR-- <a data-original-title="youtube" class="youtube"> </a>
So, by adding new attribute of data-cke-survive or by removing attribute href, the anchor is not being removed, however. Both of these solution involve altering html which is inpossible in our use case. We like to have this to be configurable something like:
if(window.CKEDITOR){ CKEDITOR.on('instanceCreated', function (ev) { CKEDITOR.dtd.$removeEmpty['a'] = 0; } }
This works if we alter the CKeditor library by changing function RemoveEmpty to
function isRemoveEmpty( node ) { // Keep marked element event if it is empty. if ( node.attributes[ 'data-cke-survive' ] ) return false; // Empty link is to be removed when empty but not anchor. (#7894) return CKEDITOR.dtd.$removeEmpty[ node.name ]; }
This is also not really good idea. How to ensure empty anchor tags are not removed? How to accomplish this from configurations or maybe we have to add some processor, filter? What is the best approach?