瀏覽代碼

【2025】【Markup】注释操作缩图刷新相关及代码整理

dinglingui 3 月之前
父節點
當前提交
610c60a689

+ 13 - 4
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFListViewExtension/CPDFListView+Event.m

@@ -3059,10 +3059,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                     if (draggedAnnotation == false) { // 当前只处理拖拽场景
                         break;
                     }
-                    // 注释 bounds 改变
-                    if ([self.pdfListViewDelegate respondsToSelector:@selector(PDFListViewAnnotationAttributeHasChange:withAnnotation:)]) {
-                        [self.pdfListViewDelegate PDFListViewAnnotationAttributeHasChange:self withAnnotation:annotation];
-                    }
+                
                     dispatch_async(dispatch_get_main_queue(), ^{
                         [[NSNotificationCenter defaultCenter] postNotificationName:CPDFListViewAnnotationsAttributeHasChangeNotification object:@{@"keyPath": CPDFAnnotationBoundsKey, @"object": annotation, @"didEnd" : @true}];
                     });
@@ -4853,6 +4850,10 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                         [(CPDFLineAnnotation *)annotation setStartPoint:startPoint];
                         [(CPDFLineAnnotation *)annotation setEndPoint:endPoint];
                     }
+                    
+                    dispatch_async(dispatch_get_main_queue(), ^{
+                        [[NSNotificationCenter defaultCenter] postNotificationName:CPDFListViewAnnotationsAttributeHasChangeNotification object:@{@"keyPath": CPDFAnnotationBoundsKey, @"object": annotation, @"didEnd" : @true}];
+                    });
                 }
             } else {
                 for (CPDFAnnotation *dragAnnotation in currentActiveAnnotations) {
@@ -4899,6 +4900,10 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                     dragAnnotation.bounds = CGRectMake(rect.origin.x + newBounds.origin.x, rect.origin.y + newBounds.origin.y, rect.size.width, rect.size.height);
                     if ([dragAnnotation isKindOfClass:[CPDFFreeTextAnnotation class]])
                         [self updateAnnotationFreeTextBounds:(CPDFFreeTextAnnotation *)dragAnnotation];
+                    
+                    dispatch_async(dispatch_get_main_queue(), ^{
+                        [[NSNotificationCenter defaultCenter] postNotificationName:CPDFListViewAnnotationsAttributeHasChangeNotification object:@{@"keyPath": CPDFAnnotationBoundsKey, @"object": dragAnnotation, @"didEnd" : @true}];
+                    });
                 }
             }
             self.multiplAnnotationObject = nil;
@@ -5214,6 +5219,10 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                     if([self.pdfListViewDelegate respondsToSelector:@selector(PDFListViewMobileAnnotationEnd:forPDFListView:forActiveAnnotations:)]) {
                         [self.pdfListViewDelegate PDFListViewMobileAnnotationEnd:point forPDFListView:self forActiveAnnotations:self.activeAnnotations];
                     }
