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

Bug: Table formatting and styling not persisting for empty cells #6583

Open
ivailop7 opened this issue Sep 1, 2024 · 4 comments
Open

Bug: Table formatting and styling not persisting for empty cells #6583

ivailop7 opened this issue Sep 1, 2024 · 4 comments
Labels
tables Relates to Lexical Tables

Comments

@ivailop7
Copy link
Collaborator

ivailop7 commented Sep 1, 2024

Lexical version: 0.17.1

Since the table cells are empty paragraphs without text nodes, applying formatting and styling to the cells doesn't persist when text is added later. Those changes should persist irrespective if cells are empty or not. A lot of people do table changes in advance before they start entering text, will also bring behaviour inline with other editors.

table_format_style_issues.mov
@ivailop7 ivailop7 added the tables Relates to Lexical Tables label Sep 1, 2024
@etrepum
Copy link
Collaborator

etrepum commented Sep 3, 2024

I think this is a design flaw, not really a bug. The workaround that is used elsewhere is to store the format on the RangeSelection, which works but that of course is ephemeral, so if you move the collapsed cursor to some text that has some existing format then the new format goes away because it was on the selection and the selection changes its format to match the existing text. This is the same way google docs works (at least with paragraphs). I think you would need to come up with some other strategy for tables (google docs persists styles on table cells or if you're at the beginning of an empty paragraph).

@etrepum
Copy link
Collaborator

etrepum commented Sep 3, 2024

It does look like there are textStyle and textFormat accessors on ParagraphNode that are currently only used by the reconciler to preserve the subtree's text style & format but that could probably be used directly by the Selection classes, at least when the ParagraphNode is empty.

@ivailop7
Copy link
Collaborator Author

ivailop7 commented Sep 3, 2024

It does look like there are textStyle and textFormat accessors on ParagraphNode that are currently only used by the reconciler to preserve the subtree's text style & format but that could probably be used directly by the Selection classes, at least when the ParagraphNode is empty.

Thanks, that's how I started solving it, wanted to make sure there is no better solution.

@etrepum
Copy link
Collaborator

etrepum commented Sep 3, 2024

Not that I can see! If you were trying to preserve it on the table selection it would probably be for naught because when you focus for text entry it will have been thrown away to make a RangeSelection. I have to imagine that's what this accessor is for, really, to preserve the intended format of an empty node. Whatever you do here should probably also be applied to other kinds of selection because RangeSelection also has this problem (e.g. create empty paragraph, change style on paragraph without entering text, navigate somewhere else and then back, and it's gone; or select a few empty paragraphs and then any attempt to change the format with the toolbar doesn't work even though the bold/italic buttons change their state).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tables Relates to Lexical Tables
Projects
None yet
Development

No branches or pull requests

2 participants