@@ -28,15 +28,17 @@ The toolbar is built using React functional components and hooks. It's organized
2828### Main Components
2929
3030- ** ` MarkdownToolbar.tsx ` ** : Main toolbar component
31+ - ** ` ImagePicker.tsx ` ** : Reusable image picker component (upload, URL, Unsplash)
3132- ** ` ToolbarButton.tsx ` ** : Reusable button component
3233- ** ` ToolbarDivider.tsx ` ** : Visual separator component
33- - ** ` PopupForm.tsx ` ** : Generic popup form component
34+ - ** ` PopupForm.tsx ` ** : Generic popup form component with file upload support
3435
3536### File Structure
3637
3738``` text
3839src/features/editor/components/
3940├── MarkdownToolbar.tsx # Main toolbar component
41+ ├── ImagePicker.tsx # Reusable image picker component
4042└── toolbar/
4143 ├── ToolbarButton.tsx # Reusable button component
4244 ├── ToolbarDivider.tsx # Visual divider
@@ -193,19 +195,38 @@ Opens when clicking the Image button:
193195** Fields:**
194196
195197- Alt Text: Alternative text for the image
196- - Image URL: The image source URL
198+ - Upload Image: File upload with drag-and-drop support
199+ - Enter Image URL: Manual URL input
200+ - Search Images from Unsplash: Opens Unsplash image search modal
201+
202+ ** Image Upload Features:**
203+
204+ - ** Drag & Drop** : Drag images directly into the upload area
205+ - ** File Selection** : Click to browse and select image files
206+ - ** Paste Support** : Paste images from clipboard (handled in ContentEditor)
207+ - ** File Validation** :
208+ - Supported formats: JPG, PNG, GIF, WebP
209+ - Maximum file size: 2MB
210+ - ** Upload Progress** : Real-time progress bar during upload
211+ - ** Image Preview** : Preview before upload
212+ - ** Error Handling** : Clear error messages for validation failures
197213
198214** Behavior:**
199215
200216- Pre-fills "Alt Text" if text is selected
217+ - Three options available: Upload, URL, or Unsplash search
218+ - Options are separated with dividers ("or")
219+ - When file is selected, URL field is hidden
220+ - When URL is entered, upload field is hidden
201221- Closes on outside click
202222- Clears values when canceled
203223- Inserts: `  `
204224
205225** Validation:**
206226
207- - URL field required
208- - Submit button disabled if URL is empty
227+ - Either file upload or URL required
228+ - Alt text required when uploading file
229+ - Submit button disabled if no image source is provided
209230
210231### Table Popup
211232
@@ -554,14 +575,34 @@ The toolbar is integrated into `ContentEditor.tsx`:
5545755 . ** Responsive** : Works seamlessly on mobile and desktop
5555766 . ** Language Independence** : Keyboard shortcuts work regardless of keyboard layout
556577
578+ ## Image Upload Service
579+
580+ The image upload feature uses a dedicated service that handles:
581+
582+ - ** File Validation** : Type and size validation (max 2MB)
583+ - ** Base64 Encoding** : Converts image to base64 for API transmission
584+ - ** Progress Tracking** : Real-time upload progress updates
585+ - ** Error Handling** : Comprehensive error messages
586+ - ** S3 Integration** : Uploads to AWS S3 via Lambda function
587+ - ** Authentication** : Requires user authentication (AWS Cognito)
588+
589+ ** Service Location** : ` src/features/editor/services/imageUploadService.ts `
590+
591+ ** Backend Integration** :
592+
593+ - Lambda function: ` backend/src/lambda/images/upload.ts `
594+ - API endpoint: ` POST /images/upload `
595+ - Storage: AWS S3 bucket with public read access
596+ - CORS: Configured for cross-origin requests
597+
557598## Future Enhancements
558599
559600Potential improvements for future versions:
560601
561602- Custom table styling options
562- - Image upload and preview
563603- Link validation
564604- Formatting presets/templates
565605- Undo/redo for individual formatting actions
566- - Drag-and-drop image insertion
567606- Emoji picker integration
607+ - Image editing (crop, resize)
608+ - Multiple image upload
0 commit comments