title: Medium.js in React.js component using invokeElement
body: <p>I am making a simple MediumEditor component in React.js. I am basing the component on the <a href="http://jakiestfu.github.io/Medium.js/docs/#invoke" rel="nofollow">invoke demo</a> from the Medium.js page. My problem is that my call to invokeElement is effecting the entire content of my editable element not the selection content. The example on the docs page has a call to medium.select() before the call to invokeElement. Here is my version:</p>
  
  <pre><code>componentDidMount: function() {
    var editor = this.refs.editor.getDOMNode();
    var medium = new Medium({
      element: editor,
      mode: Medium.richMode,
      attributes: null,
      tags: null,
      pastAsText: false
    });
  
    this.editor = editor;
    this.medium = medium;
    this.refs.editor.getDOMNode().focus();
  },
  
  highlight: function() {
    if(document.activeElement !== this.editor) {
      this.medium.select();
    }
  },
  
  setMode: function(mode) {   
    this.highlight();
    if(mode == 'bold') {
      this.medium.invokeElement('b', {
        title: "I'm bold!",
        style: "color: #66d9ef"
      });
    } else if(mode == 'underline') {
      this.medium.invokeElement('u', {
        title: "I'm underlined!",
        style: "color: #a6e22e"
      });
    } else if(mode == 'italic') {
      this.medium.invokeElement('i', {
        title: "I'm italics!",
        style: "color: #f92672"
      });
    }
  },
  </code></pre>
  
  <p>I then attach setMode to each of my style buttons (bold, italic, underline). When I use the above code all of the editable element's content is changed not just the selection content. When I look at the source for medium.js I see that select() does select all so this seems like it shouldn't be called before invokeElement is called for selected content. When I remove the highlight call nothing happens...</p>
  
  <p>This seems like a strange setup and the docs don't explain any of this from what i can find. What is the correct way to invokeElement on selected content? Any information related to using medium.js with React.js appreciated as well.</p>