diff --git a/src/main.js b/src/main.js index 1593310..03207bf 100644 --- a/src/main.js +++ b/src/main.js @@ -10,32 +10,32 @@ var extend = require('extend'); */ module.exports = function (options, prompt) { return function (scribe) { - var imagePromptCommand = new scribe.api.Command('insertImage'); + var imagePromptCommand = new scribe.api.Command('insertHTML'); imagePromptCommand.nodeName = 'IMG'; if (typeof options == 'function') { prompt = options; - }; + } imagePromptCommand.execute = function () { - link = prompt ? prompt() : window.prompt('Enter image url'); + var link = prompt ? prompt() : window.prompt('Enter image url'); if (!link) return false; if (typeof link === 'object') { // If some extra properties were passed from prompt options = extend(options, link); } else if (typeof link === 'string') { - options.url = link - }; + options.url = link; + } if (!/^https?\:\/\//.test(options.url)) { options.url = location.protocol + '//' + options.url; - }; + } var url = options.url; var html = addAttributes('', options.attributes); scribe.api.SimpleCommand.prototype.execute.call(this, html); - } + }; scribe.commands.imagePrompt = imagePromptCommand; }; @@ -51,4 +51,4 @@ function addAttributes (html, attrs) { } return host.innerHTML; -} \ No newline at end of file +}