mirror of
https://github.com/fastmail/Squire.git
synced 2025-01-03 13:16:31 -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 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 = {
|
var spanToSemantic = {
|
||||||
color: {
|
color: {
|
||||||
regexp: /\S/,
|
regexp: /\S/,
|
||||||
|
@ -1069,6 +1079,32 @@
|
||||||
el.appendChild( node.empty() );
|
el.appendChild( node.empty() );
|
||||||
return el;
|
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 ) {
|
TT: function ( node, parent ) {
|
||||||
var el = createElement( 'SPAN', {
|
var el = createElement( 'SPAN', {
|
||||||
'class': 'font',
|
'class': 'font',
|
||||||
|
|
Loading…
Reference in a new issue