Skip to content

Commit

Permalink
Merge branch 't/16850' into major
Browse files Browse the repository at this point in the history
  • Loading branch information
Comandeer committed Feb 28, 2017
2 parents 191a00e + c9ba18c commit 56e6fda
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -6,6 +6,7 @@
New Features:

* [#16818](http://dev.ckeditor.com/ticket/16818): Added table cell height parsing in the [Paste from Word](http://ckeditor.com/addon/pastefromword) plugin.
* [#16850](http://dev.ckeditor.com/ticket/16850): Added new `config.enableContextMenu` configuration option for enabling and disabling [Context Menu](http://ckeditor.com/addon/contextmenu).

Fixed Issues:

Expand Down
14 changes: 14 additions & 0 deletions plugins/contextmenu/plugin.js
Expand Up @@ -111,6 +111,10 @@ CKEDITOR.plugins.add( 'contextmenu', {
* @param {Number} [offsetY]
*/
open: function( offsetParent, corner, offsetX, offsetY ) {
if ( this.editor.config.enableContextMenu === false ) {
return;
}

this.editor.focus();
offsetParent = offsetParent || CKEDITOR.document.getDocumentElement();

Expand Down Expand Up @@ -157,3 +161,13 @@ CKEDITOR.plugins.add( 'contextmenu', {
* @cfg {Boolean} [browserContextMenuOnCtrl=true]
* @member CKEDITOR.config
*/

/**
* Whether to enable the context menu. Regardless of the setting the plugin is still loaded.
*
* config.enableContextMenu = true;
*
* @since 4.7.0
* @cfg {Boolean} [enableContextMenu=true]
* @member CKEDITOR.config
*/
27 changes: 27 additions & 0 deletions tests/plugins/contextmenu/contextmenu.js
Expand Up @@ -31,6 +31,33 @@
} );
},

'test opening context menu default config': function() {
bender.editorBot.create( {
name: 'editor_nocontextmenu1'
}, function( bot ) {
bot.editor.contextMenu.show = sinon.spy();

bot.editor.contextMenu.open( bot.editor.editable() );

assert.isTrue( bot.editor.contextMenu.show.called );
} );
},

'test opening disabled context menu': function() {
bender.editorBot.create( {
name: 'editor_nocontextmenu2',
config: {
enableContextMenu: false
}
}, function( bot ) {
bot.editor.contextMenu.show = sinon.spy();

bot.editor.contextMenu.open( bot.editor.editable() );

assert.isFalse( bot.editor.contextMenu.show.called );
} );
},

'#9706: test opening contextmenu in editable that does not autoparagraph': function() {
bender.editorBot.create( {
name: 'editor3',
Expand Down
22 changes: 22 additions & 0 deletions tests/plugins/contextmenu/manual/disabled.html
@@ -0,0 +1,22 @@
<textarea id="editor1" cols="10" rows="10">
<table border="1" cellspacing="1" cellpadding="1" style="width:500px">
<tbody>
<tr>
<td colspan="2" style="background-color:#ffdddd"></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</textarea>
<script>
CKEDITOR.replace( 'editor1', {
enableContextMenu: false
} );
</script>
12 changes: 12 additions & 0 deletions tests/plugins/contextmenu/manual/disabled.md
@@ -0,0 +1,12 @@
@bender-ui: collapsed
@bender-tags: wyswigarea, tc, 4.7.0, 16850
@bender-ckeditor-plugins: wysiwygarea,toolbar,table,tabletools,sourcearea

**Test Scenario**

1. Make sure you see a table with a pink, one-cell first row.
2. Try to open the context menu by right-clicking on the table.

**Expected**

Context menu does not appear.

0 comments on commit 56e6fda

Please sign in to comment.