Reputation: 70
I want to add rel="nofollow" to all links in the CKEditor. I have read a lot of questions about it and also tried my best with the documentation. However I cannot get it working.
I am using Drupal 7 (Not the wysiwyg module, just the ckeditor module with cdn version 4).
Code that I have tried:
var editor = new CKEDITOR.editor();
CKEDITOR.on('instanceReady', function( ev ) {
editor.dataProcessor.htmlFilter.addRules(
{
elements :
{
a : function( element )
{
console.log(element.attributes);
if ( !element.attributes.rel )
element.attributes.rel = 'nofollow';
}
}
});
});
This code was what I found in other questions. In the documentation I can't find the addRules function, and if I put a breakpoint inside of the function, I see that it never gets called.
I would really appreciate some input!
Upvotes: 1
Views: 927
Reputation: 5358
Do you need to get it done through CKeditor's config? Because This can be configurated within the Drupal interface:
Upvotes: 2