logoEnterprise-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 7.0.0
PackageReference
<PackageReference Include="BootstrapBlazor.Markdown" Version="7.0.0" />
Package Manager
Install-Package BootstrapBlazor.Markdown -Version 7.0.0

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-solid fa-font-awesome" 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-fw fa-solid fa-floppy-disk" 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 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 station related video link

No

交流群

QQ Group:BootstrapAdmin & Blazor 795206915 675147445 Welcome to join the group discussion
img
Themes
Bootstrap
Motronic
Ant Design (完善中)
DevUI (制作中)
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 Component library updated to 7.0.8-beta05

Bootstrap Blazor at present has more than 120 components. This component is based on Bootstrap Blazor An enterprise-level component library that provides several types of common components such as layout, navigation, form, data, notification, icon, voice, etc. Each component has been carefully designed with modularity, responsiveness and excellent performance. Starting from more practical scenarios, meeting the needs of various scenarios, greatly reducing the time cost of developers, greatly shortening the development cycle, greatly improving development efficiency, and providing a set of General Rights Management System Example project。Bootstrap Blazor Products are maintained by a professional full-time technical team, with efficient response speed, diversified solutions, long-term support, and enterprise-level support. At present, it has been used in many well-known state-owned enterprises, and the project is running stably with a maximum of 1200 people online. On the right is the QR code of the Chinese Blazor QQ community with the largest number of people in China, welcome to scan and join the group.

component updated to 6.6.0 Change log [portal] If the component brings you convenience, please help to light up the project Star github gitee

QQGroup
QQ 795206915