Issue with onParagraphText change event

Document Server version: 9.2.0

Hi team,

We recently started using the newly added onParagraphText event introduced in Document Server 9.2.0 (as mentioned in the changelog: https://github.com/ONLYOFFICE/DocumentServer/blob/master/CHANGELOG.md#920), and we’ve noticed a couple of issues / limitations while integrating it.

Issue 1: Event not emitted when a paragraph is deleted

When an entire paragraph is deleted, the onParagraphText event is not emitted.
Is this expected behavior, or should the event also be triggered when a paragraph is removed from the document?

Issue 2: Event text includes tracked deletions in review mode

When the editor is in Reviewing / Track Changes mode, and a word or sentence is deleted inside a paragraph:

  • The onParagraphText event is emitted
  • However, the text returned still contains the deleted content (redlined), rather than the final visible text

This seems to reflect the internal revision state rather than the accepted (final) text.

If this behavior is intentional:

  • Is there a way to retrieve the final paragraph text (as if all revisions were accepted) without modifying the document?

We tried calling SetDisplayModeInReview("final") before reading the paragraph text, but this approach modifies the document state, which is not acceptable for our use case.

Question

Is there:

  • A read-only API or flag to obtain paragraph text with all revisions accepted?
  • Or a recommended approach to extract “final” paragraph text while the document remains in review mode?

Any clarification or guidance would be appreciated.

Thanks in advance!

Hello @editor_pro

onParagraphText event was specifically made for annotations, which are available for existing text only. It is expected that this event does not include deletions.

It is also expected that this event reads tracked changed, since these changes are actually still in the document structure and accessible for other methods too.

There is also no reliable method for getting paragraph text as if it was final before accepting/rejecting the changes, because, as I have already mentioned, the text is still actually in the document.

Technically, you can get tracked changes actions and values with Review Report, also get a paragraph for specific change too, but it’d be difficult to calculate/concatenate those changes to the actual text. To get the concept, you can simply open playground, enable track changes mode and make some changes, after that call:

let doc = Api.GetDocument();
let reviewReport = doc.GetReviewReport();
let userChanges = reviewReport["Developer"];
let para = userChanges[0].ReviewedElement;
let text = para.GetText();
console.log(reviewReport);
console.log(para);
console.log(text);

In browser console you will see the concept. Probably this would be handy and you could come up with an idea.

Really appreciate the guidance and the playground example — thanks for taking the time to explain it.

1 Like