title: Having cursor, how to insert (not append) a paragraph in Google Doc
body: <p>I'm coding a simple google script for a Google Doc sidebar and I'm facing the following problem: I have to insert some text where cursor is located</p>
  
  <p>That text needs to be a paragraph as it is an specific code that must be separated from other text. Next is the code (working)</p>
  
  <pre><code>function insertText(actionObject) {
    var cursor = DocumentApp.getActiveDocument().getCursor();
  
    var stringToInsert = "\nblablabla";
  
    cursor.insertText(stringToInsert);
  }
  </code></pre>
  
  <p>Problem is that Google replaces <code>\n</code> with <code>\r</code>, so it is just a break line, but not a paragraph. This means, that my code works, but not as expected from technical point of view.</p>
  
  <p>I cannot use appendParagraph function as it always adds it at the end of the file (and it could be needed to add that paragraph in the middle of the file).</p>
  
  <p>SO, I have to use the <code>insertParagraph(childIndex, paragraph)</code> method available for Body object. But having the cursor, I'm not able to find a way that allows me to find out my current paragraph position and insert a new one just before...</p>
  
  <p>Could anybody help me on this?</p>
  
  <p>Thanks in advance!!</p>