Skip to content

fix(canvas): support smart crop for AEM assets in canvas editor - #1210

Merged
hannessolo merged 7 commits into
mainfrom
smrtcrop
Aug 6, 2026
Merged

fix(canvas): support smart crop for AEM assets in canvas editor#1210
hannessolo merged 7 commits into
mainfrom
smrtcrop

Conversation

@hannessolo

@hannessolo hannessolo commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

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>
@aem-code-sync

aem-code-sync Bot commented Aug 5, 2026

Copy link
Copy Markdown

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch.
In case there are problems, just click the checkbox below to rerun the respective action.

  • Re-sync branch
Commits

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
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>
@hannessolo
hannessolo merged commit 4d4aee4 into main Aug 6, 2026
5 checks passed
@hannessolo
hannessolo deleted the smrtcrop branch August 6, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ew] Smart crop for assets missing in canvas

2 participants