Hi,
i am working on a project with web CKEditor. I need to replace certain tags. E.g. strong => b. So the only thing i would need is to replace the tag name. I found this solution in the documentation:
var filter = new CKEDITOR.htmlParser.filter( {
elements: {
strong: function( element ) {
element.name = 'b';
}
}
} );
var fragment = CKEDITOR.htmlParser.fragment.fromHtml( '<strong>Foo<b>bar!</b></strong>' ),
writer = new CKEDITOR.htmlParser.basicWriter();
filter.applyTo( fragment );
fragment.writeHtml( writer );
writer.getHtml(); // '<b>Foo<b>bar!</b></b>'
Problem is I cant get it to work in a real editor. here is my approach:
editor.on('instanceReady', function () {
var rule = {
elements: {
strong: function (e) {
e.name = 'b';
}
}
};
editor.dataProcessor.htmlFilter = new CKEDITOR.htmlParser.filter( {
elements: {
strong: function( element ) {
element.name = 'b';
}
}
} );
editor.dataProcessor.dataFilter = new CKEDITOR.htmlParser.filter({
elements: {
strong: function (element) {
element.name = 'b';
}
}
});
});
Any ideas?
Jonas