繁体   English   中英

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

[英]Customize Format Items in EPiServer TinyMCE 2 (4.7.9)

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

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

这是使用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'}
}
});

但是,我将如何在TinyMCE的EPiServer C#版本中执行此操作? toolbarSmall是我的自定义配置,目前看起来像这样。

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));
}

tinyMCE2 h1格式

查看我在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");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM