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

[RFC] Add prev editor state for mutation listener #4796

Merged
merged 1 commit into from
Jul 18, 2023

Conversation

fantactuka
Copy link
Contributor

@fantactuka fantactuka commented Jul 17, 2023

This one should allow access for deleted nodes state using prev editor state:

editor.registerMutationListener(
  SomeNode,
  (mutations, {prevEditorState}) => {
    for (const [key, type] of mutations.entries()) {
      if (type === 'destroyed') {
      	const destroyedNode = prevEditorState.read(() => $getNodeByKey<LexicalNode>(key));
		...
      }
    }
  },
)

@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 Jul 17, 2023
@vercel
Copy link

vercel bot commented Jul 17, 2023

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 Jul 17, 2023 8:43pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 17, 2023 8:43pm

@github-actions
Copy link

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
packages/lexical/dist/Lexical.js 27.97 KB (+0.04% 🔺) 560 ms (+0.04% 🔺) 351 ms (+26.61% 🔺) 910 ms
packages/lexical-rich-text/dist/LexicalRichText.js 39.03 KB (+0.03% 🔺) 781 ms (+0.03% 🔺) 386 ms (-18.82% 🔽) 1.2 s
packages/lexical-plain-text/dist/LexicalPlainText.js 39.01 KB (+0.03% 🔺) 781 ms (+0.03% 🔺) 388 ms (+3.33% 🔺) 1.2 s

@acywatson acywatson merged commit 57b6d23 into main Jul 18, 2023
43 of 45 checks passed
@acywatson acywatson deleted the prev-state-for-mutations branch July 18, 2023 02:47
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.

None yet

4 participants