mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2026-03-13 02:18:16 +01:00
Print with embed (#5109)
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
SearchActions,
|
||||
ExportActions,
|
||||
BookmarkActions,
|
||||
PrintActions,
|
||||
} from '@app/contexts/viewer/viewerActions';
|
||||
import {
|
||||
BridgeRef,
|
||||
@@ -125,6 +126,7 @@ interface ViewerContextType {
|
||||
searchActions: SearchActions;
|
||||
exportActions: ExportActions;
|
||||
bookmarkActions: BookmarkActions;
|
||||
printActions: PrintActions;
|
||||
|
||||
// Bridge registration - internal use by bridges
|
||||
registerBridge: <K extends BridgeKey>(
|
||||
@@ -277,6 +279,7 @@ export const ViewerProvider: React.FC<ViewerProviderProps> = ({ children }) => {
|
||||
searchActions,
|
||||
exportActions,
|
||||
bookmarkActions,
|
||||
printActions,
|
||||
} = createViewerActions({
|
||||
registry: bridgeRefs,
|
||||
getScrollState,
|
||||
@@ -333,6 +336,7 @@ export const ViewerProvider: React.FC<ViewerProviderProps> = ({ children }) => {
|
||||
searchActions,
|
||||
exportActions,
|
||||
bookmarkActions,
|
||||
printActions,
|
||||
|
||||
// Bridge registration
|
||||
registerBridge,
|
||||
|
||||
@@ -65,6 +65,10 @@ export interface BookmarkActions {
|
||||
setLocalBookmarks: (bookmarks: PdfBookmarkObject[] | null, error?: string | null) => void;
|
||||
}
|
||||
|
||||
export interface PrintActions {
|
||||
print: () => void;
|
||||
}
|
||||
|
||||
export interface ViewerActionsBundle {
|
||||
scrollActions: ScrollActions;
|
||||
zoomActions: ZoomActions;
|
||||
@@ -75,6 +79,7 @@ export interface ViewerActionsBundle {
|
||||
searchActions: SearchActions;
|
||||
exportActions: ExportActions;
|
||||
bookmarkActions: BookmarkActions;
|
||||
printActions: PrintActions;
|
||||
}
|
||||
|
||||
interface ViewerActionDependencies {
|
||||
@@ -332,5 +337,13 @@ export function createViewerActions({
|
||||
api?.setLocalBookmarks?.(bookmarks ?? null, error);
|
||||
},
|
||||
},
|
||||
printActions: {
|
||||
print: () => {
|
||||
const api = registry.current.print?.api;
|
||||
if (api?.print) {
|
||||
api.print();
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -49,6 +49,10 @@ export interface SearchAPIWrapper {
|
||||
goToResult: (index: number) => void;
|
||||
}
|
||||
|
||||
export interface PrintAPIWrapper {
|
||||
print: () => void;
|
||||
}
|
||||
|
||||
export interface ThumbnailAPIWrapper {
|
||||
renderThumb: (pageIndex: number, scale: number) => {
|
||||
toPromise: () => Promise<Blob>;
|
||||
@@ -132,6 +136,7 @@ export interface BridgeStateMap {
|
||||
thumbnail: unknown;
|
||||
export: ExportState;
|
||||
bookmark: BookmarkState;
|
||||
print: unknown;
|
||||
}
|
||||
|
||||
export interface BridgeApiMap {
|
||||
@@ -145,6 +150,7 @@ export interface BridgeApiMap {
|
||||
thumbnail: ThumbnailAPIWrapper;
|
||||
export: ExportAPIWrapper;
|
||||
bookmark: BookmarkAPIWrapper;
|
||||
print: PrintAPIWrapper;
|
||||
}
|
||||
|
||||
export type BridgeKey = keyof BridgeStateMap;
|
||||
@@ -164,6 +170,7 @@ export const createBridgeRegistry = (): ViewerBridgeRegistry => ({
|
||||
thumbnail: null,
|
||||
export: null,
|
||||
bookmark: null,
|
||||
print: null,
|
||||
});
|
||||
|
||||
export function registerBridge<K extends BridgeKey>(
|
||||
|
||||
Reference in New Issue
Block a user