mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Add a menu item to the Debug menu to enable the Web Inspector
Just enables the "Inspect Element" item in a WKWebView's contextual menu at the moment.
This commit is contained in:
@@ -27,6 +27,22 @@ final class DetailWebViewController: NSViewController, WKUIDelegate {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var webInspectorEnabled: Bool {
|
||||
get {
|
||||
if let webView = webView {
|
||||
let val: NSNumber? = webView.configuration.preferences.value(forKey: "developerExtrasEnabled") as? NSNumber
|
||||
return val != nil ? val!.boolValue : false
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
set {
|
||||
if let webView = webView {
|
||||
webView.configuration.preferences.setValue(newValue, forKey: "developerExtrasEnabled")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var waitingForFirstReload = false
|
||||
private let keyboardDelegate = DetailKeyboardDelegate()
|
||||
@@ -87,6 +103,12 @@ final class DetailWebViewController: NSViewController, WKUIDelegate {
|
||||
webView.isHidden = true
|
||||
waitingForFirstReload = true
|
||||
|
||||
webInspectorEnabled = AppDefaults.webInspectorEnabled
|
||||
|
||||
NotificationCenter.default.addObserver(forName: .WebInspectorEnabledDidChange, object: nil, queue: OperationQueue.main) { (notification) in
|
||||
self.webInspectorEnabled = notification.object! as! Bool
|
||||
}
|
||||
|
||||
reloadHTML()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user