diff --git a/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js b/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js index f771fc9396..71819e25ec 100644 --- a/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js +++ b/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js @@ -11,24 +11,7 @@ t.editor = ed; t._createButtons(); - // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...'); - ed.addCommand('WP_EditImage', function() { - var el = ed.selection.getNode(), vp, H, W, cls = ed.dom.getAttrib(el, 'class'); - - if ( cls.indexOf('mceItem') != -1 || cls.indexOf('wpGallery') != -1 || el.nodeName != 'IMG' ) - return; - - vp = tinymce.DOM.getViewPort(); - H = 680 < (vp.h - 70) ? 680 : vp.h - 70; - W = 650 < vp.w ? 650 : vp.w; - - ed.windowManager.open({ - file: url + '/editimage.html', - width: W+'px', - height: H+'px', - inline: true - }); - }); + ed.addCommand('WP_EditImage', t._editImage); ed.onInit.add(function(ed) { ed.dom.events.add(ed.getBody(), 'dragstart', function(e) { @@ -38,6 +21,27 @@ ed.selection.select(parent); } }); + + // when pressing Return inside a caption move the caret to a new parapraph under it + ed.dom.events.add(ed.getBody(), 'keydown', function(e) { + var n, DL, DIV, P, content; + + if ( e.keyCode == 13 ) { + n = ed.selection.getNode(); + DL = ed.dom.getParent(n, 'dl.wp-caption'); + + if ( DL ) + DIV = ed.dom.getParent(DL, 'div.mceTemp'); + + if ( DIV ) { + ed.dom.events.cancel(e); + P = ed.dom.create('p', {}, '\uFEFF'); + ed.dom.insertAfter( P, DIV ); + ed.selection.setCursorLocation(P, 0); + return false; + } + } + }); }); // resize the caption
when the image is soft-resized by the user (only possible in Firefox and IE) @@ -90,35 +94,6 @@ } }); - // when pressing Return inside a caption move the caret to a new parapraph under it - ed.onKeyPress.add(function(ed, e) { - var n, DL, DIV, P; - - if ( e.keyCode == 13 ) { - n = ed.selection.getNode(); - DL = ed.dom.getParent(n, 'dl.wp-caption'); - - if ( DL ) - DIV = ed.dom.getParent(DL, 'div.mceTemp'); - - if ( DIV ) { - P = ed.dom.create('p', {}, '
'); - ed.dom.insertAfter( P, DIV ); - ed.selection.select(P.firstChild); - - if ( tinymce.isIE ) { - ed.selection.setContent(''); - } else { - ed.selection.setContent('
'); - ed.selection.setCursorLocation(P, 0); - } - - ed.dom.events.cancel(e); - return false; - } - } - }); - ed.onBeforeSetContent.add(function(ed, o) { o.content = ed.wpSetImgCaption(o.content); }); @@ -239,9 +214,7 @@ }); tinymce.dom.Event.add(editButton, 'mousedown', function(e) { - var ed = tinyMCE.activeEditor; - ed.windowManager.bookmark = ed.selection.getBookmark('simple'); - ed.execCommand("WP_EditImage"); + t._editImage(); }); dellButton = DOM.add('wp_editbtns', 'img', { @@ -268,6 +241,24 @@ } }); }, + + _editImage : function() { + var ed = this.editor, url = this.url, el = ed.selection.getNode(), vp, H, W, cls = el.className; + + if ( cls.indexOf('mceItem') != -1 || cls.indexOf('wpGallery') != -1 || el.nodeName != 'IMG' ) + return; + + vp = tinymce.DOM.getViewPort(); + H = 680 < (vp.h - 70) ? 680 : vp.h - 70; + W = 650 < vp.w ? 650 : vp.w; + + ed.windowManager.open({ + file: url + '/editimage.html', + width: W+'px', + height: H+'px', + inline: true + }); + }, getInfo : function() { return {