Opening a LN plugin in the sidebar when the user is selecting an email which contains a specific URL

Hello there!

We are developing a plugin/widget that displays a specific html page when the plugin is opened by the user and when the user is selecting a document which contains a specific URL.

This is done by setting a document selection listener with DocumentContextService.getDefault().addListener()

The problem is that the document selection event is received by our plugin, when it’s opened. When it’s closed, the view part does not get this event. By closed I mean that, for example, the SameTime plugin is showing and our plugin is “collapsed” at the bottom.

Does anybody have an idea how this feature can be implemented?