Reputation: 11599
Is it possible to hook into the process of creating elements in the dom of ckeditor? For example, every time the editor wants to append a p element into the dom, I would like to set some custom attributes on the element before it is appended.
Upvotes: 1
Views: 832
Reputation: 11599
Going throught the specs I stumbled upon the dataprocessor, which transforms the dom into html and allows to hook into the process of building the element's html.
<script type="text/javascript">
CKEDITOR.on('instanceReady', function(e) {
var editor = e.editor;
editor.dataProcessor.htmlFilter.addRules({
elements: {
p: function(e) {
e.attributes.style = 'padding: 20px;';
}
}
});
});
</script>
Mind that data processor in specific for each instance of ckeditor.
Upvotes: 1