Disable movement of Text Annotations but allow editing the text.

There might be cases when you want to disable movements (dragging and resizing) of text annotation but allow the user to edit the text. You can do this by using the following code:

PSPDFKit.load(options).then(instance => {
 const stopPropagation = (event) => event.stopImmediatePropagation();

 instance.addEventListener("annotationSelection.change", (ann) => {
     if (ann && ann instanceof PSPDFKit.Annotations.TextAnnotation) {
       instance.contentDocument.addEventListener(
         "pointermove",
         stopPropagation,
         { capture: true }
       );
       instance.contentDocument.addEventListener("mousemove", stopPropagation, {
         capture: true
       });
       instance.contentDocument.addEventListener("touchmove", stopPropagation, {
         capture: true
       });

       instance.contentDocument.addEventListener("keydown", stopPropagation, {
         capture: true
       });
     } else {
       instance.contentDocument.removeEventListener(
         "pointermove",
         stopPropagation,
         { capture: true }
       );

       instance.contentDocument.removeEventListener(
         "mousemove",
         stopPropagation,
         {
           capture: true
         }
       );
       instance.contentDocument.removeEventListener(
         "touchmove",
         stopPropagation,
         {
           capture: true
         }
       );

       instance.contentDocument.removeEventListener("keydown", stopPropagation, {
         capture: true
       });
     }
   });
})

All the other annotations except the Text annotation will work as expected.

This has been tested with PSPDFKit for Web 2020.6.0