lib/actions/update-image-size.js
function updateHTMLTag(editor, node, width, height) {
	const srcAttr = getAttribute(node, 'src');
	const widthAttr = getAttribute(node, 'width');
	const heightAttr = getAttribute(node, 'height');

	editor.transact(() => {
		// apply changes from right to left, first for height, then for width
		let point;
		const quote = getAttributeQuote(editor, widthAttr || heightAttr || srcAttr);

		if (!heightAttr) {
			// no `height` attribute, add it right after `width` or `src`
			point = widthAttr ? widthAttr.end : srcAttr.end;
			editor.setTextInBufferRange([point, point], ` height=${quote}${height}${quote}`);
		} else {
			editor.setTextInBufferRange(getRange(heightAttr.value), String(height));
		}

		if (!widthAttr) {
			// no `width` attribute, add it right before `height` or after `src`
			point = heightAttr ? heightAttr.start : srcAttr.end;
			editor.setTextInBufferRange([point, point], `${!heightAttr ? ' ' : ''}width=${quote}${width}${quote}${heightAttr ? ' ' : ''}`);
		} else {
			editor.setTextInBufferRange(getRange(widthAttr.value), String(width));
		}
	});
}
function updateHTMLTag(editor, node, width, height) {
	const srcAttr = getAttribute(node, 'src');
	const widthAttr = getAttribute(node, 'width');
	const heightAttr = getAttribute(node, 'height');

	editor.transact(() => {
		// apply changes from right to left, first for height, then for width
		let point;
		const quote = getAttributeQuote(editor, widthAttr || heightAttr || srcAttr);

		if (!heightAttr) {
			// no `height` attribute, add it right after `width` or `src`
			point = widthAttr ? widthAttr.end : srcAttr.end;
			editor.setTextInBufferRange([point, point], ` height=${quote}${height}${quote}`);
		} else {
			editor.setTextInBufferRange(getRange(heightAttr.value), String(height));
		}

		if (!widthAttr) {
			// no `width` attribute, add it right before `height` or after `src`
			point = heightAttr ? heightAttr.start : srcAttr.end;
			editor.setTextInBufferRange([point, point], `${!heightAttr ? ' ' : ''}width=${quote}${width}${quote}${heightAttr ? ' ' : ''}`);
		} else {
			editor.setTextInBufferRange(getRange(widthAttr.value), String(width));
		}
	});
}
function updateHTMLTag ( editor , node , width , height ) { const srcAttr = getAttribute ( node , 'src' ) ; const widthAttr = getAttribute ( node , 'width' ) ; const heightAttr = getAttribute ( node , 'height' ) ; editor . transact ( ( ) => { // apply changes from right to left, first for height, then for width let point ; const quote = getAttributeQuote ( editor , widthAttr || heightAttr || srcAttr ) ; if ( ! heightAttr ) { // no `height` attribute, add it right after `width` or `src` point = widthAttr ? widthAttr . end : srcAttr . end ; editor . setTextInBufferRange ( [ point , point ] , ` ${ quote } ${ height } ${ quote } ` ) ; } else { editor . setTextInBufferRange ( getRange ( heightAttr . value ) , String ( height ) ) ; } if ( ! widthAttr ) { // no `width` attribute, add it right before `height` or after `src` point = heightAttr ? heightAttr . start : srcAttr . end ; editor . setTextInBufferRange ( [ point , point ] , ` ${ ! heightAttr ? ' ' : '' } ${ quote } ${ width } ${ quote } ${ heightAttr ? ' ' : '' } ` ) ; } else { editor . setTextInBufferRange ( getRange ( widthAttr . value ) , String ( width ) ) ; } } ) ; }
Updates size of given HTML node
@param  {TextEditor} editor
@param  {Node}       node
@param  {Number}     width
@param  {Number}     height
Updates size of given HTML node