lib/actions/update-image-size.js
function updateImageSizeCSS(editor, model) {
	const pos = editor.getCursorBufferPosition();
	const property = getImageCSSNode(editor, model, pos);
	const urlToken = findUrlToken(property, pos);
	const src = urlToken && getImageSrcCSS(urlToken);

	if (!src) {
		return Promise.reject(new Error('No valid image source'));
	}

	locateFile(editor, src)
	.then(getImageSize)
	.then(size => {
		// since this action is asynchronous, we have to ensure that editor wasn’t
		// changed and user didn’t moved caret outside <img> node
		if (getImageCSSNode(editor, model, pos) === property) {
			updateCSSNode(editor, property, size.width, size.height);
		}
	})
	.catch(err => console.warn('Error while updating image size:', err));
}
function updateImageSizeCSS(editor, model) {
	const pos = editor.getCursorBufferPosition();
	const property = getImageCSSNode(editor, model, pos);
	const urlToken = findUrlToken(property, pos);
	const src = urlToken && getImageSrcCSS(urlToken);

	if (!src) {
		return Promise.reject(new Error('No valid image source'));
	}

	locateFile(editor, src)
	.then(getImageSize)
	.then(size => {
		// since this action is asynchronous, we have to ensure that editor wasn’t
		// changed and user didn’t moved caret outside <img> node
		if (getImageCSSNode(editor, model, pos) === property) {
			updateCSSNode(editor, property, size.width, size.height);
		}
	})
	.catch(err => console.warn('Error while updating image size:', err));
}
function updateImageSizeCSS ( editor , model ) { const pos = editor . getCursorBufferPosition ( ) ; const property = getImageCSSNode ( editor , model , pos ) ; const urlToken = findUrlToken ( property , pos ) ; const src = urlToken && getImageSrcCSS ( urlToken ) ; if ( ! src ) { return Promise . reject ( new Error ( 'No valid image source' ) ) ; } locateFile ( editor , src ) . then ( getImageSize ) . then ( size => { // since this action is asynchronous, we have to ensure that editor wasn’t // changed and user didn’t moved caret outside <img> node if ( getImageCSSNode ( editor , model , pos ) === property ) { updateCSSNode ( editor , property , size . width , size . height ) ; } } ) . catch ( err => console . warn ( 'Error while updating image size:' , err ) ) ; }
Updates image size of context rule of stylesheet model
@param  {TextEditor}  editor
@param  {SyntaxModel} model
@return {Promise}
Updates image size of context rule of stylesheet model