wpLink: Make the text editor experience the same as in the visual editor.

props azaozz.
fixes #31890.


git-svn-id: https://develop.svn.wordpress.org/trunk@32242 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Helen Hou-Sandi 2015-04-21 13:58:09 +00:00
parent afe046a84c
commit 5ff0ea1fcf

View File

@ -142,6 +142,8 @@ var wpLink;
},
refresh: function() {
var text = '';
// Refresh rivers (clear links, check visibility)
rivers.search.refresh();
rivers.recent.refresh();
@ -149,8 +151,21 @@ var wpLink;
if ( wpLink.isMCE() ) {
wpLink.mceRefresh();
} else {
inputs.wrap.removeClass( 'has-text-field' );
inputs.text.val( '' );
// For the Text editor the "Link text" field is always shown
if ( ! inputs.wrap.hasClass( 'has-text-field' ) ) {
inputs.wrap.addClass( 'has-text-field' );
}
if ( document.selection ) {
// Old IE
text = document.selection.createRange().text || '';
} else if ( typeof this.textarea.selectionStart !== 'undefined' &&
( this.textarea.selectionStart !== this.textarea.selectionEnd ) ) {
// W3C
text = this.textarea.value.substring( this.textarea.selectionStart, this.textarea.selectionEnd ) || '';
}
inputs.text.val( text );
wpLink.setDefaultValues();
}