Syncfusion RichTextEditor ASP.Net MVC 格式下拉列表

Syncfusion RichTextEditor ASP.Net MVC Format dropdown

有人可以帮助我如何更改 richtexteditor ej2 syncfusion 中格式下拉列表的内容吗?

目前,默认值为:段落、代码、引文、标题 1 等

我想删除代码、报价并添加名为 "My Paragraph" 的新自定义格式。

我已经查看了文档,显然没有列出。

我们将不胜感激。 这是我当前的配置:

@Html.EJS().RichTextEditor("table").ToolbarSettings(e => e.Items((object)ViewBag.tools)).Value((string)ViewBag.value).QuickToolbarSettings(e => { e.Table((object)ViewBag.table); }).InsertImageSettings(new RichTextEditorImageSettings() { Path = "/Uploads/", SaveUrl = "/Home/Save" }).ShowCharCount(true).MaxLength(2000).Created("created").Render()

控制器方法return在viewbag中配置

 var tools = new
        {
            tooltipText = "Custom Tools",
            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;'> Custom Tools</div></button>"
        };

        ViewBag.tools = new object[] {
            "Bold", "Italic", "Underline", "StrikeThrough",
            "FontColor", "BackgroundColor",
            "LowerCase", "UpperCase", "|",
            "Formats", "Alignments", "OrderedList", "UnorderedList",
            "Outdent", "Indent", "CreateTable","|",
            "CreateLink", "Image", "|", "ClearFormat", "Print",
            "SourceCode", "FullScreen", tools,"|", "Undo", "Redo"
        };

        ViewBag.table = new[] {
            "tableRows","tableColumns","tableCellVerticalAlign","tableCellHorizontalAlign","backgroundcolor"
        };
        ViewBag.value="";

您可以使用 Format 属性 修改现有的“格式”选项,如下所示。

[查看]

@Html.EJS().RichTextEditor("default").Format((object)ViewBag.types).ActionBegin("onBegin").Render() 
<script> 
    function onBegin(e) { 
        alert(e.element.textContent + " is Selected"); 
    } 
</script> 

[控制器]

public ActionResult Index() 
{ 
    object format1 = new { text = "Paragraph", value = "P" }; 
    object format2 = new { text = "My Paragraph", value = "BlockQuote" }; 
    object format3 = new { text = "Heading 1", value = "H1" }; 
    object format4 = new { text = "Heading 2", value = "H2" }; 
    ViewBag.types = new { width = "40px", 
        types = new[] { format1, format2, format3, format4 } 
    }; 
    return View(); 
} 

如果新添加的项目有任何预定义的格式,您可以在值中提及该格式。否则,如果您想执行自定义操作,则可以通过 RTE 的 actionBegin 事件获取所选项目并在那里执行所需的操作。现在,项目将显示在工具栏中,如下所示

Sample