Just started working with Google-apps-script and for the most part it is pretty straight forward. I am having trouble though being able to get the current word the user is typing / where the cursor is.
ie, if | represents my cursor and I was typing the word "hello" and was in this state hello| I want to return hello as a string.
I've tried many variations to get this, but can't seem to find how in the api.
var doc = DocumentApp.getActiveDocument();
var word = doc.getCursor().getElement().asText().getText();
If I had hello all| (cursor at the end of all) I'd get the entire string 'hello all' back. I am hoping there is a way to just pick off the last element (after the last space).
Thanks in advance!