codemirror5 has MarkText, but codemirror6 how to do it?

codemirror5 has method markText(from, to, {
atomic: true,
replacedWith: text
})

but I don’t know to do it by codemirror6, can you tell me, thank you!

See this example.