Fix editor bugs with the visual vs. text state