New features
- The
Bookmarks
component provides new property that can be used to set a bookmark expanded or collapsed initially.
The following sample code expands bookmarks whose depth are smaller or equal to 2:
const setBookmarkExpanded = ({ bookmark, depth, doc, index }) => {
// `bookmark` is the bookmark data structure
// `depth` is the current depth
// `doc` is the current document
// `index` is the zero-based index of bookmark relative to its parent
return depth <= 2;
};
<Bookmarks isBookmarkExpanded={setBookmarkExpanded} />;
Expanding or collapsing all bookmarks initially can be done easily:
// Expand bookmarks initially
const setBookmarkExpanded = ({ bookmark, depth, doc, index }) => true;
// Collapse bookmarks initially
const setBookmarkExpanded = ({ bookmark, depth, doc, index }) => false;
- The Page Navigation plugin provides new
NumberOfPages
component that displays the total number of pages
Improvements
- Align bookmark titles
- Compatible with React 18
- In previous versions, all bookmarks were expanded by default. From this version, a bookmark will be shown or hidden initially depending on its data structure.
You can see this behaviour on popular viewers such as Acrobat Reader. - The toolbar slot
NumberOfPages
provides the ability of customizing the number of pages
Bug fixes
- The hightlights are lost when the whole words option is enabled
- There is a visible page that isn't rendered when setting the zoom level as page width