Currently, I am in the process of developing a WYSIWYG editor as a hobby project. My approach involves utilizing an iframe with design mode enabled and leveraging the execcommand feature in JavaScript to implement the editor functionalities. For instance, I have incorporated the following code snippet to adjust the font size within the editor:
richTextField.document.execCommand('fontSize',false,slctdValue);
Upon execution, this particular piece of code modifies the content within the Iframe to something like this:
<div><font size="4" color="red">This is a test!</font></div>
However, I prefer not to utilize the font tag and instead opt for the following format:
<div style="font-size:22px;color:red;">This is a test!</div>
My query pertains to whether there exists a method through which I can identify instances similar to the initial example and replace them with the preferred format shown in the second example?