mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-09-18 09:29:24 +00:00
improved scaling and fix grey void
This commit is contained in:
parent
93607937f6
commit
fb9b01f53b
19
frontend/package-lock.json
generated
19
frontend/package-lock.json
generated
@ -17,6 +17,7 @@
|
|||||||
"@embedpdf/plugin-render": "^1.1.1",
|
"@embedpdf/plugin-render": "^1.1.1",
|
||||||
"@embedpdf/plugin-scroll": "^1.1.1",
|
"@embedpdf/plugin-scroll": "^1.1.1",
|
||||||
"@embedpdf/plugin-selection": "^1.1.1",
|
"@embedpdf/plugin-selection": "^1.1.1",
|
||||||
|
"@embedpdf/plugin-tiling": "^1.1.1",
|
||||||
"@embedpdf/plugin-viewport": "^1.1.1",
|
"@embedpdf/plugin-viewport": "^1.1.1",
|
||||||
"@embedpdf/plugin-zoom": "^1.1.1",
|
"@embedpdf/plugin-zoom": "^1.1.1",
|
||||||
"@emotion/react": "^11.14.0",
|
"@emotion/react": "^11.14.0",
|
||||||
@ -726,6 +727,24 @@
|
|||||||
"vue": ">=3.2.0"
|
"vue": ">=3.2.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@embedpdf/plugin-tiling": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@embedpdf/plugin-tiling/-/plugin-tiling-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-KxpouPRsDZ1rnxsxnusywlI92L0l9+WilMAa+RzLDDuesOrtDWL2ry/MAhT0A/lhZP6NdPZNjlqqZGBWcFZhHA==",
|
||||||
|
"dependencies": {
|
||||||
|
"@embedpdf/models": "1.1.1"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@embedpdf/core": "1.1.1",
|
||||||
|
"@embedpdf/plugin-render": "1.1.1",
|
||||||
|
"@embedpdf/plugin-scroll": "1.1.1",
|
||||||
|
"@embedpdf/plugin-viewport": "1.1.1",
|
||||||
|
"preact": "^10.26.4",
|
||||||
|
"react": ">=16.8.0",
|
||||||
|
"react-dom": ">=16.8.0",
|
||||||
|
"vue": ">=3.2.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@embedpdf/plugin-viewport": {
|
"node_modules/@embedpdf/plugin-viewport": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/@embedpdf/plugin-viewport/-/plugin-viewport-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/@embedpdf/plugin-viewport/-/plugin-viewport-1.1.1.tgz",
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
"@embedpdf/plugin-render": "^1.1.1",
|
"@embedpdf/plugin-render": "^1.1.1",
|
||||||
"@embedpdf/plugin-scroll": "^1.1.1",
|
"@embedpdf/plugin-scroll": "^1.1.1",
|
||||||
"@embedpdf/plugin-selection": "^1.1.1",
|
"@embedpdf/plugin-selection": "^1.1.1",
|
||||||
|
"@embedpdf/plugin-tiling": "^1.1.1",
|
||||||
"@embedpdf/plugin-viewport": "^1.1.1",
|
"@embedpdf/plugin-viewport": "^1.1.1",
|
||||||
"@embedpdf/plugin-zoom": "^1.1.1",
|
"@embedpdf/plugin-zoom": "^1.1.1",
|
||||||
"@emotion/react": "^11.14.0",
|
"@emotion/react": "^11.14.0",
|
||||||
|
@ -57,7 +57,14 @@ const EmbedPdfViewer = ({
|
|||||||
}, [previewFile, fileWithUrl]);
|
}, [previewFile, fileWithUrl]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box style={{ position: 'relative', height: '100%', display: 'flex', flexDirection: 'column' }}>
|
<Box style={{
|
||||||
|
position: 'relative',
|
||||||
|
height: '100%',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
overflow: 'hidden',
|
||||||
|
contain: 'layout style paint'
|
||||||
|
}}>
|
||||||
{/* Close Button - Only show in preview mode */}
|
{/* Close Button - Only show in preview mode */}
|
||||||
{onClose && previewFile && (
|
{onClose && previewFile && (
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
@ -87,7 +94,15 @@ const EmbedPdfViewer = ({
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* EmbedPDF Viewer with Toolbar Overlay */}
|
{/* EmbedPDF Viewer with Toolbar Overlay */}
|
||||||
<Box style={{ position: 'relative', flex: 1, overflow: 'hidden' }}>
|
<Box style={{
|
||||||
|
position: 'relative',
|
||||||
|
flex: 1,
|
||||||
|
overflow: 'hidden',
|
||||||
|
minHeight: 0,
|
||||||
|
minWidth: 0,
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column'
|
||||||
|
}}>
|
||||||
<LocalEmbedPDF
|
<LocalEmbedPDF
|
||||||
file={effectiveFile.file}
|
file={effectiveFile.file}
|
||||||
url={effectiveFile.url}
|
url={effectiveFile.url}
|
||||||
|
@ -11,6 +11,7 @@ import { RenderLayer, RenderPluginPackage } from '@embedpdf/plugin-render/react'
|
|||||||
import { ZoomPluginPackage, ZoomMode } from '@embedpdf/plugin-zoom/react';
|
import { ZoomPluginPackage, ZoomMode } from '@embedpdf/plugin-zoom/react';
|
||||||
import { InteractionManagerPluginPackage, PagePointerProvider } from '@embedpdf/plugin-interaction-manager/react';
|
import { InteractionManagerPluginPackage, PagePointerProvider } 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 { ZoomControlsExporter } from './ZoomControlsExporter';
|
import { ZoomControlsExporter } from './ZoomControlsExporter';
|
||||||
import { ScrollControlsExporter } from './ScrollControlsExporter';
|
import { ScrollControlsExporter } from './ScrollControlsExporter';
|
||||||
import { SelectionControlsExporter } from './SelectionControlsExporter';
|
import { SelectionControlsExporter } from './SelectionControlsExporter';
|
||||||
@ -71,7 +72,14 @@ export function LocalEmbedPDF({ file, url, colorScheme }: LocalEmbedPDFProps) {
|
|||||||
createPluginRegistration(ZoomPluginPackage, {
|
createPluginRegistration(ZoomPluginPackage, {
|
||||||
defaultZoomLevel: ZoomMode.FitPage,
|
defaultZoomLevel: ZoomMode.FitPage,
|
||||||
minZoom: 0.2,
|
minZoom: 0.2,
|
||||||
maxZoom: 5.0,
|
maxZoom: 3.0,
|
||||||
|
}),
|
||||||
|
|
||||||
|
// Register tiling plugin (depends on Render, Scroll, Viewport)
|
||||||
|
createPluginRegistration(TilingPluginPackage, {
|
||||||
|
tileSize: 768,
|
||||||
|
overlapPx: 5,
|
||||||
|
extraRings: 1,
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
}, [pdfUrl]);
|
}, [pdfUrl]);
|
||||||
@ -137,7 +145,15 @@ 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={{ height: '100%', width: '100%', overflow: 'hidden' }}>
|
<div style={{
|
||||||
|
height: '100%',
|
||||||
|
width: '100%',
|
||||||
|
position: 'relative',
|
||||||
|
overflow: 'hidden',
|
||||||
|
flex: 1,
|
||||||
|
minHeight: 0,
|
||||||
|
minWidth: 0
|
||||||
|
}}>
|
||||||
<EmbedPDF engine={engine} plugins={plugins}>
|
<EmbedPDF engine={engine} plugins={plugins}>
|
||||||
<ZoomControlsExporter />
|
<ZoomControlsExporter />
|
||||||
<ScrollControlsExporter />
|
<ScrollControlsExporter />
|
||||||
@ -147,13 +163,26 @@ export function LocalEmbedPDF({ file, url, colorScheme }: LocalEmbedPDFProps) {
|
|||||||
backgroundColor: actualColorScheme === 'dark' ? '#1a1b1e' : '#f1f3f5',
|
backgroundColor: actualColorScheme === 'dark' ? '#1a1b1e' : '#f1f3f5',
|
||||||
height: '100%',
|
height: '100%',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
|
maxHeight: '100%',
|
||||||
|
maxWidth: '100%',
|
||||||
overflow: 'auto',
|
overflow: 'auto',
|
||||||
|
position: 'relative',
|
||||||
|
flex: 1,
|
||||||
|
minHeight: 0,
|
||||||
|
minWidth: 0,
|
||||||
|
contain: 'strict',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Scroller
|
<Scroller
|
||||||
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 }) => (
|
||||||
<PagePointerProvider width={width} height={height} pageIndex={pageIndex} scale={scale} rotation={rotation}>
|
<PagePointerProvider {...{ width, height, pageIndex, scale, rotation: rotation || 0 }}>
|
||||||
<RenderLayer pageIndex={pageIndex} scale={scale} />
|
{/* 1. Low-resolution base layer for immediate feedback */}
|
||||||
|
<RenderLayer pageIndex={pageIndex} scale={0.5} />
|
||||||
|
|
||||||
|
{/* 2. High-resolution tile layer on top */}
|
||||||
|
<TilingLayer pageIndex={pageIndex} scale={scale} />
|
||||||
|
|
||||||
|
{/* 3. Selection layer for text interaction */}
|
||||||
<SelectionLayer pageIndex={pageIndex} scale={scale} />
|
<SelectionLayer pageIndex={pageIndex} scale={scale} />
|
||||||
</PagePointerProvider>
|
</PagePointerProvider>
|
||||||
)}
|
)}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user