tiff / wysihtml5

Open source rich text editor based on HTML5 and the progressive-enhancement approach. Uses a sophisticated security concept and aims to generate fully valid HTML5 markup by preventing unmaintainable tag soups and inline styles.
http://xing.github.com/wysihtml5/
MIT License
6.49k stars 1k forks source link

How do you add a custom class to a link, using createLink? #483

Open seanhinton opened 10 years ago

seanhinton commented 10 years ago

So we know how to add custom classes to inline and/or block elements like this...

wysihtml5.commands.customH1 = {
  exec: function(composer, command, className) {
    return wysihtml5.commands.formatBlock.exec(composer, command, "h1", className, CLASS_REGEXP);
  },
  state: function(composer, command, className) {
    return wysihtml5.commands.formatBlock.state(composer, command, "h1", className, CLASS_REGEXP);
  }
};

However how do you add a custom class to a link, there's not enough params to hook in a class name in the createLink command, it just has three params like so:

exec: function(composer, command, value) {

So how would you go about creating a command that has a link with a class on it?