Repository navigation
mail-react: Add a rich-text block factory for Tip-Tap content - #6406
Conversation
82ff0df to
0277b7b
Compare
|
shouldn't we use a mechanism similar to site? |
38301b7 to
9853a7e
Compare
It's the same mechanism as our existing draft-js block, Is that what you mean? |
621e327 to
c9f32d9
Compare
|
@greptileai review |
|
....that is for "normal" sites, for mail-react:
The question I'm asking is if we could have something similar to site's renderTipTapRichText for mail-react |
So you're asking if we should create a render-function instead of (or in addition to) the component/block factory, correct? The reason for the factory is that we can control precisely how the text elements are rendered, like the specific table-structure we need for lists, so it renders consistently across mail-clients. Font styling, responsive styling, spacings, etc. can all be controlled through the theme, IMO replacing the factory with a render function would make it too easy to override the html structure with one that does not work consistently across mail-clients, while preventing the library from shipping fixes for specific mail-clients, if we discover new issues. About adding the render-function in addition to the factory: it seems like one additional thing we'd need to support that will rarely to never be used in practice. Where it is used, we have the issue again, that fixes will not reach those projects. |
|
@greptileai review |
|
We discussed adding a render function when we added the Draft.js-based implementation (see #5873 (comment)). @VPS-Ricky convinced me that a factory is better because we need to support both MJML- and HTML-based rich text blocks, which would require two render function, which could drift apart. Internally, the factory does little more than calling the render functions with correctly configured arguments: IMO we can use the same approach for the TipTap-based implementation. |
It is a separate factory, not an option of `createRichTextBlock`, because the two store styling differently.
The top-level `textBlockStyles` option with `appliesTo` was replaced by `styles` on each text block and list, so the mail blocks no longer compiled against main. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
c9f32d9 to
8331de8
Compare
|
Rebased onto main while Ricky is away. #6383 was merged in the meantime and moved the TipTap block's text block styles from the top-level |
…eta.json Main now writes a description for every TipTap block into block-meta.json, so the file was out of date after the rebase. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
) In the admin, a content editor can give a nested list item its own style, but the mail rendered the item with the style of the item around it. A nested list has no text component of its own, so its cells copied the text styles of the enclosing item, and the responsive rules of the outermost list reached the nested cells too. A nested item without a style now gets its list's `textBlocks` style, not the style of the item around it, because the admin shows it that way too. ## Screenshots/screencasts The `WithListVariants` story of `MjmlTipTapRichTextBlock`: | Before | Now | | ------ | --- | | <img width="539" alt="nested-list-before-desktop" src="https://github.com/user-attachments/assets/fca23e84-8513-42cf-b89e-0cdfa7187654" /> | <img width="539" alt="nested-list-after-desktop" src="https://github.com/user-attachments/assets/84d6d742-4dc0-4ee2-bb91-40e2034d94a6" /> | ## Changeset None needed: this fixes #6406, which is not released yet. --- Task: https://vivid-planet.atlassian.net/browse/PHSB2C-12548 --------- Co-authored-by: Ricky Smith <jamesricky@me.com>
createTipTapRichTextBlockrenders the CMS Tip-Tap rich text block in mails. It uses the same components ascreateRichTextBlock, so existing styling for the draft-js block also works here. It is a separate factory because the two store styling differently.In the admin, the content editor writes paragraphs and lists, and can give each one a style, such as
titleorheader. The application defines these styles in the CMS block'stextBlockStyles. The two mail options follow that:textBlockStyles: the look of each entry in the rich text editor's style dropdown.textBlocks: the default look of a paragraph or list, when a content editor did not select a style. Leave it out to use the theme's default variant.Mails render all text as
divelements, so a heading in a mail is a style, not a heading tag.Screenshot
The same content in the demo Welcome Email, authored once in the draft-js block and once in the Tip-Tap block:
Task: https://vivid-planet.atlassian.net/browse/PHSB2C-12548