Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

urmail4ashish's avatar

Comments by paragraph

I am working on a project, in which user can add there content. For that i am using CKEDITOR. And i want to allow the users to add comments to every paragraph they add.

0 likes
8 replies
Sinnbeck's avatar

So once they have submitted it, it is locked? If I create 3 paragraphs, and later delete number 2, how would you know that the second was deleted? And would you delete all comments made on the second paragraph?

automica's avatar

@urmail4ashish sounds like you'll need to save each paragraph as a separate row, and then you can set a

Paragraph hasMany Comment relationship between the two.

urmail4ashish's avatar

No we are not locking them. What i was thinking is to add a data-id to every paragraph and then add comments to those data-id's.

Any suggestions about it

Sinnbeck's avatar

Gutenberg has a seperate row in the database for each item (paragraph). This makes it easier to identify

I haven't tested it myself, but tried it out in WordPress and read some of the source code

artcore's avatar

https://editorjs.io/

also stores paragraphs and other blocks in a json object which you can save to DB entirely or per block.

And no dependencies.

When you edit the resource you can check if any #id has a comment to prevent deletion for instance.

I have it live on one app and seems to be working nicely minus a few quirks that will be solved soonish it looks. (alignment of paragraphs e.g.) plus there's a package if you happen to use Nova

Please or to participate in this conversation.