lib/actions/update-image-size.js
function updateCSSNode(editor, srcProp, width, height) {
	const rule = srcProp.parent;
	const widthProp = getProperty(rule, 'width');
	const heightProp = getProperty(rule, 'height');

	// Detect formatting
	const separator = srcProp.separator || ': ';
	const before = getBefore(editor, srcProp);
	const insertOpt = { autoIndent: false };

	editor.transact(() => {
		// Apply changes from right to left, first for height, then for width

		if (!heightProp) {
			// no `height` property, add it right after `width` or source property
			editor.setCursorBufferPosition(widthProp ? widthProp.end : srcProp.end);
			editor.insertText(`${before}height${separator}${height}px;`, insertOpt);
		} else {
			editor.setTextInBufferRange(getRange(heightProp.valueToken), `${height}px`);
		}

		if (!widthProp) {
			// no `width` attribute, add it right after `height` or source property
			if (heightProp) {
				editor.setCursorBufferPosition(heightProp.previousSibling
					? heightProp.previousSibling.end
					: rule.contentStart.end);
			} else {
				editor.setCursorBufferPosition(srcProp.end);
			}
			editor.insertText(`${before}width${separator}${width}px;`, insertOpt);
		} else {
			editor.setTextInBufferRange(getRange(widthProp.valueToken), `${width}px`);
		}
	});
}
function updateCSSNode(editor, srcProp, width, height) {
	const rule = srcProp.parent;
	const widthProp = getProperty(rule, 'width');
	const heightProp = getProperty(rule, 'height');

	// Detect formatting
	const separator = srcProp.separator || ': ';
	const before = getBefore(editor, srcProp);
	const insertOpt = { autoIndent: false };

	editor.transact(() => {
		// Apply changes from right to left, first for height, then for width

		if (!heightProp) {
			// no `height` property, add it right after `width` or source property
			editor.setCursorBufferPosition(widthProp ? widthProp.end : srcProp.end);
			editor.insertText(`${before}height${separator}${height}px;`, insertOpt);
		} else {
			editor.setTextInBufferRange(getRange(heightProp.valueToken), `${height}px`);
		}

		if (!widthProp) {
			// no `width` attribute, add it right after `height` or source property
			if (heightProp) {
				editor.setCursorBufferPosition(heightProp.previousSibling
					? heightProp.previousSibling.end
					: rule.contentStart.end);
			} else {
				editor.setCursorBufferPosition(srcProp.end);
			}
			editor.insertText(`${before}width${separator}${width}px;`, insertOpt);
		} else {
			editor.setTextInBufferRange(getRange(widthProp.valueToken), `${width}px`);
		}
	});
}
function updateCSSNode ( editor , srcProp , width , height ) { const rule = srcProp . parent ; const widthProp = getProperty ( rule , 'width' ) ; const heightProp = getProperty ( rule , 'height' ) ; // Detect formatting const separator = srcProp . separator || ': ' ; const before = getBefore ( editor , srcProp ) ; const insertOpt = { autoIndent : false } ; editor . transact ( ( ) => { // Apply changes from right to left, first for height, then for width if ( ! heightProp ) { // no `height` property, add it right after `width` or source property editor . setCursorBufferPosition ( widthProp ? widthProp . end : srcProp . end ) ; editor . insertText ( ` ${ before } ${ separator } ${ height } ` , insertOpt ) ; } else { editor . setTextInBufferRange ( getRange ( heightProp . valueToken ) , ` ${ height } ` ) ; } if ( ! widthProp ) { // no `width` attribute, add it right after `height` or source property if ( heightProp ) { editor . setCursorBufferPosition ( heightProp . previousSibling ? heightProp . previousSibling . end : rule . contentStart . end ) ; } else { editor . setCursorBufferPosition ( srcProp . end ) ; } editor . insertText ( ` ${ before } ${ separator } ${ width } ` , insertOpt ) ; } else { editor . setTextInBufferRange ( getRange ( widthProp . valueToken ) , ` ${ width } ` ) ; } } ) ; }
Updates size of given CSS rule
@param  {TextEditor} editor
@param  {Node}       srcProp
@param  {Number}     width
@param  {Number}     height
Updates size of given CSS rule