我使用的是4.7.4版的TinyMCE和剃须刀
我有addes style_formats选项和相关的样式表,但是自定义格式并没有出现在下拉格式中,只是默认样式。
tinymce.init({
selector: 'textarea',
height: 200,
theme: 'modern',
menubar: false,
toolbar1: 'formatselect | bold italic | numlist bullist',
content_css: [
'//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
'@Url.Content("~/Content/css/rte/rte.tinymce.css")'
],
style_formats: [
{ title: 'Red', inline: 'span', classes: 'header-bolded' }
]
});rte.tinymce.css CSS:
/**name:Header*/
h3{
font-size: 1.2rem;
color: #D3D63C;
}
/**name:Paragraph*/
p{font-size: 0.8rem;}
.header-bolded {
color: #d6d63e;
}在格式下拉,我仍然有:段落,6标题和预先格式化的风格。
只有'Red'格式是可用的,不是吗?
发布于 2017-12-11 20:37:46
发布于 2018-04-27 09:52:12
是同样的问题,注释行// extended_valid_elements:"span",这很有帮助
发布于 2018-10-19 16:13:33
除了迈克尔·弗罗明的回答之外,我还想说一句:
如果在使用style_formats的同时使用导入插件,则需要添加以下参数:
importcss_append:真
示例:
tinymce.init({
selector:'textarea',
//some custom styles to add to the Formats dropdown:
style_formats: [
{ title: 'Bold text', inline: 'strong' },
{ title: 'Red text', inline: 'span', styles: { color: '#ff0000' } }
],
//Using an external CSS file in addition to custom formats:
content_css: "my.css",
plugins: [
"importcss" //if using the importcss plugin also
],
importcss_append: true //make sure you add this
});https://stackoverflow.com/questions/47760421
复制相似问题