Reduce the number of ways to convert Lexical <-> HTML #9166
GermanJablo
started this conversation in
Feature Requests & Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
There are currently 4 ways to convert from Lexical to HTML and vice versa. This is a huge problem for DX because it means that every user creating a node has to maintain 4 up-to-date and consistent serializations. And this is not even counting other forms of serialization required in Lexical, such as JSON or Markdown.
An example of the disadvantages of this is #9165, which would not have been necessary because that bug had already been solved in Lexical: facebook/lexical#6693, but we are not using their HTML converter.
Our goal is to reduce as many of these alternative serializations as possible.
Recommendations:
Make
(4) convertLexicalToHTML
rely on(1) $generateHtmlFromNodes
.We cannot remove the current way of converting to HTML for backwards compatibility, but we can promote the new way in the documentation.
Replace the places where we are using
(3)
with(1/4)
instead. HTML should work fine. The cases where someone might want JSX are rare exceptions. The only examples I can think of are:These cases seem rare enough that we could focus on
(1/4)
, with the guidance: "If you need complex rendering, consider instantiating Lexical or develop a custom JSX serializer."Also, at one point I considered using just
(3)
, and building a static HTML similar to(1/4)
usingReactDOMServer.renderToString
. I actually have a prototype in the serialize-jsx-html branch, but I'm not sure if it's worth it, given that Lexical already provides HTMLConverters that work for 99% of cases.Beta Was this translation helpful? Give feedback.
All reactions