- Default toolbar items
- Type of toolbar
- Custom Toolbar Items
Contact Support
Toolbar configuration in Markdown Editor Control
17 Mar 202524 minutes to read
Default toolbar items
By default, the Markdown Editor displays the following toolbar items:
Bold
,Italic
,|
,Formats
,Blockquote
,OrderedList
,UnorderedList
,|
,CreateLink
,Image
,|
,SourceCode
,Undo
,Redo
These default items cover essential text editing features, such as text formatting, lists, and linking.
Type of toolbar
The Syncfusion Markdown Editor allows you to configure different type of toolbars using the type field in the toolbarSettings property.
The available toolbar types are:
- Expand
- MultiRow
- Scrollable
Expanding the Toolbar
The default toolbar mode is Expand
, which is configured using toolbarSettings with type: Expand
.
In this mode, any overflowing toolbar items are hidden in the next row. Users can reveal them by clicking the expand arrow.
<ejs-richtexteditor id="markdown-editor" editorMode="Markdown" value="@ViewBag.value" type="Expand">
<e-richtexteditor-toolbarsettings items="@ViewBag.tools"></e-richtexteditor-toolbarsettings>
</ejs-richtexteditor>
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.value = @"In Rich Text Editor, you click the toolbar buttons to format the words and the changes are visible immediately. Markdown is not like that. When you format the word in Markdown format, you need to add Markdown syntax to the word to indicate which words and phrases should look different from each other. Rich Text Editor supports markdown editing when the editorMode set as **markdown** and using both *keyboard interaction* and *toolbar action*, you can apply the formatting to text. You can add our own custom formation syntax for the Markdown formation, [sample link](https://ej2.syncfusion.com/home/). The third-party library <b>Marked</b> is used in this sample to convert markdown into HTML content.";
ViewBag.tools = new[] {
"Bold", "Italic", "StrikeThrough", "InlineCode", "SuperScript",
"SubScript", "|", "Formats", "Blockquote", "|", "OrderedList", "UnorderedList",
"CreateLink", "Image", "CreateTable", "|", "Undo", "Redo"
};
return View();
}
}
Configuring a Multi-row Toolbar
By setting type: MultiRow
in toolbarSettings, the toolbar items are arranged across multiple rows. This ensures that all configured toolbar items are always visible.
<ejs-richtexteditor id="markdown-editor" editorMode="Markdown" value="@ViewBag.value" type="MultiRow">
<e-richtexteditor-toolbarsettings items="@ViewBag.tools"></e-richtexteditor-toolbarsettings>
</ejs-richtexteditor>
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.value = @"In Rich Text Editor, you click the toolbar buttons to format the words and the changes are visible immediately. Markdown is not like that. When you format the word in Markdown format, you need to add Markdown syntax to the word to indicate which words and phrases should look different from each other. Rich Text Editor supports markdown editing when the editorMode set as **markdown** and using both *keyboard interaction* and *toolbar action*, you can apply the formatting to text. You can add our own custom formation syntax for the Markdown formation, [sample link](https://ej2.syncfusion.com/home/). The third-party library <b>Marked</b> is used in this sample to convert markdown into HTML content.";
ViewBag.tools = new[] {
"Bold", "Italic", "StrikeThrough", "InlineCode", "SuperScript",
"SubScript", "|", "Formats", "Blockquote", "|", "OrderedList", "UnorderedList",
"CreateLink", "Image", "CreateTable", "|", "Undo", "Redo"
};
return View();
}
}
Implementing a Scrollable Toolbar
Use type: 'Scrollable'
in toolbarSettings to create a single-line toolbar with horizontal scrolling capability for overflow items.
<ejs-richtexteditor id="markdown-editor" editorMode="Markdown" value="@ViewBag.value" type="Scrollable">
<e-richtexteditor-toolbarsettings items="@ViewBag.tools"></e-richtexteditor-toolbarsettings>
</ejs-richtexteditor>
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.value = @"In Rich Text Editor, you click the toolbar buttons to format the words and the changes are visible immediately. Markdown is not like that. When you format the word in Markdown format, you need to add Markdown syntax to the word to indicate which words and phrases should look different from each other. Rich Text Editor supports markdown editing when the editorMode set as **markdown** and using both *keyboard interaction* and *toolbar action*, you can apply the formatting to text. You can add our own custom formation syntax for the Markdown formation, [sample link](https://ej2.syncfusion.com/home/). The third-party library <b>Marked</b> is used in this sample to convert markdown into HTML content.";
ViewBag.tools = new[] {
"Bold", "Italic", "StrikeThrough", "InlineCode", "SuperScript",
"SubScript", "|", "Formats", "Blockquote", "|", "OrderedList", "UnorderedList",
"CreateLink", "Image", "CreateTable", "|", "Undo", "Redo"
};
return View();
}
}
Creating a Sticky Toolbar
By default, the toolbar remains fixed at the top of the Markdown editor when scrolling.
You can customize its position by setting floatingToolbarOffset to adjust the offset from the top of the document.
Additionally, you can enable or disable the floating toolbar using the enableFloating property.
<div style="width:500px;margin:0 auto;">
<ejs-richtexteditor id="toolbar-floating" height="720px" created="created" value="@ViewBag.value" editorMode="Markdown" >
<e-richtexteditor-toolbarsettings items="@ViewBag.tools" enableFloating="false"></e-richtexteditor-toolbarsettings>
</ejs-richtexteditor>
<div class="col-lg-12" >
<span id="props"> Enable/Disable Floating: </span>
<ejs-checkbox id="float" checked="false" label="Enable Floating" change="checkchange"></ejs-checkbox>
</div>
</div>
<script type="text/javascript">
var defaultRTE;
function created() {
defaultRTE = this;
}
function checkchange(args) {
defaultRTE.toolbarSettings.enableFloating = args.checked;
defaultRTE.dataBind();
}
</script>
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.tools = new[] {
"Bold", "Italic", "StrikeThrough", "InlineCode", "SuperScript",
"SubScript", "|", "Formats", "Blockquote", "|", "OrderedList", "UnorderedList",
"CreateLink", "Image", "CreateTable", "|", "Undo", "Redo"
};
ViewBag.value = @"In Rich Text Editor, you click the toolbar buttons to format the words and the changes are visible immediately. Markdown is not like that. When you format the word in Markdown format, you need to add Markdown syntax to the word to indicate which words and phrases should look different from each other. Rich Text Editor supports markdown editing when the editorMode set as **markdown** and using both *keyboard interaction* and *toolbar action*, you can apply the formatting to text. You can add our own custom formation syntax for the Markdown formation, [sample link](https://ej2.syncfusion.com/home/). The third-party library <b>Marked</b> is used in this sample to convert markdown into HTML content.";
return View();
}
}
Custom Toolbar Items
The Markdown Editor allows you to add custom commands to the toolbar using the toolbarSettings property. These custom commands can be displayed as plain text, icons, or HTML templates. You can define their order and grouping, ensuring a structured and intuitive toolbar layout. Additionally, actions can be bound to these commands by retrieving their instances and handling events accordingly.
In this example, a custom toolbar item (Ω) is added to insert special characters into the editor. When users click the Ω button, a list of special characters appears, allowing them to select and insert a character into the content. This feature enhances the Markdown Editor by providing quick access to special symbols without manually entering character codes.
The following code snippet demonstrates how to configure a custom toolbar item with a tooltip. The item is added to the items field of the toolbarSettings
property, ensuring seamless integration within the toolbar.
<div id="rteSection">
<ejs-richtexteditor id="customtool" created="created" editorMode="Markdown" value="@ViewBag.value">
<e-richtexteditor-toolbarsettings items="@ViewBag.items"></e-richtexteditor-toolbarsettings>
</ejs-richtexteditor>
</div>
<ejs-dialog id="customTbarDialog" visible="false" header='Special Characters' created="onDialogCreate" zIndex="1000" showCloseIcon="false" isModal="true" cssClass='e-rte-elements' overlayClick="dialogOverlay">
<e-dialog-buttons>
<e-dialog-dialogbutton buttonModel="ViewBag.button" click="onInsert"></e-dialog-dialogbutton>
<e-dialog-dialogbutton buttonModel="ViewBag.button1" click="dialogOverlay"></e-dialog-dialogbutton>
</e-dialog-buttons>
<e-content-template>
<div id="rteSpecial_char">
<div class="char_block" title="^">^</div>
<div class="char_block" title="_">_</div>
<div class="char_block" title="`">`</div>
<div class="char_block" title="{">{</div>
<div class="char_block" title="|">|</div>
<div class="char_block" title="}">}</div>
<div class="char_block" title="~">~</div>
<div class="char_block" title=" "> </div>
<div class="char_block" title="¡">¡</div>
<div class="char_block" title="¢">¢</div>
<div class="char_block" title="£">£</div>
<div class="char_block" title="¤">¤</div>
<div class="char_block" title="¥">¥</div>
<div class="char_block" title="₹">₹</div>
<div class="char_block" title="¦">¦</div>
<div class="char_block" title="§">§</div>
<div class="char_block" title="¨">¨</div>
<div class="char_block" title="©">©</div>
<div class="char_block" title="ª">ª</div>
<div class="char_block" title="«">«</div>
<div class="char_block" title="¬">¬</div>
<div class="char_block" title="-">-</div>
<div class="char_block" title="®">®</div>
<div class="char_block" title="¯">¯</div>
<div class="char_block" title="°">°</div>
<div class="char_block" title="±">±</div>
<div class="char_block" title="²">²</div>
<div class="char_block" title="³">³</div>
<div class="char_block" title="´">´</div>
<div class="char_block" title="µ">µ</div>
<div class="char_block" title="¶">¶</div>
<div class="char_block" title="·">·</div>
<div class="char_block" title="¸">¸</div>
<div class="char_block" title="¹">¹</div>
<div class="char_block" title="º">º</div>
<div class="char_block" title="»">»</div>
<div class="char_block" title="¼">¼</div>
<div class="char_block" title="½">½</div>
<div class="char_block" title="¾">¾</div>
<div class="char_block" title="¿">¿</div>
<div class="char_block" title="À">À</div>
<div class="char_block" title="Á">Á</div>
<div class="char_block" title="Â">Â</div>
<div class="char_block" title="Ã">Ã</div>
</div>
</e-content-template>
</ejs-dialog>
<script>
var defaultRTE, selection, ranges, dialog;
function onDialogCreate() {
dialog = this;
dialog.element.style.maxHeight = '300px';
}
function onInsert() {
var activeEle = dialog.element.querySelector('.char_block.e-active');
if (defaultRTE.formatter.getUndoRedoStack().length === 0) {
defaultRTE.formatter.saveData();
}
defaultRTE.executeCommand('insertText', activeEle.textContent);
defaultRTE.formatter.saveData();
defaultRTE.formatter.enableUndo(defaultRTE);
dialogOverlay();
}
function dialogOverlay() {
var activeEle = dialog.element.querySelector('.char_block.e-active');
if (activeEle) {
activeEle.classList.remove('e-active');
}
dialog.hide();
}
function created() {
defaultRTE = this;
selection = new ej.richtexteditor.NodeSelection();
var customBtn = defaultRTE.element.querySelector('#custom_tbar');
customBtn.onclick = function (e) {
dialog.element.style.display = '';
ranges = selection.getRange(document);
dialog.width = defaultRTE.element.offsetWidth * 0.5;
dialog.dataBind();
dialog.show();
var dialogCtn = document.getElementById('rteSpecial_char');
dialogCtn.onclick = function (e) {
var target = e.target;
var activeEle = dialog.element.querySelector('.char_block.e-active');
if (target.classList.contains('char_block')) {
target.classList.add('e-active');
if (activeEle) {
activeEle.classList.remove('e-active');
}
}
};
customBtn.onclick = function (e) {
defaultRTE.focusIn();
dialog.element.style.display = '';
ranges = selection.getRange(document);
dialog.width = defaultRTE.element.offsetWidth * 0.5;
dialog.dataBind();
dialog.show();
};
};
}
</script>
<style>
#customTbarDialog #special_char,
#customTbarDialog .char_block {
display: inline-block;
}
#custom_tbar,
#custom_tbar div {
cursor: pointer;
}
#rteSpecial_char {
padding: 15px 0 15px 0;
}
#customTbarDialog .char_block.e-active {
outline: 1px solid #e3165b;
border-color: #e3165b;
}
#customTbarDialog .char_block {
width: 30px;
height: 30px;
line-height: 30px;
margin: 0 5px 5px 0;
text-align: center;
vertical-align: middle;
border: 1px solid #DDDDDD;
font-size: 20px;
cursor: pointer;
user-select: none;
}
#custom_tbar .rtecustomtool {
font-size: 18px;
}
</style>
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.value = "In Rich Text Editor, you click the toolbar buttons to format the words and the changes are visible immediately. Markdown is not like that. When you format the word in Markdown format, you need to add Markdown syntax to the word to indicate which words and phrases should look different from each other. Rich Text Editor supports markdown editing when the editorMode set as **markdown** and using both *keyboard interaction* and *toolbar action*, you can apply the formatting to text. You can add our own custom formation syntax for the Markdown formation, [sample link](https://ej2.syncfusion.com/home/). The third-party library <b>Marked</b> is used in this sample to convert markdown into HTML content.";
var tools = new
{
tooltipText = "Insert Symbol",
template = "<button class='e-tbar-btn e-btn' tabindex='-1' id='custom_tbar' style='width:100%'><div class='e-tbar-btn-text rtecustomtool' style='font-weight: 500;'> Ω</div></button>"
};
ViewBag.items = new object[] { "Bold", "Italic", "|", "Formats", "OrderedList",
"UnorderedList", "|", "CreateLink", "Image", "CreateTable", "|", tools
, "|", "Undo", "Redo"
};
ViewBag.button = new
{
content = "Insert",
isPrimary = true
};
ViewBag.button1 = new
{
content = "Cancel"
};
return View();
}
}