+ mceRefresh: function() {
+ var text,
+ selectedNode = editor.selection.getNode(),
+ linkNode = editor.dom.getParent( selectedNode, 'a[href]' ),
+ onlyText = this.hasSelectedText( linkNode );
+
+ if ( linkNode ) {
+ text = linkNode.innerText || linkNode.textContent;
+ inputs.url.val( editor.dom.getAttrib( linkNode, 'href' ) );
+ inputs.openInNewTab.prop( 'checked', '_blank' === editor.dom.getAttrib( linkNode, 'target' ) );
+ inputs.submit.val( wpLinkL10n.update );
+ } else {
+ text = editor.selection.getContent({ format: 'text' });
+ this.setDefaultValues();
+ }
+
+ if ( onlyText ) {
+ inputs.text.val( text || '' );
+ inputs.wrap.addClass( 'has-text-field' );
+ } else {
+ inputs.text.val( '' );
+ inputs.wrap.removeClass( 'has-text-field' );
+ }