Skip to content

Auto embed fix #4530 - #4535

Merged
zurfyx merged 1 commit into
mainfrom
auto-embed
May 23, 2023
Merged

zurfyx merged 1 commit into
mainfrom
auto-embed

Conversation

@fantactuka

Copy link
Copy Markdown
Contributor

Pasting enbeddable url can trigger mutation listener with up to 3 dirty leaves: new node itself and (optional) siblings on both sides of the node:

Before:
See #4530

After:

Screen.Recording.2023-05-23.at.1.36.52.PM.mov

@vercel

vercel Bot commented May 23, 2023

Copy link
Copy Markdown

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

Name Status Preview Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview May 23, 2023 5:37pm
lexical-playground ✅ Ready (Inspect) Visit Preview May 23, 2023 5:37pm

@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 May 23, 2023
@github-actions

Copy link
Copy Markdown

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
packages/lexical/dist/Lexical.js 27.25 KB (0%) 546 ms (0%) 398 ms (+188.35% 🔺) 943 ms
packages/lexical-rich-text/dist/LexicalRichText.js 38.2 KB (0%) 765 ms (0%) 326 ms (-6.61% 🔽) 1.1 s
packages/lexical-plain-text/dist/LexicalPlainText.js 38.18 KB (0%) 764 ms (0%) 312 ms (-45.73% 🔽) 1.1 s

@zurfyx
zurfyx merged commit 5b23167 into main May 23, 2023
This was referenced May 23, 2023
@fantactuka
fantactuka deleted the auto-embed branch July 6, 2023 20:07
Om-singhaI added a commit to Om-singhaI/lexical that referenced this pull request Aug 23, 2026
…ed paste gate

The dirtyLeaves.size <= 3 check in the link mutation listener came from
meta#4535, where it kept pasted prose that happens to contain a link from
opening the embed menu. The single token paste flag now inspects the
clipboard text directly and covers that case, so the count no longer
adds anything.

It did produce a false negative. When a bare URL is pasted into a
paragraph that already holds bold, italic or other inline content, the
paste marks the formatted siblings dirty and the auto link transform
splits the surrounding text, which pushes the dirty leaf count past 3
and the menu never opens. This is the case the reporter showed on video
in the review of this change.

The mutation listener now checks only the paste tag and the single
token paste flag. A unit test pastes a bare URL over a word between a
bold run and an italic run, records the dirty leaf count of the paste
update to show it exceeds 3, and checks that the embed check runs once
with the URL and that the menu opens. Against the previous code the
test fails because the embed check never runs.

Refs meta#9087

This branch was successfully deployed

2 active deployments
Preview – lexical-playground — 9c6c556f Deployed May 23, 2023 by vercel[bot]
Preview – lexical — 9c6c556f Deployed May 23, 2023 by vercel[bot]
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.

4 participants