Marktext cmEditor

I didn’t find nothing similar so i just wanna ask here
I was looking at the codemirror api, and found
markText(from, to, className, options) → object

Can be used to mark a range of text with a specific CSS class name. from and to should be {line, ch} objects. The options parameter is optional.

I looked around the current obsidian api and found nothing similar, does it already exist somewhere?

The api specifically says to avoid using cmEditor directly