Blazor CodeMirror 6 brings the power of the [CodeMirror 6](https://codemirror.net/) code editor to Blazor, offering a comprehensive .NET 6 / .NET 7 / .NET 8 / .NET 9 component. It's tailored for both general and specialized use-cases, supporting a range of languages and Markdown editing, extensive support for syntax highlighting, auto-completion, custom linting, themes, Markdown preview, and more.
$ dotnet add package GaelJ.BlazorCodeMirror6🚧 This project is still a work-in-progress 🚧
Blazor CodeMirror 6 brings the power of the CodeMirror 6 code editor to Blazor, offering a comprehensive .NET 6 / .NET 7 / .NET 8 / .NET 9 component. It's tailored for both general and specialized use-cases, supporting a range of languages and Markdown editing, extensive support for syntax highlighting, auto-completion, custom linting, themes, Markdown preview, and more.
Visit the live demo to see the component's capabilities.
textarea)<HeadOutlet /> requiredCtrl-B) or italic (Ctrl-I)@using GaelJ.BlazorCodeMirror6, @using GaelJ.BlazorCodeMirror6.Commands and @using GaelJ.BlazorCodeMirror6.Models in your _Imports.razor or page/component<CodeMirror6Wrapper /> component as demonstrated in Examples.Common/Example.razorSee Examples.Common/Example.razor
JS / CSS resources are loaded automatically (nothing to add in _Host.cshtml / index.html).
We welcome contributions!
git clone https://github.com/gaelj/BlazorCodeMirror6.gitnpm install npxrun dotnet clean followed by dotnet buildCodeMirror6/NodeLib/src/index.tsCodeMirror6/CodeMirrorJsInterop.csCodeMirror6Wrapper.razor.csCodeMirror6Wrapper.razor and CodeMirror6Wrapper.razor.csExamples.Common/Example.razorThe Node project is automatically built with the .Net project.
dotnet clean will delete the node_modules directory. Then run dotnet build again.See the Changelog
Blazor CodeMirror 6 is released under the MIT License. See the LICENSE for more details.
File an issue or open a discussion
Disclaimer: when a runtime error occurs in one of the demo / example projects, its details are sent to my private account on Sentry.io.
This is to help me detect and fix errors occurring on mobile platforms without the need for USB debugging, and to be informed of any errors that other users of the demo / example projects might encounter.
The component itself does not contain any tracking.
If you run the example projects locally and a runtime error occurs, some personal information will be sent to Sentry (OS, browser details, full path of the source file where the error occurred...)
If this makes you feel uncomfortable but you still wish to run the examples locally, you can disable Sentry by deleting:
Program.cs:builder.WebHost.UseSentry(o => {
o.Dsn = "https://d0ab79eee7b999c61d2c01fdf3958eeb@o4505402784546816.ingest.sentry.io/4506525909909504";
// When configuring for the first time, to see what the SDK is doing:
o.Debug = true;
// Set TracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
// We recommend adjusting this value in production.
o.TracesSampleRate = 1.0;
});
Examples.BlazorWasm/wwwroot/index.html (WASM example) or in Examples.BlazorServer/Pages/_Host.cshtml (Blazor Server example):<script
src="https://js.sentry-cdn.com/d0ab79eee7b999c61d2c01fdf3958eeb.min.js"
crossorigin="anonymous"
></script>