Updated function to support tinymce 4