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

Feature: Automatically Adjust Table Column Widths Based on Content for New Tables #7007

Open
AlessioGr opened this issue Dec 31, 2024 · 1 comment
Labels
enhancement Improvement over existing feature tables Relates to Lexical Tables

Comments

@AlessioGr
Copy link
Contributor

Problem Description

When a new table is created—whether through copy-pasting, markdown imports, or by loading fresh editor JSON without defined column widths—it often appears poorly formatted by default. Specifically, the column widths are not automatically adjusted to fit the content, leading to tables that are difficult to read and require manual resizing.

For example, in our project, we use markdown as the source of truth, which means we do not store column widths. As a result, every time a document is loaded into the editor, users have to resize table columns repeatedly, which is inefficient and frustrating.

Proposed Solution

To improve the user experience, the editor should automatically calculate and apply column widths based on the table's content whenever no explicit widths are provided.

Screenshots

Current Behavior:

When a table is created without specified column widths, the columns appear misaligned, as shown below:

CleanShot 2024-12-30 at 18 06 25@2x

Desired Behavior:
For comparison, when the same table is pasted into Notion, the column widths are automatically adjusted to fit the content:

CleanShot 2024-12-30 at 18 09 06@2x

@AlessioGr AlessioGr added the enhancement Improvement over existing feature label Dec 31, 2024
@AlessioGr AlessioGr changed the title Feature: automatic table column width calculation when new table is created Feature: Automatically Adjust Table Column Widths Based on Content for New Tables Dec 31, 2024
@etrepum etrepum added the tables Relates to Lexical Tables label Dec 31, 2024
@etrepum
Copy link
Collaborator

etrepum commented Dec 31, 2024

This isn't really something in lexical's table implementation, this is the TableCellResizer plugin's doing… which is just a playground plugin and not something that's distributed for re-use. I would recommend modifying your copy of the plugin according to your use case, e.g. disabling the transform that sets the default width on every column and coming up with your own scheme.

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

No branches or pull requests

2 participants