Skip to content
IzzyBlazor

Enter all results ↑ ↓ move Esc close

Toolbar and shortcuts

Since 0.1.0-alpha.22
Choose the tools in the toolbar. Shortcuts work for every format, shown or not.

RichTextTools.Default shows every tool and RichTextTools.Basic four of them. To choose your own, combine tools with |. RichTextTools.None hides the toolbar and leaves the shortcuts. When the toolbar is too wide it wraps onto more rows, filling each; to keep it one row, with what doesn't fit in a … menu at its end, set WrapToolbar to false.

With nothing selected, a format's shortcut or tool turns it on for what's typed next, and again turns it off.

Shortcuts: Ctrl+B bold, Ctrl+I italic, Ctrl+U underline, Ctrl+Shift+X strikethrough, Ctrl+= subscript, Ctrl+Shift+= superscript, Ctrl+Shift+L, E and R align start, center and end, Ctrl+E inline code, Ctrl+K link, Ctrl+Shift+8 bulleted list, Ctrl+Shift+7 numbered list, Ctrl+] and Ctrl+[ indent and outdent a list item, Ctrl+Alt+0 paragraph, Ctrl+Alt+2 to 4 headings, Ctrl+Z undo, Ctrl+Y redo, Ctrl+Shift+V paste as plain text. On a Mac, ⌘ takes Ctrl's place. Alt+F10 moves to the toolbar and Escape back to the text.

Choosing tools

These release notes leave out underline, which reads as a link, and the rule. Set Tools to the ones you want.

Static

Preview

Text style

Version 2.4

  • Exports keep the column order.
  • The --quiet flag hides progress.

Code

Tools.razor
@* Release notes: text styles, lists and undo, and no underline, which reads as a link. *@
<RichTextEditor Grow @bind-Value="_notes" Label="Release notes"
                Tools="RichTextTools.TextStyle | RichTextTools.Bold | RichTextTools.Italic | RichTextTools.InlineCode | RichTextTools.BulletedList | RichTextTools.UndoRedo" />

@code {
    private string? _notes = "<h3>Version 2.4</h3><ul><li>Exports keep the column order.</li><li>The <code>--quiet</code> flag hides progress.</li></ul>";
}

One row

With WrapToolbar false, the toolbar stays one row, and the tools that don't fit move into a … menu at its end, with the same choices.

Static

Preview

Text style
Size
Text color
Highlight
History
Text style
Size
Text formats
Text color
Highlight
Lists
Alignment

Maintenance: the portal is down Saturday from 2 to 4 a.m.

Insert image

What the image shows, for people who can't see it.

Insert table

Code

OneRow.razor
@* A notice in a narrow sidebar: every tool, on one row, the rest in the … menu. *@
<RichTextEditor @bind-Value="_notice" Label="Notice" Tools="RichTextTools.Extended" WrapToolbar="false" Rows="4"
                MaxWidth="26.Rem" Grow />

@code {
    private string? _notice = "<p><strong>Maintenance:</strong> the portal is down Saturday from 2 to 4 a.m.</p>";
}

A tool of your own

To add your own tools, put them in ToolbarContent; they go at the end of the toolbar. InsertHtmlAsync puts HTML at the caret, sanitized, and Ctrl+Z undoes it. It works on interactive pages.

Always Interactive

Preview

Hi Sam,

Your refund went out today and should reach your card in 3 to 5 days.

Code

Signature.razor
@* A reply with a tool of its own: Insert signature puts the agent's sign-off at the caret. *@
<RichTextEditor Grow @ref="_editor" @bind-Value="_reply" Label="Reply" Tools="RichTextTools.Basic" Rows="5">
    <ToolbarContent>
        <ToolbarSeparator />
        <ToolbarButton StartIcon="Lucide.Signature" Variant="ButtonVariant.Ghost" Accent="Accent.Neutral" Size="ControlSize.Sm"
                       OnClick="InsertSignature">Insert signature</ToolbarButton>
    </ToolbarContent>
</RichTextEditor>

@code {
    private RichTextEditor? _editor;
    private string? _reply = "<p>Hi Sam,</p><p>Your refund went out today and should reach your card in 3 to 5 days.</p>";

    private Task InsertSignature() =>
        _editor!.InsertHtmlAsync("<p>Kind regards,<br><strong>Dana Ruiz</strong><br>Customer support</p>");
}

Connection lost

Rejoining the server…