add preview function to the editor