Phenomenon
The document.execCommand() API, which is commonly used to apply formatting (bold, italic, etc.) in contenteditable regions, has been deprecated. However, there is no complete replacement, and many implementations still rely on it. This creates uncertainty about future browser support.
Reproduction example
- Create a contenteditable div.
- Use
document.execCommand('bold', false, null)to apply bold formatting. - Check browser console for deprecation warnings.
- Observe that the command still works but shows warnings.
Observed behavior
- Chrome shows deprecation warnings in the console when using execCommand.
- The commands still function but may stop working in future browser versions.
- The alternative (Selection API + DOM manipulation) is more complex to implement.
Expected behavior
- A standardized, modern API should be available for formatting contenteditable regions.
- The new API should be well-documented and supported across browsers.
- Migration path from execCommand should be clear.