feat(phase-6): implement comprehensive file operations system
This commit completes Phase 6 of the paint-ui implementation, adding full
file import/export capabilities with drag-drop and clipboard support.
**New Files:**
- lib/file-utils.ts: Core file operations (open, save, export, project format)
- hooks/use-file-operations.ts: React hook for file operations
- hooks/use-drag-drop.ts: Drag & drop state management
- hooks/use-clipboard.ts: Clipboard paste event handling
- components/editor/file-menu.tsx: File menu dropdown component
- components/modals/export-dialog.tsx: Export dialog with format/quality options
- components/modals/new-image-dialog.tsx: New image dialog with presets
- components/modals/index.ts: Modals barrel export
**Updated Files:**
- components/editor/editor-layout.tsx: Integrated FileMenu, drag-drop overlay, clipboard paste
- components/editor/index.ts: Added file-menu export
**Features:**
- ✨ Create new images with dimension presets (Full HD, HD, 800x600, custom)
- ✨ Open image files (PNG, JPG, WEBP) as new layers
- ✨ Save/load .paint project files (JSON with base64 layer data)
- ✨ Export as PNG/JPEG/WEBP with quality control
- ✨ Drag & drop file upload with visual overlay
- ✨ Clipboard paste support (Ctrl+V)
- ✨ File type validation and error handling
- ✨ DataTransfer API integration for unified file handling
**Project File Format (.paint):**
- JSON structure with version, dimensions, layer metadata
- Base64-encoded PNG data for each layer
- Preserves layer properties (opacity, blend mode, order, visibility)
Build verified: ✓ Compiled successfully in 1233ms
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 02:06:49 +01:00
|
|
|
import { useCallback } from 'react';
|
|
|
|
|
import { useCanvasStore, useLayerStore } from '@/store';
|
|
|
|
|
import { useHistoryStore } from '@/store/history-store';
|
2025-11-21 16:08:24 +01:00
|
|
|
import { useLoadingStore } from '@/store/loading-store';
|
feat(phase-6): implement comprehensive file operations system
This commit completes Phase 6 of the paint-ui implementation, adding full
file import/export capabilities with drag-drop and clipboard support.
**New Files:**
- lib/file-utils.ts: Core file operations (open, save, export, project format)
- hooks/use-file-operations.ts: React hook for file operations
- hooks/use-drag-drop.ts: Drag & drop state management
- hooks/use-clipboard.ts: Clipboard paste event handling
- components/editor/file-menu.tsx: File menu dropdown component
- components/modals/export-dialog.tsx: Export dialog with format/quality options
- components/modals/new-image-dialog.tsx: New image dialog with presets
- components/modals/index.ts: Modals barrel export
**Updated Files:**
- components/editor/editor-layout.tsx: Integrated FileMenu, drag-drop overlay, clipboard paste
- components/editor/index.ts: Added file-menu export
**Features:**
- ✨ Create new images with dimension presets (Full HD, HD, 800x600, custom)
- ✨ Open image files (PNG, JPG, WEBP) as new layers
- ✨ Save/load .paint project files (JSON with base64 layer data)
- ✨ Export as PNG/JPEG/WEBP with quality control
- ✨ Drag & drop file upload with visual overlay
- ✨ Clipboard paste support (Ctrl+V)
- ✨ File type validation and error handling
- ✨ DataTransfer API integration for unified file handling
**Project File Format (.paint):**
- JSON structure with version, dimensions, layer metadata
- Base64-encoded PNG data for each layer
- Preserves layer properties (opacity, blend mode, order, visibility)
Build verified: ✓ Compiled successfully in 1233ms
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 02:06:49 +01:00
|
|
|
import {
|
|
|
|
|
openImageFile,
|
|
|
|
|
exportCanvasAsImage,
|
|
|
|
|
exportProject,
|
|
|
|
|
loadProject,
|
|
|
|
|
createCanvasFromDataURL,
|
|
|
|
|
extractImageFromDataTransfer,
|
|
|
|
|
isImageFile,
|
|
|
|
|
isProjectFile,
|
|
|
|
|
} from '@/lib/file-utils';
|
feat(ui): implement comprehensive toast notification system
Added a complete toast notification system with:
- Toast store using Zustand for state management
- Toast component with 4 types: success, error, warning, info
- Animated slide-in/slide-out transitions
- Auto-dismiss after configurable duration
- Close button on each toast
- Utility functions for easy access (toast.success(), toast.error(), etc.)
Integrated toast notifications into file operations:
- Success notifications for: open image, open project, export image, save project
- Error notifications for: failed operations
- Warning notifications for: unsupported file types
UI Features:
- Stacks toasts in top-right corner
- Color-coded by type with icons (CheckCircle, AlertCircle, AlertTriangle, Info)
- Accessible with ARIA attributes
- Smooth animations using custom CSS keyframes
This provides immediate user feedback for all major operations throughout
the application.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 15:42:50 +01:00
|
|
|
import { toast } from '@/lib/toast-utils';
|
feat(phase-6): implement comprehensive file operations system
This commit completes Phase 6 of the paint-ui implementation, adding full
file import/export capabilities with drag-drop and clipboard support.
**New Files:**
- lib/file-utils.ts: Core file operations (open, save, export, project format)
- hooks/use-file-operations.ts: React hook for file operations
- hooks/use-drag-drop.ts: Drag & drop state management
- hooks/use-clipboard.ts: Clipboard paste event handling
- components/editor/file-menu.tsx: File menu dropdown component
- components/modals/export-dialog.tsx: Export dialog with format/quality options
- components/modals/new-image-dialog.tsx: New image dialog with presets
- components/modals/index.ts: Modals barrel export
**Updated Files:**
- components/editor/editor-layout.tsx: Integrated FileMenu, drag-drop overlay, clipboard paste
- components/editor/index.ts: Added file-menu export
**Features:**
- ✨ Create new images with dimension presets (Full HD, HD, 800x600, custom)
- ✨ Open image files (PNG, JPG, WEBP) as new layers
- ✨ Save/load .paint project files (JSON with base64 layer data)
- ✨ Export as PNG/JPEG/WEBP with quality control
- ✨ Drag & drop file upload with visual overlay
- ✨ Clipboard paste support (Ctrl+V)
- ✨ File type validation and error handling
- ✨ DataTransfer API integration for unified file handling
**Project File Format (.paint):**
- JSON structure with version, dimensions, layer metadata
- Base64-encoded PNG data for each layer
- Preserves layer properties (opacity, blend mode, order, visibility)
Build verified: ✓ Compiled successfully in 1233ms
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 02:06:49 +01:00
|
|
|
import type { Layer } from '@/types';
|
|
|
|
|
|
|
|
|
|
export function useFileOperations() {
|
|
|
|
|
const { width, height, setDimensions } = useCanvasStore();
|
|
|
|
|
const { layers, createLayer, clearLayers } = useLayerStore();
|
|
|
|
|
const { clearHistory } = useHistoryStore();
|
2025-11-21 16:08:24 +01:00
|
|
|
const { setLoading } = useLoadingStore();
|
feat(phase-6): implement comprehensive file operations system
This commit completes Phase 6 of the paint-ui implementation, adding full
file import/export capabilities with drag-drop and clipboard support.
**New Files:**
- lib/file-utils.ts: Core file operations (open, save, export, project format)
- hooks/use-file-operations.ts: React hook for file operations
- hooks/use-drag-drop.ts: Drag & drop state management
- hooks/use-clipboard.ts: Clipboard paste event handling
- components/editor/file-menu.tsx: File menu dropdown component
- components/modals/export-dialog.tsx: Export dialog with format/quality options
- components/modals/new-image-dialog.tsx: New image dialog with presets
- components/modals/index.ts: Modals barrel export
**Updated Files:**
- components/editor/editor-layout.tsx: Integrated FileMenu, drag-drop overlay, clipboard paste
- components/editor/index.ts: Added file-menu export
**Features:**
- ✨ Create new images with dimension presets (Full HD, HD, 800x600, custom)
- ✨ Open image files (PNG, JPG, WEBP) as new layers
- ✨ Save/load .paint project files (JSON with base64 layer data)
- ✨ Export as PNG/JPEG/WEBP with quality control
- ✨ Drag & drop file upload with visual overlay
- ✨ Clipboard paste support (Ctrl+V)
- ✨ File type validation and error handling
- ✨ DataTransfer API integration for unified file handling
**Project File Format (.paint):**
- JSON structure with version, dimensions, layer metadata
- Base64-encoded PNG data for each layer
- Preserves layer properties (opacity, blend mode, order, visibility)
Build verified: ✓ Compiled successfully in 1233ms
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 02:06:49 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create new image
|
|
|
|
|
*/
|
|
|
|
|
const createNewImage = useCallback(
|
|
|
|
|
(newWidth: number, newHeight: number, backgroundColor: string) => {
|
|
|
|
|
clearLayers();
|
|
|
|
|
clearHistory();
|
|
|
|
|
setDimensions(newWidth, newHeight);
|
|
|
|
|
|
|
|
|
|
createLayer({
|
|
|
|
|
name: 'Background',
|
|
|
|
|
width: newWidth,
|
|
|
|
|
height: newHeight,
|
|
|
|
|
fillColor: backgroundColor,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
[clearLayers, clearHistory, setDimensions, createLayer]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Open image file
|
|
|
|
|
*/
|
|
|
|
|
const openImage = useCallback(
|
|
|
|
|
async (file: File) => {
|
2025-11-21 16:08:24 +01:00
|
|
|
setLoading(true, `Opening ${file.name}...`);
|
feat(phase-6): implement comprehensive file operations system
This commit completes Phase 6 of the paint-ui implementation, adding full
file import/export capabilities with drag-drop and clipboard support.
**New Files:**
- lib/file-utils.ts: Core file operations (open, save, export, project format)
- hooks/use-file-operations.ts: React hook for file operations
- hooks/use-drag-drop.ts: Drag & drop state management
- hooks/use-clipboard.ts: Clipboard paste event handling
- components/editor/file-menu.tsx: File menu dropdown component
- components/modals/export-dialog.tsx: Export dialog with format/quality options
- components/modals/new-image-dialog.tsx: New image dialog with presets
- components/modals/index.ts: Modals barrel export
**Updated Files:**
- components/editor/editor-layout.tsx: Integrated FileMenu, drag-drop overlay, clipboard paste
- components/editor/index.ts: Added file-menu export
**Features:**
- ✨ Create new images with dimension presets (Full HD, HD, 800x600, custom)
- ✨ Open image files (PNG, JPG, WEBP) as new layers
- ✨ Save/load .paint project files (JSON with base64 layer data)
- ✨ Export as PNG/JPEG/WEBP with quality control
- ✨ Drag & drop file upload with visual overlay
- ✨ Clipboard paste support (Ctrl+V)
- ✨ File type validation and error handling
- ✨ DataTransfer API integration for unified file handling
**Project File Format (.paint):**
- JSON structure with version, dimensions, layer metadata
- Base64-encoded PNG data for each layer
- Preserves layer properties (opacity, blend mode, order, visibility)
Build verified: ✓ Compiled successfully in 1233ms
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 02:06:49 +01:00
|
|
|
try {
|
|
|
|
|
const img = await openImageFile(file);
|
|
|
|
|
|
|
|
|
|
// Create new image with loaded dimensions
|
|
|
|
|
clearLayers();
|
|
|
|
|
clearHistory();
|
|
|
|
|
setDimensions(img.width, img.height);
|
|
|
|
|
|
|
|
|
|
// Create layer with loaded image
|
|
|
|
|
const layer = createLayer({
|
|
|
|
|
name: file.name,
|
|
|
|
|
width: img.width,
|
|
|
|
|
height: img.height,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (layer.canvas) {
|
|
|
|
|
const ctx = layer.canvas.getContext('2d');
|
|
|
|
|
if (ctx) {
|
|
|
|
|
ctx.drawImage(img, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
feat(ui): implement comprehensive toast notification system
Added a complete toast notification system with:
- Toast store using Zustand for state management
- Toast component with 4 types: success, error, warning, info
- Animated slide-in/slide-out transitions
- Auto-dismiss after configurable duration
- Close button on each toast
- Utility functions for easy access (toast.success(), toast.error(), etc.)
Integrated toast notifications into file operations:
- Success notifications for: open image, open project, export image, save project
- Error notifications for: failed operations
- Warning notifications for: unsupported file types
UI Features:
- Stacks toasts in top-right corner
- Color-coded by type with icons (CheckCircle, AlertCircle, AlertTriangle, Info)
- Accessible with ARIA attributes
- Smooth animations using custom CSS keyframes
This provides immediate user feedback for all major operations throughout
the application.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 15:42:50 +01:00
|
|
|
|
|
|
|
|
toast.success(`Opened ${file.name}`);
|
feat(phase-6): implement comprehensive file operations system
This commit completes Phase 6 of the paint-ui implementation, adding full
file import/export capabilities with drag-drop and clipboard support.
**New Files:**
- lib/file-utils.ts: Core file operations (open, save, export, project format)
- hooks/use-file-operations.ts: React hook for file operations
- hooks/use-drag-drop.ts: Drag & drop state management
- hooks/use-clipboard.ts: Clipboard paste event handling
- components/editor/file-menu.tsx: File menu dropdown component
- components/modals/export-dialog.tsx: Export dialog with format/quality options
- components/modals/new-image-dialog.tsx: New image dialog with presets
- components/modals/index.ts: Modals barrel export
**Updated Files:**
- components/editor/editor-layout.tsx: Integrated FileMenu, drag-drop overlay, clipboard paste
- components/editor/index.ts: Added file-menu export
**Features:**
- ✨ Create new images with dimension presets (Full HD, HD, 800x600, custom)
- ✨ Open image files (PNG, JPG, WEBP) as new layers
- ✨ Save/load .paint project files (JSON with base64 layer data)
- ✨ Export as PNG/JPEG/WEBP with quality control
- ✨ Drag & drop file upload with visual overlay
- ✨ Clipboard paste support (Ctrl+V)
- ✨ File type validation and error handling
- ✨ DataTransfer API integration for unified file handling
**Project File Format (.paint):**
- JSON structure with version, dimensions, layer metadata
- Base64-encoded PNG data for each layer
- Preserves layer properties (opacity, blend mode, order, visibility)
Build verified: ✓ Compiled successfully in 1233ms
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 02:06:49 +01:00
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Failed to open image:', error);
|
feat(ui): implement comprehensive toast notification system
Added a complete toast notification system with:
- Toast store using Zustand for state management
- Toast component with 4 types: success, error, warning, info
- Animated slide-in/slide-out transitions
- Auto-dismiss after configurable duration
- Close button on each toast
- Utility functions for easy access (toast.success(), toast.error(), etc.)
Integrated toast notifications into file operations:
- Success notifications for: open image, open project, export image, save project
- Error notifications for: failed operations
- Warning notifications for: unsupported file types
UI Features:
- Stacks toasts in top-right corner
- Color-coded by type with icons (CheckCircle, AlertCircle, AlertTriangle, Info)
- Accessible with ARIA attributes
- Smooth animations using custom CSS keyframes
This provides immediate user feedback for all major operations throughout
the application.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 15:42:50 +01:00
|
|
|
toast.error('Failed to open image file');
|
2025-11-21 16:08:24 +01:00
|
|
|
} finally {
|
|
|
|
|
setLoading(false);
|
feat(phase-6): implement comprehensive file operations system
This commit completes Phase 6 of the paint-ui implementation, adding full
file import/export capabilities with drag-drop and clipboard support.
**New Files:**
- lib/file-utils.ts: Core file operations (open, save, export, project format)
- hooks/use-file-operations.ts: React hook for file operations
- hooks/use-drag-drop.ts: Drag & drop state management
- hooks/use-clipboard.ts: Clipboard paste event handling
- components/editor/file-menu.tsx: File menu dropdown component
- components/modals/export-dialog.tsx: Export dialog with format/quality options
- components/modals/new-image-dialog.tsx: New image dialog with presets
- components/modals/index.ts: Modals barrel export
**Updated Files:**
- components/editor/editor-layout.tsx: Integrated FileMenu, drag-drop overlay, clipboard paste
- components/editor/index.ts: Added file-menu export
**Features:**
- ✨ Create new images with dimension presets (Full HD, HD, 800x600, custom)
- ✨ Open image files (PNG, JPG, WEBP) as new layers
- ✨ Save/load .paint project files (JSON with base64 layer data)
- ✨ Export as PNG/JPEG/WEBP with quality control
- ✨ Drag & drop file upload with visual overlay
- ✨ Clipboard paste support (Ctrl+V)
- ✨ File type validation and error handling
- ✨ DataTransfer API integration for unified file handling
**Project File Format (.paint):**
- JSON structure with version, dimensions, layer metadata
- Base64-encoded PNG data for each layer
- Preserves layer properties (opacity, blend mode, order, visibility)
Build verified: ✓ Compiled successfully in 1233ms
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 02:06:49 +01:00
|
|
|
}
|
|
|
|
|
},
|
2025-11-21 16:08:24 +01:00
|
|
|
[clearLayers, clearHistory, setDimensions, createLayer, setLoading]
|
feat(phase-6): implement comprehensive file operations system
This commit completes Phase 6 of the paint-ui implementation, adding full
file import/export capabilities with drag-drop and clipboard support.
**New Files:**
- lib/file-utils.ts: Core file operations (open, save, export, project format)
- hooks/use-file-operations.ts: React hook for file operations
- hooks/use-drag-drop.ts: Drag & drop state management
- hooks/use-clipboard.ts: Clipboard paste event handling
- components/editor/file-menu.tsx: File menu dropdown component
- components/modals/export-dialog.tsx: Export dialog with format/quality options
- components/modals/new-image-dialog.tsx: New image dialog with presets
- components/modals/index.ts: Modals barrel export
**Updated Files:**
- components/editor/editor-layout.tsx: Integrated FileMenu, drag-drop overlay, clipboard paste
- components/editor/index.ts: Added file-menu export
**Features:**
- ✨ Create new images with dimension presets (Full HD, HD, 800x600, custom)
- ✨ Open image files (PNG, JPG, WEBP) as new layers
- ✨ Save/load .paint project files (JSON with base64 layer data)
- ✨ Export as PNG/JPEG/WEBP with quality control
- ✨ Drag & drop file upload with visual overlay
- ✨ Clipboard paste support (Ctrl+V)
- ✨ File type validation and error handling
- ✨ DataTransfer API integration for unified file handling
**Project File Format (.paint):**
- JSON structure with version, dimensions, layer metadata
- Base64-encoded PNG data for each layer
- Preserves layer properties (opacity, blend mode, order, visibility)
Build verified: ✓ Compiled successfully in 1233ms
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 02:06:49 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Open project file
|
|
|
|
|
*/
|
|
|
|
|
const openProject = useCallback(
|
|
|
|
|
async (file: File) => {
|
2025-11-21 16:08:24 +01:00
|
|
|
setLoading(true, `Opening project ${file.name}...`);
|
feat(phase-6): implement comprehensive file operations system
This commit completes Phase 6 of the paint-ui implementation, adding full
file import/export capabilities with drag-drop and clipboard support.
**New Files:**
- lib/file-utils.ts: Core file operations (open, save, export, project format)
- hooks/use-file-operations.ts: React hook for file operations
- hooks/use-drag-drop.ts: Drag & drop state management
- hooks/use-clipboard.ts: Clipboard paste event handling
- components/editor/file-menu.tsx: File menu dropdown component
- components/modals/export-dialog.tsx: Export dialog with format/quality options
- components/modals/new-image-dialog.tsx: New image dialog with presets
- components/modals/index.ts: Modals barrel export
**Updated Files:**
- components/editor/editor-layout.tsx: Integrated FileMenu, drag-drop overlay, clipboard paste
- components/editor/index.ts: Added file-menu export
**Features:**
- ✨ Create new images with dimension presets (Full HD, HD, 800x600, custom)
- ✨ Open image files (PNG, JPG, WEBP) as new layers
- ✨ Save/load .paint project files (JSON with base64 layer data)
- ✨ Export as PNG/JPEG/WEBP with quality control
- ✨ Drag & drop file upload with visual overlay
- ✨ Clipboard paste support (Ctrl+V)
- ✨ File type validation and error handling
- ✨ DataTransfer API integration for unified file handling
**Project File Format (.paint):**
- JSON structure with version, dimensions, layer metadata
- Base64-encoded PNG data for each layer
- Preserves layer properties (opacity, blend mode, order, visibility)
Build verified: ✓ Compiled successfully in 1233ms
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 02:06:49 +01:00
|
|
|
try {
|
|
|
|
|
const projectData = await loadProject(file);
|
|
|
|
|
|
|
|
|
|
clearLayers();
|
|
|
|
|
clearHistory();
|
|
|
|
|
setDimensions(projectData.width, projectData.height);
|
|
|
|
|
|
|
|
|
|
// Recreate layers
|
|
|
|
|
for (const layerData of projectData.layers) {
|
|
|
|
|
const layer = createLayer({
|
|
|
|
|
name: layerData.name,
|
|
|
|
|
width: layerData.width,
|
|
|
|
|
height: layerData.height,
|
|
|
|
|
opacity: layerData.opacity,
|
|
|
|
|
blendMode: layerData.blendMode as any,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Load image data
|
|
|
|
|
if (layerData.imageData && layer.canvas) {
|
|
|
|
|
const canvas = await createCanvasFromDataURL(
|
|
|
|
|
layerData.imageData,
|
|
|
|
|
layerData.width,
|
|
|
|
|
layerData.height
|
|
|
|
|
);
|
|
|
|
|
const ctx = layer.canvas.getContext('2d');
|
|
|
|
|
if (ctx) {
|
|
|
|
|
ctx.drawImage(canvas, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
feat(ui): implement comprehensive toast notification system
Added a complete toast notification system with:
- Toast store using Zustand for state management
- Toast component with 4 types: success, error, warning, info
- Animated slide-in/slide-out transitions
- Auto-dismiss after configurable duration
- Close button on each toast
- Utility functions for easy access (toast.success(), toast.error(), etc.)
Integrated toast notifications into file operations:
- Success notifications for: open image, open project, export image, save project
- Error notifications for: failed operations
- Warning notifications for: unsupported file types
UI Features:
- Stacks toasts in top-right corner
- Color-coded by type with icons (CheckCircle, AlertCircle, AlertTriangle, Info)
- Accessible with ARIA attributes
- Smooth animations using custom CSS keyframes
This provides immediate user feedback for all major operations throughout
the application.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 15:42:50 +01:00
|
|
|
|
|
|
|
|
toast.success(`Opened project ${file.name}`);
|
feat(phase-6): implement comprehensive file operations system
This commit completes Phase 6 of the paint-ui implementation, adding full
file import/export capabilities with drag-drop and clipboard support.
**New Files:**
- lib/file-utils.ts: Core file operations (open, save, export, project format)
- hooks/use-file-operations.ts: React hook for file operations
- hooks/use-drag-drop.ts: Drag & drop state management
- hooks/use-clipboard.ts: Clipboard paste event handling
- components/editor/file-menu.tsx: File menu dropdown component
- components/modals/export-dialog.tsx: Export dialog with format/quality options
- components/modals/new-image-dialog.tsx: New image dialog with presets
- components/modals/index.ts: Modals barrel export
**Updated Files:**
- components/editor/editor-layout.tsx: Integrated FileMenu, drag-drop overlay, clipboard paste
- components/editor/index.ts: Added file-menu export
**Features:**
- ✨ Create new images with dimension presets (Full HD, HD, 800x600, custom)
- ✨ Open image files (PNG, JPG, WEBP) as new layers
- ✨ Save/load .paint project files (JSON with base64 layer data)
- ✨ Export as PNG/JPEG/WEBP with quality control
- ✨ Drag & drop file upload with visual overlay
- ✨ Clipboard paste support (Ctrl+V)
- ✨ File type validation and error handling
- ✨ DataTransfer API integration for unified file handling
**Project File Format (.paint):**
- JSON structure with version, dimensions, layer metadata
- Base64-encoded PNG data for each layer
- Preserves layer properties (opacity, blend mode, order, visibility)
Build verified: ✓ Compiled successfully in 1233ms
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 02:06:49 +01:00
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Failed to open project:', error);
|
feat(ui): implement comprehensive toast notification system
Added a complete toast notification system with:
- Toast store using Zustand for state management
- Toast component with 4 types: success, error, warning, info
- Animated slide-in/slide-out transitions
- Auto-dismiss after configurable duration
- Close button on each toast
- Utility functions for easy access (toast.success(), toast.error(), etc.)
Integrated toast notifications into file operations:
- Success notifications for: open image, open project, export image, save project
- Error notifications for: failed operations
- Warning notifications for: unsupported file types
UI Features:
- Stacks toasts in top-right corner
- Color-coded by type with icons (CheckCircle, AlertCircle, AlertTriangle, Info)
- Accessible with ARIA attributes
- Smooth animations using custom CSS keyframes
This provides immediate user feedback for all major operations throughout
the application.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 15:42:50 +01:00
|
|
|
toast.error('Failed to open project file');
|
2025-11-21 16:08:24 +01:00
|
|
|
} finally {
|
|
|
|
|
setLoading(false);
|
feat(phase-6): implement comprehensive file operations system
This commit completes Phase 6 of the paint-ui implementation, adding full
file import/export capabilities with drag-drop and clipboard support.
**New Files:**
- lib/file-utils.ts: Core file operations (open, save, export, project format)
- hooks/use-file-operations.ts: React hook for file operations
- hooks/use-drag-drop.ts: Drag & drop state management
- hooks/use-clipboard.ts: Clipboard paste event handling
- components/editor/file-menu.tsx: File menu dropdown component
- components/modals/export-dialog.tsx: Export dialog with format/quality options
- components/modals/new-image-dialog.tsx: New image dialog with presets
- components/modals/index.ts: Modals barrel export
**Updated Files:**
- components/editor/editor-layout.tsx: Integrated FileMenu, drag-drop overlay, clipboard paste
- components/editor/index.ts: Added file-menu export
**Features:**
- ✨ Create new images with dimension presets (Full HD, HD, 800x600, custom)
- ✨ Open image files (PNG, JPG, WEBP) as new layers
- ✨ Save/load .paint project files (JSON with base64 layer data)
- ✨ Export as PNG/JPEG/WEBP with quality control
- ✨ Drag & drop file upload with visual overlay
- ✨ Clipboard paste support (Ctrl+V)
- ✨ File type validation and error handling
- ✨ DataTransfer API integration for unified file handling
**Project File Format (.paint):**
- JSON structure with version, dimensions, layer metadata
- Base64-encoded PNG data for each layer
- Preserves layer properties (opacity, blend mode, order, visibility)
Build verified: ✓ Compiled successfully in 1233ms
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 02:06:49 +01:00
|
|
|
}
|
|
|
|
|
},
|
2025-11-21 16:08:24 +01:00
|
|
|
[clearLayers, clearHistory, setDimensions, createLayer, setLoading]
|
feat(phase-6): implement comprehensive file operations system
This commit completes Phase 6 of the paint-ui implementation, adding full
file import/export capabilities with drag-drop and clipboard support.
**New Files:**
- lib/file-utils.ts: Core file operations (open, save, export, project format)
- hooks/use-file-operations.ts: React hook for file operations
- hooks/use-drag-drop.ts: Drag & drop state management
- hooks/use-clipboard.ts: Clipboard paste event handling
- components/editor/file-menu.tsx: File menu dropdown component
- components/modals/export-dialog.tsx: Export dialog with format/quality options
- components/modals/new-image-dialog.tsx: New image dialog with presets
- components/modals/index.ts: Modals barrel export
**Updated Files:**
- components/editor/editor-layout.tsx: Integrated FileMenu, drag-drop overlay, clipboard paste
- components/editor/index.ts: Added file-menu export
**Features:**
- ✨ Create new images with dimension presets (Full HD, HD, 800x600, custom)
- ✨ Open image files (PNG, JPG, WEBP) as new layers
- ✨ Save/load .paint project files (JSON with base64 layer data)
- ✨ Export as PNG/JPEG/WEBP with quality control
- ✨ Drag & drop file upload with visual overlay
- ✨ Clipboard paste support (Ctrl+V)
- ✨ File type validation and error handling
- ✨ DataTransfer API integration for unified file handling
**Project File Format (.paint):**
- JSON structure with version, dimensions, layer metadata
- Base64-encoded PNG data for each layer
- Preserves layer properties (opacity, blend mode, order, visibility)
Build verified: ✓ Compiled successfully in 1233ms
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 02:06:49 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Export current view as image
|
|
|
|
|
*/
|
|
|
|
|
const exportImage = useCallback(
|
|
|
|
|
async (format: 'png' | 'jpeg' | 'webp', quality: number, filename: string) => {
|
2025-11-21 16:08:24 +01:00
|
|
|
setLoading(true, `Exporting ${filename}.${format}...`);
|
feat(ui): implement comprehensive toast notification system
Added a complete toast notification system with:
- Toast store using Zustand for state management
- Toast component with 4 types: success, error, warning, info
- Animated slide-in/slide-out transitions
- Auto-dismiss after configurable duration
- Close button on each toast
- Utility functions for easy access (toast.success(), toast.error(), etc.)
Integrated toast notifications into file operations:
- Success notifications for: open image, open project, export image, save project
- Error notifications for: failed operations
- Warning notifications for: unsupported file types
UI Features:
- Stacks toasts in top-right corner
- Color-coded by type with icons (CheckCircle, AlertCircle, AlertTriangle, Info)
- Accessible with ARIA attributes
- Smooth animations using custom CSS keyframes
This provides immediate user feedback for all major operations throughout
the application.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 15:42:50 +01:00
|
|
|
try {
|
|
|
|
|
// Create temporary canvas with all layers
|
|
|
|
|
const tempCanvas = document.createElement('canvas');
|
|
|
|
|
tempCanvas.width = width;
|
|
|
|
|
tempCanvas.height = height;
|
|
|
|
|
const ctx = tempCanvas.getContext('2d');
|
|
|
|
|
|
|
|
|
|
if (!ctx) {
|
|
|
|
|
toast.error('Failed to create export canvas');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Draw all visible layers
|
|
|
|
|
layers
|
|
|
|
|
.filter((layer) => layer.visible && layer.canvas)
|
|
|
|
|
.sort((a, b) => a.order - b.order)
|
|
|
|
|
.forEach((layer) => {
|
|
|
|
|
if (!layer.canvas) return;
|
|
|
|
|
ctx.globalAlpha = layer.opacity;
|
|
|
|
|
ctx.globalCompositeOperation = layer.blendMode as GlobalCompositeOperation;
|
|
|
|
|
ctx.drawImage(layer.canvas, layer.x, layer.y);
|
|
|
|
|
});
|
feat(phase-6): implement comprehensive file operations system
This commit completes Phase 6 of the paint-ui implementation, adding full
file import/export capabilities with drag-drop and clipboard support.
**New Files:**
- lib/file-utils.ts: Core file operations (open, save, export, project format)
- hooks/use-file-operations.ts: React hook for file operations
- hooks/use-drag-drop.ts: Drag & drop state management
- hooks/use-clipboard.ts: Clipboard paste event handling
- components/editor/file-menu.tsx: File menu dropdown component
- components/modals/export-dialog.tsx: Export dialog with format/quality options
- components/modals/new-image-dialog.tsx: New image dialog with presets
- components/modals/index.ts: Modals barrel export
**Updated Files:**
- components/editor/editor-layout.tsx: Integrated FileMenu, drag-drop overlay, clipboard paste
- components/editor/index.ts: Added file-menu export
**Features:**
- ✨ Create new images with dimension presets (Full HD, HD, 800x600, custom)
- ✨ Open image files (PNG, JPG, WEBP) as new layers
- ✨ Save/load .paint project files (JSON with base64 layer data)
- ✨ Export as PNG/JPEG/WEBP with quality control
- ✨ Drag & drop file upload with visual overlay
- ✨ Clipboard paste support (Ctrl+V)
- ✨ File type validation and error handling
- ✨ DataTransfer API integration for unified file handling
**Project File Format (.paint):**
- JSON structure with version, dimensions, layer metadata
- Base64-encoded PNG data for each layer
- Preserves layer properties (opacity, blend mode, order, visibility)
Build verified: ✓ Compiled successfully in 1233ms
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 02:06:49 +01:00
|
|
|
|
feat(ui): implement comprehensive toast notification system
Added a complete toast notification system with:
- Toast store using Zustand for state management
- Toast component with 4 types: success, error, warning, info
- Animated slide-in/slide-out transitions
- Auto-dismiss after configurable duration
- Close button on each toast
- Utility functions for easy access (toast.success(), toast.error(), etc.)
Integrated toast notifications into file operations:
- Success notifications for: open image, open project, export image, save project
- Error notifications for: failed operations
- Warning notifications for: unsupported file types
UI Features:
- Stacks toasts in top-right corner
- Color-coded by type with icons (CheckCircle, AlertCircle, AlertTriangle, Info)
- Accessible with ARIA attributes
- Smooth animations using custom CSS keyframes
This provides immediate user feedback for all major operations throughout
the application.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 15:42:50 +01:00
|
|
|
ctx.globalAlpha = 1;
|
|
|
|
|
ctx.globalCompositeOperation = 'source-over';
|
feat(phase-6): implement comprehensive file operations system
This commit completes Phase 6 of the paint-ui implementation, adding full
file import/export capabilities with drag-drop and clipboard support.
**New Files:**
- lib/file-utils.ts: Core file operations (open, save, export, project format)
- hooks/use-file-operations.ts: React hook for file operations
- hooks/use-drag-drop.ts: Drag & drop state management
- hooks/use-clipboard.ts: Clipboard paste event handling
- components/editor/file-menu.tsx: File menu dropdown component
- components/modals/export-dialog.tsx: Export dialog with format/quality options
- components/modals/new-image-dialog.tsx: New image dialog with presets
- components/modals/index.ts: Modals barrel export
**Updated Files:**
- components/editor/editor-layout.tsx: Integrated FileMenu, drag-drop overlay, clipboard paste
- components/editor/index.ts: Added file-menu export
**Features:**
- ✨ Create new images with dimension presets (Full HD, HD, 800x600, custom)
- ✨ Open image files (PNG, JPG, WEBP) as new layers
- ✨ Save/load .paint project files (JSON with base64 layer data)
- ✨ Export as PNG/JPEG/WEBP with quality control
- ✨ Drag & drop file upload with visual overlay
- ✨ Clipboard paste support (Ctrl+V)
- ✨ File type validation and error handling
- ✨ DataTransfer API integration for unified file handling
**Project File Format (.paint):**
- JSON structure with version, dimensions, layer metadata
- Base64-encoded PNG data for each layer
- Preserves layer properties (opacity, blend mode, order, visibility)
Build verified: ✓ Compiled successfully in 1233ms
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 02:06:49 +01:00
|
|
|
|
feat(ui): implement comprehensive toast notification system
Added a complete toast notification system with:
- Toast store using Zustand for state management
- Toast component with 4 types: success, error, warning, info
- Animated slide-in/slide-out transitions
- Auto-dismiss after configurable duration
- Close button on each toast
- Utility functions for easy access (toast.success(), toast.error(), etc.)
Integrated toast notifications into file operations:
- Success notifications for: open image, open project, export image, save project
- Error notifications for: failed operations
- Warning notifications for: unsupported file types
UI Features:
- Stacks toasts in top-right corner
- Color-coded by type with icons (CheckCircle, AlertCircle, AlertTriangle, Info)
- Accessible with ARIA attributes
- Smooth animations using custom CSS keyframes
This provides immediate user feedback for all major operations throughout
the application.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 15:42:50 +01:00
|
|
|
await exportCanvasAsImage(tempCanvas, format, quality, filename);
|
|
|
|
|
toast.success(`Exported ${filename}.${format}`);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Failed to export image:', error);
|
|
|
|
|
toast.error('Failed to export image');
|
2025-11-21 16:08:24 +01:00
|
|
|
} finally {
|
|
|
|
|
setLoading(false);
|
feat(ui): implement comprehensive toast notification system
Added a complete toast notification system with:
- Toast store using Zustand for state management
- Toast component with 4 types: success, error, warning, info
- Animated slide-in/slide-out transitions
- Auto-dismiss after configurable duration
- Close button on each toast
- Utility functions for easy access (toast.success(), toast.error(), etc.)
Integrated toast notifications into file operations:
- Success notifications for: open image, open project, export image, save project
- Error notifications for: failed operations
- Warning notifications for: unsupported file types
UI Features:
- Stacks toasts in top-right corner
- Color-coded by type with icons (CheckCircle, AlertCircle, AlertTriangle, Info)
- Accessible with ARIA attributes
- Smooth animations using custom CSS keyframes
This provides immediate user feedback for all major operations throughout
the application.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 15:42:50 +01:00
|
|
|
}
|
feat(phase-6): implement comprehensive file operations system
This commit completes Phase 6 of the paint-ui implementation, adding full
file import/export capabilities with drag-drop and clipboard support.
**New Files:**
- lib/file-utils.ts: Core file operations (open, save, export, project format)
- hooks/use-file-operations.ts: React hook for file operations
- hooks/use-drag-drop.ts: Drag & drop state management
- hooks/use-clipboard.ts: Clipboard paste event handling
- components/editor/file-menu.tsx: File menu dropdown component
- components/modals/export-dialog.tsx: Export dialog with format/quality options
- components/modals/new-image-dialog.tsx: New image dialog with presets
- components/modals/index.ts: Modals barrel export
**Updated Files:**
- components/editor/editor-layout.tsx: Integrated FileMenu, drag-drop overlay, clipboard paste
- components/editor/index.ts: Added file-menu export
**Features:**
- ✨ Create new images with dimension presets (Full HD, HD, 800x600, custom)
- ✨ Open image files (PNG, JPG, WEBP) as new layers
- ✨ Save/load .paint project files (JSON with base64 layer data)
- ✨ Export as PNG/JPEG/WEBP with quality control
- ✨ Drag & drop file upload with visual overlay
- ✨ Clipboard paste support (Ctrl+V)
- ✨ File type validation and error handling
- ✨ DataTransfer API integration for unified file handling
**Project File Format (.paint):**
- JSON structure with version, dimensions, layer metadata
- Base64-encoded PNG data for each layer
- Preserves layer properties (opacity, blend mode, order, visibility)
Build verified: ✓ Compiled successfully in 1233ms
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 02:06:49 +01:00
|
|
|
},
|
2025-11-21 16:08:24 +01:00
|
|
|
[layers, width, height, setLoading]
|
feat(phase-6): implement comprehensive file operations system
This commit completes Phase 6 of the paint-ui implementation, adding full
file import/export capabilities with drag-drop and clipboard support.
**New Files:**
- lib/file-utils.ts: Core file operations (open, save, export, project format)
- hooks/use-file-operations.ts: React hook for file operations
- hooks/use-drag-drop.ts: Drag & drop state management
- hooks/use-clipboard.ts: Clipboard paste event handling
- components/editor/file-menu.tsx: File menu dropdown component
- components/modals/export-dialog.tsx: Export dialog with format/quality options
- components/modals/new-image-dialog.tsx: New image dialog with presets
- components/modals/index.ts: Modals barrel export
**Updated Files:**
- components/editor/editor-layout.tsx: Integrated FileMenu, drag-drop overlay, clipboard paste
- components/editor/index.ts: Added file-menu export
**Features:**
- ✨ Create new images with dimension presets (Full HD, HD, 800x600, custom)
- ✨ Open image files (PNG, JPG, WEBP) as new layers
- ✨ Save/load .paint project files (JSON with base64 layer data)
- ✨ Export as PNG/JPEG/WEBP with quality control
- ✨ Drag & drop file upload with visual overlay
- ✨ Clipboard paste support (Ctrl+V)
- ✨ File type validation and error handling
- ✨ DataTransfer API integration for unified file handling
**Project File Format (.paint):**
- JSON structure with version, dimensions, layer metadata
- Base64-encoded PNG data for each layer
- Preserves layer properties (opacity, blend mode, order, visibility)
Build verified: ✓ Compiled successfully in 1233ms
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 02:06:49 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Save project file
|
|
|
|
|
*/
|
|
|
|
|
const saveProject = useCallback(
|
|
|
|
|
async (filename: string) => {
|
2025-11-21 16:08:24 +01:00
|
|
|
setLoading(true, `Saving project ${filename}.json...`);
|
feat(ui): implement comprehensive toast notification system
Added a complete toast notification system with:
- Toast store using Zustand for state management
- Toast component with 4 types: success, error, warning, info
- Animated slide-in/slide-out transitions
- Auto-dismiss after configurable duration
- Close button on each toast
- Utility functions for easy access (toast.success(), toast.error(), etc.)
Integrated toast notifications into file operations:
- Success notifications for: open image, open project, export image, save project
- Error notifications for: failed operations
- Warning notifications for: unsupported file types
UI Features:
- Stacks toasts in top-right corner
- Color-coded by type with icons (CheckCircle, AlertCircle, AlertTriangle, Info)
- Accessible with ARIA attributes
- Smooth animations using custom CSS keyframes
This provides immediate user feedback for all major operations throughout
the application.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 15:42:50 +01:00
|
|
|
try {
|
|
|
|
|
await exportProject(layers, width, height, filename);
|
|
|
|
|
toast.success(`Saved project ${filename}.json`);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Failed to save project:', error);
|
|
|
|
|
toast.error('Failed to save project');
|
2025-11-21 16:08:24 +01:00
|
|
|
} finally {
|
|
|
|
|
setLoading(false);
|
feat(ui): implement comprehensive toast notification system
Added a complete toast notification system with:
- Toast store using Zustand for state management
- Toast component with 4 types: success, error, warning, info
- Animated slide-in/slide-out transitions
- Auto-dismiss after configurable duration
- Close button on each toast
- Utility functions for easy access (toast.success(), toast.error(), etc.)
Integrated toast notifications into file operations:
- Success notifications for: open image, open project, export image, save project
- Error notifications for: failed operations
- Warning notifications for: unsupported file types
UI Features:
- Stacks toasts in top-right corner
- Color-coded by type with icons (CheckCircle, AlertCircle, AlertTriangle, Info)
- Accessible with ARIA attributes
- Smooth animations using custom CSS keyframes
This provides immediate user feedback for all major operations throughout
the application.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 15:42:50 +01:00
|
|
|
}
|
feat(phase-6): implement comprehensive file operations system
This commit completes Phase 6 of the paint-ui implementation, adding full
file import/export capabilities with drag-drop and clipboard support.
**New Files:**
- lib/file-utils.ts: Core file operations (open, save, export, project format)
- hooks/use-file-operations.ts: React hook for file operations
- hooks/use-drag-drop.ts: Drag & drop state management
- hooks/use-clipboard.ts: Clipboard paste event handling
- components/editor/file-menu.tsx: File menu dropdown component
- components/modals/export-dialog.tsx: Export dialog with format/quality options
- components/modals/new-image-dialog.tsx: New image dialog with presets
- components/modals/index.ts: Modals barrel export
**Updated Files:**
- components/editor/editor-layout.tsx: Integrated FileMenu, drag-drop overlay, clipboard paste
- components/editor/index.ts: Added file-menu export
**Features:**
- ✨ Create new images with dimension presets (Full HD, HD, 800x600, custom)
- ✨ Open image files (PNG, JPG, WEBP) as new layers
- ✨ Save/load .paint project files (JSON with base64 layer data)
- ✨ Export as PNG/JPEG/WEBP with quality control
- ✨ Drag & drop file upload with visual overlay
- ✨ Clipboard paste support (Ctrl+V)
- ✨ File type validation and error handling
- ✨ DataTransfer API integration for unified file handling
**Project File Format (.paint):**
- JSON structure with version, dimensions, layer metadata
- Base64-encoded PNG data for each layer
- Preserves layer properties (opacity, blend mode, order, visibility)
Build verified: ✓ Compiled successfully in 1233ms
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 02:06:49 +01:00
|
|
|
},
|
2025-11-21 16:08:24 +01:00
|
|
|
[layers, width, height, setLoading]
|
feat(phase-6): implement comprehensive file operations system
This commit completes Phase 6 of the paint-ui implementation, adding full
file import/export capabilities with drag-drop and clipboard support.
**New Files:**
- lib/file-utils.ts: Core file operations (open, save, export, project format)
- hooks/use-file-operations.ts: React hook for file operations
- hooks/use-drag-drop.ts: Drag & drop state management
- hooks/use-clipboard.ts: Clipboard paste event handling
- components/editor/file-menu.tsx: File menu dropdown component
- components/modals/export-dialog.tsx: Export dialog with format/quality options
- components/modals/new-image-dialog.tsx: New image dialog with presets
- components/modals/index.ts: Modals barrel export
**Updated Files:**
- components/editor/editor-layout.tsx: Integrated FileMenu, drag-drop overlay, clipboard paste
- components/editor/index.ts: Added file-menu export
**Features:**
- ✨ Create new images with dimension presets (Full HD, HD, 800x600, custom)
- ✨ Open image files (PNG, JPG, WEBP) as new layers
- ✨ Save/load .paint project files (JSON with base64 layer data)
- ✨ Export as PNG/JPEG/WEBP with quality control
- ✨ Drag & drop file upload with visual overlay
- ✨ Clipboard paste support (Ctrl+V)
- ✨ File type validation and error handling
- ✨ DataTransfer API integration for unified file handling
**Project File Format (.paint):**
- JSON structure with version, dimensions, layer metadata
- Base64-encoded PNG data for each layer
- Preserves layer properties (opacity, blend mode, order, visibility)
Build verified: ✓ Compiled successfully in 1233ms
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 02:06:49 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handle file drop or paste
|
|
|
|
|
*/
|
|
|
|
|
const handleFileInput = useCallback(
|
|
|
|
|
async (file: File) => {
|
|
|
|
|
if (isProjectFile(file)) {
|
|
|
|
|
await openProject(file);
|
|
|
|
|
} else if (isImageFile(file)) {
|
|
|
|
|
await openImage(file);
|
|
|
|
|
} else {
|
feat(ui): implement comprehensive toast notification system
Added a complete toast notification system with:
- Toast store using Zustand for state management
- Toast component with 4 types: success, error, warning, info
- Animated slide-in/slide-out transitions
- Auto-dismiss after configurable duration
- Close button on each toast
- Utility functions for easy access (toast.success(), toast.error(), etc.)
Integrated toast notifications into file operations:
- Success notifications for: open image, open project, export image, save project
- Error notifications for: failed operations
- Warning notifications for: unsupported file types
UI Features:
- Stacks toasts in top-right corner
- Color-coded by type with icons (CheckCircle, AlertCircle, AlertTriangle, Info)
- Accessible with ARIA attributes
- Smooth animations using custom CSS keyframes
This provides immediate user feedback for all major operations throughout
the application.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 15:42:50 +01:00
|
|
|
toast.warning('Unsupported file type');
|
feat(phase-6): implement comprehensive file operations system
This commit completes Phase 6 of the paint-ui implementation, adding full
file import/export capabilities with drag-drop and clipboard support.
**New Files:**
- lib/file-utils.ts: Core file operations (open, save, export, project format)
- hooks/use-file-operations.ts: React hook for file operations
- hooks/use-drag-drop.ts: Drag & drop state management
- hooks/use-clipboard.ts: Clipboard paste event handling
- components/editor/file-menu.tsx: File menu dropdown component
- components/modals/export-dialog.tsx: Export dialog with format/quality options
- components/modals/new-image-dialog.tsx: New image dialog with presets
- components/modals/index.ts: Modals barrel export
**Updated Files:**
- components/editor/editor-layout.tsx: Integrated FileMenu, drag-drop overlay, clipboard paste
- components/editor/index.ts: Added file-menu export
**Features:**
- ✨ Create new images with dimension presets (Full HD, HD, 800x600, custom)
- ✨ Open image files (PNG, JPG, WEBP) as new layers
- ✨ Save/load .paint project files (JSON with base64 layer data)
- ✨ Export as PNG/JPEG/WEBP with quality control
- ✨ Drag & drop file upload with visual overlay
- ✨ Clipboard paste support (Ctrl+V)
- ✨ File type validation and error handling
- ✨ DataTransfer API integration for unified file handling
**Project File Format (.paint):**
- JSON structure with version, dimensions, layer metadata
- Base64-encoded PNG data for each layer
- Preserves layer properties (opacity, blend mode, order, visibility)
Build verified: ✓ Compiled successfully in 1233ms
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 02:06:49 +01:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
[openProject, openImage]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handle data transfer (drag & drop or paste)
|
|
|
|
|
*/
|
|
|
|
|
const handleDataTransfer = useCallback(
|
|
|
|
|
async (dataTransfer: DataTransfer) => {
|
|
|
|
|
const file = extractImageFromDataTransfer(dataTransfer);
|
|
|
|
|
if (file) {
|
|
|
|
|
await handleFileInput(file);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
[handleFileInput]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
createNewImage,
|
|
|
|
|
openImage,
|
|
|
|
|
openProject,
|
|
|
|
|
exportImage,
|
|
|
|
|
saveProject,
|
|
|
|
|
handleFileInput,
|
|
|
|
|
handleDataTransfer,
|
|
|
|
|
};
|
|
|
|
|
}
|