-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RegistryPreview] Adopt Monaco Editor (#35122)
- Loading branch information
1 parent
b0be69a
commit f9127b6
Showing
135 changed files
with
455 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Include Monaco Editor source code --> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup> | ||
<None Include="$(MSBuildThisFileDirectory)\Monaco\customTokenColors.js"> | ||
<Link>Assets\Monaco\customTokenColors.js</Link> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Include="$(MSBuildThisFileDirectory)\Monaco\monacoSpecialLanguages.js"> | ||
<Link>Assets\Monaco\monacoSpecialLanguages.js</Link> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Include="$(MSBuildThisFileDirectory)\Monaco\index.html"> | ||
<Link>Assets\Monaco\index.html</Link> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Include="$(MSBuildThisFileDirectory)\Monaco\monaco_languages.json"> | ||
<Link>Assets\Monaco\monaco_languages.json</Link> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Include="$(MSBuildThisFileDirectory)\Monaco\monacoSRC\**"> | ||
<Link>Assets\Monaco\monacoSRC\%(RecursiveDir)%(FileName)%(Extension)</Link> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Include="$(MSBuildThisFileDirectory)\Monaco\customLanguages\**"> | ||
<Link>Assets\Monaco\customLanguages\%(RecursiveDir)%(FileName)%(Extension)</Link> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
</Project> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/modules/registrypreview/RegistryPreviewUILib/Assets/RegistryPreview/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<!doctype HTML> | ||
<html> | ||
<head> | ||
<!-- Set browser to Edge--> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<!-- Set charset --> | ||
<meta charset="utf-8" /> | ||
<!-- Title (normally not displayed)--> | ||
<title>Registry Preview Editor</title> | ||
<style> | ||
/* Fits content to window size */ | ||
html, body { | ||
padding: 0; | ||
} | ||
|
||
#container, .monaco-editor { | ||
position: fixed; | ||
height: 100%; | ||
left: 0; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
} | ||
|
||
.overflowingContentWidgets { | ||
/*Hides alert box */ | ||
display: none !important | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<!-- Container for the editor --> | ||
<div id="container"></div> | ||
<!-- Script --> | ||
<script src="http://PowerToysLocalMonaco/monacoSRC/min/vs/loader.js"></script> | ||
<script type="module"> | ||
import { registerAdditionalLanguages } from 'http://PowerToysLocalMonaco/monacoSpecialLanguages.js'; | ||
import { customTokenColors } from 'http://PowerToysLocalMonaco/customTokenColors.js'; | ||
require.config({ paths: { vs: 'http://PowerToysLocalMonaco/monacoSRC/min/vs' } }); | ||
require(['vs/editor/editor.main'], async function () { | ||
await registerAdditionalLanguages(monaco) | ||
|
||
const editor = monaco.editor.create(document.getElementById('container'), { | ||
automaticLayout: true, | ||
language: 'reg', | ||
minimap: { enabled: false }, | ||
}); | ||
|
||
window.onresize = () => { | ||
editor.layout(); | ||
}; | ||
|
||
editor.getModel().onDidChangeContent((event) => { | ||
window.chrome.webview.postMessage({ 'id': 'contentChanged', 'content': editor.getValue() }); | ||
}); | ||
|
||
editor.focus(); | ||
|
||
window.editor = editor; | ||
}); | ||
</script> | ||
</body> | ||
</html> |
35 changes: 35 additions & 0 deletions
35
src/modules/registrypreview/RegistryPreviewUILib/MonacoEditorControl.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<UserControl | ||
x:Class="RegistryPreviewUILib.MonacoEditorControl" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:controls="using:Microsoft.UI.Xaml.Controls" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="using:RegistryPreviewUILib" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:tkconverters="using:CommunityToolkit.WinUI.Converters" | ||
mc:Ignorable="d"> | ||
|
||
<UserControl.Resources> | ||
<tkconverters:BoolToVisibilityConverter | ||
x:Key="BoolToInvertedVisibilityConverter" | ||
FalseValue="Visible" | ||
TrueValue="Collapsed" /> | ||
</UserControl.Resources> | ||
|
||
<Grid> | ||
<ProgressRing | ||
Width="48" | ||
Height="48" | ||
Visibility="{x:Bind IsLoading, Mode=OneWay}" /> | ||
<Border | ||
BorderBrush="{ThemeResource SurfaceStrokeColorDefaultBrush}" | ||
BorderThickness="1" | ||
Visibility="{x:Bind IsLoading, Mode=OneWay, Converter={StaticResource BoolToInvertedVisibilityConverter}}"> | ||
<controls:WebView2 | ||
x:Name="Browser" | ||
HorizontalAlignment="Stretch" | ||
VerticalAlignment="Stretch" | ||
Loaded="Browser_Loaded" /> | ||
</Border> | ||
</Grid> | ||
</UserControl> |
Oops, something went wrong.