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

[lexical-playground] Reuse guid method #7289

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ivailop7
Copy link
Collaborator

@ivailop7 ivailop7 commented Mar 4, 2025

We had the same method a couple of times across the codebase. A small clean up.

Copy link

vercel bot commented Mar 4, 2025

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 Mar 4, 2025 11:27pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 4, 2025 11:27pm

@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 Mar 4, 2025
@ivailop7 ivailop7 added the extended-tests Run extended e2e tests on a PR label Mar 4, 2025
@@ -65,6 +65,7 @@ export {default as positionNodeOnRange} from './positionNodeOnRange';
export {default as selectionAlwaysOnDisplay} from './selectionAlwaysOnDisplay';
export {
$splitNode,
createUID,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we need to export this from both lexical and @lexical/utils? It's already in lexical so maybe just import it from there rather than include its implementation twice?

@@ -239,6 +239,7 @@ export {
$setCompositionKey,
$setSelection,
$splitNode,
createUID,
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should add some API docs to this function if we're going to export it. I wouldn't say it's a good UID implementation, just a quick hack and only has a key space of <12M with up to 5 letters (there's no guarantee that there are any characters because it's not a good algorithm, if the representation happened to be all digits it could even return an empty string). For things that don't have to support super old browsers it might make sense to just use randomUUID when possible (in secure contexts) - otherwise I would recommend that we fix the implementation so it's at least guaranteed to produce a 5 letter string, or adopt something like the nanoid algorithm.

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.

3 participants