try to load htmlString on mac app

This commit is contained in:
Satindar Dhillon 2022-06-28 17:03:58 -07:00
parent 93d3485e40
commit 43a20abcd5
2 changed files with 18 additions and 15 deletions

View file

@ -149,7 +149,7 @@ import WebKit
}
}()
let fontFamily = fontFamilyValue.flatMap { WebFont(rawValue: $0) } ?? .inter
let fontFamily = fontFamilyValue.flatMap { WebFont(rawValue: $0) } ?? .system
webView.loadHTMLString(
WebReaderContent(
@ -308,22 +308,24 @@ import WebKit
}
}()
let fontFamily = fontFamilyValue.flatMap { WebFont(rawValue: $0) } ?? .inter
let fontFamily = fontFamilyValue.flatMap { WebFont(rawValue: $0) } ?? .system
webView.loadHTMLString(
WebReaderContent(
item: item,
articleContent: articleContent,
isDark: NSApp.effectiveAppearance.name == NSAppearance.Name.darkAqua,
fontSize: fontSize(),
lineHeight: lineHeight(),
maxWidthPercentage: maxWidthPercentage(),
fontFamily: fontFamily,
prefersHighContrastText: prefersHighContrastText
)
.styledContent,
baseURL: ViewsPackage.bundleURL
let htmlString = WebReaderContent(
item: item,
articleContent: articleContent,
isDark: NSApp.effectiveAppearance.name == NSAppearance.Name.darkAqua,
fontSize: fontSize(),
lineHeight: lineHeight(),
maxWidthPercentage: maxWidthPercentage(),
fontFamily: fontFamily,
prefersHighContrastText: prefersHighContrastText
)
.styledContent
// webView.loadFileURL(ViewsPackage.bundleURL, allowingReadAccessTo: ViewsPackage.bundleURL)
// macOS isn't loading the resources at the baseURL here for some reason
// maybe it needs the `allowingReadAccessTo` permission?
webView.loadHTMLString(htmlString, baseURL: ViewsPackage.bundleURL)
}
}

View file

@ -51,6 +51,7 @@ struct WebReaderContent {
</head>
<body>
<div id="root" />
<div>HIIIIII</div>
<div id='_omnivore-htmlContent' style="display: none;">
\(articleContent.htmlContent)
</div>