We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to restrict user edit or delete other user's comments

Hi,

Let's say I have an annotation and have comments by multiple authors. I would like to restrict edit/delete comment by other author's comments. At the same time, I would like to reply to their comments.

Thanks


1 Reply

CK Chinnamunia Karthik Chinna Thambi Syncfusion Team November 21, 2022 11:39 AM UTC

Hi Sriraman,

Refer the below sample to restrict users to edit and delete other user's comments and also you can reply to their comments.


Code Snippet:


 

  public documentLoad(args) {

    var viewer = (<any>document.getElementById('pdfViewer')).ej2_instances[0];

    viewer.annotationSettings.author = 'Syncfusion1';

  }

 

  public ajaxRequestSuccess(args) {

    if (args.action === 'RenderAnnotationComments') {

      setTimeout(() => {

        console.log(args);

        var viewer = (<any>document.getElementById('pdfViewer'))

          .ej2_instances[0];

 

        if (viewer.annotationSettings.author !== 'Syncfusion') {

          for (var i = 0; i < viewer.annotationCollection.length; i++) {

            viewer.annotationCollection[i].isCommentLock = true;

            viewer.annotation.editAnnotation(viewer.annotationCollection[i]);

          }

        }

      }, 500);

    }

  }



Sample: https://stackblitz.com/edit/angular-ddg23x-cyzatv?file=main.ts,app.component.html,app.component.ts


Note: In the given sample, We are setting the author name in the documentLoaded event and then we are locking the comments if the author name is not equal to "Syncfusion".



Regards,

CCM Karthik


Loader.
Live Chat Icon For mobile
Up arrow icon