Fix some more landscape mode issues
Render pages in landscape mode correctly.
Add orientation to PageDimensions
.
Add onLoad
function to PdfViewer
that passes original page dimensions.
Determine the scrolling element used in virtualization dynamically, instead of using document
.
This gives more freedom integrating react-pdf-selection
in another project.
Fix wrong visible pages calculations that would break on the edges of the PDF.
Improvements on selection changes, removing inconsistencies in active selections.
- Move SelectionChange listener back to document, since there are troubles with selectionchange listeners on divs.
- Change the default textSelectionColor value
Tighten boundaries of selection change event listeners
Improve custom text selection color handling
Move PdfViewer
selectionMap
from class property to state.
Keep better track of selected contents, to avoid calling the onSelection
callback functions too often.
Wrap custom TextSelectionComponent and AreaSelectionComponent usages in React Fragments with appropriate key
props
to help perform rerendering more efficiently.
- Change
textSelectionComponent
,areaSelectionComponent
andnewAreaSelectionComponent
types to render functions. This will allow external props to be plugged in more easily when necessary. - Add generic types to all ...Selection... types. This allows supplemental fields to passed with the Selection
objects, which will still be correctly typed when they are passed back in e.g. the
TextSelection
component props.
Set box-sizing
to content-box
to ensure that box model calculations for page placeholders is done correctly.
Improved pageYOffsets
calculations.
- Improved rerendering of
PdfViewer
. This allows functions to passed tochildren
, instead of components, without triggering a deep rerender at each update. - Add mentions of memoization in the docs for
PdfViewer
props.
- Add page loading component, allow document loading prop to override default loading component shown.
- Add
onPageDimensions
prop toPdfViewer
that receives the calculated page dimension data.
Have PdfViewer
accept a React component as children
that will receive the rendered PDF Document.
Default the PDF Document will be rendered.
Two fixes:
scale
andoverscanCount
were moved toprops
to make sure the PDF is rerendered correctly, the page dimensions are now recalculated onscale
update.- The
underscanPages
calculation was broken, is now not broken.
Replace react-window
virtualizer with custom implementation. The use of react-window
imposed
a few limitations on the PdfViewer
, such as constantly changing Document heights, very frequent
CSS updates for relatively expensive page renders, etc. While these properties might work for a
large range of applications and provide support for lots of different purposes, virtualization in
the case of this library could be simplified. By using page placeholders with the same dimensions
as the actual pages, the document dimensions do not update on scroll, allowing more overriding of
the Document render function (to come in a future update).
Add customizable components for text and area selections, update README
Update README, add CHANGELOG to repository
Virtualize pages with the react-window
package. This helps tremendously with initial page load
for large PDF files.
- Update README
Replace PDF.JS viewer with React PDF. This gives more control over how individual pages are rendered. Selection positions are now rendered using percentages instead of pixel values, since pixel values could proof inaccurate after normalizing to the (0, 1) domain and transforming the coordinates back to the current viewport.
First working version, including:
- PDF rendering with PDF.JS
- Text and rectangular selections
- Normalized positions provided in selections