各TextFlow要素内のすべての要素をループし、各要素ですべての属性を反復処理して同等のhtml style
プロパティを作成できます。このような何か...
var attrConversion = {
'textalign': ['text-align','',''], // [Style name, Value preffix, Value Suffix]
'color': ['color','',''],
'fontfamily': ['font-family','',''],
'fontsize': ['font-size','','px'],
'fontstyle': ['font-style','',''],
'fontweight': ['font-weight','','']
};
function attrConversor(textflowAttr) {
var attr = attrConversion[textflowAttr.name];
return attr[0] + ':' + attr[1] + textflowAttr.value + attr[2];
}
$('TextFlow *').each(function() {
var styleField = [], textflowAttrs = [];
var element = this;
// Loop through all attributes.
$.each(this.attributes,function() {
if (this.specified) {
textflowAttrs.push(this.name);
styleField.push(attrConversor(this));
}
});
// Remove all textflow attibutes from the element (you can't do it
// in the $.each because it would affect the iterations).
for (var i=0, l=textflowAttrs.length ; i<l; i++)
element.removeAttribute(textflowAttrs[i]);
// Apply the 'style' html attribute.
$(this).attr('style',styleField.join(';'));
});
ことでTextFlowは、属性名のように見えるが、このアプローチにはいくつかの問題...
を持っているだけで、HTMLのようなものですが、キャメルケース形式で、問題があることですthis.attributes
は小文字のthis.name
を取得するので、textflow属性名をHTMLバージョンに変換するオブジェクトを作成する必要があります。
TextFlowアトリビュート値の中には、htmlスタイルバージョンとの小さな違いがあります。たとえば、フォントファミリ名が異なる可能性があります。fontSize
にはpx
という接尾辞が付いていないため、手動で入力する必要があります。そのようなものはすべて発見して世話をする必要があります。
ここでは、フィドルの例を持っている... https://fiddle.jshell.net/rigobauer/xvukm9sn/
は完璧ではないですが、少なくとも、あなたで動作するように何かを与えます。私はそれが助けてくれることを願っています
あなたが 'element.getAttribute( 'fontFamily')' – LGSon