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

Make unique block id (not html id) #28137

Open
dikium opened this issue Jan 12, 2021 · 2 comments
Open

Make unique block id (not html id) #28137

dikium opened this issue Jan 12, 2021 · 2 comments

Comments

@dikium
Copy link

@dikium dikium commented Jan 12, 2021

What is this about?

Hi! I'm creating plugin which adds comment section to each block of article. So i need a unique id of an each block, stored in a database. How can i achieve this? Maybe i can somehow add extra attribute {"blockId": 1} to each block, but how can i do this, so it would not be deleted by gutenberg? Thanks!

@aristath
Copy link
Member

@aristath aristath commented Jan 12, 2021

Do you want the comments on the editor, or on the frontend?
If on the frontend then a block-ID is not necessary and it could be done via PHP filters on render_block.
I would advise against adding a new custom blockId prop to existing blocks as that would break all blocks in case your plugin gets disabled.

@dikium
Copy link
Author

@dikium dikium commented Jan 12, 2021

@aristath Yes, i want add comments to frontend. But i need identificate blocks because articles can be edited and blocks can be rearranged, so i need comments to conform own blocks. And is this a problem if blocks will have additional non active attribute? If it Will break editor i can remove it when i disable plugin. And may be i can somehow add metadata to all blocks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.