diff --git a/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js b/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js index 050a1f53f6..8894cd8f57 100644 --- a/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js +++ b/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js @@ -320,7 +320,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { if ( parent = dom.getParent( node, 'p' ) ) { wrap = dom.create( 'div', { 'class': 'mceTemp' }, html ); - dom.insertAfter( wrap, parent ); + parent.parentNode.insertBefore( wrap, parent ); dom.remove( node ); if ( dom.isEmpty( parent ) ) { @@ -593,7 +593,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { if ( parent && parent.nodeName === 'P' ) { wrap = dom.create( 'div', { 'class': 'mceTemp' }, html ); - dom.insertAfter( wrap, parent ); + parent.parentNode.insertBefore( wrap, parent ); editor.selection.select( wrap ); editor.nodeChanged(); diff --git a/wp-includes/js/tinymce/plugins/wpeditimage/plugin.min.js b/wp-includes/js/tinymce/plugins/wpeditimage/plugin.min.js index e126ebe26a..7445d5a889 100644 --- a/wp-includes/js/tinymce/plugins/wpeditimage/plugin.min.js +++ b/wp-includes/js/tinymce/plugins/wpeditimage/plugin.min.js @@ -1 +1 @@ -tinymce.PluginManager.add("wpeditimage",function(a){function b(b){return b.replace(/(?:
)?\[(?:wp_)?caption([^\]]+)\]([\s\S]+?)\[\/(?:wp_)?caption\](?:<\/p>)?/g,function(b,c,d){var e,f,g,h,i,j,k=tinymce.trim;return e=c.match(/id=['"]([^'"]*)['"] ?/),e&&(c=c.replace(e[0],"")),f=c.match(/align=['"]([^'"]*)['"] ?/),f&&(c=c.replace(f[0],"")),g=c.match(/width=['"]([0-9]*)['"] ?/),g&&(c=c.replace(g[0],"")),d=k(d),i=d.match(/((?:]+>)?]+>(?:<\/a>)?)([\s\S]*)/i),i&&i[2]?(h=k(i[2]),i=k(i[1])):(h=k(c).replace(/caption=['"]/,"").replace(/['"]$/,""),i=d),e=e&&e[1]?e[1]:"",f=f&&f[1]?f[1]:"alignnone",!g&&i&&(g=i.match(/width=['"]([0-9]*)['"]/)),g&&g[1]&&(g=g[1]),g&&h?(j=parseInt(g,10),a.getParam("wpeditimage_html5_captions")||(j+=10),' "+c[1]+" [\s\S]*<\/p>)?[\s\S]*/gi," $1 /,"").replace(/<\/p>$/,""))),b.parentNode&&"A"===b.parentNode.nodeName&&(h=b.parentNode,e.linkUrl=k.getAttrib(h,"href"),e.linkTargetBlank="_blank"===k.getAttrib(h,"target")?!0:!1,e.linkRel=k.getAttrib(h,"rel"),e.linkClassName=h.className),e}function e(a){return a&&!(!a.textContent&&!a.innerText)}function f(b,c){var d,f,g,h,j,k,l,m,n,o,p,q,r,s,t,u=a.dom;d=tinymce.explode(c.extraClasses," "),d||(d=[]),c.caption||d.push("align"+c.align),c.attachment_id&&(d.push("wp-image-"+c.attachment_id),c.size&&"custom"!==c.size&&d.push("size-"+c.size)),s=c.width,t=c.height,"custom"===c.size&&(s=c.customWidth,t=c.customHeight),q={src:c.url,width:s||null,height:t||null,alt:c.alt,title:c.title||null,"class":d.join(" ")||null},u.setAttribs(b,q),r={href:c.linkUrl,rel:c.linkRel||null,target:c.linkTargetBlank?"_blank":null,"class":c.linkClassName||null},b.parentNode&&"A"===b.parentNode.nodeName&&!e(b.parentNode)?c.linkUrl?u.setAttribs(b.parentNode,r):u.remove(b.parentNode,!0):c.linkUrl&&((l=u.getParent(b,"a"))&&u.insertAfter(b,l),l=u.create("a",r),b.parentNode.insertBefore(l,b),l.appendChild(b)),m=a.dom.getParent(b,".mceTemp"),g=b.parentNode&&"A"===b.parentNode.nodeName&&!e(b.parentNode)?b.parentNode:b,c.caption?(p=c.attachment_id?"attachment_"+c.attachment_id:null,f="wp-caption align"+(c.align||"none"),a.getParam("wpeditimage_html5_captions")||(s=parseInt(s,10),s+=10),m?(o=u.select("dl.wp-caption",m),o.length&&u.setAttribs(o,{id:p,"class":f,style:"width: "+s+"px"}),n=u.select(".wp-caption-dd",m),n.length&&u.setHTML(n[0],c.caption)):(p=p?'id="'+p+'" ':"",h=" /,"").replace(/<\/p>$/,"")))}),b.bind(a.getDoc(),"dragstart",function(c){var d=a.selection.getNode();"IMG"===d.nodeName&&b.getParent(d,".wp-caption")&&c.preventDefault(),j()}),tinymce.Env.ie&&tinymce.Env.ie>10&&(b.bind(a.getBody(),"mscontrolselect",function(c){"IMG"===c.target.nodeName&&b.getParent(c.target,".wp-caption")?a.getBody().focus():"DL"===c.target.nodeName&&b.hasClass(c.target,"wp-caption")&&c.target.focus()}),a.on("click",function(c){"IMG"===c.target.nodeName&&b.getAttrib(c.target,"data-wp-imgselect")&&b.getParent(c.target,"dl.wp-caption")&&a.getBody().focus()}))}),a.on("ObjectResized",function(b){var c,d,e=b.target,f=a.dom;"IMG"===e.nodeName&&(e.className=e.className.replace(/\bsize-[^ ]+/,""),(c=f.getParent(e,".wp-caption"))&&(d=b.width||f.getAttrib(e,"width"),d&&(d=parseInt(d,10),a.getParam("wpeditimage_html5_captions")||(d+=10),f.setStyle(c,"width",d+"px"))),i(e))}),a.on("BeforeExecCommand",function(b){var c,d,e,f,g=b.command,h=a.dom;if("mceInsertContent"===g){if((c=h.getParent(a.selection.getNode(),"div.mceTemp"))&&(d=h.create("p"),h.insertAfter(d,c),a.selection.setCursorLocation(d,0),a.nodeChanged(),tinymce.Env.ie>8))return setTimeout(function(){a.selection.setCursorLocation(d,0),a.selection.setContent(b.value)},500),!1}else if("JustifyLeft"===g||"JustifyRight"===g||"JustifyCenter"===g){if(c=a.selection.getNode(),f=g.substr(7).toLowerCase(),f="align"+f,j(),e=h.is(c,"dl.wp-caption")?c:h.getParent(c,"dl.wp-caption"))return h.hasClass(e,f)?(h.removeClass(e,f),h.addClass(e,"alignnone")):(e.className=e.className.replace(/align[^ ]+/g,""),h.addClass(e,f)),!1;"IMG"===c.nodeName&&(h.hasClass(c,f)?h.addClass(c,"alignnone"):h.removeClass(c,"alignnone"))}}),a.on("keydown",function(b){var c,d,e,f,g=a.selection,i=b.keyCode,k=a.dom;if(i===tinymce.util.VK.ENTER)c=g.getNode(),d=k.getParent(c,"div.mceTemp"),d&&(k.events.cancel(b),tinymce.each(k.select("dt, dd",d),function(a){k.isEmpty(a)&&k.remove(a)}),f=tinymce.Env.ie&&tinymce.Env.ie<11?"":' )?\[(?:wp_)?caption([^\]]+)\]([\s\S]+?)\[\/(?:wp_)?caption\](?:<\/p>)?/g,function(b,c,d){var e,f,g,h,i,j,k=tinymce.trim;return e=c.match(/id=['"]([^'"]*)['"] ?/),e&&(c=c.replace(e[0],"")),f=c.match(/align=['"]([^'"]*)['"] ?/),f&&(c=c.replace(f[0],"")),g=c.match(/width=['"]([0-9]*)['"] ?/),g&&(c=c.replace(g[0],"")),d=k(d),i=d.match(/((?:]+>)?]+>(?:<\/a>)?)([\s\S]*)/i),i&&i[2]?(h=k(i[2]),i=k(i[1])):(h=k(c).replace(/caption=['"]/,"").replace(/['"]$/,""),i=d),e=e&&e[1]?e[1]:"",f=f&&f[1]?f[1]:"alignnone",!g&&i&&(g=i.match(/width=['"]([0-9]*)['"]/)),g&&g[1]&&(g=g[1]),g&&h?(j=parseInt(g,10),a.getParam("wpeditimage_html5_captions")||(j+=10),']+)>\s*
"),'[caption id="'+e+'" align="'+f+'" width="'+g+'"]'+c+" "+d+"[/caption]"):c}),0!==c.indexOf("[caption")&&(c=b.replace(/[\s\S]*?((?:]+>)?]+>(?:<\/a>)?)(
]*>/g,"$&\n").replace(/^",(j=u.getParent(g,"p"))?(k=u.create("div",{"class":"mceTemp"},h),u.insertAfter(k,j),u.remove(g),u.isEmpty(j)&&u.remove(j)):u.setOuterHTML(g,'
]*>)\s*\n\s*/g,"$1").replace(/\s*\n\s*/g,"
")),j?(h=j.id||null,b.setAttribs(j,i),d=b.getParent(j,"dl.wp-caption"),k?d?(e=b.select("dd.wp-caption-dd",d)[0])&&(e.innerHTML=k):(j.className&&(l=j.className.match(/wp-image-([0-9]+)/),m=j.className.match(/align(left|right|center|none)/)),m?(m=m[0],j.className=j.className.replace(/align(left|right|center|none)/g,"")):m="alignnone",m=' class="wp-caption '+m+'"',l&&(l=' id="attachment_'+l[1]+'"'),n=i.width||j.clientWidth,n&&(n=parseInt(n,10),a.getParam("wpeditimage_html5_captions")||(n+=10),n=' style="width: '+n+'px"'),j.parentNode&&"A"===j.parentNode.nodeName?(g=b.getOuterHTML(j.parentNode),f=j.parentNode):(g=b.getOuterHTML(j),f=j),g="",(e=b.getParent(j,"p"))?(d=b.create("div",{"class":"mceTemp"},g),b.insertAfter(d,e),a.selection.select(d),a.nodeChanged(),b.remove(f),b.isEmpty(e)&&b.remove(e)):a.selection.setContent('
]*>/g,"$&\n").replace(/^
',e=k.create("p",null,f),"DD"===c.nodeName?k.insertAfter(e,d):d.parentNode.insertBefore(e,d),a.nodeChanged(),g.setCursorLocation(e,0));else if(i===tinymce.util.VK.DELETE||i===tinymce.util.VK.BACKSPACE){if(c=g.getNode(),"DIV"===c.nodeName&&k.hasClass(c,"mceTemp")?d=c:("IMG"===c.nodeName||"DT"===c.nodeName||"A"===c.nodeName)&&(d=k.getParent(c,"div.mceTemp")),d)return k.events.cancel(b),h(c),!1;j()}if(l){if(b.ctrlKey||b.metaKey||b.altKey||48>i&&i>90||i>186)return;j()}}),a.on("mousedown",function(b){a.dom.getParent(b.target,"#wp-image-toolbar")?tinymce.Env.ie&&b.preventDefault():"IMG"!==b.target.nodeName&&j()}),a.on("mouseup",function(b){var c,d=b.target,e=a.dom;b.button&&b.button>1||("DIV"===d.nodeName&&e.getParent(d,"#wp-image-toolbar")?(c=e.select("img[data-wp-imgselect]")[0],c&&(a.selection.select(c),e.hasClass(d,"remove")?h(c):e.hasClass(d,"edit")&&g(c))):"IMG"!==d.nodeName||a.dom.getAttrib(d,"data-wp-imgselect")||k(d)?"IMG"!==d.nodeName&&j():i(d))}),a.on("cut",function(){j()}),a.wpSetImgCaption=function(a){return b(a)},a.wpGetImgCaption=function(a){return c(a)},a.on("BeforeSetContent",function(b){b.content=a.wpSetImgCaption(b.content)}),a.on("PostProcess",function(b){b.get&&(b.content=a.wpGetImgCaption(b.content),b.content=b.content.replace(/ data-wp-imgselect="1"/g,""))}),{_do_shcode:b,_get_shcode:c}});
\ No newline at end of file
+tinymce.PluginManager.add("wpeditimage",function(a){function b(b){return b.replace(/(?: