Enterprise-level component library based on Bootstrap and Blazor
gitee
version
license
download
repo
commit
build
coverage

Markdown

A text editor that provides support for the Markdown syntax

Precautions :

This component relies on BootstrapBlazor.Markdown, which needs to reference its component package when using this component

Nuget package installation

Install the components of BootstrapBlazor.Markdown using nuget.org

.NET CLI
dotnet add package BootstrapBlazor.Markdown --version latest
PackageReference
<PackageReference Include="BootstrapBlazor.Markdown" Version="latest" />
Package Manager
Install-Package BootstrapBlazor.Markdown -Version latest

CSS file

dynamic import css

JS file

dynamic import javascript

Localization

The default setting

Demo

Once you Markdown code, click on the relevant area below to display the data

Get Markdown display with Webapi

Demo

Change the default parameters

Demo

Set the minimum height of the Markdown Editor 300px, the default height 500px, indicating that this is the Markdown, tab display, the default display of the WYSIWYG page

Simple browsing mode, not editable

Demo

Set the markdown editor to browse-only mode, IsViewer='true'

Dark mode

Demo

Enable plugins with EnableHighlight=true, highlighting using ``` followed by code formatting, and js highlight syntax for example ```js

Demo

Using APIs to manipulate the Editor from the outside, the specific API reference tui.editor api

Demo

Check data validity and prompt automatically based on custom validation rules

Demo

Attributes

Loading...
@page "/markdowns"
@using Microsoft.Extensions.DependencyInjection
@inject VersionService VersionManager
@inject IStringLocalizer<Markdowns> Localizer

<h3>Markdown</h3>

<h4>A text editor that provides support for the Markdown syntax</h4>

<p><b>Precautions :</b></p>

<p>This component relies on <a href='https://www.nuget.org/packages?q-BootstrapBlazor.Markdown' target'_blank'><code>BootstrapBlazor.Markdown</code></a>, which needs to reference its component package when using this component</p>

<p><b>Nuget package installation</b></p>

<p>Install the</code> components of <code>BootstrapBlazor.Markdown using <a href='https://www.nuget.org/packages?q-BootstrapBlazor.Markdown' target'_blank'>nuget.org</a></p>

<div class="code-label">.NET CLI</div>
<Pre class="no-highlight">dotnet add package BootstrapBlazor.Markdown --version @Version</Pre>

<div class="code-label">PackageReference</div>
<Pre class="no-highlight"><PackageReference Include="BootstrapBlazor.Markdown" Version="@Version" /></Pre>

<div class="code-label">Package Manager</div>
<Pre class="no-highlight">Install-Package BootstrapBlazor.Markdown -Version @Version</Pre>

<h4>CSS file</h4>

<p>dynamic import css</p>

<h4>JS file</h4>

<p>dynamic import javascript</p>

<h4>Localization</h4>

<Tips>The component has a built-in Chinese to switch between current cultural information for Chinese</Tips>

<DemoBlock Title="Common usage" Introduction="The default setting" Name="Normal">
    <p>Once you <code>Markdown</code> code, click on the relevant area below to display the data</p>
    <div style="width: 100%; height: 300px;">
        <Markdown Language="@Language" @bind-Value="@MarkdownString" @bind-Html="@HtmlString" />
    </div>
    <div class="mt-3">
        <textarea class="form-control" rows="6" disabled="disabled">
            @MarkdownString
        </textarea>
    </div>
    <div class="mt-3">
        <textarea class="form-control" rows="6" disabled="disabled">
            @HtmlString
        </textarea>
    </div>
</DemoBlock>

<DemoBlock Title="Load the data asynchronously" Introduction="Get <code>Markdown</code> display with <code>Webapi</code>" Name="Async">
    <Button Text="load" IsAsync="true" OnClick="GetAsyncString" Icon="fa fa-fa" class="mb-3" />
    <Markdown Value="@AsyncValue" @ref="MarkdownSetValue"></Markdown>
</DemoBlock>

