GaelJ.BlazorCodeMirror6
0.1.2
See the version list below for details.
dotnet add package GaelJ.BlazorCodeMirror6 --version 0.1.2
NuGet\Install-Package GaelJ.BlazorCodeMirror6 -Version 0.1.2
<PackageReference Include="GaelJ.BlazorCodeMirror6" Version="0.1.2" />
paket add GaelJ.BlazorCodeMirror6 --version 0.1.2
#r "nuget: GaelJ.BlazorCodeMirror6, 0.1.2"
// Install GaelJ.BlazorCodeMirror6 as a Cake Addin #addin nuget:?package=GaelJ.BlazorCodeMirror6&version=0.1.2 // Install GaelJ.BlazorCodeMirror6 as a Cake Tool #tool nuget:?package=GaelJ.BlazorCodeMirror6&version=0.1.2
Blazor CodeMirror 6
🚧 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.
Try It Out
Visit the live demo to see the component's capabilities.
Features
General
- 2-way-binding of the document contents
- setting tab size & indentation unit
- setting a placeholder text
- applying preset themes
- setting ReadOnly and Editable attributes
- applying syntax highlighting and auto-completion for 13 different languages
- manual resizing of the editor (similar to html
textarea
) - image preview
- custom linting
- insert text at cursor / at position
- allow undo / redo toolbar buttons
- configure which plugins are active at startup
- optionally scroll to the bottom of the document & place the cursor on the last line
- support long line wrapping
- support C# language
- update doc in dotnet either on text changes or on blur
- search & replace toolbar button
- toolbar with toolbar button template
- support read-only paragraphs
- diff viewer
- Implement cursor tooltips
- Implement Copilot/AI style suggestions
- allow setting the Starting selection
- Retrieve keybindings
- Highlight edited lines
- Allow toggling console debug mode
- collaborative editing
- voice recognition
- automatic translation
- deleting a file link deletes the file from the server
- button (visible when editor is hovered), to copy raw editor content to clipboard
Markdown specific
- apply Markdown syntax
- report Markdown syntax at selection(s)
- Resized header text proportional to header #
- keybindings to set text in bold (
Ctrl-B
) or italic (Ctrl-I
) - support emoji: replace on type
- format lists
- Implement @user mentions with dropdown list
- emojis: view :emoji_codes: in the raw text as the emoji
- emojis: add auto-complete
- Show horizontal rule instead of ------
- style Markdown quote lines and paragraphs
- add increase / decrease selected header (#) level
- format inline html
- support file uploads
- format links, make them clickable
- support mermaid language highlighting
- format tables
- support toolbar toggling of checklist items even if checked
- Implement kroki / mermaid preview
- support badges
- hide markdown control characters unless the selection is in the line
- Toggling-off a Markdown style should always select the whole styled text block
- Apply Markdown style toggles to whole words
- better highlight markdown inline code and code blocks
- use latest header
- customize markdown header sizes
- add color picker extension
Screenshots
Quick Start
- add the nuget package GaelJ.BlazorCodeMirror6
- Add
@using using GaelJ.BlazorCodeMirror6
,@using GaelJ.BlazorCodeMirror6.Commands
and@using GaelJ.BlazorCodeMirror6.Models.BlazorCodeMirror6
in your_Imports.razor
or page/component - Use the
<CodeMirror6Wrapper />
component as demonstrated inExamples.Common/Example.razor
Examples
See Examples.Common/Example.razor
JS / CSS resources are loaded automatically (nothing to add in _Host.cshtml
/ index.html
).
Contributing
We welcome contributions!
Local installation
- Clone the repository:
git clone https://github.com/gaelj/BlazorCodeMirror6.git
- Install node.js and npx:
npm install npx
- For build issues:
run dotnet clean
followed bydotnet build
Architecture
- The javascript-side initialization is in
CodeMirror6/NodeLib/src/index.ts
- Interop from .Net to JS is in
CodeMirror6/CodeMirrorJsInterop.cs
- Interop from JS to .Net is in
CodeMirror6Wrapper.razor.cs
- The blazor component is in
CodeMirror6Wrapper.razor
andCodeMirror6Wrapper.razor.cs
- The example component is in
Examples.Common/Example.razor
The Node project is automatically built with the .Net project.
FAQs / Troubleshooting
- If you have npm / rollup errors when building (for example after pulling recent changes),
dotnet clean
will delete thenode_modules
directory. Then rundotnet build
again.
Changelog
See the Changelog
License
Blazor CodeMirror 6 is released under the MIT License. See the LICENSE for more details.
Contact
File an issue or open a discussion
Error reporting
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:
- in
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;
});
- in
Examples.BlazorWasm/wwwroot/index.html
(WASM example) or inExamples.BlazorServer/Pages/_Host.cshtml
(Blazor Server example):
<script
src="https://js.sentry-cdn.com/d0ab79eee7b999c61d2c01fdf3958eeb.min.js"
crossorigin="anonymous"
></script>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Microsoft.AspNetCore.Components.Web (>= 6.0.25)
- Microsoft.AspNetCore.Http (>= 2.2.2)
-
net7.0
- Microsoft.AspNetCore.Components.Web (>= 7.0.0)
- Microsoft.AspNetCore.Http (>= 2.2.2)
-
net8.0
- Microsoft.AspNetCore.Components.Web (>= 8.0.0)
- Microsoft.AspNetCore.Http (>= 2.2.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on GaelJ.BlazorCodeMirror6:
Package | Downloads |
---|---|
ZauberCMS.Components
ZauberCMS components package |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.8.14 | 95 | 11/14/2024 |
0.8.13 | 71 | 11/14/2024 |
0.8.12 | 126 | 11/6/2024 |
0.8.11 | 193 | 10/22/2024 |
0.8.10 | 403 | 10/4/2024 |
0.8.9 | 509 | 7/13/2024 |
0.8.9-alpha.3 | 49 | 7/13/2024 |
0.8.9-alpha.2 | 50 | 7/13/2024 |
0.8.9-alpha.1 | 51 | 7/13/2024 |
0.8.8 | 152 | 6/16/2024 |
0.8.7 | 293 | 4/9/2024 |
0.8.6 | 326 | 4/9/2024 |
0.8.5 | 129 | 4/8/2024 |
0.8.4 | 113 | 4/8/2024 |
0.8.3 | 127 | 4/8/2024 |
0.8.2 | 152 | 3/4/2024 |
0.8.1 | 120 | 3/4/2024 |
0.8.0 | 116 | 3/3/2024 |
0.7.5 | 133 | 3/3/2024 |
0.7.4 | 133 | 3/1/2024 |
0.7.3 | 116 | 2/27/2024 |
0.7.2 | 125 | 2/25/2024 |
0.7.1 | 113 | 2/24/2024 |
0.7.0 | 121 | 2/20/2024 |
0.6.5 | 137 | 2/15/2024 |
0.6.4 | 146 | 2/14/2024 |
0.6.3 | 111 | 2/14/2024 |
0.6.2 | 112 | 2/14/2024 |
0.5.1 | 126 | 2/12/2024 |
0.5.0 | 124 | 2/12/2024 |
0.4.6 | 123 | 2/12/2024 |
0.4.4 | 110 | 2/11/2024 |
0.4.3 | 106 | 2/10/2024 |
0.4.2 | 124 | 2/10/2024 |
0.4.1 | 122 | 2/10/2024 |
0.4.0 | 121 | 2/10/2024 |
0.3.9 | 118 | 2/9/2024 |
0.3.8 | 147 | 2/8/2024 |
0.3.7 | 118 | 2/8/2024 |
0.3.6 | 118 | 2/8/2024 |
0.3.5 | 122 | 2/7/2024 |
0.3.4 | 113 | 2/6/2024 |
0.3.3 | 120 | 2/6/2024 |
0.3.2 | 118 | 2/6/2024 |
0.3.1 | 112 | 2/5/2024 |
0.3.0 | 108 | 2/5/2024 |
0.2.2 | 129 | 2/1/2024 |
0.2.1 | 97 | 1/31/2024 |
0.2.0 | 106 | 1/31/2024 |
0.1.3 | 134 | 1/21/2024 |
0.1.2 | 113 | 1/15/2024 |
0.1.1 | 112 | 1/15/2024 |
0.1.0 | 107 | 1/15/2024 |
0.0.3 | 132 | 1/13/2024 |
0.0.2 | 117 | 1/12/2024 |
0.0.1 | 118 | 1/12/2024 |