I'm working on a plug-in that includes uses of div's and pre's, each of which should have their own context menu items. The div portion works great (no surprise, it's almost identical to the div plugin) but the pre doesn't show at all.
This is the code I have adding the menu items and context listener
I've narrowed the issue down to the below code returning null.
Anyone have any ideas on why and how to make it work?
This is the code I have adding the menu items and context listener
if ( editor.addMenuItems ) { // div group is default, make sure we have one for pre editor.addMenuGroup('pre'); editor.addMenuItems({ editrepeatblock : { label : 'Edit Repeating Block', command : 'editrepeatblock', group : 'div', icon: this.path + 'images/brick_edit.png' }, removerepeatblock: { label : 'Remove Repeating Block', command : 'removerepeatblock', group : 'div', icon: this.path + 'images/brick_delete.png' }, editlinkedrepeatblock: { label: 'Edit Linked Repeat Block', command: 'editlinkedrepeatblock', group: 'pre', icon: this.path + 'images/link_edit.png' }, removelinkedrepeatblock: { label : 'Remove Linked Repeat Block', command: 'removelinkedrepeatblock', group: 'pre', icon: this.path + 'images/link_delete.png' } }); if ( editor.contextMenu ) { editor.contextMenu.addListener( function( element, selection ) { if ( !element || element.isReadOnly() ) return null; var elementPath = new CKEDITOR.dom.elementPath( element ), blockLimit = elementPath.blockLimit; console.log( elementPath ); if ( blockLimit && blockLimit.getAscendant( 'div', true ) ) { return { editrepeatblock : CKEDITOR.TRISTATE_OFF, removerepeatblock : CKEDITOR.TRISTATE_OFF }; } else if( blockLimit && blockLimit.getAscendant( 'pre', true )) { return { editlinkedrepeatblock : CKEDITOR.TRISTATE_OFF, removelinkedrepeatblock : CKEDITOR.TRISTATE_OFF }; } return null; } ); } }
I've narrowed the issue down to the below code returning null.
blockLimit.getAscendant( 'pre', true )
Anyone have any ideas on why and how to make it work?