Reimplement replace, now editing is possible
(but not fully tested)