In general, I want to recreate the Insert>Bookmark on Google docs with a custom function upon bookmarking an element (all types of elements).
Now my issue is on bookmarking the Date element. I am getting
TypeError: Cannot read property 'getRangeElements' of null
My current code for bookmarking Date element was something like this
selection.getRangeElements().forEach(e => {
const elmnt = e.getElement();
const type = elmnt.getType();
if( type == DocumentApp.ElementType.DATE ){
bookmarked = doc.addBookmark( doc.newPosition(elmnt.asDate().getParent(), 1) )
}
}); ```
