src/froala-sanitize.js
function validStyles(styleAttr) {
      var result = '';
      var styleArray = styleAttr.split(';');
      angular.forEach(styleArray, function (value) {
          var v = value.split(':');
          if (v.length === 2) {
              var key = trim(v[0].toLowerCase());
              value = trim(v[1].toLowerCase());
              if (
                  (key === 'color' || key === 'background-color') && (
                      value.match(/^rgb\([0-9%,\. ]*\)$/i) ||
                      value.match(/^rgba\([0-9%,\. ]*\)$/i) ||
                      value.match(/^hsl\([0-9%,\. ]*\)$/i) ||
                      value.match(/^hsla\([0-9%,\. ]*\)$/i) ||
                      value.match(/^#[0-9a-f]{3,6}$/i) ||
                      value.match(/^[a-z]*$/i)
                  ) ||
                  key === 'text-align' && (
                      value === 'left' ||
                      value === 'right' ||
                      value === 'center' ||
                      value === 'justify'
                  ) ||
                  key === 'float' && (
                      value === 'left' ||
                      value === 'right' ||
                      value === 'none'
                  ) ||
                  key === 'direction' && (
                      value === 'rtl' ||
                      value === 'ltr'
                  ) ||
                  key === 'font-family' && (
                      value === 'arial,helvetica,sans-serif' ||
                      value === 'georgia,serif' ||
                      value === 'impact,charcoal,sans-serif' ||
                      value === 'tahoma,geneva,sans-serif' ||
                      value === "'times new roman',times,serif" ||
                      value === 'verdana,geneva,sans-serif'
                  ) ||
                  (key === 'width' || key === 'height' || key === 'font-size' || key === 'margin-left') && (
                      value.match(/[0-9\.]*(px|em|rem|%)/)
                  )
              ) {
                  result += key + ': ' + value + ';';
              }
          }
      });
      return result;
  }
function validStyles(styleAttr) {
      var result = '';
      var styleArray = styleAttr.split(';');
      angular.forEach(styleArray, function (value) {
          var v = value.split(':');
          if (v.length === 2) {
              var key = trim(v[0].toLowerCase());
              value = trim(v[1].toLowerCase());
              if (
                  (key === 'color' || key === 'background-color') && (
                      value.match(/^rgb\([0-9%,\. ]*\)$/i) ||
                      value.match(/^rgba\([0-9%,\. ]*\)$/i) ||
                      value.match(/^hsl\([0-9%,\. ]*\)$/i) ||
                      value.match(/^hsla\([0-9%,\. ]*\)$/i) ||
                      value.match(/^#[0-9a-f]{3,6}$/i) ||
                      value.match(/^[a-z]*$/i)
                  ) ||
                  key === 'text-align' && (
                      value === 'left' ||
                      value === 'right' ||
                      value === 'center' ||
                      value === 'justify'
                  ) ||
                  key === 'float' && (
                      value === 'left' ||
                      value === 'right' ||
                      value === 'none'
                  ) ||
                  key === 'direction' && (
                      value === 'rtl' ||
                      value === 'ltr'
                  ) ||
                  key === 'font-family' && (
                      value === 'arial,helvetica,sans-serif' ||
                      value === 'georgia,serif' ||
                      value === 'impact,charcoal,sans-serif' ||
                      value === 'tahoma,geneva,sans-serif' ||
                      value === "'times new roman',times,serif" ||
                      value === 'verdana,geneva,sans-serif'
                  ) ||
                  (key === 'width' || key === 'height' || key === 'font-size' || key === 'margin-left') && (
                      value.match(/[0-9\.]*(px|em|rem|%)/)
                  )
              ) {
                  result += key + ': ' + value + ';';
              }
          }
      });
      return result;
  }
function validStyles ( styleAttr ) { var result = '' ; var styleArray = styleAttr . split ( ';' ) ; angular . forEach ( styleArray , function ( value ) { var v = value . split ( ':' ) ; if ( v . length === 2 ) { var key = trim ( v [ 0 ] . toLowerCase ( ) ) ; value = trim ( v [ 1 ] . toLowerCase ( ) ) ; if ( ( key === 'color' || key === 'background-color' ) && ( value . match ( / ^rgb\([0-9%,\. ]*\)$ / i ) || value . match ( / ^rgba\([0-9%,\. ]*\)$ / i ) || value . match ( / ^hsl\([0-9%,\. ]*\)$ / i ) || value . match ( / ^hsla\([0-9%,\. ]*\)$ / i ) || value . match ( / ^#[0-9a-f]{3,6}$ / i ) || value . match ( / ^[a-z]*$ / i ) ) || key === 'text-align' && ( value === 'left' || value === 'right' || value === 'center' || value === 'justify' ) || key === 'float' && ( value === 'left' || value === 'right' || value === 'none' ) || key === 'direction' && ( value === 'rtl' || value === 'ltr' ) || key === 'font-family' && ( value === 'arial,helvetica,sans-serif' || value === 'georgia,serif' || value === 'impact,charcoal,sans-serif' || value === 'tahoma,geneva,sans-serif' || value === "'times new roman',times,serif" || value === 'verdana,geneva,sans-serif' ) || ( key === 'width' || key === 'height' || key === 'font-size' || key === 'margin-left' ) && ( value . match ( / [0-9\.]*(px|em|rem|%) / ) ) ) { result += key + ': ' + value + ';' ; } } } ) ; return result ; }
Custom logic for accepting certain style options only - angularFroala Currently allows only the color, background-color, text-align, direction, font-family, font-size, float, width and height attributes all other attributes should be easily done through classes.
Custom logic for accepting certain style options only - angularFroala Currently allows only the color background - color text - align direction font - family font - size float width and height attributes all other attributes should be easily done through classes .