Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
I'd say you loop through the elements and append the inner text to a string, but then there's your odd requirement for "keepkng text formatting the same".
-
A while ago some websites modified the text copied (e.g. by adding ads or something like "copied from...") by doing following:
Detect what text is selected, create a new element with the text (in your case without formatting) override the selection and put to clipboard, restore the selection.
Wouldn't it be easier to tell the user to do Ctrl+Shift+V when pasting? -
Even if I copy from vscode it includes the formatting of my syntax highlighting. That blows.
Related Rants
Does anyone know how to copy text to clipboard from a h1 but text formating should be the same and no html attributes should appear
question
html
js
css