Skip to content
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

[Fixes]: Working on image editor stuff. #64

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

Anishali2
Copy link
Collaborator

@Anishali2 Anishali2 commented Mar 6, 2025

Summary by CodeRabbit

  • New Features
    • Enhanced Drawing Experience: Improved cursor behavior, emoji sizing, and shape rendering for smoother and more precise drawing.
    • Interactive Enhancements: Upgraded mouse interactions and dynamic scaling for more responsive shape transformations.
    • Tool Selection Updates: Refined active tool management for a more consistent editing experience.
    • Commenting Improvements: Added comments to clarify functionality and enhance code readability.
  • Bug Fixes
    • Adjusted cursor text and number positioning for better alignment.
  • Chores
    • Removed unnecessary whitespace in the ToolsPanel component.

@Anishali2 Anishali2 self-assigned this Mar 6, 2025
@Anishali2 Anishali2 linked an issue Mar 6, 2025 that may be closed by this pull request
Copy link

coderabbitai bot commented Mar 6, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This pull request introduces several modifications across different modules within the application. In the editor service, adjustments have been made to cursor handling and shape dimension calculations, including scaling changes and default attribute settings. Several helper functions in the blur drawer were made publicly accessible, while the shape drawing process was enhanced with additional mouse event listeners and initialization steps. Minor whitespace and placeholder modifications were introduced in the tools panel, and clarifying comments were added in the editor screen without altering its functionality.

Changes

File(s) Change Summary
apps/portal/app/services/editor/editor.ts Updated EditorService methods: added setShapeCursor, modified replaceEmoji (increased dimensions from (64*stageScale)/100 to (128*stageScale)/100), adjusted scaling factors in replaceMarkers (from 2 to 1.1), reduced font size from 44 to 20, decreased padding by 6, set defaults for x and y.
apps/portal/components/pagesComponents/_editorScreen/editorHelpers/blurDrawer.ts Changed several functions (drawBlurDragmoveListener, drawBlurDragstartListener, drawBlurDragedListener, drawBlurMouseMoveListener, drawBlurMouseUpListener) from private to public by adding the export keyword, making them accessible to other modules.
apps/portal/components/pagesComponents/_editorScreen/editorHelpers/shapeDrawer.ts Enhanced shape drawing: modified initial shape dimensions (width/height set to 1 and removed a positional offset), introduced a new blurScale variable, and added event listeners for mouse movements and drags by importing functions (drawBlurMouseMoveListener, drawBlurMouseUpListener, drawBlurDragmoveListener), and initializing pointer transformations and events.
apps/portal/components/pagesComponents/_editorScreen/toolsPanel/ToolsPanel.tsx Removed redundant whitespace and added a placeholder line containing "asdf" within a ToolsRow component. No changes affecting functionality.
apps/portal/pages/edit/[id].tsx Commented out the logic that updates the active tool based on dependency checks and added clarifying comments regarding shape type checks and stage resizing. No structural API changes were made.

Sequence Diagram(s)

sequenceDiagram
  participant U as User
  participant SD as ShapeDrawer (drawShapeMouseDownListener)
  participant PT as PointerTransformer
  participant EL as EventListeners
  participant BD as BlurDrawer Functions
  participant Stage as Canvas/Stage

  U->>SD: MouseDown Event
  SD->>PT: Initialize Pointer Transformer
  SD->>EL: Setup Event Listeners (initEventListeners)
  EL->>BD: Invoke drawBlurMouseMoveListener
  EL->>BD: Invoke drawBlurMouseUpListener
  EL->>BD: Invoke drawBlurDragmoveListener
  BD->>Stage: Update shape dimensions & position
  Stage-->>EL: Render updated shape
  U->>SD: MouseUp Event
Loading

Poem

I'm a rabbit with a hop so light,
Skipping through code in the moonlit night.
New cursors shine and shapes grow tall,
Functions now roam free for one and all.
With every change, I dance and cheer—
Code so fresh, it brings a joyful tear!
Hop on, dear coders, the time is here!


🪧 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 generate docstrings to generate docstrings for this 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.

@Anishali2
Copy link
Collaborator Author

Sir @evereq Don't merge this PR I'll create this PR for backup so that I can work more effectively and create a track record

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (3)
apps/portal/pages/edit/[id].tsx (3)

614-614: Improve comment specificity.

The comment "This is checking shape type color size etc" is too vague. Consider providing more detailed information about what types of shapes are being checked and how this affects the application.


1090-1091: Remove TODO-style comment.

This comment appears to be a placeholder or reminder. If this code is complete, the comment should be removed. If additional work is needed, use a proper TODO format with specific details.


1192-1192: Remove TODO-style comment.

Similar to the previous comment, this appears to be a placeholder. Either remove it if the implementation is complete or replace it with a proper documentation comment.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 71210ab and e92b2d0.

