@section ExternalDependencies {
<script src="https://unpkg.com/devextreme-quill/dist/dx-quill.min.js"></script>
}
@(Html.DevExtreme().HtmlEditor()
.ID("html-editor")
.Height(725)
.Content(@<text>
<h2>
<img src="~/images/widgets/HtmlEditor.svg" alt="HtmlEditor" />
Formatted Text Editor (HTML Editor)
</h2>
<br>
<p>
DevExtreme HTML5 JavaScript HTML Editor is a client-side WYSIWYG text editor that allows its users to format
textual and visual content and store it as HTML or Markdown.
</p>
<p>Supported features:</p>
<ul>
<li>
Inline formats:
<ul>
<li><strong>Bold</strong>, <em>italic</em>, <s>strikethrough</s> text formatting</li>
<li>Font, size, color changes (HTML only)</li>
</ul>
</li>
<li>
Block formats:
<ul>
<li>Headers</li>
<li>Text alignment</li>
<li>Lists (ordered and unordered)</li>
<li>Code blocks</li>
<li>Quotes</li>
</ul>
</li>
<li>Custom formats</li>
<li>HTML and Markdown support</li>
<li>Mail-merge placeholders (for example, %username%)</li>
<li>Adaptive toolbar for working images, links, and color formats</li>
<li>Insert images as a link or base64 (drag and drop images to convert them to base64)</li>
<li>Copy-paste rich content (unsupported formats are removed)</li>
<li>Tables support</li>
</ul>
<br>
<p>Supported frameworks and libraries</p>
<table>
<tr>
<td><strong>jQuery</strong></td>
<td style="text-align: right;">v2.1 - v2.2 and v3.x</td>
</tr>
<tr>
<td><strong>Angular</strong></td>
<td style="text-align: right;">v7.0.x - v10.0.x</td>
</tr>
<tr>
<td><strong>React</strong></td>
<td style="text-align: right;">v16.2+</td>
</tr>
<tr>
<td><strong>Vue</strong></td>
<td style="text-align: right;">v2.6.3+</td>
</tr>
</table>
</text>)
.Toolbar(toolbar => toolbar.Items(
items => {
items.Add().FormatName(HtmlEditorToolbarItem.Undo);
items.Add().FormatName(HtmlEditorToolbarItem.Redo);
items.Add().FormatName(HtmlEditorToolbarItem.Separator);
items.Add()
.FormatName("size")
.FormatValues(new[] { "8pt", "10pt", "12pt", "14pt", "18pt", "24pt", "36pt" });
items.Add()
.FormatName("font")
.FormatValues(new[] { "Arial", "Courier New", "Georgia", "Impact", "Lucida Console", "Tahoma", "Times New Roman", "Verdana" });
items.Add().FormatName(HtmlEditorToolbarItem.Separator);
items.Add().FormatName(HtmlEditorToolbarItem.Bold);
items.Add().FormatName(HtmlEditorToolbarItem.Italic);
items.Add().FormatName(HtmlEditorToolbarItem.Strike);
items.Add().FormatName(HtmlEditorToolbarItem.Underline);
items.Add().FormatName(HtmlEditorToolbarItem.Separator);
items.Add().FormatName(HtmlEditorToolbarItem.AlignLeft);
items.Add().FormatName(HtmlEditorToolbarItem.AlignCenter);
items.Add().FormatName(HtmlEditorToolbarItem.AlignRight);
items.Add().FormatName(HtmlEditorToolbarItem.AlignJustify);
items.Add().FormatName(HtmlEditorToolbarItem.Separator);
items.Add().FormatName(HtmlEditorToolbarItem.OrderedList);
items.Add().FormatName(HtmlEditorToolbarItem.BulletList);
items.Add().FormatName(HtmlEditorToolbarItem.Separator);
items.Add()
.FormatName("header")
.FormatValues(new JS("[false, 1, 2, 3, 4, 5]"));
items.Add().FormatName(HtmlEditorToolbarItem.Separator);
items.Add().FormatName(HtmlEditorToolbarItem.Color);
items.Add().FormatName(HtmlEditorToolbarItem.Background);
items.Add().FormatName(HtmlEditorToolbarItem.Separator);
items.Add().FormatName(HtmlEditorToolbarItem.Link);
items.Add().FormatName(HtmlEditorToolbarItem.Image);
items.Add().FormatName(HtmlEditorToolbarItem.Separator);
items.Add().FormatName(HtmlEditorToolbarItem.Clear);
items.Add().FormatName(HtmlEditorToolbarItem.CodeBlock);
items.Add().FormatName(HtmlEditorToolbarItem.Blockquote);
items.Add().FormatName(HtmlEditorToolbarItem.Separator);
items.Add().FormatName(HtmlEditorToolbarItem.InsertTable);
items.Add().FormatName(HtmlEditorToolbarItem.DeleteTable);
items.Add().FormatName(HtmlEditorToolbarItem.InsertRowAbove);
items.Add().FormatName(HtmlEditorToolbarItem.InsertRowBelow);
items.Add().FormatName(HtmlEditorToolbarItem.DeleteRow);
items.Add().FormatName(HtmlEditorToolbarItem.InsertColumnLeft);
items.Add().FormatName(HtmlEditorToolbarItem.InsertColumnRight);
items.Add().FormatName(HtmlEditorToolbarItem.DeleteColumn);
})
)
.MediaResizing(m => m.Enabled(true))
)
<div class="options">
<div class="caption">Options</div>
<div class="option">
@(Html.DevExtreme().CheckBox()
.Value(true)
.Text("Multiline toolbar")
.OnValueChanged("change_multiline")
)
</div>
</div>
<script>
function change_multiline(e) {
$("#html-editor")
.dxHtmlEditor("instance")
.option("toolbar.multiline", e.value);
}
</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using DevExtreme.NETCore.Demos.Models.SampleData;
namespace DevExtreme.NETCore.Demos.Controllers {
public class HtmlEditorController : Controller {
public IActionResult Overview() {
return View();
}
}
}
.dx-htmleditor-content img {
vertical-align: middle;
padding-right: 10px;
}
.dx-htmleditor-content table {
width: 50%;
}
.options {
padding: 20px;
background-color: rgba(191, 191, 191, 0.15);
margin-top: 20px;
}
.caption {
font-size: 18px;
font-weight: 500;
}
.option {
margin-top: 10px;
}