One alternative to the current editing model would be to go all in on the invisible textarea. Then we'd naturally handle IME input and such.
The invisible textarea contains all the text on the current row. Fractions and co are replaced with some escape character(s). [1]
Arrow Key Movement first happens in the textarea, and then we query where we are.
Optional: We can change the "symbols" design to "strings". Heck, we could go all in on the strings by doing the [1] thing.
Whenever we switch to a different row, the textarea content gets replaced with the content from that row.
[1]. For the escape character, we could pick one character from the https://en.wikipedia.org/wiki/Private_Use_Areas. And then, we have an internal Map<Offset, InputElement>, which maps from such a character+its position to the actual element at that position.
We could also always use two characters, to support "deleting -> jump into fraction" and "fully deleting -> delete entire fraction"
An advanced version would be an invisible "contenteditable" area, where the characters are carefully placed to align with the rendered characters. Wrapping every character in a span, and then setting the bounds of the span might work.
One alternative to the current editing model would be to go all in on the invisible textarea. Then we'd naturally handle IME input and such.
[1]. For the escape character, we could pick one character from the https://en.wikipedia.org/wiki/Private_Use_Areas. And then, we have an internal
Map<Offset, InputElement>
, which maps from such a character+its position to the actual element at that position. We could also always use two characters, to support "deleting -> jump into fraction" and "fully deleting -> delete entire fraction"An advanced version would be an invisible "contenteditable" area, where the characters are carefully placed to align with the rendered characters. Wrapping every character in a span, and then setting the bounds of the span might work.