In ContextMenuItem tag (See Custom Context Menu) are used two properties:
MainFunction and CheckFunction. These properties contain names of custom defined functions for HTML Editor's
Context Menu processor. The first function should do some execution on node for which the Context Menu was activated.
The second function is used for enabled status definition.
When the function returns true, this item will be enabled in the context menu.
When the function returns false, this item will be disabled in the context menu.
Both functions have two paremeters: HTML Editor object and node for which the Context Menu was activated.
Custom defined Context Menu Item example.
<ed:ContextMenuItem TagName="Table" Title="Remove Shadow" MainFunction="myRemoveShadow" CheckFunction="myRemoveShadowCheck" />
JavaScript functions example.
// Remove Shadow table(wrapper) for the source table//function myRemoveShadow(editor,tableNode){ // Get Editor's content document // var doc = editor.getDocument(); // Get the attached (Shadow) table ID // var shadowId = tableNode.getAttribute(editor.attachedIdAttributeName()); // Get it's node // var shadowNode = doc.getElementById(shadowId); if(shadowNode != null) { // Insert source table before it's shadow // shadowNode.parentNode.insertBefore(tableNode,shadowNode); // Remove the shadow table // shadowNode.parentNode.removeChild(shadowNode); // remove "attachedId" attribute from the source table // tableNode.removeAttribute(editor.attachedIdAttributeName()); }}//// Checks: can be removed Shadow table(wrapper) for the source table//function myRemoveShadowCheck(editor,tableNode){ // // Is there attached "Shadow Table" to this Table? // if(tableNode.getAttribute(editor.attachedIdAttributeName()) &&
tableNode.getAttribute(editor.attachedIdAttributeName()).length > 0) return true; // attached already else return false; // not yet}
See
CustomCM.aspx example in downloaded
zip file.