lib/resolver/cssGradient.js
function(editor, syntax) {
			var propertyName = prefs.get('css.gradient.defaultProperty');
			var omitDir = prefs.get('css.gradient.omitDefaultDirection');
			
			if (!propertyName) {
				return false;
			}
			
			// assuming that gradient definition is written on new line,
			// do a simplified parsing
			var content = String(editor.getContent());
			/** @type Range */
			var lineRange = range.create(editor.getCurrentLineRange());
			
			// get line content and adjust range with padding
			var line = lineRange.substring(content)
				.replace(/^\s+/, function(pad) {
					lineRange.start += pad.length;
					return '';
				})
				.replace(/\s+$/, function(pad) {
					lineRange.end -= pad.length;
					return '';
				});

			// trick parser: make it think that we’re parsing actual CSS property
			var fakeCSS = 'a{' + propertyName + ': ' + line + ';}';
			var gradients = this.gradientsFromCSSProperty(fakeCSS, fakeCSS.length - 2);
			if (gradients) {
				var props = getPropertiesForGradient(gradients.gradients, gradients.property);
				props.push({
					name: gradients.property.name(),
					value: insertGradientsIntoCSSValue(gradients.gradients, gradients.property.value(), {
						placeholder: '${2}',
						omitDefaultDirection: omitDir
					})
				});
				
				var sep = cssResolver.getSyntaxPreference('valueSeparator', syntax);
				var end = cssResolver.getSyntaxPreference('propertyEnd', syntax);
				
				if (prefs.get('css.alignVendor')) {
					var pads = utils.getStringsPads(props.map(function(prop) {
						return prop.value.substring(0, prop.value.indexOf('('));
					}));
					props.forEach(function(prop, i) {
						prop.value = pads[i] + prop.value;
					});
				}
				
				props = props.map(function(item) {
					return item.name + sep + item.value + end;
				});
				
				editor.replaceContent(props.join('\n'), lineRange.start, lineRange.end);
				return true;
			}
			
			return false;
		}
function(editor, syntax) {
			var propertyName = prefs.get('css.gradient.defaultProperty');
			var omitDir = prefs.get('css.gradient.omitDefaultDirection');
			
			if (!propertyName) {
				return false;
			}
			
			// assuming that gradient definition is written on new line,
			// do a simplified parsing
			var content = String(editor.getContent());
			/** @type Range */
			var lineRange = range.create(editor.getCurrentLineRange());
			
			// get line content and adjust range with padding
			var line = lineRange.substring(content)
				.replace(/^\s+/, function(pad) {
					lineRange.start += pad.length;
					return '';
				})
				.replace(/\s+$/, function(pad) {
					lineRange.end -= pad.length;
					return '';
				});

			// trick parser: make it think that we’re parsing actual CSS property
			var fakeCSS = 'a{' + propertyName + ': ' + line + ';}';
			var gradients = this.gradientsFromCSSProperty(fakeCSS, fakeCSS.length - 2);
			if (gradients) {
				var props = getPropertiesForGradient(gradients.gradients, gradients.property);
				props.push({
					name: gradients.property.name(),
					value: insertGradientsIntoCSSValue(gradients.gradients, gradients.property.value(), {
						placeholder: '${2}',
						omitDefaultDirection: omitDir
					})
				});
				
				var sep = cssResolver.getSyntaxPreference('valueSeparator', syntax);
				var end = cssResolver.getSyntaxPreference('propertyEnd', syntax);
				
				if (prefs.get('css.alignVendor')) {
					var pads = utils.getStringsPads(props.map(function(prop) {
						return prop.value.substring(0, prop.value.indexOf('('));
					}));
					props.forEach(function(prop, i) {
						prop.value = pads[i] + prop.value;
					});
				}
				
				props = props.map(function(item) {
					return item.name + sep + item.value + end;
				});
				
				editor.replaceContent(props.join('\n'), lineRange.start, lineRange.end);
				return true;
			}
			
			return false;
		}
function ( editor , syntax ) { var propertyName = prefs . get ( 'css.gradient.defaultProperty' ) ; var omitDir = prefs . get ( 'css.gradient.omitDefaultDirection' ) ; if ( ! propertyName ) { return false ; } // assuming that gradient definition is written on new line, // do a simplified parsing var content = String ( editor . getContent ( ) ) ; /** @type Range */ var lineRange = range . create ( editor . getCurrentLineRange ( ) ) ; // get line content and adjust range with padding var line = lineRange . substring ( content ) . replace ( / ^\s+ / , function ( pad ) { lineRange . start += pad . length ; return '' ; } ) . replace ( / \s+$ / , function ( pad ) { lineRange . end -= pad . length ; return '' ; } ) ; // trick parser: make it think that we’re parsing actual CSS property var fakeCSS = 'a{' + propertyName + ': ' + line + ';}' ; var gradients = this . gradientsFromCSSProperty ( fakeCSS , fakeCSS . length - 2 ) ; if ( gradients ) { var props = getPropertiesForGradient ( gradients . gradients , gradients . property ) ; props . push ( { name : gradients . property . name ( ) , value : insertGradientsIntoCSSValue ( gradients . gradients , gradients . property . value ( ) , { placeholder : '${2}' , omitDefaultDirection : omitDir } ) } ) ; var sep = cssResolver . getSyntaxPreference ( 'valueSeparator' , syntax ) ; var end = cssResolver . getSyntaxPreference ( 'propertyEnd' , syntax ) ; if ( prefs . get ( 'css.alignVendor' ) ) { var pads = utils . getStringsPads ( props . map ( function ( prop ) { return prop . value . substring ( 0 , prop . value . indexOf ( '(' ) ) ; } ) ) ; props . forEach ( function ( prop , i ) { prop . value = pads [ i ] + prop . value ; } ) ; } props = props . map ( function ( item ) { return item . name + sep + item . value + end ; } ) ; editor . replaceContent ( props . join ( '\n' ) , lineRange . start , lineRange . end ) ; return true ; } return false ; }
Tries to expand gradient outside CSS value
@param {IEmmetEditor} editor
@param {String} syntax
Tries to expand gradient outside CSS value