diff --git a/frontend/src/components/pageEditor/PageEditor.tsx b/frontend/src/components/pageEditor/PageEditor.tsx index 39c6c706b..45c0e9717 100644 --- a/frontend/src/components/pageEditor/PageEditor.tsx +++ b/frontend/src/components/pageEditor/PageEditor.tsx @@ -698,14 +698,16 @@ const PageEditor = ({ zIndex: 10 }} > - {Array.from(splitPositions).map((position) => { - // Match DragDropGrid's layout calculations exactly + {(() => { + // Calculate remToPx once outside the map to avoid layout thrashing const containerWidth = containerDimensions.width; const remToPx = parseFloat(getComputedStyle(document.documentElement).fontSize); const ITEM_WIDTH = parseFloat(GRID_CONSTANTS.ITEM_WIDTH) * remToPx; const ITEM_HEIGHT = parseFloat(GRID_CONSTANTS.ITEM_HEIGHT) * remToPx; const ITEM_GAP = parseFloat(GRID_CONSTANTS.ITEM_GAP) * remToPx; + return Array.from(splitPositions).map((position) => { + // Calculate items per row using DragDropGrid's logic const availableWidth = containerWidth - ITEM_GAP; // Account for first gap const itemWithGap = ITEM_WIDTH + ITEM_GAP; @@ -736,7 +738,8 @@ const PageEditor = ({ }} /> ); - })} + }); + })()} {/* Pages Grid */} diff --git a/frontend/src/services/documentManipulationService.ts b/frontend/src/services/documentManipulationService.ts index 75cf7d27e..6ff0eb87e 100644 --- a/frontend/src/services/documentManipulationService.ts +++ b/frontend/src/services/documentManipulationService.ts @@ -58,7 +58,7 @@ export class DocumentManipulationService { const documents: PDFDocument[] = []; const splitPoints: number[] = []; - // Find split points - pages with splitAfter create split points AFTER them + // Find split points document.pages.forEach((page, index) => { if (page.splitAfter) { console.log(`Found split marker at page ${page.pageNumber} (index ${index}), adding split point at ${index + 1}`); @@ -117,8 +117,6 @@ export class DocumentManipulationService { // Apply rotation changes from DOM updatedPage.rotation = this.getRotationFromDOM(pageElement, page); - // Apply split marker changes from document state (already handled by commands) - // Split markers are already updated by ToggleSplitCommand, so no DOM reading needed return updatedPage; } diff --git a/frontend/src/services/pdfExportService.ts b/frontend/src/services/pdfExportService.ts index 96b8b8670..fe3e314e0 100644 --- a/frontend/src/services/pdfExportService.ts +++ b/frontend/src/services/pdfExportService.ts @@ -211,7 +211,6 @@ export class PDFExportService { * Download multiple files as a ZIP */ async downloadAsZip(blobs: Blob[], filenames: string[], zipFilename: string): Promise { - // For now, download files individually blobs.forEach((blob, index) => { setTimeout(() => { this.downloadFile(blob, filenames[index]); diff --git a/frontend/src/services/pdfWorkerManager.ts b/frontend/src/services/pdfWorkerManager.ts index c15e2c207..0999c5c29 100644 --- a/frontend/src/services/pdfWorkerManager.ts +++ b/frontend/src/services/pdfWorkerManager.ts @@ -94,7 +94,6 @@ class PDFWorkerManager { try { loadingTask.destroy(); } catch (destroyError) { - // Silent cleanup failure } } throw error; @@ -167,7 +166,6 @@ class PDFWorkerManager { try { pdf.destroy(); } catch (error) { - // Silent cleanup } }); diff --git a/frontend/src/services/thumbnailGenerationService.ts b/frontend/src/services/thumbnailGenerationService.ts index be508fd1a..a81ca44ed 100644 --- a/frontend/src/services/thumbnailGenerationService.ts +++ b/frontend/src/services/thumbnailGenerationService.ts @@ -208,8 +208,6 @@ export class ThumbnailGenerationService { // Release reference to PDF document (don't destroy - keep in cache) this.releasePDFDocument(fileId); - // Optionally clean up PDF document from cache to free workers faster - // This can be called after thumbnail generation is complete for a file this.cleanupCompletedDocument(fileId); return allResults;