📒 Files selected for processing (5)
  • apps/portal/app/services/editor/editor.ts (4 hunks)
  • apps/portal/components/pagesComponents/_editorScreen/editorHelpers/blurDrawer.ts (4 hunks)
  • apps/portal/components/pagesComponents/_editorScreen/editorHelpers/shapeDrawer.ts (4 hunks)
  • apps/portal/components/pagesComponents/_editorScreen/toolsPanel/ToolsPanel.tsx (1 hunks)
  • apps/portal/pages/edit/[id].tsx (6 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/portal/components/pagesComponents/_editorScreen/toolsPanel/ToolsPanel.tsx
🔇 Additional comments (8)
apps/portal/components/pagesComponents/_editorScreen/editorHelpers/shapeDrawer.ts (3)

68-69: Good addition of descriptive comment and scaling variable.

The comment clarifies the purpose of this code section, and the new blurScale variable helps with understanding the calculation.


73-76: Improved shape initialization.

Setting initial dimensions to 1 and using the exact pointer position without offset is a better approach for consistent shape creation.


177-193: New functionality integrates blur effect with shape transformation.

This is a significant enhancement that ties shape drawing with blur effects. The code:

  1. Gets the appropriate layer
  2. Sets up the transformer
  3. Attaches event listeners for mouse movement, mouse up, and transformation
  4. Initializes event listeners for the shape

This implements the previously commented "Add draw shape logic" from the editor screen.

apps/portal/app/services/editor/editor.ts (4)

479-480: Improved emoji size for better visibility.

Doubling the emoji dimensions from 64 to 128 will make them more visible and easier to interact with.


520-521: Refined marker cursor scaling.

Changing the scale factor from 2 to 1.1 makes the marker cursor more proportionate and less overwhelming.


527-529: Adjusted padding for better cursor positioning.

Reducing the padding by 6 units helps maintain proper cursor position while still providing adequate spacing.


533-535: Added fallback values for cursor text and reduced font size.

Adding fallback values (|| 0) for x and y coordinates prevents errors when pointer position is undefined. Reducing font size from 44 to 20 makes the text more readable and appropriately sized.

Also applies to: 540-540

apps/portal/components/pagesComponents/_editorScreen/editorHelpers/blurDrawer.ts (1)

153-165: Good refactoring: exported blur drawer functions for reuse.

Making these functions public by adding the export keyword improves code reusability, allowing them to be imported in other files like shapeDrawer.ts. This promotes code modularity and reduces duplication, which is particularly valuable for complex event handling logic.

Also applies to: 167-178, 180-183, 185-202, 204-222

Comment on lines 467 to 468
//dependencies.some((tool) => compareTools(activeTool, tool)) &&
// setActiveTool(Object.assign({}, activeTool));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Commented code should be explained or removed.

The active tool update logic has been commented out without explanation. If this change is intentional, please add a comment explaining why this functionality has been disabled.


🏁 Script executed:

#!/bin/bash
# Checking if this is an intentional change or if it's causing issues elsewhere

# Find where updateDependedActiveTool is called
echo "References to updateDependedActiveTool:"
rg "updateDependedActiveTool" -A 1 -B 1

Length of output: 5318


Action Required: Clarify Disabled Active Tool Update Logic

  • In apps/portal/pages/edit/[id].tsx (lines 467-468), the code that would update the active tool is commented out:
        //dependencies.some((tool) => compareTools(activeTool, tool)) &&
        //  setActiveTool(Object.assign({}, activeTool));
  • Similar functionality is actively used elsewhere in the codebase (for example, in apps/portal/pages/whiteboard/[whiteboardID].tsx and apps/extensions/src/content/panel/screens/editorScreen/EditorScreen.tsx).
  • If disabling this logic in the current context is intentional, please add a comment explaining:
    • Why the active tool update is disabled in this file.
    • Under what conditions (or in which future scenario) it might be re-enabled.
  • If the code is no longer needed, please remove the commented lines to keep the codebase clean.

@@ -77,6 +86,7 @@ const drawShapeMouseDownListener = ({
pixelRatio: 1,
};

console.log('shapeOptions:', shapeOptions);
Copy link

@coderabbitai coderabbitai bot Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Remove debug console.log statement.

This debug statement should be removed before merging to production. Debug logs add noise to the browser console and can impact performance if called frequently.

-  console.log('shapeOptions:', shapeOptions);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
console.log('shapeOptions:', shapeOptions);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

@@ -561,6 +569,7 @@ export class EditorService {
cursorgroup.add(cursortext);
}
cursormarker.setAttr('text', Number(cursormarker.getAttr('text')) + 1);
cursorgroup.to;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix incomplete method call.

This line contains an incomplete method call cursorgroup.to; which will have no effect and may indicate a mistake. Either complete the method call or remove this line.

-    cursorgroup.to;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cursorgroup.to;

@evereq evereq requested a review from paradoxe35 March 8, 2025 21:41
@evereq
Copy link
Member

evereq commented Mar 8, 2025

@Anishali2 if it's not ready yet, you can use "Draft" PR... If it's ready for Review, please remove [DO NOT MERGE] from title

@Anishali2 Anishali2 marked this pull request as draft March 9, 2025 00:05
@Anishali2 Anishali2 changed the title [DO NOT MERGE]: Working on image editor stuff. [Fixes]: Working on image editor stuff. Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]: Multiple improvements needed in image editor page.
2 participants