I'm trying to write a script that puts the cursor's surrounding text to uppercase and set the enclosing paragraph to HEADING1. I'm able to do the first thing while I can't figure out the way to get the paragraph containing the cursor using the getCursor() method. Here is what I tried:
var cursor = DocumentApp.getActiveDocument().getCursor();
var element = cursor.getElement();
var paragraph = element.asParagraph();
However, element is a TEXT element and can't be cast as PARAGRAPH. Is there a way to get the paragraph from the text element?
Thanks.