When making a hex viewer, it does not make sense to let the user select a half of a byte, so I'm trying to force the selection to snap to byte boundaries.
In CSS, I could set user-select
to all
, but that makes it very difficult to select more than one byte, because clicking inside the element and moving your mouse starts a drag operation instead of selection.
I could try doing it via JS, but all of selection API seems to be marked as experimental technology, and its behavior differs across browsers. I.e. trying to use addRange
to extend range in Chrome does nothing, and prints a warning in console linking to this document.
Is there a reliable way to do this in CSS/JS?