X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Fcontextmenu%2Fplugin.js;h=60aad928cf05778addbcd3ac0ff3d8a08afef36e;hp=1c83546cad690c43846d4033f0910274325c08eb;hb=059b4c2fef02528bf1af189f7996e80652faddfb;hpb=c6e377a02b54abc07129d72b632763c727476a15 diff --git a/_source/plugins/contextmenu/plugin.js b/_source/plugins/contextmenu/plugin.js index 1c83546..60aad92 100644 --- a/_source/plugins/contextmenu/plugin.js +++ b/_source/plugins/contextmenu/plugin.js @@ -35,6 +35,18 @@ CKEDITOR.plugins.contextMenu = CKEDITOR.tools.createClass( editor.execCommand( commandName ); }, this); + + this._.definiton = + { + panel: + { + className : editor.skinClass + ' cke_contextmenu', + attributes : + { + 'aria-label' : editor.lang.common.options + } + } + }; }, _ : @@ -51,7 +63,7 @@ CKEDITOR.plugins.contextMenu = CKEDITOR.tools.createClass( } else { - menu = this._.menu = new CKEDITOR.menu( editor ); + menu = this._.menu = new CKEDITOR.menu( editor, this._.definiton ); menu.onClick = CKEDITOR.tools.bind( function( item ) { menu.hide(); @@ -63,9 +75,26 @@ CKEDITOR.plugins.contextMenu = CKEDITOR.tools.createClass( }, this ); - menu.onEscape = function() + menu.onEscape = function( keystroke ) { - editor.focus(); + var parent = this.parent; + // 1. If it's sub-menu, restore the last focused item + // of upper level menu. + // 2. In case of a top-menu, close it. + if ( parent ) + { + parent._.panel.hideChild(); + // Restore parent block item focus. + var parentBlock = parent._.panel._.panel._.currentBlock, + parentFocusIndex = parentBlock._.focusIndex; + parentBlock._.markItem( parentFocusIndex ); + } + else if ( keystroke == 27 ) + { + this.hide(); + editor.focus(); + } + return false; }; } @@ -196,7 +225,7 @@ CKEDITOR.plugins.contextMenu = CKEDITOR.tools.createClass( CKEDITOR.tools.setTimeout( function() { - this._.onMenu( offsetParent, null, offsetX, offsetY ); + this.show( offsetParent, null, offsetX, offsetY ); }, 0, this ); },