CmdUtils.CreateCommand({ names: ["HTML Tag"], arguments: [ {role: 'object', nountype: ["a", "b", "em", "i", "h1", "h2", "h3", "br", "li", "p", "strong", "small", "td", "th", "u"], label: 'HTML tag to insert'}, {role: "instrument", nountype: noun_arb_text, label: "URL for href link"}], description: "Wraps selection around entered HTML tag", author: { name: "Bhagwad", email: "bhagwad@yahoo.com"}, license: "MPL", help: "Make a selection on the screen, call ubiquity and enter the type of tag you want to surround it with", preview: function(pblock, {object: {text}}){ pblock.innerHTML ="Enter the tag you want to insert"; }, execute: function(args) { var me = this; var selection = CmdUtils.getSelection(); //Check if the HTML tag is if (args.object.text=="a") { if ( Utils.clipboard.text != '') { var result = "<a href=""+Utils.clipboard.text+"">"+selection+"</"+args.object.text+">"; } else { var result = "<a href=""+args.instrument.text+"">"+selection+"</"+args.object.text+">"; } } else { var result= "<"+args.object.text+">"+CmdUtils.getSelection()+"</"+args.object.text+">" } CmdUtils.setSelection(result); }, preview: function(pblock, args) { var selection = CmdUtils.getSelection(); if (args.object.text=="a") { if ( Utils.clipboard.text != '') { var result = "<a href=""+Utils.clipboard.text+"">"+selection+"</"+args.object.text+">"; } else { var result = "<a href=""+args.instrument.text+"">"+selection+"</"+args.object.text+">"; } } else { var result= "<"+args.object.text+">"+CmdUtils.getSelection()+"</"+args.object.text+">" } pblock.innerHTML = "Inserts " + result; }, });