TinyMCE: fix the "active" state of the Link button when an image wrapped in a link is selected, see #27847, for trunk.

Built from https://develop.svn.wordpress.org/trunk@28185


git-svn-id: http://core.svn.wordpress.org/trunk@28016 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2014-04-22 21:11:14 +00:00
parent 6deb34ebb3
commit f81a107cee
3 changed files with 5 additions and 3 deletions

View File

@ -15,8 +15,10 @@ tinymce.PluginManager.add( 'wplink', function( editor ) {
editor.addShortcut( 'ctrl+k', '', 'WP_Link' );
function setState( button, node ) {
button.disabled( editor.selection.isCollapsed() && node.nodeName !== 'A' );
button.active( node.nodeName === 'A' && ! node.name );
var parent = editor.dom.getParent( node, 'a' );
button.disabled( ( editor.selection.isCollapsed() && ! parent ) || ( parent && ! parent.href ) );
button.active( parent && parent.href );
}
editor.addButton( 'link', {

View File

@ -1 +1 @@
tinymce.PluginManager.add("wplink",function(a){function b(b,c){b.disabled(a.selection.isCollapsed()&&"A"!==c.nodeName),b.active("A"===c.nodeName&&!c.name)}var c;a.addCommand("WP_Link",function(){c&&c.disabled()||"undefined"==typeof window.wpLink||window.wpLink.open(a.id)}),a.addShortcut("alt+shift+a","","WP_Link"),a.addShortcut("ctrl+k","","WP_Link"),a.addButton("link",{icon:"link",tooltip:"Insert/edit link",shortcut:"Alt+Shift+A",cmd:"WP_Link",onPostRender:function(){c=this,a.on("nodechange",function(a){b(c,a.element)})}}),a.addButton("unlink",{icon:"unlink",tooltip:"Remove link",cmd:"unlink",onPostRender:function(){var c=this;a.on("nodechange",function(a){b(c,a.element)})}}),a.addMenuItem("link",{icon:"link",text:"Insert link",shortcut:"Alt+Shift+A",cmd:"WP_Link",stateSelector:"a[href]",context:"insert",prependToContext:!0})});
tinymce.PluginManager.add("wplink",function(a){function b(b,c){var d=a.dom.getParent(c,"a");b.disabled(a.selection.isCollapsed()&&!d||d&&!d.href),b.active(d&&d.href)}var c;a.addCommand("WP_Link",function(){c&&c.disabled()||"undefined"==typeof window.wpLink||window.wpLink.open(a.id)}),a.addShortcut("alt+shift+a","","WP_Link"),a.addShortcut("ctrl+k","","WP_Link"),a.addButton("link",{icon:"link",tooltip:"Insert/edit link",shortcut:"Alt+Shift+A",cmd:"WP_Link",onPostRender:function(){c=this,a.on("nodechange",function(a){b(c,a.element)})}}),a.addButton("unlink",{icon:"unlink",tooltip:"Remove link",cmd:"unlink",onPostRender:function(){var c=this;a.on("nodechange",function(a){b(c,a.element)})}}),a.addMenuItem("link",{icon:"link",text:"Insert link",shortcut:"Alt+Shift+A",cmd:"WP_Link",stateSelector:"a[href]",context:"insert",prependToContext:!0})});