diff --git a/apps/client/src/widgets/type_widgets/WebView.tsx b/apps/client/src/widgets/type_widgets/WebView.tsx
index dd3ab43c9e..b624a62800 100644
--- a/apps/client/src/widgets/type_widgets/WebView.tsx
+++ b/apps/client/src/widgets/type_widgets/WebView.tsx
@@ -1,7 +1,8 @@
import "./WebView.css";
-import { useCallback, useState } from "preact/hooks";
+import { useCallback, useEffect, useRef, useState } from "preact/hooks";
+import appContext from "../../components/app_context";
import FNote from "../../entities/fnote";
import attributes from "../../services/attributes";
import { t } from "../../services/i18n";
@@ -17,7 +18,7 @@ import { TypeWidgetProps } from "./type_widget";
const isElectron = utils.isElectron();
const HELP_PAGE = "1vHRoWCEjj0L";
-export default function WebView({ note }: TypeWidgetProps) {
+export default function WebView({ note, ntxId }: TypeWidgetProps) {
const [ webViewSrc ] = useNoteLabel(note, "webViewSrc");
const [ disabledWebViewSrc ] = useNoteLabel(note, "disabled:webViewSrc");
@@ -29,15 +30,36 @@ export default function WebView({ note }: TypeWidgetProps) {
return ;
}
- return ;
+ return isElectron
+ ?
+ : ;
}
-function WebViewContent({ src }: { src: string }) {
- if (!isElectron) {
- return ;
- }
+function DesktopWebView({ src }: { src: string }) {
return ;
+}
+function BrowserWebView({ src, ntxId }: { src: string, ntxId: string | null | undefined }) {
+ const iframeRef = useRef(null);
+
+ useEffect(() => {
+ function onBlur() {
+ if (document.activeElement === iframeRef.current && ntxId) {
+ appContext.tabManager.activateNoteContext(ntxId);
+ }
+ }
+
+ window.addEventListener("blur", onBlur);
+ return () => {
+ window.removeEventListener("blur", onBlur);
+ };
+ }, [ ntxId ]);
+
+ return ;
}
function SetupWebView({note}: {note: FNote}) {