Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
804 B
TypeScript
Raw Normal View History

2025-09-11 19:08:44 +01:00
import { useEffect } from 'react';
import { useZoom } from '@embedpdf/plugin-zoom/react';
/**
* Component that runs inside EmbedPDF context and exports zoom controls globally
*/
2025-09-12 16:26:05 +01:00
export function ZoomAPIBridge() {
2025-09-11 19:08:44 +01:00
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),
};
2025-09-12 16:26:05 +01:00
2025-09-11 19:08:44 +01:00
}
}, [zoom, zoomState]);
2025-09-12 16:26:05 +01:00
return null;
}