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

[lexical][lexical-list][lexical-rich-text]: Fix: Preserve indentation when serializing to and from HTML #6693

Merged
merged 2 commits into from
Oct 12, 2024

Conversation

GermanJablo
Copy link
Contributor

Description

This PR ensures that the indent property is preserved when importing and exporting HTML.

Closes #6082

Additionally, the following bugs are fixed:

  • in ParagraphNode.exportDOM the correct default value is used. It was set to an old value.
  • in ParagraphNode.exportDOM the indent is exported using the padding-inline-start property as used in the editor, instead of text-indent. Apparently, the person who set that did so because padding-inline-start has poor support in email clients. However, text-indent is a first-line indent, different from the lexical indent which encompasses the entire block. If someone needs to export for use in email, they should probably create their own converter.

Considerations

This PR does not include serialization of custom indent values ​​defined in the editorConfig.theme. The problem is that the CSS variable --lexical-indent-base-value is used, but when importing html the variable is not accessible. It can be used in any context, even headless. This has already caused problems for other users:

#4583
#5062

As I see it, the solution to this would be that the indent spacing is not configured with CSS under the editorConfig theme property, but using javaScript. That would be a breaking change.

Test plan

Tests are included for Paragraphs, Quotes and Headings.

Copy link

vercel bot commented Oct 3, 2024

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 Oct 6, 2024 4:04pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 6, 2024 4:04pm

@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 Oct 3, 2024
Copy link

github-actions bot commented Oct 3, 2024

size-limit report 📦

Path Size
lexical - cjs 29.91 KB (0%)
lexical - esm 29.72 KB (0%)
@lexical/rich-text - cjs 38.55 KB (0%)
@lexical/rich-text - esm 31.6 KB (0%)
@lexical/plain-text - cjs 37.09 KB (0%)
@lexical/plain-text - esm 28.92 KB (0%)
@lexical/react - cjs 40.29 KB (0%)
@lexical/react - esm 32.99 KB (0%)

@GermanJablo
Copy link
Contributor Author

I think the failed tests are flaky

@etrepum etrepum added this pull request to the merge queue Oct 12, 2024
Merged via the queue into facebook:main with commit 29871f1 Oct 12, 2024
40 of 41 checks passed
AlessioGr pushed a commit to payloadcms/payload that referenced this pull request Nov 12, 2024
I'm needing facebook/lexical#6693

I'm going to keep the dependency bump and feature updates in separate
PRs unless they're breaking changes.*

**BREAKING:**

This upgrades our lexical dependencies from 0.18.0 to 0.20.0. If you
have lexical dependencies installed in your project, you will have to
upgrade those.

Additionally, the lexical team may introduce breaking changes in this
upgrade. If you use lexical APIs directly, please consult their
changelog for more information:
https://github.com/facebook/lexical/releases
AlessioGr pushed a commit to payloadcms/payload that referenced this pull request Nov 21, 2024
… Lexical <-> HTML (#9165)

Fixes #5146 

This had been solved in facebook/lexical#6693
but we are using another serialization. I open
#9166 to discuss/track
how we can improve this in the future
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. extended-tests Run extended e2e tests on a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: paragraphNode should apply configured indent value from theme on exportDOM
4 participants