+                    
+                    dispatch_async(dispatch_get_main_queue(), ^{
+                        [[NSNotificationCenter defaultCenter] postNotificationName:CPDFListViewAnnotationsAttributeHasChangeNotification object:@{@"keyPath": CPDFAnnotationBoundsKey, @"object": newActiveAnnotation, @"didEnd" : @true}];
+                    });
                     break;
                 } else if ([theEvent type] == NSEventTypeLeftMouseDragged) {
                     NSPoint point = NSZeroPoint;

+ 0 - 2
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListView.h

@@ -324,8 +324,6 @@ enum {
 
 - (void)PDFListViewRemoveAnnotations:(CPDFListView *)pdfListView forRemoveAnnotations:(NSArray<CPDFAnnotation *> *)annotations inPage:(CPDFPage *)pdfPage;
 
-- (void)PDFListViewDeleteAnnotations:(CPDFListView *)pdfListView forDeleteAnnotations:(NSArray<CPDFAnnotation *> *)annotations inPage:(CPDFPage *)pdfPage;
-
 - (void)PDFListViewChangeatioActiveAnnotations:(CPDFListView *)pdfListView forActiveAnnotations:(NSArray<CPDFAnnotation *> *)annotations isRightMenu:(BOOL)isRightMenu;
 
 - (void)PDFListViewMenuForEvent:(CPDFListView *)pdfListView forEvent:(NSEvent *)theEvent clickMenu:(NSMenu **)menu isMoveSelectAnno:(BOOL)isMoveSelectAnno;

+ 12 - 0
PDF Office/PDF Master/KMClass/KMNPDFPageEdit/KMNThumbnailView/KMNThumbnailBaseViewController.swift

@@ -287,6 +287,18 @@ class KMNThumbnailBaseViewController: KMNBaseViewController,NSCollectionViewDele
         collectionView.reloadData()
     }
     
+    public func reloadDataWithIndexs(pageIndexs: IndexSet) {
+        if currentDocument != nil {
+            for i in pageIndexs {
+                if i < currentDocument?.pageCount ?? 0 {
+                    let thumbnail = KMNThumbnail.init(document: currentDocument!, currentPageIndex: i)
+                    thumbnail.removeCacheImage()
+                }
+            }
+            reloadDataDatas()
+        }
+    }
+    
     // MARK: - private
     public func clickMenu(point:NSPoint)->ThumbnailMenuStruct {
         let copyPages: [CPDFPage] = KMNThumbnailManager.manager.copyPages

+ 55 - 418
PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.swift

@@ -336,6 +336,8 @@ struct KMNMWCFlags {
         
         initLeftSideController()
         
+        addNotificationCenter()
+        
         activityLoadMethod()
         
         let readModel = UserDefaults.standard.bool(forKey: CPDFViewIsReadModeKey)
@@ -353,6 +355,11 @@ struct KMNMWCFlags {
         
     }
     
+    private func addNotificationCenter() {
+        NotificationCenter.default.addObserver(self, selector: #selector(annotationsAttributeHasChange), name: NSNotification.Name.CPDFListViewAnnotationsAttributeHasChange, object:nil)
+
+    }
+    
     private func loadUserDefaultsData() {
         applyLeftSideWidth(0, rightSideWidth: 0) //初始打开左边栏
     }
@@ -1341,8 +1348,9 @@ struct KMNMWCFlags {
         if annotationMode.popType == .popTypeNone {
             closeAnnotationPopWindow()
         } else {
-            listView.window?.addChildWindow(popWindow.window ?? NSWindow(), ordered: .above)
-
+            if popWindow.window?.isVisible == false {
+                listView.window?.addChildWindow(popWindow.window ?? NSWindow(), ordered: .above)
+            }
             popWindow.listView = listView
             popWindow.annotationPopMode = annotationMode
             popWindow.isOpenPane = viewManager.showRightSide
@@ -3345,13 +3353,6 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
     }
     
     //MARK: - CPDFListViewDelegate
-    func cPDFListView(_ pdfListView: CPDFListView, didDelete annotation: CPDFAnnotation, in pdfPage: CPDFPage) {
-        self.leftSideViewController.updateThumbnail(at: Int(pdfPage.pageIndex()))
-    }
-    
-    func pdfListViewAnnotationAttributeHasChange(_ pdfListView: CPDFListView!, with annotation: CPDFAnnotation!) {
-        reloadPopUIWindow()
-    }
     
     func pdfListViewChangeatioActiveAnnotations(_ pdfListView: CPDFListView!, forActiveAnnotations annotations: [CPDFAnnotation]!, isRightMenu: Bool) {
         self.view.window?.makeFirstResponder(self.listView)
@@ -3442,7 +3443,6 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
                 }
             }
             rightSideController?.reloadDataWithPDFView(pdfView: pdfListView)
-            
         }
     }
     
@@ -3458,304 +3458,27 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
         reloadPopUIWindow()
     }
     
-    
     func pdfListViewChangedAnnotationType(_ pdfListView: CPDFListView!, for annotationType: CAnnotationType) {
         if(annotationType == .unkown) {
             toggleCloseRightSide()
         }
-        let aType = annotationType
-        if aType.isMarkup() || aType == .anchored || aType == .freeText || aType.isSquare() || aType == .link {
-            KMDataManager.ud_set(annotationType.rawValue, forKey: SKLastAnnotationModeKey)
-        }
-    }
-    
-    ///开始定位链接注释
-    func pdfListViewLinkDestinationStart(_ pdfListView: CPDFListView!, withActiveAnnotation annotation: CPDFAnnotation!) {
-        
-    }
-    
-    ///刷新链接注释
-    func pdfListViewLinkDestinationEnd(_ pdfListView: CPDFListView!, withActiveAnnotation annotation: CPDFAnnotation!) {
-        
     }
     
     func pdfListViewMenuItemsEditing(at point: CGPoint, for page: CPDFPage!, menuItems: [NSMenuItem]!) -> [NSMenuItem]! {
-        if (listView.toolMode != CToolMode.editPDFToolMode) {
-            return menuItems
-        }
-        var tMenuItems = menuItems;
-        
-        if(listView.isSelectEditCharRange() ||
-           listView.isSelecteditArea(with: point)) {
-            tMenuItems?.append(NSMenuItem.separator())
-        }
-        let areas = self.listView.editingAreas() ?? []
-        if  areas.count == 1 {
-            let fristAreas = areas.first
-            if fristAreas is CPDFEditImageArea {
-                self.listView.selectImageAreas = fristAreas as? CPDFEditImageArea
-                if self.listView.isEditImage {
-                    tMenuItems?.removeAll()
-                    tMenuItems?.append(self.corpImageMenuItem())
-                    tMenuItems?.append(self.cancelCorpImageMenuItem())
-                    tMenuItems?.append(self.restoreCorpImageMenuItem())
-                } else {
-                    tMenuItems?.append(NSMenuItem.separator())
-                    tMenuItems?.append(self.cutImageArea())
-                    tMenuItems?.append(self.replaceImageArea())
-                    tMenuItems?.append(self.exportImageArea())
-                }
-            } else {
-                if tMenuItems?.count != 1 {
-                    tMenuItems?.swapAt(0, 1)
-                }
-            }
-        } else if areas.count == 0 {
-            tMenuItems?.append(NSMenuItem.separator())
-            tMenuItems?.append(self.addText())
-            tMenuItems?.append(self.addImage())
-        }
-        
-        return tMenuItems
-    }
-    
-    func pdfListViewMenu(forEvent pdfListView: CPDFListView!, for theEvent: NSEvent!, click menu: AutoreleasingUnsafeMutablePointer<NSMenu?>!, isMoveSelectAnno: Bool) {
-        self.mouseRightMenuEvent = theEvent
-        var currentMenu : NSMenu = menu.pointee!
-        
-        if let activeAnno = listView.activeAnnotation as? KMTableAnnotation {//Table
-            var pagePoint = NSPoint()
-            _ = self.listView.pageAndPoint(&pagePoint, for: theEvent, nearest: true)
-            currentMenu.removeAllItems()
-            let annotation = activeAnno
-            annotation.completeEditCellText()
-            if !(NSIsEmptyRect(annotation.drawRect)) {
-                annotation.drawLine(pagePoint)
-                NotificationCenter.default.post(name: NSNotification.Name.KMPDFViewTableAnnotationDidChange, object: self, userInfo: ["point": NSValue(point: pagePoint)])
-            }
-            if (annotation.rowNumber - annotation.currentCell.row - 1) < 0 {
-                return
-            }
-            currentMenu = tableMenu(currentMenu, withTable: listView.activeAnnotation as! KMTableAnnotation, point: pagePoint)
-            listView.needsDisplay = true
-            return
-        }
-        
-        
-        var pagePoint: NSPoint = .zero
-        if let page = self.listView.pageAndPoint(&pagePoint, for: theEvent, nearest: true) {
-            let anno = page.annotation(at: pagePoint)
-            
-            
-            
-            let item1 = NSMenuItem(title: NSLocalizedString("Delete", comment: ""), action: #selector(menuItemActionMeasureDelete), target: self)
-            item1.representedObject = anno
-            let item2 = NSMenuItem(title: NSLocalizedString("Edit Note", comment: ""), action: #selector(menuItemActionMeasureEditNote), target: self)
-            item2.representedObject = anno
-            let item3 = NSMenuItem(title: NSLocalizedString("Settings", comment: ""), action: #selector(menuItemActionMeasureSetting), target: self)
-            item3.representedObject = anno
-            
-            if let data = anno as? CPDFPolygonAnnotation { // 多变形
-                currentMenu.removeAllItems()
-                
-                currentMenu.insertItem(item1, at: 0)
-                currentMenu.insertItem(item2, at: 1)
-                currentMenu.insertItem(item3, at: 2)
-                return
-            }
-            if let data = anno as? CPDFPolylineAnnotation {
-                currentMenu.removeAllItems()
-                currentMenu.insertItem(item1, at: 0)
-                currentMenu.insertItem(item2, at: 1)
-                currentMenu.insertItem(item3, at: 2)
-                return
-            }
-            if let data = anno as? CPDFLineAnnotation, data.isMeasure {
-                currentMenu.removeAllItems()
-                currentMenu.insertItem(item1, at: 0)
-                currentMenu.insertItem(item2, at: 1)
-                currentMenu.insertItem(item3, at: 2)
-                return
-            }
-        }
-        
-        
-        if (listView.toolMode == .selectToolMode){
-            currentMenu.insertItem(NSMenuItem.separator(), at: 3)
-            currentMenu.insertItem(self.printingMenu(), at: 3)
-            currentMenu.insertItem(self.setTTSStype(), at: 3)
-            currentMenu.insertItem(self.setCropStype(), at: 3)
-            currentMenu.insertItem(self.setSnapshotStype(), at: 3)
-            let export = NSMenuItem(title: NSLocalizedString("Export", comment: ""), action: nil, target: self)
-            export.submenu = self.exportMenu()
-            currentMenu.insertItem(export, at:  3)
-            currentMenu.insertItem(NSMenuItem.separator(), at: 3)
-            if listView.activeAnnotation == nil{
-                currentMenu.insertItem(self.setAnnotationToolStype(), at: 3)
-                currentMenu.insertItem(NSMenuItem.separator(), at: 3)
-            }
-            
-            currentMenu.insertItem(NSMenuItem.separator(), at: currentMenu.items.count - 3)
-            currentMenu.insertItem(self.addReadModelStype(), at: currentMenu.items.count - 3)
-            
-            currentMenu.insertItem(NSMenuItem.separator(), at: 0)
-            currentMenu.insertItem(self.setAITranslateStype(), at: 0)
-            currentMenu.insertItem(self.setAIProofreadStype(), at: 0)
-            currentMenu.insertItem(self.setAIRewriteStype(), at: 0)
-            return
-        }
-        if (listView.toolMode == .moveToolMode || listView.toolMode == .magnifyToolMode){
-            currentMenu.insertItem(NSMenuItem.separator(), at: 0)
-            currentMenu.insertItem(self.setTTSStype(), at: 0)
-            currentMenu.insertItem(self.setCropStype(), at: 0)
-            currentMenu.insertItem(self.setSnapshotStype(), at: 0)
-            currentMenu.insertItem(NSMenuItem.separator(), at: 0)
-            
-            currentMenu.insertItem(self.addOutlineStype(), at: 0)
-            currentMenu.insertItem(self.addBookmarkMenu(), at: 0)
-            if listView.activeAnnotation == nil{
-                currentMenu.insertItem(NSMenuItem.separator(), at: 0)
-                currentMenu.insertItem(self.setAnnotationToolStype(), at: 0)
-            }
-            
-            currentMenu.insertItem(NSMenuItem.separator(), at: 0)
-            currentMenu.insertItem(self.setAITranslateStype(), at: 0)
-            currentMenu.insertItem(self.setAIProofreadStype(), at: 0)
-            currentMenu.insertItem(self.setAIRewriteStype(), at: 0)
-            return
-        }
-        
-        if currentMenu.items.count > 3 {
-            currentMenu.insertItem(NSMenuItem.separator(), at: currentMenu.items.count - 3)
-            currentMenu.insertItem(self.addReadModelStype(), at: currentMenu.items.count - 3)
-        }
-        if listView.currentSelection != nil && listView.activeAnnotations.count < 1{
-            if listView.currentSelection.selectionType() == .text {
-                currentMenu.insertItem(NSMenuItem.separator(), at: 3)
-                currentMenu.insertItem(self.setSearchBaiduStype(), at: 3)
-                currentMenu.insertItem(NSMenuItem.separator(), at: 3)
-                currentMenu.insertItem(self.setLookUpStype(), at: 3)
-                currentMenu.insertItem(NSMenuItem.separator(), at: 3)
-                currentMenu.insertItem(self.addOutlineStype(), at: 3)
-                currentMenu.insertItem(NSMenuItem.separator(), at: 3)
-                currentMenu.insertItem(self.setAnnotationToolStype(), at: 3)
-                currentMenu.insertItem(self.setTTSStype(), at: 3)
-                currentMenu.insertItem(NSMenuItem.separator(), at: 3)
-                currentMenu.insertItem(self.setShareStype(), at: 3)
-                currentMenu.insertItem(NSMenuItem.separator(), at: 3)
-            }
-            currentMenu.insertItem(self.enterAnnotationStype(), at: 3)
-            currentMenu.insertItem(NSMenuItem.separator(), at: 3)
-            if listView.currentSelection.selectionType() == .image{
-                currentMenu.insertItem(NSMenuItem.separator(), at: 6)
-                currentMenu.insertItem(self.addOutlineStype(), at: 6)
-                currentMenu.insertItem(NSMenuItem.separator(), at: 6)
-                currentMenu.insertItem(self.setAnnotationToolStype(), at: 6)
-                
-            }
-            if listView.currentSelection.selectionType() == .text {
-                currentMenu.insertItem(NSMenuItem.separator(), at: currentMenu.items.count)
-                currentMenu.insertItem(self.setTranslateStype(), at: currentMenu.items.count)
-                currentMenu.insertItem(NSMenuItem.separator(), at: currentMenu.items.count)
-            }
-        }
-        if listView.activeAnnotation != nil || isMoveSelectAnno {
-            if let data = self.listView.activeAnnotation?.type?.lowercased(), data == "stamp"{
-                currentMenu.insertItem(NSMenuItem.separator(), at: currentMenu.items.count - 15)
-                currentMenu.insertItem(self.enterAnnotationStype(), at: currentMenu.items.count - 15)
-                currentMenu.insertItem(NSMenuItem.separator(), at: currentMenu.items.count - 15)
-            }else{
-                currentMenu.insertItem(NSMenuItem.separator(), at: currentMenu.items.count - 15)
-                currentMenu.insertItem(self.enterAnnotationStype(), at: currentMenu.items.count - 15)
-                if let anno = self.listView.activeAnnotation, anno.isKind(of: CPDFStampAnnotation.self) {
-                } else {
-                    currentMenu.insertItem(NSMenuItem.separator(), at: currentMenu.items.count - 15)
-                    currentMenu.insertItem(self.setShareStype(), at: currentMenu.items.count - 15)
-                }
-                currentMenu.insertItem(NSMenuItem.separator(), at: currentMenu.items.count - 15)
-            }
-        }
-        
-        if listView.activeAnnotation == nil && listView.currentSelection == nil{
-            currentMenu.insertItem(NSMenuItem.separator(), at: currentMenu.items.count)
-            if(listView.toolMode == .selectToolMode) {
-                if NSIsEmptyRect(listView.currentSelectionRect()) {
-                    currentMenu.insertItem(self.zoomSelectionMenuItem(), at: 0)
-                    currentMenu.insertItem(NSMenuItem.separator(), at: 0)
-                }
-                currentMenu.insertItem(self.printingMenu(), at: 0)
-                currentMenu.insertItem(self.setTTSStype(), at: 0)
-                currentMenu.insertItem(self.setCropStype(), at: 0)
-                currentMenu.insertItem(self.setSnapshotStype(), at: 0)
-                let export = NSMenuItem(title: NSLocalizedString("Export", comment: ""), action: nil, target: self)
-                export.submenu = self.exportMenu()
-                currentMenu.insertItem(export, at: currentMenu.items.count)
-                
-            }else{
-                currentMenu.insertItem(NSMenuItem.separator(), at: 2)
-                currentMenu.insertItem(self.setTTSStype(), at: 2)
-                currentMenu.insertItem(self.setCropStype(), at: 2)
-                currentMenu.insertItem(self.setSnapshotStype(), at: 2)
-                currentMenu.insertItem(NSMenuItem.separator(), at: 2)
-                
-                currentMenu.insertItem(self.addOutlineStype(), at: 2)
-                currentMenu.insertItem(NSMenuItem.separator(), at: 2)
-                currentMenu.insertItem(self.enterAnnotationStype(), at: 2)
-                currentMenu.insertItem(NSMenuItem.separator(), at: 2)
-                
-                if(currentMenu.items.count > 4) {
-                    currentMenu.insertItem(NSMenuItem.separator(), at: 5)
-                }
-                if(currentMenu.items.count > 5) {
-                    currentMenu.insertItem(self.addBookmarkMenu(), at: 6)
-                }
-                
-                currentMenu.insertItem(self.setAutoScrollStype(), at: currentMenu.items.count)
-            }
-            currentMenu.insertItem(self.setAnnotationToolStype(), at: 5)
-        }
-        
-        currentMenu.insertItem(NSMenuItem.separator(), at: 0)
-        currentMenu.insertItem(self.setAITranslateStype(), at: 0)
-        currentMenu.insertItem(self.setAIProofreadStype(), at: 0)
-        currentMenu.insertItem(self.setAIRewriteStype(), at: 0)
-        
-        for item in currentMenu.items {
-            if (item.action == NSSelectorFromString("menuItemClick_HidenorShowNote:")) {
-                // 显示与隐藏注释 item action 截取
-                item.action = #selector(menuItemClick_HidenorShowNote)
-                item.target = self
-                break
-            }
-        }
+        return menuItems
     }
     
     func pdfListViewAddAnnotations(_ pdfListView: CPDFListView!, forAdd annotations: [CPDFAnnotation]!, in pdfPage: CPDFPage!) {
-        var addRedact = false
-        for anno in annotations {
-            if (anno.isKind(of: CPDFRedactAnnotation.self)) {
-                addRedact = true
-            } else if anno is CPDFSquareAnnotation || anno is CPDFCircleAnnotation {
-                anno.contents = pdfPage?.string(for: anno.bounds) ?? ""
-            }
-        }
-        self.model.hasAddRedact = addRedact
-        if self.listView.toolMode == .moveToolMode {
-            self.listView.toolMode = .textToolMode
-            self.listView.annotationType = .unkown
-            
-        }
-        if (self.model.rightMouseEventing) {
-            self.model.rightMouseEventing = false
-            
-            
-            
-        }
-        self.leftSideViewController.refreshUIForAddAnnotation(annos: annotations, page: pdfPage)
+       
+        var pageIndexes = IndexSet()
+        pageIndexes.insert(Int(pdfPage.pageIndex()))
+        botaViewController?.thumnailViewController?.reloadDataWithIndexs(pageIndexs: pageIndexes)
     }
     
     func pdfListViewRemoveAnnotations(_ pdfListView: CPDFListView!, forRemove annotations: [CPDFAnnotation]!, in pdfPage: CPDFPage!) {
-        self.leftSideViewController.annoList_refreshUIForDeleteAnnotations(annos: annotations, page: pdfPage)
+        var pageIndexes = IndexSet()
+        pageIndexes.insert(Int(pdfPage.pageIndex()))
+        botaViewController?.thumnailViewController?.reloadDataWithIndexs(pageIndexs: pageIndexes)
     }
     
     func pdfListViewDidSelectionEnd(_ pdfListView: CPDFListView!) {
@@ -3770,14 +3493,6 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
         
     }
     
-    func pdfListViewKeyDowClosePanel(_ speedy: CPDFViewSidebarSpeedMode, event theEvent: NSEvent!) {
-        if(speedy == .right) {
-
-        } else if (speedy == .left) {
-            self.menuItemAction_hiddenLeftSide(speedy)
-        }
-    }
-    
     func pdfListViewEventMarkupColor(with annotation: CPDFAnnotation!) -> [NSColor]! {
         if (annotation.isKind(of: CPDFMarkupAnnotation.self)) {
             if (annotation as! CPDFMarkupAnnotation).markupType() == .highlight {
@@ -3797,49 +3512,7 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
         }
         return true
     }
-    
-    func pdfListView(_ sender: CPDFListView!, showSnapshotAtPageNumber pageNum: Int, for rect: NSRect, scaleFactor: CGFloat, autoFits: Bool) {
-        let swc = KMSnapshotWindowController(windowNibName: "SnapshotWindow")
-        swc.delegate = self
-        swc.setPdfDocument(self.listView.document, goToPageNumber: pageNum, rect: rect, scaleFactor: scaleFactor, autoFits: autoFits)
-        swc.forceOnTop = self.interactionMode != .normal
-        self.myDocument?.addWindowController(swc)
-    }
-    
-    func pdfListView(_ pdfView: CPDFListView!, documentDataDidChanged docData: Any!, withInfo info: [AnyHashable : Any]!) {
-        if let data = info?[CPDFListView.outlineKey] as? Bool, data { // 大纲改变
-            guard let ol = docData as? CPDFOutline else {
-                return
-            }
-            let add = info?[CPDFListView.outlineAddKey] as? Bool ?? false
-            let remove = info?[CPDFListView.outlineRemoveKey] as? Bool ?? false
-            if add {
-                self.leftSideViewController.addOutlineAfter(ol)
-            }
-            if remove {
-                self.leftSideViewController.removeOutlineAfter(ol)
-            }
-            
-            let demote = info?[CPDFListView.outlineDemoteKey] as? Bool ?? false
-            let promote = info?[CPDFListView.outlinePromoteKey] as? Bool ?? false
-            if demote {
-                self.leftSideViewController.demoteOutlineAfter(ol)
-            }
-            if promote {
-                self.leftSideViewController.promoteOutlineAfter(ol)
-            }
-        }
-    }
-    
-    //TextEdit
-    func pdfListViewDidTextFontChanged(_ pdfListView: CPDFListView!) {
         
-    }
-    
-    func pdfListViewDidTextColorChanged(_ pdfListView: CPDFListView!, with color: NSColor!) {
-        
-    }
-    
     func pdfListViewAnnotationMeasureInfoChange(_ pdfListView: CPDFListView!, with annotation: CPDFAnnotation!) {
         guard let data = annotation else {
             if distanceMeasureInfoWindowController?.window?.isVisible == true {
@@ -3859,53 +3532,7 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
     func pdfListViewMeasureCancel(_ pdfListView: CPDFListView!) {
         cancelMeasureType()
     }
-    
-    func tableMenu(_ menu: NSMenu, withTable table: KMTableAnnotation, point: CGPoint) -> NSMenu {
-        if table.currentCell.row >= 0 && table.currentCell.column >= 0 {
-            let itemTitles = ["Edit", "", "Add Row Above", "Add Row Below", "", "Add Column Before", "Add Column After", "", "Delete Row", "Delete Column", "Delete Table", "Cut", "Copy", "Paste", "Paste and Match Style", "Delete Cell Contents", "Clear All"]
-            let actions = ["formAnnotTextEdit:", "", "addRowAbove:", "addRowBelow:", "", "addColumnBefore:", "addColumnAfter:", "", "deleteRow:", "deleteColumn:", "deleteTabel", "cutCell:", "copyCell:", "pasteCell:", "pasteAndMatchStyle:", "deleteCellContents:", "clearAll:"]
-            for i in 0..<itemTitles.count {
-                var item: NSMenuItem? = nil
-                if itemTitles[i] == "" {
-                    item = NSMenuItem.separator()
-                    menu.insertItem(item!, at: i)
-                } else {
-                    item = NSMenuItem(title: itemTitles[i], action: nil, keyEquivalent: "")
-                    item!.target = self
-                    item!.action = NSSelectorFromString(actions[i])
-                    if itemTitles[i] == "Paste" /*&& !_copyCellData*/ {
-                        item!.action = nil
-                    } else if itemTitles[i] == "Paste and Match Style" /*&& !_copyCellData */{
-                        item!.action = nil
-                    } else if itemTitles[i] == "Add Row Above" {
-                        let path1 = table.crossLines[table.rowNumber - table.currentCell.row]
-                        let path2 = table.crossLines[table.rowNumber - table.currentCell.row - 1]
-                        if (path1 as AnyObject).lineJoinStyle == NSBezierPath.LineJoinStyle.round && table.headerCount() >= 5 {
-                            item!.action = nil
-                        } else if (path2 as AnyObject).lineJoinStyle == NSBezierPath.LineJoinStyle.bevel && table.footerCount() >= 5 {
-                            item!.action = nil
-                        }
-                    }
-                    item!.title = NSLocalizedString(item!.title, comment: "")
-                    item!.representedObject = NSValue(point: point)
-                    menu.insertItem(item!, at: i)
-                }
-            }
-        } else {
-            let itemTitles = ["Cut", "Copy", "Paste", "Delete"]
-            let actions = ["cut:", "copy:", "paste:", "delete:"]
-            for i in 0..<itemTitles.count {
-                let item = NSMenuItem(title: itemTitles[i], action: nil, keyEquivalent: "")
-                item.target = self
-                item.action = NSSelectorFromString(actions[i])
-                item.title = NSLocalizedString(item.title, comment: "")
-                menu.insertItem(item, at: i)
-                item.representedObject = NSValue(point: point)
-            }
-        }
-        return menu
-    }
-    
+        
     private func handleLineAnnotation(_ annotation: CPDFLineAnnotation) {
         if perimeterMeasureInfoWindowController?.window?.isVisible == true {
             perimeterMeasureInfoWindowController?.hideFloatingWindow()
@@ -4081,6 +3708,41 @@ extension KMMainViewController: KMNLeftSideViewControllerDelegate {
         }
         botaViewController?.pageCountChangedAction(document: document)
     }
+    
+    func annotationsAttributeHasChange(_ sender: Notification) {
+        guard let dict = sender.object as? [String : Any] else {
+            return
+        }
+            
+        if let anno = dict["object"] as? CPDFAnnotation {
+            let value = dict["keyPath"] as? String ?? ""
+            let didEnd = dict["didEnd"] as? Bool ?? false
+            if didEnd {
+                if value == CPDFAnnotationBoundsKey {
+                    if anno is CPDFSquareAnnotation || anno is CPDFCircleAnnotation {
+                        anno.contents = anno.page?.string(for: anno.bounds) ?? ""
+                    }
+                }
+                if anno.km_isMeasure() && anno.contents == nil {
+                    anno.contents = anno.string() ?? ""
+                }
+                var pageIndexes = IndexSet()
+                pageIndexes.insert(Int(anno.page.pageIndex()))
+                botaViewController?.thumnailViewController?.reloadDataWithIndexs(pageIndexs: pageIndexes)
+                
+                reloadPopUIWindow()
+            } else {
+                if value != CPDFAnnotationBoundsKey && value != CPDFAnnotationStartPointKey && value != CPDFAnnotationEndPointKey && value != CPDFAnnotationPathsKey { // 改变bounds(箭头、直线注释 开始点和结束点, 手绘注释的paths)的操作会卡顿,比如移动
+                    var pageIndexes = IndexSet()
+                    pageIndexes.insert(Int(anno.page.pageIndex()))
+                    botaViewController?.thumnailViewController?.reloadDataWithIndexs(pageIndexs: pageIndexes)
+                    
+                    reloadPopUIWindow()
+                }
+            }
+        }
+    }
+
 }
 
 
@@ -5778,32 +5440,7 @@ extension KMMainViewController {
             }
         }
     }
-    
-    func annotationsAttributeHasChange(_ sender: Notification) {
-        guard let dict = sender.object as? [String : Any] else {
-            return
-        }
-        if let anno = dict["object"] as? CPDFAnnotation {
-            let value = dict["keyPath"] as? String ?? ""
-            let didEnd = dict["didEnd"] as? Bool ?? false
-            if didEnd {
-                if value == CPDFAnnotationBoundsKey {
-                    if anno is CPDFSquareAnnotation || anno is CPDFCircleAnnotation {
-                        anno.contents = anno.page?.string(for: anno.bounds) ?? ""
-                    }
-                }
-                if anno.km_isMeasure() && anno.contents == nil {
-                    anno.contents = anno.string() ?? ""
-                }
-                self.leftSideViewController.refreshUIForAnnoAttributeDidChange(anno, attributes: ["keyPath" : value])
-            } else {
-                if value != CPDFAnnotationBoundsKey && value != CPDFAnnotationStartPointKey && value != CPDFAnnotationEndPointKey && value != CPDFAnnotationPathsKey { // 改变bounds(箭头、直线注释 开始点和结束点, 手绘注释的paths)的操作会卡顿,比如移动
-                    self.leftSideViewController.refreshUIForAnnoAttributeDidChange(anno, attributes: ["keyPath" : value])
-                }
-            }
-        }
-    }
-    
+        
     internal func applicationWillTerminateNotification(_ sender: Notification) {
         self.savePageNumberIfNeed()
         self.saveDocument()