fix(canvas): support smart crop for AEM assets in canvas editor - #1210
Merged
Conversation
The canvas asset picker was a stripped-down fork of the old editor's picker, created before smart crop support was added. Picking an image with a smart crop inserted a URL missing the ?smartcrop=<cropName> param. Port the smart-crop flow into the canvas picker, reusing the existing edit helpers: expose isSmartCrop from getRepositoryConfig, add a two-panel layout that opens showSmartCropDialog for images when smart crop is enabled, and reuse the shared insert helpers. Link the shared da-assets.css into the panel shadow root so the crop UI is styled. Fixes #1207 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The smart-crop selection orchestration was an inlined closure in renderAssets with no test coverage of its own. Extract it into an exported buildHandleSelection with an injected getView accessor, and add canvas-side unit tests covering the standard-insert, link, and smart-crop (crops / no-crops) branches. No behavior change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The canvas asset picker was a fork of the classic editor's picker, which is what let smart-crop support drift out of sync (#1207). Make the tested edit-side selection handler environment-agnostic (inject getView + close) and have canvas call it, deleting the canvas fork of the handler, the URL builders, resolveAssetUrl, and getAssetAlt. - edit buildHandleSelection: positional args -> options object with injected getView()/close(); add a defensive no-view guard. - getAssetAlt: merge the author (_embedded) and delivery (flat dc:title) shapes so a single helper serves both pickers. - canvas: reuse buildHandleSelection + createDialogPanels; keep only its own nx-based getRepositoryConfig. Canvas now also inherits the format guard and DM approval / publish-status checks (parity improvement). - tests: update edit call sites to the options object, cover the new getAssetAlt fallbacks, and slim the canvas test to getRepositoryConfig. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
hannessolo
marked this pull request as ready for review
August 5, 2026 12:35
Canvas had a forked getRepositoryConfig reading site config via the nx-hosted daConfig util, while the same file already fetched config through blocks/shared/utils (getResponsiveImageConfig) — two config fetches via two utils. Drop the fork and reuse the edit-side resolver: same config endpoint, shared cache, and canvas now also picks up insertAsLink / mime-rendition / site-image-modifier support for free. The obsolete canvas getRepositoryConfig test is removed (covered by edit's config.test.js) and the test-only daConfig fixture change is reverted, as canvas no longer imports the nx daConfig util here. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The canvas asset picker hardcoded the selector featureSet and omitted 'dynamic-media', so on DM / smart-crop sites it lacked the dynamic-media features the classic editor enables via buildFeatureSet(). Add it for DM-enabled repos to restore parity. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Drop the inlined featureSet logic and the duplicated ASSET_SELECTOR_URL constant; import both from the classic editor's da-assets module. The shared import needs four symbols, which the deep path pushes over max-len on one line, so it's wrapped with a scoped object-curly-newline override. This removes the last picker duplication between edit and canvas, so buildFeatureSet has a single source of truth. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
sharanyavinod
approved these changes
Aug 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://smrtcrop--da-live--adobe.aem.live
Fix #1207