Feature/v2/bookmarks (#4949)

bookmark panel on viewer
This commit is contained in:
Reece Browne
2025-11-21 11:33:49 +00:00
committed by GitHub
parent fca8470637
commit 4fd336c26c
12 changed files with 990 additions and 3 deletions
@@ -1,4 +1,5 @@
import { SpreadMode } from '@embedpdf/plugin-spread/react';
import { PdfBookmarkObject } from '@embedpdf/models';
export interface ScrollAPIWrapper {
scrollToPage: (params: { pageNumber: number }) => void;
@@ -59,6 +60,12 @@ export interface ExportAPIWrapper {
saveAsCopy: () => { toPromise: () => Promise<ArrayBuffer> };
}
export interface BookmarkAPIWrapper {
fetchBookmarks: () => Promise<PdfBookmarkObject[]>;
clearBookmarks: () => void;
setLocalBookmarks: (bookmarks: PdfBookmarkObject[] | null, error?: string | null) => void;
}
export interface ScrollState {
currentPage: number;
totalPages: number;
@@ -103,6 +110,12 @@ export interface ExportState {
canExport: boolean;
}
export interface BookmarkState {
bookmarks: PdfBookmarkObject[] | null;
isLoading: boolean;
error: string | null;
}
export interface BridgeRef<TState = unknown, TApi = unknown> {
state: TState;
api: TApi;
@@ -118,6 +131,7 @@ export interface BridgeStateMap {
search: SearchState;
thumbnail: unknown;
export: ExportState;
bookmark: BookmarkState;
}
export interface BridgeApiMap {
@@ -130,6 +144,7 @@ export interface BridgeApiMap {
search: SearchAPIWrapper;
thumbnail: ThumbnailAPIWrapper;
export: ExportAPIWrapper;
bookmark: BookmarkAPIWrapper;
}
export type BridgeKey = keyof BridgeStateMap;
@@ -148,6 +163,7 @@ export const createBridgeRegistry = (): ViewerBridgeRegistry => ({
search: null,
thumbnail: null,
export: null,
bookmark: null,
});
export function registerBridge<K extends BridgeKey>(