mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-09-18 01:19:24 +00:00
27 lines
804 B
TypeScript
27 lines
804 B
TypeScript
import { useEffect } from 'react';
|
|
import { useZoom } from '@embedpdf/plugin-zoom/react';
|
|
|
|
/**
|
|
* Component that runs inside EmbedPDF context and exports zoom controls globally
|
|
*/
|
|
export function ZoomAPIBridge() {
|
|
const { provides: zoom, state: zoomState } = useZoom();
|
|
|
|
useEffect(() => {
|
|
if (zoom) {
|
|
// Export zoom controls to global window for right rail access
|
|
(window as any).embedPdfZoom = {
|
|
zoomIn: () => zoom.zoomIn(),
|
|
zoomOut: () => zoom.zoomOut(),
|
|
toggleMarqueeZoom: () => zoom.toggleMarqueeZoom(),
|
|
requestZoom: (level: any) => zoom.requestZoom(level),
|
|
currentZoom: zoomState?.currentZoomLevel || 1,
|
|
zoomPercent: Math.round((zoomState?.currentZoomLevel || 1) * 100),
|
|
};
|
|
|
|
}
|
|
}, [zoom, zoomState]);
|
|
|
|
return null;
|
|
}
|