mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
[Peek][Monaco Preview] Open Monaco URI in default browser (#27774)
* open Monaco URI in default browser * added dialog when URI is opened
This commit is contained in:
committed by
GitHub
parent
a46b80c76f
commit
7c7f6cabf7
@@ -157,6 +157,7 @@ namespace Microsoft.PowerToys.PreviewHandler.Monaco
|
||||
_webView.NavigationCompleted += WebView2Init;
|
||||
_webView.Height = this.Height;
|
||||
_webView.Width = this.Width;
|
||||
_webView.CoreWebView2.NewWindowRequested += CoreWebView2_NewWindowRequested;
|
||||
Controls.Add(_webView);
|
||||
_webView.SendToBack();
|
||||
_loadingBar.Value = 100;
|
||||
@@ -218,6 +219,16 @@ namespace Microsoft.PowerToys.PreviewHandler.Monaco
|
||||
}
|
||||
}
|
||||
|
||||
private async void CoreWebView2_NewWindowRequested(object sender, CoreWebView2NewWindowRequestedEventArgs e)
|
||||
{
|
||||
// Monaco opens URI in a new window. We open the URI in the default web browser.
|
||||
if (e.Uri != null && e.IsUserInitiated)
|
||||
{
|
||||
e.Handled = true;
|
||||
await Launcher.LaunchUriAsync(new Uri(e.Uri));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This event sets the height and width of the webview to the size of the form
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user