diff --git a/frontend/src/components/reportEditor/EditorToolbar.tsx b/frontend/src/components/reportEditor/EditorToolbar.tsx index 7e70118..71b4150 100644 --- a/frontend/src/components/reportEditor/EditorToolbar.tsx +++ b/frontend/src/components/reportEditor/EditorToolbar.tsx @@ -21,11 +21,8 @@ import { Menu, MenuItem, Collapse, - TextField, Badge, Avatar, - ToggleButton, - ToggleButtonGroup, Stack, alpha, CircularProgress, @@ -63,25 +60,13 @@ import { ExpandMore as ExpandMoreIcon, ExpandLess as ExpandLessIcon, Search as SearchIcon, - FormatBold as BoldIcon, - FormatItalic as ItalicIcon, - FormatUnderlined as UnderlineIcon, - FormatAlignLeft as AlignLeftIcon, - FormatAlignCenter as AlignCenterIcon, - FormatAlignRight as AlignRightIcon, - FormatColorFill as FillColorIcon, - FormatColorText as TextColorIcon, - BorderColor as StrokeColorIcon, CloudDone as SavedIcon, CloudOff as UnsavedIcon, - AspectRatio as AspectRatioIcon, - Check as CheckIcon, ArrowDropDown as DropdownIcon, History as HistoryIcon, - DataObject as DataBindIcon, AutoMode as AutoSaveIcon, } from "@mui/icons-material"; -import type { ElementType, AprtElement } from "../../types/report"; +import type { ElementType } from "../../types/report"; // Snap options type export interface SnapOptions { @@ -118,10 +103,6 @@ interface EditorToolbarProps { currentPageName: string; onPrevPage: () => void; onNextPage: () => void; - // Optional: selected element for contextual toolbar - selectedElement?: AprtElement | null; - // Optional: callback for element updates from toolbar - onUpdateSelectedElement?: (updates: Partial) => void; // Optional: save status hasUnsavedChanges?: boolean; lastSavedAt?: Date | null; @@ -222,30 +203,6 @@ const SNAP_OPTIONS_CONFIG = [ }, ]; -// Color presets for quick selection -const COLOR_PRESETS = [ - "#000000", - "#424242", - "#757575", - "#ffffff", - "#f44336", - "#e91e63", - "#9c27b0", - "#673ab7", - "#3f51b5", - "#2196f3", - "#03a9f4", - "#00bcd4", - "#009688", - "#4caf50", - "#8bc34a", - "#cddc39", - "#ffeb3b", - "#ffc107", - "#ff9800", - "#ff5722", -]; - // Format time ago function formatTimeAgo(date: Date | null | undefined): string { if (!date) return ""; @@ -364,109 +321,6 @@ function StyledIconButton({ ); } -// Compact color picker button -function ColorPickerButton({ - color, - onChange, - label, - icon: Icon, -}: { - color: string; - onChange: (color: string) => void; - label: string; - icon: React.ElementType; -}) { - const [anchorEl, setAnchorEl] = useState(null); - - return ( - <> - - setAnchorEl(e.currentTarget)} - sx={{ - borderRadius: 1.5, - position: "relative", - "&:hover": { bgcolor: "action.hover" }, - }} - > - - - - - setAnchorEl(null)} - anchorOrigin={{ vertical: "bottom", horizontal: "center" }} - > - - - {label} - - - {COLOR_PRESETS.map((presetColor) => ( - { - onChange(presetColor); - setAnchorEl(null); - }} - sx={{ - width: 28, - height: 28, - p: 0, - bgcolor: presetColor, - border: "2px solid", - borderColor: - color === presetColor ? "primary.main" : "divider", - "&:hover": { - transform: "scale(1.15)", - borderColor: "primary.main", - }, - }} - > - {color === presetColor && ( - - )} - - ))} - - - - - ); -} - export default function EditorToolbar({ onAddElement, onDeleteElement, @@ -492,8 +346,6 @@ export default function EditorToolbar({ currentPageName, onPrevPage, onNextPage, - selectedElement, - onUpdateSelectedElement, hasUnsavedChanges = false, lastSavedAt, onOpenCommandPalette, @@ -551,275 +403,6 @@ export default function EditorToolbar({ setAddMenuAnchor(null); }; - // Handle text formatting - const handleTextFormat = (format: "bold" | "italic" | "underline") => { - if ( - !selectedElement || - selectedElement.type !== "text" || - !onUpdateSelectedElement - ) - return; - const currentStyle = selectedElement.style || {}; - let updates: Partial = {}; - - switch (format) { - case "bold": - updates = { - style: { - ...currentStyle, - fontWeight: currentStyle.fontWeight === "bold" ? "normal" : "bold", - }, - }; - break; - case "italic": - updates = { - style: { - ...currentStyle, - fontStyle: - currentStyle.fontStyle === "italic" ? "normal" : "italic", - }, - }; - break; - case "underline": - updates = { - style: { - ...currentStyle, - textDecoration: - currentStyle.textDecoration === "underline" - ? "none" - : "underline", - }, - }; - break; - } - onUpdateSelectedElement(updates); - }; - - // Handle text alignment - const handleTextAlign = (align: "left" | "center" | "right") => { - if ( - !selectedElement || - selectedElement.type !== "text" || - !onUpdateSelectedElement - ) - return; - onUpdateSelectedElement({ - style: { - ...selectedElement.style, - textAlign: align, - }, - }); - }; - - // Contextual toolbar based on selection - const renderContextualToolbar = () => { - if (!selectedElement || !onUpdateSelectedElement) return null; - - const currentStyle = selectedElement.style || {}; - - // Text-specific toolbar - if (selectedElement.type === "text") { - return ( - - {/* Text formatting */} - - handleTextFormat("bold")} - > - - - handleTextFormat("italic")} - > - - - handleTextFormat("underline")} - > - - - - - - - {/* Text alignment */} - value && handleTextAlign(value)} - sx={{ "& .MuiToggleButton-root": { border: 0, borderRadius: 1 } }} - > - - - - - - - - - - - - - - {/* Colors */} - - onUpdateSelectedElement({ style: { ...currentStyle, color } }) - } - label="Colore testo" - icon={TextColorIcon} - /> - - onUpdateSelectedElement({ - style: { ...currentStyle, backgroundColor: color }, - }) - } - label="Sfondo" - icon={FillColorIcon} - /> - - - - {/* Data binding indicator */} - {selectedElement.content?.type === "binding" && ( - } - label="Data Bound" - size="small" - color="info" - variant="outlined" - sx={{ height: 24 }} - /> - )} - - ); - } - - // Shape/Line toolbar - if (selectedElement.type === "shape" || selectedElement.type === "line") { - return ( - - - onUpdateSelectedElement({ - style: { ...currentStyle, backgroundColor: color }, - }) - } - label="Riempimento" - icon={FillColorIcon} - /> - - onUpdateSelectedElement({ - style: { ...currentStyle, borderColor: color }, - }) - } - label="Bordo" - icon={StrokeColorIcon} - /> - - - - {/* Border width */} - - - - Bordo: - - - onUpdateSelectedElement({ - style: { - ...currentStyle, - borderWidth: Number(e.target.value), - }, - }) - } - inputProps={{ min: 0, max: 20, step: 0.5 }} - sx={{ width: 60, "& input": { py: 0.5, fontSize: "0.75rem" } }} - /> - - - - ); - } - - // Image toolbar - if (selectedElement.type === "image") { - return ( - - } - label={selectedElement.name || "Immagine"} - size="small" - variant="outlined" - sx={{ height: 24, maxWidth: 150 }} - /> - - - - - - - - ); - } - - return null; - }; - // Save status indicator const renderSaveStatus = () => { return ( @@ -1490,13 +1073,6 @@ export default function EditorToolbar({ )} - {/* Contextual toolbar for text/shape */} - {selectedElement && onUpdateSelectedElement && ( - - {renderContextualToolbar()} - - )} - {/* Shared Popovers */} )} - - {/* Contextual Toolbar Row - appears when element is selected */} - {selectedElement && onUpdateSelectedElement && ( - - {/* Element type indicator */} - e.type === selectedElement.type)?.icon - ? (() => { - const Icon = ELEMENT_TYPES.find( - (e) => e.type === selectedElement.type, - )!.icon; - return ; - })() - : undefined - } - label={ - ELEMENT_TYPES.find((e) => e.type === selectedElement.type) - ?.label || selectedElement.type - } - size="small" - variant="outlined" - sx={{ - borderColor: ELEMENT_TYPES.find( - (e) => e.type === selectedElement.type, - )?.color, - color: ELEMENT_TYPES.find((e) => e.type === selectedElement.type) - ?.color, - }} - /> - - - - {/* Contextual formatting options */} - {renderContextualToolbar()} - - - - {/* Element name */} - {selectedElement.name && ( - - {selectedElement.name} - - )} - - {/* Position info */} - - {Math.round(selectedElement.position.x)}× - {Math.round(selectedElement.position.y)} |{" "} - {Math.round(selectedElement.position.width)}× - {Math.round(selectedElement.position.height)}mm - - - )} ); } diff --git a/frontend/src/pages/ReportEditorPage.tsx b/frontend/src/pages/ReportEditorPage.tsx index 7da180f..5569fe5 100644 --- a/frontend/src/pages/ReportEditorPage.tsx +++ b/frontend/src/pages/ReportEditorPage.tsx @@ -1713,9 +1713,6 @@ export default function ReportEditorPage() { setSelectedElementIds([]); } }} - // New props for enhanced toolbar - selectedElement={selectedElement} - onUpdateSelectedElement={handleUpdateSelectedElement} hasUnsavedChanges={hasUnsavedChanges} // Auto-save props autoSaveEnabled={autoSaveEnabled} diff --git a/src/Apollinare.API/apollinare.db-shm b/src/Apollinare.API/apollinare.db-shm index 3584c8c..999dc80 100644 Binary files a/src/Apollinare.API/apollinare.db-shm and b/src/Apollinare.API/apollinare.db-shm differ diff --git a/src/Apollinare.API/apollinare.db-wal b/src/Apollinare.API/apollinare.db-wal index 8ca6b33..43af59d 100644 Binary files a/src/Apollinare.API/apollinare.db-wal and b/src/Apollinare.API/apollinare.db-wal differ