mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-09-18 01:19:24 +00:00
22 lines
735 B
TypeScript
22 lines
735 B
TypeScript
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
|
|
} |