🚧 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 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
)Ctrl-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.razor
See 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.git
npm install npx
run dotnet clean
followed by dotnet build
CodeMirror6/NodeLib/src/index.ts
CodeMirror6/CodeMirrorJsInterop.cs
CodeMirror6Wrapper.razor.cs
CodeMirror6Wrapper.razor
and CodeMirror6Wrapper.razor.cs
Examples.Common/Example.razor
The Node project is automatically built with the .Net project.
dotnet clean
will delete the node_modules
directory. Then run dotnet build
again.<HeadOutlet @rendermode="InteractiveServer" />
in the head
section of App.razor
. Not doing so will break the editor when navigating to it after the initial page load.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>