File tree Expand file tree Collapse file tree 4 files changed +103
-5
lines changed Expand file tree Collapse file tree 4 files changed +103
-5
lines changed Original file line number Diff line number Diff line change 22
33- added color palette
44- added version parser
5+ - added Transform to Responsive
56- updated tree by adding `Show this folder only`
67
78========================= 1.4
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -1067,7 +1067,96 @@ FUNC.colorize = function(css, cls) {
10671067 }
10681068 }
10691069
1070- return builder . join ( '\n' ) ;
1070+ var arr = [ ] ;
1071+ var prev = '' ;
1072+ for ( var i = 0 ; i < builder . length ; i ++ ) {
1073+ var line = builder [ i ] ;
1074+ if ( prev === line )
1075+ continue ;
1076+ prev = line ;
1077+ arr . push ( line ) ;
1078+ }
1079+
1080+ return arr . join ( '\n' ) ;
1081+ } ;
1082+
1083+ FUNC . responsive = function ( css ) {
1084+
1085+ var lines = css . split ( '\n' ) ;
1086+ var builder = [ ] ;
1087+
1088+ for ( var i = 0 ; i < lines . length ; i ++ ) {
1089+
1090+ var line = lines [ i ] ;
1091+
1092+ if ( ! line ) {
1093+ builder . push ( '' ) ;
1094+ continue ;
1095+ }
1096+
1097+ var beg = line . indexOf ( '{' ) ;
1098+ if ( beg === - 1 )
1099+ continue ;
1100+
1101+ var end = line . lastIndexOf ( '}' ) ;
1102+ if ( end === - 1 )
1103+ continue ;
1104+
1105+ var cmd = line . substring ( beg + 1 , end ) . split ( ';' ) ;
1106+ var cmdnew = [ ] ;
1107+
1108+ for ( var j = 0 ; j < cmd . length ; j ++ ) {
1109+ var c = cmd [ j ] . trim ( ) . split ( ':' ) . trim ( ) ;
1110+ switch ( c [ 0 ] ) {
1111+ case 'margin' :
1112+ case 'left' :
1113+ case 'top' :
1114+ case 'right' :
1115+ case 'bottom' :
1116+ case 'padding' :
1117+ case 'max-width' :
1118+ case 'max-height' :
1119+ case 'position' :
1120+ case 'z-index' :
1121+ case 'min-width' :
1122+ case 'min-height' :
1123+ case 'margin-left' :
1124+ case 'margin-top' :
1125+ case 'margin-right' :
1126+ case 'margin-bottom' :
1127+ case 'padding-left' :
1128+ case 'padding-top' :
1129+ case 'padding-right' :
1130+ case 'padding-bottom' :
1131+ case 'width' :
1132+ case 'font' :
1133+ case 'font-size' :
1134+ case 'line-height' :
1135+ case 'height' :
1136+ cmdnew . push ( c [ 0 ] + ': ' + c [ 1 ] ) ;
1137+ break ;
1138+ }
1139+ }
1140+ if ( cmdnew . length ) {
1141+ var selector = line . substring ( 0 , beg ) . trim ( ) ;
1142+ var sel = selector . split ( ',' ) . trim ( ) ;
1143+ for ( var k = 0 ; k < sel . length ; k ++ )
1144+ sel [ k ] = sel [ k ] . trim ( ) . replace ( / \s { 2 , } / g, ' ' ) ;
1145+ builder . push ( sel . join ( ', ' ) + ' { ' + cmdnew . join ( '; ' ) + '; }' ) ;
1146+ }
1147+ }
1148+
1149+ var arr = [ ] ;
1150+ var prev = '' ;
1151+ for ( var i = 0 ; i < builder . length ; i ++ ) {
1152+ var line = builder [ i ] ;
1153+ if ( prev === line )
1154+ continue ;
1155+ prev = line ;
1156+ arr . push ( line ) ;
1157+ }
1158+
1159+ return arr . join ( '\n' ) ;
10711160} ;
10721161
10731162FUNC . makejsonfromschema = function ( val ) {
Original file line number Diff line number Diff line change 648648 tools . push ( { name : '@(Parse keys)' , icon : 'barcode' , value : 'parsekeys' } ) ;
649649
650650 if ( ( code . current . ext === 'css' || code . current . ext === 'html' ) && ( / \: ( \s ) ? # | # \w { 6 } | c o l o r \: / ) . test ( text ) )
651- items . push ( { name : '@(Transform for Dark mode)' , icon : 'tint' , value : 'darkmode' } ) ;
651+ items . push ( { name : '@(Transform to Dark mode)' , icon : 'tint' , value : 'darkmode' } ) ;
652652
653- if ( ( / ( # ) ? [ A - F 0 - 9 ] { 6 } / i) . test ( text ) )
653+ if ( ( code . current . ext === 'css' || code . current . ext === 'html' ) )
654+ items . push ( { name : '@(Transform to Responsive)' , icon : 'tablet' , value : 'responsive' } ) ;
655+
656+ if ( ( / ( # ) ? [ A - F 0 - 9 ] { 6 } / i) . test ( text ) && text . indexOf ( '\n' ) === - 1 )
654657 items . push ( { name : '@(Convert to RGBA)' , icon : 'palette' , value : 'hex2rgba' } ) ;
655658
656659 if ( ( ( / \d + , ( \s ) ? \d + , ( \s ) ? \d + / i) ) . test ( text ) )
867870 return ;
868871 }
869872
873+ if ( value . value === 'responsive' ) {
874+ editor . replaceSelection ( FUNC . responsive ( text ) ) ;
875+ return ;
876+ }
877+
870878 if ( value . value === 'removedarkmode' ) {
871879 editor . replaceSelection ( FUNC . removecssclass ( '.ui-dark' , text ) ) ;
872880 return ;
You can’t perform that action at this time.
0 commit comments