tags:

views:

309

answers:

1

I'm currently using TinyMCE and would like to add a custom button that works as follows:

  1. User highlights text in the text-editior
  2. User clicks the custom button X
  3. The text (dog walking) is wrapped with a tag (dog walking)

Any ideas on if this can be done? I've figured out how to make a custom button inject text, but not wrap text... Here is the current code:

// Add a custom button ed.addButton('mybutton', { title : 'My button', 'class' : 'MyCoolBtn', image : 'MyCoolBtn.png', onclick : function() { // Add you own code to execute something on click ed.focus(); ed.selection.setContent('Hello world!'); } });


thanks!

A: 
    ed.addButton('mybutton', 
{ title : 'My button', 
'class' : 'MyCoolBtn', 
image : 'MyCoolBtn.png', 
onclick : function() { 
// Add you own code to execute something on click 
ed.focus(); 
ed.selection.setContent('<tag>' + ed.selection.getContent() + '</tag>'); } });
THOmas