Skip to content

Blockquote schema constraints do not match contentful behaviour in @contentful/rich-text-types #998

@JonathanVelkeneers

Description

@JonathanVelkeneers

In the current version of @contentful/rich-text-types (17.2.5), the schema validation types allow all Block children as descendant of the blockquote Container.

The issue herein lies that contful does not allow heading elements to be direct descendants of blockquotes.
The contentful web app does not allow creating it, and the validateRichTextDocument function warns that it is invalid:

[
  {
    "details": "Value must be one of expected values",
    "name": "in",
    "expected": [
      "paragraph"
    ],
    "path": [
      "content",
      4,
      "content",
      1,
      "nodeType"
    ],
    "value": "heading-3"
  }
]
Image

The types should be adjusted to reflect the actual allowed children of the blockquote container.

Related types code snippets
// blocks.d.ts:
/**
 * Map of all Contentful block types. Blocks contain inline or block nodes.
 */
export declare enum BLOCKS {
    DOCUMENT = "document",
    PARAGRAPH = "paragraph",
    HEADING_1 = "heading-1",
    HEADING_2 = "heading-2",
    HEADING_3 = "heading-3",
    HEADING_4 = "heading-4",
    HEADING_5 = "heading-5",
    HEADING_6 = "heading-6",
    OL_LIST = "ordered-list",
    UL_LIST = "unordered-list",
    LIST_ITEM = "list-item",
    HR = "hr",
    QUOTE = "blockquote",
    EMBEDDED_ENTRY = "embedded-entry-block",
    EMBEDDED_ASSET = "embedded-asset-block",
    EMBEDDED_RESOURCE = "embedded-resource-block",
    TABLE = "table",
    TABLE_ROW = "table-row",
    TABLE_CELL = "table-cell",
    TABLE_HEADER_CELL = "table-header-cell"
}
// schemaConstraints.d.ts:
/**
 * Dictionary of all container block types, and the set block types they accept as children.
 *
 * Note: This does not include `[BLOCKS.DOCUMENT]: TOP_LEVEL_BLOCKS`
 */
export declare const CONTAINERS: {
    "ordered-list": BLOCKS[];
    "unordered-list": BLOCKS[];
    "list-item": TopLevelBlockEnum[];
    blockquote: BLOCKS[];
    table: BLOCKS[];
    "table-row": BLOCKS[];
    "table-cell": BLOCKS[];
    "table-header-cell": BLOCKS[];
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions