Problem/Motivation

The template of a content type is a plain textarea, and nothing validates it.

  • Invalid JSON quietly gives no template.
  • A JSON object instead of a list breaks the node form.
  • The template lock can be set without a template.

Steps to reproduce

Proposed resolution

  • Validate the template when the content type is saved: valid JSON, a list of [name, attributes, inner blocks] items.
  • Force the lock to "None" when the template is empty.
  • Replace the textarea with a CodeMirror JSON editor that shows these errors while typing, with warnings for unknown blocks, attributes and fields.
  • The node form ignores invalid templates instead of failing.

Remaining tasks

User interface changes

The JSON editor on the content type form.

API changes

The new gutenberg.template service.

Data model changes

Issue fork gutenberg-3628772

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

marcofernandes created an issue. See original summary.

  • marcofernandes committed df20ac77 on 4.0.x
    Issue #3628772: Validate the content type template and edit it with a...
marcofernandes’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.