recogito / recogito-js

A JavaScript library for text annotation
BSD 3-Clause "New" or "Revised" License
349 stars 38 forks source link

The editor does not allow selection of text in readonly mode #60

Closed systoyanov closed 2 years ago

systoyanov commented 2 years ago

When trying to select text inside the content element(with "readOnly" enabled) the selected text gets deselected upon right mouse click so it's impossible for the user to copy it via the context menu. In my POV the problem comes from the clearSelection method in SelectionHandler class which could be evolved to respect the read only mode.

I patched it locally with a simple if(this.readOnly) { return; } in the beginning of the method.

This suits my needs but as I'm not familiar with all the features it is possible that it's a very usecase realated fix and will break some other usecases I don't use.

rsimon commented 2 years ago

Ah - thanks for spotting! Your solutions looks pretty good + clean. I'll just double check if there are any unwanted side effects to it, and make this change it if not.

Thx, R

rsimon commented 2 years ago

This should work now. I made a small change: clearSelection is now prevented specifically for right click (regardless of whether in readOnly mode or not). But seems to have pretty much the same effect. The fix will be available with the next release (probably out soon).

systoyanov commented 2 years ago

@rsimon Thanks for your reactivity and all the work you have done on this library. It's great:)