Make WordPress Core

Changeset 28614


Ignore:
Timestamp:
05/29/2014 07:50:35 AM (11 years ago)
Author:
azaozz
Message:

TinyMCE: fix problems with undo/redo after resizing an image several times. Fixes #28389.

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

Legend:

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

    r28190 r28614  
    436436        rectangle = dom.getRect( node );
    437437
    438         toolbarHtml = '<div class="dashicons dashicons-edit edit" data-mce-bogus="1"></div>' +
    439             '<div class="dashicons dashicons-no-alt remove" data-mce-bogus="1"></div>';
    440 
    441         toolbar = dom.create( 'div', {
     438        toolbarHtml = '<i class="dashicons dashicons-edit edit" data-mce-bogus="1"></i>' +
     439            '<i class="dashicons dashicons-no-alt remove" data-mce-bogus="1"></i>';
     440
     441        toolbar = dom.create( 'p', {
    442442            'id': 'wp-image-toolbar',
    443443            'data-mce-bogus': '1',
     
    754754
    755755    editor.on( 'ObjectResized', function( event ) {
    756         var parent, width,
    757             node = event.target,
    758             dom = editor.dom;
     756        var node = event.target;
    759757
    760758        if ( node.nodeName === 'IMG' ) {
    761             node.className = node.className.replace( /\bsize-[^ ]+/, '' );
    762 
    763             if ( parent = dom.getParent( node, '.wp-caption' ) ) {
    764                 width = event.width || dom.getAttrib( node, 'width' );
    765 
    766                 if ( width ) {
    767                     width = parseInt( width, 10 );
    768 
    769                     if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) {
    770                         width += 10;
     759            editor.undoManager.transact( function() {
     760                var parent, width,
     761                    dom = editor.dom;
     762
     763                node.className = node.className.replace( /\bsize-[^ ]+/, '' );
     764
     765                if ( parent = dom.getParent( node, '.wp-caption' ) ) {
     766                    width = event.width || dom.getAttrib( node, 'width' );
     767
     768                    if ( width ) {
     769                        width = parseInt( width, 10 );
     770
     771                        if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) {
     772                            width += 10;
     773                        }
     774
     775                        dom.setStyle( parent, 'width', width + 'px' );
    771776                    }
    772 
    773                     dom.setStyle( parent, 'width', width + 'px' );
    774                 }
    775             }
    776             // refresh toolbar
    777             addToolbar( node );
     777                }
     778                // refresh toolbar
     779                addToolbar( node );
     780            });
    778781        }
    779782    });
     
    922925        }
    923926
    924         if ( node.nodeName === 'DIV' && dom.getParent( node, '#wp-image-toolbar' ) ) {
     927        if ( node.nodeName === 'I' && dom.getParent( node, '#wp-image-toolbar' ) ) {
    925928            image = dom.select( 'img[data-wp-imgselect]' )[0];
    926929
     
    941944    });
    942945
     946    // Remove toolbar from undo levels
     947    editor.on( 'BeforeAddUndo', function( event ) {
     948        event.level.content = event.level.content.replace( /<p [^>]*data-mce-bogus[^>]+>[\s\S]*<\/p>/g, '' );
     949    });
     950
    943951    editor.on( 'cut', function() {
    944952        removeToolbar();
     
    954962
    955963    editor.on( 'BeforeSetContent', function( event ) {
    956         event.content = editor.wpSetImgCaption( event.content );
     964        if ( event.format !== 'raw' ) {
     965            event.content = editor.wpSetImgCaption( event.content );
     966        }
    957967    });
    958968
  • trunk/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css

    r28565 r28614  
    262262
    263263.wpview-wrap .toolbar div,
    264 #wp-image-toolbar div {
     264#wp-image-toolbar i {
    265265    margin-top: 7px;
    266266    margin-left: 7px;
     
    278278.ie8 .wpview-wrap .toolbar div,
    279279.ie7 .wpview-wrap .toolbar div,
    280 .ie8 #wp-image-toolbar div,
    281 .ie7 #wp-image-toolbar div {
     280.ie8 #wp-image-toolbar i,
     281.ie7 #wp-image-toolbar i {
    282282    display: inline;
    283283    padding: 0;
     
    320320
    321321.wpview-wrap .toolbar div:hover,
    322 #wp-image-toolbar div:hover {
     322#wp-image-toolbar i:hover {
    323323    box-shadow: 0 1px 3px rgba(0,0,0,0.8);
    324324    background-color: #000;
     
    472472
    473473.rtl .wpview-wrap .toolbar div,
    474 .rtl #wp-image-toolbar div {
     474.rtl #wp-image-toolbar i {
    475475    margin-left: auto;
    476476    margin-right: 7px;
Note: See TracChangeset for help on using the changeset viewer.