Make WordPress Core

Changeset 36743


Ignore:
Timestamp:
02/27/2016 12:51:41 AM (11 years ago)
Author:
azaozz
Message:

TinyMCE, inline link:

  • Fix applying the changes when pressing the Enter key in Firefox. No longer inserts new paragraph in the editor.
  • Fix empty check when getting text from the dialog.
  • Always focus the URL field when opening the dialog.
  • Add back the keydown events in the modal.

See #33301.

Location:
trunk/src/wp-includes/js
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/tinymce/plugins/wplink/plugin.js

    r36716 r36743  
    6969                },
    7070                getLinkText: function() {
    71                         return tinymce.trim( this.getEl().firstChild.nextSibling.value );
     71                        var text = this.getEl().firstChild.nextSibling.value;
     72
     73                        if ( ! tinymce.trim( text ) ) {
     74                                return '';
     75                        }
     76
     77                        return text.replace( /[\r\n\t ]+/g, ' ' );
    7278                },
    7379                reset: function() {
     
    145151
    146152                                editToolbar.on( 'show', function() {
    147                                         var inputNode = editToolbar.find( 'toolbar' )[0];
    148 
    149                                         if ( inputNode && ! tinymce.$( document.body ).hasClass( 'modal-open' ) ) {
     153                                        if ( ! tinymce.$( document.body ).hasClass( 'modal-open' ) ) {
    150154                                                window.setTimeout( function() {
    151                                                         inputNode.focus( true );
    152                                                 });
     155                                                        var element = editToolbar.$el.find( 'input.ui-autocomplete-input' )[0];
     156
     157                                                        if ( element ) {
     158                                                                element.focus();
     159                                                                element.select();
     160                                                        }
     161                                                } );
    153162                                        }
    154163                                } );
     
    172181                                return;
    173182                        }
     183
     184                        editToolbar.tempHide = false;
    174185
    175186                        if ( link ) {
     
    182193                                        editor.windowManager.wplinkBookmark = editor.selection.getBookmark();
    183194                                }
     195
     196                                editor.nodeChanged();
    184197                        }
    185198                } );
     
    228241                                removePlaceholders();
    229242                                editor.focus();
    230        
     243
    231244                                if ( tinymce.isIE ) {
    232245                                        editor.selection.moveToBookmark( editor.windowManager.wplinkBookmark );
    233246                                        editor.windowManager.wplinkBookmark = null;
    234247                                }
    235                                
     248
    236249                                editToolbar.tempHide = false;
    237250                        }
     
    385398                                        if ( event.keyCode === 13 ) {
    386399                                                editor.execCommand( 'wp_link_apply' );
     400                                                event.preventDefault();
    387401                                        }
    388402                                } );
  • trunk/src/wp-includes/js/wplink.js

    r36716 r36743  
    3030                        }
    3131
    32                         inputs.submit.click( function( event ) {
     32                        inputs.dialog.on( 'keydown', wpLink.keydown );
     33                        inputs.submit.on( 'click', function( event ) {
    3334                                event.preventDefault();
    3435                                wpLink.update();
     
    211212                                window.setTimeout( function() {
    212213                                        inputs.url.focus()[0].select();
    213                                 }, 100 );
     214                                } );
    214215                        }
    215216
     
    432433                },
    433434
     435                keydown: function( event ) {
     436                        var id;
     437
     438                        // Escape key.
     439                        if ( 27 === event.keyCode ) {
     440                                wpLink.close();
     441                                event.stopImmediatePropagation();
     442                        // Tab key.
     443                        } else if ( 9 === event.keyCode ) {
     444                                id = event.target.id;
     445
     446                                // wp-link-submit must always be the last focusable element in the dialog.
     447                                // following focusable elements will be skipped on keyboard navigation.
     448                                if ( id === 'wp-link-submit' && ! event.shiftKey ) {
     449                                        inputs.close.focus();
     450                                        event.preventDefault();
     451                                } else if ( id === 'wp-link-close' && event.shiftKey ) {
     452                                        inputs.submit.focus();
     453                                        event.preventDefault();
     454                                }
     455                        }
     456                },
     457
    434458                setDefaultValues: function() {
    435459                        var selection,
Note: See TracChangeset for help on using the changeset viewer.