Supply option to set textLayerMode
First of all, thank you for providing such an awesome library!
Now, I've noticed that text selection (not area selection) fails occasionally in some cases. For example, at this part of the last page of the demo, text selection fails once in every five attempts in my perception. https://github.com/agentcooper/react-pdf-highlighter/assets/22513572/bafadf47-5125-4782-bbbb-835a2efad77d
After a bit of trial and error, I found out that the failure rate drops significantly when textLayerMode of PDFViewer is 1 instead of 2.
https://github.com/agentcooper/react-pdf-highlighter/blob/4265e0ba3bf2e0fabf8d4f08fa04d263e0140116/src/components/PdfHighlighter.tsx#L182
So it might be helpful to add textLayerMode option in params of PdfHighlighter component.
+1 one for this. As far as I understand it, there are two "competing" bugs regarding textLayerMode:
- if textLayerMode=1 --> you have the bug where you select the whole page when you hit a white area, even if it is the gap between two text lines, which is very annoying, it is described here and is known since 5 years already: https://github.com/mozilla/pdf.js/issues/9843 --> this bug happens mostly (or exclusively?) in Chrome
- if textLayerMode=2 --> you have the bug you mentioned and also of the bug of highlight gaps + highlights extending on the sides described here: https://github.com/agentcooper/react-pdf-highlighter/issues/180 --> these bugs happen mostly (or exclusively?) in Firefox
Given this, maybe it makes also sense to set the textLayerMode according to the browser that is used