Whenever you click the edit button, you toggle the visibility.
Wouldn’t it be a good idea to changes the behaviour as follows:
Editor is hiden-> show editor
Editor is in foreground -> hide editor
Editor is not the foremost window -> bring editor to the top instead of closing it