Properly define webview user data directory

This commit is contained in:
crschnick 2023-12-21 10:50:05 +00:00
parent 09146d1241
commit 8e1665ba27
2 changed files with 4 additions and 0 deletions

View file

@ -1,5 +1,6 @@
package io.xpipe.app.comp.base;
import io.xpipe.app.core.AppProperties;
import io.xpipe.app.core.AppResources;
import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.CompStructure;
@ -47,6 +48,7 @@ public class MarkdownComp extends Comp<CompStructure<StackPane>> {
@SneakyThrows
private WebView createWebView() {
var wv = new WebView();
wv.getEngine().setUserDataDirectory(AppProperties.get().getDataDir().resolve("webview").toFile());
wv.setPageFill(Color.TRANSPARENT);
var theme = AppPrefs.get() != null && AppPrefs.get().theme.getValue().isDark() ? "web/github-markdown-dark.css" : "web/github-markdown-light.css";
var url = AppResources.getResourceURL(AppResources.XPIPE_MODULE, theme)

View file

@ -1,5 +1,6 @@
package io.xpipe.app.fxcomps.impl;
import io.xpipe.app.core.AppProperties;
import io.xpipe.app.fxcomps.CompStructure;
import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.fxcomps.util.SimpleChangeListener;
@ -54,6 +55,7 @@ public class SvgView {
private WebView createWebView() {
var wv = new WebView();
wv.getEngine().setUserDataDirectory(AppProperties.get().getDataDir().resolve("webview").toFile());
// Sometimes a web view might not render when the background is set to transparent, at least according to stack
// overflow
wv.setPageFill(Color.valueOf("#00000001"));