| 1 | Index: wp-includes/js/wplink.dev.js |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/js/wplink.dev.js (revision 19998) |
|---|
| 4 | +++ wp-includes/js/wplink.dev.js (working copy) |
|---|
| 5 | @@ -10,6 +10,8 @@ |
|---|
| 6 | keySensitivity: 100, |
|---|
| 7 | lastSearch: '', |
|---|
| 8 | textarea: '', |
|---|
| 9 | + selectionStart: 0, |
|---|
| 10 | + selectionEnd: 0, |
|---|
| 11 | |
|---|
| 12 | init : function() { |
|---|
| 13 | inputs.dialog = $('#wp-link'); |
|---|
| 14 | @@ -63,6 +65,11 @@ |
|---|
| 15 | return; |
|---|
| 16 | |
|---|
| 17 | this.textarea = $('#'+wpActiveEditor).get(0); |
|---|
| 18 | + // save selection info before losing focus |
|---|
| 19 | + if( typeof this.textarea.selectionStart !== 'undefined' ) { |
|---|
| 20 | + this.selectionStart = this.textarea.selectionStart; |
|---|
| 21 | + this.selectionEnd = this.textarea.selectionEnd; |
|---|
| 22 | + } |
|---|
| 23 | |
|---|
| 24 | // Initialize the dialog if necessary (html mode). |
|---|
| 25 | if ( ! inputs.dialog.data('wpdialog') ) { |
|---|
| 26 | @@ -185,8 +192,8 @@ |
|---|
| 27 | // Insert HTML |
|---|
| 28 | // W3C |
|---|
| 29 | if ( typeof textarea.selectionStart !== 'undefined' ) { |
|---|
| 30 | - start = textarea.selectionStart; |
|---|
| 31 | - end = textarea.selectionEnd; |
|---|
| 32 | + start = wpLink.selectionStart; |
|---|
| 33 | + end = wpLink.selectionEnd; |
|---|
| 34 | selection = textarea.value.substring( start, end ); |
|---|
| 35 | html = html + selection + '</a>'; |
|---|
| 36 | cursor = start + html.length; |
|---|