feat: resolve the issue of the image toolbar border exceeding the limit after clicking on the image#458
feat: resolve the issue of the image toolbar border exceeding the limit after clicking on the image#458wuyiping0628 wants to merge 1 commit intodevfrom
Conversation
…it after clicking on the image
WalkthroughThe Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
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 the current code and only fix it if needed.
Inline comments:
In `@packages/fluent-editor/src/modules/custom-image/blot-formatter.ts`:
- Around line 133-134: The current clamp uses parentRect.width/height which can
overflow when the overlay is offset; change the clamps on those two lines to use
the remaining space from the overlay's current position: compute remainingWidth
= parentRect.width - (specRect.left - parentRect.left) and remainingHeight =
parentRect.height - (specRect.top - parentRect.top), then use
Math.min(specRect.width, Math.max(0, remainingWidth)) for width and
Math.min(specRect.height, Math.max(0, remainingHeight)) for height (reference
specRect and parentRect in blot-formatter.ts).
🪄 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: 76c3b102-84a4-4297-9189-c58876c315ba
📒 Files selected for processing (1)
packages/fluent-editor/src/modules/custom-image/blot-formatter.ts
| width: `${Math.min(specRect.width, parentRect.width)}px`, | ||
| height: `${Math.min(specRect.height, parentRect.height)}px`, |
There was a problem hiding this comment.
Clamp against remaining space after offset, not full parent size.
On Line 133 and Line 134, Math.min(..., parentRect.width/height) can still overflow when the overlay starts away from the parent’s left/top edge. Clamp using the remaining space from current position.
💡 Proposed fix
Object.assign(this.overlay.style, {
display: 'block',
- left: `${specRect.left - parentRect.left - 1 + parent.scrollLeft}px`,
- top: `${specRect.top - parentRect.top + parent.scrollTop}px`,
- width: `${Math.min(specRect.width, parentRect.width)}px`,
- height: `${Math.min(specRect.height, parentRect.height)}px`,
+ left: `${Math.max(specRect.left - parentRect.left - 1, 0) + parent.scrollLeft}px`,
+ top: `${Math.max(specRect.top - parentRect.top, 0) + parent.scrollTop}px`,
+ width: `${Math.max(
+ 0,
+ Math.min(
+ specRect.width,
+ parentRect.width - Math.max(specRect.left - parentRect.left - 1, 0),
+ ),
+ )}px`,
+ height: `${Math.max(
+ 0,
+ Math.min(
+ specRect.height,
+ parentRect.height - Math.max(specRect.top - parentRect.top, 0),
+ ),
+ )}px`,
})🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/fluent-editor/src/modules/custom-image/blot-formatter.ts` around
lines 133 - 134, The current clamp uses parentRect.width/height which can
overflow when the overlay is offset; change the clamps on those two lines to use
the remaining space from the overlay's current position: compute remainingWidth
= parentRect.width - (specRect.left - parentRect.left) and remainingHeight =
parentRect.height - (specRect.top - parentRect.top), then use
Math.min(specRect.width, Math.max(0, remainingWidth)) for width and
Math.min(specRect.height, Math.max(0, remainingHeight)) for height (reference
specRect and parentRect in blot-formatter.ts).
…it after clicking on the image
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit