需求是当编辑器中存在
<p style="text-align:justify"> </p>
字符时,需要将其转换成<p> </p> through the filter
,下面是我写的程序,但是测试的时候没有跑起来,希望能解答我的问题,谢谢!
CKEDITOR.on('instanceReady', function (ev) {
/* code */
ev.editor.on('filter', function(event) {
var filter = event.data.filter;
filter.addTransformations([[
{
element: 'p',
attributes: { 'style': /^text-align:(justify)$/ },
childRule: function(child) {
if (child.name == '#text' && child.value == '\xa0') {
return CKEDITOR.htmlParser.fragment.fromHtml('<p> </p>');
}
}
}
]]);
});
/* code */
})