serdarciplak / BlazorMonaco

Blazor component for Microsoft's Monaco Editor which powers Visual Studio Code.
https://serdarciplak.github.io/BlazorMonaco/
MIT License
454 stars 98 forks source link

Is there an option to prevent the user from editing certain lines? #70

Closed simonjung1603 closed 2 years ago

simonjung1603 commented 2 years ago

This seems to be a monaco issue where this feature is not present there. Anyways I was curious whether you deem it possible to utilize something like this plugin to leverage this functionality (demo) Do you think this (functionality not necessarily plugin) could be something to be considered to include in BlazorMonaco or could you offer some guidance as to how this could be achieved for users of BlazorMonaco.

I was trying to use the callbacks (e.g. OnEditorModelContentChanged, OnKeyDown) but they all broke down when typing fast. Probably because the round-trip to my server app is too long. Additionally this way I can only revert edits already done on the client. I was however looking for a way to prevent the edit in the first place.

serdarciplak commented 2 years ago

Thanks for the suggestion, but I'm not sure if it would be good to add new things to BlazorMonaco which does not exist in Monaco Editor. That would start to differentiate BlazorMonaco from MonacoEditor. But, instead, I'm currently working on syncing BlazorMonaco better with Monaco Editor (like class names, property and method names, etc).

I, personally, think that the best option for you would be to use js and Blazor side by side and having those checks on the js side. You can even use that same plugin you've sent.