mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-08-26 14:19:24 +00:00
Decent baseline
This commit is contained in:
parent
0eecc261e2
commit
e1c30edddb
@ -999,7 +999,7 @@ const PageEditor = ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const zipBlob = await zip.generateAsync({ type: 'blob' });
|
const zipBlob = await zip.generateAsync({ type: 'blob' });
|
||||||
const zipFilename = displayDocument.name.replace(/\.pdf$/i, '_split.zip');
|
const zipFilename = displayDocument.name.replace(/\.pdf$/i, '.zip');
|
||||||
|
|
||||||
pdfExportService.downloadFile(zipBlob, zipFilename);
|
pdfExportService.downloadFile(zipBlob, zipFilename);
|
||||||
} else {
|
} else {
|
||||||
@ -1094,7 +1094,7 @@ const PageEditor = ({
|
|||||||
const displayedPages = displayDocument?.pages || [];
|
const displayedPages = displayDocument?.pages || [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box pos="relative" h="100vh" style={{ overflow: 'auto' }} data-scrolling-container="true">
|
<Box pos="relative" h="100vh" pt={40} style={{ overflow: 'auto' }} data-scrolling-container="true">
|
||||||
<LoadingOverlay visible={globalProcessing && !mergedPdfDocument} />
|
<LoadingOverlay visible={globalProcessing && !mergedPdfDocument} />
|
||||||
|
|
||||||
{!mergedPdfDocument && !globalProcessing && activeFileIds.length === 0 && (
|
{!mergedPdfDocument && !globalProcessing && activeFileIds.length === 0 && (
|
||||||
@ -1178,7 +1178,7 @@ const PageEditor = ({
|
|||||||
left: leftPosition,
|
left: leftPosition,
|
||||||
top: topPosition,
|
top: topPosition,
|
||||||
width: '1px',
|
width: '1px',
|
||||||
height: '320px', // Match item height
|
height: '20rem', // Match item height
|
||||||
borderLeft: '1px dashed #3b82f6'
|
borderLeft: '1px dashed #3b82f6'
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
@ -69,6 +69,8 @@ const PageThumbnail: React.FC<PageThumbnailProps> = ({
|
|||||||
}: PageThumbnailProps) => {
|
}: PageThumbnailProps) => {
|
||||||
const [thumbnailUrl, setThumbnailUrl] = useState<string | null>(page.thumbnail);
|
const [thumbnailUrl, setThumbnailUrl] = useState<string | null>(page.thumbnail);
|
||||||
const [isDragging, setIsDragging] = useState(false);
|
const [isDragging, setIsDragging] = useState(false);
|
||||||
|
const [isMouseDown, setIsMouseDown] = useState(false);
|
||||||
|
const [mouseStartPos, setMouseStartPos] = useState<{x: number, y: number} | null>(null);
|
||||||
const dragElementRef = useRef<HTMLDivElement>(null);
|
const dragElementRef = useRef<HTMLDivElement>(null);
|
||||||
const { getThumbnailFromCache } = useThumbnailGeneration();
|
const { getThumbnailFromCache } = useThumbnailGeneration();
|
||||||
|
|
||||||
@ -194,6 +196,40 @@ const PageThumbnail: React.FC<PageThumbnailProps> = ({
|
|||||||
onSetStatus(`Split marker ${action} after position ${index + 1}`);
|
onSetStatus(`Split marker ${action} after position ${index + 1}`);
|
||||||
}, [index, splitPositions, onExecuteCommand, onSetStatus, ToggleSplitCommand]);
|
}, [index, splitPositions, onExecuteCommand, onSetStatus, ToggleSplitCommand]);
|
||||||
|
|
||||||
|
// Handle click vs drag differentiation
|
||||||
|
const handleMouseDown = useCallback((e: React.MouseEvent) => {
|
||||||
|
if (!selectionMode) return;
|
||||||
|
|
||||||
|
setIsMouseDown(true);
|
||||||
|
setMouseStartPos({ x: e.clientX, y: e.clientY });
|
||||||
|
}, [selectionMode]);
|
||||||
|
|
||||||
|
const handleMouseUp = useCallback((e: React.MouseEvent) => {
|
||||||
|
if (!selectionMode || !isMouseDown || !mouseStartPos) {
|
||||||
|
setIsMouseDown(false);
|
||||||
|
setMouseStartPos(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate distance moved
|
||||||
|
const deltaX = Math.abs(e.clientX - mouseStartPos.x);
|
||||||
|
const deltaY = Math.abs(e.clientY - mouseStartPos.y);
|
||||||
|
const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
||||||
|
|
||||||
|
// If mouse moved less than 5 pixels, consider it a click (not a drag)
|
||||||
|
if (distance < 5 && !isDragging) {
|
||||||
|
onTogglePage(page.pageNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsMouseDown(false);
|
||||||
|
setMouseStartPos(null);
|
||||||
|
}, [selectionMode, isMouseDown, mouseStartPos, isDragging, page.pageNumber, onTogglePage]);
|
||||||
|
|
||||||
|
const handleMouseLeave = useCallback(() => {
|
||||||
|
setIsMouseDown(false);
|
||||||
|
setMouseStartPos(null);
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={pageElementRef}
|
ref={pageElementRef}
|
||||||
@ -202,7 +238,7 @@ const PageThumbnail: React.FC<PageThumbnailProps> = ({
|
|||||||
className={`
|
className={`
|
||||||
${styles.pageContainer}
|
${styles.pageContainer}
|
||||||
!rounded-lg
|
!rounded-lg
|
||||||
cursor-grab
|
${selectionMode ? 'cursor-pointer' : 'cursor-grab'}
|
||||||
select-none
|
select-none
|
||||||
w-[20rem]
|
w-[20rem]
|
||||||
h-[20rem]
|
h-[20rem]
|
||||||
@ -222,6 +258,9 @@ const PageThumbnail: React.FC<PageThumbnailProps> = ({
|
|||||||
transition: isAnimating ? 'none' : 'transform 0.2s ease-in-out'
|
transition: isAnimating ? 'none' : 'transform 0.2s ease-in-out'
|
||||||
}}
|
}}
|
||||||
draggable={false}
|
draggable={false}
|
||||||
|
onMouseDown={handleMouseDown}
|
||||||
|
onMouseUp={handleMouseUp}
|
||||||
|
onMouseLeave={handleMouseLeave}
|
||||||
>
|
>
|
||||||
{selectionMode && (
|
{selectionMode && (
|
||||||
<div
|
<div
|
||||||
@ -240,14 +279,11 @@ const PageThumbnail: React.FC<PageThumbnailProps> = ({
|
|||||||
cursor: 'pointer'
|
cursor: 'pointer'
|
||||||
}}
|
}}
|
||||||
onMouseDown={(e) => e.stopPropagation()}
|
onMouseDown={(e) => e.stopPropagation()}
|
||||||
|
onMouseUp={(e) => e.stopPropagation()}
|
||||||
onDragStart={(e) => {
|
onDragStart={(e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}}
|
}}
|
||||||
onClick={(e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
onTogglePage(page.pageNumber);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={Array.isArray(selectedPages) ? selectedPages.includes(page.pageNumber) : false}
|
checked={Array.isArray(selectedPages) ? selectedPages.includes(page.pageNumber) : false}
|
||||||
|
@ -82,8 +82,7 @@ export class PDFExportService {
|
|||||||
*/
|
*/
|
||||||
private generateFilename(originalName: string, selectedOnly: boolean): string {
|
private generateFilename(originalName: string, selectedOnly: boolean): string {
|
||||||
const baseName = originalName.replace(/\.pdf$/i, '');
|
const baseName = originalName.replace(/\.pdf$/i, '');
|
||||||
const suffix = selectedOnly ? '_selected' : '_edited';
|
return `${baseName}.pdf`;
|
||||||
return `${baseName}${suffix}.pdf`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user