diff --git a/.github/actions/spell-check/excludes.txt b/.github/actions/spell-check/excludes.txt index 111e57704b..bc08eed6e4 100644 --- a/.github/actions/spell-check/excludes.txt +++ b/.github/actions/spell-check/excludes.txt @@ -1,8 +1,10 @@ # See https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-excludes (?:^|/)monacoSRC/ +(?:^|/)MonacoPreviewHandler/customLanguages/ (?:^|/)MonacoPreviewHandler/monaco_languages.json (?:^|/)MonacoPreviewHandler/index.html (?:^|/)MonacoPreviewHandler/generateLanguagesJson.html +(?:^|/)MonacoPreviewHandler/monacoSpecialLanguages.js (?:^|/)(?i)COPYRIGHT (?:^|/)(?i)LICEN[CS]E (?:^|/)package(?:-lock)\.json$ diff --git a/.github/actions/spell-check/expect.txt b/.github/actions/spell-check/expect.txt index e79c49ca67..672aca904a 100644 --- a/.github/actions/spell-check/expect.txt +++ b/.github/actions/spell-check/expect.txt @@ -2213,6 +2213,7 @@ wdp wdupenv weakme webcam +webserver webpage website webview diff --git a/doc/devdocs/modules/powerpreview/monaco/readme.md b/doc/devdocs/modules/powerpreview/monaco/readme.md index c14a616acb..93bbf743c9 100644 --- a/doc/devdocs/modules/powerpreview/monaco/readme.md +++ b/doc/devdocs/modules/powerpreview/monaco/readme.md @@ -17,6 +17,8 @@ Developer preview is based on [Microsofts Monaco Editor](https://microsoft.githu After you updated monaco editor or adding a new language you should update the [`monaco_languages.json`](/src/modules/previewpane/MonacoPreviewHandler/monaco_languages.json) file. +You have to run the file on a local webserver! + 1. Build monaco in debug mode. 2. Open [generateLanguagesJson.html](/src/modules/previewpane/MonacoPreviewHandler/generateLanguagesJson.html) in a browser. 3. Replace the old JSON file. diff --git a/installer/PowerToysSetup/Product.wxs b/installer/PowerToysSetup/Product.wxs index a6f06f8051..f3cf340007 100644 --- a/installer/PowerToysSetup/Product.wxs +++ b/installer/PowerToysSetup/Product.wxs @@ -38,7 +38,7 @@ - + @@ -394,6 +394,7 @@ + @@ -877,6 +878,11 @@ + + + + + @@ -1044,8 +1050,9 @@ - + + diff --git a/src/modules/previewpane/MonacoPreviewHandler/MonacoPreviewHandler.csproj b/src/modules/previewpane/MonacoPreviewHandler/MonacoPreviewHandler.csproj index 613c66d1bb..ea62061dd4 100644 --- a/src/modules/previewpane/MonacoPreviewHandler/MonacoPreviewHandler.csproj +++ b/src/modules/previewpane/MonacoPreviewHandler/MonacoPreviewHandler.csproj @@ -14,9 +14,9 @@ Microsoft.PowerToys.PreviewHandler.Monaco - net6.0-windows10.0.18362.0 + net6.0-windows10.0.18362.0 true - $(SolutionDir)$(Platform)\$(Configuration)\obj\$(AssemblyName)\ + $(SolutionDir)$(Platform)\$(Configuration)\obj\$(AssemblyName)\ PowerToys.MonacoPreviewHandler @@ -39,18 +39,18 @@ - - - True - True - Resources.resx - + + + True + True + Resources.resx + - + @@ -63,20 +63,32 @@ - - Always - + + Always + - - Always - + + Always + - - Always - + + Always + + + + + + Always + + + + + + Always + diff --git a/src/modules/previewpane/MonacoPreviewHandler/customLanguages/reg.js b/src/modules/previewpane/MonacoPreviewHandler/customLanguages/reg.js new file mode 100644 index 0000000000..671f4a36bd --- /dev/null +++ b/src/modules/previewpane/MonacoPreviewHandler/customLanguages/reg.js @@ -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'], + ] + } + } +}; \ No newline at end of file diff --git a/src/modules/previewpane/MonacoPreviewHandler/generateLanguagesJson.html b/src/modules/previewpane/MonacoPreviewHandler/generateLanguagesJson.html index cafc09648c..09d074cc44 100644 --- a/src/modules/previewpane/MonacoPreviewHandler/generateLanguagesJson.html +++ b/src/modules/previewpane/MonacoPreviewHandler/generateLanguagesJson.html @@ -1,30 +1,32 @@ - - - Monaco Preview Handler monaco_languages.json generator - - + + - - -
- + 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())+"}"); + }); + + + +
+ \ No newline at end of file diff --git a/src/modules/previewpane/MonacoPreviewHandler/index.html b/src/modules/previewpane/MonacoPreviewHandler/index.html index 4da8e809d8..4c1d03bb1f 100644 --- a/src/modules/previewpane/MonacoPreviewHandler/index.html +++ b/src/modules/previewpane/MonacoPreviewHandler/index.html @@ -52,10 +52,13 @@
- + diff --git a/src/modules/previewpane/MonacoPreviewHandler/monacoSpecialLanguages.js b/src/modules/previewpane/MonacoPreviewHandler/monacoSpecialLanguages.js new file mode 100644 index 0000000000..c290488d81 --- /dev/null +++ b/src/modules/previewpane/MonacoPreviewHandler/monacoSpecialLanguages.js @@ -0,0 +1,45 @@ +// This file adds new languages to monaco + +import { regDefinition } from './customLanguages/reg.js'; + +export async function registerAdditionalLanguages(monaco){ + await languageDefinitions(); + registerAdditionalLanguage("cppExt", [".ino", ".pde"], "cpp", monaco) + registerAdditionalLanguage("xmlExt", [".xsd", ".wsdl", ".xslt"], "xml", monaco) + registerAdditionalLanguage("razorExt", [".razor"], "razor", monaco) + registerAdditionalNewLanguage("reg", [".reg"], regDefinition(), monaco) +} + +// Language definitions taken from Monaco source code +async function languageDefinitions() { + define("vs/basic-languages/cpp/cpp",["require","exports"],(function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.language=t.conf=void 0,t.conf={comments:{lineComment:"//",blockComment:["/*","*/"]},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"[",close:"]"},{open:"{",close:"}"},{open:"(",close:")"},{open:"'",close:"'",notIn:["string","comment"]},{open:'"',close:'"',notIn:["string"]}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],folding:{markers:{start:new RegExp("^\\s*#pragma\\s+region\\b"),end:new RegExp("^\\s*#pragma\\s+endregion\\b")}}},t.language={defaultToken:"",tokenPostfix:".cpp",brackets:[{token:"delimiter.curly",open:"{",close:"}"},{token:"delimiter.parenthesis",open:"(",close:")"},{token:"delimiter.square",open:"[",close:"]"},{token:"delimiter.angle",open:"<",close:">"}],keywords:["abstract","amp","array","auto","bool","break","case","catch","char","class","const","constexpr","const_cast","continue","cpu","decltype","default","delegate","delete","do","double","dynamic_cast","each","else","enum","event","explicit","export","extern","false","final","finally","float","for","friend","gcnew","generic","goto","if","in","initonly","inline","int","interface","interior_ptr","internal","literal","long","mutable","namespace","new","noexcept","nullptr","__nullptr","operator","override","partial","pascal","pin_ptr","private","property","protected","public","ref","register","reinterpret_cast","restrict","return","safe_cast","sealed","short","signed","sizeof","static","static_assert","static_cast","struct","switch","template","this","thread_local","throw","tile_static","true","try","typedef","typeid","typename","union","unsigned","using","virtual","void","volatile","wchar_t","where","while","_asm","_based","_cdecl","_declspec","_fastcall","_if_exists","_if_not_exists","_inline","_multiple_inheritance","_pascal","_single_inheritance","_stdcall","_virtual_inheritance","_w64","__abstract","__alignof","__asm","__assume","__based","__box","__builtin_alignof","__cdecl","__clrcall","__declspec","__delegate","__event","__except","__fastcall","__finally","__forceinline","__gc","__hook","__identifier","__if_exists","__if_not_exists","__inline","__int128","__int16","__int32","__int64","__int8","__interface","__leave","__m128","__m128d","__m128i","__m256","__m256d","__m256i","__m64","__multiple_inheritance","__newslot","__nogc","__noop","__nounwind","__novtordisp","__pascal","__pin","__pragma","__property","__ptr32","__ptr64","__raise","__restrict","__resume","__sealed","__single_inheritance","__stdcall","__super","__thiscall","__try","__try_cast","__typeof","__unaligned","__unhook","__uuidof","__value","__virtual_inheritance","__w64","__wchar_t"],operators:["=",">","<","!","~","?",":","==","<=",">=","!=","&&","||","++","--","+","-","*","/","&","|","^","%","<<",">>",">>>","+=","-=","*=","/=","&=","|=","^=","%=","<<=",">>=",">>>="],symbols:/[=>](?!@symbols)/,"@brackets"],[/@symbols/,{cases:{"@operators":"delimiter","@default":""}}],[/\d*\d+[eE]([\-+]?\d+)?(@floatsuffix)/,"number.float"],[/\d*\.\d+([eE][\-+]?\d+)?(@floatsuffix)/,"number.float"],[/0[xX][0-9a-fA-F']*[0-9a-fA-F](@integersuffix)/,"number.hex"],[/0[0-7']*[0-7](@integersuffix)/,"number.octal"],[/0[bB][0-1']*[0-1](@integersuffix)/,"number.binary"],[/\d[\d']*\d(@integersuffix)/,"number"],[/\d(@integersuffix)/,"number"],[/[;,.]/,"delimiter"],[/"([^"\\]|\\.)*$/,"string.invalid"],[/"/,"string","@string"],[/'[^\\']'/,"string"],[/(')(@escapes)(')/,["string","string.escape","string"]],[/'/,"string.invalid"]],whitespace:[[/[ \t\r\n]+/,""],[/\/\*\*(?!\/)/,"comment.doc","@doccomment"],[/\/\*/,"comment","@comment"],[/\/\/.*$/,"comment"]],comment:[[/[^\/*]+/,"comment"],[/\*\//,"comment","@pop"],[/[\/*]/,"comment"]],doccomment:[[/[^\/*]+/,"comment.doc"],[/\*\//,"comment.doc","@pop"],[/[\/*]/,"comment.doc"]],string:[[/[^\\"]+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/"/,"string","@pop"]],raw:[[/(.*)(\))(?:([^ ()\\\t"]*))(\")/,{cases:{"$3==$S2":["string.raw","string.raw.end","string.raw.end",{token:"string.raw.end",next:"@pop"}],"@default":["string.raw","string.raw","string.raw","string.raw"]}}],[/.*/,"string.raw"]],include:[[/(\s*)(<)([^<>]*)(>)/,["","keyword.directive.include.begin","string.include.identifier",{token:"keyword.directive.include.end",next:"@pop"}]],[/(\s*)(")([^"]*)(")/,["","keyword.directive.include.begin","string.include.identifier",{token:"keyword.directive.include.end",next:"@pop"}]]]}}})); + define("vs/basic-languages/xml/xml",["require","exports","../fillers/monaco-editor-core"],(function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.language=t.conf=void 0,t.conf={comments:{blockComment:["\x3c!--","--\x3e"]},brackets:[["<",">"]],autoClosingPairs:[{open:"<",close:">"},{open:"'",close:"'"},{open:'"',close:'"'}],surroundingPairs:[{open:"<",close:">"},{open:"'",close:"'"},{open:'"',close:'"'}],onEnterRules:[{beforeText:new RegExp("<([_:\\w][_:\\w-.\\d]*)([^/>]*(?!/)>)[^<]*$","i"),afterText:/^<\/([_:\w][_:\w-.\d]*)\s*>$/i,action:{indentAction:n.languages.IndentAction.IndentOutdent}},{beforeText:new RegExp("<(\\w[\\w\\d]*)([^/>]*(?!/)>)[^<]*$","i"),action:{indentAction:n.languages.IndentAction.Indent}}]},t.language={defaultToken:"",tokenPostfix:".xml",ignoreCase:!0,qualifiedName:/(?:[\w\.\-]+:)?[\w\.\-]+/,tokenizer:{root:[[/[^<&]+/,""],{include:"@whitespace"},[/(<)(@qualifiedName)/,[{token:"delimiter"},{token:"tag",next:"@tag"}]],[/(<\/)(@qualifiedName)(\s*)(>)/,[{token:"delimiter"},{token:"tag"},"",{token:"delimiter"}]],[/(<\?)(@qualifiedName)/,[{token:"delimiter"},{token:"metatag",next:"@tag"}]],[/(<\!)(@qualifiedName)/,[{token:"delimiter"},{token:"metatag",next:"@tag"}]],[/<\!\[CDATA\[/,{token:"delimiter.cdata",next:"@cdata"}],[/&\w+;/,"string.escape"]],cdata:[[/[^\]]+/,""],[/\]\]>/,{token:"delimiter.cdata",next:"@pop"}],[/\]/,""]],tag:[[/[ \t\r\n]+/,""],[/(@qualifiedName)(\s*=\s*)("[^"]*"|'[^']*')/,["attribute.name","","attribute.value"]],[/(@qualifiedName)(\s*=\s*)("[^">?\/]*|'[^'>?\/]*)(?=[\?\/]\>)/,["attribute.name","","attribute.value"]],[/(@qualifiedName)(\s*=\s*)("[^">]*|'[^'>]*)/,["attribute.name","","attribute.value"]],[/@qualifiedName/,"attribute.name"],[/\?>/,{token:"delimiter",next:"@pop"}],[/(\/)(>)/,[{token:"tag"},{token:"delimiter",next:"@pop"}]],[/>/,{token:"delimiter",next:"@pop"}]],whitespace:[[/[ \t\r\n]+/,""],[//,{token:"comment",next:"@pop"}],[//, "comment.html", "@pop"], [/[^-]+/, "comment.content.html"], [/./, "comment.content.html"]], otherTag: [[/@[^@]/, { token: "@rematch", switchTo: "@razorInSimpleState.otherTag" }], [/\/?>/, "delimiter.html", "@pop"], [/"([^"]*)"/, "attribute.value"], [/'([^']*)'/, "attribute.value"], [/[\w\-]+/, "attribute.name"], [/=/, "delimiter"], [/[ \t\r\n]+/]], script: [[/@[^@]/, { token: "@rematch", switchTo: "@razorInSimpleState.script" }], [/type/, "attribute.name", "@scriptAfterType"], [/"([^"]*)"/, "attribute.value"], [/'([^']*)'/, "attribute.value"], [/[\w\-]+/, "attribute.name"], [/=/, "delimiter"], [/>/, { token: "delimiter.html", next: "@scriptEmbedded.text/javascript", nextEmbedded: "text/javascript" }], [/[ \t\r\n]+/], [/(<\/)(script\s*)(>)/, ["delimiter.html", "tag.html", { token: "delimiter.html", next: "@pop" }]]], scriptAfterType: [[/@[^@]/, { token: "@rematch", switchTo: "@razorInSimpleState.scriptAfterType" }], [/=/, "delimiter", "@scriptAfterTypeEquals"], [/>/, { token: "delimiter.html", next: "@scriptEmbedded.text/javascript", nextEmbedded: "text/javascript" }], [/[ \t\r\n]+/], [/<\/script\s*>/, { token: "@rematch", next: "@pop" }]], scriptAfterTypeEquals: [[/@[^@]/, { token: "@rematch", switchTo: "@razorInSimpleState.scriptAfterTypeEquals" }], [/"([^"]*)"/, { token: "attribute.value", switchTo: "@scriptWithCustomType.$1" }], [/'([^']*)'/, { token: "attribute.value", switchTo: "@scriptWithCustomType.$1" }], [/>/, { token: "delimiter.html", next: "@scriptEmbedded.text/javascript", nextEmbedded: "text/javascript" }], [/[ \t\r\n]+/], [/<\/script\s*>/, { token: "@rematch", next: "@pop" }]], scriptWithCustomType: [[/@[^@]/, { token: "@rematch", switchTo: "@razorInSimpleState.scriptWithCustomType.$S2" }], [/>/, { token: "delimiter.html", next: "@scriptEmbedded.$S2", nextEmbedded: "$S2" }], [/"([^"]*)"/, "attribute.value"], [/'([^']*)'/, "attribute.value"], [/[\w\-]+/, "attribute.name"], [/=/, "delimiter"], [/[ \t\r\n]+/], [/<\/script\s*>/, { token: "@rematch", next: "@pop" }]], scriptEmbedded: [[/@[^@]/, { token: "@rematch", switchTo: "@razorInEmbeddedState.scriptEmbedded.$S2", nextEmbedded: "@pop" }], [/<\/script/, { token: "@rematch", next: "@pop", nextEmbedded: "@pop" }]], style: [[/@[^@]/, { token: "@rematch", switchTo: "@razorInSimpleState.style" }], [/type/, "attribute.name", "@styleAfterType"], [/"([^"]*)"/, "attribute.value"], [/'([^']*)'/, "attribute.value"], [/[\w\-]+/, "attribute.name"], [/=/, "delimiter"], [/>/, { token: "delimiter.html", next: "@styleEmbedded.text/css", nextEmbedded: "text/css" }], [/[ \t\r\n]+/], [/(<\/)(style\s*)(>)/, ["delimiter.html", "tag.html", { token: "delimiter.html", next: "@pop" }]]], styleAfterType: [[/@[^@]/, { token: "@rematch", switchTo: "@razorInSimpleState.styleAfterType" }], [/=/, "delimiter", "@styleAfterTypeEquals"], [/>/, { token: "delimiter.html", next: "@styleEmbedded.text/css", nextEmbedded: "text/css" }], [/[ \t\r\n]+/], [/<\/style\s*>/, { token: "@rematch", next: "@pop" }]], styleAfterTypeEquals: [[/@[^@]/, { token: "@rematch", switchTo: "@razorInSimpleState.styleAfterTypeEquals" }], [/"([^"]*)"/, { token: "attribute.value", switchTo: "@styleWithCustomType.$1" }], [/'([^']*)'/, { token: "attribute.value", switchTo: "@styleWithCustomType.$1" }], [/>/, { token: "delimiter.html", next: "@styleEmbedded.text/css", nextEmbedded: "text/css" }], [/[ \t\r\n]+/], [/<\/style\s*>/, { token: "@rematch", next: "@pop" }]], styleWithCustomType: [[/@[^@]/, { token: "@rematch", switchTo: "@razorInSimpleState.styleWithCustomType.$S2" }], [/>/, { token: "delimiter.html", next: "@styleEmbedded.$S2", nextEmbedded: "$S2" }], [/"([^"]*)"/, "attribute.value"], [/'([^']*)'/, "attribute.value"], [/[\w\-]+/, "attribute.name"], [/=/, "delimiter"], [/[ \t\r\n]+/], [/<\/style\s*>/, { token: "@rematch", next: "@pop" }]], styleEmbedded: [[/@[^@]/, { token: "@rematch", switchTo: "@razorInEmbeddedState.styleEmbedded.$S2", nextEmbedded: "@pop" }], [/<\/style/, { token: "@rematch", next: "@pop", nextEmbedded: "@pop" }]], razorInSimpleState: [[/@\*/, "comment.cs", "@razorBlockCommentTopLevel"], [/@[{(]/, "metatag.cs", "@razorRootTopLevel"], [/(@)(\s*[\w]+)/, ["metatag.cs", { token: "identifier.cs", switchTo: "@$S2.$S3" }]], [/[})]/, { token: "metatag.cs", switchTo: "@$S2.$S3" }], [/\*@/, { token: "comment.cs", switchTo: "@$S2.$S3" }]], razorInEmbeddedState: [[/@\*/, "comment.cs", "@razorBlockCommentTopLevel"], [/@[{(]/, "metatag.cs", "@razorRootTopLevel"], [/(@)(\s*[\w]+)/, ["metatag.cs", { token: "identifier.cs", switchTo: "@$S2.$S3", nextEmbedded: "$S3" }]], [/[})]/, { token: "metatag.cs", switchTo: "@$S2.$S3", nextEmbedded: "$S3" }], [/\*@/, { token: "comment.cs", switchTo: "@$S2.$S3", nextEmbedded: "$S3" }]], razorBlockCommentTopLevel: [[/\*@/, "@rematch", "@pop"], [/[^*]+/, "comment.cs"], [/./, "comment.cs"]], razorBlockComment: [[/\*@/, "comment.cs", "@pop"], [/[^*]+/, "comment.cs"], [/./, "comment.cs"]], razorRootTopLevel: [[/\{/, "delimiter.bracket.cs", "@razorRoot"], [/\(/, "delimiter.parenthesis.cs", "@razorRoot"], [/[})]/, "@rematch", "@pop"], { include: "razorCommon" }], razorRoot: [[/\{/, "delimiter.bracket.cs", "@razorRoot"], [/\(/, "delimiter.parenthesis.cs", "@razorRoot"], [/\}/, "delimiter.bracket.cs", "@pop"], [/\)/, "delimiter.parenthesis.cs", "@pop"], { include: "razorCommon" }], razorCommon: [[/[a-zA-Z_]\w*/, { cases: { "@razorKeywords": { token: "keyword.cs" }, "@default": "identifier.cs" } }], [/[\[\]]/, "delimiter.array.cs"], [/[ \t\r\n]+/], [/\/\/.*$/, "comment.cs"], [/@\*/, "comment.cs", "@razorBlockComment"], [/"([^"]*)"/, "string.cs"], [/'([^']*)'/, "string.cs"], [/(<)(\w+)(\/>)/, ["delimiter.html", "tag.html", "delimiter.html"]], [/(<)(\w+)(>)/, ["delimiter.html", "tag.html", "delimiter.html"]], [/(<\/)(\w+)(>)/, ["delimiter.html", "tag.html", "delimiter.html"]], [/[\+\-\*\%\&\|\^\~\!\=\<\>\/\?\;\:\.\,]/, "delimiter.cs"], [/\d*\d+[eE]([\-+]?\d+)?/, "number.float.cs"], [/\d*\.\d+([eE][\-+]?\d+)?/, "number.float.cs"], [/0[xX][0-9a-fA-F']*[0-9a-fA-F]/, "number.hex.cs"], [/0[0-7']*[0-7]/, "number.octal.cs"], [/0[bB][0-1']*[0-1]/, "number.binary.cs"], [/\d[\d']*/, "number.cs"], [/\d/, "number.cs"]] }, razorKeywords: ["abstract", "as", "async", "await", "base", "bool", "break", "by", "byte", "case", "catch", "char", "checked", "class", "const", "continue", "decimal", "default", "delegate", "do", "double", "descending", "explicit", "event", "extern", "else", "enum", "false", "finally", "fixed", "float", "for", "foreach", "from", "goto", "group", "if", "implicit", "in", "int", "interface", "internal", "into", "is", "lock", "long", "nameof", "new", "null", "namespace", "object", "operator", "out", "override", "orderby", "params", "private", "protected", "public", "readonly", "ref", "return", "switch", "struct", "sbyte", "sealed", "short", "sizeof", "stackalloc", "static", "string", "select", "this", "throw", "true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using", "var", "virtual", "volatile", "void", "when", "while", "where", "yield", "model", "inject"], escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/ } })); +} + +function registerAdditionalLanguage(id, extensions, originalId, monaco){ + require.config({ paths: { vs: 'http://powertoyslocalmonaco/monacoSRC/min/vs' } }); + require(['vs/editor/editor.main'], async function () { + monaco.languages.register({ + id: id, + extensions: extensions + }) + + const langDef = require('vs/basic-languages/'+originalId+'/'+originalId); + monaco.languages.setLanguageConfiguration(id, langDef.conf); + monaco.languages.setMonarchTokensProvider(id, langDef.language); + }) +} + +function registerAdditionalNewLanguage(id, extensions, definition, monaco) { + require.config({ paths: { vs: 'http://powertoyslocalmonaco/monacoSRC/min/vs' } }); + require(['vs/editor/editor.main'], async function () { + monaco.languages.register({ + id: id, + extensions: extensions + }) + + monaco.languages.setMonarchTokensProvider(id, definition); + }) +} + diff --git a/src/modules/previewpane/MonacoPreviewHandler/monaco_languages.json b/src/modules/previewpane/MonacoPreviewHandler/monaco_languages.json index d82808427f..9d8ca0a0a9 100644 --- a/src/modules/previewpane/MonacoPreviewHandler/monaco_languages.json +++ b/src/modules/previewpane/MonacoPreviewHandler/monaco_languages.json @@ -1,961 +1 @@ -{ - "list": [ - { - "id": "plaintext", - "extensions": [ - ".txt" - ], - "aliases": [ - "Plain Text", - "text" - ], - "mimetypes": [ - "text/plain" - ] - }, - { - "id": "json", - "extensions": [ - ".json", - ".bowerrc", - ".jshintrc", - ".jscsrc", - ".eslintrc", - ".babelrc", - ".har" - ], - "aliases": [ - "JSON", - "json" - ], - "mimetypes": [ - "application/json" - ] - }, - { - "id": "abap", - "extensions": [ - ".abap" - ], - "aliases": [ - "abap", - "ABAP" - ] - }, - { - "id": "apex", - "extensions": [ - ".cls" - ], - "aliases": [ - "Apex", - "apex" - ], - "mimetypes": [ - "text/x-apex-source", - "text/x-apex" - ] - }, - { - "id": "azcli", - "extensions": [ - ".azcli" - ], - "aliases": [ - "Azure CLI", - "azcli" - ] - }, - { - "id": "bat", - "extensions": [ - ".bat", - ".cmd" - ], - "aliases": [ - "Batch", - "bat" - ] - }, - { - "id": "cameligo", - "extensions": [ - ".mligo" - ], - "aliases": [ - "Cameligo" - ] - }, - { - "id": "clojure", - "extensions": [ - ".clj", - ".cljs", - ".cljc", - ".edn" - ], - "aliases": [ - "clojure", - "Clojure" - ] - }, - { - "id": "coffeescript", - "extensions": [ - ".coffee" - ], - "aliases": [ - "CoffeeScript", - "coffeescript", - "coffee" - ], - "mimetypes": [ - "text/x-coffeescript", - "text/coffeescript" - ] - }, - { - "id": "c", - "extensions": [ - ".c", - ".h" - ], - "aliases": [ - "C", - "c" - ] - }, - { - "id": "cpp", - "extensions": [ - ".cpp", - ".cc", - ".cxx", - ".hpp", - ".hh", - ".hxx" - ], - "aliases": [ - "C++", - "Cpp", - "cpp" - ] - }, - { - "id": "csharp", - "extensions": [ - ".cs", - ".csx", - ".cake" - ], - "aliases": [ - "C#", - "csharp" - ] - }, - { - "id": "csp", - "extensions": [], - "aliases": [ - "CSP", - "csp" - ] - }, - { - "id": "css", - "extensions": [ - ".css" - ], - "aliases": [ - "CSS", - "css" - ], - "mimetypes": [ - "text/css" - ] - }, - { - "id": "dart", - "extensions": [ - ".dart" - ], - "aliases": [ - "Dart", - "dart" - ], - "mimetypes": [ - "text/x-dart-source", - "text/x-dart" - ] - }, - { - "id": "dockerfile", - "extensions": [ - ".dockerfile" - ], - "filenames": [ - "Dockerfile" - ], - "aliases": [ - "Dockerfile" - ] - }, - { - "id": "ecl", - "extensions": [ - ".ecl" - ], - "aliases": [ - "ECL", - "Ecl", - "ecl" - ] - }, - { - "id": "fsharp", - "extensions": [ - ".fs", - ".fsi", - ".ml", - ".mli", - ".fsx", - ".fsscript" - ], - "aliases": [ - "F#", - "FSharp", - "fsharp" - ] - }, - { - "id": "go", - "extensions": [ - ".go" - ], - "aliases": [ - "Go" - ] - }, - { - "id": "graphql", - "extensions": [ - ".graphql", - ".gql" - ], - "aliases": [ - "GraphQL", - "graphql", - "gql" - ], - "mimetypes": [ - "application/graphql" - ] - }, - { - "id": "handlebars", - "extensions": [ - ".handlebars", - ".hbs" - ], - "aliases": [ - "Handlebars", - "handlebars" - ], - "mimetypes": [ - "text/x-handlebars-template" - ] - }, - { - "id": "hcl", - "extensions": [ - ".tf", - ".tfvars", - ".hcl" - ], - "aliases": [ - "Terraform", - "tf", - "HCL", - "hcl" - ] - }, - { - "id": "html", - "extensions": [ - ".html", - ".htm", - ".shtml", - ".xhtml", - ".mdoc", - ".jsp", - ".asp", - ".aspx", - ".jshtm" - ], - "aliases": [ - "HTML", - "htm", - "html", - "xhtml" - ], - "mimetypes": [ - "text/html", - "text/x-jshtm", - "text/template", - "text/ng-template" - ] - }, - { - "id": "ini", - "extensions": [ - ".ini", - ".properties", - ".gitconfig" - ], - "filenames": [ - "config", - ".gitattributes", - ".gitconfig", - ".editorconfig" - ], - "aliases": [ - "Ini", - "ini" - ] - }, - { - "id": "java", - "extensions": [ - ".java", - ".jav" - ], - "aliases": [ - "Java", - "java" - ], - "mimetypes": [ - "text/x-java-source", - "text/x-java" - ] - }, - { - "id": "javascript", - "extensions": [ - ".js", - ".es6", - ".jsx", - ".mjs" - ], - "firstLine": "^#!.*\\bnode", - "filenames": [ - "jakefile" - ], - "aliases": [ - "JavaScript", - "javascript", - "js" - ], - "mimetypes": [ - "text/javascript" - ] - }, - { - "id": "julia", - "extensions": [ - ".jl" - ], - "aliases": [ - "julia", - "Julia" - ] - }, - { - "id": "kotlin", - "extensions": [ - ".kt" - ], - "aliases": [ - "Kotlin", - "kotlin" - ], - "mimetypes": [ - "text/x-kotlin-source", - "text/x-kotlin" - ] - }, - { - "id": "less", - "extensions": [ - ".less" - ], - "aliases": [ - "Less", - "less" - ], - "mimetypes": [ - "text/x-less", - "text/less" - ] - }, - { - "id": "lexon", - "extensions": [ - ".lex" - ], - "aliases": [ - "Lexon" - ] - }, - { - "id": "lua", - "extensions": [ - ".lua" - ], - "aliases": [ - "Lua", - "lua" - ] - }, - { - "id": "m3", - "extensions": [ - ".m3", - ".i3", - ".mg", - ".ig" - ], - "aliases": [ - "Modula-3", - "Modula3", - "modula3", - "m3" - ] - }, - { - "id": "markdown", - "extensions": [ - ".md", - ".markdown", - ".mdown", - ".mkdn", - ".mkd", - ".mdwn", - ".mdtxt", - ".mdtext" - ], - "aliases": [ - "Markdown", - "markdown" - ] - }, - { - "id": "mips", - "extensions": [ - ".s" - ], - "aliases": [ - "MIPS", - "MIPS-V" - ], - "mimetypes": [ - "text/x-mips", - "text/mips", - "text/plaintext" - ] - }, - { - "id": "msdax", - "extensions": [ - ".dax", - ".msdax" - ], - "aliases": [ - "DAX", - "MSDAX" - ] - }, - { - "id": "mysql", - "extensions": [], - "aliases": [ - "MySQL", - "mysql" - ] - }, - { - "id": "objective-c", - "extensions": [ - ".m" - ], - "aliases": [ - "Objective-C" - ] - }, - { - "id": "pascal", - "extensions": [ - ".pas", - ".p", - ".pp" - ], - "aliases": [ - "Pascal", - "pas" - ], - "mimetypes": [ - "text/x-pascal-source", - "text/x-pascal" - ] - }, - { - "id": "pascaligo", - "extensions": [ - ".ligo" - ], - "aliases": [ - "Pascaligo", - "ligo" - ] - }, - { - "id": "perl", - "extensions": [ - ".pl" - ], - "aliases": [ - "Perl", - "pl" - ] - }, - { - "id": "pgsql", - "extensions": [], - "aliases": [ - "PostgreSQL", - "postgres", - "pg", - "postgre" - ] - }, - { - "id": "php", - "extensions": [ - ".php", - ".php4", - ".php5", - ".phtml", - ".ctp" - ], - "aliases": [ - "PHP", - "php" - ], - "mimetypes": [ - "application/x-php" - ] - }, - { - "id": "postiats", - "extensions": [ - ".dats", - ".sats", - ".hats" - ], - "aliases": [ - "ATS", - "ATS/Postiats" - ] - }, - { - "id": "powerquery", - "extensions": [ - ".pq", - ".pqm" - ], - "aliases": [ - "PQ", - "M", - "Power Query", - "Power Query M" - ] - }, - { - "id": "powershell", - "extensions": [ - ".ps1", - ".psm1", - ".psd1" - ], - "aliases": [ - "PowerShell", - "powershell", - "ps", - "ps1" - ] - }, - { - "id": "pug", - "extensions": [ - ".jade", - ".pug" - ], - "aliases": [ - "Pug", - "Jade", - "jade" - ] - }, - { - "id": "python", - "extensions": [ - ".py", - ".rpy", - ".pyw", - ".cpy", - ".gyp", - ".gypi" - ], - "aliases": [ - "Python", - "py" - ], - "firstLine": "^#!/.*\\bpython[0-9.-]*\\b" - }, - { - "id": "r", - "extensions": [ - ".r", - ".rhistory", - ".rmd", - ".rprofile", - ".rt" - ], - "aliases": [ - "R", - "r" - ] - }, - { - "id": "razor", - "extensions": [ - ".cshtml" - ], - "aliases": [ - "Razor", - "razor" - ], - "mimetypes": [ - "text/x-cshtml" - ] - }, - { - "id": "redis", - "extensions": [ - ".redis" - ], - "aliases": [ - "redis" - ] - }, - { - "id": "redshift", - "extensions": [], - "aliases": [ - "Redshift", - "redshift" - ] - }, - { - "id": "restructuredtext", - "extensions": [ - ".rst" - ], - "aliases": [ - "reStructuredText", - "restructuredtext" - ] - }, - { - "id": "ruby", - "extensions": [ - ".rb", - ".rbx", - ".rjs", - ".gemspec", - ".pp" - ], - "filenames": [ - "rakefile", - "Gemfile" - ], - "aliases": [ - "Ruby", - "rb" - ] - }, - { - "id": "rust", - "extensions": [ - ".rs", - ".rlib" - ], - "aliases": [ - "Rust", - "rust" - ] - }, - { - "id": "sb", - "extensions": [ - ".sb" - ], - "aliases": [ - "Small Basic", - "sb" - ] - }, - { - "id": "scala", - "extensions": [ - ".scala", - ".sc", - ".sbt" - ], - "aliases": [ - "Scala", - "scala", - "SBT", - "Sbt", - "sbt", - "Dotty", - "dotty" - ], - "mimetypes": [ - "text/x-scala-source", - "text/x-scala", - "text/x-sbt", - "text/x-dotty" - ] - }, - { - "id": "scheme", - "extensions": [ - ".scm", - ".ss", - ".sch", - ".rkt" - ], - "aliases": [ - "scheme", - "Scheme" - ] - }, - { - "id": "scss", - "extensions": [ - ".scss" - ], - "aliases": [ - "Sass", - "sass", - "scss" - ], - "mimetypes": [ - "text/x-scss", - "text/scss" - ] - }, - { - "id": "shell", - "extensions": [ - ".sh", - ".bash" - ], - "aliases": [ - "Shell", - "sh" - ] - }, - { - "id": "sol", - "extensions": [ - ".sol" - ], - "aliases": [ - "sol", - "solidity", - "Solidity" - ] - }, - { - "id": "aes", - "extensions": [ - ".aes" - ], - "aliases": [ - "aes", - "sophia", - "Sophia" - ] - }, - { - "id": "sql", - "extensions": [ - ".sql" - ], - "aliases": [ - "SQL" - ] - }, - { - "id": "st", - "extensions": [ - ".st", - ".iecst", - ".iecplc", - ".lc3lib" - ], - "aliases": [ - "StructuredText", - "scl", - "stl" - ] - }, - { - "id": "swift", - "aliases": [ - "Swift", - "swift" - ], - "extensions": [ - ".swift" - ], - "mimetypes": [ - "text/swift" - ] - }, - { - "id": "systemverilog", - "extensions": [ - ".sv", - ".svh" - ], - "aliases": [ - "SV", - "sv", - "SystemVerilog", - "systemverilog" - ] - }, - { - "id": "verilog", - "extensions": [ - ".v", - ".vh" - ], - "aliases": [ - "V", - "v", - "Verilog", - "verilog" - ] - }, - { - "id": "tcl", - "extensions": [ - ".tcl" - ], - "aliases": [ - "tcl", - "Tcl", - "tcltk", - "TclTk", - "tcl/tk", - "Tcl/Tk" - ] - }, - { - "id": "twig", - "extensions": [ - ".twig" - ], - "aliases": [ - "Twig", - "twig" - ], - "mimetypes": [ - "text/x-twig" - ] - }, - { - "id": "typescript", - "extensions": [ - ".ts", - ".tsx" - ], - "aliases": [ - "TypeScript", - "ts", - "typescript" - ], - "mimetypes": [ - "text/typescript" - ] - }, - { - "id": "vb", - "extensions": [ - ".vb" - ], - "aliases": [ - "Visual Basic", - "vb" - ] - }, - { - "id": "xml", - "extensions": [ - ".xml", - ".dtd", - ".ascx", - ".csproj", - ".config", - ".wxi", - ".wxl", - ".wxs", - ".xaml", - ".svg", - ".svgz", - ".opf", - ".xsl" - ], - "firstLine": "(\\<\\?xml.*)|(\\