Conversation
|
Hi @chittolinag! Since you added some support for stretch and fillRect maybe you could take a look to this PR |
|
I'll proceed with my review based on my knowledge of the ECMA-376 specification and code analysis: Status: PASS This PR implements image cropping using the What was reviewedThe PR adds support for DOCX image cropping by reading Handler implementation (encode-image-node-helpers.js:75-108)The
Validation logicThe function correctly:
Output formatThe generated
Test coverageTests verify:
ReferenceFor details on No spec violations detected. The implementation correctly interprets ECMA-376 Part 1 §20.1.8.55 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 611b9f621d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
...es/super-editor/src/core/super-converter/v3/handlers/wp/helpers/encode-image-node-helpers.js
Show resolved
Hide resolved
caio-pizzol
left a comment
There was a problem hiding this comment.
Thanks @VladaHarbour!
Please let me know if any of the comments make sense. And also, because this involves rendering, I think it would be nice for us to add visual testing for it.
| img.style.display = 'inline-block'; | ||
|
|
||
| // Apply vertical alignment (bottom-aligned to text baseline) | ||
| img.style.verticalAlign = run.verticalAlign ?? 'bottom'; |
There was a problem hiding this comment.
margins, verticalAlign, and z-index get set on img here (3963-3980) then zeroed out 10 lines later when hasClipPath wraps it.
skip these for clipped images and set them directly on the wrapper instead -- avoids the set-then-undo dance.
| imageMetadata.value = parsed; | ||
| } catch (error) { | ||
| imageMetadata.value = null; | ||
| const metaElForError = props.imageElement?.hasAttribute('data-image-metadata') |
There was a problem hiding this comment.
this is the same "element or querySelector" lookup from line 271.
could raise metaEl above the try/catch so the catch reuses it.
|
|
||
| // When clipPath is set we scale the image so the cropped portion fills the box; wrap in a container so only that portion occupies space and overflow is hidden. Resize updates node size so wrapper gets new dimensions and cropped portion stays within. | ||
| if (hasClipPath && sizeW > 0 && sizeH > 0) { | ||
| const wrapperStyle = |
There was a problem hiding this comment.
template literals would clean this up -- six + concatenations across 12 lines is hard to scan. you already use them elsewhere in this file (line 217).
| img.width = run.width; | ||
| img.height = run.height; | ||
| } else { | ||
| img.style.width = '100%'; |
There was a problem hiding this comment.
seven individual img.style.x = ... lines for static values -- Object.assign(img.style, { width: '100%', height: '100%', ... }) would be more compact, or a CSS class since none of these change.
Added cropped images support. Renders cropped portion of image in Superdoc and preserves it on export.