mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-09-18 09:29:24 +00:00
Remove unused code
This commit is contained in:
parent
ca9d7ef465
commit
19d7111cab
@ -8,7 +8,7 @@ import { Viewport, ViewportPluginPackage } from '@embedpdf/plugin-viewport/react
|
|||||||
import { Scroller, ScrollPluginPackage, ScrollStrategy } from '@embedpdf/plugin-scroll/react';
|
import { Scroller, ScrollPluginPackage, ScrollStrategy } from '@embedpdf/plugin-scroll/react';
|
||||||
import { LoaderPluginPackage } from '@embedpdf/plugin-loader/react';
|
import { LoaderPluginPackage } from '@embedpdf/plugin-loader/react';
|
||||||
import { RenderLayer, RenderPluginPackage } from '@embedpdf/plugin-render/react';
|
import { RenderLayer, RenderPluginPackage } from '@embedpdf/plugin-render/react';
|
||||||
import { ZoomPluginPackage, ZoomMode } from '@embedpdf/plugin-zoom/react';
|
import { ZoomPluginPackage } from '@embedpdf/plugin-zoom/react';
|
||||||
import { InteractionManagerPluginPackage, PagePointerProvider, GlobalPointerProvider } from '@embedpdf/plugin-interaction-manager/react';
|
import { InteractionManagerPluginPackage, PagePointerProvider, GlobalPointerProvider } from '@embedpdf/plugin-interaction-manager/react';
|
||||||
import { SelectionLayer, SelectionPluginPackage } from '@embedpdf/plugin-selection/react';
|
import { SelectionLayer, SelectionPluginPackage } from '@embedpdf/plugin-selection/react';
|
||||||
import { TilingLayer, TilingPluginPackage } from '@embedpdf/plugin-tiling/react';
|
import { TilingLayer, TilingPluginPackage } from '@embedpdf/plugin-tiling/react';
|
||||||
@ -36,7 +36,7 @@ interface LocalEmbedPDFProps {
|
|||||||
|
|
||||||
export function LocalEmbedPDF({ file, url, colorScheme }: LocalEmbedPDFProps) {
|
export function LocalEmbedPDF({ file, url, colorScheme }: LocalEmbedPDFProps) {
|
||||||
const [pdfUrl, setPdfUrl] = useState<string | null>(null);
|
const [pdfUrl, setPdfUrl] = useState<string | null>(null);
|
||||||
|
|
||||||
// Convert color scheme (handle 'auto' mode by defaulting to 'light')
|
// Convert color scheme (handle 'auto' mode by defaulting to 'light')
|
||||||
const actualColorScheme = colorScheme === 'auto' ? 'light' : colorScheme;
|
const actualColorScheme = colorScheme === 'auto' ? 'light' : colorScheme;
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ export function LocalEmbedPDF({ file, url, colorScheme }: LocalEmbedPDFProps) {
|
|||||||
// Create plugins configuration
|
// Create plugins configuration
|
||||||
const plugins = useMemo(() => {
|
const plugins = useMemo(() => {
|
||||||
if (!pdfUrl) return [];
|
if (!pdfUrl) return [];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
createPluginRegistration(LoaderPluginPackage, {
|
createPluginRegistration(LoaderPluginPackage, {
|
||||||
loadingOptions: {
|
loadingOptions: {
|
||||||
@ -73,43 +73,43 @@ export function LocalEmbedPDF({ file, url, colorScheme }: LocalEmbedPDFProps) {
|
|||||||
initialPage: 0,
|
initialPage: 0,
|
||||||
}),
|
}),
|
||||||
createPluginRegistration(RenderPluginPackage),
|
createPluginRegistration(RenderPluginPackage),
|
||||||
|
|
||||||
// Register interaction manager (required for zoom and selection features)
|
// Register interaction manager (required for zoom and selection features)
|
||||||
createPluginRegistration(InteractionManagerPluginPackage),
|
createPluginRegistration(InteractionManagerPluginPackage),
|
||||||
|
|
||||||
// Register selection plugin (depends on InteractionManager)
|
// Register selection plugin (depends on InteractionManager)
|
||||||
createPluginRegistration(SelectionPluginPackage),
|
createPluginRegistration(SelectionPluginPackage),
|
||||||
|
|
||||||
// Register pan plugin (depends on Viewport, InteractionManager)
|
// Register pan plugin (depends on Viewport, InteractionManager)
|
||||||
createPluginRegistration(PanPluginPackage, {
|
createPluginRegistration(PanPluginPackage, {
|
||||||
defaultMode: 'mobile', // Try mobile mode which might be more permissive
|
defaultMode: 'mobile', // Try mobile mode which might be more permissive
|
||||||
}),
|
}),
|
||||||
|
|
||||||
// Register zoom plugin with configuration
|
// Register zoom plugin with configuration
|
||||||
createPluginRegistration(ZoomPluginPackage, {
|
createPluginRegistration(ZoomPluginPackage, {
|
||||||
defaultZoomLevel: 1.0, // Start at exactly 100% zoom
|
defaultZoomLevel: 1.0, // Start at exactly 100% zoom
|
||||||
minZoom: 0.2,
|
minZoom: 0.2,
|
||||||
maxZoom: 3.0,
|
maxZoom: 3.0,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
// Register tiling plugin (depends on Render, Scroll, Viewport)
|
// Register tiling plugin (depends on Render, Scroll, Viewport)
|
||||||
createPluginRegistration(TilingPluginPackage, {
|
createPluginRegistration(TilingPluginPackage, {
|
||||||
tileSize: 768,
|
tileSize: 768,
|
||||||
overlapPx: 5,
|
overlapPx: 5,
|
||||||
extraRings: 1,
|
extraRings: 1,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
// Register spread plugin for dual page layout
|
// Register spread plugin for dual page layout
|
||||||
createPluginRegistration(SpreadPluginPackage, {
|
createPluginRegistration(SpreadPluginPackage, {
|
||||||
defaultSpreadMode: SpreadMode.None, // Start with single page view
|
defaultSpreadMode: SpreadMode.None, // Start with single page view
|
||||||
}),
|
}),
|
||||||
|
|
||||||
// Register search plugin for text search
|
// Register search plugin for text search
|
||||||
createPluginRegistration(SearchPluginPackage),
|
createPluginRegistration(SearchPluginPackage),
|
||||||
|
|
||||||
// Register thumbnail plugin for page thumbnails
|
// Register thumbnail plugin for page thumbnails
|
||||||
createPluginRegistration(ThumbnailPluginPackage),
|
createPluginRegistration(ThumbnailPluginPackage),
|
||||||
|
|
||||||
// Register rotate plugin
|
// Register rotate plugin
|
||||||
createPluginRegistration(RotatePluginPackage, {
|
createPluginRegistration(RotatePluginPackage, {
|
||||||
defaultRotation: Rotation.Degree0, // Start with no rotation
|
defaultRotation: Rotation.Degree0, // Start with no rotation
|
||||||
@ -178,10 +178,10 @@ export function LocalEmbedPDF({ file, url, colorScheme }: LocalEmbedPDFProps) {
|
|||||||
|
|
||||||
// Wrap your UI with the <EmbedPDF> provider
|
// Wrap your UI with the <EmbedPDF> provider
|
||||||
return (
|
return (
|
||||||
<div style={{
|
<div style={{
|
||||||
height: '100%',
|
height: '100%',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
flex: 1,
|
flex: 1,
|
||||||
minHeight: 0,
|
minHeight: 0,
|
||||||
@ -216,10 +216,10 @@ export function LocalEmbedPDF({ file, url, colorScheme }: LocalEmbedPDFProps) {
|
|||||||
renderPage={({ width, height, pageIndex, scale, rotation }: { width: number; height: number; pageIndex: number; scale: number; rotation?: number }) => (
|
renderPage={({ width, height, pageIndex, scale, rotation }: { width: number; height: number; pageIndex: number; scale: number; rotation?: number }) => (
|
||||||
<Rotate pageSize={{ width, height }}>
|
<Rotate pageSize={{ width, height }}>
|
||||||
<PagePointerProvider {...{ pageWidth: width, pageHeight: height, pageIndex, scale, rotation: rotation || 0 }}>
|
<PagePointerProvider {...{ pageWidth: width, pageHeight: height, pageIndex, scale, rotation: rotation || 0 }}>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
userSelect: 'none',
|
userSelect: 'none',
|
||||||
WebkitUserSelect: 'none',
|
WebkitUserSelect: 'none',
|
||||||
@ -233,13 +233,13 @@ export function LocalEmbedPDF({ file, url, colorScheme }: LocalEmbedPDFProps) {
|
|||||||
>
|
>
|
||||||
{/* 1. Low-resolution base layer for immediate feedback */}
|
{/* 1. Low-resolution base layer for immediate feedback */}
|
||||||
<RenderLayer pageIndex={pageIndex} scale={0.5} />
|
<RenderLayer pageIndex={pageIndex} scale={0.5} />
|
||||||
|
|
||||||
{/* 2. High-resolution tile layer on top */}
|
{/* 2. High-resolution tile layer on top */}
|
||||||
<TilingLayer pageIndex={pageIndex} scale={scale} />
|
<TilingLayer pageIndex={pageIndex} scale={scale} />
|
||||||
|
|
||||||
{/* 3. Search highlight layer */}
|
{/* 3. Search highlight layer */}
|
||||||
<CustomSearchLayer pageIndex={pageIndex} scale={scale} />
|
<CustomSearchLayer pageIndex={pageIndex} scale={scale} />
|
||||||
|
|
||||||
{/* 4. Selection layer for text interaction */}
|
{/* 4. Selection layer for text interaction */}
|
||||||
<SelectionLayer pageIndex={pageIndex} scale={scale} />
|
<SelectionLayer pageIndex={pageIndex} scale={scale} />
|
||||||
</div>
|
</div>
|
||||||
@ -252,4 +252,4 @@ export function LocalEmbedPDF({ file, url, colorScheme }: LocalEmbedPDFProps) {
|
|||||||
</EmbedPDF>
|
</EmbedPDF>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,6 @@ export function PdfViewerToolbar({
|
|||||||
const [dynamicZoom, setDynamicZoom] = useState(currentZoom);
|
const [dynamicZoom, setDynamicZoom] = useState(currentZoom);
|
||||||
const [dynamicPage, setDynamicPage] = useState(currentPage);
|
const [dynamicPage, setDynamicPage] = useState(currentPage);
|
||||||
const [dynamicTotalPages, setDynamicTotalPages] = useState(totalPages);
|
const [dynamicTotalPages, setDynamicTotalPages] = useState(totalPages);
|
||||||
const [isPanning, setIsPanning] = useState(false);
|
|
||||||
|
|
||||||
// Update zoom and scroll state from EmbedPDF APIs
|
// Update zoom and scroll state from EmbedPDF APIs
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -56,11 +55,6 @@ export function PdfViewerToolbar({
|
|||||||
setPageInput(currentPageNum);
|
setPageInput(currentPageNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update pan mode state
|
|
||||||
if (window.embedPdfPan) {
|
|
||||||
const panState = window.embedPdfPan.isPanning || false;
|
|
||||||
setIsPanning(panState);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Update state immediately
|
// Update state immediately
|
||||||
|
Loading…
x
Reference in New Issue
Block a user