|
@@ -127,6 +127,10 @@ import KMComponentLibrary
|
|
|
if annotations.count == 0 {
|
|
|
emptyContendView.isHidden = false
|
|
|
|
|
|
+ linkWebView.clearData()
|
|
|
+
|
|
|
+ linkEmailView.clearData()
|
|
|
+
|
|
|
} else if annotations.count == 1 {
|
|
|
|
|
|
current_Annotation = annotations.first
|
|
@@ -207,24 +211,8 @@ import KMComponentLibrary
|
|
|
linkPageView.reloadData()
|
|
|
} else if pdfLinkType == .Web {
|
|
|
linkWebView.isHidden = false
|
|
|
- linkWebView.annotation = current_Annotation
|
|
|
-
|
|
|
- if let url = current_Annotation?.url() {
|
|
|
- if url.hasPrefix("mailto:") == true {
|
|
|
- linkWebView.inputTextarea.properties.text = ""
|
|
|
- linkWebView.inputTextarea.reloadData()
|
|
|
- }
|
|
|
- }
|
|
|
} else if pdfLinkType == .Email {
|
|
|
linkEmailView.isHidden = false
|
|
|
- linkEmailView.annotation = current_Annotation
|
|
|
-
|
|
|
- if let url = current_Annotation?.url() {
|
|
|
- if url.hasPrefix("mailto:") == false {
|
|
|
- linkEmailView.inputTextarea.properties.text = ""
|
|
|
- linkEmailView.inputTextarea.reloadData()
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -240,20 +228,36 @@ import KMComponentLibrary
|
|
|
//MARK: - ComponentTabsDelegate
|
|
|
extension KMLinkViewController: ComponentTabsDelegate {
|
|
|
public func componentTabsDidSelected(_ view: ComponentTabs, _ property: ComponentTabsProperty) {
|
|
|
- if property == pageProperty {
|
|
|
- pdfLinkType = .Page
|
|
|
- } else if property == webProperty {
|
|
|
- pdfLinkType = .Web
|
|
|
- } else if property == emailProperty {
|
|
|
- pdfLinkType = .Email
|
|
|
- }
|
|
|
-
|
|
|
if let annotation = current_Annotation {
|
|
|
+ if property == pageProperty {
|
|
|
+ pdfLinkType = .Page
|
|
|
+ annotation.setURL(nil)
|
|
|
+
|
|
|
+ if let page = pdfView?.document.page(at: UInt(linkPageView.choosedIndex-1)) {
|
|
|
+ let bounds = page.bounds(for: .cropBox)
|
|
|
+ let destination = CPDFDestination(page: page, at: NSPoint(x: 0, y: bounds.size.height))
|
|
|
+ annotation.setDestination(destination)
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if property == webProperty {
|
|
|
+ pdfLinkType = .Web
|
|
|
+ annotation.setDestination(nil)
|
|
|
+
|
|
|
+ let linkUrlPath = KMNTools.judgeWebURL(linkWebView.inputTextarea.properties.text)
|
|
|
+ annotation.setURL(linkUrlPath)
|
|
|
+
|
|
|
+ } else if property == emailProperty {
|
|
|
+ pdfLinkType = .Email
|
|
|
+ annotation.setDestination(nil)
|
|
|
+
|
|
|
+ let linkUrlPath = KMNTools.judgeEmailURL(linkEmailView.inputTextarea.properties.text)
|
|
|
+ annotation.setURL(linkUrlPath)
|
|
|
+ }
|
|
|
+
|
|
|
pdfLinkTypeChanged()
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
CPDFLinkAnnotation.updateDefault_AddLinkType(pdfLinkType.rawValue)
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -264,23 +268,6 @@ extension KMLinkViewController: KMLinkPageViewDelegate {
|
|
|
pdfView?.go(toPageIndex: pageIndex-1, animated: false)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- func kmLinkPageViewDidChangeDestination(_ view: KMLinkPageView, _ pageIndex: Int) {
|
|
|
- guard let activiteAnno = current_Annotation else {
|
|
|
- return
|
|
|
- }
|
|
|
- activiteAnno.setURL(nil)
|
|
|
-
|
|
|
- if let page = pdfView?.document.page(at: UInt(pageIndex-1)) {
|
|
|
- let bounds = page.bounds(for: .cropBox)
|
|
|
- let destination = CPDFDestination(page: page, at: NSPoint(x: 0, y: bounds.size.height))
|
|
|
- activiteAnno.setDestination(destination)
|
|
|
- }
|
|
|
-
|
|
|
- if let _ = pdfView?.document.page(at: UInt(pageIndex-1)) {
|
|
|
- pdfView?.go(toPageIndex: pageIndex-1, animated: false)
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
//MARK: - KMLinkPageViewDelegate
|
|
@@ -289,10 +276,6 @@ extension KMLinkViewController: KMLinkWebViewDelegate {
|
|
|
guard let activeAnnotation = current_Annotation else {
|
|
|
return
|
|
|
}
|
|
|
- activeAnnotation.setDestination(nil)
|
|
|
-
|
|
|
- let linkUrlPath = KMNTools.judgeWebURL(webString)
|
|
|
- activeAnnotation.setURL(linkUrlPath)
|
|
|
|
|
|
if let url = activeAnnotation.url() {
|
|
|
if let data = URL(string: url) {
|
|
@@ -317,10 +300,6 @@ extension KMLinkViewController: KMLinkEmailViewDelegate {
|
|
|
alert.runModal()
|
|
|
return
|
|
|
}
|
|
|
- activeAnnotation.setDestination(nil)
|
|
|
-
|
|
|
- let linkUrlPath = KMNTools.judgeEmailURL(emailString)
|
|
|
- activeAnnotation.setURL(linkUrlPath)
|
|
|
|
|
|
if let url = activeAnnotation.url() {
|
|
|
NSWorkspace.shared.open(URL(string: url)!)
|