So, I am trying to build a WYSIWYG editor and using execCommand("bold"), execCommand("italic") etc. While they work properly, the Docs says execCommand is deprecated and might start to not work anymore. However, it doesn't say what to use instead of it. Is there any alternative ?
I have tried:
window.dispatchEvent(
new KeyboardEvent("keydown",{ctrlKey: true, code: "KeyB", keyCode: 66})
);
But, unfortunately, it doesn't affect elements with contenteditable attribute.