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');
}
}
}
});