diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js --- a/wp/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js Tue Oct 22 16:11:46 2019 +0200 +++ b/wp/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js Tue Dec 15 13:49:49 2020 +0100 @@ -18,7 +18,7 @@ } ); editor.addButton( 'wp_img_edit', { - tooltip: 'Edit|button', // '|button' is not displayed, only used for context + tooltip: 'Edit|button', // '|button' is not displayed, only used for context. icon: 'dashicon dashicons-edit', onclick: function() { editImage( editor.selection.getNode() ); @@ -146,7 +146,7 @@ caption = trim( img[2] ); img = trim( img[1] ); } else { - // old captions shortcode style + // Old captions shortcode style. caption = trim( b ).replace( /caption=['"]/, '' ).replace( /['"]$/, '' ); img = c; } @@ -214,18 +214,18 @@ } caption = caption.replace( /\r\n|\r/g, '\n' ).replace( /<[a-zA-Z0-9]+( [^<>]+)?>/g, function( a ) { - // no line breaks inside HTML tags + // No line breaks inside HTML tags. return a.replace( /[\r\n\t]+/, ' ' ); }); - // convert remaining line breaks to
+ // Convert remaining line breaks to
. caption = caption.replace( /\s*\n\s*/g, '
' ); return '[caption id="' + id + '" align="' + align + '" width="' + width + '"' + classes + ']' + c + ' ' + caption + '[/caption]'; }); if ( out.indexOf('[caption') === -1 ) { - // the caption html seems broken, try to find the image that may be wrapped in a link + // The caption html seems broken, try to find the image that may be wrapped in a link // and may be followed by

with the caption text. out = dl.replace( /[\s\S]*?((?:]+>)?]+>(?:<\/a>)?)(

[\s\S]*<\/p>)?[\s\S]*/gi, '

$1

$2' ); } @@ -240,7 +240,7 @@ dom = editor.dom, isIntRegExp = /^\d+$/; - // default attributes + // Default attributes. metadata = { attachment_id: false, size: 'custom', @@ -292,7 +292,7 @@ metadata.extraClasses = extraClasses.join( ' ' ); - // Extract caption + // Extract caption. captionBlock = dom.getParents( imageNode, '.wp-caption' ); if ( captionBlock.length ) { @@ -318,7 +318,7 @@ } } - // Extract linkTo + // Extract linkTo. if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' ) { link = imageNode.parentNode; metadata.linkUrl = dom.getAttrib( link, 'href' ); @@ -334,7 +334,7 @@ return node && !! ( node.textContent || node.innerText ).replace( /\ufeff/g, '' ); } - // Verify HTML in captions + // Verify HTML in captions. function verifyHTML( caption ) { if ( ! caption || ( caption.indexOf( '<' ) === -1 && caption.indexOf( '>' ) === -1 ) ) { return caption; @@ -404,7 +404,7 @@ }; if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' && ! hasTextContent( imageNode.parentNode ) ) { - // Update or remove an existing link wrapped around the image + // Update or remove an existing link wrapped around the image. if ( imageData.linkUrl ) { dom.setAttribs( imageNode.parentNode, linkAttrs ); } else { @@ -413,11 +413,11 @@ } else if ( imageData.linkUrl ) { if ( linkNode = dom.getParent( imageNode, 'a' ) ) { // The image is inside a link together with other nodes, - // or is nested in another node, move it out + // or is nested in another node, move it out. dom.insertAfter( imageNode, linkNode ); } - // Add link wrapped around the image + // Add link wrapped around the image. linkNode = dom.create( 'a', linkAttrs ); imageNode.parentNode.insertBefore( linkNode, imageNode ); linkNode.appendChild( imageNode ); @@ -467,7 +467,7 @@ } else { id = id ? 'id="'+ id +'" ' : ''; - // should create a new function for generating the caption markup + // Should create a new function for generating the caption markup. html = '
' + '
'+ imageData.caption +'
'; @@ -486,7 +486,7 @@ } } } else if ( captionNode ) { - // Remove the caption wrapper and place the image in new paragraph + // Remove the caption wrapper and place the image in new paragraph. parent = dom.create( 'p' ); captionNode.parentNode.insertBefore( parent, captionNode ); parent.appendChild( node ); @@ -530,7 +530,7 @@ // Mark the image node so we can select it later. editor.$( img ).attr( 'data-wp-editing', 1 ); - // Manipulate the metadata by reference that is fed into the PostImage model used in the media modal + // Manipulate the metadata by reference that is fed into the PostImage model used in the media modal. wp.media.events.trigger( 'editor:image-edit', { editor: editor, metadata: metadata, @@ -558,9 +558,11 @@ editor.focus(); frame.detach(); - // `close` fires first... - // To be able to update the image node, we need to find it here, - // and use it in the callback. + /* + * `close` fires first... + * To be able to update the image node, we need to find it here, + * and use it in the callback. + */ imageNode = editor.$( 'img[data-wp-editing]' ) imageNode.removeAttr( 'data-wp-editing' ); }); @@ -600,12 +602,12 @@ dom.addClass( editor.getBody(), captionClass ); - // Prevent IE11 from making dl.wp-caption resizable + // Prevent IE11 from making dl.wp-caption resizable. if ( tinymce.Env.ie && tinymce.Env.ie > 10 ) { - // The 'mscontrolselect' event is supported only in IE11+ + // The 'mscontrolselect' event is supported only in IE11+. dom.bind( editor.getBody(), 'mscontrolselect', function( event ) { if ( event.target.nodeName === 'IMG' && dom.getParent( event.target, '.wp-caption' ) ) { - // Hide the thick border with resize handles around dl.wp-caption + // Hide the thick border with resize handles around dl.wp-caption. editor.getBody().focus(); // :( } else if ( event.target.nodeName === 'DL' && dom.hasClass( event.target, 'wp-caption' ) ) { // Trigger the thick border with resize handles... @@ -688,25 +690,31 @@ 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. + /* + * 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. + /* + * 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 ); - // 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 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.$( captionParent ).remove(); + } editor.nodeChanged(); } else { @@ -759,7 +767,7 @@ VK = tinymce.util.VK; if ( keyCode === VK.ENTER ) { - // When pressing Enter inside a caption move the caret to a new parapraph under it + // When pressing Enter inside a caption move the caret to a new parapraph under it. node = selection.getNode(); wrap = dom.getParent( node, 'div.mceTemp' ); @@ -802,9 +810,11 @@ } }); - // After undo/redo FF seems to set the image height very slowly when it is set to 'auto' in the CSS. - // This causes image.getBoundingClientRect() to return wrong values and the resize handles are shown in wrong places. - // Collapse the selection to remove the resize handles. + /* + * After undo/redo FF seems to set the image height very slowly when it is set to 'auto' in the CSS. + * This causes image.getBoundingClientRect() to return wrong values and the resize handles are shown in wrong places. + * Collapse the selection to remove the resize handles. + */ if ( tinymce.Env.gecko ) { editor.on( 'undo redo', function() { if ( editor.selection.getNode().nodeName === 'IMG' ) { @@ -878,7 +888,7 @@ } ); } )(); - // Add to editor.wp + // Add to editor.wp. editor.wp = editor.wp || {}; editor.wp.isPlaceholder = isPlaceholder;