<DemoBlock Title="Common properties" Introduction="Change the default parameters" Name="CommonProperty">
    <p>Set the minimum height of the <code>Markdown</code> Editor <code>300px</code>, the default height <code>500px</code>, indicating that this is the <code>Markdown</code>, <code>tab</code> display, the default display of the WYSIWYG page</p>
    <Markdown Height="500" MinHeight="300" Placeholder="This is Markdown" PreviewStyle="PreviewStyle.Tab" InitialEditType="InitialEditType.Wysiwyg" Language="@Language"></Markdown>
</DemoBlock>

<DemoBlock Title="Browser mode" Introduction="Simple browsing mode, not editable" Name="IsViewer">
    <p>Set the <code>markdown</code> editor to browse-only mode, <code>IsViewer='true'</code></p>
    <Markdown IsViewer="true" Value="# Viewer Mode"></Markdown>
</DemoBlock>

<DemoBlock Title="Dark mode" Introduction="Dark mode" Name="IsDark">
    <Markdown IsDark="true" Value="# Dark Mode"></Markdown>
</DemoBlock>

<DemoBlock Title="Enable the code highlighting plugin" Introduction="Enable plugins with <code>EnableHighlight=true</code>, highlighting using ``` followed by code formatting, and js highlight syntax for example ```js" Name="EnableHighlight">
    <Markdown EnableHighlight="true" Value="@JsString"></Markdown>
</DemoBlock>

