2

言語定義の値を変更しようとしています。これは、エディター インスタンスが作成された場所で、特定の条件下で行う必要があります。

私は言語ファイルを変更したくありません。なぜなら、そのファイルはそのままで問題なく、同じ Web サイトの他の編集者は特定の変更を必要としないからです。

誰かが私を助けることができますか?私はCKEDITOR 3.6.1を使用しています

$("form textarea").each(function()
{
    var name = $(this).attr("name");
    var instance = CKEDITOR.instances[name];
    if(instance)
    {
        CKEDITOR.instances[name].destroy(true)
    }

    CKEDITOR.config.format_tags = 'h1;p';

    CKEDITOR.config.format_p = { element : 'p', attributes : { 'class' : 'my_class' } };

    //if(condition) CKEDITOR.config.lang.es.tag_h1 = "My special header";
    //if(condition) CKEDITOR.lang.es.tag_h1 = "My special header";

    CKEDITOR.replace(name);            
});
4

1 に答える 1

0

beforeInit関数を追加して、フォーマット プラグインのコードを変更します。

CKEDITOR.plugins.add( 'format', {
    requires: 'richcombo',
    beforeInit: function( editor ) {
        editor.lang.format.tag_h1 = 'Moooooooo!';
    },
    init: function( editor ) {
        ...

この機能では、ラベルやその他のものが生成され、挿入され、init()以下に表示されるので、すべての言語エントリを変更できます。ここで lang エントリを変更するには、任意の種類の条件を使用できます。


別の解決策: 難しいがグローバル。これにより、ソース コードに触れることなく、すべてのプラグインを 1 か所から上書きできます。

// Save the old CKEDITOR.plugins.load
var orgLoad = CKEDITOR.plugins.load;

// Overwrite CKEDITOR.plugins.load
CKEDITOR.plugins.load = function() {
    // Save the old callback argument.
    var oldCallback = arguments[ 1 ];

    // Overwrite the old callback argument.
    arguments[ 1 ] = function( plugins ) {
        // Modify the plugin by adding beforeInit to the definition.
        plugins.format.beforeInit = function( editor ) {
            editor.lang.format.tag_h1 = 'Moooooooo!';
        };

        // Call the old callback.
        oldCallback.call( this, plugins );
    };

    // Call old CKEDITOR.plugins.load
    orgLoad.apply( this, arguments );
};
于 2013-07-05T08:00:54.427 に答える