From fee17064633bfa71009b3598d0065cd2c8a238af Mon Sep 17 00:00:00 2001 From: Reece Date: Mon, 10 Nov 2025 16:08:47 +0000 Subject: [PATCH] Fix copilot suggestions --- .../src/core/components/pageEditor/DragDropGrid.tsx | 2 +- .../components/pageEditor/commands/pageCommands.ts | 10 ++-------- frontend/src/core/components/shared/ToolChain.tsx | 2 +- frontend/src/core/contexts/PageEditorContext.tsx | 10 +++++----- frontend/src/core/types/pageEditor.ts | 9 +++++++++ 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/frontend/src/core/components/pageEditor/DragDropGrid.tsx b/frontend/src/core/components/pageEditor/DragDropGrid.tsx index a73bea8c6..794dea3cb 100644 --- a/frontend/src/core/components/pageEditor/DragDropGrid.tsx +++ b/frontend/src/core/components/pageEditor/DragDropGrid.tsx @@ -225,7 +225,7 @@ const DraggableItem = ({ item, index, itemRefs, boxSelec }); // Notify parent when hover state changes - React.useEffect(() => { + useEffect(() => { if (isOver) { onUpdateDropTarget(item.id); } else { diff --git a/frontend/src/core/components/pageEditor/commands/pageCommands.ts b/frontend/src/core/components/pageEditor/commands/pageCommands.ts index 22dcdc9ce..a133bfbf8 100644 --- a/frontend/src/core/components/pageEditor/commands/pageCommands.ts +++ b/frontend/src/core/components/pageEditor/commands/pageCommands.ts @@ -1,5 +1,5 @@ import { FileId } from '@app/types/file'; -import { PDFDocument, PDFPage } from '@app/types/pageEditor'; +import { PDFDocument, PDFPage, PageBreakSettings, PageSize, PageOrientation } from '@app/types/pageEditor'; // V1-style DOM-first command system (replaces the old React state commands) export abstract class DOMCommand { @@ -420,13 +420,7 @@ export class SplitAllCommand extends DOMCommand { } } -export type PageSize = 'A4' | 'Letter' | 'Legal' | 'A3' | 'A5'; -export type PageOrientation = 'portrait' | 'landscape'; - -export interface PageBreakSettings { - size: PageSize; - orientation: PageOrientation; -} +// PageBreakSettings, PageSize, and PageOrientation are now imported from pageEditor.ts export class PageBreakCommand extends DOMCommand { private insertedPages: PDFPage[] = []; diff --git a/frontend/src/core/components/shared/ToolChain.tsx b/frontend/src/core/components/shared/ToolChain.tsx index 49b535f83..d3c25f653 100644 --- a/frontend/src/core/components/shared/ToolChain.tsx +++ b/frontend/src/core/components/shared/ToolChain.tsx @@ -1,4 +1,4 @@ -/** +/** * Reusable ToolChain component with smart truncation and tooltip expansion * Used across FileListItem, FileDetails, and FileThumbnail for consistent display */ diff --git a/frontend/src/core/contexts/PageEditorContext.tsx b/frontend/src/core/contexts/PageEditorContext.tsx index 2cd95adfa..6881db1ed 100644 --- a/frontend/src/core/contexts/PageEditorContext.tsx +++ b/frontend/src/core/contexts/PageEditorContext.tsx @@ -1,4 +1,4 @@ -import React, { createContext, useContext, useState, useCallback, ReactNode, useMemo } from 'react'; +import React, { createContext, useContext, useState, useCallback, ReactNode, useMemo, useRef, useEffect } from 'react'; import { FileId } from '@app/types/file'; import { useFileActions, useFileState } from '@app/contexts/FileContext'; import { PDFPage } from '@app/types/pageEditor'; @@ -149,16 +149,16 @@ export function PageEditorProvider({ children }: PageEditorProviderProps) { const { state } = useFileState(); // Keep a ref to always read latest state in stable callbacks - const stateRef = React.useRef(state); - React.useEffect(() => { + const stateRef = useRef(state); + useEffect(() => { stateRef.current = state; }, [state]); // Track the previous FileContext order to detect actual changes - const prevFileContextIdsRef = React.useRef([]); + const prevFileContextIdsRef = useRef([]); // Initialize fileOrder from FileContext when files change (add/remove only) - React.useEffect(() => { + useEffect(() => { const currentFileIds = state.files.ids; const prevFileIds = prevFileContextIdsRef.current; diff --git a/frontend/src/core/types/pageEditor.ts b/frontend/src/core/types/pageEditor.ts index 9a34834ee..b50b6613c 100644 --- a/frontend/src/core/types/pageEditor.ts +++ b/frontend/src/core/types/pageEditor.ts @@ -1,5 +1,13 @@ import { FileId } from '@app/types/file'; +export type PageSize = 'A4' | 'Letter' | 'Legal' | 'A3' | 'A5'; +export type PageOrientation = 'portrait' | 'landscape'; + +export interface PageBreakSettings { + size: PageSize; + orientation: PageOrientation; +} + export interface PDFPage { id: string; pageNumber: number; @@ -11,6 +19,7 @@ export interface PDFPage { isBlankPage?: boolean; isPlaceholder?: boolean; originalFileId?: FileId; + pageBreakSettings?: PageBreakSettings; } export interface PDFDocument {