serdarciplak / BlazorMonaco

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

Use with monaco-yaml #59

Closed JBBianchi closed 1 year ago

JBBianchi commented 2 years ago

Hello,

I've been trying to use monaco-yaml with BlazorMonaco but I wasn't able to achieve it. I think the problem is the limitation of monaco-yaml to be used as ESM only where BlazorMonaco uses the UMD flavor. I saw an issue about it but I didn't manage to make it work, I assume the issue is outdated with the latest version of monaco-yaml.

Did anybody succeed making those two beautiful projects work together?

JBBianchi commented 1 year ago

I manage to get it to work.

For those interested, you can replace those lines in your index.html:

- <script src="_content/BlazorMonaco/lib/monaco-editor/min/vs/loader.js"></script>
- <script src="_content/BlazorMonaco/lib/monaco-editor/min/vs/editor/editor.main.js"></script>
+ <script src="https://cdn.jsdelivr.net/npm/monaco-yaml-prebuilt/dist/monaco-editor.min.js"></script>

By default, monaco-yaml-prebuilt only supports JSON and YAML but you can compile your own version with other languages if you wish.