我试图在Episerver的tinyMCE中添加一个用于选择不同字体的菜单。它适用于带有以下代码的p标签,但我希望能够为所有标签(p,h1,h2等)选择字体。
var styleItemsFonts = new object[]
{
new { title = "Garant", selector = "p", styles = new { fontFamily = "Garant" } },
new { title = "Clarendon Cn", selector = "p", styles = new { fontFamily = "Clarendon Cn" } },
new { title = "Grand Hotel", selector = "p", styles = new { fontFamily = "Grand Hotel" } },
new { title = "Gotham Bold", selector = "p", styles = new { fontFamily = "Gotham Bold" } }
};
var styleFormats = ( new { title = "Font", items = styleItemsFonts });
config.Default()
.AddPlugin(plugins)
.Toolbar(toolbar1, toolbar2)
.AddSetting("paste_as_text", true)
.StyleFormats(styleFormats.Item1);
如果删除“ selector =“ p”',则会出现以下控制台错误:
Uncaught TypeError: Cannot read property 'toLowerCase' of undefined
at Object.isValidChild (tinymce.min.js:2)
at Object.isValid (tinymce.min.js:2)
at Array.u (tinymce.min.js:2)
at Rt (tinymce.min.js:2)
at tinymce.min.js:2
at Bv (tinymce.min.js:2)
at a (tinymce.min.js:2)
at Object.oy [as applyFormat] (tinymce.min.js:2)
at gy (tinymce.min.js:2)
at Object.toggle (tinymce.min.js:2)
答案 0 :(得分:2)
将选择器设置为*应该可以。 像这样:
new { title = "Garant", selector = "*", styles = new { fontFamily = "Garant" } }