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

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

22 lines
735 B
TypeScript
Raw Normal View History

2025-09-11 19:36:44 +01:00
import { useEffect } from 'react';
import { useSelectionCapability } from '@embedpdf/plugin-selection/react';
/**
* Component that runs inside EmbedPDF context and exports selection controls globally
*/
export function SelectionControlsExporter() {
const { provides: selection } = useSelectionCapability();
useEffect(() => {
if (selection) {
// Export selection controls to global window
(window as any).embedPdfSelection = {
copyToClipboard: () => selection.copyToClipboard(),
getSelectedText: () => selection.getSelectedText(),
getFormattedSelection: () => selection.getFormattedSelection(),
};
}
}, [selection]);
return null; // This component doesn't render anything
}