Many thanks for that.
I was hoping I could do away with the native events, as the host DOM is a direct part of the application. Particularly since there are a lot of things in InDesign that will not trigger events, like changes to the paragraph styles. I’ve used setInterval to pool ID for changes:
Is that horrible? Sorry, I’m a react noob.
Also, I must confess my complete ignorance on the AFTER_CONTEXT_CHANGED event. What does it actually do? When is it triggered? The documentation only mentions Dispatched after the active context changes. This event bubbles. This event is not cancelable. What is the active context? I never used that event before.
After all, InDesign features are handled within InDesign, and they remain the same even with UXP.
If there is no other option but to use setInterval, then there’s no choice but to do so. It seems like it might also be achievable with AFTER_UPDATE or similar events, but you are probably more knowledgeable about that than I am.
It appears that AFTER_CONTEXT_CHANGED is triggered when the focus of the document is changed.