Is there a way to call a function when user click on a contentControl or highlighted text in Office-js?
I am working on add-in for MS word, and I have inserted content controls which will be linked with a list in my add-in panel. When I click on list item from add-in, I am able to highlight the text in word document and also able to focus on it.
Now, I want to do the other way around, when I click the highlighted text in word document, a click event should be triggered, and list should be scrolled to the corresponding list item from add-in and highlight it.
I have tried some solutions from this post: MS Word JavaScript API - event handler for Content Controls
I am using typescript and react in add-in development.
You may be interested in the onSelectionChanged event which is fired when selection within the content control is changed. Note, this event is provided as in preview and not availble in a production environment yet.
There are no other events for that. You can post or vote for an existing feature request on Tech Community where they are considered when the Office dev team goes through the planning process.