How to set documents initial value from plugin

Hello, I’m quite new and I’m making ProseMirror plugins.

When the plug-in is initialized, I want to change the initial value of the document and inital value will be fetched from server.

After some research I found that many people used the view.updateState function to do same thing. But I want to do it within the Plugin.state.init function. Is there a good way?

I don’t think you can change editorState from plugin.state.init since you only have access to editorState in that function, and can’t directly mutate that.

Thanks for your response. If so, is there any other way that the plugin can set the initial value of the document?

You would have to use the view field of a plugin. Although I feel like for your use case, why not reset the editor entirely?

I thought I could do within plugin and I think it’s a right way to do it like you said. Thank you!