【问题标题】:Select a font in TinyMCE fontselect在 TinyMCE 中选择一种字体 fontselect
【发布时间】:2017-08-18 00:23:26
【问题描述】:

我在 TinyMCE 中定义了一个字体选择对象,如下所示:

tinymce.init({
  selector: 'textarea',  
  toolbar: 'fontselect'
});

问题是当编辑器启动时,选择的字体是“Times New Roman”,我需要它是“Arial”。这怎么能改变?是tinymce.init中的关键字吗?

【问题讨论】:

    标签: tinymce tinymce-4


    【解决方案1】:
    tinymce.init({
       selector: 'textarea',  
       toolbar: 'fontselect',
       setup : function(ed) {
        ed.onInit.add(function(ed) {
            ed.execCommand("fontName", false, "Arial");
            //Or ed.target.editorCommands.execCommand("fontName", false, "Arial");
            ed.execCommand("fontSize", false, "12");
        });
    }
    });
    

    尝试使用上面的代码并检查 .请转:Changing the default font family in TinyMCE

    【讨论】:

    • 感谢您的链接,我使用了 TinyMCE v4.3.6 的答案,这就是有效的。
    • 确实,其他答案适用于最新版本,不再定义 ed.onInit。
    • 也只有 ed.on('init', function (ed) {...} 为我工作
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-11
    • 1970-01-01
    • 1970-01-01
    • 2012-05-27
    • 2015-08-26
    相关资源
    最近更新 更多