Skip to content

[lexical-table][lexical-playground] Feature: Implement "fit nested tables" for nested table pasting - #8097

Merged
etrepum merged 14 commits into
meta:mainfrom
randal-atticus:fix-nested-table-paste-width
Feb 3, 2026
Merged

etrepum merged 14 commits into
meta:mainfrom
randal-atticus:fix-nested-table-paste-width

Conversation

@randal-atticus

@randal-atticus randal-atticus commented Jan 27, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds a hasFitNestedTables flag to TablePlugin that resizes nested tables when pasted into table cells. This is optional, because if you have hasHorizontalScroll (scrollable tables) or scrollable table cells (as in Playground), you don't really need this. However, we do need this for a use case that is designed to be closer to MS Word's tables, and I imagine this could be useful in core.

Screen.Recording.2026-01-28.at.12.31.02.am.mov

Test plan

Before

Tables are pasted at full width. This looks okay with hasHorizontalScroll, but not all Lexical users will be using this flag.

Screen.Recording.2026-01-28.at.12.34.49.am.mov

After

The pasted table is resized to fit inside the parent cell, accounting for "insets" (padding + border). This is done recursively.

Basic case:

Screen.Recording.2026-01-28.at.12.31.02.am.mov

Deeply nested tables are also resized:

Screen.Recording.2026-01-28.at.12.33.34.am.mov

Pasting into a merged cell:

Screen.Recording.2026-01-28.at.1.12.10.pm.mov

@vercel

vercel Bot commented Jan 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment Feb 2, 2026 6:36am
lexical-playground Ready Ready Preview, Comment Feb 2, 2026 6:36am

Request Review

@meta-cla meta-cla 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 Jan 27, 2026
}

export function wrapTableHtml(expected, {ignoreClasses = false} = {}) {
export function wrapTableHtml(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For whatever reason, "dir="auto" wasn't being applied on the nested table when it was pasted. Instead of debugging that, I just added ignoreDir. Then I tried to make it a bit more explicit about what it was doing (moving "dir" up to the div, and optionally adding the scrollable wrapper class).

);
}

// If we reached this point, there's a table in the selection and nested tables are not allowed - reject the paste.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm aware this behaviour is different from #8082. In that PR, tables are stripped from the payload. The non-nested-table case isn't a focus of this specific PR so I didn't try to replicate that - but there will be a merge conflict.

@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Jan 30, 2026
@etrepum
etrepum added this pull request to the merge queue Feb 3, 2026
Merged via the queue into meta:main with commit 80ed4aa Feb 3, 2026
70 of 71 checks passed
rayterion pushed a commit to rayterion/lexical that referenced this pull request Feb 8, 2026
rayterion pushed a commit to rayterion/lexical that referenced this pull request Feb 8, 2026
rayterion pushed a commit to rayterion/lexical that referenced this pull request Feb 9, 2026
rayterion pushed a commit to rayterion/lexical that referenced this pull request Feb 13, 2026
rayterion pushed a commit to rayterion/lexical that referenced this pull request Feb 18, 2026
@etrepum etrepum mentioned this pull request Feb 25, 2026
etrepum pushed a commit to etrepum/lexical that referenced this pull request Aug 2, 2026
…s and deprecate static transform()

## Description

Audit of APIs still marked experimental whose signatures have been unchanged
for more than 6 months, comparing the experimental surface at v0.40.0
(2026-02-02, the 6-month boundary) against main. Of 225 experimental
annotations on main, only 11 existed 6 months ago -- everything else (named
slots, DOM import/render, mdast, shadow DOM) landed 2026-04 or later. Collab v2
is intentionally left experimental.

Three APIs qualified, and the repo marks experimental status two ways
(`@experimental` tags and prose `EXPERIMENTAL`), so a tag-only scan misses some.

