diff --git a/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js b/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js index 1bc5a6cfeb..b3eae05d48 100644 --- a/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js @@ -49,12 +49,21 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { function getShortcode( content ) { return content.replace( /
' + out[1] + '
' + } + return ''; } - var ret = b.replace( / with the caption text.
- ret = b.replace( /[\s\S]*?((?:]+>)?]+>(?:<\/a>)?)( [\s\S]*<\/p>)?[\s\S]*/gi, ' $1 [\s\S]*<\/p>)?[\s\S]*/gi, ' $1 /, '' ).replace( /<\/p>$/, '' );
+ }
}
});
+ caption = caption.replace( /(
]*>)\s*\n\s*/g, '$1' ).replace( /\s*\n\s*/g, '
' );
+ }
+
if ( ! imgNode ) {
// New image inserted
html = dom.createHTML( 'img', data );
@@ -294,7 +313,11 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
if ( parent = dom.getParent( imgNode, 'dl.wp-caption' ) ) {
parent = dom.select( 'dd.wp-caption-dd', parent )[0];
- data.caption = parent ? parent.innerHTML : '';
+
+ if ( parent ) {
+ data.caption = editor.serializer.serialize( parent )
+ .replace( /
]*>/g, '$&\n' ).replace( /^