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

[lexical] Feature: Add onUpdate function during update with $onUpdate (correct baselline) #6773

Merged

Conversation

landisdesign
Copy link
Contributor

Description

Adds $onUpdate(fn) to allow an in-progress update/command to append a function to the _deferred stack.

Closes #6767

Test plan

Before

This functionality did not exist. Calling editor.update with an onUpdate function was the only way to perform an action after an update.

After

Performing an update such as:

editor.update(() => {
  // perform updates
  $onUpdate(() => {
    console.log('second onUpdate);
  });
}, {
  onUpdate: () => {
    console.log('first onUpdate');
  }
});

would emit first onUpdate, followed by second onUpdate, once the updates were flushed. This is essentially what the unit test does.

Successful unit test results

Copy link

vercel bot commented Oct 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 29, 2024 3:45pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 29, 2024 3:45pm

@facebook-github-bot facebook-github-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 27, 2024
Copy link

github-actions bot commented Oct 27, 2024

size-limit report 📦

Path Size
lexical - cjs 29.92 KB (0%)
lexical - esm 29.75 KB (0%)
@lexical/rich-text - cjs 38.57 KB (0%)
@lexical/rich-text - esm 31.65 KB (0%)
@lexical/plain-text - cjs 37.18 KB (0%)
@lexical/plain-text - esm 28.94 KB (0%)
@lexical/react - cjs 40.24 KB (0%)
@lexical/react - esm 33.01 KB (0%)

etrepum
etrepum previously approved these changes Oct 29, 2024
Copy link
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.

Looks good to me! I think the only thing missing here is a flow definition

@landisdesign
Copy link
Contributor Author

Looks good to me! I think the only thing missing here is a flow definition

Doh! TS fanboy here. Let me get that in.

@etrepum etrepum added this pull request to the merge queue Oct 29, 2024
Merged via the queue into facebook:main with commit 07ca5c8 Oct 29, 2024
40 checks passed
@etrepum etrepum mentioned this pull request Nov 7, 2024
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Register commands with update options
3 participants