From 0bb3c142eb6fc21fdd56b638ba408a90190840e9 Mon Sep 17 00:00:00 2001 From: Neil Jenkins Date: Thu, 21 Feb 2013 11:35:23 +1100 Subject: [PATCH] Rewrite tags when cleaning tree. * Converts to . --- source/Editor.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/source/Editor.js b/source/Editor.js index 36c93fe..28bdca7 100644 --- a/source/Editor.js +++ b/source/Editor.js @@ -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',