From f9127b63a5d646f1c693567867db24456a59682c Mon Sep 17 00:00:00 2001 From: Davide Giacometti <25966642+davidegiacometti@users.noreply.github.com> Date: Thu, 24 Oct 2024 21:55:51 +0200 Subject: [PATCH] [RegistryPreview] Adopt Monaco Editor (#35122) --- .github/actions/spell-check/excludes.txt | 12 +- PowerToys.sln | 1 + doc/devdocs/common/FilePreviewCommon.md | 22 +-- .../PowerToysSetup/PowerToysInstaller.wixproj | 2 +- src/Monaco.props | 30 ++++ .../Monaco/customLanguages/gitignore.js | 0 .../Assets => }/Monaco/customLanguages/reg.js | 0 .../Assets => }/Monaco/customTokenColors.js | 0 .../Monaco/generateLanguagesJson.html | 0 .../Assets => }/Monaco/index.html | 0 .../browser/ui/codicons/codicon/codicon.ttf | Bin .../base/common/worker/simpleWorker.nls.de.js | 0 .../base/common/worker/simpleWorker.nls.es.js | 0 .../base/common/worker/simpleWorker.nls.fr.js | 0 .../base/common/worker/simpleWorker.nls.it.js | 0 .../base/common/worker/simpleWorker.nls.ja.js | 0 .../vs/base/common/worker/simpleWorker.nls.js | 0 .../base/common/worker/simpleWorker.nls.ko.js | 0 .../base/common/worker/simpleWorker.nls.ru.js | 0 .../common/worker/simpleWorker.nls.zh-cn.js | 0 .../common/worker/simpleWorker.nls.zh-tw.js | 0 .../min/vs/base/worker/workerMain.js | 0 .../min/vs/basic-languages/abap/abap.js | 0 .../min/vs/basic-languages/apex/apex.js | 0 .../min/vs/basic-languages/azcli/azcli.js | 0 .../min/vs/basic-languages/bat/bat.js | 0 .../min/vs/basic-languages/bicep/bicep.js | 0 .../vs/basic-languages/cameligo/cameligo.js | 0 .../min/vs/basic-languages/clojure/clojure.js | 0 .../min/vs/basic-languages/coffee/coffee.js | 0 .../min/vs/basic-languages/cpp/cpp.js | 0 .../min/vs/basic-languages/csharp/csharp.js | 0 .../min/vs/basic-languages/csp/csp.js | 0 .../min/vs/basic-languages/css/css.js | 0 .../min/vs/basic-languages/cypher/cypher.js | 0 .../min/vs/basic-languages/dart/dart.js | 0 .../basic-languages/dockerfile/dockerfile.js | 0 .../min/vs/basic-languages/ecl/ecl.js | 0 .../min/vs/basic-languages/elixir/elixir.js | 0 .../min/vs/basic-languages/flow9/flow9.js | 0 .../freemarker2/freemarker2.js | 0 .../min/vs/basic-languages/fsharp/fsharp.js | 0 .../monacoSRC/min/vs/basic-languages/go/go.js | 0 .../min/vs/basic-languages/graphql/graphql.js | 0 .../basic-languages/handlebars/handlebars.js | 0 .../min/vs/basic-languages/hcl/hcl.js | 0 .../min/vs/basic-languages/html/html.js | 0 .../min/vs/basic-languages/ini/ini.js | 0 .../min/vs/basic-languages/java/java.js | 0 .../basic-languages/javascript/javascript.js | 0 .../min/vs/basic-languages/julia/julia.js | 0 .../min/vs/basic-languages/kotlin/kotlin.js | 0 .../min/vs/basic-languages/less/less.js | 0 .../min/vs/basic-languages/lexon/lexon.js | 0 .../min/vs/basic-languages/liquid/liquid.js | 0 .../min/vs/basic-languages/lua/lua.js | 0 .../monacoSRC/min/vs/basic-languages/m3/m3.js | 0 .../vs/basic-languages/markdown/markdown.js | 0 .../min/vs/basic-languages/mdx/mdx.js | 0 .../min/vs/basic-languages/mips/mips.js | 0 .../min/vs/basic-languages/msdax/msdax.js | 0 .../min/vs/basic-languages/mysql/mysql.js | 0 .../objective-c/objective-c.js | 0 .../min/vs/basic-languages/pascal/pascal.js | 0 .../vs/basic-languages/pascaligo/pascaligo.js | 0 .../min/vs/basic-languages/perl/perl.js | 0 .../min/vs/basic-languages/pgsql/pgsql.js | 0 .../min/vs/basic-languages/php/php.js | 0 .../min/vs/basic-languages/pla/pla.js | 0 .../vs/basic-languages/postiats/postiats.js | 0 .../basic-languages/powerquery/powerquery.js | 0 .../basic-languages/powershell/powershell.js | 0 .../vs/basic-languages/protobuf/protobuf.js | 0 .../min/vs/basic-languages/pug/pug.js | 0 .../min/vs/basic-languages/python/python.js | 0 .../min/vs/basic-languages/qsharp/qsharp.js | 0 .../monacoSRC/min/vs/basic-languages/r/r.js | 0 .../min/vs/basic-languages/razor/razor.js | 0 .../min/vs/basic-languages/redis/redis.js | 0 .../vs/basic-languages/redshift/redshift.js | 0 .../restructuredtext/restructuredtext.js | 0 .../min/vs/basic-languages/ruby/ruby.js | 0 .../min/vs/basic-languages/rust/rust.js | 0 .../monacoSRC/min/vs/basic-languages/sb/sb.js | 0 .../min/vs/basic-languages/scala/scala.js | 0 .../min/vs/basic-languages/scheme/scheme.js | 0 .../min/vs/basic-languages/scss/scss.js | 0 .../min/vs/basic-languages/shell/shell.js | 0 .../vs/basic-languages/solidity/solidity.js | 0 .../min/vs/basic-languages/sophia/sophia.js | 0 .../min/vs/basic-languages/sparql/sparql.js | 0 .../min/vs/basic-languages/sql/sql.js | 0 .../monacoSRC/min/vs/basic-languages/st/st.js | 0 .../min/vs/basic-languages/swift/swift.js | 0 .../systemverilog/systemverilog.js | 0 .../min/vs/basic-languages/tcl/tcl.js | 0 .../min/vs/basic-languages/twig/twig.js | 0 .../basic-languages/typescript/typescript.js | 0 .../monacoSRC/min/vs/basic-languages/vb/vb.js | 0 .../min/vs/basic-languages/wgsl/wgsl.js | 0 .../min/vs/basic-languages/xml/xml.js | 0 .../min/vs/basic-languages/yaml/yaml.js | 0 .../monacoSRC/min/vs/editor/editor.main.css | 0 .../monacoSRC/min/vs/editor/editor.main.js | 0 .../min/vs/editor/editor.main.nls.de.js | 0 .../min/vs/editor/editor.main.nls.es.js | 0 .../min/vs/editor/editor.main.nls.fr.js | 0 .../min/vs/editor/editor.main.nls.it.js | 0 .../min/vs/editor/editor.main.nls.ja.js | 0 .../min/vs/editor/editor.main.nls.js | 0 .../min/vs/editor/editor.main.nls.ko.js | 0 .../min/vs/editor/editor.main.nls.ru.js | 0 .../min/vs/editor/editor.main.nls.zh-cn.js | 0 .../min/vs/editor/editor.main.nls.zh-tw.js | 0 .../monacoSRC/min/vs/language/css/cssMode.js | 0 .../min/vs/language/css/cssWorker.js | 0 .../min/vs/language/html/htmlMode.js | 0 .../min/vs/language/html/htmlWorker.js | 0 .../min/vs/language/json/jsonMode.js | 0 .../min/vs/language/json/jsonWorker.js | 0 .../min/vs/language/typescript/tsMode.js | 0 .../min/vs/language/typescript/tsWorker.js | 0 .../Monaco/monacoSRC/min/vs/loader.js | 0 .../Monaco/monacoSpecialLanguages.js | 0 .../Assets => }/Monaco/monaco_languages.json | 0 .../FilePreviewCommon.csproj | 25 +-- .../Assets/RegistryPreview/index.html | 64 +++++++ .../MonacoEditorControl.xaml | 35 ++++ .../MonacoEditorControl.xaml.cs | 169 ++++++++++++++++++ .../RegistryPreviewUILib/MonacoHelper.cs | 50 ++++++ .../RegistryPreviewMainPage.Events.cs | 62 +++---- .../RegistryPreviewMainPage.Utilities.cs | 78 ++++---- .../RegistryPreviewMainPage.xaml | 23 +-- .../RegistryPreviewUILib.csproj | 13 ++ .../Strings/en-US/Resources.resw | 3 - 135 files changed, 456 insertions(+), 133 deletions(-) create mode 100644 src/Monaco.props rename src/{common/FilePreviewCommon/Assets => }/Monaco/customLanguages/gitignore.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/customLanguages/reg.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/customTokenColors.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/generateLanguagesJson.html (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/index.html (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/base/browser/ui/codicons/codicon/codicon.ttf (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.de.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.es.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.fr.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.it.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.ja.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.ko.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.ru.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.zh-cn.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.zh-tw.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/base/worker/workerMain.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/abap/abap.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/apex/apex.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/azcli/azcli.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/bat/bat.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/bicep/bicep.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/cameligo/cameligo.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/clojure/clojure.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/coffee/coffee.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/cpp/cpp.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/csharp/csharp.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/csp/csp.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/css/css.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/cypher/cypher.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/dart/dart.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/dockerfile/dockerfile.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/ecl/ecl.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/elixir/elixir.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/flow9/flow9.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/freemarker2/freemarker2.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/fsharp/fsharp.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/go/go.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/graphql/graphql.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/handlebars/handlebars.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/hcl/hcl.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/html/html.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/ini/ini.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/java/java.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/javascript/javascript.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/julia/julia.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/kotlin/kotlin.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/less/less.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/lexon/lexon.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/liquid/liquid.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/lua/lua.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/m3/m3.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/markdown/markdown.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/mdx/mdx.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/mips/mips.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/msdax/msdax.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/mysql/mysql.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/objective-c/objective-c.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/pascal/pascal.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/pascaligo/pascaligo.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/perl/perl.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/pgsql/pgsql.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/php/php.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/pla/pla.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/postiats/postiats.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/powerquery/powerquery.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/powershell/powershell.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/protobuf/protobuf.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/pug/pug.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/python/python.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/qsharp/qsharp.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/r/r.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/razor/razor.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/redis/redis.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/redshift/redshift.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/restructuredtext/restructuredtext.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/ruby/ruby.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/rust/rust.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/sb/sb.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/scala/scala.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/scheme/scheme.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/scss/scss.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/shell/shell.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/solidity/solidity.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/sophia/sophia.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/sparql/sparql.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/sql/sql.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/st/st.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/swift/swift.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/systemverilog/systemverilog.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/tcl/tcl.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/twig/twig.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/typescript/typescript.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/vb/vb.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/wgsl/wgsl.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/xml/xml.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/basic-languages/yaml/yaml.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/editor/editor.main.css (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/editor/editor.main.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/editor/editor.main.nls.de.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/editor/editor.main.nls.es.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/editor/editor.main.nls.fr.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/editor/editor.main.nls.it.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/editor/editor.main.nls.ja.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/editor/editor.main.nls.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/editor/editor.main.nls.ko.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/editor/editor.main.nls.ru.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/editor/editor.main.nls.zh-cn.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/editor/editor.main.nls.zh-tw.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/language/css/cssMode.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/language/css/cssWorker.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/language/html/htmlMode.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/language/html/htmlWorker.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/language/json/jsonMode.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/language/json/jsonWorker.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/language/typescript/tsMode.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/language/typescript/tsWorker.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSRC/min/vs/loader.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monacoSpecialLanguages.js (100%) rename src/{common/FilePreviewCommon/Assets => }/Monaco/monaco_languages.json (100%) create mode 100644 src/modules/registrypreview/RegistryPreviewUILib/Assets/RegistryPreview/index.html create mode 100644 src/modules/registrypreview/RegistryPreviewUILib/MonacoEditorControl.xaml create mode 100644 src/modules/registrypreview/RegistryPreviewUILib/MonacoEditorControl.xaml.cs create mode 100644 src/modules/registrypreview/RegistryPreviewUILib/MonacoHelper.cs diff --git a/.github/actions/spell-check/excludes.txt b/.github/actions/spell-check/excludes.txt index fd89d668a2..fa1d25eda9 100644 --- a/.github/actions/spell-check/excludes.txt +++ b/.github/actions/spell-check/excludes.txt @@ -2,11 +2,11 @@ (?:^|/)(?i)COPYRIGHT (?:^|/)(?i)LICEN[CS]E (?:^|/)3rdparty/ -(?:^|/)FilePreviewCommon/Assets/Monaco/customLanguages/ -(?:^|/)FilePreviewCommon/Assets/Monaco/generateLanguagesJson.html -(?:^|/)FilePreviewCommon/Assets/Monaco/index.html -(?:^|/)FilePreviewCommon/Assets/Monaco/monaco_languages.json -(?:^|/)FilePreviewCommon/Assets/Monaco/monacoSpecialLanguages.js +(?:^|/)src/Monaco/customLanguages/ +(?:^|/)src/Monaco/generateLanguagesJson.html +(?:^|/)src/Monaco/index.html +(?:^|/)src/Monaco/monaco_languages.json +(?:^|/)src/Monaco/monacoSpecialLanguages.js (?:^|/)go\.sum$ (?:^|/)monacoSRC/ (?:^|/)package(?:-lock|)\.json$ @@ -99,7 +99,7 @@ ^\Q.pipelines/ESRPSigning_core.json\E$ ^\Q.pipelines/sdl.gdnbaselines\E$ ^\Qinstaller/PowerToysSetup/Settings.wxs\E$ -^\Qsrc/common/FilePreviewCommon/Assets/Monaco/monaco_languages.json\E$ +^\Qsrc/Monaco/monaco_languages.json\E$ ^\Qsrc/common/ManagedCommon/ColorFormatHelper.cs\E$ ^\Qsrc/common/notifications/BackgroundActivatorDLL/cpp.hint\E$ ^\Qsrc/modules/colorPicker/ColorPickerUI/Assets/ColorPicker/colorPicker.cur\E$ diff --git a/PowerToys.sln b/PowerToys.sln index 29744af75f..fa6b20aacf 100644 --- a/PowerToys.sln +++ b/PowerToys.sln @@ -177,6 +177,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Directory.Build.props = Directory.Build.props Directory.Build.targets = Directory.Build.targets Directory.Packages.props = Directory.Packages.props + src\Monaco.props = src\Monaco.props Solution.props = Solution.props src\Version.props = src\Version.props EndProjectSection diff --git a/doc/devdocs/common/FilePreviewCommon.md b/doc/devdocs/common/FilePreviewCommon.md index aee9de2b2a..85b74ca7e7 100644 --- a/doc/devdocs/common/FilePreviewCommon.md +++ b/doc/devdocs/common/FilePreviewCommon.md @@ -12,14 +12,14 @@ This previewer is used for the File Explorer Dev File Previewer, as well as Powe 1. Download Monaco editor with [npm](https://www.npmjs.com/): Run `npm i monaco-editor` in the command prompt. 2. Delete everything except the `min` folder (the minimised code) from the downloaded files. -3. Copy the `min` folder into the `src/common/FilePreviewCommon/Assets/Monaco/monacoSRC` folder of the PowerToys project. +3. Copy the `min` folder into the `/src/Monaco/monacoSRC` folder of the PowerToys project. 4. Generate the JSON file as described in the generate [monaco_languages.json file](#monaco_languagesjson) section. ### Add a new language definition -As an example on how to add a new language definition you can look at the one for [registry files](/src/common/FilePreviewCommon/Assets/Monaco/customLanguages/reg.js). +As an example on how to add a new language definition you can look at the one for [registry files](/src/Monaco/customLanguages/reg.js). -1. Add the new language definition (written with [Monarch](https://microsoft.github.io/monaco-editor/monarch.html)) as a new file to the [folder containing Monaco custom languages](/src/common/FilePreviewCommon/Assets/Monaco/customLanguages/) (Remember the file name and the string you used for "idDefinition" as you need it later.). The file should be formatted like in the example below. (Please change `idDefinition` to the name of your language.) +1. Add the new language definition (written with [Monarch](https://microsoft.github.io/monaco-editor/monarch.html)) as a new file to the [folder containing Monaco custom languages](/src/Monaco/customLanguages/) (Remember the file name and the string you used for "idDefinition" as you need it later.). The file should be formatted like in the example below. (Please change `idDefinition` to the name of your language.) ```javascript export function idDefinition() { @@ -29,7 +29,7 @@ export function idDefinition() { } ``` -2. Add the following line to the [`monacoSpecialLanguages.js`](/src/common/FilePreviewCommon/Assets/Monaco/monacoSpecialLanguages.js) file, after the other import statements: +2. Add the following line to the [`monacoSpecialLanguages.js`](/src/Monaco/monacoSpecialLanguages.js) file, after the other import statements: ```javascript import { idDefinition } from './customLanguages/file.js'; @@ -37,7 +37,7 @@ import { idDefinition } from './customLanguages/file.js'; > Replace file.js with the name of your definition file from step 1. Please replace idDefinition with the string you used in step 1. -3. In the [`monacoSpecialLanguages.js`](/src/common/FilePreviewCommon/Assets/Monaco/monacoSpecialLanguages.js) file add the following line into the `registerAdditionalLanguages` function: +3. In the [`monacoSpecialLanguages.js`](/src/Monaco/monacoSpecialLanguages.js) file add the following line into the `registerAdditionalLanguages` function: ```javascript registerAdditionalNewLanguage("id", [".fileExtension"], idDefinition(), monaco) @@ -47,7 +47,7 @@ registerAdditionalNewLanguage("id", [".fileExtension"], idDefinition(), monaco) * The id can be anything. Recommended is one of the file extensions. For example "php" or "reg". -4. In case you wish to add a custom color for a token, you can do so by adding the following line to [`customTokenColors.js`](/src/common/FilePreviewCommon/Assets/Monaco/customTokenColors.js): +4. In case you wish to add a custom color for a token, you can do so by adding the following line to [`customTokenColors.js`](/src/Monaco/customTokenColors.js): ```javascript {token: 'token-name', foreground: 'ff0000'} ``` @@ -60,7 +60,7 @@ registerAdditionalNewLanguage("id", [".fileExtension"], idDefinition(), monaco) ### Add a new file extension to an existing language -1. In the [`monacoSpecialLanguages.js`](/src/common/FilePreviewCommon/Assets/Monaco/monacoSpecialLanguages.js) file add the following line to the `registerAdditionalLanguages` function. (`existingId` is the id of the language you want to add the extension to. You can find these id's in the [`monaco_languages.json`](/src/common/FilePreviewCommon/Assets/Monaco/monaco_languages.json) file): +1. In the [`monacoSpecialLanguages.js`](/src/Monaco/monacoSpecialLanguages.js) file add the following line to the `registerAdditionalLanguages` function. (`existingId` is the id of the language you want to add the extension to. You can find these id's in the [`monaco_languages.json`](/src/Monaco/monaco_languages.json) file): ```javascript registerAdditionalLanguage("id", [".fileExtension"], "existingId", monaco) @@ -68,17 +68,17 @@ registerAdditionalLanguage("id", [".fileExtension"], "existingId", monaco) * If for instance you want to add more extensions to the php language set the id to `phpExt` and the existingId to `php`. -2. Copy the existing language definition into the `languageDefinitions` function in the same file. You can find the existing definitions in the following folder: [`/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/`](/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/). +2. Copy the existing language definition into the `languageDefinitions` function in the same file. You can find the existing definitions in the following folder: [`/src/Monaco/monacoSRC/min/vs/basic-languages/`](/src/Monaco/monacoSRC/min/vs/basic-languages/). 3. Execute the steps described in the [monaco_languages.json](#monaco_languagesjson) section. ### monaco_languages.json -[`monaco_languages.json`](/src/common/FilePreviewCommon/Assets/Monaco/monaco_languages.json) contains all extensions and IDs for the languages supported by Monaco. The [`MonacoHelper`](/src/common/FilePreviewCommon/MonacoHelper.cs) class and the installer are using this file to register preview handlers for the defined extensions. +[`monaco_languages.json`](/src/Monaco/monaco_languages.json) contains all extensions and IDs for the languages supported by Monaco. The [`MonacoHelper`](/src/common/FilePreviewCommon/MonacoHelper.cs) class and the installer are using this file to register preview handlers for the defined extensions. -After updating Monaco Editor and/or adding a new language you should update the [`monaco_languages.json`](/src/common/FilePreviewCommon/Assets/Monaco/monaco_languages.json) file. +After updating Monaco Editor and/or adding a new language you should update the [`monaco_languages.json`](/src/Monaco/monaco_languages.json) file. -1. Run the [`generateLanguagesJson.html`](/src/common/FilePreviewCommon/Assets/Monaco/generateLanguagesJson.html) file on a local webserver (as webbrowsers will block certain needed features when running the file locally.) +1. Run the [`generateLanguagesJson.html`](/src/Monaco/generateLanguagesJson.html) file on a local webserver (as webbrowsers will block certain needed features when running the file locally.) * This can for example be achieved by using the [Preview Server](https://marketplace.visualstudio.com/items?itemName=yuichinukiyama.vscode-preview-server) extension for Visual Studio Code: Open the file in Visual Studio Code, right click in the code editor and select `vscode-preview-server: Launch on browser`. The file will be opened in a browser. 2. The browser will download the new `monaco_languages.json` file 3. Replace the old file with the newly downloaded one in the source code folder. diff --git a/installer/PowerToysSetup/PowerToysInstaller.wixproj b/installer/PowerToysSetup/PowerToysInstaller.wixproj index 2826a68493..8771920c3c 100644 --- a/installer/PowerToysSetup/PowerToysInstaller.wixproj +++ b/installer/PowerToysSetup/PowerToysInstaller.wixproj @@ -181,7 +181,7 @@ call powershell.exe -NonInteractive -executionpolicy Unrestricted -File $(MSBuil --> - + diff --git a/src/Monaco.props b/src/Monaco.props new file mode 100644 index 0000000000..0aeef121e2 --- /dev/null +++ b/src/Monaco.props @@ -0,0 +1,30 @@ + + + + + + Assets\Monaco\customTokenColors.js + Always + + + Assets\Monaco\monacoSpecialLanguages.js + Always + + + Assets\Monaco\index.html + Always + + + Assets\Monaco\monaco_languages.json + Always + + + Assets\Monaco\monacoSRC\%(RecursiveDir)%(FileName)%(Extension) + Always + + + Assets\Monaco\customLanguages\%(RecursiveDir)%(FileName)%(Extension) + Always + + + \ No newline at end of file diff --git a/src/common/FilePreviewCommon/Assets/Monaco/customLanguages/gitignore.js b/src/Monaco/customLanguages/gitignore.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/customLanguages/gitignore.js rename to src/Monaco/customLanguages/gitignore.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/customLanguages/reg.js b/src/Monaco/customLanguages/reg.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/customLanguages/reg.js rename to src/Monaco/customLanguages/reg.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/customTokenColors.js b/src/Monaco/customTokenColors.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/customTokenColors.js rename to src/Monaco/customTokenColors.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/generateLanguagesJson.html b/src/Monaco/generateLanguagesJson.html similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/generateLanguagesJson.html rename to src/Monaco/generateLanguagesJson.html diff --git a/src/common/FilePreviewCommon/Assets/Monaco/index.html b/src/Monaco/index.html similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/index.html rename to src/Monaco/index.html diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/base/browser/ui/codicons/codicon/codicon.ttf b/src/Monaco/monacoSRC/min/vs/base/browser/ui/codicons/codicon/codicon.ttf similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/base/browser/ui/codicons/codicon/codicon.ttf rename to src/Monaco/monacoSRC/min/vs/base/browser/ui/codicons/codicon/codicon.ttf diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.de.js b/src/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.de.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.de.js rename to src/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.de.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.es.js b/src/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.es.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.es.js rename to src/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.es.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.fr.js b/src/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.fr.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.fr.js rename to src/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.fr.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.it.js b/src/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.it.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.it.js rename to src/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.it.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.ja.js b/src/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.ja.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.ja.js rename to src/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.ja.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.js b/src/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.js rename to src/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.ko.js b/src/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.ko.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.ko.js rename to src/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.ko.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.ru.js b/src/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.ru.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.ru.js rename to src/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.ru.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.zh-cn.js b/src/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.zh-cn.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.zh-cn.js rename to src/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.zh-cn.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.zh-tw.js b/src/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.zh-tw.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.zh-tw.js rename to src/Monaco/monacoSRC/min/vs/base/common/worker/simpleWorker.nls.zh-tw.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/base/worker/workerMain.js b/src/Monaco/monacoSRC/min/vs/base/worker/workerMain.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/base/worker/workerMain.js rename to src/Monaco/monacoSRC/min/vs/base/worker/workerMain.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/abap/abap.js b/src/Monaco/monacoSRC/min/vs/basic-languages/abap/abap.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/abap/abap.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/abap/abap.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/apex/apex.js b/src/Monaco/monacoSRC/min/vs/basic-languages/apex/apex.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/apex/apex.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/apex/apex.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/azcli/azcli.js b/src/Monaco/monacoSRC/min/vs/basic-languages/azcli/azcli.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/azcli/azcli.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/azcli/azcli.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/bat/bat.js b/src/Monaco/monacoSRC/min/vs/basic-languages/bat/bat.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/bat/bat.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/bat/bat.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/bicep/bicep.js b/src/Monaco/monacoSRC/min/vs/basic-languages/bicep/bicep.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/bicep/bicep.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/bicep/bicep.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/cameligo/cameligo.js b/src/Monaco/monacoSRC/min/vs/basic-languages/cameligo/cameligo.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/cameligo/cameligo.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/cameligo/cameligo.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/clojure/clojure.js b/src/Monaco/monacoSRC/min/vs/basic-languages/clojure/clojure.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/clojure/clojure.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/clojure/clojure.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/coffee/coffee.js b/src/Monaco/monacoSRC/min/vs/basic-languages/coffee/coffee.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/coffee/coffee.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/coffee/coffee.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/cpp/cpp.js b/src/Monaco/monacoSRC/min/vs/basic-languages/cpp/cpp.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/cpp/cpp.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/cpp/cpp.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/csharp/csharp.js b/src/Monaco/monacoSRC/min/vs/basic-languages/csharp/csharp.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/csharp/csharp.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/csharp/csharp.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/csp/csp.js b/src/Monaco/monacoSRC/min/vs/basic-languages/csp/csp.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/csp/csp.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/csp/csp.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/css/css.js b/src/Monaco/monacoSRC/min/vs/basic-languages/css/css.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/css/css.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/css/css.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/cypher/cypher.js b/src/Monaco/monacoSRC/min/vs/basic-languages/cypher/cypher.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/cypher/cypher.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/cypher/cypher.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/dart/dart.js b/src/Monaco/monacoSRC/min/vs/basic-languages/dart/dart.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/dart/dart.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/dart/dart.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/dockerfile/dockerfile.js b/src/Monaco/monacoSRC/min/vs/basic-languages/dockerfile/dockerfile.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/dockerfile/dockerfile.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/dockerfile/dockerfile.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/ecl/ecl.js b/src/Monaco/monacoSRC/min/vs/basic-languages/ecl/ecl.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/ecl/ecl.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/ecl/ecl.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/elixir/elixir.js b/src/Monaco/monacoSRC/min/vs/basic-languages/elixir/elixir.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/elixir/elixir.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/elixir/elixir.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/flow9/flow9.js b/src/Monaco/monacoSRC/min/vs/basic-languages/flow9/flow9.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/flow9/flow9.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/flow9/flow9.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/freemarker2/freemarker2.js b/src/Monaco/monacoSRC/min/vs/basic-languages/freemarker2/freemarker2.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/freemarker2/freemarker2.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/freemarker2/freemarker2.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/fsharp/fsharp.js b/src/Monaco/monacoSRC/min/vs/basic-languages/fsharp/fsharp.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/fsharp/fsharp.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/fsharp/fsharp.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/go/go.js b/src/Monaco/monacoSRC/min/vs/basic-languages/go/go.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/go/go.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/go/go.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/graphql/graphql.js b/src/Monaco/monacoSRC/min/vs/basic-languages/graphql/graphql.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/graphql/graphql.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/graphql/graphql.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/handlebars/handlebars.js b/src/Monaco/monacoSRC/min/vs/basic-languages/handlebars/handlebars.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/handlebars/handlebars.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/handlebars/handlebars.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/hcl/hcl.js b/src/Monaco/monacoSRC/min/vs/basic-languages/hcl/hcl.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/hcl/hcl.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/hcl/hcl.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/html/html.js b/src/Monaco/monacoSRC/min/vs/basic-languages/html/html.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/html/html.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/html/html.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/ini/ini.js b/src/Monaco/monacoSRC/min/vs/basic-languages/ini/ini.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/ini/ini.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/ini/ini.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/java/java.js b/src/Monaco/monacoSRC/min/vs/basic-languages/java/java.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/java/java.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/java/java.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/javascript/javascript.js b/src/Monaco/monacoSRC/min/vs/basic-languages/javascript/javascript.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/javascript/javascript.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/javascript/javascript.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/julia/julia.js b/src/Monaco/monacoSRC/min/vs/basic-languages/julia/julia.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/julia/julia.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/julia/julia.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/kotlin/kotlin.js b/src/Monaco/monacoSRC/min/vs/basic-languages/kotlin/kotlin.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/kotlin/kotlin.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/kotlin/kotlin.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/less/less.js b/src/Monaco/monacoSRC/min/vs/basic-languages/less/less.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/less/less.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/less/less.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/lexon/lexon.js b/src/Monaco/monacoSRC/min/vs/basic-languages/lexon/lexon.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/lexon/lexon.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/lexon/lexon.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/liquid/liquid.js b/src/Monaco/monacoSRC/min/vs/basic-languages/liquid/liquid.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/liquid/liquid.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/liquid/liquid.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/lua/lua.js b/src/Monaco/monacoSRC/min/vs/basic-languages/lua/lua.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/lua/lua.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/lua/lua.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/m3/m3.js b/src/Monaco/monacoSRC/min/vs/basic-languages/m3/m3.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/m3/m3.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/m3/m3.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/markdown/markdown.js b/src/Monaco/monacoSRC/min/vs/basic-languages/markdown/markdown.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/markdown/markdown.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/markdown/markdown.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/mdx/mdx.js b/src/Monaco/monacoSRC/min/vs/basic-languages/mdx/mdx.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/mdx/mdx.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/mdx/mdx.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/mips/mips.js b/src/Monaco/monacoSRC/min/vs/basic-languages/mips/mips.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/mips/mips.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/mips/mips.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/msdax/msdax.js b/src/Monaco/monacoSRC/min/vs/basic-languages/msdax/msdax.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/msdax/msdax.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/msdax/msdax.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/mysql/mysql.js b/src/Monaco/monacoSRC/min/vs/basic-languages/mysql/mysql.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/mysql/mysql.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/mysql/mysql.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/objective-c/objective-c.js b/src/Monaco/monacoSRC/min/vs/basic-languages/objective-c/objective-c.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/objective-c/objective-c.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/objective-c/objective-c.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/pascal/pascal.js b/src/Monaco/monacoSRC/min/vs/basic-languages/pascal/pascal.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/pascal/pascal.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/pascal/pascal.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/pascaligo/pascaligo.js b/src/Monaco/monacoSRC/min/vs/basic-languages/pascaligo/pascaligo.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/pascaligo/pascaligo.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/pascaligo/pascaligo.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/perl/perl.js b/src/Monaco/monacoSRC/min/vs/basic-languages/perl/perl.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/perl/perl.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/perl/perl.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/pgsql/pgsql.js b/src/Monaco/monacoSRC/min/vs/basic-languages/pgsql/pgsql.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/pgsql/pgsql.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/pgsql/pgsql.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/php/php.js b/src/Monaco/monacoSRC/min/vs/basic-languages/php/php.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/php/php.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/php/php.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/pla/pla.js b/src/Monaco/monacoSRC/min/vs/basic-languages/pla/pla.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/pla/pla.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/pla/pla.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/postiats/postiats.js b/src/Monaco/monacoSRC/min/vs/basic-languages/postiats/postiats.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/postiats/postiats.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/postiats/postiats.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/powerquery/powerquery.js b/src/Monaco/monacoSRC/min/vs/basic-languages/powerquery/powerquery.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/powerquery/powerquery.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/powerquery/powerquery.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/powershell/powershell.js b/src/Monaco/monacoSRC/min/vs/basic-languages/powershell/powershell.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/powershell/powershell.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/powershell/powershell.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/protobuf/protobuf.js b/src/Monaco/monacoSRC/min/vs/basic-languages/protobuf/protobuf.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/protobuf/protobuf.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/protobuf/protobuf.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/pug/pug.js b/src/Monaco/monacoSRC/min/vs/basic-languages/pug/pug.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/pug/pug.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/pug/pug.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/python/python.js b/src/Monaco/monacoSRC/min/vs/basic-languages/python/python.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/python/python.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/python/python.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/qsharp/qsharp.js b/src/Monaco/monacoSRC/min/vs/basic-languages/qsharp/qsharp.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/qsharp/qsharp.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/qsharp/qsharp.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/r/r.js b/src/Monaco/monacoSRC/min/vs/basic-languages/r/r.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/r/r.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/r/r.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/razor/razor.js b/src/Monaco/monacoSRC/min/vs/basic-languages/razor/razor.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/razor/razor.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/razor/razor.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/redis/redis.js b/src/Monaco/monacoSRC/min/vs/basic-languages/redis/redis.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/redis/redis.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/redis/redis.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/redshift/redshift.js b/src/Monaco/monacoSRC/min/vs/basic-languages/redshift/redshift.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/redshift/redshift.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/redshift/redshift.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/restructuredtext/restructuredtext.js b/src/Monaco/monacoSRC/min/vs/basic-languages/restructuredtext/restructuredtext.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/restructuredtext/restructuredtext.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/restructuredtext/restructuredtext.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/ruby/ruby.js b/src/Monaco/monacoSRC/min/vs/basic-languages/ruby/ruby.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/ruby/ruby.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/ruby/ruby.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/rust/rust.js b/src/Monaco/monacoSRC/min/vs/basic-languages/rust/rust.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/rust/rust.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/rust/rust.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/sb/sb.js b/src/Monaco/monacoSRC/min/vs/basic-languages/sb/sb.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/sb/sb.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/sb/sb.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/scala/scala.js b/src/Monaco/monacoSRC/min/vs/basic-languages/scala/scala.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/scala/scala.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/scala/scala.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/scheme/scheme.js b/src/Monaco/monacoSRC/min/vs/basic-languages/scheme/scheme.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/scheme/scheme.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/scheme/scheme.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/scss/scss.js b/src/Monaco/monacoSRC/min/vs/basic-languages/scss/scss.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/scss/scss.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/scss/scss.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/shell/shell.js b/src/Monaco/monacoSRC/min/vs/basic-languages/shell/shell.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/shell/shell.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/shell/shell.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/solidity/solidity.js b/src/Monaco/monacoSRC/min/vs/basic-languages/solidity/solidity.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/solidity/solidity.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/solidity/solidity.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/sophia/sophia.js b/src/Monaco/monacoSRC/min/vs/basic-languages/sophia/sophia.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/sophia/sophia.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/sophia/sophia.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/sparql/sparql.js b/src/Monaco/monacoSRC/min/vs/basic-languages/sparql/sparql.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/sparql/sparql.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/sparql/sparql.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/sql/sql.js b/src/Monaco/monacoSRC/min/vs/basic-languages/sql/sql.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/sql/sql.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/sql/sql.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/st/st.js b/src/Monaco/monacoSRC/min/vs/basic-languages/st/st.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/st/st.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/st/st.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/swift/swift.js b/src/Monaco/monacoSRC/min/vs/basic-languages/swift/swift.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/swift/swift.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/swift/swift.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/systemverilog/systemverilog.js b/src/Monaco/monacoSRC/min/vs/basic-languages/systemverilog/systemverilog.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/systemverilog/systemverilog.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/systemverilog/systemverilog.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/tcl/tcl.js b/src/Monaco/monacoSRC/min/vs/basic-languages/tcl/tcl.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/tcl/tcl.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/tcl/tcl.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/twig/twig.js b/src/Monaco/monacoSRC/min/vs/basic-languages/twig/twig.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/twig/twig.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/twig/twig.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/typescript/typescript.js b/src/Monaco/monacoSRC/min/vs/basic-languages/typescript/typescript.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/typescript/typescript.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/typescript/typescript.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/vb/vb.js b/src/Monaco/monacoSRC/min/vs/basic-languages/vb/vb.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/vb/vb.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/vb/vb.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/wgsl/wgsl.js b/src/Monaco/monacoSRC/min/vs/basic-languages/wgsl/wgsl.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/wgsl/wgsl.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/wgsl/wgsl.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/xml/xml.js b/src/Monaco/monacoSRC/min/vs/basic-languages/xml/xml.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/xml/xml.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/xml/xml.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/yaml/yaml.js b/src/Monaco/monacoSRC/min/vs/basic-languages/yaml/yaml.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/basic-languages/yaml/yaml.js rename to src/Monaco/monacoSRC/min/vs/basic-languages/yaml/yaml.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/editor/editor.main.css b/src/Monaco/monacoSRC/min/vs/editor/editor.main.css similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/editor/editor.main.css rename to src/Monaco/monacoSRC/min/vs/editor/editor.main.css diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/editor/editor.main.js b/src/Monaco/monacoSRC/min/vs/editor/editor.main.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/editor/editor.main.js rename to src/Monaco/monacoSRC/min/vs/editor/editor.main.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/editor/editor.main.nls.de.js b/src/Monaco/monacoSRC/min/vs/editor/editor.main.nls.de.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/editor/editor.main.nls.de.js rename to src/Monaco/monacoSRC/min/vs/editor/editor.main.nls.de.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/editor/editor.main.nls.es.js b/src/Monaco/monacoSRC/min/vs/editor/editor.main.nls.es.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/editor/editor.main.nls.es.js rename to src/Monaco/monacoSRC/min/vs/editor/editor.main.nls.es.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/editor/editor.main.nls.fr.js b/src/Monaco/monacoSRC/min/vs/editor/editor.main.nls.fr.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/editor/editor.main.nls.fr.js rename to src/Monaco/monacoSRC/min/vs/editor/editor.main.nls.fr.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/editor/editor.main.nls.it.js b/src/Monaco/monacoSRC/min/vs/editor/editor.main.nls.it.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/editor/editor.main.nls.it.js rename to src/Monaco/monacoSRC/min/vs/editor/editor.main.nls.it.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/editor/editor.main.nls.ja.js b/src/Monaco/monacoSRC/min/vs/editor/editor.main.nls.ja.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/editor/editor.main.nls.ja.js rename to src/Monaco/monacoSRC/min/vs/editor/editor.main.nls.ja.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/editor/editor.main.nls.js b/src/Monaco/monacoSRC/min/vs/editor/editor.main.nls.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/editor/editor.main.nls.js rename to src/Monaco/monacoSRC/min/vs/editor/editor.main.nls.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/editor/editor.main.nls.ko.js b/src/Monaco/monacoSRC/min/vs/editor/editor.main.nls.ko.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/editor/editor.main.nls.ko.js rename to src/Monaco/monacoSRC/min/vs/editor/editor.main.nls.ko.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/editor/editor.main.nls.ru.js b/src/Monaco/monacoSRC/min/vs/editor/editor.main.nls.ru.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/editor/editor.main.nls.ru.js rename to src/Monaco/monacoSRC/min/vs/editor/editor.main.nls.ru.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/editor/editor.main.nls.zh-cn.js b/src/Monaco/monacoSRC/min/vs/editor/editor.main.nls.zh-cn.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/editor/editor.main.nls.zh-cn.js rename to src/Monaco/monacoSRC/min/vs/editor/editor.main.nls.zh-cn.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/editor/editor.main.nls.zh-tw.js b/src/Monaco/monacoSRC/min/vs/editor/editor.main.nls.zh-tw.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/editor/editor.main.nls.zh-tw.js rename to src/Monaco/monacoSRC/min/vs/editor/editor.main.nls.zh-tw.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/language/css/cssMode.js b/src/Monaco/monacoSRC/min/vs/language/css/cssMode.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/language/css/cssMode.js rename to src/Monaco/monacoSRC/min/vs/language/css/cssMode.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/language/css/cssWorker.js b/src/Monaco/monacoSRC/min/vs/language/css/cssWorker.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/language/css/cssWorker.js rename to src/Monaco/monacoSRC/min/vs/language/css/cssWorker.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/language/html/htmlMode.js b/src/Monaco/monacoSRC/min/vs/language/html/htmlMode.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/language/html/htmlMode.js rename to src/Monaco/monacoSRC/min/vs/language/html/htmlMode.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/language/html/htmlWorker.js b/src/Monaco/monacoSRC/min/vs/language/html/htmlWorker.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/language/html/htmlWorker.js rename to src/Monaco/monacoSRC/min/vs/language/html/htmlWorker.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/language/json/jsonMode.js b/src/Monaco/monacoSRC/min/vs/language/json/jsonMode.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/language/json/jsonMode.js rename to src/Monaco/monacoSRC/min/vs/language/json/jsonMode.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/language/json/jsonWorker.js b/src/Monaco/monacoSRC/min/vs/language/json/jsonWorker.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/language/json/jsonWorker.js rename to src/Monaco/monacoSRC/min/vs/language/json/jsonWorker.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/language/typescript/tsMode.js b/src/Monaco/monacoSRC/min/vs/language/typescript/tsMode.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/language/typescript/tsMode.js rename to src/Monaco/monacoSRC/min/vs/language/typescript/tsMode.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/language/typescript/tsWorker.js b/src/Monaco/monacoSRC/min/vs/language/typescript/tsWorker.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/language/typescript/tsWorker.js rename to src/Monaco/monacoSRC/min/vs/language/typescript/tsWorker.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/loader.js b/src/Monaco/monacoSRC/min/vs/loader.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSRC/min/vs/loader.js rename to src/Monaco/monacoSRC/min/vs/loader.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monacoSpecialLanguages.js b/src/Monaco/monacoSpecialLanguages.js similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monacoSpecialLanguages.js rename to src/Monaco/monacoSpecialLanguages.js diff --git a/src/common/FilePreviewCommon/Assets/Monaco/monaco_languages.json b/src/Monaco/monaco_languages.json similarity index 100% rename from src/common/FilePreviewCommon/Assets/Monaco/monaco_languages.json rename to src/Monaco/monaco_languages.json diff --git a/src/common/FilePreviewCommon/FilePreviewCommon.csproj b/src/common/FilePreviewCommon/FilePreviewCommon.csproj index 5849155ca0..28865605a0 100644 --- a/src/common/FilePreviewCommon/FilePreviewCommon.csproj +++ b/src/common/FilePreviewCommon/FilePreviewCommon.csproj @@ -1,6 +1,7 @@  + PowerToys FilePreviewCommon @@ -15,28 +16,4 @@ - - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - diff --git a/src/modules/registrypreview/RegistryPreviewUILib/Assets/RegistryPreview/index.html b/src/modules/registrypreview/RegistryPreviewUILib/Assets/RegistryPreview/index.html new file mode 100644 index 0000000000..5709e3f4f1 --- /dev/null +++ b/src/modules/registrypreview/RegistryPreviewUILib/Assets/RegistryPreview/index.html @@ -0,0 +1,64 @@ + + + + + + + + + Registry Preview Editor + + + + + +
+ + + + + diff --git a/src/modules/registrypreview/RegistryPreviewUILib/MonacoEditorControl.xaml b/src/modules/registrypreview/RegistryPreviewUILib/MonacoEditorControl.xaml new file mode 100644 index 0000000000..9635708343 --- /dev/null +++ b/src/modules/registrypreview/RegistryPreviewUILib/MonacoEditorControl.xaml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + diff --git a/src/modules/registrypreview/RegistryPreviewUILib/MonacoEditorControl.xaml.cs b/src/modules/registrypreview/RegistryPreviewUILib/MonacoEditorControl.xaml.cs new file mode 100644 index 0000000000..eeddfcb0f4 --- /dev/null +++ b/src/modules/registrypreview/RegistryPreviewUILib/MonacoEditorControl.xaml.cs @@ -0,0 +1,169 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.IO; +using System.Reflection; +using System.Text.Json.Nodes; +using System.Threading.Tasks; +using System.Timers; +using System.Web; +using CommunityToolkit.Mvvm.ComponentModel; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.Web.WebView2.Core; +using Windows.UI; + +namespace RegistryPreviewUILib +{ + [INotifyPropertyChanged] + public sealed partial class MonacoEditorControl : UserControl, IDisposable + { + private readonly Timer _textChangedThrottle; + private bool _textChangedThrottled; + + public string Text { get; private set; } + + [ObservableProperty] + private bool _isLoading; + + public event EventHandler TextChanged; + + public MonacoEditorControl() + { + InitializeComponent(); + Environment.SetEnvironmentVariable("WEBVIEW2_USER_DATA_FOLDER", MonacoHelper.TempFolderPath, EnvironmentVariableTarget.Process); + + _textChangedThrottle = new Timer(250); + _textChangedThrottle.Elapsed += OnTextChangedThrottleElapsed; + _textChangedThrottle.AutoReset = false; + + ActualThemeChanged += OnActualThemeChanged; + } + + public async Task SetTextAsync(string text) + { + Text = text; + + if (!IsLoading) + { + var encodedText = HttpUtility.JavaScriptStringEncode(text); + await Browser.CoreWebView2.ExecuteScriptAsync($"editor.setValue('{encodedText}')"); + } + } + + private async void OnActualThemeChanged(FrameworkElement sender, object args) + { + await SetThemeAsync(); + } + + private async void Browser_Loaded(object sender, RoutedEventArgs e) + { + IsLoading = true; + + await Browser.EnsureCoreWebView2Async(); + Browser.DefaultBackgroundColor = Color.FromArgb(0, 0, 0, 0); + Browser.CoreWebView2.NavigationCompleted += CoreWebView2_NavigationCompleted; + Browser.CoreWebView2.PermissionRequested += CoreWebView2_PermissionRequested; + Browser.CoreWebView2.Settings.AreDefaultScriptDialogsEnabled = false; + Browser.CoreWebView2.Settings.AreDefaultContextMenusEnabled = false; + Browser.CoreWebView2.Settings.AreHostObjectsAllowed = false; + Browser.CoreWebView2.Settings.IsGeneralAutofillEnabled = false; + Browser.CoreWebView2.Settings.IsPasswordAutosaveEnabled = false; + Browser.CoreWebView2.Settings.IsScriptEnabled = true; + Browser.CoreWebView2.Settings.IsWebMessageEnabled = true; +#if DEBUG + Browser.CoreWebView2.Settings.AreDevToolsEnabled = true; +#else + Browser.CoreWebView2.Settings.AreDevToolsEnabled = false; +#endif + + Browser.CoreWebView2.SetVirtualHostNameToFolderMapping( + MonacoHelper.VirtualHostName, + MonacoHelper.MonacoDirectory, + CoreWebView2HostResourceAccessKind.Allow); + + var assemblyDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty; + var index = Path.GetFullPath(Path.Combine(assemblyDir, "Assets", "RegistryPreview", "index.html")); + Browser.CoreWebView2.Navigate(index); + } + + private void CoreWebView2_PermissionRequested(CoreWebView2 sender, CoreWebView2PermissionRequestedEventArgs args) + { + if (args.PermissionKind == CoreWebView2PermissionKind.ClipboardRead) + { + // Hide the permission request dialog + args.State = CoreWebView2PermissionState.Allow; + args.Handled = true; + } + } + + private async void CoreWebView2_NavigationCompleted(CoreWebView2 sender, CoreWebView2NavigationCompletedEventArgs args) + { + await SetThemeAsync(); + IsLoading = false; + await SetTextAsync(Text); + + Browser.CoreWebView2.WebMessageReceived += CoreWebView2_WebMessageReceived; + Browser.Focus(FocusState.Programmatic); + } + + private void CoreWebView2_WebMessageReceived(CoreWebView2 sender, CoreWebView2WebMessageReceivedEventArgs args) + { + var json = JsonNode.Parse(args.WebMessageAsJson); + if (json == null) + { + return; + } + + var id = json["id"]; + if (id == null || !id.ToString().Equals("contentChanged", StringComparison.OrdinalIgnoreCase)) + { + return; + } + + var content = json["content"].ToString(); + if (content == null) + { + return; + } + + Text = content; + ThrottleTextChanged(); + } + + private async Task SetThemeAsync() + { + var theme = Application.Current.RequestedTheme == ApplicationTheme.Light ? "vs" : "vs-dark"; + await Browser.CoreWebView2.ExecuteScriptAsync($"monaco.editor.setTheme('{theme}')"); + } + + private void OnTextChangedThrottleElapsed(object sender, ElapsedEventArgs e) + { + if (_textChangedThrottled) + { + _textChangedThrottled = false; + TextChanged?.Invoke(this, EventArgs.Empty); + _textChangedThrottle.Start(); + } + } + + private void ThrottleTextChanged() + { + if (_textChangedThrottle.Enabled) + { + _textChangedThrottled = true; + return; + } + + TextChanged?.Invoke(this, EventArgs.Empty); + _textChangedThrottle.Start(); + } + + public void Dispose() + { + _textChangedThrottle?.Dispose(); + } + } +} diff --git a/src/modules/registrypreview/RegistryPreviewUILib/MonacoHelper.cs b/src/modules/registrypreview/RegistryPreviewUILib/MonacoHelper.cs new file mode 100644 index 0000000000..95305ff2ba --- /dev/null +++ b/src/modules/registrypreview/RegistryPreviewUILib/MonacoHelper.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.IO; +using System.Reflection; + +namespace RegistryPreviewUILib +{ + public static class MonacoHelper + { + /// + /// Name of the virtual host + /// + public const string VirtualHostName = "PowerToysLocalMonaco"; + + public static string TempFolderPath { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), @"AppData\LocalLow\Microsoft\PowerToys\RegistryPreview-Temp"); + + private static string _monacoDirectory; + + public static string GetRuntimeMonacoDirectory() + { + string codeBase = Assembly.GetExecutingAssembly().Location; + string path = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(codeBase) ?? string.Empty, "Assets", "Monaco")); + if (Path.Exists(path)) + { + return path; + } + else + { + // We're likely in WinUI3Apps directory and need to go back to the base directory. + return Path.GetFullPath(Path.Combine(Path.GetDirectoryName(codeBase) ?? string.Empty, "..", "Assets", "Monaco")); + } + } + + public static string MonacoDirectory + { + get + { + if (string.IsNullOrEmpty(_monacoDirectory)) + { + _monacoDirectory = GetRuntimeMonacoDirectory(); + } + + return _monacoDirectory; + } + } + } +} diff --git a/src/modules/registrypreview/RegistryPreviewUILib/RegistryPreviewMainPage.Events.cs b/src/modules/registrypreview/RegistryPreviewUILib/RegistryPreviewMainPage.Events.cs index 624b104a01..0df3a5c0f5 100644 --- a/src/modules/registrypreview/RegistryPreviewUILib/RegistryPreviewMainPage.Events.cs +++ b/src/modules/registrypreview/RegistryPreviewUILib/RegistryPreviewMainPage.Events.cs @@ -8,9 +8,9 @@ using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; -using System.Threading.Tasks; using CommunityToolkit.WinUI.UI.Controls; +using Microsoft.UI.Dispatching; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Data; @@ -21,6 +21,8 @@ namespace RegistryPreviewUILib { public sealed partial class RegistryPreviewMainPage : Page { + private readonly DispatcherQueue _dispatcherQueue = DispatcherQueue.GetForCurrentThread(); + /// /// Event that is will prevent the app from closing if the "save file" flag is active /// @@ -40,43 +42,25 @@ namespace RegistryPreviewUILib resourceLoader.GetString("YesNoCancelDialogSecondaryButtonText"), resourceLoader.GetString("YesNoCancelDialogCloseButtonText")); } - - // Check to see if the textbox's context menu is open - if (textBox.ContextFlyout != null && textBox.ContextFlyout.IsOpen) - { - textBox.ContextFlyout.Hide(); - - // if true, the app will not close yet - args.Handled = true; - - // HACK: To fix https://github.com/microsoft/PowerToys/issues/28820, wait a bit for the close animation of the flyout to run before closing the application. - // This might be called many times if the flyout still hasn't been closed, as Window_Closed will be called again by App.Current.Exit - DispatcherQueue.TryEnqueue(async () => - { - await Task.Delay(100); - Application.Current.Exit(); - }); - return; - } } /// /// Event that gets fired after the visual tree has been fully loaded; the app opens the reg file from here so it can show a message box successfully /// - private void GridPreview_Loaded(object sender, RoutedEventArgs e) + private async void GridPreview_Loaded(object sender, RoutedEventArgs e) { // static flag to track whether the Visual Tree is ready - if the main Grid has been loaded, the tree is ready. visualTreeReady = true; // Check to see if the REG file was opened and parsed successfully - if (OpenRegistryFile(_appFileName) == false) + if (await OpenRegistryFile(_appFileName) == false) { if (File.Exists(_appFileName)) { // Allow Refresh and Edit to be enabled because a broken Reg file might be fixable UpdateToolBarAndUI(false, true, true); _updateWindowTitleFunction(resourceLoader.GetString("InvalidRegistryFileTitle")); - textBox.TextChanged += TextBox_TextChanged; + MonacoEditor.TextChanged += MonacoEditor_TextChanged; return; } else @@ -87,10 +71,10 @@ namespace RegistryPreviewUILib } else { - textBox.TextChanged += TextBox_TextChanged; + MonacoEditor.TextChanged += MonacoEditor_TextChanged; } - textBox.Focus(FocusState.Programmatic); + MonacoEditor.Focus(FocusState.Programmatic); } /// @@ -153,16 +137,15 @@ namespace RegistryPreviewUILib if (storageFile != null) { // mute the TextChanged handler to make for clean UI - textBox.TextChanged -= TextBox_TextChanged; - + MonacoEditor.TextChanged -= MonacoEditor_TextChanged; _appFileName = storageFile.Path; - UpdateToolBarAndUI(OpenRegistryFile(_appFileName)); + UpdateToolBarAndUI(await OpenRegistryFile(_appFileName)); // disable the Save button as it's a new file saveButton.IsEnabled = false; // Restore the event handler as we're loaded - textBox.TextChanged += TextBox_TextChanged; + MonacoEditor.TextChanged += MonacoEditor_TextChanged; } } @@ -177,7 +160,7 @@ namespace RegistryPreviewUILib /// /// Uses a picker to save out a copy of the current reg file /// - private void SaveAsButton_Click(object sender, RoutedEventArgs e) + private async void SaveAsButton_Click(object sender, RoutedEventArgs e) { // Save out a new REG file and then open it - we have to use the direct Win32 method because FileOpenPicker crashes when it's // called while running as admin @@ -195,24 +178,24 @@ namespace RegistryPreviewUILib _appFileName = filename; SaveFile(); - UpdateToolBarAndUI(OpenRegistryFile(_appFileName)); + UpdateToolBarAndUI(await OpenRegistryFile(_appFileName)); } /// /// Reloads the current REG file from storage /// - private void RefreshButton_Click(object sender, RoutedEventArgs e) + private async void RefreshButton_Click(object sender, RoutedEventArgs e) { // mute the TextChanged handler to make for clean UI - textBox.TextChanged -= TextBox_TextChanged; + MonacoEditor.TextChanged -= MonacoEditor_TextChanged; // reload the current Registry file and update the toolbar accordingly. - UpdateToolBarAndUI(OpenRegistryFile(_appFileName), true, true); + UpdateToolBarAndUI(await OpenRegistryFile(_appFileName), true, true); saveButton.IsEnabled = false; // restore the TextChanged handler - textBox.TextChanged += TextBox_TextChanged; + MonacoEditor.TextChanged += MonacoEditor_TextChanged; } /// @@ -364,12 +347,15 @@ namespace RegistryPreviewUILib } /// - /// When the text in textBox changes, reload treeView and possibly dataGrid and reset the save button + /// When the text in editor changes, reload treeView and possibly dataGrid and reset the save button /// - private void TextBox_TextChanged(object sender, TextChangedEventArgs e) + private void MonacoEditor_TextChanged(object sender, EventArgs e) { - RefreshRegistryFile(); - saveButton.IsEnabled = true; + _dispatcherQueue.TryEnqueue(() => + { + RefreshRegistryFile(); + saveButton.IsEnabled = true; + }); } } } diff --git a/src/modules/registrypreview/RegistryPreviewUILib/RegistryPreviewMainPage.Utilities.cs b/src/modules/registrypreview/RegistryPreviewUILib/RegistryPreviewMainPage.Utilities.cs index 6c85c08ddf..daae306006 100644 --- a/src/modules/registrypreview/RegistryPreviewUILib/RegistryPreviewMainPage.Utilities.cs +++ b/src/modules/registrypreview/RegistryPreviewUILib/RegistryPreviewMainPage.Utilities.cs @@ -11,7 +11,8 @@ using System.IO; using System.Linq; using System.Reflection; using System.Text; - +using System.Threading; +using System.Threading.Tasks; using Microsoft.UI.Input; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; @@ -21,12 +22,14 @@ namespace RegistryPreviewUILib { public sealed partial class RegistryPreviewMainPage : Page { + private static SemaphoreSlim _dialogSemaphore = new(1); + public delegate void UpdateWindowTitleFunction(string title); /// /// Method that opens and processes the passed in file name; expected to be an absolute path and a first time open /// - private bool OpenRegistryFile(string filename) + private async Task OpenRegistryFile(string filename) { // clamp to prevent attempts to open a file larger than 10MB try @@ -46,7 +49,7 @@ namespace RegistryPreviewUILib // Disable parts of the UI that can cause trouble when loading ChangeCursor(gridPreview, true); - textBox.Text = string.Empty; + await MonacoEditor.SetTextAsync(string.Empty); // clear the treeView and dataGrid no matter what treeView.RootNodes.Clear(); @@ -55,7 +58,7 @@ namespace RegistryPreviewUILib // update the current window's title with the current filename _updateWindowTitleFunction(filename); - // Load in the whole file in one call and plop it all into textBox + // Load in the whole file in one call and plop it all into editor FileStream fileStream = null; try { @@ -68,15 +71,15 @@ namespace RegistryPreviewUILib StreamReader streamReader = new StreamReader(fileStream); string filenameText = streamReader.ReadToEnd(); - textBox.Text = filenameText; + await MonacoEditor.SetTextAsync(filenameText); streamReader.Close(); } catch { // restore TextChanged handler to make for clean UI - textBox.TextChanged += TextBox_TextChanged; + MonacoEditor.TextChanged += MonacoEditor_TextChanged; - // Reset the cursor but leave textBox disabled as no content got loaded + // Reset the cursor but leave editor disabled as no content got loaded ChangeCursor(gridPreview, false); return false; } @@ -89,8 +92,8 @@ namespace RegistryPreviewUILib } } - // now that the file is loaded and in textBox, parse the data - ParseRegistryFile(textBox.Text); + // now that the file is loaded and in editor, parse the data + ParseRegistryFile(MonacoEditor.Text); // Getting here means that the entire REG file was parsed without incident // so select the root of the tree and celebrate @@ -120,8 +123,8 @@ namespace RegistryPreviewUILib treeView.RootNodes.Clear(); ClearTable(); - // the existing text is still in textBox so parse the data again - ParseRegistryFile(textBox.Text); + // the existing text is still in editor so parse the data again + ParseRegistryFile(MonacoEditor.Text); // check to see if there was a key in treeView before the refresh happened if (currentNode != null) @@ -164,7 +167,7 @@ namespace RegistryPreviewUILib } /// - /// Parses the text that is passed in, which should be the same text that's in textBox + /// Parses the text that is passed in, which should be the same text that's in editor /// private bool ParseRegistryFile(string filenameText) { @@ -181,10 +184,10 @@ namespace RegistryPreviewUILib // As we'll be processing the text one line at a time, this string will be the current line string registryLine; - // Brute force editing: for textBox to show Cr-Lf corrected, we need to strip out the \n's + // Brute force editing: for editor to show Cr-Lf corrected, we need to strip out the \n's filenameText = filenameText.Replace("\r\n", "\r"); - // split apart all of the text in textBox, where one element in the array represents one line + // split apart all of the text in editor, where one element in the array represents one line string[] registryLines = filenameText.Split("\r"); if (registryLines.Length <= 1) { @@ -655,8 +658,8 @@ namespace RegistryPreviewUILib } /// - /// Enable command bar buttons and textBox. - /// Note that writeButton and textBox all update with the same value on purpose + /// Enable command bar buttons + /// Note that writeButton and editor all update with the same value on purpose /// private void UpdateToolBarAndUI(bool enableWrite, bool enableRefresh, bool enableEdit) { @@ -776,21 +779,34 @@ namespace RegistryPreviewUILib /// private async void ShowMessageBox(string title, string content, string closeButtonText) { - ContentDialog contentDialog = new ContentDialog() + if (_dialogSemaphore.CurrentCount == 0) { - Title = title, - Content = content, - CloseButtonText = closeButtonText, - }; - - // Use this code to associate the dialog to the appropriate AppWindow by setting - // the dialog's XamlRoot to the same XamlRoot as an element that is already present in the AppWindow. - if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8)) - { - contentDialog.XamlRoot = this.Content.XamlRoot; + return; } - await contentDialog.ShowAsync(); + try + { + await _dialogSemaphore.WaitAsync(); + ContentDialog contentDialog = new ContentDialog() + { + Title = title, + Content = content, + CloseButtonText = closeButtonText, + }; + + // Use this code to associate the dialog to the appropriate AppWindow by setting + // the dialog's XamlRoot to the same XamlRoot as an element that is already present in the AppWindow. + if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8)) + { + contentDialog.XamlRoot = this.Content.XamlRoot; + } + + await contentDialog.ShowAsync(); + } + finally + { + _dialogSemaphore.Release(); + } } /// @@ -894,7 +910,7 @@ namespace RegistryPreviewUILib } /// - /// Wrapper method that saves the current file in place, using the current text in textBox. + /// Wrapper method that saves the current file in place, using the current text in editor. /// private void SaveFile() { @@ -914,8 +930,8 @@ namespace RegistryPreviewUILib fileStream = new FileStream(_appFileName, fileStreamOptions); StreamWriter streamWriter = new StreamWriter(fileStream, System.Text.Encoding.Unicode); - // if we get here, the file is open and writable so dump the whole contents of textBox - string filenameText = textBox.Text; + // if we get here, the file is open and writable so dump the whole contents of editor + string filenameText = MonacoEditor.Text; streamWriter.Write(filenameText); streamWriter.Flush(); streamWriter.Close(); diff --git a/src/modules/registrypreview/RegistryPreviewUILib/RegistryPreviewMainPage.xaml b/src/modules/registrypreview/RegistryPreviewUILib/RegistryPreviewMainPage.xaml index f5e0c6ee1a..058663459e 100644 --- a/src/modules/registrypreview/RegistryPreviewUILib/RegistryPreviewMainPage.xaml +++ b/src/modules/registrypreview/RegistryPreviewUILib/RegistryPreviewMainPage.xaml @@ -3,6 +3,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:local="using:RegistryPreviewUILib" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:tk7controls="using:CommunityToolkit.WinUI.UI.Controls" xmlns:tkcontrols="using:CommunityToolkit.WinUI.Controls" @@ -133,28 +134,12 @@ - + IsTabStop="True" /> + Library @@ -39,6 +40,12 @@ + + + + + + @@ -52,4 +59,10 @@ Always + + + + MSBuild:Compile + + diff --git a/src/modules/registrypreview/RegistryPreviewUILib/Strings/en-US/Resources.resw b/src/modules/registrypreview/RegistryPreviewUILib/Strings/en-US/Resources.resw index d637b2e187..580d108d9a 100644 --- a/src/modules/registrypreview/RegistryPreviewUILib/Strings/en-US/Resources.resw +++ b/src/modules/registrypreview/RegistryPreviewUILib/Strings/en-US/Resources.resw @@ -199,9 +199,6 @@ New Registry file - - Registry file text will appear here - Registry Preview