-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Unique id for each block #873
Comments
This is also mentioned in #727 |
@floatas did you discovered any issues so far with your own implementation? I'm also looking into this right now because it makes it more easy to post-process removed/updated blocks on the server-side. Can you elaborate more on the breaking changes? |
@floatas I have the same issue and I have added fasiha/mudderjs for generate unique ordered key. Also mentioned in (#819 (comment)) |
@christoph-kluge I haven't found any issues. When loading document without id's, they are generated. Seems to work with all cases, if you found any issues, let me know (also my modifications are available as npm). As for breaking changes, structure changed (added new property), I guess it should work fine with original documents, haven't tested that much. @vincent-herlemont I'm thinking of adding ordered key to blocks, but for now I just take order of appearance and assign numbered key in backed to each block. Will definitely take a look at your implementation |
@floatas thank you sharing the the code. It helped me a lot. I discovered one issue: It always generates new uuids even if you pass an existing dataset through |
Appreciate this is an old thread but it comes up when looking for this feature - I implemented this through introducing a "metadata" object on each block as I required to be able to assign a unique ID to every block to work with it in my backend system as well as pass additional metadata for each block through my backend system. Anyone looking for similar I have the sample code here, which can be easily customised to meet your own needs; https://github.com/alibail/editor.js |
This is quite an important feature in my case. My use case: I want to be able to mention parts of documents from different documents. In case to do that, I need blocks to have unique, but constant id's during 'lifecycle' of any block (eg, the same id after the content of the block is changed). |
I need this too. |
Any updates on this? |
I've added a working copy here on the current master: christoph-kluge@2ef5c91 This works fine for me and my use case. Feel free to use. Tested Features:
Important Note:
|
I'll try it out. Although, If not currently implemented, I'd have to make my own custom version with NanoID() (which is really fast), to keep consistent with other platforms. |
@mqtik to be honest I'm fine with both. As of now I will stick to UUID because this solves my personal situation and maybe the situation of some others. As mentioned in the PR I would love to receive some feedback from the maintainers. I'm fine to make the id-generation customizable through a callback as config parameter but I would prefer to have some feedback from the maintainers in the first place instead of hanging around here with this issue.
|
ID is useful for React key, and so on. |
^ that PR works for me locally - we can get some more comments on whatever there's left to do? Otherwise, I'll continue using this fork |
Yeah, I went with the fork too. 2 years for this is just too long. |
Shouldn't this issue be closed? |
Hi @floatas! I want to implement links to other blocks in the current document. So looks like I need such element with unique id How can I set blockId for each div inside 'editorjs'? |
How to get id in Custom block render? |
yes, how do we get the ID? |
Hey, It would be great if editor assigned unique id for each block. This would help to keep references, add links to other blocks.
This probably would introduce breaking changes, discussion would be needed before implementing.
I have fork where I plan to do more changes, one of them is uids https://github.com/floatas/editor.js/commit/36c1f61ed66689bf9237ae3f37cc7e76e0658cb9
The text was updated successfully, but these errors were encountered: