0
我试图建立一个自定义插件在CKEditor的其中一个选择的单选按钮列表中的元素的更改类所选元素的对话框。例如:CKEDITOR定制插件 - 与单选按钮
选课BIG
将添加类big
,MEDIUM
=>med
和SMALL
=>sml
。
我阻塞在我必须检索所选元素的值的部分。 Eveything否则会罚款,我在代码托管波纹管应用类“MYCLASS”到最近的li
标签。
问题:如何获取CKeditor的dialog
元素中所选单选按钮的值?
下面的代码:
CKEDITOR.dialog.add('MyDialog', function (editor) {
function getListElement(editor, listTag) {
var range;
try {
range = editor.getSelection().getRanges()[ 0 ];
} catch (e) {
return null;
}
range.shrink(CKEDITOR.SHRINK_TEXT);
return editor.elementPath(range.getCommonAncestor()).contains(listTag, 1);
}
return {
title: 'Size of the element',
minWidth: 400,
minHeight: 200,
contents: [
{
id: 'tab-basic',
label: 'Size of an element',
elements: [
{
type: 'radio',
id: 'bullet-size',
label: 'Size of the bullets',
items: [ [ 'BIG', 'big' ], [ 'MEDIUM', 'mdm' ],[ 'SMALL', 'sml' ] ],
style: 'color: green',
'default': 'big',
},
]
},
],
onOk: function() {
var editor = this.getParentEditor(),
element = getListElement(editor, 'ul'),
dialog = this,
config = editor.config,
lang = editor.lang,
style = new CKEDITOR.style(config.coreStyles_alpha);
editor.attachStyleStateChange(style, function(state) {
!editor.readOnly;
});
count = element.getChildren().count();
for(k=1; k <= count; k++){
element.getChild(k-1).setAttribute('class', 'MyClass');
}
}
}
});