-
Notifications
You must be signed in to change notification settings - Fork 2k
[lexical-playground] Feature: Add file attachment support with drag & drop functionality #7895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…usable file info display - Add FilePreview component for showing file metadata - Display file name, size, and type information - Include CSS styling for consistent appearance
…chment node implementation - Implement DecoratorNode for file attachments with metadata (name, size, type, data) - Add base64 ↔ object URL conversion utilities for serialization - Support DOM import/export with data attributes - Include comprehensive serialization/deserialization logic - Add getter/setter methods for all attachment properties
…omponent for attachment display - Add React component for rendering attachment nodes - Implement file type icon mapping and display - Add selection handling and keyboard navigation - Support attachment deletion and interaction - Include floating UI for attachment actions
…drop and file insertion - Add plugin for handling file attachments in editor - Implement drag & drop file upload functionality - Support file insertion via commands and dialog - Add file validation and size limits (3MB) - Handle various file types and formats - Include attachment URL cleanup on editor destroy
…yground nodes - Add AttachmentNode to PlaygroundNodes array - Enable attachment functionality in editor
…o playground editor - Add AttachmentPlugin to Editor component - Enable attachment functionality in playground editor
- Add paperclip icon for attachment functionality - Integrate attachment insertion dialog in toolbar - Add UI controls for file upload
…theme updates - Add CSS classes for attachment node styling - Update playground theme for attachment display - Include responsive design for attachment components
- Add helper functions for attachment e2e testing - Include file upload simulation utilities - Add attachment interaction test helpers
…r attachment functionality - Add Playwright tests for attachment drag & drop workflow - Test file upload dialog and attachment display - Verify attachment deletion and keyboard navigation - Add file type validation and size limit tests - Include attachment serialization/deserialization tests
…n DragDropPastePlugin - Add attachment file type validation alongside existing image types - Support drag & drop for documents (PDF, Office files), archives, text, video, and audio files - Implement 3MB size limit validation for attachment files - Add file type inference from extension when MIME type is unavailable - Prioritize image insertion over attachment for image files - Include comprehensive file type mapping for attachment formats - Handle unsupported file types with appropriate warnings
The latest updates on your projects. Learn more about Vercel for GitHub.
|
File uploads encoded as base64 isn't really a very good idea. It's done for images just for demonstration purposes, but in order to support attachments (and images) in any real production capacity you would really need to have some server-side code or service provider (amazon s3, cloudflare r2, etc.) storing those files and the document should only store the URLs. My concern about adding more examples of what not to do will lead to more bad code in people's applications. |
@etrepum |
One useful primitive that I found when using Lexical for editing pages on GitHub-backed site is:
Like so, content with attached images/files can be nicely edited in markdown and conversion markdown <> visual representation I named this "ImageRegistry", but maybe this concept could be fused into AttachmentStore |
Description
Current behavior:
Changes being added:
The implementation includes proper cleanup of object URLs, keyboard navigation support, and responsive styling that matches the playground theme.
Test plan
Before
After
File Upload Dialog:
Drag & Drop Functionality:
Attachment Display:
Serialization & Persistence:
Supported File Types:
E2E Test Coverage:
attachment.mov