首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >加载tinyMCE编辑器后添加style_formats

加载tinyMCE编辑器后添加style_formats
EN

Stack Overflow用户
提问于 2013-10-31 21:19:15
回答 2查看 1.6K关注 0票数 1

当你初始化一个tinyMCE编辑器时,你可以传递以下自定义样式。

代码语言:javascript
复制
tinyMCE.init({ style_formats: [{ title: 'flow', selector: 'img', styles: { 'float': 'left', 'margin-right': '5px' } }]});

但是,如果我想在tinyMCE加载后给它一些自定义样式怎么办?我怎么能做到这一点。例如,我可以像这样将style_formats添加到tinyMCE编辑器对象中。

代码语言:javascript
复制
tinyMCE.editors[0].settings["style_formats"] = [{title:'flow', selector:'img', styles: {'float' : 'left'}}];

但是编辑器本身并没有更新。有没有办法让tinyMCE自己重新加载?或者,还有其他方法可以动态更新编辑器吗?

干杯。

EN

回答 2

Stack Overflow用户

发布于 2014-03-22 07:31:08

你真的想把它添加到现有设置之后,还是只是追加到现有设置之后?从版本4.0.13开始,您可以在初始化过程中使用一个名为style_formats_merge.的新属性将此属性设置为true,它会将您的样式连接到默认集。

代码语言:javascript
复制
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%' } }
            ]
        }
    ]
});
票数 3
EN

Stack Overflow用户

发布于 2017-10-14 01:32:41

在tinymce配置文件之后,您可以通过在新的js文件中添加以下代码来扩展tinymce设置。

代码语言:javascript
复制
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%' } }
            ]
        }
]
 });
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19707621

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档