Skip to content

[PF-498] Add normalization process for RichTextElement - #2965

Open
stevestreza-ksr wants to merge 1 commit into
mainfrom
stevestreza/sdui-content/normalized-nesting
Open

[PF-498] Add normalization process for RichTextElement#2965
stevestreza-ksr wants to merge 1 commit into
mainfrom
stevestreza/sdui-content/normalized-nesting

Conversation

@stevestreza-ksr

@stevestreza-ksr stevestreza-ksr commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

📲 What

This pull request does a normalization pass on RichTextElements converted from GraphQL so that nesting works properly with the elements we receive.

🤔 Why

The server has an internal HTML parser that converts an HTML element into a GraphQL type. These types can be nested. And due to the way the HTML parser works, that means elements like images can be added as children of a text node. But we need text and image nodes to be block-level nodes.

Example: <div>Here's an image: <img ... /> Isn't it neat?</div>

🛠 How

After converting the GraphQL elements to RichTextElements, we now have a function that scans all of the elements and replaces them with one or more "normalized" elements.

In the above example, the conversion turns that div into a Text block with three child elements [Text, Photo, Text]. If this type of pattern is detected, the original element is removed and replaced with three standalone elements.

The text nodes may also be empty (e.g. if the image is directly at the start or end of the block) so we filter out empty text blocks as well.

@stevestreza-ksr
stevestreza-ksr marked this pull request as ready for review August 14, 2026 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant