EPiServer TinyMCE 2 (4.7.9) 自定义格式项
Customize Format Items in EPiServer TinyMCE 2 (4.7.9)
我刚刚更新了我网站上的 EPiServer。随着更新而来的是新的 TinyMCE。
我对如何更改 format 列表的内容有疑问。
这个不错的指南 (https://world.episerver.com/documentation/developer-guides/CMS/add-ons/customizing-the-tinymce-editor-v2/) 是昨天发布的,它展示了如何做很多事情。但是我需要知道的是如何调整格式列表的内容。
例如,从 format
下拉列表中删除 <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));
}
查看我在 Episerver World 上的博客 post: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");
我刚刚更新了我网站上的 EPiServer。随着更新而来的是新的 TinyMCE。 我对如何更改 format 列表的内容有疑问。
这个不错的指南 (https://world.episerver.com/documentation/developer-guides/CMS/add-ons/customizing-the-tinymce-editor-v2/) 是昨天发布的,它展示了如何做很多事情。但是我需要知道的是如何调整格式列表的内容。
例如,从 format
下拉列表中删除 <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));
}
查看我在 Episerver World 上的博客 post: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");