TinyMCE:
- Prevent applying Indent and Outdent while an image with a caption is selected. It doesn't do anything and breaks the caption elements. - Keep all of the text when a caption `<dl>` was somehow changed. Fixes #38313. Built from https://develop.svn.wordpress.org/trunk@38796 git-svn-id: http://core.svn.wordpress.org/trunk@38739 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
da4da31af1
commit
e2e22580db
|
@ -181,16 +181,10 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
|||
return content.replace( /(?:<div [^>]+mceTemp[^>]+>)?\s*(<dl [^>]+wp-caption[^>]+>[\s\S]+?<\/dl>)\s*(?:<\/div>)?/g, function( all, dl ) {
|
||||
var out = '';
|
||||
|
||||
if ( dl.indexOf('<img ') === -1 ) {
|
||||
// Broken caption. The user managed to drag the image out?
|
||||
// Try to return the caption text as a paragraph.
|
||||
out = dl.match( /<dd [^>]+>([\s\S]+?)<\/dd>/i );
|
||||
|
||||
if ( out && out[1] ) {
|
||||
return '<p>' + out[1] + '</p>';
|
||||
}
|
||||
|
||||
return '';
|
||||
if ( dl.indexOf('<img ') === -1 || dl.indexOf('</p>') !== -1 ) {
|
||||
// Broken caption. The user managed to drag the image out or type in the wrapper div?
|
||||
// Remove the <dl>, <dd> and <dt> and return the remaining text.
|
||||
return dl.replace( /<d[ldt]( [^>]+)?>/g, '' ).replace( /<\/d[ldt]>/g, '' );
|
||||
}
|
||||
|
||||
out = dl.replace( /\s*<dl ([^>]+)>\s*<dt [^>]+>([\s\S]+?)<\/dt>\s*<dd [^>]+>([\s\S]*?)<\/dd>\s*<\/dl>\s*/gi, function( a, b, c, caption ) {
|
||||
|
@ -896,26 +890,34 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
|||
cmd = event.command,
|
||||
dom = editor.dom;
|
||||
|
||||
if ( cmd === 'mceInsertContent' ) {
|
||||
if ( cmd === 'mceInsertContent' || cmd === 'Indent' || cmd === 'Outdent' ) {
|
||||
node = editor.selection.getNode();
|
||||
captionParent = dom.getParent( node, 'div.mceTemp' );
|
||||
|
||||
if ( captionParent ) {
|
||||
if ( pasteInCaption ) {
|
||||
pasteInCaption = false;
|
||||
// We are in the caption element, and in 'paste' context,
|
||||
// and the pasted HTML was cleaned up on 'pastePostProcess' above.
|
||||
// Let it be pasted in the caption.
|
||||
return;
|
||||
}
|
||||
if ( cmd === 'mceInsertContent' ) {
|
||||
if ( pasteInCaption ) {
|
||||
pasteInCaption = false;
|
||||
// We are in the caption element, and in 'paste' context,
|
||||
// and the pasted HTML was cleaned up on 'pastePostProcess' above.
|
||||
// Let it be pasted in the caption.
|
||||
return;
|
||||
}
|
||||
|
||||
// The paste is somewhere else in the caption DL element.
|
||||
// Prevent pasting in there as it will break the caption.
|
||||
// Make new paragraph under the caption DL and move the caret there.
|
||||
p = dom.create( 'p' );
|
||||
dom.insertAfter( p, captionParent );
|
||||
editor.selection.setCursorLocation( p, 0 );
|
||||
editor.nodeChanged();
|
||||
// The paste is somewhere else in the caption DL element.
|
||||
// Prevent pasting in there as it will break the caption.
|
||||
// Make new paragraph under the caption DL and move the caret there.
|
||||
p = dom.create( 'p' );
|
||||
dom.insertAfter( p, captionParent );
|
||||
editor.selection.setCursorLocation( p, 0 );
|
||||
editor.nodeChanged();
|
||||
} else {
|
||||
// Clicking Indent or Outdent while an image with a caption is selected breaks the caption.
|
||||
// See #38313.
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if ( cmd === 'JustifyLeft' || cmd === 'JustifyRight' || cmd === 'JustifyCenter' || cmd === 'wpAlignNone' ) {
|
||||
node = editor.selection.getNode();
|
||||
|
|
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.7-alpha-38795';
|
||||
$wp_version = '4.7-alpha-38796';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue