I am hacking a plugin called yaspeller , trying to create 3 options - Ignore , Ignore All , Add Word to the Context Menu .As a start I did this much ...but not working ?
I dont see anything in the context menu basically other than the spellchecker things.
#Already existing
if (editor.addMenuItem) {
editor.addMenuGroup('yaspellergroup', -1);
}
#I added modelling on what is required .
[color=#FF4000]
if (editor.addMenuItem) {
// A group menu is required
// order, as second parameter, is not required
editor.addMenuGroup('testgroup');
// Create a menu item
editor.addMenuItem('testitem', {
label: 'Do something',
onClick: function () {
replaceWord(this.editor, this.label);
},
group: 'testgroup'
});
}
if (editor.contextMenu) {
editor.contextMenu.addListener(function(element, selection) {
// Get elements parent, strong parent first
var parents = element.getParents("strong");
// Check if it's strong
if (parents[0].getName() != "strong")
return null; // No item
// Show item
return { testitem: CKEDITOR.TRISTATE_OFF };
});
}[/color]
#Already existing code .
if (editor.contextMenu) {
editor.contextMenu.addListener(function (element, selection) {
if (element && element.is('span') && element.getAttribute('data-spell-word')) {
var e_word = element.getText();
var ea = {};
if (yaspeller_errors[editor.name][e_word].s.length > 0) {
var i;
// alert("Hi");
for (i = 0; i < yaspeller_errors[editor.name][e_word].s.length; i++) {
// alert('yaspelleritem' + yaspeller_errors[editor.name][e_word].s[i]);
editor.addMenuItem('yaspelleritem' + yaspeller_errors[editor.name][e_word].s[i], {
label: yaspeller_errors[editor.name][e_word].s[i],
onClick: function () {
replaceWord(this.editor, this.label);
},
group: 'yaspellergroup',
order: -1
});
ea['yaspelleritem' + yaspeller_errors[editor.name][e_word].s[i]] = CKEDITOR.TRISTATE_OFF;
}
} else {
editor.addMenuItem('yaspellerno', {
label: 'No variants for "' + e_word + '"',
group: 'yaspellergroup',
order: -1
});
ea['yaspellerno'] = CKEDITOR.TRISTATE_DISABLED;
}
return ea;
} else {
return null;
}
});
}
}
});
I dont see anything in the context menu basically other than the spellchecker things.
