Imported the remaining functionality from Refinery, updated wym_ prefix to visual_editor_ where it's changed in Refinery.