Skip to content

Commit cd7248a

Browse files
Clearing redaction annotations
This must apply before re-performing the PII identification on the same loaded document.
1 parent 6f0c726 commit cd7248a

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

webviewer-redaction-ai/client/document/analyzer.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ const getAnalysisResult = async () => {
6262

6363
const analyzeDocumentForPII = async () => {
6464
try {
65+
// Clear any existing AI-generated redactions before applying new ones
66+
clearAIRedactions();
67+
6568
// Show WebViewer loading spinner
6669
WebViewer.getInstance().UI.openElements('loadingModal');
6770

@@ -95,4 +98,18 @@ const analyzeDocumentForPII = async () => {
9598
}
9699
}
97100

101+
// Function to clear all AI-generated redaction annotations
102+
const clearAIRedactions = () => {
103+
const { annotationManager, Annotations } = WebViewer.getInstance().Core;
104+
// Get all redaction annotations with 'AI Redaction' Author
105+
const redactionList = annotationManager.getAnnotationsList().filter(
106+
annot => annot instanceof Annotations.RedactionAnnotation && annot.Author === 'AI Redaction'
107+
);
108+
109+
// Delete each matching redaction annotation
110+
redactionList.forEach(redaction => {
111+
annotationManager.deleteAnnotation(redaction, true);
112+
});
113+
}
114+
98115
export { analyzeDocumentForPII };

0 commit comments

Comments
 (0)