+ mceRefresh: function( searchStr, text ) {
+ var linkText, href,
+ linkNode = getLink(),
+ onlyText = this.hasSelectedText( linkNode );
+
+ if ( linkNode ) {
+ linkText = linkNode.textContent || linkNode.innerText;
+ href = editor.dom.getAttrib( linkNode, 'href' );
+
+ if ( ! $.trim( linkText ) ) {
+ linkText = text || '';
+ }
+
+ if ( searchStr && ( urlRegexp.test( searchStr ) || emailRegexp.test( searchStr ) ) ) {
+ href = searchStr;
+ }
+
+ if ( href !== '_wp_link_placeholder' ) {
+ inputs.url.val( href );
+ inputs.openInNewTab.prop( 'checked', '_blank' === editor.dom.getAttrib( linkNode, 'target' ) );
+ inputs.submit.val( wpLinkL10n.update );
+ } else {
+ this.setDefaultValues( linkText );
+ }
+
+ if ( searchStr && searchStr !== href ) {
+ // The user has typed something in the inline dialog. Trigger a search with it.
+ inputs.search.val( searchStr );
+ } else {
+ inputs.search.val( '' );
+ }
+
+ // Always reset the search
+ window.setTimeout( function() {
+ wpLink.searchInternalLinks();
+ } );
+ } else {
+ linkText = editor.selection.getContent({ format: 'text' }) || text || '';
+ this.setDefaultValues( linkText );
+ }
+
+ if ( onlyText ) {
+ inputs.text.val( linkText );
+ inputs.wrap.addClass( 'has-text-field' );
+ } else {
+ inputs.text.val( '' );
+ inputs.wrap.removeClass( 'has-text-field' );
+ }