Motivation

We are supporting node-previews and layout builder previews, but canvas preview routes are not yet supported.

It would be nice to have a full frontend-rendered preview.
(There are no preview routes any more, it moved to a JS-centric solution)

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

fago created an issue. See original summary.

fago’s picture

Issue summary: View changes
fago’s picture

Worked with AI to figure out some options to implement. Checked those:

1. Canvas extension (sidebar panel)

— A module registers a canvas_extension.yml, extension shows
frontend URL in an iframe within the left sidebar. Problem: Panel is sidebar-sized, not
full-page. Not suiting.

2. Decorate CanvasPreviewRenderer

— Replace server-rendered HTML with an iframe loading the
frontend URL or lupus_csr. Returns {"html": "

"}. Problem: Nested iframe (Canvas already puts preview in an iframe). Width dropdown still works though. Might work well.

3. Canvas core: add "preview URL" support

— Canvas learns a new preview mode where the iframe loads an external URL instead of server-rendered HTML. Width dropdown works natively.

4. DOM injection hack

— A Drupal JS library on canvas boot routes injects a button next to Preview via DOM manipulation, opens frontend URL in new tab or overlay. We don't want to go there.
fago’s picture

Version: 1.2.0 » 1.4.1
Status: Active » Needs work

I quickly tried option 2 - does not work properly since there is no clear way to differentate between preview and editor rendering. Anyway, it#s cleanest to enhance canvas to support it and to propose a patch for it.