|
@@ -700,8 +700,78 @@ extension KMMainViewController {
|
|
self.listView.autoFlow()
|
|
self.listView.autoFlow()
|
|
}
|
|
}
|
|
@objc func shareFromService(sender: NSMenuItem) {
|
|
@objc func shareFromService(sender: NSMenuItem) {
|
|
|
|
+ if ((NSApp.mainWindow?.windowController is KMBrowserWindowController) == false) {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var string = ""
|
|
|
|
+ if let freeTextAnnotation = listView.activeAnnotation as? CPDFFreeTextAnnotation {
|
|
|
|
+ string = freeTextAnnotation.contents ?? ""
|
|
|
|
+ } else if let markupAnnotation = listView.activeAnnotation as? CPDFMarkupAnnotation {
|
|
|
|
+ if let page = markupAnnotation.page {
|
|
|
|
+ if let selection = page.selection(for: markupAnnotation.bounds) {
|
|
|
|
+ string = selection.string()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ string = listView.currentSelection.string()
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ let windowControler = NSApp.mainWindow?.windowController as! KMBrowserWindowController
|
|
|
|
+ let model: CTTabStripModel = windowControler.browser.tabStripModel
|
|
|
|
+ if (model.count() <= 0) {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (model.activeTabContents().isHome) {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ let document: KMMainDocument = model.activeTabContents() as! KMMainDocument
|
|
|
|
+ if string.count > 0 {
|
|
|
|
+ let represent : NSSharingService = sender.representedObject as! NSSharingService
|
|
|
|
+ represent.perform(withItems: [string])
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 有使用付费功能
|
|
|
|
+ Task { @MainActor in
|
|
|
|
+ if await (KMLightMemberManager.manager.canPayFunction() == false) {
|
|
|
|
+ let _ = KMSubscribeWaterMarkWindowController.show(window: NSApp.mainWindow!, isContinue: true) { isSubscribeSuccess, isWaterMarkExport, isClose in
|
|
|
|
+ if (isClose) {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if (isSubscribeSuccess) {
|
|
|
|
+ let represent : NSSharingService = sender.representedObject as! NSSharingService
|
|
|
|
+ represent.perform(withItems: [string])
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if (isWaterMarkExport) {
|
|
|
|
+ let doucumentURL = document.fileURL
|
|
|
|
+ let docDir = NSTemporaryDirectory()
|
|
|
|
+ let documentName : String = doucumentURL!.path.lastPathComponent
|
|
|
|
+ let path = docDir.stringByAppendingPathComponent(documentName)
|
|
|
|
+
|
|
|
|
+ let data = KMTools.saveWatermarkDocument(document: document.mainViewController!.document!, to: URL(fileURLWithPath: path), secureOptions: document.mainViewController!.secureOptions, removePWD: document.mainViewController!.removeSecureFlag)
|
|
|
|
+ let writeSuccess = data != nil
|
|
|
|
+ if writeSuccess == false {
|
|
|
|
+ __NSBeep()
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ let represent : NSSharingService = sender.representedObject as! NSSharingService
|
|
|
|
+ represent.perform(withItems: [string])
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ let represent : NSSharingService = sender.representedObject as! NSSharingService
|
|
|
|
+ represent.perform(withItems: [string])
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
@objc func cutAction(sender: NSMenuItem) {
|
|
@objc func cutAction(sender: NSMenuItem) {
|
|
|
|
|
|
}
|
|
}
|