ui: close a code block as its opening fence is typed (#33364)
Typing ``` on a line of its own in the editor now writes the closing fence
below right away and puts the cursor on the line between them, so what comes
next is code and the block needs no last keystroke. It takes the text the
browser reports rather than the key, so soft keyboards get it too, and one
backspace brings the cursor back to the opening fence to name a language. A
fence typed where a code block is still open stays the text it is, and an
undone block goes away in one step.
Assisted by: Llama Chat (ggml-org/Qwen3.8-Flash-Next-GGUF:Q8_0 + DFLASH:Q8_0)