Make WordPress Core

Changeset 36716


Ignore:
Timestamp:
02/26/2016 12:20:54 AM (7 years ago)
Author:
azaozz
Message:

TinyMCE, inline link:

  • Make sure the inline dialog is not showing under the advanced modal.
  • Fix checking if the link node contains text.
  • Fix undo levels so all actions can be undone and redone.

See #33301.

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

Legend:

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

    r36597 r36716  
    886886        function hide( event ) {
    887887            if ( activeToolbar ) {
    888                 if ( event.type === 'hide' ) {
     888                if ( activeToolbar.tempHide || event.type === 'hide' ) {
    889889                    activeToolbar.hide();
    890890                    activeToolbar = false;
  • trunk/src/wp-includes/js/tinymce/plugins/wplink/plugin.js

    r36703 r36716  
    224224
    225225        editor.addCommand( 'wp_link_cancel', function() {
    226             inputInstance.reset();
    227             removePlaceholders();
    228             editor.focus();
    229 
    230             if ( tinymce.isIE ) {
    231                 editor.selection.moveToBookmark( editor.windowManager.wplinkBookmark );
    232                 editor.windowManager.wplinkBookmark = null;
     226            if ( ! editToolbar.tempHide ) {
     227                inputInstance.reset();
     228                removePlaceholders();
     229                editor.focus();
     230   
     231                if ( tinymce.isIE ) {
     232                    editor.selection.moveToBookmark( editor.windowManager.wplinkBookmark );
     233                    editor.windowManager.wplinkBookmark = null;
     234                }
     235               
     236                editToolbar.tempHide = false;
    233237            }
    234238        } );
     
    286290        // Prevent adding undo levels on inserting link placeholder.
    287291        editor.on( 'BeforeAddUndo', function( event ) {
    288             if ( event.level.content ) {
    289                 event.level.content = removePlaceholderStrings( event.level.content );
     292            if ( event.lastLevel && event.lastLevel.content && event.level.content &&
     293                event.lastLevel.content === removePlaceholderStrings( event.level.content ) ) {
     294
     295                event.preventDefault();
    290296            }
    291297        });
     
    389395
    390396            if ( tinymce.$( document.body ).hasClass( 'modal-open' ) ) {
     397                editToolbar.tempHide = true;
    391398                return;
    392399            }
     400
     401            editToolbar.tempHide = false;
    393402
    394403            if ( linkNode ) {
     
    433442                        text = inputInstance.getLinkText() || null;
    434443
    435                     editor.focus();
     444                    editor.focus(); // Needed for IE
    436445                    window.wpLink.open( editor.id, url, text );
     446
     447                    editToolbar.tempHide = true;
    437448                    inputInstance.reset();
    438449                }
     
    448459
    449460        return {
    450             hideEditToolbar: function() {
    451                 editToolbar.hide();
     461            close: function() {
     462                editToolbar.tempHide = false;
     463                editor.execCommand( 'wp_link_cancel' );
    452464            }
    453465        };
  • trunk/src/wp-includes/js/wplink.js

    r36703 r36716  
    245245
    246246        mceRefresh: function( url, text ) {
    247             var linkNode = editor.dom.getParent( editor.selection.getNode(), 'a[href]' ),
     247            var linkText,
     248                linkNode = getLink(),
    248249                onlyText = this.hasSelectedText( linkNode );
    249250
    250251            if ( linkNode ) {
    251                 text = tinymce.trim( linkNode.innerText || linkNode.textContent ) || text;
     252                linkText = linkNode.innerText || linkNode.textContent;
     253
     254                if ( ! tinymce.trim( linkText ) ) {
     255                    linkText = text || '';
     256                }
     257
    252258                url = url || editor.dom.getAttrib( linkNode, 'href' );
    253259
     
    265271
    266272            if ( onlyText ) {
    267                 inputs.text.val( text || '' );
     273                inputs.text.val( linkText || '' );
    268274                inputs.wrap.addClass( 'has-text-field' );
    269275            } else {
     
    284290                }
    285291            } else {
    286                 editor.plugins.wplink.hideEditToolbar();
     292                if ( editor.plugins.wplink ) {
     293                    editor.plugins.wplink.close();
     294                }
     295
    287296                editor.focus();
    288297            }
Note: See TracChangeset for help on using the changeset viewer.