加载微小的MCE编辑器后添加style_formats
Add style_formats after tinyMCE editor is loaded
当你初始化一个微小的MCE编辑器时,你可以传递以下自定义样式。
tinyMCE.init({ style_formats: [{ title: 'flow', selector: 'img', styles: { 'float': 'left', 'margin-right': '5px' } }]});
但是,如果我想在加载后给 tinyMCE som 自定义样式怎么办?我该怎么做。例如,我已经能够像这样将style_formats添加到 tinyMCE 编辑器对象中。
tinyMCE.editors[0].settings["style_formats"] = [{title:'flow', selector:'img', styles: {'float' : 'left'}}];
但是编辑器本身不会更新。有没有办法告诉 tinyMCE 自己重新加载它?或者有没有另一种方法可以即时更新编辑器?
干杯。
您真的想将其添加到现有设置之后还是只是附加到现有设置中?从版本 4.0.13 开始,现在有一个名为 style_formats_merge 的新属性可以在 init 期间使用。将此属性设置为 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 配置文件之后,您可以通过向 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%' } }
]
}
]
});
相关文章:
- 正在添加'X'按钮,在文本字段旁边使用javascript
- 如何在映射数组中添加换行符
- 正在将数据主题添加到所有项目
- ZeroClipboard-在复制之前添加到值
- 我可以在json对象中添加一个函数吗
- 将输入字段中的文本提交到我的数据库,同时将其添加到我的列表中
- 正在SharePoint 2013母版页中添加JQuery移动文件
- 如何添加浮动和非浮动,其他
- 添加文字和评论功能更新Div
- 如果使用 lodash 将属性存在于另一个对象中,则向对象添加属性
- 动态地改变“”的URL;添加新项目”;链接使用javascript/jquery
- 在函数中添加数组元素的数值
- 如何将歌曲添加到jPlayer
- 在html Select中添加搜索
- 如何在动态添加表行时更改td.style
- 如何将样式添加到span like.attr('style','width:newWidth
- 有没有一种简单的方法来转换“;字体"style属性添加到其中的每一个'他的个人风格
- 如何使用.style JavaScript属性添加css框阴影
- 添加d3 svg.selectAll(".foo").style("fill",
- 转换不能只在IE中添加到Angular指令的style中