Make WordPress Core

Changeset 24841


Ignore:
Timestamp:
07/29/2013 01:01:33 AM (12 years ago)
Author:
helen
Message:

Set the default internal search value for the link dialog to be the text that is highlighted in the editor. props greuben. fixes #16276.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/js/wplink.js

    r24419 r24841  
    280280        },
    281281        setDefaultValues : function() {
     282            var selectedText,
     283                textarea = wpLink.textarea;
     284
    282285            // Set URL and description to defaults.
    283286            // Leave the new tab setting as-is.
    284287            inputs.url.val('http://');
    285288            inputs.title.val('');
     289            if ( wpLink.isMCE() ) {
     290                selectedText = tinyMCEPopup.editor.selection.getContent( { format: 'text' } );
     291            } else {
     292                if ( document.selection && wpLink.range ) {
     293                    selectedText = wpLink.range.text;
     294                } else if ( typeof textarea.selectionStart !== 'undefined' ) {
     295                    selectedText = textarea.value.substring( textarea.selectionStart, textarea.selectionEnd );
     296                }
     297            }
     298            if ( selectedText && ( selectedText = selectedText.replace( /^\s+|\s+$/g, '' ) ) ) {
     299                if ( ! $('#search-panel').is(':visible') )
     300                    $('#internal-toggle').trigger('click');
     301                inputs.search.val( selectedText ).trigger('keyup');
     302            }
    286303
    287304            // Update save prompt.
Note: See TracChangeset for help on using the changeset viewer.