Question regarding scheme and recalculation

I have a JSON data set of text comments (including child comments, but without overlapping) and I am trying to achieve a way to edit the text (including comments) with ProseMirror and post them back as JSON. For this task, the start and end coordinates of comments would need to be recalculated as the text is being modified. I have tried to integrate the Code Highlighting plugin, which already has the decoration start and end calculation challenge solved but it does not allow child “decorations”. I will highly appreciate any advice on what approach and scheme can I use. ( Comment has a start index, end index and a type in the dataset and ideally, the type has to be visible to the user).

Have you seen the Mappable class (which for example Transaction.mapping implements)?

Thank you very much for the prompt answer. I will inspect it right away. In the meanwhile, what scheme should I use for this kind of task? Nested nodes? A example would help a lot.