<DemoBlock Title="External operation Markdown" Introduction="Using APIs to manipulate the Editor from the outside, the specific API reference <a href='https://nhn.github.io/tui.editor/latest/ToastUIEditorCore'>tui.editor api</a>" Name="Browser">
    <Markdown @ref="Markdown"></Markdown>
    <div class="mt-3">
        <Button OnClickWithoutRender="@(async () => await Markdown.DoMethodAsync("insertText", "# test"))">Insert a line of text</Button>
        <Button OnClickWithoutRender="@(async () => await Markdown.DoMethodAsync("insertText", $"![{Localizer["BrowserText"]}](https://i.niupic.com/images/2022/04/01/9Y6T.jpg)"))">Insert a picture</Button>
        <Button OnClickWithoutRender="@(async () => await Markdown.DoMethodAsync("moveCursorToEnd"))">The cursor moves to the end</Button>
    </div>
</DemoBlock>

<DemoBlock Title="Validate" Introduction="Check data validity and prompt automatically based on custom validation rules" Name="Validate">
    <ValidateForm Model="@Model">
        <div class="row g-3 form-inline">
            <div class="col-12">
                <Markdown @bind-Value="Model.Name"></Markdown>
            </div>
            <div class="col-12">
                <Button ButtonType="ButtonType.Submit" Icon="fa fa-fw fa-save" Text="Save" />
            </div>
        </div>
    </ValidateForm>
</DemoBlock>

<AttributeTable Items="GetAttributes()"></AttributeTable>
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

using BootstrapBlazor.Components;
using BootstrapBlazor.Shared.Common;
using System.Globalization;

namespace BootstrapBlazor.Shared.Samples;

/// <summary>
/// Markdown 示例代码
/// </summary>
public partial class Markdowns
{
    private string? MarkdownString { get; set; }

    private string? HtmlString { get; set; }

    /// <summary>
    /// 获得/设置 版本号字符串
    /// </summary>
    private string Version { get; set; } = "fetching";

    private string? Language { get; set; }

    private string? AsyncValue { get; set; }

    private string JsString { get; set; } = @"```js
console.log('test');
```";

    [NotNull]
    private Markdown? Markdown { get; set; }

    [NotNull]
    private Markdown? MarkdownSetValue { get; set; }

    [NotNull]
    private Foo? Model { get; set; }

    /// <summary>
    /// OnInitializedAsync 方法
    /// </summary>
    /// <returns></returns>
    protected override async Task OnInitializedAsync()
    {
        Model = new() { Name = "Name", Education = EnumEducation.Primary, DateTime = DateTime.Now };

        Language = CultureInfo.CurrentUICulture.Name;
        MarkdownString = $"### {Localizer["MarkdownString"]}";
        Version = await VersionManager.GetVersionAsync("bootstrapblazor.markdown");
    }

    private async Task GetAsyncString()
    {
        await Task.Delay(600);
        AsyncValue = $"### {DateTime.Now}";
        await MarkdownSetValue.SetValue(AsyncValue);
    }

    private IEnumerable<AttributeItem> GetAttributes() => new AttributeItem[]
    {
        new AttributeItem(){
            Name = "Height",
            Description = Localizer["Att1"],
            Type = "int",
            ValueList = " — ",
            DefaultValue = "300"
        },
        new AttributeItem(){
            Name = "MinHeight",
            Description = Localizer["Att2"],
            Type = "int",
            ValueList = " — ",
            DefaultValue = "200"
        },
        new AttributeItem(){
            Name = "InitialEditType",
            Description = Localizer["Att3"],
            Type = "InitialEditType",
            ValueList = "Markdown/Wysiwyg",
            DefaultValue = "Markdown"
        },
        new AttributeItem(){
            Name = "PreviewStyle",
            Description = Localizer["Att4"],
            Type = "PreviewStyle",
            ValueList = "Tab/Vertical",
            DefaultValue = "Vertical"
        },
        new AttributeItem(){
            Name = "Language",
            Description = Localizer["Att5"],
            Type = "string",
            ValueList = " — ",
            DefaultValue = " — "
        },
        new AttributeItem(){
            Name = "Placeholder",
            Description = Localizer["Att6"],
            Type = "string",
            ValueList = " — ",
            DefaultValue = " — "
        },
        new AttributeItem(){
            Name = "IsViewer",
            Description = Localizer["Att7"],
            Type = "bool",
            ValueList = " true/false ",
            DefaultValue = " false "
        },
        new AttributeItem(){
            Name = "IsDark",
            Description = Localizer["Att8"],
            Type = "bool",
            ValueList = " true/false ",
            DefaultValue = " false "
        },
        new AttributeItem(){
            Name = "EnableHighlight",
            Description = Localizer["Att9"],
            Type = "bool",
            ValueList = " true/false ",
            DefaultValue = " false "
        }
    };
}

B 站相关视频链接

暂无

交流群

QQ Group:BootstrapAdmin & Blazor 795206915 675147445 Welcome to join the group discussion
Themes
Bootstrap
Motronic
Ant Design (完善中)
LayUI (完善中)
An error has occurred. This application may no longer respond until reloaded. Reload
Seems like the connection with the server has been lost. It can be due to poor or broken network. Please hang on while we're trying to reconnect...
Oh snap! Failed to reconnect with the server. This is typically caused by a longer network outage, or if the server has been taken down. You can try to reconnect, but if that does not work, you need to reload the page.
Oh man! The server rejected the attempt to reconnect. The only option now is to reload the page, but be prepared that it won't work, since this is typically caused by a failure on the server.
Bootstrap Blazor 组件库 更新到 6.6.0

首先感谢您对本套组件的关注,本目前本套组件已经拥有超过 120 个组件,本组件是基于 Bootstrap 风格的 Blazor 企业级组件库,提供如布局、导航、表单、数据、通知、图标、语音等几大类通用组件,每一个组件都经过静心设计,具有模块化、响应式和优秀的性能。从更多实际场景出发,满足多种场景的需求,极大的减少开发者时间成本,大大缩短开发周期,大幅提高开发效率,并提供了一套 通用权限管理系统 示例工程。Bootstrap Blazor 产品是由一支专业的全职技术团队进行维护,高效的响应速度,多元化的解决方案,长期提供支持,并提供企业级支持。目前已在多家知名国企内部使用,项目最高在线 1200 人稳定运行。右侧为国内人数最多的中文 Blazor QQ 社区二维码,欢迎扫描加群。

组件更新到 6.6.0 更新日志 [传送门] 如果组件给您带来了方便,请您帮忙给项目点亮 Star github gitee

QQGroup
QQ 795206915