Refactor utility method for rich text editor interaction