If you have ever copied formatted text from Google Docs and pasted it into a Markdown converter, you have probably seen the entire document come out wrapped in stray **...** bold markers.
Google Docs wraps copied selections inside a <b style="font-weight:normal" id="docs-internal-guid-..."> element. Technically it is a <b> tag, so HTML-to-Markdown converters treat the whole document as bold, even though the inline style explicitly sets font-weight:normal .
Here is how we handle rich clipboard pastes cleanly in vanilla JavaScript without sending a single byte to a server.
1. Intercept paste and read text/html safely
Instead of letting a contenteditable div render raw pasted styles and then scraping its live DOM, read clipboardData directly in the paste event and parse it with DOMParser :
richBox . addEventListener ( "paste" , ( e ) => { const cd = e . clipboardData ; if ( ! cd ) return ; e . preventDefault ( ) ;
const html = cd . getData ( "text/html" ) ; const plain = cd .β¦