A Markdown editor component with a toolbar, keyboard shortcuts, and a Design/Source mode switcher.
FormComponent<string>.GetValue
FormComponent<string>.NotifyFieldChanged
FormComponent<string>.OnContextMenu
FormComponent<string>.GetClassList
FormComponent<string>.TabIndex
FormComponent<string>.Placeholder
FormComponent<string>.Disabled
FormComponent<string>.EditContext
FormComponent<string>.ValueChanged
FormComponent<string>.HasValue
FormComponent<string>.FieldIdentifier
FormComponent<string>.ValueExpression
FormComponent<string>.FormFieldContext
FormComponent<string>.CurrentPlaceholder
RadzenComponent.GetIdAttribute
RadzenComponent.RaiseContextMenu
RadzenComponent.RaiseMouseEnter
RadzenComponent.AddContextMenu
RadzenComponent.RaiseMouseLeave
RadzenComponent.OnBecameInvisible
RadzenComponent.DefaultCulture
RadzenComponent.DefaultUICulture
RadzenComponent.IsJSRuntimeAvailable
ComponentBase.OnInitializedAsync
ComponentBase.OnParametersSet
ComponentBase.OnParametersSetAsync
ComponentBase.StateHasChanged
ComponentBase.ShouldRender
ComponentBase.OnAfterRender
ComponentBase.InvokeAsync
ComponentBase.DispatchExceptionAsync
ComponentBase.RendererInfo
ComponentBase.Assets
ComponentBase.AssignedRenderMode
Namespace: Radzen.Blazor
Assembly: Radzen.Blazor.dll
public class RadzenMarkdownEditor : FormComponent<string>, IComponent, IHandleEvent, IHandleAfterRender, IRadzenFormComponent<RadzenMarkdownEditor @bind-Value=@markdown @bind-Mode=@mode />
@code {
string markdown = "# Hello";
MarkdownEditorMode mode = MarkdownEditorMode.Design;
}The Markdown text is the value in both modes. Design mode edits a parsed document and writes it back to Markdown after every edit; blocks that were not edited are kept as written. Text typed in Design mode is inserted literally: characters with a Markdown meaning are escaped. Pasted text is parsed as Markdown.
A Markdown editor component with a toolbar, keyboard shortcuts, and a Design/Source mode switcher.
public RadzenMarkdownEditor()Whether the editor's history has a state to redo to.
public bool CanRedo { get; }
| Type | Description |
|---|---|
| bool | Whether the editor's history has a state to redo to. |
Whether the editor's history has a state to undo to.
public bool CanUndo { get; }
| Type | Description |
|---|---|
| bool | Whether the editor's history has a state to undo to. |
Custom toolbar content. When set, it replaces the default toolbar tools.
public RenderFragment ChildContent { get; set; }
| Type | Description |
|---|---|
| RenderFragment | Custom toolbar content. When set, it replaces the default toolbar tools. |
The mode the editor is currently in.
public MarkdownEditorMode CurrentMode { get; }
| Type | Description |
|---|---|
| MarkdownEditorMode | The mode the editor is currently in. |
A callback invoked after a command is executed, either by a built-in tool, a shortcut, String) or a RadzenMarkdownEditorCustomTool.
public EventCallback<MarkdownEditorExecuteEventArgs> Execute { get; set; }
| Type | Description |
|---|---|
| EventCallback<MarkdownEditorExecuteEventArgs> | A callback invoked after a command is executed, either by a built-in tool, a shortcut, String) or a RadzenMarkdownEditorCustomTool. |
The block at the current selection: p or h1 to h6, an empty string when the selection spans several kinds of blocks, or null when it contains no paragraph or heading at all.
public string FormatBlock { get; }
| Type | Description |
|---|---|
| string | The block at the current selection: p or h1 to h6, an empty string when the selection spans several kinds of blocks, or null when it contains no paragraph or heading at all. |
Specifies whether Input is raised on every keystroke. Set to false by default. Unlike Immediate, Value is always updated on input; this only controls whether Input is raised per keystroke.
public bool Immediate { get; set; }
| Type | Description |
|---|---|
| bool | Specifies whether Input is raised on every keystroke. Set to false by default. Unlike Immediate, Value is always updated on input; this only controls whether Input is raised per keystroke. |
Whether the caret is inside a table.
public bool InTable { get; }
| Type | Description |
|---|---|
| bool | Whether the caret is inside a table. |
A callback invoked on every keystroke when Immediate is true.
public EventCallback<string> Input { get; set; }
| Type | Description |
|---|---|
| EventCallback<string> | A callback invoked on every keystroke when Immediate is true. |
Gets or sets the mode of the editor. Two-way bindable.
public MarkdownEditorMode Mode { get; set; }
| Type | Description |
|---|---|
| MarkdownEditorMode | Gets or sets the mode of the editor. Two-way bindable. |
A callback invoked when the user switches the mode.
public EventCallback<MarkdownEditorMode> ModeChanged { get; set; }
| Type | Description |
|---|---|
| EventCallback<MarkdownEditorMode> | A callback invoked when the user switches the mode. |
The number of visible text rows of the textarea. Set to 10 by default.
public int Rows { get; set; }
| Type | Description |
|---|---|
| int | The number of visible text rows of the textarea. Set to 10 by default. |
The selection: positions in the rendered document in Design mode, offsets in the Markdown text in Source mode.
public ValueTuple<int, int> Selection { get; }
| Type | Description |
|---|---|
| ValueTuple<int, int> | The selection: positions in the rendered document in Design mode, offsets in the Markdown text in Source mode. |
Specifies whether the toolbar is shown. Set to true by default.
public bool ShowToolbar { get; set; }
| Type | Description |
|---|---|
| bool | Specifies whether the toolbar is shown. Set to true by default. |
The alignment of the table column at the caret: none, left, center or right. null outside a table.
public string TableAlignment { get; }
| Type | Description |
|---|---|
| string | The alignment of the table column at the caret: none, left, center or right. null outside a table. |
The index of the table column at the caret, or -1 outside a table.
public int TableColumn { get; }
| Type | Description |
|---|---|
| int | The index of the table column at the caret, or -1 outside a table. |
The index of the table row at the caret (0 is the header row), or -1 outside a table.
public int TableRow { get; }
| Type | Description |
|---|---|
| int | The index of the table row at the caret (0 is the header row), or -1 outside a table. |
protected override void BuildRenderTree(Rendering.RenderTreeBuilder __builder)
| Type | Name | Description |
|---|---|---|
| Rendering.RenderTreeBuilder | __builder |
Executes a command. Built-in commands (see MarkdownEditorCommands) modify the text; unknown command names only raise Execute.
public Task ExecuteCommandAsync(string name, string value)
| Type | Name | Description |
|---|---|---|
| string | name | The command name. |
| string | value | The command value: the URL for Link and Image (a dialogue is opened when null), the text for InsertText, the size as rows x columns for InsertTable (a dialogue is opened when null), the alignment for TableAlign. |
| Type | Description |
|---|---|
| Task |
Invoked from JavaScript when a registered shortcut is pressed.
public Task ExecuteShortcutAsync(string shortcut)
| Type | Name | Description |
|---|---|---|
| string | shortcut |
| Type | Description |
|---|---|
| Task |
Focuses the editable surface in Design mode, or the textarea in Source mode.
public override ValueTask FocusAsync()
| Type | Description |
|---|---|
| ValueTask |
protected override string GetComponentCssClass()
| Type | Description |
|---|---|
| string |
Returns whether the current selection has the format of commandName applied.
public bool IsActive(string commandName)
| Type | Name | Description |
|---|---|---|
| string | commandName |
| Type | Description |
|---|---|
| bool |
protected override Task OnAfterRenderAsync(bool firstRender)
| Type | Name | Description |
|---|---|---|
| bool | firstRender |
| Type | Description |
|---|---|
| Task |
Invoked from JavaScript when the editing surface loses focus. Raises Change when the text changed.
public Task OnBlurAsync()
| Type | Description |
|---|---|
| Task |
Invoked from JavaScript when the context menu is requested inside a table. Opens the table commands.
public Task OnContextMenuAsync(double clientX, double clientY, int start, int end)
| Type | Name | Description |
|---|---|---|
| double | clientX | |
| double | clientY | |
| int | start | |
| int | end |
| Type | Description |
|---|---|
| Task |
Invoked from JavaScript once a selection settles in Design mode. Returns the selected content as Markdown, which the browser puts on the clipboard when the selection is copied.
public Task<string> OnCopyAsync(int start, int end)
| Type | Name | Description |
|---|---|---|
| int | start | |
| int | end |
| Type | Description |
|---|---|
| Task<string> |
Invoked from JavaScript when text is inserted, replaced or deleted.
public Task<MarkdownEditorUpdate> OnEditAsync(int start, int end, string text, string inputType, int version)
| Type | Name | Description |
|---|---|---|
| int | start | |
| int | end | |
| string | text | |
| string | inputType | |
| int | version |
| Type | Description |
|---|---|
| Task<MarkdownEditorUpdate> |
Invoked from JavaScript when the editing surface gains focus.
public Task OnFocusAsync()
| Type | Description |
|---|---|
| Task |
Invoked from JavaScript when Tab or Shift+Tab is pressed in a list item in Design mode.
public Task<MarkdownEditorUpdate> OnIndentAsync(int start, int end, bool outdent, int version)
| Type | Name | Description |
|---|---|---|
| int | start | |
| int | end | |
| bool | outdent | |
| int | version |
| Type | Description |
|---|---|
| Task<MarkdownEditorUpdate> |
Invoked from JavaScript when Shift+Enter is pressed in Design mode.
public Task<MarkdownEditorUpdate> OnInsertLineBreakAsync(int start, int end, int version)
| Type | Name | Description |
|---|---|---|
| int | start | |
| int | end | |
| int | version |
| Type | Description |
|---|---|
| Task<MarkdownEditorUpdate> |
Invoked from JavaScript when Enter is pressed in Design mode.
public Task<MarkdownEditorUpdate> OnInsertParagraphAsync(int start, int end, int version)
| Type | Name | Description |
|---|---|---|
| int | start | |
| int | end | |
| int | version |
| Type | Description |
|---|---|
| Task<MarkdownEditorUpdate> |
Invoked from JavaScript when Tab is pressed in the last table cell in Design mode.
public Task<MarkdownEditorUpdate> OnInsertRowAsync(int start, int end, int version)
| Type | Name | Description |
|---|---|---|
| int | start | |
| int | end | |
| int | version |
| Type | Description |
|---|---|
| Task<MarkdownEditorUpdate> |
Invoked from JavaScript when the redo shortcut is pressed.
public Task<MarkdownEditorUpdate> OnRedoAsync(int version)
| Type | Name | Description |
|---|---|---|
| int | version |
| Type | Description |
|---|---|
| Task<MarkdownEditorUpdate> |
Invoked from JavaScript when the selection changes.
public Task OnSelectionAsync(int start, int end)
| Type | Name | Description |
|---|---|---|
| int | start | |
| int | end |
| Type | Description |
|---|---|
| Task |
Invoked from JavaScript when a task list checkbox is clicked in Design mode.
public Task<MarkdownEditorUpdate> OnToggleCheckAsync(int position, int version)
| Type | Name | Description |
|---|---|---|
| int | position | |
| int | version |
| Type | Description |
|---|---|
| Task<MarkdownEditorUpdate> |
Invoked from JavaScript when the undo shortcut is pressed.
public Task<MarkdownEditorUpdate> OnUndoAsync(int version)
| Type | Name | Description |
|---|---|---|
| int | version |
| Type | Description |
|---|---|
| Task<MarkdownEditorUpdate> |
Registers a keyboard shortcut. Used by toolbar tools.
public void RegisterShortcut(string key, Func<Task> action)
| Type | Name | Description |
|---|---|---|
| string | key | |
| Func<Task> | action |
public override Task SetParametersAsync(ParameterView parameters)
| Type | Name | Description |
|---|---|---|
| ParameterView | parameters |
| Type | Description |
|---|---|
| Task |
Unregisters a keyboard shortcut. Used by toolbar tools.
public void UnregisterShortcut(string key)
| Type | Name | Description |
|---|---|---|
| string | key |