-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RegistryPreview] Adopt Monaco Editor #35122
[RegistryPreview] Adopt Monaco Editor #35122
Conversation
Does an on off switch (settings or RegistryPreviewUi) makes sense? 🤔 |
@htcfreek I think we can abstract the editor under an |
Only thought that not everybody like the colored view. And maybe with complex file it is easier to have no color than to have a rainbow. |
eb6a10e
to
3d2f944
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
94ad8f1
to
7fddb81
Compare
This is ready for review! 😃
|
Hi @stefansjfw Unfortunately there is no API to disable the command palette but I managed to achieve that with a few lines of JavaScript 😅 // Remove the command palette item from the context menu: https://github.com/microsoft/monaco-editor/issues/1280#issuecomment-2099873176
const contextmenu = editor.getContribution('editor.contrib.contextmenu');
const realMethod = contextmenu._getMenuActions;
contextmenu._getMenuActions = function () {
const items = realMethod.apply(contextmenu, arguments);
return items.filter(function (item) {
return item.id != 'editor.action.quickCommand';
});
};
// Prevent pressing F1 from opening the command palette
editor.addCommand(monaco.KeyCode.F1, function () { }); It's working fine and I am not against doing that, just keep in mind that some actions from the command palette are still accessible using the relative shortcut. Would like to know your thoughts about the solution before pushing the change. Thanks for the review! 😃 |
Wondering if disabling command palette is really needed. I mean, it does annoys the users. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Nice work!
Browser.CoreWebView2.Settings.IsScriptEnabled = true; | ||
Browser.CoreWebView2.Settings.IsWebMessageEnabled = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these two needed? can we turn them off?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double checked this before merge but we need them
Scripts of course are needed to run Monaco 😄
Web messages are used for the communication between Monaco and Registry Preview
PowerToys/src/modules/registrypreview/RegistryPreviewUILib/MonacoEditorControl.xaml.cs
Lines 112 to 114 in 2c21979
private void CoreWebView2_WebMessageReceived(CoreWebView2 sender, CoreWebView2WebMessageReceivedEventArgs args) | |
{ | |
var json = JsonNode.Parse(args.WebMessageAsJson); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it. thank you. feel free to merge whenever :)
let's leave it. It can be useful for some more power users that use RegPrev for editing and writing reg files |
This reverts commit f9127b6.
Summary of the Pull Request
PR Checklist
Detailed Description of the Pull Request / Additional comments
Easy reproducible on stable opening a new Registry Preview, typing fast on the TextBox and press Enter quickly
TODO
FilePreviewCommon
projectSimulate an upgrade ofPowerToys.RegistryPreviewUILib
NuGet package in DevHome and validate that Monaco is working as expectedInvestigate high contrast theme-vs
andvs-dark
theme are handled in HC modeValidation Steps Performed