自定义EPiServer TinyMCE 2中的格式项(4.7.9)

wut*_*wut 0 c# format tinymce episerver

我刚刚在我的网站上更新了EPiServer.随着更新来了新的TinyMCE.我有一个关于如何更改格式列表内容的问题.

昨天发布了这个很好的指南(https://world.episerver.com/documentation/developer-guides/CMS/add-ons/customizing-the-tinymce-editor-v2/),它展示了如何做很多事情.但我需要知道的是如何调整格式列表的内容.例如,<h1>format下拉列表中删除选项.

这是在JavaScript中的方法:https: //www.tinymce.com/docs/configure/editor-appearance/#menu

tinymce.init({
  selector: 'textarea',  // change this value according to your HTML
  menu: {
format: {title: 'Format', items: 'bold italic underline strikethrough superscript subscript | formats | removeformat'}
}
});
Run Code Online (Sandbox Code Playgroud)

但是我如何在TinyMCE的EPiServer C#版本中执行此操作? toolbarSmall是我的cusom配置,它现在看起来像这样.

public void ConfigureContainer(ServiceConfigurationContext context)
{
    var toolbarsSmall = new[]
    {
        "epi-link unlink | cut copy paste pastetext pasteword searchreplace | table",
        "bold | bullist numlist hr | formatselect undo redo | | fullscreen code help | tinymcespellchecker a11ychecker"
    };


    context.Services.Configure((Action<TinyMceConfiguration>)(config =>
        config
            .Empty()
            .DisableMenubar()
            .Height(300)
            .Width(580)
            .Resize(TinyMceResize.Both)
            .ContentCss("/static/css/editor.css")
            .Plugins("epi-link epi-dnd-processor epi-personalized-content help image importcss fullscreen lists searchreplace hr table code paste media")
            .Toolbar(toolbarsSmall)));

    context.Services.Intercept((Func<IServiceLocator, IPersonalizedContentFactory, IPersonalizedContentFactory>) ((locator, defaultFactory) => new PersonalizedContentFactory(defaultFactory) as IPersonalizedContentFactory));
}
Run Code Online (Sandbox Code Playgroud)

tinyMCE2 h1格式

小智 6

查看我在Episerver World上发布的博客:https://world.episerver.com/blogs/Ben-McKernan/Dates/2018/3/an-updated-tinymce-package-has-been-released/

我认为你所追求的是"block_formats"设置(https://www.tinymce.com/docs/configure/content-formatting/#block_formats),而不是你正在创建的复杂菜单设置.Episerver中的设置对象上有一个辅助方法,用于配置块格式.例如:

config.Default()
    .BlockFormats("Paragraph=p;Header 1=h1;Header 2=h2;Header 3=h3");
Run Code Online (Sandbox Code Playgroud)