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

Add SelectionAlwaysOnDisplay plugin #6872

Merged
merged 5 commits into from
Nov 27, 2024
Merged

Add SelectionAlwaysOnDisplay plugin #6872

merged 5 commits into from
Nov 27, 2024

Conversation

zurfyx
Copy link
Member

@zurfyx zurfyx commented Nov 26, 2024

This plugin already provides value in two different places internally, let's make it official

Screen.Recording.2024-11-26.at.4.30.08.PM.mov

Copy link

vercel bot commented Nov 26, 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 Nov 27, 2024 4:30pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 27, 2024 4:30pm

@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 Nov 26, 2024
Copy link

github-actions bot commented Nov 26, 2024

size-limit report 📦

Path Size
lexical - cjs 30.91 KB (0%)
lexical - esm 30.79 KB (0%)
@lexical/rich-text - cjs 39.67 KB (0%)
@lexical/rich-text - esm 32.65 KB (0%)
@lexical/plain-text - cjs 38.27 KB (0%)
@lexical/plain-text - esm 29.93 KB (0%)
@lexical/react - cjs 41.4 KB (0%)
@lexical/react - esm 34 KB (0%)

fantactuka
fantactuka previously approved these changes Nov 27, 2024
@zurfyx
Copy link
Member Author

zurfyx commented Nov 27, 2024

I wonder if RetainSelection is a good/intuitive plugin name, given that we also have the (non-visible) selection concept

potatowagon
potatowagon previously approved these changes Nov 27, 2024
@etrepum
Copy link
Collaborator

etrepum commented Nov 27, 2024

The display isn't precisely the same as a normal selection (in chrome at least), but I think this provides a lot of value at least as a demonstration of the technique

retain-selection-rects.mov

@zurfyx
Copy link
Member Author

zurfyx commented Nov 27, 2024

The display isn't precisely the same as a normal selection (in chrome at least), but I think this provides a lot of value at least as a demonstration of the technique

retain-selection-rects.mov

I'd be happy to discuss this further in our next session. Ideally, this is an exact match of the actual browser representation, but my hunch is that browser provided rects is the closest the browser provides and the rest is on us which is why this is particularly hard problem.

A potential option to fix this problem is to always customize the selection render when this is enabled (e934b9c). The trade-off is performance and the fact that we'd now trust selection to our built-in modules that are still experimental.

Screen.Recording.2024-11-27.at.2.02.36.PM.mov

Overall, I feel like this is a small and reasonable trade-off but we can also offer the two variants and let the users decide. I can iterate on this on top, but then again, I'd love to hear your thoughts on this problem.

@zurfyx zurfyx added this pull request to the merge queue Nov 27, 2024
Merged via the queue into main with commit 8cbc5d4 Nov 27, 2024
40 checks passed
@etrepum
Copy link
Collaborator

etrepum commented Nov 27, 2024

I'd probably look at the highlight API instead of trying to render it ourselves and probably provide some sort of straightforward way for decorators to get highlighted as well https://developer.mozilla.org/en-US/docs/Web/API/CSS_Custom_Highlight_API

@zurfyx
Copy link
Member Author

zurfyx commented Nov 27, 2024

I'd probably look at the highlight API instead of trying to render it ourselves and probably provide some sort of straightforward way for decorators to get highlighted as well developer.mozilla.org/en-US/docs/Web/API/CSS_Custom_Highlight_API

@etrepum Had no idea this existed 😮 Let me take a look, it seems like it's very modern API and not sure it's polyfillable but might still work for this use case. Thanks again!

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. extended-tests Run extended e2e tests on a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants