[lexical-table] Chore: Fix test for nested table pasting#8088
[lexical-table] Chore: Fix test for nested table pasting#8088etrepum merged 3 commits intofacebook:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| ), | ||
| ); | ||
|
|
||
| tableObserver.listenersToRemove.add( |
There was a problem hiding this comment.
I've hoisted this entire command handler up to LexicalTablePluginHelper, the only change is where editor != dispatchEditor is checked.
I had to move this up because none of these command handlers were being registered in tests.
Separately, I was wondering if you think all of the command handlers should be lifted out applyTableHandlers, because:
- These handlers are not registered in tests (unless wrapped in a certain way)
- This function is a mix of both DOM event handlers and lexical command handlers, perhaps should be registered separately
- The command handlers are registered somewhat redundantly for each table (e.g. if you have 100 tables in the doc, there will be 100
CUT_COMMANDhandlers, 100FORMAT_TEXT_COMMANDhandlers etc).
There was a problem hiding this comment.
Commands being registered per-table doesn't really make a lot of sense. I guess whoever did that originally was thinking that it would make sense to only register the commands when at least one table is in the document, and just didn't optimize for >1 table? These are the kinds of problems that extensions are much better at.
|
Sorry, fixing tests... |
| editor.registerCommand( | ||
| SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, | ||
| ({nodes, selection}, dispatchEditor) => { | ||
| (selectionPayload, dispatchEditor) => { |
There was a problem hiding this comment.
this is structured a bit oddly but is effectively mirroring the previous implementation 1:1 (because the old SELECTION_INSERT_CLIPBOARD_NODES_COMMAND had COMMAND_PRIORITY_HIGH and fell through to this handler afterwards).
Description
When
hasNestedTables: true, and you paste a table into another table, it flattens it. I'm working on adding a way to allow a table to be pasted into another table, and realised the test assumes we can already do that.Before changing anything I want to make sure the test obeys the current behaviour.
Test plan
Before
Screen.Recording.2026-01-20.at.4.19.51.pm.mov
After
Behaviour unchanged:
https://github.com/user-attachments/assets/14e47f23-801a-4e7e-b5c1-4aad40507d0d