-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -65,6 +65,7 @@ export {default as positionNodeOnRange} from './positionNodeOnRange'; | |||
export {default as selectionAlwaysOnDisplay} from './selectionAlwaysOnDisplay'; | |||
export { | |||
$splitNode, | |||
createUID, |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
We had the same method a couple of times across the codebase. A small clean up.