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