Automattic / Automattic/jetpack

Tiled gallery & slider blocks: conditionally transform shortcodes

Open
#11,779 1 comment 1 reaction 0 assignees View on GitHub
[Block] Slideshow [Block] Tiled Gallery [Feature] Shortcodes / Embeds [Feature] Tiled Gallery [Focus] Blocks
Dominant language
PHP
Stars
1.8k
Forks
898
Avg merge
1d 18h
Merged PRs (30d)
774

Description

`[gallery]` shortcode transform is shared between the core gallery Tiled gallery and Slideshow blocks.

Whichever has higher priority set, happens to win (~currently Tiled gallery wins~ update: shortcode transform from the Tiled gallery block was [temporarily removed](https://github.com/Automattic/wp-calypso/pull/30756)).

We should conditionally transform to Tiled gallery and Slideshow blocks only when valid `layout` attribute is set and let core gallery take care of the transform otherwise.

### Problem / blocker

Core doesn't currently support using `isMatch` in shortcode transforms (https://github.com/WordPress/gutenberg/issues/10674 and I don't see a way to divert transformation to some other block conditionally.

**The Best way forward seems to get `isMatch` fixed in core.**

`isMatch` could be something like this for Tiled gallery block:
```js
isMatch: ( { layout } ) => LAYOUT_STYLES.map( style => style.name ).includes( layout )
```

...and for the slideshow block:
```js
isMatch: ( { layout } ) => layout === 'slideshow'
```

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the shared [gallery] shortcode transforms for the Tiled Gallery, Slideshow, and core gallery blocks, then read Gutenberg issue #10674 about isMatch support. Done means valid layout values select the matching block while other gallery shortcodes remain available to core gallery transformation.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.