Ticket #28206: 28206.patch
File 28206.patch, 1.8 KB (added by , 10 years ago) |
---|
-
src/wp-includes/js/tinymce/plugins/wplink/plugin.js
1 1 /* global tinymce */ 2 2 tinymce.PluginManager.add( 'wplink', function( editor ) { 3 var linkButton;4 5 // Register a command so that it can be invoked by using tinyMCE.activeEditor.execCommand( 'WP_Link' );6 3 editor.addCommand( 'WP_Link', function() { 7 if ( ( ! linkButton || ! linkButton.disabled() ) && typeof window.wpLink !== 'undefined' ) { 8 window.wpLink.open( editor.id ); 9 } 4 window.wpLink && window.wpLink.open( editor.id ); 10 5 }); 11 6 12 7 // WP default shortcut … … 14 9 // The "de-facto standard" shortcut, see #27305 15 10 editor.addShortcut( 'ctrl+k', '', 'WP_Link' ); 16 11 17 function setState( button, node ) {18 var parent = editor.dom.getParent( node, 'a' ),19 getView = editor.plugins.wpview ? editor.plugins.wpview.getView : function() { return false; };20 21 button.disabled( ( editor.selection.isCollapsed() && ! parent ) || ( parent && ! parent.href ) || getView( node ) );22 button.active( parent && parent.href );23 }24 25 12 editor.addButton( 'link', { 26 13 icon: 'link', 27 14 tooltip: 'Insert/edit link', 28 15 shortcut: 'Alt+Shift+A', 29 16 cmd: 'WP_Link', 30 31 onPostRender: function() { 32 linkButton = this; 33 34 editor.on( 'nodechange', function( event ) { 35 setState( linkButton, event.element ); 36 }); 37 } 17 stateSelector: 'a[href]' 38 18 }); 39 19 40 20 editor.addButton( 'unlink', { 41 21 icon: 'unlink', 42 22 tooltip: 'Remove link', 43 cmd: 'unlink', 44 45 onPostRender: function() { 46 var unlinkButton = this; 47 48 editor.on( 'nodechange', function( event ) { 49 setState( unlinkButton, event.element ); 50 }); 51 } 23 cmd: 'unlink' 52 24 }); 53 25 54 26 editor.addMenuItem( 'link', {