Skip to content
This repository has been archived by the owner on Nov 13, 2020. It is now read-only.

Commit

Permalink
Fix OfflineWebView rules not being applied
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmeuli committed May 16, 2020
1 parent f25d95d commit 645c7d1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion QLPlugin/Views/PreviewVCs/WebPreviewVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class WebPreviewVC: NSViewController, PreviewVC {
withExtension: "css"
)

@IBOutlet private var webView: WKWebView!
@IBOutlet private var webView: OfflineWebView!

required convenience init(
html: String,
Expand Down
11 changes: 4 additions & 7 deletions QLPlugin/Views/Views/OfflineWebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ let blockRules = """

/// `WKWebView` which only allows the loading of local resources
class OfflineWebView: WKWebView {
override init(frame: CGRect, configuration: WKWebViewConfiguration) {
required init?(coder decoder: NSCoder) {
super.init(coder: decoder)

WKContentRuleListStore.default().compileContentRuleList(
forIdentifier: "ContentBlockingRules",
encodedContentRuleList: blockRules
Expand All @@ -47,7 +49,7 @@ class OfflineWebView: WKWebView {
error.localizedDescription
)
} else if let contentRuleList = contentRuleList {
configuration.userContentController.add(contentRuleList)
self.configuration.userContentController.add(contentRuleList)
} else {
os_log(
"Error adding WKWebView content rule list: Content rule list is not defined",
Expand All @@ -56,10 +58,5 @@ class OfflineWebView: WKWebView {
)
}
}
super.init(frame: frame, configuration: configuration)
}

required init?(coder decoder: NSCoder) {
super.init(coder: decoder)
}
}

0 comments on commit 645c7d1

Please sign in to comment.