-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Comments
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). |
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. |
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). |
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
The text was updated successfully, but these errors were encountered: