To transform a Highlight Annotation to a Strikethrough Annotation, and add a button for this logic in the annotationPopup UI element for example:
WebViewer(/*...*/).then(instance => {
const { Annotations, annotationManager } = instance.Core;
const annotationPopupItems = instance.UI.annotationPopup.getItems();
const lastItem = annotationPopupItems[annotationPopupItems.length - 1];
instance.UI.annotationPopup.add(
{
type: 'actionButton',
img: 'icon-tool-text-manipulation-strikethrough',
onClick: () => {
const highlight = instance.Core.annotationManager.getSelectedAnnotations()[0];
const strikeThroughAnnot = new Annotations.TextStrikeoutAnnotation();
strikeThroughAnnot.PageNumber = highlight.PageNumber;
strikeThroughAnnot.X = highlight.X;
strikeThroughAnnot.Y = highlight.Y;
strikeThroughAnnot.Width = highlight.Width;
strikeThroughAnnot.Height = highlight.Height;
strikeThroughAnnot.StrokeColor = highlight.StrokeColor;
strikeThroughAnnot.Quads = highlight.Quads
strikeThroughAnnot.Author = highlight.Author;
const highlightReplies = highlight.getReplies();
highlightReplies.forEach(reply => {
const newReply = annotationManager.createAnnotationReply(strikeThroughAnnot, reply.getContents());
newReply.Author = reply.Author;
});
instance.Core.annotationManager.addAnnotation(strikeThroughAnnot);
instance.Core.annotationManager.drawAnnotations(strikeThroughAnnot.PageNumber);
instance.Core.annotationManager.deleteAnnotation(highlight);
},
},
lastItem.dataElement,
);
});
Here’s a GIF demo: