title: TinyMCE - custom link button - "add link" is fine, but can't find any documentation for "edit link" and accessing link attributes
body: <p>I've added a custom button to TinyMCE which brings up a bespoke link-picker. When the user selects some text and clicks the button the dialog appears and when they've picked the url I'm using <code>execCommand('insertHTML', false, "&lt;a href... etc"&gt;)</code> on the selection.</p>
  
  <p>This works fine - now, when the link has already been created, and the user wants to edit it, they click the link button again (when the cursor is inside the linked text as normal), but then here is the situation - I don't know how to access the already created link and it's attributes to then load up and populate the dialogue again!</p>
  
  <p>Have search TinyMCE site, Stack, Google in general. Hoping for (and also slightly dreading) a simple answer - but if not, a complex one will be fine!! </p>
  
  <p>If anybody knows the answer or can point me to it, I'd be extremely grateful. Thanks in advance,
  Rob</p>
  
  <p><strong>EDIT - bits of my code to explain need</strong></p>
  
  <p>In the TinyMCE init:</p>
  
  <pre><code>setup: function (ed) {
      ed.addButton("link", {
          title: "Link",
          onclick: function (evt) {
              Intranet.TextEditor._loadUrlDialog(jQueryTextAreaObject, evt);
          }
      });
  }
  </code></pre>
  
  <p>The function which is called above:</p>
  
  <pre><code>_loadUrlDialog: function (jQueryTextAreaObject, clickEvent) {
  
      var mce = $(jQueryTextAreaObject).tinymce();
  
      var isSelected = mce.selection.getContent().length != 0 ? true : false;
  
      if (isSelected) {
          Intranet.UrlDialog.Fn.LoadDialog("", true, "", function (url, target, title) {
  
              var theTarget = target == false ? "_self" : "_blank";
  
              var link = "&lt;a href=\"" + url + "\" target=\"" + theTarget + "\" title=\"" + title + "\"&gt;" + mce.selection.getContent() + "&lt;/a&gt;";
  
              mce.execCommand('insertHTML', false, link); // creates new link
  
          });
      }
      else {
          /// THIS IS THE MISSING BIT!
      };
  }
  </code></pre>