I want users to be able to copy-paste a block of text without also getting inline controls, like buttons.
In Chrome, applying user-select: none;
to the controls accomplishes this. If the user selects the whole paragraph, the buttons are excluded from the selection, and copying gives you only the content.
In Safari, using -webkit-user-select: none;
, the selection visually shows that the buttons aren’t selected, but copy-pasting still includes their content.
Here’s a demo. The goal is that selecting everything then copying gets “13”, not “123”.
button {
-webkit-user-select: none;
user-select: none;
}
1<button>2</button>3
Also doesn’t work: putting the content in a shadow DOM.
Probably works, but I’m hoping for better: make the text an SVG, or contort the DOM so the buttons are inline only visually, not in the DOM.