createlink-base.js revision 5cbdc947eb0c9c5e840d59ff8e1dd49a0e2a1887
266bfbd67fc220029bdadabd3c49e733f9f39360Luke Smith * Adds prompt style link creation. Adds an override for the <a href="Plugin.ExecCommand.html#method_COMMANDS.createlink">createlink execCommand</a>.
266bfbd67fc220029bdadabd3c49e733f9f39360Luke Smith * @module editor
266bfbd67fc220029bdadabd3c49e733f9f39360Luke Smith * @submodule createlink-base
266bfbd67fc220029bdadabd3c49e733f9f39360Luke Smith * Adds prompt style link creation. Adds an override for the <a href="Plugin.ExecCommand.html#method_COMMANDS.createlink">createlink execCommand</a>.
266bfbd67fc220029bdadabd3c49e733f9f39360Luke Smith * @class CreateLinkBase
266bfbd67fc220029bdadabd3c49e733f9f39360Luke Smith * @namespace Plugin
266bfbd67fc220029bdadabd3c49e733f9f39360Luke Smith * Strings used by the plugin
266bfbd67fc220029bdadabd3c49e733f9f39360Luke Smith * @property STRINGS
266bfbd67fc220029bdadabd3c49e733f9f39360Luke Smith * String used for the Prompt
266bfbd67fc220029bdadabd3c49e733f9f39360Luke Smith * @property PROMPT
266bfbd67fc220029bdadabd3c49e733f9f39360Luke Smith PROMPT: 'Please enter the URL for the link to point to:',
266bfbd67fc220029bdadabd3c49e733f9f39360Luke Smith * String used as the default value of the Prompt
266bfbd67fc220029bdadabd3c49e733f9f39360Luke Smith * @property DEFAULT
266bfbd67fc220029bdadabd3c49e733f9f39360Luke Smith * Override for the createlink method from the <a href="Plugin.CreateLinkBase.html">CreateLinkBase</a> plugin.
266bfbd67fc220029bdadabd3c49e733f9f39360Luke Smith * @for ExecCommand
266bfbd67fc220029bdadabd3c49e733f9f39360Luke Smith * @method COMMANDS.createlink
266bfbd67fc220029bdadabd3c49e733f9f39360Luke Smith * @param {String} cmd The command executed: createlink
266bfbd67fc220029bdadabd3c49e733f9f39360Luke Smith * @return {Node} Node instance of the item touched by this command.
266bfbd67fc220029bdadabd3c49e733f9f39360Luke Smith var inst = this.get('host').getInstance(), out, a, sel,
266bfbd67fc220029bdadabd3c49e733f9f39360Luke Smith url = prompt(CreateLinkBase.STRINGS.PROMPT, CreateLinkBase.STRINGS.DEFAULT);
266bfbd67fc220029bdadabd3c49e733f9f39360Luke Smith Y.log('Adding link: ' + url, 'info', 'createLinkBase');
266bfbd67fc220029bdadabd3c49e733f9f39360Luke Smith //We have a selection
266bfbd67fc220029bdadabd3c49e733f9f39360Luke Smith //No selection, insert a new node..
266bfbd67fc220029bdadabd3c49e733f9f39360Luke Smith this.get('host').execCommand('inserthtml', '<a href="' + url + '">' + url + '</a>');