rename APIBridge

This commit is contained in:
Reece Browne 2025-09-12 16:26:05 +01:00
parent 9901771572
commit 18e4e03220
8 changed files with 43 additions and 43 deletions

View File

@ -17,13 +17,13 @@ import { SpreadPluginPackage, SpreadMode } from '@embedpdf/plugin-spread/react';
import { SearchPluginPackage } from '@embedpdf/plugin-search/react'; import { SearchPluginPackage } from '@embedpdf/plugin-search/react';
import { ThumbnailPluginPackage } from '@embedpdf/plugin-thumbnail/react'; import { ThumbnailPluginPackage } from '@embedpdf/plugin-thumbnail/react';
import { CustomSearchLayer } from './CustomSearchLayer'; import { CustomSearchLayer } from './CustomSearchLayer';
import { ZoomControlsExporter } from './ZoomControlsExporter'; import { ZoomAPIBridge } from './ZoomAPIBridge';
import { ScrollControlsExporter } from './ScrollControlsExporter'; import { ScrollAPIBridge } from './ScrollAPIBridge';
import { SelectionControlsExporter } from './SelectionControlsExporter'; import { SelectionAPIBridge } from './SelectionAPIBridge';
import { PanControlsExporter } from './PanControlsExporter'; import { PanAPIBridge } from './PanAPIBridge';
import { SpreadControlsExporter } from './SpreadControlsExporter'; import { SpreadAPIBridge } from './SpreadAPIBridge';
import { SearchControlsExporter } from './SearchControlsExporter'; import { SearchAPIBridge } from './SearchAPIBridge';
import { ThumbnailControlsExporter } from './ThumbnailControlsExporter'; import { ThumbnailAPIBridge } from './ThumbnailAPIBridge';
interface LocalEmbedPDFProps { interface LocalEmbedPDFProps {
file?: File | Blob; file?: File | Blob;
@ -180,13 +180,13 @@ export function LocalEmbedPDF({ file, url, colorScheme }: LocalEmbedPDFProps) {
minWidth: 0 minWidth: 0
}}> }}>
<EmbedPDF engine={engine} plugins={plugins}> <EmbedPDF engine={engine} plugins={plugins}>
<ZoomControlsExporter /> <ZoomAPIBridge />
<ScrollControlsExporter /> <ScrollAPIBridge />
<SelectionControlsExporter /> <SelectionAPIBridge />
<PanControlsExporter /> <PanAPIBridge />
<SpreadControlsExporter /> <SpreadAPIBridge />
<SearchControlsExporter /> <SearchAPIBridge />
<ThumbnailControlsExporter /> <ThumbnailAPIBridge />
<GlobalPointerProvider> <GlobalPointerProvider>
<Viewport <Viewport
style={{ style={{

View File

@ -2,9 +2,9 @@ import { useEffect, useState } from 'react';
import { usePan } from '@embedpdf/plugin-pan/react'; import { usePan } from '@embedpdf/plugin-pan/react';
/** /**
* Component that runs inside EmbedPDF context and exports pan controls globally * Component that runs inside EmbedPDF context and bridges pan controls to global window
*/ */
export function PanControlsExporter() { export function PanAPIBridge() {
const { provides: pan, isPanning } = usePan(); const { provides: pan, isPanning } = usePan();
const [panStateListeners, setPanStateListeners] = useState<Array<(isPanning: boolean) => void>>([]); const [panStateListeners, setPanStateListeners] = useState<Array<(isPanning: boolean) => void>>([]);
@ -45,5 +45,5 @@ export function PanControlsExporter() {
panStateListeners.forEach(callback => callback(isPanning)); panStateListeners.forEach(callback => callback(isPanning));
}, [isPanning, panStateListeners]); }, [isPanning, panStateListeners]);
return null; // This component doesn't render anything return null;
} }

View File

@ -4,7 +4,7 @@ import { useScroll } from '@embedpdf/plugin-scroll/react';
/** /**
* Component that runs inside EmbedPDF context and exports scroll controls globally * Component that runs inside EmbedPDF context and exports scroll controls globally
*/ */
export function ScrollControlsExporter() { export function ScrollAPIBridge() {
const { provides: scroll, state: scrollState } = useScroll(); const { provides: scroll, state: scrollState } = useScroll();
useEffect(() => { useEffect(() => {
@ -23,5 +23,5 @@ export function ScrollControlsExporter() {
} }
}, [scroll, scrollState]); }, [scroll, scrollState]);
return null; // This component doesn't render anything return null;
} }

