|
@@ -761,32 +761,33 @@ extension KMHomeViewController {
|
|
}
|
|
}
|
|
|
|
|
|
func openBlankPage() {
|
|
func openBlankPage() {
|
|
- let fileName: NSString = String(format: "%@.pdf", NSLocalizedString("Untitled", comment: "")) as NSString
|
|
|
|
- let savePath = fetchUniquePath(fileName.kUrlToPDFFolderPath() as String)
|
|
|
|
- let filePath = savePath.deletingLastPathComponent
|
|
|
|
- if FileManager.default.fileExists(atPath: filePath) == false {
|
|
|
|
- try?FileManager.default.createDirectory(atPath: filePath, withIntermediateDirectories: false)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- let pdfDocument = CPDFDocument()
|
|
|
|
- pdfDocument?.insertPage(CGSize(width: 595, height: 842), at: 0)
|
|
|
|
- pdfDocument?.write(to: URL(fileURLWithPath: savePath))
|
|
|
|
- let controll: KMBrowserWindowController? = self.view.window?.windowController as? KMBrowserWindowController
|
|
|
|
- if controll?.browser?.tabCount() ?? 0 > 1 && KMPreference.shared.openDocumentType == .newWindow{
|
|
|
|
- self.reopenDocument(forPaths: URL(fileURLWithPath: savePath))
|
|
|
|
- }else {
|
|
|
|
- NSDocumentController.shared.openDocument(withContentsOf: URL(fileURLWithPath: savePath), display: true) { document, documentWasAlreadyOpen, error in
|
|
|
|
- if error != nil {
|
|
|
|
- NSApp.presentError(error!)
|
|
|
|
- } else {
|
|
|
|
- if document is KMMainDocument {
|
|
|
|
- let newDocument = document
|
|
|
|
- (newDocument as! KMMainDocument).isNewCreated = true
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // self.homeContentView?.reloadData()
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+// let fileName: NSString = String(format: "%@.pdf", NSLocalizedString("Untitled", comment: "")) as NSString
|
|
|
|
+// let savePath = fetchUniquePath(fileName.kUrlToPDFFolderPath() as String)
|
|
|
|
+// let filePath = savePath.deletingLastPathComponent
|
|
|
|
+// if FileManager.default.fileExists(atPath: filePath) == false {
|
|
|
|
+// try?FileManager.default.createDirectory(atPath: filePath, withIntermediateDirectories: false)
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// let pdfDocument = CPDFDocument()
|
|
|
|
+// pdfDocument?.insertPage(CGSize(width: 595, height: 842), at: 0)
|
|
|
|
+// pdfDocument?.write(to: URL(fileURLWithPath: savePath))
|
|
|
|
+// let controll: KMBrowserWindowController? = self.view.window?.windowController as? KMBrowserWindowController
|
|
|
|
+// if controll?.browser?.tabCount() ?? 0 > 1 && KMPreference.shared.openDocumentType == .newWindow{
|
|
|
|
+// self.reopenDocument(forPaths: URL(fileURLWithPath: savePath))
|
|
|
|
+// }else {
|
|
|
|
+// NSDocumentController.shared.openDocument(withContentsOf: URL(fileURLWithPath: savePath), display: true) { document, documentWasAlreadyOpen, error in
|
|
|
|
+// if error != nil {
|
|
|
|
+// NSApp.presentError(error!)
|
|
|
|
+// } else {
|
|
|
|
+// if document is KMMainDocument {
|
|
|
|
+// let newDocument = document
|
|
|
|
+// (newDocument as! KMMainDocument).isNewCreated = true
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// // self.homeContentView?.reloadData()
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+ NSApplication.newBlankDocument()
|
|
}
|
|
}
|
|
|
|
|
|
func importFromWebPage() {
|
|
func importFromWebPage() {
|