feat(core): add freeform image cropping to inspector#228
Conversation
|
@thisiselijah is attempting to deploy a commit to the Yiwei Ho Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThis PR adds freeform image cropping capability to the image crop dialog. A new fit mode allows users to crop without aspect-ratio constraints. The implementation includes localized UI labels across English, Japanese, Simplified Chinese, and Traditional Chinese, plus refactored initialization logic and output normalization. ChangesFreeform Image Crop Feature
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/core/src/app/components/inspector/image-crop-dialog.tsx`:
- Around line 47-55: The aspect calculation for rectAspect can divide by zero
when initialRect.height or im.naturalHeight are 0, producing NaN/Infinity and
making the comparison fail; update the logic around initialRect && fit ===
'cover' to first check that initialRect.height and im.naturalHeight are truthy
and non-zero and that im.naturalWidth is a finite number, compute rectAspect
only if those guards pass, otherwise treat the rect as degenerate and call
setFit('freeform') and setCrop({ unit: '%', ...initialRect }) (same behavior as
the branch) so setFit, setCrop, rectAspect, aspect, initialRect,
im.naturalWidth, initialRect.height, and im.naturalHeight are all handled
safely.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7145c03c-627f-49b5-8d54-6887c77ce2cc
📒 Files selected for processing (7)
.changeset/add-freeform-crop.mdpackages/core/src/app/components/inspector/image-crop-dialog.tsxpackages/core/src/locale/en.tspackages/core/src/locale/ja.tspackages/core/src/locale/types.tspackages/core/src/locale/zh-cn.tspackages/core/src/locale/zh-tw.ts
What does this PR do?
As an open-slide user, I found the crop feature a bit inconvenient during my workflow, so I created this PR.
This PR adds a new "Freeform" crop mode to the inspector's image crop dialog. Users can now freely crop images on their slides without having the crop box forced to match the aspect ratio of the underlying image element.
This allows users to have more flexibility when adjusting image compositions on slides.
Key Changes
How to test
Summary by CodeRabbit