在 Wordpress 中向 TinyMce 4 添加另一个 "Formats" select
Add another "Formats" select to TinyMce 4 in Wordpress
我正在使用 TinyMce Style Formats 将自定义格式添加到“"Formats" 下拉列表。
问题是我要添加的样式太多,我想使用另一个 "Formats" 下拉列表,与第一个下拉列表分开。我知道我可以嵌套格式,但这还不够,我想添加两个不同的 Dropdown,我该怎么做?
看看 tinymce3 中的样式插件(在 tinymce4 中它是 tinymce 核心的一部分)。您可以复制该插件重命名并根据您的需要进行配置。然后您需要将插件添加到您的插件列表中,并将 tinymce 按钮添加到您的按钮列表中。
最好以编程方式向格式化程序添加格式,然后添加菜单项并触发格式化程序
editor.on( 'Init', function( e ) {
editor.formatter.register(
'page-title',
{ 'selector': 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li',wrapper: false, classes : ['giga', 'primary-font'] }
);
} );
editor.addButton( 'typography', {
text: 'Typography',
icon: false,
type: 'menubutton',
menu: [
{
text: 'Page Title',
menu: [
{
text: '(Giga) 88 Clan pro thin #000000',
onclick: function() {
editor.formatter.toggle( 'page-title' );
}
},
]
},
]
});
我正在使用 TinyMce Style Formats 将自定义格式添加到“"Formats" 下拉列表。 问题是我要添加的样式太多,我想使用另一个 "Formats" 下拉列表,与第一个下拉列表分开。我知道我可以嵌套格式,但这还不够,我想添加两个不同的 Dropdown,我该怎么做?
看看 tinymce3 中的样式插件(在 tinymce4 中它是 tinymce 核心的一部分)。您可以复制该插件重命名并根据您的需要进行配置。然后您需要将插件添加到您的插件列表中,并将 tinymce 按钮添加到您的按钮列表中。
最好以编程方式向格式化程序添加格式,然后添加菜单项并触发格式化程序
editor.on( 'Init', function( e ) {
editor.formatter.register(
'page-title',
{ 'selector': 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li',wrapper: false, classes : ['giga', 'primary-font'] }
);
} );
editor.addButton( 'typography', {
text: 'Typography',
icon: false,
type: 'menubutton',
menu: [
{
text: 'Page Title',
menu: [
{
text: '(Giga) 88 Clan pro thin #000000',
onclick: function() {
editor.formatter.toggle( 'page-title' );
}
},
]
},
]
});