Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/balder1840/blazor.cherrydown
A blazor markdown editor
https://github.com/balder1840/blazor.cherrydown
blazor markdown markdown-editor markdown-viewer
Last synced: 1 day ago
JSON representation
A blazor markdown editor
- Host: GitHub
- URL: https://github.com/balder1840/blazor.cherrydown
- Owner: Balder1840
- License: mit
- Created: 2024-03-13T01:28:41.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-05-31T12:38:17.000Z (8 months ago)
- Last Synced: 2025-01-20T15:47:59.270Z (2 days ago)
- Topics: blazor, markdown, markdown-editor, markdown-viewer
- Language: C#
- Homepage:
- Size: 11.5 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Blazor.Cherrydown
A blazor markdown editor wraps of [cherry-markdown](https://github.com/Tencent/cherry-markdown) from Tencent.# Features
- [x] Edit and preview mode.
- [x] Pre-defined toolbar.
- [x] Streaming file uploading(inspired by the built-in `InputFile` component).
- [x] Add auto numbers for TOC.
- [x] Other functionalities that `cherry-markdown` provided.# Getting started
## Install the package, or download the project and reference it.
```
dotnet add package Blazor.Cherrydown
```## Add the following using statement in _Imports.razor.
```razor
@using Blazor.Cherrydown
```> do not need to add the reference to the `javascript` and `CSS`, `Blazor.Cherrydown` will do it for you.
> for more into, you can refer to [blazor initializer](https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/startup?view=aspnetcore-8.0#javascript-initializers)## Add Cherrydown in a page
```razor
Change Markdown@code {
private string? _markdown = "# CherrydownEditor";protected override void OnParametersSet()
{
using var reader = new System.IO.StreamReader(@"basic.md");
_markdown = reader.ReadToEnd();
base.OnParametersSet();
}void ChangeMarkdown()
{
_markdown = "# Changed Markdown";
}private async Task SaveFile(FileUpload.IBrowserFile file)
{
var workDir = _config.GetValue("WorkDir");
var workDirVirtualPath = _config.GetValue("WorkDirVirtualPath");await using FileStream fs = new(Path.Combine(workDir, file.Name), FileMode.Create);
await file.OpenReadStream(15 * 1024 * 1024).CopyToAsync(fs);return new FileUploadResult { FileUri = $"{workDirVirtualPath}/{file.Name}" };
}
}
```