diff --git a/Mac/Base.lproj/Main.storyboard b/Mac/Base.lproj/Main.storyboard index f98f71c9..c8d938d3 100644 --- a/Mac/Base.lproj/Main.storyboard +++ b/Mac/Base.lproj/Main.storyboard @@ -1775,10 +1775,10 @@ CA - + - + @@ -1787,10 +1787,10 @@ CA - + - + diff --git a/Mac/View/MPreviewView.swift b/Mac/View/MPreviewView.swift index 7a22c457..5e9ab426 100644 --- a/Mac/View/MPreviewView.swift +++ b/Mac/View/MPreviewView.swift @@ -72,7 +72,8 @@ class MPreviewView: WKWebView, WKUIDelegate, WKNavigationDelegate { menuItem.identifier?.rawValue == "WKMenuItemIdentifierTranslate" || menuItem.identifier?.rawValue == "WKMenuItemIdentifierSearchWeb" || menuItem.identifier?.rawValue == "WKMenuItemIdentifierShareMenu" || - menuItem.identifier?.rawValue == "WKMenuItemIdentifierLookUp" { + menuItem.identifier?.rawValue == "WKMenuItemIdentifierLookUp" + { menuItem.isHidden = true } } @@ -550,7 +551,8 @@ class MPreviewView: WKWebView, WKUIDelegate, WKNavigationDelegate { class HandlerCheckbox: NSObject, WKScriptMessageHandler { func userContentController(_ userContentController: WKUserContentController, - didReceive message: WKScriptMessage) { + didReceive message: WKScriptMessage) + { guard let position = message.body as? String else { return } guard let note = EditTextView.note else { return } @@ -590,7 +592,8 @@ class HandlerCodeCopy: NSObject, WKScriptMessageHandler { } func userContentController(_ userContentController: WKUserContentController, - didReceive message: WKScriptMessage) { + didReceive message: WKScriptMessage) + { let message = (message.body as! String).trimmingCharacters(in: .whitespacesAndNewlines) HandlerCodeCopy.selectionString = message @@ -601,7 +604,8 @@ class HandlerSelection: NSObject, WKScriptMessageHandler { public static var selectionString: String? func userContentController(_ userContentController: WKUserContentController, - didReceive message: WKScriptMessage) { + didReceive message: WKScriptMessage) + { let message = (message.body as! String).trimmingCharacters(in: .whitespacesAndNewlines) HandlerSelection.selectionString = message @@ -611,7 +615,8 @@ class HandlerSelection: NSObject, WKScriptMessageHandler { // 用于解决ppt模式下背景颜色变化左侧边框颜色的适配 class HandlerRevealBackgroundColor: NSObject, WKScriptMessageHandler { func userContentController(_ userContentController: WKUserContentController, - didReceive message: WKScriptMessage) { + didReceive message: WKScriptMessage) + { guard let vc = ViewController.shared() else { return } let message = (message.body as! String).trimmingCharacters(in: .whitespacesAndNewlines) if message == "" { diff --git a/Mac/View/MarkdownView.swift b/Mac/View/MarkdownView.swift index 9b591874..32af9c21 100644 --- a/Mac/View/MarkdownView.swift +++ b/Mac/View/MarkdownView.swift @@ -70,7 +70,9 @@ open class MarkdownView: WKWebView { return "html {font-size: \(UserDefaultsManagement.presentationFontSize)px} :root { --text-font: \(UserDefaultsManagement.previewFontName), sans-serif; --code-text-font: \(codeFontName),sans-serif; } #write { max-width: 100%;}" } else { let paddingStyle = UserDefaultsManagement.isOnExport ? " padding-top: 24px" : "" - return "html {font-size: \(UserDefaultsManagement.previewFontSize)px; \(paddingStyle)} :root { --text-font: \(UserDefaultsManagement.previewFontName), sans-serif; --code-text-font: \(codeFontName),sans-serif; } #write { max-width: \(UserDefaultsManagement.previewWidth);}" + let writeCSS = UserDefaultsManagement.isOnExportHtml ? " max-width: 800px; margin: 0 auto" : "max-width: \(UserDefaultsManagement.previewWidth);" + + return "html {font-size: \(UserDefaultsManagement.previewFontSize)px; \(paddingStyle)} :root { --text-font: \(UserDefaultsManagement.previewFontName), sans-serif; --code-text-font: \(codeFontName),sans-serif; } #write { \(writeCSS)}" } } @@ -239,7 +241,8 @@ extension MarkdownView: WKNavigationDelegate { class HandlerCopyCode: NSObject, WKScriptMessageHandler { func userContentController(_ userContentController: WKUserContentController, - didReceive message: WKScriptMessage) { + didReceive message: WKScriptMessage) + { let message = (message.body as! String).trimmingCharacters(in: .whitespacesAndNewlines) let pasteboard = NSPasteboard.general pasteboard.declareTypes([NSPasteboard.PasteboardType.string], owner: nil) @@ -249,14 +252,16 @@ class HandlerCopyCode: NSObject, WKScriptMessageHandler { class HandlerMouseOver: NSObject, WKScriptMessageHandler { func userContentController(_ userContentController: WKUserContentController, - didReceive message: WKScriptMessage) { + didReceive message: WKScriptMessage) + { NSCursor.pointingHand.set() } } class HandlerMouseOut: NSObject, WKScriptMessageHandler { func userContentController(_ userContentController: WKUserContentController, - didReceive message: WKScriptMessage) { + didReceive message: WKScriptMessage) + { NSCursor.arrow.set() } }