Comments (5)
What are you using to render the PDF in the browser?
from rangefix.
We are using pdf.js library to render PDF.
from rangefix.
If I extract the HTML from the pdf.js render, I get all 3 rects in both FF and Chrome. If I run RangeFix inside the original pdf.js online viewer, I get 6 rects in both browser (maybe 3 more for the fake selection?)
Can you provide a standalone example of the bug you describe, e.g. in a CodePen?
from rangefix.
Hi,
-Please go through the link "https://codesandbox.io/s/displaying-pdf-using-react-forked-6bqup7?file=/src/components/pdf/all-pages.js"
-Open the output window in a separate tab and also open devTool console tab.
-Select the 'Vestibulum neque massa, scelerisque sit amet ligula eu, congue molestie mi. Praesent ut
varius sem. Nullam at porttitor arcu, nec lacinia nisi. Ut ac dolor vitae odio interdum
condimentum.' text from first paragraph.
-On mouse up event, we console log the "clientRects received from RangeFix" so please check the console log.
Follow the same scenario on the Google Chrome browser, Firefox, and Edge browser.
Observe the console log on the respective browser.
Note: I have verified on windows 10
Chrome browser Version 105.0.5195.102 (Official Build) (64-bit),
Firefox 104.0.2 (64-bit), and
Microsoft Edge Version 105.0.1343.33 (Official build) (64-bit)
Observation: Received clientRects from the Below code
let range = document.getSelection().getRangeAt(0);
let rects = RangeFix.getClientRects(range);
Google Chrome: 4 clientRects
Firefox: 3 clientRects
Microsoft Edge: 4 clientRects
One more eg. select the first 4 lines from the document and check the console log on Chrome and Firefox it gives a different result.
At my end, I am receiving 10 rects in Chrome and 6 rects in Firefox.
from rangefix.
A minimal test case is:
<p>Foo <b>bar</b> baz<p>
In Chrome you get a rect for the text node "bar" as well as a rect for the <b>
element. In Firefox you only get one for the <b>
tag.
I don't know which behaviour is closer to spec, or if this library could detect and fix it. Generally when using the rects lists you should assume that the rects could overlap and adapt your use case accordingly.
from rangefix.
Related Issues (9)
- Some client rects are redundant HOT 2
- Selections not returned in correct DOM order HOT 10
- Triple click line selection in Firefox HOT 4
- Bounding rect incorrect when selecting space spanning lines
- Some client rects appear twice HOT 3
- range.getBoundingClientRect() misbehaviour on multiline texts HOT 4
- issue in ios devices
- Investigate IE/Edge bi-di issue HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rangefix.