123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803 |
- //
- // KMLeftSideViewController+Action.swift
- // PDF Master
- //
- // Created by tangchao on 2023/12/22.
- //
- import Foundation
- extension KMLeftSideViewController {
-
- }
- // MARK: - NSMenuDelegate
- extension KMLeftSideViewController: NSMenuDelegate {
- func menuNeedsUpdate(_ menu: NSMenu) {
- if menu.isEqual(to: self.tocOutlineView.menu) {
- menu.removeAllItems()
- var item = menu.addItem(withTitle: NSLocalizedString("Add Item", comment: ""), action: #selector(outlineContextMenuItemClicked_AddEntry), target: self, tag: 1)
- item = menu.addItem(withTitle: NSLocalizedString("Add Sub-Item", comment: ""), action: #selector(outlineContextMenuItemClicked_AddChildEntry), target: self, tag: 2)
- item = menu.addItem(withTitle: NSLocalizedString("Add To A Higher Level", comment: ""), action: #selector(outlineContextMenuItemClicked_AddAuntEntry), target: self, tag: 3)
- menu.addItem(.separator())
- item = menu.addItem(withTitle: NSLocalizedString("Delete", comment: ""), action: #selector(outlineContextMenuItemClicked_RemoveEntry), target: self, tag: 4)
- menu.addItem(.separator())
- item = menu.addItem(withTitle: NSLocalizedString("Edit", comment: ""), action: #selector(outlineContextMenuItemClicked_Edit), target: self, tag: 5)
- item = menu.addItem(withTitle: NSLocalizedString("Change Destination", comment: ""), action: #selector(outlineContextMenuItemClicked_SetDestination), target: self, tag: 6)
- item = menu.addItem(withTitle: NSLocalizedString("Rename", comment: ""), action: #selector(outlineContextMenuItemClicked_Rename), target: self, tag: 7)
- menu.addItem(.separator())
- item = menu.addItem(withTitle: NSLocalizedString("Promote", comment: ""), action: #selector(outlineContextMenuItemClicked_Promote), target: self, tag: 8)
- item = menu.addItem(withTitle: NSLocalizedString("Demote", comment: ""), action: #selector(outlineContextMenuItemClicked_Demote), target: self, tag: 9)
- return
- }
- var item: NSMenuItem?
- menu.removeAllItems()
- if menu.isEqual(to: self.thumbnailTableView.menu) {
- let row = self.thumbnailTableView.clickedRow
- if self.listView.document.documentURL == nil || self.thumbnailTableView.selectedRowIndexes.contains(row) == false{
- return
- }
- if (row != -1 && self.listView.document.isLocked == false) {
- if(self.thumbnailTableView.selectedRowIndexes.count == self.listView.document.pageCount) {
- item = menu.addItem(title: KMLocalizedString("Cut", "Menu item title"), action: nil, target: self)
- } else {
- item = menu.addItem(title: KMLocalizedString("Cut", "Menu item title"), action: #selector(cutPage), target: self)
- }
- item?.representedObject = IndexSet(integer: row)
-
-
- item = menu.addItem(title: KMLocalizedString("Copy", "Menu item title"), action: #selector(copyPage), target: self)
- item?.representedObject = IndexSet(integer: row)
-
- if (self.copyPages.count > 0) {
- item = menu.addItem(title: KMLocalizedString("Paste", "Menu item title"), action: #selector(pastePage), target: self)
- }else{
- item = menu.addItem(title: KMLocalizedString("Paste", "Menu item title"), action: nil, target: self)
- }
- item?.representedObject = IndexSet(integer: row)
- menu.addItem(.separator())
- if(self.thumbnailTableView.selectedRowIndexes.count == self.listView.document.pageCount) {
- item = menu.addItem(title: KMLocalizedString("Delete", "Menu item title"), action: nil, target: self)
- } else {
- item = menu.addItem(title: KMLocalizedString("Delete", "Menu item title"), action: #selector(deletePage), target: self)
- }
- item?.representedObject = IndexSet(integer: row)
- menu.addItem(.separator())
- item = menu.addItem(title: KMLocalizedString("Rotate", "Menu item title"), action: #selector(rotatePageMenuAction), target: self)
- item?.representedObject = IndexSet(integer: row)
- item = menu.addItem(title: KMLocalizedString("Insert", "Menu item title"), action: nil, target: self)
- let subMenu = NSMenu()
- subMenu.addItem(title: KMLocalizedString("Blank Page", "Menu item title"), action: #selector(quickInsert), target: self)
- subMenu.addItem(title: KMLocalizedString("Blank Page - Custom...", "Menu item title"), action: #selector(insert), target: self)
- subMenu.addItem(title: KMLocalizedString("From PDF", "Menu item title"), action: #selector(insertPDF), target: self)
- item?.submenu = subMenu
- item?.representedObject = IndexSet(integer: row)
- item = menu.addItem(title: KMLocalizedString("Extract", "Menu item title"), action: #selector(extractPage), target: self)
- item?.representedObject = IndexSet(integer: row)
- item = menu.addItem(title: KMLocalizedString("Page Edit", "Menu item title"), action: #selector(pageEdit), target: self)
- menu.addItem(.separator())
- var displayStr = ""
- if (self.isDisplayPageSize) {
- displayStr = KMLocalizedString("Hide Page Size", "Menu item title")
- } else {
- displayStr = KMLocalizedString("Display Page Size", "Menu item title")
- }
- item = menu.addItem(title: displayStr, action: #selector(displayPageSize), target: self)
- item?.representedObject = IndexSet(integer: row)
-
- item = menu.addItem(title: KMLocalizedString("Share", "Menu item title"), action: nil, target: self)
- // NSString * tName = [self fileNameWithSelectedPages:leftSideController.thumbnailTableView.selectedRowIndexes];
- // if (tName.length > 50) {
- // tName = [tName substringWithRange:NSMakeRange(0, 50)];
- // }
- var tName = self.listView.document.documentURL.lastPathComponent
- item?.submenu = NSSharingServicePicker.menu(forSharingItems: [self.listView.document.documentURL], subjectContext: tName, withTarget: self, selector: #selector(sharePage), serviceDelegate: nil)
- }
- } else if menu.isEqual(to: self.findTableView.menu) {
- var rowIndexes = self.findTableView.selectedRowIndexes
- var row = self.findTableView.clickedRow
- if (row != -1) {
- if rowIndexes.contains(row) == false {
- rowIndexes = IndexSet(integer: row)
- }
- // NSArray *selections = [[leftSideController.findArrayController arrangedObjects] objectsAtIndexes:rowIndexes];
- // if ([pdfView hideNotes] == NO && [[self pdfDocument] allowsNotes]) {
- item = menu.addItem(withTitle: KMLocalizedString("Add New Circle", "Menu item title"), action: #selector(addAnnotationsForSelections), target: self, tag: 0)
- //// [item setRepresentedObject:selections];
- item = menu.addItem(withTitle: KMLocalizedString("Add New Rectangle", "Menu item title"), action: #selector(addAnnotationsForSelections), target: self, tag: 1)
- //// [item setRepresentedObject:selections];
- item = menu.addItem(withTitle: KMLocalizedString("Add New Highlight", "Menu item title"), action: #selector(addAnnotationsForSelections), target: self, tag: 2)
- //// [item setRepresentedObject:selections];
- item = menu.addItem(withTitle: KMLocalizedString("Add New Underline", "Menu item title"), action: #selector(addAnnotationsForSelections), target: self, tag: 3)
- //// [item setRepresentedObject:selections];
- item = menu.addItem(withTitle: KMLocalizedString("Add New Strikethrough", "Menu item title"), action: #selector(addAnnotationsForSelections), target: self, tag: 4)
- // [item setRepresentedObject:selections];
- // }
- }
- } else if menu.isEqual(to: self.groupedFindTableView.menu) {
- var rowIndexes = self.groupedFindTableView.selectedRowIndexes
- var row = self.groupedFindTableView.clickedRow
- if (row != -1) {
- if rowIndexes.contains(row) == false {
- rowIndexes = IndexSet(integer: row)
- }
- // NSArray *selections = [[[leftSideController.groupedFindArrayController arrangedObjects] objectsAtIndexes:rowIndexes] valueForKeyPath:@"@unionOfArrays.matches"];
- item = menu.addItem(title: KMLocalizedString("Select", "Menu item title"), action: #selector(selectSelections), target: self)
- // [item setRepresentedObject:selections];
- menu.addItem(.separator())
- // if ([pdfView hideNotes] == NO && [[self pdfDocument] allowsNotes]) {
- item = menu.addItem(withTitle: KMLocalizedString("Add New Circle", "Menu item title"), action: #selector(addAnnotationsForSelections), target: self, tag: 0)
- // [item setRepresentedObject:selections];
- item = menu.addItem(withTitle: KMLocalizedString("Add New Rectangle", "Menu item title"), action: #selector(addAnnotationsForSelections), target: self, tag: 1)
- // [item setRepresentedObject:selections];
- item = menu.addItem(withTitle: KMLocalizedString("Add New Highlight", "Menu item title"), action: #selector(addAnnotationsForSelections), target: self, tag: 2)
- // [item setRepresentedObject:selections];
- item = menu.addItem(withTitle: KMLocalizedString("Add New Underline", "Menu item title"), action: #selector(addAnnotationsForSelections), target: self, tag: 3)
- // [item setRepresentedObject:selections];
- item = menu.addItem(withTitle: KMLocalizedString("Add New Strikethrough", "Menu item title"), action: #selector(addAnnotationsForSelections), target: self, tag: 4)
- // [item setRepresentedObject:selections];
- // }
- }
- } else if menu.isEqual(to: self.snapshotTableView.menu) {
- let row = self.snapshotTableView.clickedRow
- if (row != -1) {
- let model = self.snapshots[row]
- let controller = model.windowC
- if let data = controller?.window?.isVisible, data {
- item = menu.addItem(title: KMLocalizedString("Hide", "Menu item title"), action: #selector(hideSnapshot), target: self)
- item?.representedObject = controller
- } else {
- item = menu.addItem(title: KMLocalizedString("Show", "Menu item title"), action: #selector(showSnapshot), target: self)
- item?.representedObject = controller
- }
- menu.addItem(.separator())
- item = menu.addItem(title: KMLocalizedString("Export", "Menu item title"), action: nil, target: self)
- let subMenu = NSMenu()
- var t = subMenu.addItem(title: KMLocalizedString("PNG", "Menu item title"), action: #selector(menuItemClick_ExportPNG), target: self)
- t?.representedObject = controller
- t = subMenu.addItem(title: KMLocalizedString("JPG", "Menu item title"), action: #selector(menuItemClick_ExportJPG), target: self)
- t?.representedObject = controller
-
- t = subMenu.addItem(title: KMLocalizedString("PDF", "Menu item title"), action: #selector(menuItemClick_ExportPDF), target: self)
- t?.representedObject = controller
- item?.submenu = subMenu
- item = menu.addItem(title: KMLocalizedString("Print", "Menu item title"), action: #selector(menuItemClick_Print), target: self)
- item?.representedObject = controller
- menu.addItem(.separator())
-
- item = menu.addItem(title: KMLocalizedString("Copy", "Menu item title"), action: #selector(menuItemClick_Copy), target: self)
- item?.representedObject = controller
- menu.addItem(.separator())
- item = menu.addItem(title: KMLocalizedString("Delete", "Menu item title"), action: #selector(deleteSnapshot), target: self)
- item?.representedObject = controller
- item = menu.addItem(title: KMLocalizedString("Delete All Snapshots", "Menu item title"), action: #selector(deleteAllSnapshot), target: self)
- item?.representedObject = controller
- }
- } else if menu.isEqual(to: self.noteOutlineView.menu) {
- // NSArray *items;
- var rowIndexes = self.noteOutlineView.selectedRowIndexes
- let row = self.noteOutlineView.clickedRow
- if (row != -1) {
- if rowIndexes.contains(row) == false {
- rowIndexes = IndexSet(integer: row)
- // items = [rightSideController.noteOutlineView itemsAtRowIndexes:rowIndexes];
-
- // PDFAnnotation *foldNote = (PDFAnnotation *)notes[row];
- var isFold = true
- // if ([rightSideController.allFoldNotes containsObject:foldNote]) {
- // isFold = NO;
- // }
- item = menu.addItem(title: KMLocalizedString("Expand", nil), action: #selector(unfoldNoteAction), target: self)
- if (isFold) {
- item?.state = .off
- } else {
- item?.state = .on
- }
- // [item setRepresentedObject:items];
- item = menu.addItem(title: KMLocalizedString("Collapse", nil), action: #selector(foldNoteAction), target: self)
- if (isFold) {
- item?.state = .on
- } else {
- item?.state = .off
- }
- // [item setRepresentedObject:items];
-
- //UX改版删除
- // if ([self outlineView:rightSideController.noteOutlineView canCopyItems:items]) {
- // item = [menu addItemWithTitle:NSLocalizedString(@"Copy", @"Menu item title") action:@selector(copyNotes:) target:self];
- // [item setRepresentedObject:items];
- // }
- menu.addItem(.separator())
- if self.listView.hideNotes == false {
- // if ([pdfView hideNotes] == NO && [items count] == 1) {
- // PDFAnnotation *annotation = [[self noteItems:items] lastObject];
- // if ([annotation isEditable]) {
- // if ([(PDFAnnotation *)[items lastObject] type] == nil) {
- // if ([[(SKNoteText *)[items lastObject] note] isNote]) {
- // item = [menu addItemWithTitle:[NSLocalizedString(@"Edit", @"Menu item title") stringByAppendingEllipsis] action:@selector(editNoteTextFromTable:) target:self];
- // [item setRepresentedObject:annotation];
- // }
- // } else if ([[rightSideController.noteOutlineView tableColumnWithIdentifier:NOTE_COLUMNID] isHidden]) {
- // item = [menu addItemWithTitle:[NSLocalizedString(@"Edit", @"Menu item title") stringByAppendingEllipsis] action:@selector(editThisAnnotation:) target:pdfView];
- // [item setRepresentedObject:annotation];
- // } else {
- // item = [menu addItemWithTitle:NSLocalizedString(@"Edit", @"Menu item title") action:@selector(editNoteFromTable:) target:self];
- // [item setRepresentedObject:annotation];
- // item = [menu addItemWithTitle:[NSLocalizedString(@"Edit", @"Menu item title") stringByAppendingEllipsis] action:@selector(editThisAnnotation:) target:pdfView];
- // [item setRepresentedObject:annotation];
- // [item setKeyEquivalentModifierMask:NSEventModifierFlagOption];
- // [item setAlternate:YES];
- // }
- // }
- // if ([pdfView hideNotes] == NO && [[self pdfDocument] allowsNotes]) {
- // if ([pdfView activeAnnotation] == annotation) {
- // item = [menu addItemWithTitle:NSLocalizedString(@"Deselect", @"Menu item title") action:@selector(deselectNote:) target:self];
- // [item setRepresentedObject:annotation];
- // } else {
- // item = [menu addItemWithTitle:NSLocalizedString(@"Select", @"Menu item title") action:@selector(selectNote:) target:self];
- // [item setRepresentedObject:annotation];
- // }
- // item = [menu addItemWithTitle:NSLocalizedString(@"Show", @"Menu item title") action:@selector(revealNote:) target:self];
- // [item setRepresentedObject:annotation];
- // }
- // }
- // if ([menu numberOfItems] > 0)
- // [menu addItem:[NSMenuItem separatorItem]];
- // item = [menu addItemWithTitle:[items count] == 1 ? NSLocalizedString(@"Auto Size Row", @"Menu item title") : NSLocalizedString(@"Auto Size Rows", @"Menu item title") action:@selector(autoSizeNoteRows:) target:self];
- // [item setRepresentedObject:items];
- // item = [menu addItemWithTitle:[items count] == 1 ? NSLocalizedString(@"Undo Auto Size Row", @"Menu item title") : NSLocalizedString(@"Undo Auto Size Rows", @"Menu item title") action:@selector(resetHeightOfNoteRows:) target:self];
- // [item setRepresentedObject:items];
- // [item setKeyEquivalentModifierMask:NSAlternateKeyMask];
- // [item setAlternate:YES];
- // [menu addItemWithTitle:NSLocalizedString(@"Auto Size All", @"Menu item title") action:@selector(autoSizeNoteRows:) target:self];
- // item = [menu addItemWithTitle:NSLocalizedString(@"Undo Auto Size All", @"Menu item title") action:@selector(resetHeightOfNoteRows:) target:self];
- // [item setKeyEquivalentModifierMask:NSAlternateKeyMask];
- // [item setAlternate:YES];
- // [menu addItemWithTitle:NSLocalizedString(@"Automatically Resize", @"Menu item title") action:@selector(toggleAutoResizeNoteRows:) target:self];
-
- if menu.numberOfItems > 0 {
- item = menu.addItem(title: NSLocalizedString("Export Annotations…", tableName: "MainMenu", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
-
- let subMenu = NSMenu()
- item?.submenu = subMenu
- item = subMenu.addItem(title: NSLocalizedString("PDF", tableName: "MainMenu", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
- item?.tag = 0
- item = subMenu.addItem(title: NSLocalizedString("PDF Bundle", tableName: "MainMenu", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
- item?.tag = 1
- item = subMenu.addItem(title: NSLocalizedString("PDF Reader Pro Edition Notes", tableName: "MainMenu", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
- item?.tag = 2
- item = subMenu.addItem(title: NSLocalizedString("Notes as Texts", tableName: "MainMenu", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
- item?.tag = 3
- item = subMenu.addItem(title: NSLocalizedString("Notes as RTF", tableName: "MainMenu", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
- item?.tag = 4
- item = subMenu.addItem(title: NSLocalizedString("Notes as RTFD", tableName: "MainMenu", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
- item?.tag = 5
- item = subMenu.addItem(title: NSLocalizedString("Notes as FDF", tableName: "MainMenu", comment: "Menu item title"), action: #selector(exportAnnotationNotes), target: self)
- item?.tag = 6
-
- menu.addItem(.separator())
- // if ([self outlineView:rightSideController.noteOutlineView canDeleteItems:items]) {
- item = menu.addItem(title: KMLocalizedString("Delete", "Menu item title"), action: #selector(deleteNotes), target: self)
- // [item setRepresentedObject:items];
- // }
- item = menu.addItem(title: NSLocalizedString("Remove All Annotations", tableName: "MainMenu", comment: "Menu item title"), action: #selector(removeAllAnnotations), target: self)
- }
- }
- }
- }
- }
- // else {
- // item = [menu addItemWithTitle:NSLocalizedStringFromTable(@"Export Annotations…", @"MainMenu", @"Menu item title") action:@selector(exportAnnotationNotes:) target:self];
- //
- // NSMenu *subMenu = [NSMenu menu];
- // item.submenu = subMenu;
- // item = [subMenu addItemWithTitle:NSLocalizedStringFromTable(@"PDF", @"MainMenu", @"Menu item title") action:@selector(exportAnnotationNotes:) target:self];
- // item.tag = 0;
- // item = [subMenu addItemWithTitle:NSLocalizedStringFromTable(@"PDF Bundle", @"MainMenu", @"Menu item title") action:@selector(exportAnnotationNotes:) target:self];
- // item.tag = 1;
- // item = [subMenu addItemWithTitle:NSLocalizedStringFromTable(@"PDF Reader Pro Edition Notes", @"MainMenu", @"Menu item title") action:@selector(exportAnnotationNotes:) target:self];
- // item.tag = 2;
- // item = [subMenu addItemWithTitle:NSLocalizedStringFromTable(@"Notes as Text", @"MainMenu", @"Menu item title") action:@selector(exportAnnotationNotes:) target:self];
- // item.tag = 3;
- // item = [subMenu addItemWithTitle:NSLocalizedStringFromTable(@"Notes as RTF", @"MainMenu", @"Menu item title") action:@selector(exportAnnotationNotes:) target:self];
- // item.tag = 4;
- // item = [subMenu addItemWithTitle:NSLocalizedStringFromTable(@"Notes as RTFD", @"MainMenu", @"Menu item title") action:@selector(exportAnnotationNotes:) target:self];
- // item.tag = 5;
- // item = [subMenu addItemWithTitle:NSLocalizedStringFromTable(@"Notes as FDF", @"MainMenu", @"Menu item title") action:@selector(exportAnnotationNotes:) target:self];
- // item.tag = 6;
- //
- // item = [menu addItemWithTitle:NSLocalizedStringFromTable(@"Remove All Annotations", @"MainMenu", @"Menu item title") action:@selector(removeAllAnnotations:) target:self];
- // }
- // }
- }
- }
- // MARK: - NSMenuItemValidation
- extension KMLeftSideViewController: NSMenuItemValidation {
- func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
- if (self.listView.document == nil || self.listView.document!.isLocked) {
- return false
- }
- let action = menuItem.action
-
- // if (self.isCompareMode) {
- // return NO;
- // }
- // if (action == @selector(createNewNote:)) {
- // BOOL isMarkup = [menuItem tag] == SKHighlightNote || [menuItem tag] == SKUnderlineNote || [menuItem tag] == SKStrikeOutNote;
- // isMarkup = NO;
- // return [self interactionMode] != SKPresentationMode && [[self pdfDocument] allowsNotes] && ([pdfView toolMode] == SKTextToolMode || [pdfView toolMode] == SKNoteToolMode) && [pdfView hideNotes] == NO && (isMarkup == NO || [[pdfView currentSelection] hasCharacters]);
- // } else if (action == @selector(editNote:)) {
- // PDFAnnotation *annotation = [pdfView activeAnnotation];
- // return [self interactionMode] != SKPresentationMode && [annotation isSkimNote] && ([annotation isEditable]);
- // } else if (action == @selector(alignLeft:) || action == @selector(alignRight:) || action == @selector(alignCenter:)) {
- // PDFAnnotation *annotation = [pdfView activeAnnotation];
- // return [self interactionMode] != SKPresentationMode && [annotation isSkimNote] && ([annotation isEditable]) && [annotation respondsToSelector:@selector(setAlignment:)];
- // } else if (action == @selector(toggleHideNotes:)) {
- // if ([pdfView hideNotes])
- // [menuItem setTitle:NSLocalizedString(@"Show Notes", @"Menu item title")];
- // else
- // [menuItem setTitle:NSLocalizedString(@"Hide Notes", @"Menu item title")];
- // return YES;
- // } else if (action == @selector(changeDisplaySinglePages:)) {
- // [menuItem setState:([pdfView displayMode] & kPDFDisplayTwoUp) == (PDFDisplayMode)[menuItem tag] ? NSOnState : NSOffState];
- // return [self interactionMode] != SKPresentationMode && [[self pdfDocument] isLocked] == NO;
- // } else if (action == @selector(changeDisplayContinuous:)) {
- // [menuItem setState:([pdfView displayMode] & kPDFDisplaySinglePageContinuous) == (PDFDisplayMode)[menuItem tag] ? NSOnState : NSOffState];
- // return [self interactionMode] != SKPresentationMode && [[self pdfDocument] isLocked] == NO;
- // } else if (action == @selector(changeDisplayMode:)) {
- // [menuItem setState:[pdfView displayMode] == (PDFDisplayMode)[menuItem tag] ? NSOnState : NSOffState];
- // return [self interactionMode] != SKPresentationMode && [[self pdfDocument] isLocked] == NO;
- // } else if (action == @selector(toggleDisplayAsBook:)) {
- // [menuItem setState:[pdfView displaysAsBook] ? NSOnState : NSOffState];
- // return [self interactionMode] != SKPresentationMode && [[self pdfDocument] isLocked] == NO && ([pdfView displayMode] == kPDFDisplayTwoUp || [pdfView displayMode] == kPDFDisplayTwoUpContinuous);
- // } else if (action == @selector(toggleDisplayPageBreaks:)) {
- // [menuItem setState:[pdfView displaysPageBreaks] ? NSOnState : NSOffState];
- // return [self interactionMode] != SKPresentationMode && [[self pdfDocument] isLocked] == NO;
- // } else if (action == @selector(changeDisplayBox:)) {
- // [menuItem setState:[pdfView displayBox] == (PDFDisplayBox)[menuItem tag] ? NSOnState : NSOffState];
- // return [self interactionMode] != SKPresentationMode && [[self pdfDocument] isLocked] == NO;
- // } else if (action == @selector(delete:) || action == @selector(copy:) || action == @selector(cut:) || action == @selector(paste:) || action == @selector(alternatePaste:) || action == @selector(pasteAsPlainText:) || action == @selector(deselectAll:) || action == @selector(changeAnnotationMode:) || action == @selector(changeToolMode:) || action == @selector(changeToolMode:)) {
- // return [pdfView validateMenuItem:menuItem];
- // } else
- // if (action == @selector(doGoToNextPage:)) {
- // return [pdfView canGoToNextPage];
- // } else if (action == @selector(doGoToPreviousPage:) ) {
- // return [pdfView canGoToPreviousPage];
- // } else if (action == @selector(doGoToFirstPage:)) {
- // return [pdfView canGoToFirstPage];
- // } else if (action == @selector(doGoToLastPage:)) {
- // return [pdfView canGoToLastPage];
- // } else if (action == @selector(doGoToPage:)) {
- // return [[self pdfDocument] isLocked] == NO;
- // } else if (action == @selector(allGoToNextPage:)) {
- // return [[allMainDocumentPDFViews() valueForKeyPath:@"@min.canGoToNextPage"] boolValue];
- // } else if (action == @selector(allGoToPreviousPage:)) {
- // return [[allMainDocumentPDFViews() valueForKeyPath:@"@min.canGoToPreviousPage"] boolValue];
- // } else if (action == @selector(allGoToFirstPage:)) {
- // return [[allMainDocumentPDFViews() valueForKeyPath:@"@min.canGoToFirstPage"] boolValue];
- // } else if (action == @selector(allGoToLastPage:)) {
- // return [[allMainDocumentPDFViews() valueForKeyPath:@"@min.canGoToLastPage"] boolValue];
- // } else if (action == @selector(doGoBack:)) {
- // return [pdfView canGoBack];
- // } else if (action == @selector(doGoForward:)) {
- // return [pdfView canGoForward];
- // } else if (action == @selector(goToMarkedPage:)) {
- // if (beforeMarkedPageIndex != NSNotFound) {
- // [menuItem setTitle:NSLocalizedString(@"Jump Back From Marked Page", @"Menu item title")];
- // return YES;
- // } else {
- // [menuItem setTitle:NSLocalizedString(@"Go To Marked Page", @"Menu item title")];
- // return markedPageIndex != NSNotFound && markedPageIndex != [[pdfView currentPage] pageIndex];
- // }
- // } else if (action == @selector(markPage:)) {
- // return [[self pdfDocument] isLocked] == NO;
- // } else if (action == @selector(doZoomIn:)) {
- // return [self interactionMode] != SKPresentationMode && [pdfView canZoomIn];
- // } else if (action == @selector(doZoomOut:)) {
- // return [self interactionMode] != SKPresentationMode && [pdfView canZoomOut];
- // } else if (action == @selector(doZoomToActualSize:)) {
- // return [[self pdfDocument] isLocked] == NO && ([pdfView autoScales] || fabs([pdfView scaleFactor] - 1.0 ) > 0.01);
- // } else if (action == @selector(doZoomToPhysicalSize:)) {
- // return [self interactionMode] != SKPresentationMode && [[self pdfDocument] isLocked] == NO && ([pdfView autoScales] || fabs([pdfView physicalScaleFactor] - 1.0 ) > 0.01);
- // } else if (action == @selector(doMarqueeZoomTool:)) {
- // return [self interactionMode] != SKPresentationMode && [[self pdfDocument] isLocked] == NO;
- // } else if (action == @selector(doZoomToFit:)) {
- // return [self interactionMode] != SKPresentationMode && [[self pdfDocument] isLocked] == NO && [pdfView autoScales] == NO;
- // } else if (action == @selector(alternateZoomToFit:)) {
- // PDFDisplayMode displayMode = [pdfView displayMode];
- // if (displayMode == kPDFDisplaySinglePage || displayMode == kPDFDisplayTwoUp) {
- // [menuItem setTitle:NSLocalizedString(@"Zoom To Width", @"Menu item title")];
- // } else {
- // [menuItem setTitle:NSLocalizedString(@"Zoom To Height", @"Menu item title")];
- // }
- // return [self interactionMode] != SKPresentationMode && [[self pdfDocument] isLocked] == NO;
- // } else
- // if (action == @selector(doAutoScale:)) {
- // return [[self pdfDocument] isLocked] == NO && [pdfView autoScales] == NO;
- // } else if (action == @selector(toggleAutoScale:)) {
- // [menuItem setState:[pdfView autoScales] ? NSOnState : NSOffState];
- // return [[self pdfDocument] isLocked] == NO;
- // } else if (action == @selector(rotateRight:) || action == @selector(rotateLeft:) || action == @selector(rotateAllRight:) || action == @selector(rotateAllLeft:)) {
- // return [[self pdfDocument] isLocked] == NO;
- // } else if (action == @selector(cropAll:) || action == @selector(crop:) || action == @selector(autoCropAll:) || action == @selector(smartAutoCropAll:)) {
- // return [self interactionMode] != SKPresentationMode && [[self pdfDocument] isLocked] == NO;
- // } else if (action == @selector(autoSelectContent:)) {
- // return [self interactionMode] != SKPresentationMode && [[self pdfDocument] isLocked] == NO && [pdfView toolMode] == SKSelectToolMode;
- // } else if (action == @selector(takeSnapshot:)) {
- // return [[self pdfDocument] isLocked] == NO;
- // } else if (action == @selector(toggleLeftSidePane:)) {
- // if ([self leftSidePaneIsOpen])
- // [menuItem setTitle:NSLocalizedString(@"Hide Panel", @"Menu item title")];
- // else
- // [menuItem setTitle:NSLocalizedString(@"Show Panel", @"Menu item title")];
- // return YES;
- // } else if (action == @selector(toggleRightSidePane:)) {
- // if ([self rightSidePaneIsOpen])
- // [menuItem setTitle:NSLocalizedString(@"Hide Notes Pane", @"Menu item title")];
- // else
- // [menuItem setTitle:NSLocalizedString(@"Show Notes Pane", @"Menu item title")];
- // return [self interactionMode] != SKPresentationMode;
- // } else if (action == @selector(changeLeftSidePaneState:)) {
- // [menuItem setState:mwcFlags.leftSidePaneState == (SKLeftSidePaneState)[menuItem tag] ? (([leftSideController.findTableView window] || [leftSideController.groupedFindTableView window]) ? NSMixedState : NSOnState) : NSOffState];
- // return (SKLeftSidePaneState)[menuItem tag] == SKSidePaneStateThumbnail || [[pdfView document] outlineRoot];
- // } else if (action == @selector(changeRightSidePaneState:)) {
- // [menuItem setState:mwcFlags.rightSidePaneState == (SKRightSidePaneState)[menuItem tag] ? NSOnState : NSOffState];
- // return [self interactionMode] != SKPresentationMode;
- // }
- // // else if (action == @selector(toggleSplitPDF:)) {
- // // if ([(NSView *)secondaryPdfView window])
- // // [menuItem setTitle:NSLocalizedString(@"Hide Split PDF", @"Menu item title")];
- // // else
- // // [menuItem setTitle:NSLocalizedString(@"Show Split PDF", @"Menu item title")];
- // // return [self interactionMode] != SKPresentationMode;
- // // }
- // else
- // if (action == @selector(toggleStatusBar:)) {
- // if ([statusBar isVisible])
- // [menuItem setTitle:NSLocalizedString(@"Hide Status Bar", @"Menu item title")];
- // else
- // [menuItem setTitle:NSLocalizedString(@"Show Status Bar", @"Menu item title")];
- // return [self interactionMode] == SKNormalMode || [self interactionMode] == SKFullScreenMode;
- // } else if (action == @selector(searchPDF:)) {
- // return [self interactionMode] != SKPresentationMode;
- // } else if (action == @selector(toggleFullscreen:)) {
- // if ([self interactionMode] == SKFullScreenMode || [self interactionMode] == SKLegacyFullScreenMode)
- // [menuItem setTitle:NSLocalizedString(@"Exit Full Screen", @"Menu item title")];
- // else
- // [menuItem setTitle:NSLocalizedString(@"Full Screen", @"Menu item title")];
- // return [self canEnterFullscreen] || [self canExitFullscreen];
- // } else if (action == @selector(togglePresentation:)) {
- // if ([self interactionMode] == SKPresentationMode)
- // [menuItem setTitle:NSLocalizedString(@"Exit Presentation", @"Menu item title")];
- // else
- // [menuItem setTitle:NSLocalizedString(@"Presentation", @"Menu item title")];
- // return [self canEnterPresentation] || [self canExitPresentation];
- // } else if (action == @selector(getInfo:)) {
- // return [self interactionMode] != SKPresentationMode;
- // } else if (action == @selector(performFit:)) {
- // return [self interactionMode] == SKNormalMode && [[self pdfDocument] isLocked] == NO;
- // } else if (action == @selector(password:)) {
- // return [self interactionMode] != SKPresentationMode && [[self pdfDocument] permissionsStatus] != kPDFDocumentPermissionsOwner;
- // } else if (action == @selector(toggleReadingBar:)) {
- // if ([[self pdfView] hasReadingBar])
- // [menuItem setTitle:NSLocalizedString(@"Hide Reading Bar", @"Menu item title")];
- // else
- // [menuItem setTitle:NSLocalizedString(@"Show Reading Bar", @"Menu item title")];
- // return [self interactionMode] != SKPresentationMode && [[self pdfDocument] isLocked] == NO;
- // } else
- // if (action == @selector(savePDFSettingToDefaults:)) {
- // if ([self interactionMode] == SKFullScreenMode || [self interactionMode] == SKLegacyFullScreenMode)
- // [menuItem setTitle:NSLocalizedString(@"Use Current View Settings as Default for Full Screen", @"Menu item title")];
- // else
- // [menuItem setTitle:NSLocalizedString(@"Use Current View Settings as Default", @"Menu item title")];
- // return [self interactionMode] != SKPresentationMode && [[self pdfDocument] isLocked] == NO;
- // } else if (action == @selector(chooseTransition:)) {
- // return [[self pdfDocument] pageCount] > 1;
- // } else if (action == @selector(toggleCaseInsensitiveSearch:)) {
- // [menuItem setState:mwcFlags.caseInsensitiveSearch ? NSOnState : NSOffState];
- // return YES;
- // } else if (action == @selector(toggleWholeWordSearch:)) {
- // [menuItem setState:mwcFlags.wholeWordSearch ? NSOnState : NSOffState];
- // return YES;
- // } else if (action == @selector(toggleCaseInsensitiveNoteSearch:)) {
- // [menuItem setState:mwcFlags.caseInsensitiveNoteSearch ? NSOnState : NSOffState];
- // return YES;
- // } else if (action == @selector(toggleAutoResizeNoteRows:)) {
- // [menuItem setState:mwcFlags.autoResizeNoteRows ? NSOnState : NSOffState];
- // return YES;
- // } else if (action == @selector(performFindPanelAction:)) {
- // if ([self interactionMode] == SKPresentationMode)
- // return NO;
- // switch ([menuItem tag]) {
- // case NSFindPanelActionShowFindPanel:
- // return YES;
- // case NSFindPanelActionNext:
- // case NSFindPanelActionPrevious:
- // return YES;
- // case NSFindPanelActionSetFindString:
- // return [[[self pdfView] currentSelection] hasCharacters];
- // default:
- // return NO;
- // }
- // } else
- // if (action == @selector(highlightFormFiled:)) {
- // BOOL highlightFormFiled = [[NSUserDefaults standardUserDefaults] boolForKey:@"kPDFViewHighlightFormFiledKey"];
- // [menuItem setState:highlightFormFiled ? NSOnState : NSOffState];
- // return YES;
- // } else if (action == @selector(highlightLinks:)) {
- // BOOL highlightLinks = [[NSUserDefaults standardUserDefaults] boolForKey:@"kPDFViewHighlightLinksKey"];
- // [menuItem setState:highlightLinks ? NSOnState : NSOffState];
- // return YES;
- // } else if (action == @selector(link:)) {
- // return ([self.pdfView toolMode] == SKTextToolMode || [self.pdfView toolMode] == SKNoteToolMode) && [self.pdfView hideNotes] == NO && [self.pdfView.document isLocked] == NO;
- // return ([self.pdfView toolMode] == SKTextToolMode || [self.pdfView toolMode] == SKNoteToolMode) && [self.pdfView hideNotes] == NO && [self.pdfView.document isLocked] == NO && [[self.pdfView currentSelection] hasCharacters];
- // } else if (action == @selector(deletePage:)) {
- // return self.pdfView.document.pageCount > 1 ? YES : NO;
- // } else if (action == @selector(toggleAutoFlow:)) {
- // [menuItem setState:[self.pdfView isAutoFlow] ? NSOnState : NSOffState];
- // return YES;
- // } else if (action == @selector(themesColor:)){
- // if (KMPDFViewModeNormal== self.pdfView.viewMode) {
- // [menuItem setState:(menuItem.tag == 0)?NSOnState:NSOffState];
- // } else if (KMPDFViewModeSoft == self.pdfView.viewMode){
- // [menuItem setState:(menuItem.tag == 1)?NSOnState:NSOffState];
- // } else if (KMPDFViewModeNight == self.pdfView.viewMode){
- // [menuItem setState:(menuItem.tag == 2)?NSOnState:NSOffState];
- // } else if (KMPDFViewModeGreen == self.pdfView.viewMode){
- // [menuItem setState:(menuItem.tag == 3)?NSOnState:NSOffState];
- // } else if (KMPDFViewModeThemes1 == self.pdfView.viewMode){
- // [menuItem setState:(menuItem.tag == 4)?NSOnState:NSOffState];
- // } else if (KMPDFViewModeThemes2 == self.pdfView.viewMode){
- // [menuItem setState:(menuItem.tag == 5)?NSOnState:NSOffState];
- // } else if (KMPDFViewModeThemes3 == self.pdfView.viewMode){
- // [menuItem setState:(menuItem.tag == 6)?NSOnState:NSOffState];
- // } else if (KMPDFViewModeThemes4 == self.pdfView.viewMode){
- // [menuItem setState:(menuItem.tag == 7)?NSOnState:NSOffState];
- // }
- // // else {
- // // [menuItem setState:(menuItem.tag == 4)?NSOnState:NSOffState];
- // // }
- // NSData * data = [[NSUserDefaults standardUserDefaults] objectForKey:@"kKMPDFViewModeThemesArray"] ? : nil;
- // NSInteger themesCount;
- // if (data) {
- // NSArray * appArray = [NSKeyedUnarchiver unarchiveObjectWithData:data];
- // NSMutableArray * mutableArray = [NSMutableArray arrayWithArray:appArray];
- // themesCount = [menuItem tag] - mutableArray.count;
- // } else {
- // themesCount = [menuItem tag] - 4;
- // }
- // if (themesCount >= 0) {
- // menuItem.hidden = YES;
- // return NO;
- // } else {
- // menuItem.hidden = NO;
- // return YES;
- // }
- // } else
- // if (action == @selector(splitViewAction:)){
- // if (KMPDFViewSplitModeHorizontal == self.pdfView.viewSplitMode) {
- // [menuItem setState:(menuItem.tag == 0)?NSOnState:NSOffState];
- // } else if (KMPDFViewSplitModeVertical == self.pdfView.viewSplitMode) {
- // [menuItem setState:(menuItem.tag == 1)?NSOnState:NSOffState];
- // } else if (KMPDFViewSplitModeDisable == self.pdfView.viewSplitMode) {
- // [menuItem setState:(menuItem.tag == 2)?NSOnState:NSOffState];
- // }
- // } else
- if (action == #selector(outlineContextMenuItemClicked_AddEntry) ||
- action == #selector(outlineContextMenuItemClicked_AddChildEntry) ||
- action == #selector(outlineContextMenuItemClicked_AddAuntEntry) ||
- action == #selector(outlineContextMenuItemClicked_RemoveEntry) ||
- action == #selector(outlineContextMenuItemClicked_Edit) ||
- action == #selector(outlineContextMenuItemClicked_SetDestination) ||
- action == #selector(outlineContextMenuItemClicked_Rename) ||
- action == #selector(outlineContextMenuItemClicked_Promote) ||
- action == #selector(outlineContextMenuItemClicked_Demote)) {
- if let data = self.listView.document?.isLocked, data {
- return false
- }
- if (self.isSearchOutlineMode) {
- if (action == #selector(outlineContextMenuItemClicked_AddEntry) ||
- action == #selector(outlineContextMenuItemClicked_AddChildEntry) ||
- action == #selector(outlineContextMenuItemClicked_AddAuntEntry) ||
- action == #selector(outlineContextMenuItemClicked_Edit) ||
- action == #selector(outlineContextMenuItemClicked_Rename)
- ) {
- return false
- }
- }
- if (self.tocOutlineView.selectedRowIndexes.count > 1) {
- if (menuItem.tag == KMOutlineViewMenuItemTag.remove.rawValue) {
- return true
- }
- return false
- } else if (self.tocOutlineView.selectedRowIndexes.count > 0) {
- if (action == #selector(outlineContextMenuItemClicked_AddChildEntry) ||
- action == #selector(outlineContextMenuItemClicked_SetDestination)) {
- return true
- }
- }
- if (self.tocOutlineView.clickedRow == -1) {
- if (action == #selector(outlineContextMenuItemClicked_AddEntry)) {
- return true
- } else {
- return false
- }
- } else {
- let clickedOutline = self.tocOutlineView.item(atRow: self.tocOutlineView.clickedRow) as? CPDFOutline
- if let data = clickedOutline?.index, data > 0 {
- if (action == #selector(outlineContextMenuItemClicked_Demote)) {
- return true
- }
- } else {
- if (action == #selector(outlineContextMenuItemClicked_Demote)) {
- return false
- }
- }
- let parentOutLine = clickedOutline?.parent
- let grandparentOutLine = parentOutLine?.parent
- //if clicked PDFOutline 's parent exist
- if (grandparentOutLine != nil) {
- //and title is equla "add_AuntOutlineKey"
- if (action == #selector(outlineContextMenuItemClicked_AddAuntEntry)) {
- return true
- } else if (action == #selector(outlineContextMenuItemClicked_Promote)){
- return true
- }
- } else {
- if (action == #selector(outlineContextMenuItemClicked_AddAuntEntry)) {
- return false
- }else if (action == #selector(outlineContextMenuItemClicked_Promote)){
- return false
- }
- }
- }
- return true
- }
- // else
- // if ([menuItem action] == @selector(toggleEncryptFilePanel:)) {
- // [menuItem setTitle:NSLocalizedString(@"Set Passwords", @"Menu item title")];
- // NSURL *fileURL = [self.pdfView.document documentURL];
- // if (!fileURL) {
- // return YES;
- // }
- // PDFDocument *pdfDoc = [[[PDFDocument alloc] initWithURL:fileURL] autorelease];
- //
- // if ([pdfDoc isLocked]) {
- // [menuItem setTitle:NSLocalizedString(@"Remove Security", @"Menu item title")];
- // }
- // } else if (action == @selector(toggleToolbarShow:)) {
- // NSToolbar *toolbar = [self.window toolbar];
- // if ([toolbar isVisible])
- // [menuItem setTitle:NSLocalizedString(@"Hide Toolbar", @"Menu item title")];
- // else
- // [menuItem setTitle:NSLocalizedString(@"Show Toolbar", @"Menu item title")];
- // return YES;
- // } else if (action == @selector(readMode:)) {
- // menuItem.state = self.isReadMode ? NSControlStateValueOn : NSControlStateValueOff;
- // return YES;
- // } else if (action == @selector(addForm:)) {
- // return YES;
- // } else if (action == @selector(toggleOutlineCaseInsensitiveSearch:)){
- // [menuItem setState:self.outlineIgnoreCaseFlag?NSControlStateValueOn:NSControlStateValueOff];
- // return YES;
- // } else if (action == @selector(note_expandAllComments:) ||
- // action == @selector(note_foldAllComments:) ||
- // action == @selector(exportAnnotationNotes:) ||
- // action == @selector(leftSideEmptyAnnotationClick_DeleteAnnotation:) ||
- // action == @selector(removeAllAnnotations:)) {
- // if (@available(macOS 10.13, *)) {
- // if (notes.count == 0) {
- // return NO;
- // } else {
- // return YES;
- // }
- // } else {
- // if (action == @selector(note_expandAllComments:) ||
- // action == @selector(note_foldAllComments:)) {
- // return NO;
- // }
- // }
- // } else
- // if (action == @selector(unfoldNoteAction:) ||
- // action == @selector(foldNoteAction:)) {
- // NSInteger row = [rightSideController.noteOutlineView clickedRow];
- // NSArray *noteArr = [rightSideController.noteArrayController arrangedObjects];
- // PDFAnnotation *foldNote = (PDFAnnotation *)noteArr[row];
- // if (@available(macOS 10.13, *)) {
- // if ([foldNote isKindOfClass:[PDFAnnotationMarkup class]] ||
- // [foldNote isKindOfClass:[SKNPDFAnnotationNote class]]) {
- // return YES;
- // } else {
- // return NO;
- // }
- // } else {
- // return NO;
- // }
- // } else
- if (action == #selector(menuItemClick_ExportPNG) ||
- action == #selector(menuItemClick_ExportJPG) ||
- action == #selector(menuItemClick_ExportPDF)) {
- if (self.snapshotTableView.selectedRow == -1 ) {
- return false
- } else {
- return true
- }
- }
- // else if (action == @selector(editNoteFromTable:)) {
- // NSInteger row = [rightSideController.noteOutlineView clickedRow];
- // NSArray * noteArr = [rightSideController.noteArrayController arrangedObjects];
- // PDFAnnotation *foldNote = (PDFAnnotation *)noteArr[row];
- // if (@available(macOS 10.13, *)) {
- // if ([foldNote.widgetFieldType isEqualToString:PDFAnnotationWidgetSubtypeSignature]) {
- // return NO;
- // }
- // }
- // if ([foldNote isKindOfClass:[PDFAnnotationStamp class]] ||
- // [foldNote isKindOfClass:[KMAnnotationStamp class]]) {
- // return NO;
- // } else {
- // return YES;
- // }
- // }
- else if (action == #selector(menuItemClick_SelectAll)) {
- menuItem.state = self.snapshotListIsAllSelected() ? .on : .off
- return true
- }
- // else if (action == @selector(leftSideEmptyAnnotationClick_DeleteOutline:)) {
- // PDFOutline * item = [[pdfView document] outlineRoot];
- // if (self.isSearchOutlineMode) {
- // NSInteger num = 0;
- // for (NSUInteger i = 0; i < [item numberOfChildren]; i++) {
- // PDFOutline *outline = [item childAtIndex:i];
- // if ([self hasContainString:self.leftSideController.outlineSearchField.stringValue rootOutline:outline]) {
- // num ++;
- // }
- // }
- // if (num > 0)
- // return YES;
- // else
- // return NO;
- // } else {
- // if ([item numberOfChildren] > 0)
- // return YES;
- // else
- // return NO;
- // }
- // }
- return true
- }
- }
- // MARK: - NSPopoverDelegate
- extension KMLeftSideViewController: NSPopoverDelegate {
- func popoverWillClose(_ notification: Notification) {
- guard let popover = notification.object as? NSPopover else {
- return
- }
- if let vc = popover.contentViewController as? KMOutlineEditViewController {
- self.editOutlineUI(vc)
- self.tocOutlineView.reloadData()
- }
- }
- }
|