当你初始化一个tinyMCE编辑器时,你可以传递以下自定义样式。
tinyMCE.init({ style_formats: [{ title: 'flow', selector: 'img', styles: { 'float': 'left', 'margin-right': '5px' } }]});但是,如果我想在tinyMCE加载后给它一些自定义样式怎么办?我怎么能做到这一点。例如,我可以像这样将style_formats添加到tinyMCE编辑器对象中。
tinyMCE.editors[0].settings["style_formats"] = [{title:'flow', selector:'img', styles: {'float' : 'left'}}];但是编辑器本身并没有更新。有没有办法让tinyMCE自己重新加载?或者,还有其他方法可以动态更新编辑器吗?
干杯。
发布于 2014-03-22 07:31:08
你真的想把它添加到现有设置之后,还是只是追加到现有设置之后?从版本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%' } }
]
}
]
});发布于 2017-10-14 01:32:41
在tinymce配置文件之后,您可以通过在新的js文件中添加以下代码来扩展tinymce设置。
jQuery.extend(tinymce.settings,
{
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%' } }
]
}
]
});https://stackoverflow.com/questions/19707621
复制相似问题