|
@@ -593,8 +593,8 @@ class KMNPopOperationWindowController: KMNBaseWindowController {
|
|
|
@IBOutlet var urlInput: ComponentInput!
|
|
|
@IBOutlet weak var backUrlWidthConstraint: NSLayoutConstraint!
|
|
|
|
|
|
- var fontPopover:NSPopover?
|
|
|
- var ObjectPopover:NSPopover?
|
|
|
+ private var fontPopover:NSPopover?
|
|
|
+ private var ObjectPopover:NSPopover?
|
|
|
|
|
|
weak var listView:CPDFListView? {
|
|
|
didSet {
|
|
@@ -794,6 +794,21 @@ class KMNPopOperationWindowController: KMNBaseWindowController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public func closeWindow(listView:CPDFListView?) {
|
|
|
+ if self.window?.isVisible == true {
|
|
|
+ listView?.window?.removeChildWindow(self.window ?? NSWindow())
|
|
|
+ self.window?.close()
|
|
|
+ }
|
|
|
+
|
|
|
+ if ObjectPopover?.isShown == true {
|
|
|
+ ObjectPopover?.close()
|
|
|
+ }
|
|
|
+
|
|
|
+ if fontPopover?.isShown == true {
|
|
|
+ fontPopover?.close()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//MARK: - private
|
|
|
private func congfigGeneraPopUI() {
|
|
|
var colors = KMAnnotationPropertiesColorManager.manager.markHighlightColors
|
|
@@ -1054,41 +1069,31 @@ class KMNPopOperationWindowController: KMNBaseWindowController {
|
|
|
|
|
|
@objc func linkGoButtonClicked(_ sender: NSView) {
|
|
|
if linkType == .url {
|
|
|
- let webString = urlInput.properties.text
|
|
|
- linkAnnotation.setDestination(nil)
|
|
|
-
|
|
|
- let linkUrlPath = KMNTools.judgeWebURL(webString)
|
|
|
- linkAnnotation.setURL(linkUrlPath)
|
|
|
- updatePDFViewCallback?()
|
|
|
-
|
|
|
- if let data = URL(string: linkUrlPath) {
|
|
|
+ guard let webString = linkAnnotation.url() else { return }
|
|
|
+ if let data = URL(string: webString) {
|
|
|
NSWorkspace.shared.open(data)
|
|
|
}
|
|
|
} else if linkType == .email {
|
|
|
- let emailString = urlInput.properties.text
|
|
|
-
|
|
|
- if !KMNTools.isValidateEmail(emailString) {
|
|
|
+ guard let emailString = linkAnnotation.url() else {
|
|
|
let alert = NSAlert()
|
|
|
alert.alertStyle = .critical
|
|
|
alert.messageText = NSLocalizedString("Invalid Email. Please try again.", comment: "")
|
|
|
alert.runModal()
|
|
|
return
|
|
|
}
|
|
|
- linkAnnotation.setDestination(nil)
|
|
|
-
|
|
|
- let linkUrlPath = KMNTools.judgeEmailURL(emailString)
|
|
|
- linkAnnotation.setURL(linkUrlPath)
|
|
|
- updatePDFViewCallback?()
|
|
|
-
|
|
|
- NSWorkspace.shared.open(URL(string: linkUrlPath)!)
|
|
|
+ if KMNTools.isValidateEmail(emailString) {
|
|
|
+ let alert = NSAlert()
|
|
|
+ alert.alertStyle = .critical
|
|
|
+ alert.messageText = NSLocalizedString("Invalid Email. Please try again.", comment: "")
|
|
|
+ alert.runModal()
|
|
|
+ } else {
|
|
|
+ NSWorkspace.shared.open(URL(string: emailString)!)
|
|
|
+ }
|
|
|
} else if linkType == .page {
|
|
|
- linkAnnotation.setURL(nil)
|
|
|
-
|
|
|
- let destination = CPDFDestination(document: listView?.document ?? CPDFDocument(), pageIndex: Int(paginationView.properties.currentIndex - 1))
|
|
|
- linkAnnotation.setDestination(destination)
|
|
|
- updatePDFViewCallback?()
|
|
|
-
|
|
|
- listView?.go(to: destination)
|
|
|
+ if let destination = linkAnnotation.destination() {
|
|
|
+ listView?.go(to: destination)
|
|
|
+ closeWindow(listView: listView)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1166,6 +1171,24 @@ extension KMNPopOperationWindowController: ComponentInputDelegate {
|
|
|
} else if (inputView == gropNameInput) {
|
|
|
|
|
|
} else if (inputView == urlInput) {
|
|
|
+ if linkType == .email {
|
|
|
+ let emailString = urlInput.properties.text
|
|
|
+ if KMNTools.isValidateEmail(emailString) {
|
|
|
+ linkAnnotation.setDestination(nil)
|
|
|
+
|
|
|
+ let linkUrlPath = KMNTools.judgeEmailURL(emailString)
|
|
|
+ linkAnnotation.setURL(linkUrlPath)
|
|
|
+ updatePDFViewCallback?()
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if linkType == .url {
|
|
|
+ let webString = urlInput.properties.text
|
|
|
+ linkAnnotation.setDestination(nil)
|
|
|
+
|
|
|
+ let linkUrlPath = KMNTools.judgeWebURL(webString)
|
|
|
+ linkAnnotation.setURL(linkUrlPath)
|
|
|
+ updatePDFViewCallback?()
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -1212,8 +1235,15 @@ extension KMNPopOperationWindowController: ComponentPaginationDelegate {
|
|
|
public func componentPaginationDidValueChanged(pagination: ComponentPagination) {
|
|
|
let pageIndex = pagination.properties.currentIndex
|
|
|
if let page = listView?.document.page(at: UInt(pageIndex)) {
|
|
|
+
|
|
|
+ linkAnnotation.setURL(nil)
|
|
|
+
|
|
|
+ let destination = CPDFDestination(document: listView?.document ?? CPDFDocument(), pageIndex: Int(paginationView.properties.currentIndex - 1))
|
|
|
+ linkAnnotation.setDestination(destination)
|
|
|
+
|
|
|
refreshPageThum()
|
|
|
reloadPageUrlData()
|
|
|
+ updatePDFViewCallback?()
|
|
|
}
|
|
|
}
|
|
|
}
|