What you want doesn’t really make much sense to me, but here is a shot.
The API for focusing on element is
But then, since there are already texts in the textarea, it will focus to the end of the text, which is bottom. So, if you want to scroll back to the top, you need scroll API.
Scrolling API for vanilla JS is
.scrollTo(x, y) (there are a couple more)
So, if you add
the editor will scroll to the top. But why is this important? If you do this, users won’t know that their keyboard is sitting on the textarea. If users knew this, then the textarea will scroll to the bottom as soon as they start typing because the focus has been set. So, what’s the point of giving focus to editor and scrolling the editor to the top?
As for the page, it starts from the top by default. So, I don’t see the point of adding code to scroll to the top.
Anyway, you can do this to set the page to top.