我正在尝试自定义默认的styleselect
工具栏菜单,以便可以向其添加自定义菜单元素。这个想法是将字体大小作为styleselect
子菜单放置:
我通过以下方式初始化了TinyMCE 4.0.5
:
tinymce.init(
{
language_url : '/webobbywebapp/js/tiny_mce/language/es.js',
selector:'textarea',
plugins: "image, link, print",
toolbar: "styleselect | undo redo | removeformat | bold italic underline | aligncenter alignjustify | bullist numlist outdent indent | link | print | fontselect fontsizeselect",
menubar: false,
statusbar: true,
resize: true
});
由于我找不到如何自定义默认样式选择菜单的方法,因此我也试图创建一个全新的菜单,可以在其中添加字体大小控件。但是我不想显示任何工具栏,我想要一个菜单栏。
编辑:现在我正在尝试使用以下代码修改styleselect菜单,但fontselect和fontsizeselect似乎已禁用
,style_formats:
[{
标题:“Headers_”,
项目:[{标题:“标题1”,格式:“h1”},{标题:“标题2”,格式:“h2”},{标题:“标题3”,格式:“h3”},{标题:“标题4”,格式:“h4”},{标题:“标题5”,格式:“h5”},{标题:“标题6”,格式:“h6”}]
},
{title:“_ Inline”,项目:[{title:“Bold”,图标:“bold”,格式:“bold”},{title:“斜体”,图标:“italic”,格式:“italic”},
{title:“_ Underline”,图标:“underline”,格式:“underline”},{title:“删除线”,icon:“strikethrough”,格式:“strikethrough”},{title:“上标”,icon:“上标”,格式:“上标”},{标题:“下标”,图标:“下标”,格式:“下标”},{标题:“代码”,图标:“代码”,格式:“代码”}] },
{title:“_ Blocks”,项目:[{title:“Paragraph”,格式:“p”},{title:“Blockquote”,格式:“blockquote”},{title:“Div”,格式:“div” },{title:“Pre”,format:“pre”}]},
{title:“_ Alignment”,项目:[{title:“左”,图标:“alignleft”,格式:“alignleft”},{title:“居中”,图标:“aligncenter”,格式:“aligncenter”}, {title:“右”,图标:“alignright”,格式:“alignright”},{title:“Justify”,图标:“alignjustify”,格式:“alignjustify”}]},
{title:“类”,项目:“fontsizeselect”},
{title:“dddClasses”,项目:“fontselect”
}]
最佳答案
从4.0.13版本开始,现在有一个可以在初始化期间使用的新属性,称为 style_formats_merge 。将此属性设置为true,它将把您的样式连接到默认集合上。
tinymce.init({
style_formats_merge: true,
style_formats: [
{
title: 'Line Height',
items: [
{ title: 'Normal Line Height', inline: 'span', styles: { "line-height": '100%' } },
{ title: 'Line Height + 10%', inline: 'span', styles: { "line-height": '110%' } },
{ title: 'Line Height + 50%', inline: 'span', styles: { "line-height": '150%' } },
{ title: 'Line Height + 100%', inline: 'span', styles: { "line-height": '200%' } }
]
}
]
});
关于tinymce - 自定义tinymce 4.0.5样式选择工具栏菜单,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18699465/