mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 15:23:29 -05:00
Rewrite <font> tags when cleaning tree.
* Converts to <span>.
This commit is contained in:
parent
b35b7d4b35
commit
0bb3c142eb
1 changed files with 36 additions and 0 deletions
|
@ -988,6 +988,16 @@
|
|||
|
||||
var allowedBlock = /^A(?:DDRESS|RTICLE|SIDE)|BLOCKQUOTE|CAPTION|D(?:[DLT]|IV)|F(?:IGURE|OOTER)|H[1-6]|HEADER|L(?:ABEL|EGEND|I)|O(?:L|UTPUT)|P(?:RE)?|SECTION|T(?:ABLE|BODY|D|FOOT|H|HEAD|R)|UL$/;
|
||||
|
||||
var fontSizes = {
|
||||
1: 10,
|
||||
2: 13,
|
||||
3: 16,
|
||||
4: 18,
|
||||
5: 24,
|
||||
6: 32,
|
||||
7: 48
|
||||
};
|
||||
|
||||
var spanToSemantic = {
|
||||
color: {
|
||||
regexp: /\S/,
|
||||
|
@ -1069,6 +1079,32 @@
|
|||
el.appendChild( node.empty() );
|
||||
return el;
|
||||
},
|
||||
FONT: function ( node, parent ) {
|
||||
var face = node.face,
|
||||
size = node.size,
|
||||
fontSpan, sizeSpan,
|
||||
newTreeBottom, newTreeTop;
|
||||
if ( face ) {
|
||||
fontSpan = createElement( 'SPAN', {
|
||||
'class': 'font',
|
||||
style: 'font-family:' + face
|
||||
});
|
||||
}
|
||||
if ( size ) {
|
||||
sizeSpan = createElement( 'SPAN', {
|
||||
'class': 'size',
|
||||
style: 'font-size:' + fontSizes[ size ] + 'px'
|
||||
});
|
||||
if ( fontSpan ) {
|
||||
fontSpan.appendChild( sizeSpan );
|
||||
}
|
||||
}
|
||||
newTreeTop = fontSpan || sizeSpan || createElement( 'SPAN' );
|
||||
newTreeBottom = sizeSpan || fontSpan || newTreeTop;
|
||||
parent.replaceChild( newTreeTop, node );
|
||||
newTreeBottom.appendChild( node.empty() );
|
||||
return newTreeBottom;
|
||||
},
|
||||
TT: function ( node, parent ) {
|
||||
var el = createElement( 'SPAN', {
|
||||
'class': 'font',
|
||||
|
|
Loading…
Reference in a new issue