Browse Source

Merge branch 'develop_PDFReaderProNew' of git.kdan.cc:Mac_PDF/PDF_Office into develop_PDFReaderProNew

niehaoyu 11 months ago
parent
commit
a47fd80de8
23 changed files with 4906 additions and 8948 deletions
  1. 24 6
      PDF Office/PDF Master/Class/ChromiumTabs/src/Tab/CTTabController.m
  2. 2 1
      PDF Office/PDF Master/Class/Home/View/KMComboBox.swift
  3. 2 8
      PDF Office/PDF Master/Class/PDFTools/Convert/NewController/KMConvertWindowController.swift
  4. 17 0
      PDF Office/PDF Master/Class/PDFTools/Merge/View/KMPDFThumbnialPageView.swift
  5. 5 69
      PDF Office/PDF Master/Class/PDFTools/PageEdit/Controller/KMPDFEditViewController.swift
  6. 1 1
      PDF Office/PDF Master/Class/PDFTools/PageEdit/Window/KMPDFEditPageRangeWindowController.swift
  7. 1 1
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFAnnotation+PDFListView.swift
  8. 22 4
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Event.m
  9. 1 1
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/Split/KMSecondaryViewController.m
  10. 14 6
      PDF Office/PDF Master/Class/PDFWindowController/PDFListView/Split/View/KMSecondaryPDFView.swift
  11. 66 17
      PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController+Note.swift
  12. 3 1
      PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController.swift
  13. 2 1
      PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/Thumbnail/Base/KMPDFThumbViewBaseController.swift
  14. 2 2
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMColorPickerView.swift
  15. 1 1
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMGeneralAnnotationViewController.swift
  16. 2 2
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/NSObject/KMAnnotationPropertiesColorManager.swift
  17. 11 3
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/WindowController/KMAnnotationFontWindowController.swift
  18. 12 12
      PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarItemView.swift
  19. 15 8
      PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarViewController.swift
  20. 6 0
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift
  21. 2 0
      PDF Office/PDF Master/Class/README.md
  22. 0 32
      PDF Office/PDF Reader Pro.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
  23. 4695 8772
      PDF Office/PDF Reader Pro.xcodeproj/xcuserdata/lizhe.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

+ 24 - 6
PDF Office/PDF Master/Class/ChromiumTabs/src/Tab/CTTabController.m

@@ -173,29 +173,47 @@ static NSString* const kBrowserThemeDidChangeNotification =
 
     self.tabView.wantsLayer = YES;
     NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
+    
+    BOOL isDarkModel = [KMAdvertisementConfig isDarkModel];
+    NSColor *backgroundColor_Norm = [NSColor km_initWithHex:@"#D5D5D5" alpha:1];
+    NSColor *backgroundColor_Hov = [NSColor km_initWithHex:@"#FCFDFF" alpha:1];
+    NSColor *backgroundColor_Sel = [NSColor km_initWithHex:@"#FCFDFF" alpha:1];
+    
+    NSColor *backgroundColor_Norm_Dark = [NSColor km_initWithHex:@"#393C3E" alpha:1];
+    NSColor *backgroundColor_Hov_Dark = [NSColor km_initWithHex:@"#424345" alpha:1];
+    NSColor *backgroundColor_Sel_Dark = [NSColor km_initWithHex:@"#424345" alpha:1];
+    
+    NSColor *text_Norm = [NSColor km_initWithHex:@"#42464D" alpha:1];
+    NSColor *text_Hov = [NSColor km_initWithHex:@"#0E1114" alpha:1];
+    NSColor *text_Sel = [NSColor km_initWithHex:@"#0E1114" alpha:1];
+    
+    NSColor *text_Norm_Dark = [NSColor km_initWithHex:@"#7E7F85" alpha:1];
+    NSColor *text_Hov_Dark = [NSColor km_initWithHex:@"#C8C9CC" alpha:1];
+    NSColor *text_Sel_Dark = [NSColor km_initWithHex:@"#C8C9CC" alpha:1];
+    
     if (state_ == KMDesignTokenStateNorm) {
-        self.tabView.layer.backgroundColor = NSColor.clearColor.CGColor;
+        self.tabView.layer.backgroundColor = isDarkModel ? backgroundColor_Norm_Dark.CGColor : backgroundColor_Norm.CGColor;
         self.tabView.layer.borderColor = self.borderColor.CGColor;
         self.tabView.layer.cornerRadius = self.borderRadiusTopLeft;
         style.lineSpacing = self.lineHeight;
         titleView_.font = self.font;
-        titleView_.textColor = self.textFill;
+        titleView_.textColor = isDarkModel ? text_Norm_Dark : text_Norm;
     } else if (state_ == KMDesignTokenStateHov) {
-        self.tabView.layer.backgroundColor = self.fill_hov.CGColor;
+        self.tabView.layer.backgroundColor = isDarkModel ? backgroundColor_Hov_Dark.CGColor : backgroundColor_Hov.CGColor;;
         self.tabView.layer.borderColor = self.borderColor_hov.CGColor;
         self.tabView.layer.cornerRadius = self.borderRadiusTopLeft_hov;
         self.tabView.layer.maskedCorners = kCALayerMinXMaxYCorner | kCALayerMaxXMaxYCorner;
         style.lineSpacing = self.lineHeight_hov;
         titleView_.font = self.font_hov;
-        titleView_.textColor = self.textFill_hov;
+        titleView_.textColor = isDarkModel ? text_Hov_Dark : text_Hov;
     } else if (state_ == KMDesignTokenStateSel) {
-        self.tabView.layer.backgroundColor = self.fill_sel.CGColor;
+        self.tabView.layer.backgroundColor = isDarkModel ? backgroundColor_Sel_Dark.CGColor : backgroundColor_Sel.CGColor;;
         self.tabView.layer.borderColor = self.borderColor_sel.CGColor;
         self.tabView.layer.cornerRadius = self.borderRadiusTopLeft_sel;
         self.tabView.layer.maskedCorners = kCALayerMinXMaxYCorner | kCALayerMaxXMaxYCorner;
         style.lineSpacing = self.lineHeight_sel;
         titleView_.font = self.font_sel;
-        titleView_.textColor = self.textFill_sel;
+        titleView_.textColor = isDarkModel ? text_Sel_Dark : text_Sel;
     }
 //    titleView_.attributedStringValue = [[NSMutableAttributedString alloc] initWithString:self.title attributes:@{NSParagraphStyleAttributeName:style}];
 }

