lexical icon indicating copy to clipboard operation
lexical copied to clipboard

fix mutate with replace klass

Open Piechota opened this issue 1 year ago • 11 comments

When registering mutation check for Node that replaced original one. mutation are a map so only one entry.

Should fix #4498

Piechota avatar May 11 '24 20:05 Piechota

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 May 24, 2024 8:52am
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 24, 2024 8:52am

vercel[bot] avatar May 11 '24 20:05 vercel[bot]

Hi @Piechota!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

facebook-github-bot avatar May 11 '24 20:05 facebook-github-bot

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

facebook-github-bot avatar May 11 '24 21:05 facebook-github-bot

This looks like it solves the same problem as #6076 so it should close that as well if this PR is chosen. My review comments would be basically the same: https://github.com/facebook/lexical/pull/6076#pullrequestreview-2051214716

etrepum avatar May 12 '24 15:05 etrepum

I think this approach is probably better, but without really any docs or test coverage it's hard to say if there are any additional caveats to this simpler solution

etrepum avatar May 12 '24 15:05 etrepum

In that other PR you have a good point about chain of node replacements. Currently this code doesn't support it, I will fix it when I have a second.

Piechota avatar May 12 '24 15:05 Piechota

So I have added loop to support multilevel replacement. But I have problem testing it, it seems like right now it isn't supported really well.

Basically if node A replaces node B, and node C replaces node B. Creating node A doesn't create node C. I think we should also loop over replace in $applyNodeReplacement() But that's for different change.

Piechota avatar May 12 '24 21:05 Piechota

Good idea, it seems that there is a lack of test coverage all around for this corner of the API!

etrepum avatar May 12 '24 21:05 etrepum

If no-one picks this up - I'll look at it later to add some tests. I touched klasses already in the devtools

StyleT avatar May 13 '24 16:05 StyleT

If no-one picks this up - I'll look at it later to add some tests. I touched klasses already in the devtools

That would be very welcome! I'll close https://github.com/facebook/lexical/pull/6076 since this one seems more in line with expectations.

aleksandr-lapushkin avatar May 14 '24 07:05 aleksandr-lapushkin

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
packages/lexical/dist/Lexical.js 23.93 KB (0%) 479 ms (0%) 289 ms (-2.43% 🔽) 767 ms
packages/lexical-rich-text/dist/LexicalRichText.js 34.59 KB (0%) 692 ms (0%) 840 ms (-17.75% 🔽) 1.6 s
packages/lexical-plain-text/dist/LexicalPlainText.js 34.59 KB (0%) 692 ms (0%) 970 ms (-8.52% 🔽) 1.7 s

github-actions[bot] avatar May 21 '24 23:05 github-actions[bot]

Closed in favor of https://github.com/facebook/lexical/pull/6189 (tests added)

StyleT avatar May 28 '24 23:05 StyleT