我正在尝试自定义默认的 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:
[{
title: "Headers_",
items: [{title: "Header 1",format: "h1"}, {title: "Header 2",format: "h2"}, {title: "Header 3",format: "h3"}, {title: "Header 4",format: "h4"}, {title: "Header 5",format: "h5"}, {title: "Header 6",format: "h6"}]
},
{title: "_Inline",items: [{title: "Bold",icon: "bold",format: "bold"}, {title: "Italic",icon: "italic",format: "italic"},
{title: "_Underline",icon: "underline",format: "underline"}, {title: "Strikethrough",icon: "strikethrough",format: "strikethrough"}, {title: "Superscript",icon: "superscript",format: "superscript"}, {title: "Subscript",icon: "subscript",format: "subscript"}, {title: "Code",icon: "code",format: "code"}]},
{title: "_Blocks",items: [{title: "Paragraph",format: "p"}, {title: "Blockquote",format: "blockquote"}, {title: "Div",format: "div"}, {title: "Pre",format: "pre"}]},
{title: "_Alignment",items: [{title: "Left",icon: "alignleft",format: "alignleft"}, {title: "Center",icon: "aligncenter",format: "aligncenter"}, {title: "Right",icon: "alignright",format: "alignright"}, {title: "Justify",icon: "alignjustify",format: "alignjustify"}]},
{title: "Classes", items: 'fontsizeselect'},
{title: "dddClasses", items: 'fontselect'
}]
3 回答
从版本4.0.13开始,现在可以在init期间使用一个名为 style_formats_merge 的新属性 . 将此属性设置为true,它会将您的样式连接到默认集 .
最后,添加以下代码就可以了:
如果您还需要从默认值中删除元素,您只需从_1206679中复制/粘贴它们并根据需要进行调整:
EDIT 感谢@ lucas-moeskops评论更新的网址:)