Move editor logic to directives