Ticket #46085: 46085.1.diff
File 46085.1.diff, 3.0 KB (added by , 6 years ago) |
---|
-
src/js/_enqueues/vendor/tinymce/plugins/wpeditimage/plugin.js
347 347 return serializer.serialize( editor.parser.parse( caption, { forced_root_block: false } ) ); 348 348 } 349 349 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, 352 352 captionNode, dd, dl, id, attrs, linkAttrs, width, height, align, 353 353 $imageNode, srcset, src, 354 354 dom = editor.dom; 355 355 356 if ( ! $imageNode.length ) { 357 return; 358 } 359 360 imageNode = $imageNode[0]; 356 361 classes = tinymce.explode( imageData.extraClasses, ' ' ); 357 362 358 363 if ( ! classes ) { … … 389 394 dom.setAttribs( imageNode, attrs ); 390 395 391 396 // Preserve empty alt attributes. 392 editor.$( imageNode ).attr( 'alt', imageData.alt || '' );397 $imageNode.attr( 'alt', imageData.alt || '' ); 393 398 394 399 linkAttrs = { 395 400 href: imageData.linkUrl, … … 513 518 } 514 519 515 520 function editImage( img ) { 516 var frame, callback, metadata ;521 var frame, callback, metadata, imageNode; 517 522 518 523 if ( typeof wp === 'undefined' || ! wp.media ) { 519 524 editor.execCommand( 'mceImage' ); … … 522 527 523 528 metadata = extractImageData( img ); 524 529 530 // Mark the image node so we can select it later. 531 editor.$( img ).attr( 'data-wp-editing', 1 ); 532 525 533 // Manipulate the metadata by reference that is fed into the PostImage model used in the media modal 526 534 wp.media.events.trigger( 'editor:image-edit', { 527 535 editor: editor, … … 538 546 wp.media.events.trigger( 'editor:frame-create', { frame: frame } ); 539 547 540 548 callback = function( imageData ) { 541 editor.focus();542 549 editor.undoManager.transact( function() { 543 updateImage( im g, imageData );550 updateImage( imageNode, imageData ); 544 551 } ); 545 552 frame.detach(); 546 553 }; … … 550 557 frame.on( 'close', function() { 551 558 editor.focus(); 552 559 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' ); 553 566 }); 554 567 555 568 frame.open(); … … 810 823 811 824 editor.on( 'beforeGetContent', function( event ) { 812 825 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' ); 814 827 } 815 828 }); 816 829 -
src/wp-includes/css/editor.css
1211 1211 content: "\f104"; 1212 1212 } 1213 1213 1214 .mce-content-body dl.wp-caption { 1215 max-width: 100%; 1216 } 1217 1214 1218 /* Quicktags */ 1215 1219 .quicktags-toolbar { 1216 1220 padding: 3px;