Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HTML deserialization recipe to docs #4432

Merged
merged 6 commits into from May 19, 2023

Conversation

ivailop7
Copy link
Collaborator

@ivailop7 ivailop7 commented Apr 30, 2023

I've used the most approved code snippet from the following issue: #2452 as a base to address the case for full style serialization/deserialization of HTML styles to preserve the HTML<>JSON fidelity.

Please comment on what to modify, add, remove. I'd like to make this snippet as canonical as possible, since most people will copy-paste without any modifications. I'd like to treat it as a piece of code in the library, we just can't add to the core. Should help solve a lot of the Discord questions by providing a link.

@vercel
Copy link

vercel bot commented Apr 30, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 19, 2023 9:10pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 19, 2023 9:10pm

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 30, 2023
Copy link
Member

@zurfyx zurfyx left a comment

Choose a reason for hiding this comment

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

Thank you, LGTM! Will delegate the stamp to @acywatson since he's worked the most in this space

packages/lexical-website/docs/concepts/serialization.md Outdated Show resolved Hide resolved
packages/lexical-website/docs/concepts/serialization.md Outdated Show resolved Hide resolved
packages/lexical-website/docs/concepts/serialization.md Outdated Show resolved Hide resolved
@ivailop7
Copy link
Collaborator Author

ivailop7 commented May 2, 2023

@acywatson also wanted to explore what the equivalent for a Heading override would look like and what the difference would be and if there's an alternative to duplication of the logic, besides aggregating all node overrides going to the same node.

@thorn0
Copy link
Contributor

thorn0 commented May 2, 2023

This seems to work only for spans, not for cases like <strong style="color: red">foo</strong> (to reproduce, make a piece of text bold and change the color of a part of that bold text).

@ivailop7
Copy link
Collaborator Author

ivailop7 commented May 2, 2023

This seems to work only for spans, not for cases like <strong style="color: red">foo\</strong\> (to reproduce, make a piece of text bold and change the color of a part of that bold text).

you are right, didn't realize it changes the span to strong 🤦🏻‍♂️

Comment on lines 358 to 364
static importJSON(serializedNode: SerializedTextNode): TextNode {
return TextNode.importJSON(serializedNode);
}

exportJSON(): SerializedTextNode {
return super.exportJSON();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

These lines look unnecessary.

@ivailop7
Copy link
Collaborator Author

ivailop7 commented May 9, 2023

@acywatson Should I be doing the bold, italic, etc or just keep the span, strong, em and code ones?

@ivailop7
Copy link
Collaborator Author

@fantactuka @acywatson @zurfyx can I get an approval to merge on this one. I've cleaned it up and it's the docs, can always be improved over time.

@acywatson acywatson merged commit 5595519 into facebook:main May 19, 2023
5 checks passed
@ivailop7 ivailop7 deleted the document_html_deserialization branch May 19, 2023 22:35
This was referenced May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants