Using GAS, I'm trying to navigate paragraphs in a google doc and record their starting position so that I can display an interactive navigation menu in a sidebar. But I can't find any GAS method that returns the position of a paragraph (or an element for that matter), except when the cursor is within that paragraph. I thought of inserting bookmarks to retrieve their positions, but it seems that one cannot insert a bookmark without having first a position…
Am I missing anything?
Note that I'm aware of the fact that headings have hash locations (except for normal paragraphs) that are easy to retrieve using a TOC; but I can't use these hash locations directly in any GAS add-on, because the caja compiler prevents it. Besides, I'd like to list more than headings in my navigation menu.