[Preview]Adding new filetypes for developer file preview (#17183)

* push

* push

* push

* Adressed comments and adjusted a thing

* Added xslt

* push

* push. Ready to review

* Spellcheck adjustments

* Add installer stuff

* Changed reg and removed xsl

Co-authored-by: htcfreek <61519853+htcfreek@users.noreply.github.com>

* Fixed tab

* Updated monaco_languages.json

Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
Co-authored-by: htcfreek <61519853+htcfreek@users.noreply.github.com>
This commit is contained in:
Aaron Junker
2022-04-14 16:09:49 +02:00
committed by GitHub
parent 038e8e1510
commit d9c8d8d4e2
10 changed files with 177 additions and 1021 deletions

View File

@@ -14,9 +14,9 @@
<PropertyGroup>
<RootNamespace>Microsoft.PowerToys.PreviewHandler.Monaco</RootNamespace>
<TargetFramework>net6.0-windows10.0.18362.0</TargetFramework>
<TargetFramework>net6.0-windows10.0.18362.0</TargetFramework>
<EnableComHosting>true</EnableComHosting>
<IntermediateOutputPath>$(SolutionDir)$(Platform)\$(Configuration)\obj\$(AssemblyName)\</IntermediateOutputPath>
<IntermediateOutputPath>$(SolutionDir)$(Platform)\$(Configuration)\obj\$(AssemblyName)\</IntermediateOutputPath>
<AssemblyName>PowerToys.MonacoPreviewHandler</AssemblyName>
</PropertyGroup>
@@ -39,18 +39,18 @@
</ItemGroup>
<ItemGroup>
<Compile Update="MonacoPreviewHandlerControl.cs" />
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Update="MonacoPreviewHandlerControl.cs" />
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\common\Common.UI\Common.UI.csproj" />
<ProjectReference Include="..\..\..\settings-ui\Settings.UI.Library\Settings.UI.Library.csproj" />
<ProjectReference Include="..\common\PreviewHandlerCommon.csproj" />
<ProjectReference Include="..\..\..\settings-ui\Settings.UI.Library\Settings.UI.Library.csproj" />
</ItemGroup>
<ItemGroup>
@@ -63,20 +63,32 @@
</ItemGroup>
<ItemGroup>
<None Update="index.html">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="index.html">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Update="monacoSRC\**\*.*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="monacoSRC\**\*.*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Update="monaco_languages.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="customLanguages\**\*.*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Update="monaco_languages.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Update="monacoSpecialLanguages.js">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,42 @@
export function regDefinition() {
return {
tokenPostfix: '.reg',
tokenizer: {
root: [
// Header (case sensitive)
[/Windows Registry Editor Version 5.00/, 'comment'],
[/REGEDIT4/, 'comment'],
// Comments
[/;.*/, "comment"],
// Keys
[/\[\-.*\]/, 'invalid'],
[/\\.*[^\]]/, 'keyword'],
// Values
[/@/, "keyword"],
[/\".*\"=\-/, "invalid"],
[/\".*\"(?=\=)/, "keyword"],
[/\".*\"(?!\=)/, 'string'],
[/hex\({0,1}[0-9,a,b]\)|hex|dword(?=\:)/, "type"],
[/[0-9,a-f,A-F][0-9,a-f,A-F],*/, 'string'],
// Hive names (case in-sensitive)
[/HKEY_CLASSES_ROOT/, 'type'],
[/HKEY_LOCAL_MACHINE/, 'type'],
[/HKEY_USERS/, 'type'],
[/HKEY_CURRENT_USER/, 'type'],
[/HKEY_PERFORMANCE_DATA/, 'type'],
[/HKEY_DYN_DATA/, 'type'],
[/hkey_classes_root/, 'type'],
[/hkey_local_machine/, 'type'],
[/hkey_users/, 'type'],
[/hkey_current_user/, 'type'],
[/hkey_performance_data/, 'type'],
[/hkey_dyn_data/, 'type'],
// Symbols (For better contrast on hc-black)
[/=/, 'delimiter'],
[/\[/, 'delimiter'],
[/]/, 'delimiter'],
[/:/, 'delimiter'],
]
}
}
};

View File

@@ -1,30 +1,32 @@
<!doctype Html>
<html>
<head>
<meta charset="utf-8">
<title>Monaco Preview Handler monaco_languages.json generator</title>
<script src="monacoSRC/min/vs/loader.js"></script>
<script>
function download(filename, text) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
<head>
<meta charset="utf-8">
<title>Monaco Preview Handler monaco_languages.json generator</title>
<script src="monacoSRC/min/vs/loader.js"></script>
<script src="monacoSpecialLanguages.js" type="module"></script>
<script type="module">
import {registerAdditionalLanguages} from "./monacoSpecialLanguages.js"
function download(filename, text) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
element.click();
document.body.removeChild(element);
}
require.config({ paths: { vs: 'monacoSRC/min/vs' } });
require(['vs/editor/editor.main'], function () {
download("monaco_languages.json", "{\"list\":"+ JSON.stringify(monaco.languages.getLanguages())+"}");
});
</script>
</head>
<body>
<div id="container"></div>
</body>
document.body.removeChild(element);
}
require.config({ paths: { vs: 'monacoSRC/min/vs' } });
require(['vs/editor/editor.main'], async function () {
await registerAdditionalLanguages(monaco);
download("monaco_languages.json", "{\"list\":"+ JSON.stringify(monaco.languages.getLanguages())+"}");
});
</script>
</head>
<body>
<div id="container"></div>
</body>
</html>

View File

@@ -52,10 +52,13 @@
<div id="container"></div>
<!-- Script -->
<script src="http://[[PT_URL]]/monacoSRC/min/vs/loader.js"></script>
<script>
<script src="http://[[PT_URL]]/monacoSpecialLanguages.js" type="module"></script>
<script type="module">
var editor;
import { registerAdditionalLanguages } from "http://[[PT_URL]]/monacoSpecialLanguages.js"
require.config({ paths: { vs: 'http://[[PT_URL]]/monacoSRC/min/vs' } });
require(['vs/editor/editor.main'], function () {
require(['vs/editor/editor.main'], async function () {
await registerAdditionalLanguages(monaco)
// Creates the editor
// For all parameters: https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.istandaloneeditorconstructionoptions.html
editor = monaco.editor.create(document.getElementById('container'), {
@@ -112,23 +115,23 @@
});
function onContextMenu(){
// Hide context menu items
// Code modified from https://stackoverflow.com/questions/48745208/disable-cut-and-copy-in-context-menu-in-monaco-editor/65413517#65413517
let menus = require('vs/platform/actions/common/actions').MenuRegistry._menuItems
let contextMenuEntry = [...menus].find(entry => entry[0]._debugName == "EditorContext")
let contextMenuLinks = contextMenuEntry[1]
// Hide context menu items
// Code modified from https://stackoverflow.com/questions/48745208/disable-cut-and-copy-in-context-menu-in-monaco-editor/65413517#65413517
let menus = require('vs/platform/actions/common/actions').MenuRegistry._menuItems
let contextMenuEntry = [...menus].find(entry => entry[0]._debugName == "EditorContext")
let contextMenuLinks = contextMenuEntry[1]
let removableIds = ['editor.action.clipboardCutAction', 'editor.action.formatDocument', 'editor.action.formatSelection', 'editor.action.quickCommand', 'editor.action.quickOutline', 'editor.action.refactor', 'editor.action.sourceAction', 'editor.action.rename', undefined, 'editor.action.revealDefinition', 'editor.action.revealDeclaration', 'editor.action.goToTypeDefinition', 'editor.action.goToImplementation', 'editor.action.goToReferences', 'editor.action.changeAll']
let removableIds = ['editor.action.clipboardCutAction', 'editor.action.formatDocument', 'editor.action.formatSelection', 'editor.action.quickCommand', 'editor.action.quickOutline', 'editor.action.refactor', 'editor.action.sourceAction', 'editor.action.rename', undefined, 'editor.action.revealDefinition', 'editor.action.revealDeclaration', 'editor.action.goToTypeDefinition', 'editor.action.goToImplementation', 'editor.action.goToReferences', 'editor.action.changeAll']
let removeById = (list, ids) => {
let node = list._first
do {
let shouldRemove = ids.includes(node.element?.command?.id)
if (shouldRemove) { list._remove(node) }
} while ((node = node.next))
}
let removeById = (list, ids) => {
let node = list._first
do {
let shouldRemove = ids.includes(node.element?.command?.id)
if (shouldRemove) { list._remove(node) }
} while ((node = node.next))
}
removeById(contextMenuLinks, removableIds)
removeById(contextMenuLinks, removableIds)
}
</script>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long