EasyMDE.Blazor
1.0.5
dotnet add package EasyMDE.Blazor --version 1.0.5
NuGet\Install-Package EasyMDE.Blazor -Version 1.0.5
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EasyMDE.Blazor" Version="1.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EasyMDE.Blazor" Version="1.0.5" />
<PackageReference Include="EasyMDE.Blazor" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add EasyMDE.Blazor --version 1.0.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: EasyMDE.Blazor, 1.0.5"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package EasyMDE.Blazor@1.0.5
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=EasyMDE.Blazor&version=1.0.5
#tool nuget:?package=EasyMDE.Blazor&version=1.0.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
EasyMDE.Blazor
A Blazor wrapper around EasyMDE with:
- Two-way binding (
@bind-Value) - Strongly-typed EasyMDE options (no
object-typed option surface) - Strongly-typed
Toolbar,Status, andReadOnlyunions - Optional key interception (fast-path in JavaScript; only calls .NET for registered keys)
- Optional ability to block specific keys (e.g., prevent
Enterfrom inserting a newline)
Package goals
- Keep the C# API strongly typed (simple primitives/enums/unions)
- Keep the JavaScript surface minimal
- Support Blazor Server and Blazor WebAssembly
- Avoid editor churn and event loops (programmatic
Valueupdates don’t re-trigger input handlers)
Installation
In your Blazor application, load the bundled EasyMDE stylesheet and script files:
<link rel="stylesheet" href="_content/EasyMDE.Blazor/lib/easymde/easymde.min.css" />
<script src="_content/EasyMDE.Blazor/lib/easymde/easymde.min.js"></script>
Basic usage
@using EasyMDE.Blazor
<EasyMdeEditor @bind-Value="Markdown" />
@code {
private string? Markdown = "# Hello";
}
Strongly-typed options
<EasyMdeEditor @bind-Value="Markdown" Options="Options" />
@code {
private string? Markdown;
private readonly EasyMdeOptions Options = new()
{
Placeholder = "Write markdown...",
MinHeight = "300px",
Toolbar = EasyMdeToolbar.Custom(new ToolbarItem[]
{
ToolbarItem.BuiltIn(ToolbarButton.Bold),
ToolbarItem.BuiltIn(ToolbarButton.Italic),
ToolbarItem.Separator,
ToolbarItem.BuiltIn(ToolbarButton.Preview),
ToolbarItem.BuiltIn(ToolbarButton.Fullscreen),
}),
Status = EasyMdeStatus.Custom(new StatusItem[]
{
StatusItem.BuiltIn(StatusElement.Lines),
StatusItem.BuiltIn(StatusElement.Words),
StatusItem.BuiltIn(StatusElement.Cursor),
}),
ReadOnly = EasyMdeReadOnly.Disabled
};
}
ReadOnly modes
ReadOnly = EasyMdeReadOnly.Disabled; // editable (readOnly: false)
ReadOnly = EasyMdeReadOnly.Enabled; // readOnly: true
ReadOnly = EasyMdeReadOnly.NoCursor; // readOnly: "nocursor"
Key interception and blocking (fast-path)
To avoid sending every keystroke to .NET (especially on Blazor Server), the wrapper supports pre-registered key filters.
- JS listens to
keydown - If the key is not registered, nothing happens (fast-path)
- If the key is registered:
BlockInJs = trueblocks synchronously with no .NET callNotifyDotNet = truecalls.NET(no blocking guarantee, just notification)AskDotNet = truecalls.NETfor an allow/deny decision (see notes below)
Block Enter from inserting a newline (no .NET round-trip)
<EasyMdeEditor @bind-Value="Markdown"
InterceptKeys="Keys" />
@code {
private string? Markdown;
private readonly EasyMdeKeyRegistration[] Keys =
[
new()
{
Key = "Enter",
BlockInJs = true
}
];
}
Notify .NET on Ctrl+S (save)
<EasyMdeEditor @bind-Value="Markdown"
InterceptKeys="Keys"
OnKey="HandleKey" />
@code {
private string? Markdown;
private readonly EasyMdeKeyRegistration[] Keys =
[
new() { Key = "s", Ctrl = true, NotifyDotNet = true }
];
private ValueTask<bool> HandleKey(EasyMdeKeyEvent e)
{
if (e.Ctrl && (e.Key is "s" or "S"))
{
// trigger save
}
return ValueTask.FromResult(true);
}
}
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- Microsoft.AspNetCore.Components.Web (>= 9.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on EasyMDE.Blazor:
| Repository | Stars |
|---|---|
|
LANCommander/LANCommander
|