Example of Quick Format Toolbar in ASP.NET MVC Rich Text Editor Control
This sample demonstrates the "Quick format Toolbar" option in Rich Text Editor content. To select the text content inside the Rich Text Editor and open the Quick Format toolbar for editing the Rich Text Editor value.
@* The editor's settings are in the view; the data they read (ViewData) is set in the controller action (see the controller tab). *@
@Html.UiRichTextEditor(new UiRichTextEditorOptions
{
Id = "quickEditor",
Name = "Quick",
Height = "300px",
ToolbarSettings = new UiRichTextToolbar
{
Items = (List<string>)ViewData["Tools"]
},
QuickToolbarSettings = new UiRichTextQuickToolbar
{
Text = new List<string> { "Bold", "Italic", "Underline", "StrikeThrough", "|", "SubScript", "SuperScript", "|", "CreateLink", "ClearFormat" }
},
Value = (string)ViewData["RTEValue"]
})
@Html.UiRichTextEditor(new UiRichTextEditorOptions
{
Id = "quickEditor",
Name = "Quick",
Height = "300px",
ToolbarSettings = new UiRichTextToolbar
{
Items = (List<string>)ViewData["Tools"]
},
QuickToolbarSettings = new UiRichTextQuickToolbar
{
Text = new List<string> { "Bold", "Italic", "Underline", "StrikeThrough", "|", "SubScript", "SuperScript", "|", "CreateLink", "ClearFormat" }
},
Value = (string)ViewData["RTEValue"]
})
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class RichTextEditorController : Controller
{
// The page is Views/RichTextEditor/QuickFormatToolbar.cshtml; it draws what ViewData holds.
public ActionResult QuickFormatToolbar()
{
ViewData["RTEValue"] = "<p>Select a word of this sentence to open the quick format toolbar. With the keyboard, select with Shift and the arrow keys, then press Alt+F10.</p>";
ViewData["Tools"] = new List<string> { "Formats", "Alignments", "Blockquote", "|", "OrderedList", "UnorderedList", "|", "CreateTable", "|", "Undo", "Redo" };
return View();
}
}
}
@* Install once: Install-Package Lumen.UI.Mvc (or: dotnet add package Lumen.UI.Mvc) *@
@* Views/Web.config: <add namespace="Lumen.UI.Mvc" /> *@
@* Views/Shared/_Layout.cshtml *@
<head>
@Html.UiStyles()
<link rel="stylesheet" href="~/Content/site.css" />
</head>
<body>
@RenderBody()
@Html.UiScripts()
@RenderSection("scripts", required: false)
</body>
The Quick format toolbar is used to easily edit the value of the Rich Text Editor when there is a lot of content in it. This quick toolbar item provides any toolbar item in the Rich Text Editor. This will support all the items in the toolbars of the Rich Text Editor.
In this demo, to enable this feature, configure the items in QuickToolbarSettings.Text property.