Justoverclock interesting feature.
I'm not sure how (that's Discourse?) stores their formatted post internally, but the challenge would be mapping a selection coordinate from the formatted post into a selection coordinate on the source post. Then it's "just" a little modal and a call to the existing edit API.
I wonder how it looks like if you edit across some bbcode or markdown tags? I assume it just shows the raw source without any formatting button?