Я использую библиотеку Rangy для выделения текста и применения к нему класса выделения. Проблема в том, что когда выделяется часть текста, остальные становятся невыбираемыми!
< p>Моя функция выделения:
Код: Выделить всё
applyHighlight() {
rangy.init()
let selection = rangy.getSelection();
if (selection.rangeCount > 0) {
let highlighter = rangy.createHighlighter();
highlighter.addClassApplier(rangy.createClassApplier('highlight-yellow'));
highlighter.highlightSelection('highlight-yellow');
rangy.getSelection().removeAllRanges();
}}
Код: Выделить всё
.highlight-yellow {
margin: -1px !important;
padding: 1px !important;
background-color: rgb(252, 238, 124) !important;
border-radius: 4px !important;
opacity: 50%;
cursor: pointer;}
here is the highlighted spans

and this is what it looks like from the console

As you can see the "copies are not made or distributed" part is becomes unselectable and it goes out from the span scope.
Источник: https://stackoverflow.com/questions/781 ... text-layer