+ 2 - 1
PDF Office/PDF Master/Class/Home/View/KMComboBox.swift

@@ -25,7 +25,8 @@ class KMComboBox: NSComboBox {
             p.x += comboxRect.width - 23
             p.y += (comboxRect.height - 16) / 2
             
-            NSColor.init(red: 245/255.0, green: 246/255.0, blue: 249/255.0, alpha: 1.0).setFill()
+//            NSColor.init(red: 255/255.0, green: 255/255.0, blue: 255/255.0, alpha: 1.0).setFill()
+            KMAppearance.Layout.l1Color().setFill()
             NSRect(x: p.x, y: 0, width: 16.0, height: comboxRect.height).fill()
 
             let image = NSImage(named: "KMImageNameUXIconBtnArrowDown")

+ 2 - 8
PDF Office/PDF Master/Class/PDFTools/Convert/NewController/KMConvertWindowController.swift

@@ -87,8 +87,6 @@ let kConvertFileSavePath = (kTempSavePath?.stringByAppendingPathComponent("conve
     private var fileAttri_: KMFileAttribute?
     
     deinit {
-        self.prePDFView.document = nil
-        self.tempPDFDocument = nil
 #if DEBUG
         NSLog("====KMConvertWindowController==deinit")
 #endif
@@ -544,12 +542,8 @@ let kConvertFileSavePath = (kTempSavePath?.stringByAppendingPathComponent("conve
                 print("Error removing item at path: (error.localizedDescription)")
             }
         }
-//        if #available(macOS 10.13, *) {
-//            self.window?.endSheet(sender.window!)
-//        } else {
-//            NSApp.endSheet(self.window!)
-//        }
-//        self.window?.orderOut(self)
+        self.prePDFView.document = nil
+        self.tempPDFDocument = nil
         self.km_quick_endSheet()
     }
     func showCriticalAlert(_ alertMsg: String?) {

+ 17 - 0
PDF Office/PDF Master/Class/PDFTools/Merge/View/KMPDFThumbnialPageView.swift

@@ -89,8 +89,25 @@ class KMPDFThumbnialPageLayer: CATiledLayer {
                 
                 ctx.scaleBy(x: viewWidth / bounds.size.width,
                             y: viewHeight / bounds.size.height);
+//                self.page!.drawEdit(with: .cropBox, to: ctx)
+//            self.page?.draw(with: .cropBox, to: ctx)
+//            if let tiffData = (self.page?.thumbnail(of: self.page?.size ?? .zero))?.tiffRepresentation {
+//            if let tiffData = self.page?.PDFListViewTIFFData(for: self.page?.bounds ?? .zero) {
+//                let image = NSImage(data: tiffData)
+//                image?.draw(in: ctx as! NSRect)
+//                image?.draw(in: bounds)
+//                let bitmap = NSBitmapImageRep(data: tiffData)
+//                ctx.draw((bitmap?.cgImage)!, in: NSMakeRect(0, 0, bounds.size.width, bounds.size.height))
+//                ctx.restoreGState();
+//                self.contents = bitmap?.cgImage
+//            } else {
+//            km_synchronized(self.page!.document) {
                 self.page!.drawEdit(with: .cropBox, to: ctx)
+//            }
+//                self.page!.drawEdit(with: .cropBox, to: ctx)
                 ctx.restoreGState();
+//            }
+//                ctx.restoreGState();
                 
                 if let _image = ctx.makeImage() {
                     let image = NSImage(cgImage: _image, size: NSSize(width: viewWidth, height: viewHeight))

+ 5 - 69
PDF Office/PDF Master/Class/PDFTools/PageEdit/Controller/KMPDFEditViewController.swift

@@ -958,8 +958,7 @@ class KMPDFEditViewController: KMPDFThumbViewBaseController {
         windowC.currentPage = self.getSelecteIndex() + 1
         windowC.insertLocation = 3
         windowC.callback = { [weak self] pdfDoc, _, pages, insertI in
-            if let _pages = pages {
-//                self?.insertPages(pages: _pages, at: IndexSet(integer: insertI+1))
+            if pages != nil {
                 // mm 单位的大小
                 guard let _winC = self?.kmCurrentWindowC as? KMPDFEditInsertBlankPageWindow else {
                     self?.km_endSheet()
@@ -967,8 +966,6 @@ class KMPDFEditViewController: KMPDFThumbViewBaseController {
                 }
                 var pageSize = _winC.pageSize
                 let direction = windowC.pageRotation == 0 ? 0 : 1
-//                var _pageSize = KMPageEditTools.sizeUnitToBoundSize(unit: .mm, pageSize: pageSize)
-                
                 if (direction == 0) { // 纵向
                     if (pageSize.width > pageSize.height) { // 需要交换
                         let tmp = pageSize.width
@@ -993,75 +990,12 @@ class KMPDFEditViewController: KMPDFThumbViewBaseController {
                 if let page: CPDFPage = (document?.page(at: 0)) {
                     self?.insertPages(pages: [page], at: IndexSet(integer: insertI))
                 }
+                let ips: Set<IndexPath> = [IndexPath(item: insertI, section: 0)]
+                self?.thumbnailView.collectionView.scrollToItems(at: ips, scrollPosition: .centeredVertically)
             }
-            
             self?.km_endSheet()
         }
         self.km_beginSheet(windowC: windowC)
-        #if false
-        Task { @MainActor in
-            let windowController = KMPageEditInsertCustomPageWindowController()
-            if (self.isEmptySelection() == false) {
-                let page = self.getSelectedPage()
-                let width = page.bounds.size.width * 210 / 595
-                let height = page.bounds.size.height * 297 / 842
-                windowController.selectedPageSize = NSSize(width: width, height: height)
-//                windowController.selectedPageSize = self.getSelectedPage().bounds.size
-            }
-            
-            self.km_beginSheet(windowC: windowController)
-            windowController.itemClick = { [weak self] index in
-                if (index == 1) { /// 取消
-                    self?.km_endSheet()
-                    return
-                }
-                
-                /// 插入
-                guard let windowC = self?.kmCurrentWindowC as? KMPageEditInsertCustomPageWindowController else {
-                    self?.km_endSheet()
-                    return
-                }
-                guard let _insertIndex = self?.getInsertIndex() else {
-                    self?.km_endSheet()
-                    return
-                }
-                
-                /// 样式
-                //            let type = windowC.typeIndex
-                // mm 单位的大小
-                let pageSize = windowC.pageSize
-                let direction = windowC.direction
-                var _pageSize = KMPageEditTools.sizeUnitToBoundSize(unit: .mm, pageSize: pageSize)
-                
-                if (direction == 0) { // 纵向
-                    if (_pageSize.width > _pageSize.height) { // 需要交换
-                        let tmp = _pageSize.width
-                        _pageSize.width = _pageSize.height
-                        _pageSize.height = tmp
-                    } else {
-                        // no things.
-                    }
-                } else { // 横向
-                    if (_pageSize.width > _pageSize.height) {
-                        // no things.
-                    } else { // 需要交换
-                        let tmp = _pageSize.width
-                        _pageSize.width = _pageSize.height
-                        _pageSize.height = tmp
-                    }
-                }
-                
-                /// 插入位置
-                let document = CPDFDocument()
-                document?.insertPage(_pageSize, at: 0)
-                if let page: CPDFPage = (document?.page(at: 0)) {
-                    self?.insertPages(pages: [page], at: IndexSet(integer: _insertIndex+1))
-                }
-
-                self?.km_endSheet()
-            }
-        }
-        #endif
     }
     
     func extractSelectPageItemAction() {
@@ -1482,6 +1416,8 @@ extension KMPDFEditViewController {
     
     override func insertBlankPageAfter(size: NSSize, at index: Int) {
         self.selectPages(indexs: IndexSet(integer: index))
+        let ips: Set<IndexPath> = [IndexPath(item: index, section: 0)]
+        self.thumbnailView.collectionView.scrollToItems(at: ips, scrollPosition: .centeredVertically)
         self.dealPdfDocumentDidEditCallback(type: .insert)
     }
     

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/PageEdit/Window/KMPDFEditPageRangeWindowController.swift

@@ -35,7 +35,7 @@ class KMPDFEditPageRangeWindowController: NSWindowController {
         self.pageRangeTextField.placeholderString = KMLocalizedString("e.g. 1,3-5,10", nil)
     //    self.totalPageCountLabel.integerValue = self.pdfDocument.pageCount;
         
-        self.totalPageCountLabel.stringValue = String(format: ", Total %ld Pages", self.pdfDocument?.pageCount ?? 0)
+        self.totalPageCountLabel.stringValue = String(format: KMLocalizedString(", Total %ld Pages", nil), self.pdfDocument?.pageCount ?? 0)
         self.detailLabel.stringValue = ""
         self.cancelButton.title = KMLocalizedString("Cancel", nil)
         self.okButton.title = KMLocalizedString("OK", nil)

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFAnnotation+PDFListView.swift

@@ -128,7 +128,7 @@ import Foundation
     }
     
     func dashPattern() -> [Any] {
-        return self.border.dashPattern
+        return self.border?.dashPattern ?? []
     }
     
     func setDashPattern(_ pattern: [Any]) {

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

@@ -2268,14 +2268,31 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
     } else if (CAnnotationTypeFreeText == self.annotationType ||
                CAnnotationTypeSignText == self.annotationType) {
         //保存参数
-        KMEditPDFTextFontModel *model = [KMEditPDFTextManager.manager fetchUserDefaultDataWithTypeStringWithType:@"Commonly"];
-        NSString *fontName = [KMEditPDFTextManager.manager fetchFontNameWithFontName:model.fontName];
-        NSString *fontStyle = [KMEditPDFTextManager.manager fetchFontStyleWithFontName:model.fontName];
-        CGFloat size = model.fontSize;
+        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+        NSString *fontName = [KMEditPDFTextManager.manager fetchFontNameWithFontName: [defaults objectForKey:CFreeTextNoteFontNameKey]];
+        NSString *fontStyle = [KMEditPDFTextManager.manager fetchFontStyleWithFontName: [defaults objectForKey:CFreeTextNoteFontNameKey]];
+        CGFloat size = [[defaults objectForKey:CFreeTextNoteFontSizeKey] floatValue];
+        CGFloat opacity = [[defaults objectForKey:CFreeTextNoteOpacityKey] floatValue];
+//        CGFloat size = [[defaults objectForKey:CFreeTextNoteFontSizeKey] floatValue];
+//        defaults.safe_setColor(annotation.color, forKey: CFreeTextNoteColorKey)
+//        defaults.safe_setColor((annotation as! CPDFFreeTextAnnotation).fontColor, forKey: CFreeTextNoteFontColorKey)
+//        defaults.set((annotation as! CPDFFreeTextAnnotation).alignment.rawValue, forKey: CFreeTextNoteAlignmentKey)
+//        defaults.set((annotation as! CPDFFreeTextAnnotation).fontName(), forKey: CFreeTextNoteFontNameKey)
+//        defaults.set((annotation as! CPDFFreeTextAnnotation).fontSize(), forKey: CFreeTextNoteFontSizeKey)
+//        defaults.set(annotation.lineWidth(), forKey: CFreeTextNoteLineWidthKey)
+//        defaults.set(annotation.borderStyle().rawValue, forKey: CFreeTextNoteLineStyleKey)
+//        defaults.set(annotation.dashPattern(), forKey: CFreeTextNoteDashPatternKey)
+        
+        
+//        KMEditPDFTextFontModel *model = [KMEditPDFTextManager.manager fetchUserDefaultDataWithTypeStringWithType:@"Commonly"];
+//        NSString *fontName = [KMEditPDFTextManager.manager fetchFontNameWithFontName:model.fontName];
+//        NSString *fontStyle = [KMEditPDFTextManager.manager fetchFontStyleWithFontName:model.fontName];
+//        CGFloat size = model.fontSize;
         
         CPDFAnnotationModel *annotationModel = [[CPDFAnnotationModel alloc] initWithAnnotationType:self.annotationType];
         annotationModel.fontName = [NSString stringWithFormat:@"%@-%@",fontName,fontStyle];
         annotationModel.fontSize = size;
+        annotationModel.opacity = opacity;
         
         CGFloat defaultWidth = annotationModel.fontSize;
         CGFloat defaultHeight = annotationModel.fontSize;
@@ -2288,6 +2305,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
         annotation = [self addAnnotationWithType:self.annotationType selection:nil page:page bounds:bounds];
         if (self.annotationType == CAnnotationTypeFreeText) {
             ((CPDFFreeTextAnnotation *)annotation).font = [NSFont fontWithName:fontName size:fontSize];
+            annotation.opacity = opacity;
         }
         originalBounds = [annotation bounds];
         if (annotation) {

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/Split/KMSecondaryViewController.m

@@ -89,7 +89,7 @@
     self.view.layer.backgroundColor = [KMAppearance KMColor_Layout_BG_Drak].CGColor;
         
     
-    [_dragOrClickButtonLabel setStringValue:NSLocalizedString(@"Drag file here to open it", nil)];
+    [_dragOrClickButtonLabel setStringValue:NSLocalizedString(@"Drag File Here Or Select File", nil)];
     _dragOrClickButtonLabel.textColor = [KMAppearance KMColor_Layout_H1];
     
     _selectFileButton.wantsLayer = YES;

+ 14 - 6
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/Split/View/KMSecondaryPDFView.swift

@@ -614,22 +614,30 @@ class KMSecondaryPDFView: CPDFListView {
     }
     
     @objc func handlePageChangedNotification(_ notification: Notification) {
-        self.pagePopUpButton?.selectItem(at: self.currentPageIndex)
+        if !self.document.isLocked {
+            self.pagePopUpButton?.selectItem(at: self.currentPageIndex)
+        }
     }
     
     @objc func handleSynchronizedScaleChangedNotification(_ notification: Notification) {
-        if self.synchronizeZoom {
-            self.scaleFactor = self.synchronizedPDFView?.scaleFactor ?? 0.0
+        if !self.document.isLocked {
+            if self.synchronizeZoom {
+                self.scaleFactor = self.synchronizedPDFView?.scaleFactor ?? 0.0
+            }
         }
     }
     
     @objc func handleDocumentDidUnlockNotification(_ notification: Notification) {
-        self.reloadPagePopUpButton()
+        if !self.document.isLocked {
+            self.reloadPagePopUpButton()
+        }
     }
     
     @objc func handlePDFViewScaleChangedNotification(_ notification: Notification) {
-        if self.autoScales == false && self.synchronizeZoom == false {
-            self.setScaleFactor(fmax(self.scaleFactor, SKMinDefaultScaleMenuFactor), adjustPopup: true)
+        if !self.document.isLocked {
+            if self.autoScales == false && self.synchronizeZoom == false {
+                self.setScaleFactor(fmax(self.scaleFactor, SKMinDefaultScaleMenuFactor), adjustPopup: true)
+            }
         }
     }
     

+ 66 - 17
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController+Note.swift

@@ -533,8 +533,11 @@ extension KMLeftSideViewController {
             self.noteSortButton.toolTip = KMLocalizedString("ascending sort", nil)
         }
         KMDataManager.ud_set(self.isAscendSort, forKey: Self.Key.noteAscendSortKey)
-        
-        self.reloadAnnotation()
+        if self.noteSearchMode {
+            self.reloadNoteForSearchMode()
+        } else {
+            self.reloadAnnotation()
+        }
     }
     
     @IBAction func noteSearchAction(_ sender: NSButton) {
@@ -629,7 +632,11 @@ extension KMLeftSideViewController {
         }
         KMDataManager.ud_set(self.noteSortType.rawValue, forKey: Self.Key.noteSortTypeKey)
         
-        self.reloadAnnotation()
+        if self.noteSearchMode {
+            self.reloadNoteForSearchMode()
+        } else {
+            self.reloadAnnotation()
+        }
     }
     
     func showNoteEmptyView() {
@@ -818,38 +825,83 @@ extension KMLeftSideViewController {
 //               self.filtrateButton.isEnabled = true
 //            }
         }
-        
-        Task { @MainActor in
-            self.noteOutlineView.reloadData()
+        self.note_refrshUIIfNeed()
+    }
+    
+    func reloadNoteForSearchMode() {
+        if self.noteSearchMode == false {
+            return
+        }
+        //  处理排序
+        if self.noteSortType == .page {
+            if self.isAscendSort { /// 排序(升序)
+                self.noteSearchArray.sort {
+                    let idx0 = $0.anno?.page?.pageIndex() ?? 0
+                    let idx1 = $1.anno?.page?.pageIndex() ?? 0
+                    return idx0 <= idx1
+                }
+            } else {
+                self.noteSearchArray.sort {
+                    let idx0 = $0.anno?.page?.pageIndex() ?? 0
+                    let idx1 = $1.anno?.page?.pageIndex() ?? 0
+                    return idx0 > idx1
+                }
+            }
+        } else if self.noteSortType == .time {
+            if self.isAscendSort { /// 排序(升序)
+                self.noteSearchArray.sort {
+                    if $0.anno?.modificationDate() == nil {
+                        return false
+                    }
+                    if $1.anno?.modificationDate() == nil {
+                        return false
+                    }
+                    return $0.anno!.modificationDate() <= $1.anno!.modificationDate()
+                }
+            } else {
+                self.noteSearchArray.sort {
+                    if $0.anno?.modificationDate() == nil {
+                        return false
+                    }
+                    if $1.anno?.modificationDate() == nil {
+                        return false
+                    }
+                    return $0.anno!.modificationDate() > $1.anno!.modificationDate()
+                }
+            }
         }
+        self.note_refrshUIIfNeed()
     }
     
     // 搜索 Action
     func updateNoteFilterPredicate() {
         var stringValue = self.noteSearchField.stringValue
-        if self.caseInsensitiveNoteSearch { // 忽略大小写
-            stringValue = stringValue.lowercased()
-        }
-        
         // 清空数据
         self.noteSearchArray.removeAll()
         if stringValue.isEmpty {
             for model in self.annoListModel?.datas ?? [] {
-                guard let note = model.anno else {
+                guard let _ = model.anno else {
                     continue
                 }
                 self.noteSearchArray.append(model)
             }
         } else {
+            // 忽略大小写
+            let caseInsensite = self.caseInsensitiveNoteSearch
+            if caseInsensite {
+                stringValue = stringValue.lowercased()
+            }
             for model in self.annoListModel?.datas ?? [] {
                 guard let note = model.anno else {
                     continue
                 }
-                var noteString = KMBOTAAnnotationTool.fetchContentLabelString(annotation: note)
+                var noteString = ""
                 if let anno = note as? CPDFMarkupAnnotation {
                     noteString = anno.markupContent()
+                } else {
+                    noteString = KMBOTAAnnotationTool.fetchContentLabelString(annotation: note)
                 }
-                if self.caseInsensitiveNoteSearch {
+                if caseInsensite {
                     noteString = noteString.lowercased()
                 }
                 if noteString.contains(stringValue) {
@@ -857,10 +909,7 @@ extension KMLeftSideViewController {
                 }
             }
         }
-        // 刷新 UI
-        Task { @MainActor in
-            self.noteOutlineView.reloadData()
-        }
+        self.note_refrshUIIfNeed()
     }
     
     @objc func selectSelectedNote(_ sender: AnyObject?) {

+ 3 - 1
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController.swift

@@ -2294,15 +2294,17 @@ extension KMLeftSideViewController: KMCustomOutlineViewDelegate, KMCustomOutline
             if (items.isEmpty) {
                 return
             }
+            self.dataUpdating = true
             for item in self.noteItems(items as NSArray) {
                 guard let anno = item as? CPDFAnnotation else {
                     continue
                 }
                 self.listView?.remove(anno)
             }
+            self.dataUpdating = false
             self.listView?.undoManager?.setActionName(KMLocalizedString("Remove Note", "Undo action name"))
             
-            self.reloadAnnotation()
+            self.note_refrshUIIfNeed()
         } else if anOutlineView.isEqual(to: self.tocOutlineView) {
             self.outlineContextMenuItemClicked_RemoveEntry(nil)
         }

+ 2 - 1
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/Thumbnail/Base/KMPDFThumbViewBaseController.swift

@@ -185,7 +185,8 @@ class KMPDFThumbViewBaseController: KMBaseViewController {
                         }
                     }
                     self?.insertPages(pages: insertPages, at: indexs)
-                    
+                    let ips = self?.indexsToIndexpaths(indexs: indexs) ?? []
+                    self?.thumbnailView.collectionView.scrollToItems(at: ips, scrollPosition: .centeredVertically)
                     self?.km_endSheet()
                 }
                 self.km_beginSheet(windowC: windowC)

+ 2 - 2
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMColorPickerView.swift

@@ -143,8 +143,8 @@ class KMColorPickerView: NSControl {
             lastSubview.removeFromSuperview()
         }
 
-        var width: CGFloat = 30.0
-        let space: CGFloat = 9.0
+        let width: CGFloat = 30.0
+        let space: CGFloat = 7.0
         var posX: CGFloat = 0
         var buttons: [NSButton] = []
 

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMGeneralAnnotationViewController.swift

@@ -579,7 +579,7 @@ let KMColorPickerViewHeight: CGFloat = 64
     
     var annotation: CPDFAnnotation {
         get {
-            return (annotationModel?.annotation)!
+            return annotationModel?.annotation ?? CPDFAnnotation()
         }
     }
     

+ 2 - 2
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/NSObject/KMAnnotationPropertiesColorManager.swift

@@ -204,8 +204,8 @@ extension KMAnnotationPropertiesColorManager {
                     NSColor(red: 184.0/255.0, green: 8.0/255.0, blue: 212.0/255.0, alpha: 1.0),
                     NSColor(red: 37.0/255.0, green: 38.0/255.0, blue: 41.0/255.0, alpha: 1.0)]
         } else if key == KMLineFillPropertColors {
-            return [NSColor.clear,
-                    NSColor.white,
+            return [NSColor(red: 0, green: 0, blue: 0, alpha: 0),
+                    NSColor(red: 1, green: 1, blue: 1, alpha: 1.0),
                     NSColor(red: 223.0/255.0, green: 225.0/255.0, blue: 228.0/255.0, alpha: 1.0),
                     NSColor(red: 255.0/255.0, green: 241.0/255.0, blue: 193.0/255.0, alpha: 1.0),
                     NSColor(red: 189.0/255.0, green: 223.0/255.0, blue: 253.0/255.0, alpha: 1.0)]

+ 11 - 3
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/WindowController/KMAnnotationFontWindowController.swift

@@ -30,7 +30,11 @@ class KMFontModel: NSObject {
     
     static var sharedAnnotationFont: KMAnnotationFontWindowController!
     
-    var annotationFontModel: KMFontModel?
+    var annotationFontModel: KMFontModel? {
+        didSet {
+            reloadData()
+        }
+    }
     var callback: ((KMFontModel) -> Void)?
     @IBOutlet weak var fontLabel: NSTextField!
     @IBOutlet weak var fontComboBox: NSComboBox!
@@ -106,11 +110,15 @@ class KMFontModel: NSObject {
     // MARK: private Method
     
     func reloadData() {
+        
+        guard let fontSizePopUpButton = fontSizePopUpButton else { return }
         if fontWeightPopUpButton != nil {
             fontWeightPopUpButton.removeAllItems()
         }
-        fontSizePopUpButton.title = "\(annotationFontModel?.fontSize ?? 12) pt"
-
+        
+        
+        let index = fontSizePopUpButton.indexOfItem(withTitle: "\(Int(annotationFontModel?.fontSize ?? 12)) pt")
+        fontSizePopUpButton.selectItem(at: index)
         DispatchQueue.global(qos: .default).async {
             let fonts = NSFontManager.shared.availableFontFamilies
             var fontArr = [NSAttributedString]()

+ 12 - 12
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarItemView.swift

@@ -407,11 +407,11 @@ extension KMToolbarItemView {
             return
         }
         if (!self.isSelected) {
-//            if self.selectBackgroundType == .none {
+            if self.selectBackgroundType == .none {
                 self.layer?.backgroundColor = Self.selectedBackgroundColor.cgColor
-//            } else {
-//                self.imageViewBox.fillColor = Self.selectedBackgroundColor
-//            }
+            } else {
+                self.imageViewBox.fillColor = Self.selectedBackgroundColor
+            }
             
             if(self.image != nil && self.alternateImage != nil) {
                 self._kNormalImage = self.image
@@ -438,11 +438,11 @@ extension KMToolbarItemView {
         super.mouseExited(with: event)
         
         if (!self.isSelected && !self.needExpandAction) {
-//            if self.selectBackgroundType == .none {
+            if self.selectBackgroundType == .none {
                 self.layer?.backgroundColor = self.normalBackgroundColor.cgColor
-//            } else {
-//                self.imageViewBox.fillColor = self.normalBackgroundColor
-//            }
+            } else {
+                self.imageViewBox.fillColor = self.normalBackgroundColor
+            }
            
             if(self.image != nil && self.alternateImage != nil) {
                 self.imageViewBtn.image = self._kNormalImage ?? self.image!
@@ -450,11 +450,11 @@ extension KMToolbarItemView {
         }
 
         if(self.needExpandAction && !self.isSelected) {
-//            if self.selectBackgroundType == .none {
+            if self.selectBackgroundType == .none {
                 self.layer?.backgroundColor = self.normalBackgroundColor.cgColor
-//            } else {
-//                self.imageViewBox.fillColor = self.normalBackgroundColor
-//            }
+            } else {
+                self.imageViewBox.fillColor = self.normalBackgroundColor
+            }
             
             if(self.image != nil && self.alternateImage != nil) {
                 self.imageViewBtn.image = self._kNormalImage ?? self.image!

+ 15 - 8
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarViewController.swift

@@ -188,7 +188,11 @@ class KMToolbarViewController: NSViewController, NSTextFieldDelegate {
     
     @IBAction func changeAnnotationMode(item: KMToolbarClickButton) {
         self.delegate?.changeAnnotationModeAction?(item: item)
-        self._itemSetPromptFlag(item: item.clickObject as? KMToolbarItemView)
+        if item.isKind(of: KMToolbarClickButton.self) {
+            self._itemSetPromptFlag(item: item.clickObject as? KMToolbarItemView)
+        } else {
+            
+        }
     }
     
     @IBAction func leftControllButtonAction(item: KMToolbarClickButton) {
@@ -788,11 +792,12 @@ extension KMToolbarViewController : KMToolbarViewDelegate,NSToolbarItemValidatio
                         item?.alternateImage = NSImage(named: KMImageNameUXIconSubtoolbarPageInsert)
                         item?.target = self
                         item?.btnTag = KMPageEditType.insert.rawValue
-            //            item?.toolTip = NSLocalizedString("Inserting pages into an existing PDF", comment: "")
+                        item?.isShowCustomToolTip = true
+                        item?.toolTip = NSLocalizedString("Inserting pages into an existing PDF", comment: "")
+                        item?.isPopToolTip = true
                         item?.titleName = NSLocalizedString("Insert", comment: "")
-                        item?.boxImagePosition = .imageExpandLeft
-            //            item?.btnAction = #selector(insertMenuAction)
-                        item?.needExpandAction = true
+                        item?.boxImagePosition = .imageOnly
+                        item?.btnAction = #selector(_itemAction)
                     } else if (identifier == KMToolbarPageEditExtractItemIdentifier) {
                         item?.image = NSImage(named: KMImageNameUXIconSubtoolbarPageExtract)
                         item?.alternateImage = NSImage(named: KMImageNameUXIconSubtoolbarPageExtract)
@@ -816,10 +821,12 @@ extension KMToolbarViewController : KMToolbarViewDelegate,NSToolbarItemValidatio
                         item?.alternateImage = NSImage(named: KMImageNameUXIconSubtoolbarPageSplit)
                         item?.target = self
                         item?.btnTag = KMPageEditType.split.rawValue
-            //            item?.toolTip = NSLocalizedString("Split and save selected PDF pages as a new separate document", comment: "")
+                        item?.isShowCustomToolTip = true
+                        item?.toolTip = NSLocalizedString("Split and save selected PDF pages as a new separate document", comment: "")
+                        item?.isPopToolTip = true
                         item?.titleName = NSLocalizedString("Split", comment: "")
-                        item?.boxImagePosition = .imageExpandLeft
-                        item?.needExpandAction = true
+                        item?.boxImagePosition = .imageOnly
+                        item?.btnAction = #selector(_itemAction)
                     } else if (identifier == KMToolbarPageEditReverseItemIdentifier) {
                         item?.image = NSImage(named: KMImageNameUXIconSubtoolbarPageReverse)
                         item?.alternateImage = NSImage(named: KMImageNameUXIconSubtoolbarPageReverse)

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

@@ -3408,6 +3408,7 @@ extension KMMainViewController {
         if document != nil {
             self.secondaryPdfView?.document = nil
             self.secondaryPdfView?.document = document
+            self.rightSideViewController.annotationProperties.openPropertiesType = .pageDisplay
             return true
         } else {
             return false
@@ -4643,6 +4644,11 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                     self.imageAnnotation(toolbarItem)
                 } else if toolbarItem.itemIdentifier == KMAnnotationTableToolbarItemIdentifier {
                     self.tableAnnotation(toolbarItem)
+                } else if toolbarItem.itemIdentifier == KMToolbarPageEditInsetItemIdentifier { // 插入
+                    self.leftSideViewController.insertPDF(nil)
+                } else if toolbarItem.itemIdentifier == KMToolbarPageEditSplitItemIdentifier { // 拆分
+                    let windowC = SplitWindowController(document: self.listView.document)
+                    self.km_beginSheet(windowC: windowC)
                 }
             }
         }

+ 2 - 0
PDF Office/PDF Master/Class/README.md

@@ -9,6 +9,8 @@
 
 - 页面编辑【阅读页】
 * KMPDFEditViewController
+- 页面编辑【阅读页】自定义页面范围
+* KMPDFEditPageRangeWindowController
 - 页面编辑【阅读页】插入文件
 * KMPDFEditInsertPageWindow
 - 页面编辑【阅读页】提取

+ 0 - 32
PDF Office/PDF Reader Pro.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -548,22 +548,6 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "3BE36286-8C36-4B23-9D98-9E718AA417D4"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/PDFWindowController/Side/LeftSide/KMImageToolTipWindow.swift"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "104"
-            endingLineNumber = "104"
-            landmarkName = "_showDelayed()"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
@@ -612,21 +596,5 @@
             </Locations>
          </BreakpointContent>
       </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "D709AEF9-E2F7-45B8-9385-2CE9A0A35DBF"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/Common/Base/KMBaseWindowController.swift"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "17"
-            endingLineNumber = "17"
-            landmarkName = "KMBaseWindowController"
-            landmarkType = "3">
-         </BreakpointContent>
-      </BreakpointProxy>
    </Breakpoints>
 </Bucket>

File diff suppressed because it is too large
+ 4695 - 8772
PDF Office/PDF Reader Pro.xcodeproj/xcuserdata/lizhe.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist