Skip to content

[lexical-table] Chore: Lower table handler command priority#7933

Merged
etrepum merged 2 commits intofacebook:mainfrom
patrick-atticus:table-command-priority
Oct 21, 2025
Merged

[lexical-table] Chore: Lower table handler command priority#7933
etrepum merged 2 commits intofacebook:mainfrom
patrick-atticus:table-command-priority

Conversation

@patrick-atticus
Copy link
Copy Markdown
Contributor

@patrick-atticus patrick-atticus commented Oct 20, 2025

Description

LexicalTableSelectionHelpers intercepts a number of commands with critical priority. This makes it difficult for custom plugins to intercept those same commands if TablePlugin is present (the plugin would need to be registered after TablePlugin).

I checked git history and could not see any reason for them to be critical priority (other than the fact that they are important for table operations). They were created before priorities were constant values.

Generally, I think any command should be able to be intercepted, so core handlers using COMMAND_PRIORITY_CRITICAL is unexpected to me.

If CRITICAL is the correct priority here, I can add a section to the docs on plugin ordering.

Use case

My specific use case is intercepting CUT_COMMAND in a plugin that prevents edits to content under certain situations. If table plugin is registered after, it's not possible for my plugin to prevent deletes via CUT commands.

Test plan

Existing tests pass, QA table operations (tab, cut, delete etc)

Before

Custom plugins cannot intercept commands registered by TablePlugin

After

Custom plugins can intercept commands by using COMMAND_PRIORITY_CRITICAL

@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 Oct 20, 2025
@vercel
Copy link
Copy Markdown

vercel bot commented Oct 20, 2025

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

Project Deployment Preview Comments Updated (UTC)
lexical Ready Ready Preview Comment Oct 20, 2025 5:15am
lexical-playground Ready Ready Preview Comment Oct 20, 2025 5:15am

💡 Enable Vercel Agent with $100 free credit for automated AI reviews

Copy link
Copy Markdown
Collaborator

@etrepum etrepum left a comment

Choose a reason for hiding this comment

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

I think generally this is fine, but might be worth noting that these priorities have changed in as a potentially Breaking Change.

IMO the priority system is not good especially with the commands as being as coarse as they are. Decomposing them into smaller commands will help, but eventually we're going to want to have a way to register command listeners in a way that go before, after, or around some other listener (around is really the general case since you can implement before or after with that primitive).

You could mostly get by without having any specific targeting if you could register listeners around all existing listeners, but the current behavior is that new listeners are added at a lower priority which is the least useful order. You almost always want your new listener that depends on existing listeners to run first so you can choose to run the existing listeners or not, but the only way to do that today is to register something at a higher priority and you run out of those quickly.

@etrepum etrepum added this pull request to the merge queue Oct 21, 2025
Merged via the queue into facebook:main with commit 92ddb41 Oct 21, 2025
42 checks passed
This was referenced Oct 27, 2025
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