plane icon indicating copy to clipboard operation
plane copied to clipboard

[WEB-2450] dev: custom image extension

Open Palanikannan1437 opened this issue 1 year ago • 1 comments

What's new?

This PR adds a new custom image extension to handle image uploads.

  1. Editor now supports multiple images drop and paste.
  2. While the images load, a placeholder is shown of the size of the image to prevent any content shift.

Improvements:

  1. Each image node now has its own resize handle instead of the old global handle for all the image nodes.
  2. Image resize handle now appears when the user hovers over an image.
  3. Images now have a new and improved selected state(blue overlay).

Media:

https://github.com/user-attachments/assets/bc60018d-b80e-45c4-b255-99271d390b72

Plane issue: WEB-2450

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a custom image component allowing interactive resizing and improved image upload handling via drag-and-drop or file selection.
    • Added support for read-only images, enhancing the editor's capability to display images without editing options.
  • Improvements

    • Streamlined image upload processes, allowing for multiple images to be uploaded simultaneously.
    • Enhanced error handling and performance optimizations in the editor's configuration and hooks.
  • Bug Fixes

    • Adjusted styling for images to ensure consistent appearance and interaction behavior.

These updates aim to enhance the user experience and functionality of the document editor.

Palanikannan1437 avatar Sep 11 '24 15:09 Palanikannan1437

Walkthrough

The changes primarily focus on refactoring file handling and image upload functionalities within the editor. The fileHandler prop has been removed from various components, simplifying the upload process. New components for custom image handling have been introduced, enhancing the editor's capabilities for managing images, including drag-and-drop uploads and read-only image displays. Overall, these modifications streamline interactions related to image handling in the editor.

Changes

File Path Change Summary
packages/editor/src/ce/extensions/document-extensions.tsx Removed fileHandler prop from DocumentEditorAdditionalExtensions, simplifying file upload functionality.
packages/editor/src/core/components/menus/menu-items.ts Updated ImageItem to remove uploadFile parameter and modified command handling for image uploads.
packages/editor/src/core/extensions/custom-image/components/image-node.tsx Added CustomImageNode for handling image uploads and display, integrating drag-and-drop functionality.
packages/editor/src/core/extensions/custom-image/custom-image.ts Implemented a custom image extension with enhanced upload capabilities and storage management.
packages/editor/src/core/extensions/custom-image/read-only-custom-image.ts Added CustomReadOnlyImageExtension for displaying images in a non-editable format.
packages/editor/src/core/extensions/extensions.tsx Added CustomImageExtension for improved image management and modified DropHandlerExtension.
packages/editor/src/core/hooks/use-file-upload.ts Introduced hooks for managing file uploads, including drag-and-drop functionality.
packages/editor/src/core/plugins/image/delete-image.ts Enhanced TrackImageDeletionPlugin to handle different types of image nodes dynamically.
packages/editor/src/core/plugins/image/restore-image.ts Enhanced TrackImageRestorationPlugin to accept a nodeType parameter for flexibility in image node handling.
packages/editor/src/styles/drag-drop.css Refined styles for selected nodes and introduced new styles for image components during drag-and-drop interactions.
packages/editor/src/styles/editor.css Adjusted image styling for hover effects and margins.
packages/helpers/package.json Updated build configuration to support modern JavaScript module standards, including new main, module, and types entries.

Possibly related PRs

  • #5582: The changes in this PR involve the removal of the .svg format from the accepted image formats during uploads, which is related to the overall handling of image uploads in the application, similar to the changes made in the main PR regarding file handling.

Suggested labels

🌟enhancement, 🧹chore

Poem

🐰 In the editor's realm, images now play,
With uploads so smooth, they brighten the day.
No more handlers fussing, just drag and drop,
A whimsical journey, we’ll never stop!
Custom blocks and nodes, all ready to shine,
In this rich text garden, everything's fine! 🌼


Recent review details

Configuration used: CodeRabbit UI Review profile: CHILL

Commits

Files that changed from the base of the PR and between 889dbb5a67f5c2fcf760f6c0c0bb2b52394c1f1c and 1330a0ff49129076a3ddbea0d77c3a18cbd9333a.

Files selected for processing (1)
  • packages/editor/src/core/extensions/custom-image/components/image-block.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/editor/src/core/extensions/custom-image/components/image-block.tsx

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example: -- I pushed a fix in commit <commit_id>, please review it. -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples: -- @coderabbitai generate unit testing code for this file. -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: -- @coderabbitai generate interesting stats about this repository and render them as a table. -- @coderabbitai read src/utils.ts and generate unit testing code. -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format. -- @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar Sep 11 '24 15:09 coderabbitai[bot]