Merge branch 'feature/v2/embed-pdf' of https://github.com/Stirling-Tools/Stirling-PDF into feature/v2/embed-pdf

This commit is contained in:
Reece Browne 2025-09-16 19:37:50 +01:00
commit b81ed9ec2e
2 changed files with 42 additions and 10 deletions

View File

@ -63,18 +63,36 @@ const EmbedPdfViewerContent = ({
// Handle scroll wheel zoom
React.useEffect(() => {
let accumulator = 0;
const handleWheel = (event: WheelEvent) => {
// Check if Ctrl (Windows/Linux) or Cmd (Mac) is pressed
if (event.ctrlKey || event.metaKey) {
event.preventDefault();
event.stopPropagation();
<<<<<<< HEAD
if (event.deltaY < 0) {
// Scroll up - zoom in
zoomActions.zoomIn();
} else {
// Scroll down - zoom out
zoomActions.zoomOut();
=======
// Convert smooth scrolling gestures into discrete notches
accumulator += event.deltaY;
const threshold = 10;
const zoomAPI = window.embedPdfZoom;
if (zoomAPI) {
if (accumulator <= -threshold) {
zoomAPI.zoomIn();
accumulator = 0;
} else if (accumulator >= threshold) {
zoomAPI.zoomOut();
accumulator = 0;
}
>>>>>>> 81c5d8ff46dcc5fc983109fb2348b6d6dfb129d2
}
}
};
@ -113,16 +131,27 @@ const EmbedPdfViewerContent = ({
};
}, [isViewerHovered]);
<<<<<<< HEAD
=======
// Expose toggle functions globally for right rail buttons
React.useEffect(() => {
window.toggleThumbnailSidebar = toggleThumbnailSidebar;
return () => {
delete window.toggleThumbnailSidebar;
};
}, [toggleThumbnailSidebar]);
>>>>>>> 81c5d8ff46dcc5fc983109fb2348b6d6dfb129d2
return (
<Box
<Box
ref={viewerRef}
onMouseEnter={() => setIsViewerHovered(true)}
onMouseLeave={() => setIsViewerHovered(false)}
style={{
position: 'relative',
height: '100%',
display: 'flex',
style={{
position: 'relative',
height: '100%',
display: 'flex',
flexDirection: 'column',
overflow: 'hidden',
contain: 'layout style paint'
@ -156,12 +185,14 @@ const EmbedPdfViewerContent = ({
)}
{/* EmbedPDF Viewer */}
<Box style={{
position: 'relative',
flex: 1,
<Box style={{
position: 'relative',
flex: 1,
overflow: 'hidden',
minHeight: 0,
minWidth: 0
minWidth: 0,
marginRight: isThumbnailSidebarVisible ? '15rem' : '0',
transition: 'margin-right 0.3s ease'
}}>
<LocalEmbedPDF
file={effectiveFile.file}
@ -220,4 +251,4 @@ const EmbedPdfViewer = (props: EmbedPdfViewerProps) => {
return <EmbedPdfViewerContent {...props} />;
};
export default EmbedPdfViewer;
export default EmbedPdfViewer;

View File

@ -12,4 +12,5 @@ export default defineConfig({
},
},
},
base: "http://localhost:8080",
});