moved all editor code from mode to editor