From ee2ffd6ba256a1793dd4ae61842582f2c4e363ab Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Thu, 18 May 2017 22:24:57 +0000 Subject: [PATCH] TinyMCE: fix pasting while an image with caption is selected. The image and the caption should be replaced with the pasted content. Fixes #40809. git-svn-id: https://develop.svn.wordpress.org/trunk@40786 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js b/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js index 7f13d84357..fd6de50fc0 100644 --- a/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js @@ -912,6 +912,14 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { p = dom.create( 'p' ); dom.insertAfter( p, captionParent ); editor.selection.setCursorLocation( p, 0 ); + + // If the image is selected and the user pastes "over" it, + // replace both the image and the caption elements with the pasted content. + // This matches the behavior when pasting over non-caption images. + if ( node.nodeName === 'IMG' ) { + editor.$( captionParent ).remove(); + } + editor.nodeChanged(); } else { // Clicking Indent or Outdent while an image with a caption is selected breaks the caption.