View File

@ -2,9 +2,9 @@ import { useEffect } from 'react';
import { useSearch } from '@embedpdf/plugin-search/react'; import { useSearch } from '@embedpdf/plugin-search/react';
/** /**
* Component that runs inside EmbedPDF context and exports search controls globally * Component that runs inside EmbedPDF context and bridges search controls to global window
*/ */
export function SearchControlsExporter() { export function SearchAPIBridge() {
const { provides: search, state } = useSearch(); const { provides: search, state } = useSearch();
useEffect(() => { useEffect(() => {
@ -48,5 +48,5 @@ export function SearchControlsExporter() {
} }
}, [search, state]); }, [search, state]);
return null; // This component doesn't render anything return null;
} }

View File

@ -4,7 +4,7 @@ import { useSelectionCapability, SelectionRangeX } from '@embedpdf/plugin-select
/** /**
* Component that runs inside EmbedPDF context and exports selection controls globally * Component that runs inside EmbedPDF context and exports selection controls globally
*/ */
export function SelectionControlsExporter() { export function SelectionAPIBridge() {
const { provides: selection } = useSelectionCapability(); const { provides: selection } = useSelectionCapability();
const [hasSelection, setHasSelection] = useState(false); const [hasSelection, setHasSelection] = useState(false);
@ -47,5 +47,5 @@ export function SelectionControlsExporter() {
} }
}, [selection, hasSelection]); }, [selection, hasSelection]);
return null; // This component doesn't render anything return null;
} }

View File

@ -4,7 +4,7 @@ import { useSpread, SpreadMode } from '@embedpdf/plugin-spread/react';
/** /**
* Component that runs inside EmbedPDF context and exports spread controls globally * Component that runs inside EmbedPDF context and exports spread controls globally
*/ */
export function SpreadControlsExporter() { export function SpreadAPIBridge() {
const { provides: spread, spreadMode } = useSpread(); const { provides: spread, spreadMode } = useSpread();
useEffect(() => { useEffect(() => {
@ -38,5 +38,5 @@ export function SpreadControlsExporter() {
} }
}, [spread, spreadMode]); }, [spread, spreadMode]);
return null; // This component doesn't render anything return null;
} }

View File

@ -4,11 +4,11 @@ import { useThumbnailCapability } from '@embedpdf/plugin-thumbnail/react';
/** /**
* Component that runs inside EmbedPDF context and exports thumbnail controls globally * Component that runs inside EmbedPDF context and exports thumbnail controls globally
*/ */
export function ThumbnailControlsExporter() { export function ThumbnailAPIBridge() {
const { provides: thumbnail } = useThumbnailCapability(); const { provides: thumbnail } = useThumbnailCapability();
useEffect(() => { useEffect(() => {
console.log('📄 ThumbnailControlsExporter useEffect:', { thumbnail: !!thumbnail }); console.log('📄 ThumbnailAPIBridge useEffect:', { thumbnail: !!thumbnail });
if (thumbnail) { if (thumbnail) {
console.log('📄 Exporting thumbnail controls to window:', { console.log('📄 Exporting thumbnail controls to window:', {
availableMethods: Object.keys(thumbnail), availableMethods: Object.keys(thumbnail),
@ -22,5 +22,5 @@ export function ThumbnailControlsExporter() {
} }
}, [thumbnail]); }, [thumbnail]);
return null; // This component doesn't render anything return null;
} }

View File

@ -4,7 +4,7 @@ import { useZoom } from '@embedpdf/plugin-zoom/react';
/** /**
* Component that runs inside EmbedPDF context and exports zoom controls globally * Component that runs inside EmbedPDF context and exports zoom controls globally
*/ */
export function ZoomControlsExporter() { export function ZoomAPIBridge() {
const { provides: zoom, state: zoomState } = useZoom(); const { provides: zoom, state: zoomState } = useZoom();
useEffect(() => { useEffect(() => {
@ -22,5 +22,5 @@ export function ZoomControlsExporter() {
} }
}, [zoom, zoomState]); }, [zoom, zoomState]);
return null; // This component doesn't render anything return null;
} }