更改CKEditor中的语言值
change language value in CKEditor
我正在尝试更改语言定义的值。我需要在创建编辑器实例的地方以及在特定条件下执行此操作。
我不想更改语言文件,因为该文件是正常的,也因为同一网站上的其他编辑不需要进行特定的修改。
有人能帮我吗?我正在使用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);
});
通过添加beforeInit
函数修改格式插件的代码:
CKEDITOR.plugins.add( 'format', {
requires: 'richcombo',
beforeInit: function( editor ) {
editor.lang.format.tag_h1 = 'Moooooooo!';
},
init: function( editor ) {
...
在这个函数中,您可以修改所有的语言条目,因为标签和内容会在下面的init()
中生成、插入和显示。您可以使用任何类型的条件来更改此处的lang条目。
另一个解决方案:更难,但全球化。有了这个,你可以从一个地方覆盖所有插件,而无需接触源代码:
// 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 );
};
相关文章:
- CKEditor Widget-阻止编辑可编辑元素本身
- Ckeditor-plugin:插入虚假元素add不情愿<p>标签前后
- 防止Alt+Shift默认操作或检测多种操作系统语言的Javascript
- CKEditor-我在editor.css中的风格是't
- CKeditor:更改对话框中的默认选择选项
- 删除CKEditor工具栏按钮,但不删除功能
- CKEditor v4:自制插件中对话框的动态标题
- 收听ckeditor小部件事件
- CKEditor如何允许href="javascript:void(0)"在小部件中
- Express服务器中语言子域的最佳实践
- Django可以'不能在设置中导入ckeditor,但可以在shell中导入
- 我想在Javascript中探索类似C语言的字符串的整个字符
- 我们可以使用任意的编程语言来动态化HTML页面吗
- 当我选择英语以外的任何其他语言时,无法在ckeditor中键入任何语言,只显示英文字母
- 如何用ASP.Net C#更改CKEditor的输入语言
- CKeditor语言方向
- 更改CKEditor中的语言值
- 如何定义CKEditor用于搜索配置/语言文件的路径
- 添加自定义语言文件到CKEditor
- 如何在运行时从javascript更改CKEditor语言