**Graduated (leftovers from meta#8354).** That PR removed the experimental
designation from the Extension and NodeState APIs, including the "This API is
experimental" stability section in `docs/concepts/node-state.md`, but only
cleaned up the `@experimental` tags. Two NodeState APIs spelled the marker as
prose `EXPERIMENTAL` and were missed:

- `makeStateWrapper` (`@lexical/utils`) -- its signature and the
  `StateConfigWrapper` interface are unchanged since meta#7117 (2025-02-27)
- `stateConfigs` in `StaticNodeConfigValue` (`lexical`) -- declaration unchanged
  since meta#7258 (2025-06-22), and it is the documented entry point in
  `node-state.md` whose experimental notice was already removed

**Deprecated instead of graduated.** `LexicalNode.transform()` is the oldest
qualifier -- `@experimental` since meta#4030 (2023-03-07) with a byte-identical
signature for 3 years 5 months -- but blessing it as stable would be the wrong
call: it is superseded by the `$transform` property of the config returned by
`$config()`, which the codebase already steered people toward. Per AGENTS.md,
it is deprecated with the replacement documented rather than removed, and it
keeps working unchanged. The `$transform` doc no longer describes
`transform()` as "internal" now that it is deprecated and publicly documented.

Two APIs were considered and deliberately left alone:

- `hasNestedTables` (`@lexical/react`, `@lexical/table`) qualifies mechanically
  at 8.7 months with an unchanged declaration, but its marker reads "Nested
  tables are not officially supported" -- a product-support caveat, not an
  API-stability one, so clearing it would assert support. Its sibling
  `hasFitNestedTables` (meta#8097) is 5.9 months old and misses the cutoff, so
  graduating one would split the pair.
- `StaticNodeConfigValue` had its type parameter widened from `string` to
  `string | symbol` in meta#8645 (2026-06-05), so it fails the unchanged-API test.

## Test plan

Comment-only changes: no type or runtime surface is modified. `transform()`
remains fully functional, and `getTransformSetFromKlass` still collects both it
and `$transform` into the same transform set, so no behavior changes for
existing callers. Existing test coverage (including the `static transform()`
override in `LexicalNestedComposer.test.tsx`) applies unchanged.

Co-Authored-By: Claude Opus 5 <[email protected]>
etrepum pushed a commit to etrepum/lexical that referenced this pull request Aug 3, 2026
…ic transform(), normalize makeStateWrapper marker

## Description

Audit of APIs still marked experimental whose signatures have been unchanged
for more than 6 months, comparing the experimental surface at v0.40.0
(2026-02-02, the 6-month boundary) against main. Of 225 experimental
annotations on main, only 11 existed 6 months ago -- everything else (named
slots, DOM import/render, mdast, shadow DOM) landed 2026-04 or later. Collab v2
is intentionally left experimental.

The repo marks experimental status two ways (`@experimental` tags and prose
`EXPERIMENTAL`), so a tag-only scan misses some. This PR makes three changes.

**Graduated: `stateConfigs`** in `StaticNodeConfigValue` (`lexical`). Its
declaration is unchanged since meta#7258 (2025-06-22) and it is the documented
entry point in `docs/concepts/node-state.md`, whose "This API is experimental"
stability section was already removed by meta#8354. That PR graduated the Extension
and NodeState APIs but only cleaned up the `@experimental` tags, so this prose
`EXPERIMENTAL` marker was left behind.

**Deprecated: `LexicalNode.transform()`.** It is the oldest qualifier --
`@experimental` since meta#4030 (2023-03-07) with a byte-identical signature for 3
years 5 months -- but blessing it as stable would be the wrong call: it is
superseded by the `$transform` property of the config returned by `$config()`,
which the codebase already steered people toward. Per AGENTS.md it is
deprecated with the replacement documented rather than removed, and it keeps
working unchanged. The `$transform` doc no longer describes `transform()` as
"internal" now that it is deprecated and publicly documented.

**Left experimental, marker normalized: `makeStateWrapper`**
(`@lexical/utils`). Its signature and the `StateConfigWrapper` interface are
unchanged since meta#7117 (2025-02-27), so it qualifies on age, but it is a public
export with no call sites, tests, or documentation references anywhere in the
repo. An API that nothing exercises has not really been validated by that time,
so it stays experimental; only the prose `EXPERIMENTAL` is rewritten to the
`@experimental` tag so tooling and future audits can see it.

Two APIs were considered and deliberately left alone:

- `hasNestedTables` (`@lexical/react`, `@lexical/table`) qualifies mechanically
  at 8.7 months with an unchanged declaration, but its marker reads "Nested
  tables are not officially supported" -- a product-support caveat, not an
  API-stability one, so clearing it would assert support. Its sibling
  `hasFitNestedTables` (meta#8097) is 5.9 months old and misses the cutoff, so
  graduating one would split the pair.
- `StaticNodeConfigValue` had its type parameter widened from `string` to
  `string | symbol` in meta#8645 (2026-06-05), so it fails the unchanged-API test.

## Test plan

Comment-only changes: no type or runtime surface is modified. `transform()`
remains fully functional, and `getTransformSetFromKlass` still collects both it
and `$transform` into the same transform set, so no behavior changes for
existing callers. Existing test coverage (including the `static transform()`
override in `LexicalNestedComposer.test.tsx`) applies unchanged.

Co-Authored-By: Claude Opus 5 <[email protected]>

This branch was successfully deployed

2 active deployments
Preview – lexical-playground — 28b5e676 Deployed Feb 2, 2026 by vercel[bot]
Preview – lexical — 28b5e676 Deployed Feb 2, 2026 by vercel[bot]
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.

2 participants