Refactor shared logic into xblock_editor