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-table] Bug Fix: Table cell line breaks behave differently from the intended HTML behavior. #7318

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dineug
Copy link

@dineug dineug commented Mar 12, 2025

Description

Table cell line breaks behave differently from the intended HTML behavior.

Modify the logic to align with the intended HTML line breaks.

Closes #7261

Test plan

Add TC to TableCellNode.importDOM

Before

case html editor
inline decorator <td>
<test-decorator></test-decorator>
1
</td>
<td>
<p>
<test-decorator></test-decorator>
<br />
</p>
<p>
<span>1</span>
</p>
</td>
br <td>
1
<br />
<br />
<br />
<br />
2
</td>
<td>
<p>
<span>1</span>
</p>
<p>
<span>2</span>
</p>
</td>

After

case html editor
inline decorator <td>
<test-decorator></test-decorator>
1
</td>
<td>
<p>
<test-decorator></test-decorator>
<span>1</span>
</p>
</td>
br <td>
1
<br />
<br />
<br />
<br />
2
</td>
<td>
<p>
<span>1</span>
<br />
<br />
<br />
<br />
<span>2</span>
</p>
</td>

Copy link

vercel bot commented Mar 12, 2025

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 Mar 12, 2025 7:19pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 12, 2025 7:19pm

@facebook-github-bot
Copy link
Contributor

Hi @dineug!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@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 Mar 12, 2025
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Mar 12, 2025
Copy link
Collaborator

@etrepum etrepum left a comment

Choose a reason for hiding this comment

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

It's probably not expected that TableCell import behaves differently than elsewhere, I would expect

input

<td>
  1
  <br />
  <br />
  <br />
  <br />
  2
</td>

output

<td>
  <p>
    <span>1</span>
    <br />
    <br />
    <br />
    <br />
    <span>2</span>
  </p>
</td>

I don't think each <br /> should create a new block, that's not typically how lexical works.

For example, if you paste this text/html into the root of a lexical editor:

1<br><br><br>2

Then you will get a document with this structure:

 root
  └ (47) paragraph 
    ├ (48) text "1"
    ├ (49) linebreak 
    ├ (50) linebreak 
    ├ (51) linebreak 
>   └ (52) text "2"

The same thing applies when you paste that same html into a table cell.

I don't really understand what you're trying to "fix" here (at least in the br case, I have not investigated the decorator case)

@dineug
Copy link
Author

dineug commented Mar 12, 2025

I have made the changes you mentioned! @etrepum

@etrepum
Copy link
Collaborator

etrepum commented Mar 12, 2025

It doesn't look like test are passing with these changes

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.

Bug: When there is only an inline DecoratorNode as a child of a ParagraphNode, a <br> is added at the end.
3 participants