Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ export class BlotFormatter {
display: 'block',
left: `${specRect.left - parentRect.left - 1 + parent.scrollLeft}px`,
top: `${specRect.top - parentRect.top + parent.scrollTop}px`,
width: `${specRect.width}px`,
height: `${specRect.height}px`,
width: `${Math.min(specRect.width, parentRect.width)}px`,
height: `${Math.min(specRect.height, parentRect.height)}px`,
Comment on lines +133 to +134
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

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).

})
}

Expand Down
Loading