TinyMCE: add Ctrl+K, the "de-facto standard" shortcut to open wpLink, fixes #27305

git-svn-id: https://develop.svn.wordpress.org/trunk@27449 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2014-03-07 03:09:00 +00:00
parent 142b5208fa
commit 5a13b572cb
2 changed files with 11 additions and 5 deletions

View File

@ -420,7 +420,6 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
editor.addShortcut( modKey + '+u', '', 'InsertUnorderedList' );
editor.addShortcut( modKey + '+o', '', 'InsertOrderedList' );
editor.addShortcut( modKey + '+n', '', 'mceSpellCheck' );
editor.addShortcut( modKey + '+a', '', 'WP_Link' );
editor.addShortcut( modKey + '+s', '', 'unlink' );
editor.addShortcut( modKey + '+m', '', 'WP_Medialib' );
editor.addShortcut( modKey + '+z', '', 'WP_Adv' );

View File

@ -1,12 +1,19 @@
/* global tinymce */
tinymce.PluginManager.add( 'wplink', function( editor ) {
var linkButton;
// Register a command so that it can be invoked by using tinyMCE.activeEditor.execCommand( 'WP_Link' );
editor.addCommand( 'WP_Link', function() {
if ( typeof window.wpLink !== 'undefined' ) {
if ( ( ! linkButton || ! linkButton.disabled() ) && typeof window.wpLink !== 'undefined' ) {
window.wpLink.open( editor.id );
}
});
// WP default shortcut
editor.addShortcut( 'alt+shift+a', '', 'WP_Link' );
// The "de-facto standard" shortcut, see #27305
editor.addShortcut( 'ctrl+k', '', 'WP_Link' );
editor.addButton( 'link', {
icon: 'link',
tooltip: 'Insert/edit link',
@ -14,13 +21,13 @@ tinymce.PluginManager.add( 'wplink', function( editor ) {
cmd: 'WP_Link',
onPostRender: function() {
var ctrl = this;
linkButton = this;
editor.on( 'nodechange', function( event ) {
var node = event.element;
ctrl.disabled( editor.selection.isCollapsed() && node.nodeName !== 'A' );
ctrl.active( node.nodeName === 'A' && ! node.name );
linkButton.disabled( editor.selection.isCollapsed() && node.nodeName !== 'A' );
linkButton.active( node.nodeName === 'A' && ! node.name );
});
}
});