Advice needed building a Typewriter mode plugin

Hi, I had a little play with the developer tools and figured out that a Typewriter mode in the markdown editor can be implemented by calling:

document.querySelector(".CodeMirror-scroll").scroll(0, CodeMirrorScroll.scrollHeight);

any time a size change or "Enter" is detected on this element:

var LastRow = document.querySelector(".CodeMirror-code .CodeMirror-line:last-child span");

The markdown editor is not a regular text area and I am not sure how to constantly monitor size changes or "Enter" presses on LastRow which is a span element. I tried MutationObserver and ResizeObserver with no luck.

Does anyone more versed Joplin's infrastructure have any suggestions how to proceed?
Many thanks

What's a Typewriter mode?

It's when your current active line is always scrolled so it is at the centre of the page. It's very useful for writing longer form texts.

MarkText has this option. Here is another discussion about it Typewriter mode

Ok that makes sense. Getting scrolling right is often difficult, especially since the viewer pane is supposed to move in sync, so not sure how you'd that but perhaps someone can help.

Do you have a suggestion on how to detect changes in the last span element though?