Roo.htmleditor.FilterStyleToTag = function(cfg)
{
this.tags = {
B : [ 'fontWeight' , 'bold', 'font-weight'],
I : [ 'fontStyle' , 'italic', 'font-style'],
SUP : [ 'verticalAlign' , 'super', 'vertical-align'],
SUB : [ 'verticalAlign' , 'sub', 'vertical-align']
};
Roo.apply(this, cfg);
this.walk(cfg.node);
}
Roo.extend(Roo.htmleditor.FilterStyleToTag, Roo.htmleditor.Filter,
{
tag: true, tags : false,
replaceTag : function(node)
{
if (node.getAttribute("style") === null) {
return true;
}
var inject = [];
for (var k in this.tags) {
if (node.style[this.tags[k][0]] == this.tags[k][1]) {
inject.push(k);
node.style.removeProperty(this.tags[k][2]);
}
}
if (!inject.length) {
return true;
}
var cn = Array.from(node.childNodes);
var nn = node;
Roo.each(inject, function(t) {
var nc = node.ownerDocument.createElement(t);
nn.appendChild(nc);
nn = nc;
});
for(var i = 0;i < cn.length;i++) {
node.removeChild(cn[i]);
nn.appendChild(cn[i]);
}
return true }
})