|
@@ -1191,18 +1191,19 @@ class KMPDFEditViewController: KMPDFThumbViewBaseController {
|
|
|
openPanel.beginSheetModal(for: NSWindow.currentWindow()) { [self] (result) in
|
|
|
if result == NSApplication.ModalResponse.OK {
|
|
|
if let fileURL = openPanel.urls.first {
|
|
|
- self.choosePositionWindow {[weak self] index in
|
|
|
- /// 插入位置
|
|
|
+// self.choosePositionWindow {[weak self] index in
|
|
|
+// /// 插入位置
|
|
|
if let imag = NSImage(contentsOfFile: fileURL.path ) {
|
|
|
+ let index = self.getInsertIndex()
|
|
|
let document = CPDFDocument()
|
|
|
_ = document?.km_insertPage(imag.size, withImage: fileURL.path , at: 0)
|
|
|
if let page: CPDFPage = (document?.page(at: 0)) {
|
|
|
- self?.insertPages(pages: [page], at: IndexSet(integer: index))
|
|
|
+ self.insertPages(pages: [page], at: IndexSet(integer: index))
|
|
|
}
|
|
|
let ips: Set<IndexPath> = [IndexPath(item: index, section: 0)]
|
|
|
- self?.thumbnailView.collectionView.scrollToItems(at: ips, scrollPosition: .centeredVertically)
|
|
|
+ self.thumbnailView.collectionView.scrollToItems(at: ips, scrollPosition: .centeredVertically)
|
|
|
}
|
|
|
- }
|
|
|
+// }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1229,18 +1230,19 @@ class KMPDFEditViewController: KMPDFThumbViewBaseController {
|
|
|
}
|
|
|
|
|
|
@objc func item_insertFromClipboard(sender: NSMenuItem?) {
|
|
|
- self.choosePositionWindow {[weak self] index in
|
|
|
+// self.choosePositionWindow {[weak self] index in
|
|
|
/// 插入位置
|
|
|
var error: NSError?
|
|
|
- guard let document: CPDFDocument = self?.openDocumentWithImageFromPasteboard(NSPasteboard.general, error: &error) else {
|
|
|
+ guard let document: CPDFDocument = self.openDocumentWithImageFromPasteboard(NSPasteboard.general, error: &error) else {
|
|
|
return
|
|
|
}
|
|
|
+ let index = self.getInsertIndex()
|
|
|
if let page: CPDFPage = (document.page(at: 0)) {
|
|
|
- self?.insertPages(pages: [page], at: IndexSet(integer: index))
|
|
|
+ self.insertPages(pages: [page], at: IndexSet(integer: index))
|
|
|
}
|
|
|
let ips: Set<IndexPath> = [IndexPath(item: index, section: 0)]
|
|
|
- self?.thumbnailView.collectionView.scrollToItems(at: ips, scrollPosition: .centeredVertically)
|
|
|
- }
|
|
|
+ self.thumbnailView.collectionView.scrollToItems(at: ips, scrollPosition: .centeredVertically)
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
func openDocumentWithImageFromPasteboard(_ pboard: NSPasteboard, error outError: AutoreleasingUnsafeMutablePointer<NSError?>?) -> CPDFDocument? {
|
|
@@ -1292,18 +1294,20 @@ class KMPDFEditViewController: KMPDFThumbViewBaseController {
|
|
|
let vc = KMDeviceBrowserWindowController.shared
|
|
|
vc.type = .scanner
|
|
|
vc.importScannerFileCallback = { [weak self](url: NSURL) -> Void in
|
|
|
- self?.choosePositionWindow {[weak self] index in
|
|
|
+// self?.choosePositionWindow {[weak self] index in
|
|
|
/// 插入位置
|
|
|
if let imag = NSImage(contentsOfFile: url.path! ) {
|
|
|
+ let index = self?.getInsertIndex()
|
|
|
let document = CPDFDocument()
|
|
|
_ = document?.km_insertPage(imag.size, withImage: url.path! , at: 0)
|
|
|
if let page: CPDFPage = (document?.page(at: 0)) {
|
|
|
- self?.insertPages(pages: [page], at: IndexSet(integer: index))
|
|
|
+ self?.insertPages(pages: [page], at: IndexSet(integer: index!))
|
|
|
}
|
|
|
- let ips: Set<IndexPath> = [IndexPath(item: index, section: 0)]
|
|
|
+ let ips: Set<IndexPath> = [IndexPath(item: index!, section: 0)]
|
|
|
self?.thumbnailView.collectionView.scrollToItems(at: ips, scrollPosition: .centeredVertically)
|
|
|
}
|
|
|
- }
|
|
|
+// }
|
|
|
+ vc.close()
|
|
|
}
|
|
|
vc.showWindow(NSApp.mainWindow)
|
|
|
}
|