Thanks for this Chris, but it is not exactly what we need.
You are getting what's in the Preview panel, not what's in the Edit panel.
I've been playing with this, and I do not see a way to get, or set, what's in the Edit panel:
The <textarea ...>
is the Edit panel.
I can get a reference to it, but it returns its innerText
as empty ("").
But I'm a real novice with HTML DOM and JavaScript. Maybe someone more skilled can figure this out.