mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-09-26 17:52:59 +02:00
rename APIBridge
This commit is contained in:
parent
9901771572
commit
18e4e03220
@ -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={{
|
||||||
|
@ -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>>([]);
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ export function PanControlsExporter() {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
console.warn('EmbedPDF pan API not available yet');
|
console.warn('EmbedPDF pan API not available yet');
|
||||||
}
|
}
|
||||||
@ -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;
|
||||||
}
|
}
|
@ -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(() => {
|
||||||
@ -19,9 +19,9 @@ export function ScrollControlsExporter() {
|
|||||||
currentPage: scrollState.currentPage,
|
currentPage: scrollState.currentPage,
|
||||||
totalPages: scrollState.totalPages,
|
totalPages: scrollState.totalPages,
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}, [scroll, scrollState]);
|
}, [scroll, scrollState]);
|
||||||
|
|
||||||
return null; // This component doesn't render anything
|
return null;
|
||||||
}
|
}
|
@ -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(() => {
|
||||||
@ -44,9 +44,9 @@ export function SearchControlsExporter() {
|
|||||||
searchAPI: search,
|
searchAPI: search,
|
||||||
availableMethods: search ? Object.keys(search) : [],
|
availableMethods: search ? Object.keys(search) : [],
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}, [search, state]);
|
}, [search, state]);
|
||||||
|
|
||||||
return null; // This component doesn't render anything
|
return null;
|
||||||
}
|
}
|
@ -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;
|
||||||
}
|
}
|
@ -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(() => {
|
||||||
@ -26,7 +26,7 @@ export function SpreadControlsExporter() {
|
|||||||
isDualPage: spreadMode !== SpreadMode.None,
|
isDualPage: spreadMode !== SpreadMode.None,
|
||||||
SpreadMode: SpreadMode, // Export enum for reference
|
SpreadMode: SpreadMode, // Export enum for reference
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('EmbedPDF spread controls exported to window.embedPdfSpread', {
|
console.log('EmbedPDF spread controls exported to window.embedPdfSpread', {
|
||||||
currentSpreadMode: spreadMode,
|
currentSpreadMode: spreadMode,
|
||||||
isDualPage: spreadMode !== SpreadMode.None,
|
isDualPage: spreadMode !== SpreadMode.None,
|
||||||
@ -38,5 +38,5 @@ export function SpreadControlsExporter() {
|
|||||||
}
|
}
|
||||||
}, [spread, spreadMode]);
|
}, [spread, spreadMode]);
|
||||||
|
|
||||||
return null; // This component doesn't render anything
|
return null;
|
||||||
}
|
}
|
@ -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;
|
||||||
}
|
}
|
@ -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(() => {
|
||||||
@ -18,9 +18,9 @@ export function ZoomControlsExporter() {
|
|||||||
currentZoom: zoomState?.currentZoomLevel || 1,
|
currentZoom: zoomState?.currentZoomLevel || 1,
|
||||||
zoomPercent: Math.round((zoomState?.currentZoomLevel || 1) * 100),
|
zoomPercent: Math.round((zoomState?.currentZoomLevel || 1) * 100),
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}, [zoom, zoomState]);
|
}, [zoom, zoomState]);
|
||||||
|
|
||||||
return null; // This component doesn't render anything
|
return null;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user