title: Set SelectionState for entity when clicked
body: <p>I have a case where I can click on an entity, and then select new content to replace the entire entity. For example:</p>
  
  <pre><code>Here is some text [special entity] and some more text
                         ^ click anywhere inside the brackets
  </code></pre>
  
  <p>After choosing new content, it replaces the old entity text and becomes:</p>
  
  <pre><code>Here is some text [my new entity] and some more text
  </code></pre>
  
  <p>Basically, I'm trying to do:</p>
  
  <pre><code>const newSelectionState = SelectionState.createEmpty(key).merge({
    anchorOffset: entityStart,
    focusOffset: entityEnd
  });
  </code></pre>
  
  <p>I've tried using <code>currentContentState.getSelectionBefore(key).getStartOffset()</code> and <code>currentContentState.getSelectionAfter(key).getStartOffset()</code> but the values seem unreliable.</p>
  
  <p>How should I get the proper start and end offsets for the entity? Or, is there a better way to approach this problem?</p>