Skip to content

Commit fbcd381

Browse files
committed
fix(taBind, textAngular-sanitize): Corrected and enhanced formating comming from Word and OneNote
- taBind: replaced <span style='...veritcal-align:super;...'>...</span> -> <sup style='...'>...</sup> so that we now see superscripts from OneNote - textAngular-sanitize: vertical-align is now accepted as a style adjustment and font-size is now enhanced to accept more of the standard settings.
1 parent 4ef827e commit fbcd381

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

src/taBind.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,11 @@ angular.module('textAngular.taBind', ['textAngular.factories', 'textAngular.DOM'
689689

690690
if(_pasteHandler) text = _pasteHandler(scope, {$html: text}) || text;
691691

692+
// turn span vertical-align:super into <sup></sup>
693+
text = text.replace(/<span style=("|')([^<]*?)vertical-align\s*:\s*super;?([^>]*?)("|')>([^<]+?)<\/span>/g, "<sup style='$2$3'>$5</sup>");
694+
692695
text = taSanitize(text, '', _disableSanitizer);
696+
//console.log('DONE\n', text);
693697

694698
taSelection.insertHtml(text, element[0]);
695699
$timeout(function(){

src/textAngular-sanitize.js

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -548,15 +548,37 @@ function validStyles(styleAttr){
548548
value === 'italic'
549549
)
550550
||
551-
key === 'float' && (
552-
value === 'left'
553-
|| value === 'right'
554-
|| value === 'none'
555-
)
551+
key === 'float' && (
552+
value === 'left'
553+
|| value === 'right'
554+
|| value === 'none'
555+
)
556+
||
557+
key === 'vertical-align' && (
558+
value === 'baseline'
559+
|| value === 'sub'
560+
|| value === 'super'
561+
|| value === 'test-top'
562+
|| value === 'text-bottom'
563+
|| value === 'middle'
564+
|| value === 'top'
565+
|| value === 'bottom'
566+
|| value.match(/[0-9]*(px|em)/)
567+
|| value.match(/[0-9]+?%/)
568+
)
556569
||
557570
key === 'font-size' && (
558-
value.match(/[0-9\.]*(px|em|rem|%)/)
559-
)
571+
value === 'xx-small'
572+
|| value === 'x-small'
573+
|| value === 'small'
574+
|| value === 'medium'
575+
|| value === 'large'
576+
|| value === 'x-large'
577+
|| value === 'xx-large'
578+
|| value === 'larger'
579+
|| value === 'smaller'
580+
|| value.match(/[0-9]*\.?[0-9]*(px|em|rem|mm|q|cm|in|pt|pc|%)/)
581+
)
560582
||
561583
(key === 'width' || key === 'height') && (
562584
value.match(/[0-9\.]*(px|em|rem|%)/)

0 commit comments

Comments
 (0)