When is the view function called?

According to the documentation, the view function declared in the PluginSpec interface is called when the plugin’s state is associated with an editor view.

I wonder what “is associated” means in this context.

Also, when exactly is the view function called?

Thank you.

When a view is created with this plugin active, or when a view is reconfigured and this plugin becomes active.

Thank you.

Could you explain it from the perspective of the plugin’s state?

The plugin state is orthogonal to the view part. The update method will be called when the plugin’s state is updated ( so you can react to state changes and do things in the DOM for ex. ) and you can also send transactions from the update method. You can communicate back and forth, I’d also add that this is rarely needed, most things people want to do are achievable with a Decoration.