Stirling-PDF/frontend/src/components/viewer/RotateAPIBridge.tsx

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

23 lines
705 B
TypeScript
Raw Normal View History

2025-09-15 16:05:19 +01:00
import { useEffect } from 'react';
import { useRotate } from '@embedpdf/plugin-rotate/react';
/**
* Component that runs inside EmbedPDF context and exports rotate controls globally
*/
export function RotateAPIBridge() {
const { provides: rotate, rotation } = useRotate();
useEffect(() => {
if (rotate) {
// Export rotate controls to global window for right rail access
window.embedPdfRotate = {
rotateForward: () => rotate.rotateForward(),
rotateBackward: () => rotate.rotateBackward(),
setRotation: (rotationValue: number) => rotate.setRotation(rotationValue),
getRotation: () => rotation,
};
}
}, [rotate, rotation]);
return null;
}