ToastUIEditor 0.1.2
See the version list below for details.
dotnet add package ToastUIEditor --version 0.1.2
NuGet\Install-Package ToastUIEditor -Version 0.1.2
<PackageReference Include="ToastUIEditor" Version="0.1.2" />
paket add ToastUIEditor --version 0.1.2
#r "nuget: ToastUIEditor, 0.1.2"
// Install ToastUIEditor as a Cake Addin #addin nuget:?package=ToastUIEditor&version=0.1.2 // Install ToastUIEditor as a Cake Tool #tool nuget:?package=ToastUIEditor&version=0.1.2
ToastUI Editor Blazor
tui.editor.blazor
is a Blazor component that provides a Markdown editor based on the tui.editor library.
Installation
Install the package using following command:
Install-Package ToastUIEditor
or
dotnet add package ToastUIEditor
or just use nuget package manager.
Usage
- Add the following import statement to your
_Imports.razor
file
@using ToastUI
- Use the
Editor
component in your Blazor page or component
<Editor @bind-Value="content" Options="@options" />
@bind-Value
: Binds the editor's content to a string property in your Blazor component.Options
: Sets the configuration options for the editor. Refer to theEditorOptions
class for available options.
- Use the
Viewer
component in your Blazor page or component
<Viewer Value="@content" />
Value
: Sets the content to be displayed in the viewer. It will update automatically whencontent
changes.
- Handle the available events by specifying event callbacks
<Editor @bind-Value="content"
Load="HandleLoad"
Change="HandleChange"
CaretChange="HandleCaretChange"
Focus="HandleFocus"
Blur="HandleBlur"
KeyDown="HandleKeyDown"
KeyUp="HandleKeyUp"
BeforePreviewRender="HandleBeforePreviewRender"
BeforeConvertWYSIWYGToMarkdown="HandleBeforeConvertWYSIWYGToMarkdown" />
<Viewer Value="content"
Load="HandleLoad"
Change="HandleChange"
UpdatePreview="HandleUpdatePreview" />
These events are the same as the native public events, and the parameters are detailed in the code comments.
- Access the
Editor
orViewer
instance to invoke methods
<Editor @ref="editorRef" @bind-Value="markdown" Options="@options" />
<Editor @ref="viewerRef" Value="markdown" />
<button @onclick="HandlePreview">Preview</button>
<Editor @ref="viewerRef2"/>
@code {
Editor editorRef = default!;
Viewer viewerRef = default!;
Viewer viewerRef2 = default!;
string markdown = string.Empty;
async Task HandlePreview()
{
var markdown = await editorRef.GetMarkdown();
await viewerRef2.SetMarkdown(markdown);
}
}
Most of all native methods have been implemented. Refer to the Editor class for available methods.
- Add custom language
- Use
Editor.SetLanguage
static method to add custom language. - Use
Editor.SetDefaultLanguage
static method to set default language, it will be used when no language is set inEditorOptions
.
Note: Please make sure Editor.SetLanguage and Editor.SetDefaultLanguage are called before
Editor
component is rendered.
- Widget rules
Due to BlazorServer
mode not supporting JavaScript call .NET method synchronously, the widget rules only support in BlazorWebAssembly
mode.
Implemented Features
-
Editor
andViewer
basic usage -
Editor
andViewer
events - Language setting and custom language
-
Editor
andViewer
instance methods - Toolbar with custom button
- Add command and execute command
- Add widget and set widget rules (only support in
BlazorWebAssembly
mode) - Link attributes
- Custom markdown renderer
- Custom HTML renderer
- Custom HTML Sanitizer
License
This software is licensed under the MIT License
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.19)
-
net7.0
- Microsoft.AspNetCore.Components.Web (>= 7.0.8)
-
net8.0
- Microsoft.AspNetCore.Components.Web (>= 8.0.0-preview.5.23302.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.