(waveWindowId: string, tabId: string)
| 302 | |
| 303 | // returns [tabview, initialized] |
| 304 | export async function getOrCreateWebViewForTab(waveWindowId: string, tabId: string): Promise<[WaveTabView, boolean]> { |
| 305 | let tabView = getWaveTabView(tabId); |
| 306 | if (tabView) { |
| 307 | return [tabView, true]; |
| 308 | } |
| 309 | const fullConfig = await RpcApi.GetFullConfigCommand(ElectronWshClient); |
| 310 | tabView = getSpareTab(fullConfig); |
| 311 | tabView.waveWindowId = waveWindowId; |
| 312 | tabView.lastUsedTs = Date.now(); |
| 313 | setWaveTabView(tabId, tabView); |
| 314 | tabView.waveTabId = tabId; |
| 315 | tabView.webContents.on("will-navigate", shNavHandler); |
| 316 | tabView.webContents.on("will-frame-navigate", shFrameNavHandler); |
| 317 | tabView.webContents.on("did-attach-webview", (event, wc) => { |
| 318 | wc.setWindowOpenHandler((details) => { |
| 319 | if (wc == null || wc.isDestroyed() || tabView.webContents == null || tabView.webContents.isDestroyed()) { |
| 320 | return { action: "deny" }; |
| 321 | } |
| 322 | tabView.webContents.send("webview-new-window", wc.id, details); |
| 323 | return { action: "deny" }; |
| 324 | }); |
| 325 | }); |
| 326 | tabView.webContents.on("before-input-event", (e, input) => { |
| 327 | const waveEvent = adaptFromElectronKeyEvent(input); |
| 328 | // console.log("WIN bie", tabView.waveTabId.substring(0, 8), waveEvent.type, waveEvent.code); |
| 329 | handleCtrlShiftState(tabView.webContents, waveEvent); |
| 330 | setWasActive(true); |
| 331 | if (input.type == "keyDown" && tabView.keyboardChordMode) { |
| 332 | e.preventDefault(); |
| 333 | tabView.setKeyboardChordMode(false); |
| 334 | tabView.webContents.send("reinject-key", waveEvent); |
| 335 | return; |
| 336 | } |
| 337 | |
| 338 | if (unamePlatform === "win32" && input.type == "keyDown") { |
| 339 | if (handleWindowsMenuAccelerators(waveEvent, tabView, fullConfig)) { |
| 340 | e.preventDefault(); |
| 341 | return; |
| 342 | } |
| 343 | } |
| 344 | }); |
| 345 | tabView.webContents.setWindowOpenHandler(({ url, frameName }) => { |
| 346 | if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("file://")) { |
| 347 | console.log("openExternal fallback", url); |
| 348 | shell.openExternal(url); |
| 349 | } |
| 350 | console.log("window-open denied", url); |
| 351 | return { action: "deny" }; |
| 352 | }); |
| 353 | tabView.webContents.on("blur", () => { |
| 354 | handleCtrlShiftFocus(tabView.webContents, false); |
| 355 | }); |
| 356 | configureAuthKeyRequestInjection(tabView.webContents.session); |
| 357 | return [tabView, false]; |
| 358 | } |
| 359 | |
| 360 | export function setWaveTabView(waveTabId: string, wcv: WaveTabView): void { |
| 361 | if (waveTabId == null) { |
no test coverage detected