本文介绍了更改 TinyMCE 中的默认字体系列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用文档此处 但这给我留下了一个问题.原来的默认字体在字体下拉列表中不再有效.

I've successfully changed the default font inside the editor using the documentation here but that leaves me with a problem. The original default font no longer works in the font drop down list.

原始默认值:Verdana
新默认值:MyCustomFont

Original default: Verdana
New default: MyCustomFont

当我在编辑器中键入时,默认情况下我会看到 MyCustomFont 字体.如果我尝试将其更改为 Verdana(原始默认值),则不会发生任何事情.我可以将其更改为 Verdana 以外的任何字体系列.我还注意到,当我在下拉列表中选择 MyCustomFont 时,内容会被带有内联样式的跨度包围.原始默认字体不会发生这种情况(因此什么也没发生).

When I type into the editor I see my MyCustomFont font by default. If I try to change that to Verdana (original default) nothing happens. I can change it to any font family except Verdana. I noticed also that when I select MyCustomFont in the drop down list the content gets surrounded with a span with inline styles. This does not happen with the original default font (hence why nothing happens).

在我看来,缺少一个关键的文档 - 如何告诉编辑器(特别是字体功能)我在 css 中默认定义的字体是默认字体.

It seems to me like there's a key piece of documentation missing - how to tell the editor (the font feature in particular) that the font I've defined by default in the css is the default font.

我在谷歌上搜索了很多,但没有结果.其他人似乎都在为上面提到的文档感到满意.只有我有这个问题吗?如果没有,请帮忙!:)

I've Googled quite a bit but had no results. Everybody else seems to be settling for the documentation mentioned above. Am I the only one having this problem? If not, please help! :)

请注意,这个问题的答案没有回答我的问题.

Please note, the answers to this question do not answer my question.

推荐答案

也许为时已晚,但...

maybe too late but...

$('.tinymce').tinymce({
    setup : function(ed) {
        ed.onInit.add(function(ed) {
            ed.execCommand("fontName", false, "Arial");
            ed.execCommand("fontSize", false, "2");
        });
    }
});

编辑

对于 TinyMCE 4,如@jason-tolliver 和@georg 所述,语法为:

For TinyMCE 4, as @jason-tolliver and @georg states, the syntax is:

ed.on('init', function (ed) {
    ed.target.editorCommands.execCommand("fontName", false, "Arial");
});

这篇关于更改 TinyMCE 中的默认字体系列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-16 20:30