title: How to test if selected text is a link?
body: <p>I have a very simple WYSIWYG editor using contenteditable. It works fine, but I want to test if the selected text is being used as a link.  When I use document.queryCommandState('CreateLink'), it always returns false, even if the text is within an anchor.  Example below.</p>
  
  <p>Am I doing this wrong, or is there another way to test if the text is currently used as a link?</p>
  
  <pre><code>&lt;script&gt;
      function testLink () {
  
          // check if this is a link
          var state = document.queryCommandState('CreateLink');
          alert(state);
  
          // create the link
          document.execCommand ('CreateLink', false, 'http://www.example.com');
      }
  &lt;/script&gt;
  
  &lt;div contenteditable="true"&gt;Here is some sample text to test with.&lt;/div&gt;
  &lt;br /&gt;&lt;br /&gt;
  &lt;button onclick="testLink();"&gt;Test the state of the create link command&lt;/button&gt;
  </code></pre>