Make WordPress Core

Changeset 44695


Ignore:
Timestamp:
01/24/2019 11:10:34 AM (6 years ago)
Author:
azaozz
Message:

TinyMCE Classic Block: fix the Edit Image modal to work as in the Classic Editor.

Fixes #46085.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/vendor/tinymce/plugins/wpeditimage/plugin.js

    r43309 r44695  
    348348    }
    349349
    350     function updateImage( imageNode, imageData ) {
    351         var classes, className, node, html, parent, wrap, linkNode,
     350    function updateImage( $imageNode, imageData ) {
     351        var classes, className, node, html, parent, wrap, linkNode, imageNode,
    352352            captionNode, dd, dl, id, attrs, linkAttrs, width, height, align,
    353353            $imageNode, srcset, src,
    354354            dom = editor.dom;
    355355
     356        if ( ! $imageNode || ! $imageNode.length ) {
     357            return;
     358        }
     359
     360        imageNode = $imageNode[0];
    356361        classes = tinymce.explode( imageData.extraClasses, ' ' );
    357362
     
    390395
    391396        // Preserve empty alt attributes.
    392         editor.$( imageNode ).attr( 'alt', imageData.alt || '' );
     397        $imageNode.attr( 'alt', imageData.alt || '' );
    393398
    394399        linkAttrs = {
     
    514519
    515520    function editImage( img ) {
    516         var frame, callback, metadata;
     521        var frame, callback, metadata, imageNode;
    517522
    518523        if ( typeof wp === 'undefined' || ! wp.media ) {
     
    522527
    523528        metadata = extractImageData( img );
     529
     530        // Mark the image node so we can select it later.
     531        editor.$( img ).attr( 'data-wp-editing', 1 );
    524532
    525533        // Manipulate the metadata by reference that is fed into the PostImage model used in the media modal
     
    539547
    540548        callback = function( imageData ) {
    541             editor.focus();
    542549            editor.undoManager.transact( function() {
    543                 updateImage( img, imageData );
     550                updateImage( imageNode, imageData );
    544551            } );
    545552            frame.detach();
     
    551558            editor.focus();
    552559            frame.detach();
     560
     561            // `close` fires first...
     562            // To be able to update the image node, we need to find it here,
     563            // and use it in the callback.
     564            imageNode = editor.$( 'img[data-wp-editing]' )
     565            imageNode.removeAttr( 'data-wp-editing' );
    553566        });
    554567
     
    811824    editor.on( 'beforeGetContent', function( event ) {
    812825        if ( event.format !== 'raw' ) {
    813             editor.$( 'img[id="__wp-temp-img-id"]' ).attr( 'id', null );
     826            editor.$( 'img[id="__wp-temp-img-id"]' ).removeAttr( 'id' );
    814827        }
    815828    });
  • trunk/src/wp-includes/css/editor.css

    r44637 r44695  
    12121212}
    12131213
     1214.mce-content-body dl.wp-caption {
     1215    max-width: 100%;
     1216}
     1217
    12141218/* Quicktags */
    12151219.quicktags-toolbar {
Note: See TracChangeset for help on using the changeset viewer.