Skip to content

Commit

Permalink
feat: add reload event
Browse files Browse the repository at this point in the history
work on issue #22
  • Loading branch information
bsorrentino committed Aug 21, 2023
1 parent 4c08bec commit 10dd331
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 0 additions & 1 deletion PlantUMLEditor/Sources/CodeViewer/CodeWebView+Mode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ extension CodeWebView {
case php_laravel_blade = "php_laravel_blade"
case pig = "pig"
case plain_text = "plain_text"
case plantuml = "plantuml"
case powershell = "powershell"
case praat = "praat"
case prisma = "prisma"
Expand Down
10 changes: 9 additions & 1 deletion PlantUMLEditor/Sources/CodeViewer/CodeWebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import WebKit
import Combine

#if os(OSX)
import AppKit
Expand Down Expand Up @@ -63,7 +64,8 @@ public class CodeWebView: CustomView {
private var pageLoaded = false
private var pendingFunctions = [JavascriptFunction]()


private var reloadCancellation:Cancellable?

var navigationDelegate:WKNavigationDelegate? {
get {
return webview.navigationDelegate
Expand Down Expand Up @@ -145,6 +147,12 @@ public class CodeWebView: CustomView {
extension CodeWebView {

private func initWebView() {

reloadCancellation = NotificationCenter.default.publisher(for: NSNotification.Name("reload"))
.sink(receiveValue: { [unowned self] _ in
webview.reloadFromOrigin()
})

webview.translatesAutoresizingMaskIntoConstraints = false
addSubview(webview)
webview.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
Expand Down

0 comments on commit 10dd331

Please sign in to comment.