lib/action/base64.js
function decodeFromBase64(editor, filePath, data, pos) {
		// ask user to enter path to file
		filePath = filePath || String(editor.prompt('Enter path to file (absolute or relative)'));
		if (!filePath) {
			return false;
		}

		var editorFile = editor.getFilePath();
		file.createPath(editorFile, filePath, function(err, absPath) {
			if (err || !absPath) {
				throw "Can't save file";
			}

			var content = data.replace(/^data\:.+?;.+?,/, '');
			file.save(absPath, base64.decode(content), function(err) {
				if (err) {
					throw 'Unable to save ' + absPath + ': ' + err;
				}

				editor.replaceContent('$0' + filePath, pos, pos + data.length);
			});
		});

		return true;
	}
function decodeFromBase64(editor, filePath, data, pos) {
		// ask user to enter path to file
		filePath = filePath || String(editor.prompt('Enter path to file (absolute or relative)'));
		if (!filePath) {
			return false;
		}

		var editorFile = editor.getFilePath();
		file.createPath(editorFile, filePath, function(err, absPath) {
			if (err || !absPath) {
				throw "Can't save file";
			}

			var content = data.replace(/^data\:.+?;.+?,/, '');
			file.save(absPath, base64.decode(content), function(err) {
				if (err) {
					throw 'Unable to save ' + absPath + ': ' + err;
				}

				editor.replaceContent('$0' + filePath, pos, pos + data.length);
			});
		});

		return true;
	}
function decodeFromBase64 ( editor , filePath , data , pos ) { // ask user to enter path to file filePath = filePath || String ( editor . prompt ( 'Enter path to file (absolute or relative)' ) ) ; if ( ! filePath ) { return false ; } var editorFile = editor . getFilePath ( ) ; file . createPath ( editorFile , filePath , function ( err , absPath ) { if ( err || ! absPath ) { throw "Can't save file" ; } var content = data . replace ( / ^data\:.+?;.+?, / , '' ) ; file . save ( absPath , base64 . decode ( content ) , function ( err ) { if ( err ) { throw 'Unable to save ' + absPath + ': ' + err ; } editor . replaceContent ( '$0' + filePath , pos , pos + data . length ) ; } ) ; } ) ; return true ; }
Decodes base64 string back to file.
@param {IEmmetEditor} editor
@param {String} filePath to new image
@param {String} data Base64-encoded file content
@param {Number} pos Caret position where image is located in the editor
Decodes base64 string back to file .