Browse Source

【fix】【BOTA】添加文字框,但不输入文字,退出添加,空白文字框会删除,但左侧注释列表没有刷新

tangchao 4 months ago
parent
commit
1228aec4d1

+ 11 - 9
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController+Note.swift

@@ -1105,20 +1105,22 @@ extension KMLeftSideViewController {
                         filterAnnos = (KMOCToolClass.filterAnnotation(annotations: filterAnnos,authors: authorArr) as? [CPDFAnnotation]) ?? []
                     }
                     
-                    if typeArr.contains(CPDFAnnotation.kType.measureArrow) {
-                        if typeArr.contains(CPDFAnnotation.kType.arrow) == false {
+                    if typeArr.isEmpty == false {
+                        if typeArr.contains(CPDFAnnotation.kType.measureArrow) {
+                            if typeArr.contains(CPDFAnnotation.kType.arrow) == false {
+                                for anno in filterAnnos {
+                                    if let data = anno as? CPDFLineAnnotation, data.type == CPDFAnnotation.kType.arrow && data.isMeasure == false {
+                                        filterAnnos.removeObject(anno)
+                                    }
+                                }
+                            }
+                        } else {
                             for anno in filterAnnos {
-                                if let data = anno as? CPDFLineAnnotation, data.type == CPDFAnnotation.kType.arrow && data.isMeasure == false {
+                                if let data = anno as? CPDFLineAnnotation, data.isMeasure {
                                     filterAnnos.removeObject(anno)
                                 }
                             }
                         }
-                    } else {
-                        for anno in filterAnnos {
-                            if let data = anno as? CPDFLineAnnotation, data.isMeasure {
-                                filterAnnos.removeObject(anno)
-                            }
-                        }
                     }
                     
                     if stateArr.count > 0 {

+ 13 - 0
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController.swift

@@ -447,6 +447,7 @@ import Cocoa
         NotificationCenter.default.addObserver(self, selector: #selector(didShowFullScreenNotification), name: NSWindow.didShowFullScreenNotification, object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(didAddContentViewNotification), name: NSWindow.didAddContentViewNotification, object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(addAutoSaveEvent), name: AutoSaveManager.kTimeValueChangedNotificationName, object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(didRemoveAnnotationNotification), name: NSNotification.Name.CPDFPageDidRemoveAnnotation, object: nil)
         
         Task {
             self.addAutoSaveEvent()
@@ -2456,6 +2457,18 @@ import Cocoa
         }
     }
     
+    //!!!: - CPDFFreeTextAnnotation 空注释时会删除,删除时sdk内部删除的,只能接受通知来刷选UI【正常的注释删除会走两遍】
+    @objc func didRemoveAnnotationNotification(_ sender: Notification) {
+        guard let anno = sender.object as? CPDFAnnotation else {
+            return
+        }
+        if anno.page?.document != self.listView.document {
+            return
+        }
+        
+        self.leftSideViewController.annoList_refreshUIForDeleteAnnotations(annos: [anno], page: anno.page)
+    }
+    
     // MARK: Split View
     
     func changePDFDocument(isChange: Bool, replaceBlock: @escaping (String) -> Void) {