Change document on extension init

Hello! Can i somehow write an extension which sets the editor document value on init? I want to pass the tree-document to extension and let it form the editor text from it. Maybe something what aplies transaction or sets editor document on start?

Thanks!