Target segment formatting

Hello,

Is it possible to format the target segment of the editor and underline part of the text using th API, as showed in the picture below ?

Thanks !
Xavier