I am trying to create basic text editor using Rxjs and javascript. I have created a button named 'B' in .html file which when clicked makes a selected text from textarea bold.How do I give styling to that selected text in textarea using javascript in boldcontent() function below? Also, if a selected text is entirely bold then how can I make bold button auto-selected?
I know that this is very basic doubt but I am a beginner in javascript. It would be really great if someone can help me in understanding this.
let btnbold=document.getElementById('btnbold');
let textarea=document.getElementById('text_area_id');
fromEvent(btnbold,'click').subscribe(()=>boldcontent());
let boldcontent=()=>{
let selection = (textarea.value).substring(textarea.selectionStart,textarea.selectionEnd);
}```