Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style/functionality fixes #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<img src=' + url + '>', options.attributes);

scribe.api.SimpleCommand.prototype.execute.call(this, html);
}
};

scribe.commands.imagePrompt = imagePromptCommand;
};
Expand All @@ -51,4 +51,4 @@ function addAttributes (html, attrs) {
}

return host.innerHTML;
}
}