File tree Expand file tree Collapse file tree
webviewer-redaction-ai/client/document Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,6 +62,9 @@ const getAnalysisResult = async () => {
6262
6363const 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+
98115export { analyzeDocumentForPII } ;
You can’t perform that action at this time.
0 commit comments