根据选择更新RichCombo的标签-CKEditor [英] Update the Label of a RichCombo according to Selection - CKEditor

查看:119
本文介绍了根据选择更新RichCombo的标签-CKEditor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义的RichCombo,可以选择字体。它通过一些数据并创建其选项,而特殊功能由具有相应字体系列集的跨度组成,而不仅仅是纯文本。

I have a custom RichCombo to allow Font selection. It goes through some data and creates its options, while the "special feature" consists of spans with the corresponding font-family set, instead of just plain text.

现在我想更改/更新<$每次更改以及从外部更改时,此RichCombo框的c $ c> value 或 label 。基本上,它的行为应与默认的字体选择框完全一样。

Now i want to change / update the value or label of this RichCombo box, on every change and from the outside as well. Basically, it should act exactly like the default Font selection box.

editor.ui.addRichCombo( 'FontFamily', {
    multiSelect : false,
    label: 'Schriftart',
    title: 'Schriftart',
    className:   'cke_format',
    panel: { css:[CKEDITOR.skin.getPath("editor")].concat(editor.config.contentsCss) },
    toolbar: 'font',
    init: function() {
        for (var i=0; i < allFonts.length; i++) {
            this.add(
                allFonts[i].class,
                '<span class="'+ allFonts[i].class +'">' + allFonts[i].label + '</span>',
                 allFonts[i].label
             );
        };
    },
    onClick: function(value) {
         updateFontCorrectly();
    }
}

请注意,实际上,还有更多代码代替 updateFontCorrectly()函数。

Note that there is actually more code in place of the updateFontCorrectly() function.

I希望能够做索姆像这样的

I want to be able to do something like

this.setValue("Times New Roman");

(而不是通过变量),是从 onClick内部

(and instead pass through a variable), from inside the onClick function as well as from the outside, globally.

从理论上讲,上面的代码可以正常工作,但一次使用后会完全破坏盒子。某些类的jQuery目标(位于CKEditor源码内部)在使用一次后似乎失败,并且RichCombo拒绝打开。

Theoretically, the code above works but breaks the box entirely after one use. Some class jQuery target (deep within the CKEditor source) seems to fail after using it once, and the RichCombo refuses to open.

我将其剥离为

this._.value = "Times New Roman";

但这在使用一次后也会中断。

but this breaks after one use as well.

我必须在这里完全错过一些东西。

I have to be completely missing something here. How can i get this to work?

推荐答案

事实证明这很简单。

this.setValue(foo, "Text");

唯一棘手的部分是 foo 具有作为有效值,例如,它存在于 this ._。items 中。

The only tricky part is that foo has to be a valid value, as in, it exists in this._.items.

如果无效, richCombo将中断。 文字可以是您想要的任何文字。

If it's invalid, the richCombo will break. "Text" can be whatever you want it to be.

这篇关于根据选择更新RichCombo的标签-CKEditor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