Skip to content

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

Merged
stevestreza-ksr merged 2 commits into
mainfrom
stevestreza/sdui-content/normalized-nesting
Aug 20, 2026
Merged

[PF-498] Add normalization process for RichTextElement#2965
stevestreza-ksr merged 2 commits 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

@amy-at-kickstarter amy-at-kickstarter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks good to me, but - based on the comment, it sounds like this logic should live on the server. Does Android have the same issue? Can we push this fix up to the server level, instead?

@stevestreza-ksr

Copy link
Copy Markdown
Contributor Author

Confirming with Tony but I am reasonably sure that this is handled on Android.

@stevestreza-ksr
stevestreza-ksr merged commit 48ba839 into main Aug 20, 2026
7 checks passed
@stevestreza-ksr
stevestreza-ksr deleted the stevestreza/sdui-content/normalized-nesting branch August 20, 2026 06:45
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.

2 participants