title: Update/Replace inline image on Google Document
body: <p>I'm trying to set a feature to update images on a Google Document, the same way Lucidchart Add-on does on its "Updated inserted diagram" feature. For this, I'm current doing the following:</p>
  
  <ul>
  <li>Creating a Named Range and storing its id on document properties, together with the data to generate the image, for later retrieve.</li>
  <li>On update, call body.getNamedRangeById() and replace the element with the new generated image.</li>
  </ul>
  
  <p>This works, but I have the following problems that does not happen with Lucidchart:</p>
  
  <ul>
  <li>Every update, a blank line is added after the image.</li>
  <li>If the user drag and drop the image inside document for reposition it, the Named Range disappears and I'm not able to retrieve it later. </li>
  <li>If the user centralize the image, after update the image comes back to left position, even copying its attributes</li>
  </ul>
  
  <p>Does anybody knows a good strategy to replace/update a referenced image on Google Docs, the same way Lucidchart add-on update feature works?</p>
  
  <p>Thanks</p>