Allow Templates without layouts to be nested in a layout at any depth

Created on 24 July 2024, 5 months ago

Problem/Motivation

When dropping a template into a layout, if the nesting depth of the current layout (section) exceeds the set nesting depth for that paragraph field then no templates can be added into that layout. However a template can contain only paragraphs and not layouts. Templates that contain only paragraphs (without any layouts) should be allowed to be added to any layout at any depth.

A convenient use case for templates, especially when coupled with style options, is to select pre-defined style options and/or content for a single paragraph and make that a template. If you have a particular paragraph that has many style options available, the number of permutations can quickly grow unwieldy. If some pre-determined configuration set of style options is frequently used by site editors, then it is very convenient to save that set of style options as a template. This allows for easily selecting, with one click, a paragraph with a set of style options that might take many clicks to setup.

In our use case, we only need to define this set of style options for a single paragraph. We need to be able to add a template into a layout at any depth, but only if the template only contains paragraphs without a layout. We still want to respect the nesting depth that is defined for a layout paragraph field as it applies to templates that contain layouts.

Steps to reproduce

  1. Install and setup mercury editor and mercury editor templates
  2. Add paragraphs and setup a content type for use with layout paragraphs and mercury editor
  3. Keep the max nesting depth of the layout paragraph enabled field set to 0 (the default value)
  4. Create a template that only has a paragraph in it, without a layout!
  5. Create a piece of content with the type you setup above
  6. Add a layout. within the layout, add a component: see that your template with only a paragraph isn't available

Proposed resolution

Include the changes found in the attached patch.

The code in the patch checks each template going into the add component dialogue, and if any paragraphs in the template are a section (layout paragraph is enabled) the template is excluded from list of available components to add.
If a template doesn't have any paragraphs with layout paragraphs setup then it is allowed to be added at any depth.

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Active

Version

2.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States devanbicher

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024