feat: #3621557 Offer Canvas's link-to-field affordance on per-content layouts

Issue: https://www.drupal.org/project/canvas_override/issues/3621557

Companion to the host-entity fix on the same issue. Best reviewed after it.

Problem

Canvas builds the prop linker (the "link to field" icon) only when the edited entity is a ContentTemplate — the suggestion lookup, the linker markup, and the #after_build that moves the data onto field labels all sit behind if ($entity instanceof ContentTemplate). Editing a node's own component tree shows plain static widgets, and a prop already bound to a field (every prop seeded from the template) renders as a disabled textbox with no way to see or change the binding.

Resolution

A per-content layout has the same host entity semantics as the template it was seeded from, so the same affordance is added on the built form for canvas_override-enabled nodes, using Canvas's own PropSourceSuggester and its linked_prop element. The component and its current prop sources are read from the posted client-side tree rather than storage, so components the editor just added are covered too. Content templates are untouched.

⚠️ Known limitation — not complete on its own

The linker renders and lists the node's fields, but selecting one does not apply. Canvas's client dispatches the link through the content-template layout endpoint and parses {template_bundle}/{template_view_mode} out of window.location; on a node editor URL that parse fails:

Error: The URL "canvas/api/v0/layout-content-template/{entity_type}.{template_bundle}.{template_view_mode}/{entity_id}"
requires a Template Bundle, but it could not be extracted from the current location.

No request is sent. That is hard-coded in the compiled front end and cannot be redirected from PHP, so finishing this needs a Canvas front-end change.

Therefore do not merge this as-is if a visible control that cannot complete its action is unacceptable — it is published here so the server-side half is reviewable and the remaining upstream gap is documented.

Verification (Varbase 11, Drupal 11.4.6, Canvas 1.10.1)

  • Linker renders on the seeded heading (both heading_text and url) and on a newly added component
  • Suggestions are the node's real fields: Title, Featured image, Description, Authored by, SEO title/description/image, Menu link, Revision user
  • Content template editing unchanged

phpcs clean.

AI-Generated: Yes (investigated and authored with Claude Code; reviewed by Rajab Natshah.)

Checkpoints

  • File an issue about this project
  • Addition/Change/Update/Fix to this project
  • Testing to ensure no regression
  • Automated unit/functional testing coverage
  • Developer Documentation support on feature change/addition
  • User Guide Documentation support on feature change/addition
  • UX/UI designer responsibilities
  • Accessibility and Readability
  • Reviewed by a human
  • Code review by maintainers
  • Full testing and approval
  • Credit contributors
  • Review with the product owner
  • Update Release Notes
  • Release

Merge request reports

Loading
Loading