'monaco editor set range text color programatically without css in style.css

I am trying to use Monaco editor to create an application for simple text processing (eg: select a range of text, change its foreground and background color). Is there an easy way to do this? or even best, is there any best free opensource rich text like Grammarly, I just need some mark-down features with color.

This example uses a CSS class name, but not what I am looking for. https://microsoft.github.io/monaco-editor/playground.html#interacting-with-the-editor-line-and-inline-decorations The CSS is predefined, not dynamically generated.

Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source