How to create Dynamic Menu in CK editor using javascript ?
Please See the screen shot of current working code for details.

I want dynamic context menu
if array has 2 words means need to create and show only words in context menu need to reduce the context menu length,
if array has 4 words menas need to create context menu for four words
Here result is declared as array.
var ckedit ;
editor.on('instanceReady', function (e) {
var e = e.editor;
ckedit = e;
e.addMenuGroup("cv_people", 100);
e.addMenuItems({
// Addmenu context menu
cv: {
label: "Suggestions",
group: "cv",
getItems: function () {
ckedit.addCommand("cv1", {
exec: function (ckedit) {
ckedit.insertText(result[0]);
}
});
ckedit.addCommand("cv2", {
exec: function (ckedit) {
ckedit.insertText(result[1]);
}
});
ckedit.addCommand("cv3", {
exec: function (ckedit) {
ckedit.insertText(result[2]);
}
});
ckedit.addCommand("cv4", {
exec: function (ckedit) {
ckedit.insertText(result[3]);
}
});
return {
cv1: CKEDITOR.TRISTATE_ON,
cv2: CKEDITOR.TRISTATE_OFF,
cv3: CKEDITOR.TRISTATE_OFF,
cv4: CKEDITOR.TRISTATE_OFF,
};
}
}
});
}
cv1: {
label: " ",
group: "cv_people",
getItems: function () {
//alert("ok");
}
},
cv2: {
label: " ",
group: "cv_people",
getItems: function () {
//alert("ok");
}
},
cv3: {
label: " ",
group: "cv_people",
getItems: function () {
//alert("ok");
}
},
cv4: {
label: " ",
group: "cv_people",
getItems: function () {
//alert("ok");
}
},
Please help me to get contextmenu in dynamic.
Please See the screen shot of current working code.