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

Combined selection format to ignore empty text nodes #5521

Merged
merged 1 commit into from Jan 22, 2024

Conversation

zurfyx
Copy link
Member

@zurfyx zurfyx commented Jan 19, 2024

Extending #5126 to exclude all empty text nodes as well as the resulting from the user's selection (which may not span the entire TextNode).

Copy link

vercel bot commented Jan 19, 2024

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

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview Jan 19, 2024 5:02pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 19, 2024 5:02pm

@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 Jan 19, 2024
Copy link

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
packages/lexical/dist/Lexical.js 26.66 KB (0%) 534 ms (0%) 52 ms (+31.57% 🔺) 585 ms
packages/lexical-rich-text/dist/LexicalRichText.js 39.4 KB (+0.01% 🔺) 789 ms (+0.01% 🔺) 101 ms (+88.94% 🔺) 889 ms
packages/lexical-plain-text/dist/LexicalPlainText.js 39.37 KB (+0.01% 🔺) 788 ms (+0.01% 🔺) 63 ms (+20.42% 🔺) 850 ms

const nodesLength = nodes.length;
const isBackward = selection.isBackward();
const startOffset = isBackward ? focusOffset : anchorOffset;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be better to do an old-fashioned if/else here, since it will end up with 1 comparison and 4 assignments vs 4 comparisons and 4 assignments, or does this have some minification benefits?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nevermind, you'll need to do it with closure outside the if, so you'd end up with 1 comparison but 4 declarations and 4 reassignments. Doubt it will make any difference in bundle size or minification

@zurfyx zurfyx merged commit e1605a3 into main Jan 22, 2024
40 of 45 checks passed
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

3 participants