Skip to content

Commit 3099efd

Browse files
authored
fix pdfs in preview (#3076)
1 parent b62945a commit 3099efd

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

emain/emain-util.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,17 @@ export function shNavHandler(event: Electron.Event<Electron.WebContentsWillNavig
119119
}
120120
}
121121

122+
function frameOrAncestorHasName(frame: Electron.WebFrameMain, name: string): boolean {
123+
let cur: Electron.WebFrameMain = frame;
124+
while (cur != null) {
125+
if (cur.name === name) {
126+
return true;
127+
}
128+
cur = cur.parent;
129+
}
130+
return false;
131+
}
132+
122133
export function shFrameNavHandler(event: Electron.Event<Electron.WebContentsWillFrameNavigateEventParams>) {
123134
if (!event.frame?.parent) {
124135
// only use this handler to process iframe events (non-iframe events go to shNavHandler)
@@ -135,8 +146,9 @@ export function shFrameNavHandler(event: Electron.Event<Electron.WebContentsWill
135146
return;
136147
}
137148
if (
138-
event.frame.name == "pdfview" &&
149+
frameOrAncestorHasName(event.frame, "pdfview") &&
139150
(url.startsWith("blob:file:///") ||
151+
url.startsWith("chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/") ||
140152
url.startsWith(getWebServerEndpoint() + "/wave/stream-file?") ||
141153
url.startsWith(getWebServerEndpoint() + "/wave/stream-file/") ||
142154
url.startsWith(getWebServerEndpoint() + "/wave/stream-local-file?"))
@@ -169,7 +181,7 @@ export function shFrameNavHandler(event: Electron.Event<Electron.WebContentsWill
169181
}
170182
}
171183
event.preventDefault();
172-
console.log("frame navigation canceled");
184+
console.log("frame navigation canceled", event.frame.name, url);
173185
}
174186

175187
function isWindowFullyVisible(bounds: electron.Rectangle): boolean {

0 commit comments

Comments
 (0)