Disable selection on particular lines

Hi, for my project I have to disable selection for specified lines. I’ve found a piece of css online that does the trick on a span block I create outside the editor, but it doesn’t work if I set the class with the markText command.

This is the code:
monitor.markText({line: 0, ch: 0}, {line: 1, ch: 0}, {className: "no-select"});
where no-select is defined in this way:

  color: green;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;

Even if I’m certain that the class is successfully applied (because the text becomes green) it selects everything as nothing happened.
Thanks in advance for any help you may provide,


CodeMirror doesn’t, by default, use the native selection, so this indeed won’t work.

The atomic option to markText might be what you’re looking for.